Automattic\WooCommerce\Internal\Features

FeaturesController::maybe_init_feature_definitions │ private │ WC 1.0

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

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

Хуков нет.

Возвращает

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

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

// private - только в коде основоного (родительского) класса
$result = $this->maybe_init_feature_definitions(): void;

Код FeaturesController::maybe_init_feature_definitions() 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;
	}
}