<?php
/*
 * Class MP_Profit_Plugin_Team
 * add team section
 */

class MP_Profit_Plugin_Team {

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

    /*
     * Get default sidebar 
     */

    public function get_default_sidebar() {
        wp_cache_delete('widget-mp-profit-team', 'widget');
        $args = array(
            'before_title' => '',
            'after_title' => '',
            'before_widget' => '<div class="col-xs-12 col-sm-12 col-md-12 col-lg-12">',
            'after_widget' => '</div>',
        );
        $instance = array(
            'name' => __('Jimmie Chen', 'mp-profit'),
            'position' => __('finances', 'mp-profit'),
            'image_uri' => MP_PROFIT_PLUGIN_PATH . '/images/avatar1.jpg',
            'text' => __('Jimmie joined Profit Consulting in 2016 as the Grants and Finance Officer to take on financial coordination and financial management of the organization.', 'mp-profit'),
            'facebook_url' => __('#', 'mp-profit'),
            'twitter_url' => __('#', 'mp-profit'),
            'instagram_url' => __('#', 'mp-profit'),
        );
        the_widget('MP_Profit_Plugin_Widget_Team', $instance, $args);
        $instance = array(
            'name' => __('Dave Brown', 'mp-profit'),
            'position' => __('Risks', 'mp-profit'),
            'image_uri' => MP_PROFIT_PLUGIN_PATH . '/images/avatar2.jpg',
            'text' => __('Dave leads the team on legal strategy and risks. He is a US-qualified lawyer who previously specialized in privacy and intellectual property legislation.', 'mp-profit'),
            'facebook_url' => __('#', 'mp-profit'),
            'twitter_url' => __('#', 'mp-profit'),
            'instagram_url' => __('#', 'mp-profit'),
        );
        the_widget('MP_Profit_Plugin_Widget_Team', $instance, $args);
        ?> <div class="clearfix visible-xs-block"></div> <?php
        $instance = array(
            'name' => __('Bryan Adams', 'mp-profit'),
            'position' => __('investments', 'mp-profit'),
            'image_uri' => MP_PROFIT_PLUGIN_PATH . '/images/avatar3.jpg',
            'text' => __('Bryan is an Investments Technologist with a specific focus on the area of surveillance technologies and the transparent investment strategies.', 'mp-profit'),
            'facebook_url' => __('#', 'mp-profit'),
            'twitter_url' => __('#', 'mp-profit'),
            'instagram_url' => '',
        );
        the_widget('MP_Profit_Plugin_Widget_Team', $instance, $args);
        $instance = array(
            'name' => __('view all team', 'mp-profit'),
            'uri' => '#',
        );
        the_widget('MP_Profit_Plugin_Widget_Button', $instance, $args);
    }

    /*
     * Get sidebar 
     */

    public function get_sidebar() {

        /*
         * mp_profit_before_sidebar_team hook
         *
         * @hooked mp_profit_before_sidebar_team - 10 
         */
        do_action('mp_profit_before_sidebar_team');
        ?>
        <div class="row">
            <?php
            if (is_active_sidebar('sidebar-team')) :
                dynamic_sidebar('sidebar-team');
            else:
                $this->get_default_sidebar();
            endif;
            ?>
        </div>
        <?php
        /*
         * mp_profit_after_sidebar_team hook
         *
         * @hooked mp_profit_after_sidebar_team - 10 
         */
        do_action('mp_profit_after_sidebar_team');
    }

    /*
     * Get title 
     */

    public function get_title() {
        $mp_profit_team_title = esc_html(get_theme_mod('mp_profit_team_title'));
        if (get_theme_mod('mp_profit_team_title', false) === false) :
            ?> 
            <h2 class="section-title"><?php _e('Executive team', 'mp-profit'); ?></h2>
            <?php
        else:
            if (!empty($mp_profit_team_title)):
                ?>
                <h2 class="section-title"><?php echo $mp_profit_team_title; ?></h2>

                <?php
            endif;
        endif;
    }

    /*
     * Get subtitle 
     */

    public function get_subtitle() {
        $mp_profit_team_subtitle = esc_html(get_theme_mod('mp_profit_team_subtitle'));
        if (get_theme_mod('mp_profit_team_subtitle', false) === false) :
            ?> 
            <div class="section-subtitle"><?php _e('We can achieve your goals together', 'mp-profit'); ?></div>
            <?php
        else:
            if (!empty($mp_profit_team_subtitle)):
                ?>
                <div class="section-subtitle"><?php echo $mp_profit_team_subtitle; ?></div>
                <?php
            endif;
        endif;
    }

    public function get_html() {
        ?>
        <section id="team" class="team-section grey-section default-section">
            <div class="section-content">
                <div class="container">
                    <?php
                    $this->get_title();
                    $this->get_subtitle();
                    ?>
                </div>
                <div class="container-fluid">
                    <?php
                    $this->get_sidebar();
                    ?>
                </div>
            </div>
        </section>
        <?php
    }

}
