<?php
/*
 * Class MP_Profit_Plugin_Google_Map
 * 
 * add location section
 */

class MP_Profit_Plugin_Google_Map {

    public function __construct() {
        add_action('mp_profit_section_google_map', array($this, 'get_html'));
    }

    /*
     * Get default sidebar 
     */

    public function get_default_sidebar() {
        $args = array(
            'before_title' => '',
            'after_title' => '',
            'before_widget' => '',
            'after_widget' => '',
        );
        $instance = array(
            'latidute' => '53.480602',
            'longitude' => '-2.242544',
            'text' => '<strong>Address:</strong> 1254/21 West-Holland Street, Manchester, United Kingdom<br/><strong>Phone:</strong> 345-677-554<br/><strong>Open:</strong> 8:30 am - 9:00 pm'
        );
        wp_cache_delete('widget-mp-profit-location', 'widget');
        the_widget('MP_Profit_Plugin_Widget_GoogleMap', $instance, $args);
    }

    /*
     * Get sidebar 
     */

    public function get_sidebar() {
        /*
         * mp_profit_before_sidebar_location hook
         *
         * @hooked mp_profit_before_sidebar_location - 10 
         */
        do_action('mp_profit_before_sidebar_location');
        ?>
        <?php
        if (is_active_sidebar('sidebar-location')) :
            dynamic_sidebar('sidebar-location');
        else:
            $this->get_default_sidebar();
        endif;
        ?>
        <?php
        /*
         * mp_profit_after_sidebar_location hook
         *
         * @hooked mp_profit_after_sidebar_location - 10 
         */
        do_action('mp_profit_after_sidebar_location');
    }

    public function get_html() {
        ?>
        <section id="location" class="location-section">
            <div class="section-content">
                <?php
                $this->get_sidebar();
                ?>
            </div>
        </section>
        <?php
    }

}
