Completed
Push — master ( e2a4d2...ed335c )
by
unknown
55s
created
redux-core/inc/extensions/metaboxes/class-redux-extension-metaboxes.php 2 patches
Indentation   +1469 added lines, -1469 removed lines patch added patch discarded remove patch
@@ -14,1188 +14,1188 @@  discard block
 block discarded – undo
14 14
 // Don't duplicate me!
15 15
 if ( ! class_exists( 'Redux_Extension_Metaboxes', false ) ) {
16 16
 
17
-	/**
18
-	 * Main Redux_Extension_Metaboxes class
19
-	 *
20
-	 * @since       1.0.0
21
-	 */
22
-	class Redux_Extension_Metaboxes extends Redux_Extension_Abstract {
23
-
24
-		/**
25
-		 * Extension version.
26
-		 *
27
-		 * @var string
28
-		 */
29
-		public static $version = '4.2.0';
30
-
31
-		/**
32
-		 * Extension friendly name.
33
-		 *
34
-		 * @var string
35
-		 */
36
-		public string $extension_name = 'Metaboxes';
37
-
38
-		/**
39
-		 * Boxes array.
40
-		 *
41
-		 * @var array|null
42
-		 */
43
-		public ?array $boxes = array();
44
-
45
-		/**
46
-		 * Post types array.
47
-		 *
48
-		 * @var array|null
49
-		 */
50
-		public ?array $post_types = array();
51
-
52
-		/**
53
-		 * Post type.
54
-		 *
55
-		 * @var string|null
56
-		 */
57
-		public ?string $post_type;
58
-
59
-		/**
60
-		 * Sections array.
61
-		 *
62
-		 * @var array|null
63
-		 */
64
-		public ?array $orig_args;
65
-
66
-		/**
67
-		 * Sections array.
68
-		 *
69
-		 * @var array|null
70
-		 */
71
-		public ?array $sections = array();
72
-
73
-		/**
74
-		 * CSS output array.
75
-		 *
76
-		 * @var array|null
77
-		 */
78
-		public ?array $output = array();
79
-
80
-		/**
81
-		 * Options array.
82
-		 *
83
-		 * @var array
84
-		 */
85
-		public array $options = array();
86
-
87
-		/**
88
-		 * Parent options array.
89
-		 *
90
-		 * @var array
91
-		 */
92
-		public array $parent_options = array();
93
-
94
-		/**
95
-		 * Parent defaults array.
96
-		 *
97
-		 * @var array
98
-		 */
99
-		public array $parent_defaults = array();
100
-
101
-		/**
102
-		 * Post type fields array.
103
-		 *
104
-		 * @var array
105
-		 */
106
-		public array $post_type_fields = array();
107
-
108
-		/**
109
-		 * Options defaults array.
110
-		 *
111
-		 * @var array
112
-		 */
113
-		public array $options_defaults = array();
114
-
115
-		/**
116
-		 * Replace array.
117
-		 *
118
-		 * @var array
119
-		 */
120
-		public array $to_replace = array();
121
-
122
-		/**
123
-		 * Meta data array.
124
-		 *
125
-		 * @var array
126
-		 */
127
-		public array $meta = array();
128
-
129
-		/**
130
-		 * Post ID.
131
-		 *
132
-		 * @var null|int
133
-		 */
134
-		public ?int $post_id = 0;
135
-
136
-		/**
137
-		 * Base URI.
138
-		 *
139
-		 * @var string|null
140
-		 */
141
-		public ?string $base_url;
142
-
143
-		/**
144
-		 * WP_Links array.
145
-		 *
146
-		 * @var array
147
-		 */
148
-		public array $wp_links = array();
149
-
150
-		/**
151
-		 * Notices.
152
-		 *
153
-		 * @var array
154
-		 */
155
-		private array $notices = array();
156
-
157
-		/**
158
-		 * ReduxFramework_extension_metaboxes constructor.
159
-		 *
160
-		 * @param object $redux ReduxFramework object.
161
-		 */
162
-		public function __construct( $redux ) {
163
-			global $pagenow;
164
-
165
-			parent::__construct( $redux, __FILE__ );
166
-
167
-			$this->parent->extensions['metaboxes'] = $this;
168
-
169
-			$this->extension_dir = trailingslashit( str_replace( '\\', '/', __DIR__ ) );
170
-			$this->extension_url = site_url( str_replace( trailingslashit( str_replace( '\\', '/', ABSPATH ) ), '', $this->extension_dir ) );
171
-
172
-			// Only run metaboxes on the pages/posts, not the front-end.
173
-			// The DOING_AJAX check allows for redux_post_meta to work inside
174
-			// AJAX calls. - kp.
175
-			if ( 'post-new.php' !== $pagenow && 'post.php' !== $pagenow ) {
176
-				if ( is_admin() ) {
177
-					if ( defined( 'DOING_AJAX' ) && ! DOING_AJAX ) {
178
-						return;
179
-					}
180
-
181
-					return;
182
-				}
183
-			}
184
-
185
-			if ( 'wp-cron.php' === $pagenow || 'wp-comments-post.php' === $pagenow ) {
186
-				return;
187
-			}
188
-
189
-			// Must not update the DB when just updating metaboxes. Sheesh.
190
-			if ( is_admin() && ( 'post-new.php' === $pagenow || 'post.php' === $pagenow ) ) {
191
-				$this->parent->never_save_to_db = true;
192
-			}
193
-
194
-			include_once Redux_Core::$dir . 'inc/extensions/metaboxes/redux-metaboxes-helpers.php';
195
-
196
-			// phpcs:ignore Generic.Strings.UnnecessaryStringConcat
197
-			add_action( 'add_' . 'meta_' . 'boxes', array( $this, 'add' ) );
198
-			add_action( 'save_post', array( $this, 'meta_boxes_save' ), 1, 2 );
199
-			add_action( 'pre_post_update', array( $this, 'pre_post_update' ) );
200
-			add_action( 'admin_notices', array( $this, 'meta_boxes_show_errors' ), 0 );
201
-			add_action( 'admin_enqueue_scripts', array( $this, 'enqueue' ), 20 );
202
-
203
-			// Global variable overrides for within loops.
204
-			add_action( 'the_post', array( $this, 'loop_start' ), 0 );
205
-			add_action( 'loop_end', array( $this, 'loop_end' ), 0 );
206
-
207
-			$this->init();
208
-		}
209
-
210
-		/**
211
-		 * Added class names to metabox DIV.
212
-		 *
213
-		 * @param array $classes Class array.
214
-		 *
215
-		 * @return array
216
-		 */
217
-		public function add_box_classes( array $classes ): array {
218
-			$classes[] = 'redux-metabox';
219
-			$classes[] = 'redux-' . $this->parent->args['opt_name'];
220
-
221
-			if ( '' !== $this->parent->args['class'] ) {
222
-				$classes[] = $this->parent->args['class'];
223
-			}
224
-
225
-			return $classes;
226
-		}
227
-
228
-		/**
229
-		 * Class init.
230
-		 */
231
-		public function init() {
232
-			global $pagenow;
233
-
234
-			// phpcs:ignore WordPress.NamingConventions.ValidHookName
235
-			$this->boxes = apply_filters( 'redux/metaboxes/' . $this->parent->args['opt_name'] . '/boxes', $this->boxes, $this->parent->args['opt_name'] );
236
-
237
-			if ( empty( $this->boxes ) && class_exists( 'Redux_Metaboxes' ) ) {
238
-				$this->boxes = Redux_Metaboxes::construct_boxes( $this->parent->args['opt_name'] );
239
-			}
240
-
241
-			if ( empty( $this->boxes ) || ! is_array( $this->boxes ) ) {
242
-				return;
243
-			}
244
-
245
-			if ( isset( Redux_Core::$server['HTTP_HOST'] ) && isset( Redux_Core::$server['REQUEST_URI'] ) ) {
246
-				$this->base_url = ( is_ssl() ? 'https://' : 'http://' ) . sanitize_text_field( wp_unslash( Redux_Core::$server['HTTP_HOST'] ) ) . sanitize_text_field( wp_unslash( Redux_Core::$server['REQUEST_URI'] ) ); // Safe & Reliable.
247
-				$this->post_id  = $this->url_to_postid( ( is_ssl() ? 'https://' : 'http://' ) . sanitize_text_field( wp_unslash( Redux_Core::$server['HTTP_HOST'] ) ) . sanitize_text_field( wp_unslash( Redux_Core::$server['REQUEST_URI'] ) ) );
248
-			}
249
-
250
-			if ( is_admin() && isset( $_GET['post_type'] ) && ! empty( $_GET['post_type'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification
251
-				$this->post_type = sanitize_text_field( wp_unslash( $_GET['post_type'] ) ); // phpcs:ignore WordPress.Security.NonceVerification
252
-			} else {
253
-				$this->post_type = get_post_type( $this->post_id );
254
-			}
255
-
256
-			foreach ( $this->boxes as $bk => $box ) {
257
-
258
-				// If the post-ids for this box are set, we're limiting to the current post id.
259
-				if ( ! empty( $box['post_ids'] ) ) {
260
-					if ( ! is_array( $box['post_ids'] ) ) {
261
-						$box['post_ids'] = array( $box['post_ids'] );
262
-					}
263
-					if ( ! in_array( $this->post_id, $box['post_ids'], true ) ) {
264
-						continue;
265
-					}
266
-				}
267
-
268
-				if ( ! empty( $box['sections'] ) ) {
269
-					$this->sections = wp_parse_args( $this->sections, $box['sections'] );
270
-
271
-					$this->post_types = wp_parse_args( $this->post_types, $box['post_types'] );
272
-
273
-					// Checking to override the parent variables.
274
-					$add_field = false;
275
-
276
-					foreach ( $box['post_types'] as $type ) {
277
-						if ( $this->post_type === $type ) {
278
-							$add_field = true;
279
-						}
280
-					}
281
-
282
-					// Replacing all the fields.
283
-					if ( $add_field || ( ( is_admin() && ( 'post-new.php' === $pagenow || 'post.php' === $pagenow ) ) || ( ! is_admin() ) ) ) {
284
-						$run_hooks = true;
285
-
286
-						$box_id = 'redux-' . $this->parent->args['opt_name'] . '-metabox-' . $box['id'];
287
-
288
-						// phpcs:ignore WordPress.NamingConventions.ValidHookName
289
-						do_action( 'redux/' . $this->parent->args['opt_name'] . '/extensions/metabox/init', $this, $box );
290
-
291
-						if ( isset( $box['page_template'] ) && 'page' === $this->post_type ) {
292
-							if ( ! is_array( $box['page_template'] ) ) {
293
-								$box['page_template'] = array( $box['page_template'] );
294
-							}
295
-
296
-							$this->wp_links[ $box_id ]['page_template'] = isset( $this->wp_links[ $box_id ]['page_template'] ) ? wp_parse_args( $this->wp_links[ $box_id ]['page_template'], $box['page_template'] ) : $box['page_template'];
297
-						}
298
-
299
-						if ( isset( $box['post_format'] ) && ( in_array( $this->post_type, $this->post_types, true ) || '' === $this->post_type || false === $this->post_type ) ) {
300
-							if ( ! is_array( $box['post_format'] ) ) {
301
-								$box['post_format'] = array( $box['post_format'] );
302
-							}
303
-
304
-							$this->wp_links[ $box_id ]['post_format'] = isset( $this->wp_links[ $box_id ]['post_format'] ) ? wp_parse_args( $this->wp_links[ $box_id ]['post_format'], $box['post_format'] ) : $box['post_format'];
305
-						}
306
-
307
-						$this->meta[ $this->post_id ] = $this->get_meta( $this->post_id );
308
-
309
-						foreach ( $box['sections'] as $sk => $section ) {
310
-							if ( ! empty( $section['fields'] ) ) {
311
-								foreach ( $section['fields'] as $fk => $field ) {
312
-									if ( ! isset( $field['class'] ) ) {
313
-										$field['class'] = '';
314
-
315
-										$this->boxes[ $bk ]['sections'][ $sk ]['fields'][ $fk ] = $field;
316
-									}
317
-
318
-									if ( $add_field || ( ( is_admin() && ( 'post-new.php' === $pagenow || 'post.php' === $pagenow ) ) || ( ! is_admin() ) ) ) {
319
-										if ( empty( $field['id'] ) ) {
320
-											continue;
321
-										}
322
-
323
-										if ( isset( $field['default'] ) ) {
324
-											$this->options_defaults[ $field['id'] ] = $field['default'];
325
-										} else {
326
-											$this->options_defaults[ $field['id'] ] = $this->field_default( $field );
327
-										}
328
-
329
-										foreach ( $box['post_types'] as $type ) {
330
-											$this->post_type_fields[ $type ][ $field['id'] ] = 1;
331
-
332
-											if ( 'repeater' === $field['type'] ) {
333
-												foreach ( $field['fields'] as $val ) {
334
-													$this->post_type_fields[ $type ][ $val['id'] ] = 1;
335
-												}
336
-											}
337
-										}
338
-
339
-										if ( ! empty( $field['output'] ) ) {
340
-											$this->output[ $field['id'] ] = isset( $this->output[ $field['id'] ] ) ? array_merge( $field['output'], $this->output[ $field['id'] ] ) : $field['output'];
341
-										}
342
-
343
-										// Detect what field types are being used.
344
-										if ( ! isset( $this->parent->fields[ $field['type'] ][ $field['id'] ] ) ) {
345
-											$this->parent->fields[ $field['type'] ][ $field['id'] ] = 1;
346
-										} else {
347
-											$this->parent->fields[ $field['type'] ] = array( $field['id'] => 1 );
348
-										}
349
-
350
-										if ( isset( $this->options_defaults[ $field['id'] ] ) ) {
351
-											$this->to_replace[ $field['id'] ] = $field;
352
-										}
353
-									}
354
-
355
-									if ( ! isset( $this->parent->options[ $field['id'] ] ) ) {
356
-										$this->parent->sections[ ( count( $this->parent->sections ) - 1 ) ]['fields'][] = $field;
357
-									}
358
-
359
-									if ( ! isset( $this->meta[ $this->post_id ][ $field['id'] ] ) ) {
360
-										$this->meta[ $this->post_id ][ $field['id'] ] = $this->options_defaults[ $field['id'] ];
361
-									}
362
-
363
-									// Only override if it exists, and it's not the default.
364
-									// phpcs:ignore Squiz.PHP.CommentedOutCode
365
-									// if ( isset( $this->meta[ $this->post_id ][ $field['id'] ] ) && isset( $field['default'] ) && $this->meta[ $this->post_id ][ $field['id'] ] === $field['default'] ) {
366
-									// unset($this->meta[$this->post_id][$field['id']]);
367
-									// } .
368
-								}
369
-							}
370
-						}
371
-					}
372
-				}
373
-			}
374
-
375
-			if ( isset( $run_hooks ) && true === $run_hooks ) {
376
-				$this->parent_options = array();
377
-
378
-				if ( ! empty( $this->to_replace ) ) {
379
-					foreach ( $this->to_replace as $id => $field ) {
380
-
381
-						// phpcs:ignore WordPress.NamingConventions.ValidHookName
382
-						add_filter( "redux/options/{$this->parent->args['opt_name']}/field/$id/register", array( $this, 'replace_field' ) );
383
-					}
384
-				}
385
-
386
-				add_filter( "redux/options/{$this->parent->args['opt_name']}/options", array( $this, 'override_options' ) );
387
-				add_filter( "redux/field/{$this->parent->args['opt_name']}/_can_output_css", array( $this, 'override_can_output_css' ) );
388
-				add_filter( "redux/field/{$this->parent->args['opt_name']}/output_css", array( $this, 'output_css' ) );
389
-			}
390
-		}
391
-
392
-		/**
393
-		 * Replace Field.
394
-		 *
395
-		 * @param array $field Field array.
396
-		 *
397
-		 * @return mixed
398
-		 */
399
-		public function replace_field( array $field ) {
400
-			if ( isset( $this->to_replace[ $field['id'] ] ) ) {
401
-				$field = $this->to_replace[ $field['id'] ];
402
-			}
403
-
404
-			return $field;
405
-		}
406
-
407
-		/**
408
-		 * Override CSS output.
409
-		 *
410
-		 * @param array $field Field array.
411
-		 *
412
-		 * @return array
413
-		 */
414
-		public function override_can_output_css( array $field ): array {
415
-			if ( isset( $this->output[ $field['id'] ] ) ) {
416
-				$field['force_output'] = true;
417
-			}
418
-
419
-			return $field;
420
-		}
421
-
422
-		/**
423
-		 * Output CSS.
424
-		 *
425
-		 * @param array $field Field array.
426
-		 *
427
-		 * @return array
428
-		 */
429
-		public function output_css( array $field ): array {
430
-			if ( isset( $this->output[ $field['id'] ] ) ) {
431
-				$field['output'] = $this->output[ $field['id'] ];
432
-			}
433
-
434
-			return $field;
435
-		}
436
-
437
-		/**
438
-		 * Make sure the defaults are the defaults
439
-		 *
440
-		 * @param array $options Options array.
441
-		 *
442
-		 * @return array
443
-		 */
444
-		public function override_options( array $options ): array {
445
-			$this->parent->default_values();
446
-			$this->parent_defaults = $this->parent->options_defaults;
447
-
448
-			$meta = $this->get_meta( $this->post_id );
449
-			$data = wp_parse_args( $meta, $this->options_defaults );
450
-
451
-			foreach ( $data as $key => $value ) {
452
-				if ( isset( $meta[ $key ] ) && '' !== $meta[ $key ] ) {
453
-					$data[ $key ] = $meta[ $key ];
454
-					continue;
455
-				}
456
-
457
-				if ( isset( $options[ $key ] ) ) {
458
-					$data[ $key ] = $options[ $key ];
459
-				}
460
-			}
461
-
462
-			$this->parent->options_defaults = wp_parse_args( $this->options_defaults, $this->parent->options_defaults );
463
-
464
-			return wp_parse_args( $data, $options );
465
-		}
466
-
467
-		/**
468
-		 * Loop start.
469
-		 *
470
-		 * @param mixed $the_post WP_Post object.
471
-		 *
472
-		 * @return array|void
473
-		 */
474
-		public function loop_start( $the_post = array() ) {
475
-			// phpcs:disable WordPress.NamingConventions.PrefixAllGlobals -- Cannot rename 'this.'
476
-			if ( is_admin() ) {
477
-				return $the_post;
478
-			}
479
-
480
-			if ( isset( $the_post ) && is_array( $the_post ) ) {
481
-				global $post;
482
-				$the_post = $post;
483
-			}
484
-
485
-			if ( isset( $GLOBALS[ $this->parent->args['global_variable'] . '-loop' ] ) ) {
486
-				$GLOBALS[ $this->parent->args['global_variable'] ] = $GLOBALS[ $this->parent->args['global_variable'] . '-loop' ];
487
-				unset( $GLOBALS[ $this->parent->args['global_variable'] . '-loop' ] );
488
-			}
489
-
490
-			// Override these values if they differ from the admin panel defaults.  ;) .
491
-			if ( in_array( $the_post->post_type, $this->post_types, true ) ) {
492
-				$meta = $this->get_meta( $the_post->ID );
493
-				if ( empty( $meta ) ) {
494
-					return;
495
-				}
496
-
497
-				// Backup the args.
498
-				$GLOBALS[ $this->parent->args['global_variable'] . '-loop' ] = $GLOBALS[ $this->parent->args['global_variable'] ];
499
-				$GLOBALS[ $this->parent->args['global_variable'] ]           = wp_parse_args( $meta, $GLOBALS[ $this->parent->args['global_variable'] . '-loop' ] );
500
-			}
501
-
502
-			// phpcs:enable WordPress.NamingConventions.PrefixAllGlobals -- Cannot rename 'this.'
503
-		}
504
-
505
-		/**
506
-		 * Loop end.
507
-		 */
508
-		public function loop_end() {
509
-			if ( isset( $GLOBALS[ $this->parent->args['global_variable'] . '-loop' ] ) ) {
510
-				// phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals -- Cannot rename 'this.'  C'mon WP guys. Dumbest fucking misflag ever!
511
-				$GLOBALS[ $this->parent->args['global_variable'] ] = $GLOBALS[ $this->parent->args['global_variable'] . '-loop' ];
512
-
513
-				unset( $GLOBALS[ $this->parent->args['global_variable'] . '-loop' ] );
514
-			}
515
-		}
516
-
517
-		/**
518
-		 * Enqueue fields.
519
-		 */
520
-		public function enqueue() {
521
-			global $pagenow;
522
-
523
-			$types = array();
524
-
525
-			// Enqueue CSS.
526
-			foreach ( $this->boxes as $key => $box ) {
527
-				if ( empty( $box['sections'] ) ) {
528
-					continue;
529
-				}
530
-
531
-				if ( isset( $box['post_types'] ) ) {
532
-					$types = array_merge( $box['post_types'], $types );
533
-				}
534
-
535
-				if ( ! empty( $box['post_types'] ) ) {
536
-					if ( ! is_array( $box['post_types'] ) ) {
537
-						$box['post_types']                 = array( $box['post_types'] );
538
-						$this->boxes[ $key ]['post_types'] = $box['post_types'];
539
-					}
540
-				}
541
-			}
542
-
543
-			if ( 'post-new.php' === $pagenow || 'post.php' === $pagenow ) {
544
-				global $post;
545
-
546
-				if ( in_array( $post->post_type, $types, true ) ) {
547
-					$this->parent->transients       = get_transient( $this->parent->args['opt_name'] . '-transients-metaboxes' );
548
-					$this->parent->transients_check = $this->parent->transients;
549
-
550
-					if ( isset( $this->parent->transients['notices'] ) ) {
551
-						$this->notices                              = $this->parent->transients['notices'];
552
-						$this->parent->transients['last_save_mode'] = 'metaboxes';
553
-					}
554
-
555
-					delete_transient( $this->parent->args['opt_name'] . '-transients-metaboxes' );
556
-					$this->parent->enqueue_class->init();
557
-
558
-					// phpcs:ignore WordPress.NamingConventions.ValidHookName
559
-					do_action( "redux/metaboxes/{$this->parent->args['opt_name']}/enqueue" );
560
-
561
-					// phpcs:ignore WordPress.NamingConventions.ValidHookName
562
-					do_action( "redux/{$this->parent->args['opt_name']}/extensions/metaboxes/enqueue" );
563
-
564
-					/**
565
-					 * Redux metaboxes CSS
566
-					 * filter 'redux/page/{opt_name}/enqueue/redux-extension-metaboxes-css'
567
-					 */
568
-					if ( $this->parent->args['dev_mode'] ) {
569
-						wp_enqueue_style(
570
-							'redux-extension-metaboxes',
571
-							apply_filters( "redux/metaboxes/{$this->parent->args['opt_name']}/enqueue/redux-extension-metaboxes-css", $this->extension_url . 'redux-extension-metaboxes.css' ), // phpcs:ignore: WordPress.NamingConventions.ValidHookName
572
-							array(),
573
-							self::$version
574
-						);
575
-					}
576
-
577
-					/**
578
-					 * Redux metaboxes JS
579
-					 * filter 'redux/page/{opt_name}/enqueue/redux-extension-metaboxes-js
580
-					 */
581
-					wp_enqueue_script(
582
-						'redux-extension-metaboxes',
583
-						apply_filters( "redux/metaboxes/{$this->parent->args['opt_name']}/enqueue/redux-extension-metaboxes-js", $this->extension_url . 'redux-extension-metaboxes' . Redux_Functions::isMin() . '.js' ), // phpcs:ignore: WordPress.NamingConventions.ValidHookName
584
-						array( 'jquery', 'redux-js' ),
585
-						self::$version,
586
-						true
587
-					);
588
-
589
-					// Values used by the javascript.
590
-					wp_localize_script(
591
-						'redux-extension-metaboxes',
592
-						'reduxMetaboxes',
593
-						$this->wp_links
594
-					);
595
-
596
-					wp_localize_script(
597
-						'redux-extension-metaboxes',
598
-						'reduxMetaboxesPageTemplate',
599
-						array(
600
-							'_wp_page_template' => get_post_meta( get_the_ID(), '_wp_page_template', true ),
601
-						)
602
-					);
603
-				}
604
-			}
605
-		}
606
-
607
-		/* Post URLs to IDs function, supports custom post types - borrowed and modified from url_to_postid() in wp-includes/rewrite.php */
608
-
609
-		// Taken from http://betterwp.net/wordpress-tips/url_to_postid-for-custom-post-types/
610
-		// Customized to work with non-rewrite URLs
611
-		// Modified by Dovy Paukstys (@dovy) of Redux Framework.
612
-
613
-		/**
614
-		 * URL to PostID.
615
-		 *
616
-		 * @param string $url URL.
617
-		 *
618
-		 * @return int|mixed|void
619
-		 */
620
-		private function url_to_postid( string $url ) {
621
-			global $wp_rewrite, $pagenow;
622
-
623
-			if ( ! empty( $this->post_id ) ) {
624
-				return $this->post_id;
625
-			}
626
-
627
-			if ( isset( $_GET['post'] ) ) {  // phpcs:ignore WordPress.Security.NonceVerification
628
-				$post = (int) sanitize_text_field( wp_unslash( $_GET['post'] ) );  // phpcs:ignore WordPress.Security.NonceVerification
629
-
630
-				if ( ! empty( $post ) ) {
631
-					return $post;
632
-				}
633
-			}
634
-
635
-			if ( 'post-new.php' === $pagenow || 'wp-login.php' === $pagenow ) {
636
-				return;
637
-			}
638
-
639
-			if ( is_admin() && 'post.php' === $pagenow && isset( $_POST['post_ID'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification
640
-				$post_id = sanitize_text_field( wp_unslash( $_POST['post_ID'] ) ); // phpcs:ignore WordPress.Security.NonceVerification
641
-
642
-				if ( ! empty( $post_id ) && is_numeric( $post_id ) ) {
643
-					return $post_id;
644
-				}
645
-			}
646
-
647
-			$post_id = url_to_postid( $url );
648
-
649
-			if ( isset( $post_id ) && '' !== (string) $post_id && 0 !== $post_id ) {
650
-				return $post_id;
651
-			}
652
-
653
-			// First, check to see if there is a 'p=N' or 'page_id=N' to match against.
654
-			if ( preg_match( '#[?&](p|page_id|attachment_id)=(\d+)#', $url, $values ) ) {
655
-				$id = absint( $values[2] );
656
-				if ( $id ) {
657
-					return $id;
658
-				}
659
-			}
660
-
661
-			// Check to see if we are using rewrite rules.
662
-			if ( isset( $wp_rewrite ) ) {
663
-				$rewrite = $wp_rewrite->wp_rewrite_rules();
664
-			}
665
-
666
-			// Not using rewrite rules, and 'p=N' and 'page_id=N' methods failed, so we're out of options.
667
-			if ( empty( $rewrite ) ) {
668
-				if ( ! empty( $_GET ) ) { // phpcs:ignore WordPress.Security.NonceVerification
669
-
670
-					/************************************************************************
17
+    /**
18
+     * Main Redux_Extension_Metaboxes class
19
+     *
20
+     * @since       1.0.0
21
+     */
22
+    class Redux_Extension_Metaboxes extends Redux_Extension_Abstract {
23
+
24
+        /**
25
+         * Extension version.
26
+         *
27
+         * @var string
28
+         */
29
+        public static $version = '4.2.0';
30
+
31
+        /**
32
+         * Extension friendly name.
33
+         *
34
+         * @var string
35
+         */
36
+        public string $extension_name = 'Metaboxes';
37
+
38
+        /**
39
+         * Boxes array.
40
+         *
41
+         * @var array|null
42
+         */
43
+        public ?array $boxes = array();
44
+
45
+        /**
46
+         * Post types array.
47
+         *
48
+         * @var array|null
49
+         */
50
+        public ?array $post_types = array();
51
+
52
+        /**
53
+         * Post type.
54
+         *
55
+         * @var string|null
56
+         */
57
+        public ?string $post_type;
58
+
59
+        /**
60
+         * Sections array.
61
+         *
62
+         * @var array|null
63
+         */
64
+        public ?array $orig_args;
65
+
66
+        /**
67
+         * Sections array.
68
+         *
69
+         * @var array|null
70
+         */
71
+        public ?array $sections = array();
72
+
73
+        /**
74
+         * CSS output array.
75
+         *
76
+         * @var array|null
77
+         */
78
+        public ?array $output = array();
79
+
80
+        /**
81
+         * Options array.
82
+         *
83
+         * @var array
84
+         */
85
+        public array $options = array();
86
+
87
+        /**
88
+         * Parent options array.
89
+         *
90
+         * @var array
91
+         */
92
+        public array $parent_options = array();
93
+
94
+        /**
95
+         * Parent defaults array.
96
+         *
97
+         * @var array
98
+         */
99
+        public array $parent_defaults = array();
100
+
101
+        /**
102
+         * Post type fields array.
103
+         *
104
+         * @var array
105
+         */
106
+        public array $post_type_fields = array();
107
+
108
+        /**
109
+         * Options defaults array.
110
+         *
111
+         * @var array
112
+         */
113
+        public array $options_defaults = array();
114
+
115
+        /**
116
+         * Replace array.
117
+         *
118
+         * @var array
119
+         */
120
+        public array $to_replace = array();
121
+
122
+        /**
123
+         * Meta data array.
124
+         *
125
+         * @var array
126
+         */
127
+        public array $meta = array();
128
+
129
+        /**
130
+         * Post ID.
131
+         *
132
+         * @var null|int
133
+         */
134
+        public ?int $post_id = 0;
135
+
136
+        /**
137
+         * Base URI.
138
+         *
139
+         * @var string|null
140
+         */
141
+        public ?string $base_url;
142
+
143
+        /**
144
+         * WP_Links array.
145
+         *
146
+         * @var array
147
+         */
148
+        public array $wp_links = array();
149
+
150
+        /**
151
+         * Notices.
152
+         *
153
+         * @var array
154
+         */
155
+        private array $notices = array();
156
+
157
+        /**
158
+         * ReduxFramework_extension_metaboxes constructor.
159
+         *
160
+         * @param object $redux ReduxFramework object.
161
+         */
162
+        public function __construct( $redux ) {
163
+            global $pagenow;
164
+
165
+            parent::__construct( $redux, __FILE__ );
166
+
167
+            $this->parent->extensions['metaboxes'] = $this;
168
+
169
+            $this->extension_dir = trailingslashit( str_replace( '\\', '/', __DIR__ ) );
170
+            $this->extension_url = site_url( str_replace( trailingslashit( str_replace( '\\', '/', ABSPATH ) ), '', $this->extension_dir ) );
171
+
172
+            // Only run metaboxes on the pages/posts, not the front-end.
173
+            // The DOING_AJAX check allows for redux_post_meta to work inside
174
+            // AJAX calls. - kp.
175
+            if ( 'post-new.php' !== $pagenow && 'post.php' !== $pagenow ) {
176
+                if ( is_admin() ) {
177
+                    if ( defined( 'DOING_AJAX' ) && ! DOING_AJAX ) {
178
+                        return;
179
+                    }
180
+
181
+                    return;
182
+                }
183
+            }
184
+
185
+            if ( 'wp-cron.php' === $pagenow || 'wp-comments-post.php' === $pagenow ) {
186
+                return;
187
+            }
188
+
189
+            // Must not update the DB when just updating metaboxes. Sheesh.
190
+            if ( is_admin() && ( 'post-new.php' === $pagenow || 'post.php' === $pagenow ) ) {
191
+                $this->parent->never_save_to_db = true;
192
+            }
193
+
194
+            include_once Redux_Core::$dir . 'inc/extensions/metaboxes/redux-metaboxes-helpers.php';
195
+
196
+            // phpcs:ignore Generic.Strings.UnnecessaryStringConcat
197
+            add_action( 'add_' . 'meta_' . 'boxes', array( $this, 'add' ) );
198
+            add_action( 'save_post', array( $this, 'meta_boxes_save' ), 1, 2 );
199
+            add_action( 'pre_post_update', array( $this, 'pre_post_update' ) );
200
+            add_action( 'admin_notices', array( $this, 'meta_boxes_show_errors' ), 0 );
201
+            add_action( 'admin_enqueue_scripts', array( $this, 'enqueue' ), 20 );
202
+
203
+            // Global variable overrides for within loops.
204
+            add_action( 'the_post', array( $this, 'loop_start' ), 0 );
205
+            add_action( 'loop_end', array( $this, 'loop_end' ), 0 );
206
+
207
+            $this->init();
208
+        }
209
+
210
+        /**
211
+         * Added class names to metabox DIV.
212
+         *
213
+         * @param array $classes Class array.
214
+         *
215
+         * @return array
216
+         */
217
+        public function add_box_classes( array $classes ): array {
218
+            $classes[] = 'redux-metabox';
219
+            $classes[] = 'redux-' . $this->parent->args['opt_name'];
220
+
221
+            if ( '' !== $this->parent->args['class'] ) {
222
+                $classes[] = $this->parent->args['class'];
223
+            }
224
+
225
+            return $classes;
226
+        }
227
+
228
+        /**
229
+         * Class init.
230
+         */
231
+        public function init() {
232
+            global $pagenow;
233
+
234
+            // phpcs:ignore WordPress.NamingConventions.ValidHookName
235
+            $this->boxes = apply_filters( 'redux/metaboxes/' . $this->parent->args['opt_name'] . '/boxes', $this->boxes, $this->parent->args['opt_name'] );
236
+
237
+            if ( empty( $this->boxes ) && class_exists( 'Redux_Metaboxes' ) ) {
238
+                $this->boxes = Redux_Metaboxes::construct_boxes( $this->parent->args['opt_name'] );
239
+            }
240
+
241
+            if ( empty( $this->boxes ) || ! is_array( $this->boxes ) ) {
242
+                return;
243
+            }
244
+
245
+            if ( isset( Redux_Core::$server['HTTP_HOST'] ) && isset( Redux_Core::$server['REQUEST_URI'] ) ) {
246
+                $this->base_url = ( is_ssl() ? 'https://' : 'http://' ) . sanitize_text_field( wp_unslash( Redux_Core::$server['HTTP_HOST'] ) ) . sanitize_text_field( wp_unslash( Redux_Core::$server['REQUEST_URI'] ) ); // Safe & Reliable.
247
+                $this->post_id  = $this->url_to_postid( ( is_ssl() ? 'https://' : 'http://' ) . sanitize_text_field( wp_unslash( Redux_Core::$server['HTTP_HOST'] ) ) . sanitize_text_field( wp_unslash( Redux_Core::$server['REQUEST_URI'] ) ) );
248
+            }
249
+
250
+            if ( is_admin() && isset( $_GET['post_type'] ) && ! empty( $_GET['post_type'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification
251
+                $this->post_type = sanitize_text_field( wp_unslash( $_GET['post_type'] ) ); // phpcs:ignore WordPress.Security.NonceVerification
252
+            } else {
253
+                $this->post_type = get_post_type( $this->post_id );
254
+            }
255
+
256
+            foreach ( $this->boxes as $bk => $box ) {
257
+
258
+                // If the post-ids for this box are set, we're limiting to the current post id.
259
+                if ( ! empty( $box['post_ids'] ) ) {
260
+                    if ( ! is_array( $box['post_ids'] ) ) {
261
+                        $box['post_ids'] = array( $box['post_ids'] );
262
+                    }
263
+                    if ( ! in_array( $this->post_id, $box['post_ids'], true ) ) {
264
+                        continue;
265
+                    }
266
+                }
267
+
268
+                if ( ! empty( $box['sections'] ) ) {
269
+                    $this->sections = wp_parse_args( $this->sections, $box['sections'] );
270
+
271
+                    $this->post_types = wp_parse_args( $this->post_types, $box['post_types'] );
272
+
273
+                    // Checking to override the parent variables.
274
+                    $add_field = false;
275
+
276
+                    foreach ( $box['post_types'] as $type ) {
277
+                        if ( $this->post_type === $type ) {
278
+                            $add_field = true;
279
+                        }
280
+                    }
281
+
282
+                    // Replacing all the fields.
283
+                    if ( $add_field || ( ( is_admin() && ( 'post-new.php' === $pagenow || 'post.php' === $pagenow ) ) || ( ! is_admin() ) ) ) {
284
+                        $run_hooks = true;
285
+
286
+                        $box_id = 'redux-' . $this->parent->args['opt_name'] . '-metabox-' . $box['id'];
287
+
288
+                        // phpcs:ignore WordPress.NamingConventions.ValidHookName
289
+                        do_action( 'redux/' . $this->parent->args['opt_name'] . '/extensions/metabox/init', $this, $box );
290
+
291
+                        if ( isset( $box['page_template'] ) && 'page' === $this->post_type ) {
292
+                            if ( ! is_array( $box['page_template'] ) ) {
293
+                                $box['page_template'] = array( $box['page_template'] );
294
+                            }
295
+
296
+                            $this->wp_links[ $box_id ]['page_template'] = isset( $this->wp_links[ $box_id ]['page_template'] ) ? wp_parse_args( $this->wp_links[ $box_id ]['page_template'], $box['page_template'] ) : $box['page_template'];
297
+                        }
298
+
299
+                        if ( isset( $box['post_format'] ) && ( in_array( $this->post_type, $this->post_types, true ) || '' === $this->post_type || false === $this->post_type ) ) {
300
+                            if ( ! is_array( $box['post_format'] ) ) {
301
+                                $box['post_format'] = array( $box['post_format'] );
302
+                            }
303
+
304
+                            $this->wp_links[ $box_id ]['post_format'] = isset( $this->wp_links[ $box_id ]['post_format'] ) ? wp_parse_args( $this->wp_links[ $box_id ]['post_format'], $box['post_format'] ) : $box['post_format'];
305
+                        }
306
+
307
+                        $this->meta[ $this->post_id ] = $this->get_meta( $this->post_id );
308
+
309
+                        foreach ( $box['sections'] as $sk => $section ) {
310
+                            if ( ! empty( $section['fields'] ) ) {
311
+                                foreach ( $section['fields'] as $fk => $field ) {
312
+                                    if ( ! isset( $field['class'] ) ) {
313
+                                        $field['class'] = '';
314
+
315
+                                        $this->boxes[ $bk ]['sections'][ $sk ]['fields'][ $fk ] = $field;
316
+                                    }
317
+
318
+                                    if ( $add_field || ( ( is_admin() && ( 'post-new.php' === $pagenow || 'post.php' === $pagenow ) ) || ( ! is_admin() ) ) ) {
319
+                                        if ( empty( $field['id'] ) ) {
320
+                                            continue;
321
+                                        }
322
+
323
+                                        if ( isset( $field['default'] ) ) {
324
+                                            $this->options_defaults[ $field['id'] ] = $field['default'];
325
+                                        } else {
326
+                                            $this->options_defaults[ $field['id'] ] = $this->field_default( $field );
327
+                                        }
328
+
329
+                                        foreach ( $box['post_types'] as $type ) {
330
+                                            $this->post_type_fields[ $type ][ $field['id'] ] = 1;
331
+
332
+                                            if ( 'repeater' === $field['type'] ) {
333
+                                                foreach ( $field['fields'] as $val ) {
334
+                                                    $this->post_type_fields[ $type ][ $val['id'] ] = 1;
335
+                                                }
336
+                                            }
337
+                                        }
338
+
339
+                                        if ( ! empty( $field['output'] ) ) {
340
+                                            $this->output[ $field['id'] ] = isset( $this->output[ $field['id'] ] ) ? array_merge( $field['output'], $this->output[ $field['id'] ] ) : $field['output'];
341
+                                        }
342
+
343
+                                        // Detect what field types are being used.
344
+                                        if ( ! isset( $this->parent->fields[ $field['type'] ][ $field['id'] ] ) ) {
345
+                                            $this->parent->fields[ $field['type'] ][ $field['id'] ] = 1;
346
+                                        } else {
347
+                                            $this->parent->fields[ $field['type'] ] = array( $field['id'] => 1 );
348
+                                        }
349
+
350
+                                        if ( isset( $this->options_defaults[ $field['id'] ] ) ) {
351
+                                            $this->to_replace[ $field['id'] ] = $field;
352
+                                        }
353
+                                    }
354
+
355
+                                    if ( ! isset( $this->parent->options[ $field['id'] ] ) ) {
356
+                                        $this->parent->sections[ ( count( $this->parent->sections ) - 1 ) ]['fields'][] = $field;
357
+                                    }
358
+
359
+                                    if ( ! isset( $this->meta[ $this->post_id ][ $field['id'] ] ) ) {
360
+                                        $this->meta[ $this->post_id ][ $field['id'] ] = $this->options_defaults[ $field['id'] ];
361
+                                    }
362
+
363
+                                    // Only override if it exists, and it's not the default.
364
+                                    // phpcs:ignore Squiz.PHP.CommentedOutCode
365
+                                    // if ( isset( $this->meta[ $this->post_id ][ $field['id'] ] ) && isset( $field['default'] ) && $this->meta[ $this->post_id ][ $field['id'] ] === $field['default'] ) {
366
+                                    // unset($this->meta[$this->post_id][$field['id']]);
367
+                                    // } .
368
+                                }
369
+                            }
370
+                        }
371
+                    }
372
+                }
373
+            }
374
+
375
+            if ( isset( $run_hooks ) && true === $run_hooks ) {
376
+                $this->parent_options = array();
377
+
378
+                if ( ! empty( $this->to_replace ) ) {
379
+                    foreach ( $this->to_replace as $id => $field ) {
380
+
381
+                        // phpcs:ignore WordPress.NamingConventions.ValidHookName
382
+                        add_filter( "redux/options/{$this->parent->args['opt_name']}/field/$id/register", array( $this, 'replace_field' ) );
383
+                    }
384
+                }
385
+
386
+                add_filter( "redux/options/{$this->parent->args['opt_name']}/options", array( $this, 'override_options' ) );
387
+                add_filter( "redux/field/{$this->parent->args['opt_name']}/_can_output_css", array( $this, 'override_can_output_css' ) );
388
+                add_filter( "redux/field/{$this->parent->args['opt_name']}/output_css", array( $this, 'output_css' ) );
389
+            }
390
+        }
391
+
392
+        /**
393
+         * Replace Field.
394
+         *
395
+         * @param array $field Field array.
396
+         *
397
+         * @return mixed
398
+         */
399
+        public function replace_field( array $field ) {
400
+            if ( isset( $this->to_replace[ $field['id'] ] ) ) {
401
+                $field = $this->to_replace[ $field['id'] ];
402
+            }
403
+
404
+            return $field;
405
+        }
406
+
407
+        /**
408
+         * Override CSS output.
409
+         *
410
+         * @param array $field Field array.
411
+         *
412
+         * @return array
413
+         */
414
+        public function override_can_output_css( array $field ): array {
415
+            if ( isset( $this->output[ $field['id'] ] ) ) {
416
+                $field['force_output'] = true;
417
+            }
418
+
419
+            return $field;
420
+        }
421
+
422
+        /**
423
+         * Output CSS.
424
+         *
425
+         * @param array $field Field array.
426
+         *
427
+         * @return array
428
+         */
429
+        public function output_css( array $field ): array {
430
+            if ( isset( $this->output[ $field['id'] ] ) ) {
431
+                $field['output'] = $this->output[ $field['id'] ];
432
+            }
433
+
434
+            return $field;
435
+        }
436
+
437
+        /**
438
+         * Make sure the defaults are the defaults
439
+         *
440
+         * @param array $options Options array.
441
+         *
442
+         * @return array
443
+         */
444
+        public function override_options( array $options ): array {
445
+            $this->parent->default_values();
446
+            $this->parent_defaults = $this->parent->options_defaults;
447
+
448
+            $meta = $this->get_meta( $this->post_id );
449
+            $data = wp_parse_args( $meta, $this->options_defaults );
450
+
451
+            foreach ( $data as $key => $value ) {
452
+                if ( isset( $meta[ $key ] ) && '' !== $meta[ $key ] ) {
453
+                    $data[ $key ] = $meta[ $key ];
454
+                    continue;
455
+                }
456
+
457
+                if ( isset( $options[ $key ] ) ) {
458
+                    $data[ $key ] = $options[ $key ];
459
+                }
460
+            }
461
+
462
+            $this->parent->options_defaults = wp_parse_args( $this->options_defaults, $this->parent->options_defaults );
463
+
464
+            return wp_parse_args( $data, $options );
465
+        }
466
+
467
+        /**
468
+         * Loop start.
469
+         *
470
+         * @param mixed $the_post WP_Post object.
471
+         *
472
+         * @return array|void
473
+         */
474
+        public function loop_start( $the_post = array() ) {
475
+            // phpcs:disable WordPress.NamingConventions.PrefixAllGlobals -- Cannot rename 'this.'
476
+            if ( is_admin() ) {
477
+                return $the_post;
478
+            }
479
+
480
+            if ( isset( $the_post ) && is_array( $the_post ) ) {
481
+                global $post;
482
+                $the_post = $post;
483
+            }
484
+
485
+            if ( isset( $GLOBALS[ $this->parent->args['global_variable'] . '-loop' ] ) ) {
486
+                $GLOBALS[ $this->parent->args['global_variable'] ] = $GLOBALS[ $this->parent->args['global_variable'] . '-loop' ];
487
+                unset( $GLOBALS[ $this->parent->args['global_variable'] . '-loop' ] );
488
+            }
489
+
490
+            // Override these values if they differ from the admin panel defaults.  ;) .
491
+            if ( in_array( $the_post->post_type, $this->post_types, true ) ) {
492
+                $meta = $this->get_meta( $the_post->ID );
493
+                if ( empty( $meta ) ) {
494
+                    return;
495
+                }
496
+
497
+                // Backup the args.
498
+                $GLOBALS[ $this->parent->args['global_variable'] . '-loop' ] = $GLOBALS[ $this->parent->args['global_variable'] ];
499
+                $GLOBALS[ $this->parent->args['global_variable'] ]           = wp_parse_args( $meta, $GLOBALS[ $this->parent->args['global_variable'] . '-loop' ] );
500
+            }
501
+
502
+            // phpcs:enable WordPress.NamingConventions.PrefixAllGlobals -- Cannot rename 'this.'
503
+        }
504
+
505
+        /**
506
+         * Loop end.
507
+         */
508
+        public function loop_end() {
509
+            if ( isset( $GLOBALS[ $this->parent->args['global_variable'] . '-loop' ] ) ) {
510
+                // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals -- Cannot rename 'this.'  C'mon WP guys. Dumbest fucking misflag ever!
511
+                $GLOBALS[ $this->parent->args['global_variable'] ] = $GLOBALS[ $this->parent->args['global_variable'] . '-loop' ];
512
+
513
+                unset( $GLOBALS[ $this->parent->args['global_variable'] . '-loop' ] );
514
+            }
515
+        }
516
+
517
+        /**
518
+         * Enqueue fields.
519
+         */
520
+        public function enqueue() {
521
+            global $pagenow;
522
+
523
+            $types = array();
524
+
525
+            // Enqueue CSS.
526
+            foreach ( $this->boxes as $key => $box ) {
527
+                if ( empty( $box['sections'] ) ) {
528
+                    continue;
529
+                }
530
+
531
+                if ( isset( $box['post_types'] ) ) {
532
+                    $types = array_merge( $box['post_types'], $types );
533
+                }
534
+
535
+                if ( ! empty( $box['post_types'] ) ) {
536
+                    if ( ! is_array( $box['post_types'] ) ) {
537
+                        $box['post_types']                 = array( $box['post_types'] );
538
+                        $this->boxes[ $key ]['post_types'] = $box['post_types'];
539
+                    }
540
+                }
541
+            }
542
+
543
+            if ( 'post-new.php' === $pagenow || 'post.php' === $pagenow ) {
544
+                global $post;
545
+
546
+                if ( in_array( $post->post_type, $types, true ) ) {
547
+                    $this->parent->transients       = get_transient( $this->parent->args['opt_name'] . '-transients-metaboxes' );
548
+                    $this->parent->transients_check = $this->parent->transients;
549
+
550
+                    if ( isset( $this->parent->transients['notices'] ) ) {
551
+                        $this->notices                              = $this->parent->transients['notices'];
552
+                        $this->parent->transients['last_save_mode'] = 'metaboxes';
553
+                    }
554
+
555
+                    delete_transient( $this->parent->args['opt_name'] . '-transients-metaboxes' );
556
+                    $this->parent->enqueue_class->init();
557
+
558
+                    // phpcs:ignore WordPress.NamingConventions.ValidHookName
559
+                    do_action( "redux/metaboxes/{$this->parent->args['opt_name']}/enqueue" );
560
+
561
+                    // phpcs:ignore WordPress.NamingConventions.ValidHookName
562
+                    do_action( "redux/{$this->parent->args['opt_name']}/extensions/metaboxes/enqueue" );
563
+
564
+                    /**
565
+                     * Redux metaboxes CSS
566
+                     * filter 'redux/page/{opt_name}/enqueue/redux-extension-metaboxes-css'
567
+                     */
568
+                    if ( $this->parent->args['dev_mode'] ) {
569
+                        wp_enqueue_style(
570
+                            'redux-extension-metaboxes',
571
+                            apply_filters( "redux/metaboxes/{$this->parent->args['opt_name']}/enqueue/redux-extension-metaboxes-css", $this->extension_url . 'redux-extension-metaboxes.css' ), // phpcs:ignore: WordPress.NamingConventions.ValidHookName
572
+                            array(),
573
+                            self::$version
574
+                        );
575
+                    }
576
+
577
+                    /**
578
+                     * Redux metaboxes JS
579
+                     * filter 'redux/page/{opt_name}/enqueue/redux-extension-metaboxes-js
580
+                     */
581
+                    wp_enqueue_script(
582
+                        'redux-extension-metaboxes',
583
+                        apply_filters( "redux/metaboxes/{$this->parent->args['opt_name']}/enqueue/redux-extension-metaboxes-js", $this->extension_url . 'redux-extension-metaboxes' . Redux_Functions::isMin() . '.js' ), // phpcs:ignore: WordPress.NamingConventions.ValidHookName
584
+                        array( 'jquery', 'redux-js' ),
585
+                        self::$version,
586
+                        true
587
+                    );
588
+
589
+                    // Values used by the javascript.
590
+                    wp_localize_script(
591
+                        'redux-extension-metaboxes',
592
+                        'reduxMetaboxes',
593
+                        $this->wp_links
594
+                    );
595
+
596
+                    wp_localize_script(
597
+                        'redux-extension-metaboxes',
598
+                        'reduxMetaboxesPageTemplate',
599
+                        array(
600
+                            '_wp_page_template' => get_post_meta( get_the_ID(), '_wp_page_template', true ),
601
+                        )
602
+                    );
603
+                }
604
+            }
605
+        }
606
+
607
+        /* Post URLs to IDs function, supports custom post types - borrowed and modified from url_to_postid() in wp-includes/rewrite.php */
608
+
609
+        // Taken from http://betterwp.net/wordpress-tips/url_to_postid-for-custom-post-types/
610
+        // Customized to work with non-rewrite URLs
611
+        // Modified by Dovy Paukstys (@dovy) of Redux Framework.
612
+
613
+        /**
614
+         * URL to PostID.
615
+         *
616
+         * @param string $url URL.
617
+         *
618
+         * @return int|mixed|void
619
+         */
620
+        private function url_to_postid( string $url ) {
621
+            global $wp_rewrite, $pagenow;
622
+
623
+            if ( ! empty( $this->post_id ) ) {
624
+                return $this->post_id;
625
+            }
626
+
627
+            if ( isset( $_GET['post'] ) ) {  // phpcs:ignore WordPress.Security.NonceVerification
628
+                $post = (int) sanitize_text_field( wp_unslash( $_GET['post'] ) );  // phpcs:ignore WordPress.Security.NonceVerification
629
+
630
+                if ( ! empty( $post ) ) {
631
+                    return $post;
632
+                }
633
+            }
634
+
635
+            if ( 'post-new.php' === $pagenow || 'wp-login.php' === $pagenow ) {
636
+                return;
637
+            }
638
+
639
+            if ( is_admin() && 'post.php' === $pagenow && isset( $_POST['post_ID'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification
640
+                $post_id = sanitize_text_field( wp_unslash( $_POST['post_ID'] ) ); // phpcs:ignore WordPress.Security.NonceVerification
641
+
642
+                if ( ! empty( $post_id ) && is_numeric( $post_id ) ) {
643
+                    return $post_id;
644
+                }
645
+            }
646
+
647
+            $post_id = url_to_postid( $url );
648
+
649
+            if ( isset( $post_id ) && '' !== (string) $post_id && 0 !== $post_id ) {
650
+                return $post_id;
651
+            }
652
+
653
+            // First, check to see if there is a 'p=N' or 'page_id=N' to match against.
654
+            if ( preg_match( '#[?&](p|page_id|attachment_id)=(\d+)#', $url, $values ) ) {
655
+                $id = absint( $values[2] );
656
+                if ( $id ) {
657
+                    return $id;
658
+                }
659
+            }
660
+
661
+            // Check to see if we are using rewrite rules.
662
+            if ( isset( $wp_rewrite ) ) {
663
+                $rewrite = $wp_rewrite->wp_rewrite_rules();
664
+            }
665
+
666
+            // Not using rewrite rules, and 'p=N' and 'page_id=N' methods failed, so we're out of options.
667
+            if ( empty( $rewrite ) ) {
668
+                if ( ! empty( $_GET ) ) { // phpcs:ignore WordPress.Security.NonceVerification
669
+
670
+                    /************************************************************************
671 671
 					 * ADDED: Trys checks URL for ?posttype=postname
672 672
 					 ************************************************************************ */
673 673
 
674
-					// Assign $url to $temp_url just in case. :) .
675
-					$temp_url = $url;
676
-
677
-					// Get rid of the #anchor.
678
-					$url_split = explode( '#', $temp_url );
679
-					$temp_url  = $url_split[0];
680
-
681
-					// Get rid of URL ?query=string.
682
-					$url_query = explode( '&', $temp_url );
683
-					$temp_url  = $url_query[0];
684
-
685
-					// Get rid of ? mark.
686
-					$url_query = explode( '?', $temp_url );
687
-
688
-					if ( ! empty( $url_query[1] ) && strpos( $url_query[1], '=' ) ) {
689
-						$url_query = explode( '=', $url_query[1] );
690
-
691
-						if ( isset( $url_query[0] ) && isset( $url_query[1] ) ) {
692
-							$args = array(
693
-								'name'      => $url_query[1],
694
-								'post_type' => $url_query[0],
695
-								'showposts' => 1,
696
-							);
697
-
698
-							if ( get_posts( $args ) === $post ) {
699
-								return $post[0]->ID;
700
-							}
701
-						}
702
-					}
703
-
704
-					foreach ( $GLOBALS['wp_post_types'] as $key => $value ) {
705
-						if ( ! empty( $_GET[ $key ] ) ) { // phpcs:ignore WordPress.Security.NonceVerification
706
-							$args = array(
707
-								'name'      => sanitize_text_field( wp_unslash( $_GET[ $key ] ) ), // phpcs:ignore WordPress.Security.NonceVerification
708
-								'post_type' => $key,
709
-								'showposts' => 1,
710
-							);
711
-
712
-							if ( get_posts( $args ) === $post ) {
713
-								return $post[0]->ID;
714
-							}
715
-						}
716
-					}
717
-				}
718
-			}
719
-
720
-			// Get rid of the #anchor.
721
-			$url_split = explode( '#', $url );
722
-			$url       = $url_split[0];
723
-
724
-			// Get rid of URL ?query=string.
725
-			$url_query = explode( '?', $url );
726
-			$url       = $url_query[0];
727
-
728
-			// Set the correct URL scheme.
729
-			$scheme = wp_parse_url( home_url(), PHP_URL_SCHEME );
730
-			$url    = set_url_scheme( $url, $scheme );
731
-
732
-			// Add 'www.' if it is absent and should be there.
733
-			if ( false !== strpos( home_url(), '://www.' ) && false === strpos( $url, '://www.' ) ) {
734
-				$url = str_replace( '://', '://www.', $url );
735
-			}
736
-
737
-			// Strip 'www.' if it is present and shouldn't be.
738
-			if ( false === strpos( home_url(), '://www.' ) ) {
739
-				$url = str_replace( '://www.', '://', $url );
740
-			}
741
-
742
-			// Strip 'index.php/' if we're not using path info permalinks.
743
-			if ( isset( $wp_rewrite ) && ! $wp_rewrite->using_index_permalinks() ) {
744
-				$url = str_replace( 'index.php/', '', $url );
745
-			}
746
-
747
-			if ( false !== strpos( $url, home_url() ) ) {
748
-				// Chop off http://domain.com.
749
-				$url = str_replace( home_url(), '', $url );
750
-			} else {
751
-				// Chop off /path/to/blog.
752
-				$home_path = wp_parse_url( home_url() );
753
-				$home_path = $home_path['path'] ?? '';
754
-				$url       = str_replace( $home_path, '', $url );
755
-			}
756
-
757
-			// Trim leading and lagging slashes.
758
-			$url = trim( $url, '/' );
759
-
760
-			$request = $url;
761
-
762
-			if ( empty( $request ) && ( empty( $_GET ) ) ) { // phpcs:ignore WordPress.Security.NonceVerification
763
-				return get_option( 'page_on_front' );
764
-			}
765
-
766
-			// Look for matches.
767
-			$request_match = $request;
768
-
769
-			foreach ( $rewrite as $match => $query ) {
770
-				// If the requesting file is the anchor of the match, prepend it
771
-				// to the path info.
772
-				if ( ! empty( $url ) && ( $url !== $request ) && ( strpos( $match, $url ) === 0 ) ) {
773
-					$request_match = $url . '/' . $request;
774
-				}
775
-
776
-				if ( preg_match( "!^$match!", $request_match, $matches ) ) {
777
-					global $wp;
778
-
779
-					// Got a match.
780
-					// Trim the query of everything up to the '?'.
781
-					$query = preg_replace( '!^.+\?!', '', $query );
782
-
783
-					// Substitute the substring matches into the query.
784
-					$query = addslashes( WP_MatchesMapRegex::apply( $query, $matches ) );
785
-
786
-					// Filter out non-public query vars.
787
-					parse_str( $query, $query_vars );
788
-
789
-					$query = array();
790
-
791
-					foreach ( $query_vars as $key => $value ) {
792
-						if ( in_array( $key, $wp->public_query_vars, true ) ) {
793
-							$query[ $key ] = $value;
794
-						}
795
-					}
796
-
797
-					/************************************************************************
674
+                    // Assign $url to $temp_url just in case. :) .
675
+                    $temp_url = $url;
676
+
677
+                    // Get rid of the #anchor.
678
+                    $url_split = explode( '#', $temp_url );
679
+                    $temp_url  = $url_split[0];
680
+
681
+                    // Get rid of URL ?query=string.
682
+                    $url_query = explode( '&', $temp_url );
683
+                    $temp_url  = $url_query[0];
684
+
685
+                    // Get rid of ? mark.
686
+                    $url_query = explode( '?', $temp_url );
687
+
688
+                    if ( ! empty( $url_query[1] ) && strpos( $url_query[1], '=' ) ) {
689
+                        $url_query = explode( '=', $url_query[1] );
690
+
691
+                        if ( isset( $url_query[0] ) && isset( $url_query[1] ) ) {
692
+                            $args = array(
693
+                                'name'      => $url_query[1],
694
+                                'post_type' => $url_query[0],
695
+                                'showposts' => 1,
696
+                            );
697
+
698
+                            if ( get_posts( $args ) === $post ) {
699
+                                return $post[0]->ID;
700
+                            }
701
+                        }
702
+                    }
703
+
704
+                    foreach ( $GLOBALS['wp_post_types'] as $key => $value ) {
705
+                        if ( ! empty( $_GET[ $key ] ) ) { // phpcs:ignore WordPress.Security.NonceVerification
706
+                            $args = array(
707
+                                'name'      => sanitize_text_field( wp_unslash( $_GET[ $key ] ) ), // phpcs:ignore WordPress.Security.NonceVerification
708
+                                'post_type' => $key,
709
+                                'showposts' => 1,
710
+                            );
711
+
712
+                            if ( get_posts( $args ) === $post ) {
713
+                                return $post[0]->ID;
714
+                            }
715
+                        }
716
+                    }
717
+                }
718
+            }
719
+
720
+            // Get rid of the #anchor.
721
+            $url_split = explode( '#', $url );
722
+            $url       = $url_split[0];
723
+
724
+            // Get rid of URL ?query=string.
725
+            $url_query = explode( '?', $url );
726
+            $url       = $url_query[0];
727
+
728
+            // Set the correct URL scheme.
729
+            $scheme = wp_parse_url( home_url(), PHP_URL_SCHEME );
730
+            $url    = set_url_scheme( $url, $scheme );
731
+
732
+            // Add 'www.' if it is absent and should be there.
733
+            if ( false !== strpos( home_url(), '://www.' ) && false === strpos( $url, '://www.' ) ) {
734
+                $url = str_replace( '://', '://www.', $url );
735
+            }
736
+
737
+            // Strip 'www.' if it is present and shouldn't be.
738
+            if ( false === strpos( home_url(), '://www.' ) ) {
739
+                $url = str_replace( '://www.', '://', $url );
740
+            }
741
+
742
+            // Strip 'index.php/' if we're not using path info permalinks.
743
+            if ( isset( $wp_rewrite ) && ! $wp_rewrite->using_index_permalinks() ) {
744
+                $url = str_replace( 'index.php/', '', $url );
745
+            }
746
+
747
+            if ( false !== strpos( $url, home_url() ) ) {
748
+                // Chop off http://domain.com.
749
+                $url = str_replace( home_url(), '', $url );
750
+            } else {
751
+                // Chop off /path/to/blog.
752
+                $home_path = wp_parse_url( home_url() );
753
+                $home_path = $home_path['path'] ?? '';
754
+                $url       = str_replace( $home_path, '', $url );
755
+            }
756
+
757
+            // Trim leading and lagging slashes.
758
+            $url = trim( $url, '/' );
759
+
760
+            $request = $url;
761
+
762
+            if ( empty( $request ) && ( empty( $_GET ) ) ) { // phpcs:ignore WordPress.Security.NonceVerification
763
+                return get_option( 'page_on_front' );
764
+            }
765
+
766
+            // Look for matches.
767
+            $request_match = $request;
768
+
769
+            foreach ( $rewrite as $match => $query ) {
770
+                // If the requesting file is the anchor of the match, prepend it
771
+                // to the path info.
772
+                if ( ! empty( $url ) && ( $url !== $request ) && ( strpos( $match, $url ) === 0 ) ) {
773
+                    $request_match = $url . '/' . $request;
774
+                }
775
+
776
+                if ( preg_match( "!^$match!", $request_match, $matches ) ) {
777
+                    global $wp;
778
+
779
+                    // Got a match.
780
+                    // Trim the query of everything up to the '?'.
781
+                    $query = preg_replace( '!^.+\?!', '', $query );
782
+
783
+                    // Substitute the substring matches into the query.
784
+                    $query = addslashes( WP_MatchesMapRegex::apply( $query, $matches ) );
785
+
786
+                    // Filter out non-public query vars.
787
+                    parse_str( $query, $query_vars );
788
+
789
+                    $query = array();
790
+
791
+                    foreach ( $query_vars as $key => $value ) {
792
+                        if ( in_array( $key, $wp->public_query_vars, true ) ) {
793
+                            $query[ $key ] = $value;
794
+                        }
795
+                    }
796
+
797
+                    /************************************************************************
798 798
 					 * ADDED: $GLOBALS['wp_post_types'] doesn't seem to have custom posttypes
799 799
 					 * Trying below to find posttypes in $rewrite rules
800 800
 					 ************************************************************************ */
801 801
 
802
-					// PostType Array.
803
-					$post_types = array();
804
-
805
-					foreach ( $rewrite as $value ) {
806
-						if ( preg_match( '/post_type=([^&]+)/i', $value, $matched ) ) {
807
-							if ( isset( $matched[1] ) && ! in_array( $matched[1], $post_types, true ) ) {
808
-								$post_types[] = $matched[1];
809
-							}
810
-						}
811
-					}
812
-
813
-					foreach ( $query_vars as $key => $value ) {
814
-						if ( in_array( $key, $post_types, true ) ) {
815
-							$query['post_type'] = $key;
816
-							$query['postname']  = $value;
817
-						}
818
-					}
819
-
820
-					/************************************************************************
802
+                    // PostType Array.
803
+                    $post_types = array();
804
+
805
+                    foreach ( $rewrite as $value ) {
806
+                        if ( preg_match( '/post_type=([^&]+)/i', $value, $matched ) ) {
807
+                            if ( isset( $matched[1] ) && ! in_array( $matched[1], $post_types, true ) ) {
808
+                                $post_types[] = $matched[1];
809
+                            }
810
+                        }
811
+                    }
812
+
813
+                    foreach ( $query_vars as $key => $value ) {
814
+                        if ( in_array( $key, $post_types, true ) ) {
815
+                            $query['post_type'] = $key;
816
+                            $query['postname']  = $value;
817
+                        }
818
+                    }
819
+
820
+                    /************************************************************************
821 821
 					 * END ADD
822 822
 					 ************************************************************************ */
823 823
 
824
-					// Taken from class-wp.php.
825
-					foreach ( $GLOBALS['wp_post_types'] as $post_type => $t ) {
826
-						if ( isset( $t->query_var ) ) {
827
-							$post_type_query_vars[ $t->query_var ] = $post_type;
828
-						}
829
-					}
830
-
831
-					foreach ( $wp->public_query_vars as $wpvar ) {
832
-						if ( isset( $wp->extra_query_vars[ $wpvar ] ) ) {
833
-							$query[ $wpvar ] = $wp->extra_query_vars[ $wpvar ];
834
-						} elseif ( isset( $_POST[ $wpvar ] ) ) { // phpcs:ignore WordPress.Security.NonceVerification
835
-							$query[ $wpvar ] = sanitize_text_field( wp_unslash( $_POST[ $wpvar ] ) ); // phpcs:ignore WordPress.Security.NonceVerification
836
-						} elseif ( isset( $_GET[ $wpvar ] ) ) { // phpcs:ignore WordPress.Security.NonceVerification
837
-							$query[ $wpvar ] = sanitize_text_field( wp_unslash( $_GET[ $wpvar ] ) ); // phpcs:ignore WordPress.Security.NonceVerification
838
-						} elseif ( isset( $query_vars[ $wpvar ] ) ) {
839
-							$query[ $wpvar ] = $query_vars[ $wpvar ];
840
-						}
841
-
842
-						if ( ! empty( $query[ $wpvar ] ) ) {
843
-							if ( ! is_array( $query[ $wpvar ] ) ) {
844
-								$query[ $wpvar ] = (string) $query[ $wpvar ];
845
-							} else {
846
-								foreach ( $query[ $wpvar ] as $vkey => $v ) {
847
-									if ( ! is_object( $v ) ) {
848
-										$query[ $wpvar ][ $vkey ] = (string) $v;
849
-									}
850
-								}
851
-							}
852
-
853
-							if ( isset( $post_type_query_vars[ $wpvar ] ) ) {
854
-								$query['post_type'] = $post_type_query_vars[ $wpvar ];
855
-								$query['name']      = $query[ $wpvar ];
856
-							}
857
-						}
858
-					}
859
-
860
-					// Do the query.
861
-					if ( ! empty( $query['pagename'] ) ) {
862
-						$args = array(
863
-							'name'      => $query['pagename'],
864
-							'post_type' => 'page',
865
-							'showposts' => 1,
866
-						);
867
-
868
-						if ( isset( $post ) && get_posts( $args ) === $post ) {
869
-							return $post[0]->ID;
870
-						}
871
-					}
872
-
873
-					$query = new WP_Query( $query );
874
-
875
-					if ( ! empty( $query->posts ) && $query->is_singular ) {
876
-						return $query->post->ID;
877
-					} else {
878
-
879
-						// WooCommerce override.
880
-						if ( isset( $query->query['post_type'] ) && 'product' === $query->query['post_type'] && class_exists( 'WooCommerce' ) ) {
881
-							return get_option( 'woocommerce_shop_page_id' );
882
-						}
883
-					}
884
-
885
-					if ( ( empty( $query->page ) ) && ( empty( $query->pagename ) ) ) {
886
-						return 0;
887
-					}
888
-				}
889
-			}
890
-
891
-			return 0;
892
-		}
893
-
894
-		/**
895
-		 * Get default values.
896
-		 */
897
-		public function default_values() {
898
-			if ( ! empty( $this->boxes ) && empty( $this->options_defaults ) ) {
899
-				foreach ( $this->boxes as $key => $box ) {
900
-					if ( empty( $box['sections'] ) ) {
901
-						continue;
902
-					}
903
-
904
-					// fill the cache.
905
-					foreach ( $box['sections'] as $sk => $section ) {
906
-						if ( ! isset( $section['id'] ) ) {
907
-							if ( ! is_numeric( $sk ) || ! isset( $section['title'] ) ) {
908
-								$section['id'] = $sk;
909
-							} else {
910
-								$section['id'] = sanitize_text_field( $section['title'] );
911
-							}
912
-							$this->boxes[ $key ]['sections'][ $sk ] = $section;
913
-						}
914
-						if ( isset( $section['fields'] ) ) {
915
-							foreach ( $section['fields'] as $k => $field ) {
916
-
917
-								if ( empty( $field['id'] ) && empty( $field['type'] ) ) {
918
-									continue;
919
-								}
920
-
921
-								if ( 'ace_editor' === $field['type'] && isset( $field['options'] ) ) {
922
-									$this->boxes[ $key ]['sections'][ $sk ]['fields'][ $k ]['args'] = $field['options'];
923
-									unset( $this->boxes[ $key ]['sections'][ $sk ]['fields'][ $k ]['options'] );
924
-								}
925
-
926
-								if ( 'section' === $field['type'] && isset( $field['indent'] ) && ( true === $field['indent'] || 'true' === $field['indent'] ) ) {
927
-									$field['class']  = $field['class'] ?? '';
928
-									$field['class'] .= 'redux-section-indent-start';
929
-
930
-									$this->boxes[ $key ]['sections'][ $sk ]['fields'][ $k ] = $field;
931
-								}
932
-
933
-								if ( ! isset( $this->parent->options_defaults_class ) ) {
934
-									$this->parent->options_defaults_class = new Redux_Options_Defaults();
935
-								}
936
-
937
-								$this->parent->options_defaults_class->field_default_values( $this->parent->args['opt_name'], $field );
938
-
939
-								if ( 'repeater' === $field['type'] ) {
940
-									foreach ( $field['fields'] as $f ) {
941
-										$this->parent->options_defaults_class->field_default_values( $this->parent->args['opt_name'], $f, null, true );
942
-									}
943
-								}
944
-
945
-								$this->parent->options_defaults = $this->parent->options_defaults_class->options_defaults;
946
-							}
947
-						}
948
-					}
949
-				}
950
-			}
951
-
952
-			if ( empty( $this->meta[ $this->post_id ] ) ) {
953
-				$this->meta[ $this->post_id ] = $this->get_meta( $this->post_id );
954
-			}
955
-		}
956
-
957
-		/**
958
-		 * Add Meta Boxes
959
-		 */
960
-		public function add() {
961
-			if ( empty( $this->boxes ) || ! is_array( $this->boxes ) ) {
962
-				return;
963
-			}
964
-
965
-			foreach ( $this->boxes as $key => $box ) {
966
-				if ( empty( $box['sections'] ) ) {
967
-					continue;
968
-				}
969
-
970
-				// Save users from themselves.
971
-				if ( isset( $box['position'] ) && ! in_array( strtolower( $box['position'] ), array( 'normal', 'advanced', 'side' ), true ) ) {
972
-					unset( $box['position'] );
973
-				}
974
-
975
-				if ( isset( $box['priority'] ) && ! in_array( strtolower( $box['priority'] ), array( 'high', 'core', 'default', 'low' ), true ) ) {
976
-					unset( $box['priority'] );
977
-				}
978
-
979
-				$defaults = array(
980
-					'id'         => $key . '-' . $this->parent->args['opt_name'],
981
-					'post_types' => array( 'page', 'post' ),
982
-					'position'   => 'normal',
983
-					'priority'   => 'high',
984
-				);
985
-
986
-				$box = wp_parse_args( $box, $defaults );
987
-				if ( ! empty( $box['post_types'] ) ) {
988
-					foreach ( $box['post_types'] as $posttype ) {
989
-						if ( isset( $box['title'] ) ) {
990
-							$title = $box['title'];
991
-						} elseif ( isset( $box['sections'] ) && 1 === count( $box['sections'] ) && isset( $box['sections'][0]['fields'] ) && 1 === count( $box['sections'][0]['fields'] ) && isset( $box['sections'][0]['fields'][0]['title'] ) ) {
992
-
993
-								// If only one field in this box.
994
-								$title = $box['sections'][0]['fields'][0]['title'];
995
-						} else {
996
-							$title = ucfirst( $posttype ) . ' ' . __( 'Options', 'redux-framework' );
997
-						}
998
-
999
-						$args = array(
1000
-							'position' => $box['position'],
1001
-							'sections' => $box['sections'],
1002
-							'key'      => $key,
1003
-						);
1004
-
1005
-						// Override the parent args on a metabox level.
1006
-						if ( empty( $this->orig_args ) ) {
1007
-							$this->orig_args = $this->parent->args;
1008
-						}
1009
-
1010
-						if ( isset( $box['args'] ) ) {
1011
-							$this->parent->args = wp_parse_args( $box['args'], $this->orig_args );
1012
-						} elseif ( $this->parent->args !== $this->orig_args ) {
1013
-							$this->parent->args = $this->orig_args;
1014
-						}
1015
-
1016
-						add_filter( 'postbox_classes_' . $posttype . '_redux-' . $this->parent->args['opt_name'] . '-metabox-' . $box['id'], array( $this, 'add_box_classes' ) );
1017
-
1018
-						// phpcs:ignore WordPress.NamingConventions.ValidHookName
1019
-						do_action( 'redux/' . $this->parent->args['opt_name'] . '/extensions/metabox/add', $this, $box, $posttype );
1020
-
1021
-						if ( isset( $box['post_format'] ) ) {
1022
-							add_filter( 'postbox_classes_' . $posttype . '_redux-' . $this->parent->args['opt_name'] . '-metabox-' . $box['id'], array( $this, 'add_box_hide_class' ) );
1023
-						}
1024
-
1025
-						// phpcs:ignore Generic.Strings.UnnecessaryStringConcat
1026
-						call_user_func( 'add' . '_meta' . '_box', 'redux-' . $this->parent->args['opt_name'] . '-metabox-' . $box['id'], $title, array( $this, 'generate_boxes' ), $posttype, $box['position'], $box['priority'], $args );
1027
-					}
1028
-				}
1029
-			}
1030
-		}
1031
-
1032
-		/**
1033
-		 * Add hidden class to metabox DIV.
1034
-		 *
1035
-		 * @param array $classes Class array.
1036
-		 *
1037
-		 * @return array
1038
-		 */
1039
-		public function add_box_hide_class( array $classes ): array {
1040
-			$classes[] = 'hide';
1041
-
1042
-			return $classes;
1043
-		}
1044
-
1045
-		/**
1046
-		 * Field Defaults.
1047
-		 *
1048
-		 * @param mixed $field_id ID.
1049
-		 *
1050
-		 * @return mixed|string
1051
-		 */
1052
-		private function field_default( $field_id ) {
1053
-			if ( ! isset( $this->parent->options_defaults ) ) {
1054
-				$this->parent->options_defaults = $this->parent->default_values();
1055
-			}
1056
-
1057
-			if ( ! isset( $this->parent->options ) || empty( $this->parent->options ) ) {
1058
-				if ( ! isset( $this->parent->options_class ) ) {
1059
-					$this->parent->options_class = new Redux_Options_Constructor( $this->parent );
1060
-				}
1061
-
1062
-				$this->parent->options_class->get();
1063
-			}
1064
-
1065
-			$this->options = $this->parent->options;
1066
-
1067
-			if ( isset( $this->parent->options[ $field_id['id'] ] ) && isset( $this->parent->options_defaults[ $field_id['id'] ] ) && $this->parent->options[ $field_id['id'] ] !== $this->parent->options_defaults[ $field_id['id'] ] ) {
1068
-				return $this->parent->options[ $field_id['id'] ];
1069
-			} else {
1070
-				if ( empty( $this->options_defaults ) ) {
1071
-					$this->default_values(); // fill cache.
1072
-				}
1073
-
1074
-				$data = '';
1075
-				if ( ! empty( $this->options_defaults ) ) {
1076
-					$data = $this->options_defaults[ $field_id['id'] ] ?? '';
1077
-				}
1078
-
1079
-				if ( empty( $data ) && isset( $this->parent->options_defaults[ $field_id['id'] ] ) ) {
1080
-					$data = $this->parent->options_defaults[ $field_id['id'] ] ?? '';
1081
-				}
1082
-
1083
-				return $data;
1084
-			}
1085
-		}
1086
-
1087
-		/**
1088
-		 * Function to get and cache the post meta.
1089
-		 *
1090
-		 * @param mixed $id ID.
1091
-		 *
1092
-		 * @return array
1093
-		 */
1094
-		private function get_meta( $id ): array {
1095
-			if ( ! isset( $this->meta[ $id ] ) ) {
1096
-				$this->meta[ $id ] = array();
1097
-				$o_data            = get_post_meta( $id );
1098
-
1099
-				// phpcs:ignore WordPress.NamingConventions.ValidHookName
1100
-				$o_data = apply_filters( "redux/metaboxes/{$this->parent->args['opt_name']}/get_meta", $o_data );
1101
-
1102
-				if ( ! empty( $o_data ) ) {
1103
-					foreach ( $o_data as $key => $value ) {
1104
-						if ( 1 === count( $value ) ) {
1105
-							$this->meta[ $id ][ $key ] = maybe_unserialize( $value[0] );
1106
-						} else {
1107
-							$new_value = array_map( 'maybe_unserialize', $value );
1108
-
1109
-							$this->meta[ $id ][ $key ] = $new_value[0];
1110
-						}
1111
-					}
1112
-				}
1113
-
1114
-				if ( isset( $this->meta[ $id ][ $this->parent->args['opt_name'] ] ) ) {
1115
-					$data = maybe_unserialize( $this->meta[ $id ][ $this->parent->args['opt_name'] ] );
1116
-
1117
-					foreach ( $data as $key => $value ) {
1118
-						$this->meta[ $id ][ $key ] = $value;
1119
-						update_post_meta( $id, $key, $value );
1120
-					}
1121
-
1122
-					unset( $this->meta[ $id ][ $this->parent->args['opt_name'] ] );
1123
-
1124
-					delete_post_meta( $id, $this->parent->args['opt_name'] );
1125
-				}
1126
-			}
1127
-
1128
-			return $this->meta[ $id ];
1129
-		}
1130
-
1131
-		/**
1132
-		 * Get values.
1133
-		 *
1134
-		 * @param mixed  $the_post Post object/id.
1135
-		 * @param string $meta_key Meta key.
1136
-		 * @param mixed  $def_val  Def value.
1137
-		 *
1138
-		 * @return array|mixed|string
1139
-		 */
1140
-		public function get_values( $the_post, string $meta_key = '', $def_val = '' ) {
1141
-
1142
-			// Override these values if they differ from the admin panel defaults.  ;) .
1143
-			if ( isset( $the_post->post_type ) && in_array( $the_post->post_type, $this->post_types, true ) ) {
1144
-				if ( isset( $this->post_type_values[ $the_post->post_type ] ) ) {
1145
-					$meta = $this->post_type_fields[ $the_post->post_type ];
1146
-				} else {
1147
-					$defaults = array();
1148
-					if ( ! empty( $this->post_type_fields[ $the_post->post_type ] ) ) {
1149
-						foreach ( $this->post_type_fields[ $the_post->post_type ] as $key => $null ) {
1150
-							if ( isset( $this->options_defaults[ $key ] ) ) {
1151
-								$defaults[ $key ] = $this->options_defaults[ $key ];
1152
-							}
1153
-						}
1154
-					}
1155
-
1156
-					$meta = wp_parse_args( $this->get_meta( $the_post->ID ), $defaults );
1157
-
1158
-					$this->post_type_fields[ $the_post->post_type ] = $meta;
1159
-				}
1160
-
1161
-				if ( ! empty( $meta_key ) ) {
1162
-					if ( ! isset( $meta[ $meta_key ] ) ) {
1163
-						$meta[ $meta_key ] = $def_val;
1164
-					}
1165
-
1166
-					return $meta[ $meta_key ];
1167
-				} else {
1168
-					return $meta;
1169
-				}
1170
-			}
1171
-
1172
-			return $def_val;
1173
-		}
1174
-
1175
-		/**
1176
-		 * Generate Boxes.
1177
-		 *
1178
-		 * @param mixed $post Post.
1179
-		 * @param array $metabox Metabox array.
1180
-		 */
1181
-		public function generate_boxes( $post, array $metabox ) {
1182
-			if ( ! empty( $metabox['args']['permissions'] ) && ! Redux_Helpers::current_user_can( $metabox['args']['permissions'] ) ) {
1183
-				return;
1184
-			}
1185
-
1186
-			$sections = $metabox['args']['sections'];
1187
-
1188
-			wp_nonce_field( 'redux_metaboxes_meta_nonce', 'redux_metaboxes_meta_nonce' );
1189
-
1190
-			wp_dequeue_script( 'json-view-js' );
1191
-
1192
-			$sidebar = true;
1193
-
1194
-			if ( 'side' === $metabox['args']['position'] || 1 === count( $sections ) || ( isset( $metabox['args']['sidebar'] ) && false === $metabox['args']['sidebar'] ) ) {
1195
-				$sidebar = false; // Show the section dividers or not.
1196
-			}
1197
-
1198
-			?>
824
+                    // Taken from class-wp.php.
825
+                    foreach ( $GLOBALS['wp_post_types'] as $post_type => $t ) {
826
+                        if ( isset( $t->query_var ) ) {
827
+                            $post_type_query_vars[ $t->query_var ] = $post_type;
828
+                        }
829
+                    }
830
+
831
+                    foreach ( $wp->public_query_vars as $wpvar ) {
832
+                        if ( isset( $wp->extra_query_vars[ $wpvar ] ) ) {
833
+                            $query[ $wpvar ] = $wp->extra_query_vars[ $wpvar ];
834
+                        } elseif ( isset( $_POST[ $wpvar ] ) ) { // phpcs:ignore WordPress.Security.NonceVerification
835
+                            $query[ $wpvar ] = sanitize_text_field( wp_unslash( $_POST[ $wpvar ] ) ); // phpcs:ignore WordPress.Security.NonceVerification
836
+                        } elseif ( isset( $_GET[ $wpvar ] ) ) { // phpcs:ignore WordPress.Security.NonceVerification
837
+                            $query[ $wpvar ] = sanitize_text_field( wp_unslash( $_GET[ $wpvar ] ) ); // phpcs:ignore WordPress.Security.NonceVerification
838
+                        } elseif ( isset( $query_vars[ $wpvar ] ) ) {
839
+                            $query[ $wpvar ] = $query_vars[ $wpvar ];
840
+                        }
841
+
842
+                        if ( ! empty( $query[ $wpvar ] ) ) {
843
+                            if ( ! is_array( $query[ $wpvar ] ) ) {
844
+                                $query[ $wpvar ] = (string) $query[ $wpvar ];
845
+                            } else {
846
+                                foreach ( $query[ $wpvar ] as $vkey => $v ) {
847
+                                    if ( ! is_object( $v ) ) {
848
+                                        $query[ $wpvar ][ $vkey ] = (string) $v;
849
+                                    }
850
+                                }
851
+                            }
852
+
853
+                            if ( isset( $post_type_query_vars[ $wpvar ] ) ) {
854
+                                $query['post_type'] = $post_type_query_vars[ $wpvar ];
855
+                                $query['name']      = $query[ $wpvar ];
856
+                            }
857
+                        }
858
+                    }
859
+
860
+                    // Do the query.
861
+                    if ( ! empty( $query['pagename'] ) ) {
862
+                        $args = array(
863
+                            'name'      => $query['pagename'],
864
+                            'post_type' => 'page',
865
+                            'showposts' => 1,
866
+                        );
867
+
868
+                        if ( isset( $post ) && get_posts( $args ) === $post ) {
869
+                            return $post[0]->ID;
870
+                        }
871
+                    }
872
+
873
+                    $query = new WP_Query( $query );
874
+
875
+                    if ( ! empty( $query->posts ) && $query->is_singular ) {
876
+                        return $query->post->ID;
877
+                    } else {
878
+
879
+                        // WooCommerce override.
880
+                        if ( isset( $query->query['post_type'] ) && 'product' === $query->query['post_type'] && class_exists( 'WooCommerce' ) ) {
881
+                            return get_option( 'woocommerce_shop_page_id' );
882
+                        }
883
+                    }
884
+
885
+                    if ( ( empty( $query->page ) ) && ( empty( $query->pagename ) ) ) {
886
+                        return 0;
887
+                    }
888
+                }
889
+            }
890
+
891
+            return 0;
892
+        }
893
+
894
+        /**
895
+         * Get default values.
896
+         */
897
+        public function default_values() {
898
+            if ( ! empty( $this->boxes ) && empty( $this->options_defaults ) ) {
899
+                foreach ( $this->boxes as $key => $box ) {
900
+                    if ( empty( $box['sections'] ) ) {
901
+                        continue;
902
+                    }
903
+
904
+                    // fill the cache.
905
+                    foreach ( $box['sections'] as $sk => $section ) {
906
+                        if ( ! isset( $section['id'] ) ) {
907
+                            if ( ! is_numeric( $sk ) || ! isset( $section['title'] ) ) {
908
+                                $section['id'] = $sk;
909
+                            } else {
910
+                                $section['id'] = sanitize_text_field( $section['title'] );
911
+                            }
912
+                            $this->boxes[ $key ]['sections'][ $sk ] = $section;
913
+                        }
914
+                        if ( isset( $section['fields'] ) ) {
915
+                            foreach ( $section['fields'] as $k => $field ) {
916
+
917
+                                if ( empty( $field['id'] ) && empty( $field['type'] ) ) {
918
+                                    continue;
919
+                                }
920
+
921
+                                if ( 'ace_editor' === $field['type'] && isset( $field['options'] ) ) {
922
+                                    $this->boxes[ $key ]['sections'][ $sk ]['fields'][ $k ]['args'] = $field['options'];
923
+                                    unset( $this->boxes[ $key ]['sections'][ $sk ]['fields'][ $k ]['options'] );
924
+                                }
925
+
926
+                                if ( 'section' === $field['type'] && isset( $field['indent'] ) && ( true === $field['indent'] || 'true' === $field['indent'] ) ) {
927
+                                    $field['class']  = $field['class'] ?? '';
928
+                                    $field['class'] .= 'redux-section-indent-start';
929
+
930
+                                    $this->boxes[ $key ]['sections'][ $sk ]['fields'][ $k ] = $field;
931
+                                }
932
+
933
+                                if ( ! isset( $this->parent->options_defaults_class ) ) {
934
+                                    $this->parent->options_defaults_class = new Redux_Options_Defaults();
935
+                                }
936
+
937
+                                $this->parent->options_defaults_class->field_default_values( $this->parent->args['opt_name'], $field );
938
+
939
+                                if ( 'repeater' === $field['type'] ) {
940
+                                    foreach ( $field['fields'] as $f ) {
941
+                                        $this->parent->options_defaults_class->field_default_values( $this->parent->args['opt_name'], $f, null, true );
942
+                                    }
943
+                                }
944
+
945
+                                $this->parent->options_defaults = $this->parent->options_defaults_class->options_defaults;
946
+                            }
947
+                        }
948
+                    }
949
+                }
950
+            }
951
+
952
+            if ( empty( $this->meta[ $this->post_id ] ) ) {
953
+                $this->meta[ $this->post_id ] = $this->get_meta( $this->post_id );
954
+            }
955
+        }
956
+
957
+        /**
958
+         * Add Meta Boxes
959
+         */
960
+        public function add() {
961
+            if ( empty( $this->boxes ) || ! is_array( $this->boxes ) ) {
962
+                return;
963
+            }
964
+
965
+            foreach ( $this->boxes as $key => $box ) {
966
+                if ( empty( $box['sections'] ) ) {
967
+                    continue;
968
+                }
969
+
970
+                // Save users from themselves.
971
+                if ( isset( $box['position'] ) && ! in_array( strtolower( $box['position'] ), array( 'normal', 'advanced', 'side' ), true ) ) {
972
+                    unset( $box['position'] );
973
+                }
974
+
975
+                if ( isset( $box['priority'] ) && ! in_array( strtolower( $box['priority'] ), array( 'high', 'core', 'default', 'low' ), true ) ) {
976
+                    unset( $box['priority'] );
977
+                }
978
+
979
+                $defaults = array(
980
+                    'id'         => $key . '-' . $this->parent->args['opt_name'],
981
+                    'post_types' => array( 'page', 'post' ),
982
+                    'position'   => 'normal',
983
+                    'priority'   => 'high',
984
+                );
985
+
986
+                $box = wp_parse_args( $box, $defaults );
987
+                if ( ! empty( $box['post_types'] ) ) {
988
+                    foreach ( $box['post_types'] as $posttype ) {
989
+                        if ( isset( $box['title'] ) ) {
990
+                            $title = $box['title'];
991
+                        } elseif ( isset( $box['sections'] ) && 1 === count( $box['sections'] ) && isset( $box['sections'][0]['fields'] ) && 1 === count( $box['sections'][0]['fields'] ) && isset( $box['sections'][0]['fields'][0]['title'] ) ) {
992
+
993
+                                // If only one field in this box.
994
+                                $title = $box['sections'][0]['fields'][0]['title'];
995
+                        } else {
996
+                            $title = ucfirst( $posttype ) . ' ' . __( 'Options', 'redux-framework' );
997
+                        }
998
+
999
+                        $args = array(
1000
+                            'position' => $box['position'],
1001
+                            'sections' => $box['sections'],
1002
+                            'key'      => $key,
1003
+                        );
1004
+
1005
+                        // Override the parent args on a metabox level.
1006
+                        if ( empty( $this->orig_args ) ) {
1007
+                            $this->orig_args = $this->parent->args;
1008
+                        }
1009
+
1010
+                        if ( isset( $box['args'] ) ) {
1011
+                            $this->parent->args = wp_parse_args( $box['args'], $this->orig_args );
1012
+                        } elseif ( $this->parent->args !== $this->orig_args ) {
1013
+                            $this->parent->args = $this->orig_args;
1014
+                        }
1015
+
1016
+                        add_filter( 'postbox_classes_' . $posttype . '_redux-' . $this->parent->args['opt_name'] . '-metabox-' . $box['id'], array( $this, 'add_box_classes' ) );
1017
+
1018
+                        // phpcs:ignore WordPress.NamingConventions.ValidHookName
1019
+                        do_action( 'redux/' . $this->parent->args['opt_name'] . '/extensions/metabox/add', $this, $box, $posttype );
1020
+
1021
+                        if ( isset( $box['post_format'] ) ) {
1022
+                            add_filter( 'postbox_classes_' . $posttype . '_redux-' . $this->parent->args['opt_name'] . '-metabox-' . $box['id'], array( $this, 'add_box_hide_class' ) );
1023
+                        }
1024
+
1025
+                        // phpcs:ignore Generic.Strings.UnnecessaryStringConcat
1026
+                        call_user_func( 'add' . '_meta' . '_box', 'redux-' . $this->parent->args['opt_name'] . '-metabox-' . $box['id'], $title, array( $this, 'generate_boxes' ), $posttype, $box['position'], $box['priority'], $args );
1027
+                    }
1028
+                }
1029
+            }
1030
+        }
1031
+
1032
+        /**
1033
+         * Add hidden class to metabox DIV.
1034
+         *
1035
+         * @param array $classes Class array.
1036
+         *
1037
+         * @return array
1038
+         */
1039
+        public function add_box_hide_class( array $classes ): array {
1040
+            $classes[] = 'hide';
1041
+
1042
+            return $classes;
1043
+        }
1044
+
1045
+        /**
1046
+         * Field Defaults.
1047
+         *
1048
+         * @param mixed $field_id ID.
1049
+         *
1050
+         * @return mixed|string
1051
+         */
1052
+        private function field_default( $field_id ) {
1053
+            if ( ! isset( $this->parent->options_defaults ) ) {
1054
+                $this->parent->options_defaults = $this->parent->default_values();
1055
+            }
1056
+
1057
+            if ( ! isset( $this->parent->options ) || empty( $this->parent->options ) ) {
1058
+                if ( ! isset( $this->parent->options_class ) ) {
1059
+                    $this->parent->options_class = new Redux_Options_Constructor( $this->parent );
1060
+                }
1061
+
1062
+                $this->parent->options_class->get();
1063
+            }
1064
+
1065
+            $this->options = $this->parent->options;
1066
+
1067
+            if ( isset( $this->parent->options[ $field_id['id'] ] ) && isset( $this->parent->options_defaults[ $field_id['id'] ] ) && $this->parent->options[ $field_id['id'] ] !== $this->parent->options_defaults[ $field_id['id'] ] ) {
1068
+                return $this->parent->options[ $field_id['id'] ];
1069
+            } else {
1070
+                if ( empty( $this->options_defaults ) ) {
1071
+                    $this->default_values(); // fill cache.
1072
+                }
1073
+
1074
+                $data = '';
1075
+                if ( ! empty( $this->options_defaults ) ) {
1076
+                    $data = $this->options_defaults[ $field_id['id'] ] ?? '';
1077
+                }
1078
+
1079
+                if ( empty( $data ) && isset( $this->parent->options_defaults[ $field_id['id'] ] ) ) {
1080
+                    $data = $this->parent->options_defaults[ $field_id['id'] ] ?? '';
1081
+                }
1082
+
1083
+                return $data;
1084
+            }
1085
+        }
1086
+
1087
+        /**
1088
+         * Function to get and cache the post meta.
1089
+         *
1090
+         * @param mixed $id ID.
1091
+         *
1092
+         * @return array
1093
+         */
1094
+        private function get_meta( $id ): array {
1095
+            if ( ! isset( $this->meta[ $id ] ) ) {
1096
+                $this->meta[ $id ] = array();
1097
+                $o_data            = get_post_meta( $id );
1098
+
1099
+                // phpcs:ignore WordPress.NamingConventions.ValidHookName
1100
+                $o_data = apply_filters( "redux/metaboxes/{$this->parent->args['opt_name']}/get_meta", $o_data );
1101
+
1102
+                if ( ! empty( $o_data ) ) {
1103
+                    foreach ( $o_data as $key => $value ) {
1104
+                        if ( 1 === count( $value ) ) {
1105
+                            $this->meta[ $id ][ $key ] = maybe_unserialize( $value[0] );
1106
+                        } else {
1107
+                            $new_value = array_map( 'maybe_unserialize', $value );
1108
+
1109
+                            $this->meta[ $id ][ $key ] = $new_value[0];
1110
+                        }
1111
+                    }
1112
+                }
1113
+
1114
+                if ( isset( $this->meta[ $id ][ $this->parent->args['opt_name'] ] ) ) {
1115
+                    $data = maybe_unserialize( $this->meta[ $id ][ $this->parent->args['opt_name'] ] );
1116
+
1117
+                    foreach ( $data as $key => $value ) {
1118
+                        $this->meta[ $id ][ $key ] = $value;
1119
+                        update_post_meta( $id, $key, $value );
1120
+                    }
1121
+
1122
+                    unset( $this->meta[ $id ][ $this->parent->args['opt_name'] ] );
1123
+
1124
+                    delete_post_meta( $id, $this->parent->args['opt_name'] );
1125
+                }
1126
+            }
1127
+
1128
+            return $this->meta[ $id ];
1129
+        }
1130
+
1131
+        /**
1132
+         * Get values.
1133
+         *
1134
+         * @param mixed  $the_post Post object/id.
1135
+         * @param string $meta_key Meta key.
1136
+         * @param mixed  $def_val  Def value.
1137
+         *
1138
+         * @return array|mixed|string
1139
+         */
1140
+        public function get_values( $the_post, string $meta_key = '', $def_val = '' ) {
1141
+
1142
+            // Override these values if they differ from the admin panel defaults.  ;) .
1143
+            if ( isset( $the_post->post_type ) && in_array( $the_post->post_type, $this->post_types, true ) ) {
1144
+                if ( isset( $this->post_type_values[ $the_post->post_type ] ) ) {
1145
+                    $meta = $this->post_type_fields[ $the_post->post_type ];
1146
+                } else {
1147
+                    $defaults = array();
1148
+                    if ( ! empty( $this->post_type_fields[ $the_post->post_type ] ) ) {
1149
+                        foreach ( $this->post_type_fields[ $the_post->post_type ] as $key => $null ) {
1150
+                            if ( isset( $this->options_defaults[ $key ] ) ) {
1151
+                                $defaults[ $key ] = $this->options_defaults[ $key ];
1152
+                            }
1153
+                        }
1154
+                    }
1155
+
1156
+                    $meta = wp_parse_args( $this->get_meta( $the_post->ID ), $defaults );
1157
+
1158
+                    $this->post_type_fields[ $the_post->post_type ] = $meta;
1159
+                }
1160
+
1161
+                if ( ! empty( $meta_key ) ) {
1162
+                    if ( ! isset( $meta[ $meta_key ] ) ) {
1163
+                        $meta[ $meta_key ] = $def_val;
1164
+                    }
1165
+
1166
+                    return $meta[ $meta_key ];
1167
+                } else {
1168
+                    return $meta;
1169
+                }
1170
+            }
1171
+
1172
+            return $def_val;
1173
+        }
1174
+
1175
+        /**
1176
+         * Generate Boxes.
1177
+         *
1178
+         * @param mixed $post Post.
1179
+         * @param array $metabox Metabox array.
1180
+         */
1181
+        public function generate_boxes( $post, array $metabox ) {
1182
+            if ( ! empty( $metabox['args']['permissions'] ) && ! Redux_Helpers::current_user_can( $metabox['args']['permissions'] ) ) {
1183
+                return;
1184
+            }
1185
+
1186
+            $sections = $metabox['args']['sections'];
1187
+
1188
+            wp_nonce_field( 'redux_metaboxes_meta_nonce', 'redux_metaboxes_meta_nonce' );
1189
+
1190
+            wp_dequeue_script( 'json-view-js' );
1191
+
1192
+            $sidebar = true;
1193
+
1194
+            if ( 'side' === $metabox['args']['position'] || 1 === count( $sections ) || ( isset( $metabox['args']['sidebar'] ) && false === $metabox['args']['sidebar'] ) ) {
1195
+                $sidebar = false; // Show the section dividers or not.
1196
+            }
1197
+
1198
+            ?>
1199 1199
 			<input
1200 1200
 					type="hidden"
1201 1201
 					id="currentSection"
@@ -1225,21 +1225,21 @@  discard block
 block discarded – undo
1225 1225
 					</div>
1226 1226
 				</div>
1227 1227
 				<?php
1228
-				echo '<a href="javascript:void(0);" class="expand_options hide" style="display:none;">' . esc_html__( 'Expand', 'redux-framework' ) . '</a>';
1229
-				if ( $sidebar ) {
1230
-					?>
1228
+                echo '<a href="javascript:void(0);" class="expand_options hide" style="display:none;">' . esc_html__( 'Expand', 'redux-framework' ) . '</a>';
1229
+                if ( $sidebar ) {
1230
+                    ?>
1231 1231
 					<div class="redux-sidebar">
1232 1232
 						<ul class="redux-group-menu">
1233 1233
 							<?php
1234 1234
 
1235
-							foreach ( $sections as $s_key => $section ) {
1236
-								if ( ! empty( $section['permissions'] ) && ! Redux_Helpers::current_user_can( $section['permissions'] ) ) {
1237
-									continue;
1238
-								}
1235
+                            foreach ( $sections as $s_key => $section ) {
1236
+                                if ( ! empty( $section['permissions'] ) && ! Redux_Helpers::current_user_can( $section['permissions'] ) ) {
1237
+                                    continue;
1238
+                                }
1239 1239
 
1240
-								echo $this->parent->render_class->section_menu( $s_key, $section, '_box_' . $metabox['id'], $sections ); // phpcs:ignore WordPress.Security.EscapeOutput
1241
-							}
1242
-							?>
1240
+                                echo $this->parent->render_class->section_menu( $s_key, $section, '_box_' . $metabox['id'], $sections ); // phpcs:ignore WordPress.Security.EscapeOutput
1241
+                            }
1242
+                            ?>
1243 1243
 						</ul>
1244 1244
 					</div>
1245 1245
 				<?php } ?>
@@ -1247,295 +1247,295 @@  discard block
 block discarded – undo
1247 1247
 				<div class="redux-main">
1248 1248
 					<?php
1249 1249
 
1250
-					foreach ( $sections as $s_key => $section ) {
1251
-						if ( ! empty( $section['permissions'] ) && ! Redux_Helpers::current_user_can( $section['permissions'] ) ) {
1252
-							continue;
1253
-						}
1254
-						if ( ! empty( $section['fields'] ) ) {
1255
-							if ( isset( $section['args'] ) ) {
1256
-								$this->parent->args = wp_parse_args( $section['args'], $this->orig_args );
1257
-							} elseif ( $this->parent->args !== $this->orig_args ) {
1258
-								$this->parent->args = $this->orig_args;
1259
-							}
1260
-
1261
-							$hide             = $sidebar ? '' : ' display-group';
1262
-							$section['class'] = isset( $section['class'] ) ? ' ' . $section['class'] : '';
1263
-							echo '<div id="' . esc_attr( $s_key ) . '_box_' . esc_attr( $metabox['id'] ) . '_section_group" class="redux-group-tab' . esc_attr( $section['class'] ) . ' redux_metabox_panel' . esc_attr( $hide ) . '">';
1264
-
1265
-							if ( ! empty( $section['title'] ) ) {
1266
-								echo '<h3 class="redux-section-title">' . wp_kses_post( $section['title'] ) . '</h3>';
1267
-							}
1268
-
1269
-							if ( ! empty( $section['desc'] ) ) {
1270
-								echo '<div class="redux-section-desc">' . wp_kses_post( $section['desc'] ) . '</div>';
1271
-							}
1272
-
1273
-							echo '<table class="form-table"><tbody>';
1274
-							foreach ( $section['fields'] as $field ) {
1275
-								if ( ! empty( $field['permissions'] ) && ! Redux_Helpers::current_user_can( $field['permissions'] ) ) {
1276
-									continue;
1277
-								}
1278
-								$field['name'] = $this->parent->args['opt_name'] . '[' . $field['id'] . ']';
1279
-
1280
-								$is_hidden = false;
1281
-								$ex_style  = '';
1282
-								if ( isset( $field['hidden'] ) && $field['hidden'] ) {
1283
-									$is_hidden = true;
1284
-									$ex_style  = ' style="border-bottom: none;"';
1285
-								}
1286
-
1287
-								echo '<tr valign="top"' . $ex_style . '>'; // phpcs:ignore WordPress.Security.EscapeOutput
1288
-
1289
-								$th = $this->parent->render_class->get_header_html( $field );
1290
-
1291
-								if ( $is_hidden ) {
1292
-									$str_pos = strpos( $th, 'redux_field_th' );
1293
-
1294
-									if ( $str_pos > - 1 ) {
1295
-										$th = str_replace( 'redux_field_th', 'redux_field_th hide', $th );
1296
-									}
1297
-								}
1298
-
1299
-								if ( $sidebar ) {
1300
-									if ( ! ( isset( $metabox['args']['sections'] ) && 1 === count( $metabox['args']['sections'] ) && isset( $metabox['args']['sections'][0]['fields'] ) && 1 === count( $metabox['args']['sections'][0]['fields'] ) ) && isset( $field['title'] ) ) {
1301
-										echo '<th scope="row">';
1302
-										if ( ! empty( $th ) ) {
1303
-											echo $th; // phpcs:ignore WordPress.Security.EscapeOutput
1304
-										}
1305
-										echo '</th>';
1306
-										echo '<td>';
1307
-									}
1308
-								} else {
1309
-									echo '<td>' . $th; // phpcs:ignore WordPress.Security.EscapeOutput
1310
-								}
1311
-
1312
-								if ( 'section' === $field['type'] && ( 'true' === $field['indent'] || true === $field['indent'] ) ) {
1313
-									$field['class']  = $field['class'] ?? '';
1314
-									$field['class'] .= 'redux-section-indent-start';
1315
-								}
1316
-
1317
-								if ( ! isset( $this->meta[ $this->post_id ][ $field['id'] ] ) ) {
1318
-									$this->meta[ $this->post_id ][ $field['id'] ] = '';
1319
-								}
1320
-
1321
-								$this->parent->render_class->field_input( $field, $this->meta[ $this->post_id ][ $field['id'] ], true );
1322
-								echo '</td></tr>';
1323
-							}
1324
-							echo '</tbody></table>';
1325
-							echo '</div>';
1326
-						}
1327
-					}
1328
-					?>
1250
+                    foreach ( $sections as $s_key => $section ) {
1251
+                        if ( ! empty( $section['permissions'] ) && ! Redux_Helpers::current_user_can( $section['permissions'] ) ) {
1252
+                            continue;
1253
+                        }
1254
+                        if ( ! empty( $section['fields'] ) ) {
1255
+                            if ( isset( $section['args'] ) ) {
1256
+                                $this->parent->args = wp_parse_args( $section['args'], $this->orig_args );
1257
+                            } elseif ( $this->parent->args !== $this->orig_args ) {
1258
+                                $this->parent->args = $this->orig_args;
1259
+                            }
1260
+
1261
+                            $hide             = $sidebar ? '' : ' display-group';
1262
+                            $section['class'] = isset( $section['class'] ) ? ' ' . $section['class'] : '';
1263
+                            echo '<div id="' . esc_attr( $s_key ) . '_box_' . esc_attr( $metabox['id'] ) . '_section_group" class="redux-group-tab' . esc_attr( $section['class'] ) . ' redux_metabox_panel' . esc_attr( $hide ) . '">';
1264
+
1265
+                            if ( ! empty( $section['title'] ) ) {
1266
+                                echo '<h3 class="redux-section-title">' . wp_kses_post( $section['title'] ) . '</h3>';
1267
+                            }
1268
+
1269
+                            if ( ! empty( $section['desc'] ) ) {
1270
+                                echo '<div class="redux-section-desc">' . wp_kses_post( $section['desc'] ) . '</div>';
1271
+                            }
1272
+
1273
+                            echo '<table class="form-table"><tbody>';
1274
+                            foreach ( $section['fields'] as $field ) {
1275
+                                if ( ! empty( $field['permissions'] ) && ! Redux_Helpers::current_user_can( $field['permissions'] ) ) {
1276
+                                    continue;
1277
+                                }
1278
+                                $field['name'] = $this->parent->args['opt_name'] . '[' . $field['id'] . ']';
1279
+
1280
+                                $is_hidden = false;
1281
+                                $ex_style  = '';
1282
+                                if ( isset( $field['hidden'] ) && $field['hidden'] ) {
1283
+                                    $is_hidden = true;
1284
+                                    $ex_style  = ' style="border-bottom: none;"';
1285
+                                }
1286
+
1287
+                                echo '<tr valign="top"' . $ex_style . '>'; // phpcs:ignore WordPress.Security.EscapeOutput
1288
+
1289
+                                $th = $this->parent->render_class->get_header_html( $field );
1290
+
1291
+                                if ( $is_hidden ) {
1292
+                                    $str_pos = strpos( $th, 'redux_field_th' );
1293
+
1294
+                                    if ( $str_pos > - 1 ) {
1295
+                                        $th = str_replace( 'redux_field_th', 'redux_field_th hide', $th );
1296
+                                    }
1297
+                                }
1298
+
1299
+                                if ( $sidebar ) {
1300
+                                    if ( ! ( isset( $metabox['args']['sections'] ) && 1 === count( $metabox['args']['sections'] ) && isset( $metabox['args']['sections'][0]['fields'] ) && 1 === count( $metabox['args']['sections'][0]['fields'] ) ) && isset( $field['title'] ) ) {
1301
+                                        echo '<th scope="row">';
1302
+                                        if ( ! empty( $th ) ) {
1303
+                                            echo $th; // phpcs:ignore WordPress.Security.EscapeOutput
1304
+                                        }
1305
+                                        echo '</th>';
1306
+                                        echo '<td>';
1307
+                                    }
1308
+                                } else {
1309
+                                    echo '<td>' . $th; // phpcs:ignore WordPress.Security.EscapeOutput
1310
+                                }
1311
+
1312
+                                if ( 'section' === $field['type'] && ( 'true' === $field['indent'] || true === $field['indent'] ) ) {
1313
+                                    $field['class']  = $field['class'] ?? '';
1314
+                                    $field['class'] .= 'redux-section-indent-start';
1315
+                                }
1316
+
1317
+                                if ( ! isset( $this->meta[ $this->post_id ][ $field['id'] ] ) ) {
1318
+                                    $this->meta[ $this->post_id ][ $field['id'] ] = '';
1319
+                                }
1320
+
1321
+                                $this->parent->render_class->field_input( $field, $this->meta[ $this->post_id ][ $field['id'] ], true );
1322
+                                echo '</td></tr>';
1323
+                            }
1324
+                            echo '</tbody></table>';
1325
+                            echo '</div>';
1326
+                        }
1327
+                    }
1328
+                    ?>
1329 1329
 				</div>
1330 1330
 				<div class="clear"></div>
1331 1331
 			</div>
1332 1332
 			<?php
1333
-		}
1334
-
1335
-		/**
1336
-		 * Save meta boxes
1337
-		 * Runs when a post is saved and does an action which the write panel save scripts can hook into.
1338
-		 *
1339
-		 * @access public
1340
-		 *
1341
-		 * @param mixed $post_id Post ID.
1342
-		 * @param mixed $post Post.
1343
-		 *
1344
-		 * @return mixed
1345
-		 */
1346
-		public function meta_boxes_save( $post_id, $post ) {
1347
-			if ( isset( $_POST['vc_inline'] ) && sanitize_text_field( wp_unslash( $_POST['vc_inline'] ) ) ) { // phpcs:ignore WordPress.Security.NonceVerification
1348
-				return $post_id;
1349
-			}
1350
-
1351
-			if ( isset( $_POST['post_ID'] ) && strval( $post_id ) !== $_POST['post_ID'] ) { // phpcs:ignore WordPress.Security.NonceVerification
1352
-				return $post_id;
1353
-			}
1354
-
1355
-			// Check if our nonce is set.
1356
-			if ( ! isset( $_POST['redux_metaboxes_meta_nonce'] ) || ! isset( $_POST[ $this->parent->args['opt_name'] ] ) ) {
1357
-				return $post_id;
1358
-			}
1359
-
1360
-			// Verify that the nonce is valid.
1361
-			// Validate fields (if needed).
1362
-			if ( ! wp_verify_nonce( sanitize_key( wp_unslash( $_POST['redux_metaboxes_meta_nonce'] ) ), 'redux_metaboxes_meta_nonce' ) ) {
1363
-				return $post_id;
1364
-			}
1365
-
1366
-			// If this is an autosave, our form has not been submitted, so we don't want to do anything.
1367
-			if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) {
1368
-				return $post_id;
1369
-			}
1370
-
1371
-			// Check the user's permissions, even allowing custom capabilities.
1372
-			$obj = get_post_type_object( $post->post_type );
1373
-			if ( ! current_user_can( $obj->cap->edit_post, $post_id ) ) {
1374
-				return $post_id;
1375
-			}
1376
-
1377
-			// Import.
1378
-			if ( isset( $_POST[ $this->parent->args['opt_name'] ]['import_code'] ) && ! empty( $_POST[ $this->parent->args['opt_name'] ]['import_code'] ) ) {
1379
-				$import = json_decode( sanitize_text_field( wp_unslash( $_POST[ $this->parent->args['opt_name'] ]['import_code'] ) ), true );
1380
-				unset( $_POST[ $this->parent->args['opt_name'] ]['import_code'] );
1381
-
1382
-				foreach ( Redux_Helpers::sanitize_array( wp_unslash( $_POST[ $this->parent->args['opt_name'] ] ) ) as $key => $value ) { // phpcs:ignore WordPress.Security.ValidatedSanitizedInput
1383
-					if ( ! isset( $import[ $key ] ) ) {
1384
-						$import[ $key ] = $value;
1385
-					}
1386
-				}
1387
-
1388
-				$_POST[ $this->parent->args['opt_name'] ] = $import;
1389
-			}
1390
-
1391
-			$to_save    = array();
1392
-			$to_compare = array();
1393
-			$to_delete  = array();
1394
-			$dont_save  = true;
1395
-
1396
-			if ( isset( $this->parent->args['metaboxes_save_defaults'] ) && $this->parent->args['metaboxes_save_defaults'] ) {
1397
-				$dont_save = false;
1398
-			}
1399
-
1400
-			foreach ( Redux_Helpers::sanitize_array( wp_unslash( $_POST[ $this->parent->args['opt_name'] ] ) ) as $key => $value ) { // phpcs:ignore WordPress.Security.ValidatedSanitizedInput
1401
-
1402
-				// Have to remove the escaping for array comparison.
1403
-				if ( is_array( $value ) ) {
1404
-					foreach ( $value as $k => $v ) {
1405
-						if ( ! is_array( $v ) ) {
1406
-							$value[ $k ] = wp_unslash( $v );
1407
-						}
1408
-					}
1409
-				}
1410
-
1411
-				$save = true;
1412
-
1413
-				// parent_options.
1414
-				if ( ! $dont_save && isset( $this->options_defaults[ $key ] ) && $value === $this->options_defaults[ $key ] ) {
1415
-					$save = false;
1416
-				}
1417
-
1418
-				if ( $save && isset( $this->parent_options[ $key ] ) && $this->parent_options[ $key ] !== $value ) {
1419
-					$save = false;
1420
-				}
1421
-
1422
-				if ( $save ) {
1423
-					$to_save[ $key ]    = $value;
1424
-					$to_compare[ $key ] = $this->parent->options[ $key ] ?? '';
1425
-				} else {
1426
-					$to_delete[ $key ] = $value;
1427
-				}
1428
-			}
1429
-
1430
-			// phpcs:ignore WordPress.NamingConventions.ValidHookName
1431
-			$to_save = apply_filters( 'redux/metaboxes/save/before_validate', $to_save, $to_compare, $this->sections );
1432
-
1433
-			$validate = $this->parent->validate_class->validate( $to_save, $to_compare, $this->sections );
1434
-
1435
-			// Validate fields (if needed).
1436
-			foreach ( $to_save as $key => $value ) {
1437
-				if ( isset( $validate[ $key ] ) && $value !== $validate[ $key ] ) {
1438
-					if ( isset( $this->parent->options[ $key ] ) && $validate[ $key ] === $this->parent->options[ $key ] ) {
1439
-						unset( $to_save[ $key ] );
1440
-					} else {
1441
-						$to_save[ $key ] = $validate[ $key ];
1442
-					}
1443
-				}
1444
-			}
1445
-
1446
-			if ( ! empty( $this->parent->errors ) || ! empty( $this->parent->warnings ) ) {
1447
-				$this->parent->transients['notices'] = ( isset( $this->parent->transients['notices'] ) && is_array( $this->parent->transients['notices'] ) ) ? $this->parent->transients['notices'] : array();
1448
-
1449
-				if ( ! isset( $this->parent->transients['notices']['errors'] ) || $this->parent->transients['notices']['errors'] !== $this->parent->errors ) {
1450
-					$this->parent->transients['notices']['errors'] = $this->parent->errors;
1451
-					$update_transients                             = true;
1452
-				}
1453
-
1454
-				if ( ! isset( $this->parent->transients['notices']['warnings'] ) || $this->parent->transients['notices']['warnings'] !== $this->parent->warnings ) {
1455
-					$this->parent->transients['notices']['warnings'] = $this->parent->warnings;
1456
-					$update_transients                               = true;
1457
-				}
1458
-
1459
-				if ( isset( $update_transients ) ) {
1460
-					$this->parent->transients['notices']['override'] = 1;
1461
-					set_transient( $this->parent->args['opt_name'] . '-transients-metaboxes', $this->parent->transients );
1462
-				}
1463
-			}
1464
-
1465
-			if ( isset( $_POST['post_type'] ) ) {
1466
-				$check = $this->post_type_fields[ sanitize_text_field( wp_unslash( $_POST['post_type'] ) ) ];
1467
-			}
1468
-
1469
-			// phpcs:ignore WordPress.NamingConventions.ValidHookName
1470
-			$to_save = apply_filters( 'redux/metaboxes/save', $to_save, $to_compare, $this->sections );
1471
-
1472
-			foreach ( $to_save as $key => $value ) {
1473
-				$prev_value = $this->meta[ $post_id ][ $key ] ?? '';
1474
-
1475
-				if ( isset( $check[ $key ] ) ) {
1476
-					unset( $check[ $key ] );
1477
-				}
1478
-
1479
-				update_post_meta( $post_id, $key, $value, $prev_value );
1480
-			}
1481
-
1482
-			foreach ( $to_delete as $key => $value ) {
1483
-				if ( isset( $check[ $key ] ) ) {
1484
-					unset( $check[ $key ] );
1485
-				}
1486
-
1487
-				$prev_value = $this->meta[ $post_id ][ $key ] ?? '';
1488
-				delete_post_meta( $post_id, $key, $prev_value );
1489
-			}
1490
-
1491
-			if ( ! empty( $check ) ) {
1492
-				foreach ( $check as $key => $value ) {
1493
-					delete_post_meta( $post_id, $key );
1494
-				}
1495
-			}
1496
-
1497
-			return $post_id;
1498
-		}
1499
-
1500
-		/**
1501
-		 * Some functions, like the term recount, require the visibility to be set prior. Lets save that here.
1502
-		 *
1503
-		 * @access public
1504
-		 *
1505
-		 * @param mixed $post_id Post ID.
1506
-		 *
1507
-		 * @return void
1508
-		 */
1509
-		public function pre_post_update( $post_id ) {
1510
-			if ( isset( $_POST['_visibility'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification
1511
-				update_post_meta( $post_id, '_visibility', sanitize_text_field( wp_unslash( $_POST['_visibility'] ) ) ); // phpcs:ignore WordPress.Security.NonceVerification
1512
-			}
1513
-
1514
-			if ( isset( $_POST['_stock_status'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification
1515
-				update_post_meta( $post_id, '_stock_status', sanitize_text_field( wp_unslash( $_POST['_stock_status'] ) ) ); // phpcs:ignore WordPress.Security.NonceVerification
1516
-			}
1517
-		}
1518
-
1519
-		/**
1520
-		 * Show any stored error messages.
1521
-		 *
1522
-		 * @access public
1523
-		 * @return void
1524
-		 */
1525
-		public function meta_boxes_show_errors() {
1526
-			if ( isset( $this->notices['errors'] ) && ! empty( $this->notices['errors'] ) ) {
1527
-				echo '<div id="redux_metaboxes_errors" class="error fade">';
1528
-				echo '<p><strong><span></span> ' . count( $this->notices['errors'] ) . ' ' . esc_html__( 'error(s) were found!', 'redux-framework' ) . '</strong></p>';
1529
-				echo '</div>';
1530
-			}
1531
-
1532
-			if ( isset( $this->notices['warnings'] ) && ! empty( $this->notices['warnings'] ) ) {
1533
-				echo '<div id="redux_metaboxes_warnings" class="error fade" style="border-left-color: #E8E20C;">';
1534
-				echo '<p><strong><span></span> ' . count( $this->notices['warnings'] ) . ' ' . esc_html__( 'warnings(s) were found!', 'redux-framework' ) . '</strong></p>';
1535
-				echo '</div>';
1536
-			}
1537
-		}
1538
-	}
1539
-
1540
-	class_alias( Redux_Extension_Metaboxes::class, 'ReduxFramework_Extension_metaboxes' );
1333
+        }
1334
+
1335
+        /**
1336
+         * Save meta boxes
1337
+         * Runs when a post is saved and does an action which the write panel save scripts can hook into.
1338
+         *
1339
+         * @access public
1340
+         *
1341
+         * @param mixed $post_id Post ID.
1342
+         * @param mixed $post Post.
1343
+         *
1344
+         * @return mixed
1345
+         */
1346
+        public function meta_boxes_save( $post_id, $post ) {
1347
+            if ( isset( $_POST['vc_inline'] ) && sanitize_text_field( wp_unslash( $_POST['vc_inline'] ) ) ) { // phpcs:ignore WordPress.Security.NonceVerification
1348
+                return $post_id;
1349
+            }
1350
+
1351
+            if ( isset( $_POST['post_ID'] ) && strval( $post_id ) !== $_POST['post_ID'] ) { // phpcs:ignore WordPress.Security.NonceVerification
1352
+                return $post_id;
1353
+            }
1354
+
1355
+            // Check if our nonce is set.
1356
+            if ( ! isset( $_POST['redux_metaboxes_meta_nonce'] ) || ! isset( $_POST[ $this->parent->args['opt_name'] ] ) ) {
1357
+                return $post_id;
1358
+            }
1359
+
1360
+            // Verify that the nonce is valid.
1361
+            // Validate fields (if needed).
1362
+            if ( ! wp_verify_nonce( sanitize_key( wp_unslash( $_POST['redux_metaboxes_meta_nonce'] ) ), 'redux_metaboxes_meta_nonce' ) ) {
1363
+                return $post_id;
1364
+            }
1365
+
1366
+            // If this is an autosave, our form has not been submitted, so we don't want to do anything.
1367
+            if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) {
1368
+                return $post_id;
1369
+            }
1370
+
1371
+            // Check the user's permissions, even allowing custom capabilities.
1372
+            $obj = get_post_type_object( $post->post_type );
1373
+            if ( ! current_user_can( $obj->cap->edit_post, $post_id ) ) {
1374
+                return $post_id;
1375
+            }
1376
+
1377
+            // Import.
1378
+            if ( isset( $_POST[ $this->parent->args['opt_name'] ]['import_code'] ) && ! empty( $_POST[ $this->parent->args['opt_name'] ]['import_code'] ) ) {
1379
+                $import = json_decode( sanitize_text_field( wp_unslash( $_POST[ $this->parent->args['opt_name'] ]['import_code'] ) ), true );
1380
+                unset( $_POST[ $this->parent->args['opt_name'] ]['import_code'] );
1381
+
1382
+                foreach ( Redux_Helpers::sanitize_array( wp_unslash( $_POST[ $this->parent->args['opt_name'] ] ) ) as $key => $value ) { // phpcs:ignore WordPress.Security.ValidatedSanitizedInput
1383
+                    if ( ! isset( $import[ $key ] ) ) {
1384
+                        $import[ $key ] = $value;
1385
+                    }
1386
+                }
1387
+
1388
+                $_POST[ $this->parent->args['opt_name'] ] = $import;
1389
+            }
1390
+
1391
+            $to_save    = array();
1392
+            $to_compare = array();
1393
+            $to_delete  = array();
1394
+            $dont_save  = true;
1395
+
1396
+            if ( isset( $this->parent->args['metaboxes_save_defaults'] ) && $this->parent->args['metaboxes_save_defaults'] ) {
1397
+                $dont_save = false;
1398
+            }
1399
+
1400
+            foreach ( Redux_Helpers::sanitize_array( wp_unslash( $_POST[ $this->parent->args['opt_name'] ] ) ) as $key => $value ) { // phpcs:ignore WordPress.Security.ValidatedSanitizedInput
1401
+
1402
+                // Have to remove the escaping for array comparison.
1403
+                if ( is_array( $value ) ) {
1404
+                    foreach ( $value as $k => $v ) {
1405
+                        if ( ! is_array( $v ) ) {
1406
+                            $value[ $k ] = wp_unslash( $v );
1407
+                        }
1408
+                    }
1409
+                }
1410
+
1411
+                $save = true;
1412
+
1413
+                // parent_options.
1414
+                if ( ! $dont_save && isset( $this->options_defaults[ $key ] ) && $value === $this->options_defaults[ $key ] ) {
1415
+                    $save = false;
1416
+                }
1417
+
1418
+                if ( $save && isset( $this->parent_options[ $key ] ) && $this->parent_options[ $key ] !== $value ) {
1419
+                    $save = false;
1420
+                }
1421
+
1422
+                if ( $save ) {
1423
+                    $to_save[ $key ]    = $value;
1424
+                    $to_compare[ $key ] = $this->parent->options[ $key ] ?? '';
1425
+                } else {
1426
+                    $to_delete[ $key ] = $value;
1427
+                }
1428
+            }
1429
+
1430
+            // phpcs:ignore WordPress.NamingConventions.ValidHookName
1431
+            $to_save = apply_filters( 'redux/metaboxes/save/before_validate', $to_save, $to_compare, $this->sections );
1432
+
1433
+            $validate = $this->parent->validate_class->validate( $to_save, $to_compare, $this->sections );
1434
+
1435
+            // Validate fields (if needed).
1436
+            foreach ( $to_save as $key => $value ) {
1437
+                if ( isset( $validate[ $key ] ) && $value !== $validate[ $key ] ) {
1438
+                    if ( isset( $this->parent->options[ $key ] ) && $validate[ $key ] === $this->parent->options[ $key ] ) {
1439
+                        unset( $to_save[ $key ] );
1440
+                    } else {
1441
+                        $to_save[ $key ] = $validate[ $key ];
1442
+                    }
1443
+                }
1444
+            }
1445
+
1446
+            if ( ! empty( $this->parent->errors ) || ! empty( $this->parent->warnings ) ) {
1447
+                $this->parent->transients['notices'] = ( isset( $this->parent->transients['notices'] ) && is_array( $this->parent->transients['notices'] ) ) ? $this->parent->transients['notices'] : array();
1448
+
1449
+                if ( ! isset( $this->parent->transients['notices']['errors'] ) || $this->parent->transients['notices']['errors'] !== $this->parent->errors ) {
1450
+                    $this->parent->transients['notices']['errors'] = $this->parent->errors;
1451
+                    $update_transients                             = true;
1452
+                }
1453
+
1454
+                if ( ! isset( $this->parent->transients['notices']['warnings'] ) || $this->parent->transients['notices']['warnings'] !== $this->parent->warnings ) {
1455
+                    $this->parent->transients['notices']['warnings'] = $this->parent->warnings;
1456
+                    $update_transients                               = true;
1457
+                }
1458
+
1459
+                if ( isset( $update_transients ) ) {
1460
+                    $this->parent->transients['notices']['override'] = 1;
1461
+                    set_transient( $this->parent->args['opt_name'] . '-transients-metaboxes', $this->parent->transients );
1462
+                }
1463
+            }
1464
+
1465
+            if ( isset( $_POST['post_type'] ) ) {
1466
+                $check = $this->post_type_fields[ sanitize_text_field( wp_unslash( $_POST['post_type'] ) ) ];
1467
+            }
1468
+
1469
+            // phpcs:ignore WordPress.NamingConventions.ValidHookName
1470
+            $to_save = apply_filters( 'redux/metaboxes/save', $to_save, $to_compare, $this->sections );
1471
+
1472
+            foreach ( $to_save as $key => $value ) {
1473
+                $prev_value = $this->meta[ $post_id ][ $key ] ?? '';
1474
+
1475
+                if ( isset( $check[ $key ] ) ) {
1476
+                    unset( $check[ $key ] );
1477
+                }
1478
+
1479
+                update_post_meta( $post_id, $key, $value, $prev_value );
1480
+            }
1481
+
1482
+            foreach ( $to_delete as $key => $value ) {
1483
+                if ( isset( $check[ $key ] ) ) {
1484
+                    unset( $check[ $key ] );
1485
+                }
1486
+
1487
+                $prev_value = $this->meta[ $post_id ][ $key ] ?? '';
1488
+                delete_post_meta( $post_id, $key, $prev_value );
1489
+            }
1490
+
1491
+            if ( ! empty( $check ) ) {
1492
+                foreach ( $check as $key => $value ) {
1493
+                    delete_post_meta( $post_id, $key );
1494
+                }
1495
+            }
1496
+
1497
+            return $post_id;
1498
+        }
1499
+
1500
+        /**
1501
+         * Some functions, like the term recount, require the visibility to be set prior. Lets save that here.
1502
+         *
1503
+         * @access public
1504
+         *
1505
+         * @param mixed $post_id Post ID.
1506
+         *
1507
+         * @return void
1508
+         */
1509
+        public function pre_post_update( $post_id ) {
1510
+            if ( isset( $_POST['_visibility'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification
1511
+                update_post_meta( $post_id, '_visibility', sanitize_text_field( wp_unslash( $_POST['_visibility'] ) ) ); // phpcs:ignore WordPress.Security.NonceVerification
1512
+            }
1513
+
1514
+            if ( isset( $_POST['_stock_status'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification
1515
+                update_post_meta( $post_id, '_stock_status', sanitize_text_field( wp_unslash( $_POST['_stock_status'] ) ) ); // phpcs:ignore WordPress.Security.NonceVerification
1516
+            }
1517
+        }
1518
+
1519
+        /**
1520
+         * Show any stored error messages.
1521
+         *
1522
+         * @access public
1523
+         * @return void
1524
+         */
1525
+        public function meta_boxes_show_errors() {
1526
+            if ( isset( $this->notices['errors'] ) && ! empty( $this->notices['errors'] ) ) {
1527
+                echo '<div id="redux_metaboxes_errors" class="error fade">';
1528
+                echo '<p><strong><span></span> ' . count( $this->notices['errors'] ) . ' ' . esc_html__( 'error(s) were found!', 'redux-framework' ) . '</strong></p>';
1529
+                echo '</div>';
1530
+            }
1531
+
1532
+            if ( isset( $this->notices['warnings'] ) && ! empty( $this->notices['warnings'] ) ) {
1533
+                echo '<div id="redux_metaboxes_warnings" class="error fade" style="border-left-color: #E8E20C;">';
1534
+                echo '<p><strong><span></span> ' . count( $this->notices['warnings'] ) . ' ' . esc_html__( 'warnings(s) were found!', 'redux-framework' ) . '</strong></p>';
1535
+                echo '</div>';
1536
+            }
1537
+        }
1538
+    }
1539
+
1540
+    class_alias( Redux_Extension_Metaboxes::class, 'ReduxFramework_Extension_metaboxes' );
1541 1541
 }
Please login to merge, or discard this patch.
Spacing   +117 added lines, -117 removed lines patch added patch discarded remove patch
@@ -293,7 +293,7 @@  discard block
 block discarded – undo
293 293
 								$box['page_template'] = array( $box['page_template'] );
294 294
 							}
295 295
 
296
-							$this->wp_links[ $box_id ]['page_template'] = isset( $this->wp_links[ $box_id ]['page_template'] ) ? wp_parse_args( $this->wp_links[ $box_id ]['page_template'], $box['page_template'] ) : $box['page_template'];
296
+							$this->wp_links[$box_id]['page_template'] = isset( $this->wp_links[$box_id]['page_template'] ) ? wp_parse_args( $this->wp_links[$box_id]['page_template'], $box['page_template'] ) : $box['page_template'];
297 297
 						}
298 298
 
299 299
 						if ( isset( $box['post_format'] ) && ( in_array( $this->post_type, $this->post_types, true ) || '' === $this->post_type || false === $this->post_type ) ) {
@@ -301,10 +301,10 @@  discard block
 block discarded – undo
301 301
 								$box['post_format'] = array( $box['post_format'] );
302 302
 							}
303 303
 
304
-							$this->wp_links[ $box_id ]['post_format'] = isset( $this->wp_links[ $box_id ]['post_format'] ) ? wp_parse_args( $this->wp_links[ $box_id ]['post_format'], $box['post_format'] ) : $box['post_format'];
304
+							$this->wp_links[$box_id]['post_format'] = isset( $this->wp_links[$box_id]['post_format'] ) ? wp_parse_args( $this->wp_links[$box_id]['post_format'], $box['post_format'] ) : $box['post_format'];
305 305
 						}
306 306
 
307
-						$this->meta[ $this->post_id ] = $this->get_meta( $this->post_id );
307
+						$this->meta[$this->post_id] = $this->get_meta( $this->post_id );
308 308
 
309 309
 						foreach ( $box['sections'] as $sk => $section ) {
310 310
 							if ( ! empty( $section['fields'] ) ) {
@@ -312,7 +312,7 @@  discard block
 block discarded – undo
312 312
 									if ( ! isset( $field['class'] ) ) {
313 313
 										$field['class'] = '';
314 314
 
315
-										$this->boxes[ $bk ]['sections'][ $sk ]['fields'][ $fk ] = $field;
315
+										$this->boxes[$bk]['sections'][$sk]['fields'][$fk] = $field;
316 316
 									}
317 317
 
318 318
 									if ( $add_field || ( ( is_admin() && ( 'post-new.php' === $pagenow || 'post.php' === $pagenow ) ) || ( ! is_admin() ) ) ) {
@@ -321,43 +321,43 @@  discard block
 block discarded – undo
321 321
 										}
322 322
 
323 323
 										if ( isset( $field['default'] ) ) {
324
-											$this->options_defaults[ $field['id'] ] = $field['default'];
324
+											$this->options_defaults[$field['id']] = $field['default'];
325 325
 										} else {
326
-											$this->options_defaults[ $field['id'] ] = $this->field_default( $field );
326
+											$this->options_defaults[$field['id']] = $this->field_default( $field );
327 327
 										}
328 328
 
329 329
 										foreach ( $box['post_types'] as $type ) {
330
-											$this->post_type_fields[ $type ][ $field['id'] ] = 1;
330
+											$this->post_type_fields[$type][$field['id']] = 1;
331 331
 
332 332
 											if ( 'repeater' === $field['type'] ) {
333 333
 												foreach ( $field['fields'] as $val ) {
334
-													$this->post_type_fields[ $type ][ $val['id'] ] = 1;
334
+													$this->post_type_fields[$type][$val['id']] = 1;
335 335
 												}
336 336
 											}
337 337
 										}
338 338
 
339 339
 										if ( ! empty( $field['output'] ) ) {
340
-											$this->output[ $field['id'] ] = isset( $this->output[ $field['id'] ] ) ? array_merge( $field['output'], $this->output[ $field['id'] ] ) : $field['output'];
340
+											$this->output[$field['id']] = isset( $this->output[$field['id']] ) ? array_merge( $field['output'], $this->output[$field['id']] ) : $field['output'];
341 341
 										}
342 342
 
343 343
 										// Detect what field types are being used.
344
-										if ( ! isset( $this->parent->fields[ $field['type'] ][ $field['id'] ] ) ) {
345
-											$this->parent->fields[ $field['type'] ][ $field['id'] ] = 1;
344
+										if ( ! isset( $this->parent->fields[$field['type']][$field['id']] ) ) {
345
+											$this->parent->fields[$field['type']][$field['id']] = 1;
346 346
 										} else {
347
-											$this->parent->fields[ $field['type'] ] = array( $field['id'] => 1 );
347
+											$this->parent->fields[$field['type']] = array( $field['id'] => 1 );
348 348
 										}
349 349
 
350
-										if ( isset( $this->options_defaults[ $field['id'] ] ) ) {
351
-											$this->to_replace[ $field['id'] ] = $field;
350
+										if ( isset( $this->options_defaults[$field['id']] ) ) {
351
+											$this->to_replace[$field['id']] = $field;
352 352
 										}
353 353
 									}
354 354
 
355
-									if ( ! isset( $this->parent->options[ $field['id'] ] ) ) {
356
-										$this->parent->sections[ ( count( $this->parent->sections ) - 1 ) ]['fields'][] = $field;
355
+									if ( ! isset( $this->parent->options[$field['id']] ) ) {
356
+										$this->parent->sections[( count( $this->parent->sections ) - 1 )]['fields'][] = $field;
357 357
 									}
358 358
 
359
-									if ( ! isset( $this->meta[ $this->post_id ][ $field['id'] ] ) ) {
360
-										$this->meta[ $this->post_id ][ $field['id'] ] = $this->options_defaults[ $field['id'] ];
359
+									if ( ! isset( $this->meta[$this->post_id][$field['id']] ) ) {
360
+										$this->meta[$this->post_id][$field['id']] = $this->options_defaults[$field['id']];
361 361
 									}
362 362
 
363 363
 									// Only override if it exists, and it's not the default.
@@ -397,8 +397,8 @@  discard block
 block discarded – undo
397 397
 		 * @return mixed
398 398
 		 */
399 399
 		public function replace_field( array $field ) {
400
-			if ( isset( $this->to_replace[ $field['id'] ] ) ) {
401
-				$field = $this->to_replace[ $field['id'] ];
400
+			if ( isset( $this->to_replace[$field['id']] ) ) {
401
+				$field = $this->to_replace[$field['id']];
402 402
 			}
403 403
 
404 404
 			return $field;
@@ -412,7 +412,7 @@  discard block
 block discarded – undo
412 412
 		 * @return array
413 413
 		 */
414 414
 		public function override_can_output_css( array $field ): array {
415
-			if ( isset( $this->output[ $field['id'] ] ) ) {
415
+			if ( isset( $this->output[$field['id']] ) ) {
416 416
 				$field['force_output'] = true;
417 417
 			}
418 418
 
@@ -427,8 +427,8 @@  discard block
 block discarded – undo
427 427
 		 * @return array
428 428
 		 */
429 429
 		public function output_css( array $field ): array {
430
-			if ( isset( $this->output[ $field['id'] ] ) ) {
431
-				$field['output'] = $this->output[ $field['id'] ];
430
+			if ( isset( $this->output[$field['id']] ) ) {
431
+				$field['output'] = $this->output[$field['id']];
432 432
 			}
433 433
 
434 434
 			return $field;
@@ -449,13 +449,13 @@  discard block
 block discarded – undo
449 449
 			$data = wp_parse_args( $meta, $this->options_defaults );
450 450
 
451 451
 			foreach ( $data as $key => $value ) {
452
-				if ( isset( $meta[ $key ] ) && '' !== $meta[ $key ] ) {
453
-					$data[ $key ] = $meta[ $key ];
452
+				if ( isset( $meta[$key] ) && '' !== $meta[$key] ) {
453
+					$data[$key] = $meta[$key];
454 454
 					continue;
455 455
 				}
456 456
 
457
-				if ( isset( $options[ $key ] ) ) {
458
-					$data[ $key ] = $options[ $key ];
457
+				if ( isset( $options[$key] ) ) {
458
+					$data[$key] = $options[$key];
459 459
 				}
460 460
 			}
461 461
 
@@ -482,9 +482,9 @@  discard block
 block discarded – undo
482 482
 				$the_post = $post;
483 483
 			}
484 484
 
485
-			if ( isset( $GLOBALS[ $this->parent->args['global_variable'] . '-loop' ] ) ) {
486
-				$GLOBALS[ $this->parent->args['global_variable'] ] = $GLOBALS[ $this->parent->args['global_variable'] . '-loop' ];
487
-				unset( $GLOBALS[ $this->parent->args['global_variable'] . '-loop' ] );
485
+			if ( isset( $GLOBALS[$this->parent->args['global_variable'] . '-loop'] ) ) {
486
+				$GLOBALS[$this->parent->args['global_variable']] = $GLOBALS[$this->parent->args['global_variable'] . '-loop'];
487
+				unset( $GLOBALS[$this->parent->args['global_variable'] . '-loop'] );
488 488
 			}
489 489
 
490 490
 			// Override these values if they differ from the admin panel defaults.  ;) .
@@ -495,8 +495,8 @@  discard block
 block discarded – undo
495 495
 				}
496 496
 
497 497
 				// Backup the args.
498
-				$GLOBALS[ $this->parent->args['global_variable'] . '-loop' ] = $GLOBALS[ $this->parent->args['global_variable'] ];
499
-				$GLOBALS[ $this->parent->args['global_variable'] ]           = wp_parse_args( $meta, $GLOBALS[ $this->parent->args['global_variable'] . '-loop' ] );
498
+				$GLOBALS[$this->parent->args['global_variable'] . '-loop'] = $GLOBALS[$this->parent->args['global_variable']];
499
+				$GLOBALS[$this->parent->args['global_variable']]           = wp_parse_args( $meta, $GLOBALS[$this->parent->args['global_variable'] . '-loop'] );
500 500
 			}
501 501
 
502 502
 			// phpcs:enable WordPress.NamingConventions.PrefixAllGlobals -- Cannot rename 'this.'
@@ -506,11 +506,11 @@  discard block
 block discarded – undo
506 506
 		 * Loop end.
507 507
 		 */
508 508
 		public function loop_end() {
509
-			if ( isset( $GLOBALS[ $this->parent->args['global_variable'] . '-loop' ] ) ) {
509
+			if ( isset( $GLOBALS[$this->parent->args['global_variable'] . '-loop'] ) ) {
510 510
 				// phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals -- Cannot rename 'this.'  C'mon WP guys. Dumbest fucking misflag ever!
511
-				$GLOBALS[ $this->parent->args['global_variable'] ] = $GLOBALS[ $this->parent->args['global_variable'] . '-loop' ];
511
+				$GLOBALS[$this->parent->args['global_variable']] = $GLOBALS[$this->parent->args['global_variable'] . '-loop'];
512 512
 
513
-				unset( $GLOBALS[ $this->parent->args['global_variable'] . '-loop' ] );
513
+				unset( $GLOBALS[$this->parent->args['global_variable'] . '-loop'] );
514 514
 			}
515 515
 		}
516 516
 
@@ -535,7 +535,7 @@  discard block
 block discarded – undo
535 535
 				if ( ! empty( $box['post_types'] ) ) {
536 536
 					if ( ! is_array( $box['post_types'] ) ) {
537 537
 						$box['post_types']                 = array( $box['post_types'] );
538
-						$this->boxes[ $key ]['post_types'] = $box['post_types'];
538
+						$this->boxes[$key]['post_types'] = $box['post_types'];
539 539
 					}
540 540
 				}
541 541
 			}
@@ -625,7 +625,7 @@  discard block
 block discarded – undo
625 625
 			}
626 626
 
627 627
 			if ( isset( $_GET['post'] ) ) {  // phpcs:ignore WordPress.Security.NonceVerification
628
-				$post = (int) sanitize_text_field( wp_unslash( $_GET['post'] ) );  // phpcs:ignore WordPress.Security.NonceVerification
628
+				$post = ( int ) sanitize_text_field( wp_unslash( $_GET['post'] ) ); // phpcs:ignore WordPress.Security.NonceVerification
629 629
 
630 630
 				if ( ! empty( $post ) ) {
631 631
 					return $post;
@@ -646,7 +646,7 @@  discard block
 block discarded – undo
646 646
 
647 647
 			$post_id = url_to_postid( $url );
648 648
 
649
-			if ( isset( $post_id ) && '' !== (string) $post_id && 0 !== $post_id ) {
649
+			if ( isset( $post_id ) && '' !== ( string ) $post_id && 0 !== $post_id ) {
650 650
 				return $post_id;
651 651
 			}
652 652
 
@@ -702,9 +702,9 @@  discard block
 block discarded – undo
702 702
 					}
703 703
 
704 704
 					foreach ( $GLOBALS['wp_post_types'] as $key => $value ) {
705
-						if ( ! empty( $_GET[ $key ] ) ) { // phpcs:ignore WordPress.Security.NonceVerification
705
+						if ( ! empty( $_GET[$key] ) ) { // phpcs:ignore WordPress.Security.NonceVerification
706 706
 							$args = array(
707
-								'name'      => sanitize_text_field( wp_unslash( $_GET[ $key ] ) ), // phpcs:ignore WordPress.Security.NonceVerification
707
+								'name'      => sanitize_text_field( wp_unslash( $_GET[$key] ) ), // phpcs:ignore WordPress.Security.NonceVerification
708 708
 								'post_type' => $key,
709 709
 								'showposts' => 1,
710 710
 							);
@@ -790,7 +790,7 @@  discard block
 block discarded – undo
790 790
 
791 791
 					foreach ( $query_vars as $key => $value ) {
792 792
 						if ( in_array( $key, $wp->public_query_vars, true ) ) {
793
-							$query[ $key ] = $value;
793
+							$query[$key] = $value;
794 794
 						}
795 795
 					}
796 796
 
@@ -824,35 +824,35 @@  discard block
 block discarded – undo
824 824
 					// Taken from class-wp.php.
825 825
 					foreach ( $GLOBALS['wp_post_types'] as $post_type => $t ) {
826 826
 						if ( isset( $t->query_var ) ) {
827
-							$post_type_query_vars[ $t->query_var ] = $post_type;
827
+							$post_type_query_vars[$t->query_var] = $post_type;
828 828
 						}
829 829
 					}
830 830
 
831 831
 					foreach ( $wp->public_query_vars as $wpvar ) {
832
-						if ( isset( $wp->extra_query_vars[ $wpvar ] ) ) {
833
-							$query[ $wpvar ] = $wp->extra_query_vars[ $wpvar ];
834
-						} elseif ( isset( $_POST[ $wpvar ] ) ) { // phpcs:ignore WordPress.Security.NonceVerification
835
-							$query[ $wpvar ] = sanitize_text_field( wp_unslash( $_POST[ $wpvar ] ) ); // phpcs:ignore WordPress.Security.NonceVerification
836
-						} elseif ( isset( $_GET[ $wpvar ] ) ) { // phpcs:ignore WordPress.Security.NonceVerification
837
-							$query[ $wpvar ] = sanitize_text_field( wp_unslash( $_GET[ $wpvar ] ) ); // phpcs:ignore WordPress.Security.NonceVerification
838
-						} elseif ( isset( $query_vars[ $wpvar ] ) ) {
839
-							$query[ $wpvar ] = $query_vars[ $wpvar ];
832
+						if ( isset( $wp->extra_query_vars[$wpvar] ) ) {
833
+							$query[$wpvar] = $wp->extra_query_vars[$wpvar];
834
+						} elseif ( isset( $_POST[$wpvar] ) ) { // phpcs:ignore WordPress.Security.NonceVerification
835
+							$query[$wpvar] = sanitize_text_field( wp_unslash( $_POST[$wpvar] ) ); // phpcs:ignore WordPress.Security.NonceVerification
836
+						} elseif ( isset( $_GET[$wpvar] ) ) { // phpcs:ignore WordPress.Security.NonceVerification
837
+							$query[$wpvar] = sanitize_text_field( wp_unslash( $_GET[$wpvar] ) ); // phpcs:ignore WordPress.Security.NonceVerification
838
+						} elseif ( isset( $query_vars[$wpvar] ) ) {
839
+							$query[$wpvar] = $query_vars[$wpvar];
840 840
 						}
841 841
 
842
-						if ( ! empty( $query[ $wpvar ] ) ) {
843
-							if ( ! is_array( $query[ $wpvar ] ) ) {
844
-								$query[ $wpvar ] = (string) $query[ $wpvar ];
842
+						if ( ! empty( $query[$wpvar] ) ) {
843
+							if ( ! is_array( $query[$wpvar] ) ) {
844
+								$query[$wpvar] = ( string ) $query[$wpvar];
845 845
 							} else {
846
-								foreach ( $query[ $wpvar ] as $vkey => $v ) {
846
+								foreach ( $query[$wpvar] as $vkey => $v ) {
847 847
 									if ( ! is_object( $v ) ) {
848
-										$query[ $wpvar ][ $vkey ] = (string) $v;
848
+										$query[$wpvar][$vkey] = ( string ) $v;
849 849
 									}
850 850
 								}
851 851
 							}
852 852
 
853
-							if ( isset( $post_type_query_vars[ $wpvar ] ) ) {
854
-								$query['post_type'] = $post_type_query_vars[ $wpvar ];
855
-								$query['name']      = $query[ $wpvar ];
853
+							if ( isset( $post_type_query_vars[$wpvar] ) ) {
854
+								$query['post_type'] = $post_type_query_vars[$wpvar];
855
+								$query['name']      = $query[$wpvar];
856 856
 							}
857 857
 						}
858 858
 					}
@@ -909,7 +909,7 @@  discard block
 block discarded – undo
909 909
 							} else {
910 910
 								$section['id'] = sanitize_text_field( $section['title'] );
911 911
 							}
912
-							$this->boxes[ $key ]['sections'][ $sk ] = $section;
912
+							$this->boxes[$key]['sections'][$sk] = $section;
913 913
 						}
914 914
 						if ( isset( $section['fields'] ) ) {
915 915
 							foreach ( $section['fields'] as $k => $field ) {
@@ -919,15 +919,15 @@  discard block
 block discarded – undo
919 919
 								}
920 920
 
921 921
 								if ( 'ace_editor' === $field['type'] && isset( $field['options'] ) ) {
922
-									$this->boxes[ $key ]['sections'][ $sk ]['fields'][ $k ]['args'] = $field['options'];
923
-									unset( $this->boxes[ $key ]['sections'][ $sk ]['fields'][ $k ]['options'] );
922
+									$this->boxes[$key]['sections'][$sk]['fields'][$k]['args'] = $field['options'];
923
+									unset( $this->boxes[$key]['sections'][$sk]['fields'][$k]['options'] );
924 924
 								}
925 925
 
926 926
 								if ( 'section' === $field['type'] && isset( $field['indent'] ) && ( true === $field['indent'] || 'true' === $field['indent'] ) ) {
927 927
 									$field['class']  = $field['class'] ?? '';
928 928
 									$field['class'] .= 'redux-section-indent-start';
929 929
 
930
-									$this->boxes[ $key ]['sections'][ $sk ]['fields'][ $k ] = $field;
930
+									$this->boxes[$key]['sections'][$sk]['fields'][$k] = $field;
931 931
 								}
932 932
 
933 933
 								if ( ! isset( $this->parent->options_defaults_class ) ) {
@@ -949,8 +949,8 @@  discard block
 block discarded – undo
949 949
 				}
950 950
 			}
951 951
 
952
-			if ( empty( $this->meta[ $this->post_id ] ) ) {
953
-				$this->meta[ $this->post_id ] = $this->get_meta( $this->post_id );
952
+			if ( empty( $this->meta[$this->post_id] ) ) {
953
+				$this->meta[$this->post_id] = $this->get_meta( $this->post_id );
954 954
 			}
955 955
 		}
956 956
 
@@ -1064,8 +1064,8 @@  discard block
 block discarded – undo
1064 1064
 
1065 1065
 			$this->options = $this->parent->options;
1066 1066
 
1067
-			if ( isset( $this->parent->options[ $field_id['id'] ] ) && isset( $this->parent->options_defaults[ $field_id['id'] ] ) && $this->parent->options[ $field_id['id'] ] !== $this->parent->options_defaults[ $field_id['id'] ] ) {
1068
-				return $this->parent->options[ $field_id['id'] ];
1067
+			if ( isset( $this->parent->options[$field_id['id']] ) && isset( $this->parent->options_defaults[$field_id['id']] ) && $this->parent->options[$field_id['id']] !== $this->parent->options_defaults[$field_id['id']] ) {
1068
+				return $this->parent->options[$field_id['id']];
1069 1069
 			} else {
1070 1070
 				if ( empty( $this->options_defaults ) ) {
1071 1071
 					$this->default_values(); // fill cache.
@@ -1073,11 +1073,11 @@  discard block
 block discarded – undo
1073 1073
 
1074 1074
 				$data = '';
1075 1075
 				if ( ! empty( $this->options_defaults ) ) {
1076
-					$data = $this->options_defaults[ $field_id['id'] ] ?? '';
1076
+					$data = $this->options_defaults[$field_id['id']] ?? '';
1077 1077
 				}
1078 1078
 
1079
-				if ( empty( $data ) && isset( $this->parent->options_defaults[ $field_id['id'] ] ) ) {
1080
-					$data = $this->parent->options_defaults[ $field_id['id'] ] ?? '';
1079
+				if ( empty( $data ) && isset( $this->parent->options_defaults[$field_id['id']] ) ) {
1080
+					$data = $this->parent->options_defaults[$field_id['id']] ?? '';
1081 1081
 				}
1082 1082
 
1083 1083
 				return $data;
@@ -1092,8 +1092,8 @@  discard block
 block discarded – undo
1092 1092
 		 * @return array
1093 1093
 		 */
1094 1094
 		private function get_meta( $id ): array {
1095
-			if ( ! isset( $this->meta[ $id ] ) ) {
1096
-				$this->meta[ $id ] = array();
1095
+			if ( ! isset( $this->meta[$id] ) ) {
1096
+				$this->meta[$id] = array();
1097 1097
 				$o_data            = get_post_meta( $id );
1098 1098
 
1099 1099
 				// phpcs:ignore WordPress.NamingConventions.ValidHookName
@@ -1102,30 +1102,30 @@  discard block
 block discarded – undo
1102 1102
 				if ( ! empty( $o_data ) ) {
1103 1103
 					foreach ( $o_data as $key => $value ) {
1104 1104
 						if ( 1 === count( $value ) ) {
1105
-							$this->meta[ $id ][ $key ] = maybe_unserialize( $value[0] );
1105
+							$this->meta[$id][$key] = maybe_unserialize( $value[0] );
1106 1106
 						} else {
1107 1107
 							$new_value = array_map( 'maybe_unserialize', $value );
1108 1108
 
1109
-							$this->meta[ $id ][ $key ] = $new_value[0];
1109
+							$this->meta[$id][$key] = $new_value[0];
1110 1110
 						}
1111 1111
 					}
1112 1112
 				}
1113 1113
 
1114
-				if ( isset( $this->meta[ $id ][ $this->parent->args['opt_name'] ] ) ) {
1115
-					$data = maybe_unserialize( $this->meta[ $id ][ $this->parent->args['opt_name'] ] );
1114
+				if ( isset( $this->meta[$id][$this->parent->args['opt_name']] ) ) {
1115
+					$data = maybe_unserialize( $this->meta[$id][$this->parent->args['opt_name']] );
1116 1116
 
1117 1117
 					foreach ( $data as $key => $value ) {
1118
-						$this->meta[ $id ][ $key ] = $value;
1118
+						$this->meta[$id][$key] = $value;
1119 1119
 						update_post_meta( $id, $key, $value );
1120 1120
 					}
1121 1121
 
1122
-					unset( $this->meta[ $id ][ $this->parent->args['opt_name'] ] );
1122
+					unset( $this->meta[$id][$this->parent->args['opt_name']] );
1123 1123
 
1124 1124
 					delete_post_meta( $id, $this->parent->args['opt_name'] );
1125 1125
 				}
1126 1126
 			}
1127 1127
 
1128
-			return $this->meta[ $id ];
1128
+			return $this->meta[$id];
1129 1129
 		}
1130 1130
 
1131 1131
 		/**
@@ -1141,29 +1141,29 @@  discard block
 block discarded – undo
1141 1141
 
1142 1142
 			// Override these values if they differ from the admin panel defaults.  ;) .
1143 1143
 			if ( isset( $the_post->post_type ) && in_array( $the_post->post_type, $this->post_types, true ) ) {
1144
-				if ( isset( $this->post_type_values[ $the_post->post_type ] ) ) {
1145
-					$meta = $this->post_type_fields[ $the_post->post_type ];
1144
+				if ( isset( $this->post_type_values[$the_post->post_type] ) ) {
1145
+					$meta = $this->post_type_fields[$the_post->post_type];
1146 1146
 				} else {
1147 1147
 					$defaults = array();
1148
-					if ( ! empty( $this->post_type_fields[ $the_post->post_type ] ) ) {
1149
-						foreach ( $this->post_type_fields[ $the_post->post_type ] as $key => $null ) {
1150
-							if ( isset( $this->options_defaults[ $key ] ) ) {
1151
-								$defaults[ $key ] = $this->options_defaults[ $key ];
1148
+					if ( ! empty( $this->post_type_fields[$the_post->post_type] ) ) {
1149
+						foreach ( $this->post_type_fields[$the_post->post_type] as $key => $null ) {
1150
+							if ( isset( $this->options_defaults[$key] ) ) {
1151
+								$defaults[$key] = $this->options_defaults[$key];
1152 1152
 							}
1153 1153
 						}
1154 1154
 					}
1155 1155
 
1156 1156
 					$meta = wp_parse_args( $this->get_meta( $the_post->ID ), $defaults );
1157 1157
 
1158
-					$this->post_type_fields[ $the_post->post_type ] = $meta;
1158
+					$this->post_type_fields[$the_post->post_type] = $meta;
1159 1159
 				}
1160 1160
 
1161 1161
 				if ( ! empty( $meta_key ) ) {
1162
-					if ( ! isset( $meta[ $meta_key ] ) ) {
1163
-						$meta[ $meta_key ] = $def_val;
1162
+					if ( ! isset( $meta[$meta_key] ) ) {
1163
+						$meta[$meta_key] = $def_val;
1164 1164
 					}
1165 1165
 
1166
-					return $meta[ $meta_key ];
1166
+					return $meta[$meta_key];
1167 1167
 				} else {
1168 1168
 					return $meta;
1169 1169
 				}
@@ -1314,11 +1314,11 @@  discard block
 block discarded – undo
1314 1314
 									$field['class'] .= 'redux-section-indent-start';
1315 1315
 								}
1316 1316
 
1317
-								if ( ! isset( $this->meta[ $this->post_id ][ $field['id'] ] ) ) {
1318
-									$this->meta[ $this->post_id ][ $field['id'] ] = '';
1317
+								if ( ! isset( $this->meta[$this->post_id][$field['id']] ) ) {
1318
+									$this->meta[$this->post_id][$field['id']] = '';
1319 1319
 								}
1320 1320
 
1321
-								$this->parent->render_class->field_input( $field, $this->meta[ $this->post_id ][ $field['id'] ], true );
1321
+								$this->parent->render_class->field_input( $field, $this->meta[$this->post_id][$field['id']], true );
1322 1322
 								echo '</td></tr>';
1323 1323
 							}
1324 1324
 							echo '</tbody></table>';
@@ -1353,7 +1353,7 @@  discard block
 block discarded – undo
1353 1353
 			}
1354 1354
 
1355 1355
 			// Check if our nonce is set.
1356
-			if ( ! isset( $_POST['redux_metaboxes_meta_nonce'] ) || ! isset( $_POST[ $this->parent->args['opt_name'] ] ) ) {
1356
+			if ( ! isset( $_POST['redux_metaboxes_meta_nonce'] ) || ! isset( $_POST[$this->parent->args['opt_name']] ) ) {
1357 1357
 				return $post_id;
1358 1358
 			}
1359 1359
 
@@ -1375,17 +1375,17 @@  discard block
 block discarded – undo
1375 1375
 			}
1376 1376
 
1377 1377
 			// Import.
1378
-			if ( isset( $_POST[ $this->parent->args['opt_name'] ]['import_code'] ) && ! empty( $_POST[ $this->parent->args['opt_name'] ]['import_code'] ) ) {
1379
-				$import = json_decode( sanitize_text_field( wp_unslash( $_POST[ $this->parent->args['opt_name'] ]['import_code'] ) ), true );
1380
-				unset( $_POST[ $this->parent->args['opt_name'] ]['import_code'] );
1378
+			if ( isset( $_POST[$this->parent->args['opt_name']]['import_code'] ) && ! empty( $_POST[$this->parent->args['opt_name']]['import_code'] ) ) {
1379
+				$import = json_decode( sanitize_text_field( wp_unslash( $_POST[$this->parent->args['opt_name']]['import_code'] ) ), true );
1380
+				unset( $_POST[$this->parent->args['opt_name']]['import_code'] );
1381 1381
 
1382
-				foreach ( Redux_Helpers::sanitize_array( wp_unslash( $_POST[ $this->parent->args['opt_name'] ] ) ) as $key => $value ) { // phpcs:ignore WordPress.Security.ValidatedSanitizedInput
1383
-					if ( ! isset( $import[ $key ] ) ) {
1384
-						$import[ $key ] = $value;
1382
+				foreach ( Redux_Helpers::sanitize_array( wp_unslash( $_POST[$this->parent->args['opt_name']] ) ) as $key => $value ) { // phpcs:ignore WordPress.Security.ValidatedSanitizedInput
1383
+					if ( ! isset( $import[$key] ) ) {
1384
+						$import[$key] = $value;
1385 1385
 					}
1386 1386
 				}
1387 1387
 
1388
-				$_POST[ $this->parent->args['opt_name'] ] = $import;
1388
+				$_POST[$this->parent->args['opt_name']] = $import;
1389 1389
 			}
1390 1390
 
1391 1391
 			$to_save    = array();
@@ -1397,13 +1397,13 @@  discard block
 block discarded – undo
1397 1397
 				$dont_save = false;
1398 1398
 			}
1399 1399
 
1400
-			foreach ( Redux_Helpers::sanitize_array( wp_unslash( $_POST[ $this->parent->args['opt_name'] ] ) ) as $key => $value ) { // phpcs:ignore WordPress.Security.ValidatedSanitizedInput
1400
+			foreach ( Redux_Helpers::sanitize_array( wp_unslash( $_POST[$this->parent->args['opt_name']] ) ) as $key => $value ) { // phpcs:ignore WordPress.Security.ValidatedSanitizedInput
1401 1401
 
1402 1402
 				// Have to remove the escaping for array comparison.
1403 1403
 				if ( is_array( $value ) ) {
1404 1404
 					foreach ( $value as $k => $v ) {
1405 1405
 						if ( ! is_array( $v ) ) {
1406
-							$value[ $k ] = wp_unslash( $v );
1406
+							$value[$k] = wp_unslash( $v );
1407 1407
 						}
1408 1408
 					}
1409 1409
 				}
@@ -1411,19 +1411,19 @@  discard block
 block discarded – undo
1411 1411
 				$save = true;
1412 1412
 
1413 1413
 				// parent_options.
1414
-				if ( ! $dont_save && isset( $this->options_defaults[ $key ] ) && $value === $this->options_defaults[ $key ] ) {
1414
+				if ( ! $dont_save && isset( $this->options_defaults[$key] ) && $value === $this->options_defaults[$key] ) {
1415 1415
 					$save = false;
1416 1416
 				}
1417 1417
 
1418
-				if ( $save && isset( $this->parent_options[ $key ] ) && $this->parent_options[ $key ] !== $value ) {
1418
+				if ( $save && isset( $this->parent_options[$key] ) && $this->parent_options[$key] !== $value ) {
1419 1419
 					$save = false;
1420 1420
 				}
1421 1421
 
1422 1422
 				if ( $save ) {
1423
-					$to_save[ $key ]    = $value;
1424
-					$to_compare[ $key ] = $this->parent->options[ $key ] ?? '';
1423
+					$to_save[$key]    = $value;
1424
+					$to_compare[$key] = $this->parent->options[$key] ?? '';
1425 1425
 				} else {
1426
-					$to_delete[ $key ] = $value;
1426
+					$to_delete[$key] = $value;
1427 1427
 				}
1428 1428
 			}
1429 1429
 
@@ -1434,11 +1434,11 @@  discard block
 block discarded – undo
1434 1434
 
1435 1435
 			// Validate fields (if needed).
1436 1436
 			foreach ( $to_save as $key => $value ) {
1437
-				if ( isset( $validate[ $key ] ) && $value !== $validate[ $key ] ) {
1438
-					if ( isset( $this->parent->options[ $key ] ) && $validate[ $key ] === $this->parent->options[ $key ] ) {
1439
-						unset( $to_save[ $key ] );
1437
+				if ( isset( $validate[$key] ) && $value !== $validate[$key] ) {
1438
+					if ( isset( $this->parent->options[$key] ) && $validate[$key] === $this->parent->options[$key] ) {
1439
+						unset( $to_save[$key] );
1440 1440
 					} else {
1441
-						$to_save[ $key ] = $validate[ $key ];
1441
+						$to_save[$key] = $validate[$key];
1442 1442
 					}
1443 1443
 				}
1444 1444
 			}
@@ -1463,28 +1463,28 @@  discard block
 block discarded – undo
1463 1463
 			}
1464 1464
 
1465 1465
 			if ( isset( $_POST['post_type'] ) ) {
1466
-				$check = $this->post_type_fields[ sanitize_text_field( wp_unslash( $_POST['post_type'] ) ) ];
1466
+				$check = $this->post_type_fields[sanitize_text_field( wp_unslash( $_POST['post_type'] ) )];
1467 1467
 			}
1468 1468
 
1469 1469
 			// phpcs:ignore WordPress.NamingConventions.ValidHookName
1470 1470
 			$to_save = apply_filters( 'redux/metaboxes/save', $to_save, $to_compare, $this->sections );
1471 1471
 
1472 1472
 			foreach ( $to_save as $key => $value ) {
1473
-				$prev_value = $this->meta[ $post_id ][ $key ] ?? '';
1473
+				$prev_value = $this->meta[$post_id][$key] ?? '';
1474 1474
 
1475
-				if ( isset( $check[ $key ] ) ) {
1476
-					unset( $check[ $key ] );
1475
+				if ( isset( $check[$key] ) ) {
1476
+					unset( $check[$key] );
1477 1477
 				}
1478 1478
 
1479 1479
 				update_post_meta( $post_id, $key, $value, $prev_value );
1480 1480
 			}
1481 1481
 
1482 1482
 			foreach ( $to_delete as $key => $value ) {
1483
-				if ( isset( $check[ $key ] ) ) {
1484
-					unset( $check[ $key ] );
1483
+				if ( isset( $check[$key] ) ) {
1484
+					unset( $check[$key] );
1485 1485
 				}
1486 1486
 
1487
-				$prev_value = $this->meta[ $post_id ][ $key ] ?? '';
1487
+				$prev_value = $this->meta[$post_id][$key] ?? '';
1488 1488
 				delete_post_meta( $post_id, $key, $prev_value );
1489 1489
 			}
1490 1490
 
Please login to merge, or discard this patch.
redux-core/inc/extensions/users/redux-users-helpers.php 1 patch
Indentation   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -10,20 +10,20 @@
 block discarded – undo
10 10
 // Helper function to bypass WordPress hook priorities.  ;).
11 11
 if ( ! function_exists( 'create_term_redux_users' ) ) {
12 12
 
13
-	/**
14
-	 * Create_term_redux_users.
15
-	 *
16
-	 * @param string $profile_id Profile ID.
17
-	 */
18
-	function create_term_redux_users( string $profile_id ) { // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals -- Existing API already used in themes. Cannot change due to backward compatibility. Contains the plugin name.
19
-		$instances = Redux::all_instances();
13
+    /**
14
+     * Create_term_redux_users.
15
+     *
16
+     * @param string $profile_id Profile ID.
17
+     */
18
+    function create_term_redux_users( string $profile_id ) { // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals -- Existing API already used in themes. Cannot change due to backward compatibility. Contains the plugin name.
19
+        $instances = Redux::all_instances();
20 20
 
21
-		foreach ( $_POST as $key => $value ) { // phpcs:ignore WordPress.Security.NonceVerification
22
-			if ( is_array( $value ) && isset( $instances[ $key ] ) ) {
23
-				$instances[ $key ]->extensions['users']->user_meta_save( $profile_id );
24
-			}
25
-		}
26
-	}
21
+        foreach ( $_POST as $key => $value ) { // phpcs:ignore WordPress.Security.NonceVerification
22
+            if ( is_array( $value ) && isset( $instances[ $key ] ) ) {
23
+                $instances[ $key ]->extensions['users']->user_meta_save( $profile_id );
24
+            }
25
+        }
26
+    }
27 27
 }
28 28
 
29 29
 add_action( 'create_term', 'create_term_redux_users', 4 );
Please login to merge, or discard this patch.
redux-core/inc/classes/class-redux-functions-ex.php 1 patch
Indentation   +472 added lines, -472 removed lines patch added patch discarded remove patch
@@ -13,476 +13,476 @@
 block discarded – undo
13 13
 // Don't duplicate me!
14 14
 if ( ! class_exists( 'Redux_Functions_Ex', false ) ) {
15 15
 
16
-	/**
17
-	 * Redux Functions Class
18
-	 * A Class of useful functions that can/should be shared among all Redux files.
19
-	 *
20
-	 * @since       3.0.0
21
-	 */
22
-	class Redux_Functions_Ex {
23
-
24
-		/**
25
-		 * What is this for?
26
-		 *
27
-		 * @var array
28
-		 */
29
-		public static $args;
30
-
31
-		/**
32
-		 * Enqueue Font Awesome.
33
-		 *
34
-		 * @return void
35
-		 */
36
-		public static function enqueue_font_awesome() {
37
-			wp_enqueue_style(
38
-				'font-awesome',
39
-				Redux_Core::$url . 'assets/font-awesome/css/all' . Redux_Functions::is_min() . '.css',
40
-				array(),
41
-				'6.5.2'
42
-			);
43
-
44
-			wp_enqueue_style(
45
-				'font-awesome-4-shims',
46
-				Redux_Core::$url . 'assets/font-awesome/css/v4-shims' . Redux_Functions::is_min() . '.css',
47
-				array(),
48
-				'6.5.2'
49
-			);
50
-		}
51
-
52
-		/**
53
-		 * Enqueue Elusive Font.
54
-		 *
55
-		 * @return void
56
-		 */
57
-		public static function enqueue_elusive_font() {
58
-			wp_enqueue_style(
59
-				'redux-elusive-icon',
60
-				Redux_Core::$url . 'assets/css/vendor/elusive-icons' . Redux_Functions::is_min() . '.css',
61
-				array(),
62
-				'2.0.0'
63
-			);
64
-		}
65
-
66
-		/**
67
-		 * Output alpha data tag for Iris alpha color picker, if enabled.
68
-		 *
69
-		 * @param array $data Data array.
70
-		 *
71
-		 * @return string
72
-		 */
73
-		public static function output_alpha_data( array $data ): string {
74
-			$index = null;
75
-
76
-			extract( $data ); // phpcs:ignore WordPress.PHP.DontExtract
77
-
78
-			$value = false;
79
-
80
-			if ( isset( $field['color_alpha'] ) && $field['color_alpha'] ) {
81
-				if ( is_array( $field['color_alpha'] ) ) {
82
-					$value = $field['color_alpha'][ $index ] ?? false;
83
-				} else {
84
-					$value = $field['color_alpha'];
85
-				}
86
-			}
87
-
88
-			return 'data-alpha-enabled="' . (bool) esc_attr( $value ) . '"';
89
-		}
90
-
91
-		/**
92
-		 * Parses the string into variables without the max_input_vars limitation.
93
-		 *
94
-		 * @param string $str String of data.
95
-		 *
96
-		 * @return  array|false $result
97
-		 * @since   3.5.7.11
98
-		 * @author  harunbasic
99
-		 * @access  private
100
-		 */
101
-		public static function parse_str( string $str ) {
102
-			if ( '' === $str ) {
103
-				return false;
104
-			}
105
-
106
-			$result = array();
107
-			$pairs  = explode( '&', $str );
108
-
109
-			foreach ( $pairs as $pair ) {
110
-				// use the original parse_str() on each element.
111
-				parse_str( $pair, $params );
112
-
113
-				$k = key( $params );
114
-
115
-				if ( ! isset( $result[ $k ] ) ) {
116
-					$result += $params;
117
-				} elseif ( is_array( $result[ $k ] ) && is_array( $params[ $k ] ) ) {
118
-					$result[ $k ] = self::array_merge_recursive_distinct( $result[ $k ], $params[ $k ] );
119
-				}
120
-			}
121
-
122
-			return $result;
123
-		}
124
-
125
-		/**
126
-		 * Merge arrays without converting values with duplicate keys to arrays as array_merge_recursive does.
127
-		 * As seen here http://php.net/manual/en/function.array-merge-recursive.php#92195
128
-		 *
129
-		 * @param array $array1 array one.
130
-		 * @param array $array2 array two.
131
-		 *
132
-		 * @return  array $merged
133
-		 * @since   3.5.7.11
134
-		 * @author  harunbasic
135
-		 * @access  private
136
-		 */
137
-		public static function array_merge_recursive_distinct( array $array1, array $array2 ): array {
138
-			$merged = $array1;
139
-
140
-			foreach ( $array2 as $key => $value ) {
141
-
142
-				if ( is_array( $value ) && isset( $merged[ $key ] ) && is_array( $merged[ $key ] ) ) {
143
-					$merged[ $key ] = self::array_merge_recursive_distinct( $merged[ $key ], $value );
144
-				} elseif ( is_numeric( $key ) && isset( $merged[ $key ] ) ) {
145
-					$merged[] = $value;
146
-				} else {
147
-					$merged[ $key ] = $value;
148
-				}
149
-			}
150
-
151
-			return $merged;
152
-		}
153
-
154
-		/**
155
-		 * Records calling function.
156
-		 *
157
-		 * @param string $opt_name Panel opt_name.
158
-		 */
159
-		public static function record_caller( string $opt_name = '' ) {
160
-			global $pagenow;
161
-
162
-			// phpcs:ignore WordPress.Security.NonceVerification
163
-			if ( ! ( 'options-general.php' === $pagenow && isset( $_GET['page'] ) && ( 'redux-framework' === $_GET['page'] || 'health-check' === $_GET['page'] ) ) ) {
164
-				return;
165
-			}
166
-
167
-			// phpcs:ignore WordPress.PHP.DevelopmentFunctions
168
-			$caller = debug_backtrace( DEBUG_BACKTRACE_IGNORE_ARGS, 2 )[1]['file'];
169
-
170
-			if ( ! empty( $caller ) && ! empty( $opt_name ) && class_exists( 'Redux_Core' ) ) {
171
-				if ( ! isset( Redux_Core::$callers[ $opt_name ] ) ) {
172
-					Redux_Core::$callers[ $opt_name ] = array();
173
-				}
174
-
175
-				if ( strpos( $caller, 'class-redux-' ) !== false || strpos( $caller, 'redux-core/framework.php' ) ) {
176
-					return;
177
-				}
178
-
179
-				if ( ! in_array( $caller, Redux_Core::$callers[ $opt_name ], true ) ) {
180
-					Redux_Core::$callers[ $opt_name ][] = $caller;
181
-				}
182
-
183
-				if ( ! empty( self::$args[ $opt_name ]['callers'] ) && ! in_array( $caller, self::$args[ $opt_name ]['callers'], true ) ) {
184
-					self::$args[ $opt_name ]['callers'][] = $caller;
185
-				}
186
-			}
187
-		}
188
-
189
-		/**
190
-		 * Normalize path.
191
-		 *
192
-		 * @param string $path Path to normalize.
193
-		 *
194
-		 * @return string|string[]|null
195
-		 */
196
-		public static function wp_normalize_path( string $path = '' ) {
197
-			if ( function_exists( 'wp_normalize_path' ) ) {
198
-				$path = wp_normalize_path( $path );
199
-			} else {
200
-				// Shim for pre WP 3.9.
201
-				$path = str_replace( '\\', '/', $path );
202
-				$path = preg_replace( '|(?<=.)/+|', '/', $path );
203
-
204
-				if ( ':' === substr( $path, 1, 1 ) ) {
205
-					$path = ucfirst( $path );
206
-				}
207
-			}
208
-
209
-			return $path;
210
-		}
211
-
212
-		/**
213
-		 * Action to add generator tag to page HEAD.
214
-		 */
215
-		public static function generator() {
216
-			add_action( 'wp_head', array( 'Redux_Functions_Ex', 'meta_tag' ) );
217
-		}
218
-
219
-
220
-		/**
221
-		 * Callback for wp_head hook to add meta tag.
222
-		 */
223
-		public static function meta_tag() {
224
-			echo '<meta name="generator" content="Redux ' . esc_html( Redux_Core::$version ) . '" />';
225
-		}
226
-
227
-		/**
228
-		 * Run URL through a ssl check.
229
-		 *
230
-		 * @param string $url URL to check.
231
-		 *
232
-		 * @return string
233
-		 */
234
-		public static function verify_url_protocol( string $url ): string {
235
-			// phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotValidated
236
-			$protocol = ! empty( $_SERVER['HTTPS'] ) && 'off' !== $_SERVER['HTTPS'] || ( ! empty( $_SERVER['SERVER_PORT'] ) && 443 === $_SERVER['SERVER_PORT'] ) ? 'https://' : 'http://';
237
-
238
-			if ( ! empty( $_SERVER['HTTP_X_FORWARDED_PROTO'] ) ) { // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotValidated
239
-				$new_protocol = sanitize_text_field( wp_unslash( $_SERVER['HTTP_X_FORWARDED_PROTO'] ) ) . '://'; // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotValidated
240
-				if ( 'http://' === $protocol && $new_protocol !== $protocol && false === strpos( $url, $new_protocol ) ) {
241
-					$url = str_replace( $protocol, $new_protocol, $url );
242
-				}
243
-			}
244
-
245
-			return $url;
246
-		}
247
-
248
-		/**
249
-		 * Check s.
250
-		 *
251
-		 * @access public
252
-		 * @return bool
253
-		 * @since  4.0.0
254
-		 */
255
-		public static function s(): bool {
256
-			if ( ! get_option( 'redux_p' . 'ro_lic' . 'ense_key', false ) ) { // phpcs:ignore Generic.Strings.UnnecessaryStringConcat.Found
257
-				$s = get_option( 'redux_p' . 'ro_l' . 'icense_status', false ); // phpcs:ignore Generic.Strings.UnnecessaryStringConcat.Found
258
-
259
-				if ( in_array( $s, array( 'valid', 'site_inactive' ), true ) ) {
260
-					return true;
261
-				}
262
-			}
263
-
264
-			return false;
265
-		}
266
-
267
-		/**
268
-		 * Is file in theme.
269
-		 *
270
-		 * @param string $file File to check.
271
-		 *
272
-		 * @return bool
273
-		 */
274
-		public static function file_in_theme( string $file ): bool {
275
-			$file_path = self::wp_normalize_path( dirname( $file ) );
276
-
277
-			if ( strpos( $file_path, self::wp_normalize_path( get_template_directory() ) ) !== false ) {
278
-				return true;
279
-			} elseif ( strpos( $file_path, self::wp_normalize_path( get_stylesheet_directory() ) ) !== false ) {
280
-				return true;
281
-			}
282
-
283
-			return false;
284
-		}
285
-
286
-		/**
287
-		 * Is Redux embedded inside a plugin?
288
-		 *
289
-		 * @param string $file File to check.
290
-		 *
291
-		 * @return array|bool
292
-		 */
293
-		public static function is_inside_plugin( string $file ) {
294
-			$file            = self::wp_normalize_path( $file );
295
-			$plugin_basename = self::wp_normalize_path( plugin_basename( $file ) );
296
-
297
-			if ( self::file_in_theme( $file ) ) {
298
-				return false;
299
-			}
300
-
301
-			if ( $plugin_basename !== $file ) {
302
-				$slug = explode( '/', $plugin_basename );
303
-				$slug = $slug[0];
304
-
305
-				return array(
306
-					'slug'      => $slug,
307
-					'basename'  => $plugin_basename,
308
-					'path'      => $file,
309
-					'url'       => self::verify_url_protocol( plugins_url( $plugin_basename ) ),
310
-					'real_path' => self::wp_normalize_path( dirname( realpath( $file ) ) ),
311
-				);
312
-			}
313
-
314
-			return false;
315
-		}
316
-
317
-		/**
318
-		 * Is Redux embedded in a theme?
319
-		 *
320
-		 * @param string $file File to check.
321
-		 *
322
-		 * @return array|bool
323
-		 */
324
-		public static function is_inside_theme( string $file = '' ) {
325
-
326
-			if ( ! self::file_in_theme( $file ) ) {
327
-				return false;
328
-			}
329
-
330
-			$theme_paths = array(
331
-				self::wp_normalize_path( get_template_directory() )   => get_template_directory_uri(),
332
-				// parent.
333
-				self::wp_normalize_path( get_stylesheet_directory() ) => get_stylesheet_directory_uri(),
334
-				// child.
335
-			);
336
-
337
-			$theme_paths = array_unique( $theme_paths );
338
-			$file_path   = self::wp_normalize_path( $file );
339
-
340
-			$filename = explode( DIRECTORY_SEPARATOR, $file );
341
-
342
-			end( $filename );
343
-
344
-			$filename = prev( $filename );
345
-
346
-			foreach ( $theme_paths as $theme_path => $url ) {
347
-				$real_path = self::wp_normalize_path( realpath( $theme_path ) );
348
-
349
-				if ( empty( $real_path ) ) {
350
-					continue;
351
-				}
352
-
353
-				if ( strpos( $file_path, $real_path ) !== false ) {
354
-					$slug             = explode( '/', $theme_path );
355
-					$slug             = end( $slug );
356
-					$relative_path    = explode( $slug . '/', dirname( $file_path ) );
357
-					$relative_path    = $relative_path[1];
358
-					$data             = array(
359
-						'slug'      => $slug,
360
-						'path'      => trailingslashit( trailingslashit( $theme_path ) . $relative_path ) . $filename,
361
-						'real_path' => trailingslashit( trailingslashit( $real_path ) . $relative_path ) . $filename,
362
-						'url'       => self::verify_url_protocol( trailingslashit( trailingslashit( $url ) . $relative_path ) . $filename ),
363
-						'basename'  => trailingslashit( $slug ) . trailingslashit( $relative_path ) . $filename,
364
-					);
365
-					$data['realpath'] = $data['real_path'];  // Shim for old extensions.
366
-
367
-					if ( count( $theme_paths ) > 1 ) {
368
-						$key = array_search( $theme_path, $theme_paths, true );
369
-
370
-						if ( false !== $key ) {
371
-							unset( $theme_paths[ $key ] );
372
-						}
373
-
374
-						$theme_paths_end = end( $theme_paths );
375
-						$parent_slug_end = explode( '/', $theme_paths_end );
376
-						$parent_slug_end = end( $parent_slug_end );
377
-
378
-						$data['parent_slug'] = $parent_slug_end;
379
-					}
380
-
381
-					return $data;
382
-				}
383
-			}
384
-
385
-			return false;
386
-		}
387
-
388
-		/**
389
-		 * Used to merge two deep arrays.
390
-		 *
391
-		 * @param array $a First array to deeply merge.
392
-		 * @param array $b Second array to deeply merge.
393
-		 *
394
-		 * @return    array - Deep merge of the two arrays.
395
-		 */
396
-		public static function nested_wp_parse_args( array &$a, array $b ): array {
397
-			$result = $b;
398
-
399
-			foreach ( $a as $k => &$v ) {
400
-				if ( is_array( $v ) && isset( $result[ $k ] ) ) {
401
-					$result[ $k ] = self::nested_wp_parse_args( $v, $result[ $k ] );
402
-				} else {
403
-					$result[ $k ] = $v;
404
-				}
405
-			}
406
-
407
-			return $result;
408
-		}
409
-
410
-		/**
411
-		 * AJAX callback key
412
-		 */
413
-		public static function hash_key(): string {
414
-			$key  = defined( 'AUTH_KEY' ) ? AUTH_KEY : get_site_url();
415
-			$key .= defined( 'SECURE_AUTH_KEY' ) ? SECURE_AUTH_KEY : '';
416
-
417
-			return $key;
418
-		}
419
-
420
-		/**
421
-		 * Register a class path to be autoloaded.
422
-		 * Registers a namespace to be autoloaded from a given path, using the
423
-		 * WordPress/HM-style filenames (`class-{name}.php`).
424
-		 *
425
-		 * @link https://engineering.hmn.md/standards/style/php/#file-naming
426
-		 *
427
-		 * @param string $prefix Prefix to autoload from.
428
-		 * @param string $path   Path to validate.
429
-		 */
430
-		public static function register_class_path( string $prefix = '', string $path = '' ) {
431
-			if ( ! class_exists( 'Redux_Autoloader' ) ) {
432
-				require_once Redux_Path::get_path( '/inc/classes/class-redux-autoloader.php' );
433
-			}
434
-
435
-			$loader = new Redux_Autoloader( $prefix, $path );
436
-
437
-			spl_autoload_register( array( $loader, 'load' ) );
438
-		}
439
-
440
-		/**
441
-		 * Check if a string starts with a string.
442
-		 *
443
-		 * @param string $haystack Full string.
444
-		 * @param string $needle   String to check if it starts with.
445
-		 *
446
-		 * @return bool
447
-		 */
448
-		public static function string_starts_with( string $haystack, string $needle ): bool {
449
-			$length = strlen( $needle );
450
-
451
-			return substr( $haystack, 0, $length ) === $needle;
452
-		}
453
-
454
-		/**
455
-		 * Check if a string ends with a string.
456
-		 *
457
-		 * @param string $haystack Full string.
458
-		 * @param string $needle   String to check if it starts with.
459
-		 *
460
-		 * @return bool
461
-		 */
462
-		public static function string_ends_with( string $haystack, string $needle ): bool {
463
-			$length = strlen( $needle );
464
-
465
-			if ( ! $length ) {
466
-				return true;
467
-			}
468
-
469
-			return substr( $haystack, - $length ) === $needle;
470
-		}
471
-
472
-		/**
473
-		 * Is plugin active.
474
-		 *
475
-		 * @param string $name Plugin name.
476
-		 *
477
-		 * @return bool
478
-		 */
479
-		public static function is_plugin_active( string $name ): bool {
480
-			// phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals -- active_plugins is a WP hook.
481
-			if ( in_array( $name . '/' . $name . '.php', apply_filters( 'active_plugins', get_option( 'active_plugins' ) ), true ) ) {
482
-				return true;
483
-			}
484
-
485
-			return false;
486
-		}
487
-	}
16
+    /**
17
+     * Redux Functions Class
18
+     * A Class of useful functions that can/should be shared among all Redux files.
19
+     *
20
+     * @since       3.0.0
21
+     */
22
+    class Redux_Functions_Ex {
23
+
24
+        /**
25
+         * What is this for?
26
+         *
27
+         * @var array
28
+         */
29
+        public static $args;
30
+
31
+        /**
32
+         * Enqueue Font Awesome.
33
+         *
34
+         * @return void
35
+         */
36
+        public static function enqueue_font_awesome() {
37
+            wp_enqueue_style(
38
+                'font-awesome',
39
+                Redux_Core::$url . 'assets/font-awesome/css/all' . Redux_Functions::is_min() . '.css',
40
+                array(),
41
+                '6.5.2'
42
+            );
43
+
44
+            wp_enqueue_style(
45
+                'font-awesome-4-shims',
46
+                Redux_Core::$url . 'assets/font-awesome/css/v4-shims' . Redux_Functions::is_min() . '.css',
47
+                array(),
48
+                '6.5.2'
49
+            );
50
+        }
51
+
52
+        /**
53
+         * Enqueue Elusive Font.
54
+         *
55
+         * @return void
56
+         */
57
+        public static function enqueue_elusive_font() {
58
+            wp_enqueue_style(
59
+                'redux-elusive-icon',
60
+                Redux_Core::$url . 'assets/css/vendor/elusive-icons' . Redux_Functions::is_min() . '.css',
61
+                array(),
62
+                '2.0.0'
63
+            );
64
+        }
65
+
66
+        /**
67
+         * Output alpha data tag for Iris alpha color picker, if enabled.
68
+         *
69
+         * @param array $data Data array.
70
+         *
71
+         * @return string
72
+         */
73
+        public static function output_alpha_data( array $data ): string {
74
+            $index = null;
75
+
76
+            extract( $data ); // phpcs:ignore WordPress.PHP.DontExtract
77
+
78
+            $value = false;
79
+
80
+            if ( isset( $field['color_alpha'] ) && $field['color_alpha'] ) {
81
+                if ( is_array( $field['color_alpha'] ) ) {
82
+                    $value = $field['color_alpha'][ $index ] ?? false;
83
+                } else {
84
+                    $value = $field['color_alpha'];
85
+                }
86
+            }
87
+
88
+            return 'data-alpha-enabled="' . (bool) esc_attr( $value ) . '"';
89
+        }
90
+
91
+        /**
92
+         * Parses the string into variables without the max_input_vars limitation.
93
+         *
94
+         * @param string $str String of data.
95
+         *
96
+         * @return  array|false $result
97
+         * @since   3.5.7.11
98
+         * @author  harunbasic
99
+         * @access  private
100
+         */
101
+        public static function parse_str( string $str ) {
102
+            if ( '' === $str ) {
103
+                return false;
104
+            }
105
+
106
+            $result = array();
107
+            $pairs  = explode( '&', $str );
108
+
109
+            foreach ( $pairs as $pair ) {
110
+                // use the original parse_str() on each element.
111
+                parse_str( $pair, $params );
112
+
113
+                $k = key( $params );
114
+
115
+                if ( ! isset( $result[ $k ] ) ) {
116
+                    $result += $params;
117
+                } elseif ( is_array( $result[ $k ] ) && is_array( $params[ $k ] ) ) {
118
+                    $result[ $k ] = self::array_merge_recursive_distinct( $result[ $k ], $params[ $k ] );
119
+                }
120
+            }
121
+
122
+            return $result;
123
+        }
124
+
125
+        /**
126
+         * Merge arrays without converting values with duplicate keys to arrays as array_merge_recursive does.
127
+         * As seen here http://php.net/manual/en/function.array-merge-recursive.php#92195
128
+         *
129
+         * @param array $array1 array one.
130
+         * @param array $array2 array two.
131
+         *
132
+         * @return  array $merged
133
+         * @since   3.5.7.11
134
+         * @author  harunbasic
135
+         * @access  private
136
+         */
137
+        public static function array_merge_recursive_distinct( array $array1, array $array2 ): array {
138
+            $merged = $array1;
139
+
140
+            foreach ( $array2 as $key => $value ) {
141
+
142
+                if ( is_array( $value ) && isset( $merged[ $key ] ) && is_array( $merged[ $key ] ) ) {
143
+                    $merged[ $key ] = self::array_merge_recursive_distinct( $merged[ $key ], $value );
144
+                } elseif ( is_numeric( $key ) && isset( $merged[ $key ] ) ) {
145
+                    $merged[] = $value;
146
+                } else {
147
+                    $merged[ $key ] = $value;
148
+                }
149
+            }
150
+
151
+            return $merged;
152
+        }
153
+
154
+        /**
155
+         * Records calling function.
156
+         *
157
+         * @param string $opt_name Panel opt_name.
158
+         */
159
+        public static function record_caller( string $opt_name = '' ) {
160
+            global $pagenow;
161
+
162
+            // phpcs:ignore WordPress.Security.NonceVerification
163
+            if ( ! ( 'options-general.php' === $pagenow && isset( $_GET['page'] ) && ( 'redux-framework' === $_GET['page'] || 'health-check' === $_GET['page'] ) ) ) {
164
+                return;
165
+            }
166
+
167
+            // phpcs:ignore WordPress.PHP.DevelopmentFunctions
168
+            $caller = debug_backtrace( DEBUG_BACKTRACE_IGNORE_ARGS, 2 )[1]['file'];
169
+
170
+            if ( ! empty( $caller ) && ! empty( $opt_name ) && class_exists( 'Redux_Core' ) ) {
171
+                if ( ! isset( Redux_Core::$callers[ $opt_name ] ) ) {
172
+                    Redux_Core::$callers[ $opt_name ] = array();
173
+                }
174
+
175
+                if ( strpos( $caller, 'class-redux-' ) !== false || strpos( $caller, 'redux-core/framework.php' ) ) {
176
+                    return;
177
+                }
178
+
179
+                if ( ! in_array( $caller, Redux_Core::$callers[ $opt_name ], true ) ) {
180
+                    Redux_Core::$callers[ $opt_name ][] = $caller;
181
+                }
182
+
183
+                if ( ! empty( self::$args[ $opt_name ]['callers'] ) && ! in_array( $caller, self::$args[ $opt_name ]['callers'], true ) ) {
184
+                    self::$args[ $opt_name ]['callers'][] = $caller;
185
+                }
186
+            }
187
+        }
188
+
189
+        /**
190
+         * Normalize path.
191
+         *
192
+         * @param string $path Path to normalize.
193
+         *
194
+         * @return string|string[]|null
195
+         */
196
+        public static function wp_normalize_path( string $path = '' ) {
197
+            if ( function_exists( 'wp_normalize_path' ) ) {
198
+                $path = wp_normalize_path( $path );
199
+            } else {
200
+                // Shim for pre WP 3.9.
201
+                $path = str_replace( '\\', '/', $path );
202
+                $path = preg_replace( '|(?<=.)/+|', '/', $path );
203
+
204
+                if ( ':' === substr( $path, 1, 1 ) ) {
205
+                    $path = ucfirst( $path );
206
+                }
207
+            }
208
+
209
+            return $path;
210
+        }
211
+
212
+        /**
213
+         * Action to add generator tag to page HEAD.
214
+         */
215
+        public static function generator() {
216
+            add_action( 'wp_head', array( 'Redux_Functions_Ex', 'meta_tag' ) );
217
+        }
218
+
219
+
220
+        /**
221
+         * Callback for wp_head hook to add meta tag.
222
+         */
223
+        public static function meta_tag() {
224
+            echo '<meta name="generator" content="Redux ' . esc_html( Redux_Core::$version ) . '" />';
225
+        }
226
+
227
+        /**
228
+         * Run URL through a ssl check.
229
+         *
230
+         * @param string $url URL to check.
231
+         *
232
+         * @return string
233
+         */
234
+        public static function verify_url_protocol( string $url ): string {
235
+            // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotValidated
236
+            $protocol = ! empty( $_SERVER['HTTPS'] ) && 'off' !== $_SERVER['HTTPS'] || ( ! empty( $_SERVER['SERVER_PORT'] ) && 443 === $_SERVER['SERVER_PORT'] ) ? 'https://' : 'http://';
237
+
238
+            if ( ! empty( $_SERVER['HTTP_X_FORWARDED_PROTO'] ) ) { // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotValidated
239
+                $new_protocol = sanitize_text_field( wp_unslash( $_SERVER['HTTP_X_FORWARDED_PROTO'] ) ) . '://'; // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotValidated
240
+                if ( 'http://' === $protocol && $new_protocol !== $protocol && false === strpos( $url, $new_protocol ) ) {
241
+                    $url = str_replace( $protocol, $new_protocol, $url );
242
+                }
243
+            }
244
+
245
+            return $url;
246
+        }
247
+
248
+        /**
249
+         * Check s.
250
+         *
251
+         * @access public
252
+         * @return bool
253
+         * @since  4.0.0
254
+         */
255
+        public static function s(): bool {
256
+            if ( ! get_option( 'redux_p' . 'ro_lic' . 'ense_key', false ) ) { // phpcs:ignore Generic.Strings.UnnecessaryStringConcat.Found
257
+                $s = get_option( 'redux_p' . 'ro_l' . 'icense_status', false ); // phpcs:ignore Generic.Strings.UnnecessaryStringConcat.Found
258
+
259
+                if ( in_array( $s, array( 'valid', 'site_inactive' ), true ) ) {
260
+                    return true;
261
+                }
262
+            }
263
+
264
+            return false;
265
+        }
266
+
267
+        /**
268
+         * Is file in theme.
269
+         *
270
+         * @param string $file File to check.
271
+         *
272
+         * @return bool
273
+         */
274
+        public static function file_in_theme( string $file ): bool {
275
+            $file_path = self::wp_normalize_path( dirname( $file ) );
276
+
277
+            if ( strpos( $file_path, self::wp_normalize_path( get_template_directory() ) ) !== false ) {
278
+                return true;
279
+            } elseif ( strpos( $file_path, self::wp_normalize_path( get_stylesheet_directory() ) ) !== false ) {
280
+                return true;
281
+            }
282
+
283
+            return false;
284
+        }
285
+
286
+        /**
287
+         * Is Redux embedded inside a plugin?
288
+         *
289
+         * @param string $file File to check.
290
+         *
291
+         * @return array|bool
292
+         */
293
+        public static function is_inside_plugin( string $file ) {
294
+            $file            = self::wp_normalize_path( $file );
295
+            $plugin_basename = self::wp_normalize_path( plugin_basename( $file ) );
296
+
297
+            if ( self::file_in_theme( $file ) ) {
298
+                return false;
299
+            }
300
+
301
+            if ( $plugin_basename !== $file ) {
302
+                $slug = explode( '/', $plugin_basename );
303
+                $slug = $slug[0];
304
+
305
+                return array(
306
+                    'slug'      => $slug,
307
+                    'basename'  => $plugin_basename,
308
+                    'path'      => $file,
309
+                    'url'       => self::verify_url_protocol( plugins_url( $plugin_basename ) ),
310
+                    'real_path' => self::wp_normalize_path( dirname( realpath( $file ) ) ),
311
+                );
312
+            }
313
+
314
+            return false;
315
+        }
316
+
317
+        /**
318
+         * Is Redux embedded in a theme?
319
+         *
320
+         * @param string $file File to check.
321
+         *
322
+         * @return array|bool
323
+         */
324
+        public static function is_inside_theme( string $file = '' ) {
325
+
326
+            if ( ! self::file_in_theme( $file ) ) {
327
+                return false;
328
+            }
329
+
330
+            $theme_paths = array(
331
+                self::wp_normalize_path( get_template_directory() )   => get_template_directory_uri(),
332
+                // parent.
333
+                self::wp_normalize_path( get_stylesheet_directory() ) => get_stylesheet_directory_uri(),
334
+                // child.
335
+            );
336
+
337
+            $theme_paths = array_unique( $theme_paths );
338
+            $file_path   = self::wp_normalize_path( $file );
339
+
340
+            $filename = explode( DIRECTORY_SEPARATOR, $file );
341
+
342
+            end( $filename );
343
+
344
+            $filename = prev( $filename );
345
+
346
+            foreach ( $theme_paths as $theme_path => $url ) {
347
+                $real_path = self::wp_normalize_path( realpath( $theme_path ) );
348
+
349
+                if ( empty( $real_path ) ) {
350
+                    continue;
351
+                }
352
+
353
+                if ( strpos( $file_path, $real_path ) !== false ) {
354
+                    $slug             = explode( '/', $theme_path );
355
+                    $slug             = end( $slug );
356
+                    $relative_path    = explode( $slug . '/', dirname( $file_path ) );
357
+                    $relative_path    = $relative_path[1];
358
+                    $data             = array(
359
+                        'slug'      => $slug,
360
+                        'path'      => trailingslashit( trailingslashit( $theme_path ) . $relative_path ) . $filename,
361
+                        'real_path' => trailingslashit( trailingslashit( $real_path ) . $relative_path ) . $filename,
362
+                        'url'       => self::verify_url_protocol( trailingslashit( trailingslashit( $url ) . $relative_path ) . $filename ),
363
+                        'basename'  => trailingslashit( $slug ) . trailingslashit( $relative_path ) . $filename,
364
+                    );
365
+                    $data['realpath'] = $data['real_path'];  // Shim for old extensions.
366
+
367
+                    if ( count( $theme_paths ) > 1 ) {
368
+                        $key = array_search( $theme_path, $theme_paths, true );
369
+
370
+                        if ( false !== $key ) {
371
+                            unset( $theme_paths[ $key ] );
372
+                        }
373
+
374
+                        $theme_paths_end = end( $theme_paths );
375
+                        $parent_slug_end = explode( '/', $theme_paths_end );
376
+                        $parent_slug_end = end( $parent_slug_end );
377
+
378
+                        $data['parent_slug'] = $parent_slug_end;
379
+                    }
380
+
381
+                    return $data;
382
+                }
383
+            }
384
+
385
+            return false;
386
+        }
387
+
388
+        /**
389
+         * Used to merge two deep arrays.
390
+         *
391
+         * @param array $a First array to deeply merge.
392
+         * @param array $b Second array to deeply merge.
393
+         *
394
+         * @return    array - Deep merge of the two arrays.
395
+         */
396
+        public static function nested_wp_parse_args( array &$a, array $b ): array {
397
+            $result = $b;
398
+
399
+            foreach ( $a as $k => &$v ) {
400
+                if ( is_array( $v ) && isset( $result[ $k ] ) ) {
401
+                    $result[ $k ] = self::nested_wp_parse_args( $v, $result[ $k ] );
402
+                } else {
403
+                    $result[ $k ] = $v;
404
+                }
405
+            }
406
+
407
+            return $result;
408
+        }
409
+
410
+        /**
411
+         * AJAX callback key
412
+         */
413
+        public static function hash_key(): string {
414
+            $key  = defined( 'AUTH_KEY' ) ? AUTH_KEY : get_site_url();
415
+            $key .= defined( 'SECURE_AUTH_KEY' ) ? SECURE_AUTH_KEY : '';
416
+
417
+            return $key;
418
+        }
419
+
420
+        /**
421
+         * Register a class path to be autoloaded.
422
+         * Registers a namespace to be autoloaded from a given path, using the
423
+         * WordPress/HM-style filenames (`class-{name}.php`).
424
+         *
425
+         * @link https://engineering.hmn.md/standards/style/php/#file-naming
426
+         *
427
+         * @param string $prefix Prefix to autoload from.
428
+         * @param string $path   Path to validate.
429
+         */
430
+        public static function register_class_path( string $prefix = '', string $path = '' ) {
431
+            if ( ! class_exists( 'Redux_Autoloader' ) ) {
432
+                require_once Redux_Path::get_path( '/inc/classes/class-redux-autoloader.php' );
433
+            }
434
+
435
+            $loader = new Redux_Autoloader( $prefix, $path );
436
+
437
+            spl_autoload_register( array( $loader, 'load' ) );
438
+        }
439
+
440
+        /**
441
+         * Check if a string starts with a string.
442
+         *
443
+         * @param string $haystack Full string.
444
+         * @param string $needle   String to check if it starts with.
445
+         *
446
+         * @return bool
447
+         */
448
+        public static function string_starts_with( string $haystack, string $needle ): bool {
449
+            $length = strlen( $needle );
450
+
451
+            return substr( $haystack, 0, $length ) === $needle;
452
+        }
453
+
454
+        /**
455
+         * Check if a string ends with a string.
456
+         *
457
+         * @param string $haystack Full string.
458
+         * @param string $needle   String to check if it starts with.
459
+         *
460
+         * @return bool
461
+         */
462
+        public static function string_ends_with( string $haystack, string $needle ): bool {
463
+            $length = strlen( $needle );
464
+
465
+            if ( ! $length ) {
466
+                return true;
467
+            }
468
+
469
+            return substr( $haystack, - $length ) === $needle;
470
+        }
471
+
472
+        /**
473
+         * Is plugin active.
474
+         *
475
+         * @param string $name Plugin name.
476
+         *
477
+         * @return bool
478
+         */
479
+        public static function is_plugin_active( string $name ): bool {
480
+            // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals -- active_plugins is a WP hook.
481
+            if ( in_array( $name . '/' . $name . '.php', apply_filters( 'active_plugins', get_option( 'active_plugins' ) ), true ) ) {
482
+                return true;
483
+            }
484
+
485
+            return false;
486
+        }
487
+    }
488 488
 }
Please login to merge, or discard this patch.
redux-core/inc/classes/class-redux-args.php 1 patch
Indentation   +386 added lines, -386 removed lines patch added patch discarded remove patch
@@ -11,390 +11,390 @@
 block discarded – undo
11 11
 
12 12
 if ( ! class_exists( 'Redux_Args', false ) ) {
13 13
 
14
-	/**
15
-	 * Class Redux_Args
16
-	 */
17
-	class Redux_Args {
18
-
19
-		/**
20
-		 * Returns entire arguments array.
21
-		 *
22
-		 * @var array|mixed
23
-		 */
24
-		public $get = array();
25
-
26
-		/**
27
-		 * ReduxFramework object.
28
-		 *
29
-		 * @var ReduxFramework|null
30
-		 */
31
-		private ?ReduxFramework $parent;
32
-
33
-		/**
34
-		 * Switch to omit social icons if dev_mode is set to true and Redux defaults are used.
35
-		 *
36
-		 * @var bool
37
-		 */
38
-		public bool $omit_icons = false;
39
-
40
-		/**
41
-		 * Switch to omit support menu items if dev_mode is set to true and redux defaults are used.
42
-		 *
43
-		 * @var bool
44
-		 */
45
-		public bool $omit_items = false;
46
-
47
-		/**
48
-		 * Flag to force dev_mod to true if in localhost or WP_DEBUG is set to true.
49
-		 *
50
-		 * @var bool
51
-		 */
52
-		public bool $dev_mode_forced = false;
53
-
54
-		/**
55
-		 * Redux_Args constructor.
56
-		 *
57
-		 * @param ReduxFramework $redux ReduxFramework object.
58
-		 * @param array          $args  Global arguments array.
59
-		 */
60
-		public function __construct( ReduxFramework $redux, array $args ) {
61
-			$this->parent = $redux;
62
-
63
-			$default = array(
64
-				'opt_name'                         => '',
65
-				'last_tab'                         => '',
66
-				'menu_icon'                        => '',
67
-				'menu_title'                       => '',
68
-				'page_title'                       => '',
69
-				'page_slug'                        => '',
70
-				'page_permissions'                 => 'manage_options',
71
-				'menu_type'                        => 'menu',
72
-				'page_parent'                      => 'themes.php',
73
-				'page_priority'                    => null,
74
-				'allow_sub_menu'                   => true,
75
-				'save_defaults'                    => true,
76
-				'footer_credit'                    => '',
77
-				'async_typography'                 => false,
78
-				'disable_google_fonts_link'        => false,
79
-				'class'                            => '',
80
-				'admin_bar'                        => true,
81
-				'admin_bar_priority'               => 999,
82
-				'admin_bar_icon'                   => '',
83
-				'help_tabs'                        => array(),
84
-				'help_sidebar'                     => '',
85
-				'database'                         => '',
86
-				'customizer'                       => false,
87
-				'global_variable'                  => '',
88
-				'output'                           => true,
89
-				'output_variables_prefix'          => '--',
90
-				'compiler_output_variables_prefix' => '$',
91
-				'compiler'                         => true,
92
-				'output_tag'                       => true,
93
-				'output_location'                  => array( 'frontend' ),
94
-				'transient_time'                   => '',
95
-				'default_show'                     => false,
96
-				'default_mark'                     => '',
97
-				'disable_save_warn'                => false,
98
-				'open_expanded'                    => false,
99
-				'hide_expand'                      => false,
100
-				'network_admin'                    => false,
101
-				'network_sites'                    => true,
102
-				'hide_reset'                       => false,
103
-				'hide_save'                        => false,
104
-				'hints'                            => array(
105
-					'icon'          => 'el el-question-sign',
106
-					'icon_position' => 'right',
107
-					'icon_color'    => 'lightgray',
108
-					'icon_size'     => 'normal',
109
-					'tip_style'     => array(
110
-						'color'   => 'light',
111
-						'shadow'  => true,
112
-						'rounded' => false,
113
-						'style'   => '',
114
-					),
115
-					'tip_position'  => array(
116
-						'my' => 'top_left',
117
-						'at' => 'bottom_right',
118
-					),
119
-					'tip_effect'    => array(
120
-						'show' => array(
121
-							'effect'   => 'slide',
122
-							'duration' => '500',
123
-							'event'    => 'mouseover',
124
-						),
125
-						'hide' => array(
126
-							'effect'   => 'fade',
127
-							'duration' => '500',
128
-							'event'    => 'click mouseleave',
129
-						),
130
-					),
131
-				),
132
-				'font_weights'                     => array(
133
-					array(
134
-						'id'   => '400',
135
-						'name' => __( 'Regular 400', 'redux-framework' ),
136
-					),
137
-					array(
138
-						'id'   => '400italic',
139
-						'name' => __( 'Regular 400 Italic', 'redux-framework' ),
140
-					),
141
-					array(
142
-						'id'   => '700',
143
-						'name' => __( 'Bold 700', 'redux-framework' ),
144
-					),
145
-					array(
146
-						'id'   => '700italic',
147
-						'name' => __( 'Bold 700 Italic', 'redux-framework' ),
148
-					),
149
-				),
150
-				'show_import_export'               => true,
151
-				'show_options_object'              => true,
152
-				'dev_mode'                         => true,
153
-				'templates_path'                   => '',
154
-				'ajax_save'                        => true,
155
-				'use_cdn'                          => true,
156
-				'cdn_check_time'                   => 1440,
157
-				'options_api'                      => true,
158
-				'allow_tracking'                   => true,
159
-				'admin_theme'                      => 'wp',
160
-				'elusive_frontend'                 => false,
161
-				'fontawesome_frontend'             => false,
162
-				'flyout_submenus'                  => true,
163
-				'font_display'                     => 'swap', // block|swap|fallback|optional.
164
-				'load_on_cron'                     => false,
165
-				'search'                           => false,
166
-				'widget_area'                      => false,
167
-				'custom_fonts'                     => true,
168
-			);
169
-
170
-			$args = Redux_Functions::parse_args( $args, $default );
171
-
172
-			$args = $this->args( $args );
173
-
174
-			$args = $this->default_cleanup( $args );
175
-
176
-			if ( ! in_array( $args['font_display'], array( 'block', 'swap', 'fallback', 'optional' ), true ) ) {
177
-				$args['font_display'] = 'swap';
178
-			}
179
-
180
-			if ( isset( $args['async_typography'] ) && $args['async_typography'] ) {
181
-				$args['async_typography'] = false;
182
-			}
183
-
184
-			$this->get = $args;
185
-
186
-			$this->parent->args = $args;
187
-
188
-			if ( 'redux_extensions_demo' !== $args['opt_name'] && 'redux_demo' !== $args['opt_name'] ) {
189
-				$this->change_demo_defaults( $args );
190
-			}
191
-		}
192
-
193
-		/**
194
-		 * Builds and sanitizes a global args array.
195
-		 *
196
-		 * @param     array $args Global args.
197
-		 *
198
-		 * @return array
199
-		 */
200
-		private function args( array $args ): array {
201
-			$args = $this->no_errors_please( $args );
202
-
203
-			$this->parent->old_opt_name = $args['opt_name'];
204
-
205
-			$args = $this->filters( $args );
206
-
207
-			if ( ! function_exists( 'wp_rand' ) ) {
208
-				require_once ABSPATH . '/wp-includes/pluggable.php';
209
-			}
210
-
211
-			if ( $args['opt_name'] === $this->parent->old_opt_name ) {
212
-				$this->parent->old_opt_name = null;
213
-				unset( $this->parent->old_opt_name );
214
-			}
215
-
216
-			// Do not save the defaults if we're on a live preview!
217
-			if ( 'customize' === $GLOBALS['pagenow'] && isset( $_GET['customize_theme'] ) && ! empty( $_GET['customize_theme'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification
218
-				$args['save_defaults'] = false;
219
-			}
220
-
221
-			return $this->shim( $args );
222
-		}
223
-
224
-		/**
225
-		 * Apply filters to arg data.
226
-		 *
227
-		 * @param     array $args Global args.
228
-		 *
229
-		 * @return mixed|void
230
-		 */
231
-		private function filters( array $args ) {
232
-			/**
233
-			 * Filter 'redux/args/{opt_name}'
234
-			 *
235
-			 * @param     array     $args ReduxFramework configuration
236
-			 */
237
-
238
-			// phpcs:ignore WordPress.NamingConventions.ValidHookName
239
-			$args = apply_filters( "redux/args/{$args['opt_name']}", $args );
240
-
241
-			/**
242
-			 * Filter 'redux/options/{opt_name}/args'
243
-			 *
244
-			 * @param     array     $args ReduxFramework configuration
245
-			 */
246
-
247
-			// phpcs:ignore WordPress.NamingConventions.ValidHookName
248
-			return apply_filters( "redux/options/{$args['opt_name']}/args", $args );
249
-		}
250
-
251
-		/**
252
-		 * Sanitize args that should not be empty.
253
-		 *
254
-		 * @param     array $args Global args.
255
-		 *
256
-		 * @return array
257
-		 */
258
-		private function no_errors_please( array $args ): array {
259
-			if ( empty( $args['transient_time'] ) ) {
260
-				$args['transient_time'] = 60 * MINUTE_IN_SECONDS;
261
-			}
262
-
263
-			if ( empty( $args['footer_credit'] ) ) {
264
-
265
-				$footer_text = sprintf(
266
-				/* translators: 1: Redux, 2: Link to plugin review */
267
-					__( 'Enjoyed %1$s? Please leave us a %2$s. We really appreciate your support!', 'redux-framework' ),
268
-					'<strong>' . __( 'Redux', 'redux-framework' ) . '</strong>',
269
-					'<a href="https://wordpress.org/support/plugin/redux-framework/reviews/#new-post" target="_blank">review</a>'
270
-				);
271
-				$args['footer_credit'] = '<span id="footer-thankyou">' . $footer_text . '</span>';
272
-			}
273
-
274
-			if ( empty( $args['menu_title'] ) ) {
275
-				$args['menu_title'] = esc_html__( 'Options', 'redux-framework' );
276
-			}
277
-
278
-			if ( empty( $args['page_title'] ) ) {
279
-				$args['page_title'] = esc_html__( 'Options', 'redux-framework' );
280
-			}
281
-
282
-			// Auto creates the page_slug appropriately.
283
-			if ( empty( $args['page_slug'] ) ) {
284
-				if ( ! empty( $args['display_name'] ) ) {
285
-					$args['page_slug'] = sanitize_html_class( $args['display_name'] );
286
-				} elseif ( ! empty( $args['page_title'] ) ) {
287
-					$args['page_slug'] = sanitize_html_class( $args['page_title'] );
288
-				} elseif ( ! empty( $args['menu_title'] ) ) {
289
-					$args['page_slug'] = sanitize_html_class( $args['menu_title'] );
290
-				} else {
291
-					$args['page_slug'] = str_replace( '-', '_', $args['opt_name'] );
292
-				}
293
-			}
294
-
295
-			return $args;
296
-		}
297
-
298
-		/**
299
-		 * Shims for much older v3 configs.
300
-		 *
301
-		 * @param     array $args Global args.
302
-		 *
303
-		 * @return array
304
-		 */
305
-		private function shim( array $args ): array {
306
-			/**
307
-			 * SHIM SECTION
308
-			 * Old variables and ways of doing things that need correcting.  ;)
309
-			 * */
310
-			// Variable name change.
311
-			if ( ! empty( $args['page_cap'] ) ) {
312
-				$args['page_permissions'] = $args['page_cap'];
313
-				unset( $args['page_cap'] );
314
-			}
315
-
316
-			if ( ! empty( $args['page_position'] ) ) {
317
-				$args['page_priority'] = $args['page_position'];
318
-				unset( $args['page_position'] );
319
-			}
320
-
321
-			if ( ! empty( $args['page_type'] ) ) {
322
-				$args['menu_type'] = $args['page_type'];
323
-				unset( $args['page_type'] );
324
-			}
325
-
326
-			return $args;
327
-		}
328
-
329
-		/**
330
-		 * Verify to see if dev has bothered to change admin bar links and share icons from demo data to their own.
331
-		 *
332
-		 * @param array $args Global args.
333
-		 */
334
-		private function change_demo_defaults( array $args ) {
335
-			if ( $args['dev_mode'] || true === Redux_Helpers::is_local_host() ) {
336
-				if ( ! empty( $args['admin_bar_links'] ) ) {
337
-					foreach ( $args['admin_bar_links'] as $arr ) {
338
-						if ( is_array( $arr ) && ! empty( $arr ) ) {
339
-							foreach ( $arr as $y ) {
340
-								if ( strpos( Redux_Core::strtolower( $y ), 'redux' ) !== false ) {
341
-									$this->omit_items = true;
342
-									break;
343
-								}
344
-							}
345
-						}
346
-					}
347
-				}
348
-
349
-				if ( ! empty( $args['share_icons'] ) ) {
350
-					foreach ( $args['share_icons'] as $arr ) {
351
-						if ( is_array( $arr ) && ! empty( $arr ) ) {
352
-							foreach ( $arr as $y ) {
353
-								if ( strpos( Redux_Core::strtolower( $y ), 'redux' ) !== false ) {
354
-									$this->omit_icons = true;
355
-								}
356
-							}
357
-						}
358
-					}
359
-				}
360
-			}
361
-		}
362
-
363
-		/**
364
-		 * Fix other arg criteria that sometimes gets hosed up.
365
-		 *
366
-		 * @param array $args Global args.
367
-		 *
368
-		 * @return array
369
-		 * @noinspection PhpStrictComparisonWithOperandsOfDifferentTypesInspection
370
-		 */
371
-		private function default_cleanup( array $args ): array {
372
-
373
-			// Fix the global variable name.
374
-			if ( '' === $args['global_variable'] && false !== $args['global_variable'] ) {
375
-				$args['global_variable'] = str_replace( '-', '_', $args['opt_name'] );
376
-			}
377
-
378
-			if ( isset( $args['customizer_only'] ) && $args['customizer_only'] ) {
379
-				$args['menu_type']      = 'hidden';
380
-				$args['customizer']     = true;
381
-				$args['admin_bar']      = false;
382
-				$args['allow_sub_menu'] = false;
383
-			}
384
-
385
-			// Check if the Airplane Mode plugin is installed.
386
-			if ( class_exists( 'Airplane_Mode_Core' ) ) {
387
-				$airplane = Airplane_Mode_Core::getInstance();
388
-				if ( method_exists( $airplane, 'enabled' ) ) {
389
-					if ( $airplane->enabled() ) {
390
-						$args['use_cdn'] = false;
391
-					}
392
-				} elseif ( 'on' === $airplane->check_status() ) {
393
-					$args['use_cdn'] = false;
394
-				}
395
-			}
396
-
397
-			return $args;
398
-		}
399
-	}
14
+    /**
15
+     * Class Redux_Args
16
+     */
17
+    class Redux_Args {
18
+
19
+        /**
20
+         * Returns entire arguments array.
21
+         *
22
+         * @var array|mixed
23
+         */
24
+        public $get = array();
25
+
26
+        /**
27
+         * ReduxFramework object.
28
+         *
29
+         * @var ReduxFramework|null
30
+         */
31
+        private ?ReduxFramework $parent;
32
+
33
+        /**
34
+         * Switch to omit social icons if dev_mode is set to true and Redux defaults are used.
35
+         *
36
+         * @var bool
37
+         */
38
+        public bool $omit_icons = false;
39
+
40
+        /**
41
+         * Switch to omit support menu items if dev_mode is set to true and redux defaults are used.
42
+         *
43
+         * @var bool
44
+         */
45
+        public bool $omit_items = false;
46
+
47
+        /**
48
+         * Flag to force dev_mod to true if in localhost or WP_DEBUG is set to true.
49
+         *
50
+         * @var bool
51
+         */
52
+        public bool $dev_mode_forced = false;
53
+
54
+        /**
55
+         * Redux_Args constructor.
56
+         *
57
+         * @param ReduxFramework $redux ReduxFramework object.
58
+         * @param array          $args  Global arguments array.
59
+         */
60
+        public function __construct( ReduxFramework $redux, array $args ) {
61
+            $this->parent = $redux;
62
+
63
+            $default = array(
64
+                'opt_name'                         => '',
65
+                'last_tab'                         => '',
66
+                'menu_icon'                        => '',
67
+                'menu_title'                       => '',
68
+                'page_title'                       => '',
69
+                'page_slug'                        => '',
70
+                'page_permissions'                 => 'manage_options',
71
+                'menu_type'                        => 'menu',
72
+                'page_parent'                      => 'themes.php',
73
+                'page_priority'                    => null,
74
+                'allow_sub_menu'                   => true,
75
+                'save_defaults'                    => true,
76
+                'footer_credit'                    => '',
77
+                'async_typography'                 => false,
78
+                'disable_google_fonts_link'        => false,
79
+                'class'                            => '',
80
+                'admin_bar'                        => true,
81
+                'admin_bar_priority'               => 999,
82
+                'admin_bar_icon'                   => '',
83
+                'help_tabs'                        => array(),
84
+                'help_sidebar'                     => '',
85
+                'database'                         => '',
86
+                'customizer'                       => false,
87
+                'global_variable'                  => '',
88
+                'output'                           => true,
89
+                'output_variables_prefix'          => '--',
90
+                'compiler_output_variables_prefix' => '$',
91
+                'compiler'                         => true,
92
+                'output_tag'                       => true,
93
+                'output_location'                  => array( 'frontend' ),
94
+                'transient_time'                   => '',
95
+                'default_show'                     => false,
96
+                'default_mark'                     => '',
97
+                'disable_save_warn'                => false,
98
+                'open_expanded'                    => false,
99
+                'hide_expand'                      => false,
100
+                'network_admin'                    => false,
101
+                'network_sites'                    => true,
102
+                'hide_reset'                       => false,
103
+                'hide_save'                        => false,
104
+                'hints'                            => array(
105
+                    'icon'          => 'el el-question-sign',
106
+                    'icon_position' => 'right',
107
+                    'icon_color'    => 'lightgray',
108
+                    'icon_size'     => 'normal',
109
+                    'tip_style'     => array(
110
+                        'color'   => 'light',
111
+                        'shadow'  => true,
112
+                        'rounded' => false,
113
+                        'style'   => '',
114
+                    ),
115
+                    'tip_position'  => array(
116
+                        'my' => 'top_left',
117
+                        'at' => 'bottom_right',
118
+                    ),
119
+                    'tip_effect'    => array(
120
+                        'show' => array(
121
+                            'effect'   => 'slide',
122
+                            'duration' => '500',
123
+                            'event'    => 'mouseover',
124
+                        ),
125
+                        'hide' => array(
126
+                            'effect'   => 'fade',
127
+                            'duration' => '500',
128
+                            'event'    => 'click mouseleave',
129
+                        ),
130
+                    ),
131
+                ),
132
+                'font_weights'                     => array(
133
+                    array(
134
+                        'id'   => '400',
135
+                        'name' => __( 'Regular 400', 'redux-framework' ),
136
+                    ),
137
+                    array(
138
+                        'id'   => '400italic',
139
+                        'name' => __( 'Regular 400 Italic', 'redux-framework' ),
140
+                    ),
141
+                    array(
142
+                        'id'   => '700',
143
+                        'name' => __( 'Bold 700', 'redux-framework' ),
144
+                    ),
145
+                    array(
146
+                        'id'   => '700italic',
147
+                        'name' => __( 'Bold 700 Italic', 'redux-framework' ),
148
+                    ),
149
+                ),
150
+                'show_import_export'               => true,
151
+                'show_options_object'              => true,
152
+                'dev_mode'                         => true,
153
+                'templates_path'                   => '',
154
+                'ajax_save'                        => true,
155
+                'use_cdn'                          => true,
156
+                'cdn_check_time'                   => 1440,
157
+                'options_api'                      => true,
158
+                'allow_tracking'                   => true,
159
+                'admin_theme'                      => 'wp',
160
+                'elusive_frontend'                 => false,
161
+                'fontawesome_frontend'             => false,
162
+                'flyout_submenus'                  => true,
163
+                'font_display'                     => 'swap', // block|swap|fallback|optional.
164
+                'load_on_cron'                     => false,
165
+                'search'                           => false,
166
+                'widget_area'                      => false,
167
+                'custom_fonts'                     => true,
168
+            );
169
+
170
+            $args = Redux_Functions::parse_args( $args, $default );
171
+
172
+            $args = $this->args( $args );
173
+
174
+            $args = $this->default_cleanup( $args );
175
+
176
+            if ( ! in_array( $args['font_display'], array( 'block', 'swap', 'fallback', 'optional' ), true ) ) {
177
+                $args['font_display'] = 'swap';
178
+            }
179
+
180
+            if ( isset( $args['async_typography'] ) && $args['async_typography'] ) {
181
+                $args['async_typography'] = false;
182
+            }
183
+
184
+            $this->get = $args;
185
+
186
+            $this->parent->args = $args;
187
+
188
+            if ( 'redux_extensions_demo' !== $args['opt_name'] && 'redux_demo' !== $args['opt_name'] ) {
189
+                $this->change_demo_defaults( $args );
190
+            }
191
+        }
192
+
193
+        /**
194
+         * Builds and sanitizes a global args array.
195
+         *
196
+         * @param     array $args Global args.
197
+         *
198
+         * @return array
199
+         */
200
+        private function args( array $args ): array {
201
+            $args = $this->no_errors_please( $args );
202
+
203
+            $this->parent->old_opt_name = $args['opt_name'];
204
+
205
+            $args = $this->filters( $args );
206
+
207
+            if ( ! function_exists( 'wp_rand' ) ) {
208
+                require_once ABSPATH . '/wp-includes/pluggable.php';
209
+            }
210
+
211
+            if ( $args['opt_name'] === $this->parent->old_opt_name ) {
212
+                $this->parent->old_opt_name = null;
213
+                unset( $this->parent->old_opt_name );
214
+            }
215
+
216
+            // Do not save the defaults if we're on a live preview!
217
+            if ( 'customize' === $GLOBALS['pagenow'] && isset( $_GET['customize_theme'] ) && ! empty( $_GET['customize_theme'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification
218
+                $args['save_defaults'] = false;
219
+            }
220
+
221
+            return $this->shim( $args );
222
+        }
223
+
224
+        /**
225
+         * Apply filters to arg data.
226
+         *
227
+         * @param     array $args Global args.
228
+         *
229
+         * @return mixed|void
230
+         */
231
+        private function filters( array $args ) {
232
+            /**
233
+             * Filter 'redux/args/{opt_name}'
234
+             *
235
+             * @param     array     $args ReduxFramework configuration
236
+             */
237
+
238
+            // phpcs:ignore WordPress.NamingConventions.ValidHookName
239
+            $args = apply_filters( "redux/args/{$args['opt_name']}", $args );
240
+
241
+            /**
242
+             * Filter 'redux/options/{opt_name}/args'
243
+             *
244
+             * @param     array     $args ReduxFramework configuration
245
+             */
246
+
247
+            // phpcs:ignore WordPress.NamingConventions.ValidHookName
248
+            return apply_filters( "redux/options/{$args['opt_name']}/args", $args );
249
+        }
250
+
251
+        /**
252
+         * Sanitize args that should not be empty.
253
+         *
254
+         * @param     array $args Global args.
255
+         *
256
+         * @return array
257
+         */
258
+        private function no_errors_please( array $args ): array {
259
+            if ( empty( $args['transient_time'] ) ) {
260
+                $args['transient_time'] = 60 * MINUTE_IN_SECONDS;
261
+            }
262
+
263
+            if ( empty( $args['footer_credit'] ) ) {
264
+
265
+                $footer_text = sprintf(
266
+                /* translators: 1: Redux, 2: Link to plugin review */
267
+                    __( 'Enjoyed %1$s? Please leave us a %2$s. We really appreciate your support!', 'redux-framework' ),
268
+                    '<strong>' . __( 'Redux', 'redux-framework' ) . '</strong>',
269
+                    '<a href="https://wordpress.org/support/plugin/redux-framework/reviews/#new-post" target="_blank">review</a>'
270
+                );
271
+                $args['footer_credit'] = '<span id="footer-thankyou">' . $footer_text . '</span>';
272
+            }
273
+
274
+            if ( empty( $args['menu_title'] ) ) {
275
+                $args['menu_title'] = esc_html__( 'Options', 'redux-framework' );
276
+            }
277
+
278
+            if ( empty( $args['page_title'] ) ) {
279
+                $args['page_title'] = esc_html__( 'Options', 'redux-framework' );
280
+            }
281
+
282
+            // Auto creates the page_slug appropriately.
283
+            if ( empty( $args['page_slug'] ) ) {
284
+                if ( ! empty( $args['display_name'] ) ) {
285
+                    $args['page_slug'] = sanitize_html_class( $args['display_name'] );
286
+                } elseif ( ! empty( $args['page_title'] ) ) {
287
+                    $args['page_slug'] = sanitize_html_class( $args['page_title'] );
288
+                } elseif ( ! empty( $args['menu_title'] ) ) {
289
+                    $args['page_slug'] = sanitize_html_class( $args['menu_title'] );
290
+                } else {
291
+                    $args['page_slug'] = str_replace( '-', '_', $args['opt_name'] );
292
+                }
293
+            }
294
+
295
+            return $args;
296
+        }
297
+
298
+        /**
299
+         * Shims for much older v3 configs.
300
+         *
301
+         * @param     array $args Global args.
302
+         *
303
+         * @return array
304
+         */
305
+        private function shim( array $args ): array {
306
+            /**
307
+             * SHIM SECTION
308
+             * Old variables and ways of doing things that need correcting.  ;)
309
+             * */
310
+            // Variable name change.
311
+            if ( ! empty( $args['page_cap'] ) ) {
312
+                $args['page_permissions'] = $args['page_cap'];
313
+                unset( $args['page_cap'] );
314
+            }
315
+
316
+            if ( ! empty( $args['page_position'] ) ) {
317
+                $args['page_priority'] = $args['page_position'];
318
+                unset( $args['page_position'] );
319
+            }
320
+
321
+            if ( ! empty( $args['page_type'] ) ) {
322
+                $args['menu_type'] = $args['page_type'];
323
+                unset( $args['page_type'] );
324
+            }
325
+
326
+            return $args;
327
+        }
328
+
329
+        /**
330
+         * Verify to see if dev has bothered to change admin bar links and share icons from demo data to their own.
331
+         *
332
+         * @param array $args Global args.
333
+         */
334
+        private function change_demo_defaults( array $args ) {
335
+            if ( $args['dev_mode'] || true === Redux_Helpers::is_local_host() ) {
336
+                if ( ! empty( $args['admin_bar_links'] ) ) {
337
+                    foreach ( $args['admin_bar_links'] as $arr ) {
338
+                        if ( is_array( $arr ) && ! empty( $arr ) ) {
339
+                            foreach ( $arr as $y ) {
340
+                                if ( strpos( Redux_Core::strtolower( $y ), 'redux' ) !== false ) {
341
+                                    $this->omit_items = true;
342
+                                    break;
343
+                                }
344
+                            }
345
+                        }
346
+                    }
347
+                }
348
+
349
+                if ( ! empty( $args['share_icons'] ) ) {
350
+                    foreach ( $args['share_icons'] as $arr ) {
351
+                        if ( is_array( $arr ) && ! empty( $arr ) ) {
352
+                            foreach ( $arr as $y ) {
353
+                                if ( strpos( Redux_Core::strtolower( $y ), 'redux' ) !== false ) {
354
+                                    $this->omit_icons = true;
355
+                                }
356
+                            }
357
+                        }
358
+                    }
359
+                }
360
+            }
361
+        }
362
+
363
+        /**
364
+         * Fix other arg criteria that sometimes gets hosed up.
365
+         *
366
+         * @param array $args Global args.
367
+         *
368
+         * @return array
369
+         * @noinspection PhpStrictComparisonWithOperandsOfDifferentTypesInspection
370
+         */
371
+        private function default_cleanup( array $args ): array {
372
+
373
+            // Fix the global variable name.
374
+            if ( '' === $args['global_variable'] && false !== $args['global_variable'] ) {
375
+                $args['global_variable'] = str_replace( '-', '_', $args['opt_name'] );
376
+            }
377
+
378
+            if ( isset( $args['customizer_only'] ) && $args['customizer_only'] ) {
379
+                $args['menu_type']      = 'hidden';
380
+                $args['customizer']     = true;
381
+                $args['admin_bar']      = false;
382
+                $args['allow_sub_menu'] = false;
383
+            }
384
+
385
+            // Check if the Airplane Mode plugin is installed.
386
+            if ( class_exists( 'Airplane_Mode_Core' ) ) {
387
+                $airplane = Airplane_Mode_Core::getInstance();
388
+                if ( method_exists( $airplane, 'enabled' ) ) {
389
+                    if ( $airplane->enabled() ) {
390
+                        $args['use_cdn'] = false;
391
+                    }
392
+                } elseif ( 'on' === $airplane->check_status() ) {
393
+                    $args['use_cdn'] = false;
394
+                }
395
+            }
396
+
397
+            return $args;
398
+        }
399
+    }
400 400
 }
Please login to merge, or discard this patch.
redux-core/inc/classes/class-redux-options-constructor.php 2 patches
Indentation   +1031 added lines, -1031 removed lines patch added patch discarded remove patch
@@ -12,1035 +12,1035 @@
 block discarded – undo
12 12
 
13 13
 if ( ! class_exists( 'Redux_Options_Constructor', false ) ) {
14 14
 
15
-	/**
16
-	 * Class Redux_Options
17
-	 */
18
-	class Redux_Options_Constructor extends Redux_Class {
19
-
20
-		/**
21
-		 * Array to hold single panel data.
22
-		 *
23
-		 * @var array
24
-		 */
25
-		public array $no_panel = array();
26
-
27
-		/**
28
-		 * Array to hold single panel sections.
29
-		 *
30
-		 * @var array
31
-		 */
32
-		private array $no_panel_section = array();
33
-
34
-		/**
35
-		 * Array to hold hidden fields.
36
-		 *
37
-		 * @var array
38
-		 */
39
-		private array $hidden_perm_fields = array();
40
-
41
-		/**
42
-		 * Array to hold hidden sections.
43
-		 *
44
-		 * @var array
45
-		 */
46
-		public array $hidden_perm_sections = array();
47
-
48
-		/**
49
-		 * Array to hold default options.
50
-		 *
51
-		 * @var array
52
-		 */
53
-		private array $options_defaults = array();
54
-
55
-		/**
56
-		 * Redux_Options constructor.
57
-		 *
58
-		 * @param object $redux ReduxFramework pointer.
59
-		 */
60
-		public function __construct( $redux ) {
61
-			parent::__construct( $redux );
62
-
63
-			add_action( 'admin_init', array( $this, 'register' ) );
64
-		}
65
-
66
-		/**
67
-		 * If we switch language in wpml the id of the post/page selected will be in the wrong language
68
-		 * So it won't appear as selected in the list of options and will be lost on next save, this fixes this by translating this id
69
-		 * Bonus it also gives the user the id of the post in the right language when they retrieve it.
70
-		 * The recursion allows for it to work in a repeatable field.
71
-		 *
72
-		 * @param array $sections       Sections array.
73
-		 * @param array $options_values Values array.
74
-		 */
75
-		private function translate_data_field_recursive( array $sections, array &$options_values ) {
76
-			foreach ( $sections as $key => $section ) {
77
-				if ( 'fields' === $key ) {
78
-					foreach ( $section as $field ) {
79
-						if ( ! empty( $field['id'] ) && ! empty( $field['data'] ) && ! empty( $options_values[ $field['id'] ] ) && Redux_Helpers::is_integer( $options_values[ $field['id'] ] ) ) {
80
-							//phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals -- Third party hook. Cannot change.
81
-							$options_values[ $field['id'] ] = apply_filters( 'wpml_object_id', $options_values[ $field['id'] ], $field['data'], true );
82
-						}
83
-					}
84
-				} elseif ( is_array( $section ) && ! empty( $section ) ) {
85
-					$this->translate_data_field_recursive( $section, $options_values );
86
-				}
87
-			}
88
-		}
89
-
90
-		/**
91
-		 * Retrieves the options.
92
-		 */
93
-		public function get() {
94
-			$core = $this->core();
95
-
96
-			$defaults = false;
97
-
98
-			if ( ! empty( $core->defaults ) ) {
99
-				$defaults = $core->defaults;
100
-			}
101
-
102
-			if ( empty( $core->args ) ) {
103
-				return;
104
-			}
105
-
106
-			switch ( $core->args['database'] ) {
107
-				case 'transient':
108
-					$result = get_transient( $core->args['opt_name'] . '-transient' );
109
-					break;
110
-				case 'theme_mods':
111
-					$result = get_theme_mod( $core->args['opt_name'] . '-mods' );
112
-					break;
113
-				case 'theme_mods_expanded':
114
-					$result = get_theme_mods();
115
-					break;
116
-				case 'network':
117
-					$result = get_site_option( $core->args['opt_name'], array() );
118
-					break;
119
-				default:
120
-					$result = get_option( $core->args['opt_name'], array() );
121
-
122
-			}
123
-
124
-			if ( ! is_array( $result ) ) {
125
-				return;
126
-			}
127
-
128
-			if ( empty( $result ) && empty( $defaults ) ) {
129
-				return;
130
-			}
131
-
132
-			if ( empty( $result ) && ! empty( $defaults ) ) {
133
-				$results = $defaults;
134
-				$this->set( $results );
135
-			} else {
136
-				$core->options = $result;
137
-			}
138
-
139
-			// Don't iterate unnecessarily.
140
-			if ( has_filter( 'wpml_object_id' ) ) {
141
-				$this->translate_data_field_recursive( $core->sections, $core->options );
142
-			}
143
-
144
-			/**
145
-			 * Action 'redux/options/{opt_name}/options'
146
-			 *
147
-			 * @param mixed $value option values
148
-			 */
149
-
150
-			// phpcs:ignore WordPress.NamingConventions.ValidHookName
151
-			$core->options = apply_filters( "redux/options/{$core->args['opt_name']}/options", $core->options, $core->sections );
152
-
153
-			// Get transient values.
154
-			$core->transient_class->get();
155
-
156
-			// Set a global variable by the global_variable argument.
157
-			$this->set_global_variable( $core );
158
-		}
159
-
160
-		/**
161
-		 * ->set_options(); This is used to set an arbitrary option in the option array
162
-		 *
163
-		 * @since ReduxFramework 3.0.0
164
-		 *
165
-		 * @param string|array $value the value of the option being added.
166
-		 */
167
-		public function set( $value = '' ) {
168
-			$core = $this->core();
169
-
170
-			$core->transients['last_save'] = time();
171
-
172
-			if ( ! empty( $value ) ) {
173
-				switch ( $core->args['database'] ) {
174
-					case 'transient':
175
-						set_transient( $core->args['opt_name'] . '-transient', $value, $core->args['transient_time'] );
176
-						break;
177
-					case 'theme_mods':
178
-						set_theme_mod( $core->args['opt_name'] . '-mods', $value );
179
-						break;
180
-					case 'theme_mods_expanded':
181
-						foreach ( $value as $k => $v ) {
182
-							set_theme_mod( $k, $v );
183
-						}
184
-						break;
185
-					case 'network':
186
-						update_site_option( $core->args['opt_name'], $value );
187
-						break;
188
-					default:
189
-						update_option( $core->args['opt_name'], $value );
190
-
191
-				}
192
-
193
-				// Store the changed values in the transient.
194
-				if ( $value !== $core->options ) {
195
-					foreach ( $value as $k => $v ) {
196
-						if ( ! isset( $core->options[ $k ] ) ) {
197
-							$core->options[ $k ] = '';
198
-						} elseif ( $v === $core->options[ $k ] ) {
199
-							unset( $core->options[ $k ] );
200
-						}
201
-					}
202
-
203
-					$core->transients['changed_values'] = $core->options;
204
-				}
205
-
206
-				$core->options = $value;
207
-
208
-				// Set a global variable by the global_variable argument.
209
-				$this->set_global_variable( $core );
210
-
211
-				// Saving the transient values.
212
-				$core->transient_class->set();
213
-			}
214
-		}
215
-
216
-		/**
217
-		 * Set a global variable by the global_variable argument
218
-		 *
219
-		 * @param null|ReduxFramework $core ReduxFramework core object.
220
-		 *
221
-		 * @return  void          (global was set)
222
-		 * @since   3.1.5
223
-		 */
224
-		private function set_global_variable( ?ReduxFramework $core ): void {
225
-			if ( ! empty( $core->args['global_variable'] ) ) {
226
-				$redux_options_global = $core->args['global_variable'];
227
-
228
-				/**
229
-				 * Filter 'redux/options/{opt_name}/global_variable'
230
-				 *
231
-				 * @param array $value option value to set global_variable with
232
-				 */
233
-
234
-				// phpcs:ignore WordPress.NamingConventions.ValidHookName, WordPress.NamingConventions.PrefixAllGlobals -- Misflag, variable begins with plugin name.
235
-				$GLOBALS[ $redux_options_global ] = apply_filters( "redux/options/{$core->args['opt_name']}/global_variable", $core->options );
236
-			}
237
-		}
238
-
239
-		/**
240
-		 * Register Option for use
241
-		 *
242
-		 * @return void
243
-		 * @throws ReflectionException Exception.
244
-		 * @since  1.0.0
245
-		 * @access public
246
-		 */
247
-		public function register() {
248
-			$core = $this->core();
249
-
250
-			if ( ! is_object( $core ) ) {
251
-				return;
252
-			}
253
-
254
-			if ( true === $core->args['options_api'] ) {
255
-				register_setting(
256
-					$core->args['opt_name'] . '_group',
257
-					$core->args['opt_name'],
258
-					array(
259
-						$this,
260
-						'validate_options',
261
-					)
262
-				);
263
-			}
264
-
265
-			if ( is_null( $core->sections ) ) {
266
-				return;
267
-			}
268
-
269
-			if ( empty( $core->options_defaults ) ) {
270
-				$core->options_defaults = $core->default_values();
271
-			}
272
-
273
-			$run_update = false;
274
-
275
-			foreach ( $core->sections as $k => $section ) {
276
-				if ( isset( $section['type'] ) && 'divide' === $section['type'] ) {
277
-					continue;
278
-				}
279
-
280
-				$display = true;
281
-
282
-				if ( isset( $_GET['page'] ) && $_GET['page'] === $core->args['page_slug'] ) { // phpcs:ignore WordPress.Security.NonceVerification
283
-					if ( isset( $section['panel'] ) && false === $section['panel'] ) {
284
-						$display = false;
285
-					}
286
-				}
287
-
288
-				/**
289
-				 * Filter 'redux/options/{opt_name}/section/{section.id}'
290
-				 *
291
-				 * @param array $section section configuration
292
-				 */
293
-				if ( isset( $section['id'] ) ) {
294
-					// phpcs:ignore WordPress.NamingConventions.ValidHookName
295
-					$section = apply_filters( "redux/options/{$core->args['opt_name']}/section/{$section['id']}", $section );
296
-				}
297
-
298
-				if ( empty( $section ) ) {
299
-					unset( $core->sections[ $k ] );
300
-					continue;
301
-				}
302
-
303
-				if ( ! isset( $section['title'] ) ) {
304
-					$section['title'] = '';
305
-				}
306
-
307
-				if ( isset( $section['customizer_only'] ) && true === $section['customizer_only'] ) {
308
-					$section['panel']     = false;
309
-					$core->sections[ $k ] = $section;
310
-				}
311
-
312
-				$heading = $section['heading'] ?? $section['title'];
313
-
314
-				if ( isset( $section['permissions'] ) && false !== $section['permissions'] ) {
315
-					if ( ! Redux_Helpers::current_user_can( $section['permissions'] ) ) {
316
-						$core->hidden_perm_sections[] = $section['title'];
317
-
318
-						foreach ( $section['fields'] as $field_data ) {
319
-							$field_type = $field_data['type'];
320
-
321
-							if ( ! in_array( $field_type, array( 'section', 'divide', 'info', 'raw' ), true ) ) {
322
-								$field_id = $field_data['id'];
323
-								$default  = $core->options_defaults[ $field_id ] ?? '';
324
-								$data     = $core->options[ $field_id ] ?? $default;
325
-
326
-								$this->hidden_perm_fields[ $field_id ] = $data;
327
-							}
328
-						}
329
-
330
-						continue;
331
-					}
332
-				}
333
-
334
-				if ( ! $display || ! function_exists( 'add_settings_section' ) ) {
335
-					$this->no_panel_section[ $k ] = $section;
336
-				} else {
337
-					add_settings_section(
338
-						$core->args['opt_name'] . $k . '_section',
339
-						$heading,
340
-						array(
341
-							$core->render_class,
342
-							'section_desc',
343
-						),
344
-						$core->args['opt_name'] . $k . '_section_group'
345
-					);
346
-				}
347
-
348
-				$section_ident = false;
349
-				if ( isset( $section['fields'] ) ) {
350
-					foreach ( $section['fields'] as $fieldk => $field ) {
351
-						if ( ! isset( $field['type'] ) ) {
352
-							continue; // You need a type!
353
-						}
354
-
355
-						if ( 'info' === $field['type'] && isset( $field['raw_html'] ) && true === $field['raw_html'] ) {
356
-							$field['type']                             = 'raw';
357
-							$field['content']                          = $field['desc'];
358
-							$field['desc']                             = '';
359
-							$core->sections[ $k ]['fields'][ $fieldk ] = $field;
360
-						} elseif ( 'info' === $field['type'] ) {
361
-							if ( ! isset( $field['full_width'] ) ) {
362
-								$field['full_width']                       = true;
363
-								$core->sections[ $k ]['fields'][ $fieldk ] = $field;
364
-							}
365
-						}
366
-
367
-						if ( 'raw' === $field['type'] ) {
368
-							if ( isset( $field['align'] ) ) {
369
-								$field['full_width'] = ! $field['align'];
370
-								unset( $field['align'] );
371
-							} elseif ( ! isset( $field['full_width'] ) ) {
372
-								$field['full_width'] = true;
373
-							}
374
-							$core->sections[ $k ]['fields'][ $fieldk ] = $field;
375
-						}
376
-
377
-						/**
378
-						 * Filter 'redux/options/{opt_name}/field/{field.id}'
379
-						 *
380
-						 * @param array $field field config
381
-						 */
382
-
383
-						// phpcs:ignore WordPress.NamingConventions.ValidHookName
384
-						$field = apply_filters( "redux/options/{$core->args['opt_name']}/field/{$field['id']}/register", $field );
385
-
386
-						$core->field_types[ $field['type'] ] = $core->field_types[ $field['type'] ] ?? array();
387
-
388
-						$core->field_sections[ $field['type'] ][ $field['id'] ] = $k;
389
-
390
-						$display = true;
391
-
392
-						if ( isset( $_GET['page'] ) && $core->args['page_slug'] === $_GET['page'] ) { // phpcs:ignore WordPress.Security.NonceVerification
393
-							if ( isset( $field['panel'] ) && false === $field['panel'] ) {
394
-								$display = false;
395
-							}
396
-						}
397
-						if ( isset( $field['customizer_only'] ) && true === $field['customizer_only'] ) {
398
-							$display = false;
399
-						}
400
-
401
-						if ( isset( $section['customizer'] ) ) {
402
-							$field['customizer']                       = $section['customizer'];
403
-							$core->sections[ $k ]['fields'][ $fieldk ] = $field;
404
-						}
405
-
406
-						if ( isset( $field['permissions'] ) && false !== $field['permissions'] ) {
407
-							if ( ! Redux_Helpers::current_user_can( $field['permissions'] ) ) {
408
-								$data = $core->options[ $field['id'] ] ?? $core->options_defaults[ $field['id'] ];
409
-
410
-								$this->hidden_perm_fields[ $field['id'] ] = $data;
411
-
412
-								continue;
413
-							}
414
-						}
415
-
416
-						if ( ! isset( $field['id'] ) ) {
417
-							echo '<br /><h3>No field ID is set.</h3><pre>';
418
-
419
-							// phpcs:ignore WordPress.PHP.DevelopmentFunctions
420
-							print_r( $field );
421
-
422
-							echo '</pre><br />';
423
-
424
-							continue;
425
-						}
426
-
427
-						if ( isset( $field['type'] ) && 'section' === $field['type'] ) {
428
-							if ( isset( $field['indent'] ) && true === $field['indent'] ) {
429
-								$section_ident = true;
430
-							} else {
431
-								$section_ident = false;
432
-							}
433
-						}
434
-
435
-						if ( isset( $field['type'] ) && 'info' === $field['type'] && $section_ident ) {
436
-							$field['indent'] = true;
437
-						}
438
-
439
-						$th = $core->render_class->get_header_html( $field );
440
-
441
-						$field['name'] = $core->args['opt_name'] . '[' . $field['id'] . ']';
442
-
443
-						// Set the default value if present.
444
-						$core->options_defaults[ $field['id'] ] = $core->options_defaults[ $field['id'] ] ?? '';
445
-
446
-						// Set the defaults to the value if not present.
447
-						$do_update = false;
448
-
449
-						// Check fields for values in the default parameter.
450
-						if ( ! isset( $core->options[ $field['id'] ] ) && isset( $field['default'] ) ) {
451
-							$core->options_defaults[ $field['id'] ] = $field['default'];
452
-							$core->options[ $field['id'] ]          = $field['default'];
453
-							$do_update                              = true;
454
-
455
-							// Check fields that hae no default value, but an option value with settings to
456
-							// be saved by default.
457
-						} elseif ( ! isset( $core->options[ $field['id'] ] ) && isset( $field['options'] ) ) {
458
-
459
-							// If a sorter field, check for options and save them as defaults.
460
-							if ( 'sorter' === $field['type'] || 'sortable' === $field['type'] ) {
461
-								$core->options_defaults[ $field['id'] ] = $field['options'];
462
-								$core->options[ $field['id'] ]          = $field['options'];
463
-								$do_update                              = true;
464
-							}
465
-						}
466
-
467
-						// CORRECT URLS if media URLs are wrong, but attachment IDs are present.
468
-						if ( 'media' === $field['type'] ) {
469
-							if ( isset( $core->options[ $field['id'] ]['id'] ) && isset( $core->options[ $field['id'] ]['url'] ) && ! empty( $core->options[ $field['id'] ]['url'] ) && strpos( $core->options[ $field['id'] ]['url'], str_replace( 'https://', '', WP_CONTENT_URL ) ) === false ) {
470
-								$data = wp_get_attachment_url( $core->options[ $field['id'] ]['id'] );
471
-
472
-								if ( isset( $data ) && ! empty( $data ) ) {
473
-									$core->options[ $field['id'] ]['url'] = $data;
474
-
475
-									$data = wp_get_attachment_image_src(
476
-										$core->options[ $field['id'] ]['id'],
477
-										array(
478
-											150,
479
-											150,
480
-										)
481
-									);
482
-
483
-									$core->options[ $field['id'] ]['thumbnail'] = $data[0];
484
-									$do_update                                  = true;
485
-								}
486
-							}
487
-						}
488
-
489
-						if ( 'background' === $field['type'] ) {
490
-							if ( isset( $core->options[ $field['id'] ]['media']['id'] ) && isset( $core->options[ $field['id'] ]['background-image'] ) && ! empty( $core->options[ $field['id'] ]['background-image'] ) && strpos( $core->options[ $field['id'] ]['background-image'], str_replace( array( 'https://', 'https://' ), '', WP_CONTENT_URL ) ) === false ) {
491
-								$data = wp_get_attachment_url( $core->options[ $field['id'] ]['media']['id'] );
492
-
493
-								if ( isset( $data ) && ! empty( $data ) ) {
494
-									$core->options[ $field['id'] ]['background-image'] = $data;
495
-
496
-									$data = wp_get_attachment_image_src(
497
-										$core->options[ $field['id'] ]['media']['id'],
498
-										array(
499
-											150,
500
-											150,
501
-										)
502
-									);
503
-
504
-									$core->options[ $field['id'] ]['media']['thumbnail'] = $data[0];
505
-									$do_update = true;
506
-								}
507
-							}
508
-						}
509
-
510
-						if ( 'slides' === $field['type'] ) {
511
-							if ( isset( $core->options[ $field['id'] ] ) && is_array( $core->options[ $field['id'] ] ) && isset( $core->options[ $field['id'] ][0]['attachment_id'] ) && isset( $core->options[ $field['id'] ][0]['image'] ) && ! empty( $core->options[ $field['id'] ][0]['image'] ) && strpos( $core->options[ $field['id'] ][0]['image'], str_replace( array( 'https://', 'https://' ), '', WP_CONTENT_URL ) ) === false ) {
512
-								foreach ( $core->options[ $field['id'] ] as $key => $val ) {
513
-									$data = wp_get_attachment_url( $val['attachment_id'] );
514
-
515
-									if ( isset( $data ) && ! empty( $data ) ) {
516
-										$core->options[ $field['id'] ][ $key ]['image'] = $data;
517
-
518
-										$data = wp_get_attachment_image_src(
519
-											$val['attachment_id'],
520
-											array(
521
-												150,
522
-												150,
523
-											)
524
-										);
525
-
526
-										$core->options[ $field['id'] ][ $key ]['thumb'] = $data[0];
527
-										$do_update                                      = true;
528
-									}
529
-								}
530
-							}
531
-						}
532
-						// END -> CORRECT URLS if media URLs are wrong, but attachment IDs are present.
533
-						if ( true === $do_update && ! isset( $core->never_save_to_db ) ) {
534
-							if ( $core->args['save_defaults'] ) { // Only save that to the DB if allowed to.
535
-								$run_update = true;
536
-							}
537
-						}
538
-
539
-						if ( ! isset( $field['class'] ) ) { // No errors, please.
540
-							$field['class'] = '';
541
-						}
542
-
543
-						/**
544
-						 * Filter 'redux/options/{opt_name}/field/{field.id}'.
545
-						 *
546
-						 * @param array $field field config
547
-						 */
548
-
549
-						// phpcs:ignore WordPress.NamingConventions.ValidHookName
550
-						$field = apply_filters( "redux/options/{$core->args['opt_name']}/field/{$field['id']}", $field );
551
-
552
-						if ( empty( $field ) ) {
553
-							unset( $core->sections[ $k ]['fields'][ $fieldk ] );
554
-							continue;
555
-						}
556
-
557
-						if ( ! empty( Redux_Core::$folds[ $field['id'] ]['parent'] ) ) { // This has some fold items, hide it by default.
558
-							$field['class'] .= ' fold';
559
-						}
560
-
561
-						if ( ! empty( Redux_Core::$folds[ $field['id'] ]['children'] ) ) { // Sets the values you shoe fold children on.
562
-							$field['class'] .= ' fold-parent';
563
-						}
564
-
565
-						if ( ! empty( $field['compiler'] ) ) {
566
-							$field['class']                       .= ' compiler';
567
-							$core->compiler_fields[ $field['id'] ] = 1;
568
-						}
569
-
570
-						if ( isset( $field['unit'] ) && ! isset( $field['units'] ) ) {
571
-							$field['units'] = $field['unit'];
572
-							unset( $field['unit'] );
573
-						}
574
-
575
-						$core->sections[ $k ]['fields'][ $fieldk ] = $field;
576
-
577
-						if ( isset( $core->args['display_source'] ) ) {
578
-							// phpcs:ignore WordPress.PHP.DevelopmentFunctions
579
-							$th .= '<div id="' . $field['id'] . '-settings" style="display:none;"><pre>' . var_export( $core->sections[ $k ]['fields'][ $fieldk ], true ) . '</pre></div>';
580
-							$th .= '<br /><a href="#TB_inline?width=600&height=800&inlineId=' . $field['id'] . '-settings" class="thickbox"><small>View Source</small></a>';
581
-						}
582
-
583
-						/**
584
-						 * Action 'redux/options/{opt_name}/field/{field.type}/register'
585
-						 */
586
-
587
-						// phpcs:ignore WordPress.NamingConventions.ValidHookName
588
-						do_action( "redux/options/{$core->args['opt_name']}/field/{$field['type']}/register", $field );
589
-
590
-						$core->required_class->check_dependencies( $field );
591
-						$core->field_head[ $field['id'] ] = $th;
592
-
593
-						if ( ! $display || isset( $this->no_panel_section[ $k ] ) ) {
594
-							$this->no_panel[] = $field['id'];
595
-						} else {
596
-							if ( isset( $field['disabled'] ) && $field['disabled'] ) {
597
-								$field['class'] .= ' redux_disable_field';
598
-							}
599
-
600
-							if ( isset( $field['hidden'] ) && $field['hidden'] ) {
601
-								$field['class'] .= ' redux_hide_field';
602
-							}
603
-
604
-							if ( true === $core->args['options_api'] ) {
605
-								add_settings_field(
606
-									"{$fieldk}_field",
607
-									$th,
608
-									array(
609
-										$core->render_class,
610
-										'field_input',
611
-									),
612
-									"{$core->args['opt_name']}{$k}_section_group",
613
-									"{$core->args['opt_name']}{$k}_section",
614
-									$field
615
-								);
616
-							}
617
-						}
618
-					}
619
-				}
620
-			}
621
-
622
-			/**
623
-			 * Action 'redux/options/{opt_name}/register'
624
-			 *
625
-			 * @param array $section Option sections
626
-			 */
627
-
628
-			// phpcs:ignore WordPress.NamingConventions.ValidHookName
629
-			do_action( "redux/options/{$core->args['opt_name']}/register", $core->sections );
630
-
631
-			if ( $run_update && ! isset( $core->never_save_to_db ) ) { // Always update the DB with new fields.
632
-				$this->set( $core->options );
633
-			}
634
-
635
-			if ( isset( $core->transients['run_compiler'] ) && $core->transients['run_compiler'] ) {
636
-
637
-				Redux_Core::$no_output = true;
638
-				$temp                  = $core->args['output_variables_prefix'];
639
-
640
-				// Allow the override of variable's prefix for use by SCSS or LESS.
641
-				if ( isset( $core->args['compiler_output_variables_prefix'] ) ) {
642
-					$core->args['output_variables_prefix'] = $core->args['compiler_output_variables_prefix'];
643
-				}
644
-				$core->output_class->enqueue();
645
-				$core->args['output_variables_prefix'] = $temp;
646
-
647
-				// phpcs:ignore WordPress.NamingConventions.ValidVariableName
648
-				$compiler_css = $core->compilerCSS;
649
-
650
-				/**
651
-				 * Action 'redux/options/{opt_name}/compiler'
652
-				 *
653
-				 * @param array  $options Options.
654
-				 * @param string $css CSS that get sent to the compiler hook.
655
-				 * @param array  $changed_values Changed values.
656
-				 * @param array  $output_variables Output variables.
657
-				 */
658
-
659
-				// phpcs:ignore WordPress.NamingConventions.ValidHookName
660
-				do_action( "redux/options/{$core->args['opt_name']}/compiler", $core->options, $compiler_css, $core->transients['changed_values'], $core->output_variables );
661
-
662
-				/**
663
-				 * Action 'redux/options/{opt_name}/compiler/advanced'
664
-				 *
665
-				 * @param object $redux ReduxFramework object.
666
-				 */
667
-
668
-				// phpcs:ignore WordPress.NamingConventions.ValidHookName
669
-				do_action( "redux/options/{$core->args['opt_name']}/compiler/advanced", $core );
670
-
671
-				unset( $core->transients['run_compiler'] );
672
-				$core->transient_class->set();
673
-			}
674
-		}
675
-
676
-		/**
677
-		 * Get default options into an array suitable for the settings API
678
-		 *
679
-		 * @since       1.0.0
680
-		 * @access      public
681
-		 * @return      array $this->options_defaults
682
-		 */
683
-		public function default_values(): array {
684
-			$core = $this->core();
685
-
686
-			if ( ! is_null( $core->sections ) && is_null( $core->options_defaults ) ) {
687
-				$core->options_defaults = $core->options_defaults_class->default_values( $core->args['opt_name'], $core->sections, $core->wordpress_data );
688
-			}
689
-
690
-			/**
691
-			 * Filter 'redux/options/{opt_name}/defaults'
692
-			 *
693
-			 * @param array $defaults option default values
694
-			 */
695
-
696
-			$core->transients['changed_values'] = $core->transients['changed_values'] ?? array();
697
-
698
-			// phpcs:ignore WordPress.NamingConventions.ValidHookName
699
-			$core->options_defaults = apply_filters( "redux/options/{$core->args['opt_name']}/defaults", $core->options_defaults, $core->transients['changed_values'] );
700
-
701
-			return $core->options_defaults;
702
-		}
703
-
704
-		/**
705
-		 * Validate the Options before insertion
706
-		 *
707
-		 * @param  array $plugin_options The option array.
708
-		 *
709
-		 * @return array|mixed|string
710
-		 * @since  3.0.0
711
-		 * @access public
712
-		 */
713
-		public function validate_options( array $plugin_options ) {
714
-			$core = $this->core();
715
-
716
-			if ( true === Redux_Core::$validation_ran ) {
717
-				return $plugin_options;
718
-			}
719
-
720
-			Redux_Core::$validation_ran = true;
721
-
722
-			// Save the values not in the panel.
723
-			if ( isset( $plugin_options['redux-no_panel'] ) ) {
724
-				$keys = explode( '|', $plugin_options['redux-no_panel'] );
725
-				foreach ( $keys as $key ) {
726
-					$plugin_options[ $key ] = $core->options[ $key ];
727
-				}
728
-				if ( isset( $plugin_options['redux-no_panel'] ) ) {
729
-					unset( $plugin_options['redux-no_panel'] );
730
-				}
731
-			}
732
-
733
-			if ( is_array( $this->hidden_perm_fields ) && ! empty( $this->hidden_perm_fields ) ) {
734
-				foreach ( $this->hidden_perm_fields as $id => $data ) {
735
-					$plugin_options[ $id ] = $data;
736
-				}
737
-			}
738
-
739
-			if ( $plugin_options === $core->options ) {
740
-				return $plugin_options;
741
-			}
742
-
743
-			$time = time();
744
-
745
-			// Sets last saved time.
746
-			$core->transients['last_save'] = $time;
747
-
748
-			$imported_options = array();
749
-
750
-			if ( isset( $plugin_options['import_code'] ) && '' !== $plugin_options['import_code'] ) {
751
-				$imported_options = json_decode( $plugin_options['import_code'], true );
752
-			}
753
-
754
-			// Import.
755
-			$core->transients['last_save_mode'] = 'import'; // Last save mode.
756
-			$core->transients['last_compiler']  = $time;
757
-			$core->transients['last_import']    = $time;
758
-			$core->transients['run_compiler']   = 1;
759
-
760
-			if ( is_array( $imported_options ) && ! empty( $imported_options ) && isset( $imported_options['redux-backup'] ) && ( 1 === $imported_options['redux-backup'] || '1' === $imported_options['redux-backup'] ) ) {
761
-				$core->transients['changed_values'] = array();
762
-				foreach ( $plugin_options as $key => $value ) {
763
-					if ( isset( $imported_options[ $key ] ) && $value !== $imported_options[ $key ] ) {
764
-						$plugin_options[ $key ]                     = $value;
765
-						$core->transients['changed_values'][ $key ] = $value;
766
-					}
767
-				}
768
-
769
-				/**
770
-				 * Action 'redux/options/{opt_name}/import'.
771
-				 *
772
-				 * @param  &array [&$plugin_options, redux_options]
773
-				 */
774
-
775
-				// phpcs:ignore WordPress.NamingConventions.ValidHookName
776
-				do_action_ref_array(
777
-					"redux/options/{$core->args['opt_name']}/import", // phpcs:ignore WordPress.NamingConventions.ValidHookName
778
-					array(
779
-						&$plugin_options,
780
-						$imported_options,
781
-						$core->transients['changed_values'],
782
-					)
783
-				);
784
-
785
-				setcookie( 'redux_current_tab_' . $core->args['opt_name'], '', 1, '/', $time + 1000, '/' );
786
-				$_COOKIE[ 'redux_current_tab_' . $core->args['opt_name'] ] = 1;
787
-
788
-				unset( $plugin_options['defaults'], $plugin_options['compiler'], $plugin_options['import'], $plugin_options['import_code'] );
789
-				if ( in_array( $core->args['database'], array( 'transient', 'theme_mods', 'theme_mods_expanded', 'network' ), true ) ) {
790
-					$this->set( $plugin_options );
791
-
792
-					return null;
793
-				}
794
-
795
-				$plugin_options = wp_parse_args( $imported_options, $plugin_options );
796
-
797
-				$core->transient_class->set();
798
-
799
-				return $plugin_options;
800
-			}
801
-
802
-			// Reset all to defaults.
803
-			if ( ! empty( $plugin_options['defaults'] ) ) {
804
-				if ( empty( $core->options_defaults ) ) {
805
-					$core->options_defaults = $core->_default_values();
806
-				}
807
-
808
-				/**
809
-				 * Filter: 'redux/validate/{opt_name}/defaults'.
810
-				 *
811
-				 * @param  &array [ $this->options_defaults, $plugin_options]
812
-				 */
813
-
814
-				// phpcs:ignore WordPress.NamingConventions.ValidHookName
815
-				$plugin_options = apply_filters( "redux/validate/{$core->args['opt_name']}/defaults", $core->options_defaults );
816
-
817
-				$core->transients['changed_values'] = array();
818
-
819
-				if ( empty( $core->options ) ) {
820
-					$core->options = $core->options_defaults;
821
-				}
822
-
823
-				foreach ( $core->options as $key => $value ) {
824
-					if ( isset( $plugin_options[ $key ] ) && $plugin_options[ $key ] !== $value ) {
825
-						$core->transients['changed_values'][ $key ] = $value;
826
-					}
827
-				}
828
-
829
-				$core->transients['run_compiler']   = 1;
830
-				$core->transients['last_save_mode'] = 'defaults'; // Last save mode.
831
-
832
-				$core->transient_class->set();
833
-
834
-				return $plugin_options;
835
-			}
836
-
837
-			// Section reset to default.
838
-			if ( ! empty( $plugin_options['defaults-section'] ) ) {
839
-				if ( isset( $plugin_options['redux-section'] ) && isset( $core->sections[ $plugin_options['redux-section'] ]['fields'] ) ) {
840
-					if ( empty( $core->options_defaults ) ) {
841
-						$core->options_defaults = $core->_default_values();
842
-					}
843
-
844
-					foreach ( $core->sections[ $plugin_options['redux-section'] ]['fields'] as $field ) {
845
-						if ( 'tabbed' === $field['type'] ) {
846
-							if ( ! empty( $field['tabs'] ) ) {
847
-								foreach ( $field['tabs'] as $val ) {
848
-									if ( ! empty( $val['fields'] ) ) {
849
-										foreach ( $val['fields'] as $f ) {
850
-											if ( isset( $core->options_defaults[ $f['id'] ] ) ) {
851
-												$plugin_options[ $f['id'] ] = $core->options_defaults[ $f['id'] ];
852
-											} else {
853
-												$plugin_options[ $f['id'] ] = '';
854
-											}
855
-										}
856
-									}
857
-								}
858
-							}
859
-						} elseif ( 'repeater' === $field['type'] ) {
860
-							if ( ! empty( $field['fields'] ) ) {
861
-								foreach ( $field['fields'] as $f ) {
862
-									if ( isset( $core->options_defaults[ $f['id'] ] ) ) {
863
-										$plugin_options[ $f['id'] ] = $core->options_defaults[ $f['id'] ];
864
-									} else {
865
-										$plugin_options[ $f['id'] ] = '';
866
-									}
867
-								}
868
-							}
869
-						} else {
870
-							if ( isset( $core->options_defaults[ $field['id'] ] ) ) {
871
-								$plugin_options[ $field['id'] ] = $core->options_defaults[ $field['id'] ];
872
-							} else {
873
-								$plugin_options[ $field['id'] ] = '';
874
-							}
875
-						}
876
-
877
-						if ( isset( $field['compiler'] ) ) {
878
-							$compiler = true;
879
-						}
880
-					}
881
-
882
-					/**
883
-					 * Filter: 'redux/validate/{opt_name}/defaults_section'.
884
-					 *
885
-					 * @param  &array [ $this->options_defaults, $plugin_options]
886
-					 */
887
-
888
-					// phpcs:ignore WordPress.NamingConventions.ValidHookName
889
-					$plugin_options = apply_filters( "redux/validate/{$core->args['opt_name']}/defaults_section", $plugin_options );
890
-				}
891
-
892
-				$core->transients['changed_values'] = array();
893
-
894
-				foreach ( $core->options as $key => $value ) {
895
-					if ( isset( $plugin_options[ $key ] ) && $plugin_options[ $key ] !== $value ) {
896
-						$core->transients['changed_values'][ $key ] = $value;
897
-					}
898
-				}
899
-
900
-				if ( isset( $compiler ) ) {
901
-					$core->transients['last_compiler'] = $time;
902
-					$core->transients['run_compiler']  = 1;
903
-				}
904
-
905
-				$core->transients['last_save_mode'] = 'defaults_section'; // Last save mode.
906
-
907
-				unset( $plugin_options['defaults'], $plugin_options['defaults_section'], $plugin_options['import'], $plugin_options['import_code'], $plugin_options['import_link'], $plugin_options['compiler'], $plugin_options['redux-section'] );
908
-
909
-				$core->transient_class->set();
910
-
911
-				return $plugin_options;
912
-			}
913
-
914
-			$core->transients['last_save_mode'] = 'normal'; // Last save mode.
915
-
916
-			/**
917
-			 * Filter: 'redux/validate/{opt_name}/before_validation'
918
-			 *
919
-			 * @param  &array [&$plugin_options, redux_options]
920
-			 */
921
-
922
-			// phpcs:ignore WordPress.NamingConventions.ValidHookName
923
-			$plugin_options = apply_filters( "redux/validate/{$core->args['opt_name']}/before_validation", $plugin_options, $core->options );
924
-
925
-			// Validate fields (if needed).
926
-			$plugin_options = $core->validate_class->validate( $plugin_options, $core->options, $core->sections );
927
-
928
-			// Sanitize options, if needed.
929
-			$plugin_options = $core->sanitize_class->sanitize( $plugin_options, $core->options, $core->sections );
930
-
931
-			if ( ! empty( $core->errors ) || ! empty( $core->warnings ) || ! empty( $core->sanitize ) ) {
932
-				$core->transients['notices'] = array(
933
-					'errors'   => $core->errors,
934
-					'warnings' => $core->warnings,
935
-					'sanitize' => $core->sanitize,
936
-				);
937
-			}
938
-
939
-			if ( ! isset( $core->transients['changed_values'] ) ) {
940
-				$core->transients['changed_values'] = array();
941
-			}
942
-
943
-			/**
944
-			 * Action 'redux/options/{opt_name}/validate'
945
-			 *
946
-			 * @param  &array [&$plugin_options, redux_options]
947
-			 */
948
-			// phpcs:ignore WordPress.NamingConventions.ValidHookName
949
-			do_action_ref_array(
950
-			// phpcs:ignore WordPress.NamingConventions.ValidHookName
951
-				"redux/options/{$core->args['opt_name']}/validate",
952
-				array(
953
-					&$plugin_options,
954
-					$core->options,
955
-					$core->transients['changed_values'],
956
-				)
957
-			);
958
-
959
-			if ( ! empty( $plugin_options['compiler'] ) ) {
960
-				unset( $plugin_options['compiler'] );
961
-
962
-				$core->transients['last_compiler'] = $time;
963
-				$core->transients['run_compiler']  = 1;
964
-			}
965
-
966
-			$core->transients['changed_values'] = array(); // Changed values since last save.
967
-
968
-			if ( ! empty( $core->options ) ) {
969
-				foreach ( $core->options as $key => $value ) {
970
-					if ( isset( $plugin_options[ $key ] ) && $plugin_options[ $key ] !== $value ) {
971
-						$core->transients['changed_values'][ $key ] = $value;
972
-					}
973
-				}
974
-			}
975
-
976
-			unset( $plugin_options['defaults'], $plugin_options['defaults_section'], $plugin_options['import'], $plugin_options['import_code'], $plugin_options['import_link'], $plugin_options['compiler'], $plugin_options['redux-section'] );
977
-			if ( in_array( $core->args['database'], array( 'transient', 'theme_mods', 'theme_mods_expanded' ), true ) ) {
978
-				$core->set( $core->args['opt_name'], $plugin_options );
979
-				return null;
980
-			}
981
-
982
-			if ( defined( 'WP_CACHE' ) && WP_CACHE && class_exists( 'W3_ObjectCache' ) && function_exists( 'w3_instance' ) ) {
983
-				$w3_inst = w3_instance( 'W3_ObjectCache' );
984
-				$w3      = $w3_inst->instance();
985
-				$key     = $w3->_get_cache_key( $core->args['opt_name'] . '-transients', 'transient' );
986
-				$w3->delete( $key, 'transient', true );
987
-			}
988
-
989
-			$core->transient_class->set();
990
-
991
-			return $plugin_options;
992
-		}
993
-
994
-		/**
995
-		 * ->get_default(); This is used to return the default value if default_show is set.
996
-		 *
997
-		 * @param string $opt_name The option name to return.
998
-		 * @param mixed  $defaults (null) The value to return if default not set.
999
-		 *
1000
-		 * @return      mixed $default
1001
-		 * @since       1.0.1
1002
-		 * @access      public
1003
-		 */
1004
-		public function get_default( string $opt_name, $defaults = null ) {
1005
-			if ( true === $this->args['default_show'] ) {
1006
-
1007
-				if ( empty( $this->options_defaults ) ) {
1008
-					$this->default_values(); // fill cache.
1009
-				}
1010
-
1011
-				return array_key_exists( $opt_name, $this->options_defaults ) ? $this->options_defaults[ $opt_name ] : $defaults;
1012
-			}
1013
-
1014
-			return '';
1015
-		}
1016
-
1017
-		/**
1018
-		 * Get the default value for an option
1019
-		 *
1020
-		 * @param string $key       The option's ID.
1021
-		 * @param string $array_key The key of the default's array.
1022
-		 *
1023
-		 * @return mixed
1024
-		 * @since  3.3.6
1025
-		 * @access public
1026
-		 */
1027
-		public function get_default_value( string $key, $array_key = false ) {
1028
-			if ( empty( $this->options_defaults ) ) {
1029
-				$this->options_defaults = $this->default_values();
1030
-			}
1031
-
1032
-			$defaults = $this->options_defaults;
1033
-			$value    = '';
1034
-
1035
-			if ( isset( $defaults[ $key ] ) ) {
1036
-				if ( false !== $array_key && isset( $defaults[ $key ][ $array_key ] ) ) {
1037
-					$value = $defaults[ $key ][ $array_key ];
1038
-				} else {
1039
-					$value = $defaults[ $key ];
1040
-				}
1041
-			}
1042
-
1043
-			return $value;
1044
-		}
1045
-	}
15
+    /**
16
+     * Class Redux_Options
17
+     */
18
+    class Redux_Options_Constructor extends Redux_Class {
19
+
20
+        /**
21
+         * Array to hold single panel data.
22
+         *
23
+         * @var array
24
+         */
25
+        public array $no_panel = array();
26
+
27
+        /**
28
+         * Array to hold single panel sections.
29
+         *
30
+         * @var array
31
+         */
32
+        private array $no_panel_section = array();
33
+
34
+        /**
35
+         * Array to hold hidden fields.
36
+         *
37
+         * @var array
38
+         */
39
+        private array $hidden_perm_fields = array();
40
+
41
+        /**
42
+         * Array to hold hidden sections.
43
+         *
44
+         * @var array
45
+         */
46
+        public array $hidden_perm_sections = array();
47
+
48
+        /**
49
+         * Array to hold default options.
50
+         *
51
+         * @var array
52
+         */
53
+        private array $options_defaults = array();
54
+
55
+        /**
56
+         * Redux_Options constructor.
57
+         *
58
+         * @param object $redux ReduxFramework pointer.
59
+         */
60
+        public function __construct( $redux ) {
61
+            parent::__construct( $redux );
62
+
63
+            add_action( 'admin_init', array( $this, 'register' ) );
64
+        }
65
+
66
+        /**
67
+         * If we switch language in wpml the id of the post/page selected will be in the wrong language
68
+         * So it won't appear as selected in the list of options and will be lost on next save, this fixes this by translating this id
69
+         * Bonus it also gives the user the id of the post in the right language when they retrieve it.
70
+         * The recursion allows for it to work in a repeatable field.
71
+         *
72
+         * @param array $sections       Sections array.
73
+         * @param array $options_values Values array.
74
+         */
75
+        private function translate_data_field_recursive( array $sections, array &$options_values ) {
76
+            foreach ( $sections as $key => $section ) {
77
+                if ( 'fields' === $key ) {
78
+                    foreach ( $section as $field ) {
79
+                        if ( ! empty( $field['id'] ) && ! empty( $field['data'] ) && ! empty( $options_values[ $field['id'] ] ) && Redux_Helpers::is_integer( $options_values[ $field['id'] ] ) ) {
80
+                            //phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals -- Third party hook. Cannot change.
81
+                            $options_values[ $field['id'] ] = apply_filters( 'wpml_object_id', $options_values[ $field['id'] ], $field['data'], true );
82
+                        }
83
+                    }
84
+                } elseif ( is_array( $section ) && ! empty( $section ) ) {
85
+                    $this->translate_data_field_recursive( $section, $options_values );
86
+                }
87
+            }
88
+        }
89
+
90
+        /**
91
+         * Retrieves the options.
92
+         */
93
+        public function get() {
94
+            $core = $this->core();
95
+
96
+            $defaults = false;
97
+
98
+            if ( ! empty( $core->defaults ) ) {
99
+                $defaults = $core->defaults;
100
+            }
101
+
102
+            if ( empty( $core->args ) ) {
103
+                return;
104
+            }
105
+
106
+            switch ( $core->args['database'] ) {
107
+                case 'transient':
108
+                    $result = get_transient( $core->args['opt_name'] . '-transient' );
109
+                    break;
110
+                case 'theme_mods':
111
+                    $result = get_theme_mod( $core->args['opt_name'] . '-mods' );
112
+                    break;
113
+                case 'theme_mods_expanded':
114
+                    $result = get_theme_mods();
115
+                    break;
116
+                case 'network':
117
+                    $result = get_site_option( $core->args['opt_name'], array() );
118
+                    break;
119
+                default:
120
+                    $result = get_option( $core->args['opt_name'], array() );
121
+
122
+            }
123
+
124
+            if ( ! is_array( $result ) ) {
125
+                return;
126
+            }
127
+
128
+            if ( empty( $result ) && empty( $defaults ) ) {
129
+                return;
130
+            }
131
+
132
+            if ( empty( $result ) && ! empty( $defaults ) ) {
133
+                $results = $defaults;
134
+                $this->set( $results );
135
+            } else {
136
+                $core->options = $result;
137
+            }
138
+
139
+            // Don't iterate unnecessarily.
140
+            if ( has_filter( 'wpml_object_id' ) ) {
141
+                $this->translate_data_field_recursive( $core->sections, $core->options );
142
+            }
143
+
144
+            /**
145
+             * Action 'redux/options/{opt_name}/options'
146
+             *
147
+             * @param mixed $value option values
148
+             */
149
+
150
+            // phpcs:ignore WordPress.NamingConventions.ValidHookName
151
+            $core->options = apply_filters( "redux/options/{$core->args['opt_name']}/options", $core->options, $core->sections );
152
+
153
+            // Get transient values.
154
+            $core->transient_class->get();
155
+
156
+            // Set a global variable by the global_variable argument.
157
+            $this->set_global_variable( $core );
158
+        }
159
+
160
+        /**
161
+         * ->set_options(); This is used to set an arbitrary option in the option array
162
+         *
163
+         * @since ReduxFramework 3.0.0
164
+         *
165
+         * @param string|array $value the value of the option being added.
166
+         */
167
+        public function set( $value = '' ) {
168
+            $core = $this->core();
169
+
170
+            $core->transients['last_save'] = time();
171
+
172
+            if ( ! empty( $value ) ) {
173
+                switch ( $core->args['database'] ) {
174
+                    case 'transient':
175
+                        set_transient( $core->args['opt_name'] . '-transient', $value, $core->args['transient_time'] );
176
+                        break;
177
+                    case 'theme_mods':
178
+                        set_theme_mod( $core->args['opt_name'] . '-mods', $value );
179
+                        break;
180
+                    case 'theme_mods_expanded':
181
+                        foreach ( $value as $k => $v ) {
182
+                            set_theme_mod( $k, $v );
183
+                        }
184
+                        break;
185
+                    case 'network':
186
+                        update_site_option( $core->args['opt_name'], $value );
187
+                        break;
188
+                    default:
189
+                        update_option( $core->args['opt_name'], $value );
190
+
191
+                }
192
+
193
+                // Store the changed values in the transient.
194
+                if ( $value !== $core->options ) {
195
+                    foreach ( $value as $k => $v ) {
196
+                        if ( ! isset( $core->options[ $k ] ) ) {
197
+                            $core->options[ $k ] = '';
198
+                        } elseif ( $v === $core->options[ $k ] ) {
199
+                            unset( $core->options[ $k ] );
200
+                        }
201
+                    }
202
+
203
+                    $core->transients['changed_values'] = $core->options;
204
+                }
205
+
206
+                $core->options = $value;
207
+
208
+                // Set a global variable by the global_variable argument.
209
+                $this->set_global_variable( $core );
210
+
211
+                // Saving the transient values.
212
+                $core->transient_class->set();
213
+            }
214
+        }
215
+
216
+        /**
217
+         * Set a global variable by the global_variable argument
218
+         *
219
+         * @param null|ReduxFramework $core ReduxFramework core object.
220
+         *
221
+         * @return  void          (global was set)
222
+         * @since   3.1.5
223
+         */
224
+        private function set_global_variable( ?ReduxFramework $core ): void {
225
+            if ( ! empty( $core->args['global_variable'] ) ) {
226
+                $redux_options_global = $core->args['global_variable'];
227
+
228
+                /**
229
+                 * Filter 'redux/options/{opt_name}/global_variable'
230
+                 *
231
+                 * @param array $value option value to set global_variable with
232
+                 */
233
+
234
+                // phpcs:ignore WordPress.NamingConventions.ValidHookName, WordPress.NamingConventions.PrefixAllGlobals -- Misflag, variable begins with plugin name.
235
+                $GLOBALS[ $redux_options_global ] = apply_filters( "redux/options/{$core->args['opt_name']}/global_variable", $core->options );
236
+            }
237
+        }
238
+
239
+        /**
240
+         * Register Option for use
241
+         *
242
+         * @return void
243
+         * @throws ReflectionException Exception.
244
+         * @since  1.0.0
245
+         * @access public
246
+         */
247
+        public function register() {
248
+            $core = $this->core();
249
+
250
+            if ( ! is_object( $core ) ) {
251
+                return;
252
+            }
253
+
254
+            if ( true === $core->args['options_api'] ) {
255
+                register_setting(
256
+                    $core->args['opt_name'] . '_group',
257
+                    $core->args['opt_name'],
258
+                    array(
259
+                        $this,
260
+                        'validate_options',
261
+                    )
262
+                );
263
+            }
264
+
265
+            if ( is_null( $core->sections ) ) {
266
+                return;
267
+            }
268
+
269
+            if ( empty( $core->options_defaults ) ) {
270
+                $core->options_defaults = $core->default_values();
271
+            }
272
+
273
+            $run_update = false;
274
+
275
+            foreach ( $core->sections as $k => $section ) {
276
+                if ( isset( $section['type'] ) && 'divide' === $section['type'] ) {
277
+                    continue;
278
+                }
279
+
280
+                $display = true;
281
+
282
+                if ( isset( $_GET['page'] ) && $_GET['page'] === $core->args['page_slug'] ) { // phpcs:ignore WordPress.Security.NonceVerification
283
+                    if ( isset( $section['panel'] ) && false === $section['panel'] ) {
284
+                        $display = false;
285
+                    }
286
+                }
287
+
288
+                /**
289
+                 * Filter 'redux/options/{opt_name}/section/{section.id}'
290
+                 *
291
+                 * @param array $section section configuration
292
+                 */
293
+                if ( isset( $section['id'] ) ) {
294
+                    // phpcs:ignore WordPress.NamingConventions.ValidHookName
295
+                    $section = apply_filters( "redux/options/{$core->args['opt_name']}/section/{$section['id']}", $section );
296
+                }
297
+
298
+                if ( empty( $section ) ) {
299
+                    unset( $core->sections[ $k ] );
300
+                    continue;
301
+                }
302
+
303
+                if ( ! isset( $section['title'] ) ) {
304
+                    $section['title'] = '';
305
+                }
306
+
307
+                if ( isset( $section['customizer_only'] ) && true === $section['customizer_only'] ) {
308
+                    $section['panel']     = false;
309
+                    $core->sections[ $k ] = $section;
310
+                }
311
+
312
+                $heading = $section['heading'] ?? $section['title'];
313
+
314
+                if ( isset( $section['permissions'] ) && false !== $section['permissions'] ) {
315
+                    if ( ! Redux_Helpers::current_user_can( $section['permissions'] ) ) {
316
+                        $core->hidden_perm_sections[] = $section['title'];
317
+
318
+                        foreach ( $section['fields'] as $field_data ) {
319
+                            $field_type = $field_data['type'];
320
+
321
+                            if ( ! in_array( $field_type, array( 'section', 'divide', 'info', 'raw' ), true ) ) {
322
+                                $field_id = $field_data['id'];
323
+                                $default  = $core->options_defaults[ $field_id ] ?? '';
324
+                                $data     = $core->options[ $field_id ] ?? $default;
325
+
326
+                                $this->hidden_perm_fields[ $field_id ] = $data;
327
+                            }
328
+                        }
329
+
330
+                        continue;
331
+                    }
332
+                }
333
+
334
+                if ( ! $display || ! function_exists( 'add_settings_section' ) ) {
335
+                    $this->no_panel_section[ $k ] = $section;
336
+                } else {
337
+                    add_settings_section(
338
+                        $core->args['opt_name'] . $k . '_section',
339
+                        $heading,
340
+                        array(
341
+                            $core->render_class,
342
+                            'section_desc',
343
+                        ),
344
+                        $core->args['opt_name'] . $k . '_section_group'
345
+                    );
346
+                }
347
+
348
+                $section_ident = false;
349
+                if ( isset( $section['fields'] ) ) {
350
+                    foreach ( $section['fields'] as $fieldk => $field ) {
351
+                        if ( ! isset( $field['type'] ) ) {
352
+                            continue; // You need a type!
353
+                        }
354
+
355
+                        if ( 'info' === $field['type'] && isset( $field['raw_html'] ) && true === $field['raw_html'] ) {
356
+                            $field['type']                             = 'raw';
357
+                            $field['content']                          = $field['desc'];
358
+                            $field['desc']                             = '';
359
+                            $core->sections[ $k ]['fields'][ $fieldk ] = $field;
360
+                        } elseif ( 'info' === $field['type'] ) {
361
+                            if ( ! isset( $field['full_width'] ) ) {
362
+                                $field['full_width']                       = true;
363
+                                $core->sections[ $k ]['fields'][ $fieldk ] = $field;
364
+                            }
365
+                        }
366
+
367
+                        if ( 'raw' === $field['type'] ) {
368
+                            if ( isset( $field['align'] ) ) {
369
+                                $field['full_width'] = ! $field['align'];
370
+                                unset( $field['align'] );
371
+                            } elseif ( ! isset( $field['full_width'] ) ) {
372
+                                $field['full_width'] = true;
373
+                            }
374
+                            $core->sections[ $k ]['fields'][ $fieldk ] = $field;
375
+                        }
376
+
377
+                        /**
378
+                         * Filter 'redux/options/{opt_name}/field/{field.id}'
379
+                         *
380
+                         * @param array $field field config
381
+                         */
382
+
383
+                        // phpcs:ignore WordPress.NamingConventions.ValidHookName
384
+                        $field = apply_filters( "redux/options/{$core->args['opt_name']}/field/{$field['id']}/register", $field );
385
+
386
+                        $core->field_types[ $field['type'] ] = $core->field_types[ $field['type'] ] ?? array();
387
+
388
+                        $core->field_sections[ $field['type'] ][ $field['id'] ] = $k;
389
+
390
+                        $display = true;
391
+
392
+                        if ( isset( $_GET['page'] ) && $core->args['page_slug'] === $_GET['page'] ) { // phpcs:ignore WordPress.Security.NonceVerification
393
+                            if ( isset( $field['panel'] ) && false === $field['panel'] ) {
394
+                                $display = false;
395
+                            }
396
+                        }
397
+                        if ( isset( $field['customizer_only'] ) && true === $field['customizer_only'] ) {
398
+                            $display = false;
399
+                        }
400
+
401
+                        if ( isset( $section['customizer'] ) ) {
402
+                            $field['customizer']                       = $section['customizer'];
403
+                            $core->sections[ $k ]['fields'][ $fieldk ] = $field;
404
+                        }
405
+
406
+                        if ( isset( $field['permissions'] ) && false !== $field['permissions'] ) {
407
+                            if ( ! Redux_Helpers::current_user_can( $field['permissions'] ) ) {
408
+                                $data = $core->options[ $field['id'] ] ?? $core->options_defaults[ $field['id'] ];
409
+
410
+                                $this->hidden_perm_fields[ $field['id'] ] = $data;
411
+
412
+                                continue;
413
+                            }
414
+                        }
415
+
416
+                        if ( ! isset( $field['id'] ) ) {
417
+                            echo '<br /><h3>No field ID is set.</h3><pre>';
418
+
419
+                            // phpcs:ignore WordPress.PHP.DevelopmentFunctions
420
+                            print_r( $field );
421
+
422
+                            echo '</pre><br />';
423
+
424
+                            continue;
425
+                        }
426
+
427
+                        if ( isset( $field['type'] ) && 'section' === $field['type'] ) {
428
+                            if ( isset( $field['indent'] ) && true === $field['indent'] ) {
429
+                                $section_ident = true;
430
+                            } else {
431
+                                $section_ident = false;
432
+                            }
433
+                        }
434
+
435
+                        if ( isset( $field['type'] ) && 'info' === $field['type'] && $section_ident ) {
436
+                            $field['indent'] = true;
437
+                        }
438
+
439
+                        $th = $core->render_class->get_header_html( $field );
440
+
441
+                        $field['name'] = $core->args['opt_name'] . '[' . $field['id'] . ']';
442
+
443
+                        // Set the default value if present.
444
+                        $core->options_defaults[ $field['id'] ] = $core->options_defaults[ $field['id'] ] ?? '';
445
+
446
+                        // Set the defaults to the value if not present.
447
+                        $do_update = false;
448
+
449
+                        // Check fields for values in the default parameter.
450
+                        if ( ! isset( $core->options[ $field['id'] ] ) && isset( $field['default'] ) ) {
451
+                            $core->options_defaults[ $field['id'] ] = $field['default'];
452
+                            $core->options[ $field['id'] ]          = $field['default'];
453
+                            $do_update                              = true;
454
+
455
+                            // Check fields that hae no default value, but an option value with settings to
456
+                            // be saved by default.
457
+                        } elseif ( ! isset( $core->options[ $field['id'] ] ) && isset( $field['options'] ) ) {
458
+
459
+                            // If a sorter field, check for options and save them as defaults.
460
+                            if ( 'sorter' === $field['type'] || 'sortable' === $field['type'] ) {
461
+                                $core->options_defaults[ $field['id'] ] = $field['options'];
462
+                                $core->options[ $field['id'] ]          = $field['options'];
463
+                                $do_update                              = true;
464
+                            }
465
+                        }
466
+
467
+                        // CORRECT URLS if media URLs are wrong, but attachment IDs are present.
468
+                        if ( 'media' === $field['type'] ) {
469
+                            if ( isset( $core->options[ $field['id'] ]['id'] ) && isset( $core->options[ $field['id'] ]['url'] ) && ! empty( $core->options[ $field['id'] ]['url'] ) && strpos( $core->options[ $field['id'] ]['url'], str_replace( 'https://', '', WP_CONTENT_URL ) ) === false ) {
470
+                                $data = wp_get_attachment_url( $core->options[ $field['id'] ]['id'] );
471
+
472
+                                if ( isset( $data ) && ! empty( $data ) ) {
473
+                                    $core->options[ $field['id'] ]['url'] = $data;
474
+
475
+                                    $data = wp_get_attachment_image_src(
476
+                                        $core->options[ $field['id'] ]['id'],
477
+                                        array(
478
+                                            150,
479
+                                            150,
480
+                                        )
481
+                                    );
482
+
483
+                                    $core->options[ $field['id'] ]['thumbnail'] = $data[0];
484
+                                    $do_update                                  = true;
485
+                                }
486
+                            }
487
+                        }
488
+
489
+                        if ( 'background' === $field['type'] ) {
490
+                            if ( isset( $core->options[ $field['id'] ]['media']['id'] ) && isset( $core->options[ $field['id'] ]['background-image'] ) && ! empty( $core->options[ $field['id'] ]['background-image'] ) && strpos( $core->options[ $field['id'] ]['background-image'], str_replace( array( 'https://', 'https://' ), '', WP_CONTENT_URL ) ) === false ) {
491
+                                $data = wp_get_attachment_url( $core->options[ $field['id'] ]['media']['id'] );
492
+
493
+                                if ( isset( $data ) && ! empty( $data ) ) {
494
+                                    $core->options[ $field['id'] ]['background-image'] = $data;
495
+
496
+                                    $data = wp_get_attachment_image_src(
497
+                                        $core->options[ $field['id'] ]['media']['id'],
498
+                                        array(
499
+                                            150,
500
+                                            150,
501
+                                        )
502
+                                    );
503
+
504
+                                    $core->options[ $field['id'] ]['media']['thumbnail'] = $data[0];
505
+                                    $do_update = true;
506
+                                }
507
+                            }
508
+                        }
509
+
510
+                        if ( 'slides' === $field['type'] ) {
511
+                            if ( isset( $core->options[ $field['id'] ] ) && is_array( $core->options[ $field['id'] ] ) && isset( $core->options[ $field['id'] ][0]['attachment_id'] ) && isset( $core->options[ $field['id'] ][0]['image'] ) && ! empty( $core->options[ $field['id'] ][0]['image'] ) && strpos( $core->options[ $field['id'] ][0]['image'], str_replace( array( 'https://', 'https://' ), '', WP_CONTENT_URL ) ) === false ) {
512
+                                foreach ( $core->options[ $field['id'] ] as $key => $val ) {
513
+                                    $data = wp_get_attachment_url( $val['attachment_id'] );
514
+
515
+                                    if ( isset( $data ) && ! empty( $data ) ) {
516
+                                        $core->options[ $field['id'] ][ $key ]['image'] = $data;
517
+
518
+                                        $data = wp_get_attachment_image_src(
519
+                                            $val['attachment_id'],
520
+                                            array(
521
+                                                150,
522
+                                                150,
523
+                                            )
524
+                                        );
525
+
526
+                                        $core->options[ $field['id'] ][ $key ]['thumb'] = $data[0];
527
+                                        $do_update                                      = true;
528
+                                    }
529
+                                }
530
+                            }
531
+                        }
532
+                        // END -> CORRECT URLS if media URLs are wrong, but attachment IDs are present.
533
+                        if ( true === $do_update && ! isset( $core->never_save_to_db ) ) {
534
+                            if ( $core->args['save_defaults'] ) { // Only save that to the DB if allowed to.
535
+                                $run_update = true;
536
+                            }
537
+                        }
538
+
539
+                        if ( ! isset( $field['class'] ) ) { // No errors, please.
540
+                            $field['class'] = '';
541
+                        }
542
+
543
+                        /**
544
+                         * Filter 'redux/options/{opt_name}/field/{field.id}'.
545
+                         *
546
+                         * @param array $field field config
547
+                         */
548
+
549
+                        // phpcs:ignore WordPress.NamingConventions.ValidHookName
550
+                        $field = apply_filters( "redux/options/{$core->args['opt_name']}/field/{$field['id']}", $field );
551
+
552
+                        if ( empty( $field ) ) {
553
+                            unset( $core->sections[ $k ]['fields'][ $fieldk ] );
554
+                            continue;
555
+                        }
556
+
557
+                        if ( ! empty( Redux_Core::$folds[ $field['id'] ]['parent'] ) ) { // This has some fold items, hide it by default.
558
+                            $field['class'] .= ' fold';
559
+                        }
560
+
561
+                        if ( ! empty( Redux_Core::$folds[ $field['id'] ]['children'] ) ) { // Sets the values you shoe fold children on.
562
+                            $field['class'] .= ' fold-parent';
563
+                        }
564
+
565
+                        if ( ! empty( $field['compiler'] ) ) {
566
+                            $field['class']                       .= ' compiler';
567
+                            $core->compiler_fields[ $field['id'] ] = 1;
568
+                        }
569
+
570
+                        if ( isset( $field['unit'] ) && ! isset( $field['units'] ) ) {
571
+                            $field['units'] = $field['unit'];
572
+                            unset( $field['unit'] );
573
+                        }
574
+
575
+                        $core->sections[ $k ]['fields'][ $fieldk ] = $field;
576
+
577
+                        if ( isset( $core->args['display_source'] ) ) {
578
+                            // phpcs:ignore WordPress.PHP.DevelopmentFunctions
579
+                            $th .= '<div id="' . $field['id'] . '-settings" style="display:none;"><pre>' . var_export( $core->sections[ $k ]['fields'][ $fieldk ], true ) . '</pre></div>';
580
+                            $th .= '<br /><a href="#TB_inline?width=600&height=800&inlineId=' . $field['id'] . '-settings" class="thickbox"><small>View Source</small></a>';
581
+                        }
582
+
583
+                        /**
584
+                         * Action 'redux/options/{opt_name}/field/{field.type}/register'
585
+                         */
586
+
587
+                        // phpcs:ignore WordPress.NamingConventions.ValidHookName
588
+                        do_action( "redux/options/{$core->args['opt_name']}/field/{$field['type']}/register", $field );
589
+
590
+                        $core->required_class->check_dependencies( $field );
591
+                        $core->field_head[ $field['id'] ] = $th;
592
+
593
+                        if ( ! $display || isset( $this->no_panel_section[ $k ] ) ) {
594
+                            $this->no_panel[] = $field['id'];
595
+                        } else {
596
+                            if ( isset( $field['disabled'] ) && $field['disabled'] ) {
597
+                                $field['class'] .= ' redux_disable_field';
598
+                            }
599
+
600
+                            if ( isset( $field['hidden'] ) && $field['hidden'] ) {
601
+                                $field['class'] .= ' redux_hide_field';
602
+                            }
603
+
604
+                            if ( true === $core->args['options_api'] ) {
605
+                                add_settings_field(
606
+                                    "{$fieldk}_field",
607
+                                    $th,
608
+                                    array(
609
+                                        $core->render_class,
610
+                                        'field_input',
611
+                                    ),
612
+                                    "{$core->args['opt_name']}{$k}_section_group",
613
+                                    "{$core->args['opt_name']}{$k}_section",
614
+                                    $field
615
+                                );
616
+                            }
617
+                        }
618
+                    }
619
+                }
620
+            }
621
+
622
+            /**
623
+             * Action 'redux/options/{opt_name}/register'
624
+             *
625
+             * @param array $section Option sections
626
+             */
627
+
628
+            // phpcs:ignore WordPress.NamingConventions.ValidHookName
629
+            do_action( "redux/options/{$core->args['opt_name']}/register", $core->sections );
630
+
631
+            if ( $run_update && ! isset( $core->never_save_to_db ) ) { // Always update the DB with new fields.
632
+                $this->set( $core->options );
633
+            }
634
+
635
+            if ( isset( $core->transients['run_compiler'] ) && $core->transients['run_compiler'] ) {
636
+
637
+                Redux_Core::$no_output = true;
638
+                $temp                  = $core->args['output_variables_prefix'];
639
+
640
+                // Allow the override of variable's prefix for use by SCSS or LESS.
641
+                if ( isset( $core->args['compiler_output_variables_prefix'] ) ) {
642
+                    $core->args['output_variables_prefix'] = $core->args['compiler_output_variables_prefix'];
643
+                }
644
+                $core->output_class->enqueue();
645
+                $core->args['output_variables_prefix'] = $temp;
646
+
647
+                // phpcs:ignore WordPress.NamingConventions.ValidVariableName
648
+                $compiler_css = $core->compilerCSS;
649
+
650
+                /**
651
+                 * Action 'redux/options/{opt_name}/compiler'
652
+                 *
653
+                 * @param array  $options Options.
654
+                 * @param string $css CSS that get sent to the compiler hook.
655
+                 * @param array  $changed_values Changed values.
656
+                 * @param array  $output_variables Output variables.
657
+                 */
658
+
659
+                // phpcs:ignore WordPress.NamingConventions.ValidHookName
660
+                do_action( "redux/options/{$core->args['opt_name']}/compiler", $core->options, $compiler_css, $core->transients['changed_values'], $core->output_variables );
661
+
662
+                /**
663
+                 * Action 'redux/options/{opt_name}/compiler/advanced'
664
+                 *
665
+                 * @param object $redux ReduxFramework object.
666
+                 */
667
+
668
+                // phpcs:ignore WordPress.NamingConventions.ValidHookName
669
+                do_action( "redux/options/{$core->args['opt_name']}/compiler/advanced", $core );
670
+
671
+                unset( $core->transients['run_compiler'] );
672
+                $core->transient_class->set();
673
+            }
674
+        }
675
+
676
+        /**
677
+         * Get default options into an array suitable for the settings API
678
+         *
679
+         * @since       1.0.0
680
+         * @access      public
681
+         * @return      array $this->options_defaults
682
+         */
683
+        public function default_values(): array {
684
+            $core = $this->core();
685
+
686
+            if ( ! is_null( $core->sections ) && is_null( $core->options_defaults ) ) {
687
+                $core->options_defaults = $core->options_defaults_class->default_values( $core->args['opt_name'], $core->sections, $core->wordpress_data );
688
+            }
689
+
690
+            /**
691
+             * Filter 'redux/options/{opt_name}/defaults'
692
+             *
693
+             * @param array $defaults option default values
694
+             */
695
+
696
+            $core->transients['changed_values'] = $core->transients['changed_values'] ?? array();
697
+
698
+            // phpcs:ignore WordPress.NamingConventions.ValidHookName
699
+            $core->options_defaults = apply_filters( "redux/options/{$core->args['opt_name']}/defaults", $core->options_defaults, $core->transients['changed_values'] );
700
+
701
+            return $core->options_defaults;
702
+        }
703
+
704
+        /**
705
+         * Validate the Options before insertion
706
+         *
707
+         * @param  array $plugin_options The option array.
708
+         *
709
+         * @return array|mixed|string
710
+         * @since  3.0.0
711
+         * @access public
712
+         */
713
+        public function validate_options( array $plugin_options ) {
714
+            $core = $this->core();
715
+
716
+            if ( true === Redux_Core::$validation_ran ) {
717
+                return $plugin_options;
718
+            }
719
+
720
+            Redux_Core::$validation_ran = true;
721
+
722
+            // Save the values not in the panel.
723
+            if ( isset( $plugin_options['redux-no_panel'] ) ) {
724
+                $keys = explode( '|', $plugin_options['redux-no_panel'] );
725
+                foreach ( $keys as $key ) {
726
+                    $plugin_options[ $key ] = $core->options[ $key ];
727
+                }
728
+                if ( isset( $plugin_options['redux-no_panel'] ) ) {
729
+                    unset( $plugin_options['redux-no_panel'] );
730
+                }
731
+            }
732
+
733
+            if ( is_array( $this->hidden_perm_fields ) && ! empty( $this->hidden_perm_fields ) ) {
734
+                foreach ( $this->hidden_perm_fields as $id => $data ) {
735
+                    $plugin_options[ $id ] = $data;
736
+                }
737
+            }
738
+
739
+            if ( $plugin_options === $core->options ) {
740
+                return $plugin_options;
741
+            }
742
+
743
+            $time = time();
744
+
745
+            // Sets last saved time.
746
+            $core->transients['last_save'] = $time;
747
+
748
+            $imported_options = array();
749
+
750
+            if ( isset( $plugin_options['import_code'] ) && '' !== $plugin_options['import_code'] ) {
751
+                $imported_options = json_decode( $plugin_options['import_code'], true );
752
+            }
753
+
754
+            // Import.
755
+            $core->transients['last_save_mode'] = 'import'; // Last save mode.
756
+            $core->transients['last_compiler']  = $time;
757
+            $core->transients['last_import']    = $time;
758
+            $core->transients['run_compiler']   = 1;
759
+
760
+            if ( is_array( $imported_options ) && ! empty( $imported_options ) && isset( $imported_options['redux-backup'] ) && ( 1 === $imported_options['redux-backup'] || '1' === $imported_options['redux-backup'] ) ) {
761
+                $core->transients['changed_values'] = array();
762
+                foreach ( $plugin_options as $key => $value ) {
763
+                    if ( isset( $imported_options[ $key ] ) && $value !== $imported_options[ $key ] ) {
764
+                        $plugin_options[ $key ]                     = $value;
765
+                        $core->transients['changed_values'][ $key ] = $value;
766
+                    }
767
+                }
768
+
769
+                /**
770
+                 * Action 'redux/options/{opt_name}/import'.
771
+                 *
772
+                 * @param  &array [&$plugin_options, redux_options]
773
+                 */
774
+
775
+                // phpcs:ignore WordPress.NamingConventions.ValidHookName
776
+                do_action_ref_array(
777
+                    "redux/options/{$core->args['opt_name']}/import", // phpcs:ignore WordPress.NamingConventions.ValidHookName
778
+                    array(
779
+                        &$plugin_options,
780
+                        $imported_options,
781
+                        $core->transients['changed_values'],
782
+                    )
783
+                );
784
+
785
+                setcookie( 'redux_current_tab_' . $core->args['opt_name'], '', 1, '/', $time + 1000, '/' );
786
+                $_COOKIE[ 'redux_current_tab_' . $core->args['opt_name'] ] = 1;
787
+
788
+                unset( $plugin_options['defaults'], $plugin_options['compiler'], $plugin_options['import'], $plugin_options['import_code'] );
789
+                if ( in_array( $core->args['database'], array( 'transient', 'theme_mods', 'theme_mods_expanded', 'network' ), true ) ) {
790
+                    $this->set( $plugin_options );
791
+
792
+                    return null;
793
+                }
794
+
795
+                $plugin_options = wp_parse_args( $imported_options, $plugin_options );
796
+
797
+                $core->transient_class->set();
798
+
799
+                return $plugin_options;
800
+            }
801
+
802
+            // Reset all to defaults.
803
+            if ( ! empty( $plugin_options['defaults'] ) ) {
804
+                if ( empty( $core->options_defaults ) ) {
805
+                    $core->options_defaults = $core->_default_values();
806
+                }
807
+
808
+                /**
809
+                 * Filter: 'redux/validate/{opt_name}/defaults'.
810
+                 *
811
+                 * @param  &array [ $this->options_defaults, $plugin_options]
812
+                 */
813
+
814
+                // phpcs:ignore WordPress.NamingConventions.ValidHookName
815
+                $plugin_options = apply_filters( "redux/validate/{$core->args['opt_name']}/defaults", $core->options_defaults );
816
+
817
+                $core->transients['changed_values'] = array();
818
+
819
+                if ( empty( $core->options ) ) {
820
+                    $core->options = $core->options_defaults;
821
+                }
822
+
823
+                foreach ( $core->options as $key => $value ) {
824
+                    if ( isset( $plugin_options[ $key ] ) && $plugin_options[ $key ] !== $value ) {
825
+                        $core->transients['changed_values'][ $key ] = $value;
826
+                    }
827
+                }
828
+
829
+                $core->transients['run_compiler']   = 1;
830
+                $core->transients['last_save_mode'] = 'defaults'; // Last save mode.
831
+
832
+                $core->transient_class->set();
833
+
834
+                return $plugin_options;
835
+            }
836
+
837
+            // Section reset to default.
838
+            if ( ! empty( $plugin_options['defaults-section'] ) ) {
839
+                if ( isset( $plugin_options['redux-section'] ) && isset( $core->sections[ $plugin_options['redux-section'] ]['fields'] ) ) {
840
+                    if ( empty( $core->options_defaults ) ) {
841
+                        $core->options_defaults = $core->_default_values();
842
+                    }
843
+
844
+                    foreach ( $core->sections[ $plugin_options['redux-section'] ]['fields'] as $field ) {
845
+                        if ( 'tabbed' === $field['type'] ) {
846
+                            if ( ! empty( $field['tabs'] ) ) {
847
+                                foreach ( $field['tabs'] as $val ) {
848
+                                    if ( ! empty( $val['fields'] ) ) {
849
+                                        foreach ( $val['fields'] as $f ) {
850
+                                            if ( isset( $core->options_defaults[ $f['id'] ] ) ) {
851
+                                                $plugin_options[ $f['id'] ] = $core->options_defaults[ $f['id'] ];
852
+                                            } else {
853
+                                                $plugin_options[ $f['id'] ] = '';
854
+                                            }
855
+                                        }
856
+                                    }
857
+                                }
858
+                            }
859
+                        } elseif ( 'repeater' === $field['type'] ) {
860
+                            if ( ! empty( $field['fields'] ) ) {
861
+                                foreach ( $field['fields'] as $f ) {
862
+                                    if ( isset( $core->options_defaults[ $f['id'] ] ) ) {
863
+                                        $plugin_options[ $f['id'] ] = $core->options_defaults[ $f['id'] ];
864
+                                    } else {
865
+                                        $plugin_options[ $f['id'] ] = '';
866
+                                    }
867
+                                }
868
+                            }
869
+                        } else {
870
+                            if ( isset( $core->options_defaults[ $field['id'] ] ) ) {
871
+                                $plugin_options[ $field['id'] ] = $core->options_defaults[ $field['id'] ];
872
+                            } else {
873
+                                $plugin_options[ $field['id'] ] = '';
874
+                            }
875
+                        }
876
+
877
+                        if ( isset( $field['compiler'] ) ) {
878
+                            $compiler = true;
879
+                        }
880
+                    }
881
+
882
+                    /**
883
+                     * Filter: 'redux/validate/{opt_name}/defaults_section'.
884
+                     *
885
+                     * @param  &array [ $this->options_defaults, $plugin_options]
886
+                     */
887
+
888
+                    // phpcs:ignore WordPress.NamingConventions.ValidHookName
889
+                    $plugin_options = apply_filters( "redux/validate/{$core->args['opt_name']}/defaults_section", $plugin_options );
890
+                }
891
+
892
+                $core->transients['changed_values'] = array();
893
+
894
+                foreach ( $core->options as $key => $value ) {
895
+                    if ( isset( $plugin_options[ $key ] ) && $plugin_options[ $key ] !== $value ) {
896
+                        $core->transients['changed_values'][ $key ] = $value;
897
+                    }
898
+                }
899
+
900
+                if ( isset( $compiler ) ) {
901
+                    $core->transients['last_compiler'] = $time;
902
+                    $core->transients['run_compiler']  = 1;
903
+                }
904
+
905
+                $core->transients['last_save_mode'] = 'defaults_section'; // Last save mode.
906
+
907
+                unset( $plugin_options['defaults'], $plugin_options['defaults_section'], $plugin_options['import'], $plugin_options['import_code'], $plugin_options['import_link'], $plugin_options['compiler'], $plugin_options['redux-section'] );
908
+
909
+                $core->transient_class->set();
910
+
911
+                return $plugin_options;
912
+            }
913
+
914
+            $core->transients['last_save_mode'] = 'normal'; // Last save mode.
915
+
916
+            /**
917
+             * Filter: 'redux/validate/{opt_name}/before_validation'
918
+             *
919
+             * @param  &array [&$plugin_options, redux_options]
920
+             */
921
+
922
+            // phpcs:ignore WordPress.NamingConventions.ValidHookName
923
+            $plugin_options = apply_filters( "redux/validate/{$core->args['opt_name']}/before_validation", $plugin_options, $core->options );
924
+
925
+            // Validate fields (if needed).
926
+            $plugin_options = $core->validate_class->validate( $plugin_options, $core->options, $core->sections );
927
+
928
+            // Sanitize options, if needed.
929
+            $plugin_options = $core->sanitize_class->sanitize( $plugin_options, $core->options, $core->sections );
930
+
931
+            if ( ! empty( $core->errors ) || ! empty( $core->warnings ) || ! empty( $core->sanitize ) ) {
932
+                $core->transients['notices'] = array(
933
+                    'errors'   => $core->errors,
934
+                    'warnings' => $core->warnings,
935
+                    'sanitize' => $core->sanitize,
936
+                );
937
+            }
938
+
939
+            if ( ! isset( $core->transients['changed_values'] ) ) {
940
+                $core->transients['changed_values'] = array();
941
+            }
942
+
943
+            /**
944
+             * Action 'redux/options/{opt_name}/validate'
945
+             *
946
+             * @param  &array [&$plugin_options, redux_options]
947
+             */
948
+            // phpcs:ignore WordPress.NamingConventions.ValidHookName
949
+            do_action_ref_array(
950
+            // phpcs:ignore WordPress.NamingConventions.ValidHookName
951
+                "redux/options/{$core->args['opt_name']}/validate",
952
+                array(
953
+                    &$plugin_options,
954
+                    $core->options,
955
+                    $core->transients['changed_values'],
956
+                )
957
+            );
958
+
959
+            if ( ! empty( $plugin_options['compiler'] ) ) {
960
+                unset( $plugin_options['compiler'] );
961
+
962
+                $core->transients['last_compiler'] = $time;
963
+                $core->transients['run_compiler']  = 1;
964
+            }
965
+
966
+            $core->transients['changed_values'] = array(); // Changed values since last save.
967
+
968
+            if ( ! empty( $core->options ) ) {
969
+                foreach ( $core->options as $key => $value ) {
970
+                    if ( isset( $plugin_options[ $key ] ) && $plugin_options[ $key ] !== $value ) {
971
+                        $core->transients['changed_values'][ $key ] = $value;
972
+                    }
973
+                }
974
+            }
975
+
976
+            unset( $plugin_options['defaults'], $plugin_options['defaults_section'], $plugin_options['import'], $plugin_options['import_code'], $plugin_options['import_link'], $plugin_options['compiler'], $plugin_options['redux-section'] );
977
+            if ( in_array( $core->args['database'], array( 'transient', 'theme_mods', 'theme_mods_expanded' ), true ) ) {
978
+                $core->set( $core->args['opt_name'], $plugin_options );
979
+                return null;
980
+            }
981
+
982
+            if ( defined( 'WP_CACHE' ) && WP_CACHE && class_exists( 'W3_ObjectCache' ) && function_exists( 'w3_instance' ) ) {
983
+                $w3_inst = w3_instance( 'W3_ObjectCache' );
984
+                $w3      = $w3_inst->instance();
985
+                $key     = $w3->_get_cache_key( $core->args['opt_name'] . '-transients', 'transient' );
986
+                $w3->delete( $key, 'transient', true );
987
+            }
988
+
989
+            $core->transient_class->set();
990
+
991
+            return $plugin_options;
992
+        }
993
+
994
+        /**
995
+         * ->get_default(); This is used to return the default value if default_show is set.
996
+         *
997
+         * @param string $opt_name The option name to return.
998
+         * @param mixed  $defaults (null) The value to return if default not set.
999
+         *
1000
+         * @return      mixed $default
1001
+         * @since       1.0.1
1002
+         * @access      public
1003
+         */
1004
+        public function get_default( string $opt_name, $defaults = null ) {
1005
+            if ( true === $this->args['default_show'] ) {
1006
+
1007
+                if ( empty( $this->options_defaults ) ) {
1008
+                    $this->default_values(); // fill cache.
1009
+                }
1010
+
1011
+                return array_key_exists( $opt_name, $this->options_defaults ) ? $this->options_defaults[ $opt_name ] : $defaults;
1012
+            }
1013
+
1014
+            return '';
1015
+        }
1016
+
1017
+        /**
1018
+         * Get the default value for an option
1019
+         *
1020
+         * @param string $key       The option's ID.
1021
+         * @param string $array_key The key of the default's array.
1022
+         *
1023
+         * @return mixed
1024
+         * @since  3.3.6
1025
+         * @access public
1026
+         */
1027
+        public function get_default_value( string $key, $array_key = false ) {
1028
+            if ( empty( $this->options_defaults ) ) {
1029
+                $this->options_defaults = $this->default_values();
1030
+            }
1031
+
1032
+            $defaults = $this->options_defaults;
1033
+            $value    = '';
1034
+
1035
+            if ( isset( $defaults[ $key ] ) ) {
1036
+                if ( false !== $array_key && isset( $defaults[ $key ][ $array_key ] ) ) {
1037
+                    $value = $defaults[ $key ][ $array_key ];
1038
+                } else {
1039
+                    $value = $defaults[ $key ];
1040
+                }
1041
+            }
1042
+
1043
+            return $value;
1044
+        }
1045
+    }
1046 1046
 }
Please login to merge, or discard this patch.
Spacing   +78 added lines, -78 removed lines patch added patch discarded remove patch
@@ -76,9 +76,9 @@  discard block
 block discarded – undo
76 76
 			foreach ( $sections as $key => $section ) {
77 77
 				if ( 'fields' === $key ) {
78 78
 					foreach ( $section as $field ) {
79
-						if ( ! empty( $field['id'] ) && ! empty( $field['data'] ) && ! empty( $options_values[ $field['id'] ] ) && Redux_Helpers::is_integer( $options_values[ $field['id'] ] ) ) {
79
+						if ( ! empty( $field['id'] ) && ! empty( $field['data'] ) && ! empty( $options_values[$field['id']] ) && Redux_Helpers::is_integer( $options_values[$field['id']] ) ) {
80 80
 							//phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals -- Third party hook. Cannot change.
81
-							$options_values[ $field['id'] ] = apply_filters( 'wpml_object_id', $options_values[ $field['id'] ], $field['data'], true );
81
+							$options_values[$field['id']] = apply_filters( 'wpml_object_id', $options_values[$field['id']], $field['data'], true );
82 82
 						}
83 83
 					}
84 84
 				} elseif ( is_array( $section ) && ! empty( $section ) ) {
@@ -193,10 +193,10 @@  discard block
 block discarded – undo
193 193
 				// Store the changed values in the transient.
194 194
 				if ( $value !== $core->options ) {
195 195
 					foreach ( $value as $k => $v ) {
196
-						if ( ! isset( $core->options[ $k ] ) ) {
197
-							$core->options[ $k ] = '';
198
-						} elseif ( $v === $core->options[ $k ] ) {
199
-							unset( $core->options[ $k ] );
196
+						if ( ! isset( $core->options[$k] ) ) {
197
+							$core->options[$k] = '';
198
+						} elseif ( $v === $core->options[$k] ) {
199
+							unset( $core->options[$k] );
200 200
 						}
201 201
 					}
202 202
 
@@ -232,7 +232,7 @@  discard block
 block discarded – undo
232 232
 				 */
233 233
 
234 234
 				// phpcs:ignore WordPress.NamingConventions.ValidHookName, WordPress.NamingConventions.PrefixAllGlobals -- Misflag, variable begins with plugin name.
235
-				$GLOBALS[ $redux_options_global ] = apply_filters( "redux/options/{$core->args['opt_name']}/global_variable", $core->options );
235
+				$GLOBALS[$redux_options_global] = apply_filters( "redux/options/{$core->args['opt_name']}/global_variable", $core->options );
236 236
 			}
237 237
 		}
238 238
 
@@ -296,7 +296,7 @@  discard block
 block discarded – undo
296 296
 				}
297 297
 
298 298
 				if ( empty( $section ) ) {
299
-					unset( $core->sections[ $k ] );
299
+					unset( $core->sections[$k] );
300 300
 					continue;
301 301
 				}
302 302
 
@@ -306,7 +306,7 @@  discard block
 block discarded – undo
306 306
 
307 307
 				if ( isset( $section['customizer_only'] ) && true === $section['customizer_only'] ) {
308 308
 					$section['panel']     = false;
309
-					$core->sections[ $k ] = $section;
309
+					$core->sections[$k] = $section;
310 310
 				}
311 311
 
312 312
 				$heading = $section['heading'] ?? $section['title'];
@@ -320,10 +320,10 @@  discard block
 block discarded – undo
320 320
 
321 321
 							if ( ! in_array( $field_type, array( 'section', 'divide', 'info', 'raw' ), true ) ) {
322 322
 								$field_id = $field_data['id'];
323
-								$default  = $core->options_defaults[ $field_id ] ?? '';
324
-								$data     = $core->options[ $field_id ] ?? $default;
323
+								$default  = $core->options_defaults[$field_id] ?? '';
324
+								$data     = $core->options[$field_id] ?? $default;
325 325
 
326
-								$this->hidden_perm_fields[ $field_id ] = $data;
326
+								$this->hidden_perm_fields[$field_id] = $data;
327 327
 							}
328 328
 						}
329 329
 
@@ -332,7 +332,7 @@  discard block
 block discarded – undo
332 332
 				}
333 333
 
334 334
 				if ( ! $display || ! function_exists( 'add_settings_section' ) ) {
335
-					$this->no_panel_section[ $k ] = $section;
335
+					$this->no_panel_section[$k] = $section;
336 336
 				} else {
337 337
 					add_settings_section(
338 338
 						$core->args['opt_name'] . $k . '_section',
@@ -356,11 +356,11 @@  discard block
 block discarded – undo
356 356
 							$field['type']                             = 'raw';
357 357
 							$field['content']                          = $field['desc'];
358 358
 							$field['desc']                             = '';
359
-							$core->sections[ $k ]['fields'][ $fieldk ] = $field;
359
+							$core->sections[$k]['fields'][$fieldk] = $field;
360 360
 						} elseif ( 'info' === $field['type'] ) {
361 361
 							if ( ! isset( $field['full_width'] ) ) {
362 362
 								$field['full_width']                       = true;
363
-								$core->sections[ $k ]['fields'][ $fieldk ] = $field;
363
+								$core->sections[$k]['fields'][$fieldk] = $field;
364 364
 							}
365 365
 						}
366 366
 
@@ -371,7 +371,7 @@  discard block
 block discarded – undo
371 371
 							} elseif ( ! isset( $field['full_width'] ) ) {
372 372
 								$field['full_width'] = true;
373 373
 							}
374
-							$core->sections[ $k ]['fields'][ $fieldk ] = $field;
374
+							$core->sections[$k]['fields'][$fieldk] = $field;
375 375
 						}
376 376
 
377 377
 						/**
@@ -383,9 +383,9 @@  discard block
 block discarded – undo
383 383
 						// phpcs:ignore WordPress.NamingConventions.ValidHookName
384 384
 						$field = apply_filters( "redux/options/{$core->args['opt_name']}/field/{$field['id']}/register", $field );
385 385
 
386
-						$core->field_types[ $field['type'] ] = $core->field_types[ $field['type'] ] ?? array();
386
+						$core->field_types[$field['type']] = $core->field_types[$field['type']] ?? array();
387 387
 
388
-						$core->field_sections[ $field['type'] ][ $field['id'] ] = $k;
388
+						$core->field_sections[$field['type']][$field['id']] = $k;
389 389
 
390 390
 						$display = true;
391 391
 
@@ -400,14 +400,14 @@  discard block
 block discarded – undo
400 400
 
401 401
 						if ( isset( $section['customizer'] ) ) {
402 402
 							$field['customizer']                       = $section['customizer'];
403
-							$core->sections[ $k ]['fields'][ $fieldk ] = $field;
403
+							$core->sections[$k]['fields'][$fieldk] = $field;
404 404
 						}
405 405
 
406 406
 						if ( isset( $field['permissions'] ) && false !== $field['permissions'] ) {
407 407
 							if ( ! Redux_Helpers::current_user_can( $field['permissions'] ) ) {
408
-								$data = $core->options[ $field['id'] ] ?? $core->options_defaults[ $field['id'] ];
408
+								$data = $core->options[$field['id']] ?? $core->options_defaults[$field['id']];
409 409
 
410
-								$this->hidden_perm_fields[ $field['id'] ] = $data;
410
+								$this->hidden_perm_fields[$field['id']] = $data;
411 411
 
412 412
 								continue;
413 413
 							}
@@ -441,79 +441,79 @@  discard block
 block discarded – undo
441 441
 						$field['name'] = $core->args['opt_name'] . '[' . $field['id'] . ']';
442 442
 
443 443
 						// Set the default value if present.
444
-						$core->options_defaults[ $field['id'] ] = $core->options_defaults[ $field['id'] ] ?? '';
444
+						$core->options_defaults[$field['id']] = $core->options_defaults[$field['id']] ?? '';
445 445
 
446 446
 						// Set the defaults to the value if not present.
447 447
 						$do_update = false;
448 448
 
449 449
 						// Check fields for values in the default parameter.
450
-						if ( ! isset( $core->options[ $field['id'] ] ) && isset( $field['default'] ) ) {
451
-							$core->options_defaults[ $field['id'] ] = $field['default'];
452
-							$core->options[ $field['id'] ]          = $field['default'];
450
+						if ( ! isset( $core->options[$field['id']] ) && isset( $field['default'] ) ) {
451
+							$core->options_defaults[$field['id']] = $field['default'];
452
+							$core->options[$field['id']]          = $field['default'];
453 453
 							$do_update                              = true;
454 454
 
455 455
 							// Check fields that hae no default value, but an option value with settings to
456 456
 							// be saved by default.
457
-						} elseif ( ! isset( $core->options[ $field['id'] ] ) && isset( $field['options'] ) ) {
457
+						} elseif ( ! isset( $core->options[$field['id']] ) && isset( $field['options'] ) ) {
458 458
 
459 459
 							// If a sorter field, check for options and save them as defaults.
460 460
 							if ( 'sorter' === $field['type'] || 'sortable' === $field['type'] ) {
461
-								$core->options_defaults[ $field['id'] ] = $field['options'];
462
-								$core->options[ $field['id'] ]          = $field['options'];
461
+								$core->options_defaults[$field['id']] = $field['options'];
462
+								$core->options[$field['id']]          = $field['options'];
463 463
 								$do_update                              = true;
464 464
 							}
465 465
 						}
466 466
 
467 467
 						// CORRECT URLS if media URLs are wrong, but attachment IDs are present.
468 468
 						if ( 'media' === $field['type'] ) {
469
-							if ( isset( $core->options[ $field['id'] ]['id'] ) && isset( $core->options[ $field['id'] ]['url'] ) && ! empty( $core->options[ $field['id'] ]['url'] ) && strpos( $core->options[ $field['id'] ]['url'], str_replace( 'https://', '', WP_CONTENT_URL ) ) === false ) {
470
-								$data = wp_get_attachment_url( $core->options[ $field['id'] ]['id'] );
469
+							if ( isset( $core->options[$field['id']]['id'] ) && isset( $core->options[$field['id']]['url'] ) && ! empty( $core->options[$field['id']]['url'] ) && strpos( $core->options[$field['id']]['url'], str_replace( 'https://', '', WP_CONTENT_URL ) ) === false ) {
470
+								$data = wp_get_attachment_url( $core->options[$field['id']]['id'] );
471 471
 
472 472
 								if ( isset( $data ) && ! empty( $data ) ) {
473
-									$core->options[ $field['id'] ]['url'] = $data;
473
+									$core->options[$field['id']]['url'] = $data;
474 474
 
475 475
 									$data = wp_get_attachment_image_src(
476
-										$core->options[ $field['id'] ]['id'],
476
+										$core->options[$field['id']]['id'],
477 477
 										array(
478 478
 											150,
479 479
 											150,
480 480
 										)
481 481
 									);
482 482
 
483
-									$core->options[ $field['id'] ]['thumbnail'] = $data[0];
483
+									$core->options[$field['id']]['thumbnail'] = $data[0];
484 484
 									$do_update                                  = true;
485 485
 								}
486 486
 							}
487 487
 						}
488 488
 
489 489
 						if ( 'background' === $field['type'] ) {
490
-							if ( isset( $core->options[ $field['id'] ]['media']['id'] ) && isset( $core->options[ $field['id'] ]['background-image'] ) && ! empty( $core->options[ $field['id'] ]['background-image'] ) && strpos( $core->options[ $field['id'] ]['background-image'], str_replace( array( 'https://', 'https://' ), '', WP_CONTENT_URL ) ) === false ) {
491
-								$data = wp_get_attachment_url( $core->options[ $field['id'] ]['media']['id'] );
490
+							if ( isset( $core->options[$field['id']]['media']['id'] ) && isset( $core->options[$field['id']]['background-image'] ) && ! empty( $core->options[$field['id']]['background-image'] ) && strpos( $core->options[$field['id']]['background-image'], str_replace( array( 'https://', 'https://' ), '', WP_CONTENT_URL ) ) === false ) {
491
+								$data = wp_get_attachment_url( $core->options[$field['id']]['media']['id'] );
492 492
 
493 493
 								if ( isset( $data ) && ! empty( $data ) ) {
494
-									$core->options[ $field['id'] ]['background-image'] = $data;
494
+									$core->options[$field['id']]['background-image'] = $data;
495 495
 
496 496
 									$data = wp_get_attachment_image_src(
497
-										$core->options[ $field['id'] ]['media']['id'],
497
+										$core->options[$field['id']]['media']['id'],
498 498
 										array(
499 499
 											150,
500 500
 											150,
501 501
 										)
502 502
 									);
503 503
 
504
-									$core->options[ $field['id'] ]['media']['thumbnail'] = $data[0];
504
+									$core->options[$field['id']]['media']['thumbnail'] = $data[0];
505 505
 									$do_update = true;
506 506
 								}
507 507
 							}
508 508
 						}
509 509
 
510 510
 						if ( 'slides' === $field['type'] ) {
511
-							if ( isset( $core->options[ $field['id'] ] ) && is_array( $core->options[ $field['id'] ] ) && isset( $core->options[ $field['id'] ][0]['attachment_id'] ) && isset( $core->options[ $field['id'] ][0]['image'] ) && ! empty( $core->options[ $field['id'] ][0]['image'] ) && strpos( $core->options[ $field['id'] ][0]['image'], str_replace( array( 'https://', 'https://' ), '', WP_CONTENT_URL ) ) === false ) {
512
-								foreach ( $core->options[ $field['id'] ] as $key => $val ) {
511
+							if ( isset( $core->options[$field['id']] ) && is_array( $core->options[$field['id']] ) && isset( $core->options[$field['id']][0]['attachment_id'] ) && isset( $core->options[$field['id']][0]['image'] ) && ! empty( $core->options[$field['id']][0]['image'] ) && strpos( $core->options[$field['id']][0]['image'], str_replace( array( 'https://', 'https://' ), '', WP_CONTENT_URL ) ) === false ) {
512
+								foreach ( $core->options[$field['id']] as $key => $val ) {
513 513
 									$data = wp_get_attachment_url( $val['attachment_id'] );
514 514
 
515 515
 									if ( isset( $data ) && ! empty( $data ) ) {
516
-										$core->options[ $field['id'] ][ $key ]['image'] = $data;
516
+										$core->options[$field['id']][$key]['image'] = $data;
517 517
 
518 518
 										$data = wp_get_attachment_image_src(
519 519
 											$val['attachment_id'],
@@ -523,7 +523,7 @@  discard block
 block discarded – undo
523 523
 											)
524 524
 										);
525 525
 
526
-										$core->options[ $field['id'] ][ $key ]['thumb'] = $data[0];
526
+										$core->options[$field['id']][$key]['thumb'] = $data[0];
527 527
 										$do_update                                      = true;
528 528
 									}
529 529
 								}
@@ -550,21 +550,21 @@  discard block
 block discarded – undo
550 550
 						$field = apply_filters( "redux/options/{$core->args['opt_name']}/field/{$field['id']}", $field );
551 551
 
552 552
 						if ( empty( $field ) ) {
553
-							unset( $core->sections[ $k ]['fields'][ $fieldk ] );
553
+							unset( $core->sections[$k]['fields'][$fieldk] );
554 554
 							continue;
555 555
 						}
556 556
 
557
-						if ( ! empty( Redux_Core::$folds[ $field['id'] ]['parent'] ) ) { // This has some fold items, hide it by default.
557
+						if ( ! empty( Redux_Core::$folds[$field['id']]['parent'] ) ) { // This has some fold items, hide it by default.
558 558
 							$field['class'] .= ' fold';
559 559
 						}
560 560
 
561
-						if ( ! empty( Redux_Core::$folds[ $field['id'] ]['children'] ) ) { // Sets the values you shoe fold children on.
561
+						if ( ! empty( Redux_Core::$folds[$field['id']]['children'] ) ) { // Sets the values you shoe fold children on.
562 562
 							$field['class'] .= ' fold-parent';
563 563
 						}
564 564
 
565 565
 						if ( ! empty( $field['compiler'] ) ) {
566 566
 							$field['class']                       .= ' compiler';
567
-							$core->compiler_fields[ $field['id'] ] = 1;
567
+							$core->compiler_fields[$field['id']] = 1;
568 568
 						}
569 569
 
570 570
 						if ( isset( $field['unit'] ) && ! isset( $field['units'] ) ) {
@@ -572,11 +572,11 @@  discard block
 block discarded – undo
572 572
 							unset( $field['unit'] );
573 573
 						}
574 574
 
575
-						$core->sections[ $k ]['fields'][ $fieldk ] = $field;
575
+						$core->sections[$k]['fields'][$fieldk] = $field;
576 576
 
577 577
 						if ( isset( $core->args['display_source'] ) ) {
578 578
 							// phpcs:ignore WordPress.PHP.DevelopmentFunctions
579
-							$th .= '<div id="' . $field['id'] . '-settings" style="display:none;"><pre>' . var_export( $core->sections[ $k ]['fields'][ $fieldk ], true ) . '</pre></div>';
579
+							$th .= '<div id="' . $field['id'] . '-settings" style="display:none;"><pre>' . var_export( $core->sections[$k]['fields'][$fieldk], true ) . '</pre></div>';
580 580
 							$th .= '<br /><a href="#TB_inline?width=600&height=800&inlineId=' . $field['id'] . '-settings" class="thickbox"><small>View Source</small></a>';
581 581
 						}
582 582
 
@@ -588,9 +588,9 @@  discard block
 block discarded – undo
588 588
 						do_action( "redux/options/{$core->args['opt_name']}/field/{$field['type']}/register", $field );
589 589
 
590 590
 						$core->required_class->check_dependencies( $field );
591
-						$core->field_head[ $field['id'] ] = $th;
591
+						$core->field_head[$field['id']] = $th;
592 592
 
593
-						if ( ! $display || isset( $this->no_panel_section[ $k ] ) ) {
593
+						if ( ! $display || isset( $this->no_panel_section[$k] ) ) {
594 594
 							$this->no_panel[] = $field['id'];
595 595
 						} else {
596 596
 							if ( isset( $field['disabled'] ) && $field['disabled'] ) {
@@ -723,7 +723,7 @@  discard block
 block discarded – undo
723 723
 			if ( isset( $plugin_options['redux-no_panel'] ) ) {
724 724
 				$keys = explode( '|', $plugin_options['redux-no_panel'] );
725 725
 				foreach ( $keys as $key ) {
726
-					$plugin_options[ $key ] = $core->options[ $key ];
726
+					$plugin_options[$key] = $core->options[$key];
727 727
 				}
728 728
 				if ( isset( $plugin_options['redux-no_panel'] ) ) {
729 729
 					unset( $plugin_options['redux-no_panel'] );
@@ -732,7 +732,7 @@  discard block
 block discarded – undo
732 732
 
733 733
 			if ( is_array( $this->hidden_perm_fields ) && ! empty( $this->hidden_perm_fields ) ) {
734 734
 				foreach ( $this->hidden_perm_fields as $id => $data ) {
735
-					$plugin_options[ $id ] = $data;
735
+					$plugin_options[$id] = $data;
736 736
 				}
737 737
 			}
738 738
 
@@ -760,9 +760,9 @@  discard block
 block discarded – undo
760 760
 			if ( is_array( $imported_options ) && ! empty( $imported_options ) && isset( $imported_options['redux-backup'] ) && ( 1 === $imported_options['redux-backup'] || '1' === $imported_options['redux-backup'] ) ) {
761 761
 				$core->transients['changed_values'] = array();
762 762
 				foreach ( $plugin_options as $key => $value ) {
763
-					if ( isset( $imported_options[ $key ] ) && $value !== $imported_options[ $key ] ) {
764
-						$plugin_options[ $key ]                     = $value;
765
-						$core->transients['changed_values'][ $key ] = $value;
763
+					if ( isset( $imported_options[$key] ) && $value !== $imported_options[$key] ) {
764
+						$plugin_options[$key]                     = $value;
765
+						$core->transients['changed_values'][$key] = $value;
766 766
 					}
767 767
 				}
768 768
 
@@ -783,7 +783,7 @@  discard block
 block discarded – undo
783 783
 				);
784 784
 
785 785
 				setcookie( 'redux_current_tab_' . $core->args['opt_name'], '', 1, '/', $time + 1000, '/' );
786
-				$_COOKIE[ 'redux_current_tab_' . $core->args['opt_name'] ] = 1;
786
+				$_COOKIE['redux_current_tab_' . $core->args['opt_name']] = 1;
787 787
 
788 788
 				unset( $plugin_options['defaults'], $plugin_options['compiler'], $plugin_options['import'], $plugin_options['import_code'] );
789 789
 				if ( in_array( $core->args['database'], array( 'transient', 'theme_mods', 'theme_mods_expanded', 'network' ), true ) ) {
@@ -821,8 +821,8 @@  discard block
 block discarded – undo
821 821
 				}
822 822
 
823 823
 				foreach ( $core->options as $key => $value ) {
824
-					if ( isset( $plugin_options[ $key ] ) && $plugin_options[ $key ] !== $value ) {
825
-						$core->transients['changed_values'][ $key ] = $value;
824
+					if ( isset( $plugin_options[$key] ) && $plugin_options[$key] !== $value ) {
825
+						$core->transients['changed_values'][$key] = $value;
826 826
 					}
827 827
 				}
828 828
 
@@ -836,21 +836,21 @@  discard block
 block discarded – undo
836 836
 
837 837
 			// Section reset to default.
838 838
 			if ( ! empty( $plugin_options['defaults-section'] ) ) {
839
-				if ( isset( $plugin_options['redux-section'] ) && isset( $core->sections[ $plugin_options['redux-section'] ]['fields'] ) ) {
839
+				if ( isset( $plugin_options['redux-section'] ) && isset( $core->sections[$plugin_options['redux-section']]['fields'] ) ) {
840 840
 					if ( empty( $core->options_defaults ) ) {
841 841
 						$core->options_defaults = $core->_default_values();
842 842
 					}
843 843
 
844
-					foreach ( $core->sections[ $plugin_options['redux-section'] ]['fields'] as $field ) {
844
+					foreach ( $core->sections[$plugin_options['redux-section']]['fields'] as $field ) {
845 845
 						if ( 'tabbed' === $field['type'] ) {
846 846
 							if ( ! empty( $field['tabs'] ) ) {
847 847
 								foreach ( $field['tabs'] as $val ) {
848 848
 									if ( ! empty( $val['fields'] ) ) {
849 849
 										foreach ( $val['fields'] as $f ) {
850
-											if ( isset( $core->options_defaults[ $f['id'] ] ) ) {
851
-												$plugin_options[ $f['id'] ] = $core->options_defaults[ $f['id'] ];
850
+											if ( isset( $core->options_defaults[$f['id']] ) ) {
851
+												$plugin_options[$f['id']] = $core->options_defaults[$f['id']];
852 852
 											} else {
853
-												$plugin_options[ $f['id'] ] = '';
853
+												$plugin_options[$f['id']] = '';
854 854
 											}
855 855
 										}
856 856
 									}
@@ -859,18 +859,18 @@  discard block
 block discarded – undo
859 859
 						} elseif ( 'repeater' === $field['type'] ) {
860 860
 							if ( ! empty( $field['fields'] ) ) {
861 861
 								foreach ( $field['fields'] as $f ) {
862
-									if ( isset( $core->options_defaults[ $f['id'] ] ) ) {
863
-										$plugin_options[ $f['id'] ] = $core->options_defaults[ $f['id'] ];
862
+									if ( isset( $core->options_defaults[$f['id']] ) ) {
863
+										$plugin_options[$f['id']] = $core->options_defaults[$f['id']];
864 864
 									} else {
865
-										$plugin_options[ $f['id'] ] = '';
865
+										$plugin_options[$f['id']] = '';
866 866
 									}
867 867
 								}
868 868
 							}
869 869
 						} else {
870
-							if ( isset( $core->options_defaults[ $field['id'] ] ) ) {
871
-								$plugin_options[ $field['id'] ] = $core->options_defaults[ $field['id'] ];
870
+							if ( isset( $core->options_defaults[$field['id']] ) ) {
871
+								$plugin_options[$field['id']] = $core->options_defaults[$field['id']];
872 872
 							} else {
873
-								$plugin_options[ $field['id'] ] = '';
873
+								$plugin_options[$field['id']] = '';
874 874
 							}
875 875
 						}
876 876
 
@@ -892,8 +892,8 @@  discard block
 block discarded – undo
892 892
 				$core->transients['changed_values'] = array();
893 893
 
894 894
 				foreach ( $core->options as $key => $value ) {
895
-					if ( isset( $plugin_options[ $key ] ) && $plugin_options[ $key ] !== $value ) {
896
-						$core->transients['changed_values'][ $key ] = $value;
895
+					if ( isset( $plugin_options[$key] ) && $plugin_options[$key] !== $value ) {
896
+						$core->transients['changed_values'][$key] = $value;
897 897
 					}
898 898
 				}
899 899
 
@@ -967,8 +967,8 @@  discard block
 block discarded – undo
967 967
 
968 968
 			if ( ! empty( $core->options ) ) {
969 969
 				foreach ( $core->options as $key => $value ) {
970
-					if ( isset( $plugin_options[ $key ] ) && $plugin_options[ $key ] !== $value ) {
971
-						$core->transients['changed_values'][ $key ] = $value;
970
+					if ( isset( $plugin_options[$key] ) && $plugin_options[$key] !== $value ) {
971
+						$core->transients['changed_values'][$key] = $value;
972 972
 					}
973 973
 				}
974 974
 			}
@@ -1008,7 +1008,7 @@  discard block
 block discarded – undo
1008 1008
 					$this->default_values(); // fill cache.
1009 1009
 				}
1010 1010
 
1011
-				return array_key_exists( $opt_name, $this->options_defaults ) ? $this->options_defaults[ $opt_name ] : $defaults;
1011
+				return array_key_exists( $opt_name, $this->options_defaults ) ? $this->options_defaults[$opt_name] : $defaults;
1012 1012
 			}
1013 1013
 
1014 1014
 			return '';
@@ -1032,11 +1032,11 @@  discard block
 block discarded – undo
1032 1032
 			$defaults = $this->options_defaults;
1033 1033
 			$value    = '';
1034 1034
 
1035
-			if ( isset( $defaults[ $key ] ) ) {
1036
-				if ( false !== $array_key && isset( $defaults[ $key ][ $array_key ] ) ) {
1037
-					$value = $defaults[ $key ][ $array_key ];
1035
+			if ( isset( $defaults[$key] ) ) {
1036
+				if ( false !== $array_key && isset( $defaults[$key][$array_key] ) ) {
1037
+					$value = $defaults[$key][$array_key];
1038 1038
 				} else {
1039
-					$value = $defaults[ $key ];
1039
+					$value = $defaults[$key];
1040 1040
 				}
1041 1041
 			}
1042 1042
 
Please login to merge, or discard this patch.
redux-core/inc/classes/class-redux-instances.php 1 patch
Indentation   +87 added lines, -87 removed lines patch added patch discarded remove patch
@@ -13,108 +13,108 @@
 block discarded – undo
13 13
 
14 14
 if ( ! class_exists( 'Redux_Instances', false ) ) {
15 15
 
16
-	/**
17
-	 * Class Redux_Instances
18
-	 */
19
-	class Redux_Instances {
16
+    /**
17
+     * Class Redux_Instances
18
+     */
19
+    class Redux_Instances {
20 20
 
21
-		/**
22
-		 * ReduxFramework instances
23
-		 *
24
-		 * @var ReduxFramework[]
25
-		 */
26
-		private static $instances;
21
+        /**
22
+         * ReduxFramework instances
23
+         *
24
+         * @var ReduxFramework[]
25
+         */
26
+        private static $instances;
27 27
 
28
-		/**
29
-		 * Get Instance
30
-		 * Get Redux_Instances instance
31
-		 * OR an instance of ReduxFramework by [opt_name]
32
-		 *
33
-		 * @param  string|false $opt_name the defined opt_name.
34
-		 *
35
-		 * @return ReduxFramework|Redux_Instances class instance
36
-		 */
37
-		public static function get_instance( $opt_name = false ) {
28
+        /**
29
+         * Get Instance
30
+         * Get Redux_Instances instance
31
+         * OR an instance of ReduxFramework by [opt_name]
32
+         *
33
+         * @param  string|false $opt_name the defined opt_name.
34
+         *
35
+         * @return ReduxFramework|Redux_Instances class instance
36
+         */
37
+        public static function get_instance( $opt_name = false ) {
38 38
 
39
-			if ( $opt_name && ! empty( self::$instances[ $opt_name ] ) ) {
40
-				return self::$instances[ $opt_name ];
41
-			}
39
+            if ( $opt_name && ! empty( self::$instances[ $opt_name ] ) ) {
40
+                return self::$instances[ $opt_name ];
41
+            }
42 42
 
43
-			return new self();
44
-		}
43
+            return new self();
44
+        }
45 45
 
46
-		/**
47
-		 * Shim for old get_redux_instance method.
48
-		 *
49
-		 * @param  string|false $opt_name the defined opt_name.
50
-		 *
51
-		 * @return ReduxFramework class instance
52
-		 */
53
-		public static function get_redux_instance( $opt_name = '' ) {
54
-			return self::get_instance( $opt_name );
55
-		}
46
+        /**
47
+         * Shim for old get_redux_instance method.
48
+         *
49
+         * @param  string|false $opt_name the defined opt_name.
50
+         *
51
+         * @return ReduxFramework class instance
52
+         */
53
+        public static function get_redux_instance( $opt_name = '' ) {
54
+            return self::get_instance( $opt_name );
55
+        }
56 56
 
57
-		/**
58
-		 * Get all instantiated ReduxFramework instances (so far)
59
-		 *
60
-		 * @return array|null [type] [description]
61
-		 */
62
-		public static function get_all_instances(): ?array {
63
-			return self::$instances;
64
-		}
57
+        /**
58
+         * Get all instantiated ReduxFramework instances (so far)
59
+         *
60
+         * @return array|null [type] [description]
61
+         */
62
+        public static function get_all_instances(): ?array {
63
+            return self::$instances;
64
+        }
65 65
 
66
-		/**
67
-		 * Redux_Instances constructor.
68
-		 *
69
-		 * @param mixed $redux_framework Is object.
70
-		 */
71
-		public function __construct( $redux_framework = false ) {
72
-			if ( false !== $redux_framework ) {
73
-				$this->store( $redux_framework );
74
-			} else {
75
-				add_action( 'redux/construct', array( $this, 'store' ), 5, 1 );
76
-			}
77
-		}
66
+        /**
67
+         * Redux_Instances constructor.
68
+         *
69
+         * @param mixed $redux_framework Is object.
70
+         */
71
+        public function __construct( $redux_framework = false ) {
72
+            if ( false !== $redux_framework ) {
73
+                $this->store( $redux_framework );
74
+            } else {
75
+                add_action( 'redux/construct', array( $this, 'store' ), 5, 1 );
76
+            }
77
+        }
78 78
 
79
-		/**
80
-		 * Action hook callback.
81
-		 *
82
-		 * @param object $redux_framework Pointer.
83
-		 */
84
-		public function store( $redux_framework ) {
85
-			if ( $redux_framework instanceof ReduxFramework ) {
86
-				$key                     = $redux_framework->args['opt_name'];
87
-				self::$instances[ $key ] = $redux_framework;
88
-			}
89
-		}
90
-	}
79
+        /**
80
+         * Action hook callback.
81
+         *
82
+         * @param object $redux_framework Pointer.
83
+         */
84
+        public function store( $redux_framework ) {
85
+            if ( $redux_framework instanceof ReduxFramework ) {
86
+                $key                     = $redux_framework->args['opt_name'];
87
+                self::$instances[ $key ] = $redux_framework;
88
+            }
89
+        }
90
+    }
91 91
 }
92 92
 
93 93
 if ( ! class_exists( 'ReduxFrameworkInstances' ) ) {
94
-	class_alias( 'Redux_Instances', 'ReduxFrameworkInstances' );
94
+    class_alias( 'Redux_Instances', 'ReduxFrameworkInstances' );
95 95
 }
96 96
 
97 97
 if ( ! function_exists( 'get_redux_instance' ) ) {
98
-	/**
99
-	 * Shim function that some theme oddly used.
100
-	 *
101
-	 * @param  string|false $opt_name the defined opt_name.
102
-	 *
103
-	 * @return ReduxFramework class instance
104
-	 */
105
-	function get_redux_instance( $opt_name ) { // phpcs:ignore Universal.Files.SeparateFunctionsFromOO, WordPress.NamingConventions.PrefixAllGlobals -- Themes use this function. Name cannot be changed for backward compatibility reasons.
106
-		return Redux_Instances::get_instance( $opt_name );
107
-	}
98
+    /**
99
+     * Shim function that some theme oddly used.
100
+     *
101
+     * @param  string|false $opt_name the defined opt_name.
102
+     *
103
+     * @return ReduxFramework class instance
104
+     */
105
+    function get_redux_instance( $opt_name ) { // phpcs:ignore Universal.Files.SeparateFunctionsFromOO, WordPress.NamingConventions.PrefixAllGlobals -- Themes use this function. Name cannot be changed for backward compatibility reasons.
106
+        return Redux_Instances::get_instance( $opt_name );
107
+    }
108 108
 }
109 109
 
110 110
 if ( ! function_exists( 'get_all_redux_instances' ) ) {
111
-	/**
112
-	 * Fetch all instances of ReduxFramework
113
-	 * as an associative array.
114
-	 *
115
-	 * @return array        format ['opt_name' => $ReduxFramework]
116
-	 */
117
-	function get_all_redux_instances(): ?array { // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals -- Themes use this function. Name cannot be changed for backward compatibility reasons.
118
-		return Redux_Instances::get_all_instances();
119
-	}
111
+    /**
112
+     * Fetch all instances of ReduxFramework
113
+     * as an associative array.
114
+     *
115
+     * @return array        format ['opt_name' => $ReduxFramework]
116
+     */
117
+    function get_all_redux_instances(): ?array { // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals -- Themes use this function. Name cannot be changed for backward compatibility reasons.
118
+        return Redux_Instances::get_all_instances();
119
+    }
120 120
 }
Please login to merge, or discard this patch.
redux-core/inc/classes/class-redux-wordpress-data.php 2 patches
Indentation   +675 added lines, -675 removed lines patch added patch discarded remove patch
@@ -11,679 +11,679 @@
 block discarded – undo
11 11
 
12 12
 if ( ! class_exists( 'Redux_WordPress_Data', false ) ) {
13 13
 
14
-	/**
15
-	 * Class Redux_WordPress_Data
16
-	 */
17
-	class Redux_WordPress_Data extends Redux_Class {
18
-
19
-		/**
20
-		 * Holds WordPress data.
21
-		 *
22
-		 * @var null
23
-		 */
24
-		private $wp_data = null;
25
-
26
-		/**
27
-		 * Redux_WordPress_Data constructor.
28
-		 *
29
-		 * @param mixed $redux ReduxFramework pointer or opt_name.
30
-		 */
31
-		public function __construct( $redux = null ) {
32
-			if ( is_string( $redux ) ) {
33
-				$this->opt_name = $redux;
34
-			} else {
35
-				parent::__construct( $redux );
36
-			}
37
-		}
38
-
39
-		/**
40
-		 * Get the data.
41
-		 *
42
-		 * @param string|array $type          Type.
43
-		 * @param array|string $args          Args.
44
-		 * @param string       $opt_name      Opt name.
45
-		 * @param string|int   $current_value Current value.
46
-		 * @param bool         $ajax          Tells if this is an AJAX call.
47
-		 *
48
-		 * @return array|mixed|string
49
-		 */
50
-		public function get( $type, $args = array(), string $opt_name = '', $current_value = '', bool $ajax = false ) {
51
-			if ( '' === $opt_name ) {
52
-				$opt_name = $this->opt_name;
53
-			}
54
-
55
-			// We don't want to run this, it's not a string value. Send it back!
56
-			if ( is_array( $type ) ) {
57
-				return $type;
58
-			}
59
-
60
-			/**
61
-			 * Filter 'redux/options/{opt_name}/pre_data/{type}'
62
-			 *
63
-			 * @param string $data
64
-			 */
65
-			$pre_data = apply_filters( "redux/options/$opt_name/pre_data/$type", null ); // phpcs:ignore WordPress.NamingConventions.ValidHookName
66
-			if ( null !== $pre_data || empty( $type ) ) {
67
-				return $pre_data;
68
-			}
69
-
70
-			if ( isset( $args['data_sortby'] ) && in_array( $args['data_sortby'], array( 'value', 'key' ), true ) ) {
71
-				$data_sort = $args['data_sortby'];
72
-				unset( $args['data_sortby'] );
73
-			} else {
74
-				$data_sort = 'value';
75
-			}
76
-			if ( isset( $args['data_order'] ) && in_array( $args['data_order'], array( 'asc', 'desc' ), true ) ) {
77
-				$data_order = $args['data_order'];
78
-				unset( $args['data_order'] );
79
-			} else {
80
-				$data_order = 'asc';
81
-			}
82
-
83
-			$this->maybe_get_translation( $type, $current_value, $args );
84
-
85
-			$current_data = array();
86
-			if ( empty( $current_value ) && ! Redux_Helpers::is_integer( $current_value ) ) {
87
-				$current_value = null;
88
-			} else {
89
-				// Get the args to grab the current data.
90
-				$current_data_args = $this->get_current_data_args( $type, $args, $current_value );
91
-
92
-				// Let's make a unique key for this arg array.
93
-				$current_data_args_key = md5( maybe_serialize( $current_data_args ) );
94
-
95
-				// Check to make sure we haven't already run this call before.
96
-				$current_data = $this->wp_data[ $type . $current_data_args_key ] ?? $this->get_data( $type, $current_data_args, $current_value );
97
-			}
98
-
99
-			// If ajax is enabled AND $current_data is empty, set a dummy value for the init.
100
-			if ( $ajax && ! wp_doing_ajax() ) {
101
-				// Dummy is necessary otherwise empty.
102
-				if ( empty( $current_data ) ) {
103
-					$current_data = array(
104
-						'dummy' => '',
105
-					);
106
-				}
107
-
108
-				return $current_data;
109
-			}
110
-
111
-			// phpcs:ignore Squiz.PHP.CommentedOutCode
112
-			$args_key = md5( maybe_serialize( $args ) );
113
-
114
-			// Data caching.
115
-			if ( isset( $this->wp_data[ $type . $args_key ] ) ) {
116
-				$data = $this->wp_data[ $type . $args_key ];
117
-			} else {
118
-				/**
119
-				 * Use data from WordPress to populate an option array.
120
-				 * */
121
-				$data = $this->get_data( $type, $args, $current_value );
122
-			}
123
-
124
-			if ( ! empty( $current_data ) ) {
125
-				$data += $current_data;
126
-			}
127
-
128
-			if ( ! empty( $data ) ) {
129
-				$data                               = $this->order_data( $data, $data_sort, $data_order );
130
-				$this->wp_data[ $type . $args_key ] = $data;
131
-			}
132
-
133
-			/**
134
-			 * Filter 'redux/options/{opt_name}/data/{type}'
135
-			 *
136
-			 * @param string $data
137
-			 */
138
-
139
-			// phpcs:ignore WordPress.NamingConventions.ValidHookName
140
-			return apply_filters( "redux/options/$opt_name/data/$type", $data );
141
-		}
142
-
143
-
144
-		/**
145
-		 * Process the results into a proper array, fetching the data elements needed for each data type.
146
-		 *
147
-		 * @param array|WP_Error $results       Results to process in the data array.
148
-		 * @param string|bool    $id_key        Key on object/array that represents the ID.
149
-		 * @param string|bool    $name_key      Key on object/array that represents the name/text.
150
-		 * @param bool           $add_key       If true, the display key will appear in the text.
151
-		 * @param string|bool    $secondary_key If a data type, you'd rather display a different ID as the display key.
152
-		 *
153
-		 * @return array
154
-		 */
155
-		private function process_results( $results = array(), $id_key = '', $name_key = '', bool $add_key = true, $secondary_key = 'slug' ): array {
156
-			$data = array();
157
-			if ( ! empty( $results ) && ! is_a( $results, 'WP_Error' ) ) {
158
-				foreach ( $results as $k => $v ) {
159
-					if ( empty( $id_key ) ) {
160
-						$key = $k;
161
-					} else {
162
-						if ( is_object( $v ) ) {
163
-							$key = $v->$id_key;
164
-						} elseif ( is_array( $v ) ) {
165
-							$key = $v[ $id_key ];
166
-						} else {
167
-							$key = $k;
168
-						}
169
-					}
170
-
171
-					if ( empty( $name_key ) ) {
172
-						$value = $v;
173
-					} else {
174
-						if ( is_object( $v ) ) {
175
-							$value = $v->$name_key;
176
-						} elseif ( is_array( $v ) ) {
177
-							$value = $v[ $name_key ];
178
-						} else {
179
-							$value = $v;
180
-						}
181
-					}
182
-
183
-					$display_key = $key;
184
-
185
-					if ( is_object( $v ) && isset( $v->$secondary_key ) ) {
186
-						$display_key = $v->$secondary_key;
187
-					} elseif ( ! is_object( $v ) && isset( $v[ $secondary_key ] ) ) {
188
-						$display_key = $v[ $secondary_key ];
189
-					}
190
-					$data[ $key ] = $value;
191
-					if ( $display_key !== $value && $add_key ) {
192
-						$data[ $key ] = $data[ $key ] . ' [' . $display_key . ']';
193
-					}
194
-				}
195
-			}
196
-
197
-			return $data;
198
-		}
199
-
200
-		/**
201
-		 * Order / Sort the data.
202
-		 *
203
-		 * @param array  $data  Data to sort.
204
-		 * @param string $sort  Way to sort. Accepts: key|value.
205
-		 * @param string $order Order of the sort. Accepts: asc|desc.
206
-		 *
207
-		 * @return array
208
-		 */
209
-		private function order_data( array $data = array(), string $sort = 'value', string $order = 'asc' ): array {
210
-			if ( 'key' === $sort ) {
211
-				if ( 'asc' === $order ) {
212
-					ksort( $data );
213
-				} else {
214
-					krsort( $data );
215
-				}
216
-			} elseif ( 'value' === $sort ) {
217
-				if ( 'asc' === $order ) {
218
-					asort( $data );
219
-				} else {
220
-					arsort( $data );
221
-				}
222
-			}
223
-
224
-			return $data;
225
-		}
226
-
227
-		/**
228
-		 * Fetch the data for a given type.
229
-		 *
230
-		 * @param string       $type          The data type we're fetching.
231
-		 * @param array|string $args          Arguments to pass.
232
-		 * @param mixed|array  $current_value If a current value already set in the database.
233
-		 *
234
-		 * @return array|null|string
235
-		 */
236
-		private function get_data( string $type, $args, $current_value ) {
237
-			$args = $this->get_arg_defaults( $type, $args );
238
-
239
-			$opt_name = $this->opt_name;
240
-			if ( empty( $args ) ) {
241
-				$args = array();
242
-			}
243
-
244
-			$data = array();
245
-			if ( isset( $args['args'] ) && empty( $args['args'] ) ) {
246
-				unset( $args['args'] );
247
-			}
248
-
249
-			$display_keys = false;
250
-			if ( isset( $args['display_keys'] ) ) {
251
-				$display_keys = true;
252
-				unset( $args['display_keys'] );
253
-			}
254
-
255
-			$secondary_key = 'slug';
256
-			if ( isset( $args['secondary_key'] ) ) {
257
-				$secondary_key = $args['secondary_key'];
258
-				unset( $args['secondary_key'] );
259
-			}
260
-
261
-			switch ( $type ) {
262
-				case 'categories':
263
-				case 'category':
264
-				case 'terms':
265
-				case 'term':
266
-					if ( isset( $args['taxonomies'] ) ) {
267
-						$args['taxonomy'] = $args['taxonomies'];
268
-						unset( $args['taxonomies'] );
269
-					}
270
-					$results = get_terms( $args );
271
-					$data    = $this->process_results( $results, 'term_id', 'name', $display_keys, $secondary_key );
272
-					break;
273
-
274
-				case 'pages':
275
-				case 'page':
276
-					$results = get_pages( $args );
277
-					$data    = $this->process_results( $results, 'ID', 'post_title', $display_keys, $secondary_key );
278
-					break;
279
-
280
-				case 'tags':
281
-				case 'tag':
282
-					$results = get_tags( $args );
283
-					$data    = $this->process_results( $results, 'term_id', 'name', $display_keys, $secondary_key );
284
-					break;
285
-
286
-				case 'menus':
287
-				case 'menu':
288
-					$results = wp_get_nav_menus( $args );
289
-					$data    = $this->process_results( $results, 'term_id', 'name', $display_keys, $secondary_key );
290
-					break;
291
-
292
-				case 'posts':
293
-				case 'post':
294
-					$results = get_posts( $args );
295
-					$data    = $this->process_results( $results, 'ID', 'post_title', $display_keys, $secondary_key );
296
-					break;
297
-
298
-				case 'users':
299
-				case 'user':
300
-					$results = get_users( $args );
301
-					$data    = $this->process_results( $results, 'ID', 'display_name', $display_keys, $secondary_key );
302
-					break;
303
-
304
-				case 'sites':
305
-				case 'site':
306
-					$sites = get_sites();
307
-
308
-					if ( isset( $sites ) ) {
309
-						$results = array();
310
-						foreach ( $sites as $site ) {
311
-							$site = (array) $site;
312
-							$k    = $site['blog_id'];
313
-							$v    = $site['domain'] . $site['path'];
314
-							$name = get_blog_option( $k, 'blogname' );
315
-							if ( ! empty( $name ) ) {
316
-								$v .= ' - [' . $name . ']';
317
-							}
318
-							$results[ $k ] = $v;
319
-						}
320
-						$data = $this->process_results( $results, '', '', $display_keys, $secondary_key );
321
-					}
322
-
323
-					break;
324
-
325
-				case 'taxonomies':
326
-				case 'taxonomy':
327
-				case 'tax':
328
-					$results = get_taxonomies( $args );
329
-					$data    = $this->process_results( $results, '', '', $display_keys, $secondary_key );
330
-					break;
331
-
332
-				case 'post_types':
333
-				case 'post_type':
334
-					global $wp_post_types;
335
-
336
-					$output = $args['output'];
337
-					unset( $args['output'] );
338
-					$operator = $args['operator'];
339
-					unset( $args['operator'] );
340
-
341
-					$post_types = get_post_types( $args, $output, $operator );
342
-
343
-					foreach ( $post_types as $name => $title ) {
344
-						if ( isset( $wp_post_types[ $name ]->labels->menu_name ) ) {
345
-							$data[ $name ] = $wp_post_types[ $name ]->labels->menu_name;
346
-						} else {
347
-							$data[ $name ] = ucfirst( $name );
348
-						}
349
-					}
350
-					break;
351
-
352
-				case 'menu_locations':
353
-				case 'menu_location':
354
-					global $_wp_registered_nav_menus;
355
-					foreach ( $_wp_registered_nav_menus as $k => $v ) {
356
-						$data[ $k ] = $v;
357
-						if ( ! has_nav_menu( $k ) ) {
358
-							$data[ $k ] .= ' ' . __( '[unassigned]', 'redux-framework' );
359
-						}
360
-					}
361
-					break;
362
-
363
-				case 'image_sizes':
364
-				case 'image_size':
365
-					global $_wp_additional_image_sizes;
366
-					$results = array();
367
-					foreach ( $_wp_additional_image_sizes as $size_name => $size_attrs ) {
368
-						$results[ $size_name ] = $size_name . ' - ' . $size_attrs['width'] . ' x ' . $size_attrs['height'];
369
-					}
370
-					$data = $this->process_results( $results, '', '', $display_keys, $secondary_key );
371
-
372
-					break;
373
-
374
-				case 'elusive-icons':
375
-				case 'elusive-icon':
376
-				case 'elusive':
377
-				case 'icons':
378
-				case 'font-icon':
379
-				case 'font-icons':
380
-					$fs    = Redux_Filesystem::get_instance();
381
-					$fonts = $fs->get_contents( Redux_Core::$dir . 'assets/css/vendor/elusive-icons.css' );
382
-					if ( ! empty( $fonts ) ) {
383
-						preg_match_all( '@\.el-(\w+)::before@', $fonts, $matches );
384
-						foreach ( $matches[1] as $item ) {
385
-							if ( 'before' === $item ) {
386
-								continue;
387
-							}
388
-							$data[ 'el el-' . $item ] = $item;
389
-						}
390
-					}
391
-
392
-					/**
393
-					 * Filter 'redux/font-icons'
394
-					 *
395
-					 * @param array $font_icons array of elusive icon classes
396
-					 *
397
-					 * @deprecated
398
-					 */
399
-
400
-					// phpcs:ignore WordPress.NamingConventions.ValidHookName
401
-					$font_icons = apply_filters_deprecated( 'redux/font-icons', array( $data ), '4.3', 'redux/$opt_name/field/font/icons' );
402
-
403
-					/**
404
-					 * Filter 'redux/{opt_name}/field/font/icons'
405
-					 *
406
-					 * @param array $font_icons array of elusive icon classes
407
-					 */
408
-
409
-					// phpcs:ignore WordPress.NamingConventions.ValidHookName
410
-					$data = apply_filters( "redux/$opt_name/field/font/icons", $font_icons );
411
-
412
-					break;
413
-
414
-				case 'dashicons':
415
-				case 'dashicon':
416
-				case 'dash':
417
-					$fs    = Redux_Filesystem::get_instance();
418
-					$fonts = $fs->get_contents( ABSPATH . WPINC . '/css/dashicons.css' );
419
-					if ( ! empty( $fonts ) ) {
420
-						preg_match_all( '@\.dashicons-(\w+):before@', $fonts, $matches );
421
-						foreach ( $matches[1] as $item ) {
422
-							if ( 'before' === $item ) {
423
-								continue;
424
-							}
425
-							$data[ 'dashicons dashicons-' . $item ] = $item;
426
-						}
427
-					}
428
-					break;
429
-
430
-				case 'roles':
431
-				case 'role':
432
-					global $wp_roles;
433
-					$results = $wp_roles->get_names();
434
-					$data    = $this->process_results( $results, '', '', $display_keys, $secondary_key );
435
-
436
-					break;
437
-
438
-				case 'sidebars':
439
-				case 'sidebar':
440
-					global $wp_registered_sidebars;
441
-					$data = $this->process_results( $wp_registered_sidebars, '', 'name', $display_keys, $secondary_key );
442
-					break;
443
-				case 'capabilities':
444
-				case 'capability':
445
-					global $wp_roles;
446
-					$results = array();
447
-					foreach ( $wp_roles->roles as $role ) {
448
-						foreach ( $role['capabilities'] as $key => $cap ) {
449
-							$results[ $key ] = ucwords( str_replace( '_', ' ', $key ) );
450
-						}
451
-					}
452
-					$data = $this->process_results( $results, '', '', $display_keys, $secondary_key );
453
-
454
-					break;
455
-
456
-				case 'capabilities_grouped':
457
-				case 'capability_grouped':
458
-				case 'capabilities_group':
459
-				case 'capability_group':
460
-					global $wp_roles;
461
-
462
-					foreach ( $wp_roles->roles as $role ) {
463
-						$caps = array();
464
-						foreach ( $role['capabilities'] as $key => $cap ) {
465
-							$caps[ $key ] = ucwords( str_replace( '_', ' ', $key ) );
466
-						}
467
-						asort( $caps );
468
-						$data[ $role['name'] ] = $caps;
469
-					}
470
-
471
-					break;
472
-
473
-				case 'callback':
474
-					if ( ! empty( $args ) && is_callable( $args ) ) {
475
-						$data = call_user_func( $args, $current_value );
476
-					}
477
-
478
-					break;
479
-			}
480
-
481
-			return $data;
482
-		}
483
-
484
-
485
-		/**
486
-		 * Router for translation based on the given post-type.
487
-		 *
488
-		 * @param string       $type          Type of data request.
489
-		 * @param mixed|array  $current_value Current value stored in DB.
490
-		 * @param array|string $args          Arguments for the call.
491
-		 */
492
-		private function maybe_get_translation( string $type, &$current_value = '', $args = array() ) {
493
-			switch ( $type ) {
494
-				case 'categories':
495
-				case 'category':
496
-					$this->maybe_translate( $current_value, 'category' );
497
-					break;
498
-
499
-				case 'pages':
500
-				case 'page':
501
-					$this->maybe_translate( $current_value, 'page' );
502
-					break;
503
-
504
-				case 'terms':
505
-				case 'term':
506
-					$this->maybe_translate( $current_value, $args['taxonomy'] ?? '' );
507
-					break;
508
-
509
-				case 'tags':
510
-				case 'tag':
511
-					$this->maybe_translate( $current_value, 'post_tag' );
512
-					break;
513
-
514
-				case 'menus':
515
-				case 'menu':
516
-					$this->maybe_translate( $current_value, 'nav_menu' );
517
-					break;
518
-
519
-				case 'post':
520
-				case 'posts':
521
-					$this->maybe_translate( $current_value, 'post' );
522
-					break;
523
-				default:
524
-					$this->maybe_translate( $current_value, '' );
525
-			}
526
-		}
527
-
528
-		/**
529
-		 * Maybe translate the values.
530
-		 *
531
-		 * @param mixed|array $value     Value.
532
-		 * @param mixed|array $post_type Post type.
533
-		 */
534
-		private function maybe_translate( &$value, $post_type ) {
535
-
536
-			// phpcs:ignore WordPress.NamingConventions.ValidHookName
537
-			$value = apply_filters( "redux/options/$this->opt_name/wordpress_data/translate/post_type_value", $value, $post_type );
538
-
539
-			// WPML Integration, see https://wpml.org/documentation/support/creating-multilingual-wordpress-themes/language-dependent-ids/.
540
-			if ( function_exists( 'icl_object_id' ) ) {
541
-				if ( has_filter( 'wpml_object_id' ) ) {
542
-					if ( Redux_Helpers::is_integer( $value ) ) {
543
-						// phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals -- Third party hook. Cannot change.
544
-						$value = apply_filters( 'wpml_object_id', $value, $post_type, true );
545
-					} elseif ( is_array( $value ) ) {
546
-						$value = array_map(
547
-							function ( $val ) use ( $post_type ) {
548
-								// phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals -- Third party hook. Cannot change.
549
-								return apply_filters( 'wpml_object_id', $val, $post_type, true );
550
-							},
551
-							$value
552
-						);
553
-					}
554
-				}
555
-			}
556
-		}
557
-
558
-		/**
559
-		 * Set the default arguments for a current query (existing data).
560
-		 *
561
-		 * @param string       $type          Type of data request.
562
-		 * @param array|string $args          Arguments for the call.
563
-		 * @param mixed|array  $current_value Current value stored in DB.
564
-		 *
565
-		 * @return array
566
-		 */
567
-		private function get_current_data_args( string $type, $args, $current_value ): array {
568
-			// In this section, we set the default arguments for each data type.
569
-			switch ( $type ) {
570
-				case 'categories':
571
-				case 'category':
572
-				case 'pages':
573
-				case 'page':
574
-				case 'terms':
575
-				case 'term':
576
-				case 'users':
577
-				case 'user':
578
-					$args['include'] = $current_value;
579
-					break;
580
-				case 'tags':
581
-				case 'tag':
582
-					$args['get'] = 'all';
583
-					break;
584
-				case 'menus':
585
-				case 'menu':
586
-					$args['object_ids'] = $current_value;
587
-					break;
588
-				case 'post':
589
-				case 'posts':
590
-					if ( ! empty( $current_value ) ) {
591
-						$args['post__in'] = is_array( $current_value ) ? $current_value : array( $current_value );
592
-					}
593
-					break;
594
-
595
-				default:
596
-					$args = array();
597
-			}
598
-
599
-			return $args;
600
-		}
601
-
602
-
603
-		/**
604
-		 * Get default arguments for a given data type.
605
-		 *
606
-		 * @param string       $type Type of data request.
607
-		 * @param array|string $args Arguments for the call.
608
-		 *
609
-		 * @return array|string
610
-		 */
611
-		private function get_arg_defaults( string $type, $args = array() ) {
612
-			// In this section, we set the default arguments for each data type.
613
-			switch ( $type ) {
614
-				case 'categories':
615
-				case 'category':
616
-					$args = wp_parse_args(
617
-						$args,
618
-						array(
619
-							'taxonomy' => 'category',
620
-						)
621
-					);
622
-					break;
623
-
624
-				case 'pages':
625
-				case 'page':
626
-					$args = wp_parse_args(
627
-						$args,
628
-						array(
629
-							'display_keys'   => true,
630
-							'posts_per_page' => 20,
631
-						)
632
-					);
633
-					break;
634
-
635
-				case 'post_type':
636
-				case 'post_types':
637
-					$args = wp_parse_args(
638
-						$args,
639
-						array(
640
-							'public'              => true,
641
-							'exclude_from_search' => false,
642
-							'output'              => 'names',
643
-							'operator'            => 'and',
644
-						)
645
-					);
646
-
647
-					break;
648
-
649
-				case 'tag':
650
-				case 'tags':
651
-					$args = wp_parse_args(
652
-						$args,
653
-						array(
654
-							'get'          => 'all',
655
-							'display_keys' => true,
656
-						)
657
-					);
658
-					break;
659
-
660
-				case 'sidebars':
661
-				case 'sidebar':
662
-				case 'capabilities':
663
-				case 'capability':
664
-					$args = wp_parse_args(
665
-						$args,
666
-						array(
667
-							'display_keys' => true,
668
-						)
669
-					);
670
-					break;
671
-
672
-				case 'capabilities_grouped':
673
-				case 'capability_grouped':
674
-				case 'capabilities_group':
675
-				case 'capability_group':
676
-					$args = wp_parse_args(
677
-						$args,
678
-						array(
679
-							'data_sortby' => '',
680
-						)
681
-					);
682
-					break;
683
-
684
-			}
685
-
686
-			return $args;
687
-		}
688
-	}
14
+    /**
15
+     * Class Redux_WordPress_Data
16
+     */
17
+    class Redux_WordPress_Data extends Redux_Class {
18
+
19
+        /**
20
+         * Holds WordPress data.
21
+         *
22
+         * @var null
23
+         */
24
+        private $wp_data = null;
25
+
26
+        /**
27
+         * Redux_WordPress_Data constructor.
28
+         *
29
+         * @param mixed $redux ReduxFramework pointer or opt_name.
30
+         */
31
+        public function __construct( $redux = null ) {
32
+            if ( is_string( $redux ) ) {
33
+                $this->opt_name = $redux;
34
+            } else {
35
+                parent::__construct( $redux );
36
+            }
37
+        }
38
+
39
+        /**
40
+         * Get the data.
41
+         *
42
+         * @param string|array $type          Type.
43
+         * @param array|string $args          Args.
44
+         * @param string       $opt_name      Opt name.
45
+         * @param string|int   $current_value Current value.
46
+         * @param bool         $ajax          Tells if this is an AJAX call.
47
+         *
48
+         * @return array|mixed|string
49
+         */
50
+        public function get( $type, $args = array(), string $opt_name = '', $current_value = '', bool $ajax = false ) {
51
+            if ( '' === $opt_name ) {
52
+                $opt_name = $this->opt_name;
53
+            }
54
+
55
+            // We don't want to run this, it's not a string value. Send it back!
56
+            if ( is_array( $type ) ) {
57
+                return $type;
58
+            }
59
+
60
+            /**
61
+             * Filter 'redux/options/{opt_name}/pre_data/{type}'
62
+             *
63
+             * @param string $data
64
+             */
65
+            $pre_data = apply_filters( "redux/options/$opt_name/pre_data/$type", null ); // phpcs:ignore WordPress.NamingConventions.ValidHookName
66
+            if ( null !== $pre_data || empty( $type ) ) {
67
+                return $pre_data;
68
+            }
69
+
70
+            if ( isset( $args['data_sortby'] ) && in_array( $args['data_sortby'], array( 'value', 'key' ), true ) ) {
71
+                $data_sort = $args['data_sortby'];
72
+                unset( $args['data_sortby'] );
73
+            } else {
74
+                $data_sort = 'value';
75
+            }
76
+            if ( isset( $args['data_order'] ) && in_array( $args['data_order'], array( 'asc', 'desc' ), true ) ) {
77
+                $data_order = $args['data_order'];
78
+                unset( $args['data_order'] );
79
+            } else {
80
+                $data_order = 'asc';
81
+            }
82
+
83
+            $this->maybe_get_translation( $type, $current_value, $args );
84
+
85
+            $current_data = array();
86
+            if ( empty( $current_value ) && ! Redux_Helpers::is_integer( $current_value ) ) {
87
+                $current_value = null;
88
+            } else {
89
+                // Get the args to grab the current data.
90
+                $current_data_args = $this->get_current_data_args( $type, $args, $current_value );
91
+
92
+                // Let's make a unique key for this arg array.
93
+                $current_data_args_key = md5( maybe_serialize( $current_data_args ) );
94
+
95
+                // Check to make sure we haven't already run this call before.
96
+                $current_data = $this->wp_data[ $type . $current_data_args_key ] ?? $this->get_data( $type, $current_data_args, $current_value );
97
+            }
98
+
99
+            // If ajax is enabled AND $current_data is empty, set a dummy value for the init.
100
+            if ( $ajax && ! wp_doing_ajax() ) {
101
+                // Dummy is necessary otherwise empty.
102
+                if ( empty( $current_data ) ) {
103
+                    $current_data = array(
104
+                        'dummy' => '',
105
+                    );
106
+                }
107
+
108
+                return $current_data;
109
+            }
110
+
111
+            // phpcs:ignore Squiz.PHP.CommentedOutCode
112
+            $args_key = md5( maybe_serialize( $args ) );
113
+
114
+            // Data caching.
115
+            if ( isset( $this->wp_data[ $type . $args_key ] ) ) {
116
+                $data = $this->wp_data[ $type . $args_key ];
117
+            } else {
118
+                /**
119
+                 * Use data from WordPress to populate an option array.
120
+                 * */
121
+                $data = $this->get_data( $type, $args, $current_value );
122
+            }
123
+
124
+            if ( ! empty( $current_data ) ) {
125
+                $data += $current_data;
126
+            }
127
+
128
+            if ( ! empty( $data ) ) {
129
+                $data                               = $this->order_data( $data, $data_sort, $data_order );
130
+                $this->wp_data[ $type . $args_key ] = $data;
131
+            }
132
+
133
+            /**
134
+             * Filter 'redux/options/{opt_name}/data/{type}'
135
+             *
136
+             * @param string $data
137
+             */
138
+
139
+            // phpcs:ignore WordPress.NamingConventions.ValidHookName
140
+            return apply_filters( "redux/options/$opt_name/data/$type", $data );
141
+        }
142
+
143
+
144
+        /**
145
+         * Process the results into a proper array, fetching the data elements needed for each data type.
146
+         *
147
+         * @param array|WP_Error $results       Results to process in the data array.
148
+         * @param string|bool    $id_key        Key on object/array that represents the ID.
149
+         * @param string|bool    $name_key      Key on object/array that represents the name/text.
150
+         * @param bool           $add_key       If true, the display key will appear in the text.
151
+         * @param string|bool    $secondary_key If a data type, you'd rather display a different ID as the display key.
152
+         *
153
+         * @return array
154
+         */
155
+        private function process_results( $results = array(), $id_key = '', $name_key = '', bool $add_key = true, $secondary_key = 'slug' ): array {
156
+            $data = array();
157
+            if ( ! empty( $results ) && ! is_a( $results, 'WP_Error' ) ) {
158
+                foreach ( $results as $k => $v ) {
159
+                    if ( empty( $id_key ) ) {
160
+                        $key = $k;
161
+                    } else {
162
+                        if ( is_object( $v ) ) {
163
+                            $key = $v->$id_key;
164
+                        } elseif ( is_array( $v ) ) {
165
+                            $key = $v[ $id_key ];
166
+                        } else {
167
+                            $key = $k;
168
+                        }
169
+                    }
170
+
171
+                    if ( empty( $name_key ) ) {
172
+                        $value = $v;
173
+                    } else {
174
+                        if ( is_object( $v ) ) {
175
+                            $value = $v->$name_key;
176
+                        } elseif ( is_array( $v ) ) {
177
+                            $value = $v[ $name_key ];
178
+                        } else {
179
+                            $value = $v;
180
+                        }
181
+                    }
182
+
183
+                    $display_key = $key;
184
+
185
+                    if ( is_object( $v ) && isset( $v->$secondary_key ) ) {
186
+                        $display_key = $v->$secondary_key;
187
+                    } elseif ( ! is_object( $v ) && isset( $v[ $secondary_key ] ) ) {
188
+                        $display_key = $v[ $secondary_key ];
189
+                    }
190
+                    $data[ $key ] = $value;
191
+                    if ( $display_key !== $value && $add_key ) {
192
+                        $data[ $key ] = $data[ $key ] . ' [' . $display_key . ']';
193
+                    }
194
+                }
195
+            }
196
+
197
+            return $data;
198
+        }
199
+
200
+        /**
201
+         * Order / Sort the data.
202
+         *
203
+         * @param array  $data  Data to sort.
204
+         * @param string $sort  Way to sort. Accepts: key|value.
205
+         * @param string $order Order of the sort. Accepts: asc|desc.
206
+         *
207
+         * @return array
208
+         */
209
+        private function order_data( array $data = array(), string $sort = 'value', string $order = 'asc' ): array {
210
+            if ( 'key' === $sort ) {
211
+                if ( 'asc' === $order ) {
212
+                    ksort( $data );
213
+                } else {
214
+                    krsort( $data );
215
+                }
216
+            } elseif ( 'value' === $sort ) {
217
+                if ( 'asc' === $order ) {
218
+                    asort( $data );
219
+                } else {
220
+                    arsort( $data );
221
+                }
222
+            }
223
+
224
+            return $data;
225
+        }
226
+
227
+        /**
228
+         * Fetch the data for a given type.
229
+         *
230
+         * @param string       $type          The data type we're fetching.
231
+         * @param array|string $args          Arguments to pass.
232
+         * @param mixed|array  $current_value If a current value already set in the database.
233
+         *
234
+         * @return array|null|string
235
+         */
236
+        private function get_data( string $type, $args, $current_value ) {
237
+            $args = $this->get_arg_defaults( $type, $args );
238
+
239
+            $opt_name = $this->opt_name;
240
+            if ( empty( $args ) ) {
241
+                $args = array();
242
+            }
243
+
244
+            $data = array();
245
+            if ( isset( $args['args'] ) && empty( $args['args'] ) ) {
246
+                unset( $args['args'] );
247
+            }
248
+
249
+            $display_keys = false;
250
+            if ( isset( $args['display_keys'] ) ) {
251
+                $display_keys = true;
252
+                unset( $args['display_keys'] );
253
+            }
254
+
255
+            $secondary_key = 'slug';
256
+            if ( isset( $args['secondary_key'] ) ) {
257
+                $secondary_key = $args['secondary_key'];
258
+                unset( $args['secondary_key'] );
259
+            }
260
+
261
+            switch ( $type ) {
262
+                case 'categories':
263
+                case 'category':
264
+                case 'terms':
265
+                case 'term':
266
+                    if ( isset( $args['taxonomies'] ) ) {
267
+                        $args['taxonomy'] = $args['taxonomies'];
268
+                        unset( $args['taxonomies'] );
269
+                    }
270
+                    $results = get_terms( $args );
271
+                    $data    = $this->process_results( $results, 'term_id', 'name', $display_keys, $secondary_key );
272
+                    break;
273
+
274
+                case 'pages':
275
+                case 'page':
276
+                    $results = get_pages( $args );
277
+                    $data    = $this->process_results( $results, 'ID', 'post_title', $display_keys, $secondary_key );
278
+                    break;
279
+
280
+                case 'tags':
281
+                case 'tag':
282
+                    $results = get_tags( $args );
283
+                    $data    = $this->process_results( $results, 'term_id', 'name', $display_keys, $secondary_key );
284
+                    break;
285
+
286
+                case 'menus':
287
+                case 'menu':
288
+                    $results = wp_get_nav_menus( $args );
289
+                    $data    = $this->process_results( $results, 'term_id', 'name', $display_keys, $secondary_key );
290
+                    break;
291
+
292
+                case 'posts':
293
+                case 'post':
294
+                    $results = get_posts( $args );
295
+                    $data    = $this->process_results( $results, 'ID', 'post_title', $display_keys, $secondary_key );
296
+                    break;
297
+
298
+                case 'users':
299
+                case 'user':
300
+                    $results = get_users( $args );
301
+                    $data    = $this->process_results( $results, 'ID', 'display_name', $display_keys, $secondary_key );
302
+                    break;
303
+
304
+                case 'sites':
305
+                case 'site':
306
+                    $sites = get_sites();
307
+
308
+                    if ( isset( $sites ) ) {
309
+                        $results = array();
310
+                        foreach ( $sites as $site ) {
311
+                            $site = (array) $site;
312
+                            $k    = $site['blog_id'];
313
+                            $v    = $site['domain'] . $site['path'];
314
+                            $name = get_blog_option( $k, 'blogname' );
315
+                            if ( ! empty( $name ) ) {
316
+                                $v .= ' - [' . $name . ']';
317
+                            }
318
+                            $results[ $k ] = $v;
319
+                        }
320
+                        $data = $this->process_results( $results, '', '', $display_keys, $secondary_key );
321
+                    }
322
+
323
+                    break;
324
+
325
+                case 'taxonomies':
326
+                case 'taxonomy':
327
+                case 'tax':
328
+                    $results = get_taxonomies( $args );
329
+                    $data    = $this->process_results( $results, '', '', $display_keys, $secondary_key );
330
+                    break;
331
+
332
+                case 'post_types':
333
+                case 'post_type':
334
+                    global $wp_post_types;
335
+
336
+                    $output = $args['output'];
337
+                    unset( $args['output'] );
338
+                    $operator = $args['operator'];
339
+                    unset( $args['operator'] );
340
+
341
+                    $post_types = get_post_types( $args, $output, $operator );
342
+
343
+                    foreach ( $post_types as $name => $title ) {
344
+                        if ( isset( $wp_post_types[ $name ]->labels->menu_name ) ) {
345
+                            $data[ $name ] = $wp_post_types[ $name ]->labels->menu_name;
346
+                        } else {
347
+                            $data[ $name ] = ucfirst( $name );
348
+                        }
349
+                    }
350
+                    break;
351
+
352
+                case 'menu_locations':
353
+                case 'menu_location':
354
+                    global $_wp_registered_nav_menus;
355
+                    foreach ( $_wp_registered_nav_menus as $k => $v ) {
356
+                        $data[ $k ] = $v;
357
+                        if ( ! has_nav_menu( $k ) ) {
358
+                            $data[ $k ] .= ' ' . __( '[unassigned]', 'redux-framework' );
359
+                        }
360
+                    }
361
+                    break;
362
+
363
+                case 'image_sizes':
364
+                case 'image_size':
365
+                    global $_wp_additional_image_sizes;
366
+                    $results = array();
367
+                    foreach ( $_wp_additional_image_sizes as $size_name => $size_attrs ) {
368
+                        $results[ $size_name ] = $size_name . ' - ' . $size_attrs['width'] . ' x ' . $size_attrs['height'];
369
+                    }
370
+                    $data = $this->process_results( $results, '', '', $display_keys, $secondary_key );
371
+
372
+                    break;
373
+
374
+                case 'elusive-icons':
375
+                case 'elusive-icon':
376
+                case 'elusive':
377
+                case 'icons':
378
+                case 'font-icon':
379
+                case 'font-icons':
380
+                    $fs    = Redux_Filesystem::get_instance();
381
+                    $fonts = $fs->get_contents( Redux_Core::$dir . 'assets/css/vendor/elusive-icons.css' );
382
+                    if ( ! empty( $fonts ) ) {
383
+                        preg_match_all( '@\.el-(\w+)::before@', $fonts, $matches );
384
+                        foreach ( $matches[1] as $item ) {
385
+                            if ( 'before' === $item ) {
386
+                                continue;
387
+                            }
388
+                            $data[ 'el el-' . $item ] = $item;
389
+                        }
390
+                    }
391
+
392
+                    /**
393
+                     * Filter 'redux/font-icons'
394
+                     *
395
+                     * @param array $font_icons array of elusive icon classes
396
+                     *
397
+                     * @deprecated
398
+                     */
399
+
400
+                    // phpcs:ignore WordPress.NamingConventions.ValidHookName
401
+                    $font_icons = apply_filters_deprecated( 'redux/font-icons', array( $data ), '4.3', 'redux/$opt_name/field/font/icons' );
402
+
403
+                    /**
404
+                     * Filter 'redux/{opt_name}/field/font/icons'
405
+                     *
406
+                     * @param array $font_icons array of elusive icon classes
407
+                     */
408
+
409
+                    // phpcs:ignore WordPress.NamingConventions.ValidHookName
410
+                    $data = apply_filters( "redux/$opt_name/field/font/icons", $font_icons );
411
+
412
+                    break;
413
+
414
+                case 'dashicons':
415
+                case 'dashicon':
416
+                case 'dash':
417
+                    $fs    = Redux_Filesystem::get_instance();
418
+                    $fonts = $fs->get_contents( ABSPATH . WPINC . '/css/dashicons.css' );
419
+                    if ( ! empty( $fonts ) ) {
420
+                        preg_match_all( '@\.dashicons-(\w+):before@', $fonts, $matches );
421
+                        foreach ( $matches[1] as $item ) {
422
+                            if ( 'before' === $item ) {
423
+                                continue;
424
+                            }
425
+                            $data[ 'dashicons dashicons-' . $item ] = $item;
426
+                        }
427
+                    }
428
+                    break;
429
+
430
+                case 'roles':
431
+                case 'role':
432
+                    global $wp_roles;
433
+                    $results = $wp_roles->get_names();
434
+                    $data    = $this->process_results( $results, '', '', $display_keys, $secondary_key );
435
+
436
+                    break;
437
+
438
+                case 'sidebars':
439
+                case 'sidebar':
440
+                    global $wp_registered_sidebars;
441
+                    $data = $this->process_results( $wp_registered_sidebars, '', 'name', $display_keys, $secondary_key );
442
+                    break;
443
+                case 'capabilities':
444
+                case 'capability':
445
+                    global $wp_roles;
446
+                    $results = array();
447
+                    foreach ( $wp_roles->roles as $role ) {
448
+                        foreach ( $role['capabilities'] as $key => $cap ) {
449
+                            $results[ $key ] = ucwords( str_replace( '_', ' ', $key ) );
450
+                        }
451
+                    }
452
+                    $data = $this->process_results( $results, '', '', $display_keys, $secondary_key );
453
+
454
+                    break;
455
+
456
+                case 'capabilities_grouped':
457
+                case 'capability_grouped':
458
+                case 'capabilities_group':
459
+                case 'capability_group':
460
+                    global $wp_roles;
461
+
462
+                    foreach ( $wp_roles->roles as $role ) {
463
+                        $caps = array();
464
+                        foreach ( $role['capabilities'] as $key => $cap ) {
465
+                            $caps[ $key ] = ucwords( str_replace( '_', ' ', $key ) );
466
+                        }
467
+                        asort( $caps );
468
+                        $data[ $role['name'] ] = $caps;
469
+                    }
470
+
471
+                    break;
472
+
473
+                case 'callback':
474
+                    if ( ! empty( $args ) && is_callable( $args ) ) {
475
+                        $data = call_user_func( $args, $current_value );
476
+                    }
477
+
478
+                    break;
479
+            }
480
+
481
+            return $data;
482
+        }
483
+
484
+
485
+        /**
486
+         * Router for translation based on the given post-type.
487
+         *
488
+         * @param string       $type          Type of data request.
489
+         * @param mixed|array  $current_value Current value stored in DB.
490
+         * @param array|string $args          Arguments for the call.
491
+         */
492
+        private function maybe_get_translation( string $type, &$current_value = '', $args = array() ) {
493
+            switch ( $type ) {
494
+                case 'categories':
495
+                case 'category':
496
+                    $this->maybe_translate( $current_value, 'category' );
497
+                    break;
498
+
499
+                case 'pages':
500
+                case 'page':
501
+                    $this->maybe_translate( $current_value, 'page' );
502
+                    break;
503
+
504
+                case 'terms':
505
+                case 'term':
506
+                    $this->maybe_translate( $current_value, $args['taxonomy'] ?? '' );
507
+                    break;
508
+
509
+                case 'tags':
510
+                case 'tag':
511
+                    $this->maybe_translate( $current_value, 'post_tag' );
512
+                    break;
513
+
514
+                case 'menus':
515
+                case 'menu':
516
+                    $this->maybe_translate( $current_value, 'nav_menu' );
517
+                    break;
518
+
519
+                case 'post':
520
+                case 'posts':
521
+                    $this->maybe_translate( $current_value, 'post' );
522
+                    break;
523
+                default:
524
+                    $this->maybe_translate( $current_value, '' );
525
+            }
526
+        }
527
+
528
+        /**
529
+         * Maybe translate the values.
530
+         *
531
+         * @param mixed|array $value     Value.
532
+         * @param mixed|array $post_type Post type.
533
+         */
534
+        private function maybe_translate( &$value, $post_type ) {
535
+
536
+            // phpcs:ignore WordPress.NamingConventions.ValidHookName
537
+            $value = apply_filters( "redux/options/$this->opt_name/wordpress_data/translate/post_type_value", $value, $post_type );
538
+
539
+            // WPML Integration, see https://wpml.org/documentation/support/creating-multilingual-wordpress-themes/language-dependent-ids/.
540
+            if ( function_exists( 'icl_object_id' ) ) {
541
+                if ( has_filter( 'wpml_object_id' ) ) {
542
+                    if ( Redux_Helpers::is_integer( $value ) ) {
543
+                        // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals -- Third party hook. Cannot change.
544
+                        $value = apply_filters( 'wpml_object_id', $value, $post_type, true );
545
+                    } elseif ( is_array( $value ) ) {
546
+                        $value = array_map(
547
+                            function ( $val ) use ( $post_type ) {
548
+                                // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals -- Third party hook. Cannot change.
549
+                                return apply_filters( 'wpml_object_id', $val, $post_type, true );
550
+                            },
551
+                            $value
552
+                        );
553
+                    }
554
+                }
555
+            }
556
+        }
557
+
558
+        /**
559
+         * Set the default arguments for a current query (existing data).
560
+         *
561
+         * @param string       $type          Type of data request.
562
+         * @param array|string $args          Arguments for the call.
563
+         * @param mixed|array  $current_value Current value stored in DB.
564
+         *
565
+         * @return array
566
+         */
567
+        private function get_current_data_args( string $type, $args, $current_value ): array {
568
+            // In this section, we set the default arguments for each data type.
569
+            switch ( $type ) {
570
+                case 'categories':
571
+                case 'category':
572
+                case 'pages':
573
+                case 'page':
574
+                case 'terms':
575
+                case 'term':
576
+                case 'users':
577
+                case 'user':
578
+                    $args['include'] = $current_value;
579
+                    break;
580
+                case 'tags':
581
+                case 'tag':
582
+                    $args['get'] = 'all';
583
+                    break;
584
+                case 'menus':
585
+                case 'menu':
586
+                    $args['object_ids'] = $current_value;
587
+                    break;
588
+                case 'post':
589
+                case 'posts':
590
+                    if ( ! empty( $current_value ) ) {
591
+                        $args['post__in'] = is_array( $current_value ) ? $current_value : array( $current_value );
592
+                    }
593
+                    break;
594
+
595
+                default:
596
+                    $args = array();
597
+            }
598
+
599
+            return $args;
600
+        }
601
+
602
+
603
+        /**
604
+         * Get default arguments for a given data type.
605
+         *
606
+         * @param string       $type Type of data request.
607
+         * @param array|string $args Arguments for the call.
608
+         *
609
+         * @return array|string
610
+         */
611
+        private function get_arg_defaults( string $type, $args = array() ) {
612
+            // In this section, we set the default arguments for each data type.
613
+            switch ( $type ) {
614
+                case 'categories':
615
+                case 'category':
616
+                    $args = wp_parse_args(
617
+                        $args,
618
+                        array(
619
+                            'taxonomy' => 'category',
620
+                        )
621
+                    );
622
+                    break;
623
+
624
+                case 'pages':
625
+                case 'page':
626
+                    $args = wp_parse_args(
627
+                        $args,
628
+                        array(
629
+                            'display_keys'   => true,
630
+                            'posts_per_page' => 20,
631
+                        )
632
+                    );
633
+                    break;
634
+
635
+                case 'post_type':
636
+                case 'post_types':
637
+                    $args = wp_parse_args(
638
+                        $args,
639
+                        array(
640
+                            'public'              => true,
641
+                            'exclude_from_search' => false,
642
+                            'output'              => 'names',
643
+                            'operator'            => 'and',
644
+                        )
645
+                    );
646
+
647
+                    break;
648
+
649
+                case 'tag':
650
+                case 'tags':
651
+                    $args = wp_parse_args(
652
+                        $args,
653
+                        array(
654
+                            'get'          => 'all',
655
+                            'display_keys' => true,
656
+                        )
657
+                    );
658
+                    break;
659
+
660
+                case 'sidebars':
661
+                case 'sidebar':
662
+                case 'capabilities':
663
+                case 'capability':
664
+                    $args = wp_parse_args(
665
+                        $args,
666
+                        array(
667
+                            'display_keys' => true,
668
+                        )
669
+                    );
670
+                    break;
671
+
672
+                case 'capabilities_grouped':
673
+                case 'capability_grouped':
674
+                case 'capabilities_group':
675
+                case 'capability_group':
676
+                    $args = wp_parse_args(
677
+                        $args,
678
+                        array(
679
+                            'data_sortby' => '',
680
+                        )
681
+                    );
682
+                    break;
683
+
684
+            }
685
+
686
+            return $args;
687
+        }
688
+    }
689 689
 }
Please login to merge, or discard this patch.
Spacing   +24 added lines, -24 removed lines patch added patch discarded remove patch
@@ -93,7 +93,7 @@  discard block
 block discarded – undo
93 93
 				$current_data_args_key = md5( maybe_serialize( $current_data_args ) );
94 94
 
95 95
 				// Check to make sure we haven't already run this call before.
96
-				$current_data = $this->wp_data[ $type . $current_data_args_key ] ?? $this->get_data( $type, $current_data_args, $current_value );
96
+				$current_data = $this->wp_data[$type . $current_data_args_key] ?? $this->get_data( $type, $current_data_args, $current_value );
97 97
 			}
98 98
 
99 99
 			// If ajax is enabled AND $current_data is empty, set a dummy value for the init.
@@ -112,8 +112,8 @@  discard block
 block discarded – undo
112 112
 			$args_key = md5( maybe_serialize( $args ) );
113 113
 
114 114
 			// Data caching.
115
-			if ( isset( $this->wp_data[ $type . $args_key ] ) ) {
116
-				$data = $this->wp_data[ $type . $args_key ];
115
+			if ( isset( $this->wp_data[$type . $args_key] ) ) {
116
+				$data = $this->wp_data[$type . $args_key];
117 117
 			} else {
118 118
 				/**
119 119
 				 * Use data from WordPress to populate an option array.
@@ -127,7 +127,7 @@  discard block
 block discarded – undo
127 127
 
128 128
 			if ( ! empty( $data ) ) {
129 129
 				$data                               = $this->order_data( $data, $data_sort, $data_order );
130
-				$this->wp_data[ $type . $args_key ] = $data;
130
+				$this->wp_data[$type . $args_key] = $data;
131 131
 			}
132 132
 
133 133
 			/**
@@ -162,7 +162,7 @@  discard block
 block discarded – undo
162 162
 						if ( is_object( $v ) ) {
163 163
 							$key = $v->$id_key;
164 164
 						} elseif ( is_array( $v ) ) {
165
-							$key = $v[ $id_key ];
165
+							$key = $v[$id_key];
166 166
 						} else {
167 167
 							$key = $k;
168 168
 						}
@@ -174,7 +174,7 @@  discard block
 block discarded – undo
174 174
 						if ( is_object( $v ) ) {
175 175
 							$value = $v->$name_key;
176 176
 						} elseif ( is_array( $v ) ) {
177
-							$value = $v[ $name_key ];
177
+							$value = $v[$name_key];
178 178
 						} else {
179 179
 							$value = $v;
180 180
 						}
@@ -184,12 +184,12 @@  discard block
 block discarded – undo
184 184
 
185 185
 					if ( is_object( $v ) && isset( $v->$secondary_key ) ) {
186 186
 						$display_key = $v->$secondary_key;
187
-					} elseif ( ! is_object( $v ) && isset( $v[ $secondary_key ] ) ) {
188
-						$display_key = $v[ $secondary_key ];
187
+					} elseif ( ! is_object( $v ) && isset( $v[$secondary_key] ) ) {
188
+						$display_key = $v[$secondary_key];
189 189
 					}
190
-					$data[ $key ] = $value;
190
+					$data[$key] = $value;
191 191
 					if ( $display_key !== $value && $add_key ) {
192
-						$data[ $key ] = $data[ $key ] . ' [' . $display_key . ']';
192
+						$data[$key] = $data[$key] . ' [' . $display_key . ']';
193 193
 					}
194 194
 				}
195 195
 			}
@@ -308,14 +308,14 @@  discard block
 block discarded – undo
308 308
 					if ( isset( $sites ) ) {
309 309
 						$results = array();
310 310
 						foreach ( $sites as $site ) {
311
-							$site = (array) $site;
311
+							$site = ( array ) $site;
312 312
 							$k    = $site['blog_id'];
313 313
 							$v    = $site['domain'] . $site['path'];
314 314
 							$name = get_blog_option( $k, 'blogname' );
315 315
 							if ( ! empty( $name ) ) {
316 316
 								$v .= ' - [' . $name . ']';
317 317
 							}
318
-							$results[ $k ] = $v;
318
+							$results[$k] = $v;
319 319
 						}
320 320
 						$data = $this->process_results( $results, '', '', $display_keys, $secondary_key );
321 321
 					}
@@ -341,10 +341,10 @@  discard block
 block discarded – undo
341 341
 					$post_types = get_post_types( $args, $output, $operator );
342 342
 
343 343
 					foreach ( $post_types as $name => $title ) {
344
-						if ( isset( $wp_post_types[ $name ]->labels->menu_name ) ) {
345
-							$data[ $name ] = $wp_post_types[ $name ]->labels->menu_name;
344
+						if ( isset( $wp_post_types[$name]->labels->menu_name ) ) {
345
+							$data[$name] = $wp_post_types[$name]->labels->menu_name;
346 346
 						} else {
347
-							$data[ $name ] = ucfirst( $name );
347
+							$data[$name] = ucfirst( $name );
348 348
 						}
349 349
 					}
350 350
 					break;
@@ -353,9 +353,9 @@  discard block
 block discarded – undo
353 353
 				case 'menu_location':
354 354
 					global $_wp_registered_nav_menus;
355 355
 					foreach ( $_wp_registered_nav_menus as $k => $v ) {
356
-						$data[ $k ] = $v;
356
+						$data[$k] = $v;
357 357
 						if ( ! has_nav_menu( $k ) ) {
358
-							$data[ $k ] .= ' ' . __( '[unassigned]', 'redux-framework' );
358
+							$data[$k] .= ' ' . __( '[unassigned]', 'redux-framework' );
359 359
 						}
360 360
 					}
361 361
 					break;
@@ -365,7 +365,7 @@  discard block
 block discarded – undo
365 365
 					global $_wp_additional_image_sizes;
366 366
 					$results = array();
367 367
 					foreach ( $_wp_additional_image_sizes as $size_name => $size_attrs ) {
368
-						$results[ $size_name ] = $size_name . ' - ' . $size_attrs['width'] . ' x ' . $size_attrs['height'];
368
+						$results[$size_name] = $size_name . ' - ' . $size_attrs['width'] . ' x ' . $size_attrs['height'];
369 369
 					}
370 370
 					$data = $this->process_results( $results, '', '', $display_keys, $secondary_key );
371 371
 
@@ -385,7 +385,7 @@  discard block
 block discarded – undo
385 385
 							if ( 'before' === $item ) {
386 386
 								continue;
387 387
 							}
388
-							$data[ 'el el-' . $item ] = $item;
388
+							$data['el el-' . $item] = $item;
389 389
 						}
390 390
 					}
391 391
 
@@ -422,7 +422,7 @@  discard block
 block discarded – undo
422 422
 							if ( 'before' === $item ) {
423 423
 								continue;
424 424
 							}
425
-							$data[ 'dashicons dashicons-' . $item ] = $item;
425
+							$data['dashicons dashicons-' . $item] = $item;
426 426
 						}
427 427
 					}
428 428
 					break;
@@ -446,7 +446,7 @@  discard block
 block discarded – undo
446 446
 					$results = array();
447 447
 					foreach ( $wp_roles->roles as $role ) {
448 448
 						foreach ( $role['capabilities'] as $key => $cap ) {
449
-							$results[ $key ] = ucwords( str_replace( '_', ' ', $key ) );
449
+							$results[$key] = ucwords( str_replace( '_', ' ', $key ) );
450 450
 						}
451 451
 					}
452 452
 					$data = $this->process_results( $results, '', '', $display_keys, $secondary_key );
@@ -462,10 +462,10 @@  discard block
 block discarded – undo
462 462
 					foreach ( $wp_roles->roles as $role ) {
463 463
 						$caps = array();
464 464
 						foreach ( $role['capabilities'] as $key => $cap ) {
465
-							$caps[ $key ] = ucwords( str_replace( '_', ' ', $key ) );
465
+							$caps[$key] = ucwords( str_replace( '_', ' ', $key ) );
466 466
 						}
467 467
 						asort( $caps );
468
-						$data[ $role['name'] ] = $caps;
468
+						$data[$role['name']] = $caps;
469 469
 					}
470 470
 
471 471
 					break;
@@ -544,7 +544,7 @@  discard block
 block discarded – undo
544 544
 						$value = apply_filters( 'wpml_object_id', $value, $post_type, true );
545 545
 					} elseif ( is_array( $value ) ) {
546 546
 						$value = array_map(
547
-							function ( $val ) use ( $post_type ) {
547
+							function( $val ) use ( $post_type ) {
548 548
 								// phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals -- Third party hook. Cannot change.
549 549
 								return apply_filters( 'wpml_object_id', $val, $post_type, true );
550 550
 							},
Please login to merge, or discard this patch.
redux-core/inc/classes/class-redux-api.php 2 patches
Indentation   +1755 added lines, -1755 removed lines patch added patch discarded remove patch
@@ -16,1759 +16,1759 @@
 block discarded – undo
16 16
 // Don't duplicate me!
17 17
 if ( ! class_exists( 'Redux', false ) ) {
18 18
 
19
-	/**
20
-	 * Redux API Class
21
-	 * Simple API for Redux Framework
22
-	 *
23
-	 * @since       3.0.0
24
-	 */
25
-	class Redux {
26
-
27
-
28
-		/**
29
-		 *  Option fields.
30
-		 *
31
-		 * @var array
32
-		 */
33
-		public static array $fields = array();
34
-
35
-		/**
36
-		 * Option sections.
37
-		 *
38
-		 * @var array
39
-		 */
40
-		public static array $sections = array();
41
-
42
-		/**
43
-		 * Option defaults.
44
-		 *
45
-		 * @var array
46
-		 */
47
-		public static array $options_defaults = array();
48
-
49
-		/**
50
-		 * Option help array.
51
-		 *
52
-		 * @var array
53
-		 */
54
-		public static array $help = array();
55
-
56
-		/**
57
-		 * Option global args.
58
-		 *
59
-		 * @var array
60
-		 */
61
-		public static array $args = array();
62
-
63
-		/**
64
-		 * Option section priorities.
65
-		 *
66
-		 * @var array
67
-		 */
68
-		public static array $priority = array();
69
-
70
-		/**
71
-		 * Panel validations errors.
72
-		 *
73
-		 * @var array
74
-		 */
75
-		public static array $errors = array();
76
-
77
-		/**
78
-		 * Init.
79
-		 *
80
-		 * @var array
81
-		 */
82
-		public static array $init = array();
83
-
84
-		/**
85
-		 * Delay Init opt_names
86
-		 *
87
-		 * @var array
88
-		 */
89
-		public static array $delay_init = array();
90
-
91
-		/**
92
-		 * Extension list.
93
-		 *
94
-		 * @var array
95
-		 */
96
-		public static array $extensions = array();
97
-
98
-		/**
99
-		 * Extensions in use.
100
-		 *
101
-		 * @var array
102
-		 */
103
-		public static array $uses_extensions = array();
104
-
105
-		/**
106
-		 * Extension paths.
107
-		 *
108
-		 * @var array
109
-		 */
110
-		public static array $extension_paths = array();
111
-
112
-		/**
113
-		 * Extension capability flag.
114
-		 *
115
-		 * @var boolean
116
-		 */
117
-		public static bool $extension_compatibility = false;
118
-
119
-		/**
120
-		 * Code to run at creation in instance.
121
-		 */
122
-		public static function load() {
123
-			add_action( 'after_setup_theme', array( 'Redux', 'create_redux' ) );
124
-			add_action( 'init', array( 'Redux', 'create_redux' ) );
125
-			add_action( 'switch_theme', array( 'Redux', 'create_redux' ) );
126
-
127
-			require_once Redux_Core::$dir . 'inc/extensions/metaboxes/class-redux-metaboxes-api.php';
128
-			require_once Redux_Core::$dir . 'inc/extensions/users/class-redux-users-api.php';
129
-			require_once Redux_Core::$dir . 'inc/extensions/taxonomy/class-redux-taxonomy-api.php';
130
-		}
131
-
132
-		/**
133
-		 * Delay init action function
134
-		 * Delays all Redux objects from loaded before `plugins_loaded` runs.
135
-		 *
136
-		 * @throws ReflectionException Exception.
137
-		 */
138
-		public static function delay_init() {
139
-			if ( ! empty( self::$delay_init ) ) {
140
-
141
-				foreach ( self::$delay_init as $opt_name ) {
142
-					self::init( $opt_name );
143
-					$parent = Redux_Instances::get_instance( $opt_name );
144
-					// translators: This is only shown to developers, should not impact users.
145
-					$msg = sprintf(
146
-						'<strong>%s</strong><br /><code>%s</code> %s',
147
-						esc_html__( 'Warning, Premature Initialization', 'redux-framework' ),
148
-						'self::init("' . esc_html( $opt_name ) . '")',
149
-						// translators: This is only shown to developers, should not impact users.
150
-						sprintf( esc_html__( 'was run before the %s hook and was delayed to avoid errors.', 'redux-framework' ), '<code>plugins_loaded</code>' )
151
-					);
152
-
153
-					if ( isset( $parent->args ) ) {
154
-						$data = array(
155
-							'parent'  => $parent,
156
-							'type'    => 'error',
157
-							'msg'     => $msg,
158
-							'id'      => 'redux_init',
159
-							'dismiss' => true,
160
-						);
161
-
162
-						Redux_Admin_Notices::set_notice( $data );
163
-					}
164
-				}
165
-			}
166
-		}
167
-
168
-		/**
169
-		 * Init Redux object
170
-		 *
171
-		 * @param string $opt_name Panel opt_name.
172
-		 *
173
-		 * @throws ReflectionException  Exception.
174
-		 */
175
-		public static function init( string $opt_name = '' ) {
176
-			if ( ! empty( $opt_name ) ) {
177
-				if ( ! did_action( 'plugins_loaded' ) ) {
178
-
179
-					// We don't want to load before plugins_loaded EVER.
180
-					self::$delay_init[] = $opt_name;
181
-					add_action( 'plugins_loaded', array( 'Redux', 'delay_init' ) );
182
-				} else {
183
-
184
-					// The hook `plugins_loaded` has run, let's get going!
185
-					self::load_redux( $opt_name );
186
-
187
-					remove_action( 'setup_theme', array( 'Redux', 'create_redux' ) );
188
-				}
189
-			}
190
-		}
191
-
192
-		/**
193
-		 * Retrieve ReduxFramework object.
194
-		 *
195
-		 * @param string $opt_name Panel opt_name.
196
-		 *
197
-		 * @return object|ReduxFramework
198
-		 */
199
-		public static function instance( string $opt_name ) {
200
-			return Redux_Instances::get_instance( $opt_name );
201
-		}
202
-
203
-		/**
204
-		 * Retrieve all ReduxFramework Instances.
205
-		 *
206
-		 * @return null|array|ReduxFramework[]
207
-		 */
208
-		public static function all_instances(): ?array {
209
-			return Redux_Instances::get_all_instances();
210
-		}
211
-
212
-		/**
213
-		 * Load external extensions.
214
-		 *
215
-		 * @param object $redux_framework ReduxFramework object.
216
-		 *
217
-		 * @deprecated No longer using camelCase naming conventions.
218
-		 */
219
-		public static function loadExtensions( $redux_framework ) { // phpcs:ignore WordPress.NamingConventions.ValidFunctionName
220
-			_deprecated_function( __CLASS__ . '::' . __FUNCTION__, ' Redux 4.3', 'Redux::load_extensions( $redux_framework )' );
221
-
222
-			self::load_extensions( $redux_framework );
223
-		}
224
-
225
-		/**
226
-		 * Load external extensions.
227
-		 *
228
-		 * @param object $redux_framework ReduxFramework object.
229
-		 */
230
-		public static function load_extensions( $redux_framework ) {
231
-			$instance_extensions = self::get_extensions( $redux_framework->args['opt_name'] );
232
-
233
-			if ( $instance_extensions ) {
234
-				foreach ( $instance_extensions as $name => $extension ) {
235
-					$old_class = str_replace( 'Redux_', 'ReduxFramework_', $extension['class'] );
236
-
237
-					if ( ! class_exists( $extension['class'] ) && ! class_exists( $old_class ) ) {
238
-						// In case you wanted to override your override, hah.
239
-						// Phpcs:ignore WordPress.NamingConventions.ValidHookName
240
-						$extension['path'] = apply_filters( 'redux/extension/' . $redux_framework->args['opt_name'] . '/' . $name, $extension['path'] );
241
-						if ( file_exists( $extension['path'] ) ) {
242
-							require_once $extension['path'];
243
-						}
244
-					}
245
-					if ( isset( $extension['field'] ) ) {
246
-						require_once $extension['field'];
247
-					}
248
-
249
-					if ( ! isset( $redux_framework->extensions[ $name ] ) ) {
250
-						$field_classes = array( $extension['class'], $old_class );
251
-						$ext_class     = Redux_Functions::class_exists_ex( $field_classes );
252
-						if ( false !== $ext_class ) {
253
-							$redux_framework->extensions[ $name ] = new $ext_class( $redux_framework );
254
-						} elseif ( is_admin() && true === $redux_framework->args['dev_mode'] ) {
255
-							echo '<div id="message" class="error"><p>No class named <strong>' . esc_html( $extension['class'] ) . '</strong> exists. Please verify your extension path.</p></div>';
256
-						}
257
-					}
258
-				}
259
-			}
260
-		}
261
-
262
-		/**
263
-		 * Deprecated function to set an extension path.
264
-		 *
265
-		 * @param string $extension Path.
266
-		 * @param bool   $folder    Set if a path is a folder.
267
-		 *
268
-		 * @return bool|mixed
269
-		 * @deprecated No longer using cameCase naming conventions.
270
-		 */
271
-		public static function extensionPath( string $extension, bool $folder = true ) { // phpcs:ignore WordPress.NamingConventions.ValidFunctionName
272
-			_deprecated_function( __CLASS__ . '::' . __FUNCTION__, 'Redux 4.3', 'Redux::extension_path( $extension, $folder )' );
273
-
274
-			return self::extension_path( $extension, $folder );
275
-		}
276
-
277
-		/**
278
-		 * Sets a path to an extension.
279
-		 *
280
-		 * @param string $extension Path to an extension.
281
-		 * @param bool   $folder    Set if a path is a folder.
282
-		 *
283
-		 * @return bool|mixed
284
-		 */
285
-		public static function extension_path( string $extension, bool $folder = true ) {
286
-			if ( ! isset( self::$extensions[ $extension ] ) ) {
287
-				return false;
288
-			}
289
-
290
-			$path = end( self::$extensions[ $extension ] );
291
-
292
-			if ( ! $folder ) {
293
-				return $path;
294
-			}
295
-
296
-			return dirname( $path );
297
-		}
298
-
299
-		/**
300
-		 * Deprecated function of Load Redux Framework.
301
-		 *
302
-		 * @param string $opt_name Panel opt_name.
303
-		 *
304
-		 * @throws ReflectionException Exception.
305
-		 *
306
-		 * @deprecated No longer using camelCase naming conventions.
307
-		 */
308
-		public static function loadRedux( string $opt_name = '' ) { // phpcs:ignore WordPress.NamingConventions.ValidFunctionName
309
-			_deprecated_function( __CLASS__ . '::' . __FUNCTION__, 'Redux 4.3', 'Redux::load_redux( $opt_name )' );
310
-
311
-			self::load_redux( $opt_name );
312
-		}
313
-
314
-		/**
315
-		 * Load defaults values for a given opt_name.
316
-		 *
317
-		 * @param string $opt_name Panel opt_name.
318
-		 */
319
-		public static function set_defaults( string $opt_name = '' ) {
320
-			// Try to load the class if in the same directory, so the user only has to include the Redux API.
321
-			if ( ! class_exists( 'Redux_Options_Defaults' ) ) {
322
-				$file_check = trailingslashit( __DIR__ ) . 'class-redux-options-defaults.php';
323
-
324
-				if ( file_exists( dirname( $file_check ) ) ) {
325
-					include_once $file_check;
326
-					$file_check = trailingslashit( __DIR__ ) . 'class-redux-wordpress-data.php';
327
-					if ( file_exists( dirname( $file_check ) ) ) {
328
-						include_once $file_check;
329
-					}
330
-				}
331
-			}
332
-
333
-			if ( class_exists( 'Redux_Options_Defaults' ) && ! isset( self::$options_defaults[ $opt_name ] ) ) {
334
-				$sections                            = self::construct_sections( $opt_name );
335
-				$wordpress_data                      = ( ! class_exists( 'Redux_WordPress_Data' ) ) ? null : new Redux_WordPress_Data( $opt_name );
336
-				$options_defaults_class              = new Redux_Options_Defaults();
337
-				self::$options_defaults[ $opt_name ] = $options_defaults_class->default_values( $opt_name, $sections, $wordpress_data );
338
-				if ( ! isset( self::$args[ $opt_name ]['global_variable'] ) || ( '' === self::$args[ $opt_name ]['global_variable'] && false !== self::$args[ $opt_name ]['global_variable'] ) ) {
339
-					self::$args[ $opt_name ]['global_variable'] = str_replace( '-', '_', $opt_name );
340
-				}
341
-				if ( isset( self::$args[ $opt_name ]['global_variable'] ) && self::$args[ $opt_name ]['global_variable'] ) {
342
-					$option_global = self::$args[ $opt_name ]['global_variable'];
343
-
344
-					/**
345
-					 * Filter 'redux/options/{opt_name}/global_variable'
346
-					 *
347
-					 * @param array $value option value to set global_variable with
348
-					 */
349
-					global $$option_global;
350
-
351
-					// phpcs:ignore WordPress.NamingConventions.ValidHookName, WordPress.NamingConventions.PrefixAllGlobals
352
-					$$option_global = apply_filters( 'redux/options/' . $opt_name . '/global_variable', self::$options_defaults[ $opt_name ] );
353
-				}
354
-			}
355
-		}
356
-
357
-		/**
358
-		 * Load Redux Framework.
359
-		 *
360
-		 * @param string $opt_name Panel opt_name.
361
-		 *
362
-		 * @throws ReflectionException  Exception.
363
-		 */
364
-		public static function load_redux( string $opt_name = '' ) {
365
-			if ( empty( $opt_name ) ) {
366
-				return;
367
-			}
368
-
369
-			if ( class_exists( 'ReduxFramework' ) ) {
370
-				if ( isset( self::$init[ $opt_name ] ) && ! empty( self::$init[ $opt_name ] ) ) {
371
-					return;
372
-				}
373
-			} else {
374
-				echo '<div id="message" class="error"><p>' . esc_html__( 'Redux Framework is not installed. Please install it.', 'redux-framework' ) . '</p></div>';
375
-
376
-				return;
377
-			}
378
-
379
-			self::instance( $opt_name );
380
-
381
-			Redux_Functions_Ex::record_caller( $opt_name );
382
-
383
-			if ( isset( self::$init[ $opt_name ] ) && 1 === self::$init[ $opt_name ] ) {
384
-				return;
385
-			}
386
-
387
-			// self::set_defaults( $opt_name );
388
-
389
-			$args     = self::construct_args( $opt_name );
390
-			$sections = self::construct_sections( $opt_name );
391
-
392
-			if ( isset( self::$uses_extensions[ $opt_name ] ) && ! empty( self::$uses_extensions[ $opt_name ] ) ) {
393
-				add_action( "redux/extensions/$opt_name/before", array( 'Redux', 'load_extensions' ), 0 );
394
-			}
395
-
396
-			$redux                   = new ReduxFramework( $sections, $args );
397
-			self::$init[ $opt_name ] = 1;
398
-
399
-			if ( isset( $redux->args['opt_name'] ) && $redux->args['opt_name'] !== $opt_name ) {
400
-				self::$init[ $redux->args['opt_name'] ] = 1;
401
-			}
402
-		}
403
-
404
-		/**
405
-		 * Deprecated Create Redux instance.
406
-		 *
407
-		 * @throws ReflectionException  Exception.
408
-		 *
409
-		 * @deprecated No longer using camelCase naming convention.
410
-		 */
411
-		public static function createRedux() {       // phpcs:ignore WordPress.NamingConventions.ValidFunctionName
412
-			_deprecated_function( __CLASS__ . '::' . __FUNCTION__, 'Redux 4.3', 'Redux::createRedux()' );
413
-
414
-			self::create_redux();
415
-		}
416
-
417
-		/**
418
-		 * Create Redux instance.
419
-		 *
420
-		 * @throws ReflectionException  Exception.
421
-		 */
422
-		public static function create_redux() {
423
-			foreach ( self::$sections as $opt_name => $the_sections ) {
424
-				if ( ! empty( $the_sections ) ) {
425
-					if ( ! self::$init[ $opt_name ] ) {
426
-						self::load_redux( $opt_name );
427
-					}
428
-				}
429
-			}
430
-		}
431
-
432
-		/**
433
-		 * Construct global arguments.
434
-		 *
435
-		 * @param string $opt_name Panel opt_name.
436
-		 *
437
-		 * @return array|mixed
438
-		 */
439
-		public static function construct_args( string $opt_name ) {
440
-			$args             = self::$args[ $opt_name ] ?? array();
441
-			$args['opt_name'] = $opt_name;
442
-
443
-			if ( ! isset( $args['menu_title'] ) ) {
444
-				$args['menu_title'] = ucfirst( $opt_name ) . ' Options';
445
-			}
446
-
447
-			if ( ! isset( $args['page_title'] ) ) {
448
-				$args['page_title'] = ucfirst( $opt_name ) . ' Options';
449
-			}
450
-
451
-			if ( ! isset( $args['page_slug'] ) ) {
452
-				$args['page_slug'] = $opt_name . '_options';
453
-			}
454
-
455
-			return $args;
456
-		}
457
-
458
-		/**
459
-		 * Construct option panel sections.
460
-		 *
461
-		 * @param string $opt_name Panel opt_name.
462
-		 *
463
-		 * @return array
464
-		 */
465
-		public static function construct_sections( string $opt_name ): array {
466
-			$sections = array();
467
-
468
-			if ( ! isset( self::$sections[ $opt_name ] ) ) {
469
-				return $sections;
470
-			}
471
-
472
-			foreach ( self::$sections[ $opt_name ] as $section_id => $section ) {
473
-				$section['fields'] = self::construct_fields( $opt_name, $section_id );
474
-				$p                 = $section['priority'];
475
-
476
-				while ( isset( $sections[ $p ] ) ) {
477
-					++$p;
478
-				}
479
-
480
-				$sections[ $p ] = $section;
481
-			}
482
-
483
-			ksort( $sections );
484
-
485
-			return $sections;
486
-		}
487
-
488
-		/**
489
-		 * Construct option panel fields.
490
-		 *
491
-		 * @param string $opt_name   Panel opt_name.
492
-		 * @param string $section_id ID of a section.
493
-		 *
494
-		 * @return array
495
-		 */
496
-		public static function construct_fields( string $opt_name = '', string $section_id = '' ): array {
497
-			$fields = array();
498
-
499
-			if ( ! empty( self::$fields[ $opt_name ] ) ) {
500
-				foreach ( self::$fields[ $opt_name ] as $field ) {
501
-					if ( $field['section_id'] === $section_id ) {
502
-						$p = esc_html( $field['priority'] );
503
-
504
-						while ( isset( $fields[ $p ] ) ) {
505
-							echo intval( $p++ );
506
-						}
507
-
508
-						$fields[ $p ] = $field;
509
-					}
510
-				}
511
-			}
512
-
513
-			ksort( $fields );
514
-
515
-			return $fields;
516
-		}
517
-
518
-		/**
519
-		 * Deprecated Retrieve panel section.
520
-		 *
521
-		 * @param string $opt_name Panel opt_name.
522
-		 * @param string $id       Section ID.
523
-		 *
524
-		 * @return bool
525
-		 * @deprecated No longer using camelCase naming convention.
526
-		 */
527
-		public static function getSection( string $opt_name = '', string $id = '' ): bool { // phpcs:ignore WordPress.NamingConventions.ValidFunctionName
528
-			_deprecated_function( __CLASS__ . '::' . __FUNCTION__, 'Redux 4.3', 'Redux::get_section( $opt_name, $id )' );
529
-
530
-			return self::get_section( $opt_name, $id );
531
-		}
532
-
533
-		/**
534
-		 * Retrieve panel section.
535
-		 *
536
-		 * @param string     $opt_name Panel opt_name.
537
-		 * @param string|int $id       Section ID.
538
-		 *
539
-		 * @return bool|string|int
540
-		 */
541
-		public static function get_section( string $opt_name = '', $id = '' ) {
542
-			self::check_opt_name( $opt_name );
543
-
544
-			if ( ! empty( $opt_name ) && ! empty( $id ) ) {
545
-				if ( ! isset( self::$sections[ $opt_name ][ $id ] ) ) {
546
-					$id = Redux_Core::strtolower( sanitize_html_class( $id ) );
547
-				}
548
-
549
-				return self::$sections[ $opt_name ][ $id ] ?? false;
550
-			}
551
-
552
-			return false;
553
-		}
554
-
555
-		/**
556
-		 * Deprecated Create a section of the option panel.
557
-		 *
558
-		 * @param string $opt_name Panel opt_name.
559
-		 * @param array  $sections Section ID.
560
-		 *
561
-		 * @deprecated No longer using camelCase naming convention.
562
-		 */
563
-		public static function setSections( string $opt_name = '', array $sections = array() ) { // phpcs:ignore WordPress.NamingConventions.ValidFunctionName
564
-			_deprecated_function( __CLASS__ . '::' . __FUNCTION__, 'Redux 4.3', 'Redux::set_sections( $opt_name, $sections )' );
565
-
566
-			if ( '' !== $opt_name ) {
567
-				Redux_Functions_Ex::record_caller( $opt_name );
568
-			}
569
-
570
-			self::set_sections( $opt_name, $sections );
571
-		}
572
-
573
-		/**
574
-		 * Create multiple sections of the option panel.
575
-		 *
576
-		 * @param string $opt_name Panel opt_name.
577
-		 * @param array  $sections Section ID.
578
-		 */
579
-		public static function set_sections( string $opt_name = '', array $sections = array() ) {
580
-			if ( empty( $sections ) || '' === $opt_name ) {
581
-				return;
582
-			}
583
-
584
-			self::check_opt_name( $opt_name );
585
-
586
-			Redux_Functions_Ex::record_caller( $opt_name );
587
-
588
-			foreach ( $sections as $section ) {
589
-				self::set_section( $opt_name, $section );
590
-			}
591
-		}
592
-
593
-		/**
594
-		 * Deprecated Retrieve all sections from the option panel.
595
-		 *
596
-		 * @param string $opt_name Panel opt_name.
597
-		 *
598
-		 * @return array|mixed
599
-		 * @deprecated No longer using camelCase naming convention.
600
-		 */
601
-		public static function getSections( string $opt_name = '' ) { // phpcs:ignore WordPress.NamingConventions.ValidFunctionName
602
-			_deprecated_function( __CLASS__ . '::' . __FUNCTION__, 'Redux 4.3', 'Redux::get_sections( $opt_name )' );
603
-
604
-			return self::get_sections( $opt_name );
605
-		}
606
-
607
-		/**
608
-		 * Retrieve all sections from the option panel.
609
-		 *
610
-		 * @param string $opt_name Panel opt_name.
611
-		 *
612
-		 * @return array|mixed
613
-		 */
614
-		public static function get_sections( string $opt_name = '' ) {
615
-			self::check_opt_name( $opt_name );
616
-
617
-			if ( ! empty( self::$sections[ $opt_name ] ) ) {
618
-				return self::$sections[ $opt_name ];
619
-			}
620
-
621
-			return array();
622
-		}
623
-
624
-		/**
625
-		 * Deprecated Remove option panel by ID.
626
-		 *
627
-		 * @param string     $opt_name Panel opt_name.
628
-		 * @param string|int $id       Section ID.
629
-		 * @param bool       $fields   Remove fields.
630
-		 *
631
-		 * @deprecated No longer using camelCase naming convention.
632
-		 */
633
-		public static function removeSection( string $opt_name = '', $id = '', bool $fields = false ) { // phpcs:ignore WordPress.NamingConventions.ValidFunctionName
634
-			_deprecated_function( __CLASS__ . '::' . __FUNCTION__, 'Redux 4.3', 'Redux::remove_section( $opt_name, $id )' );
635
-
636
-			if ( '' !== $opt_name ) {
637
-				Redux_Functions_Ex::record_caller( $opt_name );
638
-			}
639
-
640
-			self::remove_section( $opt_name, $id, $fields );
641
-		}
642
-
643
-		/**
644
-		 * Remove an option panel by ID.
645
-		 *
646
-		 * @param string     $opt_name Panel opt_name.
647
-		 * @param string|int $id       Section ID.
648
-		 * @param bool       $fields   Remove fields.
649
-		 */
650
-		public static function remove_section( string $opt_name = '', $id = '', bool $fields = false ) {
651
-			if ( '' !== $opt_name && '' !== $id ) {
652
-				Redux_Functions_Ex::record_caller( $opt_name );
653
-
654
-				if ( isset( self::$sections[ $opt_name ][ $id ] ) ) {
655
-					$priority = '';
656
-
657
-					foreach ( self::$sections[ $opt_name ] as $key => $section ) {
658
-						if ( $key === $id ) {
659
-							$priority = $section['priority'];
660
-							--self::$priority[ $opt_name ]['sections'];
661
-							unset( self::$sections[ $opt_name ][ $id ] );
662
-							continue;
663
-						}
664
-						if ( '' !== $priority ) {
665
-							$new_priority                        = $section['priority'];
666
-							$section['priority']                 = $priority;
667
-							self::$sections[ $opt_name ][ $key ] = $section;
668
-							$priority                            = $new_priority;
669
-						}
670
-					}
671
-
672
-					if ( isset( self::$fields[ $opt_name ] ) && ! empty( self::$fields[ $opt_name ] ) && true === $fields ) {
673
-						foreach ( self::$fields[ $opt_name ] as $key => $field ) {
674
-							if ( $field['section_id'] === $id ) {
675
-								unset( self::$fields[ $opt_name ][ $key ] );
676
-							}
677
-						}
678
-					}
679
-				}
680
-			}
681
-		}
682
-
683
-		/**
684
-		 * Deprecated Sets a single option panel section.
685
-		 *
686
-		 * @param string     $opt_name Panel opt_name.
687
-		 * @param array|null $section  Section data.
688
-		 *
689
-		 * @deprecated No longer using camelCase naming convention.
690
-		 */
691
-		public static function setSection( string $opt_name = '', ?array $section = array() ) { // phpcs:ignore WordPress.NamingConventions.ValidFunctionName
692
-			// phpcs:ignore Squiz.PHP.CommentedOutCode.Found
693
-			// _deprecated_function( __CLASS__ . '::' . __FUNCTION__, 'Redux 4.3', 'Redux::set_section( $opt_name, $section )' );
694
-
695
-			if ( '' !== $opt_name ) {
696
-				Redux_Functions_Ex::record_caller( $opt_name );
697
-			}
698
-
699
-			self::set_section( $opt_name, $section );
700
-		}
701
-
702
-		/**
703
-		 * Sets a single option panel section.
704
-		 *
705
-		 * @param string     $opt_name Panel opt_name.
706
-		 * @param array|null $section  Section data.
707
-		 * @param bool       $replace  Replaces a section instead of creating a new one.
708
-		 */
709
-		public static function set_section( string $opt_name = '', ?array $section = array(), bool $replace = false ) {
710
-
711
-			if ( empty( $section ) || '' === $opt_name ) {
712
-				return;
713
-			}
714
-
715
-			self::check_opt_name( $opt_name );
716
-
717
-			Redux_Functions_Ex::record_caller( $opt_name );
718
-
719
-			if ( ! isset( $section['id'] ) ) {
720
-				if ( isset( $section['type'] ) && 'divide' === $section['type'] ) {
721
-					$section['id'] = time();
722
-				} elseif ( isset( $section['title'] ) ) {
723
-						$section['id'] = Redux_Core::strtolower( sanitize_title( $section['title'] ) );
724
-				} else {
725
-					$section['id'] = time();
726
-				}
727
-
728
-				if ( isset( self::$sections[ $opt_name ][ $section['id'] ] ) && ! $replace ) {
729
-					$orig = $section['id'];
730
-					$i    = 0;
731
-
732
-					while ( isset( self::$sections[ $opt_name ][ $section['id'] ] ) ) {
733
-						$section['id'] = $orig . '_' . $i;
734
-						++$i;
735
-					}
736
-				} elseif ( isset( self::$sections[ $opt_name ][ $section['id'] ] ) && $replace ) {
737
-					// If replace is set, let's update the default values with these!
738
-					$fields = false;
739
-					if ( isset( self::$sections[ $opt_name ][ $section['id'] ]['fields'] ) && ! empty( self::$sections[ $opt_name ][ $section['id'] ]['fields'] ) ) {
740
-						$fields = self::$sections[ $opt_name ][ $section['id'] ]['fields'];
741
-					}
742
-					self::$sections[ $opt_name ][ $section['id'] ] = wp_parse_args( $section, self::$sections[ $opt_name ][ $section['id'] ] );
743
-					if ( ! empty( $fields ) ) {
744
-						if ( ! isset( self::$sections[ $opt_name ][ $section['id'] ]['fields'] ) || ( isset( self::$sections[ $opt_name ][ $section['id'] ]['fields'] ) && empty( self::$sections[ $opt_name ][ $section['id'] ]['fields'] ) ) ) {
745
-							self::$sections[ $opt_name ][ $section['id'] ]['fields'] = $fields;
746
-						}
747
-					}
748
-				}
749
-			}
750
-
751
-			if ( ! empty( $opt_name ) && is_array( $section ) && ! empty( $section ) ) {
752
-				if ( ! isset( $section['id'] ) && ! isset( $section['title'] ) ) {
753
-					self::$errors[ $opt_name ]['section']['missing_title'] = esc_html__( 'Unable to create a section due to missing id and title.', 'redux-framework' );
754
-
755
-					return;
756
-				}
757
-
758
-				if ( ! isset( $section['priority'] ) ) {
759
-					$section['priority'] = self::get_priority( $opt_name, 'sections' );
760
-				}
761
-
762
-				if ( isset( $section['fields'] ) ) {
763
-					if ( ! empty( $section['fields'] ) && is_array( $section['fields'] ) ) {
764
-						self::process_field_array( $opt_name, $section['id'], $section['fields'] );
765
-					}
766
-					unset( $section['fields'] );
767
-				}
768
-				self::$sections[ $opt_name ][ $section['id'] ] = $section;
769
-			} else {
770
-				self::$errors[ $opt_name ]['section']['empty'] = esc_html__( 'Unable to create a section due an empty section array or the section variable passed was not an array.', 'redux-framework' );
771
-			}
772
-		}
773
-
774
-		/**
775
-		 * Deprecated Hides an option panel section.
776
-		 *
777
-		 * @param string     $opt_name Panel opt_name.
778
-		 * @param string|int $id       Section ID.
779
-		 * @param bool       $hide     Flag to hide/show.
780
-		 *
781
-		 * @deprecated No longer using camelCase naming convention.
782
-		 */
783
-		public static function hideSection( string $opt_name = '', $id = '', bool $hide = true ) { // phpcs:ignore WordPress.NamingConventions.ValidFunctionName
784
-			_deprecated_function( __CLASS__ . '::' . __FUNCTION__, 'Redux 4.3', 'Redux::hide_section( $opt_name, $id )' );
785
-
786
-			if ( '' !== $opt_name ) {
787
-				Redux_Functions_Ex::record_caller( $opt_name );
788
-			}
789
-
790
-			self::hide_section( $opt_name, $id, $hide );
791
-		}
792
-
793
-		/**
794
-		 * Hides an option panel section.
795
-		 *
796
-		 * @param string     $opt_name Panel opt_name.
797
-		 * @param string|int $id       Section ID.
798
-		 * @param bool       $hide     Flag to hide/show.
799
-		 */
800
-		public static function hide_section( string $opt_name = '', $id = '', bool $hide = true ) {
801
-			self::check_opt_name( $opt_name );
802
-
803
-			if ( '' !== $opt_name && '' !== $id ) {
804
-				Redux_Functions_Ex::record_caller( $opt_name );
805
-
806
-				if ( isset( self::$sections[ $opt_name ][ $id ] ) ) {
807
-					self::$sections[ $opt_name ][ $id ]['hidden'] = $hide;
808
-				}
809
-			}
810
-		}
811
-
812
-		/**
813
-		 * Compiles field array data.
814
-		 *
815
-		 * @param string     $opt_name   Panel opt_name.
816
-		 * @param string|int $section_id Section ID.
817
-		 * @param array      $fields     Field data.
818
-		 */
819
-		private static function process_field_array( string $opt_name = '', $section_id = '', array $fields = array() ) {
820
-			if ( ! empty( $opt_name ) && ! empty( $section_id ) && is_array( $fields ) && ! empty( $fields ) ) {
821
-				foreach ( $fields as $field ) {
822
-					if ( ! is_array( $field ) ) {
823
-						continue;
824
-					}
825
-					self::set_field( $opt_name, $section_id, $field );
826
-				}
827
-			}
828
-		}
829
-
830
-		/**
831
-		 * Deprecated Retrieves an option panel field.
832
-		 *
833
-		 * @param string     $opt_name Panel opt_name.
834
-		 * @param string|int $id       Field ID.
835
-		 *
836
-		 * @return int|bool
837
-		 * @deprecated No longer using camelCase naming convention.
838
-		 */
839
-		public static function getField( string $opt_name = '', $id = '' ) { // phpcs:ignore WordPress.NamingConventions.ValidFunctionName
840
-			_deprecated_function( __CLASS__ . '::' . __FUNCTION__, 'Redux 4.3', 'Redux::get_field( $opt_name, $id )' );
841
-
842
-			return self::get_field( $opt_name, $id );
843
-		}
844
-
845
-		/**
846
-		 * Retrieves an option panel field.
847
-		 *
848
-		 * @param string     $opt_name Panel opt_name.
849
-		 * @param string|int $id       Field ID.
850
-		 *
851
-		 * @return int|bool
852
-		 */
853
-		public static function get_field( string $opt_name = '', $id = '' ) {
854
-			self::check_opt_name( $opt_name );
855
-
856
-			if ( ! empty( $opt_name ) && ! empty( $id ) ) {
857
-				return self::$fields[ $opt_name ][ $id ] ?? false;
858
-			}
859
-
860
-			return false;
861
-		}
862
-
863
-		/**
864
-		 * Deprecated Hides an option panel field.
865
-		 *
866
-		 * @param string     $opt_name Panel opt_name.
867
-		 * @param string|int $id       Field ID.
868
-		 * @param bool       $hide     Set hide/show.
869
-		 *
870
-		 * @deprecated No longer using camelCase naming convention.
871
-		 */
872
-		public static function hideField( string $opt_name = '', $id = '', bool $hide = true ) { // phpcs:ignore WordPress.NamingConventions.ValidFunctionName
873
-			_deprecated_function( __CLASS__ . '::' . __FUNCTION__, 'Redux 4.3', 'Redux::hide_field( $opt_name, $id )' );
874
-
875
-			if ( '' !== $opt_name ) {
876
-				Redux_Functions_Ex::record_caller( $opt_name );
877
-			}
878
-
879
-			self::hide_field( $opt_name, $id, $hide );
880
-		}
881
-
882
-		/**
883
-		 * Hides an option panel field.
884
-		 *
885
-		 * @param string     $opt_name Panel opt_name.
886
-		 * @param string|int $id       Field ID.
887
-		 * @param bool       $hide     Set hide/show.
888
-		 */
889
-		public static function hide_field( string $opt_name = '', $id = '', bool $hide = true ) {
890
-			self::check_opt_name( $opt_name );
891
-
892
-			if ( '' !== $opt_name && '' !== $id ) {
893
-				if ( isset( self::$fields[ $opt_name ][ $id ] ) ) {
894
-					Redux_Functions_Ex::record_caller( $opt_name );
895
-
896
-					if ( ! $hide ) {
897
-						self::$fields[ $opt_name ][ $id ]['class'] = str_replace( 'hidden', '', self::$fields[ $opt_name ][ $id ]['class'] );
898
-					} else {
899
-						self::$fields[ $opt_name ][ $id ]['class'] .= 'hidden';
900
-					}
901
-				}
902
-			}
903
-		}
904
-
905
-		/**
906
-		 * Deprecated Creates an option panel field.
907
-		 *
908
-		 * @param string     $opt_name   Panel opt_name.
909
-		 * @param string|int $section_id Section ID this field belongs to.
910
-		 * @param array      $field      Field data.
911
-		 *
912
-		 * @deprecated No longer using camelCase naming convention.
913
-		 */
914
-		public static function setField( string $opt_name = '', $section_id = '', array $field = array() ) { // phpcs:ignore WordPress.NamingConventions.ValidFunctionName
915
-			_deprecated_function( __CLASS__ . '::' . __FUNCTION__, 'Redux 4.3', 'Redux::set_field( $opt_name, $section_id, $field )' );
916
-
917
-			if ( '' !== $opt_name ) {
918
-				Redux_Functions_Ex::record_caller( $opt_name );
919
-			}
920
-
921
-			self::set_field( $opt_name, $section_id, $field );
922
-		}
923
-
924
-		/**
925
-		 * Creates an option panel field and adds to a section.
926
-		 *
927
-		 * @param string     $opt_name   Panel opt_name.
928
-		 * @param string|int $section_id Section ID this field belongs to.
929
-		 * @param array      $field      Field data.
930
-		 */
931
-		public static function set_field( string $opt_name = '', $section_id = '', array $field = array() ) {
932
-
933
-			if ( ! is_array( $field ) || empty( $field ) || '' === $opt_name || '' === $section_id ) {
934
-				return;
935
-			}
936
-
937
-			self::check_opt_name( $opt_name );
938
-
939
-			Redux_Functions_Ex::record_caller( $opt_name );
940
-
941
-			// Shim for the old method!
942
-			if ( is_array( $section_id ) ) {
943
-				$field = $section_id;
944
-				if ( isset( $field['section_id'] ) ) {
945
-					$section_id = $field['section_id'];
946
-				}
947
-			}
948
-
949
-			$field['section_id'] = $section_id;
950
-
951
-			if ( ! isset( $field['priority'] ) ) {
952
-				$field['priority'] = self::get_priority( $opt_name, 'fields' );
953
-			}
954
-			$field['id'] = $field['id'] ?? "{$opt_name}_{$section_id}_{$field['type']}_" . wp_rand( 1, 9999 );
955
-
956
-			self::$fields[ $opt_name ][ $field['id'] ] = $field;
957
-		}
958
-
959
-		/**
960
-		 * Create multiple fields of the option panel and apply to a section.
961
-		 *
962
-		 * @param string     $opt_name   Panel opt_name.
963
-		 * @param int|string $section_id Section ID this field belongs to.
964
-		 * @param array      $fields     Array of field arrays.
965
-		 */
966
-		public static function set_fields( string $opt_name = '', $section_id = '', array $fields = array() ) {
967
-			if ( ! is_array( $fields ) || empty( $fields ) || '' === $opt_name || '' === $section_id ) {
968
-				return;
969
-			}
970
-
971
-			self::check_opt_name( $opt_name );
972
-
973
-			// phpcs:ignore WordPress.PHP.DevelopmentFunctions
974
-			Redux_Functions_Ex::record_caller( $opt_name );
975
-
976
-			foreach ( $fields as $field ) {
977
-				if ( is_array( $field ) ) {
978
-					self::set_field( $opt_name, $section_id, $field );
979
-				}
980
-			}
981
-		}
982
-
983
-		/**
984
-		 * Deprecated Removes an option panel field.
985
-		 *
986
-		 * @param string     $opt_name Panel opt_name.
987
-		 * @param string|int $id       Field ID.
988
-		 *
989
-		 * @return bool
990
-		 * @deprecated No longer using camelCase naming convention.
991
-		 */
992
-		public static function removeField( string $opt_name = '', $id = '' ): bool { // phpcs:ignore WordPress.NamingConventions.ValidFunctionName
993
-			_deprecated_function( __CLASS__ . '::' . __FUNCTION__, 'Redux 4.3', 'Redux::remove_field( $opt_name, $id )' );
994
-
995
-			if ( '' !== $opt_name ) {
996
-				Redux_Functions_Ex::record_caller( $opt_name );
997
-			}
998
-
999
-			return self::remove_field( $opt_name, $id );
1000
-		}
1001
-
1002
-		/**
1003
-		 * Removes an option panel field.
1004
-		 *
1005
-		 * @param string     $opt_name Panel opt_name.
1006
-		 * @param string|int $id       Field ID.
1007
-		 *
1008
-		 * @return bool
1009
-		 */
1010
-		public static function remove_field( string $opt_name = '', $id = '' ): bool {
1011
-			if ( '' !== $opt_name && '' !== $id ) {
1012
-				self::check_opt_name( $opt_name );
1013
-
1014
-				Redux_Functions_Ex::record_caller( $opt_name );
1015
-
1016
-				if ( isset( self::$fields[ $opt_name ][ $id ] ) ) {
1017
-					foreach ( self::$fields[ $opt_name ] as $key => $field ) {
1018
-						if ( $key === $id ) {
1019
-							$priority = $field['priority'];
1020
-							--self::$priority[ $opt_name ]['fields'];
1021
-							unset( self::$fields[ $opt_name ][ $id ] );
1022
-							continue;
1023
-						}
1024
-
1025
-						if ( isset( $priority ) && '' !== $priority ) {
1026
-							$new_priority                      = $field['priority'];
1027
-							$field['priority']                 = $priority;
1028
-							self::$fields[ $opt_name ][ $key ] = $field;
1029
-							$priority                          = $new_priority;
1030
-						}
1031
-					}
1032
-				}
1033
-			}
1034
-
1035
-			return false;
1036
-		}
1037
-
1038
-		/**
1039
-		 * Deprecated Sets help tabs on option panel admin page.
1040
-		 *
1041
-		 * @param string $opt_name Panel opt_name.
1042
-		 * @param array  $tab      Tab data.
1043
-		 *
1044
-		 * @deprecated No longer using camelCase naming convention.
1045
-		 */
1046
-		public static function setHelpTab( string $opt_name = '', array $tab = array() ) { // phpcs:ignore WordPress.NamingConventions.ValidFunctionName
1047
-			_deprecated_function( __CLASS__ . '::' . __FUNCTION__, 'Redux 4.3', 'Redux::set_help_tab( $opt_name, $tab )' );
1048
-
1049
-			self::set_help_tab( $opt_name, $tab );
1050
-		}
1051
-
1052
-		/**
1053
-		 * Sets help tabs on option panel admin page.
1054
-		 *
1055
-		 * @param string $opt_name Panel opt_name.
1056
-		 * @param array  $tab      Tab data.
1057
-		 */
1058
-		public static function set_help_tab( string $opt_name = '', array $tab = array() ) {
1059
-			if ( ! is_array( $tab ) && empty( $tab ) ) {
1060
-				return;
1061
-			}
1062
-
1063
-			self::check_opt_name( $opt_name );
1064
-
1065
-			if ( '' !== $opt_name ) {
1066
-				if ( ! isset( self::$args[ $opt_name ]['help_tabs'] ) ) {
1067
-					self::$args[ $opt_name ]['help_tabs'] = array();
1068
-				}
1069
-
1070
-				if ( isset( $tab['id'] ) ) {
1071
-					self::$args[ $opt_name ]['help_tabs'][] = $tab;
1072
-				} elseif ( is_array( end( $tab ) ) ) {
1073
-					foreach ( $tab as $tab_item ) {
1074
-						self::$args[ $opt_name ]['help_tabs'][] = $tab_item;
1075
-					}
1076
-				}
1077
-			}
1078
-		}
1079
-
1080
-		/**
1081
-		 * Deprecated Sets the help sidebar content.
1082
-		 *
1083
-		 * @param string $opt_name Panel opt_name.
1084
-		 * @param string $content  Content.
1085
-		 *
1086
-		 * @deprecated No longer using camelCase naming convention.
1087
-		 */
1088
-		public static function setHelpSidebar( string $opt_name = '', string $content = '' ) { // phpcs:ignore WordPress.NamingConventions.ValidFunctionName
1089
-			_deprecated_function( __CLASS__ . '::' . __FUNCTION__, 'Redux 4.3', 'Redux::set_help_sidebar( $opt_name, $content )' );
1090
-
1091
-			self::set_help_sidebar( $opt_name, $content );
1092
-		}
1093
-
1094
-		/**
1095
-		 * Sets the help sidebar content.
1096
-		 *
1097
-		 * @param string $opt_name Panel opt_name.
1098
-		 * @param string $content  Content.
1099
-		 */
1100
-		public static function set_help_sidebar( string $opt_name = '', string $content = '' ) {
1101
-			if ( '' === $content || '' === $opt_name ) {
1102
-				return;
1103
-			}
1104
-			self::check_opt_name( $opt_name );
1105
-
1106
-			self::$args[ $opt_name ]['help_sidebar'] = $content;
1107
-		}
1108
-
1109
-		/**
1110
-		 * Deprecated Sets option panel global arguments.
1111
-		 *
1112
-		 * @param string $opt_name Panel opt_name.
1113
-		 * @param array  $args     Argument data.
1114
-		 *
1115
-		 * @deprecated No longer using camelCase naming convention.
1116
-		 */
1117
-		public static function setArgs( string $opt_name = '', array $args = array() ) { // phpcs:ignore WordPress.NamingConventions.ValidFunctionName
1118
-			// phpcs:ignore Squiz.PHP.CommentedOutCode.Found
1119
-			// _deprecated_function( __CLASS__ . '::' . __FUNCTION__, 'Redux 4.3', 'Redux::set_args( $opt_name, $args )' );
1120
-
1121
-			if ( '' !== $opt_name ) {
1122
-				Redux_Functions_Ex::record_caller( $opt_name );
1123
-			}
1124
-
1125
-			self::set_args( $opt_name, $args );
1126
-		}
1127
-
1128
-		/**
1129
-		 * Sets option panel global arguments.
1130
-		 *
1131
-		 * @param string $opt_name Panel opt_name.
1132
-		 * @param array  $args     Argument data.
1133
-		 */
1134
-		public static function set_args( string $opt_name = '', array $args = array() ) {
1135
-			if ( empty( $args ) || '' === $opt_name ) {
1136
-				return;
1137
-			}
1138
-
1139
-			self::check_opt_name( $opt_name );
1140
-
1141
-			Redux_Functions_Ex::record_caller( $opt_name );
1142
-
1143
-			if ( is_array( $args ) ) {
1144
-				if ( isset( self::$args[ $opt_name ]['clearArgs'] ) ) {
1145
-					self::$args[ $opt_name ] = array();
1146
-				}
1147
-				self::$args[ $opt_name ] = wp_parse_args( $args, self::$args[ $opt_name ] );
1148
-			}
1149
-		}
1150
-
1151
-		/**
1152
-		 * Set's developer key for premium services.
1153
-		 *
1154
-		 * @param string       $opt_name Panel opt_name.
1155
-		 * @param string|array $arg      Args data.
1156
-		 */
1157
-		public static function set_developer( string $opt_name = '', $arg = '' ) {
1158
-			if ( empty( $arg ) || '' === $opt_name ) {
1159
-				return;
1160
-			}
1161
-
1162
-			self::check_opt_name( $opt_name );
1163
-
1164
-			Redux_Functions_Ex::record_caller( $opt_name );
1165
-
1166
-			self::$args[ $opt_name ]['developer'] = $arg;
1167
-		}
1168
-
1169
-		/**
1170
-		 * Deprecated Retries option panel global argument array.
1171
-		 *
1172
-		 * @param string $opt_name Panel opt_name.
1173
-		 *
1174
-		 * @return mixed
1175
-		 * @deprecated No longer camelCase naming convention.
1176
-		 */
1177
-		public static function getArgs( string $opt_name = '' ) { // phpcs:ignore WordPress.NamingConventions.ValidFunctionName
1178
-			_deprecated_function( __CLASS__ . '::' . __FUNCTION__, 'Redux 4.3', 'Redux::get_args( $opt_name )' );
1179
-
1180
-			return self::get_args( $opt_name );
1181
-		}
1182
-
1183
-		/**
1184
-		 * Retries option panel global argument array.
1185
-		 *
1186
-		 * @param string $opt_name Panel opt_name.
1187
-		 * @param string $key      Argument key name to be returned.
1188
-		 *
1189
-		 * @return mixed|null|array
1190
-		 */
1191
-		public static function get_args( string $opt_name = '', string $key = '' ) {
1192
-			self::check_opt_name( $opt_name );
1193
-
1194
-			if ( ! empty( $opt_name ) && ! empty( $key ) ) {
1195
-				if ( ! empty( self::$args[ $opt_name ] ) ) {
1196
-					return self::$args[ $opt_name ][ $key ];
1197
-				} else {
1198
-					return null;
1199
-				}
1200
-			} elseif ( ! empty( $opt_name ) && ! empty( self::$args[ $opt_name ] ) ) {
1201
-				return self::$args[ $opt_name ];
1202
-			}
1203
-
1204
-			return null;
1205
-		}
1206
-
1207
-		/**
1208
-		 * Deprecated Retrieves a single global argument.
1209
-		 *
1210
-		 * @param string $opt_name Panel opt_name.
1211
-		 * @param string $key      Argument name.
1212
-		 *
1213
-		 * @return mixed
1214
-		 * @deprecated No longer using camelCase naming convention and using singular function self::get_args() now.
1215
-		 */
1216
-		public static function getArg( string $opt_name = '', string $key = '' ) { // phpcs:ignore WordPress.NamingConventions.ValidFunctionName
1217
-			_deprecated_function( __CLASS__ . '::' . __FUNCTION__, 'Redux 4.3', 'Redux::get_arg( $opt_name, $key )' );
1218
-
1219
-			return self::get_args( $opt_name, $key );
1220
-		}
1221
-
1222
-		/**
1223
-		 * Retrieves a single global argument.
1224
-		 *
1225
-		 * @param string $opt_name Panel opt_name.
1226
-		 * @param string $key      Argument name.
1227
-		 *
1228
-		 * @return mixed|array|null
1229
-		 */
1230
-		public static function get_arg( string $opt_name = '', string $key = '' ) {
1231
-			self::check_opt_name( $opt_name );
1232
-
1233
-			if ( ! empty( $opt_name ) && ! empty( $key ) && ! empty( self::$args[ $opt_name ] ) ) {
1234
-				return self::$args[ $opt_name ][ $key ];
1235
-			} else {
1236
-				return null;
1237
-			}
1238
-		}
1239
-
1240
-		/**
1241
-		 * Deprecated Retrieves a single option from the database.
1242
-		 *
1243
-		 * @param string       $opt_name Panel opt_name.
1244
-		 * @param string       $key      Option key.
1245
-		 * @param string|array $defaults  Default value.
1246
-		 *
1247
-		 * @return mixed
1248
-		 * @deprecated No longer using camelCase naming convention.
1249
-		 */
1250
-		public static function getOption( string $opt_name = '', string $key = '', $defaults = '' ) { // phpcs:ignore WordPress.NamingConventions.ValidFunctionName
1251
-			_deprecated_function( __CLASS__ . '::' . __FUNCTION__, 'Redux 4.3', 'Redux::get_option( $opt_name, $key, $default )' );
1252
-
1253
-			return self::get_option( $opt_name, $key, $defaults );
1254
-		}
1255
-
1256
-		/**
1257
-		 * Retrieves meta for a given post page, IE WordPress meta values
1258
-		 *
1259
-		 * @param string $opt_name Panel opt_name.
1260
-		 * @param mixed  $the_post Post object to denote the current post, or custom.
1261
-		 * @param string $key      Option key.
1262
-		 * @param mixed  $defaults Default value.
1263
-		 *
1264
-		 * @return mixed
1265
-		 */
1266
-		public static function get_post_meta( string $opt_name = '', $the_post = array(), string $key = '', $defaults = null ) {
1267
-			self::check_opt_name( $opt_name );
1268
-
1269
-			if ( empty( $opt_name ) ) {
1270
-				return null;
1271
-			}
1272
-
1273
-			global $post;
1274
-
1275
-			$redux = ReduxFrameworkInstances::get_instance( $opt_name );
1276
-
1277
-			$metaboxes = $redux->extensions['metaboxes'];
1278
-
1279
-			if ( null === $defaults || '' === $defaults ) {
1280
-				$defaults = self::get_option( $opt_name, $key );
1281
-			}
1282
-
1283
-			if ( isset( $the_post ) && is_array( $the_post ) ) {
1284
-				$the_post = $post;
1285
-			} elseif ( ! isset( $the_post ) || 0 === $the_post ) {
1286
-				return $defaults;
1287
-			} elseif ( is_numeric( $the_post ) ) {
1288
-				$the_post = get_post( $the_post );
1289
-			} elseif ( ! is_object( $the_post ) ) {
1290
-				$the_post = $post;
1291
-			}
1292
-
1293
-			$defaults = self::get_option( $opt_name, $key );
1294
-
1295
-			return $metaboxes->get_values( $the_post, $key, $defaults );
1296
-		}
1297
-
1298
-		/**
1299
-		 * Retrieves a single option from the database.
1300
-		 *
1301
-		 * @param string $opt_name Panel opt_name.
1302
-		 * @param string $key      Option key.
1303
-		 * @param mixed  $default  Default value.
1304
-		 *
1305
-		 * @return mixed
1306
-		 */
1307
-		public static function get_option( string $opt_name = '', string $key = '', $default = null ) { // phpcs:ignore Universal.NamingConventions
1308
-			self::check_opt_name( $opt_name );
1309
-
1310
-			if ( ! empty( $opt_name ) && ! empty( $key ) ) {
1311
-				global $$opt_name;
1312
-
1313
-				if ( empty( $$opt_name ) ) {
1314
-					$values = get_option( $opt_name );
1315
-					// phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals
1316
-					$$opt_name = $values;
1317
-				} else {
1318
-					$values = $$opt_name;
1319
-				}
1320
-
1321
-				if ( ! isset( $values[ $key ] ) ) {
1322
-					if ( null === $default ) {
1323
-						$field = self::get_field( $opt_name, $key );
1324
-
1325
-						if ( false !== $field ) {
1326
-							$defaults_class = new Redux_Options_Defaults();
1327
-							$sections       = self::construct_sections( $opt_name );
1328
-							$defaults       = $defaults_class->default_values( $opt_name, $sections );
1329
-
1330
-							if ( isset( $defaults[ $key ] ) ) {
1331
-								$default = $defaults[ $key ];
1332
-							}
1333
-						}
1334
-					}
1335
-				}
1336
-
1337
-				if ( ! empty( $subkeys ) && is_array( $subkeys ) ) {
1338
-					$value = $default;
1339
-
1340
-					if ( isset( $values[ $key ] ) ) {
1341
-						$count = count( $subkeys );
1342
-
1343
-						if ( 1 === $count ) {
1344
-							$value = $values[ $key ][ $subkeys[1] ] ?? $default;
1345
-						} elseif ( 2 === $count ) {
1346
-							if ( isset( $values[ $key ][ $subkeys[1] ] ) ) {
1347
-								$value = $values[ $key ][ $subkeys[1] ][ $subkeys[2] ] ?? $default;
1348
-							}
1349
-						} elseif ( 3 === $count ) {
1350
-							if ( isset( $values[ $key ][ $subkeys[1] ] ) ) {
1351
-								if ( isset( $values[ $key ][ $subkeys[1] ][ $subkeys[2] ] ) ) {
1352
-									$value = $values[ $key ][ $subkeys[1] ][ $subkeys[2] ][ $subkeys[3] ] ?? $default;
1353
-								}
1354
-							}
1355
-						}
1356
-					}
1357
-				} else {
1358
-					$value = $values[ $key ] ?? $default;
1359
-				}
1360
-
1361
-				return $value;
1362
-			} else {
1363
-				return false;
1364
-			}
1365
-		}
1366
-
1367
-		/**
1368
-		 * Deprecated Sets an option into the database.
1369
-		 *
1370
-		 * @param string $opt_name Panel opt_name.
1371
-		 * @param string $key      Option key.
1372
-		 * @param mixed  $option   Option value.
1373
-		 *
1374
-		 * @return bool
1375
-		 * @deprecated No longer using camelCase naming convention.
1376
-		 */
1377
-		public static function setOption( string $opt_name = '', string $key = '', $option = '' ): bool { // phpcs:ignore WordPress.NamingConventions.ValidFunctionName
1378
-			_deprecated_function( __CLASS__ . '::' . __FUNCTION__, 'Redux 4.3', 'Redux::set_option( $opt_name, $key, $option )' );
1379
-
1380
-			if ( '' !== $opt_name ) {
1381
-				Redux_Functions_Ex::record_caller( $opt_name );
1382
-			}
1383
-
1384
-			return self::set_option( $opt_name, $key, $option );
1385
-		}
1386
-
1387
-		/**
1388
-		 * Sets an option into the database.
1389
-		 *
1390
-		 * @param string $opt_name Panel opt_name.
1391
-		 * @param string $key      Option key.
1392
-		 * @param mixed  $option   Option value.
1393
-		 *
1394
-		 * @return bool
1395
-		 */
1396
-		public static function set_option( string $opt_name = '', string $key = '', $option = '' ): bool {
1397
-			if ( '' === $key ) {
1398
-				return false;
1399
-			}
1400
-
1401
-			self::check_opt_name( $opt_name );
1402
-
1403
-			Redux_Functions_Ex::record_caller( $opt_name );
1404
-
1405
-			if ( '' !== $opt_name ) {
1406
-				$redux         = get_option( $opt_name );
1407
-				$redux[ $key ] = $option;
1408
-
1409
-				return update_option( $opt_name, $redux );
1410
-			} else {
1411
-				return false;
1412
-			}
1413
-		}
1414
-
1415
-		/**
1416
-		 * Get the next available priority for field/section.
1417
-		 *
1418
-		 * @param string $opt_name Panel opt_name.
1419
-		 * @param string $type     Field or section.
1420
-		 *
1421
-		 * @return mixed
1422
-		 */
1423
-		public static function get_priority( string $opt_name, string $type ) {
1424
-			$priority                              = self::$priority[ $opt_name ][ $type ];
1425
-			self::$priority[ $opt_name ][ $type ] += 1;
1426
-
1427
-			return $priority;
1428
-		}
1429
-
1430
-		/**
1431
-		 * Check opt_name integrity.
1432
-		 *
1433
-		 * @param string $opt_name Panel opt_name.
1434
-		 */
1435
-		public static function check_opt_name( string $opt_name = '' ) {
1436
-			if ( empty( $opt_name ) || is_array( $opt_name ) ) {
1437
-				return;
1438
-			}
1439
-
1440
-			if ( ! isset( self::$sections[ $opt_name ] ) ) {
1441
-				self::$sections[ $opt_name ]             = array();
1442
-				self::$priority[ $opt_name ]['sections'] = 1;
1443
-			}
1444
-
1445
-			if ( ! isset( self::$args[ $opt_name ] ) ) {
1446
-				self::$args[ $opt_name ]             = array();
1447
-				self::$priority[ $opt_name ]['args'] = 1;
1448
-			}
1449
-
1450
-			if ( ! isset( self::$fields[ $opt_name ] ) ) {
1451
-				self::$fields[ $opt_name ]             = array();
1452
-				self::$priority[ $opt_name ]['fields'] = 1;
1453
-			}
1454
-
1455
-			if ( ! isset( self::$help[ $opt_name ] ) ) {
1456
-				self::$help[ $opt_name ]             = array();
1457
-				self::$priority[ $opt_name ]['help'] = 1;
1458
-			}
1459
-
1460
-			if ( ! isset( self::$errors[ $opt_name ] ) ) {
1461
-				self::$errors[ $opt_name ] = array();
1462
-			}
1463
-
1464
-			if ( ! isset( self::$init[ $opt_name ] ) ) {
1465
-				self::$init[ $opt_name ] = false;
1466
-			}
1467
-		}
1468
-
1469
-		/**
1470
-		 * Retrieve metadata from a file. Based on WP Core's get_file_data function
1471
-		 *
1472
-		 * @param string $file Path to the file.
1473
-		 *
1474
-		 * @return string
1475
-		 * @since 2.1.1
1476
-		 */
1477
-		public static function get_file_version( string $file ): string {
1478
-			$data = get_file_data( $file, array( 'version' ), 'plugin' );
1479
-
1480
-			return $data[0];
1481
-		}
1482
-
1483
-		/**
1484
-		 * Verify extension class name.
1485
-		 *
1486
-		 * @param string $opt_name   Panel opt_name.
1487
-		 * @param string $name       extension name.
1488
-		 * @param string $class_file Extension class file.
1489
-		 */
1490
-		private static function check_extension_class_file( string $opt_name, string $name = '', string $class_file = '' ) {
1491
-			$instance = null;
1492
-
1493
-			if ( file_exists( $class_file ) ) {
1494
-				self::$uses_extensions[ $opt_name ] = self::$uses_extensions[ $opt_name ] ?? array();
1495
-
1496
-				if ( ! in_array( $name, self::$uses_extensions[ $opt_name ], true ) ) {
1497
-					self::$uses_extensions[ $opt_name ][] = $name;
1498
-				}
1499
-
1500
-				self::$extensions[ $name ] = self::$extensions[ $name ] ?? array();
1501
-
1502
-				$version = Redux_Helpers::get_template_version( $class_file );
1503
-
1504
-				if ( empty( $version ) && ! empty( $instance ) ) {
1505
-					if ( isset( $instance->version ) ) {
1506
-						$version = $instance->version;
1507
-					}
1508
-				}
1509
-				self::$extensions[ $name ][ $version ] = self::$extensions[ $name ][ $version ] ?? $class_file;
1510
-
1511
-				$new_name  = str_replace( '_', '-', $name );
1512
-				$api_check = str_replace(
1513
-					array(
1514
-						'extension_' . $name,
1515
-						'class-redux-extension-' . $new_name,
1516
-					),
1517
-					array(
1518
-						$name . '_api',
1519
-						'class-redux-' . $new_name . '-api',
1520
-					),
1521
-					$class_file
1522
-				);
1523
-
1524
-				if ( file_exists( $api_check ) && ! class_exists( 'Redux_' . ucfirst( $name ) ) ) {
1525
-					include_once $api_check;
1526
-				}
1527
-			}
1528
-		}
1529
-
1530
-		/**
1531
-		 * Deprecated Sets all extensions in a path.
1532
-		 *
1533
-		 * @param string $opt_name Panel opt_name.
1534
-		 * @param string $path     Path to extension folder.
1535
-		 *
1536
-		 * @deprecated No longer using camelCase naming convention.
1537
-		 */
1538
-		public static function setExtensions( string $opt_name, string $path ) { // phpcs:ignore WordPress.NamingConventions.ValidFunctionName
1539
-			_deprecated_function( __CLASS__ . '::' . __FUNCTION__, 'Redux 4.3', 'Redux::get_extensions( $opt_name, $path )' );
1540
-
1541
-			if ( '' !== $opt_name ) {
1542
-				Redux_Functions_Ex::record_caller( $opt_name );
1543
-			}
1544
-
1545
-			self::set_extensions( $opt_name, $path );
1546
-		}
1547
-
1548
-		/**
1549
-		 * Sets all extensions in a path.
1550
-		 *
1551
-		 * @param string $opt_name Panel opt_name.
1552
-		 * @param string $path     Path to extension folder.
1553
-		 * @param bool   $force    Make extension reload.
1554
-		 */
1555
-		public static function set_extensions( string $opt_name, string $path, bool $force = false ) {
1556
-			if ( '' === $path || '' === $opt_name ) {
1557
-				return;
1558
-			}
1559
-
1560
-			self::check_opt_name( $opt_name );
1561
-
1562
-			Redux_Functions_Ex::record_caller( $opt_name );
1563
-
1564
-			if ( is_dir( $path ) ) {
1565
-				$path   = trailingslashit( $path );
1566
-				$folder = str_replace( '.php', '', basename( $path ) );
1567
-
1568
-				$folder_fix = str_replace( '_', '-', $folder );
1569
-
1570
-				$files = array(
1571
-					$path . 'extension_' . $folder . '.php',
1572
-					$path . 'class-redux-extension-' . $folder_fix . '.php',
1573
-				);
1574
-
1575
-				$ext_file = Redux_Functions::file_exists_ex( $files );
1576
-
1577
-				if ( $ext_file ) {
1578
-					self::check_extension_class_file( $opt_name, $folder, $ext_file );
1579
-				} else {
1580
-					$folders = scandir( $path );
1581
-
1582
-					foreach ( $folders as $folder ) {
1583
-						if ( '.' === $folder || '..' === $folder ) {
1584
-							continue;
1585
-						}
1586
-
1587
-						if ( is_dir( $path . $folder ) ) {
1588
-							self::set_extensions( $opt_name, $path . $folder );
1589
-						}
1590
-					}
1591
-				}
1592
-			} elseif ( file_exists( $path ) ) {
1593
-				$name = explode( 'extension_', basename( $path ) );
1594
-				if ( ! empty( $name[1] ) ) {
1595
-					$name = str_replace( '.php', '', $name[1] );
1596
-					self::check_extension_class_file( $opt_name, $name, $path );
1597
-				}
1598
-			}
1599
-
1600
-			self::$extension_paths[ $opt_name ] = $path;
1601
-
1602
-			if ( true === $force ) {
1603
-				if ( isset( self::$uses_extensions[ $opt_name ] ) && ! empty( self::$uses_extensions[ $opt_name ] ) ) {
1604
-					$redux = self::instance( $opt_name );
1605
-
1606
-					if ( isset( $redux ) ) {
1607
-						self::load_extensions( $redux );
1608
-					}
1609
-				}
1610
-			}
1611
-		}
1612
-
1613
-		/**
1614
-		 * Retrieves all loaded extensions.
1615
-		 */
1616
-		private static function get_all_extension() {
1617
-			$redux = self::all_instances();
1618
-
1619
-			foreach ( $redux as $instance ) {
1620
-				if ( ! empty( self::$uses_extensions[ $instance['args']['opt_name'] ] ) ) {
1621
-					continue;
1622
-				}
1623
-				if ( ! empty( $instance['extensions'] ) ) {
1624
-					self::get_instance_extension( $instance['args']['opt_name'], $instance );
1625
-				}
1626
-			}
1627
-		}
1628
-
1629
-		/**
1630
-		 * Gets all loaded extensions for the passed ReduxFramework instance.
1631
-		 *
1632
-		 * @param string      $opt_name Panel opt_name.
1633
-		 * @param object|null $instance ReduxFramework instance.
1634
-		 */
1635
-		public static function get_instance_extension( string $opt_name, $instance ) {
1636
-			if ( ! empty( self::$uses_extensions[ $opt_name ] ) || empty( $opt_name ) ) {
1637
-				return;
1638
-			}
1639
-
1640
-			if ( empty( $instance ) ) {
1641
-				$instance = self::instance( $opt_name );
1642
-			}
1643
-
1644
-			if ( empty( $instance ) || empty( $instance->extensions ) ) {
1645
-				return;
1646
-			}
1647
-
1648
-			foreach ( $instance->extensions as $name => $extension ) {
1649
-				if ( 'widget_areas' === $name ) {
1650
-					new Redux_Widget_Areas( $instance );
1651
-				}
1652
-
1653
-				if ( isset( self::$uses_extensions[ $opt_name ][ $name ] ) ) {
1654
-					continue;
1655
-				}
1656
-
1657
-				if ( isset( $extension->extension_dir ) ) {
1658
-					self::set_extensions( $opt_name, str_replace( $name, '', $extension->extension_dir ) );
1659
-				}
1660
-			}
1661
-		}
1662
-
1663
-		/**
1664
-		 * Deprecated Gets loaded extensions.
1665
-		 *
1666
-		 * @param string $opt_name Panel opt_name.
1667
-		 * @param string $key      Extension name.
1668
-		 *
1669
-		 * @return array|bool|mixed
1670
-		 * @deprecated No longer using camelCase naming convention.
1671
-		 */
1672
-		public static function getExtensions( string $opt_name = '', string $key = '' ) { // phpcs:ignore WordPress.NamingConventions.ValidFunctionName
1673
-			_deprecated_function( __CLASS__ . '::' . __FUNCTION__, 'Redux 4.0.0', 'self::get_extensions( $opt_name, $key )' );
1674
-
1675
-			return self::get_extensions( $opt_name, $key );
1676
-		}
1677
-
1678
-		/**
1679
-		 * Gets loaded extensions.
1680
-		 *
1681
-		 * @param string $opt_name Panel opt_name.
1682
-		 * @param string $key      Extension name.
1683
-		 *
1684
-		 * @return array|bool|mixed
1685
-		 */
1686
-		public static function get_extensions( string $opt_name = '', string $key = '' ) {
1687
-			if ( empty( $opt_name ) ) {
1688
-				self::get_all_extension();
1689
-
1690
-				if ( empty( $key ) ) {
1691
-					return self::$extension_paths;
1692
-				} elseif ( isset( self::$extension_paths[ $key ] ) ) {
1693
-						return self::$extension_paths[ $key ];
1694
-				}
1695
-			} else {
1696
-				if ( empty( self::$uses_extensions[ $opt_name ] ) ) {
1697
-					self::get_instance_extension( $opt_name, null );
1698
-				}
1699
-
1700
-				if ( empty( self::$uses_extensions[ $opt_name ] ) ) {
1701
-					return false;
1702
-				}
1703
-
1704
-				$instance_extensions = array();
1705
-
1706
-				foreach ( self::$uses_extensions[ $opt_name ] as $extension ) {
1707
-					$class_file = end( self::$extensions[ $extension ] );
1708
-					$directory  = explode( DIRECTORY_SEPARATOR, $class_file );
1709
-					array_pop( $directory );
1710
-					$directory       = trailingslashit( join( DIRECTORY_SEPARATOR, $directory ) );
1711
-					$name            = str_replace( '.php', '', basename( $extension ) );
1712
-					$extension_class = 'Redux_Extension_' . $name;
1713
-					$the_data        = array(
1714
-						'path'    => $class_file,
1715
-						'dir'     => $directory,
1716
-						'class'   => $extension_class,
1717
-						'version' => Redux_Helpers::get_template_version( $class_file ),
1718
-					);
1719
-
1720
-					if ( is_dir( $the_data['dir'] . $extension ) ) {
1721
-						$test_path = trailingslashit( $the_data['dir'] . $extension );
1722
-						if ( file_exists( $test_path . 'field_' . str_replace( '-', '', $extension ) . '.php' ) ) {
1723
-							$the_data['field'] = $test_path . 'field_' . str_replace( '-', '', $extension ) . '.php';
1724
-						}
1725
-						// Old extensions!
1726
-						if ( file_exists( $test_path . str_replace( '-', '', $extension ) . '.php' ) ) {
1727
-							$the_data['field'] = $test_path . str_replace( '-', '', $extension ) . '.php';
1728
-						}
1729
-					}
1730
-					$instance_extensions[ $extension ] = $the_data;
1731
-				}
1732
-
1733
-				return $instance_extensions;
1734
-			}
1735
-
1736
-			return false;
1737
-		}
1738
-
1739
-		/**
1740
-		 * Method to disables Redux demo mode popup.
1741
-		 */
1742
-		public static function disable_demo() {
1743
-			add_action( 'ReduxFrameworkPlugin_admin_notice', 'Redux::remove_demo' );
1744
-			add_action( 'redux_framework_plugin_admin_notice', 'Redux::remove_demo' );
1745
-		}
1746
-
1747
-		/**
1748
-		 * Callback used by self::disable_demo() to remove the demo mode notice from Redux.
1749
-		 */
1750
-		public static function remove_demo() {
1751
-			update_option( 'ReduxFrameworkPlugin_ACTIVATED_NOTICES', '' );
1752
-		}
1753
-
1754
-		/**
1755
-		 * Function which forces a panel/page to render.
1756
-		 *
1757
-		 * @param string|object $redux Panel opt_name or Redux object.
1758
-		 */
1759
-		public static function render( $redux = '' ) {
1760
-			if ( is_string( $redux ) ) {
1761
-				$redux = Redux_Instances::get_instance( $redux );
1762
-				if ( empty( $redux ) ) {
1763
-					return;
1764
-				}
1765
-			}
1766
-			$enqueue = new Redux_Enqueue( $redux );
1767
-			$enqueue->init();
1768
-			$panel = new Redux_Panel( $redux );
1769
-			$panel->init();
1770
-		}
1771
-	}
1772
-
1773
-	Redux::load();
19
+    /**
20
+     * Redux API Class
21
+     * Simple API for Redux Framework
22
+     *
23
+     * @since       3.0.0
24
+     */
25
+    class Redux {
26
+
27
+
28
+        /**
29
+         *  Option fields.
30
+         *
31
+         * @var array
32
+         */
33
+        public static array $fields = array();
34
+
35
+        /**
36
+         * Option sections.
37
+         *
38
+         * @var array
39
+         */
40
+        public static array $sections = array();
41
+
42
+        /**
43
+         * Option defaults.
44
+         *
45
+         * @var array
46
+         */
47
+        public static array $options_defaults = array();
48
+
49
+        /**
50
+         * Option help array.
51
+         *
52
+         * @var array
53
+         */
54
+        public static array $help = array();
55
+
56
+        /**
57
+         * Option global args.
58
+         *
59
+         * @var array
60
+         */
61
+        public static array $args = array();
62
+
63
+        /**
64
+         * Option section priorities.
65
+         *
66
+         * @var array
67
+         */
68
+        public static array $priority = array();
69
+
70
+        /**
71
+         * Panel validations errors.
72
+         *
73
+         * @var array
74
+         */
75
+        public static array $errors = array();
76
+
77
+        /**
78
+         * Init.
79
+         *
80
+         * @var array
81
+         */
82
+        public static array $init = array();
83
+
84
+        /**
85
+         * Delay Init opt_names
86
+         *
87
+         * @var array
88
+         */
89
+        public static array $delay_init = array();
90
+
91
+        /**
92
+         * Extension list.
93
+         *
94
+         * @var array
95
+         */
96
+        public static array $extensions = array();
97
+
98
+        /**
99
+         * Extensions in use.
100
+         *
101
+         * @var array
102
+         */
103
+        public static array $uses_extensions = array();
104
+
105
+        /**
106
+         * Extension paths.
107
+         *
108
+         * @var array
109
+         */
110
+        public static array $extension_paths = array();
111
+
112
+        /**
113
+         * Extension capability flag.
114
+         *
115
+         * @var boolean
116
+         */
117
+        public static bool $extension_compatibility = false;
118
+
119
+        /**
120
+         * Code to run at creation in instance.
121
+         */
122
+        public static function load() {
123
+            add_action( 'after_setup_theme', array( 'Redux', 'create_redux' ) );
124
+            add_action( 'init', array( 'Redux', 'create_redux' ) );
125
+            add_action( 'switch_theme', array( 'Redux', 'create_redux' ) );
126
+
127
+            require_once Redux_Core::$dir . 'inc/extensions/metaboxes/class-redux-metaboxes-api.php';
128
+            require_once Redux_Core::$dir . 'inc/extensions/users/class-redux-users-api.php';
129
+            require_once Redux_Core::$dir . 'inc/extensions/taxonomy/class-redux-taxonomy-api.php';
130
+        }
131
+
132
+        /**
133
+         * Delay init action function
134
+         * Delays all Redux objects from loaded before `plugins_loaded` runs.
135
+         *
136
+         * @throws ReflectionException Exception.
137
+         */
138
+        public static function delay_init() {
139
+            if ( ! empty( self::$delay_init ) ) {
140
+
141
+                foreach ( self::$delay_init as $opt_name ) {
142
+                    self::init( $opt_name );
143
+                    $parent = Redux_Instances::get_instance( $opt_name );
144
+                    // translators: This is only shown to developers, should not impact users.
145
+                    $msg = sprintf(
146
+                        '<strong>%s</strong><br /><code>%s</code> %s',
147
+                        esc_html__( 'Warning, Premature Initialization', 'redux-framework' ),
148
+                        'self::init("' . esc_html( $opt_name ) . '")',
149
+                        // translators: This is only shown to developers, should not impact users.
150
+                        sprintf( esc_html__( 'was run before the %s hook and was delayed to avoid errors.', 'redux-framework' ), '<code>plugins_loaded</code>' )
151
+                    );
152
+
153
+                    if ( isset( $parent->args ) ) {
154
+                        $data = array(
155
+                            'parent'  => $parent,
156
+                            'type'    => 'error',
157
+                            'msg'     => $msg,
158
+                            'id'      => 'redux_init',
159
+                            'dismiss' => true,
160
+                        );
161
+
162
+                        Redux_Admin_Notices::set_notice( $data );
163
+                    }
164
+                }
165
+            }
166
+        }
167
+
168
+        /**
169
+         * Init Redux object
170
+         *
171
+         * @param string $opt_name Panel opt_name.
172
+         *
173
+         * @throws ReflectionException  Exception.
174
+         */
175
+        public static function init( string $opt_name = '' ) {
176
+            if ( ! empty( $opt_name ) ) {
177
+                if ( ! did_action( 'plugins_loaded' ) ) {
178
+
179
+                    // We don't want to load before plugins_loaded EVER.
180
+                    self::$delay_init[] = $opt_name;
181
+                    add_action( 'plugins_loaded', array( 'Redux', 'delay_init' ) );
182
+                } else {
183
+
184
+                    // The hook `plugins_loaded` has run, let's get going!
185
+                    self::load_redux( $opt_name );
186
+
187
+                    remove_action( 'setup_theme', array( 'Redux', 'create_redux' ) );
188
+                }
189
+            }
190
+        }
191
+
192
+        /**
193
+         * Retrieve ReduxFramework object.
194
+         *
195
+         * @param string $opt_name Panel opt_name.
196
+         *
197
+         * @return object|ReduxFramework
198
+         */
199
+        public static function instance( string $opt_name ) {
200
+            return Redux_Instances::get_instance( $opt_name );
201
+        }
202
+
203
+        /**
204
+         * Retrieve all ReduxFramework Instances.
205
+         *
206
+         * @return null|array|ReduxFramework[]
207
+         */
208
+        public static function all_instances(): ?array {
209
+            return Redux_Instances::get_all_instances();
210
+        }
211
+
212
+        /**
213
+         * Load external extensions.
214
+         *
215
+         * @param object $redux_framework ReduxFramework object.
216
+         *
217
+         * @deprecated No longer using camelCase naming conventions.
218
+         */
219
+        public static function loadExtensions( $redux_framework ) { // phpcs:ignore WordPress.NamingConventions.ValidFunctionName
220
+            _deprecated_function( __CLASS__ . '::' . __FUNCTION__, ' Redux 4.3', 'Redux::load_extensions( $redux_framework )' );
221
+
222
+            self::load_extensions( $redux_framework );
223
+        }
224
+
225
+        /**
226
+         * Load external extensions.
227
+         *
228
+         * @param object $redux_framework ReduxFramework object.
229
+         */
230
+        public static function load_extensions( $redux_framework ) {
231
+            $instance_extensions = self::get_extensions( $redux_framework->args['opt_name'] );
232
+
233
+            if ( $instance_extensions ) {
234
+                foreach ( $instance_extensions as $name => $extension ) {
235
+                    $old_class = str_replace( 'Redux_', 'ReduxFramework_', $extension['class'] );
236
+
237
+                    if ( ! class_exists( $extension['class'] ) && ! class_exists( $old_class ) ) {
238
+                        // In case you wanted to override your override, hah.
239
+                        // Phpcs:ignore WordPress.NamingConventions.ValidHookName
240
+                        $extension['path'] = apply_filters( 'redux/extension/' . $redux_framework->args['opt_name'] . '/' . $name, $extension['path'] );
241
+                        if ( file_exists( $extension['path'] ) ) {
242
+                            require_once $extension['path'];
243
+                        }
244
+                    }
245
+                    if ( isset( $extension['field'] ) ) {
246
+                        require_once $extension['field'];
247
+                    }
248
+
249
+                    if ( ! isset( $redux_framework->extensions[ $name ] ) ) {
250
+                        $field_classes = array( $extension['class'], $old_class );
251
+                        $ext_class     = Redux_Functions::class_exists_ex( $field_classes );
252
+                        if ( false !== $ext_class ) {
253
+                            $redux_framework->extensions[ $name ] = new $ext_class( $redux_framework );
254
+                        } elseif ( is_admin() && true === $redux_framework->args['dev_mode'] ) {
255
+                            echo '<div id="message" class="error"><p>No class named <strong>' . esc_html( $extension['class'] ) . '</strong> exists. Please verify your extension path.</p></div>';
256
+                        }
257
+                    }
258
+                }
259
+            }
260
+        }
261
+
262
+        /**
263
+         * Deprecated function to set an extension path.
264
+         *
265
+         * @param string $extension Path.
266
+         * @param bool   $folder    Set if a path is a folder.
267
+         *
268
+         * @return bool|mixed
269
+         * @deprecated No longer using cameCase naming conventions.
270
+         */
271
+        public static function extensionPath( string $extension, bool $folder = true ) { // phpcs:ignore WordPress.NamingConventions.ValidFunctionName
272
+            _deprecated_function( __CLASS__ . '::' . __FUNCTION__, 'Redux 4.3', 'Redux::extension_path( $extension, $folder )' );
273
+
274
+            return self::extension_path( $extension, $folder );
275
+        }
276
+
277
+        /**
278
+         * Sets a path to an extension.
279
+         *
280
+         * @param string $extension Path to an extension.
281
+         * @param bool   $folder    Set if a path is a folder.
282
+         *
283
+         * @return bool|mixed
284
+         */
285
+        public static function extension_path( string $extension, bool $folder = true ) {
286
+            if ( ! isset( self::$extensions[ $extension ] ) ) {
287
+                return false;
288
+            }
289
+
290
+            $path = end( self::$extensions[ $extension ] );
291
+
292
+            if ( ! $folder ) {
293
+                return $path;
294
+            }
295
+
296
+            return dirname( $path );
297
+        }
298
+
299
+        /**
300
+         * Deprecated function of Load Redux Framework.
301
+         *
302
+         * @param string $opt_name Panel opt_name.
303
+         *
304
+         * @throws ReflectionException Exception.
305
+         *
306
+         * @deprecated No longer using camelCase naming conventions.
307
+         */
308
+        public static function loadRedux( string $opt_name = '' ) { // phpcs:ignore WordPress.NamingConventions.ValidFunctionName
309
+            _deprecated_function( __CLASS__ . '::' . __FUNCTION__, 'Redux 4.3', 'Redux::load_redux( $opt_name )' );
310
+
311
+            self::load_redux( $opt_name );
312
+        }
313
+
314
+        /**
315
+         * Load defaults values for a given opt_name.
316
+         *
317
+         * @param string $opt_name Panel opt_name.
318
+         */
319
+        public static function set_defaults( string $opt_name = '' ) {
320
+            // Try to load the class if in the same directory, so the user only has to include the Redux API.
321
+            if ( ! class_exists( 'Redux_Options_Defaults' ) ) {
322
+                $file_check = trailingslashit( __DIR__ ) . 'class-redux-options-defaults.php';
323
+
324
+                if ( file_exists( dirname( $file_check ) ) ) {
325
+                    include_once $file_check;
326
+                    $file_check = trailingslashit( __DIR__ ) . 'class-redux-wordpress-data.php';
327
+                    if ( file_exists( dirname( $file_check ) ) ) {
328
+                        include_once $file_check;
329
+                    }
330
+                }
331
+            }
332
+
333
+            if ( class_exists( 'Redux_Options_Defaults' ) && ! isset( self::$options_defaults[ $opt_name ] ) ) {
334
+                $sections                            = self::construct_sections( $opt_name );
335
+                $wordpress_data                      = ( ! class_exists( 'Redux_WordPress_Data' ) ) ? null : new Redux_WordPress_Data( $opt_name );
336
+                $options_defaults_class              = new Redux_Options_Defaults();
337
+                self::$options_defaults[ $opt_name ] = $options_defaults_class->default_values( $opt_name, $sections, $wordpress_data );
338
+                if ( ! isset( self::$args[ $opt_name ]['global_variable'] ) || ( '' === self::$args[ $opt_name ]['global_variable'] && false !== self::$args[ $opt_name ]['global_variable'] ) ) {
339
+                    self::$args[ $opt_name ]['global_variable'] = str_replace( '-', '_', $opt_name );
340
+                }
341
+                if ( isset( self::$args[ $opt_name ]['global_variable'] ) && self::$args[ $opt_name ]['global_variable'] ) {
342
+                    $option_global = self::$args[ $opt_name ]['global_variable'];
343
+
344
+                    /**
345
+                     * Filter 'redux/options/{opt_name}/global_variable'
346
+                     *
347
+                     * @param array $value option value to set global_variable with
348
+                     */
349
+                    global $$option_global;
350
+
351
+                    // phpcs:ignore WordPress.NamingConventions.ValidHookName, WordPress.NamingConventions.PrefixAllGlobals
352
+                    $$option_global = apply_filters( 'redux/options/' . $opt_name . '/global_variable', self::$options_defaults[ $opt_name ] );
353
+                }
354
+            }
355
+        }
356
+
357
+        /**
358
+         * Load Redux Framework.
359
+         *
360
+         * @param string $opt_name Panel opt_name.
361
+         *
362
+         * @throws ReflectionException  Exception.
363
+         */
364
+        public static function load_redux( string $opt_name = '' ) {
365
+            if ( empty( $opt_name ) ) {
366
+                return;
367
+            }
368
+
369
+            if ( class_exists( 'ReduxFramework' ) ) {
370
+                if ( isset( self::$init[ $opt_name ] ) && ! empty( self::$init[ $opt_name ] ) ) {
371
+                    return;
372
+                }
373
+            } else {
374
+                echo '<div id="message" class="error"><p>' . esc_html__( 'Redux Framework is not installed. Please install it.', 'redux-framework' ) . '</p></div>';
375
+
376
+                return;
377
+            }
378
+
379
+            self::instance( $opt_name );
380
+
381
+            Redux_Functions_Ex::record_caller( $opt_name );
382
+
383
+            if ( isset( self::$init[ $opt_name ] ) && 1 === self::$init[ $opt_name ] ) {
384
+                return;
385
+            }
386
+
387
+            // self::set_defaults( $opt_name );
388
+
389
+            $args     = self::construct_args( $opt_name );
390
+            $sections = self::construct_sections( $opt_name );
391
+
392
+            if ( isset( self::$uses_extensions[ $opt_name ] ) && ! empty( self::$uses_extensions[ $opt_name ] ) ) {
393
+                add_action( "redux/extensions/$opt_name/before", array( 'Redux', 'load_extensions' ), 0 );
394
+            }
395
+
396
+            $redux                   = new ReduxFramework( $sections, $args );
397
+            self::$init[ $opt_name ] = 1;
398
+
399
+            if ( isset( $redux->args['opt_name'] ) && $redux->args['opt_name'] !== $opt_name ) {
400
+                self::$init[ $redux->args['opt_name'] ] = 1;
401
+            }
402
+        }
403
+
404
+        /**
405
+         * Deprecated Create Redux instance.
406
+         *
407
+         * @throws ReflectionException  Exception.
408
+         *
409
+         * @deprecated No longer using camelCase naming convention.
410
+         */
411
+        public static function createRedux() {       // phpcs:ignore WordPress.NamingConventions.ValidFunctionName
412
+            _deprecated_function( __CLASS__ . '::' . __FUNCTION__, 'Redux 4.3', 'Redux::createRedux()' );
413
+
414
+            self::create_redux();
415
+        }
416
+
417
+        /**
418
+         * Create Redux instance.
419
+         *
420
+         * @throws ReflectionException  Exception.
421
+         */
422
+        public static function create_redux() {
423
+            foreach ( self::$sections as $opt_name => $the_sections ) {
424
+                if ( ! empty( $the_sections ) ) {
425
+                    if ( ! self::$init[ $opt_name ] ) {
426
+                        self::load_redux( $opt_name );
427
+                    }
428
+                }
429
+            }
430
+        }
431
+
432
+        /**
433
+         * Construct global arguments.
434
+         *
435
+         * @param string $opt_name Panel opt_name.
436
+         *
437
+         * @return array|mixed
438
+         */
439
+        public static function construct_args( string $opt_name ) {
440
+            $args             = self::$args[ $opt_name ] ?? array();
441
+            $args['opt_name'] = $opt_name;
442
+
443
+            if ( ! isset( $args['menu_title'] ) ) {
444
+                $args['menu_title'] = ucfirst( $opt_name ) . ' Options';
445
+            }
446
+
447
+            if ( ! isset( $args['page_title'] ) ) {
448
+                $args['page_title'] = ucfirst( $opt_name ) . ' Options';
449
+            }
450
+
451
+            if ( ! isset( $args['page_slug'] ) ) {
452
+                $args['page_slug'] = $opt_name . '_options';
453
+            }
454
+
455
+            return $args;
456
+        }
457
+
458
+        /**
459
+         * Construct option panel sections.
460
+         *
461
+         * @param string $opt_name Panel opt_name.
462
+         *
463
+         * @return array
464
+         */
465
+        public static function construct_sections( string $opt_name ): array {
466
+            $sections = array();
467
+
468
+            if ( ! isset( self::$sections[ $opt_name ] ) ) {
469
+                return $sections;
470
+            }
471
+
472
+            foreach ( self::$sections[ $opt_name ] as $section_id => $section ) {
473
+                $section['fields'] = self::construct_fields( $opt_name, $section_id );
474
+                $p                 = $section['priority'];
475
+
476
+                while ( isset( $sections[ $p ] ) ) {
477
+                    ++$p;
478
+                }
479
+
480
+                $sections[ $p ] = $section;
481
+            }
482
+
483
+            ksort( $sections );
484
+
485
+            return $sections;
486
+        }
487
+
488
+        /**
489
+         * Construct option panel fields.
490
+         *
491
+         * @param string $opt_name   Panel opt_name.
492
+         * @param string $section_id ID of a section.
493
+         *
494
+         * @return array
495
+         */
496
+        public static function construct_fields( string $opt_name = '', string $section_id = '' ): array {
497
+            $fields = array();
498
+
499
+            if ( ! empty( self::$fields[ $opt_name ] ) ) {
500
+                foreach ( self::$fields[ $opt_name ] as $field ) {
501
+                    if ( $field['section_id'] === $section_id ) {
502
+                        $p = esc_html( $field['priority'] );
503
+
504
+                        while ( isset( $fields[ $p ] ) ) {
505
+                            echo intval( $p++ );
506
+                        }
507
+
508
+                        $fields[ $p ] = $field;
509
+                    }
510
+                }
511
+            }
512
+
513
+            ksort( $fields );
514
+
515
+            return $fields;
516
+        }
517
+
518
+        /**
519
+         * Deprecated Retrieve panel section.
520
+         *
521
+         * @param string $opt_name Panel opt_name.
522
+         * @param string $id       Section ID.
523
+         *
524
+         * @return bool
525
+         * @deprecated No longer using camelCase naming convention.
526
+         */
527
+        public static function getSection( string $opt_name = '', string $id = '' ): bool { // phpcs:ignore WordPress.NamingConventions.ValidFunctionName
528
+            _deprecated_function( __CLASS__ . '::' . __FUNCTION__, 'Redux 4.3', 'Redux::get_section( $opt_name, $id )' );
529
+
530
+            return self::get_section( $opt_name, $id );
531
+        }
532
+
533
+        /**
534
+         * Retrieve panel section.
535
+         *
536
+         * @param string     $opt_name Panel opt_name.
537
+         * @param string|int $id       Section ID.
538
+         *
539
+         * @return bool|string|int
540
+         */
541
+        public static function get_section( string $opt_name = '', $id = '' ) {
542
+            self::check_opt_name( $opt_name );
543
+
544
+            if ( ! empty( $opt_name ) && ! empty( $id ) ) {
545
+                if ( ! isset( self::$sections[ $opt_name ][ $id ] ) ) {
546
+                    $id = Redux_Core::strtolower( sanitize_html_class( $id ) );
547
+                }
548
+
549
+                return self::$sections[ $opt_name ][ $id ] ?? false;
550
+            }
551
+
552
+            return false;
553
+        }
554
+
555
+        /**
556
+         * Deprecated Create a section of the option panel.
557
+         *
558
+         * @param string $opt_name Panel opt_name.
559
+         * @param array  $sections Section ID.
560
+         *
561
+         * @deprecated No longer using camelCase naming convention.
562
+         */
563
+        public static function setSections( string $opt_name = '', array $sections = array() ) { // phpcs:ignore WordPress.NamingConventions.ValidFunctionName
564
+            _deprecated_function( __CLASS__ . '::' . __FUNCTION__, 'Redux 4.3', 'Redux::set_sections( $opt_name, $sections )' );
565
+
566
+            if ( '' !== $opt_name ) {
567
+                Redux_Functions_Ex::record_caller( $opt_name );
568
+            }
569
+
570
+            self::set_sections( $opt_name, $sections );
571
+        }
572
+
573
+        /**
574
+         * Create multiple sections of the option panel.
575
+         *
576
+         * @param string $opt_name Panel opt_name.
577
+         * @param array  $sections Section ID.
578
+         */
579
+        public static function set_sections( string $opt_name = '', array $sections = array() ) {
580
+            if ( empty( $sections ) || '' === $opt_name ) {
581
+                return;
582
+            }
583
+
584
+            self::check_opt_name( $opt_name );
585
+
586
+            Redux_Functions_Ex::record_caller( $opt_name );
587
+
588
+            foreach ( $sections as $section ) {
589
+                self::set_section( $opt_name, $section );
590
+            }
591
+        }
592
+
593
+        /**
594
+         * Deprecated Retrieve all sections from the option panel.
595
+         *
596
+         * @param string $opt_name Panel opt_name.
597
+         *
598
+         * @return array|mixed
599
+         * @deprecated No longer using camelCase naming convention.
600
+         */
601
+        public static function getSections( string $opt_name = '' ) { // phpcs:ignore WordPress.NamingConventions.ValidFunctionName
602
+            _deprecated_function( __CLASS__ . '::' . __FUNCTION__, 'Redux 4.3', 'Redux::get_sections( $opt_name )' );
603
+
604
+            return self::get_sections( $opt_name );
605
+        }
606
+
607
+        /**
608
+         * Retrieve all sections from the option panel.
609
+         *
610
+         * @param string $opt_name Panel opt_name.
611
+         *
612
+         * @return array|mixed
613
+         */
614
+        public static function get_sections( string $opt_name = '' ) {
615
+            self::check_opt_name( $opt_name );
616
+
617
+            if ( ! empty( self::$sections[ $opt_name ] ) ) {
618
+                return self::$sections[ $opt_name ];
619
+            }
620
+
621
+            return array();
622
+        }
623
+
624
+        /**
625
+         * Deprecated Remove option panel by ID.
626
+         *
627
+         * @param string     $opt_name Panel opt_name.
628
+         * @param string|int $id       Section ID.
629
+         * @param bool       $fields   Remove fields.
630
+         *
631
+         * @deprecated No longer using camelCase naming convention.
632
+         */
633
+        public static function removeSection( string $opt_name = '', $id = '', bool $fields = false ) { // phpcs:ignore WordPress.NamingConventions.ValidFunctionName
634
+            _deprecated_function( __CLASS__ . '::' . __FUNCTION__, 'Redux 4.3', 'Redux::remove_section( $opt_name, $id )' );
635
+
636
+            if ( '' !== $opt_name ) {
637
+                Redux_Functions_Ex::record_caller( $opt_name );
638
+            }
639
+
640
+            self::remove_section( $opt_name, $id, $fields );
641
+        }
642
+
643
+        /**
644
+         * Remove an option panel by ID.
645
+         *
646
+         * @param string     $opt_name Panel opt_name.
647
+         * @param string|int $id       Section ID.
648
+         * @param bool       $fields   Remove fields.
649
+         */
650
+        public static function remove_section( string $opt_name = '', $id = '', bool $fields = false ) {
651
+            if ( '' !== $opt_name && '' !== $id ) {
652
+                Redux_Functions_Ex::record_caller( $opt_name );
653
+
654
+                if ( isset( self::$sections[ $opt_name ][ $id ] ) ) {
655
+                    $priority = '';
656
+
657
+                    foreach ( self::$sections[ $opt_name ] as $key => $section ) {
658
+                        if ( $key === $id ) {
659
+                            $priority = $section['priority'];
660
+                            --self::$priority[ $opt_name ]['sections'];
661
+                            unset( self::$sections[ $opt_name ][ $id ] );
662
+                            continue;
663
+                        }
664
+                        if ( '' !== $priority ) {
665
+                            $new_priority                        = $section['priority'];
666
+                            $section['priority']                 = $priority;
667
+                            self::$sections[ $opt_name ][ $key ] = $section;
668
+                            $priority                            = $new_priority;
669
+                        }
670
+                    }
671
+
672
+                    if ( isset( self::$fields[ $opt_name ] ) && ! empty( self::$fields[ $opt_name ] ) && true === $fields ) {
673
+                        foreach ( self::$fields[ $opt_name ] as $key => $field ) {
674
+                            if ( $field['section_id'] === $id ) {
675
+                                unset( self::$fields[ $opt_name ][ $key ] );
676
+                            }
677
+                        }
678
+                    }
679
+                }
680
+            }
681
+        }
682
+
683
+        /**
684
+         * Deprecated Sets a single option panel section.
685
+         *
686
+         * @param string     $opt_name Panel opt_name.
687
+         * @param array|null $section  Section data.
688
+         *
689
+         * @deprecated No longer using camelCase naming convention.
690
+         */
691
+        public static function setSection( string $opt_name = '', ?array $section = array() ) { // phpcs:ignore WordPress.NamingConventions.ValidFunctionName
692
+            // phpcs:ignore Squiz.PHP.CommentedOutCode.Found
693
+            // _deprecated_function( __CLASS__ . '::' . __FUNCTION__, 'Redux 4.3', 'Redux::set_section( $opt_name, $section )' );
694
+
695
+            if ( '' !== $opt_name ) {
696
+                Redux_Functions_Ex::record_caller( $opt_name );
697
+            }
698
+
699
+            self::set_section( $opt_name, $section );
700
+        }
701
+
702
+        /**
703
+         * Sets a single option panel section.
704
+         *
705
+         * @param string     $opt_name Panel opt_name.
706
+         * @param array|null $section  Section data.
707
+         * @param bool       $replace  Replaces a section instead of creating a new one.
708
+         */
709
+        public static function set_section( string $opt_name = '', ?array $section = array(), bool $replace = false ) {
710
+
711
+            if ( empty( $section ) || '' === $opt_name ) {
712
+                return;
713
+            }
714
+
715
+            self::check_opt_name( $opt_name );
716
+
717
+            Redux_Functions_Ex::record_caller( $opt_name );
718
+
719
+            if ( ! isset( $section['id'] ) ) {
720
+                if ( isset( $section['type'] ) && 'divide' === $section['type'] ) {
721
+                    $section['id'] = time();
722
+                } elseif ( isset( $section['title'] ) ) {
723
+                        $section['id'] = Redux_Core::strtolower( sanitize_title( $section['title'] ) );
724
+                } else {
725
+                    $section['id'] = time();
726
+                }
727
+
728
+                if ( isset( self::$sections[ $opt_name ][ $section['id'] ] ) && ! $replace ) {
729
+                    $orig = $section['id'];
730
+                    $i    = 0;
731
+
732
+                    while ( isset( self::$sections[ $opt_name ][ $section['id'] ] ) ) {
733
+                        $section['id'] = $orig . '_' . $i;
734
+                        ++$i;
735
+                    }
736
+                } elseif ( isset( self::$sections[ $opt_name ][ $section['id'] ] ) && $replace ) {
737
+                    // If replace is set, let's update the default values with these!
738
+                    $fields = false;
739
+                    if ( isset( self::$sections[ $opt_name ][ $section['id'] ]['fields'] ) && ! empty( self::$sections[ $opt_name ][ $section['id'] ]['fields'] ) ) {
740
+                        $fields = self::$sections[ $opt_name ][ $section['id'] ]['fields'];
741
+                    }
742
+                    self::$sections[ $opt_name ][ $section['id'] ] = wp_parse_args( $section, self::$sections[ $opt_name ][ $section['id'] ] );
743
+                    if ( ! empty( $fields ) ) {
744
+                        if ( ! isset( self::$sections[ $opt_name ][ $section['id'] ]['fields'] ) || ( isset( self::$sections[ $opt_name ][ $section['id'] ]['fields'] ) && empty( self::$sections[ $opt_name ][ $section['id'] ]['fields'] ) ) ) {
745
+                            self::$sections[ $opt_name ][ $section['id'] ]['fields'] = $fields;
746
+                        }
747
+                    }
748
+                }
749
+            }
750
+
751
+            if ( ! empty( $opt_name ) && is_array( $section ) && ! empty( $section ) ) {
752
+                if ( ! isset( $section['id'] ) && ! isset( $section['title'] ) ) {
753
+                    self::$errors[ $opt_name ]['section']['missing_title'] = esc_html__( 'Unable to create a section due to missing id and title.', 'redux-framework' );
754
+
755
+                    return;
756
+                }
757
+
758
+                if ( ! isset( $section['priority'] ) ) {
759
+                    $section['priority'] = self::get_priority( $opt_name, 'sections' );
760
+                }
761
+
762
+                if ( isset( $section['fields'] ) ) {
763
+                    if ( ! empty( $section['fields'] ) && is_array( $section['fields'] ) ) {
764
+                        self::process_field_array( $opt_name, $section['id'], $section['fields'] );
765
+                    }
766
+                    unset( $section['fields'] );
767
+                }
768
+                self::$sections[ $opt_name ][ $section['id'] ] = $section;
769
+            } else {
770
+                self::$errors[ $opt_name ]['section']['empty'] = esc_html__( 'Unable to create a section due an empty section array or the section variable passed was not an array.', 'redux-framework' );
771
+            }
772
+        }
773
+
774
+        /**
775
+         * Deprecated Hides an option panel section.
776
+         *
777
+         * @param string     $opt_name Panel opt_name.
778
+         * @param string|int $id       Section ID.
779
+         * @param bool       $hide     Flag to hide/show.
780
+         *
781
+         * @deprecated No longer using camelCase naming convention.
782
+         */
783
+        public static function hideSection( string $opt_name = '', $id = '', bool $hide = true ) { // phpcs:ignore WordPress.NamingConventions.ValidFunctionName
784
+            _deprecated_function( __CLASS__ . '::' . __FUNCTION__, 'Redux 4.3', 'Redux::hide_section( $opt_name, $id )' );
785
+
786
+            if ( '' !== $opt_name ) {
787
+                Redux_Functions_Ex::record_caller( $opt_name );
788
+            }
789
+
790
+            self::hide_section( $opt_name, $id, $hide );
791
+        }
792
+
793
+        /**
794
+         * Hides an option panel section.
795
+         *
796
+         * @param string     $opt_name Panel opt_name.
797
+         * @param string|int $id       Section ID.
798
+         * @param bool       $hide     Flag to hide/show.
799
+         */
800
+        public static function hide_section( string $opt_name = '', $id = '', bool $hide = true ) {
801
+            self::check_opt_name( $opt_name );
802
+
803
+            if ( '' !== $opt_name && '' !== $id ) {
804
+                Redux_Functions_Ex::record_caller( $opt_name );
805
+
806
+                if ( isset( self::$sections[ $opt_name ][ $id ] ) ) {
807
+                    self::$sections[ $opt_name ][ $id ]['hidden'] = $hide;
808
+                }
809
+            }
810
+        }
811
+
812
+        /**
813
+         * Compiles field array data.
814
+         *
815
+         * @param string     $opt_name   Panel opt_name.
816
+         * @param string|int $section_id Section ID.
817
+         * @param array      $fields     Field data.
818
+         */
819
+        private static function process_field_array( string $opt_name = '', $section_id = '', array $fields = array() ) {
820
+            if ( ! empty( $opt_name ) && ! empty( $section_id ) && is_array( $fields ) && ! empty( $fields ) ) {
821
+                foreach ( $fields as $field ) {
822
+                    if ( ! is_array( $field ) ) {
823
+                        continue;
824
+                    }
825
+                    self::set_field( $opt_name, $section_id, $field );
826
+                }
827
+            }
828
+        }
829
+
830
+        /**
831
+         * Deprecated Retrieves an option panel field.
832
+         *
833
+         * @param string     $opt_name Panel opt_name.
834
+         * @param string|int $id       Field ID.
835
+         *
836
+         * @return int|bool
837
+         * @deprecated No longer using camelCase naming convention.
838
+         */
839
+        public static function getField( string $opt_name = '', $id = '' ) { // phpcs:ignore WordPress.NamingConventions.ValidFunctionName
840
+            _deprecated_function( __CLASS__ . '::' . __FUNCTION__, 'Redux 4.3', 'Redux::get_field( $opt_name, $id )' );
841
+
842
+            return self::get_field( $opt_name, $id );
843
+        }
844
+
845
+        /**
846
+         * Retrieves an option panel field.
847
+         *
848
+         * @param string     $opt_name Panel opt_name.
849
+         * @param string|int $id       Field ID.
850
+         *
851
+         * @return int|bool
852
+         */
853
+        public static function get_field( string $opt_name = '', $id = '' ) {
854
+            self::check_opt_name( $opt_name );
855
+
856
+            if ( ! empty( $opt_name ) && ! empty( $id ) ) {
857
+                return self::$fields[ $opt_name ][ $id ] ?? false;
858
+            }
859
+
860
+            return false;
861
+        }
862
+
863
+        /**
864
+         * Deprecated Hides an option panel field.
865
+         *
866
+         * @param string     $opt_name Panel opt_name.
867
+         * @param string|int $id       Field ID.
868
+         * @param bool       $hide     Set hide/show.
869
+         *
870
+         * @deprecated No longer using camelCase naming convention.
871
+         */
872
+        public static function hideField( string $opt_name = '', $id = '', bool $hide = true ) { // phpcs:ignore WordPress.NamingConventions.ValidFunctionName
873
+            _deprecated_function( __CLASS__ . '::' . __FUNCTION__, 'Redux 4.3', 'Redux::hide_field( $opt_name, $id )' );
874
+
875
+            if ( '' !== $opt_name ) {
876
+                Redux_Functions_Ex::record_caller( $opt_name );
877
+            }
878
+
879
+            self::hide_field( $opt_name, $id, $hide );
880
+        }
881
+
882
+        /**
883
+         * Hides an option panel field.
884
+         *
885
+         * @param string     $opt_name Panel opt_name.
886
+         * @param string|int $id       Field ID.
887
+         * @param bool       $hide     Set hide/show.
888
+         */
889
+        public static function hide_field( string $opt_name = '', $id = '', bool $hide = true ) {
890
+            self::check_opt_name( $opt_name );
891
+
892
+            if ( '' !== $opt_name && '' !== $id ) {
893
+                if ( isset( self::$fields[ $opt_name ][ $id ] ) ) {
894
+                    Redux_Functions_Ex::record_caller( $opt_name );
895
+
896
+                    if ( ! $hide ) {
897
+                        self::$fields[ $opt_name ][ $id ]['class'] = str_replace( 'hidden', '', self::$fields[ $opt_name ][ $id ]['class'] );
898
+                    } else {
899
+                        self::$fields[ $opt_name ][ $id ]['class'] .= 'hidden';
900
+                    }
901
+                }
902
+            }
903
+        }
904
+
905
+        /**
906
+         * Deprecated Creates an option panel field.
907
+         *
908
+         * @param string     $opt_name   Panel opt_name.
909
+         * @param string|int $section_id Section ID this field belongs to.
910
+         * @param array      $field      Field data.
911
+         *
912
+         * @deprecated No longer using camelCase naming convention.
913
+         */
914
+        public static function setField( string $opt_name = '', $section_id = '', array $field = array() ) { // phpcs:ignore WordPress.NamingConventions.ValidFunctionName
915
+            _deprecated_function( __CLASS__ . '::' . __FUNCTION__, 'Redux 4.3', 'Redux::set_field( $opt_name, $section_id, $field )' );
916
+
917
+            if ( '' !== $opt_name ) {
918
+                Redux_Functions_Ex::record_caller( $opt_name );
919
+            }
920
+
921
+            self::set_field( $opt_name, $section_id, $field );
922
+        }
923
+
924
+        /**
925
+         * Creates an option panel field and adds to a section.
926
+         *
927
+         * @param string     $opt_name   Panel opt_name.
928
+         * @param string|int $section_id Section ID this field belongs to.
929
+         * @param array      $field      Field data.
930
+         */
931
+        public static function set_field( string $opt_name = '', $section_id = '', array $field = array() ) {
932
+
933
+            if ( ! is_array( $field ) || empty( $field ) || '' === $opt_name || '' === $section_id ) {
934
+                return;
935
+            }
936
+
937
+            self::check_opt_name( $opt_name );
938
+
939
+            Redux_Functions_Ex::record_caller( $opt_name );
940
+
941
+            // Shim for the old method!
942
+            if ( is_array( $section_id ) ) {
943
+                $field = $section_id;
944
+                if ( isset( $field['section_id'] ) ) {
945
+                    $section_id = $field['section_id'];
946
+                }
947
+            }
948
+
949
+            $field['section_id'] = $section_id;
950
+
951
+            if ( ! isset( $field['priority'] ) ) {
952
+                $field['priority'] = self::get_priority( $opt_name, 'fields' );
953
+            }
954
+            $field['id'] = $field['id'] ?? "{$opt_name}_{$section_id}_{$field['type']}_" . wp_rand( 1, 9999 );
955
+
956
+            self::$fields[ $opt_name ][ $field['id'] ] = $field;
957
+        }
958
+
959
+        /**
960
+         * Create multiple fields of the option panel and apply to a section.
961
+         *
962
+         * @param string     $opt_name   Panel opt_name.
963
+         * @param int|string $section_id Section ID this field belongs to.
964
+         * @param array      $fields     Array of field arrays.
965
+         */
966
+        public static function set_fields( string $opt_name = '', $section_id = '', array $fields = array() ) {
967
+            if ( ! is_array( $fields ) || empty( $fields ) || '' === $opt_name || '' === $section_id ) {
968
+                return;
969
+            }
970
+
971
+            self::check_opt_name( $opt_name );
972
+
973
+            // phpcs:ignore WordPress.PHP.DevelopmentFunctions
974
+            Redux_Functions_Ex::record_caller( $opt_name );
975
+
976
+            foreach ( $fields as $field ) {
977
+                if ( is_array( $field ) ) {
978
+                    self::set_field( $opt_name, $section_id, $field );
979
+                }
980
+            }
981
+        }
982
+
983
+        /**
984
+         * Deprecated Removes an option panel field.
985
+         *
986
+         * @param string     $opt_name Panel opt_name.
987
+         * @param string|int $id       Field ID.
988
+         *
989
+         * @return bool
990
+         * @deprecated No longer using camelCase naming convention.
991
+         */
992
+        public static function removeField( string $opt_name = '', $id = '' ): bool { // phpcs:ignore WordPress.NamingConventions.ValidFunctionName
993
+            _deprecated_function( __CLASS__ . '::' . __FUNCTION__, 'Redux 4.3', 'Redux::remove_field( $opt_name, $id )' );
994
+
995
+            if ( '' !== $opt_name ) {
996
+                Redux_Functions_Ex::record_caller( $opt_name );
997
+            }
998
+
999
+            return self::remove_field( $opt_name, $id );
1000
+        }
1001
+
1002
+        /**
1003
+         * Removes an option panel field.
1004
+         *
1005
+         * @param string     $opt_name Panel opt_name.
1006
+         * @param string|int $id       Field ID.
1007
+         *
1008
+         * @return bool
1009
+         */
1010
+        public static function remove_field( string $opt_name = '', $id = '' ): bool {
1011
+            if ( '' !== $opt_name && '' !== $id ) {
1012
+                self::check_opt_name( $opt_name );
1013
+
1014
+                Redux_Functions_Ex::record_caller( $opt_name );
1015
+
1016
+                if ( isset( self::$fields[ $opt_name ][ $id ] ) ) {
1017
+                    foreach ( self::$fields[ $opt_name ] as $key => $field ) {
1018
+                        if ( $key === $id ) {
1019
+                            $priority = $field['priority'];
1020
+                            --self::$priority[ $opt_name ]['fields'];
1021
+                            unset( self::$fields[ $opt_name ][ $id ] );
1022
+                            continue;
1023
+                        }
1024
+
1025
+                        if ( isset( $priority ) && '' !== $priority ) {
1026
+                            $new_priority                      = $field['priority'];
1027
+                            $field['priority']                 = $priority;
1028
+                            self::$fields[ $opt_name ][ $key ] = $field;
1029
+                            $priority                          = $new_priority;
1030
+                        }
1031
+                    }
1032
+                }
1033
+            }
1034
+
1035
+            return false;
1036
+        }
1037
+
1038
+        /**
1039
+         * Deprecated Sets help tabs on option panel admin page.
1040
+         *
1041
+         * @param string $opt_name Panel opt_name.
1042
+         * @param array  $tab      Tab data.
1043
+         *
1044
+         * @deprecated No longer using camelCase naming convention.
1045
+         */
1046
+        public static function setHelpTab( string $opt_name = '', array $tab = array() ) { // phpcs:ignore WordPress.NamingConventions.ValidFunctionName
1047
+            _deprecated_function( __CLASS__ . '::' . __FUNCTION__, 'Redux 4.3', 'Redux::set_help_tab( $opt_name, $tab )' );
1048
+
1049
+            self::set_help_tab( $opt_name, $tab );
1050
+        }
1051
+
1052
+        /**
1053
+         * Sets help tabs on option panel admin page.
1054
+         *
1055
+         * @param string $opt_name Panel opt_name.
1056
+         * @param array  $tab      Tab data.
1057
+         */
1058
+        public static function set_help_tab( string $opt_name = '', array $tab = array() ) {
1059
+            if ( ! is_array( $tab ) && empty( $tab ) ) {
1060
+                return;
1061
+            }
1062
+
1063
+            self::check_opt_name( $opt_name );
1064
+
1065
+            if ( '' !== $opt_name ) {
1066
+                if ( ! isset( self::$args[ $opt_name ]['help_tabs'] ) ) {
1067
+                    self::$args[ $opt_name ]['help_tabs'] = array();
1068
+                }
1069
+
1070
+                if ( isset( $tab['id'] ) ) {
1071
+                    self::$args[ $opt_name ]['help_tabs'][] = $tab;
1072
+                } elseif ( is_array( end( $tab ) ) ) {
1073
+                    foreach ( $tab as $tab_item ) {
1074
+                        self::$args[ $opt_name ]['help_tabs'][] = $tab_item;
1075
+                    }
1076
+                }
1077
+            }
1078
+        }
1079
+
1080
+        /**
1081
+         * Deprecated Sets the help sidebar content.
1082
+         *
1083
+         * @param string $opt_name Panel opt_name.
1084
+         * @param string $content  Content.
1085
+         *
1086
+         * @deprecated No longer using camelCase naming convention.
1087
+         */
1088
+        public static function setHelpSidebar( string $opt_name = '', string $content = '' ) { // phpcs:ignore WordPress.NamingConventions.ValidFunctionName
1089
+            _deprecated_function( __CLASS__ . '::' . __FUNCTION__, 'Redux 4.3', 'Redux::set_help_sidebar( $opt_name, $content )' );
1090
+
1091
+            self::set_help_sidebar( $opt_name, $content );
1092
+        }
1093
+
1094
+        /**
1095
+         * Sets the help sidebar content.
1096
+         *
1097
+         * @param string $opt_name Panel opt_name.
1098
+         * @param string $content  Content.
1099
+         */
1100
+        public static function set_help_sidebar( string $opt_name = '', string $content = '' ) {
1101
+            if ( '' === $content || '' === $opt_name ) {
1102
+                return;
1103
+            }
1104
+            self::check_opt_name( $opt_name );
1105
+
1106
+            self::$args[ $opt_name ]['help_sidebar'] = $content;
1107
+        }
1108
+
1109
+        /**
1110
+         * Deprecated Sets option panel global arguments.
1111
+         *
1112
+         * @param string $opt_name Panel opt_name.
1113
+         * @param array  $args     Argument data.
1114
+         *
1115
+         * @deprecated No longer using camelCase naming convention.
1116
+         */
1117
+        public static function setArgs( string $opt_name = '', array $args = array() ) { // phpcs:ignore WordPress.NamingConventions.ValidFunctionName
1118
+            // phpcs:ignore Squiz.PHP.CommentedOutCode.Found
1119
+            // _deprecated_function( __CLASS__ . '::' . __FUNCTION__, 'Redux 4.3', 'Redux::set_args( $opt_name, $args )' );
1120
+
1121
+            if ( '' !== $opt_name ) {
1122
+                Redux_Functions_Ex::record_caller( $opt_name );
1123
+            }
1124
+
1125
+            self::set_args( $opt_name, $args );
1126
+        }
1127
+
1128
+        /**
1129
+         * Sets option panel global arguments.
1130
+         *
1131
+         * @param string $opt_name Panel opt_name.
1132
+         * @param array  $args     Argument data.
1133
+         */
1134
+        public static function set_args( string $opt_name = '', array $args = array() ) {
1135
+            if ( empty( $args ) || '' === $opt_name ) {
1136
+                return;
1137
+            }
1138
+
1139
+            self::check_opt_name( $opt_name );
1140
+
1141
+            Redux_Functions_Ex::record_caller( $opt_name );
1142
+
1143
+            if ( is_array( $args ) ) {
1144
+                if ( isset( self::$args[ $opt_name ]['clearArgs'] ) ) {
1145
+                    self::$args[ $opt_name ] = array();
1146
+                }
1147
+                self::$args[ $opt_name ] = wp_parse_args( $args, self::$args[ $opt_name ] );
1148
+            }
1149
+        }
1150
+
1151
+        /**
1152
+         * Set's developer key for premium services.
1153
+         *
1154
+         * @param string       $opt_name Panel opt_name.
1155
+         * @param string|array $arg      Args data.
1156
+         */
1157
+        public static function set_developer( string $opt_name = '', $arg = '' ) {
1158
+            if ( empty( $arg ) || '' === $opt_name ) {
1159
+                return;
1160
+            }
1161
+
1162
+            self::check_opt_name( $opt_name );
1163
+
1164
+            Redux_Functions_Ex::record_caller( $opt_name );
1165
+
1166
+            self::$args[ $opt_name ]['developer'] = $arg;
1167
+        }
1168
+
1169
+        /**
1170
+         * Deprecated Retries option panel global argument array.
1171
+         *
1172
+         * @param string $opt_name Panel opt_name.
1173
+         *
1174
+         * @return mixed
1175
+         * @deprecated No longer camelCase naming convention.
1176
+         */
1177
+        public static function getArgs( string $opt_name = '' ) { // phpcs:ignore WordPress.NamingConventions.ValidFunctionName
1178
+            _deprecated_function( __CLASS__ . '::' . __FUNCTION__, 'Redux 4.3', 'Redux::get_args( $opt_name )' );
1179
+
1180
+            return self::get_args( $opt_name );
1181
+        }
1182
+
1183
+        /**
1184
+         * Retries option panel global argument array.
1185
+         *
1186
+         * @param string $opt_name Panel opt_name.
1187
+         * @param string $key      Argument key name to be returned.
1188
+         *
1189
+         * @return mixed|null|array
1190
+         */
1191
+        public static function get_args( string $opt_name = '', string $key = '' ) {
1192
+            self::check_opt_name( $opt_name );
1193
+
1194
+            if ( ! empty( $opt_name ) && ! empty( $key ) ) {
1195
+                if ( ! empty( self::$args[ $opt_name ] ) ) {
1196
+                    return self::$args[ $opt_name ][ $key ];
1197
+                } else {
1198
+                    return null;
1199
+                }
1200
+            } elseif ( ! empty( $opt_name ) && ! empty( self::$args[ $opt_name ] ) ) {
1201
+                return self::$args[ $opt_name ];
1202
+            }
1203
+
1204
+            return null;
1205
+        }
1206
+
1207
+        /**
1208
+         * Deprecated Retrieves a single global argument.
1209
+         *
1210
+         * @param string $opt_name Panel opt_name.
1211
+         * @param string $key      Argument name.
1212
+         *
1213
+         * @return mixed
1214
+         * @deprecated No longer using camelCase naming convention and using singular function self::get_args() now.
1215
+         */
1216
+        public static function getArg( string $opt_name = '', string $key = '' ) { // phpcs:ignore WordPress.NamingConventions.ValidFunctionName
1217
+            _deprecated_function( __CLASS__ . '::' . __FUNCTION__, 'Redux 4.3', 'Redux::get_arg( $opt_name, $key )' );
1218
+
1219
+            return self::get_args( $opt_name, $key );
1220
+        }
1221
+
1222
+        /**
1223
+         * Retrieves a single global argument.
1224
+         *
1225
+         * @param string $opt_name Panel opt_name.
1226
+         * @param string $key      Argument name.
1227
+         *
1228
+         * @return mixed|array|null
1229
+         */
1230
+        public static function get_arg( string $opt_name = '', string $key = '' ) {
1231
+            self::check_opt_name( $opt_name );
1232
+
1233
+            if ( ! empty( $opt_name ) && ! empty( $key ) && ! empty( self::$args[ $opt_name ] ) ) {
1234
+                return self::$args[ $opt_name ][ $key ];
1235
+            } else {
1236
+                return null;
1237
+            }
1238
+        }
1239
+
1240
+        /**
1241
+         * Deprecated Retrieves a single option from the database.
1242
+         *
1243
+         * @param string       $opt_name Panel opt_name.
1244
+         * @param string       $key      Option key.
1245
+         * @param string|array $defaults  Default value.
1246
+         *
1247
+         * @return mixed
1248
+         * @deprecated No longer using camelCase naming convention.
1249
+         */
1250
+        public static function getOption( string $opt_name = '', string $key = '', $defaults = '' ) { // phpcs:ignore WordPress.NamingConventions.ValidFunctionName
1251
+            _deprecated_function( __CLASS__ . '::' . __FUNCTION__, 'Redux 4.3', 'Redux::get_option( $opt_name, $key, $default )' );
1252
+
1253
+            return self::get_option( $opt_name, $key, $defaults );
1254
+        }
1255
+
1256
+        /**
1257
+         * Retrieves meta for a given post page, IE WordPress meta values
1258
+         *
1259
+         * @param string $opt_name Panel opt_name.
1260
+         * @param mixed  $the_post Post object to denote the current post, or custom.
1261
+         * @param string $key      Option key.
1262
+         * @param mixed  $defaults Default value.
1263
+         *
1264
+         * @return mixed
1265
+         */
1266
+        public static function get_post_meta( string $opt_name = '', $the_post = array(), string $key = '', $defaults = null ) {
1267
+            self::check_opt_name( $opt_name );
1268
+
1269
+            if ( empty( $opt_name ) ) {
1270
+                return null;
1271
+            }
1272
+
1273
+            global $post;
1274
+
1275
+            $redux = ReduxFrameworkInstances::get_instance( $opt_name );
1276
+
1277
+            $metaboxes = $redux->extensions['metaboxes'];
1278
+
1279
+            if ( null === $defaults || '' === $defaults ) {
1280
+                $defaults = self::get_option( $opt_name, $key );
1281
+            }
1282
+
1283
+            if ( isset( $the_post ) && is_array( $the_post ) ) {
1284
+                $the_post = $post;
1285
+            } elseif ( ! isset( $the_post ) || 0 === $the_post ) {
1286
+                return $defaults;
1287
+            } elseif ( is_numeric( $the_post ) ) {
1288
+                $the_post = get_post( $the_post );
1289
+            } elseif ( ! is_object( $the_post ) ) {
1290
+                $the_post = $post;
1291
+            }
1292
+
1293
+            $defaults = self::get_option( $opt_name, $key );
1294
+
1295
+            return $metaboxes->get_values( $the_post, $key, $defaults );
1296
+        }
1297
+
1298
+        /**
1299
+         * Retrieves a single option from the database.
1300
+         *
1301
+         * @param string $opt_name Panel opt_name.
1302
+         * @param string $key      Option key.
1303
+         * @param mixed  $default  Default value.
1304
+         *
1305
+         * @return mixed
1306
+         */
1307
+        public static function get_option( string $opt_name = '', string $key = '', $default = null ) { // phpcs:ignore Universal.NamingConventions
1308
+            self::check_opt_name( $opt_name );
1309
+
1310
+            if ( ! empty( $opt_name ) && ! empty( $key ) ) {
1311
+                global $$opt_name;
1312
+
1313
+                if ( empty( $$opt_name ) ) {
1314
+                    $values = get_option( $opt_name );
1315
+                    // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals
1316
+                    $$opt_name = $values;
1317
+                } else {
1318
+                    $values = $$opt_name;
1319
+                }
1320
+
1321
+                if ( ! isset( $values[ $key ] ) ) {
1322
+                    if ( null === $default ) {
1323
+                        $field = self::get_field( $opt_name, $key );
1324
+
1325
+                        if ( false !== $field ) {
1326
+                            $defaults_class = new Redux_Options_Defaults();
1327
+                            $sections       = self::construct_sections( $opt_name );
1328
+                            $defaults       = $defaults_class->default_values( $opt_name, $sections );
1329
+
1330
+                            if ( isset( $defaults[ $key ] ) ) {
1331
+                                $default = $defaults[ $key ];
1332
+                            }
1333
+                        }
1334
+                    }
1335
+                }
1336
+
1337
+                if ( ! empty( $subkeys ) && is_array( $subkeys ) ) {
1338
+                    $value = $default;
1339
+
1340
+                    if ( isset( $values[ $key ] ) ) {
1341
+                        $count = count( $subkeys );
1342
+
1343
+                        if ( 1 === $count ) {
1344
+                            $value = $values[ $key ][ $subkeys[1] ] ?? $default;
1345
+                        } elseif ( 2 === $count ) {
1346
+                            if ( isset( $values[ $key ][ $subkeys[1] ] ) ) {
1347
+                                $value = $values[ $key ][ $subkeys[1] ][ $subkeys[2] ] ?? $default;
1348
+                            }
1349
+                        } elseif ( 3 === $count ) {
1350
+                            if ( isset( $values[ $key ][ $subkeys[1] ] ) ) {
1351
+                                if ( isset( $values[ $key ][ $subkeys[1] ][ $subkeys[2] ] ) ) {
1352
+                                    $value = $values[ $key ][ $subkeys[1] ][ $subkeys[2] ][ $subkeys[3] ] ?? $default;
1353
+                                }
1354
+                            }
1355
+                        }
1356
+                    }
1357
+                } else {
1358
+                    $value = $values[ $key ] ?? $default;
1359
+                }
1360
+
1361
+                return $value;
1362
+            } else {
1363
+                return false;
1364
+            }
1365
+        }
1366
+
1367
+        /**
1368
+         * Deprecated Sets an option into the database.
1369
+         *
1370
+         * @param string $opt_name Panel opt_name.
1371
+         * @param string $key      Option key.
1372
+         * @param mixed  $option   Option value.
1373
+         *
1374
+         * @return bool
1375
+         * @deprecated No longer using camelCase naming convention.
1376
+         */
1377
+        public static function setOption( string $opt_name = '', string $key = '', $option = '' ): bool { // phpcs:ignore WordPress.NamingConventions.ValidFunctionName
1378
+            _deprecated_function( __CLASS__ . '::' . __FUNCTION__, 'Redux 4.3', 'Redux::set_option( $opt_name, $key, $option )' );
1379
+
1380
+            if ( '' !== $opt_name ) {
1381
+                Redux_Functions_Ex::record_caller( $opt_name );
1382
+            }
1383
+
1384
+            return self::set_option( $opt_name, $key, $option );
1385
+        }
1386
+
1387
+        /**
1388
+         * Sets an option into the database.
1389
+         *
1390
+         * @param string $opt_name Panel opt_name.
1391
+         * @param string $key      Option key.
1392
+         * @param mixed  $option   Option value.
1393
+         *
1394
+         * @return bool
1395
+         */
1396
+        public static function set_option( string $opt_name = '', string $key = '', $option = '' ): bool {
1397
+            if ( '' === $key ) {
1398
+                return false;
1399
+            }
1400
+
1401
+            self::check_opt_name( $opt_name );
1402
+
1403
+            Redux_Functions_Ex::record_caller( $opt_name );
1404
+
1405
+            if ( '' !== $opt_name ) {
1406
+                $redux         = get_option( $opt_name );
1407
+                $redux[ $key ] = $option;
1408
+
1409
+                return update_option( $opt_name, $redux );
1410
+            } else {
1411
+                return false;
1412
+            }
1413
+        }
1414
+
1415
+        /**
1416
+         * Get the next available priority for field/section.
1417
+         *
1418
+         * @param string $opt_name Panel opt_name.
1419
+         * @param string $type     Field or section.
1420
+         *
1421
+         * @return mixed
1422
+         */
1423
+        public static function get_priority( string $opt_name, string $type ) {
1424
+            $priority                              = self::$priority[ $opt_name ][ $type ];
1425
+            self::$priority[ $opt_name ][ $type ] += 1;
1426
+
1427
+            return $priority;
1428
+        }
1429
+
1430
+        /**
1431
+         * Check opt_name integrity.
1432
+         *
1433
+         * @param string $opt_name Panel opt_name.
1434
+         */
1435
+        public static function check_opt_name( string $opt_name = '' ) {
1436
+            if ( empty( $opt_name ) || is_array( $opt_name ) ) {
1437
+                return;
1438
+            }
1439
+
1440
+            if ( ! isset( self::$sections[ $opt_name ] ) ) {
1441
+                self::$sections[ $opt_name ]             = array();
1442
+                self::$priority[ $opt_name ]['sections'] = 1;
1443
+            }
1444
+
1445
+            if ( ! isset( self::$args[ $opt_name ] ) ) {
1446
+                self::$args[ $opt_name ]             = array();
1447
+                self::$priority[ $opt_name ]['args'] = 1;
1448
+            }
1449
+
1450
+            if ( ! isset( self::$fields[ $opt_name ] ) ) {
1451
+                self::$fields[ $opt_name ]             = array();
1452
+                self::$priority[ $opt_name ]['fields'] = 1;
1453
+            }
1454
+
1455
+            if ( ! isset( self::$help[ $opt_name ] ) ) {
1456
+                self::$help[ $opt_name ]             = array();
1457
+                self::$priority[ $opt_name ]['help'] = 1;
1458
+            }
1459
+
1460
+            if ( ! isset( self::$errors[ $opt_name ] ) ) {
1461
+                self::$errors[ $opt_name ] = array();
1462
+            }
1463
+
1464
+            if ( ! isset( self::$init[ $opt_name ] ) ) {
1465
+                self::$init[ $opt_name ] = false;
1466
+            }
1467
+        }
1468
+
1469
+        /**
1470
+         * Retrieve metadata from a file. Based on WP Core's get_file_data function
1471
+         *
1472
+         * @param string $file Path to the file.
1473
+         *
1474
+         * @return string
1475
+         * @since 2.1.1
1476
+         */
1477
+        public static function get_file_version( string $file ): string {
1478
+            $data = get_file_data( $file, array( 'version' ), 'plugin' );
1479
+
1480
+            return $data[0];
1481
+        }
1482
+
1483
+        /**
1484
+         * Verify extension class name.
1485
+         *
1486
+         * @param string $opt_name   Panel opt_name.
1487
+         * @param string $name       extension name.
1488
+         * @param string $class_file Extension class file.
1489
+         */
1490
+        private static function check_extension_class_file( string $opt_name, string $name = '', string $class_file = '' ) {
1491
+            $instance = null;
1492
+
1493
+            if ( file_exists( $class_file ) ) {
1494
+                self::$uses_extensions[ $opt_name ] = self::$uses_extensions[ $opt_name ] ?? array();
1495
+
1496
+                if ( ! in_array( $name, self::$uses_extensions[ $opt_name ], true ) ) {
1497
+                    self::$uses_extensions[ $opt_name ][] = $name;
1498
+                }
1499
+
1500
+                self::$extensions[ $name ] = self::$extensions[ $name ] ?? array();
1501
+
1502
+                $version = Redux_Helpers::get_template_version( $class_file );
1503
+
1504
+                if ( empty( $version ) && ! empty( $instance ) ) {
1505
+                    if ( isset( $instance->version ) ) {
1506
+                        $version = $instance->version;
1507
+                    }
1508
+                }
1509
+                self::$extensions[ $name ][ $version ] = self::$extensions[ $name ][ $version ] ?? $class_file;
1510
+
1511
+                $new_name  = str_replace( '_', '-', $name );
1512
+                $api_check = str_replace(
1513
+                    array(
1514
+                        'extension_' . $name,
1515
+                        'class-redux-extension-' . $new_name,
1516
+                    ),
1517
+                    array(
1518
+                        $name . '_api',
1519
+                        'class-redux-' . $new_name . '-api',
1520
+                    ),
1521
+                    $class_file
1522
+                );
1523
+
1524
+                if ( file_exists( $api_check ) && ! class_exists( 'Redux_' . ucfirst( $name ) ) ) {
1525
+                    include_once $api_check;
1526
+                }
1527
+            }
1528
+        }
1529
+
1530
+        /**
1531
+         * Deprecated Sets all extensions in a path.
1532
+         *
1533
+         * @param string $opt_name Panel opt_name.
1534
+         * @param string $path     Path to extension folder.
1535
+         *
1536
+         * @deprecated No longer using camelCase naming convention.
1537
+         */
1538
+        public static function setExtensions( string $opt_name, string $path ) { // phpcs:ignore WordPress.NamingConventions.ValidFunctionName
1539
+            _deprecated_function( __CLASS__ . '::' . __FUNCTION__, 'Redux 4.3', 'Redux::get_extensions( $opt_name, $path )' );
1540
+
1541
+            if ( '' !== $opt_name ) {
1542
+                Redux_Functions_Ex::record_caller( $opt_name );
1543
+            }
1544
+
1545
+            self::set_extensions( $opt_name, $path );
1546
+        }
1547
+
1548
+        /**
1549
+         * Sets all extensions in a path.
1550
+         *
1551
+         * @param string $opt_name Panel opt_name.
1552
+         * @param string $path     Path to extension folder.
1553
+         * @param bool   $force    Make extension reload.
1554
+         */
1555
+        public static function set_extensions( string $opt_name, string $path, bool $force = false ) {
1556
+            if ( '' === $path || '' === $opt_name ) {
1557
+                return;
1558
+            }
1559
+
1560
+            self::check_opt_name( $opt_name );
1561
+
1562
+            Redux_Functions_Ex::record_caller( $opt_name );
1563
+
1564
+            if ( is_dir( $path ) ) {
1565
+                $path   = trailingslashit( $path );
1566
+                $folder = str_replace( '.php', '', basename( $path ) );
1567
+
1568
+                $folder_fix = str_replace( '_', '-', $folder );
1569
+
1570
+                $files = array(
1571
+                    $path . 'extension_' . $folder . '.php',
1572
+                    $path . 'class-redux-extension-' . $folder_fix . '.php',
1573
+                );
1574
+
1575
+                $ext_file = Redux_Functions::file_exists_ex( $files );
1576
+
1577
+                if ( $ext_file ) {
1578
+                    self::check_extension_class_file( $opt_name, $folder, $ext_file );
1579
+                } else {
1580
+                    $folders = scandir( $path );
1581
+
1582
+                    foreach ( $folders as $folder ) {
1583
+                        if ( '.' === $folder || '..' === $folder ) {
1584
+                            continue;
1585
+                        }
1586
+
1587
+                        if ( is_dir( $path . $folder ) ) {
1588
+                            self::set_extensions( $opt_name, $path . $folder );
1589
+                        }
1590
+                    }
1591
+                }
1592
+            } elseif ( file_exists( $path ) ) {
1593
+                $name = explode( 'extension_', basename( $path ) );
1594
+                if ( ! empty( $name[1] ) ) {
1595
+                    $name = str_replace( '.php', '', $name[1] );
1596
+                    self::check_extension_class_file( $opt_name, $name, $path );
1597
+                }
1598
+            }
1599
+
1600
+            self::$extension_paths[ $opt_name ] = $path;
1601
+
1602
+            if ( true === $force ) {
1603
+                if ( isset( self::$uses_extensions[ $opt_name ] ) && ! empty( self::$uses_extensions[ $opt_name ] ) ) {
1604
+                    $redux = self::instance( $opt_name );
1605
+
1606
+                    if ( isset( $redux ) ) {
1607
+                        self::load_extensions( $redux );
1608
+                    }
1609
+                }
1610
+            }
1611
+        }
1612
+
1613
+        /**
1614
+         * Retrieves all loaded extensions.
1615
+         */
1616
+        private static function get_all_extension() {
1617
+            $redux = self::all_instances();
1618
+
1619
+            foreach ( $redux as $instance ) {
1620
+                if ( ! empty( self::$uses_extensions[ $instance['args']['opt_name'] ] ) ) {
1621
+                    continue;
1622
+                }
1623
+                if ( ! empty( $instance['extensions'] ) ) {
1624
+                    self::get_instance_extension( $instance['args']['opt_name'], $instance );
1625
+                }
1626
+            }
1627
+        }
1628
+
1629
+        /**
1630
+         * Gets all loaded extensions for the passed ReduxFramework instance.
1631
+         *
1632
+         * @param string      $opt_name Panel opt_name.
1633
+         * @param object|null $instance ReduxFramework instance.
1634
+         */
1635
+        public static function get_instance_extension( string $opt_name, $instance ) {
1636
+            if ( ! empty( self::$uses_extensions[ $opt_name ] ) || empty( $opt_name ) ) {
1637
+                return;
1638
+            }
1639
+
1640
+            if ( empty( $instance ) ) {
1641
+                $instance = self::instance( $opt_name );
1642
+            }
1643
+
1644
+            if ( empty( $instance ) || empty( $instance->extensions ) ) {
1645
+                return;
1646
+            }
1647
+
1648
+            foreach ( $instance->extensions as $name => $extension ) {
1649
+                if ( 'widget_areas' === $name ) {
1650
+                    new Redux_Widget_Areas( $instance );
1651
+                }
1652
+
1653
+                if ( isset( self::$uses_extensions[ $opt_name ][ $name ] ) ) {
1654
+                    continue;
1655
+                }
1656
+
1657
+                if ( isset( $extension->extension_dir ) ) {
1658
+                    self::set_extensions( $opt_name, str_replace( $name, '', $extension->extension_dir ) );
1659
+                }
1660
+            }
1661
+        }
1662
+
1663
+        /**
1664
+         * Deprecated Gets loaded extensions.
1665
+         *
1666
+         * @param string $opt_name Panel opt_name.
1667
+         * @param string $key      Extension name.
1668
+         *
1669
+         * @return array|bool|mixed
1670
+         * @deprecated No longer using camelCase naming convention.
1671
+         */
1672
+        public static function getExtensions( string $opt_name = '', string $key = '' ) { // phpcs:ignore WordPress.NamingConventions.ValidFunctionName
1673
+            _deprecated_function( __CLASS__ . '::' . __FUNCTION__, 'Redux 4.0.0', 'self::get_extensions( $opt_name, $key )' );
1674
+
1675
+            return self::get_extensions( $opt_name, $key );
1676
+        }
1677
+
1678
+        /**
1679
+         * Gets loaded extensions.
1680
+         *
1681
+         * @param string $opt_name Panel opt_name.
1682
+         * @param string $key      Extension name.
1683
+         *
1684
+         * @return array|bool|mixed
1685
+         */
1686
+        public static function get_extensions( string $opt_name = '', string $key = '' ) {
1687
+            if ( empty( $opt_name ) ) {
1688
+                self::get_all_extension();
1689
+
1690
+                if ( empty( $key ) ) {
1691
+                    return self::$extension_paths;
1692
+                } elseif ( isset( self::$extension_paths[ $key ] ) ) {
1693
+                        return self::$extension_paths[ $key ];
1694
+                }
1695
+            } else {
1696
+                if ( empty( self::$uses_extensions[ $opt_name ] ) ) {
1697
+                    self::get_instance_extension( $opt_name, null );
1698
+                }
1699
+
1700
+                if ( empty( self::$uses_extensions[ $opt_name ] ) ) {
1701
+                    return false;
1702
+                }
1703
+
1704
+                $instance_extensions = array();
1705
+
1706
+                foreach ( self::$uses_extensions[ $opt_name ] as $extension ) {
1707
+                    $class_file = end( self::$extensions[ $extension ] );
1708
+                    $directory  = explode( DIRECTORY_SEPARATOR, $class_file );
1709
+                    array_pop( $directory );
1710
+                    $directory       = trailingslashit( join( DIRECTORY_SEPARATOR, $directory ) );
1711
+                    $name            = str_replace( '.php', '', basename( $extension ) );
1712
+                    $extension_class = 'Redux_Extension_' . $name;
1713
+                    $the_data        = array(
1714
+                        'path'    => $class_file,
1715
+                        'dir'     => $directory,
1716
+                        'class'   => $extension_class,
1717
+                        'version' => Redux_Helpers::get_template_version( $class_file ),
1718
+                    );
1719
+
1720
+                    if ( is_dir( $the_data['dir'] . $extension ) ) {
1721
+                        $test_path = trailingslashit( $the_data['dir'] . $extension );
1722
+                        if ( file_exists( $test_path . 'field_' . str_replace( '-', '', $extension ) . '.php' ) ) {
1723
+                            $the_data['field'] = $test_path . 'field_' . str_replace( '-', '', $extension ) . '.php';
1724
+                        }
1725
+                        // Old extensions!
1726
+                        if ( file_exists( $test_path . str_replace( '-', '', $extension ) . '.php' ) ) {
1727
+                            $the_data['field'] = $test_path . str_replace( '-', '', $extension ) . '.php';
1728
+                        }
1729
+                    }
1730
+                    $instance_extensions[ $extension ] = $the_data;
1731
+                }
1732
+
1733
+                return $instance_extensions;
1734
+            }
1735
+
1736
+            return false;
1737
+        }
1738
+
1739
+        /**
1740
+         * Method to disables Redux demo mode popup.
1741
+         */
1742
+        public static function disable_demo() {
1743
+            add_action( 'ReduxFrameworkPlugin_admin_notice', 'Redux::remove_demo' );
1744
+            add_action( 'redux_framework_plugin_admin_notice', 'Redux::remove_demo' );
1745
+        }
1746
+
1747
+        /**
1748
+         * Callback used by self::disable_demo() to remove the demo mode notice from Redux.
1749
+         */
1750
+        public static function remove_demo() {
1751
+            update_option( 'ReduxFrameworkPlugin_ACTIVATED_NOTICES', '' );
1752
+        }
1753
+
1754
+        /**
1755
+         * Function which forces a panel/page to render.
1756
+         *
1757
+         * @param string|object $redux Panel opt_name or Redux object.
1758
+         */
1759
+        public static function render( $redux = '' ) {
1760
+            if ( is_string( $redux ) ) {
1761
+                $redux = Redux_Instances::get_instance( $redux );
1762
+                if ( empty( $redux ) ) {
1763
+                    return;
1764
+                }
1765
+            }
1766
+            $enqueue = new Redux_Enqueue( $redux );
1767
+            $enqueue->init();
1768
+            $panel = new Redux_Panel( $redux );
1769
+            $panel->init();
1770
+        }
1771
+    }
1772
+
1773
+    Redux::load();
1774 1774
 }
Please login to merge, or discard this patch.
Spacing   +123 added lines, -125 removed lines patch added patch discarded remove patch
@@ -246,11 +246,11 @@  discard block
 block discarded – undo
246 246
 						require_once $extension['field'];
247 247
 					}
248 248
 
249
-					if ( ! isset( $redux_framework->extensions[ $name ] ) ) {
249
+					if ( ! isset( $redux_framework->extensions[$name] ) ) {
250 250
 						$field_classes = array( $extension['class'], $old_class );
251 251
 						$ext_class     = Redux_Functions::class_exists_ex( $field_classes );
252 252
 						if ( false !== $ext_class ) {
253
-							$redux_framework->extensions[ $name ] = new $ext_class( $redux_framework );
253
+							$redux_framework->extensions[$name] = new $ext_class( $redux_framework );
254 254
 						} elseif ( is_admin() && true === $redux_framework->args['dev_mode'] ) {
255 255
 							echo '<div id="message" class="error"><p>No class named <strong>' . esc_html( $extension['class'] ) . '</strong> exists. Please verify your extension path.</p></div>';
256 256
 						}
@@ -283,11 +283,11 @@  discard block
 block discarded – undo
283 283
 		 * @return bool|mixed
284 284
 		 */
285 285
 		public static function extension_path( string $extension, bool $folder = true ) {
286
-			if ( ! isset( self::$extensions[ $extension ] ) ) {
286
+			if ( ! isset( self::$extensions[$extension] ) ) {
287 287
 				return false;
288 288
 			}
289 289
 
290
-			$path = end( self::$extensions[ $extension ] );
290
+			$path = end( self::$extensions[$extension] );
291 291
 
292 292
 			if ( ! $folder ) {
293 293
 				return $path;
@@ -330,16 +330,16 @@  discard block
 block discarded – undo
330 330
 				}
331 331
 			}
332 332
 
333
-			if ( class_exists( 'Redux_Options_Defaults' ) && ! isset( self::$options_defaults[ $opt_name ] ) ) {
333
+			if ( class_exists( 'Redux_Options_Defaults' ) && ! isset( self::$options_defaults[$opt_name] ) ) {
334 334
 				$sections                            = self::construct_sections( $opt_name );
335 335
 				$wordpress_data                      = ( ! class_exists( 'Redux_WordPress_Data' ) ) ? null : new Redux_WordPress_Data( $opt_name );
336 336
 				$options_defaults_class              = new Redux_Options_Defaults();
337
-				self::$options_defaults[ $opt_name ] = $options_defaults_class->default_values( $opt_name, $sections, $wordpress_data );
338
-				if ( ! isset( self::$args[ $opt_name ]['global_variable'] ) || ( '' === self::$args[ $opt_name ]['global_variable'] && false !== self::$args[ $opt_name ]['global_variable'] ) ) {
339
-					self::$args[ $opt_name ]['global_variable'] = str_replace( '-', '_', $opt_name );
337
+				self::$options_defaults[$opt_name] = $options_defaults_class->default_values( $opt_name, $sections, $wordpress_data );
338
+				if ( ! isset( self::$args[$opt_name]['global_variable'] ) || ( '' === self::$args[$opt_name]['global_variable'] && false !== self::$args[$opt_name]['global_variable'] ) ) {
339
+					self::$args[$opt_name]['global_variable'] = str_replace( '-', '_', $opt_name );
340 340
 				}
341
-				if ( isset( self::$args[ $opt_name ]['global_variable'] ) && self::$args[ $opt_name ]['global_variable'] ) {
342
-					$option_global = self::$args[ $opt_name ]['global_variable'];
341
+				if ( isset( self::$args[$opt_name]['global_variable'] ) && self::$args[$opt_name]['global_variable'] ) {
342
+					$option_global = self::$args[$opt_name]['global_variable'];
343 343
 
344 344
 					/**
345 345
 					 * Filter 'redux/options/{opt_name}/global_variable'
@@ -349,7 +349,7 @@  discard block
 block discarded – undo
349 349
 					global $$option_global;
350 350
 
351 351
 					// phpcs:ignore WordPress.NamingConventions.ValidHookName, WordPress.NamingConventions.PrefixAllGlobals
352
-					$$option_global = apply_filters( 'redux/options/' . $opt_name . '/global_variable', self::$options_defaults[ $opt_name ] );
352
+					$$option_global = apply_filters( 'redux/options/' . $opt_name . '/global_variable', self::$options_defaults[$opt_name] );
353 353
 				}
354 354
 			}
355 355
 		}
@@ -367,7 +367,7 @@  discard block
 block discarded – undo
367 367
 			}
368 368
 
369 369
 			if ( class_exists( 'ReduxFramework' ) ) {
370
-				if ( isset( self::$init[ $opt_name ] ) && ! empty( self::$init[ $opt_name ] ) ) {
370
+				if ( isset( self::$init[$opt_name] ) && ! empty( self::$init[$opt_name] ) ) {
371 371
 					return;
372 372
 				}
373 373
 			} else {
@@ -380,7 +380,7 @@  discard block
 block discarded – undo
380 380
 
381 381
 			Redux_Functions_Ex::record_caller( $opt_name );
382 382
 
383
-			if ( isset( self::$init[ $opt_name ] ) && 1 === self::$init[ $opt_name ] ) {
383
+			if ( isset( self::$init[$opt_name] ) && 1 === self::$init[$opt_name] ) {
384 384
 				return;
385 385
 			}
386 386
 
@@ -389,15 +389,15 @@  discard block
 block discarded – undo
389 389
 			$args     = self::construct_args( $opt_name );
390 390
 			$sections = self::construct_sections( $opt_name );
391 391
 
392
-			if ( isset( self::$uses_extensions[ $opt_name ] ) && ! empty( self::$uses_extensions[ $opt_name ] ) ) {
392
+			if ( isset( self::$uses_extensions[$opt_name] ) && ! empty( self::$uses_extensions[$opt_name] ) ) {
393 393
 				add_action( "redux/extensions/$opt_name/before", array( 'Redux', 'load_extensions' ), 0 );
394 394
 			}
395 395
 
396 396
 			$redux                   = new ReduxFramework( $sections, $args );
397
-			self::$init[ $opt_name ] = 1;
397
+			self::$init[$opt_name] = 1;
398 398
 
399 399
 			if ( isset( $redux->args['opt_name'] ) && $redux->args['opt_name'] !== $opt_name ) {
400
-				self::$init[ $redux->args['opt_name'] ] = 1;
400
+				self::$init[$redux->args['opt_name']] = 1;
401 401
 			}
402 402
 		}
403 403
 
@@ -422,7 +422,7 @@  discard block
 block discarded – undo
422 422
 		public static function create_redux() {
423 423
 			foreach ( self::$sections as $opt_name => $the_sections ) {
424 424
 				if ( ! empty( $the_sections ) ) {
425
-					if ( ! self::$init[ $opt_name ] ) {
425
+					if ( ! self::$init[$opt_name] ) {
426 426
 						self::load_redux( $opt_name );
427 427
 					}
428 428
 				}
@@ -437,7 +437,7 @@  discard block
 block discarded – undo
437 437
 		 * @return array|mixed
438 438
 		 */
439 439
 		public static function construct_args( string $opt_name ) {
440
-			$args             = self::$args[ $opt_name ] ?? array();
440
+			$args             = self::$args[$opt_name] ?? array();
441 441
 			$args['opt_name'] = $opt_name;
442 442
 
443 443
 			if ( ! isset( $args['menu_title'] ) ) {
@@ -465,19 +465,19 @@  discard block
 block discarded – undo
465 465
 		public static function construct_sections( string $opt_name ): array {
466 466
 			$sections = array();
467 467
 
468
-			if ( ! isset( self::$sections[ $opt_name ] ) ) {
468
+			if ( ! isset( self::$sections[$opt_name] ) ) {
469 469
 				return $sections;
470 470
 			}
471 471
 
472
-			foreach ( self::$sections[ $opt_name ] as $section_id => $section ) {
472
+			foreach ( self::$sections[$opt_name] as $section_id => $section ) {
473 473
 				$section['fields'] = self::construct_fields( $opt_name, $section_id );
474 474
 				$p                 = $section['priority'];
475 475
 
476
-				while ( isset( $sections[ $p ] ) ) {
476
+				while ( isset( $sections[$p] ) ) {
477 477
 					++$p;
478 478
 				}
479 479
 
480
-				$sections[ $p ] = $section;
480
+				$sections[$p] = $section;
481 481
 			}
482 482
 
483 483
 			ksort( $sections );
@@ -496,16 +496,16 @@  discard block
 block discarded – undo
496 496
 		public static function construct_fields( string $opt_name = '', string $section_id = '' ): array {
497 497
 			$fields = array();
498 498
 
499
-			if ( ! empty( self::$fields[ $opt_name ] ) ) {
500
-				foreach ( self::$fields[ $opt_name ] as $field ) {
499
+			if ( ! empty( self::$fields[$opt_name] ) ) {
500
+				foreach ( self::$fields[$opt_name] as $field ) {
501 501
 					if ( $field['section_id'] === $section_id ) {
502 502
 						$p = esc_html( $field['priority'] );
503 503
 
504
-						while ( isset( $fields[ $p ] ) ) {
504
+						while ( isset( $fields[$p] ) ) {
505 505
 							echo intval( $p++ );
506 506
 						}
507 507
 
508
-						$fields[ $p ] = $field;
508
+						$fields[$p] = $field;
509 509
 					}
510 510
 				}
511 511
 			}
@@ -542,11 +542,11 @@  discard block
 block discarded – undo
542 542
 			self::check_opt_name( $opt_name );
543 543
 
544 544
 			if ( ! empty( $opt_name ) && ! empty( $id ) ) {
545
-				if ( ! isset( self::$sections[ $opt_name ][ $id ] ) ) {
545
+				if ( ! isset( self::$sections[$opt_name][$id] ) ) {
546 546
 					$id = Redux_Core::strtolower( sanitize_html_class( $id ) );
547 547
 				}
548 548
 
549
-				return self::$sections[ $opt_name ][ $id ] ?? false;
549
+				return self::$sections[$opt_name][$id] ?? false;
550 550
 			}
551 551
 
552 552
 			return false;
@@ -614,8 +614,8 @@  discard block
 block discarded – undo
614 614
 		public static function get_sections( string $opt_name = '' ) {
615 615
 			self::check_opt_name( $opt_name );
616 616
 
617
-			if ( ! empty( self::$sections[ $opt_name ] ) ) {
618
-				return self::$sections[ $opt_name ];
617
+			if ( ! empty( self::$sections[$opt_name] ) ) {
618
+				return self::$sections[$opt_name];
619 619
 			}
620 620
 
621 621
 			return array();
@@ -651,28 +651,27 @@  discard block
 block discarded – undo
651 651
 			if ( '' !== $opt_name && '' !== $id ) {
652 652
 				Redux_Functions_Ex::record_caller( $opt_name );
653 653
 
654
-				if ( isset( self::$sections[ $opt_name ][ $id ] ) ) {
654
+				if ( isset( self::$sections[$opt_name][$id] ) ) {
655 655
 					$priority = '';
656 656
 
657
-					foreach ( self::$sections[ $opt_name ] as $key => $section ) {
657
+					foreach ( self::$sections[$opt_name] as $key => $section ) {
658 658
 						if ( $key === $id ) {
659
-							$priority = $section['priority'];
660
-							--self::$priority[ $opt_name ]['sections'];
661
-							unset( self::$sections[ $opt_name ][ $id ] );
659
+							$priority = $section['priority'];--self::$priority[$opt_name]['sections'];
660
+							unset( self::$sections[$opt_name][$id] );
662 661
 							continue;
663 662
 						}
664 663
 						if ( '' !== $priority ) {
665 664
 							$new_priority                        = $section['priority'];
666 665
 							$section['priority']                 = $priority;
667
-							self::$sections[ $opt_name ][ $key ] = $section;
666
+							self::$sections[$opt_name][$key] = $section;
668 667
 							$priority                            = $new_priority;
669 668
 						}
670 669
 					}
671 670
 
672
-					if ( isset( self::$fields[ $opt_name ] ) && ! empty( self::$fields[ $opt_name ] ) && true === $fields ) {
673
-						foreach ( self::$fields[ $opt_name ] as $key => $field ) {
671
+					if ( isset( self::$fields[$opt_name] ) && ! empty( self::$fields[$opt_name] ) && true === $fields ) {
672
+						foreach ( self::$fields[$opt_name] as $key => $field ) {
674 673
 							if ( $field['section_id'] === $id ) {
675
-								unset( self::$fields[ $opt_name ][ $key ] );
674
+								unset( self::$fields[$opt_name][$key] );
676 675
 							}
677 676
 						}
678 677
 					}
@@ -725,24 +724,24 @@  discard block
 block discarded – undo
725 724
 					$section['id'] = time();
726 725
 				}
727 726
 
728
-				if ( isset( self::$sections[ $opt_name ][ $section['id'] ] ) && ! $replace ) {
727
+				if ( isset( self::$sections[$opt_name][$section['id']] ) && ! $replace ) {
729 728
 					$orig = $section['id'];
730 729
 					$i    = 0;
731 730
 
732
-					while ( isset( self::$sections[ $opt_name ][ $section['id'] ] ) ) {
731
+					while ( isset( self::$sections[$opt_name][$section['id']] ) ) {
733 732
 						$section['id'] = $orig . '_' . $i;
734 733
 						++$i;
735 734
 					}
736
-				} elseif ( isset( self::$sections[ $opt_name ][ $section['id'] ] ) && $replace ) {
735
+				} elseif ( isset( self::$sections[$opt_name][$section['id']] ) && $replace ) {
737 736
 					// If replace is set, let's update the default values with these!
738 737
 					$fields = false;
739
-					if ( isset( self::$sections[ $opt_name ][ $section['id'] ]['fields'] ) && ! empty( self::$sections[ $opt_name ][ $section['id'] ]['fields'] ) ) {
740
-						$fields = self::$sections[ $opt_name ][ $section['id'] ]['fields'];
738
+					if ( isset( self::$sections[$opt_name][$section['id']]['fields'] ) && ! empty( self::$sections[$opt_name][$section['id']]['fields'] ) ) {
739
+						$fields = self::$sections[$opt_name][$section['id']]['fields'];
741 740
 					}
742
-					self::$sections[ $opt_name ][ $section['id'] ] = wp_parse_args( $section, self::$sections[ $opt_name ][ $section['id'] ] );
741
+					self::$sections[$opt_name][$section['id']] = wp_parse_args( $section, self::$sections[$opt_name][$section['id']] );
743 742
 					if ( ! empty( $fields ) ) {
744
-						if ( ! isset( self::$sections[ $opt_name ][ $section['id'] ]['fields'] ) || ( isset( self::$sections[ $opt_name ][ $section['id'] ]['fields'] ) && empty( self::$sections[ $opt_name ][ $section['id'] ]['fields'] ) ) ) {
745
-							self::$sections[ $opt_name ][ $section['id'] ]['fields'] = $fields;
743
+						if ( ! isset( self::$sections[$opt_name][$section['id']]['fields'] ) || ( isset( self::$sections[$opt_name][$section['id']]['fields'] ) && empty( self::$sections[$opt_name][$section['id']]['fields'] ) ) ) {
744
+							self::$sections[$opt_name][$section['id']]['fields'] = $fields;
746 745
 						}
747 746
 					}
748 747
 				}
@@ -750,7 +749,7 @@  discard block
 block discarded – undo
750 749
 
751 750
 			if ( ! empty( $opt_name ) && is_array( $section ) && ! empty( $section ) ) {
752 751
 				if ( ! isset( $section['id'] ) && ! isset( $section['title'] ) ) {
753
-					self::$errors[ $opt_name ]['section']['missing_title'] = esc_html__( 'Unable to create a section due to missing id and title.', 'redux-framework' );
752
+					self::$errors[$opt_name]['section']['missing_title'] = esc_html__( 'Unable to create a section due to missing id and title.', 'redux-framework' );
754 753
 
755 754
 					return;
756 755
 				}
@@ -765,9 +764,9 @@  discard block
 block discarded – undo
765 764
 					}
766 765
 					unset( $section['fields'] );
767 766
 				}
768
-				self::$sections[ $opt_name ][ $section['id'] ] = $section;
767
+				self::$sections[$opt_name][$section['id']] = $section;
769 768
 			} else {
770
-				self::$errors[ $opt_name ]['section']['empty'] = esc_html__( 'Unable to create a section due an empty section array or the section variable passed was not an array.', 'redux-framework' );
769
+				self::$errors[$opt_name]['section']['empty'] = esc_html__( 'Unable to create a section due an empty section array or the section variable passed was not an array.', 'redux-framework' );
771 770
 			}
772 771
 		}
773 772
 
@@ -803,8 +802,8 @@  discard block
 block discarded – undo
803 802
 			if ( '' !== $opt_name && '' !== $id ) {
804 803
 				Redux_Functions_Ex::record_caller( $opt_name );
805 804
 
806
-				if ( isset( self::$sections[ $opt_name ][ $id ] ) ) {
807
-					self::$sections[ $opt_name ][ $id ]['hidden'] = $hide;
805
+				if ( isset( self::$sections[$opt_name][$id] ) ) {
806
+					self::$sections[$opt_name][$id]['hidden'] = $hide;
808 807
 				}
809 808
 			}
810 809
 		}
@@ -854,7 +853,7 @@  discard block
 block discarded – undo
854 853
 			self::check_opt_name( $opt_name );
855 854
 
856 855
 			if ( ! empty( $opt_name ) && ! empty( $id ) ) {
857
-				return self::$fields[ $opt_name ][ $id ] ?? false;
856
+				return self::$fields[$opt_name][$id] ?? false;
858 857
 			}
859 858
 
860 859
 			return false;
@@ -890,13 +889,13 @@  discard block
 block discarded – undo
890 889
 			self::check_opt_name( $opt_name );
891 890
 
892 891
 			if ( '' !== $opt_name && '' !== $id ) {
893
-				if ( isset( self::$fields[ $opt_name ][ $id ] ) ) {
892
+				if ( isset( self::$fields[$opt_name][$id] ) ) {
894 893
 					Redux_Functions_Ex::record_caller( $opt_name );
895 894
 
896 895
 					if ( ! $hide ) {
897
-						self::$fields[ $opt_name ][ $id ]['class'] = str_replace( 'hidden', '', self::$fields[ $opt_name ][ $id ]['class'] );
896
+						self::$fields[$opt_name][$id]['class'] = str_replace( 'hidden', '', self::$fields[$opt_name][$id]['class'] );
898 897
 					} else {
899
-						self::$fields[ $opt_name ][ $id ]['class'] .= 'hidden';
898
+						self::$fields[$opt_name][$id]['class'] .= 'hidden';
900 899
 					}
901 900
 				}
902 901
 			}
@@ -953,7 +952,7 @@  discard block
 block discarded – undo
953 952
 			}
954 953
 			$field['id'] = $field['id'] ?? "{$opt_name}_{$section_id}_{$field['type']}_" . wp_rand( 1, 9999 );
955 954
 
956
-			self::$fields[ $opt_name ][ $field['id'] ] = $field;
955
+			self::$fields[$opt_name][$field['id']] = $field;
957 956
 		}
958 957
 
959 958
 		/**
@@ -1013,19 +1012,18 @@  discard block
 block discarded – undo
1013 1012
 
1014 1013
 				Redux_Functions_Ex::record_caller( $opt_name );
1015 1014
 
1016
-				if ( isset( self::$fields[ $opt_name ][ $id ] ) ) {
1017
-					foreach ( self::$fields[ $opt_name ] as $key => $field ) {
1015
+				if ( isset( self::$fields[$opt_name][$id] ) ) {
1016
+					foreach ( self::$fields[$opt_name] as $key => $field ) {
1018 1017
 						if ( $key === $id ) {
1019
-							$priority = $field['priority'];
1020
-							--self::$priority[ $opt_name ]['fields'];
1021
-							unset( self::$fields[ $opt_name ][ $id ] );
1018
+							$priority = $field['priority'];--self::$priority[$opt_name]['fields'];
1019
+							unset( self::$fields[$opt_name][$id] );
1022 1020
 							continue;
1023 1021
 						}
1024 1022
 
1025 1023
 						if ( isset( $priority ) && '' !== $priority ) {
1026 1024
 							$new_priority                      = $field['priority'];
1027 1025
 							$field['priority']                 = $priority;
1028
-							self::$fields[ $opt_name ][ $key ] = $field;
1026
+							self::$fields[$opt_name][$key] = $field;
1029 1027
 							$priority                          = $new_priority;
1030 1028
 						}
1031 1029
 					}
@@ -1063,15 +1061,15 @@  discard block
 block discarded – undo
1063 1061
 			self::check_opt_name( $opt_name );
1064 1062
 
1065 1063
 			if ( '' !== $opt_name ) {
1066
-				if ( ! isset( self::$args[ $opt_name ]['help_tabs'] ) ) {
1067
-					self::$args[ $opt_name ]['help_tabs'] = array();
1064
+				if ( ! isset( self::$args[$opt_name]['help_tabs'] ) ) {
1065
+					self::$args[$opt_name]['help_tabs'] = array();
1068 1066
 				}
1069 1067
 
1070 1068
 				if ( isset( $tab['id'] ) ) {
1071
-					self::$args[ $opt_name ]['help_tabs'][] = $tab;
1069
+					self::$args[$opt_name]['help_tabs'][] = $tab;
1072 1070
 				} elseif ( is_array( end( $tab ) ) ) {
1073 1071
 					foreach ( $tab as $tab_item ) {
1074
-						self::$args[ $opt_name ]['help_tabs'][] = $tab_item;
1072
+						self::$args[$opt_name]['help_tabs'][] = $tab_item;
1075 1073
 					}
1076 1074
 				}
1077 1075
 			}
@@ -1103,7 +1101,7 @@  discard block
 block discarded – undo
1103 1101
 			}
1104 1102
 			self::check_opt_name( $opt_name );
1105 1103
 
1106
-			self::$args[ $opt_name ]['help_sidebar'] = $content;
1104
+			self::$args[$opt_name]['help_sidebar'] = $content;
1107 1105
 		}
1108 1106
 
1109 1107
 		/**
@@ -1141,10 +1139,10 @@  discard block
 block discarded – undo
1141 1139
 			Redux_Functions_Ex::record_caller( $opt_name );
1142 1140
 
1143 1141
 			if ( is_array( $args ) ) {
1144
-				if ( isset( self::$args[ $opt_name ]['clearArgs'] ) ) {
1145
-					self::$args[ $opt_name ] = array();
1142
+				if ( isset( self::$args[$opt_name]['clearArgs'] ) ) {
1143
+					self::$args[$opt_name] = array();
1146 1144
 				}
1147
-				self::$args[ $opt_name ] = wp_parse_args( $args, self::$args[ $opt_name ] );
1145
+				self::$args[$opt_name] = wp_parse_args( $args, self::$args[$opt_name] );
1148 1146
 			}
1149 1147
 		}
1150 1148
 
@@ -1163,7 +1161,7 @@  discard block
 block discarded – undo
1163 1161
 
1164 1162
 			Redux_Functions_Ex::record_caller( $opt_name );
1165 1163
 
1166
-			self::$args[ $opt_name ]['developer'] = $arg;
1164
+			self::$args[$opt_name]['developer'] = $arg;
1167 1165
 		}
1168 1166
 
1169 1167
 		/**
@@ -1192,13 +1190,13 @@  discard block
 block discarded – undo
1192 1190
 			self::check_opt_name( $opt_name );
1193 1191
 
1194 1192
 			if ( ! empty( $opt_name ) && ! empty( $key ) ) {
1195
-				if ( ! empty( self::$args[ $opt_name ] ) ) {
1196
-					return self::$args[ $opt_name ][ $key ];
1193
+				if ( ! empty( self::$args[$opt_name] ) ) {
1194
+					return self::$args[$opt_name][$key];
1197 1195
 				} else {
1198 1196
 					return null;
1199 1197
 				}
1200
-			} elseif ( ! empty( $opt_name ) && ! empty( self::$args[ $opt_name ] ) ) {
1201
-				return self::$args[ $opt_name ];
1198
+			} elseif ( ! empty( $opt_name ) && ! empty( self::$args[$opt_name] ) ) {
1199
+				return self::$args[$opt_name];
1202 1200
 			}
1203 1201
 
1204 1202
 			return null;
@@ -1230,8 +1228,8 @@  discard block
 block discarded – undo
1230 1228
 		public static function get_arg( string $opt_name = '', string $key = '' ) {
1231 1229
 			self::check_opt_name( $opt_name );
1232 1230
 
1233
-			if ( ! empty( $opt_name ) && ! empty( $key ) && ! empty( self::$args[ $opt_name ] ) ) {
1234
-				return self::$args[ $opt_name ][ $key ];
1231
+			if ( ! empty( $opt_name ) && ! empty( $key ) && ! empty( self::$args[$opt_name] ) ) {
1232
+				return self::$args[$opt_name][$key];
1235 1233
 			} else {
1236 1234
 				return null;
1237 1235
 			}
@@ -1318,7 +1316,7 @@  discard block
 block discarded – undo
1318 1316
 					$values = $$opt_name;
1319 1317
 				}
1320 1318
 
1321
-				if ( ! isset( $values[ $key ] ) ) {
1319
+				if ( ! isset( $values[$key] ) ) {
1322 1320
 					if ( null === $default ) {
1323 1321
 						$field = self::get_field( $opt_name, $key );
1324 1322
 
@@ -1327,8 +1325,8 @@  discard block
 block discarded – undo
1327 1325
 							$sections       = self::construct_sections( $opt_name );
1328 1326
 							$defaults       = $defaults_class->default_values( $opt_name, $sections );
1329 1327
 
1330
-							if ( isset( $defaults[ $key ] ) ) {
1331
-								$default = $defaults[ $key ];
1328
+							if ( isset( $defaults[$key] ) ) {
1329
+								$default = $defaults[$key];
1332 1330
 							}
1333 1331
 						}
1334 1332
 					}
@@ -1337,25 +1335,25 @@  discard block
 block discarded – undo
1337 1335
 				if ( ! empty( $subkeys ) && is_array( $subkeys ) ) {
1338 1336
 					$value = $default;
1339 1337
 
1340
-					if ( isset( $values[ $key ] ) ) {
1338
+					if ( isset( $values[$key] ) ) {
1341 1339
 						$count = count( $subkeys );
1342 1340
 
1343 1341
 						if ( 1 === $count ) {
1344
-							$value = $values[ $key ][ $subkeys[1] ] ?? $default;
1342
+							$value = $values[$key][$subkeys[1]] ?? $default;
1345 1343
 						} elseif ( 2 === $count ) {
1346
-							if ( isset( $values[ $key ][ $subkeys[1] ] ) ) {
1347
-								$value = $values[ $key ][ $subkeys[1] ][ $subkeys[2] ] ?? $default;
1344
+							if ( isset( $values[$key][$subkeys[1]] ) ) {
1345
+								$value = $values[$key][$subkeys[1]][$subkeys[2]] ?? $default;
1348 1346
 							}
1349 1347
 						} elseif ( 3 === $count ) {
1350
-							if ( isset( $values[ $key ][ $subkeys[1] ] ) ) {
1351
-								if ( isset( $values[ $key ][ $subkeys[1] ][ $subkeys[2] ] ) ) {
1352
-									$value = $values[ $key ][ $subkeys[1] ][ $subkeys[2] ][ $subkeys[3] ] ?? $default;
1348
+							if ( isset( $values[$key][$subkeys[1]] ) ) {
1349
+								if ( isset( $values[$key][$subkeys[1]][$subkeys[2]] ) ) {
1350
+									$value = $values[$key][$subkeys[1]][$subkeys[2]][$subkeys[3]] ?? $default;
1353 1351
 								}
1354 1352
 							}
1355 1353
 						}
1356 1354
 					}
1357 1355
 				} else {
1358
-					$value = $values[ $key ] ?? $default;
1356
+					$value = $values[$key] ?? $default;
1359 1357
 				}
1360 1358
 
1361 1359
 				return $value;
@@ -1404,7 +1402,7 @@  discard block
 block discarded – undo
1404 1402
 
1405 1403
 			if ( '' !== $opt_name ) {
1406 1404
 				$redux         = get_option( $opt_name );
1407
-				$redux[ $key ] = $option;
1405
+				$redux[$key] = $option;
1408 1406
 
1409 1407
 				return update_option( $opt_name, $redux );
1410 1408
 			} else {
@@ -1421,8 +1419,8 @@  discard block
 block discarded – undo
1421 1419
 		 * @return mixed
1422 1420
 		 */
1423 1421
 		public static function get_priority( string $opt_name, string $type ) {
1424
-			$priority                              = self::$priority[ $opt_name ][ $type ];
1425
-			self::$priority[ $opt_name ][ $type ] += 1;
1422
+			$priority                              = self::$priority[$opt_name][$type];
1423
+			self::$priority[$opt_name][$type] += 1;
1426 1424
 
1427 1425
 			return $priority;
1428 1426
 		}
@@ -1437,32 +1435,32 @@  discard block
 block discarded – undo
1437 1435
 				return;
1438 1436
 			}
1439 1437
 
1440
-			if ( ! isset( self::$sections[ $opt_name ] ) ) {
1441
-				self::$sections[ $opt_name ]             = array();
1442
-				self::$priority[ $opt_name ]['sections'] = 1;
1438
+			if ( ! isset( self::$sections[$opt_name] ) ) {
1439
+				self::$sections[$opt_name]             = array();
1440
+				self::$priority[$opt_name]['sections'] = 1;
1443 1441
 			}
1444 1442
 
1445
-			if ( ! isset( self::$args[ $opt_name ] ) ) {
1446
-				self::$args[ $opt_name ]             = array();
1447
-				self::$priority[ $opt_name ]['args'] = 1;
1443
+			if ( ! isset( self::$args[$opt_name] ) ) {
1444
+				self::$args[$opt_name]             = array();
1445
+				self::$priority[$opt_name]['args'] = 1;
1448 1446
 			}
1449 1447
 
1450
-			if ( ! isset( self::$fields[ $opt_name ] ) ) {
1451
-				self::$fields[ $opt_name ]             = array();
1452
-				self::$priority[ $opt_name ]['fields'] = 1;
1448
+			if ( ! isset( self::$fields[$opt_name] ) ) {
1449
+				self::$fields[$opt_name]             = array();
1450
+				self::$priority[$opt_name]['fields'] = 1;
1453 1451
 			}
1454 1452
 
1455
-			if ( ! isset( self::$help[ $opt_name ] ) ) {
1456
-				self::$help[ $opt_name ]             = array();
1457
-				self::$priority[ $opt_name ]['help'] = 1;
1453
+			if ( ! isset( self::$help[$opt_name] ) ) {
1454
+				self::$help[$opt_name]             = array();
1455
+				self::$priority[$opt_name]['help'] = 1;
1458 1456
 			}
1459 1457
 
1460
-			if ( ! isset( self::$errors[ $opt_name ] ) ) {
1461
-				self::$errors[ $opt_name ] = array();
1458
+			if ( ! isset( self::$errors[$opt_name] ) ) {
1459
+				self::$errors[$opt_name] = array();
1462 1460
 			}
1463 1461
 
1464
-			if ( ! isset( self::$init[ $opt_name ] ) ) {
1465
-				self::$init[ $opt_name ] = false;
1462
+			if ( ! isset( self::$init[$opt_name] ) ) {
1463
+				self::$init[$opt_name] = false;
1466 1464
 			}
1467 1465
 		}
1468 1466
 
@@ -1491,13 +1489,13 @@  discard block
 block discarded – undo
1491 1489
 			$instance = null;
1492 1490
 
1493 1491
 			if ( file_exists( $class_file ) ) {
1494
-				self::$uses_extensions[ $opt_name ] = self::$uses_extensions[ $opt_name ] ?? array();
1492
+				self::$uses_extensions[$opt_name] = self::$uses_extensions[$opt_name] ?? array();
1495 1493
 
1496
-				if ( ! in_array( $name, self::$uses_extensions[ $opt_name ], true ) ) {
1497
-					self::$uses_extensions[ $opt_name ][] = $name;
1494
+				if ( ! in_array( $name, self::$uses_extensions[$opt_name], true ) ) {
1495
+					self::$uses_extensions[$opt_name][] = $name;
1498 1496
 				}
1499 1497
 
1500
-				self::$extensions[ $name ] = self::$extensions[ $name ] ?? array();
1498
+				self::$extensions[$name] = self::$extensions[$name] ?? array();
1501 1499
 
1502 1500
 				$version = Redux_Helpers::get_template_version( $class_file );
1503 1501
 
@@ -1506,7 +1504,7 @@  discard block
 block discarded – undo
1506 1504
 						$version = $instance->version;
1507 1505
 					}
1508 1506
 				}
1509
-				self::$extensions[ $name ][ $version ] = self::$extensions[ $name ][ $version ] ?? $class_file;
1507
+				self::$extensions[$name][$version] = self::$extensions[$name][$version] ?? $class_file;
1510 1508
 
1511 1509
 				$new_name  = str_replace( '_', '-', $name );
1512 1510
 				$api_check = str_replace(
@@ -1597,10 +1595,10 @@  discard block
 block discarded – undo
1597 1595
 				}
1598 1596
 			}
1599 1597
 
1600
-			self::$extension_paths[ $opt_name ] = $path;
1598
+			self::$extension_paths[$opt_name] = $path;
1601 1599
 
1602 1600
 			if ( true === $force ) {
1603
-				if ( isset( self::$uses_extensions[ $opt_name ] ) && ! empty( self::$uses_extensions[ $opt_name ] ) ) {
1601
+				if ( isset( self::$uses_extensions[$opt_name] ) && ! empty( self::$uses_extensions[$opt_name] ) ) {
1604 1602
 					$redux = self::instance( $opt_name );
1605 1603
 
1606 1604
 					if ( isset( $redux ) ) {
@@ -1617,7 +1615,7 @@  discard block
 block discarded – undo
1617 1615
 			$redux = self::all_instances();
1618 1616
 
1619 1617
 			foreach ( $redux as $instance ) {
1620
-				if ( ! empty( self::$uses_extensions[ $instance['args']['opt_name'] ] ) ) {
1618
+				if ( ! empty( self::$uses_extensions[$instance['args']['opt_name']] ) ) {
1621 1619
 					continue;
1622 1620
 				}
1623 1621
 				if ( ! empty( $instance['extensions'] ) ) {
@@ -1633,7 +1631,7 @@  discard block
 block discarded – undo
1633 1631
 		 * @param object|null $instance ReduxFramework instance.
1634 1632
 		 */
1635 1633
 		public static function get_instance_extension( string $opt_name, $instance ) {
1636
-			if ( ! empty( self::$uses_extensions[ $opt_name ] ) || empty( $opt_name ) ) {
1634
+			if ( ! empty( self::$uses_extensions[$opt_name] ) || empty( $opt_name ) ) {
1637 1635
 				return;
1638 1636
 			}
1639 1637
 
@@ -1650,7 +1648,7 @@  discard block
 block discarded – undo
1650 1648
 					new Redux_Widget_Areas( $instance );
1651 1649
 				}
1652 1650
 
1653
-				if ( isset( self::$uses_extensions[ $opt_name ][ $name ] ) ) {
1651
+				if ( isset( self::$uses_extensions[$opt_name][$name] ) ) {
1654 1652
 					continue;
1655 1653
 				}
1656 1654
 
@@ -1689,22 +1687,22 @@  discard block
 block discarded – undo
1689 1687
 
1690 1688
 				if ( empty( $key ) ) {
1691 1689
 					return self::$extension_paths;
1692
-				} elseif ( isset( self::$extension_paths[ $key ] ) ) {
1693
-						return self::$extension_paths[ $key ];
1690
+				} elseif ( isset( self::$extension_paths[$key] ) ) {
1691
+						return self::$extension_paths[$key];
1694 1692
 				}
1695 1693
 			} else {
1696
-				if ( empty( self::$uses_extensions[ $opt_name ] ) ) {
1694
+				if ( empty( self::$uses_extensions[$opt_name] ) ) {
1697 1695
 					self::get_instance_extension( $opt_name, null );
1698 1696
 				}
1699 1697
 
1700
-				if ( empty( self::$uses_extensions[ $opt_name ] ) ) {
1698
+				if ( empty( self::$uses_extensions[$opt_name] ) ) {
1701 1699
 					return false;
1702 1700
 				}
1703 1701
 
1704 1702
 				$instance_extensions = array();
1705 1703
 
1706
-				foreach ( self::$uses_extensions[ $opt_name ] as $extension ) {
1707
-					$class_file = end( self::$extensions[ $extension ] );
1704
+				foreach ( self::$uses_extensions[$opt_name] as $extension ) {
1705
+					$class_file = end( self::$extensions[$extension] );
1708 1706
 					$directory  = explode( DIRECTORY_SEPARATOR, $class_file );
1709 1707
 					array_pop( $directory );
1710 1708
 					$directory       = trailingslashit( join( DIRECTORY_SEPARATOR, $directory ) );
@@ -1727,7 +1725,7 @@  discard block
 block discarded – undo
1727 1725
 							$the_data['field'] = $test_path . str_replace( '-', '', $extension ) . '.php';
1728 1726
 						}
1729 1727
 					}
1730
-					$instance_extensions[ $extension ] = $the_data;
1728
+					$instance_extensions[$extension] = $the_data;
1731 1729
 				}
1732 1730
 
1733 1731
 				return $instance_extensions;
Please login to merge, or discard this patch.
redux-core/templates/panel/menu-container.tpl.php 1 patch
Indentation   +23 added lines, -23 removed lines patch added patch discarded remove patch
@@ -12,31 +12,31 @@
 block discarded – undo
12 12
 <div class="redux-sidebar">
13 13
 	<ul class="redux-group-menu">
14 14
 		<?php
15
-		foreach ( $this->parent->sections as $redux_key => $redux_section ) {
16
-			$redux_the_title = $redux_section['title'] ?? '';
17
-			$redux_skip_sec  = false;
18
-			foreach ( $this->parent->options_class->hidden_perm_sections as $redux_num => $redux_section_title ) {
19
-				if ( $redux_section_title === $redux_the_title ) {
20
-					$redux_skip_sec = true;
21
-				}
22
-			}
15
+        foreach ( $this->parent->sections as $redux_key => $redux_section ) {
16
+            $redux_the_title = $redux_section['title'] ?? '';
17
+            $redux_skip_sec  = false;
18
+            foreach ( $this->parent->options_class->hidden_perm_sections as $redux_num => $redux_section_title ) {
19
+                if ( $redux_section_title === $redux_the_title ) {
20
+                    $redux_skip_sec = true;
21
+                }
22
+            }
23 23
 
24
-			if ( isset( $redux_section['customizer_only'] ) && true === $redux_section['customizer_only'] ) {
25
-				continue;
26
-			}
24
+            if ( isset( $redux_section['customizer_only'] ) && true === $redux_section['customizer_only'] ) {
25
+                continue;
26
+            }
27 27
 
28
-			if ( false === $redux_skip_sec ) {
29
-				echo( $this->parent->render_class->section_menu( $redux_key, $redux_section ) ); // phpcs:ignore WordPress.Security.EscapeOutput
30
-				$redux_skip_sec = false;
31
-			}
32
-		}
28
+            if ( false === $redux_skip_sec ) {
29
+                echo( $this->parent->render_class->section_menu( $redux_key, $redux_section ) ); // phpcs:ignore WordPress.Security.EscapeOutput
30
+                $redux_skip_sec = false;
31
+            }
32
+        }
33 33
 
34
-		/**
35
-		 * Action 'redux/page/{opt_name}/menu/after'
36
-		 *
37
-		 * @param object $this ReduxFramework
38
-		 */
39
-		do_action( "redux/page/{$this->parent->args['opt_name']}/menu/after", $this ); // phpcs:ignore WordPress.NamingConventions.ValidHookName
40
-		?>
34
+        /**
35
+         * Action 'redux/page/{opt_name}/menu/after'
36
+         *
37
+         * @param object $this ReduxFramework
38
+         */
39
+        do_action( "redux/page/{$this->parent->args['opt_name']}/menu/after", $this ); // phpcs:ignore WordPress.NamingConventions.ValidHookName
40
+        ?>
41 41
 	</ul>
42 42
 </div>
Please login to merge, or discard this patch.