ru-se.com

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs

class-kirki-controls-multicheck-control.php (2114B)


      1 <?php
      2 /**
      3  * Customizer Control: multicheck.
      4  *
      5  * Multiple checkbox customize control class.
      6  * Props @ Justin Tadlock: http://justintadlock.com/archives/2015/05/26/multiple-checkbox-customizer-control
      7  *
      8  * @package     Kirki
      9  * @subpackage  Controls
     10  * @copyright   Copyright (c) 2016, Aristeides Stathopoulos
     11  * @license     http://opensource.org/licenses/https://opensource.org/licenses/MIT
     12  * @since       1.0
     13  */
     14 
     15 // Exit if accessed directly.
     16 if ( ! defined( 'ABSPATH' ) ) {
     17 	exit;
     18 }
     19 
     20 if ( ! class_exists( 'Kirki_Controls_MultiCheck_Control' ) ) {
     21 
     22 	/**
     23 	 * Adds a multicheck control.
     24 	 */
     25 	class Kirki_Controls_MultiCheck_Control extends Kirki_Customize_Control {
     26 
     27 		/**
     28 		 * The control type.
     29 		 *
     30 		 * @access public
     31 		 * @var string
     32 		 */
     33 		public $type = 'kirki-multicheck';
     34 
     35 		/**
     36 		 * Enqueue control related scripts/styles.
     37 		 *
     38 		 * @access public
     39 		 */
     40 		public function enqueue() {
     41 			wp_enqueue_script( 'kirki-multicheck' );
     42 		}
     43 
     44 		/**
     45 		 * An Underscore (JS) template for this control's content (but not its container).
     46 		 *
     47 		 * Class variables for this control class are available in the `data` JS object;
     48 		 * export custom variables by overriding {@see Kirki_Customize_Control::to_json()}.
     49 		 *
     50 		 * @see WP_Customize_Control::print_template()
     51 		 *
     52 		 * @access protected
     53 		 */
     54 		protected function content_template() {
     55 			?>
     56 
     57 			<# if ( ! data.choices ) { return; } #>
     58 
     59 			<# if ( data.tooltip ) { #>
     60 				<a href="#" class="tooltip hint--left" data-hint="{{ data.tooltip }}"><span class='dashicons dashicons-info'></span></a>
     61 			<# } #>
     62 
     63 			<# if ( data.label ) { #>
     64 				<span class="customize-control-title">{{ data.label }}</span>
     65 			<# } #>
     66 
     67 			<# if ( data.description ) { #>
     68 				<span class="description customize-control-description">{{{ data.description }}}</span>
     69 			<# } #>
     70 
     71 			<ul>
     72 				<# for ( key in data.choices ) { #>
     73 					<li>
     74 						<label>
     75 							<input {{{ data.inputAttrs }}} type="checkbox" value="{{ key }}"<# if ( _.contains( data.value, key ) ) { #> checked<# } #> />
     76 							{{ data.choices[ key ] }}
     77 						</label>
     78 					</li>
     79 				<# } #>
     80 			</ul>
     81 			<?php
     82 		}
     83 	}
     84 }