WC_Products_Tracking::possibly_add_attribute_tracking_scripts()publicWC 1.0

Adds the tracking scripts for product attributes filtering actions.

{} Это метод класса: WC_Products_Tracking{}

Хуков нет.

Возвращает

null. Ничего.

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

$WC_Products_Tracking = new WC_Products_Tracking();
$WC_Products_Tracking->possibly_add_attribute_tracking_scripts( $hook );
$hook(строка) (обязательный)
Page hook.

Код WC_Products_Tracking::possibly_add_attribute_tracking_scripts() WC 6.9.4

public function possibly_add_attribute_tracking_scripts( $hook ) {
	// phpcs:disable WordPress.Security.ValidatedSanitizedInput.InputNotSanitized, WordPress.Security.NonceVerification
	if (
		'product_page_product_attributes' !== $hook ||
		! isset( $_GET['page'] ) ||
		'product_attributes' !== wp_unslash( $_GET['page'] )
	) {
		return;
	}
	// phpcs:enable

	$script_assets_filename = WCAdminAssets::get_script_asset_filename( 'wp-admin-scripts', 'attributes-tracking' );
	$script_assets          = require WC_ADMIN_ABSPATH . WC_ADMIN_DIST_JS_FOLDER . 'wp-admin-scripts/' . $script_assets_filename;

	wp_enqueue_script(
		'wc-admin-attributes-tracking',
		WCAdminAssets::get_url( 'wp-admin-scripts/attributes-tracking', 'js' ),
		array_merge( array( WC_ADMIN_APP ), $script_assets ['dependencies'] ),
		WCAdminAssets::get_file_version( 'js' ),
		true
	);
}