Automattic\WooCommerce\Internal\Integrations

WPConsentAPI::enqueue_consent_api_scripts()privateWC 1.0

Enqueue JS for integration with WP Consent Level API

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

Хуков нет.

Возвращает

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

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

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

Код WPConsentAPI::enqueue_consent_api_scripts() WC 9.7.1

private function enqueue_consent_api_scripts() {
	wp_enqueue_script(
		'wp-consent-api-integration',
		plugins_url(
			"assets/js/frontend/wp-consent-api-integration{$this->get_script_suffix()}.js",
			WC_PLUGIN_FILE
		),
		array( 'wp-consent-api', 'wc-order-attribution' ),
		Constants::get_constant( 'WC_VERSION' ),
		true
	);

	// Add data for the script above. `wp_enqueue_script` API does not allow data attributes,
	// so we need a separate script tag and pollute the global scope.
	wp_add_inline_script(
		'wp-consent-api-integration',
		sprintf(
			'window.wc_order_attribution.params.consentCategory = %s;',
			wp_json_encode( self::$consent_category )
		),
		'before'
	);
}