vk-customize-helpers.php
54 lines
| 1 | <?php |
| 2 | // Do not load directly. |
| 3 | if ( ! defined( 'ABSPATH' ) ) { |
| 4 | exit; |
| 5 | } |
| 6 | |
| 7 | add_action( 'customize_register', 'vk_register_customize_helpers', 1 ); |
| 8 | if ( ! function_exists( 'vk_register_customize_helpers' ) ){ |
| 9 | function vk_register_customize_helpers( $wp_customize ) { |
| 10 | /* Add text control description |
| 11 | /*-------------------------------------------*/ |
| 12 | if ( ! class_exists( 'Custom_Text_Control' ) ) { |
| 13 | class Custom_Text_Control extends WP_Customize_Control { |
| 14 | public $type = 'customtext'; |
| 15 | public $description = ''; // we add this for the extra description |
| 16 | public $input_before = ''; |
| 17 | public $input_after = ''; |
| 18 | public function render_content() { |
| 19 | ?> |
| 20 | <label> |
| 21 | <span class="customize-control-title"><?php echo esc_html( $this->label ); ?></span> |
| 22 | <div> |
| 23 | <?php echo wp_kses_post( $this->input_before ); ?> |
| 24 | <input type="text" value="<?php echo esc_attr( $this->value() ); ?>"<?php if ( $this->input_before || $this->input_after ) : ?> style="width:50%"<?php endif; ?> <?php $this->link(); ?> /> |
| 25 | <?php echo wp_kses_post( $this->input_after ); ?> |
| 26 | </div> |
| 27 | <div><?php echo wp_kses_post( $this->description ); ?></div> |
| 28 | </label> |
| 29 | <?php |
| 30 | } // public function render_content() { |
| 31 | } // class Custom_Text_Control extends WP_Customize_Control |
| 32 | } |
| 33 | |
| 34 | if ( ! class_exists( 'Custom_Html_Control' ) ) { |
| 35 | class Custom_Html_Control extends WP_Customize_Control { |
| 36 | public $type = 'customtext'; |
| 37 | public $custom_title_sub = ''; // we add this for the extra custom_html |
| 38 | public $custom_html = ''; // we add this for the extra custom_html |
| 39 | public function render_content() { |
| 40 | if ( $this->label ) { |
| 41 | echo '<h2 class="admin-custom-h2">' . wp_kses_post( $this->label ) . '</h2>'; |
| 42 | } |
| 43 | if ( $this->custom_title_sub ) { |
| 44 | echo '<h3 class="admin-custom-h3">' . wp_kses_post( $this->custom_title_sub ) . '</h3>'; |
| 45 | } |
| 46 | if ( $this->custom_html ) { |
| 47 | echo '<div>' . wp_kses_post( $this->custom_html ) . '</div>'; |
| 48 | } |
| 49 | } // public function render_content() { |
| 50 | } // class Custom_Html_Control extends WP_Customize_Control { |
| 51 | } |
| 52 | } |
| 53 | } |
| 54 |