Completed
Push — master ( e2a4d2...ed335c )
by
unknown
55s
created
redux-core/inc/fields/sortable/class-redux-sortable.php 2 patches
Indentation   +181 added lines, -181 removed lines patch added patch discarded remove patch
@@ -11,200 +11,200 @@
 block discarded – undo
11 11
 
12 12
 if ( ! class_exists( 'Redux_Sortable', false ) ) {
13 13
 
14
-	/**
15
-	 * Class Redux_Sortable
16
-	 */
17
-	class Redux_Sortable extends Redux_Field {
18
-
19
-		/**
20
-		 * Set field defaults.
21
-		 */
22
-		public function set_defaults() {
23
-			$defaults = array(
24
-				'options' => array(),
25
-				'label'   => false,
26
-				'mode'    => 'text',
27
-			);
28
-
29
-			$this->field = wp_parse_args( $this->field, $defaults );
30
-		}
31
-
32
-		/**
33
-		 * Field Render Function.
34
-		 * Takes the vars and outputs the HTML for the field in the settings
35
-		 *
36
-		 * @since Redux_Options 2.0.1
37
-		 */
38
-		public function render() {
39
-			if ( empty( $this->field['mode'] ) ) {
40
-				$this->field['mode'] = 'text';
41
-			}
42
-
43
-			if ( 'checkbox' !== $this->field['mode'] && 'text' !== $this->field['mode'] && 'toggle' !== $this->field['mode'] ) {
44
-				$this->field['mode'] = 'text';
45
-			}
46
-
47
-			if ( 'toggle' === $this->field['mode'] ) {
48
-				$this->field['mode'] = 'checkbox';
49
-			}
50
-
51
-			$class   = ( isset( $this->field['class'] ) ) ? $this->field['class'] : '';
52
-			$options = $this->field['options'];
53
-
54
-			// This is to weed out missing options that might be in the default
55
-			// Why?  Who knows.  Call it a dummy check.
56
-			if ( ! empty( $this->value ) ) {
57
-				foreach ( $this->value as $k => $v ) {
58
-					if ( ! isset( $options[ $k ] ) ) {
59
-						unset( $this->value[ $k ] );
60
-					}
61
-				}
62
-			}
63
-
64
-			$no_sort = false;
65
-			if ( empty( $this->value ) && ! is_array( $this->value ) ) {
66
-				if ( ! empty( $this->field['options'] ) ) {
67
-					$this->value = $this->field['options'];
68
-				} else {
69
-					$this->value = array();
70
-				}
71
-			}
72
-			foreach ( $options as $k => $v ) {
73
-				if ( ! isset( $this->value[ $k ] ) ) {
74
-
75
-					// A save has previously been done.
76
-					if ( is_array( $this->value ) && array_key_exists( $k, $this->value ) ) {
77
-						$this->value[ $k ] = $v;
78
-
79
-						// Missing database entry, meaning no save has yet been done.
80
-					} else {
81
-						$no_sort           = true;
82
-						$this->value[ $k ] = '';
83
-					}
84
-				}
85
-			}
86
-
87
-			// If missing database entries are found, it means no save has been done
88
-			// and therefore no sort should be done.  Set the default array in the same
89
-			// order as the options array.  Why?  The sort order is based on the
90
-			// saved default array.  If entries are missing, the sort is messed up.
91
-			// - kp.
92
-			if ( true === $no_sort ) {
93
-				$dummy_arr = array();
94
-
95
-				foreach ( $options as $k => $v ) {
96
-					$dummy_arr[ $k ] = $this->value[ $k ];
97
-				}
98
-				unset( $this->value );
99
-				$this->value = $dummy_arr;
100
-				unset( $dummy_arr );
101
-			}
102
-
103
-			$use_labels  = false;
104
-			$label_class = ' checkbox';
105
-			if ( 'checkbox' !== $this->field['mode'] ) {
106
-				if ( ( isset( $this->field['label'] ) && true === $this->field['label'] ) ) {
107
-					$use_labels  = true;
108
-					$label_class = ' labeled';
109
-				}
110
-			}
111
-
112
-			echo '<ul id="' . esc_attr( $this->field['id'] ) . '-list" class="redux-sortable ' . esc_attr( $class ) . ' ' . esc_attr( $label_class ) . '">';
113
-
114
-			foreach ( $this->value as $k => $nicename ) {
115
-				$invisible = '';
116
-
117
-				if ( 'checkbox' === $this->field['mode'] ) {
118
-					if ( empty( $this->value[ $k ] ) ) {
119
-						$invisible = ' invisible';
120
-					}
121
-				}
122
-
123
-				echo '<li class="' . esc_attr( $invisible ) . '">';
124
-
125
-				$checked = '';
126
-				$name    = 'name="' . $this->field['name'] . $this->field['name_suffix'] . '[' . esc_attr( $k ) . ']" ';
127
-
128
-				if ( 'checkbox' === $this->field['mode'] ) {
129
-					$value_display = $this->value[ $k ];
130
-
131
-					if ( ! empty( $this->value[ $k ] ) ) {
132
-						$checked = 'checked="checked" ';
133
-					}
134
-
135
-					$class .= ' checkbox_sortable';
136
-					$name   = '';
137
-
138
-					echo '<div class="checkbox-container">';
139
-					echo '<input
14
+    /**
15
+     * Class Redux_Sortable
16
+     */
17
+    class Redux_Sortable extends Redux_Field {
18
+
19
+        /**
20
+         * Set field defaults.
21
+         */
22
+        public function set_defaults() {
23
+            $defaults = array(
24
+                'options' => array(),
25
+                'label'   => false,
26
+                'mode'    => 'text',
27
+            );
28
+
29
+            $this->field = wp_parse_args( $this->field, $defaults );
30
+        }
31
+
32
+        /**
33
+         * Field Render Function.
34
+         * Takes the vars and outputs the HTML for the field in the settings
35
+         *
36
+         * @since Redux_Options 2.0.1
37
+         */
38
+        public function render() {
39
+            if ( empty( $this->field['mode'] ) ) {
40
+                $this->field['mode'] = 'text';
41
+            }
42
+
43
+            if ( 'checkbox' !== $this->field['mode'] && 'text' !== $this->field['mode'] && 'toggle' !== $this->field['mode'] ) {
44
+                $this->field['mode'] = 'text';
45
+            }
46
+
47
+            if ( 'toggle' === $this->field['mode'] ) {
48
+                $this->field['mode'] = 'checkbox';
49
+            }
50
+
51
+            $class   = ( isset( $this->field['class'] ) ) ? $this->field['class'] : '';
52
+            $options = $this->field['options'];
53
+
54
+            // This is to weed out missing options that might be in the default
55
+            // Why?  Who knows.  Call it a dummy check.
56
+            if ( ! empty( $this->value ) ) {
57
+                foreach ( $this->value as $k => $v ) {
58
+                    if ( ! isset( $options[ $k ] ) ) {
59
+                        unset( $this->value[ $k ] );
60
+                    }
61
+                }
62
+            }
63
+
64
+            $no_sort = false;
65
+            if ( empty( $this->value ) && ! is_array( $this->value ) ) {
66
+                if ( ! empty( $this->field['options'] ) ) {
67
+                    $this->value = $this->field['options'];
68
+                } else {
69
+                    $this->value = array();
70
+                }
71
+            }
72
+            foreach ( $options as $k => $v ) {
73
+                if ( ! isset( $this->value[ $k ] ) ) {
74
+
75
+                    // A save has previously been done.
76
+                    if ( is_array( $this->value ) && array_key_exists( $k, $this->value ) ) {
77
+                        $this->value[ $k ] = $v;
78
+
79
+                        // Missing database entry, meaning no save has yet been done.
80
+                    } else {
81
+                        $no_sort           = true;
82
+                        $this->value[ $k ] = '';
83
+                    }
84
+                }
85
+            }
86
+
87
+            // If missing database entries are found, it means no save has been done
88
+            // and therefore no sort should be done.  Set the default array in the same
89
+            // order as the options array.  Why?  The sort order is based on the
90
+            // saved default array.  If entries are missing, the sort is messed up.
91
+            // - kp.
92
+            if ( true === $no_sort ) {
93
+                $dummy_arr = array();
94
+
95
+                foreach ( $options as $k => $v ) {
96
+                    $dummy_arr[ $k ] = $this->value[ $k ];
97
+                }
98
+                unset( $this->value );
99
+                $this->value = $dummy_arr;
100
+                unset( $dummy_arr );
101
+            }
102
+
103
+            $use_labels  = false;
104
+            $label_class = ' checkbox';
105
+            if ( 'checkbox' !== $this->field['mode'] ) {
106
+                if ( ( isset( $this->field['label'] ) && true === $this->field['label'] ) ) {
107
+                    $use_labels  = true;
108
+                    $label_class = ' labeled';
109
+                }
110
+            }
111
+
112
+            echo '<ul id="' . esc_attr( $this->field['id'] ) . '-list" class="redux-sortable ' . esc_attr( $class ) . ' ' . esc_attr( $label_class ) . '">';
113
+
114
+            foreach ( $this->value as $k => $nicename ) {
115
+                $invisible = '';
116
+
117
+                if ( 'checkbox' === $this->field['mode'] ) {
118
+                    if ( empty( $this->value[ $k ] ) ) {
119
+                        $invisible = ' invisible';
120
+                    }
121
+                }
122
+
123
+                echo '<li class="' . esc_attr( $invisible ) . '">';
124
+
125
+                $checked = '';
126
+                $name    = 'name="' . $this->field['name'] . $this->field['name_suffix'] . '[' . esc_attr( $k ) . ']" ';
127
+
128
+                if ( 'checkbox' === $this->field['mode'] ) {
129
+                    $value_display = $this->value[ $k ];
130
+
131
+                    if ( ! empty( $this->value[ $k ] ) ) {
132
+                        $checked = 'checked="checked" ';
133
+                    }
134
+
135
+                    $class .= ' checkbox_sortable';
136
+                    $name   = '';
137
+
138
+                    echo '<div class="checkbox-container">';
139
+                    echo '<input
140 140
 							type="hidden"
141 141
 							name="' . esc_attr( $this->field['name'] . $this->field['name_suffix'] ) . '[' . esc_attr( $k ) . ']"
142 142
 							id="' . esc_attr( $this->field['id'] . '-' . $k ) . '-hidden"
143 143
 							value="' . esc_attr( $value_display ) . '" />';
144 144
 
145
-				} else {
146
-					$value_display = $this->value[ $k ] ?? '';
147
-					$nicename      = $this->field['options'][ $k ];
148
-				}
145
+                } else {
146
+                    $value_display = $this->value[ $k ] ?? '';
147
+                    $nicename      = $this->field['options'][ $k ];
148
+                }
149 149
 
150
-				if ( 'checkbox' !== $this->field['mode'] ) {
151
-					if ( $use_labels ) {
152
-						echo '<label class="bugger" for="' . esc_attr( $this->field['id'] ) . '[' . esc_attr( $k ) . ']"><strong>' . esc_html( $k ) . '</strong></label>';
153
-						echo '<br />';
154
-					}
150
+                if ( 'checkbox' !== $this->field['mode'] ) {
151
+                    if ( $use_labels ) {
152
+                        echo '<label class="bugger" for="' . esc_attr( $this->field['id'] ) . '[' . esc_attr( $k ) . ']"><strong>' . esc_html( $k ) . '</strong></label>';
153
+                        echo '<br />';
154
+                    }
155 155
 
156
-					echo '<input
156
+                    echo '<input
157 157
 						rel="' . esc_attr( $this->field['id'] . '-' . $k ) . '-hidden"
158 158
 						class="' . esc_attr( $class ) . '" ' . esc_html( $checked ) . '
159 159
 						type="' . esc_attr( $this->field['mode'] ) . '"
160 160
 						' . $name . // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
161
-						'id="' . esc_attr( $this->field['id'] . '[' . $k ) . ']"
161
+                        'id="' . esc_attr( $this->field['id'] . '[' . $k ) . ']"
162 162
 						value="' . esc_attr( $value_display ) . '"
163 163
 						placeholder="' . esc_attr( $nicename ) . '" />';
164
-				}
165
-
166
-				echo '<span class="compact drag">';
167
-				echo '<i class="dashicons dashicons-menu icon-large"></i>';
168
-				echo '</span>';
169
-
170
-				if ( 'checkbox' === $this->field['mode'] ) {
171
-					echo '<i class="dashicons dashicons-visibility visibility"></i>';
172
-
173
-					echo '<strong>' . esc_html( $options[ $k ] ) . '</strong>';
174
-				}
175
-
176
-				if ( 'checkbox' === $this->field['mode'] ) {
177
-					echo '</div>';
178
-				}
179
-
180
-				echo '</li>';
181
-			}
182
-
183
-			echo '</ul>';
184
-		}
185
-
186
-		/**
187
-		 * Enqueue scripts and styles.
188
-		 */
189
-		public function enqueue() {
190
-			if ( $this->parent->args['dev_mode'] ) {
191
-				wp_enqueue_style(
192
-					'redux-field-sortable',
193
-					Redux_Core::$url . 'inc/fields/sortable/redux-sortable.css',
194
-					array(),
195
-					$this->timestamp
196
-				);
197
-			}
198
-
199
-			wp_enqueue_script(
200
-				'redux-field-sortable',
201
-				Redux_Core::$url . 'inc/fields/sortable/redux-sortable' . Redux_Functions::is_min() . '.js',
202
-				array( 'jquery', 'redux-js', 'jquery-ui-sortable' ),
203
-				$this->timestamp,
204
-				true
205
-			);
206
-		}
207
-	}
164
+                }
165
+
166
+                echo '<span class="compact drag">';
167
+                echo '<i class="dashicons dashicons-menu icon-large"></i>';
168
+                echo '</span>';
169
+
170
+                if ( 'checkbox' === $this->field['mode'] ) {
171
+                    echo '<i class="dashicons dashicons-visibility visibility"></i>';
172
+
173
+                    echo '<strong>' . esc_html( $options[ $k ] ) . '</strong>';
174
+                }
175
+
176
+                if ( 'checkbox' === $this->field['mode'] ) {
177
+                    echo '</div>';
178
+                }
179
+
180
+                echo '</li>';
181
+            }
182
+
183
+            echo '</ul>';
184
+        }
185
+
186
+        /**
187
+         * Enqueue scripts and styles.
188
+         */
189
+        public function enqueue() {
190
+            if ( $this->parent->args['dev_mode'] ) {
191
+                wp_enqueue_style(
192
+                    'redux-field-sortable',
193
+                    Redux_Core::$url . 'inc/fields/sortable/redux-sortable.css',
194
+                    array(),
195
+                    $this->timestamp
196
+                );
197
+            }
198
+
199
+            wp_enqueue_script(
200
+                'redux-field-sortable',
201
+                Redux_Core::$url . 'inc/fields/sortable/redux-sortable' . Redux_Functions::is_min() . '.js',
202
+                array( 'jquery', 'redux-js', 'jquery-ui-sortable' ),
203
+                $this->timestamp,
204
+                true
205
+            );
206
+        }
207
+    }
208 208
 }
209 209
 
210 210
 class_alias( 'Redux_Sortable', 'ReduxFramework_Sortable' );
Please login to merge, or discard this patch.
Spacing   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -55,8 +55,8 @@  discard block
 block discarded – undo
55 55
 			// Why?  Who knows.  Call it a dummy check.
56 56
 			if ( ! empty( $this->value ) ) {
57 57
 				foreach ( $this->value as $k => $v ) {
58
-					if ( ! isset( $options[ $k ] ) ) {
59
-						unset( $this->value[ $k ] );
58
+					if ( ! isset( $options[$k] ) ) {
59
+						unset( $this->value[$k] );
60 60
 					}
61 61
 				}
62 62
 			}
@@ -70,16 +70,16 @@  discard block
 block discarded – undo
70 70
 				}
71 71
 			}
72 72
 			foreach ( $options as $k => $v ) {
73
-				if ( ! isset( $this->value[ $k ] ) ) {
73
+				if ( ! isset( $this->value[$k] ) ) {
74 74
 
75 75
 					// A save has previously been done.
76 76
 					if ( is_array( $this->value ) && array_key_exists( $k, $this->value ) ) {
77
-						$this->value[ $k ] = $v;
77
+						$this->value[$k] = $v;
78 78
 
79 79
 						// Missing database entry, meaning no save has yet been done.
80 80
 					} else {
81 81
 						$no_sort           = true;
82
-						$this->value[ $k ] = '';
82
+						$this->value[$k] = '';
83 83
 					}
84 84
 				}
85 85
 			}
@@ -93,7 +93,7 @@  discard block
 block discarded – undo
93 93
 				$dummy_arr = array();
94 94
 
95 95
 				foreach ( $options as $k => $v ) {
96
-					$dummy_arr[ $k ] = $this->value[ $k ];
96
+					$dummy_arr[$k] = $this->value[$k];
97 97
 				}
98 98
 				unset( $this->value );
99 99
 				$this->value = $dummy_arr;
@@ -115,7 +115,7 @@  discard block
 block discarded – undo
115 115
 				$invisible = '';
116 116
 
117 117
 				if ( 'checkbox' === $this->field['mode'] ) {
118
-					if ( empty( $this->value[ $k ] ) ) {
118
+					if ( empty( $this->value[$k] ) ) {
119 119
 						$invisible = ' invisible';
120 120
 					}
121 121
 				}
@@ -126,9 +126,9 @@  discard block
 block discarded – undo
126 126
 				$name    = 'name="' . $this->field['name'] . $this->field['name_suffix'] . '[' . esc_attr( $k ) . ']" ';
127 127
 
128 128
 				if ( 'checkbox' === $this->field['mode'] ) {
129
-					$value_display = $this->value[ $k ];
129
+					$value_display = $this->value[$k];
130 130
 
131
-					if ( ! empty( $this->value[ $k ] ) ) {
131
+					if ( ! empty( $this->value[$k] ) ) {
132 132
 						$checked = 'checked="checked" ';
133 133
 					}
134 134
 
@@ -143,8 +143,8 @@  discard block
 block discarded – undo
143 143
 							value="' . esc_attr( $value_display ) . '" />';
144 144
 
145 145
 				} else {
146
-					$value_display = $this->value[ $k ] ?? '';
147
-					$nicename      = $this->field['options'][ $k ];
146
+					$value_display = $this->value[$k] ?? '';
147
+					$nicename      = $this->field['options'][$k];
148 148
 				}
149 149
 
150 150
 				if ( 'checkbox' !== $this->field['mode'] ) {
@@ -170,7 +170,7 @@  discard block
 block discarded – undo
170 170
 				if ( 'checkbox' === $this->field['mode'] ) {
171 171
 					echo '<i class="dashicons dashicons-visibility visibility"></i>';
172 172
 
173
-					echo '<strong>' . esc_html( $options[ $k ] ) . '</strong>';
173
+					echo '<strong>' . esc_html( $options[$k] ) . '</strong>';
174 174
 				}
175 175
 
176 176
 				if ( 'checkbox' === $this->field['mode'] ) {
Please login to merge, or discard this patch.
redux-core/inc/classes/class-redux-installer-muter.php 1 patch
Indentation   +19 added lines, -19 removed lines patch added patch discarded remove patch
@@ -4,24 +4,24 @@
 block discarded – undo
4 4
 
5 5
 if ( ! class_exists( 'Redux_Installer_Muter', false ) ) {
6 6
 
7
-	/**
8
-	 * Redux_Installer_Muter.
9
-	 *
10
-	 * @since 4.0.0
11
-	 */
12
-	class Redux_Installer_Muter extends WP_Upgrader_Skin {
7
+    /**
8
+     * Redux_Installer_Muter.
9
+     *
10
+     * @since 4.0.0
11
+     */
12
+    class Redux_Installer_Muter extends WP_Upgrader_Skin {
13 13
 
14
-		/**
15
-		 * Suppress feedback.
16
-		 *
17
-		 * @param string|null $feedback  A string.
18
-		 * @param array|null  ...$args Passed args.
19
-		 *
20
-		 * @return void
21
-		 * @since 4.0.0
22
-		 */
23
-		public function feedback( $feedback, ...$args ) {
24
-			/* no output */
25
-		}
26
-	}
14
+        /**
15
+         * Suppress feedback.
16
+         *
17
+         * @param string|null $feedback  A string.
18
+         * @param array|null  ...$args Passed args.
19
+         *
20
+         * @return void
21
+         * @since 4.0.0
22
+         */
23
+        public function feedback( $feedback, ...$args ) {
24
+            /* no output */
25
+        }
26
+    }
27 27
 }
Please login to merge, or discard this patch.
redux-core/inc/classes/class-redux-i18n.php 1 patch
Indentation   +46 added lines, -46 removed lines patch added patch discarded remove patch
@@ -10,50 +10,50 @@
 block discarded – undo
10 10
 
11 11
 if ( ! class_exists( 'Redux_I18n', false ) ) {
12 12
 
13
-	/**
14
-	 * Class Redux_I18n
15
-	 */
16
-	class Redux_I18n extends Redux_Class {
17
-
18
-		/**
19
-		 * Redux_I18n constructor.
20
-		 *
21
-		 * @param object $redux ReduxFramework pointer.
22
-		 */
23
-		public function __construct( $redux ) {
24
-			parent::__construct( $redux );
25
-
26
-			add_action( 'init', array( $this, 'load' ) );
27
-		}
28
-
29
-		/**
30
-		 * Load translations.
31
-		 */
32
-		public function load() {
33
-			$domain = 'redux-framework';
34
-
35
-			unload_textdomain( $domain );
36
-
37
-			$core = $this->core();
38
-
39
-			/**
40
-			 * Locale for text domain
41
-			 * filter 'redux/textdomain/basepath/{opt_name}'
42
-			 */
43
-			// phpcs:ignore WordPress.NamingConventions.ValidHookName
44
-			$locale = apply_filters( 'redux/locale', get_locale(), 'redux-framework' );
45
-			$mofile = $domain . '-' . $locale . '.mo';
46
-
47
-			// phpcs:ignore WordPress.NamingConventions.ValidHookName
48
-			$basepath = apply_filters( "redux/textdomain/basepath/{$core->args['opt_name']}", Redux_Core::$dir );
49
-
50
-			$loaded = load_textdomain( $domain, $basepath . 'languages/' . $mofile );
51
-
52
-			if ( ! $loaded ) {
53
-				$mofile = WP_LANG_DIR . '/plugins/' . $mofile;
54
-
55
-				load_textdomain( $domain, $mofile );
56
-			}
57
-		}
58
-	}
13
+    /**
14
+     * Class Redux_I18n
15
+     */
16
+    class Redux_I18n extends Redux_Class {
17
+
18
+        /**
19
+         * Redux_I18n constructor.
20
+         *
21
+         * @param object $redux ReduxFramework pointer.
22
+         */
23
+        public function __construct( $redux ) {
24
+            parent::__construct( $redux );
25
+
26
+            add_action( 'init', array( $this, 'load' ) );
27
+        }
28
+
29
+        /**
30
+         * Load translations.
31
+         */
32
+        public function load() {
33
+            $domain = 'redux-framework';
34
+
35
+            unload_textdomain( $domain );
36
+
37
+            $core = $this->core();
38
+
39
+            /**
40
+             * Locale for text domain
41
+             * filter 'redux/textdomain/basepath/{opt_name}'
42
+             */
43
+            // phpcs:ignore WordPress.NamingConventions.ValidHookName
44
+            $locale = apply_filters( 'redux/locale', get_locale(), 'redux-framework' );
45
+            $mofile = $domain . '-' . $locale . '.mo';
46
+
47
+            // phpcs:ignore WordPress.NamingConventions.ValidHookName
48
+            $basepath = apply_filters( "redux/textdomain/basepath/{$core->args['opt_name']}", Redux_Core::$dir );
49
+
50
+            $loaded = load_textdomain( $domain, $basepath . 'languages/' . $mofile );
51
+
52
+            if ( ! $loaded ) {
53
+                $mofile = WP_LANG_DIR . '/plugins/' . $mofile;
54
+
55
+                load_textdomain( $domain, $mofile );
56
+            }
57
+        }
58
+    }
59 59
 }
Please login to merge, or discard this patch.
redux-core/inc/classes/class-redux-ajax-typography.php 1 patch
Indentation   +42 added lines, -42 removed lines patch added patch discarded remove patch
@@ -11,46 +11,46 @@
 block discarded – undo
11 11
 
12 12
 if ( ! class_exists( 'Redux_AJAX_Typography', false ) ) {
13 13
 
14
-	/**
15
-	 * Class Redux_AJAX_Typography
16
-	 */
17
-	class Redux_AJAX_Typography extends Redux_Class {
18
-
19
-		/**
20
-		 * Redux_AJAX_Typography constructor.
21
-		 *
22
-		 * @param object $redux ReduxFramework object.
23
-		 */
24
-		public function __construct( $redux ) {
25
-			parent::__construct( $redux );
26
-			add_action( 'wp_ajax_redux_update_google_fonts', array( $this, 'google_fonts_update' ) );
27
-		}
28
-
29
-		/**
30
-		 * Google font AJAX callback
31
-		 *
32
-		 * @return void
33
-		 */
34
-		public function google_fonts_update() {
35
-			$field_class = 'Redux_typography';
36
-
37
-			if ( ! class_exists( $field_class ) ) {
38
-				$dir = str_replace( '/classes', '', Redux_Functions_Ex::wp_normalize_path( __DIR__ ) );
39
-
40
-				// phpcs:ignore WordPress.NamingConventions.ValidHookName
41
-				$class_file = apply_filters( 'redux-typeclass-load', $dir . '/fields/typography/class-redux-typography.php', $field_class );
42
-				if ( $class_file ) {
43
-					require_once $class_file;
44
-				}
45
-			}
46
-
47
-			if ( class_exists( $field_class ) && method_exists( $field_class, 'google_fonts_update_ajax' ) ) {
48
-				$f = new $field_class( array(), '', $this->parent );
49
-
50
-				$f->google_fonts_update_ajax();
51
-			}
52
-
53
-			die();
54
-		}
55
-	}
14
+    /**
15
+     * Class Redux_AJAX_Typography
16
+     */
17
+    class Redux_AJAX_Typography extends Redux_Class {
18
+
19
+        /**
20
+         * Redux_AJAX_Typography constructor.
21
+         *
22
+         * @param object $redux ReduxFramework object.
23
+         */
24
+        public function __construct( $redux ) {
25
+            parent::__construct( $redux );
26
+            add_action( 'wp_ajax_redux_update_google_fonts', array( $this, 'google_fonts_update' ) );
27
+        }
28
+
29
+        /**
30
+         * Google font AJAX callback
31
+         *
32
+         * @return void
33
+         */
34
+        public function google_fonts_update() {
35
+            $field_class = 'Redux_typography';
36
+
37
+            if ( ! class_exists( $field_class ) ) {
38
+                $dir = str_replace( '/classes', '', Redux_Functions_Ex::wp_normalize_path( __DIR__ ) );
39
+
40
+                // phpcs:ignore WordPress.NamingConventions.ValidHookName
41
+                $class_file = apply_filters( 'redux-typeclass-load', $dir . '/fields/typography/class-redux-typography.php', $field_class );
42
+                if ( $class_file ) {
43
+                    require_once $class_file;
44
+                }
45
+            }
46
+
47
+            if ( class_exists( $field_class ) && method_exists( $field_class, 'google_fonts_update_ajax' ) ) {
48
+                $f = new $field_class( array(), '', $this->parent );
49
+
50
+                $f->google_fonts_update_ajax();
51
+            }
52
+
53
+            die();
54
+        }
55
+    }
56 56
 }
Please login to merge, or discard this patch.
redux-core/inc/classes/class-redux-extension-abstract.php 2 patches
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -168,8 +168,8 @@
 block discarded – undo
168 168
 		// phpcs:ignore WordPress.NamingConventions.ValidHookName
169 169
 		add_filter(
170 170
 			'redux/fields',
171
-			function ( $classes ) use ( $field_name, $class ) {
172
-				$classes[ $field_name ] = $class;
171
+			function( $classes ) use ( $field_name, $class ) {
172
+				$classes[$field_name] = $class;
173 173
 
174 174
 				return $classes;
175 175
 			}
Please login to merge, or discard this patch.
Indentation   +222 added lines, -222 removed lines patch added patch discarded remove patch
@@ -17,229 +17,229 @@
 block discarded – undo
17 17
  * @see the samples directory to find a usage example
18 18
  */
19 19
 abstract class Redux_Extension_Abstract {
20
-	/**
21
-	 * The version of the extension (This is a default value you may want to override it)
22
-	 *
23
-	 * @var string
24
-	 */
25
-	public static $version = '1.0.0';
26
-
27
-	/**
28
-	 * The extension URL.
29
-	 *
30
-	 * @var string
31
-	 */
32
-	protected string $extension_url;
33
-
34
-	/**
35
-	 * The extension dir.
36
-	 *
37
-	 * @var string
38
-	 */
39
-	protected string $extension_dir;
40
-
41
-	/**
42
-	 * The instance of the extension
43
-	 *
44
-	 * @var null|object
45
-	 */
46
-	protected static ?object $instance;
47
-
48
-	/**
49
-	 * The extension's file
50
-	 *
51
-	 * @var string
52
-	 */
53
-	protected $file;
54
-
55
-	/**
56
-	 * The redux framework instance that spawned the extension.
57
-	 *
58
-	 * @var ReduxFramework|null
59
-	 */
60
-	public ?ReduxFramework $parent;
61
-
62
-	/**
63
-	 * The ReflectionClass of the extension
64
-	 *
65
-	 * @var ReflectionClass
66
-	 */
67
-	protected ReflectionClass $reflection_class;
68
-
69
-	/**
70
-	 * Redux_Extension_Abstract constructor.
71
-	 *
72
-	 * @param ReduxFramework $redux ReduxFramework pointer.
73
-	 * @param string         $file  Extension file.
74
-	 */
75
-	public function __construct( ReduxFramework $redux, string $file = '' ) {
76
-		$this->parent = $redux;
77
-
78
-		// If the file is not given, make sure we have one.
79
-		if ( empty( $file ) ) {
80
-			$file = $this->get_reflection()->getFileName();
81
-		}
82
-
83
-		$this->file = $file;
84
-
85
-		$this->extension_dir = trailingslashit( str_replace( '\\', '/', dirname( $file ) ) );
86
-
87
-		$plugin_info = Redux_Functions_Ex::is_inside_plugin( $this->file );
88
-
89
-		if ( false !== $plugin_info ) {
90
-			$this->extension_url = trailingslashit( dirname( $plugin_info['url'] ) );
91
-		} else {
92
-			$theme_info = Redux_Functions_Ex::is_inside_theme( $this->file );
93
-			if ( false !== $theme_info ) {
94
-				$this->extension_url = trailingslashit( dirname( $theme_info['url'] ) );
95
-			}
96
-		}
97
-
98
-		static::$instance = $this;
99
-	}
100
-
101
-	/**
102
-	 * Get the reflection class of the extension.
103
-	 *
104
-	 * @return ReflectionClass
105
-	 */
106
-	protected function get_reflection(): ReflectionClass {
107
-		if ( ! isset( $this->reflection_class ) ) {
108
-			$this->reflection_class = new ReflectionClass( $this );
109
-		}
110
-
111
-		return $this->reflection_class;
112
-	}
113
-
114
-	/**
115
-	 * Return extension version.
116
-	 *
117
-	 * @return string
118
-	 */
119
-	public static function get_version(): string {
120
-		return static::$version;
121
-	}
122
-
123
-	/**
124
-	 * Returns extension instance.
125
-	 *
126
-	 * @return object
127
-	 */
128
-	public static function get_instance(): object {
129
-		return static::$instance;
130
-	}
131
-
132
-	/**
133
-	 * Return extension dir.
134
-	 *
135
-	 * @return string
136
-	 */
137
-	public function get_dir(): string {
138
-		return $this->extension_dir;
139
-	}
140
-
141
-	/**
142
-	 * Returns extension URL
143
-	 *
144
-	 * @return string
145
-	 */
146
-	public function get_url(): string {
147
-		return $this->extension_url;
148
-	}
149
-
150
-	/**
151
-	 * Adds the local field. (The use of add_field is recommended).
152
-	 *
153
-	 * @param string $field_name Name of field.
154
-	 */
155
-	protected function add_overload_field_filter( string $field_name ) {
156
-		// phpcs:ignore WordPress.NamingConventions.ValidHookName
157
-		add_filter( 'redux/' . $this->parent->args['opt_name'] . '/field/class/' . $field_name, array( &$this, 'overload_field_path' ), 10, 2 );
158
-	}
159
-
160
-	/**
161
-	 * Adds the local field to the extension and register it in the builder.
162
-	 *
163
-	 * @param string $field_name Name of field.
164
-	 */
165
-	protected function add_field( string $field_name ) {
166
-		$class = $this->get_reflection()->getName();
167
-
168
-		// phpcs:ignore WordPress.NamingConventions.ValidHookName
169
-		add_filter(
170
-			'redux/fields',
171
-			function ( $classes ) use ( $field_name, $class ) {
172
-				$classes[ $field_name ] = $class;
173
-
174
-				return $classes;
175
-			}
176
-		);
177
-
178
-		$this->add_overload_field_filter( $field_name );
179
-	}
180
-
181
-	/**
182
-	 * Overload a field path.
183
-	 *
184
-	 * @param string $file  Extension file.
185
-	 * @param array  $field Field array.
186
-	 *
187
-	 * @return string
188
-	 */
189
-	public function overload_field_path( string $file, array $field ): string {
190
-		$filename_fix = str_replace( '_', '-', $field['type'] );
191
-
192
-		$files = array(
193
-			trailingslashit( dirname( $this->file ) ) . $field['type'] . DIRECTORY_SEPARATOR . 'field_' . $field['type'] . '.php',
194
-			trailingslashit( dirname( $this->file ) ) . $field['type'] . DIRECTORY_SEPARATOR . 'class-redux-' . $filename_fix . '.php',
195
-		);
196
-
197
-		return Redux_Functions::file_exists_ex( $files );
198
-	}
199
-
200
-	/**
201
-	 * Sets the minimum version of Redux to use.  Displays a notice if requirements are not met.
202
-	 *
203
-	 * @param string $min_version       Minimum version to evaluate.
204
-	 * @param string $extension_version Extension version number.
205
-	 * @param string $friendly_name     Friend extension name for notice display.
206
-	 *
207
-	 * @return bool
208
-	 */
209
-	public function is_minimum_version( string $min_version = '', string $extension_version = '', string $friendly_name = '' ): bool {
210
-		$redux_ver = Redux_Core::$version;
211
-
212
-		if ( '' !== $min_version ) {
213
-			if ( version_compare( $redux_ver, $min_version ) < 0 ) {
214
-				// translators: %1$s Extension friendly name. %2$s: minimum Redux version.
215
-				$msg = '<strong>' . sprintf( esc_html__( 'The %1$s extension requires Redux Framework version %2$s or higher.', 'redux-framework' ), $friendly_name, $min_version ) . '</strong>&nbsp;&nbsp;' . esc_html__( 'You are currently running Redux Framework version ', 'redux-framework' ) . ' ' . $redux_ver . '.<br/><br/>' . esc_html__( 'This field will not render in your option panel, and features of this extension will not be available until the latest version of Redux Framework has been installed.', 'redux-framework' );
216
-
217
-				$data = array(
218
-					'parent'  => $this->parent,
219
-					'type'    => 'error',
220
-					'msg'     => $msg,
221
-					'id'      => $this->extension_name . '_notice_' . $extension_version,
222
-					'dismiss' => false,
223
-				);
224
-
225
-				if ( method_exists( 'Redux_Admin_Notices', 'set_notice' ) ) {
226
-					Redux_Admin_Notices::set_notice( $data );
227
-				} else {
228
-					echo '<div class="error">';
229
-					echo '<p>';
230
-					echo $msg; // phpcs:ignore WordPress.Security.EscapeOutput
231
-					echo '</p>';
232
-					echo '</div>';
233
-				}
234
-
235
-				return false;
236
-			}
237
-		}
238
-
239
-		return true;
240
-	}
20
+    /**
21
+     * The version of the extension (This is a default value you may want to override it)
22
+     *
23
+     * @var string
24
+     */
25
+    public static $version = '1.0.0';
26
+
27
+    /**
28
+     * The extension URL.
29
+     *
30
+     * @var string
31
+     */
32
+    protected string $extension_url;
33
+
34
+    /**
35
+     * The extension dir.
36
+     *
37
+     * @var string
38
+     */
39
+    protected string $extension_dir;
40
+
41
+    /**
42
+     * The instance of the extension
43
+     *
44
+     * @var null|object
45
+     */
46
+    protected static ?object $instance;
47
+
48
+    /**
49
+     * The extension's file
50
+     *
51
+     * @var string
52
+     */
53
+    protected $file;
54
+
55
+    /**
56
+     * The redux framework instance that spawned the extension.
57
+     *
58
+     * @var ReduxFramework|null
59
+     */
60
+    public ?ReduxFramework $parent;
61
+
62
+    /**
63
+     * The ReflectionClass of the extension
64
+     *
65
+     * @var ReflectionClass
66
+     */
67
+    protected ReflectionClass $reflection_class;
68
+
69
+    /**
70
+     * Redux_Extension_Abstract constructor.
71
+     *
72
+     * @param ReduxFramework $redux ReduxFramework pointer.
73
+     * @param string         $file  Extension file.
74
+     */
75
+    public function __construct( ReduxFramework $redux, string $file = '' ) {
76
+        $this->parent = $redux;
77
+
78
+        // If the file is not given, make sure we have one.
79
+        if ( empty( $file ) ) {
80
+            $file = $this->get_reflection()->getFileName();
81
+        }
82
+
83
+        $this->file = $file;
84
+
85
+        $this->extension_dir = trailingslashit( str_replace( '\\', '/', dirname( $file ) ) );
86
+
87
+        $plugin_info = Redux_Functions_Ex::is_inside_plugin( $this->file );
88
+
89
+        if ( false !== $plugin_info ) {
90
+            $this->extension_url = trailingslashit( dirname( $plugin_info['url'] ) );
91
+        } else {
92
+            $theme_info = Redux_Functions_Ex::is_inside_theme( $this->file );
93
+            if ( false !== $theme_info ) {
94
+                $this->extension_url = trailingslashit( dirname( $theme_info['url'] ) );
95
+            }
96
+        }
97
+
98
+        static::$instance = $this;
99
+    }
100
+
101
+    /**
102
+     * Get the reflection class of the extension.
103
+     *
104
+     * @return ReflectionClass
105
+     */
106
+    protected function get_reflection(): ReflectionClass {
107
+        if ( ! isset( $this->reflection_class ) ) {
108
+            $this->reflection_class = new ReflectionClass( $this );
109
+        }
110
+
111
+        return $this->reflection_class;
112
+    }
113
+
114
+    /**
115
+     * Return extension version.
116
+     *
117
+     * @return string
118
+     */
119
+    public static function get_version(): string {
120
+        return static::$version;
121
+    }
122
+
123
+    /**
124
+     * Returns extension instance.
125
+     *
126
+     * @return object
127
+     */
128
+    public static function get_instance(): object {
129
+        return static::$instance;
130
+    }
131
+
132
+    /**
133
+     * Return extension dir.
134
+     *
135
+     * @return string
136
+     */
137
+    public function get_dir(): string {
138
+        return $this->extension_dir;
139
+    }
140
+
141
+    /**
142
+     * Returns extension URL
143
+     *
144
+     * @return string
145
+     */
146
+    public function get_url(): string {
147
+        return $this->extension_url;
148
+    }
149
+
150
+    /**
151
+     * Adds the local field. (The use of add_field is recommended).
152
+     *
153
+     * @param string $field_name Name of field.
154
+     */
155
+    protected function add_overload_field_filter( string $field_name ) {
156
+        // phpcs:ignore WordPress.NamingConventions.ValidHookName
157
+        add_filter( 'redux/' . $this->parent->args['opt_name'] . '/field/class/' . $field_name, array( &$this, 'overload_field_path' ), 10, 2 );
158
+    }
159
+
160
+    /**
161
+     * Adds the local field to the extension and register it in the builder.
162
+     *
163
+     * @param string $field_name Name of field.
164
+     */
165
+    protected function add_field( string $field_name ) {
166
+        $class = $this->get_reflection()->getName();
167
+
168
+        // phpcs:ignore WordPress.NamingConventions.ValidHookName
169
+        add_filter(
170
+            'redux/fields',
171
+            function ( $classes ) use ( $field_name, $class ) {
172
+                $classes[ $field_name ] = $class;
173
+
174
+                return $classes;
175
+            }
176
+        );
177
+
178
+        $this->add_overload_field_filter( $field_name );
179
+    }
180
+
181
+    /**
182
+     * Overload a field path.
183
+     *
184
+     * @param string $file  Extension file.
185
+     * @param array  $field Field array.
186
+     *
187
+     * @return string
188
+     */
189
+    public function overload_field_path( string $file, array $field ): string {
190
+        $filename_fix = str_replace( '_', '-', $field['type'] );
191
+
192
+        $files = array(
193
+            trailingslashit( dirname( $this->file ) ) . $field['type'] . DIRECTORY_SEPARATOR . 'field_' . $field['type'] . '.php',
194
+            trailingslashit( dirname( $this->file ) ) . $field['type'] . DIRECTORY_SEPARATOR . 'class-redux-' . $filename_fix . '.php',
195
+        );
196
+
197
+        return Redux_Functions::file_exists_ex( $files );
198
+    }
199
+
200
+    /**
201
+     * Sets the minimum version of Redux to use.  Displays a notice if requirements are not met.
202
+     *
203
+     * @param string $min_version       Minimum version to evaluate.
204
+     * @param string $extension_version Extension version number.
205
+     * @param string $friendly_name     Friend extension name for notice display.
206
+     *
207
+     * @return bool
208
+     */
209
+    public function is_minimum_version( string $min_version = '', string $extension_version = '', string $friendly_name = '' ): bool {
210
+        $redux_ver = Redux_Core::$version;
211
+
212
+        if ( '' !== $min_version ) {
213
+            if ( version_compare( $redux_ver, $min_version ) < 0 ) {
214
+                // translators: %1$s Extension friendly name. %2$s: minimum Redux version.
215
+                $msg = '<strong>' . sprintf( esc_html__( 'The %1$s extension requires Redux Framework version %2$s or higher.', 'redux-framework' ), $friendly_name, $min_version ) . '</strong>&nbsp;&nbsp;' . esc_html__( 'You are currently running Redux Framework version ', 'redux-framework' ) . ' ' . $redux_ver . '.<br/><br/>' . esc_html__( 'This field will not render in your option panel, and features of this extension will not be available until the latest version of Redux Framework has been installed.', 'redux-framework' );
216
+
217
+                $data = array(
218
+                    'parent'  => $this->parent,
219
+                    'type'    => 'error',
220
+                    'msg'     => $msg,
221
+                    'id'      => $this->extension_name . '_notice_' . $extension_version,
222
+                    'dismiss' => false,
223
+                );
224
+
225
+                if ( method_exists( 'Redux_Admin_Notices', 'set_notice' ) ) {
226
+                    Redux_Admin_Notices::set_notice( $data );
227
+                } else {
228
+                    echo '<div class="error">';
229
+                    echo '<p>';
230
+                    echo $msg; // phpcs:ignore WordPress.Security.EscapeOutput
231
+                    echo '</p>';
232
+                    echo '</div>';
233
+                }
234
+
235
+                return false;
236
+            }
237
+        }
238
+
239
+        return true;
240
+    }
241 241
 }
242 242
 
243 243
 if ( ! class_exists( 'Redux_Abstract_Extension' ) ) {
244
-	class_alias( 'Redux_Extension_Abstract', 'Redux_Abstract_Extension' );
244
+    class_alias( 'Redux_Extension_Abstract', 'Redux_Abstract_Extension' );
245 245
 }
Please login to merge, or discard this patch.
redux-core/inc/classes/class-redux-field.php 1 patch
Indentation   +216 added lines, -216 removed lines patch added patch discarded remove patch
@@ -11,220 +11,220 @@
 block discarded – undo
11 11
 
12 12
 if ( ! class_exists( 'Redux_Field', false ) ) {
13 13
 
14
-	/**
15
-	 * Class Redux_Field
16
-	 */
17
-	abstract class Redux_Field {
18
-
19
-		/**
20
-		 * CSS styling per field output/compiler.
21
-		 *
22
-		 * @var string
23
-		 */
24
-		public $style = null;
25
-
26
-		/**
27
-		 * Class dir.
28
-		 *
29
-		 * @var string
30
-		 */
31
-		public $dir = null;
32
-
33
-		/**
34
-		 * Class URL.
35
-		 *
36
-		 * @var string
37
-		 */
38
-		public $url = null;
39
-
40
-		/**
41
-		 * Timestamp for ver append in dev_mode
42
-		 *
43
-		 * @var string
44
-		 */
45
-		public $timestamp = null;
46
-
47
-		/**
48
-		 * ReduxFramework object pointer.
49
-		 *
50
-		 * @var ReduxFramework
51
-		 */
52
-		public $parent;
53
-
54
-		/**
55
-		 * Field values.
56
-		 *
57
-		 * @var string|array
58
-		 */
59
-		public $field;
60
-
61
-		/**
62
-		 * Value values.
63
-		 *
64
-		 * @var string|array
65
-		 */
66
-		public $value;
67
-
68
-		/**
69
-		 * Select2 options.
70
-		 *
71
-		 * @var array
72
-		 */
73
-		public $select2_config = array();
74
-
75
-		/**
76
-		 * Redux_Field constructor.
77
-		 *
78
-		 * @param array|string|null $field  Field array.
79
-		 * @param string|array|null $value  Field values.
80
-		 * @param null              $redux ReduxFramework object pointer.
81
-		 *
82
-		 * @throws ReflectionException Comment.
83
-		 */
84
-		public function __construct( $field = array(), $value = null, $redux = null ) {
85
-			$this->parent = $redux;
86
-			$this->field  = $field;
87
-			$this->value  = $value;
88
-
89
-			$this->select2_config = array(
90
-				'width'      => 'resolve',
91
-				'allowClear' => false,
92
-				'theme'      => 'default',
93
-			);
94
-
95
-			$this->set_defaults();
96
-
97
-			$class_name = get_class( $this );
98
-			$reflector  = new ReflectionClass( $class_name );
99
-			$path       = $reflector->getFilename();
100
-			$path_info  = Redux_Helpers::path_info( $path );
101
-			$this->dir  = trailingslashit( dirname( $path_info['real_path'] ) );
102
-			$this->url  = trailingslashit( dirname( $path_info['url'] ) );
103
-
104
-			$this->timestamp = Redux_Core::$version;
105
-			if ( $redux->args['dev_mode'] ) {
106
-				$this->timestamp .= '.' . time();
107
-			}
108
-		}
109
-
110
-		/**
111
-		 * Media query compiler for Redux Pro,
112
-		 *
113
-		 * @param string $style_data CSS string.
114
-		 */
115
-		public function media_query( string $style_data = '' ) {
116
-			$query_arr = $this->field['media_query'];
117
-			$css       = '';
118
-
119
-			if ( isset( $query_arr['queries'] ) ) {
120
-				foreach ( $query_arr['queries'] as $query ) {
121
-					$rule      = $query['rule'] ?? '';
122
-					$selectors = $query['selectors'] ?? array();
123
-
124
-					if ( ! is_array( $selectors ) && '' !== $selectors ) {
125
-						$selectors = array( $selectors );
126
-					}
127
-
128
-					if ( '' !== $rule && ! empty( $selectors ) ) {
129
-						$selectors = implode( ',', $selectors );
130
-
131
-						$css .= '@media ' . $rule . '{';
132
-						$css .= $selectors . '{' . $style_data . '}';
133
-						$css .= '}';
134
-					}
135
-				}
136
-			} else {
137
-				return;
138
-			}
139
-
140
-			if ( isset( $query_arr['output'] ) && $query_arr['output'] ) {
141
-				$this->parent->outputCSS .= $css;
142
-			}
143
-
144
-			if ( isset( $query_arr['compiler'] ) && $query_arr['compiler'] ) {
145
-				$this->parent->compilerCSS .= $css;
146
-			}
147
-		}
148
-
149
-		/**
150
-		 * CSS for field output, if set (Remove the noinpection line and fix this function when we drop support for PHP 7.1).
151
-		 *
152
-		 * @param string $style CSS string.
153
-		 *
154
-		 * @noinspection PhpMissingParamTypeInspection
155
-		 */
156
-		public function output( $style = '' ) {
157
-			if ( '' !== $style ) {
158
-
159
-				// Force output value into an array.
160
-				if ( isset( $this->field['output'] ) && ! is_array( $this->field['output'] ) ) {
161
-					$this->field['output'] = array( $this->field['output'] );
162
-				}
163
-
164
-				if ( ! empty( $this->field['output'] ) && is_array( $this->field['output'] ) ) {
165
-					if ( isset( $this->field['output']['important'] ) ) {
166
-						if ( $this->field['output']['important'] ) {
167
-							$style = str_replace( ';', ' !important;', $style );
168
-						}
169
-						unset( $this->field['output']['important'] );
170
-					}
171
-
172
-					$keys                     = implode( ',', $this->field['output'] );
173
-					$this->parent->outputCSS .= $keys . '{' . $style . '}';
174
-				}
175
-
176
-				// Force compiler value into an array.
177
-				if ( isset( $this->field['compiler'] ) && ! is_array( $this->field['compiler'] ) ) {
178
-					$this->field['compiler'] = array( $this->field['compiler'] );
179
-				}
180
-
181
-				if ( isset( $this->field['compiler']['important'] ) ) {
182
-					if ( $this->field['compiler']['important'] ) {
183
-						$style = str_replace( ';', ' !important;', $style );
184
-					}
185
-					unset( $this->field['compiler']['important'] );
186
-				}
187
-
188
-				if ( ! empty( $this->field['compiler'] ) && is_array( $this->field['compiler'] ) ) {
189
-					$keys                       = implode( ',', $this->field['compiler'] );
190
-					$this->parent->compilerCSS .= $keys . '{' . $style . '}';
191
-				}
192
-			}
193
-		}
194
-
195
-		/**
196
-		 * Unused for now.
197
-		 *
198
-		 * @param mixed $data CSS data.
199
-		 */
200
-		public function css_style( $data ) {}
201
-
202
-		/**
203
-		 * Unused for now.
204
-		 */
205
-		public function set_defaults() {}
206
-
207
-		/**
208
-		 * Unused for now.
209
-		 */
210
-		public function render() {}
211
-
212
-		/**
213
-		 * Unused for now.
214
-		 */
215
-		public function enqueue() {}
216
-
217
-		/**
218
-		 * Unused for now.
219
-		 */
220
-		public function always_enqueue() {}
221
-
222
-		/**
223
-		 * Unused for now.
224
-		 *
225
-		 * @param array  $field Field array.
226
-		 * @param string $value Value array.
227
-		 */
228
-		public function localize( array $field, string $value = '' ) {}
229
-	}
14
+    /**
15
+     * Class Redux_Field
16
+     */
17
+    abstract class Redux_Field {
18
+
19
+        /**
20
+         * CSS styling per field output/compiler.
21
+         *
22
+         * @var string
23
+         */
24
+        public $style = null;
25
+
26
+        /**
27
+         * Class dir.
28
+         *
29
+         * @var string
30
+         */
31
+        public $dir = null;
32
+
33
+        /**
34
+         * Class URL.
35
+         *
36
+         * @var string
37
+         */
38
+        public $url = null;
39
+
40
+        /**
41
+         * Timestamp for ver append in dev_mode
42
+         *
43
+         * @var string
44
+         */
45
+        public $timestamp = null;
46
+
47
+        /**
48
+         * ReduxFramework object pointer.
49
+         *
50
+         * @var ReduxFramework
51
+         */
52
+        public $parent;
53
+
54
+        /**
55
+         * Field values.
56
+         *
57
+         * @var string|array
58
+         */
59
+        public $field;
60
+
61
+        /**
62
+         * Value values.
63
+         *
64
+         * @var string|array
65
+         */
66
+        public $value;
67
+
68
+        /**
69
+         * Select2 options.
70
+         *
71
+         * @var array
72
+         */
73
+        public $select2_config = array();
74
+
75
+        /**
76
+         * Redux_Field constructor.
77
+         *
78
+         * @param array|string|null $field  Field array.
79
+         * @param string|array|null $value  Field values.
80
+         * @param null              $redux ReduxFramework object pointer.
81
+         *
82
+         * @throws ReflectionException Comment.
83
+         */
84
+        public function __construct( $field = array(), $value = null, $redux = null ) {
85
+            $this->parent = $redux;
86
+            $this->field  = $field;
87
+            $this->value  = $value;
88
+
89
+            $this->select2_config = array(
90
+                'width'      => 'resolve',
91
+                'allowClear' => false,
92
+                'theme'      => 'default',
93
+            );
94
+
95
+            $this->set_defaults();
96
+
97
+            $class_name = get_class( $this );
98
+            $reflector  = new ReflectionClass( $class_name );
99
+            $path       = $reflector->getFilename();
100
+            $path_info  = Redux_Helpers::path_info( $path );
101
+            $this->dir  = trailingslashit( dirname( $path_info['real_path'] ) );
102
+            $this->url  = trailingslashit( dirname( $path_info['url'] ) );
103
+
104
+            $this->timestamp = Redux_Core::$version;
105
+            if ( $redux->args['dev_mode'] ) {
106
+                $this->timestamp .= '.' . time();
107
+            }
108
+        }
109
+
110
+        /**
111
+         * Media query compiler for Redux Pro,
112
+         *
113
+         * @param string $style_data CSS string.
114
+         */
115
+        public function media_query( string $style_data = '' ) {
116
+            $query_arr = $this->field['media_query'];
117
+            $css       = '';
118
+
119
+            if ( isset( $query_arr['queries'] ) ) {
120
+                foreach ( $query_arr['queries'] as $query ) {
121
+                    $rule      = $query['rule'] ?? '';
122
+                    $selectors = $query['selectors'] ?? array();
123
+
124
+                    if ( ! is_array( $selectors ) && '' !== $selectors ) {
125
+                        $selectors = array( $selectors );
126
+                    }
127
+
128
+                    if ( '' !== $rule && ! empty( $selectors ) ) {
129
+                        $selectors = implode( ',', $selectors );
130
+
131
+                        $css .= '@media ' . $rule . '{';
132
+                        $css .= $selectors . '{' . $style_data . '}';
133
+                        $css .= '}';
134
+                    }
135
+                }
136
+            } else {
137
+                return;
138
+            }
139
+
140
+            if ( isset( $query_arr['output'] ) && $query_arr['output'] ) {
141
+                $this->parent->outputCSS .= $css;
142
+            }
143
+
144
+            if ( isset( $query_arr['compiler'] ) && $query_arr['compiler'] ) {
145
+                $this->parent->compilerCSS .= $css;
146
+            }
147
+        }
148
+
149
+        /**
150
+         * CSS for field output, if set (Remove the noinpection line and fix this function when we drop support for PHP 7.1).
151
+         *
152
+         * @param string $style CSS string.
153
+         *
154
+         * @noinspection PhpMissingParamTypeInspection
155
+         */
156
+        public function output( $style = '' ) {
157
+            if ( '' !== $style ) {
158
+
159
+                // Force output value into an array.
160
+                if ( isset( $this->field['output'] ) && ! is_array( $this->field['output'] ) ) {
161
+                    $this->field['output'] = array( $this->field['output'] );
162
+                }
163
+
164
+                if ( ! empty( $this->field['output'] ) && is_array( $this->field['output'] ) ) {
165
+                    if ( isset( $this->field['output']['important'] ) ) {
166
+                        if ( $this->field['output']['important'] ) {
167
+                            $style = str_replace( ';', ' !important;', $style );
168
+                        }
169
+                        unset( $this->field['output']['important'] );
170
+                    }
171
+
172
+                    $keys                     = implode( ',', $this->field['output'] );
173
+                    $this->parent->outputCSS .= $keys . '{' . $style . '}';
174
+                }
175
+
176
+                // Force compiler value into an array.
177
+                if ( isset( $this->field['compiler'] ) && ! is_array( $this->field['compiler'] ) ) {
178
+                    $this->field['compiler'] = array( $this->field['compiler'] );
179
+                }
180
+
181
+                if ( isset( $this->field['compiler']['important'] ) ) {
182
+                    if ( $this->field['compiler']['important'] ) {
183
+                        $style = str_replace( ';', ' !important;', $style );
184
+                    }
185
+                    unset( $this->field['compiler']['important'] );
186
+                }
187
+
188
+                if ( ! empty( $this->field['compiler'] ) && is_array( $this->field['compiler'] ) ) {
189
+                    $keys                       = implode( ',', $this->field['compiler'] );
190
+                    $this->parent->compilerCSS .= $keys . '{' . $style . '}';
191
+                }
192
+            }
193
+        }
194
+
195
+        /**
196
+         * Unused for now.
197
+         *
198
+         * @param mixed $data CSS data.
199
+         */
200
+        public function css_style( $data ) {}
201
+
202
+        /**
203
+         * Unused for now.
204
+         */
205
+        public function set_defaults() {}
206
+
207
+        /**
208
+         * Unused for now.
209
+         */
210
+        public function render() {}
211
+
212
+        /**
213
+         * Unused for now.
214
+         */
215
+        public function enqueue() {}
216
+
217
+        /**
218
+         * Unused for now.
219
+         */
220
+        public function always_enqueue() {}
221
+
222
+        /**
223
+         * Unused for now.
224
+         *
225
+         * @param array  $field Field array.
226
+         * @param string $value Value array.
227
+         */
228
+        public function localize( array $field, string $value = '' ) {}
229
+    }
230 230
 }
Please login to merge, or discard this patch.
redux-core/inc/classes/class-redux-helpers.php 2 patches
Spacing   +26 added lines, -26 removed lines patch added patch discarded remove patch
@@ -243,9 +243,9 @@  discard block
 block discarded – undo
243 243
 				'localhost.localdomain',
244 244
 				'127.0.0.1',
245 245
 				'::1',
246
-				'local.wordpress.test',         // VVV pattern.
247
-				'local.wordpress-trunk.test',   // VVV pattern.
248
-				'src.wordpress-develop.test',   // VVV pattern.
246
+				'local.wordpress.test', // VVV pattern.
247
+				'local.wordpress-trunk.test', // VVV pattern.
248
+				'src.wordpress-develop.test', // VVV pattern.
249 249
 				'build.wordpress-develop.test', // VVV pattern.
250 250
 			);
251 251
 
@@ -512,29 +512,29 @@  discard block
 block discarded – undo
512 512
 					$theme_info  = self::is_inside_theme( $caller );
513 513
 
514 514
 					if ( $theme_info ) {
515
-						if ( ! isset( $data['theme'][ $theme_info['slug'] ] ) ) {
516
-							$data['theme'][ $theme_info['slug'] ] = array();
515
+						if ( ! isset( $data['theme'][$theme_info['slug']] ) ) {
516
+							$data['theme'][$theme_info['slug']] = array();
517 517
 						}
518
-						if ( ! isset( $data['theme'][ $theme_info['slug'] ][ $opt_name ] ) ) {
519
-							$data['theme'][ $theme_info['slug'] ][ $opt_name ] = array();
518
+						if ( ! isset( $data['theme'][$theme_info['slug']][$opt_name] ) ) {
519
+							$data['theme'][$theme_info['slug']][$opt_name] = array();
520 520
 						}
521 521
 						if ( $simple ) {
522
-							$data['theme'][ $theme_info['slug'] ][ $opt_name ][] = $theme_info['basename'];
522
+							$data['theme'][$theme_info['slug']][$opt_name][] = $theme_info['basename'];
523 523
 						} else {
524
-							$data['theme'][ $theme_info['slug'] ][ $opt_name ][] = $theme_info;
524
+							$data['theme'][$theme_info['slug']][$opt_name][] = $theme_info;
525 525
 						}
526 526
 					} elseif ( $plugin_info ) {
527
-						if ( ! isset( $data['plugin'][ $plugin_info['slug'] ] ) ) {
528
-							$data['plugin'][ $plugin_info['slug'] ] = array();
527
+						if ( ! isset( $data['plugin'][$plugin_info['slug']] ) ) {
528
+							$data['plugin'][$plugin_info['slug']] = array();
529 529
 						}
530
-						if ( ! in_array( $opt_name, $data['plugin'][ $plugin_info['slug'] ], true ) ) {
531
-							if ( ! isset( $data['plugin'][ $plugin_info['slug'] ][ $opt_name ] ) ) {
532
-								$data['plugin'][ $plugin_info['slug'] ][ $opt_name ] = array();
530
+						if ( ! in_array( $opt_name, $data['plugin'][$plugin_info['slug']], true ) ) {
531
+							if ( ! isset( $data['plugin'][$plugin_info['slug']][$opt_name] ) ) {
532
+								$data['plugin'][$plugin_info['slug']][$opt_name] = array();
533 533
 							}
534 534
 							if ( $simple ) {
535
-								$data['plugin'][ $plugin_info['slug'] ][ $opt_name ][] = $plugin_info['basename'];
535
+								$data['plugin'][$plugin_info['slug']][$opt_name][] = $plugin_info['basename'];
536 536
 							} else {
537
-								$data['plugin'][ $plugin_info['slug'] ][ $opt_name ][] = $plugin_info;
537
+								$data['plugin'][$plugin_info['slug']][$opt_name][] = $plugin_info;
538 538
 							}
539 539
 						}
540 540
 					}
@@ -682,12 +682,12 @@  discard block
 block discarded – undo
682 682
 			return join(
683 683
 				' ',
684 684
 				array_map(
685
-					function ( $key ) use ( $attributes ) {
686
-						if ( is_bool( $attributes[ $key ] ) ) {
687
-							return $attributes[ $key ] ? $key : '';
685
+					function( $key ) use ( $attributes ) {
686
+						if ( is_bool( $attributes[$key] ) ) {
687
+							return $attributes[$key] ? $key : '';
688 688
 						}
689 689
 
690
-						return $key . '="' . $attributes[ $key ] . '"';
690
+						return $key . '="' . $attributes[$key] . '"';
691 691
 					},
692 692
 					array_keys( $attributes )
693 693
 				)
@@ -860,7 +860,7 @@  discard block
 block discarded – undo
860 860
 							$args[] = $object_id;
861 861
 						}
862 862
 
863
-						$expression_result = call_user_func_array( 'user_can', $args ) === (bool) $value;
863
+						$expression_result = call_user_func_array( 'user_can', $args ) === ( bool ) $value;
864 864
 					} elseif ( is_array( $value ) ) {
865 865
 						++$depth;
866 866
 
@@ -1121,7 +1121,7 @@  discard block
 block discarded – undo
1121 1121
 			$new_arr = array();
1122 1122
 
1123 1123
 			foreach ( $arr as $key => $value ) {
1124
-				$new_arr[ $key ] = ( is_array( $value ) ? self::array_map_r( $func, $value ) : ( is_array( $func ) ? call_user_func_array( $func, $value ) : $func( $value ) ) );
1124
+				$new_arr[$key] = ( is_array( $value ) ? self::array_map_r( $func, $value ) : ( is_array( $func ) ? call_user_func_array( $func, $value ) : $func( $value ) ) );
1125 1125
 			}
1126 1126
 
1127 1127
 			return $new_arr;
@@ -1196,8 +1196,8 @@  discard block
 block discarded – undo
1196 1196
 
1197 1197
 				$position_colors = array();
1198 1198
 				foreach ( $colors as $color_family ) {
1199
-					if ( isset( $color_family[ $key ] ) ) {
1200
-						$position_colors[] = $color_family[ $key ];
1199
+					if ( isset( $color_family[$key] ) ) {
1200
+						$position_colors[] = $color_family[$key];
1201 1201
 					}
1202 1202
 				}
1203 1203
 
@@ -1216,8 +1216,8 @@  discard block
 block discarded – undo
1216 1216
 			} elseif ( 'primary' === $context ) {
1217 1217
 				return $colors['primary'];
1218 1218
 			} else {
1219
-				if ( isset( $colors[ $context ] ) ) {
1220
-					return $colors[ $context ];
1219
+				if ( isset( $colors[$context] ) ) {
1220
+					return $colors[$context];
1221 1221
 				}
1222 1222
 
1223 1223
 				return $colors['primary'];
Please login to merge, or discard this patch.
Indentation   +1211 added lines, -1211 removed lines patch added patch discarded remove patch
@@ -15,1215 +15,1215 @@
 block discarded – undo
15 15
 // Don't duplicate me!
16 16
 if ( ! class_exists( 'Redux_Helpers', false ) ) {
17 17
 
18
-	/**
19
-	 * Redux Helpers Class
20
-	 * A Class of useful functions that can/should be shared among all Redux files.
21
-	 *
22
-	 * @since       3.0.0
23
-	 */
24
-	class Redux_Helpers {
25
-
26
-		/**
27
-		 * Reusable supported unit array.
28
-		 *
29
-		 * @var array
30
-		 */
31
-		public static $array_units = array( '', '%', 'in', 'cm', 'mm', 'em', 'rem', 'ex', 'pt', 'pc', 'px', 'vh', 'vw', 'vmin', 'vmax', 'ch' );
32
-
33
-		/**
34
-		 * Is customizer loaded.
35
-		 *
36
-		 * @return bool
37
-		 */
38
-		public static function is_customizer_loaded(): bool {
39
-			global $wp_customize;
40
-
41
-			if ( isset( $wp_customize ) ) {
42
-				return true;
43
-			}
44
-
45
-			return false;
46
-		}
47
-
48
-		/**
49
-		 * Retrieve the section array from field ID.
50
-		 *
51
-		 * @param string $opt_name Panel opt_name.
52
-		 * @param string $field_id Field ID.
53
-		 */
54
-		public static function section_from_field_id( string $opt_name = '', string $field_id = '' ) {
55
-			if ( '' !== $opt_name ) {
56
-				$redux = Redux::instance( $opt_name );
57
-
58
-				if ( is_object( $redux ) ) {
59
-					$sections = $redux->sections;
60
-
61
-					if ( is_array( $sections ) && ! empty( $sections ) ) {
62
-						foreach ( $sections as $section ) {
63
-							if ( ! empty( $section['fields'] ) ) {
64
-								foreach ( $section['fields'] as $field ) {
65
-									if ( is_array( $field ) && ! empty( $field ) ) {
66
-										if ( isset( $field['id'] ) && $field['id'] === $field_id ) {
67
-											return $section;
68
-										}
69
-									}
70
-								}
71
-							}
72
-						}
73
-					}
74
-				}
75
-			}
76
-
77
-			return null;
78
-		}
79
-
80
-		/**
81
-		 * Verify integer value.
82
-		 *
83
-		 * @param mixed $val Value to test.
84
-		 *
85
-		 * @return bool|false|int
86
-		 */
87
-		public static function is_integer( $val ) {
88
-			if ( ! is_scalar( $val ) || is_bool( $val ) ) {
89
-				return false;
90
-			}
91
-
92
-			return is_float( $val ) ? false : preg_match( '~^([+\-]?[0-9]+)$~', $val );
93
-		}
94
-
95
-		/**
96
-		 * Deprecated. Gets panel tab number from the specified field.
97
-		 *
98
-		 * @param object       $redux ReduxFramework object.
99
-		 * @param array|string $field  Field array.
100
-		 *
101
-		 * @return int|string
102
-		 * @deprecated No longer using camelCase naming convention.
103
-		 */
104
-		public static function tabFromField( $redux, $field ) { // phpcs:ignore WordPress.NamingConventions.ValidFunctionName
105
-			_deprecated_function( __CLASS__ . '::' . __FUNCTION__, 'Redux 4.0', 'Redux_Helpers::tab_from_field( $parent, $field )' );
106
-
107
-			return self::tab_from_field( $redux, $field );
108
-		}
109
-
110
-		/**
111
-		 * Gets panel tab number from the specified field.
112
-		 *
113
-		 * @param object       $redux ReduxFramework object.
114
-		 * @param array|string $field  Field array.
115
-		 *
116
-		 * @return int|string
117
-		 */
118
-		public static function tab_from_field( $redux, $field ) {
119
-			foreach ( $redux->sections as $k => $section ) {
120
-				if ( ! isset( $section['title'] ) ) {
121
-					continue;
122
-				}
123
-
124
-				if ( ! empty( $section['fields'] ) ) {
125
-					if ( self::recursive_array_search( $field, $section['fields'] ) ) {
126
-						return $k;
127
-					}
128
-				}
129
-			}
130
-
131
-			return null;
132
-		}
133
-
134
-		/**
135
-		 * Deprecated. Verifies if a specified field type is in use.
136
-		 *
137
-		 * @param array $fields Field arrays.
138
-		 * @param array $field  Field array.
139
-		 *
140
-		 * @return bool
141
-		 * @deprecated No longer using camelCase naming convention.
142
-		 */
143
-		public static function isFieldInUseByType( array $fields, array $field = array() ): bool { // phpcs:ignore WordPress.NamingConventions.ValidFunctionName
144
-			// phpcs:ignore Squiz.PHP.CommentedOutCode
145
-			_deprecated_function( __CLASS__ . '::' . __FUNCTION__, 'Redux 4.0', 'Redux_Helpers::is_field_in_use_by_type( $parent, $field )' );
146
-			return self::is_field_in_use_by_type( $fields, $field );
147
-		}
148
-
149
-		/**
150
-		 * Verifies if a specified field type is in use.
151
-		 *
152
-		 * @param array $fields Field arrays.
153
-		 * @param array $field  Field arrays to check.
154
-		 *
155
-		 * @return bool
156
-		 */
157
-		public static function is_field_in_use_by_type( array $fields, array $field = array() ): bool {
158
-			foreach ( $field as $name ) {
159
-				if ( array_key_exists( $name, $fields ) ) {
160
-					return true;
161
-				}
162
-			}
163
-
164
-			return false;
165
-		}
166
-
167
-		/**
168
-		 * Deprecated Verifies if field is in use.
169
-		 *
170
-		 * @param object $redux ReduxFramework object.
171
-		 * @param string $field  Field type.
172
-		 *
173
-		 * @return bool
174
-		 * @deprecated No longer using camelCase function names.
175
-		 */
176
-		public static function isFieldInUse( $redux, string $field ): bool { // phpcs:ignore WordPress.NamingConventions.ValidFunctionName
177
-			_deprecated_function( __CLASS__ . '::' . __FUNCTION__, 'Redux 4.0', 'Redux_Helpers::is_field_in_use( $parent, $field )' );
178
-
179
-			return self::is_field_in_use( $redux, $field );
180
-		}
181
-
182
-		/**
183
-		 * Verifies if field is in use.
184
-		 *
185
-		 * @param object $redux ReduxFramework object.
186
-		 * @param string $field  Field type.
187
-		 *
188
-		 * @return bool
189
-		 */
190
-		public static function is_field_in_use( $redux, string $field ): bool {
191
-			if ( empty( $redux->sections ) ) {
192
-				return false;
193
-			}
194
-
195
-			foreach ( $redux->sections as $section ) {
196
-				if ( ! isset( $section['title'] ) ) {
197
-					continue;
198
-				}
199
-
200
-				if ( ! empty( $section['fields'] ) ) {
201
-					if ( self::recursive_array_search( $field, $section['fields'] ) ) {
202
-						return true;
203
-					}
204
-				}
205
-			}
206
-
207
-			return false;
208
-		}
209
-
210
-		/**
211
-		 * Returns major version from version number.
212
-		 *
213
-		 * @param string $v Version number.
214
-		 *
215
-		 * @return string
216
-		 */
217
-		public static function major_version( string $v ): string {
218
-			$version = explode( '.', $v );
219
-			if ( count( $version ) > 1 ) {
220
-				return $version[0] . '.' . $version[1];
221
-			} else {
222
-				return $v;
223
-			}
224
-		}
225
-
226
-
227
-		/**
228
-		 * Deprecated. Checks for localhost environment.
229
-		 *
230
-		 * @return bool
231
-		 * @deprecated No longer using camelCase naming convention.
232
-		 * @since      4.0
233
-		 */
234
-		public static function isLocalHost(): bool { // phpcs:ignore WordPress.NamingConventions.ValidFunctionName
235
-			_deprecated_function( __CLASS__ . '::' . __FUNCTION__, 'Redux 4.0', 'Redux_Helpers::is_local_host()' );
236
-
237
-			return self::is_local_host();
238
-		}
239
-
240
-		/**
241
-		 * Checks for localhost environment.
242
-		 *
243
-		 * @return bool
244
-		 */
245
-		public static function is_local_host(): bool {
246
-			$is_local = false;
247
-
248
-			$domains_to_check = array_unique(
249
-				array(
250
-					'siteurl' => wp_parse_url( get_site_url(), PHP_URL_HOST ),
251
-					'homeurl' => wp_parse_url( get_home_url(), PHP_URL_HOST ),
252
-				)
253
-			);
254
-
255
-			$forbidden_domains = array(
256
-				'wordpress.com',
257
-				'localhost',
258
-				'localhost.localdomain',
259
-				'127.0.0.1',
260
-				'::1',
261
-				'local.wordpress.test',         // VVV pattern.
262
-				'local.wordpress-trunk.test',   // VVV pattern.
263
-				'src.wordpress-develop.test',   // VVV pattern.
264
-				'build.wordpress-develop.test', // VVV pattern.
265
-			);
266
-
267
-			foreach ( $domains_to_check as $domain ) {
268
-				// If it's empty, just fail out.
269
-				if ( ! $domain ) {
270
-					$is_local = true;
271
-					break;
272
-				}
273
-
274
-				// None of the explicit localhosts.
275
-				if ( in_array( $domain, $forbidden_domains, true ) ) {
276
-					$is_local = true;
277
-					break;
278
-				}
279
-
280
-				// No .test or .local domains.
281
-				if ( preg_match( '#\.(test|local)$#i', $domain ) ) {
282
-					$is_local = true;
283
-					break;
284
-				}
285
-			}
286
-
287
-			return $is_local;
288
-		}
289
-
290
-		/**
291
-		 * Deprecated. Checks if WP_DEBUG is enabled.
292
-		 *
293
-		 * @return bool::is_wp_debug()
294
-		 * @deprecated No longer using camelCase naming convention.
295
-		 * @since      4.0
296
-		 */
297
-		public static function isWpDebug(): bool { // phpcs:ignore WordPress.NamingConventions.ValidFunctionName
298
-			_deprecated_function( __CLASS__ . '::' . __FUNCTION__, 'Redux 4.0', 'Redux_Functions_Ex::is_wp_debug()' );
299
-
300
-			return self::is_wp_debug();
301
-		}
302
-
303
-		/**
304
-		 * Checks if WP_DEBUG is enabled.
305
-		 *
306
-		 * @return bool
307
-		 */
308
-		public static function is_wp_debug(): bool {
309
-			return ( defined( 'WP_DEBUG' ) && true === WP_DEBUG );
310
-		}
311
-
312
-		/**
313
-		 * Deprecated. Determines if theme is parent.
314
-		 *
315
-		 * @param string $file Path to file.
316
-		 *
317
-		 * @return bool
318
-		 * @deprecated No longer using camelCase naming convention.
319
-		 */
320
-		public static function isParentTheme( string $file ): bool { // phpcs:ignore WordPress.NamingConventions.ValidFunctionName
321
-			_deprecated_function( __CLASS__ . '::' . __FUNCTION__, 'Redux 4.0.0', 'Redux_Instances::is_parent_theme( $file )' );
322
-
323
-			return self::is_parent_theme( $file );
324
-		}
325
-
326
-		/**
327
-		 * Determines if theme is parent.
328
-		 *
329
-		 * @param string $file Path to theme dir.
330
-		 *
331
-		 * @return bool
332
-		 */
333
-		public static function is_parent_theme( string $file ): bool {
334
-			$file = Redux_Functions_Ex::wp_normalize_path( $file );
335
-			$dir  = Redux_Functions_Ex::wp_normalize_path( get_template_directory() );
336
-
337
-			$file = str_replace( '//', '/', $file );
338
-			$dir  = str_replace( '//', '/', $dir );
339
-
340
-			if ( strpos( $file, $dir ) !== false ) {
341
-				return true;
342
-			}
343
-
344
-			return false;
345
-		}
346
-
347
-		/**
348
-		 * Deprecated. Moved to another class.
349
-		 *
350
-		 * @param string $file Path to file.
351
-		 *
352
-		 * @return string
353
-		 * @deprecated Moved to another class.
354
-		 */
355
-		public static function wp_normalize_path( string $file ): string { // phpcs:ignore WordPress.NamingConventions.ValidFunctionName
356
-			_deprecated_function( __CLASS__ . '::' . __FUNCTION__, 'Redux 4.0.0', 'Redux_Functions_Ex::wp_normalize_path( $file )' );
357
-
358
-			return Redux_Functions_Ex::wp_normalize_path( $file );
359
-		}
360
-
361
-		/**
362
-		 * Deprecated. Determines if the theme is child.
363
-		 *
364
-		 * @param string $file Path to file.
365
-		 *
366
-		 * @return bool
367
-		 * @deprecated No longer using camelCase naming convention.
368
-		 */
369
-		public static function isChildTheme( string $file ): bool { // phpcs:ignore WordPress.NamingConventions.ValidFunctionName
370
-			_deprecated_function( __CLASS__ . '::' . __FUNCTION__, 'Redux 4.0.0', 'Redux_Instances::is_child_theme( $file )' );
371
-
372
-			return self::is_child_theme( $file );
373
-		}
374
-
375
-		/**
376
-		 * Determines if the theme is child.
377
-		 *
378
-		 * @param string $file Path to theme dir.
379
-		 *
380
-		 * @return bool
381
-		 */
382
-		public static function is_child_theme( string $file ): bool {
383
-			$file = Redux_Functions_Ex::wp_normalize_path( $file );
384
-			$dir  = Redux_Functions_Ex::wp_normalize_path( get_stylesheet_directory() );
385
-
386
-			$file = str_replace( '//', '/', $file );
387
-			$dir  = str_replace( '//', '/', $dir );
388
-
389
-			if ( strpos( $file, $dir ) !== false ) {
390
-				return true;
391
-			}
392
-
393
-			return false;
394
-		}
395
-
396
-		/**
397
-		 * Deprecated. Determines if file is a theme.
398
-		 *
399
-		 * @param string $file Path to file.
400
-		 *
401
-		 * @return bool
402
-		 * @deprecated No longer using camelCase naming convention.
403
-		 */
404
-		public static function isTheme( string $file ): bool { // phpcs:ignore WordPress.NamingConventions.ValidFunctionName
405
-			// phpcs:ignore Squiz.PHP.CommentedOutCode
406
-			// _deprecated_function( __CLASS__ . '::' . __FUNCTION__, 'Redux 4.0.0', 'Redux_Instances::is_theme( $file )' );
407
-
408
-			return self::is_theme( $file );
409
-		}
410
-
411
-		/**
412
-		 * Determines if file is a theme.
413
-		 *
414
-		 * @param string $file Path to fle to test.
415
-		 *
416
-		 * @return bool
417
-		 */
418
-		public static function is_theme( string $file ): bool {
419
-			if ( true === self::is_child_theme( $file ) || true === self::is_parent_theme( $file ) ) {
420
-				return true;
421
-			}
422
-
423
-			return false;
424
-		}
425
-
426
-		/**
427
-		 * Determines deep array status.
428
-		 *
429
-		 * @param array|string $needle   array to test.
430
-		 * @param array        $haystack Array to search.
431
-		 *
432
-		 * @return bool
433
-		 */
434
-		public static function array_in_array( $needle, array $haystack ): bool {
435
-			// Make sure $needle is an array for foreach.
436
-			if ( ! is_array( $needle ) ) {
437
-				$needle = array( $needle );
438
-			}
439
-			// For each value in $needle, return TRUE if in $haystack.
440
-			foreach ( $needle as $pin ) {
441
-				if ( in_array( $pin, $haystack, true ) ) {
442
-					return true;
443
-				}
444
-			}
445
-
446
-			// Return FALSE if none of the values from $needle are found in $haystack.
447
-			return false;
448
-		}
449
-
450
-		/**
451
-		 * Enum through an entire deep array.
452
-		 *
453
-		 * @param string|array $needle   String to search for.
454
-		 * @param array        $haystack Array in which to search.
455
-		 *
456
-		 * @return bool
457
-		 */
458
-		public static function recursive_array_search( $needle, array $haystack ): bool {
459
-			foreach ( $haystack as $value ) {
460
-				if ( $needle === $value || ( is_array( $value ) && self::recursive_array_search( $needle, $value ) !== false ) ) {
461
-					return true;
462
-				}
463
-			}
464
-
465
-			return false;
466
-		}
467
-
468
-		/**
469
-		 * Take a path and return it clean.
470
-		 *
471
-		 * @param string $path Path to clean.
472
-		 *
473
-		 * @return string
474
-		 * @deprecated Replaced with wp_normalize_path.
475
-		 * @since      3.1.7
476
-		 */
477
-		public static function cleanFilePath( string $path ): string { // phpcs:ignore WordPress.NamingConventions.ValidFunctionName
478
-			// phpcs:ignore Squiz.PHP.CommentedOutCode
479
-			_deprecated_function( __CLASS__ . '::' . __FUNCTION__, 'Redux 4.0', 'Redux_Functions_Ex::wp_normalize_path( $path )' );
480
-			return Redux_Functions_Ex::wp_normalize_path( $path );
481
-		}
482
-
483
-		/**
484
-		 * Get info for specified file.
485
-		 *
486
-		 * @param string $file File to check.
487
-		 *
488
-		 * @return array|bool
489
-		 */
490
-		public static function path_info( string $file ) {
491
-			$theme_info  = Redux_Functions_Ex::is_inside_theme( $file );
492
-			$plugin_info = Redux_Functions_Ex::is_inside_plugin( $file );
493
-
494
-			if ( false !== $theme_info ) {
495
-				return $theme_info;
496
-			} elseif ( false !== $plugin_info ) {
497
-				return $plugin_info;
498
-			}
499
-
500
-			return array();
501
-		}
502
-
503
-		/**
504
-		 * Compiles caller data for Redux.
505
-		 *
506
-		 * @param bool $simple Mode.
507
-		 *
508
-		 * @return array
509
-		 */
510
-		public static function process_redux_callers( bool $simple = false ): array {
511
-			$data = array();
512
-
513
-			foreach ( Redux_Core::$callers as $opt_name => $callers ) {
514
-				foreach ( $callers as $caller ) {
515
-					$plugin_info = self::is_inside_plugin( $caller );
516
-					$theme_info  = self::is_inside_theme( $caller );
517
-
518
-					if ( $theme_info ) {
519
-						if ( ! isset( $data['theme'][ $theme_info['slug'] ] ) ) {
520
-							$data['theme'][ $theme_info['slug'] ] = array();
521
-						}
522
-						if ( ! isset( $data['theme'][ $theme_info['slug'] ][ $opt_name ] ) ) {
523
-							$data['theme'][ $theme_info['slug'] ][ $opt_name ] = array();
524
-						}
525
-						if ( $simple ) {
526
-							$data['theme'][ $theme_info['slug'] ][ $opt_name ][] = $theme_info['basename'];
527
-						} else {
528
-							$data['theme'][ $theme_info['slug'] ][ $opt_name ][] = $theme_info;
529
-						}
530
-					} elseif ( $plugin_info ) {
531
-						if ( ! isset( $data['plugin'][ $plugin_info['slug'] ] ) ) {
532
-							$data['plugin'][ $plugin_info['slug'] ] = array();
533
-						}
534
-						if ( ! in_array( $opt_name, $data['plugin'][ $plugin_info['slug'] ], true ) ) {
535
-							if ( ! isset( $data['plugin'][ $plugin_info['slug'] ][ $opt_name ] ) ) {
536
-								$data['plugin'][ $plugin_info['slug'] ][ $opt_name ] = array();
537
-							}
538
-							if ( $simple ) {
539
-								$data['plugin'][ $plugin_info['slug'] ][ $opt_name ][] = $plugin_info['basename'];
540
-							} else {
541
-								$data['plugin'][ $plugin_info['slug'] ][ $opt_name ][] = $plugin_info;
542
-							}
543
-						}
544
-					}
545
-				}
546
-			}
547
-
548
-			return $data;
549
-		}
550
-
551
-		/**
552
-		 * Field Render Function.
553
-		 * Takes the color hex value and converts to a rgba.
554
-		 *
555
-		 * @param string $hex   Color value.
556
-		 * @param string $alpha Alpha value.
557
-		 *
558
-		 * @since ReduxFramework 3.0.4
559
-		 */
560
-		public static function hex2rgba( string $hex, string $alpha = '' ): string {
561
-			$hex = ltrim( $hex, '#' );
562
-			$hex = sanitize_hex_color_no_hash( $hex );
563
-
564
-			if ( '' === $hex ) {
565
-				return '';
566
-			}
567
-
568
-			if ( 3 === strlen( $hex ) ) {
569
-				$r = hexdec( substr( $hex, 0, 1 ) . substr( $hex, 0, 1 ) );
570
-				$g = hexdec( substr( $hex, 1, 1 ) . substr( $hex, 1, 1 ) );
571
-				$b = hexdec( substr( $hex, 2, 1 ) . substr( $hex, 2, 1 ) );
572
-			} else {
573
-				$r = hexdec( substr( $hex, 0, 2 ) );
574
-				$g = hexdec( substr( $hex, 2, 2 ) );
575
-				$b = hexdec( substr( $hex, 4, 2 ) );
576
-			}
577
-
578
-			$rgb = $r . ',' . $g . ',' . $b;
579
-
580
-			if ( '' === $alpha ) {
581
-				return $rgb;
582
-			} else {
583
-				$alpha = floatval( $alpha );
584
-
585
-				return 'rgba(' . $rgb . ',' . $alpha . ')';
586
-			}
587
-		}
588
-
589
-		/**
590
-		 * Deprecated. Returns string boolean value.
591
-		 *
592
-		 * @param mixed $variable String to convert to true boolean.
593
-		 *
594
-		 * @return mixed|array
595
-		 *
596
-		 * @deprecated No longer using camelCase naming convention.
597
-		 */
598
-		public static function makeBoolStr( $variable ) { // phpcs:ignore WordPress.NamingConventions.ValidFunctionName
599
-			_deprecated_function( __CLASS__ . '::' . __FUNCTION__, 'Redux 4.0.0', 'Redux_Instances::make_bool_str( $var )' );
600
-
601
-			return self::make_bool_str( $variable );
602
-		}
603
-
604
-		/**
605
-		 * Returns string boolean value.
606
-		 *
607
-		 * @param mixed $variable true|false to convert.
608
-		 *
609
-		 * @return mixed|array
610
-		 */
611
-		public static function make_bool_str( $variable ) {
612
-			if ( 'false' === $variable || empty( $variable ) ) {
613
-				return 'false';
614
-			} elseif ( true === $variable || 'true' === $variable || 1 === $variable || '1' === $variable ) {
615
-				return 'true';
616
-			} else {
617
-				return $variable;
618
-			}
619
-		}
620
-
621
-		/**
622
-		 * Compile a localized array.
623
-		 *
624
-		 * @param array $localize Array of localized strings.
625
-		 *
626
-		 * @return array
627
-		 */
628
-		public static function localize( array $localize ): array {
629
-
630
-			return $localize;
631
-		}
632
-
633
-		/**
634
-		 * Check mokama.
635
-		 *
636
-		 * @access public
637
-		 * @since 4.0.0
638
-		 * @return bool
639
-		 */
640
-		public static function mokama(): bool {
641
-			if ( defined( 'RDX_MOKAMA' ) ) {
642
-				return Redux_Functions_Ex::s();
643
-			}
644
-
645
-			return false;
646
-		}
647
-
648
-		/**
649
-		 * Retrieves template version.
650
-		 *
651
-		 * @param string $file Path to template file.
652
-		 *
653
-		 * @return string
654
-		 */
655
-		public static function get_template_version( string $file ): string {
656
-			$filesystem = Redux_Filesystem::get_instance();
657
-			// Avoid notices if file does not exist.
658
-			if ( ! file_exists( $file ) ) {
659
-				return '';
660
-			}
661
-
662
-			$data = get_file_data( $file, array( 'version' ), 'plugin' );
663
-
664
-			if ( ! empty( $data[0] ) ) {
665
-				return $data[0];
666
-			} else {
667
-				$file_data = $filesystem->get_contents( $file );
668
-
669
-				$file_data = str_replace( "\r", "\n", $file_data );
670
-				$version   = '1.0.0';
671
-
672
-				if ( preg_match( '/^[ \t\/*#@]*' . preg_quote( '@version', '/' ) . '(.*)$/mi', $file_data, $match ) && $match[1] ) {
673
-					$version = _cleanup_header_comment( $match[1] );
674
-				}
675
-
676
-				return $version;
677
-			}
678
-		}
679
-
680
-		/**
681
-		 * Create HTML attribute string.
682
-		 *
683
-		 * @param array $attributes Array of attributes.
684
-		 */
685
-		public static function html_attributes( array $attributes = array() ): string {
686
-			return join(
687
-				' ',
688
-				array_map(
689
-					function ( $key ) use ( $attributes ) {
690
-						if ( is_bool( $attributes[ $key ] ) ) {
691
-							return $attributes[ $key ] ? $key : '';
692
-						}
693
-
694
-						return $key . '="' . $attributes[ $key ] . '"';
695
-					},
696
-					array_keys( $attributes )
697
-				)
698
-			) . ' ';
699
-		}
700
-
701
-		/**
702
-		 * Normalize extensions dir.
703
-		 *
704
-		 * @param string $dir Path to extensions.
705
-		 *
706
-		 * @return string
707
-		 */
708
-		public static function get_extension_dir( string $dir ): string {
709
-			return trailingslashit( Redux_Functions_Ex::wp_normalize_path( dirname( $dir ) ) );
710
-		}
711
-
712
-		/**
713
-		 * Normalize extensions URL.
714
-		 *
715
-		 * @param string $dir Path to extensions.
716
-		 *
717
-		 * @return array|string|string[]
718
-		 */
719
-		public static function get_extension_url( string $dir ) {
720
-			$ext_dir = self::get_extension_dir( $dir );
721
-
722
-			return str_replace( Redux_Functions_Ex::wp_normalize_path( WP_CONTENT_DIR ), WP_CONTENT_URL, $ext_dir );
723
-		}
724
-
725
-		/**
726
-		 * Checks a nested capabilities array or string to determine if the current user meets the requirements.
727
-		 *
728
-		 * @param string|array $caps Permission string or array to check. See self::user_can() for details.
729
-		 *
730
-		 * @return bool Whether the user meets the requirements. False on invalid user.
731
-		 * @since 3.6.3.4
732
-		 */
733
-		public static function current_user_can( $caps ): bool { // phpcs:ignore Generic.CodeAnalysis.UnusedFunctionParameter.Found
734
-			$current_user = wp_get_current_user();
735
-
736
-			if ( empty( $current_user ) ) {
737
-				return false;
738
-			}
739
-
740
-			$name_arr = func_get_args();
741
-			$args     = array_merge( array( $current_user ), $name_arr );
742
-
743
-			return call_user_func_array( array( __CLASS__, 'user_can' ), $args );
744
-		}
745
-
746
-		/**
747
-		 * Checks a nested capabilities array or string to determine if the user meets the requirements.
748
-		 * You can pass in a simple string like 'edit_posts' or an array of conditions.
749
-		 * The capability 'relation' is reserved for controlling the relation mode (AND/OR), which defaults to AND.
750
-		 * Max depth of 30 levels.  False is returned for any conditions exceeding max depth.
751
-		 * If you want to check meta caps, you must also pass the object ID on which to check against.
752
-		 * If you get the error: PHP Notice: Undefined offset: 0 in /wp-includes/capabilities.php, you didn't
753
-		 * pass the required $object_id.
754
-		 *
755
-		 * @param int|WP_User  $user          User ID or WP_User object to check. Defaults to the current user.
756
-		 * @param string|array $capabilities  Capability string or array to check. The array lets you use multiple
757
-		 *                                    conditions to determine if a user has permission.
758
-		 *                                    Invalid conditions are skipped (conditions which aren't a string/array/bool/number(cast to bool)).
759
-		 *                                    Example array where the user needs to have either the 'edit_posts' capability OR doesn't have the
760
-		 *                                    'delete_pages' cap OR has the 'update_plugins' AND 'add_users' capabilities.
761
-		 *                                    array(
762
-		 *                                    'relation'     => 'OR',      // Optional, defaults to AND.
763
-		 *                                    'edit_posts',                // Equivalent to 'edit_posts' => true,
764
-		 *                                    'delete_pages' => false,     // Tests that the user DOESN'T have this capability
765
-		 *                                    array(                       // Nested conditions array (up to 30 nestings)
766
-		 *                                    'update_plugins',
767
-		 *                                    'add_users',
768
-		 *                                    ),
769
-		 *                                    ).
770
-		 * @param int|null     $object_id         (Optional) ID of the specific object to check against if capability is a "meta" cap.
771
-		 *                                    e.g. 'edit_post', 'edit_user', 'edit_page', etc.
772
-		 *
773
-		 * @return bool Whether the user meets the requirements.
774
-		 *              Will always return false for:
775
-		 *              - Invalid/missing user
776
-		 *              - If the $capabilities is not a string or array
777
-		 *              - Max nesting depth exceeded (for that level)
778
-		 * @since 3.6.3.4
779
-		 * @example
780
-		 *        user_can( 42, 'edit_pages' );                        // Checks if user ID 42 has the 'edit_pages' cap.
781
-		 *        user_can( 42, 'edit_page', 17433 );                  // Checks if user ID 42 has the 'edit_page' cap for post-ID 17433.
782
-		 *        user_can( 42, array( 'edit_pages', 'edit_posts' ) ); // Checks if user ID 42 has both the 'edit_pages' and 'edit_posts' caps.
783
-		 */
784
-		public static function user_can( $user, $capabilities, ?int $object_id = null ): bool {
785
-			static $depth = 0;
786
-
787
-			if ( $depth >= 30 ) {
788
-				return false;
789
-			}
790
-
791
-			if ( empty( $user ) ) {
792
-				return false;
793
-			}
794
-
795
-			if ( ! is_object( $user ) ) {
796
-				$user = get_userdata( $user );
797
-			}
798
-
799
-			if ( is_string( $capabilities ) ) {
800
-				// Simple string capability check.
801
-				$args = array( $user, $capabilities );
802
-
803
-				if ( null !== $object_id ) {
804
-					$args[] = $object_id;
805
-				}
806
-
807
-				return call_user_func_array( 'user_can', $args );
808
-			} elseif ( ! is_array( $capabilities ) ) {
809
-				// Only strings and arrays are allowed as valid capabilities.
810
-				return false;
811
-			}
812
-
813
-			// Capability array check.
814
-			$or = false;
815
-
816
-			foreach ( $capabilities as $key => $value ) {
817
-				if ( 'relation' === $key ) {
818
-					if ( 'OR' === $value ) {
819
-						$or = true;
820
-					}
821
-
822
-					continue;
823
-				}
824
-
825
-				/**
826
-				 * Rules can be in 4 different formats:
827
-				 * [
828
-				 *   [0]      => 'foobar',
829
-				 *   [1]      => array(...),
830
-				 *   'foobar' => false,
831
-				 *   'foobar' => array(...),
832
-				 * ]
833
-				 */
834
-				if ( is_numeric( $key ) ) {
835
-					// Numeric key.
836
-					if ( is_string( $value ) ) {
837
-						// Numeric key with a string value is the capability string to check
838
-						// [0] => 'foobar'.
839
-						$args = array( $user, $value );
840
-
841
-						if ( null !== $object_id ) {
842
-							$args[] = $object_id;
843
-						}
844
-
845
-						$expression_result = call_user_func_array( 'user_can', $args ) === true;
846
-					} elseif ( is_array( $value ) ) {
847
-						++$depth;
848
-
849
-						$expression_result = self::user_can( $user, $value, $object_id );
850
-
851
-						--$depth;
852
-					} else {
853
-						// Invalid types are skipped.
854
-						continue;
855
-					}
856
-				} else {
857
-					// Non-numeric key.
858
-					if ( is_scalar( $value ) ) {
859
-						$args = array( $user, $key );
860
-
861
-						if ( null !== $object_id ) {
862
-							$args[] = $object_id;
863
-						}
864
-
865
-						$expression_result = call_user_func_array( 'user_can', $args ) === (bool) $value;
866
-					} elseif ( is_array( $value ) ) {
867
-						++$depth;
868
-
869
-						$expression_result = self::user_can( $user, $value, $object_id );
870
-
871
-						--$depth;
872
-					} else {
873
-						// Invalid types are skipped.
874
-						continue;
875
-					}
876
-				}
877
-
878
-				// Check after every evaluation if we know enough to return a definitive answer.
879
-				if ( $or ) {
880
-					if ( $expression_result ) {
881
-						// If the relation is OR, return on the first true expression.
882
-						return true;
883
-					}
884
-				} elseif ( ! $expression_result ) {
885
-					// If the relation is AND, return on the first false expression.
886
-					return false;
887
-				}
888
-			}
889
-
890
-			// If we get this far on an OR, then it failed.
891
-			// If we get this far on an AND, then it succeeded.
892
-			return ! $or;
893
-		}
894
-
895
-		/**
896
-		 * Check if Google font update is needed.
897
-		 *
898
-		 * @return bool
899
-		 */
900
-		public static function google_fonts_update_needed(): bool {
901
-			$path = trailingslashit( Redux_Core::$upload_dir ) . 'google_fonts.json';
902
-			$now  = time();
903
-			$secs = 60 * 60 * 24 * 7;
904
-
905
-			if ( file_exists( $path ) ) {
906
-				if ( ( $now - filemtime( $path ) ) < $secs ) {
907
-					return false;
908
-				}
909
-			}
910
-
911
-			return true;
912
-		}
913
-
914
-		/**
915
-		 * Retrieve an updated Google font array.
916
-		 *
917
-		 * @param bool $download Flag to download to file.
918
-		 *
919
-		 * @return array|WP_Error
920
-		 */
921
-		public static function google_fonts_array( bool $download = false ) {
922
-			if ( ! empty( Redux_Core::$updated_google_fonts ) && ! self::google_fonts_update_needed() ) {
923
-				return Redux_Core::$updated_google_fonts;
924
-			}
925
-
926
-			$filesystem = Redux_Filesystem::get_instance();
927
-
928
-			$path = trailingslashit( Redux_Core::$upload_dir ) . 'google_fonts.json';
929
-
930
-			if ( ! file_exists( $path ) || ( file_exists( $path ) && $download && self::google_fonts_update_needed() ) ) {
931
-				if ( $download ) {
932
-					// phpcs:ignore WordPress.NamingConventions.ValidHookName
933
-					$url = apply_filters( 'redux/typography/google_fonts/url', 'https://raw.githubusercontent.com/reduxframework/google-fonts/master/google_fonts.json' );
934
-
935
-					$request = wp_remote_get(
936
-						$url,
937
-						array(
938
-							'timeout' => 20,
939
-						)
940
-					);
941
-
942
-					if ( ! is_wp_error( $request ) ) {
943
-						$body = wp_remote_retrieve_body( $request );
944
-						if ( ! empty( $body ) ) {
945
-							$filesystem->put_contents( $path, $body );
946
-							Redux_Core::$updated_google_fonts = json_decode( $body, true );
947
-						}
948
-					} else {
949
-						return $request;
950
-					}
951
-				}
952
-			} elseif ( file_exists( $path ) ) {
953
-				Redux_Core::$updated_google_fonts = json_decode( $filesystem->get_contents( $path ), true );
954
-				if ( empty( Redux_Core::$updated_google_fonts ) ) {
955
-					$filesystem->unlink( $path );
956
-				}
957
-			}
958
-
959
-			return Redux_Core::$updated_google_fonts;
960
-		}
961
-
962
-		/**
963
-		 * Deprecated. Gets all Redux instances
964
-		 *
965
-		 * @return array
966
-		 * @deprecated No longer using camelCase naming convention and moved to a different class.
967
-		 */
968
-		public static function getReduxInstances(): array { // phpcs:ignore WordPress.NamingConventions.ValidFunctionName
969
-			_deprecated_function( __CLASS__ . '::' . __FUNCTION__, 'Redux 4.0.0', 'Redux_Instances::get_all_instances()' );
970
-
971
-			return Redux_Instances::get_all_instances();
972
-		}
973
-
974
-		/**
975
-		 * Is Inside Plugin
976
-		 *
977
-		 * @param string $file File name.
978
-		 *
979
-		 * @return array|bool
980
-		 */
981
-		public static function is_inside_plugin( string $file ) {
982
-
983
-			// phpcs:ignore Squiz.PHP.CommentedOutCode
984
-			// if ( substr( strtoupper( $file ), 0, 2 ) === 'C:' ) {
985
-			// $file = ltrim( $file, 'C:' );
986
-			// $file = ltrim( $file, 'c:' );
987
-			// } .
988
-			//
989
-			$plugin_basename = plugin_basename( $file );
990
-
991
-			if ( Redux_Functions_Ex::wp_normalize_path( $file ) !== '/' . $plugin_basename ) {
992
-				$slug = explode( '/', $plugin_basename );
993
-				$slug = $slug[0];
994
-
995
-				return array(
996
-					'slug'      => $slug,
997
-					'basename'  => $plugin_basename,
998
-					'path'      => Redux_Functions_Ex::wp_normalize_path( $file ),
999
-					'url'       => plugins_url( $plugin_basename ),
1000
-					'real_path' => Redux_Functions_Ex::wp_normalize_path( dirname( realpath( $file ) ) ),
1001
-				);
1002
-			}
1003
-
1004
-			return false;
1005
-		}
1006
-
1007
-		/**
1008
-		 * Is inside theme.
1009
-		 *
1010
-		 * @param string $file File name.
1011
-		 *
1012
-		 * @return array|bool
1013
-		 */
1014
-		public static function is_inside_theme( string $file = '' ) {
1015
-			$theme_paths = array(
1016
-				Redux_Functions_Ex::wp_normalize_path( get_template_directory() )   => get_template_directory_uri(),
1017
-				Redux_Functions_Ex::wp_normalize_path( get_stylesheet_directory() ) => get_stylesheet_directory_uri(),
1018
-			);
1019
-
1020
-			$theme_paths = array_unique( $theme_paths );
1021
-
1022
-			$file_path = Redux_Functions_Ex::wp_normalize_path( $file );
1023
-			$filename  = explode( '/', $file_path );
1024
-			$filename  = end( $filename );
1025
-			foreach ( $theme_paths as $theme_path => $url ) {
1026
-
1027
-				$real_path = Redux_Functions_Ex::wp_normalize_path( realpath( $theme_path ) );
1028
-
1029
-				if ( strpos( $file_path, trailingslashit( $real_path ) ) !== false ) {
1030
-					$slug = explode( '/', Redux_Functions_Ex::wp_normalize_path( $theme_path ) );
1031
-					if ( empty( $slug ) ) {
1032
-						continue;
1033
-					}
1034
-					$slug          = end( $slug );
1035
-					$relative_path = explode( $slug, dirname( $file_path ) );
1036
-
1037
-					if ( 1 === count( $relative_path ) ) {
1038
-						$relative_path = $file_path;
1039
-					} else {
1040
-						$relative_path = $relative_path[1];
1041
-					}
1042
-					$relative_path = ltrim( $relative_path, '/' );
1043
-
1044
-					$data = array(
1045
-						'slug'      => $slug,
1046
-						'path'      => trailingslashit( trailingslashit( $theme_path ) . $relative_path ) . $filename,
1047
-						'real_path' => trailingslashit( trailingslashit( $real_path ) . $relative_path ) . $filename,
1048
-						'url'       => trailingslashit( trailingslashit( $url ) . $relative_path ) . $filename,
1049
-					);
1050
-
1051
-					$basename         = explode( $data['slug'], $data['path'] );
1052
-					$basename         = end( $basename );
1053
-					$basename         = ltrim( $basename, '/' );
1054
-					$data['basename'] = trailingslashit( $data['slug'] ) . $basename;
1055
-
1056
-					if ( is_child_theme() ) {
1057
-						$parent              = get_template_directory();
1058
-						$data['parent_slug'] = explode( '/', $parent );
1059
-						$data['parent_slug'] = end( $data['parent_slug'] );
1060
-						if ( $data['slug'] === $data['parent_slug'] ) {
1061
-							unset( $data['parent_slug'] );
1062
-						}
1063
-					}
1064
-
1065
-					return $data;
1066
-				}
1067
-			}
1068
-
1069
-			return false;
1070
-		}
1071
-
1072
-
1073
-		/**
1074
-		 * Get plugin options.
1075
-		 *
1076
-		 * @return array|mixed|void
1077
-		 */
1078
-		public static function get_plugin_options() {
1079
-			$defaults = array(
1080
-				'demo' => false,
1081
-			);
1082
-			$options  = array();
1083
-
1084
-			// If multisite is enabled.
1085
-			if ( is_multisite() ) {
1086
-
1087
-				// Get network activated plugins.
1088
-				$plugins = get_site_option( 'active_sitewide_plugins' );
1089
-
1090
-				foreach ( $plugins as $file => $plugin ) {
1091
-					if ( strpos( $file, 'redux-framework.php' ) !== false ) {
1092
-						$options = get_site_option( 'ReduxFrameworkPlugin', $defaults );
1093
-					}
1094
-				}
1095
-			}
1096
-
1097
-			// If options aren't set, grab them now!
1098
-			if ( empty( $options ) ) {
1099
-				$options = get_option( 'ReduxFrameworkPlugin', $defaults );
1100
-			}
1101
-
1102
-			return $options;
1103
-		}
1104
-
1105
-		/**
1106
-		 * Sanitize array keys and values.
1107
-		 *
1108
-		 * @param array $arr Array to sanitize.
1109
-		 */
1110
-		public static function sanitize_array( array $arr ): array {
1111
-			return self::array_map_r( 'wp_kses_post', $arr );
1112
-		}
1113
-
1114
-		/**
1115
-		 * Recursive array map.
1116
-		 *
1117
-		 * @param string $func function to run.
1118
-		 * @param array  $arr  Array to clean.
1119
-		 *
1120
-		 * @return array
1121
-		 */
1122
-		private static function array_map_r( string $func, array $arr ): array {
1123
-			$new_arr = array();
1124
-
1125
-			foreach ( $arr as $key => $value ) {
1126
-				$new_arr[ $key ] = ( is_array( $value ) ? self::array_map_r( $func, $value ) : ( is_array( $func ) ? call_user_func_array( $func, $value ) : $func( $value ) ) );
1127
-			}
1128
-
1129
-			return $new_arr;
1130
-		}
1131
-
1132
-		/**
1133
-		 * Material design colors.
1134
-		 *
1135
-		 * @param string $context Mode to use.
1136
-		 *
1137
-		 * @return array
1138
-		 */
1139
-		public static function get_material_design_colors( string $context = 'primary' ): array {
1140
-			$colors = array(
1141
-				'primary'     => array( '#FFFFFF', '#000000', '#F44336', '#E91E63', '#9C27B0', '#673AB7', '#3F51B5', '#2196F3', '#03A9F4', '#00BCD4', '#009688', '#4CAF50', '#8BC34A', '#CDDC39', '#FFEB3B', '#FFC107', '#FF9800', '#FF5722', '#795548', '#9E9E9E', '#607D8B' ),
1142
-				'red'         => array( '#FFEBEE', '#FFCDD2', '#EF9A9A', '#E57373', '#EF5350', '#F44336', '#E53935', '#D32F2F', '#C62828', '#B71C1C', '#FF8A80', '#FF5252', '#FF1744', '#D50000' ),
1143
-				'pink'        => array( '#FCE4EC', '#F8BBD0', '#F48FB1', '#F06292', '#EC407A', '#E91E63', '#D81B60', '#C2185B', '#AD1457', '#880E4F', '#FF80AB', '#FF4081', '#F50057', '#C51162' ),
1144
-				'purple'      => array( '#F3E5F5', '#E1BEE7', '#CE93D8', '#BA68C8', '#AB47BC', '#9C27B0', '#8E24AA', '#7B1FA2', '#6A1B9A', '#4A148C', '#EA80FC', '#E040FB', '#D500F9', '#AA00FF' ),
1145
-				'deep-purple' => array( '#EDE7F6', '#D1C4E9', '#B39DDB', '#9575CD', '#7E57C2', '#673AB7', '#5E35B1', '#512DA8', '#4527A0', '#311B92', '#B388FF', '#7C4DFF', '#651FFF', '#6200EA' ),
1146
-				'indigo'      => array( '#E8EAF6', '#C5CAE9', '#9FA8DA', '#7986CB', '#5C6BC0', '#3F51B5', '#3949AB', '#303F9F', '#283593', '#1A237E', '#8C9EFF', '#536DFE', '#3D5AFE', '#304FFE' ),
1147
-				'blue'        => array( '#E3F2FD', '#BBDEFB', '#90CAF9', '#64B5F6', '#42A5F5', '#2196F3', '#1E88E5', '#1976D2', '#1565C0', '#0D47A1', '#82B1FF', '#448AFF', '#2979FF', '#2962FF' ),
1148
-				'light-blue'  => array( '#E1F5FE', '#B3E5FC', '#81D4fA', '#4fC3F7', '#29B6FC', '#03A9F4', '#039BE5', '#0288D1', '#0277BD', '#01579B', '#80D8FF', '#40C4FF', '#00B0FF', '#0091EA' ),
1149
-				'cyan'        => array( '#E0F7FA', '#B2EBF2', '#80DEEA', '#4DD0E1', '#26C6DA', '#00BCD4', '#00ACC1', '#0097A7', '#00838F', '#006064', '#84FFFF', '#18FFFF', '#00E5FF', '#00B8D4' ),
1150
-				'teal'        => array( '#E0F2F1', '#B2DFDB', '#80CBC4', '#4DB6AC', '#26A69A', '#009688', '#00897B', '#00796B', '#00695C', '#004D40', '#A7FFEB', '#64FFDA', '#1DE9B6', '#00BFA5' ),
1151
-				'green'       => array( '#E8F5E9', '#C8E6C9', '#A5D6A7', '#81C784', '#66BB6A', '#4CAF50', '#43A047', '#388E3C', '#2E7D32', '#1B5E20', '#B9F6CA', '#69F0AE', '#00E676', '#00C853' ),
1152
-				'light-green' => array( '#F1F8E9', '#DCEDC8', '#C5E1A5', '#AED581', '#9CCC65', '#8BC34A', '#7CB342', '#689F38', '#558B2F', '#33691E', '#CCFF90', '#B2FF59', '#76FF03', '#64DD17' ),
1153
-				'lime'        => array( '#F9FBE7', '#F0F4C3', '#E6EE9C', '#DCE775', '#D4E157', '#CDDC39', '#C0CA33', '#A4B42B', '#9E9D24', '#827717', '#F4FF81', '#EEFF41', '#C6FF00', '#AEEA00' ),
1154
-				'yellow'      => array( '#FFFDE7', '#FFF9C4', '#FFF590', '#FFF176', '#FFEE58', '#FFEB3B', '#FDD835', '#FBC02D', '#F9A825', '#F57F17', '#FFFF82', '#FFFF00', '#FFEA00', '#FFD600' ),
1155
-				'amber'       => array( '#FFF8E1', '#FFECB3', '#FFE082', '#FFD54F', '#FFCA28', '#FFC107', '#FFB300', '#FFA000', '#FF8F00', '#FF6F00', '#FFE57F', '#FFD740', '#FFC400', '#FFAB00' ),
1156
-				'orange'      => array( '#FFF3E0', '#FFE0B2', '#FFCC80', '#FFB74D', '#FFA726', '#FF9800', '#FB8C00', '#F57C00', '#EF6C00', '#E65100', '#FFD180', '#FFAB40', '#FF9100', '#FF6D00' ),
1157
-				'deep-orange' => array( '#FBE9A7', '#FFCCBC', '#FFAB91', '#FF8A65', '#FF7043', '#FF5722', '#F4511E', '#E64A19', '#D84315', '#BF360C', '#FF9E80', '#FF6E40', '#FF3D00', '#DD2600' ),
1158
-				'brown'       => array( '#EFEBE9', '#D7CCC8', '#BCAAA4', '#A1887F', '#8D6E63', '#795548', '#6D4C41', '#5D4037', '#4E342E', '#3E2723' ),
1159
-				'gray'        => array( '#FAFAFA', '#F5F5F5', '#EEEEEE', '#E0E0E0', '#BDBDBD', '#9E9E9E', '#757575', '#616161', '#424242', '#212121', '#000000', '#ffffff' ),
1160
-				'blue-gray'   => array( '#ECEFF1', '#CFD8DC', '#B0BBC5', '#90A4AE', '#78909C', '#607D8B', '#546E7A', '#455A64', '#37474F', '#263238' ),
1161
-			);
1162
-
1163
-			$mui_arr = array(
1164
-				'50',
1165
-				'100',
1166
-				'200',
1167
-				'300',
1168
-				'400',
1169
-				'500',
1170
-				'600',
1171
-				'700',
1172
-				'800',
1173
-				'900',
1174
-				'A100',
1175
-				'A200',
1176
-				'A400',
1177
-				'A700',
1178
-			);
1179
-
1180
-			if ( in_array( $context, $mui_arr, true ) ) {
1181
-				$key = absint( $context ) / 100;
1182
-
1183
-				if ( 'A100' === $context ) {
1184
-					$key = 10;
1185
-					unset( $colors['grey'] );
1186
-				} elseif ( 'A200' === $context ) {
1187
-					$key = 11;
1188
-					unset( $colors['grey'] );
1189
-				} elseif ( 'A400' === $context ) {
1190
-					$key = 12;
1191
-					unset( $colors['grey'] );
1192
-				} elseif ( 'A700' === $context ) {
1193
-					$key = 13;
1194
-					unset( $colors['grey'] );
1195
-				}
1196
-
1197
-				unset( $colors['primary'] );
1198
-
1199
-				$position_colors = array();
1200
-				foreach ( $colors as $color_family ) {
1201
-					if ( isset( $color_family[ $key ] ) ) {
1202
-						$position_colors[] = $color_family[ $key ];
1203
-					}
1204
-				}
1205
-
1206
-				return $position_colors;
1207
-			} elseif ( 'all' === $context ) {
1208
-				unset( $colors['primary'] );
1209
-
1210
-				$all_colors = array();
1211
-				foreach ( $colors as $color_family ) {
1212
-					foreach ( $color_family as $color ) {
1213
-						$all_colors[] = $color;
1214
-					}
1215
-				}
1216
-
1217
-				return $all_colors;
1218
-			} elseif ( 'primary' === $context ) {
1219
-				return $colors['primary'];
1220
-			} else {
1221
-				if ( isset( $colors[ $context ] ) ) {
1222
-					return $colors[ $context ];
1223
-				}
1224
-
1225
-				return $colors['primary'];
1226
-			}
1227
-		}
1228
-	}
18
+    /**
19
+     * Redux Helpers Class
20
+     * A Class of useful functions that can/should be shared among all Redux files.
21
+     *
22
+     * @since       3.0.0
23
+     */
24
+    class Redux_Helpers {
25
+
26
+        /**
27
+         * Reusable supported unit array.
28
+         *
29
+         * @var array
30
+         */
31
+        public static $array_units = array( '', '%', 'in', 'cm', 'mm', 'em', 'rem', 'ex', 'pt', 'pc', 'px', 'vh', 'vw', 'vmin', 'vmax', 'ch' );
32
+
33
+        /**
34
+         * Is customizer loaded.
35
+         *
36
+         * @return bool
37
+         */
38
+        public static function is_customizer_loaded(): bool {
39
+            global $wp_customize;
40
+
41
+            if ( isset( $wp_customize ) ) {
42
+                return true;
43
+            }
44
+
45
+            return false;
46
+        }
47
+
48
+        /**
49
+         * Retrieve the section array from field ID.
50
+         *
51
+         * @param string $opt_name Panel opt_name.
52
+         * @param string $field_id Field ID.
53
+         */
54
+        public static function section_from_field_id( string $opt_name = '', string $field_id = '' ) {
55
+            if ( '' !== $opt_name ) {
56
+                $redux = Redux::instance( $opt_name );
57
+
58
+                if ( is_object( $redux ) ) {
59
+                    $sections = $redux->sections;
60
+
61
+                    if ( is_array( $sections ) && ! empty( $sections ) ) {
62
+                        foreach ( $sections as $section ) {
63
+                            if ( ! empty( $section['fields'] ) ) {
64
+                                foreach ( $section['fields'] as $field ) {
65
+                                    if ( is_array( $field ) && ! empty( $field ) ) {
66
+                                        if ( isset( $field['id'] ) && $field['id'] === $field_id ) {
67
+                                            return $section;
68
+                                        }
69
+                                    }
70
+                                }
71
+                            }
72
+                        }
73
+                    }
74
+                }
75
+            }
76
+
77
+            return null;
78
+        }
79
+
80
+        /**
81
+         * Verify integer value.
82
+         *
83
+         * @param mixed $val Value to test.
84
+         *
85
+         * @return bool|false|int
86
+         */
87
+        public static function is_integer( $val ) {
88
+            if ( ! is_scalar( $val ) || is_bool( $val ) ) {
89
+                return false;
90
+            }
91
+
92
+            return is_float( $val ) ? false : preg_match( '~^([+\-]?[0-9]+)$~', $val );
93
+        }
94
+
95
+        /**
96
+         * Deprecated. Gets panel tab number from the specified field.
97
+         *
98
+         * @param object       $redux ReduxFramework object.
99
+         * @param array|string $field  Field array.
100
+         *
101
+         * @return int|string
102
+         * @deprecated No longer using camelCase naming convention.
103
+         */
104
+        public static function tabFromField( $redux, $field ) { // phpcs:ignore WordPress.NamingConventions.ValidFunctionName
105
+            _deprecated_function( __CLASS__ . '::' . __FUNCTION__, 'Redux 4.0', 'Redux_Helpers::tab_from_field( $parent, $field )' );
106
+
107
+            return self::tab_from_field( $redux, $field );
108
+        }
109
+
110
+        /**
111
+         * Gets panel tab number from the specified field.
112
+         *
113
+         * @param object       $redux ReduxFramework object.
114
+         * @param array|string $field  Field array.
115
+         *
116
+         * @return int|string
117
+         */
118
+        public static function tab_from_field( $redux, $field ) {
119
+            foreach ( $redux->sections as $k => $section ) {
120
+                if ( ! isset( $section['title'] ) ) {
121
+                    continue;
122
+                }
123
+
124
+                if ( ! empty( $section['fields'] ) ) {
125
+                    if ( self::recursive_array_search( $field, $section['fields'] ) ) {
126
+                        return $k;
127
+                    }
128
+                }
129
+            }
130
+
131
+            return null;
132
+        }
133
+
134
+        /**
135
+         * Deprecated. Verifies if a specified field type is in use.
136
+         *
137
+         * @param array $fields Field arrays.
138
+         * @param array $field  Field array.
139
+         *
140
+         * @return bool
141
+         * @deprecated No longer using camelCase naming convention.
142
+         */
143
+        public static function isFieldInUseByType( array $fields, array $field = array() ): bool { // phpcs:ignore WordPress.NamingConventions.ValidFunctionName
144
+            // phpcs:ignore Squiz.PHP.CommentedOutCode
145
+            _deprecated_function( __CLASS__ . '::' . __FUNCTION__, 'Redux 4.0', 'Redux_Helpers::is_field_in_use_by_type( $parent, $field )' );
146
+            return self::is_field_in_use_by_type( $fields, $field );
147
+        }
148
+
149
+        /**
150
+         * Verifies if a specified field type is in use.
151
+         *
152
+         * @param array $fields Field arrays.
153
+         * @param array $field  Field arrays to check.
154
+         *
155
+         * @return bool
156
+         */
157
+        public static function is_field_in_use_by_type( array $fields, array $field = array() ): bool {
158
+            foreach ( $field as $name ) {
159
+                if ( array_key_exists( $name, $fields ) ) {
160
+                    return true;
161
+                }
162
+            }
163
+
164
+            return false;
165
+        }
166
+
167
+        /**
168
+         * Deprecated Verifies if field is in use.
169
+         *
170
+         * @param object $redux ReduxFramework object.
171
+         * @param string $field  Field type.
172
+         *
173
+         * @return bool
174
+         * @deprecated No longer using camelCase function names.
175
+         */
176
+        public static function isFieldInUse( $redux, string $field ): bool { // phpcs:ignore WordPress.NamingConventions.ValidFunctionName
177
+            _deprecated_function( __CLASS__ . '::' . __FUNCTION__, 'Redux 4.0', 'Redux_Helpers::is_field_in_use( $parent, $field )' );
178
+
179
+            return self::is_field_in_use( $redux, $field );
180
+        }
181
+
182
+        /**
183
+         * Verifies if field is in use.
184
+         *
185
+         * @param object $redux ReduxFramework object.
186
+         * @param string $field  Field type.
187
+         *
188
+         * @return bool
189
+         */
190
+        public static function is_field_in_use( $redux, string $field ): bool {
191
+            if ( empty( $redux->sections ) ) {
192
+                return false;
193
+            }
194
+
195
+            foreach ( $redux->sections as $section ) {
196
+                if ( ! isset( $section['title'] ) ) {
197
+                    continue;
198
+                }
199
+
200
+                if ( ! empty( $section['fields'] ) ) {
201
+                    if ( self::recursive_array_search( $field, $section['fields'] ) ) {
202
+                        return true;
203
+                    }
204
+                }
205
+            }
206
+
207
+            return false;
208
+        }
209
+
210
+        /**
211
+         * Returns major version from version number.
212
+         *
213
+         * @param string $v Version number.
214
+         *
215
+         * @return string
216
+         */
217
+        public static function major_version( string $v ): string {
218
+            $version = explode( '.', $v );
219
+            if ( count( $version ) > 1 ) {
220
+                return $version[0] . '.' . $version[1];
221
+            } else {
222
+                return $v;
223
+            }
224
+        }
225
+
226
+
227
+        /**
228
+         * Deprecated. Checks for localhost environment.
229
+         *
230
+         * @return bool
231
+         * @deprecated No longer using camelCase naming convention.
232
+         * @since      4.0
233
+         */
234
+        public static function isLocalHost(): bool { // phpcs:ignore WordPress.NamingConventions.ValidFunctionName
235
+            _deprecated_function( __CLASS__ . '::' . __FUNCTION__, 'Redux 4.0', 'Redux_Helpers::is_local_host()' );
236
+
237
+            return self::is_local_host();
238
+        }
239
+
240
+        /**
241
+         * Checks for localhost environment.
242
+         *
243
+         * @return bool
244
+         */
245
+        public static function is_local_host(): bool {
246
+            $is_local = false;
247
+
248
+            $domains_to_check = array_unique(
249
+                array(
250
+                    'siteurl' => wp_parse_url( get_site_url(), PHP_URL_HOST ),
251
+                    'homeurl' => wp_parse_url( get_home_url(), PHP_URL_HOST ),
252
+                )
253
+            );
254
+
255
+            $forbidden_domains = array(
256
+                'wordpress.com',
257
+                'localhost',
258
+                'localhost.localdomain',
259
+                '127.0.0.1',
260
+                '::1',
261
+                'local.wordpress.test',         // VVV pattern.
262
+                'local.wordpress-trunk.test',   // VVV pattern.
263
+                'src.wordpress-develop.test',   // VVV pattern.
264
+                'build.wordpress-develop.test', // VVV pattern.
265
+            );
266
+
267
+            foreach ( $domains_to_check as $domain ) {
268
+                // If it's empty, just fail out.
269
+                if ( ! $domain ) {
270
+                    $is_local = true;
271
+                    break;
272
+                }
273
+
274
+                // None of the explicit localhosts.
275
+                if ( in_array( $domain, $forbidden_domains, true ) ) {
276
+                    $is_local = true;
277
+                    break;
278
+                }
279
+
280
+                // No .test or .local domains.
281
+                if ( preg_match( '#\.(test|local)$#i', $domain ) ) {
282
+                    $is_local = true;
283
+                    break;
284
+                }
285
+            }
286
+
287
+            return $is_local;
288
+        }
289
+
290
+        /**
291
+         * Deprecated. Checks if WP_DEBUG is enabled.
292
+         *
293
+         * @return bool::is_wp_debug()
294
+         * @deprecated No longer using camelCase naming convention.
295
+         * @since      4.0
296
+         */
297
+        public static function isWpDebug(): bool { // phpcs:ignore WordPress.NamingConventions.ValidFunctionName
298
+            _deprecated_function( __CLASS__ . '::' . __FUNCTION__, 'Redux 4.0', 'Redux_Functions_Ex::is_wp_debug()' );
299
+
300
+            return self::is_wp_debug();
301
+        }
302
+
303
+        /**
304
+         * Checks if WP_DEBUG is enabled.
305
+         *
306
+         * @return bool
307
+         */
308
+        public static function is_wp_debug(): bool {
309
+            return ( defined( 'WP_DEBUG' ) && true === WP_DEBUG );
310
+        }
311
+
312
+        /**
313
+         * Deprecated. Determines if theme is parent.
314
+         *
315
+         * @param string $file Path to file.
316
+         *
317
+         * @return bool
318
+         * @deprecated No longer using camelCase naming convention.
319
+         */
320
+        public static function isParentTheme( string $file ): bool { // phpcs:ignore WordPress.NamingConventions.ValidFunctionName
321
+            _deprecated_function( __CLASS__ . '::' . __FUNCTION__, 'Redux 4.0.0', 'Redux_Instances::is_parent_theme( $file )' );
322
+
323
+            return self::is_parent_theme( $file );
324
+        }
325
+
326
+        /**
327
+         * Determines if theme is parent.
328
+         *
329
+         * @param string $file Path to theme dir.
330
+         *
331
+         * @return bool
332
+         */
333
+        public static function is_parent_theme( string $file ): bool {
334
+            $file = Redux_Functions_Ex::wp_normalize_path( $file );
335
+            $dir  = Redux_Functions_Ex::wp_normalize_path( get_template_directory() );
336
+
337
+            $file = str_replace( '//', '/', $file );
338
+            $dir  = str_replace( '//', '/', $dir );
339
+
340
+            if ( strpos( $file, $dir ) !== false ) {
341
+                return true;
342
+            }
343
+
344
+            return false;
345
+        }
346
+
347
+        /**
348
+         * Deprecated. Moved to another class.
349
+         *
350
+         * @param string $file Path to file.
351
+         *
352
+         * @return string
353
+         * @deprecated Moved to another class.
354
+         */
355
+        public static function wp_normalize_path( string $file ): string { // phpcs:ignore WordPress.NamingConventions.ValidFunctionName
356
+            _deprecated_function( __CLASS__ . '::' . __FUNCTION__, 'Redux 4.0.0', 'Redux_Functions_Ex::wp_normalize_path( $file )' );
357
+
358
+            return Redux_Functions_Ex::wp_normalize_path( $file );
359
+        }
360
+
361
+        /**
362
+         * Deprecated. Determines if the theme is child.
363
+         *
364
+         * @param string $file Path to file.
365
+         *
366
+         * @return bool
367
+         * @deprecated No longer using camelCase naming convention.
368
+         */
369
+        public static function isChildTheme( string $file ): bool { // phpcs:ignore WordPress.NamingConventions.ValidFunctionName
370
+            _deprecated_function( __CLASS__ . '::' . __FUNCTION__, 'Redux 4.0.0', 'Redux_Instances::is_child_theme( $file )' );
371
+
372
+            return self::is_child_theme( $file );
373
+        }
374
+
375
+        /**
376
+         * Determines if the theme is child.
377
+         *
378
+         * @param string $file Path to theme dir.
379
+         *
380
+         * @return bool
381
+         */
382
+        public static function is_child_theme( string $file ): bool {
383
+            $file = Redux_Functions_Ex::wp_normalize_path( $file );
384
+            $dir  = Redux_Functions_Ex::wp_normalize_path( get_stylesheet_directory() );
385
+
386
+            $file = str_replace( '//', '/', $file );
387
+            $dir  = str_replace( '//', '/', $dir );
388
+
389
+            if ( strpos( $file, $dir ) !== false ) {
390
+                return true;
391
+            }
392
+
393
+            return false;
394
+        }
395
+
396
+        /**
397
+         * Deprecated. Determines if file is a theme.
398
+         *
399
+         * @param string $file Path to file.
400
+         *
401
+         * @return bool
402
+         * @deprecated No longer using camelCase naming convention.
403
+         */
404
+        public static function isTheme( string $file ): bool { // phpcs:ignore WordPress.NamingConventions.ValidFunctionName
405
+            // phpcs:ignore Squiz.PHP.CommentedOutCode
406
+            // _deprecated_function( __CLASS__ . '::' . __FUNCTION__, 'Redux 4.0.0', 'Redux_Instances::is_theme( $file )' );
407
+
408
+            return self::is_theme( $file );
409
+        }
410
+
411
+        /**
412
+         * Determines if file is a theme.
413
+         *
414
+         * @param string $file Path to fle to test.
415
+         *
416
+         * @return bool
417
+         */
418
+        public static function is_theme( string $file ): bool {
419
+            if ( true === self::is_child_theme( $file ) || true === self::is_parent_theme( $file ) ) {
420
+                return true;
421
+            }
422
+
423
+            return false;
424
+        }
425
+
426
+        /**
427
+         * Determines deep array status.
428
+         *
429
+         * @param array|string $needle   array to test.
430
+         * @param array        $haystack Array to search.
431
+         *
432
+         * @return bool
433
+         */
434
+        public static function array_in_array( $needle, array $haystack ): bool {
435
+            // Make sure $needle is an array for foreach.
436
+            if ( ! is_array( $needle ) ) {
437
+                $needle = array( $needle );
438
+            }
439
+            // For each value in $needle, return TRUE if in $haystack.
440
+            foreach ( $needle as $pin ) {
441
+                if ( in_array( $pin, $haystack, true ) ) {
442
+                    return true;
443
+                }
444
+            }
445
+
446
+            // Return FALSE if none of the values from $needle are found in $haystack.
447
+            return false;
448
+        }
449
+
450
+        /**
451
+         * Enum through an entire deep array.
452
+         *
453
+         * @param string|array $needle   String to search for.
454
+         * @param array        $haystack Array in which to search.
455
+         *
456
+         * @return bool
457
+         */
458
+        public static function recursive_array_search( $needle, array $haystack ): bool {
459
+            foreach ( $haystack as $value ) {
460
+                if ( $needle === $value || ( is_array( $value ) && self::recursive_array_search( $needle, $value ) !== false ) ) {
461
+                    return true;
462
+                }
463
+            }
464
+
465
+            return false;
466
+        }
467
+
468
+        /**
469
+         * Take a path and return it clean.
470
+         *
471
+         * @param string $path Path to clean.
472
+         *
473
+         * @return string
474
+         * @deprecated Replaced with wp_normalize_path.
475
+         * @since      3.1.7
476
+         */
477
+        public static function cleanFilePath( string $path ): string { // phpcs:ignore WordPress.NamingConventions.ValidFunctionName
478
+            // phpcs:ignore Squiz.PHP.CommentedOutCode
479
+            _deprecated_function( __CLASS__ . '::' . __FUNCTION__, 'Redux 4.0', 'Redux_Functions_Ex::wp_normalize_path( $path )' );
480
+            return Redux_Functions_Ex::wp_normalize_path( $path );
481
+        }
482
+
483
+        /**
484
+         * Get info for specified file.
485
+         *
486
+         * @param string $file File to check.
487
+         *
488
+         * @return array|bool
489
+         */
490
+        public static function path_info( string $file ) {
491
+            $theme_info  = Redux_Functions_Ex::is_inside_theme( $file );
492
+            $plugin_info = Redux_Functions_Ex::is_inside_plugin( $file );
493
+
494
+            if ( false !== $theme_info ) {
495
+                return $theme_info;
496
+            } elseif ( false !== $plugin_info ) {
497
+                return $plugin_info;
498
+            }
499
+
500
+            return array();
501
+        }
502
+
503
+        /**
504
+         * Compiles caller data for Redux.
505
+         *
506
+         * @param bool $simple Mode.
507
+         *
508
+         * @return array
509
+         */
510
+        public static function process_redux_callers( bool $simple = false ): array {
511
+            $data = array();
512
+
513
+            foreach ( Redux_Core::$callers as $opt_name => $callers ) {
514
+                foreach ( $callers as $caller ) {
515
+                    $plugin_info = self::is_inside_plugin( $caller );
516
+                    $theme_info  = self::is_inside_theme( $caller );
517
+
518
+                    if ( $theme_info ) {
519
+                        if ( ! isset( $data['theme'][ $theme_info['slug'] ] ) ) {
520
+                            $data['theme'][ $theme_info['slug'] ] = array();
521
+                        }
522
+                        if ( ! isset( $data['theme'][ $theme_info['slug'] ][ $opt_name ] ) ) {
523
+                            $data['theme'][ $theme_info['slug'] ][ $opt_name ] = array();
524
+                        }
525
+                        if ( $simple ) {
526
+                            $data['theme'][ $theme_info['slug'] ][ $opt_name ][] = $theme_info['basename'];
527
+                        } else {
528
+                            $data['theme'][ $theme_info['slug'] ][ $opt_name ][] = $theme_info;
529
+                        }
530
+                    } elseif ( $plugin_info ) {
531
+                        if ( ! isset( $data['plugin'][ $plugin_info['slug'] ] ) ) {
532
+                            $data['plugin'][ $plugin_info['slug'] ] = array();
533
+                        }
534
+                        if ( ! in_array( $opt_name, $data['plugin'][ $plugin_info['slug'] ], true ) ) {
535
+                            if ( ! isset( $data['plugin'][ $plugin_info['slug'] ][ $opt_name ] ) ) {
536
+                                $data['plugin'][ $plugin_info['slug'] ][ $opt_name ] = array();
537
+                            }
538
+                            if ( $simple ) {
539
+                                $data['plugin'][ $plugin_info['slug'] ][ $opt_name ][] = $plugin_info['basename'];
540
+                            } else {
541
+                                $data['plugin'][ $plugin_info['slug'] ][ $opt_name ][] = $plugin_info;
542
+                            }
543
+                        }
544
+                    }
545
+                }
546
+            }
547
+
548
+            return $data;
549
+        }
550
+
551
+        /**
552
+         * Field Render Function.
553
+         * Takes the color hex value and converts to a rgba.
554
+         *
555
+         * @param string $hex   Color value.
556
+         * @param string $alpha Alpha value.
557
+         *
558
+         * @since ReduxFramework 3.0.4
559
+         */
560
+        public static function hex2rgba( string $hex, string $alpha = '' ): string {
561
+            $hex = ltrim( $hex, '#' );
562
+            $hex = sanitize_hex_color_no_hash( $hex );
563
+
564
+            if ( '' === $hex ) {
565
+                return '';
566
+            }
567
+
568
+            if ( 3 === strlen( $hex ) ) {
569
+                $r = hexdec( substr( $hex, 0, 1 ) . substr( $hex, 0, 1 ) );
570
+                $g = hexdec( substr( $hex, 1, 1 ) . substr( $hex, 1, 1 ) );
571
+                $b = hexdec( substr( $hex, 2, 1 ) . substr( $hex, 2, 1 ) );
572
+            } else {
573
+                $r = hexdec( substr( $hex, 0, 2 ) );
574
+                $g = hexdec( substr( $hex, 2, 2 ) );
575
+                $b = hexdec( substr( $hex, 4, 2 ) );
576
+            }
577
+
578
+            $rgb = $r . ',' . $g . ',' . $b;
579
+
580
+            if ( '' === $alpha ) {
581
+                return $rgb;
582
+            } else {
583
+                $alpha = floatval( $alpha );
584
+
585
+                return 'rgba(' . $rgb . ',' . $alpha . ')';
586
+            }
587
+        }
588
+
589
+        /**
590
+         * Deprecated. Returns string boolean value.
591
+         *
592
+         * @param mixed $variable String to convert to true boolean.
593
+         *
594
+         * @return mixed|array
595
+         *
596
+         * @deprecated No longer using camelCase naming convention.
597
+         */
598
+        public static function makeBoolStr( $variable ) { // phpcs:ignore WordPress.NamingConventions.ValidFunctionName
599
+            _deprecated_function( __CLASS__ . '::' . __FUNCTION__, 'Redux 4.0.0', 'Redux_Instances::make_bool_str( $var )' );
600
+
601
+            return self::make_bool_str( $variable );
602
+        }
603
+
604
+        /**
605
+         * Returns string boolean value.
606
+         *
607
+         * @param mixed $variable true|false to convert.
608
+         *
609
+         * @return mixed|array
610
+         */
611
+        public static function make_bool_str( $variable ) {
612
+            if ( 'false' === $variable || empty( $variable ) ) {
613
+                return 'false';
614
+            } elseif ( true === $variable || 'true' === $variable || 1 === $variable || '1' === $variable ) {
615
+                return 'true';
616
+            } else {
617
+                return $variable;
618
+            }
619
+        }
620
+
621
+        /**
622
+         * Compile a localized array.
623
+         *
624
+         * @param array $localize Array of localized strings.
625
+         *
626
+         * @return array
627
+         */
628
+        public static function localize( array $localize ): array {
629
+
630
+            return $localize;
631
+        }
632
+
633
+        /**
634
+         * Check mokama.
635
+         *
636
+         * @access public
637
+         * @since 4.0.0
638
+         * @return bool
639
+         */
640
+        public static function mokama(): bool {
641
+            if ( defined( 'RDX_MOKAMA' ) ) {
642
+                return Redux_Functions_Ex::s();
643
+            }
644
+
645
+            return false;
646
+        }
647
+
648
+        /**
649
+         * Retrieves template version.
650
+         *
651
+         * @param string $file Path to template file.
652
+         *
653
+         * @return string
654
+         */
655
+        public static function get_template_version( string $file ): string {
656
+            $filesystem = Redux_Filesystem::get_instance();
657
+            // Avoid notices if file does not exist.
658
+            if ( ! file_exists( $file ) ) {
659
+                return '';
660
+            }
661
+
662
+            $data = get_file_data( $file, array( 'version' ), 'plugin' );
663
+
664
+            if ( ! empty( $data[0] ) ) {
665
+                return $data[0];
666
+            } else {
667
+                $file_data = $filesystem->get_contents( $file );
668
+
669
+                $file_data = str_replace( "\r", "\n", $file_data );
670
+                $version   = '1.0.0';
671
+
672
+                if ( preg_match( '/^[ \t\/*#@]*' . preg_quote( '@version', '/' ) . '(.*)$/mi', $file_data, $match ) && $match[1] ) {
673
+                    $version = _cleanup_header_comment( $match[1] );
674
+                }
675
+
676
+                return $version;
677
+            }
678
+        }
679
+
680
+        /**
681
+         * Create HTML attribute string.
682
+         *
683
+         * @param array $attributes Array of attributes.
684
+         */
685
+        public static function html_attributes( array $attributes = array() ): string {
686
+            return join(
687
+                ' ',
688
+                array_map(
689
+                    function ( $key ) use ( $attributes ) {
690
+                        if ( is_bool( $attributes[ $key ] ) ) {
691
+                            return $attributes[ $key ] ? $key : '';
692
+                        }
693
+
694
+                        return $key . '="' . $attributes[ $key ] . '"';
695
+                    },
696
+                    array_keys( $attributes )
697
+                )
698
+            ) . ' ';
699
+        }
700
+
701
+        /**
702
+         * Normalize extensions dir.
703
+         *
704
+         * @param string $dir Path to extensions.
705
+         *
706
+         * @return string
707
+         */
708
+        public static function get_extension_dir( string $dir ): string {
709
+            return trailingslashit( Redux_Functions_Ex::wp_normalize_path( dirname( $dir ) ) );
710
+        }
711
+
712
+        /**
713
+         * Normalize extensions URL.
714
+         *
715
+         * @param string $dir Path to extensions.
716
+         *
717
+         * @return array|string|string[]
718
+         */
719
+        public static function get_extension_url( string $dir ) {
720
+            $ext_dir = self::get_extension_dir( $dir );
721
+
722
+            return str_replace( Redux_Functions_Ex::wp_normalize_path( WP_CONTENT_DIR ), WP_CONTENT_URL, $ext_dir );
723
+        }
724
+
725
+        /**
726
+         * Checks a nested capabilities array or string to determine if the current user meets the requirements.
727
+         *
728
+         * @param string|array $caps Permission string or array to check. See self::user_can() for details.
729
+         *
730
+         * @return bool Whether the user meets the requirements. False on invalid user.
731
+         * @since 3.6.3.4
732
+         */
733
+        public static function current_user_can( $caps ): bool { // phpcs:ignore Generic.CodeAnalysis.UnusedFunctionParameter.Found
734
+            $current_user = wp_get_current_user();
735
+
736
+            if ( empty( $current_user ) ) {
737
+                return false;
738
+            }
739
+
740
+            $name_arr = func_get_args();
741
+            $args     = array_merge( array( $current_user ), $name_arr );
742
+
743
+            return call_user_func_array( array( __CLASS__, 'user_can' ), $args );
744
+        }
745
+
746
+        /**
747
+         * Checks a nested capabilities array or string to determine if the user meets the requirements.
748
+         * You can pass in a simple string like 'edit_posts' or an array of conditions.
749
+         * The capability 'relation' is reserved for controlling the relation mode (AND/OR), which defaults to AND.
750
+         * Max depth of 30 levels.  False is returned for any conditions exceeding max depth.
751
+         * If you want to check meta caps, you must also pass the object ID on which to check against.
752
+         * If you get the error: PHP Notice: Undefined offset: 0 in /wp-includes/capabilities.php, you didn't
753
+         * pass the required $object_id.
754
+         *
755
+         * @param int|WP_User  $user          User ID or WP_User object to check. Defaults to the current user.
756
+         * @param string|array $capabilities  Capability string or array to check. The array lets you use multiple
757
+         *                                    conditions to determine if a user has permission.
758
+         *                                    Invalid conditions are skipped (conditions which aren't a string/array/bool/number(cast to bool)).
759
+         *                                    Example array where the user needs to have either the 'edit_posts' capability OR doesn't have the
760
+         *                                    'delete_pages' cap OR has the 'update_plugins' AND 'add_users' capabilities.
761
+         *                                    array(
762
+         *                                    'relation'     => 'OR',      // Optional, defaults to AND.
763
+         *                                    'edit_posts',                // Equivalent to 'edit_posts' => true,
764
+         *                                    'delete_pages' => false,     // Tests that the user DOESN'T have this capability
765
+         *                                    array(                       // Nested conditions array (up to 30 nestings)
766
+         *                                    'update_plugins',
767
+         *                                    'add_users',
768
+         *                                    ),
769
+         *                                    ).
770
+         * @param int|null     $object_id         (Optional) ID of the specific object to check against if capability is a "meta" cap.
771
+         *                                    e.g. 'edit_post', 'edit_user', 'edit_page', etc.
772
+         *
773
+         * @return bool Whether the user meets the requirements.
774
+         *              Will always return false for:
775
+         *              - Invalid/missing user
776
+         *              - If the $capabilities is not a string or array
777
+         *              - Max nesting depth exceeded (for that level)
778
+         * @since 3.6.3.4
779
+         * @example
780
+         *        user_can( 42, 'edit_pages' );                        // Checks if user ID 42 has the 'edit_pages' cap.
781
+         *        user_can( 42, 'edit_page', 17433 );                  // Checks if user ID 42 has the 'edit_page' cap for post-ID 17433.
782
+         *        user_can( 42, array( 'edit_pages', 'edit_posts' ) ); // Checks if user ID 42 has both the 'edit_pages' and 'edit_posts' caps.
783
+         */
784
+        public static function user_can( $user, $capabilities, ?int $object_id = null ): bool {
785
+            static $depth = 0;
786
+
787
+            if ( $depth >= 30 ) {
788
+                return false;
789
+            }
790
+
791
+            if ( empty( $user ) ) {
792
+                return false;
793
+            }
794
+
795
+            if ( ! is_object( $user ) ) {
796
+                $user = get_userdata( $user );
797
+            }
798
+
799
+            if ( is_string( $capabilities ) ) {
800
+                // Simple string capability check.
801
+                $args = array( $user, $capabilities );
802
+
803
+                if ( null !== $object_id ) {
804
+                    $args[] = $object_id;
805
+                }
806
+
807
+                return call_user_func_array( 'user_can', $args );
808
+            } elseif ( ! is_array( $capabilities ) ) {
809
+                // Only strings and arrays are allowed as valid capabilities.
810
+                return false;
811
+            }
812
+
813
+            // Capability array check.
814
+            $or = false;
815
+
816
+            foreach ( $capabilities as $key => $value ) {
817
+                if ( 'relation' === $key ) {
818
+                    if ( 'OR' === $value ) {
819
+                        $or = true;
820
+                    }
821
+
822
+                    continue;
823
+                }
824
+
825
+                /**
826
+                 * Rules can be in 4 different formats:
827
+                 * [
828
+                 *   [0]      => 'foobar',
829
+                 *   [1]      => array(...),
830
+                 *   'foobar' => false,
831
+                 *   'foobar' => array(...),
832
+                 * ]
833
+                 */
834
+                if ( is_numeric( $key ) ) {
835
+                    // Numeric key.
836
+                    if ( is_string( $value ) ) {
837
+                        // Numeric key with a string value is the capability string to check
838
+                        // [0] => 'foobar'.
839
+                        $args = array( $user, $value );
840
+
841
+                        if ( null !== $object_id ) {
842
+                            $args[] = $object_id;
843
+                        }
844
+
845
+                        $expression_result = call_user_func_array( 'user_can', $args ) === true;
846
+                    } elseif ( is_array( $value ) ) {
847
+                        ++$depth;
848
+
849
+                        $expression_result = self::user_can( $user, $value, $object_id );
850
+
851
+                        --$depth;
852
+                    } else {
853
+                        // Invalid types are skipped.
854
+                        continue;
855
+                    }
856
+                } else {
857
+                    // Non-numeric key.
858
+                    if ( is_scalar( $value ) ) {
859
+                        $args = array( $user, $key );
860
+
861
+                        if ( null !== $object_id ) {
862
+                            $args[] = $object_id;
863
+                        }
864
+
865
+                        $expression_result = call_user_func_array( 'user_can', $args ) === (bool) $value;
866
+                    } elseif ( is_array( $value ) ) {
867
+                        ++$depth;
868
+
869
+                        $expression_result = self::user_can( $user, $value, $object_id );
870
+
871
+                        --$depth;
872
+                    } else {
873
+                        // Invalid types are skipped.
874
+                        continue;
875
+                    }
876
+                }
877
+
878
+                // Check after every evaluation if we know enough to return a definitive answer.
879
+                if ( $or ) {
880
+                    if ( $expression_result ) {
881
+                        // If the relation is OR, return on the first true expression.
882
+                        return true;
883
+                    }
884
+                } elseif ( ! $expression_result ) {
885
+                    // If the relation is AND, return on the first false expression.
886
+                    return false;
887
+                }
888
+            }
889
+
890
+            // If we get this far on an OR, then it failed.
891
+            // If we get this far on an AND, then it succeeded.
892
+            return ! $or;
893
+        }
894
+
895
+        /**
896
+         * Check if Google font update is needed.
897
+         *
898
+         * @return bool
899
+         */
900
+        public static function google_fonts_update_needed(): bool {
901
+            $path = trailingslashit( Redux_Core::$upload_dir ) . 'google_fonts.json';
902
+            $now  = time();
903
+            $secs = 60 * 60 * 24 * 7;
904
+
905
+            if ( file_exists( $path ) ) {
906
+                if ( ( $now - filemtime( $path ) ) < $secs ) {
907
+                    return false;
908
+                }
909
+            }
910
+
911
+            return true;
912
+        }
913
+
914
+        /**
915
+         * Retrieve an updated Google font array.
916
+         *
917
+         * @param bool $download Flag to download to file.
918
+         *
919
+         * @return array|WP_Error
920
+         */
921
+        public static function google_fonts_array( bool $download = false ) {
922
+            if ( ! empty( Redux_Core::$updated_google_fonts ) && ! self::google_fonts_update_needed() ) {
923
+                return Redux_Core::$updated_google_fonts;
924
+            }
925
+
926
+            $filesystem = Redux_Filesystem::get_instance();
927
+
928
+            $path = trailingslashit( Redux_Core::$upload_dir ) . 'google_fonts.json';
929
+
930
+            if ( ! file_exists( $path ) || ( file_exists( $path ) && $download && self::google_fonts_update_needed() ) ) {
931
+                if ( $download ) {
932
+                    // phpcs:ignore WordPress.NamingConventions.ValidHookName
933
+                    $url = apply_filters( 'redux/typography/google_fonts/url', 'https://raw.githubusercontent.com/reduxframework/google-fonts/master/google_fonts.json' );
934
+
935
+                    $request = wp_remote_get(
936
+                        $url,
937
+                        array(
938
+                            'timeout' => 20,
939
+                        )
940
+                    );
941
+
942
+                    if ( ! is_wp_error( $request ) ) {
943
+                        $body = wp_remote_retrieve_body( $request );
944
+                        if ( ! empty( $body ) ) {
945
+                            $filesystem->put_contents( $path, $body );
946
+                            Redux_Core::$updated_google_fonts = json_decode( $body, true );
947
+                        }
948
+                    } else {
949
+                        return $request;
950
+                    }
951
+                }
952
+            } elseif ( file_exists( $path ) ) {
953
+                Redux_Core::$updated_google_fonts = json_decode( $filesystem->get_contents( $path ), true );
954
+                if ( empty( Redux_Core::$updated_google_fonts ) ) {
955
+                    $filesystem->unlink( $path );
956
+                }
957
+            }
958
+
959
+            return Redux_Core::$updated_google_fonts;
960
+        }
961
+
962
+        /**
963
+         * Deprecated. Gets all Redux instances
964
+         *
965
+         * @return array
966
+         * @deprecated No longer using camelCase naming convention and moved to a different class.
967
+         */
968
+        public static function getReduxInstances(): array { // phpcs:ignore WordPress.NamingConventions.ValidFunctionName
969
+            _deprecated_function( __CLASS__ . '::' . __FUNCTION__, 'Redux 4.0.0', 'Redux_Instances::get_all_instances()' );
970
+
971
+            return Redux_Instances::get_all_instances();
972
+        }
973
+
974
+        /**
975
+         * Is Inside Plugin
976
+         *
977
+         * @param string $file File name.
978
+         *
979
+         * @return array|bool
980
+         */
981
+        public static function is_inside_plugin( string $file ) {
982
+
983
+            // phpcs:ignore Squiz.PHP.CommentedOutCode
984
+            // if ( substr( strtoupper( $file ), 0, 2 ) === 'C:' ) {
985
+            // $file = ltrim( $file, 'C:' );
986
+            // $file = ltrim( $file, 'c:' );
987
+            // } .
988
+            //
989
+            $plugin_basename = plugin_basename( $file );
990
+
991
+            if ( Redux_Functions_Ex::wp_normalize_path( $file ) !== '/' . $plugin_basename ) {
992
+                $slug = explode( '/', $plugin_basename );
993
+                $slug = $slug[0];
994
+
995
+                return array(
996
+                    'slug'      => $slug,
997
+                    'basename'  => $plugin_basename,
998
+                    'path'      => Redux_Functions_Ex::wp_normalize_path( $file ),
999
+                    'url'       => plugins_url( $plugin_basename ),
1000
+                    'real_path' => Redux_Functions_Ex::wp_normalize_path( dirname( realpath( $file ) ) ),
1001
+                );
1002
+            }
1003
+
1004
+            return false;
1005
+        }
1006
+
1007
+        /**
1008
+         * Is inside theme.
1009
+         *
1010
+         * @param string $file File name.
1011
+         *
1012
+         * @return array|bool
1013
+         */
1014
+        public static function is_inside_theme( string $file = '' ) {
1015
+            $theme_paths = array(
1016
+                Redux_Functions_Ex::wp_normalize_path( get_template_directory() )   => get_template_directory_uri(),
1017
+                Redux_Functions_Ex::wp_normalize_path( get_stylesheet_directory() ) => get_stylesheet_directory_uri(),
1018
+            );
1019
+
1020
+            $theme_paths = array_unique( $theme_paths );
1021
+
1022
+            $file_path = Redux_Functions_Ex::wp_normalize_path( $file );
1023
+            $filename  = explode( '/', $file_path );
1024
+            $filename  = end( $filename );
1025
+            foreach ( $theme_paths as $theme_path => $url ) {
1026
+
1027
+                $real_path = Redux_Functions_Ex::wp_normalize_path( realpath( $theme_path ) );
1028
+
1029
+                if ( strpos( $file_path, trailingslashit( $real_path ) ) !== false ) {
1030
+                    $slug = explode( '/', Redux_Functions_Ex::wp_normalize_path( $theme_path ) );
1031
+                    if ( empty( $slug ) ) {
1032
+                        continue;
1033
+                    }
1034
+                    $slug          = end( $slug );
1035
+                    $relative_path = explode( $slug, dirname( $file_path ) );
1036
+
1037
+                    if ( 1 === count( $relative_path ) ) {
1038
+                        $relative_path = $file_path;
1039
+                    } else {
1040
+                        $relative_path = $relative_path[1];
1041
+                    }
1042
+                    $relative_path = ltrim( $relative_path, '/' );
1043
+
1044
+                    $data = array(
1045
+                        'slug'      => $slug,
1046
+                        'path'      => trailingslashit( trailingslashit( $theme_path ) . $relative_path ) . $filename,
1047
+                        'real_path' => trailingslashit( trailingslashit( $real_path ) . $relative_path ) . $filename,
1048
+                        'url'       => trailingslashit( trailingslashit( $url ) . $relative_path ) . $filename,
1049
+                    );
1050
+
1051
+                    $basename         = explode( $data['slug'], $data['path'] );
1052
+                    $basename         = end( $basename );
1053
+                    $basename         = ltrim( $basename, '/' );
1054
+                    $data['basename'] = trailingslashit( $data['slug'] ) . $basename;
1055
+
1056
+                    if ( is_child_theme() ) {
1057
+                        $parent              = get_template_directory();
1058
+                        $data['parent_slug'] = explode( '/', $parent );
1059
+                        $data['parent_slug'] = end( $data['parent_slug'] );
1060
+                        if ( $data['slug'] === $data['parent_slug'] ) {
1061
+                            unset( $data['parent_slug'] );
1062
+                        }
1063
+                    }
1064
+
1065
+                    return $data;
1066
+                }
1067
+            }
1068
+
1069
+            return false;
1070
+        }
1071
+
1072
+
1073
+        /**
1074
+         * Get plugin options.
1075
+         *
1076
+         * @return array|mixed|void
1077
+         */
1078
+        public static function get_plugin_options() {
1079
+            $defaults = array(
1080
+                'demo' => false,
1081
+            );
1082
+            $options  = array();
1083
+
1084
+            // If multisite is enabled.
1085
+            if ( is_multisite() ) {
1086
+
1087
+                // Get network activated plugins.
1088
+                $plugins = get_site_option( 'active_sitewide_plugins' );
1089
+
1090
+                foreach ( $plugins as $file => $plugin ) {
1091
+                    if ( strpos( $file, 'redux-framework.php' ) !== false ) {
1092
+                        $options = get_site_option( 'ReduxFrameworkPlugin', $defaults );
1093
+                    }
1094
+                }
1095
+            }
1096
+
1097
+            // If options aren't set, grab them now!
1098
+            if ( empty( $options ) ) {
1099
+                $options = get_option( 'ReduxFrameworkPlugin', $defaults );
1100
+            }
1101
+
1102
+            return $options;
1103
+        }
1104
+
1105
+        /**
1106
+         * Sanitize array keys and values.
1107
+         *
1108
+         * @param array $arr Array to sanitize.
1109
+         */
1110
+        public static function sanitize_array( array $arr ): array {
1111
+            return self::array_map_r( 'wp_kses_post', $arr );
1112
+        }
1113
+
1114
+        /**
1115
+         * Recursive array map.
1116
+         *
1117
+         * @param string $func function to run.
1118
+         * @param array  $arr  Array to clean.
1119
+         *
1120
+         * @return array
1121
+         */
1122
+        private static function array_map_r( string $func, array $arr ): array {
1123
+            $new_arr = array();
1124
+
1125
+            foreach ( $arr as $key => $value ) {
1126
+                $new_arr[ $key ] = ( is_array( $value ) ? self::array_map_r( $func, $value ) : ( is_array( $func ) ? call_user_func_array( $func, $value ) : $func( $value ) ) );
1127
+            }
1128
+
1129
+            return $new_arr;
1130
+        }
1131
+
1132
+        /**
1133
+         * Material design colors.
1134
+         *
1135
+         * @param string $context Mode to use.
1136
+         *
1137
+         * @return array
1138
+         */
1139
+        public static function get_material_design_colors( string $context = 'primary' ): array {
1140
+            $colors = array(
1141
+                'primary'     => array( '#FFFFFF', '#000000', '#F44336', '#E91E63', '#9C27B0', '#673AB7', '#3F51B5', '#2196F3', '#03A9F4', '#00BCD4', '#009688', '#4CAF50', '#8BC34A', '#CDDC39', '#FFEB3B', '#FFC107', '#FF9800', '#FF5722', '#795548', '#9E9E9E', '#607D8B' ),
1142
+                'red'         => array( '#FFEBEE', '#FFCDD2', '#EF9A9A', '#E57373', '#EF5350', '#F44336', '#E53935', '#D32F2F', '#C62828', '#B71C1C', '#FF8A80', '#FF5252', '#FF1744', '#D50000' ),
1143
+                'pink'        => array( '#FCE4EC', '#F8BBD0', '#F48FB1', '#F06292', '#EC407A', '#E91E63', '#D81B60', '#C2185B', '#AD1457', '#880E4F', '#FF80AB', '#FF4081', '#F50057', '#C51162' ),
1144
+                'purple'      => array( '#F3E5F5', '#E1BEE7', '#CE93D8', '#BA68C8', '#AB47BC', '#9C27B0', '#8E24AA', '#7B1FA2', '#6A1B9A', '#4A148C', '#EA80FC', '#E040FB', '#D500F9', '#AA00FF' ),
1145
+                'deep-purple' => array( '#EDE7F6', '#D1C4E9', '#B39DDB', '#9575CD', '#7E57C2', '#673AB7', '#5E35B1', '#512DA8', '#4527A0', '#311B92', '#B388FF', '#7C4DFF', '#651FFF', '#6200EA' ),
1146
+                'indigo'      => array( '#E8EAF6', '#C5CAE9', '#9FA8DA', '#7986CB', '#5C6BC0', '#3F51B5', '#3949AB', '#303F9F', '#283593', '#1A237E', '#8C9EFF', '#536DFE', '#3D5AFE', '#304FFE' ),
1147
+                'blue'        => array( '#E3F2FD', '#BBDEFB', '#90CAF9', '#64B5F6', '#42A5F5', '#2196F3', '#1E88E5', '#1976D2', '#1565C0', '#0D47A1', '#82B1FF', '#448AFF', '#2979FF', '#2962FF' ),
1148
+                'light-blue'  => array( '#E1F5FE', '#B3E5FC', '#81D4fA', '#4fC3F7', '#29B6FC', '#03A9F4', '#039BE5', '#0288D1', '#0277BD', '#01579B', '#80D8FF', '#40C4FF', '#00B0FF', '#0091EA' ),
1149
+                'cyan'        => array( '#E0F7FA', '#B2EBF2', '#80DEEA', '#4DD0E1', '#26C6DA', '#00BCD4', '#00ACC1', '#0097A7', '#00838F', '#006064', '#84FFFF', '#18FFFF', '#00E5FF', '#00B8D4' ),
1150
+                'teal'        => array( '#E0F2F1', '#B2DFDB', '#80CBC4', '#4DB6AC', '#26A69A', '#009688', '#00897B', '#00796B', '#00695C', '#004D40', '#A7FFEB', '#64FFDA', '#1DE9B6', '#00BFA5' ),
1151
+                'green'       => array( '#E8F5E9', '#C8E6C9', '#A5D6A7', '#81C784', '#66BB6A', '#4CAF50', '#43A047', '#388E3C', '#2E7D32', '#1B5E20', '#B9F6CA', '#69F0AE', '#00E676', '#00C853' ),
1152
+                'light-green' => array( '#F1F8E9', '#DCEDC8', '#C5E1A5', '#AED581', '#9CCC65', '#8BC34A', '#7CB342', '#689F38', '#558B2F', '#33691E', '#CCFF90', '#B2FF59', '#76FF03', '#64DD17' ),
1153
+                'lime'        => array( '#F9FBE7', '#F0F4C3', '#E6EE9C', '#DCE775', '#D4E157', '#CDDC39', '#C0CA33', '#A4B42B', '#9E9D24', '#827717', '#F4FF81', '#EEFF41', '#C6FF00', '#AEEA00' ),
1154
+                'yellow'      => array( '#FFFDE7', '#FFF9C4', '#FFF590', '#FFF176', '#FFEE58', '#FFEB3B', '#FDD835', '#FBC02D', '#F9A825', '#F57F17', '#FFFF82', '#FFFF00', '#FFEA00', '#FFD600' ),
1155
+                'amber'       => array( '#FFF8E1', '#FFECB3', '#FFE082', '#FFD54F', '#FFCA28', '#FFC107', '#FFB300', '#FFA000', '#FF8F00', '#FF6F00', '#FFE57F', '#FFD740', '#FFC400', '#FFAB00' ),
1156
+                'orange'      => array( '#FFF3E0', '#FFE0B2', '#FFCC80', '#FFB74D', '#FFA726', '#FF9800', '#FB8C00', '#F57C00', '#EF6C00', '#E65100', '#FFD180', '#FFAB40', '#FF9100', '#FF6D00' ),
1157
+                'deep-orange' => array( '#FBE9A7', '#FFCCBC', '#FFAB91', '#FF8A65', '#FF7043', '#FF5722', '#F4511E', '#E64A19', '#D84315', '#BF360C', '#FF9E80', '#FF6E40', '#FF3D00', '#DD2600' ),
1158
+                'brown'       => array( '#EFEBE9', '#D7CCC8', '#BCAAA4', '#A1887F', '#8D6E63', '#795548', '#6D4C41', '#5D4037', '#4E342E', '#3E2723' ),
1159
+                'gray'        => array( '#FAFAFA', '#F5F5F5', '#EEEEEE', '#E0E0E0', '#BDBDBD', '#9E9E9E', '#757575', '#616161', '#424242', '#212121', '#000000', '#ffffff' ),
1160
+                'blue-gray'   => array( '#ECEFF1', '#CFD8DC', '#B0BBC5', '#90A4AE', '#78909C', '#607D8B', '#546E7A', '#455A64', '#37474F', '#263238' ),
1161
+            );
1162
+
1163
+            $mui_arr = array(
1164
+                '50',
1165
+                '100',
1166
+                '200',
1167
+                '300',
1168
+                '400',
1169
+                '500',
1170
+                '600',
1171
+                '700',
1172
+                '800',
1173
+                '900',
1174
+                'A100',
1175
+                'A200',
1176
+                'A400',
1177
+                'A700',
1178
+            );
1179
+
1180
+            if ( in_array( $context, $mui_arr, true ) ) {
1181
+                $key = absint( $context ) / 100;
1182
+
1183
+                if ( 'A100' === $context ) {
1184
+                    $key = 10;
1185
+                    unset( $colors['grey'] );
1186
+                } elseif ( 'A200' === $context ) {
1187
+                    $key = 11;
1188
+                    unset( $colors['grey'] );
1189
+                } elseif ( 'A400' === $context ) {
1190
+                    $key = 12;
1191
+                    unset( $colors['grey'] );
1192
+                } elseif ( 'A700' === $context ) {
1193
+                    $key = 13;
1194
+                    unset( $colors['grey'] );
1195
+                }
1196
+
1197
+                unset( $colors['primary'] );
1198
+
1199
+                $position_colors = array();
1200
+                foreach ( $colors as $color_family ) {
1201
+                    if ( isset( $color_family[ $key ] ) ) {
1202
+                        $position_colors[] = $color_family[ $key ];
1203
+                    }
1204
+                }
1205
+
1206
+                return $position_colors;
1207
+            } elseif ( 'all' === $context ) {
1208
+                unset( $colors['primary'] );
1209
+
1210
+                $all_colors = array();
1211
+                foreach ( $colors as $color_family ) {
1212
+                    foreach ( $color_family as $color ) {
1213
+                        $all_colors[] = $color;
1214
+                    }
1215
+                }
1216
+
1217
+                return $all_colors;
1218
+            } elseif ( 'primary' === $context ) {
1219
+                return $colors['primary'];
1220
+            } else {
1221
+                if ( isset( $colors[ $context ] ) ) {
1222
+                    return $colors[ $context ];
1223
+                }
1224
+
1225
+                return $colors['primary'];
1226
+            }
1227
+        }
1228
+    }
1229 1229
 }
Please login to merge, or discard this patch.
redux-core/inc/classes/class-redux-validate.php 1 patch
Indentation   +72 added lines, -72 removed lines patch added patch discarded remove patch
@@ -11,87 +11,87 @@
 block discarded – undo
11 11
 
12 12
 if ( ! class_exists( 'Redux_Validate', false ) ) {
13 13
 
14
-	/**
15
-	 * Class Redux_Validate
16
-	 */
17
-	abstract class Redux_Validate {
18
-		/**
19
-		 * ReduxFramework object.
20
-		 *
21
-		 * @var object
22
-		 */
23
-		public $parent;
14
+    /**
15
+     * Class Redux_Validate
16
+     */
17
+    abstract class Redux_Validate {
18
+        /**
19
+         * ReduxFramework object.
20
+         *
21
+         * @var object
22
+         */
23
+        public $parent;
24 24
 
25
-		/**
26
-		 * Redux fields array.
27
-		 *
28
-		 * @var array
29
-		 */
30
-		public $field = array();
25
+        /**
26
+         * Redux fields array.
27
+         *
28
+         * @var array
29
+         */
30
+        public $field = array();
31 31
 
32
-		/**
33
-		 * Redux values array|string.
34
-		 *
35
-		 * @var array|string
36
-		 */
37
-		public $value;
32
+        /**
33
+         * Redux values array|string.
34
+         *
35
+         * @var array|string
36
+         */
37
+        public $value;
38 38
 
39
-		/**
40
-		 * Validation current value.
41
-		 *
42
-		 * @var mixed
43
-		 */
44
-		public $current;
39
+        /**
40
+         * Validation current value.
41
+         *
42
+         * @var mixed
43
+         */
44
+        public $current;
45 45
 
46
-		/**
47
-		 * Warning array.
48
-		 *
49
-		 * @var array
50
-		 */
51
-		public $warning = array();
46
+        /**
47
+         * Warning array.
48
+         *
49
+         * @var array
50
+         */
51
+        public $warning = array();
52 52
 
53
-		/**
54
-		 * Error array.
55
-		 *
56
-		 * @var array
57
-		 */
58
-		public $error = array();
53
+        /**
54
+         * Error array.
55
+         *
56
+         * @var array
57
+         */
58
+        public $error = array();
59 59
 
60
-		/**
61
-		 * Sanitize array.
62
-		 *
63
-		 * @var array
64
-		 */
65
-		public $sanitize = array();
60
+        /**
61
+         * Sanitize array.
62
+         *
63
+         * @var array
64
+         */
65
+        public $sanitize = array();
66 66
 
67
-		/**
68
-		 * Redux_Validate constructor.
69
-		 *
70
-		 * @param object       $redux ReduxFramework pointer.
71
-		 * @param array        $field Fields array.
72
-		 * @param array|string $value Values array.
73
-		 * @param mixed        $current Current.
74
-		 */
75
-		public function __construct( $redux, array $field, $value, $current ) {
76
-			$this->parent  = $redux;
77
-			$this->field   = $field;
78
-			$this->value   = $value;
79
-			$this->current = $current;
67
+        /**
68
+         * Redux_Validate constructor.
69
+         *
70
+         * @param object       $redux ReduxFramework pointer.
71
+         * @param array        $field Fields array.
72
+         * @param array|string $value Values array.
73
+         * @param mixed        $current Current.
74
+         */
75
+        public function __construct( $redux, array $field, $value, $current ) {
76
+            $this->parent  = $redux;
77
+            $this->field   = $field;
78
+            $this->value   = $value;
79
+            $this->current = $current;
80 80
 
81
-			if ( isset( $this->field['validate_msg'] ) ) {
82
-				$this->field['msg'] = $this->field['validate_msg'];
81
+            if ( isset( $this->field['validate_msg'] ) ) {
82
+                $this->field['msg'] = $this->field['validate_msg'];
83 83
 
84
-				unset( $this->field['validate_msg'] );
85
-			}
84
+                unset( $this->field['validate_msg'] );
85
+            }
86 86
 
87
-			$this->validate();
88
-		}
87
+            $this->validate();
88
+        }
89 89
 
90
-		/**
91
-		 * Validate.
92
-		 *
93
-		 * @return mixed
94
-		 */
95
-		abstract public function validate();
96
-	}
90
+        /**
91
+         * Validate.
92
+         *
93
+         * @return mixed
94
+         */
95
+        abstract public function validate();
96
+    }
97 97
 }
Please login to merge, or discard this patch.
redux-core/inc/classes/class-redux-colors.php 2 patches
Indentation   +295 added lines, -295 removed lines patch added patch discarded remove patch
@@ -11,324 +11,324 @@
 block discarded – undo
11 11
 
12 12
 if ( ! class_exists( 'Redux_Colors', false ) ) {
13 13
 
14
-	/**
15
-	 * Class Redux_Colors
16
-	 */
17
-	class Redux_Colors extends Redux_Class {
14
+    /**
15
+     * Class Redux_Colors
16
+     */
17
+    class Redux_Colors extends Redux_Class {
18 18
 
19
-		/**
20
-		 * Sanitizes a HEX value.
21
-		 * The way this works is by splitting the string in 6 substrings.
22
-		 * Each sub-string is individually sanitized, and the result is then returned.
23
-		 *
24
-		 * @param string  $color The hex value of a color.
25
-		 * @param boolean $hash  Whether we want to include a hash (#) at the beginning or not.
26
-		 *
27
-		 * @return  string      The sanitized hex color.
28
-		 */
29
-		public static function sanitize_hex( string $color = '#FFFFFF', bool $hash = true ): string {
30
-			$word_colors = array(
31
-				'aliceblue'            => 'F0F8FF',
32
-				'antiquewhite'         => 'FAEBD7',
33
-				'aqua'                 => '00FFFF',
34
-				'aquamarine'           => '7FFFD4',
35
-				'azure'                => 'F0FFFF',
36
-				'beige'                => 'F5F5DC',
37
-				'bisque'               => 'FFE4C4',
38
-				'black'                => '000000',
39
-				'blanchedalmond'       => 'FFEBCD',
40
-				'blue'                 => '0000FF',
41
-				'blueviolet'           => '8A2BE2',
42
-				'brown'                => 'A52A2A',
43
-				'burlywood'            => 'DEB887',
44
-				'cadetblue'            => '5F9EA0',
45
-				'chartreuse'           => '7FFF00',
46
-				'chocolate'            => 'D2691E',
47
-				'coral'                => 'FF7F50',
48
-				'cornflowerblue'       => '6495ED',
49
-				'cornsilk'             => 'FFF8DC',
50
-				'crimson'              => 'DC143C',
51
-				'cyan'                 => '00FFFF',
52
-				'darkblue'             => '00008B',
53
-				'darkcyan'             => '008B8B',
54
-				'darkgoldenrod'        => 'B8860B',
55
-				'darkgray'             => 'A9A9A9',
56
-				'darkgreen'            => '006400',
57
-				'darkgrey'             => 'A9A9A9',
58
-				'darkkhaki'            => 'BDB76B',
59
-				'darkmagenta'          => '8B008B',
60
-				'darkolivegreen'       => '556B2F',
61
-				'darkorange'           => 'FF8C00',
62
-				'darkorchid'           => '9932CC',
63
-				'darkred'              => '8B0000',
64
-				'darksalmon'           => 'E9967A',
65
-				'darkseagreen'         => '8FBC8F',
66
-				'darkslateblue'        => '483D8B',
67
-				'darkslategray'        => '2F4F4F',
68
-				'darkslategrey'        => '2F4F4F',
69
-				'darkturquoise'        => '00CED1',
70
-				'darkviolet'           => '9400D3',
71
-				'deeppink'             => 'FF1493',
72
-				'deepskyblue'          => '00BFFF',
73
-				'dimgray'              => '696969',
74
-				'dimgrey'              => '696969',
75
-				'dodgerblue'           => '1E90FF',
76
-				'firebrick'            => 'B22222',
77
-				'floralwhite'          => 'FFFAF0',
78
-				'forestgreen'          => '228B22',
79
-				'fuchsia'              => 'FF00FF',
80
-				'gainsboro'            => 'DCDCDC',
81
-				'ghostwhite'           => 'F8F8FF',
82
-				'gold'                 => 'FFD700',
83
-				'goldenrod'            => 'DAA520',
84
-				'gray'                 => '808080',
85
-				'green'                => '008000',
86
-				'greenyellow'          => 'ADFF2F',
87
-				'grey'                 => '808080',
88
-				'honeydew'             => 'F0FFF0',
89
-				'hotpink'              => 'FF69B4',
90
-				'indianred'            => 'CD5C5C',
91
-				'indigo'               => '4B0082',
92
-				'ivory'                => 'FFFFF0',
93
-				'khaki'                => 'F0E68C',
94
-				'lavender'             => 'E6E6FA',
95
-				'lavenderblush'        => 'FFF0F5',
96
-				'lawngreen'            => '7CFC00',
97
-				'lemonchiffon'         => 'FFFACD',
98
-				'lightblue'            => 'ADD8E6',
99
-				'lightcoral'           => 'F08080',
100
-				'lightcyan'            => 'E0FFFF',
101
-				'lightgoldenrodyellow' => 'FAFAD2',
102
-				'lightgray'            => 'D3D3D3',
103
-				'lightgreen'           => '90EE90',
104
-				'lightgrey'            => 'D3D3D3',
105
-				'lightpink'            => 'FFB6C1',
106
-				'lightsalmon'          => 'FFA07A',
107
-				'lightseagreen'        => '20B2AA',
108
-				'lightskyblue'         => '87CEFA',
109
-				'lightslategray'       => '778899',
110
-				'lightslategrey'       => '778899',
111
-				'lightsteelblue'       => 'B0C4DE',
112
-				'lightyellow'          => 'FFFFE0',
113
-				'lime'                 => '00FF00',
114
-				'limegreen'            => '32CD32',
115
-				'linen'                => 'FAF0E6',
116
-				'magenta'              => 'FF00FF',
117
-				'maroon'               => '800000',
118
-				'mediumaquamarine'     => '66CDAA',
119
-				'mediumblue'           => '0000CD',
120
-				'mediumorchid'         => 'BA55D3',
121
-				'mediumpurple'         => '9370D0',
122
-				'mediumseagreen'       => '3CB371',
123
-				'mediumslateblue'      => '7B68EE',
124
-				'mediumspringgreen'    => '00FA9A',
125
-				'mediumturquoise'      => '48D1CC',
126
-				'mediumvioletred'      => 'C71585',
127
-				'midnightblue'         => '191970',
128
-				'mintcream'            => 'F5FFFA',
129
-				'mistyrose'            => 'FFE4E1',
130
-				'moccasin'             => 'FFE4B5',
131
-				'navajowhite'          => 'FFDEAD',
132
-				'navy'                 => '000080',
133
-				'oldlace'              => 'FDF5E6',
134
-				'olive'                => '808000',
135
-				'olivedrab'            => '6B8E23',
136
-				'orange'               => 'FFA500',
137
-				'orangered'            => 'FF4500',
138
-				'orchid'               => 'DA70D6',
139
-				'palegoldenrod'        => 'EEE8AA',
140
-				'palegreen'            => '98FB98',
141
-				'paleturquoise'        => 'AFEEEE',
142
-				'palevioletred'        => 'DB7093',
143
-				'papayawhip'           => 'FFEFD5',
144
-				'peachpuff'            => 'FFDAB9',
145
-				'peru'                 => 'CD853F',
146
-				'pink'                 => 'FFC0CB',
147
-				'plum'                 => 'DDA0DD',
148
-				'powderblue'           => 'B0E0E6',
149
-				'purple'               => '800080',
150
-				'red'                  => 'FF0000',
151
-				'rosybrown'            => 'BC8F8F',
152
-				'royalblue'            => '4169E1',
153
-				'saddlebrown'          => '8B4513',
154
-				'salmon'               => 'FA8072',
155
-				'sandybrown'           => 'F4A460',
156
-				'seagreen'             => '2E8B57',
157
-				'seashell'             => 'FFF5EE',
158
-				'sienna'               => 'A0522D',
159
-				'silver'               => 'C0C0C0',
160
-				'skyblue'              => '87CEEB',
161
-				'slateblue'            => '6A5ACD',
162
-				'slategray'            => '708090',
163
-				'slategrey'            => '708090',
164
-				'snow'                 => 'FFFAFA',
165
-				'springgreen'          => '00FF7F',
166
-				'steelblue'            => '4682B4',
167
-				'tan'                  => 'D2B48C',
168
-				'teal'                 => '008080',
169
-				'thistle'              => 'D8BFD8',
170
-				'tomato'               => 'FF6347',
171
-				'turquoise'            => '40E0D0',
172
-				'violet'               => 'EE82EE',
173
-				'wheat'                => 'F5DEB3',
174
-				'white'                => 'FFFFFF',
175
-				'whitesmoke'           => 'F5F5F5',
176
-				'yellow'               => 'FFFF00',
177
-				'yellowgreen'          => '9ACD32',
178
-			);
19
+        /**
20
+         * Sanitizes a HEX value.
21
+         * The way this works is by splitting the string in 6 substrings.
22
+         * Each sub-string is individually sanitized, and the result is then returned.
23
+         *
24
+         * @param string  $color The hex value of a color.
25
+         * @param boolean $hash  Whether we want to include a hash (#) at the beginning or not.
26
+         *
27
+         * @return  string      The sanitized hex color.
28
+         */
29
+        public static function sanitize_hex( string $color = '#FFFFFF', bool $hash = true ): string {
30
+            $word_colors = array(
31
+                'aliceblue'            => 'F0F8FF',
32
+                'antiquewhite'         => 'FAEBD7',
33
+                'aqua'                 => '00FFFF',
34
+                'aquamarine'           => '7FFFD4',
35
+                'azure'                => 'F0FFFF',
36
+                'beige'                => 'F5F5DC',
37
+                'bisque'               => 'FFE4C4',
38
+                'black'                => '000000',
39
+                'blanchedalmond'       => 'FFEBCD',
40
+                'blue'                 => '0000FF',
41
+                'blueviolet'           => '8A2BE2',
42
+                'brown'                => 'A52A2A',
43
+                'burlywood'            => 'DEB887',
44
+                'cadetblue'            => '5F9EA0',
45
+                'chartreuse'           => '7FFF00',
46
+                'chocolate'            => 'D2691E',
47
+                'coral'                => 'FF7F50',
48
+                'cornflowerblue'       => '6495ED',
49
+                'cornsilk'             => 'FFF8DC',
50
+                'crimson'              => 'DC143C',
51
+                'cyan'                 => '00FFFF',
52
+                'darkblue'             => '00008B',
53
+                'darkcyan'             => '008B8B',
54
+                'darkgoldenrod'        => 'B8860B',
55
+                'darkgray'             => 'A9A9A9',
56
+                'darkgreen'            => '006400',
57
+                'darkgrey'             => 'A9A9A9',
58
+                'darkkhaki'            => 'BDB76B',
59
+                'darkmagenta'          => '8B008B',
60
+                'darkolivegreen'       => '556B2F',
61
+                'darkorange'           => 'FF8C00',
62
+                'darkorchid'           => '9932CC',
63
+                'darkred'              => '8B0000',
64
+                'darksalmon'           => 'E9967A',
65
+                'darkseagreen'         => '8FBC8F',
66
+                'darkslateblue'        => '483D8B',
67
+                'darkslategray'        => '2F4F4F',
68
+                'darkslategrey'        => '2F4F4F',
69
+                'darkturquoise'        => '00CED1',
70
+                'darkviolet'           => '9400D3',
71
+                'deeppink'             => 'FF1493',
72
+                'deepskyblue'          => '00BFFF',
73
+                'dimgray'              => '696969',
74
+                'dimgrey'              => '696969',
75
+                'dodgerblue'           => '1E90FF',
76
+                'firebrick'            => 'B22222',
77
+                'floralwhite'          => 'FFFAF0',
78
+                'forestgreen'          => '228B22',
79
+                'fuchsia'              => 'FF00FF',
80
+                'gainsboro'            => 'DCDCDC',
81
+                'ghostwhite'           => 'F8F8FF',
82
+                'gold'                 => 'FFD700',
83
+                'goldenrod'            => 'DAA520',
84
+                'gray'                 => '808080',
85
+                'green'                => '008000',
86
+                'greenyellow'          => 'ADFF2F',
87
+                'grey'                 => '808080',
88
+                'honeydew'             => 'F0FFF0',
89
+                'hotpink'              => 'FF69B4',
90
+                'indianred'            => 'CD5C5C',
91
+                'indigo'               => '4B0082',
92
+                'ivory'                => 'FFFFF0',
93
+                'khaki'                => 'F0E68C',
94
+                'lavender'             => 'E6E6FA',
95
+                'lavenderblush'        => 'FFF0F5',
96
+                'lawngreen'            => '7CFC00',
97
+                'lemonchiffon'         => 'FFFACD',
98
+                'lightblue'            => 'ADD8E6',
99
+                'lightcoral'           => 'F08080',
100
+                'lightcyan'            => 'E0FFFF',
101
+                'lightgoldenrodyellow' => 'FAFAD2',
102
+                'lightgray'            => 'D3D3D3',
103
+                'lightgreen'           => '90EE90',
104
+                'lightgrey'            => 'D3D3D3',
105
+                'lightpink'            => 'FFB6C1',
106
+                'lightsalmon'          => 'FFA07A',
107
+                'lightseagreen'        => '20B2AA',
108
+                'lightskyblue'         => '87CEFA',
109
+                'lightslategray'       => '778899',
110
+                'lightslategrey'       => '778899',
111
+                'lightsteelblue'       => 'B0C4DE',
112
+                'lightyellow'          => 'FFFFE0',
113
+                'lime'                 => '00FF00',
114
+                'limegreen'            => '32CD32',
115
+                'linen'                => 'FAF0E6',
116
+                'magenta'              => 'FF00FF',
117
+                'maroon'               => '800000',
118
+                'mediumaquamarine'     => '66CDAA',
119
+                'mediumblue'           => '0000CD',
120
+                'mediumorchid'         => 'BA55D3',
121
+                'mediumpurple'         => '9370D0',
122
+                'mediumseagreen'       => '3CB371',
123
+                'mediumslateblue'      => '7B68EE',
124
+                'mediumspringgreen'    => '00FA9A',
125
+                'mediumturquoise'      => '48D1CC',
126
+                'mediumvioletred'      => 'C71585',
127
+                'midnightblue'         => '191970',
128
+                'mintcream'            => 'F5FFFA',
129
+                'mistyrose'            => 'FFE4E1',
130
+                'moccasin'             => 'FFE4B5',
131
+                'navajowhite'          => 'FFDEAD',
132
+                'navy'                 => '000080',
133
+                'oldlace'              => 'FDF5E6',
134
+                'olive'                => '808000',
135
+                'olivedrab'            => '6B8E23',
136
+                'orange'               => 'FFA500',
137
+                'orangered'            => 'FF4500',
138
+                'orchid'               => 'DA70D6',
139
+                'palegoldenrod'        => 'EEE8AA',
140
+                'palegreen'            => '98FB98',
141
+                'paleturquoise'        => 'AFEEEE',
142
+                'palevioletred'        => 'DB7093',
143
+                'papayawhip'           => 'FFEFD5',
144
+                'peachpuff'            => 'FFDAB9',
145
+                'peru'                 => 'CD853F',
146
+                'pink'                 => 'FFC0CB',
147
+                'plum'                 => 'DDA0DD',
148
+                'powderblue'           => 'B0E0E6',
149
+                'purple'               => '800080',
150
+                'red'                  => 'FF0000',
151
+                'rosybrown'            => 'BC8F8F',
152
+                'royalblue'            => '4169E1',
153
+                'saddlebrown'          => '8B4513',
154
+                'salmon'               => 'FA8072',
155
+                'sandybrown'           => 'F4A460',
156
+                'seagreen'             => '2E8B57',
157
+                'seashell'             => 'FFF5EE',
158
+                'sienna'               => 'A0522D',
159
+                'silver'               => 'C0C0C0',
160
+                'skyblue'              => '87CEEB',
161
+                'slateblue'            => '6A5ACD',
162
+                'slategray'            => '708090',
163
+                'slategrey'            => '708090',
164
+                'snow'                 => 'FFFAFA',
165
+                'springgreen'          => '00FF7F',
166
+                'steelblue'            => '4682B4',
167
+                'tan'                  => 'D2B48C',
168
+                'teal'                 => '008080',
169
+                'thistle'              => 'D8BFD8',
170
+                'tomato'               => 'FF6347',
171
+                'turquoise'            => '40E0D0',
172
+                'violet'               => 'EE82EE',
173
+                'wheat'                => 'F5DEB3',
174
+                'white'                => 'FFFFFF',
175
+                'whitesmoke'           => 'F5F5F5',
176
+                'yellow'               => 'FFFF00',
177
+                'yellowgreen'          => '9ACD32',
178
+            );
179 179
 
180
-			if ( is_array( $color ) ) {
181
-				$color = $color[0];
182
-			}
180
+            if ( is_array( $color ) ) {
181
+                $color = $color[0];
182
+            }
183 183
 
184
-			// Remove any spaces and special characters before and after the string.
185
-			$color = trim( $color );
184
+            // Remove any spaces and special characters before and after the string.
185
+            $color = trim( $color );
186 186
 
187
-			// Check if the color is a standard word-color.
188
-			// If it is, then convert to hex.
189
-			if ( array_key_exists( $color, $word_colors ) ) {
190
-				$color = $word_colors[ $color ];
191
-			}
187
+            // Check if the color is a standard word-color.
188
+            // If it is, then convert to hex.
189
+            if ( array_key_exists( $color, $word_colors ) ) {
190
+                $color = $word_colors[ $color ];
191
+            }
192 192
 
193
-			// Remove any trailing '#' symbols from the color value.
194
-			$color = str_replace( '#', '', $color );
193
+            // Remove any trailing '#' symbols from the color value.
194
+            $color = str_replace( '#', '', $color );
195 195
 
196
-			// If the string is six characters long, then use it in pairs.
197
-			if ( 3 === strlen( $color ) ) {
198
-				$color = substr( $color, 0, 1 ) . substr( $color, 0, 1 ) . substr( $color, 1, 1 ) . substr( $color, 1, 1 ) . substr( $color, 2, 1 ) . substr( $color, 2, 1 );
199
-			}
196
+            // If the string is six characters long, then use it in pairs.
197
+            if ( 3 === strlen( $color ) ) {
198
+                $color = substr( $color, 0, 1 ) . substr( $color, 0, 1 ) . substr( $color, 1, 1 ) . substr( $color, 1, 1 ) . substr( $color, 2, 1 ) . substr( $color, 2, 1 );
199
+            }
200 200
 
201
-			$substr = array();
202
-			for ( $i = 0; $i <= 5; $i++ ) {
203
-				$default      = ( 0 === $i ) ? 'F' : ( $substr[ $i - 1 ] );
204
-				$substr[ $i ] = substr( $color, $i, 1 );
205
-				$substr[ $i ] = ( false === $substr[ $i ] || ! ctype_xdigit( $substr[ $i ] ) ) ? $default : $substr[ $i ];
206
-			}
201
+            $substr = array();
202
+            for ( $i = 0; $i <= 5; $i++ ) {
203
+                $default      = ( 0 === $i ) ? 'F' : ( $substr[ $i - 1 ] );
204
+                $substr[ $i ] = substr( $color, $i, 1 );
205
+                $substr[ $i ] = ( false === $substr[ $i ] || ! ctype_xdigit( $substr[ $i ] ) ) ? $default : $substr[ $i ];
206
+            }
207 207
 
208
-			$hex = implode( '', $substr );
208
+            $hex = implode( '', $substr );
209 209
 
210
-			return ( ! $hash ) ? $hex : '#' . $hex;
211
-		}
210
+            return ( ! $hash ) ? $hex : '#' . $hex;
211
+        }
212 212
 
213
-		/**
214
-		 * Sanitizes RGBA color.
215
-		 *
216
-		 * @param string $value RGBA value.
217
-		 *
218
-		 * @return string
219
-		 */
220
-		public static function sanitize_rgba( string $value ): string {
221
-			// If empty or an array return transparent.
222
-			if ( empty( $value ) ) {
223
-				return 'rgba(0,0,0,0)';
224
-			}
213
+        /**
214
+         * Sanitizes RGBA color.
215
+         *
216
+         * @param string $value RGBA value.
217
+         *
218
+         * @return string
219
+         */
220
+        public static function sanitize_rgba( string $value ): string {
221
+            // If empty or an array return transparent.
222
+            if ( empty( $value ) ) {
223
+                return 'rgba(0,0,0,0)';
224
+            }
225 225
 
226
-			// If string does not start with 'rgba', then treat as hex
227
-			// sanitize the hex color and finally convert hex to rgba.
228
-			if ( false === strpos( $value, 'rgba' ) ) {
229
-				return self::get_rgba( self::sanitize_hex( $value ) );
230
-			}
226
+            // If string does not start with 'rgba', then treat as hex
227
+            // sanitize the hex color and finally convert hex to rgba.
228
+            if ( false === strpos( $value, 'rgba' ) ) {
229
+                return self::get_rgba( self::sanitize_hex( $value ) );
230
+            }
231 231
 
232
-			// By now we know the string is formatted as a rgba color, so we can just return it.
233
-			$value = str_replace( array( ' ', 'rgba', '(', ')' ), '', $value );
234
-			$value = explode( ',', $value );
235
-			$red   = ( isset( $value[0] ) ) ? intval( $value[0] ) : 255;
236
-			$green = ( isset( $value[1] ) ) ? intval( $value[1] ) : 255;
237
-			$blue  = ( isset( $value[2] ) ) ? intval( $value[2] ) : 255;
238
-			$alpha = ( isset( $value[3] ) ) ? filter_var( $value[3], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION ) : 1;
232
+            // By now we know the string is formatted as a rgba color, so we can just return it.
233
+            $value = str_replace( array( ' ', 'rgba', '(', ')' ), '', $value );
234
+            $value = explode( ',', $value );
235
+            $red   = ( isset( $value[0] ) ) ? intval( $value[0] ) : 255;
236
+            $green = ( isset( $value[1] ) ) ? intval( $value[1] ) : 255;
237
+            $blue  = ( isset( $value[2] ) ) ? intval( $value[2] ) : 255;
238
+            $alpha = ( isset( $value[3] ) ) ? filter_var( $value[3], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION ) : 1;
239 239
 
240
-			return 'rgba(' . $red . ',' . $green . ',' . $blue . ',' . $alpha . ')';
241
-		}
240
+            return 'rgba(' . $red . ',' . $green . ',' . $blue . ',' . $alpha . ')';
241
+        }
242 242
 
243
-		/**
244
-		 * Sanitize colors.
245
-		 * Determine if the current value is a hex or a rgba color and call the appropriate method.
246
-		 *
247
-		 * @param  string|array $value  hex or rgba color.
248
-		 *
249
-		 * @return string
250
-		 * @since 0.8.5
251
-		 */
252
-		public static function sanitize_color( $value ): string {
253
-			if ( is_array( $value ) ) {
254
-				if ( isset( $value['rgba'] ) ) {
255
-					$value = $value['rgba'];
256
-				} elseif ( isset( $value['color'] ) ) {
257
-					$opacity = ( isset( $value['opacity'] ) ) ? $value['opacity'] : null;
258
-					$opacity = ( ! is_null( $opacity ) && isset( $value['alpha'] ) ) ? $value['alpha'] : null;
259
-					$opacity = ( is_null( $opacity ) ) ? 1 : floatval( $opacity );
243
+        /**
244
+         * Sanitize colors.
245
+         * Determine if the current value is a hex or a rgba color and call the appropriate method.
246
+         *
247
+         * @param  string|array $value  hex or rgba color.
248
+         *
249
+         * @return string
250
+         * @since 0.8.5
251
+         */
252
+        public static function sanitize_color( $value ): string {
253
+            if ( is_array( $value ) ) {
254
+                if ( isset( $value['rgba'] ) ) {
255
+                    $value = $value['rgba'];
256
+                } elseif ( isset( $value['color'] ) ) {
257
+                    $opacity = ( isset( $value['opacity'] ) ) ? $value['opacity'] : null;
258
+                    $opacity = ( ! is_null( $opacity ) && isset( $value['alpha'] ) ) ? $value['alpha'] : null;
259
+                    $opacity = ( is_null( $opacity ) ) ? 1 : floatval( $opacity );
260 260
 
261
-					$value = self::get_rgba( $value['color'], $opacity );
262
-				} else {
263
-					return '';
264
-				}
265
-			}
261
+                    $value = self::get_rgba( $value['color'], $opacity );
262
+                } else {
263
+                    return '';
264
+                }
265
+            }
266 266
 
267
-			if ( 'transparent' === $value ) {
268
-				return 'transparent';
269
-			}
267
+            if ( 'transparent' === $value ) {
268
+                return 'transparent';
269
+            }
270 270
 
271
-			// Is this a rgba color or a hex?
272
-			$mode = ( false === strpos( $value, 'rgba' ) ) ? 'rgba' : 'hex';
271
+            // Is this a rgba color or a hex?
272
+            $mode = ( false === strpos( $value, 'rgba' ) ) ? 'rgba' : 'hex';
273 273
 
274
-			if ( 'rgba' === $mode ) {
275
-				return self::sanitize_hex( $value );
276
-			} else {
277
-				return self::sanitize_rgba( $value );
278
-			}
279
-		}
274
+            if ( 'rgba' === $mode ) {
275
+                return self::sanitize_hex( $value );
276
+            } else {
277
+                return self::sanitize_rgba( $value );
278
+            }
279
+        }
280 280
 
281
-		/**
282
-		 * Gets the rgb value of the $hex color.
283
-		 *
284
-		 * @param string  $hex     The hex value of a color.
285
-		 * @param boolean $implode Whether we want to implode the values or not.
286
-		 *
287
-		 * @return  array|string       array|string
288
-		 */
289
-		public static function get_rgb( string $hex, bool $implode = false ) {
290
-			// Remove any trailing '#' symbols from the color value.
291
-			$hex = self::sanitize_hex( $hex, false );
281
+        /**
282
+         * Gets the rgb value of the $hex color.
283
+         *
284
+         * @param string  $hex     The hex value of a color.
285
+         * @param boolean $implode Whether we want to implode the values or not.
286
+         *
287
+         * @return  array|string       array|string
288
+         */
289
+        public static function get_rgb( string $hex, bool $implode = false ) {
290
+            // Remove any trailing '#' symbols from the color value.
291
+            $hex = self::sanitize_hex( $hex, false );
292 292
 
293
-			// rgb is an array.
294
-			$rgb = array(
295
-				hexdec( substr( $hex, 0, 2 ) ),
296
-				hexdec( substr( $hex, 2, 2 ) ),
297
-				hexdec( substr( $hex, 4, 2 ) ),
298
-			);
293
+            // rgb is an array.
294
+            $rgb = array(
295
+                hexdec( substr( $hex, 0, 2 ) ),
296
+                hexdec( substr( $hex, 2, 2 ) ),
297
+                hexdec( substr( $hex, 4, 2 ) ),
298
+            );
299 299
 
300
-			return ( $implode ) ? implode( ',', $rgb ) : $rgb;
301
-		}
300
+            return ( $implode ) ? implode( ',', $rgb ) : $rgb;
301
+        }
302 302
 
303
-		/**
304
-		 * Gets the rgb value of the $hex color.
305
-		 *
306
-		 * @param string $hex     The hex value of a color.
307
-		 * @param int    $opacity Opacity level (1-100).
308
-		 *
309
-		 * @return  string
310
-		 */
311
-		public static function get_rgba( string $hex = '#fff', int $opacity = 100 ): string {
312
-			$hex = self::sanitize_hex( $hex, false );
303
+        /**
304
+         * Gets the rgb value of the $hex color.
305
+         *
306
+         * @param string $hex     The hex value of a color.
307
+         * @param int    $opacity Opacity level (1-100).
308
+         *
309
+         * @return  string
310
+         */
311
+        public static function get_rgba( string $hex = '#fff', int $opacity = 100 ): string {
312
+            $hex = self::sanitize_hex( $hex, false );
313 313
 
314
-			/**
315
-			 * Make sure that opacity is properly formatted:
316
-			 * Set the opacity to 100 if a larger value has been entered by mistake.
317
-			 * If a negative value is used, then set to 0.
318
-			 * If an opacity value is entered in a decimal form (for example, 0.25), then multiply by 100.
319
-			 */
320
-			if ( $opacity >= 100 ) {
321
-				$opacity = 100;
322
-			} elseif ( $opacity < 0 ) {
323
-				$opacity = 0;
324
-			} elseif ( $opacity <= 1 && 0 !== $opacity ) {
325
-				$opacity = ( $opacity * 100 );
326
-			}
314
+            /**
315
+             * Make sure that opacity is properly formatted:
316
+             * Set the opacity to 100 if a larger value has been entered by mistake.
317
+             * If a negative value is used, then set to 0.
318
+             * If an opacity value is entered in a decimal form (for example, 0.25), then multiply by 100.
319
+             */
320
+            if ( $opacity >= 100 ) {
321
+                $opacity = 100;
322
+            } elseif ( $opacity < 0 ) {
323
+                $opacity = 0;
324
+            } elseif ( $opacity <= 1 && 0 !== $opacity ) {
325
+                $opacity = ( $opacity * 100 );
326
+            }
327 327
 
328
-			// Divide the opacity by 100 to end-up with a CSS value for the opacity.
329
-			$opacity = ( $opacity / 100 );
328
+            // Divide the opacity by 100 to end-up with a CSS value for the opacity.
329
+            $opacity = ( $opacity / 100 );
330 330
 
331
-			return 'rgba(' . self::get_rgb( $hex, true ) . ', ' . $opacity . ')';
332
-		}
333
-	}
331
+            return 'rgba(' . self::get_rgb( $hex, true ) . ', ' . $opacity . ')';
332
+        }
333
+    }
334 334
 }
Please login to merge, or discard this patch.
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -187,7 +187,7 @@  discard block
 block discarded – undo
187 187
 			// Check if the color is a standard word-color.
188 188
 			// If it is, then convert to hex.
189 189
 			if ( array_key_exists( $color, $word_colors ) ) {
190
-				$color = $word_colors[ $color ];
190
+				$color = $word_colors[$color];
191 191
 			}
192 192
 
193 193
 			// Remove any trailing '#' symbols from the color value.
@@ -200,9 +200,9 @@  discard block
 block discarded – undo
200 200
 
201 201
 			$substr = array();
202 202
 			for ( $i = 0; $i <= 5; $i++ ) {
203
-				$default      = ( 0 === $i ) ? 'F' : ( $substr[ $i - 1 ] );
204
-				$substr[ $i ] = substr( $color, $i, 1 );
205
-				$substr[ $i ] = ( false === $substr[ $i ] || ! ctype_xdigit( $substr[ $i ] ) ) ? $default : $substr[ $i ];
203
+				$default      = ( 0 === $i ) ? 'F' : ( $substr[$i - 1] );
204
+				$substr[$i] = substr( $color, $i, 1 );
205
+				$substr[$i] = ( false === $substr[$i] || ! ctype_xdigit( $substr[$i] ) ) ? $default : $substr[$i];
206 206
 			}
207 207
 
208 208
 			$hex = implode( '', $substr );
Please login to merge, or discard this patch.