/*
Theme Name:   WorkScout Child
Theme URI: http://workscout.in
Author: Purethemes
Author URI: http://themeforest.net/user/purethemes
Description: WordPress Job Theme
Version: 1.0
License: ThemeForest
License URI: http://themeforest.net/licenses
Text Domain: workscout
Domain Path: /languages/
Tags: light, responsive-layout, post-formats, theme-options, translation-ready, two-columns
Template:  workscout
*/



/* 
add_filter('gettext', 'change_candidate_to_caregiver', 20, 3);

function change_candidate_to_caregiver($translated, $text, $domain) {

    if ($translated === 'Candidate') {
        $translated = 'Caregiver';
    }

    if ($translated === 'Candidates') {
        $translated = 'Caregivers';
    }

    return $translated;
}



add_action('wp_footer', function(){

if(is_page('employer-registration')) : ?>

<script>

jQuery(function($){

    $('#freelancer-radio').closest('div').remove();

    $('#employer-radio')
        .prop('checked',true)
        .trigger('change');

    $('label[for="employer-radio"]')
        .html('<i class="sl sl-icon-briefcase"></i> Employer');

});

</script>

<?php
endif;

}); */


/**
 * Force English labels on WorkScout/Leaflet job search map
 * by redirecting OSM tiles to Wikimedia's English-labeled tiles.
 */
add_action( 'wp_footer', function() {
    ?>
    <script>
    (function() {
        function fixMapTileSrc(img) {
            if (img.src && img.src.indexOf('tile.openstreetmap.org') !== -1) {
                img.src = img.src.replace(
                    /https:\/\/([a-c])\.tile\.openstreetmap\.org\//,
                    'https://$1.maps.wikimedia.org/osm-intl/'
                ) + (img.src.indexOf('?') === -1 ? '?lang=en' : '&lang=en');
            }
        }

        // Existing tiles (page load-এর সময় যা আছে)
        document.querySelectorAll('img.leaflet-tile').forEach(fixMapTileSrc);

        // নতুন tiles (pan, zoom, search, AJAX reload) দেখার জন্য observer
        var observer = new MutationObserver(function(mutations) {
            mutations.forEach(function(mutation) {
                mutation.addedNodes.forEach(function(node) {
                    if (node.nodeType === 1) {
                        if (node.tagName === 'IMG' && node.classList && node.classList.contains('leaflet-tile')) {
                            fixMapTileSrc(node);
                        } else if (node.querySelectorAll) {
                            node.querySelectorAll('img.leaflet-tile').forEach(fixMapTileSrc);
                        }
                    }
                });
            });
        });

        observer.observe(document.body, { childList: true, subtree: true });
    })();
    </script>
    <?php
}, 100 );