true, 'strategy' => 'defer' ) ); wp_localize_script( $handle, 'aieoAttribution', array( 'enabled' => true, 'ajaxUrl' => admin_url( 'admin-ajax.php' ), 'currency' => function_exists( 'get_woocommerce_currency' ) ? get_woocommerce_currency() : 'EUR', 'archive' => self::resolve_archive_context(), 'ga4_enabled' => $ga4_browser, ) ); } public static function resolve_archive_context() { if ( ! function_exists( 'is_tax' ) || ! function_exists( 'get_queried_object' ) ) { return null; } $brand_taxonomies = array( 'product_brand', 'pwb-brand', 'yith_product_brand' ); if ( ! is_tax() ) { return null; } $term = get_queried_object(); if ( ! $term || empty( $term->term_id ) || empty( $term->taxonomy ) ) { return null; } $tax = (string) $term->taxonomy; $tax_obj = function_exists( 'get_taxonomy' ) ? get_taxonomy( $tax ) : null; $object_types = ( $tax_obj && ! empty( $tax_obj->object_type ) ) ? (array) $tax_obj->object_type : array(); $is_brand = in_array( $tax, $brand_taxonomies, true ); if ( ! $is_brand && ! in_array( 'product', $object_types, true ) ) { return null; } if ( $is_brand ) { $tax = 'product_brand'; } return array( 'term_id' => (int) $term->term_id, 'tax' => $tax, 'slug' => (string) $term->slug, 'name' => (string) $term->name, ); } } }