Completed
Push — master ( cde0c6...d99bf9 )
by Stephen
15:46
created
src/wp-includes/class-wp-network.php 1 patch
Spacing   +58 added lines, -58 removed lines patch added patch discarded remove patch
@@ -96,27 +96,27 @@  discard block
 block discarded – undo
96 96
 	 * @param int $network_id The ID of the network to retrieve.
97 97
 	 * @return WP_Network|bool The network's object if found. False if not.
98 98
 	 */
99
-	public static function get_instance( $network_id ) {
99
+	public static function get_instance($network_id) {
100 100
 		global $wpdb;
101 101
 
102 102
 		$network_id = (int) $network_id;
103
-		if ( ! $network_id ) {
103
+		if ( ! $network_id) {
104 104
 			return false;
105 105
 		}
106 106
 
107
-		$_network = wp_cache_get( $network_id, 'networks' );
107
+		$_network = wp_cache_get($network_id, 'networks');
108 108
 
109
-		if ( ! $_network ) {
110
-			$_network = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM {$wpdb->site} WHERE id = %d LIMIT 1", $network_id ) );
109
+		if ( ! $_network) {
110
+			$_network = $wpdb->get_row($wpdb->prepare("SELECT * FROM {$wpdb->site} WHERE id = %d LIMIT 1", $network_id));
111 111
 
112
-			if ( empty( $_network ) || is_wp_error( $_network ) ) {
112
+			if (empty($_network) || is_wp_error($_network)) {
113 113
 				return false;
114 114
 			}
115 115
 
116
-			wp_cache_add( $network_id, $_network, 'networks' );
116
+			wp_cache_add($network_id, $_network, 'networks');
117 117
 		}
118 118
 
119
-		return new WP_Network( $_network );
119
+		return new WP_Network($_network);
120 120
 	}
121 121
 
122 122
 	/**
@@ -130,8 +130,8 @@  discard block
 block discarded – undo
130 130
 	 *
131 131
 	 * @param WP_Network|object $network A network object.
132 132
 	 */
133
-	public function __construct( $network ) {
134
-		foreach( get_object_vars( $network ) as $key => $value ) {
133
+	public function __construct($network) {
134
+		foreach (get_object_vars($network) as $key => $value) {
135 135
 			$this->$key = $value;
136 136
 		}
137 137
 
@@ -150,8 +150,8 @@  discard block
 block discarded – undo
150 150
 	 * @param string $key Property to get.
151 151
 	 * @return mixed Value of the property. Null if not available.
152 152
 	 */
153
-	public function __get( $key ) {
154
-		switch ( $key ) {
153
+	public function __get($key) {
154
+		switch ($key) {
155 155
 			case 'id';
156 156
 				return (int) $this->id;
157 157
 			case 'blog_id':
@@ -174,8 +174,8 @@  discard block
 block discarded – undo
174 174
 	 * @param string $key Property to check if set.
175 175
 	 * @return bool Whether the property is set.
176 176
 	 */
177
-	public function __isset( $key ) {
178
-		switch ( $key ) {
177
+	public function __isset($key) {
178
+		switch ($key) {
179 179
 			case 'id':
180 180
 			case 'blog_id':
181 181
 			case 'site_id':
@@ -196,8 +196,8 @@  discard block
 block discarded – undo
196 196
 	 * @param string $key   Property to set.
197 197
 	 * @param mixed  $value Value to assign to the property.
198 198
 	 */
199
-	public function __set( $key, $value ) {
200
-		switch ( $key ) {
199
+	public function __set($key, $value) {
200
+		switch ($key) {
201 201
 			case 'id':
202 202
 				$this->id = (int) $value;
203 203
 				break;
@@ -217,12 +217,12 @@  discard block
 block discarded – undo
217 217
 	 * @access private
218 218
 	 */
219 219
 	private function _set_site_name() {
220
-		if ( ! empty( $this->site_name ) ) {
220
+		if ( ! empty($this->site_name)) {
221 221
 			return;
222 222
 		}
223 223
 
224
-		$default = ucfirst( $this->domain );
225
-		$this->site_name = get_network_option( $this->id, 'site_name', $default );
224
+		$default = ucfirst($this->domain);
225
+		$this->site_name = get_network_option($this->id, 'site_name', $default);
226 226
 	}
227 227
 
228 228
 	/**
@@ -235,13 +235,13 @@  discard block
 block discarded – undo
235 235
 	 * @access private
236 236
 	 */
237 237
 	private function _set_cookie_domain() {
238
-		if ( ! empty( $this->cookie_domain ) ) {
238
+		if ( ! empty($this->cookie_domain)) {
239 239
 			return;
240 240
 		}
241 241
 
242 242
 		$this->cookie_domain = $this->domain;
243
-		if ( 'www.' === substr( $this->cookie_domain, 0, 4 ) ) {
244
-			$this->cookie_domain = substr( $this->cookie_domain, 4 );
243
+		if ('www.' === substr($this->cookie_domain, 0, 4)) {
244
+			$this->cookie_domain = substr($this->cookie_domain, 4);
245 245
 		}
246 246
 	}
247 247
 
@@ -264,19 +264,19 @@  discard block
 block discarded – undo
264 264
 	 * @param int|null $segments Path segments to use. Defaults to null, or the full path.
265 265
 	 * @return WP_Network|bool Network object if successful. False when no network is found.
266 266
 	 */
267
-	public static function get_by_path( $domain = '', $path = '', $segments = null ) {
267
+	public static function get_by_path($domain = '', $path = '', $segments = null) {
268 268
 		global $wpdb;
269 269
 
270
-		$domains = array( $domain );
271
-		$pieces  = explode( '.', $domain );
270
+		$domains = array($domain);
271
+		$pieces  = explode('.', $domain);
272 272
 
273 273
 		/*
274 274
 		 * It's possible one domain to search is 'com', but it might as well
275 275
 		 * be 'localhost' or some other locally mapped domain.
276 276
 		 */
277
-		while ( array_shift( $pieces ) ) {
278
-			if ( ! empty( $pieces ) ) {
279
-				$domains[] = implode( '.', $pieces );
277
+		while (array_shift($pieces)) {
278
+			if ( ! empty($pieces)) {
279
+				$domains[] = implode('.', $pieces);
280 280
 			}
281 281
 		}
282 282
 
@@ -290,17 +290,17 @@  discard block
 block discarded – undo
290 290
 		 * drawbacks depending on the setup, so this is best done per-install.
291 291
 		 */
292 292
 		$using_paths = true;
293
-		if ( wp_using_ext_object_cache() ) {
294
-			$using_paths = wp_cache_get( 'networks_have_paths', 'site-options' );
295
-			if ( false === $using_paths ) {
296
-				$using_paths = (int) $wpdb->get_var( "SELECT id FROM {$wpdb->site} WHERE path <> '/' LIMIT 1" );
297
-				wp_cache_add( 'networks_have_paths', $using_paths, 'site-options'  );
293
+		if (wp_using_ext_object_cache()) {
294
+			$using_paths = wp_cache_get('networks_have_paths', 'site-options');
295
+			if (false === $using_paths) {
296
+				$using_paths = (int) $wpdb->get_var("SELECT id FROM {$wpdb->site} WHERE path <> '/' LIMIT 1");
297
+				wp_cache_add('networks_have_paths', $using_paths, 'site-options');
298 298
 			}
299 299
 		}
300 300
 
301 301
 		$paths = array();
302
-		if ( $using_paths ) {
303
-			$path_segments = array_filter( explode( '/', trim( $path, '/' ) ) );
302
+		if ($using_paths) {
303
+			$path_segments = array_filter(explode('/', trim($path, '/')));
304 304
 
305 305
 			/**
306 306
 			 * Filters the number of path segments to consider when searching for a site.
@@ -313,15 +313,15 @@  discard block
 block discarded – undo
313 313
 			 * @param string   $domain   The requested domain.
314 314
 			 * @param string   $path     The requested path, in full.
315 315
 			 */
316
-			$segments = apply_filters( 'network_by_path_segments_count', $segments, $domain, $path );
316
+			$segments = apply_filters('network_by_path_segments_count', $segments, $domain, $path);
317 317
 
318
-			if ( ( null !== $segments ) && count( $path_segments ) > $segments ) {
319
-				$path_segments = array_slice( $path_segments, 0, $segments );
318
+			if ((null !== $segments) && count($path_segments) > $segments) {
319
+				$path_segments = array_slice($path_segments, 0, $segments);
320 320
 			}
321 321
 
322
-			while ( count( $path_segments ) ) {
323
-				$paths[] = '/' . implode( '/', $path_segments ) . '/';
324
-				array_pop( $path_segments );
322
+			while (count($path_segments)) {
323
+				$paths[] = '/'.implode('/', $path_segments).'/';
324
+				array_pop($path_segments);
325 325
 			}
326 326
 
327 327
 			$paths[] = '/';
@@ -346,38 +346,38 @@  discard block
 block discarded – undo
346 346
 		 *                                   Default null, meaning the entire path was to be consulted.
347 347
 		 * @param array            $paths    The paths to search for, based on $path and $segments.
348 348
 		 */
349
-		$pre = apply_filters( 'pre_get_network_by_path', null, $domain, $path, $segments, $paths );
350
-		if ( null !== $pre ) {
349
+		$pre = apply_filters('pre_get_network_by_path', null, $domain, $path, $segments, $paths);
350
+		if (null !== $pre) {
351 351
 			return $pre;
352 352
 		}
353 353
 
354 354
 		// @todo Consider additional optimization routes, perhaps as an opt-in for plugins.
355 355
 		// We already have paths covered. What about how far domains should be drilled down (including www)?
356 356
 
357
-		$search_domains = "'" . implode( "', '", $wpdb->_escape( $domains ) ) . "'";
357
+		$search_domains = "'".implode("', '", $wpdb->_escape($domains))."'";
358 358
 
359
-		if ( ! $using_paths ) {
360
-			$network = $wpdb->get_row( "
359
+		if ( ! $using_paths) {
360
+			$network = $wpdb->get_row("
361 361
 				SELECT * FROM {$wpdb->site}
362 362
 				WHERE domain IN ({$search_domains})
363 363
 				ORDER BY CHAR_LENGTH(domain)
364 364
 				DESC LIMIT 1
365
-			" );
365
+			");
366 366
 
367
-			if ( ! empty( $network ) && ! is_wp_error( $network ) ) {
368
-				return new WP_Network( $network );
367
+			if ( ! empty($network) && ! is_wp_error($network)) {
368
+				return new WP_Network($network);
369 369
 			}
370 370
 
371 371
 			return false;
372 372
 
373 373
 		} else {
374
-			$search_paths = "'" . implode( "', '", $wpdb->_escape( $paths ) ) . "'";
375
-			$networks = $wpdb->get_results( "
374
+			$search_paths = "'".implode("', '", $wpdb->_escape($paths))."'";
375
+			$networks = $wpdb->get_results("
376 376
 				SELECT * FROM {$wpdb->site}
377 377
 				WHERE domain IN ({$search_domains})
378 378
 				AND path IN ({$search_paths})
379 379
 				ORDER BY CHAR_LENGTH(domain) DESC, CHAR_LENGTH(path) DESC
380
-			" );
380
+			");
381 381
 		}
382 382
 
383 383
 		/*
@@ -386,21 +386,21 @@  discard block
 block discarded – undo
386 386
 		 * a network with the path of / will suffice.
387 387
 		 */
388 388
 		$found = false;
389
-		foreach ( $networks as $network ) {
390
-			if ( ( $network->domain === $domain ) || ( "www.{$network->domain}" === $domain ) ) {
391
-				if ( in_array( $network->path, $paths, true ) ) {
389
+		foreach ($networks as $network) {
390
+			if (($network->domain === $domain) || ("www.{$network->domain}" === $domain)) {
391
+				if (in_array($network->path, $paths, true)) {
392 392
 					$found = true;
393 393
 					break;
394 394
 				}
395 395
 			}
396
-			if ( $network->path === '/' ) {
396
+			if ($network->path === '/') {
397 397
 				$found = true;
398 398
 				break;
399 399
 			}
400 400
 		}
401 401
 
402
-		if ( true === $found ) {
403
-			return new WP_Network( $network );
402
+		if (true === $found) {
403
+			return new WP_Network($network);
404 404
 		}
405 405
 
406 406
 		return false;
Please login to merge, or discard this patch.
src/wp-includes/class-requests.php 2 patches
Braces   +11 added lines, -22 removed lines patch added patch discarded remove patch
@@ -370,8 +370,7 @@  discard block
 block discarded – undo
370 370
 			if (is_string($options['transport'])) {
371 371
 				$transport = new $transport();
372 372
 			}
373
-		}
374
-		else {
373
+		} else {
375 374
 			$need_ssl = (0 === stripos($url, 'https://'));
376 375
 			$capabilities = array('ssl' => $need_ssl);
377 376
 			$transport = self::get_transport($capabilities);
@@ -447,8 +446,7 @@  discard block
 block discarded – undo
447 446
 			if (!isset($request['options'])) {
448 447
 				$request['options'] = $options;
449 448
 				$request['options']['type'] = $request['type'];
450
-			}
451
-			else {
449
+			} else {
452 450
 				if (empty($request['options']['type'])) {
453 451
 					$request['options']['type'] = $request['type'];
454 452
 				}
@@ -473,8 +471,7 @@  discard block
 block discarded – undo
473 471
 			if (is_string($options['transport'])) {
474 472
 				$transport = new $transport();
475 473
 			}
476
-		}
477
-		else {
474
+		} else {
478 475
 			$transport = self::get_transport();
479 476
 		}
480 477
 		$responses = $transport->request_multiple($requests, $options);
@@ -584,8 +581,7 @@  discard block
 block discarded – undo
584 581
 
585 582
 		if (is_array($options['cookies'])) {
586 583
 			$options['cookies'] = new Requests_Cookie_Jar($options['cookies']);
587
-		}
588
-		elseif (empty($options['cookies'])) {
584
+		} elseif (empty($options['cookies'])) {
589 585
 			$options['cookies'] = new Requests_Cookie_Jar();
590 586
 		}
591 587
 		if ($options['cookies'] !== false) {
@@ -604,8 +600,7 @@  discard block
 block discarded – undo
604 600
 		if (!isset($options['data_format'])) {
605 601
 			if (in_array($type, array(self::HEAD, self::GET, self::DELETE))) {
606 602
 				$options['data_format'] = 'query';
607
-			}
608
-			else {
603
+			} else {
609 604
 				$options['data_format'] = 'body';
610 605
 			}
611 606
 		}
@@ -642,8 +637,7 @@  discard block
 block discarded – undo
642 637
 
643 638
 			$headers = substr($return->raw, 0, $pos);
644 639
 			$return->body = substr($return->raw, $pos + strlen("\n\r\n\r"));
645
-		}
646
-		else {
640
+		} else {
647 641
 			$return->body = '';
648 642
 		}
649 643
 		// Pretend CRLF = LF for compatibility (RFC 2616, section 19.3)
@@ -706,8 +700,7 @@  discard block
 block discarded – undo
706 700
 				$redirected = self::request($location, $req_headers, $req_data, $options['type'], $options);
707 701
 				$redirected->history[] = $return;
708 702
 				return $redirected;
709
-			}
710
-			elseif ($options['redirected'] >= $options['redirects']) {
703
+			} elseif ($options['redirected'] >= $options['redirects']) {
711 704
 				throw new Requests_Exception('Too many redirects', 'toomanyredirects', $return);
712 705
 			}
713 706
 		}
@@ -735,8 +728,7 @@  discard block
 block discarded – undo
735 728
 			$data = $request['data'];
736 729
 			$options = $request['options'];
737 730
 			$response = self::parse_response($response, $url, $headers, $data, $options);
738
-		}
739
-		catch (Requests_Exception $e) {
731
+		} catch (Requests_Exception $e) {
740 732
 			$response = $e;
741 733
 		}
742 734
 	}
@@ -826,14 +818,11 @@  discard block
 block discarded – undo
826 818
 
827 819
 		if (function_exists('gzdecode') && ($decoded = @gzdecode($data)) !== false) {
828 820
 			return $decoded;
829
-		}
830
-		elseif (function_exists('gzinflate') && ($decoded = @gzinflate($data)) !== false) {
821
+		} elseif (function_exists('gzinflate') && ($decoded = @gzinflate($data)) !== false) {
831 822
 			return $decoded;
832
-		}
833
-		elseif (($decoded = self::compatible_gzinflate($data)) !== false) {
823
+		} elseif (($decoded = self::compatible_gzinflate($data)) !== false) {
834 824
 			return $decoded;
835
-		}
836
-		elseif (function_exists('gzuncompress') && ($decoded = @gzuncompress($data)) !== false) {
825
+		} elseif (function_exists('gzuncompress') && ($decoded = @gzuncompress($data)) !== false) {
837 826
 			return $decoded;
838 827
 		}
839 828
 
Please login to merge, or discard this patch.
Spacing   +23 added lines, -23 removed lines patch added patch discarded remove patch
@@ -142,8 +142,8 @@  discard block
 block discarded – undo
142 142
 		}
143 143
 
144 144
 		$file = str_replace('_', '/', $class);
145
-		if (file_exists(dirname(__FILE__) . '/' . $file . '.php')) {
146
-			require_once(dirname(__FILE__) . '/' . $file . '.php');
145
+		if (file_exists(dirname(__FILE__).'/'.$file.'.php')) {
146
+			require_once(dirname(__FILE__).'/'.$file.'.php');
147 147
 		}
148 148
 	}
149 149
 
@@ -200,7 +200,7 @@  discard block
 block discarded – undo
200 200
 
201 201
 		// Find us a working transport
202 202
 		foreach (self::$transports as $class) {
203
-			if (!class_exists($class)) {
203
+			if ( ! class_exists($class)) {
204 204
 				continue;
205 205
 			}
206 206
 
@@ -364,7 +364,7 @@  discard block
 block discarded – undo
364 364
 
365 365
 		$options['hooks']->dispatch('requests.before_request', array(&$url, &$headers, &$data, &$type, &$options));
366 366
 
367
-		if (!empty($options['transport'])) {
367
+		if ( ! empty($options['transport'])) {
368 368
 			$transport = $options['transport'];
369 369
 
370 370
 			if (is_string($options['transport'])) {
@@ -427,24 +427,24 @@  discard block
 block discarded – undo
427 427
 	public static function request_multiple($requests, $options = array()) {
428 428
 		$options = array_merge(self::get_default_options(true), $options);
429 429
 
430
-		if (!empty($options['hooks'])) {
430
+		if ( ! empty($options['hooks'])) {
431 431
 			$options['hooks']->register('transport.internal.parse_response', array('Requests', 'parse_multiple'));
432
-			if (!empty($options['complete'])) {
432
+			if ( ! empty($options['complete'])) {
433 433
 				$options['hooks']->register('multiple.request.complete', $options['complete']);
434 434
 			}
435 435
 		}
436 436
 
437 437
 		foreach ($requests as $id => &$request) {
438
-			if (!isset($request['headers'])) {
438
+			if ( ! isset($request['headers'])) {
439 439
 				$request['headers'] = array();
440 440
 			}
441
-			if (!isset($request['data'])) {
441
+			if ( ! isset($request['data'])) {
442 442
 				$request['data'] = array();
443 443
 			}
444
-			if (!isset($request['type'])) {
444
+			if ( ! isset($request['type'])) {
445 445
 				$request['type'] = self::GET;
446 446
 			}
447
-			if (!isset($request['options'])) {
447
+			if ( ! isset($request['options'])) {
448 448
 				$request['options'] = $options;
449 449
 				$request['options']['type'] = $request['type'];
450 450
 			}
@@ -460,14 +460,14 @@  discard block
 block discarded – undo
460 460
 			// Ensure we only hook in once
461 461
 			if ($request['options']['hooks'] !== $options['hooks']) {
462 462
 				$request['options']['hooks']->register('transport.internal.parse_response', array('Requests', 'parse_multiple'));
463
-				if (!empty($request['options']['complete'])) {
463
+				if ( ! empty($request['options']['complete'])) {
464 464
 					$request['options']['hooks']->register('multiple.request.complete', $request['options']['complete']);
465 465
 				}
466 466
 			}
467 467
 		}
468 468
 		unset($request);
469 469
 
470
-		if (!empty($options['transport'])) {
470
+		if ( ! empty($options['transport'])) {
471 471
 			$transport = $options['transport'];
472 472
 
473 473
 			if (is_string($options['transport'])) {
@@ -503,7 +503,7 @@  discard block
 block discarded – undo
503 503
 		$defaults = array(
504 504
 			'timeout' => 10,
505 505
 			'connect_timeout' => 10,
506
-			'useragent' => 'php-requests/' . self::VERSION,
506
+			'useragent' => 'php-requests/'.self::VERSION,
507 507
 			'protocol_version' => 1.1,
508 508
 			'redirected' => 0,
509 509
 			'redirects' => 10,
@@ -533,11 +533,11 @@  discard block
 block discarded – undo
533 533
 	 * @return string Default certificate path.
534 534
 	 */
535 535
 	public static function get_certificate_path() {
536
-		if ( ! empty( Requests::$certificate_path ) ) {
536
+		if ( ! empty(Requests::$certificate_path)) {
537 537
 			return Requests::$certificate_path;
538 538
 		}
539 539
 
540
-		return dirname(__FILE__) . '/Requests/Transport/cacert.pem';
540
+		return dirname(__FILE__).'/Requests/Transport/cacert.pem';
541 541
 	}
542 542
 
543 543
 	/**
@@ -545,7 +545,7 @@  discard block
 block discarded – undo
545 545
 	 *
546 546
 	 * @param string $path Certificate path, pointing to a PEM file.
547 547
 	 */
548
-	public static function set_certificate_path( $path ) {
548
+	public static function set_certificate_path($path) {
549 549
 		Requests::$certificate_path = $path;
550 550
 	}
551 551
 
@@ -560,7 +560,7 @@  discard block
 block discarded – undo
560 560
 	 * @return array $options
561 561
 	 */
562 562
 	protected static function set_defaults(&$url, &$headers, &$data, &$type, &$options) {
563
-		if (!preg_match('/^http(s)?:\/\//i', $url, $matches)) {
563
+		if ( ! preg_match('/^http(s)?:\/\//i', $url, $matches)) {
564 564
 			throw new Requests_Exception('Only HTTP(S) requests are handled.', 'nonhttp', $url);
565 565
 		}
566 566
 
@@ -601,7 +601,7 @@  discard block
 block discarded – undo
601 601
 		// Massage the type to ensure we support it.
602 602
 		$type = strtoupper($type);
603 603
 
604
-		if (!isset($options['data_format'])) {
604
+		if ( ! isset($options['data_format'])) {
605 605
 			if (in_array($type, array(self::HEAD, self::GET, self::DELETE))) {
606 606
 				$options['data_format'] = 'query';
607 607
 			}
@@ -627,14 +627,14 @@  discard block
 block discarded – undo
627 627
 	 */
628 628
 	protected static function parse_response($headers, $url, $req_headers, $req_data, $options) {
629 629
 		$return = new Requests_Response();
630
-		if (!$options['blocking']) {
630
+		if ( ! $options['blocking']) {
631 631
 			return $return;
632 632
 		}
633 633
 
634 634
 		$return->raw = $headers;
635 635
 		$return->url = $url;
636 636
 
637
-		if (!$options['filename']) {
637
+		if ( ! $options['filename']) {
638 638
 			if (($pos = strpos($headers, "\r\n\r\n")) === false) {
639 639
 				// Crap!
640 640
 				throw new Requests_Exception('Missing header/body separator', 'requests.no_crlf_separator');
@@ -749,7 +749,7 @@  discard block
 block discarded – undo
749 749
 	 * @return string Decoded body
750 750
 	 */
751 751
 	protected static function decode_chunked($data) {
752
-		if (!preg_match('/^([0-9a-f]+)(?:;(?:[\w-]*)(?:=(?:(?:[\w-]*)*|"(?:[^\r\n])*"))?)*\r\n/i', trim($data))) {
752
+		if ( ! preg_match('/^([0-9a-f]+)(?:;(?:[\w-]*)(?:=(?:(?:[\w-]*)*|"(?:[^\r\n])*"))?)*\r\n/i', trim($data))) {
753 753
 			return $data;
754 754
 		}
755 755
 
@@ -760,7 +760,7 @@  discard block
 block discarded – undo
760 760
 
761 761
 		while (true) {
762 762
 			$is_chunked = (bool) preg_match('/^([0-9a-f]+)(?:;(?:[\w-]*)(?:=(?:(?:[\w-]*)*|"(?:[^\r\n])*"))?)*\r\n/i', $encoded, $matches);
763
-			if (!$is_chunked) {
763
+			if ( ! $is_chunked) {
764 764
 				// Looks like it's not chunked after all
765 765
 				return $data;
766 766
 			}
@@ -929,7 +929,7 @@  discard block
 block discarded – undo
929 929
 			// between a compressed document, and a ZIP file
930 930
 			$zip_compressed_on_the_fly = (0x08 == (0x08 & $general_purpose_flag));
931 931
 
932
-			if (!$zip_compressed_on_the_fly) {
932
+			if ( ! $zip_compressed_on_the_fly) {
933 933
 				// Don't attempt to decode a compressed zip file
934 934
 				return $gzData;
935 935
 			}
Please login to merge, or discard this patch.
src/wp-includes/l10n.php 3 patches
Braces   +36 added lines, -23 removed lines patch added patch discarded remove patch
@@ -489,14 +489,16 @@  discard block
 block discarded – undo
489 489
  * @return string Either $single or $plural translated text.
490 490
  */
491 491
 function translate_nooped_plural( $nooped_plural, $count, $domain = 'default' ) {
492
-	if ( $nooped_plural['domain'] )
493
-		$domain = $nooped_plural['domain'];
492
+	if ( $nooped_plural['domain'] ) {
493
+			$domain = $nooped_plural['domain'];
494
+	}
494 495
 
495
-	if ( $nooped_plural['context'] )
496
-		return _nx( $nooped_plural['singular'], $nooped_plural['plural'], $count, $nooped_plural['context'], $domain );
497
-	else
498
-		return _n( $nooped_plural['singular'], $nooped_plural['plural'], $count, $domain );
499
-}
496
+	if ( $nooped_plural['context'] ) {
497
+			return _nx( $nooped_plural['singular'], $nooped_plural['plural'], $count, $nooped_plural['context'], $domain );
498
+	} else {
499
+			return _n( $nooped_plural['singular'], $nooped_plural['plural'], $count, $domain );
500
+	}
501
+	}
500 502
 
501 503
 /**
502 504
  * Load a .mo file into the text domain $domain.
@@ -558,13 +560,18 @@  discard block
 block discarded – undo
558 560
 	 */
559 561
 	$mofile = apply_filters( 'load_textdomain_mofile', $mofile, $domain );
560 562
 
561
-	if ( !is_readable( $mofile ) ) return false;
563
+	if ( !is_readable( $mofile ) ) {
564
+		return false;
565
+	}
562 566
 
563 567
 	$mo = new MO();
564
-	if ( !$mo->import_from_file( $mofile ) ) return false;
568
+	if ( !$mo->import_from_file( $mofile ) ) {
569
+		return false;
570
+	}
565 571
 
566
-	if ( isset( $l10n[$domain] ) )
567
-		$mo->merge_with( $l10n[$domain] );
572
+	if ( isset( $l10n[$domain] ) ) {
573
+			$mo->merge_with( $l10n[$domain] );
574
+	}
568 575
 
569 576
 	unset( $l10n_unloaded[ $domain ] );
570 577
 
@@ -657,8 +664,9 @@  discard block
 block discarded – undo
657 664
 		load_textdomain( 'default', WP_LANG_DIR . "/admin-$locale.mo" );
658 665
 	}
659 666
 
660
-	if ( is_network_admin() || ( defined( 'WP_INSTALLING_NETWORK' ) && WP_INSTALLING_NETWORK ) )
661
-		load_textdomain( 'default', WP_LANG_DIR . "/admin-network-$locale.mo" );
667
+	if ( is_network_admin() || ( defined( 'WP_INSTALLING_NETWORK' ) && WP_INSTALLING_NETWORK ) ) {
668
+			load_textdomain( 'default', WP_LANG_DIR . "/admin-network-$locale.mo" );
669
+	}
662 670
 
663 671
 	return $return;
664 672
 }
@@ -793,8 +801,9 @@  discard block
 block discarded – undo
793 801
  * @return bool True when the theme textdomain is successfully loaded, false otherwise.
794 802
  */
795 803
 function load_child_theme_textdomain( $domain, $path = false ) {
796
-	if ( ! $path )
797
-		$path = get_stylesheet_directory();
804
+	if ( ! $path ) {
805
+			$path = get_stylesheet_directory();
806
+	}
798 807
 	return load_theme_textdomain( $domain, $path );
799 808
 }
800 809
 
@@ -957,20 +966,24 @@  discard block
 block discarded – undo
957 966
  * @return array Array of language data.
958 967
  */
959 968
 function wp_get_installed_translations( $type ) {
960
-	if ( $type !== 'themes' && $type !== 'plugins' && $type !== 'core' )
961
-		return array();
969
+	if ( $type !== 'themes' && $type !== 'plugins' && $type !== 'core' ) {
970
+			return array();
971
+	}
962 972
 
963 973
 	$dir = 'core' === $type ? '' : "/$type";
964 974
 
965
-	if ( ! is_dir( WP_LANG_DIR ) )
966
-		return array();
975
+	if ( ! is_dir( WP_LANG_DIR ) ) {
976
+			return array();
977
+	}
967 978
 
968
-	if ( $dir && ! is_dir( WP_LANG_DIR . $dir ) )
969
-		return array();
979
+	if ( $dir && ! is_dir( WP_LANG_DIR . $dir ) ) {
980
+			return array();
981
+	}
970 982
 
971 983
 	$files = scandir( WP_LANG_DIR . $dir );
972
-	if ( ! $files )
973
-		return array();
984
+	if ( ! $files ) {
985
+			return array();
986
+	}
974 987
 
975 988
 	$language_data = array();
976 989
 
Please login to merge, or discard this patch.
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -83,7 +83,7 @@
 block discarded – undo
83 83
  *
84 84
  * @since 4.7.0
85 85
  *
86
- * @param int|WP_User $user_id User's ID or a WP_User object. Defaults to current user.
86
+ * @param integer $user_id User's ID or a WP_User object. Defaults to current user.
87 87
  * @return string The locale of the user.
88 88
  */
89 89
 function get_user_locale( $user_id = 0 ) {
Please login to merge, or discard this patch.
Spacing   +214 added lines, -214 removed lines patch added patch discarded remove patch
@@ -30,7 +30,7 @@  discard block
 block discarded – undo
30 30
 function get_locale() {
31 31
 	global $locale, $wp_local_package;
32 32
 
33
-	if ( isset( $locale ) ) {
33
+	if (isset($locale)) {
34 34
 		/**
35 35
 		 * Filters WordPress install's locale ID.
36 36
 		 *
@@ -38,41 +38,41 @@  discard block
 block discarded – undo
38 38
 		 *
39 39
 		 * @param string $locale The locale ID.
40 40
 		 */
41
-		return apply_filters( 'locale', $locale );
41
+		return apply_filters('locale', $locale);
42 42
 	}
43 43
 
44
-	if ( isset( $wp_local_package ) ) {
44
+	if (isset($wp_local_package)) {
45 45
 		$locale = $wp_local_package;
46 46
 	}
47 47
 
48 48
 	// WPLANG was defined in wp-config.
49
-	if ( defined( 'WPLANG' ) ) {
49
+	if (defined('WPLANG')) {
50 50
 		$locale = WPLANG;
51 51
 	}
52 52
 
53 53
 	// If multisite, check options.
54
-	if ( is_multisite() ) {
54
+	if (is_multisite()) {
55 55
 		// Don't check blog option when installing.
56
-		if ( wp_installing() || ( false === $ms_locale = get_option( 'WPLANG' ) ) ) {
57
-			$ms_locale = get_site_option( 'WPLANG' );
56
+		if (wp_installing() || (false === $ms_locale = get_option('WPLANG'))) {
57
+			$ms_locale = get_site_option('WPLANG');
58 58
 		}
59 59
 
60
-		if ( $ms_locale !== false ) {
60
+		if ($ms_locale !== false) {
61 61
 			$locale = $ms_locale;
62 62
 		}
63 63
 	} else {
64
-		$db_locale = get_option( 'WPLANG' );
65
-		if ( $db_locale !== false ) {
64
+		$db_locale = get_option('WPLANG');
65
+		if ($db_locale !== false) {
66 66
 			$locale = $db_locale;
67 67
 		}
68 68
 	}
69 69
 
70
-	if ( empty( $locale ) ) {
70
+	if (empty($locale)) {
71 71
 		$locale = 'en_US';
72 72
 	}
73 73
 
74 74
 	/** This filter is documented in wp-includes/l10n.php */
75
-	return apply_filters( 'locale', $locale );
75
+	return apply_filters('locale', $locale);
76 76
 }
77 77
 
78 78
 /**
@@ -86,17 +86,17 @@  discard block
 block discarded – undo
86 86
  * @param int|WP_User $user_id User's ID or a WP_User object. Defaults to current user.
87 87
  * @return string The locale of the user.
88 88
  */
89
-function get_user_locale( $user_id = 0 ) {
89
+function get_user_locale($user_id = 0) {
90 90
 	$user = false;
91
-	if ( 0 === $user_id && function_exists( 'wp_get_current_user' ) ) {
91
+	if (0 === $user_id && function_exists('wp_get_current_user')) {
92 92
 		$user = wp_get_current_user();
93
-	} elseif ( $user_id instanceof WP_User ) {
93
+	} elseif ($user_id instanceof WP_User) {
94 94
 		$user = $user_id;
95
-	} elseif ( $user_id && is_numeric( $user_id ) ) {
96
-		$user = get_user_by( 'id', $user_id );
95
+	} elseif ($user_id && is_numeric($user_id)) {
96
+		$user = get_user_by('id', $user_id);
97 97
 	}
98 98
 
99
-	if ( ! $user ) {
99
+	if ( ! $user) {
100 100
 		return get_locale();
101 101
 	}
102 102
 
@@ -118,9 +118,9 @@  discard block
 block discarded – undo
118 118
  *                       Default 'default'.
119 119
  * @return string Translated text
120 120
  */
121
-function translate( $text, $domain = 'default' ) {
122
-	$translations = get_translations_for_domain( $domain );
123
-	$translation  = $translations->translate( $text );
121
+function translate($text, $domain = 'default') {
122
+	$translations = get_translations_for_domain($domain);
123
+	$translation  = $translations->translate($text);
124 124
 
125 125
 	/**
126 126
 	 * Filters text with its translation.
@@ -131,7 +131,7 @@  discard block
 block discarded – undo
131 131
 	 * @param string $text         Text to translate.
132 132
 	 * @param string $domain       Text domain. Unique identifier for retrieving translated strings.
133 133
 	 */
134
-	return apply_filters( 'gettext', $translation, $text, $domain );
134
+	return apply_filters('gettext', $translation, $text, $domain);
135 135
 }
136 136
 
137 137
 /**
@@ -145,12 +145,12 @@  discard block
 block discarded – undo
145 145
  * @param string $string A pipe-delimited string.
146 146
  * @return string Either $string or everything before the last pipe.
147 147
  */
148
-function before_last_bar( $string ) {
149
-	$last_bar = strrpos( $string, '|' );
150
-	if ( false === $last_bar ) {
148
+function before_last_bar($string) {
149
+	$last_bar = strrpos($string, '|');
150
+	if (false === $last_bar) {
151 151
 		return $string;
152 152
 	} else {
153
-		return substr( $string, 0, $last_bar );
153
+		return substr($string, 0, $last_bar);
154 154
 	}
155 155
 }
156 156
 
@@ -170,9 +170,9 @@  discard block
 block discarded – undo
170 170
  *                        Default 'default'.
171 171
  * @return string Translated text on success, original text on failure.
172 172
  */
173
-function translate_with_gettext_context( $text, $context, $domain = 'default' ) {
174
-	$translations = get_translations_for_domain( $domain );
175
-	$translation  = $translations->translate( $text, $context );
173
+function translate_with_gettext_context($text, $context, $domain = 'default') {
174
+	$translations = get_translations_for_domain($domain);
175
+	$translation  = $translations->translate($text, $context);
176 176
 	/**
177 177
 	 * Filters text with its translation based on context information.
178 178
 	 *
@@ -183,7 +183,7 @@  discard block
 block discarded – undo
183 183
 	 * @param string $context      Context information for the translators.
184 184
 	 * @param string $domain       Text domain. Unique identifier for retrieving translated strings.
185 185
 	 */
186
-	return apply_filters( 'gettext_with_context', $translation, $text, $context, $domain );
186
+	return apply_filters('gettext_with_context', $translation, $text, $context, $domain);
187 187
 }
188 188
 
189 189
 /**
@@ -198,8 +198,8 @@  discard block
 block discarded – undo
198 198
  *                       Default 'default'.
199 199
  * @return string Translated text.
200 200
  */
201
-function __( $text, $domain = 'default' ) {
202
-	return translate( $text, $domain );
201
+function __($text, $domain = 'default') {
202
+	return translate($text, $domain);
203 203
 }
204 204
 
205 205
 /**
@@ -214,8 +214,8 @@  discard block
 block discarded – undo
214 214
  *                       Default 'default'.
215 215
  * @return string Translated text on success, original text on failure.
216 216
  */
217
-function esc_attr__( $text, $domain = 'default' ) {
218
-	return esc_attr( translate( $text, $domain ) );
217
+function esc_attr__($text, $domain = 'default') {
218
+	return esc_attr(translate($text, $domain));
219 219
 }
220 220
 
221 221
 /**
@@ -230,8 +230,8 @@  discard block
 block discarded – undo
230 230
  *                       Default 'default'.
231 231
  * @return string Translated text
232 232
  */
233
-function esc_html__( $text, $domain = 'default' ) {
234
-	return esc_html( translate( $text, $domain ) );
233
+function esc_html__($text, $domain = 'default') {
234
+	return esc_html(translate($text, $domain));
235 235
 }
236 236
 
237 237
 /**
@@ -243,8 +243,8 @@  discard block
 block discarded – undo
243 243
  * @param string $domain Optional. Text domain. Unique identifier for retrieving translated strings.
244 244
  *                       Default 'default'.
245 245
  */
246
-function _e( $text, $domain = 'default' ) {
247
-	echo translate( $text, $domain );
246
+function _e($text, $domain = 'default') {
247
+	echo translate($text, $domain);
248 248
 }
249 249
 
250 250
 /**
@@ -256,8 +256,8 @@  discard block
 block discarded – undo
256 256
  * @param string $domain Optional. Text domain. Unique identifier for retrieving translated strings.
257 257
  *                       Default 'default'.
258 258
  */
259
-function esc_attr_e( $text, $domain = 'default' ) {
260
-	echo esc_attr( translate( $text, $domain ) );
259
+function esc_attr_e($text, $domain = 'default') {
260
+	echo esc_attr(translate($text, $domain));
261 261
 }
262 262
 
263 263
 /**
@@ -269,8 +269,8 @@  discard block
 block discarded – undo
269 269
  * @param string $domain Optional. Text domain. Unique identifier for retrieving translated strings.
270 270
  *                       Default 'default'.
271 271
  */
272
-function esc_html_e( $text, $domain = 'default' ) {
273
-	echo esc_html( translate( $text, $domain ) );
272
+function esc_html_e($text, $domain = 'default') {
273
+	echo esc_html(translate($text, $domain));
274 274
 }
275 275
 
276 276
 /**
@@ -290,8 +290,8 @@  discard block
 block discarded – undo
290 290
  *                        Default 'default'.
291 291
  * @return string Translated context string without pipe.
292 292
  */
293
-function _x( $text, $context, $domain = 'default' ) {
294
-	return translate_with_gettext_context( $text, $context, $domain );
293
+function _x($text, $context, $domain = 'default') {
294
+	return translate_with_gettext_context($text, $context, $domain);
295 295
 }
296 296
 
297 297
 /**
@@ -305,8 +305,8 @@  discard block
 block discarded – undo
305 305
  *                        Default 'default'.
306 306
  * @return string Translated context string without pipe.
307 307
  */
308
-function _ex( $text, $context, $domain = 'default' ) {
309
-	echo _x( $text, $context, $domain );
308
+function _ex($text, $context, $domain = 'default') {
309
+	echo _x($text, $context, $domain);
310 310
 }
311 311
 
312 312
 /**
@@ -320,8 +320,8 @@  discard block
 block discarded – undo
320 320
  *                        Default 'default'.
321 321
  * @return string Translated text
322 322
  */
323
-function esc_attr_x( $text, $context, $domain = 'default' ) {
324
-	return esc_attr( translate_with_gettext_context( $text, $context, $domain ) );
323
+function esc_attr_x($text, $context, $domain = 'default') {
324
+	return esc_attr(translate_with_gettext_context($text, $context, $domain));
325 325
 }
326 326
 
327 327
 /**
@@ -335,8 +335,8 @@  discard block
 block discarded – undo
335 335
  *                        Default 'default'.
336 336
  * @return string Translated text.
337 337
  */
338
-function esc_html_x( $text, $context, $domain = 'default' ) {
339
-	return esc_html( translate_with_gettext_context( $text, $context, $domain ) );
338
+function esc_html_x($text, $context, $domain = 'default') {
339
+	return esc_html(translate_with_gettext_context($text, $context, $domain));
340 340
 }
341 341
 
342 342
 /**
@@ -358,9 +358,9 @@  discard block
 block discarded – undo
358 358
  *                       Default 'default'.
359 359
  * @return string The translated singular or plural form.
360 360
  */
361
-function _n( $single, $plural, $number, $domain = 'default' ) {
362
-	$translations = get_translations_for_domain( $domain );
363
-	$translation  = $translations->translate_plural( $single, $plural, $number );
361
+function _n($single, $plural, $number, $domain = 'default') {
362
+	$translations = get_translations_for_domain($domain);
363
+	$translation  = $translations->translate_plural($single, $plural, $number);
364 364
 
365 365
 	/**
366 366
 	 * Filters the singular or plural form of a string.
@@ -373,7 +373,7 @@  discard block
 block discarded – undo
373 373
 	 * @param string $number      The number to compare against to use either the singular or plural form.
374 374
 	 * @param string $domain      Text domain. Unique identifier for retrieving translated strings.
375 375
 	 */
376
-	return apply_filters( 'ngettext', $translation, $single, $plural, $number, $domain );
376
+	return apply_filters('ngettext', $translation, $single, $plural, $number, $domain);
377 377
 }
378 378
 
379 379
 /**
@@ -400,8 +400,8 @@  discard block
 block discarded – undo
400 400
  * @return string The translated singular or plural form.
401 401
  */
402 402
 function _nx($single, $plural, $number, $context, $domain = 'default') {
403
-	$translations = get_translations_for_domain( $domain );
404
-	$translation  = $translations->translate_plural( $single, $plural, $number, $context );
403
+	$translations = get_translations_for_domain($domain);
404
+	$translation  = $translations->translate_plural($single, $plural, $number, $context);
405 405
 
406 406
 	/**
407 407
 	 * Filters the singular or plural form of a string with gettext context.
@@ -415,7 +415,7 @@  discard block
 block discarded – undo
415 415
 	 * @param string $context     Context information for the translators.
416 416
 	 * @param string $domain      Text domain. Unique identifier for retrieving translated strings.
417 417
 	 */
418
-	return apply_filters( 'ngettext_with_context', $translation, $single, $plural, $number, $context, $domain );
418
+	return apply_filters('ngettext_with_context', $translation, $single, $plural, $number, $context, $domain);
419 419
 }
420 420
 
421 421
 /**
@@ -447,8 +447,8 @@  discard block
 block discarded – undo
447 447
  *     @type string $domain   Text domain.
448 448
  * }
449 449
  */
450
-function _n_noop( $singular, $plural, $domain = null ) {
451
-	return array( 0 => $singular, 1 => $plural, 'singular' => $singular, 'plural' => $plural, 'context' => null, 'domain' => $domain );
450
+function _n_noop($singular, $plural, $domain = null) {
451
+	return array(0 => $singular, 1 => $plural, 'singular' => $singular, 'plural' => $plural, 'context' => null, 'domain' => $domain);
452 452
 }
453 453
 
454 454
 /**
@@ -486,8 +486,8 @@  discard block
 block discarded – undo
486 486
  *     @type string $domain   Text domain.
487 487
  * }
488 488
  */
489
-function _nx_noop( $singular, $plural, $context, $domain = null ) {
490
-	return array( 0 => $singular, 1 => $plural, 2 => $context, 'singular' => $singular, 'plural' => $plural, 'context' => $context, 'domain' => $domain );
489
+function _nx_noop($singular, $plural, $context, $domain = null) {
490
+	return array(0 => $singular, 1 => $plural, 2 => $context, 'singular' => $singular, 'plural' => $plural, 'context' => $context, 'domain' => $domain);
491 491
 }
492 492
 
493 493
 /**
@@ -510,14 +510,14 @@  discard block
 block discarded – undo
510 510
  *                              a text domain passed to _n_noop() or _nx_noop(), it will override this value. Default 'default'.
511 511
  * @return string Either $single or $plural translated text.
512 512
  */
513
-function translate_nooped_plural( $nooped_plural, $count, $domain = 'default' ) {
514
-	if ( $nooped_plural['domain'] )
513
+function translate_nooped_plural($nooped_plural, $count, $domain = 'default') {
514
+	if ($nooped_plural['domain'])
515 515
 		$domain = $nooped_plural['domain'];
516 516
 
517
-	if ( $nooped_plural['context'] )
518
-		return _nx( $nooped_plural['singular'], $nooped_plural['plural'], $count, $nooped_plural['context'], $domain );
517
+	if ($nooped_plural['context'])
518
+		return _nx($nooped_plural['singular'], $nooped_plural['plural'], $count, $nooped_plural['context'], $domain);
519 519
 	else
520
-		return _n( $nooped_plural['singular'], $nooped_plural['plural'], $count, $domain );
520
+		return _n($nooped_plural['singular'], $nooped_plural['plural'], $count, $domain);
521 521
 }
522 522
 
523 523
 /**
@@ -538,7 +538,7 @@  discard block
 block discarded – undo
538 538
  * @param string $mofile Path to the .mo file.
539 539
  * @return bool True on success, false on failure.
540 540
  */
541
-function load_textdomain( $domain, $mofile ) {
541
+function load_textdomain($domain, $mofile) {
542 542
 	global $l10n, $l10n_unloaded;
543 543
 
544 544
 	$l10n_unloaded = (array) $l10n_unloaded;
@@ -552,10 +552,10 @@  discard block
 block discarded – undo
552 552
 	 * @param string $domain   Text domain. Unique identifier for retrieving translated strings.
553 553
 	 * @param string $mofile   Path to the MO file.
554 554
 	 */
555
-	$plugin_override = apply_filters( 'override_load_textdomain', false, $domain, $mofile );
555
+	$plugin_override = apply_filters('override_load_textdomain', false, $domain, $mofile);
556 556
 
557
-	if ( true == $plugin_override ) {
558
-		unset( $l10n_unloaded[ $domain ] );
557
+	if (true == $plugin_override) {
558
+		unset($l10n_unloaded[$domain]);
559 559
 
560 560
 		return true;
561 561
 	}
@@ -568,7 +568,7 @@  discard block
 block discarded – undo
568 568
 	 * @param string $domain Text domain. Unique identifier for retrieving translated strings.
569 569
 	 * @param string $mofile Path to the .mo file.
570 570
 	 */
571
-	do_action( 'load_textdomain', $domain, $mofile );
571
+	do_action('load_textdomain', $domain, $mofile);
572 572
 
573 573
 	/**
574 574
 	 * Filters MO file path for loading translations for a specific text domain.
@@ -578,17 +578,17 @@  discard block
 block discarded – undo
578 578
 	 * @param string $mofile Path to the MO file.
579 579
 	 * @param string $domain Text domain. Unique identifier for retrieving translated strings.
580 580
 	 */
581
-	$mofile = apply_filters( 'load_textdomain_mofile', $mofile, $domain );
581
+	$mofile = apply_filters('load_textdomain_mofile', $mofile, $domain);
582 582
 
583
-	if ( !is_readable( $mofile ) ) return false;
583
+	if ( ! is_readable($mofile)) return false;
584 584
 
585 585
 	$mo = new MO();
586
-	if ( !$mo->import_from_file( $mofile ) ) return false;
586
+	if ( ! $mo->import_from_file($mofile)) return false;
587 587
 
588
-	if ( isset( $l10n[$domain] ) )
589
-		$mo->merge_with( $l10n[$domain] );
588
+	if (isset($l10n[$domain]))
589
+		$mo->merge_with($l10n[$domain]);
590 590
 
591
-	unset( $l10n_unloaded[ $domain ] );
591
+	unset($l10n_unloaded[$domain]);
592 592
 
593 593
 	$l10n[$domain] = &$mo;
594 594
 
@@ -606,7 +606,7 @@  discard block
 block discarded – undo
606 606
  * @param string $domain Text domain. Unique identifier for retrieving translated strings.
607 607
  * @return bool Whether textdomain was unloaded.
608 608
  */
609
-function unload_textdomain( $domain ) {
609
+function unload_textdomain($domain) {
610 610
 	global $l10n, $l10n_unloaded;
611 611
 
612 612
 	$l10n_unloaded = (array) $l10n_unloaded;
@@ -619,10 +619,10 @@  discard block
 block discarded – undo
619 619
 	 * @param bool   $override Whether to override the text domain unloading. Default false.
620 620
 	 * @param string $domain   Text domain. Unique identifier for retrieving translated strings.
621 621
 	 */
622
-	$plugin_override = apply_filters( 'override_unload_textdomain', false, $domain );
622
+	$plugin_override = apply_filters('override_unload_textdomain', false, $domain);
623 623
 
624
-	if ( $plugin_override ) {
625
-		$l10n_unloaded[ $domain ] = true;
624
+	if ($plugin_override) {
625
+		$l10n_unloaded[$domain] = true;
626 626
 
627 627
 		return true;
628 628
 	}
@@ -634,12 +634,12 @@  discard block
 block discarded – undo
634 634
 	 *
635 635
 	 * @param string $domain Text domain. Unique identifier for retrieving translated strings.
636 636
 	 */
637
-	do_action( 'unload_textdomain', $domain );
637
+	do_action('unload_textdomain', $domain);
638 638
 
639
-	if ( isset( $l10n[$domain] ) ) {
640
-		unset( $l10n[$domain] );
639
+	if (isset($l10n[$domain])) {
640
+		unset($l10n[$domain]);
641 641
 
642
-		$l10n_unloaded[ $domain ] = true;
642
+		$l10n_unloaded[$domain] = true;
643 643
 
644 644
 		return true;
645 645
 	}
@@ -660,27 +660,27 @@  discard block
 block discarded – undo
660 660
  * @param string $locale Optional. Locale to load. Default is the value of get_locale().
661 661
  * @return bool Whether the textdomain was loaded.
662 662
  */
663
-function load_default_textdomain( $locale = null ) {
664
-	if ( null === $locale ) {
663
+function load_default_textdomain($locale = null) {
664
+	if (null === $locale) {
665 665
 		$locale = is_admin() ? get_user_locale() : get_locale();
666 666
 	}
667 667
 
668 668
 	// Unload previously loaded strings so we can switch translations.
669
-	unload_textdomain( 'default' );
669
+	unload_textdomain('default');
670 670
 
671
-	$return = load_textdomain( 'default', WP_LANG_DIR . "/$locale.mo" );
671
+	$return = load_textdomain('default', WP_LANG_DIR."/$locale.mo");
672 672
 
673
-	if ( ( is_multisite() || ( defined( 'WP_INSTALLING_NETWORK' ) && WP_INSTALLING_NETWORK ) ) && ! file_exists(  WP_LANG_DIR . "/admin-$locale.mo" ) ) {
674
-		load_textdomain( 'default', WP_LANG_DIR . "/ms-$locale.mo" );
673
+	if ((is_multisite() || (defined('WP_INSTALLING_NETWORK') && WP_INSTALLING_NETWORK)) && ! file_exists(WP_LANG_DIR."/admin-$locale.mo")) {
674
+		load_textdomain('default', WP_LANG_DIR."/ms-$locale.mo");
675 675
 		return $return;
676 676
 	}
677 677
 
678
-	if ( is_admin() || wp_installing() || ( defined( 'WP_REPAIRING' ) && WP_REPAIRING ) ) {
679
-		load_textdomain( 'default', WP_LANG_DIR . "/admin-$locale.mo" );
678
+	if (is_admin() || wp_installing() || (defined('WP_REPAIRING') && WP_REPAIRING)) {
679
+		load_textdomain('default', WP_LANG_DIR."/admin-$locale.mo");
680 680
 	}
681 681
 
682
-	if ( is_network_admin() || ( defined( 'WP_INSTALLING_NETWORK' ) && WP_INSTALLING_NETWORK ) )
683
-		load_textdomain( 'default', WP_LANG_DIR . "/admin-network-$locale.mo" );
682
+	if (is_network_admin() || (defined('WP_INSTALLING_NETWORK') && WP_INSTALLING_NETWORK))
683
+		load_textdomain('default', WP_LANG_DIR."/admin-network-$locale.mo");
684 684
 
685 685
 	return $return;
686 686
 }
@@ -701,7 +701,7 @@  discard block
 block discarded – undo
701 701
  *                                Default false.
702 702
  * @return bool True when textdomain is successfully loaded, false otherwise.
703 703
  */
704
-function load_plugin_textdomain( $domain, $deprecated = false, $plugin_rel_path = false ) {
704
+function load_plugin_textdomain($domain, $deprecated = false, $plugin_rel_path = false) {
705 705
 	/**
706 706
 	 * Filters a plugin's locale.
707 707
 	 *
@@ -710,25 +710,25 @@  discard block
 block discarded – undo
710 710
 	 * @param string $locale The plugin's current locale.
711 711
 	 * @param string $domain Text domain. Unique identifier for retrieving translated strings.
712 712
 	 */
713
-	$locale = apply_filters( 'plugin_locale', is_admin() ? get_user_locale() : get_locale(), $domain );
713
+	$locale = apply_filters('plugin_locale', is_admin() ? get_user_locale() : get_locale(), $domain);
714 714
 
715
-	$mofile = $domain . '-' . $locale . '.mo';
715
+	$mofile = $domain.'-'.$locale.'.mo';
716 716
 
717 717
 	// Try to load from the languages directory first.
718
-	if ( load_textdomain( $domain, WP_LANG_DIR . '/plugins/' . $mofile ) ) {
718
+	if (load_textdomain($domain, WP_LANG_DIR.'/plugins/'.$mofile)) {
719 719
 		return true;
720 720
 	}
721 721
 
722
-	if ( false !== $plugin_rel_path ) {
723
-		$path = WP_PLUGIN_DIR . '/' . trim( $plugin_rel_path, '/' );
724
-	} elseif ( false !== $deprecated ) {
725
-		_deprecated_argument( __FUNCTION__, '2.7.0' );
726
-		$path = ABSPATH . trim( $deprecated, '/' );
722
+	if (false !== $plugin_rel_path) {
723
+		$path = WP_PLUGIN_DIR.'/'.trim($plugin_rel_path, '/');
724
+	} elseif (false !== $deprecated) {
725
+		_deprecated_argument(__FUNCTION__, '2.7.0');
726
+		$path = ABSPATH.trim($deprecated, '/');
727 727
 	} else {
728 728
 		$path = WP_PLUGIN_DIR;
729 729
 	}
730 730
 
731
-	return load_textdomain( $domain, $path . '/' . $mofile );
731
+	return load_textdomain($domain, $path.'/'.$mofile);
732 732
 }
733 733
 
734 734
 /**
@@ -742,20 +742,20 @@  discard block
 block discarded – undo
742 742
  *                                   file resides. Default empty string.
743 743
  * @return bool True when textdomain is successfully loaded, false otherwise.
744 744
  */
745
-function load_muplugin_textdomain( $domain, $mu_plugin_rel_path = '' ) {
745
+function load_muplugin_textdomain($domain, $mu_plugin_rel_path = '') {
746 746
 	/** This filter is documented in wp-includes/l10n.php */
747
-	$locale = apply_filters( 'plugin_locale', is_admin() ? get_user_locale() : get_locale(), $domain );
747
+	$locale = apply_filters('plugin_locale', is_admin() ? get_user_locale() : get_locale(), $domain);
748 748
 
749
-	$mofile = $domain . '-' . $locale . '.mo';
749
+	$mofile = $domain.'-'.$locale.'.mo';
750 750
 
751 751
 	// Try to load from the languages directory first.
752
-	if ( load_textdomain( $domain, WP_LANG_DIR . '/plugins/' . $mofile ) ) {
752
+	if (load_textdomain($domain, WP_LANG_DIR.'/plugins/'.$mofile)) {
753 753
 		return true;
754 754
 	}
755 755
 
756
-	$path = trailingslashit( WPMU_PLUGIN_DIR . '/' . ltrim( $mu_plugin_rel_path, '/' ) );
756
+	$path = trailingslashit(WPMU_PLUGIN_DIR.'/'.ltrim($mu_plugin_rel_path, '/'));
757 757
 
758
-	return load_textdomain( $domain, $path . '/' . $mofile );
758
+	return load_textdomain($domain, $path.'/'.$mofile);
759 759
 }
760 760
 
761 761
 /**
@@ -774,7 +774,7 @@  discard block
 block discarded – undo
774 774
  *                       Default false.
775 775
  * @return bool True when textdomain is successfully loaded, false otherwise.
776 776
  */
777
-function load_theme_textdomain( $domain, $path = false ) {
777
+function load_theme_textdomain($domain, $path = false) {
778 778
 	/**
779 779
 	 * Filters a theme's locale.
780 780
 	 *
@@ -783,20 +783,20 @@  discard block
 block discarded – undo
783 783
 	 * @param string $locale The theme's current locale.
784 784
 	 * @param string $domain Text domain. Unique identifier for retrieving translated strings.
785 785
 	 */
786
-	$locale = apply_filters( 'theme_locale', is_admin() ? get_user_locale() : get_locale(), $domain );
786
+	$locale = apply_filters('theme_locale', is_admin() ? get_user_locale() : get_locale(), $domain);
787 787
 
788
-	$mofile = $domain . '-' . $locale . '.mo';
788
+	$mofile = $domain.'-'.$locale.'.mo';
789 789
 
790 790
 	// Try to load from the languages directory first.
791
-	if ( load_textdomain( $domain, WP_LANG_DIR . '/themes/' . $mofile ) ) {
791
+	if (load_textdomain($domain, WP_LANG_DIR.'/themes/'.$mofile)) {
792 792
 		return true;
793 793
 	}
794 794
 
795
-	if ( ! $path ) {
795
+	if ( ! $path) {
796 796
 		$path = get_template_directory();
797 797
 	}
798 798
 
799
-	return load_textdomain( $domain, $path . '/' . $locale . '.mo' );
799
+	return load_textdomain($domain, $path.'/'.$locale.'.mo');
800 800
 }
801 801
 
802 802
 /**
@@ -814,10 +814,10 @@  discard block
 block discarded – undo
814 814
  *                       Default false.
815 815
  * @return bool True when the theme textdomain is successfully loaded, false otherwise.
816 816
  */
817
-function load_child_theme_textdomain( $domain, $path = false ) {
818
-	if ( ! $path )
817
+function load_child_theme_textdomain($domain, $path = false) {
818
+	if ( ! $path)
819 819
 		$path = get_stylesheet_directory();
820
-	return load_theme_textdomain( $domain, $path );
820
+	return load_theme_textdomain($domain, $path);
821 821
 }
822 822
 
823 823
 /**
@@ -836,22 +836,22 @@  discard block
 block discarded – undo
836 836
  * @param string $domain Text domain. Unique identifier for retrieving translated strings.
837 837
  * @return bool True when the textdomain is successfully loaded, false otherwise.
838 838
  */
839
-function _load_textdomain_just_in_time( $domain ) {
839
+function _load_textdomain_just_in_time($domain) {
840 840
 	global $l10n_unloaded;
841 841
 
842 842
 	$l10n_unloaded = (array) $l10n_unloaded;
843 843
 
844 844
 	// Short-circuit if domain is 'default' which is reserved for core.
845
-	if ( 'default' === $domain || isset( $l10n_unloaded[ $domain ] ) ) {
845
+	if ('default' === $domain || isset($l10n_unloaded[$domain])) {
846 846
 		return false;
847 847
 	}
848 848
 
849
-	$translation_path = _get_path_to_translation( $domain );
850
-	if ( false === $translation_path ) {
849
+	$translation_path = _get_path_to_translation($domain);
850
+	if (false === $translation_path) {
851 851
 		return false;
852 852
 	}
853 853
 
854
-	return load_textdomain( $domain, $translation_path );
854
+	return load_textdomain($domain, $translation_path);
855 855
 }
856 856
 
857 857
 /**
@@ -868,18 +868,18 @@  discard block
 block discarded – undo
868 868
  * @param bool   $reset  Whether to reset the internal cache. Used by the switch to locale functionality.
869 869
  * @return string|false The path to the translation file or false if no translation file was found.
870 870
  */
871
-function _get_path_to_translation( $domain, $reset = false ) {
871
+function _get_path_to_translation($domain, $reset = false) {
872 872
 	static $available_translations = array();
873 873
 
874
-	if ( true === $reset ) {
874
+	if (true === $reset) {
875 875
 		$available_translations = array();
876 876
 	}
877 877
 
878
-	if ( ! isset( $available_translations[ $domain ] ) ) {
879
-		$available_translations[ $domain ] = _get_path_to_translation_from_lang_dir( $domain );
878
+	if ( ! isset($available_translations[$domain])) {
879
+		$available_translations[$domain] = _get_path_to_translation_from_lang_dir($domain);
880 880
 	}
881 881
 
882
-	return $available_translations[ $domain ];
882
+	return $available_translations[$domain];
883 883
 }
884 884
 
885 885
 /**
@@ -895,21 +895,21 @@  discard block
 block discarded – undo
895 895
  * @param string $domain Text domain. Unique identifier for retrieving translated strings.
896 896
  * @return string|false The path to the translation file or false if no translation file was found.
897 897
  */
898
-function _get_path_to_translation_from_lang_dir( $domain ) {
898
+function _get_path_to_translation_from_lang_dir($domain) {
899 899
 	static $cached_mofiles = null;
900 900
 
901
-	if ( null === $cached_mofiles ) {
901
+	if (null === $cached_mofiles) {
902 902
 		$cached_mofiles = array();
903 903
 
904 904
 		$locations = array(
905
-			WP_LANG_DIR . '/plugins',
906
-			WP_LANG_DIR . '/themes',
905
+			WP_LANG_DIR.'/plugins',
906
+			WP_LANG_DIR.'/themes',
907 907
 		);
908 908
 
909
-		foreach ( $locations as $location ) {
910
-			$mofiles = glob( $location . '/*.mo' );
911
-			if ( $mofiles ) {
912
-				$cached_mofiles = array_merge( $cached_mofiles, $mofiles );
909
+		foreach ($locations as $location) {
910
+			$mofiles = glob($location.'/*.mo');
911
+			if ($mofiles) {
912
+				$cached_mofiles = array_merge($cached_mofiles, $mofiles);
913 913
 			}
914 914
 		}
915 915
 	}
@@ -917,13 +917,13 @@  discard block
 block discarded – undo
917 917
 	$locale = is_admin() ? get_user_locale() : get_locale();
918 918
 	$mofile = "{$domain}-{$locale}.mo";
919 919
 
920
-	$path = WP_LANG_DIR . '/plugins/' . $mofile;
921
-	if ( in_array( $path, $cached_mofiles ) ) {
920
+	$path = WP_LANG_DIR.'/plugins/'.$mofile;
921
+	if (in_array($path, $cached_mofiles)) {
922 922
 		return $path;
923 923
 	}
924 924
 
925
-	$path = WP_LANG_DIR . '/themes/' . $mofile;
926
-	if ( in_array( $path, $cached_mofiles ) ) {
925
+	$path = WP_LANG_DIR.'/themes/'.$mofile;
926
+	if (in_array($path, $cached_mofiles)) {
927 927
 		return $path;
928 928
 	}
929 929
 
@@ -942,14 +942,14 @@  discard block
 block discarded – undo
942 942
  * @param string $domain Text domain. Unique identifier for retrieving translated strings.
943 943
  * @return Translations|NOOP_Translations A Translations instance.
944 944
  */
945
-function get_translations_for_domain( $domain ) {
945
+function get_translations_for_domain($domain) {
946 946
 	global $l10n;
947
-	if ( isset( $l10n[ $domain ] ) || ( _load_textdomain_just_in_time( $domain ) && isset( $l10n[ $domain ] ) ) ) {
948
-		return $l10n[ $domain ];
947
+	if (isset($l10n[$domain]) || (_load_textdomain_just_in_time($domain) && isset($l10n[$domain]))) {
948
+		return $l10n[$domain];
949 949
 	}
950 950
 
951 951
 	static $noop_translations = null;
952
-	if ( null === $noop_translations ) {
952
+	if (null === $noop_translations) {
953 953
 		$noop_translations = new NOOP_Translations;
954 954
 	}
955 955
 
@@ -966,9 +966,9 @@  discard block
 block discarded – undo
966 966
  * @param string $domain Text domain. Unique identifier for retrieving translated strings.
967 967
  * @return bool Whether there are translations.
968 968
  */
969
-function is_textdomain_loaded( $domain ) {
969
+function is_textdomain_loaded($domain) {
970 970
 	global $l10n;
971
-	return isset( $l10n[ $domain ] );
971
+	return isset($l10n[$domain]);
972 972
 }
973 973
 
974 974
 /**
@@ -988,8 +988,8 @@  discard block
 block discarded – undo
988 988
  * @param string $name The role name.
989 989
  * @return string Translated role name on success, original name on failure.
990 990
  */
991
-function translate_user_role( $name ) {
992
-	return translate_with_gettext_context( before_last_bar($name), 'User role' );
991
+function translate_user_role($name) {
992
+	return translate_with_gettext_context(before_last_bar($name), 'User role');
993 993
 }
994 994
 
995 995
 /**
@@ -1004,15 +1004,15 @@  discard block
 block discarded – undo
1004 1004
  *                    Default WP_LANG_DIR.
1005 1005
  * @return array An array of language codes or an empty array if no languages are present. Language codes are formed by stripping the .mo extension from the language file names.
1006 1006
  */
1007
-function get_available_languages( $dir = null ) {
1007
+function get_available_languages($dir = null) {
1008 1008
 	$languages = array();
1009 1009
 
1010
-	$lang_files = glob( ( is_null( $dir ) ? WP_LANG_DIR : $dir ) . '/*.mo' );
1011
-	if ( $lang_files ) {
1012
-		foreach ( $lang_files as $lang_file ) {
1013
-			$lang_file = basename( $lang_file, '.mo' );
1014
-			if ( 0 !== strpos( $lang_file, 'continents-cities' ) && 0 !== strpos( $lang_file, 'ms-' ) &&
1015
-				0 !== strpos( $lang_file, 'admin-' ) ) {
1010
+	$lang_files = glob((is_null($dir) ? WP_LANG_DIR : $dir).'/*.mo');
1011
+	if ($lang_files) {
1012
+		foreach ($lang_files as $lang_file) {
1013
+			$lang_file = basename($lang_file, '.mo');
1014
+			if (0 !== strpos($lang_file, 'continents-cities') && 0 !== strpos($lang_file, 'ms-') &&
1015
+				0 !== strpos($lang_file, 'admin-')) {
1016 1016
 				$languages[] = $lang_file;
1017 1017
 			}
1018 1018
 		}
@@ -1026,7 +1026,7 @@  discard block
 block discarded – undo
1026 1026
 	 * @param array  $languages An array of available language codes.
1027 1027
 	 * @param string $dir       The directory where the language files were found.
1028 1028
 	 */
1029
-	return apply_filters( 'get_available_languages', $languages, $dir );
1029
+	return apply_filters('get_available_languages', $languages, $dir);
1030 1030
 }
1031 1031
 
1032 1032
 /**
@@ -1040,43 +1040,43 @@  discard block
 block discarded – undo
1040 1040
  * @param string $type What to search for. Accepts 'plugins', 'themes', 'core'.
1041 1041
  * @return array Array of language data.
1042 1042
  */
1043
-function wp_get_installed_translations( $type ) {
1044
-	if ( $type !== 'themes' && $type !== 'plugins' && $type !== 'core' )
1043
+function wp_get_installed_translations($type) {
1044
+	if ($type !== 'themes' && $type !== 'plugins' && $type !== 'core')
1045 1045
 		return array();
1046 1046
 
1047 1047
 	$dir = 'core' === $type ? '' : "/$type";
1048 1048
 
1049
-	if ( ! is_dir( WP_LANG_DIR ) )
1049
+	if ( ! is_dir(WP_LANG_DIR))
1050 1050
 		return array();
1051 1051
 
1052
-	if ( $dir && ! is_dir( WP_LANG_DIR . $dir ) )
1052
+	if ($dir && ! is_dir(WP_LANG_DIR.$dir))
1053 1053
 		return array();
1054 1054
 
1055
-	$files = scandir( WP_LANG_DIR . $dir );
1056
-	if ( ! $files )
1055
+	$files = scandir(WP_LANG_DIR.$dir);
1056
+	if ( ! $files)
1057 1057
 		return array();
1058 1058
 
1059 1059
 	$language_data = array();
1060 1060
 
1061
-	foreach ( $files as $file ) {
1062
-		if ( '.' === $file[0] || is_dir( WP_LANG_DIR . "$dir/$file" ) ) {
1061
+	foreach ($files as $file) {
1062
+		if ('.' === $file[0] || is_dir(WP_LANG_DIR."$dir/$file")) {
1063 1063
 			continue;
1064 1064
 		}
1065
-		if ( substr( $file, -3 ) !== '.po' ) {
1065
+		if (substr($file, -3) !== '.po') {
1066 1066
 			continue;
1067 1067
 		}
1068
-		if ( ! preg_match( '/(?:(.+)-)?([a-z]{2,3}(?:_[A-Z]{2})?(?:_[a-z0-9]+)?).po/', $file, $match ) ) {
1068
+		if ( ! preg_match('/(?:(.+)-)?([a-z]{2,3}(?:_[A-Z]{2})?(?:_[a-z0-9]+)?).po/', $file, $match)) {
1069 1069
 			continue;
1070 1070
 		}
1071
-		if ( ! in_array( substr( $file, 0, -3 ) . '.mo', $files ) )  {
1071
+		if ( ! in_array(substr($file, 0, -3).'.mo', $files)) {
1072 1072
 			continue;
1073 1073
 		}
1074 1074
 
1075
-		list( , $textdomain, $language ) = $match;
1076
-		if ( '' === $textdomain ) {
1075
+		list(, $textdomain, $language) = $match;
1076
+		if ('' === $textdomain) {
1077 1077
 			$textdomain = 'default';
1078 1078
 		}
1079
-		$language_data[ $textdomain ][ $language ] = wp_get_pomo_file_data( WP_LANG_DIR . "$dir/$file" );
1079
+		$language_data[$textdomain][$language] = wp_get_pomo_file_data(WP_LANG_DIR."$dir/$file");
1080 1080
 	}
1081 1081
 	return $language_data;
1082 1082
 }
@@ -1089,16 +1089,16 @@  discard block
 block discarded – undo
1089 1089
  * @param string $po_file Path to PO file.
1090 1090
  * @return array PO file headers.
1091 1091
  */
1092
-function wp_get_pomo_file_data( $po_file ) {
1093
-	$headers = get_file_data( $po_file, array(
1092
+function wp_get_pomo_file_data($po_file) {
1093
+	$headers = get_file_data($po_file, array(
1094 1094
 		'POT-Creation-Date'  => '"POT-Creation-Date',
1095 1095
 		'PO-Revision-Date'   => '"PO-Revision-Date',
1096 1096
 		'Project-Id-Version' => '"Project-Id-Version',
1097 1097
 		'X-Generator'        => '"X-Generator',
1098
-	) );
1099
-	foreach ( $headers as $header => $value ) {
1098
+	));
1099
+	foreach ($headers as $header => $value) {
1100 1100
 		// Remove possible contextual '\n' and closing double quote.
1101
-		$headers[ $header ] = preg_replace( '~(\\\n)?"$~', '', $value );
1101
+		$headers[$header] = preg_replace('~(\\\n)?"$~', '', $value);
1102 1102
 	}
1103 1103
 	return $headers;
1104 1104
 }
@@ -1130,9 +1130,9 @@  discard block
 block discarded – undo
1130 1130
  * }
1131 1131
  * @return string HTML content
1132 1132
  */
1133
-function wp_dropdown_languages( $args = array() ) {
1133
+function wp_dropdown_languages($args = array()) {
1134 1134
 
1135
-	$args = wp_parse_args( $args, array(
1135
+	$args = wp_parse_args($args, array(
1136 1136
 		'id'           => '',
1137 1137
 		'name'         => '',
1138 1138
 		'languages'    => array(),
@@ -1141,16 +1141,16 @@  discard block
 block discarded – undo
1141 1141
 		'echo'         => 1,
1142 1142
 		'show_available_translations' => true,
1143 1143
 		'show_option_site_default'    => false,
1144
-	) );
1144
+	));
1145 1145
 
1146 1146
 	// English (United States) uses an empty string for the value attribute.
1147
-	if ( 'en_US' === $args['selected'] ) {
1147
+	if ('en_US' === $args['selected']) {
1148 1148
 		$args['selected'] = '';
1149 1149
 	}
1150 1150
 
1151 1151
 	$translations = $args['translations'];
1152
-	if ( empty( $translations ) ) {
1153
-		require_once( ABSPATH . 'wp-admin/includes/translation-install.php' );
1152
+	if (empty($translations)) {
1153
+		require_once(ABSPATH.'wp-admin/includes/translation-install.php');
1154 1154
 		$translations = wp_get_available_translations();
1155 1155
 	}
1156 1156
 
@@ -1159,17 +1159,17 @@  discard block
 block discarded – undo
1159 1159
 	 * $translations to get the native name. Fall back to locale.
1160 1160
 	 */
1161 1161
 	$languages = array();
1162
-	foreach ( $args['languages'] as $locale ) {
1163
-		if ( isset( $translations[ $locale ] ) ) {
1164
-			$translation = $translations[ $locale ];
1162
+	foreach ($args['languages'] as $locale) {
1163
+		if (isset($translations[$locale])) {
1164
+			$translation = $translations[$locale];
1165 1165
 			$languages[] = array(
1166 1166
 				'language'    => $translation['language'],
1167 1167
 				'native_name' => $translation['native_name'],
1168
-				'lang'        => current( $translation['iso'] ),
1168
+				'lang'        => current($translation['iso']),
1169 1169
 			);
1170 1170
 
1171 1171
 			// Remove installed language from available translations.
1172
-			unset( $translations[ $locale ] );
1172
+			unset($translations[$locale]);
1173 1173
 		} else {
1174 1174
 			$languages[] = array(
1175 1175
 				'language'    => $locale,
@@ -1179,64 +1179,64 @@  discard block
 block discarded – undo
1179 1179
 		}
1180 1180
 	}
1181 1181
 
1182
-	$translations_available = ( ! empty( $translations ) && $args['show_available_translations'] );
1182
+	$translations_available = ( ! empty($translations) && $args['show_available_translations']);
1183 1183
 
1184
-	$output = sprintf( '<select name="%s" id="%s">', esc_attr( $args['name'] ), esc_attr( $args['id'] ) );
1184
+	$output = sprintf('<select name="%s" id="%s">', esc_attr($args['name']), esc_attr($args['id']));
1185 1185
 
1186 1186
 	// Holds the HTML markup.
1187 1187
 	$structure = array();
1188 1188
 
1189 1189
 	// List installed languages.
1190
-	if ( $translations_available ) {
1191
-		$structure[] = '<optgroup label="' . esc_attr_x( 'Installed', 'translations' ) . '">';
1190
+	if ($translations_available) {
1191
+		$structure[] = '<optgroup label="'.esc_attr_x('Installed', 'translations').'">';
1192 1192
 	}
1193 1193
 
1194
-	if ( $args['show_option_site_default'] ) {
1194
+	if ($args['show_option_site_default']) {
1195 1195
 		$structure[] = sprintf(
1196 1196
 			'<option value="site-default" data-installed="1"%s>%s</option>',
1197
-			selected( 'site-default', $args['selected'], false ),
1198
-			_x( 'Site Default', 'default site language' )
1197
+			selected('site-default', $args['selected'], false),
1198
+			_x('Site Default', 'default site language')
1199 1199
 		);
1200 1200
 	}
1201 1201
 
1202 1202
 	$structure[] = sprintf(
1203 1203
 		'<option value="" lang="en" data-installed="1"%s>English (United States)</option>',
1204
-		selected( '', $args['selected'], false )
1204
+		selected('', $args['selected'], false)
1205 1205
 	);
1206 1206
 
1207
-	foreach ( $languages as $language ) {
1207
+	foreach ($languages as $language) {
1208 1208
 		$structure[] = sprintf(
1209 1209
 			'<option value="%s" lang="%s"%s data-installed="1">%s</option>',
1210
-			esc_attr( $language['language'] ),
1211
-			esc_attr( $language['lang'] ),
1212
-			selected( $language['language'], $args['selected'], false ),
1213
-			esc_html( $language['native_name'] )
1210
+			esc_attr($language['language']),
1211
+			esc_attr($language['lang']),
1212
+			selected($language['language'], $args['selected'], false),
1213
+			esc_html($language['native_name'])
1214 1214
 		);
1215 1215
 	}
1216
-	if ( $translations_available ) {
1216
+	if ($translations_available) {
1217 1217
 		$structure[] = '</optgroup>';
1218 1218
 	}
1219 1219
 
1220 1220
 	// List available translations.
1221
-	if ( $translations_available ) {
1222
-		$structure[] = '<optgroup label="' . esc_attr_x( 'Available', 'translations' ) . '">';
1223
-		foreach ( $translations as $translation ) {
1221
+	if ($translations_available) {
1222
+		$structure[] = '<optgroup label="'.esc_attr_x('Available', 'translations').'">';
1223
+		foreach ($translations as $translation) {
1224 1224
 			$structure[] = sprintf(
1225 1225
 				'<option value="%s" lang="%s"%s>%s</option>',
1226
-				esc_attr( $translation['language'] ),
1227
-				esc_attr( current( $translation['iso'] ) ),
1228
-				selected( $translation['language'], $args['selected'], false ),
1229
-				esc_html( $translation['native_name'] )
1226
+				esc_attr($translation['language']),
1227
+				esc_attr(current($translation['iso'])),
1228
+				selected($translation['language'], $args['selected'], false),
1229
+				esc_html($translation['native_name'])
1230 1230
 			);
1231 1231
 		}
1232 1232
 		$structure[] = '</optgroup>';
1233 1233
 	}
1234 1234
 
1235
-	$output .= join( "\n", $structure );
1235
+	$output .= join("\n", $structure);
1236 1236
 
1237 1237
 	$output .= '</select>';
1238 1238
 
1239
-	if ( $args['echo'] ) {
1239
+	if ($args['echo']) {
1240 1240
 		echo $output;
1241 1241
 	}
1242 1242
 
@@ -1254,7 +1254,7 @@  discard block
 block discarded – undo
1254 1254
  */
1255 1255
 function is_rtl() {
1256 1256
 	global $wp_locale;
1257
-	if ( ! ( $wp_locale instanceof WP_Locale ) ) {
1257
+	if ( ! ($wp_locale instanceof WP_Locale)) {
1258 1258
 		return false;
1259 1259
 	}
1260 1260
 	return $wp_locale->is_rtl();
@@ -1270,11 +1270,11 @@  discard block
 block discarded – undo
1270 1270
  * @param string $locale The locale.
1271 1271
  * @return bool True on success, false on failure.
1272 1272
  */
1273
-function switch_to_locale( $locale ) {
1273
+function switch_to_locale($locale) {
1274 1274
 	/* @var WP_Locale_Switcher $wp_locale_switcher */
1275 1275
 	global $wp_locale_switcher;
1276 1276
 
1277
-	return $wp_locale_switcher->switch_to_locale( $locale );
1277
+	return $wp_locale_switcher->switch_to_locale($locale);
1278 1278
 }
1279 1279
 
1280 1280
 /**
Please login to merge, or discard this patch.
src/wp-includes/ms-functions.php 4 patches
Indentation   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -1534,7 +1534,7 @@  discard block
 block discarded – undo
1534 1534
 	$current_site = get_current_site();
1535 1535
 
1536 1536
 	/**
1537
- 	 * Filters whether to bypass the welcome email after user activation.
1537
+	 * Filters whether to bypass the welcome email after user activation.
1538 1538
 	 *
1539 1539
 	 * Returning false disables the welcome email.
1540 1540
 	 *
@@ -2054,7 +2054,7 @@  discard block
 block discarded – undo
2054 2054
  * @return bool
2055 2055
  */
2056 2056
 function is_user_spammy( $user = null ) {
2057
-    if ( ! ( $user instanceof WP_User ) ) {
2057
+	if ( ! ( $user instanceof WP_User ) ) {
2058 2058
 		if ( $user ) {
2059 2059
 			$user = get_user_by( 'login', $user );
2060 2060
 		} else {
Please login to merge, or discard this patch.
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -2191,7 +2191,7 @@
 block discarded – undo
2191 2191
  *
2192 2192
  * @staticvar bool $forced_content
2193 2193
  *
2194
- * @param bool $force
2194
+ * @param string|boolean $force
2195 2195
  * @return bool True if forced, false if not forced.
2196 2196
  */
2197 2197
 function force_ssl_content( $force = '' ) {
Please login to merge, or discard this patch.
Spacing   +508 added lines, -508 removed lines patch added patch discarded remove patch
@@ -39,45 +39,45 @@  discard block
 block discarded – undo
39 39
  * @param int $user_id The unique ID of the user
40 40
  * @return WP_Site|void The blog object
41 41
  */
42
-function get_active_blog_for_user( $user_id ) {
42
+function get_active_blog_for_user($user_id) {
43 43
 	global $wpdb;
44
-	$blogs = get_blogs_of_user( $user_id );
45
-	if ( empty( $blogs ) )
44
+	$blogs = get_blogs_of_user($user_id);
45
+	if (empty($blogs))
46 46
 		return;
47 47
 
48
-	if ( !is_multisite() )
48
+	if ( ! is_multisite())
49 49
 		return $blogs[$wpdb->blogid];
50 50
 
51
-	$primary_blog = get_user_meta( $user_id, 'primary_blog', true );
51
+	$primary_blog = get_user_meta($user_id, 'primary_blog', true);
52 52
 	$first_blog = current($blogs);
53
-	if ( false !== $primary_blog ) {
54
-		if ( ! isset( $blogs[ $primary_blog ] ) ) {
55
-			update_user_meta( $user_id, 'primary_blog', $first_blog->userblog_id );
56
-			$primary = get_site( $first_blog->userblog_id );
53
+	if (false !== $primary_blog) {
54
+		if ( ! isset($blogs[$primary_blog])) {
55
+			update_user_meta($user_id, 'primary_blog', $first_blog->userblog_id);
56
+			$primary = get_site($first_blog->userblog_id);
57 57
 		} else {
58
-			$primary = get_site( $primary_blog );
58
+			$primary = get_site($primary_blog);
59 59
 		}
60 60
 	} else {
61 61
 		//TODO Review this call to add_user_to_blog too - to get here the user must have a role on this blog?
62
-		add_user_to_blog( $first_blog->userblog_id, $user_id, 'subscriber' );
63
-		update_user_meta( $user_id, 'primary_blog', $first_blog->userblog_id );
62
+		add_user_to_blog($first_blog->userblog_id, $user_id, 'subscriber');
63
+		update_user_meta($user_id, 'primary_blog', $first_blog->userblog_id);
64 64
 		$primary = $first_blog;
65 65
 	}
66 66
 
67
-	if ( ( ! is_object( $primary ) ) || ( $primary->archived == 1 || $primary->spam == 1 || $primary->deleted == 1 ) ) {
68
-		$blogs = get_blogs_of_user( $user_id, true ); // if a user's primary blog is shut down, check their other blogs.
67
+	if (( ! is_object($primary)) || ($primary->archived == 1 || $primary->spam == 1 || $primary->deleted == 1)) {
68
+		$blogs = get_blogs_of_user($user_id, true); // if a user's primary blog is shut down, check their other blogs.
69 69
 		$ret = false;
70
-		if ( is_array( $blogs ) && count( $blogs ) > 0 ) {
71
-			foreach ( (array) $blogs as $blog_id => $blog ) {
72
-				if ( $blog->site_id != $wpdb->siteid )
70
+		if (is_array($blogs) && count($blogs) > 0) {
71
+			foreach ((array) $blogs as $blog_id => $blog) {
72
+				if ($blog->site_id != $wpdb->siteid)
73 73
 					continue;
74
-				$details = get_site( $blog_id );
75
-				if ( is_object( $details ) && $details->archived == 0 && $details->spam == 0 && $details->deleted == 0 ) {
74
+				$details = get_site($blog_id);
75
+				if (is_object($details) && $details->archived == 0 && $details->spam == 0 && $details->deleted == 0) {
76 76
 					$ret = $blog;
77
-					if ( get_user_meta( $user_id , 'primary_blog', true ) != $blog_id )
78
-						update_user_meta( $user_id, 'primary_blog', $blog_id );
79
-					if ( !get_user_meta($user_id , 'source_domain', true) )
80
-						update_user_meta( $user_id, 'source_domain', $blog->domain );
77
+					if (get_user_meta($user_id, 'primary_blog', true) != $blog_id)
78
+						update_user_meta($user_id, 'primary_blog', $blog_id);
79
+					if ( ! get_user_meta($user_id, 'source_domain', true))
80
+						update_user_meta($user_id, 'source_domain', $blog->domain);
81 81
 					break;
82 82
 				}
83 83
 			}
@@ -100,7 +100,7 @@  discard block
 block discarded – undo
100 100
  * @return int
101 101
  */
102 102
 function get_user_count() {
103
-	return get_site_option( 'user_count' );
103
+	return get_site_option('user_count');
104 104
 }
105 105
 
106 106
 /**
@@ -113,11 +113,11 @@  discard block
 block discarded – undo
113 113
  * @param int $network_id Deprecated, not supported.
114 114
  * @return int
115 115
  */
116
-function get_blog_count( $network_id = 0 ) {
117
-	if ( func_num_args() )
118
-		_deprecated_argument( __FUNCTION__, '3.1.0' );
116
+function get_blog_count($network_id = 0) {
117
+	if (func_num_args())
118
+		_deprecated_argument(__FUNCTION__, '3.1.0');
119 119
 
120
-	return get_site_option( 'blog_count' );
120
+	return get_site_option('blog_count');
121 121
 }
122 122
 
123 123
 /**
@@ -129,9 +129,9 @@  discard block
 block discarded – undo
129 129
  * @param int $post_id ID of the post you're looking for.
130 130
  * @return WP_Post|null WP_Post on success or null on failure
131 131
  */
132
-function get_blog_post( $blog_id, $post_id ) {
133
-	switch_to_blog( $blog_id );
134
-	$post = get_post( $post_id );
132
+function get_blog_post($blog_id, $post_id) {
133
+	switch_to_blog($blog_id);
134
+	$post = get_post($post_id);
135 135
 	restore_current_blog();
136 136
 
137 137
 	return $post;
@@ -149,20 +149,20 @@  discard block
 block discarded – undo
149 149
  * @param string $role    The role you want the user to have
150 150
  * @return true|WP_Error
151 151
  */
152
-function add_user_to_blog( $blog_id, $user_id, $role ) {
152
+function add_user_to_blog($blog_id, $user_id, $role) {
153 153
 	switch_to_blog($blog_id);
154 154
 
155
-	$user = get_userdata( $user_id );
155
+	$user = get_userdata($user_id);
156 156
 
157
-	if ( ! $user ) {
157
+	if ( ! $user) {
158 158
 		restore_current_blog();
159
-		return new WP_Error( 'user_does_not_exist', __( 'The requested user does not exist.' ) );
159
+		return new WP_Error('user_does_not_exist', __('The requested user does not exist.'));
160 160
 	}
161 161
 
162
-	if ( !get_user_meta($user_id, 'primary_blog', true) ) {
162
+	if ( ! get_user_meta($user_id, 'primary_blog', true)) {
163 163
 		update_user_meta($user_id, 'primary_blog', $blog_id);
164
-		$site = get_site( $blog_id );
165
-		update_user_meta( $user_id, 'source_domain', $site->domain );
164
+		$site = get_site($blog_id);
165
+		update_user_meta($user_id, 'source_domain', $site->domain);
166 166
 	}
167 167
 
168 168
 	$user->set_role($role);
@@ -176,9 +176,9 @@  discard block
 block discarded – undo
176 176
 	 * @param string $role    User role.
177 177
 	 * @param int    $blog_id Blog ID.
178 178
 	 */
179
-	do_action( 'add_user_to_blog', $user_id, $role, $blog_id );
180
-	wp_cache_delete( $user_id, 'users' );
181
-	wp_cache_delete( $blog_id . '_user_count', 'blog-details' );
179
+	do_action('add_user_to_blog', $user_id, $role, $blog_id);
180
+	wp_cache_delete($user_id, 'users');
181
+	wp_cache_delete($blog_id.'_user_count', 'blog-details');
182 182
 	restore_current_blog();
183 183
 	return true;
184 184
 }
@@ -213,17 +213,17 @@  discard block
 block discarded – undo
213 213
 	 * @param int $user_id User ID.
214 214
 	 * @param int $blog_id Blog ID.
215 215
 	 */
216
-	do_action( 'remove_user_from_blog', $user_id, $blog_id );
216
+	do_action('remove_user_from_blog', $user_id, $blog_id);
217 217
 
218 218
 	// If being removed from the primary blog, set a new primary if the user is assigned
219 219
 	// to multiple blogs.
220 220
 	$primary_blog = get_user_meta($user_id, 'primary_blog', true);
221
-	if ( $primary_blog == $blog_id ) {
221
+	if ($primary_blog == $blog_id) {
222 222
 		$new_id = '';
223 223
 		$new_domain = '';
224 224
 		$blogs = get_blogs_of_user($user_id);
225
-		foreach ( (array) $blogs as $blog ) {
226
-			if ( $blog->userblog_id == $blog_id )
225
+		foreach ((array) $blogs as $blog) {
226
+			if ($blog->userblog_id == $blog_id)
227 227
 				continue;
228 228
 			$new_id = $blog->userblog_id;
229 229
 			$new_domain = $blog->domain;
@@ -235,8 +235,8 @@  discard block
 block discarded – undo
235 235
 	}
236 236
 
237 237
 	// wp_revoke_user($user_id);
238
-	$user = get_userdata( $user_id );
239
-	if ( ! $user ) {
238
+	$user = get_userdata($user_id);
239
+	if ( ! $user) {
240 240
 		restore_current_blog();
241 241
 		return new WP_Error('user_does_not_exist', __('That user does not exist.'));
242 242
 	}
@@ -244,24 +244,24 @@  discard block
 block discarded – undo
244 244
 	$user->remove_all_caps();
245 245
 
246 246
 	$blogs = get_blogs_of_user($user_id);
247
-	if ( count($blogs) == 0 ) {
247
+	if (count($blogs) == 0) {
248 248
 		update_user_meta($user_id, 'primary_blog', '');
249 249
 		update_user_meta($user_id, 'source_domain', '');
250 250
 	}
251 251
 
252
-	if ( $reassign != '' ) {
252
+	if ($reassign != '') {
253 253
 		$reassign = (int) $reassign;
254
-		$post_ids = $wpdb->get_col( $wpdb->prepare( "SELECT ID FROM $wpdb->posts WHERE post_author = %d", $user_id ) );
255
-		$link_ids = $wpdb->get_col( $wpdb->prepare( "SELECT link_id FROM $wpdb->links WHERE link_owner = %d", $user_id ) );
254
+		$post_ids = $wpdb->get_col($wpdb->prepare("SELECT ID FROM $wpdb->posts WHERE post_author = %d", $user_id));
255
+		$link_ids = $wpdb->get_col($wpdb->prepare("SELECT link_id FROM $wpdb->links WHERE link_owner = %d", $user_id));
256 256
 
257
-		if ( ! empty( $post_ids ) ) {
258
-			$wpdb->query( $wpdb->prepare( "UPDATE $wpdb->posts SET post_author = %d WHERE post_author = %d", $reassign, $user_id ) );
259
-			array_walk( $post_ids, 'clean_post_cache' );
257
+		if ( ! empty($post_ids)) {
258
+			$wpdb->query($wpdb->prepare("UPDATE $wpdb->posts SET post_author = %d WHERE post_author = %d", $reassign, $user_id));
259
+			array_walk($post_ids, 'clean_post_cache');
260 260
 		}
261 261
 
262
-		if ( ! empty( $link_ids ) ) {
263
-			$wpdb->query( $wpdb->prepare( "UPDATE $wpdb->links SET link_owner = %d WHERE link_owner = %d", $reassign, $user_id ) );
264
-			array_walk( $link_ids, 'clean_bookmark_cache' );
262
+		if ( ! empty($link_ids)) {
263
+			$wpdb->query($wpdb->prepare("UPDATE $wpdb->links SET link_owner = %d WHERE link_owner = %d", $reassign, $user_id));
264
+			array_walk($link_ids, 'clean_bookmark_cache');
265 265
 		}
266 266
 	}
267 267
 
@@ -279,9 +279,9 @@  discard block
 block discarded – undo
279 279
  * @param int $post_id ID of the desired post.
280 280
  * @return string The post's permalink
281 281
  */
282
-function get_blog_permalink( $blog_id, $post_id ) {
283
-	switch_to_blog( $blog_id );
284
-	$link = get_permalink( $post_id );
282
+function get_blog_permalink($blog_id, $post_id) {
283
+	switch_to_blog($blog_id);
284
+	$link = get_permalink($post_id);
285 285
 	restore_current_blog();
286 286
 
287 287
 	return $link;
@@ -303,14 +303,14 @@  discard block
 block discarded – undo
303 303
  * @param string $path   Optional. Not required for subdomain installations.
304 304
  * @return int 0 if no blog found, otherwise the ID of the matching blog
305 305
  */
306
-function get_blog_id_from_url( $domain, $path = '/' ) {
307
-	$domain = strtolower( $domain );
308
-	$path = strtolower( $path );
309
-	$id = wp_cache_get( md5( $domain . $path ), 'blog-id-cache' );
306
+function get_blog_id_from_url($domain, $path = '/') {
307
+	$domain = strtolower($domain);
308
+	$path = strtolower($path);
309
+	$id = wp_cache_get(md5($domain.$path), 'blog-id-cache');
310 310
 
311
-	if ( $id == -1 ) // blog does not exist
311
+	if ($id == -1) // blog does not exist
312 312
 		return 0;
313
-	elseif ( $id )
313
+	elseif ($id)
314 314
 		return (int) $id;
315 315
 
316 316
 	$args = array(
@@ -318,15 +318,15 @@  discard block
 block discarded – undo
318 318
 		'path' => $path,
319 319
 		'fields' => 'ids',
320 320
 	);
321
-	$result = get_sites( $args );
322
-	$id = array_shift( $result );
321
+	$result = get_sites($args);
322
+	$id = array_shift($result);
323 323
 
324
-	if ( ! $id ) {
325
-		wp_cache_set( md5( $domain . $path ), -1, 'blog-id-cache' );
324
+	if ( ! $id) {
325
+		wp_cache_set(md5($domain.$path), -1, 'blog-id-cache');
326 326
 		return 0;
327 327
 	}
328 328
 
329
-	wp_cache_set( md5( $domain . $path ), $id, 'blog-id-cache' );
329
+	wp_cache_set(md5($domain.$path), $id, 'blog-id-cache');
330 330
 
331 331
 	return $id;
332 332
 }
@@ -346,30 +346,30 @@  discard block
 block discarded – undo
346 346
  * @param string $user_email The email provided by the user at registration.
347 347
  * @return bool Returns true when the email address is banned.
348 348
  */
349
-function is_email_address_unsafe( $user_email ) {
350
-	$banned_names = get_site_option( 'banned_email_domains' );
351
-	if ( $banned_names && ! is_array( $banned_names ) )
352
-		$banned_names = explode( "\n", $banned_names );
349
+function is_email_address_unsafe($user_email) {
350
+	$banned_names = get_site_option('banned_email_domains');
351
+	if ($banned_names && ! is_array($banned_names))
352
+		$banned_names = explode("\n", $banned_names);
353 353
 
354 354
 	$is_email_address_unsafe = false;
355 355
 
356
-	if ( $banned_names && is_array( $banned_names ) ) {
357
-		$banned_names = array_map( 'strtolower', $banned_names );
358
-		$normalized_email = strtolower( $user_email );
356
+	if ($banned_names && is_array($banned_names)) {
357
+		$banned_names = array_map('strtolower', $banned_names);
358
+		$normalized_email = strtolower($user_email);
359 359
 
360
-		list( $email_local_part, $email_domain ) = explode( '@', $normalized_email );
360
+		list($email_local_part, $email_domain) = explode('@', $normalized_email);
361 361
 
362
-		foreach ( $banned_names as $banned_domain ) {
363
-			if ( ! $banned_domain )
362
+		foreach ($banned_names as $banned_domain) {
363
+			if ( ! $banned_domain)
364 364
 				continue;
365 365
 
366
-			if ( $email_domain == $banned_domain ) {
366
+			if ($email_domain == $banned_domain) {
367 367
 				$is_email_address_unsafe = true;
368 368
 				break;
369 369
 			}
370 370
 
371 371
 			$dotted_domain = ".$banned_domain";
372
-			if ( $dotted_domain === substr( $normalized_email, -strlen( $dotted_domain ) ) ) {
372
+			if ($dotted_domain === substr($normalized_email, -strlen($dotted_domain))) {
373 373
 				$is_email_address_unsafe = true;
374 374
 				break;
375 375
 			}
@@ -384,7 +384,7 @@  discard block
 block discarded – undo
384 384
 	 * @param bool   $is_email_address_unsafe Whether the email address is "unsafe". Default false.
385 385
 	 * @param string $user_email              User email address.
386 386
 	 */
387
-	return apply_filters( 'is_email_address_unsafe', $is_email_address_unsafe, $user_email );
387
+	return apply_filters('is_email_address_unsafe', $is_email_address_unsafe, $user_email);
388 388
 }
389 389
 
390 390
 /**
@@ -413,86 +413,86 @@  discard block
 block discarded – undo
413 413
 	$errors = new WP_Error();
414 414
 
415 415
 	$orig_username = $user_name;
416
-	$user_name = preg_replace( '/\s+/', '', sanitize_user( $user_name, true ) );
416
+	$user_name = preg_replace('/\s+/', '', sanitize_user($user_name, true));
417 417
 
418
-	if ( $user_name != $orig_username || preg_match( '/[^a-z0-9]/', $user_name ) ) {
419
-		$errors->add( 'user_name', __( 'Usernames can only contain lowercase letters (a-z) and numbers.' ) );
418
+	if ($user_name != $orig_username || preg_match('/[^a-z0-9]/', $user_name)) {
419
+		$errors->add('user_name', __('Usernames can only contain lowercase letters (a-z) and numbers.'));
420 420
 		$user_name = $orig_username;
421 421
 	}
422 422
 
423
-	$user_email = sanitize_email( $user_email );
423
+	$user_email = sanitize_email($user_email);
424 424
 
425
-	if ( empty( $user_name ) )
426
-	   	$errors->add('user_name', __( 'Please enter a username.' ) );
425
+	if (empty($user_name))
426
+	   	$errors->add('user_name', __('Please enter a username.'));
427 427
 
428
-	$illegal_names = get_site_option( 'illegal_names' );
429
-	if ( ! is_array( $illegal_names ) ) {
430
-		$illegal_names = array(  'www', 'web', 'root', 'admin', 'main', 'invite', 'administrator' );
431
-		add_site_option( 'illegal_names', $illegal_names );
428
+	$illegal_names = get_site_option('illegal_names');
429
+	if ( ! is_array($illegal_names)) {
430
+		$illegal_names = array('www', 'web', 'root', 'admin', 'main', 'invite', 'administrator');
431
+		add_site_option('illegal_names', $illegal_names);
432 432
 	}
433
-	if ( in_array( $user_name, $illegal_names ) ) {
434
-		$errors->add( 'user_name',  __( 'Sorry, that username is not allowed.' ) );
433
+	if (in_array($user_name, $illegal_names)) {
434
+		$errors->add('user_name', __('Sorry, that username is not allowed.'));
435 435
 	}
436 436
 
437 437
 	/** This filter is documented in wp-includes/user.php */
438
-	$illegal_logins = (array) apply_filters( 'illegal_user_logins', array() );
438
+	$illegal_logins = (array) apply_filters('illegal_user_logins', array());
439 439
 
440
-	if ( in_array( strtolower( $user_name ), array_map( 'strtolower', $illegal_logins ) ) ) {
441
-		$errors->add( 'user_name',  __( 'Sorry, that username is not allowed.' ) );
440
+	if (in_array(strtolower($user_name), array_map('strtolower', $illegal_logins))) {
441
+		$errors->add('user_name', __('Sorry, that username is not allowed.'));
442 442
 	}
443 443
 
444
-	if ( is_email_address_unsafe( $user_email ) )
445
-		$errors->add('user_email',  __('You cannot use that email address to signup. We are having problems with them blocking some of our email. Please use another email provider.'));
444
+	if (is_email_address_unsafe($user_email))
445
+		$errors->add('user_email', __('You cannot use that email address to signup. We are having problems with them blocking some of our email. Please use another email provider.'));
446 446
 
447
-	if ( strlen( $user_name ) < 4 )
448
-		$errors->add('user_name',  __( 'Username must be at least 4 characters.' ) );
447
+	if (strlen($user_name) < 4)
448
+		$errors->add('user_name', __('Username must be at least 4 characters.'));
449 449
 
450
-	if ( strlen( $user_name ) > 60 ) {
451
-		$errors->add( 'user_name', __( 'Username may not be longer than 60 characters.' ) );
450
+	if (strlen($user_name) > 60) {
451
+		$errors->add('user_name', __('Username may not be longer than 60 characters.'));
452 452
 	}
453 453
 
454 454
 	// all numeric?
455
-	if ( preg_match( '/^[0-9]*$/', $user_name ) )
455
+	if (preg_match('/^[0-9]*$/', $user_name))
456 456
 		$errors->add('user_name', __('Sorry, usernames must have letters too!'));
457 457
 
458
-	if ( !is_email( $user_email ) )
459
-		$errors->add('user_email', __( 'Please enter a valid email address.' ) );
458
+	if ( ! is_email($user_email))
459
+		$errors->add('user_email', __('Please enter a valid email address.'));
460 460
 
461
-	$limited_email_domains = get_site_option( 'limited_email_domains' );
462
-	if ( is_array( $limited_email_domains ) && ! empty( $limited_email_domains ) ) {
463
-		$emaildomain = substr( $user_email, 1 + strpos( $user_email, '@' ) );
464
-		if ( ! in_array( $emaildomain, $limited_email_domains ) ) {
461
+	$limited_email_domains = get_site_option('limited_email_domains');
462
+	if (is_array($limited_email_domains) && ! empty($limited_email_domains)) {
463
+		$emaildomain = substr($user_email, 1 + strpos($user_email, '@'));
464
+		if ( ! in_array($emaildomain, $limited_email_domains)) {
465 465
 			$errors->add('user_email', __('Sorry, that email address is not allowed!'));
466 466
 		}
467 467
 	}
468 468
 
469 469
 	// Check if the username has been used already.
470
-	if ( username_exists($user_name) )
471
-		$errors->add( 'user_name', __( 'Sorry, that username already exists!' ) );
470
+	if (username_exists($user_name))
471
+		$errors->add('user_name', __('Sorry, that username already exists!'));
472 472
 
473 473
 	// Check if the email address has been used already.
474
-	if ( email_exists($user_email) )
475
-		$errors->add( 'user_email', __( 'Sorry, that email address is already used!' ) );
474
+	if (email_exists($user_email))
475
+		$errors->add('user_email', __('Sorry, that email address is already used!'));
476 476
 
477 477
 	// Has someone already signed up for this username?
478
-	$signup = $wpdb->get_row( $wpdb->prepare("SELECT * FROM $wpdb->signups WHERE user_login = %s", $user_name) );
479
-	if ( $signup != null ) {
480
-		$registered_at =  mysql2date('U', $signup->registered);
481
-		$now = current_time( 'timestamp', true );
478
+	$signup = $wpdb->get_row($wpdb->prepare("SELECT * FROM $wpdb->signups WHERE user_login = %s", $user_name));
479
+	if ($signup != null) {
480
+		$registered_at = mysql2date('U', $signup->registered);
481
+		$now = current_time('timestamp', true);
482 482
 		$diff = $now - $registered_at;
483 483
 		// If registered more than two days ago, cancel registration and let this signup go through.
484
-		if ( $diff > 2 * DAY_IN_SECONDS )
485
-			$wpdb->delete( $wpdb->signups, array( 'user_login' => $user_name ) );
484
+		if ($diff > 2 * DAY_IN_SECONDS)
485
+			$wpdb->delete($wpdb->signups, array('user_login' => $user_name));
486 486
 		else
487 487
 			$errors->add('user_name', __('That username is currently reserved but may be available in a couple of days.'));
488 488
 	}
489 489
 
490
-	$signup = $wpdb->get_row( $wpdb->prepare("SELECT * FROM $wpdb->signups WHERE user_email = %s", $user_email) );
491
-	if ( $signup != null ) {
492
-		$diff = current_time( 'timestamp', true ) - mysql2date('U', $signup->registered);
490
+	$signup = $wpdb->get_row($wpdb->prepare("SELECT * FROM $wpdb->signups WHERE user_email = %s", $user_email));
491
+	if ($signup != null) {
492
+		$diff = current_time('timestamp', true) - mysql2date('U', $signup->registered);
493 493
 		// If registered more than two days ago, cancel registration and let this signup go through.
494
-		if ( $diff > 2 * DAY_IN_SECONDS )
495
-			$wpdb->delete( $wpdb->signups, array( 'user_email' => $user_email ) );
494
+		if ($diff > 2 * DAY_IN_SECONDS)
495
+			$wpdb->delete($wpdb->signups, array('user_email' => $user_email));
496 496
 		else
497 497
 			$errors->add('user_email', __('That email address has already been used. Please check your inbox for an activation email. It will become available in a couple of days if you do nothing.'));
498 498
 	}
@@ -516,7 +516,7 @@  discard block
 block discarded – undo
516 516
 	 *     @type WP_Error $errors        WP_Error object containing any errors found.
517 517
 	 * }
518 518
 	 */
519
-	return apply_filters( 'wpmu_validate_user_signup', $result );
519
+	return apply_filters('wpmu_validate_user_signup', $result);
520 520
 }
521 521
 
522 522
 /**
@@ -543,48 +543,48 @@  discard block
 block discarded – undo
543 543
  * @param WP_User|string $user       Optional. The user object to check against the new site name.
544 544
  * @return array Contains the new site data and error messages.
545 545
  */
546
-function wpmu_validate_blog_signup( $blogname, $blog_title, $user = '' ) {
546
+function wpmu_validate_blog_signup($blogname, $blog_title, $user = '') {
547 547
 	global $wpdb, $domain;
548 548
 
549 549
 	$current_network = get_network();
550 550
 	$base = $current_network->path;
551 551
 
552
-	$blog_title = strip_tags( $blog_title );
552
+	$blog_title = strip_tags($blog_title);
553 553
 
554 554
 	$errors = new WP_Error();
555
-	$illegal_names = get_site_option( 'illegal_names' );
556
-	if ( $illegal_names == false ) {
557
-		$illegal_names = array( 'www', 'web', 'root', 'admin', 'main', 'invite', 'administrator' );
558
-		add_site_option( 'illegal_names', $illegal_names );
555
+	$illegal_names = get_site_option('illegal_names');
556
+	if ($illegal_names == false) {
557
+		$illegal_names = array('www', 'web', 'root', 'admin', 'main', 'invite', 'administrator');
558
+		add_site_option('illegal_names', $illegal_names);
559 559
 	}
560 560
 
561 561
 	/*
562 562
 	 * On sub dir installs, some names are so illegal, only a filter can
563 563
 	 * spring them from jail.
564 564
 	 */
565
-	if ( ! is_subdomain_install() ) {
566
-		$illegal_names = array_merge( $illegal_names, get_subdirectory_reserved_names() );
565
+	if ( ! is_subdomain_install()) {
566
+		$illegal_names = array_merge($illegal_names, get_subdirectory_reserved_names());
567 567
 	}
568 568
 
569
-	if ( empty( $blogname ) )
570
-		$errors->add('blogname', __( 'Please enter a site name.' ) );
569
+	if (empty($blogname))
570
+		$errors->add('blogname', __('Please enter a site name.'));
571 571
 
572
-	if ( preg_match( '/[^a-z0-9]+/', $blogname ) ) {
573
-		$errors->add( 'blogname', __( 'Site names can only contain lowercase letters (a-z) and numbers.' ) );
572
+	if (preg_match('/[^a-z0-9]+/', $blogname)) {
573
+		$errors->add('blogname', __('Site names can only contain lowercase letters (a-z) and numbers.'));
574 574
 	}
575 575
 
576
-	if ( in_array( $blogname, $illegal_names ) )
577
-		$errors->add('blogname',  __( 'That name is not allowed.' ) );
576
+	if (in_array($blogname, $illegal_names))
577
+		$errors->add('blogname', __('That name is not allowed.'));
578 578
 
579
-	if ( strlen( $blogname ) < 4 && !is_super_admin() )
580
-		$errors->add('blogname',  __( 'Site name must be at least 4 characters.' ) );
579
+	if (strlen($blogname) < 4 && ! is_super_admin())
580
+		$errors->add('blogname', __('Site name must be at least 4 characters.'));
581 581
 
582 582
 	// do not allow users to create a blog that conflicts with a page on the main blog.
583
-	if ( !is_subdomain_install() && $wpdb->get_var( $wpdb->prepare( "SELECT post_name FROM " . $wpdb->get_blog_prefix( $current_network->site_id ) . "posts WHERE post_type = 'page' AND post_name = %s", $blogname ) ) )
584
-		$errors->add( 'blogname', __( 'Sorry, you may not use that site name.' ) );
583
+	if ( ! is_subdomain_install() && $wpdb->get_var($wpdb->prepare("SELECT post_name FROM ".$wpdb->get_blog_prefix($current_network->site_id)."posts WHERE post_type = 'page' AND post_name = %s", $blogname)))
584
+		$errors->add('blogname', __('Sorry, you may not use that site name.'));
585 585
 
586 586
 	// all numeric?
587
-	if ( preg_match( '/^[0-9]*$/', $blogname ) )
587
+	if (preg_match('/^[0-9]*$/', $blogname))
588 588
 		$errors->add('blogname', __('Sorry, site names must have letters too!'));
589 589
 
590 590
 	/**
@@ -597,36 +597,36 @@  discard block
 block discarded – undo
597 597
 	 *
598 598
 	 * @param string $blogname Site name.
599 599
 	 */
600
-	$blogname = apply_filters( 'newblogname', $blogname );
600
+	$blogname = apply_filters('newblogname', $blogname);
601 601
 
602
-	$blog_title = wp_unslash(  $blog_title );
602
+	$blog_title = wp_unslash($blog_title);
603 603
 
604
-	if ( empty( $blog_title ) )
605
-		$errors->add('blog_title', __( 'Please enter a site title.' ) );
604
+	if (empty($blog_title))
605
+		$errors->add('blog_title', __('Please enter a site title.'));
606 606
 
607 607
 	// Check if the domain/path has been used already.
608
-	if ( is_subdomain_install() ) {
609
-		$mydomain = $blogname . '.' . preg_replace( '|^www\.|', '', $domain );
608
+	if (is_subdomain_install()) {
609
+		$mydomain = $blogname.'.'.preg_replace('|^www\.|', '', $domain);
610 610
 		$path = $base;
611 611
 	} else {
612 612
 		$mydomain = "$domain";
613 613
 		$path = $base.$blogname.'/';
614 614
 	}
615
-	if ( domain_exists($mydomain, $path, $current_network->id) )
616
-		$errors->add( 'blogname', __( 'Sorry, that site already exists!' ) );
615
+	if (domain_exists($mydomain, $path, $current_network->id))
616
+		$errors->add('blogname', __('Sorry, that site already exists!'));
617 617
 
618
-	if ( username_exists( $blogname ) ) {
619
-		if ( ! is_object( $user ) || ( is_object($user) && ( $user->user_login != $blogname ) ) )
620
-			$errors->add( 'blogname', __( 'Sorry, that site is reserved!' ) );
618
+	if (username_exists($blogname)) {
619
+		if ( ! is_object($user) || (is_object($user) && ($user->user_login != $blogname)))
620
+			$errors->add('blogname', __('Sorry, that site is reserved!'));
621 621
 	}
622 622
 
623 623
 	// Has someone already signed up for this domain?
624
-	$signup = $wpdb->get_row( $wpdb->prepare("SELECT * FROM $wpdb->signups WHERE domain = %s AND path = %s", $mydomain, $path) ); // TODO: Check email too?
625
-	if ( ! empty($signup) ) {
626
-		$diff = current_time( 'timestamp', true ) - mysql2date('U', $signup->registered);
624
+	$signup = $wpdb->get_row($wpdb->prepare("SELECT * FROM $wpdb->signups WHERE domain = %s AND path = %s", $mydomain, $path)); // TODO: Check email too?
625
+	if ( ! empty($signup)) {
626
+		$diff = current_time('timestamp', true) - mysql2date('U', $signup->registered);
627 627
 		// If registered more than two days ago, cancel registration and let this signup go through.
628
-		if ( $diff > 2 * DAY_IN_SECONDS )
629
-			$wpdb->delete( $wpdb->signups, array( 'domain' => $mydomain , 'path' => $path ) );
628
+		if ($diff > 2 * DAY_IN_SECONDS)
629
+			$wpdb->delete($wpdb->signups, array('domain' => $mydomain, 'path' => $path));
630 630
 		else
631 631
 			$errors->add('blogname', __('That site is currently reserved but may be available in a couple days.'));
632 632
 	}
@@ -649,7 +649,7 @@  discard block
 block discarded – undo
649 649
 	 *     @type WP_Error       $errors     WP_Error containing any errors found.
650 650
 	 * }
651 651
 	 */
652
-	return apply_filters( 'wpmu_validate_blog_signup', $result );
652
+	return apply_filters('wpmu_validate_blog_signup', $result);
653 653
 }
654 654
 
655 655
 /**
@@ -666,13 +666,13 @@  discard block
 block discarded – undo
666 666
  * @param string $user_email The user's email address.
667 667
  * @param array  $meta       By default, contains the requested privacy setting and lang_id.
668 668
  */
669
-function wpmu_signup_blog( $domain, $path, $title, $user, $user_email, $meta = array() )  {
669
+function wpmu_signup_blog($domain, $path, $title, $user, $user_email, $meta = array()) {
670 670
 	global $wpdb;
671 671
 
672
-	$key = substr( md5( time() . rand() . $domain ), 0, 16 );
672
+	$key = substr(md5(time().rand().$domain), 0, 16);
673 673
 	$meta = serialize($meta);
674 674
 
675
-	$wpdb->insert( $wpdb->signups, array(
675
+	$wpdb->insert($wpdb->signups, array(
676 676
 		'domain' => $domain,
677 677
 		'path' => $path,
678 678
 		'title' => $title,
@@ -681,7 +681,7 @@  discard block
 block discarded – undo
681 681
 		'registered' => current_time('mysql', true),
682 682
 		'activation_key' => $key,
683 683
 		'meta' => $meta
684
-	) );
684
+	));
685 685
 
686 686
 	/**
687 687
 	 * Fires after site signup information has been written to the database.
@@ -696,7 +696,7 @@  discard block
 block discarded – undo
696 696
 	 * @param string $key        The user's activation key
697 697
 	 * @param array  $meta       By default, contains the requested privacy setting and lang_id.
698 698
 	 */
699
-	do_action( 'after_signup_site', $domain, $path, $title, $user, $user_email, $key, $meta );
699
+	do_action('after_signup_site', $domain, $path, $title, $user, $user_email, $key, $meta);
700 700
 }
701 701
 
702 702
 /**
@@ -713,16 +713,16 @@  discard block
 block discarded – undo
713 713
  * @param string $user_email The user's email address.
714 714
  * @param array  $meta       By default, this is an empty array.
715 715
  */
716
-function wpmu_signup_user( $user, $user_email, $meta = array() ) {
716
+function wpmu_signup_user($user, $user_email, $meta = array()) {
717 717
 	global $wpdb;
718 718
 
719 719
 	// Format data
720
-	$user = preg_replace( '/\s+/', '', sanitize_user( $user, true ) );
721
-	$user_email = sanitize_email( $user_email );
722
-	$key = substr( md5( time() . rand() . $user_email ), 0, 16 );
720
+	$user = preg_replace('/\s+/', '', sanitize_user($user, true));
721
+	$user_email = sanitize_email($user_email);
722
+	$key = substr(md5(time().rand().$user_email), 0, 16);
723 723
 	$meta = serialize($meta);
724 724
 
725
-	$wpdb->insert( $wpdb->signups, array(
725
+	$wpdb->insert($wpdb->signups, array(
726 726
 		'domain' => '',
727 727
 		'path' => '',
728 728
 		'title' => '',
@@ -731,7 +731,7 @@  discard block
 block discarded – undo
731 731
 		'registered' => current_time('mysql', true),
732 732
 		'activation_key' => $key,
733 733
 		'meta' => $meta
734
-	) );
734
+	));
735 735
 
736 736
 	/**
737 737
 	 * Fires after a user's signup information has been written to the database.
@@ -743,7 +743,7 @@  discard block
 block discarded – undo
743 743
 	 * @param string $key        The user's activation key
744 744
 	 * @param array  $meta       Additional signup meta. By default, this is an empty array.
745 745
 	 */
746
-	do_action( 'after_signup_user', $user, $user_email, $key, $meta );
746
+	do_action('after_signup_user', $user, $user_email, $key, $meta);
747 747
 }
748 748
 
749 749
 /**
@@ -770,7 +770,7 @@  discard block
 block discarded – undo
770 770
  * @param array  $meta       By default, contains the requested privacy setting and lang_id.
771 771
  * @return bool
772 772
  */
773
-function wpmu_signup_blog_notification( $domain, $path, $title, $user_login, $user_email, $key, $meta = array() ) {
773
+function wpmu_signup_blog_notification($domain, $path, $title, $user_login, $user_email, $key, $meta = array()) {
774 774
 	/**
775 775
 	 * Filters whether to bypass the new site email notification.
776 776
 	 *
@@ -784,25 +784,25 @@  discard block
 block discarded – undo
784 784
 	 * @param string      $key        Activation key created in wpmu_signup_blog().
785 785
 	 * @param array       $meta       By default, contains the requested privacy setting and lang_id.
786 786
 	 */
787
-	if ( ! apply_filters( 'wpmu_signup_blog_notification', $domain, $path, $title, $user_login, $user_email, $key, $meta ) ) {
787
+	if ( ! apply_filters('wpmu_signup_blog_notification', $domain, $path, $title, $user_login, $user_email, $key, $meta)) {
788 788
 		return false;
789 789
 	}
790 790
 
791 791
 	// Send email with activation link.
792
-	if ( !is_subdomain_install() || get_current_network_id() != 1 )
792
+	if ( ! is_subdomain_install() || get_current_network_id() != 1)
793 793
 		$activate_url = network_site_url("wp-activate.php?key=$key");
794 794
 	else
795 795
 		$activate_url = "http://{$domain}{$path}wp-activate.php?key=$key"; // @todo use *_url() API
796 796
 
797 797
 	$activate_url = esc_url($activate_url);
798
-	$admin_email = get_site_option( 'admin_email' );
799
-	if ( $admin_email == '' )
800
-		$admin_email = 'support@' . $_SERVER['SERVER_NAME'];
801
-	$from_name = get_site_option( 'site_name' ) == '' ? 'WordPress' : esc_html( get_site_option( 'site_name' ) );
802
-	$message_headers = "From: \"{$from_name}\" <{$admin_email}>\n" . "Content-Type: text/plain; charset=\"" . get_option('blog_charset') . "\"\n";
798
+	$admin_email = get_site_option('admin_email');
799
+	if ($admin_email == '')
800
+		$admin_email = 'support@'.$_SERVER['SERVER_NAME'];
801
+	$from_name = get_site_option('site_name') == '' ? 'WordPress' : esc_html(get_site_option('site_name'));
802
+	$message_headers = "From: \"{$from_name}\" <{$admin_email}>\n"."Content-Type: text/plain; charset=\"".get_option('blog_charset')."\"\n";
803 803
 
804
-	$user = get_user_by( 'login', $user_login );
805
-	$switched_locale = switch_to_locale( get_user_locale( $user ) );
804
+	$user = get_user_by('login', $user_login);
805
+	$switched_locale = switch_to_locale(get_user_locale($user));
806 806
 
807 807
 	$message = sprintf(
808 808
 		/**
@@ -821,12 +821,12 @@  discard block
 block discarded – undo
821 821
 		 * @param string $key        Activation key created in wpmu_signup_blog().
822 822
 		 * @param array  $meta       By default, contains the requested privacy setting and lang_id.
823 823
 		 */
824
-		apply_filters( 'wpmu_signup_blog_notification_email',
825
-			__( "To activate your blog, please click the following link:\n\n%s\n\nAfter you activate, you will receive *another email* with your login.\n\nAfter you activate, you can visit your site here:\n\n%s" ),
824
+		apply_filters('wpmu_signup_blog_notification_email',
825
+			__("To activate your blog, please click the following link:\n\n%s\n\nAfter you activate, you will receive *another email* with your login.\n\nAfter you activate, you can visit your site here:\n\n%s"),
826 826
 			$domain, $path, $title, $user_login, $user_email, $key, $meta
827 827
 		),
828 828
 		$activate_url,
829
-		esc_url( "http://{$domain}{$path}" ),
829
+		esc_url("http://{$domain}{$path}"),
830 830
 		$key
831 831
 	);
832 832
 	// TODO: Don't hard code activation link.
@@ -845,17 +845,17 @@  discard block
 block discarded – undo
845 845
 		 * @param string $key        Activation key created in wpmu_signup_blog().
846 846
 		 * @param array  $meta       By default, contains the requested privacy setting and lang_id.
847 847
 		 */
848
-		apply_filters( 'wpmu_signup_blog_notification_subject',
848
+		apply_filters('wpmu_signup_blog_notification_subject',
849 849
 			/* translators: New site notification email subject. 1: Network name, 2: New site URL */
850
-			_x( '[%1$s] Activate %2$s', 'New site notification email subject' ),
850
+			_x('[%1$s] Activate %2$s', 'New site notification email subject'),
851 851
 			$domain, $path, $title, $user_login, $user_email, $key, $meta
852 852
 		),
853 853
 		$from_name,
854
-		esc_url( 'http://' . $domain . $path )
854
+		esc_url('http://'.$domain.$path)
855 855
 	);
856
-	wp_mail( $user_email, wp_specialchars_decode( $subject ), $message, $message_headers );
856
+	wp_mail($user_email, wp_specialchars_decode($subject), $message, $message_headers);
857 857
 
858
-	if ( $switched_locale ) {
858
+	if ($switched_locale) {
859 859
 		restore_previous_locale();
860 860
 	}
861 861
 
@@ -883,7 +883,7 @@  discard block
 block discarded – undo
883 883
  * @param array  $meta       By default, an empty array.
884 884
  * @return bool
885 885
  */
886
-function wpmu_signup_user_notification( $user_login, $user_email, $key, $meta = array() ) {
886
+function wpmu_signup_user_notification($user_login, $user_email, $key, $meta = array()) {
887 887
 	/**
888 888
 	 * Filters whether to bypass the email notification for new user sign-up.
889 889
 	 *
@@ -894,18 +894,18 @@  discard block
 block discarded – undo
894 894
 	 * @param string $key        Activation key created in wpmu_signup_user().
895 895
 	 * @param array  $meta       Signup meta data.
896 896
 	 */
897
-	if ( ! apply_filters( 'wpmu_signup_user_notification', $user_login, $user_email, $key, $meta ) )
897
+	if ( ! apply_filters('wpmu_signup_user_notification', $user_login, $user_email, $key, $meta))
898 898
 		return false;
899 899
 
900
-	$user = get_user_by( 'login', $user_login );
901
-	$switched_locale = switch_to_locale( get_user_locale( $user ) );
900
+	$user = get_user_by('login', $user_login);
901
+	$switched_locale = switch_to_locale(get_user_locale($user));
902 902
 
903 903
 	// Send email with activation link.
904
-	$admin_email = get_site_option( 'admin_email' );
905
-	if ( $admin_email == '' )
906
-		$admin_email = 'support@' . $_SERVER['SERVER_NAME'];
907
-	$from_name = get_site_option( 'site_name' ) == '' ? 'WordPress' : esc_html( get_site_option( 'site_name' ) );
908
-	$message_headers = "From: \"{$from_name}\" <{$admin_email}>\n" . "Content-Type: text/plain; charset=\"" . get_option('blog_charset') . "\"\n";
904
+	$admin_email = get_site_option('admin_email');
905
+	if ($admin_email == '')
906
+		$admin_email = 'support@'.$_SERVER['SERVER_NAME'];
907
+	$from_name = get_site_option('site_name') == '' ? 'WordPress' : esc_html(get_site_option('site_name'));
908
+	$message_headers = "From: \"{$from_name}\" <{$admin_email}>\n"."Content-Type: text/plain; charset=\"".get_option('blog_charset')."\"\n";
909 909
 	$message = sprintf(
910 910
 		/**
911 911
 		 * Filters the content of the notification email for new user sign-up.
@@ -920,11 +920,11 @@  discard block
 block discarded – undo
920 920
 		 * @param string $key        Activation key created in wpmu_signup_user().
921 921
 		 * @param array  $meta       Signup meta data.
922 922
 		 */
923
-		apply_filters( 'wpmu_signup_user_notification_email',
924
-			__( "To activate your user, please click the following link:\n\n%s\n\nAfter you activate, you will receive *another email* with your login." ),
923
+		apply_filters('wpmu_signup_user_notification_email',
924
+			__("To activate your user, please click the following link:\n\n%s\n\nAfter you activate, you will receive *another email* with your login."),
925 925
 			$user_login, $user_email, $key, $meta
926 926
 		),
927
-		site_url( "wp-activate.php?key=$key" )
927
+		site_url("wp-activate.php?key=$key")
928 928
 	);
929 929
 	// TODO: Don't hard code activation link.
930 930
 	$subject = sprintf(
@@ -939,17 +939,17 @@  discard block
 block discarded – undo
939 939
 		 * @param string $key        Activation key created in wpmu_signup_user().
940 940
 		 * @param array  $meta       Signup meta data.
941 941
 		 */
942
-		apply_filters( 'wpmu_signup_user_notification_subject',
942
+		apply_filters('wpmu_signup_user_notification_subject',
943 943
 			/* translators: New user notification email subject. 1: Network name, 2: New user login */
944
-			_x( '[%1$s] Activate %2$s', 'New user notification email subject' ),
944
+			_x('[%1$s] Activate %2$s', 'New user notification email subject'),
945 945
 			$user_login, $user_email, $key, $meta
946 946
 		),
947 947
 		$from_name,
948 948
 		$user_login
949 949
 	);
950
-	wp_mail( $user_email, wp_specialchars_decode( $subject ), $message, $message_headers );
950
+	wp_mail($user_email, wp_specialchars_decode($subject), $message, $message_headers);
951 951
 
952
-	if ( $switched_locale ) {
952
+	if ($switched_locale) {
953 953
 		restore_previous_locale();
954 954
 	}
955 955
 
@@ -974,38 +974,38 @@  discard block
 block discarded – undo
974 974
 function wpmu_activate_signup($key) {
975 975
 	global $wpdb;
976 976
 
977
-	$signup = $wpdb->get_row( $wpdb->prepare("SELECT * FROM $wpdb->signups WHERE activation_key = %s", $key) );
977
+	$signup = $wpdb->get_row($wpdb->prepare("SELECT * FROM $wpdb->signups WHERE activation_key = %s", $key));
978 978
 
979
-	if ( empty( $signup ) )
980
-		return new WP_Error( 'invalid_key', __( 'Invalid activation key.' ) );
979
+	if (empty($signup))
980
+		return new WP_Error('invalid_key', __('Invalid activation key.'));
981 981
 
982
-	if ( $signup->active ) {
983
-		if ( empty( $signup->domain ) )
984
-			return new WP_Error( 'already_active', __( 'The user is already active.' ), $signup );
982
+	if ($signup->active) {
983
+		if (empty($signup->domain))
984
+			return new WP_Error('already_active', __('The user is already active.'), $signup);
985 985
 		else
986
-			return new WP_Error( 'already_active', __( 'The site is already active.' ), $signup );
986
+			return new WP_Error('already_active', __('The site is already active.'), $signup);
987 987
 	}
988 988
 
989 989
 	$meta = maybe_unserialize($signup->meta);
990
-	$password = wp_generate_password( 12, false );
990
+	$password = wp_generate_password(12, false);
991 991
 
992 992
 	$user_id = username_exists($signup->user_login);
993 993
 
994
-	if ( ! $user_id )
994
+	if ( ! $user_id)
995 995
 		$user_id = wpmu_create_user($signup->user_login, $password, $signup->user_email);
996 996
 	else
997 997
 		$user_already_exists = true;
998 998
 
999
-	if ( ! $user_id )
999
+	if ( ! $user_id)
1000 1000
 		return new WP_Error('create_user', __('Could not create user'), $signup);
1001 1001
 
1002 1002
 	$now = current_time('mysql', true);
1003 1003
 
1004
-	if ( empty($signup->domain) ) {
1005
-		$wpdb->update( $wpdb->signups, array('active' => 1, 'activated' => $now), array('activation_key' => $key) );
1004
+	if (empty($signup->domain)) {
1005
+		$wpdb->update($wpdb->signups, array('active' => 1, 'activated' => $now), array('activation_key' => $key));
1006 1006
 
1007
-		if ( isset( $user_already_exists ) )
1008
-			return new WP_Error( 'user_already_exists', __( 'That username is already activated.' ), $signup);
1007
+		if (isset($user_already_exists))
1008
+			return new WP_Error('user_already_exists', __('That username is already activated.'), $signup);
1009 1009
 
1010 1010
 		/**
1011 1011
 		 * Fires immediately after a new user is activated.
@@ -1016,24 +1016,24 @@  discard block
 block discarded – undo
1016 1016
 		 * @param int   $password User password.
1017 1017
 		 * @param array $meta     Signup meta data.
1018 1018
 		 */
1019
-		do_action( 'wpmu_activate_user', $user_id, $password, $meta );
1020
-		return array( 'user_id' => $user_id, 'password' => $password, 'meta' => $meta );
1019
+		do_action('wpmu_activate_user', $user_id, $password, $meta);
1020
+		return array('user_id' => $user_id, 'password' => $password, 'meta' => $meta);
1021 1021
 	}
1022 1022
 
1023
-	$blog_id = wpmu_create_blog( $signup->domain, $signup->path, $signup->title, $user_id, $meta, $wpdb->siteid );
1023
+	$blog_id = wpmu_create_blog($signup->domain, $signup->path, $signup->title, $user_id, $meta, $wpdb->siteid);
1024 1024
 
1025 1025
 	// TODO: What to do if we create a user but cannot create a blog?
1026
-	if ( is_wp_error($blog_id) ) {
1026
+	if (is_wp_error($blog_id)) {
1027 1027
 		// If blog is taken, that means a previous attempt to activate this blog failed in between creating the blog and
1028 1028
 		// setting the activation flag. Let's just set the active flag and instruct the user to reset their password.
1029
-		if ( 'blog_taken' == $blog_id->get_error_code() ) {
1030
-			$blog_id->add_data( $signup );
1031
-			$wpdb->update( $wpdb->signups, array( 'active' => 1, 'activated' => $now ), array( 'activation_key' => $key ) );
1029
+		if ('blog_taken' == $blog_id->get_error_code()) {
1030
+			$blog_id->add_data($signup);
1031
+			$wpdb->update($wpdb->signups, array('active' => 1, 'activated' => $now), array('activation_key' => $key));
1032 1032
 		}
1033 1033
 		return $blog_id;
1034 1034
 	}
1035 1035
 
1036
-	$wpdb->update( $wpdb->signups, array('active' => 1, 'activated' => $now), array('activation_key' => $key) );
1036
+	$wpdb->update($wpdb->signups, array('active' => 1, 'activated' => $now), array('activation_key' => $key));
1037 1037
 	/**
1038 1038
 	 * Fires immediately after a site is activated.
1039 1039
 	 *
@@ -1045,7 +1045,7 @@  discard block
 block discarded – undo
1045 1045
 	 * @param string $signup_title  Site title.
1046 1046
 	 * @param array  $meta          Signup meta data.
1047 1047
 	 */
1048
-	do_action( 'wpmu_activate_blog', $blog_id, $user_id, $password, $signup->title, $meta );
1048
+	do_action('wpmu_activate_blog', $blog_id, $user_id, $password, $signup->title, $meta);
1049 1049
 
1050 1050
 	return array('blog_id' => $blog_id, 'user_id' => $user_id, 'password' => $password, 'title' => $signup->title, 'meta' => $meta);
1051 1051
 }
@@ -1065,16 +1065,16 @@  discard block
 block discarded – undo
1065 1065
  * @param string $email     The new user's email address.
1066 1066
  * @return int|false Returns false on failure, or int $user_id on success
1067 1067
  */
1068
-function wpmu_create_user( $user_name, $password, $email ) {
1069
-	$user_name = preg_replace( '/\s+/', '', sanitize_user( $user_name, true ) );
1068
+function wpmu_create_user($user_name, $password, $email) {
1069
+	$user_name = preg_replace('/\s+/', '', sanitize_user($user_name, true));
1070 1070
 
1071
-	$user_id = wp_create_user( $user_name, $password, $email );
1072
-	if ( is_wp_error( $user_id ) )
1071
+	$user_id = wp_create_user($user_name, $password, $email);
1072
+	if (is_wp_error($user_id))
1073 1073
 		return false;
1074 1074
 
1075 1075
 	// Newly created users have no roles or caps until they are added to a blog.
1076
-	delete_user_option( $user_id, 'capabilities' );
1077
-	delete_user_option( $user_id, 'user_level' );
1076
+	delete_user_option($user_id, 'capabilities');
1077
+	delete_user_option($user_id, 'user_level');
1078 1078
 
1079 1079
 	/**
1080 1080
 	 * Fires immediately after a new user is created.
@@ -1083,7 +1083,7 @@  discard block
 block discarded – undo
1083 1083
 	 *
1084 1084
 	 * @param int $user_id User ID.
1085 1085
 	 */
1086
-	do_action( 'wpmu_new_user', $user_id );
1086
+	do_action('wpmu_new_user', $user_id);
1087 1087
 
1088 1088
 	return $user_id;
1089 1089
 }
@@ -1110,33 +1110,33 @@  discard block
 block discarded – undo
1110 1110
  * @param int    $site_id Optional. Only relevant on multi-network installs.
1111 1111
  * @return int|WP_Error Returns WP_Error object on failure, int $blog_id on success
1112 1112
  */
1113
-function wpmu_create_blog( $domain, $path, $title, $user_id, $meta = array(), $site_id = 1 ) {
1113
+function wpmu_create_blog($domain, $path, $title, $user_id, $meta = array(), $site_id = 1) {
1114 1114
 	$defaults = array(
1115 1115
 		'public' => 0,
1116
-		'WPLANG' => get_site_option( 'WPLANG' ),
1116
+		'WPLANG' => get_site_option('WPLANG'),
1117 1117
 	);
1118
-	$meta = wp_parse_args( $meta, $defaults );
1118
+	$meta = wp_parse_args($meta, $defaults);
1119 1119
 
1120
-	$domain = preg_replace( '/\s+/', '', sanitize_user( $domain, true ) );
1120
+	$domain = preg_replace('/\s+/', '', sanitize_user($domain, true));
1121 1121
 
1122
-	if ( is_subdomain_install() )
1123
-		$domain = str_replace( '@', '', $domain );
1122
+	if (is_subdomain_install())
1123
+		$domain = str_replace('@', '', $domain);
1124 1124
 
1125
-	$title = strip_tags( $title );
1125
+	$title = strip_tags($title);
1126 1126
 	$user_id = (int) $user_id;
1127 1127
 
1128
-	if ( empty($path) )
1128
+	if (empty($path))
1129 1129
 		$path = '/';
1130 1130
 
1131 1131
 	// Check if the domain has been used already. We should return an error message.
1132
-	if ( domain_exists($domain, $path, $site_id) )
1133
-		return new WP_Error( 'blog_taken', __( 'Sorry, that site already exists!' ) );
1132
+	if (domain_exists($domain, $path, $site_id))
1133
+		return new WP_Error('blog_taken', __('Sorry, that site already exists!'));
1134 1134
 
1135
-	if ( ! wp_installing() ) {
1136
-		wp_installing( true );
1135
+	if ( ! wp_installing()) {
1136
+		wp_installing(true);
1137 1137
 	}
1138 1138
 
1139
-	if ( ! $blog_id = insert_blog($domain, $path, $site_id) )
1139
+	if ( ! $blog_id = insert_blog($domain, $path, $site_id))
1140 1140
 		return new WP_Error('insert_blog', __('Could not create site.'));
1141 1141
 
1142 1142
 	switch_to_blog($blog_id);
@@ -1145,17 +1145,17 @@  discard block
 block discarded – undo
1145 1145
 
1146 1146
 	add_user_to_blog($blog_id, $user_id, 'administrator');
1147 1147
 
1148
-	foreach ( $meta as $key => $value ) {
1149
-		if ( in_array( $key, array( 'public', 'archived', 'mature', 'spam', 'deleted', 'lang_id' ) ) )
1150
-			update_blog_status( $blog_id, $key, $value );
1148
+	foreach ($meta as $key => $value) {
1149
+		if (in_array($key, array('public', 'archived', 'mature', 'spam', 'deleted', 'lang_id')))
1150
+			update_blog_status($blog_id, $key, $value);
1151 1151
 		else
1152
-			update_option( $key, $value );
1152
+			update_option($key, $value);
1153 1153
 	}
1154 1154
 
1155
-	update_option( 'blog_public', (int) $meta['public'] );
1155
+	update_option('blog_public', (int) $meta['public']);
1156 1156
 
1157
-	if ( ! is_super_admin( $user_id ) && ! get_user_meta( $user_id, 'primary_blog', true ) )
1158
-		update_user_meta( $user_id, 'primary_blog', $blog_id );
1157
+	if ( ! is_super_admin($user_id) && ! get_user_meta($user_id, 'primary_blog', true))
1158
+		update_user_meta($user_id, 'primary_blog', $blog_id);
1159 1159
 
1160 1160
 	restore_current_blog();
1161 1161
 	/**
@@ -1170,9 +1170,9 @@  discard block
 block discarded – undo
1170 1170
 	 * @param int    $site_id Site ID. Only relevant on multi-network installs.
1171 1171
 	 * @param array  $meta    Meta data. Used to set initial site options.
1172 1172
 	 */
1173
-	do_action( 'wpmu_new_blog', $blog_id, $user_id, $domain, $path, $site_id, $meta );
1173
+	do_action('wpmu_new_blog', $blog_id, $user_id, $domain, $path, $site_id, $meta);
1174 1174
 
1175
-	wp_cache_set( 'last_changed', microtime(), 'sites' );
1175
+	wp_cache_set('last_changed', microtime(), 'sites');
1176 1176
 
1177 1177
 	return $blog_id;
1178 1178
 }
@@ -1189,27 +1189,27 @@  discard block
 block discarded – undo
1189 1189
  * @param string $deprecated Not used.
1190 1190
  * @return bool
1191 1191
  */
1192
-function newblog_notify_siteadmin( $blog_id, $deprecated = '' ) {
1193
-	if ( get_site_option( 'registrationnotification' ) != 'yes' )
1192
+function newblog_notify_siteadmin($blog_id, $deprecated = '') {
1193
+	if (get_site_option('registrationnotification') != 'yes')
1194 1194
 		return false;
1195 1195
 
1196
-	$email = get_site_option( 'admin_email' );
1197
-	if ( is_email($email) == false )
1196
+	$email = get_site_option('admin_email');
1197
+	if (is_email($email) == false)
1198 1198
 		return false;
1199 1199
 
1200 1200
 	$options_site_url = esc_url(network_admin_url('settings.php'));
1201 1201
 
1202
-	switch_to_blog( $blog_id );
1203
-	$blogname = get_option( 'blogname' );
1202
+	switch_to_blog($blog_id);
1203
+	$blogname = get_option('blogname');
1204 1204
 	$siteurl = site_url();
1205 1205
 	restore_current_blog();
1206 1206
 
1207 1207
 	/* translators: New site notification email. 1: Site URL, 2: User IP address, 3: Settings screen URL */
1208
-	$msg = sprintf( __( 'New Site: %1$s
1208
+	$msg = sprintf(__('New Site: %1$s
1209 1209
 URL: %2$s
1210 1210
 Remote IP: %3$s
1211 1211
 
1212
-Disable these notifications: %4$s' ), $blogname, $siteurl, wp_unslash( $_SERVER['REMOTE_ADDR'] ), $options_site_url);
1212
+Disable these notifications: %4$s' ), $blogname, $siteurl, wp_unslash($_SERVER['REMOTE_ADDR']), $options_site_url);
1213 1213
 	/**
1214 1214
 	 * Filters the message body of the new site activation email sent
1215 1215
 	 * to the network administrator.
@@ -1218,9 +1218,9 @@  discard block
 block discarded – undo
1218 1218
 	 *
1219 1219
 	 * @param string $msg Email body.
1220 1220
 	 */
1221
-	$msg = apply_filters( 'newblog_notify_siteadmin', $msg );
1221
+	$msg = apply_filters('newblog_notify_siteadmin', $msg);
1222 1222
 
1223
-	wp_mail( $email, sprintf( __( 'New Site Registration: %s' ), $siteurl ), $msg );
1223
+	wp_mail($email, sprintf(__('New Site Registration: %s'), $siteurl), $msg);
1224 1224
 	return true;
1225 1225
 }
1226 1226
 
@@ -1235,23 +1235,23 @@  discard block
 block discarded – undo
1235 1235
  * @param int $user_id The new user's ID.
1236 1236
  * @return bool
1237 1237
  */
1238
-function newuser_notify_siteadmin( $user_id ) {
1239
-	if ( get_site_option( 'registrationnotification' ) != 'yes' )
1238
+function newuser_notify_siteadmin($user_id) {
1239
+	if (get_site_option('registrationnotification') != 'yes')
1240 1240
 		return false;
1241 1241
 
1242
-	$email = get_site_option( 'admin_email' );
1242
+	$email = get_site_option('admin_email');
1243 1243
 
1244
-	if ( is_email($email) == false )
1244
+	if (is_email($email) == false)
1245 1245
 		return false;
1246 1246
 
1247
-	$user = get_userdata( $user_id );
1247
+	$user = get_userdata($user_id);
1248 1248
 
1249 1249
 	$options_site_url = esc_url(network_admin_url('settings.php'));
1250 1250
 	/* translators: New user notification email. 1: User login, 2: User IP address, 3: Settings screen URL */
1251 1251
 	$msg = sprintf(__('New User: %1$s
1252 1252
 Remote IP: %2$s
1253 1253
 
1254
-Disable these notifications: %3$s'), $user->user_login, wp_unslash( $_SERVER['REMOTE_ADDR'] ), $options_site_url);
1254
+Disable these notifications: %3$s'), $user->user_login, wp_unslash($_SERVER['REMOTE_ADDR']), $options_site_url);
1255 1255
 
1256 1256
 	/**
1257 1257
 	 * Filters the message body of the new user activation email sent
@@ -1262,8 +1262,8 @@  discard block
 block discarded – undo
1262 1262
 	 * @param string  $msg  Email body.
1263 1263
 	 * @param WP_User $user WP_User instance of the new user.
1264 1264
 	 */
1265
-	$msg = apply_filters( 'newuser_notify_siteadmin', $msg, $user );
1266
-	wp_mail( $email, sprintf(__('New User Registration: %s'), $user->user_login), $msg );
1265
+	$msg = apply_filters('newuser_notify_siteadmin', $msg, $user);
1266
+	wp_mail($email, sprintf(__('New User Registration: %s'), $user->user_login), $msg);
1267 1267
 	return true;
1268 1268
 }
1269 1269
 
@@ -1283,15 +1283,15 @@  discard block
 block discarded – undo
1283 1283
  * @return int
1284 1284
  */
1285 1285
 function domain_exists($domain, $path, $site_id = 1) {
1286
-	$path = trailingslashit( $path );
1286
+	$path = trailingslashit($path);
1287 1287
 	$args = array(
1288 1288
 		'network_id' => $site_id,
1289 1289
 		'domain' => $domain,
1290 1290
 		'path' => $path,
1291 1291
 		'fields' => 'ids',
1292 1292
 	);
1293
-	$result = get_sites( $args );
1294
-	$result = array_shift( $result );
1293
+	$result = get_sites($args);
1294
+	$result = array_shift($result);
1295 1295
 
1296 1296
 	/**
1297 1297
 	 * Filters whether a blogname is taken.
@@ -1303,7 +1303,7 @@  discard block
 block discarded – undo
1303 1303
 	 * @param string   $path    Path to be checked.
1304 1304
 	 * @param int      $site_id Site ID. Relevant only on multi-network installs.
1305 1305
 	 */
1306
-	return apply_filters( 'domain_exists', $result, $domain, $path, $site_id );
1306
+	return apply_filters('domain_exists', $result, $domain, $path, $site_id);
1307 1307
 }
1308 1308
 
1309 1309
 /**
@@ -1327,12 +1327,12 @@  discard block
 block discarded – undo
1327 1327
 	$path = trailingslashit($path);
1328 1328
 	$site_id = (int) $site_id;
1329 1329
 
1330
-	$result = $wpdb->insert( $wpdb->blogs, array('site_id' => $site_id, 'domain' => $domain, 'path' => $path, 'registered' => current_time('mysql')) );
1331
-	if ( ! $result )
1330
+	$result = $wpdb->insert($wpdb->blogs, array('site_id' => $site_id, 'domain' => $domain, 'path' => $path, 'registered' => current_time('mysql')));
1331
+	if ( ! $result)
1332 1332
 		return false;
1333 1333
 
1334 1334
 	$blog_id = $wpdb->insert_id;
1335
-	refresh_blog_details( $blog_id );
1335
+	refresh_blog_details($blog_id);
1336 1336
 
1337 1337
 	wp_maybe_update_network_site_counts();
1338 1338
 
@@ -1354,57 +1354,57 @@  discard block
 block discarded – undo
1354 1354
  * @param int    $blog_id    The value returned by insert_blog().
1355 1355
  * @param string $blog_title The title of the new site.
1356 1356
  */
1357
-function install_blog( $blog_id, $blog_title = '' ) {
1357
+function install_blog($blog_id, $blog_title = '') {
1358 1358
 	global $wpdb, $wp_roles;
1359 1359
 
1360 1360
 	// Cast for security
1361 1361
 	$blog_id = (int) $blog_id;
1362 1362
 
1363
-	require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
1363
+	require_once(ABSPATH.'wp-admin/includes/upgrade.php');
1364 1364
 
1365 1365
 	$suppress = $wpdb->suppress_errors();
1366
-	if ( $wpdb->get_results( "DESCRIBE {$wpdb->posts}" ) )
1367
-		die( '<h1>' . __( 'Already Installed' ) . '</h1><p>' . __( 'You appear to have already installed WordPress. To reinstall please clear your old database tables first.' ) . '</p></body></html>' );
1368
-	$wpdb->suppress_errors( $suppress );
1366
+	if ($wpdb->get_results("DESCRIBE {$wpdb->posts}"))
1367
+		die('<h1>'.__('Already Installed').'</h1><p>'.__('You appear to have already installed WordPress. To reinstall please clear your old database tables first.').'</p></body></html>');
1368
+	$wpdb->suppress_errors($suppress);
1369 1369
 
1370
-	$url = get_blogaddress_by_id( $blog_id );
1370
+	$url = get_blogaddress_by_id($blog_id);
1371 1371
 
1372 1372
 	// Set everything up
1373
-	make_db_current_silent( 'blog' );
1373
+	make_db_current_silent('blog');
1374 1374
 	populate_options();
1375 1375
 	populate_roles();
1376 1376
 
1377 1377
 	// populate_roles() clears previous role definitions so we start over.
1378 1378
 	$wp_roles = new WP_Roles();
1379 1379
 
1380
-	$siteurl = $home = untrailingslashit( $url );
1380
+	$siteurl = $home = untrailingslashit($url);
1381 1381
 
1382
-	if ( ! is_subdomain_install() ) {
1382
+	if ( ! is_subdomain_install()) {
1383 1383
 
1384
- 		if ( 'https' === parse_url( get_site_option( 'siteurl' ), PHP_URL_SCHEME ) ) {
1385
- 			$siteurl = set_url_scheme( $siteurl, 'https' );
1384
+ 		if ('https' === parse_url(get_site_option('siteurl'), PHP_URL_SCHEME)) {
1385
+ 			$siteurl = set_url_scheme($siteurl, 'https');
1386 1386
  		}
1387
- 		if ( 'https' === parse_url( get_home_url( get_network()->site_id ), PHP_URL_SCHEME ) ) {
1388
- 			$home = set_url_scheme( $home, 'https' );
1387
+ 		if ('https' === parse_url(get_home_url(get_network()->site_id), PHP_URL_SCHEME)) {
1388
+ 			$home = set_url_scheme($home, 'https');
1389 1389
  		}
1390 1390
 
1391 1391
 	}
1392 1392
 
1393
-	update_option( 'siteurl', $siteurl );
1394
-	update_option( 'home', $home );
1393
+	update_option('siteurl', $siteurl);
1394
+	update_option('home', $home);
1395 1395
 
1396
-	if ( get_site_option( 'ms_files_rewriting' ) )
1397
-		update_option( 'upload_path', UPLOADBLOGSDIR . "/$blog_id/files" );
1396
+	if (get_site_option('ms_files_rewriting'))
1397
+		update_option('upload_path', UPLOADBLOGSDIR."/$blog_id/files");
1398 1398
 	else
1399
-		update_option( 'upload_path', get_blog_option( get_network()->site_id, 'upload_path' ) );
1399
+		update_option('upload_path', get_blog_option(get_network()->site_id, 'upload_path'));
1400 1400
 
1401
-	update_option( 'blogname', wp_unslash( $blog_title ) );
1402
-	update_option( 'admin_email', '' );
1401
+	update_option('blogname', wp_unslash($blog_title));
1402
+	update_option('admin_email', '');
1403 1403
 
1404 1404
 	// remove all perms
1405 1405
 	$table_prefix = $wpdb->get_blog_prefix();
1406
-	delete_metadata( 'user', 0, $table_prefix . 'user_level',   null, true ); // delete all
1407
-	delete_metadata( 'user', 0, $table_prefix . 'capabilities', null, true ); // delete all
1406
+	delete_metadata('user', 0, $table_prefix.'user_level', null, true); // delete all
1407
+	delete_metadata('user', 0, $table_prefix.'capabilities', null, true); // delete all
1408 1408
 }
1409 1409
 
1410 1410
 /**
@@ -1424,13 +1424,13 @@  discard block
 block discarded – undo
1424 1424
 function install_blog_defaults($blog_id, $user_id) {
1425 1425
 	global $wpdb;
1426 1426
 
1427
-	require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
1427
+	require_once(ABSPATH.'wp-admin/includes/upgrade.php');
1428 1428
 
1429 1429
 	$suppress = $wpdb->suppress_errors();
1430 1430
 
1431 1431
 	wp_install_defaults($user_id);
1432 1432
 
1433
-	$wpdb->suppress_errors( $suppress );
1433
+	$wpdb->suppress_errors($suppress);
1434 1434
 }
1435 1435
 
1436 1436
 /**
@@ -1450,7 +1450,7 @@  discard block
 block discarded – undo
1450 1450
  * @param array  $meta     Optional. Not used in the default function, but is passed along to hooks for customization.
1451 1451
  * @return bool
1452 1452
  */
1453
-function wpmu_welcome_notification( $blog_id, $user_id, $password, $title, $meta = array() ) {
1453
+function wpmu_welcome_notification($blog_id, $user_id, $password, $title, $meta = array()) {
1454 1454
 	$current_network = get_network();
1455 1455
 
1456 1456
 	/**
@@ -1466,17 +1466,17 @@  discard block
 block discarded – undo
1466 1466
 	 * @param string   $title    Site title.
1467 1467
 	 * @param array    $meta     Signup meta data.
1468 1468
 	 */
1469
-	if ( ! apply_filters( 'wpmu_welcome_notification', $blog_id, $user_id, $password, $title, $meta ) )
1469
+	if ( ! apply_filters('wpmu_welcome_notification', $blog_id, $user_id, $password, $title, $meta))
1470 1470
 		return false;
1471 1471
 
1472
-	$user = get_userdata( $user_id );
1472
+	$user = get_userdata($user_id);
1473 1473
 
1474
-	$switched_locale = switch_to_locale( get_user_locale( $user ) );
1474
+	$switched_locale = switch_to_locale(get_user_locale($user));
1475 1475
 
1476
-	$welcome_email = get_site_option( 'welcome_email' );
1477
-	if ( $welcome_email == false ) {
1476
+	$welcome_email = get_site_option('welcome_email');
1477
+	if ($welcome_email == false) {
1478 1478
 		/* translators: Do not translate USERNAME, SITE_NAME, BLOG_URL, PASSWORD: those are placeholders. */
1479
-		$welcome_email = __( 'Howdy USERNAME,
1479
+		$welcome_email = __('Howdy USERNAME,
1480 1480
 
1481 1481
 Your new SITE_NAME site has been successfully set up at:
1482 1482
 BLOG_URL
@@ -1494,11 +1494,11 @@  discard block
 block discarded – undo
1494 1494
 
1495 1495
 	$url = get_blogaddress_by_id($blog_id);
1496 1496
 
1497
-	$welcome_email = str_replace( 'SITE_NAME', $current_network->site_name, $welcome_email );
1498
-	$welcome_email = str_replace( 'BLOG_TITLE', $title, $welcome_email );
1499
-	$welcome_email = str_replace( 'BLOG_URL', $url, $welcome_email );
1500
-	$welcome_email = str_replace( 'USERNAME', $user->user_login, $welcome_email );
1501
-	$welcome_email = str_replace( 'PASSWORD', $password, $welcome_email );
1497
+	$welcome_email = str_replace('SITE_NAME', $current_network->site_name, $welcome_email);
1498
+	$welcome_email = str_replace('BLOG_TITLE', $title, $welcome_email);
1499
+	$welcome_email = str_replace('BLOG_URL', $url, $welcome_email);
1500
+	$welcome_email = str_replace('USERNAME', $user->user_login, $welcome_email);
1501
+	$welcome_email = str_replace('PASSWORD', $password, $welcome_email);
1502 1502
 
1503 1503
 	/**
1504 1504
 	 * Filters the content of the welcome email after site activation.
@@ -1514,21 +1514,21 @@  discard block
 block discarded – undo
1514 1514
 	 * @param string $title         Site title.
1515 1515
 	 * @param array  $meta          Signup meta data.
1516 1516
 	 */
1517
-	$welcome_email = apply_filters( 'update_welcome_email', $welcome_email, $blog_id, $user_id, $password, $title, $meta );
1518
-	$admin_email = get_site_option( 'admin_email' );
1517
+	$welcome_email = apply_filters('update_welcome_email', $welcome_email, $blog_id, $user_id, $password, $title, $meta);
1518
+	$admin_email = get_site_option('admin_email');
1519 1519
 
1520
-	if ( $admin_email == '' )
1521
-		$admin_email = 'support@' . $_SERVER['SERVER_NAME'];
1520
+	if ($admin_email == '')
1521
+		$admin_email = 'support@'.$_SERVER['SERVER_NAME'];
1522 1522
 
1523
-	$from_name = get_site_option( 'site_name' ) == '' ? 'WordPress' : esc_html( get_site_option( 'site_name' ) );
1524
-	$message_headers = "From: \"{$from_name}\" <{$admin_email}>\n" . "Content-Type: text/plain; charset=\"" . get_option('blog_charset') . "\"\n";
1523
+	$from_name = get_site_option('site_name') == '' ? 'WordPress' : esc_html(get_site_option('site_name'));
1524
+	$message_headers = "From: \"{$from_name}\" <{$admin_email}>\n"."Content-Type: text/plain; charset=\"".get_option('blog_charset')."\"\n";
1525 1525
 	$message = $welcome_email;
1526 1526
 
1527
-	if ( empty( $current_network->site_name ) )
1527
+	if (empty($current_network->site_name))
1528 1528
 		$current_network->site_name = 'WordPress';
1529 1529
 
1530 1530
 	/* translators: New site notification email subject. 1: Network name, 2: New site name */
1531
-	$subject = __( 'New %1$s Site: %2$s' );
1531
+	$subject = __('New %1$s Site: %2$s');
1532 1532
 
1533 1533
 	/**
1534 1534
 	 * Filters the subject of the welcome email after site activation.
@@ -1537,10 +1537,10 @@  discard block
 block discarded – undo
1537 1537
 	 *
1538 1538
 	 * @param string $subject Subject of the email.
1539 1539
 	 */
1540
-	$subject = apply_filters( 'update_welcome_subject', sprintf( $subject, $current_network->site_name, wp_unslash( $title ) ) );
1541
-	wp_mail( $user->user_email, wp_specialchars_decode( $subject ), $message, $message_headers );
1540
+	$subject = apply_filters('update_welcome_subject', sprintf($subject, $current_network->site_name, wp_unslash($title)));
1541
+	wp_mail($user->user_email, wp_specialchars_decode($subject), $message, $message_headers);
1542 1542
 
1543
-	if ( $switched_locale ) {
1543
+	if ($switched_locale) {
1544 1544
 		restore_previous_locale();
1545 1545
 	}
1546 1546
 
@@ -1562,7 +1562,7 @@  discard block
 block discarded – undo
1562 1562
  * @param array  $meta     Optional. Not used in the default function, but is passed along to hooks for customization.
1563 1563
  * @return bool
1564 1564
  */
1565
-function wpmu_welcome_user_notification( $user_id, $password, $meta = array() ) {
1565
+function wpmu_welcome_user_notification($user_id, $password, $meta = array()) {
1566 1566
 	$current_network = get_network();
1567 1567
 
1568 1568
 	/**
@@ -1576,14 +1576,14 @@  discard block
 block discarded – undo
1576 1576
 	 * @param string $password User password.
1577 1577
 	 * @param array  $meta     Signup meta data.
1578 1578
 	 */
1579
-	if ( ! apply_filters( 'wpmu_welcome_user_notification', $user_id, $password, $meta ) )
1579
+	if ( ! apply_filters('wpmu_welcome_user_notification', $user_id, $password, $meta))
1580 1580
 		return false;
1581 1581
 
1582
-	$welcome_email = get_site_option( 'welcome_user_email' );
1582
+	$welcome_email = get_site_option('welcome_user_email');
1583 1583
 
1584
-	$user = get_userdata( $user_id );
1584
+	$user = get_userdata($user_id);
1585 1585
 
1586
-	$switched_locale = switch_to_locale( get_user_locale( $user ) );
1586
+	$switched_locale = switch_to_locale(get_user_locale($user));
1587 1587
 
1588 1588
 	/**
1589 1589
 	 * Filters the content of the welcome email after user activation.
@@ -1597,26 +1597,26 @@  discard block
 block discarded – undo
1597 1597
 	 * @param string $password      User password.
1598 1598
 	 * @param array  $meta          Signup meta data.
1599 1599
 	 */
1600
-	$welcome_email = apply_filters( 'update_welcome_user_email', $welcome_email, $user_id, $password, $meta );
1601
-	$welcome_email = str_replace( 'SITE_NAME', $current_network->site_name, $welcome_email );
1602
-	$welcome_email = str_replace( 'USERNAME', $user->user_login, $welcome_email );
1603
-	$welcome_email = str_replace( 'PASSWORD', $password, $welcome_email );
1604
-	$welcome_email = str_replace( 'LOGINLINK', wp_login_url(), $welcome_email );
1600
+	$welcome_email = apply_filters('update_welcome_user_email', $welcome_email, $user_id, $password, $meta);
1601
+	$welcome_email = str_replace('SITE_NAME', $current_network->site_name, $welcome_email);
1602
+	$welcome_email = str_replace('USERNAME', $user->user_login, $welcome_email);
1603
+	$welcome_email = str_replace('PASSWORD', $password, $welcome_email);
1604
+	$welcome_email = str_replace('LOGINLINK', wp_login_url(), $welcome_email);
1605 1605
 
1606
-	$admin_email = get_site_option( 'admin_email' );
1606
+	$admin_email = get_site_option('admin_email');
1607 1607
 
1608
-	if ( $admin_email == '' )
1609
-		$admin_email = 'support@' . $_SERVER['SERVER_NAME'];
1608
+	if ($admin_email == '')
1609
+		$admin_email = 'support@'.$_SERVER['SERVER_NAME'];
1610 1610
 
1611
-	$from_name = get_site_option( 'site_name' ) == '' ? 'WordPress' : esc_html( get_site_option( 'site_name' ) );
1612
-	$message_headers = "From: \"{$from_name}\" <{$admin_email}>\n" . "Content-Type: text/plain; charset=\"" . get_option('blog_charset') . "\"\n";
1611
+	$from_name = get_site_option('site_name') == '' ? 'WordPress' : esc_html(get_site_option('site_name'));
1612
+	$message_headers = "From: \"{$from_name}\" <{$admin_email}>\n"."Content-Type: text/plain; charset=\"".get_option('blog_charset')."\"\n";
1613 1613
 	$message = $welcome_email;
1614 1614
 
1615
-	if ( empty( $current_network->site_name ) )
1615
+	if (empty($current_network->site_name))
1616 1616
 		$current_network->site_name = 'WordPress';
1617 1617
 
1618 1618
 	/* translators: New user notification email subject. 1: Network name, 2: New user login */
1619
-	$subject = __( 'New %1$s User: %2$s' );
1619
+	$subject = __('New %1$s User: %2$s');
1620 1620
 
1621 1621
 	/**
1622 1622
 	 * Filters the subject of the welcome email after user activation.
@@ -1625,10 +1625,10 @@  discard block
 block discarded – undo
1625 1625
 	 *
1626 1626
 	 * @param string $subject Subject of the email.
1627 1627
 	 */
1628
-	$subject = apply_filters( 'update_welcome_user_subject', sprintf( $subject, $current_network->site_name, $user->user_login) );
1629
-	wp_mail( $user->user_email, wp_specialchars_decode( $subject ), $message, $message_headers );
1628
+	$subject = apply_filters('update_welcome_user_subject', sprintf($subject, $current_network->site_name, $user->user_login));
1629
+	wp_mail($user->user_email, wp_specialchars_decode($subject), $message, $message_headers);
1630 1630
 
1631
-	if ( $switched_locale ) {
1631
+	if ($switched_locale) {
1632 1632
 		restore_previous_locale();
1633 1633
 	}
1634 1634
 
@@ -1667,26 +1667,26 @@  discard block
 block discarded – undo
1667 1667
  * @param int $user_id
1668 1668
  * @return array Contains the blog_id, post_id, post_date_gmt, and post_gmt_ts
1669 1669
  */
1670
-function get_most_recent_post_of_user( $user_id ) {
1670
+function get_most_recent_post_of_user($user_id) {
1671 1671
 	global $wpdb;
1672 1672
 
1673
-	$user_blogs = get_blogs_of_user( (int) $user_id );
1673
+	$user_blogs = get_blogs_of_user((int) $user_id);
1674 1674
 	$most_recent_post = array();
1675 1675
 
1676 1676
 	// Walk through each blog and get the most recent post
1677 1677
 	// published by $user_id
1678
-	foreach ( (array) $user_blogs as $blog ) {
1679
-		$prefix = $wpdb->get_blog_prefix( $blog->userblog_id );
1680
-		$recent_post = $wpdb->get_row( $wpdb->prepare("SELECT ID, post_date_gmt FROM {$prefix}posts WHERE post_author = %d AND post_type = 'post' AND post_status = 'publish' ORDER BY post_date_gmt DESC LIMIT 1", $user_id ), ARRAY_A);
1678
+	foreach ((array) $user_blogs as $blog) {
1679
+		$prefix = $wpdb->get_blog_prefix($blog->userblog_id);
1680
+		$recent_post = $wpdb->get_row($wpdb->prepare("SELECT ID, post_date_gmt FROM {$prefix}posts WHERE post_author = %d AND post_type = 'post' AND post_status = 'publish' ORDER BY post_date_gmt DESC LIMIT 1", $user_id), ARRAY_A);
1681 1681
 
1682 1682
 		// Make sure we found a post
1683
-		if ( isset($recent_post['ID']) ) {
1683
+		if (isset($recent_post['ID'])) {
1684 1684
 			$post_gmt_ts = strtotime($recent_post['post_date_gmt']);
1685 1685
 
1686 1686
 			// If this is the first post checked or if this post is
1687 1687
 			// newer than the current recent post, make it the new
1688 1688
 			// most recent post.
1689
-			if ( !isset($most_recent_post['post_gmt_ts']) || ( $post_gmt_ts > $most_recent_post['post_gmt_ts'] ) ) {
1689
+			if ( ! isset($most_recent_post['post_gmt_ts']) || ($post_gmt_ts > $most_recent_post['post_gmt_ts'])) {
1690 1690
 				$most_recent_post = array(
1691 1691
 					'blog_id'		=> $blog->userblog_id,
1692 1692
 					'post_id'		=> $recent_post['ID'],
@@ -1713,24 +1713,24 @@  discard block
 block discarded – undo
1713 1713
  * @param string $directory Full path of a directory.
1714 1714
  * @return int Size of the directory in MB.
1715 1715
  */
1716
-function get_dirsize( $directory ) {
1717
-	$dirsize = get_transient( 'dirsize_cache' );
1718
-	if ( is_array( $dirsize ) && isset( $dirsize[ $directory ][ 'size' ] ) )
1719
-		return $dirsize[ $directory ][ 'size' ];
1716
+function get_dirsize($directory) {
1717
+	$dirsize = get_transient('dirsize_cache');
1718
+	if (is_array($dirsize) && isset($dirsize[$directory]['size']))
1719
+		return $dirsize[$directory]['size'];
1720 1720
 
1721
-	if ( ! is_array( $dirsize ) )
1721
+	if ( ! is_array($dirsize))
1722 1722
 		$dirsize = array();
1723 1723
 
1724 1724
 	// Exclude individual site directories from the total when checking the main site,
1725 1725
 	// as they are subdirectories and should not be counted.
1726
-	if ( is_main_site() ) {
1727
-		$dirsize[ $directory ][ 'size' ] = recurse_dirsize( $directory, $directory . '/sites' );
1726
+	if (is_main_site()) {
1727
+		$dirsize[$directory]['size'] = recurse_dirsize($directory, $directory.'/sites');
1728 1728
 	} else {
1729
-		$dirsize[ $directory ][ 'size' ] = recurse_dirsize( $directory );
1729
+		$dirsize[$directory]['size'] = recurse_dirsize($directory);
1730 1730
 	}
1731 1731
 
1732
-	set_transient( 'dirsize_cache', $dirsize, HOUR_IN_SECONDS );
1733
-	return $dirsize[ $directory ][ 'size' ];
1732
+	set_transient('dirsize_cache', $dirsize, HOUR_IN_SECONDS);
1733
+	return $dirsize[$directory]['size'];
1734 1734
 }
1735 1735
 
1736 1736
 /**
@@ -1746,23 +1746,23 @@  discard block
 block discarded – undo
1746 1746
  * @param string $exclude   Optional. Full path of a subdirectory to exclude from the total.
1747 1747
  * @return int|false Size in MB if a valid directory. False if not.
1748 1748
  */
1749
-function recurse_dirsize( $directory, $exclude = null ) {
1749
+function recurse_dirsize($directory, $exclude = null) {
1750 1750
 	$size = 0;
1751 1751
 
1752
-	$directory = untrailingslashit( $directory );
1752
+	$directory = untrailingslashit($directory);
1753 1753
 
1754
-	if ( ! file_exists( $directory ) || ! is_dir( $directory ) || ! is_readable( $directory ) || $directory === $exclude ) {
1754
+	if ( ! file_exists($directory) || ! is_dir($directory) || ! is_readable($directory) || $directory === $exclude) {
1755 1755
 		return false;
1756 1756
 	}
1757 1757
 
1758 1758
 	if ($handle = opendir($directory)) {
1759
-		while(($file = readdir($handle)) !== false) {
1759
+		while (($file = readdir($handle)) !== false) {
1760 1760
 			$path = $directory.'/'.$file;
1761 1761
 			if ($file != '.' && $file != '..') {
1762 1762
 				if (is_file($path)) {
1763 1763
 					$size += filesize($path);
1764 1764
 				} elseif (is_dir($path)) {
1765
-					$handlesize = recurse_dirsize( $path, $exclude );
1765
+					$handlesize = recurse_dirsize($path, $exclude);
1766 1766
 					if ($handlesize > 0)
1767 1767
 						$size += $handlesize;
1768 1768
 				}
@@ -1787,12 +1787,12 @@  discard block
 block discarded – undo
1787 1787
  * @param array $mimes
1788 1788
  * @return array
1789 1789
  */
1790
-function check_upload_mimes( $mimes ) {
1791
-	$site_exts = explode( ' ', get_site_option( 'upload_filetypes', 'jpg jpeg png gif' ) );
1790
+function check_upload_mimes($mimes) {
1791
+	$site_exts = explode(' ', get_site_option('upload_filetypes', 'jpg jpeg png gif'));
1792 1792
 	$site_mimes = array();
1793
-	foreach ( $site_exts as $ext ) {
1794
-		foreach ( $mimes as $ext_pattern => $mime ) {
1795
-			if ( $ext != '' && strpos( $ext_pattern, $ext ) !== false )
1793
+	foreach ($site_exts as $ext) {
1794
+		foreach ($mimes as $ext_pattern => $mime) {
1795
+			if ($ext != '' && strpos($ext_pattern, $ext) !== false)
1796 1796
 				$site_mimes[$ext_pattern] = $mime;
1797 1797
 		}
1798 1798
 	}
@@ -1813,9 +1813,9 @@  discard block
 block discarded – undo
1813 1813
  *
1814 1814
  * @param string $deprecated Not used.
1815 1815
  */
1816
-function update_posts_count( $deprecated = '' ) {
1816
+function update_posts_count($deprecated = '') {
1817 1817
 	global $wpdb;
1818
-	update_option( 'post_count', (int) $wpdb->get_var( "SELECT COUNT(ID) FROM {$wpdb->posts} WHERE post_status = 'publish' and post_type = 'post'" ) );
1818
+	update_option('post_count', (int) $wpdb->get_var("SELECT COUNT(ID) FROM {$wpdb->posts} WHERE post_status = 'publish' and post_type = 'post'"));
1819 1819
 }
1820 1820
 
1821 1821
 /**
@@ -1828,11 +1828,11 @@  discard block
 block discarded – undo
1828 1828
  * @param int $blog_id
1829 1829
  * @param int $user_id
1830 1830
  */
1831
-function wpmu_log_new_registrations( $blog_id, $user_id ) {
1831
+function wpmu_log_new_registrations($blog_id, $user_id) {
1832 1832
 	global $wpdb;
1833
-	$user = get_userdata( (int) $user_id );
1834
-	if ( $user )
1835
-		$wpdb->insert( $wpdb->registration_log, array('email' => $user->user_email, 'IP' => preg_replace( '/[^0-9., ]/', '', wp_unslash( $_SERVER['REMOTE_ADDR'] ) ), 'blog_id' => $blog_id, 'date_registered' => current_time('mysql')) );
1833
+	$user = get_userdata((int) $user_id);
1834
+	if ($user)
1835
+		$wpdb->insert($wpdb->registration_log, array('email' => $user->user_email, 'IP' => preg_replace('/[^0-9., ]/', '', wp_unslash($_SERVER['REMOTE_ADDR'])), 'blog_id' => $blog_id, 'date_registered' => current_time('mysql')));
1836 1836
 }
1837 1837
 
1838 1838
 /**
@@ -1849,61 +1849,61 @@  discard block
 block discarded – undo
1849 1849
  * @param string $deprecated Not used.
1850 1850
  * @return int An ID from the global terms table mapped from $term_id.
1851 1851
  */
1852
-function global_terms( $term_id, $deprecated = '' ) {
1852
+function global_terms($term_id, $deprecated = '') {
1853 1853
 	global $wpdb;
1854 1854
 	static $global_terms_recurse = null;
1855 1855
 
1856
-	if ( !global_terms_enabled() )
1856
+	if ( ! global_terms_enabled())
1857 1857
 		return $term_id;
1858 1858
 
1859 1859
 	// prevent a race condition
1860 1860
 	$recurse_start = false;
1861
-	if ( $global_terms_recurse === null ) {
1861
+	if ($global_terms_recurse === null) {
1862 1862
 		$recurse_start = true;
1863 1863
 		$global_terms_recurse = 1;
1864
-	} elseif ( 10 < $global_terms_recurse++ ) {
1864
+	} elseif (10 < $global_terms_recurse++) {
1865 1865
 		return $term_id;
1866 1866
 	}
1867 1867
 
1868
-	$term_id = intval( $term_id );
1869
-	$c = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM $wpdb->terms WHERE term_id = %d", $term_id ) );
1868
+	$term_id = intval($term_id);
1869
+	$c = $wpdb->get_row($wpdb->prepare("SELECT * FROM $wpdb->terms WHERE term_id = %d", $term_id));
1870 1870
 
1871
-	$global_id = $wpdb->get_var( $wpdb->prepare( "SELECT cat_ID FROM $wpdb->sitecategories WHERE category_nicename = %s", $c->slug ) );
1872
-	if ( $global_id == null ) {
1873
-		$used_global_id = $wpdb->get_var( $wpdb->prepare( "SELECT cat_ID FROM $wpdb->sitecategories WHERE cat_ID = %d", $c->term_id ) );
1874
-		if ( null == $used_global_id ) {
1875
-			$wpdb->insert( $wpdb->sitecategories, array( 'cat_ID' => $term_id, 'cat_name' => $c->name, 'category_nicename' => $c->slug ) );
1871
+	$global_id = $wpdb->get_var($wpdb->prepare("SELECT cat_ID FROM $wpdb->sitecategories WHERE category_nicename = %s", $c->slug));
1872
+	if ($global_id == null) {
1873
+		$used_global_id = $wpdb->get_var($wpdb->prepare("SELECT cat_ID FROM $wpdb->sitecategories WHERE cat_ID = %d", $c->term_id));
1874
+		if (null == $used_global_id) {
1875
+			$wpdb->insert($wpdb->sitecategories, array('cat_ID' => $term_id, 'cat_name' => $c->name, 'category_nicename' => $c->slug));
1876 1876
 			$global_id = $wpdb->insert_id;
1877
-			if ( empty( $global_id ) )
1877
+			if (empty($global_id))
1878 1878
 				return $term_id;
1879 1879
 		} else {
1880
-			$max_global_id = $wpdb->get_var( "SELECT MAX(cat_ID) FROM $wpdb->sitecategories" );
1881
-			$max_local_id = $wpdb->get_var( "SELECT MAX(term_id) FROM $wpdb->terms" );
1882
-			$new_global_id = max( $max_global_id, $max_local_id ) + mt_rand( 100, 400 );
1883
-			$wpdb->insert( $wpdb->sitecategories, array( 'cat_ID' => $new_global_id, 'cat_name' => $c->name, 'category_nicename' => $c->slug ) );
1880
+			$max_global_id = $wpdb->get_var("SELECT MAX(cat_ID) FROM $wpdb->sitecategories");
1881
+			$max_local_id = $wpdb->get_var("SELECT MAX(term_id) FROM $wpdb->terms");
1882
+			$new_global_id = max($max_global_id, $max_local_id) + mt_rand(100, 400);
1883
+			$wpdb->insert($wpdb->sitecategories, array('cat_ID' => $new_global_id, 'cat_name' => $c->name, 'category_nicename' => $c->slug));
1884 1884
 			$global_id = $wpdb->insert_id;
1885 1885
 		}
1886
-	} elseif ( $global_id != $term_id ) {
1887
-		$local_id = $wpdb->get_var( $wpdb->prepare( "SELECT term_id FROM $wpdb->terms WHERE term_id = %d", $global_id ) );
1888
-		if ( null != $local_id ) {
1889
-			global_terms( $local_id );
1890
-			if ( 10 < $global_terms_recurse ) {
1886
+	} elseif ($global_id != $term_id) {
1887
+		$local_id = $wpdb->get_var($wpdb->prepare("SELECT term_id FROM $wpdb->terms WHERE term_id = %d", $global_id));
1888
+		if (null != $local_id) {
1889
+			global_terms($local_id);
1890
+			if (10 < $global_terms_recurse) {
1891 1891
 				$global_id = $term_id;
1892 1892
 			}
1893 1893
 		}
1894 1894
 	}
1895 1895
 
1896
-	if ( $global_id != $term_id ) {
1897
-		if ( get_option( 'default_category' ) == $term_id )
1898
-			update_option( 'default_category', $global_id );
1896
+	if ($global_id != $term_id) {
1897
+		if (get_option('default_category') == $term_id)
1898
+			update_option('default_category', $global_id);
1899 1899
 
1900
-		$wpdb->update( $wpdb->terms, array('term_id' => $global_id), array('term_id' => $term_id) );
1901
-		$wpdb->update( $wpdb->term_taxonomy, array('term_id' => $global_id), array('term_id' => $term_id) );
1902
-		$wpdb->update( $wpdb->term_taxonomy, array('parent' => $global_id), array('parent' => $term_id) );
1900
+		$wpdb->update($wpdb->terms, array('term_id' => $global_id), array('term_id' => $term_id));
1901
+		$wpdb->update($wpdb->term_taxonomy, array('term_id' => $global_id), array('term_id' => $term_id));
1902
+		$wpdb->update($wpdb->term_taxonomy, array('parent' => $global_id), array('parent' => $term_id));
1903 1903
 
1904 1904
 		clean_term_cache($term_id);
1905 1905
 	}
1906
-	if ( $recurse_start )
1906
+	if ($recurse_start)
1907 1907
 		$global_terms_recurse = null;
1908 1908
 
1909 1909
 	return $global_id;
@@ -1918,8 +1918,8 @@  discard block
 block discarded – undo
1918 1918
  * @param array|string $deprecated Not used.
1919 1919
  * @return array The current site's domain
1920 1920
  */
1921
-function redirect_this_site( $deprecated = '' ) {
1922
-	return array( get_network()->domain );
1921
+function redirect_this_site($deprecated = '') {
1922
+	return array(get_network()->domain);
1923 1923
 }
1924 1924
 
1925 1925
 /**
@@ -1932,12 +1932,12 @@  discard block
 block discarded – undo
1932 1932
  * @param array $upload
1933 1933
  * @return string|array If the upload is under the size limit, $upload is returned. Otherwise returns an error message.
1934 1934
  */
1935
-function upload_is_file_too_big( $upload ) {
1936
-	if ( ! is_array( $upload ) || defined( 'WP_IMPORTING' ) || get_site_option( 'upload_space_check_disabled' ) )
1935
+function upload_is_file_too_big($upload) {
1936
+	if ( ! is_array($upload) || defined('WP_IMPORTING') || get_site_option('upload_space_check_disabled'))
1937 1937
 		return $upload;
1938 1938
 
1939
-	if ( strlen( $upload['bits'] )  > ( KB_IN_BYTES * get_site_option( 'fileupload_maxk', 1500 ) ) ) {
1940
-		return sprintf( __( 'This file is too big. Files must be less than %d KB in size.' ) . '<br />', get_site_option( 'fileupload_maxk', 1500 ) );
1939
+	if (strlen($upload['bits']) > (KB_IN_BYTES * get_site_option('fileupload_maxk', 1500))) {
1940
+		return sprintf(__('This file is too big. Files must be less than %d KB in size.').'<br />', get_site_option('fileupload_maxk', 1500));
1941 1941
 	}
1942 1942
 
1943 1943
 	return $upload;
@@ -1951,7 +1951,7 @@  discard block
 block discarded – undo
1951 1951
 function signup_nonce_fields() {
1952 1952
 	$id = mt_rand();
1953 1953
 	echo "<input type='hidden' name='signup_form_id' value='{$id}' />";
1954
-	wp_nonce_field('signup_form_' . $id, '_signup_form', false);
1954
+	wp_nonce_field('signup_form_'.$id, '_signup_form', false);
1955 1955
 }
1956 1956
 
1957 1957
 /**
@@ -1962,12 +1962,12 @@  discard block
 block discarded – undo
1962 1962
  * @param array $result
1963 1963
  * @return array
1964 1964
  */
1965
-function signup_nonce_check( $result ) {
1966
-	if ( !strpos( $_SERVER[ 'PHP_SELF' ], 'wp-signup.php' ) )
1965
+function signup_nonce_check($result) {
1966
+	if ( ! strpos($_SERVER['PHP_SELF'], 'wp-signup.php'))
1967 1967
 		return $result;
1968 1968
 
1969
-	if ( wp_create_nonce('signup_form_' . $_POST[ 'signup_form_id' ]) != $_POST['_signup_form'] )
1970
-		wp_die( __( 'Please try again.' ) );
1969
+	if (wp_create_nonce('signup_form_'.$_POST['signup_form_id']) != $_POST['_signup_form'])
1970
+		wp_die(__('Please try again.'));
1971 1971
 
1972 1972
 	return $result;
1973 1973
 }
@@ -1987,10 +1987,10 @@  discard block
 block discarded – undo
1987 1987
 	 *
1988 1988
 	 * @param string $no_blog_redirect The redirect URL defined in NOBLOGREDIRECT.
1989 1989
 	 */
1990
-	if ( is_main_site() && is_404() && defined( 'NOBLOGREDIRECT' ) && ( $destination = apply_filters( 'blog_redirect_404', NOBLOGREDIRECT ) ) ) {
1991
-		if ( $destination == '%siteurl%' )
1990
+	if (is_main_site() && is_404() && defined('NOBLOGREDIRECT') && ($destination = apply_filters('blog_redirect_404', NOBLOGREDIRECT))) {
1991
+		if ($destination == '%siteurl%')
1992 1992
 			$destination = network_home_url();
1993
-		wp_redirect( $destination );
1993
+		wp_redirect($destination);
1994 1994
 		exit();
1995 1995
 	}
1996 1996
 }
@@ -2005,23 +2005,23 @@  discard block
 block discarded – undo
2005 2005
  * @since MU
2006 2006
  */
2007 2007
 function maybe_add_existing_user_to_blog() {
2008
-	if ( false === strpos( $_SERVER[ 'REQUEST_URI' ], '/newbloguser/' ) )
2008
+	if (false === strpos($_SERVER['REQUEST_URI'], '/newbloguser/'))
2009 2009
 		return;
2010 2010
 
2011
-	$parts = explode( '/', $_SERVER[ 'REQUEST_URI' ] );
2012
-	$key = array_pop( $parts );
2011
+	$parts = explode('/', $_SERVER['REQUEST_URI']);
2012
+	$key = array_pop($parts);
2013 2013
 
2014
-	if ( $key == '' )
2015
-		$key = array_pop( $parts );
2014
+	if ($key == '')
2015
+		$key = array_pop($parts);
2016 2016
 
2017
-	$details = get_option( 'new_user_' . $key );
2018
-	if ( !empty( $details ) )
2019
-		delete_option( 'new_user_' . $key );
2017
+	$details = get_option('new_user_'.$key);
2018
+	if ( ! empty($details))
2019
+		delete_option('new_user_'.$key);
2020 2020
 
2021
-	if ( empty( $details ) || is_wp_error( add_existing_user_to_blog( $details ) ) )
2022
-		wp_die( sprintf(__('An error occurred adding you to this site. Back to the <a href="%s">homepage</a>.'), home_url() ) );
2021
+	if (empty($details) || is_wp_error(add_existing_user_to_blog($details)))
2022
+		wp_die(sprintf(__('An error occurred adding you to this site. Back to the <a href="%s">homepage</a>.'), home_url()));
2023 2023
 
2024
-	wp_die( sprintf( __( 'You have been added to this site. Please visit the <a href="%s">homepage</a> or <a href="%s">log in</a> using your username and password.' ), home_url(), admin_url() ), __( 'WordPress &rsaquo; Success' ), array( 'response' => 200 ) );
2024
+	wp_die(sprintf(__('You have been added to this site. Please visit the <a href="%s">homepage</a> or <a href="%s">log in</a> using your username and password.'), home_url(), admin_url()), __('WordPress &rsaquo; Success'), array('response' => 200));
2025 2025
 }
2026 2026
 
2027 2027
 /**
@@ -2032,10 +2032,10 @@  discard block
 block discarded – undo
2032 2032
  * @param array $details
2033 2033
  * @return true|WP_Error|void
2034 2034
  */
2035
-function add_existing_user_to_blog( $details = false ) {
2036
-	if ( is_array( $details ) ) {
2035
+function add_existing_user_to_blog($details = false) {
2036
+	if (is_array($details)) {
2037 2037
 		$blog_id = get_current_blog_id();
2038
-		$result = add_user_to_blog( $blog_id, $details[ 'user_id' ], $details[ 'role' ] );
2038
+		$result = add_user_to_blog($blog_id, $details['user_id'], $details['role']);
2039 2039
 		/**
2040 2040
 		 * Fires immediately after an existing user is added to a site.
2041 2041
 		 *
@@ -2044,7 +2044,7 @@  discard block
 block discarded – undo
2044 2044
 		 * @param int   $user_id User ID.
2045 2045
 		 * @param mixed $result  True on success or a WP_Error object if the user doesn't exist.
2046 2046
 		 */
2047
-		do_action( 'added_existing_user', $details['user_id'], $result );
2047
+		do_action('added_existing_user', $details['user_id'], $result);
2048 2048
 		return $result;
2049 2049
 	}
2050 2050
 }
@@ -2062,13 +2062,13 @@  discard block
 block discarded – undo
2062 2062
  * @param mixed $password Ignored.
2063 2063
  * @param array $meta
2064 2064
  */
2065
-function add_new_user_to_blog( $user_id, $password, $meta ) {
2066
-	if ( !empty( $meta[ 'add_to_blog' ] ) ) {
2067
-		$blog_id = $meta[ 'add_to_blog' ];
2068
-		$role = $meta[ 'new_role' ];
2065
+function add_new_user_to_blog($user_id, $password, $meta) {
2066
+	if ( ! empty($meta['add_to_blog'])) {
2067
+		$blog_id = $meta['add_to_blog'];
2068
+		$role = $meta['new_role'];
2069 2069
 		remove_user_from_blog($user_id, get_network()->site_id); // remove user from main blog.
2070
-		add_user_to_blog( $blog_id, $user_id, $role );
2071
-		update_user_meta( $user_id, 'primary_blog', $blog_id );
2070
+		add_user_to_blog($blog_id, $user_id, $role);
2071
+		update_user_meta($user_id, 'primary_blog', $blog_id);
2072 2072
 	}
2073 2073
 }
2074 2074
 
@@ -2079,7 +2079,7 @@  discard block
 block discarded – undo
2079 2079
  *
2080 2080
  * @param PHPMailer $phpmailer The PHPMailer instance, passed by reference.
2081 2081
  */
2082
-function fix_phpmailer_messageid( $phpmailer ) {
2082
+function fix_phpmailer_messageid($phpmailer) {
2083 2083
 	$phpmailer->Hostname = get_network()->domain;
2084 2084
 }
2085 2085
 
@@ -2092,16 +2092,16 @@  discard block
 block discarded – undo
2092 2092
  * 	                           or user login name as a string.
2093 2093
  * @return bool
2094 2094
  */
2095
-function is_user_spammy( $user = null ) {
2096
-    if ( ! ( $user instanceof WP_User ) ) {
2097
-		if ( $user ) {
2098
-			$user = get_user_by( 'login', $user );
2095
+function is_user_spammy($user = null) {
2096
+    if ( ! ($user instanceof WP_User)) {
2097
+		if ($user) {
2098
+			$user = get_user_by('login', $user);
2099 2099
 		} else {
2100 2100
 			$user = wp_get_current_user();
2101 2101
 		}
2102 2102
 	}
2103 2103
 
2104
-	return $user && isset( $user->spam ) && 1 == $user->spam;
2104
+	return $user && isset($user->spam) && 1 == $user->spam;
2105 2105
 }
2106 2106
 
2107 2107
 /**
@@ -2114,8 +2114,8 @@  discard block
 block discarded – undo
2114 2114
  * @param int $old_value
2115 2115
  * @param int $value     The new public value
2116 2116
  */
2117
-function update_blog_public( $old_value, $value ) {
2118
-	update_blog_status( get_current_blog_id(), 'public', (int) $value );
2117
+function update_blog_public($old_value, $value) {
2118
+	update_blog_status(get_current_blog_id(), 'public', (int) $value);
2119 2119
 }
2120 2120
 
2121 2121
 /**
@@ -2130,16 +2130,16 @@  discard block
 block discarded – undo
2130 2130
  * @param int    $blog_id Optional. Defaults to current blog.
2131 2131
  * @return bool
2132 2132
  */
2133
-function is_user_option_local( $key, $user_id = 0, $blog_id = 0 ) {
2133
+function is_user_option_local($key, $user_id = 0, $blog_id = 0) {
2134 2134
 	global $wpdb;
2135 2135
 
2136 2136
 	$current_user = wp_get_current_user();
2137
-	if ( $blog_id == 0 ) {
2137
+	if ($blog_id == 0) {
2138 2138
 		$blog_id = $wpdb->blogid;
2139 2139
 	}
2140
-	$local_key = $wpdb->get_blog_prefix( $blog_id ) . $key;
2140
+	$local_key = $wpdb->get_blog_prefix($blog_id).$key;
2141 2141
 
2142
-	return isset( $current_user->$local_key );
2142
+	return isset($current_user->$local_key);
2143 2143
 }
2144 2144
 
2145 2145
 /**
@@ -2151,7 +2151,7 @@  discard block
 block discarded – undo
2151 2151
  */
2152 2152
 function users_can_register_signup_filter() {
2153 2153
 	$registration = get_site_option('registration');
2154
-	return ( $registration == 'all' || $registration == 'user' );
2154
+	return ($registration == 'all' || $registration == 'user');
2155 2155
 }
2156 2156
 
2157 2157
 /**
@@ -2162,12 +2162,12 @@  discard block
 block discarded – undo
2162 2162
  * @param string $text
2163 2163
  * @return string
2164 2164
  */
2165
-function welcome_user_msg_filter( $text ) {
2166
-	if ( !$text ) {
2167
-		remove_filter( 'site_option_welcome_user_email', 'welcome_user_msg_filter' );
2165
+function welcome_user_msg_filter($text) {
2166
+	if ( ! $text) {
2167
+		remove_filter('site_option_welcome_user_email', 'welcome_user_msg_filter');
2168 2168
 
2169 2169
 		/* translators: Do not translate USERNAME, PASSWORD, LOGINLINK, SITE_NAME: those are placeholders. */
2170
-		$text = __( 'Howdy USERNAME,
2170
+		$text = __('Howdy USERNAME,
2171 2171
 
2172 2172
 Your new account is set up.
2173 2173
 
@@ -2179,7 +2179,7 @@  discard block
 block discarded – undo
2179 2179
 Thanks!
2180 2180
 
2181 2181
 --The Team @ SITE_NAME' );
2182
-		update_site_option( 'welcome_user_email', $text );
2182
+		update_site_option('welcome_user_email', $text);
2183 2183
 	}
2184 2184
 	return $text;
2185 2185
 }
@@ -2194,10 +2194,10 @@  discard block
 block discarded – undo
2194 2194
  * @param bool $force
2195 2195
  * @return bool True if forced, false if not forced.
2196 2196
  */
2197
-function force_ssl_content( $force = '' ) {
2197
+function force_ssl_content($force = '') {
2198 2198
 	static $forced_content = false;
2199 2199
 
2200
-	if ( '' != $force ) {
2200
+	if ('' != $force) {
2201 2201
 		$old_forced = $forced_content;
2202 2202
 		$forced_content = $force;
2203 2203
 		return $old_forced;
@@ -2216,12 +2216,12 @@  discard block
 block discarded – undo
2216 2216
  * @param string $url URL
2217 2217
  * @return string URL with https as the scheme
2218 2218
  */
2219
-function filter_SSL( $url ) {
2220
-	if ( ! is_string( $url ) )
2221
-		return get_bloginfo( 'url' ); // Return home blog url with proper scheme
2219
+function filter_SSL($url) {
2220
+	if ( ! is_string($url))
2221
+		return get_bloginfo('url'); // Return home blog url with proper scheme
2222 2222
 
2223
-	if ( force_ssl_content() && is_ssl() )
2224
-		$url = set_url_scheme( $url, 'https' );
2223
+	if (force_ssl_content() && is_ssl())
2224
+		$url = set_url_scheme($url, 'https');
2225 2225
 
2226 2226
 	return $url;
2227 2227
 }
@@ -2232,10 +2232,10 @@  discard block
 block discarded – undo
2232 2232
  * @since 3.1.0
2233 2233
  */
2234 2234
 function wp_schedule_update_network_counts() {
2235
-	if ( !is_main_site() )
2235
+	if ( ! is_main_site())
2236 2236
 		return;
2237 2237
 
2238
-	if ( ! wp_next_scheduled('update_network_counts') && ! wp_installing() )
2238
+	if ( ! wp_next_scheduled('update_network_counts') && ! wp_installing())
2239 2239
 		wp_schedule_event(time(), 'twicedaily', 'update_network_counts');
2240 2240
 }
2241 2241
 
@@ -2258,7 +2258,7 @@  discard block
 block discarded – undo
2258 2258
  * @since 3.7.0
2259 2259
  */
2260 2260
 function wp_maybe_update_network_site_counts() {
2261
-	$is_small_network = ! wp_is_large_network( 'sites' );
2261
+	$is_small_network = ! wp_is_large_network('sites');
2262 2262
 
2263 2263
 	/**
2264 2264
 	 * Filters whether to update network site or user counts when a new site is created.
@@ -2270,7 +2270,7 @@  discard block
 block discarded – undo
2270 2270
 	 * @param bool   $small_network Whether the network is considered small.
2271 2271
 	 * @param string $context       Context. Either 'users' or 'sites'.
2272 2272
 	 */
2273
-	if ( ! apply_filters( 'enable_live_network_counts', $is_small_network, 'sites' ) )
2273
+	if ( ! apply_filters('enable_live_network_counts', $is_small_network, 'sites'))
2274 2274
 		return;
2275 2275
 
2276 2276
 	wp_update_network_site_counts();
@@ -2285,10 +2285,10 @@  discard block
 block discarded – undo
2285 2285
  * @since 3.7.0
2286 2286
  */
2287 2287
 function wp_maybe_update_network_user_counts() {
2288
-	$is_small_network = ! wp_is_large_network( 'users' );
2288
+	$is_small_network = ! wp_is_large_network('users');
2289 2289
 
2290 2290
 	/** This filter is documented in wp-includes/ms-functions.php */
2291
-	if ( ! apply_filters( 'enable_live_network_counts', $is_small_network, 'users' ) )
2291
+	if ( ! apply_filters('enable_live_network_counts', $is_small_network, 'users'))
2292 2292
 		return;
2293 2293
 
2294 2294
 	wp_update_network_user_counts();
@@ -2304,15 +2304,15 @@  discard block
 block discarded – undo
2304 2304
 function wp_update_network_site_counts() {
2305 2305
 	global $wpdb;
2306 2306
 
2307
-	$count = get_sites( array(
2307
+	$count = get_sites(array(
2308 2308
 		'network_id' => $wpdb->siteid,
2309 2309
 		'spam'       => 0,
2310 2310
 		'deleted'    => 0,
2311 2311
 		'archived'   => 0,
2312 2312
 		'count'      => true,
2313
-	) );
2313
+	));
2314 2314
 
2315
-	update_site_option( 'blog_count', $count );
2315
+	update_site_option('blog_count', $count);
2316 2316
 }
2317 2317
 
2318 2318
 /**
@@ -2325,8 +2325,8 @@  discard block
 block discarded – undo
2325 2325
 function wp_update_network_user_counts() {
2326 2326
 	global $wpdb;
2327 2327
 
2328
-	$count = $wpdb->get_var( "SELECT COUNT(ID) as c FROM $wpdb->users WHERE spam = '0' AND deleted = '0'" );
2329
-	update_site_option( 'user_count', $count );
2328
+	$count = $wpdb->get_var("SELECT COUNT(ID) as c FROM $wpdb->users WHERE spam = '0' AND deleted = '0'");
2329
+	update_site_option('user_count', $count);
2330 2330
 }
2331 2331
 
2332 2332
 /**
@@ -2344,10 +2344,10 @@  discard block
 block discarded – undo
2344 2344
 	 *
2345 2345
 	 * @param int|bool $space_used The amount of used space, in megabytes. Default false.
2346 2346
 	 */
2347
-	$space_used = apply_filters( 'pre_get_space_used', false );
2348
-	if ( false === $space_used ) {
2347
+	$space_used = apply_filters('pre_get_space_used', false);
2348
+	if (false === $space_used) {
2349 2349
 		$upload_dir = wp_upload_dir();
2350
-		$space_used = get_dirsize( $upload_dir['basedir'] ) / MB_IN_BYTES;
2350
+		$space_used = get_dirsize($upload_dir['basedir']) / MB_IN_BYTES;
2351 2351
 	}
2352 2352
 
2353 2353
 	return $space_used;
@@ -2361,12 +2361,12 @@  discard block
 block discarded – undo
2361 2361
  * @return int Quota in megabytes
2362 2362
  */
2363 2363
 function get_space_allowed() {
2364
-	$space_allowed = get_option( 'blog_upload_space' );
2364
+	$space_allowed = get_option('blog_upload_space');
2365 2365
 
2366
-	if ( ! is_numeric( $space_allowed ) )
2367
-		$space_allowed = get_site_option( 'blog_upload_space' );
2366
+	if ( ! is_numeric($space_allowed))
2367
+		$space_allowed = get_site_option('blog_upload_space');
2368 2368
 
2369
-	if ( ! is_numeric( $space_allowed ) )
2369
+	if ( ! is_numeric($space_allowed))
2370 2370
 		$space_allowed = 100;
2371 2371
 
2372 2372
 	/**
@@ -2376,7 +2376,7 @@  discard block
 block discarded – undo
2376 2376
 	 *
2377 2377
 	 * @param int $space_allowed Upload quota in megabytes for the current blog.
2378 2378
 	 */
2379
-	return apply_filters( 'get_space_allowed', $space_allowed );
2379
+	return apply_filters('get_space_allowed', $space_allowed);
2380 2380
 }
2381 2381
 
2382 2382
 /**
@@ -2388,16 +2388,16 @@  discard block
 block discarded – undo
2388 2388
  */
2389 2389
 function get_upload_space_available() {
2390 2390
 	$allowed = get_space_allowed();
2391
-	if ( $allowed < 0 ) {
2391
+	if ($allowed < 0) {
2392 2392
 		$allowed = 0;
2393 2393
 	}
2394 2394
 	$space_allowed = $allowed * MB_IN_BYTES;
2395
-	if ( get_site_option( 'upload_space_check_disabled' ) )
2395
+	if (get_site_option('upload_space_check_disabled'))
2396 2396
 		return $space_allowed;
2397 2397
 
2398 2398
 	$space_used = get_space_used() * MB_IN_BYTES;
2399 2399
 
2400
-	if ( ( $space_allowed - $space_used ) <= 0 )
2400
+	if (($space_allowed - $space_used) <= 0)
2401 2401
 		return 0;
2402 2402
 
2403 2403
 	return $space_allowed - $space_used;
@@ -2410,7 +2410,7 @@  discard block
 block discarded – undo
2410 2410
  * @return bool True if space is available, false otherwise.
2411 2411
  */
2412 2412
 function is_upload_space_available() {
2413
-	if ( get_site_option( 'upload_space_check_disabled' ) )
2413
+	if (get_site_option('upload_space_check_disabled'))
2414 2414
 		return true;
2415 2415
 
2416 2416
 	return (bool) get_upload_space_available();
@@ -2424,12 +2424,12 @@  discard block
 block discarded – undo
2424 2424
  * @param  int $size Upload size limit in bytes.
2425 2425
  * @return int       Upload size limit in bytes.
2426 2426
  */
2427
-function upload_size_limit_filter( $size ) {
2428
-	$fileupload_maxk = KB_IN_BYTES * get_site_option( 'fileupload_maxk', 1500 );
2429
-	if ( get_site_option( 'upload_space_check_disabled' ) )
2430
-		return min( $size, $fileupload_maxk );
2427
+function upload_size_limit_filter($size) {
2428
+	$fileupload_maxk = KB_IN_BYTES * get_site_option('fileupload_maxk', 1500);
2429
+	if (get_site_option('upload_space_check_disabled'))
2430
+		return min($size, $fileupload_maxk);
2431 2431
 
2432
-	return min( $size, $fileupload_maxk, get_upload_space_available() );
2432
+	return min($size, $fileupload_maxk, get_upload_space_available());
2433 2433
 }
2434 2434
 
2435 2435
 /**
@@ -2442,8 +2442,8 @@  discard block
 block discarded – undo
2442 2442
  * @param string $using 'sites or 'users'. Default is 'sites'.
2443 2443
  * @return bool True if the network meets the criteria for large. False otherwise.
2444 2444
  */
2445
-function wp_is_large_network( $using = 'sites' ) {
2446
-	if ( 'users' == $using ) {
2445
+function wp_is_large_network($using = 'sites') {
2446
+	if ('users' == $using) {
2447 2447
 		$count = get_user_count();
2448 2448
 		/**
2449 2449
 		 * Filters whether the network is considered large.
@@ -2454,12 +2454,12 @@  discard block
 block discarded – undo
2454 2454
 		 * @param string $component        The component to count. Accepts 'users', or 'sites'.
2455 2455
 		 * @param int    $count            The count of items for the component.
2456 2456
 		 */
2457
-		return apply_filters( 'wp_is_large_network', $count > 10000, 'users', $count );
2457
+		return apply_filters('wp_is_large_network', $count > 10000, 'users', $count);
2458 2458
 	}
2459 2459
 
2460 2460
 	$count = get_blog_count();
2461 2461
 	/** This filter is documented in wp-includes/ms-functions.php */
2462
-	return apply_filters( 'wp_is_large_network', $count > 10000, 'sites', $count );
2462
+	return apply_filters('wp_is_large_network', $count > 10000, 'sites', $count);
2463 2463
 }
2464 2464
 
2465 2465
 /**
@@ -2484,5 +2484,5 @@  discard block
 block discarded – undo
2484 2484
 	 *
2485 2485
 	 * @param array $subdirectory_reserved_names Array of reserved names.
2486 2486
 	 */
2487
-	return apply_filters( 'subdirectory_reserved_names', $names );
2487
+	return apply_filters('subdirectory_reserved_names', $names);
2488 2488
 }
Please login to merge, or discard this patch.
Braces   +280 added lines, -191 removed lines patch added patch discarded remove patch
@@ -42,11 +42,13 @@  discard block
 block discarded – undo
42 42
 function get_active_blog_for_user( $user_id ) {
43 43
 	global $wpdb;
44 44
 	$blogs = get_blogs_of_user( $user_id );
45
-	if ( empty( $blogs ) )
46
-		return;
45
+	if ( empty( $blogs ) ) {
46
+			return;
47
+	}
47 48
 
48
-	if ( !is_multisite() )
49
-		return $blogs[$wpdb->blogid];
49
+	if ( !is_multisite() ) {
50
+			return $blogs[$wpdb->blogid];
51
+	}
50 52
 
51 53
 	$primary_blog = get_user_meta( $user_id, 'primary_blog', true );
52 54
 	$first_blog = current($blogs);
@@ -69,15 +71,18 @@  discard block
 block discarded – undo
69 71
 		$ret = false;
70 72
 		if ( is_array( $blogs ) && count( $blogs ) > 0 ) {
71 73
 			foreach ( (array) $blogs as $blog_id => $blog ) {
72
-				if ( $blog->site_id != $wpdb->siteid )
73
-					continue;
74
+				if ( $blog->site_id != $wpdb->siteid ) {
75
+									continue;
76
+				}
74 77
 				$details = get_site( $blog_id );
75 78
 				if ( is_object( $details ) && $details->archived == 0 && $details->spam == 0 && $details->deleted == 0 ) {
76 79
 					$ret = $blog;
77
-					if ( get_user_meta( $user_id , 'primary_blog', true ) != $blog_id )
78
-						update_user_meta( $user_id, 'primary_blog', $blog_id );
79
-					if ( !get_user_meta($user_id , 'source_domain', true) )
80
-						update_user_meta( $user_id, 'source_domain', $blog->domain );
80
+					if ( get_user_meta( $user_id , 'primary_blog', true ) != $blog_id ) {
81
+											update_user_meta( $user_id, 'primary_blog', $blog_id );
82
+					}
83
+					if ( !get_user_meta($user_id , 'source_domain', true) ) {
84
+											update_user_meta( $user_id, 'source_domain', $blog->domain );
85
+					}
81 86
 					break;
82 87
 				}
83 88
 			}
@@ -114,8 +119,9 @@  discard block
 block discarded – undo
114 119
  * @return int
115 120
  */
116 121
 function get_blog_count( $network_id = 0 ) {
117
-	if ( func_num_args() )
118
-		_deprecated_argument( __FUNCTION__, '3.1.0' );
122
+	if ( func_num_args() ) {
123
+			_deprecated_argument( __FUNCTION__, '3.1.0' );
124
+	}
119 125
 
120 126
 	return get_site_option( 'blog_count' );
121 127
 }
@@ -223,8 +229,9 @@  discard block
 block discarded – undo
223 229
 		$new_domain = '';
224 230
 		$blogs = get_blogs_of_user($user_id);
225 231
 		foreach ( (array) $blogs as $blog ) {
226
-			if ( $blog->userblog_id == $blog_id )
227
-				continue;
232
+			if ( $blog->userblog_id == $blog_id ) {
233
+							continue;
234
+			}
228 235
 			$new_id = $blog->userblog_id;
229 236
 			$new_domain = $blog->domain;
230 237
 			break;
@@ -308,10 +315,12 @@  discard block
 block discarded – undo
308 315
 	$path = strtolower( $path );
309 316
 	$id = wp_cache_get( md5( $domain . $path ), 'blog-id-cache' );
310 317
 
311
-	if ( $id == -1 ) // blog does not exist
318
+	if ( $id == -1 ) {
319
+		// blog does not exist
312 320
 		return 0;
313
-	elseif ( $id )
314
-		return (int) $id;
321
+	} elseif ( $id ) {
322
+			return (int) $id;
323
+	}
315 324
 
316 325
 	$args = array(
317 326
 		'domain' => $domain,
@@ -348,8 +357,9 @@  discard block
 block discarded – undo
348 357
  */
349 358
 function is_email_address_unsafe( $user_email ) {
350 359
 	$banned_names = get_site_option( 'banned_email_domains' );
351
-	if ( $banned_names && ! is_array( $banned_names ) )
352
-		$banned_names = explode( "\n", $banned_names );
360
+	if ( $banned_names && ! is_array( $banned_names ) ) {
361
+			$banned_names = explode( "\n", $banned_names );
362
+	}
353 363
 
354 364
 	$is_email_address_unsafe = false;
355 365
 
@@ -360,8 +370,9 @@  discard block
 block discarded – undo
360 370
 		list( $email_local_part, $email_domain ) = explode( '@', $normalized_email );
361 371
 
362 372
 		foreach ( $banned_names as $banned_domain ) {
363
-			if ( ! $banned_domain )
364
-				continue;
373
+			if ( ! $banned_domain ) {
374
+							continue;
375
+			}
365 376
 
366 377
 			if ( $email_domain == $banned_domain ) {
367 378
 				$is_email_address_unsafe = true;
@@ -422,8 +433,9 @@  discard block
 block discarded – undo
422 433
 
423 434
 	$user_email = sanitize_email( $user_email );
424 435
 
425
-	if ( empty( $user_name ) )
426
-	   	$errors->add('user_name', __( 'Please enter a username.' ) );
436
+	if ( empty( $user_name ) ) {
437
+		   	$errors->add('user_name', __( 'Please enter a username.' ) );
438
+	}
427 439
 
428 440
 	$illegal_names = get_site_option( 'illegal_names' );
429 441
 	if ( ! is_array( $illegal_names ) ) {
@@ -441,22 +453,26 @@  discard block
 block discarded – undo
441 453
 		$errors->add( 'user_name',  __( 'Sorry, that username is not allowed.' ) );
442 454
 	}
443 455
 
444
-	if ( is_email_address_unsafe( $user_email ) )
445
-		$errors->add('user_email',  __('You cannot use that email address to signup. We are having problems with them blocking some of our email. Please use another email provider.'));
456
+	if ( is_email_address_unsafe( $user_email ) ) {
457
+			$errors->add('user_email',  __('You cannot use that email address to signup. We are having problems with them blocking some of our email. Please use another email provider.'));
458
+	}
446 459
 
447
-	if ( strlen( $user_name ) < 4 )
448
-		$errors->add('user_name',  __( 'Username must be at least 4 characters.' ) );
460
+	if ( strlen( $user_name ) < 4 ) {
461
+			$errors->add('user_name',  __( 'Username must be at least 4 characters.' ) );
462
+	}
449 463
 
450 464
 	if ( strlen( $user_name ) > 60 ) {
451 465
 		$errors->add( 'user_name', __( 'Username may not be longer than 60 characters.' ) );
452 466
 	}
453 467
 
454 468
 	// all numeric?
455
-	if ( preg_match( '/^[0-9]*$/', $user_name ) )
456
-		$errors->add('user_name', __('Sorry, usernames must have letters too!'));
469
+	if ( preg_match( '/^[0-9]*$/', $user_name ) ) {
470
+			$errors->add('user_name', __('Sorry, usernames must have letters too!'));
471
+	}
457 472
 
458
-	if ( !is_email( $user_email ) )
459
-		$errors->add('user_email', __( 'Please enter a valid email address.' ) );
473
+	if ( !is_email( $user_email ) ) {
474
+			$errors->add('user_email', __( 'Please enter a valid email address.' ) );
475
+	}
460 476
 
461 477
 	$limited_email_domains = get_site_option( 'limited_email_domains' );
462 478
 	if ( is_array( $limited_email_domains ) && ! empty( $limited_email_domains ) ) {
@@ -467,12 +483,14 @@  discard block
 block discarded – undo
467 483
 	}
468 484
 
469 485
 	// Check if the username has been used already.
470
-	if ( username_exists($user_name) )
471
-		$errors->add( 'user_name', __( 'Sorry, that username already exists!' ) );
486
+	if ( username_exists($user_name) ) {
487
+			$errors->add( 'user_name', __( 'Sorry, that username already exists!' ) );
488
+	}
472 489
 
473 490
 	// Check if the email address has been used already.
474
-	if ( email_exists($user_email) )
475
-		$errors->add( 'user_email', __( 'Sorry, that email address is already used!' ) );
491
+	if ( email_exists($user_email) ) {
492
+			$errors->add( 'user_email', __( 'Sorry, that email address is already used!' ) );
493
+	}
476 494
 
477 495
 	// Has someone already signed up for this username?
478 496
 	$signup = $wpdb->get_row( $wpdb->prepare("SELECT * FROM $wpdb->signups WHERE user_login = %s", $user_name) );
@@ -481,20 +499,22 @@  discard block
 block discarded – undo
481 499
 		$now = current_time( 'timestamp', true );
482 500
 		$diff = $now - $registered_at;
483 501
 		// If registered more than two days ago, cancel registration and let this signup go through.
484
-		if ( $diff > 2 * DAY_IN_SECONDS )
485
-			$wpdb->delete( $wpdb->signups, array( 'user_login' => $user_name ) );
486
-		else
487
-			$errors->add('user_name', __('That username is currently reserved but may be available in a couple of days.'));
502
+		if ( $diff > 2 * DAY_IN_SECONDS ) {
503
+					$wpdb->delete( $wpdb->signups, array( 'user_login' => $user_name ) );
504
+		} else {
505
+					$errors->add('user_name', __('That username is currently reserved but may be available in a couple of days.'));
506
+		}
488 507
 	}
489 508
 
490 509
 	$signup = $wpdb->get_row( $wpdb->prepare("SELECT * FROM $wpdb->signups WHERE user_email = %s", $user_email) );
491 510
 	if ( $signup != null ) {
492 511
 		$diff = current_time( 'timestamp', true ) - mysql2date('U', $signup->registered);
493 512
 		// If registered more than two days ago, cancel registration and let this signup go through.
494
-		if ( $diff > 2 * DAY_IN_SECONDS )
495
-			$wpdb->delete( $wpdb->signups, array( 'user_email' => $user_email ) );
496
-		else
497
-			$errors->add('user_email', __('That email address has already been used. Please check your inbox for an activation email. It will become available in a couple of days if you do nothing.'));
513
+		if ( $diff > 2 * DAY_IN_SECONDS ) {
514
+					$wpdb->delete( $wpdb->signups, array( 'user_email' => $user_email ) );
515
+		} else {
516
+					$errors->add('user_email', __('That email address has already been used. Please check your inbox for an activation email. It will become available in a couple of days if you do nothing.'));
517
+		}
498 518
 	}
499 519
 
500 520
 	$result = array('user_name' => $user_name, 'orig_username' => $orig_username, 'user_email' => $user_email, 'errors' => $errors);
@@ -566,26 +586,31 @@  discard block
 block discarded – undo
566 586
 		$illegal_names = array_merge( $illegal_names, get_subdirectory_reserved_names() );
567 587
 	}
568 588
 
569
-	if ( empty( $blogname ) )
570
-		$errors->add('blogname', __( 'Please enter a site name.' ) );
589
+	if ( empty( $blogname ) ) {
590
+			$errors->add('blogname', __( 'Please enter a site name.' ) );
591
+	}
571 592
 
572 593
 	if ( preg_match( '/[^a-z0-9]+/', $blogname ) ) {
573 594
 		$errors->add( 'blogname', __( 'Site names can only contain lowercase letters (a-z) and numbers.' ) );
574 595
 	}
575 596
 
576
-	if ( in_array( $blogname, $illegal_names ) )
577
-		$errors->add('blogname',  __( 'That name is not allowed.' ) );
597
+	if ( in_array( $blogname, $illegal_names ) ) {
598
+			$errors->add('blogname',  __( 'That name is not allowed.' ) );
599
+	}
578 600
 
579
-	if ( strlen( $blogname ) < 4 && !is_super_admin() )
580
-		$errors->add('blogname',  __( 'Site name must be at least 4 characters.' ) );
601
+	if ( strlen( $blogname ) < 4 && !is_super_admin() ) {
602
+			$errors->add('blogname',  __( 'Site name must be at least 4 characters.' ) );
603
+	}
581 604
 
582 605
 	// do not allow users to create a blog that conflicts with a page on the main blog.
583
-	if ( !is_subdomain_install() && $wpdb->get_var( $wpdb->prepare( "SELECT post_name FROM " . $wpdb->get_blog_prefix( $current_network->site_id ) . "posts WHERE post_type = 'page' AND post_name = %s", $blogname ) ) )
584
-		$errors->add( 'blogname', __( 'Sorry, you may not use that site name.' ) );
606
+	if ( !is_subdomain_install() && $wpdb->get_var( $wpdb->prepare( "SELECT post_name FROM " . $wpdb->get_blog_prefix( $current_network->site_id ) . "posts WHERE post_type = 'page' AND post_name = %s", $blogname ) ) ) {
607
+			$errors->add( 'blogname', __( 'Sorry, you may not use that site name.' ) );
608
+	}
585 609
 
586 610
 	// all numeric?
587
-	if ( preg_match( '/^[0-9]*$/', $blogname ) )
588
-		$errors->add('blogname', __('Sorry, site names must have letters too!'));
611
+	if ( preg_match( '/^[0-9]*$/', $blogname ) ) {
612
+			$errors->add('blogname', __('Sorry, site names must have letters too!'));
613
+	}
589 614
 
590 615
 	/**
591 616
 	 * Filters the new site name during registration.
@@ -601,8 +626,9 @@  discard block
 block discarded – undo
601 626
 
602 627
 	$blog_title = wp_unslash(  $blog_title );
603 628
 
604
-	if ( empty( $blog_title ) )
605
-		$errors->add('blog_title', __( 'Please enter a site title.' ) );
629
+	if ( empty( $blog_title ) ) {
630
+			$errors->add('blog_title', __( 'Please enter a site title.' ) );
631
+	}
606 632
 
607 633
 	// Check if the domain/path has been used already.
608 634
 	if ( is_subdomain_install() ) {
@@ -612,12 +638,14 @@  discard block
 block discarded – undo
612 638
 		$mydomain = "$domain";
613 639
 		$path = $base.$blogname.'/';
614 640
 	}
615
-	if ( domain_exists($mydomain, $path, $current_network->id) )
616
-		$errors->add( 'blogname', __( 'Sorry, that site already exists!' ) );
641
+	if ( domain_exists($mydomain, $path, $current_network->id) ) {
642
+			$errors->add( 'blogname', __( 'Sorry, that site already exists!' ) );
643
+	}
617 644
 
618 645
 	if ( username_exists( $blogname ) ) {
619
-		if ( ! is_object( $user ) || ( is_object($user) && ( $user->user_login != $blogname ) ) )
620
-			$errors->add( 'blogname', __( 'Sorry, that site is reserved!' ) );
646
+		if ( ! is_object( $user ) || ( is_object($user) && ( $user->user_login != $blogname ) ) ) {
647
+					$errors->add( 'blogname', __( 'Sorry, that site is reserved!' ) );
648
+		}
621 649
 	}
622 650
 
623 651
 	// Has someone already signed up for this domain?
@@ -625,10 +653,11 @@  discard block
 block discarded – undo
625 653
 	if ( ! empty($signup) ) {
626 654
 		$diff = current_time( 'timestamp', true ) - mysql2date('U', $signup->registered);
627 655
 		// If registered more than two days ago, cancel registration and let this signup go through.
628
-		if ( $diff > 2 * DAY_IN_SECONDS )
629
-			$wpdb->delete( $wpdb->signups, array( 'domain' => $mydomain , 'path' => $path ) );
630
-		else
631
-			$errors->add('blogname', __('That site is currently reserved but may be available in a couple days.'));
656
+		if ( $diff > 2 * DAY_IN_SECONDS ) {
657
+					$wpdb->delete( $wpdb->signups, array( 'domain' => $mydomain , 'path' => $path ) );
658
+		} else {
659
+					$errors->add('blogname', __('That site is currently reserved but may be available in a couple days.'));
660
+		}
632 661
 	}
633 662
 
634 663
 	$result = array('domain' => $mydomain, 'path' => $path, 'blogname' => $blogname, 'blog_title' => $blog_title, 'user' => $user, 'errors' => $errors);
@@ -789,15 +818,18 @@  discard block
 block discarded – undo
789 818
 	}
790 819
 
791 820
 	// Send email with activation link.
792
-	if ( !is_subdomain_install() || get_current_network_id() != 1 )
793
-		$activate_url = network_site_url("wp-activate.php?key=$key");
794
-	else
795
-		$activate_url = "http://{$domain}{$path}wp-activate.php?key=$key"; // @todo use *_url() API
821
+	if ( !is_subdomain_install() || get_current_network_id() != 1 ) {
822
+			$activate_url = network_site_url("wp-activate.php?key=$key");
823
+	} else {
824
+			$activate_url = "http://{$domain}{$path}wp-activate.php?key=$key";
825
+	}
826
+	// @todo use *_url() API
796 827
 
797 828
 	$activate_url = esc_url($activate_url);
798 829
 	$admin_email = get_site_option( 'admin_email' );
799
-	if ( $admin_email == '' )
800
-		$admin_email = 'support@' . $_SERVER['SERVER_NAME'];
830
+	if ( $admin_email == '' ) {
831
+			$admin_email = 'support@' . $_SERVER['SERVER_NAME'];
832
+	}
801 833
 	$from_name = get_site_option( 'site_name' ) == '' ? 'WordPress' : esc_html( get_site_option( 'site_name' ) );
802 834
 	$message_headers = "From: \"{$from_name}\" <{$admin_email}>\n" . "Content-Type: text/plain; charset=\"" . get_option('blog_charset') . "\"\n";
803 835
 
@@ -894,16 +926,18 @@  discard block
 block discarded – undo
894 926
 	 * @param string $key        Activation key created in wpmu_signup_user().
895 927
 	 * @param array  $meta       Signup meta data.
896 928
 	 */
897
-	if ( ! apply_filters( 'wpmu_signup_user_notification', $user_login, $user_email, $key, $meta ) )
898
-		return false;
929
+	if ( ! apply_filters( 'wpmu_signup_user_notification', $user_login, $user_email, $key, $meta ) ) {
930
+			return false;
931
+	}
899 932
 
900 933
 	$user = get_user_by( 'login', $user_login );
901 934
 	$switched_locale = switch_to_locale( get_user_locale( $user ) );
902 935
 
903 936
 	// Send email with activation link.
904 937
 	$admin_email = get_site_option( 'admin_email' );
905
-	if ( $admin_email == '' )
906
-		$admin_email = 'support@' . $_SERVER['SERVER_NAME'];
938
+	if ( $admin_email == '' ) {
939
+			$admin_email = 'support@' . $_SERVER['SERVER_NAME'];
940
+	}
907 941
 	$from_name = get_site_option( 'site_name' ) == '' ? 'WordPress' : esc_html( get_site_option( 'site_name' ) );
908 942
 	$message_headers = "From: \"{$from_name}\" <{$admin_email}>\n" . "Content-Type: text/plain; charset=\"" . get_option('blog_charset') . "\"\n";
909 943
 	$message = sprintf(
@@ -976,14 +1010,16 @@  discard block
 block discarded – undo
976 1010
 
977 1011
 	$signup = $wpdb->get_row( $wpdb->prepare("SELECT * FROM $wpdb->signups WHERE activation_key = %s", $key) );
978 1012
 
979
-	if ( empty( $signup ) )
980
-		return new WP_Error( 'invalid_key', __( 'Invalid activation key.' ) );
1013
+	if ( empty( $signup ) ) {
1014
+			return new WP_Error( 'invalid_key', __( 'Invalid activation key.' ) );
1015
+	}
981 1016
 
982 1017
 	if ( $signup->active ) {
983
-		if ( empty( $signup->domain ) )
984
-			return new WP_Error( 'already_active', __( 'The user is already active.' ), $signup );
985
-		else
986
-			return new WP_Error( 'already_active', __( 'The site is already active.' ), $signup );
1018
+		if ( empty( $signup->domain ) ) {
1019
+					return new WP_Error( 'already_active', __( 'The user is already active.' ), $signup );
1020
+		} else {
1021
+					return new WP_Error( 'already_active', __( 'The site is already active.' ), $signup );
1022
+		}
987 1023
 	}
988 1024
 
989 1025
 	$meta = maybe_unserialize($signup->meta);
@@ -991,21 +1027,24 @@  discard block
 block discarded – undo
991 1027
 
992 1028
 	$user_id = username_exists($signup->user_login);
993 1029
 
994
-	if ( ! $user_id )
995
-		$user_id = wpmu_create_user($signup->user_login, $password, $signup->user_email);
996
-	else
997
-		$user_already_exists = true;
1030
+	if ( ! $user_id ) {
1031
+			$user_id = wpmu_create_user($signup->user_login, $password, $signup->user_email);
1032
+	} else {
1033
+			$user_already_exists = true;
1034
+	}
998 1035
 
999
-	if ( ! $user_id )
1000
-		return new WP_Error('create_user', __('Could not create user'), $signup);
1036
+	if ( ! $user_id ) {
1037
+			return new WP_Error('create_user', __('Could not create user'), $signup);
1038
+	}
1001 1039
 
1002 1040
 	$now = current_time('mysql', true);
1003 1041
 
1004 1042
 	if ( empty($signup->domain) ) {
1005 1043
 		$wpdb->update( $wpdb->signups, array('active' => 1, 'activated' => $now), array('activation_key' => $key) );
1006 1044
 
1007
-		if ( isset( $user_already_exists ) )
1008
-			return new WP_Error( 'user_already_exists', __( 'That username is already activated.' ), $signup);
1045
+		if ( isset( $user_already_exists ) ) {
1046
+					return new WP_Error( 'user_already_exists', __( 'That username is already activated.' ), $signup);
1047
+		}
1009 1048
 
1010 1049
 		/**
1011 1050
 		 * Fires immediately after a new user is activated.
@@ -1069,8 +1108,9 @@  discard block
 block discarded – undo
1069 1108
 	$user_name = preg_replace( '/\s+/', '', sanitize_user( $user_name, true ) );
1070 1109
 
1071 1110
 	$user_id = wp_create_user( $user_name, $password, $email );
1072
-	if ( is_wp_error( $user_id ) )
1073
-		return false;
1111
+	if ( is_wp_error( $user_id ) ) {
1112
+			return false;
1113
+	}
1074 1114
 
1075 1115
 	// Newly created users have no roles or caps until they are added to a blog.
1076 1116
 	delete_user_option( $user_id, 'capabilities' );
@@ -1119,25 +1159,29 @@  discard block
 block discarded – undo
1119 1159
 
1120 1160
 	$domain = preg_replace( '/\s+/', '', sanitize_user( $domain, true ) );
1121 1161
 
1122
-	if ( is_subdomain_install() )
1123
-		$domain = str_replace( '@', '', $domain );
1162
+	if ( is_subdomain_install() ) {
1163
+			$domain = str_replace( '@', '', $domain );
1164
+	}
1124 1165
 
1125 1166
 	$title = strip_tags( $title );
1126 1167
 	$user_id = (int) $user_id;
1127 1168
 
1128
-	if ( empty($path) )
1129
-		$path = '/';
1169
+	if ( empty($path) ) {
1170
+			$path = '/';
1171
+	}
1130 1172
 
1131 1173
 	// Check if the domain has been used already. We should return an error message.
1132
-	if ( domain_exists($domain, $path, $site_id) )
1133
-		return new WP_Error( 'blog_taken', __( 'Sorry, that site already exists!' ) );
1174
+	if ( domain_exists($domain, $path, $site_id) ) {
1175
+			return new WP_Error( 'blog_taken', __( 'Sorry, that site already exists!' ) );
1176
+	}
1134 1177
 
1135 1178
 	if ( ! wp_installing() ) {
1136 1179
 		wp_installing( true );
1137 1180
 	}
1138 1181
 
1139
-	if ( ! $blog_id = insert_blog($domain, $path, $site_id) )
1140
-		return new WP_Error('insert_blog', __('Could not create site.'));
1182
+	if ( ! $blog_id = insert_blog($domain, $path, $site_id) ) {
1183
+			return new WP_Error('insert_blog', __('Could not create site.'));
1184
+	}
1141 1185
 
1142 1186
 	switch_to_blog($blog_id);
1143 1187
 	install_blog($blog_id, $title);
@@ -1146,16 +1190,18 @@  discard block
 block discarded – undo
1146 1190
 	add_user_to_blog($blog_id, $user_id, 'administrator');
1147 1191
 
1148 1192
 	foreach ( $meta as $key => $value ) {
1149
-		if ( in_array( $key, array( 'public', 'archived', 'mature', 'spam', 'deleted', 'lang_id' ) ) )
1150
-			update_blog_status( $blog_id, $key, $value );
1151
-		else
1152
-			update_option( $key, $value );
1193
+		if ( in_array( $key, array( 'public', 'archived', 'mature', 'spam', 'deleted', 'lang_id' ) ) ) {
1194
+					update_blog_status( $blog_id, $key, $value );
1195
+		} else {
1196
+					update_option( $key, $value );
1197
+		}
1153 1198
 	}
1154 1199
 
1155 1200
 	update_option( 'blog_public', (int) $meta['public'] );
1156 1201
 
1157
-	if ( ! is_super_admin( $user_id ) && ! get_user_meta( $user_id, 'primary_blog', true ) )
1158
-		update_user_meta( $user_id, 'primary_blog', $blog_id );
1202
+	if ( ! is_super_admin( $user_id ) && ! get_user_meta( $user_id, 'primary_blog', true ) ) {
1203
+			update_user_meta( $user_id, 'primary_blog', $blog_id );
1204
+	}
1159 1205
 
1160 1206
 	restore_current_blog();
1161 1207
 	/**
@@ -1190,12 +1236,14 @@  discard block
 block discarded – undo
1190 1236
  * @return bool
1191 1237
  */
1192 1238
 function newblog_notify_siteadmin( $blog_id, $deprecated = '' ) {
1193
-	if ( get_site_option( 'registrationnotification' ) != 'yes' )
1194
-		return false;
1239
+	if ( get_site_option( 'registrationnotification' ) != 'yes' ) {
1240
+			return false;
1241
+	}
1195 1242
 
1196 1243
 	$email = get_site_option( 'admin_email' );
1197
-	if ( is_email($email) == false )
1198
-		return false;
1244
+	if ( is_email($email) == false ) {
1245
+			return false;
1246
+	}
1199 1247
 
1200 1248
 	$options_site_url = esc_url(network_admin_url('settings.php'));
1201 1249
 
@@ -1236,13 +1284,15 @@  discard block
 block discarded – undo
1236 1284
  * @return bool
1237 1285
  */
1238 1286
 function newuser_notify_siteadmin( $user_id ) {
1239
-	if ( get_site_option( 'registrationnotification' ) != 'yes' )
1240
-		return false;
1287
+	if ( get_site_option( 'registrationnotification' ) != 'yes' ) {
1288
+			return false;
1289
+	}
1241 1290
 
1242 1291
 	$email = get_site_option( 'admin_email' );
1243 1292
 
1244
-	if ( is_email($email) == false )
1245
-		return false;
1293
+	if ( is_email($email) == false ) {
1294
+			return false;
1295
+	}
1246 1296
 
1247 1297
 	$user = get_userdata( $user_id );
1248 1298
 
@@ -1328,8 +1378,9 @@  discard block
 block discarded – undo
1328 1378
 	$site_id = (int) $site_id;
1329 1379
 
1330 1380
 	$result = $wpdb->insert( $wpdb->blogs, array('site_id' => $site_id, 'domain' => $domain, 'path' => $path, 'registered' => current_time('mysql')) );
1331
-	if ( ! $result )
1332
-		return false;
1381
+	if ( ! $result ) {
1382
+			return false;
1383
+	}
1333 1384
 
1334 1385
 	$blog_id = $wpdb->insert_id;
1335 1386
 	refresh_blog_details( $blog_id );
@@ -1363,8 +1414,9 @@  discard block
 block discarded – undo
1363 1414
 	require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
1364 1415
 
1365 1416
 	$suppress = $wpdb->suppress_errors();
1366
-	if ( $wpdb->get_results( "DESCRIBE {$wpdb->posts}" ) )
1367
-		die( '<h1>' . __( 'Already Installed' ) . '</h1><p>' . __( 'You appear to have already installed WordPress. To reinstall please clear your old database tables first.' ) . '</p></body></html>' );
1417
+	if ( $wpdb->get_results( "DESCRIBE {$wpdb->posts}" ) ) {
1418
+			die( '<h1>' . __( 'Already Installed' ) . '</h1><p>' . __( 'You appear to have already installed WordPress. To reinstall please clear your old database tables first.' ) . '</p></body></html>' );
1419
+	}
1368 1420
 	$wpdb->suppress_errors( $suppress );
1369 1421
 
1370 1422
 	$url = get_blogaddress_by_id( $blog_id );
@@ -1393,10 +1445,11 @@  discard block
 block discarded – undo
1393 1445
 	update_option( 'siteurl', $siteurl );
1394 1446
 	update_option( 'home', $home );
1395 1447
 
1396
-	if ( get_site_option( 'ms_files_rewriting' ) )
1397
-		update_option( 'upload_path', UPLOADBLOGSDIR . "/$blog_id/files" );
1398
-	else
1399
-		update_option( 'upload_path', get_blog_option( get_network()->site_id, 'upload_path' ) );
1448
+	if ( get_site_option( 'ms_files_rewriting' ) ) {
1449
+			update_option( 'upload_path', UPLOADBLOGSDIR . "/$blog_id/files" );
1450
+	} else {
1451
+			update_option( 'upload_path', get_blog_option( get_network()->site_id, 'upload_path' ) );
1452
+	}
1400 1453
 
1401 1454
 	update_option( 'blogname', wp_unslash( $blog_title ) );
1402 1455
 	update_option( 'admin_email', '' );
@@ -1466,8 +1519,9 @@  discard block
 block discarded – undo
1466 1519
 	 * @param string   $title    Site title.
1467 1520
 	 * @param array    $meta     Signup meta data.
1468 1521
 	 */
1469
-	if ( ! apply_filters( 'wpmu_welcome_notification', $blog_id, $user_id, $password, $title, $meta ) )
1470
-		return false;
1522
+	if ( ! apply_filters( 'wpmu_welcome_notification', $blog_id, $user_id, $password, $title, $meta ) ) {
1523
+			return false;
1524
+	}
1471 1525
 
1472 1526
 	$user = get_userdata( $user_id );
1473 1527
 
@@ -1517,15 +1571,17 @@  discard block
 block discarded – undo
1517 1571
 	$welcome_email = apply_filters( 'update_welcome_email', $welcome_email, $blog_id, $user_id, $password, $title, $meta );
1518 1572
 	$admin_email = get_site_option( 'admin_email' );
1519 1573
 
1520
-	if ( $admin_email == '' )
1521
-		$admin_email = 'support@' . $_SERVER['SERVER_NAME'];
1574
+	if ( $admin_email == '' ) {
1575
+			$admin_email = 'support@' . $_SERVER['SERVER_NAME'];
1576
+	}
1522 1577
 
1523 1578
 	$from_name = get_site_option( 'site_name' ) == '' ? 'WordPress' : esc_html( get_site_option( 'site_name' ) );
1524 1579
 	$message_headers = "From: \"{$from_name}\" <{$admin_email}>\n" . "Content-Type: text/plain; charset=\"" . get_option('blog_charset') . "\"\n";
1525 1580
 	$message = $welcome_email;
1526 1581
 
1527
-	if ( empty( $current_network->site_name ) )
1528
-		$current_network->site_name = 'WordPress';
1582
+	if ( empty( $current_network->site_name ) ) {
1583
+			$current_network->site_name = 'WordPress';
1584
+	}
1529 1585
 
1530 1586
 	/* translators: New site notification email subject. 1: Network name, 2: New site name */
1531 1587
 	$subject = __( 'New %1$s Site: %2$s' );
@@ -1576,8 +1632,9 @@  discard block
 block discarded – undo
1576 1632
 	 * @param string $password User password.
1577 1633
 	 * @param array  $meta     Signup meta data.
1578 1634
 	 */
1579
-	if ( ! apply_filters( 'wpmu_welcome_user_notification', $user_id, $password, $meta ) )
1580
-		return false;
1635
+	if ( ! apply_filters( 'wpmu_welcome_user_notification', $user_id, $password, $meta ) ) {
1636
+			return false;
1637
+	}
1581 1638
 
1582 1639
 	$welcome_email = get_site_option( 'welcome_user_email' );
1583 1640
 
@@ -1605,15 +1662,17 @@  discard block
 block discarded – undo
1605 1662
 
1606 1663
 	$admin_email = get_site_option( 'admin_email' );
1607 1664
 
1608
-	if ( $admin_email == '' )
1609
-		$admin_email = 'support@' . $_SERVER['SERVER_NAME'];
1665
+	if ( $admin_email == '' ) {
1666
+			$admin_email = 'support@' . $_SERVER['SERVER_NAME'];
1667
+	}
1610 1668
 
1611 1669
 	$from_name = get_site_option( 'site_name' ) == '' ? 'WordPress' : esc_html( get_site_option( 'site_name' ) );
1612 1670
 	$message_headers = "From: \"{$from_name}\" <{$admin_email}>\n" . "Content-Type: text/plain; charset=\"" . get_option('blog_charset') . "\"\n";
1613 1671
 	$message = $welcome_email;
1614 1672
 
1615
-	if ( empty( $current_network->site_name ) )
1616
-		$current_network->site_name = 'WordPress';
1673
+	if ( empty( $current_network->site_name ) ) {
1674
+			$current_network->site_name = 'WordPress';
1675
+	}
1617 1676
 
1618 1677
 	/* translators: New user notification email subject. 1: Network name, 2: New user login */
1619 1678
 	$subject = __( 'New %1$s User: %2$s' );
@@ -1715,11 +1774,13 @@  discard block
 block discarded – undo
1715 1774
  */
1716 1775
 function get_dirsize( $directory ) {
1717 1776
 	$dirsize = get_transient( 'dirsize_cache' );
1718
-	if ( is_array( $dirsize ) && isset( $dirsize[ $directory ][ 'size' ] ) )
1719
-		return $dirsize[ $directory ][ 'size' ];
1777
+	if ( is_array( $dirsize ) && isset( $dirsize[ $directory ][ 'size' ] ) ) {
1778
+			return $dirsize[ $directory ][ 'size' ];
1779
+	}
1720 1780
 
1721
-	if ( ! is_array( $dirsize ) )
1722
-		$dirsize = array();
1781
+	if ( ! is_array( $dirsize ) ) {
1782
+			$dirsize = array();
1783
+	}
1723 1784
 
1724 1785
 	// Exclude individual site directories from the total when checking the main site,
1725 1786
 	// as they are subdirectories and should not be counted.
@@ -1763,8 +1824,9 @@  discard block
 block discarded – undo
1763 1824
 					$size += filesize($path);
1764 1825
 				} elseif (is_dir($path)) {
1765 1826
 					$handlesize = recurse_dirsize( $path, $exclude );
1766
-					if ($handlesize > 0)
1767
-						$size += $handlesize;
1827
+					if ($handlesize > 0) {
1828
+											$size += $handlesize;
1829
+					}
1768 1830
 				}
1769 1831
 			}
1770 1832
 		}
@@ -1792,8 +1854,9 @@  discard block
 block discarded – undo
1792 1854
 	$site_mimes = array();
1793 1855
 	foreach ( $site_exts as $ext ) {
1794 1856
 		foreach ( $mimes as $ext_pattern => $mime ) {
1795
-			if ( $ext != '' && strpos( $ext_pattern, $ext ) !== false )
1796
-				$site_mimes[$ext_pattern] = $mime;
1857
+			if ( $ext != '' && strpos( $ext_pattern, $ext ) !== false ) {
1858
+							$site_mimes[$ext_pattern] = $mime;
1859
+			}
1797 1860
 		}
1798 1861
 	}
1799 1862
 	return $site_mimes;
@@ -1831,9 +1894,10 @@  discard block
 block discarded – undo
1831 1894
 function wpmu_log_new_registrations( $blog_id, $user_id ) {
1832 1895
 	global $wpdb;
1833 1896
 	$user = get_userdata( (int) $user_id );
1834
-	if ( $user )
1835
-		$wpdb->insert( $wpdb->registration_log, array('email' => $user->user_email, 'IP' => preg_replace( '/[^0-9., ]/', '', wp_unslash( $_SERVER['REMOTE_ADDR'] ) ), 'blog_id' => $blog_id, 'date_registered' => current_time('mysql')) );
1836
-}
1897
+	if ( $user ) {
1898
+			$wpdb->insert( $wpdb->registration_log, array('email' => $user->user_email, 'IP' => preg_replace( '/[^0-9., ]/', '', wp_unslash( $_SERVER['REMOTE_ADDR'] ) ), 'blog_id' => $blog_id, 'date_registered' => current_time('mysql')) );
1899
+	}
1900
+	}
1837 1901
 
1838 1902
 /**
1839 1903
  * Maintains a canonical list of terms by syncing terms created for each blog with the global terms table.
@@ -1853,8 +1917,9 @@  discard block
 block discarded – undo
1853 1917
 	global $wpdb;
1854 1918
 	static $global_terms_recurse = null;
1855 1919
 
1856
-	if ( !global_terms_enabled() )
1857
-		return $term_id;
1920
+	if ( !global_terms_enabled() ) {
1921
+			return $term_id;
1922
+	}
1858 1923
 
1859 1924
 	// prevent a race condition
1860 1925
 	$recurse_start = false;
@@ -1874,8 +1939,9 @@  discard block
 block discarded – undo
1874 1939
 		if ( null == $used_global_id ) {
1875 1940
 			$wpdb->insert( $wpdb->sitecategories, array( 'cat_ID' => $term_id, 'cat_name' => $c->name, 'category_nicename' => $c->slug ) );
1876 1941
 			$global_id = $wpdb->insert_id;
1877
-			if ( empty( $global_id ) )
1878
-				return $term_id;
1942
+			if ( empty( $global_id ) ) {
1943
+							return $term_id;
1944
+			}
1879 1945
 		} else {
1880 1946
 			$max_global_id = $wpdb->get_var( "SELECT MAX(cat_ID) FROM $wpdb->sitecategories" );
1881 1947
 			$max_local_id = $wpdb->get_var( "SELECT MAX(term_id) FROM $wpdb->terms" );
@@ -1894,8 +1960,9 @@  discard block
 block discarded – undo
1894 1960
 	}
1895 1961
 
1896 1962
 	if ( $global_id != $term_id ) {
1897
-		if ( get_option( 'default_category' ) == $term_id )
1898
-			update_option( 'default_category', $global_id );
1963
+		if ( get_option( 'default_category' ) == $term_id ) {
1964
+					update_option( 'default_category', $global_id );
1965
+		}
1899 1966
 
1900 1967
 		$wpdb->update( $wpdb->terms, array('term_id' => $global_id), array('term_id' => $term_id) );
1901 1968
 		$wpdb->update( $wpdb->term_taxonomy, array('term_id' => $global_id), array('term_id' => $term_id) );
@@ -1903,8 +1970,9 @@  discard block
 block discarded – undo
1903 1970
 
1904 1971
 		clean_term_cache($term_id);
1905 1972
 	}
1906
-	if ( $recurse_start )
1907
-		$global_terms_recurse = null;
1973
+	if ( $recurse_start ) {
1974
+			$global_terms_recurse = null;
1975
+	}
1908 1976
 
1909 1977
 	return $global_id;
1910 1978
 }
@@ -1933,8 +2001,9 @@  discard block
 block discarded – undo
1933 2001
  * @return string|array If the upload is under the size limit, $upload is returned. Otherwise returns an error message.
1934 2002
  */
1935 2003
 function upload_is_file_too_big( $upload ) {
1936
-	if ( ! is_array( $upload ) || defined( 'WP_IMPORTING' ) || get_site_option( 'upload_space_check_disabled' ) )
1937
-		return $upload;
2004
+	if ( ! is_array( $upload ) || defined( 'WP_IMPORTING' ) || get_site_option( 'upload_space_check_disabled' ) ) {
2005
+			return $upload;
2006
+	}
1938 2007
 
1939 2008
 	if ( strlen( $upload['bits'] )  > ( KB_IN_BYTES * get_site_option( 'fileupload_maxk', 1500 ) ) ) {
1940 2009
 		return sprintf( __( 'This file is too big. Files must be less than %d KB in size.' ) . '<br />', get_site_option( 'fileupload_maxk', 1500 ) );
@@ -1963,11 +2032,13 @@  discard block
 block discarded – undo
1963 2032
  * @return array
1964 2033
  */
1965 2034
 function signup_nonce_check( $result ) {
1966
-	if ( !strpos( $_SERVER[ 'PHP_SELF' ], 'wp-signup.php' ) )
1967
-		return $result;
2035
+	if ( !strpos( $_SERVER[ 'PHP_SELF' ], 'wp-signup.php' ) ) {
2036
+			return $result;
2037
+	}
1968 2038
 
1969
-	if ( wp_create_nonce('signup_form_' . $_POST[ 'signup_form_id' ]) != $_POST['_signup_form'] )
1970
-		wp_die( __( 'Please try again.' ) );
2039
+	if ( wp_create_nonce('signup_form_' . $_POST[ 'signup_form_id' ]) != $_POST['_signup_form'] ) {
2040
+			wp_die( __( 'Please try again.' ) );
2041
+	}
1971 2042
 
1972 2043
 	return $result;
1973 2044
 }
@@ -1988,8 +2059,9 @@  discard block
 block discarded – undo
1988 2059
 	 * @param string $no_blog_redirect The redirect URL defined in NOBLOGREDIRECT.
1989 2060
 	 */
1990 2061
 	if ( is_main_site() && is_404() && defined( 'NOBLOGREDIRECT' ) && ( $destination = apply_filters( 'blog_redirect_404', NOBLOGREDIRECT ) ) ) {
1991
-		if ( $destination == '%siteurl%' )
1992
-			$destination = network_home_url();
2062
+		if ( $destination == '%siteurl%' ) {
2063
+					$destination = network_home_url();
2064
+		}
1993 2065
 		wp_redirect( $destination );
1994 2066
 		exit();
1995 2067
 	}
@@ -2005,21 +2077,25 @@  discard block
 block discarded – undo
2005 2077
  * @since MU
2006 2078
  */
2007 2079
 function maybe_add_existing_user_to_blog() {
2008
-	if ( false === strpos( $_SERVER[ 'REQUEST_URI' ], '/newbloguser/' ) )
2009
-		return;
2080
+	if ( false === strpos( $_SERVER[ 'REQUEST_URI' ], '/newbloguser/' ) ) {
2081
+			return;
2082
+	}
2010 2083
 
2011 2084
 	$parts = explode( '/', $_SERVER[ 'REQUEST_URI' ] );
2012 2085
 	$key = array_pop( $parts );
2013 2086
 
2014
-	if ( $key == '' )
2015
-		$key = array_pop( $parts );
2087
+	if ( $key == '' ) {
2088
+			$key = array_pop( $parts );
2089
+	}
2016 2090
 
2017 2091
 	$details = get_option( 'new_user_' . $key );
2018
-	if ( !empty( $details ) )
2019
-		delete_option( 'new_user_' . $key );
2092
+	if ( !empty( $details ) ) {
2093
+			delete_option( 'new_user_' . $key );
2094
+	}
2020 2095
 
2021
-	if ( empty( $details ) || is_wp_error( add_existing_user_to_blog( $details ) ) )
2022
-		wp_die( sprintf(__('An error occurred adding you to this site. Back to the <a href="%s">homepage</a>.'), home_url() ) );
2096
+	if ( empty( $details ) || is_wp_error( add_existing_user_to_blog( $details ) ) ) {
2097
+			wp_die( sprintf(__('An error occurred adding you to this site. Back to the <a href="%s">homepage</a>.'), home_url() ) );
2098
+	}
2023 2099
 
2024 2100
 	wp_die( sprintf( __( 'You have been added to this site. Please visit the <a href="%s">homepage</a> or <a href="%s">log in</a> using your username and password.' ), home_url(), admin_url() ), __( 'WordPress &rsaquo; Success' ), array( 'response' => 200 ) );
2025 2101
 }
@@ -2217,11 +2293,14 @@  discard block
 block discarded – undo
2217 2293
  * @return string URL with https as the scheme
2218 2294
  */
2219 2295
 function filter_SSL( $url ) {
2220
-	if ( ! is_string( $url ) )
2221
-		return get_bloginfo( 'url' ); // Return home blog url with proper scheme
2296
+	if ( ! is_string( $url ) ) {
2297
+			return get_bloginfo( 'url' );
2298
+	}
2299
+	// Return home blog url with proper scheme
2222 2300
 
2223
-	if ( force_ssl_content() && is_ssl() )
2224
-		$url = set_url_scheme( $url, 'https' );
2301
+	if ( force_ssl_content() && is_ssl() ) {
2302
+			$url = set_url_scheme( $url, 'https' );
2303
+	}
2225 2304
 
2226 2305
 	return $url;
2227 2306
 }
@@ -2232,12 +2311,14 @@  discard block
 block discarded – undo
2232 2311
  * @since 3.1.0
2233 2312
  */
2234 2313
 function wp_schedule_update_network_counts() {
2235
-	if ( !is_main_site() )
2236
-		return;
2314
+	if ( !is_main_site() ) {
2315
+			return;
2316
+	}
2237 2317
 
2238
-	if ( ! wp_next_scheduled('update_network_counts') && ! wp_installing() )
2239
-		wp_schedule_event(time(), 'twicedaily', 'update_network_counts');
2240
-}
2318
+	if ( ! wp_next_scheduled('update_network_counts') && ! wp_installing() ) {
2319
+			wp_schedule_event(time(), 'twicedaily', 'update_network_counts');
2320
+	}
2321
+	}
2241 2322
 
2242 2323
 /**
2243 2324
  * Update the network-wide counts for the current network.
@@ -2270,8 +2351,9 @@  discard block
 block discarded – undo
2270 2351
 	 * @param bool   $small_network Whether the network is considered small.
2271 2352
 	 * @param string $context       Context. Either 'users' or 'sites'.
2272 2353
 	 */
2273
-	if ( ! apply_filters( 'enable_live_network_counts', $is_small_network, 'sites' ) )
2274
-		return;
2354
+	if ( ! apply_filters( 'enable_live_network_counts', $is_small_network, 'sites' ) ) {
2355
+			return;
2356
+	}
2275 2357
 
2276 2358
 	wp_update_network_site_counts();
2277 2359
 }
@@ -2288,8 +2370,9 @@  discard block
 block discarded – undo
2288 2370
 	$is_small_network = ! wp_is_large_network( 'users' );
2289 2371
 
2290 2372
 	/** This filter is documented in wp-includes/ms-functions.php */
2291
-	if ( ! apply_filters( 'enable_live_network_counts', $is_small_network, 'users' ) )
2292
-		return;
2373
+	if ( ! apply_filters( 'enable_live_network_counts', $is_small_network, 'users' ) ) {
2374
+			return;
2375
+	}
2293 2376
 
2294 2377
 	wp_update_network_user_counts();
2295 2378
 }
@@ -2363,11 +2446,13 @@  discard block
 block discarded – undo
2363 2446
 function get_space_allowed() {
2364 2447
 	$space_allowed = get_option( 'blog_upload_space' );
2365 2448
 
2366
-	if ( ! is_numeric( $space_allowed ) )
2367
-		$space_allowed = get_site_option( 'blog_upload_space' );
2449
+	if ( ! is_numeric( $space_allowed ) ) {
2450
+			$space_allowed = get_site_option( 'blog_upload_space' );
2451
+	}
2368 2452
 
2369
-	if ( ! is_numeric( $space_allowed ) )
2370
-		$space_allowed = 100;
2453
+	if ( ! is_numeric( $space_allowed ) ) {
2454
+			$space_allowed = 100;
2455
+	}
2371 2456
 
2372 2457
 	/**
2373 2458
 	 * Filters the upload quota for the current site.
@@ -2392,13 +2477,15 @@  discard block
 block discarded – undo
2392 2477
 		$allowed = 0;
2393 2478
 	}
2394 2479
 	$space_allowed = $allowed * MB_IN_BYTES;
2395
-	if ( get_site_option( 'upload_space_check_disabled' ) )
2396
-		return $space_allowed;
2480
+	if ( get_site_option( 'upload_space_check_disabled' ) ) {
2481
+			return $space_allowed;
2482
+	}
2397 2483
 
2398 2484
 	$space_used = get_space_used() * MB_IN_BYTES;
2399 2485
 
2400
-	if ( ( $space_allowed - $space_used ) <= 0 )
2401
-		return 0;
2486
+	if ( ( $space_allowed - $space_used ) <= 0 ) {
2487
+			return 0;
2488
+	}
2402 2489
 
2403 2490
 	return $space_allowed - $space_used;
2404 2491
 }
@@ -2410,8 +2497,9 @@  discard block
 block discarded – undo
2410 2497
  * @return bool True if space is available, false otherwise.
2411 2498
  */
2412 2499
 function is_upload_space_available() {
2413
-	if ( get_site_option( 'upload_space_check_disabled' ) )
2414
-		return true;
2500
+	if ( get_site_option( 'upload_space_check_disabled' ) ) {
2501
+			return true;
2502
+	}
2415 2503
 
2416 2504
 	return (bool) get_upload_space_available();
2417 2505
 }
@@ -2426,8 +2514,9 @@  discard block
 block discarded – undo
2426 2514
  */
2427 2515
 function upload_size_limit_filter( $size ) {
2428 2516
 	$fileupload_maxk = KB_IN_BYTES * get_site_option( 'fileupload_maxk', 1500 );
2429
-	if ( get_site_option( 'upload_space_check_disabled' ) )
2430
-		return min( $size, $fileupload_maxk );
2517
+	if ( get_site_option( 'upload_space_check_disabled' ) ) {
2518
+			return min( $size, $fileupload_maxk );
2519
+	}
2431 2520
 
2432 2521
 	return min( $size, $fileupload_maxk, get_upload_space_available() );
2433 2522
 }
Please login to merge, or discard this patch.
src/wp-includes/class-wp-post-type.php 1 patch
Spacing   +76 added lines, -76 removed lines patch added patch discarded remove patch
@@ -346,10 +346,10 @@  discard block
 block discarded – undo
346 346
 	 * @param array|string $args      Optional. Array or string of arguments for registering a post type.
347 347
 	 *                                Default empty array.
348 348
 	 */
349
-	public function __construct( $post_type, $args = array() ) {
349
+	public function __construct($post_type, $args = array()) {
350 350
 		$this->name = $post_type;
351 351
 
352
-		$this->set_props( $args );
352
+		$this->set_props($args);
353 353
 	}
354 354
 
355 355
 	/**
@@ -360,8 +360,8 @@  discard block
 block discarded – undo
360 360
 	 *
361 361
 	 * @param array|string $args Array or string of arguments for registering a post type.
362 362
 	 */
363
-	public function set_props( $args ) {
364
-		$args = wp_parse_args( $args );
363
+	public function set_props($args) {
364
+		$args = wp_parse_args($args);
365 365
 
366 366
 		/**
367 367
 		 * Filter the arguments for registering a post type.
@@ -371,9 +371,9 @@  discard block
 block discarded – undo
371 371
 		 * @param array  $args      Array of arguments for registering a post type.
372 372
 		 * @param string $post_type Post type key.
373 373
 		 */
374
-		$args = apply_filters( 'register_post_type_args', $args, $this->name );
374
+		$args = apply_filters('register_post_type_args', $args, $this->name);
375 375
 
376
-		$has_edit_link = ! empty( $args['_edit_link'] );
376
+		$has_edit_link = ! empty($args['_edit_link']);
377 377
 
378 378
 		// Args prefixed with an underscore are reserved for internal use.
379 379
 		$defaults = array(
@@ -404,88 +404,88 @@  discard block
 block discarded – undo
404 404
 			'_edit_link'           => 'post.php?post=%d',
405 405
 		);
406 406
 
407
-		$args = array_merge( $defaults, $args );
407
+		$args = array_merge($defaults, $args);
408 408
 
409 409
 		$args['name'] = $this->name;
410 410
 
411 411
 		// If not set, default to the setting for public.
412
-		if ( null === $args['publicly_queryable'] ) {
412
+		if (null === $args['publicly_queryable']) {
413 413
 			$args['publicly_queryable'] = $args['public'];
414 414
 		}
415 415
 
416 416
 		// If not set, default to the setting for public.
417
-		if ( null === $args['show_ui'] ) {
417
+		if (null === $args['show_ui']) {
418 418
 			$args['show_ui'] = $args['public'];
419 419
 		}
420 420
 
421 421
 		// If not set, default to the setting for show_ui.
422
-		if ( null === $args['show_in_menu'] || ! $args['show_ui'] ) {
422
+		if (null === $args['show_in_menu'] || ! $args['show_ui']) {
423 423
 			$args['show_in_menu'] = $args['show_ui'];
424 424
 		}
425 425
 
426 426
 		// If not set, default to the whether the full UI is shown.
427
-		if ( null === $args['show_in_admin_bar'] ) {
427
+		if (null === $args['show_in_admin_bar']) {
428 428
 			$args['show_in_admin_bar'] = (bool) $args['show_in_menu'];
429 429
 		}
430 430
 
431 431
 		// If not set, default to the setting for public.
432
-		if ( null === $args['show_in_nav_menus'] ) {
432
+		if (null === $args['show_in_nav_menus']) {
433 433
 			$args['show_in_nav_menus'] = $args['public'];
434 434
 		}
435 435
 
436 436
 		// If not set, default to true if not public, false if public.
437
-		if ( null === $args['exclude_from_search'] ) {
437
+		if (null === $args['exclude_from_search']) {
438 438
 			$args['exclude_from_search'] = ! $args['public'];
439 439
 		}
440 440
 
441 441
 		// Back compat with quirky handling in version 3.0. #14122.
442
-		if ( empty( $args['capabilities'] ) && null === $args['map_meta_cap'] && in_array( $args['capability_type'], array( 'post', 'page' ) ) ) {
442
+		if (empty($args['capabilities']) && null === $args['map_meta_cap'] && in_array($args['capability_type'], array('post', 'page'))) {
443 443
 			$args['map_meta_cap'] = true;
444 444
 		}
445 445
 
446 446
 		// If not set, default to false.
447
-		if ( null === $args['map_meta_cap'] ) {
447
+		if (null === $args['map_meta_cap']) {
448 448
 			$args['map_meta_cap'] = false;
449 449
 		}
450 450
 
451 451
 		// If there's no specified edit link and no UI, remove the edit link.
452
-		if ( ! $args['show_ui'] && ! $has_edit_link ) {
452
+		if ( ! $args['show_ui'] && ! $has_edit_link) {
453 453
 			$args['_edit_link'] = '';
454 454
 		}
455 455
 
456
-		$this->cap = get_post_type_capabilities( (object) $args );
457
-		unset( $args['capabilities'] );
456
+		$this->cap = get_post_type_capabilities((object) $args);
457
+		unset($args['capabilities']);
458 458
 
459
-		if ( is_array( $args['capability_type'] ) ) {
459
+		if (is_array($args['capability_type'])) {
460 460
 			$args['capability_type'] = $args['capability_type'][0];
461 461
 		}
462 462
 
463
-		if ( false !== $args['query_var'] ) {
464
-			if ( true === $args['query_var'] ) {
463
+		if (false !== $args['query_var']) {
464
+			if (true === $args['query_var']) {
465 465
 				$args['query_var'] = $this->name;
466 466
 			} else {
467
-				$args['query_var'] = sanitize_title_with_dashes( $args['query_var'] );
467
+				$args['query_var'] = sanitize_title_with_dashes($args['query_var']);
468 468
 			}
469 469
 		}
470 470
 
471
-		if ( false !== $args['rewrite'] && ( is_admin() || '' != get_option( 'permalink_structure' ) ) ) {
472
-			if ( ! is_array( $args['rewrite'] ) ) {
471
+		if (false !== $args['rewrite'] && (is_admin() || '' != get_option('permalink_structure'))) {
472
+			if ( ! is_array($args['rewrite'])) {
473 473
 				$args['rewrite'] = array();
474 474
 			}
475
-			if ( empty( $args['rewrite']['slug'] ) ) {
475
+			if (empty($args['rewrite']['slug'])) {
476 476
 				$args['rewrite']['slug'] = $this->name;
477 477
 			}
478
-			if ( ! isset( $args['rewrite']['with_front'] ) ) {
478
+			if ( ! isset($args['rewrite']['with_front'])) {
479 479
 				$args['rewrite']['with_front'] = true;
480 480
 			}
481
-			if ( ! isset( $args['rewrite']['pages'] ) ) {
481
+			if ( ! isset($args['rewrite']['pages'])) {
482 482
 				$args['rewrite']['pages'] = true;
483 483
 			}
484
-			if ( ! isset( $args['rewrite']['feeds'] ) || ! $args['has_archive'] ) {
484
+			if ( ! isset($args['rewrite']['feeds']) || ! $args['has_archive']) {
485 485
 				$args['rewrite']['feeds'] = (bool) $args['has_archive'];
486 486
 			}
487
-			if ( ! isset( $args['rewrite']['ep_mask'] ) ) {
488
-				if ( isset( $args['permalink_epmask'] ) ) {
487
+			if ( ! isset($args['rewrite']['ep_mask'])) {
488
+				if (isset($args['permalink_epmask'])) {
489 489
 					$args['rewrite']['ep_mask'] = $args['permalink_epmask'];
490 490
 				} else {
491 491
 					$args['rewrite']['ep_mask'] = EP_PERMALINK;
@@ -493,11 +493,11 @@  discard block
 block discarded – undo
493 493
 			}
494 494
 		}
495 495
 
496
-		foreach ( $args as $property_name => $property_value ) {
496
+		foreach ($args as $property_name => $property_value) {
497 497
 			$this->$property_name = $property_value;
498 498
 		}
499 499
 
500
-		$this->labels = get_post_type_labels( $this );
500
+		$this->labels = get_post_type_labels($this);
501 501
 		$this->label  = $this->labels->name;
502 502
 	}
503 503
 
@@ -508,12 +508,12 @@  discard block
 block discarded – undo
508 508
 	 * @access public
509 509
 	 */
510 510
 	public function add_supports() {
511
-		if ( ! empty( $this->supports ) ) {
512
-			add_post_type_support( $this->name, $this->supports );
513
-			unset( $this->supports );
514
-		} elseif ( false !== $this->supports ) {
511
+		if ( ! empty($this->supports)) {
512
+			add_post_type_support($this->name, $this->supports);
513
+			unset($this->supports);
514
+		} elseif (false !== $this->supports) {
515 515
 			// Add default features.
516
-			add_post_type_support( $this->name, array( 'title', 'editor' ) );
516
+			add_post_type_support($this->name, array('title', 'editor'));
517 517
 		}
518 518
 	}
519 519
 
@@ -529,39 +529,39 @@  discard block
 block discarded – undo
529 529
 	public function add_rewrite_rules() {
530 530
 		global $wp_rewrite, $wp;
531 531
 
532
-		if ( false !== $this->query_var && $wp && is_post_type_viewable( $this ) ) {
533
-			$wp->add_query_var( $this->query_var );
532
+		if (false !== $this->query_var && $wp && is_post_type_viewable($this)) {
533
+			$wp->add_query_var($this->query_var);
534 534
 		}
535 535
 
536
-		if ( false !== $this->rewrite && ( is_admin() || '' != get_option( 'permalink_structure' ) ) ) {
537
-			if ( $this->hierarchical ) {
538
-				add_rewrite_tag( "%$this->name%", '(.+?)', $this->query_var ? "{$this->query_var}=" : "post_type=$this->name&pagename=" );
536
+		if (false !== $this->rewrite && (is_admin() || '' != get_option('permalink_structure'))) {
537
+			if ($this->hierarchical) {
538
+				add_rewrite_tag("%$this->name%", '(.+?)', $this->query_var ? "{$this->query_var}=" : "post_type=$this->name&pagename=");
539 539
 			} else {
540
-				add_rewrite_tag( "%$this->name%", '([^/]+)', $this->query_var ? "{$this->query_var}=" : "post_type=$this->name&name=" );
540
+				add_rewrite_tag("%$this->name%", '([^/]+)', $this->query_var ? "{$this->query_var}=" : "post_type=$this->name&name=");
541 541
 			}
542 542
 
543
-			if ( $this->has_archive ) {
543
+			if ($this->has_archive) {
544 544
 				$archive_slug = true === $this->has_archive ? $this->rewrite['slug'] : $this->has_archive;
545
-				if ( $this->rewrite['with_front'] ) {
546
-					$archive_slug = substr( $wp_rewrite->front, 1 ) . $archive_slug;
545
+				if ($this->rewrite['with_front']) {
546
+					$archive_slug = substr($wp_rewrite->front, 1).$archive_slug;
547 547
 				} else {
548
-					$archive_slug = $wp_rewrite->root . $archive_slug;
548
+					$archive_slug = $wp_rewrite->root.$archive_slug;
549 549
 				}
550 550
 
551
-				add_rewrite_rule( "{$archive_slug}/?$", "index.php?post_type=$this->name", 'top' );
552
-				if ( $this->rewrite['feeds'] && $wp_rewrite->feeds ) {
553
-					$feeds = '(' . trim( implode( '|', $wp_rewrite->feeds ) ) . ')';
554
-					add_rewrite_rule( "{$archive_slug}/feed/$feeds/?$", "index.php?post_type=$this->name" . '&feed=$matches[1]', 'top' );
555
-					add_rewrite_rule( "{$archive_slug}/$feeds/?$", "index.php?post_type=$this->name" . '&feed=$matches[1]', 'top' );
551
+				add_rewrite_rule("{$archive_slug}/?$", "index.php?post_type=$this->name", 'top');
552
+				if ($this->rewrite['feeds'] && $wp_rewrite->feeds) {
553
+					$feeds = '('.trim(implode('|', $wp_rewrite->feeds)).')';
554
+					add_rewrite_rule("{$archive_slug}/feed/$feeds/?$", "index.php?post_type=$this->name".'&feed=$matches[1]', 'top');
555
+					add_rewrite_rule("{$archive_slug}/$feeds/?$", "index.php?post_type=$this->name".'&feed=$matches[1]', 'top');
556 556
 				}
557
-				if ( $this->rewrite['pages'] ) {
558
-					add_rewrite_rule( "{$archive_slug}/{$wp_rewrite->pagination_base}/([0-9]{1,})/?$", "index.php?post_type=$this->name" . '&paged=$matches[1]', 'top' );
557
+				if ($this->rewrite['pages']) {
558
+					add_rewrite_rule("{$archive_slug}/{$wp_rewrite->pagination_base}/([0-9]{1,})/?$", "index.php?post_type=$this->name".'&paged=$matches[1]', 'top');
559 559
 				}
560 560
 			}
561 561
 
562 562
 			$permastruct_args         = $this->rewrite;
563 563
 			$permastruct_args['feed'] = $permastruct_args['feeds'];
564
-			add_permastruct( $this->name, "{$this->rewrite['slug']}/%$this->name%", $permastruct_args );
564
+			add_permastruct($this->name, "{$this->rewrite['slug']}/%$this->name%", $permastruct_args);
565 565
 		}
566 566
 	}
567 567
 
@@ -572,8 +572,8 @@  discard block
 block discarded – undo
572 572
 	 * @access public
573 573
 	 */
574 574
 	public function register_meta_boxes() {
575
-		if ( $this->register_meta_box_cb ) {
576
-			add_action( 'add_meta_boxes_' . $this->name, $this->register_meta_box_cb, 10, 1 );
575
+		if ($this->register_meta_box_cb) {
576
+			add_action('add_meta_boxes_'.$this->name, $this->register_meta_box_cb, 10, 1);
577 577
 		}
578 578
 	}
579 579
 
@@ -584,7 +584,7 @@  discard block
 block discarded – undo
584 584
 	 * @access public
585 585
 	 */
586 586
 	public function add_hooks() {
587
-		add_action( 'future_' . $this->name, '_future_post_hook', 5, 2 );
587
+		add_action('future_'.$this->name, '_future_post_hook', 5, 2);
588 588
 	}
589 589
 
590 590
 	/**
@@ -594,8 +594,8 @@  discard block
 block discarded – undo
594 594
 	 * @access public
595 595
 	 */
596 596
 	public function register_taxonomies() {
597
-		foreach ( $this->taxonomies as $taxonomy ) {
598
-			register_taxonomy_for_object_type( $taxonomy, $this->name );
597
+		foreach ($this->taxonomies as $taxonomy) {
598
+			register_taxonomy_for_object_type($taxonomy, $this->name);
599 599
 		}
600 600
 	}
601 601
 
@@ -610,7 +610,7 @@  discard block
 block discarded – undo
610 610
 	public function remove_supports() {
611 611
 		global $_wp_post_type_features;
612 612
 
613
-		unset( $_wp_post_type_features[ $this->name ] );
613
+		unset($_wp_post_type_features[$this->name]);
614 614
 	}
615 615
 
616 616
 	/**
@@ -627,24 +627,24 @@  discard block
 block discarded – undo
627 627
 		global $wp, $wp_rewrite, $post_type_meta_caps;
628 628
 
629 629
 		// Remove query var.
630
-		if ( false !== $this->query_var ) {
631
-			$wp->remove_query_var( $this->query_var );
630
+		if (false !== $this->query_var) {
631
+			$wp->remove_query_var($this->query_var);
632 632
 		}
633 633
 
634 634
 		// Remove any rewrite rules, permastructs, and rules.
635
-		if ( false !== $this->rewrite ) {
636
-			remove_rewrite_tag( "%$this->name%" );
637
-			remove_permastruct( $this->name );
638
-			foreach ( $wp_rewrite->extra_rules_top as $regex => $query ) {
639
-				if ( false !== strpos( $query, "index.php?post_type=$this->name" ) ) {
640
-					unset( $wp_rewrite->extra_rules_top[ $regex ] );
635
+		if (false !== $this->rewrite) {
636
+			remove_rewrite_tag("%$this->name%");
637
+			remove_permastruct($this->name);
638
+			foreach ($wp_rewrite->extra_rules_top as $regex => $query) {
639
+				if (false !== strpos($query, "index.php?post_type=$this->name")) {
640
+					unset($wp_rewrite->extra_rules_top[$regex]);
641 641
 				}
642 642
 			}
643 643
 		}
644 644
 
645 645
 		// Remove registered custom meta capabilities.
646
-		foreach ( $this->cap as $cap ) {
647
-			unset( $post_type_meta_caps[ $cap ] );
646
+		foreach ($this->cap as $cap) {
647
+			unset($post_type_meta_caps[$cap]);
648 648
 		}
649 649
 	}
650 650
 
@@ -655,8 +655,8 @@  discard block
 block discarded – undo
655 655
 	 * @access public
656 656
 	 */
657 657
 	public function unregister_meta_boxes() {
658
-		if ( $this->register_meta_box_cb ) {
659
-			remove_action( 'add_meta_boxes_' . $this->name, $this->register_meta_box_cb, 10 );
658
+		if ($this->register_meta_box_cb) {
659
+			remove_action('add_meta_boxes_'.$this->name, $this->register_meta_box_cb, 10);
660 660
 		}
661 661
 	}
662 662
 
@@ -667,8 +667,8 @@  discard block
 block discarded – undo
667 667
 	 * @access public
668 668
 	 */
669 669
 	public function unregister_taxonomies() {
670
-		foreach ( get_object_taxonomies( $this->name ) as $taxonomy ) {
671
-			unregister_taxonomy_for_object_type( $taxonomy, $this->name );
670
+		foreach (get_object_taxonomies($this->name) as $taxonomy) {
671
+			unregister_taxonomy_for_object_type($taxonomy, $this->name);
672 672
 		}
673 673
 	}
674 674
 
@@ -679,6 +679,6 @@  discard block
 block discarded – undo
679 679
 	 * @access public
680 680
 	 */
681 681
 	public function remove_hooks() {
682
-		remove_action( 'future_' . $this->name, '_future_post_hook', 5 );
682
+		remove_action('future_'.$this->name, '_future_post_hook', 5);
683 683
 	}
684 684
 }
Please login to merge, or discard this patch.
src/wp-includes/class-wp-customize-setting.php 2 patches
Braces   +35 added lines, -22 removed lines patch added patch discarded remove patch
@@ -738,8 +738,9 @@  discard block
 block discarded – undo
738 738
 		 */
739 739
 		$value = apply_filters( "customize_sanitize_js_{$this->id}", $this->value(), $this );
740 740
 
741
-		if ( is_string( $value ) )
742
-			return html_entity_decode( $value, ENT_QUOTES, 'UTF-8');
741
+		if ( is_string( $value ) ) {
742
+					return html_entity_decode( $value, ENT_QUOTES, 'UTF-8');
743
+		}
743 744
 
744 745
 		return $value;
745 746
 	}
@@ -768,11 +769,13 @@  discard block
 block discarded – undo
768 769
 	 * @return bool False if theme doesn't support the setting or user can't change setting, otherwise true.
769 770
 	 */
770 771
 	final public function check_capabilities() {
771
-		if ( $this->capability && ! call_user_func_array( 'current_user_can', (array) $this->capability ) )
772
-			return false;
772
+		if ( $this->capability && ! call_user_func_array( 'current_user_can', (array) $this->capability ) ) {
773
+					return false;
774
+		}
773 775
 
774
-		if ( $this->theme_supports && ! call_user_func_array( 'current_theme_supports', (array) $this->theme_supports ) )
775
-			return false;
776
+		if ( $this->theme_supports && ! call_user_func_array( 'current_theme_supports', (array) $this->theme_supports ) ) {
777
+					return false;
778
+		}
776 779
 
777 780
 		return true;
778 781
 	}
@@ -788,21 +791,25 @@  discard block
 block discarded – undo
788 791
 	 * @return array|void Keys are 'root', 'node', and 'key'.
789 792
 	 */
790 793
 	final protected function multidimensional( &$root, $keys, $create = false ) {
791
-		if ( $create && empty( $root ) )
792
-			$root = array();
794
+		if ( $create && empty( $root ) ) {
795
+					$root = array();
796
+		}
793 797
 
794
-		if ( ! isset( $root ) || empty( $keys ) )
795
-			return;
798
+		if ( ! isset( $root ) || empty( $keys ) ) {
799
+					return;
800
+		}
796 801
 
797 802
 		$last = array_pop( $keys );
798 803
 		$node = &$root;
799 804
 
800 805
 		foreach ( $keys as $key ) {
801
-			if ( $create && ! isset( $node[ $key ] ) )
802
-				$node[ $key ] = array();
806
+			if ( $create && ! isset( $node[ $key ] ) ) {
807
+							$node[ $key ] = array();
808
+			}
803 809
 
804
-			if ( ! is_array( $node ) || ! isset( $node[ $key ] ) )
805
-				return;
810
+			if ( ! is_array( $node ) || ! isset( $node[ $key ] ) ) {
811
+							return;
812
+			}
806 813
 
807 814
 			$node = &$node[ $key ];
808 815
 		}
@@ -817,8 +824,9 @@  discard block
 block discarded – undo
817 824
 			}
818 825
 		}
819 826
 
820
-		if ( ! isset( $node[ $last ] ) )
821
-			return;
827
+		if ( ! isset( $node[ $last ] ) ) {
828
+					return;
829
+		}
822 830
 
823 831
 		return array(
824 832
 			'root' => &$root,
@@ -838,15 +846,18 @@  discard block
 block discarded – undo
838 846
 	 * @return mixed
839 847
 	 */
840 848
 	final protected function multidimensional_replace( $root, $keys, $value ) {
841
-		if ( ! isset( $value ) )
842
-			return $root;
843
-		elseif ( empty( $keys ) ) // If there are no keys, we're replacing the root.
849
+		if ( ! isset( $value ) ) {
850
+					return $root;
851
+		} elseif ( empty( $keys ) ) {
852
+			// If there are no keys, we're replacing the root.
844 853
 			return $value;
854
+		}
845 855
 
846 856
 		$result = $this->multidimensional( $root, $keys, true );
847 857
 
848
-		if ( isset( $result ) )
849
-			$result['node'][ $result['key'] ] = $value;
858
+		if ( isset( $result ) ) {
859
+					$result['node'][ $result['key'] ] = $value;
860
+		}
850 861
 
851 862
 		return $root;
852 863
 	}
@@ -862,8 +873,10 @@  discard block
 block discarded – undo
862 873
 	 * @return mixed The requested value or the default value.
863 874
 	 */
864 875
 	final protected function multidimensional_get( $root, $keys, $default = null ) {
865
-		if ( empty( $keys ) ) // If there are no keys, test the root.
876
+		if ( empty( $keys ) ) {
877
+			// If there are no keys, test the root.
866 878
 			return isset( $root ) ? $root : $default;
879
+		}
867 880
 
868 881
 		$result = $this->multidimensional( $root, $keys );
869 882
 		return isset( $result ) ? $result['node'][ $result['key'] ] : $default;
Please login to merge, or discard this patch.
Spacing   +159 added lines, -159 removed lines patch added patch discarded remove patch
@@ -122,11 +122,11 @@  discard block
 block discarded – undo
122 122
 	 *                                      theme mod or option name.
123 123
 	 * @param array                $args    Setting arguments.
124 124
 	 */
125
-	public function __construct( $manager, $id, $args = array() ) {
126
-		$keys = array_keys( get_object_vars( $this ) );
127
-		foreach ( $keys as $key ) {
128
-			if ( isset( $args[ $key ] ) ) {
129
-				$this->$key = $args[ $key ];
125
+	public function __construct($manager, $id, $args = array()) {
126
+		$keys = array_keys(get_object_vars($this));
127
+		foreach ($keys as $key) {
128
+			if (isset($args[$key])) {
129
+				$this->$key = $args[$key];
130 130
 			}
131 131
 		}
132 132
 
@@ -134,32 +134,32 @@  discard block
 block discarded – undo
134 134
 		$this->id = $id;
135 135
 
136 136
 		// Parse the ID for array keys.
137
-		$this->id_data['keys'] = preg_split( '/\[/', str_replace( ']', '', $this->id ) );
138
-		$this->id_data['base'] = array_shift( $this->id_data['keys'] );
137
+		$this->id_data['keys'] = preg_split('/\[/', str_replace(']', '', $this->id));
138
+		$this->id_data['base'] = array_shift($this->id_data['keys']);
139 139
 
140 140
 		// Rebuild the ID.
141
-		$this->id = $this->id_data[ 'base' ];
142
-		if ( ! empty( $this->id_data[ 'keys' ] ) ) {
143
-			$this->id .= '[' . implode( '][', $this->id_data['keys'] ) . ']';
141
+		$this->id = $this->id_data['base'];
142
+		if ( ! empty($this->id_data['keys'])) {
143
+			$this->id .= '['.implode('][', $this->id_data['keys']).']';
144 144
 		}
145 145
 
146
-		if ( $this->validate_callback ) {
147
-			add_filter( "customize_validate_{$this->id}", $this->validate_callback, 10, 3 );
146
+		if ($this->validate_callback) {
147
+			add_filter("customize_validate_{$this->id}", $this->validate_callback, 10, 3);
148 148
 		}
149
-		if ( $this->sanitize_callback ) {
150
-			add_filter( "customize_sanitize_{$this->id}", $this->sanitize_callback, 10, 2 );
149
+		if ($this->sanitize_callback) {
150
+			add_filter("customize_sanitize_{$this->id}", $this->sanitize_callback, 10, 2);
151 151
 		}
152
-		if ( $this->sanitize_js_callback ) {
153
-			add_filter( "customize_sanitize_js_{$this->id}", $this->sanitize_js_callback, 10, 2 );
152
+		if ($this->sanitize_js_callback) {
153
+			add_filter("customize_sanitize_js_{$this->id}", $this->sanitize_js_callback, 10, 2);
154 154
 		}
155 155
 
156
-		if ( 'option' === $this->type || 'theme_mod' === $this->type ) {
156
+		if ('option' === $this->type || 'theme_mod' === $this->type) {
157 157
 			// Other setting types can opt-in to aggregate multidimensional explicitly.
158 158
 			$this->aggregate_multidimensional();
159 159
 
160 160
 			// Allow option settings to indicate whether they should be autoloaded.
161
-			if ( 'option' === $this->type && isset( $args['autoload'] ) ) {
162
-				self::$aggregated_multidimensionals[ $this->type ][ $this->id_data['base'] ]['autoload'] = $args['autoload'];
161
+			if ('option' === $this->type && isset($args['autoload'])) {
162
+				self::$aggregated_multidimensionals[$this->type][$this->id_data['base']]['autoload'] = $args['autoload'];
163 163
 			}
164 164
 		}
165 165
 	}
@@ -192,20 +192,20 @@  discard block
 block discarded – undo
192 192
 	 */
193 193
 	protected function aggregate_multidimensional() {
194 194
 		$id_base = $this->id_data['base'];
195
-		if ( ! isset( self::$aggregated_multidimensionals[ $this->type ] ) ) {
196
-			self::$aggregated_multidimensionals[ $this->type ] = array();
195
+		if ( ! isset(self::$aggregated_multidimensionals[$this->type])) {
196
+			self::$aggregated_multidimensionals[$this->type] = array();
197 197
 		}
198
-		if ( ! isset( self::$aggregated_multidimensionals[ $this->type ][ $id_base ] ) ) {
199
-			self::$aggregated_multidimensionals[ $this->type ][ $id_base ] = array(
198
+		if ( ! isset(self::$aggregated_multidimensionals[$this->type][$id_base])) {
199
+			self::$aggregated_multidimensionals[$this->type][$id_base] = array(
200 200
 				'previewed_instances'       => array(), // Calling preview() will add the $setting to the array.
201 201
 				'preview_applied_instances' => array(), // Flags for which settings have had their values applied.
202
-				'root_value'                => $this->get_root_value( array() ), // Root value for initial state, manipulated by preview and update calls.
202
+				'root_value'                => $this->get_root_value(array()), // Root value for initial state, manipulated by preview and update calls.
203 203
 			);
204 204
 		}
205 205
 
206
-		if ( ! empty( $this->id_data['keys'] ) ) {
206
+		if ( ! empty($this->id_data['keys'])) {
207 207
 			// Note the preview-applied flag is cleared at priority 9 to ensure it is cleared before a deferred-preview runs.
208
-			add_action( "customize_post_value_set_{$this->id}", array( $this, '_clear_aggregated_multidimensional_preview_applied_flag' ), 9 );
208
+			add_action("customize_post_value_set_{$this->id}", array($this, '_clear_aggregated_multidimensional_preview_applied_flag'), 9);
209 209
 			$this->is_multidimensional_aggregated = true;
210 210
 		}
211 211
 	}
@@ -241,10 +241,10 @@  discard block
 block discarded – undo
241 241
 	 * @return bool If preview() has been called.
242 242
 	 */
243 243
 	public function is_current_blog_previewed() {
244
-		if ( ! isset( $this->_previewed_blog_id ) ) {
244
+		if ( ! isset($this->_previewed_blog_id)) {
245 245
 			return false;
246 246
 		}
247
-		return ( get_current_blog_id() === $this->_previewed_blog_id );
247
+		return (get_current_blog_id() === $this->_previewed_blog_id);
248 248
 	}
249 249
 
250 250
 	/**
@@ -270,18 +270,18 @@  discard block
 block discarded – undo
270 270
 	 * @return bool False when preview short-circuits due no change needing to be previewed.
271 271
 	 */
272 272
 	public function preview() {
273
-		if ( ! isset( $this->_previewed_blog_id ) ) {
273
+		if ( ! isset($this->_previewed_blog_id)) {
274 274
 			$this->_previewed_blog_id = get_current_blog_id();
275 275
 		}
276 276
 
277 277
 		// Prevent re-previewing an already-previewed setting.
278
-		if ( $this->is_previewed ) {
278
+		if ($this->is_previewed) {
279 279
 			return true;
280 280
 		}
281 281
 
282 282
 		$id_base = $this->id_data['base'];
283
-		$is_multidimensional = ! empty( $this->id_data['keys'] );
284
-		$multidimensional_filter = array( $this, '_multidimensional_preview_filter' );
283
+		$is_multidimensional = ! empty($this->id_data['keys']);
284
+		$multidimensional_filter = array($this, '_multidimensional_preview_filter');
285 285
 
286 286
 		/*
287 287
 		 * Check if the setting has a pre-existing value (an isset check),
@@ -290,53 +290,53 @@  discard block
 block discarded – undo
290 290
 		 * to be previewed.
291 291
 		 */
292 292
 		$undefined = new stdClass();
293
-		$needs_preview = ( $undefined !== $this->post_value( $undefined ) );
293
+		$needs_preview = ($undefined !== $this->post_value($undefined));
294 294
 		$value = null;
295 295
 
296 296
 		// Since no post value was defined, check if we have an initial value set.
297
-		if ( ! $needs_preview ) {
298
-			if ( $this->is_multidimensional_aggregated ) {
299
-				$root = self::$aggregated_multidimensionals[ $this->type ][ $id_base ]['root_value'];
300
-				$value = $this->multidimensional_get( $root, $this->id_data['keys'], $undefined );
297
+		if ( ! $needs_preview) {
298
+			if ($this->is_multidimensional_aggregated) {
299
+				$root = self::$aggregated_multidimensionals[$this->type][$id_base]['root_value'];
300
+				$value = $this->multidimensional_get($root, $this->id_data['keys'], $undefined);
301 301
 			} else {
302 302
 				$default = $this->default;
303 303
 				$this->default = $undefined; // Temporarily set default to undefined so we can detect if existing value is set.
304 304
 				$value = $this->value();
305 305
 				$this->default = $default;
306 306
 			}
307
-			$needs_preview = ( $undefined === $value ); // Because the default needs to be supplied.
307
+			$needs_preview = ($undefined === $value); // Because the default needs to be supplied.
308 308
 		}
309 309
 
310 310
 		// If the setting does not need previewing now, defer to when it has a value to preview.
311
-		if ( ! $needs_preview ) {
312
-			if ( ! has_action( "customize_post_value_set_{$this->id}", array( $this, 'preview' ) ) ) {
313
-				add_action( "customize_post_value_set_{$this->id}", array( $this, 'preview' ) );
311
+		if ( ! $needs_preview) {
312
+			if ( ! has_action("customize_post_value_set_{$this->id}", array($this, 'preview'))) {
313
+				add_action("customize_post_value_set_{$this->id}", array($this, 'preview'));
314 314
 			}
315 315
 			return false;
316 316
 		}
317 317
 
318
-		switch ( $this->type ) {
318
+		switch ($this->type) {
319 319
 			case 'theme_mod' :
320
-				if ( ! $is_multidimensional ) {
321
-					add_filter( "theme_mod_{$id_base}", array( $this, '_preview_filter' ) );
320
+				if ( ! $is_multidimensional) {
321
+					add_filter("theme_mod_{$id_base}", array($this, '_preview_filter'));
322 322
 				} else {
323
-					if ( empty( self::$aggregated_multidimensionals[ $this->type ][ $id_base ]['previewed_instances'] ) ) {
323
+					if (empty(self::$aggregated_multidimensionals[$this->type][$id_base]['previewed_instances'])) {
324 324
 						// Only add this filter once for this ID base.
325
-						add_filter( "theme_mod_{$id_base}", $multidimensional_filter );
325
+						add_filter("theme_mod_{$id_base}", $multidimensional_filter);
326 326
 					}
327
-					self::$aggregated_multidimensionals[ $this->type ][ $id_base ]['previewed_instances'][ $this->id ] = $this;
327
+					self::$aggregated_multidimensionals[$this->type][$id_base]['previewed_instances'][$this->id] = $this;
328 328
 				}
329 329
 				break;
330 330
 			case 'option' :
331
-				if ( ! $is_multidimensional ) {
332
-					add_filter( "pre_option_{$id_base}", array( $this, '_preview_filter' ) );
331
+				if ( ! $is_multidimensional) {
332
+					add_filter("pre_option_{$id_base}", array($this, '_preview_filter'));
333 333
 				} else {
334
-					if ( empty( self::$aggregated_multidimensionals[ $this->type ][ $id_base ]['previewed_instances'] ) ) {
334
+					if (empty(self::$aggregated_multidimensionals[$this->type][$id_base]['previewed_instances'])) {
335 335
 						// Only add these filters once for this ID base.
336
-						add_filter( "option_{$id_base}", $multidimensional_filter );
337
-						add_filter( "default_option_{$id_base}", $multidimensional_filter );
336
+						add_filter("option_{$id_base}", $multidimensional_filter);
337
+						add_filter("default_option_{$id_base}", $multidimensional_filter);
338 338
 					}
339
-					self::$aggregated_multidimensionals[ $this->type ][ $id_base ]['previewed_instances'][ $this->id ] = $this;
339
+					self::$aggregated_multidimensionals[$this->type][$id_base]['previewed_instances'][$this->id] = $this;
340 340
 				}
341 341
 				break;
342 342
 			default :
@@ -351,7 +351,7 @@  discard block
 block discarded – undo
351 351
 				 *
352 352
 				 * @param WP_Customize_Setting $this WP_Customize_Setting instance.
353 353
 				 */
354
-				do_action( "customize_preview_{$this->id}", $this );
354
+				do_action("customize_preview_{$this->id}", $this);
355 355
 
356 356
 				/**
357 357
 				 * Fires when the WP_Customize_Setting::preview() method is called for settings
@@ -363,7 +363,7 @@  discard block
 block discarded – undo
363 363
 				 *
364 364
 				 * @param WP_Customize_Setting $this WP_Customize_Setting instance.
365 365
 				 */
366
-				do_action( "customize_preview_{$this->type}", $this );
366
+				do_action("customize_preview_{$this->type}", $this);
367 367
 		}
368 368
 
369 369
 		$this->is_previewed = true;
@@ -384,7 +384,7 @@  discard block
 block discarded – undo
384 384
 	 * @see WP_Customize_Setting::_multidimensional_preview_filter()
385 385
 	 */
386 386
 	final public function _clear_aggregated_multidimensional_preview_applied_flag() {
387
-		unset( self::$aggregated_multidimensionals[ $this->type ][ $this->id_data['base'] ]['preview_applied_instances'][ $this->id ] );
387
+		unset(self::$aggregated_multidimensionals[$this->type][$this->id_data['base']]['preview_applied_instances'][$this->id]);
388 388
 	}
389 389
 
390 390
 	/**
@@ -399,14 +399,14 @@  discard block
 block discarded – undo
399 399
 	 * @param mixed $original Old value.
400 400
 	 * @return mixed New or old value.
401 401
 	 */
402
-	public function _preview_filter( $original ) {
403
-		if ( ! $this->is_current_blog_previewed() ) {
402
+	public function _preview_filter($original) {
403
+		if ( ! $this->is_current_blog_previewed()) {
404 404
 			return $original;
405 405
 		}
406 406
 
407 407
 		$undefined = new stdClass(); // Symbol hack.
408
-		$post_value = $this->post_value( $undefined );
409
-		if ( $undefined !== $post_value ) {
408
+		$post_value = $this->post_value($undefined);
409
+		if ($undefined !== $post_value) {
410 410
 			$value = $post_value;
411 411
 		} else {
412 412
 			/*
@@ -432,35 +432,35 @@  discard block
 block discarded – undo
432 432
 	 * @param mixed $original Original root value.
433 433
 	 * @return mixed New or old value.
434 434
 	 */
435
-	final public function _multidimensional_preview_filter( $original ) {
436
-		if ( ! $this->is_current_blog_previewed() ) {
435
+	final public function _multidimensional_preview_filter($original) {
436
+		if ( ! $this->is_current_blog_previewed()) {
437 437
 			return $original;
438 438
 		}
439 439
 
440 440
 		$id_base = $this->id_data['base'];
441 441
 
442 442
 		// If no settings have been previewed yet (which should not be the case, since $this is), just pass through the original value.
443
-		if ( empty( self::$aggregated_multidimensionals[ $this->type ][ $id_base ]['previewed_instances'] ) ) {
443
+		if (empty(self::$aggregated_multidimensionals[$this->type][$id_base]['previewed_instances'])) {
444 444
 			return $original;
445 445
 		}
446 446
 
447
-		foreach ( self::$aggregated_multidimensionals[ $this->type ][ $id_base ]['previewed_instances'] as $previewed_setting ) {
447
+		foreach (self::$aggregated_multidimensionals[$this->type][$id_base]['previewed_instances'] as $previewed_setting) {
448 448
 			// Skip applying previewed value for any settings that have already been applied.
449
-			if ( ! empty( self::$aggregated_multidimensionals[ $this->type ][ $id_base ]['preview_applied_instances'][ $previewed_setting->id ] ) ) {
449
+			if ( ! empty(self::$aggregated_multidimensionals[$this->type][$id_base]['preview_applied_instances'][$previewed_setting->id])) {
450 450
 				continue;
451 451
 			}
452 452
 
453 453
 			// Do the replacements of the posted/default sub value into the root value.
454
-			$value = $previewed_setting->post_value( $previewed_setting->default );
455
-			$root = self::$aggregated_multidimensionals[ $previewed_setting->type ][ $id_base ]['root_value'];
456
-			$root = $previewed_setting->multidimensional_replace( $root, $previewed_setting->id_data['keys'], $value );
457
-			self::$aggregated_multidimensionals[ $previewed_setting->type ][ $id_base ]['root_value'] = $root;
454
+			$value = $previewed_setting->post_value($previewed_setting->default);
455
+			$root = self::$aggregated_multidimensionals[$previewed_setting->type][$id_base]['root_value'];
456
+			$root = $previewed_setting->multidimensional_replace($root, $previewed_setting->id_data['keys'], $value);
457
+			self::$aggregated_multidimensionals[$previewed_setting->type][$id_base]['root_value'] = $root;
458 458
 
459 459
 			// Mark this setting having been applied so that it will be skipped when the filter is called again.
460
-			self::$aggregated_multidimensionals[ $previewed_setting->type ][ $id_base ]['preview_applied_instances'][ $previewed_setting->id ] = true;
460
+			self::$aggregated_multidimensionals[$previewed_setting->type][$id_base]['preview_applied_instances'][$previewed_setting->id] = true;
461 461
 		}
462 462
 
463
-		return self::$aggregated_multidimensionals[ $this->type ][ $id_base ]['root_value'];
463
+		return self::$aggregated_multidimensionals[$this->type][$id_base]['root_value'];
464 464
 	}
465 465
 
466 466
 	/**
@@ -476,7 +476,7 @@  discard block
 block discarded – undo
476 476
 	final public function save() {
477 477
 		$value = $this->post_value();
478 478
 
479
-		if ( ! $this->check_capabilities() || ! isset( $value ) ) {
479
+		if ( ! $this->check_capabilities() || ! isset($value)) {
480 480
 			return false;
481 481
 		}
482 482
 
@@ -492,9 +492,9 @@  discard block
 block discarded – undo
492 492
 		 *
493 493
 		 * @param WP_Customize_Setting $this WP_Customize_Setting instance.
494 494
 		 */
495
-		do_action( "customize_save_{$id_base}", $this );
495
+		do_action("customize_save_{$id_base}", $this);
496 496
 
497
-		$this->update( $value );
497
+		$this->update($value);
498 498
 	}
499 499
 
500 500
 	/**
@@ -507,8 +507,8 @@  discard block
 block discarded – undo
507 507
 	 * @param mixed $default A default value which is used as a fallback. Default is null.
508 508
 	 * @return mixed The default value on failure, otherwise the sanitized and validated value.
509 509
 	 */
510
-	final public function post_value( $default = null ) {
511
-		return $this->manager->post_value( $this, $default );
510
+	final public function post_value($default = null) {
511
+		return $this->manager->post_value($this, $default);
512 512
 	}
513 513
 
514 514
 	/**
@@ -519,7 +519,7 @@  discard block
 block discarded – undo
519 519
 	 * @param string|array $value    The value to sanitize.
520 520
 	 * @return string|array|null|WP_Error Sanitized value, or `null`/`WP_Error` if invalid.
521 521
 	 */
522
-	public function sanitize( $value ) {
522
+	public function sanitize($value) {
523 523
 
524 524
 		/**
525 525
 		 * Filters a Customize setting value in un-slashed form.
@@ -529,7 +529,7 @@  discard block
 block discarded – undo
529 529
 		 * @param mixed                $value Value of the setting.
530 530
 		 * @param WP_Customize_Setting $this  WP_Customize_Setting instance.
531 531
 		 */
532
-		return apply_filters( "customize_sanitize_{$this->id}", $value, $this );
532
+		return apply_filters("customize_sanitize_{$this->id}", $value, $this);
533 533
 	}
534 534
 
535 535
 	/**
@@ -543,12 +543,12 @@  discard block
 block discarded – undo
543 543
 	 * @param mixed $value Value to validate.
544 544
 	 * @return true|WP_Error True if the input was validated, otherwise WP_Error.
545 545
 	 */
546
-	public function validate( $value ) {
547
-		if ( is_wp_error( $value ) ) {
546
+	public function validate($value) {
547
+		if (is_wp_error($value)) {
548 548
 			return $value;
549 549
 		}
550
-		if ( is_null( $value ) ) {
551
-			return new WP_Error( 'invalid_value', __( 'Invalid value.' ) );
550
+		if (is_null($value)) {
551
+			return new WP_Error('invalid_value', __('Invalid value.'));
552 552
 		}
553 553
 
554 554
 		$validity = new WP_Error();
@@ -566,9 +566,9 @@  discard block
 block discarded – undo
566 566
 		 * @param mixed                $value    Value of the setting.
567 567
 		 * @param WP_Customize_Setting $this     WP_Customize_Setting instance.
568 568
 		 */
569
-		$validity = apply_filters( "customize_validate_{$this->id}", $validity, $value, $this );
569
+		$validity = apply_filters("customize_validate_{$this->id}", $validity, $value, $this);
570 570
 
571
-		if ( is_wp_error( $validity ) && empty( $validity->errors ) ) {
571
+		if (is_wp_error($validity) && empty($validity->errors)) {
572 572
 			$validity = true;
573 573
 		}
574 574
 		return $validity;
@@ -583,12 +583,12 @@  discard block
 block discarded – undo
583 583
 	 * @param mixed $default Value to return if root does not exist.
584 584
 	 * @return mixed
585 585
 	 */
586
-	protected function get_root_value( $default = null ) {
586
+	protected function get_root_value($default = null) {
587 587
 		$id_base = $this->id_data['base'];
588
-		if ( 'option' === $this->type ) {
589
-			return get_option( $id_base, $default );
590
-		} else if ( 'theme_mod' ) {
591
-			return get_theme_mod( $id_base, $default );
588
+		if ('option' === $this->type) {
589
+			return get_option($id_base, $default);
590
+		} else if ('theme_mod') {
591
+			return get_theme_mod($id_base, $default);
592 592
 		} else {
593 593
 			/*
594 594
 			 * Any WP_Customize_Setting subclass implementing aggregate multidimensional
@@ -608,16 +608,16 @@  discard block
 block discarded – undo
608 608
 	 * @param mixed $value Value to set as root of multidimensional setting.
609 609
 	 * @return bool Whether the multidimensional root was updated successfully.
610 610
 	 */
611
-	protected function set_root_value( $value ) {
611
+	protected function set_root_value($value) {
612 612
 		$id_base = $this->id_data['base'];
613
-		if ( 'option' === $this->type ) {
613
+		if ('option' === $this->type) {
614 614
 			$autoload = true;
615
-			if ( isset( self::$aggregated_multidimensionals[ $this->type ][ $this->id_data['base'] ]['autoload'] ) ) {
616
-				$autoload = self::$aggregated_multidimensionals[ $this->type ][ $this->id_data['base'] ]['autoload'];
615
+			if (isset(self::$aggregated_multidimensionals[$this->type][$this->id_data['base']]['autoload'])) {
616
+				$autoload = self::$aggregated_multidimensionals[$this->type][$this->id_data['base']]['autoload'];
617 617
 			}
618
-			return update_option( $id_base, $value, $autoload );
619
-		} else if ( 'theme_mod' ) {
620
-			set_theme_mod( $id_base, $value );
618
+			return update_option($id_base, $value, $autoload);
619
+		} else if ('theme_mod') {
620
+			set_theme_mod($id_base, $value);
621 621
 			return true;
622 622
 		} else {
623 623
 			/*
@@ -637,16 +637,16 @@  discard block
 block discarded – undo
637 637
 	 * @param mixed $value The value to update.
638 638
 	 * @return bool The result of saving the value.
639 639
 	 */
640
-	protected function update( $value ) {
640
+	protected function update($value) {
641 641
 		$id_base = $this->id_data['base'];
642
-		if ( 'option' === $this->type || 'theme_mod' === $this->type ) {
643
-			if ( ! $this->is_multidimensional_aggregated ) {
644
-				return $this->set_root_value( $value );
642
+		if ('option' === $this->type || 'theme_mod' === $this->type) {
643
+			if ( ! $this->is_multidimensional_aggregated) {
644
+				return $this->set_root_value($value);
645 645
 			} else {
646
-				$root = self::$aggregated_multidimensionals[ $this->type ][ $id_base ]['root_value'];
647
-				$root = $this->multidimensional_replace( $root, $this->id_data['keys'], $value );
648
-				self::$aggregated_multidimensionals[ $this->type ][ $id_base ]['root_value'] = $root;
649
-				return $this->set_root_value( $root );
646
+				$root = self::$aggregated_multidimensionals[$this->type][$id_base]['root_value'];
647
+				$root = $this->multidimensional_replace($root, $this->id_data['keys'], $value);
648
+				self::$aggregated_multidimensionals[$this->type][$id_base]['root_value'] = $root;
649
+				return $this->set_root_value($root);
650 650
 			}
651 651
 		} else {
652 652
 			/**
@@ -660,9 +660,9 @@  discard block
 block discarded – undo
660 660
 			 * @param mixed                $value Value of the setting.
661 661
 			 * @param WP_Customize_Setting $this  WP_Customize_Setting instance.
662 662
 			 */
663
-			do_action( "customize_update_{$this->type}", $value, $this );
663
+			do_action("customize_update_{$this->type}", $value, $this);
664 664
 
665
-			return has_action( "customize_update_{$this->type}" );
665
+			return has_action("customize_update_{$this->type}");
666 666
 		}
667 667
 	}
668 668
 
@@ -673,7 +673,7 @@  discard block
 block discarded – undo
673 673
 	 * @deprecated 4.4.0 Deprecated in favor of update() method.
674 674
 	 */
675 675
 	protected function _update_theme_mod() {
676
-		_deprecated_function( __METHOD__, '4.4.0', __CLASS__ . '::update()' );
676
+		_deprecated_function(__METHOD__, '4.4.0', __CLASS__.'::update()');
677 677
 	}
678 678
 
679 679
 	/**
@@ -683,7 +683,7 @@  discard block
 block discarded – undo
683 683
 	 * @deprecated 4.4.0 Deprecated in favor of update() method.
684 684
 	 */
685 685
 	protected function _update_option() {
686
-		_deprecated_function( __METHOD__, '4.4.0', __CLASS__ . '::update()' );
686
+		_deprecated_function(__METHOD__, '4.4.0', __CLASS__.'::update()');
687 687
 	}
688 688
 
689 689
 	/**
@@ -695,19 +695,19 @@  discard block
 block discarded – undo
695 695
 	 */
696 696
 	public function value() {
697 697
 		$id_base = $this->id_data['base'];
698
-		$is_core_type = ( 'option' === $this->type || 'theme_mod' === $this->type );
698
+		$is_core_type = ('option' === $this->type || 'theme_mod' === $this->type);
699 699
 
700
-		if ( ! $is_core_type && ! $this->is_multidimensional_aggregated ) {
700
+		if ( ! $is_core_type && ! $this->is_multidimensional_aggregated) {
701 701
 
702 702
 			// Use post value if previewed and a post value is present.
703
-			if ( $this->is_previewed ) {
704
-				$value = $this->post_value( null );
705
-				if ( null !== $value ) {
703
+			if ($this->is_previewed) {
704
+				$value = $this->post_value(null);
705
+				if (null !== $value) {
706 706
 					return $value;
707 707
 				}
708 708
 			}
709 709
 
710
-			$value = $this->get_root_value( $this->default );
710
+			$value = $this->get_root_value($this->default);
711 711
 
712 712
 			/**
713 713
 			 * Filters a Customize setting value not handled as a theme_mod or option.
@@ -724,17 +724,17 @@  discard block
 block discarded – undo
724 724
 			 * @param mixed                $default The setting default value. Default empty.
725 725
 			 * @param WP_Customize_Setting $this    The setting instance.
726 726
 			 */
727
-			$value = apply_filters( "customize_value_{$id_base}", $value, $this );
728
-		} elseif ( $this->is_multidimensional_aggregated ) {
729
-			$root_value = self::$aggregated_multidimensionals[ $this->type ][ $id_base ]['root_value'];
730
-			$value = $this->multidimensional_get( $root_value, $this->id_data['keys'], $this->default );
727
+			$value = apply_filters("customize_value_{$id_base}", $value, $this);
728
+		} elseif ($this->is_multidimensional_aggregated) {
729
+			$root_value = self::$aggregated_multidimensionals[$this->type][$id_base]['root_value'];
730
+			$value = $this->multidimensional_get($root_value, $this->id_data['keys'], $this->default);
731 731
 
732 732
 			// Ensure that the post value is used if the setting is previewed, since preview filters aren't applying on cached $root_value.
733
-			if ( $this->is_previewed ) {
734
-				$value = $this->post_value( $value );
733
+			if ($this->is_previewed) {
734
+				$value = $this->post_value($value);
735 735
 			}
736 736
 		} else {
737
-			$value = $this->get_root_value( $this->default );
737
+			$value = $this->get_root_value($this->default);
738 738
 		}
739 739
 		return $value;
740 740
 	}
@@ -758,10 +758,10 @@  discard block
 block discarded – undo
758 758
 		 * @param mixed                $value The setting value.
759 759
 		 * @param WP_Customize_Setting $this  WP_Customize_Setting instance.
760 760
 		 */
761
-		$value = apply_filters( "customize_sanitize_js_{$this->id}", $this->value(), $this );
761
+		$value = apply_filters("customize_sanitize_js_{$this->id}", $this->value(), $this);
762 762
 
763
-		if ( is_string( $value ) )
764
-			return html_entity_decode( $value, ENT_QUOTES, 'UTF-8');
763
+		if (is_string($value))
764
+			return html_entity_decode($value, ENT_QUOTES, 'UTF-8');
765 765
 
766 766
 		return $value;
767 767
 	}
@@ -791,10 +791,10 @@  discard block
 block discarded – undo
791 791
 	 * @return bool False if theme doesn't support the setting or user can't change setting, otherwise true.
792 792
 	 */
793 793
 	final public function check_capabilities() {
794
-		if ( $this->capability && ! call_user_func_array( 'current_user_can', (array) $this->capability ) )
794
+		if ($this->capability && ! call_user_func_array('current_user_can', (array) $this->capability))
795 795
 			return false;
796 796
 
797
-		if ( $this->theme_supports && ! call_user_func_array( 'current_theme_supports', (array) $this->theme_supports ) )
797
+		if ($this->theme_supports && ! call_user_func_array('current_theme_supports', (array) $this->theme_supports))
798 798
 			return false;
799 799
 
800 800
 		return true;
@@ -810,37 +810,37 @@  discard block
 block discarded – undo
810 810
 	 * @param bool $create Default is false.
811 811
 	 * @return array|void Keys are 'root', 'node', and 'key'.
812 812
 	 */
813
-	final protected function multidimensional( &$root, $keys, $create = false ) {
814
-		if ( $create && empty( $root ) )
813
+	final protected function multidimensional(&$root, $keys, $create = false) {
814
+		if ($create && empty($root))
815 815
 			$root = array();
816 816
 
817
-		if ( ! isset( $root ) || empty( $keys ) )
817
+		if ( ! isset($root) || empty($keys))
818 818
 			return;
819 819
 
820
-		$last = array_pop( $keys );
820
+		$last = array_pop($keys);
821 821
 		$node = &$root;
822 822
 
823
-		foreach ( $keys as $key ) {
824
-			if ( $create && ! isset( $node[ $key ] ) )
825
-				$node[ $key ] = array();
823
+		foreach ($keys as $key) {
824
+			if ($create && ! isset($node[$key]))
825
+				$node[$key] = array();
826 826
 
827
-			if ( ! is_array( $node ) || ! isset( $node[ $key ] ) )
827
+			if ( ! is_array($node) || ! isset($node[$key]))
828 828
 				return;
829 829
 
830
-			$node = &$node[ $key ];
830
+			$node = &$node[$key];
831 831
 		}
832 832
 
833
-		if ( $create ) {
834
-			if ( ! is_array( $node ) ) {
833
+		if ($create) {
834
+			if ( ! is_array($node)) {
835 835
 				// account for an array overriding a string or object value
836 836
 				$node = array();
837 837
 			}
838
-			if ( ! isset( $node[ $last ] ) ) {
839
-				$node[ $last ] = array();
838
+			if ( ! isset($node[$last])) {
839
+				$node[$last] = array();
840 840
 			}
841 841
 		}
842 842
 
843
-		if ( ! isset( $node[ $last ] ) )
843
+		if ( ! isset($node[$last]))
844 844
 			return;
845 845
 
846 846
 		return array(
@@ -860,16 +860,16 @@  discard block
 block discarded – undo
860 860
 	 * @param mixed $value The value to update.
861 861
 	 * @return mixed
862 862
 	 */
863
-	final protected function multidimensional_replace( $root, $keys, $value ) {
864
-		if ( ! isset( $value ) )
863
+	final protected function multidimensional_replace($root, $keys, $value) {
864
+		if ( ! isset($value))
865 865
 			return $root;
866
-		elseif ( empty( $keys ) ) // If there are no keys, we're replacing the root.
866
+		elseif (empty($keys)) // If there are no keys, we're replacing the root.
867 867
 			return $value;
868 868
 
869
-		$result = $this->multidimensional( $root, $keys, true );
869
+		$result = $this->multidimensional($root, $keys, true);
870 870
 
871
-		if ( isset( $result ) )
872
-			$result['node'][ $result['key'] ] = $value;
871
+		if (isset($result))
872
+			$result['node'][$result['key']] = $value;
873 873
 
874 874
 		return $root;
875 875
 	}
@@ -884,12 +884,12 @@  discard block
 block discarded – undo
884 884
 	 * @param mixed $default A default value which is used as a fallback. Default is null.
885 885
 	 * @return mixed The requested value or the default value.
886 886
 	 */
887
-	final protected function multidimensional_get( $root, $keys, $default = null ) {
888
-		if ( empty( $keys ) ) // If there are no keys, test the root.
889
-			return isset( $root ) ? $root : $default;
887
+	final protected function multidimensional_get($root, $keys, $default = null) {
888
+		if (empty($keys)) // If there are no keys, test the root.
889
+			return isset($root) ? $root : $default;
890 890
 
891
-		$result = $this->multidimensional( $root, $keys );
892
-		return isset( $result ) ? $result['node'][ $result['key'] ] : $default;
891
+		$result = $this->multidimensional($root, $keys);
892
+		return isset($result) ? $result['node'][$result['key']] : $default;
893 893
 	}
894 894
 
895 895
 	/**
@@ -901,23 +901,23 @@  discard block
 block discarded – undo
901 901
 	 * @param $keys
902 902
 	 * @return bool True if value is set, false if not.
903 903
 	 */
904
-	final protected function multidimensional_isset( $root, $keys ) {
905
-		$result = $this->multidimensional_get( $root, $keys );
906
-		return isset( $result );
904
+	final protected function multidimensional_isset($root, $keys) {
905
+		$result = $this->multidimensional_get($root, $keys);
906
+		return isset($result);
907 907
 	}
908 908
 }
909 909
 
910 910
 /** WP_Customize_Filter_Setting class */
911
-require_once( ABSPATH . WPINC . '/customize/class-wp-customize-filter-setting.php' );
911
+require_once(ABSPATH.WPINC.'/customize/class-wp-customize-filter-setting.php');
912 912
 
913 913
 /** WP_Customize_Header_Image_Setting class */
914
-require_once( ABSPATH . WPINC . '/customize/class-wp-customize-header-image-setting.php' );
914
+require_once(ABSPATH.WPINC.'/customize/class-wp-customize-header-image-setting.php');
915 915
 
916 916
 /** WP_Customize_Background_Image_Setting class */
917
-require_once( ABSPATH . WPINC . '/customize/class-wp-customize-background-image-setting.php' );
917
+require_once(ABSPATH.WPINC.'/customize/class-wp-customize-background-image-setting.php');
918 918
 
919 919
 /** WP_Customize_Nav_Menu_Item_Setting class */
920
-require_once( ABSPATH . WPINC . '/customize/class-wp-customize-nav-menu-item-setting.php' );
920
+require_once(ABSPATH.WPINC.'/customize/class-wp-customize-nav-menu-item-setting.php');
921 921
 
922 922
 /** WP_Customize_Nav_Menu_Setting class */
923
-require_once( ABSPATH . WPINC . '/customize/class-wp-customize-nav-menu-setting.php' );
923
+require_once(ABSPATH.WPINC.'/customize/class-wp-customize-nav-menu-setting.php');
Please login to merge, or discard this patch.
src/wp-includes/formatting.php 4 patches
Indentation   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -805,7 +805,7 @@  discard block
 block discarded – undo
805 805
 		.     '\\['                          // Opening bracket
806 806
 		.     "($tagregexp)"                 // 2: Shortcode name
807 807
 		.     '(?![\\w-])'                   // Not followed by word character or hyphen
808
-		                                     // Unroll the loop: Inside the opening shortcode tag
808
+											 // Unroll the loop: Inside the opening shortcode tag
809 809
 		.     '[^\\]\\/]*'                   // Not a closing bracket or forward slash
810 810
 		.     '(?:'
811 811
 		.         '\\/(?!\\])'               // A forward slash not followed by a closing bracket
@@ -2613,7 +2613,7 @@  discard block
 block discarded – undo
2613 2613
 				)
2614 2614
 				(\)?)                                                  # 3: Trailing closing parenthesis (for parethesis balancing post processing)
2615 2615
 			~xS'; // The regex is a non-anchored pattern and does not have a single fixed starting character.
2616
-			      // Tell PCRE to spend more time optimizing since, when used on a page load, it will probably be used several times.
2616
+				  // Tell PCRE to spend more time optimizing since, when used on a page load, it will probably be used several times.
2617 2617
 
2618 2618
 			$ret = preg_replace_callback( $url_clickable, '_make_url_clickable_cb', $ret );
2619 2619
 
@@ -2717,7 +2717,7 @@  discard block
 block discarded – undo
2717 2717
 	$rel  = 'nofollow';
2718 2718
 
2719 2719
 	if ( preg_match( '%href=["\'](' . preg_quote( set_url_scheme( home_url(), 'http' ) ) . ')%i', $text ) ||
2720
-	     preg_match( '%href=["\'](' . preg_quote( set_url_scheme( home_url(), 'https' ) ) . ')%i', $text )
2720
+		 preg_match( '%href=["\'](' . preg_quote( set_url_scheme( home_url(), 'https' ) ) . ')%i', $text )
2721 2721
 	) {
2722 2722
 		return "<a $text>";
2723 2723
 	}
@@ -3891,7 +3891,7 @@  discard block
 block discarded – undo
3891 3891
 	 * @since 2.0.6
3892 3892
 	 *
3893 3893
 	 * @param string $safe_text The text after it has been escaped.
3894
- 	 * @param string $text      The text prior to being escaped.
3894
+	 * @param string $text      The text prior to being escaped.
3895 3895
 	 */
3896 3896
 	return apply_filters( 'js_escape', $safe_text, $text );
3897 3897
 }
@@ -3916,7 +3916,7 @@  discard block
 block discarded – undo
3916 3916
 	 * @since 2.8.0
3917 3917
 	 *
3918 3918
 	 * @param string $safe_text The text after it has been escaped.
3919
- 	 * @param string $text      The text prior to being escaped.
3919
+	 * @param string $text      The text prior to being escaped.
3920 3920
 	 */
3921 3921
 	return apply_filters( 'esc_html', $safe_text, $text );
3922 3922
 }
@@ -3941,7 +3941,7 @@  discard block
 block discarded – undo
3941 3941
 	 * @since 2.0.6
3942 3942
 	 *
3943 3943
 	 * @param string $safe_text The text after it has been escaped.
3944
- 	 * @param string $text      The text prior to being escaped.
3944
+	 * @param string $text      The text prior to being escaped.
3945 3945
 	 */
3946 3946
 	return apply_filters( 'attribute_escape', $safe_text, $text );
3947 3947
 }
@@ -3962,7 +3962,7 @@  discard block
 block discarded – undo
3962 3962
 	 * @since 3.1.0
3963 3963
 	 *
3964 3964
 	 * @param string $safe_text The text after it has been escaped.
3965
- 	 * @param string $text      The text prior to being escaped.
3965
+	 * @param string $text      The text prior to being escaped.
3966 3966
 	 */
3967 3967
 	return apply_filters( 'esc_textarea', $safe_text, $text );
3968 3968
 }
@@ -3983,7 +3983,7 @@  discard block
 block discarded – undo
3983 3983
 	 * @since 2.8.0
3984 3984
 	 *
3985 3985
 	 * @param string $safe_tag The tag name after it has been escaped.
3986
- 	 * @param string $tag_name The text before it was escaped.
3986
+	 * @param string $tag_name The text before it was escaped.
3987 3987
 	 */
3988 3988
 	return apply_filters( 'tag_escape', $safe_tag, $tag_name );
3989 3989
 }
Please login to merge, or discard this patch.
Doc Comments   +3 added lines, -4 removed lines patch added patch discarded remove patch
@@ -879,7 +879,7 @@  discard block
 block discarded – undo
879 879
  * @staticvar string $_charset
880 880
  *
881 881
  * @param string     $string         The text which is to be encoded.
882
- * @param int|string $quote_style    Optional. Converts double quotes if set to ENT_COMPAT,
882
+ * @param integer $quote_style    Optional. Converts double quotes if set to ENT_COMPAT,
883 883
  *                                   both single and double if set to ENT_QUOTES or none if set to ENT_NOQUOTES.
884 884
  *                                   Also compatible with old values; converting single quotes if set to 'single',
885 885
  *                                   double if set to 'double' or both if otherwise set.
@@ -952,7 +952,7 @@  discard block
 block discarded – undo
952 952
  * @since 2.8.0
953 953
  *
954 954
  * @param string     $string The text which is to be decoded.
955
- * @param string|int $quote_style Optional. Converts double quotes if set to ENT_COMPAT,
955
+ * @param integer $quote_style Optional. Converts double quotes if set to ENT_COMPAT,
956 956
  *                                both single and double if set to ENT_QUOTES or
957 957
  *                                none if set to ENT_NOQUOTES.
958 958
  *                                Also compatible with old _wp_specialchars() values;
@@ -3692,7 +3692,7 @@  discard block
 block discarded – undo
3692 3692
  * @since 2.8.1
3693 3693
  * @access private
3694 3694
  *
3695
- * @param string|array $search  The value being searched for, otherwise known as the needle.
3695
+ * @param string[] $search  The value being searched for, otherwise known as the needle.
3696 3696
  *                              An array may be used to designate multiple needles.
3697 3697
  * @param string       $subject The string being searched and replaced on, otherwise known as the haystack.
3698 3698
  * @return string The string with the replaced svalues.
@@ -4358,7 +4358,6 @@  discard block
 block discarded – undo
4358 4358
  * @link https://secure.php.net/sprintf
4359 4359
  *
4360 4360
  * @param string $pattern   The string which formatted args are inserted.
4361
- * @param mixed  $args ,... Arguments to be formatted into the $pattern string.
4362 4361
  * @return string The formatted string.
4363 4362
  */
4364 4363
 function wp_sprintf( $pattern ) {
Please login to merge, or discard this patch.
Braces   +222 added lines, -139 removed lines patch added patch discarded remove patch
@@ -429,8 +429,9 @@  discard block
 block discarded – undo
429 429
 function wpautop( $pee, $br = true ) {
430 430
 	$pre_tags = array();
431 431
 
432
-	if ( trim($pee) === '' )
433
-		return '';
432
+	if ( trim($pee) === '' ) {
433
+			return '';
434
+	}
434 435
 
435 436
 	// Just to make things a little easier, pad the end.
436 437
 	$pee = $pee . "\n";
@@ -565,8 +566,9 @@  discard block
 block discarded – undo
565 566
 	$pee = preg_replace( "|\n</p>$|", '</p>', $pee );
566 567
 
567 568
 	// Replace placeholder <pre> tags with their original content.
568
-	if ( !empty($pre_tags) )
569
-		$pee = str_replace(array_keys($pre_tags), array_values($pre_tags), $pee);
569
+	if ( !empty($pre_tags) ) {
570
+			$pee = str_replace(array_keys($pre_tags), array_values($pre_tags), $pee);
571
+	}
570 572
 
571 573
 	// Restore newlines in all elements.
572 574
 	if ( false !== strpos( $pee, '<!-- wpnl -->' ) ) {
@@ -850,16 +852,38 @@  discard block
 block discarded – undo
850 852
 	reset_mbstring_encoding();
851 853
 	for ($i=0; $i < $length; $i++) {
852 854
 		$c = ord($str[$i]);
853
-		if ($c < 0x80) $n = 0; // 0bbbbbbb
854
-		elseif (($c & 0xE0) == 0xC0) $n=1; // 110bbbbb
855
-		elseif (($c & 0xF0) == 0xE0) $n=2; // 1110bbbb
856
-		elseif (($c & 0xF8) == 0xF0) $n=3; // 11110bbb
857
-		elseif (($c & 0xFC) == 0xF8) $n=4; // 111110bb
858
-		elseif (($c & 0xFE) == 0xFC) $n=5; // 1111110b
859
-		else return false; // Does not match any model
855
+		if ($c < 0x80) {
856
+			$n = 0;
857
+		}
858
+		// 0bbbbbbb
859
+		elseif (($c & 0xE0) == 0xC0) {
860
+			$n=1;
861
+		}
862
+		// 110bbbbb
863
+		elseif (($c & 0xF0) == 0xE0) {
864
+			$n=2;
865
+		}
866
+		// 1110bbbb
867
+		elseif (($c & 0xF8) == 0xF0) {
868
+			$n=3;
869
+		}
870
+		// 11110bbb
871
+		elseif (($c & 0xFC) == 0xF8) {
872
+			$n=4;
873
+		}
874
+		// 111110bb
875
+		elseif (($c & 0xFE) == 0xFC) {
876
+			$n=5;
877
+		}
878
+		// 1111110b
879
+		else {
880
+			return false;
881
+		}
882
+		// Does not match any model
860 883
 		for ($j=0; $j<$n; $j++) { // n bytes matching 10bbbbbb follow ?
861
-			if ((++$i == $length) || ((ord($str[$i]) & 0xC0) != 0x80))
862
-				return false;
884
+			if ((++$i == $length) || ((ord($str[$i]) & 0xC0) != 0x80)) {
885
+							return false;
886
+			}
863 887
 		}
864 888
 	}
865 889
 	return true;
@@ -891,18 +915,21 @@  discard block
 block discarded – undo
891 915
 function _wp_specialchars( $string, $quote_style = ENT_NOQUOTES, $charset = false, $double_encode = false ) {
892 916
 	$string = (string) $string;
893 917
 
894
-	if ( 0 === strlen( $string ) )
895
-		return '';
918
+	if ( 0 === strlen( $string ) ) {
919
+			return '';
920
+	}
896 921
 
897 922
 	// Don't bother if there are no specialchars - saves some processing
898
-	if ( ! preg_match( '/[&<>"\']/', $string ) )
899
-		return $string;
923
+	if ( ! preg_match( '/[&<>"\']/', $string ) ) {
924
+			return $string;
925
+	}
900 926
 
901 927
 	// Account for the previous behaviour of the function when the $quote_style is not an accepted value
902
-	if ( empty( $quote_style ) )
903
-		$quote_style = ENT_NOQUOTES;
904
-	elseif ( ! in_array( $quote_style, array( 0, 2, 3, 'single', 'double' ), true ) )
905
-		$quote_style = ENT_QUOTES;
928
+	if ( empty( $quote_style ) ) {
929
+			$quote_style = ENT_NOQUOTES;
930
+	} elseif ( ! in_array( $quote_style, array( 0, 2, 3, 'single', 'double' ), true ) ) {
931
+			$quote_style = ENT_QUOTES;
932
+	}
906 933
 
907 934
 	// Store the site charset as a static to avoid multiple calls to wp_load_alloptions()
908 935
 	if ( ! $charset ) {
@@ -914,8 +941,9 @@  discard block
 block discarded – undo
914 941
 		$charset = $_charset;
915 942
 	}
916 943
 
917
-	if ( in_array( $charset, array( 'utf8', 'utf-8', 'UTF8' ) ) )
918
-		$charset = 'UTF-8';
944
+	if ( in_array( $charset, array( 'utf8', 'utf-8', 'UTF8' ) ) ) {
945
+			$charset = 'UTF-8';
946
+	}
919 947
 
920 948
 	$_quote_style = $quote_style;
921 949
 
@@ -935,8 +963,9 @@  discard block
 block discarded – undo
935 963
 	$string = @htmlspecialchars( $string, $quote_style, $charset, $double_encode );
936 964
 
937 965
 	// Back-compat.
938
-	if ( 'single' === $_quote_style )
939
-		$string = str_replace( "'", '&#039;', $string );
966
+	if ( 'single' === $_quote_style ) {
967
+			$string = str_replace( "'", '&#039;', $string );
968
+	}
940 969
 
941 970
 	return $string;
942 971
 }
@@ -1084,8 +1113,9 @@  discard block
 block discarded – undo
1084 1113
 		$value = ord( $utf8_string[ $i ] );
1085 1114
 
1086 1115
 		if ( $value < 128 ) {
1087
-			if ( $length && ( $unicode_length >= $length ) )
1088
-				break;
1116
+			if ( $length && ( $unicode_length >= $length ) ) {
1117
+							break;
1118
+			}
1089 1119
 			$unicode .= chr($value);
1090 1120
 			$unicode_length++;
1091 1121
 		} else {
@@ -1101,8 +1131,9 @@  discard block
 block discarded – undo
1101 1131
 
1102 1132
 			$values[] = $value;
1103 1133
 
1104
-			if ( $length && ( $unicode_length + ($num_octets * 3) ) > $length )
1105
-				break;
1134
+			if ( $length && ( $unicode_length + ($num_octets * 3) ) > $length ) {
1135
+							break;
1136
+			}
1106 1137
 			if ( count( $values ) == $num_octets ) {
1107 1138
 				for ( $j = 0; $j < $num_octets; $j++ ) {
1108 1139
 					$unicode .= '%' . dechex( $values[ $j ] );
@@ -1497,8 +1528,9 @@  discard block
 block discarded – undo
1497 1528
  * @return string Filtered string with replaced "nice" characters.
1498 1529
  */
1499 1530
 function remove_accents( $string ) {
1500
-	if ( !preg_match('/[\x80-\xff]/', $string) )
1501
-		return $string;
1531
+	if ( !preg_match('/[\x80-\xff]/', $string) ) {
1532
+			return $string;
1533
+	}
1502 1534
 
1503 1535
 	if (seems_utf8($string)) {
1504 1536
 		$chars = array(
@@ -1804,8 +1836,9 @@  discard block
 block discarded – undo
1804 1836
 					break;
1805 1837
 				}
1806 1838
 			}
1807
-			if ( !$allowed )
1808
-				$filename .= '_';
1839
+			if ( !$allowed ) {
1840
+							$filename .= '_';
1841
+			}
1809 1842
 		}
1810 1843
 	}
1811 1844
 	$filename .= '.' . $extension;
@@ -1836,8 +1869,9 @@  discard block
 block discarded – undo
1836 1869
 	$username = preg_replace( '/&.+?;/', '', $username ); // Kill entities
1837 1870
 
1838 1871
 	// If strict, reduce to ASCII for max portability.
1839
-	if ( $strict )
1840
-		$username = preg_replace( '|[^a-z0-9 _.\-@]|i', '', $username );
1872
+	if ( $strict ) {
1873
+			$username = preg_replace( '|[^a-z0-9 _.\-@]|i', '', $username );
1874
+	}
1841 1875
 
1842 1876
 	$username = trim( $username );
1843 1877
 	// Consolidate contiguous whitespace
@@ -1898,8 +1932,9 @@  discard block
 block discarded – undo
1898 1932
 function sanitize_title( $title, $fallback_title = '', $context = 'save' ) {
1899 1933
 	$raw_title = $title;
1900 1934
 
1901
-	if ( 'save' == $context )
1902
-		$title = remove_accents($title);
1935
+	if ( 'save' == $context ) {
1936
+			$title = remove_accents($title);
1937
+	}
1903 1938
 
1904 1939
 	/**
1905 1940
 	 * Filters a sanitized title string.
@@ -1912,8 +1947,9 @@  discard block
 block discarded – undo
1912 1947
 	 */
1913 1948
 	$title = apply_filters( 'sanitize_title', $title, $raw_title, $context );
1914 1949
 
1915
-	if ( '' === $title || false === $title )
1916
-		$title = $fallback_title;
1950
+	if ( '' === $title || false === $title ) {
1951
+			$title = $fallback_title;
1952
+	}
1917 1953
 
1918 1954
 	return $title;
1919 1955
 }
@@ -2228,8 +2264,9 @@  discard block
 block discarded – undo
2228 2264
 			elseif ( substr( $regex[2], -1 ) == '/' ) {
2229 2265
 				// ...but it isn't a known single-entity self-closing tag, then don't let it be treated as such and
2230 2266
 				// immediately close it with a closing tag (the tag will encapsulate no text as a result)
2231
-				if ( ! in_array( $tag, $single_tags ) )
2232
-					$regex[2] = trim( substr( $regex[2], 0, -1 ) ) . "></$tag";
2267
+				if ( ! in_array( $tag, $single_tags ) ) {
2268
+									$regex[2] = trim( substr( $regex[2], 0, -1 ) ) . "></$tag";
2269
+				}
2233 2270
 			}
2234 2271
 			// ElseIf it's a known single-entity tag but it doesn't close itself, do so
2235 2272
 			elseif ( in_array($tag, $single_tags) ) {
@@ -2247,8 +2284,9 @@  discard block
 block discarded – undo
2247 2284
 
2248 2285
 			// Attributes
2249 2286
 			$attributes = $regex[2];
2250
-			if ( ! empty( $attributes ) && $attributes[0] != '>' )
2251
-				$attributes = ' ' . $attributes;
2287
+			if ( ! empty( $attributes ) && $attributes[0] != '>' ) {
2288
+							$attributes = ' ' . $attributes;
2289
+			}
2252 2290
 
2253 2291
 			$tag = '<' . $tag . $attributes . '>';
2254 2292
 			//If already queuing a close tag, then put this tag on, too
@@ -2268,8 +2306,10 @@  discard block
 block discarded – undo
2268 2306
 	$newtext .= $text;
2269 2307
 
2270 2308
 	// Empty Stack
2271
-	while( $x = array_pop($tagstack) )
2272
-		$newtext .= '</' . $x . '>'; // Add remaining tags to close
2309
+	while( $x = array_pop($tagstack) ) {
2310
+			$newtext .= '</' . $x . '>';
2311
+	}
2312
+	// Add remaining tags to close
2273 2313
 
2274 2314
 	// WP fix for the bug with HTML comments
2275 2315
 	$newtext = str_replace("< !--","<!--",$newtext);
@@ -2303,8 +2343,9 @@  discard block
 block discarded – undo
2303 2343
 	 * @param string $content The text, prior to formatting for editing.
2304 2344
 	 */
2305 2345
 	$content = apply_filters( 'format_to_edit', $content );
2306
-	if ( ! $rich_text )
2307
-		$content = esc_textarea( $content );
2346
+	if ( ! $rich_text ) {
2347
+			$content = esc_textarea( $content );
2348
+	}
2308 2349
 	return $content;
2309 2350
 }
2310 2351
 
@@ -2338,8 +2379,9 @@  discard block
 block discarded – undo
2338 2379
  * @return string String with backslashes inserted.
2339 2380
  */
2340 2381
 function backslashit( $string ) {
2341
-	if ( isset( $string[0] ) && $string[0] >= '0' && $string[0] <= '9' )
2342
-		$string = '\\\\' . $string;
2382
+	if ( isset( $string[0] ) && $string[0] >= '0' && $string[0] <= '9' ) {
2383
+			$string = '\\\\' . $string;
2384
+	}
2343 2385
 	return addcslashes( $string, 'A..Za..z' );
2344 2386
 }
2345 2387
 
@@ -2388,8 +2430,9 @@  discard block
 block discarded – undo
2388 2430
  * @return string Returns a string escaped with slashes.
2389 2431
  */
2390 2432
 function addslashes_gpc($gpc) {
2391
-	if ( get_magic_quotes_gpc() )
2392
-		$gpc = stripslashes($gpc);
2433
+	if ( get_magic_quotes_gpc() ) {
2434
+			$gpc = stripslashes($gpc);
2435
+	}
2393 2436
 
2394 2437
 	return wp_slash($gpc);
2395 2438
 }
@@ -2509,8 +2552,9 @@  discard block
 block discarded – undo
2509 2552
 	}
2510 2553
 
2511 2554
 	$url = esc_url($url);
2512
-	if ( empty($url) )
2513
-		return $matches[0];
2555
+	if ( empty($url) ) {
2556
+			return $matches[0];
2557
+	}
2514 2558
 
2515 2559
 	return $matches[1] . "<a href=\"$url\" rel=\"nofollow\">$url</a>" . $suffix;
2516 2560
 }
@@ -2538,8 +2582,9 @@  discard block
 block discarded – undo
2538 2582
 	}
2539 2583
 
2540 2584
 	$dest = esc_url($dest);
2541
-	if ( empty($dest) )
2542
-		return $matches[0];
2585
+	if ( empty($dest) ) {
2586
+			return $matches[0];
2587
+	}
2543 2588
 
2544 2589
 	return $matches[1] . "<a href=\"$dest\" rel=\"nofollow\">$dest</a>$ret";
2545 2590
 }
@@ -2577,10 +2622,11 @@  discard block
 block discarded – undo
2577 2622
 	$nested_code_pre = 0; // Keep track of how many levels link is nested inside <pre> or <code>
2578 2623
 	foreach ( $textarr as $piece ) {
2579 2624
 
2580
-		if ( preg_match( '|^<code[\s>]|i', $piece ) || preg_match( '|^<pre[\s>]|i', $piece ) || preg_match( '|^<script[\s>]|i', $piece ) || preg_match( '|^<style[\s>]|i', $piece ) )
2581
-			$nested_code_pre++;
2582
-		elseif ( $nested_code_pre && ( '</code>' === strtolower( $piece ) || '</pre>' === strtolower( $piece ) || '</script>' === strtolower( $piece ) || '</style>' === strtolower( $piece ) ) )
2583
-			$nested_code_pre--;
2625
+		if ( preg_match( '|^<code[\s>]|i', $piece ) || preg_match( '|^<pre[\s>]|i', $piece ) || preg_match( '|^<script[\s>]|i', $piece ) || preg_match( '|^<style[\s>]|i', $piece ) ) {
2626
+					$nested_code_pre++;
2627
+		} elseif ( $nested_code_pre && ( '</code>' === strtolower( $piece ) || '</pre>' === strtolower( $piece ) || '</script>' === strtolower( $piece ) || '</style>' === strtolower( $piece ) ) ) {
2628
+					$nested_code_pre--;
2629
+		}
2584 2630
 
2585 2631
 		if ( $nested_code_pre || empty( $piece ) || ( $piece[0] === '<' && ! preg_match( '|^<\s*[\w]{1,20}+://|', $piece ) ) ) {
2586 2632
 			$r .= $piece;
@@ -2757,8 +2803,9 @@  discard block
 block discarded – undo
2757 2803
 function translate_smiley( $matches ) {
2758 2804
 	global $wpsmiliestrans;
2759 2805
 
2760
-	if ( count( $matches ) == 0 )
2761
-		return '';
2806
+	if ( count( $matches ) == 0 ) {
2807
+			return '';
2808
+	}
2762 2809
 
2763 2810
 	$smiley = trim( reset( $matches ) );
2764 2811
 	$img = $wpsmiliestrans[ $smiley ];
@@ -2850,8 +2897,9 @@  discard block
 block discarded – undo
2850 2897
  * @return string|bool Either false or the valid email address.
2851 2898
  */
2852 2899
 function is_email( $email, $deprecated = false ) {
2853
-	if ( ! empty( $deprecated ) )
2854
-		_deprecated_argument( __FUNCTION__, '3.0.0' );
2900
+	if ( ! empty( $deprecated ) ) {
2901
+			_deprecated_argument( __FUNCTION__, '3.0.0' );
2902
+	}
2855 2903
 
2856 2904
 	// Test for the minimum length the email can be
2857 2905
 	if ( strlen( $email ) < 3 ) {
@@ -3015,13 +3063,15 @@  discard block
 block discarded – undo
3015 3063
 	$tz = get_option( 'timezone_string' );
3016 3064
 	if ( $tz ) {
3017 3065
 		$datetime = date_create( $string, new DateTimeZone( 'UTC' ) );
3018
-		if ( ! $datetime )
3019
-			return date( $format, 0 );
3066
+		if ( ! $datetime ) {
3067
+					return date( $format, 0 );
3068
+		}
3020 3069
 		$datetime->setTimezone( new DateTimeZone( $tz ) );
3021 3070
 		$string_localtime = $datetime->format( $format );
3022 3071
 	} else {
3023
-		if ( ! preg_match('#([0-9]{1,4})-([0-9]{1,2})-([0-9]{1,2}) ([0-9]{1,2}):([0-9]{1,2}):([0-9]{1,2})#', $string, $matches) )
3024
-			return date( $format, 0 );
3072
+		if ( ! preg_match('#([0-9]{1,4})-([0-9]{1,2})-([0-9]{1,2}) ([0-9]{1,2}):([0-9]{1,2}):([0-9]{1,2})#', $string, $matches) ) {
3073
+					return date( $format, 0 );
3074
+		}
3025 3075
 		$string_time = gmmktime( $matches[4], $matches[5], $matches[6], $matches[2], $matches[3], $matches[1] );
3026 3076
 		$string_localtime = gmdate( $format, $string_time + get_option( 'gmt_offset' ) * HOUR_IN_SECONDS );
3027 3077
 	}
@@ -3204,34 +3254,40 @@  discard block
 block discarded – undo
3204 3254
 
3205 3255
 	if ( $diff < HOUR_IN_SECONDS ) {
3206 3256
 		$mins = round( $diff / MINUTE_IN_SECONDS );
3207
-		if ( $mins <= 1 )
3208
-			$mins = 1;
3257
+		if ( $mins <= 1 ) {
3258
+					$mins = 1;
3259
+		}
3209 3260
 		/* translators: min=minute */
3210 3261
 		$since = sprintf( _n( '%s min', '%s mins', $mins ), $mins );
3211 3262
 	} elseif ( $diff < DAY_IN_SECONDS && $diff >= HOUR_IN_SECONDS ) {
3212 3263
 		$hours = round( $diff / HOUR_IN_SECONDS );
3213
-		if ( $hours <= 1 )
3214
-			$hours = 1;
3264
+		if ( $hours <= 1 ) {
3265
+					$hours = 1;
3266
+		}
3215 3267
 		$since = sprintf( _n( '%s hour', '%s hours', $hours ), $hours );
3216 3268
 	} elseif ( $diff < WEEK_IN_SECONDS && $diff >= DAY_IN_SECONDS ) {
3217 3269
 		$days = round( $diff / DAY_IN_SECONDS );
3218
-		if ( $days <= 1 )
3219
-			$days = 1;
3270
+		if ( $days <= 1 ) {
3271
+					$days = 1;
3272
+		}
3220 3273
 		$since = sprintf( _n( '%s day', '%s days', $days ), $days );
3221 3274
 	} elseif ( $diff < MONTH_IN_SECONDS && $diff >= WEEK_IN_SECONDS ) {
3222 3275
 		$weeks = round( $diff / WEEK_IN_SECONDS );
3223
-		if ( $weeks <= 1 )
3224
-			$weeks = 1;
3276
+		if ( $weeks <= 1 ) {
3277
+					$weeks = 1;
3278
+		}
3225 3279
 		$since = sprintf( _n( '%s week', '%s weeks', $weeks ), $weeks );
3226 3280
 	} elseif ( $diff < YEAR_IN_SECONDS && $diff >= MONTH_IN_SECONDS ) {
3227 3281
 		$months = round( $diff / MONTH_IN_SECONDS );
3228
-		if ( $months <= 1 )
3229
-			$months = 1;
3282
+		if ( $months <= 1 ) {
3283
+					$months = 1;
3284
+		}
3230 3285
 		$since = sprintf( _n( '%s month', '%s months', $months ), $months );
3231 3286
 	} elseif ( $diff >= YEAR_IN_SECONDS ) {
3232 3287
 		$years = round( $diff / YEAR_IN_SECONDS );
3233
-		if ( $years <= 1 )
3234
-			$years = 1;
3288
+		if ( $years <= 1 ) {
3289
+					$years = 1;
3290
+		}
3235 3291
 		$since = sprintf( _n( '%s year', '%s years', $years ), $years );
3236 3292
 	}
3237 3293
 
@@ -3382,8 +3438,9 @@  discard block
 block discarded – undo
3382 3438
 	 * @param string $text           The text prior to entity conversion.
3383 3439
 	 */
3384 3440
 	$filtered = apply_filters( 'pre_ent2ncr', null, $text );
3385
-	if ( null !== $filtered )
3386
-		return $filtered;
3441
+	if ( null !== $filtered ) {
3442
+			return $filtered;
3443
+	}
3387 3444
 
3388 3445
 	$to_ncr = array(
3389 3446
 		'&quot;' => '&#34;',
@@ -3745,8 +3802,9 @@  discard block
 block discarded – undo
3745 3802
 function esc_url( $url, $protocols = null, $_context = 'display' ) {
3746 3803
 	$original_url = $url;
3747 3804
 
3748
-	if ( '' == $url )
3749
-		return $url;
3805
+	if ( '' == $url ) {
3806
+			return $url;
3807
+	}
3750 3808
 
3751 3809
 	$url = str_replace( ' ', '%20', $url );
3752 3810
 	$url = preg_replace('|[^a-z0-9-~+_.?#=!&;,/:%@$\|*\'()\[\]\\x80-\\xff]|i', '', $url);
@@ -3766,8 +3824,9 @@  discard block
 block discarded – undo
3766 3824
 	 * link starting with /, # or ? or a php file).
3767 3825
 	 */
3768 3826
 	if ( strpos($url, ':') === false && ! in_array( $url[0], array( '/', '#', '?' ) ) &&
3769
-		! preg_match('/^[a-z0-9-]+?\.php/i', $url) )
3770
-		$url = 'http://' . $url;
3827
+		! preg_match('/^[a-z0-9-]+?\.php/i', $url) ) {
3828
+			$url = 'http://' . $url;
3829
+	}
3771 3830
 
3772 3831
 	// Replace ampersands and single quotes only when displaying.
3773 3832
 	if ( 'display' == $_context ) {
@@ -3816,11 +3875,13 @@  discard block
 block discarded – undo
3816 3875
 	if ( '/' === $url[0] ) {
3817 3876
 		$good_protocol_url = $url;
3818 3877
 	} else {
3819
-		if ( ! is_array( $protocols ) )
3820
-			$protocols = wp_allowed_protocols();
3878
+		if ( ! is_array( $protocols ) ) {
3879
+					$protocols = wp_allowed_protocols();
3880
+		}
3821 3881
 		$good_protocol_url = wp_kses_bad_protocol( $url, $protocols );
3822
-		if ( strtolower( $good_protocol_url ) != strtolower( $url ) )
3823
-			return '';
3882
+		if ( strtolower( $good_protocol_url ) != strtolower( $url ) ) {
3883
+					return '';
3884
+		}
3824 3885
 	}
3825 3886
 
3826 3887
 	/**
@@ -4066,17 +4127,20 @@  discard block
 block discarded – undo
4066 4127
 		case 'posts_per_page':
4067 4128
 		case 'posts_per_rss':
4068 4129
 			$value = (int) $value;
4069
-			if ( empty($value) )
4070
-				$value = 1;
4071
-			if ( $value < -1 )
4072
-				$value = abs($value);
4130
+			if ( empty($value) ) {
4131
+							$value = 1;
4132
+			}
4133
+			if ( $value < -1 ) {
4134
+							$value = abs($value);
4135
+			}
4073 4136
 			break;
4074 4137
 
4075 4138
 		case 'default_ping_status':
4076 4139
 		case 'default_comment_status':
4077 4140
 			// Options that if not there have 0 value but need to be something like "closed"
4078
-			if ( $value == '0' || $value == '')
4079
-				$value = 'closed';
4141
+			if ( $value == '0' || $value == '') {
4142
+							$value = 'closed';
4143
+			}
4080 4144
 			break;
4081 4145
 
4082 4146
 		case 'blogdescription':
@@ -4099,10 +4163,11 @@  discard block
 block discarded – undo
4099 4163
 
4100 4164
 		case 'blog_public':
4101 4165
 			// This is the value if the settings checkbox is not checked on POST. Don't rely on this.
4102
-			if ( null === $value )
4103
-				$value = 1;
4104
-			else
4105
-				$value = intval( $value );
4166
+			if ( null === $value ) {
4167
+							$value = 1;
4168
+			} else {
4169
+							$value = intval( $value );
4170
+			}
4106 4171
 			break;
4107 4172
 
4108 4173
 		case 'date_format':
@@ -4172,13 +4237,15 @@  discard block
 block discarded – undo
4172 4237
 			if ( is_wp_error( $value ) ) {
4173 4238
 				$error = $value->get_error_message();
4174 4239
 			} else {
4175
-				if ( ! is_array( $value ) )
4176
-					$value = explode( ' ', $value );
4240
+				if ( ! is_array( $value ) ) {
4241
+									$value = explode( ' ', $value );
4242
+				}
4177 4243
 
4178 4244
 				$value = array_values( array_filter( array_map( 'trim', $value ) ) );
4179 4245
 
4180
-				if ( ! $value )
4181
-					$value = '';
4246
+				if ( ! $value ) {
4247
+									$value = '';
4248
+				}
4182 4249
 			}
4183 4250
 			break;
4184 4251
 
@@ -4188,8 +4255,9 @@  discard block
 block discarded – undo
4188 4255
 			if ( is_wp_error( $value ) ) {
4189 4256
 				$error = $value->get_error_message();
4190 4257
 			} else {
4191
-				if ( ! is_array( $value ) )
4192
-					$value = explode( "\n", $value );
4258
+				if ( ! is_array( $value ) ) {
4259
+									$value = explode( "\n", $value );
4260
+				}
4193 4261
 
4194 4262
 				$domains = array_values( array_filter( array_map( 'trim', $value ) ) );
4195 4263
 				$value = array();
@@ -4199,8 +4267,9 @@  discard block
 block discarded – undo
4199 4267
 						$value[] = $domain;
4200 4268
 					}
4201 4269
 				}
4202
-				if ( ! $value )
4203
-					$value = '';
4270
+				if ( ! $value ) {
4271
+									$value = '';
4272
+				}
4204 4273
 			}
4205 4274
 			break;
4206 4275
 
@@ -4232,8 +4301,9 @@  discard block
 block discarded – undo
4232 4301
 			break;
4233 4302
 
4234 4303
 		case 'default_role' :
4235
-			if ( ! get_role( $value ) && get_role( 'subscriber' ) )
4236
-				$value = 'subscriber';
4304
+			if ( ! get_role( $value ) && get_role( 'subscriber' ) ) {
4305
+							$value = 'subscriber';
4306
+			}
4237 4307
 			break;
4238 4308
 
4239 4309
 		case 'moderation_keys':
@@ -4311,8 +4381,9 @@  discard block
 block discarded – undo
4311 4381
  */
4312 4382
 function wp_parse_str( $string, &$array ) {
4313 4383
 	parse_str( $string, $array );
4314
-	if ( get_magic_quotes_gpc() )
4315
-		$array = stripslashes_deep( $array );
4384
+	if ( get_magic_quotes_gpc() ) {
4385
+			$array = stripslashes_deep( $array );
4386
+	}
4316 4387
 	/**
4317 4388
 	 * Filters the array of variables derived from a parsed string.
4318 4389
 	 *
@@ -4346,8 +4417,9 @@  discard block
 block discarded – undo
4346 4417
  * @return string The text returned after esc_html if needed.
4347 4418
  */
4348 4419
 function wp_pre_kses_less_than_callback( $matches ) {
4349
-	if ( false === strpos($matches[0], '>') )
4350
-		return esc_html($matches[0]);
4420
+	if ( false === strpos($matches[0], '>') ) {
4421
+			return esc_html($matches[0]);
4422
+	}
4351 4423
 	return $matches[0];
4352 4424
 }
4353 4425
 
@@ -4383,8 +4455,9 @@  discard block
 block discarded – undo
4383 4455
 
4384 4456
 		// Get fragment before next %
4385 4457
 		$end = strpos($pattern, '%', $start + 1);
4386
-		if ( false === $end )
4387
-			$end = $len;
4458
+		if ( false === $end ) {
4459
+					$end = $len;
4460
+		}
4388 4461
 		$fragment = substr($pattern, $start, $end - $start);
4389 4462
 
4390 4463
 		// Fragment has a specifier
@@ -4409,10 +4482,11 @@  discard block
 block discarded – undo
4409 4482
 			 * @param string $arg      The argument.
4410 4483
 			 */
4411 4484
 			$_fragment = apply_filters( 'wp_sprintf', $fragment, $arg );
4412
-			if ( $_fragment != $fragment )
4413
-				$fragment = $_fragment;
4414
-			else
4415
-				$fragment = sprintf($fragment, strval($arg) );
4485
+			if ( $_fragment != $fragment ) {
4486
+							$fragment = $_fragment;
4487
+			} else {
4488
+							$fragment = sprintf($fragment, strval($arg) );
4489
+			}
4416 4490
 		}
4417 4491
 
4418 4492
 		// Append to result and move to next fragment
@@ -4437,12 +4511,14 @@  discard block
 block discarded – undo
4437 4511
  */
4438 4512
 function wp_sprintf_l( $pattern, $args ) {
4439 4513
 	// Not a match
4440
-	if ( substr($pattern, 0, 2) != '%l' )
4441
-		return $pattern;
4514
+	if ( substr($pattern, 0, 2) != '%l' ) {
4515
+			return $pattern;
4516
+	}
4442 4517
 
4443 4518
 	// Nothing to work with
4444
-	if ( empty($args) )
4445
-		return '';
4519
+	if ( empty($args) ) {
4520
+			return '';
4521
+	}
4446 4522
 
4447 4523
 	/**
4448 4524
 	 * Filters the translated delimiters used by wp_sprintf_l().
@@ -4466,17 +4542,19 @@  discard block
 block discarded – undo
4466 4542
 
4467 4543
 	$args = (array) $args;
4468 4544
 	$result = array_shift($args);
4469
-	if ( count($args) == 1 )
4470
-		$result .= $l['between_only_two'] . array_shift($args);
4545
+	if ( count($args) == 1 ) {
4546
+			$result .= $l['between_only_two'] . array_shift($args);
4547
+	}
4471 4548
 	// Loop when more than two args
4472 4549
 	$i = count($args);
4473 4550
 	while ( $i ) {
4474 4551
 		$arg = array_shift($args);
4475 4552
 		$i--;
4476
-		if ( 0 == $i )
4477
-			$result .= $l['between_last_two'] . $arg;
4478
-		else
4479
-			$result .= $l['between'] . $arg;
4553
+		if ( 0 == $i ) {
4554
+					$result .= $l['between_last_two'] . $arg;
4555
+		} else {
4556
+					$result .= $l['between'] . $arg;
4557
+		}
4480 4558
 	}
4481 4559
 	return $result . substr($pattern, 2);
4482 4560
 }
@@ -4496,14 +4574,16 @@  discard block
 block discarded – undo
4496 4574
  * @return string The excerpt.
4497 4575
  */
4498 4576
 function wp_html_excerpt( $str, $count, $more = null ) {
4499
-	if ( null === $more )
4500
-		$more = '';
4577
+	if ( null === $more ) {
4578
+			$more = '';
4579
+	}
4501 4580
 	$str = wp_strip_all_tags( $str, true );
4502 4581
 	$excerpt = mb_substr( $str, 0, $count );
4503 4582
 	// remove part of an entity at the end
4504 4583
 	$excerpt = preg_replace( '/&[^;\s]{0,6}$/', '', $excerpt );
4505
-	if ( $str != $excerpt )
4506
-		$excerpt = trim( $excerpt ) . $more;
4584
+	if ( $str != $excerpt ) {
4585
+			$excerpt = trim( $excerpt ) . $more;
4586
+	}
4507 4587
 	return $excerpt;
4508 4588
 }
4509 4589
 
@@ -4625,8 +4705,9 @@  discard block
 block discarded – undo
4625 4705
 	$string = preg_replace( '@<(script|style)[^>]*?>.*?</\\1>@si', '', $string );
4626 4706
 	$string = strip_tags($string);
4627 4707
 
4628
-	if ( $remove_breaks )
4629
-		$string = preg_replace('/[\r\n\t ]+/', ' ', $string);
4708
+	if ( $remove_breaks ) {
4709
+			$string = preg_replace('/[\r\n\t ]+/', ' ', $string);
4710
+	}
4630 4711
 
4631 4712
 	return trim( $string );
4632 4713
 }
@@ -4709,8 +4790,9 @@  discard block
 block discarded – undo
4709 4790
 function capital_P_dangit( $text ) {
4710 4791
 	// Simple replacement for titles
4711 4792
 	$current_filter = current_filter();
4712
-	if ( 'the_title' === $current_filter || 'wp_title' === $current_filter )
4713
-		return str_replace( 'Wordpress', 'WordPress', $text );
4793
+	if ( 'the_title' === $current_filter || 'wp_title' === $current_filter ) {
4794
+			return str_replace( 'Wordpress', 'WordPress', $text );
4795
+	}
4714 4796
 	// Still here? Use the more judicious replacement
4715 4797
 	static $dblq = false;
4716 4798
 	if ( false === $dblq ) {
@@ -4754,8 +4836,9 @@  discard block
 block discarded – undo
4754 4836
 function sanitize_trackback_urls( $to_ping ) {
4755 4837
 	$urls_to_ping = preg_split( '/[\r\n\t ]/', trim( $to_ping ), -1, PREG_SPLIT_NO_EMPTY );
4756 4838
 	foreach ( $urls_to_ping as $k => $url ) {
4757
-		if ( !preg_match( '#^https?://.#i', $url ) )
4758
-			unset( $urls_to_ping[$k] );
4839
+		if ( !preg_match( '#^https?://.#i', $url ) ) {
4840
+					unset( $urls_to_ping[$k] );
4841
+		}
4759 4842
 	}
4760 4843
 	$urls_to_ping = array_map( 'esc_url_raw', $urls_to_ping );
4761 4844
 	$urls_to_ping = implode( "\n", $urls_to_ping );
Please login to merge, or discard this patch.
Spacing   +990 added lines, -991 removed lines patch added patch discarded remove patch
@@ -38,7 +38,7 @@  discard block
 block discarded – undo
38 38
  * @param bool   $reset Set to true for unit testing. Translated patterns will reset.
39 39
  * @return string The string replaced with html entities
40 40
  */
41
-function wptexturize( $text, $reset = false ) {
41
+function wptexturize($text, $reset = false) {
42 42
 	global $wp_cockneyreplace, $shortcode_tags;
43 43
 	static $static_characters = null,
44 44
 		$static_replacements = null,
@@ -59,12 +59,12 @@  discard block
 block discarded – undo
59 59
 		$apos_flag = '<!--apos-->';
60 60
 
61 61
 	// If there's nothing to do, just stop.
62
-	if ( empty( $text ) || false === $run_texturize ) {
62
+	if (empty($text) || false === $run_texturize) {
63 63
 		return $text;
64 64
 	}
65 65
 
66 66
 	// Set up static variables. Run once only.
67
-	if ( $reset || ! isset( $static_characters ) ) {
67
+	if ($reset || ! isset($static_characters)) {
68 68
 		/**
69 69
 		 * Filters whether to skip running wptexturize().
70 70
 		 *
@@ -79,118 +79,118 @@  discard block
 block discarded – undo
79 79
 		 *
80 80
 		 * @param bool $run_texturize Whether to short-circuit wptexturize().
81 81
 		 */
82
-		$run_texturize = apply_filters( 'run_wptexturize', $run_texturize );
83
-		if ( false === $run_texturize ) {
82
+		$run_texturize = apply_filters('run_wptexturize', $run_texturize);
83
+		if (false === $run_texturize) {
84 84
 			return $text;
85 85
 		}
86 86
 
87 87
 		/* translators: opening curly double quote */
88
-		$opening_quote = _x( '&#8220;', 'opening curly double quote' );
88
+		$opening_quote = _x('&#8220;', 'opening curly double quote');
89 89
 		/* translators: closing curly double quote */
90
-		$closing_quote = _x( '&#8221;', 'closing curly double quote' );
90
+		$closing_quote = _x('&#8221;', 'closing curly double quote');
91 91
 
92 92
 		/* translators: apostrophe, for example in 'cause or can't */
93
-		$apos = _x( '&#8217;', 'apostrophe' );
93
+		$apos = _x('&#8217;', 'apostrophe');
94 94
 
95 95
 		/* translators: prime, for example in 9' (nine feet) */
96
-		$prime = _x( '&#8242;', 'prime' );
96
+		$prime = _x('&#8242;', 'prime');
97 97
 		/* translators: double prime, for example in 9" (nine inches) */
98
-		$double_prime = _x( '&#8243;', 'double prime' );
98
+		$double_prime = _x('&#8243;', 'double prime');
99 99
 
100 100
 		/* translators: opening curly single quote */
101
-		$opening_single_quote = _x( '&#8216;', 'opening curly single quote' );
101
+		$opening_single_quote = _x('&#8216;', 'opening curly single quote');
102 102
 		/* translators: closing curly single quote */
103
-		$closing_single_quote = _x( '&#8217;', 'closing curly single quote' );
103
+		$closing_single_quote = _x('&#8217;', 'closing curly single quote');
104 104
 
105 105
 		/* translators: en dash */
106
-		$en_dash = _x( '&#8211;', 'en dash' );
106
+		$en_dash = _x('&#8211;', 'en dash');
107 107
 		/* translators: em dash */
108
-		$em_dash = _x( '&#8212;', 'em dash' );
108
+		$em_dash = _x('&#8212;', 'em dash');
109 109
 
110 110
 		$default_no_texturize_tags = array('pre', 'code', 'kbd', 'style', 'script', 'tt');
111 111
 		$default_no_texturize_shortcodes = array('code');
112 112
 
113 113
 		// if a plugin has provided an autocorrect array, use it
114
-		if ( isset($wp_cockneyreplace) ) {
115
-			$cockney = array_keys( $wp_cockneyreplace );
116
-			$cockneyreplace = array_values( $wp_cockneyreplace );
114
+		if (isset($wp_cockneyreplace)) {
115
+			$cockney = array_keys($wp_cockneyreplace);
116
+			$cockneyreplace = array_values($wp_cockneyreplace);
117 117
 		} else {
118 118
 			/* translators: This is a comma-separated list of words that defy the syntax of quotations in normal use,
119 119
 			 * for example...  'We do not have enough words yet' ... is a typical quoted phrase.  But when we write
120 120
 			 * lines of code 'til we have enough of 'em, then we need to insert apostrophes instead of quotes.
121 121
 			 */
122
-			$cockney = explode( ',', _x( "'tain't,'twere,'twas,'tis,'twill,'til,'bout,'nuff,'round,'cause,'em",
123
-				'Comma-separated list of words to texturize in your language' ) );
122
+			$cockney = explode(',', _x("'tain't,'twere,'twas,'tis,'twill,'til,'bout,'nuff,'round,'cause,'em",
123
+				'Comma-separated list of words to texturize in your language'));
124 124
 
125
-			$cockneyreplace = explode( ',', _x( '&#8217;tain&#8217;t,&#8217;twere,&#8217;twas,&#8217;tis,&#8217;twill,&#8217;til,&#8217;bout,&#8217;nuff,&#8217;round,&#8217;cause,&#8217;em',
126
-				'Comma-separated list of replacement words in your language' ) );
125
+			$cockneyreplace = explode(',', _x('&#8217;tain&#8217;t,&#8217;twere,&#8217;twas,&#8217;tis,&#8217;twill,&#8217;til,&#8217;bout,&#8217;nuff,&#8217;round,&#8217;cause,&#8217;em',
126
+				'Comma-separated list of replacement words in your language'));
127 127
 		}
128 128
 
129
-		$static_characters = array_merge( array( '...', '``', '\'\'', ' (tm)' ), $cockney );
130
-		$static_replacements = array_merge( array( '&#8230;', $opening_quote, $closing_quote, ' &#8482;' ), $cockneyreplace );
129
+		$static_characters = array_merge(array('...', '``', '\'\'', ' (tm)'), $cockney);
130
+		$static_replacements = array_merge(array('&#8230;', $opening_quote, $closing_quote, ' &#8482;'), $cockneyreplace);
131 131
 
132 132
 
133 133
 		// Pattern-based replacements of characters.
134 134
 		// Sort the remaining patterns into several arrays for performance tuning.
135
-		$dynamic_characters = array( 'apos' => array(), 'quote' => array(), 'dash' => array() );
136
-		$dynamic_replacements = array( 'apos' => array(), 'quote' => array(), 'dash' => array() );
135
+		$dynamic_characters = array('apos' => array(), 'quote' => array(), 'dash' => array());
136
+		$dynamic_replacements = array('apos' => array(), 'quote' => array(), 'dash' => array());
137 137
 		$dynamic = array();
138 138
 		$spaces = wp_spaces_regexp();
139 139
 
140 140
 		// '99' and '99" are ambiguous among other patterns; assume it's an abbreviated year at the end of a quotation.
141
-		if ( "'" !== $apos || "'" !== $closing_single_quote ) {
142
-			$dynamic[ '/\'(\d\d)\'(?=\Z|[.,:;!?)}\-\]]|&gt;|' . $spaces . ')/' ] = $apos_flag . '$1' . $closing_single_quote;
141
+		if ("'" !== $apos || "'" !== $closing_single_quote) {
142
+			$dynamic['/\'(\d\d)\'(?=\Z|[.,:;!?)}\-\]]|&gt;|'.$spaces.')/'] = $apos_flag.'$1'.$closing_single_quote;
143 143
 		}
144
-		if ( "'" !== $apos || '"' !== $closing_quote ) {
145
-			$dynamic[ '/\'(\d\d)"(?=\Z|[.,:;!?)}\-\]]|&gt;|' . $spaces . ')/' ] = $apos_flag . '$1' . $closing_quote;
144
+		if ("'" !== $apos || '"' !== $closing_quote) {
145
+			$dynamic['/\'(\d\d)"(?=\Z|[.,:;!?)}\-\]]|&gt;|'.$spaces.')/'] = $apos_flag.'$1'.$closing_quote;
146 146
 		}
147 147
 
148 148
 		// '99 '99s '99's (apostrophe)  But never '9 or '99% or '999 or '99.0.
149
-		if ( "'" !== $apos ) {
150
-			$dynamic[ '/\'(?=\d\d(?:\Z|(?![%\d]|[.,]\d)))/' ] = $apos_flag;
149
+		if ("'" !== $apos) {
150
+			$dynamic['/\'(?=\d\d(?:\Z|(?![%\d]|[.,]\d)))/'] = $apos_flag;
151 151
 		}
152 152
 
153 153
 		// Quoted Numbers like '0.42'
154
-		if ( "'" !== $opening_single_quote && "'" !== $closing_single_quote ) {
155
-			$dynamic[ '/(?<=\A|' . $spaces . ')\'(\d[.,\d]*)\'/' ] = $open_sq_flag . '$1' . $closing_single_quote;
154
+		if ("'" !== $opening_single_quote && "'" !== $closing_single_quote) {
155
+			$dynamic['/(?<=\A|'.$spaces.')\'(\d[.,\d]*)\'/'] = $open_sq_flag.'$1'.$closing_single_quote;
156 156
 		}
157 157
 
158 158
 		// Single quote at start, or preceded by (, {, <, [, ", -, or spaces.
159
-		if ( "'" !== $opening_single_quote ) {
160
-			$dynamic[ '/(?<=\A|[([{"\-]|&lt;|' . $spaces . ')\'/' ] = $open_sq_flag;
159
+		if ("'" !== $opening_single_quote) {
160
+			$dynamic['/(?<=\A|[([{"\-]|&lt;|'.$spaces.')\'/'] = $open_sq_flag;
161 161
 		}
162 162
 
163 163
 		// Apostrophe in a word.  No spaces, double apostrophes, or other punctuation.
164
-		if ( "'" !== $apos ) {
165
-			$dynamic[ '/(?<!' . $spaces . ')\'(?!\Z|[.,:;!?"\'(){}[\]\-]|&[lg]t;|' . $spaces . ')/' ] = $apos_flag;
164
+		if ("'" !== $apos) {
165
+			$dynamic['/(?<!'.$spaces.')\'(?!\Z|[.,:;!?"\'(){}[\]\-]|&[lg]t;|'.$spaces.')/'] = $apos_flag;
166 166
 		}
167 167
 
168
-		$dynamic_characters['apos'] = array_keys( $dynamic );
169
-		$dynamic_replacements['apos'] = array_values( $dynamic );
168
+		$dynamic_characters['apos'] = array_keys($dynamic);
169
+		$dynamic_replacements['apos'] = array_values($dynamic);
170 170
 		$dynamic = array();
171 171
 
172 172
 		// Quoted Numbers like "42"
173
-		if ( '"' !== $opening_quote && '"' !== $closing_quote ) {
174
-			$dynamic[ '/(?<=\A|' . $spaces . ')"(\d[.,\d]*)"/' ] = $open_q_flag . '$1' . $closing_quote;
173
+		if ('"' !== $opening_quote && '"' !== $closing_quote) {
174
+			$dynamic['/(?<=\A|'.$spaces.')"(\d[.,\d]*)"/'] = $open_q_flag.'$1'.$closing_quote;
175 175
 		}
176 176
 
177 177
 		// Double quote at start, or preceded by (, {, <, [, -, or spaces, and not followed by spaces.
178
-		if ( '"' !== $opening_quote ) {
179
-			$dynamic[ '/(?<=\A|[([{\-]|&lt;|' . $spaces . ')"(?!' . $spaces . ')/' ] = $open_q_flag;
178
+		if ('"' !== $opening_quote) {
179
+			$dynamic['/(?<=\A|[([{\-]|&lt;|'.$spaces.')"(?!'.$spaces.')/'] = $open_q_flag;
180 180
 		}
181 181
 
182
-		$dynamic_characters['quote'] = array_keys( $dynamic );
183
-		$dynamic_replacements['quote'] = array_values( $dynamic );
182
+		$dynamic_characters['quote'] = array_keys($dynamic);
183
+		$dynamic_replacements['quote'] = array_values($dynamic);
184 184
 		$dynamic = array();
185 185
 
186 186
 		// Dashes and spaces
187
-		$dynamic[ '/---/' ] = $em_dash;
188
-		$dynamic[ '/(?<=^|' . $spaces . ')--(?=$|' . $spaces . ')/' ] = $em_dash;
189
-		$dynamic[ '/(?<!xn)--/' ] = $en_dash;
190
-		$dynamic[ '/(?<=^|' . $spaces . ')-(?=$|' . $spaces . ')/' ] = $en_dash;
187
+		$dynamic['/---/'] = $em_dash;
188
+		$dynamic['/(?<=^|'.$spaces.')--(?=$|'.$spaces.')/'] = $em_dash;
189
+		$dynamic['/(?<!xn)--/'] = $en_dash;
190
+		$dynamic['/(?<=^|'.$spaces.')-(?=$|'.$spaces.')/'] = $en_dash;
191 191
 
192
-		$dynamic_characters['dash'] = array_keys( $dynamic );
193
-		$dynamic_replacements['dash'] = array_values( $dynamic );
192
+		$dynamic_characters['dash'] = array_keys($dynamic);
193
+		$dynamic_replacements['dash'] = array_values($dynamic);
194 194
 	}
195 195
 
196 196
 	// Must do this every time in case plugins use these filters in a context sensitive manner
@@ -201,7 +201,7 @@  discard block
 block discarded – undo
201 201
 	 *
202 202
 	 * @param array $default_no_texturize_tags An array of HTML element names.
203 203
 	 */
204
-	$no_texturize_tags = apply_filters( 'no_texturize_tags', $default_no_texturize_tags );
204
+	$no_texturize_tags = apply_filters('no_texturize_tags', $default_no_texturize_tags);
205 205
 	/**
206 206
 	 * Filters the list of shortcodes not to texturize.
207 207
 	 *
@@ -209,84 +209,84 @@  discard block
 block discarded – undo
209 209
 	 *
210 210
 	 * @param array $default_no_texturize_shortcodes An array of shortcode names.
211 211
 	 */
212
-	$no_texturize_shortcodes = apply_filters( 'no_texturize_shortcodes', $default_no_texturize_shortcodes );
212
+	$no_texturize_shortcodes = apply_filters('no_texturize_shortcodes', $default_no_texturize_shortcodes);
213 213
 
214 214
 	$no_texturize_tags_stack = array();
215 215
 	$no_texturize_shortcodes_stack = array();
216 216
 
217 217
 	// Look for shortcodes and HTML elements.
218 218
 
219
-	preg_match_all( '@\[/?([^<>&/\[\]\x00-\x20=]++)@', $text, $matches );
220
-	$tagnames = array_intersect( array_keys( $shortcode_tags ), $matches[1] );
221
-	$found_shortcodes = ! empty( $tagnames );
222
-	$shortcode_regex = $found_shortcodes ? _get_wptexturize_shortcode_regex( $tagnames ) : '';
223
-	$regex = _get_wptexturize_split_regex( $shortcode_regex );
219
+	preg_match_all('@\[/?([^<>&/\[\]\x00-\x20=]++)@', $text, $matches);
220
+	$tagnames = array_intersect(array_keys($shortcode_tags), $matches[1]);
221
+	$found_shortcodes = ! empty($tagnames);
222
+	$shortcode_regex = $found_shortcodes ? _get_wptexturize_shortcode_regex($tagnames) : '';
223
+	$regex = _get_wptexturize_split_regex($shortcode_regex);
224 224
 
225
-	$textarr = preg_split( $regex, $text, -1, PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY );
225
+	$textarr = preg_split($regex, $text, -1, PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY);
226 226
 
227
-	foreach ( $textarr as &$curl ) {
227
+	foreach ($textarr as &$curl) {
228 228
 		// Only call _wptexturize_pushpop_element if $curl is a delimiter.
229 229
 		$first = $curl[0];
230
-		if ( '<' === $first ) {
231
-			if ( '<!--' === substr( $curl, 0, 4 ) ) {
230
+		if ('<' === $first) {
231
+			if ('<!--' === substr($curl, 0, 4)) {
232 232
 				// This is an HTML comment delimiter.
233 233
 				continue;
234 234
 			} else {
235 235
 				// This is an HTML element delimiter.
236 236
 
237 237
 				// Replace each & with &#038; unless it already looks like an entity.
238
-				$curl = preg_replace( '/&(?!#(?:\d+|x[a-f0-9]+);|[a-z1-4]{1,8};)/i', '&#038;', $curl );
238
+				$curl = preg_replace('/&(?!#(?:\d+|x[a-f0-9]+);|[a-z1-4]{1,8};)/i', '&#038;', $curl);
239 239
 
240
-				_wptexturize_pushpop_element( $curl, $no_texturize_tags_stack, $no_texturize_tags );
240
+				_wptexturize_pushpop_element($curl, $no_texturize_tags_stack, $no_texturize_tags);
241 241
 			}
242 242
 
243
-		} elseif ( '' === trim( $curl ) ) {
243
+		} elseif ('' === trim($curl)) {
244 244
 			// This is a newline between delimiters.  Performance improves when we check this.
245 245
 			continue;
246 246
 
247
-		} elseif ( '[' === $first && $found_shortcodes && 1 === preg_match( '/^' . $shortcode_regex . '$/', $curl ) ) {
247
+		} elseif ('[' === $first && $found_shortcodes && 1 === preg_match('/^'.$shortcode_regex.'$/', $curl)) {
248 248
 			// This is a shortcode delimiter.
249 249
 
250
-			if ( '[[' !== substr( $curl, 0, 2 ) && ']]' !== substr( $curl, -2 ) ) {
250
+			if ('[[' !== substr($curl, 0, 2) && ']]' !== substr($curl, -2)) {
251 251
 				// Looks like a normal shortcode.
252
-				_wptexturize_pushpop_element( $curl, $no_texturize_shortcodes_stack, $no_texturize_shortcodes );
252
+				_wptexturize_pushpop_element($curl, $no_texturize_shortcodes_stack, $no_texturize_shortcodes);
253 253
 			} else {
254 254
 				// Looks like an escaped shortcode.
255 255
 				continue;
256 256
 			}
257 257
 
258
-		} elseif ( empty( $no_texturize_shortcodes_stack ) && empty( $no_texturize_tags_stack ) ) {
258
+		} elseif (empty($no_texturize_shortcodes_stack) && empty($no_texturize_tags_stack)) {
259 259
 			// This is neither a delimiter, nor is this content inside of no_texturize pairs.  Do texturize.
260 260
 
261
-			$curl = str_replace( $static_characters, $static_replacements, $curl );
261
+			$curl = str_replace($static_characters, $static_replacements, $curl);
262 262
 
263
-			if ( false !== strpos( $curl, "'" ) ) {
264
-				$curl = preg_replace( $dynamic_characters['apos'], $dynamic_replacements['apos'], $curl );
265
-				$curl = wptexturize_primes( $curl, "'", $prime, $open_sq_flag, $closing_single_quote );
266
-				$curl = str_replace( $apos_flag, $apos, $curl );
267
-				$curl = str_replace( $open_sq_flag, $opening_single_quote, $curl );
263
+			if (false !== strpos($curl, "'")) {
264
+				$curl = preg_replace($dynamic_characters['apos'], $dynamic_replacements['apos'], $curl);
265
+				$curl = wptexturize_primes($curl, "'", $prime, $open_sq_flag, $closing_single_quote);
266
+				$curl = str_replace($apos_flag, $apos, $curl);
267
+				$curl = str_replace($open_sq_flag, $opening_single_quote, $curl);
268 268
 			}
269
-			if ( false !== strpos( $curl, '"' ) ) {
270
-				$curl = preg_replace( $dynamic_characters['quote'], $dynamic_replacements['quote'], $curl );
271
-				$curl = wptexturize_primes( $curl, '"', $double_prime, $open_q_flag, $closing_quote );
272
-				$curl = str_replace( $open_q_flag, $opening_quote, $curl );
269
+			if (false !== strpos($curl, '"')) {
270
+				$curl = preg_replace($dynamic_characters['quote'], $dynamic_replacements['quote'], $curl);
271
+				$curl = wptexturize_primes($curl, '"', $double_prime, $open_q_flag, $closing_quote);
272
+				$curl = str_replace($open_q_flag, $opening_quote, $curl);
273 273
 			}
274
-			if ( false !== strpos( $curl, '-' ) ) {
275
-				$curl = preg_replace( $dynamic_characters['dash'], $dynamic_replacements['dash'], $curl );
274
+			if (false !== strpos($curl, '-')) {
275
+				$curl = preg_replace($dynamic_characters['dash'], $dynamic_replacements['dash'], $curl);
276 276
 			}
277 277
 
278 278
 			// 9x9 (times), but never 0x9999
279
-			if ( 1 === preg_match( '/(?<=\d)x\d/', $curl ) ) {
279
+			if (1 === preg_match('/(?<=\d)x\d/', $curl)) {
280 280
 				// Searching for a digit is 10 times more expensive than for the x, so we avoid doing this one!
281
-				$curl = preg_replace( '/\b(\d(?(?<=0)[\d\.,]+|[\d\.,]*))x(\d[\d\.,]*)\b/', '$1&#215;$2', $curl );
281
+				$curl = preg_replace('/\b(\d(?(?<=0)[\d\.,]+|[\d\.,]*))x(\d[\d\.,]*)\b/', '$1&#215;$2', $curl);
282 282
 			}
283 283
 
284 284
 			// Replace each & with &#038; unless it already looks like an entity.
285
-			$curl = preg_replace( '/&(?!#(?:\d+|x[a-f0-9]+);|[a-z1-4]{1,8};)/i', '&#038;', $curl );
285
+			$curl = preg_replace('/&(?!#(?:\d+|x[a-f0-9]+);|[a-z1-4]{1,8};)/i', '&#038;', $curl);
286 286
 		}
287 287
 	}
288 288
 
289
-	return implode( '', $textarr );
289
+	return implode('', $textarr);
290 290
 }
291 291
 
292 292
 /**
@@ -303,59 +303,59 @@  discard block
 block discarded – undo
303 303
  * @param string $close_quote The closing quote char to use for replacement.
304 304
  * @return string The $haystack value after primes and quotes replacements.
305 305
  */
306
-function wptexturize_primes( $haystack, $needle, $prime, $open_quote, $close_quote ) {
306
+function wptexturize_primes($haystack, $needle, $prime, $open_quote, $close_quote) {
307 307
 	$spaces = wp_spaces_regexp();
308 308
 	$flag = '<!--wp-prime-or-quote-->';
309
-	$quote_pattern = "/$needle(?=\\Z|[.,:;!?)}\\-\\]]|&gt;|" . $spaces . ")/";
309
+	$quote_pattern = "/$needle(?=\\Z|[.,:;!?)}\\-\\]]|&gt;|".$spaces.")/";
310 310
 	$prime_pattern    = "/(?<=\\d)$needle/";
311 311
 	$flag_after_digit = "/(?<=\\d)$flag/";
312 312
 	$flag_no_digit    = "/(?<!\\d)$flag/";
313 313
 
314
-	$sentences = explode( $open_quote, $haystack );
314
+	$sentences = explode($open_quote, $haystack);
315 315
 
316
-	foreach ( $sentences as $key => &$sentence ) {
317
-		if ( false === strpos( $sentence, $needle ) ) {
316
+	foreach ($sentences as $key => &$sentence) {
317
+		if (false === strpos($sentence, $needle)) {
318 318
 			continue;
319
-		} elseif ( 0 !== $key && 0 === substr_count( $sentence, $close_quote ) ) {
320
-			$sentence = preg_replace( $quote_pattern, $flag, $sentence, -1, $count );
321
-			if ( $count > 1 ) {
319
+		} elseif (0 !== $key && 0 === substr_count($sentence, $close_quote)) {
320
+			$sentence = preg_replace($quote_pattern, $flag, $sentence, -1, $count);
321
+			if ($count > 1) {
322 322
 				// This sentence appears to have multiple closing quotes.  Attempt Vulcan logic.
323
-				$sentence = preg_replace( $flag_no_digit, $close_quote, $sentence, -1, $count2 );
324
-				if ( 0 === $count2 ) {
323
+				$sentence = preg_replace($flag_no_digit, $close_quote, $sentence, -1, $count2);
324
+				if (0 === $count2) {
325 325
 					// Try looking for a quote followed by a period.
326
-					$count2 = substr_count( $sentence, "$flag." );
327
-					if ( $count2 > 0 ) {
326
+					$count2 = substr_count($sentence, "$flag.");
327
+					if ($count2 > 0) {
328 328
 						// Assume the rightmost quote-period match is the end of quotation.
329
-						$pos = strrpos( $sentence, "$flag." );
329
+						$pos = strrpos($sentence, "$flag.");
330 330
 					} else {
331 331
 						// When all else fails, make the rightmost candidate a closing quote.
332 332
 						// This is most likely to be problematic in the context of bug #18549.
333
-						$pos = strrpos( $sentence, $flag );
333
+						$pos = strrpos($sentence, $flag);
334 334
 					}
335
-					$sentence = substr_replace( $sentence, $close_quote, $pos, strlen( $flag ) );
335
+					$sentence = substr_replace($sentence, $close_quote, $pos, strlen($flag));
336 336
 				}
337 337
 				// Use conventional replacement on any remaining primes and quotes.
338
-				$sentence = preg_replace( $prime_pattern, $prime, $sentence );
339
-				$sentence = preg_replace( $flag_after_digit, $prime, $sentence );
340
-				$sentence = str_replace( $flag, $close_quote, $sentence );
341
-			} elseif ( 1 == $count ) {
338
+				$sentence = preg_replace($prime_pattern, $prime, $sentence);
339
+				$sentence = preg_replace($flag_after_digit, $prime, $sentence);
340
+				$sentence = str_replace($flag, $close_quote, $sentence);
341
+			} elseif (1 == $count) {
342 342
 				// Found only one closing quote candidate, so give it priority over primes.
343
-				$sentence = str_replace( $flag, $close_quote, $sentence );
344
-				$sentence = preg_replace( $prime_pattern, $prime, $sentence );
343
+				$sentence = str_replace($flag, $close_quote, $sentence);
344
+				$sentence = preg_replace($prime_pattern, $prime, $sentence);
345 345
 			} else {
346 346
 				// No closing quotes found.  Just run primes pattern.
347
-				$sentence = preg_replace( $prime_pattern, $prime, $sentence );
347
+				$sentence = preg_replace($prime_pattern, $prime, $sentence);
348 348
 			}
349 349
 		} else {
350
-			$sentence = preg_replace( $prime_pattern, $prime, $sentence );
351
-			$sentence = preg_replace( $quote_pattern, $close_quote, $sentence );
350
+			$sentence = preg_replace($prime_pattern, $prime, $sentence);
351
+			$sentence = preg_replace($quote_pattern, $close_quote, $sentence);
352 352
 		}
353
-		if ( '"' == $needle && false !== strpos( $sentence, '"' ) ) {
354
-			$sentence = str_replace( '"', $close_quote, $sentence );
353
+		if ('"' == $needle && false !== strpos($sentence, '"')) {
354
+			$sentence = str_replace('"', $close_quote, $sentence);
355 355
 		}
356 356
 	}
357 357
 
358
-	return implode( $open_quote, $sentences );
358
+	return implode($open_quote, $sentences);
359 359
 }
360 360
 
361 361
 /**
@@ -372,12 +372,12 @@  discard block
 block discarded – undo
372 372
  * @param array  $stack List of open tag elements.
373 373
  * @param array  $disabled_elements The tag names to match against. Spaces are not allowed in tag names.
374 374
  */
375
-function _wptexturize_pushpop_element( $text, &$stack, $disabled_elements ) {
375
+function _wptexturize_pushpop_element($text, &$stack, $disabled_elements) {
376 376
 	// Is it an opening tag or closing tag?
377
-	if ( isset( $text[1] ) && '/' !== $text[1] ) {
377
+	if (isset($text[1]) && '/' !== $text[1]) {
378 378
 		$opening_tag = true;
379 379
 		$name_offset = 1;
380
-	} elseif ( 0 == count( $stack ) ) {
380
+	} elseif (0 == count($stack)) {
381 381
 		// Stack is empty. Just stop.
382 382
 		return;
383 383
 	} else {
@@ -386,17 +386,17 @@  discard block
 block discarded – undo
386 386
 	}
387 387
 
388 388
 	// Parse out the tag name.
389
-	$space = strpos( $text, ' ' );
390
-	if ( false === $space ) {
389
+	$space = strpos($text, ' ');
390
+	if (false === $space) {
391 391
 		$space = -1;
392 392
 	} else {
393 393
 		$space -= $name_offset;
394 394
 	}
395
-	$tag = substr( $text, $name_offset, $space );
395
+	$tag = substr($text, $name_offset, $space);
396 396
 
397 397
 	// Handle disabled tags.
398
-	if ( in_array( $tag, $disabled_elements ) ) {
399
-		if ( $opening_tag ) {
398
+	if (in_array($tag, $disabled_elements)) {
399
+		if ($opening_tag) {
400 400
 			/*
401 401
 			 * This disables texturize until we find a closing tag of our type
402 402
 			 * (e.g. <pre>) even if there was invalid nesting before that
@@ -405,9 +405,9 @@  discard block
 block discarded – undo
405 405
 			 *          "baba" won't be texturize
406 406
 			 */
407 407
 
408
-			array_push( $stack, $tag );
409
-		} elseif ( end( $stack ) == $tag ) {
410
-			array_pop( $stack );
408
+			array_push($stack, $tag);
409
+		} elseif (end($stack) == $tag) {
410
+			array_pop($stack);
411 411
 		}
412 412
 	}
413 413
 }
@@ -426,38 +426,38 @@  discard block
 block discarded – undo
426 426
  *                    after paragraphing. Default true.
427 427
  * @return string Text which has been converted into correct paragraph tags.
428 428
  */
429
-function wpautop( $pee, $br = true ) {
429
+function wpautop($pee, $br = true) {
430 430
 	$pre_tags = array();
431 431
 
432
-	if ( trim($pee) === '' )
432
+	if (trim($pee) === '')
433 433
 		return '';
434 434
 
435 435
 	// Just to make things a little easier, pad the end.
436
-	$pee = $pee . "\n";
436
+	$pee = $pee."\n";
437 437
 
438 438
 	/*
439 439
 	 * Pre tags shouldn't be touched by autop.
440 440
 	 * Replace pre tags with placeholders and bring them back after autop.
441 441
 	 */
442
-	if ( strpos($pee, '<pre') !== false ) {
443
-		$pee_parts = explode( '</pre>', $pee );
442
+	if (strpos($pee, '<pre') !== false) {
443
+		$pee_parts = explode('</pre>', $pee);
444 444
 		$last_pee = array_pop($pee_parts);
445 445
 		$pee = '';
446 446
 		$i = 0;
447 447
 
448
-		foreach ( $pee_parts as $pee_part ) {
448
+		foreach ($pee_parts as $pee_part) {
449 449
 			$start = strpos($pee_part, '<pre');
450 450
 
451 451
 			// Malformed html?
452
-			if ( $start === false ) {
452
+			if ($start === false) {
453 453
 				$pee .= $pee_part;
454 454
 				continue;
455 455
 			}
456 456
 
457 457
 			$name = "<pre wp-pre-tag-$i></pre>";
458
-			$pre_tags[$name] = substr( $pee_part, $start ) . '</pre>';
458
+			$pre_tags[$name] = substr($pee_part, $start).'</pre>';
459 459
 
460
-			$pee .= substr( $pee_part, 0, $start ) . $name;
460
+			$pee .= substr($pee_part, 0, $start).$name;
461 461
 			$i++;
462 462
 		}
463 463
 
@@ -469,41 +469,41 @@  discard block
 block discarded – undo
469 469
 	$allblocks = '(?:table|thead|tfoot|caption|col|colgroup|tbody|tr|td|th|div|dl|dd|dt|ul|ol|li|pre|form|map|area|blockquote|address|math|style|p|h[1-6]|hr|fieldset|legend|section|article|aside|hgroup|header|footer|nav|figure|figcaption|details|menu|summary)';
470 470
 
471 471
 	// Add a double line break above block-level opening tags.
472
-	$pee = preg_replace('!(<' . $allblocks . '[\s/>])!', "\n\n$1", $pee);
472
+	$pee = preg_replace('!(<'.$allblocks.'[\s/>])!', "\n\n$1", $pee);
473 473
 
474 474
 	// Add a double line break below block-level closing tags.
475
-	$pee = preg_replace('!(</' . $allblocks . '>)!', "$1\n\n", $pee);
475
+	$pee = preg_replace('!(</'.$allblocks.'>)!', "$1\n\n", $pee);
476 476
 
477 477
 	// Standardize newline characters to "\n".
478 478
 	$pee = str_replace(array("\r\n", "\r"), "\n", $pee);
479 479
 
480 480
 	// Find newlines in all elements and add placeholders.
481
-	$pee = wp_replace_in_html_tags( $pee, array( "\n" => " <!-- wpnl --> " ) );
481
+	$pee = wp_replace_in_html_tags($pee, array("\n" => " <!-- wpnl --> "));
482 482
 
483 483
 	// Collapse line breaks before and after <option> elements so they don't get autop'd.
484
-	if ( strpos( $pee, '<option' ) !== false ) {
485
-		$pee = preg_replace( '|\s*<option|', '<option', $pee );
486
-		$pee = preg_replace( '|</option>\s*|', '</option>', $pee );
484
+	if (strpos($pee, '<option') !== false) {
485
+		$pee = preg_replace('|\s*<option|', '<option', $pee);
486
+		$pee = preg_replace('|</option>\s*|', '</option>', $pee);
487 487
 	}
488 488
 
489 489
 	/*
490 490
 	 * Collapse line breaks inside <object> elements, before <param> and <embed> elements
491 491
 	 * so they don't get autop'd.
492 492
 	 */
493
-	if ( strpos( $pee, '</object>' ) !== false ) {
494
-		$pee = preg_replace( '|(<object[^>]*>)\s*|', '$1', $pee );
495
-		$pee = preg_replace( '|\s*</object>|', '</object>', $pee );
496
-		$pee = preg_replace( '%\s*(</?(?:param|embed)[^>]*>)\s*%', '$1', $pee );
493
+	if (strpos($pee, '</object>') !== false) {
494
+		$pee = preg_replace('|(<object[^>]*>)\s*|', '$1', $pee);
495
+		$pee = preg_replace('|\s*</object>|', '</object>', $pee);
496
+		$pee = preg_replace('%\s*(</?(?:param|embed)[^>]*>)\s*%', '$1', $pee);
497 497
 	}
498 498
 
499 499
 	/*
500 500
 	 * Collapse line breaks inside <audio> and <video> elements,
501 501
 	 * before and after <source> and <track> elements.
502 502
 	 */
503
-	if ( strpos( $pee, '<source' ) !== false || strpos( $pee, '<track' ) !== false ) {
504
-		$pee = preg_replace( '%([<\[](?:audio|video)[^>\]]*[>\]])\s*%', '$1', $pee );
505
-		$pee = preg_replace( '%\s*([<\[]/(?:audio|video)[>\]])%', '$1', $pee );
506
-		$pee = preg_replace( '%\s*(<(?:source|track)[^>]*>)\s*%', '$1', $pee );
503
+	if (strpos($pee, '<source') !== false || strpos($pee, '<track') !== false) {
504
+		$pee = preg_replace('%([<\[](?:audio|video)[^>\]]*[>\]])\s*%', '$1', $pee);
505
+		$pee = preg_replace('%\s*([<\[]/(?:audio|video)[>\]])%', '$1', $pee);
506
+		$pee = preg_replace('%\s*(<(?:source|track)[^>]*>)\s*%', '$1', $pee);
507 507
 	}
508 508
 
509 509
 	// Remove more than two contiguous line breaks.
@@ -516,8 +516,8 @@  discard block
 block discarded – undo
516 516
 	$pee = '';
517 517
 
518 518
 	// Rebuild the content as a string, wrapping every bit with a <p>.
519
-	foreach ( $pees as $tinkle ) {
520
-		$pee .= '<p>' . trim($tinkle, "\n") . "</p>\n";
519
+	foreach ($pees as $tinkle) {
520
+		$pee .= '<p>'.trim($tinkle, "\n")."</p>\n";
521 521
 	}
522 522
 
523 523
 	// Under certain strange conditions it could create a P of entirely whitespace.
@@ -527,7 +527,7 @@  discard block
 block discarded – undo
527 527
 	$pee = preg_replace('!<p>([^<]+)</(div|address|form)>!', "<p>$1</p></$2>", $pee);
528 528
 
529 529
 	// If an opening or closing block element tag is wrapped in a <p>, unwrap it.
530
-	$pee = preg_replace('!<p>\s*(</?' . $allblocks . '[^>]*>)\s*</p>!', "$1", $pee);
530
+	$pee = preg_replace('!<p>\s*(</?'.$allblocks.'[^>]*>)\s*</p>!', "$1", $pee);
531 531
 
532 532
 	// In some cases <li> may get wrapped in <p>, fix them.
533 533
 	$pee = preg_replace("|<p>(<li.+?)</p>|", "$1", $pee);
@@ -537,18 +537,18 @@  discard block
 block discarded – undo
537 537
 	$pee = str_replace('</blockquote></p>', '</p></blockquote>', $pee);
538 538
 
539 539
 	// If an opening or closing block element tag is preceded by an opening <p> tag, remove it.
540
-	$pee = preg_replace('!<p>\s*(</?' . $allblocks . '[^>]*>)!', "$1", $pee);
540
+	$pee = preg_replace('!<p>\s*(</?'.$allblocks.'[^>]*>)!', "$1", $pee);
541 541
 
542 542
 	// If an opening or closing block element tag is followed by a closing <p> tag, remove it.
543
-	$pee = preg_replace('!(</?' . $allblocks . '[^>]*>)\s*</p>!', "$1", $pee);
543
+	$pee = preg_replace('!(</?'.$allblocks.'[^>]*>)\s*</p>!', "$1", $pee);
544 544
 
545 545
 	// Optionally insert line breaks.
546
-	if ( $br ) {
546
+	if ($br) {
547 547
 		// Replace newlines that shouldn't be touched with a placeholder.
548 548
 		$pee = preg_replace_callback('/<(script|style).*?<\/\\1>/s', '_autop_newline_preservation_helper', $pee);
549 549
 
550 550
 		// Normalize <br>
551
-		$pee = str_replace( array( '<br>', '<br/>' ), '<br />', $pee );
551
+		$pee = str_replace(array('<br>', '<br/>'), '<br />', $pee);
552 552
 
553 553
 		// Replace any new line characters that aren't preceded by a <br /> with a <br />.
554 554
 		$pee = preg_replace('|(?<!<br />)\s*\n|', "<br />\n", $pee);
@@ -558,19 +558,19 @@  discard block
 block discarded – undo
558 558
 	}
559 559
 
560 560
 	// If a <br /> tag is after an opening or closing block tag, remove it.
561
-	$pee = preg_replace('!(</?' . $allblocks . '[^>]*>)\s*<br />!', "$1", $pee);
561
+	$pee = preg_replace('!(</?'.$allblocks.'[^>]*>)\s*<br />!', "$1", $pee);
562 562
 
563 563
 	// If a <br /> tag is before a subset of opening or closing block tags, remove it.
564 564
 	$pee = preg_replace('!<br />(\s*</?(?:p|li|div|dl|dd|dt|th|pre|td|ul|ol)[^>]*>)!', '$1', $pee);
565
-	$pee = preg_replace( "|\n</p>$|", '</p>', $pee );
565
+	$pee = preg_replace("|\n</p>$|", '</p>', $pee);
566 566
 
567 567
 	// Replace placeholder <pre> tags with their original content.
568
-	if ( !empty($pre_tags) )
568
+	if ( ! empty($pre_tags))
569 569
 		$pee = str_replace(array_keys($pre_tags), array_values($pre_tags), $pee);
570 570
 
571 571
 	// Restore newlines in all elements.
572
-	if ( false !== strpos( $pee, '<!-- wpnl -->' ) ) {
573
-		$pee = str_replace( array( ' <!-- wpnl --> ', '<!-- wpnl -->' ), "\n", $pee );
572
+	if (false !== strpos($pee, '<!-- wpnl -->')) {
573
+		$pee = str_replace(array(' <!-- wpnl --> ', '<!-- wpnl -->'), "\n", $pee);
574 574
 	}
575 575
 
576 576
 	return $pee;
@@ -584,8 +584,8 @@  discard block
 block discarded – undo
584 584
  * @param string $input The text which has to be formatted.
585 585
  * @return array The formatted text.
586 586
  */
587
-function wp_html_split( $input ) {
588
-	return preg_split( get_html_split_regex(), $input, -1, PREG_SPLIT_DELIM_CAPTURE );
587
+function wp_html_split($input) {
588
+	return preg_split(get_html_split_regex(), $input, -1, PREG_SPLIT_DELIM_CAPTURE);
589 589
 }
590 590
 
591 591
 /**
@@ -598,14 +598,14 @@  discard block
 block discarded – undo
598 598
 function get_html_split_regex() {
599 599
 	static $regex;
600 600
 
601
-	if ( ! isset( $regex ) ) {
601
+	if ( ! isset($regex)) {
602 602
 		$comments =
603 603
 			  '!'           // Start of comment, after the <.
604 604
 			. '(?:'         // Unroll the loop: Consume everything until --> is found.
605 605
 			.     '-(?!->)' // Dash not followed by end of comment.
606 606
 			.     '[^\-]*+' // Consume non-dashes.
607 607
 			. ')*+'         // Loop possessively.
608
-			. '(?:-->)?';   // End of comment. If not found, match all input.
608
+			. '(?:-->)?'; // End of comment. If not found, match all input.
609 609
 
610 610
 		$cdata =
611 611
 			  '!\[CDATA\['  // Start of comment, after the <.
@@ -614,7 +614,7 @@  discard block
 block discarded – undo
614 614
 			.     '](?!]>)' // One ] not followed by end of comment.
615 615
 			.     '[^\]]*+' // Consume non-].
616 616
 			. ')*+'         // Loop possessively.
617
-			. '(?:]]>)?';   // End of comment. If not found, match all input.
617
+			. '(?:]]>)?'; // End of comment. If not found, match all input.
618 618
 
619 619
 		$escaped =
620 620
 			  '(?='           // Is the element escaped?
@@ -653,19 +653,19 @@  discard block
 block discarded – undo
653 653
  * @param string $shortcode_regex The result from _get_wptexturize_shortcode_regex().  Optional.
654 654
  * @return string The regular expression
655 655
  */
656
-function _get_wptexturize_split_regex( $shortcode_regex = '' ) {
656
+function _get_wptexturize_split_regex($shortcode_regex = '') {
657 657
 	static $html_regex;
658 658
 
659
-	if ( ! isset( $html_regex ) ) {
659
+	if ( ! isset($html_regex)) {
660 660
 		$comment_regex =
661 661
 			  '!'           // Start of comment, after the <.
662 662
 			. '(?:'         // Unroll the loop: Consume everything until --> is found.
663 663
 			.     '-(?!->)' // Dash not followed by end of comment.
664 664
 			.     '[^\-]*+' // Consume non-dashes.
665 665
 			. ')*+'         // Loop possessively.
666
-			. '(?:-->)?';   // End of comment. If not found, match all input.
666
+			. '(?:-->)?'; // End of comment. If not found, match all input.
667 667
 
668
-		$html_regex =			 // Needs replaced with wp_html_split() per Shortcode API Roadmap.
668
+		$html_regex = // Needs replaced with wp_html_split() per Shortcode API Roadmap.
669 669
 			  '<'                // Find start of element.
670 670
 			. '(?(?=!--)'        // Is this a comment?
671 671
 			.     $comment_regex // Find end of comment.
@@ -674,10 +674,10 @@  discard block
 block discarded – undo
674 674
 			. ')';
675 675
 	}
676 676
 
677
-	if ( empty( $shortcode_regex ) ) {
678
-		$regex = '/(' . $html_regex . ')/';
677
+	if (empty($shortcode_regex)) {
678
+		$regex = '/('.$html_regex.')/';
679 679
 	} else {
680
-		$regex = '/(' . $html_regex . '|' . $shortcode_regex . ')/';
680
+		$regex = '/('.$html_regex.'|'.$shortcode_regex.')/';
681 681
 	}
682 682
 
683 683
 	return $regex;
@@ -694,8 +694,8 @@  discard block
 block discarded – undo
694 694
  * @param array $tagnames List of shortcodes to find.
695 695
  * @return string The regular expression
696 696
  */
697
-function _get_wptexturize_shortcode_regex( $tagnames ) {
698
-	$tagregexp = join( '|', array_map( 'preg_quote', $tagnames ) );
697
+function _get_wptexturize_shortcode_regex($tagnames) {
698
+	$tagregexp = join('|', array_map('preg_quote', $tagnames));
699 699
 	$tagregexp = "(?:$tagregexp)(?=[\\s\\]\\/])"; // Excerpt of get_shortcode_regex().
700 700
 	$regex =
701 701
 		  '\['              // Find start of shortcode.
@@ -707,7 +707,7 @@  discard block
 block discarded – undo
707 707
 		.     '<[^\[\]>]*>' // HTML elements permitted. Prevents matching ] before >.
708 708
 		. ')*+'             // Possessive critical.
709 709
 		. '\]'              // Find end of shortcode.
710
-		. '\]?';            // Shortcodes may end with ]]
710
+		. '\]?'; // Shortcodes may end with ]]
711 711
 
712 712
 	return $regex;
713 713
 }
@@ -721,32 +721,32 @@  discard block
 block discarded – undo
721 721
  * @param array $replace_pairs In the form array('from' => 'to', ...).
722 722
  * @return string The formatted text.
723 723
  */
724
-function wp_replace_in_html_tags( $haystack, $replace_pairs ) {
724
+function wp_replace_in_html_tags($haystack, $replace_pairs) {
725 725
 	// Find all elements.
726
-	$textarr = wp_html_split( $haystack );
726
+	$textarr = wp_html_split($haystack);
727 727
 	$changed = false;
728 728
 
729 729
 	// Optimize when searching for one item.
730
-	if ( 1 === count( $replace_pairs ) ) {
730
+	if (1 === count($replace_pairs)) {
731 731
 		// Extract $needle and $replace.
732
-		foreach ( $replace_pairs as $needle => $replace );
732
+		foreach ($replace_pairs as $needle => $replace);
733 733
 
734 734
 		// Loop through delimiters (elements) only.
735
-		for ( $i = 1, $c = count( $textarr ); $i < $c; $i += 2 ) {
736
-			if ( false !== strpos( $textarr[$i], $needle ) ) {
737
-				$textarr[$i] = str_replace( $needle, $replace, $textarr[$i] );
735
+		for ($i = 1, $c = count($textarr); $i < $c; $i += 2) {
736
+			if (false !== strpos($textarr[$i], $needle)) {
737
+				$textarr[$i] = str_replace($needle, $replace, $textarr[$i]);
738 738
 				$changed = true;
739 739
 			}
740 740
 		}
741 741
 	} else {
742 742
 		// Extract all $needles.
743
-		$needles = array_keys( $replace_pairs );
743
+		$needles = array_keys($replace_pairs);
744 744
 
745 745
 		// Loop through delimiters (elements) only.
746
-		for ( $i = 1, $c = count( $textarr ); $i < $c; $i += 2 ) {
747
-			foreach ( $needles as $needle ) {
748
-				if ( false !== strpos( $textarr[$i], $needle ) ) {
749
-					$textarr[$i] = strtr( $textarr[$i], $replace_pairs );
746
+		for ($i = 1, $c = count($textarr); $i < $c; $i += 2) {
747
+			foreach ($needles as $needle) {
748
+				if (false !== strpos($textarr[$i], $needle)) {
749
+					$textarr[$i] = strtr($textarr[$i], $replace_pairs);
750 750
 					$changed = true;
751 751
 					// After one strtr() break out of the foreach loop and look at next element.
752 752
 					break;
@@ -755,8 +755,8 @@  discard block
 block discarded – undo
755 755
 		}
756 756
 	}
757 757
 
758
-	if ( $changed ) {
759
-		$haystack = implode( $textarr );
758
+	if ($changed) {
759
+		$haystack = implode($textarr);
760 760
 	}
761 761
 
762 762
 	return $haystack;
@@ -771,8 +771,8 @@  discard block
 block discarded – undo
771 771
  * @param array $matches preg_replace_callback matches array
772 772
  * @return string
773 773
  */
774
-function _autop_newline_preservation_helper( $matches ) {
775
-	return str_replace( "\n", "<WPPreserveNewline />", $matches[0] );
774
+function _autop_newline_preservation_helper($matches) {
775
+	return str_replace("\n", "<WPPreserveNewline />", $matches[0]);
776 776
 }
777 777
 
778 778
 /**
@@ -787,20 +787,20 @@  discard block
 block discarded – undo
787 787
  * @param string $pee The content.
788 788
  * @return string The filtered content.
789 789
  */
790
-function shortcode_unautop( $pee ) {
790
+function shortcode_unautop($pee) {
791 791
 	global $shortcode_tags;
792 792
 
793
-	if ( empty( $shortcode_tags ) || !is_array( $shortcode_tags ) ) {
793
+	if (empty($shortcode_tags) || ! is_array($shortcode_tags)) {
794 794
 		return $pee;
795 795
 	}
796 796
 
797
-	$tagregexp = join( '|', array_map( 'preg_quote', array_keys( $shortcode_tags ) ) );
797
+	$tagregexp = join('|', array_map('preg_quote', array_keys($shortcode_tags)));
798 798
 	$spaces = wp_spaces_regexp();
799 799
 
800 800
 	$pattern =
801 801
 		  '/'
802 802
 		. '<p>'                              // Opening paragraph
803
-		. '(?:' . $spaces . ')*+'            // Optional leading whitespace
803
+		. '(?:'.$spaces.')*+'            // Optional leading whitespace
804 804
 		. '('                                // 1: The shortcode
805 805
 		.     '\\['                          // Opening bracket
806 806
 		.     "($tagregexp)"                 // 2: Shortcode name
@@ -825,11 +825,11 @@  discard block
 block discarded – undo
825 825
 		.         ')?'
826 826
 		.     ')'
827 827
 		. ')'
828
-		. '(?:' . $spaces . ')*+'            // optional trailing whitespace
828
+		. '(?:'.$spaces.')*+'            // optional trailing whitespace
829 829
 		. '<\\/p>'                           // closing paragraph
830 830
 		. '/';
831 831
 
832
-	return preg_replace( $pattern, '$1', $pee );
832
+	return preg_replace($pattern, '$1', $pee);
833 833
 }
834 834
 
835 835
 /**
@@ -844,20 +844,20 @@  discard block
 block discarded – undo
844 844
  * @param string $str The string to be checked
845 845
  * @return bool True if $str fits a UTF-8 model, false otherwise.
846 846
  */
847
-function seems_utf8( $str ) {
847
+function seems_utf8($str) {
848 848
 	mbstring_binary_safe_encoding();
849 849
 	$length = strlen($str);
850 850
 	reset_mbstring_encoding();
851
-	for ($i=0; $i < $length; $i++) {
851
+	for ($i = 0; $i < $length; $i++) {
852 852
 		$c = ord($str[$i]);
853 853
 		if ($c < 0x80) $n = 0; // 0bbbbbbb
854
-		elseif (($c & 0xE0) == 0xC0) $n=1; // 110bbbbb
855
-		elseif (($c & 0xF0) == 0xE0) $n=2; // 1110bbbb
856
-		elseif (($c & 0xF8) == 0xF0) $n=3; // 11110bbb
857
-		elseif (($c & 0xFC) == 0xF8) $n=4; // 111110bb
858
-		elseif (($c & 0xFE) == 0xFC) $n=5; // 1111110b
854
+		elseif (($c & 0xE0) == 0xC0) $n = 1; // 110bbbbb
855
+		elseif (($c & 0xF0) == 0xE0) $n = 2; // 1110bbbb
856
+		elseif (($c & 0xF8) == 0xF0) $n = 3; // 11110bbb
857
+		elseif (($c & 0xFC) == 0xF8) $n = 4; // 111110bb
858
+		elseif (($c & 0xFE) == 0xFC) $n = 5; // 1111110b
859 859
 		else return false; // Does not match any model
860
-		for ($j=0; $j<$n; $j++) { // n bytes matching 10bbbbbb follow ?
860
+		for ($j = 0; $j < $n; $j++) { // n bytes matching 10bbbbbb follow ?
861 861
 			if ((++$i == $length) || ((ord($str[$i]) & 0xC0) != 0x80))
862 862
 				return false;
863 863
 		}
@@ -888,55 +888,55 @@  discard block
 block discarded – undo
888 888
  * @param bool       $double_encode  Optional. Whether to encode existing html entities. Default is false.
889 889
  * @return string The encoded text with HTML entities.
890 890
  */
891
-function _wp_specialchars( $string, $quote_style = ENT_NOQUOTES, $charset = false, $double_encode = false ) {
891
+function _wp_specialchars($string, $quote_style = ENT_NOQUOTES, $charset = false, $double_encode = false) {
892 892
 	$string = (string) $string;
893 893
 
894
-	if ( 0 === strlen( $string ) )
894
+	if (0 === strlen($string))
895 895
 		return '';
896 896
 
897 897
 	// Don't bother if there are no specialchars - saves some processing
898
-	if ( ! preg_match( '/[&<>"\']/', $string ) )
898
+	if ( ! preg_match('/[&<>"\']/', $string))
899 899
 		return $string;
900 900
 
901 901
 	// Account for the previous behaviour of the function when the $quote_style is not an accepted value
902
-	if ( empty( $quote_style ) )
902
+	if (empty($quote_style))
903 903
 		$quote_style = ENT_NOQUOTES;
904
-	elseif ( ! in_array( $quote_style, array( 0, 2, 3, 'single', 'double' ), true ) )
904
+	elseif ( ! in_array($quote_style, array(0, 2, 3, 'single', 'double'), true))
905 905
 		$quote_style = ENT_QUOTES;
906 906
 
907 907
 	// Store the site charset as a static to avoid multiple calls to wp_load_alloptions()
908
-	if ( ! $charset ) {
908
+	if ( ! $charset) {
909 909
 		static $_charset = null;
910
-		if ( ! isset( $_charset ) ) {
910
+		if ( ! isset($_charset)) {
911 911
 			$alloptions = wp_load_alloptions();
912
-			$_charset = isset( $alloptions['blog_charset'] ) ? $alloptions['blog_charset'] : '';
912
+			$_charset = isset($alloptions['blog_charset']) ? $alloptions['blog_charset'] : '';
913 913
 		}
914 914
 		$charset = $_charset;
915 915
 	}
916 916
 
917
-	if ( in_array( $charset, array( 'utf8', 'utf-8', 'UTF8' ) ) )
917
+	if (in_array($charset, array('utf8', 'utf-8', 'UTF8')))
918 918
 		$charset = 'UTF-8';
919 919
 
920 920
 	$_quote_style = $quote_style;
921 921
 
922
-	if ( $quote_style === 'double' ) {
922
+	if ($quote_style === 'double') {
923 923
 		$quote_style = ENT_COMPAT;
924 924
 		$_quote_style = ENT_COMPAT;
925
-	} elseif ( $quote_style === 'single' ) {
925
+	} elseif ($quote_style === 'single') {
926 926
 		$quote_style = ENT_NOQUOTES;
927 927
 	}
928 928
 
929
-	if ( ! $double_encode ) {
929
+	if ( ! $double_encode) {
930 930
 		// Guarantee every &entity; is valid, convert &garbage; into &amp;garbage;
931 931
 		// This is required for PHP < 5.4.0 because ENT_HTML401 flag is unavailable.
932
-		$string = wp_kses_normalize_entities( $string );
932
+		$string = wp_kses_normalize_entities($string);
933 933
 	}
934 934
 
935
-	$string = @htmlspecialchars( $string, $quote_style, $charset, $double_encode );
935
+	$string = @htmlspecialchars($string, $quote_style, $charset, $double_encode);
936 936
 
937 937
 	// Back-compat.
938
-	if ( 'single' === $_quote_style )
939
-		$string = str_replace( "'", '&#039;', $string );
938
+	if ('single' === $_quote_style)
939
+		$string = str_replace("'", '&#039;', $string);
940 940
 
941 941
 	return $string;
942 942
 }
@@ -961,52 +961,52 @@  discard block
 block discarded – undo
961 961
  *                                Default is ENT_NOQUOTES.
962 962
  * @return string The decoded text without HTML entities.
963 963
  */
964
-function wp_specialchars_decode( $string, $quote_style = ENT_NOQUOTES ) {
964
+function wp_specialchars_decode($string, $quote_style = ENT_NOQUOTES) {
965 965
 	$string = (string) $string;
966 966
 
967
-	if ( 0 === strlen( $string ) ) {
967
+	if (0 === strlen($string)) {
968 968
 		return '';
969 969
 	}
970 970
 
971 971
 	// Don't bother if there are no entities - saves a lot of processing
972
-	if ( strpos( $string, '&' ) === false ) {
972
+	if (strpos($string, '&') === false) {
973 973
 		return $string;
974 974
 	}
975 975
 
976 976
 	// Match the previous behaviour of _wp_specialchars() when the $quote_style is not an accepted value
977
-	if ( empty( $quote_style ) ) {
977
+	if (empty($quote_style)) {
978 978
 		$quote_style = ENT_NOQUOTES;
979
-	} elseif ( !in_array( $quote_style, array( 0, 2, 3, 'single', 'double' ), true ) ) {
979
+	} elseif ( ! in_array($quote_style, array(0, 2, 3, 'single', 'double'), true)) {
980 980
 		$quote_style = ENT_QUOTES;
981 981
 	}
982 982
 
983 983
 	// More complete than get_html_translation_table( HTML_SPECIALCHARS )
984
-	$single = array( '&#039;'  => '\'', '&#x27;' => '\'' );
985
-	$single_preg = array( '/&#0*39;/'  => '&#039;', '/&#x0*27;/i' => '&#x27;' );
986
-	$double = array( '&quot;' => '"', '&#034;'  => '"', '&#x22;' => '"' );
987
-	$double_preg = array( '/&#0*34;/'  => '&#034;', '/&#x0*22;/i' => '&#x22;' );
988
-	$others = array( '&lt;'   => '<', '&#060;'  => '<', '&gt;'   => '>', '&#062;'  => '>', '&amp;'  => '&', '&#038;'  => '&', '&#x26;' => '&' );
989
-	$others_preg = array( '/&#0*60;/'  => '&#060;', '/&#0*62;/'  => '&#062;', '/&#0*38;/'  => '&#038;', '/&#x0*26;/i' => '&#x26;' );
990
-
991
-	if ( $quote_style === ENT_QUOTES ) {
992
-		$translation = array_merge( $single, $double, $others );
993
-		$translation_preg = array_merge( $single_preg, $double_preg, $others_preg );
994
-	} elseif ( $quote_style === ENT_COMPAT || $quote_style === 'double' ) {
995
-		$translation = array_merge( $double, $others );
996
-		$translation_preg = array_merge( $double_preg, $others_preg );
997
-	} elseif ( $quote_style === 'single' ) {
998
-		$translation = array_merge( $single, $others );
999
-		$translation_preg = array_merge( $single_preg, $others_preg );
1000
-	} elseif ( $quote_style === ENT_NOQUOTES ) {
984
+	$single = array('&#039;'  => '\'', '&#x27;' => '\'');
985
+	$single_preg = array('/&#0*39;/'  => '&#039;', '/&#x0*27;/i' => '&#x27;');
986
+	$double = array('&quot;' => '"', '&#034;'  => '"', '&#x22;' => '"');
987
+	$double_preg = array('/&#0*34;/'  => '&#034;', '/&#x0*22;/i' => '&#x22;');
988
+	$others = array('&lt;'   => '<', '&#060;'  => '<', '&gt;'   => '>', '&#062;'  => '>', '&amp;'  => '&', '&#038;'  => '&', '&#x26;' => '&');
989
+	$others_preg = array('/&#0*60;/'  => '&#060;', '/&#0*62;/'  => '&#062;', '/&#0*38;/'  => '&#038;', '/&#x0*26;/i' => '&#x26;');
990
+
991
+	if ($quote_style === ENT_QUOTES) {
992
+		$translation = array_merge($single, $double, $others);
993
+		$translation_preg = array_merge($single_preg, $double_preg, $others_preg);
994
+	} elseif ($quote_style === ENT_COMPAT || $quote_style === 'double') {
995
+		$translation = array_merge($double, $others);
996
+		$translation_preg = array_merge($double_preg, $others_preg);
997
+	} elseif ($quote_style === 'single') {
998
+		$translation = array_merge($single, $others);
999
+		$translation_preg = array_merge($single_preg, $others_preg);
1000
+	} elseif ($quote_style === ENT_NOQUOTES) {
1001 1001
 		$translation = $others;
1002 1002
 		$translation_preg = $others_preg;
1003 1003
 	}
1004 1004
 
1005 1005
 	// Remove zero padding on numeric entities
1006
-	$string = preg_replace( array_keys( $translation_preg ), array_values( $translation_preg ), $string );
1006
+	$string = preg_replace(array_keys($translation_preg), array_values($translation_preg), $string);
1007 1007
 
1008 1008
 	// Replace characters according to translation table
1009
-	return strtr( $string, $translation );
1009
+	return strtr($string, $translation);
1010 1010
 }
1011 1011
 
1012 1012
 /**
@@ -1021,40 +1021,40 @@  discard block
 block discarded – undo
1021 1021
  * @param bool    $strip Optional. Whether to attempt to strip out invalid UTF8. Default is false.
1022 1022
  * @return string The checked text.
1023 1023
  */
1024
-function wp_check_invalid_utf8( $string, $strip = false ) {
1024
+function wp_check_invalid_utf8($string, $strip = false) {
1025 1025
 	$string = (string) $string;
1026 1026
 
1027
-	if ( 0 === strlen( $string ) ) {
1027
+	if (0 === strlen($string)) {
1028 1028
 		return '';
1029 1029
 	}
1030 1030
 
1031 1031
 	// Store the site charset as a static to avoid multiple calls to get_option()
1032 1032
 	static $is_utf8 = null;
1033
-	if ( ! isset( $is_utf8 ) ) {
1034
-		$is_utf8 = in_array( get_option( 'blog_charset' ), array( 'utf8', 'utf-8', 'UTF8', 'UTF-8' ) );
1033
+	if ( ! isset($is_utf8)) {
1034
+		$is_utf8 = in_array(get_option('blog_charset'), array('utf8', 'utf-8', 'UTF8', 'UTF-8'));
1035 1035
 	}
1036
-	if ( ! $is_utf8 ) {
1036
+	if ( ! $is_utf8) {
1037 1037
 		return $string;
1038 1038
 	}
1039 1039
 
1040 1040
 	// Check for support for utf8 in the installed PCRE library once and store the result in a static
1041 1041
 	static $utf8_pcre = null;
1042
-	if ( ! isset( $utf8_pcre ) ) {
1043
-		$utf8_pcre = @preg_match( '/^./u', 'a' );
1042
+	if ( ! isset($utf8_pcre)) {
1043
+		$utf8_pcre = @preg_match('/^./u', 'a');
1044 1044
 	}
1045 1045
 	// We can't demand utf8 in the PCRE installation, so just return the string in those cases
1046
-	if ( !$utf8_pcre ) {
1046
+	if ( ! $utf8_pcre) {
1047 1047
 		return $string;
1048 1048
 	}
1049 1049
 
1050 1050
 	// preg_match fails when it encounters invalid UTF8 in $string
1051
-	if ( 1 === @preg_match( '/^./us', $string ) ) {
1051
+	if (1 === @preg_match('/^./us', $string)) {
1052 1052
 		return $string;
1053 1053
 	}
1054 1054
 
1055 1055
 	// Attempt to strip the bad chars if requested (not recommended)
1056
-	if ( $strip && function_exists( 'iconv' ) ) {
1057
-		return iconv( 'utf-8', 'utf-8', $string );
1056
+	if ($strip && function_exists('iconv')) {
1057
+		return iconv('utf-8', 'utf-8', $string);
1058 1058
 	}
1059 1059
 
1060 1060
 	return '';
@@ -1069,30 +1069,30 @@  discard block
 block discarded – undo
1069 1069
  * @param int    $length Max  length of the string
1070 1070
  * @return string String with Unicode encoded for URI.
1071 1071
  */
1072
-function utf8_uri_encode( $utf8_string, $length = 0 ) {
1072
+function utf8_uri_encode($utf8_string, $length = 0) {
1073 1073
 	$unicode = '';
1074 1074
 	$values = array();
1075 1075
 	$num_octets = 1;
1076 1076
 	$unicode_length = 0;
1077 1077
 
1078 1078
 	mbstring_binary_safe_encoding();
1079
-	$string_length = strlen( $utf8_string );
1079
+	$string_length = strlen($utf8_string);
1080 1080
 	reset_mbstring_encoding();
1081 1081
 
1082
-	for ($i = 0; $i < $string_length; $i++ ) {
1082
+	for ($i = 0; $i < $string_length; $i++) {
1083 1083
 
1084
-		$value = ord( $utf8_string[ $i ] );
1084
+		$value = ord($utf8_string[$i]);
1085 1085
 
1086
-		if ( $value < 128 ) {
1087
-			if ( $length && ( $unicode_length >= $length ) )
1086
+		if ($value < 128) {
1087
+			if ($length && ($unicode_length >= $length))
1088 1088
 				break;
1089 1089
 			$unicode .= chr($value);
1090 1090
 			$unicode_length++;
1091 1091
 		} else {
1092
-			if ( count( $values ) == 0 ) {
1093
-				if ( $value < 224 ) {
1092
+			if (count($values) == 0) {
1093
+				if ($value < 224) {
1094 1094
 					$num_octets = 2;
1095
-				} elseif ( $value < 240 ) {
1095
+				} elseif ($value < 240) {
1096 1096
 					$num_octets = 3;
1097 1097
 				} else {
1098 1098
 					$num_octets = 4;
@@ -1101,11 +1101,11 @@  discard block
 block discarded – undo
1101 1101
 
1102 1102
 			$values[] = $value;
1103 1103
 
1104
-			if ( $length && ( $unicode_length + ($num_octets * 3) ) > $length )
1104
+			if ($length && ($unicode_length + ($num_octets * 3)) > $length)
1105 1105
 				break;
1106
-			if ( count( $values ) == $num_octets ) {
1107
-				for ( $j = 0; $j < $num_octets; $j++ ) {
1108
-					$unicode .= '%' . dechex( $values[ $j ] );
1106
+			if (count($values) == $num_octets) {
1107
+				for ($j = 0; $j < $num_octets; $j++) {
1108
+					$unicode .= '%'.dechex($values[$j]);
1109 1109
 				}
1110 1110
 
1111 1111
 				$unicode_length += $num_octets * 3;
@@ -1504,8 +1504,8 @@  discard block
 block discarded – undo
1504 1504
  * @param string $string Text that might have accent characters
1505 1505
  * @return string Filtered string with replaced "nice" characters.
1506 1506
  */
1507
-function remove_accents( $string ) {
1508
-	if ( !preg_match('/[\x80-\xff]/', $string) )
1507
+function remove_accents($string) {
1508
+	if ( ! preg_match('/[\x80-\xff]/', $string))
1509 1509
 		return $string;
1510 1510
 
1511 1511
 	if (seems_utf8($string)) {
@@ -1515,7 +1515,7 @@  discard block
 block discarded – undo
1515 1515
 		'À' => 'A', 'Á' => 'A',
1516 1516
 		'Â' => 'A', 'Ã' => 'A',
1517 1517
 		'Ä' => 'A', 'Å' => 'A',
1518
-		'Æ' => 'AE','Ç' => 'C',
1518
+		'Æ' => 'AE', 'Ç' => 'C',
1519 1519
 		'È' => 'E', 'É' => 'E',
1520 1520
 		'Ê' => 'E', 'Ë' => 'E',
1521 1521
 		'Ì' => 'I', 'Í' => 'I',
@@ -1526,11 +1526,11 @@  discard block
 block discarded – undo
1526 1526
 		'Ö' => 'O', 'Ù' => 'U',
1527 1527
 		'Ú' => 'U', 'Û' => 'U',
1528 1528
 		'Ü' => 'U', 'Ý' => 'Y',
1529
-		'Þ' => 'TH','ß' => 's',
1529
+		'Þ' => 'TH', 'ß' => 's',
1530 1530
 		'à' => 'a', 'á' => 'a',
1531 1531
 		'â' => 'a', 'ã' => 'a',
1532 1532
 		'ä' => 'a', 'å' => 'a',
1533
-		'æ' => 'ae','ç' => 'c',
1533
+		'æ' => 'ae', 'ç' => 'c',
1534 1534
 		'è' => 'e', 'é' => 'e',
1535 1535
 		'ê' => 'e', 'ë' => 'e',
1536 1536
 		'ì' => 'i', 'í' => 'i',
@@ -1569,7 +1569,7 @@  discard block
 block discarded – undo
1569 1569
 		'Ĭ' => 'I', 'ĭ' => 'i',
1570 1570
 		'Į' => 'I', 'į' => 'i',
1571 1571
 		'İ' => 'I', 'ı' => 'i',
1572
-		'IJ' => 'IJ','ij' => 'ij',
1572
+		'IJ' => 'IJ', 'ij' => 'ij',
1573 1573
 		'Ĵ' => 'J', 'ĵ' => 'j',
1574 1574
 		'Ķ' => 'K', 'ķ' => 'k',
1575 1575
 		'ĸ' => 'k', 'Ĺ' => 'L',
@@ -1585,13 +1585,13 @@  discard block
 block discarded – undo
1585 1585
 		'Ō' => 'O', 'ō' => 'o',
1586 1586
 		'Ŏ' => 'O', 'ŏ' => 'o',
1587 1587
 		'Ő' => 'O', 'ő' => 'o',
1588
-		'Œ' => 'OE','œ' => 'oe',
1589
-		'Ŕ' => 'R','ŕ' => 'r',
1590
-		'Ŗ' => 'R','ŗ' => 'r',
1591
-		'Ř' => 'R','ř' => 'r',
1592
-		'Ś' => 'S','ś' => 's',
1593
-		'Ŝ' => 'S','ŝ' => 's',
1594
-		'Ş' => 'S','ş' => 's',
1588
+		'Œ' => 'OE', 'œ' => 'oe',
1589
+		'Ŕ' => 'R', 'ŕ' => 'r',
1590
+		'Ŗ' => 'R', 'ŗ' => 'r',
1591
+		'Ř' => 'R', 'ř' => 'r',
1592
+		'Ś' => 'S', 'ś' => 's',
1593
+		'Ŝ' => 'S', 'ŝ' => 's',
1594
+		'Ş' => 'S', 'ş' => 's',
1595 1595
 		'Š' => 'S', 'š' => 's',
1596 1596
 		'Ţ' => 'T', 'ţ' => 't',
1597 1597
 		'Ť' => 'T', 'ť' => 't',
@@ -1688,26 +1688,26 @@  discard block
 block discarded – undo
1688 1688
 		// Used for locale-specific rules
1689 1689
 		$locale = get_locale();
1690 1690
 
1691
-		if ( 'de_DE' == $locale || 'de_DE_formal' == $locale || 'de_CH' == $locale || 'de_CH_informal' == $locale ) {
1692
-			$chars[ 'Ä' ] = 'Ae';
1693
-			$chars[ 'ä' ] = 'ae';
1694
-			$chars[ 'Ö' ] = 'Oe';
1695
-			$chars[ 'ö' ] = 'oe';
1696
-			$chars[ 'Ü' ] = 'Ue';
1697
-			$chars[ 'ü' ] = 'ue';
1698
-			$chars[ 'ß' ] = 'ss';
1699
-		} elseif ( 'da_DK' === $locale ) {
1700
-			$chars[ 'Æ' ] = 'Ae';
1701
- 			$chars[ 'æ' ] = 'ae';
1702
-			$chars[ 'Ø' ] = 'Oe';
1703
-			$chars[ 'ø' ] = 'oe';
1704
-			$chars[ 'Å' ] = 'Aa';
1705
-			$chars[ 'å' ] = 'aa';
1706
-		} elseif ( 'ca' === $locale ) {
1707
-			$chars[ 'l·l' ] = 'll';
1708
-		} elseif ( 'sr_RS' === $locale ) {
1709
-			$chars[ 'Đ' ] = 'DJ';
1710
-			$chars[ 'đ' ] = 'dj';
1691
+		if ('de_DE' == $locale || 'de_DE_formal' == $locale || 'de_CH' == $locale || 'de_CH_informal' == $locale) {
1692
+			$chars['Ä'] = 'Ae';
1693
+			$chars['ä'] = 'ae';
1694
+			$chars['Ö'] = 'Oe';
1695
+			$chars['ö'] = 'oe';
1696
+			$chars['Ü'] = 'Ue';
1697
+			$chars['ü'] = 'ue';
1698
+			$chars['ß'] = 'ss';
1699
+		} elseif ('da_DK' === $locale) {
1700
+			$chars['Æ'] = 'Ae';
1701
+ 			$chars['æ'] = 'ae';
1702
+			$chars['Ø'] = 'Oe';
1703
+			$chars['ø'] = 'oe';
1704
+			$chars['Å'] = 'Aa';
1705
+			$chars['å'] = 'aa';
1706
+		} elseif ('ca' === $locale) {
1707
+			$chars['l·l'] = 'll';
1708
+		} elseif ('sr_RS' === $locale) {
1709
+			$chars['Đ'] = 'DJ';
1710
+			$chars['đ'] = 'dj';
1711 1711
 		}
1712 1712
 
1713 1713
 		$string = strtr($string, $chars);
@@ -1752,7 +1752,7 @@  discard block
 block discarded – undo
1752 1752
  * @param string $filename The filename to be sanitized
1753 1753
  * @return string The sanitized filename
1754 1754
  */
1755
-function sanitize_file_name( $filename ) {
1755
+function sanitize_file_name($filename) {
1756 1756
 	$filename_raw = $filename;
1757 1757
 	$special_chars = array("?", "[", "]", "/", "\\", "=", "<", ">", ":", ";", ",", "'", "\"", "&", "$", "#", "*", "(", ")", "|", "~", "`", "!", "{", "}", "%", "+", chr(0));
1758 1758
 	/**
@@ -1763,18 +1763,18 @@  discard block
 block discarded – undo
1763 1763
 	 * @param array  $special_chars Characters to remove.
1764 1764
 	 * @param string $filename_raw  Filename as it was passed into sanitize_file_name().
1765 1765
 	 */
1766
-	$special_chars = apply_filters( 'sanitize_file_name_chars', $special_chars, $filename_raw );
1767
-	$filename = preg_replace( "#\x{00a0}#siu", ' ', $filename );
1768
-	$filename = str_replace( $special_chars, '', $filename );
1769
-	$filename = str_replace( array( '%20', '+' ), '-', $filename );
1770
-	$filename = preg_replace( '/[\r\n\t -]+/', '-', $filename );
1771
-	$filename = trim( $filename, '.-_' );
1772
-
1773
-	if ( false === strpos( $filename, '.' ) ) {
1766
+	$special_chars = apply_filters('sanitize_file_name_chars', $special_chars, $filename_raw);
1767
+	$filename = preg_replace("#\x{00a0}#siu", ' ', $filename);
1768
+	$filename = str_replace($special_chars, '', $filename);
1769
+	$filename = str_replace(array('%20', '+'), '-', $filename);
1770
+	$filename = preg_replace('/[\r\n\t -]+/', '-', $filename);
1771
+	$filename = trim($filename, '.-_');
1772
+
1773
+	if (false === strpos($filename, '.')) {
1774 1774
 		$mime_types = wp_get_mime_types();
1775
-		$filetype = wp_check_filetype( 'test.' . $filename, $mime_types );
1776
-		if ( $filetype['ext'] === $filename ) {
1777
-			$filename = 'unnamed-file.' . $filetype['ext'];
1775
+		$filetype = wp_check_filetype('test.'.$filename, $mime_types);
1776
+		if ($filetype['ext'] === $filename) {
1777
+			$filename = 'unnamed-file.'.$filetype['ext'];
1778 1778
 		}
1779 1779
 	}
1780 1780
 
@@ -1782,7 +1782,7 @@  discard block
 block discarded – undo
1782 1782
 	$parts = explode('.', $filename);
1783 1783
 
1784 1784
 	// Return if only one extension
1785
-	if ( count( $parts ) <= 2 ) {
1785
+	if (count($parts) <= 2) {
1786 1786
 		/**
1787 1787
 		 * Filters a sanitized filename string.
1788 1788
 		 *
@@ -1791,7 +1791,7 @@  discard block
 block discarded – undo
1791 1791
 		 * @param string $filename     Sanitized filename.
1792 1792
 		 * @param string $filename_raw The filename prior to sanitization.
1793 1793
 		 */
1794
-		return apply_filters( 'sanitize_file_name', $filename, $filename_raw );
1794
+		return apply_filters('sanitize_file_name', $filename, $filename_raw);
1795 1795
 	}
1796 1796
 
1797 1797
 	// Process multiple extensions
@@ -1803,23 +1803,23 @@  discard block
 block discarded – undo
1803 1803
 	 * Loop over any intermediate extensions. Postfix them with a trailing underscore
1804 1804
 	 * if they are a 2 - 5 character long alpha string not in the extension whitelist.
1805 1805
 	 */
1806
-	foreach ( (array) $parts as $part) {
1807
-		$filename .= '.' . $part;
1806
+	foreach ((array) $parts as $part) {
1807
+		$filename .= '.'.$part;
1808 1808
 
1809
-		if ( preg_match("/^[a-zA-Z]{2,5}\d?$/", $part) ) {
1809
+		if (preg_match("/^[a-zA-Z]{2,5}\d?$/", $part)) {
1810 1810
 			$allowed = false;
1811
-			foreach ( $mimes as $ext_preg => $mime_match ) {
1812
-				$ext_preg = '!^(' . $ext_preg . ')$!i';
1813
-				if ( preg_match( $ext_preg, $part ) ) {
1811
+			foreach ($mimes as $ext_preg => $mime_match) {
1812
+				$ext_preg = '!^('.$ext_preg.')$!i';
1813
+				if (preg_match($ext_preg, $part)) {
1814 1814
 					$allowed = true;
1815 1815
 					break;
1816 1816
 				}
1817 1817
 			}
1818
-			if ( !$allowed )
1818
+			if ( ! $allowed)
1819 1819
 				$filename .= '_';
1820 1820
 		}
1821 1821
 	}
1822
-	$filename .= '.' . $extension;
1822
+	$filename .= '.'.$extension;
1823 1823
 	/** This filter is documented in wp-includes/formatting.php */
1824 1824
 	return apply_filters('sanitize_file_name', $filename, $filename_raw);
1825 1825
 }
@@ -1838,21 +1838,21 @@  discard block
 block discarded – undo
1838 1838
  * @param bool   $strict   If set limits $username to specific characters. Default false.
1839 1839
  * @return string The sanitized username, after passing through filters.
1840 1840
  */
1841
-function sanitize_user( $username, $strict = false ) {
1841
+function sanitize_user($username, $strict = false) {
1842 1842
 	$raw_username = $username;
1843
-	$username = wp_strip_all_tags( $username );
1844
-	$username = remove_accents( $username );
1843
+	$username = wp_strip_all_tags($username);
1844
+	$username = remove_accents($username);
1845 1845
 	// Kill octets
1846
-	$username = preg_replace( '|%([a-fA-F0-9][a-fA-F0-9])|', '', $username );
1847
-	$username = preg_replace( '/&.+?;/', '', $username ); // Kill entities
1846
+	$username = preg_replace('|%([a-fA-F0-9][a-fA-F0-9])|', '', $username);
1847
+	$username = preg_replace('/&.+?;/', '', $username); // Kill entities
1848 1848
 
1849 1849
 	// If strict, reduce to ASCII for max portability.
1850
-	if ( $strict )
1851
-		$username = preg_replace( '|[^a-z0-9 _.\-@]|i', '', $username );
1850
+	if ($strict)
1851
+		$username = preg_replace('|[^a-z0-9 _.\-@]|i', '', $username);
1852 1852
 
1853
-	$username = trim( $username );
1853
+	$username = trim($username);
1854 1854
 	// Consolidate contiguous whitespace
1855
-	$username = preg_replace( '|\s+|', ' ', $username );
1855
+	$username = preg_replace('|\s+|', ' ', $username);
1856 1856
 
1857 1857
 	/**
1858 1858
 	 * Filters a sanitized username string.
@@ -1863,7 +1863,7 @@  discard block
 block discarded – undo
1863 1863
 	 * @param string $raw_username The username prior to sanitization.
1864 1864
 	 * @param bool   $strict       Whether to limit the sanitization to specific characters. Default false.
1865 1865
 	 */
1866
-	return apply_filters( 'sanitize_user', $username, $raw_username, $strict );
1866
+	return apply_filters('sanitize_user', $username, $raw_username, $strict);
1867 1867
 }
1868 1868
 
1869 1869
 /**
@@ -1876,10 +1876,10 @@  discard block
 block discarded – undo
1876 1876
  * @param string $key String key
1877 1877
  * @return string Sanitized key
1878 1878
  */
1879
-function sanitize_key( $key ) {
1879
+function sanitize_key($key) {
1880 1880
 	$raw_key = $key;
1881
-	$key = strtolower( $key );
1882
-	$key = preg_replace( '/[^a-z0-9_\-]/', '', $key );
1881
+	$key = strtolower($key);
1882
+	$key = preg_replace('/[^a-z0-9_\-]/', '', $key);
1883 1883
 
1884 1884
 	/**
1885 1885
 	 * Filters a sanitized key string.
@@ -1889,7 +1889,7 @@  discard block
 block discarded – undo
1889 1889
 	 * @param string $key     Sanitized key.
1890 1890
 	 * @param string $raw_key The key prior to sanitization.
1891 1891
 	 */
1892
-	return apply_filters( 'sanitize_key', $key, $raw_key );
1892
+	return apply_filters('sanitize_key', $key, $raw_key);
1893 1893
 }
1894 1894
 
1895 1895
 /**
@@ -1906,10 +1906,10 @@  discard block
 block discarded – undo
1906 1906
  * @param string $context        Optional. The operation for which the string is sanitized
1907 1907
  * @return string The sanitized string.
1908 1908
  */
1909
-function sanitize_title( $title, $fallback_title = '', $context = 'save' ) {
1909
+function sanitize_title($title, $fallback_title = '', $context = 'save') {
1910 1910
 	$raw_title = $title;
1911 1911
 
1912
-	if ( 'save' == $context )
1912
+	if ('save' == $context)
1913 1913
 		$title = remove_accents($title);
1914 1914
 
1915 1915
 	/**
@@ -1921,9 +1921,9 @@  discard block
 block discarded – undo
1921 1921
 	 * @param string $raw_title The title prior to sanitization.
1922 1922
 	 * @param string $context   The context for which the title is being sanitized.
1923 1923
 	 */
1924
-	$title = apply_filters( 'sanitize_title', $title, $raw_title, $context );
1924
+	$title = apply_filters('sanitize_title', $title, $raw_title, $context);
1925 1925
 
1926
-	if ( '' === $title || false === $title )
1926
+	if ('' === $title || false === $title)
1927 1927
 		$title = $fallback_title;
1928 1928
 
1929 1929
 	return $title;
@@ -1939,8 +1939,8 @@  discard block
 block discarded – undo
1939 1939
  * @param string $title The string to be sanitized.
1940 1940
  * @return string The sanitized string.
1941 1941
  */
1942
-function sanitize_title_for_query( $title ) {
1943
-	return sanitize_title( $title, '', 'query' );
1942
+function sanitize_title_for_query($title) {
1943
+	return sanitize_title($title, '', 'query');
1944 1944
 }
1945 1945
 
1946 1946
 /**
@@ -1956,7 +1956,7 @@  discard block
 block discarded – undo
1956 1956
  * @param string $context   Optional. The operation for which the string is sanitized.
1957 1957
  * @return string The sanitized title.
1958 1958
  */
1959
-function sanitize_title_with_dashes( $title, $raw_title = '', $context = 'display' ) {
1959
+function sanitize_title_with_dashes($title, $raw_title = '', $context = 'display') {
1960 1960
 	$title = strip_tags($title);
1961 1961
 	// Preserve escaped octets.
1962 1962
 	$title = preg_replace('|%([a-fA-F0-9][a-fA-F0-9])|', '---$1---', $title);
@@ -1974,14 +1974,14 @@  discard block
 block discarded – undo
1974 1974
 
1975 1975
 	$title = strtolower($title);
1976 1976
 
1977
-	if ( 'save' == $context ) {
1977
+	if ('save' == $context) {
1978 1978
 		// Convert nbsp, ndash and mdash to hyphens
1979
-		$title = str_replace( array( '%c2%a0', '%e2%80%93', '%e2%80%94' ), '-', $title );
1979
+		$title = str_replace(array('%c2%a0', '%e2%80%93', '%e2%80%94'), '-', $title);
1980 1980
 		// Convert nbsp, ndash and mdash HTML entities to hyphens
1981
-		$title = str_replace( array( '&nbsp;', '&#160;', '&ndash;', '&#8211;', '&mdash;', '&#8212;' ), '-', $title );
1981
+		$title = str_replace(array('&nbsp;', '&#160;', '&ndash;', '&#8211;', '&mdash;', '&#8212;'), '-', $title);
1982 1982
 
1983 1983
 		// Strip these characters entirely
1984
-		$title = str_replace( array(
1984
+		$title = str_replace(array(
1985 1985
 			// iexcl and iquest
1986 1986
 			'%c2%a1', '%c2%bf',
1987 1987
 			// angle quotes
@@ -1995,10 +1995,10 @@  discard block
 block discarded – undo
1995 1995
 			'%c2%b4', '%cb%8a', '%cc%81', '%cd%81',
1996 1996
 			// grave accent, macron, caron
1997 1997
 			'%cc%80', '%cc%84', '%cc%8c',
1998
-		), '', $title );
1998
+		), '', $title);
1999 1999
 
2000 2000
 		// Convert times to x
2001
-		$title = str_replace( '%c3%97', 'x', $title );
2001
+		$title = str_replace('%c3%97', 'x', $title);
2002 2002
 	}
2003 2003
 
2004 2004
 	$title = preg_replace('/&.+?;/', '', $title); // kill entities
@@ -2025,8 +2025,8 @@  discard block
 block discarded – undo
2025 2025
  * @param string $orderby Order by clause to be validated.
2026 2026
  * @return string|false Returns $orderby if valid, false otherwise.
2027 2027
  */
2028
-function sanitize_sql_orderby( $orderby ) {
2029
-	if ( preg_match( '/^\s*(([a-z0-9_]+|`[a-z0-9_]+`)(\s+(ASC|DESC))?\s*(,\s*(?=[a-z0-9_`])|$))+$/i', $orderby ) || preg_match( '/^\s*RAND\(\s*\)\s*$/i', $orderby ) ) {
2028
+function sanitize_sql_orderby($orderby) {
2029
+	if (preg_match('/^\s*(([a-z0-9_]+|`[a-z0-9_]+`)(\s+(ASC|DESC))?\s*(,\s*(?=[a-z0-9_`])|$))+$/i', $orderby) || preg_match('/^\s*RAND\(\s*\)\s*$/i', $orderby)) {
2030 2030
 		return $orderby;
2031 2031
 	}
2032 2032
 	return false;
@@ -2047,15 +2047,15 @@  discard block
 block discarded – undo
2047 2047
  * 	Defaults to an empty string.
2048 2048
  * @return string The sanitized value
2049 2049
  */
2050
-function sanitize_html_class( $class, $fallback = '' ) {
2050
+function sanitize_html_class($class, $fallback = '') {
2051 2051
 	//Strip out any % encoded octets
2052
-	$sanitized = preg_replace( '|%[a-fA-F0-9][a-fA-F0-9]|', '', $class );
2052
+	$sanitized = preg_replace('|%[a-fA-F0-9][a-fA-F0-9]|', '', $class);
2053 2053
 
2054 2054
 	//Limit to A-Z,a-z,0-9,_,-
2055
-	$sanitized = preg_replace( '/[^A-Za-z0-9_-]/', '', $sanitized );
2055
+	$sanitized = preg_replace('/[^A-Za-z0-9_-]/', '', $sanitized);
2056 2056
 
2057
-	if ( '' == $sanitized && $fallback ) {
2058
-		return sanitize_html_class( $fallback );
2057
+	if ('' == $sanitized && $fallback) {
2058
+		return sanitize_html_class($fallback);
2059 2059
 	}
2060 2060
 	/**
2061 2061
 	 * Filters a sanitized HTML class string.
@@ -2066,7 +2066,7 @@  discard block
 block discarded – undo
2066 2066
 	 * @param string $class     HTML class before sanitization.
2067 2067
 	 * @param string $fallback  The fallback string.
2068 2068
 	 */
2069
-	return apply_filters( 'sanitize_html_class', $sanitized, $class, $fallback );
2069
+	return apply_filters('sanitize_html_class', $sanitized, $class, $fallback);
2070 2070
 }
2071 2071
 
2072 2072
 /**
@@ -2078,13 +2078,13 @@  discard block
 block discarded – undo
2078 2078
  * @param string $deprecated Not used.
2079 2079
  * @return string Converted string.
2080 2080
  */
2081
-function convert_chars( $content, $deprecated = '' ) {
2082
-	if ( ! empty( $deprecated ) ) {
2083
-		_deprecated_argument( __FUNCTION__, '0.71' );
2081
+function convert_chars($content, $deprecated = '') {
2082
+	if ( ! empty($deprecated)) {
2083
+		_deprecated_argument(__FUNCTION__, '0.71');
2084 2084
 	}
2085 2085
 
2086
-	if ( strpos( $content, '&' ) !== false ) {
2087
-		$content = preg_replace( '/&([^#])(?![a-z1-4]{1,8};)/i', '&#038;$1', $content );
2086
+	if (strpos($content, '&') !== false) {
2087
+		$content = preg_replace('/&([^#])(?![a-z1-4]{1,8};)/i', '&#038;$1', $content);
2088 2088
 	}
2089 2089
 
2090 2090
 	return $content;
@@ -2098,12 +2098,12 @@  discard block
 block discarded – undo
2098 2098
  * @param string $content String with entities that need converting.
2099 2099
  * @return string Converted string.
2100 2100
  */
2101
-function convert_invalid_entities( $content ) {
2101
+function convert_invalid_entities($content) {
2102 2102
 	$wp_htmltranswinuni = array(
2103 2103
 		'&#128;' => '&#8364;', // the Euro sign
2104 2104
 		'&#129;' => '',
2105 2105
 		'&#130;' => '&#8218;', // these are Windows CP1252 specific characters
2106
-		'&#131;' => '&#402;',  // they would look weird on non-Windows browsers
2106
+		'&#131;' => '&#402;', // they would look weird on non-Windows browsers
2107 2107
 		'&#132;' => '&#8222;',
2108 2108
 		'&#133;' => '&#8230;',
2109 2109
 		'&#134;' => '&#8224;',
@@ -2134,8 +2134,8 @@  discard block
 block discarded – undo
2134 2134
 		'&#159;' => '&#376;'
2135 2135
 	);
2136 2136
 
2137
-	if ( strpos( $content, '&#1' ) !== false ) {
2138
-		$content = strtr( $content, $wp_htmltranswinuni );
2137
+	if (strpos($content, '&#1') !== false) {
2138
+		$content = strtr($content, $wp_htmltranswinuni);
2139 2139
 	}
2140 2140
 
2141 2141
 	return $content;
@@ -2150,9 +2150,9 @@  discard block
 block discarded – undo
2150 2150
  * @param bool   $force If true, forces balancing, ignoring the value of the option. Default false.
2151 2151
  * @return string Balanced text
2152 2152
  */
2153
-function balanceTags( $text, $force = false ) {
2154
-	if ( $force || get_option('use_balanceTags') == 1 ) {
2155
-		return force_balance_tags( $text );
2153
+function balanceTags($text, $force = false) {
2154
+	if ($force || get_option('use_balanceTags') == 1) {
2155
+		return force_balance_tags($text);
2156 2156
 	} else {
2157 2157
 		return $text;
2158 2158
 	}
@@ -2176,22 +2176,22 @@  discard block
 block discarded – undo
2176 2176
  * @param string $text Text to be balanced.
2177 2177
  * @return string Balanced text.
2178 2178
  */
2179
-function force_balance_tags( $text ) {
2179
+function force_balance_tags($text) {
2180 2180
 	$tagstack = array();
2181 2181
 	$stacksize = 0;
2182 2182
 	$tagqueue = '';
2183 2183
 	$newtext = '';
2184 2184
 	// Known single-entity/self-closing tags
2185
-	$single_tags = array( 'area', 'base', 'basefont', 'br', 'col', 'command', 'embed', 'frame', 'hr', 'img', 'input', 'isindex', 'link', 'meta', 'param', 'source' );
2185
+	$single_tags = array('area', 'base', 'basefont', 'br', 'col', 'command', 'embed', 'frame', 'hr', 'img', 'input', 'isindex', 'link', 'meta', 'param', 'source');
2186 2186
 	// Tags that can be immediately nested within themselves
2187
-	$nestable_tags = array( 'blockquote', 'div', 'object', 'q', 'span' );
2187
+	$nestable_tags = array('blockquote', 'div', 'object', 'q', 'span');
2188 2188
 
2189 2189
 	// WP bug fix for comments - in case you REALLY meant to type '< !--'
2190 2190
 	$text = str_replace('< !--', '<    !--', $text);
2191 2191
 	// WP bug fix for LOVE <3 (and other situations with '<' before a number)
2192 2192
 	$text = preg_replace('#<([0-9]{1})#', '&lt;$1', $text);
2193 2193
 
2194
-	while ( preg_match("/<(\/?[\w:]*)\s*([^>]*)>/", $text, $regex) ) {
2194
+	while (preg_match("/<(\/?[\w:]*)\s*([^>]*)>/", $text, $regex)) {
2195 2195
 		$newtext .= $tagqueue;
2196 2196
 
2197 2197
 		$i = strpos($text, $regex[0]);
@@ -2200,25 +2200,25 @@  discard block
 block discarded – undo
2200 2200
 		// clear the shifter
2201 2201
 		$tagqueue = '';
2202 2202
 		// Pop or Push
2203
-		if ( isset($regex[1][0]) && '/' == $regex[1][0] ) { // End Tag
2204
-			$tag = strtolower(substr($regex[1],1));
2203
+		if (isset($regex[1][0]) && '/' == $regex[1][0]) { // End Tag
2204
+			$tag = strtolower(substr($regex[1], 1));
2205 2205
 			// if too many closing tags
2206
-			if ( $stacksize <= 0 ) {
2206
+			if ($stacksize <= 0) {
2207 2207
 				$tag = '';
2208 2208
 				// or close to be safe $tag = '/' . $tag;
2209 2209
 			}
2210 2210
 			// if stacktop value = tag close value then pop
2211
-			elseif ( $tagstack[$stacksize - 1] == $tag ) { // found closing tag
2212
-				$tag = '</' . $tag . '>'; // Close Tag
2211
+			elseif ($tagstack[$stacksize - 1] == $tag) { // found closing tag
2212
+				$tag = '</'.$tag.'>'; // Close Tag
2213 2213
 				// Pop
2214
-				array_pop( $tagstack );
2214
+				array_pop($tagstack);
2215 2215
 				$stacksize--;
2216 2216
 			} else { // closing tag not at top, search for it
2217
-				for ( $j = $stacksize-1; $j >= 0; $j-- ) {
2218
-					if ( $tagstack[$j] == $tag ) {
2217
+				for ($j = $stacksize - 1; $j >= 0; $j--) {
2218
+					if ($tagstack[$j] == $tag) {
2219 2219
 					// add tag to tagqueue
2220
-						for ( $k = $stacksize-1; $k >= $j; $k--) {
2221
-							$tagqueue .= '</' . array_pop( $tagstack ) . '>';
2220
+						for ($k = $stacksize - 1; $k >= $j; $k--) {
2221
+							$tagqueue .= '</'.array_pop($tagstack).'>';
2222 2222
 							$stacksize--;
2223 2223
 						}
2224 2224
 						break;
@@ -2232,43 +2232,43 @@  discard block
 block discarded – undo
2232 2232
 			// Tag Cleaning
2233 2233
 
2234 2234
 			// If it's an empty tag "< >", do nothing
2235
-			if ( '' == $tag ) {
2235
+			if ('' == $tag) {
2236 2236
 				// do nothing
2237 2237
 			}
2238 2238
 			// ElseIf it presents itself as a self-closing tag...
2239
-			elseif ( substr( $regex[2], -1 ) == '/' ) {
2239
+			elseif (substr($regex[2], -1) == '/') {
2240 2240
 				// ...but it isn't a known single-entity self-closing tag, then don't let it be treated as such and
2241 2241
 				// immediately close it with a closing tag (the tag will encapsulate no text as a result)
2242
-				if ( ! in_array( $tag, $single_tags ) )
2243
-					$regex[2] = trim( substr( $regex[2], 0, -1 ) ) . "></$tag";
2242
+				if ( ! in_array($tag, $single_tags))
2243
+					$regex[2] = trim(substr($regex[2], 0, -1))."></$tag";
2244 2244
 			}
2245 2245
 			// ElseIf it's a known single-entity tag but it doesn't close itself, do so
2246
-			elseif ( in_array($tag, $single_tags) ) {
2246
+			elseif (in_array($tag, $single_tags)) {
2247 2247
 				$regex[2] .= '/';
2248 2248
 			}
2249 2249
 			// Else it's not a single-entity tag
2250 2250
 			else {
2251 2251
 				// If the top of the stack is the same as the tag we want to push, close previous tag
2252
-				if ( $stacksize > 0 && !in_array($tag, $nestable_tags) && $tagstack[$stacksize - 1] == $tag ) {
2253
-					$tagqueue = '</' . array_pop( $tagstack ) . '>';
2252
+				if ($stacksize > 0 && ! in_array($tag, $nestable_tags) && $tagstack[$stacksize - 1] == $tag) {
2253
+					$tagqueue = '</'.array_pop($tagstack).'>';
2254 2254
 					$stacksize--;
2255 2255
 				}
2256
-				$stacksize = array_push( $tagstack, $tag );
2256
+				$stacksize = array_push($tagstack, $tag);
2257 2257
 			}
2258 2258
 
2259 2259
 			// Attributes
2260 2260
 			$attributes = $regex[2];
2261
-			if ( ! empty( $attributes ) && $attributes[0] != '>' )
2262
-				$attributes = ' ' . $attributes;
2261
+			if ( ! empty($attributes) && $attributes[0] != '>')
2262
+				$attributes = ' '.$attributes;
2263 2263
 
2264
-			$tag = '<' . $tag . $attributes . '>';
2264
+			$tag = '<'.$tag.$attributes.'>';
2265 2265
 			//If already queuing a close tag, then put this tag on, too
2266
-			if ( !empty($tagqueue) ) {
2266
+			if ( ! empty($tagqueue)) {
2267 2267
 				$tagqueue .= $tag;
2268 2268
 				$tag = '';
2269 2269
 			}
2270 2270
 		}
2271
-		$newtext .= substr($text, 0, $i) . $tag;
2271
+		$newtext .= substr($text, 0, $i).$tag;
2272 2272
 		$text = substr($text, $i + $l);
2273 2273
 	}
2274 2274
 
@@ -2279,12 +2279,12 @@  discard block
 block discarded – undo
2279 2279
 	$newtext .= $text;
2280 2280
 
2281 2281
 	// Empty Stack
2282
-	while( $x = array_pop($tagstack) )
2283
-		$newtext .= '</' . $x . '>'; // Add remaining tags to close
2282
+	while ($x = array_pop($tagstack))
2283
+		$newtext .= '</'.$x.'>'; // Add remaining tags to close
2284 2284
 
2285 2285
 	// WP fix for the bug with HTML comments
2286
-	$newtext = str_replace("< !--","<!--",$newtext);
2287
-	$newtext = str_replace("<    !--","< !--",$newtext);
2286
+	$newtext = str_replace("< !--", "<!--", $newtext);
2287
+	$newtext = str_replace("<    !--", "< !--", $newtext);
2288 2288
 
2289 2289
 	return $newtext;
2290 2290
 }
@@ -2305,7 +2305,7 @@  discard block
 block discarded – undo
2305 2305
  *                          Default false.
2306 2306
  * @return string The text after the filter (and possibly htmlspecialchars()) has been run.
2307 2307
  */
2308
-function format_to_edit( $content, $rich_text = false ) {
2308
+function format_to_edit($content, $rich_text = false) {
2309 2309
 	/**
2310 2310
 	 * Filters the text to be formatted for editing.
2311 2311
 	 *
@@ -2313,9 +2313,9 @@  discard block
 block discarded – undo
2313 2313
 	 *
2314 2314
 	 * @param string $content The text, prior to formatting for editing.
2315 2315
 	 */
2316
-	$content = apply_filters( 'format_to_edit', $content );
2317
-	if ( ! $rich_text )
2318
-		$content = esc_textarea( $content );
2316
+	$content = apply_filters('format_to_edit', $content);
2317
+	if ( ! $rich_text)
2318
+		$content = esc_textarea($content);
2319 2319
 	return $content;
2320 2320
 }
2321 2321
 
@@ -2336,8 +2336,8 @@  discard block
 block discarded – undo
2336 2336
  * @param int $threshold  Digit places number needs to be to not have zeros added.
2337 2337
  * @return string Adds leading zeros to number if needed.
2338 2338
  */
2339
-function zeroise( $number, $threshold ) {
2340
-	return sprintf( '%0' . $threshold . 's', $number );
2339
+function zeroise($number, $threshold) {
2340
+	return sprintf('%0'.$threshold.'s', $number);
2341 2341
 }
2342 2342
 
2343 2343
 /**
@@ -2348,10 +2348,10 @@  discard block
 block discarded – undo
2348 2348
  * @param string $string Value to which backslashes will be added.
2349 2349
  * @return string String with backslashes inserted.
2350 2350
  */
2351
-function backslashit( $string ) {
2352
-	if ( isset( $string[0] ) && $string[0] >= '0' && $string[0] <= '9' )
2353
-		$string = '\\\\' . $string;
2354
-	return addcslashes( $string, 'A..Za..z' );
2351
+function backslashit($string) {
2352
+	if (isset($string[0]) && $string[0] >= '0' && $string[0] <= '9')
2353
+		$string = '\\\\'.$string;
2354
+	return addcslashes($string, 'A..Za..z');
2355 2355
 }
2356 2356
 
2357 2357
 /**
@@ -2368,8 +2368,8 @@  discard block
 block discarded – undo
2368 2368
  * @param string $string What to add the trailing slash to.
2369 2369
  * @return string String with trailing slash added.
2370 2370
  */
2371
-function trailingslashit( $string ) {
2372
-	return untrailingslashit( $string ) . '/';
2371
+function trailingslashit($string) {
2372
+	return untrailingslashit($string).'/';
2373 2373
 }
2374 2374
 
2375 2375
 /**
@@ -2383,8 +2383,8 @@  discard block
 block discarded – undo
2383 2383
  * @param string $string What to remove the trailing slashes from.
2384 2384
  * @return string String without the trailing slashes.
2385 2385
  */
2386
-function untrailingslashit( $string ) {
2387
-	return rtrim( $string, '/\\' );
2386
+function untrailingslashit($string) {
2387
+	return rtrim($string, '/\\');
2388 2388
 }
2389 2389
 
2390 2390
 /**
@@ -2399,7 +2399,7 @@  discard block
 block discarded – undo
2399 2399
  * @return string Returns a string escaped with slashes.
2400 2400
  */
2401 2401
 function addslashes_gpc($gpc) {
2402
-	if ( get_magic_quotes_gpc() )
2402
+	if (get_magic_quotes_gpc())
2403 2403
 		$gpc = stripslashes($gpc);
2404 2404
 
2405 2405
 	return wp_slash($gpc);
@@ -2413,8 +2413,8 @@  discard block
 block discarded – undo
2413 2413
  * @param mixed $value The value to be stripped.
2414 2414
  * @return mixed Stripped value.
2415 2415
  */
2416
-function stripslashes_deep( $value ) {
2417
-	return map_deep( $value, 'stripslashes_from_strings_only' );
2416
+function stripslashes_deep($value) {
2417
+	return map_deep($value, 'stripslashes_from_strings_only');
2418 2418
 }
2419 2419
 
2420 2420
 /**
@@ -2425,8 +2425,8 @@  discard block
 block discarded – undo
2425 2425
  * @param mixed $value The array or string to be stripped.
2426 2426
  * @return mixed $value The stripped value.
2427 2427
  */
2428
-function stripslashes_from_strings_only( $value ) {
2429
-	return is_string( $value ) ? stripslashes( $value ) : $value;
2428
+function stripslashes_from_strings_only($value) {
2429
+	return is_string($value) ? stripslashes($value) : $value;
2430 2430
 }
2431 2431
 
2432 2432
 /**
@@ -2437,8 +2437,8 @@  discard block
 block discarded – undo
2437 2437
  * @param mixed $value The array or string to be encoded.
2438 2438
  * @return mixed $value The encoded value.
2439 2439
  */
2440
-function urlencode_deep( $value ) {
2441
-	return map_deep( $value, 'urlencode' );
2440
+function urlencode_deep($value) {
2441
+	return map_deep($value, 'urlencode');
2442 2442
 }
2443 2443
 
2444 2444
 /**
@@ -2449,8 +2449,8 @@  discard block
 block discarded – undo
2449 2449
  * @param mixed $value The array or string to be encoded.
2450 2450
  * @return mixed $value The encoded value.
2451 2451
  */
2452
-function rawurlencode_deep( $value ) {
2453
-	return map_deep( $value, 'rawurlencode' );
2452
+function rawurlencode_deep($value) {
2453
+	return map_deep($value, 'rawurlencode');
2454 2454
 }
2455 2455
 
2456 2456
 /**
@@ -2461,8 +2461,8 @@  discard block
 block discarded – undo
2461 2461
  * @param mixed $value The array or string to be decoded.
2462 2462
  * @return mixed $value The decoded value.
2463 2463
  */
2464
-function urldecode_deep( $value ) {
2465
-	return map_deep( $value, 'urldecode' );
2464
+function urldecode_deep($value) {
2465
+	return map_deep($value, 'urldecode');
2466 2466
 }
2467 2467
 
2468 2468
 /**
@@ -2474,20 +2474,20 @@  discard block
 block discarded – undo
2474 2474
  * @param int    $hex_encoding  Optional. Set to 1 to enable hex encoding.
2475 2475
  * @return string Converted email address.
2476 2476
  */
2477
-function antispambot( $email_address, $hex_encoding = 0 ) {
2477
+function antispambot($email_address, $hex_encoding = 0) {
2478 2478
 	$email_no_spam_address = '';
2479
-	for ( $i = 0, $len = strlen( $email_address ); $i < $len; $i++ ) {
2480
-		$j = rand( 0, 1 + $hex_encoding );
2481
-		if ( $j == 0 ) {
2482
-			$email_no_spam_address .= '&#' . ord( $email_address[$i] ) . ';';
2483
-		} elseif ( $j == 1 ) {
2479
+	for ($i = 0, $len = strlen($email_address); $i < $len; $i++) {
2480
+		$j = rand(0, 1 + $hex_encoding);
2481
+		if ($j == 0) {
2482
+			$email_no_spam_address .= '&#'.ord($email_address[$i]).';';
2483
+		} elseif ($j == 1) {
2484 2484
 			$email_no_spam_address .= $email_address[$i];
2485
-		} elseif ( $j == 2 ) {
2486
-			$email_no_spam_address .= '%' . zeroise( dechex( ord( $email_address[$i] ) ), 2 );
2485
+		} elseif ($j == 2) {
2486
+			$email_no_spam_address .= '%'.zeroise(dechex(ord($email_address[$i])), 2);
2487 2487
 		}
2488 2488
 	}
2489 2489
 
2490
-	return str_replace( '@', '&#64;', $email_no_spam_address );
2490
+	return str_replace('@', '&#64;', $email_no_spam_address);
2491 2491
 }
2492 2492
 
2493 2493
 /**
@@ -2501,10 +2501,10 @@  discard block
 block discarded – undo
2501 2501
  * @param array $matches Single Regex Match.
2502 2502
  * @return string HTML A element with URI address.
2503 2503
  */
2504
-function _make_url_clickable_cb( $matches ) {
2504
+function _make_url_clickable_cb($matches) {
2505 2505
 	$url = $matches[2];
2506 2506
 
2507
-	if ( ')' == $matches[3] && strpos( $url, '(' ) ) {
2507
+	if (')' == $matches[3] && strpos($url, '(')) {
2508 2508
 		// If the trailing character is a closing parethesis, and the URL has an opening parenthesis in it, add the closing parenthesis to the URL.
2509 2509
 		// Then we can let the parenthesis balancer do its thing below.
2510 2510
 		$url .= $matches[3];
@@ -2514,16 +2514,16 @@  discard block
 block discarded – undo
2514 2514
 	}
2515 2515
 
2516 2516
 	// Include parentheses in the URL only if paired
2517
-	while ( substr_count( $url, '(' ) < substr_count( $url, ')' ) ) {
2518
-		$suffix = strrchr( $url, ')' ) . $suffix;
2519
-		$url = substr( $url, 0, strrpos( $url, ')' ) );
2517
+	while (substr_count($url, '(') < substr_count($url, ')')) {
2518
+		$suffix = strrchr($url, ')').$suffix;
2519
+		$url = substr($url, 0, strrpos($url, ')'));
2520 2520
 	}
2521 2521
 
2522 2522
 	$url = esc_url($url);
2523
-	if ( empty($url) )
2523
+	if (empty($url))
2524 2524
 		return $matches[0];
2525 2525
 
2526
-	return $matches[1] . "<a href=\"$url\" rel=\"nofollow\">$url</a>" . $suffix;
2526
+	return $matches[1]."<a href=\"$url\" rel=\"nofollow\">$url</a>".$suffix;
2527 2527
 }
2528 2528
 
2529 2529
 /**
@@ -2537,22 +2537,22 @@  discard block
 block discarded – undo
2537 2537
  * @param array $matches Single Regex Match.
2538 2538
  * @return string HTML A element with URL address.
2539 2539
  */
2540
-function _make_web_ftp_clickable_cb( $matches ) {
2540
+function _make_web_ftp_clickable_cb($matches) {
2541 2541
 	$ret = '';
2542 2542
 	$dest = $matches[2];
2543
-	$dest = 'http://' . $dest;
2543
+	$dest = 'http://'.$dest;
2544 2544
 
2545 2545
 	// removed trailing [.,;:)] from URL
2546
-	if ( in_array( substr($dest, -1), array('.', ',', ';', ':', ')') ) === true ) {
2546
+	if (in_array(substr($dest, -1), array('.', ',', ';', ':', ')')) === true) {
2547 2547
 		$ret = substr($dest, -1);
2548
-		$dest = substr($dest, 0, strlen($dest)-1);
2548
+		$dest = substr($dest, 0, strlen($dest) - 1);
2549 2549
 	}
2550 2550
 
2551 2551
 	$dest = esc_url($dest);
2552
-	if ( empty($dest) )
2552
+	if (empty($dest))
2553 2553
 		return $matches[0];
2554 2554
 
2555
-	return $matches[1] . "<a href=\"$dest\" rel=\"nofollow\">$dest</a>$ret";
2555
+	return $matches[1]."<a href=\"$dest\" rel=\"nofollow\">$dest</a>$ret";
2556 2556
 }
2557 2557
 
2558 2558
 /**
@@ -2566,9 +2566,9 @@  discard block
 block discarded – undo
2566 2566
  * @param array $matches Single Regex Match.
2567 2567
  * @return string HTML A element with email address.
2568 2568
  */
2569
-function _make_email_clickable_cb( $matches ) {
2570
-	$email = $matches[2] . '@' . $matches[3];
2571
-	return $matches[1] . "<a href=\"mailto:$email\">$email</a>";
2569
+function _make_email_clickable_cb($matches) {
2570
+	$email = $matches[2].'@'.$matches[3];
2571
+	return $matches[1]."<a href=\"mailto:$email\">$email</a>";
2572 2572
 }
2573 2573
 
2574 2574
 /**
@@ -2582,30 +2582,30 @@  discard block
 block discarded – undo
2582 2582
  * @param string $text Content to convert URIs.
2583 2583
  * @return string Content with converted URIs.
2584 2584
  */
2585
-function make_clickable( $text ) {
2585
+function make_clickable($text) {
2586 2586
 	$r = '';
2587
-	$textarr = preg_split( '/(<[^<>]+>)/', $text, -1, PREG_SPLIT_DELIM_CAPTURE ); // split out HTML tags
2587
+	$textarr = preg_split('/(<[^<>]+>)/', $text, -1, PREG_SPLIT_DELIM_CAPTURE); // split out HTML tags
2588 2588
 	$nested_code_pre = 0; // Keep track of how many levels link is nested inside <pre> or <code>
2589
-	foreach ( $textarr as $piece ) {
2589
+	foreach ($textarr as $piece) {
2590 2590
 
2591
-		if ( preg_match( '|^<code[\s>]|i', $piece ) || preg_match( '|^<pre[\s>]|i', $piece ) || preg_match( '|^<script[\s>]|i', $piece ) || preg_match( '|^<style[\s>]|i', $piece ) )
2591
+		if (preg_match('|^<code[\s>]|i', $piece) || preg_match('|^<pre[\s>]|i', $piece) || preg_match('|^<script[\s>]|i', $piece) || preg_match('|^<style[\s>]|i', $piece))
2592 2592
 			$nested_code_pre++;
2593
-		elseif ( $nested_code_pre && ( '</code>' === strtolower( $piece ) || '</pre>' === strtolower( $piece ) || '</script>' === strtolower( $piece ) || '</style>' === strtolower( $piece ) ) )
2593
+		elseif ($nested_code_pre && ('</code>' === strtolower($piece) || '</pre>' === strtolower($piece) || '</script>' === strtolower($piece) || '</style>' === strtolower($piece)))
2594 2594
 			$nested_code_pre--;
2595 2595
 
2596
-		if ( $nested_code_pre || empty( $piece ) || ( $piece[0] === '<' && ! preg_match( '|^<\s*[\w]{1,20}+://|', $piece ) ) ) {
2596
+		if ($nested_code_pre || empty($piece) || ($piece[0] === '<' && ! preg_match('|^<\s*[\w]{1,20}+://|', $piece))) {
2597 2597
 			$r .= $piece;
2598 2598
 			continue;
2599 2599
 		}
2600 2600
 
2601 2601
 		// Long strings might contain expensive edge cases ...
2602
-		if ( 10000 < strlen( $piece ) ) {
2602
+		if (10000 < strlen($piece)) {
2603 2603
 			// ... break it up
2604
-			foreach ( _split_str_by_whitespace( $piece, 2100 ) as $chunk ) { // 2100: Extra room for scheme and leading and trailing paretheses
2605
-				if ( 2101 < strlen( $chunk ) ) {
2604
+			foreach (_split_str_by_whitespace($piece, 2100) as $chunk) { // 2100: Extra room for scheme and leading and trailing paretheses
2605
+				if (2101 < strlen($chunk)) {
2606 2606
 					$r .= $chunk; // Too big, no whitespace: bail.
2607 2607
 				} else {
2608
-					$r .= make_clickable( $chunk );
2608
+					$r .= make_clickable($chunk);
2609 2609
 				}
2610 2610
 			}
2611 2611
 		} else {
@@ -2626,18 +2626,18 @@  discard block
 block discarded – undo
2626 2626
 			~xS'; // The regex is a non-anchored pattern and does not have a single fixed starting character.
2627 2627
 			      // Tell PCRE to spend more time optimizing since, when used on a page load, it will probably be used several times.
2628 2628
 
2629
-			$ret = preg_replace_callback( $url_clickable, '_make_url_clickable_cb', $ret );
2629
+			$ret = preg_replace_callback($url_clickable, '_make_url_clickable_cb', $ret);
2630 2630
 
2631
-			$ret = preg_replace_callback( '#([\s>])((www|ftp)\.[\w\\x80-\\xff\#$%&~/.\-;:=,?@\[\]+]+)#is', '_make_web_ftp_clickable_cb', $ret );
2632
-			$ret = preg_replace_callback( '#([\s>])([.0-9a-z_+-]+)@(([0-9a-z-]+\.)+[0-9a-z]{2,})#i', '_make_email_clickable_cb', $ret );
2631
+			$ret = preg_replace_callback('#([\s>])((www|ftp)\.[\w\\x80-\\xff\#$%&~/.\-;:=,?@\[\]+]+)#is', '_make_web_ftp_clickable_cb', $ret);
2632
+			$ret = preg_replace_callback('#([\s>])([.0-9a-z_+-]+)@(([0-9a-z-]+\.)+[0-9a-z]{2,})#i', '_make_email_clickable_cb', $ret);
2633 2633
 
2634
-			$ret = substr( $ret, 1, -1 ); // Remove our whitespace padding.
2634
+			$ret = substr($ret, 1, -1); // Remove our whitespace padding.
2635 2635
 			$r .= $ret;
2636 2636
 		}
2637 2637
 	}
2638 2638
 
2639 2639
 	// Cleanup of accidental links within links
2640
-	return preg_replace( '#(<a([ \r\n\t]+[^>]+?>|>))<a [^>]+?>([^>]+?)</a></a>#i', "$1$3</a>", $r );
2640
+	return preg_replace('#(<a([ \r\n\t]+[^>]+?>|>))<a [^>]+?>([^>]+?)</a></a>#i', "$1$3</a>", $r);
2641 2641
 }
2642 2642
 
2643 2643
 /**
@@ -2669,27 +2669,27 @@  discard block
 block discarded – undo
2669 2669
  * @param int    $goal   The desired chunk length.
2670 2670
  * @return array Numeric array of chunks.
2671 2671
  */
2672
-function _split_str_by_whitespace( $string, $goal ) {
2672
+function _split_str_by_whitespace($string, $goal) {
2673 2673
 	$chunks = array();
2674 2674
 
2675
-	$string_nullspace = strtr( $string, "\r\n\t\v\f ", "\000\000\000\000\000\000" );
2675
+	$string_nullspace = strtr($string, "\r\n\t\v\f ", "\000\000\000\000\000\000");
2676 2676
 
2677
-	while ( $goal < strlen( $string_nullspace ) ) {
2678
-		$pos = strrpos( substr( $string_nullspace, 0, $goal + 1 ), "\000" );
2677
+	while ($goal < strlen($string_nullspace)) {
2678
+		$pos = strrpos(substr($string_nullspace, 0, $goal + 1), "\000");
2679 2679
 
2680
-		if ( false === $pos ) {
2681
-			$pos = strpos( $string_nullspace, "\000", $goal + 1 );
2682
-			if ( false === $pos ) {
2680
+		if (false === $pos) {
2681
+			$pos = strpos($string_nullspace, "\000", $goal + 1);
2682
+			if (false === $pos) {
2683 2683
 				break;
2684 2684
 			}
2685 2685
 		}
2686 2686
 
2687
-		$chunks[] = substr( $string, 0, $pos + 1 );
2688
-		$string = substr( $string, $pos + 1 );
2689
-		$string_nullspace = substr( $string_nullspace, $pos + 1 );
2687
+		$chunks[] = substr($string, 0, $pos + 1);
2688
+		$string = substr($string, $pos + 1);
2689
+		$string_nullspace = substr($string_nullspace, $pos + 1);
2690 2690
 	}
2691 2691
 
2692
-	if ( $string ) {
2692
+	if ($string) {
2693 2693
 		$chunks[] = $string;
2694 2694
 	}
2695 2695
 
@@ -2704,11 +2704,11 @@  discard block
 block discarded – undo
2704 2704
  * @param string $text Content that may contain HTML A elements.
2705 2705
  * @return string Converted content.
2706 2706
  */
2707
-function wp_rel_nofollow( $text ) {
2707
+function wp_rel_nofollow($text) {
2708 2708
 	// This is a pre save filter, so text is already escaped.
2709 2709
 	$text = stripslashes($text);
2710 2710
 	$text = preg_replace_callback('|<a (.+?)>|i', 'wp_rel_nofollow_callback', $text);
2711
-	return wp_slash( $text );
2711
+	return wp_slash($text);
2712 2712
 }
2713 2713
 
2714 2714
 /**
@@ -2722,30 +2722,30 @@  discard block
 block discarded – undo
2722 2722
  * @param array $matches Single Match
2723 2723
  * @return string HTML A Element with rel nofollow.
2724 2724
  */
2725
-function wp_rel_nofollow_callback( $matches ) {
2725
+function wp_rel_nofollow_callback($matches) {
2726 2726
 	$text = $matches[1];
2727
-	$atts = shortcode_parse_atts( $matches[1] );
2727
+	$atts = shortcode_parse_atts($matches[1]);
2728 2728
 	$rel  = 'nofollow';
2729 2729
 
2730
-	if ( preg_match( '%href=["\'](' . preg_quote( set_url_scheme( home_url(), 'http' ) ) . ')%i', $text ) ||
2731
-	     preg_match( '%href=["\'](' . preg_quote( set_url_scheme( home_url(), 'https' ) ) . ')%i', $text )
2730
+	if (preg_match('%href=["\']('.preg_quote(set_url_scheme(home_url(), 'http')).')%i', $text) ||
2731
+	     preg_match('%href=["\']('.preg_quote(set_url_scheme(home_url(), 'https')).')%i', $text)
2732 2732
 	) {
2733 2733
 		return "<a $text>";
2734 2734
 	}
2735 2735
 
2736
-	if ( ! empty( $atts['rel'] ) ) {
2737
-		$parts = array_map( 'trim', explode( ' ', $atts['rel'] ) );
2738
-		if ( false === array_search( 'nofollow', $parts ) ) {
2736
+	if ( ! empty($atts['rel'])) {
2737
+		$parts = array_map('trim', explode(' ', $atts['rel']));
2738
+		if (false === array_search('nofollow', $parts)) {
2739 2739
 			$parts[] = 'nofollow';
2740 2740
 		}
2741
-		$rel = implode( ' ', $parts );
2742
-		unset( $atts['rel'] );
2741
+		$rel = implode(' ', $parts);
2742
+		unset($atts['rel']);
2743 2743
 
2744 2744
 		$html = '';
2745
-		foreach ( $atts as $name => $value ) {
2745
+		foreach ($atts as $name => $value) {
2746 2746
 			$html .= "{$name}=\"$value\" ";
2747 2747
 		}
2748
-		$text = trim( $html );
2748
+		$text = trim($html);
2749 2749
 	}
2750 2750
 	return "<a $text rel=\"$rel\">";
2751 2751
 }
@@ -2765,21 +2765,21 @@  discard block
 block discarded – undo
2765 2765
  * @param array $matches Single match. Smiley code to convert to image.
2766 2766
  * @return string Image string for smiley.
2767 2767
  */
2768
-function translate_smiley( $matches ) {
2768
+function translate_smiley($matches) {
2769 2769
 	global $wpsmiliestrans;
2770 2770
 
2771
-	if ( count( $matches ) == 0 )
2771
+	if (count($matches) == 0)
2772 2772
 		return '';
2773 2773
 
2774
-	$smiley = trim( reset( $matches ) );
2775
-	$img = $wpsmiliestrans[ $smiley ];
2774
+	$smiley = trim(reset($matches));
2775
+	$img = $wpsmiliestrans[$smiley];
2776 2776
 
2777 2777
 	$matches = array();
2778
-	$ext = preg_match( '/\.([^.]+)$/', $img, $matches ) ? strtolower( $matches[1] ) : false;
2779
-	$image_exts = array( 'jpg', 'jpeg', 'jpe', 'gif', 'png' );
2778
+	$ext = preg_match('/\.([^.]+)$/', $img, $matches) ? strtolower($matches[1]) : false;
2779
+	$image_exts = array('jpg', 'jpeg', 'jpe', 'gif', 'png');
2780 2780
 
2781 2781
 	// Don't convert smilies that aren't images - they're probably emoji.
2782
-	if ( ! in_array( $ext, $image_exts ) ) {
2782
+	if ( ! in_array($ext, $image_exts)) {
2783 2783
 		return $img;
2784 2784
 	}
2785 2785
 
@@ -2792,9 +2792,9 @@  discard block
 block discarded – undo
2792 2792
 	 * @param string $img        Filename for the smiley image.
2793 2793
 	 * @param string $site_url   Site URL, as returned by site_url().
2794 2794
 	 */
2795
-	$src_url = apply_filters( 'smilies_src', includes_url( "images/smilies/$img" ), $img, site_url() );
2795
+	$src_url = apply_filters('smilies_src', includes_url("images/smilies/$img"), $img, site_url());
2796 2796
 
2797
-	return sprintf( '<img src="%s" alt="%s" class="wp-smiley" style="height: 1em; max-height: 1em;" />', esc_url( $src_url ), esc_attr( $smiley ) );
2797
+	return sprintf('<img src="%s" alt="%s" class="wp-smiley" style="height: 1em; max-height: 1em;" />', esc_url($src_url), esc_attr($smiley));
2798 2798
 }
2799 2799
 
2800 2800
 /**
@@ -2810,33 +2810,33 @@  discard block
 block discarded – undo
2810 2810
  * @param string $text Content to convert smilies from text.
2811 2811
  * @return string Converted content with text smilies replaced with images.
2812 2812
  */
2813
-function convert_smilies( $text ) {
2813
+function convert_smilies($text) {
2814 2814
 	global $wp_smiliessearch;
2815 2815
 	$output = '';
2816
-	if ( get_option( 'use_smilies' ) && ! empty( $wp_smiliessearch ) ) {
2816
+	if (get_option('use_smilies') && ! empty($wp_smiliessearch)) {
2817 2817
 		// HTML loop taken from texturize function, could possible be consolidated
2818
-		$textarr = preg_split( '/(<.*>)/U', $text, -1, PREG_SPLIT_DELIM_CAPTURE ); // capture the tags as well as in between
2819
-		$stop = count( $textarr );// loop stuff
2818
+		$textarr = preg_split('/(<.*>)/U', $text, -1, PREG_SPLIT_DELIM_CAPTURE); // capture the tags as well as in between
2819
+		$stop = count($textarr); // loop stuff
2820 2820
 
2821 2821
 		// Ignore proessing of specific tags
2822 2822
 		$tags_to_ignore = 'code|pre|style|script|textarea';
2823 2823
 		$ignore_block_element = '';
2824 2824
 
2825
-		for ( $i = 0; $i < $stop; $i++ ) {
2825
+		for ($i = 0; $i < $stop; $i++) {
2826 2826
 			$content = $textarr[$i];
2827 2827
 
2828 2828
 			// If we're in an ignore block, wait until we find its closing tag
2829
-			if ( '' == $ignore_block_element && preg_match( '/^<(' . $tags_to_ignore . ')>/', $content, $matches ) )  {
2829
+			if ('' == $ignore_block_element && preg_match('/^<('.$tags_to_ignore.')>/', $content, $matches)) {
2830 2830
 				$ignore_block_element = $matches[1];
2831 2831
 			}
2832 2832
 
2833 2833
 			// If it's not a tag and not in ignore block
2834
-			if ( '' ==  $ignore_block_element && strlen( $content ) > 0 && '<' != $content[0] ) {
2835
-				$content = preg_replace_callback( $wp_smiliessearch, 'translate_smiley', $content );
2834
+			if ('' == $ignore_block_element && strlen($content) > 0 && '<' != $content[0]) {
2835
+				$content = preg_replace_callback($wp_smiliessearch, 'translate_smiley', $content);
2836 2836
 			}
2837 2837
 
2838 2838
 			// did we exit ignore block
2839
-			if ( '' != $ignore_block_element && '</' . $ignore_block_element . '>' == $content )  {
2839
+			if ('' != $ignore_block_element && '</'.$ignore_block_element.'>' == $content) {
2840 2840
 				$ignore_block_element = '';
2841 2841
 			}
2842 2842
 
@@ -2860,12 +2860,12 @@  discard block
 block discarded – undo
2860 2860
  * @param bool   $deprecated Deprecated.
2861 2861
  * @return string|bool Either false or the valid email address.
2862 2862
  */
2863
-function is_email( $email, $deprecated = false ) {
2864
-	if ( ! empty( $deprecated ) )
2865
-		_deprecated_argument( __FUNCTION__, '3.0.0' );
2863
+function is_email($email, $deprecated = false) {
2864
+	if ( ! empty($deprecated))
2865
+		_deprecated_argument(__FUNCTION__, '3.0.0');
2866 2866
 
2867 2867
 	// Test for the minimum length the email can be
2868
-	if ( strlen( $email ) < 3 ) {
2868
+	if (strlen($email) < 3) {
2869 2869
 		/**
2870 2870
 		 * Filters whether an email address is valid.
2871 2871
 		 *
@@ -2879,65 +2879,65 @@  discard block
 block discarded – undo
2879 2879
 		 * @param string $email    The email address being checked.
2880 2880
 		 * @param string $context  Context under which the email was tested.
2881 2881
 		 */
2882
-		return apply_filters( 'is_email', false, $email, 'email_too_short' );
2882
+		return apply_filters('is_email', false, $email, 'email_too_short');
2883 2883
 	}
2884 2884
 
2885 2885
 	// Test for an @ character after the first position
2886
-	if ( strpos( $email, '@', 1 ) === false ) {
2886
+	if (strpos($email, '@', 1) === false) {
2887 2887
 		/** This filter is documented in wp-includes/formatting.php */
2888
-		return apply_filters( 'is_email', false, $email, 'email_no_at' );
2888
+		return apply_filters('is_email', false, $email, 'email_no_at');
2889 2889
 	}
2890 2890
 
2891 2891
 	// Split out the local and domain parts
2892
-	list( $local, $domain ) = explode( '@', $email, 2 );
2892
+	list($local, $domain) = explode('@', $email, 2);
2893 2893
 
2894 2894
 	// LOCAL PART
2895 2895
 	// Test for invalid characters
2896
-	if ( !preg_match( '/^[a-zA-Z0-9!#$%&\'*+\/=?^_`{|}~\.-]+$/', $local ) ) {
2896
+	if ( ! preg_match('/^[a-zA-Z0-9!#$%&\'*+\/=?^_`{|}~\.-]+$/', $local)) {
2897 2897
 		/** This filter is documented in wp-includes/formatting.php */
2898
-		return apply_filters( 'is_email', false, $email, 'local_invalid_chars' );
2898
+		return apply_filters('is_email', false, $email, 'local_invalid_chars');
2899 2899
 	}
2900 2900
 
2901 2901
 	// DOMAIN PART
2902 2902
 	// Test for sequences of periods
2903
-	if ( preg_match( '/\.{2,}/', $domain ) ) {
2903
+	if (preg_match('/\.{2,}/', $domain)) {
2904 2904
 		/** This filter is documented in wp-includes/formatting.php */
2905
-		return apply_filters( 'is_email', false, $email, 'domain_period_sequence' );
2905
+		return apply_filters('is_email', false, $email, 'domain_period_sequence');
2906 2906
 	}
2907 2907
 
2908 2908
 	// Test for leading and trailing periods and whitespace
2909
-	if ( trim( $domain, " \t\n\r\0\x0B." ) !== $domain ) {
2909
+	if (trim($domain, " \t\n\r\0\x0B.") !== $domain) {
2910 2910
 		/** This filter is documented in wp-includes/formatting.php */
2911
-		return apply_filters( 'is_email', false, $email, 'domain_period_limits' );
2911
+		return apply_filters('is_email', false, $email, 'domain_period_limits');
2912 2912
 	}
2913 2913
 
2914 2914
 	// Split the domain into subs
2915
-	$subs = explode( '.', $domain );
2915
+	$subs = explode('.', $domain);
2916 2916
 
2917 2917
 	// Assume the domain will have at least two subs
2918
-	if ( 2 > count( $subs ) ) {
2918
+	if (2 > count($subs)) {
2919 2919
 		/** This filter is documented in wp-includes/formatting.php */
2920
-		return apply_filters( 'is_email', false, $email, 'domain_no_periods' );
2920
+		return apply_filters('is_email', false, $email, 'domain_no_periods');
2921 2921
 	}
2922 2922
 
2923 2923
 	// Loop through each sub
2924
-	foreach ( $subs as $sub ) {
2924
+	foreach ($subs as $sub) {
2925 2925
 		// Test for leading and trailing hyphens and whitespace
2926
-		if ( trim( $sub, " \t\n\r\0\x0B-" ) !== $sub ) {
2926
+		if (trim($sub, " \t\n\r\0\x0B-") !== $sub) {
2927 2927
 			/** This filter is documented in wp-includes/formatting.php */
2928
-			return apply_filters( 'is_email', false, $email, 'sub_hyphen_limits' );
2928
+			return apply_filters('is_email', false, $email, 'sub_hyphen_limits');
2929 2929
 		}
2930 2930
 
2931 2931
 		// Test for invalid characters
2932
-		if ( !preg_match('/^[a-z0-9-]+$/i', $sub ) ) {
2932
+		if ( ! preg_match('/^[a-z0-9-]+$/i', $sub)) {
2933 2933
 			/** This filter is documented in wp-includes/formatting.php */
2934
-			return apply_filters( 'is_email', false, $email, 'sub_invalid_chars' );
2934
+			return apply_filters('is_email', false, $email, 'sub_invalid_chars');
2935 2935
 		}
2936 2936
 	}
2937 2937
 
2938 2938
 	// Congratulations your email made it!
2939 2939
 	/** This filter is documented in wp-includes/formatting.php */
2940
-	return apply_filters( 'is_email', $email, $email, null );
2940
+	return apply_filters('is_email', $email, $email, null);
2941 2941
 }
2942 2942
 
2943 2943
 /**
@@ -2948,13 +2948,13 @@  discard block
 block discarded – undo
2948 2948
  * @param string $string Subject line
2949 2949
  * @return string Converted string to ASCII
2950 2950
  */
2951
-function wp_iso_descrambler( $string ) {
2951
+function wp_iso_descrambler($string) {
2952 2952
 	/* this may only work with iso-8859-1, I'm afraid */
2953
-	if (!preg_match('#\=\?(.+)\?Q\?(.+)\?\=#i', $string, $matches)) {
2953
+	if ( ! preg_match('#\=\?(.+)\?Q\?(.+)\?\=#i', $string, $matches)) {
2954 2954
 		return $string;
2955 2955
 	} else {
2956 2956
 		$subject = str_replace('_', ' ', $matches[2]);
2957
-		return preg_replace_callback( '#\=([0-9a-f]{2})#i', '_wp_iso_convert', $subject );
2957
+		return preg_replace_callback('#\=([0-9a-f]{2})#i', '_wp_iso_convert', $subject);
2958 2958
 	}
2959 2959
 }
2960 2960
 
@@ -2967,8 +2967,8 @@  discard block
 block discarded – undo
2967 2967
  * @param array $match The preg_replace_callback matches array
2968 2968
  * @return string Converted chars
2969 2969
  */
2970
-function _wp_iso_convert( $match ) {
2971
-	return chr( hexdec( strtolower( $match[1] ) ) );
2970
+function _wp_iso_convert($match) {
2971
+	return chr(hexdec(strtolower($match[1])));
2972 2972
 }
2973 2973
 
2974 2974
 /**
@@ -2985,25 +2985,25 @@  discard block
 block discarded – undo
2985 2985
  * @param string $format The format string for the returned date (default is Y-m-d H:i:s)
2986 2986
  * @return string GMT version of the date provided.
2987 2987
  */
2988
-function get_gmt_from_date( $string, $format = 'Y-m-d H:i:s' ) {
2989
-	$tz = get_option( 'timezone_string' );
2990
-	if ( $tz ) {
2991
-		$datetime = date_create( $string, new DateTimeZone( $tz ) );
2992
-		if ( ! $datetime ) {
2993
-			return gmdate( $format, 0 );
2988
+function get_gmt_from_date($string, $format = 'Y-m-d H:i:s') {
2989
+	$tz = get_option('timezone_string');
2990
+	if ($tz) {
2991
+		$datetime = date_create($string, new DateTimeZone($tz));
2992
+		if ( ! $datetime) {
2993
+			return gmdate($format, 0);
2994 2994
 		}
2995
-		$datetime->setTimezone( new DateTimeZone( 'UTC' ) );
2996
-		$string_gmt = $datetime->format( $format );
2995
+		$datetime->setTimezone(new DateTimeZone('UTC'));
2996
+		$string_gmt = $datetime->format($format);
2997 2997
 	} else {
2998
-		if ( ! preg_match( '#([0-9]{1,4})-([0-9]{1,2})-([0-9]{1,2}) ([0-9]{1,2}):([0-9]{1,2}):([0-9]{1,2})#', $string, $matches ) ) {
2999
-			$datetime = strtotime( $string );
3000
-			if ( false === $datetime ) {
3001
-				return gmdate( $format, 0 );
2998
+		if ( ! preg_match('#([0-9]{1,4})-([0-9]{1,2})-([0-9]{1,2}) ([0-9]{1,2}):([0-9]{1,2}):([0-9]{1,2})#', $string, $matches)) {
2999
+			$datetime = strtotime($string);
3000
+			if (false === $datetime) {
3001
+				return gmdate($format, 0);
3002 3002
 			}
3003
-			return gmdate( $format, $datetime );
3003
+			return gmdate($format, $datetime);
3004 3004
 		}
3005
-		$string_time = gmmktime( $matches[4], $matches[5], $matches[6], $matches[2], $matches[3], $matches[1] );
3006
-		$string_gmt = gmdate( $format, $string_time - get_option( 'gmt_offset' ) * HOUR_IN_SECONDS );
3005
+		$string_time = gmmktime($matches[4], $matches[5], $matches[6], $matches[2], $matches[3], $matches[1]);
3006
+		$string_gmt = gmdate($format, $string_time - get_option('gmt_offset') * HOUR_IN_SECONDS);
3007 3007
 	}
3008 3008
 	return $string_gmt;
3009 3009
 }
@@ -3022,19 +3022,19 @@  discard block
 block discarded – undo
3022 3022
  * @param string $format The format string for the returned date (default is Y-m-d H:i:s)
3023 3023
  * @return string Formatted date relative to the timezone / GMT offset.
3024 3024
  */
3025
-function get_date_from_gmt( $string, $format = 'Y-m-d H:i:s' ) {
3026
-	$tz = get_option( 'timezone_string' );
3027
-	if ( $tz ) {
3028
-		$datetime = date_create( $string, new DateTimeZone( 'UTC' ) );
3029
-		if ( ! $datetime )
3030
-			return date( $format, 0 );
3031
-		$datetime->setTimezone( new DateTimeZone( $tz ) );
3032
-		$string_localtime = $datetime->format( $format );
3025
+function get_date_from_gmt($string, $format = 'Y-m-d H:i:s') {
3026
+	$tz = get_option('timezone_string');
3027
+	if ($tz) {
3028
+		$datetime = date_create($string, new DateTimeZone('UTC'));
3029
+		if ( ! $datetime)
3030
+			return date($format, 0);
3031
+		$datetime->setTimezone(new DateTimeZone($tz));
3032
+		$string_localtime = $datetime->format($format);
3033 3033
 	} else {
3034
-		if ( ! preg_match('#([0-9]{1,4})-([0-9]{1,2})-([0-9]{1,2}) ([0-9]{1,2}):([0-9]{1,2}):([0-9]{1,2})#', $string, $matches) )
3035
-			return date( $format, 0 );
3036
-		$string_time = gmmktime( $matches[4], $matches[5], $matches[6], $matches[2], $matches[3], $matches[1] );
3037
-		$string_localtime = gmdate( $format, $string_time + get_option( 'gmt_offset' ) * HOUR_IN_SECONDS );
3034
+		if ( ! preg_match('#([0-9]{1,4})-([0-9]{1,2})-([0-9]{1,2}) ([0-9]{1,2}):([0-9]{1,2}):([0-9]{1,2})#', $string, $matches))
3035
+			return date($format, 0);
3036
+		$string_time = gmmktime($matches[4], $matches[5], $matches[6], $matches[2], $matches[3], $matches[1]);
3037
+		$string_localtime = gmdate($format, $string_time + get_option('gmt_offset') * HOUR_IN_SECONDS);
3038 3038
 	}
3039 3039
 	return $string_localtime;
3040 3040
 }
@@ -3047,7 +3047,7 @@  discard block
 block discarded – undo
3047 3047
  * @param string $timezone Either 'Z' for 0 offset or '±hhmm'.
3048 3048
  * @return int|float The offset in seconds.
3049 3049
  */
3050
-function iso8601_timezone_to_offset( $timezone ) {
3050
+function iso8601_timezone_to_offset($timezone) {
3051 3051
 	// $timezone is either 'Z' or '[+|-]hhmm'
3052 3052
 	if ($timezone == 'Z') {
3053 3053
 		$offset = 0;
@@ -3069,14 +3069,14 @@  discard block
 block discarded – undo
3069 3069
  * @param string $timezone    Optional. If set to GMT returns the time minus gmt_offset. Default is 'user'.
3070 3070
  * @return string The date and time in MySQL DateTime format - Y-m-d H:i:s.
3071 3071
  */
3072
-function iso8601_to_datetime( $date_string, $timezone = 'user' ) {
3072
+function iso8601_to_datetime($date_string, $timezone = 'user') {
3073 3073
 	$timezone = strtolower($timezone);
3074 3074
 
3075 3075
 	if ($timezone == 'gmt') {
3076 3076
 
3077 3077
 		preg_match('#([0-9]{4})([0-9]{2})([0-9]{2})T([0-9]{2}):([0-9]{2}):([0-9]{2})(Z|[\+|\-][0-9]{2,4}){0,1}#', $date_string, $date_bits);
3078 3078
 
3079
-		if (!empty($date_bits[7])) { // we have a timezone, so let's compute an offset
3079
+		if ( ! empty($date_bits[7])) { // we have a timezone, so let's compute an offset
3080 3080
 			$offset = iso8601_timezone_to_offset($date_bits[7]);
3081 3081
 		} else { // we don't have a timezone, so we assume user local timezone (not server's!)
3082 3082
 			$offset = HOUR_IN_SECONDS * get_option('gmt_offset');
@@ -3100,9 +3100,9 @@  discard block
 block discarded – undo
3100 3100
  * @param string $email Email address to filter.
3101 3101
  * @return string Filtered email address.
3102 3102
  */
3103
-function sanitize_email( $email ) {
3103
+function sanitize_email($email) {
3104 3104
 	// Test for the minimum length the email can be
3105
-	if ( strlen( $email ) < 3 ) {
3105
+	if (strlen($email) < 3) {
3106 3106
 		/**
3107 3107
 		 * Filters a sanitized email address.
3108 3108
 		 *
@@ -3116,82 +3116,82 @@  discard block
 block discarded – undo
3116 3116
 		 * @param string $email   The email address, as provided to sanitize_email().
3117 3117
 		 * @param string $message A message to pass to the user.
3118 3118
 		 */
3119
-		return apply_filters( 'sanitize_email', '', $email, 'email_too_short' );
3119
+		return apply_filters('sanitize_email', '', $email, 'email_too_short');
3120 3120
 	}
3121 3121
 
3122 3122
 	// Test for an @ character after the first position
3123
-	if ( strpos( $email, '@', 1 ) === false ) {
3123
+	if (strpos($email, '@', 1) === false) {
3124 3124
 		/** This filter is documented in wp-includes/formatting.php */
3125
-		return apply_filters( 'sanitize_email', '', $email, 'email_no_at' );
3125
+		return apply_filters('sanitize_email', '', $email, 'email_no_at');
3126 3126
 	}
3127 3127
 
3128 3128
 	// Split out the local and domain parts
3129
-	list( $local, $domain ) = explode( '@', $email, 2 );
3129
+	list($local, $domain) = explode('@', $email, 2);
3130 3130
 
3131 3131
 	// LOCAL PART
3132 3132
 	// Test for invalid characters
3133
-	$local = preg_replace( '/[^a-zA-Z0-9!#$%&\'*+\/=?^_`{|}~\.-]/', '', $local );
3134
-	if ( '' === $local ) {
3133
+	$local = preg_replace('/[^a-zA-Z0-9!#$%&\'*+\/=?^_`{|}~\.-]/', '', $local);
3134
+	if ('' === $local) {
3135 3135
 		/** This filter is documented in wp-includes/formatting.php */
3136
-		return apply_filters( 'sanitize_email', '', $email, 'local_invalid_chars' );
3136
+		return apply_filters('sanitize_email', '', $email, 'local_invalid_chars');
3137 3137
 	}
3138 3138
 
3139 3139
 	// DOMAIN PART
3140 3140
 	// Test for sequences of periods
3141
-	$domain = preg_replace( '/\.{2,}/', '', $domain );
3142
-	if ( '' === $domain ) {
3141
+	$domain = preg_replace('/\.{2,}/', '', $domain);
3142
+	if ('' === $domain) {
3143 3143
 		/** This filter is documented in wp-includes/formatting.php */
3144
-		return apply_filters( 'sanitize_email', '', $email, 'domain_period_sequence' );
3144
+		return apply_filters('sanitize_email', '', $email, 'domain_period_sequence');
3145 3145
 	}
3146 3146
 
3147 3147
 	// Test for leading and trailing periods and whitespace
3148
-	$domain = trim( $domain, " \t\n\r\0\x0B." );
3149
-	if ( '' === $domain ) {
3148
+	$domain = trim($domain, " \t\n\r\0\x0B.");
3149
+	if ('' === $domain) {
3150 3150
 		/** This filter is documented in wp-includes/formatting.php */
3151
-		return apply_filters( 'sanitize_email', '', $email, 'domain_period_limits' );
3151
+		return apply_filters('sanitize_email', '', $email, 'domain_period_limits');
3152 3152
 	}
3153 3153
 
3154 3154
 	// Split the domain into subs
3155
-	$subs = explode( '.', $domain );
3155
+	$subs = explode('.', $domain);
3156 3156
 
3157 3157
 	// Assume the domain will have at least two subs
3158
-	if ( 2 > count( $subs ) ) {
3158
+	if (2 > count($subs)) {
3159 3159
 		/** This filter is documented in wp-includes/formatting.php */
3160
-		return apply_filters( 'sanitize_email', '', $email, 'domain_no_periods' );
3160
+		return apply_filters('sanitize_email', '', $email, 'domain_no_periods');
3161 3161
 	}
3162 3162
 
3163 3163
 	// Create an array that will contain valid subs
3164 3164
 	$new_subs = array();
3165 3165
 
3166 3166
 	// Loop through each sub
3167
-	foreach ( $subs as $sub ) {
3167
+	foreach ($subs as $sub) {
3168 3168
 		// Test for leading and trailing hyphens
3169
-		$sub = trim( $sub, " \t\n\r\0\x0B-" );
3169
+		$sub = trim($sub, " \t\n\r\0\x0B-");
3170 3170
 
3171 3171
 		// Test for invalid characters
3172
-		$sub = preg_replace( '/[^a-z0-9-]+/i', '', $sub );
3172
+		$sub = preg_replace('/[^a-z0-9-]+/i', '', $sub);
3173 3173
 
3174 3174
 		// If there's anything left, add it to the valid subs
3175
-		if ( '' !== $sub ) {
3175
+		if ('' !== $sub) {
3176 3176
 			$new_subs[] = $sub;
3177 3177
 		}
3178 3178
 	}
3179 3179
 
3180 3180
 	// If there aren't 2 or more valid subs
3181
-	if ( 2 > count( $new_subs ) ) {
3181
+	if (2 > count($new_subs)) {
3182 3182
 		/** This filter is documented in wp-includes/formatting.php */
3183
-		return apply_filters( 'sanitize_email', '', $email, 'domain_no_valid_subs' );
3183
+		return apply_filters('sanitize_email', '', $email, 'domain_no_valid_subs');
3184 3184
 	}
3185 3185
 
3186 3186
 	// Join valid subs into the new domain
3187
-	$domain = join( '.', $new_subs );
3187
+	$domain = join('.', $new_subs);
3188 3188
 
3189 3189
 	// Put the email back together
3190
-	$email = $local . '@' . $domain;
3190
+	$email = $local.'@'.$domain;
3191 3191
 
3192 3192
 	// Congratulations your email made it!
3193 3193
 	/** This filter is documented in wp-includes/formatting.php */
3194
-	return apply_filters( 'sanitize_email', $email, $email, null );
3194
+	return apply_filters('sanitize_email', $email, $email, null);
3195 3195
 }
3196 3196
 
3197 3197
 /**
@@ -3206,49 +3206,49 @@  discard block
 block discarded – undo
3206 3206
  * @param int $to   Optional. Unix timestamp to end the time difference. Default becomes time() if not set.
3207 3207
  * @return string Human readable time difference.
3208 3208
  */
3209
-function human_time_diff( $from, $to = '' ) {
3210
-	if ( empty( $to ) ) {
3209
+function human_time_diff($from, $to = '') {
3210
+	if (empty($to)) {
3211 3211
 		$to = time();
3212 3212
 	}
3213 3213
 
3214
-	$diff = (int) abs( $to - $from );
3214
+	$diff = (int) abs($to - $from);
3215 3215
 
3216
-	if ( $diff < HOUR_IN_SECONDS ) {
3217
-		$mins = round( $diff / MINUTE_IN_SECONDS );
3218
-		if ( $mins <= 1 )
3216
+	if ($diff < HOUR_IN_SECONDS) {
3217
+		$mins = round($diff / MINUTE_IN_SECONDS);
3218
+		if ($mins <= 1)
3219 3219
 			$mins = 1;
3220 3220
 		/* translators: Time difference between two dates, in minutes (min=minute). 1: Number of minutes */
3221
-		$since = sprintf( _n( '%s min', '%s mins', $mins ), $mins );
3222
-	} elseif ( $diff < DAY_IN_SECONDS && $diff >= HOUR_IN_SECONDS ) {
3223
-		$hours = round( $diff / HOUR_IN_SECONDS );
3224
-		if ( $hours <= 1 )
3221
+		$since = sprintf(_n('%s min', '%s mins', $mins), $mins);
3222
+	} elseif ($diff < DAY_IN_SECONDS && $diff >= HOUR_IN_SECONDS) {
3223
+		$hours = round($diff / HOUR_IN_SECONDS);
3224
+		if ($hours <= 1)
3225 3225
 			$hours = 1;
3226 3226
 		/* translators: Time difference between two dates, in hours. 1: Number of hours */
3227
-		$since = sprintf( _n( '%s hour', '%s hours', $hours ), $hours );
3228
-	} elseif ( $diff < WEEK_IN_SECONDS && $diff >= DAY_IN_SECONDS ) {
3229
-		$days = round( $diff / DAY_IN_SECONDS );
3230
-		if ( $days <= 1 )
3227
+		$since = sprintf(_n('%s hour', '%s hours', $hours), $hours);
3228
+	} elseif ($diff < WEEK_IN_SECONDS && $diff >= DAY_IN_SECONDS) {
3229
+		$days = round($diff / DAY_IN_SECONDS);
3230
+		if ($days <= 1)
3231 3231
 			$days = 1;
3232 3232
 		/* translators: Time difference between two dates, in days. 1: Number of days */
3233
-		$since = sprintf( _n( '%s day', '%s days', $days ), $days );
3234
-	} elseif ( $diff < MONTH_IN_SECONDS && $diff >= WEEK_IN_SECONDS ) {
3235
-		$weeks = round( $diff / WEEK_IN_SECONDS );
3236
-		if ( $weeks <= 1 )
3233
+		$since = sprintf(_n('%s day', '%s days', $days), $days);
3234
+	} elseif ($diff < MONTH_IN_SECONDS && $diff >= WEEK_IN_SECONDS) {
3235
+		$weeks = round($diff / WEEK_IN_SECONDS);
3236
+		if ($weeks <= 1)
3237 3237
 			$weeks = 1;
3238 3238
 		/* translators: Time difference between two dates, in weeks. 1: Number of weeks */
3239
-		$since = sprintf( _n( '%s week', '%s weeks', $weeks ), $weeks );
3240
-	} elseif ( $diff < YEAR_IN_SECONDS && $diff >= MONTH_IN_SECONDS ) {
3241
-		$months = round( $diff / MONTH_IN_SECONDS );
3242
-		if ( $months <= 1 )
3239
+		$since = sprintf(_n('%s week', '%s weeks', $weeks), $weeks);
3240
+	} elseif ($diff < YEAR_IN_SECONDS && $diff >= MONTH_IN_SECONDS) {
3241
+		$months = round($diff / MONTH_IN_SECONDS);
3242
+		if ($months <= 1)
3243 3243
 			$months = 1;
3244 3244
 		/* translators: Time difference between two dates, in months. 1: Number of months */
3245
-		$since = sprintf( _n( '%s month', '%s months', $months ), $months );
3246
-	} elseif ( $diff >= YEAR_IN_SECONDS ) {
3247
-		$years = round( $diff / YEAR_IN_SECONDS );
3248
-		if ( $years <= 1 )
3245
+		$since = sprintf(_n('%s month', '%s months', $months), $months);
3246
+	} elseif ($diff >= YEAR_IN_SECONDS) {
3247
+		$years = round($diff / YEAR_IN_SECONDS);
3248
+		if ($years <= 1)
3249 3249
 			$years = 1;
3250 3250
 		/* translators: Time difference between two dates, in years. 1: Number of years */
3251
-		$since = sprintf( _n( '%s year', '%s years', $years ), $years );
3251
+		$since = sprintf(_n('%s year', '%s years', $years), $years);
3252 3252
 	}
3253 3253
 
3254 3254
 	/**
@@ -3261,7 +3261,7 @@  discard block
 block discarded – undo
3261 3261
 	 * @param int    $from  Unix timestamp from which the difference begins.
3262 3262
 	 * @param int    $to    Unix timestamp to end the time difference.
3263 3263
 	 */
3264
-	return apply_filters( 'human_time_diff', $since, $diff, $from, $to );
3264
+	return apply_filters('human_time_diff', $since, $diff, $from, $to);
3265 3265
 }
3266 3266
 
3267 3267
 /**
@@ -3279,15 +3279,15 @@  discard block
 block discarded – undo
3279 3279
  * @param string $text Optional. The excerpt. If set to empty, an excerpt is generated.
3280 3280
  * @return string The excerpt.
3281 3281
  */
3282
-function wp_trim_excerpt( $text = '' ) {
3282
+function wp_trim_excerpt($text = '') {
3283 3283
 	$raw_excerpt = $text;
3284
-	if ( '' == $text ) {
3284
+	if ('' == $text) {
3285 3285
 		$text = get_the_content('');
3286 3286
 
3287
-		$text = strip_shortcodes( $text );
3287
+		$text = strip_shortcodes($text);
3288 3288
 
3289 3289
 		/** This filter is documented in wp-includes/post-template.php */
3290
-		$text = apply_filters( 'the_content', $text );
3290
+		$text = apply_filters('the_content', $text);
3291 3291
 		$text = str_replace(']]>', ']]&gt;', $text);
3292 3292
 
3293 3293
 		/**
@@ -3297,7 +3297,7 @@  discard block
 block discarded – undo
3297 3297
 		 *
3298 3298
 		 * @param int $number The number of words. Default 55.
3299 3299
 		 */
3300
-		$excerpt_length = apply_filters( 'excerpt_length', 55 );
3300
+		$excerpt_length = apply_filters('excerpt_length', 55);
3301 3301
 		/**
3302 3302
 		 * Filters the string in the "more" link displayed after a trimmed excerpt.
3303 3303
 		 *
@@ -3305,8 +3305,8 @@  discard block
 block discarded – undo
3305 3305
 		 *
3306 3306
 		 * @param string $more_string The string shown within the more link.
3307 3307
 		 */
3308
-		$excerpt_more = apply_filters( 'excerpt_more', ' ' . '[&hellip;]' );
3309
-		$text = wp_trim_words( $text, $excerpt_length, $excerpt_more );
3308
+		$excerpt_more = apply_filters('excerpt_more', ' '.'[&hellip;]');
3309
+		$text = wp_trim_words($text, $excerpt_length, $excerpt_more);
3310 3310
 	}
3311 3311
 	/**
3312 3312
 	 * Filters the trimmed excerpt string.
@@ -3316,7 +3316,7 @@  discard block
 block discarded – undo
3316 3316
 	 * @param string $text        The trimmed text.
3317 3317
 	 * @param string $raw_excerpt The text prior to trimming.
3318 3318
 	 */
3319
-	return apply_filters( 'wp_trim_excerpt', $text, $raw_excerpt );
3319
+	return apply_filters('wp_trim_excerpt', $text, $raw_excerpt);
3320 3320
 }
3321 3321
 
3322 3322
 /**
@@ -3333,35 +3333,35 @@  discard block
 block discarded – undo
3333 3333
  * @param string $more      Optional. What to append if $text needs to be trimmed. Default '&hellip;'.
3334 3334
  * @return string Trimmed text.
3335 3335
  */
3336
-function wp_trim_words( $text, $num_words = 55, $more = null ) {
3337
-	if ( null === $more ) {
3338
-		$more = __( '&hellip;' );
3336
+function wp_trim_words($text, $num_words = 55, $more = null) {
3337
+	if (null === $more) {
3338
+		$more = __('&hellip;');
3339 3339
 	}
3340 3340
 
3341 3341
 	$original_text = $text;
3342
-	$text = wp_strip_all_tags( $text );
3342
+	$text = wp_strip_all_tags($text);
3343 3343
 
3344 3344
 	/*
3345 3345
 	 * translators: If your word count is based on single characters (e.g. East Asian characters),
3346 3346
 	 * enter 'characters_excluding_spaces' or 'characters_including_spaces'. Otherwise, enter 'words'.
3347 3347
 	 * Do not translate into your own language.
3348 3348
 	 */
3349
-	if ( strpos( _x( 'words', 'Word count type. Do not translate!' ), 'characters' ) === 0 && preg_match( '/^utf\-?8$/i', get_option( 'blog_charset' ) ) ) {
3350
-		$text = trim( preg_replace( "/[\n\r\t ]+/", ' ', $text ), ' ' );
3351
-		preg_match_all( '/./u', $text, $words_array );
3352
-		$words_array = array_slice( $words_array[0], 0, $num_words + 1 );
3349
+	if (strpos(_x('words', 'Word count type. Do not translate!'), 'characters') === 0 && preg_match('/^utf\-?8$/i', get_option('blog_charset'))) {
3350
+		$text = trim(preg_replace("/[\n\r\t ]+/", ' ', $text), ' ');
3351
+		preg_match_all('/./u', $text, $words_array);
3352
+		$words_array = array_slice($words_array[0], 0, $num_words + 1);
3353 3353
 		$sep = '';
3354 3354
 	} else {
3355
-		$words_array = preg_split( "/[\n\r\t ]+/", $text, $num_words + 1, PREG_SPLIT_NO_EMPTY );
3355
+		$words_array = preg_split("/[\n\r\t ]+/", $text, $num_words + 1, PREG_SPLIT_NO_EMPTY);
3356 3356
 		$sep = ' ';
3357 3357
 	}
3358 3358
 
3359
-	if ( count( $words_array ) > $num_words ) {
3360
-		array_pop( $words_array );
3361
-		$text = implode( $sep, $words_array );
3362
-		$text = $text . $more;
3359
+	if (count($words_array) > $num_words) {
3360
+		array_pop($words_array);
3361
+		$text = implode($sep, $words_array);
3362
+		$text = $text.$more;
3363 3363
 	} else {
3364
-		$text = implode( $sep, $words_array );
3364
+		$text = implode($sep, $words_array);
3365 3365
 	}
3366 3366
 
3367 3367
 	/**
@@ -3374,7 +3374,7 @@  discard block
 block discarded – undo
3374 3374
 	 * @param string $more          An optional string to append to the end of the trimmed text, e.g. &hellip;.
3375 3375
 	 * @param string $original_text The text before it was trimmed.
3376 3376
 	 */
3377
-	return apply_filters( 'wp_trim_words', $text, $num_words, $more, $original_text );
3377
+	return apply_filters('wp_trim_words', $text, $num_words, $more, $original_text);
3378 3378
 }
3379 3379
 
3380 3380
 /**
@@ -3385,7 +3385,7 @@  discard block
 block discarded – undo
3385 3385
  * @param string $text The text within which entities will be converted.
3386 3386
  * @return string Text with converted entities.
3387 3387
  */
3388
-function ent2ncr( $text ) {
3388
+function ent2ncr($text) {
3389 3389
 
3390 3390
 	/**
3391 3391
 	 * Filters text before named entities are converted into numbered entities.
@@ -3397,8 +3397,8 @@  discard block
 block discarded – undo
3397 3397
 	 * @param null   $converted_text The text to be converted. Default null.
3398 3398
 	 * @param string $text           The text prior to entity conversion.
3399 3399
 	 */
3400
-	$filtered = apply_filters( 'pre_ent2ncr', null, $text );
3401
-	if ( null !== $filtered )
3400
+	$filtered = apply_filters('pre_ent2ncr', null, $text);
3401
+	if (null !== $filtered)
3402 3402
 		return $filtered;
3403 3403
 
3404 3404
 	$to_ncr = array(
@@ -3660,7 +3660,7 @@  discard block
 block discarded – undo
3660 3660
 		'&diams;' => '&#9830;'
3661 3661
 	);
3662 3662
 
3663
-	return str_replace( array_keys($to_ncr), array_values($to_ncr), $text );
3663
+	return str_replace(array_keys($to_ncr), array_values($to_ncr), $text);
3664 3664
 }
3665 3665
 
3666 3666
 /**
@@ -3681,9 +3681,9 @@  discard block
 block discarded – undo
3681 3681
  *                               It is usually either 'html' or 'tinymce'.
3682 3682
  * @return string The formatted text after filter is applied.
3683 3683
  */
3684
-function format_for_editor( $text, $default_editor = null ) {
3685
-	if ( $text ) {
3686
-		$text = htmlspecialchars( $text, ENT_NOQUOTES, get_option( 'blog_charset' ) );
3684
+function format_for_editor($text, $default_editor = null) {
3685
+	if ($text) {
3686
+		$text = htmlspecialchars($text, ENT_NOQUOTES, get_option('blog_charset'));
3687 3687
 	}
3688 3688
 
3689 3689
 	/**
@@ -3695,7 +3695,7 @@  discard block
 block discarded – undo
3695 3695
 	 * @param string $default_editor The default editor for the current user.
3696 3696
 	 *                               It is usually either 'html' or 'tinymce'.
3697 3697
 	 */
3698
-	return apply_filters( 'format_for_editor', $text, $default_editor );
3698
+	return apply_filters('format_for_editor', $text, $default_editor);
3699 3699
 }
3700 3700
 
3701 3701
 /**
@@ -3713,12 +3713,12 @@  discard block
 block discarded – undo
3713 3713
  * @param string       $subject The string being searched and replaced on, otherwise known as the haystack.
3714 3714
  * @return string The string with the replaced svalues.
3715 3715
  */
3716
-function _deep_replace( $search, $subject ) {
3716
+function _deep_replace($search, $subject) {
3717 3717
 	$subject = (string) $subject;
3718 3718
 
3719 3719
 	$count = 1;
3720
-	while ( $count ) {
3721
-		$subject = str_replace( $search, '', $subject, $count );
3720
+	while ($count) {
3721
+		$subject = str_replace($search, '', $subject, $count);
3722 3722
 	}
3723 3723
 
3724 3724
 	return $subject;
@@ -3738,9 +3738,9 @@  discard block
 block discarded – undo
3738 3738
  * @param string|array $data Unescaped data
3739 3739
  * @return string|array Escaped data
3740 3740
  */
3741
-function esc_sql( $data ) {
3741
+function esc_sql($data) {
3742 3742
 	global $wpdb;
3743
-	return $wpdb->_escape( $data );
3743
+	return $wpdb->_escape($data);
3744 3744
 }
3745 3745
 
3746 3746
 /**
@@ -3758,20 +3758,20 @@  discard block
 block discarded – undo
3758 3758
  * @param string $_context  Private. Use esc_url_raw() for database usage.
3759 3759
  * @return string The cleaned $url after the {@see 'clean_url'} filter is applied.
3760 3760
  */
3761
-function esc_url( $url, $protocols = null, $_context = 'display' ) {
3761
+function esc_url($url, $protocols = null, $_context = 'display') {
3762 3762
 	$original_url = $url;
3763 3763
 
3764
-	if ( '' == $url )
3764
+	if ('' == $url)
3765 3765
 		return $url;
3766 3766
 
3767
-	$url = str_replace( ' ', '%20', $url );
3767
+	$url = str_replace(' ', '%20', $url);
3768 3768
 	$url = preg_replace('|[^a-z0-9-~+_.?#=!&;,/:%@$\|*\'()\[\]\\x80-\\xff]|i', '', $url);
3769 3769
 
3770
-	if ( '' === $url ) {
3770
+	if ('' === $url) {
3771 3771
 		return $url;
3772 3772
 	}
3773 3773
 
3774
-	if ( 0 !== stripos( $url, 'mailto:' ) ) {
3774
+	if (0 !== stripos($url, 'mailto:')) {
3775 3775
 		$strip = array('%0d', '%0a', '%0D', '%0A');
3776 3776
 		$url = _deep_replace($strip, $url);
3777 3777
 	}
@@ -3781,61 +3781,61 @@  discard block
 block discarded – undo
3781 3781
 	 * presume it needs http:// prepended (unless a relative
3782 3782
 	 * link starting with /, # or ? or a php file).
3783 3783
 	 */
3784
-	if ( strpos($url, ':') === false && ! in_array( $url[0], array( '/', '#', '?' ) ) &&
3785
-		! preg_match('/^[a-z0-9-]+?\.php/i', $url) )
3786
-		$url = 'http://' . $url;
3784
+	if (strpos($url, ':') === false && ! in_array($url[0], array('/', '#', '?')) &&
3785
+		! preg_match('/^[a-z0-9-]+?\.php/i', $url))
3786
+		$url = 'http://'.$url;
3787 3787
 
3788 3788
 	// Replace ampersands and single quotes only when displaying.
3789
-	if ( 'display' == $_context ) {
3790
-		$url = wp_kses_normalize_entities( $url );
3791
-		$url = str_replace( '&amp;', '&#038;', $url );
3792
-		$url = str_replace( "'", '&#039;', $url );
3789
+	if ('display' == $_context) {
3790
+		$url = wp_kses_normalize_entities($url);
3791
+		$url = str_replace('&amp;', '&#038;', $url);
3792
+		$url = str_replace("'", '&#039;', $url);
3793 3793
 	}
3794 3794
 
3795
-	if ( ( false !== strpos( $url, '[' ) ) || ( false !== strpos( $url, ']' ) ) ) {
3795
+	if ((false !== strpos($url, '[')) || (false !== strpos($url, ']'))) {
3796 3796
 
3797
-		$parsed = wp_parse_url( $url );
3797
+		$parsed = wp_parse_url($url);
3798 3798
 		$front  = '';
3799 3799
 
3800
-		if ( isset( $parsed['scheme'] ) ) {
3801
-			$front .= $parsed['scheme'] . '://';
3802
-		} elseif ( '/' === $url[0] ) {
3800
+		if (isset($parsed['scheme'])) {
3801
+			$front .= $parsed['scheme'].'://';
3802
+		} elseif ('/' === $url[0]) {
3803 3803
 			$front .= '//';
3804 3804
 		}
3805 3805
 
3806
-		if ( isset( $parsed['user'] ) ) {
3806
+		if (isset($parsed['user'])) {
3807 3807
 			$front .= $parsed['user'];
3808 3808
 		}
3809 3809
 
3810
-		if ( isset( $parsed['pass'] ) ) {
3811
-			$front .= ':' . $parsed['pass'];
3810
+		if (isset($parsed['pass'])) {
3811
+			$front .= ':'.$parsed['pass'];
3812 3812
 		}
3813 3813
 
3814
-		if ( isset( $parsed['user'] ) || isset( $parsed['pass'] ) ) {
3814
+		if (isset($parsed['user']) || isset($parsed['pass'])) {
3815 3815
 			$front .= '@';
3816 3816
 		}
3817 3817
 
3818
-		if ( isset( $parsed['host'] ) ) {
3818
+		if (isset($parsed['host'])) {
3819 3819
 			$front .= $parsed['host'];
3820 3820
 		}
3821 3821
 
3822
-		if ( isset( $parsed['port'] ) ) {
3823
-			$front .= ':' . $parsed['port'];
3822
+		if (isset($parsed['port'])) {
3823
+			$front .= ':'.$parsed['port'];
3824 3824
 		}
3825 3825
 
3826
-		$end_dirty = str_replace( $front, '', $url );
3827
-		$end_clean = str_replace( array( '[', ']' ), array( '%5B', '%5D' ), $end_dirty );
3828
-		$url       = str_replace( $end_dirty, $end_clean, $url );
3826
+		$end_dirty = str_replace($front, '', $url);
3827
+		$end_clean = str_replace(array('[', ']'), array('%5B', '%5D'), $end_dirty);
3828
+		$url       = str_replace($end_dirty, $end_clean, $url);
3829 3829
 
3830 3830
 	}
3831 3831
 
3832
-	if ( '/' === $url[0] ) {
3832
+	if ('/' === $url[0]) {
3833 3833
 		$good_protocol_url = $url;
3834 3834
 	} else {
3835
-		if ( ! is_array( $protocols ) )
3835
+		if ( ! is_array($protocols))
3836 3836
 			$protocols = wp_allowed_protocols();
3837
-		$good_protocol_url = wp_kses_bad_protocol( $url, $protocols );
3838
-		if ( strtolower( $good_protocol_url ) != strtolower( $url ) )
3837
+		$good_protocol_url = wp_kses_bad_protocol($url, $protocols);
3838
+		if (strtolower($good_protocol_url) != strtolower($url))
3839 3839
 			return '';
3840 3840
 	}
3841 3841
 
@@ -3848,7 +3848,7 @@  discard block
 block discarded – undo
3848 3848
 	 * @param string $original_url      The URL prior to cleaning.
3849 3849
 	 * @param string $_context          If 'display', replace ampersands and single quotes only.
3850 3850
 	 */
3851
-	return apply_filters( 'clean_url', $good_protocol_url, $original_url, $_context );
3851
+	return apply_filters('clean_url', $good_protocol_url, $original_url, $_context);
3852 3852
 }
3853 3853
 
3854 3854
 /**
@@ -3860,8 +3860,8 @@  discard block
 block discarded – undo
3860 3860
  * @param array  $protocols An array of acceptable protocols.
3861 3861
  * @return string The cleaned URL.
3862 3862
  */
3863
-function esc_url_raw( $url, $protocols = null ) {
3864
-	return esc_url( $url, $protocols, 'db' );
3863
+function esc_url_raw($url, $protocols = null) {
3864
+	return esc_url($url, $protocols, 'db');
3865 3865
 }
3866 3866
 
3867 3867
 /**
@@ -3874,10 +3874,10 @@  discard block
 block discarded – undo
3874 3874
  * @param string $myHTML The text to be converted.
3875 3875
  * @return string Converted text.
3876 3876
  */
3877
-function htmlentities2( $myHTML ) {
3878
-	$translation_table = get_html_translation_table( HTML_ENTITIES, ENT_QUOTES );
3877
+function htmlentities2($myHTML) {
3878
+	$translation_table = get_html_translation_table(HTML_ENTITIES, ENT_QUOTES);
3879 3879
 	$translation_table[chr(38)] = '&';
3880
-	return preg_replace( "/&(?![A-Za-z]{0,4}\w{2,3};|#[0-9]{2,3};)/", "&amp;", strtr($myHTML, $translation_table) );
3880
+	return preg_replace("/&(?![A-Za-z]{0,4}\w{2,3};|#[0-9]{2,3};)/", "&amp;", strtr($myHTML, $translation_table));
3881 3881
 }
3882 3882
 
3883 3883
 /**
@@ -3892,12 +3892,12 @@  discard block
 block discarded – undo
3892 3892
  * @param string $text The text to be escaped.
3893 3893
  * @return string Escaped text.
3894 3894
  */
3895
-function esc_js( $text ) {
3896
-	$safe_text = wp_check_invalid_utf8( $text );
3897
-	$safe_text = _wp_specialchars( $safe_text, ENT_COMPAT );
3898
-	$safe_text = preg_replace( '/&#(x)?0*(?(1)27|39);?/i', "'", stripslashes( $safe_text ) );
3899
-	$safe_text = str_replace( "\r", '', $safe_text );
3900
-	$safe_text = str_replace( "\n", '\\n', addslashes( $safe_text ) );
3895
+function esc_js($text) {
3896
+	$safe_text = wp_check_invalid_utf8($text);
3897
+	$safe_text = _wp_specialchars($safe_text, ENT_COMPAT);
3898
+	$safe_text = preg_replace('/&#(x)?0*(?(1)27|39);?/i', "'", stripslashes($safe_text));
3899
+	$safe_text = str_replace("\r", '', $safe_text);
3900
+	$safe_text = str_replace("\n", '\\n', addslashes($safe_text));
3901 3901
 	/**
3902 3902
 	 * Filters a string cleaned and escaped for output in JavaScript.
3903 3903
 	 *
@@ -3909,7 +3909,7 @@  discard block
 block discarded – undo
3909 3909
 	 * @param string $safe_text The text after it has been escaped.
3910 3910
  	 * @param string $text      The text prior to being escaped.
3911 3911
 	 */
3912
-	return apply_filters( 'js_escape', $safe_text, $text );
3912
+	return apply_filters('js_escape', $safe_text, $text);
3913 3913
 }
3914 3914
 
3915 3915
 /**
@@ -3920,9 +3920,9 @@  discard block
 block discarded – undo
3920 3920
  * @param string $text
3921 3921
  * @return string
3922 3922
  */
3923
-function esc_html( $text ) {
3924
-	$safe_text = wp_check_invalid_utf8( $text );
3925
-	$safe_text = _wp_specialchars( $safe_text, ENT_QUOTES );
3923
+function esc_html($text) {
3924
+	$safe_text = wp_check_invalid_utf8($text);
3925
+	$safe_text = _wp_specialchars($safe_text, ENT_QUOTES);
3926 3926
 	/**
3927 3927
 	 * Filters a string cleaned and escaped for output in HTML.
3928 3928
 	 *
@@ -3934,7 +3934,7 @@  discard block
 block discarded – undo
3934 3934
 	 * @param string $safe_text The text after it has been escaped.
3935 3935
  	 * @param string $text      The text prior to being escaped.
3936 3936
 	 */
3937
-	return apply_filters( 'esc_html', $safe_text, $text );
3937
+	return apply_filters('esc_html', $safe_text, $text);
3938 3938
 }
3939 3939
 
3940 3940
 /**
@@ -3945,9 +3945,9 @@  discard block
 block discarded – undo
3945 3945
  * @param string $text
3946 3946
  * @return string
3947 3947
  */
3948
-function esc_attr( $text ) {
3949
-	$safe_text = wp_check_invalid_utf8( $text );
3950
-	$safe_text = _wp_specialchars( $safe_text, ENT_QUOTES );
3948
+function esc_attr($text) {
3949
+	$safe_text = wp_check_invalid_utf8($text);
3950
+	$safe_text = _wp_specialchars($safe_text, ENT_QUOTES);
3951 3951
 	/**
3952 3952
 	 * Filters a string cleaned and escaped for output in an HTML attribute.
3953 3953
 	 *
@@ -3959,7 +3959,7 @@  discard block
 block discarded – undo
3959 3959
 	 * @param string $safe_text The text after it has been escaped.
3960 3960
  	 * @param string $text      The text prior to being escaped.
3961 3961
 	 */
3962
-	return apply_filters( 'attribute_escape', $safe_text, $text );
3962
+	return apply_filters('attribute_escape', $safe_text, $text);
3963 3963
 }
3964 3964
 
3965 3965
 /**
@@ -3970,8 +3970,8 @@  discard block
 block discarded – undo
3970 3970
  * @param string $text
3971 3971
  * @return string
3972 3972
  */
3973
-function esc_textarea( $text ) {
3974
-	$safe_text = htmlspecialchars( $text, ENT_QUOTES, get_option( 'blog_charset' ) );
3973
+function esc_textarea($text) {
3974
+	$safe_text = htmlspecialchars($text, ENT_QUOTES, get_option('blog_charset'));
3975 3975
 	/**
3976 3976
 	 * Filters a string cleaned and escaped for output in a textarea element.
3977 3977
 	 *
@@ -3980,7 +3980,7 @@  discard block
 block discarded – undo
3980 3980
 	 * @param string $safe_text The text after it has been escaped.
3981 3981
  	 * @param string $text      The text prior to being escaped.
3982 3982
 	 */
3983
-	return apply_filters( 'esc_textarea', $safe_text, $text );
3983
+	return apply_filters('esc_textarea', $safe_text, $text);
3984 3984
 }
3985 3985
 
3986 3986
 /**
@@ -3991,8 +3991,8 @@  discard block
 block discarded – undo
3991 3991
  * @param string $tag_name
3992 3992
  * @return string
3993 3993
  */
3994
-function tag_escape( $tag_name ) {
3995
-	$safe_tag = strtolower( preg_replace('/[^a-zA-Z0-9_:]/', '', $tag_name) );
3994
+function tag_escape($tag_name) {
3995
+	$safe_tag = strtolower(preg_replace('/[^a-zA-Z0-9_:]/', '', $tag_name));
3996 3996
 	/**
3997 3997
 	 * Filters a string cleaned and escaped for output as an HTML tag.
3998 3998
 	 *
@@ -4001,7 +4001,7 @@  discard block
 block discarded – undo
4001 4001
 	 * @param string $safe_tag The tag name after it has been escaped.
4002 4002
  	 * @param string $tag_name The text before it was escaped.
4003 4003
 	 */
4004
-	return apply_filters( 'tag_escape', $safe_tag, $tag_name );
4004
+	return apply_filters('tag_escape', $safe_tag, $tag_name);
4005 4005
 }
4006 4006
 
4007 4007
 /**
@@ -4016,8 +4016,8 @@  discard block
 block discarded – undo
4016 4016
  * @param string $link Full URL path.
4017 4017
  * @return string Absolute path.
4018 4018
  */
4019
-function wp_make_link_relative( $link ) {
4020
-	return preg_replace( '|^(https?:)?//[^/]+(/?.*)|i', '$2', $link );
4019
+function wp_make_link_relative($link) {
4020
+	return preg_replace('|^(https?:)?//[^/]+(/?.*)|i', '$2', $link);
4021 4021
 }
4022 4022
 
4023 4023
 /**
@@ -4034,22 +4034,22 @@  discard block
 block discarded – undo
4034 4034
  * @param string $value  The unsanitised value.
4035 4035
  * @return string Sanitized value.
4036 4036
  */
4037
-function sanitize_option( $option, $value ) {
4037
+function sanitize_option($option, $value) {
4038 4038
 	global $wpdb;
4039 4039
 
4040 4040
 	$original_value = $value;
4041 4041
 	$error = '';
4042 4042
 
4043
-	switch ( $option ) {
4043
+	switch ($option) {
4044 4044
 		case 'admin_email' :
4045 4045
 		case 'new_admin_email' :
4046
-			$value = $wpdb->strip_invalid_text_for_column( $wpdb->options, 'option_value', $value );
4047
-			if ( is_wp_error( $value ) ) {
4046
+			$value = $wpdb->strip_invalid_text_for_column($wpdb->options, 'option_value', $value);
4047
+			if (is_wp_error($value)) {
4048 4048
 				$error = $value->get_error_message();
4049 4049
 			} else {
4050
-				$value = sanitize_email( $value );
4051
-				if ( ! is_email( $value ) ) {
4052
-					$error = __( 'The email address entered did not appear to be a valid email address. Please enter a valid email address.' );
4050
+				$value = sanitize_email($value);
4051
+				if ( ! is_email($value)) {
4052
+					$error = __('The email address entered did not appear to be a valid email address. Please enter a valid email address.');
4053 4053
 				}
4054 4054
 			}
4055 4055
 			break;
@@ -4076,36 +4076,36 @@  discard block
 block discarded – undo
4076 4076
 		case 'users_can_register':
4077 4077
 		case 'start_of_week':
4078 4078
 		case 'site_icon':
4079
-			$value = absint( $value );
4079
+			$value = absint($value);
4080 4080
 			break;
4081 4081
 
4082 4082
 		case 'posts_per_page':
4083 4083
 		case 'posts_per_rss':
4084 4084
 			$value = (int) $value;
4085
-			if ( empty($value) )
4085
+			if (empty($value))
4086 4086
 				$value = 1;
4087
-			if ( $value < -1 )
4087
+			if ($value < -1)
4088 4088
 				$value = abs($value);
4089 4089
 			break;
4090 4090
 
4091 4091
 		case 'default_ping_status':
4092 4092
 		case 'default_comment_status':
4093 4093
 			// Options that if not there have 0 value but need to be something like "closed"
4094
-			if ( $value == '0' || $value == '')
4094
+			if ($value == '0' || $value == '')
4095 4095
 				$value = 'closed';
4096 4096
 			break;
4097 4097
 
4098 4098
 		case 'blogdescription':
4099 4099
 		case 'blogname':
4100
-			$value = $wpdb->strip_invalid_text_for_column( $wpdb->options, 'option_value', $value );
4101
-			if ( $value !== $original_value ) {
4102
-				$value = $wpdb->strip_invalid_text_for_column( $wpdb->options, 'option_value', wp_encode_emoji( $original_value ) );
4100
+			$value = $wpdb->strip_invalid_text_for_column($wpdb->options, 'option_value', $value);
4101
+			if ($value !== $original_value) {
4102
+				$value = $wpdb->strip_invalid_text_for_column($wpdb->options, 'option_value', wp_encode_emoji($original_value));
4103 4103
 			}
4104 4104
 
4105
-			if ( is_wp_error( $value ) ) {
4105
+			if (is_wp_error($value)) {
4106 4106
 				$error = $value->get_error_message();
4107 4107
 			} else {
4108
-				$value = esc_html( $value );
4108
+				$value = esc_html($value);
4109 4109
 			}
4110 4110
 			break;
4111 4111
 
@@ -4115,10 +4115,10 @@  discard block
 block discarded – undo
4115 4115
 
4116 4116
 		case 'blog_public':
4117 4117
 			// This is the value if the settings checkbox is not checked on POST. Don't rely on this.
4118
-			if ( null === $value )
4118
+			if (null === $value)
4119 4119
 				$value = 1;
4120 4120
 			else
4121
-				$value = intval( $value );
4121
+				$value = intval($value);
4122 4122
 			break;
4123 4123
 
4124 4124
 		case 'date_format':
@@ -4127,20 +4127,20 @@  discard block
 block discarded – undo
4127 4127
 		case 'mailserver_login':
4128 4128
 		case 'mailserver_pass':
4129 4129
 		case 'upload_path':
4130
-			$value = $wpdb->strip_invalid_text_for_column( $wpdb->options, 'option_value', $value );
4131
-			if ( is_wp_error( $value ) ) {
4130
+			$value = $wpdb->strip_invalid_text_for_column($wpdb->options, 'option_value', $value);
4131
+			if (is_wp_error($value)) {
4132 4132
 				$error = $value->get_error_message();
4133 4133
 			} else {
4134
-				$value = strip_tags( $value );
4135
-				$value = wp_kses_data( $value );
4134
+				$value = strip_tags($value);
4135
+				$value = wp_kses_data($value);
4136 4136
 			}
4137 4137
 			break;
4138 4138
 
4139 4139
 		case 'ping_sites':
4140
-			$value = explode( "\n", $value );
4141
-			$value = array_filter( array_map( 'trim', $value ) );
4142
-			$value = array_filter( array_map( 'esc_url_raw', $value ) );
4143
-			$value = implode( "\n", $value );
4140
+			$value = explode("\n", $value);
4141
+			$value = array_filter(array_map('trim', $value));
4142
+			$value = array_filter(array_map('esc_url_raw', $value));
4143
+			$value = implode("\n", $value);
4144 4144
 			break;
4145 4145
 
4146 4146
 		case 'gmt_offset':
@@ -4148,128 +4148,128 @@  discard block
 block discarded – undo
4148 4148
 			break;
4149 4149
 
4150 4150
 		case 'siteurl':
4151
-			$value = $wpdb->strip_invalid_text_for_column( $wpdb->options, 'option_value', $value );
4152
-			if ( is_wp_error( $value ) ) {
4151
+			$value = $wpdb->strip_invalid_text_for_column($wpdb->options, 'option_value', $value);
4152
+			if (is_wp_error($value)) {
4153 4153
 				$error = $value->get_error_message();
4154 4154
 			} else {
4155
-				if ( preg_match( '#http(s?)://(.+)#i', $value ) ) {
4156
-					$value = esc_url_raw( $value );
4155
+				if (preg_match('#http(s?)://(.+)#i', $value)) {
4156
+					$value = esc_url_raw($value);
4157 4157
 				} else {
4158
-					$error = __( 'The WordPress address you entered did not appear to be a valid URL. Please enter a valid URL.' );
4158
+					$error = __('The WordPress address you entered did not appear to be a valid URL. Please enter a valid URL.');
4159 4159
 				}
4160 4160
 			}
4161 4161
 			break;
4162 4162
 
4163 4163
 		case 'home':
4164
-			$value = $wpdb->strip_invalid_text_for_column( $wpdb->options, 'option_value', $value );
4165
-			if ( is_wp_error( $value ) ) {
4164
+			$value = $wpdb->strip_invalid_text_for_column($wpdb->options, 'option_value', $value);
4165
+			if (is_wp_error($value)) {
4166 4166
 				$error = $value->get_error_message();
4167 4167
 			} else {
4168
-				if ( preg_match( '#http(s?)://(.+)#i', $value ) ) {
4169
-					$value = esc_url_raw( $value );
4168
+				if (preg_match('#http(s?)://(.+)#i', $value)) {
4169
+					$value = esc_url_raw($value);
4170 4170
 				} else {
4171
-					$error = __( 'The Site address you entered did not appear to be a valid URL. Please enter a valid URL.' );
4171
+					$error = __('The Site address you entered did not appear to be a valid URL. Please enter a valid URL.');
4172 4172
 				}
4173 4173
 			}
4174 4174
 			break;
4175 4175
 
4176 4176
 		case 'WPLANG':
4177 4177
 			$allowed = get_available_languages();
4178
-			if ( ! is_multisite() && defined( 'WPLANG' ) && '' !== WPLANG && 'en_US' !== WPLANG ) {
4178
+			if ( ! is_multisite() && defined('WPLANG') && '' !== WPLANG && 'en_US' !== WPLANG) {
4179 4179
 				$allowed[] = WPLANG;
4180 4180
 			}
4181
-			if ( ! in_array( $value, $allowed ) && ! empty( $value ) ) {
4182
-				$value = get_option( $option );
4181
+			if ( ! in_array($value, $allowed) && ! empty($value)) {
4182
+				$value = get_option($option);
4183 4183
 			}
4184 4184
 			break;
4185 4185
 
4186 4186
 		case 'illegal_names':
4187
-			$value = $wpdb->strip_invalid_text_for_column( $wpdb->options, 'option_value', $value );
4188
-			if ( is_wp_error( $value ) ) {
4187
+			$value = $wpdb->strip_invalid_text_for_column($wpdb->options, 'option_value', $value);
4188
+			if (is_wp_error($value)) {
4189 4189
 				$error = $value->get_error_message();
4190 4190
 			} else {
4191
-				if ( ! is_array( $value ) )
4192
-					$value = explode( ' ', $value );
4191
+				if ( ! is_array($value))
4192
+					$value = explode(' ', $value);
4193 4193
 
4194
-				$value = array_values( array_filter( array_map( 'trim', $value ) ) );
4194
+				$value = array_values(array_filter(array_map('trim', $value)));
4195 4195
 
4196
-				if ( ! $value )
4196
+				if ( ! $value)
4197 4197
 					$value = '';
4198 4198
 			}
4199 4199
 			break;
4200 4200
 
4201 4201
 		case 'limited_email_domains':
4202 4202
 		case 'banned_email_domains':
4203
-			$value = $wpdb->strip_invalid_text_for_column( $wpdb->options, 'option_value', $value );
4204
-			if ( is_wp_error( $value ) ) {
4203
+			$value = $wpdb->strip_invalid_text_for_column($wpdb->options, 'option_value', $value);
4204
+			if (is_wp_error($value)) {
4205 4205
 				$error = $value->get_error_message();
4206 4206
 			} else {
4207
-				if ( ! is_array( $value ) )
4208
-					$value = explode( "\n", $value );
4207
+				if ( ! is_array($value))
4208
+					$value = explode("\n", $value);
4209 4209
 
4210
-				$domains = array_values( array_filter( array_map( 'trim', $value ) ) );
4210
+				$domains = array_values(array_filter(array_map('trim', $value)));
4211 4211
 				$value = array();
4212 4212
 
4213
-				foreach ( $domains as $domain ) {
4214
-					if ( ! preg_match( '/(--|\.\.)/', $domain ) && preg_match( '|^([a-zA-Z0-9-\.])+$|', $domain ) ) {
4213
+				foreach ($domains as $domain) {
4214
+					if ( ! preg_match('/(--|\.\.)/', $domain) && preg_match('|^([a-zA-Z0-9-\.])+$|', $domain)) {
4215 4215
 						$value[] = $domain;
4216 4216
 					}
4217 4217
 				}
4218
-				if ( ! $value )
4218
+				if ( ! $value)
4219 4219
 					$value = '';
4220 4220
 			}
4221 4221
 			break;
4222 4222
 
4223 4223
 		case 'timezone_string':
4224 4224
 			$allowed_zones = timezone_identifiers_list();
4225
-			if ( ! in_array( $value, $allowed_zones ) && ! empty( $value ) ) {
4226
-				$error = __( 'The timezone you have entered is not valid. Please select a valid timezone.' );
4225
+			if ( ! in_array($value, $allowed_zones) && ! empty($value)) {
4226
+				$error = __('The timezone you have entered is not valid. Please select a valid timezone.');
4227 4227
 			}
4228 4228
 			break;
4229 4229
 
4230 4230
 		case 'permalink_structure':
4231 4231
 		case 'category_base':
4232 4232
 		case 'tag_base':
4233
-			$value = $wpdb->strip_invalid_text_for_column( $wpdb->options, 'option_value', $value );
4234
-			if ( is_wp_error( $value ) ) {
4233
+			$value = $wpdb->strip_invalid_text_for_column($wpdb->options, 'option_value', $value);
4234
+			if (is_wp_error($value)) {
4235 4235
 				$error = $value->get_error_message();
4236 4236
 			} else {
4237
-				$value = esc_url_raw( $value );
4238
-				$value = str_replace( 'http://', '', $value );
4237
+				$value = esc_url_raw($value);
4238
+				$value = str_replace('http://', '', $value);
4239 4239
 			}
4240 4240
 
4241
-			if ( 'permalink_structure' === $option && '' !== $value && ! preg_match( '/%[^\/%]+%/', $value ) ) {
4241
+			if ('permalink_structure' === $option && '' !== $value && ! preg_match('/%[^\/%]+%/', $value)) {
4242 4242
 				$error = sprintf(
4243 4243
 					/* translators: %s: Codex URL */
4244
-					__( 'A structure tag is required when using custom permalinks. <a href="%s">Learn more</a>' ),
4245
-					__( 'https://codex.wordpress.org/Using_Permalinks#Choosing_your_permalink_structure' )
4244
+					__('A structure tag is required when using custom permalinks. <a href="%s">Learn more</a>'),
4245
+					__('https://codex.wordpress.org/Using_Permalinks#Choosing_your_permalink_structure')
4246 4246
 				);
4247 4247
 			}
4248 4248
 			break;
4249 4249
 
4250 4250
 		case 'default_role' :
4251
-			if ( ! get_role( $value ) && get_role( 'subscriber' ) )
4251
+			if ( ! get_role($value) && get_role('subscriber'))
4252 4252
 				$value = 'subscriber';
4253 4253
 			break;
4254 4254
 
4255 4255
 		case 'moderation_keys':
4256 4256
 		case 'blacklist_keys':
4257
-			$value = $wpdb->strip_invalid_text_for_column( $wpdb->options, 'option_value', $value );
4258
-			if ( is_wp_error( $value ) ) {
4257
+			$value = $wpdb->strip_invalid_text_for_column($wpdb->options, 'option_value', $value);
4258
+			if (is_wp_error($value)) {
4259 4259
 				$error = $value->get_error_message();
4260 4260
 			} else {
4261
-				$value = explode( "\n", $value );
4262
-				$value = array_filter( array_map( 'trim', $value ) );
4263
-				$value = array_unique( $value );
4264
-				$value = implode( "\n", $value );
4261
+				$value = explode("\n", $value);
4262
+				$value = array_filter(array_map('trim', $value));
4263
+				$value = array_unique($value);
4264
+				$value = implode("\n", $value);
4265 4265
 			}
4266 4266
 			break;
4267 4267
 	}
4268 4268
 
4269
-	if ( ! empty( $error ) ) {
4270
-		$value = get_option( $option );
4271
-		if ( function_exists( 'add_settings_error' ) ) {
4272
-			add_settings_error( $option, "invalid_{$option}", $error );
4269
+	if ( ! empty($error)) {
4270
+		$value = get_option($option);
4271
+		if (function_exists('add_settings_error')) {
4272
+			add_settings_error($option, "invalid_{$option}", $error);
4273 4273
 		}
4274 4274
 	}
4275 4275
 
@@ -4283,7 +4283,7 @@  discard block
 block discarded – undo
4283 4283
 	 * @param string $option         The option name.
4284 4284
 	 * @param string $original_value The original value passed to the function.
4285 4285
 	 */
4286
-	return apply_filters( "sanitize_option_{$option}", $value, $option, $original_value );
4286
+	return apply_filters("sanitize_option_{$option}", $value, $option, $original_value);
4287 4287
 }
4288 4288
 
4289 4289
 /**
@@ -4297,18 +4297,18 @@  discard block
 block discarded – undo
4297 4297
  * @param callable $callback The function to map onto $value.
4298 4298
  * @return mixed The value with the callback applied to all non-arrays and non-objects inside it.
4299 4299
  */
4300
-function map_deep( $value, $callback ) {
4301
-	if ( is_array( $value ) ) {
4302
-		foreach ( $value as $index => $item ) {
4303
-			$value[ $index ] = map_deep( $item, $callback );
4300
+function map_deep($value, $callback) {
4301
+	if (is_array($value)) {
4302
+		foreach ($value as $index => $item) {
4303
+			$value[$index] = map_deep($item, $callback);
4304 4304
 		}
4305
-	} elseif ( is_object( $value ) ) {
4306
-		$object_vars = get_object_vars( $value );
4307
-		foreach ( $object_vars as $property_name => $property_value ) {
4308
-			$value->$property_name = map_deep( $property_value, $callback );
4305
+	} elseif (is_object($value)) {
4306
+		$object_vars = get_object_vars($value);
4307
+		foreach ($object_vars as $property_name => $property_value) {
4308
+			$value->$property_name = map_deep($property_value, $callback);
4309 4309
 		}
4310 4310
 	} else {
4311
-		$value = call_user_func( $callback, $value );
4311
+		$value = call_user_func($callback, $value);
4312 4312
 	}
4313 4313
 
4314 4314
 	return $value;
@@ -4325,10 +4325,10 @@  discard block
 block discarded – undo
4325 4325
  * @param string $string The string to be parsed.
4326 4326
  * @param array  $array  Variables will be stored in this array.
4327 4327
  */
4328
-function wp_parse_str( $string, &$array ) {
4329
-	parse_str( $string, $array );
4330
-	if ( get_magic_quotes_gpc() )
4331
-		$array = stripslashes_deep( $array );
4328
+function wp_parse_str($string, &$array) {
4329
+	parse_str($string, $array);
4330
+	if (get_magic_quotes_gpc())
4331
+		$array = stripslashes_deep($array);
4332 4332
 	/**
4333 4333
 	 * Filters the array of variables derived from a parsed string.
4334 4334
 	 *
@@ -4336,7 +4336,7 @@  discard block
 block discarded – undo
4336 4336
 	 *
4337 4337
 	 * @param array $array The array populated with variables.
4338 4338
 	 */
4339
-	$array = apply_filters( 'wp_parse_str', $array );
4339
+	$array = apply_filters('wp_parse_str', $array);
4340 4340
 }
4341 4341
 
4342 4342
 /**
@@ -4349,7 +4349,7 @@  discard block
 block discarded – undo
4349 4349
  * @param string $text Text to be converted.
4350 4350
  * @return string Converted text.
4351 4351
  */
4352
-function wp_pre_kses_less_than( $text ) {
4352
+function wp_pre_kses_less_than($text) {
4353 4353
 	return preg_replace_callback('%<[^>]*?((?=<)|>|$)%', 'wp_pre_kses_less_than_callback', $text);
4354 4354
 }
4355 4355
 
@@ -4361,8 +4361,8 @@  discard block
 block discarded – undo
4361 4361
  * @param array $matches Populated by matches to preg_replace.
4362 4362
  * @return string The text returned after esc_html if needed.
4363 4363
  */
4364
-function wp_pre_kses_less_than_callback( $matches ) {
4365
-	if ( false === strpos($matches[0], '>') )
4364
+function wp_pre_kses_less_than_callback($matches) {
4365
+	if (false === strpos($matches[0], '>'))
4366 4366
 		return esc_html($matches[0]);
4367 4367
 	return $matches[0];
4368 4368
 }
@@ -4377,21 +4377,21 @@  discard block
 block discarded – undo
4377 4377
  * @param mixed  $args ,... Arguments to be formatted into the $pattern string.
4378 4378
  * @return string The formatted string.
4379 4379
  */
4380
-function wp_sprintf( $pattern ) {
4380
+function wp_sprintf($pattern) {
4381 4381
 	$args = func_get_args();
4382 4382
 	$len = strlen($pattern);
4383 4383
 	$start = 0;
4384 4384
 	$result = '';
4385 4385
 	$arg_index = 0;
4386
-	while ( $len > $start ) {
4386
+	while ($len > $start) {
4387 4387
 		// Last character: append and break
4388
-		if ( strlen($pattern) - 1 == $start ) {
4388
+		if (strlen($pattern) - 1 == $start) {
4389 4389
 			$result .= substr($pattern, -1);
4390 4390
 			break;
4391 4391
 		}
4392 4392
 
4393 4393
 		// Literal %: append and continue
4394
-		if ( substr($pattern, $start, 2) == '%%' ) {
4394
+		if (substr($pattern, $start, 2) == '%%') {
4395 4395
 			$start += 2;
4396 4396
 			$result .= '%';
4397 4397
 			continue;
@@ -4399,14 +4399,14 @@  discard block
 block discarded – undo
4399 4399
 
4400 4400
 		// Get fragment before next %
4401 4401
 		$end = strpos($pattern, '%', $start + 1);
4402
-		if ( false === $end )
4402
+		if (false === $end)
4403 4403
 			$end = $len;
4404 4404
 		$fragment = substr($pattern, $start, $end - $start);
4405 4405
 
4406 4406
 		// Fragment has a specifier
4407
-		if ( $pattern[$start] == '%' ) {
4407
+		if ($pattern[$start] == '%') {
4408 4408
 			// Find numbered arguments or take the next one in order
4409
-			if ( preg_match('/^%(\d+)\$/', $fragment, $matches) ) {
4409
+			if (preg_match('/^%(\d+)\$/', $fragment, $matches)) {
4410 4410
 				$arg = isset($args[$matches[1]]) ? $args[$matches[1]] : '';
4411 4411
 				$fragment = str_replace("%{$matches[1]}$", '%', $fragment);
4412 4412
 			} else {
@@ -4424,11 +4424,11 @@  discard block
 block discarded – undo
4424 4424
 			 * @param string $fragment A fragment from the pattern.
4425 4425
 			 * @param string $arg      The argument.
4426 4426
 			 */
4427
-			$_fragment = apply_filters( 'wp_sprintf', $fragment, $arg );
4428
-			if ( $_fragment != $fragment )
4427
+			$_fragment = apply_filters('wp_sprintf', $fragment, $arg);
4428
+			if ($_fragment != $fragment)
4429 4429
 				$fragment = $_fragment;
4430 4430
 			else
4431
-				$fragment = sprintf($fragment, strval($arg) );
4431
+				$fragment = sprintf($fragment, strval($arg));
4432 4432
 		}
4433 4433
 
4434 4434
 		// Append to result and move to next fragment
@@ -4451,13 +4451,13 @@  discard block
 block discarded – undo
4451 4451
  * @param array  $args    List items to prepend to the content and replace '%l'.
4452 4452
  * @return string Localized list items and rest of the content.
4453 4453
  */
4454
-function wp_sprintf_l( $pattern, $args ) {
4454
+function wp_sprintf_l($pattern, $args) {
4455 4455
 	// Not a match
4456
-	if ( substr($pattern, 0, 2) != '%l' )
4456
+	if (substr($pattern, 0, 2) != '%l')
4457 4457
 		return $pattern;
4458 4458
 
4459 4459
 	// Nothing to work with
4460
-	if ( empty($args) )
4460
+	if (empty($args))
4461 4461
 		return '';
4462 4462
 
4463 4463
 	/**
@@ -4471,30 +4471,30 @@  discard block
 block discarded – undo
4471 4471
 	 *
4472 4472
 	 * @param array $delimiters An array of translated delimiters.
4473 4473
 	 */
4474
-	$l = apply_filters( 'wp_sprintf_l', array(
4474
+	$l = apply_filters('wp_sprintf_l', array(
4475 4475
 		/* translators: used to join items in a list with more than 2 items */
4476
-		'between'          => sprintf( __('%s, %s'), '', '' ),
4476
+		'between'          => sprintf(__('%s, %s'), '', ''),
4477 4477
 		/* translators: used to join last two items in a list with more than 2 times */
4478
-		'between_last_two' => sprintf( __('%s, and %s'), '', '' ),
4478
+		'between_last_two' => sprintf(__('%s, and %s'), '', ''),
4479 4479
 		/* translators: used to join items in a list with only 2 items */
4480
-		'between_only_two' => sprintf( __('%s and %s'), '', '' ),
4481
-	) );
4480
+		'between_only_two' => sprintf(__('%s and %s'), '', ''),
4481
+	));
4482 4482
 
4483 4483
 	$args = (array) $args;
4484 4484
 	$result = array_shift($args);
4485
-	if ( count($args) == 1 )
4486
-		$result .= $l['between_only_two'] . array_shift($args);
4485
+	if (count($args) == 1)
4486
+		$result .= $l['between_only_two'].array_shift($args);
4487 4487
 	// Loop when more than two args
4488 4488
 	$i = count($args);
4489
-	while ( $i ) {
4489
+	while ($i) {
4490 4490
 		$arg = array_shift($args);
4491 4491
 		$i--;
4492
-		if ( 0 == $i )
4493
-			$result .= $l['between_last_two'] . $arg;
4492
+		if (0 == $i)
4493
+			$result .= $l['between_last_two'].$arg;
4494 4494
 		else
4495
-			$result .= $l['between'] . $arg;
4495
+			$result .= $l['between'].$arg;
4496 4496
 	}
4497
-	return $result . substr($pattern, 2);
4497
+	return $result.substr($pattern, 2);
4498 4498
 }
4499 4499
 
4500 4500
 /**
@@ -4511,15 +4511,15 @@  discard block
 block discarded – undo
4511 4511
  * @param string $more  Optional. What to append if $str needs to be trimmed. Defaults to empty string.
4512 4512
  * @return string The excerpt.
4513 4513
  */
4514
-function wp_html_excerpt( $str, $count, $more = null ) {
4515
-	if ( null === $more )
4514
+function wp_html_excerpt($str, $count, $more = null) {
4515
+	if (null === $more)
4516 4516
 		$more = '';
4517
-	$str = wp_strip_all_tags( $str, true );
4518
-	$excerpt = mb_substr( $str, 0, $count );
4517
+	$str = wp_strip_all_tags($str, true);
4518
+	$excerpt = mb_substr($str, 0, $count);
4519 4519
 	// remove part of an entity at the end
4520
-	$excerpt = preg_replace( '/&[^;\s]{0,6}$/', '', $excerpt );
4521
-	if ( $str != $excerpt )
4522
-		$excerpt = trim( $excerpt ) . $more;
4520
+	$excerpt = preg_replace('/&[^;\s]{0,6}$/', '', $excerpt);
4521
+	if ($str != $excerpt)
4522
+		$excerpt = trim($excerpt).$more;
4523 4523
 	return $excerpt;
4524 4524
 }
4525 4525
 
@@ -4538,11 +4538,11 @@  discard block
 block discarded – undo
4538 4538
  * @param array  $attrs   The attributes which should be processed.
4539 4539
  * @return string The processed content.
4540 4540
  */
4541
-function links_add_base_url( $content, $base, $attrs = array('src', 'href') ) {
4541
+function links_add_base_url($content, $base, $attrs = array('src', 'href')) {
4542 4542
 	global $_links_add_base;
4543 4543
 	$_links_add_base = $base;
4544
-	$attrs = implode('|', (array)$attrs);
4545
-	return preg_replace_callback( "!($attrs)=(['\"])(.+?)\\2!i", '_links_add_base', $content );
4544
+	$attrs = implode('|', (array) $attrs);
4545
+	return preg_replace_callback("!($attrs)=(['\"])(.+?)\\2!i", '_links_add_base', $content);
4546 4546
 }
4547 4547
 
4548 4548
 /**
@@ -4556,13 +4556,12 @@  discard block
 block discarded – undo
4556 4556
  * @param string $m The matched link.
4557 4557
  * @return string The processed link.
4558 4558
  */
4559
-function _links_add_base( $m ) {
4559
+function _links_add_base($m) {
4560 4560
 	global $_links_add_base;
4561 4561
 	//1 = attribute name  2 = quotation mark  3 = URL
4562
-	return $m[1] . '=' . $m[2] .
4563
-		( preg_match( '#^(\w{1,20}):#', $m[3], $protocol ) && in_array( $protocol[1], wp_allowed_protocols() ) ?
4564
-			$m[3] :
4565
-			WP_Http::make_absolute_url( $m[3], $_links_add_base )
4562
+	return $m[1].'='.$m[2].
4563
+		(preg_match('#^(\w{1,20}):#', $m[3], $protocol) && in_array($protocol[1], wp_allowed_protocols()) ?
4564
+			$m[3] : WP_Http::make_absolute_url($m[3], $_links_add_base)
4566 4565
 		)
4567 4566
 		. $m[2];
4568 4567
 }
@@ -4584,11 +4583,11 @@  discard block
 block discarded – undo
4584 4583
  * @param array  $tags    An array of tags to apply to.
4585 4584
  * @return string The processed content.
4586 4585
  */
4587
-function links_add_target( $content, $target = '_blank', $tags = array('a') ) {
4586
+function links_add_target($content, $target = '_blank', $tags = array('a')) {
4588 4587
 	global $_links_add_target;
4589 4588
 	$_links_add_target = $target;
4590
-	$tags = implode('|', (array)$tags);
4591
-	return preg_replace_callback( "!<($tags)([^>]*)>!i", '_links_add_target', $content );
4589
+	$tags = implode('|', (array) $tags);
4590
+	return preg_replace_callback("!<($tags)([^>]*)>!i", '_links_add_target', $content);
4592 4591
 }
4593 4592
 
4594 4593
 /**
@@ -4602,11 +4601,11 @@  discard block
 block discarded – undo
4602 4601
  * @param string $m The matched link.
4603 4602
  * @return string The processed link.
4604 4603
  */
4605
-function _links_add_target( $m ) {
4604
+function _links_add_target($m) {
4606 4605
 	global $_links_add_target;
4607 4606
 	$tag = $m[1];
4608 4607
 	$link = preg_replace('|( target=([\'"])(.*?)\2)|i', '', $m[2]);
4609
-	return '<' . $tag . $link . ' target="' . esc_attr( $_links_add_target ) . '">';
4608
+	return '<'.$tag.$link.' target="'.esc_attr($_links_add_target).'">';
4610 4609
 }
4611 4610
 
4612 4611
 /**
@@ -4617,10 +4616,10 @@  discard block
 block discarded – undo
4617 4616
  * @param string $str The string to normalize.
4618 4617
  * @return string The normalized string.
4619 4618
  */
4620
-function normalize_whitespace( $str ) {
4621
-	$str  = trim( $str );
4622
-	$str  = str_replace( "\r", "\n", $str );
4623
-	$str  = preg_replace( array( '/\n+/', '/[ \t]+/' ), array( "\n", ' ' ), $str );
4619
+function normalize_whitespace($str) {
4620
+	$str  = trim($str);
4621
+	$str  = str_replace("\r", "\n", $str);
4622
+	$str  = preg_replace(array('/\n+/', '/[ \t]+/'), array("\n", ' '), $str);
4624 4623
 	return $str;
4625 4624
 }
4626 4625
 
@@ -4638,13 +4637,13 @@  discard block
 block discarded – undo
4638 4637
  * @return string The processed string.
4639 4638
  */
4640 4639
 function wp_strip_all_tags($string, $remove_breaks = false) {
4641
-	$string = preg_replace( '@<(script|style)[^>]*?>.*?</\\1>@si', '', $string );
4640
+	$string = preg_replace('@<(script|style)[^>]*?>.*?</\\1>@si', '', $string);
4642 4641
 	$string = strip_tags($string);
4643 4642
 
4644
-	if ( $remove_breaks )
4643
+	if ($remove_breaks)
4645 4644
 		$string = preg_replace('/[\r\n\t ]+/', ' ', $string);
4646 4645
 
4647
-	return trim( $string );
4646
+	return trim($string);
4648 4647
 }
4649 4648
 
4650 4649
 /**
@@ -4665,8 +4664,8 @@  discard block
 block discarded – undo
4665 4664
  * @param string $str String to sanitize.
4666 4665
  * @return string Sanitized string.
4667 4666
  */
4668
-function sanitize_text_field( $str ) {
4669
-	$filtered = _sanitize_text_fields( $str, false );
4667
+function sanitize_text_field($str) {
4668
+	$filtered = _sanitize_text_fields($str, false);
4670 4669
 
4671 4670
 	/**
4672 4671
 	 * Filters a sanitized text field string.
@@ -4676,7 +4675,7 @@  discard block
 block discarded – undo
4676 4675
 	 * @param string $filtered The sanitized string.
4677 4676
 	 * @param string $str      The string prior to being sanitized.
4678 4677
 	 */
4679
-	return apply_filters( 'sanitize_text_field', $filtered, $str );
4678
+	return apply_filters('sanitize_text_field', $filtered, $str);
4680 4679
 }
4681 4680
 
4682 4681
 /**
@@ -4693,8 +4692,8 @@  discard block
 block discarded – undo
4693 4692
  * @param string $str String to sanitize.
4694 4693
  * @return string Sanitized string.
4695 4694
  */
4696
-function sanitize_textarea_field( $str ) {
4697
-	$filtered = _sanitize_text_fields( $str, true );
4695
+function sanitize_textarea_field($str) {
4696
+	$filtered = _sanitize_text_fields($str, true);
4698 4697
 
4699 4698
 	/**
4700 4699
 	 * Filters a sanitized textarea field string.
@@ -4704,7 +4703,7 @@  discard block
 block discarded – undo
4704 4703
 	 * @param string $filtered The sanitized string.
4705 4704
 	 * @param string $str      The string prior to being sanitized.
4706 4705
 	 */
4707
-	return apply_filters( 'sanitize_textarea_field', $filtered, $str );
4706
+	return apply_filters('sanitize_textarea_field', $filtered, $str);
4708 4707
 }
4709 4708
 
4710 4709
 /**
@@ -4717,33 +4716,33 @@  discard block
 block discarded – undo
4717 4716
  * @param bool $keep_newlines optional Whether to keep newlines. Default: false.
4718 4717
  * @return string Sanitized string.
4719 4718
  */
4720
-function _sanitize_text_fields( $str, $keep_newlines = false ) {
4721
-	$filtered = wp_check_invalid_utf8( $str );
4719
+function _sanitize_text_fields($str, $keep_newlines = false) {
4720
+	$filtered = wp_check_invalid_utf8($str);
4722 4721
 
4723
-	if ( strpos($filtered, '<') !== false ) {
4724
-		$filtered = wp_pre_kses_less_than( $filtered );
4722
+	if (strpos($filtered, '<') !== false) {
4723
+		$filtered = wp_pre_kses_less_than($filtered);
4725 4724
 		// This will strip extra whitespace for us.
4726
-		$filtered = wp_strip_all_tags( $filtered, false );
4725
+		$filtered = wp_strip_all_tags($filtered, false);
4727 4726
 
4728 4727
 		// Use html entities in a special case to make sure no later
4729 4728
 		// newline stripping stage could lead to a functional tag
4730 4729
 		$filtered = str_replace("<\n", "&lt;\n", $filtered);
4731 4730
 	}
4732 4731
 
4733
-	if ( ! $keep_newlines ) {
4734
-		$filtered = preg_replace( '/[\r\n\t ]+/', ' ', $filtered );
4732
+	if ( ! $keep_newlines) {
4733
+		$filtered = preg_replace('/[\r\n\t ]+/', ' ', $filtered);
4735 4734
 	}
4736
-	$filtered = trim( $filtered );
4735
+	$filtered = trim($filtered);
4737 4736
 
4738 4737
 	$found = false;
4739
-	while ( preg_match('/%[a-f0-9]{2}/i', $filtered, $match) ) {
4738
+	while (preg_match('/%[a-f0-9]{2}/i', $filtered, $match)) {
4740 4739
 		$filtered = str_replace($match[0], '', $filtered);
4741 4740
 		$found = true;
4742 4741
 	}
4743 4742
 
4744
-	if ( $found ) {
4743
+	if ($found) {
4745 4744
 		// Strip out the whitespace that may now exist after removing the octets.
4746
-		$filtered = trim( preg_replace('/ +/', ' ', $filtered) );
4745
+		$filtered = trim(preg_replace('/ +/', ' ', $filtered));
4747 4746
 	}
4748 4747
 
4749 4748
 	return $filtered;
@@ -4758,8 +4757,8 @@  discard block
 block discarded – undo
4758 4757
  * @param string $suffix If the filename ends in suffix this will also be cut off.
4759 4758
  * @return string
4760 4759
  */
4761
-function wp_basename( $path, $suffix = '' ) {
4762
-	return urldecode( basename( str_replace( array( '%2F', '%5C' ), '/', urlencode( $path ) ), $suffix ) );
4760
+function wp_basename($path, $suffix = '') {
4761
+	return urldecode(basename(str_replace(array('%2F', '%5C'), '/', urlencode($path)), $suffix));
4763 4762
 }
4764 4763
 
4765 4764
 /**
@@ -4774,19 +4773,19 @@  discard block
 block discarded – undo
4774 4773
  * @param string $text The text to be modified.
4775 4774
  * @return string The modified text.
4776 4775
  */
4777
-function capital_P_dangit( $text ) {
4776
+function capital_P_dangit($text) {
4778 4777
 	// Simple replacement for titles
4779 4778
 	$current_filter = current_filter();
4780
-	if ( 'the_title' === $current_filter || 'wp_title' === $current_filter )
4781
-		return str_replace( 'Wordpress', 'WordPress', $text );
4779
+	if ('the_title' === $current_filter || 'wp_title' === $current_filter)
4780
+		return str_replace('Wordpress', 'WordPress', $text);
4782 4781
 	// Still here? Use the more judicious replacement
4783 4782
 	static $dblq = false;
4784
-	if ( false === $dblq ) {
4785
-		$dblq = _x( '&#8220;', 'opening curly double quote' );
4783
+	if (false === $dblq) {
4784
+		$dblq = _x('&#8220;', 'opening curly double quote');
4786 4785
 	}
4787 4786
 	return str_replace(
4788
-		array( ' Wordpress', '&#8216;Wordpress', $dblq . 'Wordpress', '>Wordpress', '(Wordpress' ),
4789
-		array( ' WordPress', '&#8216;WordPress', $dblq . 'WordPress', '>WordPress', '(WordPress' ),
4787
+		array(' Wordpress', '&#8216;Wordpress', $dblq.'Wordpress', '>Wordpress', '(Wordpress'),
4788
+		array(' WordPress', '&#8216;WordPress', $dblq.'WordPress', '>WordPress', '(WordPress'),
4790 4789
 	$text );
4791 4790
 }
4792 4791
 
@@ -4798,8 +4797,8 @@  discard block
 block discarded – undo
4798 4797
  * @param string $mime_type Mime type
4799 4798
  * @return string Sanitized mime type
4800 4799
  */
4801
-function sanitize_mime_type( $mime_type ) {
4802
-	$sani_mime_type = preg_replace( '/[^-+*.a-zA-Z0-9\/]/', '', $mime_type );
4800
+function sanitize_mime_type($mime_type) {
4801
+	$sani_mime_type = preg_replace('/[^-+*.a-zA-Z0-9\/]/', '', $mime_type);
4803 4802
 	/**
4804 4803
 	 * Filters a mime type following sanitization.
4805 4804
 	 *
@@ -4808,7 +4807,7 @@  discard block
 block discarded – undo
4808 4807
 	 * @param string $sani_mime_type The sanitized mime type.
4809 4808
 	 * @param string $mime_type      The mime type prior to sanitization.
4810 4809
 	 */
4811
-	return apply_filters( 'sanitize_mime_type', $sani_mime_type, $mime_type );
4810
+	return apply_filters('sanitize_mime_type', $sani_mime_type, $mime_type);
4812 4811
 }
4813 4812
 
4814 4813
 /**
@@ -4819,14 +4818,14 @@  discard block
 block discarded – undo
4819 4818
  * @param string $to_ping Space or carriage return separated URLs
4820 4819
  * @return string URLs starting with the http or https protocol, separated by a carriage return.
4821 4820
  */
4822
-function sanitize_trackback_urls( $to_ping ) {
4823
-	$urls_to_ping = preg_split( '/[\r\n\t ]/', trim( $to_ping ), -1, PREG_SPLIT_NO_EMPTY );
4824
-	foreach ( $urls_to_ping as $k => $url ) {
4825
-		if ( !preg_match( '#^https?://.#i', $url ) )
4826
-			unset( $urls_to_ping[$k] );
4821
+function sanitize_trackback_urls($to_ping) {
4822
+	$urls_to_ping = preg_split('/[\r\n\t ]/', trim($to_ping), -1, PREG_SPLIT_NO_EMPTY);
4823
+	foreach ($urls_to_ping as $k => $url) {
4824
+		if ( ! preg_match('#^https?://.#i', $url))
4825
+			unset($urls_to_ping[$k]);
4827 4826
 	}
4828
-	$urls_to_ping = array_map( 'esc_url_raw', $urls_to_ping );
4829
-	$urls_to_ping = implode( "\n", $urls_to_ping );
4827
+	$urls_to_ping = array_map('esc_url_raw', $urls_to_ping);
4828
+	$urls_to_ping = implode("\n", $urls_to_ping);
4830 4829
 	/**
4831 4830
 	 * Filters a list of trackback URLs following sanitization.
4832 4831
 	 *
@@ -4838,7 +4837,7 @@  discard block
 block discarded – undo
4838 4837
 	 * @param string $urls_to_ping Sanitized space or carriage return separated URLs.
4839 4838
 	 * @param string $to_ping      Space or carriage return separated URLs before sanitization.
4840 4839
 	 */
4841
-	return apply_filters( 'sanitize_trackback_urls', $urls_to_ping, $to_ping );
4840
+	return apply_filters('sanitize_trackback_urls', $urls_to_ping, $to_ping);
4842 4841
 }
4843 4842
 
4844 4843
 /**
@@ -4852,17 +4851,17 @@  discard block
 block discarded – undo
4852 4851
  * @param string|array $value String or array of strings to slash.
4853 4852
  * @return string|array Slashed $value
4854 4853
  */
4855
-function wp_slash( $value ) {
4856
-	if ( is_array( $value ) ) {
4857
-		foreach ( $value as $k => $v ) {
4858
-			if ( is_array( $v ) ) {
4859
-				$value[$k] = wp_slash( $v );
4854
+function wp_slash($value) {
4855
+	if (is_array($value)) {
4856
+		foreach ($value as $k => $v) {
4857
+			if (is_array($v)) {
4858
+				$value[$k] = wp_slash($v);
4860 4859
 			} else {
4861
-				$value[$k] = addslashes( $v );
4860
+				$value[$k] = addslashes($v);
4862 4861
 			}
4863 4862
 		}
4864 4863
 	} else {
4865
-		$value = addslashes( $value );
4864
+		$value = addslashes($value);
4866 4865
 	}
4867 4866
 
4868 4867
 	return $value;
@@ -4879,8 +4878,8 @@  discard block
 block discarded – undo
4879 4878
  * @param string|array $value String or array of strings to unslash.
4880 4879
  * @return string|array Unslashed $value
4881 4880
  */
4882
-function wp_unslash( $value ) {
4883
-	return stripslashes_deep( $value );
4881
+function wp_unslash($value) {
4882
+	return stripslashes_deep($value);
4884 4883
 }
4885 4884
 
4886 4885
 /**
@@ -4891,13 +4890,13 @@  discard block
 block discarded – undo
4891 4890
  * @param string $content A string which might contain a URL.
4892 4891
  * @return string|false The found URL.
4893 4892
  */
4894
-function get_url_in_content( $content ) {
4895
-	if ( empty( $content ) ) {
4893
+function get_url_in_content($content) {
4894
+	if (empty($content)) {
4896 4895
 		return false;
4897 4896
 	}
4898 4897
 
4899
-	if ( preg_match( '/<a\s[^>]*?href=([\'"])(.+?)\1/is', $content, $matches ) ) {
4900
-		return esc_url_raw( $matches[2] );
4898
+	if (preg_match('/<a\s[^>]*?href=([\'"])(.+?)\1/is', $content, $matches)) {
4899
+		return esc_url_raw($matches[2]);
4901 4900
 	}
4902 4901
 
4903 4902
 	return false;
@@ -4919,7 +4918,7 @@  discard block
 block discarded – undo
4919 4918
 function wp_spaces_regexp() {
4920 4919
 	static $spaces = '';
4921 4920
 
4922
-	if ( empty( $spaces ) ) {
4921
+	if (empty($spaces)) {
4923 4922
 		/**
4924 4923
 		 * Filters the regexp for common whitespace characters.
4925 4924
 		 *
@@ -4932,7 +4931,7 @@  discard block
 block discarded – undo
4932 4931
 		 *
4933 4932
 		 * @param string $spaces Regexp pattern for matching common whitespace characters.
4934 4933
 		 */
4935
-		$spaces = apply_filters( 'wp_spaces_regexp', '[\r\n\t ]|\xC2\xA0|&nbsp;' );
4934
+		$spaces = apply_filters('wp_spaces_regexp', '[\r\n\t ]|\xC2\xA0|&nbsp;');
4936 4935
 	}
4937 4936
 
4938 4937
 	return $spaces;
@@ -4948,7 +4947,7 @@  discard block
 block discarded – undo
4948 4947
 function print_emoji_styles() {
4949 4948
 	static $printed = false;
4950 4949
 
4951
-	if ( $printed ) {
4950
+	if ($printed) {
4952 4951
 		return;
4953 4952
 	}
4954 4953
 
@@ -4980,7 +4979,7 @@  discard block
 block discarded – undo
4980 4979
 function print_emoji_detection_script() {
4981 4980
 	static $printed = false;
4982 4981
 
4983
-	if ( $printed ) {
4982
+	if ($printed) {
4984 4983
 		return;
4985 4984
 	}
4986 4985
 
@@ -5005,7 +5004,7 @@  discard block
 block discarded – undo
5005 5004
 		 *
5006 5005
 		 * @param string The emoji base URL for png images.
5007 5006
 		 */
5008
-		'baseUrl' => apply_filters( 'emoji_url', 'https://s.w.org/images/core/emoji/2.2.1/72x72/' ),
5007
+		'baseUrl' => apply_filters('emoji_url', 'https://s.w.org/images/core/emoji/2.2.1/72x72/'),
5009 5008
 
5010 5009
 		/**
5011 5010
 		 * Filters the extension of the emoji png files.
@@ -5014,7 +5013,7 @@  discard block
 block discarded – undo
5014 5013
 		 *
5015 5014
 		 * @param string The emoji extension for png files. Default .png.
5016 5015
 		 */
5017
-		'ext' => apply_filters( 'emoji_ext', '.png' ),
5016
+		'ext' => apply_filters('emoji_ext', '.png'),
5018 5017
 
5019 5018
 		/**
5020 5019
 		 * Filters the URL where emoji SVG images are hosted.
@@ -5023,7 +5022,7 @@  discard block
 block discarded – undo
5023 5022
 		 *
5024 5023
 		 * @param string The emoji base URL for svg images.
5025 5024
 		 */
5026
-		'svgUrl' => apply_filters( 'emoji_svg_url', 'https://s.w.org/images/core/emoji/2.2.1/svg/' ),
5025
+		'svgUrl' => apply_filters('emoji_svg_url', 'https://s.w.org/images/core/emoji/2.2.1/svg/'),
5027 5026
 
5028 5027
 		/**
5029 5028
 		 * Filters the extension of the emoji SVG files.
@@ -5032,29 +5031,29 @@  discard block
 block discarded – undo
5032 5031
 		 *
5033 5032
 		 * @param string The emoji extension for svg files. Default .svg.
5034 5033
 		 */
5035
-		'svgExt' => apply_filters( 'emoji_svg_ext', '.svg' ),
5034
+		'svgExt' => apply_filters('emoji_svg_ext', '.svg'),
5036 5035
 	);
5037 5036
 
5038
-	$version = 'ver=' . get_bloginfo( 'version' );
5037
+	$version = 'ver='.get_bloginfo('version');
5039 5038
 
5040
-	if ( SCRIPT_DEBUG ) {
5039
+	if (SCRIPT_DEBUG) {
5041 5040
 		$settings['source'] = array(
5042 5041
 			/** This filter is documented in wp-includes/class.wp-scripts.php */
5043
-			'wpemoji' => apply_filters( 'script_loader_src', includes_url( "js/wp-emoji.js?$version" ), 'wpemoji' ),
5042
+			'wpemoji' => apply_filters('script_loader_src', includes_url("js/wp-emoji.js?$version"), 'wpemoji'),
5044 5043
 			/** This filter is documented in wp-includes/class.wp-scripts.php */
5045
-			'twemoji' => apply_filters( 'script_loader_src', includes_url( "js/twemoji.js?$version" ), 'twemoji' ),
5044
+			'twemoji' => apply_filters('script_loader_src', includes_url("js/twemoji.js?$version"), 'twemoji'),
5046 5045
 		);
5047 5046
 
5048 5047
 		?>
5049 5048
 		<script type="text/javascript">
5050
-			window._wpemojiSettings = <?php echo wp_json_encode( $settings ); ?>;
5051
-			<?php readfile( ABSPATH . WPINC . "/js/wp-emoji-loader.js" ); ?>
5049
+			window._wpemojiSettings = <?php echo wp_json_encode($settings); ?>;
5050
+			<?php readfile(ABSPATH.WPINC."/js/wp-emoji-loader.js"); ?>
5052 5051
 		</script>
5053 5052
 		<?php
5054 5053
 	} else {
5055 5054
 		$settings['source'] = array(
5056 5055
 			/** This filter is documented in wp-includes/class.wp-scripts.php */
5057
-			'concatemoji' => apply_filters( 'script_loader_src', includes_url( "js/wp-emoji-release.min.js?$version" ), 'concatemoji' ),
5056
+			'concatemoji' => apply_filters('script_loader_src', includes_url("js/wp-emoji-release.min.js?$version"), 'concatemoji'),
5058 5057
 		);
5059 5058
 
5060 5059
 		/*
@@ -5069,7 +5068,7 @@  discard block
 block discarded – undo
5069 5068
 		 */
5070 5069
 		?>
5071 5070
 		<script type="text/javascript">
5072
-			window._wpemojiSettings = <?php echo wp_json_encode( $settings ); ?>;
5071
+			window._wpemojiSettings = <?php echo wp_json_encode($settings); ?>;
5073 5072
 			include "js/wp-emoji-loader.min.js"
5074 5073
 		</script>
5075 5074
 		<?php
@@ -5089,8 +5088,8 @@  discard block
 block discarded – undo
5089 5088
  * @param string $content The content to encode.
5090 5089
  * @return string The encoded content.
5091 5090
  */
5092
-function wp_encode_emoji( $content ) {
5093
-	if ( function_exists( 'mb_convert_encoding' ) ) {
5091
+function wp_encode_emoji($content) {
5092
+	if (function_exists('mb_convert_encoding')) {
5094 5093
 		$regex = '/(
5095 5094
 		     \x23\xE2\x83\xA3               # Digits
5096 5095
 		     [\x30-\x39]\xE2\x83\xA3
@@ -5102,18 +5101,18 @@  discard block
 block discarded – undo
5102 5101
 		)/x';
5103 5102
 
5104 5103
 		$matches = array();
5105
-		if ( preg_match_all( $regex, $content, $matches ) ) {
5106
-			if ( ! empty( $matches[1] ) ) {
5107
-				foreach ( $matches[1] as $emoji ) {
5104
+		if (preg_match_all($regex, $content, $matches)) {
5105
+			if ( ! empty($matches[1])) {
5106
+				foreach ($matches[1] as $emoji) {
5108 5107
 					/*
5109 5108
 					 * UTF-32's hex encoding is the same as HTML's hex encoding.
5110 5109
 					 * So, by converting the emoji from UTF-8 to UTF-32, we magically
5111 5110
 					 * get the correct hex encoding.
5112 5111
 					 */
5113
-					$unpacked = unpack( 'H*', mb_convert_encoding( $emoji, 'UTF-32', 'UTF-8' ) );
5114
-					if ( isset( $unpacked[1] ) ) {
5115
-						$entity = '&#x' . ltrim( $unpacked[1], '0' ) . ';';
5116
-						$content = str_replace( $emoji, $entity, $content );
5112
+					$unpacked = unpack('H*', mb_convert_encoding($emoji, 'UTF-32', 'UTF-8'));
5113
+					if (isset($unpacked[1])) {
5114
+						$entity = '&#x'.ltrim($unpacked[1], '0').';';
5115
+						$content = str_replace($emoji, $entity, $content);
5117 5116
 					}
5118 5117
 				}
5119 5118
 			}
@@ -5131,14 +5130,14 @@  discard block
 block discarded – undo
5131 5130
  * @param string $text The content to encode.
5132 5131
  * @return string The encoded content.
5133 5132
  */
5134
-function wp_staticize_emoji( $text ) {
5135
-	$text = wp_encode_emoji( $text );
5133
+function wp_staticize_emoji($text) {
5134
+	$text = wp_encode_emoji($text);
5136 5135
 
5137 5136
 	/** This filter is documented in wp-includes/formatting.php */
5138
-	$cdn_url = apply_filters( 'emoji_url', 'https://s.w.org/images/core/emoji/2.2.1/72x72/' );
5137
+	$cdn_url = apply_filters('emoji_url', 'https://s.w.org/images/core/emoji/2.2.1/72x72/');
5139 5138
 
5140 5139
 	/** This filter is documented in wp-includes/formatting.php */
5141
-	$ext = apply_filters( 'emoji_ext', '.png' );
5140
+	$ext = apply_filters('emoji_ext', '.png');
5142 5141
 
5143 5142
 	$output = '';
5144 5143
 	/*
@@ -5147,33 +5146,33 @@  discard block
 block discarded – undo
5147 5146
 	 *
5148 5147
 	 * First, capture the tags as well as in between.
5149 5148
 	 */
5150
-	$textarr = preg_split( '/(<.*>)/U', $text, -1, PREG_SPLIT_DELIM_CAPTURE );
5151
-	$stop = count( $textarr );
5149
+	$textarr = preg_split('/(<.*>)/U', $text, -1, PREG_SPLIT_DELIM_CAPTURE);
5150
+	$stop = count($textarr);
5152 5151
 
5153 5152
 	// Ignore processing of specific tags.
5154 5153
 	$tags_to_ignore = 'code|pre|style|script|textarea';
5155 5154
 	$ignore_block_element = '';
5156 5155
 
5157
-	for ( $i = 0; $i < $stop; $i++ ) {
5156
+	for ($i = 0; $i < $stop; $i++) {
5158 5157
 		$content = $textarr[$i];
5159 5158
 
5160 5159
 		// If we're in an ignore block, wait until we find its closing tag.
5161
-		if ( '' == $ignore_block_element && preg_match( '/^<(' . $tags_to_ignore . ')>/', $content, $matches ) )  {
5160
+		if ('' == $ignore_block_element && preg_match('/^<('.$tags_to_ignore.')>/', $content, $matches)) {
5162 5161
 			$ignore_block_element = $matches[1];
5163 5162
 		}
5164 5163
 
5165 5164
 		// If it's not a tag and not in ignore block.
5166
-		if ( '' ==  $ignore_block_element && strlen( $content ) > 0 && '<' != $content[0] ) {
5165
+		if ('' == $ignore_block_element && strlen($content) > 0 && '<' != $content[0]) {
5167 5166
 			$matches = array();
5168
-			if ( preg_match_all( '/(&#x1f1(e[6-9a-f]|f[0-9a-f]);){2}/', $content, $matches ) ) {
5169
-				if ( ! empty( $matches[0] ) ) {
5170
-					foreach ( $matches[0] as $flag ) {
5171
-						$chars = str_replace( array( '&#x', ';'), '', $flag );
5167
+			if (preg_match_all('/(&#x1f1(e[6-9a-f]|f[0-9a-f]);){2}/', $content, $matches)) {
5168
+				if ( ! empty($matches[0])) {
5169
+					foreach ($matches[0] as $flag) {
5170
+						$chars = str_replace(array('&#x', ';'), '', $flag);
5172 5171
 
5173
-						list( $char1, $char2 ) = str_split( $chars, 5 );
5174
-						$entity = sprintf( '<img src="%s" alt="%s" class="wp-smiley" style="height: 1em; max-height: 1em;" />', $cdn_url . $char1 . '-' . $char2 . $ext, html_entity_decode( $flag ) );
5172
+						list($char1, $char2) = str_split($chars, 5);
5173
+						$entity = sprintf('<img src="%s" alt="%s" class="wp-smiley" style="height: 1em; max-height: 1em;" />', $cdn_url.$char1.'-'.$char2.$ext, html_entity_decode($flag));
5175 5174
 
5176
-						$content = str_replace( $flag, $entity, $content );
5175
+						$content = str_replace($flag, $entity, $content);
5177 5176
 					}
5178 5177
 				}
5179 5178
 			}
@@ -5182,20 +5181,20 @@  discard block
 block discarded – undo
5182 5181
 			$regex = '/(&#x[2-3][0-9a-f]{3};|&#x1f[1-6][0-9a-f]{2};)/';
5183 5182
 
5184 5183
 			$matches = array();
5185
-			if ( preg_match_all( $regex, $content, $matches ) ) {
5186
-				if ( ! empty( $matches[1] ) ) {
5187
-					foreach ( $matches[1] as $emoji ) {
5188
-						$char = str_replace( array( '&#x', ';'), '', $emoji );
5189
-						$entity = sprintf( '<img src="%s" alt="%s" class="wp-smiley" style="height: 1em; max-height: 1em;" />', $cdn_url . $char . $ext, html_entity_decode( $emoji ) );
5184
+			if (preg_match_all($regex, $content, $matches)) {
5185
+				if ( ! empty($matches[1])) {
5186
+					foreach ($matches[1] as $emoji) {
5187
+						$char = str_replace(array('&#x', ';'), '', $emoji);
5188
+						$entity = sprintf('<img src="%s" alt="%s" class="wp-smiley" style="height: 1em; max-height: 1em;" />', $cdn_url.$char.$ext, html_entity_decode($emoji));
5190 5189
 
5191
-						$content = str_replace( $emoji, $entity, $content );
5190
+						$content = str_replace($emoji, $entity, $content);
5192 5191
 					}
5193 5192
 				}
5194 5193
 			}
5195 5194
 		}
5196 5195
 
5197 5196
 		// Did we exit ignore block.
5198
-		if ( '' != $ignore_block_element && '</' . $ignore_block_element . '>' == $content )  {
5197
+		if ('' != $ignore_block_element && '</'.$ignore_block_element.'>' == $content) {
5199 5198
 			$ignore_block_element = '';
5200 5199
 		}
5201 5200
 
@@ -5213,8 +5212,8 @@  discard block
 block discarded – undo
5213 5212
  * @param array $mail The email data array.
5214 5213
  * @return array The email data array, with emoji in the message staticized.
5215 5214
  */
5216
-function wp_staticize_emoji_for_email( $mail ) {
5217
-	if ( ! isset( $mail['message'] ) ) {
5215
+function wp_staticize_emoji_for_email($mail) {
5216
+	if ( ! isset($mail['message'])) {
5218 5217
 		return $mail;
5219 5218
 	}
5220 5219
 
@@ -5226,47 +5225,47 @@  discard block
 block discarded – undo
5226 5225
 	 * is handling changing the Content-Type.
5227 5226
 	 */
5228 5227
 	$headers = array();
5229
-	if ( isset( $mail['headers'] ) ) {
5230
-		if ( is_array( $mail['headers'] ) ) {
5228
+	if (isset($mail['headers'])) {
5229
+		if (is_array($mail['headers'])) {
5231 5230
 			$headers = $mail['headers'];
5232 5231
 		} else {
5233
-			$headers = explode( "\n", str_replace( "\r\n", "\n", $mail['headers'] ) );
5232
+			$headers = explode("\n", str_replace("\r\n", "\n", $mail['headers']));
5234 5233
 		}
5235 5234
 	}
5236 5235
 
5237
-	foreach ( $headers as $header ) {
5238
-		if ( strpos($header, ':') === false ) {
5236
+	foreach ($headers as $header) {
5237
+		if (strpos($header, ':') === false) {
5239 5238
 			continue;
5240 5239
 		}
5241 5240
 
5242 5241
 		// Explode them out.
5243
-		list( $name, $content ) = explode( ':', trim( $header ), 2 );
5242
+		list($name, $content) = explode(':', trim($header), 2);
5244 5243
 
5245 5244
 		// Cleanup crew.
5246
-		$name    = trim( $name    );
5247
-		$content = trim( $content );
5245
+		$name    = trim($name);
5246
+		$content = trim($content);
5248 5247
 
5249
-		if ( 'content-type' === strtolower( $name ) ) {
5250
-			if ( strpos( $content, ';' ) !== false ) {
5251
-				list( $type, $charset ) = explode( ';', $content );
5252
-				$content_type = trim( $type );
5248
+		if ('content-type' === strtolower($name)) {
5249
+			if (strpos($content, ';') !== false) {
5250
+				list($type, $charset) = explode(';', $content);
5251
+				$content_type = trim($type);
5253 5252
 			} else {
5254
-				$content_type = trim( $content );
5253
+				$content_type = trim($content);
5255 5254
 			}
5256 5255
 			break;
5257 5256
 		}
5258 5257
 	}
5259 5258
 
5260 5259
 	// Set Content-Type if we don't have a content-type from the input headers.
5261
-	if ( ! isset( $content_type ) ) {
5260
+	if ( ! isset($content_type)) {
5262 5261
 		$content_type = 'text/plain';
5263 5262
 	}
5264 5263
 
5265 5264
 	/** This filter is documented in wp-includes/pluggable.php */
5266
-	$content_type = apply_filters( 'wp_mail_content_type', $content_type );
5265
+	$content_type = apply_filters('wp_mail_content_type', $content_type);
5267 5266
 
5268
-	if ( 'text/html' === $content_type ) {
5269
-		$mail['message'] = wp_staticize_emoji( $mail['message'] );
5267
+	if ('text/html' === $content_type) {
5268
+		$mail['message'] = wp_staticize_emoji($mail['message']);
5270 5269
 	}
5271 5270
 
5272 5271
 	return $mail;
@@ -5282,12 +5281,12 @@  discard block
 block discarded – undo
5282 5281
  * @param int    $length Optional. Maximum length of the shortened URL. Default 35 characters.
5283 5282
  * @return string Shortened URL.
5284 5283
  */
5285
-function url_shorten( $url, $length = 35 ) {
5286
-	$stripped = str_replace( array( 'https://', 'http://', 'www.' ), '', $url );
5287
-	$short_url = untrailingslashit( $stripped );
5284
+function url_shorten($url, $length = 35) {
5285
+	$stripped = str_replace(array('https://', 'http://', 'www.'), '', $url);
5286
+	$short_url = untrailingslashit($stripped);
5288 5287
 
5289
-	if ( strlen( $short_url ) > $length ) {
5290
-		$short_url = substr( $short_url, 0, $length - 3 ) . '&hellip;';
5288
+	if (strlen($short_url) > $length) {
5289
+		$short_url = substr($short_url, 0, $length - 3).'&hellip;';
5291 5290
 	}
5292 5291
 	return $short_url;
5293 5292
 }
@@ -5303,13 +5302,13 @@  discard block
 block discarded – undo
5303 5302
  * @param string $color
5304 5303
  * @return string|void
5305 5304
  */
5306
-function sanitize_hex_color( $color ) {
5307
-	if ( '' === $color ) {
5305
+function sanitize_hex_color($color) {
5306
+	if ('' === $color) {
5308 5307
 		return '';
5309 5308
 	}
5310 5309
 
5311 5310
 	// 3 or 6 hex digits, or the empty string.
5312
-	if ( preg_match('|^#([A-Fa-f0-9]{3}){1,2}$|', $color ) ) {
5311
+	if (preg_match('|^#([A-Fa-f0-9]{3}){1,2}$|', $color)) {
5313 5312
 		return $color;
5314 5313
 	}
5315 5314
 }
@@ -5328,14 +5327,14 @@  discard block
 block discarded – undo
5328 5327
  * @param string $color
5329 5328
  * @return string|null
5330 5329
  */
5331
-function sanitize_hex_color_no_hash( $color ) {
5332
-	$color = ltrim( $color, '#' );
5330
+function sanitize_hex_color_no_hash($color) {
5331
+	$color = ltrim($color, '#');
5333 5332
 
5334
-	if ( '' === $color ) {
5333
+	if ('' === $color) {
5335 5334
 		return '';
5336 5335
 	}
5337 5336
 
5338
-	return sanitize_hex_color( '#' . $color ) ? $color : null;
5337
+	return sanitize_hex_color('#'.$color) ? $color : null;
5339 5338
 }
5340 5339
 
5341 5340
 /**
@@ -5349,9 +5348,9 @@  discard block
 block discarded – undo
5349 5348
  * @param string $color
5350 5349
  * @return string
5351 5350
  */
5352
-function maybe_hash_hex_color( $color ) {
5353
-	if ( $unhashed = sanitize_hex_color_no_hash( $color ) ) {
5354
-		return '#' . $unhashed;
5351
+function maybe_hash_hex_color($color) {
5352
+	if ($unhashed = sanitize_hex_color_no_hash($color)) {
5353
+		return '#'.$unhashed;
5355 5354
 	}
5356 5355
 
5357 5356
 	return $color;
Please login to merge, or discard this patch.
src/wp-load.php 1 patch
Spacing   +27 added lines, -27 removed lines patch added patch discarded remove patch
@@ -19,11 +19,11 @@  discard block
 block discarded – undo
19 19
  */
20 20
 
21 21
 /** Define ABSPATH as this file's directory */
22
-if ( ! defined( 'ABSPATH' ) ) {
23
-	define( 'ABSPATH', dirname( __FILE__ ) . '/' );
22
+if ( ! defined('ABSPATH')) {
23
+	define('ABSPATH', dirname(__FILE__).'/');
24 24
 }
25 25
 
26
-error_reporting( E_CORE_ERROR | E_CORE_WARNING | E_COMPILE_ERROR | E_ERROR | E_WARNING | E_PARSE | E_USER_ERROR | E_USER_WARNING | E_RECOVERABLE_ERROR );
26
+error_reporting(E_CORE_ERROR | E_CORE_WARNING | E_COMPILE_ERROR | E_ERROR | E_WARNING | E_PARSE | E_USER_ERROR | E_USER_WARNING | E_RECOVERABLE_ERROR);
27 27
 
28 28
 /*
29 29
  * If wp-config.php exists in the WordPress root, or if it exists in the root and wp-settings.php
@@ -33,63 +33,63 @@  discard block
 block discarded – undo
33 33
  *
34 34
  * If neither set of conditions is true, initiate loading the setup process.
35 35
  */
36
-if ( file_exists( ABSPATH . 'wp-config.php') ) {
36
+if (file_exists(ABSPATH.'wp-config.php')) {
37 37
 
38 38
 	/** The config file resides in ABSPATH */
39
-	require_once( ABSPATH . 'wp-config.php' );
39
+	require_once(ABSPATH.'wp-config.php');
40 40
 
41
-} elseif ( @file_exists( dirname( ABSPATH ) . '/wp-config.php' ) && ! @file_exists( dirname( ABSPATH ) . '/wp-settings.php' ) ) {
41
+} elseif (@file_exists(dirname(ABSPATH).'/wp-config.php') && ! @file_exists(dirname(ABSPATH).'/wp-settings.php')) {
42 42
 
43 43
 	/** The config file resides one level above ABSPATH but is not part of another install */
44
-	require_once( dirname( ABSPATH ) . '/wp-config.php' );
44
+	require_once(dirname(ABSPATH).'/wp-config.php');
45 45
 
46 46
 } else {
47 47
 
48 48
 	// A config file doesn't exist
49 49
 
50
-	define( 'WPINC', 'wp-includes' );
51
-	require_once( ABSPATH . WPINC . '/load.php' );
50
+	define('WPINC', 'wp-includes');
51
+	require_once(ABSPATH.WPINC.'/load.php');
52 52
 
53 53
 	// Standardize $_SERVER variables across setups.
54 54
 	wp_fix_server_vars();
55 55
 
56
-	require_once( ABSPATH . WPINC . '/functions.php' );
56
+	require_once(ABSPATH.WPINC.'/functions.php');
57 57
 
58
-	$path = wp_guess_url() . '/wp-admin/setup-config.php';
58
+	$path = wp_guess_url().'/wp-admin/setup-config.php';
59 59
 
60 60
 	/*
61 61
 	 * We're going to redirect to setup-config.php. While this shouldn't result
62 62
 	 * in an infinite loop, that's a silly thing to assume, don't you think? If
63 63
 	 * we're traveling in circles, our last-ditch effort is "Need more help?"
64 64
 	 */
65
-	if ( false === strpos( $_SERVER['REQUEST_URI'], 'setup-config' ) ) {
66
-		header( 'Location: ' . $path );
65
+	if (false === strpos($_SERVER['REQUEST_URI'], 'setup-config')) {
66
+		header('Location: '.$path);
67 67
 		exit;
68 68
 	}
69 69
 
70
-	define( 'WP_CONTENT_DIR', ABSPATH . 'wp-content' );
71
-	require_once( ABSPATH . WPINC . '/version.php' );
70
+	define('WP_CONTENT_DIR', ABSPATH.'wp-content');
71
+	require_once(ABSPATH.WPINC.'/version.php');
72 72
 
73 73
 	wp_check_php_mysql_versions();
74 74
 	wp_load_translations_early();
75 75
 
76 76
 	// Die with an error message
77
-	$die  = sprintf(
77
+	$die = sprintf(
78 78
 		/* translators: %s: wp-config.php */
79
-		__( "There doesn't seem to be a %s file. I need this before we can get started." ),
79
+		__("There doesn't seem to be a %s file. I need this before we can get started."),
80 80
 		'<code>wp-config.php</code>'
81
-	) . '</p>';
82
-	$die .= '<p>' . sprintf(
81
+	).'</p>';
82
+	$die .= '<p>'.sprintf(
83 83
 		/* translators: %s: Codex URL */
84
-		__( "Need more help? <a href='%s'>We got it</a>." ),
85
-		__( 'https://codex.wordpress.org/Editing_wp-config.php' )
86
-	) . '</p>';
87
-	$die .= '<p>' . sprintf(
84
+		__("Need more help? <a href='%s'>We got it</a>."),
85
+		__('https://codex.wordpress.org/Editing_wp-config.php')
86
+	).'</p>';
87
+	$die .= '<p>'.sprintf(
88 88
 		/* translators: %s: wp-config.php */
89
-		__( "You can create a %s file through a web interface, but this doesn't work for all server setups. The safest way is to manually create the file." ),
89
+		__("You can create a %s file through a web interface, but this doesn't work for all server setups. The safest way is to manually create the file."),
90 90
 		'<code>wp-config.php</code>'
91
-	) . '</p>';
92
-	$die .= '<p><a href="' . $path . '" class="button button-large">' . __( "Create a Configuration File" ) . '</a>';
91
+	).'</p>';
92
+	$die .= '<p><a href="'.$path.'" class="button button-large">'.__("Create a Configuration File").'</a>';
93 93
 
94
-	wp_die( $die, __( 'WordPress &rsaquo; Error' ) );
94
+	wp_die($die, __('WordPress &rsaquo; Error'));
95 95
 }
Please login to merge, or discard this patch.
src/wp-admin/includes/class-theme-upgrader.php 2 patches
Braces   +60 added lines, -37 removed lines patch added patch discarded remove patch
@@ -99,8 +99,9 @@  discard block
 block discarded – undo
99 99
 		// Check to see if we need to install a parent theme
100 100
 		$theme_info = $this->theme_info();
101 101
 
102
-		if ( ! $theme_info->parent() )
103
-			return $install_result;
102
+		if ( ! $theme_info->parent() ) {
103
+					return $install_result;
104
+		}
104 105
 
105 106
 		$this->skin->feedback( 'parent_theme_search' );
106 107
 
@@ -140,8 +141,9 @@  discard block
 block discarded – undo
140 141
 			'clear_working' => true
141 142
 		) );
142 143
 
143
-		if ( is_wp_error($parent_result) )
144
-			add_filter('install_theme_complete_actions', array($this, 'hide_activate_preview_actions') );
144
+		if ( is_wp_error($parent_result) ) {
145
+					add_filter('install_theme_complete_actions', array($this, 'hide_activate_preview_actions') );
146
+		}
145 147
 
146 148
 		// Start cleaning up after the parents installation
147 149
 		remove_filter('install_theme_complete_actions', '__return_false', 999);
@@ -219,8 +221,9 @@  discard block
 block discarded – undo
219 221
 		remove_filter('upgrader_source_selection', array($this, 'check_package') );
220 222
 		remove_filter('upgrader_post_install', array($this, 'check_parent_theme_filter'));
221 223
 
222
-		if ( ! $this->result || is_wp_error($this->result) )
223
-			return $this->result;
224
+		if ( ! $this->result || is_wp_error($this->result) ) {
225
+					return $this->result;
226
+		}
224 227
 
225 228
 		// Refresh the Theme Update information
226 229
 		wp_clean_themes_cache( $parsed_args['clear_update_cache'] );
@@ -289,8 +292,9 @@  discard block
 block discarded – undo
289 292
 		remove_filter('upgrader_post_install', array($this, 'current_after'));
290 293
 		remove_filter('upgrader_clear_destination', array($this, 'delete_old_theme'));
291 294
 
292
-		if ( ! $this->result || is_wp_error($this->result) )
293
-			return $this->result;
295
+		if ( ! $this->result || is_wp_error($this->result) ) {
296
+					return $this->result;
297
+		}
294 298
 
295 299
 		wp_clean_themes_cache( $parsed_args['clear_update_cache'] );
296 300
 
@@ -348,10 +352,12 @@  discard block
 block discarded – undo
348 352
 		// - a theme with an update available is currently in use.
349 353
 		// @TODO: For multisite, maintenance mode should only kick in for individual sites if at all possible.
350 354
 		$maintenance = ( is_multisite() && ! empty( $themes ) );
351
-		foreach ( $themes as $theme )
352
-			$maintenance = $maintenance || $theme == get_stylesheet() || $theme == get_template();
353
-		if ( $maintenance )
354
-			$this->maintenance_mode(true);
355
+		foreach ( $themes as $theme ) {
356
+					$maintenance = $maintenance || $theme == get_stylesheet() || $theme == get_template();
357
+		}
358
+		if ( $maintenance ) {
359
+					$this->maintenance_mode(true);
360
+		}
355 361
 
356 362
 		$results = array();
357 363
 
@@ -388,8 +394,9 @@  discard block
 block discarded – undo
388 394
 			$results[$theme] = $this->result;
389 395
 
390 396
 			// Prevent credentials auth screen from displaying multiple times
391
-			if ( false === $result )
392
-				break;
397
+			if ( false === $result ) {
398
+							break;
399
+			}
393 400
 		} //end foreach $plugins
394 401
 
395 402
 		$this->maintenance_mode(false);
@@ -436,13 +443,16 @@  discard block
 block discarded – undo
436 443
 	public function check_package( $source ) {
437 444
 		global $wp_filesystem;
438 445
 
439
-		if ( is_wp_error($source) )
440
-			return $source;
446
+		if ( is_wp_error($source) ) {
447
+					return $source;
448
+		}
441 449
 
442 450
 		// Check the folder contains a valid theme
443 451
 		$working_directory = str_replace( $wp_filesystem->wp_content_dir(), trailingslashit(WP_CONTENT_DIR), $source);
444
-		if ( ! is_dir($working_directory) ) // Sanity check, if the above fails, let's not prevent installation.
452
+		if ( ! is_dir($working_directory) ) {
453
+			// Sanity check, if the above fails, let's not prevent installation.
445 454
 			return $source;
455
+		}
446 456
 
447 457
 		// A proper archive should have a style.css file in the single subdirectory
448 458
 		if ( ! file_exists( $working_directory . 'style.css' ) ) {
@@ -492,16 +502,20 @@  discard block
 block discarded – undo
492 502
 	 * @return bool|WP_Error
493 503
 	 */
494 504
 	public function current_before($return, $theme) {
495
-		if ( is_wp_error($return) )
496
-			return $return;
505
+		if ( is_wp_error($return) ) {
506
+					return $return;
507
+		}
497 508
 
498 509
 		$theme = isset($theme['theme']) ? $theme['theme'] : '';
499 510
 
500
-		if ( $theme != get_stylesheet() ) //If not current
511
+		if ( $theme != get_stylesheet() ) {
512
+			//If not current
501 513
 			return $return;
514
+		}
502 515
 		//Change to maintenance mode now.
503
-		if ( ! $this->bulk )
504
-			$this->maintenance_mode(true);
516
+		if ( ! $this->bulk ) {
517
+					$this->maintenance_mode(true);
518
+		}
505 519
 
506 520
 		return $return;
507 521
 	}
@@ -520,13 +534,16 @@  discard block
 block discarded – undo
520 534
 	 * @return bool|WP_Error
521 535
 	 */
522 536
 	public function current_after($return, $theme) {
523
-		if ( is_wp_error($return) )
524
-			return $return;
537
+		if ( is_wp_error($return) ) {
538
+					return $return;
539
+		}
525 540
 
526 541
 		$theme = isset($theme['theme']) ? $theme['theme'] : '';
527 542
 
528
-		if ( $theme != get_stylesheet() ) // If not current
543
+		if ( $theme != get_stylesheet() ) {
544
+			// If not current
529 545
 			return $return;
546
+		}
530 547
 
531 548
 		// Ensure stylesheet name hasn't changed after the upgrade:
532 549
 		if ( $theme == get_stylesheet() && $theme != $this->result['destination_name'] ) {
@@ -536,8 +553,9 @@  discard block
 block discarded – undo
536 553
 		}
537 554
 
538 555
 		//Time to remove maintenance mode
539
-		if ( ! $this->bulk )
540
-			$this->maintenance_mode(false);
556
+		if ( ! $this->bulk ) {
557
+					$this->maintenance_mode(false);
558
+		}
541 559
 		return $return;
542 560
 	}
543 561
 
@@ -561,17 +579,21 @@  discard block
 block discarded – undo
561 579
 	public function delete_old_theme( $removed, $local_destination, $remote_destination, $theme ) {
562 580
 		global $wp_filesystem;
563 581
 
564
-		if ( is_wp_error( $removed ) )
565
-			return $removed; // Pass errors through.
582
+		if ( is_wp_error( $removed ) ) {
583
+					return $removed;
584
+		}
585
+		// Pass errors through.
566 586
 
567
-		if ( ! isset( $theme['theme'] ) )
568
-			return $removed;
587
+		if ( ! isset( $theme['theme'] ) ) {
588
+					return $removed;
589
+		}
569 590
 
570 591
 		$theme = $theme['theme'];
571 592
 		$themes_dir = trailingslashit( $wp_filesystem->wp_themes_dir( $theme ) );
572 593
 		if ( $wp_filesystem->exists( $themes_dir . $theme ) ) {
573
-			if ( ! $wp_filesystem->delete( $themes_dir . $theme, true ) )
574
-				return false;
594
+			if ( ! $wp_filesystem->delete( $themes_dir . $theme, true ) ) {
595
+							return false;
596
+			}
575 597
 		}
576 598
 
577 599
 		return true;
@@ -592,10 +614,11 @@  discard block
 block discarded – undo
592 614
 	public function theme_info($theme = null) {
593 615
 
594 616
 		if ( empty($theme) ) {
595
-			if ( !empty($this->result['destination_name']) )
596
-				$theme = $this->result['destination_name'];
597
-			else
598
-				return false;
617
+			if ( !empty($this->result['destination_name']) ) {
618
+							$theme = $this->result['destination_name'];
619
+			} else {
620
+							return false;
621
+			}
599 622
 		}
600 623
 		return wp_get_theme( $theme );
601 624
 	}
Please login to merge, or discard this patch.
Spacing   +90 added lines, -90 removed lines patch added patch discarded remove patch
@@ -95,28 +95,28 @@  discard block
 block discarded – undo
95 95
 	 * @param array $child_result
96 96
 	 * @return type
97 97
 	 */
98
-	public function check_parent_theme_filter( $install_result, $hook_extra, $child_result ) {
98
+	public function check_parent_theme_filter($install_result, $hook_extra, $child_result) {
99 99
 		// Check to see if we need to install a parent theme
100 100
 		$theme_info = $this->theme_info();
101 101
 
102
-		if ( ! $theme_info->parent() )
102
+		if ( ! $theme_info->parent())
103 103
 			return $install_result;
104 104
 
105
-		$this->skin->feedback( 'parent_theme_search' );
105
+		$this->skin->feedback('parent_theme_search');
106 106
 
107
-		if ( ! $theme_info->parent()->errors() ) {
108
-			$this->skin->feedback( 'parent_theme_currently_installed', $theme_info->parent()->display('Name'), $theme_info->parent()->display('Version') );
107
+		if ( ! $theme_info->parent()->errors()) {
108
+			$this->skin->feedback('parent_theme_currently_installed', $theme_info->parent()->display('Name'), $theme_info->parent()->display('Version'));
109 109
 			// We already have the theme, fall through.
110 110
 			return $install_result;
111 111
 		}
112 112
 
113 113
 		// We don't have the parent theme, let's install it.
114
-		$api = themes_api('theme_information', array('slug' => $theme_info->get('Template'), 'fields' => array('sections' => false, 'tags' => false) ) ); //Save on a bit of bandwidth.
114
+		$api = themes_api('theme_information', array('slug' => $theme_info->get('Template'), 'fields' => array('sections' => false, 'tags' => false))); //Save on a bit of bandwidth.
115 115
 
116
-		if ( ! $api || is_wp_error($api) ) {
117
-			$this->skin->feedback( 'parent_theme_not_found', $theme_info->get('Template') );
116
+		if ( ! $api || is_wp_error($api)) {
117
+			$this->skin->feedback('parent_theme_not_found', $theme_info->get('Template'));
118 118
 			// Don't show activate or preview actions after install
119
-			add_filter('install_theme_complete_actions', array($this, 'hide_activate_preview_actions') );
119
+			add_filter('install_theme_complete_actions', array($this, 'hide_activate_preview_actions'));
120 120
 			return $install_result;
121 121
 		}
122 122
 
@@ -126,22 +126,22 @@  discard block
 block discarded – undo
126 126
 
127 127
 		// Override them
128 128
 		$this->skin->api = $api;
129
-		$this->strings['process_success_specific'] = $this->strings['parent_theme_install_success'];//, $api->name, $api->version);
129
+		$this->strings['process_success_specific'] = $this->strings['parent_theme_install_success']; //, $api->name, $api->version);
130 130
 
131 131
 		$this->skin->feedback('parent_theme_prepare_install', $api->name, $api->version);
132 132
 
133 133
 		add_filter('install_theme_complete_actions', '__return_false', 999); // Don't show any actions after installing the theme.
134 134
 
135 135
 		// Install the parent theme
136
-		$parent_result = $this->run( array(
136
+		$parent_result = $this->run(array(
137 137
 			'package' => $api->download_link,
138 138
 			'destination' => get_theme_root(),
139 139
 			'clear_destination' => false, //Do not overwrite files.
140 140
 			'clear_working' => true
141
-		) );
141
+		));
142 142
 
143
-		if ( is_wp_error($parent_result) )
144
-			add_filter('install_theme_complete_actions', array($this, 'hide_activate_preview_actions') );
143
+		if (is_wp_error($parent_result))
144
+			add_filter('install_theme_complete_actions', array($this, 'hide_activate_preview_actions'));
145 145
 
146 146
 		// Start cleaning up after the parents installation
147 147
 		remove_filter('install_theme_complete_actions', '__return_false', 999);
@@ -167,7 +167,7 @@  discard block
 block discarded – undo
167 167
 	 * @param array $actions Preview actions.
168 168
 	 * @return array
169 169
 	 */
170
-	public function hide_activate_preview_actions( $actions ) {
170
+	public function hide_activate_preview_actions($actions) {
171 171
 		unset($actions['activate'], $actions['preview']);
172 172
 		return $actions;
173 173
 	}
@@ -189,24 +189,24 @@  discard block
 block discarded – undo
189 189
 	 *
190 190
 	 * @return bool|WP_Error True if the install was successful, false or a WP_Error object otherwise.
191 191
 	 */
192
-	public function install( $package, $args = array() ) {
192
+	public function install($package, $args = array()) {
193 193
 
194 194
 		$defaults = array(
195 195
 			'clear_update_cache' => true,
196 196
 		);
197
-		$parsed_args = wp_parse_args( $args, $defaults );
197
+		$parsed_args = wp_parse_args($args, $defaults);
198 198
 
199 199
 		$this->init();
200 200
 		$this->install_strings();
201 201
 
202
-		add_filter('upgrader_source_selection', array($this, 'check_package') );
202
+		add_filter('upgrader_source_selection', array($this, 'check_package'));
203 203
 		add_filter('upgrader_post_install', array($this, 'check_parent_theme_filter'), 10, 3);
204
-		if ( $parsed_args['clear_update_cache'] ) {
204
+		if ($parsed_args['clear_update_cache']) {
205 205
 			// Clear cache so wp_update_themes() knows about the new theme.
206
-			add_action( 'upgrader_process_complete', 'wp_clean_themes_cache', 9, 0 );
206
+			add_action('upgrader_process_complete', 'wp_clean_themes_cache', 9, 0);
207 207
 		}
208 208
 
209
-		$this->run( array(
209
+		$this->run(array(
210 210
 			'package' => $package,
211 211
 			'destination' => get_theme_root(),
212 212
 			'clear_destination' => false, //Do not overwrite files.
@@ -215,17 +215,17 @@  discard block
 block discarded – undo
215 215
 				'type' => 'theme',
216 216
 				'action' => 'install',
217 217
 			),
218
-		) );
218
+		));
219 219
 
220
-		remove_action( 'upgrader_process_complete', 'wp_clean_themes_cache', 9 );
221
-		remove_filter('upgrader_source_selection', array($this, 'check_package') );
220
+		remove_action('upgrader_process_complete', 'wp_clean_themes_cache', 9);
221
+		remove_filter('upgrader_source_selection', array($this, 'check_package'));
222 222
 		remove_filter('upgrader_post_install', array($this, 'check_parent_theme_filter'));
223 223
 
224
-		if ( ! $this->result || is_wp_error($this->result) )
224
+		if ( ! $this->result || is_wp_error($this->result))
225 225
 			return $this->result;
226 226
 
227 227
 		// Refresh the Theme Update information
228
-		wp_clean_themes_cache( $parsed_args['clear_update_cache'] );
228
+		wp_clean_themes_cache($parsed_args['clear_update_cache']);
229 229
 
230 230
 		return true;
231 231
 	}
@@ -246,39 +246,39 @@  discard block
 block discarded – undo
246 246
 	 * }
247 247
 	 * @return bool|WP_Error True if the upgrade was successful, false or a WP_Error object otherwise.
248 248
 	 */
249
-	public function upgrade( $theme, $args = array() ) {
249
+	public function upgrade($theme, $args = array()) {
250 250
 
251 251
 		$defaults = array(
252 252
 			'clear_update_cache' => true,
253 253
 		);
254
-		$parsed_args = wp_parse_args( $args, $defaults );
254
+		$parsed_args = wp_parse_args($args, $defaults);
255 255
 
256 256
 		$this->init();
257 257
 		$this->upgrade_strings();
258 258
 
259 259
 		// Is an update available?
260
-		$current = get_site_transient( 'update_themes' );
261
-		if ( !isset( $current->response[ $theme ] ) ) {
260
+		$current = get_site_transient('update_themes');
261
+		if ( ! isset($current->response[$theme])) {
262 262
 			$this->skin->before();
263 263
 			$this->skin->set_result(false);
264
-			$this->skin->error( 'up_to_date' );
264
+			$this->skin->error('up_to_date');
265 265
 			$this->skin->after();
266 266
 			return false;
267 267
 		}
268 268
 
269
-		$r = $current->response[ $theme ];
269
+		$r = $current->response[$theme];
270 270
 
271 271
 		add_filter('upgrader_pre_install', array($this, 'current_before'), 10, 2);
272 272
 		add_filter('upgrader_post_install', array($this, 'current_after'), 10, 2);
273 273
 		add_filter('upgrader_clear_destination', array($this, 'delete_old_theme'), 10, 4);
274
-		if ( $parsed_args['clear_update_cache'] ) {
274
+		if ($parsed_args['clear_update_cache']) {
275 275
 			// Clear cache so wp_update_themes() knows about the new theme.
276
-			add_action( 'upgrader_process_complete', 'wp_clean_themes_cache', 9, 0 );
276
+			add_action('upgrader_process_complete', 'wp_clean_themes_cache', 9, 0);
277 277
 		}
278 278
 
279
-		$this->run( array(
279
+		$this->run(array(
280 280
 			'package' => $r['package'],
281
-			'destination' => get_theme_root( $theme ),
281
+			'destination' => get_theme_root($theme),
282 282
 			'clear_destination' => true,
283 283
 			'clear_working' => true,
284 284
 			'hook_extra' => array(
@@ -286,17 +286,17 @@  discard block
 block discarded – undo
286 286
 				'type' => 'theme',
287 287
 				'action' => 'update',
288 288
 			),
289
-		) );
289
+		));
290 290
 
291
-		remove_action( 'upgrader_process_complete', 'wp_clean_themes_cache', 9 );
291
+		remove_action('upgrader_process_complete', 'wp_clean_themes_cache', 9);
292 292
 		remove_filter('upgrader_pre_install', array($this, 'current_before'));
293 293
 		remove_filter('upgrader_post_install', array($this, 'current_after'));
294 294
 		remove_filter('upgrader_clear_destination', array($this, 'delete_old_theme'));
295 295
 
296
-		if ( ! $this->result || is_wp_error($this->result) )
296
+		if ( ! $this->result || is_wp_error($this->result))
297 297
 			return $this->result;
298 298
 
299
-		wp_clean_themes_cache( $parsed_args['clear_update_cache'] );
299
+		wp_clean_themes_cache($parsed_args['clear_update_cache']);
300 300
 
301 301
 		return true;
302 302
 	}
@@ -317,18 +317,18 @@  discard block
 block discarded – undo
317 317
 	 * }
318 318
 	 * @return array[]|false An array of results, or false if unable to connect to the filesystem.
319 319
 	 */
320
-	public function bulk_upgrade( $themes, $args = array() ) {
320
+	public function bulk_upgrade($themes, $args = array()) {
321 321
 
322 322
 		$defaults = array(
323 323
 			'clear_update_cache' => true,
324 324
 		);
325
-		$parsed_args = wp_parse_args( $args, $defaults );
325
+		$parsed_args = wp_parse_args($args, $defaults);
326 326
 
327 327
 		$this->init();
328 328
 		$this->bulk = true;
329 329
 		$this->upgrade_strings();
330 330
 
331
-		$current = get_site_transient( 'update_themes' );
331
+		$current = get_site_transient('update_themes');
332 332
 
333 333
 		add_filter('upgrader_pre_install', array($this, 'current_before'), 10, 2);
334 334
 		add_filter('upgrader_post_install', array($this, 'current_after'), 10, 2);
@@ -337,8 +337,8 @@  discard block
 block discarded – undo
337 337
 		$this->skin->header();
338 338
 
339 339
 		// Connect to the Filesystem first.
340
-		$res = $this->fs_connect( array(WP_CONTENT_DIR) );
341
-		if ( ! $res ) {
340
+		$res = $this->fs_connect(array(WP_CONTENT_DIR));
341
+		if ( ! $res) {
342 342
 			$this->skin->footer();
343 343
 			return false;
344 344
 		}
@@ -349,63 +349,63 @@  discard block
 block discarded – undo
349 349
 		// - running Multisite and there are one or more themes specified, OR
350 350
 		// - a theme with an update available is currently in use.
351 351
 		// @TODO: For multisite, maintenance mode should only kick in for individual sites if at all possible.
352
-		$maintenance = ( is_multisite() && ! empty( $themes ) );
353
-		foreach ( $themes as $theme )
352
+		$maintenance = (is_multisite() && ! empty($themes));
353
+		foreach ($themes as $theme)
354 354
 			$maintenance = $maintenance || $theme == get_stylesheet() || $theme == get_template();
355
-		if ( $maintenance )
355
+		if ($maintenance)
356 356
 			$this->maintenance_mode(true);
357 357
 
358 358
 		$results = array();
359 359
 
360 360
 		$this->update_count = count($themes);
361 361
 		$this->update_current = 0;
362
-		foreach ( $themes as $theme ) {
362
+		foreach ($themes as $theme) {
363 363
 			$this->update_current++;
364 364
 
365 365
 			$this->skin->theme_info = $this->theme_info($theme);
366 366
 
367
-			if ( !isset( $current->response[ $theme ] ) ) {
367
+			if ( ! isset($current->response[$theme])) {
368 368
 				$this->skin->set_result(true);
369 369
 				$this->skin->before();
370
-				$this->skin->feedback( 'up_to_date' );
370
+				$this->skin->feedback('up_to_date');
371 371
 				$this->skin->after();
372 372
 				$results[$theme] = true;
373 373
 				continue;
374 374
 			}
375 375
 
376 376
 			// Get the URL to the zip file
377
-			$r = $current->response[ $theme ];
377
+			$r = $current->response[$theme];
378 378
 
379
-			$result = $this->run( array(
379
+			$result = $this->run(array(
380 380
 				'package' => $r['package'],
381
-				'destination' => get_theme_root( $theme ),
381
+				'destination' => get_theme_root($theme),
382 382
 				'clear_destination' => true,
383 383
 				'clear_working' => true,
384 384
 				'is_multi' => true,
385 385
 				'hook_extra' => array(
386 386
 					'theme' => $theme
387 387
 				),
388
-			) );
388
+			));
389 389
 
390 390
 			$results[$theme] = $this->result;
391 391
 
392 392
 			// Prevent credentials auth screen from displaying multiple times
393
-			if ( false === $result )
393
+			if (false === $result)
394 394
 				break;
395 395
 		} //end foreach $plugins
396 396
 
397 397
 		$this->maintenance_mode(false);
398 398
 
399 399
 		// Refresh the Theme Update information
400
-		wp_clean_themes_cache( $parsed_args['clear_update_cache'] );
400
+		wp_clean_themes_cache($parsed_args['clear_update_cache']);
401 401
 
402 402
 		/** This action is documented in wp-admin/includes/class-wp-upgrader.php */
403
-		do_action( 'upgrader_process_complete', $this, array(
403
+		do_action('upgrader_process_complete', $this, array(
404 404
 			'action' => 'update',
405 405
 			'type' => 'theme',
406 406
 			'bulk' => true,
407 407
 			'themes' => $themes,
408
-		) );
408
+		));
409 409
 
410 410
 		$this->skin->bulk_footer();
411 411
 
@@ -434,43 +434,43 @@  discard block
 block discarded – undo
434 434
 	 * @param string $source The full path to the package source.
435 435
 	 * @return string|WP_Error The source or a WP_Error.
436 436
 	 */
437
-	public function check_package( $source ) {
437
+	public function check_package($source) {
438 438
 		global $wp_filesystem;
439 439
 
440
-		if ( is_wp_error($source) )
440
+		if (is_wp_error($source))
441 441
 			return $source;
442 442
 
443 443
 		// Check the folder contains a valid theme
444
-		$working_directory = str_replace( $wp_filesystem->wp_content_dir(), trailingslashit(WP_CONTENT_DIR), $source);
445
-		if ( ! is_dir($working_directory) ) // Sanity check, if the above fails, let's not prevent installation.
444
+		$working_directory = str_replace($wp_filesystem->wp_content_dir(), trailingslashit(WP_CONTENT_DIR), $source);
445
+		if ( ! is_dir($working_directory)) // Sanity check, if the above fails, let's not prevent installation.
446 446
 			return $source;
447 447
 
448 448
 		// A proper archive should have a style.css file in the single subdirectory
449
-		if ( ! file_exists( $working_directory . 'style.css' ) ) {
450
-			return new WP_Error( 'incompatible_archive_theme_no_style', $this->strings['incompatible_archive'],
449
+		if ( ! file_exists($working_directory.'style.css')) {
450
+			return new WP_Error('incompatible_archive_theme_no_style', $this->strings['incompatible_archive'],
451 451
 				/* translators: %s: style.css */
452
-				sprintf( __( 'The theme is missing the %s stylesheet.' ),
452
+				sprintf(__('The theme is missing the %s stylesheet.'),
453 453
 					'<code>style.css</code>'
454 454
 				)
455 455
 			);
456 456
 		}
457 457
 
458
-		$info = get_file_data( $working_directory . 'style.css', array( 'Name' => 'Theme Name', 'Template' => 'Template' ) );
458
+		$info = get_file_data($working_directory.'style.css', array('Name' => 'Theme Name', 'Template' => 'Template'));
459 459
 
460
-		if ( empty( $info['Name'] ) ) {
461
-			return new WP_Error( 'incompatible_archive_theme_no_name', $this->strings['incompatible_archive'],
460
+		if (empty($info['Name'])) {
461
+			return new WP_Error('incompatible_archive_theme_no_name', $this->strings['incompatible_archive'],
462 462
 				/* translators: %s: style.css */
463
-				sprintf( __( 'The %s stylesheet doesn&#8217;t contain a valid theme header.' ),
463
+				sprintf(__('The %s stylesheet doesn&#8217;t contain a valid theme header.'),
464 464
 					'<code>style.css</code>'
465 465
 				)
466 466
 			);
467 467
 		}
468 468
 
469 469
 		// If it's not a child theme, it must have at least an index.php to be legit.
470
-		if ( empty( $info['Template'] ) && ! file_exists( $working_directory . 'index.php' ) ) {
471
-			return new WP_Error( 'incompatible_archive_theme_no_index', $this->strings['incompatible_archive'],
470
+		if (empty($info['Template']) && ! file_exists($working_directory.'index.php')) {
471
+			return new WP_Error('incompatible_archive_theme_no_index', $this->strings['incompatible_archive'],
472 472
 				/* translators: %s: index.php */
473
-				sprintf( __( 'The theme is missing the %s file.' ),
473
+				sprintf(__('The theme is missing the %s file.'),
474 474
 					'<code>index.php</code>'
475 475
 				)
476 476
 			);
@@ -493,15 +493,15 @@  discard block
 block discarded – undo
493 493
 	 * @return bool|WP_Error
494 494
 	 */
495 495
 	public function current_before($return, $theme) {
496
-		if ( is_wp_error($return) )
496
+		if (is_wp_error($return))
497 497
 			return $return;
498 498
 
499 499
 		$theme = isset($theme['theme']) ? $theme['theme'] : '';
500 500
 
501
-		if ( $theme != get_stylesheet() ) //If not current
501
+		if ($theme != get_stylesheet()) //If not current
502 502
 			return $return;
503 503
 		//Change to maintenance mode now.
504
-		if ( ! $this->bulk )
504
+		if ( ! $this->bulk)
505 505
 			$this->maintenance_mode(true);
506 506
 
507 507
 		return $return;
@@ -521,23 +521,23 @@  discard block
 block discarded – undo
521 521
 	 * @return bool|WP_Error
522 522
 	 */
523 523
 	public function current_after($return, $theme) {
524
-		if ( is_wp_error($return) )
524
+		if (is_wp_error($return))
525 525
 			return $return;
526 526
 
527 527
 		$theme = isset($theme['theme']) ? $theme['theme'] : '';
528 528
 
529
-		if ( $theme != get_stylesheet() ) // If not current
529
+		if ($theme != get_stylesheet()) // If not current
530 530
 			return $return;
531 531
 
532 532
 		// Ensure stylesheet name hasn't changed after the upgrade:
533
-		if ( $theme == get_stylesheet() && $theme != $this->result['destination_name'] ) {
533
+		if ($theme == get_stylesheet() && $theme != $this->result['destination_name']) {
534 534
 			wp_clean_themes_cache();
535 535
 			$stylesheet = $this->result['destination_name'];
536
-			switch_theme( $stylesheet );
536
+			switch_theme($stylesheet);
537 537
 		}
538 538
 
539 539
 		//Time to remove maintenance mode
540
-		if ( ! $this->bulk )
540
+		if ( ! $this->bulk)
541 541
 			$this->maintenance_mode(false);
542 542
 		return $return;
543 543
 	}
@@ -559,19 +559,19 @@  discard block
 block discarded – undo
559 559
 	 * @param array  $theme
560 560
 	 * @return bool
561 561
 	 */
562
-	public function delete_old_theme( $removed, $local_destination, $remote_destination, $theme ) {
562
+	public function delete_old_theme($removed, $local_destination, $remote_destination, $theme) {
563 563
 		global $wp_filesystem;
564 564
 
565
-		if ( is_wp_error( $removed ) )
565
+		if (is_wp_error($removed))
566 566
 			return $removed; // Pass errors through.
567 567
 
568
-		if ( ! isset( $theme['theme'] ) )
568
+		if ( ! isset($theme['theme']))
569 569
 			return $removed;
570 570
 
571 571
 		$theme = $theme['theme'];
572
-		$themes_dir = trailingslashit( $wp_filesystem->wp_themes_dir( $theme ) );
573
-		if ( $wp_filesystem->exists( $themes_dir . $theme ) ) {
574
-			if ( ! $wp_filesystem->delete( $themes_dir . $theme, true ) )
572
+		$themes_dir = trailingslashit($wp_filesystem->wp_themes_dir($theme));
573
+		if ($wp_filesystem->exists($themes_dir.$theme)) {
574
+			if ( ! $wp_filesystem->delete($themes_dir.$theme, true))
575 575
 				return false;
576 576
 		}
577 577
 
@@ -592,13 +592,13 @@  discard block
 block discarded – undo
592 592
 	 */
593 593
 	public function theme_info($theme = null) {
594 594
 
595
-		if ( empty($theme) ) {
596
-			if ( !empty($this->result['destination_name']) )
595
+		if (empty($theme)) {
596
+			if ( ! empty($this->result['destination_name']))
597 597
 				$theme = $this->result['destination_name'];
598 598
 			else
599 599
 				return false;
600 600
 		}
601
-		return wp_get_theme( $theme );
601
+		return wp_get_theme($theme);
602 602
 	}
603 603
 
604 604
 }
Please login to merge, or discard this patch.