/**
 * Theme Name:     Astra Child
 * Author:         Brainstorm Force
 * Template:       astra
 * Text Domain:	   astra-child
 * Description:    Astra is fast, fully customizable &amp; beautiful WordPress theme suitable for blog, personal portfolio, business website and WooCommerce storefront. It is very lightweight (less than 50KB on frontend) and offers unparalleled speed. Built with SEO in mind, Astra comes with Schema.org code integrated and is Native AMP ready so search engines will love your site. It offers special features and templates so it works perfectly with all page builders like Elementor, Beaver Builder, Visual Composer, SiteOrigin, Divi, etc. Some of the other features: # WooCommerce Ready # Responsive # RTL &amp; Translation Ready # Extendible with premium addons # Regularly updated # Designed, Developed, Maintained &amp; Supported by Brainstorm Force. Looking for a perfect base theme? Look no further. Astra is fast, fully customizable and WooCommerce ready theme that you can use for building any kind of website!
 */
// Forcer les balises H2 en H3 pour les titres des produits WooCommerce
add_action('init', function() {
    remove_action('woocommerce_shop_loop_item_title', 'woocommerce_template_loop_product_title', 10);
    add_action('woocommerce_shop_loop_item_title', 'custom_woocommerce_template_loop_product_title', 10);
});

function custom_woocommerce_template_loop_product_title() {
    echo '<h3 class="woocommerce-loop-product__title">' . get_the_title() . '</h3>';
}

function custom_astra_breakpoint_script() {
    ?>
    <script>
        document.addEventListener("DOMContentLoaded", function () {
            function checkMenuBreakpoint() {
                if (window.innerWidth <= 1200) {
                    document.body.classList.add("ast-header-break-point");
                } else {
                    document.body.classList.remove("ast-header-break-point");
                }
            }
            checkMenuBreakpoint();
            window.addEventListener("resize", checkMenuBreakpoint);
        });
    </script>
    <?php
}
add_action('wp_footer', 'custom_astra_breakpoint_script');


// Afficher la description de la catégorie APRÈS les produits
add_action( 'woocommerce_after_main_content', 'ajouter_description_bas_page_categorie', 15 );
function ajouter_description_bas_page_categorie() {
  if ( is_product_category() ) {
    $category = get_queried_object();
    if ( ! empty( $category->description ) ) {
      echo '<div class="desc-seo-bas" style="margin-top:50px">';
      echo apply_filters( 'woocommerce_category_description', $category->description, $category );
      echo '</div>';
    }
  }
}

