/*
Theme Name:        ERG Base
Theme URI:         https://bestofindianproducts.com
Author:            Harkanwal Singh — Best Of Indian Products
Author URI:        https://bestofindianproducts.com
Description:       The parent theme for all Egbert Reuben Group stores. A lean, custom-built WooCommerce-native theme with zero page builder dependency. All colours, logos, and store identity are set via child themes. Built for Core Web Vitals, accessibility, and full-text mega menu navigation.
Version:           1.6.8
Requires at least: 6.0
Tested up to:      6.7
Requires PHP:      7.4
License:           GPL-2.0-or-later
License URI:       https://www.gnu.org/licenses/gpl-2.0.html
Text Domain:       erg-base
Tags:              woocommerce, custom-header, custom-logo, custom-menu, featured-images, threaded-comments, translation-ready

Changelog:
1.6.8 — Fixed New Arrivals and Popular Picks showing identical products.
        Popular Picks' fallback (when no real sales data exists yet) and
        New Arrivals both independently queried "4 most recent products"
        with no awareness of each other. Added opt-in cross-section
        duplicate avoidance to the shared product-section helper — Popular
        Picks/Best Sellers renders first and keeps the freshest items,
        New Arrivals automatically excludes whatever it already showed and
        displays the next batch instead of repeating them. Also fixed
        breadcrumb structured data: the previous Microdata markup only
        ever included "position" (missing "item" and "name", which
        schema.org's BreadcrumbList requires — likely failing Rich Results
        validation despite looking like it had schema). Replaced with
        proper JSON-LD built from the same trail data the visual
        breadcrumb uses, so the two can never drift out of sync.
1.6.7 — Added do_action('erg_before_footer') immediately before the
        <footer> tag in footer.php — a clean, named slot any plugin can
        hook into without editing the template file.
1.6.6 — Added [erg_language_switcher] shortcode output to the top bar's
        right side, next to My Account/Track Order. No new logic built —
        the plugin handles all of it; this just places it. Only renders
        if the shortcode actually outputs something, so it won't show an
        empty box if that plugin isn't active.
1.6.5 — Four tickets:
        (0) Added a "Wishlist" tab to My Account, linking to the
        configurable Wishlist page URL — only shown if one is set.
        Ticket 1 — Mobile search parity: JS for a mobile search toggle
        existed but the matching HTML was never added, so mobile had no
        search at all. Added the toggle + full-width bar, and refactored
        live search from a single hardcoded input ID to support multiple
        inputs, so mobile gets the exact same live results as desktop,
        not a separate/lesser implementation.
        Ticket 2 — De-hardcoded the Best Sellers subtitle ("Trusted by
        businesses and homes across India" — wrong for fastgives.ca and
        any future non-India deployment). Now a Customizer field with a
        generic, no-unverified-claims default.
        Ticket 3 — Best Sellers title now reflects real data: shows
        "Popular Picks" with date-based ordering until any product has
        genuine recorded sales (WooCommerce's own total_sales meta),
        then automatically switches to "Best Selling Products" with
        sales-based ordering — no manual copy change needed as a store
        matures.
        Ticket 4 — Full audit for other hardcoded trust/scale claims:
        none found beyond Ticket 2 (the "How It Works" India-specific
        copy was already fixed in an earlier update). One adjacent,
        lower-priority finding not fixed here — see chat for detail:
        the Clearance CTA section has hardcoded industrial-machinery
        wording ("Ex-Demo Machines," a 24-hour response promise) that
        would be wrong for non-machinery stores, but it's opt-in
        (hidden until a URL is explicitly set), so lower risk than 2/3.
1.6.4 — Two minimal changes, nothing else: (1) Header Wishlist link is now
        a plain customizable URL (Appearance → Customize → Top Bar →
        Wishlist page URL) instead of a dead YITH-dependent "#" fallback.
        (2) Product card wishlist button replaced with the [tbge_wishlist_button]
        shortcode from the TB Plugin, placed directly below Add to Cart —
        the old heart button (YITH-dependent, non-functional without it)
        removed entirely. No new wishlist logic built theme-side; the TB
        Plugin already handles all of it, including its own email capture.
1.6.3 — Fixed footer logo showing as a plain white box. The footer was
        reusing the main site logo (Site Identity), which usually isn't
        designed for a dark background — if it lacks transparency it just
        renders as a solid rectangle. Footer now falls back to plain
        styled text (site name) instead, same look as Trade Bargains'
        footer, until a dedicated Footer logo (Appearance → Customize →
        Footer, optional) is uploaded for a proper dark-background variant.
1.6.2 — Fixed Brand Colours not applying on the frontend at all. The
        dynamic :root color block was hooked to wp_head at priority 4,
        which runs BEFORE WordPress prints enqueued stylesheets (priority
        8) — so theme.css's own hardcoded color defaults always printed
        later in the HTML and won the CSS cascade, regardless of what was
        set in the Customizer. Moved to priority 999 so it reliably prints
        after every stylesheet, including theme.css.
1.6.1 — Added three generic Custom HTML sections (Appearance → Customize
        → Custom HTML Sections) — paste any HTML to add a fully custom
        homepage block at three fixed positions (after hero, mid-page,
        near the bottom), not limited to a fixed structure like How It
        Works. Sanitized with wp_kses_post by default (script/iframe
        stripped) — flag if you need raw/unrestricted HTML for an embed,
        that's a deliberate one-line change, not the default.
1.6.0 — Four fixes/features in one batch:
        (1) Newsletter discount is now automated — Appearance → Customize →
        Newsletter Signup saves a code + percentage, and saving the
        Customizer auto-creates/updates the matching WooCommerce coupon.
        No more manual coupon setup, no drift between displayed code and
        what actually works at checkout.
        (2) "How It Works" is now fully Customizer-editable (Appearance →
        Customize → How It Works) — eyebrow, heading, and 4 steps each
        with title/body/optional tag. Replaced the hardcoded India-specific
        UPI/Shipmozo copy with generic defaults; the erg_how_it_works_steps
        filter still works for full programmatic override if wanted.
        (3) Fixed Quick View doing nothing when clicked on variable/Tier-2
        products ("View Options" buttons): the product ID lookup relied on
        a data-product_id attribute that only existed on the Tier-1 simple
        product Add to Cart button — never present at all for variable
        products. Added a reliable data-product-id directly on every card.
        Also fixed the trigger button being nested inside an <a> tag
        (invalid HTML, unreliable clicks) by giving it a proper sibling
        wrapper.
        (4) Footer Sitemap link is now customizable (Appearance → Customize
        → Footer → Sitemap URL) — was hardcoded to /sitemap.xml, which
        doesn't match the /sitemap_index.xml format most SEO plugins
        (Yoast, RankMath) actually generate. Default corrected to match.
1.5.1 — Newsletter section redesigned: the honeypot field was visibly
        showing to real visitors ("Leave this field empty") because it
        relied entirely on an external stylesheet class to hide it. Now
        hidden via inline style so it can't be exposed by a CSS load/cache
        issue, and dropped the visible label entirely. Added a customizable
        discount incentive (Appearance → Customize → Newsletter Signup) —
        headline, subtext, and an optional discount code line. The code
        is a display value only; the actual coupon must still be created
        in WooCommerce → Marketing → Coupons.
1.5.0 — Homepage reorder: Best Sellers and a new Reviews section now come
        before the category grid (proof before navigation), matching CRO
        best practice. Added four new sections: Reviews (Trustpilot
        TrustBox embed, needs Business Unit ID in Customizer), Newsletter
        (self-hosted signup — stores subscribers as a browsable/exportable
        CPT in wp-admin, no ESP dependency), Blog teaser, and an Instagram
        strip (manually curated via Customizer, deliberately not using
        Instagram's API to avoid token-refresh maintenance). Also fixed
        the hero background: was a flat 20% opacity dimming the whole
        image; now a proper gradient scrim — solid behind the text on the
        left, fully clear by the right edge.
1.4.5 — The #sidebar block (default Pages/Archives/Categories/Search
        widgets on shop/category pages) had a second, independent source:
        archive-product.php calls do_action('woocommerce_sidebar'), which
        WooCommerce hooks its own woocommerce_get_sidebar() onto by
        default — never removed by this theme. Removed it. Also added a
        CSS #sidebar { display:none !important; } safety net in case a
        third path exists that hasn't surfaced yet.
1.4.4 — Fixed duplicate pagination ("1 2 3 →" printing twice) on the shop
        page and every product category/tag archive. Same root cause as
        the 1.1.0 breadcrumb duplicate and 1.3.0 result-count/sort
        duplicate: woocommerce_pagination() was hooked to
        woocommerce_after_shop_loop by WooCommerce's own default, then
        called manually again right after do_action() fired it once already.
1.4.3 — Unregistered a widget area with id="sidebar" that was rendering
        default WordPress Pages/Archives/Categories widgets on WooCommerce
        category pages. This theme never registered a sidebar with that
        ID (only shop-sidebar/blog-sidebar/footer-col-1..4 exist) — it was
        coming from a plugin or a previously-active theme. Killed sitewide
        via unregister_sidebar() at late priority, regardless of source.
1.4.2 — Removed .erg-page-wrap's forced min-height: 100vh, confirmed on
        the live site to be the actual cause of the sitewide gap between
        the nav and page content on home, shop, and single product pages
        alike (traced by direct CSS override on production, not by code
        review — logged here as the real root cause going forward).
1.4.1 — Removed the native WordPress "Header Image" Customizer panel
        (add_theme_support('custom-header')). It was only ever used as a
        hidden fallback image source for the homepage hero background,
        duplicating the new Homepage Hero → Background image field added
        in 1.4.0 — two controls, one confusingly labeled as if sitewide,
        both feeding the same single spot on the homepage only. That field
        is now the one and only source.
1.4.0 — The homepage hero had NO Customizer controls at all — every field
        (title, subtitle, CTAs, images) was only readable via get_theme_mod()
        with hardcoded PHP defaults, so there was no admin UI to change any
        of it. Added a full "Homepage Hero" Customizer panel. Also: the
        hero's right-hand "featured image" hook (erg_hero_aside) had zero
        listeners — wired it up. And fixed the actual empty-space bug:
        .erg-hero__inner always reserved a full 500px-tall 2-column grid
        even with nothing in the second column; it now collapses to one
        column sized to content when no featured image is set.
1.3.1 — Mini-cart quantity stepper no longer fails silently. The AJAX
        handler now buffers its entire output so a stray PHP notice can't
        corrupt the JSON response, and the JS surfaces (console + brief
        error state) any request that doesn't come back as valid JSON,
        instead of doing nothing with no trace of why.
1.3.0 — Fixed duplicate "Showing X of Y results" + sort dropdown on shop/
        category pages (same root cause as the 1.1.0 breadcrumb fix —
        WooCommerce's default hooks were never removed after the custom
        toolbar was added). Replaced the default WooCommerce related-
        products template with the theme's own product card component,
        fixing misaligned cards (price/button height used to depend on
        title length) and giving the section a more purposeful heading.
1.2.1 — Free-shipping threshold is no longer a manually-entered theme
        setting. It's now read live from whichever "Free shipping"
        method is enabled in WooCommerce → Settings → Shipping for
        the customer's matched zone, so the mini-cart bar can never
        drift out of sync with the actual shipping rule.
1.2.0 — Mini-cart rebuild: overridden woocommerce/cart/mini-cart.php to add
        a real AJAX +/- quantity stepper (WooCommerce's default widget only
        ever showed quantity as plain text), split the panel into a
        scrollable item list + a pinned footer so Checkout is always
        reachable without scrolling, added a free-shipping progress bar,
        and moved trust-badge text into the Customizer (Appearance →
        Customize → Mini-Cart & Trust Messaging) so it's shared between
        the mini-cart and the single-product trust strip.
1.1.0 — Fixed single-product template loop bug (product content was never
        rendering — the_post() was exhausting have_posts() before the real
        loop ran). Removed duplicate breadcrumb (woocommerce_breadcrumb()
        was re-hooked alongside erg_breadcrumbs(), stacking two trails).
        Added: single-product stock urgency, trust strip, recently viewed
        products, quantity +/- stepper, product meta/OG tags, JS defer.
        Converted mobile shop sidebar into a native <details> accordion
        (zero JS) instead of dumping full-height widgets above the grid.
1.0.0 — Initial release.

/*
 * ERG Base ships NO frontend styles of its own.
 * All styles are in assets/css/theme.css loaded via functions.php.
 * Child themes add their brand layer via their own style.css.
 * This file exists solely to register the theme with WordPress.
 */
