registered['jquery'])) {\n $scripts->registered['jquery']->deps = array_diff($scripts->registered['jquery']->deps, ['jquery-migrate']);\n }\n });\n\n // Dequeue Contact Form 7 assets on pages without forms\n add_action('wp_enqueue_scripts', function() {\n if (!is_admin()) {\n global $post;\n $has_form = false;\n if (is_a($post, 'WP_Post') && (has_shortcode($post->post_content, 'contact-form-7') || is_page(['contact', 'contact-us', 'contactus']))) {\n $has_form = true;\n }\n if (!$has_form) {\n wp_dequeue_script('contact-form-7');\n wp_dequeue_style('contact-form-7');\n }\n }\n }, 99);\n\n // Dequeue WC cart fragments on static pages when cart is empty\n add_action('wp_enqueue_scripts', function() {\n if (!is_admin() && function_exists('is_woocommerce')) {\n if (!is_cart() && !is_checkout()) {\n if (function_exists('WC') && is_object(WC()) && isset(WC()->cart) && is_object(WC()->cart) && method_exists(WC()->cart, 'is_empty') && WC()->cart->is_empty()) {\n wp_dequeue_script('wc-cart-fragments');\n }\n }\n }\n }, 99);\n }\n\n /**\n * 1. Dynamic, Keyword-Rich Document Title\n */\n public function filter_document_title($title) {\n if (!empty($this->cached_title)) {\n return $this->cached_title;\n }\n\n $site_name = 'Zoha Tech BD';\n\n if (is_front_page() || is_home()) {\n $this->cached_title = "Zoha Tech BD - Smart Tech, Simply Delivered | Best Gadget Shop in BD";\n } elseif (function_exists('is_shop') && is_shop()) {\n $this->cached_title = "Shop Authentic Gadgets & Accessories in Bangladesh | " . $site_name;\n } elseif (function_exists('is_product_category') && is_product_category()) {\n $term = get_queried_object();\n $cat_name = $term ? $term->name : 'Gadgets';\n $this->cached_title = esc_html($cat_name) . " Price in Bangladesh | 100% Genuine | " . $site_name;\n } elseif (function_exists('is_product') && is_product()) {\n $product_id = get_the_ID();\n $prod_title = get_the_title($product_id);\n // Clean up long title if necessary\n $this->cached_title = esc_html($prod_title) . " - Price in Bangladesh | " . $site_name;\n } elseif (is_page()) {\n $page_title = get_the_title();\n $this->cached_title = esc_html($page_title) . " | " . $site_name;\n } elseif (is_category() || is_tax()) {\n $term = get_queried_object();\n $term_name = $term ? $term->name : 'Category';\n $this->cached_title = esc_html($term_name) . " | " . $site_name;\n } elseif (is_search()) {\n $this->cached_title = 'Search results for "' . esc_html(get_search_query()) . '" | ' . $site_name;\n } else {\n $this->cached_title = (!empty($title) ? $title . " | " : "") . $site_name;\n }\n\n return $this->cached_title;\n }\n\n public function filter_title_parts($parts) {\n $full_title = $this->filter_document_title('');\n return ['title' => $full_title];\n }\n\n /**\n * 2. Dynamic, High-Converting Meta Description (130-160 chars)\n */\n public function get_meta_description() {\n if (!empty($this->cached_desc)) {\n return $this->cached_desc;\n }\n\n $desc = '';\n\n if (is_front_page() || is_home()) {\n $desc = "Shop 100% authentic smart gadgets, Anker power banks, fast chargers, wireless earbuds & IP cameras at Zoha Tech BD. Best prices in Bangladesh with warranty.";\n } elseif (function_exists('is_shop') && is_shop()) {\n $desc = "Explore genuine smart gadgets, power banks, chargers, audio gear, and IP cameras in Bangladesh at Zoha Tech BD. Best prices, official warranty & nationwide delivery.";\n } elseif (function_exists('is_product_category') && is_product_category()) {\n $term = get_queried_object();\n $cat_name = $term ? $term->name : 'smart gadgets';\n $desc = "Buy authentic " . $cat_name . " at the best price in Bangladesh. 100% genuine products with official warranty and fast home delivery from Zoha Tech BD.";\n } elseif (function_exists('is_product') && is_product()) {\n $product_id = get_the_ID();\n $product = wc_get_product($product_id);\n $prod_title = get_the_title($product_id);\n $price = $product ? $product->get_price() : '';\n $price_str = $price ? " at ৳" . number_format((float)$price) : "";\n \n // Short description check\n $short_desc = $product ? wp_strip_all_tags($product->get_short_description()) : '';\n if (!empty($short_desc) && strlen($short_desc) >= 50 && strlen($short_desc) <= 160) {\n $desc = $short_desc;\n } else {\n $desc = "Buy authentic " . $prod_title . " in Bangladesh" . $price_str . ". 100% genuine product with official warranty & fast cash on delivery from Zoha Tech BD.";\n }\n } elseif (is_page()) {\n $page_slug = get_post_field('post_name', get_the_ID());\n switch ($page_slug) {\n case 'about-us':\n $desc = "Learn about Zoha Tech BD, your trusted destination in Bangladesh for authentic smart tech gadgets, power banks, chargers, and premium audio accessories.";\n break;\n case 'contact-us':\n $desc = "Get in touch with Zoha Tech BD customer support for questions about products, warranty, orders, and delivery across Bangladesh.";\n break;\n case 'cart':\n $desc = "View and manage items in your shopping cart at Zoha Tech BD. Fast checkout and reliable cash on delivery across Bangladesh.";\n break;\n case 'checkout':\n $desc = "Secure checkout at Zoha Tech BD. Complete your order safely with cash on delivery, bKash, Nagad, or cards with fast nationwide shipping.";\n break;\n case 'my-account':\n $desc = "Access your Zoha Tech BD account to manage your profile, view order history, and track recent shipments effortlessly.";\n break;\n case 'wishlist':\n $desc = "View your saved favorite gadgets and accessories on Zoha Tech BD. Buy authentic tech with warranty and fast delivery.";\n break;\n default:\n $excerpt = wp_strip_all_tags(get_the_excerpt());\n if (!empty($excerpt) && strlen($excerpt) >= 40) {\n $desc = $excerpt;\n } else {\n $desc = "Explore " . get_the_title() . " at Zoha Tech BD. 100% genuine tech products, best prices in Bangladesh, warranty, and fast home delivery.";\n }\n }\n } else {\n $desc = "Zoha Tech BD is your premier destination for authentic smart technology, gadgets, power banks, and electronics in Bangladesh with official warranty.";\n }\n\n // Normalize spaces and truncate cleanly to <= 160 chars without cutting mid-word\n $desc = preg_replace('/\s+/', ' ', trim($desc));\n if (mb_strlen($desc) > 160) {\n $sub = mb_substr($desc, 0, 157);\n $last_space = mb_strrpos($sub, ' ');\n if ($last_space !== false && $last_space > 120) {\n $desc = mb_substr($sub, 0, $last_space) . '...';\n } else {\n $desc = $sub . '...';\n }\n }\n\n $this->cached_desc = $desc;\n return $this->cached_desc;\n }\n\n /**\n * 3. Absolute, Clean Canonical URL\n */\n public function get_canonical_url() {\n if (!empty($this->cached_canonical)) {\n return $this->cached_canonical;\n }\n\n $canonical = '';\n\n if (is_front_page() || is_home()) {\n $canonical = home_url('/');\n } elseif (function_exists('is_shop') && is_shop()) {\n $shop_page_id = wc_get_page_id('shop');\n $canonical = $shop_page_id ? get_permalink($shop_page_id) : home_url('/shop/');\n } elseif (function_exists('is_product_category') && is_product_category()) {\n $term = get_queried_object();\n $canonical = $term ? get_term_link($term) : home_url('/');\n } elseif (is_tax() || is_category() || is_tag()) {\n $term = get_queried_object();\n $canonical = $term ? get_term_link($term) : home_url('/');\n } elseif (is_singular()) {\n $canonical = get_permalink(get_the_ID());\n } elseif (is_search()) {\n $canonical = home_url('/?s=' . rawurlencode(get_search_query()));\n } else {\n $canonical = home_url(add_query_arg([], $GLOBALS['wp']->request ?? ''));\n }\n\n if (is_wp_error($canonical) || empty($canonical)) {\n $canonical = home_url('/');\n }\n\n $this->cached_canonical = esc_url($canonical);\n return $this->cached_canonical;\n }\n\n /**\n * 4. OpenGraph Image\n */\n public function get_og_image() {\n $default_img = 'https://zohatechbd.com/wp-content/uploads/2026/10/zoha-tech-logo.png';\n if (is_singular()) {\n $thumbnail_id = get_post_thumbnail_id(get_the_ID());\n if ($thumbnail_id) {\n $img_url = wp_get_attachment_image_url($thumbnail_id, 'full');\n if ($img_url) {\n return esc_url($img_url);\n }\n }\n }\n return $default_img;\n }\n\n /**\n * 5. Inject Complete Head SEO Meta & JSON-LD\n */\n public function inject_seo_head() {\n $title = $this->filter_document_title('');\n $desc = $this->get_meta_description();\n $canonical = $this->get_canonical_url();\n $og_image = $this->get_og_image();\n $is_noindex = is_search() || (function_exists('is_cart') && is_cart()) || (function_exists('is_checkout') && is_checkout()) || (function_exists('is_account_page') && is_account_page());\n\n ?>\n \n \n \n \n \n \n ' . "\n";\n }\n ?>\n\n \n \n \n \n \n \n \n \n\n \n \n \n \n \n\n \n \n \n \n \n\n \n \n inject_structured_data($canonical, $title, $desc, $og_image);\n }\n\n /**\n * 6. Schema.org JSON-LD Generation\n */\n private function inject_structured_data($canonical, $title, $desc, $og_image) {\n $schemas = [];\n\n // 1. WebSite Schema (Sitewide)\n $schemas[] = [\n '@type' => 'WebSite',\n '@id' => home_url('/#website'),\n 'url' => home_url('/'),\n 'name' => 'Zoha Tech BD',\n 'description' => 'Smart Tech, Simply Delivered',\n 'potentialAction' => [\n '@type' => 'SearchAction',\n 'target' => [\n '@type' => 'EntryPoint',\n 'urlTemplate' => home_url('/?s={search_term_string}')\n ],\n 'query-input' => 'required name=search_term_string'\n ]\n ];\n\n // 2. Organization / OnlineStore Schema\n $schemas[] = [\n '@type' => 'OnlineStore',\n '@id' => home_url('/#organization'),\n 'name' => 'Zoha Tech BD',\n 'url' => home_url('/'),\n 'logo' => [\n '@type' => 'ImageObject',\n 'url' => 'https://zohatechbd.com/wp-content/uploads/2026/10/zoha-tech-logo.png'\n ],\n 'description' => 'Leading retailer of authentic smart technology, Anker power banks, fast chargers, wireless earbuds, and electronics in Bangladesh.',\n 'priceRange' => '৳৳',\n 'currenciesAccepted' => 'BDT',\n 'paymentAccepted' => 'Cash on Delivery, bKash, Nagad, Visa, Mastercard'\n ];\n\n // 3. BreadcrumbList Schema\n if (!is_front_page()) {\n $breadcrumbs = [\n [\n '@type' => 'ListItem',\n 'position' => 1,\n 'name' => 'Home',\n 'item' => home_url('/')\n ]\n ];\n\n if (function_exists('is_shop') && is_shop()) {\n $breadcrumbs[] = [\n '@type' => 'ListItem',\n 'position' => 2,\n 'name' => 'Shop',\n 'item' => $canonical\n ];\n } elseif (function_exists('is_product_category') && is_product_category()) {\n $term = get_queried_object();\n $breadcrumbs[] = [\n '@type' => 'ListItem',\n 'position' => 2,\n 'name' => 'Shop',\n 'item' => home_url('/shop/')\n ];\n $breadcrumbs[] = [\n '@type' => 'ListItem',\n 'position' => 3,\n 'name' => $term ? $term->name : 'Category',\n 'item' => $canonical\n ];\n } elseif (function_exists('is_product') && is_product()) {\n $breadcrumbs[] = [\n '@type' => 'ListItem',\n 'position' => 2,\n 'name' => 'Shop',\n 'item' => home_url('/shop/')\n ];\n $terms = get_the_terms(get_the_ID(), 'product_cat');\n if ($terms && !is_wp_error($terms)) {\n $first_term = reset($terms);\n $breadcrumbs[] = [\n '@type' => 'ListItem',\n 'position' => 3,\n 'name' => $first_term->name,\n 'item' => get_term_link($first_term)\n ];\n $breadcrumbs[] = [\n '@type' => 'ListItem',\n 'position' => 4,\n 'name' => get_the_title(),\n 'item' => $canonical\n ];\n } else {\n $breadcrumbs[] = [\n '@type' => 'ListItem',\n 'position' => 3,\n 'name' => get_the_title(),\n 'item' => $canonical\n ];\n }\n } else {\n $breadcrumbs[] = [\n '@type' => 'ListItem',\n 'position' => 2,\n 'name' => get_the_title(),\n 'item' => $canonical\n ];\n }\n\n $schemas[] = [\n '@type' => 'BreadcrumbList',\n '@id' => $canonical . '#breadcrumb',\n 'itemListElement' => $breadcrumbs\n ];\n }\n\n // 4. Product Schema on Single Product\n if (function_exists('is_product') && is_product()) {\n $product_id = get_the_ID();\n $product = wc_get_product($product_id);\n if ($product) {\n $price = $product->get_price();\n $sku = $product->get_sku() ?: 'ZT-' . $product_id;\n $availability = $product->is_in_stock() ? 'https://schema.org/InStock' : 'https://schema.org/OutOfStock';\n \n $brand_name = 'Zoha Tech BD';\n $terms = get_the_terms($product_id, 'product_brand');\n if ($terms && !is_wp_error($terms)) {\n $brand_name = reset($terms)->name;\n } elseif (stripos(get_the_title(), 'Anker') !== false) {\n $brand_name = 'Anker';\n }\n\n $schemas[] = [\n '@type' => 'Product',\n '@id' => $canonical . '#product',\n 'name' => get_the_title(),\n 'image' => $og_image,\n 'description' => $desc,\n 'sku' => $sku,\n 'brand' => [\n '@type' => 'Brand',\n 'name' => $brand_name\n ],\n 'offers' => [\n '@type' => 'Offer',\n 'url' => $canonical,\n 'priceCurrency' => 'BDT',\n 'price' => $price ?: '0',\n 'availability' => $availability,\n 'itemCondition' => 'https://schema.org/NewCondition',\n 'seller' => [\n '@type' => 'Organization',\n 'name' => 'Zoha Tech BD'\n ]\n ]\n ];\n }\n }\n\n $full_graph = [\n '@context' => 'https://schema.org',\n '@graph' => $schemas\n ];\n\n echo '' . "\n";\n }\n\n /**\n * 7. Attachment Image Alt Enforcement\n */\n public function filter_image_attributes($attr, $attachment, $size) {\n if (!isset($attr['alt']) || trim($attr['alt']) === '') {\n $post_title = get_the_title($attachment->ID ?? 0);\n if (!empty($post_title)) {\n $attr['alt'] = esc_attr($post_title);\n } else {\n $attr['alt'] = 'Zoha Tech BD';\n }\n }\n return $attr;\n }\n\n /**\n * 8. Output Buffer Filter: 100% Alt, Aria, Anchor & H1 Enforcement\n */\n public function start_output_buffer() {\n if (is_admin() || (defined('DOING_CRON') && DOING_CRON) || (defined('REST_REQUEST') && REST_REQUEST)) {\n return;\n }\n ob_start([$this, 'filter_html_output']);\n }\n\n public function filter_html_output($html) {\n if (empty($html) || !is_string($html)) {\n return $html;\n }\n\n // --- A. Fix Missing Image Alt Attributes ---\n // Ensure every tag has an alt attribute\n $html = preg_replace_callback('/]alt\b)[^>])*)>/i', function($matches) {\n $tag_inside = $matches[1];\n // Check if it's the site logo\n if (stripos($tag_inside, 'zoha-tech-logo') !== false) {\n return 'Zoha Tech BD';\n }\n if (stripos($tag_inside, 'mp2-fire') !== false) {\n return 'Hot Deals';\n }\n if (stripos($tag_inside, 'shop.svg') !== false) {\n return 'Shop';\n }\n if (stripos($tag_inside, 'mcp-delivery') !== false) {\n return 'Fast Delivery';\n }\n if (stripos($tag_inside, 'overview.svg') !== false) {\n return 'Overview';\n }\n // Default decorative/safe alt\n return '';\n }, $html);\n\n // Fix logo images with alt="" to have alt="Zoha Tech BD"\n $html = preg_replace('/(]*zoha-tech-logo[^>]*alt=)(["\'])(["\'])/i', '$1$2Zoha Tech BD$3', $html);\n\n // --- B. Fix Missing Link Text / Discernible Names (A11y) ---\n // 1. My Account header links without aria-label\n $html = preg_replace_callback('/]aria-label\b)[^>])*href=["\'][^"\']*my-account[^"\']*["\'][^>]*)>/i', function($m) {\n return '';\n }, $html);\n\n // 2. Logo links without aria-label\n $html = preg_replace_callback('/]aria-label\b)[^>])*class=["\'][^"\']*wd-logo[^"\']*["\'][^>]*)>/i', function($m) {\n return '';\n }, $html);\n\n // 3. Fix header wishlist accessible name matching visible count (WCAG 2.5.3 label-content-name-mismatch)\n $html = preg_replace_callback('/(]*class=["\'][^"\']*wd-header-wishlist[^"\']*["\'][^>]*>.*?]*)(>.*?]*class=["\'][^"\']*wd-tools-count[^"\']*["\'][^>]*>\s*(\d+)\s*<\/span>.*?<\/a>)/is', function($m) {\n $pre_a = $m[1];\n $attrs = $m[2];\n $inner = $m[3];\n $count = $m[4];\n $attrs = preg_replace('/\s*aria-label=["\'][^"\']*["\']/', '', $attrs);\n $attrs .= ' aria-label="Wishlist ' . $count . '"';\n return $pre_a . $attrs . $inner;\n }, $html);\n\n // 4. Ensure mobile bottom toolbar links use their natural visible text (prevents label-content-name-mismatch on mobile toolbar)\n $html = preg_replace_callback('/]*class=["\'][^"\']*wd-toolbar[^"\']*["\'][^>]*>[\s\S]*?<\/div>\s*<\/div>/i', function($m) {\n return preg_replace('/\s*aria-label=["\'][^"\']*["\']/', '', $m[0]);\n }, $html);\n\n // 4. Product wishlist buttons without aria-label (link-name)\n $html = preg_replace_callback('/]aria-label\b)[^>])*class=["\'][^"\']*wd-tooltip[^"\']*["\'][^>]*href=["\'][^"\']*wishlist[^"\']*["\'][^>]*)>/i', function($m) {\n return '';\n }, $html);\n\n // 5. Product Add to Cart buttons: remove conflicting aria-hidden on text and ensure aria-label (link-name)\n $html = preg_replace('/(]*class=["\'][^"\']*add_to_cart_button[^"\']*["\'][^>]*>[\s\S]*?]*class=["\'][^"\']*wd-action-text[^"\']*)\s+aria-hidden=["\']true["\']/i', '$1', $html);\n $html = preg_replace_callback('/]aria-label\b)[^>])*class=["\'][^"\']*add_to_cart_button[^"\']*["\'][^>]*)>/i', function($m) {\n return '';\n }, $html);\n\n // --- C. Fix Crawlable Anchors for UI Controls ---\n // Any or missing role="button"\n $html = preg_replace_callback('/]role\b)[^>])*href=["\'](?:#|javascript:void\(0\);?)["\'][^>]*)>/i', function($m) {\n return '';\n }, $html);\n\n // --- D. Fix Missing iframe Title & Accessibility Attributes (A11y) ---\n $html = preg_replace_callback('/]title\b)[^>])*)>/i', function($m) {\n return '

All rights reserve to zohatechbd.com