HEX
Server: LiteSpeed
System: Linux php-prod-3.spaceapp.ru 5.15.0-151-generic #161-Ubuntu SMP Tue Jul 22 14:25:40 UTC 2025 x86_64
User: sarli3128 (1010)
PHP: 7.4.33
Disabled: pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,pcntl_unshare,
Upload Files
File: /home/sarlight.ru/public_html/wp-content/plugins/cyr2lat/includes/class-cyr-to-lat-wp-cli.php
<?php
/**
 * WP-CLI support.
 *
 * @package cyr-to-lat
 * @link    https://github.com/mihdan/wp-rocket-cli/blob/master/command.php
 */

/**
 * Class Cyr_To_Lat_WP_CLI
 *
 * @class Cyr_To_Lat_WP_CLI
 */
class Cyr_To_Lat_WP_CLI extends WP_CLI_Command {

	/**
	 * Converter class.
	 *
	 * @var Cyr_To_Lat_Converter
	 */
	private $converter;

	/**
	 * Cyr_To_Lat_WP_CLI constructor.
	 *
	 * @param Cyr_To_Lat_Converter $converter Converter.
	 */
	public function __construct( Cyr_To_Lat_Converter $converter ) {
		parent::__construct();
		$this->converter = $converter;
	}

	/**
	 * Regenerate old slugs.
	 *
	 * ## EXAMPLES
	 *
	 *     $ wp cyr2lat regenerate
	 *     Success: Regenerate Completed.
	 *
	 * @subcommand regenerate
	 *
	 * @param array $args       Arguments.
	 * @param array $assoc_args Arguments in associative array.
	 */
	public function regenerate( $args = array(), $assoc_args = array() ) {

		/**
		 * Notify instance.
		 *
		 * @var \cli\progress\Bar $notify
		 */
		$notify = $this->make_progress_bar();

		$result = array();

		if ( ! empty( $assoc_args['post_status'] ) ) {
			$result['post_status'] = explode( ',', $assoc_args['post_status'] );
			$result['post_status'] = array_values( array_filter( array_map( 'trim', $result['post_status'] ) ) );
		}

		if ( ! empty( $assoc_args['post_type'] ) ) {
			$result['post_type'] = explode( ',', $assoc_args['post_type'] );
			$result['post_type'] = array_values( array_filter( array_map( 'trim', $result['post_type'] ) ) );
		}

		$this->converter->convert_existing_slugs( $result );
		$notify->tick();
		$notify->finish();

		WP_CLI::success( 'Regenerate Completed.' );
	}

	/**
	 * Make progress bar.
	 *
	 * @return \cli\progress\Bar|\WP_CLI\NoOp
	 */
	protected function make_progress_bar() {
		return \WP_CLI\Utils\make_progress_bar( 'Regenerate existing slugs', 1 );
	}
}