Completed
Push — master ( 44aca2...0191c7 )
by
unknown
36s
created
redux-core/inc/classes/class-redux-sanitize.php 2 patches
Indentation   +115 added lines, -115 removed lines patch added patch discarded remove patch
@@ -11,119 +11,119 @@
 block discarded – undo
11 11
 
12 12
 if ( ! class_exists( 'Redux_Sanitize', false ) ) {
13 13
 
14
-	/**
15
-	 * Class Redux_Sanitize
16
-	 */
17
-	class Redux_Sanitize extends Redux_Class {
18
-
19
-		/**
20
-		 * Sanitize values from options form (used in settings api validate function)
21
-		 *
22
-		 * @since       4.0.0
23
-		 * @access      public
24
-		 *
25
-		 * @param       array $plugin_options Plugin Options.
26
-		 * @param       array $options Options.
27
-		 * @param       array $sections Sections array.
28
-		 *
29
-		 * @return      array $plugin_options
30
-		 */
31
-		public function sanitize( array $plugin_options, array $options, array $sections ): array {
32
-			$core = $this->core();
33
-
34
-			foreach ( $sections as $k => $section ) {
35
-				if ( isset( $section['fields'] ) ) {
36
-					foreach ( $section['fields'] as $field ) {
37
-
38
-						if ( is_array( $field ) ) {
39
-							$field['section_id'] = $k;
40
-						}
41
-
42
-						if ( isset( $field['type'] ) && ( 'text' === $field['type'] || 'textarea' === $field['type'] || 'multi_text' === $field['type'] ) ) {
43
-
44
-							// Make sure 'sanitize' field is set.
45
-							if ( isset( $field['sanitize'] ) ) {
46
-
47
-								// Can we make this an array of validations?
48
-								$val_arr = array();
49
-
50
-								if ( is_array( $field['sanitize'] ) ) {
51
-									$val_arr = $field['sanitize'];
52
-								} else {
53
-									$val_arr[] = $field['sanitize'];
54
-								}
55
-
56
-								foreach ( $val_arr as $function ) {
57
-
58
-									// Check for empty id value.
59
-									if ( ! isset( $field['id'] ) || ! isset( $plugin_options[ $field['id'] ] ) || ( '' === $plugin_options[ $field['id'] ] ) ) {
60
-										continue;
61
-									}
62
-
63
-									if ( function_exists( $function ) ) {
64
-										if ( empty( $options[ $field['id'] ] ) ) {
65
-											$options[ $field['id'] ] = '';
66
-										}
67
-
68
-										if ( is_array( $plugin_options[ $field['id'] ] ) && ! empty( $plugin_options[ $field['id'] ] ) ) {
69
-											foreach ( $plugin_options[ $field['id'] ] as $key => $value ) {
70
-												$before = null;
71
-												$after  = null;
72
-
73
-												if ( isset( $plugin_options[ $field['id'] ][ $key ] ) && ( ! empty( $plugin_options[ $field['id'] ][ $key ] ) || '0' === $plugin_options[ $field['id'] ][ $key ] ) ) {
74
-													if ( is_array( $plugin_options[ $field['id'] ][ $key ] ) ) {
75
-														$before = $plugin_options[ $field['id'] ][ $key ];
76
-													} else {
77
-														$before = trim( $plugin_options[ $field['id'] ][ $key ] );
78
-													}
79
-												}
80
-
81
-												if ( isset( $options[ $field['id'] ][ $key ] ) && ( ! empty( $plugin_options[ $field['id'] ][ $key ] ) || '0' === $plugin_options[ $field['id'] ][ $key ] ) ) {
82
-													$after = $options[ $field['id'] ][ $key ];
83
-												}
84
-
85
-												$value = call_user_func( $function, $before );
86
-
87
-												if ( false !== $value ) {
88
-													$plugin_options[ $field['id'] ][ $key ] = $value;
89
-												} else {
90
-													unset( $plugin_options[ $field['id'] ][ $key ] );
91
-												}
92
-
93
-												$field['current'] = $value;
94
-
95
-												$core->sanitize[] = $field;
96
-											}
97
-										} else {
98
-											if ( isset( $plugin_options[ $field['id'] ] ) ) {
99
-												if ( is_array( $plugin_options[ $field['id'] ] ) ) {
100
-													$pofi = $plugin_options[ $field['id'] ];
101
-												} else {
102
-													$pofi = trim( $plugin_options[ $field['id'] ] );
103
-												}
104
-											} else {
105
-												$pofi = null;
106
-											}
107
-
108
-											$value = call_user_func( $function, $pofi );
109
-
110
-											$plugin_options[ $field['id'] ] = $value;
111
-
112
-											$field['current'] = $value;
113
-
114
-											$core->sanitize[] = $field;
115
-										}
116
-
117
-										break;
118
-									}
119
-								}
120
-							}
121
-						}
122
-					}
123
-				}
124
-			}
125
-
126
-			return $plugin_options;
127
-		}
128
-	}
14
+    /**
15
+     * Class Redux_Sanitize
16
+     */
17
+    class Redux_Sanitize extends Redux_Class {
18
+
19
+        /**
20
+         * Sanitize values from options form (used in settings api validate function)
21
+         *
22
+         * @since       4.0.0
23
+         * @access      public
24
+         *
25
+         * @param       array $plugin_options Plugin Options.
26
+         * @param       array $options Options.
27
+         * @param       array $sections Sections array.
28
+         *
29
+         * @return      array $plugin_options
30
+         */
31
+        public function sanitize( array $plugin_options, array $options, array $sections ): array {
32
+            $core = $this->core();
33
+
34
+            foreach ( $sections as $k => $section ) {
35
+                if ( isset( $section['fields'] ) ) {
36
+                    foreach ( $section['fields'] as $field ) {
37
+
38
+                        if ( is_array( $field ) ) {
39
+                            $field['section_id'] = $k;
40
+                        }
41
+
42
+                        if ( isset( $field['type'] ) && ( 'text' === $field['type'] || 'textarea' === $field['type'] || 'multi_text' === $field['type'] ) ) {
43
+
44
+                            // Make sure 'sanitize' field is set.
45
+                            if ( isset( $field['sanitize'] ) ) {
46
+
47
+                                // Can we make this an array of validations?
48
+                                $val_arr = array();
49
+
50
+                                if ( is_array( $field['sanitize'] ) ) {
51
+                                    $val_arr = $field['sanitize'];
52
+                                } else {
53
+                                    $val_arr[] = $field['sanitize'];
54
+                                }
55
+
56
+                                foreach ( $val_arr as $function ) {
57
+
58
+                                    // Check for empty id value.
59
+                                    if ( ! isset( $field['id'] ) || ! isset( $plugin_options[ $field['id'] ] ) || ( '' === $plugin_options[ $field['id'] ] ) ) {
60
+                                        continue;
61
+                                    }
62
+
63
+                                    if ( function_exists( $function ) ) {
64
+                                        if ( empty( $options[ $field['id'] ] ) ) {
65
+                                            $options[ $field['id'] ] = '';
66
+                                        }
67
+
68
+                                        if ( is_array( $plugin_options[ $field['id'] ] ) && ! empty( $plugin_options[ $field['id'] ] ) ) {
69
+                                            foreach ( $plugin_options[ $field['id'] ] as $key => $value ) {
70
+                                                $before = null;
71
+                                                $after  = null;
72
+
73
+                                                if ( isset( $plugin_options[ $field['id'] ][ $key ] ) && ( ! empty( $plugin_options[ $field['id'] ][ $key ] ) || '0' === $plugin_options[ $field['id'] ][ $key ] ) ) {
74
+                                                    if ( is_array( $plugin_options[ $field['id'] ][ $key ] ) ) {
75
+                                                        $before = $plugin_options[ $field['id'] ][ $key ];
76
+                                                    } else {
77
+                                                        $before = trim( $plugin_options[ $field['id'] ][ $key ] );
78
+                                                    }
79
+                                                }
80
+
81
+                                                if ( isset( $options[ $field['id'] ][ $key ] ) && ( ! empty( $plugin_options[ $field['id'] ][ $key ] ) || '0' === $plugin_options[ $field['id'] ][ $key ] ) ) {
82
+                                                    $after = $options[ $field['id'] ][ $key ];
83
+                                                }
84
+
85
+                                                $value = call_user_func( $function, $before );
86
+
87
+                                                if ( false !== $value ) {
88
+                                                    $plugin_options[ $field['id'] ][ $key ] = $value;
89
+                                                } else {
90
+                                                    unset( $plugin_options[ $field['id'] ][ $key ] );
91
+                                                }
92
+
93
+                                                $field['current'] = $value;
94
+
95
+                                                $core->sanitize[] = $field;
96
+                                            }
97
+                                        } else {
98
+                                            if ( isset( $plugin_options[ $field['id'] ] ) ) {
99
+                                                if ( is_array( $plugin_options[ $field['id'] ] ) ) {
100
+                                                    $pofi = $plugin_options[ $field['id'] ];
101
+                                                } else {
102
+                                                    $pofi = trim( $plugin_options[ $field['id'] ] );
103
+                                                }
104
+                                            } else {
105
+                                                $pofi = null;
106
+                                            }
107
+
108
+                                            $value = call_user_func( $function, $pofi );
109
+
110
+                                            $plugin_options[ $field['id'] ] = $value;
111
+
112
+                                            $field['current'] = $value;
113
+
114
+                                            $core->sanitize[] = $field;
115
+                                        }
116
+
117
+                                        break;
118
+                                    }
119
+                                }
120
+                            }
121
+                        }
122
+                    }
123
+                }
124
+            }
125
+
126
+            return $plugin_options;
127
+        }
128
+    }
129 129
 }
Please login to merge, or discard this patch.
Spacing   +18 added lines, -18 removed lines patch added patch discarded remove patch
@@ -56,38 +56,38 @@  discard block
 block discarded – undo
56 56
 								foreach ( $val_arr as $function ) {
57 57
 
58 58
 									// Check for empty id value.
59
-									if ( ! isset( $field['id'] ) || ! isset( $plugin_options[ $field['id'] ] ) || ( '' === $plugin_options[ $field['id'] ] ) ) {
59
+									if ( ! isset( $field['id'] ) || ! isset( $plugin_options[$field['id']] ) || ( '' === $plugin_options[$field['id']] ) ) {
60 60
 										continue;
61 61
 									}
62 62
 
63 63
 									if ( function_exists( $function ) ) {
64
-										if ( empty( $options[ $field['id'] ] ) ) {
65
-											$options[ $field['id'] ] = '';
64
+										if ( empty( $options[$field['id']] ) ) {
65
+											$options[$field['id']] = '';
66 66
 										}
67 67
 
68
-										if ( is_array( $plugin_options[ $field['id'] ] ) && ! empty( $plugin_options[ $field['id'] ] ) ) {
69
-											foreach ( $plugin_options[ $field['id'] ] as $key => $value ) {
68
+										if ( is_array( $plugin_options[$field['id']] ) && ! empty( $plugin_options[$field['id']] ) ) {
69
+											foreach ( $plugin_options[$field['id']] as $key => $value ) {
70 70
 												$before = null;
71 71
 												$after  = null;
72 72
 
73
-												if ( isset( $plugin_options[ $field['id'] ][ $key ] ) && ( ! empty( $plugin_options[ $field['id'] ][ $key ] ) || '0' === $plugin_options[ $field['id'] ][ $key ] ) ) {
74
-													if ( is_array( $plugin_options[ $field['id'] ][ $key ] ) ) {
75
-														$before = $plugin_options[ $field['id'] ][ $key ];
73
+												if ( isset( $plugin_options[$field['id']][$key] ) && ( ! empty( $plugin_options[$field['id']][$key] ) || '0' === $plugin_options[$field['id']][$key] ) ) {
74
+													if ( is_array( $plugin_options[$field['id']][$key] ) ) {
75
+														$before = $plugin_options[$field['id']][$key];
76 76
 													} else {
77
-														$before = trim( $plugin_options[ $field['id'] ][ $key ] );
77
+														$before = trim( $plugin_options[$field['id']][$key] );
78 78
 													}
79 79
 												}
80 80
 
81
-												if ( isset( $options[ $field['id'] ][ $key ] ) && ( ! empty( $plugin_options[ $field['id'] ][ $key ] ) || '0' === $plugin_options[ $field['id'] ][ $key ] ) ) {
82
-													$after = $options[ $field['id'] ][ $key ];
81
+												if ( isset( $options[$field['id']][$key] ) && ( ! empty( $plugin_options[$field['id']][$key] ) || '0' === $plugin_options[$field['id']][$key] ) ) {
82
+													$after = $options[$field['id']][$key];
83 83
 												}
84 84
 
85 85
 												$value = call_user_func( $function, $before );
86 86
 
87 87
 												if ( false !== $value ) {
88
-													$plugin_options[ $field['id'] ][ $key ] = $value;
88
+													$plugin_options[$field['id']][$key] = $value;
89 89
 												} else {
90
-													unset( $plugin_options[ $field['id'] ][ $key ] );
90
+													unset( $plugin_options[$field['id']][$key] );
91 91
 												}
92 92
 
93 93
 												$field['current'] = $value;
@@ -95,11 +95,11 @@  discard block
 block discarded – undo
95 95
 												$core->sanitize[] = $field;
96 96
 											}
97 97
 										} else {
98
-											if ( isset( $plugin_options[ $field['id'] ] ) ) {
99
-												if ( is_array( $plugin_options[ $field['id'] ] ) ) {
100
-													$pofi = $plugin_options[ $field['id'] ];
98
+											if ( isset( $plugin_options[$field['id']] ) ) {
99
+												if ( is_array( $plugin_options[$field['id']] ) ) {
100
+													$pofi = $plugin_options[$field['id']];
101 101
 												} else {
102
-													$pofi = trim( $plugin_options[ $field['id'] ] );
102
+													$pofi = trim( $plugin_options[$field['id']] );
103 103
 												}
104 104
 											} else {
105 105
 												$pofi = null;
@@ -107,7 +107,7 @@  discard block
 block discarded – undo
107 107
 
108 108
 											$value = call_user_func( $function, $pofi );
109 109
 
110
-											$plugin_options[ $field['id'] ] = $value;
110
+											$plugin_options[$field['id']] = $value;
111 111
 
112 112
 											$field['current'] = $value;
113 113
 
Please login to merge, or discard this patch.
redux-core/inc/classes/class-redux-functions.php 2 patches
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -136,10 +136,10 @@  discard block
 block discarded – undo
136 136
 			$result = $defaults;
137 137
 
138 138
 			foreach ( $arr as $k => $v ) {
139
-				if ( is_array( $v ) && isset( $result[ $k ] ) ) {
140
-					$result[ $k ] = self::parse_args( $v, $result[ $k ] );
139
+				if ( is_array( $v ) && isset( $result[$k] ) ) {
140
+					$result[$k] = self::parse_args( $v, $result[$k] );
141 141
 				} else {
142
-					$result[ $k ] = $v;
142
+					$result[$k] = $v;
143 143
 				}
144 144
 			}
145 145
 
@@ -534,7 +534,7 @@  discard block
 block discarded – undo
534 534
 
535 535
 			$result = preg_replace_callback(
536 536
 				'/[A-Z]/',
537
-				function ( $matches ) {
537
+				function( $matches ) {
538 538
 					return '-' . Redux_Core::strtolower( $matches[0] );
539 539
 				},
540 540
 				$keys
Please login to merge, or discard this patch.
Indentation   +356 added lines, -356 removed lines patch added patch discarded remove patch
@@ -13,360 +13,360 @@
 block discarded – undo
13 13
 // Don't duplicate me!
14 14
 if ( ! class_exists( 'Redux_Functions', false ) ) {
15 15
 
16
-	/**
17
-	 * Redux Functions Class
18
-	 * A Class of useful functions that can/should be shared among all Redux files.
19
-	 *
20
-	 * @since       3.0.0
21
-	 */
22
-	class Redux_Functions {
23
-
24
-		/**
25
-		 * ReduxFramework object pointer.
26
-		 *
27
-		 * @var object
28
-		 */
29
-		public static $parent;
30
-
31
-		/**
32
-		 * ReduxFramework shim object pointer.
33
-		 *
34
-		 * @var object
35
-		 */
36
-		public static $_parent; // phpcs:ignore PSR2.Classes.PropertyDeclaration.Underscore
37
-
38
-		/**
39
-		 * Check for the existence of class name via an array of class names.
40
-		 *
41
-		 * @param array $class_names Array of class names.
42
-		 *
43
-		 * @return string|bool
44
-		 */
45
-		public static function class_exists_ex( array $class_names = array() ) {
46
-			foreach ( $class_names as $class_name ) {
47
-				if ( class_exists( $class_name ) ) {
48
-					return $class_name;
49
-				}
50
-			}
51
-
52
-			return false;
53
-		}
54
-
55
-		/**
56
-		 * Check for the existence of file name via an array of file names.
57
-		 *
58
-		 * @param array $file_names Array of file names.
59
-		 *
60
-		 * @return string|bool
61
-		 */
62
-		public static function file_exists_ex( array $file_names = array() ) {
63
-			foreach ( $file_names as $file_name ) {
64
-				if ( file_exists( $file_name ) ) {
65
-					return $file_name;
66
-				}
67
-			}
68
-
69
-			return false;
70
-		}
71
-
72
-		/** Extract data:
73
-		 * $field = field_array
74
-		 * $value = field values
75
-		 * $core = Redux instance */
76
-
77
-		/**
78
-		 * Parse args to handle deep arrays.  The WP one does not.
79
-		 *
80
-		 * @param array|string $args     Array of args.
81
-		 * @param array        $defaults Defaults array.
82
-		 *
83
-		 * @return array
84
-		 */
85
-		public static function parse_args( $args, array $defaults ): array {
86
-			$arr = array();
87
-
88
-			if ( ! is_array( $args ) ) {
89
-				$arr[] = $args;
90
-			} else {
91
-				$arr = $args;
92
-			}
93
-
94
-			$result = $defaults;
95
-
96
-			foreach ( $arr as $k => $v ) {
97
-				if ( is_array( $v ) && isset( $result[ $k ] ) ) {
98
-					$result[ $k ] = self::parse_args( $v, $result[ $k ] );
99
-				} else {
100
-					$result[ $k ] = $v;
101
-				}
102
-			}
103
-
104
-			return $result;
105
-		}
106
-
107
-		/**
108
-		 * Deprecated: Return min tag for JS and CSS files in dev_mode.
109
-		 *
110
-		 * @deprecated No longer using camelCase naming conventions.
111
-		 *
112
-		 * @return string
113
-		 */
114
-		public static function isMin(): string { // phpcs:ignore WordPress.NamingConventions.ValidFunctionName
115
-			return self::is_min();
116
-		}
117
-
118
-		/**
119
-		 * Return min tag for JS and CSS files in dev_mode.
120
-		 *
121
-		 * @return string
122
-		 */
123
-		public static function is_min(): string {
124
-			$min      = '.min';
125
-			$dev_mode = false;
126
-
127
-			$instances = Redux::all_instances();
128
-
129
-			if ( ! empty( $instances ) ) {
130
-				foreach ( $instances as $instance ) {
131
-
132
-					if ( empty( self::$parent ) ) {
133
-						self::$parent  = $instance;
134
-						self::$_parent = self::$parent;
135
-					}
136
-					if ( ! empty( $instance->args['dev_mode'] ) ) {
137
-						$dev_mode      = true;
138
-						self::$parent  = $instance;
139
-						self::$_parent = self::$parent;
140
-					}
141
-				}
142
-				if ( $dev_mode ) {
143
-					$min = '';
144
-				}
145
-			}
146
-
147
-			return $min;
148
-		}
149
-
150
-		/**
151
-		 * Parse CSS from an output/compiler array
152
-		 *
153
-		 * @param array  $css_array CSS data.
154
-		 * @param string $style     CSS style.
155
-		 * @param string $value     CSS values.
156
-		 *
157
-		 * @return string CSS string
158
-		 * @since       3.2.8
159
-		 * @access      private
160
-		 */
161
-		public static function parse_css( array $css_array = array(), string $style = '', string $value = '' ): string {
162
-
163
-			// Something wrong happened.
164
-			if ( 0 === count( $css_array ) ) {
165
-				return '';
166
-			} else {
167
-				$css       = '';
168
-				$important = false;
169
-
170
-				if ( isset( $css_array['important'] ) && true === $css_array['important'] ) {
171
-					$important = '!important';
172
-
173
-					unset( $css_array['important'] );
174
-				}
175
-
176
-				foreach ( $css_array as $element => $selector ) {
177
-
178
-					// The old way.
179
-					if ( 0 === $element ) {
180
-						return self::the_old_way( $css_array, $style );
181
-					}
182
-
183
-					// New way continued.
184
-					$css_style = $element . ':' . $value . $important . ';';
185
-
186
-					$css .= $selector . '{' . $css_style . '}';
187
-				}
188
-			}
189
-
190
-			return $css;
191
-		}
192
-
193
-		/**
194
-		 * Parse CSS shim.
195
-		 *
196
-		 * @param array  $css_array CSS data.
197
-		 * @param string $style     CSS style.
198
-		 * @param string $value     CSS values.
199
-		 *
200
-		 * @deprecated 4.0
201
-		 *
202
-		 * @return string CSS string
203
-		 * @since       4.0.0
204
-		 * @access      public
205
-		 */
206
-		public static function parseCSS( array $css_array = array(), string $style = '', string $value = '' ): string { // phpcs:ignore WordPress.NamingConventions.ValidFunctionName
207
-			_deprecated_function( __CLASS__ . '::' . __FUNCTION__, '4.0', __CLASS__ . '::parse_css( $css_array, $style, $value )' );
208
-
209
-			return self::parse_css( $css_array, $style, $value );
210
-		}
211
-
212
-		/**
213
-		 * Parse CSS the old way, without mode options.
214
-		 *
215
-		 * @param array  $css_array CSS data.
216
-		 * @param string $style     CSS style.
217
-		 *
218
-		 * @return string
219
-		 */
220
-		private static function the_old_way( array $css_array, string $style ): string {
221
-			$keys = implode( ',', $css_array );
222
-
223
-			return $keys . '{' . $style . '}';
224
-		}
225
-
226
-		/**
227
-		 * Return s.
228
-		 *
229
-		 * @access public
230
-		 * @since 4.0.0
231
-		 * @return string
232
-		 */
233
-		public static function gs(): string {
234
-			return get_option( 're' . 'dux_p' . 'ro_lic' . 'ense_key', '' ); // phpcs:ignore Generic.Strings.UnnecessaryStringConcat.Found
235
-		}
236
-
237
-		/**
238
-		 * Deprecated Initialized the WordPress filesystem, if it already isn't.
239
-		 *
240
-		 * @since       3.2.3
241
-		 * @access      public
242
-		 * @deprecated NO longer using camelCase naming conventions.
243
-		 *
244
-		 * @return      void
245
-		 */
246
-		public static function initWpFilesystem() { // phpcs:ignore WordPress.NamingConventions.ValidFunctionName
247
-			// phpcs:ignore Squiz.Commenting.InlineComment.InvalidEndChar
248
-			_deprecated_function( __CLASS__ . '::' . __FUNCTION__, '4.0', __CLASS__ . '::init_wp_filesystem()' );
249
-
250
-			self::init_wp_filesystem();
251
-		}
252
-
253
-		/**
254
-		 * Initialized the WordPress filesystem, if it already isn't.
255
-		 *
256
-		 * @since       3.2.3
257
-		 * @access      public
258
-		 *
259
-		 * @return      void
260
-		 */
261
-		public static function init_wp_filesystem() {
262
-			global $wp_filesystem;
263
-
264
-			// Initialize the WordPress filesystem, no more using file_put_contents function.
265
-			if ( empty( $wp_filesystem ) ) {
266
-				require_once ABSPATH . '/wp-includes/pluggable.php';
267
-				require_once ABSPATH . '/wp-admin/includes/file.php';
268
-
269
-				WP_Filesystem();
270
-			}
271
-		}
272
-
273
-		/**
274
-		 * TRU.
275
-		 *
276
-		 * @param string $string .
277
-		 * @param string $opt_name .
278
-		 *
279
-		 * @deprecated Ad Remover extension no longer necessary.
280
-		 *
281
-		 * @return void
282
-		 */
283
-		public static function tru( string $string, string $opt_name ) {
284
-			_deprecated_function( __CLASS__ . '::' . __FUNCTION__, '4.0', '' );
285
-		}
286
-
287
-		/**
288
-		 * DAT.
289
-		 *
290
-		 * @param string $fname .
291
-		 * @param string $opt_name .
292
-		 *
293
-		 * @deprecated Ad Remover extension no longer necessary.
294
-		 *
295
-		 * @return void
296
-		 */
297
-		public static function dat( string $fname, string $opt_name ) {
298
-			_deprecated_function( __CLASS__ . '::' . __FUNCTION__, '4.0', '' );
299
-		}
300
-
301
-		/**
302
-		 * BUB.
303
-		 *
304
-		 * @param string $fname    .
305
-		 * @param string $opt_name .
306
-		 *
307
-		 * @deprecated Ad Remover extension no longer necessary.
308
-		 *
309
-		 * @return void
310
-		 */
311
-		public static function bub( string $fname, string $opt_name ) {
312
-			_deprecated_function( __CLASS__ . '::' . __FUNCTION__, '4.0', '' );
313
-		}
314
-
315
-		/**
316
-		 * YO.
317
-		 *
318
-		 * @param string $fname    .
319
-		 * @param string $opt_name .
320
-		 *
321
-		 * @deprecated Ad Remover extension no longer necessary.
322
-		 *
323
-		 * @return void
324
-		 */
325
-		public static function yo( string $fname, string $opt_name ) {
326
-			_deprecated_function( __CLASS__ . '::' . __FUNCTION__, '4.0', '' );
327
-		}
328
-
329
-		/**
330
-		 * Sanitize camelCase keys in an array, makes then snake_case.
331
-		 *
332
-		 * @param array $arr Array of keys.
333
-		 *
334
-		 * @return array
335
-		 */
336
-		public static function sanitize_camel_case_array_keys( array $arr ): array {
337
-			$keys   = array_keys( $arr );
338
-			$values = array_values( $arr );
339
-
340
-			$result = preg_replace_callback(
341
-				'/[A-Z]/',
342
-				function ( $matches ) {
343
-					return '-' . Redux_Core::strtolower( $matches[0] );
344
-				},
345
-				$keys
346
-			);
347
-
348
-			return array_combine( $result, $values );
349
-		}
350
-
351
-		/**
352
-		 * Converts an array into an html data string.
353
-		 *
354
-		 * @param array $data example input: array('id'=>'true').
355
-		 *
356
-		 * @return string $data_string example output: data-id='true'
357
-		 */
358
-		public static function create_data_string( array $data = array() ): string {
359
-			$data_string = '';
360
-
361
-			foreach ( $data as $key => $value ) {
362
-				if ( is_array( $value ) ) {
363
-					$value = implode( '|', $value );
364
-				}
365
-
366
-				$data_string .= ' data-' . $key . '=' . Redux_Helpers::make_bool_str( $value ) . ' ';
367
-			}
368
-
369
-			return $data_string;
370
-		}
371
-	}
16
+    /**
17
+     * Redux Functions Class
18
+     * A Class of useful functions that can/should be shared among all Redux files.
19
+     *
20
+     * @since       3.0.0
21
+     */
22
+    class Redux_Functions {
23
+
24
+        /**
25
+         * ReduxFramework object pointer.
26
+         *
27
+         * @var object
28
+         */
29
+        public static $parent;
30
+
31
+        /**
32
+         * ReduxFramework shim object pointer.
33
+         *
34
+         * @var object
35
+         */
36
+        public static $_parent; // phpcs:ignore PSR2.Classes.PropertyDeclaration.Underscore
37
+
38
+        /**
39
+         * Check for the existence of class name via an array of class names.
40
+         *
41
+         * @param array $class_names Array of class names.
42
+         *
43
+         * @return string|bool
44
+         */
45
+        public static function class_exists_ex( array $class_names = array() ) {
46
+            foreach ( $class_names as $class_name ) {
47
+                if ( class_exists( $class_name ) ) {
48
+                    return $class_name;
49
+                }
50
+            }
51
+
52
+            return false;
53
+        }
54
+
55
+        /**
56
+         * Check for the existence of file name via an array of file names.
57
+         *
58
+         * @param array $file_names Array of file names.
59
+         *
60
+         * @return string|bool
61
+         */
62
+        public static function file_exists_ex( array $file_names = array() ) {
63
+            foreach ( $file_names as $file_name ) {
64
+                if ( file_exists( $file_name ) ) {
65
+                    return $file_name;
66
+                }
67
+            }
68
+
69
+            return false;
70
+        }
71
+
72
+        /** Extract data:
73
+         * $field = field_array
74
+         * $value = field values
75
+         * $core = Redux instance */
76
+
77
+        /**
78
+         * Parse args to handle deep arrays.  The WP one does not.
79
+         *
80
+         * @param array|string $args     Array of args.
81
+         * @param array        $defaults Defaults array.
82
+         *
83
+         * @return array
84
+         */
85
+        public static function parse_args( $args, array $defaults ): array {
86
+            $arr = array();
87
+
88
+            if ( ! is_array( $args ) ) {
89
+                $arr[] = $args;
90
+            } else {
91
+                $arr = $args;
92
+            }
93
+
94
+            $result = $defaults;
95
+
96
+            foreach ( $arr as $k => $v ) {
97
+                if ( is_array( $v ) && isset( $result[ $k ] ) ) {
98
+                    $result[ $k ] = self::parse_args( $v, $result[ $k ] );
99
+                } else {
100
+                    $result[ $k ] = $v;
101
+                }
102
+            }
103
+
104
+            return $result;
105
+        }
106
+
107
+        /**
108
+         * Deprecated: Return min tag for JS and CSS files in dev_mode.
109
+         *
110
+         * @deprecated No longer using camelCase naming conventions.
111
+         *
112
+         * @return string
113
+         */
114
+        public static function isMin(): string { // phpcs:ignore WordPress.NamingConventions.ValidFunctionName
115
+            return self::is_min();
116
+        }
117
+
118
+        /**
119
+         * Return min tag for JS and CSS files in dev_mode.
120
+         *
121
+         * @return string
122
+         */
123
+        public static function is_min(): string {
124
+            $min      = '.min';
125
+            $dev_mode = false;
126
+
127
+            $instances = Redux::all_instances();
128
+
129
+            if ( ! empty( $instances ) ) {
130
+                foreach ( $instances as $instance ) {
131
+
132
+                    if ( empty( self::$parent ) ) {
133
+                        self::$parent  = $instance;
134
+                        self::$_parent = self::$parent;
135
+                    }
136
+                    if ( ! empty( $instance->args['dev_mode'] ) ) {
137
+                        $dev_mode      = true;
138
+                        self::$parent  = $instance;
139
+                        self::$_parent = self::$parent;
140
+                    }
141
+                }
142
+                if ( $dev_mode ) {
143
+                    $min = '';
144
+                }
145
+            }
146
+
147
+            return $min;
148
+        }
149
+
150
+        /**
151
+         * Parse CSS from an output/compiler array
152
+         *
153
+         * @param array  $css_array CSS data.
154
+         * @param string $style     CSS style.
155
+         * @param string $value     CSS values.
156
+         *
157
+         * @return string CSS string
158
+         * @since       3.2.8
159
+         * @access      private
160
+         */
161
+        public static function parse_css( array $css_array = array(), string $style = '', string $value = '' ): string {
162
+
163
+            // Something wrong happened.
164
+            if ( 0 === count( $css_array ) ) {
165
+                return '';
166
+            } else {
167
+                $css       = '';
168
+                $important = false;
169
+
170
+                if ( isset( $css_array['important'] ) && true === $css_array['important'] ) {
171
+                    $important = '!important';
172
+
173
+                    unset( $css_array['important'] );
174
+                }
175
+
176
+                foreach ( $css_array as $element => $selector ) {
177
+
178
+                    // The old way.
179
+                    if ( 0 === $element ) {
180
+                        return self::the_old_way( $css_array, $style );
181
+                    }
182
+
183
+                    // New way continued.
184
+                    $css_style = $element . ':' . $value . $important . ';';
185
+
186
+                    $css .= $selector . '{' . $css_style . '}';
187
+                }
188
+            }
189
+
190
+            return $css;
191
+        }
192
+
193
+        /**
194
+         * Parse CSS shim.
195
+         *
196
+         * @param array  $css_array CSS data.
197
+         * @param string $style     CSS style.
198
+         * @param string $value     CSS values.
199
+         *
200
+         * @deprecated 4.0
201
+         *
202
+         * @return string CSS string
203
+         * @since       4.0.0
204
+         * @access      public
205
+         */
206
+        public static function parseCSS( array $css_array = array(), string $style = '', string $value = '' ): string { // phpcs:ignore WordPress.NamingConventions.ValidFunctionName
207
+            _deprecated_function( __CLASS__ . '::' . __FUNCTION__, '4.0', __CLASS__ . '::parse_css( $css_array, $style, $value )' );
208
+
209
+            return self::parse_css( $css_array, $style, $value );
210
+        }
211
+
212
+        /**
213
+         * Parse CSS the old way, without mode options.
214
+         *
215
+         * @param array  $css_array CSS data.
216
+         * @param string $style     CSS style.
217
+         *
218
+         * @return string
219
+         */
220
+        private static function the_old_way( array $css_array, string $style ): string {
221
+            $keys = implode( ',', $css_array );
222
+
223
+            return $keys . '{' . $style . '}';
224
+        }
225
+
226
+        /**
227
+         * Return s.
228
+         *
229
+         * @access public
230
+         * @since 4.0.0
231
+         * @return string
232
+         */
233
+        public static function gs(): string {
234
+            return get_option( 're' . 'dux_p' . 'ro_lic' . 'ense_key', '' ); // phpcs:ignore Generic.Strings.UnnecessaryStringConcat.Found
235
+        }
236
+
237
+        /**
238
+         * Deprecated Initialized the WordPress filesystem, if it already isn't.
239
+         *
240
+         * @since       3.2.3
241
+         * @access      public
242
+         * @deprecated NO longer using camelCase naming conventions.
243
+         *
244
+         * @return      void
245
+         */
246
+        public static function initWpFilesystem() { // phpcs:ignore WordPress.NamingConventions.ValidFunctionName
247
+            // phpcs:ignore Squiz.Commenting.InlineComment.InvalidEndChar
248
+            _deprecated_function( __CLASS__ . '::' . __FUNCTION__, '4.0', __CLASS__ . '::init_wp_filesystem()' );
249
+
250
+            self::init_wp_filesystem();
251
+        }
252
+
253
+        /**
254
+         * Initialized the WordPress filesystem, if it already isn't.
255
+         *
256
+         * @since       3.2.3
257
+         * @access      public
258
+         *
259
+         * @return      void
260
+         */
261
+        public static function init_wp_filesystem() {
262
+            global $wp_filesystem;
263
+
264
+            // Initialize the WordPress filesystem, no more using file_put_contents function.
265
+            if ( empty( $wp_filesystem ) ) {
266
+                require_once ABSPATH . '/wp-includes/pluggable.php';
267
+                require_once ABSPATH . '/wp-admin/includes/file.php';
268
+
269
+                WP_Filesystem();
270
+            }
271
+        }
272
+
273
+        /**
274
+         * TRU.
275
+         *
276
+         * @param string $string .
277
+         * @param string $opt_name .
278
+         *
279
+         * @deprecated Ad Remover extension no longer necessary.
280
+         *
281
+         * @return void
282
+         */
283
+        public static function tru( string $string, string $opt_name ) {
284
+            _deprecated_function( __CLASS__ . '::' . __FUNCTION__, '4.0', '' );
285
+        }
286
+
287
+        /**
288
+         * DAT.
289
+         *
290
+         * @param string $fname .
291
+         * @param string $opt_name .
292
+         *
293
+         * @deprecated Ad Remover extension no longer necessary.
294
+         *
295
+         * @return void
296
+         */
297
+        public static function dat( string $fname, string $opt_name ) {
298
+            _deprecated_function( __CLASS__ . '::' . __FUNCTION__, '4.0', '' );
299
+        }
300
+
301
+        /**
302
+         * BUB.
303
+         *
304
+         * @param string $fname    .
305
+         * @param string $opt_name .
306
+         *
307
+         * @deprecated Ad Remover extension no longer necessary.
308
+         *
309
+         * @return void
310
+         */
311
+        public static function bub( string $fname, string $opt_name ) {
312
+            _deprecated_function( __CLASS__ . '::' . __FUNCTION__, '4.0', '' );
313
+        }
314
+
315
+        /**
316
+         * YO.
317
+         *
318
+         * @param string $fname    .
319
+         * @param string $opt_name .
320
+         *
321
+         * @deprecated Ad Remover extension no longer necessary.
322
+         *
323
+         * @return void
324
+         */
325
+        public static function yo( string $fname, string $opt_name ) {
326
+            _deprecated_function( __CLASS__ . '::' . __FUNCTION__, '4.0', '' );
327
+        }
328
+
329
+        /**
330
+         * Sanitize camelCase keys in an array, makes then snake_case.
331
+         *
332
+         * @param array $arr Array of keys.
333
+         *
334
+         * @return array
335
+         */
336
+        public static function sanitize_camel_case_array_keys( array $arr ): array {
337
+            $keys   = array_keys( $arr );
338
+            $values = array_values( $arr );
339
+
340
+            $result = preg_replace_callback(
341
+                '/[A-Z]/',
342
+                function ( $matches ) {
343
+                    return '-' . Redux_Core::strtolower( $matches[0] );
344
+                },
345
+                $keys
346
+            );
347
+
348
+            return array_combine( $result, $values );
349
+        }
350
+
351
+        /**
352
+         * Converts an array into an html data string.
353
+         *
354
+         * @param array $data example input: array('id'=>'true').
355
+         *
356
+         * @return string $data_string example output: data-id='true'
357
+         */
358
+        public static function create_data_string( array $data = array() ): string {
359
+            $data_string = '';
360
+
361
+            foreach ( $data as $key => $value ) {
362
+                if ( is_array( $value ) ) {
363
+                    $value = implode( '|', $value );
364
+                }
365
+
366
+                $data_string .= ' data-' . $key . '=' . Redux_Helpers::make_bool_str( $value ) . ' ';
367
+            }
368
+
369
+            return $data_string;
370
+        }
371
+    }
372 372
 }
Please login to merge, or discard this patch.
redux-core/inc/fields/checkbox/class-redux-checkbox.php 2 patches
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -59,8 +59,8 @@  discard block
 block discarded – undo
59 59
 
60 60
 				foreach ( $this->field['options'] as $k => $v ) {
61 61
 
62
-					if ( empty( $this->value[ $k ] ) ) {
63
-						$this->value[ $k ] = '';
62
+					if ( empty( $this->value[$k] ) ) {
63
+						$this->value[$k] = '';
64 64
 					}
65 65
 
66 66
 					echo '<li>';
@@ -77,8 +77,8 @@  discard block
 block discarded – undo
77 77
 					$id      = $ident_1 . '_' . $ident_2;
78 78
 
79 79
 					echo '<label for="' . esc_attr( $id ) . '">';
80
-					echo '<input type="hidden" class="checkbox-check" data-val="1" name="' . esc_attr( $this->field['name'] . $this->field['name_suffix'] . '[' . $k . ']' ) . '" value="' . esc_attr( $this->value[ $k ] ) . '"/>';
81
-					echo '<input type="checkbox" class="checkbox ' . esc_attr( $this->field['class'] ) . '" id="' . esc_attr( $id ) . '" value="1" ' . checked( $this->value[ $k ], '1', false ) . '/>';
80
+					echo '<input type="hidden" class="checkbox-check" data-val="1" name="' . esc_attr( $this->field['name'] . $this->field['name_suffix'] . '[' . $k . ']' ) . '" value="' . esc_attr( $this->value[$k] ) . '"/>';
81
+					echo '<input type="checkbox" class="checkbox ' . esc_attr( $this->field['class'] ) . '" id="' . esc_attr( $id ) . '" value="1" ' . checked( $this->value[$k], '1', false ) . '/>';
82 82
 					echo ' ' . esc_attr( $v ) . '</label>';
83 83
 					echo '</li>';
84 84
 				}
Please login to merge, or discard this patch.
Indentation   +129 added lines, -129 removed lines patch added patch discarded remove patch
@@ -12,135 +12,135 @@
 block discarded – undo
12 12
 // Don't duplicate me!
13 13
 if ( ! class_exists( 'Redux_Checkbox', false ) ) {
14 14
 
15
-	/**
16
-	 * Main Redux_checkbox class
17
-	 *
18
-	 * @since       1.0.0
19
-	 */
20
-	class Redux_Checkbox extends Redux_Field {
21
-
22
-		/**
23
-		 * Field Render Function.
24
-		 * Takes the vars and outputs the HTML for the field in the settings
25
-		 *
26
-		 * @since       1.0.0
27
-		 * @access      public
28
-		 * @return      void
29
-		 */
30
-		public function render() {
31
-			if ( ! empty( $this->field['data'] ) && empty( $this->field['options'] ) ) {
32
-				if ( empty( $this->field['args'] ) ) {
33
-					$this->field['args'] = array();
34
-				}
35
-
36
-				$this->field['options'] = $this->parent->wordpress_data->get( $this->field['data'], $this->field['args'], $this->parent->args['opt_name'], $this->value );
37
-				if ( empty( $this->field['options'] ) ) {
38
-					return;
39
-				}
40
-			}
41
-
42
-			$this->field['data_class'] = ( isset( $this->field['multi_layout'] ) ) ? 'data-' . $this->field['multi_layout'] : 'data-full';
43
-
44
-			if ( ! empty( $this->field['options'] ) && ( is_array( $this->field['options'] ) || is_array( $this->field['default'] ) ) ) {
45
-
46
-				echo '<ul class="' . esc_attr( $this->field['data_class'] ) . '">';
47
-
48
-				if ( ! isset( $this->value ) ) {
49
-					$this->value = array();
50
-				}
51
-
52
-				if ( ! is_array( $this->value ) ) {
53
-					$this->value = array();
54
-				}
55
-
56
-				if ( empty( $this->field['options'] ) && isset( $this->field['default'] ) && is_array( $this->field['default'] ) ) {
57
-					$this->field['options'] = $this->field['default'];
58
-				}
59
-
60
-				foreach ( $this->field['options'] as $k => $v ) {
61
-
62
-					if ( empty( $this->value[ $k ] ) ) {
63
-						$this->value[ $k ] = '';
64
-					}
65
-
66
-					echo '<li>';
67
-
68
-					$ident_1 = strtr(
69
-						$this->parent->args['opt_name'] . '[' . $this->field['id'] . '][' . $k . ']',
70
-						array(
71
-							'[' => '_',
72
-							']' => '',
73
-						)
74
-					);
75
-
76
-					$ident_2 = array_search( $k, array_keys( $this->field['options'] ), true );
77
-					$id      = $ident_1 . '_' . $ident_2;
78
-
79
-					echo '<label for="' . esc_attr( $id ) . '">';
80
-					echo '<input type="hidden" class="checkbox-check" data-val="1" name="' . esc_attr( $this->field['name'] . $this->field['name_suffix'] . '[' . $k . ']' ) . '" value="' . esc_attr( $this->value[ $k ] ) . '"/>';
81
-					echo '<input type="checkbox" class="checkbox ' . esc_attr( $this->field['class'] ) . '" id="' . esc_attr( $id ) . '" value="1" ' . checked( $this->value[ $k ], '1', false ) . '/>';
82
-					echo ' ' . esc_attr( $v ) . '</label>';
83
-					echo '</li>';
84
-				}
85
-
86
-				echo '</ul>';
87
-			} elseif ( empty( $this->field['data'] ) ) {
88
-				echo '<ul class="data-full">';
89
-				echo '<li>';
90
-
91
-				if ( ! empty( $this->field['label'] ) ) {
92
-					echo '<label>';
93
-				}
94
-
95
-				$ident_1 = strtr(
96
-					$this->parent->args['opt_name'] . '[' . $this->field['id'] . ']',
97
-					array(
98
-						'[' => '_',
99
-						']' => '',
100
-					)
101
-				);
102
-
103
-				// Got the "Checked" status as "0" or "1" then insert it as the "value" option.
104
-				echo '<input type="hidden" class="checkbox-check" data-val="1" name="' . esc_attr( $this->field['name'] . $this->field['name_suffix'] ) . '" value="' . esc_attr( $this->value ) . '"/>';
105
-				echo '<input type="checkbox" id="' . esc_attr( $ident_1 ) . '" value="1" class="checkbox ' . esc_attr( $this->field['class'] ) . '" ' . checked( $this->value, '1', false ) . '/>';
106
-
107
-				if ( ! empty( $this->field['label'] ) ) {
108
-					echo ' ' . esc_html( $this->field['label'] );
109
-					echo '</label>';
110
-				}
111
-
112
-				echo '</li>';
113
-				echo '</ul>';
114
-			}
115
-		}
116
-
117
-		/**
118
-		 * Enqueue Function.
119
-		 * If this field requires any scripts, or css define this function and register/enqueue the scripts/css
120
-		 *
121
-		 * @since       1.0.0
122
-		 * @access      public
123
-		 * @return      void
124
-		 */
125
-		public function enqueue() {
126
-			if ( $this->parent->args['dev_mode'] ) {
127
-				wp_enqueue_style(
128
-					'redux-field-checkbox',
129
-					Redux_Core::$url . 'inc/fields/checkbox/redux-checkbox.css',
130
-					array(),
131
-					$this->timestamp
132
-				);
133
-			}
134
-
135
-			wp_enqueue_script(
136
-				'redux-field-checkbox',
137
-				Redux_Core::$url . 'inc/fields/checkbox/redux-checkbox' . Redux_Functions::is_min() . '.js',
138
-				array( 'jquery', 'redux-js' ),
139
-				$this->timestamp,
140
-				true
141
-			);
142
-		}
143
-	}
15
+    /**
16
+     * Main Redux_checkbox class
17
+     *
18
+     * @since       1.0.0
19
+     */
20
+    class Redux_Checkbox extends Redux_Field {
21
+
22
+        /**
23
+         * Field Render Function.
24
+         * Takes the vars and outputs the HTML for the field in the settings
25
+         *
26
+         * @since       1.0.0
27
+         * @access      public
28
+         * @return      void
29
+         */
30
+        public function render() {
31
+            if ( ! empty( $this->field['data'] ) && empty( $this->field['options'] ) ) {
32
+                if ( empty( $this->field['args'] ) ) {
33
+                    $this->field['args'] = array();
34
+                }
35
+
36
+                $this->field['options'] = $this->parent->wordpress_data->get( $this->field['data'], $this->field['args'], $this->parent->args['opt_name'], $this->value );
37
+                if ( empty( $this->field['options'] ) ) {
38
+                    return;
39
+                }
40
+            }
41
+
42
+            $this->field['data_class'] = ( isset( $this->field['multi_layout'] ) ) ? 'data-' . $this->field['multi_layout'] : 'data-full';
43
+
44
+            if ( ! empty( $this->field['options'] ) && ( is_array( $this->field['options'] ) || is_array( $this->field['default'] ) ) ) {
45
+
46
+                echo '<ul class="' . esc_attr( $this->field['data_class'] ) . '">';
47
+
48
+                if ( ! isset( $this->value ) ) {
49
+                    $this->value = array();
50
+                }
51
+
52
+                if ( ! is_array( $this->value ) ) {
53
+                    $this->value = array();
54
+                }
55
+
56
+                if ( empty( $this->field['options'] ) && isset( $this->field['default'] ) && is_array( $this->field['default'] ) ) {
57
+                    $this->field['options'] = $this->field['default'];
58
+                }
59
+
60
+                foreach ( $this->field['options'] as $k => $v ) {
61
+
62
+                    if ( empty( $this->value[ $k ] ) ) {
63
+                        $this->value[ $k ] = '';
64
+                    }
65
+
66
+                    echo '<li>';
67
+
68
+                    $ident_1 = strtr(
69
+                        $this->parent->args['opt_name'] . '[' . $this->field['id'] . '][' . $k . ']',
70
+                        array(
71
+                            '[' => '_',
72
+                            ']' => '',
73
+                        )
74
+                    );
75
+
76
+                    $ident_2 = array_search( $k, array_keys( $this->field['options'] ), true );
77
+                    $id      = $ident_1 . '_' . $ident_2;
78
+
79
+                    echo '<label for="' . esc_attr( $id ) . '">';
80
+                    echo '<input type="hidden" class="checkbox-check" data-val="1" name="' . esc_attr( $this->field['name'] . $this->field['name_suffix'] . '[' . $k . ']' ) . '" value="' . esc_attr( $this->value[ $k ] ) . '"/>';
81
+                    echo '<input type="checkbox" class="checkbox ' . esc_attr( $this->field['class'] ) . '" id="' . esc_attr( $id ) . '" value="1" ' . checked( $this->value[ $k ], '1', false ) . '/>';
82
+                    echo ' ' . esc_attr( $v ) . '</label>';
83
+                    echo '</li>';
84
+                }
85
+
86
+                echo '</ul>';
87
+            } elseif ( empty( $this->field['data'] ) ) {
88
+                echo '<ul class="data-full">';
89
+                echo '<li>';
90
+
91
+                if ( ! empty( $this->field['label'] ) ) {
92
+                    echo '<label>';
93
+                }
94
+
95
+                $ident_1 = strtr(
96
+                    $this->parent->args['opt_name'] . '[' . $this->field['id'] . ']',
97
+                    array(
98
+                        '[' => '_',
99
+                        ']' => '',
100
+                    )
101
+                );
102
+
103
+                // Got the "Checked" status as "0" or "1" then insert it as the "value" option.
104
+                echo '<input type="hidden" class="checkbox-check" data-val="1" name="' . esc_attr( $this->field['name'] . $this->field['name_suffix'] ) . '" value="' . esc_attr( $this->value ) . '"/>';
105
+                echo '<input type="checkbox" id="' . esc_attr( $ident_1 ) . '" value="1" class="checkbox ' . esc_attr( $this->field['class'] ) . '" ' . checked( $this->value, '1', false ) . '/>';
106
+
107
+                if ( ! empty( $this->field['label'] ) ) {
108
+                    echo ' ' . esc_html( $this->field['label'] );
109
+                    echo '</label>';
110
+                }
111
+
112
+                echo '</li>';
113
+                echo '</ul>';
114
+            }
115
+        }
116
+
117
+        /**
118
+         * Enqueue Function.
119
+         * If this field requires any scripts, or css define this function and register/enqueue the scripts/css
120
+         *
121
+         * @since       1.0.0
122
+         * @access      public
123
+         * @return      void
124
+         */
125
+        public function enqueue() {
126
+            if ( $this->parent->args['dev_mode'] ) {
127
+                wp_enqueue_style(
128
+                    'redux-field-checkbox',
129
+                    Redux_Core::$url . 'inc/fields/checkbox/redux-checkbox.css',
130
+                    array(),
131
+                    $this->timestamp
132
+                );
133
+            }
134
+
135
+            wp_enqueue_script(
136
+                'redux-field-checkbox',
137
+                Redux_Core::$url . 'inc/fields/checkbox/redux-checkbox' . Redux_Functions::is_min() . '.js',
138
+                array( 'jquery', 'redux-js' ),
139
+                $this->timestamp,
140
+                true
141
+            );
142
+        }
143
+    }
144 144
 }
145 145
 
146 146
 class_alias( 'Redux_Checkbox', 'ReduxFramework_Checkbox' );
Please login to merge, or discard this patch.
redux-core/inc/fields/sorter/class-redux-sorter.php 2 patches
Spacing   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -33,9 +33,9 @@  discard block
 block discarded – undo
33 33
 						$slug = Redux_Core::strtolower( $name );
34 34
 						$slug = str_replace( ' ', '-', $slug );
35 35
 
36
-						$new_arr[ $slug ] = $name;
36
+						$new_arr[$slug] = $name;
37 37
 					} else {
38
-						$new_arr[ $id ] = $name;
38
+						$new_arr[$id] = $name;
39 39
 					}
40 40
 				}
41 41
 			}
@@ -78,7 +78,7 @@  discard block
 block discarded – undo
78 78
 			}
79 79
 
80 80
 			if ( isset( $this->field['data'] ) ) {
81
-				$this->field['options'] = $this->parent->options_defaults[ $this->field['id'] ];
81
+				$this->field['options'] = $this->parent->options_defaults[$this->field['id']];
82 82
 			}
83 83
 
84 84
 			$this->field['repeater_id'] = $this->field['repeater_id'] ?? '';
@@ -105,8 +105,8 @@  discard block
 block discarded – undo
105 105
 			if ( ! empty( $sortlists ) ) {
106 106
 				foreach ( $sortlists as $section => $arr ) {
107 107
 					$arr                     = $this->replace_id_with_slug( $arr );
108
-					$sortlists[ $section ]   = $arr;
109
-					$this->value[ $section ] = $arr;
108
+					$sortlists[$section]   = $arr;
109
+					$this->value[$section] = $arr;
110 110
 				}
111 111
 			}
112 112
 
@@ -122,9 +122,9 @@  discard block
 block discarded – undo
122 122
 					if ( ! empty( $temp2 ) ) {
123 123
 						if ( ! array_key_exists( $k, $temp2 ) ) {
124 124
 							if ( isset( $sortlists['Disabled'] ) ) {
125
-								$sortlists['Disabled'][ $k ] = $v;
125
+								$sortlists['Disabled'][$k] = $v;
126 126
 							} else {
127
-								$sortlists['disabled'][ $k ] = $v;
127
+								$sortlists['disabled'][$k] = $v;
128 128
 							}
129 129
 						}
130 130
 					}
@@ -138,18 +138,18 @@  discard block
 block discarded – undo
138 138
 						// k = id.
139 139
 						// v = name.
140 140
 						if ( ! array_key_exists( $k, $temp ) ) {
141
-							unset( $sortlist[ $k ] );
141
+							unset( $sortlist[$k] );
142 142
 						}
143 143
 					}
144
-					$sortlists[ $key ] = $sortlist;
144
+					$sortlists[$key] = $sortlist;
145 145
 				}
146 146
 
147 147
 				// assuming all synced, now get the correct naming for each block.
148 148
 				foreach ( $sortlists as $key => $sortlist ) {
149 149
 					foreach ( $sortlist as $k => $v ) {
150
-						$sortlist[ $k ] = $temp[ $k ];
150
+						$sortlist[$k] = $temp[$k];
151 151
 					}
152
-					$sortlists[ $key ] = $sortlist;
152
+					$sortlists[$key] = $sortlist;
153 153
 				}
154 154
 
155 155
 				if ( $sortlists ) {
@@ -158,7 +158,7 @@  discard block
 block discarded – undo
158 158
 					foreach ( $sortlists as $group => $sortlist ) {
159 159
 						$filled = '';
160 160
 
161
-						if ( isset( $this->field['limits'][ $group ] ) && count( $sortlist ) >= $this->field['limits'][ $group ] ) {
161
+						if ( isset( $this->field['limits'][$group] ) && count( $sortlist ) >= $this->field['limits'][$group] ) {
162 162
 							$filled = ' filled';
163 163
 						}
164 164
 
Please login to merge, or discard this patch.
Indentation   +223 added lines, -223 removed lines patch added patch discarded remove patch
@@ -11,234 +11,234 @@
 block discarded – undo
11 11
 
12 12
 if ( ! class_exists( 'Redux_Sorter', false ) ) {
13 13
 
14
-	/**
15
-	 * Class Redux_Sorter
16
-	 */
17
-	class Redux_Sorter extends Redux_Field {
18
-
19
-		/**
20
-		 * Replaced ID with slag.
21
-		 *
22
-		 * @param array $arr .
23
-		 *
24
-		 * @return array
25
-		 */
26
-		private function replace_id_with_slug( array $arr ): array {
27
-			$new_arr = array();
28
-
29
-			if ( ! empty( $arr ) ) {
30
-				foreach ( $arr as $id => $name ) {
31
-
32
-					if ( is_numeric( $id ) ) {
33
-						$slug = Redux_Core::strtolower( $name );
34
-						$slug = str_replace( ' ', '-', $slug );
35
-
36
-						$new_arr[ $slug ] = $name;
37
-					} else {
38
-						$new_arr[ $id ] = $name;
39
-					}
40
-				}
41
-			}
42
-
43
-			return $new_arr;
44
-		}
45
-
46
-		/**
47
-		 * Check for empty value.
48
-		 *
49
-		 * @param mixed $val Value to check.
50
-		 *
51
-		 * @return bool
52
-		 */
53
-		private function is_value_empty( $val ): bool {
54
-			if ( ! empty( $val ) ) {
55
-				foreach ( $val as $arr ) {
56
-					if ( ! empty( $arr ) ) {
57
-						return false;
58
-					}
59
-				}
60
-			}
61
-
62
-			return true;
63
-		}
64
-
65
-		/**
66
-		 * Field Render Function.
67
-		 * Takes the vars and outputs the HTML for the field in the settings
68
-		 *
69
-		 * @since 1.0.0
70
-		 */
71
-		public function render() {
72
-			if ( ! is_array( $this->value ) && isset( $this->field['options'] ) ) {
73
-				$this->value = $this->field['options'];
74
-			}
75
-
76
-			if ( ! isset( $this->field['args'] ) ) {
77
-				$this->field['args'] = array();
78
-			}
79
-
80
-			if ( isset( $this->field['data'] ) ) {
81
-				$this->field['options'] = $this->parent->options_defaults[ $this->field['id'] ];
82
-			}
83
-
84
-			$this->field['repeater_id'] = $this->field['repeater_id'] ?? '';
85
-
86
-			// Make sure to get list of all the default blocks first.
87
-			$all_blocks = ! empty( $this->field['options'] ) ? $this->field['options'] : array();
88
-			$temp       = array(); // holds default blocks.
89
-			$temp2      = array(); // holds saved blocks.
90
-
91
-			foreach ( $all_blocks as $blocks ) {
92
-				$temp = array_merge( $temp, $blocks );
93
-			}
94
-
95
-			$temp = $this->replace_id_with_slug( $temp );
96
-
97
-			if ( $this->is_value_empty( $this->value ) ) {
98
-				if ( ! empty( $this->field['options'] ) ) {
99
-					$this->value = $this->field['options'];
100
-				}
101
-			}
102
-
103
-			$sortlists = $this->value;
104
-
105
-			if ( ! empty( $sortlists ) ) {
106
-				foreach ( $sortlists as $section => $arr ) {
107
-					$arr                     = $this->replace_id_with_slug( $arr );
108
-					$sortlists[ $section ]   = $arr;
109
-					$this->value[ $section ] = $arr;
110
-				}
111
-			}
112
-
113
-			if ( is_array( $sortlists ) ) {
114
-				foreach ( $sortlists as $sortlist ) {
115
-					$temp2 = array_merge( $temp2, $sortlist );
116
-				}
117
-
118
-				// now let's compare if we have anything missing.
119
-				foreach ( $temp as $k => $v ) {
120
-					// k = id/slug.
121
-					// v = name.
122
-					if ( ! empty( $temp2 ) ) {
123
-						if ( ! array_key_exists( $k, $temp2 ) ) {
124
-							if ( isset( $sortlists['Disabled'] ) ) {
125
-								$sortlists['Disabled'][ $k ] = $v;
126
-							} else {
127
-								$sortlists['disabled'][ $k ] = $v;
128
-							}
129
-						}
130
-					}
131
-				}
132
-
133
-				// now check if saved blocks has blocks not registered under default blocks.
134
-				foreach ( $sortlists as $key => $sortlist ) {
135
-					// key = enabled, disabled, backup.
136
-					// sortlist = id => name.
137
-					foreach ( $sortlist as $k => $v ) {
138
-						// k = id.
139
-						// v = name.
140
-						if ( ! array_key_exists( $k, $temp ) ) {
141
-							unset( $sortlist[ $k ] );
142
-						}
143
-					}
144
-					$sortlists[ $key ] = $sortlist;
145
-				}
146
-
147
-				// assuming all synced, now get the correct naming for each block.
148
-				foreach ( $sortlists as $key => $sortlist ) {
149
-					foreach ( $sortlist as $k => $v ) {
150
-						$sortlist[ $k ] = $temp[ $k ];
151
-					}
152
-					$sortlists[ $key ] = $sortlist;
153
-				}
154
-
155
-				if ( $sortlists ) {
156
-					echo '<fieldset id="' . esc_attr( $this->field['id'] ) . '" class="redux-sorter-container redux-sorter ' . esc_attr( $this->field['class'] ) . '">';
157
-
158
-					foreach ( $sortlists as $group => $sortlist ) {
159
-						$filled = '';
160
-
161
-						if ( isset( $this->field['limits'][ $group ] ) && count( $sortlist ) >= $this->field['limits'][ $group ] ) {
162
-							$filled = ' filled';
163
-						}
164
-
165
-						echo '<ul id="' . esc_attr( $this->field['id'] . '_' . $group ) . '" class="sortlist_' . esc_attr( $this->field['id'] . $filled ) . '" data-id="' . esc_attr( $this->field['id'] ) . '" data-repeater-id="' . esc_attr( $this->field['repeater_id'] ) . '" data-suffix="' . esc_attr( $this->field['name_suffix'] ) . '" data-group-id="' . esc_attr( $group ) . '">';
166
-						echo '<h3>' . esc_html( $group ) . '</h3>';
167
-
168
-						if ( ! isset( $sortlist['placebo'] ) ) {
169
-							$sortlist['placebo'] = 'placebo';
170
-						}
171
-
172
-						foreach ( $sortlist as $key => $list ) {
173
-							echo '<input
14
+    /**
15
+     * Class Redux_Sorter
16
+     */
17
+    class Redux_Sorter extends Redux_Field {
18
+
19
+        /**
20
+         * Replaced ID with slag.
21
+         *
22
+         * @param array $arr .
23
+         *
24
+         * @return array
25
+         */
26
+        private function replace_id_with_slug( array $arr ): array {
27
+            $new_arr = array();
28
+
29
+            if ( ! empty( $arr ) ) {
30
+                foreach ( $arr as $id => $name ) {
31
+
32
+                    if ( is_numeric( $id ) ) {
33
+                        $slug = Redux_Core::strtolower( $name );
34
+                        $slug = str_replace( ' ', '-', $slug );
35
+
36
+                        $new_arr[ $slug ] = $name;
37
+                    } else {
38
+                        $new_arr[ $id ] = $name;
39
+                    }
40
+                }
41
+            }
42
+
43
+            return $new_arr;
44
+        }
45
+
46
+        /**
47
+         * Check for empty value.
48
+         *
49
+         * @param mixed $val Value to check.
50
+         *
51
+         * @return bool
52
+         */
53
+        private function is_value_empty( $val ): bool {
54
+            if ( ! empty( $val ) ) {
55
+                foreach ( $val as $arr ) {
56
+                    if ( ! empty( $arr ) ) {
57
+                        return false;
58
+                    }
59
+                }
60
+            }
61
+
62
+            return true;
63
+        }
64
+
65
+        /**
66
+         * Field Render Function.
67
+         * Takes the vars and outputs the HTML for the field in the settings
68
+         *
69
+         * @since 1.0.0
70
+         */
71
+        public function render() {
72
+            if ( ! is_array( $this->value ) && isset( $this->field['options'] ) ) {
73
+                $this->value = $this->field['options'];
74
+            }
75
+
76
+            if ( ! isset( $this->field['args'] ) ) {
77
+                $this->field['args'] = array();
78
+            }
79
+
80
+            if ( isset( $this->field['data'] ) ) {
81
+                $this->field['options'] = $this->parent->options_defaults[ $this->field['id'] ];
82
+            }
83
+
84
+            $this->field['repeater_id'] = $this->field['repeater_id'] ?? '';
85
+
86
+            // Make sure to get list of all the default blocks first.
87
+            $all_blocks = ! empty( $this->field['options'] ) ? $this->field['options'] : array();
88
+            $temp       = array(); // holds default blocks.
89
+            $temp2      = array(); // holds saved blocks.
90
+
91
+            foreach ( $all_blocks as $blocks ) {
92
+                $temp = array_merge( $temp, $blocks );
93
+            }
94
+
95
+            $temp = $this->replace_id_with_slug( $temp );
96
+
97
+            if ( $this->is_value_empty( $this->value ) ) {
98
+                if ( ! empty( $this->field['options'] ) ) {
99
+                    $this->value = $this->field['options'];
100
+                }
101
+            }
102
+
103
+            $sortlists = $this->value;
104
+
105
+            if ( ! empty( $sortlists ) ) {
106
+                foreach ( $sortlists as $section => $arr ) {
107
+                    $arr                     = $this->replace_id_with_slug( $arr );
108
+                    $sortlists[ $section ]   = $arr;
109
+                    $this->value[ $section ] = $arr;
110
+                }
111
+            }
112
+
113
+            if ( is_array( $sortlists ) ) {
114
+                foreach ( $sortlists as $sortlist ) {
115
+                    $temp2 = array_merge( $temp2, $sortlist );
116
+                }
117
+
118
+                // now let's compare if we have anything missing.
119
+                foreach ( $temp as $k => $v ) {
120
+                    // k = id/slug.
121
+                    // v = name.
122
+                    if ( ! empty( $temp2 ) ) {
123
+                        if ( ! array_key_exists( $k, $temp2 ) ) {
124
+                            if ( isset( $sortlists['Disabled'] ) ) {
125
+                                $sortlists['Disabled'][ $k ] = $v;
126
+                            } else {
127
+                                $sortlists['disabled'][ $k ] = $v;
128
+                            }
129
+                        }
130
+                    }
131
+                }
132
+
133
+                // now check if saved blocks has blocks not registered under default blocks.
134
+                foreach ( $sortlists as $key => $sortlist ) {
135
+                    // key = enabled, disabled, backup.
136
+                    // sortlist = id => name.
137
+                    foreach ( $sortlist as $k => $v ) {
138
+                        // k = id.
139
+                        // v = name.
140
+                        if ( ! array_key_exists( $k, $temp ) ) {
141
+                            unset( $sortlist[ $k ] );
142
+                        }
143
+                    }
144
+                    $sortlists[ $key ] = $sortlist;
145
+                }
146
+
147
+                // assuming all synced, now get the correct naming for each block.
148
+                foreach ( $sortlists as $key => $sortlist ) {
149
+                    foreach ( $sortlist as $k => $v ) {
150
+                        $sortlist[ $k ] = $temp[ $k ];
151
+                    }
152
+                    $sortlists[ $key ] = $sortlist;
153
+                }
154
+
155
+                if ( $sortlists ) {
156
+                    echo '<fieldset id="' . esc_attr( $this->field['id'] ) . '" class="redux-sorter-container redux-sorter ' . esc_attr( $this->field['class'] ) . '">';
157
+
158
+                    foreach ( $sortlists as $group => $sortlist ) {
159
+                        $filled = '';
160
+
161
+                        if ( isset( $this->field['limits'][ $group ] ) && count( $sortlist ) >= $this->field['limits'][ $group ] ) {
162
+                            $filled = ' filled';
163
+                        }
164
+
165
+                        echo '<ul id="' . esc_attr( $this->field['id'] . '_' . $group ) . '" class="sortlist_' . esc_attr( $this->field['id'] . $filled ) . '" data-id="' . esc_attr( $this->field['id'] ) . '" data-repeater-id="' . esc_attr( $this->field['repeater_id'] ) . '" data-suffix="' . esc_attr( $this->field['name_suffix'] ) . '" data-group-id="' . esc_attr( $group ) . '">';
166
+                        echo '<h3>' . esc_html( $group ) . '</h3>';
167
+
168
+                        if ( ! isset( $sortlist['placebo'] ) ) {
169
+                            $sortlist['placebo'] = 'placebo';
170
+                        }
171
+
172
+                        foreach ( $sortlist as $key => $list ) {
173
+                            echo '<input
174 174
 									class="sorter-placebo"
175 175
 									type="hidden"
176 176
 									name="' . esc_attr( $this->field['name'] ) . esc_attr( $this->field['name_suffix'] ) . '[' . esc_html( $group ) . '][placebo]"
177 177
 									value="placebo">';
178 178
 
179
-							if ( 'placebo' !== $key ) {
180
-								echo '<li id="sortee-' . esc_attr( $key ) . '" class="sortee" data-id="' . esc_attr( $key ) . '">';
181
-								echo '<input class="position ' . esc_attr( $this->field['class'] ) . '" type="hidden" name="' . esc_attr( $this->field['name'] . $this->field['name_suffix'] . '[' . $group . '][' . $key . ']' ) . '" value="' . esc_attr( $list ) . '">';
182
-								echo esc_html( $list );
183
-								echo '</li>';
184
-							}
185
-						}
186
-
187
-						echo '</ul>';
188
-					}
189
-
190
-					echo '</fieldset>';
191
-				}
192
-			}
193
-		}
194
-
195
-		/**
196
-		 * Enqueue scripts and styles.
197
-		 */
198
-		public function enqueue() {
199
-			if ( $this->parent->args['dev_mode'] ) {
200
-				wp_enqueue_style(
201
-					'redux-field-sorter',
202
-					Redux_Core::$url . 'inc/fields/sorter/redux-sorter.css',
203
-					array(),
204
-					$this->timestamp
205
-				);
206
-			}
207
-
208
-			wp_enqueue_script(
209
-				'redux-field-sorter',
210
-				Redux_Core::$url . 'inc/fields/sorter/redux-sorter' . Redux_Functions::is_min() . '.js',
211
-				array( 'jquery', 'redux-js', 'jquery-ui-sortable' ),
212
-				$this->timestamp,
213
-				true
214
-			);
215
-		}
216
-
217
-		/**
218
-		 * Functions to pass data from the PHP to the JS at render time.
219
-		 *
220
-		 * @param array  $field Field values.
221
-		 * @param string $value Option values.
222
-		 *
223
-		 * @return array Params to be saved as a javascript object accessible to the UI.
224
-		 * @since  Redux_Framework 3.1.5
225
-		 */
226
-		public function localize( array $field, string $value = '' ): array {
227
-			$params = array();
228
-
229
-			if ( ! empty( $field['limits'] ) ) {
230
-				$params['limits'] = $field['limits'];
231
-			}
232
-
233
-			if ( empty( $value ) ) {
234
-				$value = $this->value;
235
-			}
236
-
237
-			$params['val'] = $value;
238
-
239
-			return $params;
240
-		}
241
-	}
179
+                            if ( 'placebo' !== $key ) {
180
+                                echo '<li id="sortee-' . esc_attr( $key ) . '" class="sortee" data-id="' . esc_attr( $key ) . '">';
181
+                                echo '<input class="position ' . esc_attr( $this->field['class'] ) . '" type="hidden" name="' . esc_attr( $this->field['name'] . $this->field['name_suffix'] . '[' . $group . '][' . $key . ']' ) . '" value="' . esc_attr( $list ) . '">';
182
+                                echo esc_html( $list );
183
+                                echo '</li>';
184
+                            }
185
+                        }
186
+
187
+                        echo '</ul>';
188
+                    }
189
+
190
+                    echo '</fieldset>';
191
+                }
192
+            }
193
+        }
194
+
195
+        /**
196
+         * Enqueue scripts and styles.
197
+         */
198
+        public function enqueue() {
199
+            if ( $this->parent->args['dev_mode'] ) {
200
+                wp_enqueue_style(
201
+                    'redux-field-sorter',
202
+                    Redux_Core::$url . 'inc/fields/sorter/redux-sorter.css',
203
+                    array(),
204
+                    $this->timestamp
205
+                );
206
+            }
207
+
208
+            wp_enqueue_script(
209
+                'redux-field-sorter',
210
+                Redux_Core::$url . 'inc/fields/sorter/redux-sorter' . Redux_Functions::is_min() . '.js',
211
+                array( 'jquery', 'redux-js', 'jquery-ui-sortable' ),
212
+                $this->timestamp,
213
+                true
214
+            );
215
+        }
216
+
217
+        /**
218
+         * Functions to pass data from the PHP to the JS at render time.
219
+         *
220
+         * @param array  $field Field values.
221
+         * @param string $value Option values.
222
+         *
223
+         * @return array Params to be saved as a javascript object accessible to the UI.
224
+         * @since  Redux_Framework 3.1.5
225
+         */
226
+        public function localize( array $field, string $value = '' ): array {
227
+            $params = array();
228
+
229
+            if ( ! empty( $field['limits'] ) ) {
230
+                $params['limits'] = $field['limits'];
231
+            }
232
+
233
+            if ( empty( $value ) ) {
234
+                $value = $this->value;
235
+            }
236
+
237
+            $params['val'] = $value;
238
+
239
+            return $params;
240
+        }
241
+    }
242 242
 }
243 243
 
244 244
 class_alias( 'Redux_Sorter', 'ReduxFramework_Sorter' );
Please login to merge, or discard this patch.
redux-core/inc/fields/color_gradient/class-redux-color-gradient.php 2 patches
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -108,10 +108,10 @@  discard block
 block discarded – undo
108 108
 				echo 'data-id="' . esc_attr( $this->field['id'] ) . '"';
109 109
 				echo 'id="' . esc_attr( $this->field['id'] ) . '-' . esc_attr( $mode ) . '"';
110 110
 				echo 'name="' . esc_attr( $this->field['name'] ) . esc_attr( $this->field['name_suffix'] ) . '[' . esc_attr( $mode ) . ']"';
111
-				echo 'value="' . esc_attr( $this->value[ $mode ] ) . '"';
111
+				echo 'value="' . esc_attr( $this->value[$mode] ) . '"';
112 112
 				echo 'class="color-picker redux-color redux-color-init ' . esc_attr( $this->field['class'] ) . '"';
113 113
 				echo 'type="text"';
114
-				echo 'data-default-color="' . esc_attr( $this->field['default'][ $mode ] ) . '"';
114
+				echo 'data-default-color="' . esc_attr( $this->field['default'][$mode] ) . '"';
115 115
 
116 116
 				// Escaping done in function.
117 117
 				// phpcs:ignore WordPress.Security.EscapeOutput
@@ -124,7 +124,7 @@  discard block
 block discarded – undo
124 124
 				if ( ! isset( $this->field['transparent'] ) || false !== $this->field['transparent'] ) {
125 125
 					$trans_checked = '';
126 126
 
127
-					if ( 'transparent' === $this->value[ $mode ] ) {
127
+					if ( 'transparent' === $this->value[$mode] ) {
128 128
 						$trans_checked = ' checked="checked"';
129 129
 					}
130 130
 
Please login to merge, or discard this patch.
Indentation   +212 added lines, -212 removed lines patch added patch discarded remove patch
@@ -12,218 +12,218 @@
 block discarded – undo
12 12
 // Don't duplicate me!
13 13
 if ( ! class_exists( 'Redux_Color_Gradient', false ) ) {
14 14
 
15
-	/**
16
-	 * Main Redux_color_gradient class
17
-	 *
18
-	 * @since       1.0.0
19
-	 */
20
-	class Redux_Color_Gradient extends Redux_Field {
21
-
22
-		/**
23
-		 * Filters enabled flag.
24
-		 *
25
-		 * @var bool
26
-		 */
27
-		private $filters_enabled = false;
28
-
29
-		/**
30
-		 * Redux_Field constructor.
31
-		 *
32
-		 * @param array  $field  Field array.
33
-		 * @param string $value  Field values.
34
-		 * @param null   $redux  ReduxFramework object pointer.
35
-		 *
36
-		 * @throws ReflectionException Reflection.
37
-		 */
38
-		public function __construct( $field = array(), $value = null, $redux = null ) { // phpcs:ignore Generic.CodeAnalysis.UselessOverridingMethod
39
-			parent::__construct( $field, $value, $redux );
40
-		}
41
-
42
-		/**
43
-		 * Set field and value defaults.
44
-		 */
45
-		public function set_defaults() {
46
-			// No errors please.
47
-			$defaults = array(
48
-				'from'           => '',
49
-				'to'             => '',
50
-				'gradient-type'  => 'linear',
51
-				'gradient-angle' => 0,
52
-				'gradient-reach' => array(
53
-					'from' => 0,
54
-					'to'   => 100,
55
-				),
56
-			);
57
-
58
-			$this->value = Redux_Functions::parse_args( $this->value, $defaults );
59
-
60
-			$defaults = array(
61
-				'preview'        => false,
62
-				'preview_height' => '150px',
63
-				'transparent'    => true,
64
-				'gradient-type'  => false,
65
-				'gradient-reach' => false,
66
-				'gradient-angle' => false,
67
-			);
68
-
69
-			$this->field = wp_parse_args( $this->field, $defaults );
70
-
71
-			include_once Redux_Core::$dir . 'inc/lib/gradient-filters/class-redux-gradient-filters.php';
72
-
73
-			if ( $this->field['gradient-reach'] || $this->field['gradient-angle'] || $this->field['gradient-type'] ) {
74
-				include_once Redux_Core::$dir . 'inc/lib/gradient-filters/class-redux-gradient-filters.php';
75
-				$this->filters_enabled = true;
76
-			}
77
-		}
78
-
79
-		/**
80
-		 * Field Render Function.
81
-		 * Takes the vars and outputs the HTML for the field in the settings
82
-		 *
83
-		 * @since       1.0.0
84
-		 * @access      public
85
-		 * @return      void
86
-		 */
87
-		public function render() {
88
-			$data = array(
89
-				'field' => $this->field,
90
-				'value' => $this->value,
91
-			);
92
-
93
-			// Escaping done in function.
94
-			// phpcs:ignore WordPress.Security.EscapeOutput
95
-			echo Redux_Gradient_Filters::render_select( $data );
96
-
97
-			$mode_arr = array(
98
-				'from',
99
-				'to',
100
-			);
101
-
102
-			foreach ( $mode_arr as $mode ) {
103
-				$uc_mode = ucfirst( $mode );
104
-
105
-				echo '<div class="colorGradient ' . esc_html( $mode ) . 'Label">';
106
-				echo '<strong>' . esc_html( $uc_mode . ' ' ) . '</strong>&nbsp;';
107
-				echo '<input ';
108
-				echo 'data-id="' . esc_attr( $this->field['id'] ) . '"';
109
-				echo 'id="' . esc_attr( $this->field['id'] ) . '-' . esc_attr( $mode ) . '"';
110
-				echo 'name="' . esc_attr( $this->field['name'] ) . esc_attr( $this->field['name_suffix'] ) . '[' . esc_attr( $mode ) . ']"';
111
-				echo 'value="' . esc_attr( $this->value[ $mode ] ) . '"';
112
-				echo 'class="color-picker redux-color redux-color-init ' . esc_attr( $this->field['class'] ) . '"';
113
-				echo 'type="text"';
114
-				echo 'data-default-color="' . esc_attr( $this->field['default'][ $mode ] ) . '"';
115
-
116
-				// Escaping done in function.
117
-				// phpcs:ignore WordPress.Security.EscapeOutput
118
-				echo Redux_Functions_Ex::output_alpha_data( $data );
119
-
120
-				echo '>';
121
-
122
-				echo '<input type="hidden" class="redux-saved-color" id="' . esc_attr( $this->field['id'] ) . '-' . esc_attr( $mode ) . '-saved-color" value="">';
123
-
124
-				if ( ! isset( $this->field['transparent'] ) || false !== $this->field['transparent'] ) {
125
-					$trans_checked = '';
126
-
127
-					if ( 'transparent' === $this->value[ $mode ] ) {
128
-						$trans_checked = ' checked="checked"';
129
-					}
130
-
131
-					echo '<label for="' . esc_attr( $this->field['id'] ) . '-' . esc_html( $mode ) . '-transparency" class="color-transparency-check">';
132
-					echo '<input type="checkbox" class="checkbox color-transparency ' . esc_attr( $this->field['class'] ) . '" id="' . esc_attr( $this->field['id'] ) . '-' . esc_attr( $mode ) . '-transparency" data-id="' . esc_attr( $this->field['id'] ) . '-' . esc_attr( $mode ) . '" value="1"' . esc_html( $trans_checked ) . '> ' . esc_html__( 'Transparent', 'redux-framework' );
133
-					echo '</label>';
134
-				}
135
-
136
-				echo '</div>';
137
-			}
138
-
139
-			// Escaping done in function.
140
-			// phpcs:ignore WordPress.Security.EscapeOutput
141
-			echo Redux_Gradient_Filters::render_preview( $data );
142
-
143
-			// Escaping done in function.
144
-			// phpcs:ignore WordPress.Security.EscapeOutput
145
-			echo Redux_Gradient_Filters::render_sliders( $data );
146
-		}
147
-
148
-		/**
149
-		 * Do enqueue for each field instance.
150
-		 *
151
-		 * @return void
152
-		 */
153
-		public function always_enqueue() {
154
-			Redux_Gradient_Filters::enqueue( $this->field, $this->filters_enabled );
155
-
156
-			if ( isset( $this->field['color_alpha'] ) && ( $this->field['color_alpha'] || ( $this->field['color_alpha']['from'] || $this->field['color_alpha']['to'] ) ) ) {
157
-				if ( ! wp_script_is( 'redux-wp-color-picker-alpha' ) ) {
158
-					wp_enqueue_script( 'redux-wp-color-picker-alpha' );
159
-				}
160
-			}
161
-		}
162
-
163
-		/**
164
-		 * Enqueue Function.
165
-		 * If this field requires any scripts, or CSS define this function and register/enqueue the scripts/css
166
-		 *
167
-		 * @since       1.0.0
168
-		 * @access      public
169
-		 * @return      void
170
-		 */
171
-		public function enqueue() {
172
-			wp_enqueue_style( 'wp-color-picker' );
173
-
174
-			$min = Redux_Functions::isMin();
175
-
176
-			wp_enqueue_script(
177
-				'redux-field-color-gradient',
178
-				Redux_Core::$url . 'inc/fields/color_gradient/redux-color-gradient' . $min . '.js',
179
-				array( 'jquery', 'wp-color-picker', 'redux-js' ),
180
-				$this->timestamp,
181
-				true
182
-			);
183
-
184
-			if ( $this->filters_enabled ) {
185
-				wp_enqueue_script(
186
-					'redux-field-color-gradient',
187
-					Redux_Core::$url . 'inc/fields/color_gradient/redux-color-gradient' . $min . '.js',
188
-					array( 'jquery', 'wp-color-picker' ),
189
-					Redux_Core::$version,
190
-					true
191
-				);
192
-			}
193
-
194
-			if ( $this->parent->args['dev_mode'] ) {
195
-				wp_enqueue_style( 'redux-color-picker' );
196
-
197
-				wp_enqueue_style(
198
-					'redux-field-color_gradient',
199
-					Redux_Core::$url . 'inc/fields/color_gradient/redux-color-gradient.css',
200
-					array(),
201
-					$this->timestamp
202
-				);
203
-			}
204
-		}
205
-
206
-		/**
207
-		 * Compile CSS styling for output.
208
-		 *
209
-		 * @param string $data CSS data.
210
-		 *
211
-		 * @return string
212
-		 */
213
-		public function css_style( $data ): string {
214
-			return Redux_Gradient_Filters::get_output( $data );
215
-		}
216
-
217
-		/**
218
-		 * Enable output_variables to be generated.
219
-		 *
220
-		 * @since       4.0.3
221
-		 * @return void
222
-		 */
223
-		public function output_variables() {
224
-			// No code needed, just defining the method is enough.
225
-		}
226
-	}
15
+    /**
16
+     * Main Redux_color_gradient class
17
+     *
18
+     * @since       1.0.0
19
+     */
20
+    class Redux_Color_Gradient extends Redux_Field {
21
+
22
+        /**
23
+         * Filters enabled flag.
24
+         *
25
+         * @var bool
26
+         */
27
+        private $filters_enabled = false;
28
+
29
+        /**
30
+         * Redux_Field constructor.
31
+         *
32
+         * @param array  $field  Field array.
33
+         * @param string $value  Field values.
34
+         * @param null   $redux  ReduxFramework object pointer.
35
+         *
36
+         * @throws ReflectionException Reflection.
37
+         */
38
+        public function __construct( $field = array(), $value = null, $redux = null ) { // phpcs:ignore Generic.CodeAnalysis.UselessOverridingMethod
39
+            parent::__construct( $field, $value, $redux );
40
+        }
41
+
42
+        /**
43
+         * Set field and value defaults.
44
+         */
45
+        public function set_defaults() {
46
+            // No errors please.
47
+            $defaults = array(
48
+                'from'           => '',
49
+                'to'             => '',
50
+                'gradient-type'  => 'linear',
51
+                'gradient-angle' => 0,
52
+                'gradient-reach' => array(
53
+                    'from' => 0,
54
+                    'to'   => 100,
55
+                ),
56
+            );
57
+
58
+            $this->value = Redux_Functions::parse_args( $this->value, $defaults );
59
+
60
+            $defaults = array(
61
+                'preview'        => false,
62
+                'preview_height' => '150px',
63
+                'transparent'    => true,
64
+                'gradient-type'  => false,
65
+                'gradient-reach' => false,
66
+                'gradient-angle' => false,
67
+            );
68
+
69
+            $this->field = wp_parse_args( $this->field, $defaults );
70
+
71
+            include_once Redux_Core::$dir . 'inc/lib/gradient-filters/class-redux-gradient-filters.php';
72
+
73
+            if ( $this->field['gradient-reach'] || $this->field['gradient-angle'] || $this->field['gradient-type'] ) {
74
+                include_once Redux_Core::$dir . 'inc/lib/gradient-filters/class-redux-gradient-filters.php';
75
+                $this->filters_enabled = true;
76
+            }
77
+        }
78
+
79
+        /**
80
+         * Field Render Function.
81
+         * Takes the vars and outputs the HTML for the field in the settings
82
+         *
83
+         * @since       1.0.0
84
+         * @access      public
85
+         * @return      void
86
+         */
87
+        public function render() {
88
+            $data = array(
89
+                'field' => $this->field,
90
+                'value' => $this->value,
91
+            );
92
+
93
+            // Escaping done in function.
94
+            // phpcs:ignore WordPress.Security.EscapeOutput
95
+            echo Redux_Gradient_Filters::render_select( $data );
96
+
97
+            $mode_arr = array(
98
+                'from',
99
+                'to',
100
+            );
101
+
102
+            foreach ( $mode_arr as $mode ) {
103
+                $uc_mode = ucfirst( $mode );
104
+
105
+                echo '<div class="colorGradient ' . esc_html( $mode ) . 'Label">';
106
+                echo '<strong>' . esc_html( $uc_mode . ' ' ) . '</strong>&nbsp;';
107
+                echo '<input ';
108
+                echo 'data-id="' . esc_attr( $this->field['id'] ) . '"';
109
+                echo 'id="' . esc_attr( $this->field['id'] ) . '-' . esc_attr( $mode ) . '"';
110
+                echo 'name="' . esc_attr( $this->field['name'] ) . esc_attr( $this->field['name_suffix'] ) . '[' . esc_attr( $mode ) . ']"';
111
+                echo 'value="' . esc_attr( $this->value[ $mode ] ) . '"';
112
+                echo 'class="color-picker redux-color redux-color-init ' . esc_attr( $this->field['class'] ) . '"';
113
+                echo 'type="text"';
114
+                echo 'data-default-color="' . esc_attr( $this->field['default'][ $mode ] ) . '"';
115
+
116
+                // Escaping done in function.
117
+                // phpcs:ignore WordPress.Security.EscapeOutput
118
+                echo Redux_Functions_Ex::output_alpha_data( $data );
119
+
120
+                echo '>';
121
+
122
+                echo '<input type="hidden" class="redux-saved-color" id="' . esc_attr( $this->field['id'] ) . '-' . esc_attr( $mode ) . '-saved-color" value="">';
123
+
124
+                if ( ! isset( $this->field['transparent'] ) || false !== $this->field['transparent'] ) {
125
+                    $trans_checked = '';
126
+
127
+                    if ( 'transparent' === $this->value[ $mode ] ) {
128
+                        $trans_checked = ' checked="checked"';
129
+                    }
130
+
131
+                    echo '<label for="' . esc_attr( $this->field['id'] ) . '-' . esc_html( $mode ) . '-transparency" class="color-transparency-check">';
132
+                    echo '<input type="checkbox" class="checkbox color-transparency ' . esc_attr( $this->field['class'] ) . '" id="' . esc_attr( $this->field['id'] ) . '-' . esc_attr( $mode ) . '-transparency" data-id="' . esc_attr( $this->field['id'] ) . '-' . esc_attr( $mode ) . '" value="1"' . esc_html( $trans_checked ) . '> ' . esc_html__( 'Transparent', 'redux-framework' );
133
+                    echo '</label>';
134
+                }
135
+
136
+                echo '</div>';
137
+            }
138
+
139
+            // Escaping done in function.
140
+            // phpcs:ignore WordPress.Security.EscapeOutput
141
+            echo Redux_Gradient_Filters::render_preview( $data );
142
+
143
+            // Escaping done in function.
144
+            // phpcs:ignore WordPress.Security.EscapeOutput
145
+            echo Redux_Gradient_Filters::render_sliders( $data );
146
+        }
147
+
148
+        /**
149
+         * Do enqueue for each field instance.
150
+         *
151
+         * @return void
152
+         */
153
+        public function always_enqueue() {
154
+            Redux_Gradient_Filters::enqueue( $this->field, $this->filters_enabled );
155
+
156
+            if ( isset( $this->field['color_alpha'] ) && ( $this->field['color_alpha'] || ( $this->field['color_alpha']['from'] || $this->field['color_alpha']['to'] ) ) ) {
157
+                if ( ! wp_script_is( 'redux-wp-color-picker-alpha' ) ) {
158
+                    wp_enqueue_script( 'redux-wp-color-picker-alpha' );
159
+                }
160
+            }
161
+        }
162
+
163
+        /**
164
+         * Enqueue Function.
165
+         * If this field requires any scripts, or CSS define this function and register/enqueue the scripts/css
166
+         *
167
+         * @since       1.0.0
168
+         * @access      public
169
+         * @return      void
170
+         */
171
+        public function enqueue() {
172
+            wp_enqueue_style( 'wp-color-picker' );
173
+
174
+            $min = Redux_Functions::isMin();
175
+
176
+            wp_enqueue_script(
177
+                'redux-field-color-gradient',
178
+                Redux_Core::$url . 'inc/fields/color_gradient/redux-color-gradient' . $min . '.js',
179
+                array( 'jquery', 'wp-color-picker', 'redux-js' ),
180
+                $this->timestamp,
181
+                true
182
+            );
183
+
184
+            if ( $this->filters_enabled ) {
185
+                wp_enqueue_script(
186
+                    'redux-field-color-gradient',
187
+                    Redux_Core::$url . 'inc/fields/color_gradient/redux-color-gradient' . $min . '.js',
188
+                    array( 'jquery', 'wp-color-picker' ),
189
+                    Redux_Core::$version,
190
+                    true
191
+                );
192
+            }
193
+
194
+            if ( $this->parent->args['dev_mode'] ) {
195
+                wp_enqueue_style( 'redux-color-picker' );
196
+
197
+                wp_enqueue_style(
198
+                    'redux-field-color_gradient',
199
+                    Redux_Core::$url . 'inc/fields/color_gradient/redux-color-gradient.css',
200
+                    array(),
201
+                    $this->timestamp
202
+                );
203
+            }
204
+        }
205
+
206
+        /**
207
+         * Compile CSS styling for output.
208
+         *
209
+         * @param string $data CSS data.
210
+         *
211
+         * @return string
212
+         */
213
+        public function css_style( $data ): string {
214
+            return Redux_Gradient_Filters::get_output( $data );
215
+        }
216
+
217
+        /**
218
+         * Enable output_variables to be generated.
219
+         *
220
+         * @since       4.0.3
221
+         * @return void
222
+         */
223
+        public function output_variables() {
224
+            // No code needed, just defining the method is enough.
225
+        }
226
+    }
227 227
 }
228 228
 
229 229
 class_alias( 'Redux_Color_Gradient', 'ReduxFramework_Color_Gradient' );
Please login to merge, or discard this patch.
redux-core/inc/fields/color/class-redux-color.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -58,7 +58,7 @@
 block discarded – undo
58 58
 				'index' => '',
59 59
 			);
60 60
 
61
-			echo Redux_Functions_Ex::output_alpha_data( $data );  // phpcs:ignore WordPress.Security.EscapeOutput
61
+			echo Redux_Functions_Ex::output_alpha_data( $data ); // phpcs:ignore WordPress.Security.EscapeOutput
62 62
 
63 63
 			echo '>';
64 64
 
Please login to merge, or discard this patch.
Indentation   +151 added lines, -151 removed lines patch added patch discarded remove patch
@@ -12,157 +12,157 @@
 block discarded – undo
12 12
 // Don't duplicate me!
13 13
 if ( ! class_exists( 'Redux_Color', false ) ) {
14 14
 
15
-	/**
16
-	 * Main Redux_color class
17
-	 *
18
-	 * @since       1.0.0
19
-	 */
20
-	class Redux_Color extends Redux_Field {
21
-
22
-		/**
23
-		 * Set field defaults.
24
-		 */
25
-		public function set_defaults() {
26
-			$defaults = array(
27
-				'transparent' => true,
28
-				'color_alpha' => false,
29
-			);
30
-
31
-			$this->field = wp_parse_args( $this->field, $defaults );
32
-		}
33
-
34
-		/**
35
-		 * Field Render Function.
36
-		 * Takes the vars and outputs the HTML for the field in the settings
37
-		 *
38
-		 * @since         1.0.0
39
-		 * @access        public
40
-		 * @return        void
41
-		 */
42
-		public function render() {
43
-			if ( isset( $this->field['color_alpha'] ) && $this->field['color_alpha'] ) {
44
-				$this->field['class'] = 'alpha-enabled';
45
-			}
46
-
47
-			echo '<input ';
48
-			echo 'data-id="' . esc_attr( $this->field['id'] ) . '"';
49
-			echo 'name="' . esc_attr( $this->field['name'] . $this->field['name_suffix'] ) . '"';
50
-			echo 'id="' . esc_attr( $this->field['id'] ) . '-color"';
51
-			echo 'class="color-picker redux-color redux-color-init ' . esc_attr( $this->field['class'] ) . '"';
52
-			echo 'type="text" value="' . esc_attr( $this->value ) . '"';
53
-			echo 'data-oldcolor=""';
54
-			echo 'data-default-color="' . ( isset( $this->field['default'] ) ? esc_attr( $this->field['default'] ) : '' ) . '"';
55
-
56
-			$data = array(
57
-				'field' => $this->field,
58
-				'index' => '',
59
-			);
60
-
61
-			echo Redux_Functions_Ex::output_alpha_data( $data );  // phpcs:ignore WordPress.Security.EscapeOutput
62
-
63
-			echo '>';
64
-
65
-			echo '<input type="hidden" class="redux-saved-color" id="' . esc_attr( $this->field['id'] ) . '-saved-color" value="">';
66
-
67
-			if ( ! isset( $this->field['transparent'] ) || false !== $this->field['transparent'] ) {
68
-				$trans_checked = '';
69
-
70
-				if ( 'transparent' === $this->value ) {
71
-					$trans_checked = ' checked="checked"';
72
-				}
73
-
74
-				echo '<label for="' . esc_attr( $this->field['id'] ) . '-transparency" class="color-transparency-check">';
75
-				echo '<input type="checkbox" class="checkbox color-transparency ' . esc_attr( $this->field['class'] ) . '" id="' . esc_attr( $this->field['id'] ) . '-transparency" data-id="' . esc_attr( $this->field['id'] ) . '-color" value="1"' . esc_html( $trans_checked ) . '>';
76
-				echo esc_html__( 'Transparent', 'redux-framework' );
77
-				echo '</label>';
78
-			}
79
-		}
80
-
81
-		/**
82
-		 * Do enqueue for each field instance.
83
-		 *
84
-		 * @return void
85
-		 */
86
-		public function always_enqueue() {
87
-			if ( isset( $this->field['color_alpha'] ) && $this->field['color_alpha'] ) {
88
-				if ( ! wp_script_is( 'redux-wp-color-picker-alpha' ) ) {
89
-					wp_enqueue_script( 'redux-wp-color-picker-alpha' );
90
-				}
91
-			}
92
-		}
93
-
94
-		/**
95
-		 * Enqueue Function.
96
-		 * If this field requires any scripts, or CSS define this function and register/enqueue the scripts/css
97
-		 *
98
-		 * @since         1.0.0
99
-		 * @access        public
100
-		 * @return        void
101
-		 */
102
-		public function enqueue() {
103
-			if ( $this->parent->args['dev_mode'] ) {
104
-				wp_enqueue_style( 'redux-color-picker' );
105
-			}
106
-
107
-			if ( ! wp_style_is( 'wp-color-picker' ) ) {
108
-				wp_enqueue_style( 'wp-color-picker' );
109
-			}
110
-
111
-			$dep_array = array( 'jquery', 'wp-color-picker', 'redux-js' );
112
-
113
-			wp_enqueue_script(
114
-				'redux-field-color',
115
-				Redux_Core::$url . 'inc/fields/color/redux-color' . Redux_Functions::is_min() . '.js',
116
-				$dep_array,
117
-				$this->timestamp,
118
-				true
119
-			);
120
-		}
121
-
122
-		/**
123
-		 * Generate CSS style (unused, but needed).
124
-		 *
125
-		 * @param string $data Field data.
126
-		 *
127
-		 * @return string
128
-		 */
129
-		public function css_style( $data ): string {
130
-			return '';
131
-		}
132
-
133
-		/**
134
-		 * Output CSS styling.
135
-		 *
136
-		 * @param string|null|array $style CSS style.
137
-		 */
138
-		public function output( $style = '' ) {
139
-			if ( ! empty( $this->value ) ) {
140
-				$mode = ( isset( $this->field['mode'] ) && ! empty( $this->field['mode'] ) ? $this->field['mode'] : 'color' );
141
-
142
-				$style = $mode . ':' . $this->value . ';';
143
-
144
-				if ( ! empty( $this->field['output'] ) && is_array( $this->field['output'] ) ) {
145
-					$css                      = Redux_Functions::parse_css( $this->field['output'], $style, $this->value );
146
-					$this->parent->outputCSS .= $css;
147
-				}
148
-
149
-				if ( ! empty( $this->field['compiler'] ) && is_array( $this->field['compiler'] ) ) {
150
-					$css                        = Redux_Functions::parse_css( $this->field['compiler'], $style, $this->value );
151
-					$this->parent->compilerCSS .= $css;
152
-				}
153
-			}
154
-		}
155
-
156
-		/**
157
-		 * Enable output_variables to be generated.
158
-		 *
159
-		 * @since       4.0.3
160
-		 * @return void
161
-		 */
162
-		public function output_variables() {
163
-			// No code needed, just defining the method is enough.
164
-		}
165
-	}
15
+    /**
16
+     * Main Redux_color class
17
+     *
18
+     * @since       1.0.0
19
+     */
20
+    class Redux_Color extends Redux_Field {
21
+
22
+        /**
23
+         * Set field defaults.
24
+         */
25
+        public function set_defaults() {
26
+            $defaults = array(
27
+                'transparent' => true,
28
+                'color_alpha' => false,
29
+            );
30
+
31
+            $this->field = wp_parse_args( $this->field, $defaults );
32
+        }
33
+
34
+        /**
35
+         * Field Render Function.
36
+         * Takes the vars and outputs the HTML for the field in the settings
37
+         *
38
+         * @since         1.0.0
39
+         * @access        public
40
+         * @return        void
41
+         */
42
+        public function render() {
43
+            if ( isset( $this->field['color_alpha'] ) && $this->field['color_alpha'] ) {
44
+                $this->field['class'] = 'alpha-enabled';
45
+            }
46
+
47
+            echo '<input ';
48
+            echo 'data-id="' . esc_attr( $this->field['id'] ) . '"';
49
+            echo 'name="' . esc_attr( $this->field['name'] . $this->field['name_suffix'] ) . '"';
50
+            echo 'id="' . esc_attr( $this->field['id'] ) . '-color"';
51
+            echo 'class="color-picker redux-color redux-color-init ' . esc_attr( $this->field['class'] ) . '"';
52
+            echo 'type="text" value="' . esc_attr( $this->value ) . '"';
53
+            echo 'data-oldcolor=""';
54
+            echo 'data-default-color="' . ( isset( $this->field['default'] ) ? esc_attr( $this->field['default'] ) : '' ) . '"';
55
+
56
+            $data = array(
57
+                'field' => $this->field,
58
+                'index' => '',
59
+            );
60
+
61
+            echo Redux_Functions_Ex::output_alpha_data( $data );  // phpcs:ignore WordPress.Security.EscapeOutput
62
+
63
+            echo '>';
64
+
65
+            echo '<input type="hidden" class="redux-saved-color" id="' . esc_attr( $this->field['id'] ) . '-saved-color" value="">';
66
+
67
+            if ( ! isset( $this->field['transparent'] ) || false !== $this->field['transparent'] ) {
68
+                $trans_checked = '';
69
+
70
+                if ( 'transparent' === $this->value ) {
71
+                    $trans_checked = ' checked="checked"';
72
+                }
73
+
74
+                echo '<label for="' . esc_attr( $this->field['id'] ) . '-transparency" class="color-transparency-check">';
75
+                echo '<input type="checkbox" class="checkbox color-transparency ' . esc_attr( $this->field['class'] ) . '" id="' . esc_attr( $this->field['id'] ) . '-transparency" data-id="' . esc_attr( $this->field['id'] ) . '-color" value="1"' . esc_html( $trans_checked ) . '>';
76
+                echo esc_html__( 'Transparent', 'redux-framework' );
77
+                echo '</label>';
78
+            }
79
+        }
80
+
81
+        /**
82
+         * Do enqueue for each field instance.
83
+         *
84
+         * @return void
85
+         */
86
+        public function always_enqueue() {
87
+            if ( isset( $this->field['color_alpha'] ) && $this->field['color_alpha'] ) {
88
+                if ( ! wp_script_is( 'redux-wp-color-picker-alpha' ) ) {
89
+                    wp_enqueue_script( 'redux-wp-color-picker-alpha' );
90
+                }
91
+            }
92
+        }
93
+
94
+        /**
95
+         * Enqueue Function.
96
+         * If this field requires any scripts, or CSS define this function and register/enqueue the scripts/css
97
+         *
98
+         * @since         1.0.0
99
+         * @access        public
100
+         * @return        void
101
+         */
102
+        public function enqueue() {
103
+            if ( $this->parent->args['dev_mode'] ) {
104
+                wp_enqueue_style( 'redux-color-picker' );
105
+            }
106
+
107
+            if ( ! wp_style_is( 'wp-color-picker' ) ) {
108
+                wp_enqueue_style( 'wp-color-picker' );
109
+            }
110
+
111
+            $dep_array = array( 'jquery', 'wp-color-picker', 'redux-js' );
112
+
113
+            wp_enqueue_script(
114
+                'redux-field-color',
115
+                Redux_Core::$url . 'inc/fields/color/redux-color' . Redux_Functions::is_min() . '.js',
116
+                $dep_array,
117
+                $this->timestamp,
118
+                true
119
+            );
120
+        }
121
+
122
+        /**
123
+         * Generate CSS style (unused, but needed).
124
+         *
125
+         * @param string $data Field data.
126
+         *
127
+         * @return string
128
+         */
129
+        public function css_style( $data ): string {
130
+            return '';
131
+        }
132
+
133
+        /**
134
+         * Output CSS styling.
135
+         *
136
+         * @param string|null|array $style CSS style.
137
+         */
138
+        public function output( $style = '' ) {
139
+            if ( ! empty( $this->value ) ) {
140
+                $mode = ( isset( $this->field['mode'] ) && ! empty( $this->field['mode'] ) ? $this->field['mode'] : 'color' );
141
+
142
+                $style = $mode . ':' . $this->value . ';';
143
+
144
+                if ( ! empty( $this->field['output'] ) && is_array( $this->field['output'] ) ) {
145
+                    $css                      = Redux_Functions::parse_css( $this->field['output'], $style, $this->value );
146
+                    $this->parent->outputCSS .= $css;
147
+                }
148
+
149
+                if ( ! empty( $this->field['compiler'] ) && is_array( $this->field['compiler'] ) ) {
150
+                    $css                        = Redux_Functions::parse_css( $this->field['compiler'], $style, $this->value );
151
+                    $this->parent->compilerCSS .= $css;
152
+                }
153
+            }
154
+        }
155
+
156
+        /**
157
+         * Enable output_variables to be generated.
158
+         *
159
+         * @since       4.0.3
160
+         * @return void
161
+         */
162
+        public function output_variables() {
163
+            // No code needed, just defining the method is enough.
164
+        }
165
+    }
166 166
 }
167 167
 
168 168
 class_alias( 'Redux_Color', 'ReduxFramework_Color' );
Please login to merge, or discard this patch.
redux-core/inc/fields/spacing/class-redux-spacing.php 2 patches
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -86,10 +86,10 @@  discard block
 block discarded – undo
86 86
 			}
87 87
 
88 88
 			$value = array(
89
-				'top'    => isset( $this->value[ $this->field['mode'] . '-top' ] ) ? filter_var( $this->value[ $this->field['mode'] . '-top' ], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION ) : filter_var( $this->value['top'], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION ),
90
-				'right'  => isset( $this->value[ $this->field['mode'] . '-right' ] ) ? filter_var( $this->value[ $this->field['mode'] . '-right' ], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION ) : filter_var( $this->value['right'], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION ),
91
-				'bottom' => isset( $this->value[ $this->field['mode'] . '-bottom' ] ) ? filter_var( $this->value[ $this->field['mode'] . '-bottom' ], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION ) : filter_var( $this->value['bottom'], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION ),
92
-				'left'   => isset( $this->value[ $this->field['mode'] . '-left' ] ) ? filter_var( $this->value[ $this->field['mode'] . '-left' ], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION ) : filter_var( $this->value['left'], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION ),
89
+				'top'    => isset( $this->value[$this->field['mode'] . '-top'] ) ? filter_var( $this->value[$this->field['mode'] . '-top'], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION ) : filter_var( $this->value['top'], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION ),
90
+				'right'  => isset( $this->value[$this->field['mode'] . '-right'] ) ? filter_var( $this->value[$this->field['mode'] . '-right'], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION ) : filter_var( $this->value['right'], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION ),
91
+				'bottom' => isset( $this->value[$this->field['mode'] . '-bottom'] ) ? filter_var( $this->value[$this->field['mode'] . '-bottom'], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION ) : filter_var( $this->value['bottom'], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION ),
92
+				'left'   => isset( $this->value[$this->field['mode'] . '-left'] ) ? filter_var( $this->value[$this->field['mode'] . '-left'], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION ) : filter_var( $this->value['left'], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION ),
93 93
 			);
94 94
 
95 95
 			// if field units has a value and is NOT an array, then evaluate as needed.
@@ -343,7 +343,7 @@  discard block
 block discarded – undo
343 343
 		public function css_style( $data ) {
344 344
 			$style = '';
345 345
 
346
-			$data = (array) $data;
346
+			$data = ( array ) $data;
347 347
 
348 348
 			if ( ! isset( $this->field ) ) {
349 349
 				return;
Please login to merge, or discard this patch.
Indentation   +287 added lines, -287 removed lines patch added patch discarded remove patch
@@ -11,152 +11,152 @@  discard block
 block discarded – undo
11 11
 
12 12
 if ( ! class_exists( 'Redux_Spacing', false ) ) {
13 13
 
14
-	/**
15
-	 * Class Redux_Spacing
16
-	 */
17
-	class Redux_Spacing extends Redux_Field {
18
-
19
-		/**
20
-		 * Set field a value defaults.
21
-		 */
22
-		public function set_defaults() {
23
-			$defaults = array(
24
-				'units'          => 'px',
25
-				'mode'           => 'padding',
26
-				'top'            => true,
27
-				'bottom'         => true,
28
-				'all'            => false,
29
-				'left'           => true,
30
-				'right'          => true,
31
-				'units_extended' => false,
32
-				'display_units'  => true,
33
-			);
34
-
35
-			$this->field = wp_parse_args( $this->field, $defaults );
36
-
37
-			// Set default values.
38
-			$defaults = array(
39
-				'top'    => '',
40
-				'right'  => '',
41
-				'bottom' => '',
42
-				'left'   => '',
43
-				'units'  => 'px',
44
-			);
45
-
46
-			$this->value = wp_parse_args( $this->value, $defaults );
47
-		}
48
-
49
-		/**
50
-		 * Field Render Function.
51
-		 * Takes the vars and outputs the HTML for the field in the settings
52
-		 *
53
-		 * @since ReduxFramework 1.0.0
54
-		 */
55
-		public function render() {
56
-			/*
14
+    /**
15
+     * Class Redux_Spacing
16
+     */
17
+    class Redux_Spacing extends Redux_Field {
18
+
19
+        /**
20
+         * Set field a value defaults.
21
+         */
22
+        public function set_defaults() {
23
+            $defaults = array(
24
+                'units'          => 'px',
25
+                'mode'           => 'padding',
26
+                'top'            => true,
27
+                'bottom'         => true,
28
+                'all'            => false,
29
+                'left'           => true,
30
+                'right'          => true,
31
+                'units_extended' => false,
32
+                'display_units'  => true,
33
+            );
34
+
35
+            $this->field = wp_parse_args( $this->field, $defaults );
36
+
37
+            // Set default values.
38
+            $defaults = array(
39
+                'top'    => '',
40
+                'right'  => '',
41
+                'bottom' => '',
42
+                'left'   => '',
43
+                'units'  => 'px',
44
+            );
45
+
46
+            $this->value = wp_parse_args( $this->value, $defaults );
47
+        }
48
+
49
+        /**
50
+         * Field Render Function.
51
+         * Takes the vars and outputs the HTML for the field in the settings
52
+         *
53
+         * @since ReduxFramework 1.0.0
54
+         */
55
+        public function render() {
56
+            /*
57 57
 			 * Acceptable values checks.  If the passed variable doesn't pass muster, we unset them
58 58
 			 * and reset them with default values to avoid errors.
59 59
 			 */
60 60
 
61
-			$unit_arr = Redux_Helpers::$array_units;
62
-
63
-			$unit_check   = $unit_arr;
64
-			$unit_check[] = false;
65
-
66
-			// If units field has a value but is not an acceptable value, unset the variable.
67
-			if ( ! Redux_Helpers::array_in_array( $this->field['units'], $unit_check ) ) {
68
-				$this->field['units'] = 'px';
69
-			}
70
-
71
-			// If there is a default unit value  but is not an accepted value, unset the variable.
72
-			if ( ! Redux_Helpers::array_in_array( $this->value['units'], $unit_check ) ) {
73
-				$this->value['units'] = 'px';
74
-			}
75
-
76
-			if ( false === $this->field['units'] ) {
77
-				$this->value['units'] = '';
78
-			}
79
-
80
-			if ( ! in_array( $this->field['mode'], array( 'margin', 'padding' ), true ) ) {
81
-				if ( 'absolute' === $this->field['mode'] ) {
82
-					$this->field['mode'] = '';
83
-				} else {
84
-					$this->field['mode'] = 'padding';
85
-				}
86
-			}
87
-
88
-			$value = array(
89
-				'top'    => isset( $this->value[ $this->field['mode'] . '-top' ] ) ? filter_var( $this->value[ $this->field['mode'] . '-top' ], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION ) : filter_var( $this->value['top'], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION ),
90
-				'right'  => isset( $this->value[ $this->field['mode'] . '-right' ] ) ? filter_var( $this->value[ $this->field['mode'] . '-right' ], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION ) : filter_var( $this->value['right'], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION ),
91
-				'bottom' => isset( $this->value[ $this->field['mode'] . '-bottom' ] ) ? filter_var( $this->value[ $this->field['mode'] . '-bottom' ], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION ) : filter_var( $this->value['bottom'], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION ),
92
-				'left'   => isset( $this->value[ $this->field['mode'] . '-left' ] ) ? filter_var( $this->value[ $this->field['mode'] . '-left' ], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION ) : filter_var( $this->value['left'], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION ),
93
-			);
94
-
95
-			// if field units has a value and is NOT an array, then evaluate as needed.
96
-			if ( ! is_array( $this->field['units'] ) ) {
97
-
98
-				// If units fields has a value and is not empty but units value does not then make units value the field value.
99
-				if ( '' === $this->value['units'] && ( '' !== $this->field['units'] || false === $this->field['units'] ) ) {
100
-					$this->value['units'] = $this->field['units'];
101
-
102
-					// If units field does NOT have a value and units value does NOT have a value, set both to blank (default?).
103
-				} elseif ( '' === $this->field['units'] && '' === $this->value['units'] ) {
104
-					$this->field['units'] = 'px';
105
-					$this->value['units'] = 'px';
106
-
107
-					// If units field has NO value but units value does, then set unit field to value field.
108
-				} elseif ( '' === $this->field['units'] && '' !== $this->value['units'] ) {
109
-					$this->field['units'] = $this->value['units'];
110
-
111
-					// if unit value is set and unit value doesn't equal unit field (coz who knows why)
112
-					// then set unit value to unit field.
113
-				} elseif ( '' !== $this->value['units'] && $this->field['units'] !== $this->value['units'] ) {
114
-					$this->value['units'] = $this->field['units'];
115
-				}
116
-
117
-				// do stuff based on unit field NOT set as an array.
118
-				// phpcs:ignore Generic.CodeAnalysis.EmptyStatement
119
-			} elseif ( ! empty( $this->field['units'] ) && is_array( $this->field['units'] ) ) {
120
-				// nothing to do here, but I'm leaving the construct just in case I have to debug this again.
121
-			}
122
-
123
-			if ( '' !== $this->field['units'] ) {
124
-				$value['units'] = $this->value['units'];
125
-			}
126
-
127
-			$this->value = $value;
128
-
129
-			if ( '' !== $this->field['mode'] ) {
130
-				$this->field['mode'] = $this->field['mode'] . '-';
131
-			}
132
-
133
-			if ( isset( $this->field['select2'] ) ) {
134
-				$this->field['select2'] = wp_parse_args( $this->field['select2'], $this->select2_config );
135
-			} else {
136
-				$this->field['select2'] = $this->select2_config;
137
-			}
138
-
139
-			$this->field['select2'] = Redux_Functions::sanitize_camel_case_array_keys( $this->field['select2'] );
140
-
141
-			$select2_data = Redux_Functions::create_data_string( $this->field['select2'] );
142
-
143
-			echo '<input
61
+            $unit_arr = Redux_Helpers::$array_units;
62
+
63
+            $unit_check   = $unit_arr;
64
+            $unit_check[] = false;
65
+
66
+            // If units field has a value but is not an acceptable value, unset the variable.
67
+            if ( ! Redux_Helpers::array_in_array( $this->field['units'], $unit_check ) ) {
68
+                $this->field['units'] = 'px';
69
+            }
70
+
71
+            // If there is a default unit value  but is not an accepted value, unset the variable.
72
+            if ( ! Redux_Helpers::array_in_array( $this->value['units'], $unit_check ) ) {
73
+                $this->value['units'] = 'px';
74
+            }
75
+
76
+            if ( false === $this->field['units'] ) {
77
+                $this->value['units'] = '';
78
+            }
79
+
80
+            if ( ! in_array( $this->field['mode'], array( 'margin', 'padding' ), true ) ) {
81
+                if ( 'absolute' === $this->field['mode'] ) {
82
+                    $this->field['mode'] = '';
83
+                } else {
84
+                    $this->field['mode'] = 'padding';
85
+                }
86
+            }
87
+
88
+            $value = array(
89
+                'top'    => isset( $this->value[ $this->field['mode'] . '-top' ] ) ? filter_var( $this->value[ $this->field['mode'] . '-top' ], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION ) : filter_var( $this->value['top'], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION ),
90
+                'right'  => isset( $this->value[ $this->field['mode'] . '-right' ] ) ? filter_var( $this->value[ $this->field['mode'] . '-right' ], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION ) : filter_var( $this->value['right'], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION ),
91
+                'bottom' => isset( $this->value[ $this->field['mode'] . '-bottom' ] ) ? filter_var( $this->value[ $this->field['mode'] . '-bottom' ], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION ) : filter_var( $this->value['bottom'], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION ),
92
+                'left'   => isset( $this->value[ $this->field['mode'] . '-left' ] ) ? filter_var( $this->value[ $this->field['mode'] . '-left' ], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION ) : filter_var( $this->value['left'], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION ),
93
+            );
94
+
95
+            // if field units has a value and is NOT an array, then evaluate as needed.
96
+            if ( ! is_array( $this->field['units'] ) ) {
97
+
98
+                // If units fields has a value and is not empty but units value does not then make units value the field value.
99
+                if ( '' === $this->value['units'] && ( '' !== $this->field['units'] || false === $this->field['units'] ) ) {
100
+                    $this->value['units'] = $this->field['units'];
101
+
102
+                    // If units field does NOT have a value and units value does NOT have a value, set both to blank (default?).
103
+                } elseif ( '' === $this->field['units'] && '' === $this->value['units'] ) {
104
+                    $this->field['units'] = 'px';
105
+                    $this->value['units'] = 'px';
106
+
107
+                    // If units field has NO value but units value does, then set unit field to value field.
108
+                } elseif ( '' === $this->field['units'] && '' !== $this->value['units'] ) {
109
+                    $this->field['units'] = $this->value['units'];
110
+
111
+                    // if unit value is set and unit value doesn't equal unit field (coz who knows why)
112
+                    // then set unit value to unit field.
113
+                } elseif ( '' !== $this->value['units'] && $this->field['units'] !== $this->value['units'] ) {
114
+                    $this->value['units'] = $this->field['units'];
115
+                }
116
+
117
+                // do stuff based on unit field NOT set as an array.
118
+                // phpcs:ignore Generic.CodeAnalysis.EmptyStatement
119
+            } elseif ( ! empty( $this->field['units'] ) && is_array( $this->field['units'] ) ) {
120
+                // nothing to do here, but I'm leaving the construct just in case I have to debug this again.
121
+            }
122
+
123
+            if ( '' !== $this->field['units'] ) {
124
+                $value['units'] = $this->value['units'];
125
+            }
126
+
127
+            $this->value = $value;
128
+
129
+            if ( '' !== $this->field['mode'] ) {
130
+                $this->field['mode'] = $this->field['mode'] . '-';
131
+            }
132
+
133
+            if ( isset( $this->field['select2'] ) ) {
134
+                $this->field['select2'] = wp_parse_args( $this->field['select2'], $this->select2_config );
135
+            } else {
136
+                $this->field['select2'] = $this->select2_config;
137
+            }
138
+
139
+            $this->field['select2'] = Redux_Functions::sanitize_camel_case_array_keys( $this->field['select2'] );
140
+
141
+            $select2_data = Redux_Functions::create_data_string( $this->field['select2'] );
142
+
143
+            echo '<input
144 144
 					type="hidden"
145 145
 					id="' . esc_attr( $this->field['id'] ) . '-units"
146 146
 					name="' . esc_attr( $this->field['name'] . $this->field['name_suffix'] ) . '[units]"
147 147
 					class="field-units" value="' . esc_attr( $this->value['units'] ) . '">';
148 148
 
149
-			if ( true === $this->field['all'] ) {
150
-				$this->field['top']    = true;
151
-				$this->field['right']  = true;
152
-				$this->field['bottom'] = true;
153
-				$this->field['left']   = true;
149
+            if ( true === $this->field['all'] ) {
150
+                $this->field['top']    = true;
151
+                $this->field['right']  = true;
152
+                $this->field['bottom'] = true;
153
+                $this->field['left']   = true;
154 154
 
155
-				$this->value['bottom'] = $this->value['top'];
156
-				$this->value['left']   = $this->value['top'];
157
-				$this->value['right']  = $this->value['top'];
155
+                $this->value['bottom'] = $this->value['top'];
156
+                $this->value['left']   = $this->value['top'];
157
+                $this->value['right']  = $this->value['top'];
158 158
 
159
-				echo '<div class="field-spacing-input input-prepend">
159
+                echo '<div class="field-spacing-input input-prepend">
160 160
                         <span class="add-on">
161 161
                             <i class="el el-fullscreen icon-large"></i>
162 162
                         </span>
@@ -169,54 +169,54 @@  discard block
 block discarded – undo
169 169
                             value="' . esc_attr( $this->value['top'] ) . '"
170 170
                         >
171 171
                       </div>';
172
-			}
172
+            }
173 173
 
174
-			if ( true === $this->field['top'] ) {
175
-				echo '<input
174
+            if ( true === $this->field['top'] ) {
175
+                echo '<input
176 176
                         type="hidden"
177 177
                         class="redux-spacing-value"
178 178
                         id="' . esc_attr( $this->field['id'] ) . '-top-hidden"
179 179
                         name="' . esc_attr( $this->field['name'] . $this->field['name_suffix'] . '[' . $this->field['mode'] ) . 'top]"
180 180
                         value="' . esc_attr( $this->value['top'] ) . ( ! empty( $this->value['top'] ) ? esc_attr( $this->value['units'] ) : '' ) . '"
181 181
                       >';
182
-			}
182
+            }
183 183
 
184
-			if ( true === $this->field['right'] ) {
185
-				echo '<input
184
+            if ( true === $this->field['right'] ) {
185
+                echo '<input
186 186
                         type="hidden"
187 187
                         class="redux-spacing-value"
188 188
                         id="' . esc_attr( $this->field['id'] ) . '-right-hidden"
189 189
                         name="' . esc_attr( $this->field['name'] . $this->field['name_suffix'] . '[' . $this->field['mode'] ) . 'right]"
190 190
                         value="' . esc_attr( $this->value['right'] ) . ( ! empty( $this->value['right'] ) ? esc_attr( $this->value['units'] ) : '' ) . '"
191 191
                       >';
192
-			}
192
+            }
193 193
 
194
-			if ( true === $this->field['bottom'] ) {
195
-				echo '<input
194
+            if ( true === $this->field['bottom'] ) {
195
+                echo '<input
196 196
                         type="hidden"
197 197
                         class="redux-spacing-value"
198 198
                         id="' . esc_attr( $this->field['id'] ) . '-bottom-hidden"
199 199
                         name="' . esc_attr( $this->field['name'] . $this->field['name_suffix'] . '[' . $this->field['mode'] ) . 'bottom]"
200 200
                         value="' . esc_attr( $this->value['bottom'] ) . ( ! empty( $this->value['bottom'] ) ? esc_attr( $this->value['units'] ) : '' ) . '"
201 201
                       >';
202
-			}
202
+            }
203 203
 
204
-			if ( true === $this->field['left'] ) {
205
-				echo '<input
204
+            if ( true === $this->field['left'] ) {
205
+                echo '<input
206 206
                         type="hidden"
207 207
                         class="redux-spacing-value"
208 208
                         id="' . esc_attr( $this->field['id'] ) . '-left-hidden"
209 209
                         name="' . esc_attr( $this->field['name'] . $this->field['name_suffix'] . '[' . $this->field['mode'] ) . 'left]"
210 210
                         value="' . esc_attr( $this->value['left'] ) . ( ! empty( $this->value['left'] ) ? esc_attr( $this->value['units'] ) : '' ) . '"
211 211
                       >';
212
-			}
213
-
214
-			if ( false === $this->field['all'] ) {
215
-				/**
216
-				 * Top
217
-				 * */
218
-				if ( true === $this->field['top'] ) {
219
-					echo '<div class="field-spacing-input input-prepend">
212
+            }
213
+
214
+            if ( false === $this->field['all'] ) {
215
+                /**
216
+                 * Top
217
+                 * */
218
+                if ( true === $this->field['top'] ) {
219
+                    echo '<div class="field-spacing-input input-prepend">
220 220
                             <span class="add-on">
221 221
                                 <i class="el el-arrow-up icon-large"></i>
222 222
                             </span>
@@ -227,13 +227,13 @@  discard block
 block discarded – undo
227 227
                                    rel="' . esc_attr( $this->field['id'] ) . '-top-hidden"
228 228
                                    value="' . esc_attr( $this->value['top'] ) . '"/>
229 229
                         </div>';
230
-				}
230
+                }
231 231
 
232
-				/**
233
-				 * Right
234
-				 * */
235
-				if ( true === $this->field['right'] ) {
236
-					echo '<div class="field-spacing-input input-prepend">
232
+                /**
233
+                 * Right
234
+                 * */
235
+                if ( true === $this->field['right'] ) {
236
+                    echo '<div class="field-spacing-input input-prepend">
237 237
                             <span class="add-on">
238 238
                                 <i class="el el-arrow-right icon-large"></i>
239 239
                             </span>
@@ -244,13 +244,13 @@  discard block
 block discarded – undo
244 244
                                    rel="' . esc_attr( $this->field['id'] ) . '-right-hidden"
245 245
                                    value="' . esc_attr( $this->value['right'] ) . '"/>
246 246
                         </div>';
247
-				}
247
+                }
248 248
 
249
-				/**
250
-				 * Bottom
251
-				 * */
252
-				if ( true === $this->field['bottom'] ) {
253
-					echo '<div class="field-spacing-input input-prepend">
249
+                /**
250
+                 * Bottom
251
+                 * */
252
+                if ( true === $this->field['bottom'] ) {
253
+                    echo '<div class="field-spacing-input input-prepend">
254 254
                             <span class="add-on">
255 255
                                 <i class="el el-arrow-down icon-large"></i>
256 256
                             </span>
@@ -261,13 +261,13 @@  discard block
 block discarded – undo
261 261
                                    rel="' . esc_attr( $this->field['id'] ) . '-bottom-hidden"
262 262
                                    value="' . esc_attr( $this->value['bottom'] ) . '">
263 263
                         </div>';
264
-				}
264
+                }
265 265
 
266
-				/**
267
-				 * Left
268
-				 * */
269
-				if ( true === $this->field['left'] ) {
270
-					echo '<div class="field-spacing-input input-prepend">
266
+                /**
267
+                 * Left
268
+                 * */
269
+                if ( true === $this->field['left'] ) {
270
+                    echo '<div class="field-spacing-input input-prepend">
271 271
                             <span class="add-on">
272 272
                                 <i class="el el-arrow-left icon-large"></i>
273 273
                             </span>
@@ -278,120 +278,120 @@  discard block
 block discarded – undo
278 278
                                    rel="' . esc_attr( $this->field['id'] ) . '-left-hidden"
279 279
                                    value="' . esc_attr( $this->value['left'] ) . '"/>
280 280
                         </div>';
281
-				}
282
-			}
283
-
284
-			/**
285
-			 * Units
286
-			 * */
287
-			if ( false !== $this->field['units'] && true === $this->field['display_units'] ) {
288
-				echo '<div class="select_wrapper spacing-units" original-title="' . esc_html__( 'Units', 'redux-framework' ) . '">';
289
-				echo '<select data-placeholder="' . esc_html__( 'Units', 'redux-framework' ) . '" class="redux-spacing redux-spacing-units select ' . esc_attr( $this->field['class'] ) . '" original-title="' . esc_html__( 'Units', 'redux-framework' ) . '" id="' . esc_attr( $this->field['id'] ) . '_units"' . esc_attr( $select2_data ) . '>';
290
-
291
-				if ( $this->field['units_extended'] ) {
292
-					$test_units = $unit_arr;
293
-				} else {
294
-					$test_units = array( 'px', 'em', 'pt', 'rem', '%' );
295
-				}
296
-
297
-				if ( '' !== $this->field['units'] || is_array( $this->field['units'] ) ) {
298
-					$test_units = $this->field['units'];
299
-				}
300
-
301
-				echo '<option></option>';
302
-
303
-				if ( ! is_array( $this->field['units'] ) ) {
304
-					echo '<option value="' . esc_attr( $this->field['units'] ) . '" selected="selected">' . esc_attr( $this->field['units'] ) . '</option>';
305
-				} else {
306
-					foreach ( $test_units as $a_unit ) {
307
-						echo '<option value="' . esc_attr( $a_unit ) . '" ' . selected( $this->value['units'], $a_unit, false ) . '>' . esc_html( $a_unit ) . '</option>';
308
-					}
309
-				}
310
-
311
-				echo '</select></div>';
312
-			}
313
-		}
314
-
315
-		/**
316
-		 * Enqueue Function.
317
-		 * If this field requires any scripts, or css define this function and register/enqueue the scripts/css
318
-		 *
319
-		 * @since ReduxFramework 1.0.0
320
-		 */
321
-		public function enqueue() {
322
-			wp_enqueue_style( 'select2-css' );
323
-
324
-			wp_enqueue_script(
325
-				'redux-field-spacing',
326
-				Redux_Core::$url . 'inc/fields/spacing/redux-spacing' . Redux_Functions::is_min() . '.js',
327
-				array( 'jquery', 'select2-js', 'redux-js' ),
328
-				$this->timestamp,
329
-				true
330
-			);
331
-
332
-			if ( $this->parent->args['dev_mode'] ) {
333
-				wp_enqueue_style(
334
-					'redux-field-spacing',
335
-					Redux_Core::$url . 'inc/fields/spacing/redux-spacing.css',
336
-					array(),
337
-					$this->timestamp
338
-				);
339
-			}
340
-		}
341
-
342
-		/**
343
-		 * Compile CSS data for output.
344
-		 *
345
-		 * @param string $data CSS data.
346
-		 *
347
-		 * @return string|void
348
-		 */
349
-		public function css_style( $data ) {
350
-			$style = '';
351
-
352
-			$data = (array) $data;
353
-
354
-			if ( ! isset( $this->field ) ) {
355
-				return;
356
-			}
357
-
358
-			if ( ! in_array( $this->field['mode'], array( 'padding', 'absolute', 'margin' ), true ) ) {
359
-				$this->field['mode'] = 'padding';
360
-			}
361
-
362
-			$units = $data['units'] ?? '';
363
-
364
-			foreach ( $data as $key => $value ) {
365
-				if ( 'units' === $key ) {
366
-					continue;
367
-				}
368
-				$the_units = $units;
369
-
370
-				// Strip off any alpha for is_numeric test - kp.
371
-				$num_no_alpha = preg_replace( '/[^\d.-]/', '', $value );
372
-				if ( empty( $the_units ) ) {
373
-					$the_units = str_replace( $num_no_alpha, '', $value );
374
-				}
375
-
376
-				// Output if it's a numeric entry.
377
-				if ( isset( $value ) && is_numeric( $num_no_alpha ) ) {
378
-					$style .= $key . ':' . $num_no_alpha . $the_units . ';';
379
-				}
380
-			}
381
-
382
-			return $style;
383
-		}
384
-
385
-		/**
386
-		 * Enable output_variables to be generated.
387
-		 *
388
-		 * @since       4.0.3
389
-		 * @return void
390
-		 */
391
-		public function output_variables() {
392
-			// No code needed, just defining the method is enough.
393
-		}
394
-	}
281
+                }
282
+            }
283
+
284
+            /**
285
+             * Units
286
+             * */
287
+            if ( false !== $this->field['units'] && true === $this->field['display_units'] ) {
288
+                echo '<div class="select_wrapper spacing-units" original-title="' . esc_html__( 'Units', 'redux-framework' ) . '">';
289
+                echo '<select data-placeholder="' . esc_html__( 'Units', 'redux-framework' ) . '" class="redux-spacing redux-spacing-units select ' . esc_attr( $this->field['class'] ) . '" original-title="' . esc_html__( 'Units', 'redux-framework' ) . '" id="' . esc_attr( $this->field['id'] ) . '_units"' . esc_attr( $select2_data ) . '>';
290
+
291
+                if ( $this->field['units_extended'] ) {
292
+                    $test_units = $unit_arr;
293
+                } else {
294
+                    $test_units = array( 'px', 'em', 'pt', 'rem', '%' );
295
+                }
296
+
297
+                if ( '' !== $this->field['units'] || is_array( $this->field['units'] ) ) {
298
+                    $test_units = $this->field['units'];
299
+                }
300
+
301
+                echo '<option></option>';
302
+
303
+                if ( ! is_array( $this->field['units'] ) ) {
304
+                    echo '<option value="' . esc_attr( $this->field['units'] ) . '" selected="selected">' . esc_attr( $this->field['units'] ) . '</option>';
305
+                } else {
306
+                    foreach ( $test_units as $a_unit ) {
307
+                        echo '<option value="' . esc_attr( $a_unit ) . '" ' . selected( $this->value['units'], $a_unit, false ) . '>' . esc_html( $a_unit ) . '</option>';
308
+                    }
309
+                }
310
+
311
+                echo '</select></div>';
312
+            }
313
+        }
314
+
315
+        /**
316
+         * Enqueue Function.
317
+         * If this field requires any scripts, or css define this function and register/enqueue the scripts/css
318
+         *
319
+         * @since ReduxFramework 1.0.0
320
+         */
321
+        public function enqueue() {
322
+            wp_enqueue_style( 'select2-css' );
323
+
324
+            wp_enqueue_script(
325
+                'redux-field-spacing',
326
+                Redux_Core::$url . 'inc/fields/spacing/redux-spacing' . Redux_Functions::is_min() . '.js',
327
+                array( 'jquery', 'select2-js', 'redux-js' ),
328
+                $this->timestamp,
329
+                true
330
+            );
331
+
332
+            if ( $this->parent->args['dev_mode'] ) {
333
+                wp_enqueue_style(
334
+                    'redux-field-spacing',
335
+                    Redux_Core::$url . 'inc/fields/spacing/redux-spacing.css',
336
+                    array(),
337
+                    $this->timestamp
338
+                );
339
+            }
340
+        }
341
+
342
+        /**
343
+         * Compile CSS data for output.
344
+         *
345
+         * @param string $data CSS data.
346
+         *
347
+         * @return string|void
348
+         */
349
+        public function css_style( $data ) {
350
+            $style = '';
351
+
352
+            $data = (array) $data;
353
+
354
+            if ( ! isset( $this->field ) ) {
355
+                return;
356
+            }
357
+
358
+            if ( ! in_array( $this->field['mode'], array( 'padding', 'absolute', 'margin' ), true ) ) {
359
+                $this->field['mode'] = 'padding';
360
+            }
361
+
362
+            $units = $data['units'] ?? '';
363
+
364
+            foreach ( $data as $key => $value ) {
365
+                if ( 'units' === $key ) {
366
+                    continue;
367
+                }
368
+                $the_units = $units;
369
+
370
+                // Strip off any alpha for is_numeric test - kp.
371
+                $num_no_alpha = preg_replace( '/[^\d.-]/', '', $value );
372
+                if ( empty( $the_units ) ) {
373
+                    $the_units = str_replace( $num_no_alpha, '', $value );
374
+                }
375
+
376
+                // Output if it's a numeric entry.
377
+                if ( isset( $value ) && is_numeric( $num_no_alpha ) ) {
378
+                    $style .= $key . ':' . $num_no_alpha . $the_units . ';';
379
+                }
380
+            }
381
+
382
+            return $style;
383
+        }
384
+
385
+        /**
386
+         * Enable output_variables to be generated.
387
+         *
388
+         * @since       4.0.3
389
+         * @return void
390
+         */
391
+        public function output_variables() {
392
+            // No code needed, just defining the method is enough.
393
+        }
394
+    }
395 395
 }
396 396
 
397 397
 class_alias( 'Redux_Spacing', 'ReduxFramework_Spacing' );
Please login to merge, or discard this patch.
redux-core/inc/fields/media/class-redux-media.php 2 patches
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -144,11 +144,11 @@  discard block
 block discarded – undo
144 144
 
145 145
 						foreach ( $ex_arr as $ext ) {
146 146
 							if ( in_array( $ext, $lib_array, true ) ) {
147
-								$json_arr[ $ext ] = $type;
147
+								$json_arr[$ext] = $type;
148 148
 							}
149 149
 						}
150 150
 					} elseif ( in_array( $ext, $lib_array, true ) ) {
151
-						$json_arr[ $ext ] = $type;
151
+						$json_arr[$ext] = $type;
152 152
 					}
153 153
 				}
154 154
 
@@ -301,7 +301,7 @@  discard block
 block discarded – undo
301 301
 		 * @return string|null
302 302
 		 */
303 303
 		public function css_style( $data ): string {
304
-			$data = (array) $data;
304
+			$data = ( array ) $data;
305 305
 
306 306
 			if ( isset( $data['filter'] ) ) {
307 307
 				return $this->get_filter_css( $data['filter'] );
Please login to merge, or discard this patch.
Indentation   +333 added lines, -333 removed lines patch added patch discarded remove patch
@@ -12,339 +12,339 @@
 block discarded – undo
12 12
 // Don't duplicate me!
13 13
 if ( ! class_exists( 'Redux_Media', false ) ) {
14 14
 
15
-	/**
16
-	 * Main Redux_media class
17
-	 *
18
-	 * @since       1.0.0
19
-	 */
20
-	class Redux_Media extends Redux_Field {
21
-
22
-		/**
23
-		 * Flag to filter file types.
24
-		 *
25
-		 * @var bool $filters_enabled .
26
-		 */
27
-		private $filters_enabled = false;
28
-
29
-		/**
30
-		 * Set field and value defaults.
31
-		 */
32
-		public function set_defaults() {
33
-			// No errors please.
34
-			$defaults = array(
35
-				'id'        => '',
36
-				'url'       => '',
37
-				'width'     => '',
38
-				'height'    => '',
39
-				'thumbnail' => '',
40
-				'filter'    => array(
41
-					'grayscale'  => array(
42
-						'checked' => false,
43
-						'value'   => 0,
44
-					),
45
-					'blur'       => array(
46
-						'checked' => false,
47
-						'value'   => 0,
48
-					),
49
-					'sepia'      => array(
50
-						'checked' => false,
51
-						'value'   => 0,
52
-					),
53
-					'saturate'   => array(
54
-						'checked' => false,
55
-						'value'   => 1,
56
-					),
57
-					'opacity'    => array(
58
-						'checked' => false,
59
-						'value'   => 1,
60
-					),
61
-					'brightness' => array(
62
-						'checked' => false,
63
-						'value'   => 100,
64
-					),
65
-					'contrast'   => array(
66
-						'checked' => false,
67
-						'value'   => 100,
68
-					),
69
-					'hue-rotate' => array(
70
-						'checked' => false,
71
-						'value'   => 0,
72
-					),
73
-					'invert'     => array(
74
-						'checked' => false,
75
-						'value'   => 0,
76
-					),
77
-				),
78
-			);
79
-
80
-			// Since value sub-arrays do not get parsed in wp_parse_args!
81
-			$this->value = Redux_Functions::parse_args( $this->value, $defaults );
82
-
83
-			$defaults = array(
84
-				'mode'         => 'image',
85
-				'preview'      => true,
86
-				'preview_size' => 'thumbnail',
87
-				'url'          => true,
88
-				'alt'          => '',
89
-				'placeholder'  => esc_html__( 'No media selected', 'redux-framework' ),
90
-				'readonly'     => true,
91
-				'class'        => '',
92
-				'filter'       => array(
93
-					'grayscale'  => false,
94
-					'blur'       => false,
95
-					'sepia'      => false,
96
-					'saturate'   => false,
97
-					'opacity'    => false,
98
-					'brightness' => false,
99
-					'contrast'   => false,
100
-					'hue-rotate' => false,
101
-					'invert'     => false,
102
-				),
103
-			);
104
-
105
-			$this->field = Redux_Functions::parse_args( $this->field, $defaults );
106
-
107
-			if ( false === $this->field['mode'] ) {
108
-				$this->field['mode'] = 0;
109
-			}
110
-
111
-			include_once Redux_Core::$dir . 'inc/lib/image-filters/class-redux-image-filters.php';
112
-			if ( in_array( true, $this->field['filter'], true ) ) {
113
-				$this->filters_enabled = true;
114
-				include_once Redux_Core::$dir . 'inc/lib/image-filters/class-redux-image-filters.php';
115
-			}
116
-		}
117
-
118
-		/**
119
-		 * Field Render Function.
120
-		 * Takes the vars and outputs the HTML for the field in the settings
121
-		 *
122
-		 * @since       1.0.0
123
-		 * @access      public
124
-		 * @return      void
125
-		 */
126
-		public function render() {
127
-			if ( ! isset( $this->field['library_filter'] ) ) {
128
-				$lib_filter = '';
129
-			} else {
130
-				if ( ! is_array( $this->field['library_filter'] ) ) {
131
-					$this->field['library_filter'] = array( $this->field['library_filter'] );
132
-				}
133
-
134
-				$mime_types = get_allowed_mime_types();
135
-
136
-				$lib_array = $this->field['library_filter'];
137
-
138
-				$json_arr = array();
139
-
140
-				// Enum mime types.
141
-				foreach ( $mime_types as $ext => $type ) {
142
-					if ( strpos( $ext, '|' ) ) {
143
-						$ex_arr = explode( '|', $ext );
144
-
145
-						foreach ( $ex_arr as $ext ) {
146
-							if ( in_array( $ext, $lib_array, true ) ) {
147
-								$json_arr[ $ext ] = $type;
148
-							}
149
-						}
150
-					} elseif ( in_array( $ext, $lib_array, true ) ) {
151
-						$json_arr[ $ext ] = $type;
152
-					}
153
-				}
154
-
155
-				$lib_filter = rawurlencode( wp_json_encode( $json_arr ) );
156
-			}
157
-
158
-			if ( empty( $this->value ) && ! empty( $this->field['default'] ) ) { // If there are standard values and value is empty.
159
-				if ( is_array( $this->field['default'] ) ) {
160
-					if ( ! empty( $this->field['default']['id'] ) ) {
161
-						$this->value['id'] = $this->field['default']['id'];
162
-					}
163
-
164
-					if ( ! empty( $this->field['default']['url'] ) ) {
165
-						$this->value['url'] = $this->field['default']['url'];
166
-					}
167
-				} elseif ( is_numeric( $this->field['default'] ) ) {
168
-					// Check if it's an attachment ID.
169
-					$this->value['id'] = $this->field['default'];
170
-				} else { // Must be a URL.
171
-					$this->value['url'] = $this->field['default'];
172
-				}
173
-			}
174
-
175
-			if ( empty( $this->value['url'] ) && ! empty( $this->value['id'] ) ) {
176
-				$img                   = wp_get_attachment_image_src( $this->value['id'], 'full' );
177
-				$this->value['url']    = $img[0];
178
-				$this->value['width']  = $img[1];
179
-				$this->value['height'] = $img[2];
180
-			}
181
-
182
-			$hide = 'hide ';
183
-
184
-			if ( false === $this->field['preview'] ) {
185
-				$this->field['class'] .= ' noPreview';
186
-			}
187
-
188
-			if ( ( ! empty( $this->field['url'] ) && true === $this->field['url'] ) || false === $this->field['preview'] ) {
189
-				$hide = '';
190
-			}
191
-
192
-			$read_only = '';
193
-			if ( $this->field['readonly'] ) {
194
-				$read_only = ' readonly="readonly"';
195
-			}
196
-
197
-			echo '<input placeholder="' . esc_attr( $this->field['placeholder'] ) . '" type="text" class="' . esc_attr( $hide ) . 'upload large-text ' . esc_attr( $this->field['class'] ) . '" name="' . esc_attr( $this->field['name'] . $this->field['name_suffix'] ) . '[url]" id="' . esc_attr( $this->parent->args['opt_name'] ) . '[' . esc_attr( $this->field['id'] ) . '][url]" value="' . esc_attr( $this->value['url'] ) . '"' . esc_html( $read_only ) . '/>';
198
-			echo '<input type="hidden" class="data" data-preview-size="' . esc_attr( $this->field['preview_size'] ) . '" data-mode="' . esc_attr( $this->field['mode'] ) . '" />';
199
-			echo '<input type="hidden" class="library-filter" data-lib-filter="' . $lib_filter . '" />'; // phpcs:ignore WordPress.Security.EscapeOutput
200
-			echo '<input type="hidden" class="upload-id ' . esc_attr( $this->field['class'] ) . '" name="' . esc_attr( $this->field['name'] . $this->field['name_suffix'] ) . '[id]" id="' . esc_attr( $this->parent->args['opt_name'] ) . '[' . esc_attr( $this->field['id'] ) . '][id]" value="' . esc_attr( $this->value['id'] ) . '" />';
201
-			echo '<input type="hidden" class="upload-height" name="' . esc_attr( $this->field['name'] . $this->field['name_suffix'] ) . '[height]" id="' . esc_attr( $this->parent->args['opt_name'] ) . '[' . esc_attr( $this->field['id'] ) . '][height]" value="' . esc_attr( $this->value['height'] ) . '" />';
202
-			echo '<input type="hidden" class="upload-width" name="' . esc_attr( $this->field['name'] . $this->field['name_suffix'] ) . '[width]" id="' . esc_attr( $this->parent->args['opt_name'] ) . '[' . esc_attr( $this->field['id'] ) . '][width]" value="' . esc_attr( $this->value['width'] ) . '" />';
203
-			echo '<input type="hidden" class="upload-thumbnail" name="' . esc_attr( $this->field['name'] . $this->field['name_suffix'] ) . '[thumbnail]" id="' . esc_attr( $this->parent->args['opt_name'] ) . '[' . esc_attr( $this->field['id'] ) . '][thumbnail]" value="' . esc_attr( $this->value['thumbnail'] ) . '" />';
204
-
205
-			// Preview.
206
-			$hide = '';
207
-
208
-			if ( ( false === $this->field['preview'] ) || empty( $this->value['url'] ) ) {
209
-				$hide .= 'display:none;';
210
-			}
211
-
212
-			if ( empty( $this->value['thumbnail'] ) && ! empty( $this->value['url'] ) ) { // Just in case.
213
-				if ( ! empty( $this->value['id'] ) ) {
214
-					$image = wp_get_attachment_image_src( $this->value['id'], array( 150, 150 ) );
215
-
216
-					if ( empty( $image[0] ) ) {
217
-						$this->value['thumbnail'] = $this->value['url'];
218
-					} else {
219
-						$this->value['thumbnail'] = $image[0];
220
-					}
221
-				} else {
222
-					$this->value['thumbnail'] = $this->value['url'];
223
-				}
224
-			}
225
-
226
-			$css = $this->get_filter_css( $this->value['filter'] );
227
-
228
-			$alt = wp_prepare_attachment_for_js( $this->value['id'] );
229
-			$alt = $alt['alt'] ?? '';
230
-
231
-			echo '<div class="screenshot" style="' . esc_attr( $hide ) . '">';
232
-			echo '<a class="of-uploaded-image" href="' . esc_url( $this->value['url'] ) . '" target="_blank">';
233
-			echo '<img class="redux-option-image" id="image_' . esc_attr( $this->field['id'] ) . '" src="' . esc_url( $this->value['thumbnail'] ) . '" alt="' . esc_attr( $alt ) . '" target="_blank" rel="external" style="' . $css . '" />'; // phpcs:ignore WordPress.Security.EscapeOutput
234
-			echo '</a>';
235
-			echo '</div>';
236
-
237
-			// Upload controls DIV.
238
-			echo '<div class="upload_button_div">';
239
-
240
-			// If the user has WP3.5+ show upload/remove button.
241
-			echo '<span class="button media_upload_button" id="' . esc_attr( $this->field['id'] ) . '-media">' . esc_html__( 'Upload', 'redux-framework' ) . '</span>';
242
-
243
-			$hide = '';
244
-			if ( empty( $this->value['url'] ) || '' === $this->value['url'] ) {
245
-				$hide = ' hide';
246
-			}
247
-
248
-			echo '<span class="button remove-image' . esc_attr( $hide ) . '" id="reset_' . esc_attr( $this->field['id'] ) . '" rel="' . esc_attr( $this->field['id'] ) . '">' . esc_html__( 'Remove', 'redux-framework' ) . '</span>';
249
-			echo '</div>';
250
-
251
-			if ( $this->filters_enabled ) {
252
-				$data = array(
253
-					'parent' => $this->parent,
254
-					'field'  => $this->field,
255
-					'value'  => $this->value,
256
-					'mode'   => 'media',
257
-				);
258
-
259
-				echo Redux_Image_Filters::render( $data ); // phpcs:ignore WordPress.Security.EscapeOutput
260
-			}
261
-		}
262
-
263
-		/**
264
-		 * Do enqueue for each field instance.
265
-		 *
266
-		 * @return void
267
-		 */
268
-		public function always_enqueue() {
269
-			Redux_Image_Filters::enqueue( $this->filters_enabled );
270
-		}
271
-
272
-		/**
273
-		 * Enqueue Function.
274
-		 * If this field requires any scripts, or CSS define this function and register/enqueue the scripts/css
275
-		 *
276
-		 * @since       1.0.0
277
-		 * @access      public
278
-		 * @return      void
279
-		 */
280
-		public function enqueue() {
281
-			if ( function_exists( 'wp_enqueue_media' ) ) {
282
-				wp_enqueue_media();
283
-			} else {
284
-				wp_enqueue_script( 'media-upload' );
285
-			}
286
-
287
-			wp_enqueue_script(
288
-				'redux-field-media',
289
-				Redux_Core::$url . 'assets/js/media/media' . Redux_Functions::is_min() . '.js',
290
-				array( 'jquery', 'redux-js' ),
291
-				$this->timestamp,
292
-				true
293
-			);
294
-
295
-			if ( $this->parent->args['dev_mode'] ) {
296
-				wp_enqueue_style( 'redux-field-media' );
297
-			}
298
-		}
299
-
300
-		/**
301
-		 * Compile CSS styles for output.
302
-		 *
303
-		 * @param string $data CSS data.
304
-		 *
305
-		 * @return string|null
306
-		 */
307
-		public function css_style( $data ): string {
308
-			$data = (array) $data;
309
-
310
-			if ( isset( $data['filter'] ) ) {
311
-				return $this->get_filter_css( $data['filter'] );
312
-			}
313
-
314
-			return '';
315
-		}
316
-
317
-		/**
318
-		 * Get filter CSS.
319
-		 *
320
-		 * @param array $data Data.
321
-		 *
322
-		 * @return string
323
-		 */
324
-		private function get_filter_css( array $data ): string {
325
-			$css = '';
326
-
327
-			foreach ( $data as $filter => $values ) {
328
-				$checked = filter_var( $values['checked'], FILTER_VALIDATE_BOOLEAN );
329
-
330
-				if ( true === $checked ) {
331
-					$unit = Redux_Image_Filters::get_filter_unit( $filter );
332
-
333
-					if ( '&deg;' === $unit ) {
334
-						$unit = 'deg';
335
-					}
336
-
337
-					$css .= ' ' . $filter . '(' . $values['value'] . $unit . ')';
338
-				}
339
-			}
340
-
341
-			if ( '' !== $css ) {
342
-				return 'filter:' . $css . ';-webkit-filter:' . $css . ';';
343
-			}
344
-
345
-			return '';
346
-		}
347
-	}
15
+    /**
16
+     * Main Redux_media class
17
+     *
18
+     * @since       1.0.0
19
+     */
20
+    class Redux_Media extends Redux_Field {
21
+
22
+        /**
23
+         * Flag to filter file types.
24
+         *
25
+         * @var bool $filters_enabled .
26
+         */
27
+        private $filters_enabled = false;
28
+
29
+        /**
30
+         * Set field and value defaults.
31
+         */
32
+        public function set_defaults() {
33
+            // No errors please.
34
+            $defaults = array(
35
+                'id'        => '',
36
+                'url'       => '',
37
+                'width'     => '',
38
+                'height'    => '',
39
+                'thumbnail' => '',
40
+                'filter'    => array(
41
+                    'grayscale'  => array(
42
+                        'checked' => false,
43
+                        'value'   => 0,
44
+                    ),
45
+                    'blur'       => array(
46
+                        'checked' => false,
47
+                        'value'   => 0,
48
+                    ),
49
+                    'sepia'      => array(
50
+                        'checked' => false,
51
+                        'value'   => 0,
52
+                    ),
53
+                    'saturate'   => array(
54
+                        'checked' => false,
55
+                        'value'   => 1,
56
+                    ),
57
+                    'opacity'    => array(
58
+                        'checked' => false,
59
+                        'value'   => 1,
60
+                    ),
61
+                    'brightness' => array(
62
+                        'checked' => false,
63
+                        'value'   => 100,
64
+                    ),
65
+                    'contrast'   => array(
66
+                        'checked' => false,
67
+                        'value'   => 100,
68
+                    ),
69
+                    'hue-rotate' => array(
70
+                        'checked' => false,
71
+                        'value'   => 0,
72
+                    ),
73
+                    'invert'     => array(
74
+                        'checked' => false,
75
+                        'value'   => 0,
76
+                    ),
77
+                ),
78
+            );
79
+
80
+            // Since value sub-arrays do not get parsed in wp_parse_args!
81
+            $this->value = Redux_Functions::parse_args( $this->value, $defaults );
82
+
83
+            $defaults = array(
84
+                'mode'         => 'image',
85
+                'preview'      => true,
86
+                'preview_size' => 'thumbnail',
87
+                'url'          => true,
88
+                'alt'          => '',
89
+                'placeholder'  => esc_html__( 'No media selected', 'redux-framework' ),
90
+                'readonly'     => true,
91
+                'class'        => '',
92
+                'filter'       => array(
93
+                    'grayscale'  => false,
94
+                    'blur'       => false,
95
+                    'sepia'      => false,
96
+                    'saturate'   => false,
97
+                    'opacity'    => false,
98
+                    'brightness' => false,
99
+                    'contrast'   => false,
100
+                    'hue-rotate' => false,
101
+                    'invert'     => false,
102
+                ),
103
+            );
104
+
105
+            $this->field = Redux_Functions::parse_args( $this->field, $defaults );
106
+
107
+            if ( false === $this->field['mode'] ) {
108
+                $this->field['mode'] = 0;
109
+            }
110
+
111
+            include_once Redux_Core::$dir . 'inc/lib/image-filters/class-redux-image-filters.php';
112
+            if ( in_array( true, $this->field['filter'], true ) ) {
113
+                $this->filters_enabled = true;
114
+                include_once Redux_Core::$dir . 'inc/lib/image-filters/class-redux-image-filters.php';
115
+            }
116
+        }
117
+
118
+        /**
119
+         * Field Render Function.
120
+         * Takes the vars and outputs the HTML for the field in the settings
121
+         *
122
+         * @since       1.0.0
123
+         * @access      public
124
+         * @return      void
125
+         */
126
+        public function render() {
127
+            if ( ! isset( $this->field['library_filter'] ) ) {
128
+                $lib_filter = '';
129
+            } else {
130
+                if ( ! is_array( $this->field['library_filter'] ) ) {
131
+                    $this->field['library_filter'] = array( $this->field['library_filter'] );
132
+                }
133
+
134
+                $mime_types = get_allowed_mime_types();
135
+
136
+                $lib_array = $this->field['library_filter'];
137
+
138
+                $json_arr = array();
139
+
140
+                // Enum mime types.
141
+                foreach ( $mime_types as $ext => $type ) {
142
+                    if ( strpos( $ext, '|' ) ) {
143
+                        $ex_arr = explode( '|', $ext );
144
+
145
+                        foreach ( $ex_arr as $ext ) {
146
+                            if ( in_array( $ext, $lib_array, true ) ) {
147
+                                $json_arr[ $ext ] = $type;
148
+                            }
149
+                        }
150
+                    } elseif ( in_array( $ext, $lib_array, true ) ) {
151
+                        $json_arr[ $ext ] = $type;
152
+                    }
153
+                }
154
+
155
+                $lib_filter = rawurlencode( wp_json_encode( $json_arr ) );
156
+            }
157
+
158
+            if ( empty( $this->value ) && ! empty( $this->field['default'] ) ) { // If there are standard values and value is empty.
159
+                if ( is_array( $this->field['default'] ) ) {
160
+                    if ( ! empty( $this->field['default']['id'] ) ) {
161
+                        $this->value['id'] = $this->field['default']['id'];
162
+                    }
163
+
164
+                    if ( ! empty( $this->field['default']['url'] ) ) {
165
+                        $this->value['url'] = $this->field['default']['url'];
166
+                    }
167
+                } elseif ( is_numeric( $this->field['default'] ) ) {
168
+                    // Check if it's an attachment ID.
169
+                    $this->value['id'] = $this->field['default'];
170
+                } else { // Must be a URL.
171
+                    $this->value['url'] = $this->field['default'];
172
+                }
173
+            }
174
+
175
+            if ( empty( $this->value['url'] ) && ! empty( $this->value['id'] ) ) {
176
+                $img                   = wp_get_attachment_image_src( $this->value['id'], 'full' );
177
+                $this->value['url']    = $img[0];
178
+                $this->value['width']  = $img[1];
179
+                $this->value['height'] = $img[2];
180
+            }
181
+
182
+            $hide = 'hide ';
183
+
184
+            if ( false === $this->field['preview'] ) {
185
+                $this->field['class'] .= ' noPreview';
186
+            }
187
+
188
+            if ( ( ! empty( $this->field['url'] ) && true === $this->field['url'] ) || false === $this->field['preview'] ) {
189
+                $hide = '';
190
+            }
191
+
192
+            $read_only = '';
193
+            if ( $this->field['readonly'] ) {
194
+                $read_only = ' readonly="readonly"';
195
+            }
196
+
197
+            echo '<input placeholder="' . esc_attr( $this->field['placeholder'] ) . '" type="text" class="' . esc_attr( $hide ) . 'upload large-text ' . esc_attr( $this->field['class'] ) . '" name="' . esc_attr( $this->field['name'] . $this->field['name_suffix'] ) . '[url]" id="' . esc_attr( $this->parent->args['opt_name'] ) . '[' . esc_attr( $this->field['id'] ) . '][url]" value="' . esc_attr( $this->value['url'] ) . '"' . esc_html( $read_only ) . '/>';
198
+            echo '<input type="hidden" class="data" data-preview-size="' . esc_attr( $this->field['preview_size'] ) . '" data-mode="' . esc_attr( $this->field['mode'] ) . '" />';
199
+            echo '<input type="hidden" class="library-filter" data-lib-filter="' . $lib_filter . '" />'; // phpcs:ignore WordPress.Security.EscapeOutput
200
+            echo '<input type="hidden" class="upload-id ' . esc_attr( $this->field['class'] ) . '" name="' . esc_attr( $this->field['name'] . $this->field['name_suffix'] ) . '[id]" id="' . esc_attr( $this->parent->args['opt_name'] ) . '[' . esc_attr( $this->field['id'] ) . '][id]" value="' . esc_attr( $this->value['id'] ) . '" />';
201
+            echo '<input type="hidden" class="upload-height" name="' . esc_attr( $this->field['name'] . $this->field['name_suffix'] ) . '[height]" id="' . esc_attr( $this->parent->args['opt_name'] ) . '[' . esc_attr( $this->field['id'] ) . '][height]" value="' . esc_attr( $this->value['height'] ) . '" />';
202
+            echo '<input type="hidden" class="upload-width" name="' . esc_attr( $this->field['name'] . $this->field['name_suffix'] ) . '[width]" id="' . esc_attr( $this->parent->args['opt_name'] ) . '[' . esc_attr( $this->field['id'] ) . '][width]" value="' . esc_attr( $this->value['width'] ) . '" />';
203
+            echo '<input type="hidden" class="upload-thumbnail" name="' . esc_attr( $this->field['name'] . $this->field['name_suffix'] ) . '[thumbnail]" id="' . esc_attr( $this->parent->args['opt_name'] ) . '[' . esc_attr( $this->field['id'] ) . '][thumbnail]" value="' . esc_attr( $this->value['thumbnail'] ) . '" />';
204
+
205
+            // Preview.
206
+            $hide = '';
207
+
208
+            if ( ( false === $this->field['preview'] ) || empty( $this->value['url'] ) ) {
209
+                $hide .= 'display:none;';
210
+            }
211
+
212
+            if ( empty( $this->value['thumbnail'] ) && ! empty( $this->value['url'] ) ) { // Just in case.
213
+                if ( ! empty( $this->value['id'] ) ) {
214
+                    $image = wp_get_attachment_image_src( $this->value['id'], array( 150, 150 ) );
215
+
216
+                    if ( empty( $image[0] ) ) {
217
+                        $this->value['thumbnail'] = $this->value['url'];
218
+                    } else {
219
+                        $this->value['thumbnail'] = $image[0];
220
+                    }
221
+                } else {
222
+                    $this->value['thumbnail'] = $this->value['url'];
223
+                }
224
+            }
225
+
226
+            $css = $this->get_filter_css( $this->value['filter'] );
227
+
228
+            $alt = wp_prepare_attachment_for_js( $this->value['id'] );
229
+            $alt = $alt['alt'] ?? '';
230
+
231
+            echo '<div class="screenshot" style="' . esc_attr( $hide ) . '">';
232
+            echo '<a class="of-uploaded-image" href="' . esc_url( $this->value['url'] ) . '" target="_blank">';
233
+            echo '<img class="redux-option-image" id="image_' . esc_attr( $this->field['id'] ) . '" src="' . esc_url( $this->value['thumbnail'] ) . '" alt="' . esc_attr( $alt ) . '" target="_blank" rel="external" style="' . $css . '" />'; // phpcs:ignore WordPress.Security.EscapeOutput
234
+            echo '</a>';
235
+            echo '</div>';
236
+
237
+            // Upload controls DIV.
238
+            echo '<div class="upload_button_div">';
239
+
240
+            // If the user has WP3.5+ show upload/remove button.
241
+            echo '<span class="button media_upload_button" id="' . esc_attr( $this->field['id'] ) . '-media">' . esc_html__( 'Upload', 'redux-framework' ) . '</span>';
242
+
243
+            $hide = '';
244
+            if ( empty( $this->value['url'] ) || '' === $this->value['url'] ) {
245
+                $hide = ' hide';
246
+            }
247
+
248
+            echo '<span class="button remove-image' . esc_attr( $hide ) . '" id="reset_' . esc_attr( $this->field['id'] ) . '" rel="' . esc_attr( $this->field['id'] ) . '">' . esc_html__( 'Remove', 'redux-framework' ) . '</span>';
249
+            echo '</div>';
250
+
251
+            if ( $this->filters_enabled ) {
252
+                $data = array(
253
+                    'parent' => $this->parent,
254
+                    'field'  => $this->field,
255
+                    'value'  => $this->value,
256
+                    'mode'   => 'media',
257
+                );
258
+
259
+                echo Redux_Image_Filters::render( $data ); // phpcs:ignore WordPress.Security.EscapeOutput
260
+            }
261
+        }
262
+
263
+        /**
264
+         * Do enqueue for each field instance.
265
+         *
266
+         * @return void
267
+         */
268
+        public function always_enqueue() {
269
+            Redux_Image_Filters::enqueue( $this->filters_enabled );
270
+        }
271
+
272
+        /**
273
+         * Enqueue Function.
274
+         * If this field requires any scripts, or CSS define this function and register/enqueue the scripts/css
275
+         *
276
+         * @since       1.0.0
277
+         * @access      public
278
+         * @return      void
279
+         */
280
+        public function enqueue() {
281
+            if ( function_exists( 'wp_enqueue_media' ) ) {
282
+                wp_enqueue_media();
283
+            } else {
284
+                wp_enqueue_script( 'media-upload' );
285
+            }
286
+
287
+            wp_enqueue_script(
288
+                'redux-field-media',
289
+                Redux_Core::$url . 'assets/js/media/media' . Redux_Functions::is_min() . '.js',
290
+                array( 'jquery', 'redux-js' ),
291
+                $this->timestamp,
292
+                true
293
+            );
294
+
295
+            if ( $this->parent->args['dev_mode'] ) {
296
+                wp_enqueue_style( 'redux-field-media' );
297
+            }
298
+        }
299
+
300
+        /**
301
+         * Compile CSS styles for output.
302
+         *
303
+         * @param string $data CSS data.
304
+         *
305
+         * @return string|null
306
+         */
307
+        public function css_style( $data ): string {
308
+            $data = (array) $data;
309
+
310
+            if ( isset( $data['filter'] ) ) {
311
+                return $this->get_filter_css( $data['filter'] );
312
+            }
313
+
314
+            return '';
315
+        }
316
+
317
+        /**
318
+         * Get filter CSS.
319
+         *
320
+         * @param array $data Data.
321
+         *
322
+         * @return string
323
+         */
324
+        private function get_filter_css( array $data ): string {
325
+            $css = '';
326
+
327
+            foreach ( $data as $filter => $values ) {
328
+                $checked = filter_var( $values['checked'], FILTER_VALIDATE_BOOLEAN );
329
+
330
+                if ( true === $checked ) {
331
+                    $unit = Redux_Image_Filters::get_filter_unit( $filter );
332
+
333
+                    if ( '&deg;' === $unit ) {
334
+                        $unit = 'deg';
335
+                    }
336
+
337
+                    $css .= ' ' . $filter . '(' . $values['value'] . $unit . ')';
338
+                }
339
+            }
340
+
341
+            if ( '' !== $css ) {
342
+                return 'filter:' . $css . ';-webkit-filter:' . $css . ';';
343
+            }
344
+
345
+            return '';
346
+        }
347
+    }
348 348
 }
349 349
 
350 350
 class_alias( 'Redux_Media', 'ReduxFramework_Media' );
Please login to merge, or discard this patch.
redux-core/templates/panel/menu-container.tpl.php 1 patch
Indentation   +23 added lines, -23 removed lines patch added patch discarded remove patch
@@ -12,31 +12,31 @@
 block discarded – undo
12 12
 <div class="redux-sidebar">
13 13
 	<ul class="redux-group-menu">
14 14
 		<?php
15
-		foreach ( $this->parent->sections as $k => $section ) {
16
-			$the_title = $section['title'] ?? '';
17
-			$skip_sec  = false;
18
-			foreach ( $this->parent->options_class->hidden_perm_sections as $num => $section_title ) {
19
-				if ( $section_title === $the_title ) {
20
-					$skip_sec = true;
21
-				}
22
-			}
15
+        foreach ( $this->parent->sections as $k => $section ) {
16
+            $the_title = $section['title'] ?? '';
17
+            $skip_sec  = false;
18
+            foreach ( $this->parent->options_class->hidden_perm_sections as $num => $section_title ) {
19
+                if ( $section_title === $the_title ) {
20
+                    $skip_sec = true;
21
+                }
22
+            }
23 23
 
24
-			if ( isset( $section['customizer_only'] ) && true === $section['customizer_only'] ) {
25
-				continue;
26
-			}
24
+            if ( isset( $section['customizer_only'] ) && true === $section['customizer_only'] ) {
25
+                continue;
26
+            }
27 27
 
28
-			if ( false === $skip_sec ) {
29
-				echo( $this->parent->render_class->section_menu( $k, $section ) ); // phpcs:ignore WordPress.Security.EscapeOutput
30
-				$skip_sec = false;
31
-			}
32
-		}
28
+            if ( false === $skip_sec ) {
29
+                echo( $this->parent->render_class->section_menu( $k, $section ) ); // phpcs:ignore WordPress.Security.EscapeOutput
30
+                $skip_sec = false;
31
+            }
32
+        }
33 33
 
34
-		/**
35
-		 * Action 'redux/page/{opt_name}/menu/after'
36
-		 *
37
-		 * @param object $this ReduxFramework
38
-		 */
39
-		do_action( "redux/page/{$this->parent->args['opt_name']}/menu/after", $this ); // phpcs:ignore WordPress.NamingConventions.ValidHookName
40
-		?>
34
+        /**
35
+         * Action 'redux/page/{opt_name}/menu/after'
36
+         *
37
+         * @param object $this ReduxFramework
38
+         */
39
+        do_action( "redux/page/{$this->parent->args['opt_name']}/menu/after", $this ); // phpcs:ignore WordPress.NamingConventions.ValidHookName
40
+        ?>
41 41
 	</ul>
42 42
 </div>
Please login to merge, or discard this patch.