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.
Returns
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( ?string $function_name ): bool;
- ?string $function_name
- .
Default: null
FeaturesController::verify_did_woocommerce_init() FeaturesController::verify did woocommerce init code WC 10.3.5
private function verify_did_woocommerce_init( ?string $function_name = null ): bool {
if ( ! $this->proxy->call_function( 'did_action', 'woocommerce_init' ) &&
! $this->proxy->call_function( 'doing_action', 'woocommerce_init' ) ) {
if ( ! is_null( $function_name ) ) {
$class_and_method = ( new \ReflectionClass( $this ) )->getShortName() . '::' . $function_name;
/* 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;
}