Action_Scheduler\WP_CLI\Action

Delete_Command::execute()publicWC 1.0

Execute.

Method of the class: Delete_Command{}

No Hooks.

Return

null. Nothing (null).

Usage

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

Delete_Command::execute() code WC 9.8.1

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

	$progress_bar = \WP_CLI\Utils\make_progress_bar(
		sprintf(
			/* translators: %d: number of actions to be deleted */
			_n( 'Deleting %d action', 'Deleting %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 ) {
		try {
			$store->delete_action( $action_id );
		} catch ( \Exception $e ) {
			$this->action_counts['failed']++;
			\WP_CLI::warning( $e->getMessage() );
		}

		$progress_bar->tick();
	}

	$progress_bar->finish();

	/* translators: %1$d: number of actions deleted */
	$format = _n( 'Deleted %1$d action', 'Deleted %1$d actions', $this->action_counts['deleted'], 'woocommerce' ) . ', ';
	/* translators: %2$d: number of actions deletions failed */
	$format .= _n( '%2$d failure.', '%2$d failures.', $this->action_counts['failed'], 'woocommerce' );

	\WP_CLI::success(
		sprintf(
			$format,
			number_format_i18n( $this->action_counts['deleted'] ),
			number_format_i18n( $this->action_counts['failed'] )
		)
	);
}