Completed
Push — master ( e2a4d2...ed335c )
by
unknown
55s
created
redux-core/inc/themecheck/checks/class-redux-embedded.php 1 patch
Indentation   +54 added lines, -54 removed lines patch added patch discarded remove patch
@@ -14,67 +14,67 @@
 block discarded – undo
14 14
  */
15 15
 class Redux_Embedded implements themecheck {
16 16
 
17
-	/**
18
-	 * Error array.
19
-	 *
20
-	 * @var array
21
-	 */
22
-	protected array $error = array();
17
+    /**
18
+     * Error array.
19
+     *
20
+     * @var array
21
+     */
22
+    protected array $error = array();
23 23
 
24
-	/**
25
-	 * Run checker.
26
-	 *
27
-	 * @param array $php_files - Files to check.
28
-	 * @param array $css_files - Files to check.
29
-	 * @param array $other_files - Files to check.
30
-	 *
31
-	 * @return bool
32
-	 */
33
-	public function check( $php_files, $css_files, $other_files ): bool {
24
+    /**
25
+     * Run checker.
26
+     *
27
+     * @param array $php_files - Files to check.
28
+     * @param array $css_files - Files to check.
29
+     * @param array $other_files - Files to check.
30
+     *
31
+     * @return bool
32
+     */
33
+    public function check( $php_files, $css_files, $other_files ): bool {
34 34
 
35
-		$ret   = true;
36
-		$check = Redux_ThemeCheck::get_instance();
37
-		$redux = $check::get_redux_details( $php_files );
35
+        $ret   = true;
36
+        $check = Redux_ThemeCheck::get_instance();
37
+        $redux = $check::get_redux_details( $php_files );
38 38
 
39
-		if ( $redux ) {
40
-			checkcount();
39
+        if ( $redux ) {
40
+            checkcount();
41 41
 
42
-			if ( ! isset( $_POST['redux_wporg'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification
43
-				$this->error[] = '<div class="redux-error">' . sprintf( '<span class="tc-lead tc-recommended">' . esc_html__( 'RECOMMENDED', 'redux-framework' ) . '</span>: ' . esc_html__( 'If you are submitting to WordPress.org Theme Repository, it is', 'redux-framework' ) . ' <strong>' . esc_html__( 'strongly', 'redux-framework' ) . '</strong> ' . esc_html__( 'suggested that you read', 'redux-framework' ) . ' <a href="%s" target="_blank">' . esc_html__( 'this document', 'redux-framework' ) . '</a>, ' . esc_html__( 'or your theme will be rejected because of Redux.', 'redux-framework' ), 'https://docsv3.redux.io/core/wordpress-org-submissions/' ) . '</div>';
44
-				$ret           = false;
45
-			} else {
46
-				// TODO Granular WP.org tests!!!
47
-				// Check for Tracking.
48
-				$tracking = $redux['dir'] . 'inc/tracking.php';
49
-				if ( file_exists( $tracking ) ) {
50
-					$this->error[] = '<div class="redux-error">' . sprintf( '<span class="tc-lead tc-required">' . esc_html__( 'REQUIRED', 'redux-framework' ) . '</span>: ' . esc_html__( 'You MUST delete', 'redux-framework' ) . ' <strong> %s </strong>, ' . esc_html__( 'or your theme will be rejected by WP.org theme submission because of Redux.', 'redux-framework' ), $tracking ) . '</div>';
51
-					$ret           = false;
52
-				}
42
+            if ( ! isset( $_POST['redux_wporg'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification
43
+                $this->error[] = '<div class="redux-error">' . sprintf( '<span class="tc-lead tc-recommended">' . esc_html__( 'RECOMMENDED', 'redux-framework' ) . '</span>: ' . esc_html__( 'If you are submitting to WordPress.org Theme Repository, it is', 'redux-framework' ) . ' <strong>' . esc_html__( 'strongly', 'redux-framework' ) . '</strong> ' . esc_html__( 'suggested that you read', 'redux-framework' ) . ' <a href="%s" target="_blank">' . esc_html__( 'this document', 'redux-framework' ) . '</a>, ' . esc_html__( 'or your theme will be rejected because of Redux.', 'redux-framework' ), 'https://docsv3.redux.io/core/wordpress-org-submissions/' ) . '</div>';
44
+                $ret           = false;
45
+            } else {
46
+                // TODO Granular WP.org tests!!!
47
+                // Check for Tracking.
48
+                $tracking = $redux['dir'] . 'inc/tracking.php';
49
+                if ( file_exists( $tracking ) ) {
50
+                    $this->error[] = '<div class="redux-error">' . sprintf( '<span class="tc-lead tc-required">' . esc_html__( 'REQUIRED', 'redux-framework' ) . '</span>: ' . esc_html__( 'You MUST delete', 'redux-framework' ) . ' <strong> %s </strong>, ' . esc_html__( 'or your theme will be rejected by WP.org theme submission because of Redux.', 'redux-framework' ), $tracking ) . '</div>';
51
+                    $ret           = false;
52
+                }
53 53
 
54
-				// Embedded CDN package
55
-				// use_cdn
56
-				// Arguments.
57
-				$args          = '<ol>';
58
-				$args         .= "<li><code>'save_defaults' => false</code></li>";
59
-				$args         .= "<li><code>'use_cdn' => false</code></li>";
60
-				$args         .= "<li><code>'customizer_only' => true</code> Non-Customizer Based Panels are Prohibited within WP.org Themes</li>";
61
-				$args         .= "<li><code>'database' => 'theme_mods'</code> (' . esc_html__( 'Optional', 'redux-framework' ) . ')</li>";
62
-				$args         .= '</ol>';
63
-				$this->error[] = '<div class="redux-error"><span class="tc-lead tc-recommended">' . esc_html__( 'RECOMMENDED', 'redux-framework' ) . '</span>: ' . esc_html__( 'The following arguments MUST be used for WP.org submissions, or you will be rejected because of your Redux configuration.', 'redux-framework' ) . $args . '</div>';
64
-			}
65
-		}
54
+                // Embedded CDN package
55
+                // use_cdn
56
+                // Arguments.
57
+                $args          = '<ol>';
58
+                $args         .= "<li><code>'save_defaults' => false</code></li>";
59
+                $args         .= "<li><code>'use_cdn' => false</code></li>";
60
+                $args         .= "<li><code>'customizer_only' => true</code> Non-Customizer Based Panels are Prohibited within WP.org Themes</li>";
61
+                $args         .= "<li><code>'database' => 'theme_mods'</code> (' . esc_html__( 'Optional', 'redux-framework' ) . ')</li>";
62
+                $args         .= '</ol>';
63
+                $this->error[] = '<div class="redux-error"><span class="tc-lead tc-recommended">' . esc_html__( 'RECOMMENDED', 'redux-framework' ) . '</span>: ' . esc_html__( 'The following arguments MUST be used for WP.org submissions, or you will be rejected because of your Redux configuration.', 'redux-framework' ) . $args . '</div>';
64
+            }
65
+        }
66 66
 
67
-		return $ret;
68
-	}
67
+        return $ret;
68
+    }
69 69
 
70
-	/**
71
-	 * Return error array.
72
-	 *
73
-	 * @return array
74
-	 */
75
-	public function getError(): array {
76
-		return $this->error;
77
-	}
70
+    /**
71
+     * Return error array.
72
+     *
73
+     * @return array
74
+     */
75
+    public function getError(): array {
76
+        return $this->error;
77
+    }
78 78
 
79 79
 }
80 80
 
Please login to merge, or discard this patch.
class-redux-framework-plugin.php 1 patch
Indentation   +435 added lines, -435 removed lines patch added patch discarded remove patch
@@ -11,439 +11,439 @@
 block discarded – undo
11 11
 
12 12
 if ( ! class_exists( 'Redux_Framework_Plugin', false ) ) {
13 13
 
14
-	/**
15
-	 * Main Redux_Framework_Plugin class
16
-	 *
17
-	 * @since       3.0.0
18
-	 */
19
-	class Redux_Framework_Plugin {
20
-
21
-		/**
22
-		 * Option array for demo mode.
23
-		 *
24
-		 * @access      protected
25
-		 * @var         array $options Array of config options, used to check for demo mode
26
-		 * @since       3.0.0
27
-		 */
28
-		protected array $options = array();
29
-
30
-		/**
31
-		 * Use this value as the text domain when translating strings from this plugin. It should match
32
-		 * the Text Domain field set in the plugin header, as well as the directory name of the plugin.
33
-		 * Additionally, text domains should only contain letters, number and hyphens, not underscores
34
-		 * or spaces.
35
-		 *
36
-		 * @access      protected
37
-		 * @var         string $plugin_slug The unique ID (slug) of this plugin
38
-		 * @since       3.0.0
39
-		 */
40
-		protected string $plugin_slug = 'redux-framework';
41
-
42
-		/**
43
-		 * Set on network activate.
44
-		 *
45
-		 * @access      protected
46
-		 * @var         null|string $plugin_network_activated Check for plugin network activation
47
-		 * @since       3.0.0
48
-		 */
49
-		protected ?string $plugin_network_activated = null;
50
-
51
-		/**
52
-		 * Class instance.
53
-		 *
54
-		 * @access      private
55
-		 * @var         ?Redux_Framework_Plugin $instance The one true Redux_Framework_Plugin
56
-		 * @since       3.0.0
57
-		 */
58
-		private static ?Redux_Framework_Plugin $instance = null;
59
-
60
-		/**
61
-		 * Crash flag.
62
-		 *
63
-		 * @access      private
64
-		 * @var         Redux_Framework_Plugin $crash Crash flag if inside a crash.
65
-		 * @since       4.1.15
66
-		 */
67
-		public static $crash = false;
68
-
69
-		/**
70
-		 * Get active instance
71
-		 *
72
-		 * @access      public
73
-		 * @since       3.1.3
74
-		 * @return      self::$instance The one true Redux_Framework_Plugin
75
-		 */
76
-		public static function instance(): ?Redux_Framework_Plugin {
77
-			$path = REDUX_PLUGIN_FILE;
78
-			$res  = false;
79
-
80
-			if ( function_exists( 'get_plugin_data' ) && file_exists( $path ) ) {
81
-				$data = get_plugin_data( $path, true, false );
82
-
83
-				if ( isset( $data['Version'] ) && '' !== $data['Version'] ) {
84
-					$res = version_compare( $data['Version'], '4', '<' );
85
-				}
86
-
87
-				// phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals -- active_plugins is a WP hook.
88
-				if ( true === $res && ! in_array( 'redux-framework/redux-framework.php', apply_filters( 'active_plugins', get_option( 'active_plugins' ) ), true ) ) {
89
-					echo '<div class="error"><p>' . esc_html__( 'Redux Framework version 4 is activated but not loaded. Redux Framework version 3 is still installed and activated.  Please deactivate Redux Framework version 3.', 'redux-framework' ) . '</p></div>'; // phpcs:ignore WordPress.Security.EscapeOutput
90
-					return null;
91
-				}
92
-			}
93
-
94
-			if ( ! self::$instance ) {
95
-				self::$instance = new self();
96
-				if ( class_exists( 'ReduxFramework' ) ) {
97
-					self::$instance->load_first();
98
-				} else {
99
-					self::$instance->get_redux_options();
100
-					self::$instance->includes();
101
-					self::$instance->hooks();
102
-				}
103
-			}
104
-
105
-			return self::$instance;
106
-		}
107
-
108
-		/**
109
-		 * Shim for getting instance
110
-		 *
111
-		 * @access      public
112
-		 * @since       4.0.1
113
-		 * @return      self::$instance The one true Redux_Framework_Plugin
114
-		 */
115
-		public static function get_instance(): ?Redux_Framework_Plugin {
116
-			return self::instance();
117
-		}
118
-
119
-		/**
120
-		 * Get Redux options
121
-		 *
122
-		 * @access      public
123
-		 * @since       3.1.3
124
-		 * @return      void
125
-		 */
126
-		public function get_redux_options() {
127
-
128
-			// Setup defaults.
129
-			$defaults = array(
130
-				'demo' => false,
131
-			);
132
-
133
-			// If multisite is enabled.
134
-			if ( is_multisite() ) {
135
-
136
-				// Get network activated plugins.
137
-				$plugins = get_site_option( 'active_sitewide_plugins' );
138
-
139
-				foreach ( $plugins as $file => $plugin ) {
140
-					if ( strpos( $file, 'redux-framework.php' ) !== false ) {
141
-						$this->plugin_network_activated = true;
142
-						$this->options                  = get_site_option( 'ReduxFrameworkPlugin', $defaults );
143
-					}
144
-				}
145
-			}
146
-
147
-			// If options aren't set, grab them now!
148
-			if ( empty( $this->options ) ) {
149
-				$this->options = get_option( 'ReduxFrameworkPlugin', $defaults );
150
-			}
151
-		}
152
-
153
-		/**
154
-		 * Include the necessary files
155
-		 *
156
-		 * @access      public
157
-		 * @since       3.1.3
158
-		 * @return      void
159
-		 */
160
-		public function includes() {
161
-
162
-			// Include Redux_Core.
163
-			if ( file_exists( __DIR__ . '/redux-core/framework.php' ) ) {
164
-				require_once __DIR__ . '/redux-core/framework.php';
165
-			}
166
-
167
-			if ( file_exists( __DIR__ . '/redux-templates/redux-templates.php' ) ) {
168
-				require_once __DIR__ . '/redux-templates/redux-templates.php';
169
-			}
170
-
171
-			if ( isset( Redux_Core::$as_plugin ) ) {
172
-				Redux_Core::$as_plugin = true;
173
-			}
174
-
175
-			add_action( 'setup_theme', array( $this, 'load_sample_config' ) );
176
-		}
177
-
178
-		/**
179
-		 * Loads the sample config after everything is loaded.
180
-		 *
181
-		 * @access      public
182
-		 * @since       4.0.2
183
-		 * @return      void
184
-		 */
185
-		public function load_sample_config() {
186
-			// Include demo config, if demo mode is active.
187
-			if ( $this->options['demo'] && file_exists( __DIR__ . '/sample/sample-config.php' ) ) {
188
-				require_once __DIR__ . '/sample/sample-config.php';
189
-			}
190
-		}
191
-
192
-		/**
193
-		 * Run action and filter hooks
194
-		 *
195
-		 * @access      private
196
-		 * @since       3.1.3
197
-		 * @return      void
198
-		 */
199
-		private function hooks() {
200
-			add_action( 'activated_plugin', array( $this, 'load_first' ) );
201
-			add_action( 'wp_loaded', array( $this, 'options_toggle_check' ) );
202
-
203
-			// Activate plugin when a new blog is added.
204
-			add_action( 'wpmu_new_blog', array( $this, 'activate_new_site' ) );
205
-
206
-			// Display admin notices.
207
-			add_action( 'admin_notices', array( $this, 'admin_notices' ) );
208
-
209
-			// Edit plugin metalinks.
210
-			add_filter( 'plugin_row_meta', array( $this, 'plugin_metalinks' ), null, 2 );
211
-			add_filter( 'network_admin_plugin_action_links', array( $this, 'add_settings_link' ), 1, 2 );
212
-			add_filter( 'plugin_action_links', array( $this, 'add_settings_link' ), 1, 2 );
213
-
214
-			// phpcs:ignore WordPress.NamingConventions.ValidHookName
215
-			do_action( 'redux/plugin/hooks', $this );
216
-		}
217
-
218
-		/**
219
-		 * Pushes Redux to the top of plugin load list, so it initializes before any plugin that may use it.
220
-		 */
221
-		public function load_first() {
222
-			if ( ! class_exists( 'Redux_Functions_Ex' ) ) {
223
-				require_once __DIR__ . '/redux-core/inc/classes/class-redux-functions-ex.php';
224
-			}
225
-
226
-			$plugin_dir = Redux_Functions_Ex::wp_normalize_path( WP_PLUGIN_DIR ) . '/';
227
-			$self_file  = Redux_Functions_Ex::wp_normalize_path( __FILE__ );
228
-
229
-			$path = str_replace( $plugin_dir, '', $self_file );
230
-			$path = str_replace( 'class-redux-framework-plugin.php', 'redux-framework.php', $path );
231
-
232
-			$plugins = get_option( 'active_plugins' );
233
-
234
-			if ( $plugins ) {
235
-				$key = array_search( $path, $plugins, true );
236
-
237
-				if ( false !== $key ) {
238
-					array_splice( $plugins, $key, 1 );
239
-					array_unshift( $plugins, $path );
240
-					update_option( 'active_plugins', $plugins );
241
-				}
242
-			}
243
-		}
244
-
245
-		/**
246
-		 * Fired on plugin activation
247
-		 *
248
-		 * @access      public
249
-		 * @return      void
250
-		 * @since       3.0.0
251
-		 */
252
-		public static function activate() {
253
-			delete_site_transient( 'update_plugins' );
254
-		}
255
-
256
-		/**
257
-		 * Fired when plugin is deactivated
258
-		 *
259
-		 * @access      public
260
-		 * @since       3.0.0
261
-		 *
262
-		 * @param       boolean $network_wide True if plugin is network activated, false otherwise.
263
-		 *
264
-		 * @return      void
265
-		 */
266
-		public static function deactivate( ?bool $network_wide ) {
267
-			if ( function_exists( 'is_multisite' ) && is_multisite() ) {
268
-				if ( $network_wide ) {
269
-					// Get all blog IDs.
270
-					$blog_ids = self::get_blog_ids();
271
-
272
-					foreach ( $blog_ids as $blog_id ) {
273
-						switch_to_blog( $blog_id );
274
-						self::single_deactivate();
275
-					}
276
-					restore_current_blog();
277
-				} else {
278
-					self::single_deactivate();
279
-				}
280
-			} else {
281
-				self::single_deactivate();
282
-			}
283
-
284
-			delete_option( 'ReduxFrameworkPlugin' );
285
-		}
286
-
287
-		/**
288
-		 * Fired when a new WPMU site is activated
289
-		 *
290
-		 * @access      public
291
-		 *
292
-		 * @param       int $blog_id The ID of the new blog.
293
-		 *
294
-		 * @return      void
295
-		 * @since       3.0.0
296
-		 */
297
-		public function activate_new_site( int $blog_id ) {
298
-			if ( 1 !== did_action( 'wpmu_new_blog' ) ) {
299
-				return;
300
-			}
301
-
302
-			switch_to_blog( $blog_id );
303
-			self::single_activate();
304
-			restore_current_blog();
305
-		}
306
-
307
-		/**
308
-		 * Get all IDs of blogs that are not activated, not spam, and not deleted
309
-		 *
310
-		 * @access      private
311
-		 * @since       3.0.0
312
-		 * @global      object $wpdb
313
-		 * @return      array|false Array of IDs or false if none are found
314
-		 */
315
-		private static function get_blog_ids() {
316
-			global $wpdb;
317
-
318
-			$var = '0';
319
-
320
-			// Get an array of IDs (We have to do it this way because WordPress says so, however redundant).
321
-			$result = wp_cache_get( 'redux-blog-ids' );
322
-			if ( false === $result ) {
323
-
324
-				// WordPress says get_col is discouraged?  I found no alternative.  So...ignore! - kp.
325
-				// phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery
326
-				$result = $wpdb->get_col( $wpdb->prepare( "SELECT blog_id FROM $wpdb->blogs WHERE archived = %s AND spam = %s AND deleted = %s", $var, $var, $var ) );
327
-
328
-				wp_cache_set( 'redux-blog-ids', $result );
329
-			}
330
-
331
-			return $result;
332
-		}
333
-
334
-		/**
335
-		 * Fired for each WPMS blog on plugin activation
336
-		 *
337
-		 * @access      private
338
-		 * @since       3.0.0
339
-		 * @return      void
340
-		 */
341
-		private static function single_activate() {
342
-			$nonce = wp_create_nonce( 'redux_framework_demo' );
343
-
344
-			$notices   = get_option( 'ReduxFrameworkPlugin_ACTIVATED_NOTICES', array() );
345
-			$notices[] = esc_html__( 'Redux Framework has an embedded demo.', 'redux-framework' ) . ' <a href="./plugins.php?redux-framework-plugin=demo&nonce=' . $nonce . '">' . esc_html__( 'Click here to activate the sample config file.', 'redux-framework' ) . '</a>';
346
-
347
-			update_option( 'ReduxFrameworkPlugin_ACTIVATED_NOTICES', $notices );
348
-		}
349
-
350
-		/**
351
-		 * Display admin notices
352
-		 *
353
-		 * @access      public
354
-		 * @since       3.0.0
355
-		 * @return      void
356
-		 */
357
-		public function admin_notices() {
358
-			do_action( 'redux_framework_plugin_admin_notice' );
359
-			$notices = get_option( 'ReduxFrameworkPlugin_ACTIVATED_NOTICES', '' );
360
-			if ( ! empty( $notices ) ) {
361
-				foreach ( $notices as $notice ) {
362
-					echo '<div class="updated notice is-dismissible"><p>' . $notice . '</p></div>'; // phpcs:ignore WordPress.Security.EscapeOutput
363
-				}
364
-
365
-				delete_option( 'ReduxFrameworkPlugin_ACTIVATED_NOTICES' );
366
-			}
367
-		}
368
-
369
-		/**
370
-		 * Fired for each blog when the plugin is deactivated
371
-		 *
372
-		 * @access      private
373
-		 * @since       3.0.0
374
-		 * @return      void
375
-		 */
376
-		private static function single_deactivate() {
377
-			delete_option( 'ReduxFrameworkPlugin_ACTIVATED_NOTICES' );
378
-		}
379
-
380
-		/**
381
-		 * Turn on or off
382
-		 *
383
-		 * @access      public
384
-		 * @since       3.0.0
385
-		 * @return      void
386
-		 */
387
-		public function options_toggle_check() {
388
-			if ( isset( $_GET['nonce'] ) && wp_verify_nonce( sanitize_key( $_GET['nonce'] ), 'redux_framework_demo' ) ) {
389
-				if ( isset( $_GET['redux-framework-plugin'] ) && 'demo' === $_GET['redux-framework-plugin'] ) {
390
-					$url = admin_url( add_query_arg( array( 'page' => 'redux-framework' ), 'options-general.php' ) );
391
-
392
-					if ( false === $this->options['demo'] ) {
393
-						$this->options['demo'] = true;
394
-						$url                   = admin_url( add_query_arg( array( 'page' => 'redux_demo' ), 'admin.php' ) );
395
-					} else {
396
-						$this->options['demo'] = false;
397
-					}
398
-
399
-					if ( is_multisite() && $this->plugin_network_activated ) {
400
-						update_site_option( 'ReduxFrameworkPlugin', $this->options );
401
-					} else {
402
-						update_option( 'ReduxFrameworkPlugin', $this->options );
403
-					}
404
-
405
-					wp_safe_redirect( esc_url( $url ) );
406
-
407
-					exit();
408
-				}
409
-			}
410
-		}
411
-
412
-
413
-		/**
414
-		 * Add a settings link to the Redux entry in the plugin overview screen
415
-		 *
416
-		 * @param array $links Links array.
417
-		 *
418
-		 * @return array
419
-		 * @see   filter:plugin_action_links
420
-		 * @since 1.0
421
-		 */
422
-		public function add_settings_link( array $links ): array {
423
-			return $links;
424
-		}
425
-
426
-		/**
427
-		 * Edit plugin metalinks
428
-		 *
429
-		 * @access      public
430
-		 *
431
-		 * @param array  $links The current array of links.
432
-		 * @param string $file  A specific plugin row.
433
-		 *
434
-		 * @return      array The modified array of links
435
-		 * @since       3.0.0
436
-		 */
437
-		public function plugin_metalinks( array $links, string $file ): array {
438
-			if ( strpos( $file, 'redux-framework.php' ) !== false && is_plugin_active( $file ) ) {
439
-				$links[] = '<a href="' . esc_url( admin_url( add_query_arg( array( 'page' => 'redux-framework' ), 'options-general.php' ) ) ) . '">' . esc_html__( 'What is this?', 'redux-framework' ) . '</a>';
440
-			}
441
-
442
-			return $links;
443
-		}
444
-	}
445
-
446
-	if ( ! class_exists( 'ReduxFrameworkPlugin' ) ) {
447
-		class_alias( 'Redux_Framework_Plugin', 'ReduxFrameworkPlugin' );
448
-	}
14
+    /**
15
+     * Main Redux_Framework_Plugin class
16
+     *
17
+     * @since       3.0.0
18
+     */
19
+    class Redux_Framework_Plugin {
20
+
21
+        /**
22
+         * Option array for demo mode.
23
+         *
24
+         * @access      protected
25
+         * @var         array $options Array of config options, used to check for demo mode
26
+         * @since       3.0.0
27
+         */
28
+        protected array $options = array();
29
+
30
+        /**
31
+         * Use this value as the text domain when translating strings from this plugin. It should match
32
+         * the Text Domain field set in the plugin header, as well as the directory name of the plugin.
33
+         * Additionally, text domains should only contain letters, number and hyphens, not underscores
34
+         * or spaces.
35
+         *
36
+         * @access      protected
37
+         * @var         string $plugin_slug The unique ID (slug) of this plugin
38
+         * @since       3.0.0
39
+         */
40
+        protected string $plugin_slug = 'redux-framework';
41
+
42
+        /**
43
+         * Set on network activate.
44
+         *
45
+         * @access      protected
46
+         * @var         null|string $plugin_network_activated Check for plugin network activation
47
+         * @since       3.0.0
48
+         */
49
+        protected ?string $plugin_network_activated = null;
50
+
51
+        /**
52
+         * Class instance.
53
+         *
54
+         * @access      private
55
+         * @var         ?Redux_Framework_Plugin $instance The one true Redux_Framework_Plugin
56
+         * @since       3.0.0
57
+         */
58
+        private static ?Redux_Framework_Plugin $instance = null;
59
+
60
+        /**
61
+         * Crash flag.
62
+         *
63
+         * @access      private
64
+         * @var         Redux_Framework_Plugin $crash Crash flag if inside a crash.
65
+         * @since       4.1.15
66
+         */
67
+        public static $crash = false;
68
+
69
+        /**
70
+         * Get active instance
71
+         *
72
+         * @access      public
73
+         * @since       3.1.3
74
+         * @return      self::$instance The one true Redux_Framework_Plugin
75
+         */
76
+        public static function instance(): ?Redux_Framework_Plugin {
77
+            $path = REDUX_PLUGIN_FILE;
78
+            $res  = false;
79
+
80
+            if ( function_exists( 'get_plugin_data' ) && file_exists( $path ) ) {
81
+                $data = get_plugin_data( $path, true, false );
82
+
83
+                if ( isset( $data['Version'] ) && '' !== $data['Version'] ) {
84
+                    $res = version_compare( $data['Version'], '4', '<' );
85
+                }
86
+
87
+                // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals -- active_plugins is a WP hook.
88
+                if ( true === $res && ! in_array( 'redux-framework/redux-framework.php', apply_filters( 'active_plugins', get_option( 'active_plugins' ) ), true ) ) {
89
+                    echo '<div class="error"><p>' . esc_html__( 'Redux Framework version 4 is activated but not loaded. Redux Framework version 3 is still installed and activated.  Please deactivate Redux Framework version 3.', 'redux-framework' ) . '</p></div>'; // phpcs:ignore WordPress.Security.EscapeOutput
90
+                    return null;
91
+                }
92
+            }
93
+
94
+            if ( ! self::$instance ) {
95
+                self::$instance = new self();
96
+                if ( class_exists( 'ReduxFramework' ) ) {
97
+                    self::$instance->load_first();
98
+                } else {
99
+                    self::$instance->get_redux_options();
100
+                    self::$instance->includes();
101
+                    self::$instance->hooks();
102
+                }
103
+            }
104
+
105
+            return self::$instance;
106
+        }
107
+
108
+        /**
109
+         * Shim for getting instance
110
+         *
111
+         * @access      public
112
+         * @since       4.0.1
113
+         * @return      self::$instance The one true Redux_Framework_Plugin
114
+         */
115
+        public static function get_instance(): ?Redux_Framework_Plugin {
116
+            return self::instance();
117
+        }
118
+
119
+        /**
120
+         * Get Redux options
121
+         *
122
+         * @access      public
123
+         * @since       3.1.3
124
+         * @return      void
125
+         */
126
+        public function get_redux_options() {
127
+
128
+            // Setup defaults.
129
+            $defaults = array(
130
+                'demo' => false,
131
+            );
132
+
133
+            // If multisite is enabled.
134
+            if ( is_multisite() ) {
135
+
136
+                // Get network activated plugins.
137
+                $plugins = get_site_option( 'active_sitewide_plugins' );
138
+
139
+                foreach ( $plugins as $file => $plugin ) {
140
+                    if ( strpos( $file, 'redux-framework.php' ) !== false ) {
141
+                        $this->plugin_network_activated = true;
142
+                        $this->options                  = get_site_option( 'ReduxFrameworkPlugin', $defaults );
143
+                    }
144
+                }
145
+            }
146
+
147
+            // If options aren't set, grab them now!
148
+            if ( empty( $this->options ) ) {
149
+                $this->options = get_option( 'ReduxFrameworkPlugin', $defaults );
150
+            }
151
+        }
152
+
153
+        /**
154
+         * Include the necessary files
155
+         *
156
+         * @access      public
157
+         * @since       3.1.3
158
+         * @return      void
159
+         */
160
+        public function includes() {
161
+
162
+            // Include Redux_Core.
163
+            if ( file_exists( __DIR__ . '/redux-core/framework.php' ) ) {
164
+                require_once __DIR__ . '/redux-core/framework.php';
165
+            }
166
+
167
+            if ( file_exists( __DIR__ . '/redux-templates/redux-templates.php' ) ) {
168
+                require_once __DIR__ . '/redux-templates/redux-templates.php';
169
+            }
170
+
171
+            if ( isset( Redux_Core::$as_plugin ) ) {
172
+                Redux_Core::$as_plugin = true;
173
+            }
174
+
175
+            add_action( 'setup_theme', array( $this, 'load_sample_config' ) );
176
+        }
177
+
178
+        /**
179
+         * Loads the sample config after everything is loaded.
180
+         *
181
+         * @access      public
182
+         * @since       4.0.2
183
+         * @return      void
184
+         */
185
+        public function load_sample_config() {
186
+            // Include demo config, if demo mode is active.
187
+            if ( $this->options['demo'] && file_exists( __DIR__ . '/sample/sample-config.php' ) ) {
188
+                require_once __DIR__ . '/sample/sample-config.php';
189
+            }
190
+        }
191
+
192
+        /**
193
+         * Run action and filter hooks
194
+         *
195
+         * @access      private
196
+         * @since       3.1.3
197
+         * @return      void
198
+         */
199
+        private function hooks() {
200
+            add_action( 'activated_plugin', array( $this, 'load_first' ) );
201
+            add_action( 'wp_loaded', array( $this, 'options_toggle_check' ) );
202
+
203
+            // Activate plugin when a new blog is added.
204
+            add_action( 'wpmu_new_blog', array( $this, 'activate_new_site' ) );
205
+
206
+            // Display admin notices.
207
+            add_action( 'admin_notices', array( $this, 'admin_notices' ) );
208
+
209
+            // Edit plugin metalinks.
210
+            add_filter( 'plugin_row_meta', array( $this, 'plugin_metalinks' ), null, 2 );
211
+            add_filter( 'network_admin_plugin_action_links', array( $this, 'add_settings_link' ), 1, 2 );
212
+            add_filter( 'plugin_action_links', array( $this, 'add_settings_link' ), 1, 2 );
213
+
214
+            // phpcs:ignore WordPress.NamingConventions.ValidHookName
215
+            do_action( 'redux/plugin/hooks', $this );
216
+        }
217
+
218
+        /**
219
+         * Pushes Redux to the top of plugin load list, so it initializes before any plugin that may use it.
220
+         */
221
+        public function load_first() {
222
+            if ( ! class_exists( 'Redux_Functions_Ex' ) ) {
223
+                require_once __DIR__ . '/redux-core/inc/classes/class-redux-functions-ex.php';
224
+            }
225
+
226
+            $plugin_dir = Redux_Functions_Ex::wp_normalize_path( WP_PLUGIN_DIR ) . '/';
227
+            $self_file  = Redux_Functions_Ex::wp_normalize_path( __FILE__ );
228
+
229
+            $path = str_replace( $plugin_dir, '', $self_file );
230
+            $path = str_replace( 'class-redux-framework-plugin.php', 'redux-framework.php', $path );
231
+
232
+            $plugins = get_option( 'active_plugins' );
233
+
234
+            if ( $plugins ) {
235
+                $key = array_search( $path, $plugins, true );
236
+
237
+                if ( false !== $key ) {
238
+                    array_splice( $plugins, $key, 1 );
239
+                    array_unshift( $plugins, $path );
240
+                    update_option( 'active_plugins', $plugins );
241
+                }
242
+            }
243
+        }
244
+
245
+        /**
246
+         * Fired on plugin activation
247
+         *
248
+         * @access      public
249
+         * @return      void
250
+         * @since       3.0.0
251
+         */
252
+        public static function activate() {
253
+            delete_site_transient( 'update_plugins' );
254
+        }
255
+
256
+        /**
257
+         * Fired when plugin is deactivated
258
+         *
259
+         * @access      public
260
+         * @since       3.0.0
261
+         *
262
+         * @param       boolean $network_wide True if plugin is network activated, false otherwise.
263
+         *
264
+         * @return      void
265
+         */
266
+        public static function deactivate( ?bool $network_wide ) {
267
+            if ( function_exists( 'is_multisite' ) && is_multisite() ) {
268
+                if ( $network_wide ) {
269
+                    // Get all blog IDs.
270
+                    $blog_ids = self::get_blog_ids();
271
+
272
+                    foreach ( $blog_ids as $blog_id ) {
273
+                        switch_to_blog( $blog_id );
274
+                        self::single_deactivate();
275
+                    }
276
+                    restore_current_blog();
277
+                } else {
278
+                    self::single_deactivate();
279
+                }
280
+            } else {
281
+                self::single_deactivate();
282
+            }
283
+
284
+            delete_option( 'ReduxFrameworkPlugin' );
285
+        }
286
+
287
+        /**
288
+         * Fired when a new WPMU site is activated
289
+         *
290
+         * @access      public
291
+         *
292
+         * @param       int $blog_id The ID of the new blog.
293
+         *
294
+         * @return      void
295
+         * @since       3.0.0
296
+         */
297
+        public function activate_new_site( int $blog_id ) {
298
+            if ( 1 !== did_action( 'wpmu_new_blog' ) ) {
299
+                return;
300
+            }
301
+
302
+            switch_to_blog( $blog_id );
303
+            self::single_activate();
304
+            restore_current_blog();
305
+        }
306
+
307
+        /**
308
+         * Get all IDs of blogs that are not activated, not spam, and not deleted
309
+         *
310
+         * @access      private
311
+         * @since       3.0.0
312
+         * @global      object $wpdb
313
+         * @return      array|false Array of IDs or false if none are found
314
+         */
315
+        private static function get_blog_ids() {
316
+            global $wpdb;
317
+
318
+            $var = '0';
319
+
320
+            // Get an array of IDs (We have to do it this way because WordPress says so, however redundant).
321
+            $result = wp_cache_get( 'redux-blog-ids' );
322
+            if ( false === $result ) {
323
+
324
+                // WordPress says get_col is discouraged?  I found no alternative.  So...ignore! - kp.
325
+                // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery
326
+                $result = $wpdb->get_col( $wpdb->prepare( "SELECT blog_id FROM $wpdb->blogs WHERE archived = %s AND spam = %s AND deleted = %s", $var, $var, $var ) );
327
+
328
+                wp_cache_set( 'redux-blog-ids', $result );
329
+            }
330
+
331
+            return $result;
332
+        }
333
+
334
+        /**
335
+         * Fired for each WPMS blog on plugin activation
336
+         *
337
+         * @access      private
338
+         * @since       3.0.0
339
+         * @return      void
340
+         */
341
+        private static function single_activate() {
342
+            $nonce = wp_create_nonce( 'redux_framework_demo' );
343
+
344
+            $notices   = get_option( 'ReduxFrameworkPlugin_ACTIVATED_NOTICES', array() );
345
+            $notices[] = esc_html__( 'Redux Framework has an embedded demo.', 'redux-framework' ) . ' <a href="./plugins.php?redux-framework-plugin=demo&nonce=' . $nonce . '">' . esc_html__( 'Click here to activate the sample config file.', 'redux-framework' ) . '</a>';
346
+
347
+            update_option( 'ReduxFrameworkPlugin_ACTIVATED_NOTICES', $notices );
348
+        }
349
+
350
+        /**
351
+         * Display admin notices
352
+         *
353
+         * @access      public
354
+         * @since       3.0.0
355
+         * @return      void
356
+         */
357
+        public function admin_notices() {
358
+            do_action( 'redux_framework_plugin_admin_notice' );
359
+            $notices = get_option( 'ReduxFrameworkPlugin_ACTIVATED_NOTICES', '' );
360
+            if ( ! empty( $notices ) ) {
361
+                foreach ( $notices as $notice ) {
362
+                    echo '<div class="updated notice is-dismissible"><p>' . $notice . '</p></div>'; // phpcs:ignore WordPress.Security.EscapeOutput
363
+                }
364
+
365
+                delete_option( 'ReduxFrameworkPlugin_ACTIVATED_NOTICES' );
366
+            }
367
+        }
368
+
369
+        /**
370
+         * Fired for each blog when the plugin is deactivated
371
+         *
372
+         * @access      private
373
+         * @since       3.0.0
374
+         * @return      void
375
+         */
376
+        private static function single_deactivate() {
377
+            delete_option( 'ReduxFrameworkPlugin_ACTIVATED_NOTICES' );
378
+        }
379
+
380
+        /**
381
+         * Turn on or off
382
+         *
383
+         * @access      public
384
+         * @since       3.0.0
385
+         * @return      void
386
+         */
387
+        public function options_toggle_check() {
388
+            if ( isset( $_GET['nonce'] ) && wp_verify_nonce( sanitize_key( $_GET['nonce'] ), 'redux_framework_demo' ) ) {
389
+                if ( isset( $_GET['redux-framework-plugin'] ) && 'demo' === $_GET['redux-framework-plugin'] ) {
390
+                    $url = admin_url( add_query_arg( array( 'page' => 'redux-framework' ), 'options-general.php' ) );
391
+
392
+                    if ( false === $this->options['demo'] ) {
393
+                        $this->options['demo'] = true;
394
+                        $url                   = admin_url( add_query_arg( array( 'page' => 'redux_demo' ), 'admin.php' ) );
395
+                    } else {
396
+                        $this->options['demo'] = false;
397
+                    }
398
+
399
+                    if ( is_multisite() && $this->plugin_network_activated ) {
400
+                        update_site_option( 'ReduxFrameworkPlugin', $this->options );
401
+                    } else {
402
+                        update_option( 'ReduxFrameworkPlugin', $this->options );
403
+                    }
404
+
405
+                    wp_safe_redirect( esc_url( $url ) );
406
+
407
+                    exit();
408
+                }
409
+            }
410
+        }
411
+
412
+
413
+        /**
414
+         * Add a settings link to the Redux entry in the plugin overview screen
415
+         *
416
+         * @param array $links Links array.
417
+         *
418
+         * @return array
419
+         * @see   filter:plugin_action_links
420
+         * @since 1.0
421
+         */
422
+        public function add_settings_link( array $links ): array {
423
+            return $links;
424
+        }
425
+
426
+        /**
427
+         * Edit plugin metalinks
428
+         *
429
+         * @access      public
430
+         *
431
+         * @param array  $links The current array of links.
432
+         * @param string $file  A specific plugin row.
433
+         *
434
+         * @return      array The modified array of links
435
+         * @since       3.0.0
436
+         */
437
+        public function plugin_metalinks( array $links, string $file ): array {
438
+            if ( strpos( $file, 'redux-framework.php' ) !== false && is_plugin_active( $file ) ) {
439
+                $links[] = '<a href="' . esc_url( admin_url( add_query_arg( array( 'page' => 'redux-framework' ), 'options-general.php' ) ) ) . '">' . esc_html__( 'What is this?', 'redux-framework' ) . '</a>';
440
+            }
441
+
442
+            return $links;
443
+        }
444
+    }
445
+
446
+    if ( ! class_exists( 'ReduxFrameworkPlugin' ) ) {
447
+        class_alias( 'Redux_Framework_Plugin', 'ReduxFrameworkPlugin' );
448
+    }
449 449
 }
Please login to merge, or discard this patch.
redux-core/inc/lib/get-font-classes.php 1 patch
Indentation   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -39,17 +39,17 @@
 block discarded – undo
39 39
  * @return false|string
40 40
  */
41 41
 function redux_fa_icons() {
42
-	$content = file_get_contents( 'https://raw.githubusercontent.com/FortAwesome/Font-Awesome/6.x/metadata/icons.json' );
43
-	$json    = json_decode( $content );
44
-	$icons   = '';
42
+    $content = file_get_contents( 'https://raw.githubusercontent.com/FortAwesome/Font-Awesome/6.x/metadata/icons.json' );
43
+    $json    = json_decode( $content );
44
+    $icons   = '';
45 45
 
46
-	foreach ( $json as $icon => $value ) {
47
-		foreach ( $value->styles as $style ) {
48
-			$icon = 'fa' . substr( $style, 0, 1 ) . ' fa-' . $icon;
46
+    foreach ( $json as $icon => $value ) {
47
+        foreach ( $value->styles as $style ) {
48
+            $icon = 'fa' . substr( $style, 0, 1 ) . ' fa-' . $icon;
49 49
 
50
-			$icons .= "'" . $icon . "', ";
51
-		}
52
-	}
50
+            $icons .= "'" . $icon . "', ";
51
+        }
52
+    }
53 53
 
54
-	return substr( $icons, 0, -2 );
54
+    return substr( $icons, 0, -2 );
55 55
 }
Please login to merge, or discard this patch.
redux-core/inc/lib/redux-instances.php 1 patch
Indentation   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -17,9 +17,9 @@  discard block
 block discarded – undo
17 17
  * @return ReduxFramework                ReduxFramework
18 18
  */
19 19
 function get_redux_instance( string $opt_name ): ReduxFramework { // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals -- Cannot change due to backward compatibility with older themes. Function contains plugin name.
20
-	_deprecated_function( __FUNCTION__, '4.0', 'Redux::instance($opt_name)' );
20
+    _deprecated_function( __FUNCTION__, '4.0', 'Redux::instance($opt_name)' );
21 21
 
22
-	return Redux::instance( $opt_name );
22
+    return Redux::instance( $opt_name );
23 23
 }
24 24
 
25 25
 /**
@@ -30,7 +30,7 @@  discard block
 block discarded – undo
30 30
  * @return array        format ['opt_name' => $ReduxFramework]
31 31
  */
32 32
 function get_all_redux_instances(): array { // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals -- Cannot change due to backward compatibility with older themes. Function contains plugin name.
33
-	_deprecated_function( __FUNCTION__, '4.0', 'Redux::all_instances()' );
33
+    _deprecated_function( __FUNCTION__, '4.0', 'Redux::all_instances()' );
34 34
 
35
-	return Redux::all_instances();
35
+    return Redux::all_instances();
36 36
 }
Please login to merge, or discard this patch.
redux-core/inc/welcome/views/about.php 2 patches
Indentation   +66 added lines, -66 removed lines patch added patch discarded remove patch
@@ -30,50 +30,50 @@  discard block
 block discarded – undo
30 30
 	<hr>
31 31
 	<?php
32 32
 
33
-	$redux_sys_info = Redux_Helpers::process_redux_callers();
33
+    $redux_sys_info = Redux_Helpers::process_redux_callers();
34 34
 
35
-	?>
35
+    ?>
36 36
 
37 37
 	<div class="feature-section <?php echo empty( $redux_sys_info ) ? 'one-col' : 'two-col'; ?>">
38 38
 		<div class="<?php echo ! empty( $redux_sys_info ) ? 'col' : ''; ?>">
39 39
 			<h2 style="text-align:left;"><?php echo esc_html__( 'Did I install this?', 'redux-framework' ); ?></h2>
40 40
 			<h3>
41 41
 				<?php
42
-				if ( ! empty( $redux_sys_info ) ) {
43
-					esc_html_e( 'Maybe not! These items are using Redux. If you want to keep using them, Redux will need to remain installed and activated.', 'redux-framework' );
44
-				} else {
45
-					$redux_nonce = wp_create_nonce( 'redux_framework_demo' );
46
-
47
-					$redux_query_args = array(
48
-						'page'                   => 'redux-framework',
49
-						'redux-framework-plugin' => 'demo',
50
-						'nonce'                  => $redux_nonce,
51
-					);
52
-
53
-					// translators: %1$s: URL, %2$s: close tag.
54
-					printf( esc_html__( 'Maybe not! If you want to see what Redux is all about, click here to %1$sActivate Demo Mode%2$s.', 'redux-framework' ), '<a href="' . esc_url( admin_url( add_query_arg( $redux_query_args, 'options-general.php' ) ) ) . '">', '</a>' );
55
-				}
56
-
57
-				?>
42
+                if ( ! empty( $redux_sys_info ) ) {
43
+                    esc_html_e( 'Maybe not! These items are using Redux. If you want to keep using them, Redux will need to remain installed and activated.', 'redux-framework' );
44
+                } else {
45
+                    $redux_nonce = wp_create_nonce( 'redux_framework_demo' );
46
+
47
+                    $redux_query_args = array(
48
+                        'page'                   => 'redux-framework',
49
+                        'redux-framework-plugin' => 'demo',
50
+                        'nonce'                  => $redux_nonce,
51
+                    );
52
+
53
+                    // translators: %1$s: URL, %2$s: close tag.
54
+                    printf( esc_html__( 'Maybe not! If you want to see what Redux is all about, click here to %1$sActivate Demo Mode%2$s.', 'redux-framework' ), '<a href="' . esc_url( admin_url( add_query_arg( $redux_query_args, 'options-general.php' ) ) ) . '">', '</a>' );
55
+                }
56
+
57
+                ?>
58 58
 			</h3>
59 59
 		</div>
60 60
 		<div class="col">
61 61
 			<?php
62
-			if ( ! empty( $redux_sys_info ) && is_array( $redux_sys_info ) ) {
63
-				$redux_plugin_index = array();
64
-				$redux_plugin_data  = get_plugins();
62
+            if ( ! empty( $redux_sys_info ) && is_array( $redux_sys_info ) ) {
63
+                $redux_plugin_index = array();
64
+                $redux_plugin_data  = get_plugins();
65 65
 
66
-				foreach ( $redux_plugin_data as $redux_key => $redux_data ) {
67
-					$redux_key_slug                        = explode( '/', $redux_key );
68
-					$redux_key_slug                        = $redux_key_slug[0];
69
-					$redux_plugin_index[ $redux_key_slug ] = $redux_key;
70
-				}
66
+                foreach ( $redux_plugin_data as $redux_key => $redux_data ) {
67
+                    $redux_key_slug                        = explode( '/', $redux_key );
68
+                    $redux_key_slug                        = $redux_key_slug[0];
69
+                    $redux_plugin_index[ $redux_key_slug ] = $redux_key;
70
+                }
71 71
 
72
-				foreach ( $redux_sys_info as $redux_project_type => $redux_products ) {
73
-					if ( 'theme' === $redux_project_type ) {
74
-						$redux_my_theme = wp_get_theme();
72
+                foreach ( $redux_sys_info as $redux_project_type => $redux_products ) {
73
+                    if ( 'theme' === $redux_project_type ) {
74
+                        $redux_my_theme = wp_get_theme();
75 75
 
76
-						?>
76
+                        ?>
77 77
 						<div class="redux-product">
78 78
 							<h2 class="name"><?php echo esc_html( $redux_my_theme->get( 'Name' ) ); ?>
79 79
 								<?php if ( ! empty( $redux_my_theme->get( 'Version' ) ) ) { ?>
@@ -96,33 +96,33 @@  discard block
 block discarded – undo
96 96
 							<p class="author">
97 97
 								<small>
98 98
 									<?php
99
-									foreach ( $redux_products as $redux_slug => $redux_data ) {
100
-										foreach ( $redux_data as $redux_opt_name => $redux_callers ) {
101
-											echo '<span><strong>opt_name</strong>: <code>' . esc_html( $redux_opt_name ) . '</code></span><br />';
102
-
103
-											foreach ( $redux_callers as $redux_caller ) {
104
-												echo '<span>~/' . esc_html( $redux_caller['basename'] ) . '</span><br />';
105
-											}
106
-
107
-											echo '<br />';
108
-										}
109
-									}
110
-									?>
99
+                                    foreach ( $redux_products as $redux_slug => $redux_data ) {
100
+                                        foreach ( $redux_data as $redux_opt_name => $redux_callers ) {
101
+                                            echo '<span><strong>opt_name</strong>: <code>' . esc_html( $redux_opt_name ) . '</code></span><br />';
102
+
103
+                                            foreach ( $redux_callers as $redux_caller ) {
104
+                                                echo '<span>~/' . esc_html( $redux_caller['basename'] ) . '</span><br />';
105
+                                            }
106
+
107
+                                            echo '<br />';
108
+                                        }
109
+                                    }
110
+                                    ?>
111 111
 								</small>
112 112
 							</p>
113 113
 						</div>
114 114
 						<?php
115 115
 
116
-					} else {
117
-						foreach ( $redux_products as $redux_product => $redux_data ) {
118
-							if ( ! isset( $redux_plugin_index[ $redux_product ] ) ) {
119
-								continue;
120
-							}
116
+                    } else {
117
+                        foreach ( $redux_products as $redux_product => $redux_data ) {
118
+                            if ( ! isset( $redux_plugin_index[ $redux_product ] ) ) {
119
+                                continue;
120
+                            }
121 121
 
122
-							$redux_plugin_path = Redux_Functions_Ex::wp_normalize_path( WP_PLUGIN_DIR . '/' . $redux_plugin_index[ $redux_product ] );
123
-							$redux_plugin_data = get_plugin_data( $redux_plugin_path );
122
+                            $redux_plugin_path = Redux_Functions_Ex::wp_normalize_path( WP_PLUGIN_DIR . '/' . $redux_plugin_index[ $redux_product ] );
123
+                            $redux_plugin_data = get_plugin_data( $redux_plugin_path );
124 124
 
125
-							?>
125
+                            ?>
126 126
 							<div class="redux-product">
127 127
 								<h2 class="name">
128 128
 									<?php echo esc_html( $redux_plugin_data['Name'] ); ?>
@@ -132,9 +132,9 @@  discard block
 block discarded – undo
132 132
 								</h2>
133 133
 								<p class="author">
134 134
 									<?php
135
-									if ( ! empty( $redux_plugin_data['Author'] ) ) {
136
-										$redux_plugin_url = ! empty( $redux_plugin_data['AuthorURI'] ) ? $redux_plugin_data['AuthorURI'] : $redux_plugin_data['PluginURI'];
137
-										?>
135
+                                    if ( ! empty( $redux_plugin_data['Author'] ) ) {
136
+                                        $redux_plugin_url = ! empty( $redux_plugin_data['AuthorURI'] ) ? $redux_plugin_data['AuthorURI'] : $redux_plugin_data['PluginURI'];
137
+                                        ?>
138 138
 										<?php echo esc_html__( 'By', 'redux-framework' ); ?>
139 139
 										<a href="<?php echo esc_attr( $redux_plugin_url ); ?>">
140 140
 											<?php echo esc_html( trim( wp_strip_all_tags( $redux_plugin_data['Author'] ) ) ); ?>
@@ -148,23 +148,23 @@  discard block
 block discarded – undo
148 148
 								<p class="author">
149 149
 									<small>
150 150
 										<?php
151
-										foreach ( $redux_data as $redux_opt_name => $redux_callers ) {
152
-											echo '<span><strong>opt_name</strong>: <code>' . esc_html( $redux_opt_name ) . '</code></span><br />';
153
-
154
-											foreach ( $redux_callers as $redux_caller ) {
155
-												echo '<span>~/' . esc_html( $redux_caller['basename'] ) . '</span><br />';
156
-											}
157
-										}
158
-										?>
151
+                                        foreach ( $redux_data as $redux_opt_name => $redux_callers ) {
152
+                                            echo '<span><strong>opt_name</strong>: <code>' . esc_html( $redux_opt_name ) . '</code></span><br />';
153
+
154
+                                            foreach ( $redux_callers as $redux_caller ) {
155
+                                                echo '<span>~/' . esc_html( $redux_caller['basename'] ) . '</span><br />';
156
+                                            }
157
+                                        }
158
+                                        ?>
159 159
 									</small>
160 160
 								</p>
161 161
 							</div>
162 162
 							<?php
163
-						}
164
-					}
165
-				}
166
-			}
167
-			?>
163
+                        }
164
+                    }
165
+                }
166
+            }
167
+            ?>
168 168
 		</div>
169 169
 	</div>
170 170
 </div>
Please login to merge, or discard this patch.
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -66,7 +66,7 @@  discard block
 block discarded – undo
66 66
 				foreach ( $redux_plugin_data as $redux_key => $redux_data ) {
67 67
 					$redux_key_slug                        = explode( '/', $redux_key );
68 68
 					$redux_key_slug                        = $redux_key_slug[0];
69
-					$redux_plugin_index[ $redux_key_slug ] = $redux_key;
69
+					$redux_plugin_index[$redux_key_slug] = $redux_key;
70 70
 				}
71 71
 
72 72
 				foreach ( $redux_sys_info as $redux_project_type => $redux_products ) {
@@ -115,11 +115,11 @@  discard block
 block discarded – undo
115 115
 
116 116
 					} else {
117 117
 						foreach ( $redux_products as $redux_product => $redux_data ) {
118
-							if ( ! isset( $redux_plugin_index[ $redux_product ] ) ) {
118
+							if ( ! isset( $redux_plugin_index[$redux_product] ) ) {
119 119
 								continue;
120 120
 							}
121 121
 
122
-							$redux_plugin_path = Redux_Functions_Ex::wp_normalize_path( WP_PLUGIN_DIR . '/' . $redux_plugin_index[ $redux_product ] );
122
+							$redux_plugin_path = Redux_Functions_Ex::wp_normalize_path( WP_PLUGIN_DIR . '/' . $redux_plugin_index[$redux_product] );
123 123
 							$redux_plugin_data = get_plugin_data( $redux_plugin_path );
124 124
 
125 125
 							?>
Please login to merge, or discard this patch.
redux-core/inc/themecheck/checks/class-redux-full-package.php 1 patch
Indentation   +65 added lines, -65 removed lines patch added patch discarded remove patch
@@ -14,71 +14,71 @@
 block discarded – undo
14 14
  */
15 15
 class Redux_Full_Package implements themecheck {
16 16
 
17
-	/**
18
-	 * Themecheck error array.
19
-	 *
20
-	 * @var array $error Error storage.
21
-	 */
22
-	protected array $error = array();
23
-
24
-	/**
25
-	 * Check files.
26
-	 *
27
-	 * @param array $php_files File to check.
28
-	 * @param array $css_files Files to check.
29
-	 * @param array $other_files Files to check.
30
-	 *
31
-	 * @return bool
32
-	 */
33
-	public function check( $php_files, $css_files, $other_files ): bool {
34
-
35
-		$ret = true;
36
-
37
-		$check = Redux_ThemeCheck::get_instance();
38
-		$redux = $check::get_redux_details( $php_files );
39
-
40
-		if ( $redux ) {
41
-
42
-			$blacklist = array(
43
-				'codestyles'                       => esc_html__( 'Redux Code Styles', 'redux-framework' ),
44
-				'class-redux-framework-plugin.php' => esc_html__( 'Redux Plugin File', 'redux-framework' ),
45
-				'.travis.yml'                      => esc_html__( 'CI Testing File', 'redux-framework' ),
46
-			);
47
-
48
-			$errors = array();
49
-
50
-			foreach ( $blacklist as $file => $reason ) {
51
-				checkcount();
52
-				if ( file_exists( $redux['parent_dir'] . $file ) ) {
53
-					$errors[ $redux['parent_dir'] . $file ] = $reason;
54
-				}
55
-			}
56
-
57
-			if ( ! empty( $errors ) ) {
58
-				$error  = '<span class="tc-lead tc-required">REQUIRED</span> ' . esc_html__( 'It appears that you have embedded the full Redux package inside your theme. You need only embed the', 'redux-framework' ) . ' <strong>redux-core</strong> ' . esc_html__( 'folder. Embedding anything else will get your rejected from theme submission. Suspected Redux package file(s):', 'redux-framework' );
59
-				$error .= '<ol>';
60
-
61
-				foreach ( $errors as $key => $e ) {
62
-					$error .= '<li><strong>' . $e . '</strong>: ' . $key . '</li>';
63
-				}
64
-
65
-				$error        .= '</ol>';
66
-				$this->error[] = '<div class="redux-error">' . $error . '</div>';
67
-				$ret           = false;
68
-			}
69
-		}
70
-
71
-		return $ret;
72
-	}
73
-
74
-	/**
75
-	 * Retrieve errors.
76
-	 *
77
-	 * @return array
78
-	 */
79
-	public function getError(): array {
80
-		return $this->error;
81
-	}
17
+    /**
18
+     * Themecheck error array.
19
+     *
20
+     * @var array $error Error storage.
21
+     */
22
+    protected array $error = array();
23
+
24
+    /**
25
+     * Check files.
26
+     *
27
+     * @param array $php_files File to check.
28
+     * @param array $css_files Files to check.
29
+     * @param array $other_files Files to check.
30
+     *
31
+     * @return bool
32
+     */
33
+    public function check( $php_files, $css_files, $other_files ): bool {
34
+
35
+        $ret = true;
36
+
37
+        $check = Redux_ThemeCheck::get_instance();
38
+        $redux = $check::get_redux_details( $php_files );
39
+
40
+        if ( $redux ) {
41
+
42
+            $blacklist = array(
43
+                'codestyles'                       => esc_html__( 'Redux Code Styles', 'redux-framework' ),
44
+                'class-redux-framework-plugin.php' => esc_html__( 'Redux Plugin File', 'redux-framework' ),
45
+                '.travis.yml'                      => esc_html__( 'CI Testing File', 'redux-framework' ),
46
+            );
47
+
48
+            $errors = array();
49
+
50
+            foreach ( $blacklist as $file => $reason ) {
51
+                checkcount();
52
+                if ( file_exists( $redux['parent_dir'] . $file ) ) {
53
+                    $errors[ $redux['parent_dir'] . $file ] = $reason;
54
+                }
55
+            }
56
+
57
+            if ( ! empty( $errors ) ) {
58
+                $error  = '<span class="tc-lead tc-required">REQUIRED</span> ' . esc_html__( 'It appears that you have embedded the full Redux package inside your theme. You need only embed the', 'redux-framework' ) . ' <strong>redux-core</strong> ' . esc_html__( 'folder. Embedding anything else will get your rejected from theme submission. Suspected Redux package file(s):', 'redux-framework' );
59
+                $error .= '<ol>';
60
+
61
+                foreach ( $errors as $key => $e ) {
62
+                    $error .= '<li><strong>' . $e . '</strong>: ' . $key . '</li>';
63
+                }
64
+
65
+                $error        .= '</ol>';
66
+                $this->error[] = '<div class="redux-error">' . $error . '</div>';
67
+                $ret           = false;
68
+            }
69
+        }
70
+
71
+        return $ret;
72
+    }
73
+
74
+    /**
75
+     * Retrieve errors.
76
+     *
77
+     * @return array
78
+     */
79
+    public function getError(): array {
80
+        return $this->error;
81
+    }
82 82
 }
83 83
 
84 84
 // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals -- WordPress global. Cannot be changed.
Please login to merge, or discard this patch.
inc/validation/unique_slug/class-redux-validation-unique-slug.php 1 patch
Indentation   +78 added lines, -78 removed lines patch added patch discarded remove patch
@@ -12,82 +12,82 @@
 block discarded – undo
12 12
 
13 13
 if ( ! class_exists( 'Redux_Validation_Unique_Slug', false ) ) {
14 14
 
15
-	/**
16
-	 * Class Redux_Validation_Unique_Slug
17
-	 */
18
-	class Redux_Validation_Unique_Slug extends Redux_Validate {
19
-
20
-		/**
21
-		 * Field Validation Function.
22
-		 * Takes the vars and validates them
23
-		 *
24
-		 * @since ReduxFramework 3.0.0
25
-		 */
26
-		public function validate() {
27
-			global $wpdb, $wp_rewrite;
28
-
29
-			$this->field['msg']              = $this->field['msg'] ?? esc_html__( 'That URL slug is in use, please choose another.', 'redux-framework' );
30
-			$this->field['flush_permalinks'] = $this->field['flush_permalinks'] ?? false;
31
-
32
-			$slug = $this->value;
33
-
34
-			$post_name_check = '';
35
-
36
-			$feeds = $wp_rewrite->feeds;
37
-			if ( ! is_array( $feeds ) ) {
38
-				$feeds = array();
39
-			}
40
-
41
-			// Post slugs must be unique across all posts.
42
-			$result = wp_cache_get( 'redux-post-name' );
43
-			if ( false === $result ) {
44
-				// phpcs:ignore WordPress.DB.DirectDatabaseQuery
45
-				$post_name_check = $wpdb->get_var( $wpdb->prepare( "SELECT post_name FROM $wpdb->posts WHERE post_name = %s LIMIT 1", $slug ) );
46
-
47
-				wp_cache_set( 'redux-post-name', $post_name_check );
48
-			}
49
-
50
-			/**
51
-			 * Filter whether the post slug would be bad as a flat slug.
52
-			 *
53
-			 * @since 3.1.0
54
-			 *
55
-			 * @param bool   $bad_slug  Whether the post slug would be bad as a flat slug.
56
-			 * @param string $slug      The post slug.
57
-			 * @param string $post_type Post type.
58
-			 */
59
-			if ( $post_name_check || in_array( $slug, $feeds, true ) || apply_filters( 'wp_unique_post_slug_is_bad_attachment_slug', false, $slug ) ) { // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals -- WordPress hook. Cannot be changed to plugin prefix.
60
-				$suffix = 2;
61
-
62
-				do {
63
-					$alt_post_name = _truncate_post_slug( $slug, 200 - ( strlen( $suffix ) + 1 ) ) . "-$suffix";
64
-
65
-					$result = wp_cache_get( 'redux-alt-post-name' );
66
-					if ( false === $result ) {
67
-						// phpcs:ignore WordPress.DB.DirectDatabaseQuery
68
-						$post_name_check = $wpdb->get_var( $wpdb->prepare( "SELECT post_name FROM $wpdb->posts WHERE post_name = %s LIMIT 1", $alt_post_name ) );
69
-
70
-						wp_cache_set( 'redux-alt-post-name', $result );
71
-					}
72
-
73
-					++$suffix;
74
-				} while ( $post_name_check );
75
-
76
-				$slug                   = $alt_post_name;
77
-				$this->value            = ( isset( $this->current ) ) ? $this->current : '';
78
-				$this->field['msg']     = sprintf( $this->field['msg'], $slug );
79
-				$this->field['current'] = $this->value;
80
-				$this->error            = $this->field;
81
-			} elseif ( isset( $this->field['flush_permalinks'] ) && true === $this->field['flush_permalinks'] ) {
82
-				add_action( 'init', array( $this, 'flush_permalinks' ), 99 );
83
-			}
84
-		}
85
-
86
-		/**
87
-		 * Flush WordPress permalinks.
88
-		 */
89
-		public function flush_permalinks() {
90
-			flush_rewrite_rules();
91
-		}
92
-	}
15
+    /**
16
+     * Class Redux_Validation_Unique_Slug
17
+     */
18
+    class Redux_Validation_Unique_Slug extends Redux_Validate {
19
+
20
+        /**
21
+         * Field Validation Function.
22
+         * Takes the vars and validates them
23
+         *
24
+         * @since ReduxFramework 3.0.0
25
+         */
26
+        public function validate() {
27
+            global $wpdb, $wp_rewrite;
28
+
29
+            $this->field['msg']              = $this->field['msg'] ?? esc_html__( 'That URL slug is in use, please choose another.', 'redux-framework' );
30
+            $this->field['flush_permalinks'] = $this->field['flush_permalinks'] ?? false;
31
+
32
+            $slug = $this->value;
33
+
34
+            $post_name_check = '';
35
+
36
+            $feeds = $wp_rewrite->feeds;
37
+            if ( ! is_array( $feeds ) ) {
38
+                $feeds = array();
39
+            }
40
+
41
+            // Post slugs must be unique across all posts.
42
+            $result = wp_cache_get( 'redux-post-name' );
43
+            if ( false === $result ) {
44
+                // phpcs:ignore WordPress.DB.DirectDatabaseQuery
45
+                $post_name_check = $wpdb->get_var( $wpdb->prepare( "SELECT post_name FROM $wpdb->posts WHERE post_name = %s LIMIT 1", $slug ) );
46
+
47
+                wp_cache_set( 'redux-post-name', $post_name_check );
48
+            }
49
+
50
+            /**
51
+             * Filter whether the post slug would be bad as a flat slug.
52
+             *
53
+             * @since 3.1.0
54
+             *
55
+             * @param bool   $bad_slug  Whether the post slug would be bad as a flat slug.
56
+             * @param string $slug      The post slug.
57
+             * @param string $post_type Post type.
58
+             */
59
+            if ( $post_name_check || in_array( $slug, $feeds, true ) || apply_filters( 'wp_unique_post_slug_is_bad_attachment_slug', false, $slug ) ) { // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals -- WordPress hook. Cannot be changed to plugin prefix.
60
+                $suffix = 2;
61
+
62
+                do {
63
+                    $alt_post_name = _truncate_post_slug( $slug, 200 - ( strlen( $suffix ) + 1 ) ) . "-$suffix";
64
+
65
+                    $result = wp_cache_get( 'redux-alt-post-name' );
66
+                    if ( false === $result ) {
67
+                        // phpcs:ignore WordPress.DB.DirectDatabaseQuery
68
+                        $post_name_check = $wpdb->get_var( $wpdb->prepare( "SELECT post_name FROM $wpdb->posts WHERE post_name = %s LIMIT 1", $alt_post_name ) );
69
+
70
+                        wp_cache_set( 'redux-alt-post-name', $result );
71
+                    }
72
+
73
+                    ++$suffix;
74
+                } while ( $post_name_check );
75
+
76
+                $slug                   = $alt_post_name;
77
+                $this->value            = ( isset( $this->current ) ) ? $this->current : '';
78
+                $this->field['msg']     = sprintf( $this->field['msg'], $slug );
79
+                $this->field['current'] = $this->value;
80
+                $this->error            = $this->field;
81
+            } elseif ( isset( $this->field['flush_permalinks'] ) && true === $this->field['flush_permalinks'] ) {
82
+                add_action( 'init', array( $this, 'flush_permalinks' ), 99 );
83
+            }
84
+        }
85
+
86
+        /**
87
+         * Flush WordPress permalinks.
88
+         */
89
+        public function flush_permalinks() {
90
+            flush_rewrite_rules();
91
+        }
92
+    }
93 93
 }
Please login to merge, or discard this patch.
color_scheme/color_scheme/inc/class-redux-color-scheme-functions.php 1 patch
Indentation   +1082 added lines, -1082 removed lines patch added patch discarded remove patch
@@ -11,773 +11,773 @@  discard block
 block discarded – undo
11 11
 defined( 'ABSPATH' ) || exit;
12 12
 
13 13
 if ( ! class_exists( 'Redux_Color_Scheme_Functions' ) ) {
14
-	/**
15
-	 * Class Redux_Color_Scheme_Functions
16
-	 */
17
-	class Redux_Color_Scheme_Functions {
18
-
19
-		/**
20
-		 * ReduxFramework object.
21
-		 *
22
-		 * @var null|ReduxFramework
23
-		 */
24
-		public static ?ReduxFramework $parent;
25
-
26
-		/**
27
-		 * Field ID
28
-		 *
29
-		 * @var string|null
30
-		 */
31
-		public static ?string $field_id;
32
-
33
-		/**
34
-		 * Field class.
35
-		 *
36
-		 * @var string|null
37
-		 */
38
-		public static ?string $field_class;
39
-
40
-		/**
41
-		 * Field array.
42
-		 *
43
-		 * @var array|null
44
-		 */
45
-		public static ?array $field;
46
-
47
-		/**
48
-		 * WP Upload directory.
49
-		 *
50
-		 * @var string|null
51
-		 */
52
-		public static ?string $upload_dir = '';
53
-
54
-		/**
55
-		 * WP Upload URI
56
-		 *
57
-		 * @var string|null
58
-		 */
59
-		public static ?string $upload_url = '';
60
-
61
-		/**
62
-		 * Select fields.
63
-		 *
64
-		 * @var array|null
65
-		 */
66
-		public static ?array $select;
67
-
68
-		/**
69
-		 * Class init.
70
-		 *
71
-		 * @param ReduxFramework $redux ReduxFramework object.
72
-		 */
73
-		public static function init( ReduxFramework $redux ) {
74
-			self::$parent = $redux;
75
-
76
-			if ( empty( self::$field_id ) ) {
77
-				self::$field = self::get_field( $redux );
78
-
79
-				if ( ! is_array( self::$field ) ) {
80
-					return;
81
-				}
82
-
83
-				self::$field_id = self::$field['id'];
84
-			}
85
-
86
-			// Make sanitized upload dir DIR.
87
-			self::$upload_dir = Redux_Functions_Ex::wp_normalize_path( ReduxFramework::$_upload_dir . 'color-schemes/' );
88
-
89
-			// Make sanitized upload dir URL.
90
-			self::$upload_url = Redux_Functions_Ex::wp_normalize_path( ReduxFramework::$_upload_url . 'color-schemes/' );
91
-
92
-			Redux_Functions::init_wp_filesystem();
93
-		}
94
-
95
-		/**
96
-		 * Checks if tooltips are in use.
97
-		 *
98
-		 * @param array $field Field array.
99
-		 *
100
-		 * @return bool
101
-		 */
102
-		public static function tooltips_in_use( array $field ): bool {
103
-			$blocks = $field['default'];
104
-
105
-			foreach ( $blocks as $arr ) {
106
-				if ( isset( $arr['tooltip'] ) ) {
107
-					return true;
108
-				}
109
-			}
110
-
111
-			return false;
112
-		}
113
-
114
-		/**
115
-		 * Convert DB values.
116
-		 */
117
-		public static function convert_to_db() {
118
-			$upload_dir = Redux_Functions_Ex::wp_normalize_path( ReduxFramework::$_upload_dir . 'color-schemes/' );
119
-
120
-			$cur_scheme_file = Redux_Functions_Ex::wp_normalize_path( $upload_dir . '/' . self::$parent->args['opt_name'] . '_' . self::$field_id . '.json' );
121
-
122
-			if ( is_dir( $upload_dir ) ) {
123
-				if ( file_exists( $cur_scheme_file ) ) {
124
-					$data = Redux_Core::$filesystem->execute( 'get_contents', $cur_scheme_file );
125
-					if ( ! empty( $data ) ) {
126
-						$data = json_decode( $data, true );
127
-
128
-						update_option( self::get_scheme_key(), $data );
129
-
130
-						Redux_Core::$filesystem->execute( 'delete', $cur_scheme_file );
131
-					}
132
-				}
133
-			}
134
-		}
135
-
136
-		/**
137
-		 * Get scheme key.
138
-		 *
139
-		 * @return string
140
-		 */
141
-		public static function get_scheme_key(): string {
142
-			return 'redux_cs_' . self::$parent->args['opt_name'] . '_' . self::$field_id;
143
-		}
144
-
145
-		/**
146
-		 * Get the list of groups names for the color scheme table.
147
-		 *
148
-		 * @since       2.0.0
149
-		 * @access      public static
150
-		 * @return      array Array of group names.
151
-		 */
152
-		public static function get_group_names(): array {
153
-			if ( empty( self::$field ) ) {
154
-				self::$field = self::get_field();
155
-			}
156
-
157
-			if ( isset( self::$field['groups'] ) ) {
158
-				if ( is_array( self::$field['groups'] ) && ! empty( self::$field['groups'] ) ) {
159
-					return self::$field['groups'];
160
-				}
161
-			}
162
-
163
-			return array();
164
-		}
165
-
166
-		/**
167
-		 * Get output transparent value.
168
-		 *
169
-		 * @return mixed
170
-		 */
171
-		public static function get_output_transparent_val() {
172
-			if ( empty( self::$field ) ) {
173
-				self::$field = self::get_field();
174
-			}
175
-
176
-			if ( isset( self::$field['output_transparent'] ) ) {
177
-				if ( ! empty( self::$field['output_transparent'] ) ) {
178
-					return self::$field['output_transparent'];
179
-				}
180
-			}
181
-
182
-			return false;
183
-		}
184
-
185
-		/**
186
-		 * Get select field name.
187
-		 *
188
-		 * @return array
189
-		 */
190
-		private static function get_select_names(): array {
191
-			if ( empty( self::$field ) ) {
192
-				self::$field = self::get_field();
193
-			}
194
-
195
-			if ( isset( self::$field['select'] ) ) {
196
-				if ( is_array( self::$field['select'] ) && ! empty( self::$field['select'] ) ) {
197
-					return self::$field['select'];
198
-				}
199
-			}
200
-
201
-			return array();
202
-		}
203
-
204
-		/**
205
-		 * Get color scheme field.
206
-		 *
207
-		 * @param ReduxFramework|null $redux pointer.
208
-		 *
209
-		 * @return mixed
210
-		 */
211
-		public static function get_field( ?ReduxFramework $redux = null ) {
212
-			if ( ! is_null( $redux ) ) {
213
-				self::$parent = $redux;
214
-			}
215
-
216
-			if ( isset( $redux->field_sections['color_scheme'] ) ) {
217
-				return reset( $redux->field_sections['color_scheme'] );
218
-			}
219
-
220
-			$arr = self::$parent;
221
-
222
-			foreach ( $arr as $part => $bla ) {
223
-				if ( 'sections' === $part ) {
224
-					foreach ( $bla as $field ) {
225
-						foreach ( $field as $arg => $val ) {
226
-							if ( 'fields' === $arg ) {
227
-								foreach ( $val as $v ) {
228
-									if ( ! empty( $v ) ) {
229
-										foreach ( $v as $id => $x ) {
230
-											if ( 'type' === $id ) {
231
-												if ( 'color_scheme' === $x ) {
232
-													return $v;
233
-												}
234
-											}
235
-										}
236
-									}
237
-								}
238
-							}
239
-						}
240
-					}
241
-				}
242
-			}
243
-
244
-			return null;
245
-		}
246
-
247
-		/**
248
-		 * Output scheme dropdown selector.
249
-		 *
250
-		 * @param       string $selected Selected scheme name.
251
-		 *
252
-		 * @return      string HTML of dropdown selector.
253
-		 * @since       1.0.0
254
-		 * @access      public static
255
-		 */
256
-		public static function get_scheme_select_html( string $selected ): string {
257
-
258
-			$html  = '<select name="' . esc_attr( self::$parent->args['opt_name'] ) . '[redux-scheme-select]" id="redux-scheme-select-' . esc_attr( self::$field_id ) . '" class="redux-scheme-select">';
259
-			$html .= self::get_scheme_list_html( $selected );
260
-			$html .= '</select>';
261
-
262
-			return $html;
263
-		}
264
-
265
-		/**
266
-		 * Set current scheme ID, if one isn't specified.
267
-		 *
268
-		 * @param       string $id Scheme name to set.
269
-		 *
270
-		 * @return      void
271
-		 * @since       1.0.0
272
-		 * @access      public static
273
-		 */
274
-		public static function set_current_scheme_id( string $id ) {
275
-
276
-			// Get opt name, for database.
277
-			$opt_name = self::$parent->args['opt_name'];
278
-
279
-			// Get all options from database.
280
-			$redux_options = get_option( $opt_name, array() );
281
-			if ( ! is_array( $redux_options ) ) {
282
-				$redux_options = array();
283
-			}
284
-			// Append ID to variable that holds the current scheme ID data.
285
-			$redux_options['redux-scheme-select'] = $id;
286
-
287
-			// Save the modified settings.
288
-			update_option( $opt_name, $redux_options );
289
-		}
290
-
291
-		/**
292
-		 * Get tooltip toggle state.
293
-		 *
294
-		 * @return bool
295
-		 */
296
-		public static function get_tooltip_toggle_state(): bool {
297
-
298
-			// Retrieve the opt_name, needed for database.
299
-			$opt_name = self::$parent->args['opt_name'];
300
-
301
-			// Get the entire options array.
302
-			$redux_options = get_option( $opt_name );
303
-
304
-			return $redux_options['redux-color-scheme-tooltip-toggle'] ?? true;
305
-		}
306
-
307
-		/**
308
-		 * Gets the current schem ID from the database.
309
-		 *
310
-		 * @since       1.0.0
311
-		 * @access      public static
312
-		 *
313
-		 * @return      string Current scheme ID.
314
-		 */
315
-		public static function get_current_scheme_id(): string {
316
-
317
-			// Retrieve the opt_name, needed for databasae.
318
-			$opt_name = self::$parent->args['opt_name'];
319
-
320
-			// Get the entire options array.
321
-			$redux_options = get_option( $opt_name );
322
-
323
-			// If the current scheme key exists...
324
-			return $redux_options['redux-scheme-select'] ?? 'Default';
325
-		}
326
-
327
-		/**
328
-		 * Get the list of schemes for the selector.
329
-		 *
330
-		 * @param       string $sel Scheme name to select.
331
-		 *
332
-		 * @return      string HTML option values.
333
-		 * @since       1.0.0
334
-		 * @access      static private
335
-		 */
336
-		private static function get_scheme_list_html( string $sel = '' ): string {
337
-			// no errors, please.
338
-			$html = '';
339
-
340
-			// Retrieves the list of saved schemes into an array variable.
341
-			$dropdown_values = self::get_scheme_names();
342
-
343
-			// If the dropdown array has items...
344
-			if ( ! empty( $dropdown_values ) ) {
345
-
346
-				// Sort them alphbetically.
347
-				asort( $dropdown_values );
348
-			}
349
-
350
-			// trim the selected item.
351
-			$sel = trim( $sel );
352
-
353
-			// If it's empty.
354
-			if ( '' === $sel ) {
355
-
356
-				// Make the current scheme id the selected value.
357
-				$selected = self::get_current_scheme_id();
358
-			} else {
359
-
360
-				// Otherwise, set it to the value passed to this function.
361
-				$selected = $sel;
362
-			}
363
-
364
-			// Enum through the dropdown array and append the necessary HTML for the selector.
365
-			foreach ( $dropdown_values as $k ) {
366
-				$html .= '<option value="' . $k . '" ' . selected( $k, $selected, false ) . '>' . $k . '</option>';
367
-			}
368
-
369
-			// Send it all packin'.
370
-			return $html;
371
-		}
372
-
373
-		/**
374
-		 * Returns select HTML.
375
-		 *
376
-		 * @param array $arr  Array of select fields to render.
377
-		 * @param array $data Array of scheme data.
378
-		 *
379
-		 * @return      string HTML of select fields.
380
-		 * @since       1.0.4
381
-		 * @access      static private
382
-		 */
383
-		private static function render_selects( array $arr, array $data ): string {
384
-
385
-			$html = '';
386
-			foreach ( $arr as $v ) {
387
-				$id = $v['id'];
388
-
389
-				if ( isset( $v['width'] ) && ! empty( $v['width'] ) ) {
390
-					$size = $v['width'];
391
-				} else {
392
-					$size = '40%';
393
-				}
394
-
395
-				$width = ' style="width: ' . $size . ';"';
396
-
397
-				$html .= '<span class="redux-label redux-color-scheme-opt-select-title">' . $v['title'] . '</span>';
398
-
399
-				$html .= '<select name="' . self::$parent->args['opt_name'] . '[' . self::$field_id . '][' . $id . ']" id="redux-color-scheme-opt-select-' . $id . '"' . $width . ' class="redux-color-scheme-opt-select">';
400
-
401
-				foreach ( $v['options'] as $opt_id => $opt_val ) {
402
-					$data[ $id ]['value'] = $data[ $id ]['value'] ?? '';
403
-					$html                .= '<option value="' . $opt_id . '" ' . selected( $opt_id, $data[ $id ]['value'], false ) . '>' . $opt_val . '</option>';
404
-				}
405
-
406
-				$html .= '</select>';
407
-				$html .= '<span class="redux-label redux-color-scheme-opt-select-desc">' . $v['desc'] . '</span>';
408
-				$html .= '<hr class="redux-color-scheme-select-close-hr">';
409
-				$html .= '<br/>';
410
-			}
411
-
412
-			return $html;
413
-		}
414
-
415
-		/**
416
-		 * Do diff.
417
-		 *
418
-		 * @param array $first_array  Array one.
419
-		 * @param array $second_array Array two.
420
-		 *
421
-		 * @return array
422
-		 */
423
-		private static function do_diff( array $first_array, array $second_array ): array {
424
-
425
-			/**
426
-			 * Serialize callback.
427
-			 *
428
-			 * @param array $arr Array.
429
-			 */
430
-			function redux_my_serialize( array &$arr ) {
431
-				$arr = maybe_serialize( $arr );
432
-			}
433
-
434
-			/**
435
-			 * Unserialize callback.
436
-			 *
437
-			 * @param array $arr Array.
438
-			 */
439
-			function redux_my_unserialize( &$arr ) {
440
-				$arr = maybe_unserialize( $arr );
441
-			}
442
-
443
-			// make a copy.
444
-			$first_array_s  = $first_array;
445
-			$second_array_s = $second_array;
446
-
447
-			// serialize all sub-arrays.
448
-			array_walk( $first_array_s, 'redux_my_serialize' );
449
-			array_walk( $second_array_s, 'redux_my_serialize' );
450
-
451
-			// array_diff the serialized versions.
452
-			$diff = array_diff( $first_array_s, $second_array_s );
453
-
454
-			// unserialize the result.
455
-			array_walk( $diff, 'redux_my_unserialize' );
456
-
457
-			// you've got it!
458
-			return $diff;
459
-		}
460
-
461
-		/**
462
-		 * Returns colour pickers HTML table.
463
-		 *
464
-		 * @since       1.0.0
465
-		 * @access      public static
466
-		 *
467
-		 * @param       string $scheme_id Scheme name of HTML to return.
468
-		 *
469
-		 * @return      string HTML of colour picker table.
470
-		 */
471
-		public static function get_current_color_scheme_html( $scheme_id = false ): string {
472
-
473
-			// If scheme_id is false.
474
-			if ( ! $scheme_id ) {
475
-
476
-				// Attempt to get the current scheme.
477
-				$scheme_id = self::get_current_scheme_id();
478
-
479
-				// dummy check, because this shit happens!
480
-				$arr_schemes = self::get_scheme_names();
481
-
482
-				if ( ! in_array( $scheme_id, $arr_schemes, true ) ) {
483
-					$scheme_id = 'Default';
484
-					self::set_current_scheme_id( 'Default' );
485
-				}
486
-			}
487
-
488
-			// Set oft used variables.
489
-			$opt_name    = esc_attr( self::$parent->args['opt_name'] );
490
-			$field_id    = esc_attr( self::$field_id );
491
-			$field_class = esc_attr( self::$field_class );
492
-
493
-			// Get the default options.
494
-			$field = self::get_field();
495
-
496
-			$field['output_transparent'] = $field['output_transparent'] ?? '';
497
-			$is_accordion                = $field['accordion'] ?? true;
498
-
499
-			$def_opts = $field['default'];
500
-
501
-			// Create array of element ids from default options.
502
-			if ( ! empty( $def_opts ) ) {
503
-				$id_arr = array();
504
-
505
-				foreach ( $def_opts as $vv ) {
506
-					$id_arr[] = $vv['id'];
507
-				}
508
-			}
509
-
510
-			// Get last saved default.
511
-			$saved_def = get_option( 'redux_' . $opt_name . '_' . $field_id . '_color_scheme' );
512
-
513
-			// Compare key counts between saved and current defaults to check
514
-			// for changes in color scheme.
515
-			if ( false !== $saved_def && is_array( $saved_def ) ) {
516
-
517
-				// Get the new color inputs.
518
-				$arr_diff = self::do_diff( $def_opts, $saved_def );
519
-
520
-				if ( ! empty( $arr_diff ) ) {
521
-					update_option( 'redux_' . $opt_name . '_' . $field_id . '_color_scheme', $def_opts );
522
-				}                //}
523
-			} else {
524
-				update_option( 'redux_' . $opt_name . '_' . $field_id . '_color_scheme', $def_opts );
525
-			}
526
-
527
-			// get current scheme data.
528
-			$scheme = self::get_scheme_data( $scheme_id );
529
-
530
-			if ( false === $scheme ) {
531
-				return '';
532
-			}
533
-
534
-			// If new color inputs exist...
535
-			if ( ! empty( $arr_diff ) ) {
536
-				foreach ( $arr_diff as $val ) {
537
-					if ( ! empty( $val ) && isset( $val['id'] ) ) {
538
-
539
-						$val['title'] = $val['title'] ?? $val['id'];
540
-						$val['color'] = $val['color'] ?? '';
541
-						$val['alpha'] = $val['alpha'] ?? 1;
542
-
543
-						$trans        = $field['output_transparent'];
544
-						$res          = ( '' === $val['color'] || 'transparent' === $val['color'] ) ? $trans : Redux_Helpers::hex2rgba( $val['color'], $val['alpha'] );
545
-						$val['rgba']  = $val['rgba'] ?? $res;
546
-						$val['group'] = $val['group'] ?? '';
547
-
548
-						$scheme[ $val['id'] ] = $val;
549
-					}
550
-				}
551
-
552
-				// Get list of scheme names.
553
-				$scheme_names = self::get_scheme_names();
554
-
555
-				// Update is saved scheme with new picker data.
556
-				foreach ( $scheme_names as $name ) {
557
-					self::set_scheme_data( $name, $scheme );
558
-				}
559
-
560
-				// update the database.
561
-				self::set_database_data( $scheme_id );
562
-			}
563
-
564
-			// If it's not empty then...
565
-			if ( ! empty( $scheme ) ) {
566
-
567
-				// init arrays.
568
-				$groups     = array();
569
-				$grp_desc   = array();
570
-				$groups[''] = array();
571
-				$sel_grps   = array();
572
-
573
-				if ( ! isset( self::$select ) ) {
574
-					self::$select = self::get_select_names();
575
-				}
576
-
577
-				// Enum select fields into groups array for later render.
578
-				if ( isset( self::$select ) ) {
579
-					foreach ( self::$select as $sel_arr ) {
580
-						$sel_grp = $sel_arr['group'];
581
-						if ( ! array_key_exists( $sel_grp, $sel_grps ) ) {
582
-							$sel_grps[ $sel_grp ] = array();
583
-						}
584
-						$sel_grps[ $sel_grp ][] = $sel_arr;
585
-					}
586
-				}
587
-
588
-				// Enum groups names.
589
-				$group_arr = self::get_group_names();
590
-
591
-				foreach ( $group_arr as $group_name => $description ) {
592
-					$groups[ $group_name ] = array();
593
-
594
-					if ( is_array( $description ) ) {
595
-						$grp_desc[ $group_name ]           = $description['desc'] ?? '';
596
-						$grp_grpdesc[ $group_name ]        = $description['group_desc'] ?? '';
597
-						$grp_hidden[ $group_name ]         = $description['hidden'] ?? false;
598
-						$grp_accordion_open[ $group_name ] = $description['accordion_open'] ?? false;
599
-
600
-					} else {
601
-						$grp_desc[ $group_name ]           = $description;
602
-						$grp_hidden[ $group_name ]         = false;
603
-						$grp_accordion_open[ $group_name ] = false;
604
-						$grp_grpdesc[ $group_name ]        = false;
605
-					}
606
-				}
607
-
608
-				// Assign color pickers to their specified group.
609
-				foreach ( $scheme as $arr ) {
610
-					if ( is_array( $arr ) ) {
611
-						if ( ! empty( $arr['group'] ) ) {
612
-							if ( array_key_exists( $arr['group'], $group_arr ) ) {
613
-								$groups[ $arr['group'] ][] = $arr;
614
-							} else {
615
-								$groups[''][] = $arr;
616
-							}
617
-						} else {
618
-							$groups[''][] = $arr;
619
-						}
620
-					}
621
-				}
622
-
623
-				$open_icon  = '';
624
-				$close_icon = '';
625
-
626
-				if ( $is_accordion ) {
627
-					$open_icon  = apply_filters( 'redux/extension/color_scheme/' . self::$parent->args['opt_name'] . '/icon/open', 'dashicons dashicons-arrow-down' ); // phpcs:ignore WordPress.NamingConventions.ValidHookName
628
-					$close_icon = apply_filters( 'redux/extension/color_scheme/' . self::$parent->args['opt_name'] . '/icon/close', 'dashicons dashicons-arrow-up' ); // phpcs:ignore WordPress.NamingConventions.ValidHookName
629
-				}
630
-
631
-				// open the list.
632
-				$html = '<ul class="redux-scheme-layout" data-open-icon="' . $open_icon . '" data-close-icon="' . $close_icon . '">';
633
-
634
-				// Enumerate groups.
635
-				foreach ( $groups as $title => $scheme_arr ) {
636
-
637
-					if ( '' === $title ) {
638
-						if ( empty( $scheme_arr ) ) {
639
-							continue;
640
-						}
641
-
642
-						$kill_me = false;
643
-						foreach ( $scheme_arr as $data ) {
644
-							if ( ! array_key_exists( 'color', $data ) ) {
645
-								$kill_me = true;
646
-								break;
647
-							}
648
-						}
649
-						if ( $kill_me ) {
650
-							continue;
651
-						}
652
-					}
653
-
654
-					$add_hr     = false;
655
-					$is_hidden  = false;
656
-					$class_hide = '';
657
-					$is_open    = '';
658
-
659
-					if ( isset( $grp_hidden[ $title ] ) && '' !== $grp_hidden[ $title ] ) {
660
-						$is_hidden  = $grp_hidden[ $title ];
661
-						$class_hide = ( true === $is_hidden ) ? ' hidden ' : '';
662
-						$is_open    = $grp_accordion_open[ $title ];
663
-					}
664
-
665
-					$add_class = '';
666
-					if ( $is_accordion ) {
667
-						$add_class = ' accordion ';
668
-					}
669
-
670
-					$html .= '<div class="redux-color-scheme-group' . $add_class . $class_hide . '">';
671
-
672
-					if ( ! $is_hidden ) {
673
-
674
-						if ( $is_accordion ) {
675
-							$html .= '<div class="redux-color-scheme-accordion">';
676
-						}
677
-						$icon_class = '';
678
-
679
-						// apply group title, if any.
680
-						if ( '' !== $title ) {
681
-							$html .= '<br><span class="redux-label redux-layout-group-label">' . esc_attr( $title ) . '</span>';
682
-
683
-							if ( $is_accordion ) {
684
-								$icon_class = ' titled';
685
-							}
686
-							$add_hr = true;
687
-						} elseif ( $is_accordion ) {
688
-							$icon_class = ' not-titled';
689
-						}
690
-
691
-						// apply group description, if any.
692
-						if ( isset( $grp_desc[ $title ] ) && '' !== $grp_desc[ $title ] ) {
693
-							$html  .= '<span class="redux-label redux-layout-group-desc-label' . $icon_class . '">' . esc_attr( $grp_desc[ $title ] ) . '</label>';
694
-							$add_hr = true;
695
-
696
-							if ( $is_accordion ) {
697
-								$icon_class .= ' subtitled';
698
-							}
699
-						} else {
700
-							$icon_class .= ' not-subtitled';
701
-						}
702
-
703
-						if ( $is_accordion ) {
704
-							$html .= '<span class="' . esc_attr( $open_icon ) . $icon_class . '"></span>';
705
-						}
706
-
707
-						// Add HR, if needed.
708
-						if ( true === $add_hr ) {
709
-							if ( ! $is_accordion ) {
710
-								$html .= '<hr>';
711
-							}
712
-						}
713
-
714
-						if ( $is_accordion ) {
715
-							$html .= '</div>';
716
-							$html .= '<div class="redux-color-scheme-accordion-section" data-state="' . esc_attr( $is_open ) . '">';
717
-							if ( false !== $grp_grpdesc ) {
718
-								$html .= '<div class="redux-color-scheme-group-desc">';
719
-								$html .= esc_attr( $grp_grpdesc[ $title ] );
720
-								$html .= '</div>';
721
-							}
722
-						}
723
-
724
-						// Select box render.
725
-						if ( array_key_exists( $title, $sel_grps ) ) {
726
-							$html .= self::render_selects( $sel_grps[ $title ], $scheme );
727
-						}
728
-					} elseif ( $is_accordion ) {
729
-						$html .= '<div class="redux-color-scheme-accordion-section">';
730
-					}
731
-
732
-					$html .= "<ul class='redux-scheme-layout'>";
733
-
734
-					// Enum through each element/id.
735
-					foreach ( $scheme_arr as $v ) {
736
-						if ( in_array( $v['id'], $id_arr, true ) ) {
737
-
738
-							// If no title, use ID.
739
-							$v['title'] = $v['title'] ?? $v['id'];
740
-
741
-							// If no alpha, use 1 (solid).
742
-							$v['alpha'] = $v['alpha'] ?? 1;
743
-
744
-							// Fuck forbid no colour, set to white.
745
-							$v['color'] = $v['color'] ?? '';
746
-
747
-							// RGBA..
748
-							$trans     = $field['output_transparent'];
749
-							$res       = ( '' === $v['color'] || 'transparent' === $v['color'] ) ? $trans : Redux_Helpers::hex2rgba( $v['color'], $v['alpha'] );
750
-							$v['rgba'] = $v['rgba'] ?? $res;
751
-
752
-							// group name.
753
-							$v['group'] = $v['group'] ?? '';
754
-
755
-							$v['class'] = self::get_color_block_class( $field, $v['id'] );
756
-
757
-							$block_hide = self::get_block_hidden( $field, $v['id'] ) ? 'hidden' : '';
758
-
759
-							// tooltips.
760
-							$tip_title = '';
761
-							$tip_text  = '';
762
-
763
-							$tooltip_data = self::get_tooltip_data( $field, $v['id'] );
764
-							if ( false !== $tooltip_data ) {
765
-								$tip_title = $tooltip_data['title'] ?? '';
766
-								$tip_text  = $tooltip_data['text'] ?? '';
767
-							}
768
-
769
-							// Begin the layout.
770
-							$html .= '<li class="redux-scheme-layout ' . $class_hide . ' redux-cs-qtip ' . $block_hide . '" qtip-title="' . esc_attr( $tip_title ) . '" qtip-content="' . esc_attr( $tip_text ) . '">';
771
-							$html .= '<div class="redux-scheme-layout-container" data-id="' . $field_id . '-' . $v['id'] . '">';
772
-
773
-							if ( '' === $v['color'] || 'transparent' === $v['color'] ) {
774
-								$color = '';
775
-							} else {
776
-								$color = 'rgba(' . $v['rgba'] . ')';
777
-							}
778
-
779
-							// colour picker dropdown.
780
-							$html .= '<input
14
+    /**
15
+     * Class Redux_Color_Scheme_Functions
16
+     */
17
+    class Redux_Color_Scheme_Functions {
18
+
19
+        /**
20
+         * ReduxFramework object.
21
+         *
22
+         * @var null|ReduxFramework
23
+         */
24
+        public static ?ReduxFramework $parent;
25
+
26
+        /**
27
+         * Field ID
28
+         *
29
+         * @var string|null
30
+         */
31
+        public static ?string $field_id;
32
+
33
+        /**
34
+         * Field class.
35
+         *
36
+         * @var string|null
37
+         */
38
+        public static ?string $field_class;
39
+
40
+        /**
41
+         * Field array.
42
+         *
43
+         * @var array|null
44
+         */
45
+        public static ?array $field;
46
+
47
+        /**
48
+         * WP Upload directory.
49
+         *
50
+         * @var string|null
51
+         */
52
+        public static ?string $upload_dir = '';
53
+
54
+        /**
55
+         * WP Upload URI
56
+         *
57
+         * @var string|null
58
+         */
59
+        public static ?string $upload_url = '';
60
+
61
+        /**
62
+         * Select fields.
63
+         *
64
+         * @var array|null
65
+         */
66
+        public static ?array $select;
67
+
68
+        /**
69
+         * Class init.
70
+         *
71
+         * @param ReduxFramework $redux ReduxFramework object.
72
+         */
73
+        public static function init( ReduxFramework $redux ) {
74
+            self::$parent = $redux;
75
+
76
+            if ( empty( self::$field_id ) ) {
77
+                self::$field = self::get_field( $redux );
78
+
79
+                if ( ! is_array( self::$field ) ) {
80
+                    return;
81
+                }
82
+
83
+                self::$field_id = self::$field['id'];
84
+            }
85
+
86
+            // Make sanitized upload dir DIR.
87
+            self::$upload_dir = Redux_Functions_Ex::wp_normalize_path( ReduxFramework::$_upload_dir . 'color-schemes/' );
88
+
89
+            // Make sanitized upload dir URL.
90
+            self::$upload_url = Redux_Functions_Ex::wp_normalize_path( ReduxFramework::$_upload_url . 'color-schemes/' );
91
+
92
+            Redux_Functions::init_wp_filesystem();
93
+        }
94
+
95
+        /**
96
+         * Checks if tooltips are in use.
97
+         *
98
+         * @param array $field Field array.
99
+         *
100
+         * @return bool
101
+         */
102
+        public static function tooltips_in_use( array $field ): bool {
103
+            $blocks = $field['default'];
104
+
105
+            foreach ( $blocks as $arr ) {
106
+                if ( isset( $arr['tooltip'] ) ) {
107
+                    return true;
108
+                }
109
+            }
110
+
111
+            return false;
112
+        }
113
+
114
+        /**
115
+         * Convert DB values.
116
+         */
117
+        public static function convert_to_db() {
118
+            $upload_dir = Redux_Functions_Ex::wp_normalize_path( ReduxFramework::$_upload_dir . 'color-schemes/' );
119
+
120
+            $cur_scheme_file = Redux_Functions_Ex::wp_normalize_path( $upload_dir . '/' . self::$parent->args['opt_name'] . '_' . self::$field_id . '.json' );
121
+
122
+            if ( is_dir( $upload_dir ) ) {
123
+                if ( file_exists( $cur_scheme_file ) ) {
124
+                    $data = Redux_Core::$filesystem->execute( 'get_contents', $cur_scheme_file );
125
+                    if ( ! empty( $data ) ) {
126
+                        $data = json_decode( $data, true );
127
+
128
+                        update_option( self::get_scheme_key(), $data );
129
+
130
+                        Redux_Core::$filesystem->execute( 'delete', $cur_scheme_file );
131
+                    }
132
+                }
133
+            }
134
+        }
135
+
136
+        /**
137
+         * Get scheme key.
138
+         *
139
+         * @return string
140
+         */
141
+        public static function get_scheme_key(): string {
142
+            return 'redux_cs_' . self::$parent->args['opt_name'] . '_' . self::$field_id;
143
+        }
144
+
145
+        /**
146
+         * Get the list of groups names for the color scheme table.
147
+         *
148
+         * @since       2.0.0
149
+         * @access      public static
150
+         * @return      array Array of group names.
151
+         */
152
+        public static function get_group_names(): array {
153
+            if ( empty( self::$field ) ) {
154
+                self::$field = self::get_field();
155
+            }
156
+
157
+            if ( isset( self::$field['groups'] ) ) {
158
+                if ( is_array( self::$field['groups'] ) && ! empty( self::$field['groups'] ) ) {
159
+                    return self::$field['groups'];
160
+                }
161
+            }
162
+
163
+            return array();
164
+        }
165
+
166
+        /**
167
+         * Get output transparent value.
168
+         *
169
+         * @return mixed
170
+         */
171
+        public static function get_output_transparent_val() {
172
+            if ( empty( self::$field ) ) {
173
+                self::$field = self::get_field();
174
+            }
175
+
176
+            if ( isset( self::$field['output_transparent'] ) ) {
177
+                if ( ! empty( self::$field['output_transparent'] ) ) {
178
+                    return self::$field['output_transparent'];
179
+                }
180
+            }
181
+
182
+            return false;
183
+        }
184
+
185
+        /**
186
+         * Get select field name.
187
+         *
188
+         * @return array
189
+         */
190
+        private static function get_select_names(): array {
191
+            if ( empty( self::$field ) ) {
192
+                self::$field = self::get_field();
193
+            }
194
+
195
+            if ( isset( self::$field['select'] ) ) {
196
+                if ( is_array( self::$field['select'] ) && ! empty( self::$field['select'] ) ) {
197
+                    return self::$field['select'];
198
+                }
199
+            }
200
+
201
+            return array();
202
+        }
203
+
204
+        /**
205
+         * Get color scheme field.
206
+         *
207
+         * @param ReduxFramework|null $redux pointer.
208
+         *
209
+         * @return mixed
210
+         */
211
+        public static function get_field( ?ReduxFramework $redux = null ) {
212
+            if ( ! is_null( $redux ) ) {
213
+                self::$parent = $redux;
214
+            }
215
+
216
+            if ( isset( $redux->field_sections['color_scheme'] ) ) {
217
+                return reset( $redux->field_sections['color_scheme'] );
218
+            }
219
+
220
+            $arr = self::$parent;
221
+
222
+            foreach ( $arr as $part => $bla ) {
223
+                if ( 'sections' === $part ) {
224
+                    foreach ( $bla as $field ) {
225
+                        foreach ( $field as $arg => $val ) {
226
+                            if ( 'fields' === $arg ) {
227
+                                foreach ( $val as $v ) {
228
+                                    if ( ! empty( $v ) ) {
229
+                                        foreach ( $v as $id => $x ) {
230
+                                            if ( 'type' === $id ) {
231
+                                                if ( 'color_scheme' === $x ) {
232
+                                                    return $v;
233
+                                                }
234
+                                            }
235
+                                        }
236
+                                    }
237
+                                }
238
+                            }
239
+                        }
240
+                    }
241
+                }
242
+            }
243
+
244
+            return null;
245
+        }
246
+
247
+        /**
248
+         * Output scheme dropdown selector.
249
+         *
250
+         * @param       string $selected Selected scheme name.
251
+         *
252
+         * @return      string HTML of dropdown selector.
253
+         * @since       1.0.0
254
+         * @access      public static
255
+         */
256
+        public static function get_scheme_select_html( string $selected ): string {
257
+
258
+            $html  = '<select name="' . esc_attr( self::$parent->args['opt_name'] ) . '[redux-scheme-select]" id="redux-scheme-select-' . esc_attr( self::$field_id ) . '" class="redux-scheme-select">';
259
+            $html .= self::get_scheme_list_html( $selected );
260
+            $html .= '</select>';
261
+
262
+            return $html;
263
+        }
264
+
265
+        /**
266
+         * Set current scheme ID, if one isn't specified.
267
+         *
268
+         * @param       string $id Scheme name to set.
269
+         *
270
+         * @return      void
271
+         * @since       1.0.0
272
+         * @access      public static
273
+         */
274
+        public static function set_current_scheme_id( string $id ) {
275
+
276
+            // Get opt name, for database.
277
+            $opt_name = self::$parent->args['opt_name'];
278
+
279
+            // Get all options from database.
280
+            $redux_options = get_option( $opt_name, array() );
281
+            if ( ! is_array( $redux_options ) ) {
282
+                $redux_options = array();
283
+            }
284
+            // Append ID to variable that holds the current scheme ID data.
285
+            $redux_options['redux-scheme-select'] = $id;
286
+
287
+            // Save the modified settings.
288
+            update_option( $opt_name, $redux_options );
289
+        }
290
+
291
+        /**
292
+         * Get tooltip toggle state.
293
+         *
294
+         * @return bool
295
+         */
296
+        public static function get_tooltip_toggle_state(): bool {
297
+
298
+            // Retrieve the opt_name, needed for database.
299
+            $opt_name = self::$parent->args['opt_name'];
300
+
301
+            // Get the entire options array.
302
+            $redux_options = get_option( $opt_name );
303
+
304
+            return $redux_options['redux-color-scheme-tooltip-toggle'] ?? true;
305
+        }
306
+
307
+        /**
308
+         * Gets the current schem ID from the database.
309
+         *
310
+         * @since       1.0.0
311
+         * @access      public static
312
+         *
313
+         * @return      string Current scheme ID.
314
+         */
315
+        public static function get_current_scheme_id(): string {
316
+
317
+            // Retrieve the opt_name, needed for databasae.
318
+            $opt_name = self::$parent->args['opt_name'];
319
+
320
+            // Get the entire options array.
321
+            $redux_options = get_option( $opt_name );
322
+
323
+            // If the current scheme key exists...
324
+            return $redux_options['redux-scheme-select'] ?? 'Default';
325
+        }
326
+
327
+        /**
328
+         * Get the list of schemes for the selector.
329
+         *
330
+         * @param       string $sel Scheme name to select.
331
+         *
332
+         * @return      string HTML option values.
333
+         * @since       1.0.0
334
+         * @access      static private
335
+         */
336
+        private static function get_scheme_list_html( string $sel = '' ): string {
337
+            // no errors, please.
338
+            $html = '';
339
+
340
+            // Retrieves the list of saved schemes into an array variable.
341
+            $dropdown_values = self::get_scheme_names();
342
+
343
+            // If the dropdown array has items...
344
+            if ( ! empty( $dropdown_values ) ) {
345
+
346
+                // Sort them alphbetically.
347
+                asort( $dropdown_values );
348
+            }
349
+
350
+            // trim the selected item.
351
+            $sel = trim( $sel );
352
+
353
+            // If it's empty.
354
+            if ( '' === $sel ) {
355
+
356
+                // Make the current scheme id the selected value.
357
+                $selected = self::get_current_scheme_id();
358
+            } else {
359
+
360
+                // Otherwise, set it to the value passed to this function.
361
+                $selected = $sel;
362
+            }
363
+
364
+            // Enum through the dropdown array and append the necessary HTML for the selector.
365
+            foreach ( $dropdown_values as $k ) {
366
+                $html .= '<option value="' . $k . '" ' . selected( $k, $selected, false ) . '>' . $k . '</option>';
367
+            }
368
+
369
+            // Send it all packin'.
370
+            return $html;
371
+        }
372
+
373
+        /**
374
+         * Returns select HTML.
375
+         *
376
+         * @param array $arr  Array of select fields to render.
377
+         * @param array $data Array of scheme data.
378
+         *
379
+         * @return      string HTML of select fields.
380
+         * @since       1.0.4
381
+         * @access      static private
382
+         */
383
+        private static function render_selects( array $arr, array $data ): string {
384
+
385
+            $html = '';
386
+            foreach ( $arr as $v ) {
387
+                $id = $v['id'];
388
+
389
+                if ( isset( $v['width'] ) && ! empty( $v['width'] ) ) {
390
+                    $size = $v['width'];
391
+                } else {
392
+                    $size = '40%';
393
+                }
394
+
395
+                $width = ' style="width: ' . $size . ';"';
396
+
397
+                $html .= '<span class="redux-label redux-color-scheme-opt-select-title">' . $v['title'] . '</span>';
398
+
399
+                $html .= '<select name="' . self::$parent->args['opt_name'] . '[' . self::$field_id . '][' . $id . ']" id="redux-color-scheme-opt-select-' . $id . '"' . $width . ' class="redux-color-scheme-opt-select">';
400
+
401
+                foreach ( $v['options'] as $opt_id => $opt_val ) {
402
+                    $data[ $id ]['value'] = $data[ $id ]['value'] ?? '';
403
+                    $html                .= '<option value="' . $opt_id . '" ' . selected( $opt_id, $data[ $id ]['value'], false ) . '>' . $opt_val . '</option>';
404
+                }
405
+
406
+                $html .= '</select>';
407
+                $html .= '<span class="redux-label redux-color-scheme-opt-select-desc">' . $v['desc'] . '</span>';
408
+                $html .= '<hr class="redux-color-scheme-select-close-hr">';
409
+                $html .= '<br/>';
410
+            }
411
+
412
+            return $html;
413
+        }
414
+
415
+        /**
416
+         * Do diff.
417
+         *
418
+         * @param array $first_array  Array one.
419
+         * @param array $second_array Array two.
420
+         *
421
+         * @return array
422
+         */
423
+        private static function do_diff( array $first_array, array $second_array ): array {
424
+
425
+            /**
426
+             * Serialize callback.
427
+             *
428
+             * @param array $arr Array.
429
+             */
430
+            function redux_my_serialize( array &$arr ) {
431
+                $arr = maybe_serialize( $arr );
432
+            }
433
+
434
+            /**
435
+             * Unserialize callback.
436
+             *
437
+             * @param array $arr Array.
438
+             */
439
+            function redux_my_unserialize( &$arr ) {
440
+                $arr = maybe_unserialize( $arr );
441
+            }
442
+
443
+            // make a copy.
444
+            $first_array_s  = $first_array;
445
+            $second_array_s = $second_array;
446
+
447
+            // serialize all sub-arrays.
448
+            array_walk( $first_array_s, 'redux_my_serialize' );
449
+            array_walk( $second_array_s, 'redux_my_serialize' );
450
+
451
+            // array_diff the serialized versions.
452
+            $diff = array_diff( $first_array_s, $second_array_s );
453
+
454
+            // unserialize the result.
455
+            array_walk( $diff, 'redux_my_unserialize' );
456
+
457
+            // you've got it!
458
+            return $diff;
459
+        }
460
+
461
+        /**
462
+         * Returns colour pickers HTML table.
463
+         *
464
+         * @since       1.0.0
465
+         * @access      public static
466
+         *
467
+         * @param       string $scheme_id Scheme name of HTML to return.
468
+         *
469
+         * @return      string HTML of colour picker table.
470
+         */
471
+        public static function get_current_color_scheme_html( $scheme_id = false ): string {
472
+
473
+            // If scheme_id is false.
474
+            if ( ! $scheme_id ) {
475
+
476
+                // Attempt to get the current scheme.
477
+                $scheme_id = self::get_current_scheme_id();
478
+
479
+                // dummy check, because this shit happens!
480
+                $arr_schemes = self::get_scheme_names();
481
+
482
+                if ( ! in_array( $scheme_id, $arr_schemes, true ) ) {
483
+                    $scheme_id = 'Default';
484
+                    self::set_current_scheme_id( 'Default' );
485
+                }
486
+            }
487
+
488
+            // Set oft used variables.
489
+            $opt_name    = esc_attr( self::$parent->args['opt_name'] );
490
+            $field_id    = esc_attr( self::$field_id );
491
+            $field_class = esc_attr( self::$field_class );
492
+
493
+            // Get the default options.
494
+            $field = self::get_field();
495
+
496
+            $field['output_transparent'] = $field['output_transparent'] ?? '';
497
+            $is_accordion                = $field['accordion'] ?? true;
498
+
499
+            $def_opts = $field['default'];
500
+
501
+            // Create array of element ids from default options.
502
+            if ( ! empty( $def_opts ) ) {
503
+                $id_arr = array();
504
+
505
+                foreach ( $def_opts as $vv ) {
506
+                    $id_arr[] = $vv['id'];
507
+                }
508
+            }
509
+
510
+            // Get last saved default.
511
+            $saved_def = get_option( 'redux_' . $opt_name . '_' . $field_id . '_color_scheme' );
512
+
513
+            // Compare key counts between saved and current defaults to check
514
+            // for changes in color scheme.
515
+            if ( false !== $saved_def && is_array( $saved_def ) ) {
516
+
517
+                // Get the new color inputs.
518
+                $arr_diff = self::do_diff( $def_opts, $saved_def );
519
+
520
+                if ( ! empty( $arr_diff ) ) {
521
+                    update_option( 'redux_' . $opt_name . '_' . $field_id . '_color_scheme', $def_opts );
522
+                }                //}
523
+            } else {
524
+                update_option( 'redux_' . $opt_name . '_' . $field_id . '_color_scheme', $def_opts );
525
+            }
526
+
527
+            // get current scheme data.
528
+            $scheme = self::get_scheme_data( $scheme_id );
529
+
530
+            if ( false === $scheme ) {
531
+                return '';
532
+            }
533
+
534
+            // If new color inputs exist...
535
+            if ( ! empty( $arr_diff ) ) {
536
+                foreach ( $arr_diff as $val ) {
537
+                    if ( ! empty( $val ) && isset( $val['id'] ) ) {
538
+
539
+                        $val['title'] = $val['title'] ?? $val['id'];
540
+                        $val['color'] = $val['color'] ?? '';
541
+                        $val['alpha'] = $val['alpha'] ?? 1;
542
+
543
+                        $trans        = $field['output_transparent'];
544
+                        $res          = ( '' === $val['color'] || 'transparent' === $val['color'] ) ? $trans : Redux_Helpers::hex2rgba( $val['color'], $val['alpha'] );
545
+                        $val['rgba']  = $val['rgba'] ?? $res;
546
+                        $val['group'] = $val['group'] ?? '';
547
+
548
+                        $scheme[ $val['id'] ] = $val;
549
+                    }
550
+                }
551
+
552
+                // Get list of scheme names.
553
+                $scheme_names = self::get_scheme_names();
554
+
555
+                // Update is saved scheme with new picker data.
556
+                foreach ( $scheme_names as $name ) {
557
+                    self::set_scheme_data( $name, $scheme );
558
+                }
559
+
560
+                // update the database.
561
+                self::set_database_data( $scheme_id );
562
+            }
563
+
564
+            // If it's not empty then...
565
+            if ( ! empty( $scheme ) ) {
566
+
567
+                // init arrays.
568
+                $groups     = array();
569
+                $grp_desc   = array();
570
+                $groups[''] = array();
571
+                $sel_grps   = array();
572
+
573
+                if ( ! isset( self::$select ) ) {
574
+                    self::$select = self::get_select_names();
575
+                }
576
+
577
+                // Enum select fields into groups array for later render.
578
+                if ( isset( self::$select ) ) {
579
+                    foreach ( self::$select as $sel_arr ) {
580
+                        $sel_grp = $sel_arr['group'];
581
+                        if ( ! array_key_exists( $sel_grp, $sel_grps ) ) {
582
+                            $sel_grps[ $sel_grp ] = array();
583
+                        }
584
+                        $sel_grps[ $sel_grp ][] = $sel_arr;
585
+                    }
586
+                }
587
+
588
+                // Enum groups names.
589
+                $group_arr = self::get_group_names();
590
+
591
+                foreach ( $group_arr as $group_name => $description ) {
592
+                    $groups[ $group_name ] = array();
593
+
594
+                    if ( is_array( $description ) ) {
595
+                        $grp_desc[ $group_name ]           = $description['desc'] ?? '';
596
+                        $grp_grpdesc[ $group_name ]        = $description['group_desc'] ?? '';
597
+                        $grp_hidden[ $group_name ]         = $description['hidden'] ?? false;
598
+                        $grp_accordion_open[ $group_name ] = $description['accordion_open'] ?? false;
599
+
600
+                    } else {
601
+                        $grp_desc[ $group_name ]           = $description;
602
+                        $grp_hidden[ $group_name ]         = false;
603
+                        $grp_accordion_open[ $group_name ] = false;
604
+                        $grp_grpdesc[ $group_name ]        = false;
605
+                    }
606
+                }
607
+
608
+                // Assign color pickers to their specified group.
609
+                foreach ( $scheme as $arr ) {
610
+                    if ( is_array( $arr ) ) {
611
+                        if ( ! empty( $arr['group'] ) ) {
612
+                            if ( array_key_exists( $arr['group'], $group_arr ) ) {
613
+                                $groups[ $arr['group'] ][] = $arr;
614
+                            } else {
615
+                                $groups[''][] = $arr;
616
+                            }
617
+                        } else {
618
+                            $groups[''][] = $arr;
619
+                        }
620
+                    }
621
+                }
622
+
623
+                $open_icon  = '';
624
+                $close_icon = '';
625
+
626
+                if ( $is_accordion ) {
627
+                    $open_icon  = apply_filters( 'redux/extension/color_scheme/' . self::$parent->args['opt_name'] . '/icon/open', 'dashicons dashicons-arrow-down' ); // phpcs:ignore WordPress.NamingConventions.ValidHookName
628
+                    $close_icon = apply_filters( 'redux/extension/color_scheme/' . self::$parent->args['opt_name'] . '/icon/close', 'dashicons dashicons-arrow-up' ); // phpcs:ignore WordPress.NamingConventions.ValidHookName
629
+                }
630
+
631
+                // open the list.
632
+                $html = '<ul class="redux-scheme-layout" data-open-icon="' . $open_icon . '" data-close-icon="' . $close_icon . '">';
633
+
634
+                // Enumerate groups.
635
+                foreach ( $groups as $title => $scheme_arr ) {
636
+
637
+                    if ( '' === $title ) {
638
+                        if ( empty( $scheme_arr ) ) {
639
+                            continue;
640
+                        }
641
+
642
+                        $kill_me = false;
643
+                        foreach ( $scheme_arr as $data ) {
644
+                            if ( ! array_key_exists( 'color', $data ) ) {
645
+                                $kill_me = true;
646
+                                break;
647
+                            }
648
+                        }
649
+                        if ( $kill_me ) {
650
+                            continue;
651
+                        }
652
+                    }
653
+
654
+                    $add_hr     = false;
655
+                    $is_hidden  = false;
656
+                    $class_hide = '';
657
+                    $is_open    = '';
658
+
659
+                    if ( isset( $grp_hidden[ $title ] ) && '' !== $grp_hidden[ $title ] ) {
660
+                        $is_hidden  = $grp_hidden[ $title ];
661
+                        $class_hide = ( true === $is_hidden ) ? ' hidden ' : '';
662
+                        $is_open    = $grp_accordion_open[ $title ];
663
+                    }
664
+
665
+                    $add_class = '';
666
+                    if ( $is_accordion ) {
667
+                        $add_class = ' accordion ';
668
+                    }
669
+
670
+                    $html .= '<div class="redux-color-scheme-group' . $add_class . $class_hide . '">';
671
+
672
+                    if ( ! $is_hidden ) {
673
+
674
+                        if ( $is_accordion ) {
675
+                            $html .= '<div class="redux-color-scheme-accordion">';
676
+                        }
677
+                        $icon_class = '';
678
+
679
+                        // apply group title, if any.
680
+                        if ( '' !== $title ) {
681
+                            $html .= '<br><span class="redux-label redux-layout-group-label">' . esc_attr( $title ) . '</span>';
682
+
683
+                            if ( $is_accordion ) {
684
+                                $icon_class = ' titled';
685
+                            }
686
+                            $add_hr = true;
687
+                        } elseif ( $is_accordion ) {
688
+                            $icon_class = ' not-titled';
689
+                        }
690
+
691
+                        // apply group description, if any.
692
+                        if ( isset( $grp_desc[ $title ] ) && '' !== $grp_desc[ $title ] ) {
693
+                            $html  .= '<span class="redux-label redux-layout-group-desc-label' . $icon_class . '">' . esc_attr( $grp_desc[ $title ] ) . '</label>';
694
+                            $add_hr = true;
695
+
696
+                            if ( $is_accordion ) {
697
+                                $icon_class .= ' subtitled';
698
+                            }
699
+                        } else {
700
+                            $icon_class .= ' not-subtitled';
701
+                        }
702
+
703
+                        if ( $is_accordion ) {
704
+                            $html .= '<span class="' . esc_attr( $open_icon ) . $icon_class . '"></span>';
705
+                        }
706
+
707
+                        // Add HR, if needed.
708
+                        if ( true === $add_hr ) {
709
+                            if ( ! $is_accordion ) {
710
+                                $html .= '<hr>';
711
+                            }
712
+                        }
713
+
714
+                        if ( $is_accordion ) {
715
+                            $html .= '</div>';
716
+                            $html .= '<div class="redux-color-scheme-accordion-section" data-state="' . esc_attr( $is_open ) . '">';
717
+                            if ( false !== $grp_grpdesc ) {
718
+                                $html .= '<div class="redux-color-scheme-group-desc">';
719
+                                $html .= esc_attr( $grp_grpdesc[ $title ] );
720
+                                $html .= '</div>';
721
+                            }
722
+                        }
723
+
724
+                        // Select box render.
725
+                        if ( array_key_exists( $title, $sel_grps ) ) {
726
+                            $html .= self::render_selects( $sel_grps[ $title ], $scheme );
727
+                        }
728
+                    } elseif ( $is_accordion ) {
729
+                        $html .= '<div class="redux-color-scheme-accordion-section">';
730
+                    }
731
+
732
+                    $html .= "<ul class='redux-scheme-layout'>";
733
+
734
+                    // Enum through each element/id.
735
+                    foreach ( $scheme_arr as $v ) {
736
+                        if ( in_array( $v['id'], $id_arr, true ) ) {
737
+
738
+                            // If no title, use ID.
739
+                            $v['title'] = $v['title'] ?? $v['id'];
740
+
741
+                            // If no alpha, use 1 (solid).
742
+                            $v['alpha'] = $v['alpha'] ?? 1;
743
+
744
+                            // Fuck forbid no colour, set to white.
745
+                            $v['color'] = $v['color'] ?? '';
746
+
747
+                            // RGBA..
748
+                            $trans     = $field['output_transparent'];
749
+                            $res       = ( '' === $v['color'] || 'transparent' === $v['color'] ) ? $trans : Redux_Helpers::hex2rgba( $v['color'], $v['alpha'] );
750
+                            $v['rgba'] = $v['rgba'] ?? $res;
751
+
752
+                            // group name.
753
+                            $v['group'] = $v['group'] ?? '';
754
+
755
+                            $v['class'] = self::get_color_block_class( $field, $v['id'] );
756
+
757
+                            $block_hide = self::get_block_hidden( $field, $v['id'] ) ? 'hidden' : '';
758
+
759
+                            // tooltips.
760
+                            $tip_title = '';
761
+                            $tip_text  = '';
762
+
763
+                            $tooltip_data = self::get_tooltip_data( $field, $v['id'] );
764
+                            if ( false !== $tooltip_data ) {
765
+                                $tip_title = $tooltip_data['title'] ?? '';
766
+                                $tip_text  = $tooltip_data['text'] ?? '';
767
+                            }
768
+
769
+                            // Begin the layout.
770
+                            $html .= '<li class="redux-scheme-layout ' . $class_hide . ' redux-cs-qtip ' . $block_hide . '" qtip-title="' . esc_attr( $tip_title ) . '" qtip-content="' . esc_attr( $tip_text ) . '">';
771
+                            $html .= '<div class="redux-scheme-layout-container" data-id="' . $field_id . '-' . $v['id'] . '">';
772
+
773
+                            if ( '' === $v['color'] || 'transparent' === $v['color'] ) {
774
+                                $color = '';
775
+                            } else {
776
+                                $color = 'rgba(' . $v['rgba'] . ')';
777
+                            }
778
+
779
+                            // colour picker dropdown.
780
+                            $html .= '<input
781 781
                                         id="' . $field_id . '-' . esc_attr( $v['id'] ) . '-color"
782 782
                                         class="' . $field_class . ' ' . esc_attr( $v['class'] ) . '"
783 783
                                         type="text"
@@ -793,15 +793,15 @@  discard block
 block discarded – undo
793 793
                                         data-output-transparent="' . esc_attr( $field['output_transparent'] ) . '"
794 794
                                       />';
795 795
 
796
-							$scheme_data = self::get_scheme_data( $scheme_id );
797
-							if ( false === $scheme_data ) {
798
-								return '';
799
-							}
796
+                            $scheme_data = self::get_scheme_data( $scheme_id );
797
+                            if ( false === $scheme_data ) {
798
+                                return '';
799
+                            }
800 800
 
801
-							$picker_data = $scheme_data[ $v['id'] ];
801
+                            $picker_data = $scheme_data[ $v['id'] ];
802 802
 
803
-							// Hidden input for data string.
804
-							$html .= '<input
803
+                            // Hidden input for data string.
804
+                            $html .= '<input
805 805
                                         type="hidden"
806 806
                                         class="redux-hidden-data"
807 807
                                         name="' . esc_attr( $opt_name ) . '[' . esc_attr( $field_id ) . '][' . esc_attr( $v['id'] ) . '][data]"
@@ -809,312 +809,312 @@  discard block
 block discarded – undo
809 809
                                         value="' . rawurlencode( wp_json_encode( $picker_data ) ) . '"
810 810
                                       />';
811 811
 
812
-							// closing html tags.
813
-							$html .= '</div>';
814
-							$html .= '<span class="redux-label redux-layout-label">' . esc_attr( $v['title'] ) . '</span>';
815
-							$html .= '</li>';
816
-						}
817
-					}
818
-					$html .= '</ul>';
819
-
820
-					$html .= '<hr class="redux-color-scheme-blank-hr">';
821
-
822
-					if ( $is_accordion ) {
823
-						$html .= '</div>';
824
-					}
825
-
826
-					$html .= '</div>';
827
-				}
828
-
829
-				// Close list.
830
-				$html .= '</ul>';
831
-			}
832
-
833
-			// html var not empty, return it.
834
-			if ( ! empty( $html ) ) {
835
-				return $html;
836
-			}
837
-
838
-			return '';
839
-		}
840
-
841
-		/**
842
-		 * Get color block class.
843
-		 *
844
-		 * @param array  $field Field array.
845
-		 * @param string $id    Field ID.
846
-		 *
847
-		 * @return string
848
-		 */
849
-		private static function get_color_block_class( array $field, string $id ): string {
850
-			$def = $field['default'];
851
-
852
-			if ( ! empty( $def ) ) {
853
-				foreach ( $def as $arr ) {
854
-					if ( $arr['id'] === $id ) {
855
-						if ( isset( $arr['class'] ) ) {
856
-							return $arr['class'];
857
-						}
858
-					}
859
-				}
860
-			}
861
-
862
-			return '';
863
-		}
864
-
865
-		/**
866
-		 * Get tooltip data.
867
-		 *
868
-		 * @param array  $field Field array.
869
-		 * @param string $id    Field ID.
870
-		 *
871
-		 * @return mixed
872
-		 */
873
-		private static function get_tooltip_data( array $field, string $id ) {
874
-			$def = $field['default'];
875
-
876
-			if ( ! empty( $def ) ) {
877
-				foreach ( $def as $arr ) {
878
-					if ( $arr['id'] === $id ) {
879
-						if ( isset( $arr['tooltip'] ) ) {
880
-							return $arr['tooltip'];
881
-						}
882
-					}
883
-				}
884
-			}
885
-
886
-			return false;
887
-		}
888
-
889
-		/**
890
-		 * Get hidden blocks.
891
-		 *
892
-		 * @param array  $field Field ID.
893
-		 * @param string $id    Field ID.
894
-		 *
895
-		 * @return bool
896
-		 */
897
-		private static function get_block_hidden( array $field, string $id ): bool {
898
-			$def = $field['default'];
899
-
900
-			if ( ! empty( $def ) ) {
901
-				foreach ( $def as $arr ) {
902
-					if ( $arr['id'] === $id ) {
903
-						if ( isset( $arr['hidden'] ) ) {
904
-							return $arr['hidden'];
905
-						}
906
-					}
907
-				}
908
-			}
909
-
910
-			return false;
911
-		}
912
-
913
-		/**
914
-		 * Returns scheme file contents.
915
-		 *
916
-		 * @since       1.0.0
917
-		 * @access      public static
918
-		 *
919
-		 * @return      array Array of scheme data.
920
-		 */
921
-		public static function read_scheme_file() {
922
-			$key  = self::get_scheme_key();
923
-			$data = get_option( $key );
924
-
925
-			if ( empty( $data ) ) {
926
-				$arr_data = false;
927
-			} else {
928
-				$arr_data = $data;
929
-			}
930
-
931
-			return $arr_data;
932
-		}
933
-
934
-		/**
935
-		 * Sets scheme file contents.
936
-		 *
937
-		 * @param       array $arr_data PHP array of data to encode.
938
-		 *
939
-		 * @return      bool Result of write function.
940
-		 * @since       1.0.0
941
-		 * @access      public static
942
-		 */
943
-		public static function write_scheme_file( array $arr_data ): bool {
944
-			$key = self::get_scheme_key();
945
-
946
-			return update_option( $key, $arr_data );
947
-		}
948
-
949
-		/**
950
-		 * Gets individual scheme data from scheme JSON file.
951
-		 *
952
-		 * @param       string $scheme_name Name of scheme.
953
-		 *
954
-		 * @return      mixed PHP array of scheme data.
955
-		 * @since       1.0.0
956
-		 * @access      public static
957
-		 */
958
-		public static function get_scheme_data( string $scheme_name ) {
959
-			$data = self::read_scheme_file();
960
-
961
-			if ( false === $data ) {
962
-				return false;
963
-			}
964
-
965
-			return $data[ $scheme_name ];
966
-		}
967
-
968
-		/**
969
-		 * Sets individual scheme data to scheme JSON file.
970
-		 *
971
-		 * @param string $name  Name of a scheme to save.
972
-		 * @param array  $arr   Scheme data to encode.
973
-		 *
974
-		 * @return      bool Result of file written.
975
-		 * @since       1.0.0
976
-		 * @access      public static
977
-		 */
978
-		public static function set_scheme_data( string $name, array $arr ): bool {
979
-
980
-			// Create blank array.
981
-			$new_scheme = array();
982
-
983
-			// If name is present.
984
-			if ( $name ) {
985
-
986
-				// then add the name at the new array's key.
987
-				$new_scheme['color_scheme_name'] = $name;
988
-
989
-				// Enum through values and assign them to new array.
990
-				foreach ( $arr as $val ) {
991
-					if ( isset( $val['id'] ) ) {
992
-						$new_scheme[ $val['id'] ] = $val;
993
-					}
994
-				}
995
-
996
-				// read the contents of the current scheme file.
997
-				$schemes = self::read_scheme_file();
998
-
999
-				// If returned false (not there) then create a new array.
1000
-				if ( false === $schemes ) {
1001
-					$schemes = array();
1002
-				}
1003
-
1004
-				$scheme_data = $schemes[ $name ] ?? '';
1005
-
1006
-				if ( $scheme_data !== $new_scheme ) {
1007
-
1008
-					// Add new scheme to array that will be saved.
1009
-					$schemes[ $name ] = $new_scheme;
1010
-
1011
-					// Write the data to the JSON file.
1012
-					return self::write_scheme_file( $schemes );
1013
-				}
1014
-			}
1015
-
1016
-			// !success
1017
-			return false;
1018
-		}
1019
-
1020
-		/**
1021
-		 * Enumerate the scheme names from the JSON store file.
1022
-		 *
1023
-		 * @since       1.0.0
1024
-		 * @access      public static
1025
-		 * @return      array Array of stored scheme names.
1026
-		 */
1027
-		public static function get_scheme_names(): array {
1028
-
1029
-			// Read the JSON file, which returns a PHP array.
1030
-			$schemes = self::read_scheme_file();
1031
-
1032
-			// Create a new array.
1033
-			$output = array();
1034
-
1035
-			if ( false !== $schemes ) {
1036
-
1037
-				// If the schemes array IS an array (versus false), then...
1038
-				if ( is_array( $schemes ) ) {
1039
-
1040
-					// Enum them.
1041
-					foreach ( $schemes as $scheme ) {
1042
-
1043
-						// If the color_scheme_name key is set...
1044
-						if ( isset( $scheme['color_scheme_name'] ) ) {
1045
-
1046
-							// Push it onto the array stack.
1047
-							$output[] = $scheme['color_scheme_name'];
1048
-						}
1049
-					}
1050
-				}
1051
-			}
1052
-
1053
-			// Kick the full array out the door.
1054
-			return $output;
1055
-		}
1056
-
1057
-		/**
1058
-		 * Get data array from scheme.
1059
-		 *
1060
-		 * @param string $scheme Scheme name.
1061
-		 *
1062
-		 * @return array
1063
-		 */
1064
-		public static function data_array_from_scheme( string $scheme ): array {
1065
-
1066
-			// Get scheme data from JSON file.
1067
-			$data = self::get_scheme_data( $scheme );
1068
-			if ( false === $data ) {
1069
-				return array();
1070
-			}
1071
-
1072
-			// Don't need to save select arrays to database,
1073
-			// just the id => value.
1074
-			if ( ! empty( $data ) ) {
1075
-				foreach ( $data as $k => $v ) {
1076
-					if ( isset( $v['type'] ) ) {
1077
-						$val = $v['value'];
1078
-
1079
-						unset( $data[ $k ] );
1080
-
1081
-						$data[ $k ] = $val;
1082
-					}
1083
-				}
1084
-			}
1085
-
1086
-			return $data;
1087
-		}
1088
-
1089
-		/**
1090
-		 * Sets current scheme to database.
1091
-		 *
1092
-		 * @param       string $scheme Current scheme name.
1093
-		 *
1094
-		 * @return      void
1095
-		 * @since       1.0.0
1096
-		 * @access      private
1097
-		 */
1098
-		public static function set_database_data( string $scheme = 'Default' ) {
1099
-
1100
-			$data = self::data_array_from_scheme( $scheme );
1101
-
1102
-			// Get opt name, for database.
1103
-			$opt_name = self::$parent->args['opt_name'];
1104
-
1105
-			// Get all options from database.
1106
-			$redux_options = get_option( $opt_name );
1107
-
1108
-			if ( empty( self::$field_id ) ) {
1109
-				self::$field    = self::get_field();
1110
-				self::$field_id = self::$field['id'];
1111
-			}
1112
-
1113
-			// Append ID to variable that holds the current scheme ID data.
1114
-			$redux_options[ self::$field_id ] = $data;
1115
-
1116
-			// Save the modified settings.
1117
-			update_option( $opt_name, $redux_options );
1118
-		}
1119
-	}
812
+                            // closing html tags.
813
+                            $html .= '</div>';
814
+                            $html .= '<span class="redux-label redux-layout-label">' . esc_attr( $v['title'] ) . '</span>';
815
+                            $html .= '</li>';
816
+                        }
817
+                    }
818
+                    $html .= '</ul>';
819
+
820
+                    $html .= '<hr class="redux-color-scheme-blank-hr">';
821
+
822
+                    if ( $is_accordion ) {
823
+                        $html .= '</div>';
824
+                    }
825
+
826
+                    $html .= '</div>';
827
+                }
828
+
829
+                // Close list.
830
+                $html .= '</ul>';
831
+            }
832
+
833
+            // html var not empty, return it.
834
+            if ( ! empty( $html ) ) {
835
+                return $html;
836
+            }
837
+
838
+            return '';
839
+        }
840
+
841
+        /**
842
+         * Get color block class.
843
+         *
844
+         * @param array  $field Field array.
845
+         * @param string $id    Field ID.
846
+         *
847
+         * @return string
848
+         */
849
+        private static function get_color_block_class( array $field, string $id ): string {
850
+            $def = $field['default'];
851
+
852
+            if ( ! empty( $def ) ) {
853
+                foreach ( $def as $arr ) {
854
+                    if ( $arr['id'] === $id ) {
855
+                        if ( isset( $arr['class'] ) ) {
856
+                            return $arr['class'];
857
+                        }
858
+                    }
859
+                }
860
+            }
861
+
862
+            return '';
863
+        }
864
+
865
+        /**
866
+         * Get tooltip data.
867
+         *
868
+         * @param array  $field Field array.
869
+         * @param string $id    Field ID.
870
+         *
871
+         * @return mixed
872
+         */
873
+        private static function get_tooltip_data( array $field, string $id ) {
874
+            $def = $field['default'];
875
+
876
+            if ( ! empty( $def ) ) {
877
+                foreach ( $def as $arr ) {
878
+                    if ( $arr['id'] === $id ) {
879
+                        if ( isset( $arr['tooltip'] ) ) {
880
+                            return $arr['tooltip'];
881
+                        }
882
+                    }
883
+                }
884
+            }
885
+
886
+            return false;
887
+        }
888
+
889
+        /**
890
+         * Get hidden blocks.
891
+         *
892
+         * @param array  $field Field ID.
893
+         * @param string $id    Field ID.
894
+         *
895
+         * @return bool
896
+         */
897
+        private static function get_block_hidden( array $field, string $id ): bool {
898
+            $def = $field['default'];
899
+
900
+            if ( ! empty( $def ) ) {
901
+                foreach ( $def as $arr ) {
902
+                    if ( $arr['id'] === $id ) {
903
+                        if ( isset( $arr['hidden'] ) ) {
904
+                            return $arr['hidden'];
905
+                        }
906
+                    }
907
+                }
908
+            }
909
+
910
+            return false;
911
+        }
912
+
913
+        /**
914
+         * Returns scheme file contents.
915
+         *
916
+         * @since       1.0.0
917
+         * @access      public static
918
+         *
919
+         * @return      array Array of scheme data.
920
+         */
921
+        public static function read_scheme_file() {
922
+            $key  = self::get_scheme_key();
923
+            $data = get_option( $key );
924
+
925
+            if ( empty( $data ) ) {
926
+                $arr_data = false;
927
+            } else {
928
+                $arr_data = $data;
929
+            }
930
+
931
+            return $arr_data;
932
+        }
933
+
934
+        /**
935
+         * Sets scheme file contents.
936
+         *
937
+         * @param       array $arr_data PHP array of data to encode.
938
+         *
939
+         * @return      bool Result of write function.
940
+         * @since       1.0.0
941
+         * @access      public static
942
+         */
943
+        public static function write_scheme_file( array $arr_data ): bool {
944
+            $key = self::get_scheme_key();
945
+
946
+            return update_option( $key, $arr_data );
947
+        }
948
+
949
+        /**
950
+         * Gets individual scheme data from scheme JSON file.
951
+         *
952
+         * @param       string $scheme_name Name of scheme.
953
+         *
954
+         * @return      mixed PHP array of scheme data.
955
+         * @since       1.0.0
956
+         * @access      public static
957
+         */
958
+        public static function get_scheme_data( string $scheme_name ) {
959
+            $data = self::read_scheme_file();
960
+
961
+            if ( false === $data ) {
962
+                return false;
963
+            }
964
+
965
+            return $data[ $scheme_name ];
966
+        }
967
+
968
+        /**
969
+         * Sets individual scheme data to scheme JSON file.
970
+         *
971
+         * @param string $name  Name of a scheme to save.
972
+         * @param array  $arr   Scheme data to encode.
973
+         *
974
+         * @return      bool Result of file written.
975
+         * @since       1.0.0
976
+         * @access      public static
977
+         */
978
+        public static function set_scheme_data( string $name, array $arr ): bool {
979
+
980
+            // Create blank array.
981
+            $new_scheme = array();
982
+
983
+            // If name is present.
984
+            if ( $name ) {
985
+
986
+                // then add the name at the new array's key.
987
+                $new_scheme['color_scheme_name'] = $name;
988
+
989
+                // Enum through values and assign them to new array.
990
+                foreach ( $arr as $val ) {
991
+                    if ( isset( $val['id'] ) ) {
992
+                        $new_scheme[ $val['id'] ] = $val;
993
+                    }
994
+                }
995
+
996
+                // read the contents of the current scheme file.
997
+                $schemes = self::read_scheme_file();
998
+
999
+                // If returned false (not there) then create a new array.
1000
+                if ( false === $schemes ) {
1001
+                    $schemes = array();
1002
+                }
1003
+
1004
+                $scheme_data = $schemes[ $name ] ?? '';
1005
+
1006
+                if ( $scheme_data !== $new_scheme ) {
1007
+
1008
+                    // Add new scheme to array that will be saved.
1009
+                    $schemes[ $name ] = $new_scheme;
1010
+
1011
+                    // Write the data to the JSON file.
1012
+                    return self::write_scheme_file( $schemes );
1013
+                }
1014
+            }
1015
+
1016
+            // !success
1017
+            return false;
1018
+        }
1019
+
1020
+        /**
1021
+         * Enumerate the scheme names from the JSON store file.
1022
+         *
1023
+         * @since       1.0.0
1024
+         * @access      public static
1025
+         * @return      array Array of stored scheme names.
1026
+         */
1027
+        public static function get_scheme_names(): array {
1028
+
1029
+            // Read the JSON file, which returns a PHP array.
1030
+            $schemes = self::read_scheme_file();
1031
+
1032
+            // Create a new array.
1033
+            $output = array();
1034
+
1035
+            if ( false !== $schemes ) {
1036
+
1037
+                // If the schemes array IS an array (versus false), then...
1038
+                if ( is_array( $schemes ) ) {
1039
+
1040
+                    // Enum them.
1041
+                    foreach ( $schemes as $scheme ) {
1042
+
1043
+                        // If the color_scheme_name key is set...
1044
+                        if ( isset( $scheme['color_scheme_name'] ) ) {
1045
+
1046
+                            // Push it onto the array stack.
1047
+                            $output[] = $scheme['color_scheme_name'];
1048
+                        }
1049
+                    }
1050
+                }
1051
+            }
1052
+
1053
+            // Kick the full array out the door.
1054
+            return $output;
1055
+        }
1056
+
1057
+        /**
1058
+         * Get data array from scheme.
1059
+         *
1060
+         * @param string $scheme Scheme name.
1061
+         *
1062
+         * @return array
1063
+         */
1064
+        public static function data_array_from_scheme( string $scheme ): array {
1065
+
1066
+            // Get scheme data from JSON file.
1067
+            $data = self::get_scheme_data( $scheme );
1068
+            if ( false === $data ) {
1069
+                return array();
1070
+            }
1071
+
1072
+            // Don't need to save select arrays to database,
1073
+            // just the id => value.
1074
+            if ( ! empty( $data ) ) {
1075
+                foreach ( $data as $k => $v ) {
1076
+                    if ( isset( $v['type'] ) ) {
1077
+                        $val = $v['value'];
1078
+
1079
+                        unset( $data[ $k ] );
1080
+
1081
+                        $data[ $k ] = $val;
1082
+                    }
1083
+                }
1084
+            }
1085
+
1086
+            return $data;
1087
+        }
1088
+
1089
+        /**
1090
+         * Sets current scheme to database.
1091
+         *
1092
+         * @param       string $scheme Current scheme name.
1093
+         *
1094
+         * @return      void
1095
+         * @since       1.0.0
1096
+         * @access      private
1097
+         */
1098
+        public static function set_database_data( string $scheme = 'Default' ) {
1099
+
1100
+            $data = self::data_array_from_scheme( $scheme );
1101
+
1102
+            // Get opt name, for database.
1103
+            $opt_name = self::$parent->args['opt_name'];
1104
+
1105
+            // Get all options from database.
1106
+            $redux_options = get_option( $opt_name );
1107
+
1108
+            if ( empty( self::$field_id ) ) {
1109
+                self::$field    = self::get_field();
1110
+                self::$field_id = self::$field['id'];
1111
+            }
1112
+
1113
+            // Append ID to variable that holds the current scheme ID data.
1114
+            $redux_options[ self::$field_id ] = $data;
1115
+
1116
+            // Save the modified settings.
1117
+            update_option( $opt_name, $redux_options );
1118
+        }
1119
+    }
1120 1120
 }
Please login to merge, or discard this patch.
redux-core/inc/extensions/taxonomy/redux-taxonomy-helpers.php 1 patch
Indentation   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -10,20 +10,20 @@
 block discarded – undo
10 10
 // Helper function to bypass WordPress hook priorities.
11 11
 if ( ! function_exists( 'create_term_redux_taxonomy' ) ) {
12 12
 
13
-	/**
14
-	 * Create.
15
-	 *
16
-	 * @param int $term_id  Term ID.
17
-	 */
18
-	function create_term_redux_taxonomy( int $term_id ) { // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals -- Existing API already used in themes. Cannot change due to backward compatibility. Contains the plugin name.
19
-		$instances = Redux::all_instances();
13
+    /**
14
+     * Create.
15
+     *
16
+     * @param int $term_id  Term ID.
17
+     */
18
+    function create_term_redux_taxonomy( int $term_id ) { // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals -- Existing API already used in themes. Cannot change due to backward compatibility. Contains the plugin name.
19
+        $instances = Redux::all_instances();
20 20
 
21
-		foreach ( $_POST as $key => $value ) { // phpcs:ignore WordPress.Security.NonceVerification
22
-			if ( is_array( $value ) && isset( $instances[ $key ] ) ) {
23
-				$instances[ $key ]->extensions['taxonomy']->meta_terms_save( $term_id );
24
-			}
25
-		}
26
-	}
21
+        foreach ( $_POST as $key => $value ) { // phpcs:ignore WordPress.Security.NonceVerification
22
+            if ( is_array( $value ) && isset( $instances[ $key ] ) ) {
23
+                $instances[ $key ]->extensions['taxonomy']->meta_terms_save( $term_id );
24
+            }
25
+        }
26
+    }
27 27
 }
28 28
 
29 29
 add_action( 'create_term', 'create_term_redux_taxonomy', 4 );
Please login to merge, or discard this patch.