Automattic\WooCommerce\Internal\Features

FeaturesController::verify_did_woocommerce_init()privateWC 1.0

Check if the woocommerce_init run or is running, do a 'wc_doing_it_wrong' if not.

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

Хуков нет.

Возвращает

true|false. True if woocommerce_init run or is running, false otherwise.

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

// private - только в коде основоного (родительского) класса
$result = $this->verify_did_woocommerce_init( $function ): bool;
$function(строка|null)
Name of the invoking method, if not null, 'wc_doing_it_wrong' will be invoked if woocommerce_init not run and is not running.
По умолчанию: null

Код FeaturesController::verify_did_woocommerce_init() WC 8.7.0

private function verify_did_woocommerce_init( string $function = null ): bool {
	if ( ! $this->proxy->call_function( 'did_action', 'woocommerce_init' ) &&
		! $this->proxy->call_function( 'doing_action', 'woocommerce_init' ) ) {
		if ( ! is_null( $function ) ) {
			$class_and_method = ( new \ReflectionClass( $this ) )->getShortName() . '::' . $function;
			/* translators: 1: class::method 2: plugins_loaded */
			$this->proxy->call_function( 'wc_doing_it_wrong', $class_and_method, sprintf( __( '%1$s should not be called before the %2$s action.', 'woocommerce' ), $class_and_method, 'woocommerce_init' ), '7.0' );
		}
		return false;
	}

	return true;
}