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. Ничего (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 8.6.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'] )
	) {
		WCAdminAssets::register_script( 'wp-admin-scripts', 'tags-tracking', false );
		return;
	}

	// phpcs:disable WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
	if (
		isset( $_GET['taxonomy'] ) &&
		'product_cat' === wp_unslash( $_GET['taxonomy'] )
	) {
		WCAdminAssets::register_script( 'wp-admin-scripts', 'category-tracking', false );
		return;
	}
	WCAdminAssets::register_script( 'wp-admin-scripts', 'add-term-tracking', false );
}