1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* Customizer Control: dashicons. |
4
|
|
|
* |
5
|
|
|
* @package Kirki |
6
|
|
|
* @subpackage Controls |
7
|
|
|
* @copyright Copyright (c) 2017, Aristeides Stathopoulos |
8
|
|
|
* @license https://opensource.org/licenses/MIT |
9
|
|
|
* @since 2.2.4 |
10
|
|
|
*/ |
11
|
|
|
|
12
|
|
|
// Exit if accessed directly. |
13
|
|
|
if ( ! defined( 'ABSPATH' ) ) { |
14
|
|
|
exit; |
15
|
|
|
} |
16
|
|
|
|
17
|
|
|
/** |
18
|
|
|
* Dashicons control (modified radio). |
19
|
|
|
*/ |
20
|
|
|
class Kirki_Control_Dashicons extends Kirki_Control_Base { |
21
|
|
|
|
22
|
|
|
/** |
23
|
|
|
* The control type. |
24
|
|
|
* |
25
|
|
|
* @access public |
26
|
|
|
* @var string |
27
|
|
|
*/ |
28
|
|
|
public $type = 'kirki-dashicons'; |
29
|
|
|
|
30
|
|
|
/** |
31
|
|
|
* Refresh the parameters passed to the JavaScript via JSON. |
32
|
|
|
* |
33
|
|
|
* @access public |
34
|
|
|
*/ |
35
|
|
|
public function to_json() { |
36
|
|
|
parent::to_json(); |
37
|
|
|
$this->json['icons'] = Kirki_Helper::get_dashicons(); |
38
|
|
|
} |
39
|
|
|
|
40
|
|
|
/** |
41
|
|
|
* An Underscore (JS) template for this control's content (but not its container). |
42
|
|
|
* |
43
|
|
|
* Class variables for this control class are available in the `data` JS object; |
44
|
|
|
* export custom variables by overriding {@see WP_Customize_Control::to_json()}. |
45
|
|
|
* |
46
|
|
|
* @see WP_Customize_Control::print_template() |
47
|
|
|
* |
48
|
|
|
* @access protected |
49
|
|
|
*/ |
50
|
|
|
protected function content_template() { |
51
|
|
|
?> |
52
|
|
|
<# if ( data.label ) { #><span class="customize-control-title">{{{ data.label }}}</span><# } #> |
53
|
|
|
<# if ( data.description ) { #><span class="description customize-control-description">{{{ data.description }}}</span><# } #> |
54
|
|
|
<div class="icons-wrapper"> |
55
|
|
|
<# if ( ! _.isUndefined( data.choices ) && 1 < _.size( data.choices ) ) { #> |
56
|
|
|
<# for ( key in data.choices ) { #> |
57
|
|
|
<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"<# } #>> |
58
|
|
|
<label for="{{ data.id }}{{ key }}"><span class="dashicons dashicons-{{ data.choices[ key ] }}"></span></label> |
59
|
|
|
</input> |
60
|
|
|
<# } #> |
61
|
|
|
<# } else { #> |
62
|
|
|
<h4>Admin Menu</h4> |
63
|
|
|
<# for ( key in data.icons['admin-menu'] ) { #> |
64
|
|
|
<input {{{ data.inputAttrs }}} class="dashicons-select" type="radio" value="{{ data.icons['admin-menu'][ key ] }}" name="_customize-dashicons-radio-{{ data.id }}" id="{{ data.id }}{{ data.icons['admin-menu'][ key ] }}" {{{ data.link }}}<# if ( data.value === data.icons['admin-menu'][ key ] ) { #> checked="checked"<# } #>> |
65
|
|
|
<label for="{{ data.id }}{{ data.icons['admin-menu'][ key ] }}"><span class="dashicons dashicons-{{ data.icons['admin-menu'][ key ] }}"></span></label> |
66
|
|
|
</input> |
67
|
|
|
<# } #> |
68
|
|
|
<h4>Welcome Screen</h4> |
69
|
|
|
<# for ( key in data.icons['welcome-screen'] ) { #> |
70
|
|
|
<input {{{ data.inputAttrs }}} class="dashicons-select" type="radio" value="{{ data.icons['welcome-screen'][ key ] }}" name="_customize-dashicons-radio-{{ data.id }}" id="{{ data.id }}{{ data.icons['welcome-screen'][ key ] }}" {{{ data.link }}}<# if ( data.value === data.icons['welcome-screen'][ key ] ) { #> checked="checked"<# } #>> |
71
|
|
|
<label for="{{ data.id }}{{ data.icons['welcome-screen'][ key ] }}"><span class="dashicons dashicons-{{ data.icons['welcome-screen'][ key ] }}"></span></label> |
72
|
|
|
</input> |
73
|
|
|
<# } #> |
74
|
|
|
<h4>Post Formats</h4> |
75
|
|
|
<# for ( key in data.icons['post-formats'] ) { #> |
76
|
|
|
<input {{{ data.inputAttrs }}} class="dashicons-select" type="radio" value="{{ data.icons['post-formats'][ key ] }}" name="_customize-dashicons-radio-{{ data.id }}" id="{{ data.id }}{{ data.icons['post-formats'][ key ] }}" {{{ data.link }}}<# if ( data.value === data.icons['post-formats'][ key ] ) { #> checked="checked"<# } #>> |
77
|
|
|
<label for="{{ data.id }}{{ data.icons['post-formats'][ key ] }}"><span class="dashicons dashicons-{{ data.icons['post-formats'][ key ] }}"></span></label> |
78
|
|
|
</input> |
79
|
|
|
<# } #> |
80
|
|
|
<h4>Media</h4> |
81
|
|
|
<# for ( key in data.icons['media'] ) { #> |
82
|
|
|
<input {{{ data.inputAttrs }}} class="dashicons-select" type="radio" value="{{ data.icons['media'][ key ] }}" name="_customize-dashicons-radio-{{ data.id }}" id="{{ data.id }}{{ data.icons['media'][ key ] }}" {{{ data.link }}}<# if ( data.value === data.icons['media'][ key ] ) { #> checked="checked"<# } #>> |
83
|
|
|
<label for="{{ data.id }}{{ data.icons['media'][ key ] }}"><span class="dashicons dashicons-{{ data.icons['media'][ key ] }}"></span></label> |
84
|
|
|
</input> |
85
|
|
|
<# } #> |
86
|
|
|
<h4>Image Editing</h4> |
87
|
|
|
<# for ( key in data.icons['image-editing'] ) { #> |
88
|
|
|
<input {{{ data.inputAttrs }}} class="dashicons-select" type="radio" value="{{ data.icons['image-editing'][ key ] }}" name="_customize-dashicons-radio-{{ data.id }}" id="{{ data.id }}{{ data.icons['image-editing'][ key ] }}" {{{ data.link }}}<# if ( data.value === data.icons['image-editing'][ key ] ) { #> checked="checked"<# } #>> |
89
|
|
|
<label for="{{ data.id }}{{ data.icons['image-editing'][ key ] }}"><span class="dashicons dashicons-{{ data.icons['image-editing'][ key ] }}"></span></label> |
90
|
|
|
</input> |
91
|
|
|
<# } #> |
92
|
|
|
<h4>TinyMCE</h4> |
93
|
|
|
<# for ( key in data.icons['tinymce'] ) { #> |
94
|
|
|
<input {{{ data.inputAttrs }}} class="dashicons-select" type="radio" value="{{ data.icons['tinymce'][ key ] }}" name="_customize-dashicons-radio-{{ data.id }}" id="{{ data.id }}{{ data.icons['tinymce'][ key ] }}" {{{ data.link }}}<# if ( data.value === data.icons['tinymce'][ key ] ) { #> checked="checked"<# } #>> |
95
|
|
|
<label for="{{ data.id }}{{ data.icons['tinymce'][ key ] }}"><span class="dashicons dashicons-{{ data.icons['tinymce'][ key ] }}"></span></label> |
96
|
|
|
</input> |
97
|
|
|
<# } #> |
98
|
|
|
<h4>Posts</h4> |
99
|
|
|
<# for ( key in data.icons['posts'] ) { #> |
100
|
|
|
<input {{{ data.inputAttrs }}} class="dashicons-select" type="radio" value="{{ data.icons['posts'][ key ] }}" name="_customize-dashicons-radio-{{ data.id }}" id="{{ data.id }}{{ data.icons['posts'][ key ] }}" {{{ data.link }}}<# if ( data.value === data.icons['posts'][ key ] ) { #> checked="checked"<# } #>> |
101
|
|
|
<label for="{{ data.id }}{{ data.icons['posts'][ key ] }}"><span class="dashicons dashicons-{{ data.icons['posts'][ key ] }}"></span></label> |
102
|
|
|
</input> |
103
|
|
|
<# } #> |
104
|
|
|
<h4>Sorting</h4> |
105
|
|
|
<# for ( key in data.icons['sorting'] ) { #> |
106
|
|
|
<input {{{ data.inputAttrs }}} class="dashicons-select" type="radio" value="{{ data.icons['sorting'][ key ] }}" name="_customize-dashicons-radio-{{ data.id }}" id="{{ data.id }}{{ data.icons['sorting'][ key ] }}" {{{ data.link }}}<# if ( data.value === data.icons['sorting'][ key ] ) { #> checked="checked"<# } #>> |
107
|
|
|
<label for="{{ data.id }}{{ data.icons['sorting'][ key ] }}"><span class="dashicons dashicons-{{ data.icons['sorting'][ key ] }}"></span></label> |
108
|
|
|
</input> |
109
|
|
|
<# } #> |
110
|
|
|
<h4>Social</h4> |
111
|
|
|
<# for ( key in data.icons['social'] ) { #> |
112
|
|
|
<input {{{ data.inputAttrs }}} class="dashicons-select" type="radio" value="{{ data.icons['social'][ key ] }}" name="_customize-dashicons-radio-{{ data.id }}" id="{{ data.id }}{{ data.icons['social'][ key ] }}" {{{ data.link }}}<# if ( data.value === data.icons['social'][ key ] ) { #> checked="checked"<# } #>> |
113
|
|
|
<label for="{{ data.id }}{{ data.icons['social'][ key ] }}"><span class="dashicons dashicons-{{ data.icons['social'][ key ] }}"></span></label> |
114
|
|
|
</input> |
115
|
|
|
<# } #> |
116
|
|
|
<h4>WordPress</h4> |
117
|
|
|
<# for ( key in data.icons['wordpress_org'] ) { #> |
118
|
|
|
<input {{{ data.inputAttrs }}} class="dashicons-select" type="radio" value="{{ data.icons['wordpress_org'][ key ] }}" name="_customize-dashicons-radio-{{ data.id }}" id="{{ data.id }}{{ data.icons['wordpress_org'][ key ] }}" {{{ data.link }}}<# if ( data.value === data.icons['wordpress_org'][ key ] ) { #> checked="checked"<# } #>> |
119
|
|
|
<label for="{{ data.id }}{{ data.icons['wordpress_org'][ key ] }}"><span class="dashicons dashicons-{{ data.icons['wordpress_org'][ key ] }}"></span></label> |
120
|
|
|
</input> |
121
|
|
|
<# } #> |
122
|
|
|
<h4>Products</h4> |
123
|
|
|
<# for ( key in data.icons['products'] ) { #> |
124
|
|
|
<input {{{ data.inputAttrs }}} class="dashicons-select" type="radio" value="{{ data.icons['products'][ key ] }}" name="_customize-dashicons-radio-{{ data.id }}" id="{{ data.id }}{{ data.icons['products'][ key ] }}" {{{ data.link }}}<# if ( data.value === data.icons['products'][ key ] ) { #> checked="checked"<# } #>> |
125
|
|
|
<label for="{{ data.id }}{{ data.icons['products'][ key ] }}"><span class="dashicons dashicons-{{ data.icons['products'][ key ] }}"></span></label> |
126
|
|
|
</input> |
127
|
|
|
<# } #> |
128
|
|
|
<h4>Taxonomies</h4> |
129
|
|
|
<# for ( key in data.icons['taxonomies'] ) { #> |
130
|
|
|
<input {{{ data.inputAttrs }}} class="dashicons-select" type="radio" value="{{ data.icons['taxonomies'][ key ] }}" name="_customize-dashicons-radio-{{ data.id }}" id="{{ data.id }}{{ data.icons['taxonomies'][ key ] }}" {{{ data.link }}}<# if ( data.value === data.icons['taxonomies'][ key ] ) { #> checked="checked"<# } #>> |
131
|
|
|
<label for="{{ data.id }}{{ data.icons['taxonomies'][ key ] }}"><span class="dashicons dashicons-{{ data.icons['taxonomies'][ key ] }}"></span></label> |
132
|
|
|
</input> |
133
|
|
|
<# } #> |
134
|
|
|
<h4>Widgets</h4> |
135
|
|
|
<# for ( key in data.icons['widgets'] ) { #> |
136
|
|
|
<input {{{ data.inputAttrs }}} class="dashicons-select" type="radio" value="{{ data.icons['widgets'][ key ] }}" name="_customize-dashicons-radio-{{ data.id }}" id="{{ data.id }}{{ data.icons['widgets'][ key ] }}" {{{ data.link }}}<# if ( data.value === data.icons['widgets'][ key ] ) { #> checked="checked"<# } #>> |
137
|
|
|
<label for="{{ data.id }}{{ data.icons['widgets'][ key ] }}"><span class="dashicons dashicons-{{ data.icons['widgets'][ key ] }}"></span></label> |
138
|
|
|
</input> |
139
|
|
|
<# } #> |
140
|
|
|
<h4>Notifications</h4> |
141
|
|
|
<# for ( key in data.icons['notifications'] ) { #> |
142
|
|
|
<input {{{ data.inputAttrs }}} class="dashicons-select" type="radio" value="{{ data.icons['notifications'][ key ] }}" name="_customize-dashicons-radio-{{ data.id }}" id="{{ data.id }}{{ data.icons['notifications'][ key ] }}" {{{ data.link }}}<# if ( data.value === data.icons['notifications'][ key ] ) { #> checked="checked"<# } #>> |
143
|
|
|
<label for="{{ data.id }}{{ data.icons['notifications'][ key ] }}"><span class="dashicons dashicons-{{ data.icons['notifications'][ key ] }}"></span></label> |
144
|
|
|
</input> |
145
|
|
|
<# } #> |
146
|
|
|
<h4>Misc</h4> |
147
|
|
|
<# for ( key in data.icons['misc'] ) { #> |
148
|
|
|
<input {{{ data.inputAttrs }}} class="dashicons-select" type="radio" value="{{ data.icons['misc'][ key ] }}" name="_customize-dashicons-radio-{{ data.id }}" id="{{ data.id }}{{ data.icons['misc'][ key ] }}" {{{ data.link }}}<# if ( data.value === data.icons['misc'][ key ] ) { #> checked="checked"<# } #>> |
149
|
|
|
<label for="{{ data.id }}{{ data.icons['misc'][ key ] }}"><span class="dashicons dashicons-{{ data.icons['misc'][ key ] }}"></span></label> |
150
|
|
|
</input> |
151
|
|
|
<# } #> |
152
|
|
|
<# } #> |
153
|
|
|
</div> |
154
|
|
|
<?php |
155
|
|
|
} |
156
|
|
|
} |
157
|
|
|
|