Passed
Pull Request — master (#1930)
by Aristeides
04:03
created
controls/php/class-kirki-control-repeater.php 1 patch
Spacing   +28 added lines, -28 removed lines patch added patch discarded remove patch
@@ -84,28 +84,28 @@  discard block
 block discarded – undo
84 84
 
85 85
 		if ( empty( $this->button_label ) ) {
86 86
 			/* translators: %s represents the label of the row. */
87
-			$this->button_label = sprintf( esc_attr__( 'Add new %s', 'kirki' ), $this->row_label['value'] );
87
+			$this->button_label = sprintf( esc_attr__( 'Add new %s', 'kirki' ), $this->row_label[ 'value' ] );
88 88
 		}
89 89
 
90
-		if ( empty( $args['fields'] ) || ! is_array( $args['fields'] ) ) {
91
-			$args['fields'] = array();
90
+		if ( empty( $args[ 'fields' ] ) || ! is_array( $args[ 'fields' ] ) ) {
91
+			$args[ 'fields' ] = array();
92 92
 		}
93 93
 
94 94
 		// An array to store keys of fields that need to be filtered.
95 95
 		$media_fields_to_filter = array();
96 96
 
97
-		foreach ( $args['fields'] as $key => $value ) {
98
-			if ( ! isset( $value['default'] ) ) {
99
-				$args['fields'][ $key ]['default'] = '';
97
+		foreach ( $args[ 'fields' ] as $key => $value ) {
98
+			if ( ! isset( $value[ 'default' ] ) ) {
99
+				$args[ 'fields' ][ $key ][ 'default' ] = '';
100 100
 			}
101
-			if ( ! isset( $value['label'] ) ) {
102
-				$args['fields'][ $key ]['label'] = '';
101
+			if ( ! isset( $value[ 'label' ] ) ) {
102
+				$args[ 'fields' ][ $key ][ 'label' ] = '';
103 103
 			}
104
-			$args['fields'][ $key ]['id'] = $key;
104
+			$args[ 'fields' ][ $key ][ 'id' ] = $key;
105 105
 
106 106
 			// We check if the filed is an uploaded media ( image , file, video, etc.. ).
107
-			if ( isset( $value['type'] ) ) {
108
-				switch ( $value['type'] ) {
107
+			if ( isset( $value[ 'type' ] ) ) {
108
+				switch ( $value[ 'type' ] ) {
109 109
 					case 'image':
110 110
 					case 'cropped_image':
111 111
 					case 'upload':
@@ -125,14 +125,14 @@  discard block
 block discarded – undo
125 125
 							)
126 126
 						);
127 127
 						// Hackily add in the data link parameter.
128
-						$dropdown = str_replace( '<select', '<select data-field="' . esc_attr( $args['fields'][ $key ]['id'] ) . '"' . $this->get_link(), $dropdown ); // phpcs:ignore Generic.Formatting.MultipleStatementAlignment.NotSameWarning
129
-						$args['fields'][ $key ]['dropdown'] = $dropdown;
128
+						$dropdown = str_replace( '<select', '<select data-field="' . esc_attr( $args[ 'fields' ][ $key ][ 'id' ] ) . '"' . $this->get_link(), $dropdown ); // phpcs:ignore Generic.Formatting.MultipleStatementAlignment.NotSameWarning
129
+						$args[ 'fields' ][ $key ][ 'dropdown' ] = $dropdown;
130 130
 						break;
131 131
 				}
132 132
 			}
133 133
 		}
134 134
 
135
-		$this->fields = $args['fields'];
135
+		$this->fields = $args[ 'fields' ];
136 136
 
137 137
 		// Now we are going to filter the fields.
138 138
 		// First we create a copy of the value that would be used otherwise.
@@ -192,14 +192,14 @@  discard block
 block discarded – undo
192 192
 
193 193
 		$fields = $this->fields;
194 194
 
195
-		$this->json['fields']    = $fields;
196
-		$this->json['row_label'] = $this->row_label;
195
+		$this->json[ 'fields' ]    = $fields;
196
+		$this->json[ 'row_label' ] = $this->row_label;
197 197
 
198 198
 		// If filtered_value has been set and is not empty we use it instead of the actual value.
199 199
 		if ( is_array( $this->filtered_value ) && ! empty( $this->filtered_value ) ) {
200
-			$this->json['value'] = $this->filtered_value;
200
+			$this->json[ 'value' ] = $this->filtered_value;
201 201
 		}
202
-		$this->json['value'] = apply_filters( "kirki_controls_repeater_value_{$this->id}", $this->json['value'] );
202
+		$this->json[ 'value' ] = apply_filters( "kirki_controls_repeater_value_{$this->id}", $this->json[ 'value' ] );
203 203
 	}
204 204
 
205 205
 	/**
@@ -222,9 +222,9 @@  discard block
 block discarded – undo
222 222
 
223 223
 		<ul class="repeater-fields"></ul>
224 224
 
225
-		<?php if ( isset( $this->choices['limit'] ) ) : ?>
225
+		<?php if ( isset( $this->choices[ 'limit' ] ) ) : ?>
226 226
 			<?php /* translators: %s represents the number of rows we're limiting the repeater to allow. */ ?>
227
-			<p class="limit"><?php printf( esc_attr__( 'Limit: %s rows', 'kirki' ), esc_html( $this->choices['limit'] ) ); ?></p>
227
+			<p class="limit"><?php printf( esc_attr__( 'Limit: %s rows', 'kirki' ), esc_html( $this->choices[ 'limit' ] ) ); ?></p>
228 228
 		<?php endif; ?>
229 229
 		<button class="button-secondary repeater-add"><?php echo esc_html( $this->button_label ); ?></button>
230 230
 
@@ -457,24 +457,24 @@  discard block
 block discarded – undo
457 457
 	protected function row_label( $args ) {
458 458
 
459 459
 		// Validating args for row labels.
460
-		if ( isset( $args['row_label'] ) && is_array( $args['row_label'] ) && ! empty( $args['row_label'] ) ) {
460
+		if ( isset( $args[ 'row_label' ] ) && is_array( $args[ 'row_label' ] ) && ! empty( $args[ 'row_label' ] ) ) {
461 461
 
462 462
 			// Validating row label type.
463
-			if ( isset( $args['row_label']['type'] ) && ( 'text' === $args['row_label']['type'] || 'field' === $args['row_label']['type'] ) ) {
464
-				$this->row_label['type'] = $args['row_label']['type'];
463
+			if ( isset( $args[ 'row_label' ][ 'type' ] ) && ( 'text' === $args[ 'row_label' ][ 'type' ] || 'field' === $args[ 'row_label' ][ 'type' ] ) ) {
464
+				$this->row_label[ 'type' ] = $args[ 'row_label' ][ 'type' ];
465 465
 			}
466 466
 
467 467
 			// Validating row label type.
468
-			if ( isset( $args['row_label']['value'] ) && ! empty( $args['row_label']['value'] ) ) {
469
-				$this->row_label['value'] = esc_attr( $args['row_label']['value'] );
468
+			if ( isset( $args[ 'row_label' ][ 'value' ] ) && ! empty( $args[ 'row_label' ][ 'value' ] ) ) {
469
+				$this->row_label[ 'value' ] = esc_attr( $args[ 'row_label' ][ 'value' ] );
470 470
 			}
471 471
 
472 472
 			// Validating row label field.
473
-			if ( isset( $args['row_label']['field'] ) && ! empty( $args['row_label']['field'] ) && isset( $args['fields'][ esc_attr( $args['row_label']['field'] ) ] ) ) {
474
-				$this->row_label['field'] = esc_attr( $args['row_label']['field'] );
473
+			if ( isset( $args[ 'row_label' ][ 'field' ] ) && ! empty( $args[ 'row_label' ][ 'field' ] ) && isset( $args[ 'fields' ][ esc_attr( $args[ 'row_label' ][ 'field' ] ) ] ) ) {
474
+				$this->row_label[ 'field' ] = esc_attr( $args[ 'row_label' ][ 'field' ] );
475 475
 			} else {
476 476
 				// If from field is not set correctly, making sure standard is set as the type.
477
-				$this->row_label['type'] = 'text';
477
+				$this->row_label[ 'type' ] = 'text';
478 478
 			}
479 479
 		}
480 480
 	}
Please login to merge, or discard this patch.
controls/php/class-kirki-control-slider.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -37,8 +37,8 @@
 block discarded – undo
37 37
 	public function to_json() {
38 38
 		parent::to_json();
39 39
 
40
-		$this->json['choices'] = wp_parse_args(
41
-			$this->json['choices'], array(
40
+		$this->json[ 'choices' ] = wp_parse_args(
41
+			$this->json[ 'choices' ], array(
42 42
 				'min'    => '0',
43 43
 				'max'    => '100',
44 44
 				'step'   => '1',
Please login to merge, or discard this patch.
controls/php/class-kirki-control-base.php 1 patch
Spacing   +17 added lines, -17 removed lines patch added patch discarded remove patch
@@ -159,41 +159,41 @@
 block discarded – undo
159 159
 		// Get the basics from the parent class.
160 160
 		parent::to_json();
161 161
 		// Default value.
162
-		$this->json['default'] = $this->setting->default;
162
+		$this->json[ 'default' ] = $this->setting->default;
163 163
 		if ( isset( $this->default ) ) {
164
-			$this->json['default'] = $this->default;
164
+			$this->json[ 'default' ] = $this->default;
165 165
 		}
166 166
 		// Required.
167
-		$this->json['required'] = $this->required;
167
+		$this->json[ 'required' ] = $this->required;
168 168
 		// Output.
169
-		$this->json['output'] = $this->output;
169
+		$this->json[ 'output' ] = $this->output;
170 170
 		// Value.
171
-		$this->json['value'] = $this->value();
171
+		$this->json[ 'value' ] = $this->value();
172 172
 		// Choices.
173
-		$this->json['choices'] = $this->choices;
173
+		$this->json[ 'choices' ] = $this->choices;
174 174
 		// The link.
175
-		$this->json['link'] = $this->get_link();
175
+		$this->json[ 'link' ] = $this->get_link();
176 176
 		// The ID.
177
-		$this->json['id'] = $this->id;
177
+		$this->json[ 'id' ] = $this->id;
178 178
 		// Translation strings.
179
-		$this->json['l10n'] = $this->l10n();
179
+		$this->json[ 'l10n' ] = $this->l10n();
180 180
 		// The ajaxurl in case we need it.
181
-		$this->json['ajaxurl'] = admin_url( 'admin-ajax.php' );
181
+		$this->json[ 'ajaxurl' ] = admin_url( 'admin-ajax.php' );
182 182
 		// Input attributes.
183
-		$this->json['inputAttrs'] = '';
183
+		$this->json[ 'inputAttrs' ] = '';
184 184
 		foreach ( $this->input_attrs as $attr => $value ) {
185
-			$this->json['inputAttrs'] .= $attr . '="' . esc_attr( $value ) . '" ';
185
+			$this->json[ 'inputAttrs' ] .= $attr . '="' . esc_attr( $value ) . '" ';
186 186
 		}
187 187
 		// The kirki-config.
188
-		$this->json['kirkiConfig'] = $this->kirki_config;
188
+		$this->json[ 'kirkiConfig' ] = $this->kirki_config;
189 189
 		// The option-type.
190
-		$this->json['kirkiOptionType'] = $this->option_type;
190
+		$this->json[ 'kirkiOptionType' ] = $this->option_type;
191 191
 		// The option-name.
192
-		$this->json['kirkiOptionName'] = $this->option_name;
192
+		$this->json[ 'kirkiOptionName' ] = $this->option_name;
193 193
 		// The preset.
194
-		$this->json['preset'] = $this->preset;
194
+		$this->json[ 'preset' ] = $this->preset;
195 195
 		// The CSS-Variables.
196
-		$this->json['css-var'] = $this->css_vars;
196
+		$this->json[ 'css-var' ] = $this->css_vars;
197 197
 	}
198 198
 
199 199
 	/**
Please login to merge, or discard this patch.