Automattic\WooCommerce\Internal\Features
FeaturesController::verify_did_woocommerce_init()
Check if the woocommerce_init run or is running, do a 'wc_doing_it_wrong' if not.
Method of the class: FeaturesController{}
No Hooks.
Return
true|false
. True if woocommerce_init run or is running, false otherwise.
Usage
// private - for code of main (parent) class only $result = $this->verify_did_woocommerce_init( $function ): bool;
- $function(string|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.
Default: null
FeaturesController::verify_did_woocommerce_init() FeaturesController::verify did woocommerce init code 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; }