Completed
Push — master ( 7388a0...c197b7 )
by
unknown
45s
created
redux-core/inc/validation/color/class-redux-validation-color.php 1 patch
Indentation   +36 added lines, -36 removed lines patch added patch discarded remove patch
@@ -11,51 +11,51 @@
 block discarded – undo
11 11
 
12 12
 if ( ! class_exists( 'Redux_Validation_Color', false ) ) {
13 13
 
14
-	/**
15
-	 * Class Redux_Validation_Color
16
-	 */
17
-	class Redux_Validation_Color extends Redux_Validate {
14
+    /**
15
+     * Class Redux_Validation_Color
16
+     */
17
+    class Redux_Validation_Color extends Redux_Validate {
18 18
 
19
-		/**
20
-		 * Field Validate Function.
21
-		 * Takes the vars and outputs the HTML for the field in the settings
22
-		 *
23
-		 * @since ReduxFramework 3.0.0
24
-		 */
25
-		public function validate() {
19
+        /**
20
+         * Field Validate Function.
21
+         * Takes the vars and outputs the HTML for the field in the settings
22
+         *
23
+         * @since ReduxFramework 3.0.0
24
+         */
25
+        public function validate() {
26 26
 
27
-			if ( empty( $this->value ) || ( 'transparent' === $this->value ) || is_array( $this->value ) ) {
28
-				return;
29
-			}
27
+            if ( empty( $this->value ) || ( 'transparent' === $this->value ) || is_array( $this->value ) ) {
28
+                return;
29
+            }
30 30
 
31
-			$test = str_replace( '#', '', Redux_Core::strtolower( trim( $this->value ) ) );
32
-			if ( ! in_array( strlen( $test ), array( 3, 6 ), true ) ) {
33
-				// translators: %1$s: sanitized value.  %2$s: Old value.
34
-				$this->field['msg'] = $this->field['msg'] ?? sprintf( esc_html__( 'Invalid HTML color code %1$s. Please enter a valid code. No value was saved.', 'redux-framework' ), '<code>' . $this->value . '</code>' );
31
+            $test = str_replace( '#', '', Redux_Core::strtolower( trim( $this->value ) ) );
32
+            if ( ! in_array( strlen( $test ), array( 3, 6 ), true ) ) {
33
+                // translators: %1$s: sanitized value.  %2$s: Old value.
34
+                $this->field['msg'] = $this->field['msg'] ?? sprintf( esc_html__( 'Invalid HTML color code %1$s. Please enter a valid code. No value was saved.', 'redux-framework' ), '<code>' . $this->value . '</code>' );
35 35
 
36
-				$this->warning = $this->field;
37
-				$this->value   = '';
36
+                $this->warning = $this->field;
37
+                $this->value   = '';
38 38
 
39
-				return;
40
-			} else {
41
-				$this->field['msg'] = '';
42
-				$this->warning      = $this->field;
39
+                return;
40
+            } else {
41
+                $this->field['msg'] = '';
42
+                $this->warning      = $this->field;
43 43
 
44
-			}
44
+            }
45 45
 
46
-			$sanitized_value = Redux_Colors::sanitize_color( $this->value );
46
+            $sanitized_value = Redux_Colors::sanitize_color( $this->value );
47 47
 
48
-			if ( $sanitized_value !== $this->value ) {
49
-				// translators: %1$s: sanitized value.  %2$s: Old value.
50
-				$this->field['msg'] = $this->field['msg'] ?? sprintf( esc_html__( 'Sanitized value and saved as %1$s instead of %2$s.', 'redux-framework' ), '<code>' . $sanitized_value . '</code>', '<code>' . $this->value . '</code>' );
48
+            if ( $sanitized_value !== $this->value ) {
49
+                // translators: %1$s: sanitized value.  %2$s: Old value.
50
+                $this->field['msg'] = $this->field['msg'] ?? sprintf( esc_html__( 'Sanitized value and saved as %1$s instead of %2$s.', 'redux-framework' ), '<code>' . $sanitized_value . '</code>', '<code>' . $this->value . '</code>' );
51 51
 
52
-				$this->field['old']     = $this->value;
53
-				$this->field['current'] = $sanitized_value;
52
+                $this->field['old']     = $this->value;
53
+                $this->field['current'] = $sanitized_value;
54 54
 
55
-				$this->warning = $this->field;
56
-			}
55
+                $this->warning = $this->field;
56
+            }
57 57
 
58
-			$this->value = strtoupper( $sanitized_value );
59
-		}
60
-	}
58
+            $this->value = strtoupper( $sanitized_value );
59
+        }
60
+    }
61 61
 }
Please login to merge, or discard this patch.
redux-core/inc/classes/class-redux-options-defaults.php 2 patches
Indentation   +195 added lines, -195 removed lines patch added patch discarded remove patch
@@ -11,199 +11,199 @@
 block discarded – undo
11 11
 
12 12
 if ( ! class_exists( 'Redux_Options_Defaults', false ) ) {
13 13
 
14
-	/**
15
-	 * Class Redux_Options_Defaults
16
-	 */
17
-	class Redux_Options_Defaults {
18
-
19
-		/**
20
-		 * Default options.
21
-		 *
22
-		 * @var array
23
-		 */
24
-		public $options_defaults = array();
25
-
26
-		/**
27
-		 * Field array.
28
-		 *
29
-		 * @var array
30
-		 */
31
-		public $fields = array();
32
-
33
-		/**
34
-		 * Is repeater group flag.
35
-		 *
36
-		 * @var bool
37
-		 */
38
-		private $is_repeater_group = false;
39
-
40
-		/**
41
-		 * Repeater ID.
42
-		 *
43
-		 * @var bool
44
-		 */
45
-		private $repeater_id = '';
46
-
47
-		/**
48
-		 * Creates a default options array.
49
-		 *
50
-		 * @param string $opt_name      Panel opt_name.
51
-		 * @param array  $sections      Panel sections array.
52
-		 * @param null   $wp_data_class WordPress data class.
53
-		 *
54
-		 * @return array
55
-		 */
56
-		public function default_values( string $opt_name = '', array $sections = array(), $wp_data_class = null ): array {
57
-			// We want it to be clean each time this is run.
58
-			$this->options_defaults = array();
59
-
60
-			// Check to make sure we're not in the select2 action, we don't want to fetch any there.
61
-			if ( isset( $_REQUEST['action'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Recommended
62
-				$action = sanitize_text_field( wp_unslash( $_REQUEST['action'] ) ); // phpcs:ignore WordPress.Security.NonceVerification.Recommended
63
-
64
-				if ( Redux_Functions_Ex::string_ends_with( $action, '_select2' ) && Redux_Functions_Ex::string_starts_with( $action, 'redux_' ) ) {
65
-					return array();
66
-				}
67
-			}
68
-
69
-			if ( ! empty( $sections ) ) {
70
-
71
-				// Fill the cache.
72
-				foreach ( $sections as $sk => $section ) {
73
-					if ( ! isset( $section['id'] ) ) {
74
-						if ( ! is_numeric( $sk ) || ! isset( $section['title'] ) ) {
75
-							$section['id'] = $sk;
76
-						} else {
77
-							$section['id'] = sanitize_title( $section['title'], $sk );
78
-						}
79
-
80
-						$sections[ $sk ] = $section;
81
-					}
82
-					if ( isset( $section['fields'] ) ) {
83
-						foreach ( $section['fields'] as $field ) {
84
-							if ( empty( $field['id'] ) && empty( $field['type'] ) ) {
85
-								continue;
86
-							}
87
-
88
-							$this->field_default_values( $opt_name, $field, $wp_data_class, false );
89
-
90
-							if ( 'tabbed' === $field['type'] ) {
91
-								if ( ! empty( $field['tabs'] ) ) {
92
-									foreach ( $field['tabs'] as $val ) {
93
-										if ( ! empty( $val['fields'] ) ) {
94
-											foreach ( $val['fields'] as $f ) {
95
-												$this->field_default_values( $opt_name, $f, $wp_data_class, false, true );
96
-											}
97
-										}
98
-									}
99
-								}
100
-							}
101
-
102
-							if ( 'repeater' === $field['type'] ) {
103
-								if ( ! empty( $field['fields'] ) ) {
104
-									foreach ( $field['fields'] as $f ) {
105
-										$this->field_default_values( $opt_name, $f, $wp_data_class, true );
106
-									}
107
-								}
108
-							}
109
-						}
110
-					}
111
-				}
112
-			}
113
-
114
-			return $this->options_defaults;
115
-		}
116
-
117
-		/**
118
-		 * Field default values.
119
-		 *
120
-		 * @param string $opt_name      Panel opt_name.
121
-		 * @param array  $field         Field array.
122
-		 * @param null   $wp_data_class WordPress data class.
123
-		 * @param bool   $is_repeater   Is a repeater field.
124
-		 * @param bool   $is_tabbed     Is a tabbed field.
125
-		 */
126
-		public function field_default_values( string $opt_name = '', array $field = array(), $wp_data_class = null, bool $is_repeater = false, $is_tabbed = false ) {
127
-			if ( 'repeater' === $field['type'] ) {
128
-				if ( isset( $field['group_values'] ) && true === $field['group_values'] ) {
129
-					$this->is_repeater_group = true;
130
-					$this->repeater_id       = $field['id'];
131
-				}
132
-			}
133
-
134
-			if ( null === $wp_data_class && class_exists( 'Redux_WordPress_Data' ) && ! ( 'select' === $field['type'] && isset( $field['ajax'] ) && $field['ajax'] ) ) {
135
-				$wp_data_class = new Redux_WordPress_Data( $opt_name );
136
-			}
137
-
138
-			// Detect what field types are being used.
139
-			if ( ! isset( $this->fields[ $field['type'] ][ $field['id'] ] ) ) {
140
-				$this->fields[ $field['type'] ][ $field['id'] ] = 1;
141
-			} else {
142
-				$this->fields[ $field['type'] ] = array( $field['id'] => 1 );
143
-			}
144
-
145
-			if ( isset( $field['default'] ) ) {
146
-				// phpcs:ignore WordPress.NamingConventions.ValidHookName
147
-				$def = apply_filters( "redux/$opt_name/field/{$field['type']}/defaults", $field['default'], $field );
148
-
149
-				if ( true === $is_repeater ) {
150
-					if ( true === $this->is_repeater_group ) {
151
-						$this->options_defaults[ $this->repeater_id ][ $field['id'] ] = array( $def );
152
-					} else {
153
-						$this->options_defaults[ $field['id'] ] = array( $def );
154
-					}
155
-				} elseif ( true === $is_tabbed ) {
156
-					$this->options_defaults[ $field['id'] ] = $def;
157
-				} else {
158
-					$this->options_defaults[ $field['id'] ] = $def;
159
-				}
160
-			} elseif ( ( 'ace_editor' !== $field['type'] ) && ! ( 'select' === $field['type'] && ! empty( $field['ajax'] ) ) ) {
161
-				if ( isset( $field['data'] ) ) {
162
-					if ( ! isset( $field['args'] ) ) {
163
-						$field['args'] = array();
164
-					}
165
-					if ( is_array( $field['data'] ) && ! empty( $field['data'] ) ) {
166
-						foreach ( $field['data'] as $key => $data ) {
167
-							if ( ! empty( $data ) ) {
168
-								if ( ! isset( $field['args'][ $key ] ) ) {
169
-									$field['args'][ $key ] = array();
170
-								}
171
-								if ( null !== $wp_data_class ) {
172
-									$field['options'][ $key ] = $wp_data_class->get( $data, $field['args'][ $key ], $opt_name );
173
-								}
174
-							}
175
-						}
176
-					} elseif ( null !== $wp_data_class ) {
177
-						$field['options'] = $wp_data_class->get( $field['data'], $field['args'], $opt_name );
178
-					}
179
-
180
-					if ( 'sorter' === $field['type'] && ! empty( $field['data'] ) && is_array( $field['data'] ) ) {
181
-						if ( ! isset( $field['args'] ) ) {
182
-							$field['args'] = array();
183
-						}
184
-						foreach ( $field['data'] as $key => $data ) {
185
-							if ( ! isset( $field['args'][ $key ] ) ) {
186
-								$field['args'][ $key ] = array();
187
-							}
188
-							if ( null !== $wp_data_class ) {
189
-								$field['options'][ $key ] = $wp_data_class->get( $data, $field['args'][ $key ], $opt_name );
190
-							}
191
-						}
192
-					}
193
-
194
-					if ( isset( $field['options'] ) ) {
195
-						if ( 'sortable' === $field['type'] ) {
196
-							$this->options_defaults[ $field['id'] ] = ( true === $is_repeater ) ? array( array() ) : array();
197
-						} elseif ( 'image_select' === $field['type'] ) {
198
-							$this->options_defaults[ $field['id'] ] = ( true === $is_repeater ) ? array( '' ) : '';
199
-						} elseif ( 'select' === $field['type'] ) {
200
-							$this->options_defaults[ $field['id'] ] = ( true === $is_repeater ) ? array( '' ) : '';
201
-						} else {
202
-							$this->options_defaults[ $field['id'] ] = ( true === $is_repeater ) ? array( $field['options'] ) : $field['options'];
203
-						}
204
-					}
205
-				}
206
-			}
207
-		}
208
-	}
14
+    /**
15
+     * Class Redux_Options_Defaults
16
+     */
17
+    class Redux_Options_Defaults {
18
+
19
+        /**
20
+         * Default options.
21
+         *
22
+         * @var array
23
+         */
24
+        public $options_defaults = array();
25
+
26
+        /**
27
+         * Field array.
28
+         *
29
+         * @var array
30
+         */
31
+        public $fields = array();
32
+
33
+        /**
34
+         * Is repeater group flag.
35
+         *
36
+         * @var bool
37
+         */
38
+        private $is_repeater_group = false;
39
+
40
+        /**
41
+         * Repeater ID.
42
+         *
43
+         * @var bool
44
+         */
45
+        private $repeater_id = '';
46
+
47
+        /**
48
+         * Creates a default options array.
49
+         *
50
+         * @param string $opt_name      Panel opt_name.
51
+         * @param array  $sections      Panel sections array.
52
+         * @param null   $wp_data_class WordPress data class.
53
+         *
54
+         * @return array
55
+         */
56
+        public function default_values( string $opt_name = '', array $sections = array(), $wp_data_class = null ): array {
57
+            // We want it to be clean each time this is run.
58
+            $this->options_defaults = array();
59
+
60
+            // Check to make sure we're not in the select2 action, we don't want to fetch any there.
61
+            if ( isset( $_REQUEST['action'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Recommended
62
+                $action = sanitize_text_field( wp_unslash( $_REQUEST['action'] ) ); // phpcs:ignore WordPress.Security.NonceVerification.Recommended
63
+
64
+                if ( Redux_Functions_Ex::string_ends_with( $action, '_select2' ) && Redux_Functions_Ex::string_starts_with( $action, 'redux_' ) ) {
65
+                    return array();
66
+                }
67
+            }
68
+
69
+            if ( ! empty( $sections ) ) {
70
+
71
+                // Fill the cache.
72
+                foreach ( $sections as $sk => $section ) {
73
+                    if ( ! isset( $section['id'] ) ) {
74
+                        if ( ! is_numeric( $sk ) || ! isset( $section['title'] ) ) {
75
+                            $section['id'] = $sk;
76
+                        } else {
77
+                            $section['id'] = sanitize_title( $section['title'], $sk );
78
+                        }
79
+
80
+                        $sections[ $sk ] = $section;
81
+                    }
82
+                    if ( isset( $section['fields'] ) ) {
83
+                        foreach ( $section['fields'] as $field ) {
84
+                            if ( empty( $field['id'] ) && empty( $field['type'] ) ) {
85
+                                continue;
86
+                            }
87
+
88
+                            $this->field_default_values( $opt_name, $field, $wp_data_class, false );
89
+
90
+                            if ( 'tabbed' === $field['type'] ) {
91
+                                if ( ! empty( $field['tabs'] ) ) {
92
+                                    foreach ( $field['tabs'] as $val ) {
93
+                                        if ( ! empty( $val['fields'] ) ) {
94
+                                            foreach ( $val['fields'] as $f ) {
95
+                                                $this->field_default_values( $opt_name, $f, $wp_data_class, false, true );
96
+                                            }
97
+                                        }
98
+                                    }
99
+                                }
100
+                            }
101
+
102
+                            if ( 'repeater' === $field['type'] ) {
103
+                                if ( ! empty( $field['fields'] ) ) {
104
+                                    foreach ( $field['fields'] as $f ) {
105
+                                        $this->field_default_values( $opt_name, $f, $wp_data_class, true );
106
+                                    }
107
+                                }
108
+                            }
109
+                        }
110
+                    }
111
+                }
112
+            }
113
+
114
+            return $this->options_defaults;
115
+        }
116
+
117
+        /**
118
+         * Field default values.
119
+         *
120
+         * @param string $opt_name      Panel opt_name.
121
+         * @param array  $field         Field array.
122
+         * @param null   $wp_data_class WordPress data class.
123
+         * @param bool   $is_repeater   Is a repeater field.
124
+         * @param bool   $is_tabbed     Is a tabbed field.
125
+         */
126
+        public function field_default_values( string $opt_name = '', array $field = array(), $wp_data_class = null, bool $is_repeater = false, $is_tabbed = false ) {
127
+            if ( 'repeater' === $field['type'] ) {
128
+                if ( isset( $field['group_values'] ) && true === $field['group_values'] ) {
129
+                    $this->is_repeater_group = true;
130
+                    $this->repeater_id       = $field['id'];
131
+                }
132
+            }
133
+
134
+            if ( null === $wp_data_class && class_exists( 'Redux_WordPress_Data' ) && ! ( 'select' === $field['type'] && isset( $field['ajax'] ) && $field['ajax'] ) ) {
135
+                $wp_data_class = new Redux_WordPress_Data( $opt_name );
136
+            }
137
+
138
+            // Detect what field types are being used.
139
+            if ( ! isset( $this->fields[ $field['type'] ][ $field['id'] ] ) ) {
140
+                $this->fields[ $field['type'] ][ $field['id'] ] = 1;
141
+            } else {
142
+                $this->fields[ $field['type'] ] = array( $field['id'] => 1 );
143
+            }
144
+
145
+            if ( isset( $field['default'] ) ) {
146
+                // phpcs:ignore WordPress.NamingConventions.ValidHookName
147
+                $def = apply_filters( "redux/$opt_name/field/{$field['type']}/defaults", $field['default'], $field );
148
+
149
+                if ( true === $is_repeater ) {
150
+                    if ( true === $this->is_repeater_group ) {
151
+                        $this->options_defaults[ $this->repeater_id ][ $field['id'] ] = array( $def );
152
+                    } else {
153
+                        $this->options_defaults[ $field['id'] ] = array( $def );
154
+                    }
155
+                } elseif ( true === $is_tabbed ) {
156
+                    $this->options_defaults[ $field['id'] ] = $def;
157
+                } else {
158
+                    $this->options_defaults[ $field['id'] ] = $def;
159
+                }
160
+            } elseif ( ( 'ace_editor' !== $field['type'] ) && ! ( 'select' === $field['type'] && ! empty( $field['ajax'] ) ) ) {
161
+                if ( isset( $field['data'] ) ) {
162
+                    if ( ! isset( $field['args'] ) ) {
163
+                        $field['args'] = array();
164
+                    }
165
+                    if ( is_array( $field['data'] ) && ! empty( $field['data'] ) ) {
166
+                        foreach ( $field['data'] as $key => $data ) {
167
+                            if ( ! empty( $data ) ) {
168
+                                if ( ! isset( $field['args'][ $key ] ) ) {
169
+                                    $field['args'][ $key ] = array();
170
+                                }
171
+                                if ( null !== $wp_data_class ) {
172
+                                    $field['options'][ $key ] = $wp_data_class->get( $data, $field['args'][ $key ], $opt_name );
173
+                                }
174
+                            }
175
+                        }
176
+                    } elseif ( null !== $wp_data_class ) {
177
+                        $field['options'] = $wp_data_class->get( $field['data'], $field['args'], $opt_name );
178
+                    }
179
+
180
+                    if ( 'sorter' === $field['type'] && ! empty( $field['data'] ) && is_array( $field['data'] ) ) {
181
+                        if ( ! isset( $field['args'] ) ) {
182
+                            $field['args'] = array();
183
+                        }
184
+                        foreach ( $field['data'] as $key => $data ) {
185
+                            if ( ! isset( $field['args'][ $key ] ) ) {
186
+                                $field['args'][ $key ] = array();
187
+                            }
188
+                            if ( null !== $wp_data_class ) {
189
+                                $field['options'][ $key ] = $wp_data_class->get( $data, $field['args'][ $key ], $opt_name );
190
+                            }
191
+                        }
192
+                    }
193
+
194
+                    if ( isset( $field['options'] ) ) {
195
+                        if ( 'sortable' === $field['type'] ) {
196
+                            $this->options_defaults[ $field['id'] ] = ( true === $is_repeater ) ? array( array() ) : array();
197
+                        } elseif ( 'image_select' === $field['type'] ) {
198
+                            $this->options_defaults[ $field['id'] ] = ( true === $is_repeater ) ? array( '' ) : '';
199
+                        } elseif ( 'select' === $field['type'] ) {
200
+                            $this->options_defaults[ $field['id'] ] = ( true === $is_repeater ) ? array( '' ) : '';
201
+                        } else {
202
+                            $this->options_defaults[ $field['id'] ] = ( true === $is_repeater ) ? array( $field['options'] ) : $field['options'];
203
+                        }
204
+                    }
205
+                }
206
+            }
207
+        }
208
+    }
209 209
 }
Please login to merge, or discard this patch.
Spacing   +18 added lines, -18 removed lines patch added patch discarded remove patch
@@ -77,7 +77,7 @@  discard block
 block discarded – undo
77 77
 							$section['id'] = sanitize_title( $section['title'], $sk );
78 78
 						}
79 79
 
80
-						$sections[ $sk ] = $section;
80
+						$sections[$sk] = $section;
81 81
 					}
82 82
 					if ( isset( $section['fields'] ) ) {
83 83
 						foreach ( $section['fields'] as $field ) {
@@ -136,10 +136,10 @@  discard block
 block discarded – undo
136 136
 			}
137 137
 
138 138
 			// Detect what field types are being used.
139
-			if ( ! isset( $this->fields[ $field['type'] ][ $field['id'] ] ) ) {
140
-				$this->fields[ $field['type'] ][ $field['id'] ] = 1;
139
+			if ( ! isset( $this->fields[$field['type']][$field['id']] ) ) {
140
+				$this->fields[$field['type']][$field['id']] = 1;
141 141
 			} else {
142
-				$this->fields[ $field['type'] ] = array( $field['id'] => 1 );
142
+				$this->fields[$field['type']] = array( $field['id'] => 1 );
143 143
 			}
144 144
 
145 145
 			if ( isset( $field['default'] ) ) {
@@ -148,14 +148,14 @@  discard block
 block discarded – undo
148 148
 
149 149
 				if ( true === $is_repeater ) {
150 150
 					if ( true === $this->is_repeater_group ) {
151
-						$this->options_defaults[ $this->repeater_id ][ $field['id'] ] = array( $def );
151
+						$this->options_defaults[$this->repeater_id][$field['id']] = array( $def );
152 152
 					} else {
153
-						$this->options_defaults[ $field['id'] ] = array( $def );
153
+						$this->options_defaults[$field['id']] = array( $def );
154 154
 					}
155 155
 				} elseif ( true === $is_tabbed ) {
156
-					$this->options_defaults[ $field['id'] ] = $def;
156
+					$this->options_defaults[$field['id']] = $def;
157 157
 				} else {
158
-					$this->options_defaults[ $field['id'] ] = $def;
158
+					$this->options_defaults[$field['id']] = $def;
159 159
 				}
160 160
 			} elseif ( ( 'ace_editor' !== $field['type'] ) && ! ( 'select' === $field['type'] && ! empty( $field['ajax'] ) ) ) {
161 161
 				if ( isset( $field['data'] ) ) {
@@ -165,11 +165,11 @@  discard block
 block discarded – undo
165 165
 					if ( is_array( $field['data'] ) && ! empty( $field['data'] ) ) {
166 166
 						foreach ( $field['data'] as $key => $data ) {
167 167
 							if ( ! empty( $data ) ) {
168
-								if ( ! isset( $field['args'][ $key ] ) ) {
169
-									$field['args'][ $key ] = array();
168
+								if ( ! isset( $field['args'][$key] ) ) {
169
+									$field['args'][$key] = array();
170 170
 								}
171 171
 								if ( null !== $wp_data_class ) {
172
-									$field['options'][ $key ] = $wp_data_class->get( $data, $field['args'][ $key ], $opt_name );
172
+									$field['options'][$key] = $wp_data_class->get( $data, $field['args'][$key], $opt_name );
173 173
 								}
174 174
 							}
175 175
 						}
@@ -182,24 +182,24 @@  discard block
 block discarded – undo
182 182
 							$field['args'] = array();
183 183
 						}
184 184
 						foreach ( $field['data'] as $key => $data ) {
185
-							if ( ! isset( $field['args'][ $key ] ) ) {
186
-								$field['args'][ $key ] = array();
185
+							if ( ! isset( $field['args'][$key] ) ) {
186
+								$field['args'][$key] = array();
187 187
 							}
188 188
 							if ( null !== $wp_data_class ) {
189
-								$field['options'][ $key ] = $wp_data_class->get( $data, $field['args'][ $key ], $opt_name );
189
+								$field['options'][$key] = $wp_data_class->get( $data, $field['args'][$key], $opt_name );
190 190
 							}
191 191
 						}
192 192
 					}
193 193
 
194 194
 					if ( isset( $field['options'] ) ) {
195 195
 						if ( 'sortable' === $field['type'] ) {
196
-							$this->options_defaults[ $field['id'] ] = ( true === $is_repeater ) ? array( array() ) : array();
196
+							$this->options_defaults[$field['id']] = ( true === $is_repeater ) ? array( array() ) : array();
197 197
 						} elseif ( 'image_select' === $field['type'] ) {
198
-							$this->options_defaults[ $field['id'] ] = ( true === $is_repeater ) ? array( '' ) : '';
198
+							$this->options_defaults[$field['id']] = ( true === $is_repeater ) ? array( '' ) : '';
199 199
 						} elseif ( 'select' === $field['type'] ) {
200
-							$this->options_defaults[ $field['id'] ] = ( true === $is_repeater ) ? array( '' ) : '';
200
+							$this->options_defaults[$field['id']] = ( true === $is_repeater ) ? array( '' ) : '';
201 201
 						} else {
202
-							$this->options_defaults[ $field['id'] ] = ( true === $is_repeater ) ? array( $field['options'] ) : $field['options'];
202
+							$this->options_defaults[$field['id']] = ( true === $is_repeater ) ? array( $field['options'] ) : $field['options'];
203 203
 						}
204 204
 					}
205 205
 				}
Please login to merge, or discard this patch.
sample/sections/extensions/color-scheme.php 2 patches
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -39,7 +39,7 @@  discard block
 block discarded – undo
39 39
 					'cancel_text'            => 'Cancel',
40 40
 					'show_buttons'           => true,
41 41
 					'use_extended_classes'   => true,
42
-					'palette'                => null,  // show default.
42
+					'palette'                => null, // show default.
43 43
 				),
44 44
 				'groups'   => array(
45 45
 					esc_html__( 'Header', 'your-textdomain-here' ) => array(
@@ -76,13 +76,13 @@  discard block
 block discarded – undo
76 76
 						'group'     => esc_html__( 'Header', 'your-textdomain-here' ),
77 77
 					),
78 78
 					array(
79
-						'id'        => 'home-link',     // ID.
80
-						'title'     => 'home link',     // Display text.
81
-						'color'     => '#fdfdfd',       // Default colour.
82
-						'alpha'     => 1,               // Default alpha.
83
-						'selector'  => '.home-link,.wp-block-site-title a',    // CSS selector.
84
-						'mode'      => 'color',         // CSS mode.
85
-						'important' => true,            // CSS important.
79
+						'id'        => 'home-link', // ID.
80
+						'title'     => 'home link', // Display text.
81
+						'color'     => '#fdfdfd', // Default colour.
82
+						'alpha'     => 1, // Default alpha.
83
+						'selector'  => '.home-link,.wp-block-site-title a', // CSS selector.
84
+						'mode'      => 'color', // CSS mode.
85
+						'important' => true, // CSS important.
86 86
 						'group'     => esc_html__( 'Header', 'your-textdomain-here' ),
87 87
 					),
88 88
 					array(
Please login to merge, or discard this patch.
Indentation   +208 added lines, -208 removed lines patch added patch discarded remove patch
@@ -11,214 +11,214 @@
 block discarded – undo
11 11
 defined( 'ABSPATH' ) || exit;
12 12
 
13 13
 Redux::set_section(
14
-	$opt_name,
15
-	array(
16
-		'title'      => esc_html__( 'Color Schemes', 'your-textdomain-here' ),
17
-		'desc'       => esc_html__( 'For full documentation on this field, visit: ', 'your-textdomain-here' ) . '<a href="https://devs.redux.io/core-extensions/color-schemes.html" target="_blank">https://devs.redux.io/core-extensions/color-schemes.html</a>',
18
-		'subsection' => true,
19
-		'fields'     => array(
20
-			array(
21
-				'id'       => 'opt-color-scheme',
22
-				'type'     => 'color_scheme',
23
-				'title'    => esc_html__( 'Color Schemes', 'your-textdomain-here' ),
24
-				'subtitle' => esc_html__( 'Save and load color schemes', 'your-textdomain-here' ),
25
-				'desc'     => esc_html__( 'If you\'re using the theme 2023, you will be able to see many changes on the current site.', 'your-textdomain-here' ),
26
-				'output'   => true,
27
-				'compiler' => true,
28
-				'simple'   => false,
29
-				'options'  => array(
30
-					'show_input'             => true,
31
-					'show_initial'           => true,
32
-					'show_alpha'             => true,
33
-					'show_palette'           => true,
34
-					'show_palette_only'      => false,
35
-					'show_selection_palette' => true,
36
-					'max_palette_size'       => 10,
37
-					'allow_empty'            => true,
38
-					'clickout_fires_change'  => false,
39
-					'choose_text'            => 'Choose',
40
-					'cancel_text'            => 'Cancel',
41
-					'show_buttons'           => true,
42
-					'use_extended_classes'   => true,
43
-					'palette'                => null,  // show default.
44
-				),
45
-				'groups'   => array(
46
-					esc_html__( 'Header', 'your-textdomain-here' ) => array(
47
-						'desc'           => esc_html__( 'Set header and nav colors here. (Group open by default)', 'your-textdomain-here' ),
48
-						'hidden'         => false,
49
-						'accordion_open' => true,
50
-					),
51
-					esc_html__( 'Body', 'your-textdomain-here' ) => esc_html__( 'Set body and content colors here.', 'your-textdomain-here' ),
52
-					esc_html__( 'Widget', 'your-textdomain-here' ) => '',
53
-					'' => esc_html__( 'These colors are not assigned to any group.', 'your-textdomain-here' ),
54
-				),
55
-				'default'  => array(
56
-					array(
57
-						'id'        => 'site-header',
58
-						'title'     => 'site header',
59
-						'color'     => '#980000',
60
-						'alpha'     => 1,
61
-						'selector'  => array(
62
-							'background' => '.site-header-main,header',
63
-							'color'      => '.tester',
64
-						),
65
-						'mode'      => 'background-color',
66
-						'important' => true,
67
-						'group'     => esc_html__( 'Header', 'your-textdomain-here' ),
68
-					),
69
-					array(
70
-						'id'        => 'site-header-border',
71
-						'title'     => 'site header border',
72
-						'color'     => '#ff0000',
73
-						'alpha'     => 1,
74
-						'selector'  => '.site-header,header',
75
-						'mode'      => 'border-color',
76
-						'important' => true,
77
-						'group'     => esc_html__( 'Header', 'your-textdomain-here' ),
78
-					),
79
-					array(
80
-						'id'        => 'home-link',     // ID.
81
-						'title'     => 'home link',     // Display text.
82
-						'color'     => '#fdfdfd',       // Default colour.
83
-						'alpha'     => 1,               // Default alpha.
84
-						'selector'  => '.home-link,.wp-block-site-title a',    // CSS selector.
85
-						'mode'      => 'color',         // CSS mode.
86
-						'important' => true,            // CSS important.
87
-						'group'     => esc_html__( 'Header', 'your-textdomain-here' ),
88
-					),
89
-					array(
90
-						'id'        => 'site-description',
91
-						'title'     => 'site description',
92
-						'color'     => '#ededed',
93
-						'alpha'     => 1,
94
-						'selector'  => 'h2.site-description,.wp-block-site-tagline',
95
-						'mode'      => 'color',
96
-						'important' => true,
97
-						'group'     => esc_html__( 'Header', 'your-textdomain-here' ),
98
-					),
99
-					array(
100
-						'id'       => 'navbar',
101
-						'title'    => 'navbar',
102
-						'color'    => '#e06666',
103
-						'alpha'    => 1,
104
-						'selector' => '.navbar,.wp-block-navigation',
105
-						'mode'     => 'background-color',
106
-						'group'    => esc_html__( 'Header', 'your-textdomain-here' ),
14
+    $opt_name,
15
+    array(
16
+        'title'      => esc_html__( 'Color Schemes', 'your-textdomain-here' ),
17
+        'desc'       => esc_html__( 'For full documentation on this field, visit: ', 'your-textdomain-here' ) . '<a href="https://devs.redux.io/core-extensions/color-schemes.html" target="_blank">https://devs.redux.io/core-extensions/color-schemes.html</a>',
18
+        'subsection' => true,
19
+        'fields'     => array(
20
+            array(
21
+                'id'       => 'opt-color-scheme',
22
+                'type'     => 'color_scheme',
23
+                'title'    => esc_html__( 'Color Schemes', 'your-textdomain-here' ),
24
+                'subtitle' => esc_html__( 'Save and load color schemes', 'your-textdomain-here' ),
25
+                'desc'     => esc_html__( 'If you\'re using the theme 2023, you will be able to see many changes on the current site.', 'your-textdomain-here' ),
26
+                'output'   => true,
27
+                'compiler' => true,
28
+                'simple'   => false,
29
+                'options'  => array(
30
+                    'show_input'             => true,
31
+                    'show_initial'           => true,
32
+                    'show_alpha'             => true,
33
+                    'show_palette'           => true,
34
+                    'show_palette_only'      => false,
35
+                    'show_selection_palette' => true,
36
+                    'max_palette_size'       => 10,
37
+                    'allow_empty'            => true,
38
+                    'clickout_fires_change'  => false,
39
+                    'choose_text'            => 'Choose',
40
+                    'cancel_text'            => 'Cancel',
41
+                    'show_buttons'           => true,
42
+                    'use_extended_classes'   => true,
43
+                    'palette'                => null,  // show default.
44
+                ),
45
+                'groups'   => array(
46
+                    esc_html__( 'Header', 'your-textdomain-here' ) => array(
47
+                        'desc'           => esc_html__( 'Set header and nav colors here. (Group open by default)', 'your-textdomain-here' ),
48
+                        'hidden'         => false,
49
+                        'accordion_open' => true,
50
+                    ),
51
+                    esc_html__( 'Body', 'your-textdomain-here' ) => esc_html__( 'Set body and content colors here.', 'your-textdomain-here' ),
52
+                    esc_html__( 'Widget', 'your-textdomain-here' ) => '',
53
+                    '' => esc_html__( 'These colors are not assigned to any group.', 'your-textdomain-here' ),
54
+                ),
55
+                'default'  => array(
56
+                    array(
57
+                        'id'        => 'site-header',
58
+                        'title'     => 'site header',
59
+                        'color'     => '#980000',
60
+                        'alpha'     => 1,
61
+                        'selector'  => array(
62
+                            'background' => '.site-header-main,header',
63
+                            'color'      => '.tester',
64
+                        ),
65
+                        'mode'      => 'background-color',
66
+                        'important' => true,
67
+                        'group'     => esc_html__( 'Header', 'your-textdomain-here' ),
68
+                    ),
69
+                    array(
70
+                        'id'        => 'site-header-border',
71
+                        'title'     => 'site header border',
72
+                        'color'     => '#ff0000',
73
+                        'alpha'     => 1,
74
+                        'selector'  => '.site-header,header',
75
+                        'mode'      => 'border-color',
76
+                        'important' => true,
77
+                        'group'     => esc_html__( 'Header', 'your-textdomain-here' ),
78
+                    ),
79
+                    array(
80
+                        'id'        => 'home-link',     // ID.
81
+                        'title'     => 'home link',     // Display text.
82
+                        'color'     => '#fdfdfd',       // Default colour.
83
+                        'alpha'     => 1,               // Default alpha.
84
+                        'selector'  => '.home-link,.wp-block-site-title a',    // CSS selector.
85
+                        'mode'      => 'color',         // CSS mode.
86
+                        'important' => true,            // CSS important.
87
+                        'group'     => esc_html__( 'Header', 'your-textdomain-here' ),
88
+                    ),
89
+                    array(
90
+                        'id'        => 'site-description',
91
+                        'title'     => 'site description',
92
+                        'color'     => '#ededed',
93
+                        'alpha'     => 1,
94
+                        'selector'  => 'h2.site-description,.wp-block-site-tagline',
95
+                        'mode'      => 'color',
96
+                        'important' => true,
97
+                        'group'     => esc_html__( 'Header', 'your-textdomain-here' ),
98
+                    ),
99
+                    array(
100
+                        'id'       => 'navbar',
101
+                        'title'    => 'navbar',
102
+                        'color'    => '#e06666',
103
+                        'alpha'    => 1,
104
+                        'selector' => '.navbar,.wp-block-navigation',
105
+                        'mode'     => 'background-color',
106
+                        'group'    => esc_html__( 'Header', 'your-textdomain-here' ),
107 107
 
108
-					),
109
-					array(
110
-						'id'       => 'body-text',
111
-						'title'    => 'body text',
112
-						'color'    => '#000000',
113
-						'alpha'    => 1,
114
-						'selector' => 'body p',
115
-						'mode'     => 'color',
116
-						'group'    => esc_html__( 'Body', 'your-textdomain-here' ),
117
-					),
118
-					array(
119
-						'id'       => 'site-content',
120
-						'title'    => 'site content',
121
-						'color'    => '#a4c2f4',
122
-						'alpha'    => 1,
123
-						'selector' => '.site-content',
124
-						'mode'     => 'background-color',
125
-						'group'    => esc_html__( 'Body', 'your-textdomain-here' ),
126
-					),
127
-					array(
128
-						'id'       => 'entry-content',
129
-						'title'    => 'entry content',
130
-						'color'    => '#93c47d',
131
-						'alpha'    => 1,
132
-						'selector' => '.entry-content',
133
-						'mode'     => 'background-color',
134
-						'group'    => esc_html__( 'Body', 'your-textdomain-here' ),
135
-					),
136
-					array(
137
-						'id'       => 'entry-title',
138
-						'title'    => 'entry title',
139
-						'color'    => '#000000',
140
-						'alpha'    => 1,
141
-						'selector' => '.entry-title a',
142
-						'mode'     => 'color',
143
-						'group'    => esc_html__( 'Body', 'your-textdomain-here' ),
144
-					),
145
-					array(
146
-						'id'       => 'entry-title-hover',
147
-						'title'    => 'entry title hover',
148
-						'color'    => '#ffffff',
149
-						'alpha'    => 1,
150
-						'selector' => '.entry-title a:hover',
151
-						'mode'     => 'color',
152
-						'group'    => esc_html__( 'Body', 'your-textdomain-here' ),
153
-					),
154
-					array(
155
-						'id'       => 'entry-meta',
156
-						'title'    => 'entry meta',
157
-						'color'    => '#0b5394',
158
-						'alpha'    => 1,
159
-						'selector' => '.entry-meta a',
160
-						'mode'     => 'color',
161
-						'group'    => esc_html__( 'Body', 'your-textdomain-here' ),
162
-					),
163
-					array(
164
-						'id'       => 'widget-container',
165
-						'title'    => 'widget container',
166
-						'color'    => '#f1c232',
167
-						'alpha'    => .5,
168
-						'selector' => '.widget',
169
-						'mode'     => 'background-color',
170
-						'group'    => esc_html__( 'Widget', 'your-textdomain-here' ),
171
-					),
172
-					array(
173
-						'id'        => 'widget-title',
174
-						'title'     => 'widget title',
175
-						'color'     => '#741b47',
176
-						'alpha'     => 1,
177
-						'selector'  => '.widget-title',
178
-						'mode'      => 'color',
179
-						'important' => true,
180
-						'group'     => esc_html__( 'Widget', 'your-textdomain-here' ),
181
-					),
182
-					array(
183
-						'id'        => 'widget-text',
184
-						'title'     => 'widget text',
185
-						'color'     => '#fdfdfd',
186
-						'alpha'     => 1,
187
-						'selector'  => '.widget a',
188
-						'mode'      => 'color',
189
-						'important' => true,
190
-						'group'     => esc_html__( 'Widget', 'your-textdomain-here' ),
191
-					),
192
-					array(
193
-						'id'        => 'sidebar-container',
194
-						'title'     => 'sidebar container',
195
-						'color'     => '#d5a6bd',
196
-						'alpha'     => 1,
197
-						'selector'  => '.sidebar-container',
198
-						'mode'      => 'background-color',
199
-						'important' => true,
200
-						'group'     => '',
201
-					),
202
-					array(
203
-						'id'       => 'site-footer',
204
-						'title'    => 'site footer',
205
-						'color'    => '#ededed',
206
-						'alpha'    => 1,
207
-						'selector' => '.site-footer,footer',
208
-						'mode'     => 'background-color',
209
-						'group'    => '',
210
-					),
211
-					array(
212
-						'id'       => 'site-footer-text',
213
-						'title'    => 'site footer text',
214
-						'color'    => '#000000',
215
-						'alpha'    => 1,
216
-						'selector' => '.site-footer a, footer a',
217
-						'group'    => '',
218
-					),
219
-				),
220
-			),
221
-		),
222
-	)
108
+                    ),
109
+                    array(
110
+                        'id'       => 'body-text',
111
+                        'title'    => 'body text',
112
+                        'color'    => '#000000',
113
+                        'alpha'    => 1,
114
+                        'selector' => 'body p',
115
+                        'mode'     => 'color',
116
+                        'group'    => esc_html__( 'Body', 'your-textdomain-here' ),
117
+                    ),
118
+                    array(
119
+                        'id'       => 'site-content',
120
+                        'title'    => 'site content',
121
+                        'color'    => '#a4c2f4',
122
+                        'alpha'    => 1,
123
+                        'selector' => '.site-content',
124
+                        'mode'     => 'background-color',
125
+                        'group'    => esc_html__( 'Body', 'your-textdomain-here' ),
126
+                    ),
127
+                    array(
128
+                        'id'       => 'entry-content',
129
+                        'title'    => 'entry content',
130
+                        'color'    => '#93c47d',
131
+                        'alpha'    => 1,
132
+                        'selector' => '.entry-content',
133
+                        'mode'     => 'background-color',
134
+                        'group'    => esc_html__( 'Body', 'your-textdomain-here' ),
135
+                    ),
136
+                    array(
137
+                        'id'       => 'entry-title',
138
+                        'title'    => 'entry title',
139
+                        'color'    => '#000000',
140
+                        'alpha'    => 1,
141
+                        'selector' => '.entry-title a',
142
+                        'mode'     => 'color',
143
+                        'group'    => esc_html__( 'Body', 'your-textdomain-here' ),
144
+                    ),
145
+                    array(
146
+                        'id'       => 'entry-title-hover',
147
+                        'title'    => 'entry title hover',
148
+                        'color'    => '#ffffff',
149
+                        'alpha'    => 1,
150
+                        'selector' => '.entry-title a:hover',
151
+                        'mode'     => 'color',
152
+                        'group'    => esc_html__( 'Body', 'your-textdomain-here' ),
153
+                    ),
154
+                    array(
155
+                        'id'       => 'entry-meta',
156
+                        'title'    => 'entry meta',
157
+                        'color'    => '#0b5394',
158
+                        'alpha'    => 1,
159
+                        'selector' => '.entry-meta a',
160
+                        'mode'     => 'color',
161
+                        'group'    => esc_html__( 'Body', 'your-textdomain-here' ),
162
+                    ),
163
+                    array(
164
+                        'id'       => 'widget-container',
165
+                        'title'    => 'widget container',
166
+                        'color'    => '#f1c232',
167
+                        'alpha'    => .5,
168
+                        'selector' => '.widget',
169
+                        'mode'     => 'background-color',
170
+                        'group'    => esc_html__( 'Widget', 'your-textdomain-here' ),
171
+                    ),
172
+                    array(
173
+                        'id'        => 'widget-title',
174
+                        'title'     => 'widget title',
175
+                        'color'     => '#741b47',
176
+                        'alpha'     => 1,
177
+                        'selector'  => '.widget-title',
178
+                        'mode'      => 'color',
179
+                        'important' => true,
180
+                        'group'     => esc_html__( 'Widget', 'your-textdomain-here' ),
181
+                    ),
182
+                    array(
183
+                        'id'        => 'widget-text',
184
+                        'title'     => 'widget text',
185
+                        'color'     => '#fdfdfd',
186
+                        'alpha'     => 1,
187
+                        'selector'  => '.widget a',
188
+                        'mode'      => 'color',
189
+                        'important' => true,
190
+                        'group'     => esc_html__( 'Widget', 'your-textdomain-here' ),
191
+                    ),
192
+                    array(
193
+                        'id'        => 'sidebar-container',
194
+                        'title'     => 'sidebar container',
195
+                        'color'     => '#d5a6bd',
196
+                        'alpha'     => 1,
197
+                        'selector'  => '.sidebar-container',
198
+                        'mode'      => 'background-color',
199
+                        'important' => true,
200
+                        'group'     => '',
201
+                    ),
202
+                    array(
203
+                        'id'       => 'site-footer',
204
+                        'title'    => 'site footer',
205
+                        'color'    => '#ededed',
206
+                        'alpha'    => 1,
207
+                        'selector' => '.site-footer,footer',
208
+                        'mode'     => 'background-color',
209
+                        'group'    => '',
210
+                    ),
211
+                    array(
212
+                        'id'       => 'site-footer-text',
213
+                        'title'    => 'site footer text',
214
+                        'color'    => '#000000',
215
+                        'alpha'    => 1,
216
+                        'selector' => '.site-footer a, footer a',
217
+                        'group'    => '',
218
+                    ),
219
+                ),
220
+            ),
221
+        ),
222
+    )
223 223
 );
224 224
 // phpcs:enable
Please login to merge, or discard this patch.
redux-core/inc/classes/class-redux-output.php 2 patches
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -109,7 +109,7 @@  discard block
 block discarded – undo
109 109
 							}
110 110
 
111 111
 							$field['default'] = $field['default'] ?? '';
112
-							$value            = $core->options[ $field['id'] ] ?? $field['default'];
112
+							$value            = $core->options[$field['id']] ?? $field['default'];
113 113
 							$style_data       = '';
114 114
 
115 115
 							if ( empty( $field_class ) ) {
@@ -118,7 +118,7 @@  discard block
 block discarded – undo
118 118
 
119 119
 							$field_object = new $field_class( $field, $value, $core );
120 120
 
121
-							if ( ! empty( $core->options[ $field['id'] ] ) && class_exists( $field_class ) && method_exists( $field_class, 'output' ) && $this->can_output_css( $core, $field ) ) {
121
+							if ( ! empty( $core->options[$field['id']] ) && class_exists( $field_class ) && method_exists( $field_class, 'output' ) && $this->can_output_css( $core, $field ) ) {
122 122
 
123 123
 								// phpcs:ignore WordPress.NamingConventions.ValidHookName
124 124
 								$field = apply_filters( "redux/field/{$core->args['opt_name']}/output_css", $field );
@@ -223,7 +223,7 @@  discard block
 block discarded – undo
223 223
 				// Revamp thanks to Harry: https://csswizardry.com/2020/05/the-fastest-google-fonts/.
224 224
 				$href      = str_replace( array( '|', ' ' ), array( '%7C', '%20' ), urldecode( $href ) );
225 225
 				$new_html  = '<link rel="preload" as="style" href="' . esc_attr( $href ) . '" />';
226
-				$new_html .= '<link rel="stylesheet" href="' . esc_attr( $href ) . '" media="print" onload="this.media=\'all\'">';  // phpcs:ignore WordPress.WP.EnqueuedResources.NonEnqueuedStylesheet
226
+				$new_html .= '<link rel="stylesheet" href="' . esc_attr( $href ) . '" media="print" onload="this.media=\'all\'">'; // phpcs:ignore WordPress.WP.EnqueuedResources.NonEnqueuedStylesheet
227 227
 				$new_html .= '<noscript><link rel="stylesheet" href="' . esc_attr( $href ) . '" /></noscript>'; // phpcs:ignore WordPress.WP.EnqueuedResources.NonEnqueuedStylesheet
228 228
 				$html      = $new_html;
229 229
 			}
@@ -269,19 +269,19 @@  discard block
 block discarded – undo
269 269
 
270 270
 					foreach ( $val_pieces as $val_key => $val_val ) {
271 271
 						$val_key                            = $output_variables_prefix . sanitize_title_with_dashes( $field['id'] ) . '-' . $val_key;
272
-						$core->output_variables[ $val_key ] = $val_val;
272
+						$core->output_variables[$val_key] = $val_val;
273 273
 						if ( ! empty( $style_data ) ) {
274 274
 							$val_key                            = $output_variables_prefix . sanitize_title_with_dashes( $field['id'] );
275
-							$core->output_variables[ $val_key ] = $style_data;
275
+							$core->output_variables[$val_key] = $style_data;
276 276
 						}
277 277
 					}
278 278
 				} else {
279 279
 					$val_key = $output_variables_prefix . sanitize_title_with_dashes( $field['id'] );
280 280
 
281 281
 					if ( ! empty( $style_data ) ) {
282
-						$core->output_variables[ $val_key ] = $style_data;
282
+						$core->output_variables[$val_key] = $style_data;
283 283
 					} else {
284
-						$core->output_variables[ $val_key ] = $value;
284
+						$core->output_variables[$val_key] = $value;
285 285
 					}
286 286
 				}
287 287
 			}
@@ -344,14 +344,14 @@  discard block
 block discarded – undo
344 344
 			if ( ! empty( $field['required'] ) ) {
345 345
 				if ( isset( $field['required'][0] ) ) {
346 346
 					if ( ! is_array( $field['required'][0] ) && 3 === count( $field['required'] ) ) {
347
-						$parent_value = $GLOBALS[ $core->args['global_variable'] ][ $field['required'][0] ] ?? '';
347
+						$parent_value = $GLOBALS[$core->args['global_variable']][$field['required'][0]] ?? '';
348 348
 						$check_value  = $field['required'][2];
349 349
 						$operation    = $field['required'][1];
350 350
 						$return       = $core->required_class->compare_value_dependencies( $parent_value, $check_value, $operation );
351 351
 					} elseif ( is_array( $field['required'][0] ) ) {
352 352
 						foreach ( $field['required'] as $required ) {
353 353
 							if ( isset( $required[0] ) && ! is_array( $required[0] ) && 3 === count( $required ) ) {
354
-								$parent_value = $GLOBALS[ $core->args['global_variable'] ][ $required[0] ] ?? '';
354
+								$parent_value = $GLOBALS[$core->args['global_variable']][$required[0]] ?? '';
355 355
 								$check_value  = $required[2];
356 356
 								$operation    = $required[1];
357 357
 								$return       = $core->required_class->compare_value_dependencies( $parent_value, $check_value, $operation );
Please login to merge, or discard this patch.
Indentation   +358 added lines, -358 removed lines patch added patch discarded remove patch
@@ -12,362 +12,362 @@
 block discarded – undo
12 12
 
13 13
 if ( ! class_exists( 'Redux_Output', false ) ) {
14 14
 
15
-	/**
16
-	 * Class Redux_Output
17
-	 */
18
-	class Redux_Output extends Redux_Class {
19
-
20
-		/**
21
-		 * Redux_Output constructor.
22
-		 *
23
-		 * @param object $redux ReduxFramework pointer.
24
-		 */
25
-		public function __construct( $redux ) {
26
-			parent::__construct( $redux );
27
-
28
-			// Output dynamic CSS.
29
-			// Frontend: Maybe enqueue dynamic CSS and Google fonts.
30
-			if ( empty( $this->args['output_location'] ) || in_array( 'frontend', $this->args['output_location'], true ) ) {
31
-				add_action( 'wp_head', array( $this, 'output_css' ), 150 );
32
-				add_action( 'wp_enqueue_scripts', array( $this, 'enqueue' ), 150 );
33
-			}
34
-
35
-			// Login page: Maybe enqueue dynamic CSS and Google fonts.
36
-			if ( in_array( 'login', $this->args['output_location'], true ) ) {
37
-				add_action( 'login_head', array( $this, 'output_css' ), 150 );
38
-				add_action( 'login_enqueue_scripts', array( $this, 'enqueue' ), 150 );
39
-			}
40
-
41
-			// Admin area: Maybe enqueue dynamic CSS and Google fonts.
42
-			if ( in_array( 'admin', $this->args['output_location'], true ) ) {
43
-				add_action( 'admin_head', array( $this, 'output_css' ), 150 );
44
-				add_action( 'admin_enqueue_scripts', array( $this, 'enqueue' ), 150 );
45
-			}
46
-
47
-			// phpcs:ignore WordPress.NamingConventions.ValidHookName
48
-			do_action( "redux/output/{$this->parent->args['opt_name']}/construct", $this );
49
-			// Useful for adding different locations for CSS output.
50
-		}
51
-
52
-		/**
53
-		 * Enqueue CSS and Google fonts for front end
54
-		 *
55
-		 * @return void
56
-		 * @throws ReflectionException Exception.
57
-		 * @since  1.0.0
58
-		 * @access public
59
-		 */
60
-		public function enqueue() {
61
-			$core = $this->core();
62
-
63
-			if ( false === $core->args['output'] && false === $core->args['compiler'] ) {
64
-				return;
65
-			}
66
-
67
-			foreach ( $core->sections as $k => $section ) {
68
-				if ( isset( $section['type'] ) && ( 'divide' === $section['type'] ) ) {
69
-					continue;
70
-				}
71
-
72
-				if ( isset( $section['fields'] ) ) {
73
-					foreach ( $section['fields'] as $fieldk => $field ) {
74
-						if ( isset( $field['type'] ) && 'callback' !== $field['type'] ) {
75
-							$field_classes = array( 'Redux_' . $field['type'], 'ReduxFramework_' . $field['type'] );
76
-
77
-							$field_class = Redux_Functions::class_exists_ex( $field_classes );
78
-
79
-							if ( false === $field_class ) {
80
-								if ( ! isset( $field['compiler'] ) ) {
81
-									$field['compiler'] = '';
82
-								}
83
-
84
-								$field_type = str_replace( '_', '-', $field['type'] );
85
-								$core_path  = Redux_Core::$dir . "inc/fields/{$field['type']}/class-redux-$field_type.php";
86
-
87
-								if ( ! file_exists( $core_path ) ) {
88
-									$core_path = Redux_Core::$dir . "inc/fields/{$field['type']}/field_{$field['type']}.php";
89
-								}
90
-
91
-								$filter_path = $core_path;
92
-
93
-								/**
94
-								 * Field class file
95
-								 * filter 'redux/{opt_name}/field/class/{field.type}'
96
-								 *
97
-								 * @param string $file field class file.
98
-								 * @param array $field field config data
99
-								 */
100
-
101
-								// phpcs:ignore WordPress.NamingConventions.ValidHookName
102
-								$class_file = apply_filters( "redux/{$core->args['opt_name']}/field/class/{$field['type']}", $filter_path, $field );
103
-
104
-								if ( $class_file && file_exists( $class_file ) ) {
105
-									require_once $class_file;
106
-
107
-									$field_class = Redux_Functions::class_exists_ex( $field_classes );
108
-								}
109
-							}
110
-
111
-							$field['default'] = $field['default'] ?? '';
112
-							$value            = $core->options[ $field['id'] ] ?? $field['default'];
113
-							$style_data       = '';
114
-
115
-							if ( empty( $field_class ) ) {
116
-								continue;
117
-							}
118
-
119
-							$field_object = new $field_class( $field, $value, $core );
120
-
121
-							if ( ! empty( $core->options[ $field['id'] ] ) && class_exists( $field_class ) && method_exists( $field_class, 'output' ) && $this->can_output_css( $core, $field ) ) {
122
-
123
-								// phpcs:ignore WordPress.NamingConventions.ValidHookName
124
-								$field = apply_filters( "redux/field/{$core->args['opt_name']}/output_css", $field );
125
-
126
-								if ( ! empty( $field['output'] ) && ! is_array( $field['output'] ) ) {
127
-									$field['output'] = array( $field['output'] );
128
-								}
129
-
130
-								if ( ( ( isset( $field['output'] ) && ! empty( $field['output'] ) ) || ( isset( $field['compiler'] ) && ! empty( $field['compiler'] ) ) || ( isset( $field['media_query'] ) && ! empty( $field['media_query'] ) ) || 'typography' === $field['type'] || 'icon_select' === $field['type'] || 'social_profiles' === $field['type'] ) ) {
131
-									if ( method_exists( $field_class, 'css_style' ) ) {
132
-										$style_data = $field_object->css_style( $field_object->value );
133
-									}
134
-								}
135
-
136
-								if ( null !== $style_data ) {
137
-									if ( ( ( isset( $field['output'] ) && ! empty( $field['output'] ) ) || ( isset( $field['compiler'] ) && ! empty( $field['compiler'] ) ) || 'typography' === $field['type'] || 'icon_select' === $field['type'] || 'social_profiles' === $field['type'] ) ) {
138
-										$field_object->output( $style_data );
139
-									}
140
-
141
-									if ( isset( $field['media_query'] ) && ! empty( $field['media_query'] ) ) {
142
-										$field_object->media_query( $style_data );
143
-									}
144
-								}
145
-							}
146
-
147
-							// phpcs:ignore WordPress.NamingConventions.ValidHookName
148
-							do_action( "redux/field/{$core->args['opt_name']}/output_loop", $core, $field, $value, $style_data );
149
-
150
-							// phpcs:ignore WordPress.NamingConventions.ValidHookName
151
-							do_action( "redux/field/{$core->args['opt_name']}/output_loop/{$field['type']}", $core, $field, $value, $style_data );
152
-
153
-							if ( method_exists( $field_class, 'output_variables' ) && $this->can_output_css( $core, $field ) ) {
154
-								$passed_style_data = $field_object->output_variables( $style_data );
155
-								$this->output_variables( $core, $section, $field, $value, $passed_style_data );
156
-							}
157
-						}
158
-					}
159
-
160
-					if ( ! empty( $core->outputCSS ) ) { // phpcs:ignore WordPress.NamingConventions.ValidVariableName.UsedPropertyNotSnakeCase
161
-						// phpcs:ignore WordPress.NamingConventions.ValidVariableName.UsedPropertyNotSnakeCase
162
-						$core->outputCSS = html_entity_decode( $core->outputCSS, ENT_QUOTES, 'UTF-8' );
163
-					}
164
-				}
165
-			}
166
-
167
-			// For use like in the customizer. Stops the output, but passes the CSS in the variable for the compiler.
168
-			if ( true === Redux_Core::$no_output ) {
169
-				return;
170
-			}
171
-
172
-			if ( ! empty( Redux_Core::$typography ) && filter_var( $core->args['output'], FILTER_VALIDATE_BOOLEAN ) ) {
173
-				$version = ! empty( $core->transients['last_save'] ) ? $core->transients['last_save'] : '';
174
-				if ( ! class_exists( 'Redux_Typography' ) ) {
175
-					require_once Redux_Core::$dir . '/inc/fields/typography/class-redux-typography.php';
176
-				}
177
-
178
-				$typography = new Redux_Typography( null, null, $core );
179
-
180
-				$core->args['disable_google_fonts_link'] = ( ! isset( $core->args['disable_google_fonts_link'] ) ? false : $core->args['disable_google_fonts_link'] );
181
-
182
-				if ( ! $core->args['disable_google_fonts_link'] ) {
183
-					$url = $typography->make_google_web_font_link( Redux_Core::$typography );
184
-					wp_enqueue_style( 'redux-google-fonts-' . $core->args['opt_name'], $url, array(), $version );
185
-					add_filter( 'style_loader_tag', array( $this, 'add_style_attributes' ), 10, 4 );
186
-					add_filter( 'wp_resource_hints', array( $this, 'google_fonts_preconnect' ), 10, 2 );
187
-				}
188
-			}
189
-		}
190
-
191
-		/**
192
-		 * Add a Google Fonts preconnect link.
193
-		 *
194
-		 * @param array  $urls              HTML to be added.
195
-		 * @param string $relationship_type Handle name.
196
-		 *
197
-		 * @return      array
198
-		 * @since       4.1.15
199
-		 * @access      public
200
-		 */
201
-		public function google_fonts_preconnect( array $urls, string $relationship_type ): array {
202
-			if ( 'preconnect' !== $relationship_type ) {
203
-				return $urls;
204
-			}
205
-			$urls[] = array(
206
-				'rel'  => 'preconnect',
207
-				'href' => 'https://fonts.gstatic.com',
208
-				'crossorigin',
209
-			);
210
-			return $urls;
211
-		}
212
-
213
-		/**
214
-		 * Filter to enhance the google fonts enqueue.
215
-		 *
216
-		 * @param string $html   HTML to be added.
217
-		 * @param string $handle Handle name.
218
-		 * @param string $href   HREF URL of a script.
219
-		 *
220
-		 * @return      string
221
-		 * @since       4.1.15
222
-		 * @access      public
223
-		 */
224
-		public function add_style_attributes( string $html = '', string $handle = '', string $href = '' ): string {
225
-			if ( Redux_Functions_Ex::string_starts_with( $handle, 'redux-google-fonts-' ) ) {
226
-				// Revamp thanks to Harry: https://csswizardry.com/2020/05/the-fastest-google-fonts/.
227
-				$href      = str_replace( array( '|', ' ' ), array( '%7C', '%20' ), urldecode( $href ) );
228
-				$new_html  = '<link rel="preload" as="style" href="' . esc_attr( $href ) . '" />';
229
-				$new_html .= '<link rel="stylesheet" href="' . esc_attr( $href ) . '" media="print" onload="this.media=\'all\'">';  // phpcs:ignore WordPress.WP.EnqueuedResources.NonEnqueuedStylesheet
230
-				$new_html .= '<noscript><link rel="stylesheet" href="' . esc_attr( $href ) . '" /></noscript>'; // phpcs:ignore WordPress.WP.EnqueuedResources.NonEnqueuedStylesheet
231
-				$html      = $new_html;
232
-			}
233
-
234
-			return $html;
235
-		}
236
-
237
-		/**
238
-		 * Function to output output_variables to the dynamic output.
239
-		 *
240
-		 * @param ReduxFramework $core       ReduxFramework core pointer.
241
-		 * @param array          $section    Section containing this field.
242
-		 * @param array          $field      Field object.
243
-		 * @param array|string   $value      Current value of field.
244
-		 * @param string|null    $style_data CSS output string to append to the root output variable.
245
-		 *
246
-		 * @return      void
247
-		 * @since       4.0.3
248
-		 * @access      public
249
-		 */
250
-		private function output_variables( ReduxFramework $core, array $section = array(), array $field = array(), $value = array(), ?string $style_data = '' ) {
251
-			// Let's allow section overrides, please.
252
-			if ( isset( $section['output_variables'] ) && ! isset( $field['output_variables'] ) ) {
253
-				$field['output_variables'] = $section['output_variables'];
254
-			}
255
-			if ( isset( $section['output_variables_prefix'] ) && ! isset( $field['output_variables_prefix'] ) ) {
256
-				$field['output_variables_prefix'] = $section['output_variables_prefix'];
257
-			}
258
-			if ( isset( $field['output_variables'] ) && $field['output_variables'] ) {
259
-				$output_variables_prefix = $core->args['output_variables_prefix'];
260
-				if ( isset( $field['output_variables_prefix'] ) && ! empty( $field['output_variables_prefix'] ) ) {
261
-					$output_variables_prefix = $field['output_variables_prefix'];
262
-				} elseif ( isset( $section['output_variables_prefix'] ) && ! empty( $section['output_variables_prefix'] ) ) {
263
-					$output_variables_prefix = $section['output_variables_prefix'];
264
-				}
265
-
266
-				if ( is_array( $value ) ) {
267
-					$val_pieces = array_filter( $value, 'strlen' );
268
-					// We don't need to show the Google boolean.
269
-					if ( 'typography' === $field['type'] && isset( $val_pieces['google'] ) ) {
270
-						unset( $val_pieces['google'] );
271
-					}
272
-
273
-					foreach ( $val_pieces as $val_key => $val_val ) {
274
-						$val_key                            = $output_variables_prefix . sanitize_title_with_dashes( $field['id'] ) . '-' . $val_key;
275
-						$core->output_variables[ $val_key ] = $val_val;
276
-						if ( ! empty( $style_data ) ) {
277
-							$val_key                            = $output_variables_prefix . sanitize_title_with_dashes( $field['id'] );
278
-							$core->output_variables[ $val_key ] = $style_data;
279
-						}
280
-					}
281
-				} else {
282
-					$val_key = $output_variables_prefix . sanitize_title_with_dashes( $field['id'] );
283
-
284
-					if ( ! empty( $style_data ) ) {
285
-						$core->output_variables[ $val_key ] = $style_data;
286
-					} else {
287
-						$core->output_variables[ $val_key ] = $value;
288
-					}
289
-				}
290
-			}
291
-		}
292
-
293
-		/**
294
-		 * Output dynamic CSS at the bottom of HEAD
295
-		 *
296
-		 * @return      void
297
-		 * @since       3.2.8
298
-		 * @access      public
299
-		 */
300
-		public function output_css() {
301
-			$core = $this->core();
302
-
303
-			if ( false === $core->args['output'] && false === $core->args['compiler'] && empty( $core->output_variables ) ) {
304
-				return;
305
-			}
306
-
307
-			if ( true === Redux_Core::$no_output ) {
308
-				return;
309
-			}
310
-
311
-			if ( ! empty( $core->output_variables ) ) {
312
-				$root_css = ':root{';
313
-				foreach ( $core->output_variables as $key => $value ) {
314
-					$root_css .= "$key:$value;";
315
-				}
316
-				$root_css .= '}';
317
-				// phpcs:ignore WordPress.NamingConventions.ValidVariableName, WordPress.Security.EscapeOutput
318
-				$core->outputCSS = $root_css . $core->outputCSS;
319
-			}
320
-
321
-			// phpcs:ignore WordPress.NamingConventions.ValidVariableName
322
-			if ( ! empty( $core->outputCSS ) && ( true === $core->args['output_tag'] || ( isset( $_POST['customized'] ) && isset( $_POST['nonce'] ) && wp_verify_nonce( sanitize_text_field( wp_unslash( $_POST['nonce'] ) ), 'preview-customize_' . wp_get_theme()->get_stylesheet() ) ) ) ) {
323
-				// phpcs:ignore WordPress.NamingConventions.ValidVariableName, WordPress.Security.EscapeOutput
324
-				echo '<style id="' . esc_attr( $core->args['opt_name'] ) . '-dynamic-css" title="dynamic-css" class="redux-options-output">' . $core->outputCSS . '</style>';
325
-			}
326
-		}
327
-
328
-		/**
329
-		 * Can Output CSS
330
-		 * Check if a field meets its requirements before outputting to CSS
331
-		 *
332
-		 * @param ReduxFramework $core  ReduxFramework core pointer.
333
-		 * @param array          $field Field array.
334
-		 *
335
-		 * @return bool
336
-		 */
337
-		private function can_output_css( ReduxFramework $core, array $field ): ?bool {
338
-			$return = true;
339
-
340
-			// phpcs:ignore WordPress.NamingConventions.ValidHookName
341
-			$field = apply_filters( "redux/field/{$core->args['opt_name']}/_can_output_css", $field );
342
-
343
-			if ( isset( $field['force_output'] ) && true === $field['force_output'] ) {
344
-				return true;
345
-			}
346
-
347
-			if ( ! empty( $field['required'] ) ) {
348
-				if ( isset( $field['required'][0] ) ) {
349
-					if ( ! is_array( $field['required'][0] ) && 3 === count( $field['required'] ) ) {
350
-						$parent_value = $GLOBALS[ $core->args['global_variable'] ][ $field['required'][0] ] ?? '';
351
-						$check_value  = $field['required'][2];
352
-						$operation    = $field['required'][1];
353
-						$return       = $core->required_class->compare_value_dependencies( $parent_value, $check_value, $operation );
354
-					} elseif ( is_array( $field['required'][0] ) ) {
355
-						foreach ( $field['required'] as $required ) {
356
-							if ( isset( $required[0] ) && ! is_array( $required[0] ) && 3 === count( $required ) ) {
357
-								$parent_value = $GLOBALS[ $core->args['global_variable'] ][ $required[0] ] ?? '';
358
-								$check_value  = $required[2];
359
-								$operation    = $required[1];
360
-								$return       = $core->required_class->compare_value_dependencies( $parent_value, $check_value, $operation );
361
-							}
362
-							if ( ! $return ) {
363
-								return $return;
364
-							}
365
-						}
366
-					}
367
-				}
368
-			}
369
-
370
-			return $return;
371
-		}
372
-	}
15
+    /**
16
+     * Class Redux_Output
17
+     */
18
+    class Redux_Output extends Redux_Class {
19
+
20
+        /**
21
+         * Redux_Output constructor.
22
+         *
23
+         * @param object $redux ReduxFramework pointer.
24
+         */
25
+        public function __construct( $redux ) {
26
+            parent::__construct( $redux );
27
+
28
+            // Output dynamic CSS.
29
+            // Frontend: Maybe enqueue dynamic CSS and Google fonts.
30
+            if ( empty( $this->args['output_location'] ) || in_array( 'frontend', $this->args['output_location'], true ) ) {
31
+                add_action( 'wp_head', array( $this, 'output_css' ), 150 );
32
+                add_action( 'wp_enqueue_scripts', array( $this, 'enqueue' ), 150 );
33
+            }
34
+
35
+            // Login page: Maybe enqueue dynamic CSS and Google fonts.
36
+            if ( in_array( 'login', $this->args['output_location'], true ) ) {
37
+                add_action( 'login_head', array( $this, 'output_css' ), 150 );
38
+                add_action( 'login_enqueue_scripts', array( $this, 'enqueue' ), 150 );
39
+            }
40
+
41
+            // Admin area: Maybe enqueue dynamic CSS and Google fonts.
42
+            if ( in_array( 'admin', $this->args['output_location'], true ) ) {
43
+                add_action( 'admin_head', array( $this, 'output_css' ), 150 );
44
+                add_action( 'admin_enqueue_scripts', array( $this, 'enqueue' ), 150 );
45
+            }
46
+
47
+            // phpcs:ignore WordPress.NamingConventions.ValidHookName
48
+            do_action( "redux/output/{$this->parent->args['opt_name']}/construct", $this );
49
+            // Useful for adding different locations for CSS output.
50
+        }
51
+
52
+        /**
53
+         * Enqueue CSS and Google fonts for front end
54
+         *
55
+         * @return void
56
+         * @throws ReflectionException Exception.
57
+         * @since  1.0.0
58
+         * @access public
59
+         */
60
+        public function enqueue() {
61
+            $core = $this->core();
62
+
63
+            if ( false === $core->args['output'] && false === $core->args['compiler'] ) {
64
+                return;
65
+            }
66
+
67
+            foreach ( $core->sections as $k => $section ) {
68
+                if ( isset( $section['type'] ) && ( 'divide' === $section['type'] ) ) {
69
+                    continue;
70
+                }
71
+
72
+                if ( isset( $section['fields'] ) ) {
73
+                    foreach ( $section['fields'] as $fieldk => $field ) {
74
+                        if ( isset( $field['type'] ) && 'callback' !== $field['type'] ) {
75
+                            $field_classes = array( 'Redux_' . $field['type'], 'ReduxFramework_' . $field['type'] );
76
+
77
+                            $field_class = Redux_Functions::class_exists_ex( $field_classes );
78
+
79
+                            if ( false === $field_class ) {
80
+                                if ( ! isset( $field['compiler'] ) ) {
81
+                                    $field['compiler'] = '';
82
+                                }
83
+
84
+                                $field_type = str_replace( '_', '-', $field['type'] );
85
+                                $core_path  = Redux_Core::$dir . "inc/fields/{$field['type']}/class-redux-$field_type.php";
86
+
87
+                                if ( ! file_exists( $core_path ) ) {
88
+                                    $core_path = Redux_Core::$dir . "inc/fields/{$field['type']}/field_{$field['type']}.php";
89
+                                }
90
+
91
+                                $filter_path = $core_path;
92
+
93
+                                /**
94
+                                 * Field class file
95
+                                 * filter 'redux/{opt_name}/field/class/{field.type}'
96
+                                 *
97
+                                 * @param string $file field class file.
98
+                                 * @param array $field field config data
99
+                                 */
100
+
101
+                                // phpcs:ignore WordPress.NamingConventions.ValidHookName
102
+                                $class_file = apply_filters( "redux/{$core->args['opt_name']}/field/class/{$field['type']}", $filter_path, $field );
103
+
104
+                                if ( $class_file && file_exists( $class_file ) ) {
105
+                                    require_once $class_file;
106
+
107
+                                    $field_class = Redux_Functions::class_exists_ex( $field_classes );
108
+                                }
109
+                            }
110
+
111
+                            $field['default'] = $field['default'] ?? '';
112
+                            $value            = $core->options[ $field['id'] ] ?? $field['default'];
113
+                            $style_data       = '';
114
+
115
+                            if ( empty( $field_class ) ) {
116
+                                continue;
117
+                            }
118
+
119
+                            $field_object = new $field_class( $field, $value, $core );
120
+
121
+                            if ( ! empty( $core->options[ $field['id'] ] ) && class_exists( $field_class ) && method_exists( $field_class, 'output' ) && $this->can_output_css( $core, $field ) ) {
122
+
123
+                                // phpcs:ignore WordPress.NamingConventions.ValidHookName
124
+                                $field = apply_filters( "redux/field/{$core->args['opt_name']}/output_css", $field );
125
+
126
+                                if ( ! empty( $field['output'] ) && ! is_array( $field['output'] ) ) {
127
+                                    $field['output'] = array( $field['output'] );
128
+                                }
129
+
130
+                                if ( ( ( isset( $field['output'] ) && ! empty( $field['output'] ) ) || ( isset( $field['compiler'] ) && ! empty( $field['compiler'] ) ) || ( isset( $field['media_query'] ) && ! empty( $field['media_query'] ) ) || 'typography' === $field['type'] || 'icon_select' === $field['type'] || 'social_profiles' === $field['type'] ) ) {
131
+                                    if ( method_exists( $field_class, 'css_style' ) ) {
132
+                                        $style_data = $field_object->css_style( $field_object->value );
133
+                                    }
134
+                                }
135
+
136
+                                if ( null !== $style_data ) {
137
+                                    if ( ( ( isset( $field['output'] ) && ! empty( $field['output'] ) ) || ( isset( $field['compiler'] ) && ! empty( $field['compiler'] ) ) || 'typography' === $field['type'] || 'icon_select' === $field['type'] || 'social_profiles' === $field['type'] ) ) {
138
+                                        $field_object->output( $style_data );
139
+                                    }
140
+
141
+                                    if ( isset( $field['media_query'] ) && ! empty( $field['media_query'] ) ) {
142
+                                        $field_object->media_query( $style_data );
143
+                                    }
144
+                                }
145
+                            }
146
+
147
+                            // phpcs:ignore WordPress.NamingConventions.ValidHookName
148
+                            do_action( "redux/field/{$core->args['opt_name']}/output_loop", $core, $field, $value, $style_data );
149
+
150
+                            // phpcs:ignore WordPress.NamingConventions.ValidHookName
151
+                            do_action( "redux/field/{$core->args['opt_name']}/output_loop/{$field['type']}", $core, $field, $value, $style_data );
152
+
153
+                            if ( method_exists( $field_class, 'output_variables' ) && $this->can_output_css( $core, $field ) ) {
154
+                                $passed_style_data = $field_object->output_variables( $style_data );
155
+                                $this->output_variables( $core, $section, $field, $value, $passed_style_data );
156
+                            }
157
+                        }
158
+                    }
159
+
160
+                    if ( ! empty( $core->outputCSS ) ) { // phpcs:ignore WordPress.NamingConventions.ValidVariableName.UsedPropertyNotSnakeCase
161
+                        // phpcs:ignore WordPress.NamingConventions.ValidVariableName.UsedPropertyNotSnakeCase
162
+                        $core->outputCSS = html_entity_decode( $core->outputCSS, ENT_QUOTES, 'UTF-8' );
163
+                    }
164
+                }
165
+            }
166
+
167
+            // For use like in the customizer. Stops the output, but passes the CSS in the variable for the compiler.
168
+            if ( true === Redux_Core::$no_output ) {
169
+                return;
170
+            }
171
+
172
+            if ( ! empty( Redux_Core::$typography ) && filter_var( $core->args['output'], FILTER_VALIDATE_BOOLEAN ) ) {
173
+                $version = ! empty( $core->transients['last_save'] ) ? $core->transients['last_save'] : '';
174
+                if ( ! class_exists( 'Redux_Typography' ) ) {
175
+                    require_once Redux_Core::$dir . '/inc/fields/typography/class-redux-typography.php';
176
+                }
177
+
178
+                $typography = new Redux_Typography( null, null, $core );
179
+
180
+                $core->args['disable_google_fonts_link'] = ( ! isset( $core->args['disable_google_fonts_link'] ) ? false : $core->args['disable_google_fonts_link'] );
181
+
182
+                if ( ! $core->args['disable_google_fonts_link'] ) {
183
+                    $url = $typography->make_google_web_font_link( Redux_Core::$typography );
184
+                    wp_enqueue_style( 'redux-google-fonts-' . $core->args['opt_name'], $url, array(), $version );
185
+                    add_filter( 'style_loader_tag', array( $this, 'add_style_attributes' ), 10, 4 );
186
+                    add_filter( 'wp_resource_hints', array( $this, 'google_fonts_preconnect' ), 10, 2 );
187
+                }
188
+            }
189
+        }
190
+
191
+        /**
192
+         * Add a Google Fonts preconnect link.
193
+         *
194
+         * @param array  $urls              HTML to be added.
195
+         * @param string $relationship_type Handle name.
196
+         *
197
+         * @return      array
198
+         * @since       4.1.15
199
+         * @access      public
200
+         */
201
+        public function google_fonts_preconnect( array $urls, string $relationship_type ): array {
202
+            if ( 'preconnect' !== $relationship_type ) {
203
+                return $urls;
204
+            }
205
+            $urls[] = array(
206
+                'rel'  => 'preconnect',
207
+                'href' => 'https://fonts.gstatic.com',
208
+                'crossorigin',
209
+            );
210
+            return $urls;
211
+        }
212
+
213
+        /**
214
+         * Filter to enhance the google fonts enqueue.
215
+         *
216
+         * @param string $html   HTML to be added.
217
+         * @param string $handle Handle name.
218
+         * @param string $href   HREF URL of a script.
219
+         *
220
+         * @return      string
221
+         * @since       4.1.15
222
+         * @access      public
223
+         */
224
+        public function add_style_attributes( string $html = '', string $handle = '', string $href = '' ): string {
225
+            if ( Redux_Functions_Ex::string_starts_with( $handle, 'redux-google-fonts-' ) ) {
226
+                // Revamp thanks to Harry: https://csswizardry.com/2020/05/the-fastest-google-fonts/.
227
+                $href      = str_replace( array( '|', ' ' ), array( '%7C', '%20' ), urldecode( $href ) );
228
+                $new_html  = '<link rel="preload" as="style" href="' . esc_attr( $href ) . '" />';
229
+                $new_html .= '<link rel="stylesheet" href="' . esc_attr( $href ) . '" media="print" onload="this.media=\'all\'">';  // phpcs:ignore WordPress.WP.EnqueuedResources.NonEnqueuedStylesheet
230
+                $new_html .= '<noscript><link rel="stylesheet" href="' . esc_attr( $href ) . '" /></noscript>'; // phpcs:ignore WordPress.WP.EnqueuedResources.NonEnqueuedStylesheet
231
+                $html      = $new_html;
232
+            }
233
+
234
+            return $html;
235
+        }
236
+
237
+        /**
238
+         * Function to output output_variables to the dynamic output.
239
+         *
240
+         * @param ReduxFramework $core       ReduxFramework core pointer.
241
+         * @param array          $section    Section containing this field.
242
+         * @param array          $field      Field object.
243
+         * @param array|string   $value      Current value of field.
244
+         * @param string|null    $style_data CSS output string to append to the root output variable.
245
+         *
246
+         * @return      void
247
+         * @since       4.0.3
248
+         * @access      public
249
+         */
250
+        private function output_variables( ReduxFramework $core, array $section = array(), array $field = array(), $value = array(), ?string $style_data = '' ) {
251
+            // Let's allow section overrides, please.
252
+            if ( isset( $section['output_variables'] ) && ! isset( $field['output_variables'] ) ) {
253
+                $field['output_variables'] = $section['output_variables'];
254
+            }
255
+            if ( isset( $section['output_variables_prefix'] ) && ! isset( $field['output_variables_prefix'] ) ) {
256
+                $field['output_variables_prefix'] = $section['output_variables_prefix'];
257
+            }
258
+            if ( isset( $field['output_variables'] ) && $field['output_variables'] ) {
259
+                $output_variables_prefix = $core->args['output_variables_prefix'];
260
+                if ( isset( $field['output_variables_prefix'] ) && ! empty( $field['output_variables_prefix'] ) ) {
261
+                    $output_variables_prefix = $field['output_variables_prefix'];
262
+                } elseif ( isset( $section['output_variables_prefix'] ) && ! empty( $section['output_variables_prefix'] ) ) {
263
+                    $output_variables_prefix = $section['output_variables_prefix'];
264
+                }
265
+
266
+                if ( is_array( $value ) ) {
267
+                    $val_pieces = array_filter( $value, 'strlen' );
268
+                    // We don't need to show the Google boolean.
269
+                    if ( 'typography' === $field['type'] && isset( $val_pieces['google'] ) ) {
270
+                        unset( $val_pieces['google'] );
271
+                    }
272
+
273
+                    foreach ( $val_pieces as $val_key => $val_val ) {
274
+                        $val_key                            = $output_variables_prefix . sanitize_title_with_dashes( $field['id'] ) . '-' . $val_key;
275
+                        $core->output_variables[ $val_key ] = $val_val;
276
+                        if ( ! empty( $style_data ) ) {
277
+                            $val_key                            = $output_variables_prefix . sanitize_title_with_dashes( $field['id'] );
278
+                            $core->output_variables[ $val_key ] = $style_data;
279
+                        }
280
+                    }
281
+                } else {
282
+                    $val_key = $output_variables_prefix . sanitize_title_with_dashes( $field['id'] );
283
+
284
+                    if ( ! empty( $style_data ) ) {
285
+                        $core->output_variables[ $val_key ] = $style_data;
286
+                    } else {
287
+                        $core->output_variables[ $val_key ] = $value;
288
+                    }
289
+                }
290
+            }
291
+        }
292
+
293
+        /**
294
+         * Output dynamic CSS at the bottom of HEAD
295
+         *
296
+         * @return      void
297
+         * @since       3.2.8
298
+         * @access      public
299
+         */
300
+        public function output_css() {
301
+            $core = $this->core();
302
+
303
+            if ( false === $core->args['output'] && false === $core->args['compiler'] && empty( $core->output_variables ) ) {
304
+                return;
305
+            }
306
+
307
+            if ( true === Redux_Core::$no_output ) {
308
+                return;
309
+            }
310
+
311
+            if ( ! empty( $core->output_variables ) ) {
312
+                $root_css = ':root{';
313
+                foreach ( $core->output_variables as $key => $value ) {
314
+                    $root_css .= "$key:$value;";
315
+                }
316
+                $root_css .= '}';
317
+                // phpcs:ignore WordPress.NamingConventions.ValidVariableName, WordPress.Security.EscapeOutput
318
+                $core->outputCSS = $root_css . $core->outputCSS;
319
+            }
320
+
321
+            // phpcs:ignore WordPress.NamingConventions.ValidVariableName
322
+            if ( ! empty( $core->outputCSS ) && ( true === $core->args['output_tag'] || ( isset( $_POST['customized'] ) && isset( $_POST['nonce'] ) && wp_verify_nonce( sanitize_text_field( wp_unslash( $_POST['nonce'] ) ), 'preview-customize_' . wp_get_theme()->get_stylesheet() ) ) ) ) {
323
+                // phpcs:ignore WordPress.NamingConventions.ValidVariableName, WordPress.Security.EscapeOutput
324
+                echo '<style id="' . esc_attr( $core->args['opt_name'] ) . '-dynamic-css" title="dynamic-css" class="redux-options-output">' . $core->outputCSS . '</style>';
325
+            }
326
+        }
327
+
328
+        /**
329
+         * Can Output CSS
330
+         * Check if a field meets its requirements before outputting to CSS
331
+         *
332
+         * @param ReduxFramework $core  ReduxFramework core pointer.
333
+         * @param array          $field Field array.
334
+         *
335
+         * @return bool
336
+         */
337
+        private function can_output_css( ReduxFramework $core, array $field ): ?bool {
338
+            $return = true;
339
+
340
+            // phpcs:ignore WordPress.NamingConventions.ValidHookName
341
+            $field = apply_filters( "redux/field/{$core->args['opt_name']}/_can_output_css", $field );
342
+
343
+            if ( isset( $field['force_output'] ) && true === $field['force_output'] ) {
344
+                return true;
345
+            }
346
+
347
+            if ( ! empty( $field['required'] ) ) {
348
+                if ( isset( $field['required'][0] ) ) {
349
+                    if ( ! is_array( $field['required'][0] ) && 3 === count( $field['required'] ) ) {
350
+                        $parent_value = $GLOBALS[ $core->args['global_variable'] ][ $field['required'][0] ] ?? '';
351
+                        $check_value  = $field['required'][2];
352
+                        $operation    = $field['required'][1];
353
+                        $return       = $core->required_class->compare_value_dependencies( $parent_value, $check_value, $operation );
354
+                    } elseif ( is_array( $field['required'][0] ) ) {
355
+                        foreach ( $field['required'] as $required ) {
356
+                            if ( isset( $required[0] ) && ! is_array( $required[0] ) && 3 === count( $required ) ) {
357
+                                $parent_value = $GLOBALS[ $core->args['global_variable'] ][ $required[0] ] ?? '';
358
+                                $check_value  = $required[2];
359
+                                $operation    = $required[1];
360
+                                $return       = $core->required_class->compare_value_dependencies( $parent_value, $check_value, $operation );
361
+                            }
362
+                            if ( ! $return ) {
363
+                                return $return;
364
+                            }
365
+                        }
366
+                    }
367
+                }
368
+            }
369
+
370
+            return $return;
371
+        }
372
+    }
373 373
 }
Please login to merge, or discard this patch.
redux-core/inc/classes/class-redux-extensions.php 1 patch
Indentation   +76 added lines, -76 removed lines patch added patch discarded remove patch
@@ -10,80 +10,80 @@
 block discarded – undo
10 10
 
11 11
 if ( ! class_exists( 'Redux_Extensions', false ) ) {
12 12
 
13
-	/**
14
-	 * Class Redux_Extensions
15
-	 */
16
-	class Redux_Extensions extends Redux_Class {
17
-
18
-		/**
19
-		 * Redux_Extensions constructor.
20
-		 *
21
-		 * @param object $redux ReduxFramework object pointer.
22
-		 *
23
-		 * @throws ReflectionException Exception.
24
-		 */
25
-		public function __construct( $redux ) {
26
-			parent::__construct( $redux );
27
-
28
-			$this->load();
29
-		}
30
-
31
-		/**
32
-		 * Class load functions.
33
-		 *
34
-		 * @throws ReflectionException For fallback.
35
-		 */
36
-		private function load() {
37
-			$core = $this->core();
38
-
39
-			$max = 1;
40
-
41
-			for ( $i = 1; $i <= $max; $i++ ) {
42
-				$path = Redux_Core::$dir . 'inc/extensions/';
43
-
44
-				// phpcs:ignore WordPress.NamingConventions.ValidHookName
45
-				$path = apply_filters( 'redux/' . $core->args['opt_name'] . '/extensions/dir', $path );
46
-
47
-				/**
48
-				 * Action 'redux/extensions/before'
49
-				 *
50
-				 * @param object $this ReduxFramework
51
-				 */
52
-				// phpcs:ignore WordPress.NamingConventions.ValidHookName
53
-				do_action( 'redux/extensions/before', $core );
54
-
55
-				/**
56
-				 * Action 'redux/extensions/{opt_name}/before'
57
-				 *
58
-				 * @param object $this ReduxFramework
59
-				 */
60
-				// phpcs:ignore WordPress.NamingConventions.ValidHookName
61
-				do_action( "redux/extensions/{$core->args['opt_name']}/before", $core );
62
-
63
-				if ( isset( $core->old_opt_name ) ) {
64
-					// phpcs:ignore WordPress.NamingConventions.ValidHookName
65
-					do_action( 'redux/extensions/' . $core->old_opt_name . '/before', $core );
66
-				}
67
-
68
-				require_once Redux_Core::$dir . 'inc/classes/class-redux-extension-abstract.php';
69
-
70
-				$path = untrailingslashit( $path );
71
-
72
-				Redux::set_extensions( $core->args['opt_name'], $path, true );
73
-
74
-				/**
75
-				 * Action 'redux/extensions/{opt_name}'
76
-				 *
77
-				 * @param object $this ReduxFramework
78
-				 */
79
-				// phpcs:ignore WordPress.NamingConventions.ValidHookName
80
-				do_action( "redux/extensions/{$core->args['opt_name']}", $core );
81
-
82
-				if ( isset( $core->old_opt_name ) ) {
83
-					// phpcs:ignore WordPress.NamingConventions.ValidHookName
84
-					do_action( 'redux/extensions/' . $core->old_opt_name, $core );
85
-				}
86
-			}
87
-		}
88
-	}
13
+    /**
14
+     * Class Redux_Extensions
15
+     */
16
+    class Redux_Extensions extends Redux_Class {
17
+
18
+        /**
19
+         * Redux_Extensions constructor.
20
+         *
21
+         * @param object $redux ReduxFramework object pointer.
22
+         *
23
+         * @throws ReflectionException Exception.
24
+         */
25
+        public function __construct( $redux ) {
26
+            parent::__construct( $redux );
27
+
28
+            $this->load();
29
+        }
30
+
31
+        /**
32
+         * Class load functions.
33
+         *
34
+         * @throws ReflectionException For fallback.
35
+         */
36
+        private function load() {
37
+            $core = $this->core();
38
+
39
+            $max = 1;
40
+
41
+            for ( $i = 1; $i <= $max; $i++ ) {
42
+                $path = Redux_Core::$dir . 'inc/extensions/';
43
+
44
+                // phpcs:ignore WordPress.NamingConventions.ValidHookName
45
+                $path = apply_filters( 'redux/' . $core->args['opt_name'] . '/extensions/dir', $path );
46
+
47
+                /**
48
+                 * Action 'redux/extensions/before'
49
+                 *
50
+                 * @param object $this ReduxFramework
51
+                 */
52
+                // phpcs:ignore WordPress.NamingConventions.ValidHookName
53
+                do_action( 'redux/extensions/before', $core );
54
+
55
+                /**
56
+                 * Action 'redux/extensions/{opt_name}/before'
57
+                 *
58
+                 * @param object $this ReduxFramework
59
+                 */
60
+                // phpcs:ignore WordPress.NamingConventions.ValidHookName
61
+                do_action( "redux/extensions/{$core->args['opt_name']}/before", $core );
62
+
63
+                if ( isset( $core->old_opt_name ) ) {
64
+                    // phpcs:ignore WordPress.NamingConventions.ValidHookName
65
+                    do_action( 'redux/extensions/' . $core->old_opt_name . '/before', $core );
66
+                }
67
+
68
+                require_once Redux_Core::$dir . 'inc/classes/class-redux-extension-abstract.php';
69
+
70
+                $path = untrailingslashit( $path );
71
+
72
+                Redux::set_extensions( $core->args['opt_name'], $path, true );
73
+
74
+                /**
75
+                 * Action 'redux/extensions/{opt_name}'
76
+                 *
77
+                 * @param object $this ReduxFramework
78
+                 */
79
+                // phpcs:ignore WordPress.NamingConventions.ValidHookName
80
+                do_action( "redux/extensions/{$core->args['opt_name']}", $core );
81
+
82
+                if ( isset( $core->old_opt_name ) ) {
83
+                    // phpcs:ignore WordPress.NamingConventions.ValidHookName
84
+                    do_action( 'redux/extensions/' . $core->old_opt_name, $core );
85
+                }
86
+            }
87
+        }
88
+    }
89 89
 }
Please login to merge, or discard this patch.
redux-core/inc/classes/class-redux-path.php 1 patch
Indentation   +20 added lines, -20 removed lines patch added patch discarded remove patch
@@ -11,27 +11,27 @@
 block discarded – undo
11 11
 
12 12
 if ( ! class_exists( 'Redux_Path', false ) ) {
13 13
 
14
-	/**
15
-	 * Class Redux_Path
16
-	 */
17
-	class Redux_Path {
14
+    /**
15
+     * Class Redux_Path
16
+     */
17
+    class Redux_Path {
18 18
 
19
-		/**
20
-		 * Class init
21
-		 */
22
-		public static function init() {}
19
+        /**
20
+         * Class init
21
+         */
22
+        public static function init() {}
23 23
 
24
-		/**
25
-		 * Gets Redux path.
26
-		 *
27
-		 * @param string $relative_path Self-explanatory.
28
-		 *
29
-		 * @return string
30
-		 */
31
-		public static function get_path( string $relative_path ): string {
32
-			return Redux_Core::$redux_path . $relative_path;
33
-		}
34
-	}
24
+        /**
25
+         * Gets Redux path.
26
+         *
27
+         * @param string $relative_path Self-explanatory.
28
+         *
29
+         * @return string
30
+         */
31
+        public static function get_path( string $relative_path ): string {
32
+            return Redux_Core::$redux_path . $relative_path;
33
+        }
34
+    }
35 35
 
36
-	Redux_Path::init();
36
+    Redux_Path::init();
37 37
 }
Please login to merge, or discard this patch.
redux-core/inc/fields/content/class-redux-content.php 1 patch
Indentation   +76 added lines, -76 removed lines patch added patch discarded remove patch
@@ -12,100 +12,100 @@
 block discarded – undo
12 12
 // Don't duplicate me!
13 13
 if ( ! class_exists( 'Redux_Content', false ) ) {
14 14
 
15
-	/**
16
-	 * Main Redux_Content class
17
-	 *
18
-	 * @since       1.0.0
19
-	 */
20
-	class Redux_Content extends Redux_Field {
15
+    /**
16
+     * Main Redux_Content class
17
+     *
18
+     * @since       1.0.0
19
+     */
20
+    class Redux_Content extends Redux_Field {
21 21
 
22
-		/**
23
-		 * Set field and value defaults.
24
-		 */
25
-		public function set_defaults() {
26
-			$defaults = array(
27
-				'content' => '',
28
-				'class'   => '',
29
-				'mode'    => 'content',
30
-				'icon'    => '',
31
-				'style'   => 'normal',
32
-			);
22
+        /**
23
+         * Set field and value defaults.
24
+         */
25
+        public function set_defaults() {
26
+            $defaults = array(
27
+                'content' => '',
28
+                'class'   => '',
29
+                'mode'    => 'content',
30
+                'icon'    => '',
31
+                'style'   => 'normal',
32
+            );
33 33
 
34
-			$this->field = wp_parse_args( $this->field, $defaults );
35
-		}
34
+            $this->field = wp_parse_args( $this->field, $defaults );
35
+        }
36 36
 
37
-		/**
38
-		 * Field Render Function.
39
-		 * Takes the vars and outputs the HTML for the field in the settings
40
-		 *
41
-		 * @since       1.0.0
42
-		 * @access      public
43
-		 * @return      void
44
-		 */
45
-		public function render() {
46
-			echo '</td></tr></table>';
37
+        /**
38
+         * Field Render Function.
39
+         * Takes the vars and outputs the HTML for the field in the settings
40
+         *
41
+         * @since       1.0.0
42
+         * @access      public
43
+         * @return      void
44
+         */
45
+        public function render() {
46
+            echo '</td></tr></table>';
47 47
 
48
-			if ( 'content' === $this->field['mode'] ) {
49
-				echo '<div
48
+            if ( 'content' === $this->field['mode'] ) {
49
+                echo '<div
50 50
 						id="content-' . esc_attr( $this->field['id'] ) . '"
51 51
 						class="redux-field redux-field-borders ' . esc_attr( $this->field['class'] ) . ' redux-field-' . esc_attr( $this->field['mode'] ) . '"' .
52
-					'>';
52
+                    '>';
53 53
 
54
-				echo wp_kses_post( $this->field['content'] );
55
-			} elseif ( 'heading' === $this->field['mode'] ) {
56
-				$has_icon = isset( $this->field['icon'] ) && ! empty( $this->field['icon'] ) && true !== $this->field['icon'] ? 'hasIcon ' : '';
54
+                echo wp_kses_post( $this->field['content'] );
55
+            } elseif ( 'heading' === $this->field['mode'] ) {
56
+                $has_icon = isset( $this->field['icon'] ) && ! empty( $this->field['icon'] ) && true !== $this->field['icon'] ? 'hasIcon ' : '';
57 57
 
58
-				echo '<div
58
+                echo '<div
59 59
 						id="heading-' . esc_attr( $this->field['id'] ) . '"
60 60
 						class="redux-field redux-field-borders ' . esc_attr( $has_icon ) . esc_attr( $this->field['class'] ) . ' redux-field-' . esc_attr( $this->field['mode'] ) . '"' .
61
-					'>';
61
+                    '>';
62 62
 
63
-				if ( isset( $this->field['icon'] ) && ! empty( $this->field['icon'] ) && true !== $this->field['icon'] ) {
64
-					echo '<p class="redux-heading-icon"><i class="' . esc_attr( $this->field['icon'] ) . ' icon-large"></i></p>';
65
-				}
63
+                if ( isset( $this->field['icon'] ) && ! empty( $this->field['icon'] ) && true !== $this->field['icon'] ) {
64
+                    echo '<p class="redux-heading-icon"><i class="' . esc_attr( $this->field['icon'] ) . ' icon-large"></i></p>';
65
+                }
66 66
 
67
-				echo '<h2 class="redux-heading-text">' . wp_kses_post( $this->field['content'] ) . '</h2>';
68
-			} elseif ( 'subheading' === $this->field['mode'] ) {
69
-				echo '<div
67
+                echo '<h2 class="redux-heading-text">' . wp_kses_post( $this->field['content'] ) . '</h2>';
68
+            } elseif ( 'subheading' === $this->field['mode'] ) {
69
+                echo '<div
70 70
 						id="subheading-' . esc_attr( $this->field['id'] ) . '"
71 71
 						class="redux-field redux-field-borders ' . esc_attr( $this->field['class'] ) . ' redux-field-' . esc_attr( $this->field['mode'] ) . '"' .
72
-					'>';
72
+                    '>';
73 73
 
74
-				echo wp_kses_post( $this->field['content'] );
75
-			} elseif ( 'submessage' === $this->field['mode'] ) {
76
-				echo '<div
74
+                echo wp_kses_post( $this->field['content'] );
75
+            } elseif ( 'submessage' === $this->field['mode'] ) {
76
+                echo '<div
77 77
 						id="submessage-' . esc_attr( $this->field['id'] ) . '"
78 78
 						class="redux-field redux-field-no-borders redux-submessage-' . esc_attr( $this->field['style'] ) . ' ' . esc_attr( $this->field['class'] ) . ' redux-field-' . esc_attr( $this->field['mode'] ) . '"' .
79
-					'>';
79
+                    '>';
80 80
 
81
-				echo wp_kses_post( $this->field['content'] );
82
-			}
81
+                echo wp_kses_post( $this->field['content'] );
82
+            }
83 83
 
84
-			echo '</div>';
85
-			echo '<table class="form-table no-border" style="display:none;">';
86
-			echo '<tbody>';
87
-			echo '<tr style="border-bottom:0; display:none;">';
88
-			echo '<th style="padding-top:0;"></th>';
89
-			echo '<td style="padding-top:0;">';
90
-		}
84
+            echo '</div>';
85
+            echo '<table class="form-table no-border" style="display:none;">';
86
+            echo '<tbody>';
87
+            echo '<tr style="border-bottom:0; display:none;">';
88
+            echo '<th style="padding-top:0;"></th>';
89
+            echo '<td style="padding-top:0;">';
90
+        }
91 91
 
92
-		/**
93
-		 * Enqueue Function.
94
-		 * If this field requires any scripts, or css define this function and register/enqueue the scripts/css
95
-		 *
96
-		 * @since       1.0.0
97
-		 * @access      public
98
-		 * @return      void
99
-		 */
100
-		public function enqueue() {
101
-			if ( $this->parent->args['dev_mode'] ) {
102
-				wp_enqueue_style(
103
-					'redux-field-content',
104
-					Redux_Core::$url . 'inc/fields/content/redux-content.css',
105
-					array(),
106
-					$this->timestamp
107
-				);
108
-			}
109
-		}
110
-	}
92
+        /**
93
+         * Enqueue Function.
94
+         * If this field requires any scripts, or css define this function and register/enqueue the scripts/css
95
+         *
96
+         * @since       1.0.0
97
+         * @access      public
98
+         * @return      void
99
+         */
100
+        public function enqueue() {
101
+            if ( $this->parent->args['dev_mode'] ) {
102
+                wp_enqueue_style(
103
+                    'redux-field-content',
104
+                    Redux_Core::$url . 'inc/fields/content/redux-content.css',
105
+                    array(),
106
+                    $this->timestamp
107
+                );
108
+            }
109
+        }
110
+    }
111 111
 }
Please login to merge, or discard this patch.
redux-core/inc/fields/dimensions/class-redux-dimensions.php 1 patch
Indentation   +268 added lines, -268 removed lines patch added patch discarded remove patch
@@ -12,133 +12,133 @@  discard block
 block discarded – undo
12 12
 
13 13
 if ( ! class_exists( 'Redux_Dimensions', false ) ) {
14 14
 
15
-	/**
16
-	 * Class Redux_Dimensions
17
-	 */
18
-	class Redux_Dimensions extends Redux_Field {
19
-
20
-		/**
21
-		 * Set field and value defaults.
22
-		 */
23
-		public function set_defaults() {
24
-			// No errors, please.
25
-			$defaults = array(
26
-				'width'          => true,
27
-				'height'         => true,
28
-				'units_extended' => false,
29
-				'units'          => 'px',
30
-				'mode'           => array(
31
-					'width'  => false,
32
-					'height' => false,
33
-				),
34
-			);
35
-
36
-			$this->field = wp_parse_args( $this->field, $defaults );
37
-
38
-			$defaults = array(
39
-				'width'  => '',
40
-				'height' => '',
41
-				'units'  => 'px',
42
-			);
43
-
44
-			$this->value = wp_parse_args( $this->value, $defaults );
45
-
46
-			if ( isset( $this->value['unit'] ) ) {
47
-				$this->value['units'] = $this->value['unit'];
48
-			}
49
-		}
50
-
51
-		/**
52
-		 * Field Render Function.
53
-		 * Takes the vars and outputs the HTML for the field in the settings
54
-		 *
55
-		 * @since ReduxFramework 1.0.0
56
-		 */
57
-		public function render() {
58
-			/*
15
+    /**
16
+     * Class Redux_Dimensions
17
+     */
18
+    class Redux_Dimensions extends Redux_Field {
19
+
20
+        /**
21
+         * Set field and value defaults.
22
+         */
23
+        public function set_defaults() {
24
+            // No errors, please.
25
+            $defaults = array(
26
+                'width'          => true,
27
+                'height'         => true,
28
+                'units_extended' => false,
29
+                'units'          => 'px',
30
+                'mode'           => array(
31
+                    'width'  => false,
32
+                    'height' => false,
33
+                ),
34
+            );
35
+
36
+            $this->field = wp_parse_args( $this->field, $defaults );
37
+
38
+            $defaults = array(
39
+                'width'  => '',
40
+                'height' => '',
41
+                'units'  => 'px',
42
+            );
43
+
44
+            $this->value = wp_parse_args( $this->value, $defaults );
45
+
46
+            if ( isset( $this->value['unit'] ) ) {
47
+                $this->value['units'] = $this->value['unit'];
48
+            }
49
+        }
50
+
51
+        /**
52
+         * Field Render Function.
53
+         * Takes the vars and outputs the HTML for the field in the settings
54
+         *
55
+         * @since ReduxFramework 1.0.0
56
+         */
57
+        public function render() {
58
+            /*
59 59
 			 * Acceptable values checks.  If the passed variable doesn't pass muster, we unset them
60 60
 			 * and reset them with default values to avoid errors.
61 61
 			 */
62 62
 
63
-			$arr_units = Redux_Helpers::$array_units;
63
+            $arr_units = Redux_Helpers::$array_units;
64 64
 
65
-			$unit_check   = $arr_units;
66
-			$unit_check[] = false;
65
+            $unit_check   = $arr_units;
66
+            $unit_check[] = false;
67 67
 
68
-			// If units field has a value but is not an acceptable value, unset the variable.
69
-			if ( isset( $this->field['units'] ) && ! Redux_Helpers::array_in_array( $this->field['units'], $unit_check ) ) {
70
-				unset( $this->field['units'] );
71
-			}
68
+            // If units field has a value but is not an acceptable value, unset the variable.
69
+            if ( isset( $this->field['units'] ) && ! Redux_Helpers::array_in_array( $this->field['units'], $unit_check ) ) {
70
+                unset( $this->field['units'] );
71
+            }
72 72
 
73
-			// If there is a default unit value  but is not an accepted value, unset the variable.
74
-			if ( isset( $this->value['units'] ) && ! Redux_Helpers::array_in_array( $this->value['units'], $unit_check ) ) {
75
-				unset( $this->value['units'] );
76
-			}
73
+            // If there is a default unit value  but is not an accepted value, unset the variable.
74
+            if ( isset( $this->value['units'] ) && ! Redux_Helpers::array_in_array( $this->value['units'], $unit_check ) ) {
75
+                unset( $this->value['units'] );
76
+            }
77 77
 
78
-			/*
78
+            /*
79 79
 			 * Since the unit field could be an array, string value or bool (to hide the unit field)
80 80
 			 * we need to separate our functions to avoid those nasty PHP index notices!
81 81
 			 */
82 82
 
83
-			// if field units have a value and ARE an array, then evaluate as needed.
84
-			if ( isset( $this->field['units'] ) && ! is_array( $this->field['units'] ) ) {
85
-
86
-				// If units fields has a value but units value does not then make units value the field value.
87
-				if ( isset( $this->field['units'] ) && ! isset( $this->value['units'] ) || false === $this->field['units'] ) {
88
-					$this->value['units'] = $this->field['units'];
89
-
90
-					// If unit field does NOT have a value and units value does NOT have a value, set both to blank (default?).
91
-				} elseif ( ! isset( $this->field['units'] ) && ! isset( $this->value['units'] ) ) {
92
-					$this->field['units'] = 'px';
93
-					$this->value['units'] = 'px';
94
-
95
-					// If unit field has NO value but units value does, then set unit field to value field.
96
-				} elseif ( ! isset( $this->field['units'] ) && isset( $this->value['units'] ) ) {
97
-					$this->field['units'] = $this->value['units'];
98
-
99
-					// if unit value is set and unit value doesn't equal unit field (coz who knows why)
100
-					// then set unit value to unit field.
101
-				} elseif ( isset( $this->value['units'] ) && $this->value['units'] !== $this->field['units'] ) {
102
-					$this->value['units'] = $this->field['units'];
103
-				}
104
-
105
-				// do stuff based on unit field NOT set as an array.
106
-				// phpcs:ignore Generic.CodeAnalysis.EmptyStatement
107
-			} elseif ( isset( $this->field['units'] ) && is_array( $this->field['units'] ) ) {
108
-				// nothing to do here, but I'm leaving the construct just in case I have to debug this again.
109
-			}
110
-
111
-			echo '<fieldset id="' . esc_attr( $this->field['id'] ) . '-fieldset" class="redux-dimensions-container" data-id="' . esc_attr( $this->field['id'] ) . '">';
112
-
113
-			$this->select2_config['allowClear'] = false;
114
-
115
-			if ( isset( $this->field['select2'] ) ) {
116
-				$this->field['select2'] = wp_parse_args( $this->field['select2'], $this->select2_config );
117
-			} else {
118
-				$this->field['select2'] = $this->select2_config;
119
-			}
120
-
121
-			$this->field['select2'] = Redux_Functions::sanitize_camel_case_array_keys( $this->field['select2'] );
122
-
123
-			$select2_data = Redux_Functions::create_data_string( $this->field['select2'] );
124
-
125
-			// This used to be unit field, but was giving the PHP index error when it was an array,
126
-			// so I changed it.
127
-			echo '<input type="hidden" id="' . esc_attr( $this->field['id'] ) . '-units" class="field-units" value="' . esc_attr( $this->value['units'] ) . '">';
128
-
129
-			/**
130
-			 * Width
131
-			 * */
132
-			if ( true === $this->field['width'] ) {
133
-				if ( ! empty( $this->value['width'] ) && false !== $this->value['units'] && strpos( $this->value['width'], strval( $this->value['units'] ) ) === false ) {
134
-					$this->value['width'] = filter_var( $this->value['width'], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION );
135
-					if ( false !== $this->field['units'] ) {
136
-						$this->value['width'] .= $this->value['units'];
137
-					}
138
-				}
139
-				echo '<div class="field-dimensions-input input-prepend">';
140
-				echo '<span class="add-on"><i class="el el-resize-horizontal icon-large"></i></span>';
141
-				echo '<input
83
+            // if field units have a value and ARE an array, then evaluate as needed.
84
+            if ( isset( $this->field['units'] ) && ! is_array( $this->field['units'] ) ) {
85
+
86
+                // If units fields has a value but units value does not then make units value the field value.
87
+                if ( isset( $this->field['units'] ) && ! isset( $this->value['units'] ) || false === $this->field['units'] ) {
88
+                    $this->value['units'] = $this->field['units'];
89
+
90
+                    // If unit field does NOT have a value and units value does NOT have a value, set both to blank (default?).
91
+                } elseif ( ! isset( $this->field['units'] ) && ! isset( $this->value['units'] ) ) {
92
+                    $this->field['units'] = 'px';
93
+                    $this->value['units'] = 'px';
94
+
95
+                    // If unit field has NO value but units value does, then set unit field to value field.
96
+                } elseif ( ! isset( $this->field['units'] ) && isset( $this->value['units'] ) ) {
97
+                    $this->field['units'] = $this->value['units'];
98
+
99
+                    // if unit value is set and unit value doesn't equal unit field (coz who knows why)
100
+                    // then set unit value to unit field.
101
+                } elseif ( isset( $this->value['units'] ) && $this->value['units'] !== $this->field['units'] ) {
102
+                    $this->value['units'] = $this->field['units'];
103
+                }
104
+
105
+                // do stuff based on unit field NOT set as an array.
106
+                // phpcs:ignore Generic.CodeAnalysis.EmptyStatement
107
+            } elseif ( isset( $this->field['units'] ) && is_array( $this->field['units'] ) ) {
108
+                // nothing to do here, but I'm leaving the construct just in case I have to debug this again.
109
+            }
110
+
111
+            echo '<fieldset id="' . esc_attr( $this->field['id'] ) . '-fieldset" class="redux-dimensions-container" data-id="' . esc_attr( $this->field['id'] ) . '">';
112
+
113
+            $this->select2_config['allowClear'] = false;
114
+
115
+            if ( isset( $this->field['select2'] ) ) {
116
+                $this->field['select2'] = wp_parse_args( $this->field['select2'], $this->select2_config );
117
+            } else {
118
+                $this->field['select2'] = $this->select2_config;
119
+            }
120
+
121
+            $this->field['select2'] = Redux_Functions::sanitize_camel_case_array_keys( $this->field['select2'] );
122
+
123
+            $select2_data = Redux_Functions::create_data_string( $this->field['select2'] );
124
+
125
+            // This used to be unit field, but was giving the PHP index error when it was an array,
126
+            // so I changed it.
127
+            echo '<input type="hidden" id="' . esc_attr( $this->field['id'] ) . '-units" class="field-units" value="' . esc_attr( $this->value['units'] ) . '">';
128
+
129
+            /**
130
+             * Width
131
+             * */
132
+            if ( true === $this->field['width'] ) {
133
+                if ( ! empty( $this->value['width'] ) && false !== $this->value['units'] && strpos( $this->value['width'], strval( $this->value['units'] ) ) === false ) {
134
+                    $this->value['width'] = filter_var( $this->value['width'], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION );
135
+                    if ( false !== $this->field['units'] ) {
136
+                        $this->value['width'] .= $this->value['units'];
137
+                    }
138
+                }
139
+                echo '<div class="field-dimensions-input input-prepend">';
140
+                echo '<span class="add-on"><i class="el el-resize-horizontal icon-large"></i></span>';
141
+                echo '<input
142 142
 						type="text"
143 143
 						id="' . esc_attr( $this->field['id'] ) . '-width"
144 144
 						class="redux-dimensions-input redux-dimensions-width mini ' . esc_attr( $this->field['class'] ) . '"
@@ -146,29 +146,29 @@  discard block
 block discarded – undo
146 146
 						rel="' . esc_attr( $this->field['id'] ) . '-width-hidden"
147 147
 						value="' . esc_attr( filter_var( $this->value['width'], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION ) ) . '">';
148 148
 
149
-				echo '<input
149
+                echo '<input
150 150
 						data-id="' . esc_attr( $this->field['id'] ) . '"
151 151
 						type="hidden"
152 152
 						id="' . esc_attr( $this->field['id'] ) . '-width-hidden"
153 153
 						name="' . esc_attr( $this->field['name'] . $this->field['name_suffix'] ) . '[width]"
154 154
 						value="' . esc_attr( $this->value['width'] ) . '">';
155 155
 
156
-				echo '</div>';
157
-			}
158
-
159
-			/**
160
-			 * Height
161
-			 * */
162
-			if ( true === $this->field['height'] ) {
163
-				if ( ! empty( $this->value['height'] ) && false !== $this->value['units'] && strpos( $this->value['height'], strval( $this->value['units'] ) ) === false ) {
164
-					$this->value['height'] = filter_var( $this->value['height'], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION );
165
-					if ( false !== $this->field['units'] ) {
166
-						$this->value['height'] .= $this->value['units'];
167
-					}
168
-				}
169
-				echo '<div class="field-dimensions-input input-prepend">';
170
-				echo '<span class="add-on"><i class="el el-resize-vertical icon-large"></i></span>';
171
-				echo '<input
156
+                echo '</div>';
157
+            }
158
+
159
+            /**
160
+             * Height
161
+             * */
162
+            if ( true === $this->field['height'] ) {
163
+                if ( ! empty( $this->value['height'] ) && false !== $this->value['units'] && strpos( $this->value['height'], strval( $this->value['units'] ) ) === false ) {
164
+                    $this->value['height'] = filter_var( $this->value['height'], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION );
165
+                    if ( false !== $this->field['units'] ) {
166
+                        $this->value['height'] .= $this->value['units'];
167
+                    }
168
+                }
169
+                echo '<div class="field-dimensions-input input-prepend">';
170
+                echo '<span class="add-on"><i class="el el-resize-vertical icon-large"></i></span>';
171
+                echo '<input
172 172
 						type="text"
173 173
 						id="' . esc_attr( $this->field['id'] ) . '-height"
174 174
 						class="redux-dimensions-input redux-dimensions-height mini ' . esc_attr( $this->field['class'] ) . '"
@@ -176,156 +176,156 @@  discard block
 block discarded – undo
176 176
 						rel="' . esc_attr( $this->field['id'] ) . '-height-hidden"
177 177
 						value="' . esc_attr( filter_var( $this->value['height'], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION ) ) . '">';
178 178
 
179
-				echo '<input
179
+                echo '<input
180 180
 						data-id="' . esc_attr( $this->field['id'] ) . '"
181 181
 						type="hidden"
182 182
 						id="' . esc_attr( $this->field['id'] ) . '-height-hidden"
183 183
 						name="' . esc_attr( $this->field['name'] . $this->field['name_suffix'] ) . '[height]"
184 184
 						value="' . esc_attr( $this->value['height'] ) . '">';
185
-						echo '</div>';
186
-			}
187
-
188
-			/**
189
-			 * Units
190
-			 * */
191
-			// If units field is set and units field NOT false then fill out the options object and show it, otherwise it's hidden
192
-			// and the default units value will apply.
193
-			if ( isset( $this->field['units'] ) && false !== $this->field['units'] ) {
194
-				echo '<div
185
+                        echo '</div>';
186
+            }
187
+
188
+            /**
189
+             * Units
190
+             * */
191
+            // If units field is set and units field NOT false then fill out the options object and show it, otherwise it's hidden
192
+            // and the default units value will apply.
193
+            if ( isset( $this->field['units'] ) && false !== $this->field['units'] ) {
194
+                echo '<div
195 195
 						class="select_wrapper dimensions-units"
196 196
 						original-title="' . esc_html__( 'Units', 'redux-framework' ) . '">';
197 197
 
198
-				echo '<select
198
+                echo '<select
199 199
 						data-id="' . esc_attr( $this->field['id'] ) . '"
200 200
 						data-placeholder="' . esc_html__( 'Units', 'redux-framework' ) . '"
201 201
 						class="redux-dimensions redux-dimensions-units select ' . esc_attr( $this->field['class'] ) . '"
202 202
 						original-title="' . esc_html__( 'Units', 'redux-framework' ) . '"
203 203
 						name="' . esc_attr( $this->field['name'] . $this->field['name_suffix'] ) . '[units]"' . esc_attr( $select2_data ) . '>';
204 204
 
205
-				// Extended units, show 'em all.
206
-				if ( $this->field['units_extended'] ) {
207
-					$test_units = $arr_units;
208
-				} else {
209
-					$test_units = array( 'px', 'em', 'rem', '%' );
210
-				}
211
-
212
-				if ( '' !== $this->field['units'] && is_array( $this->field['units'] ) ) {
213
-					$test_units = $this->field['units'];
214
-				}
215
-
216
-				if ( in_array( $this->field['units'], $test_units, true ) ) {
217
-					echo '<option value="' . esc_attr( $this->field['units'] ) . '" selected="selected">' . esc_attr( $this->field['units'] ) . '</option>';
218
-				} else {
219
-					foreach ( $test_units as $a_unit ) {
220
-						echo '<option value="' . esc_attr( $a_unit ) . '" ' . selected( $this->value['units'], $a_unit, false ) . '>' . esc_attr( $a_unit ) . '</option>';
221
-					}
222
-				}
223
-				echo '</select></div>';
224
-			}
225
-
226
-			echo '</fieldset>';
227
-		}
228
-
229
-		/**
230
-		 * Enqueue Function.
231
-		 * If this field requires any scripts, or css define this function and register/enqueue the scripts/css
232
-		 *
233
-		 * @since ReduxFramework 1.0.0
234
-		 */
235
-		public function enqueue() {
236
-			wp_enqueue_style( 'select2-css' );
237
-
238
-			wp_enqueue_script(
239
-				'redux-field-dimensions',
240
-				Redux_Core::$url . 'inc/fields/dimensions/redux-dimensions' . Redux_Functions::is_min() . '.js',
241
-				array( 'jquery', 'select2-js', 'redux-js' ),
242
-				$this->timestamp,
243
-				true
244
-			);
245
-
246
-			if ( $this->parent->args['dev_mode'] ) {
247
-				wp_enqueue_style(
248
-					'redux-field-dimensions',
249
-					Redux_Core::$url . 'inc/fields/dimensions/redux-dimensions.css',
250
-					array(),
251
-					$this->timestamp
252
-				);
253
-			}
254
-		}
255
-
256
-		/**
257
-		 * Compile CSS styles for output.
258
-		 *
259
-		 * @param string $data CSS data.
260
-		 *
261
-		 * @return string
262
-		 */
263
-		public function css_style( $data ): string {
264
-			$style = '';
265
-
266
-			// If field units has a value and IS an array, then evaluate as needed.
267
-			if ( isset( $this->field['units'] ) && ! is_array( $this->field['units'] ) ) {
268
-
269
-				// If units fields has a value but units value does not then make units value the field value.
270
-				if ( isset( $this->field['units'] ) && ! isset( $this->value['units'] ) || false === $this->field['units'] ) {
271
-					$this->value['units'] = $this->field['units'];
272
-
273
-					// If units field does NOT have a value and units value does NOT have a value, set both to blank (default?).
274
-				} elseif ( ! isset( $this->field['units'] ) && ! isset( $this->value['units'] ) ) {
275
-					$this->field['units'] = 'px';
276
-					$this->value['units'] = 'px';
277
-
278
-					// If units field has NO value but units value does, then set unit field to value field.
279
-				} elseif ( ! isset( $this->field['units'] ) && isset( $this->value['units'] ) ) {
280
-					$this->field['units'] = $this->value['units'];
281
-
282
-					// If unit value is set and unit value doesn't equal unit field (coz who knows why)
283
-					// then set unit value to unit field.
284
-				} elseif ( isset( $this->value['units'] ) && $this->field['units'] !== $this->value['units'] ) {
285
-					$this->value['units'] = $this->field['units'];
286
-				}
287
-
288
-				// Do stuff based on unit field NOT set as an array.
289
-				// phpcs:ignore Generic.CodeAnalysis.EmptyStatement
290
-			} elseif ( isset( $this->field['units'] ) && is_array( $this->field['units'] ) ) {
291
-				// nothing to do here, but I'm leaving the construct just in case I have to debug this again.
292
-			}
293
-
294
-			$units = $this->value['units'] ?? '';
295
-
296
-			if ( ! is_array( $this->field['mode'] ) ) {
297
-				$height = isset( $this->field['mode'] ) && ! empty( $this->field['mode'] ) ? $this->field['mode'] : 'height';
298
-				$width  = isset( $this->field['mode'] ) && ! empty( $this->field['mode'] ) ? $this->field['mode'] : 'width';
299
-			} else {
300
-				$height = false !== $this->field['mode']['height'] ? $this->field['mode']['height'] : 'height';
301
-				$width  = false !== $this->field['mode']['width'] ? $this->field['mode']['width'] : 'width';
302
-			}
303
-
304
-			$clean_value = array(
305
-				$height => isset( $this->value['height'] ) ? filter_var( $this->value['height'], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION ) : '',
306
-				$width  => isset( $this->value['width'] ) ? filter_var( $this->value['width'], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION ) : '',
307
-			);
308
-
309
-			foreach ( $clean_value as $key => $value ) {
310
-				// Output if it's a numeric entry.
311
-				if ( isset( $value ) && is_numeric( $value ) ) {
312
-					$style .= $key . ':' . $value . $units . ';';
313
-				}
314
-			}
315
-
316
-			return $style;
317
-		}
318
-
319
-		/**
320
-		 * Enable output_variables to be generated.
321
-		 *
322
-		 * @since       4.0.3
323
-		 * @return void
324
-		 */
325
-		public function output_variables() {
326
-			// No code needed, just defining the method is enough.
327
-		}
328
-	}
205
+                // Extended units, show 'em all.
206
+                if ( $this->field['units_extended'] ) {
207
+                    $test_units = $arr_units;
208
+                } else {
209
+                    $test_units = array( 'px', 'em', 'rem', '%' );
210
+                }
211
+
212
+                if ( '' !== $this->field['units'] && is_array( $this->field['units'] ) ) {
213
+                    $test_units = $this->field['units'];
214
+                }
215
+
216
+                if ( in_array( $this->field['units'], $test_units, true ) ) {
217
+                    echo '<option value="' . esc_attr( $this->field['units'] ) . '" selected="selected">' . esc_attr( $this->field['units'] ) . '</option>';
218
+                } else {
219
+                    foreach ( $test_units as $a_unit ) {
220
+                        echo '<option value="' . esc_attr( $a_unit ) . '" ' . selected( $this->value['units'], $a_unit, false ) . '>' . esc_attr( $a_unit ) . '</option>';
221
+                    }
222
+                }
223
+                echo '</select></div>';
224
+            }
225
+
226
+            echo '</fieldset>';
227
+        }
228
+
229
+        /**
230
+         * Enqueue Function.
231
+         * If this field requires any scripts, or css define this function and register/enqueue the scripts/css
232
+         *
233
+         * @since ReduxFramework 1.0.0
234
+         */
235
+        public function enqueue() {
236
+            wp_enqueue_style( 'select2-css' );
237
+
238
+            wp_enqueue_script(
239
+                'redux-field-dimensions',
240
+                Redux_Core::$url . 'inc/fields/dimensions/redux-dimensions' . Redux_Functions::is_min() . '.js',
241
+                array( 'jquery', 'select2-js', 'redux-js' ),
242
+                $this->timestamp,
243
+                true
244
+            );
245
+
246
+            if ( $this->parent->args['dev_mode'] ) {
247
+                wp_enqueue_style(
248
+                    'redux-field-dimensions',
249
+                    Redux_Core::$url . 'inc/fields/dimensions/redux-dimensions.css',
250
+                    array(),
251
+                    $this->timestamp
252
+                );
253
+            }
254
+        }
255
+
256
+        /**
257
+         * Compile CSS styles for output.
258
+         *
259
+         * @param string $data CSS data.
260
+         *
261
+         * @return string
262
+         */
263
+        public function css_style( $data ): string {
264
+            $style = '';
265
+
266
+            // If field units has a value and IS an array, then evaluate as needed.
267
+            if ( isset( $this->field['units'] ) && ! is_array( $this->field['units'] ) ) {
268
+
269
+                // If units fields has a value but units value does not then make units value the field value.
270
+                if ( isset( $this->field['units'] ) && ! isset( $this->value['units'] ) || false === $this->field['units'] ) {
271
+                    $this->value['units'] = $this->field['units'];
272
+
273
+                    // If units field does NOT have a value and units value does NOT have a value, set both to blank (default?).
274
+                } elseif ( ! isset( $this->field['units'] ) && ! isset( $this->value['units'] ) ) {
275
+                    $this->field['units'] = 'px';
276
+                    $this->value['units'] = 'px';
277
+
278
+                    // If units field has NO value but units value does, then set unit field to value field.
279
+                } elseif ( ! isset( $this->field['units'] ) && isset( $this->value['units'] ) ) {
280
+                    $this->field['units'] = $this->value['units'];
281
+
282
+                    // If unit value is set and unit value doesn't equal unit field (coz who knows why)
283
+                    // then set unit value to unit field.
284
+                } elseif ( isset( $this->value['units'] ) && $this->field['units'] !== $this->value['units'] ) {
285
+                    $this->value['units'] = $this->field['units'];
286
+                }
287
+
288
+                // Do stuff based on unit field NOT set as an array.
289
+                // phpcs:ignore Generic.CodeAnalysis.EmptyStatement
290
+            } elseif ( isset( $this->field['units'] ) && is_array( $this->field['units'] ) ) {
291
+                // nothing to do here, but I'm leaving the construct just in case I have to debug this again.
292
+            }
293
+
294
+            $units = $this->value['units'] ?? '';
295
+
296
+            if ( ! is_array( $this->field['mode'] ) ) {
297
+                $height = isset( $this->field['mode'] ) && ! empty( $this->field['mode'] ) ? $this->field['mode'] : 'height';
298
+                $width  = isset( $this->field['mode'] ) && ! empty( $this->field['mode'] ) ? $this->field['mode'] : 'width';
299
+            } else {
300
+                $height = false !== $this->field['mode']['height'] ? $this->field['mode']['height'] : 'height';
301
+                $width  = false !== $this->field['mode']['width'] ? $this->field['mode']['width'] : 'width';
302
+            }
303
+
304
+            $clean_value = array(
305
+                $height => isset( $this->value['height'] ) ? filter_var( $this->value['height'], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION ) : '',
306
+                $width  => isset( $this->value['width'] ) ? filter_var( $this->value['width'], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION ) : '',
307
+            );
308
+
309
+            foreach ( $clean_value as $key => $value ) {
310
+                // Output if it's a numeric entry.
311
+                if ( isset( $value ) && is_numeric( $value ) ) {
312
+                    $style .= $key . ':' . $value . $units . ';';
313
+                }
314
+            }
315
+
316
+            return $style;
317
+        }
318
+
319
+        /**
320
+         * Enable output_variables to be generated.
321
+         *
322
+         * @since       4.0.3
323
+         * @return void
324
+         */
325
+        public function output_variables() {
326
+            // No code needed, just defining the method is enough.
327
+        }
328
+    }
329 329
 }
330 330
 
331 331
 class_alias( 'Redux_Dimensions', 'ReduxFramework_Dimensions' );
Please login to merge, or discard this patch.
redux-core/inc/fields/border/class-redux-border.php 1 patch
Indentation   +341 added lines, -341 removed lines patch added patch discarded remove patch
@@ -12,370 +12,370 @@
 block discarded – undo
12 12
 // Don't duplicate me!
13 13
 if ( ! class_exists( 'Redux_Border', false ) ) {
14 14
 
15
-	/**
16
-	 * Class Redux_Border
17
-	 */
18
-	class Redux_Border extends Redux_Field {
19
-
20
-		/**
21
-		 * Set field and value defaults.
22
-		 */
23
-		public function set_defaults() {
24
-			// No errors, please.
25
-			$defaults = array(
26
-				'top'    => true,
27
-				'bottom' => true,
28
-				'all'    => true,
29
-				'style'  => true,
30
-				'color'  => true,
31
-				'left'   => true,
32
-				'right'  => true,
33
-			);
34
-
35
-			$this->field = wp_parse_args( $this->field, $defaults );
36
-
37
-			$defaults = array(
38
-				'top'    => '',
39
-				'right'  => '',
40
-				'bottom' => '',
41
-				'left'   => '',
42
-				'color'  => '',
43
-				'style'  => '',
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
-			$value = array(
57
-				'top'    => isset( $this->value['border-top'] ) ? filter_var( $this->value['border-top'], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION ) : filter_var( $this->value['top'], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION ),
58
-				'right'  => isset( $this->value['border-right'] ) ? filter_var( $this->value['border-right'], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION ) : filter_var( $this->value['right'], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION ),
59
-				'bottom' => isset( $this->value['border-bottom'] ) ? filter_var( $this->value['border-bottom'], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION ) : filter_var( $this->value['bottom'], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION ),
60
-				'left'   => isset( $this->value['border-left'] ) ? filter_var( $this->value['border-left'], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION ) : filter_var( $this->value['left'], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION ),
61
-				'color'  => $this->value['border-color'] ?? $this->value['color'],
62
-				'style'  => $this->value['border-style'] ?? $this->value['style'],
63
-			);
64
-
65
-			if ( ( isset( $this->value['width'] ) || isset( $this->value['border-width'] ) ) ) {
66
-				if ( isset( $this->value['border-width'] ) && ! empty( $this->value['border-width'] ) ) {
67
-					$this->value['width'] = $this->value['border-width'];
68
-				}
69
-
70
-				$this->value['width'] = $this->strip_alphas( $this->value['width'] );
71
-
72
-				$value['top']    = $this->value['width'];
73
-				$value['right']  = $this->value['width'];
74
-				$value['bottom'] = $this->value['width'];
75
-				$value['left']   = $this->value['width'];
76
-			}
77
-
78
-			$this->value = $value;
79
-
80
-			$defaults = array(
81
-				'top'    => '',
82
-				'right'  => '',
83
-				'bottom' => '',
84
-				'left'   => '',
85
-			);
86
-
87
-			$this->check_for_all();
88
-
89
-			$this->value = wp_parse_args( $this->value, $defaults );
90
-
91
-			$this->select2_config['allowClear'] = false;
92
-
93
-			if ( isset( $this->field['select2'] ) ) {
94
-				$this->field['select2'] = wp_parse_args( $this->field['select2'], $this->select2_config );
95
-			} else {
96
-				$this->field['select2'] = $this->select2_config;
97
-			}
98
-
99
-			$this->field['select2'] = Redux_Functions::sanitize_camel_case_array_keys( $this->field['select2'] );
100
-
101
-			$select2_data = Redux_Functions::create_data_string( $this->field['select2'] );
102
-
103
-			echo '<input type="hidden" class="field-units" value="px">';
104
-
105
-			if ( isset( $this->field['all'] ) && true === $this->field['all'] ) {
106
-				echo '<div class="field-border-input input-prepend"><span class="add-on"><i class="el el-fullscreen icon-large"></i></span><input type="text" class="redux-border-all redux-border-input mini ' . esc_attr( $this->field['class'] ) . '" placeholder="' . esc_html__( 'All', 'redux-framework' ) . '" rel="' . esc_attr( $this->field['id'] ) . '-all" value="' . esc_attr( $this->value['top'] ) . '"></div>';
107
-			}
108
-
109
-			echo '<input type="hidden" class="redux-border-value" id="' . esc_attr( $this->field['id'] ) . '-top-hidden" name="' . esc_attr( $this->field['name'] . $this->field['name_suffix'] ) . '[border-top]" value="' . ( isset( $this->value['top'] ) && '' !== $this->value['top'] ? esc_attr( $this->value['top'] ) . 'px' : '' ) . '">';
110
-			echo '<input type="hidden" class="redux-border-value" id="' . esc_attr( $this->field['id'] ) . '-right-hidden" name="' . esc_attr( $this->field['name'] . $this->field['name_suffix'] ) . '[border-right]" value="' . ( isset( $this->value['right'] ) && '' !== $this->value['right'] ? esc_attr( $this->value['right'] ) . 'px' : '' ) . '">';
111
-			echo '<input type="hidden" class="redux-border-value" id="' . esc_attr( $this->field['id'] ) . '-bottom-hidden" name="' . esc_attr( $this->field['name'] . $this->field['name_suffix'] ) . '[border-bottom]" value="' . ( isset( $this->value['bottom'] ) && '' !== $this->value['bottom'] ? esc_attr( $this->value['bottom'] ) . 'px' : '' ) . '">';
112
-			echo '<input type="hidden" class="redux-border-value" id="' . esc_attr( $this->field['id'] ) . '-left-hidden" name="' . esc_attr( $this->field['name'] . $this->field['name_suffix'] ) . '[border-left]" value="' . ( isset( $this->value['left'] ) && '' !== $this->value['left'] ? esc_attr( $this->value['left'] ) . 'px' : '' ) . '">';
113
-
114
-			if ( ! isset( $this->field['all'] ) || true !== $this->field['all'] ) {
115
-				/**
116
-				 * Top
117
-				 * */
118
-				if ( true === $this->field['top'] ) {
119
-					echo '<div class="field-border-input input-prepend">
15
+    /**
16
+     * Class Redux_Border
17
+     */
18
+    class Redux_Border extends Redux_Field {
19
+
20
+        /**
21
+         * Set field and value defaults.
22
+         */
23
+        public function set_defaults() {
24
+            // No errors, please.
25
+            $defaults = array(
26
+                'top'    => true,
27
+                'bottom' => true,
28
+                'all'    => true,
29
+                'style'  => true,
30
+                'color'  => true,
31
+                'left'   => true,
32
+                'right'  => true,
33
+            );
34
+
35
+            $this->field = wp_parse_args( $this->field, $defaults );
36
+
37
+            $defaults = array(
38
+                'top'    => '',
39
+                'right'  => '',
40
+                'bottom' => '',
41
+                'left'   => '',
42
+                'color'  => '',
43
+                'style'  => '',
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
+            $value = array(
57
+                'top'    => isset( $this->value['border-top'] ) ? filter_var( $this->value['border-top'], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION ) : filter_var( $this->value['top'], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION ),
58
+                'right'  => isset( $this->value['border-right'] ) ? filter_var( $this->value['border-right'], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION ) : filter_var( $this->value['right'], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION ),
59
+                'bottom' => isset( $this->value['border-bottom'] ) ? filter_var( $this->value['border-bottom'], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION ) : filter_var( $this->value['bottom'], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION ),
60
+                'left'   => isset( $this->value['border-left'] ) ? filter_var( $this->value['border-left'], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION ) : filter_var( $this->value['left'], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION ),
61
+                'color'  => $this->value['border-color'] ?? $this->value['color'],
62
+                'style'  => $this->value['border-style'] ?? $this->value['style'],
63
+            );
64
+
65
+            if ( ( isset( $this->value['width'] ) || isset( $this->value['border-width'] ) ) ) {
66
+                if ( isset( $this->value['border-width'] ) && ! empty( $this->value['border-width'] ) ) {
67
+                    $this->value['width'] = $this->value['border-width'];
68
+                }
69
+
70
+                $this->value['width'] = $this->strip_alphas( $this->value['width'] );
71
+
72
+                $value['top']    = $this->value['width'];
73
+                $value['right']  = $this->value['width'];
74
+                $value['bottom'] = $this->value['width'];
75
+                $value['left']   = $this->value['width'];
76
+            }
77
+
78
+            $this->value = $value;
79
+
80
+            $defaults = array(
81
+                'top'    => '',
82
+                'right'  => '',
83
+                'bottom' => '',
84
+                'left'   => '',
85
+            );
86
+
87
+            $this->check_for_all();
88
+
89
+            $this->value = wp_parse_args( $this->value, $defaults );
90
+
91
+            $this->select2_config['allowClear'] = false;
92
+
93
+            if ( isset( $this->field['select2'] ) ) {
94
+                $this->field['select2'] = wp_parse_args( $this->field['select2'], $this->select2_config );
95
+            } else {
96
+                $this->field['select2'] = $this->select2_config;
97
+            }
98
+
99
+            $this->field['select2'] = Redux_Functions::sanitize_camel_case_array_keys( $this->field['select2'] );
100
+
101
+            $select2_data = Redux_Functions::create_data_string( $this->field['select2'] );
102
+
103
+            echo '<input type="hidden" class="field-units" value="px">';
104
+
105
+            if ( isset( $this->field['all'] ) && true === $this->field['all'] ) {
106
+                echo '<div class="field-border-input input-prepend"><span class="add-on"><i class="el el-fullscreen icon-large"></i></span><input type="text" class="redux-border-all redux-border-input mini ' . esc_attr( $this->field['class'] ) . '" placeholder="' . esc_html__( 'All', 'redux-framework' ) . '" rel="' . esc_attr( $this->field['id'] ) . '-all" value="' . esc_attr( $this->value['top'] ) . '"></div>';
107
+            }
108
+
109
+            echo '<input type="hidden" class="redux-border-value" id="' . esc_attr( $this->field['id'] ) . '-top-hidden" name="' . esc_attr( $this->field['name'] . $this->field['name_suffix'] ) . '[border-top]" value="' . ( isset( $this->value['top'] ) && '' !== $this->value['top'] ? esc_attr( $this->value['top'] ) . 'px' : '' ) . '">';
110
+            echo '<input type="hidden" class="redux-border-value" id="' . esc_attr( $this->field['id'] ) . '-right-hidden" name="' . esc_attr( $this->field['name'] . $this->field['name_suffix'] ) . '[border-right]" value="' . ( isset( $this->value['right'] ) && '' !== $this->value['right'] ? esc_attr( $this->value['right'] ) . 'px' : '' ) . '">';
111
+            echo '<input type="hidden" class="redux-border-value" id="' . esc_attr( $this->field['id'] ) . '-bottom-hidden" name="' . esc_attr( $this->field['name'] . $this->field['name_suffix'] ) . '[border-bottom]" value="' . ( isset( $this->value['bottom'] ) && '' !== $this->value['bottom'] ? esc_attr( $this->value['bottom'] ) . 'px' : '' ) . '">';
112
+            echo '<input type="hidden" class="redux-border-value" id="' . esc_attr( $this->field['id'] ) . '-left-hidden" name="' . esc_attr( $this->field['name'] . $this->field['name_suffix'] ) . '[border-left]" value="' . ( isset( $this->value['left'] ) && '' !== $this->value['left'] ? esc_attr( $this->value['left'] ) . 'px' : '' ) . '">';
113
+
114
+            if ( ! isset( $this->field['all'] ) || true !== $this->field['all'] ) {
115
+                /**
116
+                 * Top
117
+                 * */
118
+                if ( true === $this->field['top'] ) {
119
+                    echo '<div class="field-border-input input-prepend">
120 120
                             <span class="add-on">
121 121
                                 <i class="el el-arrow-up icon-large"></i>
122 122
                             </span>
123 123
                             <input type="text" id="' . esc_attr( $this->field['id'] ) . '-top" class="redux-border-top redux-border-input mini ' . esc_attr( $this->field['class'] ) . '" placeholder="' . esc_html__( 'Top', 'redux-framework' ) . '" rel="' . esc_attr( $this->field['id'] ) . '-top-hidden" value="' . esc_attr( $this->value['top'] ) . '">
124 124
                          </div>';
125
-				}
125
+                }
126 126
 
127
-				/**
128
-				 * Right
129
-				 * */
130
-				if ( true === $this->field['right'] ) {
131
-					echo '<div class="field-border-input input-prepend">
127
+                /**
128
+                 * Right
129
+                 * */
130
+                if ( true === $this->field['right'] ) {
131
+                    echo '<div class="field-border-input input-prepend">
132 132
                             <span class="add-on">
133 133
                                 <i class="el el-arrow-right icon-large"></i>
134 134
                             </span>
135 135
                             <input type="text" id="' . esc_attr( $this->field['id'] ) . '-right" class="redux-border-right redux-border-input mini ' . esc_attr( $this->field['class'] ) . '" placeholder="' . esc_html__( 'Right', 'redux-framework' ) . '" rel="' . esc_attr( $this->field['id'] ) . '-right-hidden" value="' . esc_attr( $this->value['right'] ) . '">
136 136
                         </div>';
137
-				}
137
+                }
138 138
 
139
-				/**
140
-				 * Bottom
141
-				 * */
142
-				if ( true === $this->field['bottom'] ) {
143
-					echo '<div class="field-border-input input-prepend">
139
+                /**
140
+                 * Bottom
141
+                 * */
142
+                if ( true === $this->field['bottom'] ) {
143
+                    echo '<div class="field-border-input input-prepend">
144 144
                             <span class="add-on">
145 145
                                 <i class="el el-arrow-down icon-large"></i>
146 146
                             </span>
147 147
                             <input type="text" id="' . esc_attr( $this->field['id'] ) . '-bottom" class="redux-border-bottom redux-border-input mini ' . esc_attr( $this->field['class'] ) . '" placeholder="' . esc_html__( 'Bottom', 'redux-framework' ) . '" rel="' . esc_attr( $this->field['id'] ) . '-bottom-hidden" value="' . esc_attr( $this->value['bottom'] ) . '">
148 148
                         </div>';
149
-				}
149
+                }
150 150
 
151
-				/**
152
-				 * Left
153
-				 * */
154
-				if ( true === $this->field['left'] ) {
155
-					echo '<div class="field-border-input input-prepend">
151
+                /**
152
+                 * Left
153
+                 * */
154
+                if ( true === $this->field['left'] ) {
155
+                    echo '<div class="field-border-input input-prepend">
156 156
                             <span class="add-on">
157 157
                                 <i class="el el-arrow-left icon-large"></i>
158 158
                             </span>
159 159
                             <input type="text" id="' . esc_attr( $this->field['id'] ) . '-left" class="redux-border-left redux-border-input mini ' . esc_attr( $this->field['class'] ) . '" placeholder="' . esc_html__( 'Left', 'redux-framework' ) . '" rel="' . esc_attr( $this->field['id'] ) . '-left-hidden" value="' . esc_attr( $this->value['left'] ) . '">
160 160
                         </div>';
161
-				}
162
-			}
163
-
164
-			/**
165
-			 * Border-style
166
-			 * */
167
-			if ( false !== $this->field['style'] ) {
168
-				$options = array(
169
-					'solid'  => esc_html__( 'Solid', 'redux-framework' ),
170
-					'dashed' => esc_html__( 'Dashed', 'redux-framework' ),
171
-					'dotted' => esc_html__( 'Dotted', 'redux-framework' ),
172
-					'double' => esc_html__( 'Double', 'redux-framework' ),
173
-					'none'   => esc_html__( 'None', 'redux-framework' ),
174
-				);
175
-
176
-				echo '<select data-placeholder="' . esc_html__( 'Border style', 'redux-framework' ) . '" id="' . esc_attr( $this->field['id'] ) . '[border-style]" name="' . esc_attr( $this->field['name'] . $this->field['name_suffix'] ) . '[border-style]" class="tips redux-border-style ' . esc_attr( $this->field['class'] ) . '" rows="6" data-id="' . esc_attr( $this->field['id'] ) . '"' . esc_attr( $select2_data ) . '>';
177
-
178
-				foreach ( $options as $k => $v ) {
179
-					echo '<option value="' . esc_attr( $k ) . '" ' . selected( $value['style'], $k, false ) . '>' . esc_html( $v ) . '</option>';
180
-				}
181
-
182
-				echo '</select>';
183
-			} else {
184
-				echo '<input type="hidden" id="' . esc_attr( $this->field['id'] ) . '[border-style]" name="' . esc_attr( $this->field['name'] . $this->field['name_suffix'] ) . '[border-style]" value="' . esc_attr( $this->value['style'] ) . '" data-id="' . esc_attr( $this->field['id'] ) . '">';
185
-			}
186
-
187
-			/**
188
-			 * Color
189
-			 * */
190
-			if ( false !== $this->field['color'] ) {
191
-				$default = $this->field['default']['border-color'] ?? '';
192
-
193
-				if ( empty( $default ) ) {
194
-					$default = ( isset( $this->field['default']['color'] ) ) ? $this->field['default']['color'] : '#ffffff';
195
-				}
196
-
197
-				echo '<input ';
198
-				echo 'name="' . esc_attr( $this->field['name'] . $this->field['name_suffix'] ) . '[border-color]"';
199
-				echo 'id="' . esc_attr( $this->field['id'] ) . '-border"';
200
-				echo 'class="color-picker redux-border-color redux-color redux-color-init ' . esc_attr( $this->field['class'] ) . '"';
201
-				echo 'type="text"';
202
-				echo 'value="' . esc_attr( $this->value['color'] ) . '"';
203
-				echo 'data-default-color="' . esc_attr( $default ) . '"';
204
-				echo 'data-id="' . esc_attr( $this->field['id'] ) . '"';
205
-
206
-				$data = array(
207
-					'field' => $this->field,
208
-					'index' => '',
209
-				);
210
-
211
-				echo Redux_Functions_Ex::output_alpha_data( $data ); // phpcs:ignore WordPress.Security.EscapeOutput
212
-
213
-				echo '>';
214
-			} else {
215
-				echo '<input type="hidden" id="' . esc_attr( $this->field['id'] ) . '[border-color]" name="' . esc_attr( $this->field['name'] . $this->field['name_suffix'] ) . '[border-color]" value="' . esc_attr( $this->value['color'] ) . '" data-id="' . esc_attr( $this->field['id'] ) . '">';
216
-			}
217
-		}
218
-
219
-
220
-		/**
221
-		 * Do enqueue for each field instance.
222
-		 *
223
-		 * @return void
224
-		 */
225
-		public function always_enqueue() {
226
-			if ( isset( $this->field['color_alpha'] ) && $this->field['color_alpha'] ) {
227
-				if ( ! wp_script_is( 'redux-wp-color-picker-alpha' ) ) {
228
-					wp_enqueue_script( 'redux-wp-color-picker-alpha' );
229
-				}
230
-			}
231
-		}
232
-
233
-		/**
234
-		 * Enqueue Function.
235
-		 * If this field requires any scripts, or css define this function and register/enqueue the scripts/css
236
-		 *
237
-		 * @since ReduxFramework 1.0.0
238
-		 */
239
-		public function enqueue() {
240
-			$min = Redux_Functions::is_min();
241
-
242
-			if ( ! wp_style_is( 'select2-css' ) ) {
243
-				wp_enqueue_style( 'select2-css' );
244
-			}
245
-
246
-			if ( ! wp_style_is( 'wp-color-picker' ) ) {
247
-				wp_enqueue_style( 'wp-color-picker' );
248
-			}
249
-
250
-			$dep_array = array( 'jquery', 'select2-js', 'wp-color-picker', 'redux-js' );
251
-
252
-			wp_enqueue_script(
253
-				'redux-field-border',
254
-				Redux_Core::$url . 'inc/fields/border/redux-border' . $min . '.js',
255
-				$dep_array,
256
-				$this->timestamp,
257
-				true
258
-			);
259
-
260
-			if ( $this->parent->args['dev_mode'] ) {
261
-				if ( ! wp_style_is( 'redux-color-picker' ) ) {
262
-					wp_enqueue_style( 'redux-color-picker' );
263
-				}
264
-
265
-				wp_enqueue_style(
266
-					'redux-field-border',
267
-					Redux_Core::$url . 'inc/fields/border/redux-border.css',
268
-					array(),
269
-					$this->timestamp
270
-				);
271
-			}
272
-		}
273
-
274
-		/**
275
-		 * Check to make sure all is properly set.
276
-		 *
277
-		 * @return void
278
-		 */
279
-		private function check_for_all() {
280
-			if ( true === $this->field['all'] ) {
281
-				if ( 1 !== $this->field['top'] || 1 !== $this->field['bottom'] || 1 !== $this->field['left'] || 1 !== $this->field['right'] ) {
282
-					$this->field['all'] = false;
283
-				}
284
-			}
285
-		}
286
-
287
-		/**
288
-		 * Output CSS styling.
289
-		 *
290
-		 * @param mixed $data Value array.
291
-		 *
292
-		 * @return string
293
-		 */
294
-		public function css_style( $data ): string {
295
-			$style = '';
296
-
297
-			$this->check_for_all();
298
-
299
-			if ( isset( $this->field['all'] ) && true === $this->field['all'] ) {
300
-				$border_width = $data['border-width'] ?? '0px';
301
-				$val          = $data['border-top'] ?? $border_width;
302
-
303
-				$data['border-top']    = $val;
304
-				$data['border-bottom'] = $val;
305
-				$data['border-left']   = $val;
306
-				$data['border-right']  = $val;
307
-			}
308
-
309
-			$clean_value = array(
310
-				'color' => ! empty( $data['border-color'] ) ? $data['border-color'] : '',
311
-				'style' => ! empty( $data['border-style'] ) ? $data['border-style'] : '',
312
-			);
313
-
314
-			$border_width = '';
315
-			if ( isset( $data['border-width'] ) ) {
316
-				$border_width = $data['border-width'];
317
-			}
318
-
319
-			$this->field['top']    = $this->field['top'] ?? true;
320
-			$this->field['bottom'] = $this->field['bottom'] ?? true;
321
-			$this->field['left']   = $this->field['left'] ?? true;
322
-			$this->field['right']  = $this->field['right'] ?? true;
323
-
324
-			if ( true === $this->field['top'] ) {
325
-				$clean_value['top'] = ! empty( $data['border-top'] ) ? $data['border-top'] : $border_width;
326
-			}
327
-
328
-			if ( true === $this->field['bottom'] ) {
329
-				$clean_value['bottom'] = ! empty( $data['border-bottom'] ) ? $data['border-bottom'] : $border_width;
330
-			}
331
-
332
-			if ( true === $this->field['left'] ) {
333
-				$clean_value['left'] = ! empty( $data['border-left'] ) ? $data['border-left'] : $border_width;
334
-			}
335
-
336
-			if ( true === $this->field['right'] ) {
337
-				$clean_value['right'] = ! empty( $data['border-right'] ) ? $data['border-right'] : $border_width;
338
-			}
339
-
340
-			// absolute, padding, margin.
341
-			if ( ! isset( $this->field['all'] ) || true !== $this->field['all'] ) {
342
-				foreach ( $clean_value as $key => $value ) {
343
-					if ( 'color' === $key || 'style' === $key ) {
344
-						continue;
345
-					}
346
-					if ( ! empty( $value ) ) {
347
-						$style .= 'border-' . $key . ':' . $value . ' ' . $clean_value['style'] . ' ' . $clean_value['color'] . ';';
348
-					}
349
-				}
350
-			} elseif ( ! empty( $clean_value['top'] ) ) {
351
-				$style .= 'border:' . $clean_value['top'] . ' ' . $clean_value['style'] . ' ' . $clean_value['color'] . ';';
352
-			}
353
-
354
-			return $style;
355
-		}
356
-
357
-		/**
358
-		 * Strip alpha chars.
359
-		 *
360
-		 * @param string $s Criteria.
361
-		 *
362
-		 * @return null|string|string[]
363
-		 */
364
-		private function strip_alphas( string $s ) {
365
-			// Regex is our friend.  THERE ARE FOUR LIGHTS!!
366
-			return preg_replace( '/[^\d.-]/', '', $s );
367
-		}
368
-
369
-		/**
370
-		 * Enable output_variables to be generated.
371
-		 *
372
-		 * @since       4.0.3
373
-		 * @return void
374
-		 */
375
-		public function output_variables() {
376
-			// No code needed, just defining the method is enough.
377
-		}
378
-	}
161
+                }
162
+            }
163
+
164
+            /**
165
+             * Border-style
166
+             * */
167
+            if ( false !== $this->field['style'] ) {
168
+                $options = array(
169
+                    'solid'  => esc_html__( 'Solid', 'redux-framework' ),
170
+                    'dashed' => esc_html__( 'Dashed', 'redux-framework' ),
171
+                    'dotted' => esc_html__( 'Dotted', 'redux-framework' ),
172
+                    'double' => esc_html__( 'Double', 'redux-framework' ),
173
+                    'none'   => esc_html__( 'None', 'redux-framework' ),
174
+                );
175
+
176
+                echo '<select data-placeholder="' . esc_html__( 'Border style', 'redux-framework' ) . '" id="' . esc_attr( $this->field['id'] ) . '[border-style]" name="' . esc_attr( $this->field['name'] . $this->field['name_suffix'] ) . '[border-style]" class="tips redux-border-style ' . esc_attr( $this->field['class'] ) . '" rows="6" data-id="' . esc_attr( $this->field['id'] ) . '"' . esc_attr( $select2_data ) . '>';
177
+
178
+                foreach ( $options as $k => $v ) {
179
+                    echo '<option value="' . esc_attr( $k ) . '" ' . selected( $value['style'], $k, false ) . '>' . esc_html( $v ) . '</option>';
180
+                }
181
+
182
+                echo '</select>';
183
+            } else {
184
+                echo '<input type="hidden" id="' . esc_attr( $this->field['id'] ) . '[border-style]" name="' . esc_attr( $this->field['name'] . $this->field['name_suffix'] ) . '[border-style]" value="' . esc_attr( $this->value['style'] ) . '" data-id="' . esc_attr( $this->field['id'] ) . '">';
185
+            }
186
+
187
+            /**
188
+             * Color
189
+             * */
190
+            if ( false !== $this->field['color'] ) {
191
+                $default = $this->field['default']['border-color'] ?? '';
192
+
193
+                if ( empty( $default ) ) {
194
+                    $default = ( isset( $this->field['default']['color'] ) ) ? $this->field['default']['color'] : '#ffffff';
195
+                }
196
+
197
+                echo '<input ';
198
+                echo 'name="' . esc_attr( $this->field['name'] . $this->field['name_suffix'] ) . '[border-color]"';
199
+                echo 'id="' . esc_attr( $this->field['id'] ) . '-border"';
200
+                echo 'class="color-picker redux-border-color redux-color redux-color-init ' . esc_attr( $this->field['class'] ) . '"';
201
+                echo 'type="text"';
202
+                echo 'value="' . esc_attr( $this->value['color'] ) . '"';
203
+                echo 'data-default-color="' . esc_attr( $default ) . '"';
204
+                echo 'data-id="' . esc_attr( $this->field['id'] ) . '"';
205
+
206
+                $data = array(
207
+                    'field' => $this->field,
208
+                    'index' => '',
209
+                );
210
+
211
+                echo Redux_Functions_Ex::output_alpha_data( $data ); // phpcs:ignore WordPress.Security.EscapeOutput
212
+
213
+                echo '>';
214
+            } else {
215
+                echo '<input type="hidden" id="' . esc_attr( $this->field['id'] ) . '[border-color]" name="' . esc_attr( $this->field['name'] . $this->field['name_suffix'] ) . '[border-color]" value="' . esc_attr( $this->value['color'] ) . '" data-id="' . esc_attr( $this->field['id'] ) . '">';
216
+            }
217
+        }
218
+
219
+
220
+        /**
221
+         * Do enqueue for each field instance.
222
+         *
223
+         * @return void
224
+         */
225
+        public function always_enqueue() {
226
+            if ( isset( $this->field['color_alpha'] ) && $this->field['color_alpha'] ) {
227
+                if ( ! wp_script_is( 'redux-wp-color-picker-alpha' ) ) {
228
+                    wp_enqueue_script( 'redux-wp-color-picker-alpha' );
229
+                }
230
+            }
231
+        }
232
+
233
+        /**
234
+         * Enqueue Function.
235
+         * If this field requires any scripts, or css define this function and register/enqueue the scripts/css
236
+         *
237
+         * @since ReduxFramework 1.0.0
238
+         */
239
+        public function enqueue() {
240
+            $min = Redux_Functions::is_min();
241
+
242
+            if ( ! wp_style_is( 'select2-css' ) ) {
243
+                wp_enqueue_style( 'select2-css' );
244
+            }
245
+
246
+            if ( ! wp_style_is( 'wp-color-picker' ) ) {
247
+                wp_enqueue_style( 'wp-color-picker' );
248
+            }
249
+
250
+            $dep_array = array( 'jquery', 'select2-js', 'wp-color-picker', 'redux-js' );
251
+
252
+            wp_enqueue_script(
253
+                'redux-field-border',
254
+                Redux_Core::$url . 'inc/fields/border/redux-border' . $min . '.js',
255
+                $dep_array,
256
+                $this->timestamp,
257
+                true
258
+            );
259
+
260
+            if ( $this->parent->args['dev_mode'] ) {
261
+                if ( ! wp_style_is( 'redux-color-picker' ) ) {
262
+                    wp_enqueue_style( 'redux-color-picker' );
263
+                }
264
+
265
+                wp_enqueue_style(
266
+                    'redux-field-border',
267
+                    Redux_Core::$url . 'inc/fields/border/redux-border.css',
268
+                    array(),
269
+                    $this->timestamp
270
+                );
271
+            }
272
+        }
273
+
274
+        /**
275
+         * Check to make sure all is properly set.
276
+         *
277
+         * @return void
278
+         */
279
+        private function check_for_all() {
280
+            if ( true === $this->field['all'] ) {
281
+                if ( 1 !== $this->field['top'] || 1 !== $this->field['bottom'] || 1 !== $this->field['left'] || 1 !== $this->field['right'] ) {
282
+                    $this->field['all'] = false;
283
+                }
284
+            }
285
+        }
286
+
287
+        /**
288
+         * Output CSS styling.
289
+         *
290
+         * @param mixed $data Value array.
291
+         *
292
+         * @return string
293
+         */
294
+        public function css_style( $data ): string {
295
+            $style = '';
296
+
297
+            $this->check_for_all();
298
+
299
+            if ( isset( $this->field['all'] ) && true === $this->field['all'] ) {
300
+                $border_width = $data['border-width'] ?? '0px';
301
+                $val          = $data['border-top'] ?? $border_width;
302
+
303
+                $data['border-top']    = $val;
304
+                $data['border-bottom'] = $val;
305
+                $data['border-left']   = $val;
306
+                $data['border-right']  = $val;
307
+            }
308
+
309
+            $clean_value = array(
310
+                'color' => ! empty( $data['border-color'] ) ? $data['border-color'] : '',
311
+                'style' => ! empty( $data['border-style'] ) ? $data['border-style'] : '',
312
+            );
313
+
314
+            $border_width = '';
315
+            if ( isset( $data['border-width'] ) ) {
316
+                $border_width = $data['border-width'];
317
+            }
318
+
319
+            $this->field['top']    = $this->field['top'] ?? true;
320
+            $this->field['bottom'] = $this->field['bottom'] ?? true;
321
+            $this->field['left']   = $this->field['left'] ?? true;
322
+            $this->field['right']  = $this->field['right'] ?? true;
323
+
324
+            if ( true === $this->field['top'] ) {
325
+                $clean_value['top'] = ! empty( $data['border-top'] ) ? $data['border-top'] : $border_width;
326
+            }
327
+
328
+            if ( true === $this->field['bottom'] ) {
329
+                $clean_value['bottom'] = ! empty( $data['border-bottom'] ) ? $data['border-bottom'] : $border_width;
330
+            }
331
+
332
+            if ( true === $this->field['left'] ) {
333
+                $clean_value['left'] = ! empty( $data['border-left'] ) ? $data['border-left'] : $border_width;
334
+            }
335
+
336
+            if ( true === $this->field['right'] ) {
337
+                $clean_value['right'] = ! empty( $data['border-right'] ) ? $data['border-right'] : $border_width;
338
+            }
339
+
340
+            // absolute, padding, margin.
341
+            if ( ! isset( $this->field['all'] ) || true !== $this->field['all'] ) {
342
+                foreach ( $clean_value as $key => $value ) {
343
+                    if ( 'color' === $key || 'style' === $key ) {
344
+                        continue;
345
+                    }
346
+                    if ( ! empty( $value ) ) {
347
+                        $style .= 'border-' . $key . ':' . $value . ' ' . $clean_value['style'] . ' ' . $clean_value['color'] . ';';
348
+                    }
349
+                }
350
+            } elseif ( ! empty( $clean_value['top'] ) ) {
351
+                $style .= 'border:' . $clean_value['top'] . ' ' . $clean_value['style'] . ' ' . $clean_value['color'] . ';';
352
+            }
353
+
354
+            return $style;
355
+        }
356
+
357
+        /**
358
+         * Strip alpha chars.
359
+         *
360
+         * @param string $s Criteria.
361
+         *
362
+         * @return null|string|string[]
363
+         */
364
+        private function strip_alphas( string $s ) {
365
+            // Regex is our friend.  THERE ARE FOUR LIGHTS!!
366
+            return preg_replace( '/[^\d.-]/', '', $s );
367
+        }
368
+
369
+        /**
370
+         * Enable output_variables to be generated.
371
+         *
372
+         * @since       4.0.3
373
+         * @return void
374
+         */
375
+        public function output_variables() {
376
+            // No code needed, just defining the method is enough.
377
+        }
378
+    }
379 379
 }
380 380
 
381 381
 class_alias( 'Redux_Border', 'ReduxFramework_Border' );
Please login to merge, or discard this patch.