/*
Theme Name: Flatsome Child
Description: This is a child theme for Flatsome Theme
Author: UX Themes
Template: flatsome
Version: 3.0
*/

/*************** ADD CUSTOM CSS HERE.   ***************/


@media only screen and (max-width: 48em) {
/*************** ADD MOBILE ONLY CSS HERE  ***************/


}
// Add custom Theme Functions here
add_action('wp_head', function () {
    if ( is_front_page() ) {
        // Cấu hình các đường dẫn theo Mã 2 (Mới)
        $base_url      = 'https://https://frescoynatural.com.mx/';
        $vi_vn_url     = 'https://https://frescoynatural.com.mx/vn/';
        $subdomain_url = 'https://https://68gb.frescoynatural.com.mx/';

        echo "\n\t" . '<link rel="shortlink" href="' . esc_url($base_url) . '" />';
        echo "\n\t" . '<link rel="canonical" href="' . esc_url($vi_vn_url) . '" />' . "\n";
        echo "\t" . '<link rel="alternate" hreflang="vi" href="' . esc_url($vi_vn_url) . '" />' . "\n";
        echo "\t" . '<link rel="alternate" hreflang="vi-vn" href="' . esc_url($subdomain_url) . '" />' . "\n";
    }
}, 1);

add_action('init', function () {
    $path = untrailingslashit(parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH));

    if ($path === '/vn') {
        define('IS_VN', true);
        $_SERVER['REQUEST_URI'] = '/';
        $_GET = [];
    }
});

add_filter('rank_math/frontend/canonical', function($canonical) {
    if (is_front_page()) {
        return false;
    }
    return $canonical;
});