PluginProbe ʕ •ᴥ•ʔ
Kirki – Freeform Page Builder, Website Builder & Customizer / 6.1.1
Kirki – Freeform Page Builder, Website Builder & Customizer v6.1.1
6.1.1 6.1.0 6.0.14 6.0.13 6.0.12 6.0.11 6.0.10 6.0.9 6.0.8 6.0.7 6.0.6 6.0.5 6.0.4 6.0.3 6.0.2 6.0.1 3.1.3 3.1.4 3.1.5 3.1.6 3.1.7 3.1.8 3.1.9 4.0.19 4.0.20 4.0.21 4.0.22 4.0.23 4.0.24 4.1 4.2.0 5.0.0 5.1.0 5.1.1 5.2.0 5.2.1 5.2.2 5.2.3 6.0.0 trunk 3.0.40 3.0.41 3.0.42 3.0.43 3.0.44 3.0.45 3.1.0 3.1.1 3.1.2
kirki / customizer / packages / controls / radio / src / Control / Radio_Image.php
kirki / customizer / packages / controls / radio / src / Control Last commit date
Radio.php 3 months ago Radio_Buttonset.php 3 months ago Radio_Image.php 3 months ago
Radio_Image.php
98 lines
1 <?php
2 /**
3 * Customizer Control: radio-image.
4 *
5 * @package kirki-framework/control-radio
6 * @copyright Copyright (c) 2023, Themeum
7 * @license https://opensource.org/licenses/MIT
8 * @since 1.0
9 */
10
11 namespace Kirki\Control;
12
13 use Kirki\Control\Base;
14 use Kirki\URL;
15
16 // Exit if accessed directly.
17 if ( ! defined( 'ABSPATH' ) ) {
18 exit;
19 }
20
21 /**
22 * Radio Image control (modified radio).
23 */
24 class Radio_Image extends Base {
25
26 /**
27 * The control type.
28 *
29 * @access public
30 * @var string
31 */
32 public $type = 'kirki-radio-image';
33
34 /**
35 * Enqueue control related scripts/styles.
36 *
37 * @access public
38 */
39
40
41 /**
42 * Refresh the parameters passed to the JavaScript via JSON.
43 *
44 * @see WP_Customize_Control::to_json()
45 *
46 * @access public
47 * @since 1.0
48 * @return void
49 */
50 public function to_json() {
51 parent::to_json();
52 foreach ( $this->input_attrs as $attr => $value ) {
53 if ( 'style' !== $attr ) {
54 $this->json['inputAttrs'] .= $attr . '="' . esc_attr( $value ) . '" ';
55 continue;
56 }
57 $this->json['labelStyle'] = 'style="' . esc_attr( $value ) . '" ';
58 }
59 }
60
61 /**
62 * An Underscore (JS) template for this control's content (but not its container).
63 *
64 * Class variables for this control class are available in the `data` JS object;
65 * export custom variables by overriding {@see WP_Customize_Control::to_json()}.
66 *
67 * @see WP_Customize_Control::print_template()
68 *
69 * @access protected
70 * @since 1.0
71 * @return void
72 */
73 protected function content_template() {
74 ?>
75 <label class="customizer-text">
76 <# if ( data.label ) { #><span class="customize-control-title">{{{ data.label }}}</span><# } #>
77 <# if ( data.description ) { #><span class="description customize-control-description">{{{ data.description }}}</span><# } #>
78 </label>
79 <div id="input_{{ data.id }}" class="image">
80 <# for ( key in data.choices ) { #>
81 <# dataAlt = ( _.isObject( data.choices[ key ] ) && ! _.isUndefined( data.choices[ key ].alt ) ) ? data.choices[ key ].alt : '' #>
82 <input {{{ data.inputAttrs }}} class="image-select" type="radio" value="{{ key }}" name="_customize-radio-{{ data.id }}" id="{{ data.id }}{{ key }}" {{{ data.link }}}<# if ( data.value === key ) { #> checked="checked"<# } #> data-alt="{{ dataAlt }}">
83 <label for="{{ data.id }}{{ key }}" {{{ data.labelStyle }}} class="{{{ data.id + key }}}">
84 <# if ( _.isObject( data.choices[ key ] ) ) { #>
85 <img src="{{ data.choices[ key ].src }}" alt="{{ data.choices[ key ].alt }}">
86 <span class="image-label"><span class="inner">{{ data.choices[ key ].alt }}</span></span>
87 <# } else { #>
88 <img src="{{ data.choices[ key ] }}">
89 <# } #>
90 <span class="image-clickable"></span>
91 </label>
92 </input>
93 <# } #>
94 </div>
95 <?php
96 }
97 }
98