Completed
Push — master ( d99bf9...491baf )
by Stephen
13:47
created
src/wp-includes/class-wp-image-editor-imagick.php 3 patches
Doc Comments   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -292,7 +292,7 @@  discard block
 block discarded – undo
292 292
 	 * @param int    $dst_h       The destination height.
293 293
 	 * @param string $filter_name Optional. The Imagick filter to use when resizing. Default 'FILTER_TRIANGLE'.
294 294
 	 * @param bool   $strip_meta  Optional. Strip all profiles, excluding color profiles, from the image. Default true.
295
-	 * @return bool|WP_Error
295
+	 * @return null|WP_Error
296 296
 	 */
297 297
 	protected function thumbnail_image( $dst_w, $dst_h, $filter_name = 'FILTER_TRIANGLE', $strip_meta = true ) {
298 298
 		$allowed_filters = array(
@@ -745,7 +745,7 @@  discard block
 block discarded – undo
745 745
 	 * @since 4.7.0
746 746
 	 * @access protected
747 747
 	 *
748
-	 * @return string|WP_Error File to load or WP_Error on failure.
748
+	 * @return string File to load or WP_Error on failure.
749 749
 	 */
750 750
 	protected function pdf_setup() {
751 751
 		try {
Please login to merge, or discard this patch.
Braces   +73 added lines, -66 removed lines patch added patch discarded remove patch
@@ -48,11 +48,13 @@  discard block
 block discarded – undo
48 48
 	public static function test( $args = array() ) {
49 49
 
50 50
 		// First, test Imagick's extension and classes.
51
-		if ( ! extension_loaded( 'imagick' ) || ! class_exists( 'Imagick', false ) || ! class_exists( 'ImagickPixel', false ) )
52
-			return false;
51
+		if ( ! extension_loaded( 'imagick' ) || ! class_exists( 'Imagick', false ) || ! class_exists( 'ImagickPixel', false ) ) {
52
+					return false;
53
+		}
53 54
 
54
-		if ( version_compare( phpversion( 'imagick' ), '2.2.0', '<' ) )
55
-			return false;
55
+		if ( version_compare( phpversion( 'imagick' ), '2.2.0', '<' ) ) {
56
+					return false;
57
+		}
56 58
 
57 59
 		$required_methods = array(
58 60
 			'clear',
@@ -77,8 +79,9 @@  discard block
 block discarded – undo
77 79
 		);
78 80
 
79 81
 		// Now, test for deep requirements within Imagick.
80
-		if ( ! defined( 'imagick::COMPRESSION_JPEG' ) )
81
-			return false;
82
+		if ( ! defined( 'imagick::COMPRESSION_JPEG' ) ) {
83
+					return false;
84
+		}
82 85
 
83 86
 		$class_methods = array_map( 'strtolower', get_class_methods( 'Imagick' ) );
84 87
 		if ( array_diff( $required_methods, $class_methods ) ) {
@@ -107,18 +110,19 @@  discard block
 block discarded – undo
107 110
 	public static function supports_mime_type( $mime_type ) {
108 111
 		$imagick_extension = strtoupper( self::get_extension( $mime_type ) );
109 112
 
110
-		if ( ! $imagick_extension )
111
-			return false;
113
+		if ( ! $imagick_extension ) {
114
+					return false;
115
+		}
112 116
 
113 117
 		// setIteratorIndex is optional unless mime is an animated format.
114 118
 		// Here, we just say no if you are missing it and aren't loading a jpeg.
115
-		if ( ! method_exists( 'Imagick', 'setIteratorIndex' ) && $mime_type != 'image/jpeg' )
116
-				return false;
119
+		if ( ! method_exists( 'Imagick', 'setIteratorIndex' ) && $mime_type != 'image/jpeg' ) {
120
+						return false;
121
+		}
117 122
 
118 123
 		try {
119 124
 			return ( (bool) @Imagick::queryFormats( $imagick_extension ) );
120
-		}
121
-		catch ( Exception $e ) {
125
+		} catch ( Exception $e ) {
122 126
 			return false;
123 127
 		}
124 128
 	}
@@ -132,11 +136,13 @@  discard block
 block discarded – undo
132 136
 	 * @return true|WP_Error True if loaded; WP_Error on failure.
133 137
 	 */
134 138
 	public function load() {
135
-		if ( $this->image instanceof Imagick )
136
-			return true;
139
+		if ( $this->image instanceof Imagick ) {
140
+					return true;
141
+		}
137 142
 
138
-		if ( ! is_file( $this->file ) && ! preg_match( '|^https?://|', $this->file ) )
139
-			return new WP_Error( 'error_loading_image', __('File doesn&#8217;t exist?'), $this->file );
143
+		if ( ! is_file( $this->file ) && ! preg_match( '|^https?://|', $this->file ) ) {
144
+					return new WP_Error( 'error_loading_image', __('File doesn&#8217;t exist?'), $this->file );
145
+		}
140 146
 
141 147
 		/*
142 148
 		 * Even though Imagick uses less PHP memory than GD, set higher limit
@@ -157,16 +163,17 @@  discard block
 block discarded – undo
157 163
 			// only applies correctly before the image is read.
158 164
 			$this->image->readImage( $filename );
159 165
 
160
-			if ( ! $this->image->valid() )
161
-				return new WP_Error( 'invalid_image', __('File is not an image.'), $this->file);
166
+			if ( ! $this->image->valid() ) {
167
+							return new WP_Error( 'invalid_image', __('File is not an image.'), $this->file);
168
+			}
162 169
 
163 170
 			// Select the first frame to handle animated images properly
164
-			if ( is_callable( array( $this->image, 'setIteratorIndex' ) ) )
165
-				$this->image->setIteratorIndex(0);
171
+			if ( is_callable( array( $this->image, 'setIteratorIndex' ) ) ) {
172
+							$this->image->setIteratorIndex(0);
173
+			}
166 174
 
167 175
 			$this->mime_type = $this->get_mime_type( $this->image->getImageFormat() );
168
-		}
169
-		catch ( Exception $e ) {
176
+		} catch ( Exception $e ) {
170 177
 			return new WP_Error( 'invalid_image', $e->getMessage(), $this->file );
171 178
 		}
172 179
 
@@ -199,12 +206,10 @@  discard block
 block discarded – undo
199 206
 			if ( 'image/jpeg' == $this->mime_type ) {
200 207
 				$this->image->setImageCompressionQuality( $quality );
201 208
 				$this->image->setImageCompression( imagick::COMPRESSION_JPEG );
202
-			}
203
-			else {
209
+			} else {
204 210
 				$this->image->setImageCompressionQuality( $quality );
205 211
 			}
206
-		}
207
-		catch ( Exception $e ) {
212
+		} catch ( Exception $e ) {
208 213
 			return new WP_Error( 'image_quality_error', $e->getMessage() );
209 214
 		}
210 215
 
@@ -227,17 +232,18 @@  discard block
 block discarded – undo
227 232
 		if ( !$width || !$height ) {
228 233
 			try {
229 234
 				$size = $this->image->getImageGeometry();
230
-			}
231
-			catch ( Exception $e ) {
235
+			} catch ( Exception $e ) {
232 236
 				return new WP_Error( 'invalid_image', __( 'Could not read image size.' ), $this->file );
233 237
 			}
234 238
 		}
235 239
 
236
-		if ( ! $width )
237
-			$width = $size['width'];
240
+		if ( ! $width ) {
241
+					$width = $size['width'];
242
+		}
238 243
 
239
-		if ( ! $height )
240
-			$height = $size['height'];
244
+		if ( ! $height ) {
245
+					$height = $size['height'];
246
+		}
241 247
 
242 248
 		return parent::update_size( $width, $height );
243 249
 	}
@@ -258,12 +264,14 @@  discard block
 block discarded – undo
258 264
 	 * @return bool|WP_Error
259 265
 	 */
260 266
 	public function resize( $max_w, $max_h, $crop = false ) {
261
-		if ( ( $this->size['width'] == $max_w ) && ( $this->size['height'] == $max_h ) )
262
-			return true;
267
+		if ( ( $this->size['width'] == $max_w ) && ( $this->size['height'] == $max_h ) ) {
268
+					return true;
269
+		}
263 270
 
264 271
 		$dims = image_resize_dimensions( $this->size['width'], $this->size['height'], $max_w, $max_h, $crop );
265
-		if ( ! $dims )
266
-			return new WP_Error( 'error_getting_dimensions', __('Could not calculate resized image dimensions') );
272
+		if ( ! $dims ) {
273
+					return new WP_Error( 'error_getting_dimensions', __('Could not calculate resized image dimensions') );
274
+		}
267 275
 		list( $dst_x, $dst_y, $src_x, $src_y, $dst_w, $dst_h, $src_w, $src_h ) = $dims;
268 276
 
269 277
 		if ( $crop ) {
@@ -408,8 +416,7 @@  discard block
 block discarded – undo
408 416
 				$this->image->setInterlaceScheme( Imagick::INTERLACE_NO );
409 417
 			}
410 418
 
411
-		}
412
-		catch ( Exception $e ) {
419
+		} catch ( Exception $e ) {
413 420
 			return new WP_Error( 'image_resize_error', $e->getMessage() );
414 421
 		}
415 422
 	}
@@ -443,8 +450,9 @@  discard block
 block discarded – undo
443 450
 		$orig_image = $this->image->getImage();
444 451
 
445 452
 		foreach ( $sizes as $size => $size_data ) {
446
-			if ( ! $this->image )
447
-				$this->image = $orig_image->getImage();
453
+			if ( ! $this->image ) {
454
+							$this->image = $orig_image->getImage();
455
+			}
448 456
 
449 457
 			if ( ! isset( $size_data['width'] ) && ! isset( $size_data['height'] ) ) {
450 458
 				continue;
@@ -513,10 +521,12 @@  discard block
 block discarded – undo
513 521
 			if ( $dst_w || $dst_h ) {
514 522
 				// If destination width/height isn't specified, use same as
515 523
 				// width/height from source.
516
-				if ( ! $dst_w )
517
-					$dst_w = $src_w;
518
-				if ( ! $dst_h )
519
-					$dst_h = $src_h;
524
+				if ( ! $dst_w ) {
525
+									$dst_w = $src_w;
526
+				}
527
+				if ( ! $dst_h ) {
528
+									$dst_h = $src_h;
529
+				}
520 530
 
521 531
 				$thumb_result = $this->thumbnail_image( $dst_w, $dst_h );
522 532
 				if ( is_wp_error( $thumb_result ) ) {
@@ -525,8 +535,7 @@  discard block
 block discarded – undo
525 535
 
526 536
 				return $this->update_size();
527 537
 			}
528
-		}
529
-		catch ( Exception $e ) {
538
+		} catch ( Exception $e ) {
530 539
 			return new WP_Error( 'image_crop_error', $e->getMessage() );
531 540
 		}
532 541
 		return $this->update_size();
@@ -551,12 +560,12 @@  discard block
 block discarded – undo
551 560
 
552 561
 			// Since this changes the dimensions of the image, update the size.
553 562
 			$result = $this->update_size();
554
-			if ( is_wp_error( $result ) )
555
-				return $result;
563
+			if ( is_wp_error( $result ) ) {
564
+							return $result;
565
+			}
556 566
 
557 567
 			$this->image->setImagePage( $this->size['width'], $this->size['height'], 0, 0 );
558
-		}
559
-		catch ( Exception $e ) {
568
+		} catch ( Exception $e ) {
560 569
 			return new WP_Error( 'image_rotate_error', $e->getMessage() );
561 570
 		}
562 571
 		return true;
@@ -574,13 +583,14 @@  discard block
 block discarded – undo
574 583
 	 */
575 584
 	public function flip( $horz, $vert ) {
576 585
 		try {
577
-			if ( $horz )
578
-				$this->image->flipImage();
586
+			if ( $horz ) {
587
+							$this->image->flipImage();
588
+			}
579 589
 
580
-			if ( $vert )
581
-				$this->image->flopImage();
582
-		}
583
-		catch ( Exception $e ) {
590
+			if ( $vert ) {
591
+							$this->image->flopImage();
592
+			}
593
+		} catch ( Exception $e ) {
584 594
 			return new WP_Error( 'image_flip_error', $e->getMessage() );
585 595
 		}
586 596
 		return true;
@@ -605,8 +615,7 @@  discard block
 block discarded – undo
605 615
 
606 616
 			try {
607 617
 				$this->image->setImageFormat( strtoupper( $this->get_extension( $this->mime_type ) ) );
608
-			}
609
-			catch ( Exception $e ) {
618
+			} catch ( Exception $e ) {
610 619
 				return new WP_Error( 'image_save_error', $e->getMessage(), $this->file );
611 620
 			}
612 621
 		}
@@ -624,8 +633,9 @@  discard block
 block discarded – undo
624 633
 	protected function _save( $image, $filename = null, $mime_type = null ) {
625 634
 		list( $filename, $extension, $mime_type ) = $this->get_output_format( $filename, $mime_type );
626 635
 
627
-		if ( ! $filename )
628
-			$filename = $this->generate_filename( null, null, $extension );
636
+		if ( ! $filename ) {
637
+					$filename = $this->generate_filename( null, null, $extension );
638
+		}
629 639
 
630 640
 		try {
631 641
 			// Store initial Format
@@ -636,8 +646,7 @@  discard block
 block discarded – undo
636 646
 
637 647
 			// Reset original Format
638 648
 			$this->image->setImageFormat( $orig_format );
639
-		}
640
-		catch ( Exception $e ) {
649
+		} catch ( Exception $e ) {
641 650
 			return new WP_Error( 'image_save_error', $e->getMessage(), $filename );
642 651
 		}
643 652
 
@@ -678,8 +687,7 @@  discard block
 block discarded – undo
678 687
 
679 688
 			// Reset Image to original Format
680 689
 			$this->image->setImageFormat( $this->get_extension( $this->mime_type ) );
681
-		}
682
-		catch ( Exception $e ) {
690
+		} catch ( Exception $e ) {
683 691
 			return new WP_Error( 'image_stream_error', $e->getMessage() );
684 692
 		}
685 693
 
@@ -755,8 +763,7 @@  discard block
 block discarded – undo
755 763
 
756 764
 			// Only load the first page.
757 765
 			return $this->file . '[0]';
758
-		}
759
-		catch ( Exception $e ) {
766
+		} catch ( Exception $e ) {
760 767
 			return new WP_Error( 'pdf_setup_failed', $e->getMessage(), $this->file );
761 768
 		}
762 769
 	}
Please login to merge, or discard this patch.
Spacing   +165 added lines, -165 removed lines patch added patch discarded remove patch
@@ -24,7 +24,7 @@  discard block
 block discarded – undo
24 24
 	protected $image;
25 25
 
26 26
 	public function __destruct() {
27
-		if ( $this->image instanceof Imagick ) {
27
+		if ($this->image instanceof Imagick) {
28 28
 			// we don't need the original in memory anymore
29 29
 			$this->image->clear();
30 30
 			$this->image->destroy();
@@ -45,13 +45,13 @@  discard block
 block discarded – undo
45 45
 	 * @param array $args
46 46
 	 * @return bool
47 47
 	 */
48
-	public static function test( $args = array() ) {
48
+	public static function test($args = array()) {
49 49
 
50 50
 		// First, test Imagick's extension and classes.
51
-		if ( ! extension_loaded( 'imagick' ) || ! class_exists( 'Imagick', false ) || ! class_exists( 'ImagickPixel', false ) )
51
+		if ( ! extension_loaded('imagick') || ! class_exists('Imagick', false) || ! class_exists('ImagickPixel', false))
52 52
 			return false;
53 53
 
54
-		if ( version_compare( phpversion( 'imagick' ), '2.2.0', '<' ) )
54
+		if (version_compare(phpversion('imagick'), '2.2.0', '<'))
55 55
 			return false;
56 56
 
57 57
 		$required_methods = array(
@@ -77,16 +77,16 @@  discard block
 block discarded – undo
77 77
 		);
78 78
 
79 79
 		// Now, test for deep requirements within Imagick.
80
-		if ( ! defined( 'imagick::COMPRESSION_JPEG' ) )
80
+		if ( ! defined('imagick::COMPRESSION_JPEG'))
81 81
 			return false;
82 82
 
83
-		$class_methods = array_map( 'strtolower', get_class_methods( 'Imagick' ) );
84
-		if ( array_diff( $required_methods, $class_methods ) ) {
83
+		$class_methods = array_map('strtolower', get_class_methods('Imagick'));
84
+		if (array_diff($required_methods, $class_methods)) {
85 85
 			return false;
86 86
 		}
87 87
 
88 88
 		// HHVM Imagick does not support loading from URL, so fail to allow fallback to GD.
89
-		if ( defined( 'HHVM_VERSION' ) && isset( $args['path'] ) && preg_match( '|^https?://|', $args['path'] ) ) {
89
+		if (defined('HHVM_VERSION') && isset($args['path']) && preg_match('|^https?://|', $args['path'])) {
90 90
 			return false;
91 91
 		}
92 92
 
@@ -104,21 +104,21 @@  discard block
 block discarded – undo
104 104
 	 * @param string $mime_type
105 105
 	 * @return bool
106 106
 	 */
107
-	public static function supports_mime_type( $mime_type ) {
108
-		$imagick_extension = strtoupper( self::get_extension( $mime_type ) );
107
+	public static function supports_mime_type($mime_type) {
108
+		$imagick_extension = strtoupper(self::get_extension($mime_type));
109 109
 
110
-		if ( ! $imagick_extension )
110
+		if ( ! $imagick_extension)
111 111
 			return false;
112 112
 
113 113
 		// setIteratorIndex is optional unless mime is an animated format.
114 114
 		// Here, we just say no if you are missing it and aren't loading a jpeg.
115
-		if ( ! method_exists( 'Imagick', 'setIteratorIndex' ) && $mime_type != 'image/jpeg' )
115
+		if ( ! method_exists('Imagick', 'setIteratorIndex') && $mime_type != 'image/jpeg')
116 116
 				return false;
117 117
 
118 118
 		try {
119
-			return ( (bool) @Imagick::queryFormats( $imagick_extension ) );
119
+			return ((bool) @Imagick::queryFormats($imagick_extension));
120 120
 		}
121
-		catch ( Exception $e ) {
121
+		catch (Exception $e) {
122 122
 			return false;
123 123
 		}
124 124
 	}
@@ -132,46 +132,46 @@  discard block
 block discarded – undo
132 132
 	 * @return true|WP_Error True if loaded; WP_Error on failure.
133 133
 	 */
134 134
 	public function load() {
135
-		if ( $this->image instanceof Imagick )
135
+		if ($this->image instanceof Imagick)
136 136
 			return true;
137 137
 
138
-		if ( ! is_file( $this->file ) && ! preg_match( '|^https?://|', $this->file ) )
139
-			return new WP_Error( 'error_loading_image', __('File doesn&#8217;t exist?'), $this->file );
138
+		if ( ! is_file($this->file) && ! preg_match('|^https?://|', $this->file))
139
+			return new WP_Error('error_loading_image', __('File doesn&#8217;t exist?'), $this->file);
140 140
 
141 141
 		/*
142 142
 		 * Even though Imagick uses less PHP memory than GD, set higher limit
143 143
 		 * for users that have low PHP.ini limits.
144 144
 		 */
145
-		wp_raise_memory_limit( 'image' );
145
+		wp_raise_memory_limit('image');
146 146
 
147 147
 		try {
148 148
 			$this->image = new Imagick();
149
-			$file_extension = strtolower( pathinfo( $this->file, PATHINFO_EXTENSION ) );
149
+			$file_extension = strtolower(pathinfo($this->file, PATHINFO_EXTENSION));
150 150
 			$filename = $this->file;
151 151
 
152
-			if ( 'pdf' == $file_extension ) {
152
+			if ('pdf' == $file_extension) {
153 153
 				$filename = $this->pdf_setup();
154 154
 			}
155 155
 
156 156
 			// Reading image after Imagick instantiation because `setResolution`
157 157
 			// only applies correctly before the image is read.
158
-			$this->image->readImage( $filename );
158
+			$this->image->readImage($filename);
159 159
 
160
-			if ( ! $this->image->valid() )
161
-				return new WP_Error( 'invalid_image', __('File is not an image.'), $this->file);
160
+			if ( ! $this->image->valid())
161
+				return new WP_Error('invalid_image', __('File is not an image.'), $this->file);
162 162
 
163 163
 			// Select the first frame to handle animated images properly
164
-			if ( is_callable( array( $this->image, 'setIteratorIndex' ) ) )
164
+			if (is_callable(array($this->image, 'setIteratorIndex')))
165 165
 				$this->image->setIteratorIndex(0);
166 166
 
167
-			$this->mime_type = $this->get_mime_type( $this->image->getImageFormat() );
167
+			$this->mime_type = $this->get_mime_type($this->image->getImageFormat());
168 168
 		}
169
-		catch ( Exception $e ) {
170
-			return new WP_Error( 'invalid_image', $e->getMessage(), $this->file );
169
+		catch (Exception $e) {
170
+			return new WP_Error('invalid_image', $e->getMessage(), $this->file);
171 171
 		}
172 172
 
173 173
 		$updated_size = $this->update_size();
174
-		if ( is_wp_error( $updated_size ) ) {
174
+		if (is_wp_error($updated_size)) {
175 175
 			return $updated_size;
176 176
 		}
177 177
 
@@ -187,25 +187,25 @@  discard block
 block discarded – undo
187 187
 	 * @param int $quality Compression Quality. Range: [1,100]
188 188
 	 * @return true|WP_Error True if set successfully; WP_Error on failure.
189 189
 	 */
190
-	public function set_quality( $quality = null ) {
191
-		$quality_result = parent::set_quality( $quality );
192
-		if ( is_wp_error( $quality_result ) ) {
190
+	public function set_quality($quality = null) {
191
+		$quality_result = parent::set_quality($quality);
192
+		if (is_wp_error($quality_result)) {
193 193
 			return $quality_result;
194 194
 		} else {
195 195
 			$quality = $this->get_quality();
196 196
 		}
197 197
 
198 198
 		try {
199
-			if ( 'image/jpeg' == $this->mime_type ) {
200
-				$this->image->setImageCompressionQuality( $quality );
201
-				$this->image->setImageCompression( imagick::COMPRESSION_JPEG );
199
+			if ('image/jpeg' == $this->mime_type) {
200
+				$this->image->setImageCompressionQuality($quality);
201
+				$this->image->setImageCompression(imagick::COMPRESSION_JPEG);
202 202
 			}
203 203
 			else {
204
-				$this->image->setImageCompressionQuality( $quality );
204
+				$this->image->setImageCompressionQuality($quality);
205 205
 			}
206 206
 		}
207
-		catch ( Exception $e ) {
208
-			return new WP_Error( 'image_quality_error', $e->getMessage() );
207
+		catch (Exception $e) {
208
+			return new WP_Error('image_quality_error', $e->getMessage());
209 209
 		}
210 210
 
211 211
 		return true;
@@ -222,24 +222,24 @@  discard block
 block discarded – undo
222 222
 	 *
223 223
 	 * @return true|WP_Error
224 224
 	 */
225
-	protected function update_size( $width = null, $height = null ) {
225
+	protected function update_size($width = null, $height = null) {
226 226
 		$size = null;
227
-		if ( !$width || !$height ) {
227
+		if ( ! $width || ! $height) {
228 228
 			try {
229 229
 				$size = $this->image->getImageGeometry();
230 230
 			}
231
-			catch ( Exception $e ) {
232
-				return new WP_Error( 'invalid_image', __( 'Could not read image size.' ), $this->file );
231
+			catch (Exception $e) {
232
+				return new WP_Error('invalid_image', __('Could not read image size.'), $this->file);
233 233
 			}
234 234
 		}
235 235
 
236
-		if ( ! $width )
236
+		if ( ! $width)
237 237
 			$width = $size['width'];
238 238
 
239
-		if ( ! $height )
239
+		if ( ! $height)
240 240
 			$height = $size['height'];
241 241
 
242
-		return parent::update_size( $width, $height );
242
+		return parent::update_size($width, $height);
243 243
 	}
244 244
 
245 245
 	/**
@@ -257,26 +257,26 @@  discard block
 block discarded – undo
257 257
 	 * @param  bool     $crop
258 258
 	 * @return bool|WP_Error
259 259
 	 */
260
-	public function resize( $max_w, $max_h, $crop = false ) {
261
-		if ( ( $this->size['width'] == $max_w ) && ( $this->size['height'] == $max_h ) )
260
+	public function resize($max_w, $max_h, $crop = false) {
261
+		if (($this->size['width'] == $max_w) && ($this->size['height'] == $max_h))
262 262
 			return true;
263 263
 
264
-		$dims = image_resize_dimensions( $this->size['width'], $this->size['height'], $max_w, $max_h, $crop );
265
-		if ( ! $dims )
266
-			return new WP_Error( 'error_getting_dimensions', __('Could not calculate resized image dimensions') );
267
-		list( $dst_x, $dst_y, $src_x, $src_y, $dst_w, $dst_h, $src_w, $src_h ) = $dims;
264
+		$dims = image_resize_dimensions($this->size['width'], $this->size['height'], $max_w, $max_h, $crop);
265
+		if ( ! $dims)
266
+			return new WP_Error('error_getting_dimensions', __('Could not calculate resized image dimensions'));
267
+		list($dst_x, $dst_y, $src_x, $src_y, $dst_w, $dst_h, $src_w, $src_h) = $dims;
268 268
 
269
-		if ( $crop ) {
270
-			return $this->crop( $src_x, $src_y, $src_w, $src_h, $dst_w, $dst_h );
269
+		if ($crop) {
270
+			return $this->crop($src_x, $src_y, $src_w, $src_h, $dst_w, $dst_h);
271 271
 		}
272 272
 
273 273
 		// Execute the resize
274
-		$thumb_result = $this->thumbnail_image( $dst_w, $dst_h );
275
-		if ( is_wp_error( $thumb_result ) ) {
274
+		$thumb_result = $this->thumbnail_image($dst_w, $dst_h);
275
+		if (is_wp_error($thumb_result)) {
276 276
 			return $thumb_result;
277 277
 		}
278 278
 
279
-		return $this->update_size( $dst_w, $dst_h );
279
+		return $this->update_size($dst_w, $dst_h);
280 280
 	}
281 281
 
282 282
 	/**
@@ -294,7 +294,7 @@  discard block
 block discarded – undo
294 294
 	 * @param bool   $strip_meta  Optional. Strip all profiles, excluding color profiles, from the image. Default true.
295 295
 	 * @return bool|WP_Error
296 296
 	 */
297
-	protected function thumbnail_image( $dst_w, $dst_h, $filter_name = 'FILTER_TRIANGLE', $strip_meta = true ) {
297
+	protected function thumbnail_image($dst_w, $dst_h, $filter_name = 'FILTER_TRIANGLE', $strip_meta = true) {
298 298
 		$allowed_filters = array(
299 299
 			'FILTER_POINT',
300 300
 			'FILTER_BOX',
@@ -317,10 +317,10 @@  discard block
 block discarded – undo
317 317
 		 * Set the filter value if '$filter_name' name is in our whitelist and the related
318 318
 		 * Imagick constant is defined or fall back to our default filter.
319 319
 		 */
320
-		if ( in_array( $filter_name, $allowed_filters ) && defined( 'Imagick::' . $filter_name ) ) {
321
-			$filter = constant( 'Imagick::' . $filter_name );
320
+		if (in_array($filter_name, $allowed_filters) && defined('Imagick::'.$filter_name)) {
321
+			$filter = constant('Imagick::'.$filter_name);
322 322
 		} else {
323
-			$filter = defined( 'Imagick::FILTER_TRIANGLE' ) ? Imagick::FILTER_TRIANGLE : false;
323
+			$filter = defined('Imagick::FILTER_TRIANGLE') ? Imagick::FILTER_TRIANGLE : false;
324 324
 		}
325 325
 
326 326
 		/**
@@ -333,7 +333,7 @@  discard block
 block discarded – undo
333 333
 		 *
334 334
 		 * @param bool $strip_meta Whether to strip image metadata during resizing. Default true.
335 335
 		 */
336
-		if ( apply_filters( 'image_strip_meta', $strip_meta ) ) {
336
+		if (apply_filters('image_strip_meta', $strip_meta)) {
337 337
 			$this->strip_meta(); // Fail silently if not supported.
338 338
 		}
339 339
 
@@ -343,12 +343,12 @@  discard block
 block discarded – undo
343 343
 			 * whenever the output size is less that 1/3 of the original image size (1/3^2 ~= .111),
344 344
 			 * unless we would be resampling to a scale smaller than 128x128.
345 345
 			 */
346
-			if ( is_callable( array( $this->image, 'sampleImage' ) ) ) {
347
-				$resize_ratio = ( $dst_w / $this->size['width'] ) * ( $dst_h / $this->size['height'] );
346
+			if (is_callable(array($this->image, 'sampleImage'))) {
347
+				$resize_ratio = ($dst_w / $this->size['width']) * ($dst_h / $this->size['height']);
348 348
 				$sample_factor = 5;
349 349
 
350
-				if ( $resize_ratio < .111 && ( $dst_w * $sample_factor > 128 && $dst_h * $sample_factor > 128 ) ) {
351
-					$this->image->sampleImage( $dst_w * $sample_factor, $dst_h * $sample_factor );
350
+				if ($resize_ratio < .111 && ($dst_w * $sample_factor > 128 && $dst_h * $sample_factor > 128)) {
351
+					$this->image->sampleImage($dst_w * $sample_factor, $dst_h * $sample_factor);
352 352
 				}
353 353
 			}
354 354
 
@@ -358,27 +358,27 @@  discard block
 block discarded – undo
358 358
 			 * results in better image quality over resizeImage() with default filter
359 359
 			 * settings and retains backward compatibility with pre 4.5 functionality.
360 360
 			 */
361
-			if ( is_callable( array( $this->image, 'resizeImage' ) ) && $filter ) {
362
-				$this->image->setOption( 'filter:support', '2.0' );
363
-				$this->image->resizeImage( $dst_w, $dst_h, $filter, 1 );
361
+			if (is_callable(array($this->image, 'resizeImage')) && $filter) {
362
+				$this->image->setOption('filter:support', '2.0');
363
+				$this->image->resizeImage($dst_w, $dst_h, $filter, 1);
364 364
 			} else {
365
-				$this->image->scaleImage( $dst_w, $dst_h );
365
+				$this->image->scaleImage($dst_w, $dst_h);
366 366
 			}
367 367
 
368 368
 			// Set appropriate quality settings after resizing.
369
-			if ( 'image/jpeg' == $this->mime_type ) {
370
-				if ( is_callable( array( $this->image, 'unsharpMaskImage' ) ) ) {
371
-					$this->image->unsharpMaskImage( 0.25, 0.25, 8, 0.065 );
369
+			if ('image/jpeg' == $this->mime_type) {
370
+				if (is_callable(array($this->image, 'unsharpMaskImage'))) {
371
+					$this->image->unsharpMaskImage(0.25, 0.25, 8, 0.065);
372 372
 				}
373 373
 
374
-				$this->image->setOption( 'jpeg:fancy-upsampling', 'off' );
374
+				$this->image->setOption('jpeg:fancy-upsampling', 'off');
375 375
 			}
376 376
 
377
-			if ( 'image/png' === $this->mime_type ) {
378
-				$this->image->setOption( 'png:compression-filter', '5' );
379
-				$this->image->setOption( 'png:compression-level', '9' );
380
-				$this->image->setOption( 'png:compression-strategy', '1' );
381
-				$this->image->setOption( 'png:exclude-chunk', 'all' );
377
+			if ('image/png' === $this->mime_type) {
378
+				$this->image->setOption('png:compression-filter', '5');
379
+				$this->image->setOption('png:compression-level', '9');
380
+				$this->image->setOption('png:compression-strategy', '1');
381
+				$this->image->setOption('png:exclude-chunk', 'all');
382 382
 			}
383 383
 
384 384
 			/*
@@ -387,30 +387,30 @@  discard block
 block discarded – undo
387 387
 			 * Note that Imagick::getImageAlphaChannel() is only available if Imagick
388 388
 			 * has been compiled against ImageMagick version 6.4.0 or newer.
389 389
 			 */
390
-			if ( is_callable( array( $this->image, 'getImageAlphaChannel' ) )
391
-				&& is_callable( array( $this->image, 'setImageAlphaChannel' ) )
392
-				&& defined( 'Imagick::ALPHACHANNEL_UNDEFINED' )
393
-				&& defined( 'Imagick::ALPHACHANNEL_OPAQUE' )
390
+			if (is_callable(array($this->image, 'getImageAlphaChannel'))
391
+				&& is_callable(array($this->image, 'setImageAlphaChannel'))
392
+				&& defined('Imagick::ALPHACHANNEL_UNDEFINED')
393
+				&& defined('Imagick::ALPHACHANNEL_OPAQUE')
394 394
 			) {
395
-				if ( $this->image->getImageAlphaChannel() === Imagick::ALPHACHANNEL_UNDEFINED ) {
396
-					$this->image->setImageAlphaChannel( Imagick::ALPHACHANNEL_OPAQUE );
395
+				if ($this->image->getImageAlphaChannel() === Imagick::ALPHACHANNEL_UNDEFINED) {
396
+					$this->image->setImageAlphaChannel(Imagick::ALPHACHANNEL_OPAQUE);
397 397
 				}
398 398
 			}
399 399
 
400 400
 			// Limit the bit depth of resized images to 8 bits per channel.
401
-			if ( is_callable( array( $this->image, 'getImageDepth' ) ) && is_callable( array( $this->image, 'setImageDepth' ) ) ) {
402
-				if ( 8 < $this->image->getImageDepth() ) {
403
-					$this->image->setImageDepth( 8 );
401
+			if (is_callable(array($this->image, 'getImageDepth')) && is_callable(array($this->image, 'setImageDepth'))) {
402
+				if (8 < $this->image->getImageDepth()) {
403
+					$this->image->setImageDepth(8);
404 404
 				}
405 405
 			}
406 406
 
407
-			if ( is_callable( array( $this->image, 'setInterlaceScheme' ) ) && defined( 'Imagick::INTERLACE_NO' ) ) {
408
-				$this->image->setInterlaceScheme( Imagick::INTERLACE_NO );
407
+			if (is_callable(array($this->image, 'setInterlaceScheme')) && defined('Imagick::INTERLACE_NO')) {
408
+				$this->image->setInterlaceScheme(Imagick::INTERLACE_NO);
409 409
 			}
410 410
 
411 411
 		}
412
-		catch ( Exception $e ) {
413
-			return new WP_Error( 'image_resize_error', $e->getMessage() );
412
+		catch (Exception $e) {
413
+			return new WP_Error('image_resize_error', $e->getMessage());
414 414
 		}
415 415
 	}
416 416
 
@@ -437,42 +437,42 @@  discard block
 block discarded – undo
437 437
 	 * }
438 438
 	 * @return array An array of resized images' metadata by size.
439 439
 	 */
440
-	public function multi_resize( $sizes ) {
440
+	public function multi_resize($sizes) {
441 441
 		$metadata = array();
442 442
 		$orig_size = $this->size;
443 443
 		$orig_image = $this->image->getImage();
444 444
 
445
-		foreach ( $sizes as $size => $size_data ) {
446
-			if ( ! $this->image )
445
+		foreach ($sizes as $size => $size_data) {
446
+			if ( ! $this->image)
447 447
 				$this->image = $orig_image->getImage();
448 448
 
449
-			if ( ! isset( $size_data['width'] ) && ! isset( $size_data['height'] ) ) {
449
+			if ( ! isset($size_data['width']) && ! isset($size_data['height'])) {
450 450
 				continue;
451 451
 			}
452 452
 
453
-			if ( ! isset( $size_data['width'] ) ) {
453
+			if ( ! isset($size_data['width'])) {
454 454
 				$size_data['width'] = null;
455 455
 			}
456
-			if ( ! isset( $size_data['height'] ) ) {
456
+			if ( ! isset($size_data['height'])) {
457 457
 				$size_data['height'] = null;
458 458
 			}
459 459
 
460
-			if ( ! isset( $size_data['crop'] ) ) {
460
+			if ( ! isset($size_data['crop'])) {
461 461
 				$size_data['crop'] = false;
462 462
 			}
463 463
 
464
-			$resize_result = $this->resize( $size_data['width'], $size_data['height'], $size_data['crop'] );
465
-			$duplicate = ( ( $orig_size['width'] == $size_data['width'] ) && ( $orig_size['height'] == $size_data['height'] ) );
464
+			$resize_result = $this->resize($size_data['width'], $size_data['height'], $size_data['crop']);
465
+			$duplicate = (($orig_size['width'] == $size_data['width']) && ($orig_size['height'] == $size_data['height']));
466 466
 
467
-			if ( ! is_wp_error( $resize_result ) && ! $duplicate ) {
468
-				$resized = $this->_save( $this->image );
467
+			if ( ! is_wp_error($resize_result) && ! $duplicate) {
468
+				$resized = $this->_save($this->image);
469 469
 
470 470
 				$this->image->clear();
471 471
 				$this->image->destroy();
472 472
 				$this->image = null;
473 473
 
474
-				if ( ! is_wp_error( $resized ) && $resized ) {
475
-					unset( $resized['path'] );
474
+				if ( ! is_wp_error($resized) && $resized) {
475
+					unset($resized['path']);
476 476
 					$metadata[$size] = $resized;
477 477
 				}
478 478
 			}
@@ -500,34 +500,34 @@  discard block
 block discarded – undo
500 500
 	 * @param bool $src_abs Optional. If the source crop points are absolute.
501 501
 	 * @return bool|WP_Error
502 502
 	 */
503
-	public function crop( $src_x, $src_y, $src_w, $src_h, $dst_w = null, $dst_h = null, $src_abs = false ) {
504
-		if ( $src_abs ) {
503
+	public function crop($src_x, $src_y, $src_w, $src_h, $dst_w = null, $dst_h = null, $src_abs = false) {
504
+		if ($src_abs) {
505 505
 			$src_w -= $src_x;
506 506
 			$src_h -= $src_y;
507 507
 		}
508 508
 
509 509
 		try {
510
-			$this->image->cropImage( $src_w, $src_h, $src_x, $src_y );
511
-			$this->image->setImagePage( $src_w, $src_h, 0, 0);
510
+			$this->image->cropImage($src_w, $src_h, $src_x, $src_y);
511
+			$this->image->setImagePage($src_w, $src_h, 0, 0);
512 512
 
513
-			if ( $dst_w || $dst_h ) {
513
+			if ($dst_w || $dst_h) {
514 514
 				// If destination width/height isn't specified, use same as
515 515
 				// width/height from source.
516
-				if ( ! $dst_w )
516
+				if ( ! $dst_w)
517 517
 					$dst_w = $src_w;
518
-				if ( ! $dst_h )
518
+				if ( ! $dst_h)
519 519
 					$dst_h = $src_h;
520 520
 
521
-				$thumb_result = $this->thumbnail_image( $dst_w, $dst_h );
522
-				if ( is_wp_error( $thumb_result ) ) {
521
+				$thumb_result = $this->thumbnail_image($dst_w, $dst_h);
522
+				if (is_wp_error($thumb_result)) {
523 523
 					return $thumb_result;
524 524
 				}
525 525
 
526 526
 				return $this->update_size();
527 527
 			}
528 528
 		}
529
-		catch ( Exception $e ) {
530
-			return new WP_Error( 'image_crop_error', $e->getMessage() );
529
+		catch (Exception $e) {
530
+			return new WP_Error('image_crop_error', $e->getMessage());
531 531
 		}
532 532
 		return $this->update_size();
533 533
 	}
@@ -541,28 +541,28 @@  discard block
 block discarded – undo
541 541
 	 * @param float $angle
542 542
 	 * @return true|WP_Error
543 543
 	 */
544
-	public function rotate( $angle ) {
544
+	public function rotate($angle) {
545 545
 		/**
546 546
 		 * $angle is 360-$angle because Imagick rotates clockwise
547 547
 		 * (GD rotates counter-clockwise)
548 548
 		 */
549 549
 		try {
550
-			$this->image->rotateImage( new ImagickPixel('none'), 360-$angle );
550
+			$this->image->rotateImage(new ImagickPixel('none'), 360 - $angle);
551 551
 
552 552
 			// Normalise Exif orientation data so that display is consistent across devices.
553
-			if ( is_callable( array( $this->image, 'setImageOrientation' ) ) && defined( 'Imagick::ORIENTATION_TOPLEFT' ) ) {
554
-				$this->image->setImageOrientation( Imagick::ORIENTATION_TOPLEFT );
553
+			if (is_callable(array($this->image, 'setImageOrientation')) && defined('Imagick::ORIENTATION_TOPLEFT')) {
554
+				$this->image->setImageOrientation(Imagick::ORIENTATION_TOPLEFT);
555 555
 			}
556 556
 
557 557
 			// Since this changes the dimensions of the image, update the size.
558 558
 			$result = $this->update_size();
559
-			if ( is_wp_error( $result ) )
559
+			if (is_wp_error($result))
560 560
 				return $result;
561 561
 
562
-			$this->image->setImagePage( $this->size['width'], $this->size['height'], 0, 0 );
562
+			$this->image->setImagePage($this->size['width'], $this->size['height'], 0, 0);
563 563
 		}
564
-		catch ( Exception $e ) {
565
-			return new WP_Error( 'image_rotate_error', $e->getMessage() );
564
+		catch (Exception $e) {
565
+			return new WP_Error('image_rotate_error', $e->getMessage());
566 566
 		}
567 567
 		return true;
568 568
 	}
@@ -577,16 +577,16 @@  discard block
 block discarded – undo
577 577
 	 * @param bool $vert Flip along Vertical Axis
578 578
 	 * @return true|WP_Error
579 579
 	 */
580
-	public function flip( $horz, $vert ) {
580
+	public function flip($horz, $vert) {
581 581
 		try {
582
-			if ( $horz )
582
+			if ($horz)
583 583
 				$this->image->flipImage();
584 584
 
585
-			if ( $vert )
585
+			if ($vert)
586 586
 				$this->image->flopImage();
587 587
 		}
588
-		catch ( Exception $e ) {
589
-			return new WP_Error( 'image_flip_error', $e->getMessage() );
588
+		catch (Exception $e) {
589
+			return new WP_Error('image_flip_error', $e->getMessage());
590 590
 		}
591 591
 		return true;
592 592
 	}
@@ -601,18 +601,18 @@  discard block
 block discarded – undo
601 601
 	 * @param string $mime_type
602 602
 	 * @return array|WP_Error {'path'=>string, 'file'=>string, 'width'=>int, 'height'=>int, 'mime-type'=>string}
603 603
 	 */
604
-	public function save( $destfilename = null, $mime_type = null ) {
605
-		$saved = $this->_save( $this->image, $destfilename, $mime_type );
604
+	public function save($destfilename = null, $mime_type = null) {
605
+		$saved = $this->_save($this->image, $destfilename, $mime_type);
606 606
 
607
-		if ( ! is_wp_error( $saved ) ) {
607
+		if ( ! is_wp_error($saved)) {
608 608
 			$this->file = $saved['path'];
609 609
 			$this->mime_type = $saved['mime-type'];
610 610
 
611 611
 			try {
612
-				$this->image->setImageFormat( strtoupper( $this->get_extension( $this->mime_type ) ) );
612
+				$this->image->setImageFormat(strtoupper($this->get_extension($this->mime_type)));
613 613
 			}
614
-			catch ( Exception $e ) {
615
-				return new WP_Error( 'image_save_error', $e->getMessage(), $this->file );
614
+			catch (Exception $e) {
615
+				return new WP_Error('image_save_error', $e->getMessage(), $this->file);
616 616
 			}
617 617
 		}
618 618
 
@@ -626,35 +626,35 @@  discard block
 block discarded – undo
626 626
 	 * @param string $mime_type
627 627
 	 * @return array|WP_Error
628 628
 	 */
629
-	protected function _save( $image, $filename = null, $mime_type = null ) {
630
-		list( $filename, $extension, $mime_type ) = $this->get_output_format( $filename, $mime_type );
629
+	protected function _save($image, $filename = null, $mime_type = null) {
630
+		list($filename, $extension, $mime_type) = $this->get_output_format($filename, $mime_type);
631 631
 
632
-		if ( ! $filename )
633
-			$filename = $this->generate_filename( null, null, $extension );
632
+		if ( ! $filename)
633
+			$filename = $this->generate_filename(null, null, $extension);
634 634
 
635 635
 		try {
636 636
 			// Store initial Format
637 637
 			$orig_format = $this->image->getImageFormat();
638 638
 
639
-			$this->image->setImageFormat( strtoupper( $this->get_extension( $mime_type ) ) );
640
-			$this->make_image( $filename, array( $image, 'writeImage' ), array( $filename ) );
639
+			$this->image->setImageFormat(strtoupper($this->get_extension($mime_type)));
640
+			$this->make_image($filename, array($image, 'writeImage'), array($filename));
641 641
 
642 642
 			// Reset original Format
643
-			$this->image->setImageFormat( $orig_format );
643
+			$this->image->setImageFormat($orig_format);
644 644
 		}
645
-		catch ( Exception $e ) {
646
-			return new WP_Error( 'image_save_error', $e->getMessage(), $filename );
645
+		catch (Exception $e) {
646
+			return new WP_Error('image_save_error', $e->getMessage(), $filename);
647 647
 		}
648 648
 
649 649
 		// Set correct file permissions
650
-		$stat = stat( dirname( $filename ) );
650
+		$stat = stat(dirname($filename));
651 651
 		$perms = $stat['mode'] & 0000666; //same permissions as parent folder, strip off the executable bits
652
-		@ chmod( $filename, $perms );
652
+		@ chmod($filename, $perms);
653 653
 
654 654
 		/** This filter is documented in wp-includes/class-wp-image-editor-gd.php */
655 655
 		return array(
656 656
 			'path'      => $filename,
657
-			'file'      => wp_basename( apply_filters( 'image_make_intermediate_size', $filename ) ),
657
+			'file'      => wp_basename(apply_filters('image_make_intermediate_size', $filename)),
658 658
 			'width'     => $this->size['width'],
659 659
 			'height'    => $this->size['height'],
660 660
 			'mime-type' => $mime_type,
@@ -670,22 +670,22 @@  discard block
 block discarded – undo
670 670
 	 * @param string $mime_type
671 671
 	 * @return true|WP_Error
672 672
 	 */
673
-	public function stream( $mime_type = null ) {
674
-		list( $filename, $extension, $mime_type ) = $this->get_output_format( null, $mime_type );
673
+	public function stream($mime_type = null) {
674
+		list($filename, $extension, $mime_type) = $this->get_output_format(null, $mime_type);
675 675
 
676 676
 		try {
677 677
 			// Temporarily change format for stream
678
-			$this->image->setImageFormat( strtoupper( $extension ) );
678
+			$this->image->setImageFormat(strtoupper($extension));
679 679
 
680 680
 			// Output stream of image content
681
-			header( "Content-Type: $mime_type" );
681
+			header("Content-Type: $mime_type");
682 682
 			print $this->image->getImageBlob();
683 683
 
684 684
 			// Reset Image to original Format
685
-			$this->image->setImageFormat( $this->get_extension( $this->mime_type ) );
685
+			$this->image->setImageFormat($this->get_extension($this->mime_type));
686 686
 		}
687
-		catch ( Exception $e ) {
688
-			return new WP_Error( 'image_stream_error', $e->getMessage() );
687
+		catch (Exception $e) {
688
+			return new WP_Error('image_stream_error', $e->getMessage());
689 689
 		}
690 690
 
691 691
 		return true;
@@ -701,14 +701,14 @@  discard block
 block discarded – undo
701 701
 	 */
702 702
 	protected function strip_meta() {
703 703
 
704
-		if ( ! is_callable( array( $this->image, 'getImageProfiles' ) ) ) {
704
+		if ( ! is_callable(array($this->image, 'getImageProfiles'))) {
705 705
 			/* translators: %s: ImageMagick method name */
706
-			return new WP_Error( 'image_strip_meta_error', sprintf( __( '%s is required to strip image meta.' ), '<code>Imagick::getImageProfiles()</code>' ) );
706
+			return new WP_Error('image_strip_meta_error', sprintf(__('%s is required to strip image meta.'), '<code>Imagick::getImageProfiles()</code>'));
707 707
 		}
708 708
 
709
-		if ( ! is_callable( array( $this->image, 'removeImageProfile' ) ) ) {
709
+		if ( ! is_callable(array($this->image, 'removeImageProfile'))) {
710 710
 			/* translators: %s: ImageMagick method name */
711
-			return new WP_Error( 'image_strip_meta_error', sprintf( __( '%s is required to strip image meta.' ), '<code>Imagick::removeImageProfile()</code>' ) );
711
+			return new WP_Error('image_strip_meta_error', sprintf(__('%s is required to strip image meta.'), '<code>Imagick::removeImageProfile()</code>'));
712 712
 		}
713 713
 
714 714
 		/*
@@ -730,14 +730,14 @@  discard block
 block discarded – undo
730 730
 
731 731
 		try {
732 732
 			// Strip profiles.
733
-			foreach ( $this->image->getImageProfiles( '*', true ) as $key => $value ) {
734
-				if ( ! in_array( $key, $protected_profiles ) ) {
735
-					$this->image->removeImageProfile( $key );
733
+			foreach ($this->image->getImageProfiles('*', true) as $key => $value) {
734
+				if ( ! in_array($key, $protected_profiles)) {
735
+					$this->image->removeImageProfile($key);
736 736
 				}
737 737
 			}
738 738
 
739
-		} catch ( Exception $e ) {
740
-			return new WP_Error( 'image_strip_meta_error', $e->getMessage() );
739
+		} catch (Exception $e) {
740
+			return new WP_Error('image_strip_meta_error', $e->getMessage());
741 741
 		}
742 742
 
743 743
 		return true;
@@ -756,13 +756,13 @@  discard block
 block discarded – undo
756 756
 		try {
757 757
 			// By default, PDFs are rendered in a very low resolution.
758 758
 			// We want the thumbnail to be readable, so increase the rendering DPI.
759
-			$this->image->setResolution( 128, 128 );
759
+			$this->image->setResolution(128, 128);
760 760
 
761 761
 			// Only load the first page.
762
-			return $this->file . '[0]';
762
+			return $this->file.'[0]';
763 763
 		}
764
-		catch ( Exception $e ) {
765
-			return new WP_Error( 'pdf_setup_failed', $e->getMessage(), $this->file );
764
+		catch (Exception $e) {
765
+			return new WP_Error('pdf_setup_failed', $e->getMessage(), $this->file);
766 766
 		}
767 767
 	}
768 768
 
Please login to merge, or discard this patch.
src/wp-includes/class-wp-query.php 4 patches
Doc Comments   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -1374,7 +1374,7 @@  discard block
 block discarded – undo
1374 1374
 	 *
1375 1375
 	 * @since 3.7.0
1376 1376
 	 *
1377
-	 * @param array $terms Terms to check.
1377
+	 * @param string[] $terms Terms to check.
1378 1378
 	 * @return array Terms that are not stopwords.
1379 1379
 	 */
1380 1380
 	protected function parse_search_terms( $terms ) {
@@ -3372,7 +3372,7 @@  discard block
 block discarded – undo
3372 3372
 	 * @access public
3373 3373
 	 *
3374 3374
 	 * @param string $name Property to check if set.
3375
-	 * @return bool Whether the property is set.
3375
+	 * @return boolean|null Whether the property is set.
3376 3376
 	 */
3377 3377
 	public function __isset( $name ) {
3378 3378
 		if ( in_array( $name, $this->compat_fields ) ) {
@@ -3971,8 +3971,8 @@  discard block
 block discarded – undo
3971 3971
 	 * @global int             $more
3972 3972
 	 * @global int             $numpages
3973 3973
 	 *
3974
-	 * @param WP_Post|object|int $post WP_Post instance or Post ID/object.
3975
-	 * @return true True when finished.
3974
+	 * @param WP_Post $post WP_Post instance or Post ID/object.
3975
+	 * @return null|boolean True when finished.
3976 3976
 	 */
3977 3977
 	public function setup_postdata( $post ) {
3978 3978
 		global $id, $authordata, $currentday, $currentmonth, $page, $pages, $multipage, $more, $numpages;
Please login to merge, or discard this patch.
Indentation   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -4210,14 +4210,14 @@
 block discarded – undo
4210 4210
 	}
4211 4211
 
4212 4212
 	/**
4213
- 	 * Is the query for an existing archive page?
4214
- 	 *
4215
- 	 * Month, Year, Category, Author, Post Type archive...
4216
-	 *
4217
- 	 * @since 3.1.0
4218
- 	 *
4219
- 	 * @return bool
4220
- 	 */
4213
+	 * Is the query for an existing archive page?
4214
+	 *
4215
+	 * Month, Year, Category, Author, Post Type archive...
4216
+	 *
4217
+	 * @since 3.1.0
4218
+	 *
4219
+	 * @return bool
4220
+	 */
4221 4221
 	public function is_archive() {
4222 4222
 		return (bool) $this->is_archive;
4223 4223
 	}
Please login to merge, or discard this patch.
Spacing   +816 added lines, -816 removed lines patch added patch discarded remove patch
@@ -482,9 +482,9 @@  discard block
 block discarded – undo
482 482
 	 */
483 483
 	private $stopwords;
484 484
 
485
-	private $compat_fields = array( 'query_vars_hash', 'query_vars_changed' );
485
+	private $compat_fields = array('query_vars_hash', 'query_vars_changed');
486 486
 
487
-	private $compat_methods = array( 'init_query_flags', 'parse_tax_query' );
487
+	private $compat_methods = array('init_query_flags', 'parse_tax_query');
488 488
 
489 489
 	/**
490 490
 	 * Resets query flags to false.
@@ -538,10 +538,10 @@  discard block
 block discarded – undo
538 538
 		$this->post_count = 0;
539 539
 		$this->current_post = -1;
540 540
 		$this->in_the_loop = false;
541
-		unset( $this->request );
542
-		unset( $this->post );
543
-		unset( $this->comments );
544
-		unset( $this->comment );
541
+		unset($this->request);
542
+		unset($this->post);
543
+		unset($this->comments);
544
+		unset($this->comment);
545 545
 		$this->comment_count = 0;
546 546
 		$this->current_comment = -1;
547 547
 		$this->found_posts = 0;
@@ -612,17 +612,17 @@  discard block
 block discarded – undo
612 612
 			, 'embed'
613 613
 		);
614 614
 
615
-		foreach ( $keys as $key ) {
616
-			if ( !isset($array[$key]) )
615
+		foreach ($keys as $key) {
616
+			if ( ! isset($array[$key]))
617 617
 				$array[$key] = '';
618 618
 		}
619 619
 
620
-		$array_keys = array( 'category__in', 'category__not_in', 'category__and', 'post__in', 'post__not_in', 'post_name__in',
620
+		$array_keys = array('category__in', 'category__not_in', 'category__and', 'post__in', 'post__not_in', 'post_name__in',
621 621
 			'tag__in', 'tag__not_in', 'tag__and', 'tag_slug__in', 'tag_slug__and', 'post_parent__in', 'post_parent__not_in',
622
-			'author__in', 'author__not_in' );
622
+			'author__in', 'author__not_in');
623 623
 
624
-		foreach ( $array_keys as $key ) {
625
-			if ( !isset($array[$key]) )
624
+		foreach ($array_keys as $key) {
625
+			if ( ! isset($array[$key]))
626 626
 				$array[$key] = array();
627 627
 		}
628 628
 		return $array;
@@ -750,11 +750,11 @@  discard block
 block discarded – undo
750 750
 	 *     @type int          $year                    The four-digit year. Default empty. Accepts any four-digit year.
751 751
 	 * }
752 752
 	 */
753
-	public function parse_query( $query =  '' ) {
754
-		if ( ! empty( $query ) ) {
753
+	public function parse_query($query = '') {
754
+		if ( ! empty($query)) {
755 755
 			$this->init();
756
-			$this->query = $this->query_vars = wp_parse_args( $query );
757
-		} elseif ( ! isset( $this->query ) ) {
756
+			$this->query = $this->query_vars = wp_parse_args($query);
757
+		} elseif ( ! isset($this->query)) {
758 758
 			$this->query = $this->query_vars;
759 759
 		}
760 760
 
@@ -762,86 +762,86 @@  discard block
 block discarded – undo
762 762
 		$qv = &$this->query_vars;
763 763
 		$this->query_vars_changed = true;
764 764
 
765
-		if ( ! empty($qv['robots']) )
765
+		if ( ! empty($qv['robots']))
766 766
 			$this->is_robots = true;
767 767
 
768
-		if ( ! is_scalar( $qv['p'] ) || $qv['p'] < 0 ) {
768
+		if ( ! is_scalar($qv['p']) || $qv['p'] < 0) {
769 769
 			$qv['p'] = 0;
770 770
 			$qv['error'] = '404';
771 771
 		} else {
772
-			$qv['p'] = intval( $qv['p'] );
772
+			$qv['p'] = intval($qv['p']);
773 773
 		}
774 774
 
775
-		$qv['page_id'] =  absint($qv['page_id']);
775
+		$qv['page_id'] = absint($qv['page_id']);
776 776
 		$qv['year'] = absint($qv['year']);
777 777
 		$qv['monthnum'] = absint($qv['monthnum']);
778 778
 		$qv['day'] = absint($qv['day']);
779 779
 		$qv['w'] = absint($qv['w']);
780
-		$qv['m'] = is_scalar( $qv['m'] ) ? preg_replace( '|[^0-9]|', '', $qv['m'] ) : '';
780
+		$qv['m'] = is_scalar($qv['m']) ? preg_replace('|[^0-9]|', '', $qv['m']) : '';
781 781
 		$qv['paged'] = absint($qv['paged']);
782
-		$qv['cat'] = preg_replace( '|[^0-9,-]|', '', $qv['cat'] ); // comma separated list of positive or negative integers
783
-		$qv['author'] = preg_replace( '|[^0-9,-]|', '', $qv['author'] ); // comma separated list of positive or negative integers
784
-		$qv['pagename'] = trim( $qv['pagename'] );
785
-		$qv['name'] = trim( $qv['name'] );
786
-		$qv['title'] = trim( $qv['title'] );
787
-		if ( '' !== $qv['hour'] ) $qv['hour'] = absint($qv['hour']);
788
-		if ( '' !== $qv['minute'] ) $qv['minute'] = absint($qv['minute']);
789
-		if ( '' !== $qv['second'] ) $qv['second'] = absint($qv['second']);
790
-		if ( '' !== $qv['menu_order'] ) $qv['menu_order'] = absint($qv['menu_order']);
782
+		$qv['cat'] = preg_replace('|[^0-9,-]|', '', $qv['cat']); // comma separated list of positive or negative integers
783
+		$qv['author'] = preg_replace('|[^0-9,-]|', '', $qv['author']); // comma separated list of positive or negative integers
784
+		$qv['pagename'] = trim($qv['pagename']);
785
+		$qv['name'] = trim($qv['name']);
786
+		$qv['title'] = trim($qv['title']);
787
+		if ('' !== $qv['hour']) $qv['hour'] = absint($qv['hour']);
788
+		if ('' !== $qv['minute']) $qv['minute'] = absint($qv['minute']);
789
+		if ('' !== $qv['second']) $qv['second'] = absint($qv['second']);
790
+		if ('' !== $qv['menu_order']) $qv['menu_order'] = absint($qv['menu_order']);
791 791
 
792 792
 		// Fairly insane upper bound for search string lengths.
793
-		if ( ! is_scalar( $qv['s'] ) || ( ! empty( $qv['s'] ) && strlen( $qv['s'] ) > 1600 ) ) {
793
+		if ( ! is_scalar($qv['s']) || ( ! empty($qv['s']) && strlen($qv['s']) > 1600)) {
794 794
 			$qv['s'] = '';
795 795
 		}
796 796
 
797 797
 		// Compat. Map subpost to attachment.
798
-		if ( '' != $qv['subpost'] )
798
+		if ('' != $qv['subpost'])
799 799
 			$qv['attachment'] = $qv['subpost'];
800
-		if ( '' != $qv['subpost_id'] )
800
+		if ('' != $qv['subpost_id'])
801 801
 			$qv['attachment_id'] = $qv['subpost_id'];
802 802
 
803 803
 		$qv['attachment_id'] = absint($qv['attachment_id']);
804 804
 
805
-		if ( ('' != $qv['attachment']) || !empty($qv['attachment_id']) ) {
805
+		if (('' != $qv['attachment']) || ! empty($qv['attachment_id'])) {
806 806
 			$this->is_single = true;
807 807
 			$this->is_attachment = true;
808
-		} elseif ( '' != $qv['name'] ) {
808
+		} elseif ('' != $qv['name']) {
809 809
 			$this->is_single = true;
810
-		} elseif ( $qv['p'] ) {
810
+		} elseif ($qv['p']) {
811 811
 			$this->is_single = true;
812
-		} elseif ( ('' !== $qv['hour']) && ('' !== $qv['minute']) &&('' !== $qv['second']) && ('' != $qv['year']) && ('' != $qv['monthnum']) && ('' != $qv['day']) ) {
812
+		} elseif (('' !== $qv['hour']) && ('' !== $qv['minute']) && ('' !== $qv['second']) && ('' != $qv['year']) && ('' != $qv['monthnum']) && ('' != $qv['day'])) {
813 813
 			// If year, month, day, hour, minute, and second are set, a single
814 814
 			// post is being queried.
815 815
 			$this->is_single = true;
816
-		} elseif ( '' != $qv['static'] || '' != $qv['pagename'] || !empty($qv['page_id']) ) {
816
+		} elseif ('' != $qv['static'] || '' != $qv['pagename'] || ! empty($qv['page_id'])) {
817 817
 			$this->is_page = true;
818 818
 			$this->is_single = false;
819 819
 		} else {
820 820
 			// Look for archive queries. Dates, categories, authors, search, post type archives.
821 821
 
822
-			if ( isset( $this->query['s'] ) ) {
822
+			if (isset($this->query['s'])) {
823 823
 				$this->is_search = true;
824 824
 			}
825 825
 
826
-			if ( '' !== $qv['second'] ) {
826
+			if ('' !== $qv['second']) {
827 827
 				$this->is_time = true;
828 828
 				$this->is_date = true;
829 829
 			}
830 830
 
831
-			if ( '' !== $qv['minute'] ) {
831
+			if ('' !== $qv['minute']) {
832 832
 				$this->is_time = true;
833 833
 				$this->is_date = true;
834 834
 			}
835 835
 
836
-			if ( '' !== $qv['hour'] ) {
836
+			if ('' !== $qv['hour']) {
837 837
 				$this->is_time = true;
838 838
 				$this->is_date = true;
839 839
 			}
840 840
 
841
-			if ( $qv['day'] ) {
842
-				if ( ! $this->is_date ) {
843
-					$date = sprintf( '%04d-%02d-%02d', $qv['year'], $qv['monthnum'], $qv['day'] );
844
-					if ( $qv['monthnum'] && $qv['year'] && ! wp_checkdate( $qv['monthnum'], $qv['day'], $qv['year'], $date ) ) {
841
+			if ($qv['day']) {
842
+				if ( ! $this->is_date) {
843
+					$date = sprintf('%04d-%02d-%02d', $qv['year'], $qv['monthnum'], $qv['day']);
844
+					if ($qv['monthnum'] && $qv['year'] && ! wp_checkdate($qv['monthnum'], $qv['day'], $qv['year'], $date)) {
845 845
 						$qv['error'] = '404';
846 846
 					} else {
847 847
 						$this->is_day = true;
@@ -850,9 +850,9 @@  discard block
 block discarded – undo
850 850
 				}
851 851
 			}
852 852
 
853
-			if ( $qv['monthnum'] ) {
854
-				if ( ! $this->is_date ) {
855
-					if ( 12 < $qv['monthnum'] ) {
853
+			if ($qv['monthnum']) {
854
+				if ( ! $this->is_date) {
855
+					if (12 < $qv['monthnum']) {
856 856
 						$qv['error'] = '404';
857 857
 					} else {
858 858
 						$this->is_month = true;
@@ -861,40 +861,40 @@  discard block
 block discarded – undo
861 861
 				}
862 862
 			}
863 863
 
864
-			if ( $qv['year'] ) {
865
-				if ( ! $this->is_date ) {
864
+			if ($qv['year']) {
865
+				if ( ! $this->is_date) {
866 866
 					$this->is_year = true;
867 867
 					$this->is_date = true;
868 868
 				}
869 869
 			}
870 870
 
871
-			if ( $qv['m'] ) {
871
+			if ($qv['m']) {
872 872
 				$this->is_date = true;
873
-				if ( strlen($qv['m']) > 9 ) {
873
+				if (strlen($qv['m']) > 9) {
874 874
 					$this->is_time = true;
875
-				} elseif ( strlen( $qv['m'] ) > 7 ) {
875
+				} elseif (strlen($qv['m']) > 7) {
876 876
 					$this->is_day = true;
877
-				} elseif ( strlen( $qv['m'] ) > 5 ) {
877
+				} elseif (strlen($qv['m']) > 5) {
878 878
 					$this->is_month = true;
879 879
 				} else {
880 880
 					$this->is_year = true;
881 881
 				}
882 882
 			}
883 883
 
884
-			if ( '' != $qv['w'] ) {
884
+			if ('' != $qv['w']) {
885 885
 				$this->is_date = true;
886 886
 			}
887 887
 
888 888
 			$this->query_vars_hash = false;
889
-			$this->parse_tax_query( $qv );
889
+			$this->parse_tax_query($qv);
890 890
 
891
-			foreach ( $this->tax_query->queries as $tax_query ) {
892
-				if ( ! is_array( $tax_query ) ) {
891
+			foreach ($this->tax_query->queries as $tax_query) {
892
+				if ( ! is_array($tax_query)) {
893 893
 					continue;
894 894
 				}
895 895
 
896
-				if ( isset( $tax_query['operator'] ) && 'NOT IN' != $tax_query['operator'] ) {
897
-					switch ( $tax_query['taxonomy'] ) {
896
+				if (isset($tax_query['operator']) && 'NOT IN' != $tax_query['operator']) {
897
+					switch ($tax_query['taxonomy']) {
898 898
 						case 'category':
899 899
 							$this->is_category = true;
900 900
 							break;
@@ -906,89 +906,89 @@  discard block
 block discarded – undo
906 906
 					}
907 907
 				}
908 908
 			}
909
-			unset( $tax_query );
909
+			unset($tax_query);
910 910
 
911
-			if ( empty($qv['author']) || ($qv['author'] == '0') ) {
911
+			if (empty($qv['author']) || ($qv['author'] == '0')) {
912 912
 				$this->is_author = false;
913 913
 			} else {
914 914
 				$this->is_author = true;
915 915
 			}
916 916
 
917
-			if ( '' != $qv['author_name'] )
917
+			if ('' != $qv['author_name'])
918 918
 				$this->is_author = true;
919 919
 
920
-			if ( !empty( $qv['post_type'] ) && ! is_array( $qv['post_type'] ) ) {
921
-				$post_type_obj = get_post_type_object( $qv['post_type'] );
922
-				if ( ! empty( $post_type_obj->has_archive ) )
920
+			if ( ! empty($qv['post_type']) && ! is_array($qv['post_type'])) {
921
+				$post_type_obj = get_post_type_object($qv['post_type']);
922
+				if ( ! empty($post_type_obj->has_archive))
923 923
 					$this->is_post_type_archive = true;
924 924
 			}
925 925
 
926
-			if ( $this->is_post_type_archive || $this->is_date || $this->is_author || $this->is_category || $this->is_tag || $this->is_tax )
926
+			if ($this->is_post_type_archive || $this->is_date || $this->is_author || $this->is_category || $this->is_tag || $this->is_tax)
927 927
 				$this->is_archive = true;
928 928
 		}
929 929
 
930
-		if ( '' != $qv['feed'] )
930
+		if ('' != $qv['feed'])
931 931
 			$this->is_feed = true;
932 932
 
933
-		if ( '' != $qv['embed'] ) {
933
+		if ('' != $qv['embed']) {
934 934
 			$this->is_embed = true;
935 935
 		}
936 936
 
937
-		if ( '' != $qv['tb'] )
937
+		if ('' != $qv['tb'])
938 938
 			$this->is_trackback = true;
939 939
 
940
-		if ( '' != $qv['paged'] && ( intval($qv['paged']) > 1 ) )
940
+		if ('' != $qv['paged'] && (intval($qv['paged']) > 1))
941 941
 			$this->is_paged = true;
942 942
 
943 943
 		// if we're previewing inside the write screen
944
-		if ( '' != $qv['preview'] )
944
+		if ('' != $qv['preview'])
945 945
 			$this->is_preview = true;
946 946
 
947
-		if ( is_admin() )
947
+		if (is_admin())
948 948
 			$this->is_admin = true;
949 949
 
950
-		if ( false !== strpos($qv['feed'], 'comments-') ) {
950
+		if (false !== strpos($qv['feed'], 'comments-')) {
951 951
 			$qv['feed'] = str_replace('comments-', '', $qv['feed']);
952 952
 			$qv['withcomments'] = 1;
953 953
 		}
954 954
 
955 955
 		$this->is_singular = $this->is_single || $this->is_page || $this->is_attachment;
956 956
 
957
-		if ( $this->is_feed && ( !empty($qv['withcomments']) || ( empty($qv['withoutcomments']) && $this->is_singular ) ) )
957
+		if ($this->is_feed && ( ! empty($qv['withcomments']) || (empty($qv['withoutcomments']) && $this->is_singular)))
958 958
 			$this->is_comment_feed = true;
959 959
 
960
-		if ( !( $this->is_singular || $this->is_archive || $this->is_search || $this->is_feed || ( defined( 'REST_REQUEST' ) && REST_REQUEST ) || $this->is_trackback || $this->is_404 || $this->is_admin || $this->is_robots ) )
960
+		if ( ! ($this->is_singular || $this->is_archive || $this->is_search || $this->is_feed || (defined('REST_REQUEST') && REST_REQUEST) || $this->is_trackback || $this->is_404 || $this->is_admin || $this->is_robots))
961 961
 			$this->is_home = true;
962 962
 
963 963
 		// Correct is_* for page_on_front and page_for_posts
964
-		if ( $this->is_home && 'page' == get_option('show_on_front') && get_option('page_on_front') ) {
964
+		if ($this->is_home && 'page' == get_option('show_on_front') && get_option('page_on_front')) {
965 965
 			$_query = wp_parse_args($this->query);
966 966
 			// pagename can be set and empty depending on matched rewrite rules. Ignore an empty pagename.
967
-			if ( isset($_query['pagename']) && '' == $_query['pagename'] )
967
+			if (isset($_query['pagename']) && '' == $_query['pagename'])
968 968
 				unset($_query['pagename']);
969 969
 
970
-			unset( $_query['embed'] );
970
+			unset($_query['embed']);
971 971
 
972
-			if ( empty($_query) || !array_diff( array_keys($_query), array('preview', 'page', 'paged', 'cpage') ) ) {
972
+			if (empty($_query) || ! array_diff(array_keys($_query), array('preview', 'page', 'paged', 'cpage'))) {
973 973
 				$this->is_page = true;
974 974
 				$this->is_home = false;
975 975
 				$qv['page_id'] = get_option('page_on_front');
976 976
 				// Correct <!--nextpage--> for page_on_front
977
-				if ( !empty($qv['paged']) ) {
977
+				if ( ! empty($qv['paged'])) {
978 978
 					$qv['page'] = $qv['paged'];
979 979
 					unset($qv['paged']);
980 980
 				}
981 981
 			}
982 982
 		}
983 983
 
984
-		if ( '' != $qv['pagename'] ) {
985
-			$this->queried_object = get_page_by_path( $qv['pagename'] );
984
+		if ('' != $qv['pagename']) {
985
+			$this->queried_object = get_page_by_path($qv['pagename']);
986 986
 
987
-			if ( $this->queried_object && 'attachment' == $this->queried_object->post_type ) {
988
-				if ( preg_match( "/^[^%]*%(?:postname)%/", get_option( 'permalink_structure' ) ) ) {
987
+			if ($this->queried_object && 'attachment' == $this->queried_object->post_type) {
988
+				if (preg_match("/^[^%]*%(?:postname)%/", get_option('permalink_structure'))) {
989 989
 					// See if we also have a post with the same slug
990
-					$post = get_page_by_path( $qv['pagename'], OBJECT, 'post' );
991
-					if ( $post ) {
990
+					$post = get_page_by_path($qv['pagename'], OBJECT, 'post');
991
+					if ($post) {
992 992
 						$this->queried_object = $post;
993 993
 						$this->is_page = false;
994 994
 						$this->is_single = true;
@@ -996,53 +996,53 @@  discard block
 block discarded – undo
996 996
 				}
997 997
 			}
998 998
 
999
-			if ( ! empty( $this->queried_object ) ) {
999
+			if ( ! empty($this->queried_object)) {
1000 1000
 				$this->queried_object_id = (int) $this->queried_object->ID;
1001 1001
 			} else {
1002
-				unset( $this->queried_object );
1002
+				unset($this->queried_object);
1003 1003
 			}
1004 1004
 
1005
-			if  ( 'page' == get_option('show_on_front') && isset($this->queried_object_id) && $this->queried_object_id == get_option('page_for_posts') ) {
1005
+			if ('page' == get_option('show_on_front') && isset($this->queried_object_id) && $this->queried_object_id == get_option('page_for_posts')) {
1006 1006
 				$this->is_page = false;
1007 1007
 				$this->is_home = true;
1008 1008
 				$this->is_posts_page = true;
1009 1009
 			}
1010 1010
 		}
1011 1011
 
1012
-		if ( $qv['page_id'] ) {
1013
-			if  ( 'page' == get_option('show_on_front') && $qv['page_id'] == get_option('page_for_posts') ) {
1012
+		if ($qv['page_id']) {
1013
+			if ('page' == get_option('show_on_front') && $qv['page_id'] == get_option('page_for_posts')) {
1014 1014
 				$this->is_page = false;
1015 1015
 				$this->is_home = true;
1016 1016
 				$this->is_posts_page = true;
1017 1017
 			}
1018 1018
 		}
1019 1019
 
1020
-		if ( !empty($qv['post_type']) ) {
1021
-			if ( is_array($qv['post_type']) )
1020
+		if ( ! empty($qv['post_type'])) {
1021
+			if (is_array($qv['post_type']))
1022 1022
 				$qv['post_type'] = array_map('sanitize_key', $qv['post_type']);
1023 1023
 			else
1024 1024
 				$qv['post_type'] = sanitize_key($qv['post_type']);
1025 1025
 		}
1026 1026
 
1027
-		if ( ! empty( $qv['post_status'] ) ) {
1028
-			if ( is_array( $qv['post_status'] ) )
1027
+		if ( ! empty($qv['post_status'])) {
1028
+			if (is_array($qv['post_status']))
1029 1029
 				$qv['post_status'] = array_map('sanitize_key', $qv['post_status']);
1030 1030
 			else
1031 1031
 				$qv['post_status'] = preg_replace('|[^a-z0-9_,-]|', '', $qv['post_status']);
1032 1032
 		}
1033 1033
 
1034
-		if ( $this->is_posts_page && ( ! isset($qv['withcomments']) || ! $qv['withcomments'] ) )
1034
+		if ($this->is_posts_page && ( ! isset($qv['withcomments']) || ! $qv['withcomments']))
1035 1035
 			$this->is_comment_feed = false;
1036 1036
 
1037 1037
 		$this->is_singular = $this->is_single || $this->is_page || $this->is_attachment;
1038 1038
 		// Done correcting is_* for page_on_front and page_for_posts
1039 1039
 
1040
-		if ( '404' == $qv['error'] )
1040
+		if ('404' == $qv['error'])
1041 1041
 			$this->set_404();
1042 1042
 
1043
-		$this->is_embed = $this->is_embed && ( $this->is_singular || $this->is_404 );
1043
+		$this->is_embed = $this->is_embed && ($this->is_singular || $this->is_404);
1044 1044
 
1045
-		$this->query_vars_hash = md5( serialize( $this->query_vars ) );
1045
+		$this->query_vars_hash = md5(serialize($this->query_vars));
1046 1046
 		$this->query_vars_changed = false;
1047 1047
 
1048 1048
 		/**
@@ -1052,7 +1052,7 @@  discard block
 block discarded – undo
1052 1052
 		 *
1053 1053
 		 * @param WP_Query &$this The WP_Query instance (passed by reference).
1054 1054
 		 */
1055
-		do_action_ref_array( 'parse_query', array( &$this ) );
1055
+		do_action_ref_array('parse_query', array(&$this));
1056 1056
 	}
1057 1057
 
1058 1058
 	/**
@@ -1065,77 +1065,77 @@  discard block
 block discarded – undo
1065 1065
 	 *
1066 1066
 	 * @param array $q The query variables. Passed by reference.
1067 1067
 	 */
1068
-	public function parse_tax_query( &$q ) {
1069
-		if ( ! empty( $q['tax_query'] ) && is_array( $q['tax_query'] ) ) {
1068
+	public function parse_tax_query(&$q) {
1069
+		if ( ! empty($q['tax_query']) && is_array($q['tax_query'])) {
1070 1070
 			$tax_query = $q['tax_query'];
1071 1071
 		} else {
1072 1072
 			$tax_query = array();
1073 1073
 		}
1074 1074
 
1075
-		if ( !empty($q['taxonomy']) && !empty($q['term']) ) {
1075
+		if ( ! empty($q['taxonomy']) && ! empty($q['term'])) {
1076 1076
 			$tax_query[] = array(
1077 1077
 				'taxonomy' => $q['taxonomy'],
1078
-				'terms' => array( $q['term'] ),
1078
+				'terms' => array($q['term']),
1079 1079
 				'field' => 'slug',
1080 1080
 			);
1081 1081
 		}
1082 1082
 
1083
-		foreach ( get_taxonomies( array() , 'objects' ) as $taxonomy => $t ) {
1084
-			if ( 'post_tag' == $taxonomy )
1085
-				continue;	// Handled further down in the $q['tag'] block
1083
+		foreach (get_taxonomies(array(), 'objects') as $taxonomy => $t) {
1084
+			if ('post_tag' == $taxonomy)
1085
+				continue; // Handled further down in the $q['tag'] block
1086 1086
 
1087
-			if ( $t->query_var && !empty( $q[$t->query_var] ) ) {
1087
+			if ($t->query_var && ! empty($q[$t->query_var])) {
1088 1088
 				$tax_query_defaults = array(
1089 1089
 					'taxonomy' => $taxonomy,
1090 1090
 					'field' => 'slug',
1091 1091
 				);
1092 1092
 
1093
- 				if ( isset( $t->rewrite['hierarchical'] ) && $t->rewrite['hierarchical'] ) {
1094
-					$q[$t->query_var] = wp_basename( $q[$t->query_var] );
1093
+ 				if (isset($t->rewrite['hierarchical']) && $t->rewrite['hierarchical']) {
1094
+					$q[$t->query_var] = wp_basename($q[$t->query_var]);
1095 1095
 				}
1096 1096
 
1097 1097
 				$term = $q[$t->query_var];
1098 1098
 
1099
-				if ( is_array( $term ) ) {
1100
-					$term = implode( ',', $term );
1099
+				if (is_array($term)) {
1100
+					$term = implode(',', $term);
1101 1101
 				}
1102 1102
 
1103
-				if ( strpos($term, '+') !== false ) {
1104
-					$terms = preg_split( '/[+]+/', $term );
1105
-					foreach ( $terms as $term ) {
1106
-						$tax_query[] = array_merge( $tax_query_defaults, array(
1107
-							'terms' => array( $term )
1108
-						) );
1103
+				if (strpos($term, '+') !== false) {
1104
+					$terms = preg_split('/[+]+/', $term);
1105
+					foreach ($terms as $term) {
1106
+						$tax_query[] = array_merge($tax_query_defaults, array(
1107
+							'terms' => array($term)
1108
+						));
1109 1109
 					}
1110 1110
 				} else {
1111
-					$tax_query[] = array_merge( $tax_query_defaults, array(
1112
-						'terms' => preg_split( '/[,]+/', $term )
1113
-					) );
1111
+					$tax_query[] = array_merge($tax_query_defaults, array(
1112
+						'terms' => preg_split('/[,]+/', $term)
1113
+					));
1114 1114
 				}
1115 1115
 			}
1116 1116
 		}
1117 1117
 
1118 1118
 		// If querystring 'cat' is an array, implode it.
1119
-		if ( is_array( $q['cat'] ) ) {
1120
-			$q['cat'] = implode( ',', $q['cat'] );
1119
+		if (is_array($q['cat'])) {
1120
+			$q['cat'] = implode(',', $q['cat']);
1121 1121
 		}
1122 1122
 
1123 1123
 		// Category stuff
1124
-		if ( ! empty( $q['cat'] ) && ! $this->is_singular ) {
1124
+		if ( ! empty($q['cat']) && ! $this->is_singular) {
1125 1125
 			$cat_in = $cat_not_in = array();
1126 1126
 
1127
-			$cat_array = preg_split( '/[,\s]+/', urldecode( $q['cat'] ) );
1128
-			$cat_array = array_map( 'intval', $cat_array );
1129
-			$q['cat'] = implode( ',', $cat_array );
1127
+			$cat_array = preg_split('/[,\s]+/', urldecode($q['cat']));
1128
+			$cat_array = array_map('intval', $cat_array);
1129
+			$q['cat'] = implode(',', $cat_array);
1130 1130
 
1131
-			foreach ( $cat_array as $cat ) {
1132
-				if ( $cat > 0 )
1131
+			foreach ($cat_array as $cat) {
1132
+				if ($cat > 0)
1133 1133
 					$cat_in[] = $cat;
1134
-				elseif ( $cat < 0 )
1135
-					$cat_not_in[] = abs( $cat );
1134
+				elseif ($cat < 0)
1135
+					$cat_not_in[] = abs($cat);
1136 1136
 			}
1137 1137
 
1138
-			if ( ! empty( $cat_in ) ) {
1138
+			if ( ! empty($cat_in)) {
1139 1139
 				$tax_query[] = array(
1140 1140
 					'taxonomy' => 'category',
1141 1141
 					'terms' => $cat_in,
@@ -1144,7 +1144,7 @@  discard block
 block discarded – undo
1144 1144
 				);
1145 1145
 			}
1146 1146
 
1147
-			if ( ! empty( $cat_not_in ) ) {
1147
+			if ( ! empty($cat_not_in)) {
1148 1148
 				$tax_query[] = array(
1149 1149
 					'taxonomy' => 'category',
1150 1150
 					'terms' => $cat_not_in,
@@ -1153,19 +1153,19 @@  discard block
 block discarded – undo
1153 1153
 					'include_children' => true
1154 1154
 				);
1155 1155
 			}
1156
-			unset( $cat_array, $cat_in, $cat_not_in );
1156
+			unset($cat_array, $cat_in, $cat_not_in);
1157 1157
 		}
1158 1158
 
1159
-		if ( ! empty( $q['category__and'] ) && 1 === count( (array) $q['category__and'] ) ) {
1159
+		if ( ! empty($q['category__and']) && 1 === count((array) $q['category__and'])) {
1160 1160
 			$q['category__and'] = (array) $q['category__and'];
1161
-			if ( ! isset( $q['category__in'] ) )
1161
+			if ( ! isset($q['category__in']))
1162 1162
 				$q['category__in'] = array();
1163
-			$q['category__in'][] = absint( reset( $q['category__and'] ) );
1164
-			unset( $q['category__and'] );
1163
+			$q['category__in'][] = absint(reset($q['category__and']));
1164
+			unset($q['category__and']);
1165 1165
 		}
1166 1166
 
1167
-		if ( ! empty( $q['category__in'] ) ) {
1168
-			$q['category__in'] = array_map( 'absint', array_unique( (array) $q['category__in'] ) );
1167
+		if ( ! empty($q['category__in'])) {
1168
+			$q['category__in'] = array_map('absint', array_unique((array) $q['category__in']));
1169 1169
 			$tax_query[] = array(
1170 1170
 				'taxonomy' => 'category',
1171 1171
 				'terms' => $q['category__in'],
@@ -1174,8 +1174,8 @@  discard block
 block discarded – undo
1174 1174
 			);
1175 1175
 		}
1176 1176
 
1177
-		if ( ! empty($q['category__not_in']) ) {
1178
-			$q['category__not_in'] = array_map( 'absint', array_unique( (array) $q['category__not_in'] ) );
1177
+		if ( ! empty($q['category__not_in'])) {
1178
+			$q['category__not_in'] = array_map('absint', array_unique((array) $q['category__not_in']));
1179 1179
 			$tax_query[] = array(
1180 1180
 				'taxonomy' => 'category',
1181 1181
 				'terms' => $q['category__not_in'],
@@ -1184,8 +1184,8 @@  discard block
 block discarded – undo
1184 1184
 			);
1185 1185
 		}
1186 1186
 
1187
-		if ( ! empty($q['category__and']) ) {
1188
-			$q['category__and'] = array_map( 'absint', array_unique( (array) $q['category__and'] ) );
1187
+		if ( ! empty($q['category__and'])) {
1188
+			$q['category__and'] = array_map('absint', array_unique((array) $q['category__and']));
1189 1189
 			$tax_query[] = array(
1190 1190
 				'taxonomy' => 'category',
1191 1191
 				'terms' => $q['category__and'],
@@ -1196,21 +1196,21 @@  discard block
 block discarded – undo
1196 1196
 		}
1197 1197
 
1198 1198
 		// If querystring 'tag' is array, implode it.
1199
-		if ( is_array( $q['tag'] ) ) {
1200
-			$q['tag'] = implode( ',', $q['tag'] );
1199
+		if (is_array($q['tag'])) {
1200
+			$q['tag'] = implode(',', $q['tag']);
1201 1201
 		}
1202 1202
 
1203 1203
 		// Tag stuff
1204
-		if ( '' != $q['tag'] && !$this->is_singular && $this->query_vars_changed ) {
1205
-			if ( strpos($q['tag'], ',') !== false ) {
1204
+		if ('' != $q['tag'] && ! $this->is_singular && $this->query_vars_changed) {
1205
+			if (strpos($q['tag'], ',') !== false) {
1206 1206
 				$tags = preg_split('/[,\r\n\t ]+/', $q['tag']);
1207
-				foreach ( (array) $tags as $tag ) {
1207
+				foreach ((array) $tags as $tag) {
1208 1208
 					$tag = sanitize_term_field('slug', $tag, 0, 'post_tag', 'db');
1209 1209
 					$q['tag_slug__in'][] = $tag;
1210 1210
 				}
1211
-			} elseif ( preg_match('/[+\r\n\t ]+/', $q['tag'] ) || ! empty( $q['cat'] ) ) {
1211
+			} elseif (preg_match('/[+\r\n\t ]+/', $q['tag']) || ! empty($q['cat'])) {
1212 1212
 				$tags = preg_split('/[+\r\n\t ]+/', $q['tag']);
1213
-				foreach ( (array) $tags as $tag ) {
1213
+				foreach ((array) $tags as $tag) {
1214 1214
 					$tag = sanitize_term_field('slug', $tag, 0, 'post_tag', 'db');
1215 1215
 					$q['tag_slug__and'][] = $tag;
1216 1216
 				}
@@ -1220,24 +1220,24 @@  discard block
 block discarded – undo
1220 1220
 			}
1221 1221
 		}
1222 1222
 
1223
-		if ( !empty($q['tag_id']) ) {
1224
-			$q['tag_id'] = absint( $q['tag_id'] );
1223
+		if ( ! empty($q['tag_id'])) {
1224
+			$q['tag_id'] = absint($q['tag_id']);
1225 1225
 			$tax_query[] = array(
1226 1226
 				'taxonomy' => 'post_tag',
1227 1227
 				'terms' => $q['tag_id']
1228 1228
 			);
1229 1229
 		}
1230 1230
 
1231
-		if ( !empty($q['tag__in']) ) {
1232
-			$q['tag__in'] = array_map('absint', array_unique( (array) $q['tag__in'] ) );
1231
+		if ( ! empty($q['tag__in'])) {
1232
+			$q['tag__in'] = array_map('absint', array_unique((array) $q['tag__in']));
1233 1233
 			$tax_query[] = array(
1234 1234
 				'taxonomy' => 'post_tag',
1235 1235
 				'terms' => $q['tag__in']
1236 1236
 			);
1237 1237
 		}
1238 1238
 
1239
-		if ( !empty($q['tag__not_in']) ) {
1240
-			$q['tag__not_in'] = array_map('absint', array_unique( (array) $q['tag__not_in'] ) );
1239
+		if ( ! empty($q['tag__not_in'])) {
1240
+			$q['tag__not_in'] = array_map('absint', array_unique((array) $q['tag__not_in']));
1241 1241
 			$tax_query[] = array(
1242 1242
 				'taxonomy' => 'post_tag',
1243 1243
 				'terms' => $q['tag__not_in'],
@@ -1245,8 +1245,8 @@  discard block
 block discarded – undo
1245 1245
 			);
1246 1246
 		}
1247 1247
 
1248
-		if ( !empty($q['tag__and']) ) {
1249
-			$q['tag__and'] = array_map('absint', array_unique( (array) $q['tag__and'] ) );
1248
+		if ( ! empty($q['tag__and'])) {
1249
+			$q['tag__and'] = array_map('absint', array_unique((array) $q['tag__and']));
1250 1250
 			$tax_query[] = array(
1251 1251
 				'taxonomy' => 'post_tag',
1252 1252
 				'terms' => $q['tag__and'],
@@ -1254,8 +1254,8 @@  discard block
 block discarded – undo
1254 1254
 			);
1255 1255
 		}
1256 1256
 
1257
-		if ( !empty($q['tag_slug__in']) ) {
1258
-			$q['tag_slug__in'] = array_map('sanitize_title_for_query', array_unique( (array) $q['tag_slug__in'] ) );
1257
+		if ( ! empty($q['tag_slug__in'])) {
1258
+			$q['tag_slug__in'] = array_map('sanitize_title_for_query', array_unique((array) $q['tag_slug__in']));
1259 1259
 			$tax_query[] = array(
1260 1260
 				'taxonomy' => 'post_tag',
1261 1261
 				'terms' => $q['tag_slug__in'],
@@ -1263,8 +1263,8 @@  discard block
 block discarded – undo
1263 1263
 			);
1264 1264
 		}
1265 1265
 
1266
-		if ( !empty($q['tag_slug__and']) ) {
1267
-			$q['tag_slug__and'] = array_map('sanitize_title_for_query', array_unique( (array) $q['tag_slug__and'] ) );
1266
+		if ( ! empty($q['tag_slug__and'])) {
1267
+			$q['tag_slug__and'] = array_map('sanitize_title_for_query', array_unique((array) $q['tag_slug__and']));
1268 1268
 			$tax_query[] = array(
1269 1269
 				'taxonomy' => 'post_tag',
1270 1270
 				'terms' => $q['tag_slug__and'],
@@ -1273,7 +1273,7 @@  discard block
 block discarded – undo
1273 1273
 			);
1274 1274
 		}
1275 1275
 
1276
-		$this->tax_query = new WP_Tax_Query( $tax_query );
1276
+		$this->tax_query = new WP_Tax_Query($tax_query);
1277 1277
 
1278 1278
 		/**
1279 1279
 		 * Fires after taxonomy-related query vars have been parsed.
@@ -1282,7 +1282,7 @@  discard block
 block discarded – undo
1282 1282
 		 *
1283 1283
 		 * @param WP_Query $this The WP_Query instance.
1284 1284
 		 */
1285
-		do_action( 'parse_tax_query', $this );
1285
+		do_action('parse_tax_query', $this);
1286 1286
 	}
1287 1287
 
1288 1288
 	/**
@@ -1293,33 +1293,33 @@  discard block
 block discarded – undo
1293 1293
 	 * @param array $q Query variables.
1294 1294
 	 * @return string WHERE clause.
1295 1295
 	 */
1296
-	protected function parse_search( &$q ) {
1296
+	protected function parse_search(&$q) {
1297 1297
 		global $wpdb;
1298 1298
 
1299 1299
 		$search = '';
1300 1300
 
1301 1301
 		// added slashes screw with quote grouping when done early, so done later
1302
-		$q['s'] = stripslashes( $q['s'] );
1303
-		if ( empty( $_GET['s'] ) && $this->is_main_query() )
1304
-			$q['s'] = urldecode( $q['s'] );
1302
+		$q['s'] = stripslashes($q['s']);
1303
+		if (empty($_GET['s']) && $this->is_main_query())
1304
+			$q['s'] = urldecode($q['s']);
1305 1305
 		// there are no line breaks in <input /> fields
1306
-		$q['s'] = str_replace( array( "\r", "\n" ), '', $q['s'] );
1306
+		$q['s'] = str_replace(array("\r", "\n"), '', $q['s']);
1307 1307
 		$q['search_terms_count'] = 1;
1308
-		if ( ! empty( $q['sentence'] ) ) {
1309
-			$q['search_terms'] = array( $q['s'] );
1308
+		if ( ! empty($q['sentence'])) {
1309
+			$q['search_terms'] = array($q['s']);
1310 1310
 		} else {
1311
-			if ( preg_match_all( '/".*?("|$)|((?<=[\t ",+])|^)[^\t ",+]+/', $q['s'], $matches ) ) {
1312
-				$q['search_terms_count'] = count( $matches[0] );
1313
-				$q['search_terms'] = $this->parse_search_terms( $matches[0] );
1311
+			if (preg_match_all('/".*?("|$)|((?<=[\t ",+])|^)[^\t ",+]+/', $q['s'], $matches)) {
1312
+				$q['search_terms_count'] = count($matches[0]);
1313
+				$q['search_terms'] = $this->parse_search_terms($matches[0]);
1314 1314
 				// if the search string has only short terms or stopwords, or is 10+ terms long, match it as sentence
1315
-				if ( empty( $q['search_terms'] ) || count( $q['search_terms'] ) > 9 )
1316
-					$q['search_terms'] = array( $q['s'] );
1315
+				if (empty($q['search_terms']) || count($q['search_terms']) > 9)
1316
+					$q['search_terms'] = array($q['s']);
1317 1317
 			} else {
1318
-				$q['search_terms'] = array( $q['s'] );
1318
+				$q['search_terms'] = array($q['s']);
1319 1319
 			}
1320 1320
 		}
1321 1321
 
1322
-		$n = ! empty( $q['exact'] ) ? '' : '%';
1322
+		$n = ! empty($q['exact']) ? '' : '%';
1323 1323
 		$searchand = '';
1324 1324
 		$q['search_orderby_title'] = array();
1325 1325
 
@@ -1331,33 +1331,33 @@  discard block
 block discarded – undo
1331 1331
 		 * @param string $exclusion_prefix The prefix. Default '-'. Returning
1332 1332
 		 *                                 an empty value disables exclusions.
1333 1333
 		 */
1334
-		$exclusion_prefix = apply_filters( 'wp_query_search_exclusion_prefix', '-' );
1334
+		$exclusion_prefix = apply_filters('wp_query_search_exclusion_prefix', '-');
1335 1335
 
1336
-		foreach ( $q['search_terms'] as $term ) {
1336
+		foreach ($q['search_terms'] as $term) {
1337 1337
 			// If there is an $exclusion_prefix, terms prefixed with it should be excluded.
1338
-			$exclude = $exclusion_prefix && ( $exclusion_prefix === substr( $term, 0, 1 ) );
1339
-			if ( $exclude ) {
1338
+			$exclude = $exclusion_prefix && ($exclusion_prefix === substr($term, 0, 1));
1339
+			if ($exclude) {
1340 1340
 				$like_op  = 'NOT LIKE';
1341 1341
 				$andor_op = 'AND';
1342
-				$term     = substr( $term, 1 );
1342
+				$term     = substr($term, 1);
1343 1343
 			} else {
1344 1344
 				$like_op  = 'LIKE';
1345 1345
 				$andor_op = 'OR';
1346 1346
 			}
1347 1347
 
1348
-			if ( $n && ! $exclude ) {
1349
-				$like = '%' . $wpdb->esc_like( $term ) . '%';
1350
-				$q['search_orderby_title'][] = $wpdb->prepare( "{$wpdb->posts}.post_title LIKE %s", $like );
1348
+			if ($n && ! $exclude) {
1349
+				$like = '%'.$wpdb->esc_like($term).'%';
1350
+				$q['search_orderby_title'][] = $wpdb->prepare("{$wpdb->posts}.post_title LIKE %s", $like);
1351 1351
 			}
1352 1352
 
1353
-			$like = $n . $wpdb->esc_like( $term ) . $n;
1354
-			$search .= $wpdb->prepare( "{$searchand}(({$wpdb->posts}.post_title $like_op %s) $andor_op ({$wpdb->posts}.post_excerpt $like_op %s) $andor_op ({$wpdb->posts}.post_content $like_op %s))", $like, $like, $like );
1353
+			$like = $n.$wpdb->esc_like($term).$n;
1354
+			$search .= $wpdb->prepare("{$searchand}(({$wpdb->posts}.post_title $like_op %s) $andor_op ({$wpdb->posts}.post_excerpt $like_op %s) $andor_op ({$wpdb->posts}.post_content $like_op %s))", $like, $like, $like);
1355 1355
 			$searchand = ' AND ';
1356 1356
 		}
1357 1357
 
1358
-		if ( ! empty( $search ) ) {
1358
+		if ( ! empty($search)) {
1359 1359
 			$search = " AND ({$search}) ";
1360
-			if ( ! is_user_logged_in() ) {
1360
+			if ( ! is_user_logged_in()) {
1361 1361
 				$search .= " AND ({$wpdb->posts}.post_password = '') ";
1362 1362
 			}
1363 1363
 		}
@@ -1377,24 +1377,24 @@  discard block
 block discarded – undo
1377 1377
 	 * @param array $terms Terms to check.
1378 1378
 	 * @return array Terms that are not stopwords.
1379 1379
 	 */
1380
-	protected function parse_search_terms( $terms ) {
1381
-		$strtolower = function_exists( 'mb_strtolower' ) ? 'mb_strtolower' : 'strtolower';
1380
+	protected function parse_search_terms($terms) {
1381
+		$strtolower = function_exists('mb_strtolower') ? 'mb_strtolower' : 'strtolower';
1382 1382
 		$checked = array();
1383 1383
 
1384 1384
 		$stopwords = $this->get_search_stopwords();
1385 1385
 
1386
-		foreach ( $terms as $term ) {
1386
+		foreach ($terms as $term) {
1387 1387
 			// keep before/after spaces when term is for exact match
1388
-			if ( preg_match( '/^".+"$/', $term ) )
1389
-				$term = trim( $term, "\"'" );
1388
+			if (preg_match('/^".+"$/', $term))
1389
+				$term = trim($term, "\"'");
1390 1390
 			else
1391
-				$term = trim( $term, "\"' " );
1391
+				$term = trim($term, "\"' ");
1392 1392
 
1393 1393
 			// Avoid single A-Z and single dashes.
1394
-			if ( ! $term || ( 1 === strlen( $term ) && preg_match( '/^[a-z\-]$/i', $term ) ) )
1394
+			if ( ! $term || (1 === strlen($term) && preg_match('/^[a-z\-]$/i', $term)))
1395 1395
 				continue;
1396 1396
 
1397
-			if ( in_array( call_user_func( $strtolower, $term ), $stopwords, true ) )
1397
+			if (in_array(call_user_func($strtolower, $term), $stopwords, true))
1398 1398
 				continue;
1399 1399
 
1400 1400
 			$checked[] = $term;
@@ -1411,20 +1411,20 @@  discard block
 block discarded – undo
1411 1411
 	 * @return array Stopwords.
1412 1412
 	 */
1413 1413
 	protected function get_search_stopwords() {
1414
-		if ( isset( $this->stopwords ) )
1414
+		if (isset($this->stopwords))
1415 1415
 			return $this->stopwords;
1416 1416
 
1417 1417
 		/* translators: This is a comma-separated list of very common words that should be excluded from a search,
1418 1418
 		 * like a, an, and the. These are usually called "stopwords". You should not simply translate these individual
1419 1419
 		 * words into your language. Instead, look for and provide commonly accepted stopwords in your language.
1420 1420
 		 */
1421
-		$words = explode( ',', _x( 'about,an,are,as,at,be,by,com,for,from,how,in,is,it,of,on,or,that,the,this,to,was,what,when,where,who,will,with,www',
1422
-			'Comma-separated list of search stopwords in your language' ) );
1421
+		$words = explode(',', _x('about,an,are,as,at,be,by,com,for,from,how,in,is,it,of,on,or,that,the,this,to,was,what,when,where,who,will,with,www',
1422
+			'Comma-separated list of search stopwords in your language'));
1423 1423
 
1424 1424
 		$stopwords = array();
1425
-		foreach ( $words as $word ) {
1426
-			$word = trim( $word, "\r\n\t " );
1427
-			if ( $word )
1425
+		foreach ($words as $word) {
1426
+			$word = trim($word, "\r\n\t ");
1427
+			if ($word)
1428 1428
 				$stopwords[] = $word;
1429 1429
 		}
1430 1430
 
@@ -1435,7 +1435,7 @@  discard block
 block discarded – undo
1435 1435
 		 *
1436 1436
 		 * @param array $stopwords Stopwords.
1437 1437
 		 */
1438
-		$this->stopwords = apply_filters( 'wp_search_stopwords', $stopwords );
1438
+		$this->stopwords = apply_filters('wp_search_stopwords', $stopwords);
1439 1439
 		return $this->stopwords;
1440 1440
 	}
1441 1441
 
@@ -1445,47 +1445,47 @@  discard block
 block discarded – undo
1445 1445
 	 * @param array $q Query variables.
1446 1446
 	 * @return string ORDER BY clause.
1447 1447
 	 */
1448
-	protected function parse_search_order( &$q ) {
1448
+	protected function parse_search_order(&$q) {
1449 1449
 		global $wpdb;
1450 1450
 
1451
-		if ( $q['search_terms_count'] > 1 ) {
1452
-			$num_terms = count( $q['search_orderby_title'] );
1451
+		if ($q['search_terms_count'] > 1) {
1452
+			$num_terms = count($q['search_orderby_title']);
1453 1453
 
1454 1454
 			// If the search terms contain negative queries, don't bother ordering by sentence matches.
1455 1455
 			$like = '';
1456
-			if ( ! preg_match( '/(?:\s|^)\-/', $q['s'] ) ) {
1457
-				$like = '%' . $wpdb->esc_like( $q['s'] ) . '%';
1456
+			if ( ! preg_match('/(?:\s|^)\-/', $q['s'])) {
1457
+				$like = '%'.$wpdb->esc_like($q['s']).'%';
1458 1458
 			}
1459 1459
 
1460 1460
 			$search_orderby = '';
1461 1461
 
1462 1462
 			// sentence match in 'post_title'
1463
-			if ( $like ) {
1464
-				$search_orderby .= $wpdb->prepare( "WHEN {$wpdb->posts}.post_title LIKE %s THEN 1 ", $like );
1463
+			if ($like) {
1464
+				$search_orderby .= $wpdb->prepare("WHEN {$wpdb->posts}.post_title LIKE %s THEN 1 ", $like);
1465 1465
 			}
1466 1466
 
1467 1467
 			// sanity limit, sort as sentence when more than 6 terms
1468 1468
 			// (few searches are longer than 6 terms and most titles are not)
1469
-			if ( $num_terms < 7 ) {
1469
+			if ($num_terms < 7) {
1470 1470
 				// all words in title
1471
-				$search_orderby .= 'WHEN ' . implode( ' AND ', $q['search_orderby_title'] ) . ' THEN 2 ';
1471
+				$search_orderby .= 'WHEN '.implode(' AND ', $q['search_orderby_title']).' THEN 2 ';
1472 1472
 				// any word in title, not needed when $num_terms == 1
1473
-				if ( $num_terms > 1 )
1474
-					$search_orderby .= 'WHEN ' . implode( ' OR ', $q['search_orderby_title'] ) . ' THEN 3 ';
1473
+				if ($num_terms > 1)
1474
+					$search_orderby .= 'WHEN '.implode(' OR ', $q['search_orderby_title']).' THEN 3 ';
1475 1475
 			}
1476 1476
 
1477 1477
 			// Sentence match in 'post_content' and 'post_excerpt'.
1478
-			if ( $like ) {
1479
-				$search_orderby .= $wpdb->prepare( "WHEN {$wpdb->posts}.post_excerpt LIKE %s THEN 4 ", $like );
1480
-				$search_orderby .= $wpdb->prepare( "WHEN {$wpdb->posts}.post_content LIKE %s THEN 5 ", $like );
1478
+			if ($like) {
1479
+				$search_orderby .= $wpdb->prepare("WHEN {$wpdb->posts}.post_excerpt LIKE %s THEN 4 ", $like);
1480
+				$search_orderby .= $wpdb->prepare("WHEN {$wpdb->posts}.post_content LIKE %s THEN 5 ", $like);
1481 1481
 			}
1482 1482
 
1483
-			if ( $search_orderby ) {
1484
-				$search_orderby = '(CASE ' . $search_orderby . 'ELSE 6 END)';
1483
+			if ($search_orderby) {
1484
+				$search_orderby = '(CASE '.$search_orderby.'ELSE 6 END)';
1485 1485
 			}
1486 1486
 		} else {
1487 1487
 			// single word or sentence search
1488
-			$search_orderby = reset( $q['search_orderby_title'] ) . ' DESC';
1488
+			$search_orderby = reset($q['search_orderby_title']).' DESC';
1489 1489
 		}
1490 1490
 
1491 1491
 		return $search_orderby;
@@ -1501,7 +1501,7 @@  discard block
 block discarded – undo
1501 1501
 	 * @param string $orderby Alias for the field to order by.
1502 1502
 	 * @return string|false Table-prefixed value to used in the ORDER clause. False otherwise.
1503 1503
 	 */
1504
-	protected function parse_orderby( $orderby ) {
1504
+	protected function parse_orderby($orderby) {
1505 1505
 		global $wpdb;
1506 1506
 
1507 1507
 		// Used to filter values.
@@ -1514,32 +1514,32 @@  discard block
 block discarded – undo
1514 1514
 		$primary_meta_key = '';
1515 1515
 		$primary_meta_query = false;
1516 1516
 		$meta_clauses = $this->meta_query->get_clauses();
1517
-		if ( ! empty( $meta_clauses ) ) {
1518
-			$primary_meta_query = reset( $meta_clauses );
1517
+		if ( ! empty($meta_clauses)) {
1518
+			$primary_meta_query = reset($meta_clauses);
1519 1519
 
1520
-			if ( ! empty( $primary_meta_query['key'] ) ) {
1520
+			if ( ! empty($primary_meta_query['key'])) {
1521 1521
 				$primary_meta_key = $primary_meta_query['key'];
1522 1522
 				$allowed_keys[] = $primary_meta_key;
1523 1523
 			}
1524 1524
 
1525 1525
 			$allowed_keys[] = 'meta_value';
1526 1526
 			$allowed_keys[] = 'meta_value_num';
1527
-			$allowed_keys   = array_merge( $allowed_keys, array_keys( $meta_clauses ) );
1527
+			$allowed_keys   = array_merge($allowed_keys, array_keys($meta_clauses));
1528 1528
 		}
1529 1529
 
1530 1530
 		// If RAND() contains a seed value, sanitize and add to allowed keys.
1531 1531
 		$rand_with_seed = false;
1532
-		if ( preg_match( '/RAND\(([0-9]+)\)/i', $orderby, $matches ) ) {
1533
-			$orderby = sprintf( 'RAND(%s)', intval( $matches[1] ) );
1532
+		if (preg_match('/RAND\(([0-9]+)\)/i', $orderby, $matches)) {
1533
+			$orderby = sprintf('RAND(%s)', intval($matches[1]));
1534 1534
 			$allowed_keys[] = $orderby;
1535 1535
 			$rand_with_seed = true;
1536 1536
 		}
1537 1537
 
1538
-		if ( ! in_array( $orderby, $allowed_keys, true ) ) {
1538
+		if ( ! in_array($orderby, $allowed_keys, true)) {
1539 1539
 			return false;
1540 1540
 		}
1541 1541
 
1542
-		switch ( $orderby ) {
1542
+		switch ($orderby) {
1543 1543
 			case 'post_name':
1544 1544
 			case 'post_author':
1545 1545
 			case 'post_date':
@@ -1557,7 +1557,7 @@  discard block
 block discarded – undo
1557 1557
 				break;
1558 1558
 			case $primary_meta_key:
1559 1559
 			case 'meta_value':
1560
-				if ( ! empty( $primary_meta_query['type'] ) ) {
1560
+				if ( ! empty($primary_meta_query['type'])) {
1561 1561
 					$orderby_clause = "CAST({$primary_meta_query['alias']}.meta_value AS {$primary_meta_query['cast']})";
1562 1562
 				} else {
1563 1563
 					$orderby_clause = "{$primary_meta_query['alias']}.meta_value";
@@ -1567,15 +1567,15 @@  discard block
 block discarded – undo
1567 1567
 				$orderby_clause = "{$primary_meta_query['alias']}.meta_value+0";
1568 1568
 				break;
1569 1569
 			default:
1570
-				if ( array_key_exists( $orderby, $meta_clauses ) ) {
1570
+				if (array_key_exists($orderby, $meta_clauses)) {
1571 1571
 					// $orderby corresponds to a meta_query clause.
1572
-					$meta_clause = $meta_clauses[ $orderby ];
1572
+					$meta_clause = $meta_clauses[$orderby];
1573 1573
 					$orderby_clause = "CAST({$meta_clause['alias']}.meta_value AS {$meta_clause['cast']})";
1574
-				} elseif ( $rand_with_seed ) {
1574
+				} elseif ($rand_with_seed) {
1575 1575
 					$orderby_clause = $orderby;
1576 1576
 				} else {
1577 1577
 					// Default: order by post field.
1578
-					$orderby_clause = "{$wpdb->posts}.post_" . sanitize_key( $orderby );
1578
+					$orderby_clause = "{$wpdb->posts}.post_".sanitize_key($orderby);
1579 1579
 				}
1580 1580
 
1581 1581
 				break;
@@ -1593,12 +1593,12 @@  discard block
 block discarded – undo
1593 1593
 	 * @param string $order The 'order' query variable.
1594 1594
 	 * @return string The sanitized 'order' query variable.
1595 1595
 	 */
1596
-	protected function parse_order( $order ) {
1597
-		if ( ! is_string( $order ) || empty( $order ) ) {
1596
+	protected function parse_order($order) {
1597
+		if ( ! is_string($order) || empty($order)) {
1598 1598
 			return 'DESC';
1599 1599
 		}
1600 1600
 
1601
-		if ( 'ASC' === strtoupper( $order ) ) {
1601
+		if ('ASC' === strtoupper($order)) {
1602 1602
 			return 'ASC';
1603 1603
 		} else {
1604 1604
 			return 'DESC';
@@ -1632,9 +1632,9 @@  discard block
 block discarded – undo
1632 1632
 	 * @param mixed  $default   Optional. Value to return if the query variable is not set. Default empty.
1633 1633
 	 * @return mixed Contents of the query variable.
1634 1634
 	 */
1635
-	public function get( $query_var, $default = '' ) {
1636
-		if ( isset( $this->query_vars[ $query_var ] ) ) {
1637
-			return $this->query_vars[ $query_var ];
1635
+	public function get($query_var, $default = '') {
1636
+		if (isset($this->query_vars[$query_var])) {
1637
+			return $this->query_vars[$query_var];
1638 1638
 		}
1639 1639
 
1640 1640
 		return $default;
@@ -1680,7 +1680,7 @@  discard block
 block discarded – undo
1680 1680
 		 *
1681 1681
 		 * @param WP_Query &$this The WP_Query instance (passed by reference).
1682 1682
 		 */
1683
-		do_action_ref_array( 'pre_get_posts', array( &$this ) );
1683
+		do_action_ref_array('pre_get_posts', array(&$this));
1684 1684
 
1685 1685
 		// Shorthand.
1686 1686
 		$q = &$this->query_vars;
@@ -1690,11 +1690,11 @@  discard block
 block discarded – undo
1690 1690
 
1691 1691
 		// Parse meta query
1692 1692
 		$this->meta_query = new WP_Meta_Query();
1693
-		$this->meta_query->parse_query_vars( $q );
1693
+		$this->meta_query->parse_query_vars($q);
1694 1694
 
1695 1695
 		// Set a flag if a pre_get_posts hook changed the query vars.
1696
-		$hash = md5( serialize( $this->query_vars ) );
1697
-		if ( $hash != $this->query_vars_hash ) {
1696
+		$hash = md5(serialize($this->query_vars));
1697
+		if ($hash != $this->query_vars_hash) {
1698 1698
 			$this->query_vars_changed = true;
1699 1699
 			$this->query_vars_hash = $hash;
1700 1700
 		}
@@ -1712,103 +1712,103 @@  discard block
 block discarded – undo
1712 1712
 		$post_status_join = false;
1713 1713
 		$page = 1;
1714 1714
 
1715
-		if ( isset( $q['caller_get_posts'] ) ) {
1716
-			_deprecated_argument( 'WP_Query', '3.1.0',
1715
+		if (isset($q['caller_get_posts'])) {
1716
+			_deprecated_argument('WP_Query', '3.1.0',
1717 1717
 				/* translators: 1: caller_get_posts, 2: ignore_sticky_posts */
1718
-				sprintf( __( '%1$s is deprecated. Use %2$s instead.' ),
1718
+				sprintf(__('%1$s is deprecated. Use %2$s instead.'),
1719 1719
 					'<code>caller_get_posts</code>',
1720 1720
 					'<code>ignore_sticky_posts</code>'
1721 1721
 				)
1722 1722
 			);
1723 1723
 
1724
-			if ( ! isset( $q['ignore_sticky_posts'] ) ) {
1724
+			if ( ! isset($q['ignore_sticky_posts'])) {
1725 1725
 				$q['ignore_sticky_posts'] = $q['caller_get_posts'];
1726 1726
 			}
1727 1727
 		}
1728 1728
 
1729
-		if ( !isset( $q['ignore_sticky_posts'] ) )
1729
+		if ( ! isset($q['ignore_sticky_posts']))
1730 1730
 			$q['ignore_sticky_posts'] = false;
1731 1731
 
1732
-		if ( !isset($q['suppress_filters']) )
1732
+		if ( ! isset($q['suppress_filters']))
1733 1733
 			$q['suppress_filters'] = false;
1734 1734
 
1735
-		if ( !isset($q['cache_results']) ) {
1736
-			if ( wp_using_ext_object_cache() )
1735
+		if ( ! isset($q['cache_results'])) {
1736
+			if (wp_using_ext_object_cache())
1737 1737
 				$q['cache_results'] = false;
1738 1738
 			else
1739 1739
 				$q['cache_results'] = true;
1740 1740
 		}
1741 1741
 
1742
-		if ( !isset($q['update_post_term_cache']) )
1742
+		if ( ! isset($q['update_post_term_cache']))
1743 1743
 			$q['update_post_term_cache'] = true;
1744 1744
 
1745
-		if ( ! isset( $q['lazy_load_term_meta'] ) ) {
1745
+		if ( ! isset($q['lazy_load_term_meta'])) {
1746 1746
 			$q['lazy_load_term_meta'] = $q['update_post_term_cache'];
1747 1747
 		}
1748 1748
 
1749
-		if ( !isset($q['update_post_meta_cache']) )
1749
+		if ( ! isset($q['update_post_meta_cache']))
1750 1750
 			$q['update_post_meta_cache'] = true;
1751 1751
 
1752
-		if ( !isset($q['post_type']) ) {
1753
-			if ( $this->is_search )
1752
+		if ( ! isset($q['post_type'])) {
1753
+			if ($this->is_search)
1754 1754
 				$q['post_type'] = 'any';
1755 1755
 			else
1756 1756
 				$q['post_type'] = '';
1757 1757
 		}
1758 1758
 		$post_type = $q['post_type'];
1759
-		if ( empty( $q['posts_per_page'] ) ) {
1760
-			$q['posts_per_page'] = get_option( 'posts_per_page' );
1759
+		if (empty($q['posts_per_page'])) {
1760
+			$q['posts_per_page'] = get_option('posts_per_page');
1761 1761
 		}
1762
-		if ( isset($q['showposts']) && $q['showposts'] ) {
1762
+		if (isset($q['showposts']) && $q['showposts']) {
1763 1763
 			$q['showposts'] = (int) $q['showposts'];
1764 1764
 			$q['posts_per_page'] = $q['showposts'];
1765 1765
 		}
1766
-		if ( (isset($q['posts_per_archive_page']) && $q['posts_per_archive_page'] != 0) && ($this->is_archive || $this->is_search) )
1766
+		if ((isset($q['posts_per_archive_page']) && $q['posts_per_archive_page'] != 0) && ($this->is_archive || $this->is_search))
1767 1767
 			$q['posts_per_page'] = $q['posts_per_archive_page'];
1768
-		if ( !isset($q['nopaging']) ) {
1769
-			if ( $q['posts_per_page'] == -1 ) {
1768
+		if ( ! isset($q['nopaging'])) {
1769
+			if ($q['posts_per_page'] == -1) {
1770 1770
 				$q['nopaging'] = true;
1771 1771
 			} else {
1772 1772
 				$q['nopaging'] = false;
1773 1773
 			}
1774 1774
 		}
1775 1775
 
1776
-		if ( $this->is_feed ) {
1776
+		if ($this->is_feed) {
1777 1777
 			// This overrides posts_per_page.
1778
-			if ( ! empty( $q['posts_per_rss'] ) ) {
1778
+			if ( ! empty($q['posts_per_rss'])) {
1779 1779
 				$q['posts_per_page'] = $q['posts_per_rss'];
1780 1780
 			} else {
1781
-				$q['posts_per_page'] = get_option( 'posts_per_rss' );
1781
+				$q['posts_per_page'] = get_option('posts_per_rss');
1782 1782
 			}
1783 1783
 			$q['nopaging'] = false;
1784 1784
 		}
1785 1785
 		$q['posts_per_page'] = (int) $q['posts_per_page'];
1786
-		if ( $q['posts_per_page'] < -1 )
1786
+		if ($q['posts_per_page'] < -1)
1787 1787
 			$q['posts_per_page'] = abs($q['posts_per_page']);
1788
-		elseif ( $q['posts_per_page'] == 0 )
1788
+		elseif ($q['posts_per_page'] == 0)
1789 1789
 			$q['posts_per_page'] = 1;
1790 1790
 
1791
-		if ( !isset($q['comments_per_page']) || $q['comments_per_page'] == 0 )
1791
+		if ( ! isset($q['comments_per_page']) || $q['comments_per_page'] == 0)
1792 1792
 			$q['comments_per_page'] = get_option('comments_per_page');
1793 1793
 
1794
-		if ( $this->is_home && (empty($this->query) || $q['preview'] == 'true') && ( 'page' == get_option('show_on_front') ) && get_option('page_on_front') ) {
1794
+		if ($this->is_home && (empty($this->query) || $q['preview'] == 'true') && ('page' == get_option('show_on_front')) && get_option('page_on_front')) {
1795 1795
 			$this->is_page = true;
1796 1796
 			$this->is_home = false;
1797 1797
 			$q['page_id'] = get_option('page_on_front');
1798 1798
 		}
1799 1799
 
1800
-		if ( isset($q['page']) ) {
1800
+		if (isset($q['page'])) {
1801 1801
 			$q['page'] = trim($q['page'], '/');
1802 1802
 			$q['page'] = absint($q['page']);
1803 1803
 		}
1804 1804
 
1805 1805
 		// If true, forcibly turns off SQL_CALC_FOUND_ROWS even when limits are present.
1806
-		if ( isset($q['no_found_rows']) )
1806
+		if (isset($q['no_found_rows']))
1807 1807
 			$q['no_found_rows'] = (bool) $q['no_found_rows'];
1808 1808
 		else
1809 1809
 			$q['no_found_rows'] = false;
1810 1810
 
1811
-		switch ( $q['fields'] ) {
1811
+		switch ($q['fields']) {
1812 1812
 			case 'ids':
1813 1813
 				$fields = "{$wpdb->posts}.ID";
1814 1814
 				break;
@@ -1819,79 +1819,79 @@  discard block
 block discarded – undo
1819 1819
 				$fields = "{$wpdb->posts}.*";
1820 1820
 		}
1821 1821
 
1822
-		if ( '' !== $q['menu_order'] ) {
1823
-			$where .= " AND {$wpdb->posts}.menu_order = " . $q['menu_order'];
1822
+		if ('' !== $q['menu_order']) {
1823
+			$where .= " AND {$wpdb->posts}.menu_order = ".$q['menu_order'];
1824 1824
 		}
1825 1825
 		// The "m" parameter is meant for months but accepts datetimes of varying specificity
1826
-		if ( $q['m'] ) {
1827
-			$where .= " AND YEAR({$wpdb->posts}.post_date)=" . substr($q['m'], 0, 4);
1828
-			if ( strlen($q['m']) > 5 ) {
1829
-				$where .= " AND MONTH({$wpdb->posts}.post_date)=" . substr($q['m'], 4, 2);
1826
+		if ($q['m']) {
1827
+			$where .= " AND YEAR({$wpdb->posts}.post_date)=".substr($q['m'], 0, 4);
1828
+			if (strlen($q['m']) > 5) {
1829
+				$where .= " AND MONTH({$wpdb->posts}.post_date)=".substr($q['m'], 4, 2);
1830 1830
 			}
1831
-			if ( strlen($q['m']) > 7 ) {
1832
-				$where .= " AND DAYOFMONTH({$wpdb->posts}.post_date)=" . substr($q['m'], 6, 2);
1831
+			if (strlen($q['m']) > 7) {
1832
+				$where .= " AND DAYOFMONTH({$wpdb->posts}.post_date)=".substr($q['m'], 6, 2);
1833 1833
 			}
1834
-			if ( strlen($q['m']) > 9 ) {
1835
-				$where .= " AND HOUR({$wpdb->posts}.post_date)=" . substr($q['m'], 8, 2);
1834
+			if (strlen($q['m']) > 9) {
1835
+				$where .= " AND HOUR({$wpdb->posts}.post_date)=".substr($q['m'], 8, 2);
1836 1836
 			}
1837
-			if ( strlen($q['m']) > 11 ) {
1838
-				$where .= " AND MINUTE({$wpdb->posts}.post_date)=" . substr($q['m'], 10, 2);
1837
+			if (strlen($q['m']) > 11) {
1838
+				$where .= " AND MINUTE({$wpdb->posts}.post_date)=".substr($q['m'], 10, 2);
1839 1839
 			}
1840
-			if ( strlen($q['m']) > 13 ) {
1841
-				$where .= " AND SECOND({$wpdb->posts}.post_date)=" . substr($q['m'], 12, 2);
1840
+			if (strlen($q['m']) > 13) {
1841
+				$where .= " AND SECOND({$wpdb->posts}.post_date)=".substr($q['m'], 12, 2);
1842 1842
 			}
1843 1843
 		}
1844 1844
 
1845 1845
 		// Handle the other individual date parameters
1846 1846
 		$date_parameters = array();
1847 1847
 
1848
-		if ( '' !== $q['hour'] )
1848
+		if ('' !== $q['hour'])
1849 1849
 			$date_parameters['hour'] = $q['hour'];
1850 1850
 
1851
-		if ( '' !== $q['minute'] )
1851
+		if ('' !== $q['minute'])
1852 1852
 			$date_parameters['minute'] = $q['minute'];
1853 1853
 
1854
-		if ( '' !== $q['second'] )
1854
+		if ('' !== $q['second'])
1855 1855
 			$date_parameters['second'] = $q['second'];
1856 1856
 
1857
-		if ( $q['year'] )
1857
+		if ($q['year'])
1858 1858
 			$date_parameters['year'] = $q['year'];
1859 1859
 
1860
-		if ( $q['monthnum'] )
1860
+		if ($q['monthnum'])
1861 1861
 			$date_parameters['monthnum'] = $q['monthnum'];
1862 1862
 
1863
-		if ( $q['w'] )
1863
+		if ($q['w'])
1864 1864
 			$date_parameters['week'] = $q['w'];
1865 1865
 
1866
-		if ( $q['day'] )
1866
+		if ($q['day'])
1867 1867
 			$date_parameters['day'] = $q['day'];
1868 1868
 
1869
-		if ( $date_parameters ) {
1870
-			$date_query = new WP_Date_Query( array( $date_parameters ) );
1869
+		if ($date_parameters) {
1870
+			$date_query = new WP_Date_Query(array($date_parameters));
1871 1871
 			$where .= $date_query->get_sql();
1872 1872
 		}
1873
-		unset( $date_parameters, $date_query );
1873
+		unset($date_parameters, $date_query);
1874 1874
 
1875 1875
 		// Handle complex date queries
1876
-		if ( ! empty( $q['date_query'] ) ) {
1877
-			$this->date_query = new WP_Date_Query( $q['date_query'] );
1876
+		if ( ! empty($q['date_query'])) {
1877
+			$this->date_query = new WP_Date_Query($q['date_query']);
1878 1878
 			$where .= $this->date_query->get_sql();
1879 1879
 		}
1880 1880
 
1881 1881
 
1882 1882
 		// If we've got a post_type AND it's not "any" post_type.
1883
-		if ( !empty($q['post_type']) && 'any' != $q['post_type'] ) {
1884
-			foreach ( (array)$q['post_type'] as $_post_type ) {
1883
+		if ( ! empty($q['post_type']) && 'any' != $q['post_type']) {
1884
+			foreach ((array) $q['post_type'] as $_post_type) {
1885 1885
 				$ptype_obj = get_post_type_object($_post_type);
1886
-				if ( !$ptype_obj || !$ptype_obj->query_var || empty($q[ $ptype_obj->query_var ]) )
1886
+				if ( ! $ptype_obj || ! $ptype_obj->query_var || empty($q[$ptype_obj->query_var]))
1887 1887
 					continue;
1888 1888
 
1889
-				if ( ! $ptype_obj->hierarchical ) {
1889
+				if ( ! $ptype_obj->hierarchical) {
1890 1890
 					// Non-hierarchical post types can directly use 'name'.
1891
-					$q['name'] = $q[ $ptype_obj->query_var ];
1891
+					$q['name'] = $q[$ptype_obj->query_var];
1892 1892
 				} else {
1893 1893
 					// Hierarchical post types will operate through 'pagename'.
1894
-					$q['pagename'] = $q[ $ptype_obj->query_var ];
1894
+					$q['pagename'] = $q[$ptype_obj->query_var];
1895 1895
 					$q['name'] = '';
1896 1896
 				}
1897 1897
 
@@ -1901,99 +1901,99 @@  discard block
 block discarded – undo
1901 1901
 			unset($ptype_obj);
1902 1902
 		}
1903 1903
 
1904
-		if ( '' !== $q['title'] ) {
1905
-			$where .= $wpdb->prepare( " AND {$wpdb->posts}.post_title = %s", stripslashes( $q['title'] ) );
1904
+		if ('' !== $q['title']) {
1905
+			$where .= $wpdb->prepare(" AND {$wpdb->posts}.post_title = %s", stripslashes($q['title']));
1906 1906
 		}
1907 1907
 
1908 1908
 		// Parameters related to 'post_name'.
1909
-		if ( '' != $q['name'] ) {
1910
-			$q['name'] = sanitize_title_for_query( $q['name'] );
1911
-			$where .= " AND {$wpdb->posts}.post_name = '" . $q['name'] . "'";
1912
-		} elseif ( '' != $q['pagename'] ) {
1913
-			if ( isset($this->queried_object_id) ) {
1909
+		if ('' != $q['name']) {
1910
+			$q['name'] = sanitize_title_for_query($q['name']);
1911
+			$where .= " AND {$wpdb->posts}.post_name = '".$q['name']."'";
1912
+		} elseif ('' != $q['pagename']) {
1913
+			if (isset($this->queried_object_id)) {
1914 1914
 				$reqpage = $this->queried_object_id;
1915 1915
 			} else {
1916
-				if ( 'page' != $q['post_type'] ) {
1917
-					foreach ( (array)$q['post_type'] as $_post_type ) {
1916
+				if ('page' != $q['post_type']) {
1917
+					foreach ((array) $q['post_type'] as $_post_type) {
1918 1918
 						$ptype_obj = get_post_type_object($_post_type);
1919
-						if ( !$ptype_obj || !$ptype_obj->hierarchical )
1919
+						if ( ! $ptype_obj || ! $ptype_obj->hierarchical)
1920 1920
 							continue;
1921 1921
 
1922 1922
 						$reqpage = get_page_by_path($q['pagename'], OBJECT, $_post_type);
1923
-						if ( $reqpage )
1923
+						if ($reqpage)
1924 1924
 							break;
1925 1925
 					}
1926 1926
 					unset($ptype_obj);
1927 1927
 				} else {
1928 1928
 					$reqpage = get_page_by_path($q['pagename']);
1929 1929
 				}
1930
-				if ( !empty($reqpage) )
1930
+				if ( ! empty($reqpage))
1931 1931
 					$reqpage = $reqpage->ID;
1932 1932
 				else
1933 1933
 					$reqpage = 0;
1934 1934
 			}
1935 1935
 
1936 1936
 			$page_for_posts = get_option('page_for_posts');
1937
-			if  ( ('page' != get_option('show_on_front') ) || empty($page_for_posts) || ( $reqpage != $page_for_posts ) ) {
1938
-				$q['pagename'] = sanitize_title_for_query( wp_basename( $q['pagename'] ) );
1937
+			if (('page' != get_option('show_on_front')) || empty($page_for_posts) || ($reqpage != $page_for_posts)) {
1938
+				$q['pagename'] = sanitize_title_for_query(wp_basename($q['pagename']));
1939 1939
 				$q['name'] = $q['pagename'];
1940 1940
 				$where .= " AND ({$wpdb->posts}.ID = '$reqpage')";
1941
-				$reqpage_obj = get_post( $reqpage );
1942
-				if ( is_object($reqpage_obj) && 'attachment' == $reqpage_obj->post_type ) {
1941
+				$reqpage_obj = get_post($reqpage);
1942
+				if (is_object($reqpage_obj) && 'attachment' == $reqpage_obj->post_type) {
1943 1943
 					$this->is_attachment = true;
1944 1944
 					$post_type = $q['post_type'] = 'attachment';
1945 1945
 					$this->is_page = true;
1946 1946
 					$q['attachment_id'] = $reqpage;
1947 1947
 				}
1948 1948
 			}
1949
-		} elseif ( '' != $q['attachment'] ) {
1950
-			$q['attachment'] = sanitize_title_for_query( wp_basename( $q['attachment'] ) );
1949
+		} elseif ('' != $q['attachment']) {
1950
+			$q['attachment'] = sanitize_title_for_query(wp_basename($q['attachment']));
1951 1951
 			$q['name'] = $q['attachment'];
1952
-			$where .= " AND {$wpdb->posts}.post_name = '" . $q['attachment'] . "'";
1953
-		} elseif ( is_array( $q['post_name__in'] ) && ! empty( $q['post_name__in'] ) ) {
1954
-			$q['post_name__in'] = array_map( 'sanitize_title_for_query', $q['post_name__in'] );
1955
-			$post_name__in = "'" . implode( "','", $q['post_name__in'] ) . "'";
1952
+			$where .= " AND {$wpdb->posts}.post_name = '".$q['attachment']."'";
1953
+		} elseif (is_array($q['post_name__in']) && ! empty($q['post_name__in'])) {
1954
+			$q['post_name__in'] = array_map('sanitize_title_for_query', $q['post_name__in']);
1955
+			$post_name__in = "'".implode("','", $q['post_name__in'])."'";
1956 1956
 			$where .= " AND {$wpdb->posts}.post_name IN ($post_name__in)";
1957 1957
 		}
1958 1958
 
1959 1959
 		// If an attachment is requested by number, let it supersede any post number.
1960
-		if ( $q['attachment_id'] )
1960
+		if ($q['attachment_id'])
1961 1961
 			$q['p'] = absint($q['attachment_id']);
1962 1962
 
1963 1963
 		// If a post number is specified, load that post
1964
-		if ( $q['p'] ) {
1965
-			$where .= " AND {$wpdb->posts}.ID = " . $q['p'];
1966
-		} elseif ( $q['post__in'] ) {
1967
-			$post__in = implode(',', array_map( 'absint', $q['post__in'] ));
1964
+		if ($q['p']) {
1965
+			$where .= " AND {$wpdb->posts}.ID = ".$q['p'];
1966
+		} elseif ($q['post__in']) {
1967
+			$post__in = implode(',', array_map('absint', $q['post__in']));
1968 1968
 			$where .= " AND {$wpdb->posts}.ID IN ($post__in)";
1969
-		} elseif ( $q['post__not_in'] ) {
1970
-			$post__not_in = implode(',',  array_map( 'absint', $q['post__not_in'] ));
1969
+		} elseif ($q['post__not_in']) {
1970
+			$post__not_in = implode(',', array_map('absint', $q['post__not_in']));
1971 1971
 			$where .= " AND {$wpdb->posts}.ID NOT IN ($post__not_in)";
1972 1972
 		}
1973 1973
 
1974
-		if ( is_numeric( $q['post_parent'] ) ) {
1975
-			$where .= $wpdb->prepare( " AND {$wpdb->posts}.post_parent = %d ", $q['post_parent'] );
1976
-		} elseif ( $q['post_parent__in'] ) {
1977
-			$post_parent__in = implode( ',', array_map( 'absint', $q['post_parent__in'] ) );
1974
+		if (is_numeric($q['post_parent'])) {
1975
+			$where .= $wpdb->prepare(" AND {$wpdb->posts}.post_parent = %d ", $q['post_parent']);
1976
+		} elseif ($q['post_parent__in']) {
1977
+			$post_parent__in = implode(',', array_map('absint', $q['post_parent__in']));
1978 1978
 			$where .= " AND {$wpdb->posts}.post_parent IN ($post_parent__in)";
1979
-		} elseif ( $q['post_parent__not_in'] ) {
1980
-			$post_parent__not_in = implode( ',',  array_map( 'absint', $q['post_parent__not_in'] ) );
1979
+		} elseif ($q['post_parent__not_in']) {
1980
+			$post_parent__not_in = implode(',', array_map('absint', $q['post_parent__not_in']));
1981 1981
 			$where .= " AND {$wpdb->posts}.post_parent NOT IN ($post_parent__not_in)";
1982 1982
 		}
1983 1983
 
1984
-		if ( $q['page_id'] ) {
1985
-			if  ( ('page' != get_option('show_on_front') ) || ( $q['page_id'] != get_option('page_for_posts') ) ) {
1984
+		if ($q['page_id']) {
1985
+			if (('page' != get_option('show_on_front')) || ($q['page_id'] != get_option('page_for_posts'))) {
1986 1986
 				$q['p'] = $q['page_id'];
1987
-				$where = " AND {$wpdb->posts}.ID = " . $q['page_id'];
1987
+				$where = " AND {$wpdb->posts}.ID = ".$q['page_id'];
1988 1988
 			}
1989 1989
 		}
1990 1990
 
1991 1991
 		// If a search pattern is specified, load the posts that match.
1992
-		if ( strlen( $q['s'] ) ) {
1993
-			$search = $this->parse_search( $q );
1992
+		if (strlen($q['s'])) {
1993
+			$search = $this->parse_search($q);
1994 1994
 		}
1995 1995
 
1996
-		if ( ! $q['suppress_filters'] ) {
1996
+		if ( ! $q['suppress_filters']) {
1997 1997
 			/**
1998 1998
 			 * Filters the search SQL that is used in the WHERE clause of WP_Query.
1999 1999
 			 *
@@ -2002,36 +2002,36 @@  discard block
 block discarded – undo
2002 2002
 			 * @param string   $search Search SQL for WHERE clause.
2003 2003
 			 * @param WP_Query $this   The current WP_Query object.
2004 2004
 			 */
2005
-			$search = apply_filters_ref_array( 'posts_search', array( $search, &$this ) );
2005
+			$search = apply_filters_ref_array('posts_search', array($search, &$this));
2006 2006
 		}
2007 2007
 
2008 2008
 		// Taxonomies
2009
-		if ( !$this->is_singular ) {
2010
-			$this->parse_tax_query( $q );
2009
+		if ( ! $this->is_singular) {
2010
+			$this->parse_tax_query($q);
2011 2011
 
2012
-			$clauses = $this->tax_query->get_sql( $wpdb->posts, 'ID' );
2012
+			$clauses = $this->tax_query->get_sql($wpdb->posts, 'ID');
2013 2013
 
2014 2014
 			$join .= $clauses['join'];
2015 2015
 			$where .= $clauses['where'];
2016 2016
 		}
2017 2017
 
2018
-		if ( $this->is_tax ) {
2019
-			if ( empty($post_type) ) {
2018
+		if ($this->is_tax) {
2019
+			if (empty($post_type)) {
2020 2020
 				// Do a fully inclusive search for currently registered post types of queried taxonomies
2021 2021
 				$post_type = array();
2022
-				$taxonomies = array_keys( $this->tax_query->queried_terms );
2023
-				foreach ( get_post_types( array( 'exclude_from_search' => false ) ) as $pt ) {
2024
-					$object_taxonomies = $pt === 'attachment' ? get_taxonomies_for_attachments() : get_object_taxonomies( $pt );
2025
-					if ( array_intersect( $taxonomies, $object_taxonomies ) )
2022
+				$taxonomies = array_keys($this->tax_query->queried_terms);
2023
+				foreach (get_post_types(array('exclude_from_search' => false)) as $pt) {
2024
+					$object_taxonomies = $pt === 'attachment' ? get_taxonomies_for_attachments() : get_object_taxonomies($pt);
2025
+					if (array_intersect($taxonomies, $object_taxonomies))
2026 2026
 						$post_type[] = $pt;
2027 2027
 				}
2028
-				if ( ! $post_type )
2028
+				if ( ! $post_type)
2029 2029
 					$post_type = 'any';
2030
-				elseif ( count( $post_type ) == 1 )
2030
+				elseif (count($post_type) == 1)
2031 2031
 					$post_type = $post_type[0];
2032 2032
 
2033 2033
 				$post_status_join = true;
2034
-			} elseif ( in_array('attachment', (array) $post_type) ) {
2034
+			} elseif (in_array('attachment', (array) $post_type)) {
2035 2035
 				$post_status_join = true;
2036 2036
 			}
2037 2037
 		}
@@ -2040,22 +2040,22 @@  discard block
 block discarded – undo
2040 2040
 		 * Ensure that 'taxonomy', 'term', 'term_id', 'cat', and
2041 2041
 		 * 'category_name' vars are set for backward compatibility.
2042 2042
 		 */
2043
-		if ( ! empty( $this->tax_query->queried_terms ) ) {
2043
+		if ( ! empty($this->tax_query->queried_terms)) {
2044 2044
 
2045 2045
 			/*
2046 2046
 			 * Set 'taxonomy', 'term', and 'term_id' to the
2047 2047
 			 * first taxonomy other than 'post_tag' or 'category'.
2048 2048
 			 */
2049
-			if ( ! isset( $q['taxonomy'] ) ) {
2050
-				foreach ( $this->tax_query->queried_terms as $queried_taxonomy => $queried_items ) {
2051
-					if ( empty( $queried_items['terms'][0] ) ) {
2049
+			if ( ! isset($q['taxonomy'])) {
2050
+				foreach ($this->tax_query->queried_terms as $queried_taxonomy => $queried_items) {
2051
+					if (empty($queried_items['terms'][0])) {
2052 2052
 						continue;
2053 2053
 					}
2054 2054
 
2055
-					if ( ! in_array( $queried_taxonomy, array( 'category', 'post_tag' ) ) ) {
2055
+					if ( ! in_array($queried_taxonomy, array('category', 'post_tag'))) {
2056 2056
 						$q['taxonomy'] = $queried_taxonomy;
2057 2057
 
2058
-						if ( 'slug' === $queried_items['field'] ) {
2058
+						if ('slug' === $queried_items['field']) {
2059 2059
 							$q['term'] = $queried_items['terms'][0];
2060 2060
 						} else {
2061 2061
 							$q['term_id'] = $queried_items['terms'][0];
@@ -2068,156 +2068,156 @@  discard block
 block discarded – undo
2068 2068
 			}
2069 2069
 
2070 2070
 			// 'cat', 'category_name', 'tag_id'
2071
-			foreach ( $this->tax_query->queried_terms as $queried_taxonomy => $queried_items ) {
2072
-				if ( empty( $queried_items['terms'][0] ) ) {
2071
+			foreach ($this->tax_query->queried_terms as $queried_taxonomy => $queried_items) {
2072
+				if (empty($queried_items['terms'][0])) {
2073 2073
 					continue;
2074 2074
 				}
2075 2075
 
2076
-				if ( 'category' === $queried_taxonomy ) {
2077
-					$the_cat = get_term_by( $queried_items['field'], $queried_items['terms'][0], 'category' );
2078
-					if ( $the_cat ) {
2079
-						$this->set( 'cat', $the_cat->term_id );
2080
-						$this->set( 'category_name', $the_cat->slug );
2076
+				if ('category' === $queried_taxonomy) {
2077
+					$the_cat = get_term_by($queried_items['field'], $queried_items['terms'][0], 'category');
2078
+					if ($the_cat) {
2079
+						$this->set('cat', $the_cat->term_id);
2080
+						$this->set('category_name', $the_cat->slug);
2081 2081
 					}
2082
-					unset( $the_cat );
2082
+					unset($the_cat);
2083 2083
 				}
2084 2084
 
2085
-				if ( 'post_tag' === $queried_taxonomy ) {
2086
-					$the_tag = get_term_by( $queried_items['field'], $queried_items['terms'][0], 'post_tag' );
2087
-					if ( $the_tag ) {
2088
-						$this->set( 'tag_id', $the_tag->term_id );
2085
+				if ('post_tag' === $queried_taxonomy) {
2086
+					$the_tag = get_term_by($queried_items['field'], $queried_items['terms'][0], 'post_tag');
2087
+					if ($the_tag) {
2088
+						$this->set('tag_id', $the_tag->term_id);
2089 2089
 					}
2090
-					unset( $the_tag );
2090
+					unset($the_tag);
2091 2091
 				}
2092 2092
 			}
2093 2093
 		}
2094 2094
 
2095
-		if ( !empty( $this->tax_query->queries ) || !empty( $this->meta_query->queries ) ) {
2095
+		if ( ! empty($this->tax_query->queries) || ! empty($this->meta_query->queries)) {
2096 2096
 			$groupby = "{$wpdb->posts}.ID";
2097 2097
 		}
2098 2098
 
2099 2099
 		// Author/user stuff
2100 2100
 
2101
-		if ( ! empty( $q['author'] ) && $q['author'] != '0' ) {
2102
-			$q['author'] = addslashes_gpc( '' . urldecode( $q['author'] ) );
2103
-			$authors = array_unique( array_map( 'intval', preg_split( '/[,\s]+/', $q['author'] ) ) );
2104
-			foreach ( $authors as $author ) {
2101
+		if ( ! empty($q['author']) && $q['author'] != '0') {
2102
+			$q['author'] = addslashes_gpc(''.urldecode($q['author']));
2103
+			$authors = array_unique(array_map('intval', preg_split('/[,\s]+/', $q['author'])));
2104
+			foreach ($authors as $author) {
2105 2105
 				$key = $author > 0 ? 'author__in' : 'author__not_in';
2106
-				$q[$key][] = abs( $author );
2106
+				$q[$key][] = abs($author);
2107 2107
 			}
2108
-			$q['author'] = implode( ',', $authors );
2108
+			$q['author'] = implode(',', $authors);
2109 2109
 		}
2110 2110
 
2111
-		if ( ! empty( $q['author__not_in'] ) ) {
2112
-			$author__not_in = implode( ',', array_map( 'absint', array_unique( (array) $q['author__not_in'] ) ) );
2111
+		if ( ! empty($q['author__not_in'])) {
2112
+			$author__not_in = implode(',', array_map('absint', array_unique((array) $q['author__not_in'])));
2113 2113
 			$where .= " AND {$wpdb->posts}.post_author NOT IN ($author__not_in) ";
2114
-		} elseif ( ! empty( $q['author__in'] ) ) {
2115
-			$author__in = implode( ',', array_map( 'absint', array_unique( (array) $q['author__in'] ) ) );
2114
+		} elseif ( ! empty($q['author__in'])) {
2115
+			$author__in = implode(',', array_map('absint', array_unique((array) $q['author__in'])));
2116 2116
 			$where .= " AND {$wpdb->posts}.post_author IN ($author__in) ";
2117 2117
 		}
2118 2118
 
2119 2119
 		// Author stuff for nice URLs
2120 2120
 
2121
-		if ( '' != $q['author_name'] ) {
2122
-			if ( strpos($q['author_name'], '/') !== false ) {
2121
+		if ('' != $q['author_name']) {
2122
+			if (strpos($q['author_name'], '/') !== false) {
2123 2123
 				$q['author_name'] = explode('/', $q['author_name']);
2124
-				if ( $q['author_name'][ count($q['author_name'])-1 ] ) {
2125
-					$q['author_name'] = $q['author_name'][count($q['author_name'])-1]; // no trailing slash
2124
+				if ($q['author_name'][count($q['author_name']) - 1]) {
2125
+					$q['author_name'] = $q['author_name'][count($q['author_name']) - 1]; // no trailing slash
2126 2126
 				} else {
2127
-					$q['author_name'] = $q['author_name'][count($q['author_name'])-2]; // there was a trailing slash
2127
+					$q['author_name'] = $q['author_name'][count($q['author_name']) - 2]; // there was a trailing slash
2128 2128
 				}
2129 2129
 			}
2130
-			$q['author_name'] = sanitize_title_for_query( $q['author_name'] );
2130
+			$q['author_name'] = sanitize_title_for_query($q['author_name']);
2131 2131
 			$q['author'] = get_user_by('slug', $q['author_name']);
2132
-			if ( $q['author'] )
2132
+			if ($q['author'])
2133 2133
 				$q['author'] = $q['author']->ID;
2134
-			$whichauthor .= " AND ({$wpdb->posts}.post_author = " . absint($q['author']) . ')';
2134
+			$whichauthor .= " AND ({$wpdb->posts}.post_author = ".absint($q['author']).')';
2135 2135
 		}
2136 2136
 
2137 2137
 		// MIME-Type stuff for attachment browsing
2138 2138
 
2139
-		if ( isset( $q['post_mime_type'] ) && '' != $q['post_mime_type'] ) {
2140
-			$whichmimetype = wp_post_mime_type_where( $q['post_mime_type'], $wpdb->posts );
2139
+		if (isset($q['post_mime_type']) && '' != $q['post_mime_type']) {
2140
+			$whichmimetype = wp_post_mime_type_where($q['post_mime_type'], $wpdb->posts);
2141 2141
 		}
2142
-		$where .= $search . $whichauthor . $whichmimetype;
2142
+		$where .= $search.$whichauthor.$whichmimetype;
2143 2143
 
2144
-		if ( ! empty( $this->meta_query->queries ) ) {
2145
-			$clauses = $this->meta_query->get_sql( 'post', $wpdb->posts, 'ID', $this );
2144
+		if ( ! empty($this->meta_query->queries)) {
2145
+			$clauses = $this->meta_query->get_sql('post', $wpdb->posts, 'ID', $this);
2146 2146
 			$join   .= $clauses['join'];
2147 2147
 			$where  .= $clauses['where'];
2148 2148
 		}
2149 2149
 
2150
-		$rand = ( isset( $q['orderby'] ) && 'rand' === $q['orderby'] );
2151
-		if ( ! isset( $q['order'] ) ) {
2150
+		$rand = (isset($q['orderby']) && 'rand' === $q['orderby']);
2151
+		if ( ! isset($q['order'])) {
2152 2152
 			$q['order'] = $rand ? '' : 'DESC';
2153 2153
 		} else {
2154
-			$q['order'] = $rand ? '' : $this->parse_order( $q['order'] );
2154
+			$q['order'] = $rand ? '' : $this->parse_order($q['order']);
2155 2155
 		}
2156 2156
 
2157 2157
 		// Order by.
2158
-		if ( empty( $q['orderby'] ) ) {
2158
+		if (empty($q['orderby'])) {
2159 2159
 			/*
2160 2160
 			 * Boolean false or empty array blanks out ORDER BY,
2161 2161
 			 * while leaving the value unset or otherwise empty sets the default.
2162 2162
 			 */
2163
-			if ( isset( $q['orderby'] ) && ( is_array( $q['orderby'] ) || false === $q['orderby'] ) ) {
2163
+			if (isset($q['orderby']) && (is_array($q['orderby']) || false === $q['orderby'])) {
2164 2164
 				$orderby = '';
2165 2165
 			} else {
2166
-				$orderby = "{$wpdb->posts}.post_date " . $q['order'];
2166
+				$orderby = "{$wpdb->posts}.post_date ".$q['order'];
2167 2167
 			}
2168
-		} elseif ( 'none' == $q['orderby'] ) {
2168
+		} elseif ('none' == $q['orderby']) {
2169 2169
 			$orderby = '';
2170
-		} elseif ( $q['orderby'] == 'post__in' && ! empty( $post__in ) ) {
2170
+		} elseif ($q['orderby'] == 'post__in' && ! empty($post__in)) {
2171 2171
 			$orderby = "FIELD( {$wpdb->posts}.ID, $post__in )";
2172
-		} elseif ( $q['orderby'] == 'post_parent__in' && ! empty( $post_parent__in ) ) {
2172
+		} elseif ($q['orderby'] == 'post_parent__in' && ! empty($post_parent__in)) {
2173 2173
 			$orderby = "FIELD( {$wpdb->posts}.post_parent, $post_parent__in )";
2174
-		} elseif ( $q['orderby'] == 'post_name__in' && ! empty( $post_name__in ) ) {
2174
+		} elseif ($q['orderby'] == 'post_name__in' && ! empty($post_name__in)) {
2175 2175
 			$orderby = "FIELD( {$wpdb->posts}.post_name, $post_name__in )";
2176 2176
 		} else {
2177 2177
 			$orderby_array = array();
2178
-			if ( is_array( $q['orderby'] ) ) {
2179
-				foreach ( $q['orderby'] as $_orderby => $order ) {
2180
-					$orderby = addslashes_gpc( urldecode( $_orderby ) );
2181
-					$parsed  = $this->parse_orderby( $orderby );
2178
+			if (is_array($q['orderby'])) {
2179
+				foreach ($q['orderby'] as $_orderby => $order) {
2180
+					$orderby = addslashes_gpc(urldecode($_orderby));
2181
+					$parsed  = $this->parse_orderby($orderby);
2182 2182
 
2183
-					if ( ! $parsed ) {
2183
+					if ( ! $parsed) {
2184 2184
 						continue;
2185 2185
 					}
2186 2186
 
2187
-					$orderby_array[] = $parsed . ' ' . $this->parse_order( $order );
2187
+					$orderby_array[] = $parsed.' '.$this->parse_order($order);
2188 2188
 				}
2189
-				$orderby = implode( ', ', $orderby_array );
2189
+				$orderby = implode(', ', $orderby_array);
2190 2190
 
2191 2191
 			} else {
2192
-				$q['orderby'] = urldecode( $q['orderby'] );
2193
-				$q['orderby'] = addslashes_gpc( $q['orderby'] );
2192
+				$q['orderby'] = urldecode($q['orderby']);
2193
+				$q['orderby'] = addslashes_gpc($q['orderby']);
2194 2194
 
2195
-				foreach ( explode( ' ', $q['orderby'] ) as $i => $orderby ) {
2196
-					$parsed = $this->parse_orderby( $orderby );
2195
+				foreach (explode(' ', $q['orderby']) as $i => $orderby) {
2196
+					$parsed = $this->parse_orderby($orderby);
2197 2197
 					// Only allow certain values for safety.
2198
-					if ( ! $parsed ) {
2198
+					if ( ! $parsed) {
2199 2199
 						continue;
2200 2200
 					}
2201 2201
 
2202 2202
 					$orderby_array[] = $parsed;
2203 2203
 				}
2204
-				$orderby = implode( ' ' . $q['order'] . ', ', $orderby_array );
2204
+				$orderby = implode(' '.$q['order'].', ', $orderby_array);
2205 2205
 
2206
-				if ( empty( $orderby ) ) {
2207
-					$orderby = "{$wpdb->posts}.post_date " . $q['order'];
2208
-				} elseif ( ! empty( $q['order'] ) ) {
2206
+				if (empty($orderby)) {
2207
+					$orderby = "{$wpdb->posts}.post_date ".$q['order'];
2208
+				} elseif ( ! empty($q['order'])) {
2209 2209
 					$orderby .= " {$q['order']}";
2210 2210
 				}
2211 2211
 			}
2212 2212
 		}
2213 2213
 
2214 2214
 		// Order search results by relevance only when another "orderby" is not specified in the query.
2215
-		if ( ! empty( $q['s'] ) ) {
2215
+		if ( ! empty($q['s'])) {
2216 2216
 			$search_orderby = '';
2217
-			if ( ! empty( $q['search_orderby_title'] ) && ( empty( $q['orderby'] ) && ! $this->is_feed ) || ( isset( $q['orderby'] ) && 'relevance' === $q['orderby'] ) )
2218
-				$search_orderby = $this->parse_search_order( $q );
2217
+			if ( ! empty($q['search_orderby_title']) && (empty($q['orderby']) && ! $this->is_feed) || (isset($q['orderby']) && 'relevance' === $q['orderby']))
2218
+				$search_orderby = $this->parse_search_order($q);
2219 2219
 
2220
-			if ( ! $q['suppress_filters'] ) {
2220
+			if ( ! $q['suppress_filters']) {
2221 2221
 				/**
2222 2222
 				 * Filters the ORDER BY used when ordering search results.
2223 2223
 				 *
@@ -2226,95 +2226,95 @@  discard block
 block discarded – undo
2226 2226
 				 * @param string   $search_orderby The ORDER BY clause.
2227 2227
 				 * @param WP_Query $this           The current WP_Query instance.
2228 2228
 				 */
2229
-				$search_orderby = apply_filters( 'posts_search_orderby', $search_orderby, $this );
2229
+				$search_orderby = apply_filters('posts_search_orderby', $search_orderby, $this);
2230 2230
 			}
2231 2231
 
2232
-			if ( $search_orderby )
2233
-				$orderby = $orderby ? $search_orderby . ', ' . $orderby : $search_orderby;
2232
+			if ($search_orderby)
2233
+				$orderby = $orderby ? $search_orderby.', '.$orderby : $search_orderby;
2234 2234
 		}
2235 2235
 
2236
-		if ( is_array( $post_type ) && count( $post_type ) > 1 ) {
2236
+		if (is_array($post_type) && count($post_type) > 1) {
2237 2237
 			$post_type_cap = 'multiple_post_type';
2238 2238
 		} else {
2239
-			if ( is_array( $post_type ) )
2240
-				$post_type = reset( $post_type );
2241
-			$post_type_object = get_post_type_object( $post_type );
2242
-			if ( empty( $post_type_object ) )
2239
+			if (is_array($post_type))
2240
+				$post_type = reset($post_type);
2241
+			$post_type_object = get_post_type_object($post_type);
2242
+			if (empty($post_type_object))
2243 2243
 				$post_type_cap = $post_type;
2244 2244
 		}
2245 2245
 
2246
-		if ( isset( $q['post_password'] ) ) {
2247
-			$where .= $wpdb->prepare( " AND {$wpdb->posts}.post_password = %s", $q['post_password'] );
2248
-			if ( empty( $q['perm'] ) ) {
2246
+		if (isset($q['post_password'])) {
2247
+			$where .= $wpdb->prepare(" AND {$wpdb->posts}.post_password = %s", $q['post_password']);
2248
+			if (empty($q['perm'])) {
2249 2249
 				$q['perm'] = 'readable';
2250 2250
 			}
2251
-		} elseif ( isset( $q['has_password'] ) ) {
2252
-			$where .= sprintf( " AND {$wpdb->posts}.post_password %s ''", $q['has_password'] ? '!=' : '=' );
2251
+		} elseif (isset($q['has_password'])) {
2252
+			$where .= sprintf(" AND {$wpdb->posts}.post_password %s ''", $q['has_password'] ? '!=' : '=');
2253 2253
 		}
2254 2254
 
2255
-		if ( ! empty( $q['comment_status'] ) ) {
2256
-			$where .= $wpdb->prepare( " AND {$wpdb->posts}.comment_status = %s ", $q['comment_status'] );
2255
+		if ( ! empty($q['comment_status'])) {
2256
+			$where .= $wpdb->prepare(" AND {$wpdb->posts}.comment_status = %s ", $q['comment_status']);
2257 2257
 		}
2258 2258
 
2259
-		if ( ! empty( $q['ping_status'] ) )  {
2260
-			$where .= $wpdb->prepare( " AND {$wpdb->posts}.ping_status = %s ", $q['ping_status'] );
2259
+		if ( ! empty($q['ping_status'])) {
2260
+			$where .= $wpdb->prepare(" AND {$wpdb->posts}.ping_status = %s ", $q['ping_status']);
2261 2261
 		}
2262 2262
 
2263
-		if ( 'any' == $post_type ) {
2264
-			$in_search_post_types = get_post_types( array('exclude_from_search' => false) );
2265
-			if ( empty( $in_search_post_types ) ) {
2263
+		if ('any' == $post_type) {
2264
+			$in_search_post_types = get_post_types(array('exclude_from_search' => false));
2265
+			if (empty($in_search_post_types)) {
2266 2266
 				$where .= ' AND 1=0 ';
2267 2267
 			} else {
2268
-				$where .= " AND {$wpdb->posts}.post_type IN ('" . join( "', '", array_map( 'esc_sql', $in_search_post_types ) ) . "')";
2268
+				$where .= " AND {$wpdb->posts}.post_type IN ('".join("', '", array_map('esc_sql', $in_search_post_types))."')";
2269 2269
 			}
2270
-		} elseif ( !empty( $post_type ) && is_array( $post_type ) ) {
2271
-			$where .= " AND {$wpdb->posts}.post_type IN ('" . join("', '", esc_sql( $post_type ) ) . "')";
2272
-		} elseif ( ! empty( $post_type ) ) {
2273
-			$where .= $wpdb->prepare( " AND {$wpdb->posts}.post_type = %s", $post_type );
2274
-			$post_type_object = get_post_type_object ( $post_type );
2275
-		} elseif ( $this->is_attachment ) {
2270
+		} elseif ( ! empty($post_type) && is_array($post_type)) {
2271
+			$where .= " AND {$wpdb->posts}.post_type IN ('".join("', '", esc_sql($post_type))."')";
2272
+		} elseif ( ! empty($post_type)) {
2273
+			$where .= $wpdb->prepare(" AND {$wpdb->posts}.post_type = %s", $post_type);
2274
+			$post_type_object = get_post_type_object($post_type);
2275
+		} elseif ($this->is_attachment) {
2276 2276
 			$where .= " AND {$wpdb->posts}.post_type = 'attachment'";
2277
-			$post_type_object = get_post_type_object ( 'attachment' );
2278
-		} elseif ( $this->is_page ) {
2277
+			$post_type_object = get_post_type_object('attachment');
2278
+		} elseif ($this->is_page) {
2279 2279
 			$where .= " AND {$wpdb->posts}.post_type = 'page'";
2280
-			$post_type_object = get_post_type_object ( 'page' );
2280
+			$post_type_object = get_post_type_object('page');
2281 2281
 		} else {
2282 2282
 			$where .= " AND {$wpdb->posts}.post_type = 'post'";
2283
-			$post_type_object = get_post_type_object ( 'post' );
2283
+			$post_type_object = get_post_type_object('post');
2284 2284
 		}
2285 2285
 
2286 2286
 		$edit_cap = 'edit_post';
2287 2287
 		$read_cap = 'read_post';
2288 2288
 
2289
-		if ( ! empty( $post_type_object ) ) {
2289
+		if ( ! empty($post_type_object)) {
2290 2290
 			$edit_others_cap = $post_type_object->cap->edit_others_posts;
2291 2291
 			$read_private_cap = $post_type_object->cap->read_private_posts;
2292 2292
 		} else {
2293
-			$edit_others_cap = 'edit_others_' . $post_type_cap . 's';
2294
-			$read_private_cap = 'read_private_' . $post_type_cap . 's';
2293
+			$edit_others_cap = 'edit_others_'.$post_type_cap.'s';
2294
+			$read_private_cap = 'read_private_'.$post_type_cap.'s';
2295 2295
 		}
2296 2296
 
2297 2297
 		$user_id = get_current_user_id();
2298 2298
 
2299 2299
 		$q_status = array();
2300
-		if ( ! empty( $q['post_status'] ) ) {
2300
+		if ( ! empty($q['post_status'])) {
2301 2301
 			$statuswheres = array();
2302 2302
 			$q_status = $q['post_status'];
2303
-			if ( ! is_array( $q_status ) )
2303
+			if ( ! is_array($q_status))
2304 2304
 				$q_status = explode(',', $q_status);
2305 2305
 			$r_status = array();
2306 2306
 			$p_status = array();
2307 2307
 			$e_status = array();
2308
-			if ( in_array( 'any', $q_status ) ) {
2309
-				foreach ( get_post_stati( array( 'exclude_from_search' => true ) ) as $status ) {
2310
-					if ( ! in_array( $status, $q_status ) ) {
2308
+			if (in_array('any', $q_status)) {
2309
+				foreach (get_post_stati(array('exclude_from_search' => true)) as $status) {
2310
+					if ( ! in_array($status, $q_status)) {
2311 2311
 						$e_status[] = "{$wpdb->posts}.post_status <> '$status'";
2312 2312
 					}
2313 2313
 				}
2314 2314
 			} else {
2315
-				foreach ( get_post_stati() as $status ) {
2316
-					if ( in_array( $status, $q_status ) ) {
2317
-						if ( 'private' == $status ) {
2315
+				foreach (get_post_stati() as $status) {
2316
+					if (in_array($status, $q_status)) {
2317
+						if ('private' == $status) {
2318 2318
 							$p_status[] = "{$wpdb->posts}.post_status = '$status'";
2319 2319
 						} else {
2320 2320
 							$r_status[] = "{$wpdb->posts}.post_status = '$status'";
@@ -2323,62 +2323,62 @@  discard block
 block discarded – undo
2323 2323
 				}
2324 2324
 			}
2325 2325
 
2326
-			if ( empty($q['perm'] ) || 'readable' != $q['perm'] ) {
2326
+			if (empty($q['perm']) || 'readable' != $q['perm']) {
2327 2327
 				$r_status = array_merge($r_status, $p_status);
2328 2328
 				unset($p_status);
2329 2329
 			}
2330 2330
 
2331
-			if ( !empty($e_status) ) {
2332
-				$statuswheres[] = "(" . join( ' AND ', $e_status ) . ")";
2331
+			if ( ! empty($e_status)) {
2332
+				$statuswheres[] = "(".join(' AND ', $e_status).")";
2333 2333
 			}
2334
-			if ( !empty($r_status) ) {
2335
-				if ( !empty($q['perm'] ) && 'editable' == $q['perm'] && !current_user_can($edit_others_cap) ) {
2336
-					$statuswheres[] = "({$wpdb->posts}.post_author = $user_id " . "AND (" . join( ' OR ', $r_status ) . "))";
2334
+			if ( ! empty($r_status)) {
2335
+				if ( ! empty($q['perm']) && 'editable' == $q['perm'] && ! current_user_can($edit_others_cap)) {
2336
+					$statuswheres[] = "({$wpdb->posts}.post_author = $user_id "."AND (".join(' OR ', $r_status)."))";
2337 2337
 				} else {
2338
-					$statuswheres[] = "(" . join( ' OR ', $r_status ) . ")";
2338
+					$statuswheres[] = "(".join(' OR ', $r_status).")";
2339 2339
 				}
2340 2340
 			}
2341
-			if ( !empty($p_status) ) {
2342
-				if ( !empty($q['perm'] ) && 'readable' == $q['perm'] && !current_user_can($read_private_cap) ) {
2343
-					$statuswheres[] = "({$wpdb->posts}.post_author = $user_id " . "AND (" . join( ' OR ', $p_status ) . "))";
2341
+			if ( ! empty($p_status)) {
2342
+				if ( ! empty($q['perm']) && 'readable' == $q['perm'] && ! current_user_can($read_private_cap)) {
2343
+					$statuswheres[] = "({$wpdb->posts}.post_author = $user_id "."AND (".join(' OR ', $p_status)."))";
2344 2344
 				} else {
2345
-					$statuswheres[] = "(" . join( ' OR ', $p_status ) . ")";
2345
+					$statuswheres[] = "(".join(' OR ', $p_status).")";
2346 2346
 				}
2347 2347
 			}
2348
-			if ( $post_status_join ) {
2348
+			if ($post_status_join) {
2349 2349
 				$join .= " LEFT JOIN {$wpdb->posts} AS p2 ON ({$wpdb->posts}.post_parent = p2.ID) ";
2350
-				foreach ( $statuswheres as $index => $statuswhere ) {
2351
-					$statuswheres[$index] = "($statuswhere OR ({$wpdb->posts}.post_status = 'inherit' AND " . str_replace( $wpdb->posts, 'p2', $statuswhere ) . "))";
2350
+				foreach ($statuswheres as $index => $statuswhere) {
2351
+					$statuswheres[$index] = "($statuswhere OR ({$wpdb->posts}.post_status = 'inherit' AND ".str_replace($wpdb->posts, 'p2', $statuswhere)."))";
2352 2352
 				}
2353 2353
 			}
2354
-			$where_status = implode( ' OR ', $statuswheres );
2355
-			if ( ! empty( $where_status ) ) {
2354
+			$where_status = implode(' OR ', $statuswheres);
2355
+			if ( ! empty($where_status)) {
2356 2356
 				$where .= " AND ($where_status)";
2357 2357
 			}
2358
-		} elseif ( !$this->is_singular ) {
2358
+		} elseif ( ! $this->is_singular) {
2359 2359
 			$where .= " AND ({$wpdb->posts}.post_status = 'publish'";
2360 2360
 
2361 2361
 			// Add public states.
2362
-			$public_states = get_post_stati( array('public' => true) );
2363
-			foreach ( (array) $public_states as $state ) {
2364
-				if ( 'publish' == $state ) // Publish is hard-coded above.
2362
+			$public_states = get_post_stati(array('public' => true));
2363
+			foreach ((array) $public_states as $state) {
2364
+				if ('publish' == $state) // Publish is hard-coded above.
2365 2365
 					continue;
2366 2366
 				$where .= " OR {$wpdb->posts}.post_status = '$state'";
2367 2367
 			}
2368 2368
 
2369
-			if ( $this->is_admin ) {
2369
+			if ($this->is_admin) {
2370 2370
 				// Add protected states that should show in the admin all list.
2371
-				$admin_all_states = get_post_stati( array('protected' => true, 'show_in_admin_all_list' => true) );
2372
-				foreach ( (array) $admin_all_states as $state ) {
2371
+				$admin_all_states = get_post_stati(array('protected' => true, 'show_in_admin_all_list' => true));
2372
+				foreach ((array) $admin_all_states as $state) {
2373 2373
 					$where .= " OR {$wpdb->posts}.post_status = '$state'";
2374 2374
 				}
2375 2375
 			}
2376 2376
 
2377
-			if ( is_user_logged_in() ) {
2377
+			if (is_user_logged_in()) {
2378 2378
 				// Add private states that are limited to viewing by the author of a post or someone who has caps to read private states.
2379
-				$private_states = get_post_stati( array('private' => true) );
2380
-				foreach ( (array) $private_states as $state ) {
2381
-					$where .= current_user_can( $read_private_cap ) ? " OR {$wpdb->posts}.post_status = '$state'" : " OR {$wpdb->posts}.post_author = $user_id AND {$wpdb->posts}.post_status = '$state'";
2379
+				$private_states = get_post_stati(array('private' => true));
2380
+				foreach ((array) $private_states as $state) {
2381
+					$where .= current_user_can($read_private_cap) ? " OR {$wpdb->posts}.post_status = '$state'" : " OR {$wpdb->posts}.post_author = $user_id AND {$wpdb->posts}.post_status = '$state'";
2382 2382
 				}
2383 2383
 			}
2384 2384
 
@@ -2389,7 +2389,7 @@  discard block
 block discarded – undo
2389 2389
 		 * Apply filters on where and join prior to paging so that any
2390 2390
 		 * manipulations to them are reflected in the paging by day queries.
2391 2391
 		 */
2392
-		if ( !$q['suppress_filters'] ) {
2392
+		if ( ! $q['suppress_filters']) {
2393 2393
 			/**
2394 2394
 			 * Filters the WHERE clause of the query.
2395 2395
 			 *
@@ -2398,7 +2398,7 @@  discard block
 block discarded – undo
2398 2398
 			 * @param string   $where The WHERE clause of the query.
2399 2399
 			 * @param WP_Query &$this The WP_Query instance (passed by reference).
2400 2400
 			 */
2401
-			$where = apply_filters_ref_array( 'posts_where', array( $where, &$this ) );
2401
+			$where = apply_filters_ref_array('posts_where', array($where, &$this));
2402 2402
 
2403 2403
 			/**
2404 2404
 			 * Filters the JOIN clause of the query.
@@ -2408,28 +2408,28 @@  discard block
 block discarded – undo
2408 2408
 			 * @param string   $join  The JOIN clause of the query.
2409 2409
 			 * @param WP_Query &$this The WP_Query instance (passed by reference).
2410 2410
 			 */
2411
-			$join = apply_filters_ref_array( 'posts_join', array( $join, &$this ) );
2411
+			$join = apply_filters_ref_array('posts_join', array($join, &$this));
2412 2412
 		}
2413 2413
 
2414 2414
 		// Paging
2415
-		if ( empty($q['nopaging']) && !$this->is_singular ) {
2415
+		if (empty($q['nopaging']) && ! $this->is_singular) {
2416 2416
 			$page = absint($q['paged']);
2417
-			if ( !$page )
2417
+			if ( ! $page)
2418 2418
 				$page = 1;
2419 2419
 
2420 2420
 			// If 'offset' is provided, it takes precedence over 'paged'.
2421
-			if ( isset( $q['offset'] ) && is_numeric( $q['offset'] ) ) {
2422
-				$q['offset'] = absint( $q['offset'] );
2423
-				$pgstrt = $q['offset'] . ', ';
2421
+			if (isset($q['offset']) && is_numeric($q['offset'])) {
2422
+				$q['offset'] = absint($q['offset']);
2423
+				$pgstrt = $q['offset'].', ';
2424 2424
 			} else {
2425
-				$pgstrt = absint( ( $page - 1 ) * $q['posts_per_page'] ) . ', ';
2425
+				$pgstrt = absint(($page - 1) * $q['posts_per_page']).', ';
2426 2426
 			}
2427
-			$limits = 'LIMIT ' . $pgstrt . $q['posts_per_page'];
2427
+			$limits = 'LIMIT '.$pgstrt.$q['posts_per_page'];
2428 2428
 		}
2429 2429
 
2430 2430
 		// Comments feeds
2431
-		if ( $this->is_comment_feed && ! $this->is_singular ) {
2432
-			if ( $this->is_archive || $this->is_search ) {
2431
+		if ($this->is_comment_feed && ! $this->is_singular) {
2432
+			if ($this->is_archive || $this->is_search) {
2433 2433
 				$cjoin = "JOIN {$wpdb->posts} ON ({$wpdb->comments}.comment_post_ID = {$wpdb->posts}.ID) $join ";
2434 2434
 				$cwhere = "WHERE comment_approved = '1' $where";
2435 2435
 				$cgroupby = "{$wpdb->comments}.comment_id";
@@ -2439,7 +2439,7 @@  discard block
 block discarded – undo
2439 2439
 				$cgroupby = '';
2440 2440
 			}
2441 2441
 
2442
-			if ( !$q['suppress_filters'] ) {
2442
+			if ( ! $q['suppress_filters']) {
2443 2443
 				/**
2444 2444
 				 * Filters the JOIN clause of the comments feed query before sending.
2445 2445
 				 *
@@ -2448,7 +2448,7 @@  discard block
 block discarded – undo
2448 2448
 				 * @param string   $cjoin The JOIN clause of the query.
2449 2449
 				 * @param WP_Query &$this The WP_Query instance (passed by reference).
2450 2450
 				 */
2451
-				$cjoin = apply_filters_ref_array( 'comment_feed_join', array( $cjoin, &$this ) );
2451
+				$cjoin = apply_filters_ref_array('comment_feed_join', array($cjoin, &$this));
2452 2452
 
2453 2453
 				/**
2454 2454
 				 * Filters the WHERE clause of the comments feed query before sending.
@@ -2458,7 +2458,7 @@  discard block
 block discarded – undo
2458 2458
 				 * @param string   $cwhere The WHERE clause of the query.
2459 2459
 				 * @param WP_Query &$this  The WP_Query instance (passed by reference).
2460 2460
 				 */
2461
-				$cwhere = apply_filters_ref_array( 'comment_feed_where', array( $cwhere, &$this ) );
2461
+				$cwhere = apply_filters_ref_array('comment_feed_where', array($cwhere, &$this));
2462 2462
 
2463 2463
 				/**
2464 2464
 				 * Filters the GROUP BY clause of the comments feed query before sending.
@@ -2468,7 +2468,7 @@  discard block
 block discarded – undo
2468 2468
 				 * @param string   $cgroupby The GROUP BY clause of the query.
2469 2469
 				 * @param WP_Query &$this    The WP_Query instance (passed by reference).
2470 2470
 				 */
2471
-				$cgroupby = apply_filters_ref_array( 'comment_feed_groupby', array( $cgroupby, &$this ) );
2471
+				$cgroupby = apply_filters_ref_array('comment_feed_groupby', array($cgroupby, &$this));
2472 2472
 
2473 2473
 				/**
2474 2474
 				 * Filters the ORDER BY clause of the comments feed query before sending.
@@ -2478,7 +2478,7 @@  discard block
 block discarded – undo
2478 2478
 				 * @param string   $corderby The ORDER BY clause of the query.
2479 2479
 				 * @param WP_Query &$this    The WP_Query instance (passed by reference).
2480 2480
 				 */
2481
-				$corderby = apply_filters_ref_array( 'comment_feed_orderby', array( 'comment_date_gmt DESC', &$this ) );
2481
+				$corderby = apply_filters_ref_array('comment_feed_orderby', array('comment_date_gmt DESC', &$this));
2482 2482
 
2483 2483
 				/**
2484 2484
 				 * Filters the LIMIT clause of the comments feed query before sending.
@@ -2488,37 +2488,37 @@  discard block
 block discarded – undo
2488 2488
 				 * @param string   $climits The JOIN clause of the query.
2489 2489
 				 * @param WP_Query &$this   The WP_Query instance (passed by reference).
2490 2490
 				 */
2491
-				$climits = apply_filters_ref_array( 'comment_feed_limits', array( 'LIMIT ' . get_option('posts_per_rss'), &$this ) );
2491
+				$climits = apply_filters_ref_array('comment_feed_limits', array('LIMIT '.get_option('posts_per_rss'), &$this));
2492 2492
 			}
2493
-			$cgroupby = ( ! empty( $cgroupby ) ) ? 'GROUP BY ' . $cgroupby : '';
2494
-			$corderby = ( ! empty( $corderby ) ) ? 'ORDER BY ' . $corderby : '';
2493
+			$cgroupby = ( ! empty($cgroupby)) ? 'GROUP BY '.$cgroupby : '';
2494
+			$corderby = ( ! empty($corderby)) ? 'ORDER BY '.$corderby : '';
2495 2495
 
2496 2496
 			$comments = (array) $wpdb->get_results("SELECT $distinct {$wpdb->comments}.* FROM {$wpdb->comments} $cjoin $cwhere $cgroupby $corderby $climits");
2497 2497
 			// Convert to WP_Comment
2498
-			$this->comments = array_map( 'get_comment', $comments );
2498
+			$this->comments = array_map('get_comment', $comments);
2499 2499
 			$this->comment_count = count($this->comments);
2500 2500
 
2501 2501
 			$post_ids = array();
2502 2502
 
2503
-			foreach ( $this->comments as $comment )
2503
+			foreach ($this->comments as $comment)
2504 2504
 				$post_ids[] = (int) $comment->comment_post_ID;
2505 2505
 
2506 2506
 			$post_ids = join(',', $post_ids);
2507 2507
 			$join = '';
2508
-			if ( $post_ids ) {
2508
+			if ($post_ids) {
2509 2509
 				$where = "AND {$wpdb->posts}.ID IN ($post_ids) ";
2510 2510
 			} else {
2511 2511
 				$where = "AND 0";
2512 2512
 			}
2513 2513
 		}
2514 2514
 
2515
-		$pieces = array( 'where', 'groupby', 'join', 'orderby', 'distinct', 'fields', 'limits' );
2515
+		$pieces = array('where', 'groupby', 'join', 'orderby', 'distinct', 'fields', 'limits');
2516 2516
 
2517 2517
 		/*
2518 2518
 		 * Apply post-paging filters on where and join. Only plugins that
2519 2519
 		 * manipulate paging queries should use these hooks.
2520 2520
 		 */
2521
-		if ( !$q['suppress_filters'] ) {
2521
+		if ( ! $q['suppress_filters']) {
2522 2522
 			/**
2523 2523
 			 * Filters the WHERE clause of the query.
2524 2524
 			 *
@@ -2529,7 +2529,7 @@  discard block
 block discarded – undo
2529 2529
 			 * @param string   $where The WHERE clause of the query.
2530 2530
 			 * @param WP_Query &$this The WP_Query instance (passed by reference).
2531 2531
 			 */
2532
-			$where = apply_filters_ref_array( 'posts_where_paged', array( $where, &$this ) );
2532
+			$where = apply_filters_ref_array('posts_where_paged', array($where, &$this));
2533 2533
 
2534 2534
 			/**
2535 2535
 			 * Filters the GROUP BY clause of the query.
@@ -2539,7 +2539,7 @@  discard block
 block discarded – undo
2539 2539
 			 * @param string   $groupby The GROUP BY clause of the query.
2540 2540
 			 * @param WP_Query &$this   The WP_Query instance (passed by reference).
2541 2541
 			 */
2542
-			$groupby = apply_filters_ref_array( 'posts_groupby', array( $groupby, &$this ) );
2542
+			$groupby = apply_filters_ref_array('posts_groupby', array($groupby, &$this));
2543 2543
 
2544 2544
 			/**
2545 2545
 			 * Filters the JOIN clause of the query.
@@ -2551,7 +2551,7 @@  discard block
 block discarded – undo
2551 2551
 			 * @param string   $join  The JOIN clause of the query.
2552 2552
 			 * @param WP_Query &$this The WP_Query instance (passed by reference).
2553 2553
 			 */
2554
-			$join = apply_filters_ref_array( 'posts_join_paged', array( $join, &$this ) );
2554
+			$join = apply_filters_ref_array('posts_join_paged', array($join, &$this));
2555 2555
 
2556 2556
 			/**
2557 2557
 			 * Filters the ORDER BY clause of the query.
@@ -2561,7 +2561,7 @@  discard block
 block discarded – undo
2561 2561
 			 * @param string   $orderby The ORDER BY clause of the query.
2562 2562
 			 * @param WP_Query &$this   The WP_Query instance (passed by reference).
2563 2563
 			 */
2564
-			$orderby = apply_filters_ref_array( 'posts_orderby', array( $orderby, &$this ) );
2564
+			$orderby = apply_filters_ref_array('posts_orderby', array($orderby, &$this));
2565 2565
 
2566 2566
 			/**
2567 2567
 			 * Filters the DISTINCT clause of the query.
@@ -2571,7 +2571,7 @@  discard block
 block discarded – undo
2571 2571
 			 * @param string   $distinct The DISTINCT clause of the query.
2572 2572
 			 * @param WP_Query &$this    The WP_Query instance (passed by reference).
2573 2573
 			 */
2574
-			$distinct = apply_filters_ref_array( 'posts_distinct', array( $distinct, &$this ) );
2574
+			$distinct = apply_filters_ref_array('posts_distinct', array($distinct, &$this));
2575 2575
 
2576 2576
 			/**
2577 2577
 			 * Filters the LIMIT clause of the query.
@@ -2581,7 +2581,7 @@  discard block
 block discarded – undo
2581 2581
 			 * @param string   $limits The LIMIT clause of the query.
2582 2582
 			 * @param WP_Query &$this  The WP_Query instance (passed by reference).
2583 2583
 			 */
2584
-			$limits = apply_filters_ref_array( 'post_limits', array( $limits, &$this ) );
2584
+			$limits = apply_filters_ref_array('post_limits', array($limits, &$this));
2585 2585
 
2586 2586
 			/**
2587 2587
 			 * Filters the SELECT clause of the query.
@@ -2591,7 +2591,7 @@  discard block
 block discarded – undo
2591 2591
 			 * @param string   $fields The SELECT clause of the query.
2592 2592
 			 * @param WP_Query &$this  The WP_Query instance (passed by reference).
2593 2593
 			 */
2594
-			$fields = apply_filters_ref_array( 'posts_fields', array( $fields, &$this ) );
2594
+			$fields = apply_filters_ref_array('posts_fields', array($fields, &$this));
2595 2595
 
2596 2596
 			/**
2597 2597
 			 * Filters all query clauses at once, for convenience.
@@ -2604,15 +2604,15 @@  discard block
 block discarded – undo
2604 2604
 			 * @param array    $clauses The list of clauses for the query.
2605 2605
 			 * @param WP_Query &$this   The WP_Query instance (passed by reference).
2606 2606
 			 */
2607
-			$clauses = (array) apply_filters_ref_array( 'posts_clauses', array( compact( $pieces ), &$this ) );
2608
-
2609
-			$where = isset( $clauses[ 'where' ] ) ? $clauses[ 'where' ] : '';
2610
-			$groupby = isset( $clauses[ 'groupby' ] ) ? $clauses[ 'groupby' ] : '';
2611
-			$join = isset( $clauses[ 'join' ] ) ? $clauses[ 'join' ] : '';
2612
-			$orderby = isset( $clauses[ 'orderby' ] ) ? $clauses[ 'orderby' ] : '';
2613
-			$distinct = isset( $clauses[ 'distinct' ] ) ? $clauses[ 'distinct' ] : '';
2614
-			$fields = isset( $clauses[ 'fields' ] ) ? $clauses[ 'fields' ] : '';
2615
-			$limits = isset( $clauses[ 'limits' ] ) ? $clauses[ 'limits' ] : '';
2607
+			$clauses = (array) apply_filters_ref_array('posts_clauses', array(compact($pieces), &$this));
2608
+
2609
+			$where = isset($clauses['where']) ? $clauses['where'] : '';
2610
+			$groupby = isset($clauses['groupby']) ? $clauses['groupby'] : '';
2611
+			$join = isset($clauses['join']) ? $clauses['join'] : '';
2612
+			$orderby = isset($clauses['orderby']) ? $clauses['orderby'] : '';
2613
+			$distinct = isset($clauses['distinct']) ? $clauses['distinct'] : '';
2614
+			$fields = isset($clauses['fields']) ? $clauses['fields'] : '';
2615
+			$limits = isset($clauses['limits']) ? $clauses['limits'] : '';
2616 2616
 		}
2617 2617
 
2618 2618
 		/**
@@ -2624,13 +2624,13 @@  discard block
 block discarded – undo
2624 2624
 		 *
2625 2625
 		 * @param string $selection The assembled selection query.
2626 2626
 		 */
2627
-		do_action( 'posts_selection', $where . $groupby . $orderby . $limits . $join );
2627
+		do_action('posts_selection', $where.$groupby.$orderby.$limits.$join);
2628 2628
 
2629 2629
 		/*
2630 2630
 		 * Filters again for the benefit of caching plugins.
2631 2631
 		 * Regular plugins should use the hooks above.
2632 2632
 		 */
2633
-		if ( !$q['suppress_filters'] ) {
2633
+		if ( ! $q['suppress_filters']) {
2634 2634
 			/**
2635 2635
 			 * Filters the WHERE clause of the query.
2636 2636
 			 *
@@ -2641,7 +2641,7 @@  discard block
 block discarded – undo
2641 2641
 			 * @param string   $where The WHERE clause of the query.
2642 2642
 			 * @param WP_Query &$this The WP_Query instance (passed by reference).
2643 2643
 			 */
2644
-			$where = apply_filters_ref_array( 'posts_where_request', array( $where, &$this ) );
2644
+			$where = apply_filters_ref_array('posts_where_request', array($where, &$this));
2645 2645
 
2646 2646
 			/**
2647 2647
 			 * Filters the GROUP BY clause of the query.
@@ -2653,7 +2653,7 @@  discard block
 block discarded – undo
2653 2653
 			 * @param string   $groupby The GROUP BY clause of the query.
2654 2654
 			 * @param WP_Query &$this   The WP_Query instance (passed by reference).
2655 2655
 			 */
2656
-			$groupby = apply_filters_ref_array( 'posts_groupby_request', array( $groupby, &$this ) );
2656
+			$groupby = apply_filters_ref_array('posts_groupby_request', array($groupby, &$this));
2657 2657
 
2658 2658
 			/**
2659 2659
 			 * Filters the JOIN clause of the query.
@@ -2665,7 +2665,7 @@  discard block
 block discarded – undo
2665 2665
 			 * @param string   $join  The JOIN clause of the query.
2666 2666
 			 * @param WP_Query &$this The WP_Query instance (passed by reference).
2667 2667
 			 */
2668
-			$join = apply_filters_ref_array( 'posts_join_request', array( $join, &$this ) );
2668
+			$join = apply_filters_ref_array('posts_join_request', array($join, &$this));
2669 2669
 
2670 2670
 			/**
2671 2671
 			 * Filters the ORDER BY clause of the query.
@@ -2677,7 +2677,7 @@  discard block
 block discarded – undo
2677 2677
 			 * @param string   $orderby The ORDER BY clause of the query.
2678 2678
 			 * @param WP_Query &$this   The WP_Query instance (passed by reference).
2679 2679
 			 */
2680
-			$orderby = apply_filters_ref_array( 'posts_orderby_request', array( $orderby, &$this ) );
2680
+			$orderby = apply_filters_ref_array('posts_orderby_request', array($orderby, &$this));
2681 2681
 
2682 2682
 			/**
2683 2683
 			 * Filters the DISTINCT clause of the query.
@@ -2689,7 +2689,7 @@  discard block
 block discarded – undo
2689 2689
 			 * @param string   $distinct The DISTINCT clause of the query.
2690 2690
 			 * @param WP_Query &$this    The WP_Query instance (passed by reference).
2691 2691
 			 */
2692
-			$distinct = apply_filters_ref_array( 'posts_distinct_request', array( $distinct, &$this ) );
2692
+			$distinct = apply_filters_ref_array('posts_distinct_request', array($distinct, &$this));
2693 2693
 
2694 2694
 			/**
2695 2695
 			 * Filters the SELECT clause of the query.
@@ -2701,7 +2701,7 @@  discard block
 block discarded – undo
2701 2701
 			 * @param string   $fields The SELECT clause of the query.
2702 2702
 			 * @param WP_Query &$this  The WP_Query instance (passed by reference).
2703 2703
 			 */
2704
-			$fields = apply_filters_ref_array( 'posts_fields_request', array( $fields, &$this ) );
2704
+			$fields = apply_filters_ref_array('posts_fields_request', array($fields, &$this));
2705 2705
 
2706 2706
 			/**
2707 2707
 			 * Filters the LIMIT clause of the query.
@@ -2713,7 +2713,7 @@  discard block
 block discarded – undo
2713 2713
 			 * @param string   $limits The LIMIT clause of the query.
2714 2714
 			 * @param WP_Query &$this  The WP_Query instance (passed by reference).
2715 2715
 			 */
2716
-			$limits = apply_filters_ref_array( 'post_limits_request', array( $limits, &$this ) );
2716
+			$limits = apply_filters_ref_array('post_limits_request', array($limits, &$this));
2717 2717
 
2718 2718
 			/**
2719 2719
 			 * Filters all query clauses at once, for convenience.
@@ -2728,29 +2728,29 @@  discard block
 block discarded – undo
2728 2728
 			 * @param array    $pieces The pieces of the query.
2729 2729
 			 * @param WP_Query &$this  The WP_Query instance (passed by reference).
2730 2730
 			 */
2731
-			$clauses = (array) apply_filters_ref_array( 'posts_clauses_request', array( compact( $pieces ), &$this ) );
2732
-
2733
-			$where = isset( $clauses[ 'where' ] ) ? $clauses[ 'where' ] : '';
2734
-			$groupby = isset( $clauses[ 'groupby' ] ) ? $clauses[ 'groupby' ] : '';
2735
-			$join = isset( $clauses[ 'join' ] ) ? $clauses[ 'join' ] : '';
2736
-			$orderby = isset( $clauses[ 'orderby' ] ) ? $clauses[ 'orderby' ] : '';
2737
-			$distinct = isset( $clauses[ 'distinct' ] ) ? $clauses[ 'distinct' ] : '';
2738
-			$fields = isset( $clauses[ 'fields' ] ) ? $clauses[ 'fields' ] : '';
2739
-			$limits = isset( $clauses[ 'limits' ] ) ? $clauses[ 'limits' ] : '';
2731
+			$clauses = (array) apply_filters_ref_array('posts_clauses_request', array(compact($pieces), &$this));
2732
+
2733
+			$where = isset($clauses['where']) ? $clauses['where'] : '';
2734
+			$groupby = isset($clauses['groupby']) ? $clauses['groupby'] : '';
2735
+			$join = isset($clauses['join']) ? $clauses['join'] : '';
2736
+			$orderby = isset($clauses['orderby']) ? $clauses['orderby'] : '';
2737
+			$distinct = isset($clauses['distinct']) ? $clauses['distinct'] : '';
2738
+			$fields = isset($clauses['fields']) ? $clauses['fields'] : '';
2739
+			$limits = isset($clauses['limits']) ? $clauses['limits'] : '';
2740 2740
 		}
2741 2741
 
2742
-		if ( ! empty($groupby) )
2743
-			$groupby = 'GROUP BY ' . $groupby;
2744
-		if ( !empty( $orderby ) )
2745
-			$orderby = 'ORDER BY ' . $orderby;
2742
+		if ( ! empty($groupby))
2743
+			$groupby = 'GROUP BY '.$groupby;
2744
+		if ( ! empty($orderby))
2745
+			$orderby = 'ORDER BY '.$orderby;
2746 2746
 
2747 2747
 		$found_rows = '';
2748
-		if ( !$q['no_found_rows'] && !empty($limits) )
2748
+		if ( ! $q['no_found_rows'] && ! empty($limits))
2749 2749
 			$found_rows = 'SQL_CALC_FOUND_ROWS';
2750 2750
 
2751 2751
 		$this->request = $old_request = "SELECT $found_rows $distinct $fields FROM {$wpdb->posts} $join WHERE 1=1 $where $groupby $orderby $limits";
2752 2752
 
2753
-		if ( !$q['suppress_filters'] ) {
2753
+		if ( ! $q['suppress_filters']) {
2754 2754
 			/**
2755 2755
 			 * Filters the completed SQL query before sending.
2756 2756
 			 *
@@ -2759,7 +2759,7 @@  discard block
 block discarded – undo
2759 2759
 			 * @param string   $request The complete SQL query.
2760 2760
 			 * @param WP_Query &$this   The WP_Query instance (passed by reference).
2761 2761
 			 */
2762
-			$this->request = apply_filters_ref_array( 'posts_request', array( $this->request, &$this ) );
2762
+			$this->request = apply_filters_ref_array('posts_request', array($this->request, &$this));
2763 2763
 		}
2764 2764
 
2765 2765
 		/**
@@ -2778,41 +2778,41 @@  discard block
 block discarded – undo
2778 2778
 		 *                          or null to allow WP to run its normal queries.
2779 2779
 		 * @param WP_Query   $this  The WP_Query instance, passed by reference.
2780 2780
 		 */
2781
-		$this->posts = apply_filters_ref_array( 'posts_pre_query', array( null, &$this ) );
2781
+		$this->posts = apply_filters_ref_array('posts_pre_query', array(null, &$this));
2782 2782
 
2783
-		if ( 'ids' == $q['fields'] ) {
2784
-			if ( null === $this->posts ) {
2785
-				$this->posts = $wpdb->get_col( $this->request );
2783
+		if ('ids' == $q['fields']) {
2784
+			if (null === $this->posts) {
2785
+				$this->posts = $wpdb->get_col($this->request);
2786 2786
 			}
2787 2787
 
2788
-			$this->posts = array_map( 'intval', $this->posts );
2789
-			$this->post_count = count( $this->posts );
2790
-			$this->set_found_posts( $q, $limits );
2788
+			$this->posts = array_map('intval', $this->posts);
2789
+			$this->post_count = count($this->posts);
2790
+			$this->set_found_posts($q, $limits);
2791 2791
 
2792 2792
 			return $this->posts;
2793 2793
 		}
2794 2794
 
2795
-		if ( 'id=>parent' == $q['fields'] ) {
2796
-			if ( null === $this->posts ) {
2797
-				$this->posts = $wpdb->get_results( $this->request );
2795
+		if ('id=>parent' == $q['fields']) {
2796
+			if (null === $this->posts) {
2797
+				$this->posts = $wpdb->get_results($this->request);
2798 2798
 			}
2799 2799
 
2800
-			$this->post_count = count( $this->posts );
2801
-			$this->set_found_posts( $q, $limits );
2800
+			$this->post_count = count($this->posts);
2801
+			$this->set_found_posts($q, $limits);
2802 2802
 
2803 2803
 			$r = array();
2804
-			foreach ( $this->posts as $key => $post ) {
2805
-				$this->posts[ $key ]->ID = (int) $post->ID;
2806
-				$this->posts[ $key ]->post_parent = (int) $post->post_parent;
2804
+			foreach ($this->posts as $key => $post) {
2805
+				$this->posts[$key]->ID = (int) $post->ID;
2806
+				$this->posts[$key]->post_parent = (int) $post->post_parent;
2807 2807
 
2808
-				$r[ (int) $post->ID ] = (int) $post->post_parent;
2808
+				$r[(int) $post->ID] = (int) $post->post_parent;
2809 2809
 			}
2810 2810
 
2811 2811
 			return $r;
2812 2812
 		}
2813 2813
 
2814
-		if ( null === $this->posts ) {
2815
-			$split_the_query = ( $old_request == $this->request && "{$wpdb->posts}.*" == $fields && !empty( $limits ) && $q['posts_per_page'] < 500 );
2814
+		if (null === $this->posts) {
2815
+			$split_the_query = ($old_request == $this->request && "{$wpdb->posts}.*" == $fields && ! empty($limits) && $q['posts_per_page'] < 500);
2816 2816
 
2817 2817
 			/**
2818 2818
 			 * Filters whether to split the query.
@@ -2826,9 +2826,9 @@  discard block
 block discarded – undo
2826 2826
 			 * @param bool     $split_the_query Whether or not to split the query.
2827 2827
 			 * @param WP_Query $this            The WP_Query instance.
2828 2828
 			 */
2829
-			$split_the_query = apply_filters( 'split_the_query', $split_the_query, $this );
2829
+			$split_the_query = apply_filters('split_the_query', $split_the_query, $this);
2830 2830
 
2831
-			if ( $split_the_query ) {
2831
+			if ($split_the_query) {
2832 2832
 				// First get the IDs and then fill in the objects
2833 2833
 
2834 2834
 				$this->request = "SELECT $found_rows $distinct {$wpdb->posts}.ID FROM {$wpdb->posts} $join WHERE 1=1 $where $groupby $orderby $limits";
@@ -2841,29 +2841,29 @@  discard block
 block discarded – undo
2841 2841
 				 * @param string   $request The post ID request.
2842 2842
 				 * @param WP_Query $this    The WP_Query instance.
2843 2843
 				 */
2844
-				$this->request = apply_filters( 'posts_request_ids', $this->request, $this );
2844
+				$this->request = apply_filters('posts_request_ids', $this->request, $this);
2845 2845
 
2846
-				$ids = $wpdb->get_col( $this->request );
2846
+				$ids = $wpdb->get_col($this->request);
2847 2847
 
2848
-				if ( $ids ) {
2848
+				if ($ids) {
2849 2849
 					$this->posts = $ids;
2850
-					$this->set_found_posts( $q, $limits );
2851
-					_prime_post_caches( $ids, $q['update_post_term_cache'], $q['update_post_meta_cache'] );
2850
+					$this->set_found_posts($q, $limits);
2851
+					_prime_post_caches($ids, $q['update_post_term_cache'], $q['update_post_meta_cache']);
2852 2852
 				} else {
2853 2853
 					$this->posts = array();
2854 2854
 				}
2855 2855
 			} else {
2856
-				$this->posts = $wpdb->get_results( $this->request );
2857
-				$this->set_found_posts( $q, $limits );
2856
+				$this->posts = $wpdb->get_results($this->request);
2857
+				$this->set_found_posts($q, $limits);
2858 2858
 			}
2859 2859
 		}
2860 2860
 
2861 2861
 		// Convert to WP_Post objects.
2862
-		if ( $this->posts ) {
2863
-			$this->posts = array_map( 'get_post', $this->posts );
2862
+		if ($this->posts) {
2863
+			$this->posts = array_map('get_post', $this->posts);
2864 2864
 		}
2865 2865
 
2866
-		if ( ! $q['suppress_filters'] ) {
2866
+		if ( ! $q['suppress_filters']) {
2867 2867
 			/**
2868 2868
 			 * Filters the raw post results array, prior to status checks.
2869 2869
 			 *
@@ -2872,38 +2872,38 @@  discard block
 block discarded – undo
2872 2872
 			 * @param array    $posts The post results array.
2873 2873
 			 * @param WP_Query &$this The WP_Query instance (passed by reference).
2874 2874
 			 */
2875
-			$this->posts = apply_filters_ref_array( 'posts_results', array( $this->posts, &$this ) );
2875
+			$this->posts = apply_filters_ref_array('posts_results', array($this->posts, &$this));
2876 2876
 		}
2877 2877
 
2878
-		if ( !empty($this->posts) && $this->is_comment_feed && $this->is_singular ) {
2878
+		if ( ! empty($this->posts) && $this->is_comment_feed && $this->is_singular) {
2879 2879
 			/** This filter is documented in wp-includes/query.php */
2880
-			$cjoin = apply_filters_ref_array( 'comment_feed_join', array( '', &$this ) );
2880
+			$cjoin = apply_filters_ref_array('comment_feed_join', array('', &$this));
2881 2881
 
2882 2882
 			/** This filter is documented in wp-includes/query.php */
2883
-			$cwhere = apply_filters_ref_array( 'comment_feed_where', array( "WHERE comment_post_ID = '{$this->posts[0]->ID}' AND comment_approved = '1'", &$this ) );
2883
+			$cwhere = apply_filters_ref_array('comment_feed_where', array("WHERE comment_post_ID = '{$this->posts[0]->ID}' AND comment_approved = '1'", &$this));
2884 2884
 
2885 2885
 			/** This filter is documented in wp-includes/query.php */
2886
-			$cgroupby = apply_filters_ref_array( 'comment_feed_groupby', array( '', &$this ) );
2887
-			$cgroupby = ( ! empty( $cgroupby ) ) ? 'GROUP BY ' . $cgroupby : '';
2886
+			$cgroupby = apply_filters_ref_array('comment_feed_groupby', array('', &$this));
2887
+			$cgroupby = ( ! empty($cgroupby)) ? 'GROUP BY '.$cgroupby : '';
2888 2888
 
2889 2889
 			/** This filter is documented in wp-includes/query.php */
2890
-			$corderby = apply_filters_ref_array( 'comment_feed_orderby', array( 'comment_date_gmt DESC', &$this ) );
2891
-			$corderby = ( ! empty( $corderby ) ) ? 'ORDER BY ' . $corderby : '';
2890
+			$corderby = apply_filters_ref_array('comment_feed_orderby', array('comment_date_gmt DESC', &$this));
2891
+			$corderby = ( ! empty($corderby)) ? 'ORDER BY '.$corderby : '';
2892 2892
 
2893 2893
 			/** This filter is documented in wp-includes/query.php */
2894
-			$climits = apply_filters_ref_array( 'comment_feed_limits', array( 'LIMIT ' . get_option('posts_per_rss'), &$this ) );
2894
+			$climits = apply_filters_ref_array('comment_feed_limits', array('LIMIT '.get_option('posts_per_rss'), &$this));
2895 2895
 
2896 2896
 			$comments_request = "SELECT {$wpdb->comments}.* FROM {$wpdb->comments} $cjoin $cwhere $cgroupby $corderby $climits";
2897 2897
 			$comments = $wpdb->get_results($comments_request);
2898 2898
 			// Convert to WP_Comment
2899
-			$this->comments = array_map( 'get_comment', $comments );
2899
+			$this->comments = array_map('get_comment', $comments);
2900 2900
 			$this->comment_count = count($this->comments);
2901 2901
 		}
2902 2902
 
2903 2903
 		// Check post status to determine if post should be displayed.
2904
-		if ( !empty($this->posts) && ($this->is_single || $this->is_page) ) {
2904
+		if ( ! empty($this->posts) && ($this->is_single || $this->is_page)) {
2905 2905
 			$status = get_post_status($this->posts[0]);
2906
-			if ( 'attachment' === $this->posts[0]->post_type && 0 === (int) $this->posts[0]->post_parent ) {
2906
+			if ('attachment' === $this->posts[0]->post_type && 0 === (int) $this->posts[0]->post_parent) {
2907 2907
 				$this->is_page = false;
2908 2908
 				$this->is_single = true;
2909 2909
 				$this->is_attachment = true;
@@ -2911,23 +2911,23 @@  discard block
 block discarded – undo
2911 2911
 			$post_status_obj = get_post_status_object($status);
2912 2912
 
2913 2913
 			// If the post_status was specifically requested, let it pass through.
2914
-			if ( !$post_status_obj->public && ! in_array( $status, $q_status ) ) {
2914
+			if ( ! $post_status_obj->public && ! in_array($status, $q_status)) {
2915 2915
 
2916
-				if ( ! is_user_logged_in() ) {
2916
+				if ( ! is_user_logged_in()) {
2917 2917
 					// User must be logged in to view unpublished posts.
2918 2918
 					$this->posts = array();
2919 2919
 				} else {
2920
-					if  ( $post_status_obj->protected ) {
2920
+					if ($post_status_obj->protected) {
2921 2921
 						// User must have edit permissions on the draft to preview.
2922
-						if ( ! current_user_can($edit_cap, $this->posts[0]->ID) ) {
2922
+						if ( ! current_user_can($edit_cap, $this->posts[0]->ID)) {
2923 2923
 							$this->posts = array();
2924 2924
 						} else {
2925 2925
 							$this->is_preview = true;
2926
-							if ( 'future' != $status )
2926
+							if ('future' != $status)
2927 2927
 								$this->posts[0]->post_date = current_time('mysql');
2928 2928
 						}
2929
-					} elseif ( $post_status_obj->private ) {
2930
-						if ( ! current_user_can($read_cap, $this->posts[0]->ID) )
2929
+					} elseif ($post_status_obj->private) {
2930
+						if ( ! current_user_can($read_cap, $this->posts[0]->ID))
2931 2931
 							$this->posts = array();
2932 2932
 					} else {
2933 2933
 						$this->posts = array();
@@ -2935,7 +2935,7 @@  discard block
 block discarded – undo
2935 2935
 				}
2936 2936
 			}
2937 2937
 
2938
-			if ( $this->is_preview && $this->posts && current_user_can( $edit_cap, $this->posts[0]->ID ) ) {
2938
+			if ($this->is_preview && $this->posts && current_user_can($edit_cap, $this->posts[0]->ID)) {
2939 2939
 				/**
2940 2940
 				 * Filters the single post for preview mode.
2941 2941
 				 *
@@ -2944,18 +2944,18 @@  discard block
 block discarded – undo
2944 2944
 				 * @param WP_Post  $post_preview  The Post object.
2945 2945
 				 * @param WP_Query &$this         The WP_Query instance (passed by reference).
2946 2946
 				 */
2947
-				$this->posts[0] = get_post( apply_filters_ref_array( 'the_preview', array( $this->posts[0], &$this ) ) );
2947
+				$this->posts[0] = get_post(apply_filters_ref_array('the_preview', array($this->posts[0], &$this)));
2948 2948
 			}
2949 2949
 		}
2950 2950
 
2951 2951
 		// Put sticky posts at the top of the posts array
2952 2952
 		$sticky_posts = get_option('sticky_posts');
2953
-		if ( $this->is_home && $page <= 1 && is_array($sticky_posts) && !empty($sticky_posts) && !$q['ignore_sticky_posts'] ) {
2953
+		if ($this->is_home && $page <= 1 && is_array($sticky_posts) && ! empty($sticky_posts) && ! $q['ignore_sticky_posts']) {
2954 2954
 			$num_posts = count($this->posts);
2955 2955
 			$sticky_offset = 0;
2956 2956
 			// Loop over posts and relocate stickies to the front.
2957
-			for ( $i = 0; $i < $num_posts; $i++ ) {
2958
-				if ( in_array($this->posts[$i]->ID, $sticky_posts) ) {
2957
+			for ($i = 0; $i < $num_posts; $i++) {
2958
+				if (in_array($this->posts[$i]->ID, $sticky_posts)) {
2959 2959
 					$sticky_post = $this->posts[$i];
2960 2960
 					// Remove sticky from current position
2961 2961
 					array_splice($this->posts, $i, 1);
@@ -2965,36 +2965,36 @@  discard block
 block discarded – undo
2965 2965
 					$sticky_offset++;
2966 2966
 					// Remove post from sticky posts array
2967 2967
 					$offset = array_search($sticky_post->ID, $sticky_posts);
2968
-					unset( $sticky_posts[$offset] );
2968
+					unset($sticky_posts[$offset]);
2969 2969
 				}
2970 2970
 			}
2971 2971
 
2972 2972
 			// If any posts have been excluded specifically, Ignore those that are sticky.
2973
-			if ( !empty($sticky_posts) && !empty($q['post__not_in']) )
2973
+			if ( ! empty($sticky_posts) && ! empty($q['post__not_in']))
2974 2974
 				$sticky_posts = array_diff($sticky_posts, $q['post__not_in']);
2975 2975
 
2976 2976
 			// Fetch sticky posts that weren't in the query results
2977
-			if ( !empty($sticky_posts) ) {
2978
-				$stickies = get_posts( array(
2977
+			if ( ! empty($sticky_posts)) {
2978
+				$stickies = get_posts(array(
2979 2979
 					'post__in' => $sticky_posts,
2980 2980
 					'post_type' => $post_type,
2981 2981
 					'post_status' => 'publish',
2982 2982
 					'nopaging' => true
2983
-				) );
2983
+				));
2984 2984
 
2985
-				foreach ( $stickies as $sticky_post ) {
2986
-					array_splice( $this->posts, $sticky_offset, 0, array( $sticky_post ) );
2985
+				foreach ($stickies as $sticky_post) {
2986
+					array_splice($this->posts, $sticky_offset, 0, array($sticky_post));
2987 2987
 					$sticky_offset++;
2988 2988
 				}
2989 2989
 			}
2990 2990
 		}
2991 2991
 
2992 2992
 		// If comments have been fetched as part of the query, make sure comment meta lazy-loading is set up.
2993
-		if ( ! empty( $this->comments ) ) {
2994
-			wp_queue_comments_for_comment_meta_lazyload( $this->comments );
2993
+		if ( ! empty($this->comments)) {
2994
+			wp_queue_comments_for_comment_meta_lazyload($this->comments);
2995 2995
 		}
2996 2996
 
2997
-		if ( ! $q['suppress_filters'] ) {
2997
+		if ( ! $q['suppress_filters']) {
2998 2998
 			/**
2999 2999
 			 * Filters the array of retrieved posts after they've been fetched and
3000 3000
 			 * internally processed.
@@ -3004,27 +3004,27 @@  discard block
 block discarded – undo
3004 3004
 			 * @param array    $posts The array of retrieved posts.
3005 3005
 			 * @param WP_Query &$this The WP_Query instance (passed by reference).
3006 3006
 			 */
3007
-			$this->posts = apply_filters_ref_array( 'the_posts', array( $this->posts, &$this ) );
3007
+			$this->posts = apply_filters_ref_array('the_posts', array($this->posts, &$this));
3008 3008
 		}
3009 3009
 
3010 3010
 		// Ensure that any posts added/modified via one of the filters above are
3011 3011
 		// of the type WP_Post and are filtered.
3012
-		if ( $this->posts ) {
3013
-			$this->post_count = count( $this->posts );
3012
+		if ($this->posts) {
3013
+			$this->post_count = count($this->posts);
3014 3014
 
3015
-			$this->posts = array_map( 'get_post', $this->posts );
3015
+			$this->posts = array_map('get_post', $this->posts);
3016 3016
 
3017
-			if ( $q['cache_results'] )
3017
+			if ($q['cache_results'])
3018 3018
 				update_post_caches($this->posts, $post_type, $q['update_post_term_cache'], $q['update_post_meta_cache']);
3019 3019
 
3020
-			$this->post = reset( $this->posts );
3020
+			$this->post = reset($this->posts);
3021 3021
 		} else {
3022 3022
 			$this->post_count = 0;
3023 3023
 			$this->posts = array();
3024 3024
 		}
3025 3025
 
3026
-		if ( $q['lazy_load_term_meta'] ) {
3027
-			wp_queue_posts_for_term_meta_lazyload( $this->posts );
3026
+		if ($q['lazy_load_term_meta']) {
3027
+			wp_queue_posts_for_term_meta_lazyload($this->posts);
3028 3028
 		}
3029 3029
 
3030 3030
 		return $this->posts;
@@ -3040,14 +3040,14 @@  discard block
 block discarded – undo
3040 3040
 	 * @param array  $q      Query variables.
3041 3041
 	 * @param string $limits LIMIT clauses of the query.
3042 3042
 	 */
3043
-	private function set_found_posts( $q, $limits ) {
3043
+	private function set_found_posts($q, $limits) {
3044 3044
 		global $wpdb;
3045 3045
 		// Bail if posts is an empty array. Continue if posts is an empty string,
3046 3046
 		// null, or false to accommodate caching plugins that fill posts later.
3047
-		if ( $q['no_found_rows'] || ( is_array( $this->posts ) && ! $this->posts ) )
3047
+		if ($q['no_found_rows'] || (is_array($this->posts) && ! $this->posts))
3048 3048
 			return;
3049 3049
 
3050
-		if ( ! empty( $limits ) ) {
3050
+		if ( ! empty($limits)) {
3051 3051
 			/**
3052 3052
 			 * Filters the query to run for retrieving the found posts.
3053 3053
 			 *
@@ -3056,9 +3056,9 @@  discard block
 block discarded – undo
3056 3056
 			 * @param string   $found_posts The query to run to find the found posts.
3057 3057
 			 * @param WP_Query &$this       The WP_Query instance (passed by reference).
3058 3058
 			 */
3059
-			$this->found_posts = $wpdb->get_var( apply_filters_ref_array( 'found_posts_query', array( 'SELECT FOUND_ROWS()', &$this ) ) );
3059
+			$this->found_posts = $wpdb->get_var(apply_filters_ref_array('found_posts_query', array('SELECT FOUND_ROWS()', &$this)));
3060 3060
 		} else {
3061
-			$this->found_posts = count( $this->posts );
3061
+			$this->found_posts = count($this->posts);
3062 3062
 		}
3063 3063
 
3064 3064
 		/**
@@ -3069,10 +3069,10 @@  discard block
 block discarded – undo
3069 3069
 		 * @param int      $found_posts The number of posts found.
3070 3070
 		 * @param WP_Query &$this       The WP_Query instance (passed by reference).
3071 3071
 		 */
3072
-		$this->found_posts = apply_filters_ref_array( 'found_posts', array( $this->found_posts, &$this ) );
3072
+		$this->found_posts = apply_filters_ref_array('found_posts', array($this->found_posts, &$this));
3073 3073
 
3074
-		if ( ! empty( $limits ) )
3075
-			$this->max_num_pages = ceil( $this->found_posts / $q['posts_per_page'] );
3074
+		if ( ! empty($limits))
3075
+			$this->max_num_pages = ceil($this->found_posts / $q['posts_per_page']);
3076 3076
 	}
3077 3077
 
3078 3078
 	/**
@@ -3106,7 +3106,7 @@  discard block
 block discarded – undo
3106 3106
 		global $post;
3107 3107
 		$this->in_the_loop = true;
3108 3108
 
3109
-		if ( $this->current_post == -1 ) // loop has just started
3109
+		if ($this->current_post == -1) // loop has just started
3110 3110
 			/**
3111 3111
 			 * Fires once the loop is started.
3112 3112
 			 *
@@ -3114,10 +3114,10 @@  discard block
 block discarded – undo
3114 3114
 			 *
3115 3115
 			 * @param WP_Query &$this The WP_Query instance (passed by reference).
3116 3116
 			 */
3117
-			do_action_ref_array( 'loop_start', array( &$this ) );
3117
+			do_action_ref_array('loop_start', array(&$this));
3118 3118
 
3119 3119
 		$post = $this->next_post();
3120
-		$this->setup_postdata( $post );
3120
+		$this->setup_postdata($post);
3121 3121
 	}
3122 3122
 
3123 3123
 	/**
@@ -3131,9 +3131,9 @@  discard block
 block discarded – undo
3131 3131
 	 * @return bool True if posts are available, false if end of loop.
3132 3132
 	 */
3133 3133
 	public function have_posts() {
3134
-		if ( $this->current_post + 1 < $this->post_count ) {
3134
+		if ($this->current_post + 1 < $this->post_count) {
3135 3135
 			return true;
3136
-		} elseif ( $this->current_post + 1 == $this->post_count && $this->post_count > 0 ) {
3136
+		} elseif ($this->current_post + 1 == $this->post_count && $this->post_count > 0) {
3137 3137
 			/**
3138 3138
 			 * Fires once the loop has ended.
3139 3139
 			 *
@@ -3141,7 +3141,7 @@  discard block
 block discarded – undo
3141 3141
 			 *
3142 3142
 			 * @param WP_Query &$this The WP_Query instance (passed by reference).
3143 3143
 			 */
3144
-			do_action_ref_array( 'loop_end', array( &$this ) );
3144
+			do_action_ref_array('loop_end', array(&$this));
3145 3145
 			// Do some cleaning up after the loop
3146 3146
 			$this->rewind_posts();
3147 3147
 		}
@@ -3158,7 +3158,7 @@  discard block
 block discarded – undo
3158 3158
 	 */
3159 3159
 	public function rewind_posts() {
3160 3160
 		$this->current_post = -1;
3161
-		if ( $this->post_count > 0 ) {
3161
+		if ($this->post_count > 0) {
3162 3162
 			$this->post = $this->posts[0];
3163 3163
 		}
3164 3164
 	}
@@ -3190,13 +3190,13 @@  discard block
 block discarded – undo
3190 3190
 
3191 3191
 		$comment = $this->next_comment();
3192 3192
 
3193
-		if ( $this->current_comment == 0 ) {
3193
+		if ($this->current_comment == 0) {
3194 3194
 			/**
3195 3195
 			 * Fires once the comment loop is started.
3196 3196
 			 *
3197 3197
 			 * @since 2.2.0
3198 3198
 			 */
3199
-			do_action( 'comment_loop_start' );
3199
+			do_action('comment_loop_start');
3200 3200
 		}
3201 3201
 	}
3202 3202
 
@@ -3211,9 +3211,9 @@  discard block
 block discarded – undo
3211 3211
 	 * @return bool True, if more comments. False, if no more posts.
3212 3212
 	 */
3213 3213
 	public function have_comments() {
3214
-		if ( $this->current_comment + 1 < $this->comment_count ) {
3214
+		if ($this->current_comment + 1 < $this->comment_count) {
3215 3215
 			return true;
3216
-		} elseif ( $this->current_comment + 1 == $this->comment_count ) {
3216
+		} elseif ($this->current_comment + 1 == $this->comment_count) {
3217 3217
 			$this->rewind_comments();
3218 3218
 		}
3219 3219
 
@@ -3228,7 +3228,7 @@  discard block
 block discarded – undo
3228 3228
 	 */
3229 3229
 	public function rewind_comments() {
3230 3230
 		$this->current_comment = -1;
3231
-		if ( $this->comment_count > 0 ) {
3231
+		if ($this->comment_count > 0) {
3232 3232
 			$this->comment = $this->comments[0];
3233 3233
 		}
3234 3234
 	}
@@ -3242,9 +3242,9 @@  discard block
 block discarded – undo
3242 3242
 	 * @param string|array $query URL query string or array of query arguments.
3243 3243
 	 * @return array List of posts.
3244 3244
 	 */
3245
-	public function query( $query ) {
3245
+	public function query($query) {
3246 3246
 		$this->init();
3247
-		$this->query = $this->query_vars = wp_parse_args( $query );
3247
+		$this->query = $this->query_vars = wp_parse_args($query);
3248 3248
 		return $this->get_posts();
3249 3249
 	}
3250 3250
 
@@ -3261,64 +3261,64 @@  discard block
 block discarded – undo
3261 3261
 	 * @return object
3262 3262
 	 */
3263 3263
 	public function get_queried_object() {
3264
-		if ( isset($this->queried_object) )
3264
+		if (isset($this->queried_object))
3265 3265
 			return $this->queried_object;
3266 3266
 
3267 3267
 		$this->queried_object = null;
3268 3268
 		$this->queried_object_id = null;
3269 3269
 
3270
-		if ( $this->is_category || $this->is_tag || $this->is_tax ) {
3271
-			if ( $this->is_category ) {
3272
-				if ( $this->get( 'cat' ) ) {
3273
-					$term = get_term( $this->get( 'cat' ), 'category' );
3274
-				} elseif ( $this->get( 'category_name' ) ) {
3275
-					$term = get_term_by( 'slug', $this->get( 'category_name' ), 'category' );
3270
+		if ($this->is_category || $this->is_tag || $this->is_tax) {
3271
+			if ($this->is_category) {
3272
+				if ($this->get('cat')) {
3273
+					$term = get_term($this->get('cat'), 'category');
3274
+				} elseif ($this->get('category_name')) {
3275
+					$term = get_term_by('slug', $this->get('category_name'), 'category');
3276 3276
 				}
3277
-			} elseif ( $this->is_tag ) {
3278
-				if ( $this->get( 'tag_id' ) ) {
3279
-					$term = get_term( $this->get( 'tag_id' ), 'post_tag' );
3280
-				} elseif ( $this->get( 'tag' ) ) {
3281
-					$term = get_term_by( 'slug', $this->get( 'tag' ), 'post_tag' );
3277
+			} elseif ($this->is_tag) {
3278
+				if ($this->get('tag_id')) {
3279
+					$term = get_term($this->get('tag_id'), 'post_tag');
3280
+				} elseif ($this->get('tag')) {
3281
+					$term = get_term_by('slug', $this->get('tag'), 'post_tag');
3282 3282
 				}
3283 3283
 			} else {
3284 3284
 				// For other tax queries, grab the first term from the first clause.
3285
-				if ( ! empty( $this->tax_query->queried_terms ) ) {
3286
-					$queried_taxonomies = array_keys( $this->tax_query->queried_terms );
3287
-					$matched_taxonomy = reset( $queried_taxonomies );
3288
-					$query = $this->tax_query->queried_terms[ $matched_taxonomy ];
3289
-
3290
-					if ( ! empty( $query['terms'] ) ) {
3291
-						if ( 'term_id' == $query['field'] ) {
3292
-							$term = get_term( reset( $query['terms'] ), $matched_taxonomy );
3285
+				if ( ! empty($this->tax_query->queried_terms)) {
3286
+					$queried_taxonomies = array_keys($this->tax_query->queried_terms);
3287
+					$matched_taxonomy = reset($queried_taxonomies);
3288
+					$query = $this->tax_query->queried_terms[$matched_taxonomy];
3289
+
3290
+					if ( ! empty($query['terms'])) {
3291
+						if ('term_id' == $query['field']) {
3292
+							$term = get_term(reset($query['terms']), $matched_taxonomy);
3293 3293
 						} else {
3294
-							$term = get_term_by( $query['field'], reset( $query['terms'] ), $matched_taxonomy );
3294
+							$term = get_term_by($query['field'], reset($query['terms']), $matched_taxonomy);
3295 3295
 						}
3296 3296
 					}
3297 3297
 				}
3298 3298
 			}
3299 3299
 
3300
-			if ( ! empty( $term ) && ! is_wp_error( $term ) )  {
3300
+			if ( ! empty($term) && ! is_wp_error($term)) {
3301 3301
 				$this->queried_object = $term;
3302 3302
 				$this->queried_object_id = (int) $term->term_id;
3303 3303
 
3304
-				if ( $this->is_category && 'category' === $this->queried_object->taxonomy )
3305
-					_make_cat_compat( $this->queried_object );
3304
+				if ($this->is_category && 'category' === $this->queried_object->taxonomy)
3305
+					_make_cat_compat($this->queried_object);
3306 3306
 			}
3307
-		} elseif ( $this->is_post_type_archive ) {
3308
-			$post_type = $this->get( 'post_type' );
3309
-			if ( is_array( $post_type ) )
3310
-				$post_type = reset( $post_type );
3311
-			$this->queried_object = get_post_type_object( $post_type );
3312
-		} elseif ( $this->is_posts_page ) {
3307
+		} elseif ($this->is_post_type_archive) {
3308
+			$post_type = $this->get('post_type');
3309
+			if (is_array($post_type))
3310
+				$post_type = reset($post_type);
3311
+			$this->queried_object = get_post_type_object($post_type);
3312
+		} elseif ($this->is_posts_page) {
3313 3313
 			$page_for_posts = get_option('page_for_posts');
3314
-			$this->queried_object = get_post( $page_for_posts );
3314
+			$this->queried_object = get_post($page_for_posts);
3315 3315
 			$this->queried_object_id = (int) $this->queried_object->ID;
3316
-		} elseif ( $this->is_singular && ! empty( $this->post ) ) {
3316
+		} elseif ($this->is_singular && ! empty($this->post)) {
3317 3317
 			$this->queried_object = $this->post;
3318 3318
 			$this->queried_object_id = (int) $this->post->ID;
3319
-		} elseif ( $this->is_author ) {
3319
+		} elseif ($this->is_author) {
3320 3320
 			$this->queried_object_id = (int) $this->get('author');
3321
-			$this->queried_object = get_userdata( $this->queried_object_id );
3321
+			$this->queried_object = get_userdata($this->queried_object_id);
3322 3322
 		}
3323 3323
 
3324 3324
 		return $this->queried_object;
@@ -3335,7 +3335,7 @@  discard block
 block discarded – undo
3335 3335
 	public function get_queried_object_id() {
3336 3336
 		$this->get_queried_object();
3337 3337
 
3338
-		if ( isset($this->queried_object_id) ) {
3338
+		if (isset($this->queried_object_id)) {
3339 3339
 			return $this->queried_object_id;
3340 3340
 		}
3341 3341
 
@@ -3352,9 +3352,9 @@  discard block
 block discarded – undo
3352 3352
 	 *
3353 3353
 	 * @param string|array $query URL query string or array of vars.
3354 3354
 	 */
3355
-	public function __construct( $query = '' ) {
3356
-		if ( ! empty( $query ) ) {
3357
-			$this->query( $query );
3355
+	public function __construct($query = '') {
3356
+		if ( ! empty($query)) {
3357
+			$this->query($query);
3358 3358
 		}
3359 3359
 	}
3360 3360
 
@@ -3367,8 +3367,8 @@  discard block
 block discarded – undo
3367 3367
 	 * @param string $name Property to get.
3368 3368
 	 * @return mixed Property.
3369 3369
 	 */
3370
-	public function __get( $name ) {
3371
-		if ( in_array( $name, $this->compat_fields ) ) {
3370
+	public function __get($name) {
3371
+		if (in_array($name, $this->compat_fields)) {
3372 3372
 			return $this->$name;
3373 3373
 		}
3374 3374
 	}
@@ -3382,9 +3382,9 @@  discard block
 block discarded – undo
3382 3382
 	 * @param string $name Property to check if set.
3383 3383
 	 * @return bool Whether the property is set.
3384 3384
 	 */
3385
-	public function __isset( $name ) {
3386
-		if ( in_array( $name, $this->compat_fields ) ) {
3387
-			return isset( $this->$name );
3385
+	public function __isset($name) {
3386
+		if (in_array($name, $this->compat_fields)) {
3387
+			return isset($this->$name);
3388 3388
 		}
3389 3389
 	}
3390 3390
 
@@ -3398,9 +3398,9 @@  discard block
 block discarded – undo
3398 3398
 	 * @param array    $arguments Arguments to pass when calling.
3399 3399
 	 * @return mixed|false Return value of the callback, false otherwise.
3400 3400
 	 */
3401
-	public function __call( $name, $arguments ) {
3402
-		if ( in_array( $name, $this->compat_methods ) ) {
3403
-			return call_user_func_array( array( $this, $name ), $arguments );
3401
+	public function __call($name, $arguments) {
3402
+		if (in_array($name, $this->compat_methods)) {
3403
+			return call_user_func_array(array($this, $name), $arguments);
3404 3404
 		}
3405 3405
 		return false;
3406 3406
 	}
@@ -3426,16 +3426,16 @@  discard block
 block discarded – undo
3426 3426
 	 * @param mixed $post_types Optional. Post type or array of posts types to check against.
3427 3427
 	 * @return bool
3428 3428
 	 */
3429
-	public function is_post_type_archive( $post_types = '' ) {
3430
-		if ( empty( $post_types ) || ! $this->is_post_type_archive )
3429
+	public function is_post_type_archive($post_types = '') {
3430
+		if (empty($post_types) || ! $this->is_post_type_archive)
3431 3431
 			return (bool) $this->is_post_type_archive;
3432 3432
 
3433
-		$post_type = $this->get( 'post_type' );
3434
-		if ( is_array( $post_type ) )
3435
-			$post_type = reset( $post_type );
3436
-		$post_type_object = get_post_type_object( $post_type );
3433
+		$post_type = $this->get('post_type');
3434
+		if (is_array($post_type))
3435
+			$post_type = reset($post_type);
3436
+		$post_type_object = get_post_type_object($post_type);
3437 3437
 
3438
-		return in_array( $post_type_object->name, (array) $post_types );
3438
+		return in_array($post_type_object->name, (array) $post_types);
3439 3439
 	}
3440 3440
 
3441 3441
 	/**
@@ -3446,24 +3446,24 @@  discard block
 block discarded – undo
3446 3446
 	 * @param mixed $attachment Attachment ID, title, slug, or array of such.
3447 3447
 	 * @return bool
3448 3448
 	 */
3449
-	public function is_attachment( $attachment = '' ) {
3450
-		if ( ! $this->is_attachment ) {
3449
+	public function is_attachment($attachment = '') {
3450
+		if ( ! $this->is_attachment) {
3451 3451
 			return false;
3452 3452
 		}
3453 3453
 
3454
-		if ( empty( $attachment ) ) {
3454
+		if (empty($attachment)) {
3455 3455
 			return true;
3456 3456
 		}
3457 3457
 
3458
-		$attachment = array_map( 'strval', (array) $attachment );
3458
+		$attachment = array_map('strval', (array) $attachment);
3459 3459
 
3460 3460
 		$post_obj = $this->get_queried_object();
3461 3461
 
3462
-		if ( in_array( (string) $post_obj->ID, $attachment ) ) {
3462
+		if (in_array((string) $post_obj->ID, $attachment)) {
3463 3463
 			return true;
3464
-		} elseif ( in_array( $post_obj->post_title, $attachment ) ) {
3464
+		} elseif (in_array($post_obj->post_title, $attachment)) {
3465 3465
 			return true;
3466
-		} elseif ( in_array( $post_obj->post_name, $attachment ) ) {
3466
+		} elseif (in_array($post_obj->post_name, $attachment)) {
3467 3467
 			return true;
3468 3468
 		}
3469 3469
 		return false;
@@ -3480,22 +3480,22 @@  discard block
 block discarded – undo
3480 3480
 	 * @param mixed $author Optional. User ID, nickname, nicename, or array of User IDs, nicknames, and nicenames
3481 3481
 	 * @return bool
3482 3482
 	 */
3483
-	public function is_author( $author = '' ) {
3484
-		if ( !$this->is_author )
3483
+	public function is_author($author = '') {
3484
+		if ( ! $this->is_author)
3485 3485
 			return false;
3486 3486
 
3487
-		if ( empty($author) )
3487
+		if (empty($author))
3488 3488
 			return true;
3489 3489
 
3490 3490
 		$author_obj = $this->get_queried_object();
3491 3491
 
3492
-		$author = array_map( 'strval', (array) $author );
3492
+		$author = array_map('strval', (array) $author);
3493 3493
 
3494
-		if ( in_array( (string) $author_obj->ID, $author ) )
3494
+		if (in_array((string) $author_obj->ID, $author))
3495 3495
 			return true;
3496
-		elseif ( in_array( $author_obj->nickname, $author ) )
3496
+		elseif (in_array($author_obj->nickname, $author))
3497 3497
 			return true;
3498
-		elseif ( in_array( $author_obj->user_nicename, $author ) )
3498
+		elseif (in_array($author_obj->user_nicename, $author))
3499 3499
 			return true;
3500 3500
 
3501 3501
 		return false;
@@ -3512,22 +3512,22 @@  discard block
 block discarded – undo
3512 3512
 	 * @param mixed $category Optional. Category ID, name, slug, or array of Category IDs, names, and slugs.
3513 3513
 	 * @return bool
3514 3514
 	 */
3515
-	public function is_category( $category = '' ) {
3516
-		if ( !$this->is_category )
3515
+	public function is_category($category = '') {
3516
+		if ( ! $this->is_category)
3517 3517
 			return false;
3518 3518
 
3519
-		if ( empty($category) )
3519
+		if (empty($category))
3520 3520
 			return true;
3521 3521
 
3522 3522
 		$cat_obj = $this->get_queried_object();
3523 3523
 
3524
-		$category = array_map( 'strval', (array) $category );
3524
+		$category = array_map('strval', (array) $category);
3525 3525
 
3526
-		if ( in_array( (string) $cat_obj->term_id, $category ) )
3526
+		if (in_array((string) $cat_obj->term_id, $category))
3527 3527
 			return true;
3528
-		elseif ( in_array( $cat_obj->name, $category ) )
3528
+		elseif (in_array($cat_obj->name, $category))
3529 3529
 			return true;
3530
-		elseif ( in_array( $cat_obj->slug, $category ) )
3530
+		elseif (in_array($cat_obj->slug, $category))
3531 3531
 			return true;
3532 3532
 
3533 3533
 		return false;
@@ -3544,22 +3544,22 @@  discard block
 block discarded – undo
3544 3544
 	 * @param mixed $tag Optional. Tag ID, name, slug, or array of Tag IDs, names, and slugs.
3545 3545
 	 * @return bool
3546 3546
 	 */
3547
-	public function is_tag( $tag = '' ) {
3548
-		if ( ! $this->is_tag )
3547
+	public function is_tag($tag = '') {
3548
+		if ( ! $this->is_tag)
3549 3549
 			return false;
3550 3550
 
3551
-		if ( empty( $tag ) )
3551
+		if (empty($tag))
3552 3552
 			return true;
3553 3553
 
3554 3554
 		$tag_obj = $this->get_queried_object();
3555 3555
 
3556
-		$tag = array_map( 'strval', (array) $tag );
3556
+		$tag = array_map('strval', (array) $tag);
3557 3557
 
3558
-		if ( in_array( (string) $tag_obj->term_id, $tag ) )
3558
+		if (in_array((string) $tag_obj->term_id, $tag))
3559 3559
 			return true;
3560
-		elseif ( in_array( $tag_obj->name, $tag ) )
3560
+		elseif (in_array($tag_obj->name, $tag))
3561 3561
 			return true;
3562
-		elseif ( in_array( $tag_obj->slug, $tag ) )
3562
+		elseif (in_array($tag_obj->slug, $tag))
3563 3563
 			return true;
3564 3564
 
3565 3565
 		return false;
@@ -3583,32 +3583,32 @@  discard block
 block discarded – undo
3583 3583
 	 * @param mixed $term     Optional. Term ID, name, slug or array of Term IDs, names, and slugs.
3584 3584
 	 * @return bool True for custom taxonomy archive pages, false for built-in taxonomies (category and tag archives).
3585 3585
 	 */
3586
-	public function is_tax( $taxonomy = '', $term = '' ) {
3586
+	public function is_tax($taxonomy = '', $term = '') {
3587 3587
 		global $wp_taxonomies;
3588 3588
 
3589
-		if ( !$this->is_tax )
3589
+		if ( ! $this->is_tax)
3590 3590
 			return false;
3591 3591
 
3592
-		if ( empty( $taxonomy ) )
3592
+		if (empty($taxonomy))
3593 3593
 			return true;
3594 3594
 
3595 3595
 		$queried_object = $this->get_queried_object();
3596
-		$tax_array = array_intersect( array_keys( $wp_taxonomies ), (array) $taxonomy );
3596
+		$tax_array = array_intersect(array_keys($wp_taxonomies), (array) $taxonomy);
3597 3597
 		$term_array = (array) $term;
3598 3598
 
3599 3599
 		// Check that the taxonomy matches.
3600
-		if ( ! ( isset( $queried_object->taxonomy ) && count( $tax_array ) && in_array( $queried_object->taxonomy, $tax_array ) ) )
3600
+		if ( ! (isset($queried_object->taxonomy) && count($tax_array) && in_array($queried_object->taxonomy, $tax_array)))
3601 3601
 			return false;
3602 3602
 
3603 3603
 		// Only a Taxonomy provided.
3604
-		if ( empty( $term ) )
3604
+		if (empty($term))
3605 3605
 			return true;
3606 3606
 
3607
-		return isset( $queried_object->term_id ) &&
3608
-			count( array_intersect(
3609
-				array( $queried_object->term_id, $queried_object->name, $queried_object->slug ),
3607
+		return isset($queried_object->term_id) &&
3608
+			count(array_intersect(
3609
+				array($queried_object->term_id, $queried_object->name, $queried_object->slug),
3610 3610
 				$term_array
3611
-			) );
3611
+			));
3612 3612
 	}
3613 3613
 
3614 3614
 	/**
@@ -3620,7 +3620,7 @@  discard block
 block discarded – undo
3620 3620
 	 * @return bool
3621 3621
 	 */
3622 3622
 	public function is_comments_popup() {
3623
-		_deprecated_function( __FUNCTION__, '4.5.0' );
3623
+		_deprecated_function(__FUNCTION__, '4.5.0');
3624 3624
 
3625 3625
 		return false;
3626 3626
 	}
@@ -3655,13 +3655,13 @@  discard block
 block discarded – undo
3655 3655
 	 * @param string|array $feeds Optional feed types to check.
3656 3656
 	 * @return bool
3657 3657
 	 */
3658
-	public function is_feed( $feeds = '' ) {
3659
-		if ( empty( $feeds ) || ! $this->is_feed )
3658
+	public function is_feed($feeds = '') {
3659
+		if (empty($feeds) || ! $this->is_feed)
3660 3660
 			return (bool) $this->is_feed;
3661
-		$qv = $this->get( 'feed' );
3662
-		if ( 'feed' == $qv )
3661
+		$qv = $this->get('feed');
3662
+		if ('feed' == $qv)
3663 3663
 			$qv = get_default_feed();
3664
-		return in_array( $qv, (array) $feeds );
3664
+		return in_array($qv, (array) $feeds);
3665 3665
 	}
3666 3666
 
3667 3667
 	/**
@@ -3693,9 +3693,9 @@  discard block
 block discarded – undo
3693 3693
 	 */
3694 3694
 	public function is_front_page() {
3695 3695
 		// most likely case
3696
-		if ( 'posts' == get_option( 'show_on_front') && $this->is_home() )
3696
+		if ('posts' == get_option('show_on_front') && $this->is_home())
3697 3697
 			return true;
3698
-		elseif ( 'page' == get_option( 'show_on_front') && get_option( 'page_on_front' ) && $this->is_page( get_option( 'page_on_front' ) ) )
3698
+		elseif ('page' == get_option('show_on_front') && get_option('page_on_front') && $this->is_page(get_option('page_on_front')))
3699 3699
 			return true;
3700 3700
 		else
3701 3701
 			return false;
@@ -3746,31 +3746,31 @@  discard block
 block discarded – undo
3746 3746
 	 * @param int|string|array $page Optional. Page ID, title, slug, path, or array of such. Default empty.
3747 3747
 	 * @return bool Whether the query is for an existing single page.
3748 3748
 	 */
3749
-	public function is_page( $page = '' ) {
3750
-		if ( !$this->is_page )
3749
+	public function is_page($page = '') {
3750
+		if ( ! $this->is_page)
3751 3751
 			return false;
3752 3752
 
3753
-		if ( empty( $page ) )
3753
+		if (empty($page))
3754 3754
 			return true;
3755 3755
 
3756 3756
 		$page_obj = $this->get_queried_object();
3757 3757
 
3758
-		$page = array_map( 'strval', (array) $page );
3758
+		$page = array_map('strval', (array) $page);
3759 3759
 
3760
-		if ( in_array( (string) $page_obj->ID, $page ) ) {
3760
+		if (in_array((string) $page_obj->ID, $page)) {
3761 3761
 			return true;
3762
-		} elseif ( in_array( $page_obj->post_title, $page ) ) {
3762
+		} elseif (in_array($page_obj->post_title, $page)) {
3763 3763
 			return true;
3764
-		} elseif ( in_array( $page_obj->post_name, $page ) ) {
3764
+		} elseif (in_array($page_obj->post_name, $page)) {
3765 3765
 			return true;
3766 3766
 		} else {
3767
-			foreach ( $page as $pagepath ) {
3768
-				if ( ! strpos( $pagepath, '/' ) ) {
3767
+			foreach ($page as $pagepath) {
3768
+				if ( ! strpos($pagepath, '/')) {
3769 3769
 					continue;
3770 3770
 				}
3771
-				$pagepath_obj = get_page_by_path( $pagepath );
3771
+				$pagepath_obj = get_page_by_path($pagepath);
3772 3772
 
3773
-				if ( $pagepath_obj && ( $pagepath_obj->ID == $page_obj->ID ) ) {
3773
+				if ($pagepath_obj && ($pagepath_obj->ID == $page_obj->ID)) {
3774 3774
 					return true;
3775 3775
 				}
3776 3776
 			}
@@ -3839,31 +3839,31 @@  discard block
 block discarded – undo
3839 3839
 	 * @param int|string|array $post Optional. Post ID, title, slug, path, or array of such. Default empty.
3840 3840
 	 * @return bool Whether the query is for an existing single post.
3841 3841
 	 */
3842
-	public function is_single( $post = '' ) {
3843
-		if ( !$this->is_single )
3842
+	public function is_single($post = '') {
3843
+		if ( ! $this->is_single)
3844 3844
 			return false;
3845 3845
 
3846
-		if ( empty($post) )
3846
+		if (empty($post))
3847 3847
 			return true;
3848 3848
 
3849 3849
 		$post_obj = $this->get_queried_object();
3850 3850
 
3851
-		$post = array_map( 'strval', (array) $post );
3851
+		$post = array_map('strval', (array) $post);
3852 3852
 
3853
-		if ( in_array( (string) $post_obj->ID, $post ) ) {
3853
+		if (in_array((string) $post_obj->ID, $post)) {
3854 3854
 			return true;
3855
-		} elseif ( in_array( $post_obj->post_title, $post ) ) {
3855
+		} elseif (in_array($post_obj->post_title, $post)) {
3856 3856
 			return true;
3857
-		} elseif ( in_array( $post_obj->post_name, $post ) ) {
3857
+		} elseif (in_array($post_obj->post_name, $post)) {
3858 3858
 			return true;
3859 3859
 		} else {
3860
-			foreach ( $post as $postpath ) {
3861
-				if ( ! strpos( $postpath, '/' ) ) {
3860
+			foreach ($post as $postpath) {
3861
+				if ( ! strpos($postpath, '/')) {
3862 3862
 					continue;
3863 3863
 				}
3864
-				$postpath_obj = get_page_by_path( $postpath, OBJECT, $post_obj->post_type );
3864
+				$postpath_obj = get_page_by_path($postpath, OBJECT, $post_obj->post_type);
3865 3865
 
3866
-				if ( $postpath_obj && ( $postpath_obj->ID == $post_obj->ID ) ) {
3866
+				if ($postpath_obj && ($postpath_obj->ID == $post_obj->ID)) {
3867 3867
 					return true;
3868 3868
 				}
3869 3869
 			}
@@ -3886,13 +3886,13 @@  discard block
 block discarded – undo
3886 3886
 	 * @param string|array $post_types Optional. Post type or array of post types. Default empty.
3887 3887
 	 * @return bool Whether the query is for an existing single post of any of the given post types.
3888 3888
 	 */
3889
-	public function is_singular( $post_types = '' ) {
3890
-		if ( empty( $post_types ) || !$this->is_singular )
3889
+	public function is_singular($post_types = '') {
3890
+		if (empty($post_types) || ! $this->is_singular)
3891 3891
 			return (bool) $this->is_singular;
3892 3892
 
3893 3893
 		$post_obj = $this->get_queried_object();
3894 3894
 
3895
-		return in_array( $post_obj->post_type, (array) $post_types );
3895
+		return in_array($post_obj->post_type, (array) $post_types);
3896 3896
 	}
3897 3897
 
3898 3898
 	/**
@@ -3983,14 +3983,14 @@  discard block
 block discarded – undo
3983 3983
 	 * @param WP_Post|object|int $post WP_Post instance or Post ID/object.
3984 3984
 	 * @return true True when finished.
3985 3985
 	 */
3986
-	public function setup_postdata( $post ) {
3986
+	public function setup_postdata($post) {
3987 3987
 		global $id, $authordata, $currentday, $currentmonth, $page, $pages, $multipage, $more, $numpages;
3988 3988
 
3989
-		if ( ! ( $post instanceof WP_Post ) ) {
3990
-			$post = get_post( $post );
3989
+		if ( ! ($post instanceof WP_Post)) {
3990
+			$post = get_post($post);
3991 3991
 		}
3992 3992
 
3993
-		if ( ! $post ) {
3993
+		if ( ! $post) {
3994 3994
 			return;
3995 3995
 		}
3996 3996
 
@@ -4002,35 +4002,35 @@  discard block
 block discarded – undo
4002 4002
 		$currentmonth = mysql2date('m', $post->post_date, false);
4003 4003
 		$numpages = 1;
4004 4004
 		$multipage = 0;
4005
-		$page = $this->get( 'page' );
4006
-		if ( ! $page )
4005
+		$page = $this->get('page');
4006
+		if ( ! $page)
4007 4007
 			$page = 1;
4008 4008
 
4009 4009
 		/*
4010 4010
 		 * Force full post content when viewing the permalink for the $post,
4011 4011
 		 * or when on an RSS feed. Otherwise respect the 'more' tag.
4012 4012
 		 */
4013
-		if ( $post->ID === get_queried_object_id() && ( $this->is_page() || $this->is_single() ) ) {
4013
+		if ($post->ID === get_queried_object_id() && ($this->is_page() || $this->is_single())) {
4014 4014
 			$more = 1;
4015
-		} elseif ( $this->is_feed() ) {
4015
+		} elseif ($this->is_feed()) {
4016 4016
 			$more = 1;
4017 4017
 		} else {
4018 4018
 			$more = 0;
4019 4019
 		}
4020 4020
 
4021 4021
 		$content = $post->post_content;
4022
-		if ( false !== strpos( $content, '<!--nextpage-->' ) ) {
4023
-			$content = str_replace( "\n<!--nextpage-->\n", '<!--nextpage-->', $content );
4024
-			$content = str_replace( "\n<!--nextpage-->", '<!--nextpage-->', $content );
4025
-			$content = str_replace( "<!--nextpage-->\n", '<!--nextpage-->', $content );
4022
+		if (false !== strpos($content, '<!--nextpage-->')) {
4023
+			$content = str_replace("\n<!--nextpage-->\n", '<!--nextpage-->', $content);
4024
+			$content = str_replace("\n<!--nextpage-->", '<!--nextpage-->', $content);
4025
+			$content = str_replace("<!--nextpage-->\n", '<!--nextpage-->', $content);
4026 4026
 
4027 4027
 			// Ignore nextpage at the beginning of the content.
4028
-			if ( 0 === strpos( $content, '<!--nextpage-->' ) )
4029
-				$content = substr( $content, 15 );
4028
+			if (0 === strpos($content, '<!--nextpage-->'))
4029
+				$content = substr($content, 15);
4030 4030
 
4031 4031
 			$pages = explode('<!--nextpage-->', $content);
4032 4032
 		} else {
4033
-			$pages = array( $post->post_content );
4033
+			$pages = array($post->post_content);
4034 4034
 		}
4035 4035
 
4036 4036
 		/**
@@ -4045,12 +4045,12 @@  discard block
 block discarded – undo
4045 4045
 		 *                       of `<!-- nextpage -->` tags..
4046 4046
 		 * @param WP_Post $post  Current post object.
4047 4047
 		 */
4048
-		$pages = apply_filters( 'content_pagination', $pages, $post );
4048
+		$pages = apply_filters('content_pagination', $pages, $post);
4049 4049
 
4050
-		$numpages = count( $pages );
4050
+		$numpages = count($pages);
4051 4051
 
4052
-		if ( $numpages > 1 ) {
4053
-			if ( $page > 1 ) {
4052
+		if ($numpages > 1) {
4053
+			if ($page > 1) {
4054 4054
 				$more = 1;
4055 4055
 			}
4056 4056
 			$multipage = 1;
@@ -4067,7 +4067,7 @@  discard block
 block discarded – undo
4067 4067
 		 * @param WP_Post  &$post The Post object (passed by reference).
4068 4068
 		 * @param WP_Query &$this The current Query object (passed by reference).
4069 4069
 		 */
4070
-		do_action_ref_array( 'the_post', array( &$post, &$this ) );
4070
+		do_action_ref_array('the_post', array(&$post, &$this));
4071 4071
 
4072 4072
 		return true;
4073 4073
 	}
@@ -4080,9 +4080,9 @@  discard block
 block discarded – undo
4080 4080
 	 * @global WP_Post $post
4081 4081
 	 */
4082 4082
 	public function reset_postdata() {
4083
-		if ( ! empty( $this->post ) ) {
4083
+		if ( ! empty($this->post)) {
4084 4084
 			$GLOBALS['post'] = $this->post;
4085
-			$this->setup_postdata( $this->post );
4085
+			$this->setup_postdata($this->post);
4086 4086
 		}
4087 4087
 	}
4088 4088
 
@@ -4096,8 +4096,8 @@  discard block
 block discarded – undo
4096 4096
 	 * @param int   $term_id
4097 4097
 	 * @return mixed
4098 4098
 	 */
4099
-	public function lazyload_term_meta( $check, $term_id ) {
4100
-		_deprecated_function( __METHOD__, '4.5.0' );
4099
+	public function lazyload_term_meta($check, $term_id) {
4100
+		_deprecated_function(__METHOD__, '4.5.0');
4101 4101
 		return $check;
4102 4102
 	}
4103 4103
 
@@ -4111,8 +4111,8 @@  discard block
 block discarded – undo
4111 4111
 	 * @param int   $comment_id
4112 4112
 	 * @return mixed
4113 4113
 	 */
4114
-	public function lazyload_comment_meta( $check, $comment_id ) {
4115
-		_deprecated_function( __METHOD__, '4.5.0' );
4114
+	public function lazyload_comment_meta($check, $comment_id) {
4115
+		_deprecated_function(__METHOD__, '4.5.0');
4116 4116
 		return $check;
4117 4117
 	}
4118 4118
 }
Please login to merge, or discard this patch.
Braces   +355 added lines, -242 removed lines patch added patch discarded remove patch
@@ -613,8 +613,9 @@  discard block
 block discarded – undo
613 613
 		);
614 614
 
615 615
 		foreach ( $keys as $key ) {
616
-			if ( !isset($array[$key]) )
617
-				$array[$key] = '';
616
+			if ( !isset($array[$key]) ) {
617
+							$array[$key] = '';
618
+			}
618 619
 		}
619 620
 
620 621
 		$array_keys = array( 'category__in', 'category__not_in', 'category__and', 'post__in', 'post__not_in', 'post_name__in',
@@ -622,8 +623,9 @@  discard block
 block discarded – undo
622 623
 			'author__in', 'author__not_in' );
623 624
 
624 625
 		foreach ( $array_keys as $key ) {
625
-			if ( !isset($array[$key]) )
626
-				$array[$key] = array();
626
+			if ( !isset($array[$key]) ) {
627
+							$array[$key] = array();
628
+			}
627 629
 		}
628 630
 		return $array;
629 631
 	}
@@ -762,8 +764,9 @@  discard block
 block discarded – undo
762 764
 		$qv = &$this->query_vars;
763 765
 		$this->query_vars_changed = true;
764 766
 
765
-		if ( ! empty($qv['robots']) )
766
-			$this->is_robots = true;
767
+		if ( ! empty($qv['robots']) ) {
768
+					$this->is_robots = true;
769
+		}
767 770
 
768 771
 		if ( ! is_scalar( $qv['p'] ) || $qv['p'] < 0 ) {
769 772
 			$qv['p'] = 0;
@@ -784,10 +787,18 @@  discard block
 block discarded – undo
784 787
 		$qv['pagename'] = trim( $qv['pagename'] );
785 788
 		$qv['name'] = trim( $qv['name'] );
786 789
 		$qv['title'] = trim( $qv['title'] );
787
-		if ( '' !== $qv['hour'] ) $qv['hour'] = absint($qv['hour']);
788
-		if ( '' !== $qv['minute'] ) $qv['minute'] = absint($qv['minute']);
789
-		if ( '' !== $qv['second'] ) $qv['second'] = absint($qv['second']);
790
-		if ( '' !== $qv['menu_order'] ) $qv['menu_order'] = absint($qv['menu_order']);
790
+		if ( '' !== $qv['hour'] ) {
791
+			$qv['hour'] = absint($qv['hour']);
792
+		}
793
+		if ( '' !== $qv['minute'] ) {
794
+			$qv['minute'] = absint($qv['minute']);
795
+		}
796
+		if ( '' !== $qv['second'] ) {
797
+			$qv['second'] = absint($qv['second']);
798
+		}
799
+		if ( '' !== $qv['menu_order'] ) {
800
+			$qv['menu_order'] = absint($qv['menu_order']);
801
+		}
791 802
 
792 803
 		// Fairly insane upper bound for search string lengths.
793 804
 		if ( ! is_scalar( $qv['s'] ) || ( ! empty( $qv['s'] ) && strlen( $qv['s'] ) > 1600 ) ) {
@@ -795,10 +806,12 @@  discard block
 block discarded – undo
795 806
 		}
796 807
 
797 808
 		// Compat. Map subpost to attachment.
798
-		if ( '' != $qv['subpost'] )
799
-			$qv['attachment'] = $qv['subpost'];
800
-		if ( '' != $qv['subpost_id'] )
801
-			$qv['attachment_id'] = $qv['subpost_id'];
809
+		if ( '' != $qv['subpost'] ) {
810
+					$qv['attachment'] = $qv['subpost'];
811
+		}
812
+		if ( '' != $qv['subpost_id'] ) {
813
+					$qv['attachment_id'] = $qv['subpost_id'];
814
+		}
802 815
 
803 816
 		$qv['attachment_id'] = absint($qv['attachment_id']);
804 817
 
@@ -914,38 +927,46 @@  discard block
 block discarded – undo
914 927
 				$this->is_author = true;
915 928
 			}
916 929
 
917
-			if ( '' != $qv['author_name'] )
918
-				$this->is_author = true;
930
+			if ( '' != $qv['author_name'] ) {
931
+							$this->is_author = true;
932
+			}
919 933
 
920 934
 			if ( !empty( $qv['post_type'] ) && ! is_array( $qv['post_type'] ) ) {
921 935
 				$post_type_obj = get_post_type_object( $qv['post_type'] );
922
-				if ( ! empty( $post_type_obj->has_archive ) )
923
-					$this->is_post_type_archive = true;
936
+				if ( ! empty( $post_type_obj->has_archive ) ) {
937
+									$this->is_post_type_archive = true;
938
+				}
924 939
 			}
925 940
 
926
-			if ( $this->is_post_type_archive || $this->is_date || $this->is_author || $this->is_category || $this->is_tag || $this->is_tax )
927
-				$this->is_archive = true;
941
+			if ( $this->is_post_type_archive || $this->is_date || $this->is_author || $this->is_category || $this->is_tag || $this->is_tax ) {
942
+							$this->is_archive = true;
943
+			}
928 944
 		}
929 945
 
930
-		if ( '' != $qv['feed'] )
931
-			$this->is_feed = true;
946
+		if ( '' != $qv['feed'] ) {
947
+					$this->is_feed = true;
948
+		}
932 949
 
933 950
 		if ( '' != $qv['embed'] ) {
934 951
 			$this->is_embed = true;
935 952
 		}
936 953
 
937
-		if ( '' != $qv['tb'] )
938
-			$this->is_trackback = true;
954
+		if ( '' != $qv['tb'] ) {
955
+					$this->is_trackback = true;
956
+		}
939 957
 
940
-		if ( '' != $qv['paged'] && ( intval($qv['paged']) > 1 ) )
941
-			$this->is_paged = true;
958
+		if ( '' != $qv['paged'] && ( intval($qv['paged']) > 1 ) ) {
959
+					$this->is_paged = true;
960
+		}
942 961
 
943 962
 		// if we're previewing inside the write screen
944
-		if ( '' != $qv['preview'] )
945
-			$this->is_preview = true;
963
+		if ( '' != $qv['preview'] ) {
964
+					$this->is_preview = true;
965
+		}
946 966
 
947
-		if ( is_admin() )
948
-			$this->is_admin = true;
967
+		if ( is_admin() ) {
968
+					$this->is_admin = true;
969
+		}
949 970
 
950 971
 		if ( false !== strpos($qv['feed'], 'comments-') ) {
951 972
 			$qv['feed'] = str_replace('comments-', '', $qv['feed']);
@@ -954,18 +975,21 @@  discard block
 block discarded – undo
954 975
 
955 976
 		$this->is_singular = $this->is_single || $this->is_page || $this->is_attachment;
956 977
 
957
-		if ( $this->is_feed && ( !empty($qv['withcomments']) || ( empty($qv['withoutcomments']) && $this->is_singular ) ) )
958
-			$this->is_comment_feed = true;
978
+		if ( $this->is_feed && ( !empty($qv['withcomments']) || ( empty($qv['withoutcomments']) && $this->is_singular ) ) ) {
979
+					$this->is_comment_feed = true;
980
+		}
959 981
 
960
-		if ( !( $this->is_singular || $this->is_archive || $this->is_search || $this->is_feed || ( defined( 'REST_REQUEST' ) && REST_REQUEST ) || $this->is_trackback || $this->is_404 || $this->is_admin || $this->is_robots ) )
961
-			$this->is_home = true;
982
+		if ( !( $this->is_singular || $this->is_archive || $this->is_search || $this->is_feed || ( defined( 'REST_REQUEST' ) && REST_REQUEST ) || $this->is_trackback || $this->is_404 || $this->is_admin || $this->is_robots ) ) {
983
+					$this->is_home = true;
984
+		}
962 985
 
963 986
 		// Correct is_* for page_on_front and page_for_posts
964 987
 		if ( $this->is_home && 'page' == get_option('show_on_front') && get_option('page_on_front') ) {
965 988
 			$_query = wp_parse_args($this->query);
966 989
 			// pagename can be set and empty depending on matched rewrite rules. Ignore an empty pagename.
967
-			if ( isset($_query['pagename']) && '' == $_query['pagename'] )
968
-				unset($_query['pagename']);
990
+			if ( isset($_query['pagename']) && '' == $_query['pagename'] ) {
991
+							unset($_query['pagename']);
992
+			}
969 993
 
970 994
 			unset( $_query['embed'] );
971 995
 
@@ -1018,27 +1042,31 @@  discard block
 block discarded – undo
1018 1042
 		}
1019 1043
 
1020 1044
 		if ( !empty($qv['post_type']) ) {
1021
-			if ( is_array($qv['post_type']) )
1022
-				$qv['post_type'] = array_map('sanitize_key', $qv['post_type']);
1023
-			else
1024
-				$qv['post_type'] = sanitize_key($qv['post_type']);
1045
+			if ( is_array($qv['post_type']) ) {
1046
+							$qv['post_type'] = array_map('sanitize_key', $qv['post_type']);
1047
+			} else {
1048
+							$qv['post_type'] = sanitize_key($qv['post_type']);
1049
+			}
1025 1050
 		}
1026 1051
 
1027 1052
 		if ( ! empty( $qv['post_status'] ) ) {
1028
-			if ( is_array( $qv['post_status'] ) )
1029
-				$qv['post_status'] = array_map('sanitize_key', $qv['post_status']);
1030
-			else
1031
-				$qv['post_status'] = preg_replace('|[^a-z0-9_,-]|', '', $qv['post_status']);
1053
+			if ( is_array( $qv['post_status'] ) ) {
1054
+							$qv['post_status'] = array_map('sanitize_key', $qv['post_status']);
1055
+			} else {
1056
+							$qv['post_status'] = preg_replace('|[^a-z0-9_,-]|', '', $qv['post_status']);
1057
+			}
1032 1058
 		}
1033 1059
 
1034
-		if ( $this->is_posts_page && ( ! isset($qv['withcomments']) || ! $qv['withcomments'] ) )
1035
-			$this->is_comment_feed = false;
1060
+		if ( $this->is_posts_page && ( ! isset($qv['withcomments']) || ! $qv['withcomments'] ) ) {
1061
+					$this->is_comment_feed = false;
1062
+		}
1036 1063
 
1037 1064
 		$this->is_singular = $this->is_single || $this->is_page || $this->is_attachment;
1038 1065
 		// Done correcting is_* for page_on_front and page_for_posts
1039 1066
 
1040
-		if ( '404' == $qv['error'] )
1041
-			$this->set_404();
1067
+		if ( '404' == $qv['error'] ) {
1068
+					$this->set_404();
1069
+		}
1042 1070
 
1043 1071
 		$this->is_embed = $this->is_embed && ( $this->is_singular || $this->is_404 );
1044 1072
 
@@ -1081,8 +1109,10 @@  discard block
 block discarded – undo
1081 1109
 		}
1082 1110
 
1083 1111
 		foreach ( get_taxonomies( array() , 'objects' ) as $taxonomy => $t ) {
1084
-			if ( 'post_tag' == $taxonomy )
1085
-				continue;	// Handled further down in the $q['tag'] block
1112
+			if ( 'post_tag' == $taxonomy ) {
1113
+							continue;
1114
+			}
1115
+			// Handled further down in the $q['tag'] block
1086 1116
 
1087 1117
 			if ( $t->query_var && !empty( $q[$t->query_var] ) ) {
1088 1118
 				$tax_query_defaults = array(
@@ -1129,10 +1159,11 @@  discard block
 block discarded – undo
1129 1159
 			$q['cat'] = implode( ',', $cat_array );
1130 1160
 
1131 1161
 			foreach ( $cat_array as $cat ) {
1132
-				if ( $cat > 0 )
1133
-					$cat_in[] = $cat;
1134
-				elseif ( $cat < 0 )
1135
-					$cat_not_in[] = abs( $cat );
1162
+				if ( $cat > 0 ) {
1163
+									$cat_in[] = $cat;
1164
+				} elseif ( $cat < 0 ) {
1165
+									$cat_not_in[] = abs( $cat );
1166
+				}
1136 1167
 			}
1137 1168
 
1138 1169
 			if ( ! empty( $cat_in ) ) {
@@ -1158,8 +1189,9 @@  discard block
 block discarded – undo
1158 1189
 
1159 1190
 		if ( ! empty( $q['category__and'] ) && 1 === count( (array) $q['category__and'] ) ) {
1160 1191
 			$q['category__and'] = (array) $q['category__and'];
1161
-			if ( ! isset( $q['category__in'] ) )
1162
-				$q['category__in'] = array();
1192
+			if ( ! isset( $q['category__in'] ) ) {
1193
+							$q['category__in'] = array();
1194
+			}
1163 1195
 			$q['category__in'][] = absint( reset( $q['category__and'] ) );
1164 1196
 			unset( $q['category__and'] );
1165 1197
 		}
@@ -1300,8 +1332,9 @@  discard block
 block discarded – undo
1300 1332
 
1301 1333
 		// added slashes screw with quote grouping when done early, so done later
1302 1334
 		$q['s'] = stripslashes( $q['s'] );
1303
-		if ( empty( $_GET['s'] ) && $this->is_main_query() )
1304
-			$q['s'] = urldecode( $q['s'] );
1335
+		if ( empty( $_GET['s'] ) && $this->is_main_query() ) {
1336
+					$q['s'] = urldecode( $q['s'] );
1337
+		}
1305 1338
 		// there are no line breaks in <input /> fields
1306 1339
 		$q['s'] = str_replace( array( "\r", "\n" ), '', $q['s'] );
1307 1340
 		$q['search_terms_count'] = 1;
@@ -1312,8 +1345,9 @@  discard block
 block discarded – undo
1312 1345
 				$q['search_terms_count'] = count( $matches[0] );
1313 1346
 				$q['search_terms'] = $this->parse_search_terms( $matches[0] );
1314 1347
 				// if the search string has only short terms or stopwords, or is 10+ terms long, match it as sentence
1315
-				if ( empty( $q['search_terms'] ) || count( $q['search_terms'] ) > 9 )
1316
-					$q['search_terms'] = array( $q['s'] );
1348
+				if ( empty( $q['search_terms'] ) || count( $q['search_terms'] ) > 9 ) {
1349
+									$q['search_terms'] = array( $q['s'] );
1350
+				}
1317 1351
 			} else {
1318 1352
 				$q['search_terms'] = array( $q['s'] );
1319 1353
 			}
@@ -1385,17 +1419,20 @@  discard block
 block discarded – undo
1385 1419
 
1386 1420
 		foreach ( $terms as $term ) {
1387 1421
 			// keep before/after spaces when term is for exact match
1388
-			if ( preg_match( '/^".+"$/', $term ) )
1389
-				$term = trim( $term, "\"'" );
1390
-			else
1391
-				$term = trim( $term, "\"' " );
1422
+			if ( preg_match( '/^".+"$/', $term ) ) {
1423
+							$term = trim( $term, "\"'" );
1424
+			} else {
1425
+							$term = trim( $term, "\"' " );
1426
+			}
1392 1427
 
1393 1428
 			// Avoid single A-Z and single dashes.
1394
-			if ( ! $term || ( 1 === strlen( $term ) && preg_match( '/^[a-z\-]$/i', $term ) ) )
1395
-				continue;
1429
+			if ( ! $term || ( 1 === strlen( $term ) && preg_match( '/^[a-z\-]$/i', $term ) ) ) {
1430
+							continue;
1431
+			}
1396 1432
 
1397
-			if ( in_array( call_user_func( $strtolower, $term ), $stopwords, true ) )
1398
-				continue;
1433
+			if ( in_array( call_user_func( $strtolower, $term ), $stopwords, true ) ) {
1434
+							continue;
1435
+			}
1399 1436
 
1400 1437
 			$checked[] = $term;
1401 1438
 		}
@@ -1411,8 +1448,9 @@  discard block
 block discarded – undo
1411 1448
 	 * @return array Stopwords.
1412 1449
 	 */
1413 1450
 	protected function get_search_stopwords() {
1414
-		if ( isset( $this->stopwords ) )
1415
-			return $this->stopwords;
1451
+		if ( isset( $this->stopwords ) ) {
1452
+					return $this->stopwords;
1453
+		}
1416 1454
 
1417 1455
 		/* translators: This is a comma-separated list of very common words that should be excluded from a search,
1418 1456
 		 * like a, an, and the. These are usually called "stopwords". You should not simply translate these individual
@@ -1424,8 +1462,9 @@  discard block
 block discarded – undo
1424 1462
 		$stopwords = array();
1425 1463
 		foreach ( $words as $word ) {
1426 1464
 			$word = trim( $word, "\r\n\t " );
1427
-			if ( $word )
1428
-				$stopwords[] = $word;
1465
+			if ( $word ) {
1466
+							$stopwords[] = $word;
1467
+			}
1429 1468
 		}
1430 1469
 
1431 1470
 		/**
@@ -1470,8 +1509,9 @@  discard block
 block discarded – undo
1470 1509
 				// all words in title
1471 1510
 				$search_orderby .= 'WHEN ' . implode( ' AND ', $q['search_orderby_title'] ) . ' THEN 2 ';
1472 1511
 				// any word in title, not needed when $num_terms == 1
1473
-				if ( $num_terms > 1 )
1474
-					$search_orderby .= 'WHEN ' . implode( ' OR ', $q['search_orderby_title'] ) . ' THEN 3 ';
1512
+				if ( $num_terms > 1 ) {
1513
+									$search_orderby .= 'WHEN ' . implode( ' OR ', $q['search_orderby_title'] ) . ' THEN 3 ';
1514
+				}
1475 1515
 			}
1476 1516
 
1477 1517
 			// Sentence match in 'post_content' and 'post_excerpt'.
@@ -1726,34 +1766,40 @@  discard block
 block discarded – undo
1726 1766
 			}
1727 1767
 		}
1728 1768
 
1729
-		if ( !isset( $q['ignore_sticky_posts'] ) )
1730
-			$q['ignore_sticky_posts'] = false;
1769
+		if ( !isset( $q['ignore_sticky_posts'] ) ) {
1770
+					$q['ignore_sticky_posts'] = false;
1771
+		}
1731 1772
 
1732
-		if ( !isset($q['suppress_filters']) )
1733
-			$q['suppress_filters'] = false;
1773
+		if ( !isset($q['suppress_filters']) ) {
1774
+					$q['suppress_filters'] = false;
1775
+		}
1734 1776
 
1735 1777
 		if ( !isset($q['cache_results']) ) {
1736
-			if ( wp_using_ext_object_cache() )
1737
-				$q['cache_results'] = false;
1738
-			else
1739
-				$q['cache_results'] = true;
1778
+			if ( wp_using_ext_object_cache() ) {
1779
+							$q['cache_results'] = false;
1780
+			} else {
1781
+							$q['cache_results'] = true;
1782
+			}
1740 1783
 		}
1741 1784
 
1742
-		if ( !isset($q['update_post_term_cache']) )
1743
-			$q['update_post_term_cache'] = true;
1785
+		if ( !isset($q['update_post_term_cache']) ) {
1786
+					$q['update_post_term_cache'] = true;
1787
+		}
1744 1788
 
1745 1789
 		if ( ! isset( $q['lazy_load_term_meta'] ) ) {
1746 1790
 			$q['lazy_load_term_meta'] = $q['update_post_term_cache'];
1747 1791
 		}
1748 1792
 
1749
-		if ( !isset($q['update_post_meta_cache']) )
1750
-			$q['update_post_meta_cache'] = true;
1793
+		if ( !isset($q['update_post_meta_cache']) ) {
1794
+					$q['update_post_meta_cache'] = true;
1795
+		}
1751 1796
 
1752 1797
 		if ( !isset($q['post_type']) ) {
1753
-			if ( $this->is_search )
1754
-				$q['post_type'] = 'any';
1755
-			else
1756
-				$q['post_type'] = '';
1798
+			if ( $this->is_search ) {
1799
+							$q['post_type'] = 'any';
1800
+			} else {
1801
+							$q['post_type'] = '';
1802
+			}
1757 1803
 		}
1758 1804
 		$post_type = $q['post_type'];
1759 1805
 		if ( empty( $q['posts_per_page'] ) ) {
@@ -1763,8 +1809,9 @@  discard block
 block discarded – undo
1763 1809
 			$q['showposts'] = (int) $q['showposts'];
1764 1810
 			$q['posts_per_page'] = $q['showposts'];
1765 1811
 		}
1766
-		if ( (isset($q['posts_per_archive_page']) && $q['posts_per_archive_page'] != 0) && ($this->is_archive || $this->is_search) )
1767
-			$q['posts_per_page'] = $q['posts_per_archive_page'];
1812
+		if ( (isset($q['posts_per_archive_page']) && $q['posts_per_archive_page'] != 0) && ($this->is_archive || $this->is_search) ) {
1813
+					$q['posts_per_page'] = $q['posts_per_archive_page'];
1814
+		}
1768 1815
 		if ( !isset($q['nopaging']) ) {
1769 1816
 			if ( $q['posts_per_page'] == -1 ) {
1770 1817
 				$q['nopaging'] = true;
@@ -1783,13 +1830,15 @@  discard block
 block discarded – undo
1783 1830
 			$q['nopaging'] = false;
1784 1831
 		}
1785 1832
 		$q['posts_per_page'] = (int) $q['posts_per_page'];
1786
-		if ( $q['posts_per_page'] < -1 )
1787
-			$q['posts_per_page'] = abs($q['posts_per_page']);
1788
-		elseif ( $q['posts_per_page'] == 0 )
1789
-			$q['posts_per_page'] = 1;
1833
+		if ( $q['posts_per_page'] < -1 ) {
1834
+					$q['posts_per_page'] = abs($q['posts_per_page']);
1835
+		} elseif ( $q['posts_per_page'] == 0 ) {
1836
+					$q['posts_per_page'] = 1;
1837
+		}
1790 1838
 
1791
-		if ( !isset($q['comments_per_page']) || $q['comments_per_page'] == 0 )
1792
-			$q['comments_per_page'] = get_option('comments_per_page');
1839
+		if ( !isset($q['comments_per_page']) || $q['comments_per_page'] == 0 ) {
1840
+					$q['comments_per_page'] = get_option('comments_per_page');
1841
+		}
1793 1842
 
1794 1843
 		if ( $this->is_home && (empty($this->query) || $q['preview'] == 'true') && ( 'page' == get_option('show_on_front') ) && get_option('page_on_front') ) {
1795 1844
 			$this->is_page = true;
@@ -1803,10 +1852,11 @@  discard block
 block discarded – undo
1803 1852
 		}
1804 1853
 
1805 1854
 		// If true, forcibly turns off SQL_CALC_FOUND_ROWS even when limits are present.
1806
-		if ( isset($q['no_found_rows']) )
1807
-			$q['no_found_rows'] = (bool) $q['no_found_rows'];
1808
-		else
1809
-			$q['no_found_rows'] = false;
1855
+		if ( isset($q['no_found_rows']) ) {
1856
+					$q['no_found_rows'] = (bool) $q['no_found_rows'];
1857
+		} else {
1858
+					$q['no_found_rows'] = false;
1859
+		}
1810 1860
 
1811 1861
 		switch ( $q['fields'] ) {
1812 1862
 			case 'ids':
@@ -1845,26 +1895,33 @@  discard block
 block discarded – undo
1845 1895
 		// Handle the other individual date parameters
1846 1896
 		$date_parameters = array();
1847 1897
 
1848
-		if ( '' !== $q['hour'] )
1849
-			$date_parameters['hour'] = $q['hour'];
1898
+		if ( '' !== $q['hour'] ) {
1899
+					$date_parameters['hour'] = $q['hour'];
1900
+		}
1850 1901
 
1851
-		if ( '' !== $q['minute'] )
1852
-			$date_parameters['minute'] = $q['minute'];
1902
+		if ( '' !== $q['minute'] ) {
1903
+					$date_parameters['minute'] = $q['minute'];
1904
+		}
1853 1905
 
1854
-		if ( '' !== $q['second'] )
1855
-			$date_parameters['second'] = $q['second'];
1906
+		if ( '' !== $q['second'] ) {
1907
+					$date_parameters['second'] = $q['second'];
1908
+		}
1856 1909
 
1857
-		if ( $q['year'] )
1858
-			$date_parameters['year'] = $q['year'];
1910
+		if ( $q['year'] ) {
1911
+					$date_parameters['year'] = $q['year'];
1912
+		}
1859 1913
 
1860
-		if ( $q['monthnum'] )
1861
-			$date_parameters['monthnum'] = $q['monthnum'];
1914
+		if ( $q['monthnum'] ) {
1915
+					$date_parameters['monthnum'] = $q['monthnum'];
1916
+		}
1862 1917
 
1863
-		if ( $q['w'] )
1864
-			$date_parameters['week'] = $q['w'];
1918
+		if ( $q['w'] ) {
1919
+					$date_parameters['week'] = $q['w'];
1920
+		}
1865 1921
 
1866
-		if ( $q['day'] )
1867
-			$date_parameters['day'] = $q['day'];
1922
+		if ( $q['day'] ) {
1923
+					$date_parameters['day'] = $q['day'];
1924
+		}
1868 1925
 
1869 1926
 		if ( $date_parameters ) {
1870 1927
 			$date_query = new WP_Date_Query( array( $date_parameters ) );
@@ -1883,8 +1940,9 @@  discard block
 block discarded – undo
1883 1940
 		if ( !empty($q['post_type']) && 'any' != $q['post_type'] ) {
1884 1941
 			foreach ( (array)$q['post_type'] as $_post_type ) {
1885 1942
 				$ptype_obj = get_post_type_object($_post_type);
1886
-				if ( !$ptype_obj || !$ptype_obj->query_var || empty($q[ $ptype_obj->query_var ]) )
1887
-					continue;
1943
+				if ( !$ptype_obj || !$ptype_obj->query_var || empty($q[ $ptype_obj->query_var ]) ) {
1944
+									continue;
1945
+				}
1888 1946
 
1889 1947
 				if ( ! $ptype_obj->hierarchical ) {
1890 1948
 					// Non-hierarchical post types can directly use 'name'.
@@ -1916,21 +1974,24 @@  discard block
 block discarded – undo
1916 1974
 				if ( 'page' != $q['post_type'] ) {
1917 1975
 					foreach ( (array)$q['post_type'] as $_post_type ) {
1918 1976
 						$ptype_obj = get_post_type_object($_post_type);
1919
-						if ( !$ptype_obj || !$ptype_obj->hierarchical )
1920
-							continue;
1977
+						if ( !$ptype_obj || !$ptype_obj->hierarchical ) {
1978
+													continue;
1979
+						}
1921 1980
 
1922 1981
 						$reqpage = get_page_by_path($q['pagename'], OBJECT, $_post_type);
1923
-						if ( $reqpage )
1924
-							break;
1982
+						if ( $reqpage ) {
1983
+													break;
1984
+						}
1925 1985
 					}
1926 1986
 					unset($ptype_obj);
1927 1987
 				} else {
1928 1988
 					$reqpage = get_page_by_path($q['pagename']);
1929 1989
 				}
1930
-				if ( !empty($reqpage) )
1931
-					$reqpage = $reqpage->ID;
1932
-				else
1933
-					$reqpage = 0;
1990
+				if ( !empty($reqpage) ) {
1991
+									$reqpage = $reqpage->ID;
1992
+				} else {
1993
+									$reqpage = 0;
1994
+				}
1934 1995
 			}
1935 1996
 
1936 1997
 			$page_for_posts = get_option('page_for_posts');
@@ -1957,8 +2018,9 @@  discard block
 block discarded – undo
1957 2018
 		}
1958 2019
 
1959 2020
 		// If an attachment is requested by number, let it supersede any post number.
1960
-		if ( $q['attachment_id'] )
1961
-			$q['p'] = absint($q['attachment_id']);
2021
+		if ( $q['attachment_id'] ) {
2022
+					$q['p'] = absint($q['attachment_id']);
2023
+		}
1962 2024
 
1963 2025
 		// If a post number is specified, load that post
1964 2026
 		if ( $q['p'] ) {
@@ -2022,13 +2084,15 @@  discard block
 block discarded – undo
2022 2084
 				$taxonomies = array_keys( $this->tax_query->queried_terms );
2023 2085
 				foreach ( get_post_types( array( 'exclude_from_search' => false ) ) as $pt ) {
2024 2086
 					$object_taxonomies = $pt === 'attachment' ? get_taxonomies_for_attachments() : get_object_taxonomies( $pt );
2025
-					if ( array_intersect( $taxonomies, $object_taxonomies ) )
2026
-						$post_type[] = $pt;
2087
+					if ( array_intersect( $taxonomies, $object_taxonomies ) ) {
2088
+											$post_type[] = $pt;
2089
+					}
2090
+				}
2091
+				if ( ! $post_type ) {
2092
+									$post_type = 'any';
2093
+				} elseif ( count( $post_type ) == 1 ) {
2094
+									$post_type = $post_type[0];
2027 2095
 				}
2028
-				if ( ! $post_type )
2029
-					$post_type = 'any';
2030
-				elseif ( count( $post_type ) == 1 )
2031
-					$post_type = $post_type[0];
2032 2096
 
2033 2097
 				$post_status_join = true;
2034 2098
 			} elseif ( in_array('attachment', (array) $post_type) ) {
@@ -2129,8 +2193,9 @@  discard block
 block discarded – undo
2129 2193
 			}
2130 2194
 			$q['author_name'] = sanitize_title_for_query( $q['author_name'] );
2131 2195
 			$q['author'] = get_user_by('slug', $q['author_name']);
2132
-			if ( $q['author'] )
2133
-				$q['author'] = $q['author']->ID;
2196
+			if ( $q['author'] ) {
2197
+							$q['author'] = $q['author']->ID;
2198
+			}
2134 2199
 			$whichauthor .= " AND ({$wpdb->posts}.post_author = " . absint($q['author']) . ')';
2135 2200
 		}
2136 2201
 
@@ -2214,8 +2279,9 @@  discard block
 block discarded – undo
2214 2279
 		// Order search results by relevance only when another "orderby" is not specified in the query.
2215 2280
 		if ( ! empty( $q['s'] ) ) {
2216 2281
 			$search_orderby = '';
2217
-			if ( ! empty( $q['search_orderby_title'] ) && ( empty( $q['orderby'] ) && ! $this->is_feed ) || ( isset( $q['orderby'] ) && 'relevance' === $q['orderby'] ) )
2218
-				$search_orderby = $this->parse_search_order( $q );
2282
+			if ( ! empty( $q['search_orderby_title'] ) && ( empty( $q['orderby'] ) && ! $this->is_feed ) || ( isset( $q['orderby'] ) && 'relevance' === $q['orderby'] ) ) {
2283
+							$search_orderby = $this->parse_search_order( $q );
2284
+			}
2219 2285
 
2220 2286
 			if ( ! $q['suppress_filters'] ) {
2221 2287
 				/**
@@ -2229,18 +2295,21 @@  discard block
 block discarded – undo
2229 2295
 				$search_orderby = apply_filters( 'posts_search_orderby', $search_orderby, $this );
2230 2296
 			}
2231 2297
 
2232
-			if ( $search_orderby )
2233
-				$orderby = $orderby ? $search_orderby . ', ' . $orderby : $search_orderby;
2298
+			if ( $search_orderby ) {
2299
+							$orderby = $orderby ? $search_orderby . ', ' . $orderby : $search_orderby;
2300
+			}
2234 2301
 		}
2235 2302
 
2236 2303
 		if ( is_array( $post_type ) && count( $post_type ) > 1 ) {
2237 2304
 			$post_type_cap = 'multiple_post_type';
2238 2305
 		} else {
2239
-			if ( is_array( $post_type ) )
2240
-				$post_type = reset( $post_type );
2306
+			if ( is_array( $post_type ) ) {
2307
+							$post_type = reset( $post_type );
2308
+			}
2241 2309
 			$post_type_object = get_post_type_object( $post_type );
2242
-			if ( empty( $post_type_object ) )
2243
-				$post_type_cap = $post_type;
2310
+			if ( empty( $post_type_object ) ) {
2311
+							$post_type_cap = $post_type;
2312
+			}
2244 2313
 		}
2245 2314
 
2246 2315
 		if ( isset( $q['post_password'] ) ) {
@@ -2300,8 +2369,9 @@  discard block
 block discarded – undo
2300 2369
 		if ( ! empty( $q['post_status'] ) ) {
2301 2370
 			$statuswheres = array();
2302 2371
 			$q_status = $q['post_status'];
2303
-			if ( ! is_array( $q_status ) )
2304
-				$q_status = explode(',', $q_status);
2372
+			if ( ! is_array( $q_status ) ) {
2373
+							$q_status = explode(',', $q_status);
2374
+			}
2305 2375
 			$r_status = array();
2306 2376
 			$p_status = array();
2307 2377
 			$e_status = array();
@@ -2361,8 +2431,10 @@  discard block
 block discarded – undo
2361 2431
 			// Add public states.
2362 2432
 			$public_states = get_post_stati( array('public' => true) );
2363 2433
 			foreach ( (array) $public_states as $state ) {
2364
-				if ( 'publish' == $state ) // Publish is hard-coded above.
2434
+				if ( 'publish' == $state ) {
2435
+					// Publish is hard-coded above.
2365 2436
 					continue;
2437
+				}
2366 2438
 				$where .= " OR {$wpdb->posts}.post_status = '$state'";
2367 2439
 			}
2368 2440
 
@@ -2414,8 +2486,9 @@  discard block
 block discarded – undo
2414 2486
 		// Paging
2415 2487
 		if ( empty($q['nopaging']) && !$this->is_singular ) {
2416 2488
 			$page = absint($q['paged']);
2417
-			if ( !$page )
2418
-				$page = 1;
2489
+			if ( !$page ) {
2490
+							$page = 1;
2491
+			}
2419 2492
 
2420 2493
 			// If 'offset' is provided, it takes precedence over 'paged'.
2421 2494
 			if ( isset( $q['offset'] ) && is_numeric( $q['offset'] ) ) {
@@ -2500,8 +2573,9 @@  discard block
 block discarded – undo
2500 2573
 
2501 2574
 			$post_ids = array();
2502 2575
 
2503
-			foreach ( $this->comments as $comment )
2504
-				$post_ids[] = (int) $comment->comment_post_ID;
2576
+			foreach ( $this->comments as $comment ) {
2577
+							$post_ids[] = (int) $comment->comment_post_ID;
2578
+			}
2505 2579
 
2506 2580
 			$post_ids = join(',', $post_ids);
2507 2581
 			$join = '';
@@ -2739,14 +2813,17 @@  discard block
 block discarded – undo
2739 2813
 			$limits = isset( $clauses[ 'limits' ] ) ? $clauses[ 'limits' ] : '';
2740 2814
 		}
2741 2815
 
2742
-		if ( ! empty($groupby) )
2743
-			$groupby = 'GROUP BY ' . $groupby;
2744
-		if ( !empty( $orderby ) )
2745
-			$orderby = 'ORDER BY ' . $orderby;
2816
+		if ( ! empty($groupby) ) {
2817
+					$groupby = 'GROUP BY ' . $groupby;
2818
+		}
2819
+		if ( !empty( $orderby ) ) {
2820
+					$orderby = 'ORDER BY ' . $orderby;
2821
+		}
2746 2822
 
2747 2823
 		$found_rows = '';
2748
-		if ( !$q['no_found_rows'] && !empty($limits) )
2749
-			$found_rows = 'SQL_CALC_FOUND_ROWS';
2824
+		if ( !$q['no_found_rows'] && !empty($limits) ) {
2825
+					$found_rows = 'SQL_CALC_FOUND_ROWS';
2826
+		}
2750 2827
 
2751 2828
 		$this->request = $old_request = "SELECT $found_rows $distinct $fields FROM {$wpdb->posts} $join WHERE 1=1 $where $groupby $orderby $limits";
2752 2829
 
@@ -2923,12 +3000,14 @@  discard block
 block discarded – undo
2923 3000
 							$this->posts = array();
2924 3001
 						} else {
2925 3002
 							$this->is_preview = true;
2926
-							if ( 'future' != $status )
2927
-								$this->posts[0]->post_date = current_time('mysql');
3003
+							if ( 'future' != $status ) {
3004
+															$this->posts[0]->post_date = current_time('mysql');
3005
+							}
2928 3006
 						}
2929 3007
 					} elseif ( $post_status_obj->private ) {
2930
-						if ( ! current_user_can($read_cap, $this->posts[0]->ID) )
2931
-							$this->posts = array();
3008
+						if ( ! current_user_can($read_cap, $this->posts[0]->ID) ) {
3009
+													$this->posts = array();
3010
+						}
2932 3011
 					} else {
2933 3012
 						$this->posts = array();
2934 3013
 					}
@@ -2970,8 +3049,9 @@  discard block
 block discarded – undo
2970 3049
 			}
2971 3050
 
2972 3051
 			// If any posts have been excluded specifically, Ignore those that are sticky.
2973
-			if ( !empty($sticky_posts) && !empty($q['post__not_in']) )
2974
-				$sticky_posts = array_diff($sticky_posts, $q['post__not_in']);
3052
+			if ( !empty($sticky_posts) && !empty($q['post__not_in']) ) {
3053
+							$sticky_posts = array_diff($sticky_posts, $q['post__not_in']);
3054
+			}
2975 3055
 
2976 3056
 			// Fetch sticky posts that weren't in the query results
2977 3057
 			if ( !empty($sticky_posts) ) {
@@ -3014,8 +3094,9 @@  discard block
 block discarded – undo
3014 3094
 
3015 3095
 			$this->posts = array_map( 'get_post', $this->posts );
3016 3096
 
3017
-			if ( $q['cache_results'] )
3018
-				update_post_caches($this->posts, $post_type, $q['update_post_term_cache'], $q['update_post_meta_cache']);
3097
+			if ( $q['cache_results'] ) {
3098
+							update_post_caches($this->posts, $post_type, $q['update_post_term_cache'], $q['update_post_meta_cache']);
3099
+			}
3019 3100
 
3020 3101
 			$this->post = reset( $this->posts );
3021 3102
 		} else {
@@ -3044,8 +3125,9 @@  discard block
 block discarded – undo
3044 3125
 		global $wpdb;
3045 3126
 		// Bail if posts is an empty array. Continue if posts is an empty string,
3046 3127
 		// null, or false to accommodate caching plugins that fill posts later.
3047
-		if ( $q['no_found_rows'] || ( is_array( $this->posts ) && ! $this->posts ) )
3048
-			return;
3128
+		if ( $q['no_found_rows'] || ( is_array( $this->posts ) && ! $this->posts ) ) {
3129
+					return;
3130
+		}
3049 3131
 
3050 3132
 		if ( ! empty( $limits ) ) {
3051 3133
 			/**
@@ -3071,8 +3153,9 @@  discard block
 block discarded – undo
3071 3153
 		 */
3072 3154
 		$this->found_posts = apply_filters_ref_array( 'found_posts', array( $this->found_posts, &$this ) );
3073 3155
 
3074
-		if ( ! empty( $limits ) )
3075
-			$this->max_num_pages = ceil( $this->found_posts / $q['posts_per_page'] );
3156
+		if ( ! empty( $limits ) ) {
3157
+					$this->max_num_pages = ceil( $this->found_posts / $q['posts_per_page'] );
3158
+		}
3076 3159
 	}
3077 3160
 
3078 3161
 	/**
@@ -3106,7 +3189,8 @@  discard block
 block discarded – undo
3106 3189
 		global $post;
3107 3190
 		$this->in_the_loop = true;
3108 3191
 
3109
-		if ( $this->current_post == -1 ) // loop has just started
3192
+		if ( $this->current_post == -1 ) {
3193
+			// loop has just started
3110 3194
 			/**
3111 3195
 			 * Fires once the loop is started.
3112 3196
 			 *
@@ -3115,6 +3199,7 @@  discard block
 block discarded – undo
3115 3199
 			 * @param WP_Query &$this The WP_Query instance (passed by reference).
3116 3200
 			 */
3117 3201
 			do_action_ref_array( 'loop_start', array( &$this ) );
3202
+		}
3118 3203
 
3119 3204
 		$post = $this->next_post();
3120 3205
 		$this->setup_postdata( $post );
@@ -3261,8 +3346,9 @@  discard block
 block discarded – undo
3261 3346
 	 * @return object
3262 3347
 	 */
3263 3348
 	public function get_queried_object() {
3264
-		if ( isset($this->queried_object) )
3265
-			return $this->queried_object;
3349
+		if ( isset($this->queried_object) ) {
3350
+					return $this->queried_object;
3351
+		}
3266 3352
 
3267 3353
 		$this->queried_object = null;
3268 3354
 		$this->queried_object_id = null;
@@ -3301,13 +3387,15 @@  discard block
 block discarded – undo
3301 3387
 				$this->queried_object = $term;
3302 3388
 				$this->queried_object_id = (int) $term->term_id;
3303 3389
 
3304
-				if ( $this->is_category && 'category' === $this->queried_object->taxonomy )
3305
-					_make_cat_compat( $this->queried_object );
3390
+				if ( $this->is_category && 'category' === $this->queried_object->taxonomy ) {
3391
+									_make_cat_compat( $this->queried_object );
3392
+				}
3306 3393
 			}
3307 3394
 		} elseif ( $this->is_post_type_archive ) {
3308 3395
 			$post_type = $this->get( 'post_type' );
3309
-			if ( is_array( $post_type ) )
3310
-				$post_type = reset( $post_type );
3396
+			if ( is_array( $post_type ) ) {
3397
+							$post_type = reset( $post_type );
3398
+			}
3311 3399
 			$this->queried_object = get_post_type_object( $post_type );
3312 3400
 		} elseif ( $this->is_posts_page ) {
3313 3401
 			$page_for_posts = get_option('page_for_posts');
@@ -3427,12 +3515,14 @@  discard block
 block discarded – undo
3427 3515
 	 * @return bool
3428 3516
 	 */
3429 3517
 	public function is_post_type_archive( $post_types = '' ) {
3430
-		if ( empty( $post_types ) || ! $this->is_post_type_archive )
3431
-			return (bool) $this->is_post_type_archive;
3518
+		if ( empty( $post_types ) || ! $this->is_post_type_archive ) {
3519
+					return (bool) $this->is_post_type_archive;
3520
+		}
3432 3521
 
3433 3522
 		$post_type = $this->get( 'post_type' );
3434
-		if ( is_array( $post_type ) )
3435
-			$post_type = reset( $post_type );
3523
+		if ( is_array( $post_type ) ) {
3524
+					$post_type = reset( $post_type );
3525
+		}
3436 3526
 		$post_type_object = get_post_type_object( $post_type );
3437 3527
 
3438 3528
 		return in_array( $post_type_object->name, (array) $post_types );
@@ -3481,22 +3571,25 @@  discard block
 block discarded – undo
3481 3571
 	 * @return bool
3482 3572
 	 */
3483 3573
 	public function is_author( $author = '' ) {
3484
-		if ( !$this->is_author )
3485
-			return false;
3574
+		if ( !$this->is_author ) {
3575
+					return false;
3576
+		}
3486 3577
 
3487
-		if ( empty($author) )
3488
-			return true;
3578
+		if ( empty($author) ) {
3579
+					return true;
3580
+		}
3489 3581
 
3490 3582
 		$author_obj = $this->get_queried_object();
3491 3583
 
3492 3584
 		$author = array_map( 'strval', (array) $author );
3493 3585
 
3494
-		if ( in_array( (string) $author_obj->ID, $author ) )
3495
-			return true;
3496
-		elseif ( in_array( $author_obj->nickname, $author ) )
3497
-			return true;
3498
-		elseif ( in_array( $author_obj->user_nicename, $author ) )
3499
-			return true;
3586
+		if ( in_array( (string) $author_obj->ID, $author ) ) {
3587
+					return true;
3588
+		} elseif ( in_array( $author_obj->nickname, $author ) ) {
3589
+					return true;
3590
+		} elseif ( in_array( $author_obj->user_nicename, $author ) ) {
3591
+					return true;
3592
+		}
3500 3593
 
3501 3594
 		return false;
3502 3595
 	}
@@ -3513,22 +3606,25 @@  discard block
 block discarded – undo
3513 3606
 	 * @return bool
3514 3607
 	 */
3515 3608
 	public function is_category( $category = '' ) {
3516
-		if ( !$this->is_category )
3517
-			return false;
3609
+		if ( !$this->is_category ) {
3610
+					return false;
3611
+		}
3518 3612
 
3519
-		if ( empty($category) )
3520
-			return true;
3613
+		if ( empty($category) ) {
3614
+					return true;
3615
+		}
3521 3616
 
3522 3617
 		$cat_obj = $this->get_queried_object();
3523 3618
 
3524 3619
 		$category = array_map( 'strval', (array) $category );
3525 3620
 
3526
-		if ( in_array( (string) $cat_obj->term_id, $category ) )
3527
-			return true;
3528
-		elseif ( in_array( $cat_obj->name, $category ) )
3529
-			return true;
3530
-		elseif ( in_array( $cat_obj->slug, $category ) )
3531
-			return true;
3621
+		if ( in_array( (string) $cat_obj->term_id, $category ) ) {
3622
+					return true;
3623
+		} elseif ( in_array( $cat_obj->name, $category ) ) {
3624
+					return true;
3625
+		} elseif ( in_array( $cat_obj->slug, $category ) ) {
3626
+					return true;
3627
+		}
3532 3628
 
3533 3629
 		return false;
3534 3630
 	}
@@ -3545,22 +3641,25 @@  discard block
 block discarded – undo
3545 3641
 	 * @return bool
3546 3642
 	 */
3547 3643
 	public function is_tag( $tag = '' ) {
3548
-		if ( ! $this->is_tag )
3549
-			return false;
3644
+		if ( ! $this->is_tag ) {
3645
+					return false;
3646
+		}
3550 3647
 
3551
-		if ( empty( $tag ) )
3552
-			return true;
3648
+		if ( empty( $tag ) ) {
3649
+					return true;
3650
+		}
3553 3651
 
3554 3652
 		$tag_obj = $this->get_queried_object();
3555 3653
 
3556 3654
 		$tag = array_map( 'strval', (array) $tag );
3557 3655
 
3558
-		if ( in_array( (string) $tag_obj->term_id, $tag ) )
3559
-			return true;
3560
-		elseif ( in_array( $tag_obj->name, $tag ) )
3561
-			return true;
3562
-		elseif ( in_array( $tag_obj->slug, $tag ) )
3563
-			return true;
3656
+		if ( in_array( (string) $tag_obj->term_id, $tag ) ) {
3657
+					return true;
3658
+		} elseif ( in_array( $tag_obj->name, $tag ) ) {
3659
+					return true;
3660
+		} elseif ( in_array( $tag_obj->slug, $tag ) ) {
3661
+					return true;
3662
+		}
3564 3663
 
3565 3664
 		return false;
3566 3665
 	}
@@ -3586,23 +3685,27 @@  discard block
 block discarded – undo
3586 3685
 	public function is_tax( $taxonomy = '', $term = '' ) {
3587 3686
 		global $wp_taxonomies;
3588 3687
 
3589
-		if ( !$this->is_tax )
3590
-			return false;
3688
+		if ( !$this->is_tax ) {
3689
+					return false;
3690
+		}
3591 3691
 
3592
-		if ( empty( $taxonomy ) )
3593
-			return true;
3692
+		if ( empty( $taxonomy ) ) {
3693
+					return true;
3694
+		}
3594 3695
 
3595 3696
 		$queried_object = $this->get_queried_object();
3596 3697
 		$tax_array = array_intersect( array_keys( $wp_taxonomies ), (array) $taxonomy );
3597 3698
 		$term_array = (array) $term;
3598 3699
 
3599 3700
 		// Check that the taxonomy matches.
3600
-		if ( ! ( isset( $queried_object->taxonomy ) && count( $tax_array ) && in_array( $queried_object->taxonomy, $tax_array ) ) )
3601
-			return false;
3701
+		if ( ! ( isset( $queried_object->taxonomy ) && count( $tax_array ) && in_array( $queried_object->taxonomy, $tax_array ) ) ) {
3702
+					return false;
3703
+		}
3602 3704
 
3603 3705
 		// Only a Taxonomy provided.
3604
-		if ( empty( $term ) )
3605
-			return true;
3706
+		if ( empty( $term ) ) {
3707
+					return true;
3708
+		}
3606 3709
 
3607 3710
 		return isset( $queried_object->term_id ) &&
3608 3711
 			count( array_intersect(
@@ -3656,11 +3759,13 @@  discard block
 block discarded – undo
3656 3759
 	 * @return bool
3657 3760
 	 */
3658 3761
 	public function is_feed( $feeds = '' ) {
3659
-		if ( empty( $feeds ) || ! $this->is_feed )
3660
-			return (bool) $this->is_feed;
3762
+		if ( empty( $feeds ) || ! $this->is_feed ) {
3763
+					return (bool) $this->is_feed;
3764
+		}
3661 3765
 		$qv = $this->get( 'feed' );
3662
-		if ( 'feed' == $qv )
3663
-			$qv = get_default_feed();
3766
+		if ( 'feed' == $qv ) {
3767
+					$qv = get_default_feed();
3768
+		}
3664 3769
 		return in_array( $qv, (array) $feeds );
3665 3770
 	}
3666 3771
 
@@ -3693,12 +3798,13 @@  discard block
 block discarded – undo
3693 3798
 	 */
3694 3799
 	public function is_front_page() {
3695 3800
 		// most likely case
3696
-		if ( 'posts' == get_option( 'show_on_front') && $this->is_home() )
3697
-			return true;
3698
-		elseif ( 'page' == get_option( 'show_on_front') && get_option( 'page_on_front' ) && $this->is_page( get_option( 'page_on_front' ) ) )
3699
-			return true;
3700
-		else
3701
-			return false;
3801
+		if ( 'posts' == get_option( 'show_on_front') && $this->is_home() ) {
3802
+					return true;
3803
+		} elseif ( 'page' == get_option( 'show_on_front') && get_option( 'page_on_front' ) && $this->is_page( get_option( 'page_on_front' ) ) ) {
3804
+					return true;
3805
+		} else {
3806
+					return false;
3807
+		}
3702 3808
 	}
3703 3809
 
3704 3810
 	/**
@@ -3747,11 +3853,13 @@  discard block
 block discarded – undo
3747 3853
 	 * @return bool Whether the query is for an existing single page.
3748 3854
 	 */
3749 3855
 	public function is_page( $page = '' ) {
3750
-		if ( !$this->is_page )
3751
-			return false;
3856
+		if ( !$this->is_page ) {
3857
+					return false;
3858
+		}
3752 3859
 
3753
-		if ( empty( $page ) )
3754
-			return true;
3860
+		if ( empty( $page ) ) {
3861
+					return true;
3862
+		}
3755 3863
 
3756 3864
 		$page_obj = $this->get_queried_object();
3757 3865
 
@@ -3840,11 +3948,13 @@  discard block
 block discarded – undo
3840 3948
 	 * @return bool Whether the query is for an existing single post.
3841 3949
 	 */
3842 3950
 	public function is_single( $post = '' ) {
3843
-		if ( !$this->is_single )
3844
-			return false;
3951
+		if ( !$this->is_single ) {
3952
+					return false;
3953
+		}
3845 3954
 
3846
-		if ( empty($post) )
3847
-			return true;
3955
+		if ( empty($post) ) {
3956
+					return true;
3957
+		}
3848 3958
 
3849 3959
 		$post_obj = $this->get_queried_object();
3850 3960
 
@@ -3887,8 +3997,9 @@  discard block
 block discarded – undo
3887 3997
 	 * @return bool Whether the query is for an existing single post of any of the given post types.
3888 3998
 	 */
3889 3999
 	public function is_singular( $post_types = '' ) {
3890
-		if ( empty( $post_types ) || !$this->is_singular )
3891
-			return (bool) $this->is_singular;
4000
+		if ( empty( $post_types ) || !$this->is_singular ) {
4001
+					return (bool) $this->is_singular;
4002
+		}
3892 4003
 
3893 4004
 		$post_obj = $this->get_queried_object();
3894 4005
 
@@ -4003,8 +4114,9 @@  discard block
 block discarded – undo
4003 4114
 		$numpages = 1;
4004 4115
 		$multipage = 0;
4005 4116
 		$page = $this->get( 'page' );
4006
-		if ( ! $page )
4007
-			$page = 1;
4117
+		if ( ! $page ) {
4118
+					$page = 1;
4119
+		}
4008 4120
 
4009 4121
 		/*
4010 4122
 		 * Force full post content when viewing the permalink for the $post,
@@ -4025,8 +4137,9 @@  discard block
 block discarded – undo
4025 4137
 			$content = str_replace( "<!--nextpage-->\n", '<!--nextpage-->', $content );
4026 4138
 
4027 4139
 			// Ignore nextpage at the beginning of the content.
4028
-			if ( 0 === strpos( $content, '<!--nextpage-->' ) )
4029
-				$content = substr( $content, 15 );
4140
+			if ( 0 === strpos( $content, '<!--nextpage-->' ) ) {
4141
+							$content = substr( $content, 15 );
4142
+			}
4030 4143
 
4031 4144
 			$pages = explode('<!--nextpage-->', $content);
4032 4145
 		} else {
Please login to merge, or discard this patch.
src/wp-includes/class-wp-text-diff-renderer-table.php 4 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -183,7 +183,7 @@
 block discarded – undo
183 183
 	 * @access public
184 184
 	 *
185 185
 	 * @param string $name Property to check if set.
186
-	 * @return bool Whether the property is set.
186
+	 * @return boolean|null Whether the property is set.
187 187
 	 */
188 188
 	public function __isset( $name ) {
189 189
 		if ( in_array( $name, $this->compat_fields ) ) {
Please login to merge, or discard this patch.
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -169,7 +169,7 @@
 block discarded – undo
169 169
 				 *
170 170
 				 * @param String $processed_line The processed diffed line.
171 171
 				 * @param String $line           The unprocessed diffed line.
172
-		 		 * @param string null            The line context. Values are 'added', 'deleted' or 'unchanged'.
172
+				 * @param string null            The line context. Values are 'added', 'deleted' or 'unchanged'.
173 173
 				 */
174 174
 				$line = apply_filters( 'process_text_diff_html', $processed_line, $line, 'added' );
175 175
 			}
Please login to merge, or discard this patch.
Spacing   +94 added lines, -94 removed lines patch added patch discarded remove patch
@@ -21,7 +21,7 @@  discard block
 block discarded – undo
21 21
 	 * @access public
22 22
 	 * @since 2.6.0
23 23
 	 */
24
-	public $_leading_context_lines  = 10000;
24
+	public $_leading_context_lines = 10000;
25 25
 
26 26
 	/**
27 27
 	 * @see Text_Diff_Renderer::_trailing_context_lines
@@ -58,7 +58,7 @@  discard block
 block discarded – undo
58 58
 	 */
59 59
 	protected $_show_split_view = true;
60 60
 
61
-	protected $compat_fields = array( '_show_split_view', 'inline_diff_renderer', '_diff_threshold' );
61
+	protected $compat_fields = array('_show_split_view', 'inline_diff_renderer', '_diff_threshold');
62 62
 
63 63
 	/**
64 64
 	 * Constructor - Call parent constructor with params array.
@@ -69,10 +69,10 @@  discard block
 block discarded – undo
69 69
 	 *
70 70
 	 * @param array $params
71 71
 	 */
72
-	public function __construct( $params = array() ) {
73
-		parent::__construct( $params );
74
-		if ( isset( $params[ 'show_split_view' ] ) )
75
-			$this->_show_split_view = $params[ 'show_split_view' ];
72
+	public function __construct($params = array()) {
73
+		parent::__construct($params);
74
+		if (isset($params['show_split_view']))
75
+			$this->_show_split_view = $params['show_split_view'];
76 76
 	}
77 77
 
78 78
 	/**
@@ -81,7 +81,7 @@  discard block
 block discarded – undo
81 81
 	 * @param string $header
82 82
 	 * @return string
83 83
 	 */
84
-	public function _startBlock( $header ) {
84
+	public function _startBlock($header) {
85 85
 		return '';
86 86
 	}
87 87
 
@@ -91,7 +91,7 @@  discard block
 block discarded – undo
91 91
 	 * @param array $lines
92 92
 	 * @param string $prefix
93 93
 	 */
94
-	public function _lines( $lines, $prefix=' ' ) {
94
+	public function _lines($lines, $prefix = ' ') {
95 95
 	}
96 96
 
97 97
 	/**
@@ -100,7 +100,7 @@  discard block
 block discarded – undo
100 100
 	 * @param string $line HTML-escape the value.
101 101
 	 * @return string
102 102
 	 */
103
-	public function addedLine( $line ) {
103
+	public function addedLine($line) {
104 104
 		return "<td class='diff-addedline'>{$line}</td>";
105 105
 
106 106
 	}
@@ -111,7 +111,7 @@  discard block
 block discarded – undo
111 111
 	 * @param string $line HTML-escape the value.
112 112
 	 * @return string
113 113
 	 */
114
-	public function deletedLine( $line ) {
114
+	public function deletedLine($line) {
115 115
 		return "<td class='diff-deletedline'>{$line}</td>";
116 116
 	}
117 117
 
@@ -121,7 +121,7 @@  discard block
 block discarded – undo
121 121
 	 * @param string $line HTML-escape the value.
122 122
 	 * @return string
123 123
 	 */
124
-	public function contextLine( $line ) {
124
+	public function contextLine($line) {
125 125
 		return "<td class='diff-context'>{$line}</td>";
126 126
 	}
127 127
 
@@ -142,11 +142,11 @@  discard block
 block discarded – undo
142 142
 	 * @param bool $encode
143 143
 	 * @return string
144 144
 	 */
145
-	public function _added( $lines, $encode = true ) {
145
+	public function _added($lines, $encode = true) {
146 146
 		$r = '';
147 147
 		foreach ($lines as $line) {
148
-			if ( $encode ) {
149
-				$processed_line = htmlspecialchars( $line );
148
+			if ($encode) {
149
+				$processed_line = htmlspecialchars($line);
150 150
 
151 151
 				/**
152 152
 				 * Contextually filters a diffed line.
@@ -161,13 +161,13 @@  discard block
 block discarded – undo
161 161
 				 * @param String $line           The unprocessed diffed line.
162 162
 		 		 * @param string null            The line context. Values are 'added', 'deleted' or 'unchanged'.
163 163
 				 */
164
-				$line = apply_filters( 'process_text_diff_html', $processed_line, $line, 'added' );
164
+				$line = apply_filters('process_text_diff_html', $processed_line, $line, 'added');
165 165
 			}
166 166
 
167
-			if ( $this->_show_split_view ) {
168
-				$r .= '<tr>' . $this->emptyLine() . $this->emptyLine() . $this->addedLine( $line ) . "</tr>\n";
167
+			if ($this->_show_split_view) {
168
+				$r .= '<tr>'.$this->emptyLine().$this->emptyLine().$this->addedLine($line)."</tr>\n";
169 169
 			} else {
170
-				$r .= '<tr>' . $this->addedLine( $line ) . "</tr>\n";
170
+				$r .= '<tr>'.$this->addedLine($line)."</tr>\n";
171 171
 			}
172 172
 		}
173 173
 		return $r;
@@ -181,19 +181,19 @@  discard block
 block discarded – undo
181 181
 	 * @param bool $encode
182 182
 	 * @return string
183 183
 	 */
184
-	public function _deleted( $lines, $encode = true ) {
184
+	public function _deleted($lines, $encode = true) {
185 185
 		$r = '';
186 186
 		foreach ($lines as $line) {
187
-			if ( $encode ) {
188
-				$processed_line = htmlspecialchars( $line );
187
+			if ($encode) {
188
+				$processed_line = htmlspecialchars($line);
189 189
 
190 190
 				/** This filter is documented in wp-includes/wp-diff.php */
191
-				$line = apply_filters( 'process_text_diff_html', $processed_line, $line, 'deleted' );
191
+				$line = apply_filters('process_text_diff_html', $processed_line, $line, 'deleted');
192 192
 			}
193
-			if ( $this->_show_split_view ) {
194
-				$r .= '<tr>' . $this->deletedLine( $line ) . $this->emptyLine() . $this->emptyLine() . "</tr>\n";
193
+			if ($this->_show_split_view) {
194
+				$r .= '<tr>'.$this->deletedLine($line).$this->emptyLine().$this->emptyLine()."</tr>\n";
195 195
 			} else {
196
-				$r .= '<tr>' . $this->deletedLine( $line ) . "</tr>\n";
196
+				$r .= '<tr>'.$this->deletedLine($line)."</tr>\n";
197 197
 			}
198 198
 
199 199
 		}
@@ -208,19 +208,19 @@  discard block
 block discarded – undo
208 208
 	 * @param bool $encode
209 209
 	 * @return string
210 210
 	 */
211
-	public function _context( $lines, $encode = true ) {
211
+	public function _context($lines, $encode = true) {
212 212
 		$r = '';
213 213
 		foreach ($lines as $line) {
214
-			if ( $encode ) {
215
-				$processed_line = htmlspecialchars( $line );
214
+			if ($encode) {
215
+				$processed_line = htmlspecialchars($line);
216 216
 
217 217
 				/** This filter is documented in wp-includes/wp-diff.php */
218
-				$line = apply_filters( 'process_text_diff_html', $processed_line, $line, 'unchanged' );
218
+				$line = apply_filters('process_text_diff_html', $processed_line, $line, 'unchanged');
219 219
 			}
220
-			if (  $this->_show_split_view ) {
221
-				$r .= '<tr>' . $this->contextLine( $line ) . $this->emptyLine() . $this->contextLine( $line )  . "</tr>\n";
220
+			if ($this->_show_split_view) {
221
+				$r .= '<tr>'.$this->contextLine($line).$this->emptyLine().$this->contextLine($line)."</tr>\n";
222 222
 			} else {
223
-				$r .= '<tr>' . $this->contextLine( $line ) . "</tr>\n";
223
+				$r .= '<tr>'.$this->contextLine($line)."</tr>\n";
224 224
 			}
225 225
 		}
226 226
 		return $r;
@@ -239,7 +239,7 @@  discard block
 block discarded – undo
239 239
 	 * @param array $final
240 240
 	 * @return string
241 241
 	 */
242
-	public function _changed( $orig, $final ) {
242
+	public function _changed($orig, $final) {
243 243
 		$r = '';
244 244
 
245 245
 		// Does the aforementioned additional processing
@@ -249,66 +249,66 @@  discard block
 block discarded – undo
249 249
 		// *_rows are column vectors for the orig column and the final column.
250 250
 		//	row >= 0: an indix of the $orig or $final array
251 251
 		//	row  < 0: a blank row for that column
252
-		list($orig_matches, $final_matches, $orig_rows, $final_rows) = $this->interleave_changed_lines( $orig, $final );
252
+		list($orig_matches, $final_matches, $orig_rows, $final_rows) = $this->interleave_changed_lines($orig, $final);
253 253
 
254 254
 		// These will hold the word changes as determined by an inline diff
255 255
 		$orig_diffs  = array();
256 256
 		$final_diffs = array();
257 257
 
258 258
 		// Compute word diffs for each matched pair using the inline diff
259
-		foreach ( $orig_matches as $o => $f ) {
260
-			if ( is_numeric($o) && is_numeric($f) ) {
261
-				$text_diff = new Text_Diff( 'auto', array( array($orig[$o]), array($final[$f]) ) );
259
+		foreach ($orig_matches as $o => $f) {
260
+			if (is_numeric($o) && is_numeric($f)) {
261
+				$text_diff = new Text_Diff('auto', array(array($orig[$o]), array($final[$f])));
262 262
 				$renderer = new $this->inline_diff_renderer;
263
-				$diff = $renderer->render( $text_diff );
263
+				$diff = $renderer->render($text_diff);
264 264
 
265 265
 				// If they're too different, don't include any <ins> or <dels>
266
-				if ( preg_match_all( '!(<ins>.*?</ins>|<del>.*?</del>)!', $diff, $diff_matches ) ) {
266
+				if (preg_match_all('!(<ins>.*?</ins>|<del>.*?</del>)!', $diff, $diff_matches)) {
267 267
 					// length of all text between <ins> or <del>
268
-					$stripped_matches = strlen(strip_tags( join(' ', $diff_matches[0]) ));
268
+					$stripped_matches = strlen(strip_tags(join(' ', $diff_matches[0])));
269 269
 					// since we count lengith of text between <ins> or <del> (instead of picking just one),
270 270
 					//	we double the length of chars not in those tags.
271
-					$stripped_diff = strlen(strip_tags( $diff )) * 2 - $stripped_matches;
271
+					$stripped_diff = strlen(strip_tags($diff)) * 2 - $stripped_matches;
272 272
 					$diff_ratio = $stripped_matches / $stripped_diff;
273
-					if ( $diff_ratio > $this->_diff_threshold )
273
+					if ($diff_ratio > $this->_diff_threshold)
274 274
 						continue; // Too different. Don't save diffs.
275 275
 				}
276 276
 
277 277
 				// Un-inline the diffs by removing del or ins
278
-				$orig_diffs[$o]  = preg_replace( '|<ins>.*?</ins>|', '', $diff );
279
-				$final_diffs[$f] = preg_replace( '|<del>.*?</del>|', '', $diff );
278
+				$orig_diffs[$o]  = preg_replace('|<ins>.*?</ins>|', '', $diff);
279
+				$final_diffs[$f] = preg_replace('|<del>.*?</del>|', '', $diff);
280 280
 			}
281 281
 		}
282 282
 
283
-		foreach ( array_keys($orig_rows) as $row ) {
283
+		foreach (array_keys($orig_rows) as $row) {
284 284
 			// Both columns have blanks. Ignore them.
285
-			if ( $orig_rows[$row] < 0 && $final_rows[$row] < 0 )
285
+			if ($orig_rows[$row] < 0 && $final_rows[$row] < 0)
286 286
 				continue;
287 287
 
288 288
 			// If we have a word based diff, use it. Otherwise, use the normal line.
289
-			if ( isset( $orig_diffs[$orig_rows[$row]] ) )
289
+			if (isset($orig_diffs[$orig_rows[$row]]))
290 290
 				$orig_line = $orig_diffs[$orig_rows[$row]];
291
-			elseif ( isset( $orig[$orig_rows[$row]] ) )
291
+			elseif (isset($orig[$orig_rows[$row]]))
292 292
 				$orig_line = htmlspecialchars($orig[$orig_rows[$row]]);
293 293
 			else
294 294
 				$orig_line = '';
295 295
 
296
-			if ( isset( $final_diffs[$final_rows[$row]] ) )
296
+			if (isset($final_diffs[$final_rows[$row]]))
297 297
 				$final_line = $final_diffs[$final_rows[$row]];
298
-			elseif ( isset( $final[$final_rows[$row]] ) )
298
+			elseif (isset($final[$final_rows[$row]]))
299 299
 				$final_line = htmlspecialchars($final[$final_rows[$row]]);
300 300
 			else
301 301
 				$final_line = '';
302 302
 
303
-			if ( $orig_rows[$row] < 0 ) { // Orig is blank. This is really an added row.
304
-				$r .= $this->_added( array($final_line), false );
305
-			} elseif ( $final_rows[$row] < 0 ) { // Final is blank. This is really a deleted row.
306
-				$r .= $this->_deleted( array($orig_line), false );
303
+			if ($orig_rows[$row] < 0) { // Orig is blank. This is really an added row.
304
+				$r .= $this->_added(array($final_line), false);
305
+			} elseif ($final_rows[$row] < 0) { // Final is blank. This is really a deleted row.
306
+				$r .= $this->_deleted(array($orig_line), false);
307 307
 			} else { // A true changed row.
308
-				if ( $this->_show_split_view ) {
309
-					$r .= '<tr>' . $this->deletedLine( $orig_line ) . $this->emptyLine() . $this->addedLine( $final_line ) . "</tr>\n";
308
+				if ($this->_show_split_view) {
309
+					$r .= '<tr>'.$this->deletedLine($orig_line).$this->emptyLine().$this->addedLine($final_line)."</tr>\n";
310 310
 				} else {
311
-					$r .= '<tr>' . $this->deletedLine( $orig_line ) . "</tr><tr>" . $this->addedLine( $final_line ) . "</tr>\n";
311
+					$r .= '<tr>'.$this->deletedLine($orig_line)."</tr><tr>".$this->addedLine($final_line)."</tr>\n";
312 312
 				}
313 313
 			}
314 314
 		}
@@ -330,13 +330,13 @@  discard block
 block discarded – undo
330 330
 	 * @param array $final
331 331
 	 * @return array
332 332
 	 */
333
-	public function interleave_changed_lines( $orig, $final ) {
333
+	public function interleave_changed_lines($orig, $final) {
334 334
 
335 335
 		// Contains all pairwise string comparisons. Keys are such that this need only be a one dimensional array.
336 336
 		$matches = array();
337
-		foreach ( array_keys($orig) as $o ) {
338
-			foreach ( array_keys($final) as $f ) {
339
-				$matches["$o,$f"] = $this->compute_string_distance( $orig[$o], $final[$f] );
337
+		foreach (array_keys($orig) as $o) {
338
+			foreach (array_keys($final) as $f) {
339
+				$matches["$o,$f"] = $this->compute_string_distance($orig[$o], $final[$f]);
340 340
 			}
341 341
 		}
342 342
 		asort($matches); // Order by string distance.
@@ -344,28 +344,28 @@  discard block
 block discarded – undo
344 344
 		$orig_matches  = array();
345 345
 		$final_matches = array();
346 346
 
347
-		foreach ( $matches as $keys => $difference ) {
347
+		foreach ($matches as $keys => $difference) {
348 348
 			list($o, $f) = explode(',', $keys);
349 349
 			$o = (int) $o;
350 350
 			$f = (int) $f;
351 351
 
352 352
 			// Already have better matches for these guys
353
-			if ( isset($orig_matches[$o]) && isset($final_matches[$f]) )
353
+			if (isset($orig_matches[$o]) && isset($final_matches[$f]))
354 354
 				continue;
355 355
 
356 356
 			// First match for these guys. Must be best match
357
-			if ( !isset($orig_matches[$o]) && !isset($final_matches[$f]) ) {
357
+			if ( ! isset($orig_matches[$o]) && ! isset($final_matches[$f])) {
358 358
 				$orig_matches[$o] = $f;
359 359
 				$final_matches[$f] = $o;
360 360
 				continue;
361 361
 			}
362 362
 
363 363
 			// Best match of this final is already taken?  Must mean this final is a new row.
364
-			if ( isset($orig_matches[$o]) )
364
+			if (isset($orig_matches[$o]))
365 365
 				$final_matches[$f] = 'x';
366 366
 
367 367
 			// Best match of this orig is already taken?  Must mean this orig is a deleted row.
368
-			elseif ( isset($final_matches[$f]) )
368
+			elseif (isset($final_matches[$f]))
369 369
 				$orig_matches[$o] = 'x';
370 370
 		}
371 371
 
@@ -379,31 +379,31 @@  discard block
 block discarded – undo
379 379
 
380 380
 		// Interleaves rows with blanks to keep matches aligned.
381 381
 		// We may end up with some extraneous blank rows, but we'll just ignore them later.
382
-		foreach ( $orig_rows_copy as $orig_row ) {
382
+		foreach ($orig_rows_copy as $orig_row) {
383 383
 			$final_pos = array_search($orig_matches[$orig_row], $final_rows, true);
384 384
 			$orig_pos = (int) array_search($orig_row, $orig_rows, true);
385 385
 
386
-			if ( false === $final_pos ) { // This orig is paired with a blank final.
387
-				array_splice( $final_rows, $orig_pos, 0, -1 );
388
-			} elseif ( $final_pos < $orig_pos ) { // This orig's match is up a ways. Pad final with blank rows.
386
+			if (false === $final_pos) { // This orig is paired with a blank final.
387
+				array_splice($final_rows, $orig_pos, 0, -1);
388
+			} elseif ($final_pos < $orig_pos) { // This orig's match is up a ways. Pad final with blank rows.
389 389
 				$diff_pos = $final_pos - $orig_pos;
390
-				while ( $diff_pos < 0 )
391
-					array_splice( $final_rows, $orig_pos, 0, $diff_pos++ );
392
-			} elseif ( $final_pos > $orig_pos ) { // This orig's match is down a ways. Pad orig with blank rows.
390
+				while ($diff_pos < 0)
391
+					array_splice($final_rows, $orig_pos, 0, $diff_pos++);
392
+			} elseif ($final_pos > $orig_pos) { // This orig's match is down a ways. Pad orig with blank rows.
393 393
 				$diff_pos = $orig_pos - $final_pos;
394
-				while ( $diff_pos < 0 )
395
-					array_splice( $orig_rows, $orig_pos, 0, $diff_pos++ );
394
+				while ($diff_pos < 0)
395
+					array_splice($orig_rows, $orig_pos, 0, $diff_pos++);
396 396
 			}
397 397
 		}
398 398
 
399 399
 		// Pad the ends with blank rows if the columns aren't the same length
400 400
 		$diff_count = count($orig_rows) - count($final_rows);
401
-		if ( $diff_count < 0 ) {
402
-			while ( $diff_count < 0 )
401
+		if ($diff_count < 0) {
402
+			while ($diff_count < 0)
403 403
 				array_push($orig_rows, $diff_count++);
404
-		} elseif ( $diff_count > 0 ) {
404
+		} elseif ($diff_count > 0) {
405 405
 			$diff_count = -1 * $diff_count;
406
-			while ( $diff_count < 0 )
406
+			while ($diff_count < 0)
407 407
 				array_push($final_rows, $diff_count++);
408 408
 		}
409 409
 
@@ -419,16 +419,16 @@  discard block
 block discarded – undo
419 419
 	 * @param string $string2
420 420
 	 * @return int
421 421
 	 */
422
-	public function compute_string_distance( $string1, $string2 ) {
422
+	public function compute_string_distance($string1, $string2) {
423 423
 		// Vectors containing character frequency for all chars in each string
424 424
 		$chars1 = count_chars($string1);
425 425
 		$chars2 = count_chars($string2);
426 426
 
427 427
 		// L1-norm of difference vector.
428
-		$difference = array_sum( array_map( array($this, 'difference'), $chars1, $chars2 ) );
428
+		$difference = array_sum(array_map(array($this, 'difference'), $chars1, $chars2));
429 429
 
430 430
 		// $string1 has zero length? Odd. Give huge penalty by not dividing.
431
-		if ( !$string1 )
431
+		if ( ! $string1)
432 432
 			return $difference;
433 433
 
434 434
 		// Return distance per character (of string1).
@@ -443,8 +443,8 @@  discard block
 block discarded – undo
443 443
 	 * @param int $b
444 444
 	 * @return int
445 445
 	 */
446
-	public function difference( $a, $b ) {
447
-		return abs( $a - $b );
446
+	public function difference($a, $b) {
447
+		return abs($a - $b);
448 448
 	}
449 449
 
450 450
 	/**
@@ -456,8 +456,8 @@  discard block
 block discarded – undo
456 456
 	 * @param string $name Property to get.
457 457
 	 * @return mixed Property.
458 458
 	 */
459
-	public function __get( $name ) {
460
-		if ( in_array( $name, $this->compat_fields ) ) {
459
+	public function __get($name) {
460
+		if (in_array($name, $this->compat_fields)) {
461 461
 			return $this->$name;
462 462
 		}
463 463
 	}
@@ -472,8 +472,8 @@  discard block
 block discarded – undo
472 472
 	 * @param mixed  $value Property value.
473 473
 	 * @return mixed Newly-set property.
474 474
 	 */
475
-	public function __set( $name, $value ) {
476
-		if ( in_array( $name, $this->compat_fields ) ) {
475
+	public function __set($name, $value) {
476
+		if (in_array($name, $this->compat_fields)) {
477 477
 			return $this->$name = $value;
478 478
 		}
479 479
 	}
@@ -487,9 +487,9 @@  discard block
 block discarded – undo
487 487
 	 * @param string $name Property to check if set.
488 488
 	 * @return bool Whether the property is set.
489 489
 	 */
490
-	public function __isset( $name ) {
491
-		if ( in_array( $name, $this->compat_fields ) ) {
492
-			return isset( $this->$name );
490
+	public function __isset($name) {
491
+		if (in_array($name, $this->compat_fields)) {
492
+			return isset($this->$name);
493 493
 		}
494 494
 	}
495 495
 
@@ -501,9 +501,9 @@  discard block
 block discarded – undo
501 501
 	 *
502 502
 	 * @param string $name Property to unset.
503 503
 	 */
504
-	public function __unset( $name ) {
505
-		if ( in_array( $name, $this->compat_fields ) ) {
506
-			unset( $this->$name );
504
+	public function __unset($name) {
505
+		if (in_array($name, $this->compat_fields)) {
506
+			unset($this->$name);
507 507
 		}
508 508
 	}
509 509
 }
Please login to merge, or discard this patch.
Braces   +49 added lines, -35 removed lines patch added patch discarded remove patch
@@ -81,8 +81,9 @@  discard block
 block discarded – undo
81 81
 	 */
82 82
 	public function __construct( $params = array() ) {
83 83
 		parent::__construct( $params );
84
-		if ( isset( $params[ 'show_split_view' ] ) )
85
-			$this->_show_split_view = $params[ 'show_split_view' ];
84
+		if ( isset( $params[ 'show_split_view' ] ) ) {
85
+					$this->_show_split_view = $params[ 'show_split_view' ];
86
+		}
86 87
 	}
87 88
 
88 89
 	/**
@@ -280,8 +281,10 @@  discard block
 block discarded – undo
280 281
 					//	we double the length of chars not in those tags.
281 282
 					$stripped_diff = strlen(strip_tags( $diff )) * 2 - $stripped_matches;
282 283
 					$diff_ratio = $stripped_matches / $stripped_diff;
283
-					if ( $diff_ratio > $this->_diff_threshold )
284
-						continue; // Too different. Don't save diffs.
284
+					if ( $diff_ratio > $this->_diff_threshold ) {
285
+											continue;
286
+					}
287
+					// Too different. Don't save diffs.
285 288
 				}
286 289
 
287 290
 				// Un-inline the diffs by removing del or ins
@@ -292,23 +295,26 @@  discard block
 block discarded – undo
292 295
 
293 296
 		foreach ( array_keys($orig_rows) as $row ) {
294 297
 			// Both columns have blanks. Ignore them.
295
-			if ( $orig_rows[$row] < 0 && $final_rows[$row] < 0 )
296
-				continue;
298
+			if ( $orig_rows[$row] < 0 && $final_rows[$row] < 0 ) {
299
+							continue;
300
+			}
297 301
 
298 302
 			// If we have a word based diff, use it. Otherwise, use the normal line.
299
-			if ( isset( $orig_diffs[$orig_rows[$row]] ) )
300
-				$orig_line = $orig_diffs[$orig_rows[$row]];
301
-			elseif ( isset( $orig[$orig_rows[$row]] ) )
302
-				$orig_line = htmlspecialchars($orig[$orig_rows[$row]]);
303
-			else
304
-				$orig_line = '';
305
-
306
-			if ( isset( $final_diffs[$final_rows[$row]] ) )
307
-				$final_line = $final_diffs[$final_rows[$row]];
308
-			elseif ( isset( $final[$final_rows[$row]] ) )
309
-				$final_line = htmlspecialchars($final[$final_rows[$row]]);
310
-			else
311
-				$final_line = '';
303
+			if ( isset( $orig_diffs[$orig_rows[$row]] ) ) {
304
+							$orig_line = $orig_diffs[$orig_rows[$row]];
305
+			} elseif ( isset( $orig[$orig_rows[$row]] ) ) {
306
+							$orig_line = htmlspecialchars($orig[$orig_rows[$row]]);
307
+			} else {
308
+							$orig_line = '';
309
+			}
310
+
311
+			if ( isset( $final_diffs[$final_rows[$row]] ) ) {
312
+							$final_line = $final_diffs[$final_rows[$row]];
313
+			} elseif ( isset( $final[$final_rows[$row]] ) ) {
314
+							$final_line = htmlspecialchars($final[$final_rows[$row]]);
315
+			} else {
316
+							$final_line = '';
317
+			}
312 318
 
313 319
 			if ( $orig_rows[$row] < 0 ) { // Orig is blank. This is really an added row.
314 320
 				$r .= $this->_added( array($final_line), false );
@@ -360,8 +366,9 @@  discard block
 block discarded – undo
360 366
 			$f = (int) $f;
361 367
 
362 368
 			// Already have better matches for these guys
363
-			if ( isset($orig_matches[$o]) && isset($final_matches[$f]) )
364
-				continue;
369
+			if ( isset($orig_matches[$o]) && isset($final_matches[$f]) ) {
370
+							continue;
371
+			}
365 372
 
366 373
 			// First match for these guys. Must be best match
367 374
 			if ( !isset($orig_matches[$o]) && !isset($final_matches[$f]) ) {
@@ -371,12 +378,14 @@  discard block
 block discarded – undo
371 378
 			}
372 379
 
373 380
 			// Best match of this final is already taken?  Must mean this final is a new row.
374
-			if ( isset($orig_matches[$o]) )
375
-				$final_matches[$f] = 'x';
381
+			if ( isset($orig_matches[$o]) ) {
382
+							$final_matches[$f] = 'x';
383
+			}
376 384
 
377 385
 			// Best match of this orig is already taken?  Must mean this orig is a deleted row.
378
-			elseif ( isset($final_matches[$f]) )
379
-				$orig_matches[$o] = 'x';
386
+			elseif ( isset($final_matches[$f]) ) {
387
+							$orig_matches[$o] = 'x';
388
+			}
380 389
 		}
381 390
 
382 391
 		// We read the text in this order
@@ -397,24 +406,28 @@  discard block
 block discarded – undo
397 406
 				array_splice( $final_rows, $orig_pos, 0, -1 );
398 407
 			} elseif ( $final_pos < $orig_pos ) { // This orig's match is up a ways. Pad final with blank rows.
399 408
 				$diff_pos = $final_pos - $orig_pos;
400
-				while ( $diff_pos < 0 )
401
-					array_splice( $final_rows, $orig_pos, 0, $diff_pos++ );
409
+				while ( $diff_pos < 0 ) {
410
+									array_splice( $final_rows, $orig_pos, 0, $diff_pos++ );
411
+				}
402 412
 			} elseif ( $final_pos > $orig_pos ) { // This orig's match is down a ways. Pad orig with blank rows.
403 413
 				$diff_pos = $orig_pos - $final_pos;
404
-				while ( $diff_pos < 0 )
405
-					array_splice( $orig_rows, $orig_pos, 0, $diff_pos++ );
414
+				while ( $diff_pos < 0 ) {
415
+									array_splice( $orig_rows, $orig_pos, 0, $diff_pos++ );
416
+				}
406 417
 			}
407 418
 		}
408 419
 
409 420
 		// Pad the ends with blank rows if the columns aren't the same length
410 421
 		$diff_count = count($orig_rows) - count($final_rows);
411 422
 		if ( $diff_count < 0 ) {
412
-			while ( $diff_count < 0 )
413
-				array_push($orig_rows, $diff_count++);
423
+			while ( $diff_count < 0 ) {
424
+							array_push($orig_rows, $diff_count++);
425
+			}
414 426
 		} elseif ( $diff_count > 0 ) {
415 427
 			$diff_count = -1 * $diff_count;
416
-			while ( $diff_count < 0 )
417
-				array_push($final_rows, $diff_count++);
428
+			while ( $diff_count < 0 ) {
429
+							array_push($final_rows, $diff_count++);
430
+			}
418 431
 		}
419 432
 
420 433
 		return array($orig_matches, $final_matches, $orig_rows, $final_rows);
@@ -438,8 +451,9 @@  discard block
 block discarded – undo
438 451
 		$difference = array_sum( array_map( array($this, 'difference'), $chars1, $chars2 ) );
439 452
 
440 453
 		// $string1 has zero length? Odd. Give huge penalty by not dividing.
441
-		if ( !$string1 )
442
-			return $difference;
454
+		if ( !$string1 ) {
455
+					return $difference;
456
+		}
443 457
 
444 458
 		// Return distance per character (of string1).
445 459
 		return $difference / strlen($string1);
Please login to merge, or discard this patch.
src/wp-includes/comment.php 3 patches
Doc Comments   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -796,7 +796,7 @@  discard block
 block discarded – undo
796 796
  * @param bool   $avoid_die When true, a disallowed comment will result in the function
797 797
  *                          returning a WP_Error object, rather than executing wp_die().
798 798
  *                          Default false.
799
- * @return bool Whether comment flooding is occurring.
799
+ * @return boolean|null Whether comment flooding is occurring.
800 800
  */
801 801
 function wp_check_comment_flood( $is_flood, $ip, $email, $date, $avoid_die = false ) {
802 802
 
@@ -1636,7 +1636,7 @@  discard block
 block discarded – undo
1636 1636
  *
1637 1637
  * @since 2.0.4
1638 1638
  *
1639
- * @return array Comment author, email, url respectively.
1639
+ * @return string Comment author, email, url respectively.
1640 1640
  */
1641 1641
 function wp_get_current_commenter() {
1642 1642
 	// Cookies should already be sanitized.
@@ -2830,7 +2830,7 @@  discard block
 block discarded – undo
2830 2830
  *
2831 2831
  * @param WP_Post  $posts Post data object.
2832 2832
  * @param WP_Query $query Query object.
2833
- * @return array
2833
+ * @return WP_Post
2834 2834
  */
2835 2835
 function _close_comments_for_old_posts( $posts, $query ) {
2836 2836
 	if ( empty( $posts ) || ! $query->is_singular() || ! get_option( 'close_comments_for_old_posts' ) )
Please login to merge, or discard this patch.
Spacing   +566 added lines, -566 removed lines patch added patch discarded remove patch
@@ -40,15 +40,15 @@  discard block
 block discarded – undo
40 40
 	global $wpdb;
41 41
 
42 42
 	// If manual moderation is enabled, skip all checks and return false.
43
-	if ( 1 == get_option('comment_moderation') )
43
+	if (1 == get_option('comment_moderation'))
44 44
 		return false;
45 45
 
46 46
 	/** This filter is documented in wp-includes/comment-template.php */
47
-	$comment = apply_filters( 'comment_text', $comment, null, array() );
47
+	$comment = apply_filters('comment_text', $comment, null, array());
48 48
 
49 49
 	// Check for the number of external links if a max allowed number is set.
50
-	if ( $max_links = get_option( 'comment_max_links' ) ) {
51
-		$num_links = preg_match_all( '/<a [^>]*href/i', $comment, $out );
50
+	if ($max_links = get_option('comment_max_links')) {
51
+		$num_links = preg_match_all('/<a [^>]*href/i', $comment, $out);
52 52
 
53 53
 		/**
54 54
 		 * Filters the number of links found in a comment.
@@ -60,27 +60,27 @@  discard block
 block discarded – undo
60 60
 		 * @param string $url       Comment author's URL. Included in allowed links total.
61 61
 		 * @param string $comment   Content of the comment.
62 62
 		 */
63
-		$num_links = apply_filters( 'comment_max_links_url', $num_links, $url, $comment );
63
+		$num_links = apply_filters('comment_max_links_url', $num_links, $url, $comment);
64 64
 
65 65
 		/*
66 66
 		 * If the number of links in the comment exceeds the allowed amount,
67 67
 		 * fail the check by returning false.
68 68
 		 */
69
-		if ( $num_links >= $max_links )
69
+		if ($num_links >= $max_links)
70 70
 			return false;
71 71
 	}
72 72
 
73 73
 	$mod_keys = trim(get_option('moderation_keys'));
74 74
 
75 75
 	// If moderation 'keys' (keywords) are set, process them.
76
-	if ( !empty($mod_keys) ) {
77
-		$words = explode("\n", $mod_keys );
76
+	if ( ! empty($mod_keys)) {
77
+		$words = explode("\n", $mod_keys);
78 78
 
79
-		foreach ( (array) $words as $word) {
79
+		foreach ((array) $words as $word) {
80 80
 			$word = trim($word);
81 81
 
82 82
 			// Skip empty lines.
83
-			if ( empty($word) )
83
+			if (empty($word))
84 84
 				continue;
85 85
 
86 86
 			/*
@@ -94,12 +94,12 @@  discard block
 block discarded – undo
94 94
 			 * fail the check for the given field by returning false.
95 95
 			 */
96 96
 			$pattern = "#$word#i";
97
-			if ( preg_match($pattern, $author) ) return false;
98
-			if ( preg_match($pattern, $email) ) return false;
99
-			if ( preg_match($pattern, $url) ) return false;
100
-			if ( preg_match($pattern, $comment) ) return false;
101
-			if ( preg_match($pattern, $user_ip) ) return false;
102
-			if ( preg_match($pattern, $user_agent) ) return false;
97
+			if (preg_match($pattern, $author)) return false;
98
+			if (preg_match($pattern, $email)) return false;
99
+			if (preg_match($pattern, $url)) return false;
100
+			if (preg_match($pattern, $comment)) return false;
101
+			if (preg_match($pattern, $user_ip)) return false;
102
+			if (preg_match($pattern, $user_agent)) return false;
103 103
 		}
104 104
 	}
105 105
 
@@ -110,17 +110,17 @@  discard block
 block discarded – undo
110 110
 	 * as well as whether there are any moderation keywords (if set) present in the author
111 111
 	 * email address. If both checks pass, return true. Otherwise, return false.
112 112
 	 */
113
-	if ( 1 == get_option('comment_whitelist')) {
114
-		if ( 'trackback' != $comment_type && 'pingback' != $comment_type && $author != '' && $email != '' ) {
115
-			$comment_user = get_user_by( 'email', wp_unslash( $email ) );
116
-			if ( ! empty( $comment_user->ID ) ) {
117
-				$ok_to_comment = $wpdb->get_var( $wpdb->prepare( "SELECT comment_approved FROM $wpdb->comments WHERE user_id = %d AND comment_approved = '1' LIMIT 1", $comment_user->ID ) );
113
+	if (1 == get_option('comment_whitelist')) {
114
+		if ('trackback' != $comment_type && 'pingback' != $comment_type && $author != '' && $email != '') {
115
+			$comment_user = get_user_by('email', wp_unslash($email));
116
+			if ( ! empty($comment_user->ID)) {
117
+				$ok_to_comment = $wpdb->get_var($wpdb->prepare("SELECT comment_approved FROM $wpdb->comments WHERE user_id = %d AND comment_approved = '1' LIMIT 1", $comment_user->ID));
118 118
 			} else {
119 119
 				// expected_slashed ($author, $email)
120
-				$ok_to_comment = $wpdb->get_var( $wpdb->prepare( "SELECT comment_approved FROM $wpdb->comments WHERE comment_author = %s AND comment_author_email = %s and comment_approved = '1' LIMIT 1", $author, $email ) );
120
+				$ok_to_comment = $wpdb->get_var($wpdb->prepare("SELECT comment_approved FROM $wpdb->comments WHERE comment_author = %s AND comment_author_email = %s and comment_approved = '1' LIMIT 1", $author, $email));
121 121
 			}
122
-			if ( ( 1 == $ok_to_comment ) &&
123
-				( empty($mod_keys) || false === strpos( $email, $mod_keys) ) )
122
+			if ((1 == $ok_to_comment) &&
123
+				(empty($mod_keys) || false === strpos($email, $mod_keys)))
124 124
 					return true;
125 125
 			else
126 126
 				return false;
@@ -142,8 +142,8 @@  discard block
 block discarded – undo
142 142
  * @return int|array $comments The approved comments, or number of comments if `$count`
143 143
  *                             argument is true.
144 144
  */
145
-function get_approved_comments( $post_id, $args = array() ) {
146
-	if ( ! $post_id ) {
145
+function get_approved_comments($post_id, $args = array()) {
146
+	if ( ! $post_id) {
147 147
 		return array();
148 148
 	}
149 149
 
@@ -152,10 +152,10 @@  discard block
 block discarded – undo
152 152
 		'post_id' => $post_id,
153 153
 		'order'   => 'ASC',
154 154
 	);
155
-	$r = wp_parse_args( $args, $defaults );
155
+	$r = wp_parse_args($args, $defaults);
156 156
 
157 157
 	$query = new WP_Comment_Query;
158
-	return $query->query( $r );
158
+	return $query->query($r);
159 159
 }
160 160
 
161 161
 /**
@@ -174,20 +174,20 @@  discard block
 block discarded – undo
174 174
  *                                       a WP_Comment object, an associative array, or a numeric array, respectively. Default OBJECT.
175 175
  * @return WP_Comment|array|null Depends on $output value.
176 176
  */
177
-function get_comment( &$comment = null, $output = OBJECT ) {
178
-	if ( empty( $comment ) && isset( $GLOBALS['comment'] ) ) {
177
+function get_comment(&$comment = null, $output = OBJECT) {
178
+	if (empty($comment) && isset($GLOBALS['comment'])) {
179 179
 		$comment = $GLOBALS['comment'];
180 180
 	}
181 181
 
182
-	if ( $comment instanceof WP_Comment ) {
182
+	if ($comment instanceof WP_Comment) {
183 183
 		$_comment = $comment;
184
-	} elseif ( is_object( $comment ) ) {
185
-		$_comment = new WP_Comment( $comment );
184
+	} elseif (is_object($comment)) {
185
+		$_comment = new WP_Comment($comment);
186 186
 	} else {
187
-		$_comment = WP_Comment::get_instance( $comment );
187
+		$_comment = WP_Comment::get_instance($comment);
188 188
 	}
189 189
 
190
-	if ( ! $_comment ) {
190
+	if ( ! $_comment) {
191 191
 		return null;
192 192
 	}
193 193
 
@@ -198,14 +198,14 @@  discard block
 block discarded – undo
198 198
 	 *
199 199
 	 * @param mixed $_comment Comment data.
200 200
 	 */
201
-	$_comment = apply_filters( 'get_comment', $_comment );
201
+	$_comment = apply_filters('get_comment', $_comment);
202 202
 
203
-	if ( $output == OBJECT ) {
203
+	if ($output == OBJECT) {
204 204
 		return $_comment;
205
-	} elseif ( $output == ARRAY_A ) {
205
+	} elseif ($output == ARRAY_A) {
206 206
 		return $_comment->to_array();
207
-	} elseif ( $output == ARRAY_N ) {
208
-		return array_values( $_comment->to_array() );
207
+	} elseif ($output == ARRAY_N) {
208
+		return array_values($_comment->to_array());
209 209
 	}
210 210
 	return $_comment;
211 211
 }
@@ -221,9 +221,9 @@  discard block
 block discarded – undo
221 221
  *                           for information on accepted arguments. Default empty.
222 222
  * @return int|array List of comments or number of found comments if `$count` argument is true.
223 223
  */
224
-function get_comments( $args = '' ) {
224
+function get_comments($args = '') {
225 225
 	$query = new WP_Comment_Query;
226
-	return $query->query( $args );
226
+	return $query->query($args);
227 227
 }
228 228
 
229 229
 /**
@@ -238,10 +238,10 @@  discard block
 block discarded – undo
238 238
  */
239 239
 function get_comment_statuses() {
240 240
 	$status = array(
241
-		'hold'		=> __( 'Unapproved' ),
242
-		'approve'	=> _x( 'Approved', 'comment status' ),
243
-		'spam'		=> _x( 'Spam', 'comment status' ),
244
-		'trash'		=> _x( 'Trash', 'comment status' ),
241
+		'hold'		=> __('Unapproved'),
242
+		'approve'	=> _x('Approved', 'comment status'),
243
+		'spam'		=> _x('Spam', 'comment status'),
244
+		'trash'		=> _x('Trash', 'comment status'),
245 245
 	);
246 246
 
247 247
 	return $status;
@@ -256,8 +256,8 @@  discard block
 block discarded – undo
256 256
  * @param string $comment_type Optional. Comment type. Default 'comment'.
257 257
  * @return string Expected return value is 'open' or 'closed'.
258 258
  */
259
-function get_default_comment_status( $post_type = 'post', $comment_type = 'comment' ) {
260
-	switch ( $comment_type ) {
259
+function get_default_comment_status($post_type = 'post', $comment_type = 'comment') {
260
+	switch ($comment_type) {
261 261
 		case 'pingback' :
262 262
 		case 'trackback' :
263 263
 			$supports = 'trackbacks';
@@ -269,10 +269,10 @@  discard block
 block discarded – undo
269 269
 	}
270 270
 
271 271
 	// Set the status.
272
-	if ( 'page' === $post_type ) {
272
+	if ('page' === $post_type) {
273 273
 		$status = 'closed';
274
-	} elseif ( post_type_supports( $post_type, $supports ) ) {
275
-		$status = get_option( "default_{$option}_status" );
274
+	} elseif (post_type_supports($post_type, $supports)) {
275
+		$status = get_option("default_{$option}_status");
276 276
 	} else {
277 277
 		$status = 'closed';
278 278
 	}
@@ -287,7 +287,7 @@  discard block
 block discarded – undo
287 287
 	 * @param string $post_type    Post type. Default is `post`.
288 288
 	 * @param string $comment_type Type of comment. Default is `comment`.
289 289
 	 */
290
-	return apply_filters( 'get_default_comment_status' , $status, $post_type, $comment_type );
290
+	return apply_filters('get_default_comment_status', $status, $post_type, $comment_type);
291 291
 }
292 292
 
293 293
 /**
@@ -302,33 +302,33 @@  discard block
 block discarded – undo
302 302
  * @param string $timezone Which timezone to use in reference to 'gmt', 'blog', or 'server' locations.
303 303
  * @return string|false Last comment modified date on success, false on failure.
304 304
  */
305
-function get_lastcommentmodified( $timezone = 'server' ) {
305
+function get_lastcommentmodified($timezone = 'server') {
306 306
 	global $wpdb;
307 307
 
308
-	$timezone = strtolower( $timezone );
308
+	$timezone = strtolower($timezone);
309 309
 	$key = "lastcommentmodified:$timezone";
310 310
 
311
-	$comment_modified_date = wp_cache_get( $key, 'timeinfo' );
312
-	if ( false !== $comment_modified_date ) {
311
+	$comment_modified_date = wp_cache_get($key, 'timeinfo');
312
+	if (false !== $comment_modified_date) {
313 313
 		return $comment_modified_date;
314 314
 	}
315 315
 
316
-	switch ( $timezone ) {
316
+	switch ($timezone) {
317 317
 		case 'gmt':
318
-			$comment_modified_date = $wpdb->get_var( "SELECT comment_date_gmt FROM $wpdb->comments WHERE comment_approved = '1' ORDER BY comment_date_gmt DESC LIMIT 1" );
318
+			$comment_modified_date = $wpdb->get_var("SELECT comment_date_gmt FROM $wpdb->comments WHERE comment_approved = '1' ORDER BY comment_date_gmt DESC LIMIT 1");
319 319
 			break;
320 320
 		case 'blog':
321
-			$comment_modified_date = $wpdb->get_var( "SELECT comment_date FROM $wpdb->comments WHERE comment_approved = '1' ORDER BY comment_date_gmt DESC LIMIT 1" );
321
+			$comment_modified_date = $wpdb->get_var("SELECT comment_date FROM $wpdb->comments WHERE comment_approved = '1' ORDER BY comment_date_gmt DESC LIMIT 1");
322 322
 			break;
323 323
 		case 'server':
324
-			$add_seconds_server = date( 'Z' );
324
+			$add_seconds_server = date('Z');
325 325
 
326
-			$comment_modified_date = $wpdb->get_var( $wpdb->prepare( "SELECT DATE_ADD(comment_date_gmt, INTERVAL %s SECOND) FROM $wpdb->comments WHERE comment_approved = '1' ORDER BY comment_date_gmt DESC LIMIT 1", $add_seconds_server ) );
326
+			$comment_modified_date = $wpdb->get_var($wpdb->prepare("SELECT DATE_ADD(comment_date_gmt, INTERVAL %s SECOND) FROM $wpdb->comments WHERE comment_approved = '1' ORDER BY comment_date_gmt DESC LIMIT 1", $add_seconds_server));
327 327
 			break;
328 328
 	}
329 329
 
330
-	if ( $comment_modified_date ) {
331
-		wp_cache_set( $key, $comment_modified_date, 'timeinfo' );
330
+	if ($comment_modified_date) {
331
+		wp_cache_set($key, $comment_modified_date, 'timeinfo');
332 332
 
333 333
 		return $comment_modified_date;
334 334
 	}
@@ -349,13 +349,13 @@  discard block
 block discarded – undo
349 349
  * @param int $post_id Optional. Comment amount in post if > 0, else total comments blog wide.
350 350
  * @return array The amount of spam, approved, awaiting moderation, and total comments.
351 351
  */
352
-function get_comment_count( $post_id = 0 ) {
352
+function get_comment_count($post_id = 0) {
353 353
 	global $wpdb;
354 354
 
355 355
 	$post_id = (int) $post_id;
356 356
 
357 357
 	$where = '';
358
-	if ( $post_id > 0 ) {
358
+	if ($post_id > 0) {
359 359
 		$where = $wpdb->prepare("WHERE comment_post_ID = %d", $post_id);
360 360
 	}
361 361
 
@@ -376,8 +376,8 @@  discard block
 block discarded – undo
376 376
 		'all'                 => 0,
377 377
 	);
378 378
 
379
-	foreach ( $totals as $row ) {
380
-		switch ( $row['comment_approved'] ) {
379
+	foreach ($totals as $row) {
380
+		switch ($row['comment_approved']) {
381 381
 			case 'trash':
382 382
 				$comment_count['trash'] = $row['total'];
383 383
 				break;
@@ -489,20 +489,20 @@  discard block
 block discarded – undo
489 489
  *
490 490
  * @param array $comments Array of comment objects.
491 491
  */
492
-function wp_queue_comments_for_comment_meta_lazyload( $comments ) {
492
+function wp_queue_comments_for_comment_meta_lazyload($comments) {
493 493
 	// Don't use `wp_list_pluck()` to avoid by-reference manipulation.
494 494
 	$comment_ids = array();
495
-	if ( is_array( $comments ) ) {
496
-		foreach ( $comments as $comment ) {
497
-			if ( $comment instanceof WP_Comment ) {
495
+	if (is_array($comments)) {
496
+		foreach ($comments as $comment) {
497
+			if ($comment instanceof WP_Comment) {
498 498
 				$comment_ids[] = $comment->comment_ID;
499 499
 			}
500 500
 		}
501 501
 	}
502 502
 
503
-	if ( $comment_ids ) {
503
+	if ($comment_ids) {
504 504
 		$lazyloader = wp_metadata_lazyloader();
505
-		$lazyloader->queue_objects( 'comment', $comment_ids );
505
+		$lazyloader->queue_objects('comment', $comment_ids);
506 506
 	}
507 507
 }
508 508
 
@@ -516,7 +516,7 @@  discard block
 block discarded – undo
516 516
  * @since 3.4.0
517 517
  */
518 518
 function wp_set_comment_cookies($comment, $user) {
519
-	if ( $user->exists() )
519
+	if ($user->exists())
520 520
 		return;
521 521
 
522 522
 	/**
@@ -526,11 +526,11 @@  discard block
 block discarded – undo
526 526
 	 *
527 527
 	 * @param int $seconds Comment cookie lifetime. Default 30000000.
528 528
 	 */
529
-	$comment_cookie_lifetime = apply_filters( 'comment_cookie_lifetime', 30000000 );
530
-	$secure = ( 'https' === parse_url( home_url(), PHP_URL_SCHEME ) );
531
-	setcookie( 'comment_author_' . COOKIEHASH, $comment->comment_author, time() + $comment_cookie_lifetime, COOKIEPATH, COOKIE_DOMAIN, $secure );
532
-	setcookie( 'comment_author_email_' . COOKIEHASH, $comment->comment_author_email, time() + $comment_cookie_lifetime, COOKIEPATH, COOKIE_DOMAIN, $secure );
533
-	setcookie( 'comment_author_url_' . COOKIEHASH, esc_url($comment->comment_author_url), time() + $comment_cookie_lifetime, COOKIEPATH, COOKIE_DOMAIN, $secure );
529
+	$comment_cookie_lifetime = apply_filters('comment_cookie_lifetime', 30000000);
530
+	$secure = ('https' === parse_url(home_url(), PHP_URL_SCHEME));
531
+	setcookie('comment_author_'.COOKIEHASH, $comment->comment_author, time() + $comment_cookie_lifetime, COOKIEPATH, COOKIE_DOMAIN, $secure);
532
+	setcookie('comment_author_email_'.COOKIEHASH, $comment->comment_author_email, time() + $comment_cookie_lifetime, COOKIEPATH, COOKIE_DOMAIN, $secure);
533
+	setcookie('comment_author_url_'.COOKIEHASH, esc_url($comment->comment_author_url), time() + $comment_cookie_lifetime, COOKIEPATH, COOKIE_DOMAIN, $secure);
534 534
 }
535 535
 
536 536
 /**
@@ -542,7 +542,7 @@  discard block
 block discarded – undo
542 542
  * @since 2.0.4
543 543
  */
544 544
 function sanitize_comment_cookies() {
545
-	if ( isset( $_COOKIE['comment_author_' . COOKIEHASH] ) ) {
545
+	if (isset($_COOKIE['comment_author_'.COOKIEHASH])) {
546 546
 		/**
547 547
 		 * Filters the comment author's name cookie before it is set.
548 548
 		 *
@@ -553,13 +553,13 @@  discard block
 block discarded – undo
553 553
 		 *
554 554
 		 * @param string $author_cookie The comment author name cookie.
555 555
 		 */
556
-		$comment_author = apply_filters( 'pre_comment_author_name', $_COOKIE['comment_author_' . COOKIEHASH] );
556
+		$comment_author = apply_filters('pre_comment_author_name', $_COOKIE['comment_author_'.COOKIEHASH]);
557 557
 		$comment_author = wp_unslash($comment_author);
558 558
 		$comment_author = esc_attr($comment_author);
559
-		$_COOKIE['comment_author_' . COOKIEHASH] = $comment_author;
559
+		$_COOKIE['comment_author_'.COOKIEHASH] = $comment_author;
560 560
 	}
561 561
 
562
-	if ( isset( $_COOKIE['comment_author_email_' . COOKIEHASH] ) ) {
562
+	if (isset($_COOKIE['comment_author_email_'.COOKIEHASH])) {
563 563
 		/**
564 564
 		 * Filters the comment author's email cookie before it is set.
565 565
 		 *
@@ -570,13 +570,13 @@  discard block
 block discarded – undo
570 570
 		 *
571 571
 		 * @param string $author_email_cookie The comment author email cookie.
572 572
 		 */
573
-		$comment_author_email = apply_filters( 'pre_comment_author_email', $_COOKIE['comment_author_email_' . COOKIEHASH] );
573
+		$comment_author_email = apply_filters('pre_comment_author_email', $_COOKIE['comment_author_email_'.COOKIEHASH]);
574 574
 		$comment_author_email = wp_unslash($comment_author_email);
575 575
 		$comment_author_email = esc_attr($comment_author_email);
576 576
 		$_COOKIE['comment_author_email_'.COOKIEHASH] = $comment_author_email;
577 577
 	}
578 578
 
579
-	if ( isset( $_COOKIE['comment_author_url_' . COOKIEHASH] ) ) {
579
+	if (isset($_COOKIE['comment_author_url_'.COOKIEHASH])) {
580 580
 		/**
581 581
 		 * Filters the comment author's URL cookie before it is set.
582 582
 		 *
@@ -587,7 +587,7 @@  discard block
 block discarded – undo
587 587
 		 *
588 588
 		 * @param string $author_url_cookie The comment author URL cookie.
589 589
 		 */
590
-		$comment_author_url = apply_filters( 'pre_comment_author_url', $_COOKIE['comment_author_url_' . COOKIEHASH] );
590
+		$comment_author_url = apply_filters('pre_comment_author_url', $_COOKIE['comment_author_url_'.COOKIEHASH]);
591 591
 		$comment_author_url = wp_unslash($comment_author_url);
592 592
 		$_COOKIE['comment_author_url_'.COOKIEHASH] = $comment_author_url;
593 593
 	}
@@ -609,29 +609,29 @@  discard block
 block discarded – undo
609 609
  * @return int|string|WP_Error Allowed comments return the approval status (0|1|'spam').
610 610
  *                             If `$avoid_die` is true, disallowed comments return a WP_Error.
611 611
  */
612
-function wp_allow_comment( $commentdata, $avoid_die = false ) {
612
+function wp_allow_comment($commentdata, $avoid_die = false) {
613 613
 	global $wpdb;
614 614
 
615 615
 	// Simple duplicate check
616 616
 	// expected_slashed ($comment_post_ID, $comment_author, $comment_author_email, $comment_content)
617 617
 	$dupe = $wpdb->prepare(
618 618
 		"SELECT comment_ID FROM $wpdb->comments WHERE comment_post_ID = %d AND comment_parent = %s AND comment_approved != 'trash' AND ( comment_author = %s ",
619
-		wp_unslash( $commentdata['comment_post_ID'] ),
620
-		wp_unslash( $commentdata['comment_parent'] ),
621
-		wp_unslash( $commentdata['comment_author'] )
619
+		wp_unslash($commentdata['comment_post_ID']),
620
+		wp_unslash($commentdata['comment_parent']),
621
+		wp_unslash($commentdata['comment_author'])
622 622
 	);
623
-	if ( $commentdata['comment_author_email'] ) {
623
+	if ($commentdata['comment_author_email']) {
624 624
 		$dupe .= $wpdb->prepare(
625 625
 			"AND comment_author_email = %s ",
626
-			wp_unslash( $commentdata['comment_author_email'] )
626
+			wp_unslash($commentdata['comment_author_email'])
627 627
 		);
628 628
 	}
629 629
 	$dupe .= $wpdb->prepare(
630 630
 		") AND comment_content = %s LIMIT 1",
631
-		wp_unslash( $commentdata['comment_content'] )
631
+		wp_unslash($commentdata['comment_content'])
632 632
 	);
633 633
 
634
-	$dupe_id = $wpdb->get_var( $dupe );
634
+	$dupe_id = $wpdb->get_var($dupe);
635 635
 
636 636
 	/**
637 637
 	 * Filters the ID, if any, of the duplicate comment found when creating a new comment.
@@ -643,9 +643,9 @@  discard block
 block discarded – undo
643 643
 	 * @param int   $dupe_id     ID of the comment identified as a duplicate.
644 644
 	 * @param array $commentdata Data for the comment being created.
645 645
 	 */
646
-	$dupe_id = apply_filters( 'duplicate_comment_id', $dupe_id, $commentdata );
646
+	$dupe_id = apply_filters('duplicate_comment_id', $dupe_id, $commentdata);
647 647
 
648
-	if ( $dupe_id ) {
648
+	if ($dupe_id) {
649 649
 		/**
650 650
 		 * Fires immediately after a duplicate comment is detected.
651 651
 		 *
@@ -653,15 +653,15 @@  discard block
 block discarded – undo
653 653
 		 *
654 654
 		 * @param array $commentdata Comment data.
655 655
 		 */
656
-		do_action( 'comment_duplicate_trigger', $commentdata );
657
-		if ( true === $avoid_die ) {
658
-			return new WP_Error( 'comment_duplicate', __( 'Duplicate comment detected; it looks as though you&#8217;ve already said that!' ), 409 );
656
+		do_action('comment_duplicate_trigger', $commentdata);
657
+		if (true === $avoid_die) {
658
+			return new WP_Error('comment_duplicate', __('Duplicate comment detected; it looks as though you&#8217;ve already said that!'), 409);
659 659
 		} else {
660
-			if ( wp_doing_ajax() ) {
661
-				die( __('Duplicate comment detected; it looks as though you&#8217;ve already said that!') );
660
+			if (wp_doing_ajax()) {
661
+				die(__('Duplicate comment detected; it looks as though you&#8217;ve already said that!'));
662 662
 			}
663 663
 
664
-			wp_die( __( 'Duplicate comment detected; it looks as though you&#8217;ve already said that!' ), 409 );
664
+			wp_die(__('Duplicate comment detected; it looks as though you&#8217;ve already said that!'), 409);
665 665
 		}
666 666
 	}
667 667
 
@@ -710,24 +710,24 @@  discard block
 block discarded – undo
710 710
 		$avoid_die
711 711
 	);
712 712
 
713
-	if ( $is_flood ) {
714
-		return new WP_Error( 'comment_flood', __( 'You are posting comments too quickly. Slow down.' ), 429 );
713
+	if ($is_flood) {
714
+		return new WP_Error('comment_flood', __('You are posting comments too quickly. Slow down.'), 429);
715 715
 	}
716 716
 
717
-	if ( ! empty( $commentdata['user_id'] ) ) {
718
-		$user = get_userdata( $commentdata['user_id'] );
719
-		$post_author = $wpdb->get_var( $wpdb->prepare(
717
+	if ( ! empty($commentdata['user_id'])) {
718
+		$user = get_userdata($commentdata['user_id']);
719
+		$post_author = $wpdb->get_var($wpdb->prepare(
720 720
 			"SELECT post_author FROM $wpdb->posts WHERE ID = %d LIMIT 1",
721 721
 			$commentdata['comment_post_ID']
722
-		) );
722
+		));
723 723
 	}
724 724
 
725
-	if ( isset( $user ) && ( $commentdata['user_id'] == $post_author || $user->has_cap( 'moderate_comments' ) ) ) {
725
+	if (isset($user) && ($commentdata['user_id'] == $post_author || $user->has_cap('moderate_comments'))) {
726 726
 		// The author and the admins get respect.
727 727
 		$approved = 1;
728 728
 	} else {
729 729
 		// Everyone else's comments will be checked.
730
-		if ( check_comment(
730
+		if (check_comment(
731 731
 			$commentdata['comment_author'],
732 732
 			$commentdata['comment_author_email'],
733 733
 			$commentdata['comment_author_url'],
@@ -735,20 +735,20 @@  discard block
 block discarded – undo
735 735
 			$commentdata['comment_author_IP'],
736 736
 			$commentdata['comment_agent'],
737 737
 			$commentdata['comment_type']
738
-		) ) {
738
+		)) {
739 739
 			$approved = 1;
740 740
 		} else {
741 741
 			$approved = 0;
742 742
 		}
743 743
 
744
-		if ( wp_blacklist_check(
744
+		if (wp_blacklist_check(
745 745
 			$commentdata['comment_author'],
746 746
 			$commentdata['comment_author_email'],
747 747
 			$commentdata['comment_author_url'],
748 748
 			$commentdata['comment_content'],
749 749
 			$commentdata['comment_author_IP'],
750 750
 			$commentdata['comment_agent']
751
-		) ) {
751
+		)) {
752 752
 			$approved = EMPTY_TRASH_DAYS ? 'trash' : 'spam';
753 753
 		}
754 754
 	}
@@ -761,7 +761,7 @@  discard block
 block discarded – undo
761 761
 	 * @param bool|string $approved    The approval status. Accepts 1, 0, or 'spam'.
762 762
 	 * @param array       $commentdata Comment data.
763 763
 	 */
764
-	$approved = apply_filters( 'pre_comment_approved', $approved, $commentdata );
764
+	$approved = apply_filters('pre_comment_approved', $approved, $commentdata);
765 765
 	return $approved;
766 766
 }
767 767
 
@@ -776,7 +776,7 @@  discard block
 block discarded – undo
776 776
  * @since 4.7.0 Converted to be an add_filter() wrapper.
777 777
  */
778 778
 function check_comment_flood_db() {
779
-	add_filter( 'wp_is_comment_flood', 'wp_check_comment_flood', 10, 5 );
779
+	add_filter('wp_is_comment_flood', 'wp_check_comment_flood', 10, 5);
780 780
 }
781 781
 
782 782
 /**
@@ -798,22 +798,22 @@  discard block
 block discarded – undo
798 798
  *                          Default false.
799 799
  * @return bool Whether comment flooding is occurring.
800 800
  */
801
-function wp_check_comment_flood( $is_flood, $ip, $email, $date, $avoid_die = false ) {
801
+function wp_check_comment_flood($is_flood, $ip, $email, $date, $avoid_die = false) {
802 802
 
803 803
 	global $wpdb;
804 804
 
805 805
 	// Another callback has declared a flood. Trust it.
806
-	if ( true === $is_flood ) {
806
+	if (true === $is_flood) {
807 807
 		return $is_flood;
808 808
 	}
809 809
 
810 810
 	// don't throttle admins or moderators
811
-	if ( current_user_can( 'manage_options' ) || current_user_can( 'moderate_comments' ) ) {
811
+	if (current_user_can('manage_options') || current_user_can('moderate_comments')) {
812 812
 		return false;
813 813
 	}
814
-	$hour_ago = gmdate( 'Y-m-d H:i:s', time() - HOUR_IN_SECONDS );
814
+	$hour_ago = gmdate('Y-m-d H:i:s', time() - HOUR_IN_SECONDS);
815 815
 
816
-	if ( is_user_logged_in() ) {
816
+	if (is_user_logged_in()) {
817 817
 		$user = get_current_user_id();
818 818
 		$check_column = '`user_id`';
819 819
 	} else {
@@ -827,8 +827,8 @@  discard block
 block discarded – undo
827 827
 		$user,
828 828
 		$email
829 829
 	);
830
-	$lasttime = $wpdb->get_var( $sql );
831
-	if ( $lasttime ) {
830
+	$lasttime = $wpdb->get_var($sql);
831
+	if ($lasttime) {
832 832
 		$time_lastcomment = mysql2date('U', $lasttime, false);
833 833
 		$time_newcomment  = mysql2date('U', $date, false);
834 834
 		/**
@@ -840,8 +840,8 @@  discard block
 block discarded – undo
840 840
 		 * @param int  $time_lastcomment Timestamp of when the last comment was posted.
841 841
 		 * @param int  $time_newcomment  Timestamp of when the new comment was posted.
842 842
 		 */
843
-		$flood_die = apply_filters( 'comment_flood_filter', false, $time_lastcomment, $time_newcomment );
844
-		if ( $flood_die ) {
843
+		$flood_die = apply_filters('comment_flood_filter', false, $time_lastcomment, $time_newcomment);
844
+		if ($flood_die) {
845 845
 			/**
846 846
 			 * Fires before the comment flood message is triggered.
847 847
 			 *
@@ -850,15 +850,15 @@  discard block
 block discarded – undo
850 850
 			 * @param int $time_lastcomment Timestamp of when the last comment was posted.
851 851
 			 * @param int $time_newcomment  Timestamp of when the new comment was posted.
852 852
 			 */
853
-			do_action( 'comment_flood_trigger', $time_lastcomment, $time_newcomment );
854
-			if ( true === $avoid_die ) {
853
+			do_action('comment_flood_trigger', $time_lastcomment, $time_newcomment);
854
+			if (true === $avoid_die) {
855 855
 				return true;
856 856
 			} else {
857
-				if ( wp_doing_ajax() ) {
858
-					die( __('You are posting comments too quickly. Slow down.') );
857
+				if (wp_doing_ajax()) {
858
+					die(__('You are posting comments too quickly. Slow down.'));
859 859
 				}
860 860
 
861
-				wp_die( __( 'You are posting comments too quickly. Slow down.' ), 429 );
861
+				wp_die(__('You are posting comments too quickly. Slow down.'), 429);
862 862
 			}
863 863
 		}
864 864
 	}
@@ -877,12 +877,12 @@  discard block
 block discarded – undo
877 877
 function separate_comments(&$comments) {
878 878
 	$comments_by_type = array('comment' => array(), 'trackback' => array(), 'pingback' => array(), 'pings' => array());
879 879
 	$count = count($comments);
880
-	for ( $i = 0; $i < $count; $i++ ) {
880
+	for ($i = 0; $i < $count; $i++) {
881 881
 		$type = $comments[$i]->comment_type;
882
-		if ( empty($type) )
882
+		if (empty($type))
883 883
 			$type = 'comment';
884 884
 		$comments_by_type[$type][] = &$comments[$i];
885
-		if ( 'trackback' == $type || 'pingback' == $type )
885
+		if ('trackback' == $type || 'pingback' == $type)
886 886
 			$comments_by_type['pings'][] = &$comments[$i];
887 887
 	}
888 888
 
@@ -903,37 +903,37 @@  discard block
 block discarded – undo
903 903
  * @param bool  $threaded Optional control over flat or threaded comments.
904 904
  * @return int Number of comment pages.
905 905
  */
906
-function get_comment_pages_count( $comments = null, $per_page = null, $threaded = null ) {
906
+function get_comment_pages_count($comments = null, $per_page = null, $threaded = null) {
907 907
 	global $wp_query;
908 908
 
909
-	if ( null === $comments && null === $per_page && null === $threaded && !empty($wp_query->max_num_comment_pages) )
909
+	if (null === $comments && null === $per_page && null === $threaded && ! empty($wp_query->max_num_comment_pages))
910 910
 		return $wp_query->max_num_comment_pages;
911 911
 
912
-	if ( ( ! $comments || ! is_array( $comments ) ) && ! empty( $wp_query->comments )  )
912
+	if (( ! $comments || ! is_array($comments)) && ! empty($wp_query->comments))
913 913
 		$comments = $wp_query->comments;
914 914
 
915
-	if ( empty($comments) )
915
+	if (empty($comments))
916 916
 		return 0;
917 917
 
918
-	if ( ! get_option( 'page_comments' ) ) {
918
+	if ( ! get_option('page_comments')) {
919 919
 		return 1;
920 920
 	}
921 921
 
922
-	if ( !isset($per_page) )
922
+	if ( ! isset($per_page))
923 923
 		$per_page = (int) get_query_var('comments_per_page');
924
-	if ( 0 === $per_page )
924
+	if (0 === $per_page)
925 925
 		$per_page = (int) get_option('comments_per_page');
926
-	if ( 0 === $per_page )
926
+	if (0 === $per_page)
927 927
 		return 1;
928 928
 
929
-	if ( !isset($threaded) )
929
+	if ( ! isset($threaded))
930 930
 		$threaded = get_option('thread_comments');
931 931
 
932
-	if ( $threaded ) {
932
+	if ($threaded) {
933 933
 		$walker = new Walker_Comment;
934
-		$count = ceil( $walker->get_number_of_root_elements( $comments ) / $per_page );
934
+		$count = ceil($walker->get_number_of_root_elements($comments) / $per_page);
935 935
 	} else {
936
-		$count = ceil( count( $comments ) / $per_page );
936
+		$count = ceil(count($comments) / $per_page);
937 937
 	}
938 938
 
939 939
 	return $count;
@@ -959,49 +959,49 @@  discard block
 block discarded – undo
959 959
  * } *
960 960
  * @return int|null Comment page number or null on error.
961 961
  */
962
-function get_page_of_comment( $comment_ID, $args = array() ) {
962
+function get_page_of_comment($comment_ID, $args = array()) {
963 963
 	global $wpdb;
964 964
 
965 965
 	$page = null;
966 966
 
967
-	if ( !$comment = get_comment( $comment_ID ) )
967
+	if ( ! $comment = get_comment($comment_ID))
968 968
 		return;
969 969
 
970
-	$defaults = array( 'type' => 'all', 'page' => '', 'per_page' => '', 'max_depth' => '' );
971
-	$args = wp_parse_args( $args, $defaults );
970
+	$defaults = array('type' => 'all', 'page' => '', 'per_page' => '', 'max_depth' => '');
971
+	$args = wp_parse_args($args, $defaults);
972 972
 	$original_args = $args;
973 973
 
974 974
 	// Order of precedence: 1. `$args['per_page']`, 2. 'comments_per_page' query_var, 3. 'comments_per_page' option.
975
-	if ( get_option( 'page_comments' ) ) {
976
-		if ( '' === $args['per_page'] ) {
977
-			$args['per_page'] = get_query_var( 'comments_per_page' );
975
+	if (get_option('page_comments')) {
976
+		if ('' === $args['per_page']) {
977
+			$args['per_page'] = get_query_var('comments_per_page');
978 978
 		}
979 979
 
980
-		if ( '' === $args['per_page'] ) {
981
-			$args['per_page'] = get_option( 'comments_per_page' );
980
+		if ('' === $args['per_page']) {
981
+			$args['per_page'] = get_option('comments_per_page');
982 982
 		}
983 983
 	}
984 984
 
985
-	if ( empty($args['per_page']) ) {
985
+	if (empty($args['per_page'])) {
986 986
 		$args['per_page'] = 0;
987 987
 		$args['page'] = 0;
988 988
 	}
989 989
 
990
-	if ( $args['per_page'] < 1 ) {
990
+	if ($args['per_page'] < 1) {
991 991
 		$page = 1;
992 992
 	}
993 993
 
994
-	if ( null === $page ) {
995
-		if ( '' === $args['max_depth'] ) {
996
-			if ( get_option('thread_comments') )
994
+	if (null === $page) {
995
+		if ('' === $args['max_depth']) {
996
+			if (get_option('thread_comments'))
997 997
 				$args['max_depth'] = get_option('thread_comments_depth');
998 998
 			else
999 999
 				$args['max_depth'] = -1;
1000 1000
 		}
1001 1001
 
1002 1002
 		// Find this comment's top level parent if threading is enabled
1003
-		if ( $args['max_depth'] > 1 && 0 != $comment->comment_parent )
1004
-			return get_page_of_comment( $comment->comment_parent, $args );
1003
+		if ($args['max_depth'] > 1 && 0 != $comment->comment_parent)
1004
+			return get_page_of_comment($comment->comment_parent, $args);
1005 1005
 
1006 1006
 		$comment_args = array(
1007 1007
 			'type'       => $args['type'],
@@ -1019,15 +1019,15 @@  discard block
 block discarded – undo
1019 1019
 		);
1020 1020
 
1021 1021
 		$comment_query = new WP_Comment_Query();
1022
-		$older_comment_count = $comment_query->query( $comment_args );
1022
+		$older_comment_count = $comment_query->query($comment_args);
1023 1023
 
1024 1024
 		// No older comments? Then it's page #1.
1025
-		if ( 0 == $older_comment_count ) {
1025
+		if (0 == $older_comment_count) {
1026 1026
 			$page = 1;
1027 1027
 
1028 1028
 		// Divide comments older than this one by comments per page to get this comment's page number
1029 1029
 		} else {
1030
-			$page = ceil( ( $older_comment_count + 1 ) / $args['per_page'] );
1030
+			$page = ceil(($older_comment_count + 1) / $args['per_page']);
1031 1031
 		}
1032 1032
 	}
1033 1033
 
@@ -1058,7 +1058,7 @@  discard block
 block discarded – undo
1058 1058
 	 * }
1059 1059
 	 * @param int $comment_ID ID of the comment.
1060 1060
 	 */
1061
-	return apply_filters( 'get_page_of_comment', (int) $page, $args, $original_args, $comment_ID );
1061
+	return apply_filters('get_page_of_comment', (int) $page, $args, $original_args, $comment_ID);
1062 1062
 }
1063 1063
 
1064 1064
 /**
@@ -1080,28 +1080,28 @@  discard block
 block discarded – undo
1080 1080
 		'comment_content'      => 65525,
1081 1081
 	);
1082 1082
 
1083
-	if ( $wpdb->is_mysql ) {
1084
-		foreach ( $lengths as $column => $length ) {
1085
-			$col_length = $wpdb->get_col_length( $wpdb->comments, $column );
1083
+	if ($wpdb->is_mysql) {
1084
+		foreach ($lengths as $column => $length) {
1085
+			$col_length = $wpdb->get_col_length($wpdb->comments, $column);
1086 1086
 			$max_length = 0;
1087 1087
 
1088 1088
 			// No point if we can't get the DB column lengths
1089
-			if ( is_wp_error( $col_length ) ) {
1089
+			if (is_wp_error($col_length)) {
1090 1090
 				break;
1091 1091
 			}
1092 1092
 
1093
-			if ( ! is_array( $col_length ) && (int) $col_length > 0 ) {
1093
+			if ( ! is_array($col_length) && (int) $col_length > 0) {
1094 1094
 				$max_length = (int) $col_length;
1095
-			} elseif ( is_array( $col_length ) && isset( $col_length['length'] ) && intval( $col_length['length'] ) > 0 ) {
1095
+			} elseif (is_array($col_length) && isset($col_length['length']) && intval($col_length['length']) > 0) {
1096 1096
 				$max_length = (int) $col_length['length'];
1097 1097
 
1098
-				if ( ! empty( $col_length['type'] ) && 'byte' === $col_length['type'] ) {
1098
+				if ( ! empty($col_length['type']) && 'byte' === $col_length['type']) {
1099 1099
 					$max_length = $max_length - 10;
1100 1100
 				}
1101 1101
 			}
1102 1102
 
1103
-			if ( $max_length > 0 ) {
1104
-				$lengths[ $column ] = $max_length;
1103
+			if ($max_length > 0) {
1104
+				$lengths[$column] = $max_length;
1105 1105
 			}
1106 1106
 		}
1107 1107
 	}
@@ -1113,7 +1113,7 @@  discard block
 block discarded – undo
1113 1113
 	 *
1114 1114
 	 * @param array $lengths Associative array `'field_name' => 'maximum length'`.
1115 1115
 	 */
1116
-	return apply_filters( 'wp_get_comment_fields_max_lengths', $lengths );
1116
+	return apply_filters('wp_get_comment_fields_max_lengths', $lengths);
1117 1117
 }
1118 1118
 
1119 1119
 /**
@@ -1125,23 +1125,23 @@  discard block
 block discarded – undo
1125 1125
  * @return WP_Error|true WP_Error when a comment field exceeds the limit,
1126 1126
  *                       otherwise true.
1127 1127
  */
1128
-function wp_check_comment_data_max_lengths( $comment_data ) {
1128
+function wp_check_comment_data_max_lengths($comment_data) {
1129 1129
 	$max_lengths = wp_get_comment_fields_max_lengths();
1130 1130
 
1131
-	if ( isset( $comment_data['comment_author'] ) && mb_strlen( $comment_data['comment_author'], '8bit' ) > $max_lengths['comment_author'] ) {
1132
-		return new WP_Error( 'comment_author_column_length', __( '<strong>ERROR</strong>: your name is too long.' ), 200 );
1131
+	if (isset($comment_data['comment_author']) && mb_strlen($comment_data['comment_author'], '8bit') > $max_lengths['comment_author']) {
1132
+		return new WP_Error('comment_author_column_length', __('<strong>ERROR</strong>: your name is too long.'), 200);
1133 1133
 	}
1134 1134
 
1135
-	if ( isset( $comment_data['comment_author_email'] ) && strlen( $comment_data['comment_author_email'] ) > $max_lengths['comment_author_email'] ) {
1136
-		return new WP_Error( 'comment_author_email_column_length', __( '<strong>ERROR</strong>: your email address is too long.' ), 200 );
1135
+	if (isset($comment_data['comment_author_email']) && strlen($comment_data['comment_author_email']) > $max_lengths['comment_author_email']) {
1136
+		return new WP_Error('comment_author_email_column_length', __('<strong>ERROR</strong>: your email address is too long.'), 200);
1137 1137
 	}
1138 1138
 
1139
-	if ( isset( $comment_data['comment_author_url'] ) && strlen( $comment_data['comment_author_url'] ) > $max_lengths['comment_author_url'] ) {
1140
-		return new WP_Error( 'comment_author_url_column_length', __( '<strong>ERROR</strong>: your url is too long.' ), 200 );
1139
+	if (isset($comment_data['comment_author_url']) && strlen($comment_data['comment_author_url']) > $max_lengths['comment_author_url']) {
1140
+		return new WP_Error('comment_author_url_column_length', __('<strong>ERROR</strong>: your url is too long.'), 200);
1141 1141
 	}
1142 1142
 
1143
-	if ( isset( $comment_data['comment_content'] ) && mb_strlen( $comment_data['comment_content'], '8bit' ) > $max_lengths['comment_content'] ) {
1144
-		return new WP_Error( 'comment_content_column_length', __( '<strong>ERROR</strong>: your comment is too long.' ), 200 );
1143
+	if (isset($comment_data['comment_content']) && mb_strlen($comment_data['comment_content'], '8bit') > $max_lengths['comment_content']) {
1144
+		return new WP_Error('comment_content_column_length', __('<strong>ERROR</strong>: your comment is too long.'), 200);
1145 1145
 	}
1146 1146
 
1147 1147
 	return true;
@@ -1173,22 +1173,22 @@  discard block
 block discarded – undo
1173 1173
 	 * @param string $user_ip    Comment author's IP address.
1174 1174
 	 * @param string $user_agent Comment author's browser user agent.
1175 1175
 	 */
1176
-	do_action( 'wp_blacklist_check', $author, $email, $url, $comment, $user_ip, $user_agent );
1176
+	do_action('wp_blacklist_check', $author, $email, $url, $comment, $user_ip, $user_agent);
1177 1177
 
1178
-	$mod_keys = trim( get_option('blacklist_keys') );
1179
-	if ( '' == $mod_keys )
1178
+	$mod_keys = trim(get_option('blacklist_keys'));
1179
+	if ('' == $mod_keys)
1180 1180
 		return false; // If moderation keys are empty
1181 1181
 
1182 1182
 	// Ensure HTML tags are not being used to bypass the blacklist.
1183
-	$comment_without_html = wp_strip_all_tags( $comment );
1183
+	$comment_without_html = wp_strip_all_tags($comment);
1184 1184
 
1185
-	$words = explode("\n", $mod_keys );
1185
+	$words = explode("\n", $mod_keys);
1186 1186
 
1187
-	foreach ( (array) $words as $word ) {
1187
+	foreach ((array) $words as $word) {
1188 1188
 		$word = trim($word);
1189 1189
 
1190 1190
 		// Skip empty lines
1191
-		if ( empty($word) ) { continue; }
1191
+		if (empty($word)) { continue; }
1192 1192
 
1193 1193
 		// Do some escaping magic so that '#' chars in the
1194 1194
 		// spam words don't break things:
@@ -1225,7 +1225,7 @@  discard block
 block discarded – undo
1225 1225
  * @param int $post_id Optional. Post ID.
1226 1226
  * @return object|array Comment stats.
1227 1227
  */
1228
-function wp_count_comments( $post_id = 0 ) {
1228
+function wp_count_comments($post_id = 0) {
1229 1229
 	$post_id = (int) $post_id;
1230 1230
 
1231 1231
 	/**
@@ -1236,22 +1236,22 @@  discard block
 block discarded – undo
1236 1236
 	 * @param array $count   An empty array.
1237 1237
 	 * @param int   $post_id The post ID.
1238 1238
 	 */
1239
-	$filtered = apply_filters( 'wp_count_comments', array(), $post_id );
1240
-	if ( ! empty( $filtered ) ) {
1239
+	$filtered = apply_filters('wp_count_comments', array(), $post_id);
1240
+	if ( ! empty($filtered)) {
1241 1241
 		return $filtered;
1242 1242
 	}
1243 1243
 
1244
-	$count = wp_cache_get( "comments-{$post_id}", 'counts' );
1245
-	if ( false !== $count ) {
1244
+	$count = wp_cache_get("comments-{$post_id}", 'counts');
1245
+	if (false !== $count) {
1246 1246
 		return $count;
1247 1247
 	}
1248 1248
 
1249
-	$stats = get_comment_count( $post_id );
1249
+	$stats = get_comment_count($post_id);
1250 1250
 	$stats['moderated'] = $stats['awaiting_moderation'];
1251
-	unset( $stats['awaiting_moderation'] );
1251
+	unset($stats['awaiting_moderation']);
1252 1252
 
1253 1253
 	$stats_object = (object) $stats;
1254
-	wp_cache_set( "comments-{$post_id}", $stats_object, 'counts' );
1254
+	wp_cache_set("comments-{$post_id}", $stats_object, 'counts');
1255 1255
 
1256 1256
 	return $stats_object;
1257 1257
 }
@@ -1275,10 +1275,10 @@  discard block
 block discarded – undo
1275 1275
  */
1276 1276
 function wp_delete_comment($comment_id, $force_delete = false) {
1277 1277
 	global $wpdb;
1278
-	if (!$comment = get_comment($comment_id))
1278
+	if ( ! $comment = get_comment($comment_id))
1279 1279
 		return false;
1280 1280
 
1281
-	if ( !$force_delete && EMPTY_TRASH_DAYS && !in_array( wp_get_comment_status( $comment ), array( 'trash', 'spam' ) ) )
1281
+	if ( ! $force_delete && EMPTY_TRASH_DAYS && ! in_array(wp_get_comment_status($comment), array('trash', 'spam')))
1282 1282
 		return wp_trash_comment($comment_id);
1283 1283
 
1284 1284
 	/**
@@ -1288,21 +1288,21 @@  discard block
 block discarded – undo
1288 1288
 	 *
1289 1289
 	 * @param int $comment_id The comment ID.
1290 1290
 	 */
1291
-	do_action( 'delete_comment', $comment->comment_ID );
1291
+	do_action('delete_comment', $comment->comment_ID);
1292 1292
 
1293 1293
 	// Move children up a level.
1294
-	$children = $wpdb->get_col( $wpdb->prepare("SELECT comment_ID FROM $wpdb->comments WHERE comment_parent = %d", $comment->comment_ID) );
1295
-	if ( !empty($children) ) {
1294
+	$children = $wpdb->get_col($wpdb->prepare("SELECT comment_ID FROM $wpdb->comments WHERE comment_parent = %d", $comment->comment_ID));
1295
+	if ( ! empty($children)) {
1296 1296
 		$wpdb->update($wpdb->comments, array('comment_parent' => $comment->comment_parent), array('comment_parent' => $comment->comment_ID));
1297 1297
 		clean_comment_cache($children);
1298 1298
 	}
1299 1299
 
1300 1300
 	// Delete metadata
1301
-	$meta_ids = $wpdb->get_col( $wpdb->prepare( "SELECT meta_id FROM $wpdb->commentmeta WHERE comment_id = %d", $comment->comment_ID ) );
1302
-	foreach ( $meta_ids as $mid )
1303
-		delete_metadata_by_mid( 'comment', $mid );
1301
+	$meta_ids = $wpdb->get_col($wpdb->prepare("SELECT meta_id FROM $wpdb->commentmeta WHERE comment_id = %d", $comment->comment_ID));
1302
+	foreach ($meta_ids as $mid)
1303
+		delete_metadata_by_mid('comment', $mid);
1304 1304
 
1305
-	if ( ! $wpdb->delete( $wpdb->comments, array( 'comment_ID' => $comment->comment_ID ) ) )
1305
+	if ( ! $wpdb->delete($wpdb->comments, array('comment_ID' => $comment->comment_ID)))
1306 1306
 		return false;
1307 1307
 
1308 1308
 	/**
@@ -1312,16 +1312,16 @@  discard block
 block discarded – undo
1312 1312
 	 *
1313 1313
 	 * @param int $comment_id The comment ID.
1314 1314
 	 */
1315
-	do_action( 'deleted_comment', $comment->comment_ID );
1315
+	do_action('deleted_comment', $comment->comment_ID);
1316 1316
 
1317 1317
 	$post_id = $comment->comment_post_ID;
1318
-	if ( $post_id && $comment->comment_approved == 1 )
1318
+	if ($post_id && $comment->comment_approved == 1)
1319 1319
 		wp_update_comment_count($post_id);
1320 1320
 
1321
-	clean_comment_cache( $comment->comment_ID );
1321
+	clean_comment_cache($comment->comment_ID);
1322 1322
 
1323 1323
 	/** This action is documented in wp-includes/comment.php */
1324
-	do_action( 'wp_set_comment_status', $comment->comment_ID, 'delete' );
1324
+	do_action('wp_set_comment_status', $comment->comment_ID, 'delete');
1325 1325
 
1326 1326
 	wp_transition_comment_status('delete', $comment->comment_approved, $comment);
1327 1327
 	return true;
@@ -1338,10 +1338,10 @@  discard block
 block discarded – undo
1338 1338
  * @return bool True on success, false on failure.
1339 1339
  */
1340 1340
 function wp_trash_comment($comment_id) {
1341
-	if ( !EMPTY_TRASH_DAYS )
1341
+	if ( ! EMPTY_TRASH_DAYS)
1342 1342
 		return wp_delete_comment($comment_id, true);
1343 1343
 
1344
-	if ( !$comment = get_comment($comment_id) )
1344
+	if ( ! $comment = get_comment($comment_id))
1345 1345
 		return false;
1346 1346
 
1347 1347
 	/**
@@ -1351,13 +1351,13 @@  discard block
 block discarded – undo
1351 1351
 	 *
1352 1352
 	 * @param int $comment_id The comment ID.
1353 1353
 	 */
1354
-	do_action( 'trash_comment', $comment->comment_ID );
1354
+	do_action('trash_comment', $comment->comment_ID);
1355 1355
 
1356
-	if ( wp_set_comment_status( $comment, 'trash' ) ) {
1357
-		delete_comment_meta( $comment->comment_ID, '_wp_trash_meta_status' );
1358
-		delete_comment_meta( $comment->comment_ID, '_wp_trash_meta_time' );
1359
-		add_comment_meta( $comment->comment_ID, '_wp_trash_meta_status', $comment->comment_approved );
1360
-		add_comment_meta( $comment->comment_ID, '_wp_trash_meta_time', time() );
1356
+	if (wp_set_comment_status($comment, 'trash')) {
1357
+		delete_comment_meta($comment->comment_ID, '_wp_trash_meta_status');
1358
+		delete_comment_meta($comment->comment_ID, '_wp_trash_meta_time');
1359
+		add_comment_meta($comment->comment_ID, '_wp_trash_meta_status', $comment->comment_approved);
1360
+		add_comment_meta($comment->comment_ID, '_wp_trash_meta_time', time());
1361 1361
 
1362 1362
 		/**
1363 1363
 		 * Fires immediately after a comment is sent to Trash.
@@ -1366,7 +1366,7 @@  discard block
 block discarded – undo
1366 1366
 		 *
1367 1367
 		 * @param int $comment_id The comment ID.
1368 1368
 		 */
1369
-		do_action( 'trashed_comment', $comment->comment_ID );
1369
+		do_action('trashed_comment', $comment->comment_ID);
1370 1370
 		return true;
1371 1371
 	}
1372 1372
 
@@ -1382,8 +1382,8 @@  discard block
 block discarded – undo
1382 1382
  * @return bool True on success, false on failure.
1383 1383
  */
1384 1384
 function wp_untrash_comment($comment_id) {
1385
-	$comment = get_comment( $comment_id );
1386
-	if ( ! $comment ) {
1385
+	$comment = get_comment($comment_id);
1386
+	if ( ! $comment) {
1387 1387
 		return false;
1388 1388
 	}
1389 1389
 
@@ -1394,15 +1394,15 @@  discard block
 block discarded – undo
1394 1394
 	 *
1395 1395
 	 * @param int $comment_id The comment ID.
1396 1396
 	 */
1397
-	do_action( 'untrash_comment', $comment->comment_ID );
1397
+	do_action('untrash_comment', $comment->comment_ID);
1398 1398
 
1399
-	$status = (string) get_comment_meta( $comment->comment_ID, '_wp_trash_meta_status', true );
1400
-	if ( empty($status) )
1399
+	$status = (string) get_comment_meta($comment->comment_ID, '_wp_trash_meta_status', true);
1400
+	if (empty($status))
1401 1401
 		$status = '0';
1402 1402
 
1403
-	if ( wp_set_comment_status( $comment, $status ) ) {
1404
-		delete_comment_meta( $comment->comment_ID, '_wp_trash_meta_time' );
1405
-		delete_comment_meta( $comment->comment_ID, '_wp_trash_meta_status' );
1403
+	if (wp_set_comment_status($comment, $status)) {
1404
+		delete_comment_meta($comment->comment_ID, '_wp_trash_meta_time');
1405
+		delete_comment_meta($comment->comment_ID, '_wp_trash_meta_status');
1406 1406
 		/**
1407 1407
 		 * Fires immediately after a comment is restored from the Trash.
1408 1408
 		 *
@@ -1410,7 +1410,7 @@  discard block
 block discarded – undo
1410 1410
 		 *
1411 1411
 		 * @param int $comment_id The comment ID.
1412 1412
 		 */
1413
-		do_action( 'untrashed_comment', $comment->comment_ID );
1413
+		do_action('untrashed_comment', $comment->comment_ID);
1414 1414
 		return true;
1415 1415
 	}
1416 1416
 
@@ -1425,9 +1425,9 @@  discard block
 block discarded – undo
1425 1425
  * @param int|WP_Comment $comment_id Comment ID or WP_Comment object.
1426 1426
  * @return bool True on success, false on failure.
1427 1427
  */
1428
-function wp_spam_comment( $comment_id ) {
1429
-	$comment = get_comment( $comment_id );
1430
-	if ( ! $comment ) {
1428
+function wp_spam_comment($comment_id) {
1429
+	$comment = get_comment($comment_id);
1430
+	if ( ! $comment) {
1431 1431
 		return false;
1432 1432
 	}
1433 1433
 
@@ -1438,13 +1438,13 @@  discard block
 block discarded – undo
1438 1438
 	 *
1439 1439
 	 * @param int $comment_id The comment ID.
1440 1440
 	 */
1441
-	do_action( 'spam_comment', $comment->comment_ID );
1441
+	do_action('spam_comment', $comment->comment_ID);
1442 1442
 
1443
-	if ( wp_set_comment_status( $comment, 'spam' ) ) {
1444
-		delete_comment_meta( $comment->comment_ID, '_wp_trash_meta_status' );
1445
-		delete_comment_meta( $comment->comment_ID, '_wp_trash_meta_time' );
1446
-		add_comment_meta( $comment->comment_ID, '_wp_trash_meta_status', $comment->comment_approved );
1447
-		add_comment_meta( $comment->comment_ID, '_wp_trash_meta_time', time() );
1443
+	if (wp_set_comment_status($comment, 'spam')) {
1444
+		delete_comment_meta($comment->comment_ID, '_wp_trash_meta_status');
1445
+		delete_comment_meta($comment->comment_ID, '_wp_trash_meta_time');
1446
+		add_comment_meta($comment->comment_ID, '_wp_trash_meta_status', $comment->comment_approved);
1447
+		add_comment_meta($comment->comment_ID, '_wp_trash_meta_time', time());
1448 1448
 		/**
1449 1449
 		 * Fires immediately after a comment is marked as Spam.
1450 1450
 		 *
@@ -1452,7 +1452,7 @@  discard block
 block discarded – undo
1452 1452
 		 *
1453 1453
 		 * @param int $comment_id The comment ID.
1454 1454
 		 */
1455
-		do_action( 'spammed_comment', $comment->comment_ID );
1455
+		do_action('spammed_comment', $comment->comment_ID);
1456 1456
 		return true;
1457 1457
 	}
1458 1458
 
@@ -1467,9 +1467,9 @@  discard block
 block discarded – undo
1467 1467
  * @param int|WP_Comment $comment_id Comment ID or WP_Comment object.
1468 1468
  * @return bool True on success, false on failure.
1469 1469
  */
1470
-function wp_unspam_comment( $comment_id ) {
1471
-	$comment = get_comment( $comment_id );
1472
-	if ( ! $comment ) {
1470
+function wp_unspam_comment($comment_id) {
1471
+	$comment = get_comment($comment_id);
1472
+	if ( ! $comment) {
1473 1473
 		return false;
1474 1474
 	}
1475 1475
 
@@ -1480,15 +1480,15 @@  discard block
 block discarded – undo
1480 1480
 	 *
1481 1481
 	 * @param int $comment_id The comment ID.
1482 1482
 	 */
1483
-	do_action( 'unspam_comment', $comment->comment_ID );
1483
+	do_action('unspam_comment', $comment->comment_ID);
1484 1484
 
1485
-	$status = (string) get_comment_meta( $comment->comment_ID, '_wp_trash_meta_status', true );
1486
-	if ( empty($status) )
1485
+	$status = (string) get_comment_meta($comment->comment_ID, '_wp_trash_meta_status', true);
1486
+	if (empty($status))
1487 1487
 		$status = '0';
1488 1488
 
1489
-	if ( wp_set_comment_status( $comment, $status ) ) {
1490
-		delete_comment_meta( $comment->comment_ID, '_wp_trash_meta_status' );
1491
-		delete_comment_meta( $comment->comment_ID, '_wp_trash_meta_time' );
1489
+	if (wp_set_comment_status($comment, $status)) {
1490
+		delete_comment_meta($comment->comment_ID, '_wp_trash_meta_status');
1491
+		delete_comment_meta($comment->comment_ID, '_wp_trash_meta_time');
1492 1492
 		/**
1493 1493
 		 * Fires immediately after a comment is unmarked as Spam.
1494 1494
 		 *
@@ -1496,7 +1496,7 @@  discard block
 block discarded – undo
1496 1496
 		 *
1497 1497
 		 * @param int $comment_id The comment ID.
1498 1498
 		 */
1499
-		do_action( 'unspammed_comment', $comment->comment_ID );
1499
+		do_action('unspammed_comment', $comment->comment_ID);
1500 1500
 		return true;
1501 1501
 	}
1502 1502
 
@@ -1513,20 +1513,20 @@  discard block
 block discarded – undo
1513 1513
  */
1514 1514
 function wp_get_comment_status($comment_id) {
1515 1515
 	$comment = get_comment($comment_id);
1516
-	if ( !$comment )
1516
+	if ( ! $comment)
1517 1517
 		return false;
1518 1518
 
1519 1519
 	$approved = $comment->comment_approved;
1520 1520
 
1521
-	if ( $approved == null )
1521
+	if ($approved == null)
1522 1522
 		return false;
1523
-	elseif ( $approved == '1' )
1523
+	elseif ($approved == '1')
1524 1524
 		return 'approved';
1525
-	elseif ( $approved == '0' )
1525
+	elseif ($approved == '0')
1526 1526
 		return 'unapproved';
1527
-	elseif ( $approved == 'spam' )
1527
+	elseif ($approved == 'spam')
1528 1528
 		return 'spam';
1529
-	elseif ( $approved == 'trash' )
1529
+	elseif ($approved == 'trash')
1530 1530
 		return 'trash';
1531 1531
 	else
1532 1532
 		return false;
@@ -1562,11 +1562,11 @@  discard block
 block discarded – undo
1562 1562
 		1         => 'approved',
1563 1563
 		'approve' => 'approved', // wp_set_comment_status() uses "approve"
1564 1564
 	);
1565
-	if ( isset($comment_statuses[$new_status]) ) $new_status = $comment_statuses[$new_status];
1566
-	if ( isset($comment_statuses[$old_status]) ) $old_status = $comment_statuses[$old_status];
1565
+	if (isset($comment_statuses[$new_status])) $new_status = $comment_statuses[$new_status];
1566
+	if (isset($comment_statuses[$old_status])) $old_status = $comment_statuses[$old_status];
1567 1567
 
1568 1568
 	// Call the hooks
1569
-	if ( $new_status != $old_status ) {
1569
+	if ($new_status != $old_status) {
1570 1570
 		/**
1571 1571
 		 * Fires when the comment status is in transition.
1572 1572
 		 *
@@ -1576,7 +1576,7 @@  discard block
 block discarded – undo
1576 1576
 		 * @param int|string $old_status The old comment status.
1577 1577
 		 * @param object     $comment    The comment data.
1578 1578
 		 */
1579
-		do_action( 'transition_comment_status', $new_status, $old_status, $comment );
1579
+		do_action('transition_comment_status', $new_status, $old_status, $comment);
1580 1580
 		/**
1581 1581
 		 * Fires when the comment status is in transition from one specific status to another.
1582 1582
 		 *
@@ -1587,7 +1587,7 @@  discard block
 block discarded – undo
1587 1587
 		 *
1588 1588
 		 * @param WP_Comment $comment Comment object.
1589 1589
 		 */
1590
-		do_action( "comment_{$old_status}_to_{$new_status}", $comment );
1590
+		do_action("comment_{$old_status}_to_{$new_status}", $comment);
1591 1591
 	}
1592 1592
 	/**
1593 1593
 	 * Fires when the status of a specific comment type is in transition.
@@ -1603,7 +1603,7 @@  discard block
 block discarded – undo
1603 1603
 	 * @param int        $comment_ID The comment ID.
1604 1604
 	 * @param WP_Comment $comment    Comment object.
1605 1605
 	 */
1606
-	do_action( "comment_{$new_status}_{$comment->comment_type}", $comment->comment_ID, $comment );
1606
+	do_action("comment_{$new_status}_{$comment->comment_type}", $comment->comment_ID, $comment);
1607 1607
 }
1608 1608
 
1609 1609
 /**
@@ -1618,10 +1618,10 @@  discard block
 block discarded – undo
1618 1618
  * @param string $new_status The new comment status.
1619 1619
  * @param string $old_status The old comment status.
1620 1620
  */
1621
-function _clear_modified_cache_on_transition_comment_status( $new_status, $old_status ) {
1622
-	if ( 'approved' === $new_status || 'approved' === $old_status ) {
1623
-		foreach ( array( 'server', 'gmt', 'blog' ) as $timezone ) {
1624
-			wp_cache_delete( "lastcommentmodified:$timezone", 'timeinfo' );
1621
+function _clear_modified_cache_on_transition_comment_status($new_status, $old_status) {
1622
+	if ('approved' === $new_status || 'approved' === $old_status) {
1623
+		foreach (array('server', 'gmt', 'blog') as $timezone) {
1624
+			wp_cache_delete("lastcommentmodified:$timezone", 'timeinfo');
1625 1625
 		}
1626 1626
 	}
1627 1627
 }
@@ -1642,15 +1642,15 @@  discard block
 block discarded – undo
1642 1642
 	// Cookies should already be sanitized.
1643 1643
 
1644 1644
 	$comment_author = '';
1645
-	if ( isset($_COOKIE['comment_author_'.COOKIEHASH]) )
1645
+	if (isset($_COOKIE['comment_author_'.COOKIEHASH]))
1646 1646
 		$comment_author = $_COOKIE['comment_author_'.COOKIEHASH];
1647 1647
 
1648 1648
 	$comment_author_email = '';
1649
-	if ( isset($_COOKIE['comment_author_email_'.COOKIEHASH]) )
1649
+	if (isset($_COOKIE['comment_author_email_'.COOKIEHASH]))
1650 1650
 		$comment_author_email = $_COOKIE['comment_author_email_'.COOKIEHASH];
1651 1651
 
1652 1652
 	$comment_author_url = '';
1653
-	if ( isset($_COOKIE['comment_author_url_'.COOKIEHASH]) )
1653
+	if (isset($_COOKIE['comment_author_url_'.COOKIEHASH]))
1654 1654
 		$comment_author_url = $_COOKIE['comment_author_url_'.COOKIEHASH];
1655 1655
 
1656 1656
 	/**
@@ -1666,7 +1666,7 @@  discard block
 block discarded – undo
1666 1666
 	 *     @type string $comment_author_url   The URL address of the `$comment_author`. Default empty.
1667 1667
 	 * }
1668 1668
 	 */
1669
-	return apply_filters( 'wp_get_current_commenter', compact('comment_author', 'comment_author_email', 'comment_author_url') );
1669
+	return apply_filters('wp_get_current_commenter', compact('comment_author', 'comment_author_email', 'comment_author_url'));
1670 1670
 }
1671 1671
 
1672 1672
 /**
@@ -1704,51 +1704,51 @@  discard block
 block discarded – undo
1704 1704
  * }
1705 1705
  * @return int|false The new comment's ID on success, false on failure.
1706 1706
  */
1707
-function wp_insert_comment( $commentdata ) {
1707
+function wp_insert_comment($commentdata) {
1708 1708
 	global $wpdb;
1709
-	$data = wp_unslash( $commentdata );
1709
+	$data = wp_unslash($commentdata);
1710 1710
 
1711
-	$comment_author       = ! isset( $data['comment_author'] )       ? '' : $data['comment_author'];
1712
-	$comment_author_email = ! isset( $data['comment_author_email'] ) ? '' : $data['comment_author_email'];
1713
-	$comment_author_url   = ! isset( $data['comment_author_url'] )   ? '' : $data['comment_author_url'];
1714
-	$comment_author_IP    = ! isset( $data['comment_author_IP'] )    ? '' : $data['comment_author_IP'];
1711
+	$comment_author       = ! isset($data['comment_author']) ? '' : $data['comment_author'];
1712
+	$comment_author_email = ! isset($data['comment_author_email']) ? '' : $data['comment_author_email'];
1713
+	$comment_author_url   = ! isset($data['comment_author_url']) ? '' : $data['comment_author_url'];
1714
+	$comment_author_IP    = ! isset($data['comment_author_IP']) ? '' : $data['comment_author_IP'];
1715 1715
 
1716
-	$comment_date     = ! isset( $data['comment_date'] )     ? current_time( 'mysql' )            : $data['comment_date'];
1717
-	$comment_date_gmt = ! isset( $data['comment_date_gmt'] ) ? get_gmt_from_date( $comment_date ) : $data['comment_date_gmt'];
1716
+	$comment_date     = ! isset($data['comment_date']) ? current_time('mysql') : $data['comment_date'];
1717
+	$comment_date_gmt = ! isset($data['comment_date_gmt']) ? get_gmt_from_date($comment_date) : $data['comment_date_gmt'];
1718 1718
 
1719
-	$comment_post_ID  = ! isset( $data['comment_post_ID'] )  ? 0  : $data['comment_post_ID'];
1720
-	$comment_content  = ! isset( $data['comment_content'] )  ? '' : $data['comment_content'];
1721
-	$comment_karma    = ! isset( $data['comment_karma'] )    ? 0  : $data['comment_karma'];
1722
-	$comment_approved = ! isset( $data['comment_approved'] ) ? 1  : $data['comment_approved'];
1723
-	$comment_agent    = ! isset( $data['comment_agent'] )    ? '' : $data['comment_agent'];
1724
-	$comment_type     = ! isset( $data['comment_type'] )     ? '' : $data['comment_type'];
1725
-	$comment_parent   = ! isset( $data['comment_parent'] )   ? 0  : $data['comment_parent'];
1719
+	$comment_post_ID  = ! isset($data['comment_post_ID']) ? 0 : $data['comment_post_ID'];
1720
+	$comment_content  = ! isset($data['comment_content']) ? '' : $data['comment_content'];
1721
+	$comment_karma    = ! isset($data['comment_karma']) ? 0 : $data['comment_karma'];
1722
+	$comment_approved = ! isset($data['comment_approved']) ? 1 : $data['comment_approved'];
1723
+	$comment_agent    = ! isset($data['comment_agent']) ? '' : $data['comment_agent'];
1724
+	$comment_type     = ! isset($data['comment_type']) ? '' : $data['comment_type'];
1725
+	$comment_parent   = ! isset($data['comment_parent']) ? 0 : $data['comment_parent'];
1726 1726
 
1727
-	$user_id  = ! isset( $data['user_id'] ) ? 0 : $data['user_id'];
1727
+	$user_id = ! isset($data['user_id']) ? 0 : $data['user_id'];
1728 1728
 
1729
-	$compacted = compact( 'comment_post_ID', 'comment_author', 'comment_author_email', 'comment_author_url', 'comment_author_IP', 'comment_date', 'comment_date_gmt', 'comment_content', 'comment_karma', 'comment_approved', 'comment_agent', 'comment_type', 'comment_parent', 'user_id' );
1730
-	if ( ! $wpdb->insert( $wpdb->comments, $compacted ) ) {
1729
+	$compacted = compact('comment_post_ID', 'comment_author', 'comment_author_email', 'comment_author_url', 'comment_author_IP', 'comment_date', 'comment_date_gmt', 'comment_content', 'comment_karma', 'comment_approved', 'comment_agent', 'comment_type', 'comment_parent', 'user_id');
1730
+	if ( ! $wpdb->insert($wpdb->comments, $compacted)) {
1731 1731
 		return false;
1732 1732
 	}
1733 1733
 
1734 1734
 	$id = (int) $wpdb->insert_id;
1735 1735
 
1736
-	if ( $comment_approved == 1 ) {
1737
-		wp_update_comment_count( $comment_post_ID );
1736
+	if ($comment_approved == 1) {
1737
+		wp_update_comment_count($comment_post_ID);
1738 1738
 
1739
-		foreach ( array( 'server', 'gmt', 'blog' ) as $timezone ) {
1740
-			wp_cache_delete( "lastcommentmodified:$timezone", 'timeinfo' );
1739
+		foreach (array('server', 'gmt', 'blog') as $timezone) {
1740
+			wp_cache_delete("lastcommentmodified:$timezone", 'timeinfo');
1741 1741
 		}
1742 1742
 	}
1743 1743
 
1744
-	clean_comment_cache( $id );
1744
+	clean_comment_cache($id);
1745 1745
 
1746
-	$comment = get_comment( $id );
1746
+	$comment = get_comment($id);
1747 1747
 
1748 1748
 	// If metadata is provided, store it.
1749
-	if ( isset( $commentdata['comment_meta'] ) && is_array( $commentdata['comment_meta'] ) ) {
1750
-		foreach ( $commentdata['comment_meta'] as $meta_key => $meta_value ) {
1751
-			add_comment_meta( $comment->comment_ID, $meta_key, $meta_value, true );
1749
+	if (isset($commentdata['comment_meta']) && is_array($commentdata['comment_meta'])) {
1750
+		foreach ($commentdata['comment_meta'] as $meta_key => $meta_value) {
1751
+			add_comment_meta($comment->comment_ID, $meta_key, $meta_value, true);
1752 1752
 		}
1753 1753
 	}
1754 1754
 
@@ -1760,7 +1760,7 @@  discard block
 block discarded – undo
1760 1760
 	 * @param int        $id      The comment ID.
1761 1761
 	 * @param WP_Comment $comment Comment object.
1762 1762
 	 */
1763
-	do_action( 'wp_insert_comment', $id, $comment );
1763
+	do_action('wp_insert_comment', $id, $comment);
1764 1764
 
1765 1765
 	return $id;
1766 1766
 }
@@ -1778,7 +1778,7 @@  discard block
 block discarded – undo
1778 1778
  * @return array Parsed comment information.
1779 1779
  */
1780 1780
 function wp_filter_comment($commentdata) {
1781
-	if ( isset( $commentdata['user_ID'] ) ) {
1781
+	if (isset($commentdata['user_ID'])) {
1782 1782
 		/**
1783 1783
 		 * Filters the comment author's user id before it is set.
1784 1784
 		 *
@@ -1789,10 +1789,10 @@  discard block
 block discarded – undo
1789 1789
 		 *
1790 1790
 		 * @param int $user_ID The comment author's user ID.
1791 1791
 		 */
1792
-		$commentdata['user_id'] = apply_filters( 'pre_user_id', $commentdata['user_ID'] );
1793
-	} elseif ( isset( $commentdata['user_id'] ) ) {
1792
+		$commentdata['user_id'] = apply_filters('pre_user_id', $commentdata['user_ID']);
1793
+	} elseif (isset($commentdata['user_id'])) {
1794 1794
 		/** This filter is documented in wp-includes/comment.php */
1795
-		$commentdata['user_id'] = apply_filters( 'pre_user_id', $commentdata['user_id'] );
1795
+		$commentdata['user_id'] = apply_filters('pre_user_id', $commentdata['user_id']);
1796 1796
 	}
1797 1797
 
1798 1798
 	/**
@@ -1802,9 +1802,9 @@  discard block
 block discarded – undo
1802 1802
 	 *
1803 1803
 	 * @param string $comment_agent The comment author's browser user agent.
1804 1804
 	 */
1805
-	$commentdata['comment_agent'] = apply_filters( 'pre_comment_user_agent', ( isset( $commentdata['comment_agent'] ) ? $commentdata['comment_agent'] : '' ) );
1805
+	$commentdata['comment_agent'] = apply_filters('pre_comment_user_agent', (isset($commentdata['comment_agent']) ? $commentdata['comment_agent'] : ''));
1806 1806
 	/** This filter is documented in wp-includes/comment.php */
1807
-	$commentdata['comment_author'] = apply_filters( 'pre_comment_author_name', $commentdata['comment_author'] );
1807
+	$commentdata['comment_author'] = apply_filters('pre_comment_author_name', $commentdata['comment_author']);
1808 1808
 	/**
1809 1809
 	 * Filters the comment content before it is set.
1810 1810
 	 *
@@ -1812,7 +1812,7 @@  discard block
 block discarded – undo
1812 1812
 	 *
1813 1813
 	 * @param string $comment_content The comment content.
1814 1814
 	 */
1815
-	$commentdata['comment_content'] = apply_filters( 'pre_comment_content', $commentdata['comment_content'] );
1815
+	$commentdata['comment_content'] = apply_filters('pre_comment_content', $commentdata['comment_content']);
1816 1816
 	/**
1817 1817
 	 * Filters the comment author's IP before it is set.
1818 1818
 	 *
@@ -1820,11 +1820,11 @@  discard block
 block discarded – undo
1820 1820
 	 *
1821 1821
 	 * @param string $comment_author_ip The comment author's IP.
1822 1822
 	 */
1823
-	$commentdata['comment_author_IP'] = apply_filters( 'pre_comment_user_ip', $commentdata['comment_author_IP'] );
1823
+	$commentdata['comment_author_IP'] = apply_filters('pre_comment_user_ip', $commentdata['comment_author_IP']);
1824 1824
 	/** This filter is documented in wp-includes/comment.php */
1825
-	$commentdata['comment_author_url'] = apply_filters( 'pre_comment_author_url', $commentdata['comment_author_url'] );
1825
+	$commentdata['comment_author_url'] = apply_filters('pre_comment_author_url', $commentdata['comment_author_url']);
1826 1826
 	/** This filter is documented in wp-includes/comment.php */
1827
-	$commentdata['comment_author_email'] = apply_filters( 'pre_comment_author_email', $commentdata['comment_author_email'] );
1827
+	$commentdata['comment_author_email'] = apply_filters('pre_comment_author_email', $commentdata['comment_author_email']);
1828 1828
 	$commentdata['filtered'] = true;
1829 1829
 	return $commentdata;
1830 1830
 }
@@ -1840,9 +1840,9 @@  discard block
 block discarded – undo
1840 1840
  * @return bool Whether comment should be blocked.
1841 1841
  */
1842 1842
 function wp_throttle_comment_flood($block, $time_lastcomment, $time_newcomment) {
1843
-	if ( $block ) // a plugin has already blocked... we'll let that decision stand
1843
+	if ($block) // a plugin has already blocked... we'll let that decision stand
1844 1844
 		return $block;
1845
-	if ( ($time_newcomment - $time_lastcomment) < 15 )
1845
+	if (($time_newcomment - $time_lastcomment) < 15)
1846 1846
 		return true;
1847 1847
 	return false;
1848 1848
 }
@@ -1891,14 +1891,14 @@  discard block
 block discarded – undo
1891 1891
  *                        executing wp_die()? Default false.
1892 1892
  * @return int|false|WP_Error The ID of the comment on success, false or WP_Error on failure.
1893 1893
  */
1894
-function wp_new_comment( $commentdata, $avoid_die = false ) {
1894
+function wp_new_comment($commentdata, $avoid_die = false) {
1895 1895
 	global $wpdb;
1896 1896
 
1897
-	if ( isset( $commentdata['user_ID'] ) ) {
1897
+	if (isset($commentdata['user_ID'])) {
1898 1898
 		$commentdata['user_id'] = $commentdata['user_ID'] = (int) $commentdata['user_ID'];
1899 1899
 	}
1900 1900
 
1901
-	$prefiltered_user_id = ( isset( $commentdata['user_id'] ) ) ? (int) $commentdata['user_id'] : 0;
1901
+	$prefiltered_user_id = (isset($commentdata['user_id'])) ? (int) $commentdata['user_id'] : 0;
1902 1902
 
1903 1903
 	/**
1904 1904
 	 * Filters a comment's data before it is sanitized and inserted into the database.
@@ -1907,63 +1907,63 @@  discard block
 block discarded – undo
1907 1907
 	 *
1908 1908
 	 * @param array $commentdata Comment data.
1909 1909
 	 */
1910
-	$commentdata = apply_filters( 'preprocess_comment', $commentdata );
1910
+	$commentdata = apply_filters('preprocess_comment', $commentdata);
1911 1911
 
1912 1912
 	$commentdata['comment_post_ID'] = (int) $commentdata['comment_post_ID'];
1913
-	if ( isset( $commentdata['user_ID'] ) && $prefiltered_user_id !== (int) $commentdata['user_ID'] ) {
1913
+	if (isset($commentdata['user_ID']) && $prefiltered_user_id !== (int) $commentdata['user_ID']) {
1914 1914
 		$commentdata['user_id'] = $commentdata['user_ID'] = (int) $commentdata['user_ID'];
1915
-	} elseif ( isset( $commentdata['user_id'] ) ) {
1915
+	} elseif (isset($commentdata['user_id'])) {
1916 1916
 		$commentdata['user_id'] = (int) $commentdata['user_id'];
1917 1917
 	}
1918 1918
 
1919 1919
 	$commentdata['comment_parent'] = isset($commentdata['comment_parent']) ? absint($commentdata['comment_parent']) : 0;
1920
-	$parent_status = ( 0 < $commentdata['comment_parent'] ) ? wp_get_comment_status($commentdata['comment_parent']) : '';
1921
-	$commentdata['comment_parent'] = ( 'approved' == $parent_status || 'unapproved' == $parent_status ) ? $commentdata['comment_parent'] : 0;
1920
+	$parent_status = (0 < $commentdata['comment_parent']) ? wp_get_comment_status($commentdata['comment_parent']) : '';
1921
+	$commentdata['comment_parent'] = ('approved' == $parent_status || 'unapproved' == $parent_status) ? $commentdata['comment_parent'] : 0;
1922 1922
 
1923
-	if ( ! isset( $commentdata['comment_author_IP'] ) ) {
1923
+	if ( ! isset($commentdata['comment_author_IP'])) {
1924 1924
 		$commentdata['comment_author_IP'] = $_SERVER['REMOTE_ADDR'];
1925 1925
 	}
1926
-	$commentdata['comment_author_IP'] = preg_replace( '/[^0-9a-fA-F:., ]/', '', $commentdata['comment_author_IP'] );
1926
+	$commentdata['comment_author_IP'] = preg_replace('/[^0-9a-fA-F:., ]/', '', $commentdata['comment_author_IP']);
1927 1927
 
1928
-	if ( ! isset( $commentdata['comment_agent'] ) ) {
1929
-		$commentdata['comment_agent'] = isset( $_SERVER['HTTP_USER_AGENT'] ) ? $_SERVER['HTTP_USER_AGENT']: '';
1928
+	if ( ! isset($commentdata['comment_agent'])) {
1929
+		$commentdata['comment_agent'] = isset($_SERVER['HTTP_USER_AGENT']) ? $_SERVER['HTTP_USER_AGENT'] : '';
1930 1930
 	}
1931
-	$commentdata['comment_agent'] = substr( $commentdata['comment_agent'], 0, 254 );
1931
+	$commentdata['comment_agent'] = substr($commentdata['comment_agent'], 0, 254);
1932 1932
 
1933
-	if ( empty( $commentdata['comment_date'] ) ) {
1933
+	if (empty($commentdata['comment_date'])) {
1934 1934
 		$commentdata['comment_date'] = current_time('mysql');
1935 1935
 	}
1936 1936
 
1937
-	if ( empty( $commentdata['comment_date_gmt'] ) ) {
1938
-		$commentdata['comment_date_gmt'] = current_time( 'mysql', 1 );
1937
+	if (empty($commentdata['comment_date_gmt'])) {
1938
+		$commentdata['comment_date_gmt'] = current_time('mysql', 1);
1939 1939
 	}
1940 1940
 
1941 1941
 	$commentdata = wp_filter_comment($commentdata);
1942 1942
 
1943
-	$commentdata['comment_approved'] = wp_allow_comment( $commentdata, $avoid_die );
1944
-	if ( is_wp_error( $commentdata['comment_approved'] ) ) {
1943
+	$commentdata['comment_approved'] = wp_allow_comment($commentdata, $avoid_die);
1944
+	if (is_wp_error($commentdata['comment_approved'])) {
1945 1945
 		return $commentdata['comment_approved'];
1946 1946
 	}
1947 1947
 
1948 1948
 	$comment_ID = wp_insert_comment($commentdata);
1949
-	if ( ! $comment_ID ) {
1950
-		$fields = array( 'comment_author', 'comment_author_email', 'comment_author_url', 'comment_content' );
1949
+	if ( ! $comment_ID) {
1950
+		$fields = array('comment_author', 'comment_author_email', 'comment_author_url', 'comment_content');
1951 1951
 
1952
-		foreach ( $fields as $field ) {
1953
-			if ( isset( $commentdata[ $field ] ) ) {
1954
-				$commentdata[ $field ] = $wpdb->strip_invalid_text_for_column( $wpdb->comments, $field, $commentdata[ $field ] );
1952
+		foreach ($fields as $field) {
1953
+			if (isset($commentdata[$field])) {
1954
+				$commentdata[$field] = $wpdb->strip_invalid_text_for_column($wpdb->comments, $field, $commentdata[$field]);
1955 1955
 			}
1956 1956
 		}
1957 1957
 
1958
-		$commentdata = wp_filter_comment( $commentdata );
1958
+		$commentdata = wp_filter_comment($commentdata);
1959 1959
 
1960
-		$commentdata['comment_approved'] = wp_allow_comment( $commentdata, $avoid_die );
1961
-		if ( is_wp_error( $commentdata['comment_approved'] ) ) {
1960
+		$commentdata['comment_approved'] = wp_allow_comment($commentdata, $avoid_die);
1961
+		if (is_wp_error($commentdata['comment_approved'])) {
1962 1962
 			return $commentdata['comment_approved'];
1963 1963
 		}
1964 1964
 
1965
-		$comment_ID = wp_insert_comment( $commentdata );
1966
-		if ( ! $comment_ID ) {
1965
+		$comment_ID = wp_insert_comment($commentdata);
1966
+		if ( ! $comment_ID) {
1967 1967
 			return false;
1968 1968
 		}
1969 1969
 	}
@@ -1978,7 +1978,7 @@  discard block
 block discarded – undo
1978 1978
 	 * @param int|string $comment_approved 1 if the comment is approved, 0 if not, 'spam' if spam.
1979 1979
 	 * @param array      $commentdata      Comment data.
1980 1980
 	 */
1981
-	do_action( 'comment_post', $comment_ID, $commentdata['comment_approved'], $commentdata );
1981
+	do_action('comment_post', $comment_ID, $commentdata['comment_approved'], $commentdata);
1982 1982
 
1983 1983
 	return $comment_ID;
1984 1984
 }
@@ -1991,20 +1991,20 @@  discard block
 block discarded – undo
1991 1991
  * @param int $comment_ID ID of the comment.
1992 1992
  * @return bool True on success, false on failure.
1993 1993
  */
1994
-function wp_new_comment_notify_moderator( $comment_ID ) {
1995
-	$comment = get_comment( $comment_ID );
1994
+function wp_new_comment_notify_moderator($comment_ID) {
1995
+	$comment = get_comment($comment_ID);
1996 1996
 
1997 1997
 	// Only send notifications for pending comments.
1998
-	$maybe_notify = ( '0' == $comment->comment_approved );
1998
+	$maybe_notify = ('0' == $comment->comment_approved);
1999 1999
 
2000 2000
 	/** This filter is documented in wp-includes/comment.php */
2001
-	$maybe_notify = apply_filters( 'notify_moderator', $maybe_notify, $comment_ID );
2001
+	$maybe_notify = apply_filters('notify_moderator', $maybe_notify, $comment_ID);
2002 2002
 
2003
-	if ( ! $maybe_notify ) {
2003
+	if ( ! $maybe_notify) {
2004 2004
 		return false;
2005 2005
 	}
2006 2006
 
2007
-	return wp_notify_moderator( $comment_ID );
2007
+	return wp_notify_moderator($comment_ID);
2008 2008
 }
2009 2009
 
2010 2010
 /**
@@ -2018,10 +2018,10 @@  discard block
 block discarded – undo
2018 2018
  * @param int $comment_ID Comment ID.
2019 2019
  * @return bool True on success, false on failure.
2020 2020
  */
2021
-function wp_new_comment_notify_postauthor( $comment_ID ) {
2022
-	$comment = get_comment( $comment_ID );
2021
+function wp_new_comment_notify_postauthor($comment_ID) {
2022
+	$comment = get_comment($comment_ID);
2023 2023
 
2024
-	$maybe_notify = get_option( 'comments_notify' );
2024
+	$maybe_notify = get_option('comments_notify');
2025 2025
 
2026 2026
 	/**
2027 2027
 	 * Filters whether to send the post author new comment notification emails,
@@ -2032,22 +2032,22 @@  discard block
 block discarded – undo
2032 2032
 	 * @param bool $maybe_notify Whether to notify the post author about the new comment.
2033 2033
 	 * @param int  $comment_ID   The ID of the comment for the notification.
2034 2034
 	 */
2035
-	$maybe_notify = apply_filters( 'notify_post_author', $maybe_notify, $comment_ID );
2035
+	$maybe_notify = apply_filters('notify_post_author', $maybe_notify, $comment_ID);
2036 2036
 
2037 2037
 	/*
2038 2038
 	 * wp_notify_postauthor() checks if notifying the author of their own comment.
2039 2039
 	 * By default, it won't, but filters can override this.
2040 2040
 	 */
2041
-	if ( ! $maybe_notify ) {
2041
+	if ( ! $maybe_notify) {
2042 2042
 		return false;
2043 2043
 	}
2044 2044
 
2045 2045
 	// Only send notifications for approved comments.
2046
-	if ( ! isset( $comment->comment_approved ) || '1' != $comment->comment_approved ) {
2046
+	if ( ! isset($comment->comment_approved) || '1' != $comment->comment_approved) {
2047 2047
 		return false;
2048 2048
 	}
2049 2049
 
2050
-	return wp_notify_postauthor( $comment_ID );
2050
+	return wp_notify_postauthor($comment_ID);
2051 2051
 }
2052 2052
 
2053 2053
 /**
@@ -2068,7 +2068,7 @@  discard block
 block discarded – undo
2068 2068
 function wp_set_comment_status($comment_id, $comment_status, $wp_error = false) {
2069 2069
 	global $wpdb;
2070 2070
 
2071
-	switch ( $comment_status ) {
2071
+	switch ($comment_status) {
2072 2072
 		case 'hold':
2073 2073
 		case '0':
2074 2074
 			$status = '0';
@@ -2076,7 +2076,7 @@  discard block
 block discarded – undo
2076 2076
 		case 'approve':
2077 2077
 		case '1':
2078 2078
 			$status = '1';
2079
-			add_action( 'wp_set_comment_status', 'wp_new_comment_notify_postauthor' );
2079
+			add_action('wp_set_comment_status', 'wp_new_comment_notify_postauthor');
2080 2080
 			break;
2081 2081
 		case 'spam':
2082 2082
 			$status = 'spam';
@@ -2090,16 +2090,16 @@  discard block
 block discarded – undo
2090 2090
 
2091 2091
 	$comment_old = clone get_comment($comment_id);
2092 2092
 
2093
-	if ( !$wpdb->update( $wpdb->comments, array('comment_approved' => $status), array( 'comment_ID' => $comment_old->comment_ID ) ) ) {
2094
-		if ( $wp_error )
2093
+	if ( ! $wpdb->update($wpdb->comments, array('comment_approved' => $status), array('comment_ID' => $comment_old->comment_ID))) {
2094
+		if ($wp_error)
2095 2095
 			return new WP_Error('db_update_error', __('Could not update comment status'), $wpdb->last_error);
2096 2096
 		else
2097 2097
 			return false;
2098 2098
 	}
2099 2099
 
2100
-	clean_comment_cache( $comment_old->comment_ID );
2100
+	clean_comment_cache($comment_old->comment_ID);
2101 2101
 
2102
-	$comment = get_comment( $comment_old->comment_ID );
2102
+	$comment = get_comment($comment_old->comment_ID);
2103 2103
 
2104 2104
 	/**
2105 2105
 	 * Fires immediately before transitioning a comment's status from one to another
@@ -2111,7 +2111,7 @@  discard block
 block discarded – undo
2111 2111
 	 * @param string|bool $comment_status Current comment status. Possible values include
2112 2112
 	 *                                    'hold', 'approve', 'spam', 'trash', or false.
2113 2113
 	 */
2114
-	do_action( 'wp_set_comment_status', $comment->comment_ID, $comment_status );
2114
+	do_action('wp_set_comment_status', $comment->comment_ID, $comment_status);
2115 2115
 
2116 2116
 	wp_transition_comment_status($comment_status, $comment_old->comment_approved, $comment);
2117 2117
 
@@ -2137,12 +2137,12 @@  discard block
 block discarded – undo
2137 2137
 
2138 2138
 	// First, get all of the original fields
2139 2139
 	$comment = get_comment($commentarr['comment_ID'], ARRAY_A);
2140
-	if ( empty( $comment ) ) {
2140
+	if (empty($comment)) {
2141 2141
 		return 0;
2142 2142
 	}
2143 2143
 
2144 2144
 	// Make sure that the comment post ID is valid (if specified).
2145
-	if ( ! empty( $commentarr['comment_post_ID'] ) && ! get_post( $commentarr['comment_post_ID'] ) ) {
2145
+	if ( ! empty($commentarr['comment_post_ID']) && ! get_post($commentarr['comment_post_ID'])) {
2146 2146
 		return 0;
2147 2147
 	}
2148 2148
 
@@ -2154,10 +2154,10 @@  discard block
 block discarded – undo
2154 2154
 	// Merge old and new fields with new fields overwriting old ones.
2155 2155
 	$commentarr = array_merge($comment, $commentarr);
2156 2156
 
2157
-	$commentarr = wp_filter_comment( $commentarr );
2157
+	$commentarr = wp_filter_comment($commentarr);
2158 2158
 
2159 2159
 	// Now extract the merged array.
2160
-	$data = wp_unslash( $commentarr );
2160
+	$data = wp_unslash($commentarr);
2161 2161
 
2162 2162
 	/**
2163 2163
 	 * Filters the comment content before it is updated in the database.
@@ -2166,15 +2166,15 @@  discard block
 block discarded – undo
2166 2166
 	 *
2167 2167
 	 * @param string $comment_content The comment data.
2168 2168
 	 */
2169
-	$data['comment_content'] = apply_filters( 'comment_save_pre', $data['comment_content'] );
2169
+	$data['comment_content'] = apply_filters('comment_save_pre', $data['comment_content']);
2170 2170
 
2171
-	$data['comment_date_gmt'] = get_gmt_from_date( $data['comment_date'] );
2171
+	$data['comment_date_gmt'] = get_gmt_from_date($data['comment_date']);
2172 2172
 
2173
-	if ( ! isset( $data['comment_approved'] ) ) {
2173
+	if ( ! isset($data['comment_approved'])) {
2174 2174
 		$data['comment_approved'] = 1;
2175
-	} elseif ( 'hold' == $data['comment_approved'] ) {
2175
+	} elseif ('hold' == $data['comment_approved']) {
2176 2176
 		$data['comment_approved'] = 0;
2177
-	} elseif ( 'approve' == $data['comment_approved'] ) {
2177
+	} elseif ('approve' == $data['comment_approved']) {
2178 2178
 		$data['comment_approved'] = 1;
2179 2179
 	}
2180 2180
 
@@ -2192,15 +2192,15 @@  discard block
 block discarded – undo
2192 2192
 	 * @param array $comment    The old, unslashed comment data.
2193 2193
 	 * @param array $commentarr The new, raw comment data.
2194 2194
 	 */
2195
-	$data = apply_filters( 'wp_update_comment_data', $data, $comment, $commentarr );
2195
+	$data = apply_filters('wp_update_comment_data', $data, $comment, $commentarr);
2196 2196
 
2197
-	$keys = array( 'comment_post_ID', 'comment_content', 'comment_author', 'comment_author_email', 'comment_approved', 'comment_karma', 'comment_author_url', 'comment_date', 'comment_date_gmt', 'comment_type', 'comment_parent', 'user_id', 'comment_agent', 'comment_author_IP' );
2198
-	$data = wp_array_slice_assoc( $data, $keys );
2197
+	$keys = array('comment_post_ID', 'comment_content', 'comment_author', 'comment_author_email', 'comment_approved', 'comment_karma', 'comment_author_url', 'comment_date', 'comment_date_gmt', 'comment_type', 'comment_parent', 'user_id', 'comment_agent', 'comment_author_IP');
2198
+	$data = wp_array_slice_assoc($data, $keys);
2199 2199
 
2200
-	$rval = $wpdb->update( $wpdb->comments, $data, compact( 'comment_ID' ) );
2200
+	$rval = $wpdb->update($wpdb->comments, $data, compact('comment_ID'));
2201 2201
 
2202
-	clean_comment_cache( $comment_ID );
2203
-	wp_update_comment_count( $comment_post_ID );
2202
+	clean_comment_cache($comment_ID);
2203
+	wp_update_comment_count($comment_post_ID);
2204 2204
 	/**
2205 2205
 	 * Fires immediately after a comment is updated in the database.
2206 2206
 	 *
@@ -2212,7 +2212,7 @@  discard block
 block discarded – undo
2212 2212
 	 * @param int   $comment_ID The comment ID.
2213 2213
 	 * @param array $data       Comment data.
2214 2214
 	 */
2215
-	do_action( 'edit_comment', $comment_ID, $data );
2215
+	do_action('edit_comment', $comment_ID, $data);
2216 2216
 	$comment = get_comment($comment_ID);
2217 2217
 	wp_transition_comment_status($comment->comment_approved, $old_status, $comment);
2218 2218
 	return $rval;
@@ -2232,14 +2232,14 @@  discard block
 block discarded – undo
2232 2232
  * @param bool $defer
2233 2233
  * @return bool
2234 2234
  */
2235
-function wp_defer_comment_counting($defer=null) {
2235
+function wp_defer_comment_counting($defer = null) {
2236 2236
 	static $_defer = false;
2237 2237
 
2238
-	if ( is_bool($defer) ) {
2238
+	if (is_bool($defer)) {
2239 2239
 		$_defer = $defer;
2240 2240
 		// flush any deferred counts
2241
-		if ( !$defer )
2242
-			wp_update_comment_count( null, true );
2241
+		if ( ! $defer)
2242
+			wp_update_comment_count(null, true);
2243 2243
 	}
2244 2244
 
2245 2245
 	return $_defer;
@@ -2267,26 +2267,26 @@  discard block
 block discarded – undo
2267 2267
  * @return bool|void True on success, false on failure or if post with ID does
2268 2268
  *                   not exist.
2269 2269
  */
2270
-function wp_update_comment_count($post_id, $do_deferred=false) {
2270
+function wp_update_comment_count($post_id, $do_deferred = false) {
2271 2271
 	static $_deferred = array();
2272 2272
 
2273
-	if ( empty( $post_id ) && ! $do_deferred ) {
2273
+	if (empty($post_id) && ! $do_deferred) {
2274 2274
 		return false;
2275 2275
 	}
2276 2276
 
2277
-	if ( $do_deferred ) {
2277
+	if ($do_deferred) {
2278 2278
 		$_deferred = array_unique($_deferred);
2279
-		foreach ( $_deferred as $i => $_post_id ) {
2279
+		foreach ($_deferred as $i => $_post_id) {
2280 2280
 			wp_update_comment_count_now($_post_id);
2281
-			unset( $_deferred[$i] ); /** @todo Move this outside of the foreach and reset $_deferred to an array instead */
2281
+			unset($_deferred[$i]); /** @todo Move this outside of the foreach and reset $_deferred to an array instead */
2282 2282
 		}
2283 2283
 	}
2284 2284
 
2285
-	if ( wp_defer_comment_counting() ) {
2285
+	if (wp_defer_comment_counting()) {
2286 2286
 		$_deferred[] = $post_id;
2287 2287
 		return true;
2288 2288
 	}
2289
-	elseif ( $post_id ) {
2289
+	elseif ($post_id) {
2290 2290
 		return wp_update_comment_count_now($post_id);
2291 2291
 	}
2292 2292
 
@@ -2305,13 +2305,13 @@  discard block
 block discarded – undo
2305 2305
 function wp_update_comment_count_now($post_id) {
2306 2306
 	global $wpdb;
2307 2307
 	$post_id = (int) $post_id;
2308
-	if ( !$post_id )
2308
+	if ( ! $post_id)
2309 2309
 		return false;
2310 2310
 
2311
-	wp_cache_delete( 'comments-0', 'counts' );
2312
-	wp_cache_delete( "comments-{$post_id}", 'counts' );
2311
+	wp_cache_delete('comments-0', 'counts');
2312
+	wp_cache_delete("comments-{$post_id}", 'counts');
2313 2313
 
2314
-	if ( !$post = get_post($post_id) )
2314
+	if ( ! $post = get_post($post_id))
2315 2315
 		return false;
2316 2316
 
2317 2317
 	$old = (int) $post->comment_count;
@@ -2325,17 +2325,17 @@  discard block
 block discarded – undo
2325 2325
 	 * @param int $old     The old comment count.
2326 2326
 	 * @param int $post_id Post ID.
2327 2327
 	 */
2328
-	$new = apply_filters( 'pre_wp_update_comment_count_now', null, $old, $post_id );
2328
+	$new = apply_filters('pre_wp_update_comment_count_now', null, $old, $post_id);
2329 2329
 
2330
-	if ( is_null( $new ) ) {
2331
-		$new = (int) $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(*) FROM $wpdb->comments WHERE comment_post_ID = %d AND comment_approved = '1'", $post_id ) );
2330
+	if (is_null($new)) {
2331
+		$new = (int) $wpdb->get_var($wpdb->prepare("SELECT COUNT(*) FROM $wpdb->comments WHERE comment_post_ID = %d AND comment_approved = '1'", $post_id));
2332 2332
 	} else {
2333 2333
 		$new = (int) $new;
2334 2334
 	}
2335 2335
 
2336
-	$wpdb->update( $wpdb->posts, array('comment_count' => $new), array('ID' => $post_id) );
2336
+	$wpdb->update($wpdb->posts, array('comment_count' => $new), array('ID' => $post_id));
2337 2337
 
2338
-	clean_post_cache( $post );
2338
+	clean_post_cache($post);
2339 2339
 
2340 2340
 	/**
2341 2341
 	 * Fires immediately after a post's comment count is updated in the database.
@@ -2346,9 +2346,9 @@  discard block
 block discarded – undo
2346 2346
 	 * @param int $new     The new comment count.
2347 2347
 	 * @param int $old     The old comment count.
2348 2348
 	 */
2349
-	do_action( 'wp_update_comment_count', $post_id, $new, $old );
2349
+	do_action('wp_update_comment_count', $post_id, $new, $old);
2350 2350
 	/** This action is documented in wp-includes/post.php */
2351
-	do_action( 'edit_post', $post_id, $post );
2351
+	do_action('edit_post', $post_id, $post);
2352 2352
 
2353 2353
 	return true;
2354 2354
 }
@@ -2370,9 +2370,9 @@  discard block
 block discarded – undo
2370 2370
  * @param int $deprecated Not Used.
2371 2371
  * @return false|string False on failure, string containing URI on success.
2372 2372
  */
2373
-function discover_pingback_server_uri( $url, $deprecated = '' ) {
2374
-	if ( !empty( $deprecated ) )
2375
-		_deprecated_argument( __FUNCTION__, '2.7.0' );
2373
+function discover_pingback_server_uri($url, $deprecated = '') {
2374
+	if ( ! empty($deprecated))
2375
+		_deprecated_argument(__FUNCTION__, '2.7.0');
2376 2376
 
2377 2377
 	$pingback_str_dquote = 'rel="pingback"';
2378 2378
 	$pingback_str_squote = 'rel=\'pingback\'';
@@ -2380,47 +2380,47 @@  discard block
 block discarded – undo
2380 2380
 	/** @todo Should use Filter Extension or custom preg_match instead. */
2381 2381
 	$parsed_url = parse_url($url);
2382 2382
 
2383
-	if ( ! isset( $parsed_url['host'] ) ) // Not a URL. This should never happen.
2383
+	if ( ! isset($parsed_url['host'])) // Not a URL. This should never happen.
2384 2384
 		return false;
2385 2385
 
2386 2386
 	//Do not search for a pingback server on our own uploads
2387 2387
 	$uploads_dir = wp_get_upload_dir();
2388
-	if ( 0 === strpos($url, $uploads_dir['baseurl']) )
2388
+	if (0 === strpos($url, $uploads_dir['baseurl']))
2389 2389
 		return false;
2390 2390
 
2391
-	$response = wp_safe_remote_head( $url, array( 'timeout' => 2, 'httpversion' => '1.0' ) );
2391
+	$response = wp_safe_remote_head($url, array('timeout' => 2, 'httpversion' => '1.0'));
2392 2392
 
2393
-	if ( is_wp_error( $response ) )
2393
+	if (is_wp_error($response))
2394 2394
 		return false;
2395 2395
 
2396
-	if ( wp_remote_retrieve_header( $response, 'x-pingback' ) )
2397
-		return wp_remote_retrieve_header( $response, 'x-pingback' );
2396
+	if (wp_remote_retrieve_header($response, 'x-pingback'))
2397
+		return wp_remote_retrieve_header($response, 'x-pingback');
2398 2398
 
2399 2399
 	// Not an (x)html, sgml, or xml page, no use going further.
2400
-	if ( preg_match('#(image|audio|video|model)/#is', wp_remote_retrieve_header( $response, 'content-type' )) )
2400
+	if (preg_match('#(image|audio|video|model)/#is', wp_remote_retrieve_header($response, 'content-type')))
2401 2401
 		return false;
2402 2402
 
2403 2403
 	// Now do a GET since we're going to look in the html headers (and we're sure it's not a binary file)
2404
-	$response = wp_safe_remote_get( $url, array( 'timeout' => 2, 'httpversion' => '1.0' ) );
2404
+	$response = wp_safe_remote_get($url, array('timeout' => 2, 'httpversion' => '1.0'));
2405 2405
 
2406
-	if ( is_wp_error( $response ) )
2406
+	if (is_wp_error($response))
2407 2407
 		return false;
2408 2408
 
2409
-	$contents = wp_remote_retrieve_body( $response );
2409
+	$contents = wp_remote_retrieve_body($response);
2410 2410
 
2411 2411
 	$pingback_link_offset_dquote = strpos($contents, $pingback_str_dquote);
2412 2412
 	$pingback_link_offset_squote = strpos($contents, $pingback_str_squote);
2413
-	if ( $pingback_link_offset_dquote || $pingback_link_offset_squote ) {
2413
+	if ($pingback_link_offset_dquote || $pingback_link_offset_squote) {
2414 2414
 		$quote = ($pingback_link_offset_dquote) ? '"' : '\'';
2415
-		$pingback_link_offset = ($quote=='"') ? $pingback_link_offset_dquote : $pingback_link_offset_squote;
2415
+		$pingback_link_offset = ($quote == '"') ? $pingback_link_offset_dquote : $pingback_link_offset_squote;
2416 2416
 		$pingback_href_pos = @strpos($contents, 'href=', $pingback_link_offset);
2417
-		$pingback_href_start = $pingback_href_pos+6;
2417
+		$pingback_href_start = $pingback_href_pos + 6;
2418 2418
 		$pingback_href_end = @strpos($contents, $quote, $pingback_href_start);
2419 2419
 		$pingback_server_url_len = $pingback_href_end - $pingback_href_start;
2420 2420
 		$pingback_server_url = substr($contents, $pingback_href_start, $pingback_server_url_len);
2421 2421
 
2422 2422
 		// We may find rel="pingback" but an incomplete pingback URL
2423
-		if ( $pingback_server_url_len > 0 ) { // We got it!
2423
+		if ($pingback_server_url_len > 0) { // We got it!
2424 2424
 			return $pingback_server_url;
2425 2425
 		}
2426 2426
 	}
@@ -2440,20 +2440,20 @@  discard block
 block discarded – undo
2440 2440
 
2441 2441
 	// Do pingbacks
2442 2442
 	while ($ping = $wpdb->get_row("SELECT ID, post_content, meta_id FROM {$wpdb->posts}, {$wpdb->postmeta} WHERE {$wpdb->posts}.ID = {$wpdb->postmeta}.post_id AND {$wpdb->postmeta}.meta_key = '_pingme' LIMIT 1")) {
2443
-		delete_metadata_by_mid( 'post', $ping->meta_id );
2444
-		pingback( $ping->post_content, $ping->ID );
2443
+		delete_metadata_by_mid('post', $ping->meta_id);
2444
+		pingback($ping->post_content, $ping->ID);
2445 2445
 	}
2446 2446
 
2447 2447
 	// Do Enclosures
2448 2448
 	while ($enclosure = $wpdb->get_row("SELECT ID, post_content, meta_id FROM {$wpdb->posts}, {$wpdb->postmeta} WHERE {$wpdb->posts}.ID = {$wpdb->postmeta}.post_id AND {$wpdb->postmeta}.meta_key = '_encloseme' LIMIT 1")) {
2449
-		delete_metadata_by_mid( 'post', $enclosure->meta_id );
2450
-		do_enclose( $enclosure->post_content, $enclosure->ID );
2449
+		delete_metadata_by_mid('post', $enclosure->meta_id);
2450
+		do_enclose($enclosure->post_content, $enclosure->ID);
2451 2451
 	}
2452 2452
 
2453 2453
 	// Do Trackbacks
2454 2454
 	$trackbacks = $wpdb->get_col("SELECT ID FROM $wpdb->posts WHERE to_ping <> '' AND post_status = 'publish'");
2455
-	if ( is_array($trackbacks) )
2456
-		foreach ( $trackbacks as $trackback )
2455
+	if (is_array($trackbacks))
2456
+		foreach ($trackbacks as $trackback)
2457 2457
 			do_trackbacks($trackback);
2458 2458
 
2459 2459
 	//Do Update Services/Generic Pings
@@ -2470,44 +2470,44 @@  discard block
 block discarded – undo
2470 2470
  *
2471 2471
  * @param int|WP_Post $post_id Post object or ID to do trackbacks on.
2472 2472
  */
2473
-function do_trackbacks( $post_id ) {
2473
+function do_trackbacks($post_id) {
2474 2474
 	global $wpdb;
2475
-	$post = get_post( $post_id );
2476
-	if ( ! $post ) {
2475
+	$post = get_post($post_id);
2476
+	if ( ! $post) {
2477 2477
 		return false;
2478 2478
 	}
2479 2479
 
2480
-	$to_ping = get_to_ping( $post );
2481
-	$pinged  = get_pung( $post );
2482
-	if ( empty( $to_ping ) ) {
2483
-		$wpdb->update($wpdb->posts, array( 'to_ping' => '' ), array( 'ID' => $post->ID ) );
2480
+	$to_ping = get_to_ping($post);
2481
+	$pinged  = get_pung($post);
2482
+	if (empty($to_ping)) {
2483
+		$wpdb->update($wpdb->posts, array('to_ping' => ''), array('ID' => $post->ID));
2484 2484
 		return;
2485 2485
 	}
2486 2486
 
2487
-	if ( empty($post->post_excerpt) ) {
2487
+	if (empty($post->post_excerpt)) {
2488 2488
 		/** This filter is documented in wp-includes/post-template.php */
2489
-		$excerpt = apply_filters( 'the_content', $post->post_content, $post->ID );
2489
+		$excerpt = apply_filters('the_content', $post->post_content, $post->ID);
2490 2490
 	} else {
2491 2491
 		/** This filter is documented in wp-includes/post-template.php */
2492
-		$excerpt = apply_filters( 'the_excerpt', $post->post_excerpt );
2492
+		$excerpt = apply_filters('the_excerpt', $post->post_excerpt);
2493 2493
 	}
2494 2494
 
2495 2495
 	$excerpt = str_replace(']]>', ']]&gt;', $excerpt);
2496 2496
 	$excerpt = wp_html_excerpt($excerpt, 252, '&#8230;');
2497 2497
 
2498 2498
 	/** This filter is documented in wp-includes/post-template.php */
2499
-	$post_title = apply_filters( 'the_title', $post->post_title, $post->ID );
2499
+	$post_title = apply_filters('the_title', $post->post_title, $post->ID);
2500 2500
 	$post_title = strip_tags($post_title);
2501 2501
 
2502
-	if ( $to_ping ) {
2503
-		foreach ( (array) $to_ping as $tb_ping ) {
2502
+	if ($to_ping) {
2503
+		foreach ((array) $to_ping as $tb_ping) {
2504 2504
 			$tb_ping = trim($tb_ping);
2505
-			if ( !in_array($tb_ping, $pinged) ) {
2506
-				trackback( $tb_ping, $post_title, $excerpt, $post->ID );
2505
+			if ( ! in_array($tb_ping, $pinged)) {
2506
+				trackback($tb_ping, $post_title, $excerpt, $post->ID);
2507 2507
 				$pinged[] = $tb_ping;
2508 2508
 			} else {
2509
-				$wpdb->query( $wpdb->prepare( "UPDATE $wpdb->posts SET to_ping = TRIM(REPLACE(to_ping, %s,
2510
-					'')) WHERE ID = %d", $tb_ping, $post->ID ) );
2509
+				$wpdb->query($wpdb->prepare("UPDATE $wpdb->posts SET to_ping = TRIM(REPLACE(to_ping, %s,
2510
+					'')) WHERE ID = %d", $tb_ping, $post->ID));
2511 2511
 			}
2512 2512
 		}
2513 2513
 	}
@@ -2521,13 +2521,13 @@  discard block
 block discarded – undo
2521 2521
  * @param int $post_id Post ID.
2522 2522
  * @return int Same as Post ID from parameter
2523 2523
  */
2524
-function generic_ping( $post_id = 0 ) {
2524
+function generic_ping($post_id = 0) {
2525 2525
 	$services = get_option('ping_sites');
2526 2526
 
2527 2527
 	$services = explode("\n", $services);
2528
-	foreach ( (array) $services as $service ) {
2528
+	foreach ((array) $services as $service) {
2529 2529
 		$service = trim($service);
2530
-		if ( '' != $service )
2530
+		if ('' != $service)
2531 2531
 			weblog_ping($service);
2532 2532
 	}
2533 2533
 
@@ -2543,27 +2543,27 @@  discard block
 block discarded – undo
2543 2543
  * @param string $content Post content to check for links. If empty will retrieve from post.
2544 2544
  * @param int|WP_Post $post_id Post Object or ID.
2545 2545
  */
2546
-function pingback( $content, $post_id ) {
2547
-	include_once( ABSPATH . WPINC . '/class-IXR.php' );
2548
-	include_once( ABSPATH . WPINC . '/class-wp-http-ixr-client.php' );
2546
+function pingback($content, $post_id) {
2547
+	include_once(ABSPATH.WPINC.'/class-IXR.php');
2548
+	include_once(ABSPATH.WPINC.'/class-wp-http-ixr-client.php');
2549 2549
 
2550 2550
 	// original code by Mort (http://mort.mine.nu:8080)
2551 2551
 	$post_links = array();
2552 2552
 
2553
-	$post = get_post( $post_id );
2554
-	if ( ! $post ) {
2553
+	$post = get_post($post_id);
2554
+	if ( ! $post) {
2555 2555
 		return;
2556 2556
 	}
2557 2557
 
2558
-	$pung = get_pung( $post );
2558
+	$pung = get_pung($post);
2559 2559
 
2560
-	if ( empty( $content ) ) {
2560
+	if (empty($content)) {
2561 2561
 		$content = $post->post_content;
2562 2562
 	}
2563 2563
 
2564 2564
 	// Step 1
2565 2565
 	// Parsing the post, external links (if any) are stored in the $post_links array
2566
-	$post_links_temp = wp_extract_urls( $content );
2566
+	$post_links_temp = wp_extract_urls($content);
2567 2567
 
2568 2568
 	// Step 2.
2569 2569
 	// Walking thru the links array
@@ -2574,19 +2574,19 @@  discard block
 block discarded – undo
2574 2574
 	// http://dummy-weblog.org/post.php
2575 2575
 	// We don't wanna ping first and second types, even if they have a valid <link/>
2576 2576
 
2577
-	foreach ( (array) $post_links_temp as $link_test ) :
2578
-		if ( ! in_array( $link_test, $pung ) && ( url_to_postid( $link_test ) != $post->ID ) // If we haven't pung it already and it isn't a link to itself
2579
-				&& !is_local_attachment($link_test) ) : // Also, let's never ping local attachments.
2580
-			if ( $test = @parse_url($link_test) ) {
2581
-				if ( isset($test['query']) )
2577
+	foreach ((array) $post_links_temp as $link_test) :
2578
+		if ( ! in_array($link_test, $pung) && (url_to_postid($link_test) != $post->ID) // If we haven't pung it already and it isn't a link to itself
2579
+				&& ! is_local_attachment($link_test)) : // Also, let's never ping local attachments.
2580
+			if ($test = @parse_url($link_test)) {
2581
+				if (isset($test['query']))
2582 2582
 					$post_links[] = $link_test;
2583
-				elseif ( isset( $test['path'] ) && ( $test['path'] != '/' ) && ( $test['path'] != '' ) )
2583
+				elseif (isset($test['path']) && ($test['path'] != '/') && ($test['path'] != ''))
2584 2584
 					$post_links[] = $link_test;
2585 2585
 			}
2586 2586
 		endif;
2587 2587
 	endforeach;
2588 2588
 
2589
-	$post_links = array_unique( $post_links );
2589
+	$post_links = array_unique($post_links);
2590 2590
 	/**
2591 2591
 	 * Fires just before pinging back links found in a post.
2592 2592
 	 *
@@ -2596,15 +2596,15 @@  discard block
 block discarded – undo
2596 2596
 	 * @param array &$pung       Whether a link has already been pinged, passed by reference.
2597 2597
 	 * @param int   $post_ID     The post ID.
2598 2598
 	 */
2599
-	do_action_ref_array( 'pre_ping', array( &$post_links, &$pung, $post->ID ) );
2599
+	do_action_ref_array('pre_ping', array(&$post_links, &$pung, $post->ID));
2600 2600
 
2601
-	foreach ( (array) $post_links as $pagelinkedto ) {
2602
-		$pingback_server_url = discover_pingback_server_uri( $pagelinkedto );
2601
+	foreach ((array) $post_links as $pagelinkedto) {
2602
+		$pingback_server_url = discover_pingback_server_uri($pagelinkedto);
2603 2603
 
2604
-		if ( $pingback_server_url ) {
2605
-			@ set_time_limit( 60 );
2604
+		if ($pingback_server_url) {
2605
+			@ set_time_limit(60);
2606 2606
 			// Now, the RPC call
2607
-			$pagelinkedfrom = get_permalink( $post );
2607
+			$pagelinkedfrom = get_permalink($post);
2608 2608
 
2609 2609
 			// using a timeout of 3 seconds should be enough to cover slow servers
2610 2610
 			$client = new WP_HTTP_IXR_Client($pingback_server_url);
@@ -2621,12 +2621,12 @@  discard block
 block discarded – undo
2621 2621
 			 * @param string $pagelinkedto        URL of page linked to.
2622 2622
 			 * @param string $pagelinkedfrom      URL of page linked from.
2623 2623
 			 */
2624
-			$client->useragent = apply_filters( 'pingback_useragent', $client->useragent . ' -- WordPress/' . get_bloginfo( 'version' ), $client->useragent, $pingback_server_url, $pagelinkedto, $pagelinkedfrom );
2624
+			$client->useragent = apply_filters('pingback_useragent', $client->useragent.' -- WordPress/'.get_bloginfo('version'), $client->useragent, $pingback_server_url, $pagelinkedto, $pagelinkedfrom);
2625 2625
 			// when set to true, this outputs debug messages by itself
2626 2626
 			$client->debug = false;
2627 2627
 
2628
-			if ( $client->query('pingback.ping', $pagelinkedfrom, $pagelinkedto) || ( isset($client->error->code) && 48 == $client->error->code ) ) // Already registered
2629
-				add_ping( $post, $pagelinkedto );
2628
+			if ($client->query('pingback.ping', $pagelinkedfrom, $pagelinkedto) || (isset($client->error->code) && 48 == $client->error->code)) // Already registered
2629
+				add_ping($post, $pagelinkedto);
2630 2630
 		}
2631 2631
 	}
2632 2632
 }
@@ -2640,7 +2640,7 @@  discard block
 block discarded – undo
2640 2640
  * @return mixed Empty string if blog is not public, returns $sites, if site is public.
2641 2641
  */
2642 2642
 function privacy_ping_filter($sites) {
2643
-	if ( '0' != get_option('blog_public') )
2643
+	if ('0' != get_option('blog_public'))
2644 2644
 		return $sites;
2645 2645
 	else
2646 2646
 		return '';
@@ -2664,7 +2664,7 @@  discard block
 block discarded – undo
2664 2664
 function trackback($trackback_url, $title, $excerpt, $ID) {
2665 2665
 	global $wpdb;
2666 2666
 
2667
-	if ( empty($trackback_url) )
2667
+	if (empty($trackback_url))
2668 2668
 		return;
2669 2669
 
2670 2670
 	$options = array();
@@ -2676,13 +2676,13 @@  discard block
 block discarded – undo
2676 2676
 		'excerpt' => $excerpt
2677 2677
 	);
2678 2678
 
2679
-	$response = wp_safe_remote_post( $trackback_url, $options );
2679
+	$response = wp_safe_remote_post($trackback_url, $options);
2680 2680
 
2681
-	if ( is_wp_error( $response ) )
2681
+	if (is_wp_error($response))
2682 2682
 		return;
2683 2683
 
2684
-	$wpdb->query( $wpdb->prepare("UPDATE $wpdb->posts SET pinged = CONCAT(pinged, '\n', %s) WHERE ID = %d", $trackback_url, $ID) );
2685
-	return $wpdb->query( $wpdb->prepare("UPDATE $wpdb->posts SET to_ping = TRIM(REPLACE(to_ping, %s, '')) WHERE ID = %d", $trackback_url, $ID) );
2684
+	$wpdb->query($wpdb->prepare("UPDATE $wpdb->posts SET pinged = CONCAT(pinged, '\n', %s) WHERE ID = %d", $trackback_url, $ID));
2685
+	return $wpdb->query($wpdb->prepare("UPDATE $wpdb->posts SET to_ping = TRIM(REPLACE(to_ping, %s, '')) WHERE ID = %d", $trackback_url, $ID));
2686 2686
 }
2687 2687
 
2688 2688
 /**
@@ -2694,18 +2694,18 @@  discard block
 block discarded – undo
2694 2694
  * @param string $path Path to send the ping.
2695 2695
  */
2696 2696
 function weblog_ping($server = '', $path = '') {
2697
-	include_once( ABSPATH . WPINC . '/class-IXR.php' );
2698
-	include_once( ABSPATH . WPINC . '/class-wp-http-ixr-client.php' );
2697
+	include_once(ABSPATH.WPINC.'/class-IXR.php');
2698
+	include_once(ABSPATH.WPINC.'/class-wp-http-ixr-client.php');
2699 2699
 
2700 2700
 	// using a timeout of 3 seconds should be enough to cover slow servers
2701
-	$client = new WP_HTTP_IXR_Client($server, ((!strlen(trim($path)) || ('/' == $path)) ? false : $path));
2701
+	$client = new WP_HTTP_IXR_Client($server, (( ! strlen(trim($path)) || ('/' == $path)) ? false : $path));
2702 2702
 	$client->timeout = 3;
2703
-	$client->useragent .= ' -- WordPress/' . get_bloginfo( 'version' );
2703
+	$client->useragent .= ' -- WordPress/'.get_bloginfo('version');
2704 2704
 
2705 2705
 	// when set to true, this outputs debug messages by itself
2706 2706
 	$client->debug = false;
2707
-	$home = trailingslashit( home_url() );
2708
-	if ( !$client->query('weblogUpdates.extendedPing', get_option('blogname'), $home, get_bloginfo('rss2_url') ) ) // then try a normal ping
2707
+	$home = trailingslashit(home_url());
2708
+	if ( ! $client->query('weblogUpdates.extendedPing', get_option('blogname'), $home, get_bloginfo('rss2_url'))) // then try a normal ping
2709 2709
 		$client->query('weblogUpdates.ping', get_option('blogname'), $home);
2710 2710
 }
2711 2711
 
@@ -2718,8 +2718,8 @@  discard block
 block discarded – undo
2718 2718
  * @param string $source_uri
2719 2719
  * @return string
2720 2720
  */
2721
-function pingback_ping_source_uri( $source_uri ) {
2722
-	return (string) wp_http_validate_url( $source_uri );
2721
+function pingback_ping_source_uri($source_uri) {
2722
+	return (string) wp_http_validate_url($source_uri);
2723 2723
 }
2724 2724
 
2725 2725
 /**
@@ -2734,10 +2734,10 @@  discard block
 block discarded – undo
2734 2734
  * @param IXR_Error $ixr_error
2735 2735
  * @return IXR_Error
2736 2736
  */
2737
-function xmlrpc_pingback_error( $ixr_error ) {
2738
-	if ( $ixr_error->code === 48 )
2737
+function xmlrpc_pingback_error($ixr_error) {
2738
+	if ($ixr_error->code === 48)
2739 2739
 		return $ixr_error;
2740
-	return new IXR_Error( 0, '' );
2740
+	return new IXR_Error(0, '');
2741 2741
 }
2742 2742
 
2743 2743
 //
@@ -2752,8 +2752,8 @@  discard block
 block discarded – undo
2752 2752
  * @param int|array $ids Comment ID or an array of comment IDs to remove from cache.
2753 2753
  */
2754 2754
 function clean_comment_cache($ids) {
2755
-	foreach ( (array) $ids as $id ) {
2756
-		wp_cache_delete( $id, 'comment' );
2755
+	foreach ((array) $ids as $id) {
2756
+		wp_cache_delete($id, 'comment');
2757 2757
 
2758 2758
 		/**
2759 2759
 		 * Fires immediately after a comment has been removed from the object cache.
@@ -2762,10 +2762,10 @@  discard block
 block discarded – undo
2762 2762
 		 *
2763 2763
 		 * @param int $id Comment ID.
2764 2764
 		 */
2765
-		do_action( 'clean_comment_cache', $id );
2765
+		do_action('clean_comment_cache', $id);
2766 2766
 	}
2767 2767
 
2768
-	wp_cache_set( 'last_changed', microtime(), 'comment' );
2768
+	wp_cache_set('last_changed', microtime(), 'comment');
2769 2769
 }
2770 2770
 
2771 2771
 /**
@@ -2781,17 +2781,17 @@  discard block
 block discarded – undo
2781 2781
  * @param array $comments          Array of comment row objects
2782 2782
  * @param bool  $update_meta_cache Whether to update commentmeta cache. Default true.
2783 2783
  */
2784
-function update_comment_cache( $comments, $update_meta_cache = true ) {
2785
-	foreach ( (array) $comments as $comment )
2784
+function update_comment_cache($comments, $update_meta_cache = true) {
2785
+	foreach ((array) $comments as $comment)
2786 2786
 		wp_cache_add($comment->comment_ID, $comment, 'comment');
2787 2787
 
2788
-	if ( $update_meta_cache ) {
2788
+	if ($update_meta_cache) {
2789 2789
 		// Avoid `wp_list_pluck()` in case `$comments` is passed by reference.
2790 2790
 		$comment_ids = array();
2791
-		foreach ( $comments as $comment ) {
2791
+		foreach ($comments as $comment) {
2792 2792
 			$comment_ids[] = $comment->comment_ID;
2793 2793
 		}
2794
-		update_meta_cache( 'comment', $comment_ids );
2794
+		update_meta_cache('comment', $comment_ids);
2795 2795
 	}
2796 2796
 }
2797 2797
 
@@ -2807,14 +2807,14 @@  discard block
 block discarded – undo
2807 2807
  * @param array $comment_ids       Array of comment IDs.
2808 2808
  * @param bool  $update_meta_cache Optional. Whether to update the meta cache. Default true.
2809 2809
  */
2810
-function _prime_comment_caches( $comment_ids, $update_meta_cache = true ) {
2810
+function _prime_comment_caches($comment_ids, $update_meta_cache = true) {
2811 2811
 	global $wpdb;
2812 2812
 
2813
-	$non_cached_ids = _get_non_cached_ids( $comment_ids, 'comment' );
2814
-	if ( !empty( $non_cached_ids ) ) {
2815
-		$fresh_comments = $wpdb->get_results( sprintf( "SELECT $wpdb->comments.* FROM $wpdb->comments WHERE comment_ID IN (%s)", join( ",", array_map( 'intval', $non_cached_ids ) ) ) );
2813
+	$non_cached_ids = _get_non_cached_ids($comment_ids, 'comment');
2814
+	if ( ! empty($non_cached_ids)) {
2815
+		$fresh_comments = $wpdb->get_results(sprintf("SELECT $wpdb->comments.* FROM $wpdb->comments WHERE comment_ID IN (%s)", join(",", array_map('intval', $non_cached_ids))));
2816 2816
 
2817
-		update_comment_cache( $fresh_comments, $update_meta_cache );
2817
+		update_comment_cache($fresh_comments, $update_meta_cache);
2818 2818
 	}
2819 2819
 }
2820 2820
 
@@ -2832,8 +2832,8 @@  discard block
 block discarded – undo
2832 2832
  * @param WP_Query $query Query object.
2833 2833
  * @return array
2834 2834
  */
2835
-function _close_comments_for_old_posts( $posts, $query ) {
2836
-	if ( empty( $posts ) || ! $query->is_singular() || ! get_option( 'close_comments_for_old_posts' ) )
2835
+function _close_comments_for_old_posts($posts, $query) {
2836
+	if (empty($posts) || ! $query->is_singular() || ! get_option('close_comments_for_old_posts'))
2837 2837
 		return $posts;
2838 2838
 
2839 2839
 	/**
@@ -2843,15 +2843,15 @@  discard block
 block discarded – undo
2843 2843
 	 *
2844 2844
 	 * @param array $post_types An array of registered post types. Default array with 'post'.
2845 2845
 	 */
2846
-	$post_types = apply_filters( 'close_comments_for_post_types', array( 'post' ) );
2847
-	if ( ! in_array( $posts[0]->post_type, $post_types ) )
2846
+	$post_types = apply_filters('close_comments_for_post_types', array('post'));
2847
+	if ( ! in_array($posts[0]->post_type, $post_types))
2848 2848
 		return $posts;
2849 2849
 
2850
-	$days_old = (int) get_option( 'close_comments_days_old' );
2851
-	if ( ! $days_old )
2850
+	$days_old = (int) get_option('close_comments_days_old');
2851
+	if ( ! $days_old)
2852 2852
 		return $posts;
2853 2853
 
2854
-	if ( time() - strtotime( $posts[0]->post_date_gmt ) > ( $days_old * DAY_IN_SECONDS ) ) {
2854
+	if (time() - strtotime($posts[0]->post_date_gmt) > ($days_old * DAY_IN_SECONDS)) {
2855 2855
 		$posts[0]->comment_status = 'closed';
2856 2856
 		$posts[0]->ping_status = 'closed';
2857 2857
 	}
@@ -2869,30 +2869,30 @@  discard block
 block discarded – undo
2869 2869
  * @param int $post_id Post ID
2870 2870
  * @return bool $open
2871 2871
  */
2872
-function _close_comments_for_old_post( $open, $post_id ) {
2873
-	if ( ! $open )
2872
+function _close_comments_for_old_post($open, $post_id) {
2873
+	if ( ! $open)
2874 2874
 		return $open;
2875 2875
 
2876
-	if ( !get_option('close_comments_for_old_posts') )
2876
+	if ( ! get_option('close_comments_for_old_posts'))
2877 2877
 		return $open;
2878 2878
 
2879 2879
 	$days_old = (int) get_option('close_comments_days_old');
2880
-	if ( !$days_old )
2880
+	if ( ! $days_old)
2881 2881
 		return $open;
2882 2882
 
2883 2883
 	$post = get_post($post_id);
2884 2884
 
2885 2885
 	/** This filter is documented in wp-includes/comment.php */
2886
-	$post_types = apply_filters( 'close_comments_for_post_types', array( 'post' ) );
2887
-	if ( ! in_array( $post->post_type, $post_types ) )
2886
+	$post_types = apply_filters('close_comments_for_post_types', array('post'));
2887
+	if ( ! in_array($post->post_type, $post_types))
2888 2888
 		return $open;
2889 2889
 
2890 2890
 	// Undated drafts should not show up as comments closed.
2891
-	if ( '0000-00-00 00:00:00' === $post->post_date_gmt ) {
2891
+	if ('0000-00-00 00:00:00' === $post->post_date_gmt) {
2892 2892
 		return $open;
2893 2893
 	}
2894 2894
 
2895
-	if ( time() - strtotime( $post->post_date_gmt ) > ( $days_old * DAY_IN_SECONDS ) )
2895
+	if (time() - strtotime($post->post_date_gmt) > ($days_old * DAY_IN_SECONDS))
2896 2896
 		return false;
2897 2897
 
2898 2898
 	return $open;
@@ -2919,33 +2919,33 @@  discard block
 block discarded – undo
2919 2919
  * }
2920 2920
  * @return WP_Comment|WP_Error A WP_Comment object on success, a WP_Error object on failure.
2921 2921
  */
2922
-function wp_handle_comment_submission( $comment_data ) {
2922
+function wp_handle_comment_submission($comment_data) {
2923 2923
 
2924 2924
 	$comment_post_ID = $comment_parent = 0;
2925 2925
 	$comment_author = $comment_author_email = $comment_author_url = $comment_content = null;
2926 2926
 
2927
-	if ( isset( $comment_data['comment_post_ID'] ) ) {
2927
+	if (isset($comment_data['comment_post_ID'])) {
2928 2928
 		$comment_post_ID = (int) $comment_data['comment_post_ID'];
2929 2929
 	}
2930
-	if ( isset( $comment_data['author'] ) && is_string( $comment_data['author'] ) ) {
2931
-		$comment_author = trim( strip_tags( $comment_data['author'] ) );
2930
+	if (isset($comment_data['author']) && is_string($comment_data['author'])) {
2931
+		$comment_author = trim(strip_tags($comment_data['author']));
2932 2932
 	}
2933
-	if ( isset( $comment_data['email'] ) && is_string( $comment_data['email'] ) ) {
2934
-		$comment_author_email = trim( $comment_data['email'] );
2933
+	if (isset($comment_data['email']) && is_string($comment_data['email'])) {
2934
+		$comment_author_email = trim($comment_data['email']);
2935 2935
 	}
2936
-	if ( isset( $comment_data['url'] ) && is_string( $comment_data['url'] ) ) {
2937
-		$comment_author_url = trim( $comment_data['url'] );
2936
+	if (isset($comment_data['url']) && is_string($comment_data['url'])) {
2937
+		$comment_author_url = trim($comment_data['url']);
2938 2938
 	}
2939
-	if ( isset( $comment_data['comment'] ) && is_string( $comment_data['comment'] ) ) {
2940
-		$comment_content = trim( $comment_data['comment'] );
2939
+	if (isset($comment_data['comment']) && is_string($comment_data['comment'])) {
2940
+		$comment_content = trim($comment_data['comment']);
2941 2941
 	}
2942
-	if ( isset( $comment_data['comment_parent'] ) ) {
2943
-		$comment_parent = absint( $comment_data['comment_parent'] );
2942
+	if (isset($comment_data['comment_parent'])) {
2943
+		$comment_parent = absint($comment_data['comment_parent']);
2944 2944
 	}
2945 2945
 
2946
-	$post = get_post( $comment_post_ID );
2946
+	$post = get_post($comment_post_ID);
2947 2947
 
2948
-	if ( empty( $post->comment_status ) ) {
2948
+	if (empty($post->comment_status)) {
2949 2949
 
2950 2950
 		/**
2951 2951
 		 * Fires when a comment is attempted on a post that does not exist.
@@ -2954,22 +2954,22 @@  discard block
 block discarded – undo
2954 2954
 		 *
2955 2955
 		 * @param int $comment_post_ID Post ID.
2956 2956
 		 */
2957
-		do_action( 'comment_id_not_found', $comment_post_ID );
2957
+		do_action('comment_id_not_found', $comment_post_ID);
2958 2958
 
2959
-		return new WP_Error( 'comment_id_not_found' );
2959
+		return new WP_Error('comment_id_not_found');
2960 2960
 
2961 2961
 	}
2962 2962
 
2963 2963
 	// get_post_status() will get the parent status for attachments.
2964
-	$status = get_post_status( $post );
2964
+	$status = get_post_status($post);
2965 2965
 
2966
-	if ( ( 'private' == $status ) && ! current_user_can( 'read_post', $comment_post_ID ) ) {
2967
-		return new WP_Error( 'comment_id_not_found' );
2966
+	if (('private' == $status) && ! current_user_can('read_post', $comment_post_ID)) {
2967
+		return new WP_Error('comment_id_not_found');
2968 2968
 	}
2969 2969
 
2970
-	$status_obj = get_post_status_object( $status );
2970
+	$status_obj = get_post_status_object($status);
2971 2971
 
2972
-	if ( ! comments_open( $comment_post_ID ) ) {
2972
+	if ( ! comments_open($comment_post_ID)) {
2973 2973
 
2974 2974
 		/**
2975 2975
 		 * Fires when a comment is attempted on a post that has comments closed.
@@ -2978,11 +2978,11 @@  discard block
 block discarded – undo
2978 2978
 		 *
2979 2979
 		 * @param int $comment_post_ID Post ID.
2980 2980
 		 */
2981
-		do_action( 'comment_closed', $comment_post_ID );
2981
+		do_action('comment_closed', $comment_post_ID);
2982 2982
 
2983
-		return new WP_Error( 'comment_closed', __( 'Sorry, comments are closed for this item.' ), 403 );
2983
+		return new WP_Error('comment_closed', __('Sorry, comments are closed for this item.'), 403);
2984 2984
 
2985
-	} elseif ( 'trash' == $status ) {
2985
+	} elseif ('trash' == $status) {
2986 2986
 
2987 2987
 		/**
2988 2988
 		 * Fires when a comment is attempted on a trashed post.
@@ -2991,11 +2991,11 @@  discard block
 block discarded – undo
2991 2991
 		 *
2992 2992
 		 * @param int $comment_post_ID Post ID.
2993 2993
 		 */
2994
-		do_action( 'comment_on_trash', $comment_post_ID );
2994
+		do_action('comment_on_trash', $comment_post_ID);
2995 2995
 
2996
-		return new WP_Error( 'comment_on_trash' );
2996
+		return new WP_Error('comment_on_trash');
2997 2997
 
2998
-	} elseif ( ! $status_obj->public && ! $status_obj->private ) {
2998
+	} elseif ( ! $status_obj->public && ! $status_obj->private) {
2999 2999
 
3000 3000
 		/**
3001 3001
 		 * Fires when a comment is attempted on a post in draft mode.
@@ -3004,15 +3004,15 @@  discard block
 block discarded – undo
3004 3004
 		 *
3005 3005
 		 * @param int $comment_post_ID Post ID.
3006 3006
 		 */
3007
-		do_action( 'comment_on_draft', $comment_post_ID );
3007
+		do_action('comment_on_draft', $comment_post_ID);
3008 3008
 		
3009
-		if ( current_user_can( 'read_post', $comment_post_ID ) ) {
3010
-			return new WP_Error( 'comment_on_draft', __( 'Sorry, comments are not allowed for this item.' ), 403 );
3009
+		if (current_user_can('read_post', $comment_post_ID)) {
3010
+			return new WP_Error('comment_on_draft', __('Sorry, comments are not allowed for this item.'), 403);
3011 3011
 		} else {
3012
-			return new WP_Error( 'comment_on_draft' );
3012
+			return new WP_Error('comment_on_draft');
3013 3013
 		}
3014 3014
 
3015
-	} elseif ( post_password_required( $comment_post_ID ) ) {
3015
+	} elseif (post_password_required($comment_post_ID)) {
3016 3016
 
3017 3017
 		/**
3018 3018
 		 * Fires when a comment is attempted on a password-protected post.
@@ -3021,9 +3021,9 @@  discard block
 block discarded – undo
3021 3021
 		 *
3022 3022
 		 * @param int $comment_post_ID Post ID.
3023 3023
 		 */
3024
-		do_action( 'comment_on_password_protected', $comment_post_ID );
3024
+		do_action('comment_on_password_protected', $comment_post_ID);
3025 3025
 
3026
-		return new WP_Error( 'comment_on_password_protected' );
3026
+		return new WP_Error('comment_on_password_protected');
3027 3027
 
3028 3028
 	} else {
3029 3029
 
@@ -3034,46 +3034,46 @@  discard block
 block discarded – undo
3034 3034
 		 *
3035 3035
 		 * @param int $comment_post_ID Post ID.
3036 3036
 		 */
3037
-		do_action( 'pre_comment_on_post', $comment_post_ID );
3037
+		do_action('pre_comment_on_post', $comment_post_ID);
3038 3038
 
3039 3039
 	}
3040 3040
 
3041 3041
 	// If the user is logged in
3042 3042
 	$user = wp_get_current_user();
3043
-	if ( $user->exists() ) {
3044
-		if ( empty( $user->display_name ) ) {
3045
-			$user->display_name=$user->user_login;
3043
+	if ($user->exists()) {
3044
+		if (empty($user->display_name)) {
3045
+			$user->display_name = $user->user_login;
3046 3046
 		}
3047 3047
 		$comment_author       = $user->display_name;
3048 3048
 		$comment_author_email = $user->user_email;
3049 3049
 		$comment_author_url   = $user->user_url;
3050 3050
 		$user_ID              = $user->ID;
3051
-		if ( current_user_can( 'unfiltered_html' ) ) {
3052
-			if ( ! isset( $comment_data['_wp_unfiltered_html_comment'] )
3053
-				|| ! wp_verify_nonce( $comment_data['_wp_unfiltered_html_comment'], 'unfiltered-html-comment_' . $comment_post_ID )
3051
+		if (current_user_can('unfiltered_html')) {
3052
+			if ( ! isset($comment_data['_wp_unfiltered_html_comment'])
3053
+				|| ! wp_verify_nonce($comment_data['_wp_unfiltered_html_comment'], 'unfiltered-html-comment_'.$comment_post_ID)
3054 3054
 			) {
3055 3055
 				kses_remove_filters(); // start with a clean slate
3056 3056
 				kses_init_filters(); // set up the filters
3057 3057
 			}
3058 3058
 		}
3059 3059
 	} else {
3060
-		if ( get_option( 'comment_registration' ) ) {
3061
-			return new WP_Error( 'not_logged_in', __( 'Sorry, you must be logged in to comment.' ), 403 );
3060
+		if (get_option('comment_registration')) {
3061
+			return new WP_Error('not_logged_in', __('Sorry, you must be logged in to comment.'), 403);
3062 3062
 		}
3063 3063
 	}
3064 3064
 
3065 3065
 	$comment_type = '';
3066 3066
 
3067
-	if ( get_option( 'require_name_email' ) && ! $user->exists() ) {
3068
-		if ( '' == $comment_author_email || '' == $comment_author ) {
3069
-			return new WP_Error( 'require_name_email', __( '<strong>ERROR</strong>: please fill the required fields (name, email).' ), 200 );
3070
-		} elseif ( ! is_email( $comment_author_email ) ) {
3071
-			return new WP_Error( 'require_valid_email', __( '<strong>ERROR</strong>: please enter a valid email address.' ), 200 );
3067
+	if (get_option('require_name_email') && ! $user->exists()) {
3068
+		if ('' == $comment_author_email || '' == $comment_author) {
3069
+			return new WP_Error('require_name_email', __('<strong>ERROR</strong>: please fill the required fields (name, email).'), 200);
3070
+		} elseif ( ! is_email($comment_author_email)) {
3071
+			return new WP_Error('require_valid_email', __('<strong>ERROR</strong>: please enter a valid email address.'), 200);
3072 3072
 		}
3073 3073
 	}
3074 3074
 
3075
-	if ( '' == $comment_content ) {
3076
-		return new WP_Error( 'require_valid_comment', __( '<strong>ERROR</strong>: please type a comment.' ), 200 );
3075
+	if ('' == $comment_content) {
3076
+		return new WP_Error('require_valid_comment', __('<strong>ERROR</strong>: please type a comment.'), 200);
3077 3077
 	}
3078 3078
 
3079 3079
 	$commentdata = compact(
@@ -3087,19 +3087,19 @@  discard block
 block discarded – undo
3087 3087
 		'user_ID'
3088 3088
 	);
3089 3089
 
3090
-	$check_max_lengths = wp_check_comment_data_max_lengths( $commentdata );
3091
-	if ( is_wp_error( $check_max_lengths ) ) {
3090
+	$check_max_lengths = wp_check_comment_data_max_lengths($commentdata);
3091
+	if (is_wp_error($check_max_lengths)) {
3092 3092
 		return $check_max_lengths;
3093 3093
 	}
3094 3094
 
3095
-	$comment_id = wp_new_comment( wp_slash( $commentdata ), true );
3096
-	if ( is_wp_error( $comment_id ) ) {
3095
+	$comment_id = wp_new_comment(wp_slash($commentdata), true);
3096
+	if (is_wp_error($comment_id)) {
3097 3097
 		return $comment_id;
3098 3098
 	}
3099 3099
 
3100
-	if ( ! $comment_id ) {
3101
-		return new WP_Error( 'comment_save_error', __( '<strong>ERROR</strong>: The comment could not be saved. Please try again later.' ), 500 );
3100
+	if ( ! $comment_id) {
3101
+		return new WP_Error('comment_save_error', __('<strong>ERROR</strong>: The comment could not be saved. Please try again later.'), 500);
3102 3102
 	}
3103 3103
 
3104
-	return get_comment( $comment_id );
3104
+	return get_comment($comment_id);
3105 3105
 }
Please login to merge, or discard this patch.
Braces   +241 added lines, -157 removed lines patch added patch discarded remove patch
@@ -40,8 +40,9 @@  discard block
 block discarded – undo
40 40
 	global $wpdb;
41 41
 
42 42
 	// If manual moderation is enabled, skip all checks and return false.
43
-	if ( 1 == get_option('comment_moderation') )
44
-		return false;
43
+	if ( 1 == get_option('comment_moderation') ) {
44
+			return false;
45
+	}
45 46
 
46 47
 	/** This filter is documented in wp-includes/comment-template.php */
47 48
 	$comment = apply_filters( 'comment_text', $comment, null, array() );
@@ -66,8 +67,9 @@  discard block
 block discarded – undo
66 67
 		 * If the number of links in the comment exceeds the allowed amount,
67 68
 		 * fail the check by returning false.
68 69
 		 */
69
-		if ( $num_links >= $max_links )
70
-			return false;
70
+		if ( $num_links >= $max_links ) {
71
+					return false;
72
+		}
71 73
 	}
72 74
 
73 75
 	$mod_keys = trim(get_option('moderation_keys'));
@@ -80,8 +82,9 @@  discard block
 block discarded – undo
80 82
 			$word = trim($word);
81 83
 
82 84
 			// Skip empty lines.
83
-			if ( empty($word) )
84
-				continue;
85
+			if ( empty($word) ) {
86
+							continue;
87
+			}
85 88
 
86 89
 			/*
87 90
 			 * Do some escaping magic so that '#' (number of) characters in the spam
@@ -94,12 +97,24 @@  discard block
 block discarded – undo
94 97
 			 * fail the check for the given field by returning false.
95 98
 			 */
96 99
 			$pattern = "#$word#i";
97
-			if ( preg_match($pattern, $author) ) return false;
98
-			if ( preg_match($pattern, $email) ) return false;
99
-			if ( preg_match($pattern, $url) ) return false;
100
-			if ( preg_match($pattern, $comment) ) return false;
101
-			if ( preg_match($pattern, $user_ip) ) return false;
102
-			if ( preg_match($pattern, $user_agent) ) return false;
100
+			if ( preg_match($pattern, $author) ) {
101
+				return false;
102
+			}
103
+			if ( preg_match($pattern, $email) ) {
104
+				return false;
105
+			}
106
+			if ( preg_match($pattern, $url) ) {
107
+				return false;
108
+			}
109
+			if ( preg_match($pattern, $comment) ) {
110
+				return false;
111
+			}
112
+			if ( preg_match($pattern, $user_ip) ) {
113
+				return false;
114
+			}
115
+			if ( preg_match($pattern, $user_agent) ) {
116
+				return false;
117
+			}
103 118
 		}
104 119
 	}
105 120
 
@@ -120,10 +135,11 @@  discard block
 block discarded – undo
120 135
 				$ok_to_comment = $wpdb->get_var( $wpdb->prepare( "SELECT comment_approved FROM $wpdb->comments WHERE comment_author = %s AND comment_author_email = %s and comment_approved = '1' LIMIT 1", $author, $email ) );
121 136
 			}
122 137
 			if ( ( 1 == $ok_to_comment ) &&
123
-				( empty($mod_keys) || false === strpos( $email, $mod_keys) ) )
124
-					return true;
125
-			else
126
-				return false;
138
+				( empty($mod_keys) || false === strpos( $email, $mod_keys) ) ) {
139
+								return true;
140
+			} else {
141
+							return false;
142
+			}
127 143
 		} else {
128 144
 			return false;
129 145
 		}
@@ -516,8 +532,9 @@  discard block
 block discarded – undo
516 532
  * @since 3.4.0
517 533
  */
518 534
 function wp_set_comment_cookies($comment, $user) {
519
-	if ( $user->exists() )
520
-		return;
535
+	if ( $user->exists() ) {
536
+			return;
537
+	}
521 538
 
522 539
 	/**
523 540
 	 * Filters the lifetime of the comment cookie in seconds.
@@ -879,11 +896,13 @@  discard block
 block discarded – undo
879 896
 	$count = count($comments);
880 897
 	for ( $i = 0; $i < $count; $i++ ) {
881 898
 		$type = $comments[$i]->comment_type;
882
-		if ( empty($type) )
883
-			$type = 'comment';
899
+		if ( empty($type) ) {
900
+					$type = 'comment';
901
+		}
884 902
 		$comments_by_type[$type][] = &$comments[$i];
885
-		if ( 'trackback' == $type || 'pingback' == $type )
886
-			$comments_by_type['pings'][] = &$comments[$i];
903
+		if ( 'trackback' == $type || 'pingback' == $type ) {
904
+					$comments_by_type['pings'][] = &$comments[$i];
905
+		}
887 906
 	}
888 907
 
889 908
 	return $comments_by_type;
@@ -906,28 +925,35 @@  discard block
 block discarded – undo
906 925
 function get_comment_pages_count( $comments = null, $per_page = null, $threaded = null ) {
907 926
 	global $wp_query;
908 927
 
909
-	if ( null === $comments && null === $per_page && null === $threaded && !empty($wp_query->max_num_comment_pages) )
910
-		return $wp_query->max_num_comment_pages;
928
+	if ( null === $comments && null === $per_page && null === $threaded && !empty($wp_query->max_num_comment_pages) ) {
929
+			return $wp_query->max_num_comment_pages;
930
+	}
911 931
 
912
-	if ( ( ! $comments || ! is_array( $comments ) ) && ! empty( $wp_query->comments )  )
913
-		$comments = $wp_query->comments;
932
+	if ( ( ! $comments || ! is_array( $comments ) ) && ! empty( $wp_query->comments )  ) {
933
+			$comments = $wp_query->comments;
934
+	}
914 935
 
915
-	if ( empty($comments) )
916
-		return 0;
936
+	if ( empty($comments) ) {
937
+			return 0;
938
+	}
917 939
 
918 940
 	if ( ! get_option( 'page_comments' ) ) {
919 941
 		return 1;
920 942
 	}
921 943
 
922
-	if ( !isset($per_page) )
923
-		$per_page = (int) get_query_var('comments_per_page');
924
-	if ( 0 === $per_page )
925
-		$per_page = (int) get_option('comments_per_page');
926
-	if ( 0 === $per_page )
927
-		return 1;
944
+	if ( !isset($per_page) ) {
945
+			$per_page = (int) get_query_var('comments_per_page');
946
+	}
947
+	if ( 0 === $per_page ) {
948
+			$per_page = (int) get_option('comments_per_page');
949
+	}
950
+	if ( 0 === $per_page ) {
951
+			return 1;
952
+	}
928 953
 
929
-	if ( !isset($threaded) )
930
-		$threaded = get_option('thread_comments');
954
+	if ( !isset($threaded) ) {
955
+			$threaded = get_option('thread_comments');
956
+	}
931 957
 
932 958
 	if ( $threaded ) {
933 959
 		$walker = new Walker_Comment;
@@ -964,8 +990,9 @@  discard block
 block discarded – undo
964 990
 
965 991
 	$page = null;
966 992
 
967
-	if ( !$comment = get_comment( $comment_ID ) )
968
-		return;
993
+	if ( !$comment = get_comment( $comment_ID ) ) {
994
+			return;
995
+	}
969 996
 
970 997
 	$defaults = array( 'type' => 'all', 'page' => '', 'per_page' => '', 'max_depth' => '' );
971 998
 	$args = wp_parse_args( $args, $defaults );
@@ -993,15 +1020,17 @@  discard block
 block discarded – undo
993 1020
 
994 1021
 	if ( null === $page ) {
995 1022
 		if ( '' === $args['max_depth'] ) {
996
-			if ( get_option('thread_comments') )
997
-				$args['max_depth'] = get_option('thread_comments_depth');
998
-			else
999
-				$args['max_depth'] = -1;
1023
+			if ( get_option('thread_comments') ) {
1024
+							$args['max_depth'] = get_option('thread_comments_depth');
1025
+			} else {
1026
+							$args['max_depth'] = -1;
1027
+			}
1000 1028
 		}
1001 1029
 
1002 1030
 		// Find this comment's top level parent if threading is enabled
1003
-		if ( $args['max_depth'] > 1 && 0 != $comment->comment_parent )
1004
-			return get_page_of_comment( $comment->comment_parent, $args );
1031
+		if ( $args['max_depth'] > 1 && 0 != $comment->comment_parent ) {
1032
+					return get_page_of_comment( $comment->comment_parent, $args );
1033
+		}
1005 1034
 
1006 1035
 		$comment_args = array(
1007 1036
 			'type'       => $args['type'],
@@ -1176,8 +1205,10 @@  discard block
 block discarded – undo
1176 1205
 	do_action( 'wp_blacklist_check', $author, $email, $url, $comment, $user_ip, $user_agent );
1177 1206
 
1178 1207
 	$mod_keys = trim( get_option('blacklist_keys') );
1179
-	if ( '' == $mod_keys )
1180
-		return false; // If moderation keys are empty
1208
+	if ( '' == $mod_keys ) {
1209
+			return false;
1210
+	}
1211
+	// If moderation keys are empty
1181 1212
 
1182 1213
 	// Ensure HTML tags are not being used to bypass the blacklist.
1183 1214
 	$comment_without_html = wp_strip_all_tags( $comment );
@@ -1203,8 +1234,9 @@  discard block
 block discarded – undo
1203 1234
 			|| preg_match($pattern, $comment_without_html)
1204 1235
 			|| preg_match($pattern, $user_ip)
1205 1236
 			|| preg_match($pattern, $user_agent)
1206
-		 )
1207
-			return true;
1237
+		 ) {
1238
+					return true;
1239
+		}
1208 1240
 	}
1209 1241
 	return false;
1210 1242
 }
@@ -1275,11 +1307,13 @@  discard block
 block discarded – undo
1275 1307
  */
1276 1308
 function wp_delete_comment($comment_id, $force_delete = false) {
1277 1309
 	global $wpdb;
1278
-	if (!$comment = get_comment($comment_id))
1279
-		return false;
1310
+	if (!$comment = get_comment($comment_id)) {
1311
+			return false;
1312
+	}
1280 1313
 
1281
-	if ( !$force_delete && EMPTY_TRASH_DAYS && !in_array( wp_get_comment_status( $comment ), array( 'trash', 'spam' ) ) )
1282
-		return wp_trash_comment($comment_id);
1314
+	if ( !$force_delete && EMPTY_TRASH_DAYS && !in_array( wp_get_comment_status( $comment ), array( 'trash', 'spam' ) ) ) {
1315
+			return wp_trash_comment($comment_id);
1316
+	}
1283 1317
 
1284 1318
 	/**
1285 1319
 	 * Fires immediately before a comment is deleted from the database.
@@ -1299,11 +1333,13 @@  discard block
 block discarded – undo
1299 1333
 
1300 1334
 	// Delete metadata
1301 1335
 	$meta_ids = $wpdb->get_col( $wpdb->prepare( "SELECT meta_id FROM $wpdb->commentmeta WHERE comment_id = %d", $comment->comment_ID ) );
1302
-	foreach ( $meta_ids as $mid )
1303
-		delete_metadata_by_mid( 'comment', $mid );
1336
+	foreach ( $meta_ids as $mid ) {
1337
+			delete_metadata_by_mid( 'comment', $mid );
1338
+	}
1304 1339
 
1305
-	if ( ! $wpdb->delete( $wpdb->comments, array( 'comment_ID' => $comment->comment_ID ) ) )
1306
-		return false;
1340
+	if ( ! $wpdb->delete( $wpdb->comments, array( 'comment_ID' => $comment->comment_ID ) ) ) {
1341
+			return false;
1342
+	}
1307 1343
 
1308 1344
 	/**
1309 1345
 	 * Fires immediately after a comment is deleted from the database.
@@ -1315,8 +1351,9 @@  discard block
 block discarded – undo
1315 1351
 	do_action( 'deleted_comment', $comment->comment_ID );
1316 1352
 
1317 1353
 	$post_id = $comment->comment_post_ID;
1318
-	if ( $post_id && $comment->comment_approved == 1 )
1319
-		wp_update_comment_count($post_id);
1354
+	if ( $post_id && $comment->comment_approved == 1 ) {
1355
+			wp_update_comment_count($post_id);
1356
+	}
1320 1357
 
1321 1358
 	clean_comment_cache( $comment->comment_ID );
1322 1359
 
@@ -1338,11 +1375,13 @@  discard block
 block discarded – undo
1338 1375
  * @return bool True on success, false on failure.
1339 1376
  */
1340 1377
 function wp_trash_comment($comment_id) {
1341
-	if ( !EMPTY_TRASH_DAYS )
1342
-		return wp_delete_comment($comment_id, true);
1378
+	if ( !EMPTY_TRASH_DAYS ) {
1379
+			return wp_delete_comment($comment_id, true);
1380
+	}
1343 1381
 
1344
-	if ( !$comment = get_comment($comment_id) )
1345
-		return false;
1382
+	if ( !$comment = get_comment($comment_id) ) {
1383
+			return false;
1384
+	}
1346 1385
 
1347 1386
 	/**
1348 1387
 	 * Fires immediately before a comment is sent to the Trash.
@@ -1397,8 +1436,9 @@  discard block
 block discarded – undo
1397 1436
 	do_action( 'untrash_comment', $comment->comment_ID );
1398 1437
 
1399 1438
 	$status = (string) get_comment_meta( $comment->comment_ID, '_wp_trash_meta_status', true );
1400
-	if ( empty($status) )
1401
-		$status = '0';
1439
+	if ( empty($status) ) {
1440
+			$status = '0';
1441
+	}
1402 1442
 
1403 1443
 	if ( wp_set_comment_status( $comment, $status ) ) {
1404 1444
 		delete_comment_meta( $comment->comment_ID, '_wp_trash_meta_time' );
@@ -1483,8 +1523,9 @@  discard block
 block discarded – undo
1483 1523
 	do_action( 'unspam_comment', $comment->comment_ID );
1484 1524
 
1485 1525
 	$status = (string) get_comment_meta( $comment->comment_ID, '_wp_trash_meta_status', true );
1486
-	if ( empty($status) )
1487
-		$status = '0';
1526
+	if ( empty($status) ) {
1527
+			$status = '0';
1528
+	}
1488 1529
 
1489 1530
 	if ( wp_set_comment_status( $comment, $status ) ) {
1490 1531
 		delete_comment_meta( $comment->comment_ID, '_wp_trash_meta_status' );
@@ -1513,24 +1554,26 @@  discard block
 block discarded – undo
1513 1554
  */
1514 1555
 function wp_get_comment_status($comment_id) {
1515 1556
 	$comment = get_comment($comment_id);
1516
-	if ( !$comment )
1517
-		return false;
1557
+	if ( !$comment ) {
1558
+			return false;
1559
+	}
1518 1560
 
1519 1561
 	$approved = $comment->comment_approved;
1520 1562
 
1521
-	if ( $approved == null )
1522
-		return false;
1523
-	elseif ( $approved == '1' )
1524
-		return 'approved';
1525
-	elseif ( $approved == '0' )
1526
-		return 'unapproved';
1527
-	elseif ( $approved == 'spam' )
1528
-		return 'spam';
1529
-	elseif ( $approved == 'trash' )
1530
-		return 'trash';
1531
-	else
1532
-		return false;
1533
-}
1563
+	if ( $approved == null ) {
1564
+			return false;
1565
+	} elseif ( $approved == '1' ) {
1566
+			return 'approved';
1567
+	} elseif ( $approved == '0' ) {
1568
+			return 'unapproved';
1569
+	} elseif ( $approved == 'spam' ) {
1570
+			return 'spam';
1571
+	} elseif ( $approved == 'trash' ) {
1572
+			return 'trash';
1573
+	} else {
1574
+			return false;
1575
+	}
1576
+	}
1534 1577
 
1535 1578
 /**
1536 1579
  * Call hooks for when a comment status transition occurs.
@@ -1562,8 +1605,12 @@  discard block
 block discarded – undo
1562 1605
 		1         => 'approved',
1563 1606
 		'approve' => 'approved', // wp_set_comment_status() uses "approve"
1564 1607
 	);
1565
-	if ( isset($comment_statuses[$new_status]) ) $new_status = $comment_statuses[$new_status];
1566
-	if ( isset($comment_statuses[$old_status]) ) $old_status = $comment_statuses[$old_status];
1608
+	if ( isset($comment_statuses[$new_status]) ) {
1609
+		$new_status = $comment_statuses[$new_status];
1610
+	}
1611
+	if ( isset($comment_statuses[$old_status]) ) {
1612
+		$old_status = $comment_statuses[$old_status];
1613
+	}
1567 1614
 
1568 1615
 	// Call the hooks
1569 1616
 	if ( $new_status != $old_status ) {
@@ -1642,16 +1689,19 @@  discard block
 block discarded – undo
1642 1689
 	// Cookies should already be sanitized.
1643 1690
 
1644 1691
 	$comment_author = '';
1645
-	if ( isset($_COOKIE['comment_author_'.COOKIEHASH]) )
1646
-		$comment_author = $_COOKIE['comment_author_'.COOKIEHASH];
1692
+	if ( isset($_COOKIE['comment_author_'.COOKIEHASH]) ) {
1693
+			$comment_author = $_COOKIE['comment_author_'.COOKIEHASH];
1694
+	}
1647 1695
 
1648 1696
 	$comment_author_email = '';
1649
-	if ( isset($_COOKIE['comment_author_email_'.COOKIEHASH]) )
1650
-		$comment_author_email = $_COOKIE['comment_author_email_'.COOKIEHASH];
1697
+	if ( isset($_COOKIE['comment_author_email_'.COOKIEHASH]) ) {
1698
+			$comment_author_email = $_COOKIE['comment_author_email_'.COOKIEHASH];
1699
+	}
1651 1700
 
1652 1701
 	$comment_author_url = '';
1653
-	if ( isset($_COOKIE['comment_author_url_'.COOKIEHASH]) )
1654
-		$comment_author_url = $_COOKIE['comment_author_url_'.COOKIEHASH];
1702
+	if ( isset($_COOKIE['comment_author_url_'.COOKIEHASH]) ) {
1703
+			$comment_author_url = $_COOKIE['comment_author_url_'.COOKIEHASH];
1704
+	}
1655 1705
 
1656 1706
 	/**
1657 1707
 	 * Filters the current commenter's name, email, and URL.
@@ -1840,10 +1890,13 @@  discard block
 block discarded – undo
1840 1890
  * @return bool Whether comment should be blocked.
1841 1891
  */
1842 1892
 function wp_throttle_comment_flood($block, $time_lastcomment, $time_newcomment) {
1843
-	if ( $block ) // a plugin has already blocked... we'll let that decision stand
1893
+	if ( $block ) {
1894
+		// a plugin has already blocked... we'll let that decision stand
1844 1895
 		return $block;
1845
-	if ( ($time_newcomment - $time_lastcomment) < 15 )
1846
-		return true;
1896
+	}
1897
+	if ( ($time_newcomment - $time_lastcomment) < 15 ) {
1898
+			return true;
1899
+	}
1847 1900
 	return false;
1848 1901
 }
1849 1902
 
@@ -2091,10 +2144,11 @@  discard block
 block discarded – undo
2091 2144
 	$comment_old = clone get_comment($comment_id);
2092 2145
 
2093 2146
 	if ( !$wpdb->update( $wpdb->comments, array('comment_approved' => $status), array( 'comment_ID' => $comment_old->comment_ID ) ) ) {
2094
-		if ( $wp_error )
2095
-			return new WP_Error('db_update_error', __('Could not update comment status'), $wpdb->last_error);
2096
-		else
2097
-			return false;
2147
+		if ( $wp_error ) {
2148
+					return new WP_Error('db_update_error', __('Could not update comment status'), $wpdb->last_error);
2149
+		} else {
2150
+					return false;
2151
+		}
2098 2152
 	}
2099 2153
 
2100 2154
 	clean_comment_cache( $comment_old->comment_ID );
@@ -2238,8 +2292,9 @@  discard block
 block discarded – undo
2238 2292
 	if ( is_bool($defer) ) {
2239 2293
 		$_defer = $defer;
2240 2294
 		// flush any deferred counts
2241
-		if ( !$defer )
2242
-			wp_update_comment_count( null, true );
2295
+		if ( !$defer ) {
2296
+					wp_update_comment_count( null, true );
2297
+		}
2243 2298
 	}
2244 2299
 
2245 2300
 	return $_defer;
@@ -2285,8 +2340,7 @@  discard block
 block discarded – undo
2285 2340
 	if ( wp_defer_comment_counting() ) {
2286 2341
 		$_deferred[] = $post_id;
2287 2342
 		return true;
2288
-	}
2289
-	elseif ( $post_id ) {
2343
+	} elseif ( $post_id ) {
2290 2344
 		return wp_update_comment_count_now($post_id);
2291 2345
 	}
2292 2346
 
@@ -2305,14 +2359,16 @@  discard block
 block discarded – undo
2305 2359
 function wp_update_comment_count_now($post_id) {
2306 2360
 	global $wpdb;
2307 2361
 	$post_id = (int) $post_id;
2308
-	if ( !$post_id )
2309
-		return false;
2362
+	if ( !$post_id ) {
2363
+			return false;
2364
+	}
2310 2365
 
2311 2366
 	wp_cache_delete( 'comments-0', 'counts' );
2312 2367
 	wp_cache_delete( "comments-{$post_id}", 'counts' );
2313 2368
 
2314
-	if ( !$post = get_post($post_id) )
2315
-		return false;
2369
+	if ( !$post = get_post($post_id) ) {
2370
+			return false;
2371
+	}
2316 2372
 
2317 2373
 	$old = (int) $post->comment_count;
2318 2374
 
@@ -2371,8 +2427,9 @@  discard block
 block discarded – undo
2371 2427
  * @return false|string False on failure, string containing URI on success.
2372 2428
  */
2373 2429
 function discover_pingback_server_uri( $url, $deprecated = '' ) {
2374
-	if ( !empty( $deprecated ) )
2375
-		_deprecated_argument( __FUNCTION__, '2.7.0' );
2430
+	if ( !empty( $deprecated ) ) {
2431
+			_deprecated_argument( __FUNCTION__, '2.7.0' );
2432
+	}
2376 2433
 
2377 2434
 	$pingback_str_dquote = 'rel="pingback"';
2378 2435
 	$pingback_str_squote = 'rel=\'pingback\'';
@@ -2380,31 +2437,38 @@  discard block
 block discarded – undo
2380 2437
 	/** @todo Should use Filter Extension or custom preg_match instead. */
2381 2438
 	$parsed_url = parse_url($url);
2382 2439
 
2383
-	if ( ! isset( $parsed_url['host'] ) ) // Not a URL. This should never happen.
2440
+	if ( ! isset( $parsed_url['host'] ) ) {
2441
+		// Not a URL. This should never happen.
2384 2442
 		return false;
2443
+	}
2385 2444
 
2386 2445
 	//Do not search for a pingback server on our own uploads
2387 2446
 	$uploads_dir = wp_get_upload_dir();
2388
-	if ( 0 === strpos($url, $uploads_dir['baseurl']) )
2389
-		return false;
2447
+	if ( 0 === strpos($url, $uploads_dir['baseurl']) ) {
2448
+			return false;
2449
+	}
2390 2450
 
2391 2451
 	$response = wp_safe_remote_head( $url, array( 'timeout' => 2, 'httpversion' => '1.0' ) );
2392 2452
 
2393
-	if ( is_wp_error( $response ) )
2394
-		return false;
2453
+	if ( is_wp_error( $response ) ) {
2454
+			return false;
2455
+	}
2395 2456
 
2396
-	if ( wp_remote_retrieve_header( $response, 'x-pingback' ) )
2397
-		return wp_remote_retrieve_header( $response, 'x-pingback' );
2457
+	if ( wp_remote_retrieve_header( $response, 'x-pingback' ) ) {
2458
+			return wp_remote_retrieve_header( $response, 'x-pingback' );
2459
+	}
2398 2460
 
2399 2461
 	// Not an (x)html, sgml, or xml page, no use going further.
2400
-	if ( preg_match('#(image|audio|video|model)/#is', wp_remote_retrieve_header( $response, 'content-type' )) )
2401
-		return false;
2462
+	if ( preg_match('#(image|audio|video|model)/#is', wp_remote_retrieve_header( $response, 'content-type' )) ) {
2463
+			return false;
2464
+	}
2402 2465
 
2403 2466
 	// Now do a GET since we're going to look in the html headers (and we're sure it's not a binary file)
2404 2467
 	$response = wp_safe_remote_get( $url, array( 'timeout' => 2, 'httpversion' => '1.0' ) );
2405 2468
 
2406
-	if ( is_wp_error( $response ) )
2407
-		return false;
2469
+	if ( is_wp_error( $response ) ) {
2470
+			return false;
2471
+	}
2408 2472
 
2409 2473
 	$contents = wp_remote_retrieve_body( $response );
2410 2474
 
@@ -2452,9 +2516,10 @@  discard block
 block discarded – undo
2452 2516
 
2453 2517
 	// Do Trackbacks
2454 2518
 	$trackbacks = $wpdb->get_col("SELECT ID FROM $wpdb->posts WHERE to_ping <> '' AND post_status = 'publish'");
2455
-	if ( is_array($trackbacks) )
2456
-		foreach ( $trackbacks as $trackback )
2519
+	if ( is_array($trackbacks) ) {
2520
+			foreach ( $trackbacks as $trackback )
2457 2521
 			do_trackbacks($trackback);
2522
+	}
2458 2523
 
2459 2524
 	//Do Update Services/Generic Pings
2460 2525
 	generic_ping();
@@ -2527,8 +2592,9 @@  discard block
 block discarded – undo
2527 2592
 	$services = explode("\n", $services);
2528 2593
 	foreach ( (array) $services as $service ) {
2529 2594
 		$service = trim($service);
2530
-		if ( '' != $service )
2531
-			weblog_ping($service);
2595
+		if ( '' != $service ) {
2596
+					weblog_ping($service);
2597
+		}
2532 2598
 	}
2533 2599
 
2534 2600
 	return $post_id;
@@ -2578,10 +2644,11 @@  discard block
 block discarded – undo
2578 2644
 		if ( ! in_array( $link_test, $pung ) && ( url_to_postid( $link_test ) != $post->ID ) // If we haven't pung it already and it isn't a link to itself
2579 2645
 				&& !is_local_attachment($link_test) ) : // Also, let's never ping local attachments.
2580 2646
 			if ( $test = @parse_url($link_test) ) {
2581
-				if ( isset($test['query']) )
2582
-					$post_links[] = $link_test;
2583
-				elseif ( isset( $test['path'] ) && ( $test['path'] != '/' ) && ( $test['path'] != '' ) )
2584
-					$post_links[] = $link_test;
2647
+				if ( isset($test['query']) ) {
2648
+									$post_links[] = $link_test;
2649
+				} elseif ( isset( $test['path'] ) && ( $test['path'] != '/' ) && ( $test['path'] != '' ) ) {
2650
+									$post_links[] = $link_test;
2651
+				}
2585 2652
 			}
2586 2653
 		endif;
2587 2654
 	endforeach;
@@ -2625,8 +2692,10 @@  discard block
 block discarded – undo
2625 2692
 			// when set to true, this outputs debug messages by itself
2626 2693
 			$client->debug = false;
2627 2694
 
2628
-			if ( $client->query('pingback.ping', $pagelinkedfrom, $pagelinkedto) || ( isset($client->error->code) && 48 == $client->error->code ) ) // Already registered
2695
+			if ( $client->query('pingback.ping', $pagelinkedfrom, $pagelinkedto) || ( isset($client->error->code) && 48 == $client->error->code ) ) {
2696
+				// Already registered
2629 2697
 				add_ping( $post, $pagelinkedto );
2698
+			}
2630 2699
 		}
2631 2700
 	}
2632 2701
 }
@@ -2640,11 +2709,12 @@  discard block
 block discarded – undo
2640 2709
  * @return mixed Empty string if blog is not public, returns $sites, if site is public.
2641 2710
  */
2642 2711
 function privacy_ping_filter($sites) {
2643
-	if ( '0' != get_option('blog_public') )
2644
-		return $sites;
2645
-	else
2646
-		return '';
2647
-}
2712
+	if ( '0' != get_option('blog_public') ) {
2713
+			return $sites;
2714
+	} else {
2715
+			return '';
2716
+	}
2717
+	}
2648 2718
 
2649 2719
 /**
2650 2720
  * Send a Trackback.
@@ -2664,8 +2734,9 @@  discard block
 block discarded – undo
2664 2734
 function trackback($trackback_url, $title, $excerpt, $ID) {
2665 2735
 	global $wpdb;
2666 2736
 
2667
-	if ( empty($trackback_url) )
2668
-		return;
2737
+	if ( empty($trackback_url) ) {
2738
+			return;
2739
+	}
2669 2740
 
2670 2741
 	$options = array();
2671 2742
 	$options['timeout'] = 10;
@@ -2678,8 +2749,9 @@  discard block
 block discarded – undo
2678 2749
 
2679 2750
 	$response = wp_safe_remote_post( $trackback_url, $options );
2680 2751
 
2681
-	if ( is_wp_error( $response ) )
2682
-		return;
2752
+	if ( is_wp_error( $response ) ) {
2753
+			return;
2754
+	}
2683 2755
 
2684 2756
 	$wpdb->query( $wpdb->prepare("UPDATE $wpdb->posts SET pinged = CONCAT(pinged, '\n', %s) WHERE ID = %d", $trackback_url, $ID) );
2685 2757
 	return $wpdb->query( $wpdb->prepare("UPDATE $wpdb->posts SET to_ping = TRIM(REPLACE(to_ping, %s, '')) WHERE ID = %d", $trackback_url, $ID) );
@@ -2705,9 +2777,11 @@  discard block
 block discarded – undo
2705 2777
 	// when set to true, this outputs debug messages by itself
2706 2778
 	$client->debug = false;
2707 2779
 	$home = trailingslashit( home_url() );
2708
-	if ( !$client->query('weblogUpdates.extendedPing', get_option('blogname'), $home, get_bloginfo('rss2_url') ) ) // then try a normal ping
2780
+	if ( !$client->query('weblogUpdates.extendedPing', get_option('blogname'), $home, get_bloginfo('rss2_url') ) ) {
2781
+		// then try a normal ping
2709 2782
 		$client->query('weblogUpdates.ping', get_option('blogname'), $home);
2710
-}
2783
+	}
2784
+	}
2711 2785
 
2712 2786
 /**
2713 2787
  * Default filter attached to pingback_ping_source_uri to validate the pingback's Source URI
@@ -2735,8 +2809,9 @@  discard block
 block discarded – undo
2735 2809
  * @return IXR_Error
2736 2810
  */
2737 2811
 function xmlrpc_pingback_error( $ixr_error ) {
2738
-	if ( $ixr_error->code === 48 )
2739
-		return $ixr_error;
2812
+	if ( $ixr_error->code === 48 ) {
2813
+			return $ixr_error;
2814
+	}
2740 2815
 	return new IXR_Error( 0, '' );
2741 2816
 }
2742 2817
 
@@ -2782,8 +2857,9 @@  discard block
 block discarded – undo
2782 2857
  * @param bool  $update_meta_cache Whether to update commentmeta cache. Default true.
2783 2858
  */
2784 2859
 function update_comment_cache( $comments, $update_meta_cache = true ) {
2785
-	foreach ( (array) $comments as $comment )
2786
-		wp_cache_add($comment->comment_ID, $comment, 'comment');
2860
+	foreach ( (array) $comments as $comment ) {
2861
+			wp_cache_add($comment->comment_ID, $comment, 'comment');
2862
+	}
2787 2863
 
2788 2864
 	if ( $update_meta_cache ) {
2789 2865
 		// Avoid `wp_list_pluck()` in case `$comments` is passed by reference.
@@ -2833,8 +2909,9 @@  discard block
 block discarded – undo
2833 2909
  * @return array
2834 2910
  */
2835 2911
 function _close_comments_for_old_posts( $posts, $query ) {
2836
-	if ( empty( $posts ) || ! $query->is_singular() || ! get_option( 'close_comments_for_old_posts' ) )
2837
-		return $posts;
2912
+	if ( empty( $posts ) || ! $query->is_singular() || ! get_option( 'close_comments_for_old_posts' ) ) {
2913
+			return $posts;
2914
+	}
2838 2915
 
2839 2916
 	/**
2840 2917
 	 * Filters the list of post types to automatically close comments for.
@@ -2844,12 +2921,14 @@  discard block
 block discarded – undo
2844 2921
 	 * @param array $post_types An array of registered post types. Default array with 'post'.
2845 2922
 	 */
2846 2923
 	$post_types = apply_filters( 'close_comments_for_post_types', array( 'post' ) );
2847
-	if ( ! in_array( $posts[0]->post_type, $post_types ) )
2848
-		return $posts;
2924
+	if ( ! in_array( $posts[0]->post_type, $post_types ) ) {
2925
+			return $posts;
2926
+	}
2849 2927
 
2850 2928
 	$days_old = (int) get_option( 'close_comments_days_old' );
2851
-	if ( ! $days_old )
2852
-		return $posts;
2929
+	if ( ! $days_old ) {
2930
+			return $posts;
2931
+	}
2853 2932
 
2854 2933
 	if ( time() - strtotime( $posts[0]->post_date_gmt ) > ( $days_old * DAY_IN_SECONDS ) ) {
2855 2934
 		$posts[0]->comment_status = 'closed';
@@ -2870,30 +2949,35 @@  discard block
 block discarded – undo
2870 2949
  * @return bool $open
2871 2950
  */
2872 2951
 function _close_comments_for_old_post( $open, $post_id ) {
2873
-	if ( ! $open )
2874
-		return $open;
2952
+	if ( ! $open ) {
2953
+			return $open;
2954
+	}
2875 2955
 
2876
-	if ( !get_option('close_comments_for_old_posts') )
2877
-		return $open;
2956
+	if ( !get_option('close_comments_for_old_posts') ) {
2957
+			return $open;
2958
+	}
2878 2959
 
2879 2960
 	$days_old = (int) get_option('close_comments_days_old');
2880
-	if ( !$days_old )
2881
-		return $open;
2961
+	if ( !$days_old ) {
2962
+			return $open;
2963
+	}
2882 2964
 
2883 2965
 	$post = get_post($post_id);
2884 2966
 
2885 2967
 	/** This filter is documented in wp-includes/comment.php */
2886 2968
 	$post_types = apply_filters( 'close_comments_for_post_types', array( 'post' ) );
2887
-	if ( ! in_array( $post->post_type, $post_types ) )
2888
-		return $open;
2969
+	if ( ! in_array( $post->post_type, $post_types ) ) {
2970
+			return $open;
2971
+	}
2889 2972
 
2890 2973
 	// Undated drafts should not show up as comments closed.
2891 2974
 	if ( '0000-00-00 00:00:00' === $post->post_date_gmt ) {
2892 2975
 		return $open;
2893 2976
 	}
2894 2977
 
2895
-	if ( time() - strtotime( $post->post_date_gmt ) > ( $days_old * DAY_IN_SECONDS ) )
2896
-		return false;
2978
+	if ( time() - strtotime( $post->post_date_gmt ) > ( $days_old * DAY_IN_SECONDS ) ) {
2979
+			return false;
2980
+	}
2897 2981
 
2898 2982
 	return $open;
2899 2983
 }
Please login to merge, or discard this patch.
src/wp-includes/http.php 3 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -721,7 +721,7 @@
 block discarded – undo
721 721
  * @see   http://php.net/manual/en/url.constants.php
722 722
  *
723 723
  * @param int $constant PHP_URL_* constant.
724
- * @return string|bool The named key or false.
724
+ * @return string|false The named key or false.
725 725
  */
726 726
 function _wp_translate_php_url_constant_to_key( $constant ) {
727 727
 	$translation = array(
Please login to merge, or discard this patch.
Braces   +60 added lines, -39 removed lines patch added patch discarded remove patch
@@ -255,8 +255,9 @@  discard block
 block discarded – undo
255 255
  * @return int|string The response code as an integer. Empty string on incorrect parameter given.
256 256
  */
257 257
 function wp_remote_retrieve_response_code( $response ) {
258
-	if ( is_wp_error($response) || ! isset($response['response']) || ! is_array($response['response']))
259
-		return '';
258
+	if ( is_wp_error($response) || ! isset($response['response']) || ! is_array($response['response'])) {
259
+			return '';
260
+	}
260 261
 
261 262
 	return $response['response']['code'];
262 263
 }
@@ -272,8 +273,9 @@  discard block
 block discarded – undo
272 273
  * @return string The response message. Empty string on incorrect parameter given.
273 274
  */
274 275
 function wp_remote_retrieve_response_message( $response ) {
275
-	if ( is_wp_error($response) || ! isset($response['response']) || ! is_array($response['response']))
276
-		return '';
276
+	if ( is_wp_error($response) || ! isset($response['response']) || ! is_array($response['response'])) {
277
+			return '';
278
+	}
277 279
 
278 280
 	return $response['response']['message'];
279 281
 }
@@ -287,8 +289,9 @@  discard block
 block discarded – undo
287 289
  * @return string The body of the response. Empty string if no body or incorrect parameter given.
288 290
  */
289 291
 function wp_remote_retrieve_body( $response ) {
290
-	if ( is_wp_error($response) || ! isset($response['body']) )
291
-		return '';
292
+	if ( is_wp_error($response) || ! isset($response['body']) ) {
293
+			return '';
294
+	}
292 295
 
293 296
 	return $response['body'];
294 297
 }
@@ -395,8 +398,9 @@  discard block
 block discarded – undo
395 398
  */
396 399
 function get_http_origin() {
397 400
 	$origin = '';
398
-	if ( ! empty ( $_SERVER[ 'HTTP_ORIGIN' ] ) )
399
-		$origin = $_SERVER[ 'HTTP_ORIGIN' ];
401
+	if ( ! empty ( $_SERVER[ 'HTTP_ORIGIN' ] ) ) {
402
+			$origin = $_SERVER[ 'HTTP_ORIGIN' ];
403
+	}
400 404
 
401 405
 	/**
402 406
 	 * Change the origin of an HTTP request.
@@ -454,11 +458,13 @@  discard block
 block discarded – undo
454 458
 function is_allowed_http_origin( $origin = null ) {
455 459
 	$origin_arg = $origin;
456 460
 
457
-	if ( null === $origin )
458
-		$origin = get_http_origin();
461
+	if ( null === $origin ) {
462
+			$origin = get_http_origin();
463
+	}
459 464
 
460
-	if ( $origin && ! in_array( $origin, get_allowed_http_origins() ) )
461
-		$origin = '';
465
+	if ( $origin && ! in_array( $origin, get_allowed_http_origins() ) ) {
466
+			$origin = '';
467
+	}
462 468
 
463 469
 	/**
464 470
 	 * Change the allowed HTTP origin result.
@@ -490,8 +496,9 @@  discard block
 block discarded – undo
490 496
 	if ( is_allowed_http_origin( $origin ) ) {
491 497
 		@header( 'Access-Control-Allow-Origin: ' .  $origin );
492 498
 		@header( 'Access-Control-Allow-Credentials: true' );
493
-		if ( 'OPTIONS' === $_SERVER['REQUEST_METHOD'] )
494
-			exit;
499
+		if ( 'OPTIONS' === $_SERVER['REQUEST_METHOD'] ) {
500
+					exit;
501
+		}
495 502
 		return $origin;
496 503
 	}
497 504
 
@@ -514,18 +521,22 @@  discard block
 block discarded – undo
514 521
 function wp_http_validate_url( $url ) {
515 522
 	$original_url = $url;
516 523
 	$url = wp_kses_bad_protocol( $url, array( 'http', 'https' ) );
517
-	if ( ! $url || strtolower( $url ) !== strtolower( $original_url ) )
518
-		return false;
524
+	if ( ! $url || strtolower( $url ) !== strtolower( $original_url ) ) {
525
+			return false;
526
+	}
519 527
 
520 528
 	$parsed_url = @parse_url( $url );
521
-	if ( ! $parsed_url || empty( $parsed_url['host'] ) )
522
-		return false;
529
+	if ( ! $parsed_url || empty( $parsed_url['host'] ) ) {
530
+			return false;
531
+	}
523 532
 
524
-	if ( isset( $parsed_url['user'] ) || isset( $parsed_url['pass'] ) )
525
-		return false;
533
+	if ( isset( $parsed_url['user'] ) || isset( $parsed_url['pass'] ) ) {
534
+			return false;
535
+	}
526 536
 
527
-	if ( false !== strpbrk( $parsed_url['host'], ':#?[]' ) )
528
-		return false;
537
+	if ( false !== strpbrk( $parsed_url['host'], ':#?[]' ) ) {
538
+			return false;
539
+	}
529 540
 
530 541
 	$parsed_home = @parse_url( get_option( 'home' ) );
531 542
 
@@ -541,8 +552,10 @@  discard block
 block discarded – undo
541 552
 			$ip = $host;
542 553
 		} else {
543 554
 			$ip = gethostbyname( $host );
544
-			if ( $ip === $host ) // Error condition for gethostbyname()
555
+			if ( $ip === $host ) {
556
+				// Error condition for gethostbyname()
545 557
 				$ip = false;
558
+			}
546 559
 		}
547 560
 		if ( $ip ) {
548 561
 			$parts = array_map( 'intval', explode( '.', $ip ) );
@@ -562,21 +575,25 @@  discard block
 block discarded – undo
562 575
 				 * @param string $host IP of the requested host.
563 576
 				 * @param string $url  URL of the requested host.
564 577
 				 */
565
-				if ( ! apply_filters( 'http_request_host_is_external', false, $host, $url ) )
566
-					return false;
578
+				if ( ! apply_filters( 'http_request_host_is_external', false, $host, $url ) ) {
579
+									return false;
580
+				}
567 581
 			}
568 582
 		}
569 583
 	}
570 584
 
571
-	if ( empty( $parsed_url['port'] ) )
572
-		return $url;
585
+	if ( empty( $parsed_url['port'] ) ) {
586
+			return $url;
587
+	}
573 588
 
574 589
 	$port = $parsed_url['port'];
575
-	if ( 80 === $port || 443 === $port || 8080 === $port )
576
-		return $url;
590
+	if ( 80 === $port || 443 === $port || 8080 === $port ) {
591
+			return $url;
592
+	}
577 593
 
578
-	if ( $parsed_home && $same_host && isset( $parsed_home['port'] ) && $parsed_home['port'] === $port )
579
-		return $url;
594
+	if ( $parsed_home && $same_host && isset( $parsed_home['port'] ) && $parsed_home['port'] === $port ) {
595
+			return $url;
596
+	}
580 597
 
581 598
 	return false;
582 599
 }
@@ -593,8 +610,9 @@  discard block
 block discarded – undo
593 610
  * @return bool
594 611
  */
595 612
 function allowed_http_request_hosts( $is_external, $host ) {
596
-	if ( ! $is_external && wp_validate_redirect( 'http://' . $host ) )
597
-		$is_external = true;
613
+	if ( ! $is_external && wp_validate_redirect( 'http://' . $host ) ) {
614
+			$is_external = true;
615
+	}
598 616
 	return $is_external;
599 617
 }
600 618
 
@@ -615,12 +633,15 @@  discard block
 block discarded – undo
615 633
 function ms_allowed_http_request_hosts( $is_external, $host ) {
616 634
 	global $wpdb;
617 635
 	static $queried = array();
618
-	if ( $is_external )
619
-		return $is_external;
620
-	if ( $host === get_network()->domain )
621
-		return true;
622
-	if ( isset( $queried[ $host ] ) )
623
-		return $queried[ $host ];
636
+	if ( $is_external ) {
637
+			return $is_external;
638
+	}
639
+	if ( $host === get_network()->domain ) {
640
+			return true;
641
+	}
642
+	if ( isset( $queried[ $host ] ) ) {
643
+			return $queried[ $host ];
644
+	}
624 645
 	$queried[ $host ] = (bool) $wpdb->get_var( $wpdb->prepare( "SELECT domain FROM $wpdb->blogs WHERE domain = %s LIMIT 1", $host ) );
625 646
 	return $queried[ $host ];
626 647
 }
Please login to merge, or discard this patch.
Spacing   +116 added lines, -116 removed lines patch added patch discarded remove patch
@@ -22,7 +22,7 @@  discard block
 block discarded – undo
22 22
 function _wp_http_get_object() {
23 23
 	static $http = null;
24 24
 
25
-	if ( is_null( $http ) ) {
25
+	if (is_null($http)) {
26 26
 		$http = new WP_Http();
27 27
 	}
28 28
 	return $http;
@@ -43,10 +43,10 @@  discard block
 block discarded – undo
43 43
  * @param array  $args Optional. Request arguments. Default empty array.
44 44
  * @return WP_Error|array The response or WP_Error on failure.
45 45
  */
46
-function wp_safe_remote_request( $url, $args = array() ) {
46
+function wp_safe_remote_request($url, $args = array()) {
47 47
 	$args['reject_unsafe_urls'] = true;
48 48
 	$http = _wp_http_get_object();
49
-	return $http->request( $url, $args );
49
+	return $http->request($url, $args);
50 50
 }
51 51
 
52 52
 /**
@@ -64,10 +64,10 @@  discard block
 block discarded – undo
64 64
  * @param array  $args Optional. Request arguments. Default empty array.
65 65
  * @return WP_Error|array The response or WP_Error on failure.
66 66
  */
67
-function wp_safe_remote_get( $url, $args = array() ) {
67
+function wp_safe_remote_get($url, $args = array()) {
68 68
 	$args['reject_unsafe_urls'] = true;
69 69
 	$http = _wp_http_get_object();
70
-	return $http->get( $url, $args );
70
+	return $http->get($url, $args);
71 71
 }
72 72
 
73 73
 /**
@@ -85,10 +85,10 @@  discard block
 block discarded – undo
85 85
  * @param array  $args Optional. Request arguments. Default empty array.
86 86
  * @return WP_Error|array The response or WP_Error on failure.
87 87
  */
88
-function wp_safe_remote_post( $url, $args = array() ) {
88
+function wp_safe_remote_post($url, $args = array()) {
89 89
 	$args['reject_unsafe_urls'] = true;
90 90
 	$http = _wp_http_get_object();
91
-	return $http->post( $url, $args );
91
+	return $http->post($url, $args);
92 92
 }
93 93
 
94 94
 /**
@@ -106,10 +106,10 @@  discard block
 block discarded – undo
106 106
  * @param array $args Optional. Request arguments. Default empty array.
107 107
  * @return WP_Error|array The response or WP_Error on failure.
108 108
  */
109
-function wp_safe_remote_head( $url, $args = array() ) {
109
+function wp_safe_remote_head($url, $args = array()) {
110 110
 	$args['reject_unsafe_urls'] = true;
111 111
 	$http = _wp_http_get_object();
112
-	return $http->head( $url, $args );
112
+	return $http->head($url, $args);
113 113
 }
114 114
 
115 115
 /**
@@ -150,7 +150,7 @@  discard block
 block discarded – undo
150 150
  */
151 151
 function wp_remote_request($url, $args = array()) {
152 152
 	$http = _wp_http_get_object();
153
-	return $http->request( $url, $args );
153
+	return $http->request($url, $args);
154 154
 }
155 155
 
156 156
 /**
@@ -167,7 +167,7 @@  discard block
 block discarded – undo
167 167
  */
168 168
 function wp_remote_get($url, $args = array()) {
169 169
 	$http = _wp_http_get_object();
170
-	return $http->get( $url, $args );
170
+	return $http->get($url, $args);
171 171
 }
172 172
 
173 173
 /**
@@ -184,7 +184,7 @@  discard block
 block discarded – undo
184 184
  */
185 185
 function wp_remote_post($url, $args = array()) {
186 186
 	$http = _wp_http_get_object();
187
-	return $http->post( $url, $args );
187
+	return $http->post($url, $args);
188 188
 }
189 189
 
190 190
 /**
@@ -201,7 +201,7 @@  discard block
 block discarded – undo
201 201
  */
202 202
 function wp_remote_head($url, $args = array()) {
203 203
 	$http = _wp_http_get_object();
204
-	return $http->head( $url, $args );
204
+	return $http->head($url, $args);
205 205
 }
206 206
 
207 207
 /**
@@ -215,8 +215,8 @@  discard block
 block discarded – undo
215 215
  * @param array $response HTTP response.
216 216
  * @return array|\Requests_Utility_CaseInsensitiveDictionary The headers of the response. Empty array if incorrect parameter given.
217 217
  */
218
-function wp_remote_retrieve_headers( $response ) {
219
-	if ( is_wp_error( $response ) || ! isset( $response['headers'] ) ) {
218
+function wp_remote_retrieve_headers($response) {
219
+	if (is_wp_error($response) || ! isset($response['headers'])) {
220 220
 		return array();
221 221
 	}
222 222
 
@@ -232,12 +232,12 @@  discard block
 block discarded – undo
232 232
  * @param string $header Header name to retrieve value from.
233 233
  * @return string The header value. Empty string on if incorrect parameter given, or if the header doesn't exist.
234 234
  */
235
-function wp_remote_retrieve_header( $response, $header ) {
236
-	if ( is_wp_error( $response ) || ! isset( $response['headers'] ) ) {
235
+function wp_remote_retrieve_header($response, $header) {
236
+	if (is_wp_error($response) || ! isset($response['headers'])) {
237 237
 		return '';
238 238
 	}
239 239
 
240
-	if ( isset( $response['headers'][ $header ] ) ) {
240
+	if (isset($response['headers'][$header])) {
241 241
 		return $response['headers'][$header];
242 242
 	}
243 243
 
@@ -254,8 +254,8 @@  discard block
 block discarded – undo
254 254
  * @param array $response HTTP response.
255 255
  * @return int|string The response code as an integer. Empty string on incorrect parameter given.
256 256
  */
257
-function wp_remote_retrieve_response_code( $response ) {
258
-	if ( is_wp_error($response) || ! isset($response['response']) || ! is_array($response['response']))
257
+function wp_remote_retrieve_response_code($response) {
258
+	if (is_wp_error($response) || ! isset($response['response']) || ! is_array($response['response']))
259 259
 		return '';
260 260
 
261 261
 	return $response['response']['code'];
@@ -271,8 +271,8 @@  discard block
 block discarded – undo
271 271
  * @param array $response HTTP response.
272 272
  * @return string The response message. Empty string on incorrect parameter given.
273 273
  */
274
-function wp_remote_retrieve_response_message( $response ) {
275
-	if ( is_wp_error($response) || ! isset($response['response']) || ! is_array($response['response']))
274
+function wp_remote_retrieve_response_message($response) {
275
+	if (is_wp_error($response) || ! isset($response['response']) || ! is_array($response['response']))
276 276
 		return '';
277 277
 
278 278
 	return $response['response']['message'];
@@ -286,8 +286,8 @@  discard block
 block discarded – undo
286 286
  * @param array $response HTTP response.
287 287
  * @return string The body of the response. Empty string if no body or incorrect parameter given.
288 288
  */
289
-function wp_remote_retrieve_body( $response ) {
290
-	if ( is_wp_error($response) || ! isset($response['body']) )
289
+function wp_remote_retrieve_body($response) {
290
+	if (is_wp_error($response) || ! isset($response['body']))
291 291
 		return '';
292 292
 
293 293
 	return $response['body'];
@@ -301,8 +301,8 @@  discard block
 block discarded – undo
301 301
  * @param array $response HTTP response.
302 302
  * @return array An array of `WP_Http_Cookie` objects from the response. Empty array if there are none, or the response is a WP_Error.
303 303
  */
304
-function wp_remote_retrieve_cookies( $response ) {
305
-	if ( is_wp_error( $response ) || empty( $response['cookies'] ) ) {
304
+function wp_remote_retrieve_cookies($response) {
305
+	if (is_wp_error($response) || empty($response['cookies'])) {
306 306
 		return array();
307 307
 	}
308 308
 
@@ -318,15 +318,15 @@  discard block
 block discarded – undo
318 318
  * @param string $name     The name of the cookie to retrieve.
319 319
  * @return WP_Http_Cookie|string The `WP_Http_Cookie` object. Empty string if the cookie isn't present in the response.
320 320
  */
321
-function wp_remote_retrieve_cookie( $response, $name ) {
322
-	$cookies = wp_remote_retrieve_cookies( $response );
321
+function wp_remote_retrieve_cookie($response, $name) {
322
+	$cookies = wp_remote_retrieve_cookies($response);
323 323
 
324
-	if ( empty( $cookies ) ) {
324
+	if (empty($cookies)) {
325 325
 		return '';
326 326
 	}
327 327
 
328
-	foreach ( $cookies as $cookie ) {
329
-		if ( $cookie->name === $name ) {
328
+	foreach ($cookies as $cookie) {
329
+		if ($cookie->name === $name) {
330 330
 			return $cookie;
331 331
 		}
332 332
 	}
@@ -343,10 +343,10 @@  discard block
 block discarded – undo
343 343
  * @param string $name     The name of the cookie to retrieve.
344 344
  * @return string The value of the cookie. Empty string if the cookie isn't present in the response.
345 345
  */
346
-function wp_remote_retrieve_cookie_value( $response, $name ) {
347
-	$cookie = wp_remote_retrieve_cookie( $response, $name );
346
+function wp_remote_retrieve_cookie_value($response, $name) {
347
+	$cookie = wp_remote_retrieve_cookie($response, $name);
348 348
 
349
-	if ( ! is_a( $cookie, 'WP_Http_Cookie' ) ) {
349
+	if ( ! is_a($cookie, 'WP_Http_Cookie')) {
350 350
 		return '';
351 351
 	}
352 352
 
@@ -364,26 +364,26 @@  discard block
 block discarded – undo
364 364
  *
365 365
  * @return bool
366 366
  */
367
-function wp_http_supports( $capabilities = array(), $url = null ) {
367
+function wp_http_supports($capabilities = array(), $url = null) {
368 368
 	$http = _wp_http_get_object();
369 369
 
370
-	$capabilities = wp_parse_args( $capabilities );
370
+	$capabilities = wp_parse_args($capabilities);
371 371
 
372
-	$count = count( $capabilities );
372
+	$count = count($capabilities);
373 373
 
374 374
 	// If we have a numeric $capabilities array, spoof a wp_remote_request() associative $args array
375
-	if ( $count && count( array_filter( array_keys( $capabilities ), 'is_numeric' ) ) == $count ) {
376
-		$capabilities = array_combine( array_values( $capabilities ), array_fill( 0, $count, true ) );
375
+	if ($count && count(array_filter(array_keys($capabilities), 'is_numeric')) == $count) {
376
+		$capabilities = array_combine(array_values($capabilities), array_fill(0, $count, true));
377 377
 	}
378 378
 
379
-	if ( $url && !isset( $capabilities['ssl'] ) ) {
380
-		$scheme = parse_url( $url, PHP_URL_SCHEME );
381
-		if ( 'https' == $scheme || 'ssl' == $scheme ) {
379
+	if ($url && ! isset($capabilities['ssl'])) {
380
+		$scheme = parse_url($url, PHP_URL_SCHEME);
381
+		if ('https' == $scheme || 'ssl' == $scheme) {
382 382
 			$capabilities['ssl'] = true;
383 383
 		}
384 384
 	}
385 385
 
386
-	return (bool) $http->_get_first_available_transport( $capabilities );
386
+	return (bool) $http->_get_first_available_transport($capabilities);
387 387
 }
388 388
 
389 389
 /**
@@ -395,8 +395,8 @@  discard block
 block discarded – undo
395 395
  */
396 396
 function get_http_origin() {
397 397
 	$origin = '';
398
-	if ( ! empty ( $_SERVER[ 'HTTP_ORIGIN' ] ) )
399
-		$origin = $_SERVER[ 'HTTP_ORIGIN' ];
398
+	if ( ! empty ($_SERVER['HTTP_ORIGIN']))
399
+		$origin = $_SERVER['HTTP_ORIGIN'];
400 400
 
401 401
 	/**
402 402
 	 * Change the origin of an HTTP request.
@@ -405,7 +405,7 @@  discard block
 block discarded – undo
405 405
 	 *
406 406
 	 * @param string $origin The original origin for the request.
407 407
 	 */
408
-	return apply_filters( 'http_origin', $origin );
408
+	return apply_filters('http_origin', $origin);
409 409
 }
410 410
 
411 411
 /**
@@ -416,16 +416,16 @@  discard block
 block discarded – undo
416 416
  * @return array Array of origin URLs.
417 417
  */
418 418
 function get_allowed_http_origins() {
419
-	$admin_origin = parse_url( admin_url() );
420
-	$home_origin = parse_url( home_url() );
419
+	$admin_origin = parse_url(admin_url());
420
+	$home_origin = parse_url(home_url());
421 421
 
422 422
 	// @todo preserve port?
423
-	$allowed_origins = array_unique( array(
424
-		'http://' . $admin_origin[ 'host' ],
425
-		'https://' . $admin_origin[ 'host' ],
426
-		'http://' . $home_origin[ 'host' ],
427
-		'https://' . $home_origin[ 'host' ],
428
-	) );
423
+	$allowed_origins = array_unique(array(
424
+		'http://'.$admin_origin['host'],
425
+		'https://'.$admin_origin['host'],
426
+		'http://'.$home_origin['host'],
427
+		'https://'.$home_origin['host'],
428
+	));
429 429
 
430 430
 	/**
431 431
 	 * Change the origin types allowed for HTTP requests.
@@ -440,7 +440,7 @@  discard block
 block discarded – undo
440 440
 	 *     @type string Secure URL for home origin.
441 441
 	 * }
442 442
 	 */
443
-	return apply_filters( 'allowed_http_origins' , $allowed_origins );
443
+	return apply_filters('allowed_http_origins', $allowed_origins);
444 444
 }
445 445
 
446 446
 /**
@@ -451,13 +451,13 @@  discard block
 block discarded – undo
451 451
  * @param null|string $origin Origin URL. If not provided, the value of get_http_origin() is used.
452 452
  * @return string Origin URL if allowed, empty string if not.
453 453
  */
454
-function is_allowed_http_origin( $origin = null ) {
454
+function is_allowed_http_origin($origin = null) {
455 455
 	$origin_arg = $origin;
456 456
 
457
-	if ( null === $origin )
457
+	if (null === $origin)
458 458
 		$origin = get_http_origin();
459 459
 
460
-	if ( $origin && ! in_array( $origin, get_allowed_http_origins() ) )
460
+	if ($origin && ! in_array($origin, get_allowed_http_origins()))
461 461
 		$origin = '';
462 462
 
463 463
 	/**
@@ -468,7 +468,7 @@  discard block
 block discarded – undo
468 468
 	 * @param string $origin     Origin URL if allowed, empty string if not.
469 469
 	 * @param string $origin_arg Original origin string passed into is_allowed_http_origin function.
470 470
 	 */
471
-	return apply_filters( 'allowed_http_origin', $origin, $origin_arg );
471
+	return apply_filters('allowed_http_origin', $origin, $origin_arg);
472 472
 }
473 473
 
474 474
 /**
@@ -487,16 +487,16 @@  discard block
 block discarded – undo
487 487
 function send_origin_headers() {
488 488
 	$origin = get_http_origin();
489 489
 
490
-	if ( is_allowed_http_origin( $origin ) ) {
491
-		@header( 'Access-Control-Allow-Origin: ' .  $origin );
492
-		@header( 'Access-Control-Allow-Credentials: true' );
493
-		if ( 'OPTIONS' === $_SERVER['REQUEST_METHOD'] )
490
+	if (is_allowed_http_origin($origin)) {
491
+		@header('Access-Control-Allow-Origin: '.$origin);
492
+		@header('Access-Control-Allow-Credentials: true');
493
+		if ('OPTIONS' === $_SERVER['REQUEST_METHOD'])
494 494
 			exit;
495 495
 		return $origin;
496 496
 	}
497 497
 
498
-	if ( 'OPTIONS' === $_SERVER['REQUEST_METHOD'] ) {
499
-		status_header( 403 );
498
+	if ('OPTIONS' === $_SERVER['REQUEST_METHOD']) {
499
+		status_header(403);
500 500
 		exit;
501 501
 	}
502 502
 
@@ -511,44 +511,44 @@  discard block
 block discarded – undo
511 511
  * @param string $url
512 512
  * @return false|string URL or false on failure.
513 513
  */
514
-function wp_http_validate_url( $url ) {
514
+function wp_http_validate_url($url) {
515 515
 	$original_url = $url;
516
-	$url = wp_kses_bad_protocol( $url, array( 'http', 'https' ) );
517
-	if ( ! $url || strtolower( $url ) !== strtolower( $original_url ) )
516
+	$url = wp_kses_bad_protocol($url, array('http', 'https'));
517
+	if ( ! $url || strtolower($url) !== strtolower($original_url))
518 518
 		return false;
519 519
 
520
-	$parsed_url = @parse_url( $url );
521
-	if ( ! $parsed_url || empty( $parsed_url['host'] ) )
520
+	$parsed_url = @parse_url($url);
521
+	if ( ! $parsed_url || empty($parsed_url['host']))
522 522
 		return false;
523 523
 
524
-	if ( isset( $parsed_url['user'] ) || isset( $parsed_url['pass'] ) )
524
+	if (isset($parsed_url['user']) || isset($parsed_url['pass']))
525 525
 		return false;
526 526
 
527
-	if ( false !== strpbrk( $parsed_url['host'], ':#?[]' ) )
527
+	if (false !== strpbrk($parsed_url['host'], ':#?[]'))
528 528
 		return false;
529 529
 
530
-	$parsed_home = @parse_url( get_option( 'home' ) );
530
+	$parsed_home = @parse_url(get_option('home'));
531 531
 
532
-	if ( isset( $parsed_home['host'] ) ) {
533
-		$same_host = ( strtolower( $parsed_home['host'] ) === strtolower( $parsed_url['host'] ) || 'localhost' === strtolower( $parsed_url['host'] ) );
532
+	if (isset($parsed_home['host'])) {
533
+		$same_host = (strtolower($parsed_home['host']) === strtolower($parsed_url['host']) || 'localhost' === strtolower($parsed_url['host']));
534 534
 	} else {
535 535
 		$same_host = false;
536 536
 	}
537 537
 
538
-	if ( ! $same_host ) {
539
-		$host = trim( $parsed_url['host'], '.' );
540
-		if ( preg_match( '#^(([1-9]?\d|1\d\d|25[0-5]|2[0-4]\d)\.){3}([1-9]?\d|1\d\d|25[0-5]|2[0-4]\d)$#', $host ) ) {
538
+	if ( ! $same_host) {
539
+		$host = trim($parsed_url['host'], '.');
540
+		if (preg_match('#^(([1-9]?\d|1\d\d|25[0-5]|2[0-4]\d)\.){3}([1-9]?\d|1\d\d|25[0-5]|2[0-4]\d)$#', $host)) {
541 541
 			$ip = $host;
542 542
 		} else {
543
-			$ip = gethostbyname( $host );
544
-			if ( $ip === $host ) // Error condition for gethostbyname()
543
+			$ip = gethostbyname($host);
544
+			if ($ip === $host) // Error condition for gethostbyname()
545 545
 				$ip = false;
546 546
 		}
547
-		if ( $ip ) {
548
-			$parts = array_map( 'intval', explode( '.', $ip ) );
549
-			if ( 127 === $parts[0] || 10 === $parts[0] || 0 === $parts[0]
550
-				|| ( 172 === $parts[0] && 16 <= $parts[1] && 31 >= $parts[1] )
551
-				|| ( 192 === $parts[0] && 168 === $parts[1] )
547
+		if ($ip) {
548
+			$parts = array_map('intval', explode('.', $ip));
549
+			if (127 === $parts[0] || 10 === $parts[0] || 0 === $parts[0]
550
+				|| (172 === $parts[0] && 16 <= $parts[1] && 31 >= $parts[1])
551
+				|| (192 === $parts[0] && 168 === $parts[1])
552 552
 			) {
553 553
 				// If host appears local, reject unless specifically allowed.
554 554
 				/**
@@ -562,20 +562,20 @@  discard block
 block discarded – undo
562 562
 				 * @param string $host IP of the requested host.
563 563
 				 * @param string $url  URL of the requested host.
564 564
 				 */
565
-				if ( ! apply_filters( 'http_request_host_is_external', false, $host, $url ) )
565
+				if ( ! apply_filters('http_request_host_is_external', false, $host, $url))
566 566
 					return false;
567 567
 			}
568 568
 		}
569 569
 	}
570 570
 
571
-	if ( empty( $parsed_url['port'] ) )
571
+	if (empty($parsed_url['port']))
572 572
 		return $url;
573 573
 
574 574
 	$port = $parsed_url['port'];
575
-	if ( 80 === $port || 443 === $port || 8080 === $port )
575
+	if (80 === $port || 443 === $port || 8080 === $port)
576 576
 		return $url;
577 577
 
578
-	if ( $parsed_home && $same_host && isset( $parsed_home['port'] ) && $parsed_home['port'] === $port )
578
+	if ($parsed_home && $same_host && isset($parsed_home['port']) && $parsed_home['port'] === $port)
579 579
 		return $url;
580 580
 
581 581
 	return false;
@@ -592,8 +592,8 @@  discard block
 block discarded – undo
592 592
  * @param string $host
593 593
  * @return bool
594 594
  */
595
-function allowed_http_request_hosts( $is_external, $host ) {
596
-	if ( ! $is_external && wp_validate_redirect( 'http://' . $host ) )
595
+function allowed_http_request_hosts($is_external, $host) {
596
+	if ( ! $is_external && wp_validate_redirect('http://'.$host))
597 597
 		$is_external = true;
598 598
 	return $is_external;
599 599
 }
@@ -612,17 +612,17 @@  discard block
 block discarded – undo
612 612
  * @param string $host
613 613
  * @return bool
614 614
  */
615
-function ms_allowed_http_request_hosts( $is_external, $host ) {
615
+function ms_allowed_http_request_hosts($is_external, $host) {
616 616
 	global $wpdb;
617 617
 	static $queried = array();
618
-	if ( $is_external )
618
+	if ($is_external)
619 619
 		return $is_external;
620
-	if ( $host === get_network()->domain )
620
+	if ($host === get_network()->domain)
621 621
 		return true;
622
-	if ( isset( $queried[ $host ] ) )
623
-		return $queried[ $host ];
624
-	$queried[ $host ] = (bool) $wpdb->get_var( $wpdb->prepare( "SELECT domain FROM $wpdb->blogs WHERE domain = %s LIMIT 1", $host ) );
625
-	return $queried[ $host ];
622
+	if (isset($queried[$host]))
623
+		return $queried[$host];
624
+	$queried[$host] = (bool) $wpdb->get_var($wpdb->prepare("SELECT domain FROM $wpdb->blogs WHERE domain = %s LIMIT 1", $host));
625
+	return $queried[$host];
626 626
 }
627 627
 
628 628
 /**
@@ -653,32 +653,32 @@  discard block
 block discarded – undo
653 653
  *               doesn't exist in the given URL; a string or - in the case of
654 654
  *               PHP_URL_PORT - integer when it does. See parse_url()'s return values.
655 655
  */
656
-function wp_parse_url( $url, $component = -1 ) {
656
+function wp_parse_url($url, $component = -1) {
657 657
 	$to_unset = array();
658
-	$url = strval( $url );
658
+	$url = strval($url);
659 659
 
660
-	if ( '//' === substr( $url, 0, 2 ) ) {
660
+	if ('//' === substr($url, 0, 2)) {
661 661
 		$to_unset[] = 'scheme';
662
-		$url = 'placeholder:' . $url;
663
-	} elseif ( '/' === substr( $url, 0, 1 ) ) {
662
+		$url = 'placeholder:'.$url;
663
+	} elseif ('/' === substr($url, 0, 1)) {
664 664
 		$to_unset[] = 'scheme';
665 665
 		$to_unset[] = 'host';
666
-		$url = 'placeholder://placeholder' . $url;
666
+		$url = 'placeholder://placeholder'.$url;
667 667
 	}
668 668
 
669
-	$parts = @parse_url( $url );
669
+	$parts = @parse_url($url);
670 670
 
671
-	if ( false === $parts ) {
671
+	if (false === $parts) {
672 672
 		// Parsing failure.
673 673
 		return $parts;
674 674
 	}
675 675
 
676 676
 	// Remove the placeholder values.
677
-	foreach ( $to_unset as $key ) {
678
-		unset( $parts[ $key ] );
677
+	foreach ($to_unset as $key) {
678
+		unset($parts[$key]);
679 679
 	}
680 680
 
681
-	return _get_component_from_parsed_url_array( $parts, $component );
681
+	return _get_component_from_parsed_url_array($parts, $component);
682 682
 }
683 683
 
684 684
 /**
@@ -698,14 +698,14 @@  discard block
 block discarded – undo
698 698
  *               doesn't exist in the given URL; a string or - in the case of
699 699
  *               PHP_URL_PORT - integer when it does. See parse_url()'s return values.
700 700
  */
701
-function _get_component_from_parsed_url_array( $url_parts, $component = -1 ) {
701
+function _get_component_from_parsed_url_array($url_parts, $component = -1) {
702 702
 	if ( -1 === $component ) {
703 703
 		return $url_parts;
704 704
 	}
705 705
 
706
-	$key = _wp_translate_php_url_constant_to_key( $component );
707
-	if ( false !== $key && is_array( $url_parts ) && isset( $url_parts[ $key ] ) ) {
708
-		return $url_parts[ $key ];
706
+	$key = _wp_translate_php_url_constant_to_key($component);
707
+	if (false !== $key && is_array($url_parts) && isset($url_parts[$key])) {
708
+		return $url_parts[$key];
709 709
 	} else {
710 710
 		return null;
711 711
 	}
@@ -723,7 +723,7 @@  discard block
 block discarded – undo
723 723
  * @param int $constant PHP_URL_* constant.
724 724
  * @return string|bool The named key or false.
725 725
  */
726
-function _wp_translate_php_url_constant_to_key( $constant ) {
726
+function _wp_translate_php_url_constant_to_key($constant) {
727 727
 	$translation = array(
728 728
 		PHP_URL_SCHEME   => 'scheme',
729 729
 		PHP_URL_HOST     => 'host',
@@ -735,8 +735,8 @@  discard block
 block discarded – undo
735 735
 		PHP_URL_FRAGMENT => 'fragment',
736 736
 	);
737 737
 
738
-	if ( isset( $translation[ $constant ] ) ) {
739
-		return $translation[ $constant ];
738
+	if (isset($translation[$constant])) {
739
+		return $translation[$constant];
740 740
 	} else {
741 741
 		return false;
742 742
 	}
Please login to merge, or discard this patch.
src/wp-includes/IXR/class-IXR-introspectionserver.php 3 patches
Doc Comments   +6 added lines patch added patch discarded remove patch
@@ -1048,6 +1048,12 @@
 block discarded – undo
1048 1048
 		self::__construct();
1049 1049
 	}
1050 1050
 
1051
+    /**
1052
+     * @param string $method
1053
+     * @param string $callback
1054
+     * @param string[] $args
1055
+     * @param string $help
1056
+     */
1051 1057
     function addCallback($method, $callback, $args, $help)
1052 1058
     {
1053 1059
         $this->callbacks[$method] = $callback;
Please login to merge, or discard this patch.
Indentation   +145 added lines, -145 removed lines patch added patch discarded remove patch
@@ -8,45 +8,45 @@  discard block
 block discarded – undo
8 8
  */
9 9
 class IXR_IntrospectionServer extends IXR_Server
10 10
 {
11
-    var $signatures;
12
-    var $help;
11
+	var $signatures;
12
+	var $help;
13 13
 
14 14
 	/**
15 15
 	 * PHP5 constructor.
16 16
 	 */
17
-    function __construct()
18
-    {
19
-        $this->setCallbacks();
20
-        $this->setCapabilities();
21
-        $this->capabilities['introspection'] = array(
22
-            'specUrl' => 'http://xmlrpc.usefulinc.com/doc/reserved.html',
23
-            'specVersion' => 1
24
-        );
25
-        $this->addCallback(
26
-            'system.methodSignature',
27
-            'this:methodSignature',
28
-            array('array', 'string'),
29
-            'Returns an array describing the return type and required parameters of a method'
30
-        );
31
-        $this->addCallback(
32
-            'system.getCapabilities',
33
-            'this:getCapabilities',
34
-            array('struct'),
35
-            'Returns a struct describing the XML-RPC specifications supported by this server'
36
-        );
37
-        $this->addCallback(
38
-            'system.listMethods',
39
-            'this:listMethods',
40
-            array('array'),
41
-            'Returns an array of available methods on this server'
42
-        );
43
-        $this->addCallback(
44
-            'system.methodHelp',
45
-            'this:methodHelp',
46
-            array('string', 'string'),
47
-            'Returns a documentation string for the specified method'
48
-        );
49
-    }
17
+	function __construct()
18
+	{
19
+		$this->setCallbacks();
20
+		$this->setCapabilities();
21
+		$this->capabilities['introspection'] = array(
22
+			'specUrl' => 'http://xmlrpc.usefulinc.com/doc/reserved.html',
23
+			'specVersion' => 1
24
+		);
25
+		$this->addCallback(
26
+			'system.methodSignature',
27
+			'this:methodSignature',
28
+			array('array', 'string'),
29
+			'Returns an array describing the return type and required parameters of a method'
30
+		);
31
+		$this->addCallback(
32
+			'system.getCapabilities',
33
+			'this:getCapabilities',
34
+			array('struct'),
35
+			'Returns a struct describing the XML-RPC specifications supported by this server'
36
+		);
37
+		$this->addCallback(
38
+			'system.listMethods',
39
+			'this:listMethods',
40
+			array('array'),
41
+			'Returns an array of available methods on this server'
42
+		);
43
+		$this->addCallback(
44
+			'system.methodHelp',
45
+			'this:methodHelp',
46
+			array('string', 'string'),
47
+			'Returns a documentation string for the specified method'
48
+		);
49
+	}
50 50
 
51 51
 	/**
52 52
 	 * PHP4 constructor.
@@ -55,120 +55,120 @@  discard block
 block discarded – undo
55 55
 		self::__construct();
56 56
 	}
57 57
 
58
-    function addCallback($method, $callback, $args, $help)
59
-    {
60
-        $this->callbacks[$method] = $callback;
61
-        $this->signatures[$method] = $args;
62
-        $this->help[$method] = $help;
63
-    }
58
+	function addCallback($method, $callback, $args, $help)
59
+	{
60
+		$this->callbacks[$method] = $callback;
61
+		$this->signatures[$method] = $args;
62
+		$this->help[$method] = $help;
63
+	}
64 64
 
65
-    function call($methodname, $args)
66
-    {
67
-        // Make sure it's in an array
68
-        if ($args && !is_array($args)) {
69
-            $args = array($args);
70
-        }
65
+	function call($methodname, $args)
66
+	{
67
+		// Make sure it's in an array
68
+		if ($args && !is_array($args)) {
69
+			$args = array($args);
70
+		}
71 71
 
72
-        // Over-rides default call method, adds signature check
73
-        if (!$this->hasMethod($methodname)) {
74
-            return new IXR_Error(-32601, 'server error. requested method "'.$this->message->methodName.'" not specified.');
75
-        }
76
-        $method = $this->callbacks[$methodname];
77
-        $signature = $this->signatures[$methodname];
78
-        $returnType = array_shift($signature);
72
+		// Over-rides default call method, adds signature check
73
+		if (!$this->hasMethod($methodname)) {
74
+			return new IXR_Error(-32601, 'server error. requested method "'.$this->message->methodName.'" not specified.');
75
+		}
76
+		$method = $this->callbacks[$methodname];
77
+		$signature = $this->signatures[$methodname];
78
+		$returnType = array_shift($signature);
79 79
 
80
-        // Check the number of arguments
81
-        if (count($args) != count($signature)) {
82
-            return new IXR_Error(-32602, 'server error. wrong number of method parameters');
83
-        }
80
+		// Check the number of arguments
81
+		if (count($args) != count($signature)) {
82
+			return new IXR_Error(-32602, 'server error. wrong number of method parameters');
83
+		}
84 84
 
85
-        // Check the argument types
86
-        $ok = true;
87
-        $argsbackup = $args;
88
-        for ($i = 0, $j = count($args); $i < $j; $i++) {
89
-            $arg = array_shift($args);
90
-            $type = array_shift($signature);
91
-            switch ($type) {
92
-                case 'int':
93
-                case 'i4':
94
-                    if (is_array($arg) || !is_int($arg)) {
95
-                        $ok = false;
96
-                    }
97
-                    break;
98
-                case 'base64':
99
-                case 'string':
100
-                    if (!is_string($arg)) {
101
-                        $ok = false;
102
-                    }
103
-                    break;
104
-                case 'boolean':
105
-                    if ($arg !== false && $arg !== true) {
106
-                        $ok = false;
107
-                    }
108
-                    break;
109
-                case 'float':
110
-                case 'double':
111
-                    if (!is_float($arg)) {
112
-                        $ok = false;
113
-                    }
114
-                    break;
115
-                case 'date':
116
-                case 'dateTime.iso8601':
117
-                    if (!is_a($arg, 'IXR_Date')) {
118
-                        $ok = false;
119
-                    }
120
-                    break;
121
-            }
122
-            if (!$ok) {
123
-                return new IXR_Error(-32602, 'server error. invalid method parameters');
124
-            }
125
-        }
126
-        // It passed the test - run the "real" method call
127
-        return parent::call($methodname, $argsbackup);
128
-    }
85
+		// Check the argument types
86
+		$ok = true;
87
+		$argsbackup = $args;
88
+		for ($i = 0, $j = count($args); $i < $j; $i++) {
89
+			$arg = array_shift($args);
90
+			$type = array_shift($signature);
91
+			switch ($type) {
92
+				case 'int':
93
+				case 'i4':
94
+					if (is_array($arg) || !is_int($arg)) {
95
+						$ok = false;
96
+					}
97
+					break;
98
+				case 'base64':
99
+				case 'string':
100
+					if (!is_string($arg)) {
101
+						$ok = false;
102
+					}
103
+					break;
104
+				case 'boolean':
105
+					if ($arg !== false && $arg !== true) {
106
+						$ok = false;
107
+					}
108
+					break;
109
+				case 'float':
110
+				case 'double':
111
+					if (!is_float($arg)) {
112
+						$ok = false;
113
+					}
114
+					break;
115
+				case 'date':
116
+				case 'dateTime.iso8601':
117
+					if (!is_a($arg, 'IXR_Date')) {
118
+						$ok = false;
119
+					}
120
+					break;
121
+			}
122
+			if (!$ok) {
123
+				return new IXR_Error(-32602, 'server error. invalid method parameters');
124
+			}
125
+		}
126
+		// It passed the test - run the "real" method call
127
+		return parent::call($methodname, $argsbackup);
128
+	}
129 129
 
130
-    function methodSignature($method)
131
-    {
132
-        if (!$this->hasMethod($method)) {
133
-            return new IXR_Error(-32601, 'server error. requested method "'.$method.'" not specified.');
134
-        }
135
-        // We should be returning an array of types
136
-        $types = $this->signatures[$method];
137
-        $return = array();
138
-        foreach ($types as $type) {
139
-            switch ($type) {
140
-                case 'string':
141
-                    $return[] = 'string';
142
-                    break;
143
-                case 'int':
144
-                case 'i4':
145
-                    $return[] = 42;
146
-                    break;
147
-                case 'double':
148
-                    $return[] = 3.1415;
149
-                    break;
150
-                case 'dateTime.iso8601':
151
-                    $return[] = new IXR_Date(time());
152
-                    break;
153
-                case 'boolean':
154
-                    $return[] = true;
155
-                    break;
156
-                case 'base64':
157
-                    $return[] = new IXR_Base64('base64');
158
-                    break;
159
-                case 'array':
160
-                    $return[] = array('array');
161
-                    break;
162
-                case 'struct':
163
-                    $return[] = array('struct' => 'struct');
164
-                    break;
165
-            }
166
-        }
167
-        return $return;
168
-    }
130
+	function methodSignature($method)
131
+	{
132
+		if (!$this->hasMethod($method)) {
133
+			return new IXR_Error(-32601, 'server error. requested method "'.$method.'" not specified.');
134
+		}
135
+		// We should be returning an array of types
136
+		$types = $this->signatures[$method];
137
+		$return = array();
138
+		foreach ($types as $type) {
139
+			switch ($type) {
140
+				case 'string':
141
+					$return[] = 'string';
142
+					break;
143
+				case 'int':
144
+				case 'i4':
145
+					$return[] = 42;
146
+					break;
147
+				case 'double':
148
+					$return[] = 3.1415;
149
+					break;
150
+				case 'dateTime.iso8601':
151
+					$return[] = new IXR_Date(time());
152
+					break;
153
+				case 'boolean':
154
+					$return[] = true;
155
+					break;
156
+				case 'base64':
157
+					$return[] = new IXR_Base64('base64');
158
+					break;
159
+				case 'array':
160
+					$return[] = array('array');
161
+					break;
162
+				case 'struct':
163
+					$return[] = array('struct' => 'struct');
164
+					break;
165
+			}
166
+		}
167
+		return $return;
168
+	}
169 169
 
170
-    function methodHelp($method)
171
-    {
172
-        return $this->help[$method];
173
-    }
170
+	function methodHelp($method)
171
+	{
172
+		return $this->help[$method];
173
+	}
174 174
 }
Please login to merge, or discard this patch.
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -65,12 +65,12 @@  discard block
 block discarded – undo
65 65
     function call($methodname, $args)
66 66
     {
67 67
         // Make sure it's in an array
68
-        if ($args && !is_array($args)) {
68
+        if ($args && ! is_array($args)) {
69 69
             $args = array($args);
70 70
         }
71 71
 
72 72
         // Over-rides default call method, adds signature check
73
-        if (!$this->hasMethod($methodname)) {
73
+        if ( ! $this->hasMethod($methodname)) {
74 74
             return new IXR_Error(-32601, 'server error. requested method "'.$this->message->methodName.'" not specified.');
75 75
         }
76 76
         $method = $this->callbacks[$methodname];
@@ -91,13 +91,13 @@  discard block
 block discarded – undo
91 91
             switch ($type) {
92 92
                 case 'int':
93 93
                 case 'i4':
94
-                    if (is_array($arg) || !is_int($arg)) {
94
+                    if (is_array($arg) || ! is_int($arg)) {
95 95
                         $ok = false;
96 96
                     }
97 97
                     break;
98 98
                 case 'base64':
99 99
                 case 'string':
100
-                    if (!is_string($arg)) {
100
+                    if ( ! is_string($arg)) {
101 101
                         $ok = false;
102 102
                     }
103 103
                     break;
@@ -108,18 +108,18 @@  discard block
 block discarded – undo
108 108
                     break;
109 109
                 case 'float':
110 110
                 case 'double':
111
-                    if (!is_float($arg)) {
111
+                    if ( ! is_float($arg)) {
112 112
                         $ok = false;
113 113
                     }
114 114
                     break;
115 115
                 case 'date':
116 116
                 case 'dateTime.iso8601':
117
-                    if (!is_a($arg, 'IXR_Date')) {
117
+                    if ( ! is_a($arg, 'IXR_Date')) {
118 118
                         $ok = false;
119 119
                     }
120 120
                     break;
121 121
             }
122
-            if (!$ok) {
122
+            if ( ! $ok) {
123 123
                 return new IXR_Error(-32602, 'server error. invalid method parameters');
124 124
             }
125 125
         }
@@ -129,7 +129,7 @@  discard block
 block discarded – undo
129 129
 
130 130
     function methodSignature($method)
131 131
     {
132
-        if (!$this->hasMethod($method)) {
132
+        if ( ! $this->hasMethod($method)) {
133 133
             return new IXR_Error(-32601, 'server error. requested method "'.$method.'" not specified.');
134 134
         }
135 135
         // We should be returning an array of types
Please login to merge, or discard this patch.
src/wp-includes/ms-functions.php 4 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -2191,7 +2191,7 @@
 block discarded – undo
2191 2191
  *
2192 2192
  * @staticvar bool $forced_content
2193 2193
  *
2194
- * @param bool $force
2194
+ * @param string|boolean $force
2195 2195
  * @return bool True if forced, false if not forced.
2196 2196
  */
2197 2197
 function force_ssl_content( $force = '' ) {
Please login to merge, or discard this patch.
Indentation   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -1607,7 +1607,7 @@  discard block
 block discarded – undo
1607 1607
 	$current_network = get_network();
1608 1608
 
1609 1609
 	/**
1610
- 	 * Filters whether to bypass the welcome email after user activation.
1610
+	 * Filters whether to bypass the welcome email after user activation.
1611 1611
 	 *
1612 1612
 	 * Returning false disables the welcome email.
1613 1613
 	 *
@@ -2134,7 +2134,7 @@  discard block
 block discarded – undo
2134 2134
  * @return bool
2135 2135
  */
2136 2136
 function is_user_spammy( $user = null ) {
2137
-    if ( ! ( $user instanceof WP_User ) ) {
2137
+	if ( ! ( $user instanceof WP_User ) ) {
2138 2138
 		if ( $user ) {
2139 2139
 			$user = get_user_by( 'login', $user );
2140 2140
 		} else {
Please login to merge, or discard this patch.
Spacing   +526 added lines, -526 removed lines patch added patch discarded remove patch
@@ -39,45 +39,45 @@  discard block
 block discarded – undo
39 39
  * @param int $user_id The unique ID of the user
40 40
  * @return WP_Site|void The blog object
41 41
  */
42
-function get_active_blog_for_user( $user_id ) {
42
+function get_active_blog_for_user($user_id) {
43 43
 	global $wpdb;
44
-	$blogs = get_blogs_of_user( $user_id );
45
-	if ( empty( $blogs ) )
44
+	$blogs = get_blogs_of_user($user_id);
45
+	if (empty($blogs))
46 46
 		return;
47 47
 
48
-	if ( !is_multisite() )
48
+	if ( ! is_multisite())
49 49
 		return $blogs[$wpdb->blogid];
50 50
 
51
-	$primary_blog = get_user_meta( $user_id, 'primary_blog', true );
51
+	$primary_blog = get_user_meta($user_id, 'primary_blog', true);
52 52
 	$first_blog = current($blogs);
53
-	if ( false !== $primary_blog ) {
54
-		if ( ! isset( $blogs[ $primary_blog ] ) ) {
55
-			update_user_meta( $user_id, 'primary_blog', $first_blog->userblog_id );
56
-			$primary = get_site( $first_blog->userblog_id );
53
+	if (false !== $primary_blog) {
54
+		if ( ! isset($blogs[$primary_blog])) {
55
+			update_user_meta($user_id, 'primary_blog', $first_blog->userblog_id);
56
+			$primary = get_site($first_blog->userblog_id);
57 57
 		} else {
58
-			$primary = get_site( $primary_blog );
58
+			$primary = get_site($primary_blog);
59 59
 		}
60 60
 	} else {
61 61
 		//TODO Review this call to add_user_to_blog too - to get here the user must have a role on this blog?
62
-		add_user_to_blog( $first_blog->userblog_id, $user_id, 'subscriber' );
63
-		update_user_meta( $user_id, 'primary_blog', $first_blog->userblog_id );
62
+		add_user_to_blog($first_blog->userblog_id, $user_id, 'subscriber');
63
+		update_user_meta($user_id, 'primary_blog', $first_blog->userblog_id);
64 64
 		$primary = $first_blog;
65 65
 	}
66 66
 
67
-	if ( ( ! is_object( $primary ) ) || ( $primary->archived == 1 || $primary->spam == 1 || $primary->deleted == 1 ) ) {
68
-		$blogs = get_blogs_of_user( $user_id, true ); // if a user's primary blog is shut down, check their other blogs.
67
+	if (( ! is_object($primary)) || ($primary->archived == 1 || $primary->spam == 1 || $primary->deleted == 1)) {
68
+		$blogs = get_blogs_of_user($user_id, true); // if a user's primary blog is shut down, check their other blogs.
69 69
 		$ret = false;
70
-		if ( is_array( $blogs ) && count( $blogs ) > 0 ) {
71
-			foreach ( (array) $blogs as $blog_id => $blog ) {
72
-				if ( $blog->site_id != $wpdb->siteid )
70
+		if (is_array($blogs) && count($blogs) > 0) {
71
+			foreach ((array) $blogs as $blog_id => $blog) {
72
+				if ($blog->site_id != $wpdb->siteid)
73 73
 					continue;
74
-				$details = get_site( $blog_id );
75
-				if ( is_object( $details ) && $details->archived == 0 && $details->spam == 0 && $details->deleted == 0 ) {
74
+				$details = get_site($blog_id);
75
+				if (is_object($details) && $details->archived == 0 && $details->spam == 0 && $details->deleted == 0) {
76 76
 					$ret = $blog;
77
-					if ( get_user_meta( $user_id , 'primary_blog', true ) != $blog_id )
78
-						update_user_meta( $user_id, 'primary_blog', $blog_id );
79
-					if ( !get_user_meta($user_id , 'source_domain', true) )
80
-						update_user_meta( $user_id, 'source_domain', $blog->domain );
77
+					if (get_user_meta($user_id, 'primary_blog', true) != $blog_id)
78
+						update_user_meta($user_id, 'primary_blog', $blog_id);
79
+					if ( ! get_user_meta($user_id, 'source_domain', true))
80
+						update_user_meta($user_id, 'source_domain', $blog->domain);
81 81
 					break;
82 82
 				}
83 83
 			}
@@ -101,8 +101,8 @@  discard block
 block discarded – undo
101 101
  * @param int|null $network_id ID of the network. Default is the current network.
102 102
  * @return int Number of active users on the network.
103 103
  */
104
-function get_user_count( $network_id = null ) {
105
-	return get_network_option( $network_id, 'user_count' );
104
+function get_user_count($network_id = null) {
105
+	return get_network_option($network_id, 'user_count');
106 106
 }
107 107
 
108 108
 /**
@@ -117,8 +117,8 @@  discard block
 block discarded – undo
117 117
  * @param int|null $network_id ID of the network. Default is the current network.
118 118
  * @return int Number of active sites on the network.
119 119
  */
120
-function get_blog_count( $network_id = null ) {
121
-	return get_network_option( $network_id, 'blog_count' );
120
+function get_blog_count($network_id = null) {
121
+	return get_network_option($network_id, 'blog_count');
122 122
 }
123 123
 
124 124
 /**
@@ -130,9 +130,9 @@  discard block
 block discarded – undo
130 130
  * @param int $post_id ID of the post you're looking for.
131 131
  * @return WP_Post|null WP_Post on success or null on failure
132 132
  */
133
-function get_blog_post( $blog_id, $post_id ) {
134
-	switch_to_blog( $blog_id );
135
-	$post = get_post( $post_id );
133
+function get_blog_post($blog_id, $post_id) {
134
+	switch_to_blog($blog_id);
135
+	$post = get_post($post_id);
136 136
 	restore_current_blog();
137 137
 
138 138
 	return $post;
@@ -150,20 +150,20 @@  discard block
 block discarded – undo
150 150
  * @param string $role    The role you want the user to have
151 151
  * @return true|WP_Error
152 152
  */
153
-function add_user_to_blog( $blog_id, $user_id, $role ) {
153
+function add_user_to_blog($blog_id, $user_id, $role) {
154 154
 	switch_to_blog($blog_id);
155 155
 
156
-	$user = get_userdata( $user_id );
156
+	$user = get_userdata($user_id);
157 157
 
158
-	if ( ! $user ) {
158
+	if ( ! $user) {
159 159
 		restore_current_blog();
160
-		return new WP_Error( 'user_does_not_exist', __( 'The requested user does not exist.' ) );
160
+		return new WP_Error('user_does_not_exist', __('The requested user does not exist.'));
161 161
 	}
162 162
 
163
-	if ( !get_user_meta($user_id, 'primary_blog', true) ) {
163
+	if ( ! get_user_meta($user_id, 'primary_blog', true)) {
164 164
 		update_user_meta($user_id, 'primary_blog', $blog_id);
165
-		$site = get_site( $blog_id );
166
-		update_user_meta( $user_id, 'source_domain', $site->domain );
165
+		$site = get_site($blog_id);
166
+		update_user_meta($user_id, 'source_domain', $site->domain);
167 167
 	}
168 168
 
169 169
 	$user->set_role($role);
@@ -177,9 +177,9 @@  discard block
 block discarded – undo
177 177
 	 * @param string $role    User role.
178 178
 	 * @param int    $blog_id Blog ID.
179 179
 	 */
180
-	do_action( 'add_user_to_blog', $user_id, $role, $blog_id );
181
-	wp_cache_delete( $user_id, 'users' );
182
-	wp_cache_delete( $blog_id . '_user_count', 'blog-details' );
180
+	do_action('add_user_to_blog', $user_id, $role, $blog_id);
181
+	wp_cache_delete($user_id, 'users');
182
+	wp_cache_delete($blog_id.'_user_count', 'blog-details');
183 183
 	restore_current_blog();
184 184
 	return true;
185 185
 }
@@ -214,17 +214,17 @@  discard block
 block discarded – undo
214 214
 	 * @param int $user_id User ID.
215 215
 	 * @param int $blog_id Blog ID.
216 216
 	 */
217
-	do_action( 'remove_user_from_blog', $user_id, $blog_id );
217
+	do_action('remove_user_from_blog', $user_id, $blog_id);
218 218
 
219 219
 	// If being removed from the primary blog, set a new primary if the user is assigned
220 220
 	// to multiple blogs.
221 221
 	$primary_blog = get_user_meta($user_id, 'primary_blog', true);
222
-	if ( $primary_blog == $blog_id ) {
222
+	if ($primary_blog == $blog_id) {
223 223
 		$new_id = '';
224 224
 		$new_domain = '';
225 225
 		$blogs = get_blogs_of_user($user_id);
226
-		foreach ( (array) $blogs as $blog ) {
227
-			if ( $blog->userblog_id == $blog_id )
226
+		foreach ((array) $blogs as $blog) {
227
+			if ($blog->userblog_id == $blog_id)
228 228
 				continue;
229 229
 			$new_id = $blog->userblog_id;
230 230
 			$new_domain = $blog->domain;
@@ -236,8 +236,8 @@  discard block
 block discarded – undo
236 236
 	}
237 237
 
238 238
 	// wp_revoke_user($user_id);
239
-	$user = get_userdata( $user_id );
240
-	if ( ! $user ) {
239
+	$user = get_userdata($user_id);
240
+	if ( ! $user) {
241 241
 		restore_current_blog();
242 242
 		return new WP_Error('user_does_not_exist', __('That user does not exist.'));
243 243
 	}
@@ -245,24 +245,24 @@  discard block
 block discarded – undo
245 245
 	$user->remove_all_caps();
246 246
 
247 247
 	$blogs = get_blogs_of_user($user_id);
248
-	if ( count($blogs) == 0 ) {
248
+	if (count($blogs) == 0) {
249 249
 		update_user_meta($user_id, 'primary_blog', '');
250 250
 		update_user_meta($user_id, 'source_domain', '');
251 251
 	}
252 252
 
253
-	if ( $reassign != '' ) {
253
+	if ($reassign != '') {
254 254
 		$reassign = (int) $reassign;
255
-		$post_ids = $wpdb->get_col( $wpdb->prepare( "SELECT ID FROM $wpdb->posts WHERE post_author = %d", $user_id ) );
256
-		$link_ids = $wpdb->get_col( $wpdb->prepare( "SELECT link_id FROM $wpdb->links WHERE link_owner = %d", $user_id ) );
255
+		$post_ids = $wpdb->get_col($wpdb->prepare("SELECT ID FROM $wpdb->posts WHERE post_author = %d", $user_id));
256
+		$link_ids = $wpdb->get_col($wpdb->prepare("SELECT link_id FROM $wpdb->links WHERE link_owner = %d", $user_id));
257 257
 
258
-		if ( ! empty( $post_ids ) ) {
259
-			$wpdb->query( $wpdb->prepare( "UPDATE $wpdb->posts SET post_author = %d WHERE post_author = %d", $reassign, $user_id ) );
260
-			array_walk( $post_ids, 'clean_post_cache' );
258
+		if ( ! empty($post_ids)) {
259
+			$wpdb->query($wpdb->prepare("UPDATE $wpdb->posts SET post_author = %d WHERE post_author = %d", $reassign, $user_id));
260
+			array_walk($post_ids, 'clean_post_cache');
261 261
 		}
262 262
 
263
-		if ( ! empty( $link_ids ) ) {
264
-			$wpdb->query( $wpdb->prepare( "UPDATE $wpdb->links SET link_owner = %d WHERE link_owner = %d", $reassign, $user_id ) );
265
-			array_walk( $link_ids, 'clean_bookmark_cache' );
263
+		if ( ! empty($link_ids)) {
264
+			$wpdb->query($wpdb->prepare("UPDATE $wpdb->links SET link_owner = %d WHERE link_owner = %d", $reassign, $user_id));
265
+			array_walk($link_ids, 'clean_bookmark_cache');
266 266
 		}
267 267
 	}
268 268
 
@@ -280,9 +280,9 @@  discard block
 block discarded – undo
280 280
  * @param int $post_id ID of the desired post.
281 281
  * @return string The post's permalink
282 282
  */
283
-function get_blog_permalink( $blog_id, $post_id ) {
284
-	switch_to_blog( $blog_id );
285
-	$link = get_permalink( $post_id );
283
+function get_blog_permalink($blog_id, $post_id) {
284
+	switch_to_blog($blog_id);
285
+	$link = get_permalink($post_id);
286 286
 	restore_current_blog();
287 287
 
288 288
 	return $link;
@@ -304,14 +304,14 @@  discard block
 block discarded – undo
304 304
  * @param string $path   Optional. Not required for subdomain installations.
305 305
  * @return int 0 if no blog found, otherwise the ID of the matching blog
306 306
  */
307
-function get_blog_id_from_url( $domain, $path = '/' ) {
308
-	$domain = strtolower( $domain );
309
-	$path = strtolower( $path );
310
-	$id = wp_cache_get( md5( $domain . $path ), 'blog-id-cache' );
307
+function get_blog_id_from_url($domain, $path = '/') {
308
+	$domain = strtolower($domain);
309
+	$path = strtolower($path);
310
+	$id = wp_cache_get(md5($domain.$path), 'blog-id-cache');
311 311
 
312
-	if ( $id == -1 ) // blog does not exist
312
+	if ($id == -1) // blog does not exist
313 313
 		return 0;
314
-	elseif ( $id )
314
+	elseif ($id)
315 315
 		return (int) $id;
316 316
 
317 317
 	$args = array(
@@ -319,15 +319,15 @@  discard block
 block discarded – undo
319 319
 		'path' => $path,
320 320
 		'fields' => 'ids',
321 321
 	);
322
-	$result = get_sites( $args );
323
-	$id = array_shift( $result );
322
+	$result = get_sites($args);
323
+	$id = array_shift($result);
324 324
 
325
-	if ( ! $id ) {
326
-		wp_cache_set( md5( $domain . $path ), -1, 'blog-id-cache' );
325
+	if ( ! $id) {
326
+		wp_cache_set(md5($domain.$path), -1, 'blog-id-cache');
327 327
 		return 0;
328 328
 	}
329 329
 
330
-	wp_cache_set( md5( $domain . $path ), $id, 'blog-id-cache' );
330
+	wp_cache_set(md5($domain.$path), $id, 'blog-id-cache');
331 331
 
332 332
 	return $id;
333 333
 }
@@ -347,30 +347,30 @@  discard block
 block discarded – undo
347 347
  * @param string $user_email The email provided by the user at registration.
348 348
  * @return bool Returns true when the email address is banned.
349 349
  */
350
-function is_email_address_unsafe( $user_email ) {
351
-	$banned_names = get_site_option( 'banned_email_domains' );
352
-	if ( $banned_names && ! is_array( $banned_names ) )
353
-		$banned_names = explode( "\n", $banned_names );
350
+function is_email_address_unsafe($user_email) {
351
+	$banned_names = get_site_option('banned_email_domains');
352
+	if ($banned_names && ! is_array($banned_names))
353
+		$banned_names = explode("\n", $banned_names);
354 354
 
355 355
 	$is_email_address_unsafe = false;
356 356
 
357
-	if ( $banned_names && is_array( $banned_names ) && false !== strpos( $user_email, '@', 1 ) ) {
358
-		$banned_names = array_map( 'strtolower', $banned_names );
359
-		$normalized_email = strtolower( $user_email );
357
+	if ($banned_names && is_array($banned_names) && false !== strpos($user_email, '@', 1)) {
358
+		$banned_names = array_map('strtolower', $banned_names);
359
+		$normalized_email = strtolower($user_email);
360 360
 
361
-		list( $email_local_part, $email_domain ) = explode( '@', $normalized_email );
361
+		list($email_local_part, $email_domain) = explode('@', $normalized_email);
362 362
 
363
-		foreach ( $banned_names as $banned_domain ) {
364
-			if ( ! $banned_domain )
363
+		foreach ($banned_names as $banned_domain) {
364
+			if ( ! $banned_domain)
365 365
 				continue;
366 366
 
367
-			if ( $email_domain == $banned_domain ) {
367
+			if ($email_domain == $banned_domain) {
368 368
 				$is_email_address_unsafe = true;
369 369
 				break;
370 370
 			}
371 371
 
372 372
 			$dotted_domain = ".$banned_domain";
373
-			if ( $dotted_domain === substr( $normalized_email, -strlen( $dotted_domain ) ) ) {
373
+			if ($dotted_domain === substr($normalized_email, -strlen($dotted_domain))) {
374 374
 				$is_email_address_unsafe = true;
375 375
 				break;
376 376
 			}
@@ -385,7 +385,7 @@  discard block
 block discarded – undo
385 385
 	 * @param bool   $is_email_address_unsafe Whether the email address is "unsafe". Default false.
386 386
 	 * @param string $user_email              User email address.
387 387
 	 */
388
-	return apply_filters( 'is_email_address_unsafe', $is_email_address_unsafe, $user_email );
388
+	return apply_filters('is_email_address_unsafe', $is_email_address_unsafe, $user_email);
389 389
 }
390 390
 
391 391
 /**
@@ -414,86 +414,86 @@  discard block
 block discarded – undo
414 414
 	$errors = new WP_Error();
415 415
 
416 416
 	$orig_username = $user_name;
417
-	$user_name = preg_replace( '/\s+/', '', sanitize_user( $user_name, true ) );
417
+	$user_name = preg_replace('/\s+/', '', sanitize_user($user_name, true));
418 418
 
419
-	if ( $user_name != $orig_username || preg_match( '/[^a-z0-9]/', $user_name ) ) {
420
-		$errors->add( 'user_name', __( 'Usernames can only contain lowercase letters (a-z) and numbers.' ) );
419
+	if ($user_name != $orig_username || preg_match('/[^a-z0-9]/', $user_name)) {
420
+		$errors->add('user_name', __('Usernames can only contain lowercase letters (a-z) and numbers.'));
421 421
 		$user_name = $orig_username;
422 422
 	}
423 423
 
424
-	$user_email = sanitize_email( $user_email );
424
+	$user_email = sanitize_email($user_email);
425 425
 
426
-	if ( empty( $user_name ) )
427
-	   	$errors->add('user_name', __( 'Please enter a username.' ) );
426
+	if (empty($user_name))
427
+	   	$errors->add('user_name', __('Please enter a username.'));
428 428
 
429
-	$illegal_names = get_site_option( 'illegal_names' );
430
-	if ( ! is_array( $illegal_names ) ) {
431
-		$illegal_names = array(  'www', 'web', 'root', 'admin', 'main', 'invite', 'administrator' );
432
-		add_site_option( 'illegal_names', $illegal_names );
429
+	$illegal_names = get_site_option('illegal_names');
430
+	if ( ! is_array($illegal_names)) {
431
+		$illegal_names = array('www', 'web', 'root', 'admin', 'main', 'invite', 'administrator');
432
+		add_site_option('illegal_names', $illegal_names);
433 433
 	}
434
-	if ( in_array( $user_name, $illegal_names ) ) {
435
-		$errors->add( 'user_name',  __( 'Sorry, that username is not allowed.' ) );
434
+	if (in_array($user_name, $illegal_names)) {
435
+		$errors->add('user_name', __('Sorry, that username is not allowed.'));
436 436
 	}
437 437
 
438 438
 	/** This filter is documented in wp-includes/user.php */
439
-	$illegal_logins = (array) apply_filters( 'illegal_user_logins', array() );
439
+	$illegal_logins = (array) apply_filters('illegal_user_logins', array());
440 440
 
441
-	if ( in_array( strtolower( $user_name ), array_map( 'strtolower', $illegal_logins ) ) ) {
442
-		$errors->add( 'user_name',  __( 'Sorry, that username is not allowed.' ) );
441
+	if (in_array(strtolower($user_name), array_map('strtolower', $illegal_logins))) {
442
+		$errors->add('user_name', __('Sorry, that username is not allowed.'));
443 443
 	}
444 444
 
445
-	if ( ! is_email( $user_email ) ) {
446
-		$errors->add( 'user_email', __( 'Please enter a valid email address.' ) );
447
-	} elseif ( is_email_address_unsafe( $user_email ) ) {
448
-		$errors->add( 'user_email', __( 'You cannot use that email address to signup. We are having problems with them blocking some of our email. Please use another email provider.' ) );
445
+	if ( ! is_email($user_email)) {
446
+		$errors->add('user_email', __('Please enter a valid email address.'));
447
+	} elseif (is_email_address_unsafe($user_email)) {
448
+		$errors->add('user_email', __('You cannot use that email address to signup. We are having problems with them blocking some of our email. Please use another email provider.'));
449 449
 	}
450 450
 
451
-	if ( strlen( $user_name ) < 4 )
452
-		$errors->add('user_name',  __( 'Username must be at least 4 characters.' ) );
451
+	if (strlen($user_name) < 4)
452
+		$errors->add('user_name', __('Username must be at least 4 characters.'));
453 453
 
454
-	if ( strlen( $user_name ) > 60 ) {
455
-		$errors->add( 'user_name', __( 'Username may not be longer than 60 characters.' ) );
454
+	if (strlen($user_name) > 60) {
455
+		$errors->add('user_name', __('Username may not be longer than 60 characters.'));
456 456
 	}
457 457
 
458 458
 	// all numeric?
459
-	if ( preg_match( '/^[0-9]*$/', $user_name ) )
459
+	if (preg_match('/^[0-9]*$/', $user_name))
460 460
 		$errors->add('user_name', __('Sorry, usernames must have letters too!'));
461 461
 
462
-	$limited_email_domains = get_site_option( 'limited_email_domains' );
463
-	if ( is_array( $limited_email_domains ) && ! empty( $limited_email_domains ) ) {
464
-		$emaildomain = substr( $user_email, 1 + strpos( $user_email, '@' ) );
465
-		if ( ! in_array( $emaildomain, $limited_email_domains ) ) {
462
+	$limited_email_domains = get_site_option('limited_email_domains');
463
+	if (is_array($limited_email_domains) && ! empty($limited_email_domains)) {
464
+		$emaildomain = substr($user_email, 1 + strpos($user_email, '@'));
465
+		if ( ! in_array($emaildomain, $limited_email_domains)) {
466 466
 			$errors->add('user_email', __('Sorry, that email address is not allowed!'));
467 467
 		}
468 468
 	}
469 469
 
470 470
 	// Check if the username has been used already.
471
-	if ( username_exists($user_name) )
472
-		$errors->add( 'user_name', __( 'Sorry, that username already exists!' ) );
471
+	if (username_exists($user_name))
472
+		$errors->add('user_name', __('Sorry, that username already exists!'));
473 473
 
474 474
 	// Check if the email address has been used already.
475
-	if ( email_exists($user_email) )
476
-		$errors->add( 'user_email', __( 'Sorry, that email address is already used!' ) );
475
+	if (email_exists($user_email))
476
+		$errors->add('user_email', __('Sorry, that email address is already used!'));
477 477
 
478 478
 	// Has someone already signed up for this username?
479
-	$signup = $wpdb->get_row( $wpdb->prepare("SELECT * FROM $wpdb->signups WHERE user_login = %s", $user_name) );
480
-	if ( $signup != null ) {
481
-		$registered_at =  mysql2date('U', $signup->registered);
482
-		$now = current_time( 'timestamp', true );
479
+	$signup = $wpdb->get_row($wpdb->prepare("SELECT * FROM $wpdb->signups WHERE user_login = %s", $user_name));
480
+	if ($signup != null) {
481
+		$registered_at = mysql2date('U', $signup->registered);
482
+		$now = current_time('timestamp', true);
483 483
 		$diff = $now - $registered_at;
484 484
 		// If registered more than two days ago, cancel registration and let this signup go through.
485
-		if ( $diff > 2 * DAY_IN_SECONDS )
486
-			$wpdb->delete( $wpdb->signups, array( 'user_login' => $user_name ) );
485
+		if ($diff > 2 * DAY_IN_SECONDS)
486
+			$wpdb->delete($wpdb->signups, array('user_login' => $user_name));
487 487
 		else
488 488
 			$errors->add('user_name', __('That username is currently reserved but may be available in a couple of days.'));
489 489
 	}
490 490
 
491
-	$signup = $wpdb->get_row( $wpdb->prepare("SELECT * FROM $wpdb->signups WHERE user_email = %s", $user_email) );
492
-	if ( $signup != null ) {
493
-		$diff = current_time( 'timestamp', true ) - mysql2date('U', $signup->registered);
491
+	$signup = $wpdb->get_row($wpdb->prepare("SELECT * FROM $wpdb->signups WHERE user_email = %s", $user_email));
492
+	if ($signup != null) {
493
+		$diff = current_time('timestamp', true) - mysql2date('U', $signup->registered);
494 494
 		// If registered more than two days ago, cancel registration and let this signup go through.
495
-		if ( $diff > 2 * DAY_IN_SECONDS )
496
-			$wpdb->delete( $wpdb->signups, array( 'user_email' => $user_email ) );
495
+		if ($diff > 2 * DAY_IN_SECONDS)
496
+			$wpdb->delete($wpdb->signups, array('user_email' => $user_email));
497 497
 		else
498 498
 			$errors->add('user_email', __('That email address has already been used. Please check your inbox for an activation email. It will become available in a couple of days if you do nothing.'));
499 499
 	}
@@ -517,7 +517,7 @@  discard block
 block discarded – undo
517 517
 	 *     @type WP_Error $errors        WP_Error object containing any errors found.
518 518
 	 * }
519 519
 	 */
520
-	return apply_filters( 'wpmu_validate_user_signup', $result );
520
+	return apply_filters('wpmu_validate_user_signup', $result);
521 521
 }
522 522
 
523 523
 /**
@@ -544,38 +544,38 @@  discard block
 block discarded – undo
544 544
  * @param WP_User|string $user       Optional. The user object to check against the new site name.
545 545
  * @return array Contains the new site data and error messages.
546 546
  */
547
-function wpmu_validate_blog_signup( $blogname, $blog_title, $user = '' ) {
547
+function wpmu_validate_blog_signup($blogname, $blog_title, $user = '') {
548 548
 	global $wpdb, $domain;
549 549
 
550 550
 	$current_network = get_network();
551 551
 	$base = $current_network->path;
552 552
 
553
-	$blog_title = strip_tags( $blog_title );
553
+	$blog_title = strip_tags($blog_title);
554 554
 
555 555
 	$errors = new WP_Error();
556
-	$illegal_names = get_site_option( 'illegal_names' );
557
-	if ( $illegal_names == false ) {
558
-		$illegal_names = array( 'www', 'web', 'root', 'admin', 'main', 'invite', 'administrator' );
559
-		add_site_option( 'illegal_names', $illegal_names );
556
+	$illegal_names = get_site_option('illegal_names');
557
+	if ($illegal_names == false) {
558
+		$illegal_names = array('www', 'web', 'root', 'admin', 'main', 'invite', 'administrator');
559
+		add_site_option('illegal_names', $illegal_names);
560 560
 	}
561 561
 
562 562
 	/*
563 563
 	 * On sub dir installs, some names are so illegal, only a filter can
564 564
 	 * spring them from jail.
565 565
 	 */
566
-	if ( ! is_subdomain_install() ) {
567
-		$illegal_names = array_merge( $illegal_names, get_subdirectory_reserved_names() );
566
+	if ( ! is_subdomain_install()) {
567
+		$illegal_names = array_merge($illegal_names, get_subdirectory_reserved_names());
568 568
 	}
569 569
 
570
-	if ( empty( $blogname ) )
571
-		$errors->add('blogname', __( 'Please enter a site name.' ) );
570
+	if (empty($blogname))
571
+		$errors->add('blogname', __('Please enter a site name.'));
572 572
 
573
-	if ( preg_match( '/[^a-z0-9]+/', $blogname ) ) {
574
-		$errors->add( 'blogname', __( 'Site names can only contain lowercase letters (a-z) and numbers.' ) );
573
+	if (preg_match('/[^a-z0-9]+/', $blogname)) {
574
+		$errors->add('blogname', __('Site names can only contain lowercase letters (a-z) and numbers.'));
575 575
 	}
576 576
 
577
-	if ( in_array( $blogname, $illegal_names ) )
578
-		$errors->add('blogname',  __( 'That name is not allowed.' ) );
577
+	if (in_array($blogname, $illegal_names))
578
+		$errors->add('blogname', __('That name is not allowed.'));
579 579
 
580 580
 	/**
581 581
 	 * Filters the minimum site name length required when validating a site signup.
@@ -584,19 +584,19 @@  discard block
 block discarded – undo
584 584
 	 *
585 585
 	 * @param int $length The minimum site name length. Default 4.
586 586
 	 */
587
-	$minimum_site_name_length = apply_filters( 'minimum_site_name_length', 4 );
587
+	$minimum_site_name_length = apply_filters('minimum_site_name_length', 4);
588 588
 
589
-	if ( strlen( $blogname ) < $minimum_site_name_length ) {
589
+	if (strlen($blogname) < $minimum_site_name_length) {
590 590
 		/* translators: %s: minimum site name length */
591
-		$errors->add( 'blogname', sprintf( _n( 'Site name must be at least %s character.', 'Site name must be at least %s characters.', $minimum_site_name_length ), number_format_i18n( $minimum_site_name_length ) ) );
591
+		$errors->add('blogname', sprintf(_n('Site name must be at least %s character.', 'Site name must be at least %s characters.', $minimum_site_name_length), number_format_i18n($minimum_site_name_length)));
592 592
 	}
593 593
 
594 594
 	// do not allow users to create a blog that conflicts with a page on the main blog.
595
-	if ( !is_subdomain_install() && $wpdb->get_var( $wpdb->prepare( "SELECT post_name FROM " . $wpdb->get_blog_prefix( $current_network->site_id ) . "posts WHERE post_type = 'page' AND post_name = %s", $blogname ) ) )
596
-		$errors->add( 'blogname', __( 'Sorry, you may not use that site name.' ) );
595
+	if ( ! is_subdomain_install() && $wpdb->get_var($wpdb->prepare("SELECT post_name FROM ".$wpdb->get_blog_prefix($current_network->site_id)."posts WHERE post_type = 'page' AND post_name = %s", $blogname)))
596
+		$errors->add('blogname', __('Sorry, you may not use that site name.'));
597 597
 
598 598
 	// all numeric?
599
-	if ( preg_match( '/^[0-9]*$/', $blogname ) )
599
+	if (preg_match('/^[0-9]*$/', $blogname))
600 600
 		$errors->add('blogname', __('Sorry, site names must have letters too!'));
601 601
 
602 602
 	/**
@@ -609,36 +609,36 @@  discard block
 block discarded – undo
609 609
 	 *
610 610
 	 * @param string $blogname Site name.
611 611
 	 */
612
-	$blogname = apply_filters( 'newblogname', $blogname );
612
+	$blogname = apply_filters('newblogname', $blogname);
613 613
 
614
-	$blog_title = wp_unslash(  $blog_title );
614
+	$blog_title = wp_unslash($blog_title);
615 615
 
616
-	if ( empty( $blog_title ) )
617
-		$errors->add('blog_title', __( 'Please enter a site title.' ) );
616
+	if (empty($blog_title))
617
+		$errors->add('blog_title', __('Please enter a site title.'));
618 618
 
619 619
 	// Check if the domain/path has been used already.
620
-	if ( is_subdomain_install() ) {
621
-		$mydomain = $blogname . '.' . preg_replace( '|^www\.|', '', $domain );
620
+	if (is_subdomain_install()) {
621
+		$mydomain = $blogname.'.'.preg_replace('|^www\.|', '', $domain);
622 622
 		$path = $base;
623 623
 	} else {
624 624
 		$mydomain = "$domain";
625 625
 		$path = $base.$blogname.'/';
626 626
 	}
627
-	if ( domain_exists($mydomain, $path, $current_network->id) )
628
-		$errors->add( 'blogname', __( 'Sorry, that site already exists!' ) );
627
+	if (domain_exists($mydomain, $path, $current_network->id))
628
+		$errors->add('blogname', __('Sorry, that site already exists!'));
629 629
 
630
-	if ( username_exists( $blogname ) ) {
631
-		if ( ! is_object( $user ) || ( is_object($user) && ( $user->user_login != $blogname ) ) )
632
-			$errors->add( 'blogname', __( 'Sorry, that site is reserved!' ) );
630
+	if (username_exists($blogname)) {
631
+		if ( ! is_object($user) || (is_object($user) && ($user->user_login != $blogname)))
632
+			$errors->add('blogname', __('Sorry, that site is reserved!'));
633 633
 	}
634 634
 
635 635
 	// Has someone already signed up for this domain?
636
-	$signup = $wpdb->get_row( $wpdb->prepare("SELECT * FROM $wpdb->signups WHERE domain = %s AND path = %s", $mydomain, $path) ); // TODO: Check email too?
637
-	if ( ! empty($signup) ) {
638
-		$diff = current_time( 'timestamp', true ) - mysql2date('U', $signup->registered);
636
+	$signup = $wpdb->get_row($wpdb->prepare("SELECT * FROM $wpdb->signups WHERE domain = %s AND path = %s", $mydomain, $path)); // TODO: Check email too?
637
+	if ( ! empty($signup)) {
638
+		$diff = current_time('timestamp', true) - mysql2date('U', $signup->registered);
639 639
 		// If registered more than two days ago, cancel registration and let this signup go through.
640
-		if ( $diff > 2 * DAY_IN_SECONDS )
641
-			$wpdb->delete( $wpdb->signups, array( 'domain' => $mydomain , 'path' => $path ) );
640
+		if ($diff > 2 * DAY_IN_SECONDS)
641
+			$wpdb->delete($wpdb->signups, array('domain' => $mydomain, 'path' => $path));
642 642
 		else
643 643
 			$errors->add('blogname', __('That site is currently reserved but may be available in a couple days.'));
644 644
 	}
@@ -661,7 +661,7 @@  discard block
 block discarded – undo
661 661
 	 *     @type WP_Error       $errors     WP_Error containing any errors found.
662 662
 	 * }
663 663
 	 */
664
-	return apply_filters( 'wpmu_validate_blog_signup', $result );
664
+	return apply_filters('wpmu_validate_blog_signup', $result);
665 665
 }
666 666
 
667 667
 /**
@@ -678,10 +678,10 @@  discard block
 block discarded – undo
678 678
  * @param string $user_email The user's email address.
679 679
  * @param array  $meta       Optional. Signup meta data. By default, contains the requested privacy setting and lang_id.
680 680
  */
681
-function wpmu_signup_blog( $domain, $path, $title, $user, $user_email, $meta = array() )  {
681
+function wpmu_signup_blog($domain, $path, $title, $user, $user_email, $meta = array()) {
682 682
 	global $wpdb;
683 683
 
684
-	$key = substr( md5( time() . wp_rand() . $domain ), 0, 16 );
684
+	$key = substr(md5(time().wp_rand().$domain), 0, 16);
685 685
 
686 686
 	/**
687 687
 	 * Filters the metadata for a site signup.
@@ -698,9 +698,9 @@  discard block
 block discarded – undo
698 698
 	 * @param string $user_email The user's email address.
699 699
 	 * @param string $key        The user's activation key.
700 700
 	 */
701
-	$meta = apply_filters( 'signup_site_meta', $meta, $domain, $path, $title, $user, $user_email, $key );
701
+	$meta = apply_filters('signup_site_meta', $meta, $domain, $path, $title, $user, $user_email, $key);
702 702
 
703
-	$wpdb->insert( $wpdb->signups, array(
703
+	$wpdb->insert($wpdb->signups, array(
704 704
 		'domain' => $domain,
705 705
 		'path' => $path,
706 706
 		'title' => $title,
@@ -708,8 +708,8 @@  discard block
 block discarded – undo
708 708
 		'user_email' => $user_email,
709 709
 		'registered' => current_time('mysql', true),
710 710
 		'activation_key' => $key,
711
-		'meta' => serialize( $meta )
712
-	) );
711
+		'meta' => serialize($meta)
712
+	));
713 713
 
714 714
 	/**
715 715
 	 * Fires after site signup information has been written to the database.
@@ -724,7 +724,7 @@  discard block
 block discarded – undo
724 724
 	 * @param string $key        The user's activation key.
725 725
 	 * @param array  $meta       Signup meta data. By default, contains the requested privacy setting and lang_id.
726 726
 	 */
727
-	do_action( 'after_signup_site', $domain, $path, $title, $user, $user_email, $key, $meta );
727
+	do_action('after_signup_site', $domain, $path, $title, $user, $user_email, $key, $meta);
728 728
 }
729 729
 
730 730
 /**
@@ -741,13 +741,13 @@  discard block
 block discarded – undo
741 741
  * @param string $user_email The user's email address.
742 742
  * @param array  $meta       Optional. Signup meta data. Default empty array.
743 743
  */
744
-function wpmu_signup_user( $user, $user_email, $meta = array() ) {
744
+function wpmu_signup_user($user, $user_email, $meta = array()) {
745 745
 	global $wpdb;
746 746
 
747 747
 	// Format data
748
-	$user = preg_replace( '/\s+/', '', sanitize_user( $user, true ) );
749
-	$user_email = sanitize_email( $user_email );
750
-	$key = substr( md5( time() . wp_rand() . $user_email ), 0, 16 );
748
+	$user = preg_replace('/\s+/', '', sanitize_user($user, true));
749
+	$user_email = sanitize_email($user_email);
750
+	$key = substr(md5(time().wp_rand().$user_email), 0, 16);
751 751
 
752 752
 	/**
753 753
 	 * Filters the metadata for a user signup.
@@ -761,9 +761,9 @@  discard block
 block discarded – undo
761 761
 	 * @param string $user_email The user's email address.
762 762
 	 * @param string $key        The user's activation key.
763 763
 	 */
764
-	$meta = apply_filters( 'signup_user_meta', $meta, $user, $user_email, $key );
764
+	$meta = apply_filters('signup_user_meta', $meta, $user, $user_email, $key);
765 765
 
766
-	$wpdb->insert( $wpdb->signups, array(
766
+	$wpdb->insert($wpdb->signups, array(
767 767
 		'domain' => '',
768 768
 		'path' => '',
769 769
 		'title' => '',
@@ -771,8 +771,8 @@  discard block
 block discarded – undo
771 771
 		'user_email' => $user_email,
772 772
 		'registered' => current_time('mysql', true),
773 773
 		'activation_key' => $key,
774
-		'meta' => serialize( $meta )
775
-	) );
774
+		'meta' => serialize($meta)
775
+	));
776 776
 
777 777
 	/**
778 778
 	 * Fires after a user's signup information has been written to the database.
@@ -784,7 +784,7 @@  discard block
 block discarded – undo
784 784
 	 * @param string $key        The user's activation key.
785 785
 	 * @param array  $meta       Signup meta data. Default empty array.
786 786
 	 */
787
-	do_action( 'after_signup_user', $user, $user_email, $key, $meta );
787
+	do_action('after_signup_user', $user, $user_email, $key, $meta);
788 788
 }
789 789
 
790 790
 /**
@@ -811,7 +811,7 @@  discard block
 block discarded – undo
811 811
  * @param array  $meta       Optional. Signup meta data. By default, contains the requested privacy setting and lang_id.
812 812
  * @return bool
813 813
  */
814
-function wpmu_signup_blog_notification( $domain, $path, $title, $user_login, $user_email, $key, $meta = array() ) {
814
+function wpmu_signup_blog_notification($domain, $path, $title, $user_login, $user_email, $key, $meta = array()) {
815 815
 	/**
816 816
 	 * Filters whether to bypass the new site email notification.
817 817
 	 *
@@ -825,25 +825,25 @@  discard block
 block discarded – undo
825 825
 	 * @param string      $key        Activation key created in wpmu_signup_blog().
826 826
 	 * @param array       $meta       Signup meta data. By default, contains the requested privacy setting and lang_id.
827 827
 	 */
828
-	if ( ! apply_filters( 'wpmu_signup_blog_notification', $domain, $path, $title, $user_login, $user_email, $key, $meta ) ) {
828
+	if ( ! apply_filters('wpmu_signup_blog_notification', $domain, $path, $title, $user_login, $user_email, $key, $meta)) {
829 829
 		return false;
830 830
 	}
831 831
 
832 832
 	// Send email with activation link.
833
-	if ( !is_subdomain_install() || get_current_network_id() != 1 )
833
+	if ( ! is_subdomain_install() || get_current_network_id() != 1)
834 834
 		$activate_url = network_site_url("wp-activate.php?key=$key");
835 835
 	else
836 836
 		$activate_url = "http://{$domain}{$path}wp-activate.php?key=$key"; // @todo use *_url() API
837 837
 
838 838
 	$activate_url = esc_url($activate_url);
839
-	$admin_email = get_site_option( 'admin_email' );
840
-	if ( $admin_email == '' )
841
-		$admin_email = 'support@' . $_SERVER['SERVER_NAME'];
842
-	$from_name = get_site_option( 'site_name' ) == '' ? 'WordPress' : esc_html( get_site_option( 'site_name' ) );
843
-	$message_headers = "From: \"{$from_name}\" <{$admin_email}>\n" . "Content-Type: text/plain; charset=\"" . get_option('blog_charset') . "\"\n";
839
+	$admin_email = get_site_option('admin_email');
840
+	if ($admin_email == '')
841
+		$admin_email = 'support@'.$_SERVER['SERVER_NAME'];
842
+	$from_name = get_site_option('site_name') == '' ? 'WordPress' : esc_html(get_site_option('site_name'));
843
+	$message_headers = "From: \"{$from_name}\" <{$admin_email}>\n"."Content-Type: text/plain; charset=\"".get_option('blog_charset')."\"\n";
844 844
 
845
-	$user = get_user_by( 'login', $user_login );
846
-	$switched_locale = switch_to_locale( get_user_locale( $user ) );
845
+	$user = get_user_by('login', $user_login);
846
+	$switched_locale = switch_to_locale(get_user_locale($user));
847 847
 
848 848
 	$message = sprintf(
849 849
 		/**
@@ -862,12 +862,12 @@  discard block
 block discarded – undo
862 862
 		 * @param string $key        Activation key created in wpmu_signup_blog().
863 863
 		 * @param array  $meta       Signup meta data. By default, contains the requested privacy setting and lang_id.
864 864
 		 */
865
-		apply_filters( 'wpmu_signup_blog_notification_email',
866
-			__( "To activate your blog, please click the following link:\n\n%s\n\nAfter you activate, you will receive *another email* with your login.\n\nAfter you activate, you can visit your site here:\n\n%s" ),
865
+		apply_filters('wpmu_signup_blog_notification_email',
866
+			__("To activate your blog, please click the following link:\n\n%s\n\nAfter you activate, you will receive *another email* with your login.\n\nAfter you activate, you can visit your site here:\n\n%s"),
867 867
 			$domain, $path, $title, $user_login, $user_email, $key, $meta
868 868
 		),
869 869
 		$activate_url,
870
-		esc_url( "http://{$domain}{$path}" ),
870
+		esc_url("http://{$domain}{$path}"),
871 871
 		$key
872 872
 	);
873 873
 	// TODO: Don't hard code activation link.
@@ -886,17 +886,17 @@  discard block
 block discarded – undo
886 886
 		 * @param string $key        Activation key created in wpmu_signup_blog().
887 887
 		 * @param array  $meta       Signup meta data. By default, contains the requested privacy setting and lang_id.
888 888
 		 */
889
-		apply_filters( 'wpmu_signup_blog_notification_subject',
889
+		apply_filters('wpmu_signup_blog_notification_subject',
890 890
 			/* translators: New site notification email subject. 1: Network name, 2: New site URL */
891
-			_x( '[%1$s] Activate %2$s', 'New site notification email subject' ),
891
+			_x('[%1$s] Activate %2$s', 'New site notification email subject'),
892 892
 			$domain, $path, $title, $user_login, $user_email, $key, $meta
893 893
 		),
894 894
 		$from_name,
895
-		esc_url( 'http://' . $domain . $path )
895
+		esc_url('http://'.$domain.$path)
896 896
 	);
897
-	wp_mail( $user_email, wp_specialchars_decode( $subject ), $message, $message_headers );
897
+	wp_mail($user_email, wp_specialchars_decode($subject), $message, $message_headers);
898 898
 
899
-	if ( $switched_locale ) {
899
+	if ($switched_locale) {
900 900
 		restore_previous_locale();
901 901
 	}
902 902
 
@@ -924,7 +924,7 @@  discard block
 block discarded – undo
924 924
  * @param array  $meta       Optional. Signup meta data. Default empty array.
925 925
  * @return bool
926 926
  */
927
-function wpmu_signup_user_notification( $user_login, $user_email, $key, $meta = array() ) {
927
+function wpmu_signup_user_notification($user_login, $user_email, $key, $meta = array()) {
928 928
 	/**
929 929
 	 * Filters whether to bypass the email notification for new user sign-up.
930 930
 	 *
@@ -935,18 +935,18 @@  discard block
 block discarded – undo
935 935
 	 * @param string $key        Activation key created in wpmu_signup_user().
936 936
 	 * @param array  $meta       Signup meta data. Default empty array.
937 937
 	 */
938
-	if ( ! apply_filters( 'wpmu_signup_user_notification', $user_login, $user_email, $key, $meta ) )
938
+	if ( ! apply_filters('wpmu_signup_user_notification', $user_login, $user_email, $key, $meta))
939 939
 		return false;
940 940
 
941
-	$user = get_user_by( 'login', $user_login );
942
-	$switched_locale = switch_to_locale( get_user_locale( $user ) );
941
+	$user = get_user_by('login', $user_login);
942
+	$switched_locale = switch_to_locale(get_user_locale($user));
943 943
 
944 944
 	// Send email with activation link.
945
-	$admin_email = get_site_option( 'admin_email' );
946
-	if ( $admin_email == '' )
947
-		$admin_email = 'support@' . $_SERVER['SERVER_NAME'];
948
-	$from_name = get_site_option( 'site_name' ) == '' ? 'WordPress' : esc_html( get_site_option( 'site_name' ) );
949
-	$message_headers = "From: \"{$from_name}\" <{$admin_email}>\n" . "Content-Type: text/plain; charset=\"" . get_option('blog_charset') . "\"\n";
945
+	$admin_email = get_site_option('admin_email');
946
+	if ($admin_email == '')
947
+		$admin_email = 'support@'.$_SERVER['SERVER_NAME'];
948
+	$from_name = get_site_option('site_name') == '' ? 'WordPress' : esc_html(get_site_option('site_name'));
949
+	$message_headers = "From: \"{$from_name}\" <{$admin_email}>\n"."Content-Type: text/plain; charset=\"".get_option('blog_charset')."\"\n";
950 950
 	$message = sprintf(
951 951
 		/**
952 952
 		 * Filters the content of the notification email for new user sign-up.
@@ -961,11 +961,11 @@  discard block
 block discarded – undo
961 961
 		 * @param string $key        Activation key created in wpmu_signup_user().
962 962
 		 * @param array  $meta       Signup meta data. Default empty array.
963 963
 		 */
964
-		apply_filters( 'wpmu_signup_user_notification_email',
965
-			__( "To activate your user, please click the following link:\n\n%s\n\nAfter you activate, you will receive *another email* with your login." ),
964
+		apply_filters('wpmu_signup_user_notification_email',
965
+			__("To activate your user, please click the following link:\n\n%s\n\nAfter you activate, you will receive *another email* with your login."),
966 966
 			$user_login, $user_email, $key, $meta
967 967
 		),
968
-		site_url( "wp-activate.php?key=$key" )
968
+		site_url("wp-activate.php?key=$key")
969 969
 	);
970 970
 	// TODO: Don't hard code activation link.
971 971
 	$subject = sprintf(
@@ -980,17 +980,17 @@  discard block
 block discarded – undo
980 980
 		 * @param string $key        Activation key created in wpmu_signup_user().
981 981
 		 * @param array  $meta       Signup meta data. Default empty array.
982 982
 		 */
983
-		apply_filters( 'wpmu_signup_user_notification_subject',
983
+		apply_filters('wpmu_signup_user_notification_subject',
984 984
 			/* translators: New user notification email subject. 1: Network name, 2: New user login */
985
-			_x( '[%1$s] Activate %2$s', 'New user notification email subject' ),
985
+			_x('[%1$s] Activate %2$s', 'New user notification email subject'),
986 986
 			$user_login, $user_email, $key, $meta
987 987
 		),
988 988
 		$from_name,
989 989
 		$user_login
990 990
 	);
991
-	wp_mail( $user_email, wp_specialchars_decode( $subject ), $message, $message_headers );
991
+	wp_mail($user_email, wp_specialchars_decode($subject), $message, $message_headers);
992 992
 
993
-	if ( $switched_locale ) {
993
+	if ($switched_locale) {
994 994
 		restore_previous_locale();
995 995
 	}
996 996
 
@@ -1015,38 +1015,38 @@  discard block
 block discarded – undo
1015 1015
 function wpmu_activate_signup($key) {
1016 1016
 	global $wpdb;
1017 1017
 
1018
-	$signup = $wpdb->get_row( $wpdb->prepare("SELECT * FROM $wpdb->signups WHERE activation_key = %s", $key) );
1018
+	$signup = $wpdb->get_row($wpdb->prepare("SELECT * FROM $wpdb->signups WHERE activation_key = %s", $key));
1019 1019
 
1020
-	if ( empty( $signup ) )
1021
-		return new WP_Error( 'invalid_key', __( 'Invalid activation key.' ) );
1020
+	if (empty($signup))
1021
+		return new WP_Error('invalid_key', __('Invalid activation key.'));
1022 1022
 
1023
-	if ( $signup->active ) {
1024
-		if ( empty( $signup->domain ) )
1025
-			return new WP_Error( 'already_active', __( 'The user is already active.' ), $signup );
1023
+	if ($signup->active) {
1024
+		if (empty($signup->domain))
1025
+			return new WP_Error('already_active', __('The user is already active.'), $signup);
1026 1026
 		else
1027
-			return new WP_Error( 'already_active', __( 'The site is already active.' ), $signup );
1027
+			return new WP_Error('already_active', __('The site is already active.'), $signup);
1028 1028
 	}
1029 1029
 
1030 1030
 	$meta = maybe_unserialize($signup->meta);
1031
-	$password = wp_generate_password( 12, false );
1031
+	$password = wp_generate_password(12, false);
1032 1032
 
1033 1033
 	$user_id = username_exists($signup->user_login);
1034 1034
 
1035
-	if ( ! $user_id )
1035
+	if ( ! $user_id)
1036 1036
 		$user_id = wpmu_create_user($signup->user_login, $password, $signup->user_email);
1037 1037
 	else
1038 1038
 		$user_already_exists = true;
1039 1039
 
1040
-	if ( ! $user_id )
1040
+	if ( ! $user_id)
1041 1041
 		return new WP_Error('create_user', __('Could not create user'), $signup);
1042 1042
 
1043 1043
 	$now = current_time('mysql', true);
1044 1044
 
1045
-	if ( empty($signup->domain) ) {
1046
-		$wpdb->update( $wpdb->signups, array('active' => 1, 'activated' => $now), array('activation_key' => $key) );
1045
+	if (empty($signup->domain)) {
1046
+		$wpdb->update($wpdb->signups, array('active' => 1, 'activated' => $now), array('activation_key' => $key));
1047 1047
 
1048
-		if ( isset( $user_already_exists ) )
1049
-			return new WP_Error( 'user_already_exists', __( 'That username is already activated.' ), $signup);
1048
+		if (isset($user_already_exists))
1049
+			return new WP_Error('user_already_exists', __('That username is already activated.'), $signup);
1050 1050
 
1051 1051
 		/**
1052 1052
 		 * Fires immediately after a new user is activated.
@@ -1057,24 +1057,24 @@  discard block
 block discarded – undo
1057 1057
 		 * @param int   $password User password.
1058 1058
 		 * @param array $meta     Signup meta data.
1059 1059
 		 */
1060
-		do_action( 'wpmu_activate_user', $user_id, $password, $meta );
1061
-		return array( 'user_id' => $user_id, 'password' => $password, 'meta' => $meta );
1060
+		do_action('wpmu_activate_user', $user_id, $password, $meta);
1061
+		return array('user_id' => $user_id, 'password' => $password, 'meta' => $meta);
1062 1062
 	}
1063 1063
 
1064
-	$blog_id = wpmu_create_blog( $signup->domain, $signup->path, $signup->title, $user_id, $meta, $wpdb->siteid );
1064
+	$blog_id = wpmu_create_blog($signup->domain, $signup->path, $signup->title, $user_id, $meta, $wpdb->siteid);
1065 1065
 
1066 1066
 	// TODO: What to do if we create a user but cannot create a blog?
1067
-	if ( is_wp_error($blog_id) ) {
1067
+	if (is_wp_error($blog_id)) {
1068 1068
 		// If blog is taken, that means a previous attempt to activate this blog failed in between creating the blog and
1069 1069
 		// setting the activation flag. Let's just set the active flag and instruct the user to reset their password.
1070
-		if ( 'blog_taken' == $blog_id->get_error_code() ) {
1071
-			$blog_id->add_data( $signup );
1072
-			$wpdb->update( $wpdb->signups, array( 'active' => 1, 'activated' => $now ), array( 'activation_key' => $key ) );
1070
+		if ('blog_taken' == $blog_id->get_error_code()) {
1071
+			$blog_id->add_data($signup);
1072
+			$wpdb->update($wpdb->signups, array('active' => 1, 'activated' => $now), array('activation_key' => $key));
1073 1073
 		}
1074 1074
 		return $blog_id;
1075 1075
 	}
1076 1076
 
1077
-	$wpdb->update( $wpdb->signups, array('active' => 1, 'activated' => $now), array('activation_key' => $key) );
1077
+	$wpdb->update($wpdb->signups, array('active' => 1, 'activated' => $now), array('activation_key' => $key));
1078 1078
 	/**
1079 1079
 	 * Fires immediately after a site is activated.
1080 1080
 	 *
@@ -1086,7 +1086,7 @@  discard block
 block discarded – undo
1086 1086
 	 * @param string $signup_title  Site title.
1087 1087
 	 * @param array  $meta          Signup meta data. By default, contains the requested privacy setting and lang_id.
1088 1088
 	 */
1089
-	do_action( 'wpmu_activate_blog', $blog_id, $user_id, $password, $signup->title, $meta );
1089
+	do_action('wpmu_activate_blog', $blog_id, $user_id, $password, $signup->title, $meta);
1090 1090
 
1091 1091
 	return array('blog_id' => $blog_id, 'user_id' => $user_id, 'password' => $password, 'title' => $signup->title, 'meta' => $meta);
1092 1092
 }
@@ -1106,16 +1106,16 @@  discard block
 block discarded – undo
1106 1106
  * @param string $email     The new user's email address.
1107 1107
  * @return int|false Returns false on failure, or int $user_id on success
1108 1108
  */
1109
-function wpmu_create_user( $user_name, $password, $email ) {
1110
-	$user_name = preg_replace( '/\s+/', '', sanitize_user( $user_name, true ) );
1109
+function wpmu_create_user($user_name, $password, $email) {
1110
+	$user_name = preg_replace('/\s+/', '', sanitize_user($user_name, true));
1111 1111
 
1112
-	$user_id = wp_create_user( $user_name, $password, $email );
1113
-	if ( is_wp_error( $user_id ) )
1112
+	$user_id = wp_create_user($user_name, $password, $email);
1113
+	if (is_wp_error($user_id))
1114 1114
 		return false;
1115 1115
 
1116 1116
 	// Newly created users have no roles or caps until they are added to a blog.
1117
-	delete_user_option( $user_id, 'capabilities' );
1118
-	delete_user_option( $user_id, 'user_level' );
1117
+	delete_user_option($user_id, 'capabilities');
1118
+	delete_user_option($user_id, 'user_level');
1119 1119
 
1120 1120
 	/**
1121 1121
 	 * Fires immediately after a new user is created.
@@ -1124,7 +1124,7 @@  discard block
 block discarded – undo
1124 1124
 	 *
1125 1125
 	 * @param int $user_id User ID.
1126 1126
 	 */
1127
-	do_action( 'wpmu_new_user', $user_id );
1127
+	do_action('wpmu_new_user', $user_id);
1128 1128
 
1129 1129
 	return $user_id;
1130 1130
 }
@@ -1151,33 +1151,33 @@  discard block
 block discarded – undo
1151 1151
  * @param int    $site_id Optional. Only relevant on multi-network installs.
1152 1152
  * @return int|WP_Error Returns WP_Error object on failure, int $blog_id on success
1153 1153
  */
1154
-function wpmu_create_blog( $domain, $path, $title, $user_id, $meta = array(), $site_id = 1 ) {
1154
+function wpmu_create_blog($domain, $path, $title, $user_id, $meta = array(), $site_id = 1) {
1155 1155
 	$defaults = array(
1156 1156
 		'public' => 0,
1157
-		'WPLANG' => get_site_option( 'WPLANG' ),
1157
+		'WPLANG' => get_site_option('WPLANG'),
1158 1158
 	);
1159
-	$meta = wp_parse_args( $meta, $defaults );
1159
+	$meta = wp_parse_args($meta, $defaults);
1160 1160
 
1161
-	$domain = preg_replace( '/\s+/', '', sanitize_user( $domain, true ) );
1161
+	$domain = preg_replace('/\s+/', '', sanitize_user($domain, true));
1162 1162
 
1163
-	if ( is_subdomain_install() )
1164
-		$domain = str_replace( '@', '', $domain );
1163
+	if (is_subdomain_install())
1164
+		$domain = str_replace('@', '', $domain);
1165 1165
 
1166
-	$title = strip_tags( $title );
1166
+	$title = strip_tags($title);
1167 1167
 	$user_id = (int) $user_id;
1168 1168
 
1169
-	if ( empty($path) )
1169
+	if (empty($path))
1170 1170
 		$path = '/';
1171 1171
 
1172 1172
 	// Check if the domain has been used already. We should return an error message.
1173
-	if ( domain_exists($domain, $path, $site_id) )
1174
-		return new WP_Error( 'blog_taken', __( 'Sorry, that site already exists!' ) );
1173
+	if (domain_exists($domain, $path, $site_id))
1174
+		return new WP_Error('blog_taken', __('Sorry, that site already exists!'));
1175 1175
 
1176
-	if ( ! wp_installing() ) {
1177
-		wp_installing( true );
1176
+	if ( ! wp_installing()) {
1177
+		wp_installing(true);
1178 1178
 	}
1179 1179
 
1180
-	if ( ! $blog_id = insert_blog($domain, $path, $site_id) )
1180
+	if ( ! $blog_id = insert_blog($domain, $path, $site_id))
1181 1181
 		return new WP_Error('insert_blog', __('Could not create site.'));
1182 1182
 
1183 1183
 	switch_to_blog($blog_id);
@@ -1186,17 +1186,17 @@  discard block
 block discarded – undo
1186 1186
 
1187 1187
 	add_user_to_blog($blog_id, $user_id, 'administrator');
1188 1188
 
1189
-	foreach ( $meta as $key => $value ) {
1190
-		if ( in_array( $key, array( 'public', 'archived', 'mature', 'spam', 'deleted', 'lang_id' ) ) )
1191
-			update_blog_status( $blog_id, $key, $value );
1189
+	foreach ($meta as $key => $value) {
1190
+		if (in_array($key, array('public', 'archived', 'mature', 'spam', 'deleted', 'lang_id')))
1191
+			update_blog_status($blog_id, $key, $value);
1192 1192
 		else
1193
-			update_option( $key, $value );
1193
+			update_option($key, $value);
1194 1194
 	}
1195 1195
 
1196
-	update_option( 'blog_public', (int) $meta['public'] );
1196
+	update_option('blog_public', (int) $meta['public']);
1197 1197
 
1198
-	if ( ! is_super_admin( $user_id ) && ! get_user_meta( $user_id, 'primary_blog', true ) )
1199
-		update_user_meta( $user_id, 'primary_blog', $blog_id );
1198
+	if ( ! is_super_admin($user_id) && ! get_user_meta($user_id, 'primary_blog', true))
1199
+		update_user_meta($user_id, 'primary_blog', $blog_id);
1200 1200
 
1201 1201
 	restore_current_blog();
1202 1202
 	/**
@@ -1211,9 +1211,9 @@  discard block
 block discarded – undo
1211 1211
 	 * @param int    $site_id Site ID. Only relevant on multi-network installs.
1212 1212
 	 * @param array  $meta    Meta data. Used to set initial site options.
1213 1213
 	 */
1214
-	do_action( 'wpmu_new_blog', $blog_id, $user_id, $domain, $path, $site_id, $meta );
1214
+	do_action('wpmu_new_blog', $blog_id, $user_id, $domain, $path, $site_id, $meta);
1215 1215
 
1216
-	wp_cache_set( 'last_changed', microtime(), 'sites' );
1216
+	wp_cache_set('last_changed', microtime(), 'sites');
1217 1217
 
1218 1218
 	return $blog_id;
1219 1219
 }
@@ -1230,27 +1230,27 @@  discard block
 block discarded – undo
1230 1230
  * @param string $deprecated Not used.
1231 1231
  * @return bool
1232 1232
  */
1233
-function newblog_notify_siteadmin( $blog_id, $deprecated = '' ) {
1234
-	if ( get_site_option( 'registrationnotification' ) != 'yes' )
1233
+function newblog_notify_siteadmin($blog_id, $deprecated = '') {
1234
+	if (get_site_option('registrationnotification') != 'yes')
1235 1235
 		return false;
1236 1236
 
1237
-	$email = get_site_option( 'admin_email' );
1238
-	if ( is_email($email) == false )
1237
+	$email = get_site_option('admin_email');
1238
+	if (is_email($email) == false)
1239 1239
 		return false;
1240 1240
 
1241 1241
 	$options_site_url = esc_url(network_admin_url('settings.php'));
1242 1242
 
1243
-	switch_to_blog( $blog_id );
1244
-	$blogname = get_option( 'blogname' );
1243
+	switch_to_blog($blog_id);
1244
+	$blogname = get_option('blogname');
1245 1245
 	$siteurl = site_url();
1246 1246
 	restore_current_blog();
1247 1247
 
1248 1248
 	/* translators: New site notification email. 1: Site URL, 2: User IP address, 3: Settings screen URL */
1249
-	$msg = sprintf( __( 'New Site: %1$s
1249
+	$msg = sprintf(__('New Site: %1$s
1250 1250
 URL: %2$s
1251 1251
 Remote IP: %3$s
1252 1252
 
1253
-Disable these notifications: %4$s' ), $blogname, $siteurl, wp_unslash( $_SERVER['REMOTE_ADDR'] ), $options_site_url);
1253
+Disable these notifications: %4$s' ), $blogname, $siteurl, wp_unslash($_SERVER['REMOTE_ADDR']), $options_site_url);
1254 1254
 	/**
1255 1255
 	 * Filters the message body of the new site activation email sent
1256 1256
 	 * to the network administrator.
@@ -1259,9 +1259,9 @@  discard block
 block discarded – undo
1259 1259
 	 *
1260 1260
 	 * @param string $msg Email body.
1261 1261
 	 */
1262
-	$msg = apply_filters( 'newblog_notify_siteadmin', $msg );
1262
+	$msg = apply_filters('newblog_notify_siteadmin', $msg);
1263 1263
 
1264
-	wp_mail( $email, sprintf( __( 'New Site Registration: %s' ), $siteurl ), $msg );
1264
+	wp_mail($email, sprintf(__('New Site Registration: %s'), $siteurl), $msg);
1265 1265
 	return true;
1266 1266
 }
1267 1267
 
@@ -1276,23 +1276,23 @@  discard block
 block discarded – undo
1276 1276
  * @param int $user_id The new user's ID.
1277 1277
  * @return bool
1278 1278
  */
1279
-function newuser_notify_siteadmin( $user_id ) {
1280
-	if ( get_site_option( 'registrationnotification' ) != 'yes' )
1279
+function newuser_notify_siteadmin($user_id) {
1280
+	if (get_site_option('registrationnotification') != 'yes')
1281 1281
 		return false;
1282 1282
 
1283
-	$email = get_site_option( 'admin_email' );
1283
+	$email = get_site_option('admin_email');
1284 1284
 
1285
-	if ( is_email($email) == false )
1285
+	if (is_email($email) == false)
1286 1286
 		return false;
1287 1287
 
1288
-	$user = get_userdata( $user_id );
1288
+	$user = get_userdata($user_id);
1289 1289
 
1290 1290
 	$options_site_url = esc_url(network_admin_url('settings.php'));
1291 1291
 	/* translators: New user notification email. 1: User login, 2: User IP address, 3: Settings screen URL */
1292 1292
 	$msg = sprintf(__('New User: %1$s
1293 1293
 Remote IP: %2$s
1294 1294
 
1295
-Disable these notifications: %3$s'), $user->user_login, wp_unslash( $_SERVER['REMOTE_ADDR'] ), $options_site_url);
1295
+Disable these notifications: %3$s'), $user->user_login, wp_unslash($_SERVER['REMOTE_ADDR']), $options_site_url);
1296 1296
 
1297 1297
 	/**
1298 1298
 	 * Filters the message body of the new user activation email sent
@@ -1303,8 +1303,8 @@  discard block
 block discarded – undo
1303 1303
 	 * @param string  $msg  Email body.
1304 1304
 	 * @param WP_User $user WP_User instance of the new user.
1305 1305
 	 */
1306
-	$msg = apply_filters( 'newuser_notify_siteadmin', $msg, $user );
1307
-	wp_mail( $email, sprintf(__('New User Registration: %s'), $user->user_login), $msg );
1306
+	$msg = apply_filters('newuser_notify_siteadmin', $msg, $user);
1307
+	wp_mail($email, sprintf(__('New User Registration: %s'), $user->user_login), $msg);
1308 1308
 	return true;
1309 1309
 }
1310 1310
 
@@ -1324,15 +1324,15 @@  discard block
 block discarded – undo
1324 1324
  * @return int
1325 1325
  */
1326 1326
 function domain_exists($domain, $path, $site_id = 1) {
1327
-	$path = trailingslashit( $path );
1327
+	$path = trailingslashit($path);
1328 1328
 	$args = array(
1329 1329
 		'network_id' => $site_id,
1330 1330
 		'domain' => $domain,
1331 1331
 		'path' => $path,
1332 1332
 		'fields' => 'ids',
1333 1333
 	);
1334
-	$result = get_sites( $args );
1335
-	$result = array_shift( $result );
1334
+	$result = get_sites($args);
1335
+	$result = array_shift($result);
1336 1336
 
1337 1337
 	/**
1338 1338
 	 * Filters whether a blogname is taken.
@@ -1344,7 +1344,7 @@  discard block
 block discarded – undo
1344 1344
 	 * @param string   $path    Path to be checked.
1345 1345
 	 * @param int      $site_id Site ID. Relevant only on multi-network installs.
1346 1346
 	 */
1347
-	return apply_filters( 'domain_exists', $result, $domain, $path, $site_id );
1347
+	return apply_filters('domain_exists', $result, $domain, $path, $site_id);
1348 1348
 }
1349 1349
 
1350 1350
 /**
@@ -1368,14 +1368,14 @@  discard block
 block discarded – undo
1368 1368
 	$path = trailingslashit($path);
1369 1369
 	$site_id = (int) $site_id;
1370 1370
 
1371
-	$result = $wpdb->insert( $wpdb->blogs, array('site_id' => $site_id, 'domain' => $domain, 'path' => $path, 'registered' => current_time('mysql')) );
1372
-	if ( ! $result )
1371
+	$result = $wpdb->insert($wpdb->blogs, array('site_id' => $site_id, 'domain' => $domain, 'path' => $path, 'registered' => current_time('mysql')));
1372
+	if ( ! $result)
1373 1373
 		return false;
1374 1374
 
1375 1375
 	$blog_id = $wpdb->insert_id;
1376
-	refresh_blog_details( $blog_id );
1376
+	refresh_blog_details($blog_id);
1377 1377
 
1378
-	wp_maybe_update_network_site_counts( $site_id );
1378
+	wp_maybe_update_network_site_counts($site_id);
1379 1379
 
1380 1380
 	return $blog_id;
1381 1381
 }
@@ -1395,57 +1395,57 @@  discard block
 block discarded – undo
1395 1395
  * @param int    $blog_id    The value returned by insert_blog().
1396 1396
  * @param string $blog_title The title of the new site.
1397 1397
  */
1398
-function install_blog( $blog_id, $blog_title = '' ) {
1398
+function install_blog($blog_id, $blog_title = '') {
1399 1399
 	global $wpdb, $wp_roles;
1400 1400
 
1401 1401
 	// Cast for security
1402 1402
 	$blog_id = (int) $blog_id;
1403 1403
 
1404
-	require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
1404
+	require_once(ABSPATH.'wp-admin/includes/upgrade.php');
1405 1405
 
1406 1406
 	$suppress = $wpdb->suppress_errors();
1407
-	if ( $wpdb->get_results( "DESCRIBE {$wpdb->posts}" ) )
1408
-		die( '<h1>' . __( 'Already Installed' ) . '</h1><p>' . __( 'You appear to have already installed WordPress. To reinstall please clear your old database tables first.' ) . '</p></body></html>' );
1409
-	$wpdb->suppress_errors( $suppress );
1407
+	if ($wpdb->get_results("DESCRIBE {$wpdb->posts}"))
1408
+		die('<h1>'.__('Already Installed').'</h1><p>'.__('You appear to have already installed WordPress. To reinstall please clear your old database tables first.').'</p></body></html>');
1409
+	$wpdb->suppress_errors($suppress);
1410 1410
 
1411
-	$url = get_blogaddress_by_id( $blog_id );
1411
+	$url = get_blogaddress_by_id($blog_id);
1412 1412
 
1413 1413
 	// Set everything up
1414
-	make_db_current_silent( 'blog' );
1414
+	make_db_current_silent('blog');
1415 1415
 	populate_options();
1416 1416
 	populate_roles();
1417 1417
 
1418 1418
 	// populate_roles() clears previous role definitions so we start over.
1419 1419
 	$wp_roles = new WP_Roles();
1420 1420
 
1421
-	$siteurl = $home = untrailingslashit( $url );
1421
+	$siteurl = $home = untrailingslashit($url);
1422 1422
 
1423
-	if ( ! is_subdomain_install() ) {
1423
+	if ( ! is_subdomain_install()) {
1424 1424
 
1425
- 		if ( 'https' === parse_url( get_site_option( 'siteurl' ), PHP_URL_SCHEME ) ) {
1426
- 			$siteurl = set_url_scheme( $siteurl, 'https' );
1425
+ 		if ('https' === parse_url(get_site_option('siteurl'), PHP_URL_SCHEME)) {
1426
+ 			$siteurl = set_url_scheme($siteurl, 'https');
1427 1427
  		}
1428
- 		if ( 'https' === parse_url( get_home_url( get_network()->site_id ), PHP_URL_SCHEME ) ) {
1429
- 			$home = set_url_scheme( $home, 'https' );
1428
+ 		if ('https' === parse_url(get_home_url(get_network()->site_id), PHP_URL_SCHEME)) {
1429
+ 			$home = set_url_scheme($home, 'https');
1430 1430
  		}
1431 1431
 
1432 1432
 	}
1433 1433
 
1434
-	update_option( 'siteurl', $siteurl );
1435
-	update_option( 'home', $home );
1434
+	update_option('siteurl', $siteurl);
1435
+	update_option('home', $home);
1436 1436
 
1437
-	if ( get_site_option( 'ms_files_rewriting' ) )
1438
-		update_option( 'upload_path', UPLOADBLOGSDIR . "/$blog_id/files" );
1437
+	if (get_site_option('ms_files_rewriting'))
1438
+		update_option('upload_path', UPLOADBLOGSDIR."/$blog_id/files");
1439 1439
 	else
1440
-		update_option( 'upload_path', get_blog_option( get_network()->site_id, 'upload_path' ) );
1440
+		update_option('upload_path', get_blog_option(get_network()->site_id, 'upload_path'));
1441 1441
 
1442
-	update_option( 'blogname', wp_unslash( $blog_title ) );
1443
-	update_option( 'admin_email', '' );
1442
+	update_option('blogname', wp_unslash($blog_title));
1443
+	update_option('admin_email', '');
1444 1444
 
1445 1445
 	// remove all perms
1446 1446
 	$table_prefix = $wpdb->get_blog_prefix();
1447
-	delete_metadata( 'user', 0, $table_prefix . 'user_level',   null, true ); // delete all
1448
-	delete_metadata( 'user', 0, $table_prefix . 'capabilities', null, true ); // delete all
1447
+	delete_metadata('user', 0, $table_prefix.'user_level', null, true); // delete all
1448
+	delete_metadata('user', 0, $table_prefix.'capabilities', null, true); // delete all
1449 1449
 }
1450 1450
 
1451 1451
 /**
@@ -1465,13 +1465,13 @@  discard block
 block discarded – undo
1465 1465
 function install_blog_defaults($blog_id, $user_id) {
1466 1466
 	global $wpdb;
1467 1467
 
1468
-	require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
1468
+	require_once(ABSPATH.'wp-admin/includes/upgrade.php');
1469 1469
 
1470 1470
 	$suppress = $wpdb->suppress_errors();
1471 1471
 
1472 1472
 	wp_install_defaults($user_id);
1473 1473
 
1474
-	$wpdb->suppress_errors( $suppress );
1474
+	$wpdb->suppress_errors($suppress);
1475 1475
 }
1476 1476
 
1477 1477
 /**
@@ -1491,7 +1491,7 @@  discard block
 block discarded – undo
1491 1491
  * @param array  $meta     Optional. Signup meta data. By default, contains the requested privacy setting and lang_id.
1492 1492
  * @return bool
1493 1493
  */
1494
-function wpmu_welcome_notification( $blog_id, $user_id, $password, $title, $meta = array() ) {
1494
+function wpmu_welcome_notification($blog_id, $user_id, $password, $title, $meta = array()) {
1495 1495
 	$current_network = get_network();
1496 1496
 
1497 1497
 	/**
@@ -1507,17 +1507,17 @@  discard block
 block discarded – undo
1507 1507
 	 * @param string   $title    Site title.
1508 1508
 	 * @param array    $meta     Signup meta data. By default, contains the requested privacy setting and lang_id.
1509 1509
 	 */
1510
-	if ( ! apply_filters( 'wpmu_welcome_notification', $blog_id, $user_id, $password, $title, $meta ) )
1510
+	if ( ! apply_filters('wpmu_welcome_notification', $blog_id, $user_id, $password, $title, $meta))
1511 1511
 		return false;
1512 1512
 
1513
-	$user = get_userdata( $user_id );
1513
+	$user = get_userdata($user_id);
1514 1514
 
1515
-	$switched_locale = switch_to_locale( get_user_locale( $user ) );
1515
+	$switched_locale = switch_to_locale(get_user_locale($user));
1516 1516
 
1517
-	$welcome_email = get_site_option( 'welcome_email' );
1518
-	if ( $welcome_email == false ) {
1517
+	$welcome_email = get_site_option('welcome_email');
1518
+	if ($welcome_email == false) {
1519 1519
 		/* translators: Do not translate USERNAME, SITE_NAME, BLOG_URL, PASSWORD: those are placeholders. */
1520
-		$welcome_email = __( 'Howdy USERNAME,
1520
+		$welcome_email = __('Howdy USERNAME,
1521 1521
 
1522 1522
 Your new SITE_NAME site has been successfully set up at:
1523 1523
 BLOG_URL
@@ -1535,11 +1535,11 @@  discard block
 block discarded – undo
1535 1535
 
1536 1536
 	$url = get_blogaddress_by_id($blog_id);
1537 1537
 
1538
-	$welcome_email = str_replace( 'SITE_NAME', $current_network->site_name, $welcome_email );
1539
-	$welcome_email = str_replace( 'BLOG_TITLE', $title, $welcome_email );
1540
-	$welcome_email = str_replace( 'BLOG_URL', $url, $welcome_email );
1541
-	$welcome_email = str_replace( 'USERNAME', $user->user_login, $welcome_email );
1542
-	$welcome_email = str_replace( 'PASSWORD', $password, $welcome_email );
1538
+	$welcome_email = str_replace('SITE_NAME', $current_network->site_name, $welcome_email);
1539
+	$welcome_email = str_replace('BLOG_TITLE', $title, $welcome_email);
1540
+	$welcome_email = str_replace('BLOG_URL', $url, $welcome_email);
1541
+	$welcome_email = str_replace('USERNAME', $user->user_login, $welcome_email);
1542
+	$welcome_email = str_replace('PASSWORD', $password, $welcome_email);
1543 1543
 
1544 1544
 	/**
1545 1545
 	 * Filters the content of the welcome email after site activation.
@@ -1555,21 +1555,21 @@  discard block
 block discarded – undo
1555 1555
 	 * @param string $title         Site title.
1556 1556
 	 * @param array  $meta          Signup meta data. By default, contains the requested privacy setting and lang_id.
1557 1557
 	 */
1558
-	$welcome_email = apply_filters( 'update_welcome_email', $welcome_email, $blog_id, $user_id, $password, $title, $meta );
1559
-	$admin_email = get_site_option( 'admin_email' );
1558
+	$welcome_email = apply_filters('update_welcome_email', $welcome_email, $blog_id, $user_id, $password, $title, $meta);
1559
+	$admin_email = get_site_option('admin_email');
1560 1560
 
1561
-	if ( $admin_email == '' )
1562
-		$admin_email = 'support@' . $_SERVER['SERVER_NAME'];
1561
+	if ($admin_email == '')
1562
+		$admin_email = 'support@'.$_SERVER['SERVER_NAME'];
1563 1563
 
1564
-	$from_name = get_site_option( 'site_name' ) == '' ? 'WordPress' : esc_html( get_site_option( 'site_name' ) );
1565
-	$message_headers = "From: \"{$from_name}\" <{$admin_email}>\n" . "Content-Type: text/plain; charset=\"" . get_option('blog_charset') . "\"\n";
1564
+	$from_name = get_site_option('site_name') == '' ? 'WordPress' : esc_html(get_site_option('site_name'));
1565
+	$message_headers = "From: \"{$from_name}\" <{$admin_email}>\n"."Content-Type: text/plain; charset=\"".get_option('blog_charset')."\"\n";
1566 1566
 	$message = $welcome_email;
1567 1567
 
1568
-	if ( empty( $current_network->site_name ) )
1568
+	if (empty($current_network->site_name))
1569 1569
 		$current_network->site_name = 'WordPress';
1570 1570
 
1571 1571
 	/* translators: New site notification email subject. 1: Network name, 2: New site name */
1572
-	$subject = __( 'New %1$s Site: %2$s' );
1572
+	$subject = __('New %1$s Site: %2$s');
1573 1573
 
1574 1574
 	/**
1575 1575
 	 * Filters the subject of the welcome email after site activation.
@@ -1578,10 +1578,10 @@  discard block
 block discarded – undo
1578 1578
 	 *
1579 1579
 	 * @param string $subject Subject of the email.
1580 1580
 	 */
1581
-	$subject = apply_filters( 'update_welcome_subject', sprintf( $subject, $current_network->site_name, wp_unslash( $title ) ) );
1582
-	wp_mail( $user->user_email, wp_specialchars_decode( $subject ), $message, $message_headers );
1581
+	$subject = apply_filters('update_welcome_subject', sprintf($subject, $current_network->site_name, wp_unslash($title)));
1582
+	wp_mail($user->user_email, wp_specialchars_decode($subject), $message, $message_headers);
1583 1583
 
1584
-	if ( $switched_locale ) {
1584
+	if ($switched_locale) {
1585 1585
 		restore_previous_locale();
1586 1586
 	}
1587 1587
 
@@ -1603,7 +1603,7 @@  discard block
 block discarded – undo
1603 1603
  * @param array  $meta     Optional. Signup meta data. Default empty array.
1604 1604
  * @return bool
1605 1605
  */
1606
-function wpmu_welcome_user_notification( $user_id, $password, $meta = array() ) {
1606
+function wpmu_welcome_user_notification($user_id, $password, $meta = array()) {
1607 1607
 	$current_network = get_network();
1608 1608
 
1609 1609
 	/**
@@ -1617,14 +1617,14 @@  discard block
 block discarded – undo
1617 1617
 	 * @param string $password User password.
1618 1618
 	 * @param array  $meta     Signup meta data. Default empty array.
1619 1619
 	 */
1620
-	if ( ! apply_filters( 'wpmu_welcome_user_notification', $user_id, $password, $meta ) )
1620
+	if ( ! apply_filters('wpmu_welcome_user_notification', $user_id, $password, $meta))
1621 1621
 		return false;
1622 1622
 
1623
-	$welcome_email = get_site_option( 'welcome_user_email' );
1623
+	$welcome_email = get_site_option('welcome_user_email');
1624 1624
 
1625
-	$user = get_userdata( $user_id );
1625
+	$user = get_userdata($user_id);
1626 1626
 
1627
-	$switched_locale = switch_to_locale( get_user_locale( $user ) );
1627
+	$switched_locale = switch_to_locale(get_user_locale($user));
1628 1628
 
1629 1629
 	/**
1630 1630
 	 * Filters the content of the welcome email after user activation.
@@ -1638,26 +1638,26 @@  discard block
 block discarded – undo
1638 1638
 	 * @param string $password      User password.
1639 1639
 	 * @param array  $meta          Signup meta data. Default empty array.
1640 1640
 	 */
1641
-	$welcome_email = apply_filters( 'update_welcome_user_email', $welcome_email, $user_id, $password, $meta );
1642
-	$welcome_email = str_replace( 'SITE_NAME', $current_network->site_name, $welcome_email );
1643
-	$welcome_email = str_replace( 'USERNAME', $user->user_login, $welcome_email );
1644
-	$welcome_email = str_replace( 'PASSWORD', $password, $welcome_email );
1645
-	$welcome_email = str_replace( 'LOGINLINK', wp_login_url(), $welcome_email );
1641
+	$welcome_email = apply_filters('update_welcome_user_email', $welcome_email, $user_id, $password, $meta);
1642
+	$welcome_email = str_replace('SITE_NAME', $current_network->site_name, $welcome_email);
1643
+	$welcome_email = str_replace('USERNAME', $user->user_login, $welcome_email);
1644
+	$welcome_email = str_replace('PASSWORD', $password, $welcome_email);
1645
+	$welcome_email = str_replace('LOGINLINK', wp_login_url(), $welcome_email);
1646 1646
 
1647
-	$admin_email = get_site_option( 'admin_email' );
1647
+	$admin_email = get_site_option('admin_email');
1648 1648
 
1649
-	if ( $admin_email == '' )
1650
-		$admin_email = 'support@' . $_SERVER['SERVER_NAME'];
1649
+	if ($admin_email == '')
1650
+		$admin_email = 'support@'.$_SERVER['SERVER_NAME'];
1651 1651
 
1652
-	$from_name = get_site_option( 'site_name' ) == '' ? 'WordPress' : esc_html( get_site_option( 'site_name' ) );
1653
-	$message_headers = "From: \"{$from_name}\" <{$admin_email}>\n" . "Content-Type: text/plain; charset=\"" . get_option('blog_charset') . "\"\n";
1652
+	$from_name = get_site_option('site_name') == '' ? 'WordPress' : esc_html(get_site_option('site_name'));
1653
+	$message_headers = "From: \"{$from_name}\" <{$admin_email}>\n"."Content-Type: text/plain; charset=\"".get_option('blog_charset')."\"\n";
1654 1654
 	$message = $welcome_email;
1655 1655
 
1656
-	if ( empty( $current_network->site_name ) )
1656
+	if (empty($current_network->site_name))
1657 1657
 		$current_network->site_name = 'WordPress';
1658 1658
 
1659 1659
 	/* translators: New user notification email subject. 1: Network name, 2: New user login */
1660
-	$subject = __( 'New %1$s User: %2$s' );
1660
+	$subject = __('New %1$s User: %2$s');
1661 1661
 
1662 1662
 	/**
1663 1663
 	 * Filters the subject of the welcome email after user activation.
@@ -1666,10 +1666,10 @@  discard block
 block discarded – undo
1666 1666
 	 *
1667 1667
 	 * @param string $subject Subject of the email.
1668 1668
 	 */
1669
-	$subject = apply_filters( 'update_welcome_user_subject', sprintf( $subject, $current_network->site_name, $user->user_login) );
1670
-	wp_mail( $user->user_email, wp_specialchars_decode( $subject ), $message, $message_headers );
1669
+	$subject = apply_filters('update_welcome_user_subject', sprintf($subject, $current_network->site_name, $user->user_login));
1670
+	wp_mail($user->user_email, wp_specialchars_decode($subject), $message, $message_headers);
1671 1671
 
1672
-	if ( $switched_locale ) {
1672
+	if ($switched_locale) {
1673 1673
 		restore_previous_locale();
1674 1674
 	}
1675 1675
 
@@ -1708,26 +1708,26 @@  discard block
 block discarded – undo
1708 1708
  * @param int $user_id
1709 1709
  * @return array Contains the blog_id, post_id, post_date_gmt, and post_gmt_ts
1710 1710
  */
1711
-function get_most_recent_post_of_user( $user_id ) {
1711
+function get_most_recent_post_of_user($user_id) {
1712 1712
 	global $wpdb;
1713 1713
 
1714
-	$user_blogs = get_blogs_of_user( (int) $user_id );
1714
+	$user_blogs = get_blogs_of_user((int) $user_id);
1715 1715
 	$most_recent_post = array();
1716 1716
 
1717 1717
 	// Walk through each blog and get the most recent post
1718 1718
 	// published by $user_id
1719
-	foreach ( (array) $user_blogs as $blog ) {
1720
-		$prefix = $wpdb->get_blog_prefix( $blog->userblog_id );
1721
-		$recent_post = $wpdb->get_row( $wpdb->prepare("SELECT ID, post_date_gmt FROM {$prefix}posts WHERE post_author = %d AND post_type = 'post' AND post_status = 'publish' ORDER BY post_date_gmt DESC LIMIT 1", $user_id ), ARRAY_A);
1719
+	foreach ((array) $user_blogs as $blog) {
1720
+		$prefix = $wpdb->get_blog_prefix($blog->userblog_id);
1721
+		$recent_post = $wpdb->get_row($wpdb->prepare("SELECT ID, post_date_gmt FROM {$prefix}posts WHERE post_author = %d AND post_type = 'post' AND post_status = 'publish' ORDER BY post_date_gmt DESC LIMIT 1", $user_id), ARRAY_A);
1722 1722
 
1723 1723
 		// Make sure we found a post
1724
-		if ( isset($recent_post['ID']) ) {
1724
+		if (isset($recent_post['ID'])) {
1725 1725
 			$post_gmt_ts = strtotime($recent_post['post_date_gmt']);
1726 1726
 
1727 1727
 			// If this is the first post checked or if this post is
1728 1728
 			// newer than the current recent post, make it the new
1729 1729
 			// most recent post.
1730
-			if ( !isset($most_recent_post['post_gmt_ts']) || ( $post_gmt_ts > $most_recent_post['post_gmt_ts'] ) ) {
1730
+			if ( ! isset($most_recent_post['post_gmt_ts']) || ($post_gmt_ts > $most_recent_post['post_gmt_ts'])) {
1731 1731
 				$most_recent_post = array(
1732 1732
 					'blog_id'		=> $blog->userblog_id,
1733 1733
 					'post_id'		=> $recent_post['ID'],
@@ -1754,24 +1754,24 @@  discard block
 block discarded – undo
1754 1754
  * @param string $directory Full path of a directory.
1755 1755
  * @return int Size of the directory in MB.
1756 1756
  */
1757
-function get_dirsize( $directory ) {
1758
-	$dirsize = get_transient( 'dirsize_cache' );
1759
-	if ( is_array( $dirsize ) && isset( $dirsize[ $directory ][ 'size' ] ) )
1760
-		return $dirsize[ $directory ][ 'size' ];
1757
+function get_dirsize($directory) {
1758
+	$dirsize = get_transient('dirsize_cache');
1759
+	if (is_array($dirsize) && isset($dirsize[$directory]['size']))
1760
+		return $dirsize[$directory]['size'];
1761 1761
 
1762
-	if ( ! is_array( $dirsize ) )
1762
+	if ( ! is_array($dirsize))
1763 1763
 		$dirsize = array();
1764 1764
 
1765 1765
 	// Exclude individual site directories from the total when checking the main site,
1766 1766
 	// as they are subdirectories and should not be counted.
1767
-	if ( is_main_site() ) {
1768
-		$dirsize[ $directory ][ 'size' ] = recurse_dirsize( $directory, $directory . '/sites' );
1767
+	if (is_main_site()) {
1768
+		$dirsize[$directory]['size'] = recurse_dirsize($directory, $directory.'/sites');
1769 1769
 	} else {
1770
-		$dirsize[ $directory ][ 'size' ] = recurse_dirsize( $directory );
1770
+		$dirsize[$directory]['size'] = recurse_dirsize($directory);
1771 1771
 	}
1772 1772
 
1773
-	set_transient( 'dirsize_cache', $dirsize, HOUR_IN_SECONDS );
1774
-	return $dirsize[ $directory ][ 'size' ];
1773
+	set_transient('dirsize_cache', $dirsize, HOUR_IN_SECONDS);
1774
+	return $dirsize[$directory]['size'];
1775 1775
 }
1776 1776
 
1777 1777
 /**
@@ -1787,23 +1787,23 @@  discard block
 block discarded – undo
1787 1787
  * @param string $exclude   Optional. Full path of a subdirectory to exclude from the total.
1788 1788
  * @return int|false Size in MB if a valid directory. False if not.
1789 1789
  */
1790
-function recurse_dirsize( $directory, $exclude = null ) {
1790
+function recurse_dirsize($directory, $exclude = null) {
1791 1791
 	$size = 0;
1792 1792
 
1793
-	$directory = untrailingslashit( $directory );
1793
+	$directory = untrailingslashit($directory);
1794 1794
 
1795
-	if ( ! file_exists( $directory ) || ! is_dir( $directory ) || ! is_readable( $directory ) || $directory === $exclude ) {
1795
+	if ( ! file_exists($directory) || ! is_dir($directory) || ! is_readable($directory) || $directory === $exclude) {
1796 1796
 		return false;
1797 1797
 	}
1798 1798
 
1799 1799
 	if ($handle = opendir($directory)) {
1800
-		while(($file = readdir($handle)) !== false) {
1800
+		while (($file = readdir($handle)) !== false) {
1801 1801
 			$path = $directory.'/'.$file;
1802 1802
 			if ($file != '.' && $file != '..') {
1803 1803
 				if (is_file($path)) {
1804 1804
 					$size += filesize($path);
1805 1805
 				} elseif (is_dir($path)) {
1806
-					$handlesize = recurse_dirsize( $path, $exclude );
1806
+					$handlesize = recurse_dirsize($path, $exclude);
1807 1807
 					if ($handlesize > 0)
1808 1808
 						$size += $handlesize;
1809 1809
 				}
@@ -1828,12 +1828,12 @@  discard block
 block discarded – undo
1828 1828
  * @param array $mimes
1829 1829
  * @return array
1830 1830
  */
1831
-function check_upload_mimes( $mimes ) {
1832
-	$site_exts = explode( ' ', get_site_option( 'upload_filetypes', 'jpg jpeg png gif' ) );
1831
+function check_upload_mimes($mimes) {
1832
+	$site_exts = explode(' ', get_site_option('upload_filetypes', 'jpg jpeg png gif'));
1833 1833
 	$site_mimes = array();
1834
-	foreach ( $site_exts as $ext ) {
1835
-		foreach ( $mimes as $ext_pattern => $mime ) {
1836
-			if ( $ext != '' && strpos( $ext_pattern, $ext ) !== false )
1834
+	foreach ($site_exts as $ext) {
1835
+		foreach ($mimes as $ext_pattern => $mime) {
1836
+			if ($ext != '' && strpos($ext_pattern, $ext) !== false)
1837 1837
 				$site_mimes[$ext_pattern] = $mime;
1838 1838
 		}
1839 1839
 	}
@@ -1854,9 +1854,9 @@  discard block
 block discarded – undo
1854 1854
  *
1855 1855
  * @param string $deprecated Not used.
1856 1856
  */
1857
-function update_posts_count( $deprecated = '' ) {
1857
+function update_posts_count($deprecated = '') {
1858 1858
 	global $wpdb;
1859
-	update_option( 'post_count', (int) $wpdb->get_var( "SELECT COUNT(ID) FROM {$wpdb->posts} WHERE post_status = 'publish' and post_type = 'post'" ) );
1859
+	update_option('post_count', (int) $wpdb->get_var("SELECT COUNT(ID) FROM {$wpdb->posts} WHERE post_status = 'publish' and post_type = 'post'"));
1860 1860
 }
1861 1861
 
1862 1862
 /**
@@ -1869,11 +1869,11 @@  discard block
 block discarded – undo
1869 1869
  * @param int $blog_id
1870 1870
  * @param int $user_id
1871 1871
  */
1872
-function wpmu_log_new_registrations( $blog_id, $user_id ) {
1872
+function wpmu_log_new_registrations($blog_id, $user_id) {
1873 1873
 	global $wpdb;
1874
-	$user = get_userdata( (int) $user_id );
1875
-	if ( $user )
1876
-		$wpdb->insert( $wpdb->registration_log, array('email' => $user->user_email, 'IP' => preg_replace( '/[^0-9., ]/', '', wp_unslash( $_SERVER['REMOTE_ADDR'] ) ), 'blog_id' => $blog_id, 'date_registered' => current_time('mysql')) );
1874
+	$user = get_userdata((int) $user_id);
1875
+	if ($user)
1876
+		$wpdb->insert($wpdb->registration_log, array('email' => $user->user_email, 'IP' => preg_replace('/[^0-9., ]/', '', wp_unslash($_SERVER['REMOTE_ADDR'])), 'blog_id' => $blog_id, 'date_registered' => current_time('mysql')));
1877 1877
 }
1878 1878
 
1879 1879
 /**
@@ -1890,61 +1890,61 @@  discard block
 block discarded – undo
1890 1890
  * @param string $deprecated Not used.
1891 1891
  * @return int An ID from the global terms table mapped from $term_id.
1892 1892
  */
1893
-function global_terms( $term_id, $deprecated = '' ) {
1893
+function global_terms($term_id, $deprecated = '') {
1894 1894
 	global $wpdb;
1895 1895
 	static $global_terms_recurse = null;
1896 1896
 
1897
-	if ( !global_terms_enabled() )
1897
+	if ( ! global_terms_enabled())
1898 1898
 		return $term_id;
1899 1899
 
1900 1900
 	// prevent a race condition
1901 1901
 	$recurse_start = false;
1902
-	if ( $global_terms_recurse === null ) {
1902
+	if ($global_terms_recurse === null) {
1903 1903
 		$recurse_start = true;
1904 1904
 		$global_terms_recurse = 1;
1905
-	} elseif ( 10 < $global_terms_recurse++ ) {
1905
+	} elseif (10 < $global_terms_recurse++) {
1906 1906
 		return $term_id;
1907 1907
 	}
1908 1908
 
1909
-	$term_id = intval( $term_id );
1910
-	$c = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM $wpdb->terms WHERE term_id = %d", $term_id ) );
1909
+	$term_id = intval($term_id);
1910
+	$c = $wpdb->get_row($wpdb->prepare("SELECT * FROM $wpdb->terms WHERE term_id = %d", $term_id));
1911 1911
 
1912
-	$global_id = $wpdb->get_var( $wpdb->prepare( "SELECT cat_ID FROM $wpdb->sitecategories WHERE category_nicename = %s", $c->slug ) );
1913
-	if ( $global_id == null ) {
1914
-		$used_global_id = $wpdb->get_var( $wpdb->prepare( "SELECT cat_ID FROM $wpdb->sitecategories WHERE cat_ID = %d", $c->term_id ) );
1915
-		if ( null == $used_global_id ) {
1916
-			$wpdb->insert( $wpdb->sitecategories, array( 'cat_ID' => $term_id, 'cat_name' => $c->name, 'category_nicename' => $c->slug ) );
1912
+	$global_id = $wpdb->get_var($wpdb->prepare("SELECT cat_ID FROM $wpdb->sitecategories WHERE category_nicename = %s", $c->slug));
1913
+	if ($global_id == null) {
1914
+		$used_global_id = $wpdb->get_var($wpdb->prepare("SELECT cat_ID FROM $wpdb->sitecategories WHERE cat_ID = %d", $c->term_id));
1915
+		if (null == $used_global_id) {
1916
+			$wpdb->insert($wpdb->sitecategories, array('cat_ID' => $term_id, 'cat_name' => $c->name, 'category_nicename' => $c->slug));
1917 1917
 			$global_id = $wpdb->insert_id;
1918
-			if ( empty( $global_id ) )
1918
+			if (empty($global_id))
1919 1919
 				return $term_id;
1920 1920
 		} else {
1921
-			$max_global_id = $wpdb->get_var( "SELECT MAX(cat_ID) FROM $wpdb->sitecategories" );
1922
-			$max_local_id = $wpdb->get_var( "SELECT MAX(term_id) FROM $wpdb->terms" );
1923
-			$new_global_id = max( $max_global_id, $max_local_id ) + mt_rand( 100, 400 );
1924
-			$wpdb->insert( $wpdb->sitecategories, array( 'cat_ID' => $new_global_id, 'cat_name' => $c->name, 'category_nicename' => $c->slug ) );
1921
+			$max_global_id = $wpdb->get_var("SELECT MAX(cat_ID) FROM $wpdb->sitecategories");
1922
+			$max_local_id = $wpdb->get_var("SELECT MAX(term_id) FROM $wpdb->terms");
1923
+			$new_global_id = max($max_global_id, $max_local_id) + mt_rand(100, 400);
1924
+			$wpdb->insert($wpdb->sitecategories, array('cat_ID' => $new_global_id, 'cat_name' => $c->name, 'category_nicename' => $c->slug));
1925 1925
 			$global_id = $wpdb->insert_id;
1926 1926
 		}
1927
-	} elseif ( $global_id != $term_id ) {
1928
-		$local_id = $wpdb->get_var( $wpdb->prepare( "SELECT term_id FROM $wpdb->terms WHERE term_id = %d", $global_id ) );
1929
-		if ( null != $local_id ) {
1930
-			global_terms( $local_id );
1931
-			if ( 10 < $global_terms_recurse ) {
1927
+	} elseif ($global_id != $term_id) {
1928
+		$local_id = $wpdb->get_var($wpdb->prepare("SELECT term_id FROM $wpdb->terms WHERE term_id = %d", $global_id));
1929
+		if (null != $local_id) {
1930
+			global_terms($local_id);
1931
+			if (10 < $global_terms_recurse) {
1932 1932
 				$global_id = $term_id;
1933 1933
 			}
1934 1934
 		}
1935 1935
 	}
1936 1936
 
1937
-	if ( $global_id != $term_id ) {
1938
-		if ( get_option( 'default_category' ) == $term_id )
1939
-			update_option( 'default_category', $global_id );
1937
+	if ($global_id != $term_id) {
1938
+		if (get_option('default_category') == $term_id)
1939
+			update_option('default_category', $global_id);
1940 1940
 
1941
-		$wpdb->update( $wpdb->terms, array('term_id' => $global_id), array('term_id' => $term_id) );
1942
-		$wpdb->update( $wpdb->term_taxonomy, array('term_id' => $global_id), array('term_id' => $term_id) );
1943
-		$wpdb->update( $wpdb->term_taxonomy, array('parent' => $global_id), array('parent' => $term_id) );
1941
+		$wpdb->update($wpdb->terms, array('term_id' => $global_id), array('term_id' => $term_id));
1942
+		$wpdb->update($wpdb->term_taxonomy, array('term_id' => $global_id), array('term_id' => $term_id));
1943
+		$wpdb->update($wpdb->term_taxonomy, array('parent' => $global_id), array('parent' => $term_id));
1944 1944
 
1945 1945
 		clean_term_cache($term_id);
1946 1946
 	}
1947
-	if ( $recurse_start )
1947
+	if ($recurse_start)
1948 1948
 		$global_terms_recurse = null;
1949 1949
 
1950 1950
 	return $global_id;
@@ -1959,8 +1959,8 @@  discard block
 block discarded – undo
1959 1959
  * @param array|string $deprecated Not used.
1960 1960
  * @return array The current site's domain
1961 1961
  */
1962
-function redirect_this_site( $deprecated = '' ) {
1963
-	return array( get_network()->domain );
1962
+function redirect_this_site($deprecated = '') {
1963
+	return array(get_network()->domain);
1964 1964
 }
1965 1965
 
1966 1966
 /**
@@ -1973,12 +1973,12 @@  discard block
 block discarded – undo
1973 1973
  * @param array $upload
1974 1974
  * @return string|array If the upload is under the size limit, $upload is returned. Otherwise returns an error message.
1975 1975
  */
1976
-function upload_is_file_too_big( $upload ) {
1977
-	if ( ! is_array( $upload ) || defined( 'WP_IMPORTING' ) || get_site_option( 'upload_space_check_disabled' ) )
1976
+function upload_is_file_too_big($upload) {
1977
+	if ( ! is_array($upload) || defined('WP_IMPORTING') || get_site_option('upload_space_check_disabled'))
1978 1978
 		return $upload;
1979 1979
 
1980
-	if ( strlen( $upload['bits'] )  > ( KB_IN_BYTES * get_site_option( 'fileupload_maxk', 1500 ) ) ) {
1981
-		return sprintf( __( 'This file is too big. Files must be less than %d KB in size.' ) . '<br />', get_site_option( 'fileupload_maxk', 1500 ) );
1980
+	if (strlen($upload['bits']) > (KB_IN_BYTES * get_site_option('fileupload_maxk', 1500))) {
1981
+		return sprintf(__('This file is too big. Files must be less than %d KB in size.').'<br />', get_site_option('fileupload_maxk', 1500));
1982 1982
 	}
1983 1983
 
1984 1984
 	return $upload;
@@ -1992,7 +1992,7 @@  discard block
 block discarded – undo
1992 1992
 function signup_nonce_fields() {
1993 1993
 	$id = mt_rand();
1994 1994
 	echo "<input type='hidden' name='signup_form_id' value='{$id}' />";
1995
-	wp_nonce_field('signup_form_' . $id, '_signup_form', false);
1995
+	wp_nonce_field('signup_form_'.$id, '_signup_form', false);
1996 1996
 }
1997 1997
 
1998 1998
 /**
@@ -2003,12 +2003,12 @@  discard block
 block discarded – undo
2003 2003
  * @param array $result
2004 2004
  * @return array
2005 2005
  */
2006
-function signup_nonce_check( $result ) {
2007
-	if ( !strpos( $_SERVER[ 'PHP_SELF' ], 'wp-signup.php' ) )
2006
+function signup_nonce_check($result) {
2007
+	if ( ! strpos($_SERVER['PHP_SELF'], 'wp-signup.php'))
2008 2008
 		return $result;
2009 2009
 
2010
-	if ( wp_create_nonce('signup_form_' . $_POST[ 'signup_form_id' ]) != $_POST['_signup_form'] )
2011
-		wp_die( __( 'Please try again.' ) );
2010
+	if (wp_create_nonce('signup_form_'.$_POST['signup_form_id']) != $_POST['_signup_form'])
2011
+		wp_die(__('Please try again.'));
2012 2012
 
2013 2013
 	return $result;
2014 2014
 }
@@ -2028,10 +2028,10 @@  discard block
 block discarded – undo
2028 2028
 	 *
2029 2029
 	 * @param string $no_blog_redirect The redirect URL defined in NOBLOGREDIRECT.
2030 2030
 	 */
2031
-	if ( is_main_site() && is_404() && defined( 'NOBLOGREDIRECT' ) && ( $destination = apply_filters( 'blog_redirect_404', NOBLOGREDIRECT ) ) ) {
2032
-		if ( $destination == '%siteurl%' )
2031
+	if (is_main_site() && is_404() && defined('NOBLOGREDIRECT') && ($destination = apply_filters('blog_redirect_404', NOBLOGREDIRECT))) {
2032
+		if ($destination == '%siteurl%')
2033 2033
 			$destination = network_home_url();
2034
-		wp_redirect( $destination );
2034
+		wp_redirect($destination);
2035 2035
 		exit();
2036 2036
 	}
2037 2037
 }
@@ -2046,23 +2046,23 @@  discard block
 block discarded – undo
2046 2046
  * @since MU
2047 2047
  */
2048 2048
 function maybe_add_existing_user_to_blog() {
2049
-	if ( false === strpos( $_SERVER[ 'REQUEST_URI' ], '/newbloguser/' ) )
2049
+	if (false === strpos($_SERVER['REQUEST_URI'], '/newbloguser/'))
2050 2050
 		return;
2051 2051
 
2052
-	$parts = explode( '/', $_SERVER[ 'REQUEST_URI' ] );
2053
-	$key = array_pop( $parts );
2052
+	$parts = explode('/', $_SERVER['REQUEST_URI']);
2053
+	$key = array_pop($parts);
2054 2054
 
2055
-	if ( $key == '' )
2056
-		$key = array_pop( $parts );
2055
+	if ($key == '')
2056
+		$key = array_pop($parts);
2057 2057
 
2058
-	$details = get_option( 'new_user_' . $key );
2059
-	if ( !empty( $details ) )
2060
-		delete_option( 'new_user_' . $key );
2058
+	$details = get_option('new_user_'.$key);
2059
+	if ( ! empty($details))
2060
+		delete_option('new_user_'.$key);
2061 2061
 
2062
-	if ( empty( $details ) || is_wp_error( add_existing_user_to_blog( $details ) ) )
2063
-		wp_die( sprintf(__('An error occurred adding you to this site. Back to the <a href="%s">homepage</a>.'), home_url() ) );
2062
+	if (empty($details) || is_wp_error(add_existing_user_to_blog($details)))
2063
+		wp_die(sprintf(__('An error occurred adding you to this site. Back to the <a href="%s">homepage</a>.'), home_url()));
2064 2064
 
2065
-	wp_die( sprintf( __( 'You have been added to this site. Please visit the <a href="%s">homepage</a> or <a href="%s">log in</a> using your username and password.' ), home_url(), admin_url() ), __( 'WordPress &rsaquo; Success' ), array( 'response' => 200 ) );
2065
+	wp_die(sprintf(__('You have been added to this site. Please visit the <a href="%s">homepage</a> or <a href="%s">log in</a> using your username and password.'), home_url(), admin_url()), __('WordPress &rsaquo; Success'), array('response' => 200));
2066 2066
 }
2067 2067
 
2068 2068
 /**
@@ -2073,10 +2073,10 @@  discard block
 block discarded – undo
2073 2073
  * @param array $details
2074 2074
  * @return true|WP_Error|void
2075 2075
  */
2076
-function add_existing_user_to_blog( $details = false ) {
2077
-	if ( is_array( $details ) ) {
2076
+function add_existing_user_to_blog($details = false) {
2077
+	if (is_array($details)) {
2078 2078
 		$blog_id = get_current_blog_id();
2079
-		$result = add_user_to_blog( $blog_id, $details[ 'user_id' ], $details[ 'role' ] );
2079
+		$result = add_user_to_blog($blog_id, $details['user_id'], $details['role']);
2080 2080
 		/**
2081 2081
 		 * Fires immediately after an existing user is added to a site.
2082 2082
 		 *
@@ -2085,7 +2085,7 @@  discard block
 block discarded – undo
2085 2085
 		 * @param int   $user_id User ID.
2086 2086
 		 * @param mixed $result  True on success or a WP_Error object if the user doesn't exist.
2087 2087
 		 */
2088
-		do_action( 'added_existing_user', $details['user_id'], $result );
2088
+		do_action('added_existing_user', $details['user_id'], $result);
2089 2089
 		return $result;
2090 2090
 	}
2091 2091
 }
@@ -2103,13 +2103,13 @@  discard block
 block discarded – undo
2103 2103
  * @param mixed $password Ignored.
2104 2104
  * @param array $meta
2105 2105
  */
2106
-function add_new_user_to_blog( $user_id, $password, $meta ) {
2107
-	if ( !empty( $meta[ 'add_to_blog' ] ) ) {
2108
-		$blog_id = $meta[ 'add_to_blog' ];
2109
-		$role = $meta[ 'new_role' ];
2106
+function add_new_user_to_blog($user_id, $password, $meta) {
2107
+	if ( ! empty($meta['add_to_blog'])) {
2108
+		$blog_id = $meta['add_to_blog'];
2109
+		$role = $meta['new_role'];
2110 2110
 		remove_user_from_blog($user_id, get_network()->site_id); // remove user from main blog.
2111
-		add_user_to_blog( $blog_id, $user_id, $role );
2112
-		update_user_meta( $user_id, 'primary_blog', $blog_id );
2111
+		add_user_to_blog($blog_id, $user_id, $role);
2112
+		update_user_meta($user_id, 'primary_blog', $blog_id);
2113 2113
 	}
2114 2114
 }
2115 2115
 
@@ -2120,7 +2120,7 @@  discard block
 block discarded – undo
2120 2120
  *
2121 2121
  * @param PHPMailer $phpmailer The PHPMailer instance, passed by reference.
2122 2122
  */
2123
-function fix_phpmailer_messageid( $phpmailer ) {
2123
+function fix_phpmailer_messageid($phpmailer) {
2124 2124
 	$phpmailer->Hostname = get_network()->domain;
2125 2125
 }
2126 2126
 
@@ -2133,16 +2133,16 @@  discard block
 block discarded – undo
2133 2133
  * 	                           or user login name as a string.
2134 2134
  * @return bool
2135 2135
  */
2136
-function is_user_spammy( $user = null ) {
2137
-    if ( ! ( $user instanceof WP_User ) ) {
2138
-		if ( $user ) {
2139
-			$user = get_user_by( 'login', $user );
2136
+function is_user_spammy($user = null) {
2137
+    if ( ! ($user instanceof WP_User)) {
2138
+		if ($user) {
2139
+			$user = get_user_by('login', $user);
2140 2140
 		} else {
2141 2141
 			$user = wp_get_current_user();
2142 2142
 		}
2143 2143
 	}
2144 2144
 
2145
-	return $user && isset( $user->spam ) && 1 == $user->spam;
2145
+	return $user && isset($user->spam) && 1 == $user->spam;
2146 2146
 }
2147 2147
 
2148 2148
 /**
@@ -2155,8 +2155,8 @@  discard block
 block discarded – undo
2155 2155
  * @param int $old_value
2156 2156
  * @param int $value     The new public value
2157 2157
  */
2158
-function update_blog_public( $old_value, $value ) {
2159
-	update_blog_status( get_current_blog_id(), 'public', (int) $value );
2158
+function update_blog_public($old_value, $value) {
2159
+	update_blog_status(get_current_blog_id(), 'public', (int) $value);
2160 2160
 }
2161 2161
 
2162 2162
 /**
@@ -2171,16 +2171,16 @@  discard block
 block discarded – undo
2171 2171
  * @param int    $blog_id Optional. Defaults to current blog.
2172 2172
  * @return bool
2173 2173
  */
2174
-function is_user_option_local( $key, $user_id = 0, $blog_id = 0 ) {
2174
+function is_user_option_local($key, $user_id = 0, $blog_id = 0) {
2175 2175
 	global $wpdb;
2176 2176
 
2177 2177
 	$current_user = wp_get_current_user();
2178
-	if ( $blog_id == 0 ) {
2178
+	if ($blog_id == 0) {
2179 2179
 		$blog_id = $wpdb->blogid;
2180 2180
 	}
2181
-	$local_key = $wpdb->get_blog_prefix( $blog_id ) . $key;
2181
+	$local_key = $wpdb->get_blog_prefix($blog_id).$key;
2182 2182
 
2183
-	return isset( $current_user->$local_key );
2183
+	return isset($current_user->$local_key);
2184 2184
 }
2185 2185
 
2186 2186
 /**
@@ -2192,7 +2192,7 @@  discard block
 block discarded – undo
2192 2192
  */
2193 2193
 function users_can_register_signup_filter() {
2194 2194
 	$registration = get_site_option('registration');
2195
-	return ( $registration == 'all' || $registration == 'user' );
2195
+	return ($registration == 'all' || $registration == 'user');
2196 2196
 }
2197 2197
 
2198 2198
 /**
@@ -2203,12 +2203,12 @@  discard block
 block discarded – undo
2203 2203
  * @param string $text
2204 2204
  * @return string
2205 2205
  */
2206
-function welcome_user_msg_filter( $text ) {
2207
-	if ( !$text ) {
2208
-		remove_filter( 'site_option_welcome_user_email', 'welcome_user_msg_filter' );
2206
+function welcome_user_msg_filter($text) {
2207
+	if ( ! $text) {
2208
+		remove_filter('site_option_welcome_user_email', 'welcome_user_msg_filter');
2209 2209
 
2210 2210
 		/* translators: Do not translate USERNAME, PASSWORD, LOGINLINK, SITE_NAME: those are placeholders. */
2211
-		$text = __( 'Howdy USERNAME,
2211
+		$text = __('Howdy USERNAME,
2212 2212
 
2213 2213
 Your new account is set up.
2214 2214
 
@@ -2220,7 +2220,7 @@  discard block
 block discarded – undo
2220 2220
 Thanks!
2221 2221
 
2222 2222
 --The Team @ SITE_NAME' );
2223
-		update_site_option( 'welcome_user_email', $text );
2223
+		update_site_option('welcome_user_email', $text);
2224 2224
 	}
2225 2225
 	return $text;
2226 2226
 }
@@ -2235,10 +2235,10 @@  discard block
 block discarded – undo
2235 2235
  * @param bool $force
2236 2236
  * @return bool True if forced, false if not forced.
2237 2237
  */
2238
-function force_ssl_content( $force = '' ) {
2238
+function force_ssl_content($force = '') {
2239 2239
 	static $forced_content = false;
2240 2240
 
2241
-	if ( '' != $force ) {
2241
+	if ('' != $force) {
2242 2242
 		$old_forced = $forced_content;
2243 2243
 		$forced_content = $force;
2244 2244
 		return $old_forced;
@@ -2257,12 +2257,12 @@  discard block
 block discarded – undo
2257 2257
  * @param string $url URL
2258 2258
  * @return string URL with https as the scheme
2259 2259
  */
2260
-function filter_SSL( $url ) {
2261
-	if ( ! is_string( $url ) )
2262
-		return get_bloginfo( 'url' ); // Return home blog url with proper scheme
2260
+function filter_SSL($url) {
2261
+	if ( ! is_string($url))
2262
+		return get_bloginfo('url'); // Return home blog url with proper scheme
2263 2263
 
2264
-	if ( force_ssl_content() && is_ssl() )
2265
-		$url = set_url_scheme( $url, 'https' );
2264
+	if (force_ssl_content() && is_ssl())
2265
+		$url = set_url_scheme($url, 'https');
2266 2266
 
2267 2267
 	return $url;
2268 2268
 }
@@ -2273,10 +2273,10 @@  discard block
 block discarded – undo
2273 2273
  * @since 3.1.0
2274 2274
  */
2275 2275
 function wp_schedule_update_network_counts() {
2276
-	if ( !is_main_site() )
2276
+	if ( ! is_main_site())
2277 2277
 		return;
2278 2278
 
2279
-	if ( ! wp_next_scheduled('update_network_counts') && ! wp_installing() )
2279
+	if ( ! wp_next_scheduled('update_network_counts') && ! wp_installing())
2280 2280
 		wp_schedule_event(time(), 'twicedaily', 'update_network_counts');
2281 2281
 }
2282 2282
 
@@ -2288,9 +2288,9 @@  discard block
 block discarded – undo
2288 2288
  *
2289 2289
  * @param int|null $network_id ID of the network. Default is the current network.
2290 2290
  */
2291
-function wp_update_network_counts( $network_id = null ) {
2292
-	wp_update_network_user_counts( $network_id );
2293
-	wp_update_network_site_counts( $network_id );
2291
+function wp_update_network_counts($network_id = null) {
2292
+	wp_update_network_user_counts($network_id);
2293
+	wp_update_network_site_counts($network_id);
2294 2294
 }
2295 2295
 
2296 2296
 /**
@@ -2304,8 +2304,8 @@  discard block
 block discarded – undo
2304 2304
  *
2305 2305
  * @param int|null $network_id ID of the network. Default is the current network.
2306 2306
  */
2307
-function wp_maybe_update_network_site_counts( $network_id = null ) {
2308
-	$is_small_network = ! wp_is_large_network( 'sites', $network_id );
2307
+function wp_maybe_update_network_site_counts($network_id = null) {
2308
+	$is_small_network = ! wp_is_large_network('sites', $network_id);
2309 2309
 
2310 2310
 	/**
2311 2311
 	 * Filters whether to update network site or user counts when a new site is created.
@@ -2317,10 +2317,10 @@  discard block
 block discarded – undo
2317 2317
 	 * @param bool   $small_network Whether the network is considered small.
2318 2318
 	 * @param string $context       Context. Either 'users' or 'sites'.
2319 2319
 	 */
2320
-	if ( ! apply_filters( 'enable_live_network_counts', $is_small_network, 'sites' ) )
2320
+	if ( ! apply_filters('enable_live_network_counts', $is_small_network, 'sites'))
2321 2321
 		return;
2322 2322
 
2323
-	wp_update_network_site_counts( $network_id );
2323
+	wp_update_network_site_counts($network_id);
2324 2324
 }
2325 2325
 
2326 2326
 /**
@@ -2334,14 +2334,14 @@  discard block
 block discarded – undo
2334 2334
  *
2335 2335
  * @param int|null $network_id ID of the network. Default is the current network.
2336 2336
  */
2337
-function wp_maybe_update_network_user_counts( $network_id = null ) {
2338
-	$is_small_network = ! wp_is_large_network( 'users', $network_id );
2337
+function wp_maybe_update_network_user_counts($network_id = null) {
2338
+	$is_small_network = ! wp_is_large_network('users', $network_id);
2339 2339
 
2340 2340
 	/** This filter is documented in wp-includes/ms-functions.php */
2341
-	if ( ! apply_filters( 'enable_live_network_counts', $is_small_network, 'users' ) )
2341
+	if ( ! apply_filters('enable_live_network_counts', $is_small_network, 'users'))
2342 2342
 		return;
2343 2343
 
2344
-	wp_update_network_user_counts( $network_id );
2344
+	wp_update_network_user_counts($network_id);
2345 2345
 }
2346 2346
 
2347 2347
 /**
@@ -2352,21 +2352,21 @@  discard block
 block discarded – undo
2352 2352
  *
2353 2353
  * @param int|null $network_id ID of the network. Default is the current network.
2354 2354
  */
2355
-function wp_update_network_site_counts( $network_id = null ) {
2355
+function wp_update_network_site_counts($network_id = null) {
2356 2356
 	$network_id = (int) $network_id;
2357
-	if ( ! $network_id ) {
2357
+	if ( ! $network_id) {
2358 2358
 		$network_id = get_current_network_id();
2359 2359
 	}
2360 2360
 
2361
-	$count = get_sites( array(
2361
+	$count = get_sites(array(
2362 2362
 		'network_id' => $network_id,
2363 2363
 		'spam'       => 0,
2364 2364
 		'deleted'    => 0,
2365 2365
 		'archived'   => 0,
2366 2366
 		'count'      => true,
2367
-	) );
2367
+	));
2368 2368
 
2369
-	update_network_option( $network_id, 'blog_count', $count );
2369
+	update_network_option($network_id, 'blog_count', $count);
2370 2370
 }
2371 2371
 
2372 2372
 /**
@@ -2379,11 +2379,11 @@  discard block
 block discarded – undo
2379 2379
  *
2380 2380
  * @param int|null $network_id ID of the network. Default is the current network.
2381 2381
  */
2382
-function wp_update_network_user_counts( $network_id = null ) {
2382
+function wp_update_network_user_counts($network_id = null) {
2383 2383
 	global $wpdb;
2384 2384
 
2385
-	$count = $wpdb->get_var( "SELECT COUNT(ID) as c FROM $wpdb->users WHERE spam = '0' AND deleted = '0'" );
2386
-	update_network_option( $network_id, 'user_count', $count );
2385
+	$count = $wpdb->get_var("SELECT COUNT(ID) as c FROM $wpdb->users WHERE spam = '0' AND deleted = '0'");
2386
+	update_network_option($network_id, 'user_count', $count);
2387 2387
 }
2388 2388
 
2389 2389
 /**
@@ -2401,10 +2401,10 @@  discard block
 block discarded – undo
2401 2401
 	 *
2402 2402
 	 * @param int|bool $space_used The amount of used space, in megabytes. Default false.
2403 2403
 	 */
2404
-	$space_used = apply_filters( 'pre_get_space_used', false );
2405
-	if ( false === $space_used ) {
2404
+	$space_used = apply_filters('pre_get_space_used', false);
2405
+	if (false === $space_used) {
2406 2406
 		$upload_dir = wp_upload_dir();
2407
-		$space_used = get_dirsize( $upload_dir['basedir'] ) / MB_IN_BYTES;
2407
+		$space_used = get_dirsize($upload_dir['basedir']) / MB_IN_BYTES;
2408 2408
 	}
2409 2409
 
2410 2410
 	return $space_used;
@@ -2418,12 +2418,12 @@  discard block
 block discarded – undo
2418 2418
  * @return int Quota in megabytes
2419 2419
  */
2420 2420
 function get_space_allowed() {
2421
-	$space_allowed = get_option( 'blog_upload_space' );
2421
+	$space_allowed = get_option('blog_upload_space');
2422 2422
 
2423
-	if ( ! is_numeric( $space_allowed ) )
2424
-		$space_allowed = get_site_option( 'blog_upload_space' );
2423
+	if ( ! is_numeric($space_allowed))
2424
+		$space_allowed = get_site_option('blog_upload_space');
2425 2425
 
2426
-	if ( ! is_numeric( $space_allowed ) )
2426
+	if ( ! is_numeric($space_allowed))
2427 2427
 		$space_allowed = 100;
2428 2428
 
2429 2429
 	/**
@@ -2433,7 +2433,7 @@  discard block
 block discarded – undo
2433 2433
 	 *
2434 2434
 	 * @param int $space_allowed Upload quota in megabytes for the current blog.
2435 2435
 	 */
2436
-	return apply_filters( 'get_space_allowed', $space_allowed );
2436
+	return apply_filters('get_space_allowed', $space_allowed);
2437 2437
 }
2438 2438
 
2439 2439
 /**
@@ -2445,16 +2445,16 @@  discard block
 block discarded – undo
2445 2445
  */
2446 2446
 function get_upload_space_available() {
2447 2447
 	$allowed = get_space_allowed();
2448
-	if ( $allowed < 0 ) {
2448
+	if ($allowed < 0) {
2449 2449
 		$allowed = 0;
2450 2450
 	}
2451 2451
 	$space_allowed = $allowed * MB_IN_BYTES;
2452
-	if ( get_site_option( 'upload_space_check_disabled' ) )
2452
+	if (get_site_option('upload_space_check_disabled'))
2453 2453
 		return $space_allowed;
2454 2454
 
2455 2455
 	$space_used = get_space_used() * MB_IN_BYTES;
2456 2456
 
2457
-	if ( ( $space_allowed - $space_used ) <= 0 )
2457
+	if (($space_allowed - $space_used) <= 0)
2458 2458
 		return 0;
2459 2459
 
2460 2460
 	return $space_allowed - $space_used;
@@ -2467,7 +2467,7 @@  discard block
 block discarded – undo
2467 2467
  * @return bool True if space is available, false otherwise.
2468 2468
  */
2469 2469
 function is_upload_space_available() {
2470
-	if ( get_site_option( 'upload_space_check_disabled' ) )
2470
+	if (get_site_option('upload_space_check_disabled'))
2471 2471
 		return true;
2472 2472
 
2473 2473
 	return (bool) get_upload_space_available();
@@ -2481,12 +2481,12 @@  discard block
 block discarded – undo
2481 2481
  * @param  int $size Upload size limit in bytes.
2482 2482
  * @return int       Upload size limit in bytes.
2483 2483
  */
2484
-function upload_size_limit_filter( $size ) {
2485
-	$fileupload_maxk = KB_IN_BYTES * get_site_option( 'fileupload_maxk', 1500 );
2486
-	if ( get_site_option( 'upload_space_check_disabled' ) )
2487
-		return min( $size, $fileupload_maxk );
2484
+function upload_size_limit_filter($size) {
2485
+	$fileupload_maxk = KB_IN_BYTES * get_site_option('fileupload_maxk', 1500);
2486
+	if (get_site_option('upload_space_check_disabled'))
2487
+		return min($size, $fileupload_maxk);
2488 2488
 
2489
-	return min( $size, $fileupload_maxk, get_upload_space_available() );
2489
+	return min($size, $fileupload_maxk, get_upload_space_available());
2490 2490
 }
2491 2491
 
2492 2492
 /**
@@ -2502,14 +2502,14 @@  discard block
 block discarded – undo
2502 2502
  * @param int|null $network_id ID of the network. Default is the current network.
2503 2503
  * @return bool True if the network meets the criteria for large. False otherwise.
2504 2504
  */
2505
-function wp_is_large_network( $using = 'sites', $network_id = null ) {
2505
+function wp_is_large_network($using = 'sites', $network_id = null) {
2506 2506
 	$network_id = (int) $network_id;
2507
-	if ( ! $network_id ) {
2507
+	if ( ! $network_id) {
2508 2508
 		$network_id = get_current_network_id();
2509 2509
 	}
2510 2510
 
2511
-	if ( 'users' == $using ) {
2512
-		$count = get_user_count( $network_id );
2511
+	if ('users' == $using) {
2512
+		$count = get_user_count($network_id);
2513 2513
 		/**
2514 2514
 		 * Filters whether the network is considered large.
2515 2515
 		 *
@@ -2521,12 +2521,12 @@  discard block
 block discarded – undo
2521 2521
 		 * @param int    $count            The count of items for the component.
2522 2522
 		 * @param int    $network_id       The ID of the network being checked.
2523 2523
 		 */
2524
-		return apply_filters( 'wp_is_large_network', $count > 10000, 'users', $count, $network_id );
2524
+		return apply_filters('wp_is_large_network', $count > 10000, 'users', $count, $network_id);
2525 2525
 	}
2526 2526
 
2527
-	$count = get_blog_count( $network_id );
2527
+	$count = get_blog_count($network_id);
2528 2528
 	/** This filter is documented in wp-includes/ms-functions.php */
2529
-	return apply_filters( 'wp_is_large_network', $count > 10000, 'sites', $count, $network_id );
2529
+	return apply_filters('wp_is_large_network', $count > 10000, 'sites', $count, $network_id);
2530 2530
 }
2531 2531
 
2532 2532
 /**
@@ -2551,5 +2551,5 @@  discard block
 block discarded – undo
2551 2551
 	 *
2552 2552
 	 * @param array $subdirectory_reserved_names Array of reserved names.
2553 2553
 	 */
2554
-	return apply_filters( 'subdirectory_reserved_names', $names );
2554
+	return apply_filters('subdirectory_reserved_names', $names);
2555 2555
 }
Please login to merge, or discard this patch.
Braces   +268 added lines, -183 removed lines patch added patch discarded remove patch
@@ -42,11 +42,13 @@  discard block
 block discarded – undo
42 42
 function get_active_blog_for_user( $user_id ) {
43 43
 	global $wpdb;
44 44
 	$blogs = get_blogs_of_user( $user_id );
45
-	if ( empty( $blogs ) )
46
-		return;
45
+	if ( empty( $blogs ) ) {
46
+			return;
47
+	}
47 48
 
48
-	if ( !is_multisite() )
49
-		return $blogs[$wpdb->blogid];
49
+	if ( !is_multisite() ) {
50
+			return $blogs[$wpdb->blogid];
51
+	}
50 52
 
51 53
 	$primary_blog = get_user_meta( $user_id, 'primary_blog', true );
52 54
 	$first_blog = current($blogs);
@@ -69,15 +71,18 @@  discard block
 block discarded – undo
69 71
 		$ret = false;
70 72
 		if ( is_array( $blogs ) && count( $blogs ) > 0 ) {
71 73
 			foreach ( (array) $blogs as $blog_id => $blog ) {
72
-				if ( $blog->site_id != $wpdb->siteid )
73
-					continue;
74
+				if ( $blog->site_id != $wpdb->siteid ) {
75
+									continue;
76
+				}
74 77
 				$details = get_site( $blog_id );
75 78
 				if ( is_object( $details ) && $details->archived == 0 && $details->spam == 0 && $details->deleted == 0 ) {
76 79
 					$ret = $blog;
77
-					if ( get_user_meta( $user_id , 'primary_blog', true ) != $blog_id )
78
-						update_user_meta( $user_id, 'primary_blog', $blog_id );
79
-					if ( !get_user_meta($user_id , 'source_domain', true) )
80
-						update_user_meta( $user_id, 'source_domain', $blog->domain );
80
+					if ( get_user_meta( $user_id , 'primary_blog', true ) != $blog_id ) {
81
+											update_user_meta( $user_id, 'primary_blog', $blog_id );
82
+					}
83
+					if ( !get_user_meta($user_id , 'source_domain', true) ) {
84
+											update_user_meta( $user_id, 'source_domain', $blog->domain );
85
+					}
81 86
 					break;
82 87
 				}
83 88
 			}
@@ -224,8 +229,9 @@  discard block
 block discarded – undo
224 229
 		$new_domain = '';
225 230
 		$blogs = get_blogs_of_user($user_id);
226 231
 		foreach ( (array) $blogs as $blog ) {
227
-			if ( $blog->userblog_id == $blog_id )
228
-				continue;
232
+			if ( $blog->userblog_id == $blog_id ) {
233
+							continue;
234
+			}
229 235
 			$new_id = $blog->userblog_id;
230 236
 			$new_domain = $blog->domain;
231 237
 			break;
@@ -309,10 +315,12 @@  discard block
 block discarded – undo
309 315
 	$path = strtolower( $path );
310 316
 	$id = wp_cache_get( md5( $domain . $path ), 'blog-id-cache' );
311 317
 
312
-	if ( $id == -1 ) // blog does not exist
318
+	if ( $id == -1 ) {
319
+		// blog does not exist
313 320
 		return 0;
314
-	elseif ( $id )
315
-		return (int) $id;
321
+	} elseif ( $id ) {
322
+			return (int) $id;
323
+	}
316 324
 
317 325
 	$args = array(
318 326
 		'domain' => $domain,
@@ -349,8 +357,9 @@  discard block
 block discarded – undo
349 357
  */
350 358
 function is_email_address_unsafe( $user_email ) {
351 359
 	$banned_names = get_site_option( 'banned_email_domains' );
352
-	if ( $banned_names && ! is_array( $banned_names ) )
353
-		$banned_names = explode( "\n", $banned_names );
360
+	if ( $banned_names && ! is_array( $banned_names ) ) {
361
+			$banned_names = explode( "\n", $banned_names );
362
+	}
354 363
 
355 364
 	$is_email_address_unsafe = false;
356 365
 
@@ -361,8 +370,9 @@  discard block
 block discarded – undo
361 370
 		list( $email_local_part, $email_domain ) = explode( '@', $normalized_email );
362 371
 
363 372
 		foreach ( $banned_names as $banned_domain ) {
364
-			if ( ! $banned_domain )
365
-				continue;
373
+			if ( ! $banned_domain ) {
374
+							continue;
375
+			}
366 376
 
367 377
 			if ( $email_domain == $banned_domain ) {
368 378
 				$is_email_address_unsafe = true;
@@ -423,8 +433,9 @@  discard block
 block discarded – undo
423 433
 
424 434
 	$user_email = sanitize_email( $user_email );
425 435
 
426
-	if ( empty( $user_name ) )
427
-	   	$errors->add('user_name', __( 'Please enter a username.' ) );
436
+	if ( empty( $user_name ) ) {
437
+		   	$errors->add('user_name', __( 'Please enter a username.' ) );
438
+	}
428 439
 
429 440
 	$illegal_names = get_site_option( 'illegal_names' );
430 441
 	if ( ! is_array( $illegal_names ) ) {
@@ -448,16 +459,18 @@  discard block
 block discarded – undo
448 459
 		$errors->add( 'user_email', __( 'You cannot use that email address to signup. We are having problems with them blocking some of our email. Please use another email provider.' ) );
449 460
 	}
450 461
 
451
-	if ( strlen( $user_name ) < 4 )
452
-		$errors->add('user_name',  __( 'Username must be at least 4 characters.' ) );
462
+	if ( strlen( $user_name ) < 4 ) {
463
+			$errors->add('user_name',  __( 'Username must be at least 4 characters.' ) );
464
+	}
453 465
 
454 466
 	if ( strlen( $user_name ) > 60 ) {
455 467
 		$errors->add( 'user_name', __( 'Username may not be longer than 60 characters.' ) );
456 468
 	}
457 469
 
458 470
 	// all numeric?
459
-	if ( preg_match( '/^[0-9]*$/', $user_name ) )
460
-		$errors->add('user_name', __('Sorry, usernames must have letters too!'));
471
+	if ( preg_match( '/^[0-9]*$/', $user_name ) ) {
472
+			$errors->add('user_name', __('Sorry, usernames must have letters too!'));
473
+	}
461 474
 
462 475
 	$limited_email_domains = get_site_option( 'limited_email_domains' );
463 476
 	if ( is_array( $limited_email_domains ) && ! empty( $limited_email_domains ) ) {
@@ -468,12 +481,14 @@  discard block
 block discarded – undo
468 481
 	}
469 482
 
470 483
 	// Check if the username has been used already.
471
-	if ( username_exists($user_name) )
472
-		$errors->add( 'user_name', __( 'Sorry, that username already exists!' ) );
484
+	if ( username_exists($user_name) ) {
485
+			$errors->add( 'user_name', __( 'Sorry, that username already exists!' ) );
486
+	}
473 487
 
474 488
 	// Check if the email address has been used already.
475
-	if ( email_exists($user_email) )
476
-		$errors->add( 'user_email', __( 'Sorry, that email address is already used!' ) );
489
+	if ( email_exists($user_email) ) {
490
+			$errors->add( 'user_email', __( 'Sorry, that email address is already used!' ) );
491
+	}
477 492
 
478 493
 	// Has someone already signed up for this username?
479 494
 	$signup = $wpdb->get_row( $wpdb->prepare("SELECT * FROM $wpdb->signups WHERE user_login = %s", $user_name) );
@@ -482,20 +497,22 @@  discard block
 block discarded – undo
482 497
 		$now = current_time( 'timestamp', true );
483 498
 		$diff = $now - $registered_at;
484 499
 		// If registered more than two days ago, cancel registration and let this signup go through.
485
-		if ( $diff > 2 * DAY_IN_SECONDS )
486
-			$wpdb->delete( $wpdb->signups, array( 'user_login' => $user_name ) );
487
-		else
488
-			$errors->add('user_name', __('That username is currently reserved but may be available in a couple of days.'));
500
+		if ( $diff > 2 * DAY_IN_SECONDS ) {
501
+					$wpdb->delete( $wpdb->signups, array( 'user_login' => $user_name ) );
502
+		} else {
503
+					$errors->add('user_name', __('That username is currently reserved but may be available in a couple of days.'));
504
+		}
489 505
 	}
490 506
 
491 507
 	$signup = $wpdb->get_row( $wpdb->prepare("SELECT * FROM $wpdb->signups WHERE user_email = %s", $user_email) );
492 508
 	if ( $signup != null ) {
493 509
 		$diff = current_time( 'timestamp', true ) - mysql2date('U', $signup->registered);
494 510
 		// If registered more than two days ago, cancel registration and let this signup go through.
495
-		if ( $diff > 2 * DAY_IN_SECONDS )
496
-			$wpdb->delete( $wpdb->signups, array( 'user_email' => $user_email ) );
497
-		else
498
-			$errors->add('user_email', __('That email address has already been used. Please check your inbox for an activation email. It will become available in a couple of days if you do nothing.'));
511
+		if ( $diff > 2 * DAY_IN_SECONDS ) {
512
+					$wpdb->delete( $wpdb->signups, array( 'user_email' => $user_email ) );
513
+		} else {
514
+					$errors->add('user_email', __('That email address has already been used. Please check your inbox for an activation email. It will become available in a couple of days if you do nothing.'));
515
+		}
499 516
 	}
500 517
 
501 518
 	$result = array('user_name' => $user_name, 'orig_username' => $orig_username, 'user_email' => $user_email, 'errors' => $errors);
@@ -567,15 +584,17 @@  discard block
 block discarded – undo
567 584
 		$illegal_names = array_merge( $illegal_names, get_subdirectory_reserved_names() );
568 585
 	}
569 586
 
570
-	if ( empty( $blogname ) )
571
-		$errors->add('blogname', __( 'Please enter a site name.' ) );
587
+	if ( empty( $blogname ) ) {
588
+			$errors->add('blogname', __( 'Please enter a site name.' ) );
589
+	}
572 590
 
573 591
 	if ( preg_match( '/[^a-z0-9]+/', $blogname ) ) {
574 592
 		$errors->add( 'blogname', __( 'Site names can only contain lowercase letters (a-z) and numbers.' ) );
575 593
 	}
576 594
 
577
-	if ( in_array( $blogname, $illegal_names ) )
578
-		$errors->add('blogname',  __( 'That name is not allowed.' ) );
595
+	if ( in_array( $blogname, $illegal_names ) ) {
596
+			$errors->add('blogname',  __( 'That name is not allowed.' ) );
597
+	}
579 598
 
580 599
 	/**
581 600
 	 * Filters the minimum site name length required when validating a site signup.
@@ -592,12 +611,14 @@  discard block
 block discarded – undo
592 611
 	}
593 612
 
594 613
 	// do not allow users to create a blog that conflicts with a page on the main blog.
595
-	if ( !is_subdomain_install() && $wpdb->get_var( $wpdb->prepare( "SELECT post_name FROM " . $wpdb->get_blog_prefix( $current_network->site_id ) . "posts WHERE post_type = 'page' AND post_name = %s", $blogname ) ) )
596
-		$errors->add( 'blogname', __( 'Sorry, you may not use that site name.' ) );
614
+	if ( !is_subdomain_install() && $wpdb->get_var( $wpdb->prepare( "SELECT post_name FROM " . $wpdb->get_blog_prefix( $current_network->site_id ) . "posts WHERE post_type = 'page' AND post_name = %s", $blogname ) ) ) {
615
+			$errors->add( 'blogname', __( 'Sorry, you may not use that site name.' ) );
616
+	}
597 617
 
598 618
 	// all numeric?
599
-	if ( preg_match( '/^[0-9]*$/', $blogname ) )
600
-		$errors->add('blogname', __('Sorry, site names must have letters too!'));
619
+	if ( preg_match( '/^[0-9]*$/', $blogname ) ) {
620
+			$errors->add('blogname', __('Sorry, site names must have letters too!'));
621
+	}
601 622
 
602 623
 	/**
603 624
 	 * Filters the new site name during registration.
@@ -613,8 +634,9 @@  discard block
 block discarded – undo
613 634
 
614 635
 	$blog_title = wp_unslash(  $blog_title );
615 636
 
616
-	if ( empty( $blog_title ) )
617
-		$errors->add('blog_title', __( 'Please enter a site title.' ) );
637
+	if ( empty( $blog_title ) ) {
638
+			$errors->add('blog_title', __( 'Please enter a site title.' ) );
639
+	}
618 640
 
619 641
 	// Check if the domain/path has been used already.
620 642
 	if ( is_subdomain_install() ) {
@@ -624,12 +646,14 @@  discard block
 block discarded – undo
624 646
 		$mydomain = "$domain";
625 647
 		$path = $base.$blogname.'/';
626 648
 	}
627
-	if ( domain_exists($mydomain, $path, $current_network->id) )
628
-		$errors->add( 'blogname', __( 'Sorry, that site already exists!' ) );
649
+	if ( domain_exists($mydomain, $path, $current_network->id) ) {
650
+			$errors->add( 'blogname', __( 'Sorry, that site already exists!' ) );
651
+	}
629 652
 
630 653
 	if ( username_exists( $blogname ) ) {
631
-		if ( ! is_object( $user ) || ( is_object($user) && ( $user->user_login != $blogname ) ) )
632
-			$errors->add( 'blogname', __( 'Sorry, that site is reserved!' ) );
654
+		if ( ! is_object( $user ) || ( is_object($user) && ( $user->user_login != $blogname ) ) ) {
655
+					$errors->add( 'blogname', __( 'Sorry, that site is reserved!' ) );
656
+		}
633 657
 	}
634 658
 
635 659
 	// Has someone already signed up for this domain?
@@ -637,10 +661,11 @@  discard block
 block discarded – undo
637 661
 	if ( ! empty($signup) ) {
638 662
 		$diff = current_time( 'timestamp', true ) - mysql2date('U', $signup->registered);
639 663
 		// If registered more than two days ago, cancel registration and let this signup go through.
640
-		if ( $diff > 2 * DAY_IN_SECONDS )
641
-			$wpdb->delete( $wpdb->signups, array( 'domain' => $mydomain , 'path' => $path ) );
642
-		else
643
-			$errors->add('blogname', __('That site is currently reserved but may be available in a couple days.'));
664
+		if ( $diff > 2 * DAY_IN_SECONDS ) {
665
+					$wpdb->delete( $wpdb->signups, array( 'domain' => $mydomain , 'path' => $path ) );
666
+		} else {
667
+					$errors->add('blogname', __('That site is currently reserved but may be available in a couple days.'));
668
+		}
644 669
 	}
645 670
 
646 671
 	$result = array('domain' => $mydomain, 'path' => $path, 'blogname' => $blogname, 'blog_title' => $blog_title, 'user' => $user, 'errors' => $errors);
@@ -830,15 +855,18 @@  discard block
 block discarded – undo
830 855
 	}
831 856
 
832 857
 	// Send email with activation link.
833
-	if ( !is_subdomain_install() || get_current_network_id() != 1 )
834
-		$activate_url = network_site_url("wp-activate.php?key=$key");
835
-	else
836
-		$activate_url = "http://{$domain}{$path}wp-activate.php?key=$key"; // @todo use *_url() API
858
+	if ( !is_subdomain_install() || get_current_network_id() != 1 ) {
859
+			$activate_url = network_site_url("wp-activate.php?key=$key");
860
+	} else {
861
+			$activate_url = "http://{$domain}{$path}wp-activate.php?key=$key";
862
+	}
863
+	// @todo use *_url() API
837 864
 
838 865
 	$activate_url = esc_url($activate_url);
839 866
 	$admin_email = get_site_option( 'admin_email' );
840
-	if ( $admin_email == '' )
841
-		$admin_email = 'support@' . $_SERVER['SERVER_NAME'];
867
+	if ( $admin_email == '' ) {
868
+			$admin_email = 'support@' . $_SERVER['SERVER_NAME'];
869
+	}
842 870
 	$from_name = get_site_option( 'site_name' ) == '' ? 'WordPress' : esc_html( get_site_option( 'site_name' ) );
843 871
 	$message_headers = "From: \"{$from_name}\" <{$admin_email}>\n" . "Content-Type: text/plain; charset=\"" . get_option('blog_charset') . "\"\n";
844 872
 
@@ -935,16 +963,18 @@  discard block
 block discarded – undo
935 963
 	 * @param string $key        Activation key created in wpmu_signup_user().
936 964
 	 * @param array  $meta       Signup meta data. Default empty array.
937 965
 	 */
938
-	if ( ! apply_filters( 'wpmu_signup_user_notification', $user_login, $user_email, $key, $meta ) )
939
-		return false;
966
+	if ( ! apply_filters( 'wpmu_signup_user_notification', $user_login, $user_email, $key, $meta ) ) {
967
+			return false;
968
+	}
940 969
 
941 970
 	$user = get_user_by( 'login', $user_login );
942 971
 	$switched_locale = switch_to_locale( get_user_locale( $user ) );
943 972
 
944 973
 	// Send email with activation link.
945 974
 	$admin_email = get_site_option( 'admin_email' );
946
-	if ( $admin_email == '' )
947
-		$admin_email = 'support@' . $_SERVER['SERVER_NAME'];
975
+	if ( $admin_email == '' ) {
976
+			$admin_email = 'support@' . $_SERVER['SERVER_NAME'];
977
+	}
948 978
 	$from_name = get_site_option( 'site_name' ) == '' ? 'WordPress' : esc_html( get_site_option( 'site_name' ) );
949 979
 	$message_headers = "From: \"{$from_name}\" <{$admin_email}>\n" . "Content-Type: text/plain; charset=\"" . get_option('blog_charset') . "\"\n";
950 980
 	$message = sprintf(
@@ -1017,14 +1047,16 @@  discard block
 block discarded – undo
1017 1047
 
1018 1048
 	$signup = $wpdb->get_row( $wpdb->prepare("SELECT * FROM $wpdb->signups WHERE activation_key = %s", $key) );
1019 1049
 
1020
-	if ( empty( $signup ) )
1021
-		return new WP_Error( 'invalid_key', __( 'Invalid activation key.' ) );
1050
+	if ( empty( $signup ) ) {
1051
+			return new WP_Error( 'invalid_key', __( 'Invalid activation key.' ) );
1052
+	}
1022 1053
 
1023 1054
 	if ( $signup->active ) {
1024
-		if ( empty( $signup->domain ) )
1025
-			return new WP_Error( 'already_active', __( 'The user is already active.' ), $signup );
1026
-		else
1027
-			return new WP_Error( 'already_active', __( 'The site is already active.' ), $signup );
1055
+		if ( empty( $signup->domain ) ) {
1056
+					return new WP_Error( 'already_active', __( 'The user is already active.' ), $signup );
1057
+		} else {
1058
+					return new WP_Error( 'already_active', __( 'The site is already active.' ), $signup );
1059
+		}
1028 1060
 	}
1029 1061
 
1030 1062
 	$meta = maybe_unserialize($signup->meta);
@@ -1032,21 +1064,24 @@  discard block
 block discarded – undo
1032 1064
 
1033 1065
 	$user_id = username_exists($signup->user_login);
1034 1066
 
1035
-	if ( ! $user_id )
1036
-		$user_id = wpmu_create_user($signup->user_login, $password, $signup->user_email);
1037
-	else
1038
-		$user_already_exists = true;
1067
+	if ( ! $user_id ) {
1068
+			$user_id = wpmu_create_user($signup->user_login, $password, $signup->user_email);
1069
+	} else {
1070
+			$user_already_exists = true;
1071
+	}
1039 1072
 
1040
-	if ( ! $user_id )
1041
-		return new WP_Error('create_user', __('Could not create user'), $signup);
1073
+	if ( ! $user_id ) {
1074
+			return new WP_Error('create_user', __('Could not create user'), $signup);
1075
+	}
1042 1076
 
1043 1077
 	$now = current_time('mysql', true);
1044 1078
 
1045 1079
 	if ( empty($signup->domain) ) {
1046 1080
 		$wpdb->update( $wpdb->signups, array('active' => 1, 'activated' => $now), array('activation_key' => $key) );
1047 1081
 
1048
-		if ( isset( $user_already_exists ) )
1049
-			return new WP_Error( 'user_already_exists', __( 'That username is already activated.' ), $signup);
1082
+		if ( isset( $user_already_exists ) ) {
1083
+					return new WP_Error( 'user_already_exists', __( 'That username is already activated.' ), $signup);
1084
+		}
1050 1085
 
1051 1086
 		/**
1052 1087
 		 * Fires immediately after a new user is activated.
@@ -1110,8 +1145,9 @@  discard block
 block discarded – undo
1110 1145
 	$user_name = preg_replace( '/\s+/', '', sanitize_user( $user_name, true ) );
1111 1146
 
1112 1147
 	$user_id = wp_create_user( $user_name, $password, $email );
1113
-	if ( is_wp_error( $user_id ) )
1114
-		return false;
1148
+	if ( is_wp_error( $user_id ) ) {
1149
+			return false;
1150
+	}
1115 1151
 
1116 1152
 	// Newly created users have no roles or caps until they are added to a blog.
1117 1153
 	delete_user_option( $user_id, 'capabilities' );
@@ -1160,25 +1196,29 @@  discard block
 block discarded – undo
1160 1196
 
1161 1197
 	$domain = preg_replace( '/\s+/', '', sanitize_user( $domain, true ) );
1162 1198
 
1163
-	if ( is_subdomain_install() )
1164
-		$domain = str_replace( '@', '', $domain );
1199
+	if ( is_subdomain_install() ) {
1200
+			$domain = str_replace( '@', '', $domain );
1201
+	}
1165 1202
 
1166 1203
 	$title = strip_tags( $title );
1167 1204
 	$user_id = (int) $user_id;
1168 1205
 
1169
-	if ( empty($path) )
1170
-		$path = '/';
1206
+	if ( empty($path) ) {
1207
+			$path = '/';
1208
+	}
1171 1209
 
1172 1210
 	// Check if the domain has been used already. We should return an error message.
1173
-	if ( domain_exists($domain, $path, $site_id) )
1174
-		return new WP_Error( 'blog_taken', __( 'Sorry, that site already exists!' ) );
1211
+	if ( domain_exists($domain, $path, $site_id) ) {
1212
+			return new WP_Error( 'blog_taken', __( 'Sorry, that site already exists!' ) );
1213
+	}
1175 1214
 
1176 1215
 	if ( ! wp_installing() ) {
1177 1216
 		wp_installing( true );
1178 1217
 	}
1179 1218
 
1180
-	if ( ! $blog_id = insert_blog($domain, $path, $site_id) )
1181
-		return new WP_Error('insert_blog', __('Could not create site.'));
1219
+	if ( ! $blog_id = insert_blog($domain, $path, $site_id) ) {
1220
+			return new WP_Error('insert_blog', __('Could not create site.'));
1221
+	}
1182 1222
 
1183 1223
 	switch_to_blog($blog_id);
1184 1224
 	install_blog($blog_id, $title);
@@ -1187,16 +1227,18 @@  discard block
 block discarded – undo
1187 1227
 	add_user_to_blog($blog_id, $user_id, 'administrator');
1188 1228
 
1189 1229
 	foreach ( $meta as $key => $value ) {
1190
-		if ( in_array( $key, array( 'public', 'archived', 'mature', 'spam', 'deleted', 'lang_id' ) ) )
1191
-			update_blog_status( $blog_id, $key, $value );
1192
-		else
1193
-			update_option( $key, $value );
1230
+		if ( in_array( $key, array( 'public', 'archived', 'mature', 'spam', 'deleted', 'lang_id' ) ) ) {
1231
+					update_blog_status( $blog_id, $key, $value );
1232
+		} else {
1233
+					update_option( $key, $value );
1234
+		}
1194 1235
 	}
1195 1236
 
1196 1237
 	update_option( 'blog_public', (int) $meta['public'] );
1197 1238
 
1198
-	if ( ! is_super_admin( $user_id ) && ! get_user_meta( $user_id, 'primary_blog', true ) )
1199
-		update_user_meta( $user_id, 'primary_blog', $blog_id );
1239
+	if ( ! is_super_admin( $user_id ) && ! get_user_meta( $user_id, 'primary_blog', true ) ) {
1240
+			update_user_meta( $user_id, 'primary_blog', $blog_id );
1241
+	}
1200 1242
 
1201 1243
 	restore_current_blog();
1202 1244
 	/**
@@ -1231,12 +1273,14 @@  discard block
 block discarded – undo
1231 1273
  * @return bool
1232 1274
  */
1233 1275
 function newblog_notify_siteadmin( $blog_id, $deprecated = '' ) {
1234
-	if ( get_site_option( 'registrationnotification' ) != 'yes' )
1235
-		return false;
1276
+	if ( get_site_option( 'registrationnotification' ) != 'yes' ) {
1277
+			return false;
1278
+	}
1236 1279
 
1237 1280
 	$email = get_site_option( 'admin_email' );
1238
-	if ( is_email($email) == false )
1239
-		return false;
1281
+	if ( is_email($email) == false ) {
1282
+			return false;
1283
+	}
1240 1284
 
1241 1285
 	$options_site_url = esc_url(network_admin_url('settings.php'));
1242 1286
 
@@ -1277,13 +1321,15 @@  discard block
 block discarded – undo
1277 1321
  * @return bool
1278 1322
  */
1279 1323
 function newuser_notify_siteadmin( $user_id ) {
1280
-	if ( get_site_option( 'registrationnotification' ) != 'yes' )
1281
-		return false;
1324
+	if ( get_site_option( 'registrationnotification' ) != 'yes' ) {
1325
+			return false;
1326
+	}
1282 1327
 
1283 1328
 	$email = get_site_option( 'admin_email' );
1284 1329
 
1285
-	if ( is_email($email) == false )
1286
-		return false;
1330
+	if ( is_email($email) == false ) {
1331
+			return false;
1332
+	}
1287 1333
 
1288 1334
 	$user = get_userdata( $user_id );
1289 1335
 
@@ -1369,8 +1415,9 @@  discard block
 block discarded – undo
1369 1415
 	$site_id = (int) $site_id;
1370 1416
 
1371 1417
 	$result = $wpdb->insert( $wpdb->blogs, array('site_id' => $site_id, 'domain' => $domain, 'path' => $path, 'registered' => current_time('mysql')) );
1372
-	if ( ! $result )
1373
-		return false;
1418
+	if ( ! $result ) {
1419
+			return false;
1420
+	}
1374 1421
 
1375 1422
 	$blog_id = $wpdb->insert_id;
1376 1423
 	refresh_blog_details( $blog_id );
@@ -1404,8 +1451,9 @@  discard block
 block discarded – undo
1404 1451
 	require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
1405 1452
 
1406 1453
 	$suppress = $wpdb->suppress_errors();
1407
-	if ( $wpdb->get_results( "DESCRIBE {$wpdb->posts}" ) )
1408
-		die( '<h1>' . __( 'Already Installed' ) . '</h1><p>' . __( 'You appear to have already installed WordPress. To reinstall please clear your old database tables first.' ) . '</p></body></html>' );
1454
+	if ( $wpdb->get_results( "DESCRIBE {$wpdb->posts}" ) ) {
1455
+			die( '<h1>' . __( 'Already Installed' ) . '</h1><p>' . __( 'You appear to have already installed WordPress. To reinstall please clear your old database tables first.' ) . '</p></body></html>' );
1456
+	}
1409 1457
 	$wpdb->suppress_errors( $suppress );
1410 1458
 
1411 1459
 	$url = get_blogaddress_by_id( $blog_id );
@@ -1434,10 +1482,11 @@  discard block
 block discarded – undo
1434 1482
 	update_option( 'siteurl', $siteurl );
1435 1483
 	update_option( 'home', $home );
1436 1484
 
1437
-	if ( get_site_option( 'ms_files_rewriting' ) )
1438
-		update_option( 'upload_path', UPLOADBLOGSDIR . "/$blog_id/files" );
1439
-	else
1440
-		update_option( 'upload_path', get_blog_option( get_network()->site_id, 'upload_path' ) );
1485
+	if ( get_site_option( 'ms_files_rewriting' ) ) {
1486
+			update_option( 'upload_path', UPLOADBLOGSDIR . "/$blog_id/files" );
1487
+	} else {
1488
+			update_option( 'upload_path', get_blog_option( get_network()->site_id, 'upload_path' ) );
1489
+	}
1441 1490
 
1442 1491
 	update_option( 'blogname', wp_unslash( $blog_title ) );
1443 1492
 	update_option( 'admin_email', '' );
@@ -1507,8 +1556,9 @@  discard block
 block discarded – undo
1507 1556
 	 * @param string   $title    Site title.
1508 1557
 	 * @param array    $meta     Signup meta data. By default, contains the requested privacy setting and lang_id.
1509 1558
 	 */
1510
-	if ( ! apply_filters( 'wpmu_welcome_notification', $blog_id, $user_id, $password, $title, $meta ) )
1511
-		return false;
1559
+	if ( ! apply_filters( 'wpmu_welcome_notification', $blog_id, $user_id, $password, $title, $meta ) ) {
1560
+			return false;
1561
+	}
1512 1562
 
1513 1563
 	$user = get_userdata( $user_id );
1514 1564
 
@@ -1558,15 +1608,17 @@  discard block
 block discarded – undo
1558 1608
 	$welcome_email = apply_filters( 'update_welcome_email', $welcome_email, $blog_id, $user_id, $password, $title, $meta );
1559 1609
 	$admin_email = get_site_option( 'admin_email' );
1560 1610
 
1561
-	if ( $admin_email == '' )
1562
-		$admin_email = 'support@' . $_SERVER['SERVER_NAME'];
1611
+	if ( $admin_email == '' ) {
1612
+			$admin_email = 'support@' . $_SERVER['SERVER_NAME'];
1613
+	}
1563 1614
 
1564 1615
 	$from_name = get_site_option( 'site_name' ) == '' ? 'WordPress' : esc_html( get_site_option( 'site_name' ) );
1565 1616
 	$message_headers = "From: \"{$from_name}\" <{$admin_email}>\n" . "Content-Type: text/plain; charset=\"" . get_option('blog_charset') . "\"\n";
1566 1617
 	$message = $welcome_email;
1567 1618
 
1568
-	if ( empty( $current_network->site_name ) )
1569
-		$current_network->site_name = 'WordPress';
1619
+	if ( empty( $current_network->site_name ) ) {
1620
+			$current_network->site_name = 'WordPress';
1621
+	}
1570 1622
 
1571 1623
 	/* translators: New site notification email subject. 1: Network name, 2: New site name */
1572 1624
 	$subject = __( 'New %1$s Site: %2$s' );
@@ -1617,8 +1669,9 @@  discard block
 block discarded – undo
1617 1669
 	 * @param string $password User password.
1618 1670
 	 * @param array  $meta     Signup meta data. Default empty array.
1619 1671
 	 */
1620
-	if ( ! apply_filters( 'wpmu_welcome_user_notification', $user_id, $password, $meta ) )
1621
-		return false;
1672
+	if ( ! apply_filters( 'wpmu_welcome_user_notification', $user_id, $password, $meta ) ) {
1673
+			return false;
1674
+	}
1622 1675
 
1623 1676
 	$welcome_email = get_site_option( 'welcome_user_email' );
1624 1677
 
@@ -1646,15 +1699,17 @@  discard block
 block discarded – undo
1646 1699
 
1647 1700
 	$admin_email = get_site_option( 'admin_email' );
1648 1701
 
1649
-	if ( $admin_email == '' )
1650
-		$admin_email = 'support@' . $_SERVER['SERVER_NAME'];
1702
+	if ( $admin_email == '' ) {
1703
+			$admin_email = 'support@' . $_SERVER['SERVER_NAME'];
1704
+	}
1651 1705
 
1652 1706
 	$from_name = get_site_option( 'site_name' ) == '' ? 'WordPress' : esc_html( get_site_option( 'site_name' ) );
1653 1707
 	$message_headers = "From: \"{$from_name}\" <{$admin_email}>\n" . "Content-Type: text/plain; charset=\"" . get_option('blog_charset') . "\"\n";
1654 1708
 	$message = $welcome_email;
1655 1709
 
1656
-	if ( empty( $current_network->site_name ) )
1657
-		$current_network->site_name = 'WordPress';
1710
+	if ( empty( $current_network->site_name ) ) {
1711
+			$current_network->site_name = 'WordPress';
1712
+	}
1658 1713
 
1659 1714
 	/* translators: New user notification email subject. 1: Network name, 2: New user login */
1660 1715
 	$subject = __( 'New %1$s User: %2$s' );
@@ -1756,11 +1811,13 @@  discard block
 block discarded – undo
1756 1811
  */
1757 1812
 function get_dirsize( $directory ) {
1758 1813
 	$dirsize = get_transient( 'dirsize_cache' );
1759
-	if ( is_array( $dirsize ) && isset( $dirsize[ $directory ][ 'size' ] ) )
1760
-		return $dirsize[ $directory ][ 'size' ];
1814
+	if ( is_array( $dirsize ) && isset( $dirsize[ $directory ][ 'size' ] ) ) {
1815
+			return $dirsize[ $directory ][ 'size' ];
1816
+	}
1761 1817
 
1762
-	if ( ! is_array( $dirsize ) )
1763
-		$dirsize = array();
1818
+	if ( ! is_array( $dirsize ) ) {
1819
+			$dirsize = array();
1820
+	}
1764 1821
 
1765 1822
 	// Exclude individual site directories from the total when checking the main site,
1766 1823
 	// as they are subdirectories and should not be counted.
@@ -1804,8 +1861,9 @@  discard block
 block discarded – undo
1804 1861
 					$size += filesize($path);
1805 1862
 				} elseif (is_dir($path)) {
1806 1863
 					$handlesize = recurse_dirsize( $path, $exclude );
1807
-					if ($handlesize > 0)
1808
-						$size += $handlesize;
1864
+					if ($handlesize > 0) {
1865
+											$size += $handlesize;
1866
+					}
1809 1867
 				}
1810 1868
 			}
1811 1869
 		}
@@ -1833,8 +1891,9 @@  discard block
 block discarded – undo
1833 1891
 	$site_mimes = array();
1834 1892
 	foreach ( $site_exts as $ext ) {
1835 1893
 		foreach ( $mimes as $ext_pattern => $mime ) {
1836
-			if ( $ext != '' && strpos( $ext_pattern, $ext ) !== false )
1837
-				$site_mimes[$ext_pattern] = $mime;
1894
+			if ( $ext != '' && strpos( $ext_pattern, $ext ) !== false ) {
1895
+							$site_mimes[$ext_pattern] = $mime;
1896
+			}
1838 1897
 		}
1839 1898
 	}
1840 1899
 	return $site_mimes;
@@ -1872,9 +1931,10 @@  discard block
 block discarded – undo
1872 1931
 function wpmu_log_new_registrations( $blog_id, $user_id ) {
1873 1932
 	global $wpdb;
1874 1933
 	$user = get_userdata( (int) $user_id );
1875
-	if ( $user )
1876
-		$wpdb->insert( $wpdb->registration_log, array('email' => $user->user_email, 'IP' => preg_replace( '/[^0-9., ]/', '', wp_unslash( $_SERVER['REMOTE_ADDR'] ) ), 'blog_id' => $blog_id, 'date_registered' => current_time('mysql')) );
1877
-}
1934
+	if ( $user ) {
1935
+			$wpdb->insert( $wpdb->registration_log, array('email' => $user->user_email, 'IP' => preg_replace( '/[^0-9., ]/', '', wp_unslash( $_SERVER['REMOTE_ADDR'] ) ), 'blog_id' => $blog_id, 'date_registered' => current_time('mysql')) );
1936
+	}
1937
+	}
1878 1938
 
1879 1939
 /**
1880 1940
  * Maintains a canonical list of terms by syncing terms created for each blog with the global terms table.
@@ -1894,8 +1954,9 @@  discard block
 block discarded – undo
1894 1954
 	global $wpdb;
1895 1955
 	static $global_terms_recurse = null;
1896 1956
 
1897
-	if ( !global_terms_enabled() )
1898
-		return $term_id;
1957
+	if ( !global_terms_enabled() ) {
1958
+			return $term_id;
1959
+	}
1899 1960
 
1900 1961
 	// prevent a race condition
1901 1962
 	$recurse_start = false;
@@ -1915,8 +1976,9 @@  discard block
 block discarded – undo
1915 1976
 		if ( null == $used_global_id ) {
1916 1977
 			$wpdb->insert( $wpdb->sitecategories, array( 'cat_ID' => $term_id, 'cat_name' => $c->name, 'category_nicename' => $c->slug ) );
1917 1978
 			$global_id = $wpdb->insert_id;
1918
-			if ( empty( $global_id ) )
1919
-				return $term_id;
1979
+			if ( empty( $global_id ) ) {
1980
+							return $term_id;
1981
+			}
1920 1982
 		} else {
1921 1983
 			$max_global_id = $wpdb->get_var( "SELECT MAX(cat_ID) FROM $wpdb->sitecategories" );
1922 1984
 			$max_local_id = $wpdb->get_var( "SELECT MAX(term_id) FROM $wpdb->terms" );
@@ -1935,8 +1997,9 @@  discard block
 block discarded – undo
1935 1997
 	}
1936 1998
 
1937 1999
 	if ( $global_id != $term_id ) {
1938
-		if ( get_option( 'default_category' ) == $term_id )
1939
-			update_option( 'default_category', $global_id );
2000
+		if ( get_option( 'default_category' ) == $term_id ) {
2001
+					update_option( 'default_category', $global_id );
2002
+		}
1940 2003
 
1941 2004
 		$wpdb->update( $wpdb->terms, array('term_id' => $global_id), array('term_id' => $term_id) );
1942 2005
 		$wpdb->update( $wpdb->term_taxonomy, array('term_id' => $global_id), array('term_id' => $term_id) );
@@ -1944,8 +2007,9 @@  discard block
 block discarded – undo
1944 2007
 
1945 2008
 		clean_term_cache($term_id);
1946 2009
 	}
1947
-	if ( $recurse_start )
1948
-		$global_terms_recurse = null;
2010
+	if ( $recurse_start ) {
2011
+			$global_terms_recurse = null;
2012
+	}
1949 2013
 
1950 2014
 	return $global_id;
1951 2015
 }
@@ -1974,8 +2038,9 @@  discard block
 block discarded – undo
1974 2038
  * @return string|array If the upload is under the size limit, $upload is returned. Otherwise returns an error message.
1975 2039
  */
1976 2040
 function upload_is_file_too_big( $upload ) {
1977
-	if ( ! is_array( $upload ) || defined( 'WP_IMPORTING' ) || get_site_option( 'upload_space_check_disabled' ) )
1978
-		return $upload;
2041
+	if ( ! is_array( $upload ) || defined( 'WP_IMPORTING' ) || get_site_option( 'upload_space_check_disabled' ) ) {
2042
+			return $upload;
2043
+	}
1979 2044
 
1980 2045
 	if ( strlen( $upload['bits'] )  > ( KB_IN_BYTES * get_site_option( 'fileupload_maxk', 1500 ) ) ) {
1981 2046
 		return sprintf( __( 'This file is too big. Files must be less than %d KB in size.' ) . '<br />', get_site_option( 'fileupload_maxk', 1500 ) );
@@ -2004,11 +2069,13 @@  discard block
 block discarded – undo
2004 2069
  * @return array
2005 2070
  */
2006 2071
 function signup_nonce_check( $result ) {
2007
-	if ( !strpos( $_SERVER[ 'PHP_SELF' ], 'wp-signup.php' ) )
2008
-		return $result;
2072
+	if ( !strpos( $_SERVER[ 'PHP_SELF' ], 'wp-signup.php' ) ) {
2073
+			return $result;
2074
+	}
2009 2075
 
2010
-	if ( wp_create_nonce('signup_form_' . $_POST[ 'signup_form_id' ]) != $_POST['_signup_form'] )
2011
-		wp_die( __( 'Please try again.' ) );
2076
+	if ( wp_create_nonce('signup_form_' . $_POST[ 'signup_form_id' ]) != $_POST['_signup_form'] ) {
2077
+			wp_die( __( 'Please try again.' ) );
2078
+	}
2012 2079
 
2013 2080
 	return $result;
2014 2081
 }
@@ -2029,8 +2096,9 @@  discard block
 block discarded – undo
2029 2096
 	 * @param string $no_blog_redirect The redirect URL defined in NOBLOGREDIRECT.
2030 2097
 	 */
2031 2098
 	if ( is_main_site() && is_404() && defined( 'NOBLOGREDIRECT' ) && ( $destination = apply_filters( 'blog_redirect_404', NOBLOGREDIRECT ) ) ) {
2032
-		if ( $destination == '%siteurl%' )
2033
-			$destination = network_home_url();
2099
+		if ( $destination == '%siteurl%' ) {
2100
+					$destination = network_home_url();
2101
+		}
2034 2102
 		wp_redirect( $destination );
2035 2103
 		exit();
2036 2104
 	}
@@ -2046,21 +2114,25 @@  discard block
 block discarded – undo
2046 2114
  * @since MU
2047 2115
  */
2048 2116
 function maybe_add_existing_user_to_blog() {
2049
-	if ( false === strpos( $_SERVER[ 'REQUEST_URI' ], '/newbloguser/' ) )
2050
-		return;
2117
+	if ( false === strpos( $_SERVER[ 'REQUEST_URI' ], '/newbloguser/' ) ) {
2118
+			return;
2119
+	}
2051 2120
 
2052 2121
 	$parts = explode( '/', $_SERVER[ 'REQUEST_URI' ] );
2053 2122
 	$key = array_pop( $parts );
2054 2123
 
2055
-	if ( $key == '' )
2056
-		$key = array_pop( $parts );
2124
+	if ( $key == '' ) {
2125
+			$key = array_pop( $parts );
2126
+	}
2057 2127
 
2058 2128
 	$details = get_option( 'new_user_' . $key );
2059
-	if ( !empty( $details ) )
2060
-		delete_option( 'new_user_' . $key );
2129
+	if ( !empty( $details ) ) {
2130
+			delete_option( 'new_user_' . $key );
2131
+	}
2061 2132
 
2062
-	if ( empty( $details ) || is_wp_error( add_existing_user_to_blog( $details ) ) )
2063
-		wp_die( sprintf(__('An error occurred adding you to this site. Back to the <a href="%s">homepage</a>.'), home_url() ) );
2133
+	if ( empty( $details ) || is_wp_error( add_existing_user_to_blog( $details ) ) ) {
2134
+			wp_die( sprintf(__('An error occurred adding you to this site. Back to the <a href="%s">homepage</a>.'), home_url() ) );
2135
+	}
2064 2136
 
2065 2137
 	wp_die( sprintf( __( 'You have been added to this site. Please visit the <a href="%s">homepage</a> or <a href="%s">log in</a> using your username and password.' ), home_url(), admin_url() ), __( 'WordPress &rsaquo; Success' ), array( 'response' => 200 ) );
2066 2138
 }
@@ -2258,11 +2330,14 @@  discard block
 block discarded – undo
2258 2330
  * @return string URL with https as the scheme
2259 2331
  */
2260 2332
 function filter_SSL( $url ) {
2261
-	if ( ! is_string( $url ) )
2262
-		return get_bloginfo( 'url' ); // Return home blog url with proper scheme
2333
+	if ( ! is_string( $url ) ) {
2334
+			return get_bloginfo( 'url' );
2335
+	}
2336
+	// Return home blog url with proper scheme
2263 2337
 
2264
-	if ( force_ssl_content() && is_ssl() )
2265
-		$url = set_url_scheme( $url, 'https' );
2338
+	if ( force_ssl_content() && is_ssl() ) {
2339
+			$url = set_url_scheme( $url, 'https' );
2340
+	}
2266 2341
 
2267 2342
 	return $url;
2268 2343
 }
@@ -2273,12 +2348,14 @@  discard block
 block discarded – undo
2273 2348
  * @since 3.1.0
2274 2349
  */
2275 2350
 function wp_schedule_update_network_counts() {
2276
-	if ( !is_main_site() )
2277
-		return;
2351
+	if ( !is_main_site() ) {
2352
+			return;
2353
+	}
2278 2354
 
2279
-	if ( ! wp_next_scheduled('update_network_counts') && ! wp_installing() )
2280
-		wp_schedule_event(time(), 'twicedaily', 'update_network_counts');
2281
-}
2355
+	if ( ! wp_next_scheduled('update_network_counts') && ! wp_installing() ) {
2356
+			wp_schedule_event(time(), 'twicedaily', 'update_network_counts');
2357
+	}
2358
+	}
2282 2359
 
2283 2360
 /**
2284 2361
  * Update the network-wide counts for the current network.
@@ -2317,8 +2394,9 @@  discard block
 block discarded – undo
2317 2394
 	 * @param bool   $small_network Whether the network is considered small.
2318 2395
 	 * @param string $context       Context. Either 'users' or 'sites'.
2319 2396
 	 */
2320
-	if ( ! apply_filters( 'enable_live_network_counts', $is_small_network, 'sites' ) )
2321
-		return;
2397
+	if ( ! apply_filters( 'enable_live_network_counts', $is_small_network, 'sites' ) ) {
2398
+			return;
2399
+	}
2322 2400
 
2323 2401
 	wp_update_network_site_counts( $network_id );
2324 2402
 }
@@ -2338,8 +2416,9 @@  discard block
 block discarded – undo
2338 2416
 	$is_small_network = ! wp_is_large_network( 'users', $network_id );
2339 2417
 
2340 2418
 	/** This filter is documented in wp-includes/ms-functions.php */
2341
-	if ( ! apply_filters( 'enable_live_network_counts', $is_small_network, 'users' ) )
2342
-		return;
2419
+	if ( ! apply_filters( 'enable_live_network_counts', $is_small_network, 'users' ) ) {
2420
+			return;
2421
+	}
2343 2422
 
2344 2423
 	wp_update_network_user_counts( $network_id );
2345 2424
 }
@@ -2420,11 +2499,13 @@  discard block
 block discarded – undo
2420 2499
 function get_space_allowed() {
2421 2500
 	$space_allowed = get_option( 'blog_upload_space' );
2422 2501
 
2423
-	if ( ! is_numeric( $space_allowed ) )
2424
-		$space_allowed = get_site_option( 'blog_upload_space' );
2502
+	if ( ! is_numeric( $space_allowed ) ) {
2503
+			$space_allowed = get_site_option( 'blog_upload_space' );
2504
+	}
2425 2505
 
2426
-	if ( ! is_numeric( $space_allowed ) )
2427
-		$space_allowed = 100;
2506
+	if ( ! is_numeric( $space_allowed ) ) {
2507
+			$space_allowed = 100;
2508
+	}
2428 2509
 
2429 2510
 	/**
2430 2511
 	 * Filters the upload quota for the current site.
@@ -2449,13 +2530,15 @@  discard block
 block discarded – undo
2449 2530
 		$allowed = 0;
2450 2531
 	}
2451 2532
 	$space_allowed = $allowed * MB_IN_BYTES;
2452
-	if ( get_site_option( 'upload_space_check_disabled' ) )
2453
-		return $space_allowed;
2533
+	if ( get_site_option( 'upload_space_check_disabled' ) ) {
2534
+			return $space_allowed;
2535
+	}
2454 2536
 
2455 2537
 	$space_used = get_space_used() * MB_IN_BYTES;
2456 2538
 
2457
-	if ( ( $space_allowed - $space_used ) <= 0 )
2458
-		return 0;
2539
+	if ( ( $space_allowed - $space_used ) <= 0 ) {
2540
+			return 0;
2541
+	}
2459 2542
 
2460 2543
 	return $space_allowed - $space_used;
2461 2544
 }
@@ -2467,8 +2550,9 @@  discard block
 block discarded – undo
2467 2550
  * @return bool True if space is available, false otherwise.
2468 2551
  */
2469 2552
 function is_upload_space_available() {
2470
-	if ( get_site_option( 'upload_space_check_disabled' ) )
2471
-		return true;
2553
+	if ( get_site_option( 'upload_space_check_disabled' ) ) {
2554
+			return true;
2555
+	}
2472 2556
 
2473 2557
 	return (bool) get_upload_space_available();
2474 2558
 }
@@ -2483,8 +2567,9 @@  discard block
 block discarded – undo
2483 2567
  */
2484 2568
 function upload_size_limit_filter( $size ) {
2485 2569
 	$fileupload_maxk = KB_IN_BYTES * get_site_option( 'fileupload_maxk', 1500 );
2486
-	if ( get_site_option( 'upload_space_check_disabled' ) )
2487
-		return min( $size, $fileupload_maxk );
2570
+	if ( get_site_option( 'upload_space_check_disabled' ) ) {
2571
+			return min( $size, $fileupload_maxk );
2572
+	}
2488 2573
 
2489 2574
 	return min( $size, $fileupload_maxk, get_upload_space_available() );
2490 2575
 }
Please login to merge, or discard this patch.
src/wp-includes/option.php 3 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -1867,7 +1867,7 @@
 block discarded – undo
1867 1867
  * @param string $option_group A settings group name. Should correspond to a whitelisted option key name.
1868 1868
  * 	Default whitelisted option key names include "general," "discussion," and "reading," among others.
1869 1869
  * @param string $option_name The name of an option to sanitize and save.
1870
- * @param array  $args {
1870
+ * @param callable  $args {
1871 1871
  *     Data used to describe the setting when registered.
1872 1872
  *
1873 1873
  *     @type string   $type              The type of data associated with this setting.
Please login to merge, or discard this patch.
Braces   +93 added lines, -63 removed lines patch added patch discarded remove patch
@@ -31,8 +31,9 @@  discard block
 block discarded – undo
31 31
 	global $wpdb;
32 32
 
33 33
 	$option = trim( $option );
34
-	if ( empty( $option ) )
35
-		return false;
34
+	if ( empty( $option ) ) {
35
+			return false;
36
+	}
36 37
 
37 38
 	/**
38 39
 	 * Filters the value of an existing option before it is retrieved.
@@ -50,11 +51,13 @@  discard block
 block discarded – undo
50 51
 	 * @param string     $option     Option name.
51 52
 	 */
52 53
 	$pre = apply_filters( "pre_option_{$option}", false, $option );
53
-	if ( false !== $pre )
54
-		return $pre;
54
+	if ( false !== $pre ) {
55
+			return $pre;
56
+	}
55 57
 
56
-	if ( defined( 'WP_SETUP_CONFIG' ) )
57
-		return false;
58
+	if ( defined( 'WP_SETUP_CONFIG' ) ) {
59
+			return false;
60
+	}
58 61
 
59 62
 	// Distinguish between `false` as a default, and not passing one.
60 63
 	$passed_default = func_num_args() > 1;
@@ -119,11 +122,13 @@  discard block
 block discarded – undo
119 122
 	}
120 123
 
121 124
 	// If home is not set use siteurl.
122
-	if ( 'home' == $option && '' == $value )
123
-		return get_option( 'siteurl' );
125
+	if ( 'home' == $option && '' == $value ) {
126
+			return get_option( 'siteurl' );
127
+	}
124 128
 
125
-	if ( in_array( $option, array('siteurl', 'home', 'category_base', 'tag_base') ) )
126
-		$value = untrailingslashit( $value );
129
+	if ( in_array( $option, array('siteurl', 'home', 'category_base', 'tag_base') ) ) {
130
+			$value = untrailingslashit( $value );
131
+	}
127 132
 
128 133
 	/**
129 134
 	 * Filters the value of an existing option.
@@ -152,9 +157,10 @@  discard block
 block discarded – undo
152 157
  * @param string $option Option name.
153 158
  */
154 159
 function wp_protect_special_option( $option ) {
155
-	if ( 'alloptions' === $option || 'notoptions' === $option )
156
-		wp_die( sprintf( __( '%s is a protected WP option and may not be modified' ), esc_html( $option ) ) );
157
-}
160
+	if ( 'alloptions' === $option || 'notoptions' === $option ) {
161
+			wp_die( sprintf( __( '%s is a protected WP option and may not be modified' ), esc_html( $option ) ) );
162
+	}
163
+	}
158 164
 
159 165
 /**
160 166
  * Print option value after sanitizing for forms.
@@ -179,22 +185,25 @@  discard block
 block discarded – undo
179 185
 function wp_load_alloptions() {
180 186
 	global $wpdb;
181 187
 
182
-	if ( ! wp_installing() || ! is_multisite() )
183
-		$alloptions = wp_cache_get( 'alloptions', 'options' );
184
-	else
185
-		$alloptions = false;
188
+	if ( ! wp_installing() || ! is_multisite() ) {
189
+			$alloptions = wp_cache_get( 'alloptions', 'options' );
190
+	} else {
191
+			$alloptions = false;
192
+	}
186 193
 
187 194
 	if ( !$alloptions ) {
188 195
 		$suppress = $wpdb->suppress_errors();
189
-		if ( !$alloptions_db = $wpdb->get_results( "SELECT option_name, option_value FROM $wpdb->options WHERE autoload = 'yes'" ) )
190
-			$alloptions_db = $wpdb->get_results( "SELECT option_name, option_value FROM $wpdb->options" );
196
+		if ( !$alloptions_db = $wpdb->get_results( "SELECT option_name, option_value FROM $wpdb->options WHERE autoload = 'yes'" ) ) {
197
+					$alloptions_db = $wpdb->get_results( "SELECT option_name, option_value FROM $wpdb->options" );
198
+		}
191 199
 		$wpdb->suppress_errors($suppress);
192 200
 		$alloptions = array();
193 201
 		foreach ( (array) $alloptions_db as $o ) {
194 202
 			$alloptions[$o->option_name] = $o->option_value;
195 203
 		}
196
-		if ( ! wp_installing() || ! is_multisite() )
197
-			wp_cache_add( 'alloptions', $alloptions, 'options' );
204
+		if ( ! wp_installing() || ! is_multisite() ) {
205
+					wp_cache_add( 'alloptions', $alloptions, 'options' );
206
+		}
198 207
 	}
199 208
 
200 209
 	return $alloptions;
@@ -212,11 +221,13 @@  discard block
 block discarded – undo
212 221
 function wp_load_core_site_options( $site_id = null ) {
213 222
 	global $wpdb;
214 223
 
215
-	if ( ! is_multisite() || wp_using_ext_object_cache() || wp_installing() )
216
-		return;
224
+	if ( ! is_multisite() || wp_using_ext_object_cache() || wp_installing() ) {
225
+			return;
226
+	}
217 227
 
218
-	if ( empty($site_id) )
219
-		$site_id = $wpdb->siteid;
228
+	if ( empty($site_id) ) {
229
+			$site_id = $wpdb->siteid;
230
+	}
220 231
 
221 232
 	$core_options = array('site_name', 'siteurl', 'active_sitewide_plugins', '_site_transient_timeout_theme_roots', '_site_transient_theme_roots', 'site_admins', 'can_compress_scripts', 'global_terms_enabled', 'ms_files_rewriting' );
222 233
 
@@ -259,13 +270,15 @@  discard block
 block discarded – undo
259 270
 	global $wpdb;
260 271
 
261 272
 	$option = trim($option);
262
-	if ( empty($option) )
263
-		return false;
273
+	if ( empty($option) ) {
274
+			return false;
275
+	}
264 276
 
265 277
 	wp_protect_special_option( $option );
266 278
 
267
-	if ( is_object( $value ) )
268
-		$value = clone $value;
279
+	if ( is_object( $value ) ) {
280
+			$value = clone $value;
281
+	}
269 282
 
270 283
 	$value = sanitize_option( $option, $value );
271 284
 	$old_value = get_option( $option );
@@ -340,8 +353,9 @@  discard block
 block discarded – undo
340 353
 	}
341 354
 
342 355
 	$result = $wpdb->update( $wpdb->options, $update_args, array( 'option_name' => $option ) );
343
-	if ( ! $result )
344
-		return false;
356
+	if ( ! $result ) {
357
+			return false;
358
+	}
345 359
 
346 360
 	$notoptions = wp_cache_get( 'notoptions', 'options' );
347 361
 	if ( is_array( $notoptions ) && isset( $notoptions[$option] ) ) {
@@ -412,26 +426,30 @@  discard block
 block discarded – undo
412 426
 function add_option( $option, $value = '', $deprecated = '', $autoload = 'yes' ) {
413 427
 	global $wpdb;
414 428
 
415
-	if ( !empty( $deprecated ) )
416
-		_deprecated_argument( __FUNCTION__, '2.3.0' );
429
+	if ( !empty( $deprecated ) ) {
430
+			_deprecated_argument( __FUNCTION__, '2.3.0' );
431
+	}
417 432
 
418 433
 	$option = trim($option);
419
-	if ( empty($option) )
420
-		return false;
434
+	if ( empty($option) ) {
435
+			return false;
436
+	}
421 437
 
422 438
 	wp_protect_special_option( $option );
423 439
 
424
-	if ( is_object($value) )
425
-		$value = clone $value;
440
+	if ( is_object($value) ) {
441
+			$value = clone $value;
442
+	}
426 443
 
427 444
 	$value = sanitize_option( $option, $value );
428 445
 
429 446
 	// Make sure the option doesn't already exist. We can check the 'notoptions' cache before we ask for a db query
430 447
 	$notoptions = wp_cache_get( 'notoptions', 'options' );
431
-	if ( !is_array( $notoptions ) || !isset( $notoptions[$option] ) )
432
-		/** This filter is documented in wp-includes/option.php */
448
+	if ( !is_array( $notoptions ) || !isset( $notoptions[$option] ) ) {
449
+			/** This filter is documented in wp-includes/option.php */
433 450
 		if ( apply_filters( "default_option_{$option}", false, $option, false ) !== get_option( $option ) )
434 451
 			return false;
452
+	}
435 453
 
436 454
 	$serialized_value = maybe_serialize( $value );
437 455
 	$autoload = ( 'no' === $autoload || false === $autoload ) ? 'no' : 'yes';
@@ -447,8 +465,9 @@  discard block
 block discarded – undo
447 465
 	do_action( 'add_option', $option, $value );
448 466
 
449 467
 	$result = $wpdb->query( $wpdb->prepare( "INSERT INTO `$wpdb->options` (`option_name`, `option_value`, `autoload`) VALUES (%s, %s, %s) ON DUPLICATE KEY UPDATE `option_name` = VALUES(`option_name`), `option_value` = VALUES(`option_value`), `autoload` = VALUES(`autoload`)", $option, $serialized_value, $autoload ) );
450
-	if ( ! $result )
451
-		return false;
468
+	if ( ! $result ) {
469
+			return false;
470
+	}
452 471
 
453 472
 	if ( ! wp_installing() ) {
454 473
 		if ( 'yes' == $autoload ) {
@@ -506,15 +525,17 @@  discard block
 block discarded – undo
506 525
 	global $wpdb;
507 526
 
508 527
 	$option = trim( $option );
509
-	if ( empty( $option ) )
510
-		return false;
528
+	if ( empty( $option ) ) {
529
+			return false;
530
+	}
511 531
 
512 532
 	wp_protect_special_option( $option );
513 533
 
514 534
 	// Get the ID, if no ID then return
515 535
 	$row = $wpdb->get_row( $wpdb->prepare( "SELECT autoload FROM $wpdb->options WHERE option_name = %s", $option ) );
516
-	if ( is_null( $row ) )
517
-		return false;
536
+	if ( is_null( $row ) ) {
537
+			return false;
538
+	}
518 539
 
519 540
 	/**
520 541
 	 * Fires immediately before an option is deleted.
@@ -590,8 +611,9 @@  discard block
 block discarded – undo
590 611
 		$option_timeout = '_transient_timeout_' . $transient;
591 612
 		$option = '_transient_' . $transient;
592 613
 		$result = delete_option( $option );
593
-		if ( $result )
594
-			delete_option( $option_timeout );
614
+		if ( $result ) {
615
+					delete_option( $option_timeout );
616
+		}
595 617
 	}
596 618
 
597 619
 	if ( $result ) {
@@ -639,8 +661,9 @@  discard block
 block discarded – undo
639 661
 	 * @param string $transient     Transient name.
640 662
 	 */
641 663
 	$pre = apply_filters( "pre_transient_{$transient}", false, $transient );
642
-	if ( false !== $pre )
643
-		return $pre;
664
+	if ( false !== $pre ) {
665
+			return $pre;
666
+	}
644 667
 
645 668
 	if ( wp_using_ext_object_cache() ) {
646 669
 		$value = wp_cache_get( $transient, 'transient' );
@@ -660,8 +683,9 @@  discard block
 block discarded – undo
660 683
 			}
661 684
 		}
662 685
 
663
-		if ( ! isset( $value ) )
664
-			$value = get_option( $transient_option );
686
+		if ( ! isset( $value ) ) {
687
+					$value = get_option( $transient_option );
688
+		}
665 689
 	}
666 690
 
667 691
 	/**
@@ -818,8 +842,9 @@  discard block
 block discarded – undo
818 842
 		$cookie = preg_replace( '/[^A-Za-z0-9=&_]/', '', $_COOKIE['wp-settings-' . $user_id] );
819 843
 
820 844
 		// No change or both empty
821
-		if ( $cookie == $settings )
822
-			return;
845
+		if ( $cookie == $settings ) {
846
+					return;
847
+		}
823 848
 
824 849
 		$last_saved = (int) get_user_option( 'user-settings-time', $user_id );
825 850
 		$current = isset( $_COOKIE['wp-settings-time-' . $user_id]) ? preg_replace( '/[^0-9]/', '', $_COOKIE['wp-settings-time-' . $user_id] ) : 0;
@@ -1542,8 +1567,9 @@  discard block
 block discarded – undo
1542 1567
 		$option_timeout = '_site_transient_timeout_' . $transient;
1543 1568
 		$option = '_site_transient_' . $transient;
1544 1569
 		$result = delete_site_option( $option );
1545
-		if ( $result )
1546
-			delete_site_option( $option_timeout );
1570
+		if ( $result ) {
1571
+					delete_site_option( $option_timeout );
1572
+		}
1547 1573
 	}
1548 1574
 	if ( $result ) {
1549 1575
 
@@ -1593,8 +1619,9 @@  discard block
 block discarded – undo
1593 1619
 	 */
1594 1620
 	$pre = apply_filters( "pre_site_transient_{$transient}", false, $transient );
1595 1621
 
1596
-	if ( false !== $pre )
1597
-		return $pre;
1622
+	if ( false !== $pre ) {
1623
+			return $pre;
1624
+	}
1598 1625
 
1599 1626
 	if ( wp_using_ext_object_cache() ) {
1600 1627
 		$value = wp_cache_get( $transient, 'site-transient' );
@@ -1612,8 +1639,9 @@  discard block
 block discarded – undo
1612 1639
 			}
1613 1640
 		}
1614 1641
 
1615
-		if ( ! isset( $value ) )
1616
-			$value = get_site_option( $transient_option );
1642
+		if ( ! isset( $value ) ) {
1643
+					$value = get_site_option( $transient_option );
1644
+		}
1617 1645
 	}
1618 1646
 
1619 1647
 	/**
@@ -1682,12 +1710,14 @@  discard block
 block discarded – undo
1682 1710
 		$transient_timeout = '_site_transient_timeout_' . $transient;
1683 1711
 		$option = '_site_transient_' . $transient;
1684 1712
 		if ( false === get_site_option( $option ) ) {
1685
-			if ( $expiration )
1686
-				add_site_option( $transient_timeout, time() + $expiration );
1713
+			if ( $expiration ) {
1714
+							add_site_option( $transient_timeout, time() + $expiration );
1715
+			}
1687 1716
 			$result = add_site_option( $option, $value );
1688 1717
 		} else {
1689
-			if ( $expiration )
1690
-				update_site_option( $transient_timeout, time() + $expiration );
1718
+			if ( $expiration ) {
1719
+							update_site_option( $transient_timeout, time() + $expiration );
1720
+			}
1691 1721
 			$result = update_site_option( $option, $value );
1692 1722
 		}
1693 1723
 	}
Please login to merge, or discard this patch.
Spacing   +443 added lines, -443 removed lines patch added patch discarded remove patch
@@ -27,11 +27,11 @@  discard block
 block discarded – undo
27 27
  * @param mixed  $default Optional. Default value to return if the option does not exist.
28 28
  * @return mixed Value set for the option.
29 29
  */
30
-function get_option( $option, $default = false ) {
30
+function get_option($option, $default = false) {
31 31
 	global $wpdb;
32 32
 
33
-	$option = trim( $option );
34
-	if ( empty( $option ) )
33
+	$option = trim($option);
34
+	if (empty($option))
35 35
 		return false;
36 36
 
37 37
 	/**
@@ -49,20 +49,20 @@  discard block
 block discarded – undo
49 49
 	 *                               Default false to skip it.
50 50
 	 * @param string     $option     Option name.
51 51
 	 */
52
-	$pre = apply_filters( "pre_option_{$option}", false, $option );
53
-	if ( false !== $pre )
52
+	$pre = apply_filters("pre_option_{$option}", false, $option);
53
+	if (false !== $pre)
54 54
 		return $pre;
55 55
 
56
-	if ( defined( 'WP_SETUP_CONFIG' ) )
56
+	if (defined('WP_SETUP_CONFIG'))
57 57
 		return false;
58 58
 
59 59
 	// Distinguish between `false` as a default, and not passing one.
60 60
 	$passed_default = func_num_args() > 1;
61 61
 
62
-	if ( ! wp_installing() ) {
62
+	if ( ! wp_installing()) {
63 63
 		// prevent non-existent options from triggering multiple queries
64
-		$notoptions = wp_cache_get( 'notoptions', 'options' );
65
-		if ( isset( $notoptions[ $option ] ) ) {
64
+		$notoptions = wp_cache_get('notoptions', 'options');
65
+		if (isset($notoptions[$option])) {
66 66
 			/**
67 67
 			 * Filters the default value for an option.
68 68
 			 *
@@ -77,53 +77,53 @@  discard block
 block discarded – undo
77 77
 			 * @param string $option  Option name.
78 78
 			 * @param bool   $passed_default Was `get_option()` passed a default value?
79 79
 			 */
80
-			return apply_filters( "default_option_{$option}", $default, $option, $passed_default );
80
+			return apply_filters("default_option_{$option}", $default, $option, $passed_default);
81 81
 		}
82 82
 
83 83
 		$alloptions = wp_load_alloptions();
84 84
 
85
-		if ( isset( $alloptions[$option] ) ) {
85
+		if (isset($alloptions[$option])) {
86 86
 			$value = $alloptions[$option];
87 87
 		} else {
88
-			$value = wp_cache_get( $option, 'options' );
88
+			$value = wp_cache_get($option, 'options');
89 89
 
90
-			if ( false === $value ) {
91
-				$row = $wpdb->get_row( $wpdb->prepare( "SELECT option_value FROM $wpdb->options WHERE option_name = %s LIMIT 1", $option ) );
90
+			if (false === $value) {
91
+				$row = $wpdb->get_row($wpdb->prepare("SELECT option_value FROM $wpdb->options WHERE option_name = %s LIMIT 1", $option));
92 92
 
93 93
 				// Has to be get_row instead of get_var because of funkiness with 0, false, null values
94
-				if ( is_object( $row ) ) {
94
+				if (is_object($row)) {
95 95
 					$value = $row->option_value;
96
-					wp_cache_add( $option, $value, 'options' );
96
+					wp_cache_add($option, $value, 'options');
97 97
 				} else { // option does not exist, so we must cache its non-existence
98
-					if ( ! is_array( $notoptions ) ) {
98
+					if ( ! is_array($notoptions)) {
99 99
 						 $notoptions = array();
100 100
 					}
101 101
 					$notoptions[$option] = true;
102
-					wp_cache_set( 'notoptions', $notoptions, 'options' );
102
+					wp_cache_set('notoptions', $notoptions, 'options');
103 103
 
104 104
 					/** This filter is documented in wp-includes/option.php */
105
-					return apply_filters( "default_option_{$option}", $default, $option, $passed_default );
105
+					return apply_filters("default_option_{$option}", $default, $option, $passed_default);
106 106
 				}
107 107
 			}
108 108
 		}
109 109
 	} else {
110 110
 		$suppress = $wpdb->suppress_errors();
111
-		$row = $wpdb->get_row( $wpdb->prepare( "SELECT option_value FROM $wpdb->options WHERE option_name = %s LIMIT 1", $option ) );
112
-		$wpdb->suppress_errors( $suppress );
113
-		if ( is_object( $row ) ) {
111
+		$row = $wpdb->get_row($wpdb->prepare("SELECT option_value FROM $wpdb->options WHERE option_name = %s LIMIT 1", $option));
112
+		$wpdb->suppress_errors($suppress);
113
+		if (is_object($row)) {
114 114
 			$value = $row->option_value;
115 115
 		} else {
116 116
 			/** This filter is documented in wp-includes/option.php */
117
-			return apply_filters( "default_option_{$option}", $default, $option, $passed_default );
117
+			return apply_filters("default_option_{$option}", $default, $option, $passed_default);
118 118
 		}
119 119
 	}
120 120
 
121 121
 	// If home is not set use siteurl.
122
-	if ( 'home' == $option && '' == $value )
123
-		return get_option( 'siteurl' );
122
+	if ('home' == $option && '' == $value)
123
+		return get_option('siteurl');
124 124
 
125
-	if ( in_array( $option, array('siteurl', 'home', 'category_base', 'tag_base') ) )
126
-		$value = untrailingslashit( $value );
125
+	if (in_array($option, array('siteurl', 'home', 'category_base', 'tag_base')))
126
+		$value = untrailingslashit($value);
127 127
 
128 128
 	/**
129 129
 	 * Filters the value of an existing option.
@@ -138,7 +138,7 @@  discard block
 block discarded – undo
138 138
 	 *                       unserialized prior to being returned.
139 139
 	 * @param string $option Option name.
140 140
 	 */
141
-	return apply_filters( "option_{$option}", maybe_unserialize( $value ), $option );
141
+	return apply_filters("option_{$option}", maybe_unserialize($value), $option);
142 142
 }
143 143
 
144 144
 /**
@@ -151,9 +151,9 @@  discard block
 block discarded – undo
151 151
  *
152 152
  * @param string $option Option name.
153 153
  */
154
-function wp_protect_special_option( $option ) {
155
-	if ( 'alloptions' === $option || 'notoptions' === $option )
156
-		wp_die( sprintf( __( '%s is a protected WP option and may not be modified' ), esc_html( $option ) ) );
154
+function wp_protect_special_option($option) {
155
+	if ('alloptions' === $option || 'notoptions' === $option)
156
+		wp_die(sprintf(__('%s is a protected WP option and may not be modified'), esc_html($option)));
157 157
 }
158 158
 
159 159
 /**
@@ -163,8 +163,8 @@  discard block
 block discarded – undo
163 163
  *
164 164
  * @param string $option Option name.
165 165
  */
166
-function form_option( $option ) {
167
-	echo esc_attr( get_option( $option ) );
166
+function form_option($option) {
167
+	echo esc_attr(get_option($option));
168 168
 }
169 169
 
170 170
 /**
@@ -179,22 +179,22 @@  discard block
 block discarded – undo
179 179
 function wp_load_alloptions() {
180 180
 	global $wpdb;
181 181
 
182
-	if ( ! wp_installing() || ! is_multisite() )
183
-		$alloptions = wp_cache_get( 'alloptions', 'options' );
182
+	if ( ! wp_installing() || ! is_multisite())
183
+		$alloptions = wp_cache_get('alloptions', 'options');
184 184
 	else
185 185
 		$alloptions = false;
186 186
 
187
-	if ( !$alloptions ) {
187
+	if ( ! $alloptions) {
188 188
 		$suppress = $wpdb->suppress_errors();
189
-		if ( !$alloptions_db = $wpdb->get_results( "SELECT option_name, option_value FROM $wpdb->options WHERE autoload = 'yes'" ) )
190
-			$alloptions_db = $wpdb->get_results( "SELECT option_name, option_value FROM $wpdb->options" );
189
+		if ( ! $alloptions_db = $wpdb->get_results("SELECT option_name, option_value FROM $wpdb->options WHERE autoload = 'yes'"))
190
+			$alloptions_db = $wpdb->get_results("SELECT option_name, option_value FROM $wpdb->options");
191 191
 		$wpdb->suppress_errors($suppress);
192 192
 		$alloptions = array();
193
-		foreach ( (array) $alloptions_db as $o ) {
193
+		foreach ((array) $alloptions_db as $o) {
194 194
 			$alloptions[$o->option_name] = $o->option_value;
195 195
 		}
196
-		if ( ! wp_installing() || ! is_multisite() )
197
-			wp_cache_add( 'alloptions', $alloptions, 'options' );
196
+		if ( ! wp_installing() || ! is_multisite())
197
+			wp_cache_add('alloptions', $alloptions, 'options');
198 198
 	}
199 199
 
200 200
 	return $alloptions;
@@ -209,26 +209,26 @@  discard block
 block discarded – undo
209 209
  *
210 210
  * @param int $site_id Optional site ID for which to query the options. Defaults to the current site.
211 211
  */
212
-function wp_load_core_site_options( $site_id = null ) {
212
+function wp_load_core_site_options($site_id = null) {
213 213
 	global $wpdb;
214 214
 
215
-	if ( ! is_multisite() || wp_using_ext_object_cache() || wp_installing() )
215
+	if ( ! is_multisite() || wp_using_ext_object_cache() || wp_installing())
216 216
 		return;
217 217
 
218
-	if ( empty($site_id) )
218
+	if (empty($site_id))
219 219
 		$site_id = $wpdb->siteid;
220 220
 
221
-	$core_options = array('site_name', 'siteurl', 'active_sitewide_plugins', '_site_transient_timeout_theme_roots', '_site_transient_theme_roots', 'site_admins', 'can_compress_scripts', 'global_terms_enabled', 'ms_files_rewriting' );
221
+	$core_options = array('site_name', 'siteurl', 'active_sitewide_plugins', '_site_transient_timeout_theme_roots', '_site_transient_theme_roots', 'site_admins', 'can_compress_scripts', 'global_terms_enabled', 'ms_files_rewriting');
222 222
 
223
-	$core_options_in = "'" . implode("', '", $core_options) . "'";
224
-	$options = $wpdb->get_results( $wpdb->prepare("SELECT meta_key, meta_value FROM $wpdb->sitemeta WHERE meta_key IN ($core_options_in) AND site_id = %d", $site_id) );
223
+	$core_options_in = "'".implode("', '", $core_options)."'";
224
+	$options = $wpdb->get_results($wpdb->prepare("SELECT meta_key, meta_value FROM $wpdb->sitemeta WHERE meta_key IN ($core_options_in) AND site_id = %d", $site_id));
225 225
 
226
-	foreach ( $options as $option ) {
226
+	foreach ($options as $option) {
227 227
 		$key = $option->meta_key;
228 228
 		$cache_key = "{$site_id}:$key";
229
-		$option->meta_value = maybe_unserialize( $option->meta_value );
229
+		$option->meta_value = maybe_unserialize($option->meta_value);
230 230
 
231
-		wp_cache_set( $cache_key, $option->meta_value, 'site-options' );
231
+		wp_cache_set($cache_key, $option->meta_value, 'site-options');
232 232
 	}
233 233
 }
234 234
 
@@ -255,20 +255,20 @@  discard block
 block discarded – undo
255 255
  *                              the default value is 'yes'. Default null.
256 256
  * @return bool False if value was not updated and true if value was updated.
257 257
  */
258
-function update_option( $option, $value, $autoload = null ) {
258
+function update_option($option, $value, $autoload = null) {
259 259
 	global $wpdb;
260 260
 
261 261
 	$option = trim($option);
262
-	if ( empty($option) )
262
+	if (empty($option))
263 263
 		return false;
264 264
 
265
-	wp_protect_special_option( $option );
265
+	wp_protect_special_option($option);
266 266
 
267
-	if ( is_object( $value ) )
267
+	if (is_object($value))
268 268
 		$value = clone $value;
269 269
 
270
-	$value = sanitize_option( $option, $value );
271
-	$old_value = get_option( $option );
270
+	$value = sanitize_option($option, $value);
271
+	$old_value = get_option($option);
272 272
 
273 273
 	/**
274 274
 	 * Filters a specific option before its value is (maybe) serialized and updated.
@@ -282,7 +282,7 @@  discard block
 block discarded – undo
282 282
 	 * @param mixed  $old_value The old option value.
283 283
 	 * @param string $option    Option name.
284 284
 	 */
285
-	$value = apply_filters( "pre_update_option_{$option}", $value, $old_value, $option );
285
+	$value = apply_filters("pre_update_option_{$option}", $value, $old_value, $option);
286 286
 
287 287
 	/**
288 288
 	 * Filters an option before its value is (maybe) serialized and updated.
@@ -293,7 +293,7 @@  discard block
 block discarded – undo
293 293
 	 * @param string $option    Name of the option.
294 294
 	 * @param mixed  $old_value The old option value.
295 295
 	 */
296
-	$value = apply_filters( 'pre_update_option', $value, $option, $old_value );
296
+	$value = apply_filters('pre_update_option', $value, $option, $old_value);
297 297
 
298 298
 	/*
299 299
 	 * If the new and old values are the same, no need to update.
@@ -304,21 +304,21 @@  discard block
 block discarded – undo
304 304
 	 *
305 305
 	 * See https://core.trac.wordpress.org/ticket/38903
306 306
 	 */
307
-	if ( $value === $old_value || maybe_serialize( $value ) === maybe_serialize( $old_value ) ) {
307
+	if ($value === $old_value || maybe_serialize($value) === maybe_serialize($old_value)) {
308 308
 		return false;
309 309
 	}
310 310
 
311 311
 	/** This filter is documented in wp-includes/option.php */
312
-	if ( apply_filters( "default_option_{$option}", false, $option, false ) === $old_value ) {
312
+	if (apply_filters("default_option_{$option}", false, $option, false) === $old_value) {
313 313
 		// Default setting for new options is 'yes'.
314
-		if ( null === $autoload ) {
314
+		if (null === $autoload) {
315 315
 			$autoload = 'yes';
316 316
 		}
317 317
 
318
-		return add_option( $option, $value, '', $autoload );
318
+		return add_option($option, $value, '', $autoload);
319 319
 	}
320 320
 
321
-	$serialized_value = maybe_serialize( $value );
321
+	$serialized_value = maybe_serialize($value);
322 322
 
323 323
 	/**
324 324
 	 * Fires immediately before an option value is updated.
@@ -329,33 +329,33 @@  discard block
 block discarded – undo
329 329
 	 * @param mixed  $old_value The old option value.
330 330
 	 * @param mixed  $value     The new option value.
331 331
 	 */
332
-	do_action( 'update_option', $option, $old_value, $value );
332
+	do_action('update_option', $option, $old_value, $value);
333 333
 
334 334
 	$update_args = array(
335 335
 		'option_value' => $serialized_value,
336 336
 	);
337 337
 
338
-	if ( null !== $autoload ) {
339
-		$update_args['autoload'] = ( 'no' === $autoload || false === $autoload ) ? 'no' : 'yes';
338
+	if (null !== $autoload) {
339
+		$update_args['autoload'] = ('no' === $autoload || false === $autoload) ? 'no' : 'yes';
340 340
 	}
341 341
 
342
-	$result = $wpdb->update( $wpdb->options, $update_args, array( 'option_name' => $option ) );
343
-	if ( ! $result )
342
+	$result = $wpdb->update($wpdb->options, $update_args, array('option_name' => $option));
343
+	if ( ! $result)
344 344
 		return false;
345 345
 
346
-	$notoptions = wp_cache_get( 'notoptions', 'options' );
347
-	if ( is_array( $notoptions ) && isset( $notoptions[$option] ) ) {
348
-		unset( $notoptions[$option] );
349
-		wp_cache_set( 'notoptions', $notoptions, 'options' );
346
+	$notoptions = wp_cache_get('notoptions', 'options');
347
+	if (is_array($notoptions) && isset($notoptions[$option])) {
348
+		unset($notoptions[$option]);
349
+		wp_cache_set('notoptions', $notoptions, 'options');
350 350
 	}
351 351
 
352
-	if ( ! wp_installing() ) {
352
+	if ( ! wp_installing()) {
353 353
 		$alloptions = wp_load_alloptions();
354
-		if ( isset( $alloptions[$option] ) ) {
355
-			$alloptions[ $option ] = $serialized_value;
356
-			wp_cache_set( 'alloptions', $alloptions, 'options' );
354
+		if (isset($alloptions[$option])) {
355
+			$alloptions[$option] = $serialized_value;
356
+			wp_cache_set('alloptions', $alloptions, 'options');
357 357
 		} else {
358
-			wp_cache_set( $option, $serialized_value, 'options' );
358
+			wp_cache_set($option, $serialized_value, 'options');
359 359
 		}
360 360
 	}
361 361
 
@@ -371,7 +371,7 @@  discard block
 block discarded – undo
371 371
 	 * @param mixed  $value     The new option value.
372 372
 	 * @param string $option    Option name.
373 373
 	 */
374
-	do_action( "update_option_{$option}", $old_value, $value, $option );
374
+	do_action("update_option_{$option}", $old_value, $value, $option);
375 375
 
376 376
 	/**
377 377
 	 * Fires after the value of an option has been successfully updated.
@@ -382,7 +382,7 @@  discard block
 block discarded – undo
382 382
 	 * @param mixed  $old_value The old option value.
383 383
 	 * @param mixed  $value     The new option value.
384 384
 	 */
385
-	do_action( 'updated_option', $option, $old_value, $value );
385
+	do_action('updated_option', $option, $old_value, $value);
386 386
 	return true;
387 387
 }
388 388
 
@@ -409,32 +409,32 @@  discard block
 block discarded – undo
409 409
  *                                    Default is enabled. Accepts 'no' to disable for legacy reasons.
410 410
  * @return bool False if option was not added and true if option was added.
411 411
  */
412
-function add_option( $option, $value = '', $deprecated = '', $autoload = 'yes' ) {
412
+function add_option($option, $value = '', $deprecated = '', $autoload = 'yes') {
413 413
 	global $wpdb;
414 414
 
415
-	if ( !empty( $deprecated ) )
416
-		_deprecated_argument( __FUNCTION__, '2.3.0' );
415
+	if ( ! empty($deprecated))
416
+		_deprecated_argument(__FUNCTION__, '2.3.0');
417 417
 
418 418
 	$option = trim($option);
419
-	if ( empty($option) )
419
+	if (empty($option))
420 420
 		return false;
421 421
 
422
-	wp_protect_special_option( $option );
422
+	wp_protect_special_option($option);
423 423
 
424
-	if ( is_object($value) )
424
+	if (is_object($value))
425 425
 		$value = clone $value;
426 426
 
427
-	$value = sanitize_option( $option, $value );
427
+	$value = sanitize_option($option, $value);
428 428
 
429 429
 	// Make sure the option doesn't already exist. We can check the 'notoptions' cache before we ask for a db query
430
-	$notoptions = wp_cache_get( 'notoptions', 'options' );
431
-	if ( !is_array( $notoptions ) || !isset( $notoptions[$option] ) )
430
+	$notoptions = wp_cache_get('notoptions', 'options');
431
+	if ( ! is_array($notoptions) || ! isset($notoptions[$option]))
432 432
 		/** This filter is documented in wp-includes/option.php */
433
-		if ( apply_filters( "default_option_{$option}", false, $option, false ) !== get_option( $option ) )
433
+		if (apply_filters("default_option_{$option}", false, $option, false) !== get_option($option))
434 434
 			return false;
435 435
 
436
-	$serialized_value = maybe_serialize( $value );
437
-	$autoload = ( 'no' === $autoload || false === $autoload ) ? 'no' : 'yes';
436
+	$serialized_value = maybe_serialize($value);
437
+	$autoload = ('no' === $autoload || false === $autoload) ? 'no' : 'yes';
438 438
 
439 439
 	/**
440 440
 	 * Fires before an option is added.
@@ -444,27 +444,27 @@  discard block
 block discarded – undo
444 444
 	 * @param string $option Name of the option to add.
445 445
 	 * @param mixed  $value  Value of the option.
446 446
 	 */
447
-	do_action( 'add_option', $option, $value );
447
+	do_action('add_option', $option, $value);
448 448
 
449
-	$result = $wpdb->query( $wpdb->prepare( "INSERT INTO `$wpdb->options` (`option_name`, `option_value`, `autoload`) VALUES (%s, %s, %s) ON DUPLICATE KEY UPDATE `option_name` = VALUES(`option_name`), `option_value` = VALUES(`option_value`), `autoload` = VALUES(`autoload`)", $option, $serialized_value, $autoload ) );
450
-	if ( ! $result )
449
+	$result = $wpdb->query($wpdb->prepare("INSERT INTO `$wpdb->options` (`option_name`, `option_value`, `autoload`) VALUES (%s, %s, %s) ON DUPLICATE KEY UPDATE `option_name` = VALUES(`option_name`), `option_value` = VALUES(`option_value`), `autoload` = VALUES(`autoload`)", $option, $serialized_value, $autoload));
450
+	if ( ! $result)
451 451
 		return false;
452 452
 
453
-	if ( ! wp_installing() ) {
454
-		if ( 'yes' == $autoload ) {
453
+	if ( ! wp_installing()) {
454
+		if ('yes' == $autoload) {
455 455
 			$alloptions = wp_load_alloptions();
456
-			$alloptions[ $option ] = $serialized_value;
457
-			wp_cache_set( 'alloptions', $alloptions, 'options' );
456
+			$alloptions[$option] = $serialized_value;
457
+			wp_cache_set('alloptions', $alloptions, 'options');
458 458
 		} else {
459
-			wp_cache_set( $option, $serialized_value, 'options' );
459
+			wp_cache_set($option, $serialized_value, 'options');
460 460
 		}
461 461
 	}
462 462
 
463 463
 	// This option exists now
464
-	$notoptions = wp_cache_get( 'notoptions', 'options' ); // yes, again... we need it to be fresh
465
-	if ( is_array( $notoptions ) && isset( $notoptions[$option] ) ) {
466
-		unset( $notoptions[$option] );
467
-		wp_cache_set( 'notoptions', $notoptions, 'options' );
464
+	$notoptions = wp_cache_get('notoptions', 'options'); // yes, again... we need it to be fresh
465
+	if (is_array($notoptions) && isset($notoptions[$option])) {
466
+		unset($notoptions[$option]);
467
+		wp_cache_set('notoptions', $notoptions, 'options');
468 468
 	}
469 469
 
470 470
 	/**
@@ -478,7 +478,7 @@  discard block
 block discarded – undo
478 478
 	 * @param string $option Name of the option to add.
479 479
 	 * @param mixed  $value  Value of the option.
480 480
 	 */
481
-	do_action( "add_option_{$option}", $option, $value );
481
+	do_action("add_option_{$option}", $option, $value);
482 482
 
483 483
 	/**
484 484
 	 * Fires after an option has been added.
@@ -488,7 +488,7 @@  discard block
 block discarded – undo
488 488
 	 * @param string $option Name of the added option.
489 489
 	 * @param mixed  $value  Value of the option.
490 490
 	 */
491
-	do_action( 'added_option', $option, $value );
491
+	do_action('added_option', $option, $value);
492 492
 	return true;
493 493
 }
494 494
 
@@ -502,18 +502,18 @@  discard block
 block discarded – undo
502 502
  * @param string $option Name of option to remove. Expected to not be SQL-escaped.
503 503
  * @return bool True, if option is successfully deleted. False on failure.
504 504
  */
505
-function delete_option( $option ) {
505
+function delete_option($option) {
506 506
 	global $wpdb;
507 507
 
508
-	$option = trim( $option );
509
-	if ( empty( $option ) )
508
+	$option = trim($option);
509
+	if (empty($option))
510 510
 		return false;
511 511
 
512
-	wp_protect_special_option( $option );
512
+	wp_protect_special_option($option);
513 513
 
514 514
 	// Get the ID, if no ID then return
515
-	$row = $wpdb->get_row( $wpdb->prepare( "SELECT autoload FROM $wpdb->options WHERE option_name = %s", $option ) );
516
-	if ( is_null( $row ) )
515
+	$row = $wpdb->get_row($wpdb->prepare("SELECT autoload FROM $wpdb->options WHERE option_name = %s", $option));
516
+	if (is_null($row))
517 517
 		return false;
518 518
 
519 519
 	/**
@@ -523,21 +523,21 @@  discard block
 block discarded – undo
523 523
 	 *
524 524
 	 * @param string $option Name of the option to delete.
525 525
 	 */
526
-	do_action( 'delete_option', $option );
526
+	do_action('delete_option', $option);
527 527
 
528
-	$result = $wpdb->delete( $wpdb->options, array( 'option_name' => $option ) );
529
-	if ( ! wp_installing() ) {
530
-		if ( 'yes' == $row->autoload ) {
528
+	$result = $wpdb->delete($wpdb->options, array('option_name' => $option));
529
+	if ( ! wp_installing()) {
530
+		if ('yes' == $row->autoload) {
531 531
 			$alloptions = wp_load_alloptions();
532
-			if ( is_array( $alloptions ) && isset( $alloptions[$option] ) ) {
533
-				unset( $alloptions[$option] );
534
-				wp_cache_set( 'alloptions', $alloptions, 'options' );
532
+			if (is_array($alloptions) && isset($alloptions[$option])) {
533
+				unset($alloptions[$option]);
534
+				wp_cache_set('alloptions', $alloptions, 'options');
535 535
 			}
536 536
 		} else {
537
-			wp_cache_delete( $option, 'options' );
537
+			wp_cache_delete($option, 'options');
538 538
 		}
539 539
 	}
540
-	if ( $result ) {
540
+	if ($result) {
541 541
 
542 542
 		/**
543 543
 		 * Fires after a specific option has been deleted.
@@ -548,7 +548,7 @@  discard block
 block discarded – undo
548 548
 		 *
549 549
 		 * @param string $option Name of the deleted option.
550 550
 		 */
551
-		do_action( "delete_option_{$option}", $option );
551
+		do_action("delete_option_{$option}", $option);
552 552
 
553 553
 		/**
554 554
 		 * Fires after an option has been deleted.
@@ -557,7 +557,7 @@  discard block
 block discarded – undo
557 557
 		 *
558 558
 		 * @param string $option Name of the deleted option.
559 559
 		 */
560
-		do_action( 'deleted_option', $option );
560
+		do_action('deleted_option', $option);
561 561
 		return true;
562 562
 	}
563 563
 	return false;
@@ -571,7 +571,7 @@  discard block
 block discarded – undo
571 571
  * @param string $transient Transient name. Expected to not be SQL-escaped.
572 572
  * @return bool true if successful, false otherwise
573 573
  */
574
-function delete_transient( $transient ) {
574
+function delete_transient($transient) {
575 575
 
576 576
 	/**
577 577
 	 * Fires immediately before a specific transient is deleted.
@@ -582,19 +582,19 @@  discard block
 block discarded – undo
582 582
 	 *
583 583
 	 * @param string $transient Transient name.
584 584
 	 */
585
-	do_action( "delete_transient_{$transient}", $transient );
585
+	do_action("delete_transient_{$transient}", $transient);
586 586
 
587
-	if ( wp_using_ext_object_cache() ) {
588
-		$result = wp_cache_delete( $transient, 'transient' );
587
+	if (wp_using_ext_object_cache()) {
588
+		$result = wp_cache_delete($transient, 'transient');
589 589
 	} else {
590
-		$option_timeout = '_transient_timeout_' . $transient;
591
-		$option = '_transient_' . $transient;
592
-		$result = delete_option( $option );
593
-		if ( $result )
594
-			delete_option( $option_timeout );
590
+		$option_timeout = '_transient_timeout_'.$transient;
591
+		$option = '_transient_'.$transient;
592
+		$result = delete_option($option);
593
+		if ($result)
594
+			delete_option($option_timeout);
595 595
 	}
596 596
 
597
-	if ( $result ) {
597
+	if ($result) {
598 598
 
599 599
 		/**
600 600
 		 * Fires after a transient is deleted.
@@ -603,7 +603,7 @@  discard block
 block discarded – undo
603 603
 		 *
604 604
 		 * @param string $transient Deleted transient name.
605 605
 		 */
606
-		do_action( 'deleted_transient', $transient );
606
+		do_action('deleted_transient', $transient);
607 607
 	}
608 608
 
609 609
 	return $result;
@@ -620,7 +620,7 @@  discard block
 block discarded – undo
620 620
  * @param string $transient Transient name. Expected to not be SQL-escaped.
621 621
  * @return mixed Value of transient.
622 622
  */
623
-function get_transient( $transient ) {
623
+function get_transient($transient) {
624 624
 
625 625
 	/**
626 626
 	 * Filters the value of an existing transient.
@@ -638,30 +638,30 @@  discard block
 block discarded – undo
638 638
 	 *                              of the transient, and return the returned value.
639 639
 	 * @param string $transient     Transient name.
640 640
 	 */
641
-	$pre = apply_filters( "pre_transient_{$transient}", false, $transient );
642
-	if ( false !== $pre )
641
+	$pre = apply_filters("pre_transient_{$transient}", false, $transient);
642
+	if (false !== $pre)
643 643
 		return $pre;
644 644
 
645
-	if ( wp_using_ext_object_cache() ) {
646
-		$value = wp_cache_get( $transient, 'transient' );
645
+	if (wp_using_ext_object_cache()) {
646
+		$value = wp_cache_get($transient, 'transient');
647 647
 	} else {
648
-		$transient_option = '_transient_' . $transient;
649
-		if ( ! wp_installing() ) {
648
+		$transient_option = '_transient_'.$transient;
649
+		if ( ! wp_installing()) {
650 650
 			// If option is not in alloptions, it is not autoloaded and thus has a timeout
651 651
 			$alloptions = wp_load_alloptions();
652
-			if ( !isset( $alloptions[$transient_option] ) ) {
653
-				$transient_timeout = '_transient_timeout_' . $transient;
654
-				$timeout = get_option( $transient_timeout );
655
-				if ( false !== $timeout && $timeout < time() ) {
656
-					delete_option( $transient_option  );
657
-					delete_option( $transient_timeout );
652
+			if ( ! isset($alloptions[$transient_option])) {
653
+				$transient_timeout = '_transient_timeout_'.$transient;
654
+				$timeout = get_option($transient_timeout);
655
+				if (false !== $timeout && $timeout < time()) {
656
+					delete_option($transient_option);
657
+					delete_option($transient_timeout);
658 658
 					$value = false;
659 659
 				}
660 660
 			}
661 661
 		}
662 662
 
663
-		if ( ! isset( $value ) )
664
-			$value = get_option( $transient_option );
663
+		if ( ! isset($value))
664
+			$value = get_option($transient_option);
665 665
 	}
666 666
 
667 667
 	/**
@@ -675,7 +675,7 @@  discard block
 block discarded – undo
675 675
 	 * @param mixed  $value     Value of transient.
676 676
 	 * @param string $transient Transient name.
677 677
 	 */
678
-	return apply_filters( "transient_{$transient}", $value, $transient );
678
+	return apply_filters("transient_{$transient}", $value, $transient);
679 679
 }
680 680
 
681 681
 /**
@@ -693,7 +693,7 @@  discard block
 block discarded – undo
693 693
  * @param int    $expiration Optional. Time until expiration in seconds. Default 0 (no expiration).
694 694
  * @return bool False if value was not set and true if value was set.
695 695
  */
696
-function set_transient( $transient, $value, $expiration = 0 ) {
696
+function set_transient($transient, $value, $expiration = 0) {
697 697
 
698 698
 	$expiration = (int) $expiration;
699 699
 
@@ -710,7 +710,7 @@  discard block
 block discarded – undo
710 710
 	 * @param int    $expiration Time until expiration in seconds.
711 711
 	 * @param string $transient  Transient name.
712 712
 	 */
713
-	$value = apply_filters( "pre_set_transient_{$transient}", $value, $expiration, $transient );
713
+	$value = apply_filters("pre_set_transient_{$transient}", $value, $expiration, $transient);
714 714
 
715 715
 	/**
716 716
 	 * Filters the expiration for a transient before its value is set.
@@ -723,41 +723,41 @@  discard block
 block discarded – undo
723 723
 	 * @param mixed  $value      New value of transient.
724 724
 	 * @param string $transient  Transient name.
725 725
 	 */
726
-	$expiration = apply_filters( "expiration_of_transient_{$transient}", $expiration, $value, $transient );
726
+	$expiration = apply_filters("expiration_of_transient_{$transient}", $expiration, $value, $transient);
727 727
 
728
-	if ( wp_using_ext_object_cache() ) {
729
-		$result = wp_cache_set( $transient, $value, 'transient', $expiration );
728
+	if (wp_using_ext_object_cache()) {
729
+		$result = wp_cache_set($transient, $value, 'transient', $expiration);
730 730
 	} else {
731
-		$transient_timeout = '_transient_timeout_' . $transient;
732
-		$transient_option = '_transient_' . $transient;
733
-		if ( false === get_option( $transient_option ) ) {
731
+		$transient_timeout = '_transient_timeout_'.$transient;
732
+		$transient_option = '_transient_'.$transient;
733
+		if (false === get_option($transient_option)) {
734 734
 			$autoload = 'yes';
735
-			if ( $expiration ) {
735
+			if ($expiration) {
736 736
 				$autoload = 'no';
737
-				add_option( $transient_timeout, time() + $expiration, '', 'no' );
737
+				add_option($transient_timeout, time() + $expiration, '', 'no');
738 738
 			}
739
-			$result = add_option( $transient_option, $value, '', $autoload );
739
+			$result = add_option($transient_option, $value, '', $autoload);
740 740
 		} else {
741 741
 			// If expiration is requested, but the transient has no timeout option,
742 742
 			// delete, then re-create transient rather than update.
743 743
 			$update = true;
744
-			if ( $expiration ) {
745
-				if ( false === get_option( $transient_timeout ) ) {
746
-					delete_option( $transient_option );
747
-					add_option( $transient_timeout, time() + $expiration, '', 'no' );
748
-					$result = add_option( $transient_option, $value, '', 'no' );
744
+			if ($expiration) {
745
+				if (false === get_option($transient_timeout)) {
746
+					delete_option($transient_option);
747
+					add_option($transient_timeout, time() + $expiration, '', 'no');
748
+					$result = add_option($transient_option, $value, '', 'no');
749 749
 					$update = false;
750 750
 				} else {
751
-					update_option( $transient_timeout, time() + $expiration );
751
+					update_option($transient_timeout, time() + $expiration);
752 752
 				}
753 753
 			}
754
-			if ( $update ) {
755
-				$result = update_option( $transient_option, $value );
754
+			if ($update) {
755
+				$result = update_option($transient_option, $value);
756 756
 			}
757 757
 		}
758 758
 	}
759 759
 
760
-	if ( $result ) {
760
+	if ($result) {
761 761
 
762 762
 		/**
763 763
 		 * Fires after the value for a specific transient has been set.
@@ -772,7 +772,7 @@  discard block
 block discarded – undo
772 772
 		 * @param int    $expiration Time until expiration in seconds.
773 773
 		 * @param string $transient  The name of the transient.
774 774
 		 */
775
-		do_action( "set_transient_{$transient}", $value, $expiration, $transient );
775
+		do_action("set_transient_{$transient}", $value, $expiration, $transient);
776 776
 
777 777
 		/**
778 778
 		 * Fires after the value for a transient has been set.
@@ -784,7 +784,7 @@  discard block
 block discarded – undo
784 784
 		 * @param mixed  $value      Transient value.
785 785
 		 * @param int    $expiration Time until expiration in seconds.
786 786
 		 */
787
-		do_action( 'setted_transient', $transient, $value, $expiration );
787
+		do_action('setted_transient', $transient, $value, $expiration);
788 788
 	}
789 789
 	return $result;
790 790
 }
@@ -800,43 +800,43 @@  discard block
 block discarded – undo
800 800
  */
801 801
 function wp_user_settings() {
802 802
 
803
-	if ( ! is_admin() || wp_doing_ajax() ) {
803
+	if ( ! is_admin() || wp_doing_ajax()) {
804 804
 		return;
805 805
 	}
806 806
 
807
-	if ( ! $user_id = get_current_user_id() ) {
807
+	if ( ! $user_id = get_current_user_id()) {
808 808
 		return;
809 809
 	}
810 810
 
811
-	if ( ! is_user_member_of_blog() ) {
811
+	if ( ! is_user_member_of_blog()) {
812 812
 		return;
813 813
 	}
814 814
 
815
-	$settings = (string) get_user_option( 'user-settings', $user_id );
815
+	$settings = (string) get_user_option('user-settings', $user_id);
816 816
 
817
-	if ( isset( $_COOKIE['wp-settings-' . $user_id] ) ) {
818
-		$cookie = preg_replace( '/[^A-Za-z0-9=&_]/', '', $_COOKIE['wp-settings-' . $user_id] );
817
+	if (isset($_COOKIE['wp-settings-'.$user_id])) {
818
+		$cookie = preg_replace('/[^A-Za-z0-9=&_]/', '', $_COOKIE['wp-settings-'.$user_id]);
819 819
 
820 820
 		// No change or both empty
821
-		if ( $cookie == $settings )
821
+		if ($cookie == $settings)
822 822
 			return;
823 823
 
824
-		$last_saved = (int) get_user_option( 'user-settings-time', $user_id );
825
-		$current = isset( $_COOKIE['wp-settings-time-' . $user_id]) ? preg_replace( '/[^0-9]/', '', $_COOKIE['wp-settings-time-' . $user_id] ) : 0;
824
+		$last_saved = (int) get_user_option('user-settings-time', $user_id);
825
+		$current = isset($_COOKIE['wp-settings-time-'.$user_id]) ? preg_replace('/[^0-9]/', '', $_COOKIE['wp-settings-time-'.$user_id]) : 0;
826 826
 
827 827
 		// The cookie is newer than the saved value. Update the user_option and leave the cookie as-is
828
-		if ( $current > $last_saved ) {
829
-			update_user_option( $user_id, 'user-settings', $cookie, false );
830
-			update_user_option( $user_id, 'user-settings-time', time() - 5, false );
828
+		if ($current > $last_saved) {
829
+			update_user_option($user_id, 'user-settings', $cookie, false);
830
+			update_user_option($user_id, 'user-settings-time', time() - 5, false);
831 831
 			return;
832 832
 		}
833 833
 	}
834 834
 
835 835
 	// The cookie is not set in the current browser or the saved value is newer.
836
-	$secure = ( 'https' === parse_url( admin_url(), PHP_URL_SCHEME ) );
837
-	setcookie( 'wp-settings-' . $user_id, $settings, time() + YEAR_IN_SECONDS, SITECOOKIEPATH, null, $secure );
838
-	setcookie( 'wp-settings-time-' . $user_id, time(), time() + YEAR_IN_SECONDS, SITECOOKIEPATH, null, $secure );
839
-	$_COOKIE['wp-settings-' . $user_id] = $settings;
836
+	$secure = ('https' === parse_url(admin_url(), PHP_URL_SCHEME));
837
+	setcookie('wp-settings-'.$user_id, $settings, time() + YEAR_IN_SECONDS, SITECOOKIEPATH, null, $secure);
838
+	setcookie('wp-settings-time-'.$user_id, time(), time() + YEAR_IN_SECONDS, SITECOOKIEPATH, null, $secure);
839
+	$_COOKIE['wp-settings-'.$user_id] = $settings;
840 840
 }
841 841
 
842 842
 /**
@@ -848,10 +848,10 @@  discard block
 block discarded – undo
848 848
  * @param string $default Optional default value to return when $name is not set.
849 849
  * @return mixed the last saved user setting or the default value/false if it doesn't exist.
850 850
  */
851
-function get_user_setting( $name, $default = false ) {
851
+function get_user_setting($name, $default = false) {
852 852
 	$all_user_settings = get_all_user_settings();
853 853
 
854
-	return isset( $all_user_settings[$name] ) ? $all_user_settings[$name] : $default;
854
+	return isset($all_user_settings[$name]) ? $all_user_settings[$name] : $default;
855 855
 }
856 856
 
857 857
 /**
@@ -867,15 +867,15 @@  discard block
 block discarded – undo
867 867
  * @param string $value The value for the setting.
868 868
  * @return bool|null True if set successfully, false if not. Null if the current user can't be established.
869 869
  */
870
-function set_user_setting( $name, $value ) {
871
-	if ( headers_sent() ) {
870
+function set_user_setting($name, $value) {
871
+	if (headers_sent()) {
872 872
 		return false;
873 873
 	}
874 874
 
875 875
 	$all_user_settings = get_all_user_settings();
876 876
 	$all_user_settings[$name] = $value;
877 877
 
878
-	return wp_set_all_user_settings( $all_user_settings );
878
+	return wp_set_all_user_settings($all_user_settings);
879 879
 }
880 880
 
881 881
 /**
@@ -890,8 +890,8 @@  discard block
 block discarded – undo
890 890
  * @param string $names The name or array of names of the setting to be deleted.
891 891
  * @return bool|null True if deleted successfully, false if not. Null if the current user can't be established.
892 892
  */
893
-function delete_user_setting( $names ) {
894
-	if ( headers_sent() ) {
893
+function delete_user_setting($names) {
894
+	if (headers_sent()) {
895 895
 		return false;
896 896
 	}
897 897
 
@@ -899,15 +899,15 @@  discard block
 block discarded – undo
899 899
 	$names = (array) $names;
900 900
 	$deleted = false;
901 901
 
902
-	foreach ( $names as $name ) {
903
-		if ( isset( $all_user_settings[$name] ) ) {
904
-			unset( $all_user_settings[$name] );
902
+	foreach ($names as $name) {
903
+		if (isset($all_user_settings[$name])) {
904
+			unset($all_user_settings[$name]);
905 905
 			$deleted = true;
906 906
 		}
907 907
 	}
908 908
 
909
-	if ( $deleted ) {
910
-		return wp_set_all_user_settings( $all_user_settings );
909
+	if ($deleted) {
910
+		return wp_set_all_user_settings($all_user_settings);
911 911
 	}
912 912
 
913 913
 	return false;
@@ -925,27 +925,27 @@  discard block
 block discarded – undo
925 925
 function get_all_user_settings() {
926 926
 	global $_updated_user_settings;
927 927
 
928
-	if ( ! $user_id = get_current_user_id() ) {
928
+	if ( ! $user_id = get_current_user_id()) {
929 929
 		return array();
930 930
 	}
931 931
 
932
-	if ( isset( $_updated_user_settings ) && is_array( $_updated_user_settings ) ) {
932
+	if (isset($_updated_user_settings) && is_array($_updated_user_settings)) {
933 933
 		return $_updated_user_settings;
934 934
 	}
935 935
 
936 936
 	$user_settings = array();
937 937
 
938
-	if ( isset( $_COOKIE['wp-settings-' . $user_id] ) ) {
939
-		$cookie = preg_replace( '/[^A-Za-z0-9=&_-]/', '', $_COOKIE['wp-settings-' . $user_id] );
938
+	if (isset($_COOKIE['wp-settings-'.$user_id])) {
939
+		$cookie = preg_replace('/[^A-Za-z0-9=&_-]/', '', $_COOKIE['wp-settings-'.$user_id]);
940 940
 
941
-		if ( strpos( $cookie, '=' ) ) { // '=' cannot be 1st char
942
-			parse_str( $cookie, $user_settings );
941
+		if (strpos($cookie, '=')) { // '=' cannot be 1st char
942
+			parse_str($cookie, $user_settings);
943 943
 		}
944 944
 	} else {
945
-		$option = get_user_option( 'user-settings', $user_id );
945
+		$option = get_user_option('user-settings', $user_id);
946 946
 
947
-		if ( $option && is_string( $option ) ) {
948
-			parse_str( $option, $user_settings );
947
+		if ($option && is_string($option)) {
948
+			parse_str($option, $user_settings);
949 949
 		}
950 950
 	}
951 951
 
@@ -965,32 +965,32 @@  discard block
 block discarded – undo
965 965
  * @return bool|null False if the current user can't be found, null if the current
966 966
  *                   user is not a super admin or a member of the site, otherwise true.
967 967
  */
968
-function wp_set_all_user_settings( $user_settings ) {
968
+function wp_set_all_user_settings($user_settings) {
969 969
 	global $_updated_user_settings;
970 970
 
971
-	if ( ! $user_id = get_current_user_id() ) {
971
+	if ( ! $user_id = get_current_user_id()) {
972 972
 		return false;
973 973
 	}
974 974
 
975
-	if ( ! is_user_member_of_blog() ) {
975
+	if ( ! is_user_member_of_blog()) {
976 976
 		return;
977 977
 	}
978 978
 
979 979
 	$settings = '';
980
-	foreach ( $user_settings as $name => $value ) {
981
-		$_name = preg_replace( '/[^A-Za-z0-9_-]+/', '', $name );
982
-		$_value = preg_replace( '/[^A-Za-z0-9_-]+/', '', $value );
980
+	foreach ($user_settings as $name => $value) {
981
+		$_name = preg_replace('/[^A-Za-z0-9_-]+/', '', $name);
982
+		$_value = preg_replace('/[^A-Za-z0-9_-]+/', '', $value);
983 983
 
984
-		if ( ! empty( $_name ) ) {
985
-			$settings .= $_name . '=' . $_value . '&';
984
+		if ( ! empty($_name)) {
985
+			$settings .= $_name.'='.$_value.'&';
986 986
 		}
987 987
 	}
988 988
 
989
-	$settings = rtrim( $settings, '&' );
990
-	parse_str( $settings, $_updated_user_settings );
989
+	$settings = rtrim($settings, '&');
990
+	parse_str($settings, $_updated_user_settings);
991 991
 
992
-	update_user_option( $user_id, 'user-settings', $settings, false );
993
-	update_user_option( $user_id, 'user-settings-time', time(), false );
992
+	update_user_option($user_id, 'user-settings', $settings, false);
993
+	update_user_option($user_id, 'user-settings-time', time(), false);
994 994
 
995 995
 	return true;
996 996
 }
@@ -1001,12 +1001,12 @@  discard block
 block discarded – undo
1001 1001
  * @since 2.7.0
1002 1002
  */
1003 1003
 function delete_all_user_settings() {
1004
-	if ( ! $user_id = get_current_user_id() ) {
1004
+	if ( ! $user_id = get_current_user_id()) {
1005 1005
 		return;
1006 1006
 	}
1007 1007
 
1008
-	update_user_option( $user_id, 'user-settings', '', false );
1009
-	setcookie( 'wp-settings-' . $user_id, ' ', time() - YEAR_IN_SECONDS, SITECOOKIEPATH );
1008
+	update_user_option($user_id, 'user-settings', '', false);
1009
+	setcookie('wp-settings-'.$user_id, ' ', time() - YEAR_IN_SECONDS, SITECOOKIEPATH);
1010 1010
 }
1011 1011
 
1012 1012
 /**
@@ -1023,8 +1023,8 @@  discard block
 block discarded – undo
1023 1023
  * @param bool   $deprecated Whether to use cache. Multisite only. Always set to true.
1024 1024
  * @return mixed Value set for the option.
1025 1025
  */
1026
-function get_site_option( $option, $default = false, $deprecated = true ) {
1027
-	return get_network_option( null, $option, $default );
1026
+function get_site_option($option, $default = false, $deprecated = true) {
1027
+	return get_network_option(null, $option, $default);
1028 1028
 }
1029 1029
 
1030 1030
 /**
@@ -1041,8 +1041,8 @@  discard block
 block discarded – undo
1041 1041
  * @param mixed  $value  Option value, can be anything. Expected to not be SQL-escaped.
1042 1042
  * @return bool False if the option was not added. True if the option was added.
1043 1043
  */
1044
-function add_site_option( $option, $value ) {
1045
-	return add_network_option( null, $option, $value );
1044
+function add_site_option($option, $value) {
1045
+	return add_network_option(null, $option, $value);
1046 1046
 }
1047 1047
 
1048 1048
 /**
@@ -1056,8 +1056,8 @@  discard block
 block discarded – undo
1056 1056
  * @param string $option Name of option to remove. Expected to not be SQL-escaped.
1057 1057
  * @return bool True, if succeed. False, if failure.
1058 1058
  */
1059
-function delete_site_option( $option ) {
1060
-	return delete_network_option( null, $option );
1059
+function delete_site_option($option) {
1060
+	return delete_network_option(null, $option);
1061 1061
 }
1062 1062
 
1063 1063
 /**
@@ -1072,8 +1072,8 @@  discard block
 block discarded – undo
1072 1072
  * @param mixed  $value  Option value. Expected to not be SQL-escaped.
1073 1073
  * @return bool False if value was not updated. True if value was updated.
1074 1074
  */
1075
-function update_site_option( $option, $value ) {
1076
-	return update_network_option( null, $option, $value );
1075
+function update_site_option($option, $value) {
1076
+	return update_network_option(null, $option, $value);
1077 1077
 }
1078 1078
 
1079 1079
 /**
@@ -1090,17 +1090,17 @@  discard block
 block discarded – undo
1090 1090
  * @param mixed    $default    Optional. Value to return if the option doesn't exist. Default false.
1091 1091
  * @return mixed Value set for the option.
1092 1092
  */
1093
-function get_network_option( $network_id, $option, $default = false ) {
1093
+function get_network_option($network_id, $option, $default = false) {
1094 1094
 	global $wpdb;
1095 1095
 
1096
-	if ( $network_id && ! is_numeric( $network_id ) ) {
1096
+	if ($network_id && ! is_numeric($network_id)) {
1097 1097
 		return false;
1098 1098
 	}
1099 1099
 
1100 1100
 	$network_id = (int) $network_id;
1101 1101
 
1102 1102
 	// Fallback to the current network if a network ID is not specified.
1103
-	if ( ! $network_id ) {
1103
+	if ( ! $network_id) {
1104 1104
 		$network_id = get_current_network_id();
1105 1105
 	}
1106 1106
 
@@ -1121,17 +1121,17 @@  discard block
 block discarded – undo
1121 1121
 	 * @param string $option     Option name.
1122 1122
 	 * @param int    $network_id ID of the network.
1123 1123
 	 */
1124
-	$pre = apply_filters( "pre_site_option_{$option}", false, $option, $network_id );
1124
+	$pre = apply_filters("pre_site_option_{$option}", false, $option, $network_id);
1125 1125
 
1126
-	if ( false !== $pre ) {
1126
+	if (false !== $pre) {
1127 1127
 		return $pre;
1128 1128
 	}
1129 1129
 
1130 1130
 	// prevent non-existent options from triggering multiple queries
1131 1131
 	$notoptions_key = "$network_id:notoptions";
1132
-	$notoptions = wp_cache_get( $notoptions_key, 'site-options' );
1132
+	$notoptions = wp_cache_get($notoptions_key, 'site-options');
1133 1133
 
1134
-	if ( isset( $notoptions[ $option ] ) ) {
1134
+	if (isset($notoptions[$option])) {
1135 1135
 
1136 1136
 		/**
1137 1137
 		 * Filters a specific default network option.
@@ -1147,34 +1147,34 @@  discard block
 block discarded – undo
1147 1147
 		 * @param string $option     Option name.
1148 1148
 		 * @param int    $network_id ID of the network.
1149 1149
 		 */
1150
-		return apply_filters( "default_site_option_{$option}", $default, $option, $network_id );
1150
+		return apply_filters("default_site_option_{$option}", $default, $option, $network_id);
1151 1151
 	}
1152 1152
 
1153
-	if ( ! is_multisite() ) {
1153
+	if ( ! is_multisite()) {
1154 1154
 		/** This filter is documented in wp-includes/option.php */
1155
-		$default = apply_filters( 'default_site_option_' . $option, $default, $option, $network_id );
1156
-		$value = get_option( $option, $default );
1155
+		$default = apply_filters('default_site_option_'.$option, $default, $option, $network_id);
1156
+		$value = get_option($option, $default);
1157 1157
 	} else {
1158 1158
 		$cache_key = "$network_id:$option";
1159
-		$value = wp_cache_get( $cache_key, 'site-options' );
1159
+		$value = wp_cache_get($cache_key, 'site-options');
1160 1160
 
1161
-		if ( ! isset( $value ) || false === $value ) {
1162
-			$row = $wpdb->get_row( $wpdb->prepare( "SELECT meta_value FROM $wpdb->sitemeta WHERE meta_key = %s AND site_id = %d", $option, $network_id ) );
1161
+		if ( ! isset($value) || false === $value) {
1162
+			$row = $wpdb->get_row($wpdb->prepare("SELECT meta_value FROM $wpdb->sitemeta WHERE meta_key = %s AND site_id = %d", $option, $network_id));
1163 1163
 
1164 1164
 			// Has to be get_row instead of get_var because of funkiness with 0, false, null values
1165
-			if ( is_object( $row ) ) {
1165
+			if (is_object($row)) {
1166 1166
 				$value = $row->meta_value;
1167
-				$value = maybe_unserialize( $value );
1168
-				wp_cache_set( $cache_key, $value, 'site-options' );
1167
+				$value = maybe_unserialize($value);
1168
+				wp_cache_set($cache_key, $value, 'site-options');
1169 1169
 			} else {
1170
-				if ( ! is_array( $notoptions ) ) {
1170
+				if ( ! is_array($notoptions)) {
1171 1171
 					$notoptions = array();
1172 1172
 				}
1173
-				$notoptions[ $option ] = true;
1174
-				wp_cache_set( $notoptions_key, $notoptions, 'site-options' );
1173
+				$notoptions[$option] = true;
1174
+				wp_cache_set($notoptions_key, $notoptions, 'site-options');
1175 1175
 
1176 1176
 				/** This filter is documented in wp-includes/option.php */
1177
-				$value = apply_filters( 'default_site_option_' . $option, $default, $option, $network_id );
1177
+				$value = apply_filters('default_site_option_'.$option, $default, $option, $network_id);
1178 1178
 			}
1179 1179
 		}
1180 1180
 	}
@@ -1193,7 +1193,7 @@  discard block
 block discarded – undo
1193 1193
 	 * @param string $option     Option name.
1194 1194
 	 * @param int    $network_id ID of the network.
1195 1195
 	 */
1196
-	return apply_filters( "site_option_{$option}", $value, $option, $network_id );
1196
+	return apply_filters("site_option_{$option}", $value, $option, $network_id);
1197 1197
 }
1198 1198
 
1199 1199
 /**
@@ -1212,21 +1212,21 @@  discard block
 block discarded – undo
1212 1212
  * @param mixed  $value      Option value, can be anything. Expected to not be SQL-escaped.
1213 1213
  * @return bool False if option was not added and true if option was added.
1214 1214
  */
1215
-function add_network_option( $network_id, $option, $value ) {
1215
+function add_network_option($network_id, $option, $value) {
1216 1216
 	global $wpdb;
1217 1217
 
1218
-	if ( $network_id && ! is_numeric( $network_id ) ) {
1218
+	if ($network_id && ! is_numeric($network_id)) {
1219 1219
 		return false;
1220 1220
 	}
1221 1221
 
1222 1222
 	$network_id = (int) $network_id;
1223 1223
 
1224 1224
 	// Fallback to the current network if a network ID is not specified.
1225
-	if ( ! $network_id ) {
1225
+	if ( ! $network_id) {
1226 1226
 		$network_id = get_current_network_id();
1227 1227
 	}
1228 1228
 
1229
-	wp_protect_special_option( $option );
1229
+	wp_protect_special_option($option);
1230 1230
 
1231 1231
 	/**
1232 1232
 	 * Filters the value of a specific network option before it is added.
@@ -1242,43 +1242,43 @@  discard block
 block discarded – undo
1242 1242
 	 * @param string $option     Option name.
1243 1243
 	 * @param int    $network_id ID of the network.
1244 1244
 	 */
1245
-	$value = apply_filters( "pre_add_site_option_{$option}", $value, $option, $network_id );
1245
+	$value = apply_filters("pre_add_site_option_{$option}", $value, $option, $network_id);
1246 1246
 
1247 1247
 	$notoptions_key = "$network_id:notoptions";
1248 1248
 
1249
-	if ( ! is_multisite() ) {
1250
-		$result = add_option( $option, $value, '', 'no' );
1249
+	if ( ! is_multisite()) {
1250
+		$result = add_option($option, $value, '', 'no');
1251 1251
 	} else {
1252 1252
 		$cache_key = "$network_id:$option";
1253 1253
 
1254 1254
 		// Make sure the option doesn't already exist. We can check the 'notoptions' cache before we ask for a db query
1255
-		$notoptions = wp_cache_get( $notoptions_key, 'site-options' );
1256
-		if ( ! is_array( $notoptions ) || ! isset( $notoptions[ $option ] ) ) {
1257
-			if ( false !== get_network_option( $network_id, $option, false ) ) {
1255
+		$notoptions = wp_cache_get($notoptions_key, 'site-options');
1256
+		if ( ! is_array($notoptions) || ! isset($notoptions[$option])) {
1257
+			if (false !== get_network_option($network_id, $option, false)) {
1258 1258
 				return false;
1259 1259
 			}
1260 1260
 		}
1261 1261
 
1262
-		$value = sanitize_option( $option, $value );
1262
+		$value = sanitize_option($option, $value);
1263 1263
 
1264
-		$serialized_value = maybe_serialize( $value );
1265
-		$result = $wpdb->insert( $wpdb->sitemeta, array( 'site_id'    => $network_id, 'meta_key'   => $option, 'meta_value' => $serialized_value ) );
1264
+		$serialized_value = maybe_serialize($value);
1265
+		$result = $wpdb->insert($wpdb->sitemeta, array('site_id'    => $network_id, 'meta_key'   => $option, 'meta_value' => $serialized_value));
1266 1266
 
1267
-		if ( ! $result ) {
1267
+		if ( ! $result) {
1268 1268
 			return false;
1269 1269
 		}
1270 1270
 
1271
-		wp_cache_set( $cache_key, $value, 'site-options' );
1271
+		wp_cache_set($cache_key, $value, 'site-options');
1272 1272
 
1273 1273
 		// This option exists now
1274
-		$notoptions = wp_cache_get( $notoptions_key, 'site-options' ); // yes, again... we need it to be fresh
1275
-		if ( is_array( $notoptions ) && isset( $notoptions[ $option ] ) ) {
1276
-			unset( $notoptions[ $option ] );
1277
-			wp_cache_set( $notoptions_key, $notoptions, 'site-options' );
1274
+		$notoptions = wp_cache_get($notoptions_key, 'site-options'); // yes, again... we need it to be fresh
1275
+		if (is_array($notoptions) && isset($notoptions[$option])) {
1276
+			unset($notoptions[$option]);
1277
+			wp_cache_set($notoptions_key, $notoptions, 'site-options');
1278 1278
 		}
1279 1279
 	}
1280 1280
 
1281
-	if ( $result ) {
1281
+	if ($result) {
1282 1282
 
1283 1283
 		/**
1284 1284
 		 * Fires after a specific network option has been successfully added.
@@ -1293,7 +1293,7 @@  discard block
 block discarded – undo
1293 1293
 		 * @param mixed  $value      Value of the network option.
1294 1294
 		 * @param int    $network_id ID of the network.
1295 1295
 		 */
1296
-		do_action( "add_site_option_{$option}", $option, $value, $network_id );
1296
+		do_action("add_site_option_{$option}", $option, $value, $network_id);
1297 1297
 
1298 1298
 		/**
1299 1299
 		 * Fires after a network option has been successfully added.
@@ -1305,7 +1305,7 @@  discard block
 block discarded – undo
1305 1305
 		 * @param mixed  $value      Value of the network option.
1306 1306
 		 * @param int    $network_id ID of the network.
1307 1307
 		 */
1308
-		do_action( 'add_site_option', $option, $value, $network_id );
1308
+		do_action('add_site_option', $option, $value, $network_id);
1309 1309
 
1310 1310
 		return true;
1311 1311
 	}
@@ -1326,17 +1326,17 @@  discard block
 block discarded – undo
1326 1326
  * @param string $option     Name of option to remove. Expected to not be SQL-escaped.
1327 1327
  * @return bool True, if succeed. False, if failure.
1328 1328
  */
1329
-function delete_network_option( $network_id, $option ) {
1329
+function delete_network_option($network_id, $option) {
1330 1330
 	global $wpdb;
1331 1331
 
1332
-	if ( $network_id && ! is_numeric( $network_id ) ) {
1332
+	if ($network_id && ! is_numeric($network_id)) {
1333 1333
 		return false;
1334 1334
 	}
1335 1335
 
1336 1336
 	$network_id = (int) $network_id;
1337 1337
 
1338 1338
 	// Fallback to the current network if a network ID is not specified.
1339
-	if ( ! $network_id ) {
1339
+	if ( ! $network_id) {
1340 1340
 		$network_id = get_current_network_id();
1341 1341
 	}
1342 1342
 
@@ -1352,22 +1352,22 @@  discard block
 block discarded – undo
1352 1352
 	 * @param string $option     Option name.
1353 1353
 	 * @param int    $network_id ID of the network.
1354 1354
 	 */
1355
-	do_action( "pre_delete_site_option_{$option}", $option, $network_id );
1355
+	do_action("pre_delete_site_option_{$option}", $option, $network_id);
1356 1356
 
1357
-	if ( ! is_multisite() ) {
1358
-		$result = delete_option( $option );
1357
+	if ( ! is_multisite()) {
1358
+		$result = delete_option($option);
1359 1359
 	} else {
1360
-		$row = $wpdb->get_row( $wpdb->prepare( "SELECT meta_id FROM {$wpdb->sitemeta} WHERE meta_key = %s AND site_id = %d", $option, $network_id ) );
1361
-		if ( is_null( $row ) || ! $row->meta_id ) {
1360
+		$row = $wpdb->get_row($wpdb->prepare("SELECT meta_id FROM {$wpdb->sitemeta} WHERE meta_key = %s AND site_id = %d", $option, $network_id));
1361
+		if (is_null($row) || ! $row->meta_id) {
1362 1362
 			return false;
1363 1363
 		}
1364 1364
 		$cache_key = "$network_id:$option";
1365
-		wp_cache_delete( $cache_key, 'site-options' );
1365
+		wp_cache_delete($cache_key, 'site-options');
1366 1366
 
1367
-		$result = $wpdb->delete( $wpdb->sitemeta, array( 'meta_key' => $option, 'site_id' => $network_id ) );
1367
+		$result = $wpdb->delete($wpdb->sitemeta, array('meta_key' => $option, 'site_id' => $network_id));
1368 1368
 	}
1369 1369
 
1370
-	if ( $result ) {
1370
+	if ($result) {
1371 1371
 
1372 1372
 		/**
1373 1373
 		 * Fires after a specific network option has been deleted.
@@ -1381,7 +1381,7 @@  discard block
 block discarded – undo
1381 1381
 		 * @param string $option     Name of the network option.
1382 1382
 		 * @param int    $network_id ID of the network.
1383 1383
 		 */
1384
-		do_action( "delete_site_option_{$option}", $option, $network_id );
1384
+		do_action("delete_site_option_{$option}", $option, $network_id);
1385 1385
 
1386 1386
 		/**
1387 1387
 		 * Fires after a network option has been deleted.
@@ -1392,7 +1392,7 @@  discard block
 block discarded – undo
1392 1392
 		 * @param string $option     Name of the network option.
1393 1393
 		 * @param int    $network_id ID of the network.
1394 1394
 		 */
1395
-		do_action( 'delete_site_option', $option, $network_id );
1395
+		do_action('delete_site_option', $option, $network_id);
1396 1396
 
1397 1397
 		return true;
1398 1398
 	}
@@ -1414,23 +1414,23 @@  discard block
 block discarded – undo
1414 1414
  * @param mixed    $value      Option value. Expected to not be SQL-escaped.
1415 1415
  * @return bool False if value was not updated and true if value was updated.
1416 1416
  */
1417
-function update_network_option( $network_id, $option, $value ) {
1417
+function update_network_option($network_id, $option, $value) {
1418 1418
 	global $wpdb;
1419 1419
 
1420
-	if ( $network_id && ! is_numeric( $network_id ) ) {
1420
+	if ($network_id && ! is_numeric($network_id)) {
1421 1421
 		return false;
1422 1422
 	}
1423 1423
 
1424 1424
 	$network_id = (int) $network_id;
1425 1425
 
1426 1426
 	// Fallback to the current network if a network ID is not specified.
1427
-	if ( ! $network_id ) {
1427
+	if ( ! $network_id) {
1428 1428
 		$network_id = get_current_network_id();
1429 1429
 	}
1430 1430
 
1431
-	wp_protect_special_option( $option );
1431
+	wp_protect_special_option($option);
1432 1432
 
1433
-	$old_value = get_network_option( $network_id, $option, false );
1433
+	$old_value = get_network_option($network_id, $option, false);
1434 1434
 
1435 1435
 	/**
1436 1436
 	 * Filters a specific network option before its value is updated.
@@ -1447,38 +1447,38 @@  discard block
 block discarded – undo
1447 1447
 	 * @param string $option     Option name.
1448 1448
 	 * @param int    $network_id ID of the network.
1449 1449
 	 */
1450
-	$value = apply_filters( "pre_update_site_option_{$option}", $value, $old_value, $option, $network_id );
1450
+	$value = apply_filters("pre_update_site_option_{$option}", $value, $old_value, $option, $network_id);
1451 1451
 
1452
-	if ( $value === $old_value ) {
1452
+	if ($value === $old_value) {
1453 1453
 		return false;
1454 1454
 	}
1455 1455
 
1456
-	if ( false === $old_value ) {
1457
-		return add_network_option( $network_id, $option, $value );
1456
+	if (false === $old_value) {
1457
+		return add_network_option($network_id, $option, $value);
1458 1458
 	}
1459 1459
 
1460 1460
 	$notoptions_key = "$network_id:notoptions";
1461
-	$notoptions = wp_cache_get( $notoptions_key, 'site-options' );
1462
-	if ( is_array( $notoptions ) && isset( $notoptions[ $option ] ) ) {
1463
-		unset( $notoptions[ $option ] );
1464
-		wp_cache_set( $notoptions_key, $notoptions, 'site-options' );
1461
+	$notoptions = wp_cache_get($notoptions_key, 'site-options');
1462
+	if (is_array($notoptions) && isset($notoptions[$option])) {
1463
+		unset($notoptions[$option]);
1464
+		wp_cache_set($notoptions_key, $notoptions, 'site-options');
1465 1465
 	}
1466 1466
 
1467
-	if ( ! is_multisite() ) {
1468
-		$result = update_option( $option, $value, 'no' );
1467
+	if ( ! is_multisite()) {
1468
+		$result = update_option($option, $value, 'no');
1469 1469
 	} else {
1470
-		$value = sanitize_option( $option, $value );
1470
+		$value = sanitize_option($option, $value);
1471 1471
 
1472
-		$serialized_value = maybe_serialize( $value );
1473
-		$result = $wpdb->update( $wpdb->sitemeta, array( 'meta_value' => $serialized_value ), array( 'site_id' => $network_id, 'meta_key' => $option ) );
1472
+		$serialized_value = maybe_serialize($value);
1473
+		$result = $wpdb->update($wpdb->sitemeta, array('meta_value' => $serialized_value), array('site_id' => $network_id, 'meta_key' => $option));
1474 1474
 
1475
-		if ( $result ) {
1475
+		if ($result) {
1476 1476
 			$cache_key = "$network_id:$option";
1477
-			wp_cache_set( $cache_key, $value, 'site-options' );
1477
+			wp_cache_set($cache_key, $value, 'site-options');
1478 1478
 		}
1479 1479
 	}
1480 1480
 
1481
-	if ( $result ) {
1481
+	if ($result) {
1482 1482
 
1483 1483
 		/**
1484 1484
 		 * Fires after the value of a specific network option has been successfully updated.
@@ -1494,7 +1494,7 @@  discard block
 block discarded – undo
1494 1494
 		 * @param mixed  $old_value  Old value of the network option.
1495 1495
 		 * @param int    $network_id ID of the network.
1496 1496
 		 */
1497
-		do_action( "update_site_option_{$option}", $option, $value, $old_value, $network_id );
1497
+		do_action("update_site_option_{$option}", $option, $value, $old_value, $network_id);
1498 1498
 
1499 1499
 		/**
1500 1500
 		 * Fires after the value of a network option has been successfully updated.
@@ -1507,7 +1507,7 @@  discard block
 block discarded – undo
1507 1507
 		 * @param mixed  $old_value  Old value of the network option.
1508 1508
 		 * @param int    $network_id ID of the network.
1509 1509
 		 */
1510
-		do_action( 'update_site_option', $option, $value, $old_value, $network_id );
1510
+		do_action('update_site_option', $option, $value, $old_value, $network_id);
1511 1511
 
1512 1512
 		return true;
1513 1513
 	}
@@ -1523,7 +1523,7 @@  discard block
 block discarded – undo
1523 1523
  * @param string $transient Transient name. Expected to not be SQL-escaped.
1524 1524
  * @return bool True if successful, false otherwise
1525 1525
  */
1526
-function delete_site_transient( $transient ) {
1526
+function delete_site_transient($transient) {
1527 1527
 
1528 1528
 	/**
1529 1529
 	 * Fires immediately before a specific site transient is deleted.
@@ -1534,18 +1534,18 @@  discard block
 block discarded – undo
1534 1534
 	 *
1535 1535
 	 * @param string $transient Transient name.
1536 1536
 	 */
1537
-	do_action( "delete_site_transient_{$transient}", $transient );
1537
+	do_action("delete_site_transient_{$transient}", $transient);
1538 1538
 
1539
-	if ( wp_using_ext_object_cache() ) {
1540
-		$result = wp_cache_delete( $transient, 'site-transient' );
1539
+	if (wp_using_ext_object_cache()) {
1540
+		$result = wp_cache_delete($transient, 'site-transient');
1541 1541
 	} else {
1542
-		$option_timeout = '_site_transient_timeout_' . $transient;
1543
-		$option = '_site_transient_' . $transient;
1544
-		$result = delete_site_option( $option );
1545
-		if ( $result )
1546
-			delete_site_option( $option_timeout );
1542
+		$option_timeout = '_site_transient_timeout_'.$transient;
1543
+		$option = '_site_transient_'.$transient;
1544
+		$result = delete_site_option($option);
1545
+		if ($result)
1546
+			delete_site_option($option_timeout);
1547 1547
 	}
1548
-	if ( $result ) {
1548
+	if ($result) {
1549 1549
 
1550 1550
 		/**
1551 1551
 		 * Fires after a transient is deleted.
@@ -1554,7 +1554,7 @@  discard block
 block discarded – undo
1554 1554
 		 *
1555 1555
 		 * @param string $transient Deleted transient name.
1556 1556
 		 */
1557
-		do_action( 'deleted_site_transient', $transient );
1557
+		do_action('deleted_site_transient', $transient);
1558 1558
 	}
1559 1559
 
1560 1560
 	return $result;
@@ -1573,7 +1573,7 @@  discard block
 block discarded – undo
1573 1573
  * @param string $transient Transient name. Expected to not be SQL-escaped.
1574 1574
  * @return mixed Value of transient.
1575 1575
  */
1576
-function get_site_transient( $transient ) {
1576
+function get_site_transient($transient) {
1577 1577
 
1578 1578
 	/**
1579 1579
 	 * Filters the value of an existing site transient.
@@ -1591,29 +1591,29 @@  discard block
 block discarded – undo
1591 1591
 	 *                                   of the transient, and return the returned value.
1592 1592
 	 * @param string $transient          Transient name.
1593 1593
 	 */
1594
-	$pre = apply_filters( "pre_site_transient_{$transient}", false, $transient );
1594
+	$pre = apply_filters("pre_site_transient_{$transient}", false, $transient);
1595 1595
 
1596
-	if ( false !== $pre )
1596
+	if (false !== $pre)
1597 1597
 		return $pre;
1598 1598
 
1599
-	if ( wp_using_ext_object_cache() ) {
1600
-		$value = wp_cache_get( $transient, 'site-transient' );
1599
+	if (wp_using_ext_object_cache()) {
1600
+		$value = wp_cache_get($transient, 'site-transient');
1601 1601
 	} else {
1602 1602
 		// Core transients that do not have a timeout. Listed here so querying timeouts can be avoided.
1603 1603
 		$no_timeout = array('update_core', 'update_plugins', 'update_themes');
1604
-		$transient_option = '_site_transient_' . $transient;
1605
-		if ( ! in_array( $transient, $no_timeout ) ) {
1606
-			$transient_timeout = '_site_transient_timeout_' . $transient;
1607
-			$timeout = get_site_option( $transient_timeout );
1608
-			if ( false !== $timeout && $timeout < time() ) {
1609
-				delete_site_option( $transient_option  );
1610
-				delete_site_option( $transient_timeout );
1604
+		$transient_option = '_site_transient_'.$transient;
1605
+		if ( ! in_array($transient, $no_timeout)) {
1606
+			$transient_timeout = '_site_transient_timeout_'.$transient;
1607
+			$timeout = get_site_option($transient_timeout);
1608
+			if (false !== $timeout && $timeout < time()) {
1609
+				delete_site_option($transient_option);
1610
+				delete_site_option($transient_timeout);
1611 1611
 				$value = false;
1612 1612
 			}
1613 1613
 		}
1614 1614
 
1615
-		if ( ! isset( $value ) )
1616
-			$value = get_site_option( $transient_option );
1615
+		if ( ! isset($value))
1616
+			$value = get_site_option($transient_option);
1617 1617
 	}
1618 1618
 
1619 1619
 	/**
@@ -1627,7 +1627,7 @@  discard block
 block discarded – undo
1627 1627
 	 * @param mixed  $value     Value of site transient.
1628 1628
 	 * @param string $transient Transient name.
1629 1629
 	 */
1630
-	return apply_filters( "site_transient_{$transient}", $value, $transient );
1630
+	return apply_filters("site_transient_{$transient}", $value, $transient);
1631 1631
 }
1632 1632
 
1633 1633
 /**
@@ -1646,7 +1646,7 @@  discard block
 block discarded – undo
1646 1646
  * @param int    $expiration Optional. Time until expiration in seconds. Default 0 (no expiration).
1647 1647
  * @return bool False if value was not set and true if value was set.
1648 1648
  */
1649
-function set_site_transient( $transient, $value, $expiration = 0 ) {
1649
+function set_site_transient($transient, $value, $expiration = 0) {
1650 1650
 
1651 1651
 	/**
1652 1652
 	 * Filters the value of a specific site transient before it is set.
@@ -1659,7 +1659,7 @@  discard block
 block discarded – undo
1659 1659
 	 * @param mixed  $value     New value of site transient.
1660 1660
 	 * @param string $transient Transient name.
1661 1661
 	 */
1662
-	$value = apply_filters( "pre_set_site_transient_{$transient}", $value, $transient );
1662
+	$value = apply_filters("pre_set_site_transient_{$transient}", $value, $transient);
1663 1663
 
1664 1664
 	$expiration = (int) $expiration;
1665 1665
 
@@ -1674,24 +1674,24 @@  discard block
 block discarded – undo
1674 1674
 	 * @param mixed  $value      New value of site transient.
1675 1675
 	 * @param string $transient  Transient name.
1676 1676
 	 */
1677
-	$expiration = apply_filters( "expiration_of_site_transient_{$transient}", $expiration, $value, $transient );
1677
+	$expiration = apply_filters("expiration_of_site_transient_{$transient}", $expiration, $value, $transient);
1678 1678
 
1679
-	if ( wp_using_ext_object_cache() ) {
1680
-		$result = wp_cache_set( $transient, $value, 'site-transient', $expiration );
1679
+	if (wp_using_ext_object_cache()) {
1680
+		$result = wp_cache_set($transient, $value, 'site-transient', $expiration);
1681 1681
 	} else {
1682
-		$transient_timeout = '_site_transient_timeout_' . $transient;
1683
-		$option = '_site_transient_' . $transient;
1684
-		if ( false === get_site_option( $option ) ) {
1685
-			if ( $expiration )
1686
-				add_site_option( $transient_timeout, time() + $expiration );
1687
-			$result = add_site_option( $option, $value );
1682
+		$transient_timeout = '_site_transient_timeout_'.$transient;
1683
+		$option = '_site_transient_'.$transient;
1684
+		if (false === get_site_option($option)) {
1685
+			if ($expiration)
1686
+				add_site_option($transient_timeout, time() + $expiration);
1687
+			$result = add_site_option($option, $value);
1688 1688
 		} else {
1689
-			if ( $expiration )
1690
-				update_site_option( $transient_timeout, time() + $expiration );
1691
-			$result = update_site_option( $option, $value );
1689
+			if ($expiration)
1690
+				update_site_option($transient_timeout, time() + $expiration);
1691
+			$result = update_site_option($option, $value);
1692 1692
 		}
1693 1693
 	}
1694
-	if ( $result ) {
1694
+	if ($result) {
1695 1695
 
1696 1696
 		/**
1697 1697
 		 * Fires after the value for a specific site transient has been set.
@@ -1705,7 +1705,7 @@  discard block
 block discarded – undo
1705 1705
 		 * @param int    $expiration Time until expiration in seconds.
1706 1706
 		 * @param string $transient  Transient name.
1707 1707
 		 */
1708
-		do_action( "set_site_transient_{$transient}", $value, $expiration, $transient );
1708
+		do_action("set_site_transient_{$transient}", $value, $expiration, $transient);
1709 1709
 
1710 1710
 		/**
1711 1711
 		 * Fires after the value for a site transient has been set.
@@ -1716,7 +1716,7 @@  discard block
 block discarded – undo
1716 1716
 		 * @param mixed  $value      Site transient value.
1717 1717
 		 * @param int    $expiration Time until expiration in seconds.
1718 1718
 		 */
1719
-		do_action( 'setted_site_transient', $transient, $value, $expiration );
1719
+		do_action('setted_site_transient', $transient, $value, $expiration);
1720 1720
 	}
1721 1721
 	return $result;
1722 1722
 }
@@ -1730,24 +1730,24 @@  discard block
 block discarded – undo
1730 1730
  * @since 4.7.0
1731 1731
  */
1732 1732
 function register_initial_settings() {
1733
-	register_setting( 'general', 'blogname', array(
1733
+	register_setting('general', 'blogname', array(
1734 1734
 		'show_in_rest' => array(
1735 1735
 			'name' => 'title',
1736 1736
 		),
1737 1737
 		'type'         => 'string',
1738
-		'description'  => __( 'Site title.' ),
1739
-	) );
1738
+		'description'  => __('Site title.'),
1739
+	));
1740 1740
 
1741
-	register_setting( 'general', 'blogdescription', array(
1741
+	register_setting('general', 'blogdescription', array(
1742 1742
 		'show_in_rest' => array(
1743 1743
 			'name' => 'description',
1744 1744
 		),
1745 1745
 		'type'         => 'string',
1746
-		'description'  => __( 'Site tagline.' ),
1747
-	) );
1746
+		'description'  => __('Site tagline.'),
1747
+	));
1748 1748
 
1749
-	if ( ! is_multisite() ) {
1750
-		register_setting( 'general', 'siteurl', array(
1749
+	if ( ! is_multisite()) {
1750
+		register_setting('general', 'siteurl', array(
1751 1751
 			'show_in_rest' => array(
1752 1752
 				'name'    => 'url',
1753 1753
 				'schema'  => array(
@@ -1755,12 +1755,12 @@  discard block
 block discarded – undo
1755 1755
 				),
1756 1756
 			),
1757 1757
 			'type'         => 'string',
1758
-			'description'  => __( 'Site URL.' ),
1759
-		) );
1758
+			'description'  => __('Site URL.'),
1759
+		));
1760 1760
 	}
1761 1761
 
1762
-	if ( ! is_multisite() ) {
1763
-		register_setting( 'general', 'admin_email', array(
1762
+	if ( ! is_multisite()) {
1763
+		register_setting('general', 'admin_email', array(
1764 1764
 			'show_in_rest' => array(
1765 1765
 				'name'    => 'email',
1766 1766
 				'schema'  => array(
@@ -1768,90 +1768,90 @@  discard block
 block discarded – undo
1768 1768
 				),
1769 1769
 			),
1770 1770
 			'type'         => 'string',
1771
-			'description'  => __( 'This address is used for admin purposes, like new user notification.' ),
1772
-		) );
1771
+			'description'  => __('This address is used for admin purposes, like new user notification.'),
1772
+		));
1773 1773
 	}
1774 1774
 
1775
-	register_setting( 'general', 'timezone_string', array(
1775
+	register_setting('general', 'timezone_string', array(
1776 1776
 		'show_in_rest' => array(
1777 1777
 			'name' => 'timezone',
1778 1778
 		),
1779 1779
 		'type'         => 'string',
1780
-		'description'  => __( 'A city in the same timezone as you.' ),
1781
-	) );
1780
+		'description'  => __('A city in the same timezone as you.'),
1781
+	));
1782 1782
 
1783
-	register_setting( 'general', 'date_format', array(
1783
+	register_setting('general', 'date_format', array(
1784 1784
 		'show_in_rest' => true,
1785 1785
 		'type'         => 'string',
1786
-		'description'  => __( 'A date format for all date strings.' ),
1787
-	) );
1786
+		'description'  => __('A date format for all date strings.'),
1787
+	));
1788 1788
 
1789
-	register_setting( 'general', 'time_format', array(
1789
+	register_setting('general', 'time_format', array(
1790 1790
 		'show_in_rest' => true,
1791 1791
 		'type'         => 'string',
1792
-		'description'  => __( 'A time format for all time strings.' ),
1793
-	) );
1792
+		'description'  => __('A time format for all time strings.'),
1793
+	));
1794 1794
 
1795
-	register_setting( 'general', 'start_of_week', array(
1795
+	register_setting('general', 'start_of_week', array(
1796 1796
 		'show_in_rest' => true,
1797 1797
 		'type'         => 'integer',
1798
-		'description'  => __( 'A day number of the week that the week should start on.' ),
1799
-	) );
1798
+		'description'  => __('A day number of the week that the week should start on.'),
1799
+	));
1800 1800
 
1801
-	register_setting( 'general', 'WPLANG', array(
1801
+	register_setting('general', 'WPLANG', array(
1802 1802
 		'show_in_rest' => array(
1803 1803
 			'name' => 'language',
1804 1804
 		),
1805 1805
 		'type'         => 'string',
1806
-		'description'  => __( 'WordPress locale code.' ),
1806
+		'description'  => __('WordPress locale code.'),
1807 1807
 		'default'      => 'en_US',
1808
-	) );
1808
+	));
1809 1809
 
1810
-	register_setting( 'writing', 'use_smilies', array(
1810
+	register_setting('writing', 'use_smilies', array(
1811 1811
 		'show_in_rest' => true,
1812 1812
 		'type'         => 'boolean',
1813
-		'description'  => __( 'Convert emoticons like :-) and :-P to graphics on display.' ),
1813
+		'description'  => __('Convert emoticons like :-) and :-P to graphics on display.'),
1814 1814
 		'default'      => true,
1815
-	) );
1815
+	));
1816 1816
 
1817
-	register_setting( 'writing', 'default_category', array(
1817
+	register_setting('writing', 'default_category', array(
1818 1818
 		'show_in_rest' => true,
1819 1819
 		'type'         => 'integer',
1820
-		'description'  => __( 'Default post category.' ),
1821
-	) );
1820
+		'description'  => __('Default post category.'),
1821
+	));
1822 1822
 
1823
-	register_setting( 'writing', 'default_post_format', array(
1823
+	register_setting('writing', 'default_post_format', array(
1824 1824
 		'show_in_rest' => true,
1825 1825
 		'type'         => 'string',
1826
-		'description'  => __( 'Default post format.' ),
1827
-	) );
1826
+		'description'  => __('Default post format.'),
1827
+	));
1828 1828
 
1829
-	register_setting( 'reading', 'posts_per_page', array(
1829
+	register_setting('reading', 'posts_per_page', array(
1830 1830
 		'show_in_rest' => true,
1831 1831
 		'type'         => 'integer',
1832
-		'description'  => __( 'Blog pages show at most.' ),
1832
+		'description'  => __('Blog pages show at most.'),
1833 1833
 		'default'      => 10,
1834
-	) );
1834
+	));
1835 1835
 
1836
-	register_setting( 'discussion', 'default_ping_status', array(
1836
+	register_setting('discussion', 'default_ping_status', array(
1837 1837
 		'show_in_rest' => array(
1838 1838
 			'schema'   => array(
1839
-				'enum' => array( 'open', 'closed' ),
1839
+				'enum' => array('open', 'closed'),
1840 1840
 			),
1841 1841
 		),
1842 1842
 		'type'         => 'string',
1843
-		'description'  => __( 'Allow link notifications from other blogs (pingbacks and trackbacks) on new articles.' ),
1844
-	) );
1843
+		'description'  => __('Allow link notifications from other blogs (pingbacks and trackbacks) on new articles.'),
1844
+	));
1845 1845
 
1846
-	register_setting( 'discussion', 'default_comment_status', array(
1846
+	register_setting('discussion', 'default_comment_status', array(
1847 1847
 		'show_in_rest' => array(
1848 1848
 			'schema'   => array(
1849
-				'enum' => array( 'open', 'closed' ),
1849
+				'enum' => array('open', 'closed'),
1850 1850
 			),
1851 1851
 		),
1852 1852
 		'type'         => 'string',
1853
-		'description'  => __( 'Allow people to post comments on new articles.' ),
1854
-	) );
1853
+		'description'  => __('Allow people to post comments on new articles.'),
1854
+	));
1855 1855
 
1856 1856
 }
1857 1857
 
@@ -1878,7 +1878,7 @@  discard block
 block discarded – undo
1878 1878
  *     @type mixed    $default           Default value when calling `get_option()`.
1879 1879
  * }
1880 1880
  */
1881
-function register_setting( $option_group, $option_name, $args = array() ) {
1881
+function register_setting($option_group, $option_name, $args = array()) {
1882 1882
 	global $new_whitelist_options, $wp_registered_settings;
1883 1883
 
1884 1884
 	$defaults = array(
@@ -1890,7 +1890,7 @@  discard block
 block discarded – undo
1890 1890
 	);
1891 1891
 
1892 1892
 	// Back-compat: old sanitize callback is added.
1893
-	if ( is_callable( $args ) ) {
1893
+	if (is_callable($args)) {
1894 1894
 		$args = array(
1895 1895
 			'sanitize_callback' => $args,
1896 1896
 		);
@@ -1906,42 +1906,42 @@  discard block
 block discarded – undo
1906 1906
 	 * @param string $option_group Setting group.
1907 1907
 	 * @param string $option_name  Setting name.
1908 1908
 	 */
1909
-	$args = apply_filters( 'register_setting_args', $args, $defaults, $option_group, $option_name );
1910
-	$args = wp_parse_args( $args, $defaults );
1909
+	$args = apply_filters('register_setting_args', $args, $defaults, $option_group, $option_name);
1910
+	$args = wp_parse_args($args, $defaults);
1911 1911
 
1912
-	if ( ! is_array( $wp_registered_settings ) ) {
1912
+	if ( ! is_array($wp_registered_settings)) {
1913 1913
 		$wp_registered_settings = array();
1914 1914
 	}
1915 1915
 
1916
-	if ( 'misc' == $option_group ) {
1917
-		_deprecated_argument( __FUNCTION__, '3.0.0',
1916
+	if ('misc' == $option_group) {
1917
+		_deprecated_argument(__FUNCTION__, '3.0.0',
1918 1918
 			/* translators: %s: misc */
1919
-			sprintf( __( 'The "%s" options group has been removed. Use another settings group.' ),
1919
+			sprintf(__('The "%s" options group has been removed. Use another settings group.'),
1920 1920
 				'misc'
1921 1921
 			)
1922 1922
 		);
1923 1923
 		$option_group = 'general';
1924 1924
 	}
1925 1925
 
1926
-	if ( 'privacy' == $option_group ) {
1927
-		_deprecated_argument( __FUNCTION__, '3.5.0',
1926
+	if ('privacy' == $option_group) {
1927
+		_deprecated_argument(__FUNCTION__, '3.5.0',
1928 1928
 			/* translators: %s: privacy */
1929
-			sprintf( __( 'The "%s" options group has been removed. Use another settings group.' ),
1929
+			sprintf(__('The "%s" options group has been removed. Use another settings group.'),
1930 1930
 				'privacy'
1931 1931
 			)
1932 1932
 		);
1933 1933
 		$option_group = 'reading';
1934 1934
 	}
1935 1935
 
1936
-	$new_whitelist_options[ $option_group ][] = $option_name;
1937
-	if ( ! empty( $args['sanitize_callback'] ) ) {
1938
-		add_filter( "sanitize_option_{$option_name}", $args['sanitize_callback'] );
1936
+	$new_whitelist_options[$option_group][] = $option_name;
1937
+	if ( ! empty($args['sanitize_callback'])) {
1938
+		add_filter("sanitize_option_{$option_name}", $args['sanitize_callback']);
1939 1939
 	}
1940
-	if ( array_key_exists( 'default', $args ) ) {
1941
-		add_filter( "default_option_{$option_name}", 'filter_default_option', 10, 3 );
1940
+	if (array_key_exists('default', $args)) {
1941
+		add_filter("default_option_{$option_name}", 'filter_default_option', 10, 3);
1942 1942
 	}
1943 1943
 
1944
-	$wp_registered_settings[ $option_name ] = $args;
1944
+	$wp_registered_settings[$option_name] = $args;
1945 1945
 }
1946 1946
 
1947 1947
 /**
@@ -1956,51 +1956,51 @@  discard block
 block discarded – undo
1956 1956
  * @param string   $option_name       The name of the option to unregister.
1957 1957
  * @param callable $deprecated        Deprecated.
1958 1958
  */
1959
-function unregister_setting( $option_group, $option_name, $deprecated = '' ) {
1959
+function unregister_setting($option_group, $option_name, $deprecated = '') {
1960 1960
 	global $new_whitelist_options, $wp_registered_settings;
1961 1961
 
1962
-	if ( 'misc' == $option_group ) {
1963
-		_deprecated_argument( __FUNCTION__, '3.0.0',
1962
+	if ('misc' == $option_group) {
1963
+		_deprecated_argument(__FUNCTION__, '3.0.0',
1964 1964
 			/* translators: %s: misc */
1965
-			sprintf( __( 'The "%s" options group has been removed. Use another settings group.' ),
1965
+			sprintf(__('The "%s" options group has been removed. Use another settings group.'),
1966 1966
 				'misc'
1967 1967
 			)
1968 1968
 		);
1969 1969
 		$option_group = 'general';
1970 1970
 	}
1971 1971
 
1972
-	if ( 'privacy' == $option_group ) {
1973
-		_deprecated_argument( __FUNCTION__, '3.5.0',
1972
+	if ('privacy' == $option_group) {
1973
+		_deprecated_argument(__FUNCTION__, '3.5.0',
1974 1974
 			/* translators: %s: privacy */
1975
-			sprintf( __( 'The "%s" options group has been removed. Use another settings group.' ),
1975
+			sprintf(__('The "%s" options group has been removed. Use another settings group.'),
1976 1976
 				'privacy'
1977 1977
 			)
1978 1978
 		);
1979 1979
 		$option_group = 'reading';
1980 1980
 	}
1981 1981
 
1982
-	$pos = array_search( $option_name, (array) $new_whitelist_options[ $option_group ] );
1983
-	if ( $pos !== false ) {
1984
-		unset( $new_whitelist_options[ $option_group ][ $pos ] );
1982
+	$pos = array_search($option_name, (array) $new_whitelist_options[$option_group]);
1983
+	if ($pos !== false) {
1984
+		unset($new_whitelist_options[$option_group][$pos]);
1985 1985
 	}
1986
-	if ( '' !== $deprecated ) {
1987
-		_deprecated_argument( __FUNCTION__, '4.7.0',
1986
+	if ('' !== $deprecated) {
1987
+		_deprecated_argument(__FUNCTION__, '4.7.0',
1988 1988
 			/* translators: 1: $sanitize_callback, 2: register_setting() */
1989
-			sprintf( __( '%1$s is deprecated. The callback from %2$s is used instead.' ),
1989
+			sprintf(__('%1$s is deprecated. The callback from %2$s is used instead.'),
1990 1990
 				'<code>$sanitize_callback</code>',
1991 1991
 				'<code>register_setting()</code>'
1992 1992
 			)
1993 1993
 		);
1994
-		remove_filter( "sanitize_option_{$option_name}", $deprecated );
1994
+		remove_filter("sanitize_option_{$option_name}", $deprecated);
1995 1995
 	}
1996 1996
 
1997
-	if ( isset( $wp_registered_settings[ $option_name ] ) ) {
1997
+	if (isset($wp_registered_settings[$option_name])) {
1998 1998
 		// Remove the sanitize callback if one was set during registration.
1999
-		if ( ! empty( $wp_registered_settings[ $option_name ]['sanitize_callback'] ) ) {
2000
-			remove_filter( "sanitize_option_{$option_name}", $wp_registered_settings[ $option_name ]['sanitize_callback'] );
1999
+		if ( ! empty($wp_registered_settings[$option_name]['sanitize_callback'])) {
2000
+			remove_filter("sanitize_option_{$option_name}", $wp_registered_settings[$option_name]['sanitize_callback']);
2001 2001
 		}
2002 2002
 
2003
-		unset( $wp_registered_settings[ $option_name ] );
2003
+		unset($wp_registered_settings[$option_name]);
2004 2004
 	}
2005 2005
 }
2006 2006
 
@@ -2014,7 +2014,7 @@  discard block
 block discarded – undo
2014 2014
 function get_registered_settings() {
2015 2015
 	global $wp_registered_settings;
2016 2016
 
2017
-	if ( ! is_array( $wp_registered_settings ) ) {
2017
+	if ( ! is_array($wp_registered_settings)) {
2018 2018
 		return array();
2019 2019
 	}
2020 2020
 
@@ -2034,15 +2034,15 @@  discard block
 block discarded – undo
2034 2034
  * @param bool $passed_default Was `get_option()` passed a default value?
2035 2035
  * @return mixed Filtered default value.
2036 2036
  */
2037
-function filter_default_option( $default, $option, $passed_default ) {
2038
-	if ( $passed_default ) {
2037
+function filter_default_option($default, $option, $passed_default) {
2038
+	if ($passed_default) {
2039 2039
 		return $default;
2040 2040
 	}
2041 2041
 
2042 2042
 	$registered = get_registered_settings();
2043
-	if ( empty( $registered[ $option ] ) ) {
2043
+	if (empty($registered[$option])) {
2044 2044
 		return $default;
2045 2045
 	}
2046 2046
 
2047
-	return $registered[ $option ]['default'];
2047
+	return $registered[$option]['default'];
2048 2048
 }
Please login to merge, or discard this patch.
src/wp-includes/query.php 2 patches
Doc Comments   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -20,7 +20,7 @@  discard block
 block discarded – undo
20 20
  * @global WP_Query $wp_query Global WP_Query instance.
21 21
  *
22 22
  * @param string $var       The variable key to retrieve.
23
- * @param mixed  $default   Optional. Value to return if the query variable is not set. Default empty.
23
+ * @param integer  $default   Optional. Value to return if the query variable is not set. Default empty.
24 24
  * @return mixed Contents of the query variable.
25 25
  */
26 26
 function get_query_var( $var, $default = '' ) {
@@ -286,8 +286,8 @@  discard block
 block discarded – undo
286 286
  *
287 287
  * @global WP_Query $wp_query Global WP_Query instance.
288 288
  *
289
- * @param string|array     $taxonomy Optional. Taxonomy slug or slugs.
290
- * @param int|string|array $term     Optional. Term ID, name, slug or array of Term IDs, names, and slugs.
289
+ * @param string     $taxonomy Optional. Taxonomy slug or slugs.
290
+ * @param string $term     Optional. Term ID, name, slug or array of Term IDs, names, and slugs.
291 291
  * @return bool True for custom taxonomy archive pages, false for built-in taxonomies (category and tag archives).
292 292
  */
293 293
 function is_tax( $taxonomy = '', $term = '' ) {
Please login to merge, or discard this patch.
Spacing   +110 added lines, -110 removed lines patch added patch discarded remove patch
@@ -23,9 +23,9 @@  discard block
 block discarded – undo
23 23
  * @param mixed  $default   Optional. Value to return if the query variable is not set. Default empty.
24 24
  * @return mixed Contents of the query variable.
25 25
  */
26
-function get_query_var( $var, $default = '' ) {
26
+function get_query_var($var, $default = '') {
27 27
 	global $wp_query;
28
-	return $wp_query->get( $var, $default );
28
+	return $wp_query->get($var, $default);
29 29
 }
30 30
 
31 31
 /**
@@ -71,9 +71,9 @@  discard block
 block discarded – undo
71 71
  * @param string $var   Query variable key.
72 72
  * @param mixed  $value Query variable value.
73 73
  */
74
-function set_query_var( $var, $value ) {
74
+function set_query_var($var, $value) {
75 75
 	global $wp_query;
76
-	$wp_query->set( $var, $value );
76
+	$wp_query->set($var, $value);
77 77
 }
78 78
 
79 79
 /**
@@ -127,7 +127,7 @@  discard block
 block discarded – undo
127 127
 function wp_reset_postdata() {
128 128
 	global $wp_query;
129 129
 
130
-	if ( isset( $wp_query ) ) {
130
+	if (isset($wp_query)) {
131 131
 		$wp_query->reset_postdata();
132 132
 	}
133 133
 }
@@ -150,8 +150,8 @@  discard block
 block discarded – undo
150 150
 function is_archive() {
151 151
 	global $wp_query;
152 152
 
153
-	if ( ! isset( $wp_query ) ) {
154
-		_doing_it_wrong( __FUNCTION__, __( 'Conditional query tags do not work before the query is run. Before then, they always return false.' ), '3.1.0' );
153
+	if ( ! isset($wp_query)) {
154
+		_doing_it_wrong(__FUNCTION__, __('Conditional query tags do not work before the query is run. Before then, they always return false.'), '3.1.0');
155 155
 		return false;
156 156
 	}
157 157
 
@@ -168,15 +168,15 @@  discard block
 block discarded – undo
168 168
  * @param string|array $post_types Optional. Post type or array of posts types to check against.
169 169
  * @return bool
170 170
  */
171
-function is_post_type_archive( $post_types = '' ) {
171
+function is_post_type_archive($post_types = '') {
172 172
 	global $wp_query;
173 173
 
174
-	if ( ! isset( $wp_query ) ) {
175
-		_doing_it_wrong( __FUNCTION__, __( 'Conditional query tags do not work before the query is run. Before then, they always return false.' ), '3.1.0' );
174
+	if ( ! isset($wp_query)) {
175
+		_doing_it_wrong(__FUNCTION__, __('Conditional query tags do not work before the query is run. Before then, they always return false.'), '3.1.0');
176 176
 		return false;
177 177
 	}
178 178
 
179
-	return $wp_query->is_post_type_archive( $post_types );
179
+	return $wp_query->is_post_type_archive($post_types);
180 180
 }
181 181
 
182 182
 /**
@@ -189,15 +189,15 @@  discard block
 block discarded – undo
189 189
  * @param int|string|array|object $attachment Attachment ID, title, slug, or array of such.
190 190
  * @return bool
191 191
  */
192
-function is_attachment( $attachment = '' ) {
192
+function is_attachment($attachment = '') {
193 193
 	global $wp_query;
194 194
 
195
-	if ( ! isset( $wp_query ) ) {
196
-		_doing_it_wrong( __FUNCTION__, __( 'Conditional query tags do not work before the query is run. Before then, they always return false.' ), '3.1.0' );
195
+	if ( ! isset($wp_query)) {
196
+		_doing_it_wrong(__FUNCTION__, __('Conditional query tags do not work before the query is run. Before then, they always return false.'), '3.1.0');
197 197
 		return false;
198 198
 	}
199 199
 
200
-	return $wp_query->is_attachment( $attachment );
200
+	return $wp_query->is_attachment($attachment);
201 201
 }
202 202
 
203 203
 /**
@@ -213,15 +213,15 @@  discard block
 block discarded – undo
213 213
  * @param mixed $author Optional. User ID, nickname, nicename, or array of User IDs, nicknames, and nicenames
214 214
  * @return bool
215 215
  */
216
-function is_author( $author = '' ) {
216
+function is_author($author = '') {
217 217
 	global $wp_query;
218 218
 
219
-	if ( ! isset( $wp_query ) ) {
220
-		_doing_it_wrong( __FUNCTION__, __( 'Conditional query tags do not work before the query is run. Before then, they always return false.' ), '3.1.0' );
219
+	if ( ! isset($wp_query)) {
220
+		_doing_it_wrong(__FUNCTION__, __('Conditional query tags do not work before the query is run. Before then, they always return false.'), '3.1.0');
221 221
 		return false;
222 222
 	}
223 223
 
224
-	return $wp_query->is_author( $author );
224
+	return $wp_query->is_author($author);
225 225
 }
226 226
 
227 227
 /**
@@ -237,15 +237,15 @@  discard block
 block discarded – undo
237 237
  * @param mixed $category Optional. Category ID, name, slug, or array of Category IDs, names, and slugs.
238 238
  * @return bool
239 239
  */
240
-function is_category( $category = '' ) {
240
+function is_category($category = '') {
241 241
 	global $wp_query;
242 242
 
243
-	if ( ! isset( $wp_query ) ) {
244
-		_doing_it_wrong( __FUNCTION__, __( 'Conditional query tags do not work before the query is run. Before then, they always return false.' ), '3.1.0' );
243
+	if ( ! isset($wp_query)) {
244
+		_doing_it_wrong(__FUNCTION__, __('Conditional query tags do not work before the query is run. Before then, they always return false.'), '3.1.0');
245 245
 		return false;
246 246
 	}
247 247
 
248
-	return $wp_query->is_category( $category );
248
+	return $wp_query->is_category($category);
249 249
 }
250 250
 
251 251
 /**
@@ -261,15 +261,15 @@  discard block
 block discarded – undo
261 261
  * @param mixed $tag Optional. Tag ID, name, slug, or array of Tag IDs, names, and slugs.
262 262
  * @return bool
263 263
  */
264
-function is_tag( $tag = '' ) {
264
+function is_tag($tag = '') {
265 265
 	global $wp_query;
266 266
 
267
-	if ( ! isset( $wp_query ) ) {
268
-		_doing_it_wrong( __FUNCTION__, __( 'Conditional query tags do not work before the query is run. Before then, they always return false.' ), '3.1.0' );
267
+	if ( ! isset($wp_query)) {
268
+		_doing_it_wrong(__FUNCTION__, __('Conditional query tags do not work before the query is run. Before then, they always return false.'), '3.1.0');
269 269
 		return false;
270 270
 	}
271 271
 
272
-	return $wp_query->is_tag( $tag );
272
+	return $wp_query->is_tag($tag);
273 273
 }
274 274
 
275 275
 /**
@@ -290,15 +290,15 @@  discard block
 block discarded – undo
290 290
  * @param int|string|array $term     Optional. Term ID, name, slug or array of Term IDs, names, and slugs.
291 291
  * @return bool True for custom taxonomy archive pages, false for built-in taxonomies (category and tag archives).
292 292
  */
293
-function is_tax( $taxonomy = '', $term = '' ) {
293
+function is_tax($taxonomy = '', $term = '') {
294 294
 	global $wp_query;
295 295
 
296
-	if ( ! isset( $wp_query ) ) {
297
-		_doing_it_wrong( __FUNCTION__, __( 'Conditional query tags do not work before the query is run. Before then, they always return false.' ), '3.1.0' );
296
+	if ( ! isset($wp_query)) {
297
+		_doing_it_wrong(__FUNCTION__, __('Conditional query tags do not work before the query is run. Before then, they always return false.'), '3.1.0');
298 298
 		return false;
299 299
 	}
300 300
 
301
-	return $wp_query->is_tax( $taxonomy, $term );
301
+	return $wp_query->is_tax($taxonomy, $term);
302 302
 }
303 303
 
304 304
 /**
@@ -313,8 +313,8 @@  discard block
 block discarded – undo
313 313
 function is_date() {
314 314
 	global $wp_query;
315 315
 
316
-	if ( ! isset( $wp_query ) ) {
317
-		_doing_it_wrong( __FUNCTION__, __( 'Conditional query tags do not work before the query is run. Before then, they always return false.' ), '3.1.0' );
316
+	if ( ! isset($wp_query)) {
317
+		_doing_it_wrong(__FUNCTION__, __('Conditional query tags do not work before the query is run. Before then, they always return false.'), '3.1.0');
318 318
 		return false;
319 319
 	}
320 320
 
@@ -333,8 +333,8 @@  discard block
 block discarded – undo
333 333
 function is_day() {
334 334
 	global $wp_query;
335 335
 
336
-	if ( ! isset( $wp_query ) ) {
337
-		_doing_it_wrong( __FUNCTION__, __( 'Conditional query tags do not work before the query is run. Before then, they always return false.' ), '3.1.0' );
336
+	if ( ! isset($wp_query)) {
337
+		_doing_it_wrong(__FUNCTION__, __('Conditional query tags do not work before the query is run. Before then, they always return false.'), '3.1.0');
338 338
 		return false;
339 339
 	}
340 340
 
@@ -351,15 +351,15 @@  discard block
 block discarded – undo
351 351
  * @param string|array $feeds Optional feed types to check.
352 352
  * @return bool
353 353
  */
354
-function is_feed( $feeds = '' ) {
354
+function is_feed($feeds = '') {
355 355
 	global $wp_query;
356 356
 
357
-	if ( ! isset( $wp_query ) ) {
358
-		_doing_it_wrong( __FUNCTION__, __( 'Conditional query tags do not work before the query is run. Before then, they always return false.' ), '3.1.0' );
357
+	if ( ! isset($wp_query)) {
358
+		_doing_it_wrong(__FUNCTION__, __('Conditional query tags do not work before the query is run. Before then, they always return false.'), '3.1.0');
359 359
 		return false;
360 360
 	}
361 361
 
362
-	return $wp_query->is_feed( $feeds );
362
+	return $wp_query->is_feed($feeds);
363 363
 }
364 364
 
365 365
 /**
@@ -374,8 +374,8 @@  discard block
 block discarded – undo
374 374
 function is_comment_feed() {
375 375
 	global $wp_query;
376 376
 
377
-	if ( ! isset( $wp_query ) ) {
378
-		_doing_it_wrong( __FUNCTION__, __( 'Conditional query tags do not work before the query is run. Before then, they always return false.' ), '3.1.0' );
377
+	if ( ! isset($wp_query)) {
378
+		_doing_it_wrong(__FUNCTION__, __('Conditional query tags do not work before the query is run. Before then, they always return false.'), '3.1.0');
379 379
 		return false;
380 380
 	}
381 381
 
@@ -403,8 +403,8 @@  discard block
 block discarded – undo
403 403
 function is_front_page() {
404 404
 	global $wp_query;
405 405
 
406
-	if ( ! isset( $wp_query ) ) {
407
-		_doing_it_wrong( __FUNCTION__, __( 'Conditional query tags do not work before the query is run. Before then, they always return false.' ), '3.1.0' );
406
+	if ( ! isset($wp_query)) {
407
+		_doing_it_wrong(__FUNCTION__, __('Conditional query tags do not work before the query is run. Before then, they always return false.'), '3.1.0');
408 408
 		return false;
409 409
 	}
410 410
 
@@ -432,8 +432,8 @@  discard block
 block discarded – undo
432 432
 function is_home() {
433 433
 	global $wp_query;
434 434
 
435
-	if ( ! isset( $wp_query ) ) {
436
-		_doing_it_wrong( __FUNCTION__, __( 'Conditional query tags do not work before the query is run. Before then, they always return false.' ), '3.1.0' );
435
+	if ( ! isset($wp_query)) {
436
+		_doing_it_wrong(__FUNCTION__, __('Conditional query tags do not work before the query is run. Before then, they always return false.'), '3.1.0');
437 437
 		return false;
438 438
 	}
439 439
 
@@ -452,8 +452,8 @@  discard block
 block discarded – undo
452 452
 function is_month() {
453 453
 	global $wp_query;
454 454
 
455
-	if ( ! isset( $wp_query ) ) {
456
-		_doing_it_wrong( __FUNCTION__, __( 'Conditional query tags do not work before the query is run. Before then, they always return false.' ), '3.1.0' );
455
+	if ( ! isset($wp_query)) {
456
+		_doing_it_wrong(__FUNCTION__, __('Conditional query tags do not work before the query is run. Before then, they always return false.'), '3.1.0');
457 457
 		return false;
458 458
 	}
459 459
 
@@ -476,15 +476,15 @@  discard block
 block discarded – undo
476 476
  * @param int|string|array $page Optional. Page ID, title, slug, or array of such. Default empty.
477 477
  * @return bool Whether the query is for an existing single page.
478 478
  */
479
-function is_page( $page = '' ) {
479
+function is_page($page = '') {
480 480
 	global $wp_query;
481 481
 
482
-	if ( ! isset( $wp_query ) ) {
483
-		_doing_it_wrong( __FUNCTION__, __( 'Conditional query tags do not work before the query is run. Before then, they always return false.' ), '3.1.0' );
482
+	if ( ! isset($wp_query)) {
483
+		_doing_it_wrong(__FUNCTION__, __('Conditional query tags do not work before the query is run. Before then, they always return false.'), '3.1.0');
484 484
 		return false;
485 485
 	}
486 486
 
487
-	return $wp_query->is_page( $page );
487
+	return $wp_query->is_page($page);
488 488
 }
489 489
 
490 490
 /**
@@ -499,8 +499,8 @@  discard block
 block discarded – undo
499 499
 function is_paged() {
500 500
 	global $wp_query;
501 501
 
502
-	if ( ! isset( $wp_query ) ) {
503
-		_doing_it_wrong( __FUNCTION__, __( 'Conditional query tags do not work before the query is run. Before then, they always return false.' ), '3.1.0' );
502
+	if ( ! isset($wp_query)) {
503
+		_doing_it_wrong(__FUNCTION__, __('Conditional query tags do not work before the query is run. Before then, they always return false.'), '3.1.0');
504 504
 		return false;
505 505
 	}
506 506
 
@@ -519,8 +519,8 @@  discard block
 block discarded – undo
519 519
 function is_preview() {
520 520
 	global $wp_query;
521 521
 
522
-	if ( ! isset( $wp_query ) ) {
523
-		_doing_it_wrong( __FUNCTION__, __( 'Conditional query tags do not work before the query is run. Before then, they always return false.' ), '3.1.0' );
522
+	if ( ! isset($wp_query)) {
523
+		_doing_it_wrong(__FUNCTION__, __('Conditional query tags do not work before the query is run. Before then, they always return false.'), '3.1.0');
524 524
 		return false;
525 525
 	}
526 526
 
@@ -539,8 +539,8 @@  discard block
 block discarded – undo
539 539
 function is_robots() {
540 540
 	global $wp_query;
541 541
 
542
-	if ( ! isset( $wp_query ) ) {
543
-		_doing_it_wrong( __FUNCTION__, __( 'Conditional query tags do not work before the query is run. Before then, they always return false.' ), '3.1.0' );
542
+	if ( ! isset($wp_query)) {
543
+		_doing_it_wrong(__FUNCTION__, __('Conditional query tags do not work before the query is run. Before then, they always return false.'), '3.1.0');
544 544
 		return false;
545 545
 	}
546 546
 
@@ -559,8 +559,8 @@  discard block
 block discarded – undo
559 559
 function is_search() {
560 560
 	global $wp_query;
561 561
 
562
-	if ( ! isset( $wp_query ) ) {
563
-		_doing_it_wrong( __FUNCTION__, __( 'Conditional query tags do not work before the query is run. Before then, they always return false.' ), '3.1.0' );
562
+	if ( ! isset($wp_query)) {
563
+		_doing_it_wrong(__FUNCTION__, __('Conditional query tags do not work before the query is run. Before then, they always return false.'), '3.1.0');
564 564
 		return false;
565 565
 	}
566 566
 
@@ -585,15 +585,15 @@  discard block
 block discarded – undo
585 585
  * @param int|string|array $post Optional. Post ID, title, slug, or array of such. Default empty.
586 586
  * @return bool Whether the query is for an existing single post.
587 587
  */
588
-function is_single( $post = '' ) {
588
+function is_single($post = '') {
589 589
 	global $wp_query;
590 590
 
591
-	if ( ! isset( $wp_query ) ) {
592
-		_doing_it_wrong( __FUNCTION__, __( 'Conditional query tags do not work before the query is run. Before then, they always return false.' ), '3.1.0' );
591
+	if ( ! isset($wp_query)) {
592
+		_doing_it_wrong(__FUNCTION__, __('Conditional query tags do not work before the query is run. Before then, they always return false.'), '3.1.0');
593 593
 		return false;
594 594
 	}
595 595
 
596
-	return $wp_query->is_single( $post );
596
+	return $wp_query->is_single($post);
597 597
 }
598 598
 
599 599
 /**
@@ -612,15 +612,15 @@  discard block
 block discarded – undo
612 612
  * @param string|array $post_types Optional. Post type or array of post types. Default empty.
613 613
  * @return bool Whether the query is for an existing single post of any of the given post types.
614 614
  */
615
-function is_singular( $post_types = '' ) {
615
+function is_singular($post_types = '') {
616 616
 	global $wp_query;
617 617
 
618
-	if ( ! isset( $wp_query ) ) {
619
-		_doing_it_wrong( __FUNCTION__, __( 'Conditional query tags do not work before the query is run. Before then, they always return false.' ), '3.1.0' );
618
+	if ( ! isset($wp_query)) {
619
+		_doing_it_wrong(__FUNCTION__, __('Conditional query tags do not work before the query is run. Before then, they always return false.'), '3.1.0');
620 620
 		return false;
621 621
 	}
622 622
 
623
-	return $wp_query->is_singular( $post_types );
623
+	return $wp_query->is_singular($post_types);
624 624
 }
625 625
 
626 626
 /**
@@ -635,8 +635,8 @@  discard block
 block discarded – undo
635 635
 function is_time() {
636 636
 	global $wp_query;
637 637
 
638
-	if ( ! isset( $wp_query ) ) {
639
-		_doing_it_wrong( __FUNCTION__, __( 'Conditional query tags do not work before the query is run. Before then, they always return false.' ), '3.1.0' );
638
+	if ( ! isset($wp_query)) {
639
+		_doing_it_wrong(__FUNCTION__, __('Conditional query tags do not work before the query is run. Before then, they always return false.'), '3.1.0');
640 640
 		return false;
641 641
 	}
642 642
 
@@ -655,8 +655,8 @@  discard block
 block discarded – undo
655 655
 function is_trackback() {
656 656
 	global $wp_query;
657 657
 
658
-	if ( ! isset( $wp_query ) ) {
659
-		_doing_it_wrong( __FUNCTION__, __( 'Conditional query tags do not work before the query is run. Before then, they always return false.' ), '3.1.0' );
658
+	if ( ! isset($wp_query)) {
659
+		_doing_it_wrong(__FUNCTION__, __('Conditional query tags do not work before the query is run. Before then, they always return false.'), '3.1.0');
660 660
 		return false;
661 661
 	}
662 662
 
@@ -675,8 +675,8 @@  discard block
 block discarded – undo
675 675
 function is_year() {
676 676
 	global $wp_query;
677 677
 
678
-	if ( ! isset( $wp_query ) ) {
679
-		_doing_it_wrong( __FUNCTION__, __( 'Conditional query tags do not work before the query is run. Before then, they always return false.' ), '3.1.0' );
678
+	if ( ! isset($wp_query)) {
679
+		_doing_it_wrong(__FUNCTION__, __('Conditional query tags do not work before the query is run. Before then, they always return false.'), '3.1.0');
680 680
 		return false;
681 681
 	}
682 682
 
@@ -695,8 +695,8 @@  discard block
 block discarded – undo
695 695
 function is_404() {
696 696
 	global $wp_query;
697 697
 
698
-	if ( ! isset( $wp_query ) ) {
699
-		_doing_it_wrong( __FUNCTION__, __( 'Conditional query tags do not work before the query is run. Before then, they always return false.' ), '3.1.0' );
698
+	if ( ! isset($wp_query)) {
699
+		_doing_it_wrong(__FUNCTION__, __('Conditional query tags do not work before the query is run. Before then, they always return false.'), '3.1.0');
700 700
 		return false;
701 701
 	}
702 702
 
@@ -715,8 +715,8 @@  discard block
 block discarded – undo
715 715
 function is_embed() {
716 716
 	global $wp_query;
717 717
 
718
-	if ( ! isset( $wp_query ) ) {
719
-		_doing_it_wrong( __FUNCTION__, __( 'Conditional query tags do not work before the query is run. Before then, they always return false.' ), '3.1.0' );
718
+	if ( ! isset($wp_query)) {
719
+		_doing_it_wrong(__FUNCTION__, __('Conditional query tags do not work before the query is run. Before then, they always return false.'), '3.1.0');
720 720
 		return false;
721 721
 	}
722 722
 
@@ -733,16 +733,16 @@  discard block
 block discarded – undo
733 733
  * @return bool
734 734
  */
735 735
 function is_main_query() {
736
-	if ( 'pre_get_posts' === current_filter() ) {
736
+	if ('pre_get_posts' === current_filter()) {
737 737
 		$message = sprintf(
738 738
 			/* translators: 1: pre_get_posts 2: WP_Query->is_main_query() 3: is_main_query() 4: link to codex is_main_query() page. */
739
-			__( 'In %1$s, use the %2$s method, not the %3$s function. See %4$s.' ),
739
+			__('In %1$s, use the %2$s method, not the %3$s function. See %4$s.'),
740 740
 			'<code>pre_get_posts</code>',
741 741
 			'<code>WP_Query->is_main_query()</code>',
742 742
 			'<code>is_main_query()</code>',
743
-			__( 'https://codex.wordpress.org/Function_Reference/is_main_query' )
743
+			__('https://codex.wordpress.org/Function_Reference/is_main_query')
744 744
 		);
745
-		_doing_it_wrong( __FUNCTION__, $message, '3.7.0' );
745
+		_doing_it_wrong(__FUNCTION__, $message, '3.7.0');
746 746
 	}
747 747
 
748 748
 	global $wp_query;
@@ -847,58 +847,58 @@  discard block
 block discarded – undo
847 847
  * @global wpdb $wpdb WordPress database abstraction object.
848 848
  */
849 849
 function wp_old_slug_redirect() {
850
-	if ( is_404() && '' !== get_query_var( 'name' ) ) {
850
+	if (is_404() && '' !== get_query_var('name')) {
851 851
 		global $wpdb;
852 852
 
853 853
 		// Guess the current post_type based on the query vars.
854
-		if ( get_query_var( 'post_type' ) ) {
855
-			$post_type = get_query_var( 'post_type' );
856
-		} elseif ( get_query_var( 'attachment' ) ) {
854
+		if (get_query_var('post_type')) {
855
+			$post_type = get_query_var('post_type');
856
+		} elseif (get_query_var('attachment')) {
857 857
 			$post_type = 'attachment';
858
-		} elseif ( get_query_var( 'pagename' ) ) {
858
+		} elseif (get_query_var('pagename')) {
859 859
 			$post_type = 'page';
860 860
 		} else {
861 861
 			$post_type = 'post';
862 862
 		}
863 863
 
864
-		if ( is_array( $post_type ) ) {
865
-			if ( count( $post_type ) > 1 ) {
864
+		if (is_array($post_type)) {
865
+			if (count($post_type) > 1) {
866 866
 				return;
867 867
 			}
868
-			$post_type = reset( $post_type );
868
+			$post_type = reset($post_type);
869 869
 		}
870 870
 
871 871
 		// Do not attempt redirect for hierarchical post types
872
-		if ( is_post_type_hierarchical( $post_type ) ) {
872
+		if (is_post_type_hierarchical($post_type)) {
873 873
 			return;
874 874
 		}
875 875
 
876
-		$query = $wpdb->prepare("SELECT post_id FROM $wpdb->postmeta, $wpdb->posts WHERE ID = post_id AND post_type = %s AND meta_key = '_wp_old_slug' AND meta_value = %s", $post_type, get_query_var( 'name' ) );
876
+		$query = $wpdb->prepare("SELECT post_id FROM $wpdb->postmeta, $wpdb->posts WHERE ID = post_id AND post_type = %s AND meta_key = '_wp_old_slug' AND meta_value = %s", $post_type, get_query_var('name'));
877 877
 
878 878
 		// if year, monthnum, or day have been specified, make our query more precise
879 879
 		// just in case there are multiple identical _wp_old_slug values
880
-		if ( get_query_var( 'year' ) ) {
881
-			$query .= $wpdb->prepare(" AND YEAR(post_date) = %d", get_query_var( 'year' ) );
880
+		if (get_query_var('year')) {
881
+			$query .= $wpdb->prepare(" AND YEAR(post_date) = %d", get_query_var('year'));
882 882
 		}
883
-		if ( get_query_var( 'monthnum' ) ) {
884
-			$query .= $wpdb->prepare(" AND MONTH(post_date) = %d", get_query_var( 'monthnum' ) );
883
+		if (get_query_var('monthnum')) {
884
+			$query .= $wpdb->prepare(" AND MONTH(post_date) = %d", get_query_var('monthnum'));
885 885
 		}
886
-		if ( get_query_var( 'day' ) ) {
887
-			$query .= $wpdb->prepare(" AND DAYOFMONTH(post_date) = %d", get_query_var( 'day' ) );
886
+		if (get_query_var('day')) {
887
+			$query .= $wpdb->prepare(" AND DAYOFMONTH(post_date) = %d", get_query_var('day'));
888 888
 		}
889 889
 
890
-		$id = (int) $wpdb->get_var( $query );
890
+		$id = (int) $wpdb->get_var($query);
891 891
 
892
-		if ( ! $id ) {
892
+		if ( ! $id) {
893 893
 			return;
894 894
 		}
895 895
 
896
-		$link = get_permalink( $id );
896
+		$link = get_permalink($id);
897 897
 
898
-		if ( get_query_var( 'paged' ) > 1 ) {
899
-			$link = user_trailingslashit( trailingslashit( $link ) . 'page/' . get_query_var( 'paged' ) );
900
-		} elseif( is_embed() ) {
901
-			$link = user_trailingslashit( trailingslashit( $link ) . 'embed' );
898
+		if (get_query_var('paged') > 1) {
899
+			$link = user_trailingslashit(trailingslashit($link).'page/'.get_query_var('paged'));
900
+		} elseif (is_embed()) {
901
+			$link = user_trailingslashit(trailingslashit($link).'embed');
902 902
 		}
903 903
 
904 904
 		/**
@@ -908,13 +908,13 @@  discard block
 block discarded – undo
908 908
 		 *
909 909
 		 * @param string $link The redirect URL.
910 910
 		 */
911
-		$link = apply_filters( 'old_slug_redirect_url', $link );
911
+		$link = apply_filters('old_slug_redirect_url', $link);
912 912
 
913
-		if ( ! $link ) {
913
+		if ( ! $link) {
914 914
 			return;
915 915
 		}
916 916
 
917
-		wp_redirect( $link, 301 ); // Permanent redirect
917
+		wp_redirect($link, 301); // Permanent redirect
918 918
 		exit;
919 919
 	}
920 920
 }
@@ -930,11 +930,11 @@  discard block
 block discarded – undo
930 930
  * @param WP_Post|object|int $post WP_Post instance or Post ID/object.
931 931
  * @return bool True when finished.
932 932
  */
933
-function setup_postdata( $post ) {
933
+function setup_postdata($post) {
934 934
 	global $wp_query;
935 935
 
936
-	if ( ! empty( $wp_query ) && $wp_query instanceof WP_Query ) {
937
-		return $wp_query->setup_postdata( $post );
936
+	if ( ! empty($wp_query) && $wp_query instanceof WP_Query) {
937
+		return $wp_query->setup_postdata($post);
938 938
 	}
939 939
 
940 940
 	return false;
Please login to merge, or discard this patch.