add_control( new Beetan_Customize_Number_Control( $wp_customize, 'id', array( 'label' => esc_html__( 'Label', 'beetan' ), 'description' => esc_html__( 'Description', 'beetan' ), 'section' => 'section', 'required' => array( 'abcd' ), 'input_attrs' => array( 'min' => 1, 'max' => 100, 'step' => 1, ) ) ) );*/ if ( ! class_exists( 'Beetan_Customize_Number_Control' ) ): class Beetan_Customize_Number_Control extends WP_Customize_Control { public $type = 'number'; private $placeholder; private $extras = array(); private $required = array(); public function __construct( $manager, $id, $args = array() ) { parent::__construct( $manager, $id, $args ); $this->placeholder = isset( $args[ 'placeholder' ] ) ? $args[ 'placeholder' ] : ''; $this->extras = isset( $args[ 'extras' ] ) ? $args[ 'extras' ] : array(); $this->required = isset( $args[ 'required' ] ) ? $args[ 'required' ] : array(); $this->input_attrs = wp_parse_args( isset( $args[ 'input_attrs' ] ) ? $args[ 'input_attrs' ] : array(), array( 'min' => 0, 'max' => 100, 'step' => 1 ) ); if ( ! isset( $this->extras[ 'id' ] ) ) { $this->extras[ 'id' ] = $id; } } public function to_json() { parent::to_json(); $this->json[ 'placeholder' ] = $this->placeholder; $this->json[ 'extras' ] = $this->extras; $this->json[ 'required' ] = $this->required; } public function enqueue() { $suffix = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min'; wp_enqueue_script( 'customize-number-control', esc_url( get_theme_file_uri( "/assets/js/customize-number-control$suffix.js" ) ), array( 'jquery' ), FALSE, TRUE ); wp_enqueue_style( 'customize-number-control', esc_url( get_theme_file_uri( "/assets/css/customize-number-control$suffix.css" ) ) ); } protected function render_content() { ?>