Completed
Push — master ( fdb3a7...cde0c6 )
by Stephen
20:18
created
src/wp-includes/ms-load.php 1 patch
Spacing   +126 added lines, -126 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;
@@ -129,8 +129,8 @@  discard block
 block discarded – undo
129 129
  * @param int|null $segments Path segments to use. Defaults to null, or the full path.
130 130
  * @return WP_Network|false Network object if successful. False when no network is found.
131 131
  */
132
-function get_network_by_path( $domain, $path, $segments = null ) {
133
-	return WP_Network::get_by_path( $domain, $path, $segments );
132
+function get_network_by_path($domain, $path, $segments = null) {
133
+	return WP_Network::get_by_path($domain, $path, $segments);
134 134
 }
135 135
 
136 136
 /**
@@ -143,9 +143,9 @@  discard block
 block discarded – undo
143 143
  * @param object|int $network The network's database row or ID.
144 144
  * @return WP_Network|false Object containing network information if found, false if not.
145 145
  */
146
-function wp_get_network( $network ) {
147
-	$network = get_network( $network );
148
-	if ( null === $network ) {
146
+function wp_get_network($network) {
147
+	$network = get_network($network);
148
+	if (null === $network) {
149 149
 		return false;
150 150
 	}
151 151
 
@@ -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,18 +239,18 @@  discard block
 block discarded – undo
239 239
 		'number' => 1,
240 240
 	);
241 241
 
242
-	if ( count( $domains ) > 1 ) {
242
+	if (count($domains) > 1) {
243 243
 		$args['orderby']['domain_length'] = 'DESC';
244 244
 	}
245 245
 
246
-	if ( count( $paths ) > 1 ) {
246
+	if (count($paths) > 1) {
247 247
 		$args['orderby']['path_length'] = 'DESC';
248 248
 	}
249 249
 
250
-	$result = get_sites( $args );
251
-	$site = array_shift( $result );
250
+	$result = get_sites($args);
251
+	$site = array_shift($result);
252 252
 
253
-	if ( $site ) {
253
+	if ($site) {
254 254
 		// @todo get_blog_details()
255 255
 		return $site;
256 256
 	}
@@ -289,55 +289,55 @@  discard block
 block discarded – undo
289 289
  *                     False if bootstrap could not be properly completed.
290 290
  *                     Redirect URL if parts exist, but the request as a whole can not be fulfilled.
291 291
  */
292
-function ms_load_current_site_and_network( $domain, $path, $subdomain = false ) {
292
+function ms_load_current_site_and_network($domain, $path, $subdomain = false) {
293 293
 	global $wpdb, $current_site, $current_blog;
294 294
 
295 295
 	// If the network is defined in wp-config.php, we can simply use that.
296
-	if ( defined( 'DOMAIN_CURRENT_SITE' ) && defined( 'PATH_CURRENT_SITE' ) ) {
296
+	if (defined('DOMAIN_CURRENT_SITE') && defined('PATH_CURRENT_SITE')) {
297 297
 		$current_site = new stdClass;
298
-		$current_site->id = defined( 'SITE_ID_CURRENT_SITE' ) ? SITE_ID_CURRENT_SITE : 1;
298
+		$current_site->id = defined('SITE_ID_CURRENT_SITE') ? SITE_ID_CURRENT_SITE : 1;
299 299
 		$current_site->domain = DOMAIN_CURRENT_SITE;
300 300
 		$current_site->path = PATH_CURRENT_SITE;
301
-		if ( defined( 'BLOG_ID_CURRENT_SITE' ) ) {
301
+		if (defined('BLOG_ID_CURRENT_SITE')) {
302 302
 			$current_site->blog_id = BLOG_ID_CURRENT_SITE;
303
-		} elseif ( defined( 'BLOGID_CURRENT_SITE' ) ) { // deprecated.
303
+		} elseif (defined('BLOGID_CURRENT_SITE')) { // deprecated.
304 304
 			$current_site->blog_id = BLOGID_CURRENT_SITE;
305 305
 		}
306 306
 
307
-		if ( 0 === strcasecmp( $current_site->domain, $domain ) && 0 === strcasecmp( $current_site->path, $path ) ) {
308
-			$current_blog = get_site_by_path( $domain, $path );
309
-		} elseif ( '/' !== $current_site->path && 0 === strcasecmp( $current_site->domain, $domain ) && 0 === stripos( $path, $current_site->path ) ) {
307
+		if (0 === strcasecmp($current_site->domain, $domain) && 0 === strcasecmp($current_site->path, $path)) {
308
+			$current_blog = get_site_by_path($domain, $path);
309
+		} elseif ('/' !== $current_site->path && 0 === strcasecmp($current_site->domain, $domain) && 0 === stripos($path, $current_site->path)) {
310 310
 			// If the current network has a path and also matches the domain and path of the request,
311 311
 			// we need to look for a site using the first path segment following the network's path.
312
-			$current_blog = get_site_by_path( $domain, $path, 1 + count( explode( '/', trim( $current_site->path, '/' ) ) ) );
312
+			$current_blog = get_site_by_path($domain, $path, 1 + count(explode('/', trim($current_site->path, '/'))));
313 313
 		} else {
314 314
 			// Otherwise, use the first path segment (as usual).
315
-			$current_blog = get_site_by_path( $domain, $path, 1 );
315
+			$current_blog = get_site_by_path($domain, $path, 1);
316 316
 		}
317 317
 
318
-	} elseif ( ! $subdomain ) {
318
+	} elseif ( ! $subdomain) {
319 319
 		/*
320 320
 		 * A "subdomain" install can be re-interpreted to mean "can support any domain".
321 321
 		 * If we're not dealing with one of these installs, then the important part is determining
322 322
 		 * the network first, because we need the network's path to identify any sites.
323 323
 		 */
324
-		if ( ! $current_site = wp_cache_get( 'current_network', 'site-options' ) ) {
324
+		if ( ! $current_site = wp_cache_get('current_network', 'site-options')) {
325 325
 			// Are there even two networks installed?
326
-			$one_network = $wpdb->get_row( "SELECT * FROM $wpdb->site LIMIT 2" ); // [sic]
327
-			if ( 1 === $wpdb->num_rows ) {
328
-				$current_site = new WP_Network( $one_network );
329
-				wp_cache_add( 'current_network', $current_site, 'site-options' );
330
-			} elseif ( 0 === $wpdb->num_rows ) {
326
+			$one_network = $wpdb->get_row("SELECT * FROM $wpdb->site LIMIT 2"); // [sic]
327
+			if (1 === $wpdb->num_rows) {
328
+				$current_site = new WP_Network($one_network);
329
+				wp_cache_add('current_network', $current_site, 'site-options');
330
+			} elseif (0 === $wpdb->num_rows) {
331 331
 				// A network not found hook should fire here.
332 332
 				return false;
333 333
 			}
334 334
 		}
335 335
 
336
-		if ( empty( $current_site ) ) {
337
-			$current_site = WP_Network::get_by_path( $domain, $path, 1 );
336
+		if (empty($current_site)) {
337
+			$current_site = WP_Network::get_by_path($domain, $path, 1);
338 338
 		}
339 339
 
340
-		if ( empty( $current_site ) ) {
340
+		if (empty($current_site)) {
341 341
 			/**
342 342
 			 * Fires when a network cannot be found based on the requested domain and path.
343 343
 			 *
@@ -349,48 +349,48 @@  discard block
 block discarded – undo
349 349
 			 * @param string $domain       The domain used to search for a network.
350 350
 			 * @param string $path         The path used to search for a path.
351 351
 			 */
352
-			do_action( 'ms_network_not_found', $domain, $path );
352
+			do_action('ms_network_not_found', $domain, $path);
353 353
 
354 354
 			return false;
355
-		} elseif ( $path === $current_site->path ) {
356
-			$current_blog = get_site_by_path( $domain, $path );
355
+		} elseif ($path === $current_site->path) {
356
+			$current_blog = get_site_by_path($domain, $path);
357 357
 		} else {
358 358
 			// Search the network path + one more path segment (on top of the network path).
359
-			$current_blog = get_site_by_path( $domain, $path, substr_count( $current_site->path, '/' ) );
359
+			$current_blog = get_site_by_path($domain, $path, substr_count($current_site->path, '/'));
360 360
 		}
361 361
 	} else {
362 362
 		// Find the site by the domain and at most the first path segment.
363
-		$current_blog = get_site_by_path( $domain, $path, 1 );
364
-		if ( $current_blog ) {
365
-			$current_site = WP_Network::get_instance( $current_blog->site_id ? $current_blog->site_id : 1 );
363
+		$current_blog = get_site_by_path($domain, $path, 1);
364
+		if ($current_blog) {
365
+			$current_site = WP_Network::get_instance($current_blog->site_id ? $current_blog->site_id : 1);
366 366
 		} else {
367 367
 			// If you don't have a site with the same domain/path as a network, you're pretty screwed, but:
368
-			$current_site = WP_Network::get_by_path( $domain, $path, 1 );
368
+			$current_site = WP_Network::get_by_path($domain, $path, 1);
369 369
 		}
370 370
 	}
371 371
 
372 372
 	// The network declared by the site trumps any constants.
373
-	if ( $current_blog && $current_blog->site_id != $current_site->id ) {
374
-		$current_site = WP_Network::get_instance( $current_blog->site_id );
373
+	if ($current_blog && $current_blog->site_id != $current_site->id) {
374
+		$current_site = WP_Network::get_instance($current_blog->site_id);
375 375
 	}
376 376
 
377 377
 	// No network has been found, bail.
378
-	if ( empty( $current_site ) ) {
378
+	if (empty($current_site)) {
379 379
 		/** This action is documented in wp-includes/ms-settings.php */
380
-		do_action( 'ms_network_not_found', $domain, $path );
380
+		do_action('ms_network_not_found', $domain, $path);
381 381
 
382 382
 		return false;
383 383
 	}
384 384
 
385 385
 	// During activation of a new subdomain, the requested site does not yet exist.
386
-	if ( empty( $current_blog ) && wp_installing() ) {
386
+	if (empty($current_blog) && wp_installing()) {
387 387
 		$current_blog = new stdClass;
388 388
 		$current_blog->blog_id = $blog_id = 1;
389 389
 		$current_blog->public = 1;
390 390
 	}
391 391
 
392 392
 	// No site has been found, bail.
393
-	if ( empty( $current_blog ) ) {
393
+	if (empty($current_blog)) {
394 394
 		// We're going to redirect to the network URL, with some possible modifications.
395 395
 		$scheme = is_ssl() ? 'https' : 'http';
396 396
 		$destination = "$scheme://{$current_site->domain}{$current_site->path}";
@@ -407,19 +407,19 @@  discard block
 block discarded – undo
407 407
 		 * @param string $domain       The domain used to search for a site.
408 408
 		 * @param string $path         The path used to search for a site.
409 409
 		 */
410
-		do_action( 'ms_site_not_found', $current_site, $domain, $path );
410
+		do_action('ms_site_not_found', $current_site, $domain, $path);
411 411
 
412
-		if ( $subdomain && ! defined( 'NOBLOGREDIRECT' ) ) {
412
+		if ($subdomain && ! defined('NOBLOGREDIRECT')) {
413 413
 			// For a "subdomain" install, redirect to the signup form specifically.
414
-			$destination .= 'wp-signup.php?new=' . str_replace( '.' . $current_site->domain, '', $domain );
415
-		} elseif ( $subdomain ) {
414
+			$destination .= 'wp-signup.php?new='.str_replace('.'.$current_site->domain, '', $domain);
415
+		} elseif ($subdomain) {
416 416
 			// For a "subdomain" install, the NOBLOGREDIRECT constant
417 417
 			// can be used to avoid a redirect to the signup form.
418 418
 			// Using the ms_site_not_found action is preferred to the constant.
419
-			if ( '%siteurl%' !== NOBLOGREDIRECT ) {
419
+			if ('%siteurl%' !== NOBLOGREDIRECT) {
420 420
 				$destination = NOBLOGREDIRECT;
421 421
 			}
422
-		} elseif ( 0 === strcasecmp( $current_site->domain, $domain ) ) {
422
+		} elseif (0 === strcasecmp($current_site->domain, $domain)) {
423 423
 			/*
424 424
 			 * If the domain we were searching for matches the network's domain,
425 425
 			 * it's no use redirecting back to ourselves -- it'll cause a loop.
@@ -432,13 +432,13 @@  discard block
 block discarded – undo
432 432
 	}
433 433
 
434 434
 	// Figure out the current network's main site.
435
-	if ( empty( $current_site->blog_id ) ) {
436
-		if ( $current_blog->domain === $current_site->domain && $current_blog->path === $current_site->path ) {
435
+	if (empty($current_site->blog_id)) {
436
+		if ($current_blog->domain === $current_site->domain && $current_blog->path === $current_site->path) {
437 437
 			$current_site->blog_id = $current_blog->blog_id;
438
-		} elseif ( ! $current_site->blog_id = wp_cache_get( 'network:' . $current_site->id . ':main_site', 'site-options' ) ) {
439
-			$current_site->blog_id = $wpdb->get_var( $wpdb->prepare( "SELECT blog_id FROM $wpdb->blogs WHERE domain = %s AND path = %s",
440
-				$current_site->domain, $current_site->path ) );
441
-			wp_cache_add( 'network:' . $current_site->id . ':main_site', $current_site->blog_id, 'site-options' );
438
+		} elseif ( ! $current_site->blog_id = wp_cache_get('network:'.$current_site->id.':main_site', 'site-options')) {
439
+			$current_site->blog_id = $wpdb->get_var($wpdb->prepare("SELECT blog_id FROM $wpdb->blogs WHERE domain = %s AND path = %s",
440
+				$current_site->domain, $current_site->path));
441
+			wp_cache_add('network:'.$current_site->id.':main_site', $current_site->blog_id, 'site-options');
442 442
 		}
443 443
 	}
444 444
 
@@ -459,50 +459,50 @@  discard block
 block discarded – undo
459 459
  * @param string $domain The requested domain for the error to reference.
460 460
  * @param string $path   The requested path for the error to reference.
461 461
  */
462
-function ms_not_installed( $domain, $path ) {
462
+function ms_not_installed($domain, $path) {
463 463
 	global $wpdb;
464 464
 
465
-	if ( ! is_admin() ) {
465
+	if ( ! is_admin()) {
466 466
 		dead_db();
467 467
 	}
468 468
 
469 469
 	wp_load_translations_early();
470 470
 
471
-	$title = __( 'Error establishing a database connection' );
471
+	$title = __('Error establishing a database connection');
472 472
 
473
-	$msg  = '<h1>' . $title . '</h1>';
474
-	$msg .= '<p>' . __( 'If your site does not display, please contact the owner of this network.' ) . '';
475
-	$msg .= ' ' . __( 'If you are the owner of this network please check that MySQL is running properly and all tables are error free.' ) . '</p>';
476
-	$query = $wpdb->prepare( "SHOW TABLES LIKE %s", $wpdb->esc_like( $wpdb->site ) );
477
-	if ( ! $wpdb->get_var( $query ) ) {
478
-		$msg .= '<p>' . sprintf(
473
+	$msg  = '<h1>'.$title.'</h1>';
474
+	$msg .= '<p>'.__('If your site does not display, please contact the owner of this network.').'';
475
+	$msg .= ' '.__('If you are the owner of this network please check that MySQL is running properly and all tables are error free.').'</p>';
476
+	$query = $wpdb->prepare("SHOW TABLES LIKE %s", $wpdb->esc_like($wpdb->site));
477
+	if ( ! $wpdb->get_var($query)) {
478
+		$msg .= '<p>'.sprintf(
479 479
 			/* translators: %s: table name */
480
-			__( '<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.' ),
481
-			'<code>' . $wpdb->site . '</code>'
482
-		) . '</p>';
480
+			__('<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.'),
481
+			'<code>'.$wpdb->site.'</code>'
482
+		).'</p>';
483 483
 	} else {
484
-		$msg .= '<p>' . sprintf(
484
+		$msg .= '<p>'.sprintf(
485 485
 			/* translators: 1: site url, 2: table name, 3: database name */
486
-			__( '<strong>Could not find site %1$s.</strong> Searched for table %2$s in database %3$s. Is that right?' ),
487
-			'<code>' . rtrim( $domain . $path, '/' ) . '</code>',
488
-			'<code>' . $wpdb->blogs . '</code>',
489
-			'<code>' . DB_NAME . '</code>'
490
-		) . '</p>';
486
+			__('<strong>Could not find site %1$s.</strong> Searched for table %2$s in database %3$s. Is that right?'),
487
+			'<code>'.rtrim($domain.$path, '/').'</code>',
488
+			'<code>'.$wpdb->blogs.'</code>',
489
+			'<code>'.DB_NAME.'</code>'
490
+		).'</p>';
491 491
 	}
492
-	$msg .= '<p><strong>' . __( 'What do I do now?' ) . '</strong> ';
492
+	$msg .= '<p><strong>'.__('What do I do now?').'</strong> ';
493 493
 	/* translators: %s: Codex URL */
494
-	$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.' ),
495
-		__( 'https://codex.wordpress.org/Debugging_a_WordPress_Network' )
494
+	$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.'),
495
+		__('https://codex.wordpress.org/Debugging_a_WordPress_Network')
496 496
 	);
497
-	$msg .= ' ' . __( 'If you&#8217;re still stuck with this message, then check that your database contains the following tables:' ) . '</p><ul>';
498
-	foreach ( $wpdb->tables('global') as $t => $table ) {
499
-		if ( 'sitecategories' == $t )
497
+	$msg .= ' '.__('If you&#8217;re still stuck with this message, then check that your database contains the following tables:').'</p><ul>';
498
+	foreach ($wpdb->tables('global') as $t => $table) {
499
+		if ('sitecategories' == $t)
500 500
 			continue;
501
-		$msg .= '<li>' . $table . '</li>';
501
+		$msg .= '<li>'.$table.'</li>';
502 502
 	}
503 503
 	$msg .= '</ul>';
504 504
 
505
-	wp_die( $msg, $title, array( 'response' => 500 ) );
505
+	wp_die($msg, $title, array('response' => 500));
506 506
 }
507 507
 
508 508
 /**
@@ -518,8 +518,8 @@  discard block
 block discarded – undo
518 518
  * @param object $current_site
519 519
  * @return object
520 520
  */
521
-function get_current_site_name( $current_site ) {
522
-	_deprecated_function( __FUNCTION__, '3.9.0', 'get_current_site()' );
521
+function get_current_site_name($current_site) {
522
+	_deprecated_function(__FUNCTION__, '3.9.0', 'get_current_site()');
523 523
 	return $current_site;
524 524
 }
525 525
 
@@ -539,6 +539,6 @@  discard block
 block discarded – undo
539 539
  */
540 540
 function wpmu_current_site() {
541 541
 	global $current_site;
542
-	_deprecated_function( __FUNCTION__, '3.9.0' );
542
+	_deprecated_function(__FUNCTION__, '3.9.0');
543 543
 	return $current_site;
544 544
 }
Please login to merge, or discard this patch.
src/wp-includes/ms-default-constants.php 1 patch
Spacing   +38 added lines, -38 removed lines patch added patch discarded remove patch
@@ -21,23 +21,23 @@  discard block
 block discarded – undo
21 21
 	global $wpdb;
22 22
 
23 23
 	// This filter is attached in ms-default-filters.php but that file is not included during SHORTINIT.
24
-	add_filter( 'default_site_option_ms_files_rewriting', '__return_true' );
24
+	add_filter('default_site_option_ms_files_rewriting', '__return_true');
25 25
 
26
-	if ( ! get_site_option( 'ms_files_rewriting' ) )
26
+	if ( ! get_site_option('ms_files_rewriting'))
27 27
 		return;
28 28
 
29 29
 	// Base uploads dir relative to ABSPATH
30
-	if ( !defined( 'UPLOADBLOGSDIR' ) )
31
-		define( 'UPLOADBLOGSDIR', 'wp-content/blogs.dir' );
30
+	if ( ! defined('UPLOADBLOGSDIR'))
31
+		define('UPLOADBLOGSDIR', 'wp-content/blogs.dir');
32 32
 
33 33
 	// Note, the main site in a post-MU network uses wp-content/uploads.
34 34
 	// This is handled in wp_upload_dir() by ignoring UPLOADS for this case.
35
-	if ( ! defined( 'UPLOADS' ) ) {
36
-		define( 'UPLOADS', UPLOADBLOGSDIR . "/{$wpdb->blogid}/files/" );
35
+	if ( ! defined('UPLOADS')) {
36
+		define('UPLOADS', UPLOADBLOGSDIR."/{$wpdb->blogid}/files/");
37 37
 
38 38
 		// Uploads dir relative to ABSPATH
39
-		if ( 'wp-content/blogs.dir' == UPLOADBLOGSDIR && ! defined( 'BLOGUPLOADDIR' ) )
40
-			define( 'BLOGUPLOADDIR', WP_CONTENT_DIR . "/blogs.dir/{$wpdb->blogid}/files/" );
39
+		if ('wp-content/blogs.dir' == UPLOADBLOGSDIR && ! defined('BLOGUPLOADDIR'))
40
+			define('BLOGUPLOADDIR', WP_CONTENT_DIR."/blogs.dir/{$wpdb->blogid}/files/");
41 41
 	}
42 42
 }
43 43
 
@@ -52,34 +52,34 @@  discard block
 block discarded – undo
52 52
 	/**
53 53
 	 * @since 1.2.0
54 54
 	 */
55
-	if ( !defined( 'COOKIEPATH' ) )
56
-		define( 'COOKIEPATH', $current_site->path );
55
+	if ( ! defined('COOKIEPATH'))
56
+		define('COOKIEPATH', $current_site->path);
57 57
 
58 58
 	/**
59 59
 	 * @since 1.5.0
60 60
 	 */
61
-	if ( !defined( 'SITECOOKIEPATH' ) )
62
-		define( 'SITECOOKIEPATH', $current_site->path );
61
+	if ( ! defined('SITECOOKIEPATH'))
62
+		define('SITECOOKIEPATH', $current_site->path);
63 63
 
64 64
 	/**
65 65
 	 * @since 2.6.0
66 66
 	 */
67
-	if ( !defined( 'ADMIN_COOKIE_PATH' ) ) {
68
-		if ( ! is_subdomain_install() || trim( parse_url( get_option( 'siteurl' ), PHP_URL_PATH ), '/' ) ) {
69
-			define( 'ADMIN_COOKIE_PATH', SITECOOKIEPATH );
67
+	if ( ! defined('ADMIN_COOKIE_PATH')) {
68
+		if ( ! is_subdomain_install() || trim(parse_url(get_option('siteurl'), PHP_URL_PATH), '/')) {
69
+			define('ADMIN_COOKIE_PATH', SITECOOKIEPATH);
70 70
 		} else {
71
-			define( 'ADMIN_COOKIE_PATH', SITECOOKIEPATH . 'wp-admin' );
71
+			define('ADMIN_COOKIE_PATH', SITECOOKIEPATH.'wp-admin');
72 72
 		}
73 73
 	}
74 74
 
75 75
 	/**
76 76
 	 * @since 2.0.0
77 77
 	 */
78
-	if ( !defined('COOKIE_DOMAIN') && is_subdomain_install() ) {
79
-		if ( !empty( $current_site->cookie_domain ) )
80
-			define('COOKIE_DOMAIN', '.' . $current_site->cookie_domain);
78
+	if ( ! defined('COOKIE_DOMAIN') && is_subdomain_install()) {
79
+		if ( ! empty($current_site->cookie_domain))
80
+			define('COOKIE_DOMAIN', '.'.$current_site->cookie_domain);
81 81
 		else
82
-			define('COOKIE_DOMAIN', '.' . $current_site->domain);
82
+			define('COOKIE_DOMAIN', '.'.$current_site->domain);
83 83
 	}
84 84
 }
85 85
 
@@ -96,15 +96,15 @@  discard block
 block discarded – undo
96 96
 	 * Optional support for X-Sendfile header
97 97
 	 * @since 3.0.0
98 98
 	 */
99
-	if ( !defined( 'WPMU_SENDFILE' ) )
100
-		define( 'WPMU_SENDFILE', false );
99
+	if ( ! defined('WPMU_SENDFILE'))
100
+		define('WPMU_SENDFILE', false);
101 101
 
102 102
 	/**
103 103
 	 * Optional support for X-Accel-Redirect header
104 104
 	 * @since 3.0.0
105 105
 	 */
106
-	if ( !defined( 'WPMU_ACCEL_REDIRECT' ) )
107
-		define( 'WPMU_ACCEL_REDIRECT', false );
106
+	if ( ! defined('WPMU_ACCEL_REDIRECT'))
107
+		define('WPMU_ACCEL_REDIRECT', false);
108 108
 }
109 109
 
110 110
 /**
@@ -124,41 +124,41 @@  discard block
 block discarded – undo
124 124
 	static $subdomain_error = null;
125 125
 	static $subdomain_error_warn = null;
126 126
 
127
-	if ( false === $subdomain_error ) {
127
+	if (false === $subdomain_error) {
128 128
 		return;
129 129
 	}
130 130
 
131
-	if ( $subdomain_error ) {
131
+	if ($subdomain_error) {
132 132
 		$vhost_deprecated = sprintf(
133 133
 			/* translators: 1: VHOST, 2: SUBDOMAIN_INSTALL, 3: wp-config.php, 4: is_subdomain_install() */
134
-			__( 'The constant %1$s <strong>is deprecated</strong>. Use the boolean constant %2$s in %3$s to enable a subdomain configuration. Use %4$s to check whether a subdomain configuration is enabled.' ),
134
+			__('The constant %1$s <strong>is deprecated</strong>. Use the boolean constant %2$s in %3$s to enable a subdomain configuration. Use %4$s to check whether a subdomain configuration is enabled.'),
135 135
 			'<code>VHOST</code>',
136 136
 			'<code>SUBDOMAIN_INSTALL</code>',
137 137
 			'<code>wp-config.php</code>',
138 138
 			'<code>is_subdomain_install()</code>'
139 139
 		);
140
-		if ( $subdomain_error_warn ) {
141
-			trigger_error( __( '<strong>Conflicting values for the constants VHOST and SUBDOMAIN_INSTALL.</strong> The value of SUBDOMAIN_INSTALL will be assumed to be your subdomain configuration setting.' ) . ' ' . $vhost_deprecated, E_USER_WARNING );
140
+		if ($subdomain_error_warn) {
141
+			trigger_error(__('<strong>Conflicting values for the constants VHOST and SUBDOMAIN_INSTALL.</strong> The value of SUBDOMAIN_INSTALL will be assumed to be your subdomain configuration setting.').' '.$vhost_deprecated, E_USER_WARNING);
142 142
 		} else {
143
-	 		_deprecated_argument( 'define()', '3.0.0', $vhost_deprecated );
143
+	 		_deprecated_argument('define()', '3.0.0', $vhost_deprecated);
144 144
 		}
145 145
 		return;
146 146
 	}
147 147
 
148
-	if ( defined( 'SUBDOMAIN_INSTALL' ) && defined( 'VHOST' ) ) {
148
+	if (defined('SUBDOMAIN_INSTALL') && defined('VHOST')) {
149 149
 		$subdomain_error = true;
150
-		if ( SUBDOMAIN_INSTALL !== ( 'yes' == VHOST ) ) {
150
+		if (SUBDOMAIN_INSTALL !== ('yes' == VHOST)) {
151 151
 			$subdomain_error_warn = true;
152 152
 		}
153
-	} elseif ( defined( 'SUBDOMAIN_INSTALL' ) ) {
153
+	} elseif (defined('SUBDOMAIN_INSTALL')) {
154 154
 		$subdomain_error = false;
155
-		define( 'VHOST', SUBDOMAIN_INSTALL ? 'yes' : 'no' );
156
-	} elseif ( defined( 'VHOST' ) ) {
155
+		define('VHOST', SUBDOMAIN_INSTALL ? 'yes' : 'no');
156
+	} elseif (defined('VHOST')) {
157 157
 		$subdomain_error = true;
158
-		define( 'SUBDOMAIN_INSTALL', 'yes' == VHOST );
158
+		define('SUBDOMAIN_INSTALL', 'yes' == VHOST);
159 159
 	} else {
160 160
 		$subdomain_error = false;
161
-		define( 'SUBDOMAIN_INSTALL', false );
162
-		define( 'VHOST', 'no' );
161
+		define('SUBDOMAIN_INSTALL', false);
162
+		define('VHOST', 'no');
163 163
 	}
164 164
 }
Please login to merge, or discard this patch.
src/wp-includes/Requests/Transport/cURL.php 1 patch
Spacing   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -227,7 +227,7 @@  discard block
 block discarded – undo
227 227
 			// Read the information as needed
228 228
 			while ($done = curl_multi_info_read($multihandle)) {
229 229
 				$key = array_search($done['handle'], $subhandles, true);
230
-				if (!isset($to_process[$key])) {
230
+				if ( ! isset($to_process[$key])) {
231 231
 					$to_process[$key] = $done;
232 232
 				}
233 233
 			}
@@ -256,7 +256,7 @@  discard block
 block discarded – undo
256 256
 				curl_multi_remove_handle($multihandle, $done['handle']);
257 257
 				curl_close($done['handle']);
258 258
 
259
-				if (!is_string($responses[$key])) {
259
+				if ( ! is_string($responses[$key])) {
260 260
 					$options['hooks']->dispatch('multiple.request.complete', array(&$responses[$key], $key));
261 261
 				}
262 262
 				$completed++;
@@ -310,20 +310,20 @@  discard block
 block discarded – undo
310 310
 		$options['hooks']->dispatch('curl.before_request', array(&$this->handle));
311 311
 
312 312
 		// Force closing the connection for old versions of cURL (<7.22).
313
-		if ( ! isset( $headers['Connection'] ) ) {
313
+		if ( ! isset($headers['Connection'])) {
314 314
 			$headers['Connection'] = 'close';
315 315
 		}
316 316
 
317 317
 		$headers = Requests::flatten($headers);
318 318
 
319
-		if (!empty($data)) {
319
+		if ( ! empty($data)) {
320 320
 			$data_format = $options['data_format'];
321 321
 
322 322
 			if ($data_format === 'query') {
323 323
 				$url = self::format_get($url, $data);
324 324
 				$data = '';
325 325
 			}
326
-			elseif (!is_string($data)) {
326
+			elseif ( ! is_string($data)) {
327 327
 				$data = http_build_query($data, null, '&');
328 328
 			}
329 329
 		}
@@ -346,8 +346,8 @@  discard block
 block discarded – undo
346 346
 			case Requests::OPTIONS:
347 347
 			default:
348 348
 				curl_setopt($this->handle, CURLOPT_CUSTOMREQUEST, $options['type']);
349
-				if (!empty($data)) {
350
-					curl_setopt( $this->handle, CURLOPT_POSTFIELDS, $data );
349
+				if ( ! empty($data)) {
350
+					curl_setopt($this->handle, CURLOPT_POSTFIELDS, $data);
351 351
 				}
352 352
 		}
353 353
 
@@ -495,7 +495,7 @@  discard block
 block discarded – undo
495 495
 	 * @return string URL with data
496 496
 	 */
497 497
 	protected static function format_get($url, $data) {
498
-		if (!empty($data)) {
498
+		if ( ! empty($data)) {
499 499
 			$url_parts = parse_url($url);
500 500
 			if (empty($url_parts['query'])) {
501 501
 				$query = $url_parts['query'] = '';
@@ -504,11 +504,11 @@  discard block
 block discarded – undo
504 504
 				$query = $url_parts['query'];
505 505
 			}
506 506
 
507
-			$query .= '&' . http_build_query($data, null, '&');
507
+			$query .= '&'.http_build_query($data, null, '&');
508 508
 			$query = trim($query, '&');
509 509
 
510 510
 			if (empty($url_parts['query'])) {
511
-				$url .= '?' . $query;
511
+				$url .= '?'.$query;
512 512
 			}
513 513
 			else {
514 514
 				$url = str_replace($url_parts['query'], $query, $url);
@@ -524,14 +524,14 @@  discard block
 block discarded – undo
524 524
 	 * @return boolean True if the transport is valid, false otherwise.
525 525
 	 */
526 526
 	public static function test($capabilities = array()) {
527
-		if (!function_exists('curl_init') && !function_exists('curl_exec')) {
527
+		if ( ! function_exists('curl_init') && ! function_exists('curl_exec')) {
528 528
 			return false;
529 529
 		}
530 530
 
531 531
 		// If needed, check that our installed curl version supports SSL
532 532
 		if (isset($capabilities['ssl']) && $capabilities['ssl']) {
533 533
 			$curl_version = curl_version();
534
-			if (!(CURL_VERSION_SSL & $curl_version['features'])) {
534
+			if ( ! (CURL_VERSION_SSL & $curl_version['features'])) {
535 535
 				return false;
536 536
 			}
537 537
 		}
Please login to merge, or discard this patch.
src/wp-includes/class-wp-network-query.php 2 patches
Indentation   +21 added lines, -21 removed lines patch added patch discarded remove patch
@@ -99,27 +99,27 @@
 block discarded – undo
99 99
 	 *
100 100
 	 *     @type array        $network__in          Array of network IDs to include. Default empty.
101 101
 	 *     @type array        $network__not_in      Array of network IDs to exclude. Default empty.
102
- 	 *     @type bool         $count                Whether to return a network count (true) or array of network objects.
103
- 	 *                                              Default false.
104
- 	 *     @type string       $fields               Network fields to return. Accepts 'ids' (returns an array of network IDs)
105
- 	 *                                              or empty (returns an array of complete network objects). Default empty.
106
- 	 *     @type int          $number               Maximum number of networks to retrieve. Default null (no limit).
107
- 	 *     @type int          $offset               Number of networks to offset the query. Used to build LIMIT clause.
108
- 	 *                                              Default 0.
109
- 	 *     @type bool         $no_found_rows        Whether to disable the `SQL_CALC_FOUND_ROWS` query. Default true.
110
- 	 *     @type string|array $orderby              Network status or array of statuses. Accepts 'id', 'domain', 'path',
111
- 	 *                                              'domain_length', 'path_length' and 'network__in'. Also accepts false,
112
- 	 *                                              an empty array, or 'none' to disable `ORDER BY` clause. Default 'id'.
113
- 	 *     @type string       $order                How to order retrieved networks. Accepts 'ASC', 'DESC'. Default 'ASC'.
114
- 	 *     @type string       $domain               Limit results to those affiliated with a given network ID.
115
- 	 *                                              Default current network ID.
116
- 	 *     @type array        $domain__in           Array of domains to include affiliated networks for. Default empty.
117
- 	 *     @type array        $domain__not_in       Array of domains to exclude affiliated networks for. Default empty.
118
- 	 *     @type string       $path                 Limit results to those affiliated with a given network ID.
119
- 	 *                                              Default current network ID.
120
- 	 *     @type array        $path__in             Array of paths to include affiliated networks for. Default empty.
121
- 	 *     @type array        $path__not_in         Array of paths to exclude affiliated networks for. Default empty.
122
- 	 *     @type string       $search               Search term(s) to retrieve matching networks for. Default empty.
102
+	 *     @type bool         $count                Whether to return a network count (true) or array of network objects.
103
+	 *                                              Default false.
104
+	 *     @type string       $fields               Network fields to return. Accepts 'ids' (returns an array of network IDs)
105
+	 *                                              or empty (returns an array of complete network objects). Default empty.
106
+	 *     @type int          $number               Maximum number of networks to retrieve. Default null (no limit).
107
+	 *     @type int          $offset               Number of networks to offset the query. Used to build LIMIT clause.
108
+	 *                                              Default 0.
109
+	 *     @type bool         $no_found_rows        Whether to disable the `SQL_CALC_FOUND_ROWS` query. Default true.
110
+	 *     @type string|array $orderby              Network status or array of statuses. Accepts 'id', 'domain', 'path',
111
+	 *                                              'domain_length', 'path_length' and 'network__in'. Also accepts false,
112
+	 *                                              an empty array, or 'none' to disable `ORDER BY` clause. Default 'id'.
113
+	 *     @type string       $order                How to order retrieved networks. Accepts 'ASC', 'DESC'. Default 'ASC'.
114
+	 *     @type string       $domain               Limit results to those affiliated with a given network ID.
115
+	 *                                              Default current network ID.
116
+	 *     @type array        $domain__in           Array of domains to include affiliated networks for. Default empty.
117
+	 *     @type array        $domain__not_in       Array of domains to exclude affiliated networks for. Default empty.
118
+	 *     @type string       $path                 Limit results to those affiliated with a given network ID.
119
+	 *                                              Default current network ID.
120
+	 *     @type array        $path__in             Array of paths to include affiliated networks for. Default empty.
121
+	 *     @type array        $path__not_in         Array of paths to exclude affiliated networks for. Default empty.
122
+	 *     @type string       $search               Search term(s) to retrieve matching networks for. Default empty.
123 123
 	 *     @type bool         $update_network_cache Whether to prime the cache for found networks. Default true.
124 124
 	 * }
125 125
 	 */
Please login to merge, or discard this patch.
Spacing   +104 added lines, -105 removed lines patch added patch discarded remove patch
@@ -123,7 +123,7 @@  discard block
 block discarded – undo
123 123
 	 *     @type bool         $update_network_cache Whether to prime the cache for found networks. Default true.
124 124
 	 * }
125 125
 	 */
126
-	public function __construct( $query = '' ) {
126
+	public function __construct($query = '') {
127 127
 		$this->query_var_defaults = array(
128 128
 			'network__in'          => '',
129 129
 			'network__not_in'      => '',
@@ -144,8 +144,8 @@  discard block
 block discarded – undo
144 144
 			'update_network_cache' => true,
145 145
 		);
146 146
 
147
-		if ( ! empty( $query ) ) {
148
-			$this->query( $query );
147
+		if ( ! empty($query)) {
148
+			$this->query($query);
149 149
 		}
150 150
 	}
151 151
 
@@ -158,12 +158,12 @@  discard block
 block discarded – undo
158 158
 	 *
159 159
 	 * @param string|array $query WP_Network_Query arguments. See WP_Network_Query::__construct()
160 160
 	 */
161
-	public function parse_query( $query = '' ) {
162
-		if ( empty( $query ) ) {
161
+	public function parse_query($query = '') {
162
+		if (empty($query)) {
163 163
 			$query = $this->query_vars;
164 164
 		}
165 165
 
166
-		$this->query_vars = wp_parse_args( $query, $this->query_var_defaults );
166
+		$this->query_vars = wp_parse_args($query, $this->query_var_defaults);
167 167
 
168 168
 		/**
169 169
 		 * Fires after the network query vars have been parsed.
@@ -172,7 +172,7 @@  discard block
 block discarded – undo
172 172
 		 *
173 173
 		 * @param WP_Network_Query &$this The WP_Network_Query instance (passed by reference).
174 174
 		 */
175
-		do_action_ref_array( 'parse_network_query', array( &$this ) );
175
+		do_action_ref_array('parse_network_query', array(&$this));
176 176
 	}
177 177
 
178 178
 	/**
@@ -184,8 +184,8 @@  discard block
 block discarded – undo
184 184
 	 * @param string|array $query Array or URL query string of parameters.
185 185
 	 * @return array|int List of networks, or number of networks when 'count' is passed as a query var.
186 186
 	 */
187
-	public function query( $query ) {
188
-		$this->query_vars = wp_parse_args( $query );
187
+	public function query($query) {
188
+		$this->query_vars = wp_parse_args($query);
189 189
 		return $this->get_networks();
190 190
 	}
191 191
 
@@ -207,22 +207,22 @@  discard block
 block discarded – undo
207 207
 		 *
208 208
 		 * @param WP_Network_Query &$this Current instance of WP_Network_Query, passed by reference.
209 209
 		 */
210
-		do_action_ref_array( 'pre_get_networks', array( &$this ) );
210
+		do_action_ref_array('pre_get_networks', array(&$this));
211 211
 
212 212
 		// $args can include anything. Only use the args defined in the query_var_defaults to compute the key.
213
-		$key = md5( serialize( wp_array_slice_assoc( $this->query_vars, array_keys( $this->query_var_defaults ) ) ) );
214
-		$last_changed = wp_cache_get( 'last_changed', 'networks' );
215
-		if ( ! $last_changed ) {
213
+		$key = md5(serialize(wp_array_slice_assoc($this->query_vars, array_keys($this->query_var_defaults))));
214
+		$last_changed = wp_cache_get('last_changed', 'networks');
215
+		if ( ! $last_changed) {
216 216
 			$last_changed = microtime();
217
-			wp_cache_set( 'last_changed', $last_changed, 'networks' );
217
+			wp_cache_set('last_changed', $last_changed, 'networks');
218 218
 		}
219 219
 
220 220
 		$cache_key = "get_network_ids:$key:$last_changed";
221
-		$cache_value = wp_cache_get( $cache_key, 'networks' );
221
+		$cache_value = wp_cache_get($cache_key, 'networks');
222 222
 
223
-		if ( false === $cache_value ) {
223
+		if (false === $cache_value) {
224 224
 			$network_ids = $this->get_network_ids();
225
-			if ( $network_ids ) {
225
+			if ($network_ids) {
226 226
 				$this->set_found_networks();
227 227
 			}
228 228
 
@@ -230,37 +230,37 @@  discard block
 block discarded – undo
230 230
 				'network_ids' => $network_ids,
231 231
 				'found_networks' => $this->found_networks,
232 232
 			);
233
-			wp_cache_add( $cache_key, $cache_value, 'networks' );
233
+			wp_cache_add($cache_key, $cache_value, 'networks');
234 234
 		} else {
235 235
 			$network_ids = $cache_value['network_ids'];
236 236
 			$this->found_networks = $cache_value['found_networks'];
237 237
 		}
238 238
 
239
-		if ( $this->found_networks && $this->query_vars['number'] ) {
240
-			$this->max_num_pages = ceil( $this->found_networks / $this->query_vars['number'] );
239
+		if ($this->found_networks && $this->query_vars['number']) {
240
+			$this->max_num_pages = ceil($this->found_networks / $this->query_vars['number']);
241 241
 		}
242 242
 
243 243
 		// If querying for a count only, there's nothing more to do.
244
-		if ( $this->query_vars['count'] ) {
244
+		if ($this->query_vars['count']) {
245 245
 			// $network_ids is actually a count in this case.
246
-			return intval( $network_ids );
246
+			return intval($network_ids);
247 247
 		}
248 248
 
249
-		$network_ids = array_map( 'intval', $network_ids );
249
+		$network_ids = array_map('intval', $network_ids);
250 250
 
251
-		if ( 'ids' == $this->query_vars['fields'] ) {
251
+		if ('ids' == $this->query_vars['fields']) {
252 252
 			$this->networks = $network_ids;
253 253
 			return $this->networks;
254 254
 		}
255 255
 
256
-		if ( $this->query_vars['update_network_cache'] ) {
257
-			_prime_network_caches( $network_ids );
256
+		if ($this->query_vars['update_network_cache']) {
257
+			_prime_network_caches($network_ids);
258 258
 		}
259 259
 
260 260
 		// Fetch full network objects from the primed cache.
261 261
 		$_networks = array();
262
-		foreach ( $network_ids as $network_id ) {
263
-			if ( $_network = get_network( $network_id ) ) {
262
+		foreach ($network_ids as $network_id) {
263
+			if ($_network = get_network($network_id)) {
264 264
 				$_networks[] = $_network;
265 265
 			}
266 266
 		}
@@ -273,10 +273,10 @@  discard block
 block discarded – undo
273 273
 		 * @param array            $results  An array of networks.
274 274
 		 * @param WP_Network_Query &$this    Current instance of WP_Network_Query, passed by reference.
275 275
 		 */
276
-		$_networks = apply_filters_ref_array( 'the_networks', array( $_networks, &$this ) );
276
+		$_networks = apply_filters_ref_array('the_networks', array($_networks, &$this));
277 277
 
278 278
 		// Convert to WP_Network instances
279
-		$this->networks = array_map( 'get_network', $_networks );
279
+		$this->networks = array_map('get_network', $_networks);
280 280
 
281 281
 		return $this->networks;
282 282
 	}
@@ -292,23 +292,22 @@  discard block
 block discarded – undo
292 292
 	protected function get_network_ids() {
293 293
 		global $wpdb;
294 294
 
295
-		$order = $this->parse_order( $this->query_vars['order'] );
295
+		$order = $this->parse_order($this->query_vars['order']);
296 296
 
297 297
 		// Disable ORDER BY with 'none', an empty array, or boolean false.
298
-		if ( in_array( $this->query_vars['orderby'], array( 'none', array(), false ), true ) ) {
298
+		if (in_array($this->query_vars['orderby'], array('none', array(), false), true)) {
299 299
 			$orderby = '';
300
-		} elseif ( ! empty( $this->query_vars['orderby'] ) ) {
301
-			$ordersby = is_array( $this->query_vars['orderby'] ) ?
302
-				$this->query_vars['orderby'] :
303
-				preg_split( '/[,\s]/', $this->query_vars['orderby'] );
300
+		} elseif ( ! empty($this->query_vars['orderby'])) {
301
+			$ordersby = is_array($this->query_vars['orderby']) ?
302
+				$this->query_vars['orderby'] : preg_split('/[,\s]/', $this->query_vars['orderby']);
304 303
 
305 304
 			$orderby_array = array();
306
-			foreach ( $ordersby as $_key => $_value ) {
307
-				if ( ! $_value ) {
305
+			foreach ($ordersby as $_key => $_value) {
306
+				if ( ! $_value) {
308 307
 					continue;
309 308
 				}
310 309
 
311
-				if ( is_int( $_key ) ) {
310
+				if (is_int($_key)) {
312 311
 					$_orderby = $_value;
313 312
 					$_order = $order;
314 313
 				} else {
@@ -316,93 +315,93 @@  discard block
 block discarded – undo
316 315
 					$_order = $_value;
317 316
 				}
318 317
 
319
-				$parsed = $this->parse_orderby( $_orderby );
318
+				$parsed = $this->parse_orderby($_orderby);
320 319
 
321
-				if ( ! $parsed ) {
320
+				if ( ! $parsed) {
322 321
 					continue;
323 322
 				}
324 323
 
325
-				if ( 'network__in' === $_orderby ) {
324
+				if ('network__in' === $_orderby) {
326 325
 					$orderby_array[] = $parsed;
327 326
 					continue;
328 327
 				}
329 328
 
330
-				$orderby_array[] = $parsed . ' ' . $this->parse_order( $_order );
329
+				$orderby_array[] = $parsed.' '.$this->parse_order($_order);
331 330
 			}
332 331
 
333
-			$orderby = implode( ', ', $orderby_array );
332
+			$orderby = implode(', ', $orderby_array);
334 333
 		} else {
335 334
 			$orderby = "$wpdb->site.id $order";
336 335
 		}
337 336
 
338
-		$number = absint( $this->query_vars['number'] );
339
-		$offset = absint( $this->query_vars['offset'] );
337
+		$number = absint($this->query_vars['number']);
338
+		$offset = absint($this->query_vars['offset']);
340 339
 
341
-		if ( ! empty( $number ) ) {
342
-			if ( $offset ) {
343
-				$limits = 'LIMIT ' . $offset . ',' . $number;
340
+		if ( ! empty($number)) {
341
+			if ($offset) {
342
+				$limits = 'LIMIT '.$offset.','.$number;
344 343
 			} else {
345
-				$limits = 'LIMIT ' . $number;
344
+				$limits = 'LIMIT '.$number;
346 345
 			}
347 346
 		}
348 347
 
349
-		if ( $this->query_vars['count'] ) {
348
+		if ($this->query_vars['count']) {
350 349
 			$fields = 'COUNT(*)';
351 350
 		} else {
352 351
 			$fields = "$wpdb->site.id";
353 352
 		}
354 353
 
355 354
 		// Parse network IDs for an IN clause.
356
-		if ( ! empty( $this->query_vars['network__in'] ) ) {
357
-			$this->sql_clauses['where']['network__in'] = "$wpdb->site.id IN ( " . implode( ',', wp_parse_id_list( $this->query_vars['network__in'] ) ) . ' )';
355
+		if ( ! empty($this->query_vars['network__in'])) {
356
+			$this->sql_clauses['where']['network__in'] = "$wpdb->site.id IN ( ".implode(',', wp_parse_id_list($this->query_vars['network__in'])).' )';
358 357
 		}
359 358
 
360 359
 		// Parse network IDs for a NOT IN clause.
361
-		if ( ! empty( $this->query_vars['network__not_in'] ) ) {
362
-			$this->sql_clauses['where']['network__not_in'] = "$wpdb->site.id NOT IN ( " . implode( ',', wp_parse_id_list( $this->query_vars['network__not_in'] ) ) . ' )';
360
+		if ( ! empty($this->query_vars['network__not_in'])) {
361
+			$this->sql_clauses['where']['network__not_in'] = "$wpdb->site.id NOT IN ( ".implode(',', wp_parse_id_list($this->query_vars['network__not_in'])).' )';
363 362
 		}
364 363
 
365
-		if ( ! empty( $this->query_vars['domain'] ) ) {
366
-			$this->sql_clauses['where']['domain'] = $wpdb->prepare( "$wpdb->site.domain = %s", $this->query_vars['domain'] );
364
+		if ( ! empty($this->query_vars['domain'])) {
365
+			$this->sql_clauses['where']['domain'] = $wpdb->prepare("$wpdb->site.domain = %s", $this->query_vars['domain']);
367 366
 		}
368 367
 
369 368
 		// Parse network domain for an IN clause.
370
-		if ( is_array( $this->query_vars['domain__in'] ) ) {
371
-			$this->sql_clauses['where']['domain__in'] = "$wpdb->site.domain IN ( '" . implode( "', '", $wpdb->_escape( $this->query_vars['domain__in'] ) ) . "' )";
369
+		if (is_array($this->query_vars['domain__in'])) {
370
+			$this->sql_clauses['where']['domain__in'] = "$wpdb->site.domain IN ( '".implode("', '", $wpdb->_escape($this->query_vars['domain__in']))."' )";
372 371
 		}
373 372
 
374 373
 		// Parse network domain for a NOT IN clause.
375
-		if ( is_array( $this->query_vars['domain__not_in'] ) ) {
376
-			$this->sql_clauses['where']['domain__not_in'] = "$wpdb->site.domain NOT IN ( '" . implode( "', '", $wpdb->_escape( $this->query_vars['domain__not_in'] ) ) . "' )";
374
+		if (is_array($this->query_vars['domain__not_in'])) {
375
+			$this->sql_clauses['where']['domain__not_in'] = "$wpdb->site.domain NOT IN ( '".implode("', '", $wpdb->_escape($this->query_vars['domain__not_in']))."' )";
377 376
 		}
378 377
 
379
-		if ( ! empty( $this->query_vars['path'] ) ) {
380
-			$this->sql_clauses['where']['path'] = $wpdb->prepare( "$wpdb->site.path = %s", $this->query_vars['path'] );
378
+		if ( ! empty($this->query_vars['path'])) {
379
+			$this->sql_clauses['where']['path'] = $wpdb->prepare("$wpdb->site.path = %s", $this->query_vars['path']);
381 380
 		}
382 381
 
383 382
 		// Parse network path for an IN clause.
384
-		if ( is_array( $this->query_vars['path__in'] ) ) {
385
-			$this->sql_clauses['where']['path__in'] = "$wpdb->site.path IN ( '" . implode( "', '", $wpdb->_escape( $this->query_vars['path__in'] ) ) . "' )";
383
+		if (is_array($this->query_vars['path__in'])) {
384
+			$this->sql_clauses['where']['path__in'] = "$wpdb->site.path IN ( '".implode("', '", $wpdb->_escape($this->query_vars['path__in']))."' )";
386 385
 		}
387 386
 
388 387
 		// Parse network path for a NOT IN clause.
389
-		if ( is_array( $this->query_vars['path__not_in'] ) ) {
390
-			$this->sql_clauses['where']['path__not_in'] = "$wpdb->site.path NOT IN ( '" . implode( "', '", $wpdb->_escape( $this->query_vars['path__not_in'] ) ) . "' )";
388
+		if (is_array($this->query_vars['path__not_in'])) {
389
+			$this->sql_clauses['where']['path__not_in'] = "$wpdb->site.path NOT IN ( '".implode("', '", $wpdb->_escape($this->query_vars['path__not_in']))."' )";
391 390
 		}
392 391
 
393 392
 		// Falsey search strings are ignored.
394
-		if ( strlen( $this->query_vars['search'] ) ) {
393
+		if (strlen($this->query_vars['search'])) {
395 394
 			$this->sql_clauses['where']['search'] = $this->get_search_sql(
396 395
 				$this->query_vars['search'],
397
-				array( "$wpdb->site.domain", "$wpdb->site.path" )
396
+				array("$wpdb->site.domain", "$wpdb->site.path")
398 397
 			);
399 398
 		}
400 399
 
401 400
 		$join = '';
402 401
 
403
-		$where = implode( ' AND ', $this->sql_clauses['where'] );
402
+		$where = implode(' AND ', $this->sql_clauses['where']);
404 403
 
405
-		$pieces = array( 'fields', 'join', 'where', 'orderby', 'limits', 'groupby' );
404
+		$pieces = array('fields', 'join', 'where', 'orderby', 'limits', 'groupby');
406 405
 
407 406
 		/**
408 407
 		 * Filters the network query clauses.
@@ -412,29 +411,29 @@  discard block
 block discarded – undo
412 411
 		 * @param array            $pieces A compacted array of network query clauses.
413 412
 		 * @param WP_Network_Query &$this  Current instance of WP_Network_Query, passed by reference.
414 413
 		 */
415
-		$clauses = apply_filters_ref_array( 'networks_clauses', array( compact( $pieces ), &$this ) );
414
+		$clauses = apply_filters_ref_array('networks_clauses', array(compact($pieces), &$this));
416 415
 
417
-		$fields = isset( $clauses['fields'] ) ? $clauses['fields'] : '';
418
-		$join = isset( $clauses['join'] ) ? $clauses['join'] : '';
419
-		$where = isset( $clauses['where'] ) ? $clauses['where'] : '';
420
-		$orderby = isset( $clauses['orderby'] ) ? $clauses['orderby'] : '';
421
-		$limits = isset( $clauses['limits'] ) ? $clauses['limits'] : '';
422
-		$groupby = isset( $clauses['groupby'] ) ? $clauses['groupby'] : '';
416
+		$fields = isset($clauses['fields']) ? $clauses['fields'] : '';
417
+		$join = isset($clauses['join']) ? $clauses['join'] : '';
418
+		$where = isset($clauses['where']) ? $clauses['where'] : '';
419
+		$orderby = isset($clauses['orderby']) ? $clauses['orderby'] : '';
420
+		$limits = isset($clauses['limits']) ? $clauses['limits'] : '';
421
+		$groupby = isset($clauses['groupby']) ? $clauses['groupby'] : '';
423 422
 
424
-		if ( $where ) {
425
-			$where = 'WHERE ' . $where;
423
+		if ($where) {
424
+			$where = 'WHERE '.$where;
426 425
 		}
427 426
 
428
-		if ( $groupby ) {
429
-			$groupby = 'GROUP BY ' . $groupby;
427
+		if ($groupby) {
428
+			$groupby = 'GROUP BY '.$groupby;
430 429
 		}
431 430
 
432
-		if ( $orderby ) {
431
+		if ($orderby) {
433 432
 			$orderby = "ORDER BY $orderby";
434 433
 		}
435 434
 
436 435
 		$found_rows = '';
437
-		if ( ! $this->query_vars['no_found_rows'] ) {
436
+		if ( ! $this->query_vars['no_found_rows']) {
438 437
 			$found_rows = 'SQL_CALC_FOUND_ROWS';
439 438
 		}
440 439
 
@@ -446,13 +445,13 @@  discard block
 block discarded – undo
446 445
 
447 446
 		$this->request = "{$this->sql_clauses['select']} {$this->sql_clauses['from']} {$where} {$this->sql_clauses['groupby']} {$this->sql_clauses['orderby']} {$this->sql_clauses['limits']}";
448 447
 
449
-		if ( $this->query_vars['count'] ) {
450
-			return intval( $wpdb->get_var( $this->request ) );
448
+		if ($this->query_vars['count']) {
449
+			return intval($wpdb->get_var($this->request));
451 450
 		}
452 451
 
453
-		$network_ids = $wpdb->get_col( $this->request );
452
+		$network_ids = $wpdb->get_col($this->request);
454 453
 
455
-		return array_map( 'intval', $network_ids );
454
+		return array_map('intval', $network_ids);
456 455
 	}
457 456
 
458 457
 	/**
@@ -467,7 +466,7 @@  discard block
 block discarded – undo
467 466
 	private function set_found_networks() {
468 467
 		global $wpdb;
469 468
 
470
-		if ( $this->query_vars['number'] && ! $this->query_vars['no_found_rows'] ) {
469
+		if ($this->query_vars['number'] && ! $this->query_vars['no_found_rows']) {
471 470
 			/**
472 471
 			 * Filters the query used to retrieve found network count.
473 472
 			 *
@@ -476,9 +475,9 @@  discard block
 block discarded – undo
476 475
 			 * @param string           $found_networks_query SQL query. Default 'SELECT FOUND_ROWS()'.
477 476
 			 * @param WP_Network_Query $network_query        The `WP_Network_Query` instance.
478 477
 			 */
479
-			$found_networks_query = apply_filters( 'found_networks_query', 'SELECT FOUND_ROWS()', $this );
478
+			$found_networks_query = apply_filters('found_networks_query', 'SELECT FOUND_ROWS()', $this);
480 479
 
481
-			$this->found_networks = (int) $wpdb->get_var( $found_networks_query );
480
+			$this->found_networks = (int) $wpdb->get_var($found_networks_query);
482 481
 		}
483 482
 	}
484 483
 
@@ -495,17 +494,17 @@  discard block
 block discarded – undo
495 494
 	 *
496 495
 	 * @return string Search SQL.
497 496
 	 */
498
-	protected function get_search_sql( $string, $columns ) {
497
+	protected function get_search_sql($string, $columns) {
499 498
 		global $wpdb;
500 499
 
501
-		$like = '%' . $wpdb->esc_like( $string ) . '%';
500
+		$like = '%'.$wpdb->esc_like($string).'%';
502 501
 
503 502
 		$searches = array();
504
-		foreach ( $columns as $column ) {
505
-			$searches[] = $wpdb->prepare( "$column LIKE %s", $like );
503
+		foreach ($columns as $column) {
504
+			$searches[] = $wpdb->prepare("$column LIKE %s", $like);
506 505
 		}
507 506
 
508
-		return '(' . implode( ' OR ', $searches ) . ')';
507
+		return '('.implode(' OR ', $searches).')';
509 508
 	}
510 509
 
511 510
 	/**
@@ -519,7 +518,7 @@  discard block
 block discarded – undo
519 518
 	 * @param string $orderby Alias for the field to order by.
520 519
 	 * @return string|false Value to used in the ORDER clause. False otherwise.
521 520
 	 */
522
-	protected function parse_orderby( $orderby ) {
521
+	protected function parse_orderby($orderby) {
523 522
 		global $wpdb;
524 523
 
525 524
 		$allowed_keys = array(
@@ -529,13 +528,13 @@  discard block
 block discarded – undo
529 528
 		);
530 529
 
531 530
 		$parsed = false;
532
-		if ( $orderby == 'network__in' ) {
533
-			$network__in = implode( ',', array_map( 'absint', $this->query_vars['network__in'] ) );
531
+		if ($orderby == 'network__in') {
532
+			$network__in = implode(',', array_map('absint', $this->query_vars['network__in']));
534 533
 			$parsed = "FIELD( {$wpdb->site}.id, $network__in )";
535
-		} elseif ( $orderby == 'domain_length' || $orderby == 'path_length' ) {
536
-			$field = substr( $orderby, 0, -7 );
534
+		} elseif ($orderby == 'domain_length' || $orderby == 'path_length') {
535
+			$field = substr($orderby, 0, -7);
537 536
 			$parsed = "CHAR_LENGTH($wpdb->site.$field)";
538
-		} elseif ( in_array( $orderby, $allowed_keys ) ) {
537
+		} elseif (in_array($orderby, $allowed_keys)) {
539 538
 			$parsed = "$wpdb->site.$orderby";
540 539
 		}
541 540
 
@@ -551,12 +550,12 @@  discard block
 block discarded – undo
551 550
 	 * @param string $order The 'order' query variable.
552 551
 	 * @return string The sanitized 'order' query variable.
553 552
 	 */
554
-	protected function parse_order( $order ) {
555
-		if ( ! is_string( $order ) || empty( $order ) ) {
553
+	protected function parse_order($order) {
554
+		if ( ! is_string($order) || empty($order)) {
556 555
 			return 'ASC';
557 556
 		}
558 557
 
559
-		if ( 'ASC' === strtoupper( $order ) ) {
558
+		if ('ASC' === strtoupper($order)) {
560 559
 			return 'ASC';
561 560
 		} else {
562 561
 			return 'DESC';
Please login to merge, or discard this patch.
src/wp-includes/rss.php 1 patch
Spacing   +224 added lines, -224 removed lines patch added patch discarded remove patch
@@ -16,7 +16,7 @@  discard block
 block discarded – undo
16 16
 /**
17 17
  * Deprecated. Use SimplePie (class-simplepie.php) instead.
18 18
  */
19
-_deprecated_file( basename( __FILE__ ), '3.0.0', WPINC . '/class-simplepie.php' );
19
+_deprecated_file(basename(__FILE__), '3.0.0', WPINC.'/class-simplepie.php');
20 20
 
21 21
 /**
22 22
  * Fires before MagpieRSS is loaded, to optionally replace it.
@@ -24,32 +24,32 @@  discard block
 block discarded – undo
24 24
  * @since 2.3.0
25 25
  * @deprecated 3.0.0
26 26
  */
27
-do_action( 'load_feed_engine' );
27
+do_action('load_feed_engine');
28 28
 
29 29
 /** RSS feed constant. */
30 30
 define('RSS', 'RSS');
31 31
 define('ATOM', 'Atom');
32
-define('MAGPIE_USER_AGENT', 'WordPress/' . $GLOBALS['wp_version']);
32
+define('MAGPIE_USER_AGENT', 'WordPress/'.$GLOBALS['wp_version']);
33 33
 
34 34
 class MagpieRSS {
35 35
 	var $parser;
36
-	var $current_item	= array();	// item currently being parsed
37
-	var $items			= array();	// collection of parsed items
38
-	var $channel		= array();	// hash of channel fields
39
-	var $textinput		= array();
36
+	var $current_item = array(); // item currently being parsed
37
+	var $items			= array(); // collection of parsed items
38
+	var $channel = array(); // hash of channel fields
39
+	var $textinput = array();
40 40
 	var $image			= array();
41 41
 	var $feed_type;
42 42
 	var $feed_version;
43 43
 
44 44
 	// parser variables
45
-	var $stack				= array(); // parser stack
45
+	var $stack = array(); // parser stack
46 46
 	var $inchannel			= false;
47
-	var $initem 			= false;
47
+	var $initem = false;
48 48
 	var $incontent			= false; // if in Atom <content mode="xml"> field
49
-	var $intextinput		= false;
50
-	var $inimage 			= false;
51
-	var $current_field		= '';
52
-	var $current_namespace	= false;
49
+	var $intextinput = false;
50
+	var $inimage = false;
51
+	var $current_field = '';
52
+	var $current_namespace = false;
53 53
 
54 54
 	//var $ERROR = "";
55 55
 
@@ -58,44 +58,44 @@  discard block
 block discarded – undo
58 58
 	/**
59 59
 	 * PHP5 constructor.
60 60
 	 */
61
-	function __construct( $source ) {
61
+	function __construct($source) {
62 62
 
63 63
 		# if PHP xml isn't compiled in, die
64 64
 		#
65
-		if ( !function_exists('xml_parser_create') )
66
-			trigger_error( "Failed to load PHP's XML Extension. https://secure.php.net/manual/en/ref.xml.php" );
65
+		if ( ! function_exists('xml_parser_create'))
66
+			trigger_error("Failed to load PHP's XML Extension. https://secure.php.net/manual/en/ref.xml.php");
67 67
 
68 68
 		$parser = @xml_parser_create();
69 69
 
70
-		if ( !is_resource($parser) )
71
-			trigger_error( "Failed to create an instance of PHP's XML parser. https://secure.php.net/manual/en/ref.xml.php");
70
+		if ( ! is_resource($parser))
71
+			trigger_error("Failed to create an instance of PHP's XML parser. https://secure.php.net/manual/en/ref.xml.php");
72 72
 
73 73
 		$this->parser = $parser;
74 74
 
75 75
 		# pass in parser, and a reference to this object
76 76
 		# set up handlers
77 77
 		#
78
-		xml_set_object( $this->parser, $this );
78
+		xml_set_object($this->parser, $this);
79 79
 		xml_set_element_handler($this->parser,
80
-				'feed_start_element', 'feed_end_element' );
80
+				'feed_start_element', 'feed_end_element');
81 81
 
82
-		xml_set_character_data_handler( $this->parser, 'feed_cdata' );
82
+		xml_set_character_data_handler($this->parser, 'feed_cdata');
83 83
 
84
-		$status = xml_parse( $this->parser, $source );
84
+		$status = xml_parse($this->parser, $source);
85 85
 
86
-		if (! $status ) {
87
-			$errorcode = xml_get_error_code( $this->parser );
88
-			if ( $errorcode != XML_ERROR_NONE ) {
89
-				$xml_error = xml_error_string( $errorcode );
86
+		if ( ! $status) {
87
+			$errorcode = xml_get_error_code($this->parser);
88
+			if ($errorcode != XML_ERROR_NONE) {
89
+				$xml_error = xml_error_string($errorcode);
90 90
 				$error_line = xml_get_current_line_number($this->parser);
91 91
 				$error_col = xml_get_current_column_number($this->parser);
92 92
 				$errormsg = "$xml_error at line $error_line, column $error_col";
93 93
 
94
-				$this->error( $errormsg );
94
+				$this->error($errormsg);
95 95
 			}
96 96
 		}
97 97
 
98
-		xml_parser_free( $this->parser );
98
+		xml_parser_free($this->parser);
99 99
 
100 100
 		$this->normalize();
101 101
 	}
@@ -103,8 +103,8 @@  discard block
 block discarded – undo
103 103
 	/**
104 104
 	 * PHP4 constructor.
105 105
 	 */
106
-	public function MagpieRSS( $source ) {
107
-		self::__construct( $source );
106
+	public function MagpieRSS($source) {
107
+		self::__construct($source);
108 108
 	}
109 109
 
110 110
 	function feed_start_element($p, $element, &$attrs) {
@@ -112,27 +112,27 @@  discard block
 block discarded – undo
112 112
 		$attrs = array_change_key_case($attrs, CASE_LOWER);
113 113
 
114 114
 		// check for a namespace, and split if found
115
-		$ns	= false;
116
-		if ( strpos( $element, ':' ) ) {
117
-			list($ns, $el) = explode( ':', $element, 2);
115
+		$ns = false;
116
+		if (strpos($element, ':')) {
117
+			list($ns, $el) = explode(':', $element, 2);
118 118
 		}
119
-		if ( $ns and $ns != 'rdf' ) {
119
+		if ($ns and $ns != 'rdf') {
120 120
 			$this->current_namespace = $ns;
121 121
 		}
122 122
 
123 123
 		# if feed type isn't set, then this is first element of feed
124 124
 		# identify feed from root element
125 125
 		#
126
-		if (!isset($this->feed_type) ) {
127
-			if ( $el == 'rdf' ) {
126
+		if ( ! isset($this->feed_type)) {
127
+			if ($el == 'rdf') {
128 128
 				$this->feed_type = RSS;
129 129
 				$this->feed_version = '1.0';
130 130
 			}
131
-			elseif ( $el == 'rss' ) {
131
+			elseif ($el == 'rss') {
132 132
 				$this->feed_type = RSS;
133 133
 				$this->feed_version = $attrs['version'];
134 134
 			}
135
-			elseif ( $el == 'feed' ) {
135
+			elseif ($el == 'feed') {
136 136
 				$this->feed_type = ATOM;
137 137
 				$this->feed_version = $attrs['version'];
138 138
 				$this->inchannel = true;
@@ -140,14 +140,14 @@  discard block
 block discarded – undo
140 140
 			return;
141 141
 		}
142 142
 
143
-		if ( $el == 'channel' )
143
+		if ($el == 'channel')
144 144
 		{
145 145
 			$this->inchannel = true;
146 146
 		}
147
-		elseif ($el == 'item' or $el == 'entry' )
147
+		elseif ($el == 'item' or $el == 'entry')
148 148
 		{
149 149
 			$this->initem = true;
150
-			if ( isset($attrs['rdf:about']) ) {
150
+			if (isset($attrs['rdf:about'])) {
151 151
 				$this->current_item['about'] = $attrs['rdf:about'];
152 152
 			}
153 153
 		}
@@ -171,10 +171,10 @@  discard block
 block discarded – undo
171 171
 		}
172 172
 
173 173
 		# handle atom content constructs
174
-		elseif ( $this->feed_type == ATOM and in_array($el, $this->_CONTENT_CONSTRUCTS) )
174
+		elseif ($this->feed_type == ATOM and in_array($el, $this->_CONTENT_CONSTRUCTS))
175 175
 		{
176 176
 			// avoid clashing w/ RSS mod_content
177
-			if ($el == 'content' ) {
177
+			if ($el == 'content') {
178 178
 				$el = 'atom_content';
179 179
 			}
180 180
 
@@ -183,31 +183,31 @@  discard block
 block discarded – undo
183 183
 		}
184 184
 
185 185
 		// if inside an Atom content construct (e.g. content or summary) field treat tags as text
186
-		elseif ($this->feed_type == ATOM and $this->incontent )
186
+		elseif ($this->feed_type == ATOM and $this->incontent)
187 187
 		{
188 188
 			// if tags are inlined, then flatten
189 189
 			$attrs_str = join(' ',
190 190
 					array_map(array('MagpieRSS', 'map_attrs'),
191 191
 					array_keys($attrs),
192
-					array_values($attrs) ) );
192
+					array_values($attrs)));
193 193
 
194
-			$this->append_content( "<$element $attrs_str>"  );
194
+			$this->append_content("<$element $attrs_str>");
195 195
 
196
-			array_unshift( $this->stack, $el );
196
+			array_unshift($this->stack, $el);
197 197
 		}
198 198
 
199 199
 		// Atom support many links per containging element.
200 200
 		// Magpie treats link elements of type rel='alternate'
201 201
 		// as being equivalent to RSS's simple link element.
202 202
 		//
203
-		elseif ($this->feed_type == ATOM and $el == 'link' )
203
+		elseif ($this->feed_type == ATOM and $el == 'link')
204 204
 		{
205
-			if ( isset($attrs['rel']) and $attrs['rel'] == 'alternate' )
205
+			if (isset($attrs['rel']) and $attrs['rel'] == 'alternate')
206 206
 			{
207 207
 				$link_el = 'link';
208 208
 			}
209 209
 			else {
210
-				$link_el = 'link_' . $attrs['rel'];
210
+				$link_el = 'link_'.$attrs['rel'];
211 211
 			}
212 212
 
213 213
 			$this->append($link_el, $attrs['href']);
@@ -218,11 +218,11 @@  discard block
 block discarded – undo
218 218
 		}
219 219
 	}
220 220
 
221
-	function feed_cdata ($p, $text) {
221
+	function feed_cdata($p, $text) {
222 222
 
223 223
 		if ($this->feed_type == ATOM and $this->incontent)
224 224
 		{
225
-			$this->append_content( $text );
225
+			$this->append_content($text);
226 226
 		}
227 227
 		else {
228 228
 			$current_el = join('_', array_reverse($this->stack));
@@ -230,35 +230,35 @@  discard block
 block discarded – undo
230 230
 		}
231 231
 	}
232 232
 
233
-	function feed_end_element ($p, $el) {
233
+	function feed_end_element($p, $el) {
234 234
 		$el = strtolower($el);
235 235
 
236
-		if ( $el == 'item' or $el == 'entry' )
236
+		if ($el == 'item' or $el == 'entry')
237 237
 		{
238 238
 			$this->items[] = $this->current_item;
239 239
 			$this->current_item = array();
240 240
 			$this->initem = false;
241 241
 		}
242
-		elseif ($this->feed_type == RSS and $this->current_namespace == '' and $el == 'textinput' )
242
+		elseif ($this->feed_type == RSS and $this->current_namespace == '' and $el == 'textinput')
243 243
 		{
244 244
 			$this->intextinput = false;
245 245
 		}
246
-		elseif ($this->feed_type == RSS and $this->current_namespace == '' and $el == 'image' )
246
+		elseif ($this->feed_type == RSS and $this->current_namespace == '' and $el == 'image')
247 247
 		{
248 248
 			$this->inimage = false;
249 249
 		}
250
-		elseif ($this->feed_type == ATOM and in_array($el, $this->_CONTENT_CONSTRUCTS) )
250
+		elseif ($this->feed_type == ATOM and in_array($el, $this->_CONTENT_CONSTRUCTS))
251 251
 		{
252 252
 			$this->incontent = false;
253 253
 		}
254
-		elseif ($el == 'channel' or $el == 'feed' )
254
+		elseif ($el == 'channel' or $el == 'feed')
255 255
 		{
256 256
 			$this->inchannel = false;
257 257
 		}
258
-		elseif ($this->feed_type == ATOM and $this->incontent  ) {
258
+		elseif ($this->feed_type == ATOM and $this->incontent) {
259 259
 			// balance tags properly
260 260
 			// note: This may not actually be necessary
261
-			if ( $this->stack[0] == $el )
261
+			if ($this->stack[0] == $el)
262 262
 			{
263 263
 				$this->append_content("</$el>");
264 264
 			}
@@ -266,97 +266,97 @@  discard block
 block discarded – undo
266 266
 				$this->append_content("<$el />");
267 267
 			}
268 268
 
269
-			array_shift( $this->stack );
269
+			array_shift($this->stack);
270 270
 		}
271 271
 		else {
272
-			array_shift( $this->stack );
272
+			array_shift($this->stack);
273 273
 		}
274 274
 
275 275
 		$this->current_namespace = false;
276 276
 	}
277 277
 
278
-	function concat (&$str1, $str2="") {
279
-		if (!isset($str1) ) {
280
-			$str1="";
278
+	function concat(&$str1, $str2 = "") {
279
+		if ( ! isset($str1)) {
280
+			$str1 = "";
281 281
 		}
282 282
 		$str1 .= $str2;
283 283
 	}
284 284
 
285 285
 	function append_content($text) {
286
-		if ( $this->initem ) {
287
-			$this->concat( $this->current_item[ $this->incontent ], $text );
286
+		if ($this->initem) {
287
+			$this->concat($this->current_item[$this->incontent], $text);
288 288
 		}
289
-		elseif ( $this->inchannel ) {
290
-			$this->concat( $this->channel[ $this->incontent ], $text );
289
+		elseif ($this->inchannel) {
290
+			$this->concat($this->channel[$this->incontent], $text);
291 291
 		}
292 292
 	}
293 293
 
294 294
 	// smart append - field and namespace aware
295 295
 	function append($el, $text) {
296
-		if (!$el) {
296
+		if ( ! $el) {
297 297
 			return;
298 298
 		}
299
-		if ( $this->current_namespace )
299
+		if ($this->current_namespace)
300 300
 		{
301
-			if ( $this->initem ) {
301
+			if ($this->initem) {
302 302
 				$this->concat(
303
-					$this->current_item[ $this->current_namespace ][ $el ], $text);
303
+					$this->current_item[$this->current_namespace][$el], $text);
304 304
 			}
305 305
 			elseif ($this->inchannel) {
306 306
 				$this->concat(
307
-					$this->channel[ $this->current_namespace][ $el ], $text );
307
+					$this->channel[$this->current_namespace][$el], $text );
308 308
 			}
309 309
 			elseif ($this->intextinput) {
310 310
 				$this->concat(
311
-					$this->textinput[ $this->current_namespace][ $el ], $text );
311
+					$this->textinput[$this->current_namespace][$el], $text );
312 312
 			}
313 313
 			elseif ($this->inimage) {
314 314
 				$this->concat(
315
-					$this->image[ $this->current_namespace ][ $el ], $text );
315
+					$this->image[$this->current_namespace][$el], $text );
316 316
 			}
317 317
 		}
318 318
 		else {
319
-			if ( $this->initem ) {
319
+			if ($this->initem) {
320 320
 				$this->concat(
321
-					$this->current_item[ $el ], $text);
321
+					$this->current_item[$el], $text);
322 322
 			}
323 323
 			elseif ($this->intextinput) {
324 324
 				$this->concat(
325
-					$this->textinput[ $el ], $text );
325
+					$this->textinput[$el], $text );
326 326
 			}
327 327
 			elseif ($this->inimage) {
328 328
 				$this->concat(
329
-					$this->image[ $el ], $text );
329
+					$this->image[$el], $text );
330 330
 			}
331 331
 			elseif ($this->inchannel) {
332 332
 				$this->concat(
333
-					$this->channel[ $el ], $text );
333
+					$this->channel[$el], $text );
334 334
 			}
335 335
 
336 336
 		}
337 337
 	}
338 338
 
339
-	function normalize () {
339
+	function normalize() {
340 340
 		// if atom populate rss fields
341
-		if ( $this->is_atom() ) {
341
+		if ($this->is_atom()) {
342 342
 			$this->channel['descripton'] = $this->channel['tagline'];
343
-			for ( $i = 0; $i < count($this->items); $i++) {
343
+			for ($i = 0; $i < count($this->items); $i++) {
344 344
 				$item = $this->items[$i];
345
-				if ( isset($item['summary']) )
345
+				if (isset($item['summary']))
346 346
 					$item['description'] = $item['summary'];
347
-				if ( isset($item['atom_content']))
347
+				if (isset($item['atom_content']))
348 348
 					$item['content']['encoded'] = $item['atom_content'];
349 349
 
350 350
 				$this->items[$i] = $item;
351 351
 			}
352 352
 		}
353
-		elseif ( $this->is_rss() ) {
353
+		elseif ($this->is_rss()) {
354 354
 			$this->channel['tagline'] = $this->channel['description'];
355
-			for ( $i = 0; $i < count($this->items); $i++) {
355
+			for ($i = 0; $i < count($this->items); $i++) {
356 356
 				$item = $this->items[$i];
357
-				if ( isset($item['description']))
357
+				if (isset($item['description']))
358 358
 					$item['summary'] = $item['description'];
359
-				if ( isset($item['content']['encoded'] ) )
359
+				if (isset($item['content']['encoded']))
360 360
 					$item['atom_content'] = $item['content']['encoded'];
361 361
 
362 362
 				$this->items[$i] = $item;
@@ -364,8 +364,8 @@  discard block
 block discarded – undo
364 364
 		}
365 365
 	}
366 366
 
367
-	function is_rss () {
368
-		if ( $this->feed_type == RSS ) {
367
+	function is_rss() {
368
+		if ($this->feed_type == RSS) {
369 369
 			return $this->feed_version;
370 370
 		}
371 371
 		else {
@@ -374,7 +374,7 @@  discard block
 block discarded – undo
374 374
 	}
375 375
 
376 376
 	function is_atom() {
377
-		if ( $this->feed_type == ATOM ) {
377
+		if ($this->feed_type == ATOM) {
378 378
 			return $this->feed_version;
379 379
 		}
380 380
 		else {
@@ -386,21 +386,21 @@  discard block
 block discarded – undo
386 386
 		return "$k=\"$v\"";
387 387
 	}
388 388
 
389
-	function error( $errormsg, $lvl = E_USER_WARNING ) {
389
+	function error($errormsg, $lvl = E_USER_WARNING) {
390 390
 		// append PHP's error message if track_errors enabled
391
-		if ( isset($php_errormsg) ) {
391
+		if (isset($php_errormsg)) {
392 392
 			$errormsg .= " ($php_errormsg)";
393 393
 		}
394
-		if ( MAGPIE_DEBUG ) {
395
-			trigger_error( $errormsg, $lvl);
394
+		if (MAGPIE_DEBUG) {
395
+			trigger_error($errormsg, $lvl);
396 396
 		} else {
397
-			error_log( $errormsg, 0);
397
+			error_log($errormsg, 0);
398 398
 		}
399 399
 	}
400 400
 
401 401
 }
402 402
 
403
-if ( !function_exists('fetch_rss') ) :
403
+if ( ! function_exists('fetch_rss')) :
404 404
 /**
405 405
  * Build Magpie object based on RSS from URL.
406 406
  *
@@ -411,21 +411,21 @@  discard block
 block discarded – undo
411 411
  * @param string $url URL to retrieve feed
412 412
  * @return bool|MagpieRSS false on failure or MagpieRSS object on success.
413 413
  */
414
-function fetch_rss ($url) {
414
+function fetch_rss($url) {
415 415
 	// initialize constants
416 416
 	init();
417 417
 
418
-	if ( !isset($url) ) {
418
+	if ( ! isset($url)) {
419 419
 		// error("fetch_rss called without a url");
420 420
 		return false;
421 421
 	}
422 422
 
423 423
 	// if cache is disabled
424
-	if ( !MAGPIE_CACHE_ON ) {
424
+	if ( ! MAGPIE_CACHE_ON) {
425 425
 		// fetch file, and parse it
426
-		$resp = _fetch_remote_file( $url );
427
-		if ( is_success( $resp->status ) ) {
428
-			return _response_to_rss( $resp );
426
+		$resp = _fetch_remote_file($url);
427
+		if (is_success($resp->status)) {
428
+			return _response_to_rss($resp);
429 429
 		}
430 430
 		else {
431 431
 			// error("Failed to fetch $url and cache is off");
@@ -440,28 +440,28 @@  discard block
 block discarded – undo
440 440
 		// 3. if cached obj fails freshness check, fetch remote
441 441
 		// 4. if remote fails, return stale object, or error
442 442
 
443
-		$cache = new RSSCache( MAGPIE_CACHE_DIR, MAGPIE_CACHE_AGE );
443
+		$cache = new RSSCache(MAGPIE_CACHE_DIR, MAGPIE_CACHE_AGE);
444 444
 
445 445
 		if (MAGPIE_DEBUG and $cache->ERROR) {
446 446
 			debug($cache->ERROR, E_USER_WARNING);
447 447
 		}
448 448
 
449
-		$cache_status 	 = 0;		// response of check_cache
449
+		$cache_status = 0; // response of check_cache
450 450
 		$request_headers = array(); // HTTP headers to send with fetch
451
-		$rss 			 = 0;		// parsed RSS object
452
-		$errormsg		 = 0;		// errors, if any
451
+		$rss = 0; // parsed RSS object
452
+		$errormsg = 0; // errors, if any
453 453
 
454
-		if (!$cache->ERROR) {
454
+		if ( ! $cache->ERROR) {
455 455
 			// return cache HIT, MISS, or STALE
456
-			$cache_status = $cache->check_cache( $url );
456
+			$cache_status = $cache->check_cache($url);
457 457
 		}
458 458
 
459 459
 		// if object cached, and cache is fresh, return cached obj
460
-		if ( $cache_status == 'HIT' ) {
461
-			$rss = $cache->get( $url );
462
-			if ( isset($rss) and $rss ) {
460
+		if ($cache_status == 'HIT') {
461
+			$rss = $cache->get($url);
462
+			if (isset($rss) and $rss) {
463 463
 				$rss->from_cache = 1;
464
-				if ( MAGPIE_DEBUG > 1) {
464
+				if (MAGPIE_DEBUG > 1) {
465 465
 				debug("MagpieRSS: Cache HIT", E_USER_NOTICE);
466 466
 			}
467 467
 				return $rss;
@@ -471,47 +471,47 @@  discard block
 block discarded – undo
471 471
 		// else attempt a conditional get
472 472
 
473 473
 		// set up headers
474
-		if ( $cache_status == 'STALE' ) {
475
-			$rss = $cache->get( $url );
476
-			if ( isset($rss->etag) and $rss->last_modified ) {
474
+		if ($cache_status == 'STALE') {
475
+			$rss = $cache->get($url);
476
+			if (isset($rss->etag) and $rss->last_modified) {
477 477
 				$request_headers['If-None-Match'] = $rss->etag;
478 478
 				$request_headers['If-Last-Modified'] = $rss->last_modified;
479 479
 			}
480 480
 		}
481 481
 
482
-		$resp = _fetch_remote_file( $url, $request_headers );
482
+		$resp = _fetch_remote_file($url, $request_headers);
483 483
 
484 484
 		if (isset($resp) and $resp) {
485
-			if ($resp->status == '304' ) {
485
+			if ($resp->status == '304') {
486 486
 				// we have the most current copy
487
-				if ( MAGPIE_DEBUG > 1) {
487
+				if (MAGPIE_DEBUG > 1) {
488 488
 					debug("Got 304 for $url");
489 489
 				}
490 490
 				// reset cache on 304 (at minutillo insistent prodding)
491 491
 				$cache->set($url, $rss);
492 492
 				return $rss;
493 493
 			}
494
-			elseif ( is_success( $resp->status ) ) {
495
-				$rss = _response_to_rss( $resp );
496
-				if ( $rss ) {
494
+			elseif (is_success($resp->status)) {
495
+				$rss = _response_to_rss($resp);
496
+				if ($rss) {
497 497
 					if (MAGPIE_DEBUG > 1) {
498 498
 						debug("Fetch successful");
499 499
 					}
500 500
 					// add object to cache
501
-					$cache->set( $url, $rss );
501
+					$cache->set($url, $rss);
502 502
 					return $rss;
503 503
 				}
504 504
 			}
505 505
 			else {
506 506
 				$errormsg = "Failed to fetch $url. ";
507
-				if ( $resp->error ) {
507
+				if ($resp->error) {
508 508
 					# compensate for Snoopy's annoying habbit to tacking
509 509
 					# on '\n'
510 510
 					$http_error = substr($resp->error, 0, -2);
511 511
 					$errormsg .= "(HTTP Error: $http_error)";
512 512
 				}
513 513
 				else {
514
-					$errormsg .=  "(HTTP Response: " . $resp->response_code .')';
514
+					$errormsg .= "(HTTP Response: ".$resp->response_code.')';
515 515
 				}
516 516
 			}
517 517
 		}
@@ -523,7 +523,7 @@  discard block
 block discarded – undo
523 523
 
524 524
 		// attempt to return cached object
525 525
 		if ($rss) {
526
-			if ( MAGPIE_DEBUG ) {
526
+			if (MAGPIE_DEBUG) {
527 527
 				debug("Returning STALE object for $url");
528 528
 			}
529 529
 			return $rss;
@@ -549,35 +549,35 @@  discard block
 block discarded – undo
549 549
  * @param array $headers Optional. Headers to send to the URL.
550 550
  * @return Snoopy style response
551 551
  */
552
-function _fetch_remote_file($url, $headers = "" ) {
553
-	$resp = wp_safe_remote_request( $url, array( 'headers' => $headers, 'timeout' => MAGPIE_FETCH_TIME_OUT ) );
554
-	if ( is_wp_error($resp) ) {
552
+function _fetch_remote_file($url, $headers = "") {
553
+	$resp = wp_safe_remote_request($url, array('headers' => $headers, 'timeout' => MAGPIE_FETCH_TIME_OUT));
554
+	if (is_wp_error($resp)) {
555 555
 		$error = array_shift($resp->errors);
556 556
 
557 557
 		$resp = new stdClass;
558 558
 		$resp->status = 500;
559 559
 		$resp->response_code = 500;
560
-		$resp->error = $error[0] . "\n"; //\n = Snoopy compatibility
560
+		$resp->error = $error[0]."\n"; //\n = Snoopy compatibility
561 561
 		return $resp;
562 562
 	}
563 563
 
564 564
 	// Snoopy returns headers unprocessed.
565 565
 	// Also note, WP_HTTP lowercases all keys, Snoopy did not.
566 566
 	$return_headers = array();
567
-	foreach ( wp_remote_retrieve_headers( $resp ) as $key => $value ) {
568
-		if ( !is_array($value) ) {
567
+	foreach (wp_remote_retrieve_headers($resp) as $key => $value) {
568
+		if ( ! is_array($value)) {
569 569
 			$return_headers[] = "$key: $value";
570 570
 		} else {
571
-			foreach ( $value as $v )
571
+			foreach ($value as $v)
572 572
 				$return_headers[] = "$key: $v";
573 573
 		}
574 574
 	}
575 575
 
576 576
 	$response = new stdClass;
577
-	$response->status = wp_remote_retrieve_response_code( $resp );
578
-	$response->response_code = wp_remote_retrieve_response_code( $resp );
577
+	$response->status = wp_remote_retrieve_response_code($resp);
578
+	$response->response_code = wp_remote_retrieve_response_code($resp);
579 579
 	$response->headers = $return_headers;
580
-	$response->results = wp_remote_retrieve_body( $resp );
580
+	$response->results = wp_remote_retrieve_body($resp);
581 581
 
582 582
 	return $response;
583 583
 }
@@ -592,14 +592,14 @@  discard block
 block discarded – undo
592 592
  * @param array $resp
593 593
  * @return MagpieRSS|bool
594 594
  */
595
-function _response_to_rss ($resp) {
596
-	$rss = new MagpieRSS( $resp->results );
595
+function _response_to_rss($resp) {
596
+	$rss = new MagpieRSS($resp->results);
597 597
 
598 598
 	// if RSS parsed successfully
599
-	if ( $rss && (!isset($rss->ERROR) || !$rss->ERROR) ) {
599
+	if ($rss && ( ! isset($rss->ERROR) || ! $rss->ERROR)) {
600 600
 
601 601
 		// find Etag, and Last-Modified
602
-		foreach ( (array) $resp->headers as $h) {
602
+		foreach ((array) $resp->headers as $h) {
603 603
 			// 2003-03-02 - Nicola Asuni (www.tecnick.com) - fixed bug "Undefined offset: 1"
604 604
 			if (strpos($h, ": ")) {
605 605
 				list($field, $val) = explode(": ", $h, 2);
@@ -609,11 +609,11 @@  discard block
 block discarded – undo
609 609
 				$val = "";
610 610
 			}
611 611
 
612
-			if ( $field == 'etag' ) {
612
+			if ($field == 'etag') {
613 613
 				$rss->etag = $val;
614 614
 			}
615 615
 
616
-			if ( $field == 'last-modified' ) {
616
+			if ($field == 'last-modified') {
617 617
 				$rss->last_modified = $val;
618 618
 			}
619 619
 		}
@@ -624,7 +624,7 @@  discard block
 block discarded – undo
624 624
 		$errormsg = "Failed to parse RSS file.";
625 625
 
626 626
 		if ($rss) {
627
-			$errormsg .= " (" . $rss->ERROR . ")";
627
+			$errormsg .= " (".$rss->ERROR.")";
628 628
 		}
629 629
 		// error($errormsg);
630 630
 
@@ -639,95 +639,95 @@  discard block
 block discarded – undo
639 639
  * @package External
640 640
  * @subpackage MagpieRSS
641 641
  */
642
-function init () {
643
-	if ( defined('MAGPIE_INITALIZED') ) {
642
+function init() {
643
+	if (defined('MAGPIE_INITALIZED')) {
644 644
 		return;
645 645
 	}
646 646
 	else {
647 647
 		define('MAGPIE_INITALIZED', 1);
648 648
 	}
649 649
 
650
-	if ( !defined('MAGPIE_CACHE_ON') ) {
650
+	if ( ! defined('MAGPIE_CACHE_ON')) {
651 651
 		define('MAGPIE_CACHE_ON', 1);
652 652
 	}
653 653
 
654
-	if ( !defined('MAGPIE_CACHE_DIR') ) {
654
+	if ( ! defined('MAGPIE_CACHE_DIR')) {
655 655
 		define('MAGPIE_CACHE_DIR', './cache');
656 656
 	}
657 657
 
658
-	if ( !defined('MAGPIE_CACHE_AGE') ) {
659
-		define('MAGPIE_CACHE_AGE', 60*60); // one hour
658
+	if ( ! defined('MAGPIE_CACHE_AGE')) {
659
+		define('MAGPIE_CACHE_AGE', 60 * 60); // one hour
660 660
 	}
661 661
 
662
-	if ( !defined('MAGPIE_CACHE_FRESH_ONLY') ) {
662
+	if ( ! defined('MAGPIE_CACHE_FRESH_ONLY')) {
663 663
 		define('MAGPIE_CACHE_FRESH_ONLY', 0);
664 664
 	}
665 665
 
666
-		if ( !defined('MAGPIE_DEBUG') ) {
666
+		if ( ! defined('MAGPIE_DEBUG')) {
667 667
 		define('MAGPIE_DEBUG', 0);
668 668
 	}
669 669
 
670
-	if ( !defined('MAGPIE_USER_AGENT') ) {
671
-		$ua = 'WordPress/' . $GLOBALS['wp_version'];
670
+	if ( ! defined('MAGPIE_USER_AGENT')) {
671
+		$ua = 'WordPress/'.$GLOBALS['wp_version'];
672 672
 
673
-		if ( MAGPIE_CACHE_ON ) {
674
-			$ua = $ua . ')';
673
+		if (MAGPIE_CACHE_ON) {
674
+			$ua = $ua.')';
675 675
 		}
676 676
 		else {
677
-			$ua = $ua . '; No cache)';
677
+			$ua = $ua.'; No cache)';
678 678
 		}
679 679
 
680 680
 		define('MAGPIE_USER_AGENT', $ua);
681 681
 	}
682 682
 
683
-	if ( !defined('MAGPIE_FETCH_TIME_OUT') ) {
684
-		define('MAGPIE_FETCH_TIME_OUT', 2);	// 2 second timeout
683
+	if ( ! defined('MAGPIE_FETCH_TIME_OUT')) {
684
+		define('MAGPIE_FETCH_TIME_OUT', 2); // 2 second timeout
685 685
 	}
686 686
 
687 687
 	// use gzip encoding to fetch rss files if supported?
688
-	if ( !defined('MAGPIE_USE_GZIP') ) {
688
+	if ( ! defined('MAGPIE_USE_GZIP')) {
689 689
 		define('MAGPIE_USE_GZIP', true);
690 690
 	}
691 691
 }
692 692
 
693
-function is_info ($sc) {
693
+function is_info($sc) {
694 694
 	return $sc >= 100 && $sc < 200;
695 695
 }
696 696
 
697
-function is_success ($sc) {
697
+function is_success($sc) {
698 698
 	return $sc >= 200 && $sc < 300;
699 699
 }
700 700
 
701
-function is_redirect ($sc) {
701
+function is_redirect($sc) {
702 702
 	return $sc >= 300 && $sc < 400;
703 703
 }
704 704
 
705
-function is_error ($sc) {
705
+function is_error($sc) {
706 706
 	return $sc >= 400 && $sc < 600;
707 707
 }
708 708
 
709
-function is_client_error ($sc) {
709
+function is_client_error($sc) {
710 710
 	return $sc >= 400 && $sc < 500;
711 711
 }
712 712
 
713
-function is_server_error ($sc) {
713
+function is_server_error($sc) {
714 714
 	return $sc >= 500 && $sc < 600;
715 715
 }
716 716
 
717 717
 class RSSCache {
718
-	var $BASE_CACHE;	// where the cache files are stored
719
-	var $MAX_AGE	= 43200;  		// when are files stale, default twelve hours
720
-	var $ERROR 		= '';			// accumulate error messages
718
+	var $BASE_CACHE; // where the cache files are stored
719
+	var $MAX_AGE	= 43200; // when are files stale, default twelve hours
720
+	var $ERROR 		= ''; // accumulate error messages
721 721
 
722 722
 	/**
723 723
 	 * PHP5 constructor.
724 724
 	 */
725
-	function __construct( $base = '', $age = '' ) {
726
-		$this->BASE_CACHE = WP_CONTENT_DIR . '/cache';
727
-		if ( $base ) {
725
+	function __construct($base = '', $age = '') {
726
+		$this->BASE_CACHE = WP_CONTENT_DIR.'/cache';
727
+		if ($base) {
728 728
 			$this->BASE_CACHE = $base;
729 729
 		}
730
-		if ( $age ) {
730
+		if ($age) {
731 731
 			$this->MAX_AGE = $age;
732 732
 		}
733 733
 
@@ -736,8 +736,8 @@  discard block
 block discarded – undo
736 736
 	/**
737 737
 	 * PHP4 constructor.
738 738
 	 */
739
-	public function RSSCache( $base = '', $age = '' ) {
740
-		self::__construct( $base, $age );
739
+	public function RSSCache($base = '', $age = '') {
740
+		self::__construct($base, $age);
741 741
 	}
742 742
 
743 743
 /*=======================================================================*\
@@ -746,8 +746,8 @@  discard block
 block discarded – undo
746 746
 	Input:		url from wich the rss file was fetched
747 747
 	Output:		true on success
748 748
 \*=======================================================================*/
749
-	function set ($url, $rss) {
750
-		$cache_option = 'rss_' . $this->file_name( $url );
749
+	function set($url, $rss) {
750
+		$cache_option = 'rss_'.$this->file_name($url);
751 751
 
752 752
 		set_transient($cache_option, $rss, $this->MAX_AGE);
753 753
 
@@ -760,11 +760,11 @@  discard block
 block discarded – undo
760 760
 	Input:		url from wich the rss file was fetched
761 761
 	Output:		cached object on HIT, false on MISS
762 762
 \*=======================================================================*/
763
-	function get ($url) {
763
+	function get($url) {
764 764
 		$this->ERROR = "";
765
-		$cache_option = 'rss_' . $this->file_name( $url );
765
+		$cache_option = 'rss_'.$this->file_name($url);
766 766
 
767
-		if ( ! $rss = get_transient( $cache_option ) ) {
767
+		if ( ! $rss = get_transient($cache_option)) {
768 768
 			$this->debug(
769 769
 				"Cache doesn't contain: $url (cache option: $cache_option)"
770 770
 			);
@@ -781,11 +781,11 @@  discard block
 block discarded – undo
781 781
 	Input:		url from wich the rss file was fetched
782 782
 	Output:		cached object on HIT, false on MISS
783 783
 \*=======================================================================*/
784
-	function check_cache ( $url ) {
784
+	function check_cache($url) {
785 785
 		$this->ERROR = "";
786
-		$cache_option = 'rss_' . $this->file_name( $url );
786
+		$cache_option = 'rss_'.$this->file_name($url);
787 787
 
788
-		if ( get_transient($cache_option) ) {
788
+		if (get_transient($cache_option)) {
789 789
 			// object exists and is current
790 790
 				return 'HIT';
791 791
 		} else {
@@ -797,15 +797,15 @@  discard block
 block discarded – undo
797 797
 /*=======================================================================*\
798 798
 	Function:	serialize
799 799
 \*=======================================================================*/
800
-	function serialize ( $rss ) {
801
-		return serialize( $rss );
800
+	function serialize($rss) {
801
+		return serialize($rss);
802 802
 	}
803 803
 
804 804
 /*=======================================================================*\
805 805
 	Function:	unserialize
806 806
 \*=======================================================================*/
807
-	function unserialize ( $data ) {
808
-		return unserialize( $data );
807
+	function unserialize($data) {
808
+		return unserialize($data);
809 809
 	}
810 810
 
811 811
 /*=======================================================================*\
@@ -814,64 +814,64 @@  discard block
 block discarded – undo
814 814
 	Input:		url from wich the rss file was fetched
815 815
 	Output:		a file name
816 816
 \*=======================================================================*/
817
-	function file_name ($url) {
818
-		return md5( $url );
817
+	function file_name($url) {
818
+		return md5($url);
819 819
 	}
820 820
 
821 821
 /*=======================================================================*\
822 822
 	Function:	error
823 823
 	Purpose:	register error
824 824
 \*=======================================================================*/
825
-	function error ($errormsg, $lvl=E_USER_WARNING) {
825
+	function error($errormsg, $lvl = E_USER_WARNING) {
826 826
 		// append PHP's error message if track_errors enabled
827
-		if ( isset($php_errormsg) ) {
827
+		if (isset($php_errormsg)) {
828 828
 			$errormsg .= " ($php_errormsg)";
829 829
 		}
830 830
 		$this->ERROR = $errormsg;
831
-		if ( MAGPIE_DEBUG ) {
832
-			trigger_error( $errormsg, $lvl);
831
+		if (MAGPIE_DEBUG) {
832
+			trigger_error($errormsg, $lvl);
833 833
 		}
834 834
 		else {
835
-			error_log( $errormsg, 0);
835
+			error_log($errormsg, 0);
836 836
 		}
837 837
 	}
838
-			function debug ($debugmsg, $lvl=E_USER_NOTICE) {
839
-		if ( MAGPIE_DEBUG ) {
838
+			function debug($debugmsg, $lvl = E_USER_NOTICE) {
839
+		if (MAGPIE_DEBUG) {
840 840
 			$this->error("MagpieRSS [debug] $debugmsg", $lvl);
841 841
 		}
842 842
 	}
843 843
 }
844 844
 
845
-if ( !function_exists('parse_w3cdtf') ) :
846
-function parse_w3cdtf ( $date_str ) {
845
+if ( ! function_exists('parse_w3cdtf')) :
846
+function parse_w3cdtf($date_str) {
847 847
 
848 848
 	# regex to match wc3dtf
849 849
 	$pat = "/(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2})(:(\d{2}))?(?:([-+])(\d{2}):?(\d{2})|(Z))?/";
850 850
 
851
-	if ( preg_match( $pat, $date_str, $match ) ) {
852
-		list( $year, $month, $day, $hours, $minutes, $seconds) =
853
-			array( $match[1], $match[2], $match[3], $match[4], $match[5], $match[7]);
851
+	if (preg_match($pat, $date_str, $match)) {
852
+		list($year, $month, $day, $hours, $minutes, $seconds) =
853
+			array($match[1], $match[2], $match[3], $match[4], $match[5], $match[7]);
854 854
 
855 855
 		# calc epoch for current date assuming GMT
856
-		$epoch = gmmktime( $hours, $minutes, $seconds, $month, $day, $year);
856
+		$epoch = gmmktime($hours, $minutes, $seconds, $month, $day, $year);
857 857
 
858 858
 		$offset = 0;
859
-		if ( $match[11] == 'Z' ) {
859
+		if ($match[11] == 'Z') {
860 860
 			# zulu time, aka GMT
861 861
 		}
862 862
 		else {
863
-			list( $tz_mod, $tz_hour, $tz_min ) =
864
-				array( $match[8], $match[9], $match[10]);
863
+			list($tz_mod, $tz_hour, $tz_min) =
864
+				array($match[8], $match[9], $match[10]);
865 865
 
866 866
 			# zero out the variables
867
-			if ( ! $tz_hour ) { $tz_hour = 0; }
868
-			if ( ! $tz_min ) { $tz_min = 0; }
867
+			if ( ! $tz_hour) { $tz_hour = 0; }
868
+			if ( ! $tz_min) { $tz_min = 0; }
869 869
 
870
-			$offset_secs = (($tz_hour*60)+$tz_min)*60;
870
+			$offset_secs = (($tz_hour * 60) + $tz_min) * 60;
871 871
 
872 872
 			# is timezone ahead of GMT?  then subtract offset
873 873
 			#
874
-			if ( $tz_mod == '+' ) {
874
+			if ($tz_mod == '+') {
875 875
 				$offset_secs = $offset_secs * -1;
876 876
 			}
877 877
 
@@ -886,7 +886,7 @@  discard block
 block discarded – undo
886 886
 }
887 887
 endif;
888 888
 
889
-if ( !function_exists('wp_rss') ) :
889
+if ( ! function_exists('wp_rss')) :
890 890
 /**
891 891
  * Display all RSS items in a HTML ordered list.
892 892
  *
@@ -897,31 +897,31 @@  discard block
 block discarded – undo
897 897
  * @param string $url URL of feed to display. Will not auto sense feed URL.
898 898
  * @param int $num_items Optional. Number of items to display, default is all.
899 899
  */
900
-function wp_rss( $url, $num_items = -1 ) {
901
-	if ( $rss = fetch_rss( $url ) ) {
900
+function wp_rss($url, $num_items = -1) {
901
+	if ($rss = fetch_rss($url)) {
902 902
 		echo '<ul>';
903 903
 
904
-		if ( $num_items !== -1 ) {
905
-			$rss->items = array_slice( $rss->items, 0, $num_items );
904
+		if ($num_items !== -1) {
905
+			$rss->items = array_slice($rss->items, 0, $num_items);
906 906
 		}
907 907
 
908
-		foreach ( (array) $rss->items as $item ) {
908
+		foreach ((array) $rss->items as $item) {
909 909
 			printf(
910 910
 				'<li><a href="%1$s" title="%2$s">%3$s</a></li>',
911
-				esc_url( $item['link'] ),
912
-				esc_attr( strip_tags( $item['description'] ) ),
913
-				esc_html( $item['title'] )
911
+				esc_url($item['link']),
912
+				esc_attr(strip_tags($item['description'])),
913
+				esc_html($item['title'])
914 914
 			);
915 915
 		}
916 916
 
917 917
 		echo '</ul>';
918 918
 	} else {
919
-		_e( 'An error has occurred, which probably means the feed is down. Try again later.' );
919
+		_e('An error has occurred, which probably means the feed is down. Try again later.');
920 920
 	}
921 921
 }
922 922
 endif;
923 923
 
924
-if ( !function_exists('get_rss') ) :
924
+if ( ! function_exists('get_rss')) :
925 925
 /**
926 926
  * Display RSS items in HTML list items.
927 927
  *
@@ -938,11 +938,11 @@  discard block
 block discarded – undo
938 938
  * @param int $num_items Optional. Number of items to display, default is all.
939 939
  * @return bool False on failure.
940 940
  */
941
-function get_rss ($url, $num_items = 5) { // Like get posts, but for RSS
941
+function get_rss($url, $num_items = 5) { // Like get posts, but for RSS
942 942
 	$rss = fetch_rss($url);
943
-	if ( $rss ) {
943
+	if ($rss) {
944 944
 		$rss->items = array_slice($rss->items, 0, $num_items);
945
-		foreach ( (array) $rss->items as $item ) {
945
+		foreach ((array) $rss->items as $item) {
946 946
 			echo "<li>\n";
947 947
 			echo "<a href='$item[link]' title='$item[description]'>";
948 948
 			echo esc_html($item['title']);
Please login to merge, or discard this patch.
src/wp-includes/class-wp-term.php 1 patch
Spacing   +34 added lines, -34 removed lines patch added patch discarded remove patch
@@ -122,73 +122,73 @@  discard block
 block discarded – undo
122 122
 	 *                                there's insufficient data to distinguish which term is intended.
123 123
 	 *                                False for other failures.
124 124
 	 */
125
-	public static function get_instance( $term_id, $taxonomy = null ) {
125
+	public static function get_instance($term_id, $taxonomy = null) {
126 126
 		global $wpdb;
127 127
 
128 128
 		$term_id = (int) $term_id;
129
-		if ( ! $term_id ) {
129
+		if ( ! $term_id) {
130 130
 			return false;
131 131
 		}
132 132
 
133
-		$_term = wp_cache_get( $term_id, 'terms' );
133
+		$_term = wp_cache_get($term_id, 'terms');
134 134
 
135 135
 		// If there isn't a cached version, hit the database.
136
-		if ( ! $_term || ( $taxonomy && $taxonomy !== $_term->taxonomy ) ) {
136
+		if ( ! $_term || ($taxonomy && $taxonomy !== $_term->taxonomy)) {
137 137
 			// Grab all matching terms, in case any are shared between taxonomies.
138
-			$terms = $wpdb->get_results( $wpdb->prepare( "SELECT t.*, tt.* FROM $wpdb->terms AS t INNER JOIN $wpdb->term_taxonomy AS tt ON t.term_id = tt.term_id WHERE t.term_id = %d", $term_id ) );
139
-			if ( ! $terms ) {
138
+			$terms = $wpdb->get_results($wpdb->prepare("SELECT t.*, tt.* FROM $wpdb->terms AS t INNER JOIN $wpdb->term_taxonomy AS tt ON t.term_id = tt.term_id WHERE t.term_id = %d", $term_id));
139
+			if ( ! $terms) {
140 140
 				return false;
141 141
 			}
142 142
 
143 143
 			// If a taxonomy was specified, find a match.
144
-			if ( $taxonomy ) {
145
-				foreach ( $terms as $match ) {
146
-					if ( $taxonomy === $match->taxonomy ) {
144
+			if ($taxonomy) {
145
+				foreach ($terms as $match) {
146
+					if ($taxonomy === $match->taxonomy) {
147 147
 						$_term = $match;
148 148
 						break;
149 149
 					}
150 150
 				}
151 151
 
152 152
 			// If only one match was found, it's the one we want.
153
-			} elseif ( 1 === count( $terms ) ) {
154
-				$_term = reset( $terms );
153
+			} elseif (1 === count($terms)) {
154
+				$_term = reset($terms);
155 155
 
156 156
 			// Otherwise, the term must be shared between taxonomies.
157 157
 			} else {
158 158
 				// If the term is shared only with invalid taxonomies, return the one valid term.
159
-				foreach ( $terms as $t ) {
160
-					if ( ! taxonomy_exists( $t->taxonomy ) ) {
159
+				foreach ($terms as $t) {
160
+					if ( ! taxonomy_exists($t->taxonomy)) {
161 161
 						continue;
162 162
 					}
163 163
 
164 164
 					// Only hit if we've already identified a term in a valid taxonomy.
165
-					if ( $_term ) {
166
-						return new WP_Error( 'ambiguous_term_id', __( 'Term ID is shared between multiple taxonomies' ), $term_id );
165
+					if ($_term) {
166
+						return new WP_Error('ambiguous_term_id', __('Term ID is shared between multiple taxonomies'), $term_id);
167 167
 					}
168 168
 
169 169
 					$_term = $t;
170 170
 				}
171 171
 			}
172 172
 
173
-			if ( ! $_term ) {
173
+			if ( ! $_term) {
174 174
 				return false;
175 175
 			}
176 176
 
177 177
 			// Don't return terms from invalid taxonomies.
178
-			if ( ! taxonomy_exists( $_term->taxonomy ) ) {
179
-				return new WP_Error( 'invalid_taxonomy', __( 'Invalid taxonomy.' ) );
178
+			if ( ! taxonomy_exists($_term->taxonomy)) {
179
+				return new WP_Error('invalid_taxonomy', __('Invalid taxonomy.'));
180 180
 			}
181 181
 
182
-			$_term = sanitize_term( $_term, $_term->taxonomy, 'raw' );
182
+			$_term = sanitize_term($_term, $_term->taxonomy, 'raw');
183 183
 
184 184
 			// Don't cache terms that are shared between taxonomies.
185
-			if ( 1 === count( $terms ) ) {
186
-				wp_cache_add( $term_id, $_term, 'terms' );
185
+			if (1 === count($terms)) {
186
+				wp_cache_add($term_id, $_term, 'terms');
187 187
 			}
188 188
 		}
189 189
 
190
-		$term_obj = new WP_Term( $_term );
191
-		$term_obj->filter( $term_obj->filter );
190
+		$term_obj = new WP_Term($_term);
191
+		$term_obj->filter($term_obj->filter);
192 192
 
193 193
 		return $term_obj;
194 194
 	}
@@ -201,8 +201,8 @@  discard block
 block discarded – undo
201 201
 	 *
202 202
 	 * @param WP_Term|object $term Term object.
203 203
 	 */
204
-	public function __construct( $term ) {
205
-		foreach ( get_object_vars( $term ) as $key => $value ) {
204
+	public function __construct($term) {
205
+		foreach (get_object_vars($term) as $key => $value) {
206 206
 			$this->$key = $value;
207 207
 		}
208 208
 	}
@@ -215,8 +215,8 @@  discard block
 block discarded – undo
215 215
 	 *
216 216
 	 * @param string $filter Filter context. Accepts 'edit', 'db', 'display', 'attribute', 'js', 'raw'.
217 217
 	 */
218
-	public function filter( $filter ) {
219
-		sanitize_term( $this, $this->taxonomy, $filter );
218
+	public function filter($filter) {
219
+		sanitize_term($this, $this->taxonomy, $filter);
220 220
 	}
221 221
 
222 222
 	/**
@@ -228,7 +228,7 @@  discard block
 block discarded – undo
228 228
 	 * @return array Object as array.
229 229
 	 */
230 230
 	public function to_array() {
231
-		return get_object_vars( $this );
231
+		return get_object_vars($this);
232 232
 	}
233 233
 
234 234
 	/**
@@ -240,16 +240,16 @@  discard block
 block discarded – undo
240 240
 	 * @param string $key Property to get.
241 241
 	 * @return mixed Property value.
242 242
 	 */
243
-	public function __get( $key ) {
244
-		switch ( $key ) {
243
+	public function __get($key) {
244
+		switch ($key) {
245 245
 			case 'data' :
246 246
 				$data = new stdClass();
247
-				$columns = array( 'term_id', 'name', 'slug', 'term_group', 'term_taxonomy_id', 'taxonomy', 'description', 'parent', 'count' );
248
-				foreach ( $columns as $column ) {
249
-					$data->{$column} = isset( $this->{$column} ) ? $this->{$column} : null;
247
+				$columns = array('term_id', 'name', 'slug', 'term_group', 'term_taxonomy_id', 'taxonomy', 'description', 'parent', 'count');
248
+				foreach ($columns as $column) {
249
+					$data->{$column} = isset($this->{$column} ) ? $this->{$column} : null;
250 250
 				}
251 251
 
252
-				return sanitize_term( $data, $data->taxonomy, 'raw' );
252
+				return sanitize_term($data, $data->taxonomy, 'raw');
253 253
 				break;
254 254
 		}
255 255
 	}
Please login to merge, or discard this patch.
src/wp-includes/canonical.php 1 patch
Spacing   +238 added lines, -238 removed lines patch added patch discarded remove patch
@@ -38,28 +38,28 @@  discard block
 block discarded – undo
38 38
  * @param bool $do_redirect Optional. Redirect to the new URL.
39 39
  * @return string|void The string of the URL, if redirect needed.
40 40
  */
41
-function redirect_canonical( $requested_url = null, $do_redirect = true ) {
41
+function redirect_canonical($requested_url = null, $do_redirect = true) {
42 42
 	global $wp_rewrite, $is_IIS, $wp_query, $wpdb, $wp;
43 43
 
44
-	if ( isset( $_SERVER['REQUEST_METHOD'] ) && ! in_array( strtoupper( $_SERVER['REQUEST_METHOD'] ), array( 'GET', 'HEAD' ) ) ) {
44
+	if (isset($_SERVER['REQUEST_METHOD']) && ! in_array(strtoupper($_SERVER['REQUEST_METHOD']), array('GET', 'HEAD'))) {
45 45
 		return;
46 46
 	}
47 47
 
48 48
 	// If we're not in wp-admin and the post has been published and preview nonce
49 49
 	// is non-existent or invalid then no need for preview in query
50
-	if ( is_preview() && get_query_var( 'p' ) && 'publish' == get_post_status( get_query_var( 'p' ) ) ) {
51
-		if ( ! isset( $_GET['preview_id'] )
52
-			|| ! isset( $_GET['preview_nonce'] )
53
-			|| ! wp_verify_nonce( $_GET['preview_nonce'], 'post_preview_' . (int) $_GET['preview_id'] ) ) {
50
+	if (is_preview() && get_query_var('p') && 'publish' == get_post_status(get_query_var('p'))) {
51
+		if ( ! isset($_GET['preview_id'])
52
+			|| ! isset($_GET['preview_nonce'])
53
+			|| ! wp_verify_nonce($_GET['preview_nonce'], 'post_preview_'.(int) $_GET['preview_id'])) {
54 54
 			$wp_query->is_preview = false;
55 55
 		}
56 56
 	}
57 57
 
58
-	if ( is_trackback() || is_search() || is_admin() || is_preview() || is_robots() || ( $is_IIS && !iis7_supports_permalinks() ) ) {
58
+	if (is_trackback() || is_search() || is_admin() || is_preview() || is_robots() || ($is_IIS && ! iis7_supports_permalinks())) {
59 59
 		return;
60 60
 	}
61 61
 
62
-	if ( ! $requested_url && isset( $_SERVER['HTTP_HOST'] ) ) {
62
+	if ( ! $requested_url && isset($_SERVER['HTTP_HOST'])) {
63 63
 		// build the URL in the address bar
64 64
 		$requested_url  = is_ssl() ? 'https://' : 'http://';
65 65
 		$requested_url .= $_SERVER['HTTP_HOST'];
@@ -67,7 +67,7 @@  discard block
 block discarded – undo
67 67
 	}
68 68
 
69 69
 	$original = @parse_url($requested_url);
70
-	if ( false === $original ) {
70
+	if (false === $original) {
71 71
 		return;
72 72
 	}
73 73
 
@@ -75,170 +75,170 @@  discard block
 block discarded – undo
75 75
 	$redirect_url = false;
76 76
 
77 77
 	// Notice fixing
78
-	if ( !isset($redirect['path']) )
78
+	if ( ! isset($redirect['path']))
79 79
 		$redirect['path'] = '';
80
-	if ( !isset($redirect['query']) )
80
+	if ( ! isset($redirect['query']))
81 81
 		$redirect['query'] = '';
82 82
 
83 83
 	// If the original URL ended with non-breaking spaces, they were almost
84 84
 	// certainly inserted by accident. Let's remove them, so the reader doesn't
85 85
 	// see a 404 error with no obvious cause.
86
-	$redirect['path'] = preg_replace( '|(%C2%A0)+$|i', '', $redirect['path'] );
86
+	$redirect['path'] = preg_replace('|(%C2%A0)+$|i', '', $redirect['path']);
87 87
 
88 88
 	// It's not a preview, so remove it from URL
89
-	if ( get_query_var( 'preview' ) ) {
90
-		$redirect['query'] = remove_query_arg( 'preview', $redirect['query'] );
89
+	if (get_query_var('preview')) {
90
+		$redirect['query'] = remove_query_arg('preview', $redirect['query']);
91 91
 	}
92 92
 
93
-	if ( is_feed() && ( $id = get_query_var( 'p' ) ) ) {
94
-		if ( $redirect_url = get_post_comments_feed_link( $id, get_query_var( 'feed' ) ) ) {
95
-			$redirect['query'] = _remove_qs_args_if_not_in_url( $redirect['query'], array( 'p', 'page_id', 'attachment_id', 'pagename', 'name', 'post_type', 'feed'), $redirect_url );
96
-			$redirect['path'] = parse_url( $redirect_url, PHP_URL_PATH );
93
+	if (is_feed() && ($id = get_query_var('p'))) {
94
+		if ($redirect_url = get_post_comments_feed_link($id, get_query_var('feed'))) {
95
+			$redirect['query'] = _remove_qs_args_if_not_in_url($redirect['query'], array('p', 'page_id', 'attachment_id', 'pagename', 'name', 'post_type', 'feed'), $redirect_url);
96
+			$redirect['path'] = parse_url($redirect_url, PHP_URL_PATH);
97 97
 		}
98 98
 	}
99 99
 
100
-	if ( is_singular() && 1 > $wp_query->post_count && ($id = get_query_var('p')) ) {
100
+	if (is_singular() && 1 > $wp_query->post_count && ($id = get_query_var('p'))) {
101 101
 
102
-		$vars = $wpdb->get_results( $wpdb->prepare("SELECT post_type, post_parent FROM $wpdb->posts WHERE ID = %d", $id) );
102
+		$vars = $wpdb->get_results($wpdb->prepare("SELECT post_type, post_parent FROM $wpdb->posts WHERE ID = %d", $id));
103 103
 
104
-		if ( isset($vars[0]) && $vars = $vars[0] ) {
105
-			if ( 'revision' == $vars->post_type && $vars->post_parent > 0 )
104
+		if (isset($vars[0]) && $vars = $vars[0]) {
105
+			if ('revision' == $vars->post_type && $vars->post_parent > 0)
106 106
 				$id = $vars->post_parent;
107 107
 
108
-			if ( $redirect_url = get_permalink($id) )
109
-				$redirect['query'] = _remove_qs_args_if_not_in_url( $redirect['query'], array( 'p', 'page_id', 'attachment_id', 'pagename', 'name', 'post_type' ), $redirect_url );
108
+			if ($redirect_url = get_permalink($id))
109
+				$redirect['query'] = _remove_qs_args_if_not_in_url($redirect['query'], array('p', 'page_id', 'attachment_id', 'pagename', 'name', 'post_type'), $redirect_url);
110 110
 		}
111 111
 	}
112 112
 
113 113
 	// These tests give us a WP-generated permalink
114
-	if ( is_404() ) {
114
+	if (is_404()) {
115 115
 
116 116
 		// Redirect ?page_id, ?p=, ?attachment_id= to their respective url's
117
-		$id = max( get_query_var('p'), get_query_var('page_id'), get_query_var('attachment_id') );
118
-		if ( $id && $redirect_post = get_post($id) ) {
117
+		$id = max(get_query_var('p'), get_query_var('page_id'), get_query_var('attachment_id'));
118
+		if ($id && $redirect_post = get_post($id)) {
119 119
 			$post_type_obj = get_post_type_object($redirect_post->post_type);
120
-			if ( $post_type_obj->public && 'auto-draft' != $redirect_post->post_status ) {
120
+			if ($post_type_obj->public && 'auto-draft' != $redirect_post->post_status) {
121 121
 				$redirect_url = get_permalink($redirect_post);
122
-				$redirect['query'] = _remove_qs_args_if_not_in_url( $redirect['query'], array( 'p', 'page_id', 'attachment_id', 'pagename', 'name', 'post_type' ), $redirect_url );
122
+				$redirect['query'] = _remove_qs_args_if_not_in_url($redirect['query'], array('p', 'page_id', 'attachment_id', 'pagename', 'name', 'post_type'), $redirect_url);
123 123
 			}
124 124
 		}
125 125
 
126
-		if ( get_query_var( 'day' ) && get_query_var( 'monthnum' ) && get_query_var( 'year' ) ) {
127
-			$year  = get_query_var( 'year' );
128
-			$month = get_query_var( 'monthnum' );
129
-			$day   = get_query_var( 'day' );
130
-			$date  = sprintf( '%04d-%02d-%02d', $year, $month, $day );
131
-			if ( ! wp_checkdate( $month, $day, $year, $date ) ) {
132
-				$redirect_url = get_month_link( $year, $month );
133
-				$redirect['query'] = _remove_qs_args_if_not_in_url( $redirect['query'], array( 'year', 'monthnum', 'day' ), $redirect_url );
126
+		if (get_query_var('day') && get_query_var('monthnum') && get_query_var('year')) {
127
+			$year  = get_query_var('year');
128
+			$month = get_query_var('monthnum');
129
+			$day   = get_query_var('day');
130
+			$date  = sprintf('%04d-%02d-%02d', $year, $month, $day);
131
+			if ( ! wp_checkdate($month, $day, $year, $date)) {
132
+				$redirect_url = get_month_link($year, $month);
133
+				$redirect['query'] = _remove_qs_args_if_not_in_url($redirect['query'], array('year', 'monthnum', 'day'), $redirect_url);
134 134
 			}
135
-		} elseif ( get_query_var( 'monthnum' ) && get_query_var( 'year' ) && 12 < get_query_var( 'monthnum' ) ) {
136
-			$redirect_url = get_year_link( get_query_var( 'year' ) );
137
-			$redirect['query'] = _remove_qs_args_if_not_in_url( $redirect['query'], array( 'year', 'monthnum' ), $redirect_url );
135
+		} elseif (get_query_var('monthnum') && get_query_var('year') && 12 < get_query_var('monthnum')) {
136
+			$redirect_url = get_year_link(get_query_var('year'));
137
+			$redirect['query'] = _remove_qs_args_if_not_in_url($redirect['query'], array('year', 'monthnum'), $redirect_url);
138 138
 		}
139 139
 
140
-		if ( ! $redirect_url ) {
141
-			if ( $redirect_url = redirect_guess_404_permalink() ) {
142
-				$redirect['query'] = _remove_qs_args_if_not_in_url( $redirect['query'], array( 'page', 'feed', 'p', 'page_id', 'attachment_id', 'pagename', 'name', 'post_type' ), $redirect_url );
140
+		if ( ! $redirect_url) {
141
+			if ($redirect_url = redirect_guess_404_permalink()) {
142
+				$redirect['query'] = _remove_qs_args_if_not_in_url($redirect['query'], array('page', 'feed', 'p', 'page_id', 'attachment_id', 'pagename', 'name', 'post_type'), $redirect_url);
143 143
 			}
144 144
 		}
145 145
 
146
-		if ( get_query_var( 'page' ) && $wp_query->post &&
147
-			false !== strpos( $wp_query->post->post_content, '<!--nextpage-->' ) ) {
148
-			$redirect['path'] = rtrim( $redirect['path'], (int) get_query_var( 'page' ) . '/' );
149
-			$redirect['query'] = remove_query_arg( 'page', $redirect['query'] );
150
-			$redirect_url = get_permalink( $wp_query->post->ID );
146
+		if (get_query_var('page') && $wp_query->post &&
147
+			false !== strpos($wp_query->post->post_content, '<!--nextpage-->')) {
148
+			$redirect['path'] = rtrim($redirect['path'], (int) get_query_var('page').'/');
149
+			$redirect['query'] = remove_query_arg('page', $redirect['query']);
150
+			$redirect_url = get_permalink($wp_query->post->ID);
151 151
 		}
152 152
 
153
-	} elseif ( is_object($wp_rewrite) && $wp_rewrite->using_permalinks() ) {
153
+	} elseif (is_object($wp_rewrite) && $wp_rewrite->using_permalinks()) {
154 154
 		// rewriting of old ?p=X, ?m=2004, ?m=200401, ?m=20040101
155
-		if ( is_attachment() &&
156
-			! array_diff( array_keys( $wp->query_vars ), array( 'attachment', 'attachment_id' ) ) &&
157
-			! $redirect_url ) {
158
-			if ( ! empty( $_GET['attachment_id'] ) ) {
159
-				$redirect_url = get_attachment_link( get_query_var( 'attachment_id' ) );
160
-				if ( $redirect_url ) {
161
-					$redirect['query'] = remove_query_arg( 'attachment_id', $redirect['query'] );
155
+		if (is_attachment() &&
156
+			! array_diff(array_keys($wp->query_vars), array('attachment', 'attachment_id')) &&
157
+			! $redirect_url) {
158
+			if ( ! empty($_GET['attachment_id'])) {
159
+				$redirect_url = get_attachment_link(get_query_var('attachment_id'));
160
+				if ($redirect_url) {
161
+					$redirect['query'] = remove_query_arg('attachment_id', $redirect['query']);
162 162
 				}
163 163
 			} else {
164 164
 				$redirect_url = get_attachment_link();
165 165
 			}
166
-		} elseif ( is_single() && !empty($_GET['p']) && ! $redirect_url ) {
167
-			if ( $redirect_url = get_permalink(get_query_var('p')) )
166
+		} elseif (is_single() && ! empty($_GET['p']) && ! $redirect_url) {
167
+			if ($redirect_url = get_permalink(get_query_var('p')))
168 168
 				$redirect['query'] = remove_query_arg(array('p', 'post_type'), $redirect['query']);
169
-		} elseif ( is_single() && !empty($_GET['name'])  && ! $redirect_url ) {
170
-			if ( $redirect_url = get_permalink( $wp_query->get_queried_object_id() ) )
169
+		} elseif (is_single() && ! empty($_GET['name']) && ! $redirect_url) {
170
+			if ($redirect_url = get_permalink($wp_query->get_queried_object_id()))
171 171
 				$redirect['query'] = remove_query_arg('name', $redirect['query']);
172
-		} elseif ( is_page() && !empty($_GET['page_id']) && ! $redirect_url ) {
173
-			if ( $redirect_url = get_permalink(get_query_var('page_id')) )
172
+		} elseif (is_page() && ! empty($_GET['page_id']) && ! $redirect_url) {
173
+			if ($redirect_url = get_permalink(get_query_var('page_id')))
174 174
 				$redirect['query'] = remove_query_arg('page_id', $redirect['query']);
175
-		} elseif ( is_page() && !is_feed() && 'page' == get_option('show_on_front') && get_queried_object_id() == get_option('page_on_front')  && ! $redirect_url ) {
175
+		} elseif (is_page() && ! is_feed() && 'page' == get_option('show_on_front') && get_queried_object_id() == get_option('page_on_front') && ! $redirect_url) {
176 176
 			$redirect_url = home_url('/');
177
-		} elseif ( is_home() && !empty($_GET['page_id']) && 'page' == get_option('show_on_front') && get_query_var('page_id') == get_option('page_for_posts')  && ! $redirect_url ) {
178
-			if ( $redirect_url = get_permalink(get_option('page_for_posts')) )
177
+		} elseif (is_home() && ! empty($_GET['page_id']) && 'page' == get_option('show_on_front') && get_query_var('page_id') == get_option('page_for_posts') && ! $redirect_url) {
178
+			if ($redirect_url = get_permalink(get_option('page_for_posts')))
179 179
 				$redirect['query'] = remove_query_arg('page_id', $redirect['query']);
180
-		} elseif ( !empty($_GET['m']) && ( is_year() || is_month() || is_day() ) ) {
180
+		} elseif ( ! empty($_GET['m']) && (is_year() || is_month() || is_day())) {
181 181
 			$m = get_query_var('m');
182
-			switch ( strlen($m) ) {
182
+			switch (strlen($m)) {
183 183
 				case 4: // Yearly
184 184
 					$redirect_url = get_year_link($m);
185 185
 					break;
186 186
 				case 6: // Monthly
187
-					$redirect_url = get_month_link( substr($m, 0, 4), substr($m, 4, 2) );
187
+					$redirect_url = get_month_link(substr($m, 0, 4), substr($m, 4, 2));
188 188
 					break;
189 189
 				case 8: // Daily
190 190
 					$redirect_url = get_day_link(substr($m, 0, 4), substr($m, 4, 2), substr($m, 6, 2));
191 191
 					break;
192 192
 			}
193
-			if ( $redirect_url )
193
+			if ($redirect_url)
194 194
 				$redirect['query'] = remove_query_arg('m', $redirect['query']);
195 195
 		// now moving on to non ?m=X year/month/day links
196
-		} elseif ( is_day() && get_query_var('year') && get_query_var('monthnum') && !empty($_GET['day']) ) {
197
-			if ( $redirect_url = get_day_link(get_query_var('year'), get_query_var('monthnum'), get_query_var('day')) )
196
+		} elseif (is_day() && get_query_var('year') && get_query_var('monthnum') && ! empty($_GET['day'])) {
197
+			if ($redirect_url = get_day_link(get_query_var('year'), get_query_var('monthnum'), get_query_var('day')))
198 198
 				$redirect['query'] = remove_query_arg(array('year', 'monthnum', 'day'), $redirect['query']);
199
-		} elseif ( is_month() && get_query_var('year') && !empty($_GET['monthnum']) ) {
200
-			if ( $redirect_url = get_month_link(get_query_var('year'), get_query_var('monthnum')) )
199
+		} elseif (is_month() && get_query_var('year') && ! empty($_GET['monthnum'])) {
200
+			if ($redirect_url = get_month_link(get_query_var('year'), get_query_var('monthnum')))
201 201
 				$redirect['query'] = remove_query_arg(array('year', 'monthnum'), $redirect['query']);
202
-		} elseif ( is_year() && !empty($_GET['year']) ) {
203
-			if ( $redirect_url = get_year_link(get_query_var('year')) )
202
+		} elseif (is_year() && ! empty($_GET['year'])) {
203
+			if ($redirect_url = get_year_link(get_query_var('year')))
204 204
 				$redirect['query'] = remove_query_arg('year', $redirect['query']);
205
-		} elseif ( is_author() && !empty($_GET['author']) && preg_match( '|^[0-9]+$|', $_GET['author'] ) ) {
205
+		} elseif (is_author() && ! empty($_GET['author']) && preg_match('|^[0-9]+$|', $_GET['author'])) {
206 206
 			$author = get_userdata(get_query_var('author'));
207
-			if ( ( false !== $author ) && $wpdb->get_var( $wpdb->prepare( "SELECT ID FROM $wpdb->posts WHERE $wpdb->posts.post_author = %d AND $wpdb->posts.post_status = 'publish' LIMIT 1", $author->ID ) ) ) {
208
-				if ( $redirect_url = get_author_posts_url($author->ID, $author->user_nicename) )
207
+			if ((false !== $author) && $wpdb->get_var($wpdb->prepare("SELECT ID FROM $wpdb->posts WHERE $wpdb->posts.post_author = %d AND $wpdb->posts.post_status = 'publish' LIMIT 1", $author->ID))) {
208
+				if ($redirect_url = get_author_posts_url($author->ID, $author->user_nicename))
209 209
 					$redirect['query'] = remove_query_arg('author', $redirect['query']);
210 210
 			}
211
-		} elseif ( is_category() || is_tag() || is_tax() ) { // Terms (Tags/categories)
211
+		} elseif (is_category() || is_tag() || is_tax()) { // Terms (Tags/categories)
212 212
 
213 213
 			$term_count = 0;
214
-			foreach ( $wp_query->tax_query->queried_terms as $tax_query )
215
-				$term_count += count( $tax_query['terms'] );
214
+			foreach ($wp_query->tax_query->queried_terms as $tax_query)
215
+				$term_count += count($tax_query['terms']);
216 216
 
217 217
 			$obj = $wp_query->get_queried_object();
218
-			if ( $term_count <= 1 && !empty($obj->term_id) && ( $tax_url = get_term_link((int)$obj->term_id, $obj->taxonomy) ) && !is_wp_error($tax_url) ) {
219
-				if ( !empty($redirect['query']) ) {
218
+			if ($term_count <= 1 && ! empty($obj->term_id) && ($tax_url = get_term_link((int) $obj->term_id, $obj->taxonomy)) && ! is_wp_error($tax_url)) {
219
+				if ( ! empty($redirect['query'])) {
220 220
 					// Strip taxonomy query vars off the url.
221
-					$qv_remove = array( 'term', 'taxonomy');
222
-					if ( is_category() ) {
221
+					$qv_remove = array('term', 'taxonomy');
222
+					if (is_category()) {
223 223
 						$qv_remove[] = 'category_name';
224 224
 						$qv_remove[] = 'cat';
225
-					} elseif ( is_tag() ) {
225
+					} elseif (is_tag()) {
226 226
 						$qv_remove[] = 'tag';
227 227
 						$qv_remove[] = 'tag_id';
228 228
 					} else { // Custom taxonomies will have a custom query var, remove those too:
229
-						$tax_obj = get_taxonomy( $obj->taxonomy );
230
-						if ( false !== $tax_obj->query_var )
229
+						$tax_obj = get_taxonomy($obj->taxonomy);
230
+						if (false !== $tax_obj->query_var)
231 231
 							$qv_remove[] = $tax_obj->query_var;
232 232
 					}
233 233
 
234
-					$rewrite_vars = array_diff( array_keys($wp_query->query), array_keys($_GET) );
234
+					$rewrite_vars = array_diff(array_keys($wp_query->query), array_keys($_GET));
235 235
 
236
-					if ( !array_diff($rewrite_vars, array_keys($_GET))  ) { // Check to see if all the Query vars are coming from the rewrite, none are set via $_GET
236
+					if ( ! array_diff($rewrite_vars, array_keys($_GET))) { // Check to see if all the Query vars are coming from the rewrite, none are set via $_GET
237 237
 						$redirect['query'] = remove_query_arg($qv_remove, $redirect['query']); //Remove all of the per-tax qv's
238 238
 
239 239
 						// Create the destination url for this taxonomy
240 240
 						$tax_url = parse_url($tax_url);
241
-						if ( ! empty($tax_url['query']) ) { // Taxonomy accessible via ?taxonomy=..&term=.. or any custom qv..
241
+						if ( ! empty($tax_url['query'])) { // Taxonomy accessible via ?taxonomy=..&term=.. or any custom qv..
242 242
 							parse_str($tax_url['query'], $query_vars);
243 243
 							$redirect['query'] = add_query_arg($query_vars, $redirect['query']);
244 244
 						} else { // Taxonomy is accessible via a "pretty-URL"
@@ -246,40 +246,40 @@  discard block
 block discarded – undo
246 246
 						}
247 247
 
248 248
 					} else { // Some query vars are set via $_GET. Unset those from $_GET that exist via the rewrite
249
-						foreach ( $qv_remove as $_qv ) {
250
-							if ( isset($rewrite_vars[$_qv]) )
249
+						foreach ($qv_remove as $_qv) {
250
+							if (isset($rewrite_vars[$_qv]))
251 251
 								$redirect['query'] = remove_query_arg($_qv, $redirect['query']);
252 252
 						}
253 253
 					}
254 254
 				}
255 255
 
256 256
 			}
257
-		} elseif ( is_single() && strpos($wp_rewrite->permalink_structure, '%category%') !== false && $cat = get_query_var( 'category_name' ) ) {
258
-			$category = get_category_by_path( $cat );
259
-			if ( ( ! $category || is_wp_error( $category ) ) || ! has_term( $category->term_id, 'category', $wp_query->get_queried_object_id() ) ) {
257
+		} elseif (is_single() && strpos($wp_rewrite->permalink_structure, '%category%') !== false && $cat = get_query_var('category_name')) {
258
+			$category = get_category_by_path($cat);
259
+			if (( ! $category || is_wp_error($category)) || ! has_term($category->term_id, 'category', $wp_query->get_queried_object_id())) {
260 260
 				$redirect_url = get_permalink($wp_query->get_queried_object_id());
261 261
 			}
262 262
 		}
263 263
 
264 264
 		// Post Paging
265
-		if ( is_singular() && get_query_var('page') ) {
266
-			if ( !$redirect_url )
267
-				$redirect_url = get_permalink( get_queried_object_id() );
268
-
269
-			$page = get_query_var( 'page' );
270
-			if ( $page > 1 ) {
271
-				if ( is_front_page() ) {
272
-					$redirect_url = trailingslashit( $redirect_url ) . user_trailingslashit( "$wp_rewrite->pagination_base/$page", 'paged' );
265
+		if (is_singular() && get_query_var('page')) {
266
+			if ( ! $redirect_url)
267
+				$redirect_url = get_permalink(get_queried_object_id());
268
+
269
+			$page = get_query_var('page');
270
+			if ($page > 1) {
271
+				if (is_front_page()) {
272
+					$redirect_url = trailingslashit($redirect_url).user_trailingslashit("$wp_rewrite->pagination_base/$page", 'paged');
273 273
 				} else {
274
-					$redirect_url = trailingslashit( $redirect_url ) . user_trailingslashit( $page, 'single_paged' );
274
+					$redirect_url = trailingslashit($redirect_url).user_trailingslashit($page, 'single_paged');
275 275
 				}
276 276
 			}
277
-			$redirect['query'] = remove_query_arg( 'page', $redirect['query'] );
277
+			$redirect['query'] = remove_query_arg('page', $redirect['query']);
278 278
 		}
279 279
 
280 280
 		// paging and feeds
281
-		if ( get_query_var('paged') || is_feed() || get_query_var('cpage') ) {
282
-			while ( preg_match( "#/$wp_rewrite->pagination_base/?[0-9]+?(/+)?$#", $redirect['path'] ) || preg_match( '#/(comments/?)?(feed|rss|rdf|atom|rss2)(/+)?$#', $redirect['path'] ) || preg_match( "#/{$wp_rewrite->comments_pagination_base}-[0-9]+(/+)?$#", $redirect['path'] ) ) {
281
+		if (get_query_var('paged') || is_feed() || get_query_var('cpage')) {
282
+			while (preg_match("#/$wp_rewrite->pagination_base/?[0-9]+?(/+)?$#", $redirect['path']) || preg_match('#/(comments/?)?(feed|rss|rdf|atom|rss2)(/+)?$#', $redirect['path']) || preg_match("#/{$wp_rewrite->comments_pagination_base}-[0-9]+(/+)?$#", $redirect['path'])) {
283 283
 				// Strip off paging and feed
284 284
 				$redirect['path'] = preg_replace("#/$wp_rewrite->pagination_base/?[0-9]+?(/+)?$#", '/', $redirect['path']); // strip off any existing paging
285 285
 				$redirect['path'] = preg_replace('#/(comments/?)?(feed|rss2?|rdf|atom)(/+|$)#', '/', $redirect['path']); // strip off feed endings
@@ -287,16 +287,16 @@  discard block
 block discarded – undo
287 287
 			}
288 288
 
289 289
 			$addl_path = '';
290
-			if ( is_feed() && in_array( get_query_var('feed'), $wp_rewrite->feeds ) ) {
291
-				$addl_path = !empty( $addl_path ) ? trailingslashit($addl_path) : '';
292
-				if ( !is_singular() && get_query_var( 'withcomments' ) )
290
+			if (is_feed() && in_array(get_query_var('feed'), $wp_rewrite->feeds)) {
291
+				$addl_path = ! empty($addl_path) ? trailingslashit($addl_path) : '';
292
+				if ( ! is_singular() && get_query_var('withcomments'))
293 293
 					$addl_path .= 'comments/';
294
-				if ( ( 'rss' == get_default_feed() && 'feed' == get_query_var('feed') ) || 'rss' == get_query_var('feed') )
295
-					$addl_path .= user_trailingslashit( 'feed/' . ( ( get_default_feed() == 'rss2' ) ? '' : 'rss2' ), 'feed' );
294
+				if (('rss' == get_default_feed() && 'feed' == get_query_var('feed')) || 'rss' == get_query_var('feed'))
295
+					$addl_path .= user_trailingslashit('feed/'.((get_default_feed() == 'rss2') ? '' : 'rss2'), 'feed');
296 296
 				else
297
-					$addl_path .= user_trailingslashit( 'feed/' . ( ( get_default_feed() ==  get_query_var('feed') || 'feed' == get_query_var('feed') ) ? '' : get_query_var('feed') ), 'feed' );
298
-				$redirect['query'] = remove_query_arg( 'feed', $redirect['query'] );
299
-			} elseif ( is_feed() && 'old' == get_query_var('feed') ) {
297
+					$addl_path .= user_trailingslashit('feed/'.((get_default_feed() == get_query_var('feed') || 'feed' == get_query_var('feed')) ? '' : get_query_var('feed')), 'feed');
298
+				$redirect['query'] = remove_query_arg('feed', $redirect['query']);
299
+			} elseif (is_feed() && 'old' == get_query_var('feed')) {
300 300
 				$old_feed_files = array(
301 301
 					'wp-atom.php'         => 'atom',
302 302
 					'wp-commentsrss2.php' => 'comments_rss2',
@@ -305,178 +305,178 @@  discard block
 block discarded – undo
305 305
 					'wp-rss.php'          => 'rss2',
306 306
 					'wp-rss2.php'         => 'rss2',
307 307
 				);
308
-				if ( isset( $old_feed_files[ basename( $redirect['path'] ) ] ) ) {
309
-					$redirect_url = get_feed_link( $old_feed_files[ basename( $redirect['path'] ) ] );
310
-					wp_redirect( $redirect_url, 301 );
308
+				if (isset($old_feed_files[basename($redirect['path'])])) {
309
+					$redirect_url = get_feed_link($old_feed_files[basename($redirect['path'])]);
310
+					wp_redirect($redirect_url, 301);
311 311
 					die();
312 312
 				}
313 313
 			}
314 314
 
315
-			if ( get_query_var('paged') > 0 ) {
315
+			if (get_query_var('paged') > 0) {
316 316
 				$paged = get_query_var('paged');
317
-				$redirect['query'] = remove_query_arg( 'paged', $redirect['query'] );
318
-				if ( !is_feed() ) {
319
-					if ( $paged > 1 && !is_single() ) {
320
-						$addl_path = ( !empty( $addl_path ) ? trailingslashit($addl_path) : '' ) . user_trailingslashit("$wp_rewrite->pagination_base/$paged", 'paged');
321
-					} elseif ( !is_single() ) {
322
-						$addl_path = !empty( $addl_path ) ? trailingslashit($addl_path) : '';
317
+				$redirect['query'] = remove_query_arg('paged', $redirect['query']);
318
+				if ( ! is_feed()) {
319
+					if ($paged > 1 && ! is_single()) {
320
+						$addl_path = ( ! empty($addl_path) ? trailingslashit($addl_path) : '').user_trailingslashit("$wp_rewrite->pagination_base/$paged", 'paged');
321
+					} elseif ( ! is_single()) {
322
+						$addl_path = ! empty($addl_path) ? trailingslashit($addl_path) : '';
323 323
 					}
324
-				} elseif ( $paged > 1 ) {
325
-					$redirect['query'] = add_query_arg( 'paged', $paged, $redirect['query'] );
324
+				} elseif ($paged > 1) {
325
+					$redirect['query'] = add_query_arg('paged', $paged, $redirect['query']);
326 326
 				}
327 327
 			}
328 328
 
329
-			if ( get_option( 'page_comments' ) && (
330
-				( 'newest' == get_option( 'default_comments_page' ) && get_query_var( 'cpage' ) > 0 ) ||
331
-				( 'newest' != get_option( 'default_comments_page' ) && get_query_var( 'cpage' ) > 1 )
332
-			) ) {
333
-				$addl_path = ( !empty( $addl_path ) ? trailingslashit($addl_path) : '' ) . user_trailingslashit( $wp_rewrite->comments_pagination_base . '-' . get_query_var('cpage'), 'commentpaged' );
334
-				$redirect['query'] = remove_query_arg( 'cpage', $redirect['query'] );
329
+			if (get_option('page_comments') && (
330
+				('newest' == get_option('default_comments_page') && get_query_var('cpage') > 0) ||
331
+				('newest' != get_option('default_comments_page') && get_query_var('cpage') > 1)
332
+			)) {
333
+				$addl_path = ( ! empty($addl_path) ? trailingslashit($addl_path) : '').user_trailingslashit($wp_rewrite->comments_pagination_base.'-'.get_query_var('cpage'), 'commentpaged');
334
+				$redirect['query'] = remove_query_arg('cpage', $redirect['query']);
335 335
 			}
336 336
 
337
-			$redirect['path'] = user_trailingslashit( preg_replace('|/' . preg_quote( $wp_rewrite->index, '|' ) . '/?$|', '/', $redirect['path']) ); // strip off trailing /index.php/
338
-			if ( !empty( $addl_path ) && $wp_rewrite->using_index_permalinks() && strpos($redirect['path'], '/' . $wp_rewrite->index . '/') === false )
339
-				$redirect['path'] = trailingslashit($redirect['path']) . $wp_rewrite->index . '/';
340
-			if ( !empty( $addl_path ) )
341
-				$redirect['path'] = trailingslashit($redirect['path']) . $addl_path;
342
-			$redirect_url = $redirect['scheme'] . '://' . $redirect['host'] . $redirect['path'];
337
+			$redirect['path'] = user_trailingslashit(preg_replace('|/'.preg_quote($wp_rewrite->index, '|').'/?$|', '/', $redirect['path'])); // strip off trailing /index.php/
338
+			if ( ! empty($addl_path) && $wp_rewrite->using_index_permalinks() && strpos($redirect['path'], '/'.$wp_rewrite->index.'/') === false)
339
+				$redirect['path'] = trailingslashit($redirect['path']).$wp_rewrite->index.'/';
340
+			if ( ! empty($addl_path))
341
+				$redirect['path'] = trailingslashit($redirect['path']).$addl_path;
342
+			$redirect_url = $redirect['scheme'].'://'.$redirect['host'].$redirect['path'];
343 343
 		}
344 344
 
345
-		if ( 'wp-register.php' == basename( $redirect['path'] ) ) {
346
-			if ( is_multisite() ) {
345
+		if ('wp-register.php' == basename($redirect['path'])) {
346
+			if (is_multisite()) {
347 347
 				/** This filter is documented in wp-login.php */
348
-				$redirect_url = apply_filters( 'wp_signup_location', network_site_url( 'wp-signup.php' ) );
348
+				$redirect_url = apply_filters('wp_signup_location', network_site_url('wp-signup.php'));
349 349
 			} else {
350 350
 				$redirect_url = wp_registration_url();
351 351
 			}
352 352
 
353
-			wp_redirect( $redirect_url, 301 );
353
+			wp_redirect($redirect_url, 301);
354 354
 			die();
355 355
 		}
356 356
 	}
357 357
 
358 358
 	// tack on any additional query vars
359
-	$redirect['query'] = preg_replace( '#^\??&*?#', '', $redirect['query'] );
360
-	if ( $redirect_url && !empty($redirect['query']) ) {
361
-		parse_str( $redirect['query'], $_parsed_query );
359
+	$redirect['query'] = preg_replace('#^\??&*?#', '', $redirect['query']);
360
+	if ($redirect_url && ! empty($redirect['query'])) {
361
+		parse_str($redirect['query'], $_parsed_query);
362 362
 		$redirect = @parse_url($redirect_url);
363 363
 
364
-		if ( ! empty( $_parsed_query['name'] ) && ! empty( $redirect['query'] ) ) {
365
-			parse_str( $redirect['query'], $_parsed_redirect_query );
364
+		if ( ! empty($_parsed_query['name']) && ! empty($redirect['query'])) {
365
+			parse_str($redirect['query'], $_parsed_redirect_query);
366 366
 
367
-			if ( empty( $_parsed_redirect_query['name'] ) )
368
-				unset( $_parsed_query['name'] );
367
+			if (empty($_parsed_redirect_query['name']))
368
+				unset($_parsed_query['name']);
369 369
 		}
370 370
 
371
-		$_parsed_query = rawurlencode_deep( $_parsed_query );
372
-		$redirect_url = add_query_arg( $_parsed_query, $redirect_url );
371
+		$_parsed_query = rawurlencode_deep($_parsed_query);
372
+		$redirect_url = add_query_arg($_parsed_query, $redirect_url);
373 373
 	}
374 374
 
375
-	if ( $redirect_url )
375
+	if ($redirect_url)
376 376
 		$redirect = @parse_url($redirect_url);
377 377
 
378 378
 	// www.example.com vs example.com
379 379
 	$user_home = @parse_url(home_url());
380
-	if ( !empty($user_home['host']) )
380
+	if ( ! empty($user_home['host']))
381 381
 		$redirect['host'] = $user_home['host'];
382
-	if ( empty($user_home['path']) )
382
+	if (empty($user_home['path']))
383 383
 		$user_home['path'] = '/';
384 384
 
385 385
 	// Handle ports
386
-	if ( !empty($user_home['port']) )
386
+	if ( ! empty($user_home['port']))
387 387
 		$redirect['port'] = $user_home['port'];
388 388
 	else
389 389
 		unset($redirect['port']);
390 390
 
391 391
 	// trailing /index.php
392
-	$redirect['path'] = preg_replace('|/' . preg_quote( $wp_rewrite->index, '|' ) . '/*?$|', '/', $redirect['path']);
392
+	$redirect['path'] = preg_replace('|/'.preg_quote($wp_rewrite->index, '|').'/*?$|', '/', $redirect['path']);
393 393
 
394 394
 	// Remove trailing spaces from the path
395
-	$redirect['path'] = preg_replace( '#(%20| )+$#', '', $redirect['path'] );
395
+	$redirect['path'] = preg_replace('#(%20| )+$#', '', $redirect['path']);
396 396
 
397
-	if ( !empty( $redirect['query'] ) ) {
397
+	if ( ! empty($redirect['query'])) {
398 398
 		// Remove trailing spaces from certain terminating query string args
399
-		$redirect['query'] = preg_replace( '#((p|page_id|cat|tag)=[^&]*?)(%20| )+$#', '$1', $redirect['query'] );
399
+		$redirect['query'] = preg_replace('#((p|page_id|cat|tag)=[^&]*?)(%20| )+$#', '$1', $redirect['query']);
400 400
 
401 401
 		// Clean up empty query strings
402
-		$redirect['query'] = trim(preg_replace( '#(^|&)(p|page_id|cat|tag)=?(&|$)#', '&', $redirect['query']), '&');
402
+		$redirect['query'] = trim(preg_replace('#(^|&)(p|page_id|cat|tag)=?(&|$)#', '&', $redirect['query']), '&');
403 403
 
404 404
 		// Redirect obsolete feeds
405
-		$redirect['query'] = preg_replace( '#(^|&)feed=rss(&|$)#', '$1feed=rss2$2', $redirect['query'] );
405
+		$redirect['query'] = preg_replace('#(^|&)feed=rss(&|$)#', '$1feed=rss2$2', $redirect['query']);
406 406
 
407 407
 		// Remove redundant leading ampersands
408
-		$redirect['query'] = preg_replace( '#^\??&*?#', '', $redirect['query'] );
408
+		$redirect['query'] = preg_replace('#^\??&*?#', '', $redirect['query']);
409 409
 	}
410 410
 
411 411
 	// strip /index.php/ when we're not using PATHINFO permalinks
412
-	if ( !$wp_rewrite->using_index_permalinks() )
413
-		$redirect['path'] = str_replace( '/' . $wp_rewrite->index . '/', '/', $redirect['path'] );
412
+	if ( ! $wp_rewrite->using_index_permalinks())
413
+		$redirect['path'] = str_replace('/'.$wp_rewrite->index.'/', '/', $redirect['path']);
414 414
 
415 415
 	// trailing slashes
416
-	if ( is_object($wp_rewrite) && $wp_rewrite->using_permalinks() && !is_404() && (!is_front_page() || ( is_front_page() && (get_query_var('paged') > 1) ) ) ) {
416
+	if (is_object($wp_rewrite) && $wp_rewrite->using_permalinks() && ! is_404() && ( ! is_front_page() || (is_front_page() && (get_query_var('paged') > 1)))) {
417 417
 		$user_ts_type = '';
418
-		if ( get_query_var('paged') > 0 ) {
418
+		if (get_query_var('paged') > 0) {
419 419
 			$user_ts_type = 'paged';
420 420
 		} else {
421
-			foreach ( array('single', 'category', 'page', 'day', 'month', 'year', 'home') as $type ) {
422
-				$func = 'is_' . $type;
423
-				if ( call_user_func($func) ) {
421
+			foreach (array('single', 'category', 'page', 'day', 'month', 'year', 'home') as $type) {
422
+				$func = 'is_'.$type;
423
+				if (call_user_func($func)) {
424 424
 					$user_ts_type = $type;
425 425
 					break;
426 426
 				}
427 427
 			}
428 428
 		}
429 429
 		$redirect['path'] = user_trailingslashit($redirect['path'], $user_ts_type);
430
-	} elseif ( is_front_page() ) {
430
+	} elseif (is_front_page()) {
431 431
 		$redirect['path'] = trailingslashit($redirect['path']);
432 432
 	}
433 433
 
434 434
 	// Strip multiple slashes out of the URL
435
-	if ( strpos($redirect['path'], '//') > -1 )
435
+	if (strpos($redirect['path'], '//') > -1)
436 436
 		$redirect['path'] = preg_replace('|/+|', '/', $redirect['path']);
437 437
 
438 438
 	// Always trailing slash the Front Page URL
439
-	if ( trailingslashit( $redirect['path'] ) == trailingslashit( $user_home['path'] ) )
439
+	if (trailingslashit($redirect['path']) == trailingslashit($user_home['path']))
440 440
 		$redirect['path'] = trailingslashit($redirect['path']);
441 441
 
442 442
 	// Ignore differences in host capitalization, as this can lead to infinite redirects
443 443
 	// Only redirect no-www <=> yes-www
444
-	if ( strtolower($original['host']) == strtolower($redirect['host']) ||
445
-		( strtolower($original['host']) != 'www.' . strtolower($redirect['host']) && 'www.' . strtolower($original['host']) != strtolower($redirect['host']) ) )
444
+	if (strtolower($original['host']) == strtolower($redirect['host']) ||
445
+		(strtolower($original['host']) != 'www.'.strtolower($redirect['host']) && 'www.'.strtolower($original['host']) != strtolower($redirect['host'])))
446 446
 		$redirect['host'] = $original['host'];
447 447
 
448
-	$compare_original = array( $original['host'], $original['path'] );
448
+	$compare_original = array($original['host'], $original['path']);
449 449
 
450
-	if ( !empty( $original['port'] ) )
450
+	if ( ! empty($original['port']))
451 451
 		$compare_original[] = $original['port'];
452 452
 
453
-	if ( !empty( $original['query'] ) )
453
+	if ( ! empty($original['query']))
454 454
 		$compare_original[] = $original['query'];
455 455
 
456
-	$compare_redirect = array( $redirect['host'], $redirect['path'] );
456
+	$compare_redirect = array($redirect['host'], $redirect['path']);
457 457
 
458
-	if ( !empty( $redirect['port'] ) )
458
+	if ( ! empty($redirect['port']))
459 459
 		$compare_redirect[] = $redirect['port'];
460 460
 
461
-	if ( !empty( $redirect['query'] ) )
461
+	if ( ! empty($redirect['query']))
462 462
 		$compare_redirect[] = $redirect['query'];
463 463
 
464
-	if ( $compare_original !== $compare_redirect ) {
465
-		$redirect_url = $redirect['scheme'] . '://' . $redirect['host'];
466
-		if ( !empty($redirect['port']) )
467
-			$redirect_url .= ':' . $redirect['port'];
464
+	if ($compare_original !== $compare_redirect) {
465
+		$redirect_url = $redirect['scheme'].'://'.$redirect['host'];
466
+		if ( ! empty($redirect['port']))
467
+			$redirect_url .= ':'.$redirect['port'];
468 468
 		$redirect_url .= $redirect['path'];
469
-		if ( !empty($redirect['query']) )
470
-			$redirect_url .= '?' . $redirect['query'];
469
+		if ( ! empty($redirect['query']))
470
+			$redirect_url .= '?'.$redirect['query'];
471 471
 	}
472 472
 
473
-	if ( ! $redirect_url || $redirect_url == $requested_url ) {
473
+	if ( ! $redirect_url || $redirect_url == $requested_url) {
474 474
 		return;
475 475
 	}
476 476
 
477 477
 	// Hex encoded octets are case-insensitive.
478
-	if ( false !== strpos($requested_url, '%') ) {
479
-		if ( !function_exists('lowercase_octets') ) {
478
+	if (false !== strpos($requested_url, '%')) {
479
+		if ( ! function_exists('lowercase_octets')) {
480 480
 			/**
481 481
 			 * Converts the first hex-encoded octet match to lowercase.
482 482
 			 *
@@ -487,7 +487,7 @@  discard block
 block discarded – undo
487 487
 			 * @return string Lowercased version of the first match.
488 488
 			 */
489 489
 			function lowercase_octets($matches) {
490
-				return strtolower( $matches[0] );
490
+				return strtolower($matches[0]);
491 491
 			}
492 492
 		}
493 493
 		$requested_url = preg_replace_callback('|%[a-fA-F0-9][a-fA-F0-9]|', 'lowercase_octets', $requested_url);
@@ -503,16 +503,16 @@  discard block
 block discarded – undo
503 503
 	 * @param string $redirect_url  The redirect URL.
504 504
 	 * @param string $requested_url The requested URL.
505 505
 	 */
506
-	$redirect_url = apply_filters( 'redirect_canonical', $redirect_url, $requested_url );
506
+	$redirect_url = apply_filters('redirect_canonical', $redirect_url, $requested_url);
507 507
 
508 508
 	// yes, again -- in case the filter aborted the request
509
-	if ( ! $redirect_url || strip_fragment_from_url( $redirect_url ) == strip_fragment_from_url( $requested_url ) ) {
509
+	if ( ! $redirect_url || strip_fragment_from_url($redirect_url) == strip_fragment_from_url($requested_url)) {
510 510
 		return;
511 511
 	}
512 512
 
513
-	if ( $do_redirect ) {
513
+	if ($do_redirect) {
514 514
 		// protect against chained redirects
515
-		if ( !redirect_canonical($redirect_url, false) ) {
515
+		if ( ! redirect_canonical($redirect_url, false)) {
516 516
 			wp_redirect($redirect_url, 301);
517 517
 			exit();
518 518
 		} else {
@@ -537,16 +537,16 @@  discard block
 block discarded – undo
537 537
  * @param string $url
538 538
  * @return string The altered query string
539 539
  */
540
-function _remove_qs_args_if_not_in_url( $query_string, Array $args_to_check, $url ) {
541
-	$parsed_url = @parse_url( $url );
542
-	if ( ! empty( $parsed_url['query'] ) ) {
543
-		parse_str( $parsed_url['query'], $parsed_query );
544
-		foreach ( $args_to_check as $qv ) {
545
-			if ( !isset( $parsed_query[$qv] ) )
546
-				$query_string = remove_query_arg( $qv, $query_string );
540
+function _remove_qs_args_if_not_in_url($query_string, Array $args_to_check, $url) {
541
+	$parsed_url = @parse_url($url);
542
+	if ( ! empty($parsed_url['query'])) {
543
+		parse_str($parsed_url['query'], $parsed_query);
544
+		foreach ($args_to_check as $qv) {
545
+			if ( ! isset($parsed_query[$qv]))
546
+				$query_string = remove_query_arg($qv, $query_string);
547 547
 		}
548 548
 	} else {
549
-		$query_string = remove_query_arg( $args_to_check, $query_string );
549
+		$query_string = remove_query_arg($args_to_check, $query_string);
550 550
 	}
551 551
 	return $query_string;
552 552
 }
@@ -559,17 +559,17 @@  discard block
 block discarded – undo
559 559
  * @param string $url The URL to strip.
560 560
  * @return string The altered URL.
561 561
  */
562
-function strip_fragment_from_url( $url ) {
563
-	$parsed_url = @parse_url( $url );
564
-	if ( ! empty( $parsed_url['host'] ) ) {
562
+function strip_fragment_from_url($url) {
563
+	$parsed_url = @parse_url($url);
564
+	if ( ! empty($parsed_url['host'])) {
565 565
 		// This mirrors code in redirect_canonical(). It does not handle every case.
566
-		$url = $parsed_url['scheme'] . '://' . $parsed_url['host'];
567
-		if ( ! empty( $parsed_url['port'] ) ) {
568
-			$url .= ':' . $parsed_url['port'];
566
+		$url = $parsed_url['scheme'].'://'.$parsed_url['host'];
567
+		if ( ! empty($parsed_url['port'])) {
568
+			$url .= ':'.$parsed_url['port'];
569 569
 		}
570 570
 		$url .= $parsed_url['path'];
571
-		if ( ! empty( $parsed_url['query'] ) ) {
572
-			$url .= '?' . $parsed_url['query'];
571
+		if ( ! empty($parsed_url['query'])) {
572
+			$url .= '?'.$parsed_url['query'];
573 573
 		}
574 574
 	}
575 575
 
@@ -588,31 +588,31 @@  discard block
 block discarded – undo
588 588
 function redirect_guess_404_permalink() {
589 589
 	global $wpdb;
590 590
 
591
-	if ( get_query_var('name') ) {
592
-		$where = $wpdb->prepare("post_name LIKE %s", $wpdb->esc_like( get_query_var('name') ) . '%');
591
+	if (get_query_var('name')) {
592
+		$where = $wpdb->prepare("post_name LIKE %s", $wpdb->esc_like(get_query_var('name')).'%');
593 593
 
594 594
 		// if any of post_type, year, monthnum, or day are set, use them to refine the query
595
-		if ( get_query_var('post_type') )
595
+		if (get_query_var('post_type'))
596 596
 			$where .= $wpdb->prepare(" AND post_type = %s", get_query_var('post_type'));
597 597
 		else
598
-			$where .= " AND post_type IN ('" . implode( "', '", get_post_types( array( 'public' => true ) ) ) . "')";
598
+			$where .= " AND post_type IN ('".implode("', '", get_post_types(array('public' => true)))."')";
599 599
 
600
-		if ( get_query_var('year') )
600
+		if (get_query_var('year'))
601 601
 			$where .= $wpdb->prepare(" AND YEAR(post_date) = %d", get_query_var('year'));
602
-		if ( get_query_var('monthnum') )
602
+		if (get_query_var('monthnum'))
603 603
 			$where .= $wpdb->prepare(" AND MONTH(post_date) = %d", get_query_var('monthnum'));
604
-		if ( get_query_var('day') )
604
+		if (get_query_var('day'))
605 605
 			$where .= $wpdb->prepare(" AND DAYOFMONTH(post_date) = %d", get_query_var('day'));
606 606
 
607 607
 		$post_id = $wpdb->get_var("SELECT ID FROM $wpdb->posts WHERE $where AND post_status = 'publish'");
608
-		if ( ! $post_id )
608
+		if ( ! $post_id)
609 609
 			return false;
610
-		if ( get_query_var( 'feed' ) )
611
-			return get_post_comments_feed_link( $post_id, get_query_var( 'feed' ) );
612
-		elseif ( get_query_var( 'page' ) && 1 < get_query_var( 'page' ) )
613
-			return trailingslashit( get_permalink( $post_id ) ) . user_trailingslashit( get_query_var( 'page' ), 'single_paged' );
610
+		if (get_query_var('feed'))
611
+			return get_post_comments_feed_link($post_id, get_query_var('feed'));
612
+		elseif (get_query_var('page') && 1 < get_query_var('page'))
613
+			return trailingslashit(get_permalink($post_id)).user_trailingslashit(get_query_var('page'), 'single_paged');
614 614
 		else
615
-			return get_permalink( $post_id );
615
+			return get_permalink($post_id);
616 616
 	}
617 617
 
618 618
 	return false;
@@ -630,28 +630,28 @@  discard block
 block discarded – undo
630 630
  */
631 631
 function wp_redirect_admin_locations() {
632 632
 	global $wp_rewrite;
633
-	if ( ! ( is_404() && $wp_rewrite->using_permalinks() ) )
633
+	if ( ! (is_404() && $wp_rewrite->using_permalinks()))
634 634
 		return;
635 635
 
636 636
 	$admins = array(
637
-		home_url( 'wp-admin', 'relative' ),
638
-		home_url( 'dashboard', 'relative' ),
639
-		home_url( 'admin', 'relative' ),
640
-		site_url( 'dashboard', 'relative' ),
641
-		site_url( 'admin', 'relative' ),
637
+		home_url('wp-admin', 'relative'),
638
+		home_url('dashboard', 'relative'),
639
+		home_url('admin', 'relative'),
640
+		site_url('dashboard', 'relative'),
641
+		site_url('admin', 'relative'),
642 642
 	);
643
-	if ( in_array( untrailingslashit( $_SERVER['REQUEST_URI'] ), $admins ) ) {
644
-		wp_redirect( admin_url() );
643
+	if (in_array(untrailingslashit($_SERVER['REQUEST_URI']), $admins)) {
644
+		wp_redirect(admin_url());
645 645
 		exit;
646 646
 	}
647 647
 
648 648
 	$logins = array(
649
-		home_url( 'wp-login.php', 'relative' ),
650
-		home_url( 'login', 'relative' ),
651
-		site_url( 'login', 'relative' ),
649
+		home_url('wp-login.php', 'relative'),
650
+		home_url('login', 'relative'),
651
+		site_url('login', 'relative'),
652 652
 	);
653
-	if ( in_array( untrailingslashit( $_SERVER['REQUEST_URI'] ), $logins ) ) {
654
-		wp_redirect( wp_login_url() );
653
+	if (in_array(untrailingslashit($_SERVER['REQUEST_URI']), $logins)) {
654
+		wp_redirect(wp_login_url());
655 655
 		exit;
656 656
 	}
657 657
 }
Please login to merge, or discard this patch.
src/wp-includes/customize/class-wp-customize-nav-menu-location-control.php 1 patch
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -56,28 +56,28 @@
 block discarded – undo
56 56
 	 * @access public
57 57
 	 */
58 58
 	public function render_content() {
59
-		if ( empty( $this->choices ) ) {
59
+		if (empty($this->choices)) {
60 60
 			return;
61 61
 		}
62 62
 		?>
63 63
 		<label>
64
-			<?php if ( ! empty( $this->label ) ) : ?>
65
-			<span class="customize-control-title"><?php echo esc_html( $this->label ); ?></span>
64
+			<?php if ( ! empty($this->label)) : ?>
65
+			<span class="customize-control-title"><?php echo esc_html($this->label); ?></span>
66 66
 			<?php endif; ?>
67 67
 
68
-			<?php if ( ! empty( $this->description ) ) : ?>
68
+			<?php if ( ! empty($this->description)) : ?>
69 69
 			<span class="description customize-control-description"><?php echo $this->description; ?></span>
70 70
 			<?php endif; ?>
71 71
 
72 72
 			<select <?php $this->link(); ?>>
73 73
 				<?php
74
-				foreach ( $this->choices as $value => $label ) :
75
-					echo '<option value="' . esc_attr( $value ) . '"' . selected( $this->value(), $value, false ) . '>' . $label . '</option>';
74
+				foreach ($this->choices as $value => $label) :
75
+					echo '<option value="'.esc_attr($value).'"'.selected($this->value(), $value, false).'>'.$label.'</option>';
76 76
 				endforeach;
77 77
 				?>
78 78
 			</select>
79 79
 		</label>
80
-		<button type="button" class="button-link edit-menu<?php if ( ! $this->value() ) { echo ' hidden'; } ?>" aria-label="<?php esc_attr_e( 'Edit selected menu' ); ?>"><?php _e( 'Edit Menu' ); ?></button>
80
+		<button type="button" class="button-link edit-menu<?php if ( ! $this->value()) { echo ' hidden'; } ?>" aria-label="<?php esc_attr_e('Edit selected menu'); ?>"><?php _e('Edit Menu'); ?></button>
81 81
 		<?php
82 82
 	}
83 83
 }
Please login to merge, or discard this patch.
src/wp-includes/customize/class-wp-customize-nav-menu-section.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -36,7 +36,7 @@
 block discarded – undo
36 36
 	 */
37 37
 	public function json() {
38 38
 		$exported = parent::json();
39
-		$exported['menu_id'] = intval( preg_replace( '/^nav_menu\[(-?\d+)\]/', '$1', $this->id ) );
39
+		$exported['menu_id'] = intval(preg_replace('/^nav_menu\[(-?\d+)\]/', '$1', $this->id));
40 40
 
41 41
 		return $exported;
42 42
 	}
Please login to merge, or discard this patch.