Action_Scheduler\WP_CLI\Action

Run_Command::execute()publicWC 1.0

Execute.

Method of the class: Run_Command{}

No Hooks.

Return

null. Nothing (null).

Usage

$Run_Command = new Run_Command();
$Run_Command->execute();

Run_Command::execute() code WC 9.8.1

public function execute() {
	$runner = \ActionScheduler::runner();

	$progress_bar = \WP_CLI\Utils\make_progress_bar(
		sprintf(
			/* translators: %d: number of actions */
			_n( 'Executing %d action', 'Executing %d actions', $this->action_counts['total'], 'woocommerce' ),
			number_format_i18n( $this->action_counts['total'] )
		),
		$this->action_counts['total']
	);

	foreach ( $this->action_ids as $action_id ) {
		$runner->process_action( $action_id, 'Action Scheduler CLI' );
		$progress_bar->tick();
	}

	$progress_bar->finish();

	foreach ( array(
		'ignored',
		'invalid',
		'failed',
	) as $type ) {
		$count = $this->action_counts[ $type ];

		if ( empty( $count ) ) {
			continue;
		}

		/*
		 * translators:
		 * %1$d: count of actions evaluated.
		 * %2$s: type of action evaluated.
		 */
		$format = _n( '%1$d action %2$s.', '%1$d actions %2$s.', $count, 'woocommerce' );

		\WP_CLI::warning(
			sprintf(
				$format,
				number_format_i18n( $count ),
				$type
			)
		);
	}

	\WP_CLI::success(
		sprintf(
			/* translators: %d: number of executed actions */
			_n( 'Executed %d action.', 'Executed %d actions.', $this->action_counts['executed'], 'woocommerce' ),
			number_format_i18n( $this->action_counts['executed'] )
		)
	);
}