<?php
/*
 * Class MP_Profit_Plugin_Features
 * 
 * add features section
 */

class MP_Profit_Plugin_Features {

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

    /*
     * Get default sidebar 
     */

    public function get_default_sidebar() {
        echo '<div class="default-features">';
        $args = array(
            'before_name' => '',
            'after_name' => '',
            'before_widget' => '<div id="%1$s" class="widget %1$s col-xs-12 col-sm-12 col-md-12 col-lg-12">',
            'after_widget' => '</div>',
        );
        wp_cache_delete('widget-mp-profit-features', 'widget');
        $instance = array(
            'text' => __('Clients&rsquo; strength and security are our main goals. Trade confidently with the provider you can fully rely on.', 'mp-profit'),
            'subname' => __('personal finance', 'mp-profit'),
            'name' => __('Financial Security', 'mp-profit'),
            'image_uri' => MP_PROFIT_PLUGIN_PATH . '/images/life-ring.png'
        );

        the_widget('MP_Profit_Plugin_Widget_Features', $instance, $args);
        $instance = array(
            'text' => __('We offer individual well-thought and tested strategies so you can easy succeed in a fierce business world.', 'mp-profit'),
            'subname' => __('market data', 'mp-profit'),
            'name' => __('Successful Market Strategies', 'mp-profit'),
            'image_uri' => MP_PROFIT_PLUGIN_PATH . '/images/bullhorn.png'
        );
        the_widget('MP_Profit_Plugin_Widget_Features', $instance, $args);

        $instance = array(
            'text' => __('Stay on the top of the financial market with our free video tutorials, detailed guides and daily updated blog.', 'mp-profit'),
            'subname' => __('24 / 7 support', 'mp-profit'),
            'name' => __('Custom Financial Training', 'mp-profit'),
            'image_uri' => MP_PROFIT_PLUGIN_PATH . '/images/chat.png'
        );
        the_widget('MP_Profit_Plugin_Widget_Features', $instance, $args);
        ?> <div class="clearfix visible-lg-block visible-md-block visible-sm-block"></div> <?php
        $instance = array(
            'text' => __('Join webinars to improve your knowledge and get trade ideas to be the step ahead of your competitors.', 'mp-profit'),
            'subname' => __('advisory agent', 'mp-profit'),
            'name' => __('Live Trading Sessions', 'mp-profit'),
            'image_uri' => MP_PROFIT_PLUGIN_PATH . '/images/money.png'
        );

        the_widget('MP_Profit_Plugin_Widget_Features', $instance, $args);
        $instance = array(
            'text' => __('Pay only when you get result. Our pricing are fully transparent and competitive. You&rsquo;ll like them by far.', 'mp-profit'),
            'subname' => __('unique approach', 'mp-profit'),
            'name' => __('Reliable Pricing', 'mp-profit'),
            'image_uri' => MP_PROFIT_PLUGIN_PATH . '/images/group.png'
        );
        the_widget('MP_Profit_Plugin_Widget_Features', $instance, $args);

        $instance = array(
            'text' => __('Our professional support team is always next to you to answer all questions via chat, email or phone.', 'mp-profit'),
            'subname' => __('creative solutions', 'mp-profit'),
            'name' => __('Customer Support', 'mp-profit'),
            'image_uri' => MP_PROFIT_PLUGIN_PATH . '/images/case.png'
        );
        the_widget('MP_Profit_Plugin_Widget_Features', $instance, $args);
        echo '</div>';
    }

    /*
     * Get sidebar 
     */

    public function get_sidebar() {
        /*
         * mp_profit_before_sidebar_features hook
         *
         * @hooked mp_profit_before_sidebar_features - 10 
         */
        do_action('mp_profit_before_sidebar_features');
        ?>
        <div class="row ">
            <?php
            if (is_active_sidebar('sidebar-features')) :
                dynamic_sidebar('sidebar-features');
            else:
                $this->get_default_sidebar();
            endif;
            ?>
        </div>
        <?php
        /*
         * mp_profit_after_sidebar_features hook
         *
         * @hooked mp_profit_after_sidebar_features - 10 
         */
        do_action('mp_profit_after_sidebar_features');
    }

    /*
     * Get title 
     */

    public function get_title() {
        $mp_profit_features_title = esc_html(get_theme_mod('mp_profit_features_title'));
        if (get_theme_mod('mp_profit_features_title', false) === false) :
            ?> 
            <h2 class="section-title"><?php _e('Reasons to choose us', 'mp-profit'); ?></h2>
            <?php
        else:
            if (!empty($mp_profit_features_title)):
                ?>
                <h2 class="section-title"><?php echo $mp_profit_features_title; ?></h2>
                <?php
            endif;
        endif;
    }

    /*
     * Get subtitle 
     */

    public function get_subtitle() {
        $mp_profit_features_subtitle = esc_html(get_theme_mod('mp_profit_features_subtitle'));
        if (get_theme_mod('mp_profit_features_subtitle', false) === false) :
            ?> 
            <div class="section-subtitle"><?php _e('The best services for your business needs', 'mp-profit'); ?></div>
            <?php
        else:
            if (!empty($mp_profit_features_subtitle)):
                ?>
                <div class="section-subtitle"><?php echo $mp_profit_features_subtitle; ?></div>
                <?php
            endif;
        endif;
    }

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

}
