<?php
/* current year in copyright */
function year_shortcode() {
$year = date('Y');
return $year;
}
add_shortcode('year', 'year_shortcode');


/* custom map */
function customMap() {
    return '<div id="custom-map"><script src="https://maps.googleapis.com/maps/api/js?key=AIzaSyDMG5PTq_3M3Pc0jf4nwpfmNV1D8lLKU2U&callback=initMap&v=weekly" defer></script>
    <script>
        let map;
        let image;
        
        function initMap() {
            map = new google.maps.Map(document.getElementById("custom-map"), {
                center: new google.maps.LatLng(41.74088139667338, -71.30636039635661),
                zoom: 16,
            });
    
            setMarkers(map);
    
            var marker = new google.maps.Marker({
                position: new google.maps.LatLng(41.74088139667338, -71.30636039635661),
                map: map,
                icon: image,
            });
    
        }
    
        function setMarkers(map) {
            image = {
                url: "/wp-content/uploads/2023/05/radial-pin.png",
                size: new google.maps.Size(305, 305),
                anchor: new google.maps.Point(130, 130),
            };
    
        }
    
        window.initMap = initMap;
    </script></div>';
}
add_shortcode( 'custom-map', 'customMap' );


/* Get Started Btn */
function getStartedBtn() {
    return '<a href="/schedule-your-appointment/" class="main-btn">Get Started Today</a>';
}
add_shortcode( 'get-started-btn', 'getStartedBtn' );

if( !function_exists('_add_my_quicktags') ){
    function _add_my_quicktags()
    { ?>
        <script type="text/javascript">
          window.onload = function(){
            QTags.addButton( 'customMap', 'Custom Map', '[custom-map]' );
            QTags.addButton( 'getStartedBtn', 'Get Started Btn', '[get-started-btn]' );
          }
        </script>
    <?php }
    // We can attach it to 'admin_print_footer_scripts' (for admin-only) or 'wp_footer' (for front-end only)
    add_action('admin_print_footer_scripts',  '_add_my_quicktags');
}