PluginProbe
QuadMenu – Mega Menu / 3.3.8
QuadMenu – Mega Menu v3.3.8
3.3.8 3.3.7 3.3.6 trunk 1.8.4 1.8.5 1.8.7 1.8.8 1.8.9 1.9.0 1.9.2 1.9.3 1.9.4 1.9.5 1.9.6 1.9.7 1.9.8 1.9.9 2.0.0 2.0.1 2.0.2 2.0.3 2.0.4 2.0.5 2.0.6 All 88 releases
quadmenu / redux / ReduxCore / inc / extensions / customizer / extension_customizer.php

extension_customizer.php in QuadMenu – Mega Menu 3.3.8, at redux/ReduxCore/inc/extensions/customizer/extension_customizer.php

829 lines 27.8 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 // <input type="radio" value="1" name="_customize-radio-redux_demo[opt-radio]" data-customize-setting-link="redux_demo[opt-color-title]">
3 // return;
4 /**
5 * Redux Framework is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation, either version 2 of the License, or
8 * any later version.
9 * Redux Framework is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 * You should have received a copy of the GNU General Public License
14 * along with Redux Framework. If not, see <http://www.gnu.org/licenses/>.
15 *
16 * @package ReduxFrameworkLegacy
17 * @author Dovy Paukstys (dovy)
18 * @version 0.1.0
19 */
20
21 // Exit if accessed directly
22 if ( ! defined( 'ABSPATH' ) ) {
23 exit;
24 }
25
26 // Don't duplicate me!
27 if ( ! class_exists( 'ReduxFrameworkLegacy_extension_customizer' ) ) {
28
29 /**
30 * Main ReduxFrameworkLegacy customizer extension class
31 *
32 * @since 1.0.0
33 */
34 class ReduxFrameworkLegacy_extension_customizer {
35
36 // Protected vars
37 protected $redux;
38 private $_extension_url;
39 private $_extension_dir;
40 private $parent;
41 private $orig_options = array();
42 private static $post_values = array();
43 public static $version = '2.0.0';
44 private $options = array();
45
46 /**
47 * Class Constructor. Defines the args for the extions class
48 *
49 * @since 1.0.0
50 * @access public
51 *
52 * @param array $sections Panel sections.
53 * @param array $args Class constructor arguments.
54 * @param array $extra_tabs Extra panel tabs.
55 *
56 * @return void
57 */
58 public function __construct( $parent ) {
59
60 $this->parent = $parent;
61
62 $this->upload_dir = ReduxFrameworkLegacy::$_upload_dir . 'advanced-customizer/';
63
64 // add_action('wp_head', array( $this, '_enqueue_new' ));
65 if ( $parent->args['customizer'] == false ) {
66 return;
67 }
68
69 // Override the ReduxCore class
70 add_filter(
71 "redux/extension/{$this->parent->args['opt_name']}/customizer",
72 array(
73 $this,
74 'remove_core_customizer_class',
75 )
76 );
77
78 global $pagenow, $wp_customize;
79 if ( ! isset( $wp_customize ) && $pagenow !== 'customize.php' && $pagenow !== 'admin-ajax.php' ) {
80 return;
81 }
82 if ( ( $pagenow !== 'customize.php' && $pagenow !== 'admin-ajax.php' && ! isset( $GLOBALS['wp_customize'] ) ) ) {
83 // return;
84 }
85
86 if ( empty( $this->_extension_dir ) ) {
87 $this->_extension_dir = apply_filters( 'redux/extension/customizer/dir', trailingslashit( str_replace( '\\', '/', __DIR__ ) ) );
88 $this->_extension_url = apply_filters( 'redux/extension/customizer/url', plugin_dir_url( __FILE__ ) );
89 }
90
91 self::get_post_values();
92
93 // Create defaults array
94 $defaults = array();
95 /*
96 customize_controls_init
97 customize_controls_enqueue_scripts
98 customize_controls_print_styles
99 customize_controls_print_scripts
100 customize_controls_print_footer_scripts
101 */
102
103 // add_action('customize_save', );
104
105 if ( isset( $_POST['wp_customize'] ) && $_POST['wp_customize'] == 'on' ) {
106 $this->parent->args['customizer_only'] = true;
107 }
108
109 if ( isset( $_POST['wp_customize'] ) && $_POST['wp_customize'] == 'on' && isset( $_POST['customized'] ) && ! empty( $_POST['customized'] ) && ! isset( $_POST['action'] ) ) {
110 add_action(
111 "redux/options/{$this->parent->args['opt_name']}/options",
112 array(
113 $this,
114 '_override_values',
115 ),
116 100
117 );
118 }
119
120 add_action(
121 'customize_register',
122 array(
123 $this,
124 '_register_customizer_controls',
125 )
126 ); // Create controls
127
128 add_action( 'wp_head', array( $this, 'customize_preview_init' ) );
129
130 // add_action( 'customize_save', array( $this, 'customizer_save_before' ) ); // Before save
131 add_action( 'customize_save_after', array( &$this, 'customizer_save_after' ) ); // After save
132
133 // Add global controls CSS file
134 add_action( 'customize_controls_print_scripts', array( $this, 'enqueue_controls_css' ) );
135
136 add_action( 'customize_controls_init', array( $this, 'enqueue_panel_css' ) );
137
138 // add_action( 'wp_enqueue_scripts', array( &$this, '_enqueue_previewer_css' ) ); // Enqueue previewer css
139 // add_action( 'wp_enqueue_scripts', array( &$this, '_enqueue_previewer_js' ) ); // Enqueue previewer javascript
140 // add_action( "wp_footer", array( $this, '_enqueue_new' ), 100 );
141 // $this->_enqueue_new();
142 }
143
144 function enqueue_controls_css() {
145
146 require_once ReduxFrameworkLegacy::$_dir . 'core/enqueue.php';
147 $enqueue = new reduxLegacyCoreEnqueue( $this->parent );
148 $enqueue->get_warnings_and_errors_array();
149 $enqueue->init();
150 wp_enqueue_style( 'redux-extension-advanced-customizer', $this->_extension_url . 'extension_customizer.css', '', time() );
151
152 wp_enqueue_script(
153 'redux-extension-customizer',
154 $this->_extension_url . 'extension_customizer' . ReduxLegacy_Functions::isMin() . '.js',
155 array( 'jquery', 'redux-js' ),
156 self::$version,
157 true
158 );
159 wp_localize_script( 'redux-extension-customizer', 'redux_customizer', array( 'body_class' => sanitize_html_class( 'admin-color-' . get_user_option( 'admin_color' ), 'fresh' ) ) );
160 }
161
162 function enqueue_panel_css() {
163 }
164
165 function remove_core_customizer_class( $path ) {
166 return '';
167 }
168
169 function customize_preview_init() {
170 do_action( 'redux/customizer/live_preview' );
171 }
172
173 protected static function get_post_values() {
174 if ( empty( self::$post_values ) && isset( $_POST['customized'] ) && ! empty( $_POST['customized'] ) ) {
175 self::$post_values = json_decode( stripslashes_deep( $_POST['customized'] ), true );
176 }
177 }
178
179 public function _override_values( $data ) {
180
181 self::get_post_values();
182
183 if ( isset( $_POST['customized'] ) && ! empty( self::$post_values ) ) {
184
185 if ( is_array( self::$post_values ) ) {
186 foreach ( self::$post_values as $key => $value ) {
187 if ( strpos( $key, $this->parent->args['opt_name'] ) !== false ) {
188
189 // if (is_array($value)) {
190 // $value = @stripslashes( $value );
191 // if ( function_exists( 'get_magic_quotes_gpc' ) && get_magic_quotes_gpc() ) {
192 // $value = @array_map( 'stripslashes_deep', $value );
193 // $value = @array_map( 'urldecode', $value );
194 // }
195 // } else {
196 // $value = @urldecode($value);
197 // }
198 $key = str_replace( $this->parent->args['opt_name'] . '[', '', rtrim( $key, ']' ) );
199 $data[ $key ] = $value;
200 $GLOBALS[ $this->parent->args['global_variable'] ][ $key ] = $value;
201 $this->parent->options[ $key ] = $value;
202 }
203 }
204 }
205 }
206
207 return $data;
208 }
209
210 public function _enqueue_new() {
211 // echo "<script type='text/javascript' src='".$this->_extension_url . 'new/codemirror.min.js'."'></script>";
212 // echo "<script type='text/javascript' src='".$this->_extension_url . 'new/colors-control.js'."'></script>";
213 // echo "<script type='text/javascript' src='".$this->_extension_url . 'new/customizer-control.js'."'></script>";
214 // echo "<script type='text/javascript' src='".$this->_extension_url . 'new/fonts-customizer-admin.js'."'></script>";
215 // echo "<script type='text/javascript' src='".$this->_extension_url . 'new/header-control.js'."'></script>";
216 // echo "<script type='text/javascript' src='".$this->_extension_url . 'new/header-models.js'."'></script>";
217 // echo "<script type='text/javascript' src='".$this->_extension_url . 'new/jquery.slimscroll.js'."'></script>";
218 // echo "<script type='text/javascript' src='".$this->_extension_url . 'new/jquery.ui.droppable.min.js'."'></script>";
219 // echo "<script type='text/javascript' src='".$this->_extension_url . 'new/media-editor.min.js'."'></script>";
220 // echo "<script type='text/javascript' src='".$this->_extension_url . 'new/new-customizer.js'."'></script>";
221 // echo "<script type='text/javascript' src='".$this->_extension_url . 'new/previewing.js'."'></script>";
222 // echo "<script type='text/javascript' src='".$this->_extension_url . 'new/theme-customizer.js'."'></script>";
223
224 /*
225 wp_enqueue_script('redux-extension-customizer-codemirror-js', $this->_extension_url . 'new/codemirror.min.js');
226 wp_enqueue_script('redux-extension-customizer-color-js', $this->_extension_url . 'new/colors-control.js');
227 wp_enqueue_script('redux-extension-customizer-controls-js', $this->_extension_url . 'new/customizer-control.js');
228 wp_enqueue_script('redux-extension-customizer-fonts-js', $this->_extension_url . 'new/fonts-customizer-admin.js');
229 wp_enqueue_script('redux-extension-customizer-header-js', $this->_extension_url . 'new/header-control.js');
230 wp_enqueue_script('redux-extension-customizer-models-js', $this->_extension_url . 'new/header-models.js');
231 wp_enqueue_script('redux-extension-customizer-slimscroll-js', $this->_extension_url . 'new/jquery.slimscroll.js');
232 wp_enqueue_script('redux-extension-customizer-droppable-js', $this->_extension_url . 'new/jquery.ui.droppable.min.js');
233 wp_enqueue_script('redux-extension-customizer-editor-js', $this->_extension_url . 'new/media-editor.min.js');
234 wp_enqueue_script('redux-extension-customizer-new-js', $this->_extension_url . 'new/new-customizer.js');
235 wp_enqueue_script('redux-extension-customizer-previewing-js', $this->_extension_url . 'new/previewing.js');
236 wp_enqueue_script('redux-extension-customizer-theme-js', $this->_extension_url . 'new/theme-customizer.js');
237 */
238 }
239
240 public function render( $control ) {
241 $fieldID = str_replace( $this->parent->args['opt_name'] . '-', '', $control->redux_id );
242 $field = $this->options[ $fieldID ];
243
244 if ( isset( $field['compiler'] ) && ! empty( $field['compiler'] ) ) {
245 echo '<tr class="compiler">';
246 } else {
247 echo '<tr>';
248 }
249 echo '<th scope="row">' . $this->parent->field_head[ $field['id'] ] . '</th>';
250 echo '<td>';
251 // $field['data-customize-setting-link'] = array(
252 // 'name' => $field['name'],
253 // 'suffix' => isset($field['name_suffix']) ? $field['name_suffix'] : ''
254 // );
255 //
256 $field['name'] = $field['id'];
257 $this->parent->_field_input( $field );
258 echo '</td>';
259 echo '</tr>';
260 }
261
262 // All sections, settings, and controls will be added here
263 public function _register_customizer_controls( $wp_customize ) {
264
265 if ( ! class_exists( 'ReduxLegacy_Customizer_Section' ) ) {
266 require_once __DIR__ . '/inc/customizer_section.php';
267 if ( method_exists( $wp_customize, 'register_section_type' ) ) {
268 $wp_customize->register_section_type( 'ReduxLegacy_Customizer_Section' );
269 }
270 }
271 if ( ! class_exists( 'ReduxLegacy_Customizer_Panel' ) ) {
272 require_once __DIR__ . '/inc/customizer_panel.php';
273 if ( method_exists( $wp_customize, 'register_panel_type' ) ) {
274 $wp_customize->register_panel_type( 'ReduxLegacy_Customizer_Panel' );
275 }
276 }
277 if ( ! class_exists( 'ReduxLegacy_Customizer_Control' ) ) {
278 require_once __DIR__ . '/inc/customizer_control.php';
279 }
280
281 require_once __DIR__ . '/inc/customizer_fields.php';
282 require_once __DIR__ . '/inc/customizer_devs.php';
283
284 do_action( 'redux/extension/customizer/control/includes' );
285
286 // if ($this->parent->args['dev_mode']) {
287 // $section = new ReduxLegacy_Customizer_rAds( $wp_customize, 'redux_rAds', array(
288 // 'priority' => 0,
289 // ) );
290 // $wp_customize->add_section( $section, array(
291 // 'priority' => 0,
292 // ) );
293 //
294 // $wp_customize->add_control( new ReduxLegacy_Customizer_Control_rAds( $wp_customize, 'reduxAdsDisplay', array(
295 // 'section' => 'redux_rAds',
296 // 'settings' => 'redux_rAds_field',
297 // 'type' => 'redux-rAds',
298 // ) ) );
299 //
300 //
301 //
302 //
303 // }
304 if ( $this->parent->args['dev_mode'] ) {
305 // $args = array(
306 // 'priority' => 0,
307 // );
308 // $section = new ReduxLegacy_Customizer_Section( $wp_customize, 'redux_rAds', $args );
309 // $wp_customize->add_section( $section, $args );
310 // $this->add_section( 'redux_rAds', array(
311 // 'title' => '',
312 // 'priority' => 1,
313 // 'description' => '',
314 // 'capability' => 'edit_theme_options',
315 // ), $wp_customize );
316 //
317 // $wp_customize->add_control( new WP_Customize_Color_Control(
318 // $wp_customize,
319 // 'redux_rAds_display',
320 // array(
321 // 'section' => 'redux_rAds',
322 // 'settings' => 'redux_rAds_display',
323 // )
324 // ));
325 // $wp_customize->add_control( new ReduxLegacy_Customizer_Control_rAds( $wp_customize, 'reduxAdsDisplay', array(
326 // 'section' => 'redux_rAds',
327 // 'settings' => 'redux_rAds_field',
328 // 'type' => 'redux-rAds',
329 // ) ) );
330 // start copyright settings
331
332 // $section = new ReduxLegacy_Customizer_section_rAds( $wp_customize, 'redux_rAds', array(
333 // 'priority' => -999,
334 // ) );
335 // $wp_customize->add_section( $section, array(
336 // 'priority' => -999,
337 // ) );
338 // $wp_customize->add_setting(
339 // 'redux_rAds_empty'
340 // );
341 // $wp_customize->add_control(
342 // new ReduxLegacy_Customizer_Control_rAds(
343 // $wp_customize,
344 // 'redux_rAds_empty',
345 // array(
346 // 'section' => 'redux_rAds',
347 // 'settings' => 'redux_rAds_empty'
348 // )
349 // )
350 // );
351 }
352
353 $order = array(
354 'heading' => - 500,
355 'option' => - 500,
356 );
357 $defaults = array(
358 'default-color' => '',
359 'default-image' => '',
360 'wp-head-callback' => '',
361 'admin-head-callback' => '',
362 'admin-preview-callback' => '',
363 );
364 $panel = '';
365
366 $this->parent->args['options_api'] = false;
367 $this->parent->_register_settings();
368
369 foreach ( $this->parent->sections as $key => $section ) {
370
371 // Not a type that should go on the customizer
372 if ( isset( $section['type'] ) && ( $section['type'] == 'divide' ) ) {
373 continue;
374 }
375
376 if ( isset( $section['id'] ) && $section['id'] == 'import/export' ) {
377 continue;
378 }
379
380 // If section customizer is set to false
381 if ( isset( $section['customizer'] ) && $section['customizer'] === false ) {
382 continue;
383 }
384
385 $section['permissions'] = isset( $section['permissions'] ) ? $section['permissions'] : 'edit_theme_options';
386
387 // No errors please
388 if ( ! isset( $section['desc'] ) ) {
389 $section['desc'] = '';
390 }
391
392 // Fill the description if there is a subtitle
393 if ( empty( $section['desc'] ) && ! empty( $section['subtitle'] ) ) {
394 $section['desc'] = $section['subtitle'];
395 }
396
397 // Let's make a section ID from the title
398 if ( empty( $section['id'] ) ) {
399 $section['id'] = strtolower( str_replace( ' ', '', $section['title'] ) );
400 }
401
402 // No title is present, let's show what section is missing a title
403 if ( ! isset( $section['title'] ) ) {
404 $section['title'] = '';
405 }
406
407 // Let's set a default priority
408 if ( empty( $section['priority'] ) ) {
409 $section['priority'] = $order['heading'];
410 ++$order['heading'];
411 }
412
413 // print_r($section);
414 // print_r($this->parent->sections[$key+1]);
415 // echo $key;
416 // exit();
417
418 if ( method_exists( $wp_customize, 'add_panel' ) && ( ! isset( $section['subsection'] ) || ( isset( $section['subsection'] ) && $section['subsection'] != true ) ) && isset( $this->parent->sections[ ( $key + 1 ) ]['subsection'] ) && $this->parent->sections[ ( $key + 1 ) ]['subsection'] ) {
419
420 $this->add_panel(
421 $section['id'],
422 array(
423 'priority' => $section['priority'],
424 'capability' => $section['permissions'],
425 // 'theme_supports' => '',
426 'title' => $section['title'],
427 'section' => $section,
428 'opt_name' => $this->parent->args['opt_name'],
429 'description' => '',
430 ),
431 $wp_customize
432 );
433 $panel = $section['id'];
434
435 $this->add_section(
436 $section['id'],
437 array(
438 'title' => $section['title'],
439 'priority' => $section['priority'],
440 'description' => $section['desc'],
441 'section' => $section,
442 'opt_name' => $this->parent->args['opt_name'],
443 'capability' => $section['permissions'],
444 'panel' => $panel,
445 ),
446 $wp_customize
447 );
448
449 } else {
450 if ( ! isset( $section['subsection'] ) || ( isset( $section['subsection'] ) && $section['subsection'] != true ) ) {
451 $panel = '';
452 }
453 $this->add_section(
454 $section['id'],
455 array(
456 'title' => $section['title'],
457 'priority' => $section['priority'],
458 'description' => $section['desc'],
459 'opt_name' => $this->parent->args['opt_name'],
460 'section' => $section,
461 'capability' => $section['permissions'],
462 'panel' => $panel,
463 ),
464 $wp_customize
465 );
466 }
467
468 if ( ! isset( $section['fields'] ) || ( isset( $section['fields'] ) && empty( $section['fields'] ) ) ) {
469 continue;
470 }
471
472 foreach ( $section['fields'] as $skey => $option ) {
473
474 if ( isset( $option['customizer'] ) && $option['customizer'] === false ) {
475 continue;
476 }
477
478 if ( $this->parent->args['customizer'] === false && ( ! isset( $option['customizer'] ) || $option['customizer'] !== true ) ) {
479 continue;
480 }
481
482 $this->options[ $option['id'] ] = $option;
483 add_action(
484 'redux/advanced_customizer/control/render/' . $this->parent->args['opt_name'] . '-' . $option['id'],
485 array(
486 $this,
487 'render',
488 )
489 );
490
491 $option['permissions'] = isset( $option['permissions'] ) ? $option['permissions'] : 'edit_theme_options';
492
493 //
494 // if ( isset( $option['validate_callback'] ) && ! empty( $option['validate_callback'] ) ) {
495 // continue;
496 // }
497
498 // Change the item priority if not set
499 if ( $option['type'] != 'heading' && ! isset( $option['priority'] ) ) {
500 $option['priority'] = $order['option'];
501 ++$order['option'];
502 }
503
504 if ( ! empty( $this->options_defaults[ $option['id'] ] ) ) {
505 $option['default'] = $this->options_defaults['option']['id'];
506 }
507
508 // $option['id'] = $this->parent->args['opt_name'].'['.$option['id'].']';
509 // echo $option['id'];
510
511 if ( ! isset( $option['default'] ) ) {
512 $option['default'] = '';
513 }
514 if ( ! isset( $option['title'] ) ) {
515 $option['title'] = '';
516 }
517
518 $option['id'] = $this->parent->args['opt_name'] . '[' . $option['id'] . ']';
519
520 if ( $option['type'] != 'heading' && $option['type'] != 'import_export' && ! empty( $option['type'] ) ) {
521
522 $wp_customize->add_setting(
523 $option['id'],
524 array(
525 'default' => $option['default'],
526 // 'type' => 'option',
527 // 'capabilities' => $option['permissions'],
528 // 'capabilities' => 'edit_theme_options',
529 // 'capabilities' => $this->parent->args['page_permissions'],
530 'transport' => 'refresh',
531 'opt_name' => $this->parent->args['opt_name'],
532 // 'theme_supports' => '',
533 // 'sanitize_callback' => '__return_false',
534 'sanitize_callback' => array( $this, '_field_validation' ),
535 // 'sanitize_js_callback' =>array( &$parent, '_field_input' ),
536 )
537 );
538
539 }
540
541 if ( ! empty( $option['data'] ) && empty( $option['options'] ) ) {
542 if ( empty( $option['args'] ) ) {
543 $option['args'] = array();
544 }
545
546 if ( $option['data'] == 'elusive-icons' || $option['data'] == 'elusive-icon' || $option['data'] == 'elusive' ) {
547 $icons_file = ReduxFrameworkLegacy::$_dir . 'inc/fields/select/elusive-icons.php';
548 $icons_file = apply_filters( 'redux-font-icons-file', $icons_file );
549
550 if ( file_exists( $icons_file ) ) {
551 require_once $icons_file;
552 }
553 }
554 $option['options'] = $this->parent->get_wordpress_data( $option['data'], $option['args'] );
555 }
556
557 $class_name = 'ReduxLegacy_Customizer_Control_' . $option['type'];
558
559 do_action( 'redux/extension/customizer/control_init', $option );
560
561 if ( ! class_exists( $class_name ) ) {
562 continue;
563 }
564
565 $wp_customize->add_control(
566 new $class_name(
567 $wp_customize,
568 $option['id'],
569 array(
570 'label' => $option['title'],
571 'section' => $section['id'],
572 'settings' => $option['id'],
573 'type' => 'redux-' . $option['type'],
574 'field' => $option,
575 'ReduxFrameworkLegacy' => $this->parent,
576 'active_callback' => ( isset( $option['required'] ) && class_exists( 'ReduxLegacy_Customizer_Active_Callback' ) ) ? array(
577 'ReduxLegacy_Customizer_Active_Callback',
578 'evaluate',
579 ) : '__return_true',
580 'priority' => $option['priority'],
581 )
582 )
583 );
584
585 $section['fields'][ $skey ]['name'] = $option['id'];
586 if ( ! isset( $section['fields'][ $skey ]['class'] ) ) { // No errors please
587 $section['fields'][ $skey ]['class'] = '';
588 }
589
590 $this->controls[ $section['fields'][ $skey ]['id'] ] = $section['fields'][ $skey ];
591
592 add_action(
593 'redux/advanced_customizer/render/' . $option['id'],
594 array(
595 $this,
596 'field_render',
597 ),
598 $option['priority']
599 );
600
601 }
602 }
603 }
604
605 public function add_section( $id, $args = array(), $wp_customize ) {
606
607 if ( is_a( $id, 'WP_Customize_Section' ) ) {
608 $section = $id;
609 } else {
610
611 $section_class = apply_filters( 'redux/customizer/section/class_name', 'ReduxLegacy_Customizer_Section' );
612 $section = new $section_class( $wp_customize, $id, $args );
613 }
614
615 $wp_customize->add_section( $section, $args );
616 }
617
618 /**
619 * Add a customize panel.
620 *
621 * @since 4.0.0
622 * @access public
623 *
624 * @param WP_Customize_Panel|string $id Customize Panel object, or Panel ID.
625 * @param array $args Optional. Panel arguments. Default empty array.
626 */
627 public function add_panel( $id, $args = array(), $wp_customize ) {
628 if ( is_a( $id, 'WP_Customize_Panel' ) ) {
629 $panel = $id;
630 } else {
631 $panel_class = apply_filters( 'redux/customizer/panel/class_name', 'ReduxLegacy_Customizer_Panel' );
632 $panel = new $panel_class( $wp_customize, $id, $args );
633 }
634
635 $wp_customize->add_panel( $panel, $args );
636 }
637
638 public function field_render( $option ) {
639 echo '1';
640 preg_match_all( '/\[([^\]]*)\]/', $option->id, $matches );
641 $id = $matches[1][0];
642 echo $option->link();
643 // $link = $option->link();
644 // echo $link;
645
646 $this->parent->_field_input( $this->controls[ $id ] );
647 echo '2';
648 }
649
650 public function customizer_save_before( $plugin_options ) {
651 $this->before_save = $this->parent->options;
652 // $parent->_field_input( $plugin_options );
653 }
654
655 public function customizer_save_after( $wp_customize ) {
656
657 if ( empty( $this->parent->options ) ) {
658 $this->parent->get_options();
659 }
660 if ( empty( $this->orig_options ) && ! empty( $this->parent->options ) ) {
661 $this->orig_options = $this->parent->options;
662 }
663
664 $options = json_decode( stripslashes_deep( $_POST['customized'] ), true );
665 $compiler = false;
666 $changed = false;
667
668 foreach ( $options as $key => $value ) {
669 if ( strpos( $key, $this->parent->args['opt_name'] ) !== false ) {
670 $key = str_replace( $this->parent->args['opt_name'] . '[', '', rtrim( $key, ']' ) );
671
672 if ( ! isset( $this->orig_options[ $key ] ) || $this->orig_options[ $key ] != $value || ( isset( $this->orig_options[ $key ] ) && ! empty( $this->orig_options[ $key ] ) && empty( $value ) ) ) {
673 $this->parent->options[ $key ] = $value;
674 $changed = true;
675 if ( isset( $this->parent->compiler_fields[ $key ] ) ) {
676 $compiler = true;
677 }
678 }
679 }
680 }
681
682 if ( $changed ) {
683 $this->parent->set_options( $this->parent->options );
684 if ( $compiler ) {
685 // Have to set this to stop the output of the CSS and typography stuff.
686 $this->parent->no_output = true;
687 $this->parent->_enqueue_output();
688 do_action( "redux/options/{$this->parent->args['opt_name']}/compiler", $this->parent->options, $this->parent->compilerCSS );
689 do_action( "redux/options/{$this->args['opt_name']}/compiler/advanced", $this->parent );
690 }
691 }
692 }
693
694 /**
695 * Enqueue CSS/JS for preview pane
696 *
697 * @since 1.0.0
698 * @access public
699 * @global $wp_styles
700 * @return void
701 */
702 public function _enqueue_previewer() {
703 wp_enqueue_script(
704 'redux-extension-previewer-js',
705 $this->_extension_url . 'assets/js/preview.js'
706 );
707
708 $localize = array(
709 'save_pending' => __( 'You have changes that are not saved. Would you like to save them now?', 'redux-framework' ),
710 'reset_confirm' => __( 'Are you sure? Resetting will lose all custom values.', 'redux-framework' ),
711 'preset_confirm' => __( 'Your current options will be replaced with the values of this preset. Would you like to proceed?', 'redux-framework' ),
712 'opt_name' => $this->args['opt_name'],
713 // 'folds' => $this->folds,
714 'options' => $this->parent->options,
715 'defaults' => $this->parent->options_defaults,
716 );
717
718 wp_localize_script(
719 'redux-extension-previewer-js',
720 'reduxPost',
721 $localize
722 );
723 }
724
725 /**
726 * Enqueue CSS/JS for the customizer controls
727 *
728 * @since 1.0.0
729 * @access public
730 * @global $wp_styles
731 * @return void
732 */
733 public function _enqueue() {
734 global $wp_styles;
735
736 // wp_enqueue_style( 'wp-pointer' );
737 // wp_enqueue_script( 'wp-pointer' );
738 // Remove when code is in place!
739 // wp_enqueue_script('redux-extension-customizer-js', $this->_extension_url . 'assets/js/customizer.js');
740 // Get styles
741 // wp_enqueue_style('redux-extension-customizer-css', $this->_extension_url . 'assets/css/customizer.css');
742
743 $localize = array(
744 'save_pending' => __( 'You have changes that are not saved. Would you like to save them now?', 'redux-framework' ),
745 'reset_confirm' => __( 'Are you sure? Resetting will lose all custom values.', 'redux-framework' ),
746 'preset_confirm' => __( 'Your current options will be replaced with the values of this preset. Would you like to proceed?', 'redux-framework' ),
747 'opt_name' => $this->args['opt_name'],
748 // 'folds' => $this->folds,
749 'field' => $this->parent->options,
750 'defaults' => $this->parent->options_defaults,
751 );
752
753 // Values used by the javascript
754 wp_localize_script(
755 'redux-js',
756 'redux_opts',
757 $localize
758 );
759
760 do_action( 'redux-enqueue-' . $this->args['opt_name'] );
761
762 foreach ( $this->sections as $section ) {
763 if ( isset( $section['fields'] ) ) {
764 foreach ( $section['fields'] as $field ) {
765 if ( isset( $field['type'] ) ) {
766 $field_class = 'ReduxFrameworkLegacy_' . $field['type'];
767
768 if ( ! class_exists( $field_class ) ) {
769 $class_file = apply_filters( 'redux-typeclass-load', $this->path . 'inc/fields/' . $field['type'] . '/field_' . $field['type'] . '.php', $field_class );
770 if ( $class_file ) {
771 /** @noinspection PhpIncludeInspection */
772 require_once $class_file;
773 }
774 }
775
776 if ( class_exists( $field_class ) && method_exists( $field_class, 'enqueue' ) ) {
777 $enqueue = new $field_class( '', '', $this );
778 $enqueue->enqueue();
779 }
780 }
781 }
782 }
783 }
784 }
785
786 /**
787 * Register Option for use
788 *
789 * @since 1.0.0
790 * @access public
791 * @return void
792 */
793 public function _register_setting() {
794 }
795
796 /**
797 * Validate the options before insertion
798 *
799 * @since 3.0.0
800 * @access public
801 *
802 * @param array $plugin_options The options array
803 *
804 * @return
805 */
806 public function _field_validation( $value ) {
807 // print_r( $value );
808 // print_r( $_POST );
809
810 return $value;
811
812 // return $this->parent->_validate_options( $plugin_options );
813 }
814
815 /**
816 * HTML OUTPUT.
817 *
818 * @since 1.0.0
819 * @access public
820 * @return void
821 */
822 public function _customizer_html_output() {
823 }
824 } // class
825 function redux_customizer_custom_validation( $field ) {
826 return $field;
827 }
828 } // if
829