PluginProbe ʕ •ᴥ•ʔ
Kirki – Freeform Page Builder, Website Builder & Customizer / 6.0.13
Kirki – Freeform Page Builder, Website Builder & Customizer v6.0.13
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 / responsive / src / Control / Responsive.php
kirki / customizer / packages / controls / responsive / src / Control Last commit date
Responsive.php 3 months ago
Responsive.php
116 lines
1 <?php
2 /**
3 * Customizer Control: kirki-responsive.
4 *
5 * @package kirki-responsive
6 * @since 1.0
7 */
8
9 namespace Kirki\Control;
10
11 use Kirki\Control\Base;
12 use Kirki\URL;
13
14 // Exit if accessed directly.
15 if ( ! defined( 'ABSPATH' ) ) {
16 exit;
17 }
18
19 /**
20 * Responsive control
21 */
22 class Responsive extends Base {
23
24 /**
25 * The control type.
26 *
27 * @since 1.0
28 * @var string
29 */
30 public $type = 'kirki-responsive';
31
32 /**
33 * The version. Used in scripts & styles for cache-busting.
34 *
35 * @since 1.0
36 * @var string
37 */
38 public static $control_ver = '1.0.0';
39
40 /**
41 * Enqueue control related styles/scripts.
42 *
43 * @since 1.0
44 * @access public
45 */
46
47
48 /**
49 * Refresh the parameters passed to the JavaScript via JSON.
50 *
51 * @access public
52 * @since 1.0
53 * @see WP_Customize_Control::to_json()
54 * @return void
55 */
56 public function to_json() {
57
58 // Get the basics from the parent class.
59 parent::to_json();
60
61 $device_icons = [
62 'desktop' => 'dashicons-desktop',
63 'tablet' => 'dashicons-tablet',
64 'mobile' => 'dashicons-smartphone',
65 ];
66
67 $devices = isset( $this->choices['devices'] ) ? $this->choices['devices'] : [];
68
69 $device_menu = '';
70 $loop_index = 0;
71
72 foreach ( $devices as $device ) {
73 $loop_index++;
74
75 $device_menu .= '
76 <li class="kirki-device-button kirki-device-button-' . $device . ( 1 === $loop_index ? ' is-active' : '' ) . '" data-kirki-device="' . esc_attr( $device ) . '">
77 <i class="dashicons ' . esc_html( $device_icons[ $device ] ) . '"></i>
78 </li>
79 ';
80 }
81
82 $this->json['deviceMenu'] = $device_menu;
83
84 }
85
86 /**
87 * An Underscore (JS) template for this control's content (but not its container).
88 *
89 * Class variables for this control class are available in the `data` JS object;
90 * export custom variables by overriding {@see WP_Customize_Control::to_json()}.
91 *
92 * @see WP_Customize_Control::print_template()
93 * @since 1.0
94 */
95 protected function content_template() {
96 ?>
97
98 <div class="kirki-responsive" data-kirki-responsive-id="{{{ data.settings.default }}}">
99 <div class="kirki-control-label">
100 <div class="customize-control-title">
101 <span>{{{ data.label }}}</span>
102 </div>
103 <# if (data.description) { #>
104 <div class="customize-control-description">{{{ data.description }}}</div>
105 <# } #>
106 </div>
107 <ul class="kirki-device-buttons">
108 {{{ data.deviceMenu }}}
109 </ul>
110 </div>
111
112 <?php
113 }
114
115 }
116