WC_Products_Tracking::possibly_add_tag_tracking_scripts()publicWC 1.0

Adds the tracking scripts for tags and categories filtering actions.

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

Хуков нет.

Возвращает

null. Ничего.

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

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

Код WC_Products_Tracking::possibly_add_tag_tracking_scripts() WC 6.9.1

public function possibly_add_tag_tracking_scripts( $hook ) {
	// phpcs:disable WordPress.Security.ValidatedSanitizedInput.InputNotSanitized, WordPress.Security.NonceVerification
	if (
		'edit-tags.php' !== $hook ||
		! isset( $_GET['post_type'] ) ||
		'product' !== wp_unslash( $_GET['post_type'] )
	) {
		return;
	}
	// phpcs:enable

	// phpcs:disable WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
	if (
		isset( $_GET['taxonomy'] ) &&
		'product_tag' === wp_unslash( $_GET['taxonomy'] )
	) {
		// phpcs:enable
		$tags_script_assets_filename = WCAdminAssets::get_script_asset_filename( 'wp-admin-scripts', 'tags-tracking' );
		$tags_script_assets          = require WC_ADMIN_ABSPATH . WC_ADMIN_DIST_JS_FOLDER . 'wp-admin-scripts/' . $tags_script_assets_filename;

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

	// phpcs:disable WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
	if (
		isset( $_GET['taxonomy'] ) &&
		'product_cat' === wp_unslash( $_GET['taxonomy'] )
	) {
		// phpcs:enable
		$category_script_assets_filename = WCAdminAssets::get_script_asset_filename( 'wp-admin-scripts', 'category-tracking' );
		$category_script_assets          = require WC_ADMIN_ABSPATH . WC_ADMIN_DIST_JS_FOLDER . 'wp-admin-scripts/' . $category_script_assets_filename;

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

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

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