Automattic\WooCommerce\Internal\Integrations
WPConsentAPI::enqueue_consent_api_scripts
Enqueue JS for integration with WP Consent Level API
Метод класса: WPConsentAPI{}
Хуков нет.
Возвращает
null. Ничего (null).
Использование
// private - только в коде основоного (родительского) класса $result = $this->enqueue_consent_api_scripts();
Код WPConsentAPI::enqueue_consent_api_scripts() WPConsentAPI::enqueue consent api scripts WC 10.7.0
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, JSON_HEX_TAG | JSON_UNESCAPED_SLASHES )
),
'before'
);
}