Completed
Push — master ( 8d1412...e15369 )
by
unknown
49s
created
redux-core/framework.php 1 patch
Indentation   +850 added lines, -850 removed lines patch added patch discarded remove patch
@@ -39,854 +39,854 @@
 block discarded – undo
39 39
 // Don't duplicate me!
40 40
 if ( ! class_exists( 'ReduxFramework', false ) ) {
41 41
 
42
-	/**
43
-	 * Main ReduxFramework class
44
-	 *
45
-	 * @since       1.0.0
46
-	 */
47
-	class ReduxFramework {
48
-
49
-		/**
50
-		 * ReduxFramework instance storage.
51
-		 *
52
-		 * @var null|ReduxFramework
53
-		 * @access public
54
-		 */
55
-		public static ?ReduxFramework $instance;
56
-
57
-		/**
58
-		 * Redux current version.
59
-		 *
60
-		 * @var string
61
-		 * @access public
62
-		 *
63
-		 * @deprecated 4.0.0
64
-		 */
65
-		public static string $_version = ''; // phpcs:ignore PSR2.Classes.PropertyDeclaration
66
-
67
-		/**
68
-		 * Absolute directory of the Redux instance.
69
-		 *
70
-		 * @var string
71
-		 * @access public
72
-		 *
73
-		 * @deprecated 4.0.0
74
-		 */
75
-		public static string $_dir = ''; // phpcs:ignore PSR2.Classes.PropertyDeclaration
76
-
77
-		/**
78
-		 * Full URL of the Redux instance.
79
-		 *
80
-		 * @var string
81
-		 * @access public
82
-		 *
83
-		 * @deprecated 4.0.0
84
-		 */
85
-		public static string $_url = ''; // phpcs:ignore PSR2.Classes.PropertyDeclaration
86
-
87
-		/**
88
-		 * Current WordPress upload directory.
89
-		 *
90
-		 * @var string
91
-		 * @access public
92
-		 *
93
-		 * @deprecated 4.0.0
94
-		 */
95
-		public static string $_upload_dir = ''; // phpcs:ignore PSR2.Classes.PropertyDeclaration
96
-
97
-		/**
98
-		 * Current WordPress upload URL
99
-		 *
100
-		 * @var string
101
-		 * @access public
102
-		 *
103
-		 * @deprecated 4.0.0
104
-		 */
105
-		public static string $_upload_url; // phpcs:ignore PSR2.Classes.PropertyDeclaration
106
-
107
-		/**
108
-		 * Init
109
-		 *
110
-		 * Backward compatibility for previous versions of Redux.
111
-		 */
112
-		public static function init() {
113
-
114
-			// Backward compatibility for extensions.
115
-			self::$_version    = Redux_Core::$version;
116
-			self::$_dir        = Redux_Core::$dir;
117
-			self::$_url        = Redux_Core::$url;
118
-			self::$_upload_dir = Redux_Core::$upload_dir;
119
-			self::$_upload_url = Redux_Core::$upload_url;
120
-			self::$_as_plugin  = Redux_Core::$as_plugin;
121
-			self::$_is_plugin  = Redux_Core::$is_plugin;
122
-		}
123
-
124
-		/**
125
-		 * Array of field arrays.
126
-		 *
127
-		 * @var null|array
128
-		 */
129
-		public ?array $fields = array();
130
-
131
-		/**
132
-		 * Array of field sections.
133
-		 *
134
-		 * @var null|array
135
-		 */
136
-		public ?array $field_sections = array();
137
-
138
-		/**
139
-		 * Array of field types.
140
-		 *
141
-		 * @var null|array
142
-		 */
143
-		public ?array $field_types = array();
144
-
145
-		/**
146
-		 * Array of field heads.
147
-		 *
148
-		 * @var null|array
149
-		 */
150
-		public ?array $field_head = array();
151
-
152
-		/**
153
-		 * Array of extensions by type used in the panel.
154
-		 *
155
-		 * @var null|array
156
-		 */
157
-		public ?array $extensions = array();
158
-
159
-		/**
160
-		 * Array of sections and fields arrays.
161
-		 *
162
-		 * @var null|array
163
-		 */
164
-		public ?array $sections = array();
165
-
166
-		/**
167
-		 * Array of generated errors from the panel for localization.
168
-		 *
169
-		 * @var null|array
170
-		 */
171
-		public ?array $errors = array();
172
-
173
-		/**
174
-		 * Array of generated warnings from the panel for localization.
175
-		 *
176
-		 * @var null|array
177
-		 */
178
-		public ?array $warnings = array();
179
-
180
-		/**
181
-		 * Array of generated sanitize notices from the panel for localization.
182
-		 *
183
-		 * @var null|array
184
-		 */
185
-		public ?array $sanitize = array();
186
-
187
-		/**
188
-		 * Array of current option values.
189
-		 *
190
-		 * @var null|array
191
-		 */
192
-		public ?array $options = array();
193
-
194
-		/**
195
-		 * Array of option defaults.
196
-		 *
197
-		 * @var null|array
198
-		 */
199
-		public ?array $options_defaults = null;
200
-
201
-		/**
202
-		 * Array of fields set to trigger the compiler hook.
203
-		 *
204
-		 * @var null|array
205
-		 */
206
-		public ?array $compiler_fields = array();
207
-
208
-		/**
209
-		 * Array of fields with CSS output selectors.
210
-		 *
211
-		 * @var null|array
212
-		 */
213
-		public ?array $output = array();
214
-
215
-		/**
216
-		 * Autogenerated CSS appended to the header (snake case maintained for backward compatibility).
217
-		 *
218
-		 * @var null|string
219
-		 */
220
-		public ?string $outputCSS = ''; // phpcs:ignore WordPress.NamingConventions.ValidVariableName
221
-
222
-		/**
223
-		 * Autogenerated variables appended to dynamic output.
224
-		 *
225
-		 * @var null|array
226
-		 */
227
-		public ?array $output_variables = array();
228
-
229
-		/**
230
-		 * CSS sent to the compiler hook (snake case maintained for backward compatibility).
231
-		 *
232
-		 * @var null|string
233
-		 */
234
-		public ?string $compilerCSS = ''; // phpcs:ignore WordPress.NamingConventions.ValidVariableName
235
-
236
-		/**
237
-		 * Array of global arguments.
238
-		 *
239
-		 * @var array|null
240
-		 */
241
-		public ?array $args = array();
242
-
243
-		/**
244
-		 * Used in customizer hooks.
245
-		 *
246
-		 * @var null|string
247
-		 */
248
-		public ?string $old_opt_name = '';
249
-
250
-		/**
251
-		 * Pointer to the Redux_Options_Default class.
252
-		 *
253
-		 * @var null|Redux_Options_Defaults
254
-		 */
255
-		public ?Redux_Options_Defaults $options_defaults_class = null;
256
-
257
-		/**
258
-		 * Pointer to the Redux_Options class.
259
-		 *
260
-		 * @var null|Redux_Options_Constructor
261
-		 */
262
-		public ?Redux_Options_Constructor $options_class = null;
263
-
264
-		/**
265
-		 * Pointer to the Redux_Required class
266
-		 *
267
-		 * @var null|Redux_Required
268
-		 */
269
-		public ?Redux_Required $required_class = null;
270
-
271
-		/**
272
-		 * Pointer to the Redux_Output class.
273
-		 *
274
-		 * @var null|Redux_Output
275
-		 */
276
-		public ?Redux_Output $output_class = null;
277
-
278
-		/**
279
-		 * Pointer to the Redux_Page_Render class.
280
-		 *
281
-		 * @var null|Redux_Page_Render
282
-		 */
283
-		public ?Redux_Page_Render $render_class = null;
284
-
285
-		/**
286
-		 * Pointer to the Redux_Enqueue class.
287
-		 *
288
-		 * @var null|Redux_Enqueue
289
-		 */
290
-		public ?Redux_Enqueue $enqueue_class = null;
291
-
292
-		/**
293
-		 * Pointer to the Redux_Transients class.
294
-		 *
295
-		 * @var null|Redux_Transients
296
-		 */
297
-		public ?Redux_Transients $transient_class = null;
298
-
299
-		/**
300
-		 * Pointer to the Redux_wordPress_Data class.
301
-		 *
302
-		 * @var null|Redux_WordPress_Data
303
-		 */
304
-		public ?Redux_WordPress_Data $wordpress_data = null;
305
-
306
-		/**
307
-		 * Pointer to the Redux_Validation class.
308
-		 *
309
-		 * @var null|Redux_Validation
310
-		 */
311
-		public ?Redux_Validation $validate_class = null;
312
-
313
-		/**
314
-		 * Pointer to the Redux_Sanitize class.
315
-		 *
316
-		 * @var null|Redux_Sanitize
317
-		 */
318
-		public ?Redux_Sanitize $sanitize_class = null;
319
-
320
-		/**
321
-		 * Pointer to the Redux_Args class.
322
-		 *
323
-		 * @var null|Redux_Args
324
-		 */
325
-		public ?Redux_Args $args_class = null;
326
-
327
-		/**
328
-		 * Array of active transients used by Redux.
329
-		 *
330
-		 * @var null|mixed
331
-		 */
332
-		public $transients = array();
333
-
334
-		/**
335
-		 * Array of localized repeater data.
336
-		 *
337
-		 * @var null|array
338
-		 */
339
-		public ?array $repeater_data = array();
340
-
341
-		/**
342
-		 * Array of localized data.
343
-		 *
344
-		 * @var null|array
345
-		 */
346
-		public ?array $localize_data = array();
347
-
348
-		/**
349
-		 * Array of checked transients used by Redux.
350
-		 *
351
-		 * @var null|mixed
352
-		 */
353
-		public $transients_check = array();
354
-
355
-		/**
356
-		 * Never save to DB flag for metaboxes.
357
-		 *
358
-		 * @var bool
359
-		 */
360
-		public bool $never_save_to_db;
361
-
362
-		/**
363
-		 * File system object used for I/O file operations.  Done the WordPress way.
364
-		 *
365
-		 * @var null|object
366
-		 *
367
-		 * @deprecated 4.5.1
368
-		 */
369
-		public ?object $filesystem;
370
-
371
-		/**
372
-		 * Deprecated shim for v3 templates.
373
-		 *
374
-		 * @var null|array
375
-		 *
376
-		 * @deprecated 4.0.0
377
-		 */
378
-		public ?array $hidden_perm_sections = array();
379
-
380
-		/**
381
-		 * Deprecated shim for v3 as plugin check.
382
-		 *
383
-		 * @var bool
384
-		 *
385
-		 * @deprecated 4.0.0
386
-		 */
387
-		public static bool $_as_plugin = false;  // phpcs:ignore PSR2.Classes.PropertyDeclaration
388
-
389
-		/**
390
-		 * Deprecated shim for v3 as plugin check.
391
-		 *
392
-		 * @var bool
393
-		 *
394
-		 * @deprecated 4.0.0
395
-		 */
396
-		public static bool $_is_plugin = false;  // phpcs:ignore PSR2.Classes.PropertyDeclaration
397
-
398
-		/**
399
-		 * Cloning is forbidden.
400
-		 *
401
-		 * @since 4.0.0
402
-		 */
403
-		public function __clone() {
404
-			_doing_it_wrong( __FUNCTION__, esc_html__( 'Cheatin’ eh?', 'redux-framework' ), '4.0' );
405
-		}
406
-
407
-		/**
408
-		 * Un-serializing instances of this class are forbidden.
409
-		 *
410
-		 * @since 4.0.0
411
-		 */
412
-		public function __wakeup() {
413
-			_doing_it_wrong( __FUNCTION__, esc_html__( 'Cheatin’ eh?', 'redux-framework' ), '4.0' );
414
-		}
415
-
416
-		/**
417
-		 * Add a deprecating notice for all the old themes that still use this method..
418
-		 *
419
-		 * @param object $filesystem Filesystem object.
420
-		 *
421
-		 * @since 4.0.0
422
-		 */
423
-		private function deprecated_filesystem( $filesystem ) {
424
-			//_deprecated_function( esc_html__( 'The global variable "$filesystem" of the ReduxFramework object', 'redux-framework' ), '4.5.1', 'Redux_Core::$filesystem' );
425
-
426
-			return $filesystem;
427
-		}
428
-
429
-		/**
430
-		 * Class Constructor. Defines the args for the theme options class
431
-		 *
432
-		 * @param array $sections Panel sections.
433
-		 * @param array $args     Class constructor arguments.
434
-		 *
435
-		 * @throws ReflectionException Exception.
436
-		 * @since       1.0.0
437
-		 */
438
-		public function __construct( array $sections = array(), array $args = array() ) {
439
-			global $pagenow;
440
-
441
-			if ( Redux_Core::is_heartbeat() ) {
442
-				return;
443
-			}
444
-
445
-			$args['load_on_cron'] = $args['load_on_cron'] ?? false;
446
-
447
-			if ( false === $args['load_on_cron'] && 'wp-cron.php' === $pagenow ) {
448
-				return;
449
-			}
450
-
451
-			if ( empty( $args ) || ( empty( $args['opt_name'] ) ) ) {
452
-				return;
453
-			}
454
-
455
-			if ( ! isset( Redux::$init[ $args['opt_name'] ] ) ) {
456
-				// Let's go back to the Redux API instead of having it run directly.
457
-				Redux_Functions_Ex::record_caller( $args['opt_name'] );
458
-				Redux::set_args( $args['opt_name'], $args );
459
-				if ( ! empty( $sections ) ) {
460
-					Redux::set_sections( $args['opt_name'], $sections );
461
-				}
462
-				$sections = Redux::construct_sections( $args['opt_name'] );
463
-				$args     = Redux::construct_args( $args['opt_name'] );
464
-				Redux::set_defaults( $args['opt_name'] );
465
-				Redux::$init[ $args['opt_name'] ] = 1;
466
-			}
467
-
468
-			$args             = new Redux_Args( $this, $args );
469
-			$this->args_class = $args;
470
-			$this->args       = $args->get;
471
-
472
-			Redux_Core::core_construct( $this );
473
-
474
-			new Redux_Admin_Notices( $this );
475
-
476
-			if ( ! empty( $this->args['opt_name'] ) ) {
477
-				new Redux_Instances( $this );
478
-
479
-				Redux_Core::$filesystem = Redux_Filesystem::get_instance( $this );
480
-
481
-				$this->filesystem = $this->deprecated_filesystem( Redux_Core::$filesystem );
482
-
483
-				/**
484
-				 * Filter 'redux/options/{opt_name}/sections'
485
-				 *
486
-				 * @param  array $sections field option sections
487
-				 */
488
-
489
-				// phpcs:ignore WordPress.NamingConventions.ValidHookName
490
-				$this->sections = apply_filters( "redux/options/{$this->args['opt_name']}/sections", $sections );
491
-
492
-				/**
493
-				 * Construct hook
494
-				 * action 'redux/construct'
495
-				 *
496
-				 * @param object $this ReduxFramework
497
-				 */
498
-
499
-				// phpcs:ignore WordPress.NamingConventions.ValidHookName
500
-				do_action( 'redux/construct', $this );
501
-
502
-				// Internationalization.
503
-				new Redux_I18n( $this, __FILE__ );
504
-
505
-				$this->required_class  = new Redux_Required( $this );
506
-				$this->transient_class = new Redux_Transients( $this );
507
-				$this->wordpress_data  = new Redux_WordPress_Data( $this );
508
-				$this->validate_class  = new Redux_Validation( $this );
509
-				$this->sanitize_class  = new Redux_Sanitize( $this );
510
-
511
-				// Register extra extensions.
512
-				new Redux_Extensions( $this );
513
-
514
-				// Grab database values.
515
-				$this->options_defaults_class = new Redux_Options_Defaults();
516
-				$this->options_class          = new Redux_Options_Constructor( $this );
517
-				$this->options_class->get();
518
-
519
-				$this->output_class  = new Redux_Output( $this );
520
-				$this->render_class  = new Redux_Page_Render( $this );
521
-				$this->enqueue_class = new Redux_Enqueue( $this );
522
-
523
-				new Redux_AJAX_Save( $this );
524
-				new Redux_AJAX_Typography( $this );
525
-				new Redux_AJAX_Select2( $this );
526
-			}
527
-
528
-			/**
529
-			 * Loaded hook
530
-			 * action 'redux/loaded'
531
-			 *
532
-			 * @param  object $this ReduxFramework
533
-			 */
534
-
535
-			// phpcs:ignore WordPress.NamingConventions.ValidHookName
536
-			do_action( 'redux/loaded', $this );
537
-		}
538
-
539
-		/**
540
-		 * Begin backward compatibility shims for Redux v3 configs and extensions.
541
-		 */
542
-
543
-		/**
544
-		 * SHIM: _register_settings
545
-		 *
546
-		 * @deprecated 4.0.0
547
-		 */
548
-		public function _register_settings() { // phpcs:ignore PSR2.Methods.MethodDeclaration.Underscore
549
-			_deprecated_function( __FUNCTION__, '4.0.0', 'options_class->register()' );
550
-
551
-			$this->options_class->register();
552
-		}
553
-
554
-		/**
555
-		 * SHIM: _field_input
556
-		 *
557
-		 * @param array        $field Field array.
558
-		 * @param string|array $v     Field values.
559
-		 *
560
-		 * @deprecated 4.0.0
561
-		 */
562
-		public function _field_input( array $field, $v = null ) { // phpcs:ignore PSR2.Methods.MethodDeclaration.Underscore
563
-			_deprecated_function( __FUNCTION__, '4.0.0', 'render_class->field_input( $field, $value )' );
564
-
565
-			$this->render_class->field_input( $field, $v );
566
-		}
567
-
568
-		/**
569
-		 * SHIM: field_default_values
570
-		 *
571
-		 * @param array $field Field array.
572
-		 *
573
-		 * @deprecated 4.0.0
574
-		 */
575
-		public function field_default_values( array $field ) {
576
-			_deprecated_function( __FUNCTION__, '4.0.0', 'options_defaults_class->field_default_values( $opt_name, $field )' );
577
-
578
-			$this->options_defaults_class->field_default_values( '', $field );
579
-		}
580
-
581
-		/**
582
-		 * SHIM: set_options
583
-		 *
584
-		 * @param string|array $value Option values.
585
-		 *
586
-		 * @deprecated 4.0.0
587
-		 */
588
-		public function set_options( $value ) {
589
-			_deprecated_function( __FUNCTION__, '4.0.0', 'options_class->set( $value )' );
590
-
591
-			$this->options_class->set( $value );
592
-		}
593
-
594
-		/**
595
-		 * SHIM: get_options
596
-		 *
597
-		 * @deprecated 4.0.0
598
-		 */
599
-		public function get_options() {
600
-			_deprecated_function( __FUNCTION__, '4.0.0', 'options_class->get()' );
601
-
602
-			$this->options_class->get();
603
-		}
604
-
605
-		/**
606
-		 * SHIM: _default_values
607
-		 *
608
-		 * @return array
609
-		 *
610
-		 * @deprecated 4.0.0
611
-		 */
612
-		public function _default_values() { // phpcs:ignore PSR2.Methods.MethodDeclaration.Underscore
613
-			_deprecated_function( __FUNCTION__, '4.0.0', 'options_class->default_values()' );
614
-
615
-			return $this->default_values();
616
-		}
617
-
618
-		/**
619
-		 * Get default values.
620
-		 *
621
-		 * @return array
622
-		 */
623
-		public function default_values() {
624
-			if ( ! isset( $this->options_class ) ) {
625
-				$this->options_defaults_class = new Redux_Options_Defaults();
626
-				$this->options_class          = new Redux_Options_Constructor( $this );
627
-			}
628
-
629
-			return $this->options_class->default_values();
630
-		}
631
-
632
-		/**
633
-		 * SHIM: check_dependencies
634
-		 *
635
-		 * @param array $field Field array.
636
-		 *
637
-		 * @deprecated 4.0.0
638
-		 */
639
-		public function check_dependencies( array $field ) {
640
-			_deprecated_function( __FUNCTION__, '4.0.0', 'required_class->check_dependencies( $field )' );
641
-
642
-			$this->required_class->check_dependencies( $field );
643
-		}
644
-
645
-		/**
646
-		 * SHIM: _enqueue_output
647
-		 *
648
-		 * @throws ReflectionException Exception.
649
-		 *
650
-		 * @deprecated 4.0.0
651
-		 */
652
-		public function _enqueue_output() { // phpcs:ignore PSR2.Methods.MethodDeclaration.Underscore
653
-			_deprecated_function( __FUNCTION__, '4.0.0', 'output_class->enqueue()' );
654
-
655
-			if ( empty( $this->output_class ) ) {
656
-				$obj          = new ReduxFramework( $this->sections, $this->args );
657
-				$obj->options = $this->options;
658
-				$obj->output_class->enqueue();
659
-				$this->outputCSS = $obj->outputCSS; // phpcs:ignore WordPress.NamingConventions.ValidVariableName
660
-			} else {
661
-				$this->output_class->enqueue();
662
-			}
663
-		}
664
-
665
-		/**
666
-		 * SHIM: _enqueue
667
-		 *
668
-		 * @deprecated 4.0.0
669
-		 */
670
-		public function _enqueue() { // phpcs:ignore PSR2.Methods.MethodDeclaration.Underscore
671
-			_deprecated_function( __FUNCTION__, '4.0.0', 'enqueue_class->init()' );
672
-
673
-			$this->enqueue_class->init();
674
-		}
675
-
676
-		/**
677
-		 * _enqueue replacement.
678
-		 *
679
-		 * @return void
680
-		 */
681
-		public function init_enqueue() {
682
-			$this->enqueue_class->init();
683
-		}
684
-
685
-		/**
686
-		 * SHIM: generate_panel
687
-		 *
688
-		 * @since       1.0.0
689
-		 * @access      public
690
-		 * @return      void
691
-		 *
692
-		 * @deprecated 4.0.0
693
-		 */
694
-		public function generate_panel() {
695
-			_deprecated_function( __FUNCTION__, '4.0.0', 'render_class->generate_panel()' );
696
-
697
-			$this->render_class->generate_panel();
698
-		}
699
-
700
-		/**
701
-		 * SHIM: get_default_values
702
-		 *
703
-		 * @param string $key       Key value.
704
-		 * @param bool   $array_key Flag to determine array status.
705
-		 *
706
-		 * @return array
707
-		 *
708
-		 * @deprecated 4.0.0
709
-		 */
710
-		public function get_default_values( $key, $array_key = false ) {
711
-			_deprecated_function( __FUNCTION__, '4.0.0', 'options_class->get_default_value( $key, $array_key )' );
712
-
713
-			if ( ! isset( $this->options_class ) ) {
714
-				$this->options_defaults_class = new Redux_Options_Defaults();
715
-				$this->options_class          = new Redux_Options_Constructor( $this );
716
-			}
717
-
718
-			return $this->options_class->get_default_value( $key, $array_key );
719
-		}
720
-
721
-		/**
722
-		 * SHIM: get_default_value
723
-		 *
724
-		 * @param string $key       Key value.
725
-		 * @param bool   $array_key Flag to determine array status.
726
-		 *
727
-		 * @return array
728
-		 *
729
-		 * @deprecated 4.0.0
730
-		 */
731
-		public function get_default_value( $key, $array_key = false ) {
732
-			_deprecated_function( __FUNCTION__, '4.0.0', 'options_class->get_default_value( $key, $array_key )' );
733
-
734
-			if ( ! isset( $this->options_class ) ) {
735
-				$this->options_defaults_class = new Redux_Options_Defaults();
736
-				$this->options_class          = new Redux_Options_Constructor( $this );
737
-			}
738
-
739
-			return $this->options_class->get_default_value( $key, $array_key );
740
-		}
741
-
742
-		/**
743
-		 * SHIM: get_wordpress_data
744
-		 *
745
-		 * @param bool         $type data type.
746
-		 * @param array        $args args to pass to WordPress API.
747
-		 * @param string|array $current_value Current value.
748
-		 *
749
-		 * @return array|mixed|string|void
750
-		 *
751
-		 * @deprecated 4.0.0
752
-		 */
753
-		public function get_wordpress_data( $type = false, $args = array(), $current_value = null ) {
754
-			_deprecated_function( __FUNCTION__, '4.0.0', 'wordpress_data->get( $type, $args, $opt_name, $value )' );
755
-
756
-			return $this->wordpress_data->get( $type, $args, $this->args['opt_name'], $current_value );
757
-		}
758
-
759
-		/**
760
-		 * SHIM: _validate_values
761
-		 *
762
-		 * @param array $plugin_options Current panel options.
763
-		 * @param array $options        Options to validate.
764
-		 * @param array $sections       Sections array.
765
-		 *
766
-		 * @return array
767
-		 *
768
-		 * @deprecated 4.0.0
769
-		 */
770
-		public function _validate_values( $plugin_options, $options, $sections ) { // phpcs:ignore PSR2.Methods.MethodDeclaration.Underscore
771
-			_deprecated_function( __FUNCTION__, '4.0.0', 'validate_class->validate( $plugin_options, $options, $sections )' );
772
-
773
-			if ( ! isset( $this->validate_class ) ) {
774
-				$this->validate_class = new Redux_Validation( $this );
775
-			}
776
-
777
-			return $this->validate_class->validate( $plugin_options, $options, $sections );
778
-		}
779
-
780
-		/**
781
-		 * SHIM: set_transients
782
-		 *
783
-		 * @return void
784
-		 *
785
-		 * @deprecated 4.0.0
786
-		 */
787
-		public function set_transients() {
788
-			_deprecated_function( __FUNCTION__, '4.0.0', 'Please update the extension that uses this deprecated function.' );
789
-		}
790
-
791
-		/**
792
-		 * SHIM: section_menu
793
-		 *
794
-		 * @param int    $k        Array Key.
795
-		 * @param array  $section  Section array.
796
-		 * @param string $suffix   Unique string.
797
-		 * @param array  $sections Section array.
798
-		 *
799
-		 * @return string
800
-		 *
801
-		 * @deprecated 4.0.0
802
-		 */
803
-		public function section_menu( $k, $section, $suffix = '', $sections = array() ) {
804
-			_deprecated_function( __FUNCTION__, '4.0.0', 'render_class->section_menu( $index, $section, $suffix, $sections )' );
805
-
806
-			return $this->render_class->section_menu( $k, $section, $suffix, $sections );
807
-		}
808
-
809
-		/**
810
-		 * SHIM: get_header_html
811
-		 *
812
-		 * @param array $field Field array.
813
-		 *
814
-		 * @return string
815
-		 *
816
-		 * @deprecated 4.0.0
817
-		 */
818
-		public function get_header_html( $field ) {
819
-			_deprecated_function( __FUNCTION__, '4.0.0', 'render_class->get_header_html( $field )' );
820
-
821
-			return $this->render_class->get_header_html( $field );
822
-		}
823
-
824
-		/**
825
-		 * SHIM: current_user_can
826
-		 *
827
-		 * @param string $permission User permission.
828
-		 *
829
-		 * @return bool
830
-		 *
831
-		 * @deprecated 4.0.0
832
-		 */
833
-		public function current_user_can( $permission ) {
834
-			_deprecated_function( __FUNCTION__, '4.0.0', 'Redux_Helpers::current_user_can' );
835
-
836
-			return Redux_Helpers::current_user_can( $permission );
837
-		}
838
-
839
-		/**
840
-		 * End backward compatibility shims for Redux v3 configs and extensions.
841
-		 */
842
-
843
-		/**
844
-		 * Pointer to the ReduxFramework instance.
845
-		 *
846
-		 * @return ReduxFramework|null
847
-		 */
848
-		public function get_instance(): ?ReduxFramework {
849
-			return self::$instance;
850
-		}
851
-
852
-		/**
853
-		 * →get(); This is used to return and option value from the option array
854
-		 *
855
-		 * @since       1.0.0
856
-		 * @access      public
857
-		 *
858
-		 * @param       string $opt_name The option name to return.
859
-		 * @param       mixed  $defaults (null) The value to return if an option isn't set.
860
-		 *
861
-		 * @return      mixed
862
-		 */
863
-		public function get( string $opt_name, $defaults = null ) {
864
-			return ( ! empty( $this->options[ $opt_name ] ) ) ? $this->options[ $opt_name ] : $this->options_class->get_default( $opt_name, $defaults );
865
-		}
866
-
867
-		/**
868
-		 * →set(); This is used to set an arbitrary option in the option array
869
-		 *
870
-		 * @since       1.0.0
871
-		 * @access      public
872
-		 *
873
-		 * @param       string $opt_name The name of the option being added.
874
-		 * @param       mixed  $values   The value of the option being added.
875
-		 *
876
-		 * @return      void
877
-		 */
878
-		public function set( string $opt_name = '', $values = array() ) {
879
-			if ( ! empty( $opt_name ) && is_array( $values ) ) {
880
-				$this->options[ $opt_name ] = $values;
881
-				$this->options_class->set( $values );
882
-			}
883
-		}
884
-	}
885
-
886
-	ReduxFramework::init();
887
-
888
-	/**
889
-	 * Action 'redux/init'
890
-	 */
891
-	do_action( 'redux/init' ); // phpcs:ignore WordPress.NamingConventions.ValidHookName
42
+    /**
43
+     * Main ReduxFramework class
44
+     *
45
+     * @since       1.0.0
46
+     */
47
+    class ReduxFramework {
48
+
49
+        /**
50
+         * ReduxFramework instance storage.
51
+         *
52
+         * @var null|ReduxFramework
53
+         * @access public
54
+         */
55
+        public static ?ReduxFramework $instance;
56
+
57
+        /**
58
+         * Redux current version.
59
+         *
60
+         * @var string
61
+         * @access public
62
+         *
63
+         * @deprecated 4.0.0
64
+         */
65
+        public static string $_version = ''; // phpcs:ignore PSR2.Classes.PropertyDeclaration
66
+
67
+        /**
68
+         * Absolute directory of the Redux instance.
69
+         *
70
+         * @var string
71
+         * @access public
72
+         *
73
+         * @deprecated 4.0.0
74
+         */
75
+        public static string $_dir = ''; // phpcs:ignore PSR2.Classes.PropertyDeclaration
76
+
77
+        /**
78
+         * Full URL of the Redux instance.
79
+         *
80
+         * @var string
81
+         * @access public
82
+         *
83
+         * @deprecated 4.0.0
84
+         */
85
+        public static string $_url = ''; // phpcs:ignore PSR2.Classes.PropertyDeclaration
86
+
87
+        /**
88
+         * Current WordPress upload directory.
89
+         *
90
+         * @var string
91
+         * @access public
92
+         *
93
+         * @deprecated 4.0.0
94
+         */
95
+        public static string $_upload_dir = ''; // phpcs:ignore PSR2.Classes.PropertyDeclaration
96
+
97
+        /**
98
+         * Current WordPress upload URL
99
+         *
100
+         * @var string
101
+         * @access public
102
+         *
103
+         * @deprecated 4.0.0
104
+         */
105
+        public static string $_upload_url; // phpcs:ignore PSR2.Classes.PropertyDeclaration
106
+
107
+        /**
108
+         * Init
109
+         *
110
+         * Backward compatibility for previous versions of Redux.
111
+         */
112
+        public static function init() {
113
+
114
+            // Backward compatibility for extensions.
115
+            self::$_version    = Redux_Core::$version;
116
+            self::$_dir        = Redux_Core::$dir;
117
+            self::$_url        = Redux_Core::$url;
118
+            self::$_upload_dir = Redux_Core::$upload_dir;
119
+            self::$_upload_url = Redux_Core::$upload_url;
120
+            self::$_as_plugin  = Redux_Core::$as_plugin;
121
+            self::$_is_plugin  = Redux_Core::$is_plugin;
122
+        }
123
+
124
+        /**
125
+         * Array of field arrays.
126
+         *
127
+         * @var null|array
128
+         */
129
+        public ?array $fields = array();
130
+
131
+        /**
132
+         * Array of field sections.
133
+         *
134
+         * @var null|array
135
+         */
136
+        public ?array $field_sections = array();
137
+
138
+        /**
139
+         * Array of field types.
140
+         *
141
+         * @var null|array
142
+         */
143
+        public ?array $field_types = array();
144
+
145
+        /**
146
+         * Array of field heads.
147
+         *
148
+         * @var null|array
149
+         */
150
+        public ?array $field_head = array();
151
+
152
+        /**
153
+         * Array of extensions by type used in the panel.
154
+         *
155
+         * @var null|array
156
+         */
157
+        public ?array $extensions = array();
158
+
159
+        /**
160
+         * Array of sections and fields arrays.
161
+         *
162
+         * @var null|array
163
+         */
164
+        public ?array $sections = array();
165
+
166
+        /**
167
+         * Array of generated errors from the panel for localization.
168
+         *
169
+         * @var null|array
170
+         */
171
+        public ?array $errors = array();
172
+
173
+        /**
174
+         * Array of generated warnings from the panel for localization.
175
+         *
176
+         * @var null|array
177
+         */
178
+        public ?array $warnings = array();
179
+
180
+        /**
181
+         * Array of generated sanitize notices from the panel for localization.
182
+         *
183
+         * @var null|array
184
+         */
185
+        public ?array $sanitize = array();
186
+
187
+        /**
188
+         * Array of current option values.
189
+         *
190
+         * @var null|array
191
+         */
192
+        public ?array $options = array();
193
+
194
+        /**
195
+         * Array of option defaults.
196
+         *
197
+         * @var null|array
198
+         */
199
+        public ?array $options_defaults = null;
200
+
201
+        /**
202
+         * Array of fields set to trigger the compiler hook.
203
+         *
204
+         * @var null|array
205
+         */
206
+        public ?array $compiler_fields = array();
207
+
208
+        /**
209
+         * Array of fields with CSS output selectors.
210
+         *
211
+         * @var null|array
212
+         */
213
+        public ?array $output = array();
214
+
215
+        /**
216
+         * Autogenerated CSS appended to the header (snake case maintained for backward compatibility).
217
+         *
218
+         * @var null|string
219
+         */
220
+        public ?string $outputCSS = ''; // phpcs:ignore WordPress.NamingConventions.ValidVariableName
221
+
222
+        /**
223
+         * Autogenerated variables appended to dynamic output.
224
+         *
225
+         * @var null|array
226
+         */
227
+        public ?array $output_variables = array();
228
+
229
+        /**
230
+         * CSS sent to the compiler hook (snake case maintained for backward compatibility).
231
+         *
232
+         * @var null|string
233
+         */
234
+        public ?string $compilerCSS = ''; // phpcs:ignore WordPress.NamingConventions.ValidVariableName
235
+
236
+        /**
237
+         * Array of global arguments.
238
+         *
239
+         * @var array|null
240
+         */
241
+        public ?array $args = array();
242
+
243
+        /**
244
+         * Used in customizer hooks.
245
+         *
246
+         * @var null|string
247
+         */
248
+        public ?string $old_opt_name = '';
249
+
250
+        /**
251
+         * Pointer to the Redux_Options_Default class.
252
+         *
253
+         * @var null|Redux_Options_Defaults
254
+         */
255
+        public ?Redux_Options_Defaults $options_defaults_class = null;
256
+
257
+        /**
258
+         * Pointer to the Redux_Options class.
259
+         *
260
+         * @var null|Redux_Options_Constructor
261
+         */
262
+        public ?Redux_Options_Constructor $options_class = null;
263
+
264
+        /**
265
+         * Pointer to the Redux_Required class
266
+         *
267
+         * @var null|Redux_Required
268
+         */
269
+        public ?Redux_Required $required_class = null;
270
+
271
+        /**
272
+         * Pointer to the Redux_Output class.
273
+         *
274
+         * @var null|Redux_Output
275
+         */
276
+        public ?Redux_Output $output_class = null;
277
+
278
+        /**
279
+         * Pointer to the Redux_Page_Render class.
280
+         *
281
+         * @var null|Redux_Page_Render
282
+         */
283
+        public ?Redux_Page_Render $render_class = null;
284
+
285
+        /**
286
+         * Pointer to the Redux_Enqueue class.
287
+         *
288
+         * @var null|Redux_Enqueue
289
+         */
290
+        public ?Redux_Enqueue $enqueue_class = null;
291
+
292
+        /**
293
+         * Pointer to the Redux_Transients class.
294
+         *
295
+         * @var null|Redux_Transients
296
+         */
297
+        public ?Redux_Transients $transient_class = null;
298
+
299
+        /**
300
+         * Pointer to the Redux_wordPress_Data class.
301
+         *
302
+         * @var null|Redux_WordPress_Data
303
+         */
304
+        public ?Redux_WordPress_Data $wordpress_data = null;
305
+
306
+        /**
307
+         * Pointer to the Redux_Validation class.
308
+         *
309
+         * @var null|Redux_Validation
310
+         */
311
+        public ?Redux_Validation $validate_class = null;
312
+
313
+        /**
314
+         * Pointer to the Redux_Sanitize class.
315
+         *
316
+         * @var null|Redux_Sanitize
317
+         */
318
+        public ?Redux_Sanitize $sanitize_class = null;
319
+
320
+        /**
321
+         * Pointer to the Redux_Args class.
322
+         *
323
+         * @var null|Redux_Args
324
+         */
325
+        public ?Redux_Args $args_class = null;
326
+
327
+        /**
328
+         * Array of active transients used by Redux.
329
+         *
330
+         * @var null|mixed
331
+         */
332
+        public $transients = array();
333
+
334
+        /**
335
+         * Array of localized repeater data.
336
+         *
337
+         * @var null|array
338
+         */
339
+        public ?array $repeater_data = array();
340
+
341
+        /**
342
+         * Array of localized data.
343
+         *
344
+         * @var null|array
345
+         */
346
+        public ?array $localize_data = array();
347
+
348
+        /**
349
+         * Array of checked transients used by Redux.
350
+         *
351
+         * @var null|mixed
352
+         */
353
+        public $transients_check = array();
354
+
355
+        /**
356
+         * Never save to DB flag for metaboxes.
357
+         *
358
+         * @var bool
359
+         */
360
+        public bool $never_save_to_db;
361
+
362
+        /**
363
+         * File system object used for I/O file operations.  Done the WordPress way.
364
+         *
365
+         * @var null|object
366
+         *
367
+         * @deprecated 4.5.1
368
+         */
369
+        public ?object $filesystem;
370
+
371
+        /**
372
+         * Deprecated shim for v3 templates.
373
+         *
374
+         * @var null|array
375
+         *
376
+         * @deprecated 4.0.0
377
+         */
378
+        public ?array $hidden_perm_sections = array();
379
+
380
+        /**
381
+         * Deprecated shim for v3 as plugin check.
382
+         *
383
+         * @var bool
384
+         *
385
+         * @deprecated 4.0.0
386
+         */
387
+        public static bool $_as_plugin = false;  // phpcs:ignore PSR2.Classes.PropertyDeclaration
388
+
389
+        /**
390
+         * Deprecated shim for v3 as plugin check.
391
+         *
392
+         * @var bool
393
+         *
394
+         * @deprecated 4.0.0
395
+         */
396
+        public static bool $_is_plugin = false;  // phpcs:ignore PSR2.Classes.PropertyDeclaration
397
+
398
+        /**
399
+         * Cloning is forbidden.
400
+         *
401
+         * @since 4.0.0
402
+         */
403
+        public function __clone() {
404
+            _doing_it_wrong( __FUNCTION__, esc_html__( 'Cheatin’ eh?', 'redux-framework' ), '4.0' );
405
+        }
406
+
407
+        /**
408
+         * Un-serializing instances of this class are forbidden.
409
+         *
410
+         * @since 4.0.0
411
+         */
412
+        public function __wakeup() {
413
+            _doing_it_wrong( __FUNCTION__, esc_html__( 'Cheatin’ eh?', 'redux-framework' ), '4.0' );
414
+        }
415
+
416
+        /**
417
+         * Add a deprecating notice for all the old themes that still use this method..
418
+         *
419
+         * @param object $filesystem Filesystem object.
420
+         *
421
+         * @since 4.0.0
422
+         */
423
+        private function deprecated_filesystem( $filesystem ) {
424
+            //_deprecated_function( esc_html__( 'The global variable "$filesystem" of the ReduxFramework object', 'redux-framework' ), '4.5.1', 'Redux_Core::$filesystem' );
425
+
426
+            return $filesystem;
427
+        }
428
+
429
+        /**
430
+         * Class Constructor. Defines the args for the theme options class
431
+         *
432
+         * @param array $sections Panel sections.
433
+         * @param array $args     Class constructor arguments.
434
+         *
435
+         * @throws ReflectionException Exception.
436
+         * @since       1.0.0
437
+         */
438
+        public function __construct( array $sections = array(), array $args = array() ) {
439
+            global $pagenow;
440
+
441
+            if ( Redux_Core::is_heartbeat() ) {
442
+                return;
443
+            }
444
+
445
+            $args['load_on_cron'] = $args['load_on_cron'] ?? false;
446
+
447
+            if ( false === $args['load_on_cron'] && 'wp-cron.php' === $pagenow ) {
448
+                return;
449
+            }
450
+
451
+            if ( empty( $args ) || ( empty( $args['opt_name'] ) ) ) {
452
+                return;
453
+            }
454
+
455
+            if ( ! isset( Redux::$init[ $args['opt_name'] ] ) ) {
456
+                // Let's go back to the Redux API instead of having it run directly.
457
+                Redux_Functions_Ex::record_caller( $args['opt_name'] );
458
+                Redux::set_args( $args['opt_name'], $args );
459
+                if ( ! empty( $sections ) ) {
460
+                    Redux::set_sections( $args['opt_name'], $sections );
461
+                }
462
+                $sections = Redux::construct_sections( $args['opt_name'] );
463
+                $args     = Redux::construct_args( $args['opt_name'] );
464
+                Redux::set_defaults( $args['opt_name'] );
465
+                Redux::$init[ $args['opt_name'] ] = 1;
466
+            }
467
+
468
+            $args             = new Redux_Args( $this, $args );
469
+            $this->args_class = $args;
470
+            $this->args       = $args->get;
471
+
472
+            Redux_Core::core_construct( $this );
473
+
474
+            new Redux_Admin_Notices( $this );
475
+
476
+            if ( ! empty( $this->args['opt_name'] ) ) {
477
+                new Redux_Instances( $this );
478
+
479
+                Redux_Core::$filesystem = Redux_Filesystem::get_instance( $this );
480
+
481
+                $this->filesystem = $this->deprecated_filesystem( Redux_Core::$filesystem );
482
+
483
+                /**
484
+                 * Filter 'redux/options/{opt_name}/sections'
485
+                 *
486
+                 * @param  array $sections field option sections
487
+                 */
488
+
489
+                // phpcs:ignore WordPress.NamingConventions.ValidHookName
490
+                $this->sections = apply_filters( "redux/options/{$this->args['opt_name']}/sections", $sections );
491
+
492
+                /**
493
+                 * Construct hook
494
+                 * action 'redux/construct'
495
+                 *
496
+                 * @param object $this ReduxFramework
497
+                 */
498
+
499
+                // phpcs:ignore WordPress.NamingConventions.ValidHookName
500
+                do_action( 'redux/construct', $this );
501
+
502
+                // Internationalization.
503
+                new Redux_I18n( $this, __FILE__ );
504
+
505
+                $this->required_class  = new Redux_Required( $this );
506
+                $this->transient_class = new Redux_Transients( $this );
507
+                $this->wordpress_data  = new Redux_WordPress_Data( $this );
508
+                $this->validate_class  = new Redux_Validation( $this );
509
+                $this->sanitize_class  = new Redux_Sanitize( $this );
510
+
511
+                // Register extra extensions.
512
+                new Redux_Extensions( $this );
513
+
514
+                // Grab database values.
515
+                $this->options_defaults_class = new Redux_Options_Defaults();
516
+                $this->options_class          = new Redux_Options_Constructor( $this );
517
+                $this->options_class->get();
518
+
519
+                $this->output_class  = new Redux_Output( $this );
520
+                $this->render_class  = new Redux_Page_Render( $this );
521
+                $this->enqueue_class = new Redux_Enqueue( $this );
522
+
523
+                new Redux_AJAX_Save( $this );
524
+                new Redux_AJAX_Typography( $this );
525
+                new Redux_AJAX_Select2( $this );
526
+            }
527
+
528
+            /**
529
+             * Loaded hook
530
+             * action 'redux/loaded'
531
+             *
532
+             * @param  object $this ReduxFramework
533
+             */
534
+
535
+            // phpcs:ignore WordPress.NamingConventions.ValidHookName
536
+            do_action( 'redux/loaded', $this );
537
+        }
538
+
539
+        /**
540
+         * Begin backward compatibility shims for Redux v3 configs and extensions.
541
+         */
542
+
543
+        /**
544
+         * SHIM: _register_settings
545
+         *
546
+         * @deprecated 4.0.0
547
+         */
548
+        public function _register_settings() { // phpcs:ignore PSR2.Methods.MethodDeclaration.Underscore
549
+            _deprecated_function( __FUNCTION__, '4.0.0', 'options_class->register()' );
550
+
551
+            $this->options_class->register();
552
+        }
553
+
554
+        /**
555
+         * SHIM: _field_input
556
+         *
557
+         * @param array        $field Field array.
558
+         * @param string|array $v     Field values.
559
+         *
560
+         * @deprecated 4.0.0
561
+         */
562
+        public function _field_input( array $field, $v = null ) { // phpcs:ignore PSR2.Methods.MethodDeclaration.Underscore
563
+            _deprecated_function( __FUNCTION__, '4.0.0', 'render_class->field_input( $field, $value )' );
564
+
565
+            $this->render_class->field_input( $field, $v );
566
+        }
567
+
568
+        /**
569
+         * SHIM: field_default_values
570
+         *
571
+         * @param array $field Field array.
572
+         *
573
+         * @deprecated 4.0.0
574
+         */
575
+        public function field_default_values( array $field ) {
576
+            _deprecated_function( __FUNCTION__, '4.0.0', 'options_defaults_class->field_default_values( $opt_name, $field )' );
577
+
578
+            $this->options_defaults_class->field_default_values( '', $field );
579
+        }
580
+
581
+        /**
582
+         * SHIM: set_options
583
+         *
584
+         * @param string|array $value Option values.
585
+         *
586
+         * @deprecated 4.0.0
587
+         */
588
+        public function set_options( $value ) {
589
+            _deprecated_function( __FUNCTION__, '4.0.0', 'options_class->set( $value )' );
590
+
591
+            $this->options_class->set( $value );
592
+        }
593
+
594
+        /**
595
+         * SHIM: get_options
596
+         *
597
+         * @deprecated 4.0.0
598
+         */
599
+        public function get_options() {
600
+            _deprecated_function( __FUNCTION__, '4.0.0', 'options_class->get()' );
601
+
602
+            $this->options_class->get();
603
+        }
604
+
605
+        /**
606
+         * SHIM: _default_values
607
+         *
608
+         * @return array
609
+         *
610
+         * @deprecated 4.0.0
611
+         */
612
+        public function _default_values() { // phpcs:ignore PSR2.Methods.MethodDeclaration.Underscore
613
+            _deprecated_function( __FUNCTION__, '4.0.0', 'options_class->default_values()' );
614
+
615
+            return $this->default_values();
616
+        }
617
+
618
+        /**
619
+         * Get default values.
620
+         *
621
+         * @return array
622
+         */
623
+        public function default_values() {
624
+            if ( ! isset( $this->options_class ) ) {
625
+                $this->options_defaults_class = new Redux_Options_Defaults();
626
+                $this->options_class          = new Redux_Options_Constructor( $this );
627
+            }
628
+
629
+            return $this->options_class->default_values();
630
+        }
631
+
632
+        /**
633
+         * SHIM: check_dependencies
634
+         *
635
+         * @param array $field Field array.
636
+         *
637
+         * @deprecated 4.0.0
638
+         */
639
+        public function check_dependencies( array $field ) {
640
+            _deprecated_function( __FUNCTION__, '4.0.0', 'required_class->check_dependencies( $field )' );
641
+
642
+            $this->required_class->check_dependencies( $field );
643
+        }
644
+
645
+        /**
646
+         * SHIM: _enqueue_output
647
+         *
648
+         * @throws ReflectionException Exception.
649
+         *
650
+         * @deprecated 4.0.0
651
+         */
652
+        public function _enqueue_output() { // phpcs:ignore PSR2.Methods.MethodDeclaration.Underscore
653
+            _deprecated_function( __FUNCTION__, '4.0.0', 'output_class->enqueue()' );
654
+
655
+            if ( empty( $this->output_class ) ) {
656
+                $obj          = new ReduxFramework( $this->sections, $this->args );
657
+                $obj->options = $this->options;
658
+                $obj->output_class->enqueue();
659
+                $this->outputCSS = $obj->outputCSS; // phpcs:ignore WordPress.NamingConventions.ValidVariableName
660
+            } else {
661
+                $this->output_class->enqueue();
662
+            }
663
+        }
664
+
665
+        /**
666
+         * SHIM: _enqueue
667
+         *
668
+         * @deprecated 4.0.0
669
+         */
670
+        public function _enqueue() { // phpcs:ignore PSR2.Methods.MethodDeclaration.Underscore
671
+            _deprecated_function( __FUNCTION__, '4.0.0', 'enqueue_class->init()' );
672
+
673
+            $this->enqueue_class->init();
674
+        }
675
+
676
+        /**
677
+         * _enqueue replacement.
678
+         *
679
+         * @return void
680
+         */
681
+        public function init_enqueue() {
682
+            $this->enqueue_class->init();
683
+        }
684
+
685
+        /**
686
+         * SHIM: generate_panel
687
+         *
688
+         * @since       1.0.0
689
+         * @access      public
690
+         * @return      void
691
+         *
692
+         * @deprecated 4.0.0
693
+         */
694
+        public function generate_panel() {
695
+            _deprecated_function( __FUNCTION__, '4.0.0', 'render_class->generate_panel()' );
696
+
697
+            $this->render_class->generate_panel();
698
+        }
699
+
700
+        /**
701
+         * SHIM: get_default_values
702
+         *
703
+         * @param string $key       Key value.
704
+         * @param bool   $array_key Flag to determine array status.
705
+         *
706
+         * @return array
707
+         *
708
+         * @deprecated 4.0.0
709
+         */
710
+        public function get_default_values( $key, $array_key = false ) {
711
+            _deprecated_function( __FUNCTION__, '4.0.0', 'options_class->get_default_value( $key, $array_key )' );
712
+
713
+            if ( ! isset( $this->options_class ) ) {
714
+                $this->options_defaults_class = new Redux_Options_Defaults();
715
+                $this->options_class          = new Redux_Options_Constructor( $this );
716
+            }
717
+
718
+            return $this->options_class->get_default_value( $key, $array_key );
719
+        }
720
+
721
+        /**
722
+         * SHIM: get_default_value
723
+         *
724
+         * @param string $key       Key value.
725
+         * @param bool   $array_key Flag to determine array status.
726
+         *
727
+         * @return array
728
+         *
729
+         * @deprecated 4.0.0
730
+         */
731
+        public function get_default_value( $key, $array_key = false ) {
732
+            _deprecated_function( __FUNCTION__, '4.0.0', 'options_class->get_default_value( $key, $array_key )' );
733
+
734
+            if ( ! isset( $this->options_class ) ) {
735
+                $this->options_defaults_class = new Redux_Options_Defaults();
736
+                $this->options_class          = new Redux_Options_Constructor( $this );
737
+            }
738
+
739
+            return $this->options_class->get_default_value( $key, $array_key );
740
+        }
741
+
742
+        /**
743
+         * SHIM: get_wordpress_data
744
+         *
745
+         * @param bool         $type data type.
746
+         * @param array        $args args to pass to WordPress API.
747
+         * @param string|array $current_value Current value.
748
+         *
749
+         * @return array|mixed|string|void
750
+         *
751
+         * @deprecated 4.0.0
752
+         */
753
+        public function get_wordpress_data( $type = false, $args = array(), $current_value = null ) {
754
+            _deprecated_function( __FUNCTION__, '4.0.0', 'wordpress_data->get( $type, $args, $opt_name, $value )' );
755
+
756
+            return $this->wordpress_data->get( $type, $args, $this->args['opt_name'], $current_value );
757
+        }
758
+
759
+        /**
760
+         * SHIM: _validate_values
761
+         *
762
+         * @param array $plugin_options Current panel options.
763
+         * @param array $options        Options to validate.
764
+         * @param array $sections       Sections array.
765
+         *
766
+         * @return array
767
+         *
768
+         * @deprecated 4.0.0
769
+         */
770
+        public function _validate_values( $plugin_options, $options, $sections ) { // phpcs:ignore PSR2.Methods.MethodDeclaration.Underscore
771
+            _deprecated_function( __FUNCTION__, '4.0.0', 'validate_class->validate( $plugin_options, $options, $sections )' );
772
+
773
+            if ( ! isset( $this->validate_class ) ) {
774
+                $this->validate_class = new Redux_Validation( $this );
775
+            }
776
+
777
+            return $this->validate_class->validate( $plugin_options, $options, $sections );
778
+        }
779
+
780
+        /**
781
+         * SHIM: set_transients
782
+         *
783
+         * @return void
784
+         *
785
+         * @deprecated 4.0.0
786
+         */
787
+        public function set_transients() {
788
+            _deprecated_function( __FUNCTION__, '4.0.0', 'Please update the extension that uses this deprecated function.' );
789
+        }
790
+
791
+        /**
792
+         * SHIM: section_menu
793
+         *
794
+         * @param int    $k        Array Key.
795
+         * @param array  $section  Section array.
796
+         * @param string $suffix   Unique string.
797
+         * @param array  $sections Section array.
798
+         *
799
+         * @return string
800
+         *
801
+         * @deprecated 4.0.0
802
+         */
803
+        public function section_menu( $k, $section, $suffix = '', $sections = array() ) {
804
+            _deprecated_function( __FUNCTION__, '4.0.0', 'render_class->section_menu( $index, $section, $suffix, $sections )' );
805
+
806
+            return $this->render_class->section_menu( $k, $section, $suffix, $sections );
807
+        }
808
+
809
+        /**
810
+         * SHIM: get_header_html
811
+         *
812
+         * @param array $field Field array.
813
+         *
814
+         * @return string
815
+         *
816
+         * @deprecated 4.0.0
817
+         */
818
+        public function get_header_html( $field ) {
819
+            _deprecated_function( __FUNCTION__, '4.0.0', 'render_class->get_header_html( $field )' );
820
+
821
+            return $this->render_class->get_header_html( $field );
822
+        }
823
+
824
+        /**
825
+         * SHIM: current_user_can
826
+         *
827
+         * @param string $permission User permission.
828
+         *
829
+         * @return bool
830
+         *
831
+         * @deprecated 4.0.0
832
+         */
833
+        public function current_user_can( $permission ) {
834
+            _deprecated_function( __FUNCTION__, '4.0.0', 'Redux_Helpers::current_user_can' );
835
+
836
+            return Redux_Helpers::current_user_can( $permission );
837
+        }
838
+
839
+        /**
840
+         * End backward compatibility shims for Redux v3 configs and extensions.
841
+         */
842
+
843
+        /**
844
+         * Pointer to the ReduxFramework instance.
845
+         *
846
+         * @return ReduxFramework|null
847
+         */
848
+        public function get_instance(): ?ReduxFramework {
849
+            return self::$instance;
850
+        }
851
+
852
+        /**
853
+         * →get(); This is used to return and option value from the option array
854
+         *
855
+         * @since       1.0.0
856
+         * @access      public
857
+         *
858
+         * @param       string $opt_name The option name to return.
859
+         * @param       mixed  $defaults (null) The value to return if an option isn't set.
860
+         *
861
+         * @return      mixed
862
+         */
863
+        public function get( string $opt_name, $defaults = null ) {
864
+            return ( ! empty( $this->options[ $opt_name ] ) ) ? $this->options[ $opt_name ] : $this->options_class->get_default( $opt_name, $defaults );
865
+        }
866
+
867
+        /**
868
+         * →set(); This is used to set an arbitrary option in the option array
869
+         *
870
+         * @since       1.0.0
871
+         * @access      public
872
+         *
873
+         * @param       string $opt_name The name of the option being added.
874
+         * @param       mixed  $values   The value of the option being added.
875
+         *
876
+         * @return      void
877
+         */
878
+        public function set( string $opt_name = '', $values = array() ) {
879
+            if ( ! empty( $opt_name ) && is_array( $values ) ) {
880
+                $this->options[ $opt_name ] = $values;
881
+                $this->options_class->set( $values );
882
+            }
883
+        }
884
+    }
885
+
886
+    ReduxFramework::init();
887
+
888
+    /**
889
+     * Action 'redux/init'
890
+     */
891
+    do_action( 'redux/init' ); // phpcs:ignore WordPress.NamingConventions.ValidHookName
892 892
 }
Please login to merge, or discard this patch.
redux-core/inc/classes/class-redux-validation.php 2 patches
Indentation   +237 added lines, -237 removed lines patch added patch discarded remove patch
@@ -11,241 +11,241 @@
 block discarded – undo
11 11
 
12 12
 if ( ! class_exists( 'Redux_Validation', false ) ) {
13 13
 
14
-	/**
15
-	 * Class Redux_Validation
16
-	 */
17
-	class Redux_Validation extends Redux_Class {
18
-
19
-		/**
20
-		 * Validate values from options form (used in settings api validate function)
21
-		 * calls the custom validation class for the field so authors can override with custom classes
22
-		 *
23
-		 * @since       1.0.0
24
-		 * @access      public
25
-		 *
26
-		 * @param       array $plugin_options Plugin Options.
27
-		 * @param       array $options        Options.
28
-		 * @param       array $sections       Sections array.
29
-		 *
30
-		 * @return      array $plugin_options
31
-		 */
32
-		public function validate( array $plugin_options, array $options, array $sections ): array {
33
-			$core = $this->core();
34
-
35
-			if (null === $core) {
36
-				return $plugin_options;
37
-			}
38
-
39
-			foreach ( $sections as $k => $section ) {
40
-				if ( isset( $section['fields'] ) ) {
41
-					foreach ( $section['fields'] as $fkey => $field ) {
42
-						if ( is_array( $field ) ) {
43
-							$field['section_id'] = $k;
44
-						}
45
-
46
-						if ( isset( $field['type'] ) && ( 'checkbox' === $field['type'] || 'checkbox_hide_below' === $field['type'] || 'checkbox_hide_all' === $field['type'] ) ) {
47
-							if ( ! isset( $plugin_options[ $field['id'] ] ) ) {
48
-								$plugin_options[ $field['id'] ] = 0;
49
-							}
50
-						}
51
-
52
-						// Part of Dovy's serialize typography effort.  Preserved here in case it becomes a thing. - kp.
53
-						/**
54
-						 * If ( isset ( $field['type'] ) && $field['type'] == 'typography' ) {
55
-						 *      if ( ! is_array( $plugin_options[ $field['id'] ] ) && ! empty( $plugin_options[ $field['id'] ] ) ) {
56
-						 *          $plugin_options[ $field['id'] ] = json_decode( $plugin_options[ $field['id'] ], true );
57
-						 *      }
58
-						 * }
59
-						 */
60
-
61
-						if ( isset( $core->extensions[ $field['type'] ] ) && method_exists( $core->extensions[ $field['type'] ], '_validate_values' ) ) {
62
-							$plugin_options = $core->extensions[ $field['type'] ]->_validate_values( $plugin_options, $field, $sections );
63
-						}
64
-
65
-						// Make sure 'validate' field is set.
66
-						if ( isset( $field['validate'] ) ) {
67
-
68
-							// Can we make this an array of validations?
69
-							$val_arr = array();
70
-
71
-							if ( is_array( $field['validate'] ) ) {
72
-								$val_arr = $field['validate'];
73
-							} else {
74
-								$val_arr[] = $field['validate'];
75
-							}
76
-
77
-							foreach ( $val_arr as $idx => $val ) {
78
-								// shim for old *_not_empty validations.
79
-								if ( 'email_not_empty' === $val || 'numeric_not_empty' === $val ) {
80
-									$val = 'not_empty';
81
-								}
82
-
83
-								// Make sure 'validate field' is set to 'not_empty'.
84
-								$is_not_empty = false;
85
-
86
-								if ( 'not_empty' === $val ) {
87
-									// Set the flag.
88
-									$is_not_empty = true;
89
-								}
90
-
91
-								// Check for empty id value.
92
-								if ( ! isset( $field['id'] ) || ! isset( $plugin_options[ $field['id'] ] ) || ( '' === $plugin_options[ $field['id'] ] ) ) {
93
-
94
-									// If we are looking for an empty value, in the case of 'not_empty'
95
-									// then we need to keep processing.
96
-									if ( ! $is_not_empty ) {
97
-
98
-										// Empty id and not checking for 'not_empty'.  Bail out...
99
-										if ( ! isset( $field['validate_callback'] ) ) {
100
-											continue;
101
-										}
102
-									}
103
-								}
104
-
105
-								// Force validate of custom field types.
106
-								if ( isset( $field['type'] ) && ! isset( $val ) && ! isset( $field['validate_callback'] ) ) {
107
-									if ( 'color' === $field['type'] || 'color_gradient' === $field['type'] ) {
108
-										$val = 'color';
109
-									} elseif ( 'date' === $field['type'] ) {
110
-										$val = 'date';
111
-									}
112
-								}
113
-
114
-								// No need.  Spectrum self validates.
115
-								if ( 'color_rgba' === $field['type'] ) {
116
-									continue;
117
-								}
118
-
119
-								// Shim out old color rgba validators.
120
-								if ( 'color_rgba' === $val || 'colorrgba' === $val ) {
121
-									$val = 'color';
122
-								}
123
-
124
-								$validate = 'Redux_Validation_' . $val;
125
-
126
-								if ( ! class_exists( $validate ) ) {
127
-									$file = str_replace( '_', '-', $val );
128
-
129
-									/**
130
-									 * Filter 'redux/validate/{opt_name}/class/{field.validate}'
131
-									 *
132
-									 * @param string $validate   validation class file path
133
-									 */
134
-
135
-									// phpcs:ignore WordPress.NamingConventions.ValidHookName
136
-									$class_file = apply_filters( "redux/validate/{$core->args['opt_name']}/class/$val", Redux_Core::$dir . "inc/validation/$val/class-redux-validation-$file.php", $validate );
137
-
138
-									if ( $class_file ) {
139
-										if ( file_exists( $class_file ) ) {
140
-											require_once $class_file;
141
-										}
142
-									}
143
-								}
144
-
145
-								if ( class_exists( $validate ) ) {
146
-									if ( empty( $options[ $field['id'] ] ) ) {
147
-										$options[ $field['id'] ] = '';
148
-									}
149
-
150
-									if ( isset( $plugin_options[ $field['id'] ] ) && is_array( $plugin_options[ $field['id'] ] ) && ! empty( $plugin_options[ $field['id'] ] ) ) {
151
-										foreach ( $plugin_options[ $field['id'] ] as $key => $value ) {
152
-											$before = null;
153
-											$after  = null;
154
-
155
-											if ( isset( $plugin_options[ $field['id'] ][ $key ] ) && ( ! empty( $plugin_options[ $field['id'] ][ $key ] ) || '0' === $plugin_options[ $field['id'] ][ $key ] ) ) {
156
-												if ( is_array( $plugin_options[ $field['id'] ][ $key ] ) ) {
157
-													$before = $plugin_options[ $field['id'] ][ $key ];
158
-												} else {
159
-													$before = trim( $plugin_options[ $field['id'] ][ $key ] );
160
-												}
161
-											}
162
-
163
-											if ( isset( $options[ $field['id'] ][ $key ] ) && ( ! empty( $plugin_options[ $field['id'] ][ $key ] ) || '0' === $plugin_options[ $field['id'] ][ $key ] ) ) {
164
-												$after = $options[ $field['id'] ][ $key ];
165
-											}
166
-
167
-											$validation = new $validate( $core, $field, $before, $after );
168
-
169
-											if ( ! empty( $validation->value ) || '0' === $validation->value ) {
170
-												$plugin_options[ $field['id'] ][ $key ] = $validation->value;
171
-											} else {
172
-												unset( $plugin_options[ $field['id'] ][ $key ] );
173
-											}
174
-
175
-											if ( ! empty( $validation->error ) ) {
176
-												$core->errors[] = $validation->error;
177
-											}
178
-
179
-											if ( ! empty( $validation->warning ) ) {
180
-												$core->warnings[] = $validation->warning;
181
-											}
182
-
183
-											if ( ! empty( $validation->sanitize ) ) {
184
-												$core->sanitize[] = $validation->sanitize;
185
-											}
186
-										}
187
-									} else {
188
-										if ( isset( $plugin_options[ $field['id'] ] ) ) {
189
-											if ( is_array( $plugin_options[ $field['id'] ] ) ) {
190
-												$pofi = $plugin_options[ $field['id'] ];
191
-											} else {
192
-												$pofi = trim( $plugin_options[ $field['id'] ] );
193
-											}
194
-										} else {
195
-											$pofi = null;
196
-										}
197
-
198
-										$validation                     = new $validate( $core, $field, $pofi, $options[ $field['id'] ] );
199
-										$plugin_options[ $field['id'] ] = $validation->value;
200
-
201
-										if ( ! empty( $validation->error ) ) {
202
-											$core->errors[] = $validation->error;
203
-										}
204
-
205
-										if ( ! empty( $validation->warning ) ) {
206
-											$core->warnings[] = $validation->warning;
207
-										}
208
-
209
-										if ( ! empty( $validation->sanitize ) ) {
210
-											$core->sanitize[] = $validation->sanitize;
211
-										}
212
-									}
213
-
214
-									break;
215
-								}
216
-							}
217
-						}
218
-
219
-						if ( isset( $field['validate_callback'] ) && ( is_callable( $field['validate_callback'] ) || ( is_string( $field['validate_callback'] ) && function_exists( $field['validate_callback'] ) ) ) ) {
220
-							$callback = $field['validate_callback'];
221
-							unset( $field['validate_callback'] );
222
-
223
-							$plugin_option = $plugin_options[ $field['id'] ] ?? null;
224
-							$option        = $options[ $field['id'] ] ?? null;
225
-
226
-							if ( null !== $plugin_option ) {
227
-								$callbackvalues = call_user_func( $callback, $field, $plugin_option, $option );
228
-
229
-								$plugin_options[ $field['id'] ] = $callbackvalues['value'];
230
-
231
-								if ( isset( $callbackvalues['error'] ) ) {
232
-									$core->errors[] = $callbackvalues['error'];
233
-								}
234
-
235
-								if ( isset( $callbackvalues['warning'] ) ) {
236
-									$core->warnings[] = $callbackvalues['warning'];
237
-								}
238
-
239
-								if ( isset( $callbackvalues['sanitize'] ) ) {
240
-									$core->sanitize[] = $callbackvalues['sanitize'];
241
-								}
242
-							}
243
-						}
244
-					}
245
-				}
246
-			}
247
-
248
-			return $plugin_options;
249
-		}
250
-	}
14
+    /**
15
+     * Class Redux_Validation
16
+     */
17
+    class Redux_Validation extends Redux_Class {
18
+
19
+        /**
20
+         * Validate values from options form (used in settings api validate function)
21
+         * calls the custom validation class for the field so authors can override with custom classes
22
+         *
23
+         * @since       1.0.0
24
+         * @access      public
25
+         *
26
+         * @param       array $plugin_options Plugin Options.
27
+         * @param       array $options        Options.
28
+         * @param       array $sections       Sections array.
29
+         *
30
+         * @return      array $plugin_options
31
+         */
32
+        public function validate( array $plugin_options, array $options, array $sections ): array {
33
+            $core = $this->core();
34
+
35
+            if (null === $core) {
36
+                return $plugin_options;
37
+            }
38
+
39
+            foreach ( $sections as $k => $section ) {
40
+                if ( isset( $section['fields'] ) ) {
41
+                    foreach ( $section['fields'] as $fkey => $field ) {
42
+                        if ( is_array( $field ) ) {
43
+                            $field['section_id'] = $k;
44
+                        }
45
+
46
+                        if ( isset( $field['type'] ) && ( 'checkbox' === $field['type'] || 'checkbox_hide_below' === $field['type'] || 'checkbox_hide_all' === $field['type'] ) ) {
47
+                            if ( ! isset( $plugin_options[ $field['id'] ] ) ) {
48
+                                $plugin_options[ $field['id'] ] = 0;
49
+                            }
50
+                        }
51
+
52
+                        // Part of Dovy's serialize typography effort.  Preserved here in case it becomes a thing. - kp.
53
+                        /**
54
+                         * If ( isset ( $field['type'] ) && $field['type'] == 'typography' ) {
55
+                         *      if ( ! is_array( $plugin_options[ $field['id'] ] ) && ! empty( $plugin_options[ $field['id'] ] ) ) {
56
+                         *          $plugin_options[ $field['id'] ] = json_decode( $plugin_options[ $field['id'] ], true );
57
+                         *      }
58
+                         * }
59
+                         */
60
+
61
+                        if ( isset( $core->extensions[ $field['type'] ] ) && method_exists( $core->extensions[ $field['type'] ], '_validate_values' ) ) {
62
+                            $plugin_options = $core->extensions[ $field['type'] ]->_validate_values( $plugin_options, $field, $sections );
63
+                        }
64
+
65
+                        // Make sure 'validate' field is set.
66
+                        if ( isset( $field['validate'] ) ) {
67
+
68
+                            // Can we make this an array of validations?
69
+                            $val_arr = array();
70
+
71
+                            if ( is_array( $field['validate'] ) ) {
72
+                                $val_arr = $field['validate'];
73
+                            } else {
74
+                                $val_arr[] = $field['validate'];
75
+                            }
76
+
77
+                            foreach ( $val_arr as $idx => $val ) {
78
+                                // shim for old *_not_empty validations.
79
+                                if ( 'email_not_empty' === $val || 'numeric_not_empty' === $val ) {
80
+                                    $val = 'not_empty';
81
+                                }
82
+
83
+                                // Make sure 'validate field' is set to 'not_empty'.
84
+                                $is_not_empty = false;
85
+
86
+                                if ( 'not_empty' === $val ) {
87
+                                    // Set the flag.
88
+                                    $is_not_empty = true;
89
+                                }
90
+
91
+                                // Check for empty id value.
92
+                                if ( ! isset( $field['id'] ) || ! isset( $plugin_options[ $field['id'] ] ) || ( '' === $plugin_options[ $field['id'] ] ) ) {
93
+
94
+                                    // If we are looking for an empty value, in the case of 'not_empty'
95
+                                    // then we need to keep processing.
96
+                                    if ( ! $is_not_empty ) {
97
+
98
+                                        // Empty id and not checking for 'not_empty'.  Bail out...
99
+                                        if ( ! isset( $field['validate_callback'] ) ) {
100
+                                            continue;
101
+                                        }
102
+                                    }
103
+                                }
104
+
105
+                                // Force validate of custom field types.
106
+                                if ( isset( $field['type'] ) && ! isset( $val ) && ! isset( $field['validate_callback'] ) ) {
107
+                                    if ( 'color' === $field['type'] || 'color_gradient' === $field['type'] ) {
108
+                                        $val = 'color';
109
+                                    } elseif ( 'date' === $field['type'] ) {
110
+                                        $val = 'date';
111
+                                    }
112
+                                }
113
+
114
+                                // No need.  Spectrum self validates.
115
+                                if ( 'color_rgba' === $field['type'] ) {
116
+                                    continue;
117
+                                }
118
+
119
+                                // Shim out old color rgba validators.
120
+                                if ( 'color_rgba' === $val || 'colorrgba' === $val ) {
121
+                                    $val = 'color';
122
+                                }
123
+
124
+                                $validate = 'Redux_Validation_' . $val;
125
+
126
+                                if ( ! class_exists( $validate ) ) {
127
+                                    $file = str_replace( '_', '-', $val );
128
+
129
+                                    /**
130
+                                     * Filter 'redux/validate/{opt_name}/class/{field.validate}'
131
+                                     *
132
+                                     * @param string $validate   validation class file path
133
+                                     */
134
+
135
+                                    // phpcs:ignore WordPress.NamingConventions.ValidHookName
136
+                                    $class_file = apply_filters( "redux/validate/{$core->args['opt_name']}/class/$val", Redux_Core::$dir . "inc/validation/$val/class-redux-validation-$file.php", $validate );
137
+
138
+                                    if ( $class_file ) {
139
+                                        if ( file_exists( $class_file ) ) {
140
+                                            require_once $class_file;
141
+                                        }
142
+                                    }
143
+                                }
144
+
145
+                                if ( class_exists( $validate ) ) {
146
+                                    if ( empty( $options[ $field['id'] ] ) ) {
147
+                                        $options[ $field['id'] ] = '';
148
+                                    }
149
+
150
+                                    if ( isset( $plugin_options[ $field['id'] ] ) && is_array( $plugin_options[ $field['id'] ] ) && ! empty( $plugin_options[ $field['id'] ] ) ) {
151
+                                        foreach ( $plugin_options[ $field['id'] ] as $key => $value ) {
152
+                                            $before = null;
153
+                                            $after  = null;
154
+
155
+                                            if ( isset( $plugin_options[ $field['id'] ][ $key ] ) && ( ! empty( $plugin_options[ $field['id'] ][ $key ] ) || '0' === $plugin_options[ $field['id'] ][ $key ] ) ) {
156
+                                                if ( is_array( $plugin_options[ $field['id'] ][ $key ] ) ) {
157
+                                                    $before = $plugin_options[ $field['id'] ][ $key ];
158
+                                                } else {
159
+                                                    $before = trim( $plugin_options[ $field['id'] ][ $key ] );
160
+                                                }
161
+                                            }
162
+
163
+                                            if ( isset( $options[ $field['id'] ][ $key ] ) && ( ! empty( $plugin_options[ $field['id'] ][ $key ] ) || '0' === $plugin_options[ $field['id'] ][ $key ] ) ) {
164
+                                                $after = $options[ $field['id'] ][ $key ];
165
+                                            }
166
+
167
+                                            $validation = new $validate( $core, $field, $before, $after );
168
+
169
+                                            if ( ! empty( $validation->value ) || '0' === $validation->value ) {
170
+                                                $plugin_options[ $field['id'] ][ $key ] = $validation->value;
171
+                                            } else {
172
+                                                unset( $plugin_options[ $field['id'] ][ $key ] );
173
+                                            }
174
+
175
+                                            if ( ! empty( $validation->error ) ) {
176
+                                                $core->errors[] = $validation->error;
177
+                                            }
178
+
179
+                                            if ( ! empty( $validation->warning ) ) {
180
+                                                $core->warnings[] = $validation->warning;
181
+                                            }
182
+
183
+                                            if ( ! empty( $validation->sanitize ) ) {
184
+                                                $core->sanitize[] = $validation->sanitize;
185
+                                            }
186
+                                        }
187
+                                    } else {
188
+                                        if ( isset( $plugin_options[ $field['id'] ] ) ) {
189
+                                            if ( is_array( $plugin_options[ $field['id'] ] ) ) {
190
+                                                $pofi = $plugin_options[ $field['id'] ];
191
+                                            } else {
192
+                                                $pofi = trim( $plugin_options[ $field['id'] ] );
193
+                                            }
194
+                                        } else {
195
+                                            $pofi = null;
196
+                                        }
197
+
198
+                                        $validation                     = new $validate( $core, $field, $pofi, $options[ $field['id'] ] );
199
+                                        $plugin_options[ $field['id'] ] = $validation->value;
200
+
201
+                                        if ( ! empty( $validation->error ) ) {
202
+                                            $core->errors[] = $validation->error;
203
+                                        }
204
+
205
+                                        if ( ! empty( $validation->warning ) ) {
206
+                                            $core->warnings[] = $validation->warning;
207
+                                        }
208
+
209
+                                        if ( ! empty( $validation->sanitize ) ) {
210
+                                            $core->sanitize[] = $validation->sanitize;
211
+                                        }
212
+                                    }
213
+
214
+                                    break;
215
+                                }
216
+                            }
217
+                        }
218
+
219
+                        if ( isset( $field['validate_callback'] ) && ( is_callable( $field['validate_callback'] ) || ( is_string( $field['validate_callback'] ) && function_exists( $field['validate_callback'] ) ) ) ) {
220
+                            $callback = $field['validate_callback'];
221
+                            unset( $field['validate_callback'] );
222
+
223
+                            $plugin_option = $plugin_options[ $field['id'] ] ?? null;
224
+                            $option        = $options[ $field['id'] ] ?? null;
225
+
226
+                            if ( null !== $plugin_option ) {
227
+                                $callbackvalues = call_user_func( $callback, $field, $plugin_option, $option );
228
+
229
+                                $plugin_options[ $field['id'] ] = $callbackvalues['value'];
230
+
231
+                                if ( isset( $callbackvalues['error'] ) ) {
232
+                                    $core->errors[] = $callbackvalues['error'];
233
+                                }
234
+
235
+                                if ( isset( $callbackvalues['warning'] ) ) {
236
+                                    $core->warnings[] = $callbackvalues['warning'];
237
+                                }
238
+
239
+                                if ( isset( $callbackvalues['sanitize'] ) ) {
240
+                                    $core->sanitize[] = $callbackvalues['sanitize'];
241
+                                }
242
+                            }
243
+                        }
244
+                    }
245
+                }
246
+            }
247
+
248
+            return $plugin_options;
249
+        }
250
+    }
251 251
 }
Please login to merge, or discard this patch.
Spacing   +27 added lines, -27 removed lines patch added patch discarded remove patch
@@ -32,7 +32,7 @@  discard block
 block discarded – undo
32 32
 		public function validate( array $plugin_options, array $options, array $sections ): array {
33 33
 			$core = $this->core();
34 34
 
35
-			if (null === $core) {
35
+			if ( null === $core ) {
36 36
 				return $plugin_options;
37 37
 			}
38 38
 
@@ -44,8 +44,8 @@  discard block
 block discarded – undo
44 44
 						}
45 45
 
46 46
 						if ( isset( $field['type'] ) && ( 'checkbox' === $field['type'] || 'checkbox_hide_below' === $field['type'] || 'checkbox_hide_all' === $field['type'] ) ) {
47
-							if ( ! isset( $plugin_options[ $field['id'] ] ) ) {
48
-								$plugin_options[ $field['id'] ] = 0;
47
+							if ( ! isset( $plugin_options[$field['id']] ) ) {
48
+								$plugin_options[$field['id']] = 0;
49 49
 							}
50 50
 						}
51 51
 
@@ -58,8 +58,8 @@  discard block
 block discarded – undo
58 58
 						 * }
59 59
 						 */
60 60
 
61
-						if ( isset( $core->extensions[ $field['type'] ] ) && method_exists( $core->extensions[ $field['type'] ], '_validate_values' ) ) {
62
-							$plugin_options = $core->extensions[ $field['type'] ]->_validate_values( $plugin_options, $field, $sections );
61
+						if ( isset( $core->extensions[$field['type']] ) && method_exists( $core->extensions[$field['type']], '_validate_values' ) ) {
62
+							$plugin_options = $core->extensions[$field['type']]->_validate_values( $plugin_options, $field, $sections );
63 63
 						}
64 64
 
65 65
 						// Make sure 'validate' field is set.
@@ -89,7 +89,7 @@  discard block
 block discarded – undo
89 89
 								}
90 90
 
91 91
 								// Check for empty id value.
92
-								if ( ! isset( $field['id'] ) || ! isset( $plugin_options[ $field['id'] ] ) || ( '' === $plugin_options[ $field['id'] ] ) ) {
92
+								if ( ! isset( $field['id'] ) || ! isset( $plugin_options[$field['id']] ) || ( '' === $plugin_options[$field['id']] ) ) {
93 93
 
94 94
 									// If we are looking for an empty value, in the case of 'not_empty'
95 95
 									// then we need to keep processing.
@@ -143,33 +143,33 @@  discard block
 block discarded – undo
143 143
 								}
144 144
 
145 145
 								if ( class_exists( $validate ) ) {
146
-									if ( empty( $options[ $field['id'] ] ) ) {
147
-										$options[ $field['id'] ] = '';
146
+									if ( empty( $options[$field['id']] ) ) {
147
+										$options[$field['id']] = '';
148 148
 									}
149 149
 
150
-									if ( isset( $plugin_options[ $field['id'] ] ) && is_array( $plugin_options[ $field['id'] ] ) && ! empty( $plugin_options[ $field['id'] ] ) ) {
151
-										foreach ( $plugin_options[ $field['id'] ] as $key => $value ) {
150
+									if ( isset( $plugin_options[$field['id']] ) && is_array( $plugin_options[$field['id']] ) && ! empty( $plugin_options[$field['id']] ) ) {
151
+										foreach ( $plugin_options[$field['id']] as $key => $value ) {
152 152
 											$before = null;
153 153
 											$after  = null;
154 154
 
155
-											if ( isset( $plugin_options[ $field['id'] ][ $key ] ) && ( ! empty( $plugin_options[ $field['id'] ][ $key ] ) || '0' === $plugin_options[ $field['id'] ][ $key ] ) ) {
156
-												if ( is_array( $plugin_options[ $field['id'] ][ $key ] ) ) {
157
-													$before = $plugin_options[ $field['id'] ][ $key ];
155
+											if ( isset( $plugin_options[$field['id']][$key] ) && ( ! empty( $plugin_options[$field['id']][$key] ) || '0' === $plugin_options[$field['id']][$key] ) ) {
156
+												if ( is_array( $plugin_options[$field['id']][$key] ) ) {
157
+													$before = $plugin_options[$field['id']][$key];
158 158
 												} else {
159
-													$before = trim( $plugin_options[ $field['id'] ][ $key ] );
159
+													$before = trim( $plugin_options[$field['id']][$key] );
160 160
 												}
161 161
 											}
162 162
 
163
-											if ( isset( $options[ $field['id'] ][ $key ] ) && ( ! empty( $plugin_options[ $field['id'] ][ $key ] ) || '0' === $plugin_options[ $field['id'] ][ $key ] ) ) {
164
-												$after = $options[ $field['id'] ][ $key ];
163
+											if ( isset( $options[$field['id']][$key] ) && ( ! empty( $plugin_options[$field['id']][$key] ) || '0' === $plugin_options[$field['id']][$key] ) ) {
164
+												$after = $options[$field['id']][$key];
165 165
 											}
166 166
 
167 167
 											$validation = new $validate( $core, $field, $before, $after );
168 168
 
169 169
 											if ( ! empty( $validation->value ) || '0' === $validation->value ) {
170
-												$plugin_options[ $field['id'] ][ $key ] = $validation->value;
170
+												$plugin_options[$field['id']][$key] = $validation->value;
171 171
 											} else {
172
-												unset( $plugin_options[ $field['id'] ][ $key ] );
172
+												unset( $plugin_options[$field['id']][$key] );
173 173
 											}
174 174
 
175 175
 											if ( ! empty( $validation->error ) ) {
@@ -185,18 +185,18 @@  discard block
 block discarded – undo
185 185
 											}
186 186
 										}
187 187
 									} else {
188
-										if ( isset( $plugin_options[ $field['id'] ] ) ) {
189
-											if ( is_array( $plugin_options[ $field['id'] ] ) ) {
190
-												$pofi = $plugin_options[ $field['id'] ];
188
+										if ( isset( $plugin_options[$field['id']] ) ) {
189
+											if ( is_array( $plugin_options[$field['id']] ) ) {
190
+												$pofi = $plugin_options[$field['id']];
191 191
 											} else {
192
-												$pofi = trim( $plugin_options[ $field['id'] ] );
192
+												$pofi = trim( $plugin_options[$field['id']] );
193 193
 											}
194 194
 										} else {
195 195
 											$pofi = null;
196 196
 										}
197 197
 
198
-										$validation                     = new $validate( $core, $field, $pofi, $options[ $field['id'] ] );
199
-										$plugin_options[ $field['id'] ] = $validation->value;
198
+										$validation                     = new $validate( $core, $field, $pofi, $options[$field['id']] );
199
+										$plugin_options[$field['id']] = $validation->value;
200 200
 
201 201
 										if ( ! empty( $validation->error ) ) {
202 202
 											$core->errors[] = $validation->error;
@@ -220,13 +220,13 @@  discard block
 block discarded – undo
220 220
 							$callback = $field['validate_callback'];
221 221
 							unset( $field['validate_callback'] );
222 222
 
223
-							$plugin_option = $plugin_options[ $field['id'] ] ?? null;
224
-							$option        = $options[ $field['id'] ] ?? null;
223
+							$plugin_option = $plugin_options[$field['id']] ?? null;
224
+							$option        = $options[$field['id']] ?? null;
225 225
 
226 226
 							if ( null !== $plugin_option ) {
227 227
 								$callbackvalues = call_user_func( $callback, $field, $plugin_option, $option );
228 228
 
229
-								$plugin_options[ $field['id'] ] = $callbackvalues['value'];
229
+								$plugin_options[$field['id']] = $callbackvalues['value'];
230 230
 
231 231
 								if ( isset( $callbackvalues['error'] ) ) {
232 232
 									$core->errors[] = $callbackvalues['error'];
Please login to merge, or discard this patch.