1 | <?php |
||
16 | class Kirki_Init { |
||
17 | |||
18 | /** |
||
19 | * Control types. |
||
20 | * |
||
21 | * @access private |
||
22 | * @since 3.0.0 |
||
23 | * @var array |
||
24 | */ |
||
25 | private $control_types = array(); |
||
26 | |||
27 | /** |
||
28 | * The class constructor. |
||
29 | */ |
||
30 | public function __construct() { |
||
31 | |||
32 | $this->set_url(); |
||
33 | add_action( 'after_setup_theme', array( $this, 'set_url' ) ); |
||
34 | add_action( 'wp_loaded', array( $this, 'add_to_customizer' ), 1 ); |
||
35 | add_filter( 'kirki/control_types', array( $this, 'default_control_types' ) ); |
||
36 | |||
37 | new Kirki_Custom_Build(); |
||
38 | } |
||
39 | |||
40 | /** |
||
41 | * Properly set the Kirki URL for assets. |
||
42 | * Determines if Kirki is installed as a plugin, in a child theme, or a parent theme |
||
43 | * and then does some calculations to get the proper URL for its CSS & JS assets. |
||
44 | */ |
||
45 | public function set_url() { |
||
92 | |||
93 | /** |
||
94 | * Add the default Kirki control types. |
||
95 | * |
||
96 | * @access public |
||
97 | * @since 3.0.0 |
||
98 | * @param array $control_types The control types array. |
||
99 | * @return array |
||
100 | */ |
||
101 | public function default_control_types( $control_types = array() ) { |
||
102 | |||
103 | $this->control_types = array( |
||
104 | 'checkbox' => 'WP_Customize_Control', |
||
105 | 'kirki-background' => 'Kirki_Control_Background', |
||
106 | 'kirki-code' => 'Kirki_Control_Code', |
||
107 | 'kirki-color' => 'Kirki_Control_Color', |
||
108 | 'kirki-color-palette' => 'Kirki_Control_Color_Palette', |
||
109 | 'kirki-custom' => 'Kirki_Control_Custom', |
||
110 | 'kirki-date' => 'Kirki_Control_Date', |
||
111 | 'kirki-dashicons' => 'Kirki_Control_Dashicons', |
||
112 | 'kirki-dimension' => 'Kirki_Control_Dimension', |
||
113 | 'kirki-dimensions' => 'Kirki_Control_Dimensions', |
||
114 | 'kirki-editor' => 'Kirki_Control_Editor', |
||
115 | 'kirki-fontawesome' => 'Kirki_Control_FontAwesome', |
||
116 | 'kirki-gradient' => 'Kirki_Control_Gradient', |
||
117 | 'kirki-image' => 'Kirki_Control_Image', |
||
118 | 'kirki-multicolor' => 'Kirki_Control_Multicolor', |
||
119 | 'kirki-multicheck' => 'Kirki_Control_MultiCheck', |
||
120 | 'kirki-number' => 'Kirki_Control_Number', |
||
121 | 'kirki-palette' => 'Kirki_Control_Palette', |
||
122 | 'kirki-preset' => 'Kirki_Control_Preset', |
||
123 | 'kirki-radio' => 'Kirki_Control_Radio', |
||
124 | 'kirki-radio-buttonset' => 'Kirki_Control_Radio_ButtonSet', |
||
125 | 'kirki-radio-image' => 'Kirki_Control_Radio_Image', |
||
126 | 'repeater' => 'Kirki_Control_Repeater', |
||
127 | 'kirki-select' => 'Kirki_Control_Select', |
||
128 | 'kirki-slider' => 'Kirki_Control_Slider', |
||
129 | 'kirki-sortable' => 'Kirki_Control_Sortable', |
||
130 | 'kirki-spacing' => 'Kirki_Control_Dimensions', |
||
131 | 'kirki-switch' => 'Kirki_Control_Switch', |
||
132 | 'kirki-generic' => 'Kirki_Control_Generic', |
||
133 | 'kirki-toggle' => 'Kirki_Control_Toggle', |
||
134 | 'kirki-typography' => 'Kirki_Control_Typography', |
||
135 | 'image' => 'Kirki_Control_Image', |
||
136 | 'cropped_image' => 'WP_Customize_Cropped_Image_Control', |
||
137 | 'upload' => 'WP_Customize_Upload_Control', |
||
138 | ); |
||
139 | return array_merge( $control_types, $this->control_types ); |
||
140 | |||
141 | } |
||
142 | |||
143 | /** |
||
144 | * Helper function that adds the fields, sections and panels to the customizer. |
||
145 | * |
||
146 | * @return void |
||
147 | */ |
||
148 | public function add_to_customizer() { |
||
149 | $this->fields_from_filters(); |
||
150 | add_action( 'customize_register', array( $this, 'register_control_types' ) ); |
||
151 | add_action( 'customize_register', array( $this, 'add_panels' ), 97 ); |
||
152 | add_action( 'customize_register', array( $this, 'add_sections' ), 98 ); |
||
153 | add_action( 'customize_register', array( $this, 'add_fields' ), 99 ); |
||
154 | } |
||
155 | |||
156 | /** |
||
157 | * Register control types |
||
158 | * |
||
159 | * @return void |
||
160 | */ |
||
161 | public function register_control_types() { |
||
180 | |||
181 | /** |
||
182 | * Register our panels to the WordPress Customizer. |
||
183 | * |
||
184 | * @access public |
||
185 | */ |
||
186 | public function add_panels() { |
||
201 | |||
202 | /** |
||
203 | * Register our sections to the WordPress Customizer. |
||
204 | * |
||
205 | * @var object The WordPress Customizer object |
||
206 | * @return void |
||
207 | */ |
||
208 | public function add_sections() { |
||
227 | |||
228 | /** |
||
229 | * Create the settings and controls from the $fields array and register them. |
||
230 | * |
||
231 | * @var object The WordPress Customizer object |
||
232 | * @return void |
||
233 | */ |
||
234 | public function add_fields() { |
||
253 | |||
254 | /** |
||
255 | * Process fields added using the 'kirki/fields' and 'kirki/controls' filter. |
||
256 | * These filters are no longer used, this is simply for backwards-compatibility. |
||
257 | * |
||
258 | * @access private |
||
259 | * @since 2.0.0 |
||
260 | */ |
||
261 | private function fields_from_filters() { |
||
272 | |||
273 | /** |
||
274 | * Alias for the is_plugin static method in the Kirki_Util class. |
||
275 | * This is here for backwards-compatibility purposes. |
||
276 | * |
||
277 | * @static |
||
278 | * @access public |
||
279 | * @since 3.0.0 |
||
280 | * @return bool |
||
281 | */ |
||
282 | public static function is_plugin() { |
||
289 | |||
290 | /** |
||
291 | * Alias for the get_variables static method in the Kirki_Util class. |
||
292 | * This is here for backwards-compatibility purposes. |
||
293 | * |
||
294 | * @static |
||
295 | * @access public |
||
296 | * @since 2.0.0 |
||
297 | * @return array Formatted as array( 'variable-name' => value ). |
||
298 | */ |
||
299 | public static function get_variables() { |
||
306 | |||
307 | } |
||
308 |