<?php /** * Customizer custom controls * * @package Theme Palace * @subpackage Kids Education * @since Kids Education 0.1 */ if ( ! class_exists( 'WP_Customize_Control' ) ) { return null; } /** * Customize Control for Taxonomy Select. * * @since Kids Education 0.1 * * @see WP_Customize_Control */ class kids_education_Dropdown_Taxonomies_Control extends WP_Customize_Control { /** * Control type. * * @access public * @var string */ public $type = 'dropdown-taxonomies'; /** * Taxonomy. * * @access public * @var string */ public $taxonomy = ''; /** * Constructor. * * @since Kids Education 0.1 * * @param WP_Customize_Manager $manager Customizer bootstrap instance. * @param string $id Control ID. * @param array $args Optional. Arguments to override class property defaults. */ public function __construct( $manager, $id, $args = array() ) { $taxonomy = 'category'; if ( isset( $args['taxonomy'] ) ) { $taxonomy_exist = taxonomy_exists( esc_attr( $args['taxonomy'] ) ); if ( true === $taxonomy_exist ) { $taxonomy = esc_attr( $args['taxonomy'] ); } } $args['taxonomy'] = $taxonomy; $this->taxonomy = esc_attr( $taxonomy ); parent::__construct( $manager, $id, $args ); } /** * Render content. * * @since Kids Education 0.1 */ public function render_content() { $tax_args = array( 'hierarchical' => 0, 'taxonomy' => $this->taxonomy, ); $taxonomies = get_categories( $tax_args ); ?> <label> <span class="customize-control-title"><?php echo esc_html( $this->label ); ?></span> <?php if ( ! empty( $this->description ) ) : ?> <span class="description customize-control-description"><?php echo esc_html( $this->description ); ?></span> <?php endif; ?> <select <?php $this->link(); ?>> <?php printf( '<option value="%s" %s>%s</option>', '', selected( $this->value(), '', false ), esc_html__('--None--', 'kids-education') ); ?> <?php if ( ! empty( $taxonomies ) ) : ?> <?php foreach ( $taxonomies as $key => $tax ) : ?> <?php printf( '<option value="%s" %s>%s</option>', esc_attr( $tax->term_id ), selected( $this->value(), $tax->term_id, false ), esc_html( $tax->name ) ); ?> <?php endforeach ?> <?php endif ?> </select> </label> <?php } } //Custom control for horizontal line class kids_education_Customize_Horizontal_Line extends WP_Customize_Control { public $type = 'hr'; public function render_content() { ?> <div> <hr style="border: 1px dotted #72777c;" /> </div> <?php } } /** * Customize Control for Category Select. * * @since Kids Education 0.1 * * @see WP_Customize_Control */ class kids_education_Dropdown_Category_Control extends WP_Customize_Control { /** * Control type. * * @access public * @var string */ public $type = 'dropdown-categories'; /** * Category. * * @access public * @var string */ public $taxonomy = ''; /** * Constructor. * * @since Kids Education 0.1 * * @param WP_Customize_Manager $manager Customizer bootstrap instance. * @param string $id Control ID. * @param array $args Optional. Arguments to override class property defaults. */ public function __construct( $manager, $id, $args = array() ) { $taxonomy = 'category'; if ( isset( $args['taxonomy'] ) ) { $taxonomy_exist = taxonomy_exists( esc_attr( $args['taxonomy'] ) ); if ( true === $taxonomy_exist ) { $taxonomy = esc_attr( $args['taxonomy'] ); } } $args['taxonomy'] = $taxonomy; $this->taxonomy = esc_attr( $taxonomy ); parent::__construct( $manager, $id, $args ); } /** * Render content. * * @since Kids Education 0.1 */ public function render_content() { $tax_args = array( 'hierarchical' => 0, 'taxonomy' => $this->taxonomy, ); $taxonomies = get_categories( $tax_args ); ?> <label> <span class="customize-control-title"><?php echo esc_html( $this->label ); ?></span> <?php if ( ! empty( $this->description ) ) : ?> <span class="description customize-control-description"><?php echo esc_html( $this->description ); ?></span> <?php endif; ?> <select <?php $this->link(); ?> multiple> <?php printf( '<option value="%s" %s>%s</option>', '', selected( $this->value(), '', false ), esc_html__('--None--', 'kids-education') ); ?> <?php if ( ! empty( $taxonomies ) ) : ?> <?php foreach ( $taxonomies as $key => $tax ) : ?> <?php printf( '<option value="%s" %s>%s</option>', esc_attr( $tax->term_id ), selected( $this->value(), $tax->term_id, false ), esc_html( $tax->name ) ); ?> <?php endforeach ?> <?php endif ?> </select> </label> <?php echo '<p class="description">'. esc_html__( 'Hold down the Ctrl (windows) / Command (Mac) button to select multiple options.', 'kids-education' ) . '</p>'; } } //Custom control for any note, use label as output description class kids_education_Note_Control extends WP_Customize_Control { public $type = 'description'; public function render_content() { echo '<h2 class="description">' . esc_html( $this->label ) . '</h2>'; } } if ( class_exists( 'TP_Education' ) ) : /** * Customize Control for Event Taxonomy Select. * * @since Kids Education 0.1 * * @see WP_Customize_Control */ class kids_education_Dropdown_Team_Taxonomies_Control extends WP_Customize_Control { /** * Control type. * * @access public * @var string */ public $type = 'dropdown-taxonomies'; /** * Taxonomy. * * @access public * @var string */ public $taxonomy = ''; /** * Constructor. * * @since Kids Education 0.1 * * @param WP_Customize_Manager $manager Customizer bootstrap instance. * @param string $id Control ID. * @param array $args Optional. Arguments to override class property defaults. */ public function __construct( $manager, $id, $args = array() ) { $taxonomy = 'tp-team-category'; if ( isset( $args['taxonomy'] ) ) { $taxonomy_exist = taxonomy_exists( esc_attr( $args['taxonomy'] ) ); if ( true === $taxonomy_exist ) { $taxonomy = esc_attr( $args['taxonomy'] ); } } $args['taxonomy'] = $taxonomy; $this->taxonomy = esc_attr( $taxonomy ); parent::__construct( $manager, $id, $args ); } /** * Render content. * * @since Kids Education 0.1 */ public function render_content() { $tax_args = array( 'hierarchical' => 0, 'taxonomy' => $this->taxonomy, ); $taxonomies = get_categories( $tax_args ); ?> <label> <span class="customize-control-title"><?php echo esc_html( $this->label ); ?></span> <?php if ( ! empty( $this->description ) ) : ?> <span class="description customize-control-description"><?php echo esc_html( $this->description ); ?></span> <?php endif; ?> <select <?php $this->link(); ?>> <?php printf( '<option value="%s" %s>%s</option>', '', selected( $this->value(), '', false ), esc_html__('--None--', 'kids-education') ); ?> <?php if ( ! empty( $taxonomies ) ) : ?> <?php foreach ( $taxonomies as $key => $tax ) : ?> <?php printf( '<option value="%s" %s>%s</option>', esc_attr( $tax->term_id ), selected( $this->value(), $tax->term_id, false ), esc_html( $tax->name ) ); ?> <?php endforeach ?> <?php endif ?> </select> </label> <?php echo '<p class="description">'. esc_html__( 'Hold down the Ctrl (windows) / Command (Mac) button to select multiple options.', 'kids-education' ) . '</p>'; } } endif;