PluginProbe
QuadMenu – Mega Menu / 1.8.8
QuadMenu – Mega Menu v1.8.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 / lib / ReduxCore / inc / extensions / customizer / extension_customizer.php

extension_customizer.php in QuadMenu – Mega Menu 1.8.8, at lib/ReduxCore/inc/extensions/customizer/extension_customizer.php

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