Automattic\WooCommerce\Admin\PluginsInstallLoggers

AsyncPluginsInstallLogger::__construct()publicWC 1.0

Constructor.

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

Хуков нет.

Возвращает

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

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

$AsyncPluginsInstallLogger = new AsyncPluginsInstallLogger();
$AsyncPluginsInstallLogger->__construct( $option_name );
$option_name(строка) (обязательный)
option name.

Код AsyncPluginsInstallLogger::__construct() WC 9.4.2

public function __construct( string $option_name ) {
	$this->option_name = $option_name;
	add_option(
		$this->option_name,
		array(
			'created_time' => time(),
			'status'       => 'pending',
			'plugins'      => array(),
		),
		'',
		'no'
	);

	// Set status as failed in case we run out of execution time.
	register_shutdown_function(
		function () {
			$error = error_get_last();
			if ( isset( $error['type'] ) && E_ERROR === $error['type'] ) {
				$option           = $this->get();
				$option['status'] = 'failed';
				$this->update( $option );
			}
		}
	);
}