<?php
/*
Theme Name:           Flatsome
Theme URI:            http://flatsome.uxthemes.com
Author:               UX-Themes
Author URI:           https://uxthemes.com
Description:          Multi-Purpose Responsive WooCommerce Theme
Version:              3.16.2
Requires at least:    5.0.0
Requires PHP:         5.6.20
WC requires at least: 4.4.0
Text Domain:          flatsome
License:              https://themeforest.net/licenses
License URI:          https://themeforest.net/licenses
*/

/*
===============================================================
🌿 Nadi Center – Hero Preload + UX Builder Disable (Original)
===============================================================
*/

/* ✅ Preload hero images only on homepage */
function nadi_preload_homepage_images() {
    if ( is_front_page() ) {
        echo '
        <!-- ========================================================= -->
        <!-- ✅ Hero & Grid Image Preloads (Homepage LCP Optimization) -->
        <!-- ========================================================= -->
        <link rel="preload" as="image"
              href="https://nadicenter.gr/wp-content/uploads/2025/11/nadi-center-hero-poster.webp"
              fetchpriority="high"
              importance="high"
              type="image/webp"
              imagesizes="100vw">

        <link rel="preload" as="image"
              href="https://nadicenter.gr/wp-content/uploads/2025/09/nadi-center-alimos-pilates-yoga-fitness.webp"
              fetchpriority="high"
              importance="high"
              type="image/webp"
              imagesizes="100vw">
        ';
    }
}
add_action('wp_head', 'nadi_preload_homepage_images', 1);

/* ✅ Disable Flatsome UX Builder scripts on frontend */
add_action( 'wp_enqueue_scripts', function() {
    if ( ! is_admin() && ! is_customize_preview() ) {
        wp_dequeue_script( 'ux-builder-frontend' );
        wp_dequeue_script( 'ux-builder-common' );
        wp_dequeue_style( 'ux-builder-frontend' );
    }
}, 99 );
