Completed
Push — master ( c4cd1f...963c86 )
by
unknown
36s
created
inc/extensions/custom_fonts/class-redux-extension-custom-fonts.php 2 patches
Spacing   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -278,7 +278,7 @@  discard block
 block discarded – undo
278 278
 								continue;
279 279
 							}
280 280
 
281
-							$this->custom_fonts[ $section['name'] ] = $this->custom_fonts[ $section['name'] ] ?? array();
281
+							$this->custom_fonts[$section['name']] = $this->custom_fonts[$section['name']] ?? array();
282 282
 
283 283
 							foreach ( $section['files'] as $font ) {
284 284
 								if ( ! empty( $font['name'] ) ) {
@@ -295,7 +295,7 @@  discard block
 block discarded – undo
295 295
 										}
296 296
 									}
297 297
 
298
-									$this->custom_fonts[ $section['name'] ][ $font['name'] ] = $kinds;
298
+									$this->custom_fonts[$section['name']][$font['name']] = $kinds;
299 299
 								}
300 300
 							}
301 301
 						}
@@ -416,7 +416,7 @@  discard block
 block discarded – undo
416 416
 				} elseif ( 'f' === $file['type'] ) {
417 417
 					$valid = $this->check_font_name( $file );
418 418
 					if ( $valid ) {
419
-						$output[ $valid ] = trailingslashit( $path ) . $file['name'];
419
+						$output[$valid] = trailingslashit( $path ) . $file['name'];
420 420
 					}
421 421
 				}
422 422
 			}
@@ -477,7 +477,7 @@  discard block
 block discarded – undo
477 477
 
478 478
 			$filename = explode( '/', $this->selected_file );
479 479
 
480
-			$filename = $filename[ ( count( $filename ) - 1 ) ];
480
+			$filename = $filename[( count( $filename ) - 1 )];
481 481
 
482 482
 			$fontname = ucfirst(
483 483
 				str_replace(
@@ -523,7 +523,7 @@  discard block
 block discarded – undo
523 523
 
524 524
 				if ( ! empty( $output ) ) {
525 525
 					foreach ( $complete as $test ) {
526
-						if ( ! isset( $output[ $test ] ) ) {
526
+						if ( ! isset( $output[$test] ) ) {
527 527
 							$missing[] = $test;
528 528
 						}
529 529
 					}
@@ -555,7 +555,7 @@  discard block
 block discarded – undo
555 555
 			} elseif ( 'svg+xml' === $subtype || 'vnd.ms-fontobject' === $subtype || 'x-font-ttf' === $subtype || 'ttf' === $subtype || 'otf' === $subtype || 'font-woff' === $subtype || 'font-woff2' === $subtype || 'application-octet-stream' === $subtype || 'octet-stream' === $subtype ) {
556 556
 				foreach ( $complete as $test ) {
557 557
 					if ( $subtype !== $test ) {
558
-						if ( ! isset( $output[ $test ] ) ) {
558
+						if ( ! isset( $output[$test] ) ) {
559 559
 							$missing[] = $test;
560 560
 						}
561 561
 					}
@@ -691,12 +691,12 @@  discard block
 block discarded – undo
691 691
 				$payload .= md5( 'redux_custom_font' );
692 692
 				$payload .= "\r\n";
693 693
 
694
-				if ( $output[ $main ] ) {
694
+				if ( $output[$main] ) {
695 695
 					$payload .= '--' . $boundary;
696 696
 					$payload .= "\r\n";
697
-					$payload .= 'Content-Disposition: form-data; name="convert"; filename="' . basename( $output[ $main ] ) . '"' . "\r\n";
697
+					$payload .= 'Content-Disposition: form-data; name="convert"; filename="' . basename( $output[$main] ) . '"' . "\r\n";
698 698
 					$payload .= "\r\n";
699
-					$payload .= Redux_Core::$filesystem->execute( 'get_contents', $output[ $main ] );
699
+					$payload .= Redux_Core::$filesystem->execute( 'get_contents', $output[$main] );
700 700
 					$payload .= "\r\n";
701 701
 				}
702 702
 
@@ -760,7 +760,7 @@  discard block
 block discarded – undo
760 760
 						Redux_Core::$filesystem->execute( 'move', $temp . DIRECTORY_SEPARATOR . 'fonts' . DIRECTORY_SEPARATOR . ( $file['name'] ), $param_array );
761 761
 					}
762 762
 				} else {
763
-					$path_parts = pathinfo( $output[ $main ] );
763
+					$path_parts = pathinfo( $output[$main] );
764 764
 
765 765
 					$param_array = array(
766 766
 						'destination' => $this->upload_dir . $this->subfolder . $this->font_folder . DIRECTORY_SEPARATOR . sanitize_file_name( $path_parts['basename'] ),
@@ -768,7 +768,7 @@  discard block
 block discarded – undo
768 768
 						'chmod'       => 755,
769 769
 					);
770 770
 
771
-					Redux_Core::$filesystem->execute( 'move', $output[ $main ], $param_array );
771
+					Redux_Core::$filesystem->execute( 'move', $output[$main], $param_array );
772 772
 
773 773
 					if ( in_array( $font_ext, $unsupported, true ) ) {
774 774
 						return array(
@@ -897,7 +897,7 @@  discard block
 block discarded – undo
897 897
 			$output = array();
898 898
 
899 899
 			foreach ( $files as $file ) {
900
-				$output[ $this->check_font_name( $file ) ] = $file['name'];
900
+				$output[$this->check_font_name( $file )] = $file['name'];
901 901
 			}
902 902
 
903 903
 			$css = '@font-face {';
@@ -959,9 +959,9 @@  discard block
 block discarded – undo
959 959
 				);
960 960
 
961 961
 				for ( $i = count( $this->parent->sections ); $i >= 1; $i-- ) {
962
-					if ( isset( $this->parent->sections[ $i ] ) && isset( $this->parent->sections[ $i ]['title'] ) && esc_html__( 'Font Control', 'redux-framework' ) === $this->parent->sections[ $i ]['title'] ) {
962
+					if ( isset( $this->parent->sections[$i] ) && isset( $this->parent->sections[$i]['title'] ) && esc_html__( 'Font Control', 'redux-framework' ) === $this->parent->sections[$i]['title'] ) {
963 963
 						$this->parent->fontControl                                        = $i;
964
-						$this->parent->sections[ $this->parent->fontControl ]['fields'][] = array(
964
+						$this->parent->sections[$this->parent->fontControl]['fields'][] = array(
965 965
 							'id'   => 'redux_font_control',
966 966
 							'type' => 'custom_fonts',
967 967
 						);
Please login to merge, or discard this patch.
Indentation   +963 added lines, -963 removed lines patch added patch discarded remove patch
@@ -16,967 +16,967 @@
 block discarded – undo
16 16
 
17 17
 if ( ! class_exists( 'Redux_Extension_Custom_Fonts' ) ) {
18 18
 
19
-	/**
20
-	 * Class Redux_Extension_Custom_Fonts
21
-	 */
22
-	class Redux_Extension_Custom_Fonts extends Redux_Extension_Abstract {
23
-
24
-		/**
25
-		 * Extension version.
26
-		 *
27
-		 * @var string
28
-		 */
29
-		public static $version = '4.5.6';
30
-
31
-		/**
32
-		 * Extension friendly name.
33
-		 *
34
-		 * @var string
35
-		 */
36
-		public string $extension_name = 'Custom Fonts';
37
-		/**
38
-		 * Class instance.
39
-		 *
40
-		 * @var object|null
41
-		 */
42
-		public static ?object $instance;
43
-
44
-		/**
45
-		 * Custom fonts array.
46
-		 *
47
-		 * @var array|null
48
-		 */
49
-		public ?array $custom_fonts = array();
50
-
51
-		/**
52
-		 * WordPress upload directory.
53
-		 *
54
-		 * @var string|null
55
-		 */
56
-		public ?string $upload_dir = '';
57
-
58
-		/**
59
-		 * WordPress upload URI.
60
-		 *
61
-		 * @var string|null
62
-		 */
63
-		public ?string $upload_url = '';
64
-
65
-		/**
66
-		 * Subfolder name.
67
-		 *
68
-		 * @var string
69
-		 */
70
-		public string $subfolder = 'custom/';
71
-
72
-		/**
73
-		 * Font folder.
74
-		 *
75
-		 * @var string|null
76
-		 */
77
-		public ?string $font_folder = '';
78
-
79
-		/**
80
-		 * Font Filename.
81
-		 *
82
-		 * @var string|null
83
-		 */
84
-		public ?string $font_filename = '';
85
-
86
-		/**
87
-		 * File selected in media upload.
88
-		 *
89
-		 * @var string|null
90
-		 */
91
-		public ?string $selected_file = '';
92
-
93
-		/**
94
-		 * Is font conversation service available?
95
-		 *
96
-		 * @var bool
97
-		 */
98
-		private bool $can_convert;
99
-
100
-		/**
101
-		 * Class Constructor. Defines the args for the extensions class
102
-		 *
103
-		 * @param ReduxFramework $redux ReduxFramework pointer.
104
-		 *
105
-		 * @return      void
106
-		 * @since       1.0.0
107
-		 * @access      public
108
-		 */
109
-		public function __construct( $redux ) {
110
-			if ( false === $redux->args['custom_fonts'] ) {
111
-				return;
112
-			}
113
-
114
-			parent::__construct( $redux, __FILE__ );
115
-
116
-			self::$instance = parent::get_instance();
117
-
118
-			$this->add_field( 'custom_fonts' );
119
-
120
-			$this->upload_dir = Redux_Core::$upload_dir . 'custom-fonts/';
121
-			$this->upload_url = Redux_Core::$upload_url . 'custom-fonts/';
122
-
123
-			if ( ! is_dir( $this->upload_dir ) ) {
124
-				Redux_Core::$filesystem->execute( 'mkdir', $this->upload_dir );
125
-			}
126
-
127
-			if ( ! is_dir( $this->upload_dir . '/custom' ) ) {
128
-				Redux_Core::$filesystem->execute( 'mkdir', $this->upload_dir . '/custom' );
129
-			}
130
-
131
-			$this->get_fonts();
132
-
133
-			if ( file_exists( $this->upload_dir . 'fonts.css' ) ) {
134
-				if ( filemtime( $this->upload_dir . 'custom' ) > ( filemtime( $this->upload_dir . 'fonts.css' ) + 10 ) ) {
135
-					$this->generate_css();
136
-				}
137
-			} else {
138
-				$this->generate_css();
139
-			}
140
-
141
-			add_action( 'wp_ajax_redux_custom_fonts', array( $this, 'ajax' ) );
142
-			add_action( 'wp_ajax_redux_custom_font_timer', array( $this, 'timer' ) );
143
-
144
-			add_filter( "redux/{$this->parent->args['opt_name']}/field/typography/custom_fonts", array( $this, 'add_custom_fonts' ) );
145
-
146
-			// phpcs:disable
147
-			// $this->is_field = Redux_Helpers::is_field_in_use( $parent, 'custom_fonts' );
148
-
149
-			// if ( ! $this->is_field ) {
150
-			// 	$this->add_section();
151
-			// }
152
-
153
-			add_filter( "redux/options/{$this->parent->args['opt_name']}/section/redux_dynamic_font_control", array( $this, 'remove_dynamic_section' ) ); // phpcs:ignore WordPress.NamingConventions.ValidHookName
154
-			add_filter( 'upload_mimes', array( $this, 'custom_upload_mimes' ) );
155
-			add_action( 'wp_head', array( $this, 'enqueue_output' ), 150 );
156
-			add_filter( 'tiny_mce_before_init', array( $this, 'extend_tinymce_dropdown' ) );
157
-
158
-			$this->can_convert = true; // has_filter( 'redux/' . $this->parent->args['opt_name'] . '/extensions/custom_fonts/api_url' );
159
-			// phpcs:enable
160
-		}
161
-
162
-		/**
163
-		 * Timer.
164
-		 */
165
-		public function timer() {
166
-			$name = get_option( 'redux_custom_font_current' );
167
-
168
-			if ( ! empty( $name ) ) {
169
-				echo esc_html( $name );
170
-			}
171
-
172
-			die();
173
-		}
174
-
175
-		/**
176
-		 * Remove the dynamically added section if the field was used elsewhere
177
-		 *
178
-		 * @param array $section Section array.
179
-		 *
180
-		 * @return array
181
-		 * @since  Redux_Framework 3.1.1
182
-		 */
183
-		public function remove_dynamic_section( array $section ): array {
184
-			if ( isset( $this->parent->field_types['custom_fonts'] ) ) {
185
-				$section = array();
186
-			}
187
-
188
-			return $section;
189
-		}
190
-
191
-		/**
192
-		 * Adds FontMeister fonts to the TinyMCE drop-down.
193
-		 * Typekit's fonts don't render properly in the drop-down and in the editor,
194
-		 * because Typekit needs JS and TinyMCE doesn't support that.
195
-		 *
196
-		 * @param array $opt Option array.
197
-		 *
198
-		 * @return array
199
-		 */
200
-		public function extend_tinymce_dropdown( array $opt ): array {
201
-			if ( ! is_admin() ) {
202
-				return $opt;
203
-			}
204
-
205
-			if ( file_exists( $this->upload_dir . 'fonts.css' ) ) {
206
-				$theme_advanced_fonts = $opt['font_formats'] ?? 'Andale Mono=andale mono,times;Arial=arial,helvetica,sans-serif;Arial Black=arial black,avant garde;Book Antiqua=book antiqua,palatino;Comic Sans MS=comic sans ms,sans-serif;Courier New=courier new,courier;Georgia=georgia,palatino;Helvetica=helvetica;Impact=impact,chicago;Symbol=symbol;Tahoma=tahoma,arial,helvetica,sans-serif;Terminal=terminal,monaco;Times New Roman=times new roman,times;Trebuchet MS=trebuchet ms,geneva;Verdana=verdana,geneva;Webdings=webdings;Wingdings=wingdings,zapf dingbats';
207
-				$custom_fonts         = '';
208
-
209
-				$stylesheet = $this->upload_url . 'fonts.css';
210
-
211
-				if ( empty( $opt['content_css'] ) ) {
212
-					$opt['content_css'] = $stylesheet;
213
-				} else {
214
-					$opt['content_css'] = $opt['content_css'] . ',' . $stylesheet;
215
-				}
216
-
217
-				foreach ( $this->custom_fonts as $arr ) {
218
-					foreach ( $arr as $font => $pieces ) {
219
-						$custom_fonts .= ';' . $font . '=' . $font;
220
-					}
221
-				}
222
-
223
-				$opt['font_formats'] = $theme_advanced_fonts . $custom_fonts;
224
-			}
225
-
226
-			return $opt;
227
-		}
228
-
229
-
230
-		/**
231
-		 * Function to enqueue the custom fonts css
232
-		 */
233
-		public function enqueue_output() {
234
-			if ( file_exists( $this->upload_dir . 'fonts.css' ) ) {
235
-				wp_enqueue_style(
236
-					'redux-custom-fonts',
237
-					$this->upload_url . 'fonts.css',
238
-					array(),
239
-					filemtime( $this->upload_dir . 'fonts.css' )
240
-				);
241
-			}
242
-		}
243
-
244
-		/**
245
-		 * Adds the appropriate mime types to WordPress
246
-		 *
247
-		 * @param array $existing_mimes Mine array.
248
-		 *
249
-		 * @return array
250
-		 */
251
-		public function custom_upload_mimes( array $existing_mimes = array() ): array {
252
-			$existing_mimes['ttf']   = 'font/ttf';
253
-			$existing_mimes['otf']   = 'font/otf';
254
-			$existing_mimes['eot']   = 'application/vnd.ms-fontobject';
255
-			$existing_mimes['woff']  = 'application/font-woff';
256
-			$existing_mimes['woff2'] = 'application/font-woff2';
257
-			$existing_mimes['svg']   = 'image/svg+xml';
258
-			$existing_mimes['zip']   = 'application/zip';
259
-
260
-			return $existing_mimes;
261
-		}
262
-
263
-		/**
264
-		 * Gets all the fonts in the custom_fonts directory
265
-		 */
266
-		public function get_fonts() {
267
-			if ( empty( $this->custom_fonts ) ) {
268
-				$params = array(
269
-					'include_hidden' => false,
270
-					'recursive'      => true,
271
-				);
272
-
273
-				$fonts = Redux_Core::$filesystem->execute( 'dirlist', $this->upload_dir, $params );
274
-
275
-				if ( ! empty( $fonts ) ) {
276
-					foreach ( $fonts as $section ) {
277
-						if ( 'd' === $section['type'] && ! empty( $section['name'] ) ) {
278
-							if ( 'custom' === $section['name'] ) {
279
-								$section['name'] = esc_html__( 'Custom Fonts', 'redux-framework' );
280
-							}
281
-
282
-							if ( empty( $section['files'] ) ) {
283
-								continue;
284
-							}
285
-
286
-							$this->custom_fonts[ $section['name'] ] = $this->custom_fonts[ $section['name'] ] ?? array();
287
-
288
-							foreach ( $section['files'] as $font ) {
289
-								if ( ! empty( $font['name'] ) ) {
290
-									if ( empty( $font['files'] ) ) {
291
-										continue;
292
-									}
293
-
294
-									$kinds = array();
295
-
296
-									foreach ( $font['files'] as $f ) {
297
-										$valid = $this->check_font_name( $f );
298
-										if ( $valid ) {
299
-											$kinds[] = $valid;
300
-										}
301
-									}
302
-
303
-									$this->custom_fonts[ $section['name'] ][ $font['name'] ] = $kinds;
304
-								}
305
-							}
306
-						}
307
-					}
308
-				}
309
-			}
310
-		}
311
-
312
-		/**
313
-		 * Add custom fonts.
314
-		 *
315
-		 * @param mixed $custom_fonts Custom fonts.
316
-		 *
317
-		 * @return array
318
-		 */
319
-		public function add_custom_fonts( $custom_fonts ): array {
320
-			if ( empty( $custom_fonts ) ) {
321
-				$custom_fonts = array();
322
-			}
323
-
324
-			return wp_parse_args( $custom_fonts, $this->custom_fonts );
325
-		}
326
-
327
-		/**
328
-		 * Ajax used within the panel to add and process the fonts
329
-		 */
330
-		public function ajax() {
331
-			if ( ! isset( $_POST['nonce'] ) || ! wp_verify_nonce( sanitize_key( wp_unslash( $_POST['nonce'] ) ), 'redux_custom_fonts' ) ) {
332
-				die( 0 );
333
-			}
334
-
335
-			if ( isset( $_POST['type'] ) && 'delete' === $_POST['type'] ) {
336
-				if ( isset( $_POST['section'] ) ) {
337
-					if ( esc_html__( 'Custom Fonts', 'redux-framework' ) === $_POST['section'] ) {
338
-						$_POST['section'] = 'custom';
339
-					}
340
-				}
341
-
342
-				try {
343
-					if ( isset( $_POST['section'] ) || isset( $_POST['name'] ) ) {
344
-						$ret = Redux_Core::$filesystem->execute( 'rmdir', $this->upload_dir . sanitize_file_name( wp_unslash( $_POST['section'] ) ) . '/' . sanitize_file_name( wp_unslash( $_POST['name'] ) ) . '/', array( 'recursive' => true ) );
345
-
346
-						if ( true === $ret ) {
347
-							$result = array( 'type' => 'success' );
348
-						} else {
349
-							$result = array(
350
-								'type' => 'error',
351
-								'msg'  => esc_html__( 'File system failure. Could not delete temp dir.', 'redux-framework' ),
352
-							);
353
-						}
354
-
355
-						echo wp_json_encode( $result );
356
-					}
357
-				} catch ( Exception $e ) {
358
-					echo wp_json_encode(
359
-						array(
360
-							'type' => 'error',
361
-							'msg'  => esc_html__( 'Unable to delete font file(s).', 'redux-framework' ),
362
-						)
363
-					);
364
-				}
365
-
366
-				die();
367
-			}
368
-
369
-			if ( ! isset( $_POST['title'] ) ) {
370
-				$_POST['title'] = '';
371
-			}
372
-
373
-			if ( ! isset( $_POST['filename'] ) ) {
374
-				$_POST['filename'] = '';
375
-			}
376
-
377
-			$this->font_folder   = sanitize_file_name( wp_unslash( $_POST['title'] ) );
378
-			$this->font_filename = sanitize_file_name( wp_unslash( $_POST['filename'] ) );
379
-
380
-			if ( ! empty( $_POST['attachment_id'] ) ) {
381
-				if ( isset( $_POST['title'] ) || isset( $_POST['mime'] ) ) {
382
-					$msg = $this->process_web_font( sanitize_key( wp_unslash( $_POST['attachment_id'] ) ), sanitize_text_field( wp_unslash( $_POST['mime'] ) ) );
383
-
384
-					if ( empty( $msg ) ) {
385
-						$msg = '';
386
-					}
387
-
388
-					$result = array(
389
-						'type' => 'success',
390
-						'msg'  => $msg,
391
-					);
392
-
393
-					echo wp_json_encode( $result );
394
-				}
395
-			}
396
-
397
-			die();
398
-		}
399
-
400
-		/**
401
-		 * Get only valid files. Ensure everything is proper for processing.
402
-		 *
403
-		 * @param string $path Path.
404
-		 *
405
-		 * @return array
406
-		 */
407
-		public function get_valid_files( string $path ): array {
408
-			$output = array();
409
-			$path   = trailingslashit( $path );
410
-
411
-			$params = array(
412
-				'include_hidden' => false,
413
-				'recursive'      => true,
414
-			);
415
-
416
-			$files = Redux_Core::$filesystem->execute( 'dirlist', $path, $params );
417
-
418
-			foreach ( $files as $file ) {
419
-				if ( 'd' === $file['type'] ) {
420
-					$output = array_merge( $output, $this->get_valid_files( $path . $file['name'] ) );
421
-				} elseif ( 'f' === $file['type'] ) {
422
-					$valid = $this->check_font_name( $file );
423
-					if ( $valid ) {
424
-						$output[ $valid ] = trailingslashit( $path ) . $file['name'];
425
-					}
426
-				}
427
-			}
428
-
429
-			return $output;
430
-		}
431
-
432
-		/**
433
-		 * Take a valid web font and process the missing pieces.
434
-		 *
435
-		 * @param string $attachment_id ID.
436
-		 * @param string $mime_type     Mine type.
437
-		 */
438
-		public function process_web_font( string $attachment_id, string $mime_type ) {
439
-			// phpcs:ignore WordPress.Security.NonceVerification
440
-			if ( ! isset( $_POST['conversion'] ) ) {
441
-				$_POST['conversion'] = 'false';
442
-			}
443
-
444
-			// phpcs:ignore WordPress.Security.NonceVerification
445
-			$conversion = sanitize_text_field( wp_unslash( $_POST['conversion'] ) );
446
-
447
-			$missing = array();
448
-
449
-			$complete = array(
450
-				'ttf',
451
-				'woff',
452
-				'woff2',
453
-				'eot',
454
-				'svg',
455
-				'otf',
456
-			);
457
-
458
-			$subtype = explode( '/', $mime_type );
459
-			$subtype = trim( max( $subtype ) );
460
-
461
-			if ( ! is_dir( $this->upload_dir ) ) {
462
-				Redux_Core::$filesystem->execute( 'mkdir', $this->upload_dir );
463
-			}
464
-
465
-			if ( ! is_dir( $this->upload_dir . $this->subfolder ) ) {
466
-				Redux_Core::$filesystem->execute( 'mkdir', $this->upload_dir . $this->subfolder );
467
-			}
468
-
469
-			$temp                = $this->upload_dir . 'temp';
470
-			$this->selected_file = get_attached_file( $attachment_id );
471
-
472
-			if ( empty( $this->selected_file ) ) {
473
-				echo wp_json_encode(
474
-					array(
475
-						'type' => 'error',
476
-						'msg'  => esc_html__( 'Attachment does not exist.', 'redux-framework' ),
477
-					)
478
-				);
479
-
480
-				die();
481
-			}
482
-
483
-			$filename = explode( '/', $this->selected_file );
484
-
485
-			$filename = $filename[ ( count( $filename ) - 1 ) ];
486
-
487
-			$fontname = ucfirst(
488
-				str_replace(
489
-					array(
490
-						'.zip',
491
-						'.ttf',
492
-						'.woff',
493
-						'.woff2',
494
-						'.eot',
495
-						'.svg',
496
-						'.otf',
497
-					),
498
-					'',
499
-					strtolower( $filename )
500
-				)
501
-			);
502
-
503
-			if ( empty( $this->font_folder ) ) {
504
-				$this->font_folder = $fontname;
505
-			}
506
-
507
-			$ret = array();
508
-
509
-			if ( ! is_dir( $temp ) ) {
510
-				Redux_Core::$filesystem->execute( 'mkdir', $temp );
511
-			}
512
-
513
-			if ( 'zip' === $subtype ) {
514
-				$unzipfile = unzip_file( $this->selected_file, $temp );
515
-
516
-				if ( is_wp_error( $unzipfile ) ) {
517
-					echo wp_json_encode(
518
-						array(
519
-							'type' => 'error',
520
-							'msg'  => $unzipfile->get_error_message() . '<br><br>' . esc_html__( 'Unzipping failed.', 'redux-framework' ),
521
-						)
522
-					);
523
-
524
-					die();
525
-				}
526
-
527
-				$output = $this->get_valid_files( $temp );
528
-
529
-				if ( ! empty( $output ) ) {
530
-					foreach ( $complete as $test ) {
531
-						if ( ! isset( $output[ $test ] ) ) {
532
-							$missing[] = $test;
533
-						}
534
-					}
535
-
536
-					if ( ! is_dir( $this->upload_dir . $this->subfolder . $this->font_folder . '/' ) ) {
537
-						Redux_Core::$filesystem->execute( 'mkdir', $this->upload_dir . $this->subfolder . $this->font_folder . '/' );
538
-					}
539
-
540
-					foreach ( $output as $key => $value ) {
541
-						$param_array = array(
542
-							'destination' => $this->upload_dir . $this->subfolder . $this->font_folder . '/' . $fontname . '.' . $key,
543
-							'overwrite'   => true,
544
-							'chmod'       => 755,
545
-						);
546
-
547
-						Redux_Core::$filesystem->execute( 'copy', $value, $param_array );
548
-					}
549
-
550
-					if ( true === $this->can_convert && 'true' === $conversion ) {
551
-						$ret = $this->get_missing_files( $fontname, $missing, $output );
552
-					}
553
-				}
554
-
555
-				Redux_Core::$filesystem->execute( 'rmdir', $temp, array( 'recursive' => true ) );
556
-
557
-				$this->generate_css();
558
-
559
-				wp_delete_attachment( $attachment_id, true );
560
-			} elseif ( 'svg+xml' === $subtype || 'vnd.ms-fontobject' === $subtype || 'x-font-ttf' === $subtype || 'ttf' === $subtype || 'otf' === $subtype || 'font-woff' === $subtype || 'font-woff2' === $subtype || 'application-octet-stream' === $subtype || 'octet-stream' === $subtype ) {
561
-				foreach ( $complete as $test ) {
562
-					if ( $subtype !== $test ) {
563
-						if ( ! isset( $output[ $test ] ) ) {
564
-							$missing[] = $test;
565
-						}
566
-					}
567
-				}
568
-
569
-				if ( ! is_dir( $this->upload_dir . $this->subfolder . $this->font_folder . '/' ) ) {
570
-					Redux_Core::$filesystem->execute( 'mkdir', $this->upload_dir . $this->subfolder . $this->font_folder . '/' );
571
-				}
572
-
573
-				$output = array( $subtype => $this->selected_file );
574
-
575
-				if ( true === $this->can_convert && 'true' === $conversion ) {
576
-					$ret = $this->get_missing_files( $fontname, $missing, $output );
577
-
578
-					if ( false === $ret ) {
579
-						if ( false === $this->convert_local_font() ) {
580
-							echo wp_json_encode(
581
-								array(
582
-									'type' => 'error',
583
-									'msg'  => esc_html__( 'File permission error. Local file could not be installed.', 'redux-framework' ) . ' ' . $subtype,
584
-								)
585
-							);
586
-
587
-							die;
588
-						}
589
-					}
590
-				} elseif ( false === $this->convert_local_font() ) {
591
-						echo wp_json_encode(
592
-							array(
593
-								'type' => 'error',
594
-								'msg'  => esc_html__( 'File permission error. Local file could not be installed.', 'redux-framework' ) . ' ' . $subtype,
595
-							)
596
-						);
597
-
598
-						die;
599
-				}
600
-
601
-				Redux_Core::$filesystem->execute( 'rmdir', $temp, array( 'recursive' => true ) );
602
-
603
-				$this->generate_css();
604
-
605
-				wp_delete_attachment( $attachment_id, true );
606
-			} else {
607
-				echo wp_json_encode(
608
-					array(
609
-						'type' => 'error',
610
-						'msg'  => esc_html__( 'File type not recognized.', 'redux-framework' ) . ' ' . $subtype,
611
-					)
612
-				);
613
-
614
-				die();
615
-			}
616
-
617
-			if ( is_array( $ret ) && ! empty( $ret ) ) {
618
-				$msg = esc_html__( 'Unidentified error.', 'redux-framework' );
619
-
620
-				if ( isset( $ret['msg'] ) ) {
621
-					$msg = $ret['msg'];
622
-				}
623
-
624
-				return $msg;
625
-			}
626
-
627
-			return '';
628
-		}
629
-
630
-		/**
631
-		 * Install selected file into Custom Fonts.
632
-		 *
633
-		 * @return bool
634
-		 */
635
-		private function convert_local_font(): bool {
636
-			$param_array = array(
637
-				'destination' => $this->upload_dir . $this->subfolder . '/' . $this->font_folder . '/' . $this->font_filename,
638
-				'overwrite'   => true,
639
-				'chmod'       => 755,
640
-			);
641
-
642
-			return Redux_Core::$filesystem->execute( 'copy', $this->selected_file, $param_array );
643
-		}
644
-
645
-		/**
646
-		 * Ping the WebFontOMatic API to get the missing files.
647
-		 *
648
-		 * @param string $fontname  Font name.
649
-		 * @param array  $missing   Missing.
650
-		 * @param array  $output    Output.
651
-		 */
652
-		private function get_missing_files( string $fontname, array $missing, array $output ) {
653
-			if ( ! empty( $this->font_folder ) && ! empty( $missing ) ) {
654
-				$temp = $this->upload_dir . 'temp';
655
-
656
-				$font_ext = pathinfo( $this->font_filename, PATHINFO_EXTENSION );
657
-
658
-				$unsupported = array( 'eot', 'woff', 'woff2' );
659
-
660
-				// Find a file to convert from.
661
-				foreach ( $output as $key => $value ) {
662
-					if ( 'eot' === $key ) {
663
-						continue;
664
-					} else {
665
-						$main = $key;
666
-						break;
667
-					}
668
-				}
669
-
670
-				if ( ! isset( $main ) ) {
671
-					echo wp_json_encode(
672
-						array(
673
-							'type' => 'error',
674
-							'msg'  => esc_html__( 'No valid font file was found.', 'redux-framework' ),
675
-						)
676
-					);
677
-
678
-					Redux_Core::$filesystem->execute( 'rmdir', $temp, array( 'recursive' => true ) );
679
-					Redux_Core::$filesystem->execute( 'rmdir', $this->upload_dir . $this->subfolder . $this->font_folder . '/', array( 'recursive' => true ) );
680
-
681
-					die();
682
-				}
683
-
684
-				update_option( 'redux_custom_font_current', $this->font_folder . '.zip' );
685
-
686
-				$boundary = wp_generate_password( 24 );
687
-
688
-				$headers = array(
689
-					'content-type' => 'multipart/form-data; boundary=' . $boundary,
690
-					'user-agent'   => 'redux-custom-fonts-' . self::$version . ' using ' . wp_get_theme(),
691
-				);
692
-
693
-				$payload  = '--' . $boundary;
694
-				$payload .= "\r\n";
695
-				$payload .= 'Content-Disposition: form-data; name="md5"' . "\r\n\r\n";
696
-				$payload .= md5( 'redux_custom_font' );
697
-				$payload .= "\r\n";
698
-
699
-				if ( $output[ $main ] ) {
700
-					$payload .= '--' . $boundary;
701
-					$payload .= "\r\n";
702
-					$payload .= 'Content-Disposition: form-data; name="convert"; filename="' . basename( $output[ $main ] ) . '"' . "\r\n";
703
-					$payload .= "\r\n";
704
-					$payload .= Redux_Core::$filesystem->execute( 'get_contents', $output[ $main ] );
705
-					$payload .= "\r\n";
706
-				}
707
-
708
-				$payload .= '--' . $boundary . '--';
709
-
710
-				$args = array(
711
-					'headers'    => $headers,
712
-					'body'       => $payload,
713
-					'user-agent' => $headers['user-agent'],
714
-					'timeout'    => 300,
715
-					'sslverify'  => true,
716
-				);
717
-
718
-				// phpcs:disable WordPress.NamingConventions.ValidHookName
719
-				$api_url = apply_filters( 'redux/' . $this->parent->args['opt_name'] . '/extensions/custom_fonts/api_url', 'https://redux.io/fonts' );
720
-
721
-				$response = wp_remote_post( $api_url, $args );
722
-
723
-				if ( is_wp_error( $response ) ) {
724
-					return array(
725
-						'type' => 'error',
726
-						'msg'  => $response->get_error_message() . '<br><br>' . esc_html__( 'Your font could not be converted at this time. Please try again later.', 'redux-framework' ),
727
-					);
728
-				} elseif ( isset( $response['body'] ) ) {
729
-					if ( null !== json_decode( $response['body'] ) ) {
730
-						return json_decode( $response['body'], true );
731
-					}
732
-				}
733
-
734
-				$param_array = array(
735
-					'content'   => $response['body'],
736
-					'overwrite' => true,
737
-					'chmod'     => FS_CHMOD_FILE,
738
-				);
739
-
740
-				$zip_file = $temp . DIRECTORY_SEPARATOR . $fontname . '.zip';
741
-
742
-				Redux_Core::$filesystem->execute( 'put_contents', $zip_file, $param_array );
743
-
744
-				if ( 0 === filesize( $zip_file ) ) {
745
-					return false;
746
-				}
747
-
748
-				$zip = unzip_file( $zip_file, $temp );
749
-
750
-				if ( ! is_wp_error( $zip ) ) {
751
-					$params = array(
752
-						'include_hidden' => false,
753
-						'recursive'      => false,
754
-					);
755
-
756
-					$files = Redux_Core::$filesystem->execute( 'dirlist', $temp . DIRECTORY_SEPARATOR . 'fonts' . DIRECTORY_SEPARATOR, $params );
757
-
758
-					foreach ( $files as $file ) {
759
-						$param_array = array(
760
-							'destination' => $this->upload_dir . $this->subfolder . $this->font_folder . DIRECTORY_SEPARATOR . sanitize_file_name( $file['name'] ),
761
-							'overwrite'   => true,
762
-							'chmod'       => 755,
763
-						);
764
-
765
-						Redux_Core::$filesystem->execute( 'move', $temp . DIRECTORY_SEPARATOR . 'fonts' . DIRECTORY_SEPARATOR . ( $file['name'] ), $param_array );
766
-					}
767
-				} else {
768
-					$path_parts = pathinfo( $output[ $main ] );
769
-
770
-					$param_array = array(
771
-						'destination' => $this->upload_dir . $this->subfolder . $this->font_folder . DIRECTORY_SEPARATOR . sanitize_file_name( $path_parts['basename'] ),
772
-						'overwrite'   => true,
773
-						'chmod'       => 755,
774
-					);
775
-
776
-					Redux_Core::$filesystem->execute( 'move', $output[ $main ], $param_array );
777
-
778
-					if ( in_array( $font_ext, $unsupported, true ) ) {
779
-						return array(
780
-							'type' => 'error',
781
-							// translators: %s = font extension.
782
-							'msg'  => $zip->get_error_message() . '<br><br>' . sprintf( esc_html__( 'The font converter does not support %s fonts.', 'redux-framework' ), $font_ext ),
783
-						);
784
-					} else {
785
-						return array(
786
-							'type' => 'error',
787
-							'msg'  => $zip->get_error_message() . '<br><br>' . esc_html__( 'ZIP error. Your font could not be converted at this time. Please try again later.', 'redux-framework' ),
788
-						);
789
-					}
790
-				}
791
-
792
-				delete_option( 'redux_custom_font_current' );
793
-			}
794
-
795
-			return true;
796
-		}
797
-
798
-		/**
799
-		 * Check if the file name is a valid font file.
800
-		 *
801
-		 * @param array $file File.
802
-		 *
803
-		 * @return bool|string
804
-		 */
805
-		private function check_font_name( array $file ) {
806
-			if ( '.woff' === strtolower( substr( $file['name'], - 5 ) ) ) {
807
-				return 'woff';
808
-			}
809
-
810
-			if ( '.woff2' === strtolower( substr( $file['name'], - 6 ) ) ) {
811
-				return 'woff2';
812
-			}
813
-
814
-			$sub = strtolower( substr( $file['name'], - 4 ) );
815
-
816
-			if ( '.ttf' === $sub ) {
817
-				return 'ttf';
818
-			}
819
-
820
-			if ( '.eot' === $sub ) {
821
-				return 'eot';
822
-			}
823
-
824
-			if ( '.svg' === $sub ) {
825
-				return 'svg';
826
-			}
827
-
828
-			if ( '.otf' === $sub ) {
829
-				return 'otf';
830
-			}
831
-
832
-			return false;
833
-		}
834
-
835
-		/**
836
-		 * Generate a new custom CSS file for enqueuing on the frontend and backend.
837
-		 */
838
-		private function generate_css() {
839
-			$params = array(
840
-				'include_hidden' => false,
841
-				'recursive'      => true,
842
-			);
843
-
844
-			$fonts = Redux_Core::$filesystem->execute( 'dirlist', $this->upload_dir . 'custom' . DIRECTORY_SEPARATOR, $params );
845
-
846
-			if ( empty( $fonts ) || ! is_array( $fonts ) ) {
847
-				return;
848
-			}
849
-
850
-			foreach ( $fonts as $font ) {
851
-				if ( 'd' === $font['type'] ) {
852
-					break;
853
-				}
854
-
855
-				if ( file_exists( $this->upload_dir . 'fonts.css' ) ) {
856
-					Redux_Core::$filesystem->execute( 'delete', $this->upload_dir . 'fonts.css' );
857
-				}
858
-
859
-				return;
860
-			}
861
-
862
-			$css = '';
863
-
864
-			foreach ( $fonts as $font ) {
865
-				if ( 'd' === $font['type'] ) {
866
-					$css .= $this->generate_font_css( $font['name'], $this->upload_dir . 'custom' . DIRECTORY_SEPARATOR );
867
-				}
868
-			}
869
-
870
-			if ( '' !== $css ) {
871
-				$param_array = array(
872
-					'content' => $css,
873
-					'chmod'   => FS_CHMOD_FILE,
874
-				);
875
-
876
-				Redux_Core::$filesystem->execute( 'put_contents', $this->upload_dir . 'fonts.css', $param_array );
877
-			}
878
-		}
879
-
880
-		/**
881
-		 * Process to actually construct the custom font css file.
882
-		 *
883
-		 * @param string $name Name.
884
-		 * @param string $dir  Directory.
885
-		 *
886
-		 * @return string
887
-		 */
888
-		private function generate_font_css( string $name, string $dir ): ?string {
889
-			$path = $dir . $name;
890
-
891
-			$params = array(
892
-				'include_hidden' => false,
893
-				'recursive'      => true,
894
-			);
895
-
896
-			$files = Redux_Core::$filesystem->execute( 'dirlist', $path, $params );
897
-
898
-			if ( empty( $files ) ) {
899
-				return null;
900
-			}
901
-
902
-			$output = array();
903
-
904
-			foreach ( $files as $file ) {
905
-				$output[ $this->check_font_name( $file ) ] = $file['name'];
906
-			}
907
-
908
-			$css = '@font-face {';
909
-
910
-			$css .= 'font-family:"' . $name . '";';
911
-
912
-			$src = array();
913
-
914
-			if ( isset( $output['eot'] ) ) {
915
-				$src[] = "url('{$this->upload_url}custom/$name/{$output['eot']}?#iefix') format('embedded-opentype')";
916
-			}
917
-
918
-			if ( isset( $output['woff'] ) ) {
919
-				$src[] = "url('{$this->upload_url}custom/$name/{$output['woff']}') format('woff')";
920
-			}
921
-
922
-			if ( isset( $output['woff2'] ) ) {
923
-				$src[] = "url('{$this->upload_url}custom/$name/{$output['woff2']}') format('woff2')";
924
-			}
925
-
926
-			if ( isset( $output['ttf'] ) ) {
927
-				$src[] = "url('{$this->upload_url}custom/$name/{$output['ttf']}') format('truetype')";
928
-			}
929
-
930
-			if ( isset( $output['svg'] ) ) {
931
-				$src[] = "url('{$this->upload_url}custom/$name/{$output['svg']}#svg$name') format('svg')";
932
-			}
933
-
934
-			if ( ! empty( $src ) ) {
935
-				$css .= 'src:' . implode( ', ', $src ) . ';';
936
-			}
937
-
938
-			// Replace font weight and style with sub-sets.
939
-			$css .= 'font-weight: normal;';
940
-
941
-			$css .= 'font-style: normal;';
942
-
943
-			$css .= '}';
944
-
945
-			return $css;
946
-		}
947
-
948
-		/**
949
-		 * Custom function for filtering the section array.
950
-		 * Good for child themes to override or add to the sections.
951
-		 * Simply include this function in the child themes functions.php file.
952
-		 * NOTE: the defined constants for URLs and directories will NOT be available at this point in a child theme,
953
-		 * so you must use get_template_directory_uri() if you want to use any of the built-in icons
954
-		 */
955
-		public function add_section() {
956
-			if ( ! isset( $this->parent->fontControl ) ) {
957
-				$this->parent->sections[] = array(
958
-					'title'  => esc_html__( 'Font Control', 'redux-framework' ),
959
-					'desc'   => '<p class="description"></p>',
960
-					'icon'   => 'el-icon-font',
961
-					'id'     => 'redux_dynamic_font_control',
962
-					// Leave this as a blank section, no options just some intro text set above.
963
-					'fields' => array(),
964
-				);
965
-
966
-				for ( $i = count( $this->parent->sections ); $i >= 1; $i-- ) {
967
-					if ( isset( $this->parent->sections[ $i ] ) && isset( $this->parent->sections[ $i ]['title'] ) && esc_html__( 'Font Control', 'redux-framework' ) === $this->parent->sections[ $i ]['title'] ) {
968
-						$this->parent->fontControl                                        = $i;
969
-						$this->parent->sections[ $this->parent->fontControl ]['fields'][] = array(
970
-							'id'   => 'redux_font_control',
971
-							'type' => 'custom_fonts',
972
-						);
973
-
974
-						break;
975
-					}
976
-				}
977
-			}
978
-		}
979
-	}
980
-
981
-	class_alias( Redux_Extension_Custom_Fonts::class, 'ReduxFramework_Extension_custom_fonts' );
19
+    /**
20
+     * Class Redux_Extension_Custom_Fonts
21
+     */
22
+    class Redux_Extension_Custom_Fonts extends Redux_Extension_Abstract {
23
+
24
+        /**
25
+         * Extension version.
26
+         *
27
+         * @var string
28
+         */
29
+        public static $version = '4.5.6';
30
+
31
+        /**
32
+         * Extension friendly name.
33
+         *
34
+         * @var string
35
+         */
36
+        public string $extension_name = 'Custom Fonts';
37
+        /**
38
+         * Class instance.
39
+         *
40
+         * @var object|null
41
+         */
42
+        public static ?object $instance;
43
+
44
+        /**
45
+         * Custom fonts array.
46
+         *
47
+         * @var array|null
48
+         */
49
+        public ?array $custom_fonts = array();
50
+
51
+        /**
52
+         * WordPress upload directory.
53
+         *
54
+         * @var string|null
55
+         */
56
+        public ?string $upload_dir = '';
57
+
58
+        /**
59
+         * WordPress upload URI.
60
+         *
61
+         * @var string|null
62
+         */
63
+        public ?string $upload_url = '';
64
+
65
+        /**
66
+         * Subfolder name.
67
+         *
68
+         * @var string
69
+         */
70
+        public string $subfolder = 'custom/';
71
+
72
+        /**
73
+         * Font folder.
74
+         *
75
+         * @var string|null
76
+         */
77
+        public ?string $font_folder = '';
78
+
79
+        /**
80
+         * Font Filename.
81
+         *
82
+         * @var string|null
83
+         */
84
+        public ?string $font_filename = '';
85
+
86
+        /**
87
+         * File selected in media upload.
88
+         *
89
+         * @var string|null
90
+         */
91
+        public ?string $selected_file = '';
92
+
93
+        /**
94
+         * Is font conversation service available?
95
+         *
96
+         * @var bool
97
+         */
98
+        private bool $can_convert;
99
+
100
+        /**
101
+         * Class Constructor. Defines the args for the extensions class
102
+         *
103
+         * @param ReduxFramework $redux ReduxFramework pointer.
104
+         *
105
+         * @return      void
106
+         * @since       1.0.0
107
+         * @access      public
108
+         */
109
+        public function __construct( $redux ) {
110
+            if ( false === $redux->args['custom_fonts'] ) {
111
+                return;
112
+            }
113
+
114
+            parent::__construct( $redux, __FILE__ );
115
+
116
+            self::$instance = parent::get_instance();
117
+
118
+            $this->add_field( 'custom_fonts' );
119
+
120
+            $this->upload_dir = Redux_Core::$upload_dir . 'custom-fonts/';
121
+            $this->upload_url = Redux_Core::$upload_url . 'custom-fonts/';
122
+
123
+            if ( ! is_dir( $this->upload_dir ) ) {
124
+                Redux_Core::$filesystem->execute( 'mkdir', $this->upload_dir );
125
+            }
126
+
127
+            if ( ! is_dir( $this->upload_dir . '/custom' ) ) {
128
+                Redux_Core::$filesystem->execute( 'mkdir', $this->upload_dir . '/custom' );
129
+            }
130
+
131
+            $this->get_fonts();
132
+
133
+            if ( file_exists( $this->upload_dir . 'fonts.css' ) ) {
134
+                if ( filemtime( $this->upload_dir . 'custom' ) > ( filemtime( $this->upload_dir . 'fonts.css' ) + 10 ) ) {
135
+                    $this->generate_css();
136
+                }
137
+            } else {
138
+                $this->generate_css();
139
+            }
140
+
141
+            add_action( 'wp_ajax_redux_custom_fonts', array( $this, 'ajax' ) );
142
+            add_action( 'wp_ajax_redux_custom_font_timer', array( $this, 'timer' ) );
143
+
144
+            add_filter( "redux/{$this->parent->args['opt_name']}/field/typography/custom_fonts", array( $this, 'add_custom_fonts' ) );
145
+
146
+            // phpcs:disable
147
+            // $this->is_field = Redux_Helpers::is_field_in_use( $parent, 'custom_fonts' );
148
+
149
+            // if ( ! $this->is_field ) {
150
+            // 	$this->add_section();
151
+            // }
152
+
153
+            add_filter( "redux/options/{$this->parent->args['opt_name']}/section/redux_dynamic_font_control", array( $this, 'remove_dynamic_section' ) ); // phpcs:ignore WordPress.NamingConventions.ValidHookName
154
+            add_filter( 'upload_mimes', array( $this, 'custom_upload_mimes' ) );
155
+            add_action( 'wp_head', array( $this, 'enqueue_output' ), 150 );
156
+            add_filter( 'tiny_mce_before_init', array( $this, 'extend_tinymce_dropdown' ) );
157
+
158
+            $this->can_convert = true; // has_filter( 'redux/' . $this->parent->args['opt_name'] . '/extensions/custom_fonts/api_url' );
159
+            // phpcs:enable
160
+        }
161
+
162
+        /**
163
+         * Timer.
164
+         */
165
+        public function timer() {
166
+            $name = get_option( 'redux_custom_font_current' );
167
+
168
+            if ( ! empty( $name ) ) {
169
+                echo esc_html( $name );
170
+            }
171
+
172
+            die();
173
+        }
174
+
175
+        /**
176
+         * Remove the dynamically added section if the field was used elsewhere
177
+         *
178
+         * @param array $section Section array.
179
+         *
180
+         * @return array
181
+         * @since  Redux_Framework 3.1.1
182
+         */
183
+        public function remove_dynamic_section( array $section ): array {
184
+            if ( isset( $this->parent->field_types['custom_fonts'] ) ) {
185
+                $section = array();
186
+            }
187
+
188
+            return $section;
189
+        }
190
+
191
+        /**
192
+         * Adds FontMeister fonts to the TinyMCE drop-down.
193
+         * Typekit's fonts don't render properly in the drop-down and in the editor,
194
+         * because Typekit needs JS and TinyMCE doesn't support that.
195
+         *
196
+         * @param array $opt Option array.
197
+         *
198
+         * @return array
199
+         */
200
+        public function extend_tinymce_dropdown( array $opt ): array {
201
+            if ( ! is_admin() ) {
202
+                return $opt;
203
+            }
204
+
205
+            if ( file_exists( $this->upload_dir . 'fonts.css' ) ) {
206
+                $theme_advanced_fonts = $opt['font_formats'] ?? 'Andale Mono=andale mono,times;Arial=arial,helvetica,sans-serif;Arial Black=arial black,avant garde;Book Antiqua=book antiqua,palatino;Comic Sans MS=comic sans ms,sans-serif;Courier New=courier new,courier;Georgia=georgia,palatino;Helvetica=helvetica;Impact=impact,chicago;Symbol=symbol;Tahoma=tahoma,arial,helvetica,sans-serif;Terminal=terminal,monaco;Times New Roman=times new roman,times;Trebuchet MS=trebuchet ms,geneva;Verdana=verdana,geneva;Webdings=webdings;Wingdings=wingdings,zapf dingbats';
207
+                $custom_fonts         = '';
208
+
209
+                $stylesheet = $this->upload_url . 'fonts.css';
210
+
211
+                if ( empty( $opt['content_css'] ) ) {
212
+                    $opt['content_css'] = $stylesheet;
213
+                } else {
214
+                    $opt['content_css'] = $opt['content_css'] . ',' . $stylesheet;
215
+                }
216
+
217
+                foreach ( $this->custom_fonts as $arr ) {
218
+                    foreach ( $arr as $font => $pieces ) {
219
+                        $custom_fonts .= ';' . $font . '=' . $font;
220
+                    }
221
+                }
222
+
223
+                $opt['font_formats'] = $theme_advanced_fonts . $custom_fonts;
224
+            }
225
+
226
+            return $opt;
227
+        }
228
+
229
+
230
+        /**
231
+         * Function to enqueue the custom fonts css
232
+         */
233
+        public function enqueue_output() {
234
+            if ( file_exists( $this->upload_dir . 'fonts.css' ) ) {
235
+                wp_enqueue_style(
236
+                    'redux-custom-fonts',
237
+                    $this->upload_url . 'fonts.css',
238
+                    array(),
239
+                    filemtime( $this->upload_dir . 'fonts.css' )
240
+                );
241
+            }
242
+        }
243
+
244
+        /**
245
+         * Adds the appropriate mime types to WordPress
246
+         *
247
+         * @param array $existing_mimes Mine array.
248
+         *
249
+         * @return array
250
+         */
251
+        public function custom_upload_mimes( array $existing_mimes = array() ): array {
252
+            $existing_mimes['ttf']   = 'font/ttf';
253
+            $existing_mimes['otf']   = 'font/otf';
254
+            $existing_mimes['eot']   = 'application/vnd.ms-fontobject';
255
+            $existing_mimes['woff']  = 'application/font-woff';
256
+            $existing_mimes['woff2'] = 'application/font-woff2';
257
+            $existing_mimes['svg']   = 'image/svg+xml';
258
+            $existing_mimes['zip']   = 'application/zip';
259
+
260
+            return $existing_mimes;
261
+        }
262
+
263
+        /**
264
+         * Gets all the fonts in the custom_fonts directory
265
+         */
266
+        public function get_fonts() {
267
+            if ( empty( $this->custom_fonts ) ) {
268
+                $params = array(
269
+                    'include_hidden' => false,
270
+                    'recursive'      => true,
271
+                );
272
+
273
+                $fonts = Redux_Core::$filesystem->execute( 'dirlist', $this->upload_dir, $params );
274
+
275
+                if ( ! empty( $fonts ) ) {
276
+                    foreach ( $fonts as $section ) {
277
+                        if ( 'd' === $section['type'] && ! empty( $section['name'] ) ) {
278
+                            if ( 'custom' === $section['name'] ) {
279
+                                $section['name'] = esc_html__( 'Custom Fonts', 'redux-framework' );
280
+                            }
281
+
282
+                            if ( empty( $section['files'] ) ) {
283
+                                continue;
284
+                            }
285
+
286
+                            $this->custom_fonts[ $section['name'] ] = $this->custom_fonts[ $section['name'] ] ?? array();
287
+
288
+                            foreach ( $section['files'] as $font ) {
289
+                                if ( ! empty( $font['name'] ) ) {
290
+                                    if ( empty( $font['files'] ) ) {
291
+                                        continue;
292
+                                    }
293
+
294
+                                    $kinds = array();
295
+
296
+                                    foreach ( $font['files'] as $f ) {
297
+                                        $valid = $this->check_font_name( $f );
298
+                                        if ( $valid ) {
299
+                                            $kinds[] = $valid;
300
+                                        }
301
+                                    }
302
+
303
+                                    $this->custom_fonts[ $section['name'] ][ $font['name'] ] = $kinds;
304
+                                }
305
+                            }
306
+                        }
307
+                    }
308
+                }
309
+            }
310
+        }
311
+
312
+        /**
313
+         * Add custom fonts.
314
+         *
315
+         * @param mixed $custom_fonts Custom fonts.
316
+         *
317
+         * @return array
318
+         */
319
+        public function add_custom_fonts( $custom_fonts ): array {
320
+            if ( empty( $custom_fonts ) ) {
321
+                $custom_fonts = array();
322
+            }
323
+
324
+            return wp_parse_args( $custom_fonts, $this->custom_fonts );
325
+        }
326
+
327
+        /**
328
+         * Ajax used within the panel to add and process the fonts
329
+         */
330
+        public function ajax() {
331
+            if ( ! isset( $_POST['nonce'] ) || ! wp_verify_nonce( sanitize_key( wp_unslash( $_POST['nonce'] ) ), 'redux_custom_fonts' ) ) {
332
+                die( 0 );
333
+            }
334
+
335
+            if ( isset( $_POST['type'] ) && 'delete' === $_POST['type'] ) {
336
+                if ( isset( $_POST['section'] ) ) {
337
+                    if ( esc_html__( 'Custom Fonts', 'redux-framework' ) === $_POST['section'] ) {
338
+                        $_POST['section'] = 'custom';
339
+                    }
340
+                }
341
+
342
+                try {
343
+                    if ( isset( $_POST['section'] ) || isset( $_POST['name'] ) ) {
344
+                        $ret = Redux_Core::$filesystem->execute( 'rmdir', $this->upload_dir . sanitize_file_name( wp_unslash( $_POST['section'] ) ) . '/' . sanitize_file_name( wp_unslash( $_POST['name'] ) ) . '/', array( 'recursive' => true ) );
345
+
346
+                        if ( true === $ret ) {
347
+                            $result = array( 'type' => 'success' );
348
+                        } else {
349
+                            $result = array(
350
+                                'type' => 'error',
351
+                                'msg'  => esc_html__( 'File system failure. Could not delete temp dir.', 'redux-framework' ),
352
+                            );
353
+                        }
354
+
355
+                        echo wp_json_encode( $result );
356
+                    }
357
+                } catch ( Exception $e ) {
358
+                    echo wp_json_encode(
359
+                        array(
360
+                            'type' => 'error',
361
+                            'msg'  => esc_html__( 'Unable to delete font file(s).', 'redux-framework' ),
362
+                        )
363
+                    );
364
+                }
365
+
366
+                die();
367
+            }
368
+
369
+            if ( ! isset( $_POST['title'] ) ) {
370
+                $_POST['title'] = '';
371
+            }
372
+
373
+            if ( ! isset( $_POST['filename'] ) ) {
374
+                $_POST['filename'] = '';
375
+            }
376
+
377
+            $this->font_folder   = sanitize_file_name( wp_unslash( $_POST['title'] ) );
378
+            $this->font_filename = sanitize_file_name( wp_unslash( $_POST['filename'] ) );
379
+
380
+            if ( ! empty( $_POST['attachment_id'] ) ) {
381
+                if ( isset( $_POST['title'] ) || isset( $_POST['mime'] ) ) {
382
+                    $msg = $this->process_web_font( sanitize_key( wp_unslash( $_POST['attachment_id'] ) ), sanitize_text_field( wp_unslash( $_POST['mime'] ) ) );
383
+
384
+                    if ( empty( $msg ) ) {
385
+                        $msg = '';
386
+                    }
387
+
388
+                    $result = array(
389
+                        'type' => 'success',
390
+                        'msg'  => $msg,
391
+                    );
392
+
393
+                    echo wp_json_encode( $result );
394
+                }
395
+            }
396
+
397
+            die();
398
+        }
399
+
400
+        /**
401
+         * Get only valid files. Ensure everything is proper for processing.
402
+         *
403
+         * @param string $path Path.
404
+         *
405
+         * @return array
406
+         */
407
+        public function get_valid_files( string $path ): array {
408
+            $output = array();
409
+            $path   = trailingslashit( $path );
410
+
411
+            $params = array(
412
+                'include_hidden' => false,
413
+                'recursive'      => true,
414
+            );
415
+
416
+            $files = Redux_Core::$filesystem->execute( 'dirlist', $path, $params );
417
+
418
+            foreach ( $files as $file ) {
419
+                if ( 'd' === $file['type'] ) {
420
+                    $output = array_merge( $output, $this->get_valid_files( $path . $file['name'] ) );
421
+                } elseif ( 'f' === $file['type'] ) {
422
+                    $valid = $this->check_font_name( $file );
423
+                    if ( $valid ) {
424
+                        $output[ $valid ] = trailingslashit( $path ) . $file['name'];
425
+                    }
426
+                }
427
+            }
428
+
429
+            return $output;
430
+        }
431
+
432
+        /**
433
+         * Take a valid web font and process the missing pieces.
434
+         *
435
+         * @param string $attachment_id ID.
436
+         * @param string $mime_type     Mine type.
437
+         */
438
+        public function process_web_font( string $attachment_id, string $mime_type ) {
439
+            // phpcs:ignore WordPress.Security.NonceVerification
440
+            if ( ! isset( $_POST['conversion'] ) ) {
441
+                $_POST['conversion'] = 'false';
442
+            }
443
+
444
+            // phpcs:ignore WordPress.Security.NonceVerification
445
+            $conversion = sanitize_text_field( wp_unslash( $_POST['conversion'] ) );
446
+
447
+            $missing = array();
448
+
449
+            $complete = array(
450
+                'ttf',
451
+                'woff',
452
+                'woff2',
453
+                'eot',
454
+                'svg',
455
+                'otf',
456
+            );
457
+
458
+            $subtype = explode( '/', $mime_type );
459
+            $subtype = trim( max( $subtype ) );
460
+
461
+            if ( ! is_dir( $this->upload_dir ) ) {
462
+                Redux_Core::$filesystem->execute( 'mkdir', $this->upload_dir );
463
+            }
464
+
465
+            if ( ! is_dir( $this->upload_dir . $this->subfolder ) ) {
466
+                Redux_Core::$filesystem->execute( 'mkdir', $this->upload_dir . $this->subfolder );
467
+            }
468
+
469
+            $temp                = $this->upload_dir . 'temp';
470
+            $this->selected_file = get_attached_file( $attachment_id );
471
+
472
+            if ( empty( $this->selected_file ) ) {
473
+                echo wp_json_encode(
474
+                    array(
475
+                        'type' => 'error',
476
+                        'msg'  => esc_html__( 'Attachment does not exist.', 'redux-framework' ),
477
+                    )
478
+                );
479
+
480
+                die();
481
+            }
482
+
483
+            $filename = explode( '/', $this->selected_file );
484
+
485
+            $filename = $filename[ ( count( $filename ) - 1 ) ];
486
+
487
+            $fontname = ucfirst(
488
+                str_replace(
489
+                    array(
490
+                        '.zip',
491
+                        '.ttf',
492
+                        '.woff',
493
+                        '.woff2',
494
+                        '.eot',
495
+                        '.svg',
496
+                        '.otf',
497
+                    ),
498
+                    '',
499
+                    strtolower( $filename )
500
+                )
501
+            );
502
+
503
+            if ( empty( $this->font_folder ) ) {
504
+                $this->font_folder = $fontname;
505
+            }
506
+
507
+            $ret = array();
508
+
509
+            if ( ! is_dir( $temp ) ) {
510
+                Redux_Core::$filesystem->execute( 'mkdir', $temp );
511
+            }
512
+
513
+            if ( 'zip' === $subtype ) {
514
+                $unzipfile = unzip_file( $this->selected_file, $temp );
515
+
516
+                if ( is_wp_error( $unzipfile ) ) {
517
+                    echo wp_json_encode(
518
+                        array(
519
+                            'type' => 'error',
520
+                            'msg'  => $unzipfile->get_error_message() . '<br><br>' . esc_html__( 'Unzipping failed.', 'redux-framework' ),
521
+                        )
522
+                    );
523
+
524
+                    die();
525
+                }
526
+
527
+                $output = $this->get_valid_files( $temp );
528
+
529
+                if ( ! empty( $output ) ) {
530
+                    foreach ( $complete as $test ) {
531
+                        if ( ! isset( $output[ $test ] ) ) {
532
+                            $missing[] = $test;
533
+                        }
534
+                    }
535
+
536
+                    if ( ! is_dir( $this->upload_dir . $this->subfolder . $this->font_folder . '/' ) ) {
537
+                        Redux_Core::$filesystem->execute( 'mkdir', $this->upload_dir . $this->subfolder . $this->font_folder . '/' );
538
+                    }
539
+
540
+                    foreach ( $output as $key => $value ) {
541
+                        $param_array = array(
542
+                            'destination' => $this->upload_dir . $this->subfolder . $this->font_folder . '/' . $fontname . '.' . $key,
543
+                            'overwrite'   => true,
544
+                            'chmod'       => 755,
545
+                        );
546
+
547
+                        Redux_Core::$filesystem->execute( 'copy', $value, $param_array );
548
+                    }
549
+
550
+                    if ( true === $this->can_convert && 'true' === $conversion ) {
551
+                        $ret = $this->get_missing_files( $fontname, $missing, $output );
552
+                    }
553
+                }
554
+
555
+                Redux_Core::$filesystem->execute( 'rmdir', $temp, array( 'recursive' => true ) );
556
+
557
+                $this->generate_css();
558
+
559
+                wp_delete_attachment( $attachment_id, true );
560
+            } elseif ( 'svg+xml' === $subtype || 'vnd.ms-fontobject' === $subtype || 'x-font-ttf' === $subtype || 'ttf' === $subtype || 'otf' === $subtype || 'font-woff' === $subtype || 'font-woff2' === $subtype || 'application-octet-stream' === $subtype || 'octet-stream' === $subtype ) {
561
+                foreach ( $complete as $test ) {
562
+                    if ( $subtype !== $test ) {
563
+                        if ( ! isset( $output[ $test ] ) ) {
564
+                            $missing[] = $test;
565
+                        }
566
+                    }
567
+                }
568
+
569
+                if ( ! is_dir( $this->upload_dir . $this->subfolder . $this->font_folder . '/' ) ) {
570
+                    Redux_Core::$filesystem->execute( 'mkdir', $this->upload_dir . $this->subfolder . $this->font_folder . '/' );
571
+                }
572
+
573
+                $output = array( $subtype => $this->selected_file );
574
+
575
+                if ( true === $this->can_convert && 'true' === $conversion ) {
576
+                    $ret = $this->get_missing_files( $fontname, $missing, $output );
577
+
578
+                    if ( false === $ret ) {
579
+                        if ( false === $this->convert_local_font() ) {
580
+                            echo wp_json_encode(
581
+                                array(
582
+                                    'type' => 'error',
583
+                                    'msg'  => esc_html__( 'File permission error. Local file could not be installed.', 'redux-framework' ) . ' ' . $subtype,
584
+                                )
585
+                            );
586
+
587
+                            die;
588
+                        }
589
+                    }
590
+                } elseif ( false === $this->convert_local_font() ) {
591
+                        echo wp_json_encode(
592
+                            array(
593
+                                'type' => 'error',
594
+                                'msg'  => esc_html__( 'File permission error. Local file could not be installed.', 'redux-framework' ) . ' ' . $subtype,
595
+                            )
596
+                        );
597
+
598
+                        die;
599
+                }
600
+
601
+                Redux_Core::$filesystem->execute( 'rmdir', $temp, array( 'recursive' => true ) );
602
+
603
+                $this->generate_css();
604
+
605
+                wp_delete_attachment( $attachment_id, true );
606
+            } else {
607
+                echo wp_json_encode(
608
+                    array(
609
+                        'type' => 'error',
610
+                        'msg'  => esc_html__( 'File type not recognized.', 'redux-framework' ) . ' ' . $subtype,
611
+                    )
612
+                );
613
+
614
+                die();
615
+            }
616
+
617
+            if ( is_array( $ret ) && ! empty( $ret ) ) {
618
+                $msg = esc_html__( 'Unidentified error.', 'redux-framework' );
619
+
620
+                if ( isset( $ret['msg'] ) ) {
621
+                    $msg = $ret['msg'];
622
+                }
623
+
624
+                return $msg;
625
+            }
626
+
627
+            return '';
628
+        }
629
+
630
+        /**
631
+         * Install selected file into Custom Fonts.
632
+         *
633
+         * @return bool
634
+         */
635
+        private function convert_local_font(): bool {
636
+            $param_array = array(
637
+                'destination' => $this->upload_dir . $this->subfolder . '/' . $this->font_folder . '/' . $this->font_filename,
638
+                'overwrite'   => true,
639
+                'chmod'       => 755,
640
+            );
641
+
642
+            return Redux_Core::$filesystem->execute( 'copy', $this->selected_file, $param_array );
643
+        }
644
+
645
+        /**
646
+         * Ping the WebFontOMatic API to get the missing files.
647
+         *
648
+         * @param string $fontname  Font name.
649
+         * @param array  $missing   Missing.
650
+         * @param array  $output    Output.
651
+         */
652
+        private function get_missing_files( string $fontname, array $missing, array $output ) {
653
+            if ( ! empty( $this->font_folder ) && ! empty( $missing ) ) {
654
+                $temp = $this->upload_dir . 'temp';
655
+
656
+                $font_ext = pathinfo( $this->font_filename, PATHINFO_EXTENSION );
657
+
658
+                $unsupported = array( 'eot', 'woff', 'woff2' );
659
+
660
+                // Find a file to convert from.
661
+                foreach ( $output as $key => $value ) {
662
+                    if ( 'eot' === $key ) {
663
+                        continue;
664
+                    } else {
665
+                        $main = $key;
666
+                        break;
667
+                    }
668
+                }
669
+
670
+                if ( ! isset( $main ) ) {
671
+                    echo wp_json_encode(
672
+                        array(
673
+                            'type' => 'error',
674
+                            'msg'  => esc_html__( 'No valid font file was found.', 'redux-framework' ),
675
+                        )
676
+                    );
677
+
678
+                    Redux_Core::$filesystem->execute( 'rmdir', $temp, array( 'recursive' => true ) );
679
+                    Redux_Core::$filesystem->execute( 'rmdir', $this->upload_dir . $this->subfolder . $this->font_folder . '/', array( 'recursive' => true ) );
680
+
681
+                    die();
682
+                }
683
+
684
+                update_option( 'redux_custom_font_current', $this->font_folder . '.zip' );
685
+
686
+                $boundary = wp_generate_password( 24 );
687
+
688
+                $headers = array(
689
+                    'content-type' => 'multipart/form-data; boundary=' . $boundary,
690
+                    'user-agent'   => 'redux-custom-fonts-' . self::$version . ' using ' . wp_get_theme(),
691
+                );
692
+
693
+                $payload  = '--' . $boundary;
694
+                $payload .= "\r\n";
695
+                $payload .= 'Content-Disposition: form-data; name="md5"' . "\r\n\r\n";
696
+                $payload .= md5( 'redux_custom_font' );
697
+                $payload .= "\r\n";
698
+
699
+                if ( $output[ $main ] ) {
700
+                    $payload .= '--' . $boundary;
701
+                    $payload .= "\r\n";
702
+                    $payload .= 'Content-Disposition: form-data; name="convert"; filename="' . basename( $output[ $main ] ) . '"' . "\r\n";
703
+                    $payload .= "\r\n";
704
+                    $payload .= Redux_Core::$filesystem->execute( 'get_contents', $output[ $main ] );
705
+                    $payload .= "\r\n";
706
+                }
707
+
708
+                $payload .= '--' . $boundary . '--';
709
+
710
+                $args = array(
711
+                    'headers'    => $headers,
712
+                    'body'       => $payload,
713
+                    'user-agent' => $headers['user-agent'],
714
+                    'timeout'    => 300,
715
+                    'sslverify'  => true,
716
+                );
717
+
718
+                // phpcs:disable WordPress.NamingConventions.ValidHookName
719
+                $api_url = apply_filters( 'redux/' . $this->parent->args['opt_name'] . '/extensions/custom_fonts/api_url', 'https://redux.io/fonts' );
720
+
721
+                $response = wp_remote_post( $api_url, $args );
722
+
723
+                if ( is_wp_error( $response ) ) {
724
+                    return array(
725
+                        'type' => 'error',
726
+                        'msg'  => $response->get_error_message() . '<br><br>' . esc_html__( 'Your font could not be converted at this time. Please try again later.', 'redux-framework' ),
727
+                    );
728
+                } elseif ( isset( $response['body'] ) ) {
729
+                    if ( null !== json_decode( $response['body'] ) ) {
730
+                        return json_decode( $response['body'], true );
731
+                    }
732
+                }
733
+
734
+                $param_array = array(
735
+                    'content'   => $response['body'],
736
+                    'overwrite' => true,
737
+                    'chmod'     => FS_CHMOD_FILE,
738
+                );
739
+
740
+                $zip_file = $temp . DIRECTORY_SEPARATOR . $fontname . '.zip';
741
+
742
+                Redux_Core::$filesystem->execute( 'put_contents', $zip_file, $param_array );
743
+
744
+                if ( 0 === filesize( $zip_file ) ) {
745
+                    return false;
746
+                }
747
+
748
+                $zip = unzip_file( $zip_file, $temp );
749
+
750
+                if ( ! is_wp_error( $zip ) ) {
751
+                    $params = array(
752
+                        'include_hidden' => false,
753
+                        'recursive'      => false,
754
+                    );
755
+
756
+                    $files = Redux_Core::$filesystem->execute( 'dirlist', $temp . DIRECTORY_SEPARATOR . 'fonts' . DIRECTORY_SEPARATOR, $params );
757
+
758
+                    foreach ( $files as $file ) {
759
+                        $param_array = array(
760
+                            'destination' => $this->upload_dir . $this->subfolder . $this->font_folder . DIRECTORY_SEPARATOR . sanitize_file_name( $file['name'] ),
761
+                            'overwrite'   => true,
762
+                            'chmod'       => 755,
763
+                        );
764
+
765
+                        Redux_Core::$filesystem->execute( 'move', $temp . DIRECTORY_SEPARATOR . 'fonts' . DIRECTORY_SEPARATOR . ( $file['name'] ), $param_array );
766
+                    }
767
+                } else {
768
+                    $path_parts = pathinfo( $output[ $main ] );
769
+
770
+                    $param_array = array(
771
+                        'destination' => $this->upload_dir . $this->subfolder . $this->font_folder . DIRECTORY_SEPARATOR . sanitize_file_name( $path_parts['basename'] ),
772
+                        'overwrite'   => true,
773
+                        'chmod'       => 755,
774
+                    );
775
+
776
+                    Redux_Core::$filesystem->execute( 'move', $output[ $main ], $param_array );
777
+
778
+                    if ( in_array( $font_ext, $unsupported, true ) ) {
779
+                        return array(
780
+                            'type' => 'error',
781
+                            // translators: %s = font extension.
782
+                            'msg'  => $zip->get_error_message() . '<br><br>' . sprintf( esc_html__( 'The font converter does not support %s fonts.', 'redux-framework' ), $font_ext ),
783
+                        );
784
+                    } else {
785
+                        return array(
786
+                            'type' => 'error',
787
+                            'msg'  => $zip->get_error_message() . '<br><br>' . esc_html__( 'ZIP error. Your font could not be converted at this time. Please try again later.', 'redux-framework' ),
788
+                        );
789
+                    }
790
+                }
791
+
792
+                delete_option( 'redux_custom_font_current' );
793
+            }
794
+
795
+            return true;
796
+        }
797
+
798
+        /**
799
+         * Check if the file name is a valid font file.
800
+         *
801
+         * @param array $file File.
802
+         *
803
+         * @return bool|string
804
+         */
805
+        private function check_font_name( array $file ) {
806
+            if ( '.woff' === strtolower( substr( $file['name'], - 5 ) ) ) {
807
+                return 'woff';
808
+            }
809
+
810
+            if ( '.woff2' === strtolower( substr( $file['name'], - 6 ) ) ) {
811
+                return 'woff2';
812
+            }
813
+
814
+            $sub = strtolower( substr( $file['name'], - 4 ) );
815
+
816
+            if ( '.ttf' === $sub ) {
817
+                return 'ttf';
818
+            }
819
+
820
+            if ( '.eot' === $sub ) {
821
+                return 'eot';
822
+            }
823
+
824
+            if ( '.svg' === $sub ) {
825
+                return 'svg';
826
+            }
827
+
828
+            if ( '.otf' === $sub ) {
829
+                return 'otf';
830
+            }
831
+
832
+            return false;
833
+        }
834
+
835
+        /**
836
+         * Generate a new custom CSS file for enqueuing on the frontend and backend.
837
+         */
838
+        private function generate_css() {
839
+            $params = array(
840
+                'include_hidden' => false,
841
+                'recursive'      => true,
842
+            );
843
+
844
+            $fonts = Redux_Core::$filesystem->execute( 'dirlist', $this->upload_dir . 'custom' . DIRECTORY_SEPARATOR, $params );
845
+
846
+            if ( empty( $fonts ) || ! is_array( $fonts ) ) {
847
+                return;
848
+            }
849
+
850
+            foreach ( $fonts as $font ) {
851
+                if ( 'd' === $font['type'] ) {
852
+                    break;
853
+                }
854
+
855
+                if ( file_exists( $this->upload_dir . 'fonts.css' ) ) {
856
+                    Redux_Core::$filesystem->execute( 'delete', $this->upload_dir . 'fonts.css' );
857
+                }
858
+
859
+                return;
860
+            }
861
+
862
+            $css = '';
863
+
864
+            foreach ( $fonts as $font ) {
865
+                if ( 'd' === $font['type'] ) {
866
+                    $css .= $this->generate_font_css( $font['name'], $this->upload_dir . 'custom' . DIRECTORY_SEPARATOR );
867
+                }
868
+            }
869
+
870
+            if ( '' !== $css ) {
871
+                $param_array = array(
872
+                    'content' => $css,
873
+                    'chmod'   => FS_CHMOD_FILE,
874
+                );
875
+
876
+                Redux_Core::$filesystem->execute( 'put_contents', $this->upload_dir . 'fonts.css', $param_array );
877
+            }
878
+        }
879
+
880
+        /**
881
+         * Process to actually construct the custom font css file.
882
+         *
883
+         * @param string $name Name.
884
+         * @param string $dir  Directory.
885
+         *
886
+         * @return string
887
+         */
888
+        private function generate_font_css( string $name, string $dir ): ?string {
889
+            $path = $dir . $name;
890
+
891
+            $params = array(
892
+                'include_hidden' => false,
893
+                'recursive'      => true,
894
+            );
895
+
896
+            $files = Redux_Core::$filesystem->execute( 'dirlist', $path, $params );
897
+
898
+            if ( empty( $files ) ) {
899
+                return null;
900
+            }
901
+
902
+            $output = array();
903
+
904
+            foreach ( $files as $file ) {
905
+                $output[ $this->check_font_name( $file ) ] = $file['name'];
906
+            }
907
+
908
+            $css = '@font-face {';
909
+
910
+            $css .= 'font-family:"' . $name . '";';
911
+
912
+            $src = array();
913
+
914
+            if ( isset( $output['eot'] ) ) {
915
+                $src[] = "url('{$this->upload_url}custom/$name/{$output['eot']}?#iefix') format('embedded-opentype')";
916
+            }
917
+
918
+            if ( isset( $output['woff'] ) ) {
919
+                $src[] = "url('{$this->upload_url}custom/$name/{$output['woff']}') format('woff')";
920
+            }
921
+
922
+            if ( isset( $output['woff2'] ) ) {
923
+                $src[] = "url('{$this->upload_url}custom/$name/{$output['woff2']}') format('woff2')";
924
+            }
925
+
926
+            if ( isset( $output['ttf'] ) ) {
927
+                $src[] = "url('{$this->upload_url}custom/$name/{$output['ttf']}') format('truetype')";
928
+            }
929
+
930
+            if ( isset( $output['svg'] ) ) {
931
+                $src[] = "url('{$this->upload_url}custom/$name/{$output['svg']}#svg$name') format('svg')";
932
+            }
933
+
934
+            if ( ! empty( $src ) ) {
935
+                $css .= 'src:' . implode( ', ', $src ) . ';';
936
+            }
937
+
938
+            // Replace font weight and style with sub-sets.
939
+            $css .= 'font-weight: normal;';
940
+
941
+            $css .= 'font-style: normal;';
942
+
943
+            $css .= '}';
944
+
945
+            return $css;
946
+        }
947
+
948
+        /**
949
+         * Custom function for filtering the section array.
950
+         * Good for child themes to override or add to the sections.
951
+         * Simply include this function in the child themes functions.php file.
952
+         * NOTE: the defined constants for URLs and directories will NOT be available at this point in a child theme,
953
+         * so you must use get_template_directory_uri() if you want to use any of the built-in icons
954
+         */
955
+        public function add_section() {
956
+            if ( ! isset( $this->parent->fontControl ) ) {
957
+                $this->parent->sections[] = array(
958
+                    'title'  => esc_html__( 'Font Control', 'redux-framework' ),
959
+                    'desc'   => '<p class="description"></p>',
960
+                    'icon'   => 'el-icon-font',
961
+                    'id'     => 'redux_dynamic_font_control',
962
+                    // Leave this as a blank section, no options just some intro text set above.
963
+                    'fields' => array(),
964
+                );
965
+
966
+                for ( $i = count( $this->parent->sections ); $i >= 1; $i-- ) {
967
+                    if ( isset( $this->parent->sections[ $i ] ) && isset( $this->parent->sections[ $i ]['title'] ) && esc_html__( 'Font Control', 'redux-framework' ) === $this->parent->sections[ $i ]['title'] ) {
968
+                        $this->parent->fontControl                                        = $i;
969
+                        $this->parent->sections[ $this->parent->fontControl ]['fields'][] = array(
970
+                            'id'   => 'redux_font_control',
971
+                            'type' => 'custom_fonts',
972
+                        );
973
+
974
+                        break;
975
+                    }
976
+                }
977
+            }
978
+        }
979
+    }
980
+
981
+    class_alias( Redux_Extension_Custom_Fonts::class, 'ReduxFramework_Extension_custom_fonts' );
982 982
 }
Please login to merge, or discard this patch.
redux-core/inc/classes/class-redux-api.php 2 patches
Indentation   +1754 added lines, -1754 removed lines patch added patch discarded remove patch
@@ -16,1758 +16,1758 @@
 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
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
-					$$opt_name = $values;
1316
-				} else {
1317
-					$values = $$opt_name;
1318
-				}
1319
-
1320
-				if ( ! isset( $values[ $key ] ) ) {
1321
-					if ( null === $default ) {
1322
-						$field = self::get_field( $opt_name, $key );
1323
-
1324
-						if ( false !== $field ) {
1325
-							$defaults_class = new Redux_Options_Defaults();
1326
-							$sections       = self::construct_sections( $opt_name );
1327
-							$defaults       = $defaults_class->default_values( $opt_name, $sections );
1328
-
1329
-							if ( isset( $defaults[ $key ] ) ) {
1330
-								$default = $defaults[ $key ];
1331
-							}
1332
-						}
1333
-					}
1334
-				}
1335
-
1336
-				if ( ! empty( $subkeys ) && is_array( $subkeys ) ) {
1337
-					$value = $default;
1338
-
1339
-					if ( isset( $values[ $key ] ) ) {
1340
-						$count = count( $subkeys );
1341
-
1342
-						if ( 1 === $count ) {
1343
-							$value = $values[ $key ][ $subkeys[1] ] ?? $default;
1344
-						} elseif ( 2 === $count ) {
1345
-							if ( isset( $values[ $key ][ $subkeys[1] ] ) ) {
1346
-								$value = $values[ $key ][ $subkeys[1] ][ $subkeys[2] ] ?? $default;
1347
-							}
1348
-						} elseif ( 3 === $count ) {
1349
-							if ( isset( $values[ $key ][ $subkeys[1] ] ) ) {
1350
-								if ( isset( $values[ $key ][ $subkeys[1] ][ $subkeys[2] ] ) ) {
1351
-									$value = $values[ $key ][ $subkeys[1] ][ $subkeys[2] ][ $subkeys[3] ] ?? $default;
1352
-								}
1353
-							}
1354
-						}
1355
-					}
1356
-				} else {
1357
-					$value = $values[ $key ] ?? $default;
1358
-				}
1359
-
1360
-				return $value;
1361
-			} else {
1362
-				return false;
1363
-			}
1364
-		}
1365
-
1366
-		/**
1367
-		 * Deprecated Sets an option into the database.
1368
-		 *
1369
-		 * @param string $opt_name Panel opt_name.
1370
-		 * @param string $key      Option key.
1371
-		 * @param mixed  $option   Option value.
1372
-		 *
1373
-		 * @return bool
1374
-		 * @deprecated No longer using camelCase naming convention.
1375
-		 */
1376
-		public static function setOption( string $opt_name = '', string $key = '', $option = '' ): bool { // phpcs:ignore WordPress.NamingConventions.ValidFunctionName
1377
-			_deprecated_function( __CLASS__ . '::' . __FUNCTION__, 'Redux 4.3', 'Redux::set_option( $opt_name, $key, $option )' );
1378
-
1379
-			if ( '' !== $opt_name ) {
1380
-				Redux_Functions_Ex::record_caller( $opt_name );
1381
-			}
1382
-
1383
-			return self::set_option( $opt_name, $key, $option );
1384
-		}
1385
-
1386
-		/**
1387
-		 * Sets an option into the database.
1388
-		 *
1389
-		 * @param string $opt_name Panel opt_name.
1390
-		 * @param string $key      Option key.
1391
-		 * @param mixed  $option   Option value.
1392
-		 *
1393
-		 * @return bool
1394
-		 */
1395
-		public static function set_option( string $opt_name = '', string $key = '', $option = '' ): bool {
1396
-			if ( '' === $key ) {
1397
-				return false;
1398
-			}
1399
-
1400
-			self::check_opt_name( $opt_name );
1401
-
1402
-			Redux_Functions_Ex::record_caller( $opt_name );
1403
-
1404
-			if ( '' !== $opt_name ) {
1405
-				$redux         = get_option( $opt_name );
1406
-				$redux[ $key ] = $option;
1407
-
1408
-				return update_option( $opt_name, $redux );
1409
-			} else {
1410
-				return false;
1411
-			}
1412
-		}
1413
-
1414
-		/**
1415
-		 * Get the next available priority for field/section.
1416
-		 *
1417
-		 * @param string $opt_name Panel opt_name.
1418
-		 * @param string $type     Field or section.
1419
-		 *
1420
-		 * @return mixed
1421
-		 */
1422
-		public static function get_priority( string $opt_name, string $type ) {
1423
-			$priority                              = self::$priority[ $opt_name ][ $type ];
1424
-			self::$priority[ $opt_name ][ $type ] += 1;
1425
-
1426
-			return $priority;
1427
-		}
1428
-
1429
-		/**
1430
-		 * Check opt_name integrity.
1431
-		 *
1432
-		 * @param string $opt_name Panel opt_name.
1433
-		 */
1434
-		public static function check_opt_name( string $opt_name = '' ) {
1435
-			if ( empty( $opt_name ) || is_array( $opt_name ) ) {
1436
-				return;
1437
-			}
1438
-
1439
-			if ( ! isset( self::$sections[ $opt_name ] ) ) {
1440
-				self::$sections[ $opt_name ]             = array();
1441
-				self::$priority[ $opt_name ]['sections'] = 1;
1442
-			}
1443
-
1444
-			if ( ! isset( self::$args[ $opt_name ] ) ) {
1445
-				self::$args[ $opt_name ]             = array();
1446
-				self::$priority[ $opt_name ]['args'] = 1;
1447
-			}
1448
-
1449
-			if ( ! isset( self::$fields[ $opt_name ] ) ) {
1450
-				self::$fields[ $opt_name ]             = array();
1451
-				self::$priority[ $opt_name ]['fields'] = 1;
1452
-			}
1453
-
1454
-			if ( ! isset( self::$help[ $opt_name ] ) ) {
1455
-				self::$help[ $opt_name ]             = array();
1456
-				self::$priority[ $opt_name ]['help'] = 1;
1457
-			}
1458
-
1459
-			if ( ! isset( self::$errors[ $opt_name ] ) ) {
1460
-				self::$errors[ $opt_name ] = array();
1461
-			}
1462
-
1463
-			if ( ! isset( self::$init[ $opt_name ] ) ) {
1464
-				self::$init[ $opt_name ] = false;
1465
-			}
1466
-		}
1467
-
1468
-		/**
1469
-		 * Retrieve metadata from a file. Based on WP Core's get_file_data function
1470
-		 *
1471
-		 * @param string $file Path to the file.
1472
-		 *
1473
-		 * @return string
1474
-		 * @since 2.1.1
1475
-		 */
1476
-		public static function get_file_version( string $file ): string {
1477
-			$data = get_file_data( $file, array( 'version' ), 'plugin' );
1478
-
1479
-			return $data[0];
1480
-		}
1481
-
1482
-		/**
1483
-		 * Verify extension class name.
1484
-		 *
1485
-		 * @param string $opt_name   Panel opt_name.
1486
-		 * @param string $name       extension name.
1487
-		 * @param string $class_file Extension class file.
1488
-		 */
1489
-		private static function check_extension_class_file( string $opt_name, string $name = '', string $class_file = '' ) {
1490
-			$instance = null;
1491
-
1492
-			if ( file_exists( $class_file ) ) {
1493
-				self::$uses_extensions[ $opt_name ] = self::$uses_extensions[ $opt_name ] ?? array();
1494
-
1495
-				if ( ! in_array( $name, self::$uses_extensions[ $opt_name ], true ) ) {
1496
-					self::$uses_extensions[ $opt_name ][] = $name;
1497
-				}
1498
-
1499
-				self::$extensions[ $name ] = self::$extensions[ $name ] ?? array();
1500
-
1501
-				$version = Redux_Helpers::get_template_version( $class_file );
1502
-
1503
-				if ( empty( $version ) && ! empty( $instance ) ) {
1504
-					if ( isset( $instance->version ) ) {
1505
-						$version = $instance->version;
1506
-					}
1507
-				}
1508
-				self::$extensions[ $name ][ $version ] = self::$extensions[ $name ][ $version ] ?? $class_file;
1509
-
1510
-				$new_name  = str_replace( '_', '-', $name );
1511
-				$api_check = str_replace(
1512
-					array(
1513
-						'extension_' . $name,
1514
-						'class-redux-extension-' . $new_name,
1515
-					),
1516
-					array(
1517
-						$name . '_api',
1518
-						'class-redux-' . $new_name . '-api',
1519
-					),
1520
-					$class_file
1521
-				);
1522
-
1523
-				if ( file_exists( $api_check ) && ! class_exists( 'Redux_' . ucfirst( $name ) ) ) {
1524
-					include_once $api_check;
1525
-				}
1526
-			}
1527
-		}
1528
-
1529
-		/**
1530
-		 * Deprecated Sets all extensions in a path.
1531
-		 *
1532
-		 * @param string $opt_name Panel opt_name.
1533
-		 * @param string $path     Path to extension folder.
1534
-		 *
1535
-		 * @deprecated No longer using camelCase naming convention.
1536
-		 */
1537
-		public static function setExtensions( string $opt_name, string $path ) { // phpcs:ignore WordPress.NamingConventions.ValidFunctionName
1538
-			_deprecated_function( __CLASS__ . '::' . __FUNCTION__, 'Redux 4.3', 'Redux::get_extensions( $opt_name, $path )' );
1539
-
1540
-			if ( '' !== $opt_name ) {
1541
-				Redux_Functions_Ex::record_caller( $opt_name );
1542
-			}
1543
-
1544
-			self::set_extensions( $opt_name, $path );
1545
-		}
1546
-
1547
-		/**
1548
-		 * Sets all extensions in a path.
1549
-		 *
1550
-		 * @param string $opt_name Panel opt_name.
1551
-		 * @param string $path     Path to extension folder.
1552
-		 * @param bool   $force    Make extension reload.
1553
-		 */
1554
-		public static function set_extensions( string $opt_name, string $path, bool $force = false ) {
1555
-			if ( '' === $path || '' === $opt_name ) {
1556
-				return;
1557
-			}
1558
-
1559
-			self::check_opt_name( $opt_name );
1560
-
1561
-			Redux_Functions_Ex::record_caller( $opt_name );
1562
-
1563
-			if ( is_dir( $path ) ) {
1564
-				$path   = trailingslashit( $path );
1565
-				$folder = str_replace( '.php', '', basename( $path ) );
1566
-
1567
-				$folder_fix = str_replace( '_', '-', $folder );
1568
-
1569
-				$files = array(
1570
-					$path . 'extension_' . $folder . '.php',
1571
-					$path . 'class-redux-extension-' . $folder_fix . '.php',
1572
-				);
1573
-
1574
-				$ext_file = Redux_Functions::file_exists_ex( $files );
1575
-
1576
-				if ( $ext_file ) {
1577
-					self::check_extension_class_file( $opt_name, $folder, $ext_file );
1578
-				} else {
1579
-					$folders = scandir( $path );
1580
-
1581
-					foreach ( $folders as $folder ) {
1582
-						if ( '.' === $folder || '..' === $folder ) {
1583
-							continue;
1584
-						}
1585
-
1586
-						if ( is_dir( $path . $folder ) ) {
1587
-							self::set_extensions( $opt_name, $path . $folder );
1588
-						}
1589
-					}
1590
-				}
1591
-			} elseif ( file_exists( $path ) ) {
1592
-				$name = explode( 'extension_', basename( $path ) );
1593
-				if ( ! empty( $name[1] ) ) {
1594
-					$name = str_replace( '.php', '', $name[1] );
1595
-					self::check_extension_class_file( $opt_name, $name, $path );
1596
-				}
1597
-			}
1598
-
1599
-			self::$extension_paths[ $opt_name ] = $path;
1600
-
1601
-			if ( true === $force ) {
1602
-				if ( isset( self::$uses_extensions[ $opt_name ] ) && ! empty( self::$uses_extensions[ $opt_name ] ) ) {
1603
-					$redux = self::instance( $opt_name );
1604
-
1605
-					if ( isset( $redux ) ) {
1606
-						self::load_extensions( $redux );
1607
-					}
1608
-				}
1609
-			}
1610
-		}
1611
-
1612
-		/**
1613
-		 * Retrieves all loaded extensions.
1614
-		 */
1615
-		private static function get_all_extension() {
1616
-			$redux = self::all_instances();
1617
-
1618
-			foreach ( $redux as $instance ) {
1619
-				if ( ! empty( self::$uses_extensions[ $instance['args']['opt_name'] ] ) ) {
1620
-					continue;
1621
-				}
1622
-				if ( ! empty( $instance['extensions'] ) ) {
1623
-					self::get_instance_extension( $instance['args']['opt_name'], $instance );
1624
-				}
1625
-			}
1626
-		}
1627
-
1628
-		/**
1629
-		 * Gets all loaded extensions for the passed ReduxFramework instance.
1630
-		 *
1631
-		 * @param string      $opt_name Panel opt_name.
1632
-		 * @param object|null $instance ReduxFramework instance.
1633
-		 */
1634
-		public static function get_instance_extension( string $opt_name, $instance ) {
1635
-			if ( ! empty( self::$uses_extensions[ $opt_name ] ) || empty( $opt_name ) ) {
1636
-				return;
1637
-			}
1638
-
1639
-			if ( empty( $instance ) ) {
1640
-				$instance = self::instance( $opt_name );
1641
-			}
1642
-
1643
-			if ( empty( $instance ) || empty( $instance->extensions ) ) {
1644
-				return;
1645
-			}
1646
-
1647
-			foreach ( $instance->extensions as $name => $extension ) {
1648
-				if ( 'widget_areas' === $name ) {
1649
-					new Redux_Widget_Areas( $instance );
1650
-				}
1651
-
1652
-				if ( isset( self::$uses_extensions[ $opt_name ][ $name ] ) ) {
1653
-					continue;
1654
-				}
1655
-
1656
-				if ( isset( $extension->extension_dir ) ) {
1657
-					self::set_extensions( $opt_name, str_replace( $name, '', $extension->extension_dir ) );
1658
-				}
1659
-			}
1660
-		}
1661
-
1662
-		/**
1663
-		 * Deprecated Gets loaded extensions.
1664
-		 *
1665
-		 * @param string $opt_name Panel opt_name.
1666
-		 * @param string $key      Extension name.
1667
-		 *
1668
-		 * @return array|bool|mixed
1669
-		 * @deprecated No longer using camelCase naming convention.
1670
-		 */
1671
-		public static function getExtensions( string $opt_name = '', string $key = '' ) { // phpcs:ignore WordPress.NamingConventions.ValidFunctionName
1672
-			_deprecated_function( __CLASS__ . '::' . __FUNCTION__, 'Redux 4.0.0', 'self::get_extensions( $opt_name, $key )' );
1673
-
1674
-			return self::get_extensions( $opt_name, $key );
1675
-		}
1676
-
1677
-		/**
1678
-		 * Gets loaded extensions.
1679
-		 *
1680
-		 * @param string $opt_name Panel opt_name.
1681
-		 * @param string $key      Extension name.
1682
-		 *
1683
-		 * @return array|bool|mixed
1684
-		 */
1685
-		public static function get_extensions( string $opt_name = '', string $key = '' ) {
1686
-			if ( empty( $opt_name ) ) {
1687
-				self::get_all_extension();
1688
-
1689
-				if ( empty( $key ) ) {
1690
-					return self::$extension_paths;
1691
-				} elseif ( isset( self::$extension_paths[ $key ] ) ) {
1692
-						return self::$extension_paths[ $key ];
1693
-				}
1694
-			} else {
1695
-				if ( empty( self::$uses_extensions[ $opt_name ] ) ) {
1696
-					self::get_instance_extension( $opt_name, null );
1697
-				}
1698
-
1699
-				if ( empty( self::$uses_extensions[ $opt_name ] ) ) {
1700
-					return false;
1701
-				}
1702
-
1703
-				$instance_extensions = array();
1704
-
1705
-				foreach ( self::$uses_extensions[ $opt_name ] as $extension ) {
1706
-					$class_file = end( self::$extensions[ $extension ] );
1707
-					$directory  = explode( DIRECTORY_SEPARATOR, $class_file );
1708
-					array_pop( $directory );
1709
-					$directory       = trailingslashit( join( DIRECTORY_SEPARATOR, $directory ) );
1710
-					$name            = str_replace( '.php', '', basename( $extension ) );
1711
-					$extension_class = 'Redux_Extension_' . $name;
1712
-					$the_data        = array(
1713
-						'path'    => $class_file,
1714
-						'dir'     => $directory,
1715
-						'class'   => $extension_class,
1716
-						'version' => Redux_Helpers::get_template_version( $class_file ),
1717
-					);
1718
-
1719
-					if ( is_dir( $the_data['dir'] . $extension ) ) {
1720
-						$test_path = trailingslashit( $the_data['dir'] . $extension );
1721
-						if ( file_exists( $test_path . 'field_' . str_replace( '-', '', $extension ) . '.php' ) ) {
1722
-							$the_data['field'] = $test_path . 'field_' . str_replace( '-', '', $extension ) . '.php';
1723
-						}
1724
-						// Old extensions!
1725
-						if ( file_exists( $test_path . str_replace( '-', '', $extension ) . '.php' ) ) {
1726
-							$the_data['field'] = $test_path . str_replace( '-', '', $extension ) . '.php';
1727
-						}
1728
-					}
1729
-					$instance_extensions[ $extension ] = $the_data;
1730
-				}
1731
-
1732
-				return $instance_extensions;
1733
-			}
1734
-
1735
-			return false;
1736
-		}
1737
-
1738
-		/**
1739
-		 * Method to disables Redux demo mode popup.
1740
-		 */
1741
-		public static function disable_demo() {
1742
-			add_action( 'ReduxFrameworkPlugin_admin_notice', 'Redux::remove_demo' );
1743
-			add_action( 'redux_framework_plugin_admin_notice', 'Redux::remove_demo' );
1744
-		}
1745
-
1746
-		/**
1747
-		 * Callback used by self::disable_demo() to remove the demo mode notice from Redux.
1748
-		 */
1749
-		public static function remove_demo() {
1750
-			update_option( 'ReduxFrameworkPlugin_ACTIVATED_NOTICES', '' );
1751
-		}
1752
-
1753
-		/**
1754
-		 * Function which forces a panel/page to render.
1755
-		 *
1756
-		 * @param string|object $redux Panel opt_name or Redux object.
1757
-		 */
1758
-		public static function render( $redux = '' ) {
1759
-			if ( is_string( $redux ) ) {
1760
-				$redux = Redux_Instances::get_instance( $redux );
1761
-				if ( empty( $redux ) ) {
1762
-					return;
1763
-				}
1764
-			}
1765
-			$enqueue = new Redux_Enqueue( $redux );
1766
-			$enqueue->init();
1767
-			$panel = new Redux_Panel( $redux );
1768
-			$panel->init();
1769
-		}
1770
-	}
1771
-
1772
-	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
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
+                    $$opt_name = $values;
1316
+                } else {
1317
+                    $values = $$opt_name;
1318
+                }
1319
+
1320
+                if ( ! isset( $values[ $key ] ) ) {
1321
+                    if ( null === $default ) {
1322
+                        $field = self::get_field( $opt_name, $key );
1323
+
1324
+                        if ( false !== $field ) {
1325
+                            $defaults_class = new Redux_Options_Defaults();
1326
+                            $sections       = self::construct_sections( $opt_name );
1327
+                            $defaults       = $defaults_class->default_values( $opt_name, $sections );
1328
+
1329
+                            if ( isset( $defaults[ $key ] ) ) {
1330
+                                $default = $defaults[ $key ];
1331
+                            }
1332
+                        }
1333
+                    }
1334
+                }
1335
+
1336
+                if ( ! empty( $subkeys ) && is_array( $subkeys ) ) {
1337
+                    $value = $default;
1338
+
1339
+                    if ( isset( $values[ $key ] ) ) {
1340
+                        $count = count( $subkeys );
1341
+
1342
+                        if ( 1 === $count ) {
1343
+                            $value = $values[ $key ][ $subkeys[1] ] ?? $default;
1344
+                        } elseif ( 2 === $count ) {
1345
+                            if ( isset( $values[ $key ][ $subkeys[1] ] ) ) {
1346
+                                $value = $values[ $key ][ $subkeys[1] ][ $subkeys[2] ] ?? $default;
1347
+                            }
1348
+                        } elseif ( 3 === $count ) {
1349
+                            if ( isset( $values[ $key ][ $subkeys[1] ] ) ) {
1350
+                                if ( isset( $values[ $key ][ $subkeys[1] ][ $subkeys[2] ] ) ) {
1351
+                                    $value = $values[ $key ][ $subkeys[1] ][ $subkeys[2] ][ $subkeys[3] ] ?? $default;
1352
+                                }
1353
+                            }
1354
+                        }
1355
+                    }
1356
+                } else {
1357
+                    $value = $values[ $key ] ?? $default;
1358
+                }
1359
+
1360
+                return $value;
1361
+            } else {
1362
+                return false;
1363
+            }
1364
+        }
1365
+
1366
+        /**
1367
+         * Deprecated Sets an option into the database.
1368
+         *
1369
+         * @param string $opt_name Panel opt_name.
1370
+         * @param string $key      Option key.
1371
+         * @param mixed  $option   Option value.
1372
+         *
1373
+         * @return bool
1374
+         * @deprecated No longer using camelCase naming convention.
1375
+         */
1376
+        public static function setOption( string $opt_name = '', string $key = '', $option = '' ): bool { // phpcs:ignore WordPress.NamingConventions.ValidFunctionName
1377
+            _deprecated_function( __CLASS__ . '::' . __FUNCTION__, 'Redux 4.3', 'Redux::set_option( $opt_name, $key, $option )' );
1378
+
1379
+            if ( '' !== $opt_name ) {
1380
+                Redux_Functions_Ex::record_caller( $opt_name );
1381
+            }
1382
+
1383
+            return self::set_option( $opt_name, $key, $option );
1384
+        }
1385
+
1386
+        /**
1387
+         * Sets an option into the database.
1388
+         *
1389
+         * @param string $opt_name Panel opt_name.
1390
+         * @param string $key      Option key.
1391
+         * @param mixed  $option   Option value.
1392
+         *
1393
+         * @return bool
1394
+         */
1395
+        public static function set_option( string $opt_name = '', string $key = '', $option = '' ): bool {
1396
+            if ( '' === $key ) {
1397
+                return false;
1398
+            }
1399
+
1400
+            self::check_opt_name( $opt_name );
1401
+
1402
+            Redux_Functions_Ex::record_caller( $opt_name );
1403
+
1404
+            if ( '' !== $opt_name ) {
1405
+                $redux         = get_option( $opt_name );
1406
+                $redux[ $key ] = $option;
1407
+
1408
+                return update_option( $opt_name, $redux );
1409
+            } else {
1410
+                return false;
1411
+            }
1412
+        }
1413
+
1414
+        /**
1415
+         * Get the next available priority for field/section.
1416
+         *
1417
+         * @param string $opt_name Panel opt_name.
1418
+         * @param string $type     Field or section.
1419
+         *
1420
+         * @return mixed
1421
+         */
1422
+        public static function get_priority( string $opt_name, string $type ) {
1423
+            $priority                              = self::$priority[ $opt_name ][ $type ];
1424
+            self::$priority[ $opt_name ][ $type ] += 1;
1425
+
1426
+            return $priority;
1427
+        }
1428
+
1429
+        /**
1430
+         * Check opt_name integrity.
1431
+         *
1432
+         * @param string $opt_name Panel opt_name.
1433
+         */
1434
+        public static function check_opt_name( string $opt_name = '' ) {
1435
+            if ( empty( $opt_name ) || is_array( $opt_name ) ) {
1436
+                return;
1437
+            }
1438
+
1439
+            if ( ! isset( self::$sections[ $opt_name ] ) ) {
1440
+                self::$sections[ $opt_name ]             = array();
1441
+                self::$priority[ $opt_name ]['sections'] = 1;
1442
+            }
1443
+
1444
+            if ( ! isset( self::$args[ $opt_name ] ) ) {
1445
+                self::$args[ $opt_name ]             = array();
1446
+                self::$priority[ $opt_name ]['args'] = 1;
1447
+            }
1448
+
1449
+            if ( ! isset( self::$fields[ $opt_name ] ) ) {
1450
+                self::$fields[ $opt_name ]             = array();
1451
+                self::$priority[ $opt_name ]['fields'] = 1;
1452
+            }
1453
+
1454
+            if ( ! isset( self::$help[ $opt_name ] ) ) {
1455
+                self::$help[ $opt_name ]             = array();
1456
+                self::$priority[ $opt_name ]['help'] = 1;
1457
+            }
1458
+
1459
+            if ( ! isset( self::$errors[ $opt_name ] ) ) {
1460
+                self::$errors[ $opt_name ] = array();
1461
+            }
1462
+
1463
+            if ( ! isset( self::$init[ $opt_name ] ) ) {
1464
+                self::$init[ $opt_name ] = false;
1465
+            }
1466
+        }
1467
+
1468
+        /**
1469
+         * Retrieve metadata from a file. Based on WP Core's get_file_data function
1470
+         *
1471
+         * @param string $file Path to the file.
1472
+         *
1473
+         * @return string
1474
+         * @since 2.1.1
1475
+         */
1476
+        public static function get_file_version( string $file ): string {
1477
+            $data = get_file_data( $file, array( 'version' ), 'plugin' );
1478
+
1479
+            return $data[0];
1480
+        }
1481
+
1482
+        /**
1483
+         * Verify extension class name.
1484
+         *
1485
+         * @param string $opt_name   Panel opt_name.
1486
+         * @param string $name       extension name.
1487
+         * @param string $class_file Extension class file.
1488
+         */
1489
+        private static function check_extension_class_file( string $opt_name, string $name = '', string $class_file = '' ) {
1490
+            $instance = null;
1491
+
1492
+            if ( file_exists( $class_file ) ) {
1493
+                self::$uses_extensions[ $opt_name ] = self::$uses_extensions[ $opt_name ] ?? array();
1494
+
1495
+                if ( ! in_array( $name, self::$uses_extensions[ $opt_name ], true ) ) {
1496
+                    self::$uses_extensions[ $opt_name ][] = $name;
1497
+                }
1498
+
1499
+                self::$extensions[ $name ] = self::$extensions[ $name ] ?? array();
1500
+
1501
+                $version = Redux_Helpers::get_template_version( $class_file );
1502
+
1503
+                if ( empty( $version ) && ! empty( $instance ) ) {
1504
+                    if ( isset( $instance->version ) ) {
1505
+                        $version = $instance->version;
1506
+                    }
1507
+                }
1508
+                self::$extensions[ $name ][ $version ] = self::$extensions[ $name ][ $version ] ?? $class_file;
1509
+
1510
+                $new_name  = str_replace( '_', '-', $name );
1511
+                $api_check = str_replace(
1512
+                    array(
1513
+                        'extension_' . $name,
1514
+                        'class-redux-extension-' . $new_name,
1515
+                    ),
1516
+                    array(
1517
+                        $name . '_api',
1518
+                        'class-redux-' . $new_name . '-api',
1519
+                    ),
1520
+                    $class_file
1521
+                );
1522
+
1523
+                if ( file_exists( $api_check ) && ! class_exists( 'Redux_' . ucfirst( $name ) ) ) {
1524
+                    include_once $api_check;
1525
+                }
1526
+            }
1527
+        }
1528
+
1529
+        /**
1530
+         * Deprecated Sets all extensions in a path.
1531
+         *
1532
+         * @param string $opt_name Panel opt_name.
1533
+         * @param string $path     Path to extension folder.
1534
+         *
1535
+         * @deprecated No longer using camelCase naming convention.
1536
+         */
1537
+        public static function setExtensions( string $opt_name, string $path ) { // phpcs:ignore WordPress.NamingConventions.ValidFunctionName
1538
+            _deprecated_function( __CLASS__ . '::' . __FUNCTION__, 'Redux 4.3', 'Redux::get_extensions( $opt_name, $path )' );
1539
+
1540
+            if ( '' !== $opt_name ) {
1541
+                Redux_Functions_Ex::record_caller( $opt_name );
1542
+            }
1543
+
1544
+            self::set_extensions( $opt_name, $path );
1545
+        }
1546
+
1547
+        /**
1548
+         * Sets all extensions in a path.
1549
+         *
1550
+         * @param string $opt_name Panel opt_name.
1551
+         * @param string $path     Path to extension folder.
1552
+         * @param bool   $force    Make extension reload.
1553
+         */
1554
+        public static function set_extensions( string $opt_name, string $path, bool $force = false ) {
1555
+            if ( '' === $path || '' === $opt_name ) {
1556
+                return;
1557
+            }
1558
+
1559
+            self::check_opt_name( $opt_name );
1560
+
1561
+            Redux_Functions_Ex::record_caller( $opt_name );
1562
+
1563
+            if ( is_dir( $path ) ) {
1564
+                $path   = trailingslashit( $path );
1565
+                $folder = str_replace( '.php', '', basename( $path ) );
1566
+
1567
+                $folder_fix = str_replace( '_', '-', $folder );
1568
+
1569
+                $files = array(
1570
+                    $path . 'extension_' . $folder . '.php',
1571
+                    $path . 'class-redux-extension-' . $folder_fix . '.php',
1572
+                );
1573
+
1574
+                $ext_file = Redux_Functions::file_exists_ex( $files );
1575
+
1576
+                if ( $ext_file ) {
1577
+                    self::check_extension_class_file( $opt_name, $folder, $ext_file );
1578
+                } else {
1579
+                    $folders = scandir( $path );
1580
+
1581
+                    foreach ( $folders as $folder ) {
1582
+                        if ( '.' === $folder || '..' === $folder ) {
1583
+                            continue;
1584
+                        }
1585
+
1586
+                        if ( is_dir( $path . $folder ) ) {
1587
+                            self::set_extensions( $opt_name, $path . $folder );
1588
+                        }
1589
+                    }
1590
+                }
1591
+            } elseif ( file_exists( $path ) ) {
1592
+                $name = explode( 'extension_', basename( $path ) );
1593
+                if ( ! empty( $name[1] ) ) {
1594
+                    $name = str_replace( '.php', '', $name[1] );
1595
+                    self::check_extension_class_file( $opt_name, $name, $path );
1596
+                }
1597
+            }
1598
+
1599
+            self::$extension_paths[ $opt_name ] = $path;
1600
+
1601
+            if ( true === $force ) {
1602
+                if ( isset( self::$uses_extensions[ $opt_name ] ) && ! empty( self::$uses_extensions[ $opt_name ] ) ) {
1603
+                    $redux = self::instance( $opt_name );
1604
+
1605
+                    if ( isset( $redux ) ) {
1606
+                        self::load_extensions( $redux );
1607
+                    }
1608
+                }
1609
+            }
1610
+        }
1611
+
1612
+        /**
1613
+         * Retrieves all loaded extensions.
1614
+         */
1615
+        private static function get_all_extension() {
1616
+            $redux = self::all_instances();
1617
+
1618
+            foreach ( $redux as $instance ) {
1619
+                if ( ! empty( self::$uses_extensions[ $instance['args']['opt_name'] ] ) ) {
1620
+                    continue;
1621
+                }
1622
+                if ( ! empty( $instance['extensions'] ) ) {
1623
+                    self::get_instance_extension( $instance['args']['opt_name'], $instance );
1624
+                }
1625
+            }
1626
+        }
1627
+
1628
+        /**
1629
+         * Gets all loaded extensions for the passed ReduxFramework instance.
1630
+         *
1631
+         * @param string      $opt_name Panel opt_name.
1632
+         * @param object|null $instance ReduxFramework instance.
1633
+         */
1634
+        public static function get_instance_extension( string $opt_name, $instance ) {
1635
+            if ( ! empty( self::$uses_extensions[ $opt_name ] ) || empty( $opt_name ) ) {
1636
+                return;
1637
+            }
1638
+
1639
+            if ( empty( $instance ) ) {
1640
+                $instance = self::instance( $opt_name );
1641
+            }
1642
+
1643
+            if ( empty( $instance ) || empty( $instance->extensions ) ) {
1644
+                return;
1645
+            }
1646
+
1647
+            foreach ( $instance->extensions as $name => $extension ) {
1648
+                if ( 'widget_areas' === $name ) {
1649
+                    new Redux_Widget_Areas( $instance );
1650
+                }
1651
+
1652
+                if ( isset( self::$uses_extensions[ $opt_name ][ $name ] ) ) {
1653
+                    continue;
1654
+                }
1655
+
1656
+                if ( isset( $extension->extension_dir ) ) {
1657
+                    self::set_extensions( $opt_name, str_replace( $name, '', $extension->extension_dir ) );
1658
+                }
1659
+            }
1660
+        }
1661
+
1662
+        /**
1663
+         * Deprecated Gets loaded extensions.
1664
+         *
1665
+         * @param string $opt_name Panel opt_name.
1666
+         * @param string $key      Extension name.
1667
+         *
1668
+         * @return array|bool|mixed
1669
+         * @deprecated No longer using camelCase naming convention.
1670
+         */
1671
+        public static function getExtensions( string $opt_name = '', string $key = '' ) { // phpcs:ignore WordPress.NamingConventions.ValidFunctionName
1672
+            _deprecated_function( __CLASS__ . '::' . __FUNCTION__, 'Redux 4.0.0', 'self::get_extensions( $opt_name, $key )' );
1673
+
1674
+            return self::get_extensions( $opt_name, $key );
1675
+        }
1676
+
1677
+        /**
1678
+         * Gets loaded extensions.
1679
+         *
1680
+         * @param string $opt_name Panel opt_name.
1681
+         * @param string $key      Extension name.
1682
+         *
1683
+         * @return array|bool|mixed
1684
+         */
1685
+        public static function get_extensions( string $opt_name = '', string $key = '' ) {
1686
+            if ( empty( $opt_name ) ) {
1687
+                self::get_all_extension();
1688
+
1689
+                if ( empty( $key ) ) {
1690
+                    return self::$extension_paths;
1691
+                } elseif ( isset( self::$extension_paths[ $key ] ) ) {
1692
+                        return self::$extension_paths[ $key ];
1693
+                }
1694
+            } else {
1695
+                if ( empty( self::$uses_extensions[ $opt_name ] ) ) {
1696
+                    self::get_instance_extension( $opt_name, null );
1697
+                }
1698
+
1699
+                if ( empty( self::$uses_extensions[ $opt_name ] ) ) {
1700
+                    return false;
1701
+                }
1702
+
1703
+                $instance_extensions = array();
1704
+
1705
+                foreach ( self::$uses_extensions[ $opt_name ] as $extension ) {
1706
+                    $class_file = end( self::$extensions[ $extension ] );
1707
+                    $directory  = explode( DIRECTORY_SEPARATOR, $class_file );
1708
+                    array_pop( $directory );
1709
+                    $directory       = trailingslashit( join( DIRECTORY_SEPARATOR, $directory ) );
1710
+                    $name            = str_replace( '.php', '', basename( $extension ) );
1711
+                    $extension_class = 'Redux_Extension_' . $name;
1712
+                    $the_data        = array(
1713
+                        'path'    => $class_file,
1714
+                        'dir'     => $directory,
1715
+                        'class'   => $extension_class,
1716
+                        'version' => Redux_Helpers::get_template_version( $class_file ),
1717
+                    );
1718
+
1719
+                    if ( is_dir( $the_data['dir'] . $extension ) ) {
1720
+                        $test_path = trailingslashit( $the_data['dir'] . $extension );
1721
+                        if ( file_exists( $test_path . 'field_' . str_replace( '-', '', $extension ) . '.php' ) ) {
1722
+                            $the_data['field'] = $test_path . 'field_' . str_replace( '-', '', $extension ) . '.php';
1723
+                        }
1724
+                        // Old extensions!
1725
+                        if ( file_exists( $test_path . str_replace( '-', '', $extension ) . '.php' ) ) {
1726
+                            $the_data['field'] = $test_path . str_replace( '-', '', $extension ) . '.php';
1727
+                        }
1728
+                    }
1729
+                    $instance_extensions[ $extension ] = $the_data;
1730
+                }
1731
+
1732
+                return $instance_extensions;
1733
+            }
1734
+
1735
+            return false;
1736
+        }
1737
+
1738
+        /**
1739
+         * Method to disables Redux demo mode popup.
1740
+         */
1741
+        public static function disable_demo() {
1742
+            add_action( 'ReduxFrameworkPlugin_admin_notice', 'Redux::remove_demo' );
1743
+            add_action( 'redux_framework_plugin_admin_notice', 'Redux::remove_demo' );
1744
+        }
1745
+
1746
+        /**
1747
+         * Callback used by self::disable_demo() to remove the demo mode notice from Redux.
1748
+         */
1749
+        public static function remove_demo() {
1750
+            update_option( 'ReduxFrameworkPlugin_ACTIVATED_NOTICES', '' );
1751
+        }
1752
+
1753
+        /**
1754
+         * Function which forces a panel/page to render.
1755
+         *
1756
+         * @param string|object $redux Panel opt_name or Redux object.
1757
+         */
1758
+        public static function render( $redux = '' ) {
1759
+            if ( is_string( $redux ) ) {
1760
+                $redux = Redux_Instances::get_instance( $redux );
1761
+                if ( empty( $redux ) ) {
1762
+                    return;
1763
+                }
1764
+            }
1765
+            $enqueue = new Redux_Enqueue( $redux );
1766
+            $enqueue->init();
1767
+            $panel = new Redux_Panel( $redux );
1768
+            $panel->init();
1769
+        }
1770
+    }
1771
+
1772
+    Redux::load();
1773 1773
 }
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
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
 			}
@@ -1317,7 +1315,7 @@  discard block
 block discarded – undo
1317 1315
 					$values = $$opt_name;
1318 1316
 				}
1319 1317
 
1320
-				if ( ! isset( $values[ $key ] ) ) {
1318
+				if ( ! isset( $values[$key] ) ) {
1321 1319
 					if ( null === $default ) {
1322 1320
 						$field = self::get_field( $opt_name, $key );
1323 1321
 
@@ -1326,8 +1324,8 @@  discard block
 block discarded – undo
1326 1324
 							$sections       = self::construct_sections( $opt_name );
1327 1325
 							$defaults       = $defaults_class->default_values( $opt_name, $sections );
1328 1326
 
1329
-							if ( isset( $defaults[ $key ] ) ) {
1330
-								$default = $defaults[ $key ];
1327
+							if ( isset( $defaults[$key] ) ) {
1328
+								$default = $defaults[$key];
1331 1329
 							}
1332 1330
 						}
1333 1331
 					}
@@ -1336,25 +1334,25 @@  discard block
 block discarded – undo
1336 1334
 				if ( ! empty( $subkeys ) && is_array( $subkeys ) ) {
1337 1335
 					$value = $default;
1338 1336
 
1339
-					if ( isset( $values[ $key ] ) ) {
1337
+					if ( isset( $values[$key] ) ) {
1340 1338
 						$count = count( $subkeys );
1341 1339
 
1342 1340
 						if ( 1 === $count ) {
1343
-							$value = $values[ $key ][ $subkeys[1] ] ?? $default;
1341
+							$value = $values[$key][$subkeys[1]] ?? $default;
1344 1342
 						} elseif ( 2 === $count ) {
1345
-							if ( isset( $values[ $key ][ $subkeys[1] ] ) ) {
1346
-								$value = $values[ $key ][ $subkeys[1] ][ $subkeys[2] ] ?? $default;
1343
+							if ( isset( $values[$key][$subkeys[1]] ) ) {
1344
+								$value = $values[$key][$subkeys[1]][$subkeys[2]] ?? $default;
1347 1345
 							}
1348 1346
 						} elseif ( 3 === $count ) {
1349
-							if ( isset( $values[ $key ][ $subkeys[1] ] ) ) {
1350
-								if ( isset( $values[ $key ][ $subkeys[1] ][ $subkeys[2] ] ) ) {
1351
-									$value = $values[ $key ][ $subkeys[1] ][ $subkeys[2] ][ $subkeys[3] ] ?? $default;
1347
+							if ( isset( $values[$key][$subkeys[1]] ) ) {
1348
+								if ( isset( $values[$key][$subkeys[1]][$subkeys[2]] ) ) {
1349
+									$value = $values[$key][$subkeys[1]][$subkeys[2]][$subkeys[3]] ?? $default;
1352 1350
 								}
1353 1351
 							}
1354 1352
 						}
1355 1353
 					}
1356 1354
 				} else {
1357
-					$value = $values[ $key ] ?? $default;
1355
+					$value = $values[$key] ?? $default;
1358 1356
 				}
1359 1357
 
1360 1358
 				return $value;
@@ -1403,7 +1401,7 @@  discard block
 block discarded – undo
1403 1401
 
1404 1402
 			if ( '' !== $opt_name ) {
1405 1403
 				$redux         = get_option( $opt_name );
1406
-				$redux[ $key ] = $option;
1404
+				$redux[$key] = $option;
1407 1405
 
1408 1406
 				return update_option( $opt_name, $redux );
1409 1407
 			} else {
@@ -1420,8 +1418,8 @@  discard block
 block discarded – undo
1420 1418
 		 * @return mixed
1421 1419
 		 */
1422 1420
 		public static function get_priority( string $opt_name, string $type ) {
1423
-			$priority                              = self::$priority[ $opt_name ][ $type ];
1424
-			self::$priority[ $opt_name ][ $type ] += 1;
1421
+			$priority                              = self::$priority[$opt_name][$type];
1422
+			self::$priority[$opt_name][$type] += 1;
1425 1423
 
1426 1424
 			return $priority;
1427 1425
 		}
@@ -1436,32 +1434,32 @@  discard block
 block discarded – undo
1436 1434
 				return;
1437 1435
 			}
1438 1436
 
1439
-			if ( ! isset( self::$sections[ $opt_name ] ) ) {
1440
-				self::$sections[ $opt_name ]             = array();
1441
-				self::$priority[ $opt_name ]['sections'] = 1;
1437
+			if ( ! isset( self::$sections[$opt_name] ) ) {
1438
+				self::$sections[$opt_name]             = array();
1439
+				self::$priority[$opt_name]['sections'] = 1;
1442 1440
 			}
1443 1441
 
1444
-			if ( ! isset( self::$args[ $opt_name ] ) ) {
1445
-				self::$args[ $opt_name ]             = array();
1446
-				self::$priority[ $opt_name ]['args'] = 1;
1442
+			if ( ! isset( self::$args[$opt_name] ) ) {
1443
+				self::$args[$opt_name]             = array();
1444
+				self::$priority[$opt_name]['args'] = 1;
1447 1445
 			}
1448 1446
 
1449
-			if ( ! isset( self::$fields[ $opt_name ] ) ) {
1450
-				self::$fields[ $opt_name ]             = array();
1451
-				self::$priority[ $opt_name ]['fields'] = 1;
1447
+			if ( ! isset( self::$fields[$opt_name] ) ) {
1448
+				self::$fields[$opt_name]             = array();
1449
+				self::$priority[$opt_name]['fields'] = 1;
1452 1450
 			}
1453 1451
 
1454
-			if ( ! isset( self::$help[ $opt_name ] ) ) {
1455
-				self::$help[ $opt_name ]             = array();
1456
-				self::$priority[ $opt_name ]['help'] = 1;
1452
+			if ( ! isset( self::$help[$opt_name] ) ) {
1453
+				self::$help[$opt_name]             = array();
1454
+				self::$priority[$opt_name]['help'] = 1;
1457 1455
 			}
1458 1456
 
1459
-			if ( ! isset( self::$errors[ $opt_name ] ) ) {
1460
-				self::$errors[ $opt_name ] = array();
1457
+			if ( ! isset( self::$errors[$opt_name] ) ) {
1458
+				self::$errors[$opt_name] = array();
1461 1459
 			}
1462 1460
 
1463
-			if ( ! isset( self::$init[ $opt_name ] ) ) {
1464
-				self::$init[ $opt_name ] = false;
1461
+			if ( ! isset( self::$init[$opt_name] ) ) {
1462
+				self::$init[$opt_name] = false;
1465 1463
 			}
1466 1464
 		}
1467 1465
 
@@ -1490,13 +1488,13 @@  discard block
 block discarded – undo
1490 1488
 			$instance = null;
1491 1489
 
1492 1490
 			if ( file_exists( $class_file ) ) {
1493
-				self::$uses_extensions[ $opt_name ] = self::$uses_extensions[ $opt_name ] ?? array();
1491
+				self::$uses_extensions[$opt_name] = self::$uses_extensions[$opt_name] ?? array();
1494 1492
 
1495
-				if ( ! in_array( $name, self::$uses_extensions[ $opt_name ], true ) ) {
1496
-					self::$uses_extensions[ $opt_name ][] = $name;
1493
+				if ( ! in_array( $name, self::$uses_extensions[$opt_name], true ) ) {
1494
+					self::$uses_extensions[$opt_name][] = $name;
1497 1495
 				}
1498 1496
 
1499
-				self::$extensions[ $name ] = self::$extensions[ $name ] ?? array();
1497
+				self::$extensions[$name] = self::$extensions[$name] ?? array();
1500 1498
 
1501 1499
 				$version = Redux_Helpers::get_template_version( $class_file );
1502 1500
 
@@ -1505,7 +1503,7 @@  discard block
 block discarded – undo
1505 1503
 						$version = $instance->version;
1506 1504
 					}
1507 1505
 				}
1508
-				self::$extensions[ $name ][ $version ] = self::$extensions[ $name ][ $version ] ?? $class_file;
1506
+				self::$extensions[$name][$version] = self::$extensions[$name][$version] ?? $class_file;
1509 1507
 
1510 1508
 				$new_name  = str_replace( '_', '-', $name );
1511 1509
 				$api_check = str_replace(
@@ -1596,10 +1594,10 @@  discard block
 block discarded – undo
1596 1594
 				}
1597 1595
 			}
1598 1596
 
1599
-			self::$extension_paths[ $opt_name ] = $path;
1597
+			self::$extension_paths[$opt_name] = $path;
1600 1598
 
1601 1599
 			if ( true === $force ) {
1602
-				if ( isset( self::$uses_extensions[ $opt_name ] ) && ! empty( self::$uses_extensions[ $opt_name ] ) ) {
1600
+				if ( isset( self::$uses_extensions[$opt_name] ) && ! empty( self::$uses_extensions[$opt_name] ) ) {
1603 1601
 					$redux = self::instance( $opt_name );
1604 1602
 
1605 1603
 					if ( isset( $redux ) ) {
@@ -1616,7 +1614,7 @@  discard block
 block discarded – undo
1616 1614
 			$redux = self::all_instances();
1617 1615
 
1618 1616
 			foreach ( $redux as $instance ) {
1619
-				if ( ! empty( self::$uses_extensions[ $instance['args']['opt_name'] ] ) ) {
1617
+				if ( ! empty( self::$uses_extensions[$instance['args']['opt_name']] ) ) {
1620 1618
 					continue;
1621 1619
 				}
1622 1620
 				if ( ! empty( $instance['extensions'] ) ) {
@@ -1632,7 +1630,7 @@  discard block
 block discarded – undo
1632 1630
 		 * @param object|null $instance ReduxFramework instance.
1633 1631
 		 */
1634 1632
 		public static function get_instance_extension( string $opt_name, $instance ) {
1635
-			if ( ! empty( self::$uses_extensions[ $opt_name ] ) || empty( $opt_name ) ) {
1633
+			if ( ! empty( self::$uses_extensions[$opt_name] ) || empty( $opt_name ) ) {
1636 1634
 				return;
1637 1635
 			}
1638 1636
 
@@ -1649,7 +1647,7 @@  discard block
 block discarded – undo
1649 1647
 					new Redux_Widget_Areas( $instance );
1650 1648
 				}
1651 1649
 
1652
-				if ( isset( self::$uses_extensions[ $opt_name ][ $name ] ) ) {
1650
+				if ( isset( self::$uses_extensions[$opt_name][$name] ) ) {
1653 1651
 					continue;
1654 1652
 				}
1655 1653
 
@@ -1688,22 +1686,22 @@  discard block
 block discarded – undo
1688 1686
 
1689 1687
 				if ( empty( $key ) ) {
1690 1688
 					return self::$extension_paths;
1691
-				} elseif ( isset( self::$extension_paths[ $key ] ) ) {
1692
-						return self::$extension_paths[ $key ];
1689
+				} elseif ( isset( self::$extension_paths[$key] ) ) {
1690
+						return self::$extension_paths[$key];
1693 1691
 				}
1694 1692
 			} else {
1695
-				if ( empty( self::$uses_extensions[ $opt_name ] ) ) {
1693
+				if ( empty( self::$uses_extensions[$opt_name] ) ) {
1696 1694
 					self::get_instance_extension( $opt_name, null );
1697 1695
 				}
1698 1696
 
1699
-				if ( empty( self::$uses_extensions[ $opt_name ] ) ) {
1697
+				if ( empty( self::$uses_extensions[$opt_name] ) ) {
1700 1698
 					return false;
1701 1699
 				}
1702 1700
 
1703 1701
 				$instance_extensions = array();
1704 1702
 
1705
-				foreach ( self::$uses_extensions[ $opt_name ] as $extension ) {
1706
-					$class_file = end( self::$extensions[ $extension ] );
1703
+				foreach ( self::$uses_extensions[$opt_name] as $extension ) {
1704
+					$class_file = end( self::$extensions[$extension] );
1707 1705
 					$directory  = explode( DIRECTORY_SEPARATOR, $class_file );
1708 1706
 					array_pop( $directory );
1709 1707
 					$directory       = trailingslashit( join( DIRECTORY_SEPARATOR, $directory ) );
@@ -1726,7 +1724,7 @@  discard block
 block discarded – undo
1726 1724
 							$the_data['field'] = $test_path . str_replace( '-', '', $extension ) . '.php';
1727 1725
 						}
1728 1726
 					}
1729
-					$instance_extensions[ $extension ] = $the_data;
1727
+					$instance_extensions[$extension] = $the_data;
1730 1728
 				}
1731 1729
 
1732 1730
 				return $instance_extensions;
Please login to merge, or discard this patch.
redux-core/inc/classes/class-redux-required.php 2 patches
Indentation   +256 added lines, -256 removed lines patch added patch discarded remove patch
@@ -11,286 +11,286 @@
 block discarded – undo
11 11
 
12 12
 if ( ! class_exists( 'Redux_Required', false ) ) {
13 13
 
14
-	/**
15
-	 * Class Redux_Required
16
-	 */
17
-	class Redux_Required extends Redux_Class {
14
+    /**
15
+     * Class Redux_Required
16
+     */
17
+    class Redux_Required extends Redux_Class {
18 18
 
19
-		/**
20
-		 * Array of fields to reload.
21
-		 *
22
-		 * @var array
23
-		 */
24
-		public $reload_fields = array();
19
+        /**
20
+         * Array of fields to reload.
21
+         *
22
+         * @var array
23
+         */
24
+        public $reload_fields = array();
25 25
 
26
-		/**
27
-		 * Redux_Required Constructor.
28
-		 *
29
-		 * @param object $parent ReduxFramework object.
30
-		 */
31
-		public function __construct( $parent = null ) {
32
-			parent::__construct( $parent );
33
-		}
26
+        /**
27
+         * Redux_Required Constructor.
28
+         *
29
+         * @param object $parent ReduxFramework object.
30
+         */
31
+        public function __construct( $parent = null ) {
32
+            parent::__construct( $parent );
33
+        }
34 34
 
35
-		/**
36
-		 * Checks dependencies between objects based on the $field['required'] array
37
-		 * If the array is set it needs to have exactly 3 entries.
38
-		 * The first entry describes which field should be monitored by the current field. e.g.: "content"
39
-		 * The second entry describes the comparison parameter. eg: "equals, not, is_larger, is_smaller, contains"
40
-		 * The third entry describes the value that we are comparing against.
41
-		 * Example: if the required array is set to array('content','equals','Hello World'); then the current
42
-		 * field will only be displayed if the field with id "content" has exactly the value "Hello World"
43
-		 *
44
-		 * @param array $field Field array.
45
-		 */
46
-		public function check_dependencies( array $field ) {
47
-			$core = $this->core();
35
+        /**
36
+         * Checks dependencies between objects based on the $field['required'] array
37
+         * If the array is set it needs to have exactly 3 entries.
38
+         * The first entry describes which field should be monitored by the current field. e.g.: "content"
39
+         * The second entry describes the comparison parameter. eg: "equals, not, is_larger, is_smaller, contains"
40
+         * The third entry describes the value that we are comparing against.
41
+         * Example: if the required array is set to array('content','equals','Hello World'); then the current
42
+         * field will only be displayed if the field with id "content" has exactly the value "Hello World"
43
+         *
44
+         * @param array $field Field array.
45
+         */
46
+        public function check_dependencies( array $field ) {
47
+            $core = $this->core();
48 48
 
49
-			if ( isset( $field['ajax_save'] ) && false === $field['ajax_save'] ) {
50
-				$core->required_class->reload_fields[] = $field['id'];
51
-			}
49
+            if ( isset( $field['ajax_save'] ) && false === $field['ajax_save'] ) {
50
+                $core->required_class->reload_fields[] = $field['id'];
51
+            }
52 52
 
53
-			if ( ! empty( $field['required'] ) ) {
54
-				if ( ! isset( Redux_Core::$required_child[ $field['id'] ] ) ) {
55
-					Redux_Core::$required_child[ $field['id'] ] = array();
56
-				}
53
+            if ( ! empty( $field['required'] ) ) {
54
+                if ( ! isset( Redux_Core::$required_child[ $field['id'] ] ) ) {
55
+                    Redux_Core::$required_child[ $field['id'] ] = array();
56
+                }
57 57
 
58
-				if ( ! isset( Redux_Core::$required[ $field['id'] ] ) ) {
59
-					Redux_Core::$required[ $field['id'] ] = array();
60
-				}
58
+                if ( ! isset( Redux_Core::$required[ $field['id'] ] ) ) {
59
+                    Redux_Core::$required[ $field['id'] ] = array();
60
+                }
61 61
 
62
-				if ( is_array( $field['required'][0] ) ) {
62
+                if ( is_array( $field['required'][0] ) ) {
63 63
 
64
-					foreach ( $field['required'] as $value ) {
65
-						if ( is_array( $value ) && 3 === count( $value ) ) {
66
-							$data               = array();
67
-							$data['parent']     = $value[0];
68
-							$data['operation']  = $value[1];
69
-							$data['checkValue'] = $value[2];
64
+                    foreach ( $field['required'] as $value ) {
65
+                        if ( is_array( $value ) && 3 === count( $value ) ) {
66
+                            $data               = array();
67
+                            $data['parent']     = $value[0];
68
+                            $data['operation']  = $value[1];
69
+                            $data['checkValue'] = $value[2];
70 70
 
71
-							Redux_Core::$required[ $data['parent'] ][ $field['id'] ][] = $data;
71
+                            Redux_Core::$required[ $data['parent'] ][ $field['id'] ][] = $data;
72 72
 
73
-							if ( ! in_array( $data['parent'], Redux_Core::$required_child[ $field['id'] ], true ) ) {
74
-								Redux_Core::$required_child[ $field['id'] ][] = $data;
75
-							}
73
+                            if ( ! in_array( $data['parent'], Redux_Core::$required_child[ $field['id'] ], true ) ) {
74
+                                Redux_Core::$required_child[ $field['id'] ][] = $data;
75
+                            }
76 76
 
77
-							$this->check_required_dependencies( $core, $field, $data );
78
-						}
79
-					}
80
-				} else {
81
-					$data               = array();
82
-					$data['parent']     = $field['required'][0];
83
-					$data['operation']  = $field['required'][1];
84
-					$data['checkValue'] = $field['required'][2];
77
+                            $this->check_required_dependencies( $core, $field, $data );
78
+                        }
79
+                    }
80
+                } else {
81
+                    $data               = array();
82
+                    $data['parent']     = $field['required'][0];
83
+                    $data['operation']  = $field['required'][1];
84
+                    $data['checkValue'] = $field['required'][2];
85 85
 
86
-					Redux_Core::$required[ $data['parent'] ][ $field['id'] ][] = $data;
86
+                    Redux_Core::$required[ $data['parent'] ][ $field['id'] ][] = $data;
87 87
 
88
-					if ( false === array_search( $data['parent'], array_column( Redux_Core::$required_child[ $field['id'] ], 'parent' ), true ) ) {
89
-						Redux_Core::$required_child[ $field['id'] ][] = $data;
90
-					}
88
+                    if ( false === array_search( $data['parent'], array_column( Redux_Core::$required_child[ $field['id'] ], 'parent' ), true ) ) {
89
+                        Redux_Core::$required_child[ $field['id'] ][] = $data;
90
+                    }
91 91
 
92
-					$this->check_required_dependencies( $core, $field, $data );
93
-				}
94
-			}
95
-		}
92
+                    $this->check_required_dependencies( $core, $field, $data );
93
+                }
94
+            }
95
+        }
96 96
 
97
-		/**
98
-		 * Check field for required deps.
99
-		 *
100
-		 * @param object $core  ReduxFramework core pointer.
101
-		 * @param array  $field Field array.
102
-		 * @param array  $data  Required data.
103
-		 */
104
-		private function check_required_dependencies( $core, array $field, array $data ) {
105
-			// The Required field must not be hidden. Otherwise, hide this one by default.
106
-			if ( ! in_array( $data['parent'], Redux_Core::$fields_hidden, true ) && ( ! isset( Redux_Core::$folds[ $field['id'] ] ) || 'hide' !== Redux_Core::$folds[ $field['id'] ] ) ) {
107
-				if ( isset( $core->options[ $data['parent'] ] ) ) {
108
-					$return = $this->compare_value_dependencies( $core->options[ $data['parent'] ], $data['checkValue'], $data['operation'] );
109
-				} elseif ( isset( $core->options_defaults[ $data['parent'] ] ) ) {
110
-					$return = $this->compare_value_dependencies( $core->options_defaults[ $data['parent'] ], $data['checkValue'], $data['operation'] );
111
-				}
112
-			}
97
+        /**
98
+         * Check field for required deps.
99
+         *
100
+         * @param object $core  ReduxFramework core pointer.
101
+         * @param array  $field Field array.
102
+         * @param array  $data  Required data.
103
+         */
104
+        private function check_required_dependencies( $core, array $field, array $data ) {
105
+            // The Required field must not be hidden. Otherwise, hide this one by default.
106
+            if ( ! in_array( $data['parent'], Redux_Core::$fields_hidden, true ) && ( ! isset( Redux_Core::$folds[ $field['id'] ] ) || 'hide' !== Redux_Core::$folds[ $field['id'] ] ) ) {
107
+                if ( isset( $core->options[ $data['parent'] ] ) ) {
108
+                    $return = $this->compare_value_dependencies( $core->options[ $data['parent'] ], $data['checkValue'], $data['operation'] );
109
+                } elseif ( isset( $core->options_defaults[ $data['parent'] ] ) ) {
110
+                    $return = $this->compare_value_dependencies( $core->options_defaults[ $data['parent'] ], $data['checkValue'], $data['operation'] );
111
+                }
112
+            }
113 113
 
114
-			if ( ( isset( $return ) && $return ) && ( ! isset( Redux_Core::$folds[ $field['id'] ] ) || 'hide' !== Redux_Core::$folds[ $field['id'] ] ) ) {
115
-				Redux_Core::$folds[ $field['id'] ] = 'show';
116
-			} else {
117
-				Redux_Core::$folds[ $field['id'] ] = 'hide';
114
+            if ( ( isset( $return ) && $return ) && ( ! isset( Redux_Core::$folds[ $field['id'] ] ) || 'hide' !== Redux_Core::$folds[ $field['id'] ] ) ) {
115
+                Redux_Core::$folds[ $field['id'] ] = 'show';
116
+            } else {
117
+                Redux_Core::$folds[ $field['id'] ] = 'hide';
118 118
 
119
-				if ( ! in_array( $field['id'], Redux_Core::$fields_hidden, true ) ) {
120
-					Redux_Core::$fields_hidden[] = $field['id'];
121
-				}
122
-			}
123
-		}
119
+                if ( ! in_array( $field['id'], Redux_Core::$fields_hidden, true ) ) {
120
+                    Redux_Core::$fields_hidden[] = $field['id'];
121
+                }
122
+            }
123
+        }
124 124
 
125
-		/**
126
-		 * Compare data for required field.
127
-		 *
128
-		 * @param mixed  $parent_value Parent value.
129
-		 * @param mixed  $check_value  Check value.
130
-		 * @param string $operation    Operation.
131
-		 *
132
-		 * @return bool
133
-		 */
134
-		public function compare_value_dependencies( $parent_value, $check_value, string $operation ): bool {
135
-			$return = false;
136
-			switch ( $operation ) {
137
-				case '=':
138
-				case 'equals':
139
-					$data['operation'] = '=';
125
+        /**
126
+         * Compare data for required field.
127
+         *
128
+         * @param mixed  $parent_value Parent value.
129
+         * @param mixed  $check_value  Check value.
130
+         * @param string $operation    Operation.
131
+         *
132
+         * @return bool
133
+         */
134
+        public function compare_value_dependencies( $parent_value, $check_value, string $operation ): bool {
135
+            $return = false;
136
+            switch ( $operation ) {
137
+                case '=':
138
+                case 'equals':
139
+                    $data['operation'] = '=';
140 140
 
141
-					if ( is_array( $parent_value ) ) {
142
-						foreach ( $parent_value as $val ) {
143
-							if ( is_array( $check_value ) ) {
144
-								foreach ( $check_value as $v ) {
145
-									if ( Redux_Helpers::make_bool_str( $val ) === Redux_Helpers::make_bool_str( $v ) ) {
146
-										$return = true;
147
-									}
148
-								}
149
-							} else {
150
-								if ( Redux_Helpers::make_bool_str( $val ) === Redux_Helpers::make_bool_str( $check_value ) ) {
151
-									$return = true;
152
-								}
153
-							}
154
-						}
155
-					} else {
156
-						if ( is_array( $check_value ) ) {
157
-							foreach ( $check_value as $v ) {
158
-								if ( Redux_Helpers::make_bool_str( $parent_value ) === Redux_Helpers::make_bool_str( $v ) ) {
159
-									$return = true;
160
-								}
161
-							}
162
-						} else {
163
-							if ( Redux_Helpers::make_bool_str( $parent_value ) === Redux_Helpers::make_bool_str( $check_value ) ) {
164
-								$return = true;
165
-							}
166
-						}
167
-					}
168
-					break;
141
+                    if ( is_array( $parent_value ) ) {
142
+                        foreach ( $parent_value as $val ) {
143
+                            if ( is_array( $check_value ) ) {
144
+                                foreach ( $check_value as $v ) {
145
+                                    if ( Redux_Helpers::make_bool_str( $val ) === Redux_Helpers::make_bool_str( $v ) ) {
146
+                                        $return = true;
147
+                                    }
148
+                                }
149
+                            } else {
150
+                                if ( Redux_Helpers::make_bool_str( $val ) === Redux_Helpers::make_bool_str( $check_value ) ) {
151
+                                    $return = true;
152
+                                }
153
+                            }
154
+                        }
155
+                    } else {
156
+                        if ( is_array( $check_value ) ) {
157
+                            foreach ( $check_value as $v ) {
158
+                                if ( Redux_Helpers::make_bool_str( $parent_value ) === Redux_Helpers::make_bool_str( $v ) ) {
159
+                                    $return = true;
160
+                                }
161
+                            }
162
+                        } else {
163
+                            if ( Redux_Helpers::make_bool_str( $parent_value ) === Redux_Helpers::make_bool_str( $check_value ) ) {
164
+                                $return = true;
165
+                            }
166
+                        }
167
+                    }
168
+                    break;
169 169
 
170
-				case '!=':
171
-				case 'not':
172
-					$data['operation'] = '!==';
173
-					if ( is_array( $parent_value ) ) {
174
-						foreach ( $parent_value as $val ) {
175
-							if ( is_array( $check_value ) ) {
176
-								foreach ( $check_value as $v ) {
177
-									if ( Redux_Helpers::make_bool_str( $val ) !== Redux_Helpers::make_bool_str( $v ) ) {
178
-										$return = true;
179
-									}
180
-								}
181
-							} else {
182
-								if ( Redux_Helpers::make_bool_str( $val ) !== Redux_Helpers::make_bool_str( $check_value ) ) {
183
-									$return = true;
184
-								}
185
-							}
186
-						}
187
-					} else {
188
-						if ( is_array( $check_value ) ) {
189
-							foreach ( $check_value as $v ) {
190
-								if ( Redux_Helpers::make_bool_str( $parent_value ) !== Redux_Helpers::make_bool_str( $v ) ) {
191
-									$return = true;
192
-								}
193
-							}
194
-						} else {
195
-							if ( Redux_Helpers::make_bool_str( $parent_value ) !== Redux_Helpers::make_bool_str( $check_value ) ) {
196
-								$return = true;
197
-							}
198
-						}
199
-					}
170
+                case '!=':
171
+                case 'not':
172
+                    $data['operation'] = '!==';
173
+                    if ( is_array( $parent_value ) ) {
174
+                        foreach ( $parent_value as $val ) {
175
+                            if ( is_array( $check_value ) ) {
176
+                                foreach ( $check_value as $v ) {
177
+                                    if ( Redux_Helpers::make_bool_str( $val ) !== Redux_Helpers::make_bool_str( $v ) ) {
178
+                                        $return = true;
179
+                                    }
180
+                                }
181
+                            } else {
182
+                                if ( Redux_Helpers::make_bool_str( $val ) !== Redux_Helpers::make_bool_str( $check_value ) ) {
183
+                                    $return = true;
184
+                                }
185
+                            }
186
+                        }
187
+                    } else {
188
+                        if ( is_array( $check_value ) ) {
189
+                            foreach ( $check_value as $v ) {
190
+                                if ( Redux_Helpers::make_bool_str( $parent_value ) !== Redux_Helpers::make_bool_str( $v ) ) {
191
+                                    $return = true;
192
+                                }
193
+                            }
194
+                        } else {
195
+                            if ( Redux_Helpers::make_bool_str( $parent_value ) !== Redux_Helpers::make_bool_str( $check_value ) ) {
196
+                                $return = true;
197
+                            }
198
+                        }
199
+                    }
200 200
 
201
-					break;
202
-				case '>':
203
-				case 'greater':
204
-				case 'is_larger':
205
-					$data['operation'] = '>';
206
-					if ( $parent_value > $check_value ) {
207
-						$return = true;
208
-					}
209
-					break;
210
-				case '>=':
211
-				case 'greater_equal':
212
-				case 'is_larger_equal':
213
-					$data['operation'] = '>=';
214
-					if ( $parent_value >= $check_value ) {
215
-						$return = true;
216
-					}
217
-					break;
218
-				case '<':
219
-				case 'less':
220
-				case 'is_smaller':
221
-					$data['operation'] = '<';
222
-					if ( $parent_value < $check_value ) {
223
-						$return = true;
224
-					}
225
-					break;
226
-				case '<=':
227
-				case 'less_equal':
228
-				case 'is_smaller_equal':
229
-					$data['operation'] = '<=';
230
-					if ( $parent_value <= $check_value ) {
231
-						$return = true;
232
-					}
233
-					break;
234
-				case 'contains':
235
-					if ( is_array( $parent_value ) ) {
236
-						$parent_value = implode( ',', $parent_value );
237
-					}
201
+                    break;
202
+                case '>':
203
+                case 'greater':
204
+                case 'is_larger':
205
+                    $data['operation'] = '>';
206
+                    if ( $parent_value > $check_value ) {
207
+                        $return = true;
208
+                    }
209
+                    break;
210
+                case '>=':
211
+                case 'greater_equal':
212
+                case 'is_larger_equal':
213
+                    $data['operation'] = '>=';
214
+                    if ( $parent_value >= $check_value ) {
215
+                        $return = true;
216
+                    }
217
+                    break;
218
+                case '<':
219
+                case 'less':
220
+                case 'is_smaller':
221
+                    $data['operation'] = '<';
222
+                    if ( $parent_value < $check_value ) {
223
+                        $return = true;
224
+                    }
225
+                    break;
226
+                case '<=':
227
+                case 'less_equal':
228
+                case 'is_smaller_equal':
229
+                    $data['operation'] = '<=';
230
+                    if ( $parent_value <= $check_value ) {
231
+                        $return = true;
232
+                    }
233
+                    break;
234
+                case 'contains':
235
+                    if ( is_array( $parent_value ) ) {
236
+                        $parent_value = implode( ',', $parent_value );
237
+                    }
238 238
 
239
-					if ( is_array( $check_value ) ) {
240
-						foreach ( $check_value as $opt ) {
241
-							if ( strpos( $parent_value, (string) $opt ) !== false ) {
242
-								$return = true;
243
-							}
244
-						}
245
-					} elseif ( strpos( $parent_value, (string) $check_value ) !== false ) {
246
-						$return = true;
247
-					}
239
+                    if ( is_array( $check_value ) ) {
240
+                        foreach ( $check_value as $opt ) {
241
+                            if ( strpos( $parent_value, (string) $opt ) !== false ) {
242
+                                $return = true;
243
+                            }
244
+                        }
245
+                    } elseif ( strpos( $parent_value, (string) $check_value ) !== false ) {
246
+                        $return = true;
247
+                    }
248 248
 
249
-					break;
250
-				case 'doesnt_contain':
251
-				case 'not_contain':
252
-					if ( is_array( $parent_value ) ) {
253
-						$parent_value = implode( ',', $parent_value );
254
-					}
249
+                    break;
250
+                case 'doesnt_contain':
251
+                case 'not_contain':
252
+                    if ( is_array( $parent_value ) ) {
253
+                        $parent_value = implode( ',', $parent_value );
254
+                    }
255 255
 
256
-					if ( is_array( $check_value ) ) {
257
-						foreach ( $check_value as $opt ) {
258
-							if ( strpos( $parent_value, (string) $opt ) === false ) {
259
-								$return = true;
260
-							}
261
-						}
262
-					} elseif ( strpos( $parent_value, (string) $check_value ) === false ) {
263
-						$return = true;
264
-					}
256
+                    if ( is_array( $check_value ) ) {
257
+                        foreach ( $check_value as $opt ) {
258
+                            if ( strpos( $parent_value, (string) $opt ) === false ) {
259
+                                $return = true;
260
+                            }
261
+                        }
262
+                    } elseif ( strpos( $parent_value, (string) $check_value ) === false ) {
263
+                        $return = true;
264
+                    }
265 265
 
266
-					break;
267
-				case 'is_empty_or':
268
-					if ( empty( $parent_value ) || $check_value === $parent_value ) {
269
-						$return = true;
270
-					}
271
-					break;
272
-				case 'not_empty_and':
273
-					if ( ! empty( $parent_value ) && $check_value !== $parent_value ) {
274
-						$return = true;
275
-					}
276
-					break;
277
-				case 'is_empty':
278
-				case 'empty':
279
-				case '!isset':
280
-					if ( empty( $parent_value ) ) {
281
-						$return = true;
282
-					}
283
-					break;
284
-				case 'not_empty':
285
-				case '!empty':
286
-				case 'isset':
287
-					if ( ! empty( $parent_value ) && '' !== $parent_value ) {
288
-						$return = true;
289
-					}
290
-					break;
291
-			}
266
+                    break;
267
+                case 'is_empty_or':
268
+                    if ( empty( $parent_value ) || $check_value === $parent_value ) {
269
+                        $return = true;
270
+                    }
271
+                    break;
272
+                case 'not_empty_and':
273
+                    if ( ! empty( $parent_value ) && $check_value !== $parent_value ) {
274
+                        $return = true;
275
+                    }
276
+                    break;
277
+                case 'is_empty':
278
+                case 'empty':
279
+                case '!isset':
280
+                    if ( empty( $parent_value ) ) {
281
+                        $return = true;
282
+                    }
283
+                    break;
284
+                case 'not_empty':
285
+                case '!empty':
286
+                case 'isset':
287
+                    if ( ! empty( $parent_value ) && '' !== $parent_value ) {
288
+                        $return = true;
289
+                    }
290
+                    break;
291
+            }
292 292
 
293
-			return $return;
294
-		}
295
-	}
293
+            return $return;
294
+        }
295
+    }
296 296
 }
Please login to merge, or discard this patch.
Spacing   +22 added lines, -22 removed lines patch added patch discarded remove patch
@@ -51,12 +51,12 @@  discard block
 block discarded – undo
51 51
 			}
52 52
 
53 53
 			if ( ! empty( $field['required'] ) ) {
54
-				if ( ! isset( Redux_Core::$required_child[ $field['id'] ] ) ) {
55
-					Redux_Core::$required_child[ $field['id'] ] = array();
54
+				if ( ! isset( Redux_Core::$required_child[$field['id']] ) ) {
55
+					Redux_Core::$required_child[$field['id']] = array();
56 56
 				}
57 57
 
58
-				if ( ! isset( Redux_Core::$required[ $field['id'] ] ) ) {
59
-					Redux_Core::$required[ $field['id'] ] = array();
58
+				if ( ! isset( Redux_Core::$required[$field['id']] ) ) {
59
+					Redux_Core::$required[$field['id']] = array();
60 60
 				}
61 61
 
62 62
 				if ( is_array( $field['required'][0] ) ) {
@@ -68,10 +68,10 @@  discard block
 block discarded – undo
68 68
 							$data['operation']  = $value[1];
69 69
 							$data['checkValue'] = $value[2];
70 70
 
71
-							Redux_Core::$required[ $data['parent'] ][ $field['id'] ][] = $data;
71
+							Redux_Core::$required[$data['parent']][$field['id']][] = $data;
72 72
 
73
-							if ( ! in_array( $data['parent'], Redux_Core::$required_child[ $field['id'] ], true ) ) {
74
-								Redux_Core::$required_child[ $field['id'] ][] = $data;
73
+							if ( ! in_array( $data['parent'], Redux_Core::$required_child[$field['id']], true ) ) {
74
+								Redux_Core::$required_child[$field['id']][] = $data;
75 75
 							}
76 76
 
77 77
 							$this->check_required_dependencies( $core, $field, $data );
@@ -83,10 +83,10 @@  discard block
 block discarded – undo
83 83
 					$data['operation']  = $field['required'][1];
84 84
 					$data['checkValue'] = $field['required'][2];
85 85
 
86
-					Redux_Core::$required[ $data['parent'] ][ $field['id'] ][] = $data;
86
+					Redux_Core::$required[$data['parent']][$field['id']][] = $data;
87 87
 
88
-					if ( false === array_search( $data['parent'], array_column( Redux_Core::$required_child[ $field['id'] ], 'parent' ), true ) ) {
89
-						Redux_Core::$required_child[ $field['id'] ][] = $data;
88
+					if ( false === array_search( $data['parent'], array_column( Redux_Core::$required_child[$field['id']], 'parent' ), true ) ) {
89
+						Redux_Core::$required_child[$field['id']][] = $data;
90 90
 					}
91 91
 
92 92
 					$this->check_required_dependencies( $core, $field, $data );
@@ -103,18 +103,18 @@  discard block
 block discarded – undo
103 103
 		 */
104 104
 		private function check_required_dependencies( $core, array $field, array $data ) {
105 105
 			// The Required field must not be hidden. Otherwise, hide this one by default.
106
-			if ( ! in_array( $data['parent'], Redux_Core::$fields_hidden, true ) && ( ! isset( Redux_Core::$folds[ $field['id'] ] ) || 'hide' !== Redux_Core::$folds[ $field['id'] ] ) ) {
107
-				if ( isset( $core->options[ $data['parent'] ] ) ) {
108
-					$return = $this->compare_value_dependencies( $core->options[ $data['parent'] ], $data['checkValue'], $data['operation'] );
109
-				} elseif ( isset( $core->options_defaults[ $data['parent'] ] ) ) {
110
-					$return = $this->compare_value_dependencies( $core->options_defaults[ $data['parent'] ], $data['checkValue'], $data['operation'] );
106
+			if ( ! in_array( $data['parent'], Redux_Core::$fields_hidden, true ) && ( ! isset( Redux_Core::$folds[$field['id']] ) || 'hide' !== Redux_Core::$folds[$field['id']] ) ) {
107
+				if ( isset( $core->options[$data['parent']] ) ) {
108
+					$return = $this->compare_value_dependencies( $core->options[$data['parent']], $data['checkValue'], $data['operation'] );
109
+				} elseif ( isset( $core->options_defaults[$data['parent']] ) ) {
110
+					$return = $this->compare_value_dependencies( $core->options_defaults[$data['parent']], $data['checkValue'], $data['operation'] );
111 111
 				}
112 112
 			}
113 113
 
114
-			if ( ( isset( $return ) && $return ) && ( ! isset( Redux_Core::$folds[ $field['id'] ] ) || 'hide' !== Redux_Core::$folds[ $field['id'] ] ) ) {
115
-				Redux_Core::$folds[ $field['id'] ] = 'show';
114
+			if ( ( isset( $return ) && $return ) && ( ! isset( Redux_Core::$folds[$field['id']] ) || 'hide' !== Redux_Core::$folds[$field['id']] ) ) {
115
+				Redux_Core::$folds[$field['id']] = 'show';
116 116
 			} else {
117
-				Redux_Core::$folds[ $field['id'] ] = 'hide';
117
+				Redux_Core::$folds[$field['id']] = 'hide';
118 118
 
119 119
 				if ( ! in_array( $field['id'], Redux_Core::$fields_hidden, true ) ) {
120 120
 					Redux_Core::$fields_hidden[] = $field['id'];
@@ -238,11 +238,11 @@  discard block
 block discarded – undo
238 238
 
239 239
 					if ( is_array( $check_value ) ) {
240 240
 						foreach ( $check_value as $opt ) {
241
-							if ( strpos( $parent_value, (string) $opt ) !== false ) {
241
+							if ( strpos( $parent_value, ( string ) $opt ) !== false ) {
242 242
 								$return = true;
243 243
 							}
244 244
 						}
245
-					} elseif ( strpos( $parent_value, (string) $check_value ) !== false ) {
245
+					} elseif ( strpos( $parent_value, ( string ) $check_value ) !== false ) {
246 246
 						$return = true;
247 247
 					}
248 248
 
@@ -255,11 +255,11 @@  discard block
 block discarded – undo
255 255
 
256 256
 					if ( is_array( $check_value ) ) {
257 257
 						foreach ( $check_value as $opt ) {
258
-							if ( strpos( $parent_value, (string) $opt ) === false ) {
258
+							if ( strpos( $parent_value, ( string ) $opt ) === false ) {
259 259
 								$return = true;
260 260
 							}
261 261
 						}
262
-					} elseif ( strpos( $parent_value, (string) $check_value ) === false ) {
262
+					} elseif ( strpos( $parent_value, ( string ) $check_value ) === false ) {
263 263
 						$return = true;
264 264
 					}
265 265
 
Please login to merge, or discard this patch.
redux-core/inc/classes/class-redux-enqueue.php 2 patches
Indentation   +730 added lines, -730 removed lines patch added patch discarded remove patch
@@ -12,737 +12,737 @@
 block discarded – undo
12 12
 
13 13
 if ( ! class_exists( 'Redux_Enqueue', false ) ) {
14 14
 
15
-	/**
16
-	 * Class Redux_Enqueue
17
-	 */
18
-	class Redux_Enqueue extends Redux_Class {
19
-
20
-		/**
21
-		 * Data to localize.
22
-		 *
23
-		 * @var array
24
-		 */
25
-		public array $localize_data = array();
26
-
27
-		/**
28
-		 * Min string for .min files.
29
-		 *
30
-		 * @var string
31
-		 */
32
-		private string $min = '';
33
-
34
-		/**
35
-		 * Timestamp for file versions.
36
-		 *
37
-		 * @var string
38
-		 */
39
-		private string $timestamp = '';
40
-
41
-		/**
42
-		 * Localize data required for the repeater extension.
43
-		 *
44
-		 * @var array
45
-		 */
46
-		private array $repeater_data = array();
47
-
48
-		/**
49
-		 * Redux_Enqueue constructor.
50
-		 *
51
-		 * @param     object $redux ReduxFramework pointer.
52
-		 */
53
-		public function __construct( $redux ) {
54
-			parent::__construct( $redux );
55
-
56
-			// Enqueue the admin page CSS and JS.
57
-			if ( isset( $_GET['page'] ) && $_GET['page'] === $redux->args['page_slug'] ) { // phpcs:ignore WordPress.Security.NonceVerification
58
-				add_action( 'admin_enqueue_scripts', array( $this, 'init' ), 1 );
59
-			}
60
-
61
-			add_action( 'wp_enqueue_scripts', array( $this, 'frontend_init' ), 10 );
62
-
63
-			// phpcs:ignore WordPress.NamingConventions.ValidHookName
64
-			do_action( "redux/{$redux->args['opt_name']}/enqueue/construct", $this );
65
-
66
-			// phpcs:ignore WordPress.NamingConventions.ValidHookName
67
-			do_action( 'redux/enqueue/construct', $this );
68
-
69
-			// phpcs:ignore WordPress.NamingConventions.ValidHookName
70
-			do_action( 'redux/search/' . $redux->args['opt_name'] . '/construct' );
71
-
72
-			//if ( isset( $_GET['page'] ) && sanitize_text_field( wp_unslash( $_GET['page'] === $this->parent->args['page_slug'] ) ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Recommended
73
-			//	add_action( 'admin_enqueue_scripts', array( $this, 'enqueue' ), 0 );
74
-			//}
75
-
76
-			//add_action( "redux/metaboxes/{$this->parent->args[ 'opt_name' ]}/enqueue", array( $this, 'enqueue' ), 10 );
77
-		}
78
-
79
-		/**
80
-		 * Scripts to enqueue on the frontend
81
-		 */
82
-		public function frontend_init() {
83
-			$core = $this->core();
84
-
85
-			if ( $core->args['elusive_frontend'] ) {
86
-				Redux_Functions_Ex::enqueue_elusive_font();
87
-			}
88
-
89
-			if ( $core->args['fontawesome_frontend'] ) {
90
-				Redux_Functions_Ex::enqueue_font_awesome();
91
-			}
92
-		}
93
-
94
-		/**
95
-		 * Class init functions.
96
-		 */
97
-		public function init() {
98
-			$core = $this->core();
99
-
100
-			Redux_Functions::$parent = $core;
101
-
102
-			$this->min = Redux_Functions::is_min();
103
-
104
-			$this->timestamp = Redux_Core::$version;
105
-			if ( $core->args['dev_mode'] ) {
106
-				$this->timestamp .= '.' . time();
107
-			}
108
-
109
-			$this->register_styles( $core );
110
-			$this->register_scripts();
111
-
112
-			add_thickbox();
113
-
114
-			$this->enqueue_fields( $core );
115
-
116
-			add_filter( "redux/{$core->args['opt_name']}/localize", array( 'Redux_Helpers', 'localize' ) );
117
-
118
-			$this->set_localized_data( $core );
119
-
120
-			/**
121
-			 * Action 'redux/page/{opt_name}/enqueue'
122
-			 */
123
-			// phpcs:ignore WordPress.NamingConventions.ValidHookName
124
-			do_action( "redux/page/{$core->args['opt_name']}/enqueue" );
125
-		}
126
-
127
-		/**
128
-		 * Register all core framework styles.
129
-		 *
130
-		 * @param ReduxFramework $core ReduxFramework object.
131
-		 */
132
-		private function register_styles( ReduxFramework $core ) {
133
-
134
-			/**
135
-			 * Redux Admin CSS
136
-			 */
137
-			if ( 'wordpress' === $core->args['admin_theme'] || 'wp' === $core->args['admin_theme'] ) { // phpcs:ignore WordPress.WP.CapitalPDangit
138
-				$color_scheme = get_user_option( 'admin_color' );
139
-			} elseif ( 'classic' === $core->args['admin_theme'] || '' === $core->args['admin_theme'] ) {
140
-				$color_scheme = 'classic';
141
-			} else {
142
-				$color_scheme = $core->args['admin_theme'];
143
-			}
144
-
145
-			if ( ! file_exists( Redux_Core::$dir . "assets/css/colors/$color_scheme/colors$this->min.css" ) ) {
146
-				$color_scheme = 'fresh';
147
-			}
148
-
149
-			$css = Redux_Core::$url . "assets/css/colors/$color_scheme/colors$this->min.css";
150
-
151
-			// phpcs:ignore WordPress.NamingConventions.ValidHookName
152
-			$css = apply_filters( 'redux/enqueue/' . $core->args['opt_name'] . '/args/admin_theme/css_url', $css );
153
-
154
-			wp_register_style(
155
-				'redux-admin-theme',
156
-				$css,
157
-				array(),
158
-				$this->timestamp
159
-			);
160
-
161
-			wp_enqueue_style(
162
-				'redux-admin-css',
163
-				Redux_Core::$url . "assets/css/redux-admin$this->min.css",
164
-				array( 'redux-admin-theme' ),
165
-				$this->timestamp
166
-			);
167
-
168
-			/**
169
-			 * Redux Fields CSS
170
-			 */
171
-			if ( ! $core->args['dev_mode'] ) {
172
-				wp_enqueue_style(
173
-					'redux-fields',
174
-					Redux_Core::$url . 'assets/css/redux-fields.min.css',
175
-					array(),
176
-					$this->timestamp
177
-				);
178
-			}
179
-
180
-			/**
181
-			 * Select2 CSS
182
-			 */
183
-			wp_enqueue_style(
184
-				'select2-css',
185
-				Redux_Core::$url . 'assets/css/vendor/select2.min.css',
186
-				array(),
187
-				'4.1.0'
188
-			);
189
-
190
-			/**
191
-			 * Spectrum CSS
192
-			 */
193
-			wp_register_style(
194
-				'redux-spectrum-css',
195
-				Redux_Core::$url . "assets/css/vendor/spectrum$this->min.css",
196
-				array(),
197
-				'1.3.3'
198
-			);
199
-
200
-			/**
201
-			 * Elusive Icon CSS
202
-			 */
203
-			Redux_Functions_Ex::enqueue_elusive_font();
204
-
205
-			/**
206
-			 * Font Awesome for Social Profiles and Icon Select
207
-			 */
208
-			Redux_Functions_Ex::enqueue_font_awesome();
209
-
210
-			/**
211
-			 * QTip CSS
212
-			 */
213
-			wp_enqueue_style(
214
-				'qtip',
215
-				Redux_Core::$url . "assets/css/vendor/qtip$this->min.css",
216
-				array(),
217
-				'3.0.3'
218
-			);
219
-
220
-			/**
221
-			 * JQuery UI CSS
222
-			 */
223
-			wp_enqueue_style(
224
-				'jquery-ui',
225
-				// phpcs:ignore WordPress.NamingConventions.ValidHookName
226
-				apply_filters(
227
-				// phpcs:ignore WordPress.NamingConventions.ValidHookName
228
-					"redux/page/{$core->args['opt_name']}/enqueue/jquery-ui-css",
229
-					Redux_Core::$url . 'assets/css/vendor/jquery-ui-1.10.0.custom.css'
230
-				),
231
-				array(),
232
-				$this->timestamp
233
-			);
234
-
235
-			/**
236
-			 * Iris CSS
237
-			 */
238
-			wp_enqueue_style( 'wp-color-picker' );
239
-
240
-			if ( $core->args['dev_mode'] ) {
241
-
242
-				/**
243
-				 * Media CSS
244
-				 */
245
-				wp_enqueue_style(
246
-					'redux-field-media',
247
-					Redux_Core::$url . 'assets/css/media.css',
248
-					array(),
249
-					$this->timestamp
250
-				);
251
-			}
252
-
253
-			/**
254
-			 * RTL CSS
255
-			 */
256
-			if ( is_rtl() ) {
257
-				wp_enqueue_style(
258
-					'redux-rtl',
259
-					Redux_Core::$url . 'assets/css/rtl.css',
260
-					array(),
261
-					$this->timestamp
262
-				);
263
-			}
264
-		}
265
-
266
-		/**
267
-		 * Register all core framework scripts.
268
-		 */
269
-		private function register_scripts() {
270
-			// *****************************************************************
271
-			// JQuery / JQuery UI JS
272
-			// *****************************************************************
273
-			wp_enqueue_script( 'jquery' );
274
-			wp_enqueue_script( 'jquery-ui-core' );
275
-			wp_enqueue_script( 'jquery-ui-dialog' );
276
-
277
-			/**
278
-			 * Select2 Sortable JS
279
-			 */
280
-			wp_register_script(
281
-				'redux-select2-sortable',
282
-				Redux_Core::$url . 'assets/js/vendor/select2-sortable/redux.select2.sortable' . $this->min . '.js',
283
-				array( 'jquery', 'jquery-ui-sortable' ),
284
-				$this->timestamp,
285
-				true
286
-			);
287
-
288
-			/**
289
-			 * Select2
290
-			 */
291
-			wp_enqueue_script(
292
-				'select2-js',
293
-				Redux_Core::$url . 'assets/js/vendor/select2/select2' . $this->min . '.js`',
294
-				array( 'jquery', 'redux-select2-sortable' ),
295
-				'4.1.0',
296
-				true
297
-			);
298
-
299
-			/**
300
-			 * QTip JS
301
-			 */
302
-			wp_enqueue_script(
303
-				'qtip',
304
-				Redux_Core::$url . 'assets/js/vendor/qtip/qtip' . $this->min . '.js',
305
-				array( 'jquery' ),
306
-				'3.0.3',
307
-				true
308
-			);
309
-
310
-			/**
311
-			 * Iris alpha color picker
312
-			 */
313
-			if ( ! wp_script_is( 'redux-wp-color-picker-alpha' ) ) {
314
-				wp_enqueue_style( 'wp-color-picker' );
315
-
316
-				wp_register_script(
317
-					'redux-wp-color-picker-alpha',
318
-					Redux_Core::$url . 'assets/js/vendor/wp-color-picker-alpha/wp-color-picker-alpha' . $this->min . '.js',
319
-					array( 'jquery', 'wp-color-picker' ),
320
-					'3.0.0',
321
-					true
322
-				);
323
-			}
324
-
325
-			/**
326
-			 * Block UI (used by Custom Fonts and Color Schemes).
327
-			 */
328
-			wp_register_script(
329
-				'redux-block-ui',
330
-				Redux_Core::$url . 'assets/js/vendor/block-ui/jquery.blockUI' . $this->min . '.js',
331
-				array( 'jquery' ),
332
-				'2.70.0',
333
-				true
334
-			);
335
-
336
-			/**
337
-			 * Spectrum JS
338
-			 */
339
-			wp_register_script(
340
-				'redux-spectrum-js',
341
-				Redux_Core::$url . 'assets/js/vendor/spectrum/redux-spectrum' . $this->min . '.js',
342
-				array( 'jquery' ),
343
-				'1.3.3',
344
-				true
345
-			);
346
-
347
-			/**
348
-			 * Vendor JS
349
-			 */
350
-			wp_register_script(
351
-				'redux-vendor',
352
-				Redux_Core::$url . 'assets/js/redux-vendors' . $this->min . '.js',
353
-				array( 'jquery' ),
354
-				$this->timestamp,
355
-				true
356
-			);
357
-
358
-			/**
359
-			 * Redux JS
360
-			 */
361
-			wp_register_script(
362
-				'redux-js',
363
-				Redux_Core::$url . 'assets/js/redux' . $this->min . '.js',
364
-				array( 'jquery', 'redux-vendor' ),
365
-				$this->timestamp,
366
-				true
367
-			);
368
-		}
369
-
370
-		/**
371
-		 * Enqueue fields that are in use.
372
-		 *
373
-		 * @param ReduxFramework $core  ReduxFramework object.
374
-		 * @param array          $field Field array.
375
-		 */
376
-		public function enqueue_field( ReduxFramework $core, array $field ) {
377
-			if ( isset( $field['type'] ) && 'callback' !== $field['type'] ) {
378
-				$field_type = str_replace( '_', '-', $field['type'] );
379
-				$core_path  = Redux_Core::$dir . "inc/fields/{$field['type']}/class-redux-$field_type.php";
380
-
381
-				// Shim for v3 extension class names.
382
-				if ( ! file_exists( $core_path ) ) {
383
-					$core_path = Redux_Core::$dir . "inc/fields/{$field['type']}/field_{$field['type']}.php";
384
-				}
385
-
386
-				$filter_path = $core_path;
387
-
388
-				/**
389
-				 * Field class file
390
-				 * filter 'redux/{opt_name}/field/class/{field.type}'
391
-				 *
392
-				 * @param     string    $filter_path Field class file path
393
-				 * @param     array     $field       Field config data
394
-				 */
395
-				// phpcs:ignore WordPress.NamingConventions.ValidHookName
396
-				$class_file = apply_filters(
397
-				// phpcs:ignore WordPress.NamingConventions.ValidHookName
398
-					"redux/{$core->args['opt_name']}/field/class/{$field['type']}",
399
-					$filter_path,
400
-					$field
401
-				);
402
-
403
-				$field_classes = array( 'Redux_' . $field['type'], 'ReduxFramework_' . $field['type'] );
404
-
405
-				if ( $class_file ) {
406
-					$field_class = Redux_Functions::class_exists_ex( $field_classes );
407
-					if ( false === $field_class ) {
408
-						if ( file_exists( $class_file ) ) {
409
-							require_once $class_file;
410
-
411
-							$field_class = Redux_Functions::class_exists_ex( $field_classes );
412
-						} else {
413
-							return;
414
-						}
415
-					}
416
-
417
-					if ( false !== $field_class && ( ( method_exists( $field_class, 'enqueue' ) ) || method_exists( $field_class, 'localize' ) ) ) {
418
-						if ( ! isset( $core->options[ $field['id'] ] ) ) {
419
-							$core->options[ $field['id'] ] = '';
420
-						}
421
-
422
-						$the_field = new $field_class( $field, $core->options[ $field['id'] ], $core );
423
-
424
-						// Move dev_mode check to a new if/then block.
425
-						if ( ! wp_script_is( 'redux-field-' . $field_type ) && ( class_exists( $field_class ) && method_exists( $field_class, 'enqueue' ) ) ) {
426
-							$the_field->enqueue();
427
-						}
428
-
429
-						if ( class_exists( $field_class ) && method_exists( $field_class, 'always_enqueue' ) ) {
430
-							$the_field->always_enqueue();
431
-						}
432
-
433
-						if ( method_exists( $field_class, 'localize' ) ) {
434
-							$the_field->localize( $field );
435
-
436
-							if ( ! isset( $this->localize_data[ $field['type'] ] ) ) {
437
-								$this->localize_data[ $field['type'] ] = array();
438
-							}
439
-
440
-							$localize_data = $the_field->localize( $field );
441
-
442
-							$shims = array( 'repeater' );
443
-
444
-							// phpcs:ignore WordPress.NamingConventions.ValidHookName
445
-							$shims = apply_filters( 'redux/' . $core->args['opt_name'] . '/localize/shims', $shims );
446
-
447
-							if ( is_array( $shims ) && in_array( $field['type'], $shims, true ) ) {
448
-								$this->repeater_data[ $field['type'] ][ $field['id'] ] = $localize_data;
449
-							}
450
-
451
-							$this->localize_data[ $field['type'] ][ $field['id'] ] = $localize_data;
452
-						}
453
-
454
-						unset( $the_field );
455
-					}
456
-				}
457
-			}
458
-		}
459
-
460
-		/**
461
-		 * Enqueue field files.
462
-		 *
463
-		 * @param ReduxFramework $core ReduxFramework object.
464
-		 */
465
-		private function enqueue_fields( ReduxFramework $core ) {
466
-			foreach ( $core->sections as $section ) {
467
-				if ( isset( $section['fields'] ) ) {
468
-					foreach ( $section['fields'] as $field ) {
469
-						$this->enqueue_field( $core, $field );
470
-					}
471
-				}
472
-			}
473
-		}
474
-
475
-		/**
476
-		 * Build a localized array from field functions, if any.
477
-		 *
478
-		 * @param ReduxFramework $core ReduxFramework object.
479
-		 * @param string         $type Field type.
480
-		 */
481
-		private function build_local_array( ReduxFramework $core, string $type ) {
482
-			if ( isset( $core->transients['last_save_mode'] ) && ! empty( $core->transients['notices'][ $type ] ) ) {
483
-				$the_total = 0;
484
-				$messages  = array();
485
-
486
-				foreach ( $core->transients['notices'][ $type ] as $msg ) {
487
-					if ( is_array( $msg ) && ! empty( $msg ) ) {
488
-						$messages[ $msg['section_id'] ][ $type ][] = $msg;
489
-
490
-						if ( ! isset( $messages[ $msg['section_id'] ]['total'] ) ) {
491
-							$messages[ $msg['section_id'] ]['total'] = 0;
492
-						}
493
-
494
-						++$messages[ $msg['section_id'] ]['total'];
495
-						++$the_total;
496
-					}
497
-				}
498
-
499
-				$this->localize_data[ $type ] = array(
500
-					'total' => $the_total,
501
-					"$type" => $messages,
502
-				);
503
-
504
-				unset( $core->transients['notices'][ $type ] );
505
-			}
506
-		}
507
-
508
-		/**
509
-		 * Compile panel errors and wearings for a localized array.
510
-		 */
511
-		public function get_warnings_and_errors_array() {
512
-			$core = $this->core();
513
-
514
-			$this->build_local_array( $core, 'errors' );
515
-			$this->build_local_array( $core, 'warnings' );
516
-			$this->build_local_array( $core, 'sanitize' );
517
-
518
-			if ( empty( $core->transients['notices'] ) ) {
519
-				if ( isset( $core->transients['notices'] ) ) {
520
-					unset( $core->transients['notices'] );
521
-				}
522
-			}
523
-		}
524
-
525
-		/**
526
-		 * Commit localized data to global array.
527
-		 *
528
-		 * @param ReduxFramework $core ReduxFramework object.
529
-		 */
530
-		private function set_localized_data( ReduxFramework $core ) {
531
-			if ( ! empty( $core->args['last_tab'] ) ) {
532
-				$this->localize_data['last_tab'] = $core->args['last_tab'];
533
-			}
534
-
535
-			$this->localize_data['search'] = esc_html__( 'Search for field(s)', 'redux-framework' );
536
-
537
-			$this->localize_data['font_weights'] = $this->args['font_weights'];
538
-
539
-			$this->localize_data['required'] = Redux_Core::$required;
540
-			$this->repeater_data['fonts']    = Redux_Core::$fonts;
541
-
542
-			if ( ! isset( $this->repeater_data['opt_names'] ) ) {
543
-				$this->repeater_data['opt_names'] = array();
544
-			}
545
-
546
-			$this->repeater_data['opt_names'][]    = $core->args['opt_name'];
547
-			$this->repeater_data['folds']          = array();
548
-			$this->localize_data['required_child'] = Redux_Core::$required_child;
549
-			$this->localize_data['fields']         = $core->fields;
550
-
551
-			if ( isset( Redux_Core::$font_groups['google'] ) ) {
552
-				$this->repeater_data['googlefonts'] = Redux_Core::$font_groups['google'];
553
-			}
554
-
555
-			if ( isset( Redux_Core::$font_groups['std'] ) ) {
556
-				$this->repeater_data['stdfonts'] = Redux_Core::$font_groups['std'];
557
-			}
558
-
559
-			if ( isset( Redux_Core::$font_groups['customfonts'] ) ) {
560
-				$this->repeater_data['customfonts'] = Redux_Core::$font_groups['customfonts'];
561
-			}
562
-
563
-			if ( isset( Redux_Core::$font_groups['typekitfonts'] ) ) {
564
-				$this->repeater_data['typekitfonts'] = Redux_Core::$font_groups['typekitfonts'];
565
-			}
566
-
567
-			$this->localize_data['folds'] = Redux_Core::$folds;
568
-
569
-			// Make sure the children are all hidden properly.
570
-			foreach ( $core->fields as $key => $value ) {
571
-				if ( in_array( $key, Redux_Core::$fields_hidden, true ) ) {
572
-					foreach ( $value as $k => $v ) {
573
-						if ( ! in_array( $k, Redux_Core::$fields_hidden, true ) ) {
574
-							Redux_Core::$fields_hidden[] = $k;
575
-							Redux_Core::$folds[ $k ]     = 'hide';
576
-						}
577
-					}
578
-				}
579
-			}
580
-
581
-			$this->localize_data['fields_hidden'] = Redux_Core::$fields_hidden;
582
-			$this->localize_data['options']       = $core->options;
583
-			$this->localize_data['defaults']      = $core->options_defaults;
584
-
585
-			/**
586
-			 * Save pending string
587
-			 * filter 'redux/{opt_name}/localize/save_pending'
588
-			 *
589
-			 * @param string $msg Save_pending string
590
-			 */
591
-			// phpcs:ignore WordPress.NamingConventions.ValidHookName
592
-			$save_pending = apply_filters(
593
-			// phpcs:ignore WordPress.NamingConventions.ValidHookName
594
-				"redux/{$core->args['opt_name']}/localize/save_pending",
595
-				esc_html__(
596
-					'You have changes that are not saved. Would you like to save them now?',
597
-					'redux-framework'
598
-				)
599
-			);
600
-
601
-			/**
602
-			 * Reset all string
603
-			 * filter 'redux/{opt_name}/localize/reset'
604
-			 *
605
-			 * @param string $msg Reset all string.
606
-			 */
607
-			// phpcs:ignore WordPress.NamingConventions.ValidHookName
608
-			$reset_all = apply_filters(
609
-			// phpcs:ignore WordPress.NamingConventions.ValidHookName
610
-				"redux/{$core->args['opt_name']}/localize/reset",
611
-				esc_html__(
612
-					'Are you sure? Resetting will lose all custom values.',
613
-					'redux-framework'
614
-				)
615
-			);
616
-
617
-			/**
618
-			 * Reset section string
619
-			 * filter 'redux/{opt_name}/localize/reset_section'
620
-			 *
621
-			 * @param string $msg Reset section string.
622
-			 */
623
-			// phpcs:ignore WordPress.NamingConventions.ValidHookName
624
-			$reset_section = apply_filters(
625
-			// phpcs:ignore WordPress.NamingConventions.ValidHookName
626
-				"redux/{$core->args['opt_name']}/localize/reset_section",
627
-				esc_html__(
628
-					'Are you sure? Resetting will lose all custom values in this section.',
629
-					'redux-framework'
630
-				)
631
-			);
632
-
633
-			/**
634
-			 * Preset confirm string
635
-			 * filter 'redux/{opt_name}/localize/preset'
636
-			 *
637
-			 * @param string $msg Preset confirm string.
638
-			 */
639
-			// phpcs:ignore WordPress.NamingConventions.ValidHookName
640
-			$preset_confirm = apply_filters(
641
-			// phpcs:ignore WordPress.NamingConventions.ValidHookName
642
-				"redux/{$core->args['opt_name']}/localize/preset",
643
-				esc_html__(
644
-					'Your current options will be replaced with the values of this preset. Would you like to proceed?',
645
-					'redux-framework'
646
-				)
647
-			);
648
-
649
-			/**
650
-			 * Import confirm string
651
-			 * filter 'redux/{opt_name}/localize/import
652
-			 *
653
-			 * @param string $msg Import confirm string.
654
-			 */
655
-			// phpcs:ignore WordPress.NamingConventions.ValidHookName
656
-			$import_confirm = apply_filters(
657
-			// phpcs:ignore WordPress.NamingConventions.ValidHookName
658
-				"redux/{$core->args['opt_name']}/localize/import",
659
-				esc_html__(
660
-					'Your current options will be replaced with the values of this import. Would you like to proceed?',
661
-					'redux-framework'
662
-				)
663
-			);
664
-
665
-			global $pagenow;
666
-
667
-			$this->localize_data['args'] = array(
668
-				'dev_mode'               => $core->args['dev_mode'],
669
-				'save_pending'           => $save_pending,
670
-				'reset_confirm'          => $reset_all,
671
-				'reset_section_confirm'  => $reset_section,
672
-				'preset_confirm'         => $preset_confirm,
673
-				'import_section_confirm' => $import_confirm,
674
-				'please_wait'            => esc_html__( 'Please Wait', 'redux-framework' ),
675
-				'opt_name'               => $core->args['opt_name'],
676
-				'flyout_submenus'        => $core->args['flyout_submenus'] ?? false,
677
-				'search'                 => $core->args['search'] ?? true,
678
-				'slug'                   => $core->args['page_slug'],
679
-				'hints'                  => $core->args['hints'],
680
-				'disable_save_warn'      => $core->args['disable_save_warn'],
681
-				'class'                  => $core->args['class'],
682
-				'ajax_save'              => $core->args['ajax_save'],
683
-				'menu_search'            => $pagenow . '?page=' . $core->args['page_slug'] . '&tab=',
684
-			);
685
-
686
-			$this->localize_data['ajax'] = array(
687
-				'console' => esc_html__(
688
-					'There was an error saving. Here is the result of your action:',
689
-					'redux-framework'
690
-				),
691
-				'alert'   => esc_html__(
692
-					'There was a problem with your action. Please try again or reload the page.',
693
-					'redux-framework'
694
-				),
695
-			);
696
-
697
-			// phpcs:ignore WordPress.NamingConventions.ValidHookName
698
-			$this->localize_data = apply_filters( "redux/{$core->args['opt_name']}/localize", $this->localize_data );
699
-
700
-			// phpcs:ignore WordPress.NamingConventions.ValidHookName
701
-			$this->repeater_data = apply_filters( "redux/{$core->args['opt_name']}/repeater", $this->repeater_data );
702
-
703
-			$this->get_warnings_and_errors_array();
704
-
705
-			if ( ! isset( $core->repeater_data ) ) {
706
-				$core->repeater_data = array();
707
-			}
708
-			$core->repeater_data = Redux_Functions_Ex::nested_wp_parse_args(
709
-				$this->repeater_data,
710
-				$core->repeater_data
711
-			);
712
-
713
-			if ( ! isset( $core->localize_data ) ) {
714
-				$core->localize_data = array();
715
-			}
716
-			$core->localize_data = Redux_Functions_Ex::nested_wp_parse_args(
717
-				$this->localize_data,
718
-				$core->localize_data
719
-			);
720
-
721
-			// Shim for extension compatibility.
722
-			if ( Redux::$extension_compatibility ) {
723
-				$this->repeater_data = Redux_Functions_Ex::nested_wp_parse_args(
724
-					$this->repeater_data,
725
-					$core->localize_data
726
-				);
727
-			}
728
-
729
-			wp_localize_script(
730
-				'redux-js',
731
-				'redux',
732
-				$this->repeater_data
733
-			);
734
-
735
-			wp_localize_script(
736
-				'redux-js',
737
-				'redux_' . str_replace( '-', '_', $core->args['opt_name'] ),
738
-				$this->localize_data
739
-			);
740
-
741
-			wp_enqueue_script( 'redux-js' ); // Enqueue the JS now.
742
-		}
743
-	}
15
+    /**
16
+     * Class Redux_Enqueue
17
+     */
18
+    class Redux_Enqueue extends Redux_Class {
19
+
20
+        /**
21
+         * Data to localize.
22
+         *
23
+         * @var array
24
+         */
25
+        public array $localize_data = array();
26
+
27
+        /**
28
+         * Min string for .min files.
29
+         *
30
+         * @var string
31
+         */
32
+        private string $min = '';
33
+
34
+        /**
35
+         * Timestamp for file versions.
36
+         *
37
+         * @var string
38
+         */
39
+        private string $timestamp = '';
40
+
41
+        /**
42
+         * Localize data required for the repeater extension.
43
+         *
44
+         * @var array
45
+         */
46
+        private array $repeater_data = array();
47
+
48
+        /**
49
+         * Redux_Enqueue constructor.
50
+         *
51
+         * @param     object $redux ReduxFramework pointer.
52
+         */
53
+        public function __construct( $redux ) {
54
+            parent::__construct( $redux );
55
+
56
+            // Enqueue the admin page CSS and JS.
57
+            if ( isset( $_GET['page'] ) && $_GET['page'] === $redux->args['page_slug'] ) { // phpcs:ignore WordPress.Security.NonceVerification
58
+                add_action( 'admin_enqueue_scripts', array( $this, 'init' ), 1 );
59
+            }
60
+
61
+            add_action( 'wp_enqueue_scripts', array( $this, 'frontend_init' ), 10 );
62
+
63
+            // phpcs:ignore WordPress.NamingConventions.ValidHookName
64
+            do_action( "redux/{$redux->args['opt_name']}/enqueue/construct", $this );
65
+
66
+            // phpcs:ignore WordPress.NamingConventions.ValidHookName
67
+            do_action( 'redux/enqueue/construct', $this );
68
+
69
+            // phpcs:ignore WordPress.NamingConventions.ValidHookName
70
+            do_action( 'redux/search/' . $redux->args['opt_name'] . '/construct' );
71
+
72
+            //if ( isset( $_GET['page'] ) && sanitize_text_field( wp_unslash( $_GET['page'] === $this->parent->args['page_slug'] ) ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Recommended
73
+            //	add_action( 'admin_enqueue_scripts', array( $this, 'enqueue' ), 0 );
74
+            //}
75
+
76
+            //add_action( "redux/metaboxes/{$this->parent->args[ 'opt_name' ]}/enqueue", array( $this, 'enqueue' ), 10 );
77
+        }
78
+
79
+        /**
80
+         * Scripts to enqueue on the frontend
81
+         */
82
+        public function frontend_init() {
83
+            $core = $this->core();
84
+
85
+            if ( $core->args['elusive_frontend'] ) {
86
+                Redux_Functions_Ex::enqueue_elusive_font();
87
+            }
88
+
89
+            if ( $core->args['fontawesome_frontend'] ) {
90
+                Redux_Functions_Ex::enqueue_font_awesome();
91
+            }
92
+        }
93
+
94
+        /**
95
+         * Class init functions.
96
+         */
97
+        public function init() {
98
+            $core = $this->core();
99
+
100
+            Redux_Functions::$parent = $core;
101
+
102
+            $this->min = Redux_Functions::is_min();
103
+
104
+            $this->timestamp = Redux_Core::$version;
105
+            if ( $core->args['dev_mode'] ) {
106
+                $this->timestamp .= '.' . time();
107
+            }
108
+
109
+            $this->register_styles( $core );
110
+            $this->register_scripts();
111
+
112
+            add_thickbox();
113
+
114
+            $this->enqueue_fields( $core );
115
+
116
+            add_filter( "redux/{$core->args['opt_name']}/localize", array( 'Redux_Helpers', 'localize' ) );
117
+
118
+            $this->set_localized_data( $core );
119
+
120
+            /**
121
+             * Action 'redux/page/{opt_name}/enqueue'
122
+             */
123
+            // phpcs:ignore WordPress.NamingConventions.ValidHookName
124
+            do_action( "redux/page/{$core->args['opt_name']}/enqueue" );
125
+        }
126
+
127
+        /**
128
+         * Register all core framework styles.
129
+         *
130
+         * @param ReduxFramework $core ReduxFramework object.
131
+         */
132
+        private function register_styles( ReduxFramework $core ) {
133
+
134
+            /**
135
+             * Redux Admin CSS
136
+             */
137
+            if ( 'wordpress' === $core->args['admin_theme'] || 'wp' === $core->args['admin_theme'] ) { // phpcs:ignore WordPress.WP.CapitalPDangit
138
+                $color_scheme = get_user_option( 'admin_color' );
139
+            } elseif ( 'classic' === $core->args['admin_theme'] || '' === $core->args['admin_theme'] ) {
140
+                $color_scheme = 'classic';
141
+            } else {
142
+                $color_scheme = $core->args['admin_theme'];
143
+            }
144
+
145
+            if ( ! file_exists( Redux_Core::$dir . "assets/css/colors/$color_scheme/colors$this->min.css" ) ) {
146
+                $color_scheme = 'fresh';
147
+            }
148
+
149
+            $css = Redux_Core::$url . "assets/css/colors/$color_scheme/colors$this->min.css";
150
+
151
+            // phpcs:ignore WordPress.NamingConventions.ValidHookName
152
+            $css = apply_filters( 'redux/enqueue/' . $core->args['opt_name'] . '/args/admin_theme/css_url', $css );
153
+
154
+            wp_register_style(
155
+                'redux-admin-theme',
156
+                $css,
157
+                array(),
158
+                $this->timestamp
159
+            );
160
+
161
+            wp_enqueue_style(
162
+                'redux-admin-css',
163
+                Redux_Core::$url . "assets/css/redux-admin$this->min.css",
164
+                array( 'redux-admin-theme' ),
165
+                $this->timestamp
166
+            );
167
+
168
+            /**
169
+             * Redux Fields CSS
170
+             */
171
+            if ( ! $core->args['dev_mode'] ) {
172
+                wp_enqueue_style(
173
+                    'redux-fields',
174
+                    Redux_Core::$url . 'assets/css/redux-fields.min.css',
175
+                    array(),
176
+                    $this->timestamp
177
+                );
178
+            }
179
+
180
+            /**
181
+             * Select2 CSS
182
+             */
183
+            wp_enqueue_style(
184
+                'select2-css',
185
+                Redux_Core::$url . 'assets/css/vendor/select2.min.css',
186
+                array(),
187
+                '4.1.0'
188
+            );
189
+
190
+            /**
191
+             * Spectrum CSS
192
+             */
193
+            wp_register_style(
194
+                'redux-spectrum-css',
195
+                Redux_Core::$url . "assets/css/vendor/spectrum$this->min.css",
196
+                array(),
197
+                '1.3.3'
198
+            );
199
+
200
+            /**
201
+             * Elusive Icon CSS
202
+             */
203
+            Redux_Functions_Ex::enqueue_elusive_font();
204
+
205
+            /**
206
+             * Font Awesome for Social Profiles and Icon Select
207
+             */
208
+            Redux_Functions_Ex::enqueue_font_awesome();
209
+
210
+            /**
211
+             * QTip CSS
212
+             */
213
+            wp_enqueue_style(
214
+                'qtip',
215
+                Redux_Core::$url . "assets/css/vendor/qtip$this->min.css",
216
+                array(),
217
+                '3.0.3'
218
+            );
219
+
220
+            /**
221
+             * JQuery UI CSS
222
+             */
223
+            wp_enqueue_style(
224
+                'jquery-ui',
225
+                // phpcs:ignore WordPress.NamingConventions.ValidHookName
226
+                apply_filters(
227
+                // phpcs:ignore WordPress.NamingConventions.ValidHookName
228
+                    "redux/page/{$core->args['opt_name']}/enqueue/jquery-ui-css",
229
+                    Redux_Core::$url . 'assets/css/vendor/jquery-ui-1.10.0.custom.css'
230
+                ),
231
+                array(),
232
+                $this->timestamp
233
+            );
234
+
235
+            /**
236
+             * Iris CSS
237
+             */
238
+            wp_enqueue_style( 'wp-color-picker' );
239
+
240
+            if ( $core->args['dev_mode'] ) {
241
+
242
+                /**
243
+                 * Media CSS
244
+                 */
245
+                wp_enqueue_style(
246
+                    'redux-field-media',
247
+                    Redux_Core::$url . 'assets/css/media.css',
248
+                    array(),
249
+                    $this->timestamp
250
+                );
251
+            }
252
+
253
+            /**
254
+             * RTL CSS
255
+             */
256
+            if ( is_rtl() ) {
257
+                wp_enqueue_style(
258
+                    'redux-rtl',
259
+                    Redux_Core::$url . 'assets/css/rtl.css',
260
+                    array(),
261
+                    $this->timestamp
262
+                );
263
+            }
264
+        }
265
+
266
+        /**
267
+         * Register all core framework scripts.
268
+         */
269
+        private function register_scripts() {
270
+            // *****************************************************************
271
+            // JQuery / JQuery UI JS
272
+            // *****************************************************************
273
+            wp_enqueue_script( 'jquery' );
274
+            wp_enqueue_script( 'jquery-ui-core' );
275
+            wp_enqueue_script( 'jquery-ui-dialog' );
276
+
277
+            /**
278
+             * Select2 Sortable JS
279
+             */
280
+            wp_register_script(
281
+                'redux-select2-sortable',
282
+                Redux_Core::$url . 'assets/js/vendor/select2-sortable/redux.select2.sortable' . $this->min . '.js',
283
+                array( 'jquery', 'jquery-ui-sortable' ),
284
+                $this->timestamp,
285
+                true
286
+            );
287
+
288
+            /**
289
+             * Select2
290
+             */
291
+            wp_enqueue_script(
292
+                'select2-js',
293
+                Redux_Core::$url . 'assets/js/vendor/select2/select2' . $this->min . '.js`',
294
+                array( 'jquery', 'redux-select2-sortable' ),
295
+                '4.1.0',
296
+                true
297
+            );
298
+
299
+            /**
300
+             * QTip JS
301
+             */
302
+            wp_enqueue_script(
303
+                'qtip',
304
+                Redux_Core::$url . 'assets/js/vendor/qtip/qtip' . $this->min . '.js',
305
+                array( 'jquery' ),
306
+                '3.0.3',
307
+                true
308
+            );
309
+
310
+            /**
311
+             * Iris alpha color picker
312
+             */
313
+            if ( ! wp_script_is( 'redux-wp-color-picker-alpha' ) ) {
314
+                wp_enqueue_style( 'wp-color-picker' );
315
+
316
+                wp_register_script(
317
+                    'redux-wp-color-picker-alpha',
318
+                    Redux_Core::$url . 'assets/js/vendor/wp-color-picker-alpha/wp-color-picker-alpha' . $this->min . '.js',
319
+                    array( 'jquery', 'wp-color-picker' ),
320
+                    '3.0.0',
321
+                    true
322
+                );
323
+            }
324
+
325
+            /**
326
+             * Block UI (used by Custom Fonts and Color Schemes).
327
+             */
328
+            wp_register_script(
329
+                'redux-block-ui',
330
+                Redux_Core::$url . 'assets/js/vendor/block-ui/jquery.blockUI' . $this->min . '.js',
331
+                array( 'jquery' ),
332
+                '2.70.0',
333
+                true
334
+            );
335
+
336
+            /**
337
+             * Spectrum JS
338
+             */
339
+            wp_register_script(
340
+                'redux-spectrum-js',
341
+                Redux_Core::$url . 'assets/js/vendor/spectrum/redux-spectrum' . $this->min . '.js',
342
+                array( 'jquery' ),
343
+                '1.3.3',
344
+                true
345
+            );
346
+
347
+            /**
348
+             * Vendor JS
349
+             */
350
+            wp_register_script(
351
+                'redux-vendor',
352
+                Redux_Core::$url . 'assets/js/redux-vendors' . $this->min . '.js',
353
+                array( 'jquery' ),
354
+                $this->timestamp,
355
+                true
356
+            );
357
+
358
+            /**
359
+             * Redux JS
360
+             */
361
+            wp_register_script(
362
+                'redux-js',
363
+                Redux_Core::$url . 'assets/js/redux' . $this->min . '.js',
364
+                array( 'jquery', 'redux-vendor' ),
365
+                $this->timestamp,
366
+                true
367
+            );
368
+        }
369
+
370
+        /**
371
+         * Enqueue fields that are in use.
372
+         *
373
+         * @param ReduxFramework $core  ReduxFramework object.
374
+         * @param array          $field Field array.
375
+         */
376
+        public function enqueue_field( ReduxFramework $core, array $field ) {
377
+            if ( isset( $field['type'] ) && 'callback' !== $field['type'] ) {
378
+                $field_type = str_replace( '_', '-', $field['type'] );
379
+                $core_path  = Redux_Core::$dir . "inc/fields/{$field['type']}/class-redux-$field_type.php";
380
+
381
+                // Shim for v3 extension class names.
382
+                if ( ! file_exists( $core_path ) ) {
383
+                    $core_path = Redux_Core::$dir . "inc/fields/{$field['type']}/field_{$field['type']}.php";
384
+                }
385
+
386
+                $filter_path = $core_path;
387
+
388
+                /**
389
+                 * Field class file
390
+                 * filter 'redux/{opt_name}/field/class/{field.type}'
391
+                 *
392
+                 * @param     string    $filter_path Field class file path
393
+                 * @param     array     $field       Field config data
394
+                 */
395
+                // phpcs:ignore WordPress.NamingConventions.ValidHookName
396
+                $class_file = apply_filters(
397
+                // phpcs:ignore WordPress.NamingConventions.ValidHookName
398
+                    "redux/{$core->args['opt_name']}/field/class/{$field['type']}",
399
+                    $filter_path,
400
+                    $field
401
+                );
402
+
403
+                $field_classes = array( 'Redux_' . $field['type'], 'ReduxFramework_' . $field['type'] );
404
+
405
+                if ( $class_file ) {
406
+                    $field_class = Redux_Functions::class_exists_ex( $field_classes );
407
+                    if ( false === $field_class ) {
408
+                        if ( file_exists( $class_file ) ) {
409
+                            require_once $class_file;
410
+
411
+                            $field_class = Redux_Functions::class_exists_ex( $field_classes );
412
+                        } else {
413
+                            return;
414
+                        }
415
+                    }
416
+
417
+                    if ( false !== $field_class && ( ( method_exists( $field_class, 'enqueue' ) ) || method_exists( $field_class, 'localize' ) ) ) {
418
+                        if ( ! isset( $core->options[ $field['id'] ] ) ) {
419
+                            $core->options[ $field['id'] ] = '';
420
+                        }
421
+
422
+                        $the_field = new $field_class( $field, $core->options[ $field['id'] ], $core );
423
+
424
+                        // Move dev_mode check to a new if/then block.
425
+                        if ( ! wp_script_is( 'redux-field-' . $field_type ) && ( class_exists( $field_class ) && method_exists( $field_class, 'enqueue' ) ) ) {
426
+                            $the_field->enqueue();
427
+                        }
428
+
429
+                        if ( class_exists( $field_class ) && method_exists( $field_class, 'always_enqueue' ) ) {
430
+                            $the_field->always_enqueue();
431
+                        }
432
+
433
+                        if ( method_exists( $field_class, 'localize' ) ) {
434
+                            $the_field->localize( $field );
435
+
436
+                            if ( ! isset( $this->localize_data[ $field['type'] ] ) ) {
437
+                                $this->localize_data[ $field['type'] ] = array();
438
+                            }
439
+
440
+                            $localize_data = $the_field->localize( $field );
441
+
442
+                            $shims = array( 'repeater' );
443
+
444
+                            // phpcs:ignore WordPress.NamingConventions.ValidHookName
445
+                            $shims = apply_filters( 'redux/' . $core->args['opt_name'] . '/localize/shims', $shims );
446
+
447
+                            if ( is_array( $shims ) && in_array( $field['type'], $shims, true ) ) {
448
+                                $this->repeater_data[ $field['type'] ][ $field['id'] ] = $localize_data;
449
+                            }
450
+
451
+                            $this->localize_data[ $field['type'] ][ $field['id'] ] = $localize_data;
452
+                        }
453
+
454
+                        unset( $the_field );
455
+                    }
456
+                }
457
+            }
458
+        }
459
+
460
+        /**
461
+         * Enqueue field files.
462
+         *
463
+         * @param ReduxFramework $core ReduxFramework object.
464
+         */
465
+        private function enqueue_fields( ReduxFramework $core ) {
466
+            foreach ( $core->sections as $section ) {
467
+                if ( isset( $section['fields'] ) ) {
468
+                    foreach ( $section['fields'] as $field ) {
469
+                        $this->enqueue_field( $core, $field );
470
+                    }
471
+                }
472
+            }
473
+        }
474
+
475
+        /**
476
+         * Build a localized array from field functions, if any.
477
+         *
478
+         * @param ReduxFramework $core ReduxFramework object.
479
+         * @param string         $type Field type.
480
+         */
481
+        private function build_local_array( ReduxFramework $core, string $type ) {
482
+            if ( isset( $core->transients['last_save_mode'] ) && ! empty( $core->transients['notices'][ $type ] ) ) {
483
+                $the_total = 0;
484
+                $messages  = array();
485
+
486
+                foreach ( $core->transients['notices'][ $type ] as $msg ) {
487
+                    if ( is_array( $msg ) && ! empty( $msg ) ) {
488
+                        $messages[ $msg['section_id'] ][ $type ][] = $msg;
489
+
490
+                        if ( ! isset( $messages[ $msg['section_id'] ]['total'] ) ) {
491
+                            $messages[ $msg['section_id'] ]['total'] = 0;
492
+                        }
493
+
494
+                        ++$messages[ $msg['section_id'] ]['total'];
495
+                        ++$the_total;
496
+                    }
497
+                }
498
+
499
+                $this->localize_data[ $type ] = array(
500
+                    'total' => $the_total,
501
+                    "$type" => $messages,
502
+                );
503
+
504
+                unset( $core->transients['notices'][ $type ] );
505
+            }
506
+        }
507
+
508
+        /**
509
+         * Compile panel errors and wearings for a localized array.
510
+         */
511
+        public function get_warnings_and_errors_array() {
512
+            $core = $this->core();
513
+
514
+            $this->build_local_array( $core, 'errors' );
515
+            $this->build_local_array( $core, 'warnings' );
516
+            $this->build_local_array( $core, 'sanitize' );
517
+
518
+            if ( empty( $core->transients['notices'] ) ) {
519
+                if ( isset( $core->transients['notices'] ) ) {
520
+                    unset( $core->transients['notices'] );
521
+                }
522
+            }
523
+        }
524
+
525
+        /**
526
+         * Commit localized data to global array.
527
+         *
528
+         * @param ReduxFramework $core ReduxFramework object.
529
+         */
530
+        private function set_localized_data( ReduxFramework $core ) {
531
+            if ( ! empty( $core->args['last_tab'] ) ) {
532
+                $this->localize_data['last_tab'] = $core->args['last_tab'];
533
+            }
534
+
535
+            $this->localize_data['search'] = esc_html__( 'Search for field(s)', 'redux-framework' );
536
+
537
+            $this->localize_data['font_weights'] = $this->args['font_weights'];
538
+
539
+            $this->localize_data['required'] = Redux_Core::$required;
540
+            $this->repeater_data['fonts']    = Redux_Core::$fonts;
541
+
542
+            if ( ! isset( $this->repeater_data['opt_names'] ) ) {
543
+                $this->repeater_data['opt_names'] = array();
544
+            }
545
+
546
+            $this->repeater_data['opt_names'][]    = $core->args['opt_name'];
547
+            $this->repeater_data['folds']          = array();
548
+            $this->localize_data['required_child'] = Redux_Core::$required_child;
549
+            $this->localize_data['fields']         = $core->fields;
550
+
551
+            if ( isset( Redux_Core::$font_groups['google'] ) ) {
552
+                $this->repeater_data['googlefonts'] = Redux_Core::$font_groups['google'];
553
+            }
554
+
555
+            if ( isset( Redux_Core::$font_groups['std'] ) ) {
556
+                $this->repeater_data['stdfonts'] = Redux_Core::$font_groups['std'];
557
+            }
558
+
559
+            if ( isset( Redux_Core::$font_groups['customfonts'] ) ) {
560
+                $this->repeater_data['customfonts'] = Redux_Core::$font_groups['customfonts'];
561
+            }
562
+
563
+            if ( isset( Redux_Core::$font_groups['typekitfonts'] ) ) {
564
+                $this->repeater_data['typekitfonts'] = Redux_Core::$font_groups['typekitfonts'];
565
+            }
566
+
567
+            $this->localize_data['folds'] = Redux_Core::$folds;
568
+
569
+            // Make sure the children are all hidden properly.
570
+            foreach ( $core->fields as $key => $value ) {
571
+                if ( in_array( $key, Redux_Core::$fields_hidden, true ) ) {
572
+                    foreach ( $value as $k => $v ) {
573
+                        if ( ! in_array( $k, Redux_Core::$fields_hidden, true ) ) {
574
+                            Redux_Core::$fields_hidden[] = $k;
575
+                            Redux_Core::$folds[ $k ]     = 'hide';
576
+                        }
577
+                    }
578
+                }
579
+            }
580
+
581
+            $this->localize_data['fields_hidden'] = Redux_Core::$fields_hidden;
582
+            $this->localize_data['options']       = $core->options;
583
+            $this->localize_data['defaults']      = $core->options_defaults;
584
+
585
+            /**
586
+             * Save pending string
587
+             * filter 'redux/{opt_name}/localize/save_pending'
588
+             *
589
+             * @param string $msg Save_pending string
590
+             */
591
+            // phpcs:ignore WordPress.NamingConventions.ValidHookName
592
+            $save_pending = apply_filters(
593
+            // phpcs:ignore WordPress.NamingConventions.ValidHookName
594
+                "redux/{$core->args['opt_name']}/localize/save_pending",
595
+                esc_html__(
596
+                    'You have changes that are not saved. Would you like to save them now?',
597
+                    'redux-framework'
598
+                )
599
+            );
600
+
601
+            /**
602
+             * Reset all string
603
+             * filter 'redux/{opt_name}/localize/reset'
604
+             *
605
+             * @param string $msg Reset all string.
606
+             */
607
+            // phpcs:ignore WordPress.NamingConventions.ValidHookName
608
+            $reset_all = apply_filters(
609
+            // phpcs:ignore WordPress.NamingConventions.ValidHookName
610
+                "redux/{$core->args['opt_name']}/localize/reset",
611
+                esc_html__(
612
+                    'Are you sure? Resetting will lose all custom values.',
613
+                    'redux-framework'
614
+                )
615
+            );
616
+
617
+            /**
618
+             * Reset section string
619
+             * filter 'redux/{opt_name}/localize/reset_section'
620
+             *
621
+             * @param string $msg Reset section string.
622
+             */
623
+            // phpcs:ignore WordPress.NamingConventions.ValidHookName
624
+            $reset_section = apply_filters(
625
+            // phpcs:ignore WordPress.NamingConventions.ValidHookName
626
+                "redux/{$core->args['opt_name']}/localize/reset_section",
627
+                esc_html__(
628
+                    'Are you sure? Resetting will lose all custom values in this section.',
629
+                    'redux-framework'
630
+                )
631
+            );
632
+
633
+            /**
634
+             * Preset confirm string
635
+             * filter 'redux/{opt_name}/localize/preset'
636
+             *
637
+             * @param string $msg Preset confirm string.
638
+             */
639
+            // phpcs:ignore WordPress.NamingConventions.ValidHookName
640
+            $preset_confirm = apply_filters(
641
+            // phpcs:ignore WordPress.NamingConventions.ValidHookName
642
+                "redux/{$core->args['opt_name']}/localize/preset",
643
+                esc_html__(
644
+                    'Your current options will be replaced with the values of this preset. Would you like to proceed?',
645
+                    'redux-framework'
646
+                )
647
+            );
648
+
649
+            /**
650
+             * Import confirm string
651
+             * filter 'redux/{opt_name}/localize/import
652
+             *
653
+             * @param string $msg Import confirm string.
654
+             */
655
+            // phpcs:ignore WordPress.NamingConventions.ValidHookName
656
+            $import_confirm = apply_filters(
657
+            // phpcs:ignore WordPress.NamingConventions.ValidHookName
658
+                "redux/{$core->args['opt_name']}/localize/import",
659
+                esc_html__(
660
+                    'Your current options will be replaced with the values of this import. Would you like to proceed?',
661
+                    'redux-framework'
662
+                )
663
+            );
664
+
665
+            global $pagenow;
666
+
667
+            $this->localize_data['args'] = array(
668
+                'dev_mode'               => $core->args['dev_mode'],
669
+                'save_pending'           => $save_pending,
670
+                'reset_confirm'          => $reset_all,
671
+                'reset_section_confirm'  => $reset_section,
672
+                'preset_confirm'         => $preset_confirm,
673
+                'import_section_confirm' => $import_confirm,
674
+                'please_wait'            => esc_html__( 'Please Wait', 'redux-framework' ),
675
+                'opt_name'               => $core->args['opt_name'],
676
+                'flyout_submenus'        => $core->args['flyout_submenus'] ?? false,
677
+                'search'                 => $core->args['search'] ?? true,
678
+                'slug'                   => $core->args['page_slug'],
679
+                'hints'                  => $core->args['hints'],
680
+                'disable_save_warn'      => $core->args['disable_save_warn'],
681
+                'class'                  => $core->args['class'],
682
+                'ajax_save'              => $core->args['ajax_save'],
683
+                'menu_search'            => $pagenow . '?page=' . $core->args['page_slug'] . '&tab=',
684
+            );
685
+
686
+            $this->localize_data['ajax'] = array(
687
+                'console' => esc_html__(
688
+                    'There was an error saving. Here is the result of your action:',
689
+                    'redux-framework'
690
+                ),
691
+                'alert'   => esc_html__(
692
+                    'There was a problem with your action. Please try again or reload the page.',
693
+                    'redux-framework'
694
+                ),
695
+            );
696
+
697
+            // phpcs:ignore WordPress.NamingConventions.ValidHookName
698
+            $this->localize_data = apply_filters( "redux/{$core->args['opt_name']}/localize", $this->localize_data );
699
+
700
+            // phpcs:ignore WordPress.NamingConventions.ValidHookName
701
+            $this->repeater_data = apply_filters( "redux/{$core->args['opt_name']}/repeater", $this->repeater_data );
702
+
703
+            $this->get_warnings_and_errors_array();
704
+
705
+            if ( ! isset( $core->repeater_data ) ) {
706
+                $core->repeater_data = array();
707
+            }
708
+            $core->repeater_data = Redux_Functions_Ex::nested_wp_parse_args(
709
+                $this->repeater_data,
710
+                $core->repeater_data
711
+            );
712
+
713
+            if ( ! isset( $core->localize_data ) ) {
714
+                $core->localize_data = array();
715
+            }
716
+            $core->localize_data = Redux_Functions_Ex::nested_wp_parse_args(
717
+                $this->localize_data,
718
+                $core->localize_data
719
+            );
720
+
721
+            // Shim for extension compatibility.
722
+            if ( Redux::$extension_compatibility ) {
723
+                $this->repeater_data = Redux_Functions_Ex::nested_wp_parse_args(
724
+                    $this->repeater_data,
725
+                    $core->localize_data
726
+                );
727
+            }
728
+
729
+            wp_localize_script(
730
+                'redux-js',
731
+                'redux',
732
+                $this->repeater_data
733
+            );
734
+
735
+            wp_localize_script(
736
+                'redux-js',
737
+                'redux_' . str_replace( '-', '_', $core->args['opt_name'] ),
738
+                $this->localize_data
739
+            );
740
+
741
+            wp_enqueue_script( 'redux-js' ); // Enqueue the JS now.
742
+        }
743
+    }
744 744
 }
745 745
 
746 746
 if ( ! class_exists( 'reduxCoreEnqueue' ) ) {
747
-	class_alias( 'Redux_Enqueue', 'reduxCoreEnqueue' );
747
+    class_alias( 'Redux_Enqueue', 'reduxCoreEnqueue' );
748 748
 }
Please login to merge, or discard this patch.
Spacing   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -415,11 +415,11 @@  discard block
 block discarded – undo
415 415
 					}
416 416
 
417 417
 					if ( false !== $field_class && ( ( method_exists( $field_class, 'enqueue' ) ) || method_exists( $field_class, 'localize' ) ) ) {
418
-						if ( ! isset( $core->options[ $field['id'] ] ) ) {
419
-							$core->options[ $field['id'] ] = '';
418
+						if ( ! isset( $core->options[$field['id']] ) ) {
419
+							$core->options[$field['id']] = '';
420 420
 						}
421 421
 
422
-						$the_field = new $field_class( $field, $core->options[ $field['id'] ], $core );
422
+						$the_field = new $field_class( $field, $core->options[$field['id']], $core );
423 423
 
424 424
 						// Move dev_mode check to a new if/then block.
425 425
 						if ( ! wp_script_is( 'redux-field-' . $field_type ) && ( class_exists( $field_class ) && method_exists( $field_class, 'enqueue' ) ) ) {
@@ -433,8 +433,8 @@  discard block
 block discarded – undo
433 433
 						if ( method_exists( $field_class, 'localize' ) ) {
434 434
 							$the_field->localize( $field );
435 435
 
436
-							if ( ! isset( $this->localize_data[ $field['type'] ] ) ) {
437
-								$this->localize_data[ $field['type'] ] = array();
436
+							if ( ! isset( $this->localize_data[$field['type']] ) ) {
437
+								$this->localize_data[$field['type']] = array();
438 438
 							}
439 439
 
440 440
 							$localize_data = $the_field->localize( $field );
@@ -445,10 +445,10 @@  discard block
 block discarded – undo
445 445
 							$shims = apply_filters( 'redux/' . $core->args['opt_name'] . '/localize/shims', $shims );
446 446
 
447 447
 							if ( is_array( $shims ) && in_array( $field['type'], $shims, true ) ) {
448
-								$this->repeater_data[ $field['type'] ][ $field['id'] ] = $localize_data;
448
+								$this->repeater_data[$field['type']][$field['id']] = $localize_data;
449 449
 							}
450 450
 
451
-							$this->localize_data[ $field['type'] ][ $field['id'] ] = $localize_data;
451
+							$this->localize_data[$field['type']][$field['id']] = $localize_data;
452 452
 						}
453 453
 
454 454
 						unset( $the_field );
@@ -479,29 +479,29 @@  discard block
 block discarded – undo
479 479
 		 * @param string         $type Field type.
480 480
 		 */
481 481
 		private function build_local_array( ReduxFramework $core, string $type ) {
482
-			if ( isset( $core->transients['last_save_mode'] ) && ! empty( $core->transients['notices'][ $type ] ) ) {
482
+			if ( isset( $core->transients['last_save_mode'] ) && ! empty( $core->transients['notices'][$type] ) ) {
483 483
 				$the_total = 0;
484 484
 				$messages  = array();
485 485
 
486
-				foreach ( $core->transients['notices'][ $type ] as $msg ) {
486
+				foreach ( $core->transients['notices'][$type] as $msg ) {
487 487
 					if ( is_array( $msg ) && ! empty( $msg ) ) {
488
-						$messages[ $msg['section_id'] ][ $type ][] = $msg;
488
+						$messages[$msg['section_id']][$type][] = $msg;
489 489
 
490
-						if ( ! isset( $messages[ $msg['section_id'] ]['total'] ) ) {
491
-							$messages[ $msg['section_id'] ]['total'] = 0;
490
+						if ( ! isset( $messages[$msg['section_id']]['total'] ) ) {
491
+							$messages[$msg['section_id']]['total'] = 0;
492 492
 						}
493 493
 
494
-						++$messages[ $msg['section_id'] ]['total'];
494
+						++$messages[$msg['section_id']]['total'];
495 495
 						++$the_total;
496 496
 					}
497 497
 				}
498 498
 
499
-				$this->localize_data[ $type ] = array(
499
+				$this->localize_data[$type] = array(
500 500
 					'total' => $the_total,
501 501
 					"$type" => $messages,
502 502
 				);
503 503
 
504
-				unset( $core->transients['notices'][ $type ] );
504
+				unset( $core->transients['notices'][$type] );
505 505
 			}
506 506
 		}
507 507
 
@@ -572,7 +572,7 @@  discard block
 block discarded – undo
572 572
 					foreach ( $value as $k => $v ) {
573 573
 						if ( ! in_array( $k, Redux_Core::$fields_hidden, true ) ) {
574 574
 							Redux_Core::$fields_hidden[] = $k;
575
-							Redux_Core::$folds[ $k ]     = 'hide';
575
+							Redux_Core::$folds[$k]     = 'hide';
576 576
 						}
577 577
 					}
578 578
 				}
Please login to merge, or discard this patch.
redux-core/inc/classes/class-redux-functions-ex.php 2 patches
Indentation   +471 added lines, -471 removed lines patch added patch discarded remove patch
@@ -13,475 +13,475 @@
 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
-			if ( in_array( $name . '/' . $name . '.php', apply_filters( 'active_plugins', get_option( 'active_plugins' ) ), true ) ) {
481
-				return true;
482
-			}
483
-
484
-			return false;
485
-		}
486
-	}
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
+            if ( in_array( $name . '/' . $name . '.php', apply_filters( 'active_plugins', get_option( 'active_plugins' ) ), true ) ) {
481
+                return true;
482
+            }
483
+
484
+            return false;
485
+        }
486
+    }
487 487
 }
Please login to merge, or discard this patch.
Spacing   +20 added lines, -20 removed lines patch added patch discarded remove patch
@@ -79,13 +79,13 @@  discard block
 block discarded – undo
79 79
 
80 80
 			if ( isset( $field['color_alpha'] ) && $field['color_alpha'] ) {
81 81
 				if ( is_array( $field['color_alpha'] ) ) {
82
-					$value = $field['color_alpha'][ $index ] ?? false;
82
+					$value = $field['color_alpha'][$index] ?? false;
83 83
 				} else {
84 84
 					$value = $field['color_alpha'];
85 85
 				}
86 86
 			}
87 87
 
88
-			return 'data-alpha-enabled="' . (bool) esc_attr( $value ) . '"';
88
+			return 'data-alpha-enabled="' . ( bool ) esc_attr( $value ) . '"';
89 89
 		}
90 90
 
91 91
 		/**
@@ -112,10 +112,10 @@  discard block
 block discarded – undo
112 112
 
113 113
 				$k = key( $params );
114 114
 
115
-				if ( ! isset( $result[ $k ] ) ) {
115
+				if ( ! isset( $result[$k] ) ) {
116 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 ] );
117
+				} elseif ( is_array( $result[$k] ) && is_array( $params[$k] ) ) {
118
+					$result[$k] = self::array_merge_recursive_distinct( $result[$k], $params[$k] );
119 119
 				}
120 120
 			}
121 121
 
@@ -139,12 +139,12 @@  discard block
 block discarded – undo
139 139
 
140 140
 			foreach ( $array2 as $key => $value ) {
141 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 ] ) ) {
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 145
 					$merged[] = $value;
146 146
 				} else {
147
-					$merged[ $key ] = $value;
147
+					$merged[$key] = $value;
148 148
 				}
149 149
 			}
150 150
 
@@ -168,20 +168,20 @@  discard block
 block discarded – undo
168 168
 			$caller = debug_backtrace( DEBUG_BACKTRACE_IGNORE_ARGS, 2 )[1]['file'];
169 169
 
170 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();
171
+				if ( ! isset( Redux_Core::$callers[$opt_name] ) ) {
172
+					Redux_Core::$callers[$opt_name] = array();
173 173
 				}
174 174
 
175 175
 				if ( strpos( $caller, 'class-redux-' ) !== false || strpos( $caller, 'redux-core/framework.php' ) ) {
176 176
 					return;
177 177
 				}
178 178
 
179
-				if ( ! in_array( $caller, Redux_Core::$callers[ $opt_name ], true ) ) {
180
-					Redux_Core::$callers[ $opt_name ][] = $caller;
179
+				if ( ! in_array( $caller, Redux_Core::$callers[$opt_name], true ) ) {
180
+					Redux_Core::$callers[$opt_name][] = $caller;
181 181
 				}
182 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;
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 185
 				}
186 186
 			}
187 187
 		}
@@ -362,13 +362,13 @@  discard block
 block discarded – undo
362 362
 						'url'       => self::verify_url_protocol( trailingslashit( trailingslashit( $url ) . $relative_path ) . $filename ),
363 363
 						'basename'  => trailingslashit( $slug ) . trailingslashit( $relative_path ) . $filename,
364 364
 					);
365
-					$data['realpath'] = $data['real_path'];  // Shim for old extensions.
365
+					$data['realpath'] = $data['real_path']; // Shim for old extensions.
366 366
 
367 367
 					if ( count( $theme_paths ) > 1 ) {
368 368
 						$key = array_search( $theme_path, $theme_paths, true );
369 369
 
370 370
 						if ( false !== $key ) {
371
-							unset( $theme_paths[ $key ] );
371
+							unset( $theme_paths[$key] );
372 372
 						}
373 373
 
374 374
 						$theme_paths_end = end( $theme_paths );
@@ -397,10 +397,10 @@  discard block
 block discarded – undo
397 397
 			$result = $b;
398 398
 
399 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 ] );
400
+				if ( is_array( $v ) && isset( $result[$k] ) ) {
401
+					$result[$k] = self::nested_wp_parse_args( $v, $result[$k] );
402 402
 				} else {
403
-					$result[ $k ] = $v;
403
+					$result[$k] = $v;
404 404
 				}
405 405
 			}
406 406
 
Please login to merge, or discard this patch.
redux-core/inc/classes/class-redux-options-constructor.php 2 patches
Spacing   +78 added lines, -78 removed lines patch added patch discarded remove patch
@@ -76,8 +76,8 @@  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'] ] ) ) {
80
-							$options_values[ $field['id'] ] = apply_filters( 'wpml_object_id', $options_values[ $field['id'] ], $field['data'], true );
79
+						if ( ! empty( $field['id'] ) && ! empty( $field['data'] ) && ! empty( $options_values[$field['id']] ) && Redux_Helpers::is_integer( $options_values[$field['id']] ) ) {
80
+							$options_values[$field['id']] = apply_filters( 'wpml_object_id', $options_values[$field['id']], $field['data'], true );
81 81
 						}
82 82
 					}
83 83
 				} elseif ( is_array( $section ) && ! empty( $section ) ) {
@@ -188,10 +188,10 @@  discard block
 block discarded – undo
188 188
 				// Store the changed values in the transient.
189 189
 				if ( $value !== $core->options ) {
190 190
 					foreach ( $value as $k => $v ) {
191
-						if ( ! isset( $core->options[ $k ] ) ) {
192
-							$core->options[ $k ] = '';
193
-						} elseif ( $v === $core->options[ $k ] ) {
194
-							unset( $core->options[ $k ] );
191
+						if ( ! isset( $core->options[$k] ) ) {
192
+							$core->options[$k] = '';
193
+						} elseif ( $v === $core->options[$k] ) {
194
+							unset( $core->options[$k] );
195 195
 						}
196 196
 					}
197 197
 
@@ -227,7 +227,7 @@  discard block
 block discarded – undo
227 227
 				 */
228 228
 
229 229
 				// phpcs:ignore WordPress.NamingConventions.ValidHookName
230
-				$GLOBALS[ $options_global ] = apply_filters( "redux/options/{$core->args['opt_name']}/global_variable", $core->options );
230
+				$GLOBALS[$options_global] = apply_filters( "redux/options/{$core->args['opt_name']}/global_variable", $core->options );
231 231
 			}
232 232
 		}
233 233
 
@@ -291,7 +291,7 @@  discard block
 block discarded – undo
291 291
 				}
292 292
 
293 293
 				if ( empty( $section ) ) {
294
-					unset( $core->sections[ $k ] );
294
+					unset( $core->sections[$k] );
295 295
 					continue;
296 296
 				}
297 297
 
@@ -301,7 +301,7 @@  discard block
 block discarded – undo
301 301
 
302 302
 				if ( isset( $section['customizer_only'] ) && true === $section['customizer_only'] ) {
303 303
 					$section['panel']     = false;
304
-					$core->sections[ $k ] = $section;
304
+					$core->sections[$k] = $section;
305 305
 				}
306 306
 
307 307
 				$heading = $section['heading'] ?? $section['title'];
@@ -315,10 +315,10 @@  discard block
 block discarded – undo
315 315
 
316 316
 							if ( ! in_array( $field_type, array( 'section', 'divide', 'info', 'raw' ), true ) ) {
317 317
 								$field_id = $field_data['id'];
318
-								$default  = $core->options_defaults[ $field_id ] ?? '';
319
-								$data     = $core->options[ $field_id ] ?? $default;
318
+								$default  = $core->options_defaults[$field_id] ?? '';
319
+								$data     = $core->options[$field_id] ?? $default;
320 320
 
321
-								$this->hidden_perm_fields[ $field_id ] = $data;
321
+								$this->hidden_perm_fields[$field_id] = $data;
322 322
 							}
323 323
 						}
324 324
 
@@ -327,7 +327,7 @@  discard block
 block discarded – undo
327 327
 				}
328 328
 
329 329
 				if ( ! $display || ! function_exists( 'add_settings_section' ) ) {
330
-					$this->no_panel_section[ $k ] = $section;
330
+					$this->no_panel_section[$k] = $section;
331 331
 				} else {
332 332
 					add_settings_section(
333 333
 						$core->args['opt_name'] . $k . '_section',
@@ -351,11 +351,11 @@  discard block
 block discarded – undo
351 351
 							$field['type']                             = 'raw';
352 352
 							$field['content']                          = $field['desc'];
353 353
 							$field['desc']                             = '';
354
-							$core->sections[ $k ]['fields'][ $fieldk ] = $field;
354
+							$core->sections[$k]['fields'][$fieldk] = $field;
355 355
 						} elseif ( 'info' === $field['type'] ) {
356 356
 							if ( ! isset( $field['full_width'] ) ) {
357 357
 								$field['full_width']                       = true;
358
-								$core->sections[ $k ]['fields'][ $fieldk ] = $field;
358
+								$core->sections[$k]['fields'][$fieldk] = $field;
359 359
 							}
360 360
 						}
361 361
 
@@ -366,7 +366,7 @@  discard block
 block discarded – undo
366 366
 							} elseif ( ! isset( $field['full_width'] ) ) {
367 367
 								$field['full_width'] = true;
368 368
 							}
369
-							$core->sections[ $k ]['fields'][ $fieldk ] = $field;
369
+							$core->sections[$k]['fields'][$fieldk] = $field;
370 370
 						}
371 371
 
372 372
 						/**
@@ -378,9 +378,9 @@  discard block
 block discarded – undo
378 378
 						// phpcs:ignore WordPress.NamingConventions.ValidHookName
379 379
 						$field = apply_filters( "redux/options/{$core->args['opt_name']}/field/{$field['id']}/register", $field );
380 380
 
381
-						$core->field_types[ $field['type'] ] = $core->field_types[ $field['type'] ] ?? array();
381
+						$core->field_types[$field['type']] = $core->field_types[$field['type']] ?? array();
382 382
 
383
-						$core->field_sections[ $field['type'] ][ $field['id'] ] = $k;
383
+						$core->field_sections[$field['type']][$field['id']] = $k;
384 384
 
385 385
 						$display = true;
386 386
 
@@ -395,14 +395,14 @@  discard block
 block discarded – undo
395 395
 
396 396
 						if ( isset( $section['customizer'] ) ) {
397 397
 							$field['customizer']                       = $section['customizer'];
398
-							$core->sections[ $k ]['fields'][ $fieldk ] = $field;
398
+							$core->sections[$k]['fields'][$fieldk] = $field;
399 399
 						}
400 400
 
401 401
 						if ( isset( $field['permissions'] ) && false !== $field['permissions'] ) {
402 402
 							if ( ! Redux_Helpers::current_user_can( $field['permissions'] ) ) {
403
-								$data = $core->options[ $field['id'] ] ?? $core->options_defaults[ $field['id'] ];
403
+								$data = $core->options[$field['id']] ?? $core->options_defaults[$field['id']];
404 404
 
405
-								$this->hidden_perm_fields[ $field['id'] ] = $data;
405
+								$this->hidden_perm_fields[$field['id']] = $data;
406 406
 
407 407
 								continue;
408 408
 							}
@@ -436,79 +436,79 @@  discard block
 block discarded – undo
436 436
 						$field['name'] = $core->args['opt_name'] . '[' . $field['id'] . ']';
437 437
 
438 438
 						// Set the default value if present.
439
-						$core->options_defaults[ $field['id'] ] = $core->options_defaults[ $field['id'] ] ?? '';
439
+						$core->options_defaults[$field['id']] = $core->options_defaults[$field['id']] ?? '';
440 440
 
441 441
 						// Set the defaults to the value if not present.
442 442
 						$do_update = false;
443 443
 
444 444
 						// Check fields for values in the default parameter.
445
-						if ( ! isset( $core->options[ $field['id'] ] ) && isset( $field['default'] ) ) {
446
-							$core->options_defaults[ $field['id'] ] = $field['default'];
447
-							$core->options[ $field['id'] ]          = $field['default'];
445
+						if ( ! isset( $core->options[$field['id']] ) && isset( $field['default'] ) ) {
446
+							$core->options_defaults[$field['id']] = $field['default'];
447
+							$core->options[$field['id']]          = $field['default'];
448 448
 							$do_update                              = true;
449 449
 
450 450
 							// Check fields that hae no default value, but an option value with settings to
451 451
 							// be saved by default.
452
-						} elseif ( ! isset( $core->options[ $field['id'] ] ) && isset( $field['options'] ) ) {
452
+						} elseif ( ! isset( $core->options[$field['id']] ) && isset( $field['options'] ) ) {
453 453
 
454 454
 							// If a sorter field, check for options and save them as defaults.
455 455
 							if ( 'sorter' === $field['type'] || 'sortable' === $field['type'] ) {
456
-								$core->options_defaults[ $field['id'] ] = $field['options'];
457
-								$core->options[ $field['id'] ]          = $field['options'];
456
+								$core->options_defaults[$field['id']] = $field['options'];
457
+								$core->options[$field['id']]          = $field['options'];
458 458
 								$do_update                              = true;
459 459
 							}
460 460
 						}
461 461
 
462 462
 						// CORRECT URLS if media URLs are wrong, but attachment IDs are present.
463 463
 						if ( 'media' === $field['type'] ) {
464
-							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( 'http://', '', WP_CONTENT_URL ) ) === false ) {
465
-								$data = wp_get_attachment_url( $core->options[ $field['id'] ]['id'] );
464
+							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( 'http://', '', WP_CONTENT_URL ) ) === false ) {
465
+								$data = wp_get_attachment_url( $core->options[$field['id']]['id'] );
466 466
 
467 467
 								if ( isset( $data ) && ! empty( $data ) ) {
468
-									$core->options[ $field['id'] ]['url'] = $data;
468
+									$core->options[$field['id']]['url'] = $data;
469 469
 
470 470
 									$data = wp_get_attachment_image_src(
471
-										$core->options[ $field['id'] ]['id'],
471
+										$core->options[$field['id']]['id'],
472 472
 										array(
473 473
 											150,
474 474
 											150,
475 475
 										)
476 476
 									);
477 477
 
478
-									$core->options[ $field['id'] ]['thumbnail'] = $data[0];
478
+									$core->options[$field['id']]['thumbnail'] = $data[0];
479 479
 									$do_update                                  = true;
480 480
 								}
481 481
 							}
482 482
 						}
483 483
 
484 484
 						if ( 'background' === $field['type'] ) {
485
-							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( 'http://', 'https://' ), '', WP_CONTENT_URL ) ) === false ) {
486
-								$data = wp_get_attachment_url( $core->options[ $field['id'] ]['media']['id'] );
485
+							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( 'http://', 'https://' ), '', WP_CONTENT_URL ) ) === false ) {
486
+								$data = wp_get_attachment_url( $core->options[$field['id']]['media']['id'] );
487 487
 
488 488
 								if ( isset( $data ) && ! empty( $data ) ) {
489
-									$core->options[ $field['id'] ]['background-image'] = $data;
489
+									$core->options[$field['id']]['background-image'] = $data;
490 490
 
491 491
 									$data = wp_get_attachment_image_src(
492
-										$core->options[ $field['id'] ]['media']['id'],
492
+										$core->options[$field['id']]['media']['id'],
493 493
 										array(
494 494
 											150,
495 495
 											150,
496 496
 										)
497 497
 									);
498 498
 
499
-									$core->options[ $field['id'] ]['media']['thumbnail'] = $data[0];
499
+									$core->options[$field['id']]['media']['thumbnail'] = $data[0];
500 500
 									$do_update = true;
501 501
 								}
502 502
 							}
503 503
 						}
504 504
 
505 505
 						if ( 'slides' === $field['type'] ) {
506
-							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( 'http://', 'https://' ), '', WP_CONTENT_URL ) ) === false ) {
507
-								foreach ( $core->options[ $field['id'] ] as $key => $val ) {
506
+							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( 'http://', 'https://' ), '', WP_CONTENT_URL ) ) === false ) {
507
+								foreach ( $core->options[$field['id']] as $key => $val ) {
508 508
 									$data = wp_get_attachment_url( $val['attachment_id'] );
509 509
 
510 510
 									if ( isset( $data ) && ! empty( $data ) ) {
511
-										$core->options[ $field['id'] ][ $key ]['image'] = $data;
511
+										$core->options[$field['id']][$key]['image'] = $data;
512 512
 
513 513
 										$data = wp_get_attachment_image_src(
514 514
 											$val['attachment_id'],
@@ -518,7 +518,7 @@  discard block
 block discarded – undo
518 518
 											)
519 519
 										);
520 520
 
521
-										$core->options[ $field['id'] ][ $key ]['thumb'] = $data[0];
521
+										$core->options[$field['id']][$key]['thumb'] = $data[0];
522 522
 										$do_update                                      = true;
523 523
 									}
524 524
 								}
@@ -545,21 +545,21 @@  discard block
 block discarded – undo
545 545
 						$field = apply_filters( "redux/options/{$core->args['opt_name']}/field/{$field['id']}", $field );
546 546
 
547 547
 						if ( empty( $field ) ) {
548
-							unset( $core->sections[ $k ]['fields'][ $fieldk ] );
548
+							unset( $core->sections[$k]['fields'][$fieldk] );
549 549
 							continue;
550 550
 						}
551 551
 
552
-						if ( ! empty( Redux_Core::$folds[ $field['id'] ]['parent'] ) ) { // This has some fold items, hide it by default.
552
+						if ( ! empty( Redux_Core::$folds[$field['id']]['parent'] ) ) { // This has some fold items, hide it by default.
553 553
 							$field['class'] .= ' fold';
554 554
 						}
555 555
 
556
-						if ( ! empty( Redux_Core::$folds[ $field['id'] ]['children'] ) ) { // Sets the values you shoe fold children on.
556
+						if ( ! empty( Redux_Core::$folds[$field['id']]['children'] ) ) { // Sets the values you shoe fold children on.
557 557
 							$field['class'] .= ' fold-parent';
558 558
 						}
559 559
 
560 560
 						if ( ! empty( $field['compiler'] ) ) {
561 561
 							$field['class']                       .= ' compiler';
562
-							$core->compiler_fields[ $field['id'] ] = 1;
562
+							$core->compiler_fields[$field['id']] = 1;
563 563
 						}
564 564
 
565 565
 						if ( isset( $field['unit'] ) && ! isset( $field['units'] ) ) {
@@ -567,11 +567,11 @@  discard block
 block discarded – undo
567 567
 							unset( $field['unit'] );
568 568
 						}
569 569
 
570
-						$core->sections[ $k ]['fields'][ $fieldk ] = $field;
570
+						$core->sections[$k]['fields'][$fieldk] = $field;
571 571
 
572 572
 						if ( isset( $core->args['display_source'] ) ) {
573 573
 							// phpcs:ignore WordPress.PHP.DevelopmentFunctions
574
-							$th .= '<div id="' . $field['id'] . '-settings" style="display:none;"><pre>' . var_export( $core->sections[ $k ]['fields'][ $fieldk ], true ) . '</pre></div>';
574
+							$th .= '<div id="' . $field['id'] . '-settings" style="display:none;"><pre>' . var_export( $core->sections[$k]['fields'][$fieldk], true ) . '</pre></div>';
575 575
 							$th .= '<br /><a href="#TB_inline?width=600&height=800&inlineId=' . $field['id'] . '-settings" class="thickbox"><small>View Source</small></a>';
576 576
 						}
577 577
 
@@ -583,9 +583,9 @@  discard block
 block discarded – undo
583 583
 						do_action( "redux/options/{$core->args['opt_name']}/field/{$field['type']}/register", $field );
584 584
 
585 585
 						$core->required_class->check_dependencies( $field );
586
-						$core->field_head[ $field['id'] ] = $th;
586
+						$core->field_head[$field['id']] = $th;
587 587
 
588
-						if ( ! $display || isset( $this->no_panel_section[ $k ] ) ) {
588
+						if ( ! $display || isset( $this->no_panel_section[$k] ) ) {
589 589
 							$this->no_panel[] = $field['id'];
590 590
 						} else {
591 591
 							if ( isset( $field['disabled'] ) && $field['disabled'] ) {
@@ -718,7 +718,7 @@  discard block
 block discarded – undo
718 718
 			if ( isset( $plugin_options['redux-no_panel'] ) ) {
719 719
 				$keys = explode( '|', $plugin_options['redux-no_panel'] );
720 720
 				foreach ( $keys as $key ) {
721
-					$plugin_options[ $key ] = $core->options[ $key ];
721
+					$plugin_options[$key] = $core->options[$key];
722 722
 				}
723 723
 				if ( isset( $plugin_options['redux-no_panel'] ) ) {
724 724
 					unset( $plugin_options['redux-no_panel'] );
@@ -727,7 +727,7 @@  discard block
 block discarded – undo
727 727
 
728 728
 			if ( is_array( $this->hidden_perm_fields ) && ! empty( $this->hidden_perm_fields ) ) {
729 729
 				foreach ( $this->hidden_perm_fields as $id => $data ) {
730
-					$plugin_options[ $id ] = $data;
730
+					$plugin_options[$id] = $data;
731 731
 				}
732 732
 			}
733 733
 
@@ -755,9 +755,9 @@  discard block
 block discarded – undo
755 755
 			if ( is_array( $imported_options ) && ! empty( $imported_options ) && isset( $imported_options['redux-backup'] ) && ( 1 === $imported_options['redux-backup'] || '1' === $imported_options['redux-backup'] ) ) {
756 756
 				$core->transients['changed_values'] = array();
757 757
 				foreach ( $plugin_options as $key => $value ) {
758
-					if ( isset( $imported_options[ $key ] ) && $value !== $imported_options[ $key ] ) {
759
-						$plugin_options[ $key ]                     = $value;
760
-						$core->transients['changed_values'][ $key ] = $value;
758
+					if ( isset( $imported_options[$key] ) && $value !== $imported_options[$key] ) {
759
+						$plugin_options[$key]                     = $value;
760
+						$core->transients['changed_values'][$key] = $value;
761 761
 					}
762 762
 				}
763 763
 
@@ -778,7 +778,7 @@  discard block
 block discarded – undo
778 778
 				);
779 779
 
780 780
 				setcookie( 'redux_current_tab_' . $core->args['opt_name'], '', 1, '/', $time + 1000, '/' );
781
-				$_COOKIE[ 'redux_current_tab_' . $core->args['opt_name'] ] = 1;
781
+				$_COOKIE['redux_current_tab_' . $core->args['opt_name']] = 1;
782 782
 
783 783
 				unset( $plugin_options['defaults'], $plugin_options['compiler'], $plugin_options['import'], $plugin_options['import_code'] );
784 784
 				if ( in_array( $core->args['database'], array( 'transient', 'theme_mods', 'theme_mods_expanded', 'network' ), true ) ) {
@@ -816,8 +816,8 @@  discard block
 block discarded – undo
816 816
 				}
817 817
 
818 818
 				foreach ( $core->options as $key => $value ) {
819
-					if ( isset( $plugin_options[ $key ] ) && $plugin_options[ $key ] !== $value ) {
820
-						$core->transients['changed_values'][ $key ] = $value;
819
+					if ( isset( $plugin_options[$key] ) && $plugin_options[$key] !== $value ) {
820
+						$core->transients['changed_values'][$key] = $value;
821 821
 					}
822 822
 				}
823 823
 
@@ -831,21 +831,21 @@  discard block
 block discarded – undo
831 831
 
832 832
 			// Section reset to default.
833 833
 			if ( ! empty( $plugin_options['defaults-section'] ) ) {
834
-				if ( isset( $plugin_options['redux-section'] ) && isset( $core->sections[ $plugin_options['redux-section'] ]['fields'] ) ) {
834
+				if ( isset( $plugin_options['redux-section'] ) && isset( $core->sections[$plugin_options['redux-section']]['fields'] ) ) {
835 835
 					if ( empty( $core->options_defaults ) ) {
836 836
 						$core->options_defaults = $core->_default_values();
837 837
 					}
838 838
 
839
-					foreach ( $core->sections[ $plugin_options['redux-section'] ]['fields'] as $field ) {
839
+					foreach ( $core->sections[$plugin_options['redux-section']]['fields'] as $field ) {
840 840
 						if ( 'tabbed' === $field['type'] ) {
841 841
 							if ( ! empty( $field['tabs'] ) ) {
842 842
 								foreach ( $field['tabs'] as $val ) {
843 843
 									if ( ! empty( $val['fields'] ) ) {
844 844
 										foreach ( $val['fields'] as $f ) {
845
-											if ( isset( $core->options_defaults[ $f['id'] ] ) ) {
846
-												$plugin_options[ $f['id'] ] = $core->options_defaults[ $f['id'] ];
845
+											if ( isset( $core->options_defaults[$f['id']] ) ) {
846
+												$plugin_options[$f['id']] = $core->options_defaults[$f['id']];
847 847
 											} else {
848
-												$plugin_options[ $f['id'] ] = '';
848
+												$plugin_options[$f['id']] = '';
849 849
 											}
850 850
 										}
851 851
 									}
@@ -854,18 +854,18 @@  discard block
 block discarded – undo
854 854
 						} elseif ( 'repeater' === $field['type'] ) {
855 855
 							if ( ! empty( $field['fields'] ) ) {
856 856
 								foreach ( $field['fields'] as $f ) {
857
-									if ( isset( $core->options_defaults[ $f['id'] ] ) ) {
858
-										$plugin_options[ $f['id'] ] = $core->options_defaults[ $f['id'] ];
857
+									if ( isset( $core->options_defaults[$f['id']] ) ) {
858
+										$plugin_options[$f['id']] = $core->options_defaults[$f['id']];
859 859
 									} else {
860
-										$plugin_options[ $f['id'] ] = '';
860
+										$plugin_options[$f['id']] = '';
861 861
 									}
862 862
 								}
863 863
 							}
864 864
 						} else {
865
-							if ( isset( $core->options_defaults[ $field['id'] ] ) ) {
866
-								$plugin_options[ $field['id'] ] = $core->options_defaults[ $field['id'] ];
865
+							if ( isset( $core->options_defaults[$field['id']] ) ) {
866
+								$plugin_options[$field['id']] = $core->options_defaults[$field['id']];
867 867
 							} else {
868
-								$plugin_options[ $field['id'] ] = '';
868
+								$plugin_options[$field['id']] = '';
869 869
 							}
870 870
 						}
871 871
 
@@ -887,8 +887,8 @@  discard block
 block discarded – undo
887 887
 				$core->transients['changed_values'] = array();
888 888
 
889 889
 				foreach ( $core->options as $key => $value ) {
890
-					if ( isset( $plugin_options[ $key ] ) && $plugin_options[ $key ] !== $value ) {
891
-						$core->transients['changed_values'][ $key ] = $value;
890
+					if ( isset( $plugin_options[$key] ) && $plugin_options[$key] !== $value ) {
891
+						$core->transients['changed_values'][$key] = $value;
892 892
 					}
893 893
 				}
894 894
 
@@ -962,8 +962,8 @@  discard block
 block discarded – undo
962 962
 
963 963
 			if ( ! empty( $core->options ) ) {
964 964
 				foreach ( $core->options as $key => $value ) {
965
-					if ( isset( $plugin_options[ $key ] ) && $plugin_options[ $key ] !== $value ) {
966
-						$core->transients['changed_values'][ $key ] = $value;
965
+					if ( isset( $plugin_options[$key] ) && $plugin_options[$key] !== $value ) {
966
+						$core->transients['changed_values'][$key] = $value;
967 967
 					}
968 968
 				}
969 969
 			}
@@ -1003,7 +1003,7 @@  discard block
 block discarded – undo
1003 1003
 					$this->default_values(); // fill cache.
1004 1004
 				}
1005 1005
 
1006
-				return array_key_exists( $opt_name, $this->options_defaults ) ? $this->options_defaults[ $opt_name ] : $defaults;
1006
+				return array_key_exists( $opt_name, $this->options_defaults ) ? $this->options_defaults[$opt_name] : $defaults;
1007 1007
 			}
1008 1008
 
1009 1009
 			return '';
@@ -1027,11 +1027,11 @@  discard block
 block discarded – undo
1027 1027
 			$defaults = $this->options_defaults;
1028 1028
 			$value    = '';
1029 1029
 
1030
-			if ( isset( $defaults[ $key ] ) ) {
1031
-				if ( false !== $array_key && isset( $defaults[ $key ][ $array_key ] ) ) {
1032
-					$value = $defaults[ $key ][ $array_key ];
1030
+			if ( isset( $defaults[$key] ) ) {
1031
+				if ( false !== $array_key && isset( $defaults[$key][$array_key] ) ) {
1032
+					$value = $defaults[$key][$array_key];
1033 1033
 				} else {
1034
-					$value = $defaults[ $key ];
1034
+					$value = $defaults[$key];
1035 1035
 				}
1036 1036
 			}
1037 1037
 
Please login to merge, or discard this patch.
Indentation   +1030 added lines, -1030 removed lines patch added patch discarded remove patch
@@ -12,1034 +12,1034 @@
 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
-							$options_values[ $field['id'] ] = apply_filters( 'wpml_object_id', $options_values[ $field['id'] ], $field['data'], true );
81
-						}
82
-					}
83
-				} elseif ( is_array( $section ) && ! empty( $section ) ) {
84
-					$this->translate_data_field_recursive( $section, $options_values );
85
-				}
86
-			}
87
-		}
88
-
89
-		/**
90
-		 * Retrieves the options.
91
-		 */
92
-		public function get() {
93
-			$core = $this->core();
94
-
95
-			$defaults = false;
96
-
97
-			if ( ! empty( $core->defaults ) ) {
98
-				$defaults = $core->defaults;
99
-			}
100
-
101
-			if ( empty( $core->args ) ) {
102
-				return;
103
-			}
104
-
105
-			switch ( $core->args['database'] ) {
106
-				case 'transient':
107
-					$result = get_transient( $core->args['opt_name'] . '-transient' );
108
-					break;
109
-				case 'theme_mods':
110
-					$result = get_theme_mod( $core->args['opt_name'] . '-mods' );
111
-					break;
112
-				case 'theme_mods_expanded':
113
-					$result = get_theme_mods();
114
-					break;
115
-				case 'network':
116
-					$result = get_site_option( $core->args['opt_name'], array() );
117
-					break;
118
-				default:
119
-					$result = get_option( $core->args['opt_name'], array() );
120
-
121
-			}
122
-
123
-			if ( ! is_array( $result ) ) {
124
-				return;
125
-			}
126
-
127
-			if ( empty( $result ) && empty( $defaults ) ) {
128
-				return;
129
-			}
130
-
131
-			if ( empty( $result ) && ! empty( $defaults ) ) {
132
-				$results = $defaults;
133
-				$this->set( $results );
134
-			} else {
135
-				$core->options = $result;
136
-			}
137
-
138
-			// Don't iterate unnecessarily.
139
-			if ( has_filter( 'wpml_object_id' ) ) {
140
-				$this->translate_data_field_recursive( $core->sections, $core->options );
141
-			}
142
-
143
-			/**
144
-			 * Action 'redux/options/{opt_name}/options'
145
-			 *
146
-			 * @param mixed $value option values
147
-			 */
148
-
149
-			// phpcs:ignore WordPress.NamingConventions.ValidHookName
150
-			$core->options = apply_filters( "redux/options/{$core->args['opt_name']}/options", $core->options, $core->sections );
151
-
152
-			// Get transient values.
153
-			$core->transient_class->get();
154
-
155
-			// Set a global variable by the global_variable argument.
156
-			$this->set_global_variable( $core );
157
-		}
158
-
159
-		/**
160
-		 * ->set_options(); This is used to set an arbitrary option in the option array
161
-		 *
162
-		 * @since ReduxFramework 3.0.0
163
-		 *
164
-		 * @param string|array $value the value of the option being added.
165
-		 */
166
-		public function set( $value = '' ) {
167
-			$core = $this->core();
168
-
169
-			$core->transients['last_save'] = time();
170
-
171
-			if ( ! empty( $value ) ) {
172
-				switch ( $core->args['database'] ) {
173
-					case 'transient':
174
-						set_transient( $core->args['opt_name'] . '-transient', $value, $core->args['transient_time'] );
175
-						break;
176
-					case 'theme_mods':
177
-						set_theme_mod( $core->args['opt_name'] . '-mods', $value );
178
-						break;
179
-					case 'theme_mods_expanded':
180
-						foreach ( $value as $k => $v ) {
181
-							set_theme_mod( $k, $v );
182
-						}
183
-						break;
184
-					case 'network':
185
-						update_site_option( $core->args['opt_name'], $value );
186
-						break;
187
-					default:
188
-						update_option( $core->args['opt_name'], $value );
189
-
190
-				}
191
-
192
-				// Store the changed values in the transient.
193
-				if ( $value !== $core->options ) {
194
-					foreach ( $value as $k => $v ) {
195
-						if ( ! isset( $core->options[ $k ] ) ) {
196
-							$core->options[ $k ] = '';
197
-						} elseif ( $v === $core->options[ $k ] ) {
198
-							unset( $core->options[ $k ] );
199
-						}
200
-					}
201
-
202
-					$core->transients['changed_values'] = $core->options;
203
-				}
204
-
205
-				$core->options = $value;
206
-
207
-				// Set a global variable by the global_variable argument.
208
-				$this->set_global_variable( $core );
209
-
210
-				// Saving the transient values.
211
-				$core->transient_class->set();
212
-			}
213
-		}
214
-
215
-		/**
216
-		 * Set a global variable by the global_variable argument
217
-		 *
218
-		 * @param null|ReduxFramework $core ReduxFramework core object.
219
-		 *
220
-		 * @return  void          (global was set)
221
-		 * @since   3.1.5
222
-		 */
223
-		private function set_global_variable( ?ReduxFramework $core ): void {
224
-			if ( ! empty( $core->args['global_variable'] ) ) {
225
-				$options_global = $core->args['global_variable'];
226
-
227
-				/**
228
-				 * Filter 'redux/options/{opt_name}/global_variable'
229
-				 *
230
-				 * @param array $value option value to set global_variable with
231
-				 */
232
-
233
-				// phpcs:ignore WordPress.NamingConventions.ValidHookName
234
-				$GLOBALS[ $options_global ] = apply_filters( "redux/options/{$core->args['opt_name']}/global_variable", $core->options );
235
-			}
236
-		}
237
-
238
-		/**
239
-		 * Register Option for use
240
-		 *
241
-		 * @return void
242
-		 * @throws ReflectionException Exception.
243
-		 * @since  1.0.0
244
-		 * @access public
245
-		 */
246
-		public function register() {
247
-			$core = $this->core();
248
-
249
-			if ( ! is_object( $core ) ) {
250
-				return;
251
-			}
252
-
253
-			if ( true === $core->args['options_api'] ) {
254
-				register_setting(
255
-					$core->args['opt_name'] . '_group',
256
-					$core->args['opt_name'],
257
-					array(
258
-						$this,
259
-						'validate_options',
260
-					)
261
-				);
262
-			}
263
-
264
-			if ( is_null( $core->sections ) ) {
265
-				return;
266
-			}
267
-
268
-			if ( empty( $core->options_defaults ) ) {
269
-				$core->options_defaults = $core->default_values();
270
-			}
271
-
272
-			$run_update = false;
273
-
274
-			foreach ( $core->sections as $k => $section ) {
275
-				if ( isset( $section['type'] ) && 'divide' === $section['type'] ) {
276
-					continue;
277
-				}
278
-
279
-				$display = true;
280
-
281
-				if ( isset( $_GET['page'] ) && $_GET['page'] === $core->args['page_slug'] ) { // phpcs:ignore WordPress.Security.NonceVerification
282
-					if ( isset( $section['panel'] ) && false === $section['panel'] ) {
283
-						$display = false;
284
-					}
285
-				}
286
-
287
-				/**
288
-				 * Filter 'redux/options/{opt_name}/section/{section.id}'
289
-				 *
290
-				 * @param array $section section configuration
291
-				 */
292
-				if ( isset( $section['id'] ) ) {
293
-					// phpcs:ignore WordPress.NamingConventions.ValidHookName
294
-					$section = apply_filters( "redux/options/{$core->args['opt_name']}/section/{$section['id']}", $section );
295
-				}
296
-
297
-				if ( empty( $section ) ) {
298
-					unset( $core->sections[ $k ] );
299
-					continue;
300
-				}
301
-
302
-				if ( ! isset( $section['title'] ) ) {
303
-					$section['title'] = '';
304
-				}
305
-
306
-				if ( isset( $section['customizer_only'] ) && true === $section['customizer_only'] ) {
307
-					$section['panel']     = false;
308
-					$core->sections[ $k ] = $section;
309
-				}
310
-
311
-				$heading = $section['heading'] ?? $section['title'];
312
-
313
-				if ( isset( $section['permissions'] ) && false !== $section['permissions'] ) {
314
-					if ( ! Redux_Helpers::current_user_can( $section['permissions'] ) ) {
315
-						$core->hidden_perm_sections[] = $section['title'];
316
-
317
-						foreach ( $section['fields'] as $field_data ) {
318
-							$field_type = $field_data['type'];
319
-
320
-							if ( ! in_array( $field_type, array( 'section', 'divide', 'info', 'raw' ), true ) ) {
321
-								$field_id = $field_data['id'];
322
-								$default  = $core->options_defaults[ $field_id ] ?? '';
323
-								$data     = $core->options[ $field_id ] ?? $default;
324
-
325
-								$this->hidden_perm_fields[ $field_id ] = $data;
326
-							}
327
-						}
328
-
329
-						continue;
330
-					}
331
-				}
332
-
333
-				if ( ! $display || ! function_exists( 'add_settings_section' ) ) {
334
-					$this->no_panel_section[ $k ] = $section;
335
-				} else {
336
-					add_settings_section(
337
-						$core->args['opt_name'] . $k . '_section',
338
-						$heading,
339
-						array(
340
-							$core->render_class,
341
-							'section_desc',
342
-						),
343
-						$core->args['opt_name'] . $k . '_section_group'
344
-					);
345
-				}
346
-
347
-				$section_ident = false;
348
-				if ( isset( $section['fields'] ) ) {
349
-					foreach ( $section['fields'] as $fieldk => $field ) {
350
-						if ( ! isset( $field['type'] ) ) {
351
-							continue; // You need a type!
352
-						}
353
-
354
-						if ( 'info' === $field['type'] && isset( $field['raw_html'] ) && true === $field['raw_html'] ) {
355
-							$field['type']                             = 'raw';
356
-							$field['content']                          = $field['desc'];
357
-							$field['desc']                             = '';
358
-							$core->sections[ $k ]['fields'][ $fieldk ] = $field;
359
-						} elseif ( 'info' === $field['type'] ) {
360
-							if ( ! isset( $field['full_width'] ) ) {
361
-								$field['full_width']                       = true;
362
-								$core->sections[ $k ]['fields'][ $fieldk ] = $field;
363
-							}
364
-						}
365
-
366
-						if ( 'raw' === $field['type'] ) {
367
-							if ( isset( $field['align'] ) ) {
368
-								$field['full_width'] = ! $field['align'];
369
-								unset( $field['align'] );
370
-							} elseif ( ! isset( $field['full_width'] ) ) {
371
-								$field['full_width'] = true;
372
-							}
373
-							$core->sections[ $k ]['fields'][ $fieldk ] = $field;
374
-						}
375
-
376
-						/**
377
-						 * Filter 'redux/options/{opt_name}/field/{field.id}'
378
-						 *
379
-						 * @param array $field field config
380
-						 */
381
-
382
-						// phpcs:ignore WordPress.NamingConventions.ValidHookName
383
-						$field = apply_filters( "redux/options/{$core->args['opt_name']}/field/{$field['id']}/register", $field );
384
-
385
-						$core->field_types[ $field['type'] ] = $core->field_types[ $field['type'] ] ?? array();
386
-
387
-						$core->field_sections[ $field['type'] ][ $field['id'] ] = $k;
388
-
389
-						$display = true;
390
-
391
-						if ( isset( $_GET['page'] ) && $core->args['page_slug'] === $_GET['page'] ) { // phpcs:ignore WordPress.Security.NonceVerification
392
-							if ( isset( $field['panel'] ) && false === $field['panel'] ) {
393
-								$display = false;
394
-							}
395
-						}
396
-						if ( isset( $field['customizer_only'] ) && true === $field['customizer_only'] ) {
397
-							$display = false;
398
-						}
399
-
400
-						if ( isset( $section['customizer'] ) ) {
401
-							$field['customizer']                       = $section['customizer'];
402
-							$core->sections[ $k ]['fields'][ $fieldk ] = $field;
403
-						}
404
-
405
-						if ( isset( $field['permissions'] ) && false !== $field['permissions'] ) {
406
-							if ( ! Redux_Helpers::current_user_can( $field['permissions'] ) ) {
407
-								$data = $core->options[ $field['id'] ] ?? $core->options_defaults[ $field['id'] ];
408
-
409
-								$this->hidden_perm_fields[ $field['id'] ] = $data;
410
-
411
-								continue;
412
-							}
413
-						}
414
-
415
-						if ( ! isset( $field['id'] ) ) {
416
-							echo '<br /><h3>No field ID is set.</h3><pre>';
417
-
418
-							// phpcs:ignore WordPress.PHP.DevelopmentFunctions
419
-							print_r( $field );
420
-
421
-							echo '</pre><br />';
422
-
423
-							continue;
424
-						}
425
-
426
-						if ( isset( $field['type'] ) && 'section' === $field['type'] ) {
427
-							if ( isset( $field['indent'] ) && true === $field['indent'] ) {
428
-								$section_ident = true;
429
-							} else {
430
-								$section_ident = false;
431
-							}
432
-						}
433
-
434
-						if ( isset( $field['type'] ) && 'info' === $field['type'] && $section_ident ) {
435
-							$field['indent'] = true;
436
-						}
437
-
438
-						$th = $core->render_class->get_header_html( $field );
439
-
440
-						$field['name'] = $core->args['opt_name'] . '[' . $field['id'] . ']';
441
-
442
-						// Set the default value if present.
443
-						$core->options_defaults[ $field['id'] ] = $core->options_defaults[ $field['id'] ] ?? '';
444
-
445
-						// Set the defaults to the value if not present.
446
-						$do_update = false;
447
-
448
-						// Check fields for values in the default parameter.
449
-						if ( ! isset( $core->options[ $field['id'] ] ) && isset( $field['default'] ) ) {
450
-							$core->options_defaults[ $field['id'] ] = $field['default'];
451
-							$core->options[ $field['id'] ]          = $field['default'];
452
-							$do_update                              = true;
453
-
454
-							// Check fields that hae no default value, but an option value with settings to
455
-							// be saved by default.
456
-						} elseif ( ! isset( $core->options[ $field['id'] ] ) && isset( $field['options'] ) ) {
457
-
458
-							// If a sorter field, check for options and save them as defaults.
459
-							if ( 'sorter' === $field['type'] || 'sortable' === $field['type'] ) {
460
-								$core->options_defaults[ $field['id'] ] = $field['options'];
461
-								$core->options[ $field['id'] ]          = $field['options'];
462
-								$do_update                              = true;
463
-							}
464
-						}
465
-
466
-						// CORRECT URLS if media URLs are wrong, but attachment IDs are present.
467
-						if ( 'media' === $field['type'] ) {
468
-							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( 'http://', '', WP_CONTENT_URL ) ) === false ) {
469
-								$data = wp_get_attachment_url( $core->options[ $field['id'] ]['id'] );
470
-
471
-								if ( isset( $data ) && ! empty( $data ) ) {
472
-									$core->options[ $field['id'] ]['url'] = $data;
473
-
474
-									$data = wp_get_attachment_image_src(
475
-										$core->options[ $field['id'] ]['id'],
476
-										array(
477
-											150,
478
-											150,
479
-										)
480
-									);
481
-
482
-									$core->options[ $field['id'] ]['thumbnail'] = $data[0];
483
-									$do_update                                  = true;
484
-								}
485
-							}
486
-						}
487
-
488
-						if ( 'background' === $field['type'] ) {
489
-							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( 'http://', 'https://' ), '', WP_CONTENT_URL ) ) === false ) {
490
-								$data = wp_get_attachment_url( $core->options[ $field['id'] ]['media']['id'] );
491
-
492
-								if ( isset( $data ) && ! empty( $data ) ) {
493
-									$core->options[ $field['id'] ]['background-image'] = $data;
494
-
495
-									$data = wp_get_attachment_image_src(
496
-										$core->options[ $field['id'] ]['media']['id'],
497
-										array(
498
-											150,
499
-											150,
500
-										)
501
-									);
502
-
503
-									$core->options[ $field['id'] ]['media']['thumbnail'] = $data[0];
504
-									$do_update = true;
505
-								}
506
-							}
507
-						}
508
-
509
-						if ( 'slides' === $field['type'] ) {
510
-							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( 'http://', 'https://' ), '', WP_CONTENT_URL ) ) === false ) {
511
-								foreach ( $core->options[ $field['id'] ] as $key => $val ) {
512
-									$data = wp_get_attachment_url( $val['attachment_id'] );
513
-
514
-									if ( isset( $data ) && ! empty( $data ) ) {
515
-										$core->options[ $field['id'] ][ $key ]['image'] = $data;
516
-
517
-										$data = wp_get_attachment_image_src(
518
-											$val['attachment_id'],
519
-											array(
520
-												150,
521
-												150,
522
-											)
523
-										);
524
-
525
-										$core->options[ $field['id'] ][ $key ]['thumb'] = $data[0];
526
-										$do_update                                      = true;
527
-									}
528
-								}
529
-							}
530
-						}
531
-						// END -> CORRECT URLS if media URLs are wrong, but attachment IDs are present.
532
-						if ( true === $do_update && ! isset( $core->never_save_to_db ) ) {
533
-							if ( $core->args['save_defaults'] ) { // Only save that to the DB if allowed to.
534
-								$run_update = true;
535
-							}
536
-						}
537
-
538
-						if ( ! isset( $field['class'] ) ) { // No errors, please.
539
-							$field['class'] = '';
540
-						}
541
-
542
-						/**
543
-						 * Filter 'redux/options/{opt_name}/field/{field.id}'.
544
-						 *
545
-						 * @param array $field field config
546
-						 */
547
-
548
-						// phpcs:ignore WordPress.NamingConventions.ValidHookName
549
-						$field = apply_filters( "redux/options/{$core->args['opt_name']}/field/{$field['id']}", $field );
550
-
551
-						if ( empty( $field ) ) {
552
-							unset( $core->sections[ $k ]['fields'][ $fieldk ] );
553
-							continue;
554
-						}
555
-
556
-						if ( ! empty( Redux_Core::$folds[ $field['id'] ]['parent'] ) ) { // This has some fold items, hide it by default.
557
-							$field['class'] .= ' fold';
558
-						}
559
-
560
-						if ( ! empty( Redux_Core::$folds[ $field['id'] ]['children'] ) ) { // Sets the values you shoe fold children on.
561
-							$field['class'] .= ' fold-parent';
562
-						}
563
-
564
-						if ( ! empty( $field['compiler'] ) ) {
565
-							$field['class']                       .= ' compiler';
566
-							$core->compiler_fields[ $field['id'] ] = 1;
567
-						}
568
-
569
-						if ( isset( $field['unit'] ) && ! isset( $field['units'] ) ) {
570
-							$field['units'] = $field['unit'];
571
-							unset( $field['unit'] );
572
-						}
573
-
574
-						$core->sections[ $k ]['fields'][ $fieldk ] = $field;
575
-
576
-						if ( isset( $core->args['display_source'] ) ) {
577
-							// phpcs:ignore WordPress.PHP.DevelopmentFunctions
578
-							$th .= '<div id="' . $field['id'] . '-settings" style="display:none;"><pre>' . var_export( $core->sections[ $k ]['fields'][ $fieldk ], true ) . '</pre></div>';
579
-							$th .= '<br /><a href="#TB_inline?width=600&height=800&inlineId=' . $field['id'] . '-settings" class="thickbox"><small>View Source</small></a>';
580
-						}
581
-
582
-						/**
583
-						 * Action 'redux/options/{opt_name}/field/{field.type}/register'
584
-						 */
585
-
586
-						// phpcs:ignore WordPress.NamingConventions.ValidHookName
587
-						do_action( "redux/options/{$core->args['opt_name']}/field/{$field['type']}/register", $field );
588
-
589
-						$core->required_class->check_dependencies( $field );
590
-						$core->field_head[ $field['id'] ] = $th;
591
-
592
-						if ( ! $display || isset( $this->no_panel_section[ $k ] ) ) {
593
-							$this->no_panel[] = $field['id'];
594
-						} else {
595
-							if ( isset( $field['disabled'] ) && $field['disabled'] ) {
596
-								$field['class'] .= ' redux_disable_field';
597
-							}
598
-
599
-							if ( isset( $field['hidden'] ) && $field['hidden'] ) {
600
-								$field['class'] .= ' redux_hide_field';
601
-							}
602
-
603
-							if ( true === $core->args['options_api'] ) {
604
-								add_settings_field(
605
-									"{$fieldk}_field",
606
-									$th,
607
-									array(
608
-										$core->render_class,
609
-										'field_input',
610
-									),
611
-									"{$core->args['opt_name']}{$k}_section_group",
612
-									"{$core->args['opt_name']}{$k}_section",
613
-									$field
614
-								);
615
-							}
616
-						}
617
-					}
618
-				}
619
-			}
620
-
621
-			/**
622
-			 * Action 'redux/options/{opt_name}/register'
623
-			 *
624
-			 * @param array $section Option sections
625
-			 */
626
-
627
-			// phpcs:ignore WordPress.NamingConventions.ValidHookName
628
-			do_action( "redux/options/{$core->args['opt_name']}/register", $core->sections );
629
-
630
-			if ( $run_update && ! isset( $core->never_save_to_db ) ) { // Always update the DB with new fields.
631
-				$this->set( $core->options );
632
-			}
633
-
634
-			if ( isset( $core->transients['run_compiler'] ) && $core->transients['run_compiler'] ) {
635
-
636
-				Redux_Core::$no_output = true;
637
-				$temp                  = $core->args['output_variables_prefix'];
638
-
639
-				// Allow the override of variable's prefix for use by SCSS or LESS.
640
-				if ( isset( $core->args['compiler_output_variables_prefix'] ) ) {
641
-					$core->args['output_variables_prefix'] = $core->args['compiler_output_variables_prefix'];
642
-				}
643
-				$core->output_class->enqueue();
644
-				$core->args['output_variables_prefix'] = $temp;
645
-
646
-				// phpcs:ignore WordPress.NamingConventions.ValidVariableName
647
-				$compiler_css = $core->compilerCSS;
648
-
649
-				/**
650
-				 * Action 'redux/options/{opt_name}/compiler'
651
-				 *
652
-				 * @param array  $options Options.
653
-				 * @param string $css CSS that get sent to the compiler hook.
654
-				 * @param array  $changed_values Changed values.
655
-				 * @param array  $output_variables Output variables.
656
-				 */
657
-
658
-				// phpcs:ignore WordPress.NamingConventions.ValidHookName
659
-				do_action( "redux/options/{$core->args['opt_name']}/compiler", $core->options, $compiler_css, $core->transients['changed_values'], $core->output_variables );
660
-
661
-				/**
662
-				 * Action 'redux/options/{opt_name}/compiler/advanced'
663
-				 *
664
-				 * @param object $redux ReduxFramework object.
665
-				 */
666
-
667
-				// phpcs:ignore WordPress.NamingConventions.ValidHookName
668
-				do_action( "redux/options/{$core->args['opt_name']}/compiler/advanced", $core );
669
-
670
-				unset( $core->transients['run_compiler'] );
671
-				$core->transient_class->set();
672
-			}
673
-		}
674
-
675
-		/**
676
-		 * Get default options into an array suitable for the settings API
677
-		 *
678
-		 * @since       1.0.0
679
-		 * @access      public
680
-		 * @return      array $this->options_defaults
681
-		 */
682
-		public function default_values(): array {
683
-			$core = $this->core();
684
-
685
-			if ( ! is_null( $core->sections ) && is_null( $core->options_defaults ) ) {
686
-				$core->options_defaults = $core->options_defaults_class->default_values( $core->args['opt_name'], $core->sections, $core->wordpress_data );
687
-			}
688
-
689
-			/**
690
-			 * Filter 'redux/options/{opt_name}/defaults'
691
-			 *
692
-			 * @param array $defaults option default values
693
-			 */
694
-
695
-			$core->transients['changed_values'] = $core->transients['changed_values'] ?? array();
696
-
697
-			// phpcs:ignore WordPress.NamingConventions.ValidHookName
698
-			$core->options_defaults = apply_filters( "redux/options/{$core->args['opt_name']}/defaults", $core->options_defaults, $core->transients['changed_values'] );
699
-
700
-			return $core->options_defaults;
701
-		}
702
-
703
-		/**
704
-		 * Validate the Options before insertion
705
-		 *
706
-		 * @param  array $plugin_options The option array.
707
-		 *
708
-		 * @return array|mixed|string
709
-		 * @since  3.0.0
710
-		 * @access public
711
-		 */
712
-		public function validate_options( array $plugin_options ) {
713
-			$core = $this->core();
714
-
715
-			if ( true === Redux_Core::$validation_ran ) {
716
-				return $plugin_options;
717
-			}
718
-
719
-			Redux_Core::$validation_ran = true;
720
-
721
-			// Save the values not in the panel.
722
-			if ( isset( $plugin_options['redux-no_panel'] ) ) {
723
-				$keys = explode( '|', $plugin_options['redux-no_panel'] );
724
-				foreach ( $keys as $key ) {
725
-					$plugin_options[ $key ] = $core->options[ $key ];
726
-				}
727
-				if ( isset( $plugin_options['redux-no_panel'] ) ) {
728
-					unset( $plugin_options['redux-no_panel'] );
729
-				}
730
-			}
731
-
732
-			if ( is_array( $this->hidden_perm_fields ) && ! empty( $this->hidden_perm_fields ) ) {
733
-				foreach ( $this->hidden_perm_fields as $id => $data ) {
734
-					$plugin_options[ $id ] = $data;
735
-				}
736
-			}
737
-
738
-			if ( $plugin_options === $core->options ) {
739
-				return $plugin_options;
740
-			}
741
-
742
-			$time = time();
743
-
744
-			// Sets last saved time.
745
-			$core->transients['last_save'] = $time;
746
-
747
-			$imported_options = array();
748
-
749
-			if ( isset( $plugin_options['import_code'] ) && '' !== $plugin_options['import_code'] ) {
750
-				$imported_options = json_decode( $plugin_options['import_code'], true );
751
-			}
752
-
753
-			// Import.
754
-			$core->transients['last_save_mode'] = 'import'; // Last save mode.
755
-			$core->transients['last_compiler']  = $time;
756
-			$core->transients['last_import']    = $time;
757
-			$core->transients['run_compiler']   = 1;
758
-
759
-			if ( is_array( $imported_options ) && ! empty( $imported_options ) && isset( $imported_options['redux-backup'] ) && ( 1 === $imported_options['redux-backup'] || '1' === $imported_options['redux-backup'] ) ) {
760
-				$core->transients['changed_values'] = array();
761
-				foreach ( $plugin_options as $key => $value ) {
762
-					if ( isset( $imported_options[ $key ] ) && $value !== $imported_options[ $key ] ) {
763
-						$plugin_options[ $key ]                     = $value;
764
-						$core->transients['changed_values'][ $key ] = $value;
765
-					}
766
-				}
767
-
768
-				/**
769
-				 * Action 'redux/options/{opt_name}/import'.
770
-				 *
771
-				 * @param  &array [&$plugin_options, redux_options]
772
-				 */
773
-
774
-				// phpcs:ignore WordPress.NamingConventions.ValidHookName
775
-				do_action_ref_array(
776
-					"redux/options/{$core->args['opt_name']}/import", // phpcs:ignore WordPress.NamingConventions.ValidHookName
777
-					array(
778
-						&$plugin_options,
779
-						$imported_options,
780
-						$core->transients['changed_values'],
781
-					)
782
-				);
783
-
784
-				setcookie( 'redux_current_tab_' . $core->args['opt_name'], '', 1, '/', $time + 1000, '/' );
785
-				$_COOKIE[ 'redux_current_tab_' . $core->args['opt_name'] ] = 1;
786
-
787
-				unset( $plugin_options['defaults'], $plugin_options['compiler'], $plugin_options['import'], $plugin_options['import_code'] );
788
-				if ( in_array( $core->args['database'], array( 'transient', 'theme_mods', 'theme_mods_expanded', 'network' ), true ) ) {
789
-					$this->set( $plugin_options );
790
-
791
-					return null;
792
-				}
793
-
794
-				$plugin_options = wp_parse_args( $imported_options, $plugin_options );
795
-
796
-				$core->transient_class->set();
797
-
798
-				return $plugin_options;
799
-			}
800
-
801
-			// Reset all to defaults.
802
-			if ( ! empty( $plugin_options['defaults'] ) ) {
803
-				if ( empty( $core->options_defaults ) ) {
804
-					$core->options_defaults = $core->_default_values();
805
-				}
806
-
807
-				/**
808
-				 * Filter: 'redux/validate/{opt_name}/defaults'.
809
-				 *
810
-				 * @param  &array [ $this->options_defaults, $plugin_options]
811
-				 */
812
-
813
-				// phpcs:ignore WordPress.NamingConventions.ValidHookName
814
-				$plugin_options = apply_filters( "redux/validate/{$core->args['opt_name']}/defaults", $core->options_defaults );
815
-
816
-				$core->transients['changed_values'] = array();
817
-
818
-				if ( empty( $core->options ) ) {
819
-					$core->options = $core->options_defaults;
820
-				}
821
-
822
-				foreach ( $core->options as $key => $value ) {
823
-					if ( isset( $plugin_options[ $key ] ) && $plugin_options[ $key ] !== $value ) {
824
-						$core->transients['changed_values'][ $key ] = $value;
825
-					}
826
-				}
827
-
828
-				$core->transients['run_compiler']   = 1;
829
-				$core->transients['last_save_mode'] = 'defaults'; // Last save mode.
830
-
831
-				$core->transient_class->set();
832
-
833
-				return $plugin_options;
834
-			}
835
-
836
-			// Section reset to default.
837
-			if ( ! empty( $plugin_options['defaults-section'] ) ) {
838
-				if ( isset( $plugin_options['redux-section'] ) && isset( $core->sections[ $plugin_options['redux-section'] ]['fields'] ) ) {
839
-					if ( empty( $core->options_defaults ) ) {
840
-						$core->options_defaults = $core->_default_values();
841
-					}
842
-
843
-					foreach ( $core->sections[ $plugin_options['redux-section'] ]['fields'] as $field ) {
844
-						if ( 'tabbed' === $field['type'] ) {
845
-							if ( ! empty( $field['tabs'] ) ) {
846
-								foreach ( $field['tabs'] as $val ) {
847
-									if ( ! empty( $val['fields'] ) ) {
848
-										foreach ( $val['fields'] as $f ) {
849
-											if ( isset( $core->options_defaults[ $f['id'] ] ) ) {
850
-												$plugin_options[ $f['id'] ] = $core->options_defaults[ $f['id'] ];
851
-											} else {
852
-												$plugin_options[ $f['id'] ] = '';
853
-											}
854
-										}
855
-									}
856
-								}
857
-							}
858
-						} elseif ( 'repeater' === $field['type'] ) {
859
-							if ( ! empty( $field['fields'] ) ) {
860
-								foreach ( $field['fields'] as $f ) {
861
-									if ( isset( $core->options_defaults[ $f['id'] ] ) ) {
862
-										$plugin_options[ $f['id'] ] = $core->options_defaults[ $f['id'] ];
863
-									} else {
864
-										$plugin_options[ $f['id'] ] = '';
865
-									}
866
-								}
867
-							}
868
-						} else {
869
-							if ( isset( $core->options_defaults[ $field['id'] ] ) ) {
870
-								$plugin_options[ $field['id'] ] = $core->options_defaults[ $field['id'] ];
871
-							} else {
872
-								$plugin_options[ $field['id'] ] = '';
873
-							}
874
-						}
875
-
876
-						if ( isset( $field['compiler'] ) ) {
877
-							$compiler = true;
878
-						}
879
-					}
880
-
881
-					/**
882
-					 * Filter: 'redux/validate/{opt_name}/defaults_section'.
883
-					 *
884
-					 * @param  &array [ $this->options_defaults, $plugin_options]
885
-					 */
886
-
887
-					// phpcs:ignore WordPress.NamingConventions.ValidHookName
888
-					$plugin_options = apply_filters( "redux/validate/{$core->args['opt_name']}/defaults_section", $plugin_options );
889
-				}
890
-
891
-				$core->transients['changed_values'] = array();
892
-
893
-				foreach ( $core->options as $key => $value ) {
894
-					if ( isset( $plugin_options[ $key ] ) && $plugin_options[ $key ] !== $value ) {
895
-						$core->transients['changed_values'][ $key ] = $value;
896
-					}
897
-				}
898
-
899
-				if ( isset( $compiler ) ) {
900
-					$core->transients['last_compiler'] = $time;
901
-					$core->transients['run_compiler']  = 1;
902
-				}
903
-
904
-				$core->transients['last_save_mode'] = 'defaults_section'; // Last save mode.
905
-
906
-				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'] );
907
-
908
-				$core->transient_class->set();
909
-
910
-				return $plugin_options;
911
-			}
912
-
913
-			$core->transients['last_save_mode'] = 'normal'; // Last save mode.
914
-
915
-			/**
916
-			 * Filter: 'redux/validate/{opt_name}/before_validation'
917
-			 *
918
-			 * @param  &array [&$plugin_options, redux_options]
919
-			 */
920
-
921
-			// phpcs:ignore WordPress.NamingConventions.ValidHookName
922
-			$plugin_options = apply_filters( "redux/validate/{$core->args['opt_name']}/before_validation", $plugin_options, $core->options );
923
-
924
-			// Validate fields (if needed).
925
-			$plugin_options = $core->validate_class->validate( $plugin_options, $core->options, $core->sections );
926
-
927
-			// Sanitize options, if needed.
928
-			$plugin_options = $core->sanitize_class->sanitize( $plugin_options, $core->options, $core->sections );
929
-
930
-			if ( ! empty( $core->errors ) || ! empty( $core->warnings ) || ! empty( $core->sanitize ) ) {
931
-				$core->transients['notices'] = array(
932
-					'errors'   => $core->errors,
933
-					'warnings' => $core->warnings,
934
-					'sanitize' => $core->sanitize,
935
-				);
936
-			}
937
-
938
-			if ( ! isset( $core->transients['changed_values'] ) ) {
939
-				$core->transients['changed_values'] = array();
940
-			}
941
-
942
-			/**
943
-			 * Action 'redux/options/{opt_name}/validate'
944
-			 *
945
-			 * @param  &array [&$plugin_options, redux_options]
946
-			 */
947
-			// phpcs:ignore WordPress.NamingConventions.ValidHookName
948
-			do_action_ref_array(
949
-			// phpcs:ignore WordPress.NamingConventions.ValidHookName
950
-				"redux/options/{$core->args['opt_name']}/validate",
951
-				array(
952
-					&$plugin_options,
953
-					$core->options,
954
-					$core->transients['changed_values'],
955
-				)
956
-			);
957
-
958
-			if ( ! empty( $plugin_options['compiler'] ) ) {
959
-				unset( $plugin_options['compiler'] );
960
-
961
-				$core->transients['last_compiler'] = $time;
962
-				$core->transients['run_compiler']  = 1;
963
-			}
964
-
965
-			$core->transients['changed_values'] = array(); // Changed values since last save.
966
-
967
-			if ( ! empty( $core->options ) ) {
968
-				foreach ( $core->options as $key => $value ) {
969
-					if ( isset( $plugin_options[ $key ] ) && $plugin_options[ $key ] !== $value ) {
970
-						$core->transients['changed_values'][ $key ] = $value;
971
-					}
972
-				}
973
-			}
974
-
975
-			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'] );
976
-			if ( in_array( $core->args['database'], array( 'transient', 'theme_mods', 'theme_mods_expanded' ), true ) ) {
977
-				$core->set( $core->args['opt_name'], $plugin_options );
978
-				return null;
979
-			}
980
-
981
-			if ( defined( 'WP_CACHE' ) && WP_CACHE && class_exists( 'W3_ObjectCache' ) && function_exists( 'w3_instance' ) ) {
982
-				$w3_inst = w3_instance( 'W3_ObjectCache' );
983
-				$w3      = $w3_inst->instance();
984
-				$key     = $w3->_get_cache_key( $core->args['opt_name'] . '-transients', 'transient' );
985
-				$w3->delete( $key, 'transient', true );
986
-			}
987
-
988
-			$core->transient_class->set();
989
-
990
-			return $plugin_options;
991
-		}
992
-
993
-		/**
994
-		 * ->get_default(); This is used to return the default value if default_show is set.
995
-		 *
996
-		 * @param string $opt_name The option name to return.
997
-		 * @param mixed  $defaults (null) The value to return if default not set.
998
-		 *
999
-		 * @return      mixed $default
1000
-		 * @since       1.0.1
1001
-		 * @access      public
1002
-		 */
1003
-		public function get_default( string $opt_name, $defaults = null ) {
1004
-			if ( true === $this->args['default_show'] ) {
1005
-
1006
-				if ( empty( $this->options_defaults ) ) {
1007
-					$this->default_values(); // fill cache.
1008
-				}
1009
-
1010
-				return array_key_exists( $opt_name, $this->options_defaults ) ? $this->options_defaults[ $opt_name ] : $defaults;
1011
-			}
1012
-
1013
-			return '';
1014
-		}
1015
-
1016
-		/**
1017
-		 * Get the default value for an option
1018
-		 *
1019
-		 * @param string $key       The option's ID.
1020
-		 * @param string $array_key The key of the default's array.
1021
-		 *
1022
-		 * @return mixed
1023
-		 * @since  3.3.6
1024
-		 * @access public
1025
-		 */
1026
-		public function get_default_value( string $key, $array_key = false ) {
1027
-			if ( empty( $this->options_defaults ) ) {
1028
-				$this->options_defaults = $this->default_values();
1029
-			}
1030
-
1031
-			$defaults = $this->options_defaults;
1032
-			$value    = '';
1033
-
1034
-			if ( isset( $defaults[ $key ] ) ) {
1035
-				if ( false !== $array_key && isset( $defaults[ $key ][ $array_key ] ) ) {
1036
-					$value = $defaults[ $key ][ $array_key ];
1037
-				} else {
1038
-					$value = $defaults[ $key ];
1039
-				}
1040
-			}
1041
-
1042
-			return $value;
1043
-		}
1044
-	}
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
+                            $options_values[ $field['id'] ] = apply_filters( 'wpml_object_id', $options_values[ $field['id'] ], $field['data'], true );
81
+                        }
82
+                    }
83
+                } elseif ( is_array( $section ) && ! empty( $section ) ) {
84
+                    $this->translate_data_field_recursive( $section, $options_values );
85
+                }
86
+            }
87
+        }
88
+
89
+        /**
90
+         * Retrieves the options.
91
+         */
92
+        public function get() {
93
+            $core = $this->core();
94
+
95
+            $defaults = false;
96
+
97
+            if ( ! empty( $core->defaults ) ) {
98
+                $defaults = $core->defaults;
99
+            }
100
+
101
+            if ( empty( $core->args ) ) {
102
+                return;
103
+            }
104
+
105
+            switch ( $core->args['database'] ) {
106
+                case 'transient':
107
+                    $result = get_transient( $core->args['opt_name'] . '-transient' );
108
+                    break;
109
+                case 'theme_mods':
110
+                    $result = get_theme_mod( $core->args['opt_name'] . '-mods' );
111
+                    break;
112
+                case 'theme_mods_expanded':
113
+                    $result = get_theme_mods();
114
+                    break;
115
+                case 'network':
116
+                    $result = get_site_option( $core->args['opt_name'], array() );
117
+                    break;
118
+                default:
119
+                    $result = get_option( $core->args['opt_name'], array() );
120
+
121
+            }
122
+
123
+            if ( ! is_array( $result ) ) {
124
+                return;
125
+            }
126
+
127
+            if ( empty( $result ) && empty( $defaults ) ) {
128
+                return;
129
+            }
130
+
131
+            if ( empty( $result ) && ! empty( $defaults ) ) {
132
+                $results = $defaults;
133
+                $this->set( $results );
134
+            } else {
135
+                $core->options = $result;
136
+            }
137
+
138
+            // Don't iterate unnecessarily.
139
+            if ( has_filter( 'wpml_object_id' ) ) {
140
+                $this->translate_data_field_recursive( $core->sections, $core->options );
141
+            }
142
+
143
+            /**
144
+             * Action 'redux/options/{opt_name}/options'
145
+             *
146
+             * @param mixed $value option values
147
+             */
148
+
149
+            // phpcs:ignore WordPress.NamingConventions.ValidHookName
150
+            $core->options = apply_filters( "redux/options/{$core->args['opt_name']}/options", $core->options, $core->sections );
151
+
152
+            // Get transient values.
153
+            $core->transient_class->get();
154
+
155
+            // Set a global variable by the global_variable argument.
156
+            $this->set_global_variable( $core );
157
+        }
158
+
159
+        /**
160
+         * ->set_options(); This is used to set an arbitrary option in the option array
161
+         *
162
+         * @since ReduxFramework 3.0.0
163
+         *
164
+         * @param string|array $value the value of the option being added.
165
+         */
166
+        public function set( $value = '' ) {
167
+            $core = $this->core();
168
+
169
+            $core->transients['last_save'] = time();
170
+
171
+            if ( ! empty( $value ) ) {
172
+                switch ( $core->args['database'] ) {
173
+                    case 'transient':
174
+                        set_transient( $core->args['opt_name'] . '-transient', $value, $core->args['transient_time'] );
175
+                        break;
176
+                    case 'theme_mods':
177
+                        set_theme_mod( $core->args['opt_name'] . '-mods', $value );
178
+                        break;
179
+                    case 'theme_mods_expanded':
180
+                        foreach ( $value as $k => $v ) {
181
+                            set_theme_mod( $k, $v );
182
+                        }
183
+                        break;
184
+                    case 'network':
185
+                        update_site_option( $core->args['opt_name'], $value );
186
+                        break;
187
+                    default:
188
+                        update_option( $core->args['opt_name'], $value );
189
+
190
+                }
191
+
192
+                // Store the changed values in the transient.
193
+                if ( $value !== $core->options ) {
194
+                    foreach ( $value as $k => $v ) {
195
+                        if ( ! isset( $core->options[ $k ] ) ) {
196
+                            $core->options[ $k ] = '';
197
+                        } elseif ( $v === $core->options[ $k ] ) {
198
+                            unset( $core->options[ $k ] );
199
+                        }
200
+                    }
201
+
202
+                    $core->transients['changed_values'] = $core->options;
203
+                }
204
+
205
+                $core->options = $value;
206
+
207
+                // Set a global variable by the global_variable argument.
208
+                $this->set_global_variable( $core );
209
+
210
+                // Saving the transient values.
211
+                $core->transient_class->set();
212
+            }
213
+        }
214
+
215
+        /**
216
+         * Set a global variable by the global_variable argument
217
+         *
218
+         * @param null|ReduxFramework $core ReduxFramework core object.
219
+         *
220
+         * @return  void          (global was set)
221
+         * @since   3.1.5
222
+         */
223
+        private function set_global_variable( ?ReduxFramework $core ): void {
224
+            if ( ! empty( $core->args['global_variable'] ) ) {
225
+                $options_global = $core->args['global_variable'];
226
+
227
+                /**
228
+                 * Filter 'redux/options/{opt_name}/global_variable'
229
+                 *
230
+                 * @param array $value option value to set global_variable with
231
+                 */
232
+
233
+                // phpcs:ignore WordPress.NamingConventions.ValidHookName
234
+                $GLOBALS[ $options_global ] = apply_filters( "redux/options/{$core->args['opt_name']}/global_variable", $core->options );
235
+            }
236
+        }
237
+
238
+        /**
239
+         * Register Option for use
240
+         *
241
+         * @return void
242
+         * @throws ReflectionException Exception.
243
+         * @since  1.0.0
244
+         * @access public
245
+         */
246
+        public function register() {
247
+            $core = $this->core();
248
+
249
+            if ( ! is_object( $core ) ) {
250
+                return;
251
+            }
252
+
253
+            if ( true === $core->args['options_api'] ) {
254
+                register_setting(
255
+                    $core->args['opt_name'] . '_group',
256
+                    $core->args['opt_name'],
257
+                    array(
258
+                        $this,
259
+                        'validate_options',
260
+                    )
261
+                );
262
+            }
263
+
264
+            if ( is_null( $core->sections ) ) {
265
+                return;
266
+            }
267
+
268
+            if ( empty( $core->options_defaults ) ) {
269
+                $core->options_defaults = $core->default_values();
270
+            }
271
+
272
+            $run_update = false;
273
+
274
+            foreach ( $core->sections as $k => $section ) {
275
+                if ( isset( $section['type'] ) && 'divide' === $section['type'] ) {
276
+                    continue;
277
+                }
278
+
279
+                $display = true;
280
+
281
+                if ( isset( $_GET['page'] ) && $_GET['page'] === $core->args['page_slug'] ) { // phpcs:ignore WordPress.Security.NonceVerification
282
+                    if ( isset( $section['panel'] ) && false === $section['panel'] ) {
283
+                        $display = false;
284
+                    }
285
+                }
286
+
287
+                /**
288
+                 * Filter 'redux/options/{opt_name}/section/{section.id}'
289
+                 *
290
+                 * @param array $section section configuration
291
+                 */
292
+                if ( isset( $section['id'] ) ) {
293
+                    // phpcs:ignore WordPress.NamingConventions.ValidHookName
294
+                    $section = apply_filters( "redux/options/{$core->args['opt_name']}/section/{$section['id']}", $section );
295
+                }
296
+
297
+                if ( empty( $section ) ) {
298
+                    unset( $core->sections[ $k ] );
299
+                    continue;
300
+                }
301
+
302
+                if ( ! isset( $section['title'] ) ) {
303
+                    $section['title'] = '';
304
+                }
305
+
306
+                if ( isset( $section['customizer_only'] ) && true === $section['customizer_only'] ) {
307
+                    $section['panel']     = false;
308
+                    $core->sections[ $k ] = $section;
309
+                }
310
+
311
+                $heading = $section['heading'] ?? $section['title'];
312
+
313
+                if ( isset( $section['permissions'] ) && false !== $section['permissions'] ) {
314
+                    if ( ! Redux_Helpers::current_user_can( $section['permissions'] ) ) {
315
+                        $core->hidden_perm_sections[] = $section['title'];
316
+
317
+                        foreach ( $section['fields'] as $field_data ) {
318
+                            $field_type = $field_data['type'];
319
+
320
+                            if ( ! in_array( $field_type, array( 'section', 'divide', 'info', 'raw' ), true ) ) {
321
+                                $field_id = $field_data['id'];
322
+                                $default  = $core->options_defaults[ $field_id ] ?? '';
323
+                                $data     = $core->options[ $field_id ] ?? $default;
324
+
325
+                                $this->hidden_perm_fields[ $field_id ] = $data;
326
+                            }
327
+                        }
328
+
329
+                        continue;
330
+                    }
331
+                }
332
+
333
+                if ( ! $display || ! function_exists( 'add_settings_section' ) ) {
334
+                    $this->no_panel_section[ $k ] = $section;
335
+                } else {
336
+                    add_settings_section(
337
+                        $core->args['opt_name'] . $k . '_section',
338
+                        $heading,
339
+                        array(
340
+                            $core->render_class,
341
+                            'section_desc',
342
+                        ),
343
+                        $core->args['opt_name'] . $k . '_section_group'
344
+                    );
345
+                }
346
+
347
+                $section_ident = false;
348
+                if ( isset( $section['fields'] ) ) {
349
+                    foreach ( $section['fields'] as $fieldk => $field ) {
350
+                        if ( ! isset( $field['type'] ) ) {
351
+                            continue; // You need a type!
352
+                        }
353
+
354
+                        if ( 'info' === $field['type'] && isset( $field['raw_html'] ) && true === $field['raw_html'] ) {
355
+                            $field['type']                             = 'raw';
356
+                            $field['content']                          = $field['desc'];
357
+                            $field['desc']                             = '';
358
+                            $core->sections[ $k ]['fields'][ $fieldk ] = $field;
359
+                        } elseif ( 'info' === $field['type'] ) {
360
+                            if ( ! isset( $field['full_width'] ) ) {
361
+                                $field['full_width']                       = true;
362
+                                $core->sections[ $k ]['fields'][ $fieldk ] = $field;
363
+                            }
364
+                        }
365
+
366
+                        if ( 'raw' === $field['type'] ) {
367
+                            if ( isset( $field['align'] ) ) {
368
+                                $field['full_width'] = ! $field['align'];
369
+                                unset( $field['align'] );
370
+                            } elseif ( ! isset( $field['full_width'] ) ) {
371
+                                $field['full_width'] = true;
372
+                            }
373
+                            $core->sections[ $k ]['fields'][ $fieldk ] = $field;
374
+                        }
375
+
376
+                        /**
377
+                         * Filter 'redux/options/{opt_name}/field/{field.id}'
378
+                         *
379
+                         * @param array $field field config
380
+                         */
381
+
382
+                        // phpcs:ignore WordPress.NamingConventions.ValidHookName
383
+                        $field = apply_filters( "redux/options/{$core->args['opt_name']}/field/{$field['id']}/register", $field );
384
+
385
+                        $core->field_types[ $field['type'] ] = $core->field_types[ $field['type'] ] ?? array();
386
+
387
+                        $core->field_sections[ $field['type'] ][ $field['id'] ] = $k;
388
+
389
+                        $display = true;
390
+
391
+                        if ( isset( $_GET['page'] ) && $core->args['page_slug'] === $_GET['page'] ) { // phpcs:ignore WordPress.Security.NonceVerification
392
+                            if ( isset( $field['panel'] ) && false === $field['panel'] ) {
393
+                                $display = false;
394
+                            }
395
+                        }
396
+                        if ( isset( $field['customizer_only'] ) && true === $field['customizer_only'] ) {
397
+                            $display = false;
398
+                        }
399
+
400
+                        if ( isset( $section['customizer'] ) ) {
401
+                            $field['customizer']                       = $section['customizer'];
402
+                            $core->sections[ $k ]['fields'][ $fieldk ] = $field;
403
+                        }
404
+
405
+                        if ( isset( $field['permissions'] ) && false !== $field['permissions'] ) {
406
+                            if ( ! Redux_Helpers::current_user_can( $field['permissions'] ) ) {
407
+                                $data = $core->options[ $field['id'] ] ?? $core->options_defaults[ $field['id'] ];
408
+
409
+                                $this->hidden_perm_fields[ $field['id'] ] = $data;
410
+
411
+                                continue;
412
+                            }
413
+                        }
414
+
415
+                        if ( ! isset( $field['id'] ) ) {
416
+                            echo '<br /><h3>No field ID is set.</h3><pre>';
417
+
418
+                            // phpcs:ignore WordPress.PHP.DevelopmentFunctions
419
+                            print_r( $field );
420
+
421
+                            echo '</pre><br />';
422
+
423
+                            continue;
424
+                        }
425
+
426
+                        if ( isset( $field['type'] ) && 'section' === $field['type'] ) {
427
+                            if ( isset( $field['indent'] ) && true === $field['indent'] ) {
428
+                                $section_ident = true;
429
+                            } else {
430
+                                $section_ident = false;
431
+                            }
432
+                        }
433
+
434
+                        if ( isset( $field['type'] ) && 'info' === $field['type'] && $section_ident ) {
435
+                            $field['indent'] = true;
436
+                        }
437
+
438
+                        $th = $core->render_class->get_header_html( $field );
439
+
440
+                        $field['name'] = $core->args['opt_name'] . '[' . $field['id'] . ']';
441
+
442
+                        // Set the default value if present.
443
+                        $core->options_defaults[ $field['id'] ] = $core->options_defaults[ $field['id'] ] ?? '';
444
+
445
+                        // Set the defaults to the value if not present.
446
+                        $do_update = false;
447
+
448
+                        // Check fields for values in the default parameter.
449
+                        if ( ! isset( $core->options[ $field['id'] ] ) && isset( $field['default'] ) ) {
450
+                            $core->options_defaults[ $field['id'] ] = $field['default'];
451
+                            $core->options[ $field['id'] ]          = $field['default'];
452
+                            $do_update                              = true;
453
+
454
+                            // Check fields that hae no default value, but an option value with settings to
455
+                            // be saved by default.
456
+                        } elseif ( ! isset( $core->options[ $field['id'] ] ) && isset( $field['options'] ) ) {
457
+
458
+                            // If a sorter field, check for options and save them as defaults.
459
+                            if ( 'sorter' === $field['type'] || 'sortable' === $field['type'] ) {
460
+                                $core->options_defaults[ $field['id'] ] = $field['options'];
461
+                                $core->options[ $field['id'] ]          = $field['options'];
462
+                                $do_update                              = true;
463
+                            }
464
+                        }
465
+
466
+                        // CORRECT URLS if media URLs are wrong, but attachment IDs are present.
467
+                        if ( 'media' === $field['type'] ) {
468
+                            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( 'http://', '', WP_CONTENT_URL ) ) === false ) {
469
+                                $data = wp_get_attachment_url( $core->options[ $field['id'] ]['id'] );
470
+
471
+                                if ( isset( $data ) && ! empty( $data ) ) {
472
+                                    $core->options[ $field['id'] ]['url'] = $data;
473
+
474
+                                    $data = wp_get_attachment_image_src(
475
+                                        $core->options[ $field['id'] ]['id'],
476
+                                        array(
477
+                                            150,
478
+                                            150,
479
+                                        )
480
+                                    );
481
+
482
+                                    $core->options[ $field['id'] ]['thumbnail'] = $data[0];
483
+                                    $do_update                                  = true;
484
+                                }
485
+                            }
486
+                        }
487
+
488
+                        if ( 'background' === $field['type'] ) {
489
+                            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( 'http://', 'https://' ), '', WP_CONTENT_URL ) ) === false ) {
490
+                                $data = wp_get_attachment_url( $core->options[ $field['id'] ]['media']['id'] );
491
+
492
+                                if ( isset( $data ) && ! empty( $data ) ) {
493
+                                    $core->options[ $field['id'] ]['background-image'] = $data;
494
+
495
+                                    $data = wp_get_attachment_image_src(
496
+                                        $core->options[ $field['id'] ]['media']['id'],
497
+                                        array(
498
+                                            150,
499
+                                            150,
500
+                                        )
501
+                                    );
502
+
503
+                                    $core->options[ $field['id'] ]['media']['thumbnail'] = $data[0];
504
+                                    $do_update = true;
505
+                                }
506
+                            }
507
+                        }
508
+
509
+                        if ( 'slides' === $field['type'] ) {
510
+                            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( 'http://', 'https://' ), '', WP_CONTENT_URL ) ) === false ) {
511
+                                foreach ( $core->options[ $field['id'] ] as $key => $val ) {
512
+                                    $data = wp_get_attachment_url( $val['attachment_id'] );
513
+
514
+                                    if ( isset( $data ) && ! empty( $data ) ) {
515
+                                        $core->options[ $field['id'] ][ $key ]['image'] = $data;
516
+
517
+                                        $data = wp_get_attachment_image_src(
518
+                                            $val['attachment_id'],
519
+                                            array(
520
+                                                150,
521
+                                                150,
522
+                                            )
523
+                                        );
524
+
525
+                                        $core->options[ $field['id'] ][ $key ]['thumb'] = $data[0];
526
+                                        $do_update                                      = true;
527
+                                    }
528
+                                }
529
+                            }
530
+                        }
531
+                        // END -> CORRECT URLS if media URLs are wrong, but attachment IDs are present.
532
+                        if ( true === $do_update && ! isset( $core->never_save_to_db ) ) {
533
+                            if ( $core->args['save_defaults'] ) { // Only save that to the DB if allowed to.
534
+                                $run_update = true;
535
+                            }
536
+                        }
537
+
538
+                        if ( ! isset( $field['class'] ) ) { // No errors, please.
539
+                            $field['class'] = '';
540
+                        }
541
+
542
+                        /**
543
+                         * Filter 'redux/options/{opt_name}/field/{field.id}'.
544
+                         *
545
+                         * @param array $field field config
546
+                         */
547
+
548
+                        // phpcs:ignore WordPress.NamingConventions.ValidHookName
549
+                        $field = apply_filters( "redux/options/{$core->args['opt_name']}/field/{$field['id']}", $field );
550
+
551
+                        if ( empty( $field ) ) {
552
+                            unset( $core->sections[ $k ]['fields'][ $fieldk ] );
553
+                            continue;
554
+                        }
555
+
556
+                        if ( ! empty( Redux_Core::$folds[ $field['id'] ]['parent'] ) ) { // This has some fold items, hide it by default.
557
+                            $field['class'] .= ' fold';
558
+                        }
559
+
560
+                        if ( ! empty( Redux_Core::$folds[ $field['id'] ]['children'] ) ) { // Sets the values you shoe fold children on.
561
+                            $field['class'] .= ' fold-parent';
562
+                        }
563
+
564
+                        if ( ! empty( $field['compiler'] ) ) {
565
+                            $field['class']                       .= ' compiler';
566
+                            $core->compiler_fields[ $field['id'] ] = 1;
567
+                        }
568
+
569
+                        if ( isset( $field['unit'] ) && ! isset( $field['units'] ) ) {
570
+                            $field['units'] = $field['unit'];
571
+                            unset( $field['unit'] );
572
+                        }
573
+
574
+                        $core->sections[ $k ]['fields'][ $fieldk ] = $field;
575
+
576
+                        if ( isset( $core->args['display_source'] ) ) {
577
+                            // phpcs:ignore WordPress.PHP.DevelopmentFunctions
578
+                            $th .= '<div id="' . $field['id'] . '-settings" style="display:none;"><pre>' . var_export( $core->sections[ $k ]['fields'][ $fieldk ], true ) . '</pre></div>';
579
+                            $th .= '<br /><a href="#TB_inline?width=600&height=800&inlineId=' . $field['id'] . '-settings" class="thickbox"><small>View Source</small></a>';
580
+                        }
581
+
582
+                        /**
583
+                         * Action 'redux/options/{opt_name}/field/{field.type}/register'
584
+                         */
585
+
586
+                        // phpcs:ignore WordPress.NamingConventions.ValidHookName
587
+                        do_action( "redux/options/{$core->args['opt_name']}/field/{$field['type']}/register", $field );
588
+
589
+                        $core->required_class->check_dependencies( $field );
590
+                        $core->field_head[ $field['id'] ] = $th;
591
+
592
+                        if ( ! $display || isset( $this->no_panel_section[ $k ] ) ) {
593
+                            $this->no_panel[] = $field['id'];
594
+                        } else {
595
+                            if ( isset( $field['disabled'] ) && $field['disabled'] ) {
596
+                                $field['class'] .= ' redux_disable_field';
597
+                            }
598
+
599
+                            if ( isset( $field['hidden'] ) && $field['hidden'] ) {
600
+                                $field['class'] .= ' redux_hide_field';
601
+                            }
602
+
603
+                            if ( true === $core->args['options_api'] ) {
604
+                                add_settings_field(
605
+                                    "{$fieldk}_field",
606
+                                    $th,
607
+                                    array(
608
+                                        $core->render_class,
609
+                                        'field_input',
610
+                                    ),
611
+                                    "{$core->args['opt_name']}{$k}_section_group",
612
+                                    "{$core->args['opt_name']}{$k}_section",
613
+                                    $field
614
+                                );
615
+                            }
616
+                        }
617
+                    }
618
+                }
619
+            }
620
+
621
+            /**
622
+             * Action 'redux/options/{opt_name}/register'
623
+             *
624
+             * @param array $section Option sections
625
+             */
626
+
627
+            // phpcs:ignore WordPress.NamingConventions.ValidHookName
628
+            do_action( "redux/options/{$core->args['opt_name']}/register", $core->sections );
629
+
630
+            if ( $run_update && ! isset( $core->never_save_to_db ) ) { // Always update the DB with new fields.
631
+                $this->set( $core->options );
632
+            }
633
+
634
+            if ( isset( $core->transients['run_compiler'] ) && $core->transients['run_compiler'] ) {
635
+
636
+                Redux_Core::$no_output = true;
637
+                $temp                  = $core->args['output_variables_prefix'];
638
+
639
+                // Allow the override of variable's prefix for use by SCSS or LESS.
640
+                if ( isset( $core->args['compiler_output_variables_prefix'] ) ) {
641
+                    $core->args['output_variables_prefix'] = $core->args['compiler_output_variables_prefix'];
642
+                }
643
+                $core->output_class->enqueue();
644
+                $core->args['output_variables_prefix'] = $temp;
645
+
646
+                // phpcs:ignore WordPress.NamingConventions.ValidVariableName
647
+                $compiler_css = $core->compilerCSS;
648
+
649
+                /**
650
+                 * Action 'redux/options/{opt_name}/compiler'
651
+                 *
652
+                 * @param array  $options Options.
653
+                 * @param string $css CSS that get sent to the compiler hook.
654
+                 * @param array  $changed_values Changed values.
655
+                 * @param array  $output_variables Output variables.
656
+                 */
657
+
658
+                // phpcs:ignore WordPress.NamingConventions.ValidHookName
659
+                do_action( "redux/options/{$core->args['opt_name']}/compiler", $core->options, $compiler_css, $core->transients['changed_values'], $core->output_variables );
660
+
661
+                /**
662
+                 * Action 'redux/options/{opt_name}/compiler/advanced'
663
+                 *
664
+                 * @param object $redux ReduxFramework object.
665
+                 */
666
+
667
+                // phpcs:ignore WordPress.NamingConventions.ValidHookName
668
+                do_action( "redux/options/{$core->args['opt_name']}/compiler/advanced", $core );
669
+
670
+                unset( $core->transients['run_compiler'] );
671
+                $core->transient_class->set();
672
+            }
673
+        }
674
+
675
+        /**
676
+         * Get default options into an array suitable for the settings API
677
+         *
678
+         * @since       1.0.0
679
+         * @access      public
680
+         * @return      array $this->options_defaults
681
+         */
682
+        public function default_values(): array {
683
+            $core = $this->core();
684
+
685
+            if ( ! is_null( $core->sections ) && is_null( $core->options_defaults ) ) {
686
+                $core->options_defaults = $core->options_defaults_class->default_values( $core->args['opt_name'], $core->sections, $core->wordpress_data );
687
+            }
688
+
689
+            /**
690
+             * Filter 'redux/options/{opt_name}/defaults'
691
+             *
692
+             * @param array $defaults option default values
693
+             */
694
+
695
+            $core->transients['changed_values'] = $core->transients['changed_values'] ?? array();
696
+
697
+            // phpcs:ignore WordPress.NamingConventions.ValidHookName
698
+            $core->options_defaults = apply_filters( "redux/options/{$core->args['opt_name']}/defaults", $core->options_defaults, $core->transients['changed_values'] );
699
+
700
+            return $core->options_defaults;
701
+        }
702
+
703
+        /**
704
+         * Validate the Options before insertion
705
+         *
706
+         * @param  array $plugin_options The option array.
707
+         *
708
+         * @return array|mixed|string
709
+         * @since  3.0.0
710
+         * @access public
711
+         */
712
+        public function validate_options( array $plugin_options ) {
713
+            $core = $this->core();
714
+
715
+            if ( true === Redux_Core::$validation_ran ) {
716
+                return $plugin_options;
717
+            }
718
+
719
+            Redux_Core::$validation_ran = true;
720
+
721
+            // Save the values not in the panel.
722
+            if ( isset( $plugin_options['redux-no_panel'] ) ) {
723
+                $keys = explode( '|', $plugin_options['redux-no_panel'] );
724
+                foreach ( $keys as $key ) {
725
+                    $plugin_options[ $key ] = $core->options[ $key ];
726
+                }
727
+                if ( isset( $plugin_options['redux-no_panel'] ) ) {
728
+                    unset( $plugin_options['redux-no_panel'] );
729
+                }
730
+            }
731
+
732
+            if ( is_array( $this->hidden_perm_fields ) && ! empty( $this->hidden_perm_fields ) ) {
733
+                foreach ( $this->hidden_perm_fields as $id => $data ) {
734
+                    $plugin_options[ $id ] = $data;
735
+                }
736
+            }
737
+
738
+            if ( $plugin_options === $core->options ) {
739
+                return $plugin_options;
740
+            }
741
+
742
+            $time = time();
743
+
744
+            // Sets last saved time.
745
+            $core->transients['last_save'] = $time;
746
+
747
+            $imported_options = array();
748
+
749
+            if ( isset( $plugin_options['import_code'] ) && '' !== $plugin_options['import_code'] ) {
750
+                $imported_options = json_decode( $plugin_options['import_code'], true );
751
+            }
752
+
753
+            // Import.
754
+            $core->transients['last_save_mode'] = 'import'; // Last save mode.
755
+            $core->transients['last_compiler']  = $time;
756
+            $core->transients['last_import']    = $time;
757
+            $core->transients['run_compiler']   = 1;
758
+
759
+            if ( is_array( $imported_options ) && ! empty( $imported_options ) && isset( $imported_options['redux-backup'] ) && ( 1 === $imported_options['redux-backup'] || '1' === $imported_options['redux-backup'] ) ) {
760
+                $core->transients['changed_values'] = array();
761
+                foreach ( $plugin_options as $key => $value ) {
762
+                    if ( isset( $imported_options[ $key ] ) && $value !== $imported_options[ $key ] ) {
763
+                        $plugin_options[ $key ]                     = $value;
764
+                        $core->transients['changed_values'][ $key ] = $value;
765
+                    }
766
+                }
767
+
768
+                /**
769
+                 * Action 'redux/options/{opt_name}/import'.
770
+                 *
771
+                 * @param  &array [&$plugin_options, redux_options]
772
+                 */
773
+
774
+                // phpcs:ignore WordPress.NamingConventions.ValidHookName
775
+                do_action_ref_array(
776
+                    "redux/options/{$core->args['opt_name']}/import", // phpcs:ignore WordPress.NamingConventions.ValidHookName
777
+                    array(
778
+                        &$plugin_options,
779
+                        $imported_options,
780
+                        $core->transients['changed_values'],
781
+                    )
782
+                );
783
+
784
+                setcookie( 'redux_current_tab_' . $core->args['opt_name'], '', 1, '/', $time + 1000, '/' );
785
+                $_COOKIE[ 'redux_current_tab_' . $core->args['opt_name'] ] = 1;
786
+
787
+                unset( $plugin_options['defaults'], $plugin_options['compiler'], $plugin_options['import'], $plugin_options['import_code'] );
788
+                if ( in_array( $core->args['database'], array( 'transient', 'theme_mods', 'theme_mods_expanded', 'network' ), true ) ) {
789
+                    $this->set( $plugin_options );
790
+
791
+                    return null;
792
+                }
793
+
794
+                $plugin_options = wp_parse_args( $imported_options, $plugin_options );
795
+
796
+                $core->transient_class->set();
797
+
798
+                return $plugin_options;
799
+            }
800
+
801
+            // Reset all to defaults.
802
+            if ( ! empty( $plugin_options['defaults'] ) ) {
803
+                if ( empty( $core->options_defaults ) ) {
804
+                    $core->options_defaults = $core->_default_values();
805
+                }
806
+
807
+                /**
808
+                 * Filter: 'redux/validate/{opt_name}/defaults'.
809
+                 *
810
+                 * @param  &array [ $this->options_defaults, $plugin_options]
811
+                 */
812
+
813
+                // phpcs:ignore WordPress.NamingConventions.ValidHookName
814
+                $plugin_options = apply_filters( "redux/validate/{$core->args['opt_name']}/defaults", $core->options_defaults );
815
+
816
+                $core->transients['changed_values'] = array();
817
+
818
+                if ( empty( $core->options ) ) {
819
+                    $core->options = $core->options_defaults;
820
+                }
821
+
822
+                foreach ( $core->options as $key => $value ) {
823
+                    if ( isset( $plugin_options[ $key ] ) && $plugin_options[ $key ] !== $value ) {
824
+                        $core->transients['changed_values'][ $key ] = $value;
825
+                    }
826
+                }
827
+
828
+                $core->transients['run_compiler']   = 1;
829
+                $core->transients['last_save_mode'] = 'defaults'; // Last save mode.
830
+
831
+                $core->transient_class->set();
832
+
833
+                return $plugin_options;
834
+            }
835
+
836
+            // Section reset to default.
837
+            if ( ! empty( $plugin_options['defaults-section'] ) ) {
838
+                if ( isset( $plugin_options['redux-section'] ) && isset( $core->sections[ $plugin_options['redux-section'] ]['fields'] ) ) {
839
+                    if ( empty( $core->options_defaults ) ) {
840
+                        $core->options_defaults = $core->_default_values();
841
+                    }
842
+
843
+                    foreach ( $core->sections[ $plugin_options['redux-section'] ]['fields'] as $field ) {
844
+                        if ( 'tabbed' === $field['type'] ) {
845
+                            if ( ! empty( $field['tabs'] ) ) {
846
+                                foreach ( $field['tabs'] as $val ) {
847
+                                    if ( ! empty( $val['fields'] ) ) {
848
+                                        foreach ( $val['fields'] as $f ) {
849
+                                            if ( isset( $core->options_defaults[ $f['id'] ] ) ) {
850
+                                                $plugin_options[ $f['id'] ] = $core->options_defaults[ $f['id'] ];
851
+                                            } else {
852
+                                                $plugin_options[ $f['id'] ] = '';
853
+                                            }
854
+                                        }
855
+                                    }
856
+                                }
857
+                            }
858
+                        } elseif ( 'repeater' === $field['type'] ) {
859
+                            if ( ! empty( $field['fields'] ) ) {
860
+                                foreach ( $field['fields'] as $f ) {
861
+                                    if ( isset( $core->options_defaults[ $f['id'] ] ) ) {
862
+                                        $plugin_options[ $f['id'] ] = $core->options_defaults[ $f['id'] ];
863
+                                    } else {
864
+                                        $plugin_options[ $f['id'] ] = '';
865
+                                    }
866
+                                }
867
+                            }
868
+                        } else {
869
+                            if ( isset( $core->options_defaults[ $field['id'] ] ) ) {
870
+                                $plugin_options[ $field['id'] ] = $core->options_defaults[ $field['id'] ];
871
+                            } else {
872
+                                $plugin_options[ $field['id'] ] = '';
873
+                            }
874
+                        }
875
+
876
+                        if ( isset( $field['compiler'] ) ) {
877
+                            $compiler = true;
878
+                        }
879
+                    }
880
+
881
+                    /**
882
+                     * Filter: 'redux/validate/{opt_name}/defaults_section'.
883
+                     *
884
+                     * @param  &array [ $this->options_defaults, $plugin_options]
885
+                     */
886
+
887
+                    // phpcs:ignore WordPress.NamingConventions.ValidHookName
888
+                    $plugin_options = apply_filters( "redux/validate/{$core->args['opt_name']}/defaults_section", $plugin_options );
889
+                }
890
+
891
+                $core->transients['changed_values'] = array();
892
+
893
+                foreach ( $core->options as $key => $value ) {
894
+                    if ( isset( $plugin_options[ $key ] ) && $plugin_options[ $key ] !== $value ) {
895
+                        $core->transients['changed_values'][ $key ] = $value;
896
+                    }
897
+                }
898
+
899
+                if ( isset( $compiler ) ) {
900
+                    $core->transients['last_compiler'] = $time;
901
+                    $core->transients['run_compiler']  = 1;
902
+                }
903
+
904
+                $core->transients['last_save_mode'] = 'defaults_section'; // Last save mode.
905
+
906
+                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'] );
907
+
908
+                $core->transient_class->set();
909
+
910
+                return $plugin_options;
911
+            }
912
+
913
+            $core->transients['last_save_mode'] = 'normal'; // Last save mode.
914
+
915
+            /**
916
+             * Filter: 'redux/validate/{opt_name}/before_validation'
917
+             *
918
+             * @param  &array [&$plugin_options, redux_options]
919
+             */
920
+
921
+            // phpcs:ignore WordPress.NamingConventions.ValidHookName
922
+            $plugin_options = apply_filters( "redux/validate/{$core->args['opt_name']}/before_validation", $plugin_options, $core->options );
923
+
924
+            // Validate fields (if needed).
925
+            $plugin_options = $core->validate_class->validate( $plugin_options, $core->options, $core->sections );
926
+
927
+            // Sanitize options, if needed.
928
+            $plugin_options = $core->sanitize_class->sanitize( $plugin_options, $core->options, $core->sections );
929
+
930
+            if ( ! empty( $core->errors ) || ! empty( $core->warnings ) || ! empty( $core->sanitize ) ) {
931
+                $core->transients['notices'] = array(
932
+                    'errors'   => $core->errors,
933
+                    'warnings' => $core->warnings,
934
+                    'sanitize' => $core->sanitize,
935
+                );
936
+            }
937
+
938
+            if ( ! isset( $core->transients['changed_values'] ) ) {
939
+                $core->transients['changed_values'] = array();
940
+            }
941
+
942
+            /**
943
+             * Action 'redux/options/{opt_name}/validate'
944
+             *
945
+             * @param  &array [&$plugin_options, redux_options]
946
+             */
947
+            // phpcs:ignore WordPress.NamingConventions.ValidHookName
948
+            do_action_ref_array(
949
+            // phpcs:ignore WordPress.NamingConventions.ValidHookName
950
+                "redux/options/{$core->args['opt_name']}/validate",
951
+                array(
952
+                    &$plugin_options,
953
+                    $core->options,
954
+                    $core->transients['changed_values'],
955
+                )
956
+            );
957
+
958
+            if ( ! empty( $plugin_options['compiler'] ) ) {
959
+                unset( $plugin_options['compiler'] );
960
+
961
+                $core->transients['last_compiler'] = $time;
962
+                $core->transients['run_compiler']  = 1;
963
+            }
964
+
965
+            $core->transients['changed_values'] = array(); // Changed values since last save.
966
+
967
+            if ( ! empty( $core->options ) ) {
968
+                foreach ( $core->options as $key => $value ) {
969
+                    if ( isset( $plugin_options[ $key ] ) && $plugin_options[ $key ] !== $value ) {
970
+                        $core->transients['changed_values'][ $key ] = $value;
971
+                    }
972
+                }
973
+            }
974
+
975
+            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'] );
976
+            if ( in_array( $core->args['database'], array( 'transient', 'theme_mods', 'theme_mods_expanded' ), true ) ) {
977
+                $core->set( $core->args['opt_name'], $plugin_options );
978
+                return null;
979
+            }
980
+
981
+            if ( defined( 'WP_CACHE' ) && WP_CACHE && class_exists( 'W3_ObjectCache' ) && function_exists( 'w3_instance' ) ) {
982
+                $w3_inst = w3_instance( 'W3_ObjectCache' );
983
+                $w3      = $w3_inst->instance();
984
+                $key     = $w3->_get_cache_key( $core->args['opt_name'] . '-transients', 'transient' );
985
+                $w3->delete( $key, 'transient', true );
986
+            }
987
+
988
+            $core->transient_class->set();
989
+
990
+            return $plugin_options;
991
+        }
992
+
993
+        /**
994
+         * ->get_default(); This is used to return the default value if default_show is set.
995
+         *
996
+         * @param string $opt_name The option name to return.
997
+         * @param mixed  $defaults (null) The value to return if default not set.
998
+         *
999
+         * @return      mixed $default
1000
+         * @since       1.0.1
1001
+         * @access      public
1002
+         */
1003
+        public function get_default( string $opt_name, $defaults = null ) {
1004
+            if ( true === $this->args['default_show'] ) {
1005
+
1006
+                if ( empty( $this->options_defaults ) ) {
1007
+                    $this->default_values(); // fill cache.
1008
+                }
1009
+
1010
+                return array_key_exists( $opt_name, $this->options_defaults ) ? $this->options_defaults[ $opt_name ] : $defaults;
1011
+            }
1012
+
1013
+            return '';
1014
+        }
1015
+
1016
+        /**
1017
+         * Get the default value for an option
1018
+         *
1019
+         * @param string $key       The option's ID.
1020
+         * @param string $array_key The key of the default's array.
1021
+         *
1022
+         * @return mixed
1023
+         * @since  3.3.6
1024
+         * @access public
1025
+         */
1026
+        public function get_default_value( string $key, $array_key = false ) {
1027
+            if ( empty( $this->options_defaults ) ) {
1028
+                $this->options_defaults = $this->default_values();
1029
+            }
1030
+
1031
+            $defaults = $this->options_defaults;
1032
+            $value    = '';
1033
+
1034
+            if ( isset( $defaults[ $key ] ) ) {
1035
+                if ( false !== $array_key && isset( $defaults[ $key ][ $array_key ] ) ) {
1036
+                    $value = $defaults[ $key ][ $array_key ];
1037
+                } else {
1038
+                    $value = $defaults[ $key ];
1039
+                }
1040
+            }
1041
+
1042
+            return $value;
1043
+        }
1044
+    }
1045 1045
 }
Please login to merge, or discard this patch.
redux-core/class-redux-core.php 2 patches
Indentation   +614 added lines, -614 removed lines patch added patch discarded remove patch
@@ -11,620 +11,620 @@
 block discarded – undo
11 11
 
12 12
 if ( ! class_exists( 'Redux_Core', false ) ) {
13 13
 
14
-	/**
15
-	 * Class Redux_Core
16
-	 */
17
-	class Redux_Core {
18
-
19
-		/**
20
-		 * Class instance.
21
-		 *
22
-		 * @var null|Redux_Core
23
-		 */
24
-		public static ?Redux_Core $instance = null;
25
-
26
-		/**
27
-		 * Project version
28
-		 *
29
-		 * @var string
30
-		 */
31
-		public static string $version;
32
-
33
-		/**
34
-		 * Project directory.
35
-		 *
36
-		 * @var string.
37
-		 */
38
-		public static string $dir;
39
-
40
-		/**
41
-		 * Project URL.
42
-		 *
43
-		 * @var string.
44
-		 */
45
-		public static string $url;
46
-
47
-		/**
48
-		 * Base directory path.
49
-		 *
50
-		 * @var string
51
-		 */
52
-		public static string $redux_path;
53
-
54
-		/**
55
-		 * Absolute direction path to WordPress upload directory.
56
-		 *
57
-		 * @var string
58
-		 */
59
-		public static string $upload_dir = '';
60
-
61
-		/**
62
-		 * Full URL to WordPress upload directory.
63
-		 *
64
-		 * @var null|string
65
-		 */
66
-		public static ?string $upload_url = '';
67
-
68
-		/**
69
-		 * Set when Redux is run as a plugin.
70
-		 *
71
-		 * @var bool
72
-		 */
73
-		public static bool $is_plugin = true;
74
-
75
-		/**
76
-		 * Indicated in_theme or in_plugin.
77
-		 *
78
-		 * @var string
79
-		 */
80
-		public static string $installed = '';
81
-
82
-		/**
83
-		 * Set when Redux is run as a plugin.
84
-		 *
85
-		 * @var bool
86
-		 */
87
-		public static bool $as_plugin = false;
88
-
89
-		/**
90
-		 * Set when Redux is embedded within a theme.
91
-		 *
92
-		 * @var bool
93
-		 */
94
-		public static bool $in_theme = false;
95
-
96
-		/**
97
-		 * Pointer to an updated Google fonts array.
98
-		 *
99
-		 * @var array|null
100
-		 */
101
-		public static ?array $updated_google_fonts = array();
102
-
103
-		/**
104
-		 * List of files calling Redux.
105
-		 *
106
-		 * @var array|null
107
-		 */
108
-		public static ?array $callers = array();
109
-
110
-		/**
111
-		 * Pointer to _SERVER global.
112
-		 *
113
-		 * @var array|null
114
-		 */
115
-		public static ?array $server = array();
116
-
117
-		/**
118
-		 * Field folding information for localization.
119
-		 *
120
-		 * @var null|array
121
-		 */
122
-		public static ?array $required = array();
123
-
124
-		/**
125
-		 * Field child-folding information for localization.
126
-		 *
127
-		 * @var null|array
128
-		 */
129
-		public static ?array $required_child = array();
130
-
131
-		/**
132
-		 * Array of fields to be folded.
133
-		 *
134
-		 * @var array|null
135
-		 */
136
-		public static ?array $folds = array();
137
-
138
-		/**
139
-		 * Array of fields that didn't pass the fold dependency test and are hidden.
140
-		 *
141
-		 * @var null|array
142
-		 */
143
-		public static ?array $fields_hidden = array();
144
-
145
-		/**
146
-		 * Values to generate google font CSS.
147
-		 *
148
-		 * @var null|array
149
-		 */
150
-		public static ?array $typography = array();
151
-
152
-		/**
153
-		 * Validation ran flag.
154
-		 *
155
-		 * @var bool
156
-		 */
157
-		public static bool $validation_ran = false;
158
-
159
-		/**
160
-		 * No output flag.
161
-		 *
162
-		 * @var bool
163
-		 */
164
-		public static bool $no_output = false;
165
-
166
-		/**
167
-		 * Array of fonts used by the panel for localization.
168
-		 *
169
-		 * @var null|array
170
-		 */
171
-		public static ?array $fonts = array();
172
-
173
-		/**
174
-		 * Array of Google fonts used by the panel for localization.
175
-		 *
176
-		 * @var null|array
177
-		 */
178
-		public static ?array $google_array = array();
179
-
180
-		/**
181
-		 * Array of various font groups used within the typography field.
182
-		 *
183
-		 * @var null|array
184
-		 */
185
-		public static ?array $font_groups = array();
186
-
187
-		/**
188
-		 * File system object used for I/O file operations.  Done the WordPress way.
189
-		 *
190
-		 * @var null|object
191
-		 */
192
-		public static ?object $filesystem;
193
-
194
-		/**
195
-		 * Pointer to the third party fixes class.
196
-		 *
197
-		 * @var Redux_ThirdParty_Fixes
198
-		 */
199
-		public static Redux_ThirdParty_Fixes $third_party_fixes;
200
-
201
-		/**
202
-		 * Redux Welcome screen object.
203
-		 *
204
-		 * @var Redux_Welcome
205
-		 */
206
-		public static Redux_Welcome $welcome;
207
-
208
-		/**
209
-		 * Creates instance of class.
210
-		 *
211
-		 * @return Redux_Core
212
-		 * @throws Exception Comment.
213
-		 */
214
-		public static function instance(): ?Redux_Core {
215
-			if ( ! self::$instance ) {
216
-				self::$instance = new self();
217
-
218
-				self::$instance->includes();
219
-				self::$instance->init();
220
-				self::$instance->hooks();
221
-
222
-				add_action( 'plugins_loaded', array( 'Redux_Core', 'plugins_loaded' ) );
223
-			}
224
-
225
-			return self::$instance;
226
-		}
227
-
228
-		/**
229
-		 * Things to run after pluggable.php had loaded.
230
-		 */
231
-		public static function plugins_loaded() {}
232
-
233
-		/**
234
-		 * Class init.
235
-		 */
236
-		private function init() {
237
-			self::$server = array(
238
-				'SERVER_SOFTWARE' => '',
239
-				'REMOTE_ADDR'     => Redux_Helpers::is_local_host() ? '127.0.0.1' : '',
240
-				'HTTP_USER_AGENT' => '',
241
-				'HTTP_HOST'       => '',
242
-				'REQUEST_URI'     => '',
243
-			);
244
-
245
-			// phpcs:disable WordPress.NamingConventions.ValidVariableName.VariableNotSnakeCase
246
-			if ( ! empty( $_SERVER['SERVER_SOFTWARE'] ) ) {
247
-				self::$server['SERVER_SOFTWARE'] = sanitize_text_field( wp_unslash( $_SERVER['SERVER_SOFTWARE'] ) );
248
-			}
249
-			if ( ! empty( $_SERVER['REMOTE_ADDR'] ) ) {
250
-				self::$server['REMOTE_ADDR'] = sanitize_text_field( wp_unslash( $_SERVER['REMOTE_ADDR'] ) );
251
-			}
252
-			if ( ! empty( $_SERVER['HTTP_USER_AGENT'] ) ) {
253
-				self::$server['HTTP_USER_AGENT'] = sanitize_text_field( wp_unslash( $_SERVER['HTTP_USER_AGENT'] ) );
254
-			}
255
-			if ( ! empty( $_SERVER['HTTP_HOST'] ) ) {
256
-				self::$server['HTTP_HOST'] = sanitize_text_field( wp_unslash( $_SERVER['HTTP_HOST'] ) );
257
-			}
258
-			if ( ! empty( $_SERVER['REQUEST_URI'] ) ) {
259
-				self::$server['REQUEST_URI'] = sanitize_text_field( wp_unslash( $_SERVER['REQUEST_URI'] ) );
260
-			}
261
-
262
-			// phpcs:enable
263
-
264
-			self::$dir = trailingslashit( wp_normalize_path( dirname( realpath( __FILE__ ) ) ) );
265
-
266
-			Redux_Functions_Ex::generator();
267
-
268
-			if ( defined( 'REDUX_PLUGIN_FILE' ) ) {
269
-				$plugin_info = Redux_Functions_Ex::is_inside_plugin( REDUX_PLUGIN_FILE );
270
-			}
271
-
272
-			$plugin_info = Redux_Functions_Ex::is_inside_plugin( __FILE__ );
273
-
274
-			if ( false !== $plugin_info ) {
275
-				self::$installed = class_exists( 'Redux_Framework_Plugin' ) ? 'plugin' : 'in_plugin';
276
-				self::$is_plugin = class_exists( 'Redux_Framework_Plugin' );
277
-				self::$as_plugin = true;
278
-				self::$url       = trailingslashit( dirname( $plugin_info['url'] ) );
279
-			} else {
280
-				$theme_info = Redux_Functions_Ex::is_inside_theme( __FILE__ );
281
-				if ( false !== $theme_info ) {
282
-					self::$url       = trailingslashit( dirname( $theme_info['url'] ) );
283
-					self::$in_theme  = true;
284
-					self::$installed = 'in_theme';
285
-				}
286
-			}
287
-
288
-			// phpcs:ignore WordPress.NamingConventions.ValidHookName
289
-			self::$url = apply_filters( 'redux/url', self::$url );
290
-
291
-			// phpcs:ignore WordPress.NamingConventions.ValidHookName
292
-			self::$dir = apply_filters( 'redux/dir', self::$dir );
293
-
294
-			// phpcs:ignore WordPress.NamingConventions.ValidHookName
295
-			self::$is_plugin = apply_filters( 'redux/is_plugin', self::$is_plugin );
296
-
297
-			if ( ! function_exists( 'current_time' ) ) {
298
-				require_once ABSPATH . '/wp-includes/functions.php';
299
-			}
300
-
301
-			$upload_dir       = wp_upload_dir();
302
-			self::$upload_dir = $upload_dir['basedir'] . '/redux/';
303
-			self::$upload_url = str_replace( array( 'https://', 'http://' ), '//', $upload_dir['baseurl'] . '/redux/' );
304
-
305
-			// phpcs:ignore WordPress.NamingConventions.ValidHookName
306
-			self::$upload_dir = apply_filters( 'redux/upload_dir', self::$upload_dir );
307
-
308
-			// phpcs:ignore WordPress.NamingConventions.ValidHookName
309
-			self::$upload_url = apply_filters( 'redux/upload_url', self::$upload_url );
310
-		}
311
-
312
-		/**
313
-		 * Code to execute on a framework __construct.
314
-		 *
315
-		 * @param ReduxFramework $redux Pointer to ReduxFramework object.
316
-		 */
317
-		public static function core_construct( ReduxFramework $redux ) {
318
-			self::$third_party_fixes = new Redux_ThirdParty_Fixes( $redux );
319
-
320
-			Redux_ThemeCheck::get_instance();
321
-		}
322
-
323
-		/**
324
-		 * Autoregister run.
325
-		 *
326
-		 * @throws Exception Comment.
327
-		 */
328
-		private function includes() {
329
-			if ( is_admin() ) {
330
-				if ( class_exists( 'Redux_Pro' ) && isset( Redux_Pro::$dir ) ) {
331
-					echo '<div class="error"><p>' . sprintf( esc_html__( 'Redux has detected the Redux Pro plugin is enabled. All featured of Redux Pro are now part of the entire Redux plugin and is no longer required. Please disable the Redux Pro plugin to avoid potential conflicts.', 'redux-framework' ), '<code></code>' ) . '</p></div>';
332
-				}
333
-			}
334
-
335
-			require_once __DIR__ . '/inc/classes/class-redux-path.php';
336
-			require_once __DIR__ . '/inc/classes/class-redux-functions-ex.php';
337
-			require_once __DIR__ . '/inc/classes/class-redux-helpers.php';
338
-			require_once __DIR__ . '/inc/classes/class-redux-instances.php';
339
-
340
-			Redux_Functions_Ex::register_class_path( 'Redux', __DIR__ . '/inc/classes' );
341
-			Redux_Functions_Ex::register_class_path( 'Redux', __DIR__ . '/inc/welcome' );
342
-
343
-			spl_autoload_register( array( $this, 'register_classes' ) );
344
-
345
-			self::$welcome = new Redux_Welcome();
346
-
347
-			add_filter( 'debug_information', array( $this, 'add_debug_info' ) );
348
-		}
349
-
350
-		/**
351
-		 * Add debug info for the WP Site Health screen.
352
-		 *
353
-		 * @param array $debug_info Debug data.
354
-		 *
355
-		 * @return array
356
-		 * @throws ReflectionException Exception.
357
-		 */
358
-		public function add_debug_info( array $debug_info ): array {
359
-
360
-			// Get browser data.
361
-			if ( ! class_exists( 'ReduxBrowser' ) ) {
362
-				require_once self::$dir . 'inc/lib/browser.php';
363
-			}
364
-
365
-			$browser = new ReduxBrowser();
366
-
367
-			$browser_data = array(
368
-				'Agent'    => $browser->getUserAgent(),
369
-				'Browser'  => $browser->getBrowser(),
370
-				'Version'  => $browser->getVersion(),
371
-				'Platform' => $browser->getPlatform(),
372
-			);
373
-
374
-			// Set Redux dir permission results to Site Health screen.
375
-			$debug_info['wp-filesystem']['fields'][] = array(
376
-				'label' => esc_html__( 'The Redux upload directory', 'redux-framework' ),
377
-				'value' => wp_is_writable( self::$upload_dir ) ? 'Writable' : 'Not writable',
378
-			);
379
-
380
-			// Set Redux plugin results to Site Health screen.
381
-			$debug_info['redux-framework'] = array(
382
-				'label'       => esc_html__( 'Redux Framework', 'redux-framework' ),
383
-				'description' => esc_html__( 'Debug information specific to Redux Framework.', 'redux-framework' ),
384
-				'fields'      => array(
385
-					'version'        => array(
386
-						'label' => esc_html__( 'Version', 'redux-framework' ),
387
-						'value' => self::$version,
388
-					),
389
-					'installation'   => array(
390
-						'label' => esc_html__( 'Installation', 'redux-framework' ),
391
-						'value' => self::$installed,
392
-					),
393
-					'data directory' => array(
394
-						'label' => esc_html__( 'Data directory', 'redux-framework' ),
395
-						'value' => self::$dir,
396
-					),
397
-					'browser'        => array(
398
-						'label' => esc_html__( 'Browser', 'redux-framework' ),
399
-						'value' => $browser_data,
400
-					),
401
-				),
402
-			);
403
-
404
-			$redux = Redux::all_instances();
405
-
406
-			$extensions = array();
407
-
408
-			if ( ! empty( $redux ) && is_array( $redux ) ) {
409
-				foreach ( $redux as $inst => $data ) {
410
-					Redux::init( $inst );
411
-
412
-					$inst_name = ucwords( str_replace( array( '_', '-' ), ' ', $inst ) );
413
-					$args      = $data->args;
414
-
415
-					$ext = Redux::get_extensions( $inst );
416
-					if ( ! empty( $ext ) && is_array( $ext ) ) {
417
-						ksort( $ext );
418
-
419
-						foreach ( $ext as $name => $arr ) {
420
-							$ver = $arr['version'];
421
-
422
-							$ex = esc_html( ucwords( str_replace( array( '_', '-' ), ' ', $name ) ) );
423
-
424
-							$extensions[ $ex ] = esc_html( $ver );
425
-						}
426
-					}
427
-
428
-					// Output Redux instances.
429
-					$debug_info[ 'redux-instance-' . $inst ] = array(
430
-						// translators: %s = Instance name.
431
-						'label'       => sprintf( esc_html__( 'Redux Instance: %s', 'redux-framework' ), $inst_name ),
432
-						// translators: %s = Instance name w/ HTML.
433
-						'description' => sprintf( esc_html__( 'Debug information for the %s Redux instance.', 'redux-framework' ), '<code>' . $inst . '</code>' ),
434
-						'fields'      => array(
435
-							'opt_name'         => array(
436
-								'label' => esc_html( 'opt_name' ),
437
-								'value' => $args['opt_name'],
438
-							),
439
-							'global_variable'  => array(
440
-								'label' => esc_html( 'global_variable' ),
441
-								'value' => $args['global_variable'],
442
-							),
443
-							'dev_mode'         => array(
444
-								'label' => esc_html( 'dev_mode' ),
445
-								'value' => $args['dev_mode'] ? 'true' : 'false',
446
-							),
447
-							'ajax_save'        => array(
448
-								'label' => esc_html( 'ajax_save' ),
449
-								'value' => $args['ajax_save'] ? 'true' : 'false',
450
-							),
451
-							'page_slug'        => array(
452
-								'label' => esc_html( 'page_slug' ),
453
-								'value' => $args['page_slug'],
454
-							),
455
-							'page_permissions' => array(
456
-								'label' => esc_html( 'page_permissions' ),
457
-								'value' => $args['page_permissions'],
458
-							),
459
-							'menu_type'        => array(
460
-								'label' => esc_html( 'menu_type' ),
461
-								'value' => $args['menu_type'],
462
-							),
463
-							'page_parent'      => array(
464
-								'label' => esc_html( 'page_parent' ),
465
-								'value' => $args['page_parent'],
466
-							),
467
-							'compiler'         => array(
468
-								'label' => esc_html( 'compiler' ),
469
-								'value' => $args['compiler'] ? 'true' : 'false',
470
-							),
471
-							'output'           => array(
472
-								'label' => esc_html( 'output' ),
473
-								'value' => $args['output'] ? 'true' : 'false',
474
-							),
475
-							'output_tag'       => array(
476
-								'label' => esc_html( 'output_tag' ),
477
-								'value' => $args['output_tag'] ? 'true' : 'false',
478
-							),
479
-							'templates_path'   => array(
480
-								'label' => esc_html( 'templates_path' ),
481
-								'value' => $args['templates_path'],
482
-							),
483
-							'extensions'       => array(
484
-								'label' => esc_html( 'extensions' ),
485
-								'value' => $extensions,
486
-							),
487
-						),
488
-					);
489
-				}
490
-			}
491
-
492
-			return $debug_info;
493
-		}
494
-
495
-		/**
496
-		 * Register callback for autoload.
497
-		 *
498
-		 * @param string $class_name name of class.
499
-		 */
500
-		public function register_classes( string $class_name ) {
501
-			$class_name_test = self::strtolower( $class_name );
502
-
503
-			if ( strpos( $class_name_test, 'redux' ) === false ) {
504
-				return;
505
-			}
506
-
507
-			if ( ! class_exists( 'Redux_Functions_Ex' ) ) {
508
-				require_once Redux_Path::get_path( '/inc/classes/class-redux-functions-ex.php' );
509
-			}
510
-
511
-			if ( ! class_exists( $class_name ) ) {
512
-				// Backward compatibility for extensions sucks!
513
-				if ( 'Redux_Instances' === $class_name ) {
514
-					require_once Redux_Path::get_path( '/inc/classes/class-redux-instances.php' );
515
-					require_once Redux_Path::get_path( '/inc/lib/redux-instances.php' );
516
-
517
-					return;
518
-				}
519
-
520
-				// Load Redux APIs.
521
-				if ( 'Redux' === $class_name ) {
522
-					require_once Redux_Path::get_path( '/inc/classes/class-redux-api.php' );
523
-
524
-					return;
525
-				}
526
-
527
-				// Redux extra theme checks.
528
-				if ( 'Redux_ThemeCheck' === $class_name ) {
529
-					require_once Redux_Path::get_path( '/inc/themecheck/class-redux-themecheck.php' );
530
-
531
-					return;
532
-				}
533
-
534
-				if ( 'Redux_Welcome' === $class_name ) {
535
-					require_once Redux_Path::get_path( '/inc/welcome/class-redux-welcome.php' );
536
-
537
-					return;
538
-				}
539
-
540
-				$mappings = array(
541
-					'ReduxFrameworkInstances'  => 'Redux_Instances',
542
-					'reduxCorePanel'           => 'Redux_Panel',
543
-					'reduxCoreEnqueue'         => 'Redux_Enqueue',
544
-					'Redux_Abstract_Extension' => 'Redux_Extension_Abstract',
545
-				);
546
-				$alias    = false;
547
-				if ( isset( $mappings[ $class_name ] ) ) {
548
-					$alias      = $class_name;
549
-					$class_name = $mappings[ $class_name ];
550
-				}
551
-
552
-				// Everything else.
553
-				$file = 'class.' . $class_name_test . '.php';
554
-
555
-				$class_path = Redux_Path::get_path( '/inc/classes/' . $file );
556
-
557
-				if ( ! file_exists( $class_path ) ) {
558
-					$class_file_name = str_replace( '_', '-', $class_name );
559
-					$file            = 'class-' . $class_name_test . '.php';
560
-					$class_path      = Redux_Path::get_path( '/inc/classes/' . $file );
561
-				}
562
-
563
-				if ( file_exists( $class_path ) && ! class_exists( $class_name ) ) {
564
-					require_once $class_path;
565
-				}
566
-				if ( class_exists( $class_name ) && ! empty( $alias ) && ! class_exists( $alias ) ) {
567
-					class_alias( $class_name, $alias );
568
-				}
569
-			}
570
-
571
-			// phpcs:ignore WordPress.NamingConventions.ValidHookName
572
-			do_action( 'redux/core/includes', $this );
573
-		}
574
-
575
-		/**
576
-		 * Hooks to run on instance creation.
577
-		 */
578
-		private function hooks() {
579
-			// phpcs:ignore WordPress.NamingConventions.ValidHookName
580
-			do_action( 'redux/core/hooks', $this );
581
-		}
582
-
583
-		/**
584
-		 * Action to run on WordPress heartbeat.
585
-		 *
586
-		 * @return bool
587
-		 */
588
-		public static function is_heartbeat(): bool {
589
-			// Disregard WP AJAX 'heartbeat' call.  Why waste resources?
590
-			if ( isset( $_POST ) && isset( $_POST['_nonce'] ) && wp_verify_nonce( sanitize_key( wp_unslash( $_POST['_nonce'] ) ), 'heartbeat-nonce' ) ) {
591
-
592
-				if ( isset( $_POST['action'] ) && 'heartbeat' === sanitize_text_field( wp_unslash( $_POST['action'] ) ) ) {
593
-
594
-					// Hook, for purists.
595
-					if ( has_action( 'redux/ajax/heartbeat' ) ) {
596
-						// phpcs:ignore WordPress.NamingConventions.ValidHookName
597
-						do_action( 'redux/ajax/heartbeat' );
598
-					}
599
-
600
-					return true;
601
-				}
602
-
603
-				return false;
604
-			}
605
-
606
-			// Buh bye!
607
-			return false;
608
-		}
609
-
610
-		/**
611
-		 * Helper method to check for mb_strtolower or to use the standard strtolower.
612
-		 *
613
-		 * @param string|null $str String to make lowercase.
614
-		 *
615
-		 * @return string|null
616
-		 */
617
-		public static function strtolower( ?string $str ): string {
618
-			if ( function_exists( 'mb_strtolower' ) && function_exists( 'mb_detect_encoding' ) ) {
619
-				return mb_strtolower( $str, mb_detect_encoding( $str ) );
620
-			} else {
621
-				return strtolower( $str );
622
-			}
623
-		}
624
-	}
625
-
626
-	/*
14
+    /**
15
+     * Class Redux_Core
16
+     */
17
+    class Redux_Core {
18
+
19
+        /**
20
+         * Class instance.
21
+         *
22
+         * @var null|Redux_Core
23
+         */
24
+        public static ?Redux_Core $instance = null;
25
+
26
+        /**
27
+         * Project version
28
+         *
29
+         * @var string
30
+         */
31
+        public static string $version;
32
+
33
+        /**
34
+         * Project directory.
35
+         *
36
+         * @var string.
37
+         */
38
+        public static string $dir;
39
+
40
+        /**
41
+         * Project URL.
42
+         *
43
+         * @var string.
44
+         */
45
+        public static string $url;
46
+
47
+        /**
48
+         * Base directory path.
49
+         *
50
+         * @var string
51
+         */
52
+        public static string $redux_path;
53
+
54
+        /**
55
+         * Absolute direction path to WordPress upload directory.
56
+         *
57
+         * @var string
58
+         */
59
+        public static string $upload_dir = '';
60
+
61
+        /**
62
+         * Full URL to WordPress upload directory.
63
+         *
64
+         * @var null|string
65
+         */
66
+        public static ?string $upload_url = '';
67
+
68
+        /**
69
+         * Set when Redux is run as a plugin.
70
+         *
71
+         * @var bool
72
+         */
73
+        public static bool $is_plugin = true;
74
+
75
+        /**
76
+         * Indicated in_theme or in_plugin.
77
+         *
78
+         * @var string
79
+         */
80
+        public static string $installed = '';
81
+
82
+        /**
83
+         * Set when Redux is run as a plugin.
84
+         *
85
+         * @var bool
86
+         */
87
+        public static bool $as_plugin = false;
88
+
89
+        /**
90
+         * Set when Redux is embedded within a theme.
91
+         *
92
+         * @var bool
93
+         */
94
+        public static bool $in_theme = false;
95
+
96
+        /**
97
+         * Pointer to an updated Google fonts array.
98
+         *
99
+         * @var array|null
100
+         */
101
+        public static ?array $updated_google_fonts = array();
102
+
103
+        /**
104
+         * List of files calling Redux.
105
+         *
106
+         * @var array|null
107
+         */
108
+        public static ?array $callers = array();
109
+
110
+        /**
111
+         * Pointer to _SERVER global.
112
+         *
113
+         * @var array|null
114
+         */
115
+        public static ?array $server = array();
116
+
117
+        /**
118
+         * Field folding information for localization.
119
+         *
120
+         * @var null|array
121
+         */
122
+        public static ?array $required = array();
123
+
124
+        /**
125
+         * Field child-folding information for localization.
126
+         *
127
+         * @var null|array
128
+         */
129
+        public static ?array $required_child = array();
130
+
131
+        /**
132
+         * Array of fields to be folded.
133
+         *
134
+         * @var array|null
135
+         */
136
+        public static ?array $folds = array();
137
+
138
+        /**
139
+         * Array of fields that didn't pass the fold dependency test and are hidden.
140
+         *
141
+         * @var null|array
142
+         */
143
+        public static ?array $fields_hidden = array();
144
+
145
+        /**
146
+         * Values to generate google font CSS.
147
+         *
148
+         * @var null|array
149
+         */
150
+        public static ?array $typography = array();
151
+
152
+        /**
153
+         * Validation ran flag.
154
+         *
155
+         * @var bool
156
+         */
157
+        public static bool $validation_ran = false;
158
+
159
+        /**
160
+         * No output flag.
161
+         *
162
+         * @var bool
163
+         */
164
+        public static bool $no_output = false;
165
+
166
+        /**
167
+         * Array of fonts used by the panel for localization.
168
+         *
169
+         * @var null|array
170
+         */
171
+        public static ?array $fonts = array();
172
+
173
+        /**
174
+         * Array of Google fonts used by the panel for localization.
175
+         *
176
+         * @var null|array
177
+         */
178
+        public static ?array $google_array = array();
179
+
180
+        /**
181
+         * Array of various font groups used within the typography field.
182
+         *
183
+         * @var null|array
184
+         */
185
+        public static ?array $font_groups = array();
186
+
187
+        /**
188
+         * File system object used for I/O file operations.  Done the WordPress way.
189
+         *
190
+         * @var null|object
191
+         */
192
+        public static ?object $filesystem;
193
+
194
+        /**
195
+         * Pointer to the third party fixes class.
196
+         *
197
+         * @var Redux_ThirdParty_Fixes
198
+         */
199
+        public static Redux_ThirdParty_Fixes $third_party_fixes;
200
+
201
+        /**
202
+         * Redux Welcome screen object.
203
+         *
204
+         * @var Redux_Welcome
205
+         */
206
+        public static Redux_Welcome $welcome;
207
+
208
+        /**
209
+         * Creates instance of class.
210
+         *
211
+         * @return Redux_Core
212
+         * @throws Exception Comment.
213
+         */
214
+        public static function instance(): ?Redux_Core {
215
+            if ( ! self::$instance ) {
216
+                self::$instance = new self();
217
+
218
+                self::$instance->includes();
219
+                self::$instance->init();
220
+                self::$instance->hooks();
221
+
222
+                add_action( 'plugins_loaded', array( 'Redux_Core', 'plugins_loaded' ) );
223
+            }
224
+
225
+            return self::$instance;
226
+        }
227
+
228
+        /**
229
+         * Things to run after pluggable.php had loaded.
230
+         */
231
+        public static function plugins_loaded() {}
232
+
233
+        /**
234
+         * Class init.
235
+         */
236
+        private function init() {
237
+            self::$server = array(
238
+                'SERVER_SOFTWARE' => '',
239
+                'REMOTE_ADDR'     => Redux_Helpers::is_local_host() ? '127.0.0.1' : '',
240
+                'HTTP_USER_AGENT' => '',
241
+                'HTTP_HOST'       => '',
242
+                'REQUEST_URI'     => '',
243
+            );
244
+
245
+            // phpcs:disable WordPress.NamingConventions.ValidVariableName.VariableNotSnakeCase
246
+            if ( ! empty( $_SERVER['SERVER_SOFTWARE'] ) ) {
247
+                self::$server['SERVER_SOFTWARE'] = sanitize_text_field( wp_unslash( $_SERVER['SERVER_SOFTWARE'] ) );
248
+            }
249
+            if ( ! empty( $_SERVER['REMOTE_ADDR'] ) ) {
250
+                self::$server['REMOTE_ADDR'] = sanitize_text_field( wp_unslash( $_SERVER['REMOTE_ADDR'] ) );
251
+            }
252
+            if ( ! empty( $_SERVER['HTTP_USER_AGENT'] ) ) {
253
+                self::$server['HTTP_USER_AGENT'] = sanitize_text_field( wp_unslash( $_SERVER['HTTP_USER_AGENT'] ) );
254
+            }
255
+            if ( ! empty( $_SERVER['HTTP_HOST'] ) ) {
256
+                self::$server['HTTP_HOST'] = sanitize_text_field( wp_unslash( $_SERVER['HTTP_HOST'] ) );
257
+            }
258
+            if ( ! empty( $_SERVER['REQUEST_URI'] ) ) {
259
+                self::$server['REQUEST_URI'] = sanitize_text_field( wp_unslash( $_SERVER['REQUEST_URI'] ) );
260
+            }
261
+
262
+            // phpcs:enable
263
+
264
+            self::$dir = trailingslashit( wp_normalize_path( dirname( realpath( __FILE__ ) ) ) );
265
+
266
+            Redux_Functions_Ex::generator();
267
+
268
+            if ( defined( 'REDUX_PLUGIN_FILE' ) ) {
269
+                $plugin_info = Redux_Functions_Ex::is_inside_plugin( REDUX_PLUGIN_FILE );
270
+            }
271
+
272
+            $plugin_info = Redux_Functions_Ex::is_inside_plugin( __FILE__ );
273
+
274
+            if ( false !== $plugin_info ) {
275
+                self::$installed = class_exists( 'Redux_Framework_Plugin' ) ? 'plugin' : 'in_plugin';
276
+                self::$is_plugin = class_exists( 'Redux_Framework_Plugin' );
277
+                self::$as_plugin = true;
278
+                self::$url       = trailingslashit( dirname( $plugin_info['url'] ) );
279
+            } else {
280
+                $theme_info = Redux_Functions_Ex::is_inside_theme( __FILE__ );
281
+                if ( false !== $theme_info ) {
282
+                    self::$url       = trailingslashit( dirname( $theme_info['url'] ) );
283
+                    self::$in_theme  = true;
284
+                    self::$installed = 'in_theme';
285
+                }
286
+            }
287
+
288
+            // phpcs:ignore WordPress.NamingConventions.ValidHookName
289
+            self::$url = apply_filters( 'redux/url', self::$url );
290
+
291
+            // phpcs:ignore WordPress.NamingConventions.ValidHookName
292
+            self::$dir = apply_filters( 'redux/dir', self::$dir );
293
+
294
+            // phpcs:ignore WordPress.NamingConventions.ValidHookName
295
+            self::$is_plugin = apply_filters( 'redux/is_plugin', self::$is_plugin );
296
+
297
+            if ( ! function_exists( 'current_time' ) ) {
298
+                require_once ABSPATH . '/wp-includes/functions.php';
299
+            }
300
+
301
+            $upload_dir       = wp_upload_dir();
302
+            self::$upload_dir = $upload_dir['basedir'] . '/redux/';
303
+            self::$upload_url = str_replace( array( 'https://', 'http://' ), '//', $upload_dir['baseurl'] . '/redux/' );
304
+
305
+            // phpcs:ignore WordPress.NamingConventions.ValidHookName
306
+            self::$upload_dir = apply_filters( 'redux/upload_dir', self::$upload_dir );
307
+
308
+            // phpcs:ignore WordPress.NamingConventions.ValidHookName
309
+            self::$upload_url = apply_filters( 'redux/upload_url', self::$upload_url );
310
+        }
311
+
312
+        /**
313
+         * Code to execute on a framework __construct.
314
+         *
315
+         * @param ReduxFramework $redux Pointer to ReduxFramework object.
316
+         */
317
+        public static function core_construct( ReduxFramework $redux ) {
318
+            self::$third_party_fixes = new Redux_ThirdParty_Fixes( $redux );
319
+
320
+            Redux_ThemeCheck::get_instance();
321
+        }
322
+
323
+        /**
324
+         * Autoregister run.
325
+         *
326
+         * @throws Exception Comment.
327
+         */
328
+        private function includes() {
329
+            if ( is_admin() ) {
330
+                if ( class_exists( 'Redux_Pro' ) && isset( Redux_Pro::$dir ) ) {
331
+                    echo '<div class="error"><p>' . sprintf( esc_html__( 'Redux has detected the Redux Pro plugin is enabled. All featured of Redux Pro are now part of the entire Redux plugin and is no longer required. Please disable the Redux Pro plugin to avoid potential conflicts.', 'redux-framework' ), '<code></code>' ) . '</p></div>';
332
+                }
333
+            }
334
+
335
+            require_once __DIR__ . '/inc/classes/class-redux-path.php';
336
+            require_once __DIR__ . '/inc/classes/class-redux-functions-ex.php';
337
+            require_once __DIR__ . '/inc/classes/class-redux-helpers.php';
338
+            require_once __DIR__ . '/inc/classes/class-redux-instances.php';
339
+
340
+            Redux_Functions_Ex::register_class_path( 'Redux', __DIR__ . '/inc/classes' );
341
+            Redux_Functions_Ex::register_class_path( 'Redux', __DIR__ . '/inc/welcome' );
342
+
343
+            spl_autoload_register( array( $this, 'register_classes' ) );
344
+
345
+            self::$welcome = new Redux_Welcome();
346
+
347
+            add_filter( 'debug_information', array( $this, 'add_debug_info' ) );
348
+        }
349
+
350
+        /**
351
+         * Add debug info for the WP Site Health screen.
352
+         *
353
+         * @param array $debug_info Debug data.
354
+         *
355
+         * @return array
356
+         * @throws ReflectionException Exception.
357
+         */
358
+        public function add_debug_info( array $debug_info ): array {
359
+
360
+            // Get browser data.
361
+            if ( ! class_exists( 'ReduxBrowser' ) ) {
362
+                require_once self::$dir . 'inc/lib/browser.php';
363
+            }
364
+
365
+            $browser = new ReduxBrowser();
366
+
367
+            $browser_data = array(
368
+                'Agent'    => $browser->getUserAgent(),
369
+                'Browser'  => $browser->getBrowser(),
370
+                'Version'  => $browser->getVersion(),
371
+                'Platform' => $browser->getPlatform(),
372
+            );
373
+
374
+            // Set Redux dir permission results to Site Health screen.
375
+            $debug_info['wp-filesystem']['fields'][] = array(
376
+                'label' => esc_html__( 'The Redux upload directory', 'redux-framework' ),
377
+                'value' => wp_is_writable( self::$upload_dir ) ? 'Writable' : 'Not writable',
378
+            );
379
+
380
+            // Set Redux plugin results to Site Health screen.
381
+            $debug_info['redux-framework'] = array(
382
+                'label'       => esc_html__( 'Redux Framework', 'redux-framework' ),
383
+                'description' => esc_html__( 'Debug information specific to Redux Framework.', 'redux-framework' ),
384
+                'fields'      => array(
385
+                    'version'        => array(
386
+                        'label' => esc_html__( 'Version', 'redux-framework' ),
387
+                        'value' => self::$version,
388
+                    ),
389
+                    'installation'   => array(
390
+                        'label' => esc_html__( 'Installation', 'redux-framework' ),
391
+                        'value' => self::$installed,
392
+                    ),
393
+                    'data directory' => array(
394
+                        'label' => esc_html__( 'Data directory', 'redux-framework' ),
395
+                        'value' => self::$dir,
396
+                    ),
397
+                    'browser'        => array(
398
+                        'label' => esc_html__( 'Browser', 'redux-framework' ),
399
+                        'value' => $browser_data,
400
+                    ),
401
+                ),
402
+            );
403
+
404
+            $redux = Redux::all_instances();
405
+
406
+            $extensions = array();
407
+
408
+            if ( ! empty( $redux ) && is_array( $redux ) ) {
409
+                foreach ( $redux as $inst => $data ) {
410
+                    Redux::init( $inst );
411
+
412
+                    $inst_name = ucwords( str_replace( array( '_', '-' ), ' ', $inst ) );
413
+                    $args      = $data->args;
414
+
415
+                    $ext = Redux::get_extensions( $inst );
416
+                    if ( ! empty( $ext ) && is_array( $ext ) ) {
417
+                        ksort( $ext );
418
+
419
+                        foreach ( $ext as $name => $arr ) {
420
+                            $ver = $arr['version'];
421
+
422
+                            $ex = esc_html( ucwords( str_replace( array( '_', '-' ), ' ', $name ) ) );
423
+
424
+                            $extensions[ $ex ] = esc_html( $ver );
425
+                        }
426
+                    }
427
+
428
+                    // Output Redux instances.
429
+                    $debug_info[ 'redux-instance-' . $inst ] = array(
430
+                        // translators: %s = Instance name.
431
+                        'label'       => sprintf( esc_html__( 'Redux Instance: %s', 'redux-framework' ), $inst_name ),
432
+                        // translators: %s = Instance name w/ HTML.
433
+                        'description' => sprintf( esc_html__( 'Debug information for the %s Redux instance.', 'redux-framework' ), '<code>' . $inst . '</code>' ),
434
+                        'fields'      => array(
435
+                            'opt_name'         => array(
436
+                                'label' => esc_html( 'opt_name' ),
437
+                                'value' => $args['opt_name'],
438
+                            ),
439
+                            'global_variable'  => array(
440
+                                'label' => esc_html( 'global_variable' ),
441
+                                'value' => $args['global_variable'],
442
+                            ),
443
+                            'dev_mode'         => array(
444
+                                'label' => esc_html( 'dev_mode' ),
445
+                                'value' => $args['dev_mode'] ? 'true' : 'false',
446
+                            ),
447
+                            'ajax_save'        => array(
448
+                                'label' => esc_html( 'ajax_save' ),
449
+                                'value' => $args['ajax_save'] ? 'true' : 'false',
450
+                            ),
451
+                            'page_slug'        => array(
452
+                                'label' => esc_html( 'page_slug' ),
453
+                                'value' => $args['page_slug'],
454
+                            ),
455
+                            'page_permissions' => array(
456
+                                'label' => esc_html( 'page_permissions' ),
457
+                                'value' => $args['page_permissions'],
458
+                            ),
459
+                            'menu_type'        => array(
460
+                                'label' => esc_html( 'menu_type' ),
461
+                                'value' => $args['menu_type'],
462
+                            ),
463
+                            'page_parent'      => array(
464
+                                'label' => esc_html( 'page_parent' ),
465
+                                'value' => $args['page_parent'],
466
+                            ),
467
+                            'compiler'         => array(
468
+                                'label' => esc_html( 'compiler' ),
469
+                                'value' => $args['compiler'] ? 'true' : 'false',
470
+                            ),
471
+                            'output'           => array(
472
+                                'label' => esc_html( 'output' ),
473
+                                'value' => $args['output'] ? 'true' : 'false',
474
+                            ),
475
+                            'output_tag'       => array(
476
+                                'label' => esc_html( 'output_tag' ),
477
+                                'value' => $args['output_tag'] ? 'true' : 'false',
478
+                            ),
479
+                            'templates_path'   => array(
480
+                                'label' => esc_html( 'templates_path' ),
481
+                                'value' => $args['templates_path'],
482
+                            ),
483
+                            'extensions'       => array(
484
+                                'label' => esc_html( 'extensions' ),
485
+                                'value' => $extensions,
486
+                            ),
487
+                        ),
488
+                    );
489
+                }
490
+            }
491
+
492
+            return $debug_info;
493
+        }
494
+
495
+        /**
496
+         * Register callback for autoload.
497
+         *
498
+         * @param string $class_name name of class.
499
+         */
500
+        public function register_classes( string $class_name ) {
501
+            $class_name_test = self::strtolower( $class_name );
502
+
503
+            if ( strpos( $class_name_test, 'redux' ) === false ) {
504
+                return;
505
+            }
506
+
507
+            if ( ! class_exists( 'Redux_Functions_Ex' ) ) {
508
+                require_once Redux_Path::get_path( '/inc/classes/class-redux-functions-ex.php' );
509
+            }
510
+
511
+            if ( ! class_exists( $class_name ) ) {
512
+                // Backward compatibility for extensions sucks!
513
+                if ( 'Redux_Instances' === $class_name ) {
514
+                    require_once Redux_Path::get_path( '/inc/classes/class-redux-instances.php' );
515
+                    require_once Redux_Path::get_path( '/inc/lib/redux-instances.php' );
516
+
517
+                    return;
518
+                }
519
+
520
+                // Load Redux APIs.
521
+                if ( 'Redux' === $class_name ) {
522
+                    require_once Redux_Path::get_path( '/inc/classes/class-redux-api.php' );
523
+
524
+                    return;
525
+                }
526
+
527
+                // Redux extra theme checks.
528
+                if ( 'Redux_ThemeCheck' === $class_name ) {
529
+                    require_once Redux_Path::get_path( '/inc/themecheck/class-redux-themecheck.php' );
530
+
531
+                    return;
532
+                }
533
+
534
+                if ( 'Redux_Welcome' === $class_name ) {
535
+                    require_once Redux_Path::get_path( '/inc/welcome/class-redux-welcome.php' );
536
+
537
+                    return;
538
+                }
539
+
540
+                $mappings = array(
541
+                    'ReduxFrameworkInstances'  => 'Redux_Instances',
542
+                    'reduxCorePanel'           => 'Redux_Panel',
543
+                    'reduxCoreEnqueue'         => 'Redux_Enqueue',
544
+                    'Redux_Abstract_Extension' => 'Redux_Extension_Abstract',
545
+                );
546
+                $alias    = false;
547
+                if ( isset( $mappings[ $class_name ] ) ) {
548
+                    $alias      = $class_name;
549
+                    $class_name = $mappings[ $class_name ];
550
+                }
551
+
552
+                // Everything else.
553
+                $file = 'class.' . $class_name_test . '.php';
554
+
555
+                $class_path = Redux_Path::get_path( '/inc/classes/' . $file );
556
+
557
+                if ( ! file_exists( $class_path ) ) {
558
+                    $class_file_name = str_replace( '_', '-', $class_name );
559
+                    $file            = 'class-' . $class_name_test . '.php';
560
+                    $class_path      = Redux_Path::get_path( '/inc/classes/' . $file );
561
+                }
562
+
563
+                if ( file_exists( $class_path ) && ! class_exists( $class_name ) ) {
564
+                    require_once $class_path;
565
+                }
566
+                if ( class_exists( $class_name ) && ! empty( $alias ) && ! class_exists( $alias ) ) {
567
+                    class_alias( $class_name, $alias );
568
+                }
569
+            }
570
+
571
+            // phpcs:ignore WordPress.NamingConventions.ValidHookName
572
+            do_action( 'redux/core/includes', $this );
573
+        }
574
+
575
+        /**
576
+         * Hooks to run on instance creation.
577
+         */
578
+        private function hooks() {
579
+            // phpcs:ignore WordPress.NamingConventions.ValidHookName
580
+            do_action( 'redux/core/hooks', $this );
581
+        }
582
+
583
+        /**
584
+         * Action to run on WordPress heartbeat.
585
+         *
586
+         * @return bool
587
+         */
588
+        public static function is_heartbeat(): bool {
589
+            // Disregard WP AJAX 'heartbeat' call.  Why waste resources?
590
+            if ( isset( $_POST ) && isset( $_POST['_nonce'] ) && wp_verify_nonce( sanitize_key( wp_unslash( $_POST['_nonce'] ) ), 'heartbeat-nonce' ) ) {
591
+
592
+                if ( isset( $_POST['action'] ) && 'heartbeat' === sanitize_text_field( wp_unslash( $_POST['action'] ) ) ) {
593
+
594
+                    // Hook, for purists.
595
+                    if ( has_action( 'redux/ajax/heartbeat' ) ) {
596
+                        // phpcs:ignore WordPress.NamingConventions.ValidHookName
597
+                        do_action( 'redux/ajax/heartbeat' );
598
+                    }
599
+
600
+                    return true;
601
+                }
602
+
603
+                return false;
604
+            }
605
+
606
+            // Buh bye!
607
+            return false;
608
+        }
609
+
610
+        /**
611
+         * Helper method to check for mb_strtolower or to use the standard strtolower.
612
+         *
613
+         * @param string|null $str String to make lowercase.
614
+         *
615
+         * @return string|null
616
+         */
617
+        public static function strtolower( ?string $str ): string {
618
+            if ( function_exists( 'mb_strtolower' ) && function_exists( 'mb_detect_encoding' ) ) {
619
+                return mb_strtolower( $str, mb_detect_encoding( $str ) );
620
+            } else {
621
+                return strtolower( $str );
622
+            }
623
+        }
624
+    }
625
+
626
+    /*
627 627
 	 * Backwards comparability alias
628 628
 	 */
629
-	class_alias( 'Redux_Core', 'redux-core' );
629
+    class_alias( 'Redux_Core', 'redux-core' );
630 630
 }
Please login to merge, or discard this patch.
Spacing   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -98,56 +98,56 @@  discard block
 block discarded – undo
98 98
 		 *
99 99
 		 * @var array|null
100 100
 		 */
101
-		public static ?array $updated_google_fonts = array();
101
+		public static ? array $updated_google_fonts = array();
102 102
 
103 103
 		/**
104 104
 		 * List of files calling Redux.
105 105
 		 *
106 106
 		 * @var array|null
107 107
 		 */
108
-		public static ?array $callers = array();
108
+		public static ? array $callers = array();
109 109
 
110 110
 		/**
111 111
 		 * Pointer to _SERVER global.
112 112
 		 *
113 113
 		 * @var array|null
114 114
 		 */
115
-		public static ?array $server = array();
115
+		public static ? array $server = array();
116 116
 
117 117
 		/**
118 118
 		 * Field folding information for localization.
119 119
 		 *
120 120
 		 * @var null|array
121 121
 		 */
122
-		public static ?array $required = array();
122
+		public static ? array $required = array();
123 123
 
124 124
 		/**
125 125
 		 * Field child-folding information for localization.
126 126
 		 *
127 127
 		 * @var null|array
128 128
 		 */
129
-		public static ?array $required_child = array();
129
+		public static ? array $required_child = array();
130 130
 
131 131
 		/**
132 132
 		 * Array of fields to be folded.
133 133
 		 *
134 134
 		 * @var array|null
135 135
 		 */
136
-		public static ?array $folds = array();
136
+		public static ? array $folds = array();
137 137
 
138 138
 		/**
139 139
 		 * Array of fields that didn't pass the fold dependency test and are hidden.
140 140
 		 *
141 141
 		 * @var null|array
142 142
 		 */
143
-		public static ?array $fields_hidden = array();
143
+		public static ? array $fields_hidden = array();
144 144
 
145 145
 		/**
146 146
 		 * Values to generate google font CSS.
147 147
 		 *
148 148
 		 * @var null|array
149 149
 		 */
150
-		public static ?array $typography = array();
150
+		public static ? array $typography = array();
151 151
 
152 152
 		/**
153 153
 		 * Validation ran flag.
@@ -168,21 +168,21 @@  discard block
 block discarded – undo
168 168
 		 *
169 169
 		 * @var null|array
170 170
 		 */
171
-		public static ?array $fonts = array();
171
+		public static ? array $fonts = array();
172 172
 
173 173
 		/**
174 174
 		 * Array of Google fonts used by the panel for localization.
175 175
 		 *
176 176
 		 * @var null|array
177 177
 		 */
178
-		public static ?array $google_array = array();
178
+		public static ? array $google_array = array();
179 179
 
180 180
 		/**
181 181
 		 * Array of various font groups used within the typography field.
182 182
 		 *
183 183
 		 * @var null|array
184 184
 		 */
185
-		public static ?array $font_groups = array();
185
+		public static ? array $font_groups = array();
186 186
 
187 187
 		/**
188 188
 		 * File system object used for I/O file operations.  Done the WordPress way.
@@ -421,12 +421,12 @@  discard block
 block discarded – undo
421 421
 
422 422
 							$ex = esc_html( ucwords( str_replace( array( '_', '-' ), ' ', $name ) ) );
423 423
 
424
-							$extensions[ $ex ] = esc_html( $ver );
424
+							$extensions[$ex] = esc_html( $ver );
425 425
 						}
426 426
 					}
427 427
 
428 428
 					// Output Redux instances.
429
-					$debug_info[ 'redux-instance-' . $inst ] = array(
429
+					$debug_info['redux-instance-' . $inst] = array(
430 430
 						// translators: %s = Instance name.
431 431
 						'label'       => sprintf( esc_html__( 'Redux Instance: %s', 'redux-framework' ), $inst_name ),
432 432
 						// translators: %s = Instance name w/ HTML.
@@ -543,10 +543,10 @@  discard block
 block discarded – undo
543 543
 					'reduxCoreEnqueue'         => 'Redux_Enqueue',
544 544
 					'Redux_Abstract_Extension' => 'Redux_Extension_Abstract',
545 545
 				);
546
-				$alias    = false;
547
-				if ( isset( $mappings[ $class_name ] ) ) {
546
+				$alias = false;
547
+				if ( isset( $mappings[$class_name] ) ) {
548 548
 					$alias      = $class_name;
549
-					$class_name = $mappings[ $class_name ];
549
+					$class_name = $mappings[$class_name];
550 550
 				}
551 551
 
552 552
 				// Everything else.
Please login to merge, or discard this patch.
redux-core/inc/extensions/customizer/inc/class-redux-customizer-section.php 1 patch
Indentation   +155 added lines, -155 removed lines patch added patch discarded remove patch
@@ -15,108 +15,108 @@  discard block
 block discarded – undo
15 15
  */
16 16
 class Redux_Customizer_Section extends WP_Customize_Section {
17 17
 
18
-	/**
19
-	 * Type of this section.
20
-	 *
21
-	 * @since  4.1.0
22
-	 * @access public
23
-	 * @var string
24
-	 */
25
-	public $type = 'redux';
26
-
27
-	/**
28
-	 * Panel opt_name.
29
-	 *
30
-	 * @since  4.0.0
31
-	 * @access public
32
-	 * @var string
33
-	 */
34
-	public $opt_name = '';
35
-
36
-	/**
37
-	 * Section array.
38
-	 *
39
-	 * @var array|mixed
40
-	 */
41
-	public $section = array();
42
-
43
-	/**
44
-	 * Section array.
45
-	 *
46
-	 * @var string
47
-	 */
48
-	public string $wp_ver;
49
-
50
-	/**
51
-	 * Constructor.
52
-	 * Any supplied $args override class property defaults.
53
-	 *
54
-	 * @since 3.4.0
55
-	 *
56
-	 * @param WP_Customize_Manager $manager Customizer bootstrap instance.
57
-	 * @param string               $id      A specific ID of the section.
58
-	 * @param array                $args    Section arguments.
59
-	 */
60
-	public function __construct( $manager, $id, $args = array() ) {
61
-		global $wp_version;
62
-
63
-		parent::__construct( $manager, $id, $args );
64
-
65
-		// Redux addition.
66
-		if ( isset( $args['section'] ) ) {
67
-			$this->section     = $args['section'];
68
-			$this->description = $this->section['desc'] ?? '';
69
-			$this->opt_name    = $args['opt_name'] ?? '';
70
-		}
71
-
72
-		$version      = explode( '-', $wp_version );
73
-		$this->wp_ver = $version[0];
74
-	}
75
-
76
-	/**
77
-	 * WP < 4.3 Render
78
-	 */
79
-	protected function render() {
80
-		global $wp_version;
81
-		$version = explode( '-', $wp_version );
82
-		if ( version_compare( $version[0], '4.3', '<' ) ) {
83
-			$this->render_fallback();
84
-		}
85
-	}
86
-
87
-	/**
88
-	 * Render the section, and the controls that have been added to it.
89
-	 *
90
-	 * @since 3.4.0
91
-	 */
92
-	protected function render_fallback() {
93
-		$classes = 'accordion-section redux-section control-section control-section-' . $this->type;
94
-		?>
18
+    /**
19
+     * Type of this section.
20
+     *
21
+     * @since  4.1.0
22
+     * @access public
23
+     * @var string
24
+     */
25
+    public $type = 'redux';
26
+
27
+    /**
28
+     * Panel opt_name.
29
+     *
30
+     * @since  4.0.0
31
+     * @access public
32
+     * @var string
33
+     */
34
+    public $opt_name = '';
35
+
36
+    /**
37
+     * Section array.
38
+     *
39
+     * @var array|mixed
40
+     */
41
+    public $section = array();
42
+
43
+    /**
44
+     * Section array.
45
+     *
46
+     * @var string
47
+     */
48
+    public string $wp_ver;
49
+
50
+    /**
51
+     * Constructor.
52
+     * Any supplied $args override class property defaults.
53
+     *
54
+     * @since 3.4.0
55
+     *
56
+     * @param WP_Customize_Manager $manager Customizer bootstrap instance.
57
+     * @param string               $id      A specific ID of the section.
58
+     * @param array                $args    Section arguments.
59
+     */
60
+    public function __construct( $manager, $id, $args = array() ) {
61
+        global $wp_version;
62
+
63
+        parent::__construct( $manager, $id, $args );
64
+
65
+        // Redux addition.
66
+        if ( isset( $args['section'] ) ) {
67
+            $this->section     = $args['section'];
68
+            $this->description = $this->section['desc'] ?? '';
69
+            $this->opt_name    = $args['opt_name'] ?? '';
70
+        }
71
+
72
+        $version      = explode( '-', $wp_version );
73
+        $this->wp_ver = $version[0];
74
+    }
75
+
76
+    /**
77
+     * WP < 4.3 Render
78
+     */
79
+    protected function render() {
80
+        global $wp_version;
81
+        $version = explode( '-', $wp_version );
82
+        if ( version_compare( $version[0], '4.3', '<' ) ) {
83
+            $this->render_fallback();
84
+        }
85
+    }
86
+
87
+    /**
88
+     * Render the section, and the controls that have been added to it.
89
+     *
90
+     * @since 3.4.0
91
+     */
92
+    protected function render_fallback() {
93
+        $classes = 'accordion-section redux-section control-section control-section-' . $this->type;
94
+        ?>
95 95
 		<li id="accordion-section-<?php echo esc_attr( $this->id ); ?>" class="<?php echo esc_attr( $classes ); ?>">
96 96
 			<h3 class="accordion-section-title" tabindex="0">
97 97
 				<?php
98
-				echo wp_kses(
99
-					$this->title,
100
-					array(
101
-						'em'     => array(),
102
-						'i'      => array(),
103
-						'strong' => array(),
104
-						'span'   => array(
105
-							'class' => array(),
106
-							'style' => array(),
107
-						),
108
-					)
109
-				);
110
-				?>
98
+                echo wp_kses(
99
+                    $this->title,
100
+                    array(
101
+                        'em'     => array(),
102
+                        'i'      => array(),
103
+                        'strong' => array(),
104
+                        'span'   => array(
105
+                            'class' => array(),
106
+                            'style' => array(),
107
+                        ),
108
+                    )
109
+                );
110
+                ?>
111 111
 				<span class="screen-reader-text"><?php esc_attr_e( 'Press return or enter to expand', 'redux-framework' ); ?></span>
112 112
 			</h3>
113 113
 			<ul class="accordion-section-content redux-main">
114 114
 				<?php
115
-				if ( isset( $this->opt_name ) && isset( $this->section ) ) {
116
-					// phpcs:ignore WordPress.NamingConventions.ValidHookName
117
-					do_action( "redux/page/$this->opt_name/section/before", $this->section );
118
-				}
119
-				?>
115
+                if ( isset( $this->opt_name ) && isset( $this->section ) ) {
116
+                    // phpcs:ignore WordPress.NamingConventions.ValidHookName
117
+                    do_action( "redux/page/$this->opt_name/section/before", $this->section );
118
+                }
119
+                ?>
120 120
 				<?php if ( ! empty( $this->description ) ) { ?>
121 121
 					<li class="customize-section-description-container">
122 122
 						<p class="description customize-section-description legacy"><?php echo wp_kses_post( $this->description ); ?></p>
@@ -125,60 +125,60 @@  discard block
 block discarded – undo
125 125
 			</ul>
126 126
 		</li>
127 127
 		<?php
128
-	}
129
-
130
-
131
-	/**
132
-	 * Gather the parameters passed to client JavaScript via JSON.
133
-	 *
134
-	 * @since 4.1.0
135
-	 *
136
-	 * @return array The array to be exported to the client as JSON.
137
-	 */
138
-	public function json(): array {
139
-		$array = wp_array_slice_assoc(
140
-			parent::json(),
141
-			array(
142
-				'id',
143
-				'title',
144
-				'description',
145
-				'priority',
146
-				'panel',
147
-				'type',
148
-			)
149
-		);
150
-
151
-		$array['content']        = $this->get_content();
152
-		$array['active']         = $this->active();
153
-		$array['instanceNumber'] = $this->instance_number;
154
-
155
-		if ( $this->panel ) {
156
-			/* translators: &#9656; is the unicode right-pointing triangle, and %s is the section title in the Customizer */
157
-			$array['customizeAction'] = sprintf( __( 'Customizing &#9656; %s', 'redux-framework' ), esc_html( $this->manager->get_panel( $this->panel )->title ) );
158
-		} else {
159
-			$array['customizeAction'] = __( 'Customizing', 'redux-framework' );
160
-		}
161
-
162
-		// BEGIN Redux Additions.
163
-		$array['width'] = $this->section['customizer_width'] ?? '';
164
-		$array['icon']  = ( isset( $this->section['icon'] ) && ! empty( $this->section['icon'] ) ) ? $this->section['icon'] : 'hide';
165
-
166
-		$array['opt_name'] = $this->opt_name;
167
-
168
-		return $array;
169
-	}
170
-
171
-	/**
172
-	 * An Underscore (JS) template for rendering this section.
173
-	 * Class variables for this section class are available in the `data` JS object;
174
-	 * export custom variables by overriding {@see WP_Customize_Section::json()}.
175
-	 *
176
-	 * @see   WP_Customize_Section::print_template()
177
-	 * @since 4.3.0
178
-	 */
179
-	protected function render_template() {
180
-
181
-		?>
128
+    }
129
+
130
+
131
+    /**
132
+     * Gather the parameters passed to client JavaScript via JSON.
133
+     *
134
+     * @since 4.1.0
135
+     *
136
+     * @return array The array to be exported to the client as JSON.
137
+     */
138
+    public function json(): array {
139
+        $array = wp_array_slice_assoc(
140
+            parent::json(),
141
+            array(
142
+                'id',
143
+                'title',
144
+                'description',
145
+                'priority',
146
+                'panel',
147
+                'type',
148
+            )
149
+        );
150
+
151
+        $array['content']        = $this->get_content();
152
+        $array['active']         = $this->active();
153
+        $array['instanceNumber'] = $this->instance_number;
154
+
155
+        if ( $this->panel ) {
156
+            /* translators: &#9656; is the unicode right-pointing triangle, and %s is the section title in the Customizer */
157
+            $array['customizeAction'] = sprintf( __( 'Customizing &#9656; %s', 'redux-framework' ), esc_html( $this->manager->get_panel( $this->panel )->title ) );
158
+        } else {
159
+            $array['customizeAction'] = __( 'Customizing', 'redux-framework' );
160
+        }
161
+
162
+        // BEGIN Redux Additions.
163
+        $array['width'] = $this->section['customizer_width'] ?? '';
164
+        $array['icon']  = ( isset( $this->section['icon'] ) && ! empty( $this->section['icon'] ) ) ? $this->section['icon'] : 'hide';
165
+
166
+        $array['opt_name'] = $this->opt_name;
167
+
168
+        return $array;
169
+    }
170
+
171
+    /**
172
+     * An Underscore (JS) template for rendering this section.
173
+     * Class variables for this section class are available in the `data` JS object;
174
+     * export custom variables by overriding {@see WP_Customize_Section::json()}.
175
+     *
176
+     * @see   WP_Customize_Section::print_template()
177
+     * @since 4.3.0
178
+     */
179
+    protected function render_template() {
180
+
181
+        ?>
182 182
 		<li id="accordion-section-{{ data.id }}"
183 183
 			class="redux-standalone-section redux-customizer-opt-name redux-section accordion-section control-section control-section-{{ data.type }}"
184 184
 			data-opt-name="{{ data.opt_name }}"
@@ -210,14 +210,14 @@  discard block
 block discarded – undo
210 210
 					<p class="description customize-section-description">{{{ data.description }}}</p>
211 211
 					<# } #>
212 212
 					<?php
213
-					if ( isset( $this->opt_name ) && isset( $this->section ) ) {
214
-						// phpcs:ignore WordPress.NamingConventions.ValidHookName
215
-						do_action( "redux/page/$this->opt_name/section/before", $this->section );
216
-					}
217
-					?>
213
+                    if ( isset( $this->opt_name ) && isset( $this->section ) ) {
214
+                        // phpcs:ignore WordPress.NamingConventions.ValidHookName
215
+                        do_action( "redux/page/$this->opt_name/section/before", $this->section );
216
+                    }
217
+                    ?>
218 218
 				</li>
219 219
 			</ul>
220 220
 		</li>
221 221
 		<?php
222
-	}
222
+    }
223 223
 }
Please login to merge, or discard this patch.
redux-core/inc/extensions/customizer/inc/class-redux-customizer-panel.php 1 patch
Indentation   +141 added lines, -141 removed lines patch added patch discarded remove patch
@@ -19,83 +19,83 @@  discard block
 block discarded – undo
19 19
  */
20 20
 class Redux_Customizer_Panel extends WP_Customize_Panel {
21 21
 
22
-	/**
23
-	 * Type of this panel.
24
-	 *
25
-	 * @since  4.0.0
26
-	 * @access public
27
-	 * @var string
28
-	 */
29
-	public $type = 'redux';
22
+    /**
23
+     * Type of this panel.
24
+     *
25
+     * @since  4.0.0
26
+     * @access public
27
+     * @var string
28
+     */
29
+    public $type = 'redux';
30 30
 
31
-	/**
32
-	 * Panel opt_name.
33
-	 *
34
-	 * @since  4.0.0
35
-	 * @access public
36
-	 * @var string
37
-	 */
38
-	public $opt_name = '';
31
+    /**
32
+     * Panel opt_name.
33
+     *
34
+     * @since  4.0.0
35
+     * @access public
36
+     * @var string
37
+     */
38
+    public $opt_name = '';
39 39
 
40
-	/**
41
-	 * Section array.
42
-	 *
43
-	 * @var array|mixed
44
-	 */
45
-	public $section = array();
40
+    /**
41
+     * Section array.
42
+     *
43
+     * @var array|mixed
44
+     */
45
+    public $section = array();
46 46
 
47
-	/**
48
-	 * Section array.
49
-	 *
50
-	 * @var string
51
-	 */
52
-	public string $wp_ver;
47
+    /**
48
+     * Section array.
49
+     *
50
+     * @var string
51
+     */
52
+    public string $wp_ver;
53 53
 
54
-	/**
55
-	 * Constructor.
56
-	 * Any supplied $args override class property defaults.
57
-	 *
58
-	 * @since 4.0.0
59
-	 *
60
-	 * @param WP_Customize_Manager $manager Customizer bootstrap instance.
61
-	 * @param string               $id      A specific ID for the panel.
62
-	 * @param array                $args    Panel arguments.
63
-	 */
64
-	public function __construct( $manager, $id, $args = array() ) {
65
-		global $wp_version;
54
+    /**
55
+     * Constructor.
56
+     * Any supplied $args override class property defaults.
57
+     *
58
+     * @since 4.0.0
59
+     *
60
+     * @param WP_Customize_Manager $manager Customizer bootstrap instance.
61
+     * @param string               $id      A specific ID for the panel.
62
+     * @param array                $args    Panel arguments.
63
+     */
64
+    public function __construct( $manager, $id, $args = array() ) {
65
+        global $wp_version;
66 66
 
67
-		parent::__construct( $manager, $id, $args );
67
+        parent::__construct( $manager, $id, $args );
68 68
 
69
-		$version      = explode( '-', $wp_version );
70
-		$this->wp_ver = $version[0];
69
+        $version      = explode( '-', $wp_version );
70
+        $this->wp_ver = $version[0];
71 71
 
72
-		// Redux addition.
73
-		if ( isset( $args['section'] ) ) {
74
-			$this->section     = $args['section'];
75
-			$this->description = $this->section['desc'] ?? '';
76
-			$this->opt_name    = $args['opt_name'] ?? '';
77
-		}
78
-	}
72
+        // Redux addition.
73
+        if ( isset( $args['section'] ) ) {
74
+            $this->section     = $args['section'];
75
+            $this->description = $this->section['desc'] ?? '';
76
+            $this->opt_name    = $args['opt_name'] ?? '';
77
+        }
78
+    }
79 79
 
80
-	/**
81
-	 * WP < 4.3 Render
82
-	 *
83
-	 * @since
84
-	 * @access protected
85
-	 */
86
-	protected function render() {
87
-		if ( version_compare( $this->wp_ver, '4.3', '<' ) ) {
88
-			$this->render_fallback();
89
-		}
90
-	}
80
+    /**
81
+     * WP < 4.3 Render
82
+     *
83
+     * @since
84
+     * @access protected
85
+     */
86
+    protected function render() {
87
+        if ( version_compare( $this->wp_ver, '4.3', '<' ) ) {
88
+            $this->render_fallback();
89
+        }
90
+    }
91 91
 
92
-	/**
93
-	 * Render.
94
-	 */
95
-	protected function render_fallback() {
96
-		$classes = 'accordion-section redux-main redux-panel control-section control-panel control-panel-' . esc_attr( $this->type );
92
+    /**
93
+     * Render.
94
+     */
95
+    protected function render_fallback() {
96
+        $classes = 'accordion-section redux-main redux-panel control-section control-panel control-panel-' . esc_attr( $this->type );
97 97
 
98
-		?>
98
+        ?>
99 99
 		<li id="accordion-panel-<?php echo esc_attr( $this->id ); ?>" class="<?php echo esc_attr( $classes ); ?>"
100 100
 			data-width="<?php echo isset( $this->section['customizer_width'] ) ? esc_attr( $this->section['customizer_width'] ) : ''; ?>">
101 101
 			<h3 class="accordion-section-title" tabindex="0">
@@ -103,19 +103,19 @@  discard block
 block discarded – undo
103 103
 					<i class="<?php echo esc_attr( $this->section['icon'] ); ?>"></i>
104 104
 				<?php endif; ?>
105 105
 				<?php
106
-				echo wp_kses(
107
-					$this->title,
108
-					array(
109
-						'em'     => array(),
110
-						'i'      => array(),
111
-						'strong' => array(),
112
-						'span'   => array(
113
-							'class' => array(),
114
-							'style' => array(),
115
-						),
116
-					)
117
-				);
118
-				?>
106
+                echo wp_kses(
107
+                    $this->title,
108
+                    array(
109
+                        'em'     => array(),
110
+                        'i'      => array(),
111
+                        'strong' => array(),
112
+                        'span'   => array(
113
+                            'class' => array(),
114
+                            'style' => array(),
115
+                        ),
116
+                    )
117
+                );
118
+                ?>
119 119
 				<span class="screen-reader-text"><?php esc_html_e( 'Press return or enter to open this panel', 'redux-framework' ); ?></span>
120 120
 			</h3>
121 121
 			<ul class="accordion-sub-container control-panel-content">
@@ -125,22 +125,22 @@  discard block
 block discarded – undo
125 125
 			</ul>
126 126
 		</li>
127 127
 		<?php
128
-	}
128
+    }
129 129
 
130
-	/**
131
-	 * Render the sections that have been added to the panel.
132
-	 *
133
-	 * @since  4.1.0
134
-	 * @access protected
135
-	 */
136
-	protected function render_content() {
137
-		?>
130
+    /**
131
+     * Render the sections that have been added to the panel.
132
+     *
133
+     * @since  4.1.0
134
+     * @access protected
135
+     */
136
+    protected function render_content() {
137
+        ?>
138 138
 		<li class="panel-meta accordion-section redux-panel redux-panel-meta control-section
139 139
 		<?php
140
-		if ( empty( $this->description ) ) {
141
-			echo ' cannot-expand';
142
-		}
143
-		?>
140
+        if ( empty( $this->description ) ) {
141
+            echo ' cannot-expand';
142
+        }
143
+        ?>
144 144
 		">
145 145
 			<div class="accordion-section-title" tabindex="0">
146 146
 				<span class="preview-notice">
@@ -155,47 +155,47 @@  discard block
 block discarded – undo
155 155
 			<?php } ?>
156 156
 		</li>
157 157
 		<?php
158
-	}
158
+    }
159 159
 
160
-	/**
161
-	 * JSON.
162
-	 *
163
-	 * @return array
164
-	 */
165
-	public function json(): array {
166
-		$array = wp_array_slice_assoc(
167
-			parent::json(),
168
-			array(
169
-				'id',
170
-				'title',
171
-				'description',
172
-				'priority',
173
-				'type',
174
-			)
175
-		);
160
+    /**
161
+     * JSON.
162
+     *
163
+     * @return array
164
+     */
165
+    public function json(): array {
166
+        $array = wp_array_slice_assoc(
167
+            parent::json(),
168
+            array(
169
+                'id',
170
+                'title',
171
+                'description',
172
+                'priority',
173
+                'type',
174
+            )
175
+        );
176 176
 
177
-		$array['content']        = $this->get_content();
178
-		$array['active']         = $this->active();
179
-		$array['instanceNumber'] = $this->instance_number;
177
+        $array['content']        = $this->get_content();
178
+        $array['active']         = $this->active();
179
+        $array['instanceNumber'] = $this->instance_number;
180 180
 
181
-		// BEGIN Redux Additions.
182
-		$array['width'] = $this->section['customizer_width'] ?? '';
183
-		$array['icon']  = ( isset( $this->section['icon'] ) && ! empty( $this->section['icon'] ) ) ? $this->section['icon'] : 'hide';
181
+        // BEGIN Redux Additions.
182
+        $array['width'] = $this->section['customizer_width'] ?? '';
183
+        $array['icon']  = ( isset( $this->section['icon'] ) && ! empty( $this->section['icon'] ) ) ? $this->section['icon'] : 'hide';
184 184
 
185
-		$array['opt_name'] = $this->opt_name;
186
-		return $array;
187
-	}
185
+        $array['opt_name'] = $this->opt_name;
186
+        return $array;
187
+    }
188 188
 
189
-	/**
190
-	 * An Underscore (JS) template for this panel's content (but not its container).
191
-	 * Class variables for this panel class are available in the `data` JS object;
192
-	 * export custom variables by overriding {@see WP_Customize_Panel::json()}.
193
-	 *
194
-	 * @see   WP_Customize_Panel::print_template()
195
-	 * @since 4.3.0
196
-	 */
197
-	protected function content_template() {
198
-		?>
189
+    /**
190
+     * An Underscore (JS) template for this panel's content (but not its container).
191
+     * Class variables for this panel class are available in the `data` JS object;
192
+     * export custom variables by overriding {@see WP_Customize_Panel::json()}.
193
+     *
194
+     * @see   WP_Customize_Panel::print_template()
195
+     * @since 4.3.0
196
+     */
197
+    protected function content_template() {
198
+        ?>
199 199
 		<li
200 200
 			class="panel-meta customize-info redux-customizer-opt-name redux-panel accordion-section <# if ( ! data.description ) { #> cannot-expand<# } #>"
201 201
 			data-opt-name="{{{ data.opt_name }}}">
@@ -223,18 +223,18 @@  discard block
 block discarded – undo
223 223
 			<# } #>
224 224
 		</li>
225 225
 		<?php
226
-	}
226
+    }
227 227
 
228
-	/**
229
-	 * An Underscore (JS) template for rendering this panel's container.
230
-	 * Class variables for this panel class are available in the `data` JS object;
231
-	 * export custom variables by overriding {@see WP_Customize_Panel::json()}.
232
-	 *
233
-	 * @see   WP_Customize_Panel::print_template()
234
-	 * @since 4.3.0
235
-	 */
236
-	protected function render_template() {
237
-		?>
228
+    /**
229
+     * An Underscore (JS) template for rendering this panel's container.
230
+     * Class variables for this panel class are available in the `data` JS object;
231
+     * export custom variables by overriding {@see WP_Customize_Panel::json()}.
232
+     *
233
+     * @see   WP_Customize_Panel::print_template()
234
+     * @since 4.3.0
235
+     */
236
+    protected function render_template() {
237
+        ?>
238 238
 		<li id="accordion-panel-{{ data.id }}"
239 239
 			class="accordion-section redux-panel control-section control-panel control-panel-{{ data.type }}"
240 240
 			data-width="{{ data.width }}">
@@ -252,5 +252,5 @@  discard block
 block discarded – undo
252 252
 			<ul class="accordion-sub-container control-panel-content"></ul>
253 253
 		</li>
254 254
 		<?php
255
-	}
255
+    }
256 256
 }
Please login to merge, or discard this patch.