<?php
    /**
     * Base class that extends WP_Customzier_Control
     * 
     * @package Blog Bee
     * @see WP_Customzier_Control
     * 
     * @since 1.0.0
     */
    namespace BBE\Customizer;
    
    if( ! class_exists( __NAMESPACE__ . '\\Base' ) ) {
        /**
         * Base Class
         */
        abstract class Base extends \WP_Customize_Control {
            /**
             * Tab
             * 
             * @var string
             * @since 1.0.0
             */
            public $tab = 'general';

            /**
             * Control type
             * Acts the same was as $type but for our own purpose
             * 
             * @since 1.0.0
             */
            protected static $control_type = '';

            /**
             * Get all controls
             * 
             * @since 1.0.0
             */
            protected static $custom_controls = [];

            /**
             * Get all custom controls
             * 
             * @since 1.0.0
             */
            public static function get_all_custom_controls() {
                return self::$custom_controls;
            }

            /**
             * Set control type
             * 
             * @since 1.0.0
             * @param   string  $control_type   The type of control
             * @param   string  $class_name     The class name
             */
            public static function set_control_type( $control_type, $class_name = '' ) {
                if( $class_name ) {
                    self::$custom_controls[ $control_type ] = $class_name;
                } else {
                    self::$custom_controls[ $control_type ] = static::class;
                }
            }

            /**
             * Contructor
             * 
             * @since 1.0.0
             */
            public function __construct( $manager, $id, $args = [] ) {
                parent::__construct( $manager, $id, $args );
            }

            /**
             * Conditions
             * 
             * @var array
             * @since 1.0.0
             */
            public $conditions = [];

            /**
             * Parameters to send
             * 
             * @since 1.0.0
             * @override 
             */
            public function to_json() {
                parent::to_json();
                $this->json[ 'tab' ] = $this->tab;
                $this->json[ 'conditions' ] = $this->conditions;
            }

            /**
             * Add custom container
             * 
             * @since 1.0.0
             * @override
             */
            public function render_content() {
                ?>
                    <div class="root"></div>
                <?php
            }
        }
    }