Completed
Push — master ( c4cd1f...963c86 )
by
unknown
36s
created
redux-core/inc/fields/spinner/class-redux-spinner.php 1 patch
Indentation   +200 added lines, -200 removed lines patch added patch discarded remove patch
@@ -11,206 +11,206 @@
 block discarded – undo
11 11
 
12 12
 if ( ! class_exists( 'Redux_Spinner', false ) ) {
13 13
 
14
-	/**
15
-	 * Class Redux_Spinner
16
-	 */
17
-	class Redux_Spinner extends Redux_Field {
18
-
19
-		/**
20
-		 * Set field and value defaults.
21
-		 */
22
-		public function set_defaults() {
23
-			$params = array(
24
-				'min'     => 0,
25
-				'max'     => 1,
26
-				'step'    => 1,
27
-				'default' => '',
28
-				'edit'    => true,
29
-				'plus'    => '+',
30
-				'minus'   => '-',
31
-				'format'  => '',
32
-				'prefix'  => '',
33
-				'suffix'  => '',
34
-				'point'   => '.',
35
-				'places'  => null,
36
-			);
37
-
38
-			$this->field = wp_parse_args( $this->field, $params );
39
-		}
40
-
41
-		/**
42
-		 * Field Render Function.
43
-		 * Takes the vars and outputs the HTML for the field in the settings
44
-		 *
45
-		 * @since ReduxFramework 3.0.0
46
-		 */
47
-		public function render() {
48
-			$data_string = '';
49
-
50
-			foreach ( $this->field as $key => $val ) {
51
-				if ( in_array( $key, array( 'min', 'max', 'step', 'default', 'plus', 'minus', 'prefix', 'suffix', 'point', 'places' ), true ) ) {
52
-					$data_string .= ' data-' . esc_attr( $key ) . '="' . esc_attr( $val ) . '" ';
53
-				}
54
-			}
55
-
56
-			$data_string .= ' data-val=' . $this->value;
57
-
58
-			// Don't allow input edit if there's a step.
59
-			$readonly = '';
60
-			if ( isset( $this->field['edit'] ) && false === $this->field['edit'] ) {
61
-				$readonly = ' readonly="readonly"';
62
-			}
63
-
64
-			echo '<div id="' . esc_attr( $this->field['id'] ) . '-spinner" class="redux_spinner" rel="' . esc_attr( $this->field['id'] ) . '">';
65
-
66
-			echo '<input type="text" ' . $data_string . ' name="' . esc_attr( $this->field['name'] . $this->field['name_suffix'] ) . '" id="' . esc_attr( $this->field['id'] ) . '" value="' . esc_attr( $this->value ) . '" class="mini spinner-input ' . esc_attr( $this->field['class'] ) . '"' . $readonly . '/>'; // phpcs:ignore WordPress.Security.EscapeOutput
67
-
68
-			echo '</div>';
69
-		}
70
-
71
-		/**
72
-		 * Clean the field data to the fields defaults given the parameters.
73
-		 *
74
-		 * @since Redux_Framework 3.1.1
75
-		 */
76
-		private function clean() {
77
-			if ( empty( $this->field['min'] ) ) {
78
-				$this->field['min'] = 0;
79
-			} else {
80
-				$this->field['min'] = intval( $this->field['min'] );
81
-			}
82
-
83
-			if ( empty( $this->field['max'] ) ) {
84
-				$this->field['max'] = $this->field['min'] + 1;
85
-			} else {
86
-				$this->field['max'] = intval( $this->field['max'] );
87
-			}
88
-
89
-			if ( empty( $this->field['step'] ) || $this->field['step'] > $this->field['max'] ) {
90
-				$this->field['step'] = 1;
91
-			} else {
92
-				$this->field['step'] = intval( $this->field['step'] );
93
-			}
94
-
95
-			if ( empty( $this->value ) && ! empty( $this->field['default'] ) && $this->field['min'] >= 1 ) {
96
-				$this->value = intval( $this->field['default'] );
97
-			}
98
-
99
-			if ( empty( $this->value ) && $this->field['min'] >= 1 ) {
100
-				$this->value = $this->field['min'];
101
-			}
102
-
103
-			if ( empty( $this->value ) ) {
104
-				$this->value = 0;
105
-			}
106
-
107
-			// Extra Validation.
108
-			if ( $this->value < $this->field['min'] ) {
109
-				$this->value = $this->field['min'];
110
-			} elseif ( $this->value > $this->field['max'] ) {
111
-				$this->value = $this->field['max'];
112
-			}
113
-		}
114
-
115
-		/**
116
-		 * Enqueue Function.
117
-		 * If this field requires any scripts, or css define this function and register/enqueue the scripts/css
118
-		 *
119
-		 * @since ReduxFramework 3.0.0
120
-		 */
121
-		public function enqueue() {
122
-			wp_enqueue_script(
123
-				'redux-field-spinner-custom',
124
-				Redux_Core::$url . 'inc/fields/spinner/vendor/jquery.ui.spinner' . Redux_Functions::is_min() . '.js',
125
-				array( 'jquery', 'redux-js' ),
126
-				$this->timestamp,
127
-				true
128
-			);
129
-
130
-			wp_enqueue_script(
131
-				'redux-field-spinner',
132
-				Redux_Core::$url . 'inc/fields/spinner/redux-spinner' . Redux_Functions::is_min() . '.js',
133
-				array( 'jquery', 'redux-field-spinner-custom', 'jquery-ui-core', 'jquery-ui-dialog', 'redux-js' ),
134
-				$this->timestamp,
135
-				true
136
-			);
137
-
138
-			if ( $this->parent->args['dev_mode'] ) {
139
-				wp_enqueue_style(
140
-					'redux-field-spinner',
141
-					Redux_Core::$url . 'inc/fields/spinner/redux-spinner.css',
142
-					array(),
143
-					$this->timestamp
144
-				);
145
-			}
146
-		}
147
-
148
-		/**
149
-		 * CSS/compiler output.
150
-		 *
151
-		 * @param string|null|array $style CSS styles.
152
-		 */
153
-		public function output( $style = '' ) {
154
-			if ( ! empty( $this->value ) ) {
155
-				if ( ! empty( $this->field['output'] ) && is_array( $this->field['output'] ) ) {
156
-					$css                      = $this->parse_css( $this->value, $this->field['output'] );
157
-					$this->parent->outputCSS .= esc_attr( $css );
158
-				}
159
-
160
-				if ( ! empty( $this->field['compiler'] ) && is_array( $this->field['compiler'] ) ) {
161
-					$css                        = $this->parse_css( $this->value, $this->field['compiler'] );
162
-					$this->parent->compilerCSS .= esc_attr( $css );
163
-				}
164
-			}
165
-		}
166
-
167
-		/**
168
-		 * Compile CSS data for output.
169
-		 *
170
-		 * @param mixed $value Value.
171
-		 * @param mixed $output .
172
-		 *
173
-		 * @return string
174
-		 */
175
-		private function parse_css( $value, $output ): string {
176
-			// No notices.
177
-			$css = '';
178
-
179
-			$unit = $this->field['output_unit'] ?? 'px';
180
-
181
-			// Must be an array.
182
-			if ( is_array( $output ) ) {
183
-				foreach ( $output as $selector => $mode ) {
184
-					if ( '' !== $mode && '' !== $selector ) {
185
-						$css .= $selector . '{' . $mode . ':' . $value . $unit . ';}';
186
-					}
187
-				}
188
-			}
189
-
190
-			return $css;
191
-		}
192
-
193
-		/**
194
-		 * Generate CSS style (unused, but needed).
195
-		 *
196
-		 * @param string $data Field data.
197
-		 *
198
-		 * @return string
199
-		 */
200
-		public function css_style( $data ): string {
201
-			return '';
202
-		}
203
-
204
-		/**
205
-		 * Enable output_variables to be generated.
206
-		 *
207
-		 * @since       4.0.3
208
-		 * @return void
209
-		 */
210
-		public function output_variables() {
211
-			// No code needed, just defining the method is enough.
212
-		}
213
-	}
14
+    /**
15
+     * Class Redux_Spinner
16
+     */
17
+    class Redux_Spinner extends Redux_Field {
18
+
19
+        /**
20
+         * Set field and value defaults.
21
+         */
22
+        public function set_defaults() {
23
+            $params = array(
24
+                'min'     => 0,
25
+                'max'     => 1,
26
+                'step'    => 1,
27
+                'default' => '',
28
+                'edit'    => true,
29
+                'plus'    => '+',
30
+                'minus'   => '-',
31
+                'format'  => '',
32
+                'prefix'  => '',
33
+                'suffix'  => '',
34
+                'point'   => '.',
35
+                'places'  => null,
36
+            );
37
+
38
+            $this->field = wp_parse_args( $this->field, $params );
39
+        }
40
+
41
+        /**
42
+         * Field Render Function.
43
+         * Takes the vars and outputs the HTML for the field in the settings
44
+         *
45
+         * @since ReduxFramework 3.0.0
46
+         */
47
+        public function render() {
48
+            $data_string = '';
49
+
50
+            foreach ( $this->field as $key => $val ) {
51
+                if ( in_array( $key, array( 'min', 'max', 'step', 'default', 'plus', 'minus', 'prefix', 'suffix', 'point', 'places' ), true ) ) {
52
+                    $data_string .= ' data-' . esc_attr( $key ) . '="' . esc_attr( $val ) . '" ';
53
+                }
54
+            }
55
+
56
+            $data_string .= ' data-val=' . $this->value;
57
+
58
+            // Don't allow input edit if there's a step.
59
+            $readonly = '';
60
+            if ( isset( $this->field['edit'] ) && false === $this->field['edit'] ) {
61
+                $readonly = ' readonly="readonly"';
62
+            }
63
+
64
+            echo '<div id="' . esc_attr( $this->field['id'] ) . '-spinner" class="redux_spinner" rel="' . esc_attr( $this->field['id'] ) . '">';
65
+
66
+            echo '<input type="text" ' . $data_string . ' name="' . esc_attr( $this->field['name'] . $this->field['name_suffix'] ) . '" id="' . esc_attr( $this->field['id'] ) . '" value="' . esc_attr( $this->value ) . '" class="mini spinner-input ' . esc_attr( $this->field['class'] ) . '"' . $readonly . '/>'; // phpcs:ignore WordPress.Security.EscapeOutput
67
+
68
+            echo '</div>';
69
+        }
70
+
71
+        /**
72
+         * Clean the field data to the fields defaults given the parameters.
73
+         *
74
+         * @since Redux_Framework 3.1.1
75
+         */
76
+        private function clean() {
77
+            if ( empty( $this->field['min'] ) ) {
78
+                $this->field['min'] = 0;
79
+            } else {
80
+                $this->field['min'] = intval( $this->field['min'] );
81
+            }
82
+
83
+            if ( empty( $this->field['max'] ) ) {
84
+                $this->field['max'] = $this->field['min'] + 1;
85
+            } else {
86
+                $this->field['max'] = intval( $this->field['max'] );
87
+            }
88
+
89
+            if ( empty( $this->field['step'] ) || $this->field['step'] > $this->field['max'] ) {
90
+                $this->field['step'] = 1;
91
+            } else {
92
+                $this->field['step'] = intval( $this->field['step'] );
93
+            }
94
+
95
+            if ( empty( $this->value ) && ! empty( $this->field['default'] ) && $this->field['min'] >= 1 ) {
96
+                $this->value = intval( $this->field['default'] );
97
+            }
98
+
99
+            if ( empty( $this->value ) && $this->field['min'] >= 1 ) {
100
+                $this->value = $this->field['min'];
101
+            }
102
+
103
+            if ( empty( $this->value ) ) {
104
+                $this->value = 0;
105
+            }
106
+
107
+            // Extra Validation.
108
+            if ( $this->value < $this->field['min'] ) {
109
+                $this->value = $this->field['min'];
110
+            } elseif ( $this->value > $this->field['max'] ) {
111
+                $this->value = $this->field['max'];
112
+            }
113
+        }
114
+
115
+        /**
116
+         * Enqueue Function.
117
+         * If this field requires any scripts, or css define this function and register/enqueue the scripts/css
118
+         *
119
+         * @since ReduxFramework 3.0.0
120
+         */
121
+        public function enqueue() {
122
+            wp_enqueue_script(
123
+                'redux-field-spinner-custom',
124
+                Redux_Core::$url . 'inc/fields/spinner/vendor/jquery.ui.spinner' . Redux_Functions::is_min() . '.js',
125
+                array( 'jquery', 'redux-js' ),
126
+                $this->timestamp,
127
+                true
128
+            );
129
+
130
+            wp_enqueue_script(
131
+                'redux-field-spinner',
132
+                Redux_Core::$url . 'inc/fields/spinner/redux-spinner' . Redux_Functions::is_min() . '.js',
133
+                array( 'jquery', 'redux-field-spinner-custom', 'jquery-ui-core', 'jquery-ui-dialog', 'redux-js' ),
134
+                $this->timestamp,
135
+                true
136
+            );
137
+
138
+            if ( $this->parent->args['dev_mode'] ) {
139
+                wp_enqueue_style(
140
+                    'redux-field-spinner',
141
+                    Redux_Core::$url . 'inc/fields/spinner/redux-spinner.css',
142
+                    array(),
143
+                    $this->timestamp
144
+                );
145
+            }
146
+        }
147
+
148
+        /**
149
+         * CSS/compiler output.
150
+         *
151
+         * @param string|null|array $style CSS styles.
152
+         */
153
+        public function output( $style = '' ) {
154
+            if ( ! empty( $this->value ) ) {
155
+                if ( ! empty( $this->field['output'] ) && is_array( $this->field['output'] ) ) {
156
+                    $css                      = $this->parse_css( $this->value, $this->field['output'] );
157
+                    $this->parent->outputCSS .= esc_attr( $css );
158
+                }
159
+
160
+                if ( ! empty( $this->field['compiler'] ) && is_array( $this->field['compiler'] ) ) {
161
+                    $css                        = $this->parse_css( $this->value, $this->field['compiler'] );
162
+                    $this->parent->compilerCSS .= esc_attr( $css );
163
+                }
164
+            }
165
+        }
166
+
167
+        /**
168
+         * Compile CSS data for output.
169
+         *
170
+         * @param mixed $value Value.
171
+         * @param mixed $output .
172
+         *
173
+         * @return string
174
+         */
175
+        private function parse_css( $value, $output ): string {
176
+            // No notices.
177
+            $css = '';
178
+
179
+            $unit = $this->field['output_unit'] ?? 'px';
180
+
181
+            // Must be an array.
182
+            if ( is_array( $output ) ) {
183
+                foreach ( $output as $selector => $mode ) {
184
+                    if ( '' !== $mode && '' !== $selector ) {
185
+                        $css .= $selector . '{' . $mode . ':' . $value . $unit . ';}';
186
+                    }
187
+                }
188
+            }
189
+
190
+            return $css;
191
+        }
192
+
193
+        /**
194
+         * Generate CSS style (unused, but needed).
195
+         *
196
+         * @param string $data Field data.
197
+         *
198
+         * @return string
199
+         */
200
+        public function css_style( $data ): string {
201
+            return '';
202
+        }
203
+
204
+        /**
205
+         * Enable output_variables to be generated.
206
+         *
207
+         * @since       4.0.3
208
+         * @return void
209
+         */
210
+        public function output_variables() {
211
+            // No code needed, just defining the method is enough.
212
+        }
213
+    }
214 214
 }
215 215
 
216 216
 class_alias( 'Redux_Spinner', 'ReduxFramework_Spinner' );
Please login to merge, or discard this patch.
redux-core/inc/fields/radio/class-redux-radio.php 1 patch
Indentation   +36 added lines, -36 removed lines patch added patch discarded remove patch
@@ -12,53 +12,53 @@
 block discarded – undo
12 12
 
13 13
 if ( ! class_exists( 'Redux_Radio', false ) ) {
14 14
 
15
-	/**
16
-	 * Class Redux_Radio
17
-	 */
18
-	class Redux_Radio extends Redux_Field {
15
+    /**
16
+     * Class Redux_Radio
17
+     */
18
+    class Redux_Radio extends Redux_Field {
19 19
 
20
-		/**
21
-		 * Field Render Function.
22
-		 * Takes the vars and outputs the HTML for the field in the settings
23
-		 *
24
-		 * @since ReduxFramework 1.0.0
25
-		 */
26
-		public function render() {
27
-			if ( ! empty( $this->field['data'] ) && empty( $this->field['options'] ) ) {
28
-				if ( empty( $this->field['args'] ) ) {
29
-					$this->field['args'] = array();
30
-				}
20
+        /**
21
+         * Field Render Function.
22
+         * Takes the vars and outputs the HTML for the field in the settings
23
+         *
24
+         * @since ReduxFramework 1.0.0
25
+         */
26
+        public function render() {
27
+            if ( ! empty( $this->field['data'] ) && empty( $this->field['options'] ) ) {
28
+                if ( empty( $this->field['args'] ) ) {
29
+                    $this->field['args'] = array();
30
+                }
31 31
 
32
-				if ( is_array( $this->field['data'] ) ) {
33
-					$this->field['options'] = $this->field['data'];
34
-				} else {
35
-					$this->field['options'] = $this->parent->wordpress_data->get( $this->field['data'], $this->field['args'], $this->parent->args['opt_name'], $this->value );
36
-				}
37
-			}
32
+                if ( is_array( $this->field['data'] ) ) {
33
+                    $this->field['options'] = $this->field['data'];
34
+                } else {
35
+                    $this->field['options'] = $this->parent->wordpress_data->get( $this->field['data'], $this->field['args'], $this->parent->args['opt_name'], $this->value );
36
+                }
37
+            }
38 38
 
39
-			$this->field['data_class'] = ( isset( $this->field['multi_layout'] ) ) ? 'data-' . $this->field['multi_layout'] : 'data-full';
39
+            $this->field['data_class'] = ( isset( $this->field['multi_layout'] ) ) ? 'data-' . $this->field['multi_layout'] : 'data-full';
40 40
 
41
-			if ( isset( $this->field['options'] ) && ! empty( $this->field['options'] ) ) {
42
-				echo '<ul class="' . esc_attr( $this->field['data_class'] ) . '">';
41
+            if ( isset( $this->field['options'] ) && ! empty( $this->field['options'] ) ) {
42
+                echo '<ul class="' . esc_attr( $this->field['data_class'] ) . '">';
43 43
 
44
-				foreach ( $this->field['options'] as $k => $v ) {
45
-					echo '<li>';
46
-					echo '<label for="' . esc_attr( $this->field['id'] . '_' . array_search( $k, array_keys( $this->field['options'] ), true ) ) . '">';
47
-					echo '<input
44
+                foreach ( $this->field['options'] as $k => $v ) {
45
+                    echo '<li>';
46
+                    echo '<label for="' . esc_attr( $this->field['id'] . '_' . array_search( $k, array_keys( $this->field['options'] ), true ) ) . '">';
47
+                    echo '<input
48 48
 							type="radio"
49 49
 							class="radio ' . esc_attr( $this->field['class'] ) . '"
50 50
 							id="' . esc_attr( $this->field['id'] . '_' . array_search( $k, array_keys( $this->field['options'] ), true ) ) . '"
51 51
 							name="' . esc_attr( $this->field['name'] . $this->field['name_suffix'] ) . '"
52 52
 							value="' . esc_attr( $k ) . '" ' . ( ! is_array( $this->value ) ? checked( $this->value, $k, false ) : '' ) . '/>';
53
-					echo ' <span>' . wp_kses_post( $v ) . '</span>';
54
-					echo '</label>';
55
-					echo '</li>';
56
-				}
53
+                    echo ' <span>' . wp_kses_post( $v ) . '</span>';
54
+                    echo '</label>';
55
+                    echo '</li>';
56
+                }
57 57
 
58
-				echo '</ul>';
59
-			}
60
-		}
61
-	}
58
+                echo '</ul>';
59
+            }
60
+        }
61
+    }
62 62
 }
63 63
 
64 64
 class_alias( 'Redux_Radio', 'ReduxFramework_Radio' );
Please login to merge, or discard this patch.
redux-core/inc/fields/text/class-redux-text.php 2 patches
Indentation   +88 added lines, -88 removed lines patch added patch discarded remove patch
@@ -12,94 +12,94 @@
 block discarded – undo
12 12
 
13 13
 if ( ! class_exists( 'Redux_Text', false ) ) {
14 14
 
15
-	/**
16
-	 * Class Redux_Text
17
-	 */
18
-	class Redux_Text extends Redux_Field {
19
-
20
-		/**
21
-		 * Field Render Function.
22
-		 * Takes the vars and outputs the HTML for the field in the settings
23
-		 *
24
-		 * @since ReduxFramework 1.0.0
25
-		 */
26
-		public function render() {
27
-			if ( ! empty( $this->field['data'] ) && empty( $this->field['options'] ) ) {
28
-				if ( empty( $this->field['args'] ) ) {
29
-					$this->field['args'] = array();
30
-				}
31
-
32
-				$this->field['options'] = $this->parent->wordpress_data->get( $this->field['data'], $this->field['args'], $this->parent->args['opt_name'], $this->value );
33
-				$this->field['class']  .= ' hasOptions ';
34
-			}
35
-
36
-			if ( empty( $this->value ) && ! empty( $this->field['data'] ) && ! empty( $this->field['options'] ) ) {
37
-				$this->value = $this->field['options'];
38
-			}
39
-
40
-			$qtip_title = isset( $this->field['text_hint']['title'] ) ? 'qtip-title="' . $this->field['text_hint']['title'] . '" ' : '';
41
-			$qtip_text  = isset( $this->field['text_hint']['content'] ) ? 'qtip-content="' . $this->field['text_hint']['content'] . '" ' : '';
42
-
43
-			$readonly     = ( isset( $this->field['readonly'] ) && $this->field['readonly'] ) ? ' readonly="readonly"' : '';
44
-			$autocomplete = ( isset( $this->field['autocomplete'] ) && false === $this->field['autocomplete'] ) ? ' autocomplete="off"' : '';
45
-
46
-			if ( isset( $this->field['options'] ) && ! empty( $this->field['options'] ) ) {
47
-				$placeholder = '';
48
-
49
-				if ( isset( $this->field['placeholder'] ) ) {
50
-					$placeholder = $this->field['placeholder'];
51
-				}
52
-
53
-				foreach ( $this->field['options'] as $k => $v ) {
54
-					if ( ! empty( $placeholder ) ) {
55
-						$placeholder = ( is_array( $this->field['placeholder'] ) && isset( $this->field['placeholder'][ $k ] ) ) ? ' placeholder="' . esc_attr( $this->field['placeholder'][ $k ] ) . '" ' : '';
56
-					}
57
-
58
-					echo '<div class="input_wrapper">';
59
-					echo '<label for="' . esc_attr( $this->field['id'] . '-text-' . $k ) . '">' . esc_html( $v ) . '</label> ';
60
-
61
-					$value = $this->value[ $k ] ?? '';
62
-					$value = ! empty( $this->value[ $k ] ) ? $this->value[ $k ] : '';
63
-
64
-					// phpcs:ignore WordPress.Security.EscapeOutput
65
-					echo '<input type="text" id="' . esc_attr( $this->field['id'] . '-text-' . $k ) . '" ' . esc_attr( $qtip_title ) . esc_attr( $qtip_text ) . ' name="' . esc_attr( $this->field['name'] . $this->field['name_suffix'] . '[' . esc_attr( $k ) ) . ']" ' . $placeholder . ' value="' . esc_attr( $value ) . '" class="regular-text ' . esc_attr( $this->field['class'] ) . '" ' . esc_html( $readonly ) . esc_html( $autocomplete ) . '/><br />';
66
-					echo '</div>';
67
-				}
68
-			} else {
69
-				$placeholder = ( isset( $this->field['placeholder'] ) && ! is_array( $this->field['placeholder'] ) ) ? ' placeholder="' . esc_attr( $this->field['placeholder'] ) . '" ' : '';
70
-
71
-				// phpcs:ignore WordPress.Security.EscapeOutput
72
-				echo '<input ' . esc_attr( $qtip_title ) . esc_attr( $qtip_text ) . 'type="text" id="' . esc_attr( $this->field['id'] ) . '" name="' . esc_attr( $this->field['name'] . $this->field['name_suffix'] ) . '" ' . $placeholder . 'value="' . esc_attr( $this->value ) . '" class="regular-text ' . esc_attr( $this->field['class'] ) . '"' . esc_html( $readonly ) . esc_html( $autocomplete ) . ' />';
73
-			}
74
-		}
75
-
76
-		/**
77
-		 * Enqueue Function.
78
-		 * If this field requires any scripts, or css define this function and register/enqueue the scripts/css
79
-		 *
80
-		 * @since ReduxFramework 3.0.0
81
-		 */
82
-		public function enqueue() {
83
-			if ( $this->parent->args['dev_mode'] ) {
84
-				wp_enqueue_style(
85
-					'redux-field-text',
86
-					Redux_Core::$url . 'inc/fields/text/redux-text.css',
87
-					array(),
88
-					$this->timestamp
89
-				);
90
-			}
91
-		}
92
-
93
-		/**
94
-		 * Enable output_variables to be generated.
95
-		 *
96
-		 * @since       4.0.3
97
-		 * @return void
98
-		 */
99
-		public function output_variables() {
100
-			// No code needed, just defining the method is enough.
101
-		}
102
-	}
15
+    /**
16
+     * Class Redux_Text
17
+     */
18
+    class Redux_Text extends Redux_Field {
19
+
20
+        /**
21
+         * Field Render Function.
22
+         * Takes the vars and outputs the HTML for the field in the settings
23
+         *
24
+         * @since ReduxFramework 1.0.0
25
+         */
26
+        public function render() {
27
+            if ( ! empty( $this->field['data'] ) && empty( $this->field['options'] ) ) {
28
+                if ( empty( $this->field['args'] ) ) {
29
+                    $this->field['args'] = array();
30
+                }
31
+
32
+                $this->field['options'] = $this->parent->wordpress_data->get( $this->field['data'], $this->field['args'], $this->parent->args['opt_name'], $this->value );
33
+                $this->field['class']  .= ' hasOptions ';
34
+            }
35
+
36
+            if ( empty( $this->value ) && ! empty( $this->field['data'] ) && ! empty( $this->field['options'] ) ) {
37
+                $this->value = $this->field['options'];
38
+            }
39
+
40
+            $qtip_title = isset( $this->field['text_hint']['title'] ) ? 'qtip-title="' . $this->field['text_hint']['title'] . '" ' : '';
41
+            $qtip_text  = isset( $this->field['text_hint']['content'] ) ? 'qtip-content="' . $this->field['text_hint']['content'] . '" ' : '';
42
+
43
+            $readonly     = ( isset( $this->field['readonly'] ) && $this->field['readonly'] ) ? ' readonly="readonly"' : '';
44
+            $autocomplete = ( isset( $this->field['autocomplete'] ) && false === $this->field['autocomplete'] ) ? ' autocomplete="off"' : '';
45
+
46
+            if ( isset( $this->field['options'] ) && ! empty( $this->field['options'] ) ) {
47
+                $placeholder = '';
48
+
49
+                if ( isset( $this->field['placeholder'] ) ) {
50
+                    $placeholder = $this->field['placeholder'];
51
+                }
52
+
53
+                foreach ( $this->field['options'] as $k => $v ) {
54
+                    if ( ! empty( $placeholder ) ) {
55
+                        $placeholder = ( is_array( $this->field['placeholder'] ) && isset( $this->field['placeholder'][ $k ] ) ) ? ' placeholder="' . esc_attr( $this->field['placeholder'][ $k ] ) . '" ' : '';
56
+                    }
57
+
58
+                    echo '<div class="input_wrapper">';
59
+                    echo '<label for="' . esc_attr( $this->field['id'] . '-text-' . $k ) . '">' . esc_html( $v ) . '</label> ';
60
+
61
+                    $value = $this->value[ $k ] ?? '';
62
+                    $value = ! empty( $this->value[ $k ] ) ? $this->value[ $k ] : '';
63
+
64
+                    // phpcs:ignore WordPress.Security.EscapeOutput
65
+                    echo '<input type="text" id="' . esc_attr( $this->field['id'] . '-text-' . $k ) . '" ' . esc_attr( $qtip_title ) . esc_attr( $qtip_text ) . ' name="' . esc_attr( $this->field['name'] . $this->field['name_suffix'] . '[' . esc_attr( $k ) ) . ']" ' . $placeholder . ' value="' . esc_attr( $value ) . '" class="regular-text ' . esc_attr( $this->field['class'] ) . '" ' . esc_html( $readonly ) . esc_html( $autocomplete ) . '/><br />';
66
+                    echo '</div>';
67
+                }
68
+            } else {
69
+                $placeholder = ( isset( $this->field['placeholder'] ) && ! is_array( $this->field['placeholder'] ) ) ? ' placeholder="' . esc_attr( $this->field['placeholder'] ) . '" ' : '';
70
+
71
+                // phpcs:ignore WordPress.Security.EscapeOutput
72
+                echo '<input ' . esc_attr( $qtip_title ) . esc_attr( $qtip_text ) . 'type="text" id="' . esc_attr( $this->field['id'] ) . '" name="' . esc_attr( $this->field['name'] . $this->field['name_suffix'] ) . '" ' . $placeholder . 'value="' . esc_attr( $this->value ) . '" class="regular-text ' . esc_attr( $this->field['class'] ) . '"' . esc_html( $readonly ) . esc_html( $autocomplete ) . ' />';
73
+            }
74
+        }
75
+
76
+        /**
77
+         * Enqueue Function.
78
+         * If this field requires any scripts, or css define this function and register/enqueue the scripts/css
79
+         *
80
+         * @since ReduxFramework 3.0.0
81
+         */
82
+        public function enqueue() {
83
+            if ( $this->parent->args['dev_mode'] ) {
84
+                wp_enqueue_style(
85
+                    'redux-field-text',
86
+                    Redux_Core::$url . 'inc/fields/text/redux-text.css',
87
+                    array(),
88
+                    $this->timestamp
89
+                );
90
+            }
91
+        }
92
+
93
+        /**
94
+         * Enable output_variables to be generated.
95
+         *
96
+         * @since       4.0.3
97
+         * @return void
98
+         */
99
+        public function output_variables() {
100
+            // No code needed, just defining the method is enough.
101
+        }
102
+    }
103 103
 }
104 104
 
105 105
 class_alias( 'Redux_Text', 'ReduxFramework_Text' );
Please login to merge, or discard this patch.
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -52,14 +52,14 @@
 block discarded – undo
52 52
 
53 53
 				foreach ( $this->field['options'] as $k => $v ) {
54 54
 					if ( ! empty( $placeholder ) ) {
55
-						$placeholder = ( is_array( $this->field['placeholder'] ) && isset( $this->field['placeholder'][ $k ] ) ) ? ' placeholder="' . esc_attr( $this->field['placeholder'][ $k ] ) . '" ' : '';
55
+						$placeholder = ( is_array( $this->field['placeholder'] ) && isset( $this->field['placeholder'][$k] ) ) ? ' placeholder="' . esc_attr( $this->field['placeholder'][$k] ) . '" ' : '';
56 56
 					}
57 57
 
58 58
 					echo '<div class="input_wrapper">';
59 59
 					echo '<label for="' . esc_attr( $this->field['id'] . '-text-' . $k ) . '">' . esc_html( $v ) . '</label> ';
60 60
 
61
-					$value = $this->value[ $k ] ?? '';
62
-					$value = ! empty( $this->value[ $k ] ) ? $this->value[ $k ] : '';
61
+					$value = $this->value[$k] ?? '';
62
+					$value = ! empty( $this->value[$k] ) ? $this->value[$k] : '';
63 63
 
64 64
 					// phpcs:ignore WordPress.Security.EscapeOutput
65 65
 					echo '<input type="text" id="' . esc_attr( $this->field['id'] . '-text-' . $k ) . '" ' . esc_attr( $qtip_title ) . esc_attr( $qtip_text ) . ' name="' . esc_attr( $this->field['name'] . $this->field['name_suffix'] . '[' . esc_attr( $k ) ) . ']" ' . $placeholder . ' value="' . esc_attr( $value ) . '" class="regular-text ' . esc_attr( $this->field['class'] ) . '" ' . esc_html( $readonly ) . esc_html( $autocomplete ) . '/><br />';
Please login to merge, or discard this patch.
redux-templates/classes/class-init.php 1 patch
Indentation   +30 added lines, -30 removed lines patch added patch discarded remove patch
@@ -19,36 +19,36 @@
 block discarded – undo
19 19
  */
20 20
 class Init {
21 21
 
22
-	/**
23
-	 * Init constructor.
24
-	 *
25
-	 * @access public
26
-	 */
27
-	public function __construct() {
28
-		global $pagenow;
29
-
30
-		if ( 'widgets.php' === $pagenow ) {
31
-			return;
32
-		}
33
-
34
-		require_once REDUXTEMPLATES_DIR_PATH . 'classes/class-templates.php';
35
-
36
-		add_action( 'init', array( $this, 'load' ) );
37
-
38
-		if ( did_action( 'init' ) ) { // In case the devs load it at the wrong place.
39
-			$this->load();
40
-		}
41
-	}
42
-
43
-	/**
44
-	 * Load everything up after init.
45
-	 *
46
-	 * @access public
47
-	 * @since 4.0.0
48
-	 */
49
-	public static function load() {
50
-		new ReduxTemplates\Templates();
51
-	}
22
+    /**
23
+     * Init constructor.
24
+     *
25
+     * @access public
26
+     */
27
+    public function __construct() {
28
+        global $pagenow;
29
+
30
+        if ( 'widgets.php' === $pagenow ) {
31
+            return;
32
+        }
33
+
34
+        require_once REDUXTEMPLATES_DIR_PATH . 'classes/class-templates.php';
35
+
36
+        add_action( 'init', array( $this, 'load' ) );
37
+
38
+        if ( did_action( 'init' ) ) { // In case the devs load it at the wrong place.
39
+            $this->load();
40
+        }
41
+    }
42
+
43
+    /**
44
+     * Load everything up after init.
45
+     *
46
+     * @access public
47
+     * @since 4.0.0
48
+     */
49
+    public static function load() {
50
+        new ReduxTemplates\Templates();
51
+    }
52 52
 }
53 53
 
54 54
 new Init();
Please login to merge, or discard this patch.
redux-core/inc/fields/textarea/class-redux-textarea.php 1 patch
Indentation   +33 added lines, -33 removed lines patch added patch discarded remove patch
@@ -11,37 +11,37 @@  discard block
 block discarded – undo
11 11
 
12 12
 if ( ! class_exists( 'Redux_Textarea', false ) ) {
13 13
 
14
-	/**
15
-	 * Class Redux_Textarea
16
-	 */
17
-	class Redux_Textarea extends Redux_Field {
18
-
19
-		/**
20
-		 * Set field and value defaults.
21
-		 */
22
-		public function set_defaults() {
23
-			$defaults = array(
24
-				'placeholder'  => '',
25
-				'rows'         => 6,
26
-				'autocomplete' => false,
27
-				'readonly'     => false,
28
-				'class'        => '',
29
-			);
30
-
31
-			$this->field = wp_parse_args( $this->field, $defaults );
32
-		}
33
-
34
-		/**
35
-		 * Field Render Function.
36
-		 * Takes the vars and outputs the HTML for the field in the settings
37
-		 *
38
-		 * @since ReduxFramework 1.0.0
39
-		 * */
40
-		public function render() {
41
-			$readonly     = ( true === boolval( $this->field['readonly'] ) ) ? ' readonly' : '';
42
-			$autocomplete = ( true === boolval( $this->field['autocomplete'] ) ) ? 'on' : 'off';
43
-
44
-			?>
14
+    /**
15
+     * Class Redux_Textarea
16
+     */
17
+    class Redux_Textarea extends Redux_Field {
18
+
19
+        /**
20
+         * Set field and value defaults.
21
+         */
22
+        public function set_defaults() {
23
+            $defaults = array(
24
+                'placeholder'  => '',
25
+                'rows'         => 6,
26
+                'autocomplete' => false,
27
+                'readonly'     => false,
28
+                'class'        => '',
29
+            );
30
+
31
+            $this->field = wp_parse_args( $this->field, $defaults );
32
+        }
33
+
34
+        /**
35
+         * Field Render Function.
36
+         * Takes the vars and outputs the HTML for the field in the settings
37
+         *
38
+         * @since ReduxFramework 1.0.0
39
+         * */
40
+        public function render() {
41
+            $readonly     = ( true === boolval( $this->field['readonly'] ) ) ? ' readonly' : '';
42
+            $autocomplete = ( true === boolval( $this->field['autocomplete'] ) ) ? 'on' : 'off';
43
+
44
+            ?>
45 45
 			<label for="<?php echo esc_attr( $this->field['id'] ); ?>-textarea"></label>
46 46
 			<textarea <?php echo esc_html( $readonly ); ?>
47 47
 					name="<?php echo esc_attr( $this->field['name'] . $this->field['name_suffix'] ); ?>"
@@ -51,8 +51,8 @@  discard block
 block discarded – undo
51 51
 					class="large-text <?php echo esc_attr( $this->field['class'] ); ?>"
52 52
 					rows="<?php echo esc_attr( $this->field['rows'] ); ?>"><?php echo esc_textarea( $this->value ); ?></textarea>
53 53
 			<?php
54
-		}
55
-	}
54
+        }
55
+    }
56 56
 }
57 57
 
58 58
 class_alias( 'Redux_Textarea', 'ReduxFramework_Textarea' );
Please login to merge, or discard this patch.
redux-core/inc/classes/class-redux-panel.php 1 patch
Indentation   +406 added lines, -406 removed lines patch added patch discarded remove patch
@@ -12,396 +12,396 @@  discard block
 block discarded – undo
12 12
 
13 13
 if ( ! class_exists( 'Redux_Panel', false ) ) {
14 14
 
15
-	/**
16
-	 * Class Redux_Panel
17
-	 */
18
-	class Redux_Panel {
19
-
20
-		/**
21
-		 * ReduxFramework object pointer.
22
-		 *
23
-		 * @var object
24
-		 */
25
-		public $parent = null;
26
-
27
-		/**
28
-		 * Path to templates dir.
29
-		 *
30
-		 * @var null|string
31
-		 */
32
-		public $template_path = null;
33
-
34
-		/**
35
-		 * Original template path.
36
-		 *
37
-		 * @var null
38
-		 */
39
-		public $original_path = null;
40
-
41
-		/**
42
-		 * Sets the path from the arg or via filter. Also calls the panel template function.
43
-		 *
44
-		 * @param object $redux ReduxFramework pointer.
45
-		 */
46
-		public function __construct( $redux ) {
47
-			$this->parent        = $redux;
48
-			$this->template_path = Redux_Core::$dir . 'templates/panel/';
49
-			$this->original_path = Redux_Core::$dir . 'templates/panel/';
50
-
51
-			if ( ! empty( $this->parent->args['templates_path'] ) ) {
52
-				$this->template_path = trailingslashit( $this->parent->args['templates_path'] );
53
-			}
54
-
55
-			// phpcs:ignore WordPress.NamingConventions.ValidHookName
56
-			$this->template_path = trailingslashit( apply_filters( "redux/{$this->parent->args['opt_name']}/panel/templates_path", $this->template_path ) );
57
-		}
58
-
59
-		/**
60
-		 * Class init.
61
-		 */
62
-		public function init() {
63
-			$this->panel_template();
64
-		}
65
-
66
-		/**
67
-		 * Loads the panel templates where needed and provides the container for Redux
68
-		 */
69
-		private function panel_template() {
70
-			if ( $this->parent->args['dev_mode'] ) {
71
-				$this->template_file_check_notice();
72
-			}
73
-
74
-			/**
75
-			 * Action 'redux/{opt_name}/panel/before'
76
-			 */
77
-
78
-			// phpcs:ignore WordPress.NamingConventions.ValidHookName
79
-			do_action( "redux/{$this->parent->args['opt_name']}/panel/before" );
80
-
81
-			echo '<div class="wrap"><h2></h2></div>'; // Stupid hack for WordPress alerts and warnings.
82
-
83
-			echo '<div class="clear"></div>';
84
-			echo '<div class="wrap redux-wrap-div" data-opt-name="' . esc_attr( $this->parent->args['opt_name'] ) . '">';
85
-
86
-			// Do we support JS?
87
-			echo '<noscript><div class="no-js">' . esc_html__( 'Warning- This options panel will not work properly without javascript!', 'redux-framework' ) . '</div></noscript>';
88
-
89
-			// Security is vital!
90
-			echo '<input type="hidden" class="redux-ajax-security" data-opt-name="' . esc_attr( $this->parent->args['opt_name'] ) . '" id="ajaxsecurity" name="security" value="' . esc_attr( wp_create_nonce( 'redux_ajax_nonce' . $this->parent->args['opt_name'] ) ) . '" />';
91
-
92
-			/**
93
-			 * Action 'redux/page/{opt_name}/form/before'
94
-			 *
95
-			 * @param object $this ReduxFramework
96
-			 */
97
-
98
-			// phpcs:ignore WordPress.NamingConventions.ValidHookName
99
-			do_action( "redux/page/{$this->parent->args['opt_name']}/form/before", $this );
100
-
101
-			if ( is_rtl() ) {
102
-				$this->parent->args['class'] = ' redux-rtl';
103
-			}
104
-
105
-			$this->get_template( 'container.tpl.php' );
106
-
107
-			/**
108
-			 * Action 'redux/page/{opt_name}/form/after'
109
-			 *
110
-			 * @param object $this ReduxFramework
111
-			 */
112
-
113
-			// phpcs:ignore WordPress.NamingConventions.ValidHookName
114
-			do_action( "redux/page/{$this->parent->args['opt_name']}/form/after", $this );
115
-
116
-			echo '<div class="clear"></div>';
117
-			echo '</div>';
118
-
119
-			if ( true === $this->parent->args['dev_mode'] ) {
120
-				echo '<br /><div class="redux-timer">' . esc_html( get_num_queries() ) . ' queries in ' . esc_html( timer_stop() ) . ' seconds<br/>Redux is currently set to developer mode.</div>';
121
-			}
122
-
123
-			/**
124
-			 * Action 'redux/{opt_name}/panel/after'
125
-			 */
126
-
127
-			// phpcs:ignore WordPress.NamingConventions.ValidHookName
128
-			do_action( "redux/{$this->parent->args['opt_name']}/panel/after" );
129
-		}
130
-
131
-		/**
132
-		 * Calls the various notification bars and sets the appropriate templates.
133
-		 */
134
-		public function notification_bar() {
135
-			if ( isset( $this->parent->transients['last_save_mode'] ) ) {
136
-
137
-				if ( 'import' === $this->parent->transients['last_save_mode'] ) {
138
-					/**
139
-					 * Action 'redux/options/{opt_name}/import'
140
-					 *
141
-					 * @param object $this ReduxFramework
142
-					 */
143
-
144
-					// phpcs:ignore WordPress.NamingConventions.ValidHookName
145
-					do_action( "redux/options/{$this->parent->args['opt_name']}/import", $this, $this->parent->transients['changed_values'] );
146
-
147
-					echo '<div class="admin-notice notice-blue saved_notice">';
148
-
149
-					/**
150
-					 * Filter 'redux-imported-text-{opt_name}'
151
-					 *
152
-					 * @param string $text Translated "settings imported" text.
153
-					 */
154
-
155
-					// phpcs:ignore WordPress.NamingConventions.ValidHookName
156
-					echo '<strong>' . esc_html( apply_filters( "redux-imported-text-{$this->parent->args['opt_name']}", esc_html__( 'Settings Imported!', 'redux-framework' ) ) ) . '</strong>';
157
-					echo '</div>';
158
-				} elseif ( 'defaults' === $this->parent->transients['last_save_mode'] ) {
159
-					/**
160
-					 * Action 'redux/options/{opt_name}/reset'
161
-					 *
162
-					 * @param object $this ReduxFramework
163
-					 */
164
-
165
-					// phpcs:ignore WordPress.NamingConventions.ValidHookName
166
-					do_action( "redux/options/{$this->parent->args['opt_name']}/reset", $this );
167
-
168
-					echo '<div class="saved_notice admin-notice notice-yellow">';
169
-
170
-					/**
171
-					 * Filter 'redux-defaults-text-{opt_name}'
172
-					 *
173
-					 * @param string $text Translated "settings imported" text.
174
-					 */
175
-
176
-					// phpcs:ignore WordPress.NamingConventions.ValidHookName
177
-					echo '<strong>' . esc_html( apply_filters( "redux-defaults-text-{$this->parent->args['opt_name']}", esc_html__( 'All Defaults Restored!', 'redux-framework' ) ) ) . '</strong>';
178
-					echo '</div>';
179
-				} elseif ( 'defaults_section' === $this->parent->transients['last_save_mode'] ) {
180
-					/**
181
-					 * Action 'redux/options/{opt_name}/section/reset'
182
-					 *
183
-					 * @param object $this ReduxFramework
184
-					 */
185
-
186
-					// phpcs:ignore WordPress.NamingConventions.ValidHookName
187
-					do_action( "redux/options/{$this->parent->args['opt_name']}/section/reset", $this );
188
-
189
-					echo '<div class="saved_notice admin-notice notice-yellow">';
190
-
191
-					/**
192
-					 * Filter 'redux-defaults-section-text-{opt_name}'
193
-					 *
194
-					 * @param string $text Translated "settings imported" text.
195
-					 */
196
-
197
-					// phpcs:ignore WordPress.NamingConventions.ValidHookName
198
-					echo '<strong>' . esc_html( apply_filters( "redux-defaults-section-text-{$this->parent->args['opt_name']}", esc_html__( 'Section Defaults Restored!', 'redux-framework' ) ) ) . '</strong>';
199
-					echo '</div>';
200
-				} elseif ( 'normal' === $this->parent->transients['last_save_mode'] ) {
201
-					/**
202
-					 * Action 'redux/options/{opt_name}/saved'
203
-					 *
204
-					 * @param mixed $value set/saved option value
205
-					 */
206
-
207
-					// phpcs:ignore WordPress.NamingConventions.ValidHookName
208
-					do_action( "redux/options/{$this->parent->args['opt_name']}/saved", $this->parent->options, $this->parent->transients['changed_values'] );
209
-
210
-					echo '<div class="saved_notice admin-notice notice-green">';
211
-
212
-					/**
213
-					 * Filter 'redux-saved-text-{opt_name}'
214
-					 *
215
-					 * @param string $text Translated "settings saved" text.
216
-					 */
217
-
218
-					// phpcs:ignore WordPress.NamingConventions.ValidHookName
219
-					echo '<strong>' . esc_html( apply_filters( "redux-saved-text-{$this->parent->args['opt_name']}", esc_html__( 'Settings Saved!', 'redux-framework' ) ) ) . '</strong>';
220
-					echo '</div>';
221
-				}
222
-
223
-				unset( $this->parent->transients['last_save_mode'] );
224
-
225
-				$this->parent->transient_class->set();
226
-			}
227
-
228
-			/**
229
-			 * Action 'redux/options/{opt_name}/settings/changes'
230
-			 *
231
-			 * @param mixed $value set/saved option value
232
-			 */
233
-
234
-			// phpcs:ignore WordPress.NamingConventions.ValidHookName
235
-			do_action( "redux/options/{$this->parent->args['opt_name']}/settings/change", $this->parent->options, $this->parent->transients['changed_values'] );
236
-
237
-			echo '<div class="redux-save-warn notice-yellow">';
238
-
239
-			/**
240
-			 * Filter 'redux-changed-text-{opt_name}'
241
-			 *
242
-			 * @param string $text Translated "settings have changed" text.
243
-			 */
244
-
245
-			// phpcs:ignore WordPress.NamingConventions.ValidHookName
246
-			echo '<strong>' . esc_html( apply_filters( "redux-changed-text-{$this->parent->args['opt_name']}", esc_html__( 'Settings have changed, you should save them!', 'redux-framework' ) ) ) . '</strong>';
247
-			echo '</div>';
248
-
249
-			/**
250
-			 * Action 'redux/options/{opt_name}/errors'
251
-			 *
252
-			 * @param array $this ->errors error information
253
-			 */
254
-
255
-			// phpcs:ignore WordPress.NamingConventions.ValidHookName
256
-			do_action( "redux/options/{$this->parent->args['opt_name']}/errors", $this->parent->errors );
257
-
258
-			echo '<div class="redux-field-errors notice-red">';
259
-			echo '<strong>';
260
-			echo '<span></span> ' . esc_html__( 'error(s) were found!', 'redux-framework' );
261
-			echo '</strong>';
262
-			echo '</div>';
263
-
264
-			/**
265
-			 * Action 'redux/options/{opt_name}/warnings'
266
-			 *
267
-			 * @param array $this ->warnings warning information
268
-			 */
269
-
270
-			// phpcs:ignore WordPress.NamingConventions.ValidHookName
271
-			do_action( "redux/options/{$this->parent->args['opt_name']}/warnings", $this->parent->warnings );
272
-
273
-			echo '<div class="redux-field-warnings notice-yellow">';
274
-			echo '<strong>';
275
-			echo '<span></span> ' . esc_html__( 'warning(s) were found!', 'redux-framework' );
276
-			echo '</strong>';
277
-			echo '</div>';
278
-		}
279
-
280
-		/**
281
-		 * Used to initialize the settings fields for this panel. Required for saving and redirect.
282
-		 */
283
-		private function init_settings_fields() {
284
-			// Must run or the page won't redirect properly.
285
-			settings_fields( "{$this->parent->args['opt_name']}_group" );
286
-		}
287
-
288
-		/**
289
-		 * Enable file deprecate warning from core.  This is necessary because the function is considered private.
290
-		 *
291
-		 * @return bool
292
-		 */
293
-		public function tick_file_deprecate_warning(): bool {
294
-			return true;
295
-		}
296
-
297
-		/**
298
-		 * Used to select the proper template. If it doesn't exist in the path, then the original template file is used.
299
-		 *
300
-		 * @param string $file Path to template file.
301
-		 */
302
-		public function get_template( string $file ) {
303
-			if ( empty( $file ) ) {
304
-				return;
305
-			}
306
-
307
-			if ( file_exists( $this->template_path . $file ) ) {
308
-				$path = $this->template_path . $file;
309
-			} else {
310
-				$path = $this->original_path . $file;
311
-			}
312
-
313
-			// Shim for v3 templates.
314
-			if ( ! file_exists( $path ) ) {
315
-				$old_file = $file;
316
-
317
-				add_filter( 'deprecated_file_trigger_error', array( $this, 'tick_file_deprecate_warning' ) );
318
-
319
-				$file = str_replace( '_', '-', $file );
320
-
321
-				_deprecated_file( esc_html( $old_file ), '4.0', esc_html( $file ), 'Please replace this outdated template with the current one from the Redux core.' );
322
-
323
-				if ( file_exists( $this->template_path . $file ) ) {
324
-					$path = $this->template_path . $file;
325
-				} else {
326
-					$path = $this->original_path . $file;
327
-				}
328
-			}
329
-
330
-			// phpcs:ignore WordPress.NamingConventions.ValidHookName
331
-			do_action( "redux/{$this->parent->args['opt_name']}/panel/template/" . $file . '/before' );
332
-
333
-			// phpcs:ignore WordPress.NamingConventions.ValidHookName
334
-			$path = apply_filters( "redux/{$this->parent->args['opt_name']}/panel/template/" . $file, $path );
335
-
336
-			// phpcs:ignore WordPress.NamingConventions.ValidHookName
337
-			do_action( "redux/{$this->parent->args['opt_name']}/panel/template/" . $file . '/after' );
338
-
339
-			if ( file_exists( $path ) ) {
340
-				if ( is_readable( $path ) ) {
341
-					require $path;
342
-				} else {
343
-					// translators: %1$s: template path.
344
-					echo '<div class="error"><p>' . sprintf( esc_html__( 'Redux Panel Template %1$s cannot be read. Please check the permissions for this file.', 'redux-framework' ), '<code>' . esc_html( $path ) . '</code>' ) . '</p></div>';
345
-				}
346
-			} elseif ( file_exists( Redux_Core::$dir . 'templates/panel/' . $file ) ) {
347
-					require Redux_Core::$dir . 'templates/panel/' . $file;
348
-			} else {
349
-				// translators: %1$s: template path.
350
-				echo '<div class="error"><p>' . sprintf( esc_html__( 'Redux Panel Template %1$s does not exist. Please reinstall Redux to replace this file.', 'redux-framework' ), '<code>' . esc_html( $path ) . '</code>' ) . '</p></div>';
351
-			}
352
-		}
353
-
354
-		/**
355
-		 * Scan the template files.
356
-		 *
357
-		 * @param string $template_path Path to template file.
358
-		 *
359
-		 * @return array
360
-		 */
361
-		public function scan_template_files( string $template_path ): array {
362
-			$files  = scandir( $template_path );
363
-			$result = array();
364
-			if ( $files ) {
365
-				foreach ( $files as $value ) {
366
-					if ( ! in_array( $value, array( '.', '..' ), true ) ) {
367
-						if ( is_dir( $template_path . DIRECTORY_SEPARATOR . $value ) ) {
368
-							$sub_files = self::scan_template_files( $template_path . DIRECTORY_SEPARATOR . $value );
369
-							foreach ( $sub_files as $sub_file ) {
370
-								$result[] = $value . DIRECTORY_SEPARATOR . $sub_file;
371
-							}
372
-						} else {
373
-							$result[] = $value;
374
-						}
375
-					}
376
-				}
377
-			}
378
-
379
-			return $result;
380
-		}
381
-
382
-		/**
383
-		 * Show a notice highlighting bad template files
384
-		 */
385
-		public function template_file_check_notice() {
386
-			if ( $this->original_path === $this->template_path ) {
387
-				return;
388
-			}
389
-
390
-			$core_templates = $this->scan_template_files( $this->original_path );
391
-
392
-			foreach ( $core_templates as $file ) {
393
-				$developer_theme_file = false;
394
-
395
-				if ( file_exists( $this->template_path . $file ) ) {
396
-					$developer_theme_file = $this->template_path . $file;
397
-				}
398
-
399
-				if ( $developer_theme_file ) {
400
-					$core_version      = Redux_Helpers::get_template_version( $this->original_path . $file );
401
-					$developer_version = Redux_Helpers::get_template_version( $developer_theme_file );
402
-
403
-					if ( $core_version && $developer_version && version_compare( $developer_version, $core_version, '<' ) ) {
404
-						?>
15
+    /**
16
+     * Class Redux_Panel
17
+     */
18
+    class Redux_Panel {
19
+
20
+        /**
21
+         * ReduxFramework object pointer.
22
+         *
23
+         * @var object
24
+         */
25
+        public $parent = null;
26
+
27
+        /**
28
+         * Path to templates dir.
29
+         *
30
+         * @var null|string
31
+         */
32
+        public $template_path = null;
33
+
34
+        /**
35
+         * Original template path.
36
+         *
37
+         * @var null
38
+         */
39
+        public $original_path = null;
40
+
41
+        /**
42
+         * Sets the path from the arg or via filter. Also calls the panel template function.
43
+         *
44
+         * @param object $redux ReduxFramework pointer.
45
+         */
46
+        public function __construct( $redux ) {
47
+            $this->parent        = $redux;
48
+            $this->template_path = Redux_Core::$dir . 'templates/panel/';
49
+            $this->original_path = Redux_Core::$dir . 'templates/panel/';
50
+
51
+            if ( ! empty( $this->parent->args['templates_path'] ) ) {
52
+                $this->template_path = trailingslashit( $this->parent->args['templates_path'] );
53
+            }
54
+
55
+            // phpcs:ignore WordPress.NamingConventions.ValidHookName
56
+            $this->template_path = trailingslashit( apply_filters( "redux/{$this->parent->args['opt_name']}/panel/templates_path", $this->template_path ) );
57
+        }
58
+
59
+        /**
60
+         * Class init.
61
+         */
62
+        public function init() {
63
+            $this->panel_template();
64
+        }
65
+
66
+        /**
67
+         * Loads the panel templates where needed and provides the container for Redux
68
+         */
69
+        private function panel_template() {
70
+            if ( $this->parent->args['dev_mode'] ) {
71
+                $this->template_file_check_notice();
72
+            }
73
+
74
+            /**
75
+             * Action 'redux/{opt_name}/panel/before'
76
+             */
77
+
78
+            // phpcs:ignore WordPress.NamingConventions.ValidHookName
79
+            do_action( "redux/{$this->parent->args['opt_name']}/panel/before" );
80
+
81
+            echo '<div class="wrap"><h2></h2></div>'; // Stupid hack for WordPress alerts and warnings.
82
+
83
+            echo '<div class="clear"></div>';
84
+            echo '<div class="wrap redux-wrap-div" data-opt-name="' . esc_attr( $this->parent->args['opt_name'] ) . '">';
85
+
86
+            // Do we support JS?
87
+            echo '<noscript><div class="no-js">' . esc_html__( 'Warning- This options panel will not work properly without javascript!', 'redux-framework' ) . '</div></noscript>';
88
+
89
+            // Security is vital!
90
+            echo '<input type="hidden" class="redux-ajax-security" data-opt-name="' . esc_attr( $this->parent->args['opt_name'] ) . '" id="ajaxsecurity" name="security" value="' . esc_attr( wp_create_nonce( 'redux_ajax_nonce' . $this->parent->args['opt_name'] ) ) . '" />';
91
+
92
+            /**
93
+             * Action 'redux/page/{opt_name}/form/before'
94
+             *
95
+             * @param object $this ReduxFramework
96
+             */
97
+
98
+            // phpcs:ignore WordPress.NamingConventions.ValidHookName
99
+            do_action( "redux/page/{$this->parent->args['opt_name']}/form/before", $this );
100
+
101
+            if ( is_rtl() ) {
102
+                $this->parent->args['class'] = ' redux-rtl';
103
+            }
104
+
105
+            $this->get_template( 'container.tpl.php' );
106
+
107
+            /**
108
+             * Action 'redux/page/{opt_name}/form/after'
109
+             *
110
+             * @param object $this ReduxFramework
111
+             */
112
+
113
+            // phpcs:ignore WordPress.NamingConventions.ValidHookName
114
+            do_action( "redux/page/{$this->parent->args['opt_name']}/form/after", $this );
115
+
116
+            echo '<div class="clear"></div>';
117
+            echo '</div>';
118
+
119
+            if ( true === $this->parent->args['dev_mode'] ) {
120
+                echo '<br /><div class="redux-timer">' . esc_html( get_num_queries() ) . ' queries in ' . esc_html( timer_stop() ) . ' seconds<br/>Redux is currently set to developer mode.</div>';
121
+            }
122
+
123
+            /**
124
+             * Action 'redux/{opt_name}/panel/after'
125
+             */
126
+
127
+            // phpcs:ignore WordPress.NamingConventions.ValidHookName
128
+            do_action( "redux/{$this->parent->args['opt_name']}/panel/after" );
129
+        }
130
+
131
+        /**
132
+         * Calls the various notification bars and sets the appropriate templates.
133
+         */
134
+        public function notification_bar() {
135
+            if ( isset( $this->parent->transients['last_save_mode'] ) ) {
136
+
137
+                if ( 'import' === $this->parent->transients['last_save_mode'] ) {
138
+                    /**
139
+                     * Action 'redux/options/{opt_name}/import'
140
+                     *
141
+                     * @param object $this ReduxFramework
142
+                     */
143
+
144
+                    // phpcs:ignore WordPress.NamingConventions.ValidHookName
145
+                    do_action( "redux/options/{$this->parent->args['opt_name']}/import", $this, $this->parent->transients['changed_values'] );
146
+
147
+                    echo '<div class="admin-notice notice-blue saved_notice">';
148
+
149
+                    /**
150
+                     * Filter 'redux-imported-text-{opt_name}'
151
+                     *
152
+                     * @param string $text Translated "settings imported" text.
153
+                     */
154
+
155
+                    // phpcs:ignore WordPress.NamingConventions.ValidHookName
156
+                    echo '<strong>' . esc_html( apply_filters( "redux-imported-text-{$this->parent->args['opt_name']}", esc_html__( 'Settings Imported!', 'redux-framework' ) ) ) . '</strong>';
157
+                    echo '</div>';
158
+                } elseif ( 'defaults' === $this->parent->transients['last_save_mode'] ) {
159
+                    /**
160
+                     * Action 'redux/options/{opt_name}/reset'
161
+                     *
162
+                     * @param object $this ReduxFramework
163
+                     */
164
+
165
+                    // phpcs:ignore WordPress.NamingConventions.ValidHookName
166
+                    do_action( "redux/options/{$this->parent->args['opt_name']}/reset", $this );
167
+
168
+                    echo '<div class="saved_notice admin-notice notice-yellow">';
169
+
170
+                    /**
171
+                     * Filter 'redux-defaults-text-{opt_name}'
172
+                     *
173
+                     * @param string $text Translated "settings imported" text.
174
+                     */
175
+
176
+                    // phpcs:ignore WordPress.NamingConventions.ValidHookName
177
+                    echo '<strong>' . esc_html( apply_filters( "redux-defaults-text-{$this->parent->args['opt_name']}", esc_html__( 'All Defaults Restored!', 'redux-framework' ) ) ) . '</strong>';
178
+                    echo '</div>';
179
+                } elseif ( 'defaults_section' === $this->parent->transients['last_save_mode'] ) {
180
+                    /**
181
+                     * Action 'redux/options/{opt_name}/section/reset'
182
+                     *
183
+                     * @param object $this ReduxFramework
184
+                     */
185
+
186
+                    // phpcs:ignore WordPress.NamingConventions.ValidHookName
187
+                    do_action( "redux/options/{$this->parent->args['opt_name']}/section/reset", $this );
188
+
189
+                    echo '<div class="saved_notice admin-notice notice-yellow">';
190
+
191
+                    /**
192
+                     * Filter 'redux-defaults-section-text-{opt_name}'
193
+                     *
194
+                     * @param string $text Translated "settings imported" text.
195
+                     */
196
+
197
+                    // phpcs:ignore WordPress.NamingConventions.ValidHookName
198
+                    echo '<strong>' . esc_html( apply_filters( "redux-defaults-section-text-{$this->parent->args['opt_name']}", esc_html__( 'Section Defaults Restored!', 'redux-framework' ) ) ) . '</strong>';
199
+                    echo '</div>';
200
+                } elseif ( 'normal' === $this->parent->transients['last_save_mode'] ) {
201
+                    /**
202
+                     * Action 'redux/options/{opt_name}/saved'
203
+                     *
204
+                     * @param mixed $value set/saved option value
205
+                     */
206
+
207
+                    // phpcs:ignore WordPress.NamingConventions.ValidHookName
208
+                    do_action( "redux/options/{$this->parent->args['opt_name']}/saved", $this->parent->options, $this->parent->transients['changed_values'] );
209
+
210
+                    echo '<div class="saved_notice admin-notice notice-green">';
211
+
212
+                    /**
213
+                     * Filter 'redux-saved-text-{opt_name}'
214
+                     *
215
+                     * @param string $text Translated "settings saved" text.
216
+                     */
217
+
218
+                    // phpcs:ignore WordPress.NamingConventions.ValidHookName
219
+                    echo '<strong>' . esc_html( apply_filters( "redux-saved-text-{$this->parent->args['opt_name']}", esc_html__( 'Settings Saved!', 'redux-framework' ) ) ) . '</strong>';
220
+                    echo '</div>';
221
+                }
222
+
223
+                unset( $this->parent->transients['last_save_mode'] );
224
+
225
+                $this->parent->transient_class->set();
226
+            }
227
+
228
+            /**
229
+             * Action 'redux/options/{opt_name}/settings/changes'
230
+             *
231
+             * @param mixed $value set/saved option value
232
+             */
233
+
234
+            // phpcs:ignore WordPress.NamingConventions.ValidHookName
235
+            do_action( "redux/options/{$this->parent->args['opt_name']}/settings/change", $this->parent->options, $this->parent->transients['changed_values'] );
236
+
237
+            echo '<div class="redux-save-warn notice-yellow">';
238
+
239
+            /**
240
+             * Filter 'redux-changed-text-{opt_name}'
241
+             *
242
+             * @param string $text Translated "settings have changed" text.
243
+             */
244
+
245
+            // phpcs:ignore WordPress.NamingConventions.ValidHookName
246
+            echo '<strong>' . esc_html( apply_filters( "redux-changed-text-{$this->parent->args['opt_name']}", esc_html__( 'Settings have changed, you should save them!', 'redux-framework' ) ) ) . '</strong>';
247
+            echo '</div>';
248
+
249
+            /**
250
+             * Action 'redux/options/{opt_name}/errors'
251
+             *
252
+             * @param array $this ->errors error information
253
+             */
254
+
255
+            // phpcs:ignore WordPress.NamingConventions.ValidHookName
256
+            do_action( "redux/options/{$this->parent->args['opt_name']}/errors", $this->parent->errors );
257
+
258
+            echo '<div class="redux-field-errors notice-red">';
259
+            echo '<strong>';
260
+            echo '<span></span> ' . esc_html__( 'error(s) were found!', 'redux-framework' );
261
+            echo '</strong>';
262
+            echo '</div>';
263
+
264
+            /**
265
+             * Action 'redux/options/{opt_name}/warnings'
266
+             *
267
+             * @param array $this ->warnings warning information
268
+             */
269
+
270
+            // phpcs:ignore WordPress.NamingConventions.ValidHookName
271
+            do_action( "redux/options/{$this->parent->args['opt_name']}/warnings", $this->parent->warnings );
272
+
273
+            echo '<div class="redux-field-warnings notice-yellow">';
274
+            echo '<strong>';
275
+            echo '<span></span> ' . esc_html__( 'warning(s) were found!', 'redux-framework' );
276
+            echo '</strong>';
277
+            echo '</div>';
278
+        }
279
+
280
+        /**
281
+         * Used to initialize the settings fields for this panel. Required for saving and redirect.
282
+         */
283
+        private function init_settings_fields() {
284
+            // Must run or the page won't redirect properly.
285
+            settings_fields( "{$this->parent->args['opt_name']}_group" );
286
+        }
287
+
288
+        /**
289
+         * Enable file deprecate warning from core.  This is necessary because the function is considered private.
290
+         *
291
+         * @return bool
292
+         */
293
+        public function tick_file_deprecate_warning(): bool {
294
+            return true;
295
+        }
296
+
297
+        /**
298
+         * Used to select the proper template. If it doesn't exist in the path, then the original template file is used.
299
+         *
300
+         * @param string $file Path to template file.
301
+         */
302
+        public function get_template( string $file ) {
303
+            if ( empty( $file ) ) {
304
+                return;
305
+            }
306
+
307
+            if ( file_exists( $this->template_path . $file ) ) {
308
+                $path = $this->template_path . $file;
309
+            } else {
310
+                $path = $this->original_path . $file;
311
+            }
312
+
313
+            // Shim for v3 templates.
314
+            if ( ! file_exists( $path ) ) {
315
+                $old_file = $file;
316
+
317
+                add_filter( 'deprecated_file_trigger_error', array( $this, 'tick_file_deprecate_warning' ) );
318
+
319
+                $file = str_replace( '_', '-', $file );
320
+
321
+                _deprecated_file( esc_html( $old_file ), '4.0', esc_html( $file ), 'Please replace this outdated template with the current one from the Redux core.' );
322
+
323
+                if ( file_exists( $this->template_path . $file ) ) {
324
+                    $path = $this->template_path . $file;
325
+                } else {
326
+                    $path = $this->original_path . $file;
327
+                }
328
+            }
329
+
330
+            // phpcs:ignore WordPress.NamingConventions.ValidHookName
331
+            do_action( "redux/{$this->parent->args['opt_name']}/panel/template/" . $file . '/before' );
332
+
333
+            // phpcs:ignore WordPress.NamingConventions.ValidHookName
334
+            $path = apply_filters( "redux/{$this->parent->args['opt_name']}/panel/template/" . $file, $path );
335
+
336
+            // phpcs:ignore WordPress.NamingConventions.ValidHookName
337
+            do_action( "redux/{$this->parent->args['opt_name']}/panel/template/" . $file . '/after' );
338
+
339
+            if ( file_exists( $path ) ) {
340
+                if ( is_readable( $path ) ) {
341
+                    require $path;
342
+                } else {
343
+                    // translators: %1$s: template path.
344
+                    echo '<div class="error"><p>' . sprintf( esc_html__( 'Redux Panel Template %1$s cannot be read. Please check the permissions for this file.', 'redux-framework' ), '<code>' . esc_html( $path ) . '</code>' ) . '</p></div>';
345
+                }
346
+            } elseif ( file_exists( Redux_Core::$dir . 'templates/panel/' . $file ) ) {
347
+                    require Redux_Core::$dir . 'templates/panel/' . $file;
348
+            } else {
349
+                // translators: %1$s: template path.
350
+                echo '<div class="error"><p>' . sprintf( esc_html__( 'Redux Panel Template %1$s does not exist. Please reinstall Redux to replace this file.', 'redux-framework' ), '<code>' . esc_html( $path ) . '</code>' ) . '</p></div>';
351
+            }
352
+        }
353
+
354
+        /**
355
+         * Scan the template files.
356
+         *
357
+         * @param string $template_path Path to template file.
358
+         *
359
+         * @return array
360
+         */
361
+        public function scan_template_files( string $template_path ): array {
362
+            $files  = scandir( $template_path );
363
+            $result = array();
364
+            if ( $files ) {
365
+                foreach ( $files as $value ) {
366
+                    if ( ! in_array( $value, array( '.', '..' ), true ) ) {
367
+                        if ( is_dir( $template_path . DIRECTORY_SEPARATOR . $value ) ) {
368
+                            $sub_files = self::scan_template_files( $template_path . DIRECTORY_SEPARATOR . $value );
369
+                            foreach ( $sub_files as $sub_file ) {
370
+                                $result[] = $value . DIRECTORY_SEPARATOR . $sub_file;
371
+                            }
372
+                        } else {
373
+                            $result[] = $value;
374
+                        }
375
+                    }
376
+                }
377
+            }
378
+
379
+            return $result;
380
+        }
381
+
382
+        /**
383
+         * Show a notice highlighting bad template files
384
+         */
385
+        public function template_file_check_notice() {
386
+            if ( $this->original_path === $this->template_path ) {
387
+                return;
388
+            }
389
+
390
+            $core_templates = $this->scan_template_files( $this->original_path );
391
+
392
+            foreach ( $core_templates as $file ) {
393
+                $developer_theme_file = false;
394
+
395
+                if ( file_exists( $this->template_path . $file ) ) {
396
+                    $developer_theme_file = $this->template_path . $file;
397
+                }
398
+
399
+                if ( $developer_theme_file ) {
400
+                    $core_version      = Redux_Helpers::get_template_version( $this->original_path . $file );
401
+                    $developer_version = Redux_Helpers::get_template_version( $developer_theme_file );
402
+
403
+                    if ( $core_version && $developer_version && version_compare( $developer_version, $core_version, '<' ) ) {
404
+                        ?>
405 405
 						<div id="message" class="error redux-message" style="display:block!important">
406 406
 							<p>
407 407
 								<strong><?php esc_html_e( 'Your panel has bundled copies of Redux Framework template files that are outdated!', 'redux-framework' ); ?></strong>&nbsp;&nbsp;<?php esc_html_e( 'Please ask the author of this theme to update them as functionality issues could arise.', 'redux-framework' ); ?>
@@ -409,23 +409,23 @@  discard block
 block discarded – undo
409 409
 						</div>
410 410
 						<?php
411 411
 
412
-						return;
413
-					}
414
-				}
415
-			}
416
-		}
417
-
418
-		/**
419
-		 * Outputs the HTML for a given section using the WordPress settings API.
420
-		 *
421
-		 * @param mixed $k Section number of settings panel to display.
422
-		 */
423
-		private function output_section( $k ) {
424
-			do_settings_sections( $this->parent->args['opt_name'] . $k . '_section_group' );
425
-		}
426
-	}
412
+                        return;
413
+                    }
414
+                }
415
+            }
416
+        }
417
+
418
+        /**
419
+         * Outputs the HTML for a given section using the WordPress settings API.
420
+         *
421
+         * @param mixed $k Section number of settings panel to display.
422
+         */
423
+        private function output_section( $k ) {
424
+            do_settings_sections( $this->parent->args['opt_name'] . $k . '_section_group' );
425
+        }
426
+    }
427 427
 }
428 428
 
429 429
 if ( ! class_exists( 'reduxCorePanel' ) ) {
430
-	class_alias( 'Redux_Panel', 'reduxCorePanel' );
430
+    class_alias( 'Redux_Panel', 'reduxCorePanel' );
431 431
 }
Please login to merge, or discard this patch.
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.