WP_CLI\Bootstrap

RegisterDeferredCommands::add_deferred_commands()publicWP-CLI 1.0

Add deferred commands that are still waiting to be processed.

Метод класса: RegisterDeferredCommands{}

Хуков нет.

Возвращает

null. Ничего (null).

Использование

$RegisterDeferredCommands = new RegisterDeferredCommands();
$RegisterDeferredCommands->add_deferred_commands();

Код RegisterDeferredCommands::add_deferred_commands() WP-CLI 2.8.0-alpha

public function add_deferred_commands() {
	$deferred_additions = WP_CLI::get_deferred_additions();

	foreach ( $deferred_additions as $name => $addition ) {
		$addition_data = [];
		foreach ( $addition as $addition_key => $addition_value ) {
			// Describe the callable as a string instead of directly printing it
			// for better debug info.
			if ( 'callable' === $addition_key ) {
				$addition_value = Utils\describe_callable( $addition_value );

			} elseif ( is_array( $addition_value ) ) {
				$addition_value = json_encode( $addition_value );
			}

			$addition_data[] = sprintf(
				'%s: %s',
				$addition_key,
				$addition_value
			);
		}

		WP_CLI::debug(
			sprintf(
				'Adding deferred command: %s (%s)',
				$name,
				implode( ', ', $addition_data )
			),
			'bootstrap'
		);

		WP_CLI::add_command(
			$name,
			$addition['callable'],
			$addition['args']
		);
	}
}