Completed
Push — master ( c0c536...fdb3a7 )
by Stephen
20:33
created
src/wp-includes/ID3/module.audio.ogg.php 4 patches
Doc Comments   +5 added lines patch added patch discarded remove patch
@@ -427,6 +427,11 @@
 block discarded – undo
427 427
 	}
428 428
 
429 429
 	// http://tools.ietf.org/html/draft-ietf-codec-oggopus-03
430
+
431
+	/**
432
+	 * @param string $filedata
433
+	 * @param integer $filedataoffset
434
+	 */
430 435
 	public function ParseOpusPageHeader(&$filedata, &$filedataoffset, &$oggpageinfo) {
431 436
 		$info = &$this->getid3->info;
432 437
 		$info['audio']['dataformat']   = 'opus';
Please login to merge, or discard this patch.
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -528,7 +528,7 @@
 block discarded – undo
528 528
 		return $oggheader;
529 529
 	}
530 530
 
531
-    // http://xiph.org/vorbis/doc/Vorbis_I_spec.html#x1-810005
531
+	// http://xiph.org/vorbis/doc/Vorbis_I_spec.html#x1-810005
532 532
 	public function ParseVorbisComments() {
533 533
 		$info = &$this->getid3->info;
534 534
 
Please login to merge, or discard this patch.
Spacing   +61 added lines, -61 removed lines patch added patch discarded remove patch
@@ -65,7 +65,7 @@  discard block
 block discarded – undo
65 65
 
66 66
 		} elseif (substr($filedata, 0, 8) == 'OpusHead') {
67 67
 
68
-			if( $this->ParseOpusPageHeader($filedata, $filedataoffset, $oggpageinfo) == false ) {
68
+			if ($this->ParseOpusPageHeader($filedata, $filedataoffset, $oggpageinfo) == false) {
69 69
 				return false;
70 70
 			}
71 71
 
@@ -78,9 +78,9 @@  discard block
 block discarded – undo
78 78
 			$info['audio']['bitrate_mode'] = 'abr';
79 79
 			$info['audio']['lossless']     = false;
80 80
 
81
-			$info['ogg']['pageheader'][$oggpageinfo['page_seqno']]['speex_string']           =                              substr($filedata, $filedataoffset, 8); // hard-coded to 'Speex   '
81
+			$info['ogg']['pageheader'][$oggpageinfo['page_seqno']]['speex_string']           = substr($filedata, $filedataoffset, 8); // hard-coded to 'Speex   '
82 82
 			$filedataoffset += 8;
83
-			$info['ogg']['pageheader'][$oggpageinfo['page_seqno']]['speex_version']          =                              substr($filedata, $filedataoffset, 20);
83
+			$info['ogg']['pageheader'][$oggpageinfo['page_seqno']]['speex_version']          = substr($filedata, $filedataoffset, 20);
84 84
 			$filedataoffset += 20;
85 85
 			$info['ogg']['pageheader'][$oggpageinfo['page_seqno']]['speex_version_id']       = getid3_lib::LittleEndian2Int(substr($filedata, $filedataoffset, 4));
86 86
 			$filedataoffset += 4;
@@ -125,45 +125,45 @@  discard block
 block discarded – undo
125 125
 
126 126
 			// http://www.theora.org/doc/Theora.pdf (section 6.2)
127 127
 
128
-			$info['ogg']['pageheader']['theora']['theora_magic']             =                           substr($filedata, $filedataoffset,  7); // hard-coded to "\x80.'theora'
128
+			$info['ogg']['pageheader']['theora']['theora_magic']             = substr($filedata, $filedataoffset, 7); // hard-coded to "\x80.'theora'
129 129
 			$filedataoffset += 7;
130
-			$info['ogg']['pageheader']['theora']['version_major']            = getid3_lib::BigEndian2Int(substr($filedata, $filedataoffset,  1));
130
+			$info['ogg']['pageheader']['theora']['version_major']            = getid3_lib::BigEndian2Int(substr($filedata, $filedataoffset, 1));
131 131
 			$filedataoffset += 1;
132
-			$info['ogg']['pageheader']['theora']['version_minor']            = getid3_lib::BigEndian2Int(substr($filedata, $filedataoffset,  1));
132
+			$info['ogg']['pageheader']['theora']['version_minor']            = getid3_lib::BigEndian2Int(substr($filedata, $filedataoffset, 1));
133 133
 			$filedataoffset += 1;
134
-			$info['ogg']['pageheader']['theora']['version_revision']         = getid3_lib::BigEndian2Int(substr($filedata, $filedataoffset,  1));
134
+			$info['ogg']['pageheader']['theora']['version_revision']         = getid3_lib::BigEndian2Int(substr($filedata, $filedataoffset, 1));
135 135
 			$filedataoffset += 1;
136
-			$info['ogg']['pageheader']['theora']['frame_width_macroblocks']  = getid3_lib::BigEndian2Int(substr($filedata, $filedataoffset,  2));
136
+			$info['ogg']['pageheader']['theora']['frame_width_macroblocks']  = getid3_lib::BigEndian2Int(substr($filedata, $filedataoffset, 2));
137 137
 			$filedataoffset += 2;
138
-			$info['ogg']['pageheader']['theora']['frame_height_macroblocks'] = getid3_lib::BigEndian2Int(substr($filedata, $filedataoffset,  2));
138
+			$info['ogg']['pageheader']['theora']['frame_height_macroblocks'] = getid3_lib::BigEndian2Int(substr($filedata, $filedataoffset, 2));
139 139
 			$filedataoffset += 2;
140
-			$info['ogg']['pageheader']['theora']['resolution_x']             = getid3_lib::BigEndian2Int(substr($filedata, $filedataoffset,  3));
140
+			$info['ogg']['pageheader']['theora']['resolution_x']             = getid3_lib::BigEndian2Int(substr($filedata, $filedataoffset, 3));
141 141
 			$filedataoffset += 3;
142
-			$info['ogg']['pageheader']['theora']['resolution_y']             = getid3_lib::BigEndian2Int(substr($filedata, $filedataoffset,  3));
142
+			$info['ogg']['pageheader']['theora']['resolution_y']             = getid3_lib::BigEndian2Int(substr($filedata, $filedataoffset, 3));
143 143
 			$filedataoffset += 3;
144
-			$info['ogg']['pageheader']['theora']['picture_offset_x']         = getid3_lib::BigEndian2Int(substr($filedata, $filedataoffset,  1));
144
+			$info['ogg']['pageheader']['theora']['picture_offset_x']         = getid3_lib::BigEndian2Int(substr($filedata, $filedataoffset, 1));
145 145
 			$filedataoffset += 1;
146
-			$info['ogg']['pageheader']['theora']['picture_offset_y']         = getid3_lib::BigEndian2Int(substr($filedata, $filedataoffset,  1));
146
+			$info['ogg']['pageheader']['theora']['picture_offset_y']         = getid3_lib::BigEndian2Int(substr($filedata, $filedataoffset, 1));
147 147
 			$filedataoffset += 1;
148
-			$info['ogg']['pageheader']['theora']['frame_rate_numerator']     = getid3_lib::BigEndian2Int(substr($filedata, $filedataoffset,  4));
148
+			$info['ogg']['pageheader']['theora']['frame_rate_numerator']     = getid3_lib::BigEndian2Int(substr($filedata, $filedataoffset, 4));
149 149
 			$filedataoffset += 4;
150
-			$info['ogg']['pageheader']['theora']['frame_rate_denominator']   = getid3_lib::BigEndian2Int(substr($filedata, $filedataoffset,  4));
150
+			$info['ogg']['pageheader']['theora']['frame_rate_denominator']   = getid3_lib::BigEndian2Int(substr($filedata, $filedataoffset, 4));
151 151
 			$filedataoffset += 4;
152
-			$info['ogg']['pageheader']['theora']['pixel_aspect_numerator']   = getid3_lib::BigEndian2Int(substr($filedata, $filedataoffset,  3));
152
+			$info['ogg']['pageheader']['theora']['pixel_aspect_numerator']   = getid3_lib::BigEndian2Int(substr($filedata, $filedataoffset, 3));
153 153
 			$filedataoffset += 3;
154
-			$info['ogg']['pageheader']['theora']['pixel_aspect_denominator'] = getid3_lib::BigEndian2Int(substr($filedata, $filedataoffset,  3));
154
+			$info['ogg']['pageheader']['theora']['pixel_aspect_denominator'] = getid3_lib::BigEndian2Int(substr($filedata, $filedataoffset, 3));
155 155
 			$filedataoffset += 3;
156
-			$info['ogg']['pageheader']['theora']['color_space_id']           = getid3_lib::BigEndian2Int(substr($filedata, $filedataoffset,  1));
156
+			$info['ogg']['pageheader']['theora']['color_space_id']           = getid3_lib::BigEndian2Int(substr($filedata, $filedataoffset, 1));
157 157
 			$filedataoffset += 1;
158
-			$info['ogg']['pageheader']['theora']['nominal_bitrate']          = getid3_lib::BigEndian2Int(substr($filedata, $filedataoffset,  3));
158
+			$info['ogg']['pageheader']['theora']['nominal_bitrate']          = getid3_lib::BigEndian2Int(substr($filedata, $filedataoffset, 3));
159 159
 			$filedataoffset += 3;
160
-			$info['ogg']['pageheader']['theora']['flags']                    = getid3_lib::BigEndian2Int(substr($filedata, $filedataoffset,  2));
160
+			$info['ogg']['pageheader']['theora']['flags']                    = getid3_lib::BigEndian2Int(substr($filedata, $filedataoffset, 2));
161 161
 			$filedataoffset += 2;
162 162
 
163 163
 			$info['ogg']['pageheader']['theora']['quality']         = ($info['ogg']['pageheader']['theora']['flags'] & 0xFC00) >> 10;
164
-			$info['ogg']['pageheader']['theora']['kfg_shift']       = ($info['ogg']['pageheader']['theora']['flags'] & 0x03E0) >>  5;
165
-			$info['ogg']['pageheader']['theora']['pixel_format_id'] = ($info['ogg']['pageheader']['theora']['flags'] & 0x0018) >>  3;
166
-			$info['ogg']['pageheader']['theora']['reserved']        = ($info['ogg']['pageheader']['theora']['flags'] & 0x0007) >>  0; // should be 0
164
+			$info['ogg']['pageheader']['theora']['kfg_shift']       = ($info['ogg']['pageheader']['theora']['flags'] & 0x03E0) >> 5;
165
+			$info['ogg']['pageheader']['theora']['pixel_format_id'] = ($info['ogg']['pageheader']['theora']['flags'] & 0x0018) >> 3;
166
+			$info['ogg']['pageheader']['theora']['reserved']        = ($info['ogg']['pageheader']['theora']['flags'] & 0x0007) >> 0; // should be 0
167 167
 			$info['ogg']['pageheader']['theora']['color_space']     = self::TheoraColorSpace($info['ogg']['pageheader']['theora']['color_space_id']);
168 168
 			$info['ogg']['pageheader']['theora']['pixel_format']    = self::TheoraPixelFormat($info['ogg']['pageheader']['theora']['pixel_format_id']);
169 169
 
@@ -187,24 +187,24 @@  discard block
 block discarded – undo
187 187
 			// Ogg Skeleton version 3.0 Format Specification
188 188
 			// http://xiph.org/ogg/doc/skeleton.html
189 189
 			$filedataoffset += 8;
190
-			$info['ogg']['skeleton']['fishead']['raw']['version_major']                = getid3_lib::LittleEndian2Int(substr($filedata, $filedataoffset,  2));
190
+			$info['ogg']['skeleton']['fishead']['raw']['version_major']                = getid3_lib::LittleEndian2Int(substr($filedata, $filedataoffset, 2));
191 191
 			$filedataoffset += 2;
192
-			$info['ogg']['skeleton']['fishead']['raw']['version_minor']                = getid3_lib::LittleEndian2Int(substr($filedata, $filedataoffset,  2));
192
+			$info['ogg']['skeleton']['fishead']['raw']['version_minor']                = getid3_lib::LittleEndian2Int(substr($filedata, $filedataoffset, 2));
193 193
 			$filedataoffset += 2;
194
-			$info['ogg']['skeleton']['fishead']['raw']['presentationtime_numerator']   = getid3_lib::LittleEndian2Int(substr($filedata, $filedataoffset,  8));
194
+			$info['ogg']['skeleton']['fishead']['raw']['presentationtime_numerator']   = getid3_lib::LittleEndian2Int(substr($filedata, $filedataoffset, 8));
195 195
 			$filedataoffset += 8;
196
-			$info['ogg']['skeleton']['fishead']['raw']['presentationtime_denominator'] = getid3_lib::LittleEndian2Int(substr($filedata, $filedataoffset,  8));
196
+			$info['ogg']['skeleton']['fishead']['raw']['presentationtime_denominator'] = getid3_lib::LittleEndian2Int(substr($filedata, $filedataoffset, 8));
197 197
 			$filedataoffset += 8;
198
-			$info['ogg']['skeleton']['fishead']['raw']['basetime_numerator']           = getid3_lib::LittleEndian2Int(substr($filedata, $filedataoffset,  8));
198
+			$info['ogg']['skeleton']['fishead']['raw']['basetime_numerator']           = getid3_lib::LittleEndian2Int(substr($filedata, $filedataoffset, 8));
199 199
 			$filedataoffset += 8;
200
-			$info['ogg']['skeleton']['fishead']['raw']['basetime_denominator']         = getid3_lib::LittleEndian2Int(substr($filedata, $filedataoffset,  8));
200
+			$info['ogg']['skeleton']['fishead']['raw']['basetime_denominator']         = getid3_lib::LittleEndian2Int(substr($filedata, $filedataoffset, 8));
201 201
 			$filedataoffset += 8;
202 202
 			$info['ogg']['skeleton']['fishead']['raw']['utc']                          = getid3_lib::LittleEndian2Int(substr($filedata, $filedataoffset, 20));
203 203
 			$filedataoffset += 20;
204 204
 
205 205
 			$info['ogg']['skeleton']['fishead']['version']          = $info['ogg']['skeleton']['fishead']['raw']['version_major'].'.'.$info['ogg']['skeleton']['fishead']['raw']['version_minor'];
206 206
 			$info['ogg']['skeleton']['fishead']['presentationtime'] = $info['ogg']['skeleton']['fishead']['raw']['presentationtime_numerator'] / $info['ogg']['skeleton']['fishead']['raw']['presentationtime_denominator'];
207
-			$info['ogg']['skeleton']['fishead']['basetime']         = $info['ogg']['skeleton']['fishead']['raw']['basetime_numerator']         / $info['ogg']['skeleton']['fishead']['raw']['basetime_denominator'];
207
+			$info['ogg']['skeleton']['fishead']['basetime']         = $info['ogg']['skeleton']['fishead']['raw']['basetime_numerator'] / $info['ogg']['skeleton']['fishead']['raw']['basetime_denominator'];
208 208
 			$info['ogg']['skeleton']['fishead']['utc']              = $info['ogg']['skeleton']['fishead']['raw']['utc'];
209 209
 
210 210
 
@@ -218,23 +218,23 @@  discard block
 block discarded – undo
218 218
 				if (substr($filedata, 0, 8) == "fisbone\x00") {
219 219
 
220 220
 					$filedataoffset = 8;
221
-					$info['ogg']['skeleton']['fisbone']['raw']['message_header_offset']   = getid3_lib::LittleEndian2Int(substr($filedata, $filedataoffset,  4));
221
+					$info['ogg']['skeleton']['fisbone']['raw']['message_header_offset']   = getid3_lib::LittleEndian2Int(substr($filedata, $filedataoffset, 4));
222 222
 					$filedataoffset += 4;
223
-					$info['ogg']['skeleton']['fisbone']['raw']['serial_number']           = getid3_lib::LittleEndian2Int(substr($filedata, $filedataoffset,  4));
223
+					$info['ogg']['skeleton']['fisbone']['raw']['serial_number']           = getid3_lib::LittleEndian2Int(substr($filedata, $filedataoffset, 4));
224 224
 					$filedataoffset += 4;
225
-					$info['ogg']['skeleton']['fisbone']['raw']['number_header_packets']   = getid3_lib::LittleEndian2Int(substr($filedata, $filedataoffset,  4));
225
+					$info['ogg']['skeleton']['fisbone']['raw']['number_header_packets']   = getid3_lib::LittleEndian2Int(substr($filedata, $filedataoffset, 4));
226 226
 					$filedataoffset += 4;
227
-					$info['ogg']['skeleton']['fisbone']['raw']['granulerate_numerator']   = getid3_lib::LittleEndian2Int(substr($filedata, $filedataoffset,  8));
227
+					$info['ogg']['skeleton']['fisbone']['raw']['granulerate_numerator']   = getid3_lib::LittleEndian2Int(substr($filedata, $filedataoffset, 8));
228 228
 					$filedataoffset += 8;
229
-					$info['ogg']['skeleton']['fisbone']['raw']['granulerate_denominator'] = getid3_lib::LittleEndian2Int(substr($filedata, $filedataoffset,  8));
229
+					$info['ogg']['skeleton']['fisbone']['raw']['granulerate_denominator'] = getid3_lib::LittleEndian2Int(substr($filedata, $filedataoffset, 8));
230 230
 					$filedataoffset += 8;
231
-					$info['ogg']['skeleton']['fisbone']['raw']['basegranule']             = getid3_lib::LittleEndian2Int(substr($filedata, $filedataoffset,  8));
231
+					$info['ogg']['skeleton']['fisbone']['raw']['basegranule']             = getid3_lib::LittleEndian2Int(substr($filedata, $filedataoffset, 8));
232 232
 					$filedataoffset += 8;
233
-					$info['ogg']['skeleton']['fisbone']['raw']['preroll']                 = getid3_lib::LittleEndian2Int(substr($filedata, $filedataoffset,  4));
233
+					$info['ogg']['skeleton']['fisbone']['raw']['preroll']                 = getid3_lib::LittleEndian2Int(substr($filedata, $filedataoffset, 4));
234 234
 					$filedataoffset += 4;
235
-					$info['ogg']['skeleton']['fisbone']['raw']['granuleshift']            = getid3_lib::LittleEndian2Int(substr($filedata, $filedataoffset,  1));
235
+					$info['ogg']['skeleton']['fisbone']['raw']['granuleshift']            = getid3_lib::LittleEndian2Int(substr($filedata, $filedataoffset, 1));
236 236
 					$filedataoffset += 1;
237
-					$info['ogg']['skeleton']['fisbone']['raw']['padding']                 =                              substr($filedata, $filedataoffset,  3);
237
+					$info['ogg']['skeleton']['fisbone']['raw']['padding']                 = substr($filedata, $filedataoffset, 3);
238 238
 					$filedataoffset += 3;
239 239
 
240 240
 				} elseif (substr($filedata, 1, 6) == 'theora') {
@@ -276,14 +276,14 @@  discard block
 block discarded – undo
276 276
 			case 'vorbis':
277 277
 				$filedata = $this->fread($info['ogg']['pageheader'][$oggpageinfo['page_seqno']]['page_length']);
278 278
 				$info['ogg']['pageheader'][$oggpageinfo['page_seqno']]['packet_type'] = getid3_lib::LittleEndian2Int(substr($filedata, 0, 1));
279
-				$info['ogg']['pageheader'][$oggpageinfo['page_seqno']]['stream_type'] =                              substr($filedata, 1, 6); // hard-coded to 'vorbis'
279
+				$info['ogg']['pageheader'][$oggpageinfo['page_seqno']]['stream_type'] = substr($filedata, 1, 6); // hard-coded to 'vorbis'
280 280
 
281 281
 				$this->ParseVorbisComments();
282 282
 				break;
283 283
 
284 284
 			case 'flac':
285 285
 				$flac = new getid3_flac($this->getid3);
286
-				if (!$flac->parseMETAdata()) {
286
+				if ( ! $flac->parseMETAdata()) {
287 287
 					$info['error'][] = 'Failed to parse FLAC headers';
288 288
 					return false;
289 289
 				}
@@ -298,7 +298,7 @@  discard block
 block discarded – undo
298 298
 			case 'opus':
299 299
 				$filedata = $this->fread($info['ogg']['pageheader'][$oggpageinfo['page_seqno']]['page_length']);
300 300
 				$info['ogg']['pageheader'][$oggpageinfo['page_seqno']]['stream_type'] = substr($filedata, 0, 8); // hard-coded to 'OpusTags'
301
-				if(substr($filedata, 0, 8)  != 'OpusTags') {
301
+				if (substr($filedata, 0, 8) != 'OpusTags') {
302 302
 					$info['error'][] = 'Expected "OpusTags" as header but got "'.substr($filedata, 0, 8).'"';
303 303
 					return false;
304 304
 				}
@@ -309,7 +309,7 @@  discard block
 block discarded – undo
309 309
 		}
310 310
 
311 311
 		// Last Page - Number of Samples
312
-		if (!getid3_lib::intValueSupported($info['avdataend'])) {
312
+		if ( ! getid3_lib::intValueSupported($info['avdataend'])) {
313 313
 
314 314
 			$info['warning'][] = 'Unable to parse Ogg end chunk file (PHP does not support file operations beyond '.round(PHP_INT_MAX / 1073741824).'GB)';
315 315
 
@@ -321,26 +321,26 @@  discard block
 block discarded – undo
321 321
 				$this->fseek($info['avdataend'] - ($LastOggSpostion + strlen('SggO')));
322 322
 				$info['avdataend'] = $this->ftell();
323 323
 				$info['ogg']['pageheader']['eos'] = $this->ParseOggPageHeader();
324
-				$info['ogg']['samples']   = $info['ogg']['pageheader']['eos']['pcm_abs_position'];
324
+				$info['ogg']['samples'] = $info['ogg']['pageheader']['eos']['pcm_abs_position'];
325 325
 				if ($info['ogg']['samples'] == 0) {
326 326
 					$info['error'][] = 'Corrupt Ogg file: eos.number of samples == zero';
327 327
 					return false;
328 328
 				}
329
-				if (!empty($info['audio']['sample_rate'])) {
329
+				if ( ! empty($info['audio']['sample_rate'])) {
330 330
 					$info['ogg']['bitrate_average'] = (($info['avdataend'] - $info['avdataoffset']) * 8) / ($info['ogg']['samples'] / $info['audio']['sample_rate']);
331 331
 				}
332 332
 			}
333 333
 
334 334
 		}
335 335
 
336
-		if (!empty($info['ogg']['bitrate_average'])) {
336
+		if ( ! empty($info['ogg']['bitrate_average'])) {
337 337
 			$info['audio']['bitrate'] = $info['ogg']['bitrate_average'];
338
-		} elseif (!empty($info['ogg']['bitrate_nominal'])) {
338
+		} elseif ( ! empty($info['ogg']['bitrate_nominal'])) {
339 339
 			$info['audio']['bitrate'] = $info['ogg']['bitrate_nominal'];
340
-		} elseif (!empty($info['ogg']['bitrate_min']) && !empty($info['ogg']['bitrate_max'])) {
340
+		} elseif ( ! empty($info['ogg']['bitrate_min']) && ! empty($info['ogg']['bitrate_max'])) {
341 341
 			$info['audio']['bitrate'] = ($info['ogg']['bitrate_min'] + $info['ogg']['bitrate_max']) / 2;
342 342
 		}
343
-		if (isset($info['audio']['bitrate']) && !isset($info['playtime_seconds'])) {
343
+		if (isset($info['audio']['bitrate']) && ! isset($info['playtime_seconds'])) {
344 344
 			if ($info['audio']['bitrate'] == 0) {
345 345
 				$info['error'][] = 'Corrupt Ogg file: bitrate_audio == zero';
346 346
 				return false;
@@ -355,7 +355,7 @@  discard block
 block discarded – undo
355 355
 			if ($info['audio']['dataformat'] == 'vorbis') {
356 356
 
357 357
 				// Vorbis 1.0 starts with Xiph.Org
358
-				if  (preg_match('/^Xiph.Org/', $info['audio']['encoder'])) {
358
+				if (preg_match('/^Xiph.Org/', $info['audio']['encoder'])) {
359 359
 
360 360
 					if ($info['audio']['bitrate_mode'] == 'abr') {
361 361
 
@@ -369,7 +369,7 @@  discard block
 block discarded – undo
369 369
 					}
370 370
 				}
371 371
 
372
-				if (empty($info['audio']['encoder_options']) && !empty($info['ogg']['bitrate_nominal'])) {
372
+				if (empty($info['audio']['encoder_options']) && ! empty($info['ogg']['bitrate_nominal'])) {
373 373
 					$info['audio']['encoder_options'] = 'Nominal bitrate: '.intval(round($info['ogg']['bitrate_nominal'] / 1000)).'kbps';
374 374
 				}
375 375
 			}
@@ -407,7 +407,7 @@  discard block
 block discarded – undo
407 407
 		$filedataoffset += 4;
408 408
 		$info['ogg']['bitrate_min']      = getid3_lib::LittleEndian2Int(substr($filedata, $filedataoffset, 4));
409 409
 		$filedataoffset += 4;
410
-		$info['ogg']['blocksize_small']  = pow(2,  getid3_lib::LittleEndian2Int(substr($filedata, $filedataoffset, 1)) & 0x0F);
410
+		$info['ogg']['blocksize_small']  = pow(2, getid3_lib::LittleEndian2Int(substr($filedata, $filedataoffset, 1)) & 0x0F);
411 411
 		$info['ogg']['blocksize_large']  = pow(2, (getid3_lib::LittleEndian2Int(substr($filedata, $filedataoffset, 1)) & 0xF0) >> 4);
412 412
 		$info['ogg']['stop_bit']         = getid3_lib::LittleEndian2Int(substr($filedata, $filedataoffset, 1)); // must be 1, marks end of packet
413 413
 
@@ -439,7 +439,7 @@  discard block
 block discarded – undo
439 439
 
440 440
 		$info['ogg']['pageheader']['opus']['opus_magic'] = substr($filedata, $filedataoffset, 8); // hard-coded to 'OpusHead'
441 441
 		$filedataoffset += 8;
442
-		$info['ogg']['pageheader']['opus']['version']    = getid3_lib::LittleEndian2Int(substr($filedata, $filedataoffset,  1));
442
+		$info['ogg']['pageheader']['opus']['version']    = getid3_lib::LittleEndian2Int(substr($filedata, $filedataoffset, 1));
443 443
 		$filedataoffset += 1;
444 444
 
445 445
 		if ($info['ogg']['pageheader']['opus']['version'] < 1 || $info['ogg']['pageheader']['opus']['version'] > 15) {
@@ -447,7 +447,7 @@  discard block
 block discarded – undo
447 447
 			return false;
448 448
 		}
449 449
 
450
-		$info['ogg']['pageheader']['opus']['out_channel_count'] = getid3_lib::LittleEndian2Int(substr($filedata, $filedataoffset,  1));
450
+		$info['ogg']['pageheader']['opus']['out_channel_count'] = getid3_lib::LittleEndian2Int(substr($filedata, $filedataoffset, 1));
451 451
 		$filedataoffset += 1;
452 452
 
453 453
 		if ($info['ogg']['pageheader']['opus']['out_channel_count'] == 0) {
@@ -455,10 +455,10 @@  discard block
 block discarded – undo
455 455
 			return false;
456 456
 		}
457 457
 
458
-		$info['ogg']['pageheader']['opus']['pre_skip'] = getid3_lib::LittleEndian2Int(substr($filedata, $filedataoffset,  2));
458
+		$info['ogg']['pageheader']['opus']['pre_skip'] = getid3_lib::LittleEndian2Int(substr($filedata, $filedataoffset, 2));
459 459
 		$filedataoffset += 2;
460 460
 
461
-		$info['ogg']['pageheader']['opus']['sample_rate'] = getid3_lib::LittleEndian2Int(substr($filedata, $filedataoffset,  4));
461
+		$info['ogg']['pageheader']['opus']['sample_rate'] = getid3_lib::LittleEndian2Int(substr($filedata, $filedataoffset, 4));
462 462
 		$filedataoffset += 4;
463 463
 
464 464
 		//$info['ogg']['pageheader']['opus']['output_gain'] = getid3_lib::LittleEndian2Int(substr($filedata, $filedataoffset,  2));
@@ -540,7 +540,7 @@  discard block
 block discarded – undo
540 540
 			case 'vorbis':
541 541
 			case 'speex':
542 542
 			case 'opus':
543
-				$CommentStartOffset = $info['ogg']['pageheader'][$VorbisCommentPage]['page_start_offset'];  // Second Ogg page, after header block
543
+				$CommentStartOffset = $info['ogg']['pageheader'][$VorbisCommentPage]['page_start_offset']; // Second Ogg page, after header block
544 544
 				$this->fseek($CommentStartOffset);
545 545
 				$commentdataoffset = 27 + $info['ogg']['pageheader'][$VorbisCommentPage]['page_segments'];
546 546
 				$commentdata = $this->fread(self::OggPageSegmentLength($info['ogg']['pageheader'][$VorbisCommentPage], 1) + $commentdataoffset);
@@ -641,7 +641,7 @@  discard block
 block discarded – undo
641 641
 				$commentdata .= $AsYetUnusedData;
642 642
 
643 643
 				//$commentdata .= $this->fread($info['ogg']['pageheader'][$oggpageinfo['page_seqno']]['page_length']);
644
-				if (!isset($info['ogg']['pageheader'][$VorbisCommentPage])) {
644
+				if ( ! isset($info['ogg']['pageheader'][$VorbisCommentPage])) {
645 645
 					$info['warning'][] = 'undefined Vorbis Comment page "'.$VorbisCommentPage.'" at offset '.$this->ftell();
646 646
 					break;
647 647
 				}
@@ -658,7 +658,7 @@  discard block
 block discarded – undo
658 658
 			$commentstring = substr($commentdata, $commentdataoffset, $ThisFileInfo_ogg_comments_raw[$i]['size']);
659 659
 			$commentdataoffset += $ThisFileInfo_ogg_comments_raw[$i]['size'];
660 660
 
661
-			if (!$commentstring) {
661
+			if ( ! $commentstring) {
662 662
 
663 663
 				// no comment?
664 664
 				$info['warning'][] = 'Blank Ogg comment ['.$i.']';
@@ -686,7 +686,7 @@  discard block
 block discarded – undo
686 686
 					$this->notice('Found deprecated COVERART tag, it should be replaced in honor of METADATA_BLOCK_PICTURE structure');
687 687
 					/** @todo use 'coverartmime' where available */
688 688
 					$imageinfo = getid3_lib::GetDataImageSize($data);
689
-					if ($imageinfo === false || !isset($imageinfo['mime'])) {
689
+					if ($imageinfo === false || ! isset($imageinfo['mime'])) {
690 690
 						$this->warning('COVERART vorbiscomment tag contains invalid image');
691 691
 						continue;
692 692
 					}
@@ -775,7 +775,7 @@  discard block
 block discarded – undo
775 775
 	}
776 776
 
777 777
 
778
-	public static function OggPageSegmentLength($OggInfoArray, $SegmentNumber=1) {
778
+	public static function OggPageSegmentLength($OggInfoArray, $SegmentNumber = 1) {
779 779
 		for ($i = 0; $i < $SegmentNumber; $i++) {
780 780
 			$segmentlength = 0;
781 781
 			foreach ($OggInfoArray['segment_table'] as $key => $value) {
Please login to merge, or discard this patch.
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -547,8 +547,7 @@
 block discarded – undo
547 547
 
548 548
 				if ($info['audio']['dataformat'] == 'vorbis') {
549 549
 					$commentdataoffset += (strlen('vorbis') + 1);
550
-				}
551
-				else if ($info['audio']['dataformat'] == 'opus') {
550
+				} else if ($info['audio']['dataformat'] == 'opus') {
552 551
 					$commentdataoffset += strlen('OpusTags');
553 552
 				}
554 553
 
Please login to merge, or discard this patch.
src/wp-includes/ID3/module.tag.apetag.php 2 patches
Doc Comments   +3 added lines patch added patch discarded remove patch
@@ -331,6 +331,9 @@
 block discarded – undo
331 331
 		return true;
332 332
 	}
333 333
 
334
+	/**
335
+	 * @param string $APEheaderFooterData
336
+	 */
334 337
 	public function parseAPEheaderFooter($APEheaderFooterData) {
335 338
 		// http://www.uni-jena.de/~pfk/mpp/sv8/apeheader.html
336 339
 
Please login to merge, or discard this patch.
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -22,7 +22,7 @@  discard block
 block discarded – undo
22 22
 	public function Analyze() {
23 23
 		$info = &$this->getid3->info;
24 24
 
25
-		if (!getid3_lib::intValueSupported($info['filesize'])) {
25
+		if ( ! getid3_lib::intValueSupported($info['filesize'])) {
26 26
 			$info['warning'][] = 'Unable to check for APEtags because file is larger than '.round(PHP_INT_MAX / 1073741824).'GB';
27 27
 			return false;
28 28
 		}
@@ -58,7 +58,7 @@  discard block
 block discarded – undo
58 58
 			}
59 59
 
60 60
 		}
61
-		if (!isset($info['ape']['tag_offset_end'])) {
61
+		if ( ! isset($info['ape']['tag_offset_end'])) {
62 62
 
63 63
 			// APE tag not found
64 64
 			unset($info['ape']);
@@ -71,7 +71,7 @@  discard block
 block discarded – undo
71 71
 
72 72
 		$this->fseek($thisfile_ape['tag_offset_end'] - $apetagheadersize);
73 73
 		$APEfooterData = $this->fread(32);
74
-		if (!($thisfile_ape['footer'] = $this->parseAPEheaderFooter($APEfooterData))) {
74
+		if ( ! ($thisfile_ape['footer'] = $this->parseAPEheaderFooter($APEfooterData))) {
75 75
 			$info['error'][] = 'Error parsing APE footer at offset '.$thisfile_ape['tag_offset_end'];
76 76
 			return false;
77 77
 		}
@@ -282,7 +282,7 @@  discard block
 block discarded – undo
282 282
 							}
283 283
 						} elseif (is_string($this->inline_attachments)) {
284 284
 							$this->inline_attachments = rtrim(str_replace(array('/', '\\'), DIRECTORY_SEPARATOR, $this->inline_attachments), DIRECTORY_SEPARATOR);
285
-							if (!is_dir($this->inline_attachments) || !is_writable($this->inline_attachments)) {
285
+							if ( ! is_dir($this->inline_attachments) || ! is_writable($this->inline_attachments)) {
286 286
 								// cannot write, skip
287 287
 								$info['warning'][] = 'attachment at '.$thisfile_ape_items_current['offset'].' cannot be saved to "'.$this->inline_attachments.'" (not writable)';
288 288
 								unset($thisfile_ape_items_current['data']);
@@ -292,7 +292,7 @@  discard block
 block discarded – undo
292 292
 						// if we get this far, must be OK
293 293
 						if (is_string($this->inline_attachments)) {
294 294
 							$destination_filename = $this->inline_attachments.DIRECTORY_SEPARATOR.md5($info['filenamepath']).'_'.$thisfile_ape_items_current['data_offset'];
295
-							if (!file_exists($destination_filename) || is_writable($destination_filename)) {
295
+							if ( ! file_exists($destination_filename) || is_writable($destination_filename)) {
296 296
 								file_put_contents($destination_filename, $thisfile_ape_items_current['data']);
297 297
 							} else {
298 298
 								$info['warning'][] = 'attachment at '.$thisfile_ape_items_current['offset'].' cannot be saved to "'.$destination_filename.'" (not writable)';
@@ -300,7 +300,7 @@  discard block
 block discarded – undo
300 300
 							$thisfile_ape_items_current['data_filename'] = $destination_filename;
301 301
 							unset($thisfile_ape_items_current['data']);
302 302
 						} else {
303
-							if (!isset($info['ape']['comments']['picture'])) {
303
+							if ( ! isset($info['ape']['comments']['picture'])) {
304 304
 								$info['ape']['comments']['picture'] = array();
305 305
 							}
306 306
 							$comments_picture_data = array();
@@ -338,17 +338,17 @@  discard block
 block discarded – undo
338 338
 		$headerfooterinfo['raw'] = array();
339 339
 		$headerfooterinfo_raw = &$headerfooterinfo['raw'];
340 340
 
341
-		$headerfooterinfo_raw['footer_tag']   =                  substr($APEheaderFooterData,  0, 8);
341
+		$headerfooterinfo_raw['footer_tag'] = substr($APEheaderFooterData, 0, 8);
342 342
 		if ($headerfooterinfo_raw['footer_tag'] != 'APETAGEX') {
343 343
 			return false;
344 344
 		}
345
-		$headerfooterinfo_raw['version']      = getid3_lib::LittleEndian2Int(substr($APEheaderFooterData,  8, 4));
345
+		$headerfooterinfo_raw['version']      = getid3_lib::LittleEndian2Int(substr($APEheaderFooterData, 8, 4));
346 346
 		$headerfooterinfo_raw['tagsize']      = getid3_lib::LittleEndian2Int(substr($APEheaderFooterData, 12, 4));
347 347
 		$headerfooterinfo_raw['tag_items']    = getid3_lib::LittleEndian2Int(substr($APEheaderFooterData, 16, 4));
348 348
 		$headerfooterinfo_raw['global_flags'] = getid3_lib::LittleEndian2Int(substr($APEheaderFooterData, 20, 4));
349
-		$headerfooterinfo_raw['reserved']     =                              substr($APEheaderFooterData, 24, 8);
349
+		$headerfooterinfo_raw['reserved']     = substr($APEheaderFooterData, 24, 8);
350 350
 
351
-		$headerfooterinfo['tag_version']         = $headerfooterinfo_raw['version'] / 1000;
351
+		$headerfooterinfo['tag_version'] = $headerfooterinfo_raw['version'] / 1000;
352 352
 		if ($headerfooterinfo['tag_version'] >= 2) {
353 353
 			$headerfooterinfo['flags'] = $this->parseAPEtagFlags($headerfooterinfo_raw['global_flags']);
354 354
 		}
@@ -362,7 +362,7 @@  discard block
 block discarded – undo
362 362
 		$flags['header']            = (bool) ($rawflagint & 0x80000000);
363 363
 		$flags['footer']            = (bool) ($rawflagint & 0x40000000);
364 364
 		$flags['this_is_header']    = (bool) ($rawflagint & 0x20000000);
365
-		$flags['item_contents_raw'] =        ($rawflagint & 0x00000006) >> 1;
365
+		$flags['item_contents_raw'] = ($rawflagint & 0x00000006) >> 1;
366 366
 		$flags['read_only']         = (bool) ($rawflagint & 0x00000001);
367 367
 
368 368
 		$flags['item_contents']     = $this->APEcontentTypeFlagLookup($flags['item_contents_raw']);
Please login to merge, or discard this patch.
src/wp-includes/ID3/module.tag.id3v2.php 3 patches
Doc Comments   +27 added lines patch added patch discarded remove patch
@@ -2596,6 +2596,9 @@  discard block
 block discarded – undo
2596 2596
 
2597 2597
 
2598 2598
 
2599
+	/**
2600
+	 * @param string $languagecode
2601
+	 */
2599 2602
 	public static function LanguageLookup($languagecode, $casesensitive=false) {
2600 2603
 
2601 2604
 		if (!$casesensitive) {
@@ -3052,6 +3055,9 @@  discard block
 block discarded – undo
3052 3055
 	}
3053 3056
 
3054 3057
 
3058
+	/**
3059
+	 * @param string $index
3060
+	 */
3055 3061
 	public static function ETCOEventLookup($index) {
3056 3062
 		if (($index >= 0x17) && ($index <= 0xDF)) {
3057 3063
 			return 'reserved for future use';
@@ -3095,6 +3101,9 @@  discard block
 block discarded – undo
3095 3101
 		return (isset($EventLookup[$index]) ? $EventLookup[$index] : '');
3096 3102
 	}
3097 3103
 
3104
+	/**
3105
+	 * @param integer $index
3106
+	 */
3098 3107
 	public static function SYTLContentTypeLookup($index) {
3099 3108
 		static $SYTLContentTypeLookup = array(
3100 3109
 			0x00 => 'other',
@@ -3111,6 +3120,9 @@  discard block
 block discarded – undo
3111 3120
 		return (isset($SYTLContentTypeLookup[$index]) ? $SYTLContentTypeLookup[$index] : '');
3112 3121
 	}
3113 3122
 
3123
+	/**
3124
+	 * @param integer $index
3125
+	 */
3114 3126
 	public static function APICPictureTypeLookup($index, $returnarray=false) {
3115 3127
 		static $APICPictureTypeLookup = array(
3116 3128
 			0x00 => 'Other',
@@ -3141,6 +3153,9 @@  discard block
 block discarded – undo
3141 3153
 		return (isset($APICPictureTypeLookup[$index]) ? $APICPictureTypeLookup[$index] : '');
3142 3154
 	}
3143 3155
 
3156
+	/**
3157
+	 * @param integer $index
3158
+	 */
3144 3159
 	public static function COMRReceivedAsLookup($index) {
3145 3160
 		static $COMRReceivedAsLookup = array(
3146 3161
 			0x00 => 'Other',
@@ -3157,6 +3172,9 @@  discard block
 block discarded – undo
3157 3172
 		return (isset($COMRReceivedAsLookup[$index]) ? $COMRReceivedAsLookup[$index] : '');
3158 3173
 	}
3159 3174
 
3175
+	/**
3176
+	 * @param integer $index
3177
+	 */
3160 3178
 	public static function RVA2ChannelTypeLookup($index) {
3161 3179
 		static $RVA2ChannelTypeLookup = array(
3162 3180
 			0x00 => 'Other',
@@ -3536,6 +3554,9 @@  discard block
 block discarded – undo
3536 3554
 		return getid3_lib::EmbeddedLookup($framename, $begin, __LINE__, __FILE__, 'id3v2-framename_short');
3537 3555
 	}
3538 3556
 
3557
+	/**
3558
+	 * @param integer $encoding
3559
+	 */
3539 3560
 	public static function TextEncodingTerminatorLookup($encoding) {
3540 3561
 		// http://www.id3.org/id3v2.4.0-structure.txt
3541 3562
 		// Frames that allow different types of text encoding contains a text encoding description byte. Possible encodings:
@@ -3562,6 +3583,9 @@  discard block
 block discarded – undo
3562 3583
 		return (isset($TextEncodingNameLookup[$encoding]) ? $TextEncodingNameLookup[$encoding] : 'ISO-8859-1');
3563 3584
 	}
3564 3585
 
3586
+	/**
3587
+	 * @param string $framename
3588
+	 */
3565 3589
 	public static function IsValidID3v2FrameName($framename, $id3v2majorversion) {
3566 3590
 		switch ($id3v2majorversion) {
3567 3591
 			case 2:
@@ -3591,6 +3615,9 @@  discard block
 block discarded – undo
3591 3615
 		return true;
3592 3616
 	}
3593 3617
 
3618
+	/**
3619
+	 * @param string $datestamp
3620
+	 */
3594 3621
 	public static function IsValidDateStampString($datestamp) {
3595 3622
 		if (strlen($datestamp) != 8) {
3596 3623
 			return false;
Please login to merge, or discard this patch.
Indentation   +9 added lines, -14 removed lines patch added patch discarded remove patch
@@ -1972,9 +1972,9 @@  discard block
 block discarded – undo
1972 1972
 			// Element ID      <text string> $00
1973 1973
 			// Start time      $xx xx xx xx
1974 1974
 			// End time        $xx xx xx xx
1975
-            // Start offset    $xx xx xx xx
1976
-            // End offset      $xx xx xx xx
1977
-            // <Optional embedded sub-frames>
1975
+			// Start offset    $xx xx xx xx
1976
+			// End offset      $xx xx xx xx
1977
+			// <Optional embedded sub-frames>
1978 1978
 
1979 1979
 			$frame_offset = 0;
1980 1980
 			@list($parsedFrame['element_id']) = explode("\x00", $parsedFrame['data'], 2);
@@ -2069,7 +2069,7 @@  discard block
 block discarded – undo
2069 2069
 			// CTOC flags        %xx
2070 2070
 			// Entry count       $xx
2071 2071
 			// Child Element ID  <string>$00   /* zero or more child CHAP or CTOC entries */
2072
-            // <Optional embedded sub-frames>
2072
+			// <Optional embedded sub-frames>
2073 2073
 
2074 2074
 			$frame_offset = 0;
2075 2075
 			@list($parsedFrame['element_id']) = explode("\x00", $parsedFrame['data'], 2);
@@ -2392,8 +2392,7 @@  discard block
 block discarded – undo
2392 2392
 			ZAR	Rand
2393 2393
 			ZMK	Kwacha
2394 2394
 			ZWD	Zimbabwe Dollars
2395
-
2396
-		*/
2395
+		 */
2397 2396
 
2398 2397
 		return getid3_lib::EmbeddedLookup($currencyid, $begin, __LINE__, __FILE__, 'id3v2-currency-units');
2399 2398
 	}
@@ -2588,8 +2587,7 @@  discard block
 block discarded – undo
2588 2587
 			ZAR	South Africa
2589 2588
 			ZMK	Zambia
2590 2589
 			ZWD	Zimbabwe
2591
-
2592
-		*/
2590
+		 */
2593 2591
 
2594 2592
 		return getid3_lib::EmbeddedLookup($currencyid, $begin, __LINE__, __FILE__, 'id3v2-currency-country');
2595 2593
 	}
@@ -3045,8 +3043,7 @@  discard block
 block discarded – undo
3045 3043
 			zho	Chinese
3046 3044
 			zul	Zulu
3047 3045
 			zun	Zuni
3048
-
3049
-		*/
3046
+		 */
3050 3047
 
3051 3048
 		return getid3_lib::EmbeddedLookup($languagecode, $begin, __LINE__, __FILE__, 'id3v2-languagecode');
3052 3049
 	}
@@ -3346,8 +3343,7 @@  discard block
 block discarded – undo
3346 3343
 			TFEA	Featured Artist
3347 3344
 			TSTU	Recording Studio
3348 3345
 			rgad	Replay Gain Adjustment
3349
-
3350
-		*/
3346
+		 */
3351 3347
 
3352 3348
 		return getid3_lib::EmbeddedLookup($framename, $begin, __LINE__, __FILE__, 'id3v2-framename_long');
3353 3349
 
@@ -3530,8 +3526,7 @@  discard block
 block discarded – undo
3530 3526
 			TFEA	featured_artist
3531 3527
 			TSTU	recording_studio
3532 3528
 			rgad	replay_gain_adjustment
3533
-
3534
-		*/
3529
+		 */
3535 3530
 
3536 3531
 		return getid3_lib::EmbeddedLookup($framename, $begin, __LINE__, __FILE__, 'id3v2-framename_short');
3537 3532
 	}
Please login to merge, or discard this patch.
Spacing   +63 added lines, -63 removed lines patch added patch discarded remove patch
@@ -48,13 +48,13 @@  discard block
 block discarded – undo
48 48
 		// shortcuts
49 49
 		$info['id3v2']['header'] = true;
50 50
 		$thisfile_id3v2                  = &$info['id3v2'];
51
-		$thisfile_id3v2['flags']         =  array();
51
+		$thisfile_id3v2['flags']         = array();
52 52
 		$thisfile_id3v2_flags            = &$thisfile_id3v2['flags'];
53 53
 
54 54
 
55 55
 		$this->fseek($this->StartingOffset);
56 56
 		$header = $this->fread(10);
57
-		if (substr($header, 0, 3) == 'ID3'  &&  strlen($header) == 10) {
57
+		if (substr($header, 0, 3) == 'ID3' && strlen($header) == 10) {
58 58
 
59 59
 			$thisfile_id3v2['majorversion'] = ord($header{3});
60 60
 			$thisfile_id3v2['minorversion'] = ord($header{4});
@@ -124,10 +124,10 @@  discard block
 block discarded – undo
124 124
 	//        Flags         $xx xx
125 125
 
126 126
 		$sizeofframes = $thisfile_id3v2['headerlength'] - 10; // not including 10-byte initial header
127
-		if (!empty($thisfile_id3v2['exthead']['length'])) {
127
+		if ( ! empty($thisfile_id3v2['exthead']['length'])) {
128 128
 			$sizeofframes -= ($thisfile_id3v2['exthead']['length'] + 4);
129 129
 		}
130
-		if (!empty($thisfile_id3v2_flags['isfooter'])) {
130
+		if ( ! empty($thisfile_id3v2_flags['isfooter'])) {
131 131
 			$sizeofframes -= 10; // footer takes last 10 bytes of ID3v2 header, after frame data, before audio
132 132
 		}
133 133
 		if ($sizeofframes > 0) {
@@ -135,7 +135,7 @@  discard block
 block discarded – undo
135 135
 			$framedata = $this->fread($sizeofframes); // read all frames from file into $framedata variable
136 136
 
137 137
 			//    if entire frame data is unsynched, de-unsynch it now (ID3v2.3.x)
138
-			if (!empty($thisfile_id3v2_flags['unsynch']) && ($id3v2_majorversion <= 3)) {
138
+			if ( ! empty($thisfile_id3v2_flags['unsynch']) && ($id3v2_majorversion <= 3)) {
139 139
 				$framedata = $this->DeUnsynchronise($framedata);
140 140
 			}
141 141
 			//        [in ID3v2.4.0] Unsynchronisation [S:6.1] is done on frame level, instead
@@ -150,7 +150,7 @@  discard block
 block discarded – undo
150 150
 
151 151
 
152 152
 			//    Extended Header
153
-			if (!empty($thisfile_id3v2_flags['exthead'])) {
153
+			if ( ! empty($thisfile_id3v2_flags['exthead'])) {
154 154
 				$extended_header_offset = 0;
155 155
 
156 156
 				if ($id3v2_majorversion == 3) {
@@ -272,7 +272,7 @@  discard block
 block discarded – undo
272 272
 					// Flags     $xx xx
273 273
 
274 274
 					$frame_header = substr($framedata, 0, 6); // take next 6 bytes for header
275
-					$framedata    = substr($framedata, 6);    // and leave the rest in $framedata
275
+					$framedata    = substr($framedata, 6); // and leave the rest in $framedata
276 276
 					$frame_name   = substr($frame_header, 0, 3);
277 277
 					$frame_size   = getid3_lib::BigEndian2Int(substr($frame_header, 3, 3), 0);
278 278
 					$frame_flags  = 0; // not used for anything in ID3v2.2, just set to avoid E_NOTICEs
@@ -284,7 +284,7 @@  discard block
 block discarded – undo
284 284
 					// Flags     $xx xx
285 285
 
286 286
 					$frame_header = substr($framedata, 0, 10); // take next 10 bytes for header
287
-					$framedata    = substr($framedata, 10);    // and leave the rest in $framedata
287
+					$framedata    = substr($framedata, 10); // and leave the rest in $framedata
288 288
 
289 289
 					$frame_name = substr($frame_header, 0, 4);
290 290
 					if ($id3v2_majorversion == 3) {
@@ -379,7 +379,7 @@  discard block
 block discarded – undo
379 379
 						$info['warning'][] = 'Invalid ID3v2 frame size, aborting.';
380 380
 
381 381
 					}
382
-					if (!$this->IsValidID3v2FrameName($frame_name, $id3v2_majorversion)) {
382
+					if ( ! $this->IsValidID3v2FrameName($frame_name, $id3v2_majorversion)) {
383 383
 
384 384
 						switch ($frame_name) {
385 385
 							case "\x00\x00".'MP':
@@ -397,7 +397,7 @@  discard block
 block discarded – undo
397 397
 								break;
398 398
 						}
399 399
 
400
-					} elseif (!isset($framedata) || ($frame_size > strlen($framedata))) {
400
+					} elseif ( ! isset($framedata) || ($frame_size > strlen($framedata))) {
401 401
 
402 402
 						$info['error'][] = 'error parsing "'.$frame_name.'" ('.$framedataoffset.' bytes into the ID3v2.'.$id3v2_majorversion.' tag). (ERROR: $frame_size ('.$frame_size.') > strlen($framedata) ('.(isset($framedata) ? strlen($framedata) : 'null').')).';
403 403
 
@@ -456,27 +456,27 @@  discard block
 block discarded – undo
456 456
 			}
457 457
 		}
458 458
 
459
-		if (!isset($thisfile_id3v2['comments']['year']) && !empty($thisfile_id3v2['comments']['recording_time'][0]) && preg_match('#^([0-9]{4})#', trim($thisfile_id3v2['comments']['recording_time'][0]), $matches)) {
459
+		if ( ! isset($thisfile_id3v2['comments']['year']) && ! empty($thisfile_id3v2['comments']['recording_time'][0]) && preg_match('#^([0-9]{4})#', trim($thisfile_id3v2['comments']['recording_time'][0]), $matches)) {
460 460
 			$thisfile_id3v2['comments']['year'] = array($matches[1]);
461 461
 		}
462 462
 
463 463
 
464
-		if (!empty($thisfile_id3v2['TXXX'])) {
464
+		if ( ! empty($thisfile_id3v2['TXXX'])) {
465 465
 			// MediaMonkey does this, maybe others: write a blank RGAD frame, but put replay-gain adjustment values in TXXX frames
466 466
 			foreach ($thisfile_id3v2['TXXX'] as $txxx_array) {
467 467
 				switch ($txxx_array['description']) {
468 468
 					case 'replaygain_track_gain':
469
-						if (empty($info['replay_gain']['track']['adjustment']) && !empty($txxx_array['data'])) {
469
+						if (empty($info['replay_gain']['track']['adjustment']) && ! empty($txxx_array['data'])) {
470 470
 							$info['replay_gain']['track']['adjustment'] = floatval(trim(str_replace('dB', '', $txxx_array['data'])));
471 471
 						}
472 472
 						break;
473 473
 					case 'replaygain_track_peak':
474
-						if (empty($info['replay_gain']['track']['peak']) && !empty($txxx_array['data'])) {
474
+						if (empty($info['replay_gain']['track']['peak']) && ! empty($txxx_array['data'])) {
475 475
 							$info['replay_gain']['track']['peak'] = floatval($txxx_array['data']);
476 476
 						}
477 477
 						break;
478 478
 					case 'replaygain_album_gain':
479
-						if (empty($info['replay_gain']['album']['adjustment']) && !empty($txxx_array['data'])) {
479
+						if (empty($info['replay_gain']['album']['adjustment']) && ! empty($txxx_array['data'])) {
480 480
 							$info['replay_gain']['album']['adjustment'] = floatval(trim(str_replace('dB', '', $txxx_array['data'])));
481 481
 						}
482 482
 						break;
@@ -524,7 +524,7 @@  discard block
 block discarded – undo
524 524
 		$info = &$this->getid3->info;
525 525
 		$id3v2_majorversion = $info['id3v2']['majorversion'];
526 526
 
527
-		$parsedFrame['framenamelong']  = $this->FrameNameLongLookup($parsedFrame['frame_name']);
527
+		$parsedFrame['framenamelong'] = $this->FrameNameLongLookup($parsedFrame['frame_name']);
528 528
 		if (empty($parsedFrame['framenamelong'])) {
529 529
 			unset($parsedFrame['framenamelong']);
530 530
 		}
@@ -563,14 +563,14 @@  discard block
 block discarded – undo
563 563
 
564 564
 				if ($parsedFrame['flags']['DataLengthIndicator']) {
565 565
 					$parsedFrame['data_length_indicator'] = getid3_lib::BigEndian2Int(substr($parsedFrame['data'], 0, 4), 1);
566
-					$parsedFrame['data']                  =                           substr($parsedFrame['data'], 4);
566
+					$parsedFrame['data']                  = substr($parsedFrame['data'], 4);
567 567
 				}
568 568
 			}
569 569
 
570 570
 			//    Frame-level de-compression
571 571
 			if ($parsedFrame['flags']['compression']) {
572 572
 				$parsedFrame['decompressed_size'] = getid3_lib::BigEndian2Int(substr($parsedFrame['data'], 0, 4));
573
-				if (!function_exists('gzuncompress')) {
573
+				if ( ! function_exists('gzuncompress')) {
574 574
 					$info['warning'][] = 'gzuncompress() support required to decompress ID3v2 frame "'.$parsedFrame['frame_name'].'"';
575 575
 				} else {
576 576
 					if ($decompresseddata = @gzuncompress(substr($parsedFrame['data'], 4))) {
@@ -584,7 +584,7 @@  discard block
 block discarded – undo
584 584
 			}
585 585
 		}
586 586
 
587
-		if (!empty($parsedFrame['flags']['DataLengthIndicator'])) {
587
+		if ( ! empty($parsedFrame['flags']['DataLengthIndicator'])) {
588 588
 			if ($parsedFrame['data_length_indicator'] != strlen($parsedFrame['data'])) {
589 589
 				$info['warning'][] = 'ID3v2 frame "'.$parsedFrame['frame_name'].'" should be '.$parsedFrame['data_length_indicator'].' bytes long according to DataLengthIndicator, but found '.strlen($parsedFrame['data']).' bytes of data';
590 590
 			}
@@ -643,9 +643,9 @@  discard block
 block discarded – undo
643 643
 
644 644
 			$parsedFrame['description'] = trim(getid3_lib::iconv_fallback($parsedFrame['encoding'], $info['id3v2']['encoding'], $frame_description));
645 645
 			$parsedFrame['data'] = substr($parsedFrame['data'], $frame_terminatorpos + strlen($frame_textencoding_terminator));
646
-			if (!empty($parsedFrame['framenameshort']) && !empty($parsedFrame['data'])) {
646
+			if ( ! empty($parsedFrame['framenameshort']) && ! empty($parsedFrame['data'])) {
647 647
 				$commentkey = ($parsedFrame['description'] ? $parsedFrame['description'] : (isset($info['id3v2']['comments'][$parsedFrame['framenameshort']]) ? count($info['id3v2']['comments'][$parsedFrame['framenameshort']]) : 0));
648
-				if (!isset($info['id3v2']['comments'][$parsedFrame['framenameshort']]) || !array_key_exists($commentkey, $info['id3v2']['comments'][$parsedFrame['framenameshort']])) {
648
+				if ( ! isset($info['id3v2']['comments'][$parsedFrame['framenameshort']]) || ! array_key_exists($commentkey, $info['id3v2']['comments'][$parsedFrame['framenameshort']])) {
649 649
 					$info['id3v2']['comments'][$parsedFrame['framenameshort']][$commentkey] = trim(getid3_lib::iconv_fallback($parsedFrame['encoding'], $info['id3v2']['encoding'], $parsedFrame['data']));
650 650
 				} else {
651 651
 					$info['id3v2']['comments'][$parsedFrame['framenameshort']][]            = trim(getid3_lib::iconv_fallback($parsedFrame['encoding'], $info['id3v2']['encoding'], $parsedFrame['data']));
@@ -672,7 +672,7 @@  discard block
 block discarded – undo
672 672
 			$parsedFrame['encodingid'] = $frame_textencoding;
673 673
 			$parsedFrame['encoding']   = $this->TextEncodingNameLookup($frame_textencoding);
674 674
 
675
-			if (!empty($parsedFrame['framenameshort']) && !empty($parsedFrame['data'])) {
675
+			if ( ! empty($parsedFrame['framenameshort']) && ! empty($parsedFrame['data'])) {
676 676
 				// ID3v2.3 specs say that TPE1 (and others) can contain multiple artist values separated with /
677 677
 				// This of course breaks when an artist name contains slash character, e.g. "AC/DC"
678 678
 				// MP3tag (maybe others) implement alternative system where multiple artists are null-separated, which makes more sense
@@ -700,7 +700,7 @@  discard block
 block discarded – undo
700 700
 				$Txxx_elements[] = substr($parsedFrame['data'], $Txxx_elements_start_offset, $i - $Txxx_elements_start_offset);
701 701
 				foreach ($Txxx_elements as $Txxx_element) {
702 702
 					$string = getid3_lib::iconv_fallback($parsedFrame['encoding'], $info['id3v2']['encoding'], $Txxx_element);
703
-					if (!empty($string)) {
703
+					if ( ! empty($string)) {
704 704
 						$info['id3v2']['comments'][$parsedFrame['framenameshort']][] = $string;
705 705
 					}
706 706
 				}
@@ -752,7 +752,7 @@  discard block
 block discarded – undo
752 752
 
753 753
 			$parsedFrame['url']         = $frame_urldata;
754 754
 			$parsedFrame['description'] = $frame_description;
755
-			if (!empty($parsedFrame['framenameshort']) && $parsedFrame['url']) {
755
+			if ( ! empty($parsedFrame['framenameshort']) && $parsedFrame['url']) {
756 756
 				$info['id3v2']['comments'][$parsedFrame['framenameshort']][] = getid3_lib::iconv_fallback($parsedFrame['encoding'], $info['id3v2']['encoding'], $parsedFrame['url']);
757 757
 			}
758 758
 			unset($parsedFrame['data']);
@@ -766,7 +766,7 @@  discard block
 block discarded – undo
766 766
 			// URL              <text string>
767 767
 
768 768
 			$parsedFrame['url'] = trim($parsedFrame['data']);
769
-			if (!empty($parsedFrame['framenameshort']) && $parsedFrame['url']) {
769
+			if ( ! empty($parsedFrame['framenameshort']) && $parsedFrame['url']) {
770 770
 				$info['id3v2']['comments'][$parsedFrame['framenameshort']][] = $parsedFrame['url'];
771 771
 			}
772 772
 			unset($parsedFrame['data']);
@@ -847,7 +847,7 @@  discard block
 block discarded – undo
847 847
 			}
848 848
 			$parsedFrame['data'] = $IPLS_parts;
849 849
 
850
-			if (!empty($parsedFrame['framenameshort']) && !empty($parsedFrame['data'])) {
850
+			if ( ! empty($parsedFrame['framenameshort']) && ! empty($parsedFrame['data'])) {
851 851
 				$info['id3v2']['comments'][$parsedFrame['framenameshort']][] = $parsedFrame['data'];
852 852
 			}
853 853
 
@@ -858,7 +858,7 @@  discard block
 block discarded – undo
858 858
 			// <Header for 'Music CD identifier', ID: 'MCDI'>
859 859
 			// CD TOC                <binary data>
860 860
 
861
-			if (!empty($parsedFrame['framenameshort']) && !empty($parsedFrame['data'])) {
861
+			if ( ! empty($parsedFrame['framenameshort']) && ! empty($parsedFrame['data'])) {
862 862
 				$info['id3v2']['comments'][$parsedFrame['framenameshort']][] = $parsedFrame['data'];
863 863
 			}
864 864
 
@@ -983,7 +983,7 @@  discard block
 block discarded – undo
983 983
 			$parsedFrame['language']     = $frame_language;
984 984
 			$parsedFrame['languagename'] = $this->LanguageLookup($frame_language, false);
985 985
 			$parsedFrame['description']  = $frame_description;
986
-			if (!empty($parsedFrame['framenameshort']) && !empty($parsedFrame['data'])) {
986
+			if ( ! empty($parsedFrame['framenameshort']) && ! empty($parsedFrame['data'])) {
987 987
 				$info['id3v2']['comments'][$parsedFrame['framenameshort']][] = getid3_lib::iconv_fallback($parsedFrame['encoding'], $info['id3v2']['encoding'], $parsedFrame['data']);
988 988
 			}
989 989
 			unset($parsedFrame['data']);
@@ -1091,9 +1091,9 @@  discard block
 block discarded – undo
1091 1091
 				$parsedFrame['languagename'] = $this->LanguageLookup($frame_language, false);
1092 1092
 				$parsedFrame['description']  = $frame_description;
1093 1093
 				$parsedFrame['data']         = $frame_text;
1094
-				if (!empty($parsedFrame['framenameshort']) && !empty($parsedFrame['data'])) {
1095
-					$commentkey = ($parsedFrame['description'] ? $parsedFrame['description'] : (!empty($info['id3v2']['comments'][$parsedFrame['framenameshort']]) ? count($info['id3v2']['comments'][$parsedFrame['framenameshort']]) : 0));
1096
-					if (!isset($info['id3v2']['comments'][$parsedFrame['framenameshort']]) || !array_key_exists($commentkey, $info['id3v2']['comments'][$parsedFrame['framenameshort']])) {
1094
+				if ( ! empty($parsedFrame['framenameshort']) && ! empty($parsedFrame['data'])) {
1095
+					$commentkey = ($parsedFrame['description'] ? $parsedFrame['description'] : ( ! empty($info['id3v2']['comments'][$parsedFrame['framenameshort']]) ? count($info['id3v2']['comments'][$parsedFrame['framenameshort']]) : 0));
1096
+					if ( ! isset($info['id3v2']['comments'][$parsedFrame['framenameshort']]) || ! array_key_exists($commentkey, $info['id3v2']['comments'][$parsedFrame['framenameshort']])) {
1097 1097
 						$info['id3v2']['comments'][$parsedFrame['framenameshort']][$commentkey] = getid3_lib::iconv_fallback($parsedFrame['encoding'], $info['id3v2']['encoding'], $parsedFrame['data']);
1098 1098
 					} else {
1099 1099
 						$info['id3v2']['comments'][$parsedFrame['framenameshort']][]            = getid3_lib::iconv_fallback($parsedFrame['encoding'], $info['id3v2']['encoding'], $parsedFrame['data']);
@@ -1136,7 +1136,7 @@  discard block
 block discarded – undo
1136 1136
 					break;
1137 1137
 				}
1138 1138
 				$frame_bytespeakvolume = ceil($parsedFrame[$RVA2channelcounter]['bitspeakvolume'] / 8);
1139
-				$parsedFrame[$RVA2channelcounter]['peakvolume']     = getid3_lib::BigEndian2Int(substr($frame_remainingdata, $frame_offset, $frame_bytespeakvolume));
1139
+				$parsedFrame[$RVA2channelcounter]['peakvolume'] = getid3_lib::BigEndian2Int(substr($frame_remainingdata, $frame_offset, $frame_bytespeakvolume));
1140 1140
 				$frame_remainingdata = substr($frame_remainingdata, $frame_offset + $frame_bytespeakvolume);
1141 1141
 				$RVA2channelcounter++;
1142 1142
 			}
@@ -1404,7 +1404,7 @@  discard block
 block discarded – undo
1404 1404
 				$imageinfo = array();
1405 1405
 				$imagechunkcheck = getid3_lib::GetDataImageSize($parsedFrame['data'], $imageinfo);
1406 1406
 				if (($imagechunkcheck[2] >= 1) && ($imagechunkcheck[2] <= 3)) {
1407
-					$parsedFrame['image_mime']       = 'image/'.getid3_lib::ImageTypesLookup($imagechunkcheck[2]);
1407
+					$parsedFrame['image_mime'] = 'image/'.getid3_lib::ImageTypesLookup($imagechunkcheck[2]);
1408 1408
 					if ($imagechunkcheck[0]) {
1409 1409
 						$parsedFrame['image_width']  = $imagechunkcheck[0];
1410 1410
 					}
@@ -1432,7 +1432,7 @@  discard block
 block discarded – undo
1432 1432
 */
1433 1433
 					} elseif (is_string($this->getid3->option_save_attachments)) {
1434 1434
 						$dir = rtrim(str_replace(array('/', '\\'), DIRECTORY_SEPARATOR, $this->getid3->option_save_attachments), DIRECTORY_SEPARATOR);
1435
-						if (!is_dir($dir) || !is_writable($dir)) {
1435
+						if ( ! is_dir($dir) || ! is_writable($dir)) {
1436 1436
 							// cannot write, skip
1437 1437
 							$info['warning'][] = 'attachment at '.$frame_offset.' cannot be saved to "'.$dir.'" (not writable)';
1438 1438
 							unset($parsedFrame['data']);
@@ -1442,7 +1442,7 @@  discard block
 block discarded – undo
1442 1442
 					// if we get this far, must be OK
1443 1443
 					if (is_string($this->getid3->option_save_attachments)) {
1444 1444
 						$destination_filename = $dir.DIRECTORY_SEPARATOR.md5($info['filenamepath']).'_'.$frame_offset;
1445
-						if (!file_exists($destination_filename) || is_writable($destination_filename)) {
1445
+						if ( ! file_exists($destination_filename) || is_writable($destination_filename)) {
1446 1446
 							file_put_contents($destination_filename, $parsedFrame['data']);
1447 1447
 						} else {
1448 1448
 							$info['warning'][] = 'attachment at '.$frame_offset.' cannot be saved to "'.$destination_filename.'" (not writable)';
@@ -1450,8 +1450,8 @@  discard block
 block discarded – undo
1450 1450
 						$parsedFrame['data_filename'] = $destination_filename;
1451 1451
 						unset($parsedFrame['data']);
1452 1452
 					} else {
1453
-						if (!empty($parsedFrame['framenameshort']) && !empty($parsedFrame['data'])) {
1454
-							if (!isset($info['id3v2']['comments']['picture'])) {
1453
+						if ( ! empty($parsedFrame['framenameshort']) && ! empty($parsedFrame['data'])) {
1454
+							if ( ! isset($info['id3v2']['comments']['picture'])) {
1455 1455
 								$info['id3v2']['comments']['picture'] = array();
1456 1456
 							}
1457 1457
 							$comments_picture_data = array();
@@ -1530,7 +1530,7 @@  discard block
 block discarded – undo
1530 1530
 			// <Header for 'Play counter', ID: 'PCNT'>
1531 1531
 			// Counter        $xx xx xx xx (xx ...)
1532 1532
 
1533
-			$parsedFrame['data']          = getid3_lib::BigEndian2Int($parsedFrame['data']);
1533
+			$parsedFrame['data'] = getid3_lib::BigEndian2Int($parsedFrame['data']);
1534 1534
 
1535 1535
 
1536 1536
 		} elseif ((($id3v2_majorversion >= 3) && ($parsedFrame['frame_name'] == 'POPM')) || // 4.17  POPM Popularimeter
@@ -1654,7 +1654,7 @@  discard block
 block discarded – undo
1654 1654
 			$parsedFrame['url'] = $frame_url;
1655 1655
 
1656 1656
 			$parsedFrame['additionaldata'] = (string) substr($parsedFrame['data'], $frame_offset);
1657
-			if (!empty($parsedFrame['framenameshort']) && $parsedFrame['url']) {
1657
+			if ( ! empty($parsedFrame['framenameshort']) && $parsedFrame['url']) {
1658 1658
 				$info['id3v2']['comments'][$parsedFrame['framenameshort']][] = getid3_lib::iconv_fallback_iso88591_utf8($parsedFrame['url']);
1659 1659
 			}
1660 1660
 			unset($parsedFrame['data']);
@@ -1693,7 +1693,7 @@  discard block
 block discarded – undo
1693 1693
 			$parsedFrame['encoding']     = $this->TextEncodingNameLookup($frame_textencoding);
1694 1694
 
1695 1695
 			$parsedFrame['data']         = (string) substr($parsedFrame['data'], $frame_offset);
1696
-			if (!empty($parsedFrame['framenameshort']) && !empty($parsedFrame['data'])) {
1696
+			if ( ! empty($parsedFrame['framenameshort']) && ! empty($parsedFrame['data'])) {
1697 1697
 				$info['id3v2']['comments'][$parsedFrame['framenameshort']][] = getid3_lib::iconv_fallback($parsedFrame['encoding'], $info['id3v2']['encoding'], $parsedFrame['data']);
1698 1698
 			}
1699 1699
 			unset($parsedFrame['data']);
@@ -1724,8 +1724,8 @@  discard block
 block discarded – undo
1724 1724
 			$parsedFrame['pricepaid']['value']      = substr($frame_pricepaid, 3);
1725 1725
 
1726 1726
 			$parsedFrame['purchasedate'] = substr($parsedFrame['data'], $frame_offset, 8);
1727
-			if (!$this->IsValidDateStampString($parsedFrame['purchasedate'])) {
1728
-				$parsedFrame['purchasedateunix'] = mktime (0, 0, 0, substr($parsedFrame['purchasedate'], 4, 2), substr($parsedFrame['purchasedate'], 6, 2), substr($parsedFrame['purchasedate'], 0, 4));
1727
+			if ( ! $this->IsValidDateStampString($parsedFrame['purchasedate'])) {
1728
+				$parsedFrame['purchasedateunix'] = mktime(0, 0, 0, substr($parsedFrame['purchasedate'], 4, 2), substr($parsedFrame['purchasedate'], 6, 2), substr($parsedFrame['purchasedate'], 0, 4));
1729 1729
 			}
1730 1730
 			$frame_offset += 8;
1731 1731
 
@@ -1896,7 +1896,7 @@  discard block
 block discarded – undo
1896 1896
 			// Minimum offset to next tag       $xx xx xx xx
1897 1897
 
1898 1898
 			$frame_offset = 0;
1899
-			$parsedFrame['data']          = getid3_lib::BigEndian2Int(substr($parsedFrame['data'], $frame_offset, 4));
1899
+			$parsedFrame['data'] = getid3_lib::BigEndian2Int(substr($parsedFrame['data'], $frame_offset, 4));
1900 1900
 
1901 1901
 
1902 1902
 		} elseif (($id3v2_majorversion >= 4) && ($parsedFrame['frame_name'] == 'ASPI')) { // 4.30  ASPI Audio seek point index (ID3v2.4+ only)
@@ -1990,7 +1990,7 @@  discard block
 block discarded – undo
1990 1990
 			$frame_offset += 4;
1991 1991
 			if (substr($parsedFrame['data'], $frame_offset, 4) != "\xFF\xFF\xFF\xFF") {
1992 1992
 				// "If these bytes are all set to 0xFF then the value should be ignored and the start time value should be utilized."
1993
-				$parsedFrame['offset_end']   = getid3_lib::BigEndian2Int(substr($parsedFrame['data'], $frame_offset, 4));
1993
+				$parsedFrame['offset_end'] = getid3_lib::BigEndian2Int(substr($parsedFrame['data'], $frame_offset, 4));
1994 1994
 			}
1995 1995
 			$frame_offset += 4;
1996 1996
 
@@ -1999,7 +1999,7 @@  discard block
 block discarded – undo
1999 1999
 				while ($frame_offset < strlen($parsedFrame['data'])) {
2000 2000
 					// <Optional embedded sub-frames>
2001 2001
 					$subframe = array();
2002
-					$subframe['name']      =                           substr($parsedFrame['data'], $frame_offset, 4);
2002
+					$subframe['name']      = substr($parsedFrame['data'], $frame_offset, 4);
2003 2003
 					$frame_offset += 4;
2004 2004
 					$subframe['size']      = getid3_lib::BigEndian2Int(substr($parsedFrame['data'], $frame_offset, 4));
2005 2005
 					$frame_offset += 4;
@@ -2013,9 +2013,9 @@  discard block
 block discarded – undo
2013 2013
 					$frame_offset += $subframe['size'];
2014 2014
 
2015 2015
 					$subframe['encodingid'] = ord(substr($subframe_rawdata, 0, 1));
2016
-					$subframe['text']       =     substr($subframe_rawdata, 1);
2016
+					$subframe['text']       = substr($subframe_rawdata, 1);
2017 2017
 					$subframe['encoding']   = $this->TextEncodingNameLookup($subframe['encodingid']);
2018
-					$encoding_converted_text = trim(getid3_lib::iconv_fallback($subframe['encoding'], $info['encoding'], $subframe['text']));;
2018
+					$encoding_converted_text = trim(getid3_lib::iconv_fallback($subframe['encoding'], $info['encoding'], $subframe['text'])); ;
2019 2019
 					switch (substr($encoding_converted_text, 0, 2)) {
2020 2020
 						case "\xFF\xFE":
2021 2021
 						case "\xFE\xFF":
@@ -2055,7 +2055,7 @@  discard block
 block discarded – undo
2055 2055
 					$id3v2_chapter_entry[$id3v2_chapter_key] = $parsedFrame[$id3v2_chapter_key];
2056 2056
 				}
2057 2057
 			}
2058
-			if (!isset($info['id3v2']['chapters'])) {
2058
+			if ( ! isset($info['id3v2']['chapters'])) {
2059 2059
 				$info['id3v2']['chapters'] = array();
2060 2060
 			}
2061 2061
 			$info['id3v2']['chapters'][] = $id3v2_chapter_entry;
@@ -2096,7 +2096,7 @@  discard block
 block discarded – undo
2096 2096
 				while ($frame_offset < strlen($parsedFrame['data'])) {
2097 2097
 					// <Optional embedded sub-frames>
2098 2098
 					$subframe = array();
2099
-					$subframe['name']      =                           substr($parsedFrame['data'], $frame_offset, 4);
2099
+					$subframe['name']      = substr($parsedFrame['data'], $frame_offset, 4);
2100 2100
 					$frame_offset += 4;
2101 2101
 					$subframe['size']      = getid3_lib::BigEndian2Int(substr($parsedFrame['data'], $frame_offset, 4));
2102 2102
 					$frame_offset += 4;
@@ -2110,9 +2110,9 @@  discard block
 block discarded – undo
2110 2110
 					$frame_offset += $subframe['size'];
2111 2111
 
2112 2112
 					$subframe['encodingid'] = ord(substr($subframe_rawdata, 0, 1));
2113
-					$subframe['text']       =     substr($subframe_rawdata, 1);
2113
+					$subframe['text']       = substr($subframe_rawdata, 1);
2114 2114
 					$subframe['encoding']   = $this->TextEncodingNameLookup($subframe['encodingid']);
2115
-					$encoding_converted_text = trim(getid3_lib::iconv_fallback($subframe['encoding'], $info['encoding'], $subframe['text']));;
2115
+					$encoding_converted_text = trim(getid3_lib::iconv_fallback($subframe['encoding'], $info['encoding'], $subframe['text'])); ;
2116 2116
 					switch (substr($encoding_converted_text, 0, 2)) {
2117 2117
 						case "\xFF\xFE":
2118 2118
 						case "\xFE\xFF":
@@ -2596,9 +2596,9 @@  discard block
 block discarded – undo
2596 2596
 
2597 2597
 
2598 2598
 
2599
-	public static function LanguageLookup($languagecode, $casesensitive=false) {
2599
+	public static function LanguageLookup($languagecode, $casesensitive = false) {
2600 2600
 
2601
-		if (!$casesensitive) {
2601
+		if ( ! $casesensitive) {
2602 2602
 			$languagecode = strtolower($languagecode);
2603 2603
 		}
2604 2604
 
@@ -3101,8 +3101,8 @@  discard block
 block discarded – undo
3101 3101
 			0x01 => 'lyrics',
3102 3102
 			0x02 => 'text transcription',
3103 3103
 			0x03 => 'movement/part name', // (e.g. 'Adagio')
3104
-			0x04 => 'events',             // (e.g. 'Don Quijote enters the stage')
3105
-			0x05 => 'chord',              // (e.g. 'Bb F Fsus')
3104
+			0x04 => 'events', // (e.g. 'Don Quijote enters the stage')
3105
+			0x05 => 'chord', // (e.g. 'Bb F Fsus')
3106 3106
 			0x06 => 'trivia/\'pop up\' information',
3107 3107
 			0x07 => 'URLs to webpages',
3108 3108
 			0x08 => 'URLs to images'
@@ -3111,7 +3111,7 @@  discard block
 block discarded – undo
3111 3111
 		return (isset($SYTLContentTypeLookup[$index]) ? $SYTLContentTypeLookup[$index] : '');
3112 3112
 	}
3113 3113
 
3114
-	public static function APICPictureTypeLookup($index, $returnarray=false) {
3114
+	public static function APICPictureTypeLookup($index, $returnarray = false) {
3115 3115
 		static $APICPictureTypeLookup = array(
3116 3116
 			0x00 => 'Other',
3117 3117
 			0x01 => '32x32 pixels \'file icon\' (PNG only)',
@@ -3540,10 +3540,10 @@  discard block
 block discarded – undo
3540 3540
 		// http://www.id3.org/id3v2.4.0-structure.txt
3541 3541
 		// Frames that allow different types of text encoding contains a text encoding description byte. Possible encodings:
3542 3542
 		static $TextEncodingTerminatorLookup = array(
3543
-			0   => "\x00",     // $00  ISO-8859-1. Terminated with $00.
3543
+			0   => "\x00", // $00  ISO-8859-1. Terminated with $00.
3544 3544
 			1   => "\x00\x00", // $01  UTF-16 encoded Unicode with BOM. All strings in the same frame SHALL have the same byteorder. Terminated with $00 00.
3545 3545
 			2   => "\x00\x00", // $02  UTF-16BE encoded Unicode without BOM. Terminated with $00 00.
3546
-			3   => "\x00",     // $03  UTF-8 encoded Unicode. Terminated with $00.
3546
+			3   => "\x00", // $03  UTF-8 encoded Unicode. Terminated with $00.
3547 3547
 			255 => "\x00\x00"
3548 3548
 		);
3549 3549
 		return (isset($TextEncodingTerminatorLookup[$encoding]) ? $TextEncodingTerminatorLookup[$encoding] : "\x00");
@@ -3554,9 +3554,9 @@  discard block
 block discarded – undo
3554 3554
 		// Frames that allow different types of text encoding contains a text encoding description byte. Possible encodings:
3555 3555
 		static $TextEncodingNameLookup = array(
3556 3556
 			0   => 'ISO-8859-1', // $00  ISO-8859-1. Terminated with $00.
3557
-			1   => 'UTF-16',     // $01  UTF-16 encoded Unicode with BOM. All strings in the same frame SHALL have the same byteorder. Terminated with $00 00.
3558
-			2   => 'UTF-16BE',   // $02  UTF-16BE encoded Unicode without BOM. Terminated with $00 00.
3559
-			3   => 'UTF-8',      // $03  UTF-8 encoded Unicode. Terminated with $00.
3557
+			1   => 'UTF-16', // $01  UTF-16 encoded Unicode with BOM. All strings in the same frame SHALL have the same byteorder. Terminated with $00 00.
3558
+			2   => 'UTF-16BE', // $02  UTF-16BE encoded Unicode without BOM. Terminated with $00 00.
3559
+			3   => 'UTF-8', // $03  UTF-8 encoded Unicode. Terminated with $00.
3560 3560
 			255 => 'UTF-16BE'
3561 3561
 		);
3562 3562
 		return (isset($TextEncodingNameLookup[$encoding]) ? $TextEncodingNameLookup[$encoding] : 'ISO-8859-1');
@@ -3576,7 +3576,7 @@  discard block
 block discarded – undo
3576 3576
 		return false;
3577 3577
 	}
3578 3578
 
3579
-	public static function IsANumber($numberstring, $allowdecimal=false, $allownegative=false) {
3579
+	public static function IsANumber($numberstring, $allowdecimal = false, $allownegative = false) {
3580 3580
 		for ($i = 0; $i < strlen($numberstring); $i++) {
3581 3581
 			if ((chr($numberstring{$i}) < chr('0')) || (chr($numberstring{$i}) > chr('9'))) {
3582 3582
 				if (($numberstring{$i} == '.') && $allowdecimal) {
@@ -3595,7 +3595,7 @@  discard block
 block discarded – undo
3595 3595
 		if (strlen($datestamp) != 8) {
3596 3596
 			return false;
3597 3597
 		}
3598
-		if (!self::IsANumber($datestamp, false)) {
3598
+		if ( ! self::IsANumber($datestamp, false)) {
3599 3599
 			return false;
3600 3600
 		}
3601 3601
 		$year  = substr($datestamp, 0, 4);
Please login to merge, or discard this patch.
src/wp-includes/ID3/module.tag.lyrics3.php 2 patches
Doc Comments   +6 added lines patch added patch discarded remove patch
@@ -126,6 +126,9 @@  discard block
 block discarded – undo
126 126
 		return true;
127 127
 	}
128 128
 
129
+	/**
130
+	 * @param integer $version
131
+	 */
129 132
 	public function getLyrics3Data($endoffset, $version, $length) {
130 133
 		// http://www.volweb.cz/str/tags.htm
131 134
 
@@ -287,6 +290,9 @@  discard block
 block discarded – undo
287 290
 		return true;
288 291
 	}
289 292
 
293
+	/**
294
+	 * @param string $char
295
+	 */
290 296
 	public function IntString2Bool($char) {
291 297
 		if ($char == '1') {
292 298
 			return true;
Please login to merge, or discard this patch.
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -23,15 +23,15 @@  discard block
 block discarded – undo
23 23
 
24 24
 		// http://www.volweb.cz/str/tags.htm
25 25
 
26
-		if (!getid3_lib::intValueSupported($info['filesize'])) {
26
+		if ( ! getid3_lib::intValueSupported($info['filesize'])) {
27 27
 			$info['warning'][] = 'Unable to check for Lyrics3 because file is larger than '.round(PHP_INT_MAX / 1073741824).'GB';
28 28
 			return false;
29 29
 		}
30 30
 
31
-		$this->fseek((0 - 128 - 9 - 6), SEEK_END);          // end - ID3v1 - "LYRICSEND" - [Lyrics3size]
31
+		$this->fseek((0 - 128 - 9 - 6), SEEK_END); // end - ID3v1 - "LYRICSEND" - [Lyrics3size]
32 32
 		$lyrics3_id3v1 = $this->fread(128 + 9 + 6);
33
-		$lyrics3lsz    = substr($lyrics3_id3v1,  0,   6); // Lyrics3size
34
-		$lyrics3end    = substr($lyrics3_id3v1,  6,   9); // LYRICSEND or LYRICS200
33
+		$lyrics3lsz    = substr($lyrics3_id3v1, 0, 6); // Lyrics3size
34
+		$lyrics3end    = substr($lyrics3_id3v1, 6, 9); // LYRICSEND or LYRICS200
35 35
 		$id3v1tag      = substr($lyrics3_id3v1, 15, 128); // ID3v1
36 36
 
37 37
 		if ($lyrics3end == 'LYRICSEND') {
@@ -100,7 +100,7 @@  discard block
 block discarded – undo
100 100
 			$info['avdataend'] = $lyrics3offset;
101 101
 			$this->getLyrics3Data($lyrics3offset, $lyrics3version, $lyrics3size);
102 102
 
103
-			if (!isset($info['ape'])) {
103
+			if ( ! isset($info['ape'])) {
104 104
 				if (isset($info['lyrics3']['tag_offset_start'])) {
105 105
 					$GETID3_ERRORARRAY = &$info['warning'];
106 106
 					getid3_lib::IncludeDependency(GETID3_INCLUDEPATH.'module.tag.apetag.php', __FILE__, true);
@@ -109,10 +109,10 @@  discard block
 block discarded – undo
109 109
 					$getid3_apetag = new getid3_apetag($getid3_temp);
110 110
 					$getid3_apetag->overrideendoffset = $info['lyrics3']['tag_offset_start'];
111 111
 					$getid3_apetag->Analyze();
112
-					if (!empty($getid3_temp->info['ape'])) {
112
+					if ( ! empty($getid3_temp->info['ape'])) {
113 113
 						$info['ape'] = $getid3_temp->info['ape'];
114 114
 					}
115
-					if (!empty($getid3_temp->info['replay_gain'])) {
115
+					if ( ! empty($getid3_temp->info['replay_gain'])) {
116 116
 						$info['replay_gain'] = $getid3_temp->info['replay_gain'];
117 117
 					}
118 118
 					unset($getid3_temp, $getid3_apetag);
@@ -131,7 +131,7 @@  discard block
 block discarded – undo
131 131
 
132 132
 		$info = &$this->getid3->info;
133 133
 
134
-		if (!getid3_lib::intValueSupported($endoffset)) {
134
+		if ( ! getid3_lib::intValueSupported($endoffset)) {
135 135
 			$info['warning'][] = 'Unable to check for Lyrics3 because file is larger than '.round(PHP_INT_MAX / 1073741824).'GB';
136 136
 			return false;
137 137
 		}
@@ -211,8 +211,8 @@  discard block
 block discarded – undo
211 211
 						foreach ($imagestrings as $key => $imagestring) {
212 212
 							if (strpos($imagestring, '||') !== false) {
213 213
 								$imagearray = explode('||', $imagestring);
214
-								$ParsedLyrics3['images'][$key]['filename']     =                                (isset($imagearray[0]) ? $imagearray[0] : '');
215
-								$ParsedLyrics3['images'][$key]['description']  =                                (isset($imagearray[1]) ? $imagearray[1] : '');
214
+								$ParsedLyrics3['images'][$key]['filename']     = (isset($imagearray[0]) ? $imagearray[0] : '');
215
+								$ParsedLyrics3['images'][$key]['description']  = (isset($imagearray[1]) ? $imagearray[1] : '');
216 216
 								$ParsedLyrics3['images'][$key]['timestamp']    = $this->Lyrics3Timestamp2Seconds(isset($imagearray[2]) ? $imagearray[2] : '');
217 217
 							}
218 218
 						}
Please login to merge, or discard this patch.
src/wp-includes/load.php 3 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -218,7 +218,7 @@
 block discarded – undo
218 218
  * @global float   $timestart Seconds from when timer_start() is called.
219 219
  * @global float   $timeend   Seconds from when function is called.
220 220
  *
221
- * @param int|bool $display   Whether to echo or return the results. Accepts 0|false for return,
221
+ * @param integer $display   Whether to echo or return the results. Accepts 0|false for return,
222 222
  *                            1|true for echo. Default 0|false.
223 223
  * @param int      $precision The number of digits from the right of the decimal to display.
224 224
  *                            Default 3.
Please login to merge, or discard this patch.
Braces   +145 added lines, -100 removed lines patch added patch discarded remove patch
@@ -29,19 +29,22 @@  discard block
 block discarded – undo
29 29
  * @access private
30 30
  */
31 31
 function wp_unregister_GLOBALS() {
32
-	if ( !ini_get( 'register_globals' ) )
33
-		return;
32
+	if ( !ini_get( 'register_globals' ) ) {
33
+			return;
34
+	}
34 35
 
35
-	if ( isset( $_REQUEST['GLOBALS'] ) )
36
-		die( 'GLOBALS overwrite attempt detected' );
36
+	if ( isset( $_REQUEST['GLOBALS'] ) ) {
37
+			die( 'GLOBALS overwrite attempt detected' );
38
+	}
37 39
 
38 40
 	// Variables that shouldn't be unset
39 41
 	$no_unset = array( 'GLOBALS', '_GET', '_POST', '_COOKIE', '_REQUEST', '_SERVER', '_ENV', '_FILES', 'table_prefix' );
40 42
 
41 43
 	$input = array_merge( $_GET, $_POST, $_COOKIE, $_SERVER, $_ENV, $_FILES, isset( $_SESSION ) && is_array( $_SESSION ) ? $_SESSION : array() );
42
-	foreach ( $input as $k => $v )
43
-		if ( !in_array( $k, $no_unset ) && isset( $GLOBALS[$k] ) ) {
44
+	foreach ( $input as $k => $v ) {
45
+			if ( !in_array( $k, $no_unset ) && isset( $GLOBALS[$k] ) ) {
44 46
 			unset( $GLOBALS[$k] );
47
+	}
45 48
 		}
46 49
 }
47 50
 
@@ -76,15 +79,17 @@  discard block
 block discarded – undo
76 79
 			$_SERVER['REQUEST_URI'] = $_SERVER['HTTP_X_REWRITE_URL'];
77 80
 		} else {
78 81
 			// Use ORIG_PATH_INFO if there is no PATH_INFO
79
-			if ( !isset( $_SERVER['PATH_INFO'] ) && isset( $_SERVER['ORIG_PATH_INFO'] ) )
80
-				$_SERVER['PATH_INFO'] = $_SERVER['ORIG_PATH_INFO'];
82
+			if ( !isset( $_SERVER['PATH_INFO'] ) && isset( $_SERVER['ORIG_PATH_INFO'] ) ) {
83
+							$_SERVER['PATH_INFO'] = $_SERVER['ORIG_PATH_INFO'];
84
+			}
81 85
 
82 86
 			// Some IIS + PHP configurations puts the script-name in the path-info (No need to append it twice)
83 87
 			if ( isset( $_SERVER['PATH_INFO'] ) ) {
84
-				if ( $_SERVER['PATH_INFO'] == $_SERVER['SCRIPT_NAME'] )
85
-					$_SERVER['REQUEST_URI'] = $_SERVER['PATH_INFO'];
86
-				else
87
-					$_SERVER['REQUEST_URI'] = $_SERVER['SCRIPT_NAME'] . $_SERVER['PATH_INFO'];
88
+				if ( $_SERVER['PATH_INFO'] == $_SERVER['SCRIPT_NAME'] ) {
89
+									$_SERVER['REQUEST_URI'] = $_SERVER['PATH_INFO'];
90
+				} else {
91
+									$_SERVER['REQUEST_URI'] = $_SERVER['SCRIPT_NAME'] . $_SERVER['PATH_INFO'];
92
+				}
88 93
 			}
89 94
 
90 95
 			// Append the query string if it exists and isn't null
@@ -95,18 +100,21 @@  discard block
 block discarded – undo
95 100
 	}
96 101
 
97 102
 	// Fix for PHP as CGI hosts that set SCRIPT_FILENAME to something ending in php.cgi for all requests
98
-	if ( isset( $_SERVER['SCRIPT_FILENAME'] ) && ( strpos( $_SERVER['SCRIPT_FILENAME'], 'php.cgi' ) == strlen( $_SERVER['SCRIPT_FILENAME'] ) - 7 ) )
99
-		$_SERVER['SCRIPT_FILENAME'] = $_SERVER['PATH_TRANSLATED'];
103
+	if ( isset( $_SERVER['SCRIPT_FILENAME'] ) && ( strpos( $_SERVER['SCRIPT_FILENAME'], 'php.cgi' ) == strlen( $_SERVER['SCRIPT_FILENAME'] ) - 7 ) ) {
104
+			$_SERVER['SCRIPT_FILENAME'] = $_SERVER['PATH_TRANSLATED'];
105
+	}
100 106
 
101 107
 	// Fix for Dreamhost and other PHP as CGI hosts
102
-	if ( strpos( $_SERVER['SCRIPT_NAME'], 'php.cgi' ) !== false )
103
-		unset( $_SERVER['PATH_INFO'] );
108
+	if ( strpos( $_SERVER['SCRIPT_NAME'], 'php.cgi' ) !== false ) {
109
+			unset( $_SERVER['PATH_INFO'] );
110
+	}
104 111
 
105 112
 	// Fix empty PHP_SELF
106 113
 	$PHP_SELF = $_SERVER['PHP_SELF'];
107
-	if ( empty( $PHP_SELF ) )
108
-		$_SERVER['PHP_SELF'] = $PHP_SELF = preg_replace( '/(\?.*)?$/', '', $_SERVER["REQUEST_URI"] );
109
-}
114
+	if ( empty( $PHP_SELF ) ) {
115
+			$_SERVER['PHP_SELF'] = $PHP_SELF = preg_replace( '/(\?.*)?$/', '', $_SERVER["REQUEST_URI"] );
116
+	}
117
+	}
110 118
 
111 119
 /**
112 120
  * Check for the required PHP version, and the MySQL extension or
@@ -174,15 +182,17 @@  discard block
 block discarded – undo
174 182
  * @global int $upgrading the unix timestamp marking when upgrading WordPress began.
175 183
  */
176 184
 function wp_maintenance() {
177
-	if ( ! file_exists( ABSPATH . '.maintenance' ) || wp_installing() )
178
-		return;
185
+	if ( ! file_exists( ABSPATH . '.maintenance' ) || wp_installing() ) {
186
+			return;
187
+	}
179 188
 
180 189
 	global $upgrading;
181 190
 
182 191
 	include( ABSPATH . '.maintenance' );
183 192
 	// If the $upgrading timestamp is older than 10 minutes, don't die.
184
-	if ( ( time() - $upgrading ) >= 600 )
185
-		return;
193
+	if ( ( time() - $upgrading ) >= 600 ) {
194
+			return;
195
+	}
186 196
 
187 197
 	if ( file_exists( WP_CONTENT_DIR . '/maintenance.php' ) ) {
188 198
 		require_once( WP_CONTENT_DIR . '/maintenance.php' );
@@ -197,7 +207,10 @@  discard block
 block discarded – undo
197 207
 	header( 'Retry-After: 600' );
198 208
 ?>
199 209
 	<!DOCTYPE html>
200
-	<html xmlns="http://www.w3.org/1999/xhtml"<?php if ( is_rtl() ) echo ' dir="rtl"'; ?>>
210
+	<html xmlns="http://www.w3.org/1999/xhtml"<?php if ( is_rtl() ) {
211
+	echo ' dir="rtl"';
212
+}
213
+?>>
201 214
 	<head>
202 215
 	<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
203 216
 		<title><?php _e( 'Maintenance' ); ?></title>
@@ -248,8 +261,9 @@  discard block
 block discarded – undo
248 261
 	$timeend = microtime( true );
249 262
 	$timetotal = $timeend - $timestart;
250 263
 	$r = ( function_exists( 'number_format_i18n' ) ) ? number_format_i18n( $timetotal, $precision ) : number_format( $timetotal, $precision );
251
-	if ( $display )
252
-		echo $r;
264
+	if ( $display ) {
265
+			echo $r;
266
+	}
253 267
 	return $r;
254 268
 }
255 269
 
@@ -288,10 +302,11 @@  discard block
 block discarded – undo
288 302
 	if ( WP_DEBUG ) {
289 303
 		error_reporting( E_ALL );
290 304
 
291
-		if ( WP_DEBUG_DISPLAY )
292
-			ini_set( 'display_errors', 1 );
293
-		elseif ( null !== WP_DEBUG_DISPLAY )
294
-			ini_set( 'display_errors', 0 );
305
+		if ( WP_DEBUG_DISPLAY ) {
306
+					ini_set( 'display_errors', 1 );
307
+		} elseif ( null !== WP_DEBUG_DISPLAY ) {
308
+					ini_set( 'display_errors', 0 );
309
+		}
295 310
 
296 311
 		if ( WP_DEBUG_LOG ) {
297 312
 			ini_set( 'log_errors', 1 );
@@ -362,11 +377,13 @@  discard block
 block discarded – undo
362 377
 	global $wpdb;
363 378
 
364 379
 	require_once( ABSPATH . WPINC . '/wp-db.php' );
365
-	if ( file_exists( WP_CONTENT_DIR . '/db.php' ) )
366
-		require_once( WP_CONTENT_DIR . '/db.php' );
380
+	if ( file_exists( WP_CONTENT_DIR . '/db.php' ) ) {
381
+			require_once( WP_CONTENT_DIR . '/db.php' );
382
+	}
367 383
 
368
-	if ( isset( $wpdb ) )
369
-		return;
384
+	if ( isset( $wpdb ) ) {
385
+			return;
386
+	}
370 387
 
371 388
 	$wpdb = new wpdb( DB_USER, DB_PASSWORD, DB_NAME, DB_HOST );
372 389
 }
@@ -385,8 +402,9 @@  discard block
 block discarded – undo
385 402
  */
386 403
 function wp_set_wpdb_vars() {
387 404
 	global $wpdb, $table_prefix;
388
-	if ( !empty( $wpdb->error ) )
389
-		dead_db();
405
+	if ( !empty( $wpdb->error ) ) {
406
+			dead_db();
407
+	}
390 408
 
391 409
 	$wpdb->field_types = array( 'post_author' => '%d', 'post_parent' => '%d', 'menu_order' => '%d', 'term_id' => '%d', 'term_group' => '%d', 'term_taxonomy_id' => '%d',
392 410
 		'parent' => '%d', 'count' => '%d','object_id' => '%d', 'term_order' => '%d', 'ID' => '%d', 'comment_ID' => '%d', 'comment_post_ID' => '%d', 'comment_parent' => '%d',
@@ -424,8 +442,9 @@  discard block
 block discarded – undo
424 442
 function wp_using_ext_object_cache( $using = null ) {
425 443
 	global $_wp_using_ext_object_cache;
426 444
 	$current_using = $_wp_using_ext_object_cache;
427
-	if ( null !== $using )
428
-		$_wp_using_ext_object_cache = $using;
445
+	if ( null !== $using ) {
446
+			$_wp_using_ext_object_cache = $using;
447
+	}
429 448
 	return $current_using;
430 449
 }
431 450
 
@@ -447,8 +466,9 @@  discard block
 block discarded – undo
447 466
  	if ( ! function_exists( 'wp_cache_init' ) ) {
448 467
 		if ( file_exists( WP_CONTENT_DIR . '/object-cache.php' ) ) {
449 468
 			require_once ( WP_CONTENT_DIR . '/object-cache.php' );
450
-			if ( function_exists( 'wp_cache_init' ) )
451
-				wp_using_ext_object_cache( true );
469
+			if ( function_exists( 'wp_cache_init' ) ) {
470
+							wp_using_ext_object_cache( true );
471
+			}
452 472
 		}
453 473
 
454 474
 		$first_init = true;
@@ -462,18 +482,20 @@  discard block
 block discarded – undo
462 482
 		wp_using_ext_object_cache( true );
463 483
 	}
464 484
 
465
-	if ( ! wp_using_ext_object_cache() )
466
-		require_once ( ABSPATH . WPINC . '/cache.php' );
485
+	if ( ! wp_using_ext_object_cache() ) {
486
+			require_once ( ABSPATH . WPINC . '/cache.php' );
487
+	}
467 488
 
468 489
 	/*
469 490
 	 * If cache supports reset, reset instead of init if already
470 491
 	 * initialized. Reset signals to the cache that global IDs
471 492
 	 * have changed and it may need to update keys and cleanup caches.
472 493
 	 */
473
-	if ( ! $first_init && function_exists( 'wp_cache_switch_to_blog' ) )
474
-		wp_cache_switch_to_blog( $blog_id );
475
-	elseif ( function_exists( 'wp_cache_init' ) )
476
-		wp_cache_init();
494
+	if ( ! $first_init && function_exists( 'wp_cache_switch_to_blog' ) ) {
495
+			wp_cache_switch_to_blog( $blog_id );
496
+	} elseif ( function_exists( 'wp_cache_init' ) ) {
497
+			wp_cache_init();
498
+	}
477 499
 
478 500
 	if ( function_exists( 'wp_cache_add_global_groups' ) ) {
479 501
 		wp_cache_add_global_groups( array( 'users', 'userlogins', 'usermeta', 'user_meta', 'useremail', 'userslugs', 'site-transient', 'site-options', 'site-lookup', 'blog-lookup', 'blog-details', 'rss', 'global-posts', 'blog-id-cache', 'networks', 'sites' ) );
@@ -524,13 +546,16 @@  discard block
 block discarded – undo
524 546
  */
525 547
 function wp_get_mu_plugins() {
526 548
 	$mu_plugins = array();
527
-	if ( !is_dir( WPMU_PLUGIN_DIR ) )
528
-		return $mu_plugins;
529
-	if ( ! $dh = opendir( WPMU_PLUGIN_DIR ) )
530
-		return $mu_plugins;
549
+	if ( !is_dir( WPMU_PLUGIN_DIR ) ) {
550
+			return $mu_plugins;
551
+	}
552
+	if ( ! $dh = opendir( WPMU_PLUGIN_DIR ) ) {
553
+			return $mu_plugins;
554
+	}
531 555
 	while ( ( $plugin = readdir( $dh ) ) !== false ) {
532
-		if ( substr( $plugin, -4 ) == '.php' )
533
-			$mu_plugins[] = WPMU_PLUGIN_DIR . '/' . $plugin;
556
+		if ( substr( $plugin, -4 ) == '.php' ) {
557
+					$mu_plugins[] = WPMU_PLUGIN_DIR . '/' . $plugin;
558
+		}
534 559
 	}
535 560
 	closedir( $dh );
536 561
 	sort( $mu_plugins );
@@ -562,8 +587,9 @@  discard block
 block discarded – undo
562 587
 		array_unshift( $plugins, ABSPATH . 'my-hacks.php' );
563 588
 	}
564 589
 
565
-	if ( empty( $active_plugins ) || wp_installing() )
566
-		return $plugins;
590
+	if ( empty( $active_plugins ) || wp_installing() ) {
591
+			return $plugins;
592
+	}
567 593
 
568 594
 	$network_plugins = is_multisite() ? wp_get_active_network_plugins() : false;
569 595
 
@@ -573,8 +599,9 @@  discard block
 block discarded – undo
573 599
 			&& file_exists( WP_PLUGIN_DIR . '/' . $plugin ) // $plugin must exist
574 600
 			// not already included as a network plugin
575 601
 			&& ( ! $network_plugins || ! in_array( WP_PLUGIN_DIR . '/' . $plugin, $network_plugins ) )
576
-			)
577
-		$plugins[] = WP_PLUGIN_DIR . '/' . $plugin;
602
+			) {
603
+				$plugins[] = WP_PLUGIN_DIR . '/' . $plugin;
604
+		}
578 605
 	}
579 606
 	return $plugins;
580 607
 }
@@ -591,8 +618,9 @@  discard block
 block discarded – undo
591 618
 function wp_set_internal_encoding() {
592 619
 	if ( function_exists( 'mb_internal_encoding' ) ) {
593 620
 		$charset = get_option( 'blog_charset' );
594
-		if ( ! $charset || ! @mb_internal_encoding( $charset ) )
595
-			mb_internal_encoding( 'UTF-8' );
621
+		if ( ! $charset || ! @mb_internal_encoding( $charset ) ) {
622
+					mb_internal_encoding( 'UTF-8' );
623
+		}
596 624
 	}
597 625
 }
598 626
 
@@ -667,10 +695,11 @@  discard block
 block discarded – undo
667 695
  * @return bool True if inside WordPress administration interface, false otherwise.
668 696
  */
669 697
 function is_admin() {
670
-	if ( isset( $GLOBALS['current_screen'] ) )
671
-		return $GLOBALS['current_screen']->in_admin();
672
-	elseif ( defined( 'WP_ADMIN' ) )
673
-		return WP_ADMIN;
698
+	if ( isset( $GLOBALS['current_screen'] ) ) {
699
+			return $GLOBALS['current_screen']->in_admin();
700
+	} elseif ( defined( 'WP_ADMIN' ) ) {
701
+			return WP_ADMIN;
702
+	}
674 703
 
675 704
 	return false;
676 705
 }
@@ -690,10 +719,11 @@  discard block
 block discarded – undo
690 719
  * @return bool True if inside WordPress blog administration pages.
691 720
  */
692 721
 function is_blog_admin() {
693
-	if ( isset( $GLOBALS['current_screen'] ) )
694
-		return $GLOBALS['current_screen']->in_admin( 'site' );
695
-	elseif ( defined( 'WP_BLOG_ADMIN' ) )
696
-		return WP_BLOG_ADMIN;
722
+	if ( isset( $GLOBALS['current_screen'] ) ) {
723
+			return $GLOBALS['current_screen']->in_admin( 'site' );
724
+	} elseif ( defined( 'WP_BLOG_ADMIN' ) ) {
725
+			return WP_BLOG_ADMIN;
726
+	}
697 727
 
698 728
 	return false;
699 729
 }
@@ -713,10 +743,11 @@  discard block
 block discarded – undo
713 743
  * @return bool True if inside WordPress network administration pages.
714 744
  */
715 745
 function is_network_admin() {
716
-	if ( isset( $GLOBALS['current_screen'] ) )
717
-		return $GLOBALS['current_screen']->in_admin( 'network' );
718
-	elseif ( defined( 'WP_NETWORK_ADMIN' ) )
719
-		return WP_NETWORK_ADMIN;
746
+	if ( isset( $GLOBALS['current_screen'] ) ) {
747
+			return $GLOBALS['current_screen']->in_admin( 'network' );
748
+	} elseif ( defined( 'WP_NETWORK_ADMIN' ) ) {
749
+			return WP_NETWORK_ADMIN;
750
+	}
720 751
 
721 752
 	return false;
722 753
 }
@@ -737,10 +768,11 @@  discard block
 block discarded – undo
737 768
  * @return bool True if inside WordPress user administration pages.
738 769
  */
739 770
 function is_user_admin() {
740
-	if ( isset( $GLOBALS['current_screen'] ) )
741
-		return $GLOBALS['current_screen']->in_admin( 'user' );
742
-	elseif ( defined( 'WP_USER_ADMIN' ) )
743
-		return WP_USER_ADMIN;
771
+	if ( isset( $GLOBALS['current_screen'] ) ) {
772
+			return $GLOBALS['current_screen']->in_admin( 'user' );
773
+	} elseif ( defined( 'WP_USER_ADMIN' ) ) {
774
+			return WP_USER_ADMIN;
775
+	}
744 776
 
745 777
 	return false;
746 778
 }
@@ -753,11 +785,13 @@  discard block
 block discarded – undo
753 785
  * @return bool True if Multisite is enabled, false otherwise.
754 786
  */
755 787
 function is_multisite() {
756
-	if ( defined( 'MULTISITE' ) )
757
-		return MULTISITE;
788
+	if ( defined( 'MULTISITE' ) ) {
789
+			return MULTISITE;
790
+	}
758 791
 
759
-	if ( defined( 'SUBDOMAIN_INSTALL' ) || defined( 'VHOST' ) || defined( 'SUNRISE' ) )
760
-		return true;
792
+	if ( defined( 'SUBDOMAIN_INSTALL' ) || defined( 'VHOST' ) || defined( 'SUNRISE' ) ) {
793
+			return true;
794
+	}
761 795
 
762 796
 	return false;
763 797
 }
@@ -798,12 +832,14 @@  discard block
 block discarded – undo
798 832
 	global $text_direction, $wp_locale;
799 833
 
800 834
 	static $loaded = false;
801
-	if ( $loaded )
802
-		return;
835
+	if ( $loaded ) {
836
+			return;
837
+	}
803 838
 	$loaded = true;
804 839
 
805
-	if ( function_exists( 'did_action' ) && did_action( 'init' ) )
806
-		return;
840
+	if ( function_exists( 'did_action' ) && did_action( 'init' ) ) {
841
+			return;
842
+	}
807 843
 
808 844
 	// We need $wp_local_package
809 845
 	require ABSPATH . WPINC . '/version.php';
@@ -820,31 +856,39 @@  discard block
 block discarded – undo
820 856
 
821 857
 	while ( true ) {
822 858
 		if ( defined( 'WPLANG' ) ) {
823
-			if ( '' == WPLANG )
824
-				break;
859
+			if ( '' == WPLANG ) {
860
+							break;
861
+			}
825 862
 			$locales[] = WPLANG;
826 863
 		}
827 864
 
828
-		if ( isset( $wp_local_package ) )
829
-			$locales[] = $wp_local_package;
865
+		if ( isset( $wp_local_package ) ) {
866
+					$locales[] = $wp_local_package;
867
+		}
830 868
 
831
-		if ( ! $locales )
832
-			break;
869
+		if ( ! $locales ) {
870
+					break;
871
+		}
833 872
 
834
-		if ( defined( 'WP_LANG_DIR' ) && @is_dir( WP_LANG_DIR ) )
835
-			$locations[] = WP_LANG_DIR;
873
+		if ( defined( 'WP_LANG_DIR' ) && @is_dir( WP_LANG_DIR ) ) {
874
+					$locations[] = WP_LANG_DIR;
875
+		}
836 876
 
837
-		if ( defined( 'WP_CONTENT_DIR' ) && @is_dir( WP_CONTENT_DIR . '/languages' ) )
838
-			$locations[] = WP_CONTENT_DIR . '/languages';
877
+		if ( defined( 'WP_CONTENT_DIR' ) && @is_dir( WP_CONTENT_DIR . '/languages' ) ) {
878
+					$locations[] = WP_CONTENT_DIR . '/languages';
879
+		}
839 880
 
840
-		if ( @is_dir( ABSPATH . 'wp-content/languages' ) )
841
-			$locations[] = ABSPATH . 'wp-content/languages';
881
+		if ( @is_dir( ABSPATH . 'wp-content/languages' ) ) {
882
+					$locations[] = ABSPATH . 'wp-content/languages';
883
+		}
842 884
 
843
-		if ( @is_dir( ABSPATH . WPINC . '/languages' ) )
844
-			$locations[] = ABSPATH . WPINC . '/languages';
885
+		if ( @is_dir( ABSPATH . WPINC . '/languages' ) ) {
886
+					$locations[] = ABSPATH . WPINC . '/languages';
887
+		}
845 888
 
846
-		if ( ! $locations )
847
-			break;
889
+		if ( ! $locations ) {
890
+					break;
891
+		}
848 892
 
849 893
 		$locations = array_unique( $locations );
850 894
 
@@ -852,8 +896,9 @@  discard block
 block discarded – undo
852 896
 			foreach ( $locations as $location ) {
853 897
 				if ( file_exists( $location . '/' . $locale . '.mo' ) ) {
854 898
 					load_textdomain( 'default', $location . '/' . $locale . '.mo' );
855
-					if ( defined( 'WP_SETUP_CONFIG' ) && file_exists( $location . '/admin-' . $locale . '.mo' ) )
856
-						load_textdomain( 'default', $location . '/admin-' . $locale . '.mo' );
899
+					if ( defined( 'WP_SETUP_CONFIG' ) && file_exists( $location . '/admin-' . $locale . '.mo' ) ) {
900
+											load_textdomain( 'default', $location . '/admin-' . $locale . '.mo' );
901
+					}
857 902
 					break 2;
858 903
 				}
859 904
 			}
Please login to merge, or discard this patch.
Spacing   +193 added lines, -193 removed lines patch added patch discarded remove patch
@@ -16,7 +16,7 @@  discard block
 block discarded – undo
16 16
  */
17 17
 function wp_get_server_protocol() {
18 18
 	$protocol = $_SERVER['SERVER_PROTOCOL'];
19
-	if ( ! in_array( $protocol, array( 'HTTP/1.1', 'HTTP/2', 'HTTP/2.0' ) ) ) {
19
+	if ( ! in_array($protocol, array('HTTP/1.1', 'HTTP/2', 'HTTP/2.0'))) {
20 20
 		$protocol = 'HTTP/1.0';
21 21
 	}
22 22
 	return $protocol;
@@ -29,19 +29,19 @@  discard block
 block discarded – undo
29 29
  * @access private
30 30
  */
31 31
 function wp_unregister_GLOBALS() {
32
-	if ( !ini_get( 'register_globals' ) )
32
+	if ( ! ini_get('register_globals'))
33 33
 		return;
34 34
 
35
-	if ( isset( $_REQUEST['GLOBALS'] ) )
36
-		die( 'GLOBALS overwrite attempt detected' );
35
+	if (isset($_REQUEST['GLOBALS']))
36
+		die('GLOBALS overwrite attempt detected');
37 37
 
38 38
 	// Variables that shouldn't be unset
39
-	$no_unset = array( 'GLOBALS', '_GET', '_POST', '_COOKIE', '_REQUEST', '_SERVER', '_ENV', '_FILES', 'table_prefix' );
39
+	$no_unset = array('GLOBALS', '_GET', '_POST', '_COOKIE', '_REQUEST', '_SERVER', '_ENV', '_FILES', 'table_prefix');
40 40
 
41
-	$input = array_merge( $_GET, $_POST, $_COOKIE, $_SERVER, $_ENV, $_FILES, isset( $_SESSION ) && is_array( $_SESSION ) ? $_SESSION : array() );
42
-	foreach ( $input as $k => $v )
43
-		if ( !in_array( $k, $no_unset ) && isset( $GLOBALS[$k] ) ) {
44
-			unset( $GLOBALS[$k] );
41
+	$input = array_merge($_GET, $_POST, $_COOKIE, $_SERVER, $_ENV, $_FILES, isset($_SESSION) && is_array($_SESSION) ? $_SESSION : array());
42
+	foreach ($input as $k => $v)
43
+		if ( ! in_array($k, $no_unset) && isset($GLOBALS[$k])) {
44
+			unset($GLOBALS[$k]);
45 45
 		}
46 46
 }
47 47
 
@@ -62,50 +62,50 @@  discard block
 block discarded – undo
62 62
 		'REQUEST_URI' => '',
63 63
 	);
64 64
 
65
-	$_SERVER = array_merge( $default_server_values, $_SERVER );
65
+	$_SERVER = array_merge($default_server_values, $_SERVER);
66 66
 
67 67
 	// Fix for IIS when running with PHP ISAPI
68
-	if ( empty( $_SERVER['REQUEST_URI'] ) || ( PHP_SAPI != 'cgi-fcgi' && preg_match( '/^Microsoft-IIS\//', $_SERVER['SERVER_SOFTWARE'] ) ) ) {
68
+	if (empty($_SERVER['REQUEST_URI']) || (PHP_SAPI != 'cgi-fcgi' && preg_match('/^Microsoft-IIS\//', $_SERVER['SERVER_SOFTWARE']))) {
69 69
 
70 70
 		// IIS Mod-Rewrite
71
-		if ( isset( $_SERVER['HTTP_X_ORIGINAL_URL'] ) ) {
71
+		if (isset($_SERVER['HTTP_X_ORIGINAL_URL'])) {
72 72
 			$_SERVER['REQUEST_URI'] = $_SERVER['HTTP_X_ORIGINAL_URL'];
73 73
 		}
74 74
 		// IIS Isapi_Rewrite
75
-		elseif ( isset( $_SERVER['HTTP_X_REWRITE_URL'] ) ) {
75
+		elseif (isset($_SERVER['HTTP_X_REWRITE_URL'])) {
76 76
 			$_SERVER['REQUEST_URI'] = $_SERVER['HTTP_X_REWRITE_URL'];
77 77
 		} else {
78 78
 			// Use ORIG_PATH_INFO if there is no PATH_INFO
79
-			if ( !isset( $_SERVER['PATH_INFO'] ) && isset( $_SERVER['ORIG_PATH_INFO'] ) )
79
+			if ( ! isset($_SERVER['PATH_INFO']) && isset($_SERVER['ORIG_PATH_INFO']))
80 80
 				$_SERVER['PATH_INFO'] = $_SERVER['ORIG_PATH_INFO'];
81 81
 
82 82
 			// Some IIS + PHP configurations puts the script-name in the path-info (No need to append it twice)
83
-			if ( isset( $_SERVER['PATH_INFO'] ) ) {
84
-				if ( $_SERVER['PATH_INFO'] == $_SERVER['SCRIPT_NAME'] )
83
+			if (isset($_SERVER['PATH_INFO'])) {
84
+				if ($_SERVER['PATH_INFO'] == $_SERVER['SCRIPT_NAME'])
85 85
 					$_SERVER['REQUEST_URI'] = $_SERVER['PATH_INFO'];
86 86
 				else
87
-					$_SERVER['REQUEST_URI'] = $_SERVER['SCRIPT_NAME'] . $_SERVER['PATH_INFO'];
87
+					$_SERVER['REQUEST_URI'] = $_SERVER['SCRIPT_NAME'].$_SERVER['PATH_INFO'];
88 88
 			}
89 89
 
90 90
 			// Append the query string if it exists and isn't null
91
-			if ( ! empty( $_SERVER['QUERY_STRING'] ) ) {
92
-				$_SERVER['REQUEST_URI'] .= '?' . $_SERVER['QUERY_STRING'];
91
+			if ( ! empty($_SERVER['QUERY_STRING'])) {
92
+				$_SERVER['REQUEST_URI'] .= '?'.$_SERVER['QUERY_STRING'];
93 93
 			}
94 94
 		}
95 95
 	}
96 96
 
97 97
 	// Fix for PHP as CGI hosts that set SCRIPT_FILENAME to something ending in php.cgi for all requests
98
-	if ( isset( $_SERVER['SCRIPT_FILENAME'] ) && ( strpos( $_SERVER['SCRIPT_FILENAME'], 'php.cgi' ) == strlen( $_SERVER['SCRIPT_FILENAME'] ) - 7 ) )
98
+	if (isset($_SERVER['SCRIPT_FILENAME']) && (strpos($_SERVER['SCRIPT_FILENAME'], 'php.cgi') == strlen($_SERVER['SCRIPT_FILENAME']) - 7))
99 99
 		$_SERVER['SCRIPT_FILENAME'] = $_SERVER['PATH_TRANSLATED'];
100 100
 
101 101
 	// Fix for Dreamhost and other PHP as CGI hosts
102
-	if ( strpos( $_SERVER['SCRIPT_NAME'], 'php.cgi' ) !== false )
103
-		unset( $_SERVER['PATH_INFO'] );
102
+	if (strpos($_SERVER['SCRIPT_NAME'], 'php.cgi') !== false)
103
+		unset($_SERVER['PATH_INFO']);
104 104
 
105 105
 	// Fix empty PHP_SELF
106 106
 	$PHP_SELF = $_SERVER['PHP_SELF'];
107
-	if ( empty( $PHP_SELF ) )
108
-		$_SERVER['PHP_SELF'] = $PHP_SELF = preg_replace( '/(\?.*)?$/', '', $_SERVER["REQUEST_URI"] );
107
+	if (empty($PHP_SELF))
108
+		$_SERVER['PHP_SELF'] = $PHP_SELF = preg_replace('/(\?.*)?$/', '', $_SERVER["REQUEST_URI"]);
109 109
 }
110 110
 
111 111
 /**
@@ -124,22 +124,22 @@  discard block
 block discarded – undo
124 124
 	global $required_php_version, $wp_version;
125 125
 	$php_version = phpversion();
126 126
 
127
-	if ( version_compare( $required_php_version, $php_version, '>' ) ) {
127
+	if (version_compare($required_php_version, $php_version, '>')) {
128 128
 		wp_load_translations_early();
129 129
 
130 130
 		$protocol = wp_get_server_protocol();
131
-		header( sprintf( '%s 500 Internal Server Error', $protocol ), true, 500 );
132
-		header( 'Content-Type: text/html; charset=utf-8' );
133
-		die( sprintf( __( 'Your server is running PHP version %1$s but WordPress %2$s requires at least %3$s.' ), $php_version, $wp_version, $required_php_version ) );
131
+		header(sprintf('%s 500 Internal Server Error', $protocol), true, 500);
132
+		header('Content-Type: text/html; charset=utf-8');
133
+		die(sprintf(__('Your server is running PHP version %1$s but WordPress %2$s requires at least %3$s.'), $php_version, $wp_version, $required_php_version));
134 134
 	}
135 135
 
136
-	if ( ! extension_loaded( 'mysql' ) && ! extension_loaded( 'mysqli' ) && ! extension_loaded( 'mysqlnd' ) && ! file_exists( WP_CONTENT_DIR . '/db.php' ) ) {
136
+	if ( ! extension_loaded('mysql') && ! extension_loaded('mysqli') && ! extension_loaded('mysqlnd') && ! file_exists(WP_CONTENT_DIR.'/db.php')) {
137 137
 		wp_load_translations_early();
138 138
 
139 139
 		$protocol = wp_get_server_protocol();
140
-		header( sprintf( '%s 500 Internal Server Error', $protocol ), true, 500 );
141
-		header( 'Content-Type: text/html; charset=utf-8' );
142
-		die( __( 'Your PHP installation appears to be missing the MySQL extension which is required by WordPress.' ) );
140
+		header(sprintf('%s 500 Internal Server Error', $protocol), true, 500);
141
+		header('Content-Type: text/html; charset=utf-8');
142
+		die(__('Your PHP installation appears to be missing the MySQL extension which is required by WordPress.'));
143 143
 	}
144 144
 }
145 145
 
@@ -151,7 +151,7 @@  discard block
 block discarded – undo
151 151
  * @since 3.0.0
152 152
  */
153 153
 function wp_favicon_request() {
154
-	if ( '/favicon.ico' == $_SERVER['REQUEST_URI'] ) {
154
+	if ('/favicon.ico' == $_SERVER['REQUEST_URI']) {
155 155
 		header('Content-Type: image/vnd.microsoft.icon');
156 156
 		exit;
157 157
 	}
@@ -174,14 +174,14 @@  discard block
 block discarded – undo
174 174
  * @global int $upgrading the unix timestamp marking when upgrading WordPress began.
175 175
  */
176 176
 function wp_maintenance() {
177
-	if ( ! file_exists( ABSPATH . '.maintenance' ) || wp_installing() )
177
+	if ( ! file_exists(ABSPATH.'.maintenance') || wp_installing())
178 178
 		return;
179 179
 
180 180
 	global $upgrading;
181 181
 
182
-	include( ABSPATH . '.maintenance' );
182
+	include(ABSPATH.'.maintenance');
183 183
 	// If the $upgrading timestamp is older than 10 minutes, don't die.
184
-	if ( ( time() - $upgrading ) >= 600 )
184
+	if ((time() - $upgrading) >= 600)
185 185
 		return;
186 186
 
187 187
 	/**
@@ -197,31 +197,31 @@  discard block
 block discarded – undo
197 197
 	 * @param bool $enable_checks Whether to enable maintenance mode. Default true.
198 198
 	 * @param int  $upgrading     The timestamp set in the .maintenance file.
199 199
 	 */
200
-	if ( ! apply_filters( 'enable_maintenance_mode', true, $upgrading ) ) {
200
+	if ( ! apply_filters('enable_maintenance_mode', true, $upgrading)) {
201 201
 		return;
202 202
 	}
203 203
 
204
-	if ( file_exists( WP_CONTENT_DIR . '/maintenance.php' ) ) {
205
-		require_once( WP_CONTENT_DIR . '/maintenance.php' );
204
+	if (file_exists(WP_CONTENT_DIR.'/maintenance.php')) {
205
+		require_once(WP_CONTENT_DIR.'/maintenance.php');
206 206
 		die();
207 207
 	}
208 208
 
209 209
 	wp_load_translations_early();
210 210
 
211 211
 	$protocol = wp_get_server_protocol();
212
-	header( "$protocol 503 Service Unavailable", true, 503 );
213
-	header( 'Content-Type: text/html; charset=utf-8' );
214
-	header( 'Retry-After: 600' );
212
+	header("$protocol 503 Service Unavailable", true, 503);
213
+	header('Content-Type: text/html; charset=utf-8');
214
+	header('Retry-After: 600');
215 215
 ?>
216 216
 	<!DOCTYPE html>
217
-	<html xmlns="http://www.w3.org/1999/xhtml"<?php if ( is_rtl() ) echo ' dir="rtl"'; ?>>
217
+	<html xmlns="http://www.w3.org/1999/xhtml"<?php if (is_rtl()) echo ' dir="rtl"'; ?>>
218 218
 	<head>
219 219
 	<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
220
-		<title><?php _e( 'Maintenance' ); ?></title>
220
+		<title><?php _e('Maintenance'); ?></title>
221 221
 
222 222
 	</head>
223 223
 	<body>
224
-		<h1><?php _e( 'Briefly unavailable for scheduled maintenance. Check back in a minute.' ); ?></h1>
224
+		<h1><?php _e('Briefly unavailable for scheduled maintenance. Check back in a minute.'); ?></h1>
225 225
 	</body>
226 226
 	</html>
227 227
 <?php
@@ -241,7 +241,7 @@  discard block
 block discarded – undo
241 241
  */
242 242
 function timer_start() {
243 243
 	global $timestart;
244
-	$timestart = microtime( true );
244
+	$timestart = microtime(true);
245 245
 	return true;
246 246
 }
247 247
 
@@ -260,12 +260,12 @@  discard block
 block discarded – undo
260 260
  * @return string The "second.microsecond" finished time calculation. The number is formatted
261 261
  *                for human consumption, both localized and rounded.
262 262
  */
263
-function timer_stop( $display = 0, $precision = 3 ) {
263
+function timer_stop($display = 0, $precision = 3) {
264 264
 	global $timestart, $timeend;
265
-	$timeend = microtime( true );
265
+	$timeend = microtime(true);
266 266
 	$timetotal = $timeend - $timestart;
267
-	$r = ( function_exists( 'number_format_i18n' ) ) ? number_format_i18n( $timetotal, $precision ) : number_format( $timetotal, $precision );
268
-	if ( $display )
267
+	$r = (function_exists('number_format_i18n')) ? number_format_i18n($timetotal, $precision) : number_format($timetotal, $precision);
268
+	if ($display)
269 269
 		echo $r;
270 270
 	return $r;
271 271
 }
@@ -314,28 +314,28 @@  discard block
 block discarded – undo
314 314
 	 *
315 315
 	 * @param bool $enable_debug_mode Whether to enable debug mode checks to occur. Default true.
316 316
 	 */
317
-	if ( ! apply_filters( 'enable_wp_debug_mode_checks', true ) ){
317
+	if ( ! apply_filters('enable_wp_debug_mode_checks', true)) {
318 318
 		return;
319 319
 	}
320 320
 
321
-	if ( WP_DEBUG ) {
322
-		error_reporting( E_ALL );
321
+	if (WP_DEBUG) {
322
+		error_reporting(E_ALL);
323 323
 
324
-		if ( WP_DEBUG_DISPLAY )
325
-			ini_set( 'display_errors', 1 );
326
-		elseif ( null !== WP_DEBUG_DISPLAY )
327
-			ini_set( 'display_errors', 0 );
324
+		if (WP_DEBUG_DISPLAY)
325
+			ini_set('display_errors', 1);
326
+		elseif (null !== WP_DEBUG_DISPLAY)
327
+			ini_set('display_errors', 0);
328 328
 
329
-		if ( WP_DEBUG_LOG ) {
330
-			ini_set( 'log_errors', 1 );
331
-			ini_set( 'error_log', WP_CONTENT_DIR . '/debug.log' );
329
+		if (WP_DEBUG_LOG) {
330
+			ini_set('log_errors', 1);
331
+			ini_set('error_log', WP_CONTENT_DIR.'/debug.log');
332 332
 		}
333 333
 	} else {
334
-		error_reporting( E_CORE_ERROR | E_CORE_WARNING | E_COMPILE_ERROR | E_ERROR | E_WARNING | E_PARSE | E_USER_ERROR | E_USER_WARNING | E_RECOVERABLE_ERROR );
334
+		error_reporting(E_CORE_ERROR | E_CORE_WARNING | E_COMPILE_ERROR | E_ERROR | E_WARNING | E_PARSE | E_USER_ERROR | E_USER_WARNING | E_RECOVERABLE_ERROR);
335 335
 	}
336 336
 
337
-	if ( defined( 'XMLRPC_REQUEST' ) || defined( 'REST_REQUEST' ) || ( defined( 'DOING_AJAX' ) && DOING_AJAX ) ) {
338
-		@ini_set( 'display_errors', 0 );
337
+	if (defined('XMLRPC_REQUEST') || defined('REST_REQUEST') || (defined('DOING_AJAX') && DOING_AJAX)) {
338
+		@ini_set('display_errors', 0);
339 339
 	}
340 340
 }
341 341
 
@@ -353,8 +353,8 @@  discard block
 block discarded – undo
353 353
  * @access private
354 354
  */
355 355
 function wp_set_lang_dir() {
356
-	if ( !defined( 'WP_LANG_DIR' ) ) {
357
-		if ( file_exists( WP_CONTENT_DIR . '/languages' ) && @is_dir( WP_CONTENT_DIR . '/languages' ) || !@is_dir(ABSPATH . WPINC . '/languages') ) {
356
+	if ( ! defined('WP_LANG_DIR')) {
357
+		if (file_exists(WP_CONTENT_DIR.'/languages') && @is_dir(WP_CONTENT_DIR.'/languages') || ! @is_dir(ABSPATH.WPINC.'/languages')) {
358 358
 			/**
359 359
 			 * Server path of the language directory.
360 360
 			 *
@@ -362,10 +362,10 @@  discard block
 block discarded – undo
362 362
 			 *
363 363
 			 * @since 2.1.0
364 364
 			 */
365
-			define( 'WP_LANG_DIR', WP_CONTENT_DIR . '/languages' );
366
-			if ( !defined( 'LANGDIR' ) ) {
365
+			define('WP_LANG_DIR', WP_CONTENT_DIR.'/languages');
366
+			if ( ! defined('LANGDIR')) {
367 367
 				// Old static relative path maintained for limited backward compatibility - won't work in some cases.
368
-				define( 'LANGDIR', 'wp-content/languages' );
368
+				define('LANGDIR', 'wp-content/languages');
369 369
 			}
370 370
 		} else {
371 371
 			/**
@@ -375,10 +375,10 @@  discard block
 block discarded – undo
375 375
 			 *
376 376
 			 * @since 2.1.0
377 377
 			 */
378
-			define( 'WP_LANG_DIR', ABSPATH . WPINC . '/languages' );
379
-			if ( !defined( 'LANGDIR' ) ) {
378
+			define('WP_LANG_DIR', ABSPATH.WPINC.'/languages');
379
+			if ( ! defined('LANGDIR')) {
380 380
 				// Old relative path maintained for backward compatibility.
381
-				define( 'LANGDIR', WPINC . '/languages' );
381
+				define('LANGDIR', WPINC.'/languages');
382 382
 			}
383 383
 		}
384 384
 	}
@@ -394,14 +394,14 @@  discard block
 block discarded – undo
394 394
 function require_wp_db() {
395 395
 	global $wpdb;
396 396
 
397
-	require_once( ABSPATH . WPINC . '/wp-db.php' );
398
-	if ( file_exists( WP_CONTENT_DIR . '/db.php' ) )
399
-		require_once( WP_CONTENT_DIR . '/db.php' );
397
+	require_once(ABSPATH.WPINC.'/wp-db.php');
398
+	if (file_exists(WP_CONTENT_DIR.'/db.php'))
399
+		require_once(WP_CONTENT_DIR.'/db.php');
400 400
 
401
-	if ( isset( $wpdb ) )
401
+	if (isset($wpdb))
402 402
 		return;
403 403
 
404
-	$wpdb = new wpdb( DB_USER, DB_PASSWORD, DB_NAME, DB_HOST );
404
+	$wpdb = new wpdb(DB_USER, DB_PASSWORD, DB_NAME, DB_HOST);
405 405
 }
406 406
 
407 407
 /**
@@ -418,24 +418,24 @@  discard block
 block discarded – undo
418 418
  */
419 419
 function wp_set_wpdb_vars() {
420 420
 	global $wpdb, $table_prefix;
421
-	if ( !empty( $wpdb->error ) )
421
+	if ( ! empty($wpdb->error))
422 422
 		dead_db();
423 423
 
424
-	$wpdb->field_types = array( 'post_author' => '%d', 'post_parent' => '%d', 'menu_order' => '%d', 'term_id' => '%d', 'term_group' => '%d', 'term_taxonomy_id' => '%d',
425
-		'parent' => '%d', 'count' => '%d','object_id' => '%d', 'term_order' => '%d', 'ID' => '%d', 'comment_ID' => '%d', 'comment_post_ID' => '%d', 'comment_parent' => '%d',
424
+	$wpdb->field_types = array('post_author' => '%d', 'post_parent' => '%d', 'menu_order' => '%d', 'term_id' => '%d', 'term_group' => '%d', 'term_taxonomy_id' => '%d',
425
+		'parent' => '%d', 'count' => '%d', 'object_id' => '%d', 'term_order' => '%d', 'ID' => '%d', 'comment_ID' => '%d', 'comment_post_ID' => '%d', 'comment_parent' => '%d',
426 426
 		'user_id' => '%d', 'link_id' => '%d', 'link_owner' => '%d', 'link_rating' => '%d', 'option_id' => '%d', 'blog_id' => '%d', 'meta_id' => '%d', 'post_id' => '%d',
427 427
 		'user_status' => '%d', 'umeta_id' => '%d', 'comment_karma' => '%d', 'comment_count' => '%d',
428 428
 		// multisite:
429 429
 		'active' => '%d', 'cat_id' => '%d', 'deleted' => '%d', 'lang_id' => '%d', 'mature' => '%d', 'public' => '%d', 'site_id' => '%d', 'spam' => '%d',
430 430
 	);
431 431
 
432
-	$prefix = $wpdb->set_prefix( $table_prefix );
432
+	$prefix = $wpdb->set_prefix($table_prefix);
433 433
 
434
-	if ( is_wp_error( $prefix ) ) {
434
+	if (is_wp_error($prefix)) {
435 435
 		wp_load_translations_early();
436 436
 		wp_die(
437 437
 			/* translators: 1: $table_prefix 2: wp-config.php */
438
-			sprintf( __( '<strong>ERROR</strong>: %1$s in %2$s can only contain numbers, letters, and underscores.' ),
438
+			sprintf(__('<strong>ERROR</strong>: %1$s in %2$s can only contain numbers, letters, and underscores.'),
439 439
 				'<code>$table_prefix</code>',
440 440
 				'<code>wp-config.php</code>'
441 441
 			)
@@ -454,10 +454,10 @@  discard block
 block discarded – undo
454 454
  * @param bool $using Whether external object cache is being used.
455 455
  * @return bool The current 'using' setting.
456 456
  */
457
-function wp_using_ext_object_cache( $using = null ) {
457
+function wp_using_ext_object_cache($using = null) {
458 458
 	global $_wp_using_ext_object_cache;
459 459
 	$current_using = $_wp_using_ext_object_cache;
460
-	if ( null !== $using )
460
+	if (null !== $using)
461 461
 		$_wp_using_ext_object_cache = $using;
462 462
 	return $current_using;
463 463
 }
@@ -477,40 +477,40 @@  discard block
 block discarded – undo
477 477
 	global $blog_id;
478 478
 
479 479
 	$first_init = false;
480
- 	if ( ! function_exists( 'wp_cache_init' ) ) {
481
-		if ( file_exists( WP_CONTENT_DIR . '/object-cache.php' ) ) {
482
-			require_once ( WP_CONTENT_DIR . '/object-cache.php' );
483
-			if ( function_exists( 'wp_cache_init' ) )
484
-				wp_using_ext_object_cache( true );
480
+ 	if ( ! function_exists('wp_cache_init')) {
481
+		if (file_exists(WP_CONTENT_DIR.'/object-cache.php')) {
482
+			require_once (WP_CONTENT_DIR.'/object-cache.php');
483
+			if (function_exists('wp_cache_init'))
484
+				wp_using_ext_object_cache(true);
485 485
 		}
486 486
 
487 487
 		$first_init = true;
488
-	} elseif ( ! wp_using_ext_object_cache() && file_exists( WP_CONTENT_DIR . '/object-cache.php' ) ) {
488
+	} elseif ( ! wp_using_ext_object_cache() && file_exists(WP_CONTENT_DIR.'/object-cache.php')) {
489 489
 		/*
490 490
 		 * Sometimes advanced-cache.php can load object-cache.php before
491 491
 		 * it is loaded here. This breaks the function_exists check above
492 492
 		 * and can result in `$_wp_using_ext_object_cache` being set
493 493
 		 * incorrectly. Double check if an external cache exists.
494 494
 		 */
495
-		wp_using_ext_object_cache( true );
495
+		wp_using_ext_object_cache(true);
496 496
 	}
497 497
 
498
-	if ( ! wp_using_ext_object_cache() )
499
-		require_once ( ABSPATH . WPINC . '/cache.php' );
498
+	if ( ! wp_using_ext_object_cache())
499
+		require_once (ABSPATH.WPINC.'/cache.php');
500 500
 
501 501
 	/*
502 502
 	 * If cache supports reset, reset instead of init if already
503 503
 	 * initialized. Reset signals to the cache that global IDs
504 504
 	 * have changed and it may need to update keys and cleanup caches.
505 505
 	 */
506
-	if ( ! $first_init && function_exists( 'wp_cache_switch_to_blog' ) )
507
-		wp_cache_switch_to_blog( $blog_id );
508
-	elseif ( function_exists( 'wp_cache_init' ) )
506
+	if ( ! $first_init && function_exists('wp_cache_switch_to_blog'))
507
+		wp_cache_switch_to_blog($blog_id);
508
+	elseif (function_exists('wp_cache_init'))
509 509
 		wp_cache_init();
510 510
 
511
-	if ( function_exists( 'wp_cache_add_global_groups' ) ) {
512
-		wp_cache_add_global_groups( array( 'users', 'userlogins', 'usermeta', 'user_meta', 'useremail', 'userslugs', 'site-transient', 'site-options', 'site-lookup', 'blog-lookup', 'blog-details', 'rss', 'global-posts', 'blog-id-cache', 'networks', 'sites' ) );
513
-		wp_cache_add_non_persistent_groups( array( 'counts', 'plugins' ) );
511
+	if (function_exists('wp_cache_add_global_groups')) {
512
+		wp_cache_add_global_groups(array('users', 'userlogins', 'usermeta', 'user_meta', 'useremail', 'userslugs', 'site-transient', 'site-options', 'site-lookup', 'blog-lookup', 'blog-details', 'rss', 'global-posts', 'blog-id-cache', 'networks', 'sites'));
513
+		wp_cache_add_non_persistent_groups(array('counts', 'plugins'));
514 514
 	}
515 515
 }
516 516
 
@@ -523,22 +523,22 @@  discard block
 block discarded – undo
523 523
  * @access private
524 524
  */
525 525
 function wp_not_installed() {
526
-	if ( is_multisite() ) {
527
-		if ( ! is_blog_installed() && ! wp_installing() ) {
526
+	if (is_multisite()) {
527
+		if ( ! is_blog_installed() && ! wp_installing()) {
528 528
 			nocache_headers();
529 529
 
530
-			wp_die( __( 'The site you have requested is not installed properly. Please contact the system administrator.' ) );
530
+			wp_die(__('The site you have requested is not installed properly. Please contact the system administrator.'));
531 531
 		}
532
-	} elseif ( ! is_blog_installed() && ! wp_installing() ) {
532
+	} elseif ( ! is_blog_installed() && ! wp_installing()) {
533 533
 		nocache_headers();
534 534
 
535
-		require( ABSPATH . WPINC . '/kses.php' );
536
-		require( ABSPATH . WPINC . '/pluggable.php' );
537
-		require( ABSPATH . WPINC . '/formatting.php' );
535
+		require(ABSPATH.WPINC.'/kses.php');
536
+		require(ABSPATH.WPINC.'/pluggable.php');
537
+		require(ABSPATH.WPINC.'/formatting.php');
538 538
 
539
-		$link = wp_guess_url() . '/wp-admin/install.php';
539
+		$link = wp_guess_url().'/wp-admin/install.php';
540 540
 
541
-		wp_redirect( $link );
541
+		wp_redirect($link);
542 542
 		die();
543 543
 	}
544 544
 }
@@ -557,16 +557,16 @@  discard block
 block discarded – undo
557 557
  */
558 558
 function wp_get_mu_plugins() {
559 559
 	$mu_plugins = array();
560
-	if ( !is_dir( WPMU_PLUGIN_DIR ) )
560
+	if ( ! is_dir(WPMU_PLUGIN_DIR))
561 561
 		return $mu_plugins;
562
-	if ( ! $dh = opendir( WPMU_PLUGIN_DIR ) )
562
+	if ( ! $dh = opendir(WPMU_PLUGIN_DIR))
563 563
 		return $mu_plugins;
564
-	while ( ( $plugin = readdir( $dh ) ) !== false ) {
565
-		if ( substr( $plugin, -4 ) == '.php' )
566
-			$mu_plugins[] = WPMU_PLUGIN_DIR . '/' . $plugin;
564
+	while (($plugin = readdir($dh)) !== false) {
565
+		if (substr($plugin, -4) == '.php')
566
+			$mu_plugins[] = WPMU_PLUGIN_DIR.'/'.$plugin;
567 567
 	}
568
-	closedir( $dh );
569
-	sort( $mu_plugins );
568
+	closedir($dh);
569
+	sort($mu_plugins);
570 570
 
571 571
 	return $mu_plugins;
572 572
 }
@@ -587,27 +587,27 @@  discard block
 block discarded – undo
587 587
  */
588 588
 function wp_get_active_and_valid_plugins() {
589 589
 	$plugins = array();
590
-	$active_plugins = (array) get_option( 'active_plugins', array() );
590
+	$active_plugins = (array) get_option('active_plugins', array());
591 591
 
592 592
 	// Check for hacks file if the option is enabled
593
-	if ( get_option( 'hack_file' ) && file_exists( ABSPATH . 'my-hacks.php' ) ) {
594
-		_deprecated_file( 'my-hacks.php', '1.5' );
595
-		array_unshift( $plugins, ABSPATH . 'my-hacks.php' );
593
+	if (get_option('hack_file') && file_exists(ABSPATH.'my-hacks.php')) {
594
+		_deprecated_file('my-hacks.php', '1.5');
595
+		array_unshift($plugins, ABSPATH.'my-hacks.php');
596 596
 	}
597 597
 
598
-	if ( empty( $active_plugins ) || wp_installing() )
598
+	if (empty($active_plugins) || wp_installing())
599 599
 		return $plugins;
600 600
 
601 601
 	$network_plugins = is_multisite() ? wp_get_active_network_plugins() : false;
602 602
 
603
-	foreach ( $active_plugins as $plugin ) {
604
-		if ( ! validate_file( $plugin ) // $plugin must validate as file
605
-			&& '.php' == substr( $plugin, -4 ) // $plugin must end with '.php'
606
-			&& file_exists( WP_PLUGIN_DIR . '/' . $plugin ) // $plugin must exist
603
+	foreach ($active_plugins as $plugin) {
604
+		if ( ! validate_file($plugin) // $plugin must validate as file
605
+			&& '.php' == substr($plugin, -4) // $plugin must end with '.php'
606
+			&& file_exists(WP_PLUGIN_DIR.'/'.$plugin) // $plugin must exist
607 607
 			// not already included as a network plugin
608
-			&& ( ! $network_plugins || ! in_array( WP_PLUGIN_DIR . '/' . $plugin, $network_plugins ) )
608
+			&& ( ! $network_plugins || ! in_array(WP_PLUGIN_DIR.'/'.$plugin, $network_plugins))
609 609
 			)
610
-		$plugins[] = WP_PLUGIN_DIR . '/' . $plugin;
610
+		$plugins[] = WP_PLUGIN_DIR.'/'.$plugin;
611 611
 	}
612 612
 	return $plugins;
613 613
 }
@@ -622,10 +622,10 @@  discard block
 block discarded – undo
622 622
  * @access private
623 623
  */
624 624
 function wp_set_internal_encoding() {
625
-	if ( function_exists( 'mb_internal_encoding' ) ) {
626
-		$charset = get_option( 'blog_charset' );
627
-		if ( ! $charset || ! @mb_internal_encoding( $charset ) )
628
-			mb_internal_encoding( 'UTF-8' );
625
+	if (function_exists('mb_internal_encoding')) {
626
+		$charset = get_option('blog_charset');
627
+		if ( ! $charset || ! @mb_internal_encoding($charset))
628
+			mb_internal_encoding('UTF-8');
629 629
 	}
630 630
 }
631 631
 
@@ -640,20 +640,20 @@  discard block
 block discarded – undo
640 640
  */
641 641
 function wp_magic_quotes() {
642 642
 	// If already slashed, strip.
643
-	if ( get_magic_quotes_gpc() ) {
644
-		$_GET    = stripslashes_deep( $_GET    );
645
-		$_POST   = stripslashes_deep( $_POST   );
646
-		$_COOKIE = stripslashes_deep( $_COOKIE );
643
+	if (get_magic_quotes_gpc()) {
644
+		$_GET    = stripslashes_deep($_GET);
645
+		$_POST   = stripslashes_deep($_POST);
646
+		$_COOKIE = stripslashes_deep($_COOKIE);
647 647
 	}
648 648
 
649 649
 	// Escape with wpdb.
650
-	$_GET    = add_magic_quotes( $_GET    );
651
-	$_POST   = add_magic_quotes( $_POST   );
652
-	$_COOKIE = add_magic_quotes( $_COOKIE );
653
-	$_SERVER = add_magic_quotes( $_SERVER );
650
+	$_GET    = add_magic_quotes($_GET);
651
+	$_POST   = add_magic_quotes($_POST);
652
+	$_COOKIE = add_magic_quotes($_COOKIE);
653
+	$_SERVER = add_magic_quotes($_SERVER);
654 654
 
655 655
 	// Force REQUEST to be GET + POST.
656
-	$_REQUEST = array_merge( $_GET, $_POST );
656
+	$_REQUEST = array_merge($_GET, $_POST);
657 657
 }
658 658
 
659 659
 /**
@@ -668,7 +668,7 @@  discard block
 block discarded – undo
668 668
 	 *
669 669
 	 * @since 1.2.0
670 670
 	 */
671
-	do_action( 'shutdown' );
671
+	do_action('shutdown');
672 672
 
673 673
 	wp_cache_close();
674 674
 }
@@ -682,9 +682,9 @@  discard block
 block discarded – undo
682 682
  * @param object $object The object to clone.
683 683
  * @return object The cloned object.
684 684
  */
685
-function wp_clone( $object ) {
685
+function wp_clone($object) {
686 686
 	// Use parens for clone to accommodate PHP 4. See #17880
687
-	return clone( $object );
687
+	return clone($object);
688 688
 }
689 689
 
690 690
 /**
@@ -700,9 +700,9 @@  discard block
 block discarded – undo
700 700
  * @return bool True if inside WordPress administration interface, false otherwise.
701 701
  */
702 702
 function is_admin() {
703
-	if ( isset( $GLOBALS['current_screen'] ) )
703
+	if (isset($GLOBALS['current_screen']))
704 704
 		return $GLOBALS['current_screen']->in_admin();
705
-	elseif ( defined( 'WP_ADMIN' ) )
705
+	elseif (defined('WP_ADMIN'))
706 706
 		return WP_ADMIN;
707 707
 
708 708
 	return false;
@@ -723,9 +723,9 @@  discard block
 block discarded – undo
723 723
  * @return bool True if inside WordPress blog administration pages.
724 724
  */
725 725
 function is_blog_admin() {
726
-	if ( isset( $GLOBALS['current_screen'] ) )
727
-		return $GLOBALS['current_screen']->in_admin( 'site' );
728
-	elseif ( defined( 'WP_BLOG_ADMIN' ) )
726
+	if (isset($GLOBALS['current_screen']))
727
+		return $GLOBALS['current_screen']->in_admin('site');
728
+	elseif (defined('WP_BLOG_ADMIN'))
729 729
 		return WP_BLOG_ADMIN;
730 730
 
731 731
 	return false;
@@ -746,9 +746,9 @@  discard block
 block discarded – undo
746 746
  * @return bool True if inside WordPress network administration pages.
747 747
  */
748 748
 function is_network_admin() {
749
-	if ( isset( $GLOBALS['current_screen'] ) )
750
-		return $GLOBALS['current_screen']->in_admin( 'network' );
751
-	elseif ( defined( 'WP_NETWORK_ADMIN' ) )
749
+	if (isset($GLOBALS['current_screen']))
750
+		return $GLOBALS['current_screen']->in_admin('network');
751
+	elseif (defined('WP_NETWORK_ADMIN'))
752 752
 		return WP_NETWORK_ADMIN;
753 753
 
754 754
 	return false;
@@ -770,9 +770,9 @@  discard block
 block discarded – undo
770 770
  * @return bool True if inside WordPress user administration pages.
771 771
  */
772 772
 function is_user_admin() {
773
-	if ( isset( $GLOBALS['current_screen'] ) )
774
-		return $GLOBALS['current_screen']->in_admin( 'user' );
775
-	elseif ( defined( 'WP_USER_ADMIN' ) )
773
+	if (isset($GLOBALS['current_screen']))
774
+		return $GLOBALS['current_screen']->in_admin('user');
775
+	elseif (defined('WP_USER_ADMIN'))
776 776
 		return WP_USER_ADMIN;
777 777
 
778 778
 	return false;
@@ -786,10 +786,10 @@  discard block
 block discarded – undo
786 786
  * @return bool True if Multisite is enabled, false otherwise.
787 787
  */
788 788
 function is_multisite() {
789
-	if ( defined( 'MULTISITE' ) )
789
+	if (defined('MULTISITE'))
790 790
 		return MULTISITE;
791 791
 
792
-	if ( defined( 'SUBDOMAIN_INSTALL' ) || defined( 'VHOST' ) || defined( 'SUNRISE' ) )
792
+	if (defined('SUBDOMAIN_INSTALL') || defined('VHOST') || defined('SUNRISE'))
793 793
 		return true;
794 794
 
795 795
 	return false;
@@ -819,17 +819,17 @@  discard block
 block discarded – undo
819 819
  * @return int The ID of the current network.
820 820
  */
821 821
 function get_current_network_id() {
822
-	if ( ! is_multisite() ) {
822
+	if ( ! is_multisite()) {
823 823
 		return 1;
824 824
 	}
825 825
 
826 826
 	$current_site = get_current_site();
827 827
 
828
-	if ( ! isset( $current_site->id ) ) {
828
+	if ( ! isset($current_site->id)) {
829 829
 		return get_main_network_id();
830 830
 	}
831 831
 
832
-	return absint( $current_site->id );
832
+	return absint($current_site->id);
833 833
 }
834 834
 
835 835
 /**
@@ -854,62 +854,62 @@  discard block
 block discarded – undo
854 854
 	global $text_direction, $wp_locale;
855 855
 
856 856
 	static $loaded = false;
857
-	if ( $loaded )
857
+	if ($loaded)
858 858
 		return;
859 859
 	$loaded = true;
860 860
 
861
-	if ( function_exists( 'did_action' ) && did_action( 'init' ) )
861
+	if (function_exists('did_action') && did_action('init'))
862 862
 		return;
863 863
 
864 864
 	// We need $wp_local_package
865
-	require ABSPATH . WPINC . '/version.php';
865
+	require ABSPATH.WPINC.'/version.php';
866 866
 
867 867
 	// Translation and localization
868
-	require_once ABSPATH . WPINC . '/pomo/mo.php';
869
-	require_once ABSPATH . WPINC . '/l10n.php';
870
-	require_once ABSPATH . WPINC . '/locale.php';
868
+	require_once ABSPATH.WPINC.'/pomo/mo.php';
869
+	require_once ABSPATH.WPINC.'/l10n.php';
870
+	require_once ABSPATH.WPINC.'/locale.php';
871 871
 
872 872
 	// General libraries
873
-	require_once ABSPATH . WPINC . '/plugin.php';
873
+	require_once ABSPATH.WPINC.'/plugin.php';
874 874
 
875 875
 	$locales = $locations = array();
876 876
 
877
-	while ( true ) {
878
-		if ( defined( 'WPLANG' ) ) {
879
-			if ( '' == WPLANG )
877
+	while (true) {
878
+		if (defined('WPLANG')) {
879
+			if ('' == WPLANG)
880 880
 				break;
881 881
 			$locales[] = WPLANG;
882 882
 		}
883 883
 
884
-		if ( isset( $wp_local_package ) )
884
+		if (isset($wp_local_package))
885 885
 			$locales[] = $wp_local_package;
886 886
 
887
-		if ( ! $locales )
887
+		if ( ! $locales)
888 888
 			break;
889 889
 
890
-		if ( defined( 'WP_LANG_DIR' ) && @is_dir( WP_LANG_DIR ) )
890
+		if (defined('WP_LANG_DIR') && @is_dir(WP_LANG_DIR))
891 891
 			$locations[] = WP_LANG_DIR;
892 892
 
893
-		if ( defined( 'WP_CONTENT_DIR' ) && @is_dir( WP_CONTENT_DIR . '/languages' ) )
894
-			$locations[] = WP_CONTENT_DIR . '/languages';
893
+		if (defined('WP_CONTENT_DIR') && @is_dir(WP_CONTENT_DIR.'/languages'))
894
+			$locations[] = WP_CONTENT_DIR.'/languages';
895 895
 
896
-		if ( @is_dir( ABSPATH . 'wp-content/languages' ) )
897
-			$locations[] = ABSPATH . 'wp-content/languages';
896
+		if (@is_dir(ABSPATH.'wp-content/languages'))
897
+			$locations[] = ABSPATH.'wp-content/languages';
898 898
 
899
-		if ( @is_dir( ABSPATH . WPINC . '/languages' ) )
900
-			$locations[] = ABSPATH . WPINC . '/languages';
899
+		if (@is_dir(ABSPATH.WPINC.'/languages'))
900
+			$locations[] = ABSPATH.WPINC.'/languages';
901 901
 
902
-		if ( ! $locations )
902
+		if ( ! $locations)
903 903
 			break;
904 904
 
905
-		$locations = array_unique( $locations );
905
+		$locations = array_unique($locations);
906 906
 
907
-		foreach ( $locales as $locale ) {
908
-			foreach ( $locations as $location ) {
909
-				if ( file_exists( $location . '/' . $locale . '.mo' ) ) {
910
-					load_textdomain( 'default', $location . '/' . $locale . '.mo' );
911
-					if ( defined( 'WP_SETUP_CONFIG' ) && file_exists( $location . '/admin-' . $locale . '.mo' ) )
912
-						load_textdomain( 'default', $location . '/admin-' . $locale . '.mo' );
907
+		foreach ($locales as $locale) {
908
+			foreach ($locations as $location) {
909
+				if (file_exists($location.'/'.$locale.'.mo')) {
910
+					load_textdomain('default', $location.'/'.$locale.'.mo');
911
+					if (defined('WP_SETUP_CONFIG') && file_exists($location.'/admin-'.$locale.'.mo'))
912
+						load_textdomain('default', $location.'/admin-'.$locale.'.mo');
913 913
 					break 2;
914 914
 				}
915 915
 			}
@@ -935,15 +935,15 @@  discard block
 block discarded – undo
935 935
  * @return bool True if WP is installing, otherwise false. When a `$is_installing` is passed, the function will
936 936
  *              report whether WP was in installing mode prior to the change to `$is_installing`.
937 937
  */
938
-function wp_installing( $is_installing = null ) {
938
+function wp_installing($is_installing = null) {
939 939
 	static $installing = null;
940 940
 
941 941
 	// Support for the `WP_INSTALLING` constant, defined before WP is loaded.
942
-	if ( is_null( $installing ) ) {
943
-		$installing = defined( 'WP_INSTALLING' ) && WP_INSTALLING;
942
+	if (is_null($installing)) {
943
+		$installing = defined('WP_INSTALLING') && WP_INSTALLING;
944 944
 	}
945 945
 
946
-	if ( ! is_null( $is_installing ) ) {
946
+	if ( ! is_null($is_installing)) {
947 947
 		$old_installing = $installing;
948 948
 		$installing = $is_installing;
949 949
 		return (bool) $old_installing;
@@ -961,15 +961,15 @@  discard block
 block discarded – undo
961 961
  * @return bool True if SSL, otherwise false.
962 962
  */
963 963
 function is_ssl() {
964
-	if ( isset( $_SERVER['HTTPS'] ) ) {
965
-		if ( 'on' == strtolower( $_SERVER['HTTPS'] ) ) {
964
+	if (isset($_SERVER['HTTPS'])) {
965
+		if ('on' == strtolower($_SERVER['HTTPS'])) {
966 966
 			return true;
967 967
 		}
968 968
 
969
-		if ( '1' == $_SERVER['HTTPS'] ) {
969
+		if ('1' == $_SERVER['HTTPS']) {
970 970
 			return true;
971 971
 		}
972
-	} elseif ( isset($_SERVER['SERVER_PORT'] ) && ( '443' == $_SERVER['SERVER_PORT'] ) ) {
972
+	} elseif (isset($_SERVER['SERVER_PORT']) && ('443' == $_SERVER['SERVER_PORT'])) {
973 973
 		return true;
974 974
 	}
975 975
 	return false;
Please login to merge, or discard this patch.
src/wp-includes/ms-blogs.php 4 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -595,7 +595,7 @@
 block discarded – undo
595 595
  *
596 596
  * @param int  $new_blog   The id of the blog you want to switch to. Default: current blog
597 597
  * @param bool $deprecated Deprecated argument
598
- * @return true Always returns True.
598
+ * @return boolean Always returns True.
599 599
  */
600 600
 function switch_to_blog( $new_blog, $deprecated = null ) {
601 601
 	global $wpdb;
Please login to merge, or discard this patch.
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -845,7 +845,7 @@
 block discarded – undo
845 845
 		 *
846 846
 		 * @param int    $blog_id Blog ID.
847 847
 		 * @param string $value   The value of blog status.
848
- 		 */
848
+		 */
849 849
 		do_action( 'update_blog_public', $blog_id, $value ); // Moved here from update_blog_public().
850 850
 	}
851 851
 
Please login to merge, or discard this patch.
Braces   +90 added lines, -62 removed lines patch added patch discarded remove patch
@@ -52,11 +52,13 @@  discard block
 block discarded – undo
52 52
  */
53 53
 function get_blogaddress_by_name( $blogname ) {
54 54
 	if ( is_subdomain_install() ) {
55
-		if ( $blogname == 'main' )
56
-			$blogname = 'www';
55
+		if ( $blogname == 'main' ) {
56
+					$blogname = 'www';
57
+		}
57 58
 		$url = rtrim( network_home_url(), '/' );
58
-		if ( !empty( $blogname ) )
59
-			$url = preg_replace( '|^([^\.]+://)|', "\${1}" . $blogname . '.', $url );
59
+		if ( !empty( $blogname ) ) {
60
+					$url = preg_replace( '|^([^\.]+://)|', "\${1}" . $blogname . '.', $url );
61
+		}
60 62
 	} else {
61 63
 		$url = network_home_url( $blogname );
62 64
 	}
@@ -80,8 +82,9 @@  discard block
 block discarded – undo
80 82
 	$slug = trim( $slug, '/' );
81 83
 
82 84
 	$blog_id = wp_cache_get( 'get_id_from_blogname_' . $slug, 'blog-details' );
83
-	if ( $blog_id )
84
-		return $blog_id;
85
+	if ( $blog_id ) {
86
+			return $blog_id;
87
+	}
85 88
 
86 89
 	if ( is_subdomain_install() ) {
87 90
 		$domain = $slug . '.' . $current_site->domain;
@@ -118,8 +121,9 @@  discard block
 block discarded – undo
118 121
 		} elseif ( isset($fields['domain']) && isset($fields['path']) ) {
119 122
 			$key = md5( $fields['domain'] . $fields['path'] );
120 123
 			$blog = wp_cache_get($key, 'blog-lookup');
121
-			if ( false !== $blog )
122
-				return $blog;
124
+			if ( false !== $blog ) {
125
+							return $blog;
126
+			}
123 127
 			if ( substr( $fields['domain'], 0, 4 ) == 'www.' ) {
124 128
 				$nowww = substr( $fields['domain'], 4 );
125 129
 				$blog = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM $wpdb->blogs WHERE domain IN (%s,%s) AND path = %s ORDER BY CHAR_LENGTH(domain) DESC", $nowww, $fields['domain'], $fields['path'] ) );
@@ -135,8 +139,9 @@  discard block
 block discarded – undo
135 139
 		} elseif ( isset($fields['domain']) && is_subdomain_install() ) {
136 140
 			$key = md5( $fields['domain'] );
137 141
 			$blog = wp_cache_get($key, 'blog-lookup');
138
-			if ( false !== $blog )
139
-				return $blog;
142
+			if ( false !== $blog ) {
143
+							return $blog;
144
+			}
140 145
 			if ( substr( $fields['domain'], 0, 4 ) == 'www.' ) {
141 146
 				$nowww = substr( $fields['domain'], 4 );
142 147
 				$blog = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM $wpdb->blogs WHERE domain IN (%s,%s) ORDER BY CHAR_LENGTH(domain) DESC", $nowww, $fields['domain'] ) );
@@ -153,12 +158,13 @@  discard block
 block discarded – undo
153 158
 			return false;
154 159
 		}
155 160
 	} else {
156
-		if ( ! $fields )
157
-			$blog_id = get_current_blog_id();
158
-		elseif ( ! is_numeric( $fields ) )
159
-			$blog_id = get_id_from_blogname( $fields );
160
-		else
161
-			$blog_id = $fields;
161
+		if ( ! $fields ) {
162
+					$blog_id = get_current_blog_id();
163
+		} elseif ( ! is_numeric( $fields ) ) {
164
+					$blog_id = get_id_from_blogname( $fields );
165
+		} else {
166
+					$blog_id = $fields;
167
+		}
162 168
 	}
163 169
 
164 170
 	$blog_id = (int) $blog_id;
@@ -289,15 +295,18 @@  discard block
 block discarded – undo
289 295
 function update_blog_details( $blog_id, $details = array() ) {
290 296
 	global $wpdb;
291 297
 
292
-	if ( empty($details) )
293
-		return false;
298
+	if ( empty($details) ) {
299
+			return false;
300
+	}
294 301
 
295
-	if ( is_object($details) )
296
-		$details = get_object_vars($details);
302
+	if ( is_object($details) ) {
303
+			$details = get_object_vars($details);
304
+	}
297 305
 
298 306
 	$current_details = get_blog_details($blog_id, false);
299
-	if ( empty($current_details) )
300
-		return false;
307
+	if ( empty($current_details) ) {
308
+			return false;
309
+	}
301 310
 
302 311
 	$current_details = get_object_vars($current_details);
303 312
 
@@ -316,8 +325,9 @@  discard block
 block discarded – undo
316 325
 
317 326
 	$result = $wpdb->update( $wpdb->blogs, $update_details, array('blog_id' => $blog_id) );
318 327
 
319
-	if ( false === $result )
320
-		return false;
328
+	if ( false === $result ) {
329
+			return false;
330
+	}
321 331
 
322 332
 	// If spam status changed, issue actions.
323 333
 	if ( $details['spam'] != $current_details['spam'] ) {
@@ -462,11 +472,13 @@  discard block
 block discarded – undo
462 472
 function get_blog_option( $id, $option, $default = false ) {
463 473
 	$id = (int) $id;
464 474
 
465
-	if ( empty( $id ) )
466
-		$id = get_current_blog_id();
475
+	if ( empty( $id ) ) {
476
+			$id = get_current_blog_id();
477
+	}
467 478
 
468
-	if ( get_current_blog_id() == $id )
469
-		return get_option( $option, $default );
479
+	if ( get_current_blog_id() == $id ) {
480
+			return get_option( $option, $default );
481
+	}
470 482
 
471 483
 	switch_to_blog( $id );
472 484
 	$value = get_option( $option, $default );
@@ -507,11 +519,13 @@  discard block
 block discarded – undo
507 519
 function add_blog_option( $id, $option, $value ) {
508 520
 	$id = (int) $id;
509 521
 
510
-	if ( empty( $id ) )
511
-		$id = get_current_blog_id();
522
+	if ( empty( $id ) ) {
523
+			$id = get_current_blog_id();
524
+	}
512 525
 
513
-	if ( get_current_blog_id() == $id )
514
-		return add_option( $option, $value );
526
+	if ( get_current_blog_id() == $id ) {
527
+			return add_option( $option, $value );
528
+	}
515 529
 
516 530
 	switch_to_blog( $id );
517 531
 	$return = add_option( $option, $value );
@@ -532,11 +546,13 @@  discard block
 block discarded – undo
532 546
 function delete_blog_option( $id, $option ) {
533 547
 	$id = (int) $id;
534 548
 
535
-	if ( empty( $id ) )
536
-		$id = get_current_blog_id();
549
+	if ( empty( $id ) ) {
550
+			$id = get_current_blog_id();
551
+	}
537 552
 
538
-	if ( get_current_blog_id() == $id )
539
-		return delete_option( $option );
553
+	if ( get_current_blog_id() == $id ) {
554
+			return delete_option( $option );
555
+	}
540 556
 
541 557
 	switch_to_blog( $id );
542 558
 	$return = delete_option( $option );
@@ -558,11 +574,13 @@  discard block
 block discarded – undo
558 574
 function update_blog_option( $id, $option, $value, $deprecated = null ) {
559 575
 	$id = (int) $id;
560 576
 
561
-	if ( null !== $deprecated  )
562
-		_deprecated_argument( __FUNCTION__, '3.1' );
577
+	if ( null !== $deprecated  ) {
578
+			_deprecated_argument( __FUNCTION__, '3.1' );
579
+	}
563 580
 
564
-	if ( get_current_blog_id() == $id )
565
-		return update_option( $option, $value );
581
+	if ( get_current_blog_id() == $id ) {
582
+			return update_option( $option, $value );
583
+	}
566 584
 
567 585
 	switch_to_blog( $id );
568 586
 	$return = update_option( $option, $value );
@@ -600,8 +618,9 @@  discard block
 block discarded – undo
600 618
 function switch_to_blog( $new_blog, $deprecated = null ) {
601 619
 	global $wpdb;
602 620
 
603
-	if ( empty( $new_blog ) )
604
-		$new_blog = $GLOBALS['blog_id'];
621
+	if ( empty( $new_blog ) ) {
622
+			$new_blog = $GLOBALS['blog_id'];
623
+	}
605 624
 
606 625
 	$GLOBALS['_wp_switched_stack'][] = $GLOBALS['blog_id'];
607 626
 
@@ -634,10 +653,11 @@  discard block
 block discarded – undo
634 653
 	} else {
635 654
 		global $wp_object_cache;
636 655
 
637
-		if ( is_object( $wp_object_cache ) && isset( $wp_object_cache->global_groups ) )
638
-			$global_groups = $wp_object_cache->global_groups;
639
-		else
640
-			$global_groups = false;
656
+		if ( is_object( $wp_object_cache ) && isset( $wp_object_cache->global_groups ) ) {
657
+					$global_groups = $wp_object_cache->global_groups;
658
+		} else {
659
+					$global_groups = false;
660
+		}
641 661
 
642 662
 		wp_cache_init();
643 663
 
@@ -682,8 +702,9 @@  discard block
 block discarded – undo
682 702
 function restore_current_blog() {
683 703
 	global $wpdb;
684 704
 
685
-	if ( empty( $GLOBALS['_wp_switched_stack'] ) )
686
-		return false;
705
+	if ( empty( $GLOBALS['_wp_switched_stack'] ) ) {
706
+			return false;
707
+	}
687 708
 
688 709
 	$blog = array_pop( $GLOBALS['_wp_switched_stack'] );
689 710
 
@@ -705,10 +726,11 @@  discard block
 block discarded – undo
705 726
 	} else {
706 727
 		global $wp_object_cache;
707 728
 
708
-		if ( is_object( $wp_object_cache ) && isset( $wp_object_cache->global_groups ) )
709
-			$global_groups = $wp_object_cache->global_groups;
710
-		else
711
-			$global_groups = false;
729
+		if ( is_object( $wp_object_cache ) && isset( $wp_object_cache->global_groups ) ) {
730
+					$global_groups = $wp_object_cache->global_groups;
731
+		} else {
732
+					$global_groups = false;
733
+		}
712 734
 
713 735
 		wp_cache_init();
714 736
 
@@ -792,16 +814,19 @@  discard block
 block discarded – undo
792 814
 function update_blog_status( $blog_id, $pref, $value, $deprecated = null ) {
793 815
 	global $wpdb;
794 816
 
795
-	if ( null !== $deprecated  )
796
-		_deprecated_argument( __FUNCTION__, '3.1' );
817
+	if ( null !== $deprecated  ) {
818
+			_deprecated_argument( __FUNCTION__, '3.1' );
819
+	}
797 820
 
798
-	if ( ! in_array( $pref, array( 'site_id', 'domain', 'path', 'registered', 'last_updated', 'public', 'archived', 'mature', 'spam', 'deleted', 'lang_id') ) )
799
-		return $value;
821
+	if ( ! in_array( $pref, array( 'site_id', 'domain', 'path', 'registered', 'last_updated', 'public', 'archived', 'mature', 'spam', 'deleted', 'lang_id') ) ) {
822
+			return $value;
823
+	}
800 824
 
801 825
 	$result = $wpdb->update( $wpdb->blogs, array($pref => $value, 'last_updated' => current_time('mysql', true)), array('blog_id' => $blog_id) );
802 826
 
803
-	if ( false === $result )
804
-		return false;
827
+	if ( false === $result ) {
828
+			return false;
829
+	}
805 830
 
806 831
 	refresh_blog_details( $blog_id );
807 832
 
@@ -867,8 +892,9 @@  discard block
 block discarded – undo
867 892
 	global $wpdb;
868 893
 
869 894
 	$details = get_blog_details( $id, false );
870
-	if ( $details )
871
-		return $details->$pref;
895
+	if ( $details ) {
896
+			return $details->$pref;
897
+	}
872 898
 
873 899
 	return $wpdb->get_var( $wpdb->prepare("SELECT %s FROM {$wpdb->blogs} WHERE blog_id = %d", $pref, $id) );
874 900
 }
@@ -888,8 +914,10 @@  discard block
 block discarded – undo
888 914
 function get_last_updated( $deprecated = '', $start = 0, $quantity = 40 ) {
889 915
 	global $wpdb;
890 916
 
891
-	if ( ! empty( $deprecated ) )
892
-		_deprecated_argument( __FUNCTION__, 'MU' ); // never used
917
+	if ( ! empty( $deprecated ) ) {
918
+			_deprecated_argument( __FUNCTION__, 'MU' );
919
+	}
920
+	// never used
893 921
 
894 922
 	return $wpdb->get_results( $wpdb->prepare("SELECT blog_id, domain, path FROM $wpdb->blogs WHERE site_id = %d AND public = '1' AND archived = '0' AND mature = '0' AND spam = '0' AND deleted = '0' AND last_updated != '0000-00-00 00:00:00' ORDER BY last_updated DESC limit %d, %d", $wpdb->siteid, $start, $quantity ) , ARRAY_A );
895 923
 }
Please login to merge, or discard this patch.
Spacing   +285 added lines, -285 removed lines patch added patch discarded remove patch
@@ -18,7 +18,7 @@  discard block
 block discarded – undo
18 18
 function wpmu_update_blogs_date() {
19 19
 	global $wpdb;
20 20
 
21
-	update_blog_details( $wpdb->blogid, array('last_updated' => current_time('mysql', true)) );
21
+	update_blog_details($wpdb->blogid, array('last_updated' => current_time('mysql', true)));
22 22
 	/**
23 23
 	 * Fires after the blog details are updated.
24 24
 	 *
@@ -26,7 +26,7 @@  discard block
 block discarded – undo
26 26
 	 *
27 27
 	 * @param int $blog_id Site ID.
28 28
 	 */
29
-	do_action( 'wpmu_blog_updated', $wpdb->blogid );
29
+	do_action('wpmu_blog_updated', $wpdb->blogid);
30 30
 }
31 31
 
32 32
 /**
@@ -37,17 +37,17 @@  discard block
 block discarded – undo
37 37
  * @param int $blog_id Blog ID
38 38
  * @return string Full URL of the blog if found. Empty string if not.
39 39
  */
40
-function get_blogaddress_by_id( $blog_id ) {
41
-	$bloginfo = get_blog_details( (int) $blog_id );
40
+function get_blogaddress_by_id($blog_id) {
41
+	$bloginfo = get_blog_details((int) $blog_id);
42 42
 
43
-	if ( empty( $bloginfo ) ) {
43
+	if (empty($bloginfo)) {
44 44
 		return '';
45 45
 	}
46 46
 
47
-	$scheme = parse_url( $bloginfo->home, PHP_URL_SCHEME );
48
-	$scheme = empty( $scheme ) ? 'http' : $scheme;
47
+	$scheme = parse_url($bloginfo->home, PHP_URL_SCHEME);
48
+	$scheme = empty($scheme) ? 'http' : $scheme;
49 49
 
50
-	return esc_url( $scheme . '://' . $bloginfo->domain . $bloginfo->path );
50
+	return esc_url($scheme.'://'.$bloginfo->domain.$bloginfo->path);
51 51
 }
52 52
 
53 53
 /**
@@ -58,17 +58,17 @@  discard block
 block discarded – undo
58 58
  * @param string $blogname The (subdomain or directory) name
59 59
  * @return string
60 60
  */
61
-function get_blogaddress_by_name( $blogname ) {
62
-	if ( is_subdomain_install() ) {
63
-		if ( $blogname == 'main' )
61
+function get_blogaddress_by_name($blogname) {
62
+	if (is_subdomain_install()) {
63
+		if ($blogname == 'main')
64 64
 			$blogname = 'www';
65
-		$url = rtrim( network_home_url(), '/' );
66
-		if ( !empty( $blogname ) )
67
-			$url = preg_replace( '|^([^\.]+://)|', "\${1}" . $blogname . '.', $url );
65
+		$url = rtrim(network_home_url(), '/');
66
+		if ( ! empty($blogname))
67
+			$url = preg_replace('|^([^\.]+://)|', "\${1}".$blogname.'.', $url);
68 68
 	} else {
69
-		$url = network_home_url( $blogname );
69
+		$url = network_home_url($blogname);
70 70
 	}
71
-	return esc_url( $url . '/' );
71
+	return esc_url($url.'/');
72 72
 }
73 73
 
74 74
 /**
@@ -81,26 +81,26 @@  discard block
 block discarded – undo
81 81
  * @param string $slug
82 82
  * @return int A blog id
83 83
  */
84
-function get_id_from_blogname( $slug ) {
84
+function get_id_from_blogname($slug) {
85 85
 	global $wpdb;
86 86
 
87 87
 	$current_site = get_current_site();
88
-	$slug = trim( $slug, '/' );
88
+	$slug = trim($slug, '/');
89 89
 
90
-	$blog_id = wp_cache_get( 'get_id_from_blogname_' . $slug, 'blog-details' );
91
-	if ( $blog_id )
90
+	$blog_id = wp_cache_get('get_id_from_blogname_'.$slug, 'blog-details');
91
+	if ($blog_id)
92 92
 		return $blog_id;
93 93
 
94
-	if ( is_subdomain_install() ) {
95
-		$domain = $slug . '.' . $current_site->domain;
94
+	if (is_subdomain_install()) {
95
+		$domain = $slug.'.'.$current_site->domain;
96 96
 		$path = $current_site->path;
97 97
 	} else {
98 98
 		$domain = $current_site->domain;
99
-		$path = $current_site->path . $slug . '/';
99
+		$path = $current_site->path.$slug.'/';
100 100
 	}
101 101
 
102
-	$blog_id = $wpdb->get_var( $wpdb->prepare("SELECT blog_id FROM {$wpdb->blogs} WHERE domain = %s AND path = %s", $domain, $path) );
103
-	wp_cache_set( 'get_id_from_blogname_' . $slug, $blog_id, 'blog-details' );
102
+	$blog_id = $wpdb->get_var($wpdb->prepare("SELECT blog_id FROM {$wpdb->blogs} WHERE domain = %s AND path = %s", $domain, $path));
103
+	wp_cache_set('get_id_from_blogname_'.$slug, $blog_id, 'blog-details');
104 104
 	return $blog_id;
105 105
 }
106 106
 
@@ -117,42 +117,42 @@  discard block
 block discarded – undo
117 117
  *                                  Default is true.
118 118
  * @return WP_Site|false Blog details on success. False on failure.
119 119
  */
120
-function get_blog_details( $fields = null, $get_all = true ) {
120
+function get_blog_details($fields = null, $get_all = true) {
121 121
 	global $wpdb;
122 122
 
123
-	if ( is_array($fields ) ) {
124
-		if ( isset($fields['blog_id']) ) {
123
+	if (is_array($fields)) {
124
+		if (isset($fields['blog_id'])) {
125 125
 			$blog_id = $fields['blog_id'];
126
-		} elseif ( isset($fields['domain']) && isset($fields['path']) ) {
127
-			$key = md5( $fields['domain'] . $fields['path'] );
126
+		} elseif (isset($fields['domain']) && isset($fields['path'])) {
127
+			$key = md5($fields['domain'].$fields['path']);
128 128
 			$blog = wp_cache_get($key, 'blog-lookup');
129
-			if ( false !== $blog )
129
+			if (false !== $blog)
130 130
 				return $blog;
131
-			if ( substr( $fields['domain'], 0, 4 ) == 'www.' ) {
132
-				$nowww = substr( $fields['domain'], 4 );
133
-				$blog = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM $wpdb->blogs WHERE domain IN (%s,%s) AND path = %s ORDER BY CHAR_LENGTH(domain) DESC", $nowww, $fields['domain'], $fields['path'] ) );
131
+			if (substr($fields['domain'], 0, 4) == 'www.') {
132
+				$nowww = substr($fields['domain'], 4);
133
+				$blog = $wpdb->get_row($wpdb->prepare("SELECT * FROM $wpdb->blogs WHERE domain IN (%s,%s) AND path = %s ORDER BY CHAR_LENGTH(domain) DESC", $nowww, $fields['domain'], $fields['path']));
134 134
 			} else {
135
-				$blog = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM $wpdb->blogs WHERE domain = %s AND path = %s", $fields['domain'], $fields['path'] ) );
135
+				$blog = $wpdb->get_row($wpdb->prepare("SELECT * FROM $wpdb->blogs WHERE domain = %s AND path = %s", $fields['domain'], $fields['path']));
136 136
 			}
137
-			if ( $blog ) {
138
-				wp_cache_set($blog->blog_id . 'short', $blog, 'blog-details');
137
+			if ($blog) {
138
+				wp_cache_set($blog->blog_id.'short', $blog, 'blog-details');
139 139
 				$blog_id = $blog->blog_id;
140 140
 			} else {
141 141
 				return false;
142 142
 			}
143
-		} elseif ( isset($fields['domain']) && is_subdomain_install() ) {
144
-			$key = md5( $fields['domain'] );
143
+		} elseif (isset($fields['domain']) && is_subdomain_install()) {
144
+			$key = md5($fields['domain']);
145 145
 			$blog = wp_cache_get($key, 'blog-lookup');
146
-			if ( false !== $blog )
146
+			if (false !== $blog)
147 147
 				return $blog;
148
-			if ( substr( $fields['domain'], 0, 4 ) == 'www.' ) {
149
-				$nowww = substr( $fields['domain'], 4 );
150
-				$blog = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM $wpdb->blogs WHERE domain IN (%s,%s) ORDER BY CHAR_LENGTH(domain) DESC", $nowww, $fields['domain'] ) );
148
+			if (substr($fields['domain'], 0, 4) == 'www.') {
149
+				$nowww = substr($fields['domain'], 4);
150
+				$blog = $wpdb->get_row($wpdb->prepare("SELECT * FROM $wpdb->blogs WHERE domain IN (%s,%s) ORDER BY CHAR_LENGTH(domain) DESC", $nowww, $fields['domain']));
151 151
 			} else {
152
-				$blog = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM $wpdb->blogs WHERE domain = %s", $fields['domain'] ) );
152
+				$blog = $wpdb->get_row($wpdb->prepare("SELECT * FROM $wpdb->blogs WHERE domain = %s", $fields['domain']));
153 153
 			}
154
-			if ( $blog ) {
155
-				wp_cache_set($blog->blog_id . 'short', $blog, 'blog-details');
154
+			if ($blog) {
155
+				wp_cache_set($blog->blog_id.'short', $blog, 'blog-details');
156 156
 				$blog_id = $blog->blog_id;
157 157
 			} else {
158 158
 				return false;
@@ -161,10 +161,10 @@  discard block
 block discarded – undo
161 161
 			return false;
162 162
 		}
163 163
 	} else {
164
-		if ( ! $fields )
164
+		if ( ! $fields)
165 165
 			$blog_id = get_current_blog_id();
166
-		elseif ( ! is_numeric( $fields ) )
167
-			$blog_id = get_id_from_blogname( $fields );
166
+		elseif ( ! is_numeric($fields))
167
+			$blog_id = get_id_from_blogname($fields);
168 168
 		else
169 169
 			$blog_id = $fields;
170 170
 	}
@@ -172,20 +172,20 @@  discard block
 block discarded – undo
172 172
 	$blog_id = (int) $blog_id;
173 173
 
174 174
 	$all = $get_all == true ? '' : 'short';
175
-	$details = wp_cache_get( $blog_id . $all, 'blog-details' );
175
+	$details = wp_cache_get($blog_id.$all, 'blog-details');
176 176
 
177
-	if ( $details ) {
178
-		if ( ! is_object( $details ) ) {
179
-			if ( $details == -1 ) {
177
+	if ($details) {
178
+		if ( ! is_object($details)) {
179
+			if ($details == -1) {
180 180
 				return false;
181 181
 			} else {
182 182
 				// Clear old pre-serialized objects. Cache clients do better with that.
183
-				wp_cache_delete( $blog_id . $all, 'blog-details' );
183
+				wp_cache_delete($blog_id.$all, 'blog-details');
184 184
 				unset($details);
185 185
 			}
186
-		} elseif ( ! $details->blog_id || ! $details->site_id ) {
186
+		} elseif ( ! $details->blog_id || ! $details->site_id) {
187 187
 			// Clear objects missing critical properties.
188
-			wp_cache_delete( $blog_id . $all, 'blog-details' );
188
+			wp_cache_delete($blog_id.$all, 'blog-details');
189 189
 			unset($details);
190 190
 		} else {
191 191
 			return $details;
@@ -193,23 +193,23 @@  discard block
 block discarded – undo
193 193
 	}
194 194
 
195 195
 	// Try the other cache.
196
-	if ( $get_all ) {
197
-		$details = wp_cache_get( $blog_id . 'short', 'blog-details' );
196
+	if ($get_all) {
197
+		$details = wp_cache_get($blog_id.'short', 'blog-details');
198 198
 	} else {
199
-		$details = wp_cache_get( $blog_id, 'blog-details' );
199
+		$details = wp_cache_get($blog_id, 'blog-details');
200 200
 		// If short was requested and full cache is set, we can return.
201
-		if ( $details ) {
202
-			if ( ! is_object( $details ) ) {
203
-				if ( $details == -1 ) {
201
+		if ($details) {
202
+			if ( ! is_object($details)) {
203
+				if ($details == -1) {
204 204
 					return false;
205 205
 				} else {
206 206
 					// Clear old pre-serialized objects. Cache clients do better with that.
207
-					wp_cache_delete( $blog_id, 'blog-details' );
207
+					wp_cache_delete($blog_id, 'blog-details');
208 208
 					unset($details);
209 209
 				}
210
-			} elseif ( ! $details->blog_id || ! $details->site_id ) {
210
+			} elseif ( ! $details->blog_id || ! $details->site_id) {
211 211
 				// Clear objects missing critical properties.
212
-				wp_cache_delete( $blog_id, 'blog-details' );
212
+				wp_cache_delete($blog_id, 'blog-details');
213 213
 				unset($details);
214 214
 			} else {
215 215
 				return $details;
@@ -217,29 +217,29 @@  discard block
 block discarded – undo
217 217
 		}
218 218
 	}
219 219
 
220
-	if ( empty( $details ) || ! $details->blog_id || ! $details->site_id ) {
221
-		$details = WP_Site::get_instance( $blog_id );
222
-		if ( ! $details ) {
220
+	if (empty($details) || ! $details->blog_id || ! $details->site_id) {
221
+		$details = WP_Site::get_instance($blog_id);
222
+		if ( ! $details) {
223 223
 			// Set the full cache.
224
-			wp_cache_set( $blog_id, -1, 'blog-details' );
224
+			wp_cache_set($blog_id, -1, 'blog-details');
225 225
 			return false;
226 226
 		}
227 227
 	}
228 228
 
229
-	if ( ! $details instanceof WP_Site ) {
230
-		$details = new WP_Site( $details );
229
+	if ( ! $details instanceof WP_Site) {
230
+		$details = new WP_Site($details);
231 231
 	}
232 232
 
233
-	if ( ! $get_all ) {
234
-		wp_cache_set( $blog_id . $all, $details, 'blog-details' );
233
+	if ( ! $get_all) {
234
+		wp_cache_set($blog_id.$all, $details, 'blog-details');
235 235
 		return $details;
236 236
 	}
237 237
 
238
-	switch_to_blog( $blog_id );
239
-	$details->blogname   = get_option( 'blogname' );
240
-	$details->siteurl    = get_option( 'siteurl' );
241
-	$details->post_count = get_option( 'post_count' );
242
-	$details->home       = get_option( 'home' );
238
+	switch_to_blog($blog_id);
239
+	$details->blogname   = get_option('blogname');
240
+	$details->siteurl    = get_option('siteurl');
241
+	$details->post_count = get_option('post_count');
242
+	$details->home       = get_option('home');
243 243
 	restore_current_blog();
244 244
 
245 245
 	/**
@@ -249,12 +249,12 @@  discard block
 block discarded – undo
249 249
 	 *
250 250
 	 * @param object $details The blog details.
251 251
 	 */
252
-	$details = apply_filters( 'blog_details', $details );
252
+	$details = apply_filters('blog_details', $details);
253 253
 
254
-	wp_cache_set( $blog_id . $all, $details, 'blog-details' );
254
+	wp_cache_set($blog_id.$all, $details, 'blog-details');
255 255
 
256
-	$key = md5( $details->domain . $details->path );
257
-	wp_cache_set( $key, $details, 'blog-lookup' );
256
+	$key = md5($details->domain.$details->path);
257
+	wp_cache_set($key, $details, 'blog-lookup');
258 258
 
259 259
 	return $details;
260 260
 }
@@ -266,14 +266,14 @@  discard block
 block discarded – undo
266 266
  *
267 267
  * @param int $blog_id Optional. Blog ID. Defaults to current blog.
268 268
  */
269
-function refresh_blog_details( $blog_id = 0 ) {
269
+function refresh_blog_details($blog_id = 0) {
270 270
 	$blog_id = (int) $blog_id;
271
-	if ( ! $blog_id ) {
271
+	if ( ! $blog_id) {
272 272
 		$blog_id = get_current_blog_id();
273 273
 	}
274 274
 
275
-	$details = get_blog_details( $blog_id, false );
276
-	if ( ! $details ) {
275
+	$details = get_blog_details($blog_id, false);
276
+	if ( ! $details) {
277 277
 		// Make sure clean_blog_cache() gets the blog ID
278 278
 		// when the blog has been previously cached as
279 279
 		// non-existent.
@@ -284,7 +284,7 @@  discard block
 block discarded – undo
284 284
 		);
285 285
 	}
286 286
 
287
-	clean_blog_cache( $details );
287
+	clean_blog_cache($details);
288 288
 
289 289
 	/**
290 290
 	 * Fires after the blog details cache is cleared.
@@ -293,7 +293,7 @@  discard block
 block discarded – undo
293 293
 	 *
294 294
 	 * @param int $blog_id Blog ID.
295 295
 	 */
296
-	do_action( 'refresh_blog_details', $blog_id );
296
+	do_action('refresh_blog_details', $blog_id);
297 297
 }
298 298
 
299 299
 /**
@@ -307,17 +307,17 @@  discard block
 block discarded – undo
307 307
  * @param array $details Array of details keyed by blogs table field names.
308 308
  * @return bool True if update succeeds, false otherwise.
309 309
  */
310
-function update_blog_details( $blog_id, $details = array() ) {
310
+function update_blog_details($blog_id, $details = array()) {
311 311
 	global $wpdb;
312 312
 
313
-	if ( empty($details) )
313
+	if (empty($details))
314 314
 		return false;
315 315
 
316
-	if ( is_object($details) )
316
+	if (is_object($details))
317 317
 		$details = get_object_vars($details);
318 318
 
319 319
 	$current_details = get_blog_details($blog_id, false);
320
-	if ( empty($current_details) )
320
+	if (empty($current_details))
321 321
 		return false;
322 322
 
323 323
 	$current_details = get_object_vars($current_details);
@@ -326,23 +326,23 @@  discard block
 block discarded – undo
326 326
 	$details['last_updated'] = current_time('mysql', true);
327 327
 
328 328
 	$update_details = array();
329
-	$fields = array( 'site_id', 'domain', 'path', 'registered', 'last_updated', 'public', 'archived', 'mature', 'spam', 'deleted', 'lang_id');
330
-	foreach ( array_intersect( array_keys( $details ), $fields ) as $field ) {
331
-		if ( 'path' === $field ) {
332
-			$details[ $field ] = trailingslashit( '/' . trim( $details[ $field ], '/' ) );
329
+	$fields = array('site_id', 'domain', 'path', 'registered', 'last_updated', 'public', 'archived', 'mature', 'spam', 'deleted', 'lang_id');
330
+	foreach (array_intersect(array_keys($details), $fields) as $field) {
331
+		if ('path' === $field) {
332
+			$details[$field] = trailingslashit('/'.trim($details[$field], '/'));
333 333
 		}
334 334
 
335
-		$update_details[ $field ] = $details[ $field ];
335
+		$update_details[$field] = $details[$field];
336 336
 	}
337 337
 
338
-	$result = $wpdb->update( $wpdb->blogs, $update_details, array('blog_id' => $blog_id) );
338
+	$result = $wpdb->update($wpdb->blogs, $update_details, array('blog_id' => $blog_id));
339 339
 
340
-	if ( false === $result )
340
+	if (false === $result)
341 341
 		return false;
342 342
 
343 343
 	// If spam status changed, issue actions.
344
-	if ( $details['spam'] != $current_details['spam'] ) {
345
-		if ( $details['spam'] == 1 ) {
344
+	if ($details['spam'] != $current_details['spam']) {
345
+		if ($details['spam'] == 1) {
346 346
 			/**
347 347
 			 * Fires when the blog status is changed to 'spam'.
348 348
 			 *
@@ -350,7 +350,7 @@  discard block
 block discarded – undo
350 350
 			 *
351 351
 			 * @param int $blog_id Blog ID.
352 352
 			 */
353
-			do_action( 'make_spam_blog', $blog_id );
353
+			do_action('make_spam_blog', $blog_id);
354 354
 		} else {
355 355
 			/**
356 356
 			 * Fires when the blog status is changed to 'ham'.
@@ -359,13 +359,13 @@  discard block
 block discarded – undo
359 359
 			 *
360 360
 			 * @param int $blog_id Blog ID.
361 361
 			 */
362
-			do_action( 'make_ham_blog', $blog_id );
362
+			do_action('make_ham_blog', $blog_id);
363 363
 		}
364 364
 	}
365 365
 
366 366
 	// If mature status changed, issue actions.
367
-	if ( $details['mature'] != $current_details['mature'] ) {
368
-		if ( $details['mature'] == 1 ) {
367
+	if ($details['mature'] != $current_details['mature']) {
368
+		if ($details['mature'] == 1) {
369 369
 			/**
370 370
 			 * Fires when the blog status is changed to 'mature'.
371 371
 			 *
@@ -373,7 +373,7 @@  discard block
 block discarded – undo
373 373
 			 *
374 374
 			 * @param int $blog_id Blog ID.
375 375
 			 */
376
-			do_action( 'mature_blog', $blog_id );
376
+			do_action('mature_blog', $blog_id);
377 377
 		} else {
378 378
 			/**
379 379
 			 * Fires when the blog status is changed to 'unmature'.
@@ -382,13 +382,13 @@  discard block
 block discarded – undo
382 382
 			 *
383 383
 			 * @param int $blog_id Blog ID.
384 384
 			 */
385
-			do_action( 'unmature_blog', $blog_id );
385
+			do_action('unmature_blog', $blog_id);
386 386
 		}
387 387
 	}
388 388
 
389 389
 	// If archived status changed, issue actions.
390
-	if ( $details['archived'] != $current_details['archived'] ) {
391
-		if ( $details['archived'] == 1 ) {
390
+	if ($details['archived'] != $current_details['archived']) {
391
+		if ($details['archived'] == 1) {
392 392
 			/**
393 393
 			 * Fires when the blog status is changed to 'archived'.
394 394
 			 *
@@ -396,7 +396,7 @@  discard block
 block discarded – undo
396 396
 			 *
397 397
 			 * @param int $blog_id Blog ID.
398 398
 			 */
399
-			do_action( 'archive_blog', $blog_id );
399
+			do_action('archive_blog', $blog_id);
400 400
 		} else {
401 401
 			/**
402 402
 			 * Fires when the blog status is changed to 'unarchived'.
@@ -405,13 +405,13 @@  discard block
 block discarded – undo
405 405
 			 *
406 406
 			 * @param int $blog_id Blog ID.
407 407
 			 */
408
-			do_action( 'unarchive_blog', $blog_id );
408
+			do_action('unarchive_blog', $blog_id);
409 409
 		}
410 410
 	}
411 411
 
412 412
 	// If deleted status changed, issue actions.
413
-	if ( $details['deleted'] != $current_details['deleted'] ) {
414
-		if ( $details['deleted'] == 1 ) {
413
+	if ($details['deleted'] != $current_details['deleted']) {
414
+		if ($details['deleted'] == 1) {
415 415
 			/**
416 416
 			 * Fires when the blog status is changed to 'deleted'.
417 417
 			 *
@@ -419,7 +419,7 @@  discard block
 block discarded – undo
419 419
 			 *
420 420
 			 * @param int $blog_id Blog ID.
421 421
 			 */
422
-			do_action( 'make_delete_blog', $blog_id );
422
+			do_action('make_delete_blog', $blog_id);
423 423
 		} else {
424 424
 			/**
425 425
 			 * Fires when the blog status is changed to 'undeleted'.
@@ -428,13 +428,13 @@  discard block
 block discarded – undo
428 428
 			 *
429 429
 			 * @param int $blog_id Blog ID.
430 430
 			 */
431
-			do_action( 'make_undelete_blog', $blog_id );
431
+			do_action('make_undelete_blog', $blog_id);
432 432
 		}
433 433
 	}
434 434
 
435
-	if ( isset( $details['public'] ) ) {
436
-		switch_to_blog( $blog_id );
437
-		update_option( 'blog_public', $details['public'] );
435
+	if (isset($details['public'])) {
436
+		switch_to_blog($blog_id);
437
+		update_option('blog_public', $details['public']);
438 438
 		restore_current_blog();
439 439
 	}
440 440
 
@@ -450,18 +450,18 @@  discard block
 block discarded – undo
450 450
  *
451 451
  * @param WP_Site $blog The blog details as returned from get_blog_details()
452 452
  */
453
-function clean_blog_cache( $blog ) {
453
+function clean_blog_cache($blog) {
454 454
 	$blog_id = $blog->blog_id;
455
-	$domain_path_key = md5( $blog->domain . $blog->path );
455
+	$domain_path_key = md5($blog->domain.$blog->path);
456 456
 
457
-	wp_cache_delete( $blog_id, 'sites' );
458
-	wp_cache_delete( $blog_id , 'blog-details' );
459
-	wp_cache_delete( $blog_id . 'short' , 'blog-details' );
460
-	wp_cache_delete(  $domain_path_key, 'blog-lookup' );
461
-	wp_cache_delete( 'current_blog_' . $blog->domain, 'site-options' );
462
-	wp_cache_delete( 'current_blog_' . $blog->domain . $blog->path, 'site-options' );
463
-	wp_cache_delete( 'get_id_from_blogname_' . trim( $blog->path, '/' ), 'blog-details' );
464
-	wp_cache_delete( $domain_path_key, 'blog-id-cache' );
457
+	wp_cache_delete($blog_id, 'sites');
458
+	wp_cache_delete($blog_id, 'blog-details');
459
+	wp_cache_delete($blog_id.'short', 'blog-details');
460
+	wp_cache_delete($domain_path_key, 'blog-lookup');
461
+	wp_cache_delete('current_blog_'.$blog->domain, 'site-options');
462
+	wp_cache_delete('current_blog_'.$blog->domain.$blog->path, 'site-options');
463
+	wp_cache_delete('get_id_from_blogname_'.trim($blog->path, '/'), 'blog-details');
464
+	wp_cache_delete($domain_path_key, 'blog-id-cache');
465 465
 
466 466
 	/**
467 467
 	 * Fires immediately after a site has been removed from the object cache.
@@ -472,9 +472,9 @@  discard block
 block discarded – undo
472 472
 	 * @param WP_Site $blog
473 473
 	 * @param string  $domain_path_key md5 hash of domain and path.
474 474
 	 */
475
-	do_action( 'clean_site_cache', $blog_id, $blog, $domain_path_key );
475
+	do_action('clean_site_cache', $blog_id, $blog, $domain_path_key);
476 476
 
477
-	wp_cache_set( 'last_changed', microtime(), 'sites' );
477
+	wp_cache_set('last_changed', microtime(), 'sites');
478 478
 }
479 479
 
480 480
 /**
@@ -490,21 +490,21 @@  discard block
 block discarded – undo
490 490
  * @param WP_Site|int|null $site Optional. Site to retrieve. Default is the current site.
491 491
  * @return WP_Site|null The site object or null if not found.
492 492
  */
493
-function get_site( &$site = null ) {
493
+function get_site(&$site = null) {
494 494
 	global $current_blog;
495
-	if ( empty( $site ) && isset( $current_blog ) ) {
495
+	if (empty($site) && isset($current_blog)) {
496 496
 		$site = $current_blog;
497 497
 	}
498 498
 
499
-	if ( $site instanceof WP_Site ) {
499
+	if ($site instanceof WP_Site) {
500 500
 		$_site = $site;
501
-	} elseif ( is_object( $site ) ) {
502
-		$_site = new WP_Site( $site );
501
+	} elseif (is_object($site)) {
502
+		$_site = new WP_Site($site);
503 503
 	} else {
504
-		$_site = WP_Site::get_instance( $site );
504
+		$_site = WP_Site::get_instance($site);
505 505
 	}
506 506
 
507
-	if ( ! $_site ) {
507
+	if ( ! $_site) {
508 508
 		return null;
509 509
 	}
510 510
 
@@ -515,7 +515,7 @@  discard block
 block discarded – undo
515 515
 	 *
516 516
 	 * @param WP_Site $_site Site data.
517 517
 	 */
518
-	$_site = apply_filters( 'get_site', $_site );
518
+	$_site = apply_filters('get_site', $_site);
519 519
 
520 520
 	return $_site;
521 521
 }
@@ -532,14 +532,14 @@  discard block
 block discarded – undo
532 532
  *
533 533
  * @param array $ids ID list.
534 534
  */
535
-function _prime_site_caches( $ids ) {
535
+function _prime_site_caches($ids) {
536 536
 	global $wpdb;
537 537
 
538
-	$non_cached_ids = _get_non_cached_ids( $ids, 'sites' );
539
-	if ( ! empty( $non_cached_ids ) ) {
540
-		$fresh_sites = $wpdb->get_results( sprintf( "SELECT * FROM $wpdb->blogs WHERE blog_id IN (%s)", join( ",", array_map( 'intval', $non_cached_ids ) ) ) );
538
+	$non_cached_ids = _get_non_cached_ids($ids, 'sites');
539
+	if ( ! empty($non_cached_ids)) {
540
+		$fresh_sites = $wpdb->get_results(sprintf("SELECT * FROM $wpdb->blogs WHERE blog_id IN (%s)", join(",", array_map('intval', $non_cached_ids))));
541 541
 
542
-		update_site_cache( $fresh_sites );
542
+		update_site_cache($fresh_sites);
543 543
 	}
544 544
 }
545 545
 
@@ -550,14 +550,14 @@  discard block
 block discarded – undo
550 550
  *
551 551
  * @param array $sites Array of site objects, passed by reference.
552 552
  */
553
-function update_site_cache( &$sites ) {
554
-	if ( ! $sites ) {
553
+function update_site_cache(&$sites) {
554
+	if ( ! $sites) {
555 555
 		return;
556 556
 	}
557 557
 
558
-	foreach ( $sites as $site ) {
559
-		wp_cache_add( $site->blog_id, $site, 'sites' );
560
-		wp_cache_add( $site->blog_id . 'short', $site, 'blog-details' );
558
+	foreach ($sites as $site) {
559
+		wp_cache_add($site->blog_id, $site, 'sites');
560
+		wp_cache_add($site->blog_id.'short', $site, 'blog-details');
561 561
 	}
562 562
 }
563 563
 
@@ -612,10 +612,10 @@  discard block
 block discarded – undo
612 612
  * }
613 613
  * @return array List of sites.
614 614
  */
615
-function get_sites( $args = array() ) {
615
+function get_sites($args = array()) {
616 616
 	$query = new WP_Site_Query();
617 617
 
618
-	return $query->query( $args );
618
+	return $query->query($args);
619 619
 }
620 620
 
621 621
 /**
@@ -635,17 +635,17 @@  discard block
 block discarded – undo
635 635
  * @param mixed  $default Optional. Default value to return if the option does not exist.
636 636
  * @return mixed Value set for the option.
637 637
  */
638
-function get_blog_option( $id, $option, $default = false ) {
638
+function get_blog_option($id, $option, $default = false) {
639 639
 	$id = (int) $id;
640 640
 
641
-	if ( empty( $id ) )
641
+	if (empty($id))
642 642
 		$id = get_current_blog_id();
643 643
 
644
-	if ( get_current_blog_id() == $id )
645
-		return get_option( $option, $default );
644
+	if (get_current_blog_id() == $id)
645
+		return get_option($option, $default);
646 646
 
647
-	switch_to_blog( $id );
648
-	$value = get_option( $option, $default );
647
+	switch_to_blog($id);
648
+	$value = get_option($option, $default);
649 649
 	restore_current_blog();
650 650
 
651 651
 	/**
@@ -658,7 +658,7 @@  discard block
 block discarded – undo
658 658
 	 * @param string  $value The option value.
659 659
 	 * @param int     $id    Blog ID.
660 660
 	 */
661
-	return apply_filters( "blog_option_{$option}", $value, $id );
661
+	return apply_filters("blog_option_{$option}", $value, $id);
662 662
 }
663 663
 
664 664
 /**
@@ -680,17 +680,17 @@  discard block
 block discarded – undo
680 680
  * @param mixed  $value  Optional. Option value, can be anything. Expected to not be SQL-escaped.
681 681
  * @return bool False if option was not added and true if option was added.
682 682
  */
683
-function add_blog_option( $id, $option, $value ) {
683
+function add_blog_option($id, $option, $value) {
684 684
 	$id = (int) $id;
685 685
 
686
-	if ( empty( $id ) )
686
+	if (empty($id))
687 687
 		$id = get_current_blog_id();
688 688
 
689
-	if ( get_current_blog_id() == $id )
690
-		return add_option( $option, $value );
689
+	if (get_current_blog_id() == $id)
690
+		return add_option($option, $value);
691 691
 
692
-	switch_to_blog( $id );
693
-	$return = add_option( $option, $value );
692
+	switch_to_blog($id);
693
+	$return = add_option($option, $value);
694 694
 	restore_current_blog();
695 695
 
696 696
 	return $return;
@@ -705,17 +705,17 @@  discard block
 block discarded – undo
705 705
  * @param string $option Name of option to remove. Expected to not be SQL-escaped.
706 706
  * @return bool True, if option is successfully deleted. False on failure.
707 707
  */
708
-function delete_blog_option( $id, $option ) {
708
+function delete_blog_option($id, $option) {
709 709
 	$id = (int) $id;
710 710
 
711
-	if ( empty( $id ) )
711
+	if (empty($id))
712 712
 		$id = get_current_blog_id();
713 713
 
714
-	if ( get_current_blog_id() == $id )
715
-		return delete_option( $option );
714
+	if (get_current_blog_id() == $id)
715
+		return delete_option($option);
716 716
 
717
-	switch_to_blog( $id );
718
-	$return = delete_option( $option );
717
+	switch_to_blog($id);
718
+	$return = delete_option($option);
719 719
 	restore_current_blog();
720 720
 
721 721
 	return $return;
@@ -732,20 +732,20 @@  discard block
 block discarded – undo
732 732
  * @param mixed  $deprecated Not used.
733 733
  * @return bool True on success, false on failure.
734 734
  */
735
-function update_blog_option( $id, $option, $value, $deprecated = null ) {
735
+function update_blog_option($id, $option, $value, $deprecated = null) {
736 736
 	$id = (int) $id;
737 737
 
738
-	if ( null !== $deprecated  )
739
-		_deprecated_argument( __FUNCTION__, '3.1' );
738
+	if (null !== $deprecated)
739
+		_deprecated_argument(__FUNCTION__, '3.1');
740 740
 
741
-	if ( get_current_blog_id() == $id )
742
-		return update_option( $option, $value );
741
+	if (get_current_blog_id() == $id)
742
+		return update_option($option, $value);
743 743
 
744
-	switch_to_blog( $id );
745
-	$return = update_option( $option, $value );
744
+	switch_to_blog($id);
745
+	$return = update_option($option, $value);
746 746
 	restore_current_blog();
747 747
 
748
-	refresh_blog_details( $id );
748
+	refresh_blog_details($id);
749 749
 
750 750
 	return $return;
751 751
 }
@@ -774,10 +774,10 @@  discard block
 block discarded – undo
774 774
  * @param bool $deprecated Deprecated argument
775 775
  * @return true Always returns True.
776 776
  */
777
-function switch_to_blog( $new_blog, $deprecated = null ) {
777
+function switch_to_blog($new_blog, $deprecated = null) {
778 778
 	global $wpdb;
779 779
 
780
-	if ( empty( $new_blog ) )
780
+	if (empty($new_blog))
781 781
 		$new_blog = $GLOBALS['blog_id'];
782 782
 
783 783
 	$GLOBALS['_wp_switched_stack'][] = $GLOBALS['blog_id'];
@@ -787,7 +787,7 @@  discard block
 block discarded – undo
787 787
 	 * set the right vars, do the associated actions, but skip
788 788
 	 * the extra unnecessary work
789 789
 	 */
790
-	if ( $new_blog == $GLOBALS['blog_id'] ) {
790
+	if ($new_blog == $GLOBALS['blog_id']) {
791 791
 		/**
792 792
 		 * Fires when the blog is switched.
793 793
 		 *
@@ -796,46 +796,46 @@  discard block
 block discarded – undo
796 796
 		 * @param int $new_blog New blog ID.
797 797
 		 * @param int $new_blog Blog ID.
798 798
 		 */
799
-		do_action( 'switch_blog', $new_blog, $new_blog );
799
+		do_action('switch_blog', $new_blog, $new_blog);
800 800
 		$GLOBALS['switched'] = true;
801 801
 		return true;
802 802
 	}
803 803
 
804
-	$wpdb->set_blog_id( $new_blog );
804
+	$wpdb->set_blog_id($new_blog);
805 805
 	$GLOBALS['table_prefix'] = $wpdb->get_blog_prefix();
806 806
 	$prev_blog_id = $GLOBALS['blog_id'];
807 807
 	$GLOBALS['blog_id'] = $new_blog;
808 808
 
809
-	if ( function_exists( 'wp_cache_switch_to_blog' ) ) {
810
-		wp_cache_switch_to_blog( $new_blog );
809
+	if (function_exists('wp_cache_switch_to_blog')) {
810
+		wp_cache_switch_to_blog($new_blog);
811 811
 	} else {
812 812
 		global $wp_object_cache;
813 813
 
814
-		if ( is_object( $wp_object_cache ) && isset( $wp_object_cache->global_groups ) )
814
+		if (is_object($wp_object_cache) && isset($wp_object_cache->global_groups))
815 815
 			$global_groups = $wp_object_cache->global_groups;
816 816
 		else
817 817
 			$global_groups = false;
818 818
 
819 819
 		wp_cache_init();
820 820
 
821
-		if ( function_exists( 'wp_cache_add_global_groups' ) ) {
822
-			if ( is_array( $global_groups ) ) {
823
-				wp_cache_add_global_groups( $global_groups );
821
+		if (function_exists('wp_cache_add_global_groups')) {
822
+			if (is_array($global_groups)) {
823
+				wp_cache_add_global_groups($global_groups);
824 824
 			} else {
825
-				wp_cache_add_global_groups( array( 'users', 'userlogins', 'usermeta', 'user_meta', 'useremail', 'userslugs', 'site-transient', 'site-options', 'site-lookup', 'blog-lookup', 'blog-details', 'rss', 'global-posts', 'blog-id-cache', 'networks', 'sites' ) );
825
+				wp_cache_add_global_groups(array('users', 'userlogins', 'usermeta', 'user_meta', 'useremail', 'userslugs', 'site-transient', 'site-options', 'site-lookup', 'blog-lookup', 'blog-details', 'rss', 'global-posts', 'blog-id-cache', 'networks', 'sites'));
826 826
 			}
827
-			wp_cache_add_non_persistent_groups( array( 'counts', 'plugins' ) );
827
+			wp_cache_add_non_persistent_groups(array('counts', 'plugins'));
828 828
 		}
829 829
 	}
830 830
 
831
-	if ( did_action( 'init' ) ) {
831
+	if (did_action('init')) {
832 832
 		wp_roles()->reinit();
833 833
 		$current_user = wp_get_current_user();
834
-		$current_user->for_blog( $new_blog );
834
+		$current_user->for_blog($new_blog);
835 835
 	}
836 836
 
837 837
 	/** This filter is documented in wp-includes/ms-blogs.php */
838
-	do_action( 'switch_blog', $new_blog, $prev_blog_id );
838
+	do_action('switch_blog', $new_blog, $prev_blog_id);
839 839
 	$GLOBALS['switched'] = true;
840 840
 
841 841
 	return true;
@@ -859,57 +859,57 @@  discard block
 block discarded – undo
859 859
 function restore_current_blog() {
860 860
 	global $wpdb;
861 861
 
862
-	if ( empty( $GLOBALS['_wp_switched_stack'] ) )
862
+	if (empty($GLOBALS['_wp_switched_stack']))
863 863
 		return false;
864 864
 
865
-	$blog = array_pop( $GLOBALS['_wp_switched_stack'] );
865
+	$blog = array_pop($GLOBALS['_wp_switched_stack']);
866 866
 
867
-	if ( $GLOBALS['blog_id'] == $blog ) {
867
+	if ($GLOBALS['blog_id'] == $blog) {
868 868
 		/** This filter is documented in wp-includes/ms-blogs.php */
869
-		do_action( 'switch_blog', $blog, $blog );
869
+		do_action('switch_blog', $blog, $blog);
870 870
 		// If we still have items in the switched stack, consider ourselves still 'switched'
871
-		$GLOBALS['switched'] = ! empty( $GLOBALS['_wp_switched_stack'] );
871
+		$GLOBALS['switched'] = ! empty($GLOBALS['_wp_switched_stack']);
872 872
 		return true;
873 873
 	}
874 874
 
875
-	$wpdb->set_blog_id( $blog );
875
+	$wpdb->set_blog_id($blog);
876 876
 	$prev_blog_id = $GLOBALS['blog_id'];
877 877
 	$GLOBALS['blog_id'] = $blog;
878 878
 	$GLOBALS['table_prefix'] = $wpdb->get_blog_prefix();
879 879
 
880
-	if ( function_exists( 'wp_cache_switch_to_blog' ) ) {
881
-		wp_cache_switch_to_blog( $blog );
880
+	if (function_exists('wp_cache_switch_to_blog')) {
881
+		wp_cache_switch_to_blog($blog);
882 882
 	} else {
883 883
 		global $wp_object_cache;
884 884
 
885
-		if ( is_object( $wp_object_cache ) && isset( $wp_object_cache->global_groups ) )
885
+		if (is_object($wp_object_cache) && isset($wp_object_cache->global_groups))
886 886
 			$global_groups = $wp_object_cache->global_groups;
887 887
 		else
888 888
 			$global_groups = false;
889 889
 
890 890
 		wp_cache_init();
891 891
 
892
-		if ( function_exists( 'wp_cache_add_global_groups' ) ) {
893
-			if ( is_array( $global_groups ) ) {
894
-				wp_cache_add_global_groups( $global_groups );
892
+		if (function_exists('wp_cache_add_global_groups')) {
893
+			if (is_array($global_groups)) {
894
+				wp_cache_add_global_groups($global_groups);
895 895
 			} else {
896
-				wp_cache_add_global_groups( array( 'users', 'userlogins', 'usermeta', 'user_meta', 'useremail', 'userslugs', 'site-transient', 'site-options', 'site-lookup', 'blog-lookup', 'blog-details', 'rss', 'global-posts', 'blog-id-cache', 'networks', 'sites' ) );
896
+				wp_cache_add_global_groups(array('users', 'userlogins', 'usermeta', 'user_meta', 'useremail', 'userslugs', 'site-transient', 'site-options', 'site-lookup', 'blog-lookup', 'blog-details', 'rss', 'global-posts', 'blog-id-cache', 'networks', 'sites'));
897 897
 			}
898
-			wp_cache_add_non_persistent_groups( array( 'counts', 'plugins' ) );
898
+			wp_cache_add_non_persistent_groups(array('counts', 'plugins'));
899 899
 		}
900 900
 	}
901 901
 
902
-	if ( did_action( 'init' ) ) {
902
+	if (did_action('init')) {
903 903
 		wp_roles()->reinit();
904 904
 		$current_user = wp_get_current_user();
905
-		$current_user->for_blog( $blog );
905
+		$current_user->for_blog($blog);
906 906
 	}
907 907
 
908 908
 	/** This filter is documented in wp-includes/ms-blogs.php */
909
-	do_action( 'switch_blog', $blog, $prev_blog_id );
909
+	do_action('switch_blog', $blog, $prev_blog_id);
910 910
 
911 911
 	// If we still have items in the switched stack, consider ourselves still 'switched'
912
-	$GLOBALS['switched'] = ! empty( $GLOBALS['_wp_switched_stack'] );
912
+	$GLOBALS['switched'] = ! empty($GLOBALS['_wp_switched_stack']);
913 913
 
914 914
 	return true;
915 915
 }
@@ -924,7 +924,7 @@  discard block
 block discarded – undo
924 924
  * @return bool True if switched, false otherwise.
925 925
  */
926 926
 function ms_is_switched() {
927
-	return ! empty( $GLOBALS['_wp_switched_stack'] );
927
+	return ! empty($GLOBALS['_wp_switched_stack']);
928 928
 }
929 929
 
930 930
 /**
@@ -935,7 +935,7 @@  discard block
 block discarded – undo
935 935
  * @param int $id The blog id
936 936
  * @return string Whether the blog is archived or not
937 937
  */
938
-function is_archived( $id ) {
938
+function is_archived($id) {
939 939
 	return get_blog_status($id, 'archived');
940 940
 }
941 941
 
@@ -948,7 +948,7 @@  discard block
 block discarded – undo
948 948
  * @param string $archived The new status
949 949
  * @return string $archived
950 950
  */
951
-function update_archived( $id, $archived ) {
951
+function update_archived($id, $archived) {
952 952
 	update_blog_status($id, 'archived', $archived);
953 953
 	return $archived;
954 954
 }
@@ -966,55 +966,55 @@  discard block
 block discarded – undo
966 966
  * @param null   $deprecated
967 967
  * @return string|false $value
968 968
  */
969
-function update_blog_status( $blog_id, $pref, $value, $deprecated = null ) {
969
+function update_blog_status($blog_id, $pref, $value, $deprecated = null) {
970 970
 	global $wpdb;
971 971
 
972
-	if ( null !== $deprecated  )
973
-		_deprecated_argument( __FUNCTION__, '3.1' );
972
+	if (null !== $deprecated)
973
+		_deprecated_argument(__FUNCTION__, '3.1');
974 974
 
975
-	if ( ! in_array( $pref, array( 'site_id', 'domain', 'path', 'registered', 'last_updated', 'public', 'archived', 'mature', 'spam', 'deleted', 'lang_id') ) )
975
+	if ( ! in_array($pref, array('site_id', 'domain', 'path', 'registered', 'last_updated', 'public', 'archived', 'mature', 'spam', 'deleted', 'lang_id')))
976 976
 		return $value;
977 977
 
978
-	$result = $wpdb->update( $wpdb->blogs, array($pref => $value, 'last_updated' => current_time('mysql', true)), array('blog_id' => $blog_id) );
978
+	$result = $wpdb->update($wpdb->blogs, array($pref => $value, 'last_updated' => current_time('mysql', true)), array('blog_id' => $blog_id));
979 979
 
980
-	if ( false === $result )
980
+	if (false === $result)
981 981
 		return false;
982 982
 
983
-	refresh_blog_details( $blog_id );
983
+	refresh_blog_details($blog_id);
984 984
 
985
-	if ( 'spam' == $pref ) {
986
-		if ( $value == 1 ) {
985
+	if ('spam' == $pref) {
986
+		if ($value == 1) {
987 987
 			/** This filter is documented in wp-includes/ms-blogs.php */
988
-			do_action( 'make_spam_blog', $blog_id );
988
+			do_action('make_spam_blog', $blog_id);
989 989
 		} else {
990 990
 			/** This filter is documented in wp-includes/ms-blogs.php */
991
-			do_action( 'make_ham_blog', $blog_id );
991
+			do_action('make_ham_blog', $blog_id);
992 992
 		}
993
-	} elseif ( 'mature' == $pref ) {
994
-		if ( $value == 1 ) {
993
+	} elseif ('mature' == $pref) {
994
+		if ($value == 1) {
995 995
 			/** This filter is documented in wp-includes/ms-blogs.php */
996
-			do_action( 'mature_blog', $blog_id );
996
+			do_action('mature_blog', $blog_id);
997 997
 		} else {
998 998
 			/** This filter is documented in wp-includes/ms-blogs.php */
999
-			do_action( 'unmature_blog', $blog_id );
999
+			do_action('unmature_blog', $blog_id);
1000 1000
 		}
1001
-	} elseif ( 'archived' == $pref ) {
1002
-		if ( $value == 1 ) {
1001
+	} elseif ('archived' == $pref) {
1002
+		if ($value == 1) {
1003 1003
 			/** This filter is documented in wp-includes/ms-blogs.php */
1004
-			do_action( 'archive_blog', $blog_id );
1004
+			do_action('archive_blog', $blog_id);
1005 1005
 		} else {
1006 1006
 			/** This filter is documented in wp-includes/ms-blogs.php */
1007
-			do_action( 'unarchive_blog', $blog_id );
1007
+			do_action('unarchive_blog', $blog_id);
1008 1008
 		}
1009
-	} elseif ( 'deleted' == $pref ) {
1010
-		if ( $value == 1 ) {
1009
+	} elseif ('deleted' == $pref) {
1010
+		if ($value == 1) {
1011 1011
 			/** This filter is documented in wp-includes/ms-blogs.php */
1012
-			do_action( 'make_delete_blog', $blog_id );
1012
+			do_action('make_delete_blog', $blog_id);
1013 1013
 		} else {
1014 1014
 			/** This filter is documented in wp-includes/ms-blogs.php */
1015
-			do_action( 'make_undelete_blog', $blog_id );
1015
+			do_action('make_undelete_blog', $blog_id);
1016 1016
 		}
1017
-	} elseif ( 'public' == $pref ) {
1017
+	} elseif ('public' == $pref) {
1018 1018
 		/**
1019 1019
 		 * Fires after the current blog's 'public' setting is updated.
1020 1020
 		 *
@@ -1023,7 +1023,7 @@  discard block
 block discarded – undo
1023 1023
 		 * @param int    $blog_id Blog ID.
1024 1024
 		 * @param string $value   The value of blog status.
1025 1025
  		 */
1026
-		do_action( 'update_blog_public', $blog_id, $value ); // Moved here from update_blog_public().
1026
+		do_action('update_blog_public', $blog_id, $value); // Moved here from update_blog_public().
1027 1027
 	}
1028 1028
 
1029 1029
 	return $value;
@@ -1040,14 +1040,14 @@  discard block
 block discarded – undo
1040 1040
  * @param string $pref A field name
1041 1041
  * @return bool|string|null $value
1042 1042
  */
1043
-function get_blog_status( $id, $pref ) {
1043
+function get_blog_status($id, $pref) {
1044 1044
 	global $wpdb;
1045 1045
 
1046
-	$details = get_blog_details( $id, false );
1047
-	if ( $details )
1046
+	$details = get_blog_details($id, false);
1047
+	if ($details)
1048 1048
 		return $details->$pref;
1049 1049
 
1050
-	return $wpdb->get_var( $wpdb->prepare("SELECT %s FROM {$wpdb->blogs} WHERE blog_id = %d", $pref, $id) );
1050
+	return $wpdb->get_var($wpdb->prepare("SELECT %s FROM {$wpdb->blogs} WHERE blog_id = %d", $pref, $id));
1051 1051
 }
1052 1052
 
1053 1053
 /**
@@ -1062,13 +1062,13 @@  discard block
 block discarded – undo
1062 1062
  * @param int   $quantity   The maximum number of blogs to retrieve. Default is 40.
1063 1063
  * @return array The list of blogs
1064 1064
  */
1065
-function get_last_updated( $deprecated = '', $start = 0, $quantity = 40 ) {
1065
+function get_last_updated($deprecated = '', $start = 0, $quantity = 40) {
1066 1066
 	global $wpdb;
1067 1067
 
1068
-	if ( ! empty( $deprecated ) )
1069
-		_deprecated_argument( __FUNCTION__, 'MU' ); // never used
1068
+	if ( ! empty($deprecated))
1069
+		_deprecated_argument(__FUNCTION__, 'MU'); // never used
1070 1070
 
1071
-	return $wpdb->get_results( $wpdb->prepare("SELECT blog_id, domain, path FROM $wpdb->blogs WHERE site_id = %d AND public = '1' AND archived = '0' AND mature = '0' AND spam = '0' AND deleted = '0' AND last_updated != '0000-00-00 00:00:00' ORDER BY last_updated DESC limit %d, %d", $wpdb->siteid, $start, $quantity ) , ARRAY_A );
1071
+	return $wpdb->get_results($wpdb->prepare("SELECT blog_id, domain, path FROM $wpdb->blogs WHERE site_id = %d AND public = '1' AND archived = '0' AND mature = '0' AND spam = '0' AND deleted = '0' AND last_updated != '0000-00-00 00:00:00' ORDER BY last_updated DESC limit %d, %d", $wpdb->siteid, $start, $quantity), ARRAY_A);
1072 1072
 }
1073 1073
 
1074 1074
 /**
@@ -1080,10 +1080,10 @@  discard block
 block discarded – undo
1080 1080
  *                           for information on accepted arguments. Default empty.
1081 1081
  * @return int|array List of networks or number of found networks if `$count` argument is true.
1082 1082
  */
1083
-function get_networks( $args = '' ) {
1083
+function get_networks($args = '') {
1084 1084
 	$query = new WP_Network_Query();
1085 1085
 
1086
-	return $query->query( $args );
1086
+	return $query->query($args);
1087 1087
 }
1088 1088
 
1089 1089
 /**
@@ -1099,21 +1099,21 @@  discard block
 block discarded – undo
1099 1099
  * @param WP_Network|int|null $network Network to retrieve.
1100 1100
  * @return WP_Network|null The network object or null if not found.
1101 1101
  */
1102
-function get_network( &$network = null ) {
1102
+function get_network(&$network = null) {
1103 1103
 	global $current_site;
1104
-	if ( empty( $network ) && isset( $current_site ) ) {
1104
+	if (empty($network) && isset($current_site)) {
1105 1105
 		$network = $current_site;
1106 1106
 	}
1107 1107
 
1108
-	if ( $network instanceof WP_Network ) {
1108
+	if ($network instanceof WP_Network) {
1109 1109
 		$_network = $network;
1110
-	} elseif ( is_object( $network ) ) {
1111
-		$_network = new WP_Network( $network );
1110
+	} elseif (is_object($network)) {
1111
+		$_network = new WP_Network($network);
1112 1112
 	} else {
1113
-		$_network = WP_Network::get_instance( $network );
1113
+		$_network = WP_Network::get_instance($network);
1114 1114
 	}
1115 1115
 
1116
-	if ( ! $_network ) {
1116
+	if ( ! $_network) {
1117 1117
 		return null;
1118 1118
 	}
1119 1119
 
@@ -1124,7 +1124,7 @@  discard block
 block discarded – undo
1124 1124
 	 *
1125 1125
 	 * @param WP_Network $_network Network data.
1126 1126
 	 */
1127
-	$_network = apply_filters( 'get_network', $_network );
1127
+	$_network = apply_filters('get_network', $_network);
1128 1128
 
1129 1129
 	return $_network;
1130 1130
 }
@@ -1136,9 +1136,9 @@  discard block
 block discarded – undo
1136 1136
  *
1137 1137
  * @param int|array $ids Network ID or an array of network IDs to remove from cache.
1138 1138
  */
1139
-function clean_network_cache( $ids ) {
1140
-	foreach ( (array) $ids as $id ) {
1141
-		wp_cache_delete( $id, 'networks' );
1139
+function clean_network_cache($ids) {
1140
+	foreach ((array) $ids as $id) {
1141
+		wp_cache_delete($id, 'networks');
1142 1142
 
1143 1143
 		/**
1144 1144
 		 * Fires immediately after a network has been removed from the object cache.
@@ -1147,10 +1147,10 @@  discard block
 block discarded – undo
1147 1147
 		 *
1148 1148
 		 * @param int $id Network ID.
1149 1149
 		 */
1150
-		do_action( 'clean_network_cache', $id );
1150
+		do_action('clean_network_cache', $id);
1151 1151
 	}
1152 1152
 
1153
-	wp_cache_set( 'last_changed', microtime(), 'networks' );
1153
+	wp_cache_set('last_changed', microtime(), 'networks');
1154 1154
 }
1155 1155
 
1156 1156
 /**
@@ -1164,9 +1164,9 @@  discard block
 block discarded – undo
1164 1164
  *
1165 1165
  * @param array $networks Array of network row objects.
1166 1166
  */
1167
-function update_network_cache( $networks ) {
1168
-	foreach ( (array) $networks as $network ) {
1169
-		wp_cache_add( $network->id, $network, 'networks' );
1167
+function update_network_cache($networks) {
1168
+	foreach ((array) $networks as $network) {
1169
+		wp_cache_add($network->id, $network, 'networks');
1170 1170
 	}
1171 1171
 }
1172 1172
 
@@ -1181,14 +1181,14 @@  discard block
 block discarded – undo
1181 1181
  *
1182 1182
  * @param array $network_ids Array of network IDs.
1183 1183
  */
1184
-function _prime_network_caches( $network_ids ) {
1184
+function _prime_network_caches($network_ids) {
1185 1185
 	global $wpdb;
1186 1186
 
1187
-	$non_cached_ids = _get_non_cached_ids( $network_ids, 'networks' );
1188
-	if ( !empty( $non_cached_ids ) ) {
1189
-		$fresh_networks = $wpdb->get_results( sprintf( "SELECT $wpdb->site.* FROM $wpdb->site WHERE id IN (%s)", join( ",", array_map( 'intval', $non_cached_ids ) ) ) );
1187
+	$non_cached_ids = _get_non_cached_ids($network_ids, 'networks');
1188
+	if ( ! empty($non_cached_ids)) {
1189
+		$fresh_networks = $wpdb->get_results(sprintf("SELECT $wpdb->site.* FROM $wpdb->site WHERE id IN (%s)", join(",", array_map('intval', $non_cached_ids))));
1190 1190
 
1191
-		update_network_cache( $fresh_networks );
1191
+		update_network_cache($fresh_networks);
1192 1192
 	}
1193 1193
 }
1194 1194
 
@@ -1201,13 +1201,13 @@  discard block
 block discarded – undo
1201 1201
  * @param string $old_status The old post status
1202 1202
  * @param object $post       Post object
1203 1203
  */
1204
-function _update_blog_date_on_post_publish( $new_status, $old_status, $post ) {
1205
-	$post_type_obj = get_post_type_object( $post->post_type );
1206
-	if ( ! $post_type_obj || ! $post_type_obj->public ) {
1204
+function _update_blog_date_on_post_publish($new_status, $old_status, $post) {
1205
+	$post_type_obj = get_post_type_object($post->post_type);
1206
+	if ( ! $post_type_obj || ! $post_type_obj->public) {
1207 1207
 		return;
1208 1208
 	}
1209 1209
 
1210
-	if ( 'publish' != $new_status && 'publish' != $old_status ) {
1210
+	if ('publish' != $new_status && 'publish' != $old_status) {
1211 1211
 		return;
1212 1212
 	}
1213 1213
 
@@ -1223,15 +1223,15 @@  discard block
 block discarded – undo
1223 1223
  *
1224 1224
  * @param int $post_id Post ID
1225 1225
  */
1226
-function _update_blog_date_on_post_delete( $post_id ) {
1227
-	$post = get_post( $post_id );
1226
+function _update_blog_date_on_post_delete($post_id) {
1227
+	$post = get_post($post_id);
1228 1228
 
1229
-	$post_type_obj = get_post_type_object( $post->post_type );
1230
-	if ( ! $post_type_obj || ! $post_type_obj->public ) {
1229
+	$post_type_obj = get_post_type_object($post->post_type);
1230
+	if ( ! $post_type_obj || ! $post_type_obj->public) {
1231 1231
 		return;
1232 1232
 	}
1233 1233
 
1234
-	if ( 'publish' != $post->post_status ) {
1234
+	if ('publish' != $post->post_status) {
1235 1235
 		return;
1236 1236
 	}
1237 1237
 
@@ -1245,10 +1245,10 @@  discard block
 block discarded – undo
1245 1245
  *
1246 1246
  * @param int $post_id Post ID.
1247 1247
  */
1248
-function _update_posts_count_on_delete( $post_id ) {
1249
-	$post = get_post( $post_id );
1248
+function _update_posts_count_on_delete($post_id) {
1249
+	$post = get_post($post_id);
1250 1250
 
1251
-	if ( ! $post || 'publish' !== $post->post_status ) {
1251
+	if ( ! $post || 'publish' !== $post->post_status) {
1252 1252
 		return;
1253 1253
 	}
1254 1254
 
@@ -1263,12 +1263,12 @@  discard block
 block discarded – undo
1263 1263
  * @param string $new_status The status the post is changing to.
1264 1264
  * @param string $old_status The status the post is changing from.
1265 1265
  */
1266
-function _update_posts_count_on_transition_post_status( $new_status, $old_status ) {
1267
-	if ( $new_status === $old_status ) {
1266
+function _update_posts_count_on_transition_post_status($new_status, $old_status) {
1267
+	if ($new_status === $old_status) {
1268 1268
 		return;
1269 1269
 	}
1270 1270
 
1271
-	if ( 'publish' !== $new_status && 'publish' !== $old_status ) {
1271
+	if ('publish' !== $new_status && 'publish' !== $old_status) {
1272 1272
 		return;
1273 1273
 	}
1274 1274
 
Please login to merge, or discard this patch.
src/wp-includes/ms-load.php 4 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -65,7 +65,7 @@
 block discarded – undo
65 65
  *
66 66
  * @since 3.0.0
67 67
  *
68
- * @return true|string Returns true on success, or drop-in file to include.
68
+ * @return boolean|string Returns true on success, or drop-in file to include.
69 69
  */
70 70
 function ms_site_check() {
71 71
 	$blog = get_blog_details();
Please login to merge, or discard this patch.
Braces   +28 added lines, -20 removed lines patch added patch discarded remove patch
@@ -16,8 +16,9 @@  discard block
 block discarded – undo
16 16
  * @return bool True if subdomain configuration is enabled, false otherwise.
17 17
  */
18 18
 function is_subdomain_install() {
19
-	if ( defined('SUBDOMAIN_INSTALL') )
20
-		return SUBDOMAIN_INSTALL;
19
+	if ( defined('SUBDOMAIN_INSTALL') ) {
20
+			return SUBDOMAIN_INSTALL;
21
+	}
21 22
 
22 23
 	return ( defined( 'VHOST' ) && VHOST == 'yes' );
23 24
 }
@@ -35,8 +36,9 @@  discard block
 block discarded – undo
35 36
  */
36 37
 function wp_get_active_network_plugins() {
37 38
 	$active_plugins = (array) get_site_option( 'active_sitewide_plugins', array() );
38
-	if ( empty( $active_plugins ) )
39
-		return array();
39
+	if ( empty( $active_plugins ) ) {
40
+			return array();
41
+	}
40 42
 
41 43
 	$plugins = array();
42 44
 	$active_plugins = array_keys( $active_plugins );
@@ -46,8 +48,9 @@  discard block
 block discarded – undo
46 48
 		if ( ! validate_file( $plugin ) // $plugin must validate as file
47 49
 			&& '.php' == substr( $plugin, -4 ) // $plugin must end with '.php'
48 50
 			&& file_exists( WP_PLUGIN_DIR . '/' . $plugin ) // $plugin must exist
49
-			)
50
-		$plugins[] = WP_PLUGIN_DIR . '/' . $plugin;
51
+			) {
52
+				$plugins[] = WP_PLUGIN_DIR . '/' . $plugin;
53
+		}
51 54
 	}
52 55
 	return $plugins;
53 56
 }
@@ -78,18 +81,21 @@  discard block
 block discarded – undo
78 81
 	 * @param bool null Whether to skip the blog status check. Default null.
79 82
 	*/
80 83
 	$check = apply_filters( 'ms_site_check', null );
81
-	if ( null !== $check )
82
-		return true;
84
+	if ( null !== $check ) {
85
+			return true;
86
+	}
83 87
 
84 88
 	// Allow super admins to see blocked sites
85
-	if ( is_super_admin() )
86
-		return true;
89
+	if ( is_super_admin() ) {
90
+			return true;
91
+	}
87 92
 
88 93
 	if ( '1' == $blog->deleted ) {
89
-		if ( file_exists( WP_CONTENT_DIR . '/blog-deleted.php' ) )
90
-			return WP_CONTENT_DIR . '/blog-deleted.php';
91
-		else
92
-			wp_die( __( 'This site is no longer available.' ), '', array( 'response' => 410 ) );
94
+		if ( file_exists( WP_CONTENT_DIR . '/blog-deleted.php' ) ) {
95
+					return WP_CONTENT_DIR . '/blog-deleted.php';
96
+		} else {
97
+					wp_die( __( 'This site is no longer available.' ), '', array( 'response' => 410 ) );
98
+		}
93 99
 	}
94 100
 
95 101
 	if ( '2' == $blog->deleted ) {
@@ -107,10 +113,11 @@  discard block
 block discarded – undo
107 113
 	}
108 114
 
109 115
 	if ( $blog->archived == '1' || $blog->spam == '1' ) {
110
-		if ( file_exists( WP_CONTENT_DIR . '/blog-suspended.php' ) )
111
-			return WP_CONTENT_DIR . '/blog-suspended.php';
112
-		else
113
-			wp_die( __( 'This site has been archived or suspended.' ), '', array( 'response' => 410 ) );
116
+		if ( file_exists( WP_CONTENT_DIR . '/blog-suspended.php' ) ) {
117
+					return WP_CONTENT_DIR . '/blog-suspended.php';
118
+		} else {
119
+					wp_die( __( 'This site has been archived or suspended.' ), '', array( 'response' => 410 ) );
120
+		}
114 121
 	}
115 122
 
116 123
 	return true;
@@ -311,8 +318,9 @@  discard block
 block discarded – undo
311 318
 	);
312 319
 	$msg .= ' ' . __( 'If you&#8217;re still stuck with this message, then check that your database contains the following tables:' ) . '</p><ul>';
313 320
 	foreach ( $wpdb->tables('global') as $t => $table ) {
314
-		if ( 'sitecategories' == $t )
315
-			continue;
321
+		if ( 'sitecategories' == $t ) {
322
+					continue;
323
+		}
316 324
 		$msg .= '<li>' . $table . '</li>';
317 325
 	}
318 326
 	$msg .= '</ul>';
Please login to merge, or discard this patch.
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -75,7 +75,7 @@
 block discarded – undo
75 75
 	 * @since 3.0.0
76 76
 	 *
77 77
 	 * @param bool null Whether to skip the blog status check. Default null.
78
-	*/
78
+	 */
79 79
 	$check = apply_filters( 'ms_site_check', null );
80 80
 	if ( null !== $check )
81 81
 		return true;
Please login to merge, or discard this patch.
Spacing   +127 added lines, -127 removed lines patch added patch discarded remove patch
@@ -16,10 +16,10 @@  discard block
 block discarded – undo
16 16
  * @return bool True if subdomain configuration is enabled, false otherwise.
17 17
  */
18 18
 function is_subdomain_install() {
19
-	if ( defined('SUBDOMAIN_INSTALL') )
19
+	if (defined('SUBDOMAIN_INSTALL'))
20 20
 		return SUBDOMAIN_INSTALL;
21 21
 
22
-	return ( defined( 'VHOST' ) && VHOST == 'yes' );
22
+	return (defined('VHOST') && VHOST == 'yes');
23 23
 }
24 24
 
25 25
 /**
@@ -34,20 +34,20 @@  discard block
 block discarded – undo
34 34
  * @return array Files to include.
35 35
  */
36 36
 function wp_get_active_network_plugins() {
37
-	$active_plugins = (array) get_site_option( 'active_sitewide_plugins', array() );
38
-	if ( empty( $active_plugins ) )
37
+	$active_plugins = (array) get_site_option('active_sitewide_plugins', array());
38
+	if (empty($active_plugins))
39 39
 		return array();
40 40
 
41 41
 	$plugins = array();
42
-	$active_plugins = array_keys( $active_plugins );
43
-	sort( $active_plugins );
42
+	$active_plugins = array_keys($active_plugins);
43
+	sort($active_plugins);
44 44
 
45
-	foreach ( $active_plugins as $plugin ) {
46
-		if ( ! validate_file( $plugin ) // $plugin must validate as file
47
-			&& '.php' == substr( $plugin, -4 ) // $plugin must end with '.php'
48
-			&& file_exists( WP_PLUGIN_DIR . '/' . $plugin ) // $plugin must exist
45
+	foreach ($active_plugins as $plugin) {
46
+		if ( ! validate_file($plugin) // $plugin must validate as file
47
+			&& '.php' == substr($plugin, -4) // $plugin must end with '.php'
48
+			&& file_exists(WP_PLUGIN_DIR.'/'.$plugin) // $plugin must exist
49 49
 			)
50
-		$plugins[] = WP_PLUGIN_DIR . '/' . $plugin;
50
+		$plugins[] = WP_PLUGIN_DIR.'/'.$plugin;
51 51
 	}
52 52
 	return $plugins;
53 53
 }
@@ -76,42 +76,42 @@  discard block
 block discarded – undo
76 76
 	 *
77 77
 	 * @param bool null Whether to skip the blog status check. Default null.
78 78
 	*/
79
-	$check = apply_filters( 'ms_site_check', null );
80
-	if ( null !== $check )
79
+	$check = apply_filters('ms_site_check', null);
80
+	if (null !== $check)
81 81
 		return true;
82 82
 
83 83
 	// Allow super admins to see blocked sites
84
-	if ( is_super_admin() )
84
+	if (is_super_admin())
85 85
 		return true;
86 86
 
87 87
 	$blog = get_blog_details();
88 88
 
89
-	if ( '1' == $blog->deleted ) {
90
-		if ( file_exists( WP_CONTENT_DIR . '/blog-deleted.php' ) )
91
-			return WP_CONTENT_DIR . '/blog-deleted.php';
89
+	if ('1' == $blog->deleted) {
90
+		if (file_exists(WP_CONTENT_DIR.'/blog-deleted.php'))
91
+			return WP_CONTENT_DIR.'/blog-deleted.php';
92 92
 		else
93
-			wp_die( __( 'This site is no longer available.' ), '', array( 'response' => 410 ) );
93
+			wp_die(__('This site is no longer available.'), '', array('response' => 410));
94 94
 	}
95 95
 
96
-	if ( '2' == $blog->deleted ) {
97
-		if ( file_exists( WP_CONTENT_DIR . '/blog-inactive.php' ) ) {
98
-			return WP_CONTENT_DIR . '/blog-inactive.php';
96
+	if ('2' == $blog->deleted) {
97
+		if (file_exists(WP_CONTENT_DIR.'/blog-inactive.php')) {
98
+			return WP_CONTENT_DIR.'/blog-inactive.php';
99 99
 		} else {
100
-			$admin_email = str_replace( '@', ' AT ', get_site_option( 'admin_email', 'support@' . get_current_site()->domain ) );
100
+			$admin_email = str_replace('@', ' AT ', get_site_option('admin_email', 'support@'.get_current_site()->domain));
101 101
 			wp_die(
102 102
 				/* translators: %s: admin email link */
103
-				sprintf( __( 'This site has not been activated yet. If you are having problems activating your site, please contact %s.' ),
104
-					sprintf( '<a href="mailto:%s">%s</a>', $admin_email )
103
+				sprintf(__('This site has not been activated yet. If you are having problems activating your site, please contact %s.'),
104
+					sprintf('<a href="mailto:%s">%s</a>', $admin_email)
105 105
 				)
106 106
 			);
107 107
 		}
108 108
 	}
109 109
 
110
-	if ( $blog->archived == '1' || $blog->spam == '1' ) {
111
-		if ( file_exists( WP_CONTENT_DIR . '/blog-suspended.php' ) )
112
-			return WP_CONTENT_DIR . '/blog-suspended.php';
110
+	if ($blog->archived == '1' || $blog->spam == '1') {
111
+		if (file_exists(WP_CONTENT_DIR.'/blog-suspended.php'))
112
+			return WP_CONTENT_DIR.'/blog-suspended.php';
113 113
 		else
114
-			wp_die( __( 'This site has been archived or suspended.' ), '', array( 'response' => 410 ) );
114
+			wp_die(__('This site has been archived or suspended.'), '', array('response' => 410));
115 115
 	}
116 116
 
117 117
 	return true;
@@ -128,8 +128,8 @@  discard block
 block discarded – undo
128 128
  * @param int|null $segments Path segments to use. Defaults to null, or the full path.
129 129
  * @return WP_Network|false Network object if successful. False when no network is found.
130 130
  */
131
-function get_network_by_path( $domain, $path, $segments = null ) {
132
-	return WP_Network::get_by_path( $domain, $path, $segments );
131
+function get_network_by_path($domain, $path, $segments = null) {
132
+	return WP_Network::get_by_path($domain, $path, $segments);
133 133
 }
134 134
 
135 135
 /**
@@ -142,9 +142,9 @@  discard block
 block discarded – undo
142 142
  * @param object|int $network The network's database row or ID.
143 143
  * @return WP_Network|false Object containing network information if found, false if not.
144 144
  */
145
-function wp_get_network( $network ) {
146
-	$network = get_network( $network );
147
-	if ( null === $network ) {
145
+function wp_get_network($network) {
146
+	$network = get_network($network);
147
+	if (null === $network) {
148 148
 		return false;
149 149
 	}
150 150
 
@@ -164,8 +164,8 @@  discard block
 block discarded – undo
164 164
  * @param int|null $segments Path segments to use. Defaults to null, or the full path.
165 165
  * @return object|false Site object if successful. False when no site is found.
166 166
  */
167
-function get_site_by_path( $domain, $path, $segments = null ) {
168
-	$path_segments = array_filter( explode( '/', trim( $path, '/' ) ) );
167
+function get_site_by_path($domain, $path, $segments = null) {
168
+	$path_segments = array_filter(explode('/', trim($path, '/')));
169 169
 
170 170
 	/**
171 171
 	 * Filters the number of path segments to consider when searching for a site.
@@ -178,17 +178,17 @@  discard block
 block discarded – undo
178 178
 	 * @param string   $domain   The requested domain.
179 179
 	 * @param string   $path     The requested path, in full.
180 180
 	 */
181
-	$segments = apply_filters( 'site_by_path_segments_count', $segments, $domain, $path );
181
+	$segments = apply_filters('site_by_path_segments_count', $segments, $domain, $path);
182 182
 
183
-	if ( null !== $segments && count( $path_segments ) > $segments ) {
184
-		$path_segments = array_slice( $path_segments, 0, $segments );
183
+	if (null !== $segments && count($path_segments) > $segments) {
184
+		$path_segments = array_slice($path_segments, 0, $segments);
185 185
 	}
186 186
 
187 187
 	$paths = array();
188 188
 
189
-	while ( count( $path_segments ) ) {
190
-		$paths[] = '/' . implode( '/', $path_segments ) . '/';
191
-		array_pop( $path_segments );
189
+	while (count($path_segments)) {
190
+		$paths[] = '/'.implode('/', $path_segments).'/';
191
+		array_pop($path_segments);
192 192
 	}
193 193
 
194 194
 	$paths[] = '/';
@@ -212,8 +212,8 @@  discard block
 block discarded – undo
212 212
 	 *                                   Default null, meaning the entire path was to be consulted.
213 213
 	 * @param array            $paths    The paths to search for, based on $path and $segments.
214 214
 	 */
215
-	$pre = apply_filters( 'pre_get_site_by_path', null, $domain, $path, $segments, $paths );
216
-	if ( null !== $pre ) {
215
+	$pre = apply_filters('pre_get_site_by_path', null, $domain, $path, $segments, $paths);
216
+	if (null !== $pre) {
217 217
 		return $pre;
218 218
 	}
219 219
 
@@ -228,9 +228,9 @@  discard block
 block discarded – undo
228 228
 
229 229
 	// Either www or non-www is supported, not both. If a www domain is requested,
230 230
 	// query for both to provide the proper redirect.
231
-	$domains = array( $domain );
232
-	if ( 'www.' === substr( $domain, 0, 4 ) ) {
233
-		$domains[] = substr( $domain, 4 );
231
+	$domains = array($domain);
232
+	if ('www.' === substr($domain, 0, 4)) {
233
+		$domains[] = substr($domain, 4);
234 234
 	}
235 235
 
236 236
 	$args = array(
@@ -239,21 +239,21 @@  discard block
 block discarded – undo
239 239
 		'number' => 1,
240 240
 	);
241 241
 
242
-	if ( count( $domains ) > 1 && count( $paths ) > 1 ) {
242
+	if (count($domains) > 1 && count($paths) > 1) {
243 243
 		$args['orderby'] = 'domain_length path_length';
244 244
 		$args['order'] = 'DESC DESC';
245
-	} elseif ( count( $domains ) > 1 ) {
245
+	} elseif (count($domains) > 1) {
246 246
 		$args['orderby'] = 'domain_length';
247 247
 		$args['order'] = 'DESC';
248
-	} elseif ( count( $paths ) > 1 ) {
248
+	} elseif (count($paths) > 1) {
249 249
 		$args['orderby'] = 'path_length';
250 250
 		$args['order'] = 'DESC';
251 251
 	}
252 252
 
253
-	$result = get_sites( $args );
254
-	$site = array_shift( $result );
253
+	$result = get_sites($args);
254
+	$site = array_shift($result);
255 255
 
256
-	if ( $site ) {
256
+	if ($site) {
257 257
 		// @todo get_blog_details()
258 258
 		return $site;
259 259
 	}
@@ -291,55 +291,55 @@  discard block
 block discarded – undo
291 291
  *                     False if bootstrap could not be properly completed.
292 292
  *                     Redirect URL if parts exist, but the request as a whole can not be fulfilled.
293 293
  */
294
-function ms_load_current_site_and_network( $domain, $path, $subdomain = false ) {
294
+function ms_load_current_site_and_network($domain, $path, $subdomain = false) {
295 295
 	global $wpdb, $current_site, $current_blog;
296 296
 
297 297
 	// If the network is defined in wp-config.php, we can simply use that.
298
-	if ( defined( 'DOMAIN_CURRENT_SITE' ) && defined( 'PATH_CURRENT_SITE' ) ) {
298
+	if (defined('DOMAIN_CURRENT_SITE') && defined('PATH_CURRENT_SITE')) {
299 299
 		$current_site = new stdClass;
300
-		$current_site->id = defined( 'SITE_ID_CURRENT_SITE' ) ? SITE_ID_CURRENT_SITE : 1;
300
+		$current_site->id = defined('SITE_ID_CURRENT_SITE') ? SITE_ID_CURRENT_SITE : 1;
301 301
 		$current_site->domain = DOMAIN_CURRENT_SITE;
302 302
 		$current_site->path = PATH_CURRENT_SITE;
303
-		if ( defined( 'BLOG_ID_CURRENT_SITE' ) ) {
303
+		if (defined('BLOG_ID_CURRENT_SITE')) {
304 304
 			$current_site->blog_id = BLOG_ID_CURRENT_SITE;
305
-		} elseif ( defined( 'BLOGID_CURRENT_SITE' ) ) { // deprecated.
305
+		} elseif (defined('BLOGID_CURRENT_SITE')) { // deprecated.
306 306
 			$current_site->blog_id = BLOGID_CURRENT_SITE;
307 307
 		}
308 308
 
309
-		if ( 0 === strcasecmp( $current_site->domain, $domain ) && 0 === strcasecmp( $current_site->path, $path ) ) {
310
-			$current_blog = get_site_by_path( $domain, $path );
311
-		} elseif ( '/' !== $current_site->path && 0 === strcasecmp( $current_site->domain, $domain ) && 0 === stripos( $path, $current_site->path ) ) {
309
+		if (0 === strcasecmp($current_site->domain, $domain) && 0 === strcasecmp($current_site->path, $path)) {
310
+			$current_blog = get_site_by_path($domain, $path);
311
+		} elseif ('/' !== $current_site->path && 0 === strcasecmp($current_site->domain, $domain) && 0 === stripos($path, $current_site->path)) {
312 312
 			// If the current network has a path and also matches the domain and path of the request,
313 313
 			// we need to look for a site using the first path segment following the network's path.
314
-			$current_blog = get_site_by_path( $domain, $path, 1 + count( explode( '/', trim( $current_site->path, '/' ) ) ) );
314
+			$current_blog = get_site_by_path($domain, $path, 1 + count(explode('/', trim($current_site->path, '/'))));
315 315
 		} else {
316 316
 			// Otherwise, use the first path segment (as usual).
317
-			$current_blog = get_site_by_path( $domain, $path, 1 );
317
+			$current_blog = get_site_by_path($domain, $path, 1);
318 318
 		}
319 319
 
320
-	} elseif ( ! $subdomain ) {
320
+	} elseif ( ! $subdomain) {
321 321
 		/*
322 322
 		 * A "subdomain" install can be re-interpreted to mean "can support any domain".
323 323
 		 * If we're not dealing with one of these installs, then the important part is determining
324 324
 		 * the network first, because we need the network's path to identify any sites.
325 325
 		 */
326
-		if ( ! $current_site = wp_cache_get( 'current_network', 'site-options' ) ) {
326
+		if ( ! $current_site = wp_cache_get('current_network', 'site-options')) {
327 327
 			// Are there even two networks installed?
328
-			$one_network = $wpdb->get_row( "SELECT * FROM $wpdb->site LIMIT 2" ); // [sic]
329
-			if ( 1 === $wpdb->num_rows ) {
330
-				$current_site = new WP_Network( $one_network );
331
-				wp_cache_add( 'current_network', $current_site, 'site-options' );
332
-			} elseif ( 0 === $wpdb->num_rows ) {
328
+			$one_network = $wpdb->get_row("SELECT * FROM $wpdb->site LIMIT 2"); // [sic]
329
+			if (1 === $wpdb->num_rows) {
330
+				$current_site = new WP_Network($one_network);
331
+				wp_cache_add('current_network', $current_site, 'site-options');
332
+			} elseif (0 === $wpdb->num_rows) {
333 333
 				// A network not found hook should fire here.
334 334
 				return false;
335 335
 			}
336 336
 		}
337 337
 
338
-		if ( empty( $current_site ) ) {
339
-			$current_site = WP_Network::get_by_path( $domain, $path, 1 );
338
+		if (empty($current_site)) {
339
+			$current_site = WP_Network::get_by_path($domain, $path, 1);
340 340
 		}
341 341
 
342
-		if ( empty( $current_site ) ) {
342
+		if (empty($current_site)) {
343 343
 			/**
344 344
 			 * Fires when a network cannot be found based on the requested domain and path.
345 345
 			 *
@@ -351,48 +351,48 @@  discard block
 block discarded – undo
351 351
 			 * @param string $domain       The domain used to search for a network.
352 352
 			 * @param string $path         The path used to search for a path.
353 353
 			 */
354
-			do_action( 'ms_network_not_found', $domain, $path );
354
+			do_action('ms_network_not_found', $domain, $path);
355 355
 
356 356
 			return false;
357
-		} elseif ( $path === $current_site->path ) {
358
-			$current_blog = get_site_by_path( $domain, $path );
357
+		} elseif ($path === $current_site->path) {
358
+			$current_blog = get_site_by_path($domain, $path);
359 359
 		} else {
360 360
 			// Search the network path + one more path segment (on top of the network path).
361
-			$current_blog = get_site_by_path( $domain, $path, substr_count( $current_site->path, '/' ) );
361
+			$current_blog = get_site_by_path($domain, $path, substr_count($current_site->path, '/'));
362 362
 		}
363 363
 	} else {
364 364
 		// Find the site by the domain and at most the first path segment.
365
-		$current_blog = get_site_by_path( $domain, $path, 1 );
366
-		if ( $current_blog ) {
367
-			$current_site = WP_Network::get_instance( $current_blog->site_id ? $current_blog->site_id : 1 );
365
+		$current_blog = get_site_by_path($domain, $path, 1);
366
+		if ($current_blog) {
367
+			$current_site = WP_Network::get_instance($current_blog->site_id ? $current_blog->site_id : 1);
368 368
 		} else {
369 369
 			// If you don't have a site with the same domain/path as a network, you're pretty screwed, but:
370
-			$current_site = WP_Network::get_by_path( $domain, $path, 1 );
370
+			$current_site = WP_Network::get_by_path($domain, $path, 1);
371 371
 		}
372 372
 	}
373 373
 
374 374
 	// The network declared by the site trumps any constants.
375
-	if ( $current_blog && $current_blog->site_id != $current_site->id ) {
376
-		$current_site = WP_Network::get_instance( $current_blog->site_id );
375
+	if ($current_blog && $current_blog->site_id != $current_site->id) {
376
+		$current_site = WP_Network::get_instance($current_blog->site_id);
377 377
 	}
378 378
 
379 379
 	// No network has been found, bail.
380
-	if ( empty( $current_site ) ) {
380
+	if (empty($current_site)) {
381 381
 		/** This action is documented in wp-includes/ms-settings.php */
382
-		do_action( 'ms_network_not_found', $domain, $path );
382
+		do_action('ms_network_not_found', $domain, $path);
383 383
 
384 384
 		return false;
385 385
 	}
386 386
 
387 387
 	// During activation of a new subdomain, the requested site does not yet exist.
388
-	if ( empty( $current_blog ) && wp_installing() ) {
388
+	if (empty($current_blog) && wp_installing()) {
389 389
 		$current_blog = new stdClass;
390 390
 		$current_blog->blog_id = $blog_id = 1;
391 391
 		$current_blog->public = 1;
392 392
 	}
393 393
 
394 394
 	// No site has been found, bail.
395
-	if ( empty( $current_blog ) ) {
395
+	if (empty($current_blog)) {
396 396
 		// We're going to redirect to the network URL, with some possible modifications.
397 397
 		$scheme = is_ssl() ? 'https' : 'http';
398 398
 		$destination = "$scheme://{$current_site->domain}{$current_site->path}";
@@ -409,19 +409,19 @@  discard block
 block discarded – undo
409 409
 		 * @param string $domain       The domain used to search for a site.
410 410
 		 * @param string $path         The path used to search for a site.
411 411
 		 */
412
-		do_action( 'ms_site_not_found', $current_site, $domain, $path );
412
+		do_action('ms_site_not_found', $current_site, $domain, $path);
413 413
 
414
-		if ( $subdomain && ! defined( 'NOBLOGREDIRECT' ) ) {
414
+		if ($subdomain && ! defined('NOBLOGREDIRECT')) {
415 415
 			// For a "subdomain" install, redirect to the signup form specifically.
416
-			$destination .= 'wp-signup.php?new=' . str_replace( '.' . $current_site->domain, '', $domain );
417
-		} elseif ( $subdomain ) {
416
+			$destination .= 'wp-signup.php?new='.str_replace('.'.$current_site->domain, '', $domain);
417
+		} elseif ($subdomain) {
418 418
 			// For a "subdomain" install, the NOBLOGREDIRECT constant
419 419
 			// can be used to avoid a redirect to the signup form.
420 420
 			// Using the ms_site_not_found action is preferred to the constant.
421
-			if ( '%siteurl%' !== NOBLOGREDIRECT ) {
421
+			if ('%siteurl%' !== NOBLOGREDIRECT) {
422 422
 				$destination = NOBLOGREDIRECT;
423 423
 			}
424
-		} elseif ( 0 === strcasecmp( $current_site->domain, $domain ) ) {
424
+		} elseif (0 === strcasecmp($current_site->domain, $domain)) {
425 425
 			/*
426 426
 			 * If the domain we were searching for matches the network's domain,
427 427
 			 * it's no use redirecting back to ourselves -- it'll cause a loop.
@@ -434,13 +434,13 @@  discard block
 block discarded – undo
434 434
 	}
435 435
 
436 436
 	// Figure out the current network's main site.
437
-	if ( empty( $current_site->blog_id ) ) {
438
-		if ( $current_blog->domain === $current_site->domain && $current_blog->path === $current_site->path ) {
437
+	if (empty($current_site->blog_id)) {
438
+		if ($current_blog->domain === $current_site->domain && $current_blog->path === $current_site->path) {
439 439
 			$current_site->blog_id = $current_blog->blog_id;
440
-		} elseif ( ! $current_site->blog_id = wp_cache_get( 'network:' . $current_site->id . ':main_site', 'site-options' ) ) {
441
-			$current_site->blog_id = $wpdb->get_var( $wpdb->prepare( "SELECT blog_id FROM $wpdb->blogs WHERE domain = %s AND path = %s",
442
-				$current_site->domain, $current_site->path ) );
443
-			wp_cache_add( 'network:' . $current_site->id . ':main_site', $current_site->blog_id, 'site-options' );
440
+		} elseif ( ! $current_site->blog_id = wp_cache_get('network:'.$current_site->id.':main_site', 'site-options')) {
441
+			$current_site->blog_id = $wpdb->get_var($wpdb->prepare("SELECT blog_id FROM $wpdb->blogs WHERE domain = %s AND path = %s",
442
+				$current_site->domain, $current_site->path));
443
+			wp_cache_add('network:'.$current_site->id.':main_site', $current_site->blog_id, 'site-options');
444 444
 		}
445 445
 	}
446 446
 
@@ -461,50 +461,50 @@  discard block
 block discarded – undo
461 461
  * @param string $domain The requested domain for the error to reference.
462 462
  * @param string $path   The requested path for the error to reference.
463 463
  */
464
-function ms_not_installed( $domain, $path ) {
464
+function ms_not_installed($domain, $path) {
465 465
 	global $wpdb;
466 466
 
467
-	if ( ! is_admin() ) {
467
+	if ( ! is_admin()) {
468 468
 		dead_db();
469 469
 	}
470 470
 
471 471
 	wp_load_translations_early();
472 472
 
473
-	$title = __( 'Error establishing a database connection' );
473
+	$title = __('Error establishing a database connection');
474 474
 
475
-	$msg  = '<h1>' . $title . '</h1>';
476
-	$msg .= '<p>' . __( 'If your site does not display, please contact the owner of this network.' ) . '';
477
-	$msg .= ' ' . __( 'If you are the owner of this network please check that MySQL is running properly and all tables are error free.' ) . '</p>';
478
-	$query = $wpdb->prepare( "SHOW TABLES LIKE %s", $wpdb->esc_like( $wpdb->site ) );
479
-	if ( ! $wpdb->get_var( $query ) ) {
480
-		$msg .= '<p>' . sprintf(
475
+	$msg  = '<h1>'.$title.'</h1>';
476
+	$msg .= '<p>'.__('If your site does not display, please contact the owner of this network.').'';
477
+	$msg .= ' '.__('If you are the owner of this network please check that MySQL is running properly and all tables are error free.').'</p>';
478
+	$query = $wpdb->prepare("SHOW TABLES LIKE %s", $wpdb->esc_like($wpdb->site));
479
+	if ( ! $wpdb->get_var($query)) {
480
+		$msg .= '<p>'.sprintf(
481 481
 			/* translators: %s: table name */
482
-			__( '<strong>Database tables are missing.</strong> This means that MySQL is not running, WordPress was not installed properly, or someone deleted %s. You really should look at your database now.' ),
483
-			'<code>' . $wpdb->site . '</code>'
484
-		) . '</p>';
482
+			__('<strong>Database tables are missing.</strong> This means that MySQL is not running, WordPress was not installed properly, or someone deleted %s. You really should look at your database now.'),
483
+			'<code>'.$wpdb->site.'</code>'
484
+		).'</p>';
485 485
 	} else {
486
-		$msg .= '<p>' . sprintf(
486
+		$msg .= '<p>'.sprintf(
487 487
 			/* translators: 1: site url, 2: table name, 3: database name */
488
-			__( '<strong>Could not find site %1$s.</strong> Searched for table %2$s in database %3$s. Is that right?' ),
489
-			'<code>' . rtrim( $domain . $path, '/' ) . '</code>',
490
-			'<code>' . $wpdb->blogs . '</code>',
491
-			'<code>' . DB_NAME . '</code>'
492
-		) . '</p>';
488
+			__('<strong>Could not find site %1$s.</strong> Searched for table %2$s in database %3$s. Is that right?'),
489
+			'<code>'.rtrim($domain.$path, '/').'</code>',
490
+			'<code>'.$wpdb->blogs.'</code>',
491
+			'<code>'.DB_NAME.'</code>'
492
+		).'</p>';
493 493
 	}
494
-	$msg .= '<p><strong>' . __( 'What do I do now?' ) . '</strong> ';
494
+	$msg .= '<p><strong>'.__('What do I do now?').'</strong> ';
495 495
 	/* translators: %s: Codex URL */
496
-	$msg .= sprintf( __( 'Read the <a href="%s" target="_blank">bug report</a> page. Some of the guidelines there may help you figure out what went wrong.' ),
497
-		__( 'https://codex.wordpress.org/Debugging_a_WordPress_Network' )
496
+	$msg .= sprintf(__('Read the <a href="%s" target="_blank">bug report</a> page. Some of the guidelines there may help you figure out what went wrong.'),
497
+		__('https://codex.wordpress.org/Debugging_a_WordPress_Network')
498 498
 	);
499
-	$msg .= ' ' . __( 'If you&#8217;re still stuck with this message, then check that your database contains the following tables:' ) . '</p><ul>';
500
-	foreach ( $wpdb->tables('global') as $t => $table ) {
501
-		if ( 'sitecategories' == $t )
499
+	$msg .= ' '.__('If you&#8217;re still stuck with this message, then check that your database contains the following tables:').'</p><ul>';
500
+	foreach ($wpdb->tables('global') as $t => $table) {
501
+		if ('sitecategories' == $t)
502 502
 			continue;
503
-		$msg .= '<li>' . $table . '</li>';
503
+		$msg .= '<li>'.$table.'</li>';
504 504
 	}
505 505
 	$msg .= '</ul>';
506 506
 
507
-	wp_die( $msg, $title, array( 'response' => 500 ) );
507
+	wp_die($msg, $title, array('response' => 500));
508 508
 }
509 509
 
510 510
 /**
@@ -520,8 +520,8 @@  discard block
 block discarded – undo
520 520
  * @param object $current_site
521 521
  * @return object
522 522
  */
523
-function get_current_site_name( $current_site ) {
524
-	_deprecated_function( __FUNCTION__, '3.9', 'get_current_site()' );
523
+function get_current_site_name($current_site) {
524
+	_deprecated_function(__FUNCTION__, '3.9', 'get_current_site()');
525 525
 	return $current_site;
526 526
 }
527 527
 
@@ -541,6 +541,6 @@  discard block
 block discarded – undo
541 541
  */
542 542
 function wpmu_current_site() {
543 543
 	global $current_site;
544
-	_deprecated_function( __FUNCTION__, '3.9' );
544
+	_deprecated_function(__FUNCTION__, '3.9');
545 545
 	return $current_site;
546 546
 }
Please login to merge, or discard this patch.
src/wp-includes/pomo/mo.php 3 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -68,7 +68,7 @@
 block discarded – undo
68 68
 
69 69
 	/**
70 70
 	 * @param resource $fh
71
-	 * @return true
71
+	 * @return boolean
72 72
 	 */
73 73
 	function export_to_file_handle($fh) {
74 74
 		$entries = array_filter( $this->entries, array( $this, 'is_entry_good_for_export' ) );
Please login to merge, or discard this patch.
Spacing   +40 added lines, -40 removed lines patch added patch discarded remove patch
@@ -7,10 +7,10 @@  discard block
 block discarded – undo
7 7
  * @subpackage mo
8 8
  */
9 9
 
10
-require_once dirname(__FILE__) . '/translations.php';
11
-require_once dirname(__FILE__) . '/streams.php';
10
+require_once dirname(__FILE__).'/translations.php';
11
+require_once dirname(__FILE__).'/streams.php';
12 12
 
13
-if ( ! class_exists( 'MO', false ) ):
13
+if ( ! class_exists('MO', false)):
14 14
 class MO extends Gettext_Translations {
15 15
 
16 16
 	var $_nplurals = 2;
@@ -22,7 +22,7 @@  discard block
 block discarded – undo
22 22
 	 */
23 23
 	function import_from_file($filename) {
24 24
 		$reader = new POMO_FileReader($filename);
25
-		if (!$reader->is_resource())
25
+		if ( ! $reader->is_resource())
26 26
 			return false;
27 27
 		return $this->import_from_reader($reader);
28 28
 	}
@@ -33,8 +33,8 @@  discard block
 block discarded – undo
33 33
 	 */
34 34
 	function export_to_file($filename) {
35 35
 		$fh = fopen($filename, 'wb');
36
-		if ( !$fh ) return false;
37
-		$res = $this->export_to_file_handle( $fh );
36
+		if ( ! $fh) return false;
37
+		$res = $this->export_to_file_handle($fh);
38 38
 		fclose($fh);
39 39
 		return $res;
40 40
 	}
@@ -44,22 +44,22 @@  discard block
 block discarded – undo
44 44
 	 */
45 45
 	function export() {
46 46
 		$tmp_fh = fopen("php://temp", 'r+');
47
-		if ( !$tmp_fh ) return false;
48
-		$this->export_to_file_handle( $tmp_fh );
49
-		rewind( $tmp_fh );
50
-		return stream_get_contents( $tmp_fh );
47
+		if ( ! $tmp_fh) return false;
48
+		$this->export_to_file_handle($tmp_fh);
49
+		rewind($tmp_fh);
50
+		return stream_get_contents($tmp_fh);
51 51
 	}
52 52
 
53 53
 	/**
54 54
 	 * @param Translation_Entry $entry
55 55
 	 * @return bool
56 56
 	 */
57
-	function is_entry_good_for_export( $entry ) {
58
-		if ( empty( $entry->translations ) ) {
57
+	function is_entry_good_for_export($entry) {
58
+		if (empty($entry->translations)) {
59 59
 			return false;
60 60
 		}
61 61
 
62
-		if ( !array_filter( $entry->translations ) ) {
62
+		if ( ! array_filter($entry->translations)) {
63 63
 			return false;
64 64
 		}
65 65
 
@@ -71,7 +71,7 @@  discard block
 block discarded – undo
71 71
 	 * @return true
72 72
 	 */
73 73
 	function export_to_file_handle($fh) {
74
-		$entries = array_filter( $this->entries, array( $this, 'is_entry_good_for_export' ) );
74
+		$entries = array_filter($this->entries, array($this, 'is_entry_good_for_export'));
75 75
 		ksort($entries);
76 76
 		$magic = 0x950412de;
77 77
 		$revision = 0;
@@ -92,8 +92,8 @@  discard block
 block discarded – undo
92 92
 
93 93
 		$reader = new POMO_Reader();
94 94
 
95
-		foreach($entries as $entry) {
96
-			$originals_table .= $this->export_original($entry) . chr(0);
95
+		foreach ($entries as $entry) {
96
+			$originals_table .= $this->export_original($entry).chr(0);
97 97
 			$length = $reader->strlen($this->export_original($entry));
98 98
 			fwrite($fh, pack('VV', $length, $current_addr));
99 99
 			$current_addr += $length + 1; // account for the NULL byte after
@@ -102,10 +102,10 @@  discard block
 block discarded – undo
102 102
 		$exported_headers = $this->export_headers();
103 103
 		fwrite($fh, pack('VV', $reader->strlen($exported_headers), $current_addr));
104 104
 		$current_addr += strlen($exported_headers) + 1;
105
-		$translations_table = $exported_headers . chr(0);
105
+		$translations_table = $exported_headers.chr(0);
106 106
 
107
-		foreach($entries as $entry) {
108
-			$translations_table .= $this->export_translations($entry) . chr(0);
107
+		foreach ($entries as $entry) {
108
+			$translations_table .= $this->export_translations($entry).chr(0);
109 109
 			$length = $reader->strlen($this->export_translations($entry));
110 110
 			fwrite($fh, pack('VV', $length, $current_addr));
111 111
 			$current_addr += $length + 1;
@@ -124,7 +124,7 @@  discard block
 block discarded – undo
124 124
 		//TODO: warnings for control characters
125 125
 		$exported = $entry->singular;
126 126
 		if ($entry->is_plural) $exported .= chr(0).$entry->plural;
127
-		if ($entry->context) $exported = $entry->context . chr(4) . $exported;
127
+		if ($entry->context) $exported = $entry->context.chr(4).$exported;
128 128
 		return $exported;
129 129
 	}
130 130
 
@@ -142,8 +142,8 @@  discard block
 block discarded – undo
142 142
 	 */
143 143
 	function export_headers() {
144 144
 		$exported = '';
145
-		foreach($this->headers as $header => $value) {
146
-			$exported.= "$header: $value\n";
145
+		foreach ($this->headers as $header => $value) {
146
+			$exported .= "$header: $value\n";
147 147
 		}
148 148
 		return $exported;
149 149
 	}
@@ -156,10 +156,10 @@  discard block
 block discarded – undo
156 156
 		// The magic is 0x950412de
157 157
 
158 158
 		// bug in PHP 5.0.2, see https://savannah.nongnu.org/bugs/?func=detailitem&item_id=10565
159
-		$magic_little = (int) - 1794895138;
159
+		$magic_little = (int) -1794895138;
160 160
 		$magic_little_64 = (int) 2500072158;
161 161
 		// 0xde120495
162
-		$magic_big = ((int) - 569244523) & 0xFFFFFFFF;
162
+		$magic_big = ((int) -569244523) & 0xFFFFFFFF;
163 163
 		if ($magic_little == $magic || $magic_little_64 == $magic) {
164 164
 			return 'little';
165 165
 		} else if ($magic_big == $magic) {
@@ -179,7 +179,7 @@  discard block
 block discarded – undo
179 179
 		}
180 180
 		$reader->setEndian($endian_string);
181 181
 
182
-		$endian = ('big' == $endian_string)? 'N' : 'V';
182
+		$endian = ('big' == $endian_string) ? 'N' : 'V';
183 183
 
184 184
 		$header = $reader->read(24);
185 185
 		if ($reader->strlen($header) != 24)
@@ -187,42 +187,42 @@  discard block
 block discarded – undo
187 187
 
188 188
 		// parse header
189 189
 		$header = unpack("{$endian}revision/{$endian}total/{$endian}originals_lenghts_addr/{$endian}translations_lenghts_addr/{$endian}hash_length/{$endian}hash_addr", $header);
190
-		if (!is_array($header))
190
+		if ( ! is_array($header))
191 191
 			return false;
192 192
 
193 193
 		// support revision 0 of MO format specs, only
194
-		if ( $header['revision'] != 0 ) {
194
+		if ($header['revision'] != 0) {
195 195
 			return false;
196 196
 		}
197 197
 
198 198
 		// seek to data blocks
199
-		$reader->seekto( $header['originals_lenghts_addr'] );
199
+		$reader->seekto($header['originals_lenghts_addr']);
200 200
 
201 201
 		// read originals' indices
202 202
 		$originals_lengths_length = $header['translations_lenghts_addr'] - $header['originals_lenghts_addr'];
203
-		if ( $originals_lengths_length != $header['total'] * 8 ) {
203
+		if ($originals_lengths_length != $header['total'] * 8) {
204 204
 			return false;
205 205
 		}
206 206
 
207 207
 		$originals = $reader->read($originals_lengths_length);
208
-		if ( $reader->strlen( $originals ) != $originals_lengths_length ) {
208
+		if ($reader->strlen($originals) != $originals_lengths_length) {
209 209
 			return false;
210 210
 		}
211 211
 
212 212
 		// read translations' indices
213 213
 		$translations_lenghts_length = $header['hash_addr'] - $header['translations_lenghts_addr'];
214
-		if ( $translations_lenghts_length != $header['total'] * 8 ) {
214
+		if ($translations_lenghts_length != $header['total'] * 8) {
215 215
 			return false;
216 216
 		}
217 217
 
218 218
 		$translations = $reader->read($translations_lenghts_length);
219
-		if ( $reader->strlen( $translations ) != $translations_lenghts_length ) {
219
+		if ($reader->strlen($translations) != $translations_lenghts_length) {
220 220
 			return false;
221 221
 		}
222 222
 
223 223
 		// transform raw data into set of indices
224
-		$originals    = $reader->str_split( $originals, 8 );
225
-		$translations = $reader->str_split( $translations, 8 );
224
+		$originals    = $reader->str_split($originals, 8);
225
+		$translations = $reader->str_split($translations, 8);
226 226
 
227 227
 		// skip hash table
228 228
 		$strings_addr = $header['hash_addr'] + $header['hash_length'] * 4;
@@ -232,17 +232,17 @@  discard block
 block discarded – undo
232 232
 		$strings = $reader->read_all();
233 233
 		$reader->close();
234 234
 
235
-		for ( $i = 0; $i < $header['total']; $i++ ) {
236
-			$o = unpack( "{$endian}length/{$endian}pos", $originals[$i] );
237
-			$t = unpack( "{$endian}length/{$endian}pos", $translations[$i] );
238
-			if ( !$o || !$t ) return false;
235
+		for ($i = 0; $i < $header['total']; $i++) {
236
+			$o = unpack("{$endian}length/{$endian}pos", $originals[$i]);
237
+			$t = unpack("{$endian}length/{$endian}pos", $translations[$i]);
238
+			if ( ! $o || ! $t) return false;
239 239
 
240 240
 			// adjust offset due to reading strings to separate space before
241 241
 			$o['pos'] -= $strings_addr;
242 242
 			$t['pos'] -= $strings_addr;
243 243
 
244
-			$original    = $reader->substr( $strings, $o['pos'], $o['length'] );
245
-			$translation = $reader->substr( $strings, $t['pos'], $t['length'] );
244
+			$original    = $reader->substr($strings, $o['pos'], $o['length']);
245
+			$translation = $reader->substr($strings, $t['pos'], $t['length']);
246 246
 
247 247
 			if ('' === $original) {
248 248
 				$this->set_headers($this->make_headers($translation));
Please login to merge, or discard this patch.
Braces   +24 added lines, -11 removed lines patch added patch discarded remove patch
@@ -22,8 +22,9 @@  discard block
 block discarded – undo
22 22
 	 */
23 23
 	function import_from_file($filename) {
24 24
 		$reader = new POMO_FileReader($filename);
25
-		if (!$reader->is_resource())
26
-			return false;
25
+		if (!$reader->is_resource()) {
26
+					return false;
27
+		}
27 28
 		return $this->import_from_reader($reader);
28 29
 	}
29 30
 
@@ -33,7 +34,9 @@  discard block
 block discarded – undo
33 34
 	 */
34 35
 	function export_to_file($filename) {
35 36
 		$fh = fopen($filename, 'wb');
36
-		if ( !$fh ) return false;
37
+		if ( !$fh ) {
38
+			return false;
39
+		}
37 40
 		$res = $this->export_to_file_handle( $fh );
38 41
 		fclose($fh);
39 42
 		return $res;
@@ -44,7 +47,9 @@  discard block
 block discarded – undo
44 47
 	 */
45 48
 	function export() {
46 49
 		$tmp_fh = fopen("php://temp", 'r+');
47
-		if ( !$tmp_fh ) return false;
50
+		if ( !$tmp_fh ) {
51
+			return false;
52
+		}
48 53
 		$this->export_to_file_handle( $tmp_fh );
49 54
 		rewind( $tmp_fh );
50 55
 		return stream_get_contents( $tmp_fh );
@@ -123,8 +128,12 @@  discard block
 block discarded – undo
123 128
 	function export_original($entry) {
124 129
 		//TODO: warnings for control characters
125 130
 		$exported = $entry->singular;
126
-		if ($entry->is_plural) $exported .= chr(0).$entry->plural;
127
-		if ($entry->context) $exported = $entry->context . chr(4) . $exported;
131
+		if ($entry->is_plural) {
132
+			$exported .= chr(0).$entry->plural;
133
+		}
134
+		if ($entry->context) {
135
+			$exported = $entry->context . chr(4) . $exported;
136
+		}
128 137
 		return $exported;
129 138
 	}
130 139
 
@@ -182,13 +191,15 @@  discard block
 block discarded – undo
182 191
 		$endian = ('big' == $endian_string)? 'N' : 'V';
183 192
 
184 193
 		$header = $reader->read(24);
185
-		if ($reader->strlen($header) != 24)
186
-			return false;
194
+		if ($reader->strlen($header) != 24) {
195
+					return false;
196
+		}
187 197
 
188 198
 		// parse header
189 199
 		$header = unpack("{$endian}revision/{$endian}total/{$endian}originals_lenghts_addr/{$endian}translations_lenghts_addr/{$endian}hash_length/{$endian}hash_addr", $header);
190
-		if (!is_array($header))
191
-			return false;
200
+		if (!is_array($header)) {
201
+					return false;
202
+		}
192 203
 
193 204
 		// support revision 0 of MO format specs, only
194 205
 		if ( $header['revision'] != 0 ) {
@@ -235,7 +246,9 @@  discard block
 block discarded – undo
235 246
 		for ( $i = 0; $i < $header['total']; $i++ ) {
236 247
 			$o = unpack( "{$endian}length/{$endian}pos", $originals[$i] );
237 248
 			$t = unpack( "{$endian}length/{$endian}pos", $translations[$i] );
238
-			if ( !$o || !$t ) return false;
249
+			if ( !$o || !$t ) {
250
+				return false;
251
+			}
239 252
 
240 253
 			// adjust offset due to reading strings to separate space before
241 254
 			$o['pos'] -= $strings_addr;
Please login to merge, or discard this patch.
src/wp-includes/pomo/streams.php 3 patches
Doc Comments   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -32,7 +32,7 @@  discard block
 block discarded – undo
32 32
 	/**
33 33
 	 * Sets the endianness of the file.
34 34
 	 *
35
-	 * @param $endian string 'big' or 'little'
35
+	 * @param string $endian string 'big' or 'little'
36 36
 	 */
37 37
 	function setEndian($endian) {
38 38
 		$this->endian = $endian;
@@ -41,7 +41,7 @@  discard block
 block discarded – undo
41 41
 	/**
42 42
 	 * Reads a 32bit Integer from the Stream
43 43
 	 *
44
-	 * @return mixed The integer, corresponding to the next 32 bits from
44
+	 * @return integer The integer, corresponding to the next 32 bits from
45 45
 	 * 	the stream of false if there are not enough bytes or on error
46 46
 	 */
47 47
 	function readint32() {
@@ -119,14 +119,14 @@  discard block
 block discarded – undo
119 119
 	}
120 120
 
121 121
 	/**
122
-	 * @return true
122
+	 * @return boolean
123 123
 	 */
124 124
 	function is_resource() {
125 125
 		return true;
126 126
 	}
127 127
 
128 128
 	/**
129
-	 * @return true
129
+	 * @return boolean
130 130
 	 */
131 131
 	function close() {
132 132
 		return true;
Please login to merge, or discard this patch.
Braces   +21 added lines, -12 removed lines patch added patch discarded remove patch
@@ -46,8 +46,9 @@  discard block
 block discarded – undo
46 46
 	 */
47 47
 	function readint32() {
48 48
 		$bytes = $this->read(4);
49
-		if (4 != $this->strlen($bytes))
50
-			return false;
49
+		if (4 != $this->strlen($bytes)) {
50
+					return false;
51
+		}
51 52
 		$endian_letter = ('big' == $this->endian)? 'N' : 'V';
52 53
 		$int = unpack($endian_letter, $bytes);
53 54
 		return reset( $int );
@@ -62,8 +63,9 @@  discard block
 block discarded – undo
62 63
 	 */
63 64
 	function readint32array($count) {
64 65
 		$bytes = $this->read(4 * $count);
65
-		if (4*$count != $this->strlen($bytes))
66
-			return false;
66
+		if (4*$count != $this->strlen($bytes)) {
67
+					return false;
68
+		}
67 69
 		$endian_letter = ('big' == $this->endian)? 'N' : 'V';
68 70
 		return unpack($endian_letter.$count, $bytes);
69 71
 	}
@@ -103,8 +105,9 @@  discard block
 block discarded – undo
103 105
 		if (!function_exists('str_split')) {
104 106
 			$length = $this->strlen($string);
105 107
 			$out = array();
106
-			for ($i = 0; $i < $length; $i += $chunk_size)
107
-				$out[] = $this->substr($string, $i, $chunk_size);
108
+			for ($i = 0; $i < $length; $i += $chunk_size) {
109
+							$out[] = $this->substr($string, $i, $chunk_size);
110
+			}
108 111
 			return $out;
109 112
 		} else {
110 113
 			return str_split( $string, $chunk_size );
@@ -197,8 +200,9 @@  discard block
 block discarded – undo
197 200
 	 */
198 201
 	function read_all() {
199 202
 		$all = '';
200
-		while ( !$this->feof() )
201
-			$all .= $this->read(4096);
203
+		while ( !$this->feof() ) {
204
+					$all .= $this->read(4096);
205
+		}
202 206
 		return $all;
203 207
 	}
204 208
 }
@@ -236,7 +240,9 @@  discard block
 block discarded – undo
236 240
 	function read($bytes) {
237 241
 		$data = $this->substr($this->_str, $this->_pos, $bytes);
238 242
 		$this->_pos += $bytes;
239
-		if ($this->strlen($this->_str) < $this->_pos) $this->_pos = $this->strlen($this->_str);
243
+		if ($this->strlen($this->_str) < $this->_pos) {
244
+			$this->_pos = $this->strlen($this->_str);
245
+		}
240 246
 		return $data;
241 247
 	}
242 248
 
@@ -246,7 +252,9 @@  discard block
 block discarded – undo
246 252
 	 */
247 253
 	function seekto($pos) {
248 254
 		$this->_pos = $pos;
249
-		if ($this->strlen($this->_str) < $this->_pos) $this->_pos = $this->strlen($this->_str);
255
+		if ($this->strlen($this->_str) < $this->_pos) {
256
+			$this->_pos = $this->strlen($this->_str);
257
+		}
250 258
 		return $this->_pos;
251 259
 	}
252 260
 
@@ -278,8 +286,9 @@  discard block
 block discarded – undo
278 286
 	function __construct( $filename ) {
279 287
 		parent::POMO_StringReader();
280 288
 		$this->_str = file_get_contents($filename);
281
-		if (false === $this->_str)
282
-			return false;
289
+		if (false === $this->_str) {
290
+					return false;
291
+		}
283 292
 		$this->_pos = 0;
284 293
 	}
285 294
 
Please login to merge, or discard this patch.
Spacing   +24 added lines, -24 removed lines patch added patch discarded remove patch
@@ -8,7 +8,7 @@  discard block
 block discarded – undo
8 8
  * @subpackage streams
9 9
  */
10 10
 
11
-if ( ! class_exists( 'POMO_Reader', false ) ):
11
+if ( ! class_exists('POMO_Reader', false)):
12 12
 class POMO_Reader {
13 13
 
14 14
 	var $endian = 'little';
@@ -48,9 +48,9 @@  discard block
 block discarded – undo
48 48
 		$bytes = $this->read(4);
49 49
 		if (4 != $this->strlen($bytes))
50 50
 			return false;
51
-		$endian_letter = ('big' == $this->endian)? 'N' : 'V';
51
+		$endian_letter = ('big' == $this->endian) ? 'N' : 'V';
52 52
 		$int = unpack($endian_letter, $bytes);
53
-		return reset( $int );
53
+		return reset($int);
54 54
 	}
55 55
 
56 56
 	/**
@@ -62,9 +62,9 @@  discard block
 block discarded – undo
62 62
 	 */
63 63
 	function readint32array($count) {
64 64
 		$bytes = $this->read(4 * $count);
65
-		if (4*$count != $this->strlen($bytes))
65
+		if (4 * $count != $this->strlen($bytes))
66 66
 			return false;
67
-		$endian_letter = ('big' == $this->endian)? 'N' : 'V';
67
+		$endian_letter = ('big' == $this->endian) ? 'N' : 'V';
68 68
 		return unpack($endian_letter.$count, $bytes);
69 69
 	}
70 70
 
@@ -100,14 +100,14 @@  discard block
 block discarded – undo
100 100
 	 * @return array
101 101
 	 */
102 102
 	function str_split($string, $chunk_size) {
103
-		if (!function_exists('str_split')) {
103
+		if ( ! function_exists('str_split')) {
104 104
 			$length = $this->strlen($string);
105 105
 			$out = array();
106 106
 			for ($i = 0; $i < $length; $i += $chunk_size)
107 107
 				$out[] = $this->substr($string, $i, $chunk_size);
108 108
 			return $out;
109 109
 		} else {
110
-			return str_split( $string, $chunk_size );
110
+			return str_split($string, $chunk_size);
111 111
 		}
112 112
 	}
113 113
 
@@ -134,13 +134,13 @@  discard block
 block discarded – undo
134 134
 }
135 135
 endif;
136 136
 
137
-if ( ! class_exists( 'POMO_FileReader', false ) ):
137
+if ( ! class_exists('POMO_FileReader', false)):
138 138
 class POMO_FileReader extends POMO_Reader {
139 139
 
140 140
 	/**
141 141
 	 * @param string $filename
142 142
 	 */
143
-	function __construct( $filename ) {
143
+	function __construct($filename) {
144 144
 		parent::POMO_Reader();
145 145
 		$this->_f = fopen($filename, 'rb');
146 146
 	}
@@ -148,8 +148,8 @@  discard block
 block discarded – undo
148 148
 	/**
149 149
 	 * PHP4 constructor.
150 150
 	 */
151
-	public function POMO_FileReader( $filename ) {
152
-		self::__construct( $filename );
151
+	public function POMO_FileReader($filename) {
152
+		self::__construct($filename);
153 153
 	}
154 154
 
155 155
 	/**
@@ -197,14 +197,14 @@  discard block
 block discarded – undo
197 197
 	 */
198 198
 	function read_all() {
199 199
 		$all = '';
200
-		while ( !$this->feof() )
200
+		while ( ! $this->feof())
201 201
 			$all .= $this->read(4096);
202 202
 		return $all;
203 203
 	}
204 204
 }
205 205
 endif;
206 206
 
207
-if ( ! class_exists( 'POMO_StringReader', false ) ):
207
+if ( ! class_exists('POMO_StringReader', false)):
208 208
 /**
209 209
  * Provides file-like methods for manipulating a string instead
210 210
  * of a physical file.
@@ -216,7 +216,7 @@  discard block
 block discarded – undo
216 216
 	/**
217 217
 	 * PHP5 constructor.
218 218
 	 */
219
-	function __construct( $str = '' ) {
219
+	function __construct($str = '') {
220 220
 		parent::POMO_Reader();
221 221
 		$this->_str = $str;
222 222
 		$this->_pos = 0;
@@ -225,8 +225,8 @@  discard block
 block discarded – undo
225 225
 	/**
226 226
 	 * PHP4 constructor.
227 227
 	 */
228
-	public function POMO_StringReader( $str = '' ) {
229
-		self::__construct( $str );
228
+	public function POMO_StringReader($str = '') {
229
+		self::__construct($str);
230 230
 	}
231 231
 
232 232
 	/**
@@ -267,7 +267,7 @@  discard block
 block discarded – undo
267 267
 }
268 268
 endif;
269 269
 
270
-if ( ! class_exists( 'POMO_CachedFileReader', false ) ):
270
+if ( ! class_exists('POMO_CachedFileReader', false)):
271 271
 /**
272 272
  * Reads the contents of the file in the beginning.
273 273
  */
@@ -275,7 +275,7 @@  discard block
 block discarded – undo
275 275
 	/**
276 276
 	 * PHP5 constructor.
277 277
 	 */
278
-	function __construct( $filename ) {
278
+	function __construct($filename) {
279 279
 		parent::POMO_StringReader();
280 280
 		$this->_str = file_get_contents($filename);
281 281
 		if (false === $this->_str)
@@ -286,13 +286,13 @@  discard block
 block discarded – undo
286 286
 	/**
287 287
 	 * PHP4 constructor.
288 288
 	 */
289
-	public function POMO_CachedFileReader( $filename ) {
290
-		self::__construct( $filename );
289
+	public function POMO_CachedFileReader($filename) {
290
+		self::__construct($filename);
291 291
 	}
292 292
 }
293 293
 endif;
294 294
 
295
-if ( ! class_exists( 'POMO_CachedIntFileReader', false ) ):
295
+if ( ! class_exists('POMO_CachedIntFileReader', false)):
296 296
 /**
297 297
  * Reads the contents of the file in the beginning.
298 298
  */
@@ -300,15 +300,15 @@  discard block
 block discarded – undo
300 300
 	/**
301 301
 	 * PHP5 constructor.
302 302
 	 */
303
-	public function __construct( $filename ) {
303
+	public function __construct($filename) {
304 304
 		parent::POMO_CachedFileReader($filename);
305 305
 	}
306 306
 
307 307
 	/**
308 308
 	 * PHP4 constructor.
309 309
 	 */
310
-	function POMO_CachedIntFileReader( $filename ) {
311
-		self::__construct( $filename );
310
+	function POMO_CachedIntFileReader($filename) {
311
+		self::__construct($filename);
312 312
 	}
313 313
 }
314 314
 endif;
Please login to merge, or discard this patch.