<?php
/**
 * Customizer Control: Upgrade to Pro
 *
 * @package Bootstrap Coach
 */

// Exit if accessed directly.
if ( ! defined( 'ABSPATH' ) ) {
	exit;
}

if( ! class_exists( 'Bootstrap_Coach_Control_Upgrade_To_Pro' ) ) {
    /**
     * Upgrade to Pro control
     */
    class Bootstrap_Coach_Control_Upgrade_To_Pro extends WP_Customize_Control {
        /**
         * The control type.
         *
         * @access public
         * @var string
         */
        public $type = 'upgrade-to-pro-control';

        /**
         * Set title.
         *
         * @access public
         * @var string
         */
        public $title = '';

        /**
         * Set items.
         *
         * @access public
         * @var array
         */
        public $items = array();

        /**
         * Set button URL.
         *
         * @access public
         * @var string
         */
        public $button_url = '';

        /**
         * Set button text.
         *
         * @access public
         * @var string
         */
        public $button_text = '';

        /**
         * Refresh the parameters passed to the JavaScript via JSON.
         *
         * @access public
         * @return void
         */
        public function json() {
            $json = parent::json();

            $json['title'] = $this->title;
            $json['items'] = $this->items;
            $json['button_url'] = $this->button_url;
            $json['button_text'] = $this->button_text;

            return $json;
        }

        /**
         * Enqueue control related scripts/styles.
         *
         * @access public
         */
        public function enqueue() {
            wp_enqueue_script(
                'bootstrap-coach-control-upgrade-to-pro-js',
                get_template_directory_uri() . '/inc/custom-controls/upgrade-to-pro/upgrade-to-pro.js',
                array( 'jquery' ),
                BOOTSTRAP_COACH_VERSION,
                true
            );
            wp_enqueue_style(
                'bootstrap-coach-control-upgrade-to-pro-css',
                get_template_directory_uri() . '/inc/custom-controls/upgrade-to-pro/upgrade-to-pro.css',
                array(),
                BOOTSTRAP_COACH_VERSION
            );
        }

        /**
         * Render content.
         */
        public function content_template() {
            ?>
            <div class="upgrade-to-pro-container">
                <div class="upgrade-to-pro-logo">
                    <svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="32" height="32" xml:space="preserve" version="1.1" viewBox="0 0 32 32"><image width="32" height="32" xlink:href="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAAB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fuYT+h3N1ZWdmA1HQdHh51DKbWXoXaQKaXSge4RtemgvwaSlINlKio3G7+OBdZV3qEUnlUPHmyvDo21JCbYxOXJca0AFNw9d0Xf8qJ8t9OV1nNevHaSp2q4epoatL7z99dYll0m6W5rprvxtRsph94dDgrQKPex+HPEa2mUZaAMmG6vC/t4YXDUZos0nyJ9zIrOAPGYvDP8Kl1cuPU6dqanXEQ+vrys80IFrpUvF/KFoXfuKTd+4AAAAASUVORK5CYII="/>
                    </svg>
                </div>
                <div class="upgrade-to-pro-title">{{ data.title }}</div>
                <ul class="upgrade-to-pro-items">
                    <# _.each( data.items, function( item, i ) { #>
                    <li class="upgrade-to-pro-item"><svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg"> <path d="M12.2399 4.23999L6.79994 9.67999L4.55994 7.43999L3.43994 8.55999L6.79994 11.92L13.3599 5.35999L12.2399 4.23999Z" fill="#0284C7"></path></svg><span class="upgrade-to-pro-item-title">{{ item.title }}</span></li>
                    <# }); #>
                </ul>
                <a href="{{{ data.button_url }}}" target="_blank" class="upgrade-to-pro-button">{{data.button_text}}</a>
            </div>
            <?php
        }
    }
}