Automattic\WooCommerce\Internal\Features

FeaturesController::maybe_init_feature_definitions │ private │ WC 1.0

Initialize hardcoded feature definitions if they have not been initialized yet.

Method of the class: FeaturesController{}

No Hooks.

Returns

null. Nothing (null).

Usage

// private - for code of main (parent) class only
$result = $this->maybe_init_feature_definitions(): void;

FeaturesController::maybe_init_feature_definitions() code WC 11.3.0

private function maybe_init_feature_definitions(): void {
	if ( $this->initializing_feature_definitions ) {
		if ( ! $this->issued_feature_definitions_notice ) {
			// Set this before issuing the notice because wc_doing_it_wrong() invokes gettext callbacks.
			$this->issued_feature_definitions_notice = true;
			wc_doing_it_wrong(
				__METHOD__,
				__( 'FeaturesController methods that access feature definitions should not be called while feature definitions are being initialized. Use the woocommerce_init action or later.', 'woocommerce' ),
				'11.3.0'
			);
		}

		return;
	}

	if ( ! empty( $this->features ) ) {
		return;
	}

	$this->initializing_feature_definitions = true;

	try {
		$this->init_feature_definitions();
	} finally {
		$this->initializing_feature_definitions = false;
	}
}