PluginProbe ʕ •ᴥ•ʔ
Kirki – Freeform Page Builder, Website Builder & Customizer / 6.2.0
Kirki – Freeform Page Builder, Website Builder & Customizer v6.2.0
6.2.1 6.2.0 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 / dashicons / src / Control / Dashicons.php
kirki / customizer / packages / controls / dashicons / src / Control Last commit date
Dashicons.php 4 months ago
Dashicons.php
133 lines
1 <?php
2 /**
3 * Customizer Control: dashicons.
4 *
5 * @package kirki-framework/control-dashicons
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\URL;
14 use Kirki\Control\Base;
15
16 // Exit if accessed directly.
17 if ( ! defined( 'ABSPATH' ) ) {
18 exit;
19 }
20
21 /**
22 * Dashicons control (modified radio).
23 *
24 * @since 1.0
25 */
26 class Dashicons extends Base {
27
28 /**
29 * The control type.
30 *
31 * @access public
32 * @since 1.0
33 * @var string
34 */
35 public $type = 'kirki-dashicons';
36
37 /**
38 * The version. Used in scripts & styles for cache-busting.
39 *
40 * @static
41 * @access public
42 * @since 1.0.2
43 * @var string
44 */
45 public static $control_ver = '1.0';
46
47 /**
48 * Enqueue control related scripts/styles.
49 *
50 * @access public
51 * @since 1.0
52 * @return void
53 */
54
55
56 /**
57 * Refresh the parameters passed to the JavaScript via JSON.
58 *
59 * @access public
60 * @since 1.0
61 * @return void
62 */
63 public function to_json() {
64 parent::to_json();
65 $this->json['icons'] = \Kirki\Util\Dashicons::get_icons();
66 }
67
68 /**
69 * An Underscore (JS) template for this control's content (but not its container).
70 *
71 * Class variables for this control class are available in the `data` JS object;
72 * export custom variables by overriding {@see WP_Customize_Control::to_json()}.
73 *
74 * @see WP_Customize_Control::print_template()
75 *
76 * @access protected
77 * @since 1.0
78 * @return void
79 */
80 protected function content_template() {
81 ?>
82 <# if ( data.label ) { #><span class="customize-control-title">{{{ data.label }}}</span><# } #>
83 <# if ( data.description ) { #><span class="description customize-control-description">{{{ data.description }}}</span><# } #>
84 <div class="icons-wrapper">
85 <# if ( ! _.isUndefined( data.choices ) && 1 < _.size( data.choices ) ) { #>
86 <# for ( key in data.choices ) { #>
87 <input {{{ data.inputAttrs }}} class="dashicons-select" type="radio" value="{{ key }}" name="_customize-dashicons-radio-{{ data.id }}" id="{{ data.id }}{{ key }}" {{{ data.link }}}<# if ( data.value === key ) { #> checked="checked"<# } #>>
88 <label for="{{ data.id }}{{ key }}"><span class="dashicons dashicons-{{ data.choices[ key ] }}"></span></label>
89 </input>
90 <# } #>
91 <# } else { #>
92 <#
93 var dashiconSections = {
94 'admin-menu': '<?php esc_html_e( 'Admin Menu', 'kirki' ); ?>',
95 'welcome-screen': '<?php esc_html_e( 'Welcome Screen', 'kirki' ); ?>',
96 'post-formats': '<?php esc_html_e( 'Post Formats', 'kirki' ); ?>',
97 'media': '<?php esc_html_e( 'Media', 'kirki' ); ?>',
98 'image-editing': '<?php esc_html_e( 'Image Editing', 'kirki' ); ?>',
99 'tinymce': 'TinyMCE',
100 'posts': '<?php esc_html_e( 'Posts', 'kirki' ); ?>',
101 'sorting': '<?php esc_html_e( 'Sorting', 'kirki' ); ?>',
102 'social': '<?php esc_html_e( 'Social', 'kirki' ); ?>',
103 'wordpress_org': 'WordPress',
104 'products': '<?php esc_html_e( 'Products', 'kirki' ); ?>',
105 'taxonomies': '<?php esc_html_e( 'Taxonomies', 'kirki' ); ?>',
106 'widgets': '<?php esc_html_e( 'Widgets', 'kirki' ); ?>',
107 'notifications': '<?php esc_html_e( 'Notifications', 'kirki' ); ?>',
108 'misc': '<?php esc_html_e( 'Miscellaneous', 'kirki' ); ?>'
109 };
110 #>
111 <# _.each( dashiconSections, function( sectionLabel, sectionKey ) { #>
112 <h4>{{ sectionLabel }}</h4>
113 <# for ( key in data.icons[ sectionKey ] ) { #>
114 <input {{{ data.inputAttrs }}}
115 class="dashicons-select"
116 type="radio"
117 value="{{ data.icons[ sectionKey ][ key ] }}"
118 name="_customize-dashicons-radio-{{ data.id }}"
119 id="{{ data.id }}{{ data.icons[ sectionKey ][ key ] }}"
120 {{{ data.link }}}
121 <# if ( data.value === data.icons[ sectionKey ][ key ] ) { #> checked="checked"<# } #>>
122 <label for="{{ data.id }}{{ data.icons[ sectionKey ][ key ] }}">
123 <span class="dashicons dashicons-{{ data.icons[ sectionKey ][ key ] }}"></span>
124 </label>
125 </input>
126 <# } #>
127 <# }); #>
128 <# } #>
129 </div>
130 <?php
131 }
132 }
133