Completed
Push — master ( d99bf9...491baf )
by Stephen
13:47
created
src/wp-includes/customize/class-wp-customize-media-control.php 1 patch
Spacing   +24 added lines, -24 removed lines patch added patch discarded remove patch
@@ -52,19 +52,19 @@  discard block
 block discarded – undo
52 52
 	 * @param string               $id      Control ID.
53 53
 	 * @param array                $args    Optional. Arguments to override class property defaults.
54 54
 	 */
55
-	public function __construct( $manager, $id, $args = array() ) {
56
-		parent::__construct( $manager, $id, $args );
55
+	public function __construct($manager, $id, $args = array()) {
56
+		parent::__construct($manager, $id, $args);
57 57
 
58
-		if ( ! ( $this instanceof WP_Customize_Image_Control ) ) {
59
-			$this->button_labels = wp_parse_args( $this->button_labels, array(
60
-				'select'       => __( 'Select File' ),
61
-				'change'       => __( 'Change File' ),
62
-				'default'      => __( 'Default' ),
63
-				'remove'       => __( 'Remove' ),
64
-				'placeholder'  => __( 'No file selected' ),
65
-				'frame_title'  => __( 'Select File' ),
66
-				'frame_button' => __( 'Choose File' ),
67
-			) );
58
+		if ( ! ($this instanceof WP_Customize_Image_Control)) {
59
+			$this->button_labels = wp_parse_args($this->button_labels, array(
60
+				'select'       => __('Select File'),
61
+				'change'       => __('Change File'),
62
+				'default'      => __('Default'),
63
+				'remove'       => __('Remove'),
64
+				'placeholder'  => __('No file selected'),
65
+				'frame_title'  => __('Select File'),
66
+				'frame_button' => __('Choose File'),
67
+			));
68 68
 		}
69 69
 	}
70 70
 
@@ -88,40 +88,40 @@  discard block
 block discarded – undo
88 88
 	 */
89 89
 	public function to_json() {
90 90
 		parent::to_json();
91
-		$this->json['label'] = html_entity_decode( $this->label, ENT_QUOTES, get_bloginfo( 'charset' ) );
91
+		$this->json['label'] = html_entity_decode($this->label, ENT_QUOTES, get_bloginfo('charset'));
92 92
 		$this->json['mime_type'] = $this->mime_type;
93 93
 		$this->json['button_labels'] = $this->button_labels;
94
-		$this->json['canUpload'] = current_user_can( 'upload_files' );
94
+		$this->json['canUpload'] = current_user_can('upload_files');
95 95
 
96 96
 		$value = $this->value();
97 97
 
98
-		if ( is_object( $this->setting ) ) {
99
-			if ( $this->setting->default ) {
98
+		if (is_object($this->setting)) {
99
+			if ($this->setting->default) {
100 100
 				// Fake an attachment model - needs all fields used by template.
101 101
 				// Note that the default value must be a URL, NOT an attachment ID.
102
-				$type = in_array( substr( $this->setting->default, -3 ), array( 'jpg', 'png', 'gif', 'bmp' ) ) ? 'image' : 'document';
102
+				$type = in_array(substr($this->setting->default, -3), array('jpg', 'png', 'gif', 'bmp')) ? 'image' : 'document';
103 103
 				$default_attachment = array(
104 104
 					'id' => 1,
105 105
 					'url' => $this->setting->default,
106 106
 					'type' => $type,
107
-					'icon' => wp_mime_type_icon( $type ),
108
-					'title' => basename( $this->setting->default ),
107
+					'icon' => wp_mime_type_icon($type),
108
+					'title' => basename($this->setting->default),
109 109
 				);
110 110
 
111
-				if ( 'image' === $type ) {
111
+				if ('image' === $type) {
112 112
 					$default_attachment['sizes'] = array(
113
-						'full' => array( 'url' => $this->setting->default ),
113
+						'full' => array('url' => $this->setting->default),
114 114
 					);
115 115
 				}
116 116
 
117 117
 				$this->json['defaultAttachment'] = $default_attachment;
118 118
 			}
119 119
 
120
-			if ( $value && $this->setting->default && $value === $this->setting->default ) {
120
+			if ($value && $this->setting->default && $value === $this->setting->default) {
121 121
 				// Set the default as the attachment.
122 122
 				$this->json['attachment'] = $this->json['defaultAttachment'];
123
-			} elseif ( $value ) {
124
-				$this->json['attachment'] = wp_prepare_attachment_for_js( $value );
123
+			} elseif ($value) {
124
+				$this->json['attachment'] = wp_prepare_attachment_for_js($value);
125 125
 			}
126 126
 		}
127 127
 	}
Please login to merge, or discard this patch.
src/wp-includes/class-wp-meta-query.php 2 patches
Braces   +12 added lines, -8 removed lines patch added patch discarded remove patch
@@ -136,8 +136,9 @@  discard block
 block discarded – undo
136 136
 	 * }
137 137
 	 */
138 138
 	public function __construct( $meta_query = false ) {
139
-		if ( !$meta_query )
140
-			return;
139
+		if ( !$meta_query ) {
140
+					return;
141
+		}
141 142
 
142 143
 		if ( isset( $meta_query['relation'] ) && strtoupper( $meta_query['relation'] ) == 'OR' ) {
143 144
 			$this->relation = 'OR';
@@ -290,16 +291,19 @@  discard block
 block discarded – undo
290 291
 	 * @return string MySQL type.
291 292
 	 */
292 293
 	public function get_cast_for_type( $type = '' ) {
293
-		if ( empty( $type ) )
294
-			return 'CHAR';
294
+		if ( empty( $type ) ) {
295
+					return 'CHAR';
296
+		}
295 297
 
296 298
 		$meta_type = strtoupper( $type );
297 299
 
298
-		if ( ! preg_match( '/^(?:BINARY|CHAR|DATE|DATETIME|SIGNED|UNSIGNED|TIME|NUMERIC(?:\(\d+(?:,\s?\d+)?\))?|DECIMAL(?:\(\d+(?:,\s?\d+)?\))?)$/', $meta_type ) )
299
-			return 'CHAR';
300
+		if ( ! preg_match( '/^(?:BINARY|CHAR|DATE|DATETIME|SIGNED|UNSIGNED|TIME|NUMERIC(?:\(\d+(?:,\s?\d+)?\))?|DECIMAL(?:\(\d+(?:,\s?\d+)?\))?)$/', $meta_type ) ) {
301
+					return 'CHAR';
302
+		}
300 303
 
301
-		if ( 'NUMERIC' == $meta_type )
302
-			$meta_type = 'SIGNED';
304
+		if ( 'NUMERIC' == $meta_type ) {
305
+					$meta_type = 'SIGNED';
306
+		}
303 307
 
304 308
 		return $meta_type;
305 309
 	}
Please login to merge, or discard this patch.
Spacing   +117 added lines, -117 removed lines patch added patch discarded remove patch
@@ -136,17 +136,17 @@  discard block
 block discarded – undo
136 136
 	 *     }
137 137
 	 * }
138 138
 	 */
139
-	public function __construct( $meta_query = false ) {
140
-		if ( !$meta_query )
139
+	public function __construct($meta_query = false) {
140
+		if ( ! $meta_query)
141 141
 			return;
142 142
 
143
-		if ( isset( $meta_query['relation'] ) && strtoupper( $meta_query['relation'] ) == 'OR' ) {
143
+		if (isset($meta_query['relation']) && strtoupper($meta_query['relation']) == 'OR') {
144 144
 			$this->relation = 'OR';
145 145
 		} else {
146 146
 			$this->relation = 'AND';
147 147
 		}
148 148
 
149
-		$this->queries = $this->sanitize_query( $meta_query );
149
+		$this->queries = $this->sanitize_query($meta_query);
150 150
 	}
151 151
 
152 152
 	/**
@@ -160,44 +160,44 @@  discard block
 block discarded – undo
160 160
 	 * @param array $queries Array of query clauses.
161 161
 	 * @return array Sanitized array of query clauses.
162 162
 	 */
163
-	public function sanitize_query( $queries ) {
163
+	public function sanitize_query($queries) {
164 164
 		$clean_queries = array();
165 165
 
166
-		if ( ! is_array( $queries ) ) {
166
+		if ( ! is_array($queries)) {
167 167
 			return $clean_queries;
168 168
 		}
169 169
 
170
-		foreach ( $queries as $key => $query ) {
171
-			if ( 'relation' === $key ) {
170
+		foreach ($queries as $key => $query) {
171
+			if ('relation' === $key) {
172 172
 				$relation = $query;
173 173
 
174
-			} elseif ( ! is_array( $query ) ) {
174
+			} elseif ( ! is_array($query)) {
175 175
 				continue;
176 176
 
177 177
 			// First-order clause.
178
-			} elseif ( $this->is_first_order_clause( $query ) ) {
179
-				if ( isset( $query['value'] ) && array() === $query['value'] ) {
180
-					unset( $query['value'] );
178
+			} elseif ($this->is_first_order_clause($query)) {
179
+				if (isset($query['value']) && array() === $query['value']) {
180
+					unset($query['value']);
181 181
 				}
182 182
 
183
-				$clean_queries[ $key ] = $query;
183
+				$clean_queries[$key] = $query;
184 184
 
185 185
 			// Otherwise, it's a nested query, so we recurse.
186 186
 			} else {
187
-				$cleaned_query = $this->sanitize_query( $query );
187
+				$cleaned_query = $this->sanitize_query($query);
188 188
 
189
-				if ( ! empty( $cleaned_query ) ) {
190
-					$clean_queries[ $key ] = $cleaned_query;
189
+				if ( ! empty($cleaned_query)) {
190
+					$clean_queries[$key] = $cleaned_query;
191 191
 				}
192 192
 			}
193 193
 		}
194 194
 
195
-		if ( empty( $clean_queries ) ) {
195
+		if (empty($clean_queries)) {
196 196
 			return $clean_queries;
197 197
 		}
198 198
 
199 199
 		// Sanitize the 'relation' key provided in the query.
200
-		if ( isset( $relation ) && 'OR' === strtoupper( $relation ) ) {
200
+		if (isset($relation) && 'OR' === strtoupper($relation)) {
201 201
 			$clean_queries['relation'] = 'OR';
202 202
 			$this->has_or_relation = true;
203 203
 
@@ -206,7 +206,7 @@  discard block
 block discarded – undo
206 206
 		 * This value will not actually be used to join clauses, but it
207 207
 		 * simplifies the logic around combining key-only queries.
208 208
 		 */
209
-		} elseif ( 1 === count( $clean_queries ) ) {
209
+		} elseif (1 === count($clean_queries)) {
210 210
 			$clean_queries['relation'] = 'OR';
211 211
 
212 212
 		// Default to AND.
@@ -229,8 +229,8 @@  discard block
 block discarded – undo
229 229
 	 * @param array $query Meta query arguments.
230 230
 	 * @return bool Whether the query clause is a first-order clause.
231 231
 	 */
232
-	protected function is_first_order_clause( $query ) {
233
-		return isset( $query['key'] ) || isset( $query['value'] );
232
+	protected function is_first_order_clause($query) {
233
+		return isset($query['key']) || isset($query['value']);
234 234
 	}
235 235
 
236 236
 	/**
@@ -241,7 +241,7 @@  discard block
 block discarded – undo
241 241
 	 *
242 242
 	 * @param array $qv The query variables
243 243
 	 */
244
-	public function parse_query_vars( $qv ) {
244
+	public function parse_query_vars($qv) {
245 245
 		$meta_query = array();
246 246
 
247 247
 		/*
@@ -251,34 +251,34 @@  discard block
 block discarded – undo
251 251
 		 * the rest of the meta_query).
252 252
 		 */
253 253
 		$primary_meta_query = array();
254
-		foreach ( array( 'key', 'compare', 'type' ) as $key ) {
255
-			if ( ! empty( $qv[ "meta_$key" ] ) ) {
256
-				$primary_meta_query[ $key ] = $qv[ "meta_$key" ];
254
+		foreach (array('key', 'compare', 'type') as $key) {
255
+			if ( ! empty($qv["meta_$key"])) {
256
+				$primary_meta_query[$key] = $qv["meta_$key"];
257 257
 			}
258 258
 		}
259 259
 
260 260
 		// WP_Query sets 'meta_value' = '' by default.
261
-		if ( isset( $qv['meta_value'] ) && '' !== $qv['meta_value'] && ( ! is_array( $qv['meta_value'] ) || $qv['meta_value'] ) ) {
261
+		if (isset($qv['meta_value']) && '' !== $qv['meta_value'] && ( ! is_array($qv['meta_value']) || $qv['meta_value'])) {
262 262
 			$primary_meta_query['value'] = $qv['meta_value'];
263 263
 		}
264 264
 
265
-		$existing_meta_query = isset( $qv['meta_query'] ) && is_array( $qv['meta_query'] ) ? $qv['meta_query'] : array();
265
+		$existing_meta_query = isset($qv['meta_query']) && is_array($qv['meta_query']) ? $qv['meta_query'] : array();
266 266
 
267
-		if ( ! empty( $primary_meta_query ) && ! empty( $existing_meta_query ) ) {
267
+		if ( ! empty($primary_meta_query) && ! empty($existing_meta_query)) {
268 268
 			$meta_query = array(
269 269
 				'relation' => 'AND',
270 270
 				$primary_meta_query,
271 271
 				$existing_meta_query,
272 272
 			);
273
-		} elseif ( ! empty( $primary_meta_query ) ) {
273
+		} elseif ( ! empty($primary_meta_query)) {
274 274
 			$meta_query = array(
275 275
 				$primary_meta_query,
276 276
 			);
277
-		} elseif ( ! empty( $existing_meta_query ) ) {
277
+		} elseif ( ! empty($existing_meta_query)) {
278 278
 			$meta_query = $existing_meta_query;
279 279
 		}
280 280
 
281
-		$this->__construct( $meta_query );
281
+		$this->__construct($meta_query);
282 282
 	}
283 283
 
284 284
 	/**
@@ -290,16 +290,16 @@  discard block
 block discarded – undo
290 290
 	 * @param string $type MySQL type to cast meta_value.
291 291
 	 * @return string MySQL type.
292 292
 	 */
293
-	public function get_cast_for_type( $type = '' ) {
294
-		if ( empty( $type ) )
293
+	public function get_cast_for_type($type = '') {
294
+		if (empty($type))
295 295
 			return 'CHAR';
296 296
 
297
-		$meta_type = strtoupper( $type );
297
+		$meta_type = strtoupper($type);
298 298
 
299
-		if ( ! preg_match( '/^(?:BINARY|CHAR|DATE|DATETIME|SIGNED|UNSIGNED|TIME|NUMERIC(?:\(\d+(?:,\s?\d+)?\))?|DECIMAL(?:\(\d+(?:,\s?\d+)?\))?)$/', $meta_type ) )
299
+		if ( ! preg_match('/^(?:BINARY|CHAR|DATE|DATETIME|SIGNED|UNSIGNED|TIME|NUMERIC(?:\(\d+(?:,\s?\d+)?\))?|DECIMAL(?:\(\d+(?:,\s?\d+)?\))?)$/', $meta_type))
300 300
 			return 'CHAR';
301 301
 
302
-		if ( 'NUMERIC' == $meta_type )
302
+		if ('NUMERIC' == $meta_type)
303 303
 			$meta_type = 'SIGNED';
304 304
 
305 305
 		return $meta_type;
@@ -322,15 +322,15 @@  discard block
 block discarded – undo
322 322
 	 *     @type string $where SQL fragment to append to the main WHERE clause.
323 323
 	 * }
324 324
 	 */
325
-	public function get_sql( $type, $primary_table, $primary_id_column, $context = null ) {
326
-		if ( ! $meta_table = _get_meta_table( $type ) ) {
325
+	public function get_sql($type, $primary_table, $primary_id_column, $context = null) {
326
+		if ( ! $meta_table = _get_meta_table($type)) {
327 327
 			return false;
328 328
 		}
329 329
 
330 330
 		$this->table_aliases = array();
331 331
 
332 332
 		$this->meta_table     = $meta_table;
333
-		$this->meta_id_column = sanitize_key( $type . '_id' );
333
+		$this->meta_id_column = sanitize_key($type.'_id');
334 334
 
335 335
 		$this->primary_table     = $primary_table;
336 336
 		$this->primary_id_column = $primary_id_column;
@@ -341,8 +341,8 @@  discard block
 block discarded – undo
341 341
 		 * If any JOINs are LEFT JOINs (as in the case of NOT EXISTS), then all JOINs should
342 342
 		 * be LEFT. Otherwise posts with no metadata will be excluded from results.
343 343
 		 */
344
-		if ( false !== strpos( $sql['join'], 'LEFT JOIN' ) ) {
345
-			$sql['join'] = str_replace( 'INNER JOIN', 'LEFT JOIN', $sql['join'] );
344
+		if (false !== strpos($sql['join'], 'LEFT JOIN')) {
345
+			$sql['join'] = str_replace('INNER JOIN', 'LEFT JOIN', $sql['join']);
346 346
 		}
347 347
 
348 348
 		/**
@@ -357,7 +357,7 @@  discard block
 block discarded – undo
357 357
 		 * @param string $primary_id_column Primary column ID.
358 358
 		 * @param object $context           The main query object.
359 359
 		 */
360
-		return apply_filters_ref_array( 'get_meta_sql', array( $sql, $this->queries, $type, $primary_table, $primary_id_column, $context ) );
360
+		return apply_filters_ref_array('get_meta_sql', array($sql, $this->queries, $type, $primary_table, $primary_id_column, $context));
361 361
 	}
362 362
 
363 363
 	/**
@@ -382,10 +382,10 @@  discard block
 block discarded – undo
382 382
 		 * To keep $this->queries unaltered, pass a copy.
383 383
 		 */
384 384
 		$queries = $this->queries;
385
-		$sql = $this->get_sql_for_query( $queries );
385
+		$sql = $this->get_sql_for_query($queries);
386 386
 
387
-		if ( ! empty( $sql['where'] ) ) {
388
-			$sql['where'] = ' AND ' . $sql['where'];
387
+		if ( ! empty($sql['where'])) {
388
+			$sql['where'] = ' AND '.$sql['where'];
389 389
 		}
390 390
 
391 391
 		return $sql;
@@ -410,7 +410,7 @@  discard block
 block discarded – undo
410 410
 	 *     @type string $where SQL fragment to append to the main WHERE clause.
411 411
 	 * }
412 412
 	 */
413
-	protected function get_sql_for_query( &$query, $depth = 0 ) {
413
+	protected function get_sql_for_query(&$query, $depth = 0) {
414 414
 		$sql_chunks = array(
415 415
 			'join'  => array(),
416 416
 			'where' => array(),
@@ -422,32 +422,32 @@  discard block
 block discarded – undo
422 422
 		);
423 423
 
424 424
 		$indent = '';
425
-		for ( $i = 0; $i < $depth; $i++ ) {
425
+		for ($i = 0; $i < $depth; $i++) {
426 426
 			$indent .= "  ";
427 427
 		}
428 428
 
429
-		foreach ( $query as $key => &$clause ) {
430
-			if ( 'relation' === $key ) {
429
+		foreach ($query as $key => &$clause) {
430
+			if ('relation' === $key) {
431 431
 				$relation = $query['relation'];
432
-			} elseif ( is_array( $clause ) ) {
432
+			} elseif (is_array($clause)) {
433 433
 
434 434
 				// This is a first-order clause.
435
-				if ( $this->is_first_order_clause( $clause ) ) {
436
-					$clause_sql = $this->get_sql_for_clause( $clause, $query, $key );
435
+				if ($this->is_first_order_clause($clause)) {
436
+					$clause_sql = $this->get_sql_for_clause($clause, $query, $key);
437 437
 
438
-					$where_count = count( $clause_sql['where'] );
439
-					if ( ! $where_count ) {
438
+					$where_count = count($clause_sql['where']);
439
+					if ( ! $where_count) {
440 440
 						$sql_chunks['where'][] = '';
441
-					} elseif ( 1 === $where_count ) {
441
+					} elseif (1 === $where_count) {
442 442
 						$sql_chunks['where'][] = $clause_sql['where'][0];
443 443
 					} else {
444
-						$sql_chunks['where'][] = '( ' . implode( ' AND ', $clause_sql['where'] ) . ' )';
444
+						$sql_chunks['where'][] = '( '.implode(' AND ', $clause_sql['where']).' )';
445 445
 					}
446 446
 
447
-					$sql_chunks['join'] = array_merge( $sql_chunks['join'], $clause_sql['join'] );
447
+					$sql_chunks['join'] = array_merge($sql_chunks['join'], $clause_sql['join']);
448 448
 				// This is a subquery, so we recurse.
449 449
 				} else {
450
-					$clause_sql = $this->get_sql_for_query( $clause, $depth + 1 );
450
+					$clause_sql = $this->get_sql_for_query($clause, $depth + 1);
451 451
 
452 452
 					$sql_chunks['where'][] = $clause_sql['where'];
453 453
 					$sql_chunks['join'][]  = $clause_sql['join'];
@@ -456,21 +456,21 @@  discard block
 block discarded – undo
456 456
 		}
457 457
 
458 458
 		// Filter to remove empties.
459
-		$sql_chunks['join']  = array_filter( $sql_chunks['join'] );
460
-		$sql_chunks['where'] = array_filter( $sql_chunks['where'] );
459
+		$sql_chunks['join']  = array_filter($sql_chunks['join']);
460
+		$sql_chunks['where'] = array_filter($sql_chunks['where']);
461 461
 
462
-		if ( empty( $relation ) ) {
462
+		if (empty($relation)) {
463 463
 			$relation = 'AND';
464 464
 		}
465 465
 
466 466
 		// Filter duplicate JOIN clauses and combine into a single string.
467
-		if ( ! empty( $sql_chunks['join'] ) ) {
468
-			$sql['join'] = implode( ' ', array_unique( $sql_chunks['join'] ) );
467
+		if ( ! empty($sql_chunks['join'])) {
468
+			$sql['join'] = implode(' ', array_unique($sql_chunks['join']));
469 469
 		}
470 470
 
471 471
 		// Generate a single WHERE clause with proper brackets and indentation.
472
-		if ( ! empty( $sql_chunks['where'] ) ) {
473
-			$sql['where'] = '( ' . "\n  " . $indent . implode( ' ' . "\n  " . $indent . $relation . ' ' . "\n  " . $indent, $sql_chunks['where'] ) . "\n" . $indent . ')';
472
+		if ( ! empty($sql_chunks['where'])) {
473
+			$sql['where'] = '( '."\n  ".$indent.implode(' '."\n  ".$indent.$relation.' '."\n  ".$indent, $sql_chunks['where'])."\n".$indent.')';
474 474
 		}
475 475
 
476 476
 		return $sql;
@@ -497,7 +497,7 @@  discard block
 block discarded – undo
497 497
 	 *     @type string $where SQL fragment to append to the main WHERE clause.
498 498
 	 * }
499 499
 	 */
500
-	public function get_sql_for_clause( &$clause, $parent_query, $clause_key = '' ) {
500
+	public function get_sql_for_clause(&$clause, $parent_query, $clause_key = '') {
501 501
 		global $wpdb;
502 502
 
503 503
 		$sql_chunks = array(
@@ -505,20 +505,20 @@  discard block
 block discarded – undo
505 505
 			'join' => array(),
506 506
 		);
507 507
 
508
-		if ( isset( $clause['compare'] ) ) {
509
-			$clause['compare'] = strtoupper( $clause['compare'] );
508
+		if (isset($clause['compare'])) {
509
+			$clause['compare'] = strtoupper($clause['compare']);
510 510
 		} else {
511
-			$clause['compare'] = isset( $clause['value'] ) && is_array( $clause['value'] ) ? 'IN' : '=';
511
+			$clause['compare'] = isset($clause['value']) && is_array($clause['value']) ? 'IN' : '=';
512 512
 		}
513 513
 
514
-		if ( ! in_array( $clause['compare'], array(
514
+		if ( ! in_array($clause['compare'], array(
515 515
 			'=', '!=', '>', '>=', '<', '<=',
516 516
 			'LIKE', 'NOT LIKE',
517 517
 			'IN', 'NOT IN',
518 518
 			'BETWEEN', 'NOT BETWEEN',
519 519
 			'EXISTS', 'NOT EXISTS',
520 520
 			'REGEXP', 'NOT REGEXP', 'RLIKE'
521
-		) ) ) {
521
+		))) {
522 522
 			$clause['compare'] = '=';
523 523
 		}
524 524
 
@@ -528,16 +528,16 @@  discard block
 block discarded – undo
528 528
 		$join = '';
529 529
 
530 530
 		// We prefer to avoid joins if possible. Look for an existing join compatible with this clause.
531
-		$alias = $this->find_compatible_table_alias( $clause, $parent_query );
532
-		if ( false === $alias ) {
533
-			$i = count( $this->table_aliases );
534
-			$alias = $i ? 'mt' . $i : $this->meta_table;
531
+		$alias = $this->find_compatible_table_alias($clause, $parent_query);
532
+		if (false === $alias) {
533
+			$i = count($this->table_aliases);
534
+			$alias = $i ? 'mt'.$i : $this->meta_table;
535 535
 
536 536
 			// JOIN clauses for NOT EXISTS have their own syntax.
537
-			if ( 'NOT EXISTS' === $meta_compare ) {
537
+			if ('NOT EXISTS' === $meta_compare) {
538 538
 				$join .= " LEFT JOIN $this->meta_table";
539 539
 				$join .= $i ? " AS $alias" : '';
540
-				$join .= $wpdb->prepare( " ON ($this->primary_table.$this->primary_id_column = $alias.$this->meta_id_column AND $alias.meta_key = %s )", $clause['key'] );
540
+				$join .= $wpdb->prepare(" ON ($this->primary_table.$this->primary_id_column = $alias.$this->meta_id_column AND $alias.meta_key = %s )", $clause['key']);
541 541
 
542 542
 			// All other JOIN clauses.
543 543
 			} else {
@@ -554,72 +554,72 @@  discard block
 block discarded – undo
554 554
 		$clause['alias'] = $alias;
555 555
 
556 556
 		// Determine the data type.
557
-		$_meta_type = isset( $clause['type'] ) ? $clause['type'] : '';
558
-		$meta_type  = $this->get_cast_for_type( $_meta_type );
557
+		$_meta_type = isset($clause['type']) ? $clause['type'] : '';
558
+		$meta_type  = $this->get_cast_for_type($_meta_type);
559 559
 		$clause['cast'] = $meta_type;
560 560
 
561 561
 		// Fallback for clause keys is the table alias. Key must be a string.
562
-		if ( is_int( $clause_key ) || ! $clause_key ) {
562
+		if (is_int($clause_key) || ! $clause_key) {
563 563
 			$clause_key = $clause['alias'];
564 564
 		}
565 565
 
566 566
 		// Ensure unique clause keys, so none are overwritten.
567 567
 		$iterator = 1;
568 568
 		$clause_key_base = $clause_key;
569
-		while ( isset( $this->clauses[ $clause_key ] ) ) {
570
-			$clause_key = $clause_key_base . '-' . $iterator;
569
+		while (isset($this->clauses[$clause_key])) {
570
+			$clause_key = $clause_key_base.'-'.$iterator;
571 571
 			$iterator++;
572 572
 		}
573 573
 
574 574
 		// Store the clause in our flat array.
575
-		$this->clauses[ $clause_key ] =& $clause;
575
+		$this->clauses[$clause_key] = & $clause;
576 576
 
577 577
 		// Next, build the WHERE clause.
578 578
 
579 579
 		// meta_key.
580
-		if ( array_key_exists( 'key', $clause ) ) {
581
-			if ( 'NOT EXISTS' === $meta_compare ) {
582
-				$sql_chunks['where'][] = $alias . '.' . $this->meta_id_column . ' IS NULL';
580
+		if (array_key_exists('key', $clause)) {
581
+			if ('NOT EXISTS' === $meta_compare) {
582
+				$sql_chunks['where'][] = $alias.'.'.$this->meta_id_column.' IS NULL';
583 583
 			} else {
584
-				$sql_chunks['where'][] = $wpdb->prepare( "$alias.meta_key = %s", trim( $clause['key'] ) );
584
+				$sql_chunks['where'][] = $wpdb->prepare("$alias.meta_key = %s", trim($clause['key']));
585 585
 			}
586 586
 		}
587 587
 
588 588
 		// meta_value.
589
-		if ( array_key_exists( 'value', $clause ) ) {
589
+		if (array_key_exists('value', $clause)) {
590 590
 			$meta_value = $clause['value'];
591 591
 
592
-			if ( in_array( $meta_compare, array( 'IN', 'NOT IN', 'BETWEEN', 'NOT BETWEEN' ) ) ) {
593
-				if ( ! is_array( $meta_value ) ) {
594
-					$meta_value = preg_split( '/[,\s]+/', $meta_value );
592
+			if (in_array($meta_compare, array('IN', 'NOT IN', 'BETWEEN', 'NOT BETWEEN'))) {
593
+				if ( ! is_array($meta_value)) {
594
+					$meta_value = preg_split('/[,\s]+/', $meta_value);
595 595
 				}
596 596
 			} else {
597
-				$meta_value = trim( $meta_value );
597
+				$meta_value = trim($meta_value);
598 598
 			}
599 599
 
600
-			switch ( $meta_compare ) {
600
+			switch ($meta_compare) {
601 601
 				case 'IN' :
602 602
 				case 'NOT IN' :
603
-					$meta_compare_string = '(' . substr( str_repeat( ',%s', count( $meta_value ) ), 1 ) . ')';
604
-					$where = $wpdb->prepare( $meta_compare_string, $meta_value );
603
+					$meta_compare_string = '('.substr(str_repeat(',%s', count($meta_value)), 1).')';
604
+					$where = $wpdb->prepare($meta_compare_string, $meta_value);
605 605
 					break;
606 606
 
607 607
 				case 'BETWEEN' :
608 608
 				case 'NOT BETWEEN' :
609
-					$meta_value = array_slice( $meta_value, 0, 2 );
610
-					$where = $wpdb->prepare( '%s AND %s', $meta_value );
609
+					$meta_value = array_slice($meta_value, 0, 2);
610
+					$where = $wpdb->prepare('%s AND %s', $meta_value);
611 611
 					break;
612 612
 
613 613
 				case 'LIKE' :
614 614
 				case 'NOT LIKE' :
615
-					$meta_value = '%' . $wpdb->esc_like( $meta_value ) . '%';
616
-					$where = $wpdb->prepare( '%s', $meta_value );
615
+					$meta_value = '%'.$wpdb->esc_like($meta_value).'%';
616
+					$where = $wpdb->prepare('%s', $meta_value);
617 617
 					break;
618 618
 
619 619
 				// EXISTS with a value is interpreted as '='.
620 620
 				case 'EXISTS' :
621 621
 					$meta_compare = '=';
622
-					$where = $wpdb->prepare( '%s', $meta_value );
622
+					$where = $wpdb->prepare('%s', $meta_value);
623 623
 					break;
624 624
 
625 625
 				// 'value' is ignored for NOT EXISTS.
@@ -628,13 +628,13 @@  discard block
 block discarded – undo
628 628
 					break;
629 629
 
630 630
 				default :
631
-					$where = $wpdb->prepare( '%s', $meta_value );
631
+					$where = $wpdb->prepare('%s', $meta_value);
632 632
 					break;
633 633
 
634 634
 			}
635 635
 
636
-			if ( $where ) {
637
-				if ( 'CHAR' === $meta_type ) {
636
+			if ($where) {
637
+				if ('CHAR' === $meta_type) {
638 638
 					$sql_chunks['where'][] = "$alias.meta_value {$meta_compare} {$where}";
639 639
 				} else {
640 640
 					$sql_chunks['where'][] = "CAST($alias.meta_value AS {$meta_type}) {$meta_compare} {$where}";
@@ -646,8 +646,8 @@  discard block
 block discarded – undo
646 646
 		 * Multiple WHERE clauses (for meta_key and meta_value) should
647 647
 		 * be joined in parentheses.
648 648
 		 */
649
-		if ( 1 < count( $sql_chunks['where'] ) ) {
650
-			$sql_chunks['where'] = array( '( ' . implode( ' AND ', $sql_chunks['where'] ) . ' )' );
649
+		if (1 < count($sql_chunks['where'])) {
650
+			$sql_chunks['where'] = array('( '.implode(' AND ', $sql_chunks['where']).' )');
651 651
 		}
652 652
 
653 653
 		return $sql_chunks;
@@ -689,34 +689,34 @@  discard block
 block discarded – undo
689 689
 	 * @param  array       $parent_query Parent query of $clause.
690 690
 	 * @return string|bool Table alias if found, otherwise false.
691 691
 	 */
692
-	protected function find_compatible_table_alias( $clause, $parent_query ) {
692
+	protected function find_compatible_table_alias($clause, $parent_query) {
693 693
 		$alias = false;
694 694
 
695
-		foreach ( $parent_query as $sibling ) {
695
+		foreach ($parent_query as $sibling) {
696 696
 			// If the sibling has no alias yet, there's nothing to check.
697
-			if ( empty( $sibling['alias'] ) ) {
697
+			if (empty($sibling['alias'])) {
698 698
 				continue;
699 699
 			}
700 700
 
701 701
 			// We're only interested in siblings that are first-order clauses.
702
-			if ( ! is_array( $sibling ) || ! $this->is_first_order_clause( $sibling ) ) {
702
+			if ( ! is_array($sibling) || ! $this->is_first_order_clause($sibling)) {
703 703
 				continue;
704 704
 			}
705 705
 
706 706
 			$compatible_compares = array();
707 707
 
708 708
 			// Clauses connected by OR can share joins as long as they have "positive" operators.
709
-			if ( 'OR' === $parent_query['relation'] ) {
710
-				$compatible_compares = array( '=', 'IN', 'BETWEEN', 'LIKE', 'REGEXP', 'RLIKE', '>', '>=', '<', '<=' );
709
+			if ('OR' === $parent_query['relation']) {
710
+				$compatible_compares = array('=', 'IN', 'BETWEEN', 'LIKE', 'REGEXP', 'RLIKE', '>', '>=', '<', '<=');
711 711
 
712 712
 			// Clauses joined by AND with "negative" operators share a join only if they also share a key.
713
-			} elseif ( isset( $sibling['key'] ) && isset( $clause['key'] ) && $sibling['key'] === $clause['key'] ) {
714
-				$compatible_compares = array( '!=', 'NOT IN', 'NOT LIKE' );
713
+			} elseif (isset($sibling['key']) && isset($clause['key']) && $sibling['key'] === $clause['key']) {
714
+				$compatible_compares = array('!=', 'NOT IN', 'NOT LIKE');
715 715
 			}
716 716
 
717
-			$clause_compare  = strtoupper( $clause['compare'] );
718
-			$sibling_compare = strtoupper( $sibling['compare'] );
719
-			if ( in_array( $clause_compare, $compatible_compares ) && in_array( $sibling_compare, $compatible_compares ) ) {
717
+			$clause_compare  = strtoupper($clause['compare']);
718
+			$sibling_compare = strtoupper($sibling['compare']);
719
+			if (in_array($clause_compare, $compatible_compares) && in_array($sibling_compare, $compatible_compares)) {
720 720
 				$alias = $sibling['alias'];
721 721
 				break;
722 722
 			}
@@ -732,7 +732,7 @@  discard block
 block discarded – undo
732 732
 		 * @param array       $parent_query Parent of $clause.
733 733
 		 * @param object      $this         WP_Meta_Query object.
734 734
 		 */
735
-		return apply_filters( 'meta_query_find_compatible_table_alias', $alias, $clause, $parent_query, $this ) ;
735
+		return apply_filters('meta_query_find_compatible_table_alias', $alias, $clause, $parent_query, $this);
736 736
 	}
737 737
 
738 738
 	/**
Please login to merge, or discard this patch.
src/wp-includes/theme-compat/footer-embed.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -16,7 +16,7 @@
 block discarded – undo
16 16
  *
17 17
  * @since 4.4.0
18 18
  */
19
-do_action( 'embed_footer' );
19
+do_action('embed_footer');
20 20
 ?>
21 21
 </body>
22 22
 </html>
Please login to merge, or discard this patch.
src/wp-includes/theme-compat/comments.php 2 patches
Braces   +8 added lines, -4 removed lines patch added patch discarded remove patch
@@ -17,8 +17,9 @@  discard block
 block discarded – undo
17 17
 );
18 18
 
19 19
 // Do not delete these lines
20
-	if (!empty($_SERVER['SCRIPT_FILENAME']) && 'comments.php' == basename($_SERVER['SCRIPT_FILENAME']))
21
-		die ('Please do not load this page directly. Thanks!');
20
+	if (!empty($_SERVER['SCRIPT_FILENAME']) && 'comments.php' == basename($_SERVER['SCRIPT_FILENAME'])) {
21
+			die ('Please do not load this page directly. Thanks!');
22
+	}
22 23
 
23 24
 	if ( post_password_required() ) { ?>
24 25
 		<p class="nocomments"><?php _e('This post is password protected. Enter the password to view comments.'); ?></p>
@@ -56,14 +57,17 @@  discard block
 block discarded – undo
56 57
 		<div class="alignleft"><?php previous_comments_link() ?></div>
57 58
 		<div class="alignright"><?php next_comments_link() ?></div>
58 59
 	</div>
59
- <?php else : // this is displayed if there are no comments so far ?>
60
+ <?php else {
61
+	: // this is displayed if there are no comments so far ?>
60 62
 
61 63
 	<?php if ( comments_open() ) : ?>
62 64
 		<!-- If comments are open, but there are no comments. -->
63 65
 
64 66
 	 <?php else : // comments are closed ?>
65 67
 		<!-- If comments are closed. -->
66
-		<p class="nocomments"><?php _e('Comments are closed.'); ?></p>
68
+		<p class="nocomments"><?php _e('Comments are closed.');
69
+}
70
+?></p>
67 71
 
68 72
 	<?php endif; ?>
69 73
 <?php endif; ?>
Please login to merge, or discard this patch.
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -9,18 +9,18 @@  discard block
 block discarded – undo
9 9
  */
10 10
 _deprecated_file(
11 11
 	/* translators: %s: template name */
12
-	sprintf( __( 'Theme without %s' ), basename( __FILE__ ) ),
12
+	sprintf(__('Theme without %s'), basename(__FILE__)),
13 13
 	'3.0.0',
14 14
 	null,
15 15
 	/* translators: %s: template name */
16
-	sprintf( __( 'Please include a %s template in your theme.' ), basename( __FILE__ ) )
16
+	sprintf(__('Please include a %s template in your theme.'), basename(__FILE__))
17 17
 );
18 18
 
19 19
 // Do not delete these lines
20
-	if (!empty($_SERVER['SCRIPT_FILENAME']) && 'comments.php' == basename($_SERVER['SCRIPT_FILENAME']))
20
+	if ( ! empty($_SERVER['SCRIPT_FILENAME']) && 'comments.php' == basename($_SERVER['SCRIPT_FILENAME']))
21 21
 		die ('Please do not load this page directly. Thanks!');
22 22
 
23
-	if ( post_password_required() ) { ?>
23
+	if (post_password_required()) { ?>
24 24
 		<p class="nocomments"><?php _e('This post is password protected. Enter the password to view comments.'); ?></p>
25 25
 	<?php
26 26
 		return;
@@ -29,16 +29,16 @@  discard block
 block discarded – undo
29 29
 
30 30
 <!-- You can start editing here. -->
31 31
 
32
-<?php if ( have_comments() ) : ?>
32
+<?php if (have_comments()) : ?>
33 33
 	<h3 id="comments">
34 34
 		<?php
35
-			if ( 1 == get_comments_number() ) {
35
+			if (1 == get_comments_number()) {
36 36
 				/* translators: %s: post title */
37
-				printf( __( 'One response to %s' ),  '&#8220;' . get_the_title() . '&#8221;' );
37
+				printf(__('One response to %s'), '&#8220;'.get_the_title().'&#8221;');
38 38
 			} else {
39 39
 				/* translators: 1: number of comments, 2: post title */
40
-				printf( _n( '%1$s response to %2$s', '%1$s responses to %2$s', get_comments_number() ),
41
-					number_format_i18n( get_comments_number() ),  '&#8220;' . get_the_title() . '&#8221;' );
40
+				printf(_n('%1$s response to %2$s', '%1$s responses to %2$s', get_comments_number()),
41
+					number_format_i18n(get_comments_number()), '&#8220;'.get_the_title().'&#8221;');
42 42
 			}
43 43
 		?>
44 44
 	</h3>
@@ -49,7 +49,7 @@  discard block
 block discarded – undo
49 49
 	</div>
50 50
 
51 51
 	<ol class="commentlist">
52
-	<?php wp_list_comments();?>
52
+	<?php wp_list_comments(); ?>
53 53
 	</ol>
54 54
 
55 55
 	<div class="navigation">
@@ -58,7 +58,7 @@  discard block
 block discarded – undo
58 58
 	</div>
59 59
  <?php else : // this is displayed if there are no comments so far ?>
60 60
 
61
-	<?php if ( comments_open() ) : ?>
61
+	<?php if (comments_open()) : ?>
62 62
 		<!-- If comments are open, but there are no comments. -->
63 63
 
64 64
 	 <?php else : // comments are closed ?>
Please login to merge, or discard this patch.
src/wp-includes/theme-compat/embed-404.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -12,15 +12,15 @@  discard block
 block discarded – undo
12 12
  */
13 13
 ?>
14 14
 <div class="wp-embed">
15
-	<p class="wp-embed-heading"><?php _e( 'Oops! That embed can&#8217;t be found.' ); ?></p>
15
+	<p class="wp-embed-heading"><?php _e('Oops! That embed can&#8217;t be found.'); ?></p>
16 16
 
17 17
 	<div class="wp-embed-excerpt">
18 18
 		<p>
19 19
 			<?php
20 20
 			printf(
21 21
 				/* translators: %s: a link to the embedded site */
22
-				__( 'It looks like nothing was found at this location. Maybe try visiting %s directly?' ),
23
-				'<strong><a href="' . esc_url( home_url() ) . '">' . esc_html( get_bloginfo( 'name' ) ) . '</a></strong>'
22
+				__('It looks like nothing was found at this location. Maybe try visiting %s directly?'),
23
+				'<strong><a href="'.esc_url(home_url()).'">'.esc_html(get_bloginfo('name')).'</a></strong>'
24 24
 			);
25 25
 			?>
26 26
 		</p>
@@ -28,7 +28,7 @@  discard block
 block discarded – undo
28 28
 
29 29
 	<?php
30 30
 	/** This filter is documented in wp-includes/theme-compat/embed-content.php */
31
-	do_action( 'embed_content' );
31
+	do_action('embed_content');
32 32
 	?>
33 33
 
34 34
 	<div class="wp-embed-footer">
Please login to merge, or discard this patch.
src/wp-includes/theme-compat/header-embed.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -11,8 +11,8 @@  discard block
 block discarded – undo
11 11
  * @since 4.5.0
12 12
  */
13 13
 
14
-if ( ! headers_sent() ) {
15
-	header( 'X-WP-embed: true' );
14
+if ( ! headers_sent()) {
15
+	header('X-WP-embed: true');
16 16
 }
17 17
 
18 18
 ?>
@@ -27,7 +27,7 @@  discard block
 block discarded – undo
27 27
 	 *
28 28
 	 * @since 4.4.0
29 29
 	 */
30
-	do_action( 'embed_head' );
30
+	do_action('embed_head');
31 31
 	?>
32 32
 </head>
33 33
 <body <?php body_class(); ?>>
Please login to merge, or discard this patch.
src/wp-includes/theme-compat/embed.php 2 patches
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -10,14 +10,14 @@
 block discarded – undo
10 10
  * @since 4.4.0
11 11
  */
12 12
 
13
-get_header( 'embed' );
13
+get_header('embed');
14 14
 
15
-if ( have_posts() ) :
16
-	while ( have_posts() ) : the_post();
17
-		get_template_part( 'embed', 'content' );
15
+if (have_posts()) :
16
+	while (have_posts()) : the_post();
17
+		get_template_part('embed', 'content');
18 18
 	endwhile;
19 19
 else :
20
-	get_template_part( 'embed', '404' );
20
+	get_template_part('embed', '404');
21 21
 endif;
22 22
 
23
-get_footer( 'embed' );
23
+get_footer('embed');
Please login to merge, or discard this patch.
Braces   +3 added lines, -1 removed lines patch added patch discarded remove patch
@@ -16,8 +16,10 @@
 block discarded – undo
16 16
 	while ( have_posts() ) : the_post();
17 17
 		get_template_part( 'embed', 'content' );
18 18
 	endwhile;
19
-else :
19
+else {
20
+	:
20 21
 	get_template_part( 'embed', '404' );
22
+}
21 23
 endif;
22 24
 
23 25
 get_footer( 'embed' );
Please login to merge, or discard this patch.
src/wp-includes/class-walker-category-dropdown.php 2 patches
Braces   +6 added lines, -4 removed lines patch added patch discarded remove patch
@@ -58,12 +58,14 @@
 block discarded – undo
58 58
 		$output .= "\t<option class=\"level-$depth\" value=\"" . esc_attr( $category->{$value_field} ) . "\"";
59 59
 
60 60
 		// Type-juggling causes false matches, so we force everything to a string.
61
-		if ( (string) $category->{$value_field} === (string) $args['selected'] )
62
-			$output .= ' selected="selected"';
61
+		if ( (string) $category->{$value_field} === (string) $args['selected'] ) {
62
+					$output .= ' selected="selected"';
63
+		}
63 64
 		$output .= '>';
64 65
 		$output .= $pad.$cat_name;
65
-		if ( $args['show_count'] )
66
-			$output .= '&nbsp;&nbsp;('. number_format_i18n( $category->count ) .')';
66
+		if ( $args['show_count'] ) {
67
+					$output .= '&nbsp;&nbsp;('. number_format_i18n( $category->count ) .')';
68
+		}
67 69
 		$output .= "</option>\n";
68 70
 	}
69 71
 }
Please login to merge, or discard this patch.
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -37,7 +37,7 @@  discard block
 block discarded – undo
37 37
 	 *
38 38
 	 * @see Walker::$db_fields
39 39
 	 */
40
-	public $db_fields = array ('parent' => 'parent', 'id' => 'term_id');
40
+	public $db_fields = array('parent' => 'parent', 'id' => 'term_id');
41 41
 
42 42
 	/**
43 43
 	 * Starts the element output.
@@ -54,27 +54,27 @@  discard block
 block discarded – undo
54 54
 	 *                         See wp_dropdown_categories().
55 55
 	 * @param int    $id       Optional. ID of the current category. Default 0 (unused).
56 56
 	 */
57
-	public function start_el( &$output, $category, $depth = 0, $args = array(), $id = 0 ) {
57
+	public function start_el(&$output, $category, $depth = 0, $args = array(), $id = 0) {
58 58
 		$pad = str_repeat('&nbsp;', $depth * 3);
59 59
 
60 60
 		/** This filter is documented in wp-includes/category-template.php */
61
-		$cat_name = apply_filters( 'list_cats', $category->name, $category );
61
+		$cat_name = apply_filters('list_cats', $category->name, $category);
62 62
 
63
-		if ( isset( $args['value_field'] ) && isset( $category->{$args['value_field']} ) ) {
63
+		if (isset($args['value_field']) && isset($category->{$args['value_field']} )) {
64 64
 			$value_field = $args['value_field'];
65 65
 		} else {
66 66
 			$value_field = 'term_id';
67 67
 		}
68 68
 
69
-		$output .= "\t<option class=\"level-$depth\" value=\"" . esc_attr( $category->{$value_field} ) . "\"";
69
+		$output .= "\t<option class=\"level-$depth\" value=\"".esc_attr($category->{$value_field} )."\"";
70 70
 
71 71
 		// Type-juggling causes false matches, so we force everything to a string.
72
-		if ( (string) $category->{$value_field} === (string) $args['selected'] )
72
+		if ((string) $category->{$value_field} === (string) $args['selected'])
73 73
 			$output .= ' selected="selected"';
74 74
 		$output .= '>';
75 75
 		$output .= $pad.$cat_name;
76
-		if ( $args['show_count'] )
77
-			$output .= '&nbsp;&nbsp;('. number_format_i18n( $category->count ) .')';
76
+		if ($args['show_count'])
77
+			$output .= '&nbsp;&nbsp;('.number_format_i18n($category->count).')';
78 78
 		$output .= "</option>\n";
79 79
 	}
80 80
 }
Please login to merge, or discard this patch.
src/wp-includes/class-wp-widget.php 3 patches
Braces   +14 added lines, -10 removed lines patch added patch discarded remove patch
@@ -382,21 +382,24 @@  discard block
 block discarded – undo
382 382
 		$all_instances = $this->get_settings();
383 383
 
384 384
 		// We need to update the data
385
-		if ( $this->updated )
386
-			return;
385
+		if ( $this->updated ) {
386
+					return;
387
+		}
387 388
 
388 389
 		if ( isset($_POST['delete_widget']) && $_POST['delete_widget'] ) {
389 390
 			// Delete the settings for this instance of the widget
390
-			if ( isset($_POST['the-widget-id']) )
391
-				$del_id = $_POST['the-widget-id'];
392
-			else
393
-				return;
391
+			if ( isset($_POST['the-widget-id']) ) {
392
+							$del_id = $_POST['the-widget-id'];
393
+			} else {
394
+							return;
395
+			}
394 396
 
395 397
 			if ( isset($wp_registered_widgets[$del_id]['params'][0]['number']) ) {
396 398
 				$number = $wp_registered_widgets[$del_id]['params'][0]['number'];
397 399
 
398
-				if ( $this->id_base . '-' . $number == $del_id )
399
-					unset($all_instances[$number]);
400
+				if ( $this->id_base . '-' . $number == $del_id ) {
401
+									unset($all_instances[$number]);
402
+				}
400 403
 			}
401 404
 		} else {
402 405
 			if ( isset($_POST['widget-' . $this->id_base]) && is_array($_POST['widget-' . $this->id_base]) ) {
@@ -461,8 +464,9 @@  discard block
 block discarded – undo
461 464
 	 * @return string|null
462 465
 	 */
463 466
 	public function form_callback( $widget_args = 1 ) {
464
-		if ( is_numeric($widget_args) )
465
-			$widget_args = array( 'number' => $widget_args );
467
+		if ( is_numeric($widget_args) ) {
468
+					$widget_args = array( 'number' => $widget_args );
469
+		}
466 470
 
467 471
 		$widget_args = wp_parse_args( $widget_args, array( 'number' => -1 ) );
468 472
 		$all_instances = $this->get_settings();
Please login to merge, or discard this patch.
Doc Comments   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -333,7 +333,7 @@  discard block
 block discarded – undo
333 333
 	 *
334 334
 	 * @param array     $args        Display arguments. See WP_Widget::widget() for information
335 335
 	 *                               on accepted arguments.
336
-	 * @param int|array $widget_args {
336
+	 * @param integer $widget_args {
337 337
 	 *     Optional. Internal order number of the widget instance, or array of multi-widget arguments.
338 338
 	 *     Default 1.
339 339
 	 *
@@ -473,7 +473,7 @@  discard block
 block discarded – undo
473 473
 	 * @since 2.8.0
474 474
 	 * @access public
475 475
 	 *
476
-	 * @param int|array $widget_args {
476
+	 * @param integer $widget_args {
477 477
 	 *     Optional. Internal order number of the widget instance, or array of multi-widget arguments.
478 478
 	 *     Default 1.
479 479
 	 *
Please login to merge, or discard this patch.
Spacing   +82 added lines, -82 removed lines patch added patch discarded remove patch
@@ -119,7 +119,7 @@  discard block
 block discarded – undo
119 119
 	 *                        'before_widget', and 'after_widget'.
120 120
 	 * @param array $instance The settings for the particular instance of the widget.
121 121
 	 */
122
-	public function widget( $args, $instance ) {
122
+	public function widget($args, $instance) {
123 123
 		die('function WP_Widget::widget() must be over-ridden in a sub-class.');
124 124
 	}
125 125
 
@@ -138,7 +138,7 @@  discard block
 block discarded – undo
138 138
 	 * @param array $old_instance Old settings for this instance.
139 139
 	 * @return array Settings to save or bool false to cancel saving.
140 140
 	 */
141
-	public function update( $new_instance, $old_instance ) {
141
+	public function update($new_instance, $old_instance) {
142 142
 		return $new_instance;
143 143
 	}
144 144
 
@@ -151,8 +151,8 @@  discard block
 block discarded – undo
151 151
 	 * @param array $instance Current settings.
152 152
 	 * @return string Default return is 'noform'.
153 153
 	 */
154
-	public function form( $instance ) {
155
-		echo '<p class="no-options-widget">' . __('There are no options for this widget.') . '</p>';
154
+	public function form($instance) {
155
+		echo '<p class="no-options-widget">'.__('There are no options for this widget.').'</p>';
156 156
 		return 'noform';
157 157
 	}
158 158
 
@@ -172,12 +172,12 @@  discard block
 block discarded – undo
172 172
 	 * @param array  $control_options Optional. Widget control options. See wp_register_widget_control() for
173 173
 	 *                                information on accepted arguments. Default empty array.
174 174
 	 */
175
-	public function __construct( $id_base, $name, $widget_options = array(), $control_options = array() ) {
176
-		$this->id_base = empty($id_base) ? preg_replace( '/(wp_)?widget_/', '', strtolower(get_class($this)) ) : strtolower($id_base);
175
+	public function __construct($id_base, $name, $widget_options = array(), $control_options = array()) {
176
+		$this->id_base = empty($id_base) ? preg_replace('/(wp_)?widget_/', '', strtolower(get_class($this))) : strtolower($id_base);
177 177
 		$this->name = $name;
178
-		$this->option_name = 'widget_' . $this->id_base;
179
-		$this->widget_options = wp_parse_args( $widget_options, array( 'classname' => $this->option_name, 'customize_selective_refresh' => false ) );
180
-		$this->control_options = wp_parse_args( $control_options, array( 'id_base' => $this->id_base ) );
178
+		$this->option_name = 'widget_'.$this->id_base;
179
+		$this->widget_options = wp_parse_args($widget_options, array('classname' => $this->option_name, 'customize_selective_refresh' => false));
180
+		$this->control_options = wp_parse_args($control_options, array('id_base' => $this->id_base));
181 181
 	}
182 182
 
183 183
 	/**
@@ -196,9 +196,9 @@  discard block
 block discarded – undo
196 196
 	 * @param array  $control_options Optional. Widget control options. See wp_register_widget_control() for
197 197
 	 *                                information on accepted arguments. Default empty array.
198 198
 	 */
199
-	public function WP_Widget( $id_base, $name, $widget_options = array(), $control_options = array() ) {
200
-		_deprecated_constructor( 'WP_Widget', '4.3.0', get_class( $this ) );
201
-		WP_Widget::__construct( $id_base, $name, $widget_options, $control_options );
199
+	public function WP_Widget($id_base, $name, $widget_options = array(), $control_options = array()) {
200
+		_deprecated_constructor('WP_Widget', '4.3.0', get_class($this));
201
+		WP_Widget::__construct($id_base, $name, $widget_options, $control_options);
202 202
 	}
203 203
 
204 204
 	/**
@@ -215,10 +215,10 @@  discard block
 block discarded – undo
215 215
 	 * @return string Name attribute for $field_name
216 216
 	 */
217 217
 	public function get_field_name($field_name) {
218
-		if ( false === $pos = strpos( $field_name, '[' ) ) {
219
-			return 'widget-' . $this->id_base . '[' . $this->number . '][' . $field_name . ']';
218
+		if (false === $pos = strpos($field_name, '[')) {
219
+			return 'widget-'.$this->id_base.'['.$this->number.']['.$field_name.']';
220 220
 		} else {
221
-			return 'widget-' . $this->id_base . '[' . $this->number . '][' . substr_replace( $field_name, '][', $pos, strlen( '[' ) );
221
+			return 'widget-'.$this->id_base.'['.$this->number.']['.substr_replace($field_name, '][', $pos, strlen('['));
222 222
 		}
223 223
 	}
224 224
 
@@ -235,8 +235,8 @@  discard block
 block discarded – undo
235 235
 	 * @param string $field_name Field name.
236 236
 	 * @return string ID attribute for `$field_name`.
237 237
 	 */
238
-	public function get_field_id( $field_name ) {
239
-		return 'widget-' . $this->id_base . '-' . $this->number . '-' . trim( str_replace( array( '[]', '[', ']' ), array( '', '-', '' ), $field_name ), '-' );
238
+	public function get_field_id($field_name) {
239
+		return 'widget-'.$this->id_base.'-'.$this->number.'-'.trim(str_replace(array('[]', '[', ']'), array('', '-', ''), $field_name), '-');
240 240
 	}
241 241
 
242 242
 	/**
@@ -250,23 +250,23 @@  discard block
 block discarded – undo
250 250
 		$empty = true;
251 251
 
252 252
 		// When $settings is an array-like object, get an intrinsic array for use with array_keys().
253
-		if ( $settings instanceof ArrayObject || $settings instanceof ArrayIterator ) {
253
+		if ($settings instanceof ArrayObject || $settings instanceof ArrayIterator) {
254 254
 			$settings = $settings->getArrayCopy();
255 255
 		}
256 256
 
257
-		if ( is_array( $settings ) ) {
258
-			foreach ( array_keys( $settings ) as $number ) {
259
-				if ( is_numeric( $number ) ) {
260
-					$this->_set( $number );
261
-					$this->_register_one( $number );
257
+		if (is_array($settings)) {
258
+			foreach (array_keys($settings) as $number) {
259
+				if (is_numeric($number)) {
260
+					$this->_set($number);
261
+					$this->_register_one($number);
262 262
 					$empty = false;
263 263
 				}
264 264
 			}
265 265
 		}
266 266
 
267
-		if ( $empty ) {
267
+		if ($empty) {
268 268
 			// If there are none, we register the widget's existence with a generic template.
269
-			$this->_set( 1 );
269
+			$this->_set(1);
270 270
 			$this->_register_one();
271 271
 		}
272 272
 	}
@@ -282,7 +282,7 @@  discard block
 block discarded – undo
282 282
 	 */
283 283
 	public function _set($number) {
284 284
 		$this->number = $number;
285
-		$this->id = $this->id_base . '-' . $number;
285
+		$this->id = $this->id_base.'-'.$number;
286 286
 	}
287 287
 
288 288
 	/**
@@ -338,7 +338,7 @@  discard block
 block discarded – undo
338 338
 	 */
339 339
 	public function is_preview() {
340 340
 		global $wp_customize;
341
-		return ( isset( $wp_customize ) && $wp_customize->is_preview() ) ;
341
+		return (isset($wp_customize) && $wp_customize->is_preview());
342 342
 	}
343 343
 
344 344
 	/**
@@ -358,17 +358,17 @@  discard block
 block discarded – undo
358 358
 	 *     @type int $number Number increment used for multiples of the same widget.
359 359
 	 * }
360 360
 	 */
361
-	public function display_callback( $args, $widget_args = 1 ) {
362
-		if ( is_numeric( $widget_args ) ) {
363
-			$widget_args = array( 'number' => $widget_args );
361
+	public function display_callback($args, $widget_args = 1) {
362
+		if (is_numeric($widget_args)) {
363
+			$widget_args = array('number' => $widget_args);
364 364
 		}
365 365
 
366
-		$widget_args = wp_parse_args( $widget_args, array( 'number' => -1 ) );
367
-		$this->_set( $widget_args['number'] );
366
+		$widget_args = wp_parse_args($widget_args, array('number' => -1));
367
+		$this->_set($widget_args['number']);
368 368
 		$instances = $this->get_settings();
369 369
 
370
-		if ( array_key_exists( $this->number, $instances ) ) {
371
-			$instance = $instances[ $this->number ];
370
+		if (array_key_exists($this->number, $instances)) {
371
+			$instance = $instances[$this->number];
372 372
 
373 373
 			/**
374 374
 			 * Filters the settings for a particular widget instance.
@@ -381,21 +381,21 @@  discard block
 block discarded – undo
381 381
 			 * @param WP_Widget $this     The current widget instance.
382 382
 			 * @param array     $args     An array of default widget arguments.
383 383
 			 */
384
-			$instance = apply_filters( 'widget_display_callback', $instance, $this, $args );
384
+			$instance = apply_filters('widget_display_callback', $instance, $this, $args);
385 385
 
386
-			if ( false === $instance ) {
386
+			if (false === $instance) {
387 387
 				return;
388 388
 			}
389 389
 
390 390
 			$was_cache_addition_suspended = wp_suspend_cache_addition();
391
-			if ( $this->is_preview() && ! $was_cache_addition_suspended ) {
392
-				wp_suspend_cache_addition( true );
391
+			if ($this->is_preview() && ! $was_cache_addition_suspended) {
392
+				wp_suspend_cache_addition(true);
393 393
 			}
394 394
 
395
-			$this->widget( $args, $instance );
395
+			$this->widget($args, $instance);
396 396
 
397
-			if ( $this->is_preview() ) {
398
-				wp_suspend_cache_addition( $was_cache_addition_suspended );
397
+			if ($this->is_preview()) {
398
+				wp_suspend_cache_addition($was_cache_addition_suspended);
399 399
 			}
400 400
 		}
401 401
 	}
@@ -410,53 +410,53 @@  discard block
 block discarded – undo
410 410
 	 *
411 411
 	 * @param int $deprecated Not used.
412 412
 	 */
413
-	public function update_callback( $deprecated = 1 ) {
413
+	public function update_callback($deprecated = 1) {
414 414
 		global $wp_registered_widgets;
415 415
 
416 416
 		$all_instances = $this->get_settings();
417 417
 
418 418
 		// We need to update the data
419
-		if ( $this->updated )
419
+		if ($this->updated)
420 420
 			return;
421 421
 
422
-		if ( isset($_POST['delete_widget']) && $_POST['delete_widget'] ) {
422
+		if (isset($_POST['delete_widget']) && $_POST['delete_widget']) {
423 423
 			// Delete the settings for this instance of the widget
424
-			if ( isset($_POST['the-widget-id']) )
424
+			if (isset($_POST['the-widget-id']))
425 425
 				$del_id = $_POST['the-widget-id'];
426 426
 			else
427 427
 				return;
428 428
 
429
-			if ( isset($wp_registered_widgets[$del_id]['params'][0]['number']) ) {
429
+			if (isset($wp_registered_widgets[$del_id]['params'][0]['number'])) {
430 430
 				$number = $wp_registered_widgets[$del_id]['params'][0]['number'];
431 431
 
432
-				if ( $this->id_base . '-' . $number == $del_id )
432
+				if ($this->id_base.'-'.$number == $del_id)
433 433
 					unset($all_instances[$number]);
434 434
 			}
435 435
 		} else {
436
-			if ( isset($_POST['widget-' . $this->id_base]) && is_array($_POST['widget-' . $this->id_base]) ) {
437
-				$settings = $_POST['widget-' . $this->id_base];
438
-			} elseif ( isset($_POST['id_base']) && $_POST['id_base'] == $this->id_base ) {
436
+			if (isset($_POST['widget-'.$this->id_base]) && is_array($_POST['widget-'.$this->id_base])) {
437
+				$settings = $_POST['widget-'.$this->id_base];
438
+			} elseif (isset($_POST['id_base']) && $_POST['id_base'] == $this->id_base) {
439 439
 				$num = $_POST['multi_number'] ? (int) $_POST['multi_number'] : (int) $_POST['widget_number'];
440
-				$settings = array( $num => array() );
440
+				$settings = array($num => array());
441 441
 			} else {
442 442
 				return;
443 443
 			}
444 444
 
445
-			foreach ( $settings as $number => $new_instance ) {
445
+			foreach ($settings as $number => $new_instance) {
446 446
 				$new_instance = stripslashes_deep($new_instance);
447 447
 				$this->_set($number);
448 448
 
449 449
 				$old_instance = isset($all_instances[$number]) ? $all_instances[$number] : array();
450 450
 
451 451
 				$was_cache_addition_suspended = wp_suspend_cache_addition();
452
-				if ( $this->is_preview() && ! $was_cache_addition_suspended ) {
453
-					wp_suspend_cache_addition( true );
452
+				if ($this->is_preview() && ! $was_cache_addition_suspended) {
453
+					wp_suspend_cache_addition(true);
454 454
 				}
455 455
 
456
-				$instance = $this->update( $new_instance, $old_instance );
456
+				$instance = $this->update($new_instance, $old_instance);
457 457
 
458
-				if ( $this->is_preview() ) {
459
-					wp_suspend_cache_addition( $was_cache_addition_suspended );
458
+				if ($this->is_preview()) {
459
+					wp_suspend_cache_addition($was_cache_addition_suspended);
460 460
 				}
461 461
 
462 462
 				/**
@@ -472,8 +472,8 @@  discard block
 block discarded – undo
472 472
 				 * @param array     $old_instance Array of old widget settings.
473 473
 				 * @param WP_Widget $this         The current widget instance.
474 474
 				 */
475
-				$instance = apply_filters( 'widget_update_callback', $instance, $new_instance, $old_instance, $this );
476
-				if ( false !== $instance ) {
475
+				$instance = apply_filters('widget_update_callback', $instance, $new_instance, $old_instance, $this);
476
+				if (false !== $instance) {
477 477
 					$all_instances[$number] = $instance;
478 478
 				}
479 479
 
@@ -499,11 +499,11 @@  discard block
 block discarded – undo
499 499
 	 * }
500 500
 	 * @return string|null
501 501
 	 */
502
-	public function form_callback( $widget_args = 1 ) {
503
-		if ( is_numeric($widget_args) )
504
-			$widget_args = array( 'number' => $widget_args );
502
+	public function form_callback($widget_args = 1) {
503
+		if (is_numeric($widget_args))
504
+			$widget_args = array('number' => $widget_args);
505 505
 
506
-		$widget_args = wp_parse_args( $widget_args, array( 'number' => -1 ) );
506
+		$widget_args = wp_parse_args($widget_args, array('number' => -1));
507 507
 		$all_instances = $this->get_settings();
508 508
 
509 509
 		if ( -1 == $widget_args['number'] ) {
@@ -512,7 +512,7 @@  discard block
 block discarded – undo
512 512
 			$instance = array();
513 513
 		} else {
514 514
 			$this->_set($widget_args['number']);
515
-			$instance = $all_instances[ $widget_args['number'] ];
515
+			$instance = $all_instances[$widget_args['number']];
516 516
 		}
517 517
 
518 518
 		/**
@@ -525,10 +525,10 @@  discard block
 block discarded – undo
525 525
 		 * @param array     $instance The current widget instance's settings.
526 526
 		 * @param WP_Widget $this     The current widget instance.
527 527
 		 */
528
-		$instance = apply_filters( 'widget_form_callback', $instance, $this );
528
+		$instance = apply_filters('widget_form_callback', $instance, $this);
529 529
 
530 530
 		$return = null;
531
-		if ( false !== $instance ) {
531
+		if (false !== $instance) {
532 532
 			$return = $this->form($instance);
533 533
 
534 534
 			/**
@@ -547,7 +547,7 @@  discard block
 block discarded – undo
547 547
 			 * @param null      $return   Return null if new fields are added.
548 548
 			 * @param array     $instance An array of the widget's settings.
549 549
 			 */
550
-			do_action_ref_array( 'in_widget_form', array( &$this, &$return, $instance ) );
550
+			do_action_ref_array('in_widget_form', array(&$this, &$return, $instance));
551 551
 		}
552 552
 		return $return;
553 553
 	}
@@ -561,10 +561,10 @@  discard block
 block discarded – undo
561 561
 	 * @param integer $number Optional. The unique order number of this widget instance
562 562
 	 *                        compared to other instances of the same class. Default -1.
563 563
 	 */
564
-	public function _register_one( $number = -1 ) {
565
-		wp_register_sidebar_widget(	$this->id, $this->name,	$this->_get_display_callback(), $this->widget_options, array( 'number' => $number ) );
566
-		_register_widget_update_callback( $this->id_base, $this->_get_update_callback(), $this->control_options, array( 'number' => -1 ) );
567
-		_register_widget_form_callback(	$this->id, $this->name,	$this->_get_form_callback(), $this->control_options, array( 'number' => $number ) );
564
+	public function _register_one($number = -1) {
565
+		wp_register_sidebar_widget($this->id, $this->name, $this->_get_display_callback(), $this->widget_options, array('number' => $number));
566
+		_register_widget_update_callback($this->id_base, $this->_get_update_callback(), $this->control_options, array('number' => -1));
567
+		_register_widget_form_callback($this->id, $this->name, $this->_get_form_callback(), $this->control_options, array('number' => $number));
568 568
 	}
569 569
 
570 570
 	/**
@@ -575,9 +575,9 @@  discard block
 block discarded – undo
575 575
 	 *
576 576
 	 * @param array $settings Multi-dimensional array of widget instance settings.
577 577
 	 */
578
-	public function save_settings( $settings ) {
578
+	public function save_settings($settings) {
579 579
 		$settings['_multiwidget'] = 1;
580
-		update_option( $this->option_name, $settings );
580
+		update_option($this->option_name, $settings);
581 581
 	}
582 582
 
583 583
 	/**
@@ -590,27 +590,27 @@  discard block
 block discarded – undo
590 590
 	 */
591 591
 	public function get_settings() {
592 592
 
593
-		$settings = get_option( $this->option_name );
593
+		$settings = get_option($this->option_name);
594 594
 
595
-		if ( false === $settings ) {
596
-			if ( isset( $this->alt_option_name ) ) {
597
-				$settings = get_option( $this->alt_option_name );
595
+		if (false === $settings) {
596
+			if (isset($this->alt_option_name)) {
597
+				$settings = get_option($this->alt_option_name);
598 598
 			} else {
599 599
 				// Save an option so it can be autoloaded next time.
600
-				$this->save_settings( array() );
600
+				$this->save_settings(array());
601 601
 			}
602 602
 		}
603 603
 
604
-		if ( ! is_array( $settings ) && ! ( $settings instanceof ArrayObject || $settings instanceof ArrayIterator ) ) {
604
+		if ( ! is_array($settings) && ! ($settings instanceof ArrayObject || $settings instanceof ArrayIterator)) {
605 605
 			$settings = array();
606 606
 		}
607 607
 
608
-		if ( ! empty( $settings ) && ! isset( $settings['_multiwidget'] ) ) {
608
+		if ( ! empty($settings) && ! isset($settings['_multiwidget'])) {
609 609
 			// Old format, convert if single widget.
610
-			$settings = wp_convert_widget_settings( $this->id_base, $this->option_name, $settings );
610
+			$settings = wp_convert_widget_settings($this->id_base, $this->option_name, $settings);
611 611
 		}
612 612
 
613
-		unset( $settings['_multiwidget'], $settings['__i__'] );
613
+		unset($settings['_multiwidget'], $settings['__i__']);
614 614
 		return $settings;
615 615
 	}
616 616
 }
Please login to merge, or discard this patch.