Completed
Push — master ( d99bf9...491baf )
by Stephen
13:47
created
src/wp-includes/functions.php 5 patches
Switch Indentation   +20 added lines, -20 removed lines patch added patch discarded remove patch
@@ -2440,15 +2440,15 @@  discard block
 block discarded – undo
2440 2440
 		}
2441 2441
 		$errors = $message->get_error_messages();
2442 2442
 		switch ( count( $errors ) ) {
2443
-		case 0 :
2444
-			$message = '';
2445
-			break;
2446
-		case 1 :
2447
-			$message = "<p>{$errors[0]}</p>";
2448
-			break;
2449
-		default :
2450
-			$message = "<ul>\n\t\t<li>" . join( "</li>\n\t\t<li>", $errors ) . "</li>\n\t</ul>";
2451
-			break;
2443
+			case 0 :
2444
+				$message = '';
2445
+				break;
2446
+			case 1 :
2447
+				$message = "<p>{$errors[0]}</p>";
2448
+				break;
2449
+			default :
2450
+				$message = "<ul>\n\t\t<li>" . join( "</li>\n\t\t<li>", $errors ) . "</li>\n\t</ul>";
2451
+				break;
2452 2452
 		}
2453 2453
 	} elseif ( is_string( $message ) ) {
2454 2454
 		$message = "<p>$message</p>";
@@ -4447,17 +4447,17 @@  discard block
 block discarded – undo
4447 4447
  */
4448 4448
 function _wp_mysql_week( $column ) {
4449 4449
 	switch ( $start_of_week = (int) get_option( 'start_of_week' ) ) {
4450
-	case 1 :
4451
-		return "WEEK( $column, 1 )";
4452
-	case 2 :
4453
-	case 3 :
4454
-	case 4 :
4455
-	case 5 :
4456
-	case 6 :
4457
-		return "WEEK( DATE_SUB( $column, INTERVAL $start_of_week DAY ), 0 )";
4458
-	case 0 :
4459
-	default :
4460
-		return "WEEK( $column, 0 )";
4450
+		case 1 :
4451
+			return "WEEK( $column, 1 )";
4452
+		case 2 :
4453
+		case 3 :
4454
+		case 4 :
4455
+		case 5 :
4456
+		case 6 :
4457
+			return "WEEK( DATE_SUB( $column, INTERVAL $start_of_week DAY ), 0 )";
4458
+		case 0 :
4459
+		default :
4460
+			return "WEEK( $column, 0 )";
4461 4461
 	}
4462 4462
 }
4463 4463
 
Please login to merge, or discard this patch.
Indentation   +29 added lines, -29 removed lines patch added patch discarded remove patch
@@ -3245,7 +3245,7 @@  discard block
 block discarded – undo
3245 3245
 		  ':arrow:' => "\xe2\x9e\xa1",
3246 3246
 		  ':shock:' => "\xf0\x9f\x98\xaf",
3247 3247
 		  ':smile:' => "\xf0\x9f\x99\x82",
3248
-		    ':???:' => "\xf0\x9f\x98\x95",
3248
+			':???:' => "\xf0\x9f\x98\x95",
3249 3249
 		   ':cool:' => "\xf0\x9f\x98\x8e",
3250 3250
 		   ':evil:' => "\xf0\x9f\x91\xbf",
3251 3251
 		   ':grin:' => "\xf0\x9f\x98\x80",
@@ -3254,36 +3254,36 @@  discard block
 block discarded – undo
3254 3254
 		   ':razz:' => "\xf0\x9f\x98\x9b",
3255 3255
 		   ':roll:' => "\xf0\x9f\x99\x84",
3256 3256
 		   ':wink:' => "\xf0\x9f\x98\x89",
3257
-		    ':cry:' => "\xf0\x9f\x98\xa5",
3258
-		    ':eek:' => "\xf0\x9f\x98\xae",
3259
-		    ':lol:' => "\xf0\x9f\x98\x86",
3260
-		    ':mad:' => "\xf0\x9f\x98\xa1",
3261
-		    ':sad:' => "\xf0\x9f\x99\x81",
3262
-		      '8-)' => "\xf0\x9f\x98\x8e",
3263
-		      '8-O' => "\xf0\x9f\x98\xaf",
3264
-		      ':-(' => "\xf0\x9f\x99\x81",
3265
-		      ':-)' => "\xf0\x9f\x99\x82",
3266
-		      ':-?' => "\xf0\x9f\x98\x95",
3267
-		      ':-D' => "\xf0\x9f\x98\x80",
3268
-		      ':-P' => "\xf0\x9f\x98\x9b",
3269
-		      ':-o' => "\xf0\x9f\x98\xae",
3270
-		      ':-x' => "\xf0\x9f\x98\xa1",
3271
-		      ':-|' => "\xf0\x9f\x98\x90",
3272
-		      ';-)' => "\xf0\x9f\x98\x89",
3257
+			':cry:' => "\xf0\x9f\x98\xa5",
3258
+			':eek:' => "\xf0\x9f\x98\xae",
3259
+			':lol:' => "\xf0\x9f\x98\x86",
3260
+			':mad:' => "\xf0\x9f\x98\xa1",
3261
+			':sad:' => "\xf0\x9f\x99\x81",
3262
+			  '8-)' => "\xf0\x9f\x98\x8e",
3263
+			  '8-O' => "\xf0\x9f\x98\xaf",
3264
+			  ':-(' => "\xf0\x9f\x99\x81",
3265
+			  ':-)' => "\xf0\x9f\x99\x82",
3266
+			  ':-?' => "\xf0\x9f\x98\x95",
3267
+			  ':-D' => "\xf0\x9f\x98\x80",
3268
+			  ':-P' => "\xf0\x9f\x98\x9b",
3269
+			  ':-o' => "\xf0\x9f\x98\xae",
3270
+			  ':-x' => "\xf0\x9f\x98\xa1",
3271
+			  ':-|' => "\xf0\x9f\x98\x90",
3272
+			  ';-)' => "\xf0\x9f\x98\x89",
3273 3273
 		// This one transformation breaks regular text with frequency.
3274 3274
 		//     '8)' => "\xf0\x9f\x98\x8e",
3275
-		       '8O' => "\xf0\x9f\x98\xaf",
3276
-		       ':(' => "\xf0\x9f\x99\x81",
3277
-		       ':)' => "\xf0\x9f\x99\x82",
3278
-		       ':?' => "\xf0\x9f\x98\x95",
3279
-		       ':D' => "\xf0\x9f\x98\x80",
3280
-		       ':P' => "\xf0\x9f\x98\x9b",
3281
-		       ':o' => "\xf0\x9f\x98\xae",
3282
-		       ':x' => "\xf0\x9f\x98\xa1",
3283
-		       ':|' => "\xf0\x9f\x98\x90",
3284
-		       ';)' => "\xf0\x9f\x98\x89",
3285
-		      ':!:' => "\xe2\x9d\x97",
3286
-		      ':?:' => "\xe2\x9d\x93",
3275
+			   '8O' => "\xf0\x9f\x98\xaf",
3276
+			   ':(' => "\xf0\x9f\x99\x81",
3277
+			   ':)' => "\xf0\x9f\x99\x82",
3278
+			   ':?' => "\xf0\x9f\x98\x95",
3279
+			   ':D' => "\xf0\x9f\x98\x80",
3280
+			   ':P' => "\xf0\x9f\x98\x9b",
3281
+			   ':o' => "\xf0\x9f\x98\xae",
3282
+			   ':x' => "\xf0\x9f\x98\xa1",
3283
+			   ':|' => "\xf0\x9f\x98\x90",
3284
+			   ';)' => "\xf0\x9f\x98\x89",
3285
+			  ':!:' => "\xe2\x9d\x97",
3286
+			  ':?:' => "\xe2\x9d\x93",
3287 3287
 		);
3288 3288
 	}
3289 3289
 
Please login to merge, or discard this patch.
Doc Comments   +8 added lines, -11 removed lines patch added patch discarded remove patch
@@ -55,7 +55,7 @@  discard block
 block discarded – undo
55 55
  *
56 56
  * @param string   $type Type of time to retrieve. Accepts 'mysql', 'timestamp', or PHP date
57 57
  *                       format string (e.g. 'Y-m-d').
58
- * @param int|bool $gmt  Optional. Whether to use GMT timezone. Default false.
58
+ * @param integer $gmt  Optional. Whether to use GMT timezone. Default false.
59 59
  * @return int|string Integer if $type is 'timestamp', string otherwise.
60 60
  */
61 61
 function current_time( $type, $gmt = 0 ) {
@@ -436,7 +436,7 @@  discard block
 block discarded – undo
436 436
  * @since 2.0.5
437 437
  *
438 438
  * @param string|array|object $data Data that might be serialized.
439
- * @return mixed A scalar data
439
+ * @return string A scalar data
440 440
  */
441 441
 function maybe_serialize( $data ) {
442 442
 	if ( is_array( $data ) || is_object( $data ) )
@@ -771,9 +771,6 @@  discard block
 block discarded – undo
771 771
  *
772 772
  * @since 1.5.0
773 773
  *
774
- * @param string|array $key   Either a query variable key, or an associative array of query variables.
775
- * @param string       $value Optional. Either a query variable value, or a URL to act upon.
776
- * @param string       $url   Optional. A URL to act upon.
777 774
  * @return string New URL query string (unescaped).
778 775
  */
779 776
 function add_query_arg() {
@@ -1428,7 +1425,7 @@  discard block
 block discarded – undo
1428 1425
  * @since 2.0.4
1429 1426
  *
1430 1427
  * @param string     $actionurl URL to add nonce action.
1431
- * @param int|string $action    Optional. Nonce action name. Default -1.
1428
+ * @param integer $action    Optional. Nonce action name. Default -1.
1432 1429
  * @param string     $name      Optional. Nonce name. Default '_wpnonce'.
1433 1430
  * @return string Escaped URL with nonce action added.
1434 1431
  */
@@ -1457,7 +1454,7 @@  discard block
 block discarded – undo
1457 1454
  *
1458 1455
  * @since 2.0.4
1459 1456
  *
1460
- * @param int|string $action  Optional. Action name. Default -1.
1457
+ * @param integer $action  Optional. Action name. Default -1.
1461 1458
  * @param string     $name    Optional. Nonce name. Default '_wpnonce'.
1462 1459
  * @param bool       $referer Optional. Whether to set the referer field for validation. Default true.
1463 1460
  * @param bool       $echo    Optional. Whether to display or return hidden form field. Default true.
@@ -1549,7 +1546,7 @@  discard block
 block discarded – undo
1549 1546
  *
1550 1547
  * @since 4.5.0
1551 1548
  *
1552
- * @return string|false Referer URL on success, false on failure.
1549
+ * @return string Referer URL on success, false on failure.
1553 1550
  */
1554 1551
 function wp_get_raw_referer() {
1555 1552
 	if ( ! empty( $_REQUEST['_wp_http_referer'] ) ) {
@@ -1861,7 +1858,7 @@  discard block
 block discarded – undo
1861 1858
  * @param bool   $create_dir Optional. Whether to check and create the uploads directory.
1862 1859
  *                           Default true for backward compatibility.
1863 1860
  * @param bool   $refresh_cache Optional. Whether to refresh the cache. Default false.
1864
- * @return array See above for description.
1861
+ * @return callable|null See above for description.
1865 1862
  */
1866 1863
 function wp_upload_dir( $time = null, $create_dir = true, $refresh_cache = false ) {
1867 1864
 	static $cache = array(), $tested_paths = array();
@@ -4692,7 +4689,7 @@  discard block
 block discarded – undo
4692 4689
  *
4693 4690
  * @see __return_false()
4694 4691
  *
4695
- * @return true True.
4692
+ * @return boolean True.
4696 4693
  */
4697 4694
 function __return_true() {
4698 4695
 	return true;
@@ -4814,7 +4811,7 @@  discard block
 block discarded – undo
4814 4811
  * @param int      $start         The ID to start the loop check at.
4815 4812
  * @param int      $start_parent  The parent_ID of $start to use instead of calling $callback( $start ).
4816 4813
  *                                Use null to always use $callback
4817
- * @param array    $callback_args Optional. Additional arguments to send to $callback.
4814
+ * @param string[]    $callback_args Optional. Additional arguments to send to $callback.
4818 4815
  * @return array IDs of all members of loop.
4819 4816
  */
4820 4817
 function wp_find_hierarchy_loop( $callback, $start, $start_parent, $callback_args = array() ) {
Please login to merge, or discard this patch.
Spacing   +1058 added lines, -1058 removed lines patch added patch discarded remove patch
@@ -5,7 +5,7 @@  discard block
 block discarded – undo
5 5
  * @package WordPress
6 6
  */
7 7
 
8
-require( ABSPATH . WPINC . '/option.php' );
8
+require(ABSPATH.WPINC.'/option.php');
9 9
 
10 10
 /**
11 11
  * Convert given date string into a different format.
@@ -23,22 +23,22 @@  discard block
 block discarded – undo
23 23
  * @param bool   $translate Whether the return date should be translated. Default true.
24 24
  * @return string|int|bool Formatted date string or Unix timestamp. False if $date is empty.
25 25
  */
26
-function mysql2date( $format, $date, $translate = true ) {
27
-	if ( empty( $date ) )
26
+function mysql2date($format, $date, $translate = true) {
27
+	if (empty($date))
28 28
 		return false;
29 29
 
30
-	if ( 'G' == $format )
31
-		return strtotime( $date . ' +0000' );
30
+	if ('G' == $format)
31
+		return strtotime($date.' +0000');
32 32
 
33
-	$i = strtotime( $date );
33
+	$i = strtotime($date);
34 34
 
35
-	if ( 'U' == $format )
35
+	if ('U' == $format)
36 36
 		return $i;
37 37
 
38
-	if ( $translate )
39
-		return date_i18n( $format, $i );
38
+	if ($translate)
39
+		return date_i18n($format, $i);
40 40
 	else
41
-		return date( $format, $i );
41
+		return date($format, $i);
42 42
 }
43 43
 
44 44
 /**
@@ -58,14 +58,14 @@  discard block
 block discarded – undo
58 58
  * @param int|bool $gmt  Optional. Whether to use GMT timezone. Default false.
59 59
  * @return int|string Integer if $type is 'timestamp', string otherwise.
60 60
  */
61
-function current_time( $type, $gmt = 0 ) {
62
-	switch ( $type ) {
61
+function current_time($type, $gmt = 0) {
62
+	switch ($type) {
63 63
 		case 'mysql':
64
-			return ( $gmt ) ? gmdate( 'Y-m-d H:i:s' ) : gmdate( 'Y-m-d H:i:s', ( time() + ( get_option( 'gmt_offset' ) * HOUR_IN_SECONDS ) ) );
64
+			return ($gmt) ? gmdate('Y-m-d H:i:s') : gmdate('Y-m-d H:i:s', (time() + (get_option('gmt_offset') * HOUR_IN_SECONDS)));
65 65
 		case 'timestamp':
66
-			return ( $gmt ) ? time() : time() + ( get_option( 'gmt_offset' ) * HOUR_IN_SECONDS );
66
+			return ($gmt) ? time() : time() + (get_option('gmt_offset') * HOUR_IN_SECONDS);
67 67
 		default:
68
-			return ( $gmt ) ? date( $type ) : date( $type, time() + ( get_option( 'gmt_offset' ) * HOUR_IN_SECONDS ) );
68
+			return ($gmt) ? date($type) : date($type, time() + (get_option('gmt_offset') * HOUR_IN_SECONDS));
69 69
 	}
70 70
 }
71 71
 
@@ -86,12 +86,12 @@  discard block
 block discarded – undo
86 86
  *
87 87
  * @return string The date, translated if locale specifies it.
88 88
  */
89
-function date_i18n( $dateformatstring, $unixtimestamp = false, $gmt = false ) {
89
+function date_i18n($dateformatstring, $unixtimestamp = false, $gmt = false) {
90 90
 	global $wp_locale;
91 91
 	$i = $unixtimestamp;
92 92
 
93
-	if ( false === $i ) {
94
-		$i = current_time( 'timestamp', $gmt );
93
+	if (false === $i) {
94
+		$i = current_time('timestamp', $gmt);
95 95
 	}
96 96
 
97 97
 	/*
@@ -100,41 +100,41 @@  discard block
 block discarded – undo
100 100
 	 */
101 101
 	$req_format = $dateformatstring;
102 102
 
103
-	if ( ( !empty( $wp_locale->month ) ) && ( !empty( $wp_locale->weekday ) ) ) {
104
-		$datemonth = $wp_locale->get_month( date( 'm', $i ) );
105
-		$datemonth_abbrev = $wp_locale->get_month_abbrev( $datemonth );
106
-		$dateweekday = $wp_locale->get_weekday( date( 'w', $i ) );
107
-		$dateweekday_abbrev = $wp_locale->get_weekday_abbrev( $dateweekday );
108
-		$datemeridiem = $wp_locale->get_meridiem( date( 'a', $i ) );
109
-		$datemeridiem_capital = $wp_locale->get_meridiem( date( 'A', $i ) );
103
+	if (( ! empty($wp_locale->month)) && ( ! empty($wp_locale->weekday))) {
104
+		$datemonth = $wp_locale->get_month(date('m', $i));
105
+		$datemonth_abbrev = $wp_locale->get_month_abbrev($datemonth);
106
+		$dateweekday = $wp_locale->get_weekday(date('w', $i));
107
+		$dateweekday_abbrev = $wp_locale->get_weekday_abbrev($dateweekday);
108
+		$datemeridiem = $wp_locale->get_meridiem(date('a', $i));
109
+		$datemeridiem_capital = $wp_locale->get_meridiem(date('A', $i));
110 110
 		$dateformatstring = ' '.$dateformatstring;
111
-		$dateformatstring = preg_replace( "/([^\\\])D/", "\\1" . backslashit( $dateweekday_abbrev ), $dateformatstring );
112
-		$dateformatstring = preg_replace( "/([^\\\])F/", "\\1" . backslashit( $datemonth ), $dateformatstring );
113
-		$dateformatstring = preg_replace( "/([^\\\])l/", "\\1" . backslashit( $dateweekday ), $dateformatstring );
114
-		$dateformatstring = preg_replace( "/([^\\\])M/", "\\1" . backslashit( $datemonth_abbrev ), $dateformatstring );
115
-		$dateformatstring = preg_replace( "/([^\\\])a/", "\\1" . backslashit( $datemeridiem ), $dateformatstring );
116
-		$dateformatstring = preg_replace( "/([^\\\])A/", "\\1" . backslashit( $datemeridiem_capital ), $dateformatstring );
117
-
118
-		$dateformatstring = substr( $dateformatstring, 1, strlen( $dateformatstring ) -1 );
119
-	}
120
-	$timezone_formats = array( 'P', 'I', 'O', 'T', 'Z', 'e' );
121
-	$timezone_formats_re = implode( '|', $timezone_formats );
122
-	if ( preg_match( "/$timezone_formats_re/", $dateformatstring ) ) {
123
-		$timezone_string = get_option( 'timezone_string' );
124
-		if ( $timezone_string ) {
125
-			$timezone_object = timezone_open( $timezone_string );
126
-			$date_object = date_create( null, $timezone_object );
127
-			foreach ( $timezone_formats as $timezone_format ) {
128
-				if ( false !== strpos( $dateformatstring, $timezone_format ) ) {
129
-					$formatted = date_format( $date_object, $timezone_format );
111
+		$dateformatstring = preg_replace("/([^\\\])D/", "\\1".backslashit($dateweekday_abbrev), $dateformatstring);
112
+		$dateformatstring = preg_replace("/([^\\\])F/", "\\1".backslashit($datemonth), $dateformatstring);
113
+		$dateformatstring = preg_replace("/([^\\\])l/", "\\1".backslashit($dateweekday), $dateformatstring);
114
+		$dateformatstring = preg_replace("/([^\\\])M/", "\\1".backslashit($datemonth_abbrev), $dateformatstring);
115
+		$dateformatstring = preg_replace("/([^\\\])a/", "\\1".backslashit($datemeridiem), $dateformatstring);
116
+		$dateformatstring = preg_replace("/([^\\\])A/", "\\1".backslashit($datemeridiem_capital), $dateformatstring);
117
+
118
+		$dateformatstring = substr($dateformatstring, 1, strlen($dateformatstring) - 1);
119
+	}
120
+	$timezone_formats = array('P', 'I', 'O', 'T', 'Z', 'e');
121
+	$timezone_formats_re = implode('|', $timezone_formats);
122
+	if (preg_match("/$timezone_formats_re/", $dateformatstring)) {
123
+		$timezone_string = get_option('timezone_string');
124
+		if ($timezone_string) {
125
+			$timezone_object = timezone_open($timezone_string);
126
+			$date_object = date_create(null, $timezone_object);
127
+			foreach ($timezone_formats as $timezone_format) {
128
+				if (false !== strpos($dateformatstring, $timezone_format)) {
129
+					$formatted = date_format($date_object, $timezone_format);
130 130
 					$dateformatstring = ' '.$dateformatstring;
131
-					$dateformatstring = preg_replace( "/([^\\\])$timezone_format/", "\\1" . backslashit( $formatted ), $dateformatstring );
132
-					$dateformatstring = substr( $dateformatstring, 1, strlen( $dateformatstring ) -1 );
131
+					$dateformatstring = preg_replace("/([^\\\])$timezone_format/", "\\1".backslashit($formatted), $dateformatstring);
132
+					$dateformatstring = substr($dateformatstring, 1, strlen($dateformatstring) - 1);
133 133
 				}
134 134
 			}
135 135
 		}
136 136
 	}
137
-	$j = @date( $dateformatstring, $i );
137
+	$j = @date($dateformatstring, $i);
138 138
 
139 139
 	/**
140 140
 	 * Filters the date formatted based on the locale.
@@ -146,7 +146,7 @@  discard block
 block discarded – undo
146 146
 	 * @param int    $i          Unix timestamp.
147 147
 	 * @param bool   $gmt        Whether to convert to GMT for time. Default false.
148 148
 	 */
149
-	$j = apply_filters( 'date_i18n', $j, $req_format, $i, $gmt );
149
+	$j = apply_filters('date_i18n', $j, $req_format, $i, $gmt);
150 150
 	return $j;
151 151
 }
152 152
 
@@ -163,41 +163,41 @@  discard block
 block discarded – undo
163 163
  * @param string $date Formatted date string.
164 164
  * @return string The date, declined if locale specifies it.
165 165
  */
166
-function wp_maybe_decline_date( $date ) {
166
+function wp_maybe_decline_date($date) {
167 167
 	global $wp_locale;
168 168
 
169 169
 	// i18n functions are not available in SHORTINIT mode
170
-	if ( ! function_exists( '_x' ) ) {
170
+	if ( ! function_exists('_x')) {
171 171
 		return $date;
172 172
 	}
173 173
 
174 174
 	/* translators: If months in your language require a genitive case,
175 175
 	 * translate this to 'on'. Do not translate into your own language.
176 176
 	 */
177
-	if ( 'on' === _x( 'off', 'decline months names: on or off' ) ) {
177
+	if ('on' === _x('off', 'decline months names: on or off')) {
178 178
 		// Match a format like 'j F Y' or 'j. F'
179
-		if ( @preg_match( '#^\d{1,2}\.? [^\d ]+#u', $date ) ) {
179
+		if (@preg_match('#^\d{1,2}\.? [^\d ]+#u', $date)) {
180 180
 			$months          = $wp_locale->month;
181 181
 			$months_genitive = $wp_locale->month_genitive;
182 182
 
183
-			foreach ( $months as $key => $month ) {
184
-				$months[ $key ] = '# ' . $month . '( |$)#u';
183
+			foreach ($months as $key => $month) {
184
+				$months[$key] = '# '.$month.'( |$)#u';
185 185
 			}
186 186
 
187
-			foreach ( $months_genitive as $key => $month ) {
188
-				$months_genitive[ $key ] = ' ' . $month . '$1';
187
+			foreach ($months_genitive as $key => $month) {
188
+				$months_genitive[$key] = ' '.$month.'$1';
189 189
 			}
190 190
 
191
-			$date = preg_replace( $months, $months_genitive, $date );
191
+			$date = preg_replace($months, $months_genitive, $date);
192 192
 		}
193 193
 	}
194 194
 
195 195
 	// Used for locale-specific rules
196 196
 	$locale = get_locale();
197 197
 
198
-	if ( 'ca' === $locale ) {
198
+	if ('ca' === $locale) {
199 199
 		// " de abril| de agost| de octubre..." -> " d'abril| d'agost| d'octubre..."
200
-		$date = preg_replace( '# de ([ao])#i', " d'\\1", $date );
200
+		$date = preg_replace('# de ([ao])#i', " d'\\1", $date);
201 201
 	}
202 202
 
203 203
 	return $date;
@@ -214,13 +214,13 @@  discard block
 block discarded – undo
214 214
  * @param int   $decimals Optional. Precision of the number of decimal places. Default 0.
215 215
  * @return string Converted number in string format.
216 216
  */
217
-function number_format_i18n( $number, $decimals = 0 ) {
217
+function number_format_i18n($number, $decimals = 0) {
218 218
 	global $wp_locale;
219 219
 
220
-	if ( isset( $wp_locale ) ) {
221
-		$formatted = number_format( $number, absint( $decimals ), $wp_locale->number_format['decimal_point'], $wp_locale->number_format['thousands_sep'] );
220
+	if (isset($wp_locale)) {
221
+		$formatted = number_format($number, absint($decimals), $wp_locale->number_format['decimal_point'], $wp_locale->number_format['thousands_sep']);
222 222
 	} else {
223
-		$formatted = number_format( $number, absint( $decimals ) );
223
+		$formatted = number_format($number, absint($decimals));
224 224
 	}
225 225
 
226 226
 	/**
@@ -230,7 +230,7 @@  discard block
 block discarded – undo
230 230
 	 *
231 231
 	 * @param string $formatted Converted number in string format.
232 232
 	 */
233
-	return apply_filters( 'number_format_i18n', $formatted );
233
+	return apply_filters('number_format_i18n', $formatted);
234 234
 }
235 235
 
236 236
 /**
@@ -253,7 +253,7 @@  discard block
 block discarded – undo
253 253
  * @param int        $decimals Optional. Precision of number of decimal places. Default 0.
254 254
  * @return string|false False on failure. Number string on success.
255 255
  */
256
-function size_format( $bytes, $decimals = 0 ) {
256
+function size_format($bytes, $decimals = 0) {
257 257
 	$quant = array(
258 258
 		'TB' => TB_IN_BYTES,
259 259
 		'GB' => GB_IN_BYTES,
@@ -262,13 +262,13 @@  discard block
 block discarded – undo
262 262
 		'B'  => 1,
263 263
 	);
264 264
 
265
-	if ( 0 === $bytes ) {
266
-		return number_format_i18n( 0, $decimals ) . ' B';
265
+	if (0 === $bytes) {
266
+		return number_format_i18n(0, $decimals).' B';
267 267
 	}
268 268
 
269
-	foreach ( $quant as $unit => $mag ) {
270
-		if ( doubleval( $bytes ) >= $mag ) {
271
-			return number_format_i18n( $bytes / $mag, $decimals ) . ' ' . $unit;
269
+	foreach ($quant as $unit => $mag) {
270
+		if (doubleval($bytes) >= $mag) {
271
+			return number_format_i18n($bytes / $mag, $decimals).' '.$unit;
272 272
 		}
273 273
 	}
274 274
 
@@ -284,34 +284,34 @@  discard block
 block discarded – undo
284 284
  * @param int|string $start_of_week Optional. Start of the week as an integer. Default empty string.
285 285
  * @return array Keys are 'start' and 'end'.
286 286
  */
287
-function get_weekstartend( $mysqlstring, $start_of_week = '' ) {
287
+function get_weekstartend($mysqlstring, $start_of_week = '') {
288 288
 	// MySQL string year.
289
-	$my = substr( $mysqlstring, 0, 4 );
289
+	$my = substr($mysqlstring, 0, 4);
290 290
 
291 291
 	// MySQL string month.
292
-	$mm = substr( $mysqlstring, 8, 2 );
292
+	$mm = substr($mysqlstring, 8, 2);
293 293
 
294 294
 	// MySQL string day.
295
-	$md = substr( $mysqlstring, 5, 2 );
295
+	$md = substr($mysqlstring, 5, 2);
296 296
 
297 297
 	// The timestamp for MySQL string day.
298
-	$day = mktime( 0, 0, 0, $md, $mm, $my );
298
+	$day = mktime(0, 0, 0, $md, $mm, $my);
299 299
 
300 300
 	// The day of the week from the timestamp.
301
-	$weekday = date( 'w', $day );
301
+	$weekday = date('w', $day);
302 302
 
303
-	if ( !is_numeric($start_of_week) )
304
-		$start_of_week = get_option( 'start_of_week' );
303
+	if ( ! is_numeric($start_of_week))
304
+		$start_of_week = get_option('start_of_week');
305 305
 
306
-	if ( $weekday < $start_of_week )
306
+	if ($weekday < $start_of_week)
307 307
 		$weekday += 7;
308 308
 
309 309
 	// The most recent week start day on or before $day.
310
-	$start = $day - DAY_IN_SECONDS * ( $weekday - $start_of_week );
310
+	$start = $day - DAY_IN_SECONDS * ($weekday - $start_of_week);
311 311
 
312 312
 	// $start + 1 week - 1 second.
313 313
 	$end = $start + WEEK_IN_SECONDS - 1;
314
-	return compact( 'start', 'end' );
314
+	return compact('start', 'end');
315 315
 }
316 316
 
317 317
 /**
@@ -322,9 +322,9 @@  discard block
 block discarded – undo
322 322
  * @param string $original Maybe unserialized original, if is needed.
323 323
  * @return mixed Unserialized data can be any type.
324 324
  */
325
-function maybe_unserialize( $original ) {
326
-	if ( is_serialized( $original ) ) // don't attempt to unserialize data that wasn't serialized going in
327
-		return @unserialize( $original );
325
+function maybe_unserialize($original) {
326
+	if (is_serialized($original)) // don't attempt to unserialize data that wasn't serialized going in
327
+		return @unserialize($original);
328 328
 	return $original;
329 329
 }
330 330
 
@@ -340,57 +340,57 @@  discard block
 block discarded – undo
340 340
  * @param bool   $strict Optional. Whether to be strict about the end of the string. Default true.
341 341
  * @return bool False if not serialized and true if it was.
342 342
  */
343
-function is_serialized( $data, $strict = true ) {
343
+function is_serialized($data, $strict = true) {
344 344
 	// if it isn't a string, it isn't serialized.
345
-	if ( ! is_string( $data ) ) {
345
+	if ( ! is_string($data)) {
346 346
 		return false;
347 347
 	}
348
-	$data = trim( $data );
349
- 	if ( 'N;' == $data ) {
348
+	$data = trim($data);
349
+ 	if ('N;' == $data) {
350 350
 		return true;
351 351
 	}
352
-	if ( strlen( $data ) < 4 ) {
352
+	if (strlen($data) < 4) {
353 353
 		return false;
354 354
 	}
355
-	if ( ':' !== $data[1] ) {
355
+	if (':' !== $data[1]) {
356 356
 		return false;
357 357
 	}
358
-	if ( $strict ) {
359
-		$lastc = substr( $data, -1 );
360
-		if ( ';' !== $lastc && '}' !== $lastc ) {
358
+	if ($strict) {
359
+		$lastc = substr($data, -1);
360
+		if (';' !== $lastc && '}' !== $lastc) {
361 361
 			return false;
362 362
 		}
363 363
 	} else {
364
-		$semicolon = strpos( $data, ';' );
365
-		$brace     = strpos( $data, '}' );
364
+		$semicolon = strpos($data, ';');
365
+		$brace     = strpos($data, '}');
366 366
 		// Either ; or } must exist.
367
-		if ( false === $semicolon && false === $brace )
367
+		if (false === $semicolon && false === $brace)
368 368
 			return false;
369 369
 		// But neither must be in the first X characters.
370
-		if ( false !== $semicolon && $semicolon < 3 )
370
+		if (false !== $semicolon && $semicolon < 3)
371 371
 			return false;
372
-		if ( false !== $brace && $brace < 4 )
372
+		if (false !== $brace && $brace < 4)
373 373
 			return false;
374 374
 	}
375 375
 	$token = $data[0];
376
-	switch ( $token ) {
376
+	switch ($token) {
377 377
 		case 's' :
378
-			if ( $strict ) {
379
-				if ( '"' !== substr( $data, -2, 1 ) ) {
378
+			if ($strict) {
379
+				if ('"' !== substr($data, -2, 1)) {
380 380
 					return false;
381 381
 				}
382
-			} elseif ( false === strpos( $data, '"' ) ) {
382
+			} elseif (false === strpos($data, '"')) {
383 383
 				return false;
384 384
 			}
385 385
 			// or else fall through
386 386
 		case 'a' :
387 387
 		case 'O' :
388
-			return (bool) preg_match( "/^{$token}:[0-9]+:/s", $data );
388
+			return (bool) preg_match("/^{$token}:[0-9]+:/s", $data);
389 389
 		case 'b' :
390 390
 		case 'i' :
391 391
 		case 'd' :
392 392
 			$end = $strict ? '$' : '';
393
-			return (bool) preg_match( "/^{$token}:[0-9.E-]+;$end/", $data );
393
+			return (bool) preg_match("/^{$token}:[0-9.E-]+;$end/", $data);
394 394
 	}
395 395
 	return false;
396 396
 }
@@ -403,21 +403,21 @@  discard block
 block discarded – undo
403 403
  * @param string $data Serialized data.
404 404
  * @return bool False if not a serialized string, true if it is.
405 405
  */
406
-function is_serialized_string( $data ) {
406
+function is_serialized_string($data) {
407 407
 	// if it isn't a string, it isn't a serialized string.
408
-	if ( ! is_string( $data ) ) {
408
+	if ( ! is_string($data)) {
409 409
 		return false;
410 410
 	}
411
-	$data = trim( $data );
412
-	if ( strlen( $data ) < 4 ) {
411
+	$data = trim($data);
412
+	if (strlen($data) < 4) {
413 413
 		return false;
414
-	} elseif ( ':' !== $data[1] ) {
414
+	} elseif (':' !== $data[1]) {
415 415
 		return false;
416
-	} elseif ( ';' !== substr( $data, -1 ) ) {
416
+	} elseif (';' !== substr($data, -1)) {
417 417
 		return false;
418
-	} elseif ( $data[0] !== 's' ) {
418
+	} elseif ($data[0] !== 's') {
419 419
 		return false;
420
-	} elseif ( '"' !== substr( $data, -2, 1 ) ) {
420
+	} elseif ('"' !== substr($data, -2, 1)) {
421 421
 		return false;
422 422
 	} else {
423 423
 		return true;
@@ -432,15 +432,15 @@  discard block
 block discarded – undo
432 432
  * @param string|array|object $data Data that might be serialized.
433 433
  * @return mixed A scalar data
434 434
  */
435
-function maybe_serialize( $data ) {
436
-	if ( is_array( $data ) || is_object( $data ) )
437
-		return serialize( $data );
435
+function maybe_serialize($data) {
436
+	if (is_array($data) || is_object($data))
437
+		return serialize($data);
438 438
 
439 439
 	// Double serialization is required for backward compatibility.
440 440
 	// See https://core.trac.wordpress.org/ticket/12930
441 441
 	// Also the world will end. See WP 3.6.1.
442
-	if ( is_serialized( $data, false ) )
443
-		return serialize( $data );
442
+	if (is_serialized($data, false))
443
+		return serialize($data);
444 444
 
445 445
 	return $data;
446 446
 }
@@ -458,9 +458,9 @@  discard block
 block discarded – undo
458 458
  * @param string $content XMLRPC XML Request content
459 459
  * @return string Post title
460 460
  */
461
-function xmlrpc_getposttitle( $content ) {
461
+function xmlrpc_getposttitle($content) {
462 462
 	global $post_default_title;
463
-	if ( preg_match( '/<title>(.+?)<\/title>/is', $content, $matchtitle ) ) {
463
+	if (preg_match('/<title>(.+?)<\/title>/is', $content, $matchtitle)) {
464 464
 		$post_title = $matchtitle[1];
465 465
 	} else {
466 466
 		$post_title = $post_default_title;
@@ -482,11 +482,11 @@  discard block
 block discarded – undo
482 482
  * @param string $content XMLRPC XML Request content
483 483
  * @return string|array List of categories or category name.
484 484
  */
485
-function xmlrpc_getpostcategory( $content ) {
485
+function xmlrpc_getpostcategory($content) {
486 486
 	global $post_default_category;
487
-	if ( preg_match( '/<category>(.+?)<\/category>/is', $content, $matchcat ) ) {
488
-		$post_category = trim( $matchcat[1], ',' );
489
-		$post_category = explode( ',', $post_category );
487
+	if (preg_match('/<category>(.+?)<\/category>/is', $content, $matchcat)) {
488
+		$post_category = trim($matchcat[1], ',');
489
+		$post_category = explode(',', $post_category);
490 490
 	} else {
491 491
 		$post_category = $post_default_category;
492 492
 	}
@@ -501,10 +501,10 @@  discard block
 block discarded – undo
501 501
  * @param string $content XML-RPC XML Request content.
502 502
  * @return string XMLRPC XML Request content without title and category elements.
503 503
  */
504
-function xmlrpc_removepostdata( $content ) {
505
-	$content = preg_replace( '/<title>(.+?)<\/title>/si', '', $content );
506
-	$content = preg_replace( '/<category>(.+?)<\/category>/si', '', $content );
507
-	$content = trim( $content );
504
+function xmlrpc_removepostdata($content) {
505
+	$content = preg_replace('/<title>(.+?)<\/title>/si', '', $content);
506
+	$content = preg_replace('/<category>(.+?)<\/category>/si', '', $content);
507
+	$content = trim($content);
508 508
 	return $content;
509 509
 }
510 510
 
@@ -516,7 +516,7 @@  discard block
 block discarded – undo
516 516
  * @param string $content Content to extract URLs from.
517 517
  * @return array URLs found in passed string.
518 518
  */
519
-function wp_extract_urls( $content ) {
519
+function wp_extract_urls($content) {
520 520
 	preg_match_all(
521 521
 		"#([\"']?)("
522 522
 			. "(?:([\w-]+:)?//?)"
@@ -534,9 +534,9 @@  discard block
 block discarded – undo
534 534
 		$post_links
535 535
 	);
536 536
 
537
-	$post_links = array_unique( array_map( 'html_entity_decode', $post_links[2] ) );
537
+	$post_links = array_unique(array_map('html_entity_decode', $post_links[2]));
538 538
 
539
-	return array_values( $post_links );
539
+	return array_values($post_links);
540 540
 }
541 541
 
542 542
 /**
@@ -553,34 +553,34 @@  discard block
 block discarded – undo
553 553
  * @param string $content Post Content.
554 554
  * @param int    $post_ID Post ID.
555 555
  */
556
-function do_enclose( $content, $post_ID ) {
556
+function do_enclose($content, $post_ID) {
557 557
 	global $wpdb;
558 558
 
559 559
 	//TODO: Tidy this ghetto code up and make the debug code optional
560
-	include_once( ABSPATH . WPINC . '/class-IXR.php' );
560
+	include_once(ABSPATH.WPINC.'/class-IXR.php');
561 561
 
562 562
 	$post_links = array();
563 563
 
564
-	$pung = get_enclosed( $post_ID );
564
+	$pung = get_enclosed($post_ID);
565 565
 
566
-	$post_links_temp = wp_extract_urls( $content );
566
+	$post_links_temp = wp_extract_urls($content);
567 567
 
568
-	foreach ( $pung as $link_test ) {
569
-		if ( ! in_array( $link_test, $post_links_temp ) ) { // link no longer in post
570
-			$mids = $wpdb->get_col( $wpdb->prepare("SELECT meta_id FROM $wpdb->postmeta WHERE post_id = %d AND meta_key = 'enclosure' AND meta_value LIKE %s", $post_ID, $wpdb->esc_like( $link_test ) . '%') );
571
-			foreach ( $mids as $mid )
572
-				delete_metadata_by_mid( 'post', $mid );
568
+	foreach ($pung as $link_test) {
569
+		if ( ! in_array($link_test, $post_links_temp)) { // link no longer in post
570
+			$mids = $wpdb->get_col($wpdb->prepare("SELECT meta_id FROM $wpdb->postmeta WHERE post_id = %d AND meta_key = 'enclosure' AND meta_value LIKE %s", $post_ID, $wpdb->esc_like($link_test).'%'));
571
+			foreach ($mids as $mid)
572
+				delete_metadata_by_mid('post', $mid);
573 573
 		}
574 574
 	}
575 575
 
576
-	foreach ( (array) $post_links_temp as $link_test ) {
577
-		if ( !in_array( $link_test, $pung ) ) { // If we haven't pung it already
578
-			$test = @parse_url( $link_test );
579
-			if ( false === $test )
576
+	foreach ((array) $post_links_temp as $link_test) {
577
+		if ( ! in_array($link_test, $pung)) { // If we haven't pung it already
578
+			$test = @parse_url($link_test);
579
+			if (false === $test)
580 580
 				continue;
581
-			if ( isset( $test['query'] ) )
581
+			if (isset($test['query']))
582 582
 				$post_links[] = $link_test;
583
-			elseif ( isset($test['path']) && ( $test['path'] != '/' ) &&  ($test['path'] != '' ) )
583
+			elseif (isset($test['path']) && ($test['path'] != '/') && ($test['path'] != ''))
584 584
 				$post_links[] = $link_test;
585 585
 		}
586 586
 	}
@@ -596,24 +596,24 @@  discard block
 block discarded – undo
596 596
 	 * @param array $post_links An array of enclosure links.
597 597
 	 * @param int   $post_ID    Post ID.
598 598
 	 */
599
-	$post_links = apply_filters( 'enclosure_links', $post_links, $post_ID );
599
+	$post_links = apply_filters('enclosure_links', $post_links, $post_ID);
600 600
 
601
-	foreach ( (array) $post_links as $url ) {
602
-		if ( $url != '' && !$wpdb->get_var( $wpdb->prepare( "SELECT post_id FROM $wpdb->postmeta WHERE post_id = %d AND meta_key = 'enclosure' AND meta_value LIKE %s", $post_ID, $wpdb->esc_like( $url ) . '%' ) ) ) {
601
+	foreach ((array) $post_links as $url) {
602
+		if ($url != '' && ! $wpdb->get_var($wpdb->prepare("SELECT post_id FROM $wpdb->postmeta WHERE post_id = %d AND meta_key = 'enclosure' AND meta_value LIKE %s", $post_ID, $wpdb->esc_like($url).'%'))) {
603 603
 
604
-			if ( $headers = wp_get_http_headers( $url) ) {
605
-				$len = isset( $headers['content-length'] ) ? (int) $headers['content-length'] : 0;
606
-				$type = isset( $headers['content-type'] ) ? $headers['content-type'] : '';
607
-				$allowed_types = array( 'video', 'audio' );
604
+			if ($headers = wp_get_http_headers($url)) {
605
+				$len = isset($headers['content-length']) ? (int) $headers['content-length'] : 0;
606
+				$type = isset($headers['content-type']) ? $headers['content-type'] : '';
607
+				$allowed_types = array('video', 'audio');
608 608
 
609 609
 				// Check to see if we can figure out the mime type from
610 610
 				// the extension
611
-				$url_parts = @parse_url( $url );
612
-				if ( false !== $url_parts ) {
613
-					$extension = pathinfo( $url_parts['path'], PATHINFO_EXTENSION );
614
-					if ( !empty( $extension ) ) {
615
-						foreach ( wp_get_mime_types() as $exts => $mime ) {
616
-							if ( preg_match( '!^(' . $exts . ')$!i', $extension ) ) {
611
+				$url_parts = @parse_url($url);
612
+				if (false !== $url_parts) {
613
+					$extension = pathinfo($url_parts['path'], PATHINFO_EXTENSION);
614
+					if ( ! empty($extension)) {
615
+						foreach (wp_get_mime_types() as $exts => $mime) {
616
+							if (preg_match('!^('.$exts.')$!i', $extension)) {
617 617
 								$type = $mime;
618 618
 								break;
619 619
 							}
@@ -621,8 +621,8 @@  discard block
 block discarded – undo
621 621
 					}
622 622
 				}
623 623
 
624
-				if ( in_array( substr( $type, 0, strpos( $type, "/" ) ), $allowed_types ) ) {
625
-					add_post_meta( $post_ID, 'enclosure', "$url\n$len\n$mime\n" );
624
+				if (in_array(substr($type, 0, strpos($type, "/")), $allowed_types)) {
625
+					add_post_meta($post_ID, 'enclosure', "$url\n$len\n$mime\n");
626 626
 				}
627 627
 			}
628 628
 		}
@@ -638,16 +638,16 @@  discard block
 block discarded – undo
638 638
  * @param bool   $deprecated Not Used.
639 639
  * @return bool|string False on failure, headers on success.
640 640
  */
641
-function wp_get_http_headers( $url, $deprecated = false ) {
642
-	if ( !empty( $deprecated ) )
643
-		_deprecated_argument( __FUNCTION__, '2.7.0' );
641
+function wp_get_http_headers($url, $deprecated = false) {
642
+	if ( ! empty($deprecated))
643
+		_deprecated_argument(__FUNCTION__, '2.7.0');
644 644
 
645
-	$response = wp_safe_remote_head( $url );
645
+	$response = wp_safe_remote_head($url);
646 646
 
647
-	if ( is_wp_error( $response ) )
647
+	if (is_wp_error($response))
648 648
 		return false;
649 649
 
650
-	return wp_remote_retrieve_headers( $response );
650
+	return wp_remote_retrieve_headers($response);
651 651
 }
652 652
 
653 653
 /**
@@ -663,7 +663,7 @@  discard block
 block discarded – undo
663 663
  */
664 664
 function is_new_day() {
665 665
 	global $currentday, $previousday;
666
-	if ( $currentday != $previousday )
666
+	if ($currentday != $previousday)
667 667
 		return 1;
668 668
 	else
669 669
 		return 0;
@@ -684,8 +684,8 @@  discard block
 block discarded – undo
684 684
  * @param array $data URL-encode key/value pairs.
685 685
  * @return string URL-encoded string.
686 686
  */
687
-function build_query( $data ) {
688
-	return _http_build_query( $data, null, '&', '', false );
687
+function build_query($data) {
688
+	return _http_build_query($data, null, '&', '', false);
689 689
 }
690 690
 
691 691
 /**
@@ -706,30 +706,30 @@  discard block
 block discarded – undo
706 706
  *
707 707
  * @return string The query string.
708 708
  */
709
-function _http_build_query( $data, $prefix = null, $sep = null, $key = '', $urlencode = true ) {
709
+function _http_build_query($data, $prefix = null, $sep = null, $key = '', $urlencode = true) {
710 710
 	$ret = array();
711 711
 
712
-	foreach ( (array) $data as $k => $v ) {
713
-		if ( $urlencode)
712
+	foreach ((array) $data as $k => $v) {
713
+		if ($urlencode)
714 714
 			$k = urlencode($k);
715
-		if ( is_int($k) && $prefix != null )
715
+		if (is_int($k) && $prefix != null)
716 716
 			$k = $prefix.$k;
717
-		if ( !empty($key) )
718
-			$k = $key . '%5B' . $k . '%5D';
719
-		if ( $v === null )
717
+		if ( ! empty($key))
718
+			$k = $key.'%5B'.$k.'%5D';
719
+		if ($v === null)
720 720
 			continue;
721
-		elseif ( $v === false )
721
+		elseif ($v === false)
722 722
 			$v = '0';
723 723
 
724
-		if ( is_array($v) || is_object($v) )
725
-			array_push($ret,_http_build_query($v, '', $sep, $k, $urlencode));
726
-		elseif ( $urlencode )
724
+		if (is_array($v) || is_object($v))
725
+			array_push($ret, _http_build_query($v, '', $sep, $k, $urlencode));
726
+		elseif ($urlencode)
727 727
 			array_push($ret, $k.'='.urlencode($v));
728 728
 		else
729 729
 			array_push($ret, $k.'='.$v);
730 730
 	}
731 731
 
732
-	if ( null === $sep )
732
+	if (null === $sep)
733 733
 		$sep = ini_get('arg_separator.output');
734 734
 
735 735
 	return implode($sep, $ret);
@@ -772,64 +772,64 @@  discard block
 block discarded – undo
772 772
  */
773 773
 function add_query_arg() {
774 774
 	$args = func_get_args();
775
-	if ( is_array( $args[0] ) ) {
776
-		if ( count( $args ) < 2 || false === $args[1] )
775
+	if (is_array($args[0])) {
776
+		if (count($args) < 2 || false === $args[1])
777 777
 			$uri = $_SERVER['REQUEST_URI'];
778 778
 		else
779 779
 			$uri = $args[1];
780 780
 	} else {
781
-		if ( count( $args ) < 3 || false === $args[2] )
781
+		if (count($args) < 3 || false === $args[2])
782 782
 			$uri = $_SERVER['REQUEST_URI'];
783 783
 		else
784 784
 			$uri = $args[2];
785 785
 	}
786 786
 
787
-	if ( $frag = strstr( $uri, '#' ) )
788
-		$uri = substr( $uri, 0, -strlen( $frag ) );
787
+	if ($frag = strstr($uri, '#'))
788
+		$uri = substr($uri, 0, -strlen($frag));
789 789
 	else
790 790
 		$frag = '';
791 791
 
792
-	if ( 0 === stripos( $uri, 'http://' ) ) {
792
+	if (0 === stripos($uri, 'http://')) {
793 793
 		$protocol = 'http://';
794
-		$uri = substr( $uri, 7 );
795
-	} elseif ( 0 === stripos( $uri, 'https://' ) ) {
794
+		$uri = substr($uri, 7);
795
+	} elseif (0 === stripos($uri, 'https://')) {
796 796
 		$protocol = 'https://';
797
-		$uri = substr( $uri, 8 );
797
+		$uri = substr($uri, 8);
798 798
 	} else {
799 799
 		$protocol = '';
800 800
 	}
801 801
 
802
-	if ( strpos( $uri, '?' ) !== false ) {
803
-		list( $base, $query ) = explode( '?', $uri, 2 );
802
+	if (strpos($uri, '?') !== false) {
803
+		list($base, $query) = explode('?', $uri, 2);
804 804
 		$base .= '?';
805
-	} elseif ( $protocol || strpos( $uri, '=' ) === false ) {
806
-		$base = $uri . '?';
805
+	} elseif ($protocol || strpos($uri, '=') === false) {
806
+		$base = $uri.'?';
807 807
 		$query = '';
808 808
 	} else {
809 809
 		$base = '';
810 810
 		$query = $uri;
811 811
 	}
812 812
 
813
-	wp_parse_str( $query, $qs );
814
-	$qs = urlencode_deep( $qs ); // this re-URL-encodes things that were already in the query string
815
-	if ( is_array( $args[0] ) ) {
816
-		foreach ( $args[0] as $k => $v ) {
817
-			$qs[ $k ] = $v;
813
+	wp_parse_str($query, $qs);
814
+	$qs = urlencode_deep($qs); // this re-URL-encodes things that were already in the query string
815
+	if (is_array($args[0])) {
816
+		foreach ($args[0] as $k => $v) {
817
+			$qs[$k] = $v;
818 818
 		}
819 819
 	} else {
820
-		$qs[ $args[0] ] = $args[1];
820
+		$qs[$args[0]] = $args[1];
821 821
 	}
822 822
 
823
-	foreach ( $qs as $k => $v ) {
824
-		if ( $v === false )
825
-			unset( $qs[$k] );
823
+	foreach ($qs as $k => $v) {
824
+		if ($v === false)
825
+			unset($qs[$k]);
826 826
 	}
827 827
 
828
-	$ret = build_query( $qs );
829
-	$ret = trim( $ret, '?' );
830
-	$ret = preg_replace( '#=(&|$)#', '$1', $ret );
831
-	$ret = $protocol . $base . $ret . $frag;
832
-	$ret = rtrim( $ret, '?' );
828
+	$ret = build_query($qs);
829
+	$ret = trim($ret, '?');
830
+	$ret = preg_replace('#=(&|$)#', '$1', $ret);
831
+	$ret = $protocol.$base.$ret.$frag;
832
+	$ret = rtrim($ret, '?');
833 833
 	return $ret;
834 834
 }
835 835
 
@@ -842,13 +842,13 @@  discard block
 block discarded – undo
842 842
  * @param bool|string  $query Optional. When false uses the current URL. Default false.
843 843
  * @return string New URL query string.
844 844
  */
845
-function remove_query_arg( $key, $query = false ) {
846
-	if ( is_array( $key ) ) { // removing multiple keys
847
-		foreach ( $key as $k )
848
-			$query = add_query_arg( $k, false, $query );
845
+function remove_query_arg($key, $query = false) {
846
+	if (is_array($key)) { // removing multiple keys
847
+		foreach ($key as $k)
848
+			$query = add_query_arg($k, false, $query);
849 849
 		return $query;
850 850
 	}
851
-	return add_query_arg( $key, false, $query );
851
+	return add_query_arg($key, false, $query);
852 852
 }
853 853
 
854 854
 /**
@@ -892,7 +892,7 @@  discard block
 block discarded – undo
892 892
 	 *
893 893
 	 * @param array $removable_query_args An array of query variables to remove from a URL.
894 894
 	 */
895
-	return apply_filters( 'removable_query_args', $removable_query_args );
895
+	return apply_filters('removable_query_args', $removable_query_args);
896 896
 }
897 897
 
898 898
 /**
@@ -903,12 +903,12 @@  discard block
 block discarded – undo
903 903
  * @param array $array Array to walk while sanitizing contents.
904 904
  * @return array Sanitized $array.
905 905
  */
906
-function add_magic_quotes( $array ) {
907
-	foreach ( (array) $array as $k => $v ) {
908
-		if ( is_array( $v ) ) {
909
-			$array[$k] = add_magic_quotes( $v );
906
+function add_magic_quotes($array) {
907
+	foreach ((array) $array as $k => $v) {
908
+		if (is_array($v)) {
909
+			$array[$k] = add_magic_quotes($v);
910 910
 		} else {
911
-			$array[$k] = addslashes( $v );
911
+			$array[$k] = addslashes($v);
912 912
 		}
913 913
 	}
914 914
 	return $array;
@@ -924,21 +924,21 @@  discard block
 block discarded – undo
924 924
  * @param string $uri URI/URL of web page to retrieve.
925 925
  * @return false|string HTTP content. False on failure.
926 926
  */
927
-function wp_remote_fopen( $uri ) {
928
-	$parsed_url = @parse_url( $uri );
927
+function wp_remote_fopen($uri) {
928
+	$parsed_url = @parse_url($uri);
929 929
 
930
-	if ( !$parsed_url || !is_array( $parsed_url ) )
930
+	if ( ! $parsed_url || ! is_array($parsed_url))
931 931
 		return false;
932 932
 
933 933
 	$options = array();
934 934
 	$options['timeout'] = 10;
935 935
 
936
-	$response = wp_safe_remote_get( $uri, $options );
936
+	$response = wp_safe_remote_get($uri, $options);
937 937
 
938
-	if ( is_wp_error( $response ) )
938
+	if (is_wp_error($response))
939 939
 		return false;
940 940
 
941
-	return wp_remote_retrieve_body( $response );
941
+	return wp_remote_retrieve_body($response);
942 942
 }
943 943
 
944 944
 /**
@@ -952,11 +952,11 @@  discard block
 block discarded – undo
952 952
  *
953 953
  * @param string|array $query_vars Default WP_Query arguments.
954 954
  */
955
-function wp( $query_vars = '' ) {
955
+function wp($query_vars = '') {
956 956
 	global $wp, $wp_query, $wp_the_query;
957
-	$wp->main( $query_vars );
957
+	$wp->main($query_vars);
958 958
 
959
-	if ( !isset($wp_the_query) )
959
+	if ( ! isset($wp_the_query))
960 960
 		$wp_the_query = $wp_query;
961 961
 }
962 962
 
@@ -970,12 +970,12 @@  discard block
 block discarded – undo
970 970
  * @param int $code HTTP status code.
971 971
  * @return string Empty string if not found, or description if found.
972 972
  */
973
-function get_status_header_desc( $code ) {
973
+function get_status_header_desc($code) {
974 974
 	global $wp_header_to_desc;
975 975
 
976
-	$code = absint( $code );
976
+	$code = absint($code);
977 977
 
978
-	if ( !isset( $wp_header_to_desc ) ) {
978
+	if ( ! isset($wp_header_to_desc)) {
979 979
 		$wp_header_to_desc = array(
980 980
 			100 => 'Continue',
981 981
 			101 => 'Switching Protocols',
@@ -1043,7 +1043,7 @@  discard block
 block discarded – undo
1043 1043
 		);
1044 1044
 	}
1045 1045
 
1046
-	if ( isset( $wp_header_to_desc[$code] ) )
1046
+	if (isset($wp_header_to_desc[$code]))
1047 1047
 		return $wp_header_to_desc[$code];
1048 1048
 	else
1049 1049
 		return '';
@@ -1060,18 +1060,18 @@  discard block
 block discarded – undo
1060 1060
  * @param int    $code        HTTP status code.
1061 1061
  * @param string $description Optional. A custom description for the HTTP status.
1062 1062
  */
1063
-function status_header( $code, $description = '' ) {
1064
-	if ( ! $description ) {
1065
-		$description = get_status_header_desc( $code );
1063
+function status_header($code, $description = '') {
1064
+	if ( ! $description) {
1065
+		$description = get_status_header_desc($code);
1066 1066
 	}
1067 1067
 
1068
-	if ( empty( $description ) ) {
1068
+	if (empty($description)) {
1069 1069
 		return;
1070 1070
 	}
1071 1071
 
1072 1072
 	$protocol = wp_get_server_protocol();
1073 1073
 	$status_header = "$protocol $code $description";
1074
-	if ( function_exists( 'apply_filters' ) )
1074
+	if (function_exists('apply_filters'))
1075 1075
 
1076 1076
 		/**
1077 1077
 		 * Filters an HTTP status header.
@@ -1083,9 +1083,9 @@  discard block
 block discarded – undo
1083 1083
 		 * @param string $description   Description for the status code.
1084 1084
 		 * @param string $protocol      Server protocol.
1085 1085
 		 */
1086
-		$status_header = apply_filters( 'status_header', $status_header, $code, $description, $protocol );
1086
+		$status_header = apply_filters('status_header', $status_header, $code, $description, $protocol);
1087 1087
 
1088
-	@header( $status_header, true, $code );
1088
+	@header($status_header, true, $code);
1089 1089
 }
1090 1090
 
1091 1091
 /**
@@ -1104,7 +1104,7 @@  discard block
 block discarded – undo
1104 1104
 		'Cache-Control' => 'no-cache, must-revalidate, max-age=0',
1105 1105
 	);
1106 1106
 
1107
-	if ( function_exists('apply_filters') ) {
1107
+	if (function_exists('apply_filters')) {
1108 1108
 		/**
1109 1109
 		 * Filters the cache-controlling headers.
1110 1110
 		 *
@@ -1119,7 +1119,7 @@  discard block
 block discarded – undo
1119 1119
 		 *     @type string $Cache-Control Cache-Control header.
1120 1120
 		 * }
1121 1121
 		 */
1122
-		$headers = (array) apply_filters( 'nocache_headers', $headers );
1122
+		$headers = (array) apply_filters('nocache_headers', $headers);
1123 1123
 	}
1124 1124
 	$headers['Last-Modified'] = false;
1125 1125
 	return $headers;
@@ -1139,23 +1139,23 @@  discard block
 block discarded – undo
1139 1139
 function nocache_headers() {
1140 1140
 	$headers = wp_get_nocache_headers();
1141 1141
 
1142
-	unset( $headers['Last-Modified'] );
1142
+	unset($headers['Last-Modified']);
1143 1143
 
1144 1144
 	// In PHP 5.3+, make sure we are not sending a Last-Modified header.
1145
-	if ( function_exists( 'header_remove' ) ) {
1146
-		@header_remove( 'Last-Modified' );
1145
+	if (function_exists('header_remove')) {
1146
+		@header_remove('Last-Modified');
1147 1147
 	} else {
1148 1148
 		// In PHP 5.2, send an empty Last-Modified header, but only as a
1149 1149
 		// last resort to override a header already sent. #WP23021
1150
-		foreach ( headers_list() as $header ) {
1151
-			if ( 0 === stripos( $header, 'Last-Modified' ) ) {
1150
+		foreach (headers_list() as $header) {
1151
+			if (0 === stripos($header, 'Last-Modified')) {
1152 1152
 				$headers['Last-Modified'] = '';
1153 1153
 				break;
1154 1154
 			}
1155 1155
 		}
1156 1156
 	}
1157 1157
 
1158
-	foreach ( $headers as $name => $field_value )
1158
+	foreach ($headers as $name => $field_value)
1159 1159
 		@header("{$name}: {$field_value}");
1160 1160
 }
1161 1161
 
@@ -1167,9 +1167,9 @@  discard block
 block discarded – undo
1167 1167
 function cache_javascript_headers() {
1168 1168
 	$expiresOffset = 10 * DAY_IN_SECONDS;
1169 1169
 
1170
-	header( "Content-Type: text/javascript; charset=" . get_bloginfo( 'charset' ) );
1171
-	header( "Vary: Accept-Encoding" ); // Handle proxies
1172
-	header( "Expires: " . gmdate( "D, d M Y H:i:s", time() + $expiresOffset ) . " GMT" );
1170
+	header("Content-Type: text/javascript; charset=".get_bloginfo('charset'));
1171
+	header("Vary: Accept-Encoding"); // Handle proxies
1172
+	header("Expires: ".gmdate("D, d M Y H:i:s", time() + $expiresOffset)." GMT");
1173 1173
 }
1174 1174
 
1175 1175
 /**
@@ -1196,8 +1196,8 @@  discard block
 block discarded – undo
1196 1196
  * @param string $yn Character string containing either 'y' (yes) or 'n' (no).
1197 1197
  * @return bool True if yes, false on anything else.
1198 1198
  */
1199
-function bool_from_yn( $yn ) {
1200
-	return ( strtolower( $yn ) == 'y' );
1199
+function bool_from_yn($yn) {
1200
+	return (strtolower($yn) == 'y');
1201 1201
 }
1202 1202
 
1203 1203
 /**
@@ -1215,16 +1215,16 @@  discard block
 block discarded – undo
1215 1215
 function do_feed() {
1216 1216
 	global $wp_query;
1217 1217
 
1218
-	$feed = get_query_var( 'feed' );
1218
+	$feed = get_query_var('feed');
1219 1219
 
1220 1220
 	// Remove the pad, if present.
1221
-	$feed = preg_replace( '/^_+/', '', $feed );
1221
+	$feed = preg_replace('/^_+/', '', $feed);
1222 1222
 
1223
-	if ( $feed == '' || $feed == 'feed' )
1223
+	if ($feed == '' || $feed == 'feed')
1224 1224
 		$feed = get_default_feed();
1225 1225
 
1226
-	if ( ! has_action( "do_feed_{$feed}" ) ) {
1227
-		wp_die( __( 'ERROR: This is not a valid feed template.' ), '', array( 'response' => 404 ) );
1226
+	if ( ! has_action("do_feed_{$feed}")) {
1227
+		wp_die(__('ERROR: This is not a valid feed template.'), '', array('response' => 404));
1228 1228
 	}
1229 1229
 
1230 1230
 	/**
@@ -1239,7 +1239,7 @@  discard block
 block discarded – undo
1239 1239
 	 * @param bool   $is_comment_feed Whether the feed is a comment feed.
1240 1240
 	 * @param string $feed            The feed name.
1241 1241
 	 */
1242
-	do_action( "do_feed_{$feed}", $wp_query->is_comment_feed, $feed );
1242
+	do_action("do_feed_{$feed}", $wp_query->is_comment_feed, $feed);
1243 1243
 }
1244 1244
 
1245 1245
 /**
@@ -1250,7 +1250,7 @@  discard block
 block discarded – undo
1250 1250
  * @see load_template()
1251 1251
  */
1252 1252
 function do_feed_rdf() {
1253
-	load_template( ABSPATH . WPINC . '/feed-rdf.php' );
1253
+	load_template(ABSPATH.WPINC.'/feed-rdf.php');
1254 1254
 }
1255 1255
 
1256 1256
 /**
@@ -1261,7 +1261,7 @@  discard block
 block discarded – undo
1261 1261
  * @see load_template()
1262 1262
  */
1263 1263
 function do_feed_rss() {
1264
-	load_template( ABSPATH . WPINC . '/feed-rss.php' );
1264
+	load_template(ABSPATH.WPINC.'/feed-rss.php');
1265 1265
 }
1266 1266
 
1267 1267
 /**
@@ -1273,11 +1273,11 @@  discard block
 block discarded – undo
1273 1273
  *
1274 1274
  * @param bool $for_comments True for the comment feed, false for normal feed.
1275 1275
  */
1276
-function do_feed_rss2( $for_comments ) {
1277
-	if ( $for_comments )
1278
-		load_template( ABSPATH . WPINC . '/feed-rss2-comments.php' );
1276
+function do_feed_rss2($for_comments) {
1277
+	if ($for_comments)
1278
+		load_template(ABSPATH.WPINC.'/feed-rss2-comments.php');
1279 1279
 	else
1280
-		load_template( ABSPATH . WPINC . '/feed-rss2.php' );
1280
+		load_template(ABSPATH.WPINC.'/feed-rss2.php');
1281 1281
 }
1282 1282
 
1283 1283
 /**
@@ -1289,11 +1289,11 @@  discard block
 block discarded – undo
1289 1289
  *
1290 1290
  * @param bool $for_comments True for the comment feed, false for normal feed.
1291 1291
  */
1292
-function do_feed_atom( $for_comments ) {
1292
+function do_feed_atom($for_comments) {
1293 1293
 	if ($for_comments)
1294
-		load_template( ABSPATH . WPINC . '/feed-atom-comments.php');
1294
+		load_template(ABSPATH.WPINC.'/feed-atom-comments.php');
1295 1295
 	else
1296
-		load_template( ABSPATH . WPINC . '/feed-atom.php' );
1296
+		load_template(ABSPATH.WPINC.'/feed-atom.php');
1297 1297
 }
1298 1298
 
1299 1299
 /**
@@ -1305,22 +1305,22 @@  discard block
 block discarded – undo
1305 1305
  * @since 2.1.0
1306 1306
  */
1307 1307
 function do_robots() {
1308
-	header( 'Content-Type: text/plain; charset=utf-8' );
1308
+	header('Content-Type: text/plain; charset=utf-8');
1309 1309
 
1310 1310
 	/**
1311 1311
 	 * Fires when displaying the robots.txt file.
1312 1312
 	 *
1313 1313
 	 * @since 2.1.0
1314 1314
 	 */
1315
-	do_action( 'do_robotstxt' );
1315
+	do_action('do_robotstxt');
1316 1316
 
1317 1317
 	$output = "User-agent: *\n";
1318
-	$public = get_option( 'blog_public' );
1319
-	if ( '0' == $public ) {
1318
+	$public = get_option('blog_public');
1319
+	if ('0' == $public) {
1320 1320
 		$output .= "Disallow: /\n";
1321 1321
 	} else {
1322
-		$site_url = parse_url( site_url() );
1323
-		$path = ( !empty( $site_url['path'] ) ) ? $site_url['path'] : '';
1322
+		$site_url = parse_url(site_url());
1323
+		$path = ( ! empty($site_url['path'])) ? $site_url['path'] : '';
1324 1324
 		$output .= "Disallow: $path/wp-admin/\n";
1325 1325
 		$output .= "Allow: $path/wp-admin/admin-ajax.php\n";
1326 1326
 	}
@@ -1333,7 +1333,7 @@  discard block
 block discarded – undo
1333 1333
 	 * @param string $output Robots.txt output.
1334 1334
 	 * @param bool   $public Whether the site is considered "public".
1335 1335
 	 */
1336
-	echo apply_filters( 'robots_txt', $output, $public );
1336
+	echo apply_filters('robots_txt', $output, $public);
1337 1337
 }
1338 1338
 
1339 1339
 /**
@@ -1358,28 +1358,28 @@  discard block
 block discarded – undo
1358 1358
 	 * Check cache first. If options table goes away and we have true
1359 1359
 	 * cached, oh well.
1360 1360
 	 */
1361
-	if ( wp_cache_get( 'is_blog_installed' ) )
1361
+	if (wp_cache_get('is_blog_installed'))
1362 1362
 		return true;
1363 1363
 
1364 1364
 	$suppress = $wpdb->suppress_errors();
1365
-	if ( ! wp_installing() ) {
1365
+	if ( ! wp_installing()) {
1366 1366
 		$alloptions = wp_load_alloptions();
1367 1367
 	}
1368 1368
 	// If siteurl is not set to autoload, check it specifically
1369
-	if ( !isset( $alloptions['siteurl'] ) )
1370
-		$installed = $wpdb->get_var( "SELECT option_value FROM $wpdb->options WHERE option_name = 'siteurl'" );
1369
+	if ( ! isset($alloptions['siteurl']))
1370
+		$installed = $wpdb->get_var("SELECT option_value FROM $wpdb->options WHERE option_name = 'siteurl'");
1371 1371
 	else
1372 1372
 		$installed = $alloptions['siteurl'];
1373
-	$wpdb->suppress_errors( $suppress );
1373
+	$wpdb->suppress_errors($suppress);
1374 1374
 
1375
-	$installed = !empty( $installed );
1376
-	wp_cache_set( 'is_blog_installed', $installed );
1375
+	$installed = ! empty($installed);
1376
+	wp_cache_set('is_blog_installed', $installed);
1377 1377
 
1378
-	if ( $installed )
1378
+	if ($installed)
1379 1379
 		return true;
1380 1380
 
1381 1381
 	// If visiting repair.php, return true and let it take over.
1382
-	if ( defined( 'WP_REPAIRING' ) )
1382
+	if (defined('WP_REPAIRING'))
1383 1383
 		return true;
1384 1384
 
1385 1385
 	$suppress = $wpdb->suppress_errors();
@@ -1390,14 +1390,14 @@  discard block
 block discarded – undo
1390 1390
 	 * options table could not be accessed.
1391 1391
 	 */
1392 1392
 	$wp_tables = $wpdb->tables();
1393
-	foreach ( $wp_tables as $table ) {
1393
+	foreach ($wp_tables as $table) {
1394 1394
 		// The existence of custom user tables shouldn't suggest an insane state or prevent a clean install.
1395
-		if ( defined( 'CUSTOM_USER_TABLE' ) && CUSTOM_USER_TABLE == $table )
1395
+		if (defined('CUSTOM_USER_TABLE') && CUSTOM_USER_TABLE == $table)
1396 1396
 			continue;
1397
-		if ( defined( 'CUSTOM_USER_META_TABLE' ) && CUSTOM_USER_META_TABLE == $table )
1397
+		if (defined('CUSTOM_USER_META_TABLE') && CUSTOM_USER_META_TABLE == $table)
1398 1398
 			continue;
1399 1399
 
1400
-		if ( ! $wpdb->get_results( "DESCRIBE $table;" ) )
1400
+		if ( ! $wpdb->get_results("DESCRIBE $table;"))
1401 1401
 			continue;
1402 1402
 
1403 1403
 		// One or more tables exist. We are insane.
@@ -1407,16 +1407,16 @@  discard block
 block discarded – undo
1407 1407
 		// Die with a DB error.
1408 1408
 		$wpdb->error = sprintf(
1409 1409
 			/* translators: %s: database repair URL */
1410
-			__( 'One or more database tables are unavailable. The database may need to be <a href="%s">repaired</a>.' ),
1410
+			__('One or more database tables are unavailable. The database may need to be <a href="%s">repaired</a>.'),
1411 1411
 			'maint/repair.php?referrer=is_blog_installed'
1412 1412
 		);
1413 1413
 
1414 1414
 		dead_db();
1415 1415
 	}
1416 1416
 
1417
-	$wpdb->suppress_errors( $suppress );
1417
+	$wpdb->suppress_errors($suppress);
1418 1418
 
1419
-	wp_cache_set( 'is_blog_installed', false );
1419
+	wp_cache_set('is_blog_installed', false);
1420 1420
 
1421 1421
 	return false;
1422 1422
 }
@@ -1431,9 +1431,9 @@  discard block
 block discarded – undo
1431 1431
  * @param string     $name      Optional. Nonce name. Default '_wpnonce'.
1432 1432
  * @return string Escaped URL with nonce action added.
1433 1433
  */
1434
-function wp_nonce_url( $actionurl, $action = -1, $name = '_wpnonce' ) {
1435
-	$actionurl = str_replace( '&amp;', '&', $actionurl );
1436
-	return esc_html( add_query_arg( $name, wp_create_nonce( $action ), $actionurl ) );
1434
+function wp_nonce_url($actionurl, $action = -1, $name = '_wpnonce') {
1435
+	$actionurl = str_replace('&amp;', '&', $actionurl);
1436
+	return esc_html(add_query_arg($name, wp_create_nonce($action), $actionurl));
1437 1437
 }
1438 1438
 
1439 1439
 /**
@@ -1462,14 +1462,14 @@  discard block
 block discarded – undo
1462 1462
  * @param bool       $echo    Optional. Whether to display or return hidden form field. Default true.
1463 1463
  * @return string Nonce field HTML markup.
1464 1464
  */
1465
-function wp_nonce_field( $action = -1, $name = "_wpnonce", $referer = true , $echo = true ) {
1466
-	$name = esc_attr( $name );
1467
-	$nonce_field = '<input type="hidden" id="' . $name . '" name="' . $name . '" value="' . wp_create_nonce( $action ) . '" />';
1465
+function wp_nonce_field($action = -1, $name = "_wpnonce", $referer = true, $echo = true) {
1466
+	$name = esc_attr($name);
1467
+	$nonce_field = '<input type="hidden" id="'.$name.'" name="'.$name.'" value="'.wp_create_nonce($action).'" />';
1468 1468
 
1469
-	if ( $referer )
1470
-		$nonce_field .= wp_referer_field( false );
1469
+	if ($referer)
1470
+		$nonce_field .= wp_referer_field(false);
1471 1471
 
1472
-	if ( $echo )
1472
+	if ($echo)
1473 1473
 		echo $nonce_field;
1474 1474
 
1475 1475
 	return $nonce_field;
@@ -1486,10 +1486,10 @@  discard block
 block discarded – undo
1486 1486
  * @param bool $echo Optional. Whether to echo or return the referer field. Default true.
1487 1487
  * @return string Referer field HTML markup.
1488 1488
  */
1489
-function wp_referer_field( $echo = true ) {
1490
-	$referer_field = '<input type="hidden" name="_wp_http_referer" value="'. esc_attr( wp_unslash( $_SERVER['REQUEST_URI'] ) ) . '" />';
1489
+function wp_referer_field($echo = true) {
1490
+	$referer_field = '<input type="hidden" name="_wp_http_referer" value="'.esc_attr(wp_unslash($_SERVER['REQUEST_URI'])).'" />';
1491 1491
 
1492
-	if ( $echo )
1492
+	if ($echo)
1493 1493
 		echo $referer_field;
1494 1494
 	return $referer_field;
1495 1495
 }
@@ -1508,12 +1508,12 @@  discard block
 block discarded – undo
1508 1508
  *                             Default 'current'.
1509 1509
  * @return string Original referer field.
1510 1510
  */
1511
-function wp_original_referer_field( $echo = true, $jump_back_to = 'current' ) {
1512
-	if ( ! $ref = wp_get_original_referer() ) {
1513
-		$ref = 'previous' == $jump_back_to ? wp_get_referer() : wp_unslash( $_SERVER['REQUEST_URI'] );
1511
+function wp_original_referer_field($echo = true, $jump_back_to = 'current') {
1512
+	if ( ! $ref = wp_get_original_referer()) {
1513
+		$ref = 'previous' == $jump_back_to ? wp_get_referer() : wp_unslash($_SERVER['REQUEST_URI']);
1514 1514
 	}
1515
-	$orig_referer_field = '<input type="hidden" name="_wp_original_http_referer" value="' . esc_attr( $ref ) . '" />';
1516
-	if ( $echo )
1515
+	$orig_referer_field = '<input type="hidden" name="_wp_original_http_referer" value="'.esc_attr($ref).'" />';
1516
+	if ($echo)
1517 1517
 		echo $orig_referer_field;
1518 1518
 	return $orig_referer_field;
1519 1519
 }
@@ -1528,14 +1528,14 @@  discard block
 block discarded – undo
1528 1528
  * @return false|string False on failure. Referer URL on success.
1529 1529
  */
1530 1530
 function wp_get_referer() {
1531
-	if ( ! function_exists( 'wp_validate_redirect' ) ) {
1531
+	if ( ! function_exists('wp_validate_redirect')) {
1532 1532
 		return false;
1533 1533
 	}
1534 1534
 
1535 1535
 	$ref = wp_get_raw_referer();
1536 1536
 
1537
-	if ( $ref && $ref !== wp_unslash( $_SERVER['REQUEST_URI'] ) && $ref !== home_url() . wp_unslash( $_SERVER['REQUEST_URI'] ) ) {
1538
-		return wp_validate_redirect( $ref, false );
1537
+	if ($ref && $ref !== wp_unslash($_SERVER['REQUEST_URI']) && $ref !== home_url().wp_unslash($_SERVER['REQUEST_URI'])) {
1538
+		return wp_validate_redirect($ref, false);
1539 1539
 	}
1540 1540
 
1541 1541
 	return false;
@@ -1551,10 +1551,10 @@  discard block
 block discarded – undo
1551 1551
  * @return string|false Referer URL on success, false on failure.
1552 1552
  */
1553 1553
 function wp_get_raw_referer() {
1554
-	if ( ! empty( $_REQUEST['_wp_http_referer'] ) ) {
1555
-		return wp_unslash( $_REQUEST['_wp_http_referer'] );
1556
-	} else if ( ! empty( $_SERVER['HTTP_REFERER'] ) ) {
1557
-		return wp_unslash( $_SERVER['HTTP_REFERER'] );
1554
+	if ( ! empty($_REQUEST['_wp_http_referer'])) {
1555
+		return wp_unslash($_REQUEST['_wp_http_referer']);
1556
+	} else if ( ! empty($_SERVER['HTTP_REFERER'])) {
1557
+		return wp_unslash($_SERVER['HTTP_REFERER']);
1558 1558
 	}
1559 1559
 
1560 1560
 	return false;
@@ -1568,8 +1568,8 @@  discard block
 block discarded – undo
1568 1568
  * @return string|false False if no original referer or original referer if set.
1569 1569
  */
1570 1570
 function wp_get_original_referer() {
1571
-	if ( ! empty( $_REQUEST['_wp_original_http_referer'] ) && function_exists( 'wp_validate_redirect' ) )
1572
-		return wp_validate_redirect( wp_unslash( $_REQUEST['_wp_original_http_referer'] ), false );
1571
+	if ( ! empty($_REQUEST['_wp_original_http_referer']) && function_exists('wp_validate_redirect'))
1572
+		return wp_validate_redirect(wp_unslash($_REQUEST['_wp_original_http_referer']), false);
1573 1573
 	return false;
1574 1574
 }
1575 1575
 
@@ -1583,20 +1583,20 @@  discard block
 block discarded – undo
1583 1583
  * @param string $target Full path to attempt to create.
1584 1584
  * @return bool Whether the path was created. True if path already exists.
1585 1585
  */
1586
-function wp_mkdir_p( $target ) {
1586
+function wp_mkdir_p($target) {
1587 1587
 	$wrapper = null;
1588 1588
 
1589 1589
 	// Strip the protocol.
1590
-	if ( wp_is_stream( $target ) ) {
1591
-		list( $wrapper, $target ) = explode( '://', $target, 2 );
1590
+	if (wp_is_stream($target)) {
1591
+		list($wrapper, $target) = explode('://', $target, 2);
1592 1592
 	}
1593 1593
 
1594 1594
 	// From php.net/mkdir user contributed notes.
1595
-	$target = str_replace( '//', '/', $target );
1595
+	$target = str_replace('//', '/', $target);
1596 1596
 
1597 1597
 	// Put the wrapper back on the target.
1598
-	if ( $wrapper !== null ) {
1599
-		$target = $wrapper . '://' . $target;
1598
+	if ($wrapper !== null) {
1599
+		$target = $wrapper.'://'.$target;
1600 1600
 	}
1601 1601
 
1602 1602
 	/*
@@ -1604,35 +1604,35 @@  discard block
 block discarded – undo
1604 1604
 	 * Use rtrim() instead of untrailingslashit to avoid formatting.php dependency.
1605 1605
 	 */
1606 1606
 	$target = rtrim($target, '/');
1607
-	if ( empty($target) )
1607
+	if (empty($target))
1608 1608
 		$target = '/';
1609 1609
 
1610
-	if ( file_exists( $target ) )
1611
-		return @is_dir( $target );
1610
+	if (file_exists($target))
1611
+		return @is_dir($target);
1612 1612
 
1613 1613
 	// We need to find the permissions of the parent folder that exists and inherit that.
1614
-	$target_parent = dirname( $target );
1615
-	while ( '.' != $target_parent && ! is_dir( $target_parent ) ) {
1616
-		$target_parent = dirname( $target_parent );
1614
+	$target_parent = dirname($target);
1615
+	while ('.' != $target_parent && ! is_dir($target_parent)) {
1616
+		$target_parent = dirname($target_parent);
1617 1617
 	}
1618 1618
 
1619 1619
 	// Get the permission bits.
1620
-	if ( $stat = @stat( $target_parent ) ) {
1620
+	if ($stat = @stat($target_parent)) {
1621 1621
 		$dir_perms = $stat['mode'] & 0007777;
1622 1622
 	} else {
1623 1623
 		$dir_perms = 0777;
1624 1624
 	}
1625 1625
 
1626
-	if ( @mkdir( $target, $dir_perms, true ) ) {
1626
+	if (@mkdir($target, $dir_perms, true)) {
1627 1627
 
1628 1628
 		/*
1629 1629
 		 * If a umask is set that modifies $dir_perms, we'll have to re-set
1630 1630
 		 * the $dir_perms correctly with chmod()
1631 1631
 		 */
1632
-		if ( $dir_perms != ( $dir_perms & ~umask() ) ) {
1633
-			$folder_parts = explode( '/', substr( $target, strlen( $target_parent ) + 1 ) );
1634
-			for ( $i = 1, $c = count( $folder_parts ); $i <= $c; $i++ ) {
1635
-				@chmod( $target_parent . '/' . implode( '/', array_slice( $folder_parts, 0, $i ) ), $dir_perms );
1632
+		if ($dir_perms != ($dir_perms & ~umask())) {
1633
+			$folder_parts = explode('/', substr($target, strlen($target_parent) + 1));
1634
+			for ($i = 1, $c = count($folder_parts); $i <= $c; $i++) {
1635
+				@chmod($target_parent.'/'.implode('/', array_slice($folder_parts, 0, $i)), $dir_perms);
1636 1636
 			}
1637 1637
 		}
1638 1638
 
@@ -1652,23 +1652,23 @@  discard block
 block discarded – undo
1652 1652
  * @param string $path File path.
1653 1653
  * @return bool True if path is absolute, false is not absolute.
1654 1654
  */
1655
-function path_is_absolute( $path ) {
1655
+function path_is_absolute($path) {
1656 1656
 	/*
1657 1657
 	 * This is definitive if true but fails if $path does not exist or contains
1658 1658
 	 * a symbolic link.
1659 1659
 	 */
1660
-	if ( realpath($path) == $path )
1660
+	if (realpath($path) == $path)
1661 1661
 		return true;
1662 1662
 
1663
-	if ( strlen($path) == 0 || $path[0] == '.' )
1663
+	if (strlen($path) == 0 || $path[0] == '.')
1664 1664
 		return false;
1665 1665
 
1666 1666
 	// Windows allows absolute paths like this.
1667
-	if ( preg_match('#^[a-zA-Z]:\\\\#', $path) )
1667
+	if (preg_match('#^[a-zA-Z]:\\\\#', $path))
1668 1668
 		return true;
1669 1669
 
1670 1670
 	// A path starting with / or \ is absolute; anything else is relative.
1671
-	return ( $path[0] == '/' || $path[0] == '\\' );
1671
+	return ($path[0] == '/' || $path[0] == '\\');
1672 1672
 }
1673 1673
 
1674 1674
 /**
@@ -1683,11 +1683,11 @@  discard block
 block discarded – undo
1683 1683
  * @param string $path Path relative to $base.
1684 1684
  * @return string The path with the base or absolute path.
1685 1685
  */
1686
-function path_join( $base, $path ) {
1687
-	if ( path_is_absolute($path) )
1686
+function path_join($base, $path) {
1687
+	if (path_is_absolute($path))
1688 1688
 		return $path;
1689 1689
 
1690
-	return rtrim($base, '/') . '/' . ltrim($path, '/');
1690
+	return rtrim($base, '/').'/'.ltrim($path, '/');
1691 1691
 }
1692 1692
 
1693 1693
 /**
@@ -1705,11 +1705,11 @@  discard block
 block discarded – undo
1705 1705
  * @param string $path Path to normalize.
1706 1706
  * @return string Normalized path.
1707 1707
  */
1708
-function wp_normalize_path( $path ) {
1709
-	$path = str_replace( '\\', '/', $path );
1710
-	$path = preg_replace( '|(?<=.)/+|', '/', $path );
1711
-	if ( ':' === substr( $path, 1, 1 ) ) {
1712
-		$path = ucfirst( $path );
1708
+function wp_normalize_path($path) {
1709
+	$path = str_replace('\\', '/', $path);
1710
+	$path = preg_replace('|(?<=.)/+|', '/', $path);
1711
+	if (':' === substr($path, 1, 1)) {
1712
+		$path = ucfirst($path);
1713 1713
 	}
1714 1714
 	return $path;
1715 1715
 }
@@ -1732,24 +1732,24 @@  discard block
 block discarded – undo
1732 1732
  */
1733 1733
 function get_temp_dir() {
1734 1734
 	static $temp = '';
1735
-	if ( defined('WP_TEMP_DIR') )
1735
+	if (defined('WP_TEMP_DIR'))
1736 1736
 		return trailingslashit(WP_TEMP_DIR);
1737 1737
 
1738
-	if ( $temp )
1739
-		return trailingslashit( $temp );
1738
+	if ($temp)
1739
+		return trailingslashit($temp);
1740 1740
 
1741
-	if ( function_exists('sys_get_temp_dir') ) {
1741
+	if (function_exists('sys_get_temp_dir')) {
1742 1742
 		$temp = sys_get_temp_dir();
1743
-		if ( @is_dir( $temp ) && wp_is_writable( $temp ) )
1744
-			return trailingslashit( $temp );
1743
+		if (@is_dir($temp) && wp_is_writable($temp))
1744
+			return trailingslashit($temp);
1745 1745
 	}
1746 1746
 
1747 1747
 	$temp = ini_get('upload_tmp_dir');
1748
-	if ( @is_dir( $temp ) && wp_is_writable( $temp ) )
1749
-		return trailingslashit( $temp );
1748
+	if (@is_dir($temp) && wp_is_writable($temp))
1749
+		return trailingslashit($temp);
1750 1750
 
1751
-	$temp = WP_CONTENT_DIR . '/';
1752
-	if ( is_dir( $temp ) && wp_is_writable( $temp ) )
1751
+	$temp = WP_CONTENT_DIR.'/';
1752
+	if (is_dir($temp) && wp_is_writable($temp))
1753 1753
 		return $temp;
1754 1754
 
1755 1755
 	return '/tmp/';
@@ -1768,11 +1768,11 @@  discard block
 block discarded – undo
1768 1768
  * @param string $path Path to check for write-ability.
1769 1769
  * @return bool Whether the path is writable.
1770 1770
  */
1771
-function wp_is_writable( $path ) {
1772
-	if ( 'WIN' === strtoupper( substr( PHP_OS, 0, 3 ) ) )
1773
-		return win_is_writable( $path );
1771
+function wp_is_writable($path) {
1772
+	if ('WIN' === strtoupper(substr(PHP_OS, 0, 3)))
1773
+		return win_is_writable($path);
1774 1774
 	else
1775
-		return @is_writable( $path );
1775
+		return @is_writable($path);
1776 1776
 }
1777 1777
 
1778 1778
 /**
@@ -1791,21 +1791,21 @@  discard block
 block discarded – undo
1791 1791
  * @param string $path Windows path to check for write-ability.
1792 1792
  * @return bool Whether the path is writable.
1793 1793
  */
1794
-function win_is_writable( $path ) {
1794
+function win_is_writable($path) {
1795 1795
 
1796
-	if ( $path[strlen( $path ) - 1] == '/' ) { // if it looks like a directory, check a random file within the directory
1797
-		return win_is_writable( $path . uniqid( mt_rand() ) . '.tmp');
1798
-	} elseif ( is_dir( $path ) ) { // If it's a directory (and not a file) check a random file within the directory
1799
-		return win_is_writable( $path . '/' . uniqid( mt_rand() ) . '.tmp' );
1796
+	if ($path[strlen($path) - 1] == '/') { // if it looks like a directory, check a random file within the directory
1797
+		return win_is_writable($path.uniqid(mt_rand()).'.tmp');
1798
+	} elseif (is_dir($path)) { // If it's a directory (and not a file) check a random file within the directory
1799
+		return win_is_writable($path.'/'.uniqid(mt_rand()).'.tmp');
1800 1800
 	}
1801 1801
 	// check tmp file for read/write capabilities
1802
-	$should_delete_tmp_file = !file_exists( $path );
1803
-	$f = @fopen( $path, 'a' );
1804
-	if ( $f === false )
1802
+	$should_delete_tmp_file = ! file_exists($path);
1803
+	$f = @fopen($path, 'a');
1804
+	if ($f === false)
1805 1805
 		return false;
1806
-	fclose( $f );
1807
-	if ( $should_delete_tmp_file )
1808
-		unlink( $path );
1806
+	fclose($f);
1807
+	if ($should_delete_tmp_file)
1808
+		unlink($path);
1809 1809
 	return true;
1810 1810
 }
1811 1811
 
@@ -1823,7 +1823,7 @@  discard block
 block discarded – undo
1823 1823
  * @return array See wp_upload_dir() for description.
1824 1824
  */
1825 1825
 function wp_get_upload_dir() {
1826
-	return wp_upload_dir( null, false );
1826
+	return wp_upload_dir(null, false);
1827 1827
 }
1828 1828
 
1829 1829
 /**
@@ -1862,13 +1862,13 @@  discard block
 block discarded – undo
1862 1862
  * @param bool   $refresh_cache Optional. Whether to refresh the cache. Default false.
1863 1863
  * @return array See above for description.
1864 1864
  */
1865
-function wp_upload_dir( $time = null, $create_dir = true, $refresh_cache = false ) {
1865
+function wp_upload_dir($time = null, $create_dir = true, $refresh_cache = false) {
1866 1866
 	static $cache = array(), $tested_paths = array();
1867 1867
 
1868
-	$key = sprintf( '%d-%s', get_current_blog_id(), (string) $time );
1868
+	$key = sprintf('%d-%s', get_current_blog_id(), (string) $time);
1869 1869
 
1870
-	if ( $refresh_cache || empty( $cache[ $key ] ) ) {
1871
-		$cache[ $key ] = _wp_upload_dir( $time );
1870
+	if ($refresh_cache || empty($cache[$key])) {
1871
+		$cache[$key] = _wp_upload_dir($time);
1872 1872
 	}
1873 1873
 
1874 1874
 	/**
@@ -1879,29 +1879,29 @@  discard block
 block discarded – undo
1879 1879
 	 * @param array $uploads Array of upload directory data with keys of 'path',
1880 1880
 	 *                       'url', 'subdir, 'basedir', and 'error'.
1881 1881
 	 */
1882
-	$uploads = apply_filters( 'upload_dir', $cache[ $key ] );
1882
+	$uploads = apply_filters('upload_dir', $cache[$key]);
1883 1883
 
1884
-	if ( $create_dir ) {
1884
+	if ($create_dir) {
1885 1885
 		$path = $uploads['path'];
1886 1886
 
1887
-		if ( array_key_exists( $path, $tested_paths ) ) {
1888
-			$uploads['error'] = $tested_paths[ $path ];
1887
+		if (array_key_exists($path, $tested_paths)) {
1888
+			$uploads['error'] = $tested_paths[$path];
1889 1889
 		} else {
1890
-			if ( ! wp_mkdir_p( $path ) ) {
1891
-				if ( 0 === strpos( $uploads['basedir'], ABSPATH ) ) {
1892
-					$error_path = str_replace( ABSPATH, '', $uploads['basedir'] ) . $uploads['subdir'];
1890
+			if ( ! wp_mkdir_p($path)) {
1891
+				if (0 === strpos($uploads['basedir'], ABSPATH)) {
1892
+					$error_path = str_replace(ABSPATH, '', $uploads['basedir']).$uploads['subdir'];
1893 1893
 				} else {
1894
-					$error_path = basename( $uploads['basedir'] ) . $uploads['subdir'];
1894
+					$error_path = basename($uploads['basedir']).$uploads['subdir'];
1895 1895
 				}
1896 1896
 
1897 1897
 				$uploads['error'] = sprintf(
1898 1898
 					/* translators: %s: directory path */
1899
-					__( 'Unable to create directory %s. Is its parent directory writable by the server?' ),
1900
-					esc_html( $error_path )
1899
+					__('Unable to create directory %s. Is its parent directory writable by the server?'),
1900
+					esc_html($error_path)
1901 1901
 				);
1902 1902
 			}
1903 1903
 
1904
-			$tested_paths[ $path ] = $uploads['error'];
1904
+			$tested_paths[$path] = $uploads['error'];
1905 1905
 		}
1906 1906
 	}
1907 1907
 
@@ -1917,39 +1917,39 @@  discard block
 block discarded – undo
1917 1917
  * @param string $time Optional. Time formatted in 'yyyy/mm'. Default null.
1918 1918
  * @return array See wp_upload_dir()
1919 1919
  */
1920
-function _wp_upload_dir( $time = null ) {
1921
-	$siteurl = get_option( 'siteurl' );
1922
-	$upload_path = trim( get_option( 'upload_path' ) );
1920
+function _wp_upload_dir($time = null) {
1921
+	$siteurl = get_option('siteurl');
1922
+	$upload_path = trim(get_option('upload_path'));
1923 1923
 
1924
-	if ( empty( $upload_path ) || 'wp-content/uploads' == $upload_path ) {
1925
-		$dir = WP_CONTENT_DIR . '/uploads';
1926
-	} elseif ( 0 !== strpos( $upload_path, ABSPATH ) ) {
1924
+	if (empty($upload_path) || 'wp-content/uploads' == $upload_path) {
1925
+		$dir = WP_CONTENT_DIR.'/uploads';
1926
+	} elseif (0 !== strpos($upload_path, ABSPATH)) {
1927 1927
 		// $dir is absolute, $upload_path is (maybe) relative to ABSPATH
1928
-		$dir = path_join( ABSPATH, $upload_path );
1928
+		$dir = path_join(ABSPATH, $upload_path);
1929 1929
 	} else {
1930 1930
 		$dir = $upload_path;
1931 1931
 	}
1932 1932
 
1933
-	if ( !$url = get_option( 'upload_url_path' ) ) {
1934
-		if ( empty($upload_path) || ( 'wp-content/uploads' == $upload_path ) || ( $upload_path == $dir ) )
1935
-			$url = WP_CONTENT_URL . '/uploads';
1933
+	if ( ! $url = get_option('upload_url_path')) {
1934
+		if (empty($upload_path) || ('wp-content/uploads' == $upload_path) || ($upload_path == $dir))
1935
+			$url = WP_CONTENT_URL.'/uploads';
1936 1936
 		else
1937
-			$url = trailingslashit( $siteurl ) . $upload_path;
1937
+			$url = trailingslashit($siteurl).$upload_path;
1938 1938
 	}
1939 1939
 
1940 1940
 	/*
1941 1941
 	 * Honor the value of UPLOADS. This happens as long as ms-files rewriting is disabled.
1942 1942
 	 * We also sometimes obey UPLOADS when rewriting is enabled -- see the next block.
1943 1943
 	 */
1944
-	if ( defined( 'UPLOADS' ) && ! ( is_multisite() && get_site_option( 'ms_files_rewriting' ) ) ) {
1945
-		$dir = ABSPATH . UPLOADS;
1946
-		$url = trailingslashit( $siteurl ) . UPLOADS;
1944
+	if (defined('UPLOADS') && ! (is_multisite() && get_site_option('ms_files_rewriting'))) {
1945
+		$dir = ABSPATH.UPLOADS;
1946
+		$url = trailingslashit($siteurl).UPLOADS;
1947 1947
 	}
1948 1948
 
1949 1949
 	// If multisite (and if not the main site in a post-MU network)
1950
-	if ( is_multisite() && ! ( is_main_network() && is_main_site() && defined( 'MULTISITE' ) ) ) {
1950
+	if (is_multisite() && ! (is_main_network() && is_main_site() && defined('MULTISITE'))) {
1951 1951
 
1952
-		if ( ! get_site_option( 'ms_files_rewriting' ) ) {
1952
+		if ( ! get_site_option('ms_files_rewriting')) {
1953 1953
 			/*
1954 1954
 			 * If ms-files rewriting is disabled (networks created post-3.5), it is fairly
1955 1955
 			 * straightforward: Append sites/%d if we're not on the main site (for post-MU
@@ -1959,15 +1959,15 @@  discard block
 block discarded – undo
1959 1959
 			 * had wp-content/uploads for the main site.)
1960 1960
 			 */
1961 1961
 
1962
-			if ( defined( 'MULTISITE' ) )
1963
-				$ms_dir = '/sites/' . get_current_blog_id();
1962
+			if (defined('MULTISITE'))
1963
+				$ms_dir = '/sites/'.get_current_blog_id();
1964 1964
 			else
1965
-				$ms_dir = '/' . get_current_blog_id();
1965
+				$ms_dir = '/'.get_current_blog_id();
1966 1966
 
1967 1967
 			$dir .= $ms_dir;
1968 1968
 			$url .= $ms_dir;
1969 1969
 
1970
-		} elseif ( defined( 'UPLOADS' ) && ! ms_is_switched() ) {
1970
+		} elseif (defined('UPLOADS') && ! ms_is_switched()) {
1971 1971
 			/*
1972 1972
 			 * Handle the old-form ms-files.php rewriting if the network still has that enabled.
1973 1973
 			 * When ms-files rewriting is enabled, then we only listen to UPLOADS when:
@@ -1982,11 +1982,11 @@  discard block
 block discarded – undo
1982 1982
 			 * rewriting in multisite, the resulting URL is /files. (#WP22702 for background.)
1983 1983
 			 */
1984 1984
 
1985
-			if ( defined( 'BLOGUPLOADDIR' ) )
1986
-				$dir = untrailingslashit( BLOGUPLOADDIR );
1985
+			if (defined('BLOGUPLOADDIR'))
1986
+				$dir = untrailingslashit(BLOGUPLOADDIR);
1987 1987
 			else
1988
-				$dir = ABSPATH . UPLOADS;
1989
-			$url = trailingslashit( $siteurl ) . 'files';
1988
+				$dir = ABSPATH.UPLOADS;
1989
+			$url = trailingslashit($siteurl).'files';
1990 1990
 		}
1991 1991
 	}
1992 1992
 
@@ -1994,12 +1994,12 @@  discard block
 block discarded – undo
1994 1994
 	$baseurl = $url;
1995 1995
 
1996 1996
 	$subdir = '';
1997
-	if ( get_option( 'uploads_use_yearmonth_folders' ) ) {
1997
+	if (get_option('uploads_use_yearmonth_folders')) {
1998 1998
 		// Generate the yearly and monthly dirs
1999
-		if ( !$time )
2000
-			$time = current_time( 'mysql' );
2001
-		$y = substr( $time, 0, 4 );
2002
-		$m = substr( $time, 5, 2 );
1999
+		if ( ! $time)
2000
+			$time = current_time('mysql');
2001
+		$y = substr($time, 0, 4);
2002
+		$m = substr($time, 5, 2);
2003 2003
 		$subdir = "/$y/$m";
2004 2004
 	}
2005 2005
 
@@ -2033,19 +2033,19 @@  discard block
 block discarded – undo
2033 2033
  * @param callable $unique_filename_callback Callback. Default null.
2034 2034
  * @return string New filename, if given wasn't unique.
2035 2035
  */
2036
-function wp_unique_filename( $dir, $filename, $unique_filename_callback = null ) {
2036
+function wp_unique_filename($dir, $filename, $unique_filename_callback = null) {
2037 2037
 	// Sanitize the file name before we begin processing.
2038 2038
 	$filename = sanitize_file_name($filename);
2039 2039
 
2040 2040
 	// Separate the filename into a name and extension.
2041
-	$ext = pathinfo( $filename, PATHINFO_EXTENSION );
2042
-	$name = pathinfo( $filename, PATHINFO_BASENAME );
2043
-	if ( $ext ) {
2044
-		$ext = '.' . $ext;
2041
+	$ext = pathinfo($filename, PATHINFO_EXTENSION);
2042
+	$name = pathinfo($filename, PATHINFO_BASENAME);
2043
+	if ($ext) {
2044
+		$ext = '.'.$ext;
2045 2045
 	}
2046 2046
 
2047 2047
 	// Edge case: if file is named '.ext', treat as an empty name.
2048
-	if ( $name === $ext ) {
2048
+	if ($name === $ext) {
2049 2049
 		$name = '';
2050 2050
 	}
2051 2051
 
@@ -2053,21 +2053,21 @@  discard block
 block discarded – undo
2053 2053
 	 * Increment the file number until we have a unique file to save in $dir.
2054 2054
 	 * Use callback if supplied.
2055 2055
 	 */
2056
-	if ( $unique_filename_callback && is_callable( $unique_filename_callback ) ) {
2057
-		$filename = call_user_func( $unique_filename_callback, $dir, $name, $ext );
2056
+	if ($unique_filename_callback && is_callable($unique_filename_callback)) {
2057
+		$filename = call_user_func($unique_filename_callback, $dir, $name, $ext);
2058 2058
 	} else {
2059 2059
 		$number = '';
2060 2060
 
2061 2061
 		// Change '.ext' to lower case.
2062
-		if ( $ext && strtolower($ext) != $ext ) {
2062
+		if ($ext && strtolower($ext) != $ext) {
2063 2063
 			$ext2 = strtolower($ext);
2064
-			$filename2 = preg_replace( '|' . preg_quote($ext) . '$|', $ext2, $filename );
2064
+			$filename2 = preg_replace('|'.preg_quote($ext).'$|', $ext2, $filename);
2065 2065
 
2066 2066
 			// Check for both lower and upper case extension or image sub-sizes may be overwritten.
2067
-			while ( file_exists($dir . "/$filename") || file_exists($dir . "/$filename2") ) {
2067
+			while (file_exists($dir."/$filename") || file_exists($dir."/$filename2")) {
2068 2068
 				$new_number = (int) $number + 1;
2069
-				$filename = str_replace( array( "-$number$ext", "$number$ext" ), "-$new_number$ext", $filename );
2070
-				$filename2 = str_replace( array( "-$number$ext2", "$number$ext2" ), "-$new_number$ext2", $filename2 );
2069
+				$filename = str_replace(array("-$number$ext", "$number$ext"), "-$new_number$ext", $filename);
2070
+				$filename2 = str_replace(array("-$number$ext2", "$number$ext2"), "-$new_number$ext2", $filename2);
2071 2071
 				$number = $new_number;
2072 2072
 			}
2073 2073
 
@@ -2081,22 +2081,22 @@  discard block
 block discarded – undo
2081 2081
 			 * @param string        $dir                      Directory path.
2082 2082
 			 * @param callable|null $unique_filename_callback Callback function that generates the unique file name.
2083 2083
 			 */
2084
-			return apply_filters( 'wp_unique_filename', $filename2, $ext, $dir, $unique_filename_callback );
2084
+			return apply_filters('wp_unique_filename', $filename2, $ext, $dir, $unique_filename_callback);
2085 2085
 		}
2086 2086
 
2087
-		while ( file_exists( $dir . "/$filename" ) ) {
2087
+		while (file_exists($dir."/$filename")) {
2088 2088
 			$new_number = (int) $number + 1;
2089
-			if ( '' == "$number$ext" ) {
2090
-				$filename = "$filename-" . $new_number;
2089
+			if ('' == "$number$ext") {
2090
+				$filename = "$filename-".$new_number;
2091 2091
 			} else {
2092
-				$filename = str_replace( array( "-$number$ext", "$number$ext" ), "-" . $new_number . $ext, $filename );
2092
+				$filename = str_replace(array("-$number$ext", "$number$ext"), "-".$new_number.$ext, $filename);
2093 2093
 			}
2094 2094
 			$number = $new_number;
2095 2095
 		}
2096 2096
 	}
2097 2097
 
2098 2098
 	/** This filter is documented in wp-includes/functions.php */
2099
-	return apply_filters( 'wp_unique_filename', $filename, $ext, $dir, $unique_filename_callback );
2099
+	return apply_filters('wp_unique_filename', $filename, $ext, $dir, $unique_filename_callback);
2100 2100
 }
2101 2101
 
2102 2102
 /**
@@ -2122,20 +2122,20 @@  discard block
 block discarded – undo
2122 2122
  * @param string       $time       Optional. Time formatted in 'yyyy/mm'. Default null.
2123 2123
  * @return array
2124 2124
  */
2125
-function wp_upload_bits( $name, $deprecated, $bits, $time = null ) {
2126
-	if ( !empty( $deprecated ) )
2127
-		_deprecated_argument( __FUNCTION__, '2.0.0' );
2125
+function wp_upload_bits($name, $deprecated, $bits, $time = null) {
2126
+	if ( ! empty($deprecated))
2127
+		_deprecated_argument(__FUNCTION__, '2.0.0');
2128 2128
 
2129
-	if ( empty( $name ) )
2130
-		return array( 'error' => __( 'Empty filename' ) );
2129
+	if (empty($name))
2130
+		return array('error' => __('Empty filename'));
2131 2131
 
2132
-	$wp_filetype = wp_check_filetype( $name );
2133
-	if ( ! $wp_filetype['ext'] && ! current_user_can( 'unfiltered_upload' ) )
2134
-		return array( 'error' => __( 'Sorry, this file type is not permitted for security reasons.' ) );
2132
+	$wp_filetype = wp_check_filetype($name);
2133
+	if ( ! $wp_filetype['ext'] && ! current_user_can('unfiltered_upload'))
2134
+		return array('error' => __('Sorry, this file type is not permitted for security reasons.'));
2135 2135
 
2136
-	$upload = wp_upload_dir( $time );
2136
+	$upload = wp_upload_dir($time);
2137 2137
 
2138
-	if ( $upload['error'] !== false )
2138
+	if ($upload['error'] !== false)
2139 2139
 		return $upload;
2140 2140
 
2141 2141
 	/**
@@ -2148,49 +2148,49 @@  discard block
 block discarded – undo
2148 2148
 	 *
2149 2149
 	 * @param mixed $upload_bits_error An array of upload bits data, or a non-array error to return.
2150 2150
 	 */
2151
-	$upload_bits_error = apply_filters( 'wp_upload_bits', array( 'name' => $name, 'bits' => $bits, 'time' => $time ) );
2152
-	if ( !is_array( $upload_bits_error ) ) {
2153
-		$upload[ 'error' ] = $upload_bits_error;
2151
+	$upload_bits_error = apply_filters('wp_upload_bits', array('name' => $name, 'bits' => $bits, 'time' => $time));
2152
+	if ( ! is_array($upload_bits_error)) {
2153
+		$upload['error'] = $upload_bits_error;
2154 2154
 		return $upload;
2155 2155
 	}
2156 2156
 
2157
-	$filename = wp_unique_filename( $upload['path'], $name );
2157
+	$filename = wp_unique_filename($upload['path'], $name);
2158 2158
 
2159
-	$new_file = $upload['path'] . "/$filename";
2160
-	if ( ! wp_mkdir_p( dirname( $new_file ) ) ) {
2161
-		if ( 0 === strpos( $upload['basedir'], ABSPATH ) )
2162
-			$error_path = str_replace( ABSPATH, '', $upload['basedir'] ) . $upload['subdir'];
2159
+	$new_file = $upload['path']."/$filename";
2160
+	if ( ! wp_mkdir_p(dirname($new_file))) {
2161
+		if (0 === strpos($upload['basedir'], ABSPATH))
2162
+			$error_path = str_replace(ABSPATH, '', $upload['basedir']).$upload['subdir'];
2163 2163
 		else
2164
-			$error_path = basename( $upload['basedir'] ) . $upload['subdir'];
2164
+			$error_path = basename($upload['basedir']).$upload['subdir'];
2165 2165
 
2166 2166
 		$message = sprintf(
2167 2167
 			/* translators: %s: directory path */
2168
-			__( 'Unable to create directory %s. Is its parent directory writable by the server?' ),
2168
+			__('Unable to create directory %s. Is its parent directory writable by the server?'),
2169 2169
 			$error_path
2170 2170
 		);
2171
-		return array( 'error' => $message );
2171
+		return array('error' => $message);
2172 2172
 	}
2173 2173
 
2174
-	$ifp = @ fopen( $new_file, 'wb' );
2175
-	if ( ! $ifp )
2176
-		return array( 'error' => sprintf( __( 'Could not write file %s' ), $new_file ) );
2174
+	$ifp = @ fopen($new_file, 'wb');
2175
+	if ( ! $ifp)
2176
+		return array('error' => sprintf(__('Could not write file %s'), $new_file));
2177 2177
 
2178
-	@fwrite( $ifp, $bits );
2179
-	fclose( $ifp );
2178
+	@fwrite($ifp, $bits);
2179
+	fclose($ifp);
2180 2180
 	clearstatcache();
2181 2181
 
2182 2182
 	// Set correct file permissions
2183
-	$stat = @ stat( dirname( $new_file ) );
2183
+	$stat = @ stat(dirname($new_file));
2184 2184
 	$perms = $stat['mode'] & 0007777;
2185 2185
 	$perms = $perms & 0000666;
2186
-	@ chmod( $new_file, $perms );
2186
+	@ chmod($new_file, $perms);
2187 2187
 	clearstatcache();
2188 2188
 
2189 2189
 	// Compute the URL
2190
-	$url = $upload['url'] . "/$filename";
2190
+	$url = $upload['url']."/$filename";
2191 2191
 
2192 2192
 	/** This filter is documented in wp-admin/includes/file.php */
2193
-	return apply_filters( 'wp_handle_upload', array( 'file' => $new_file, 'url' => $url, 'type' => $wp_filetype['type'], 'error' => false ), 'sideload' );
2193
+	return apply_filters('wp_handle_upload', array('file' => $new_file, 'url' => $url, 'type' => $wp_filetype['type'], 'error' => false), 'sideload');
2194 2194
 }
2195 2195
 
2196 2196
 /**
@@ -2201,12 +2201,12 @@  discard block
 block discarded – undo
2201 2201
  * @param string $ext The extension to search.
2202 2202
  * @return string|void The file type, example: audio, video, document, spreadsheet, etc.
2203 2203
  */
2204
-function wp_ext2type( $ext ) {
2205
-	$ext = strtolower( $ext );
2204
+function wp_ext2type($ext) {
2205
+	$ext = strtolower($ext);
2206 2206
 
2207 2207
 	$ext2type = wp_get_ext_types();
2208
-	foreach ( $ext2type as $type => $exts )
2209
-		if ( in_array( $ext, $exts ) )
2208
+	foreach ($ext2type as $type => $exts)
2209
+		if (in_array($ext, $exts))
2210 2210
 			return $type;
2211 2211
 }
2212 2212
 
@@ -2221,22 +2221,22 @@  discard block
 block discarded – undo
2221 2221
  * @param array  $mimes    Optional. Key is the file extension with value as the mime type.
2222 2222
  * @return array Values with extension first and mime type.
2223 2223
  */
2224
-function wp_check_filetype( $filename, $mimes = null ) {
2225
-	if ( empty($mimes) )
2224
+function wp_check_filetype($filename, $mimes = null) {
2225
+	if (empty($mimes))
2226 2226
 		$mimes = get_allowed_mime_types();
2227 2227
 	$type = false;
2228 2228
 	$ext = false;
2229 2229
 
2230
-	foreach ( $mimes as $ext_preg => $mime_match ) {
2231
-		$ext_preg = '!\.(' . $ext_preg . ')$!i';
2232
-		if ( preg_match( $ext_preg, $filename, $ext_matches ) ) {
2230
+	foreach ($mimes as $ext_preg => $mime_match) {
2231
+		$ext_preg = '!\.('.$ext_preg.')$!i';
2232
+		if (preg_match($ext_preg, $filename, $ext_matches)) {
2233 2233
 			$type = $mime_match;
2234 2234
 			$ext = $ext_matches[1];
2235 2235
 			break;
2236 2236
 		}
2237 2237
 	}
2238 2238
 
2239
-	return compact( 'ext', 'type' );
2239
+	return compact('ext', 'type');
2240 2240
 }
2241 2241
 
2242 2242
 /**
@@ -2258,28 +2258,28 @@  discard block
 block discarded – undo
2258 2258
  * @return array Values for the extension, MIME, and either a corrected filename or false
2259 2259
  *               if original $filename is valid.
2260 2260
  */
2261
-function wp_check_filetype_and_ext( $file, $filename, $mimes = null ) {
2261
+function wp_check_filetype_and_ext($file, $filename, $mimes = null) {
2262 2262
 	$proper_filename = false;
2263 2263
 
2264 2264
 	// Do basic extension validation and MIME mapping
2265
-	$wp_filetype = wp_check_filetype( $filename, $mimes );
2265
+	$wp_filetype = wp_check_filetype($filename, $mimes);
2266 2266
 	$ext = $wp_filetype['ext'];
2267 2267
 	$type = $wp_filetype['type'];
2268 2268
 
2269 2269
 	// We can't do any further validation without a file to work with
2270
-	if ( ! file_exists( $file ) ) {
2271
-		return compact( 'ext', 'type', 'proper_filename' );
2270
+	if ( ! file_exists($file)) {
2271
+		return compact('ext', 'type', 'proper_filename');
2272 2272
 	}
2273 2273
 
2274 2274
 	$real_mime = false;
2275 2275
 
2276 2276
 	// Validate image types.
2277
-	if ( $type && 0 === strpos( $type, 'image/' ) ) {
2277
+	if ($type && 0 === strpos($type, 'image/')) {
2278 2278
 
2279 2279
 		// Attempt to figure out what type of image it actually is
2280
-		$real_mime = wp_get_image_mime( $file );
2280
+		$real_mime = wp_get_image_mime($file);
2281 2281
 
2282
-		if ( $real_mime && $real_mime != $type ) {
2282
+		if ($real_mime && $real_mime != $type) {
2283 2283
 			/**
2284 2284
 			 * Filters the list mapping image mime types to their respective extensions.
2285 2285
 			 *
@@ -2287,26 +2287,26 @@  discard block
 block discarded – undo
2287 2287
 			 *
2288 2288
 			 * @param  array $mime_to_ext Array of image mime types and their matching extensions.
2289 2289
 			 */
2290
-			$mime_to_ext = apply_filters( 'getimagesize_mimes_to_exts', array(
2290
+			$mime_to_ext = apply_filters('getimagesize_mimes_to_exts', array(
2291 2291
 				'image/jpeg' => 'jpg',
2292 2292
 				'image/png'  => 'png',
2293 2293
 				'image/gif'  => 'gif',
2294 2294
 				'image/bmp'  => 'bmp',
2295 2295
 				'image/tiff' => 'tif',
2296
-			) );
2296
+			));
2297 2297
 
2298 2298
 			// Replace whatever is after the last period in the filename with the correct extension
2299
-			if ( ! empty( $mime_to_ext[ $real_mime ] ) ) {
2300
-				$filename_parts = explode( '.', $filename );
2301
-				array_pop( $filename_parts );
2302
-				$filename_parts[] = $mime_to_ext[ $real_mime ];
2303
-				$new_filename = implode( '.', $filename_parts );
2299
+			if ( ! empty($mime_to_ext[$real_mime])) {
2300
+				$filename_parts = explode('.', $filename);
2301
+				array_pop($filename_parts);
2302
+				$filename_parts[] = $mime_to_ext[$real_mime];
2303
+				$new_filename = implode('.', $filename_parts);
2304 2304
 
2305
-				if ( $new_filename != $filename ) {
2305
+				if ($new_filename != $filename) {
2306 2306
 					$proper_filename = $new_filename; // Mark that it changed
2307 2307
 				}
2308 2308
 				// Redefine the extension / MIME
2309
-				$wp_filetype = wp_check_filetype( $new_filename, $mimes );
2309
+				$wp_filetype = wp_check_filetype($new_filename, $mimes);
2310 2310
 				$ext = $wp_filetype['ext'];
2311 2311
 				$type = $wp_filetype['type'];
2312 2312
 			} else {
@@ -2317,20 +2317,20 @@  discard block
 block discarded – undo
2317 2317
 	}
2318 2318
 
2319 2319
 	// Validate files that didn't get validated during previous checks.
2320
-	if ( $type && ! $real_mime && extension_loaded( 'fileinfo' ) ) {
2321
-		$finfo = finfo_open( FILEINFO_MIME_TYPE );
2322
-		$real_mime = finfo_file( $finfo, $file );
2323
-		finfo_close( $finfo );
2320
+	if ($type && ! $real_mime && extension_loaded('fileinfo')) {
2321
+		$finfo = finfo_open(FILEINFO_MIME_TYPE);
2322
+		$real_mime = finfo_file($finfo, $file);
2323
+		finfo_close($finfo);
2324 2324
 
2325 2325
 		/*
2326 2326
 		 * If $real_mime doesn't match what we're expecting, we need to do some extra
2327 2327
 		 * vetting of application mime types to make sure this type of file is allowed.
2328 2328
 		 * Other mime types are assumed to be safe, but should be considered unverified.
2329 2329
 		 */
2330
-		if ( $real_mime && ( $real_mime !== $type ) && ( 0 === strpos( $real_mime, 'application' ) ) ) {
2330
+		if ($real_mime && ($real_mime !== $type) && (0 === strpos($real_mime, 'application'))) {
2331 2331
 			$allowed = get_allowed_mime_types();
2332 2332
 
2333
-			if ( ! in_array( $real_mime, $allowed ) ) {
2333
+			if ( ! in_array($real_mime, $allowed)) {
2334 2334
 				$type = $ext = false;
2335 2335
 			}
2336 2336
 		}
@@ -2348,7 +2348,7 @@  discard block
 block discarded – undo
2348 2348
 	 *                                          $file being in a tmp directory).
2349 2349
 	 * @param array  $mimes                     Key is the file extension with value as the mime type.
2350 2350
 	 */
2351
-	return apply_filters( 'wp_check_filetype_and_ext', compact( 'ext', 'type', 'proper_filename' ), $file, $filename, $mimes );
2351
+	return apply_filters('wp_check_filetype_and_ext', compact('ext', 'type', 'proper_filename'), $file, $filename, $mimes);
2352 2352
 }
2353 2353
 
2354 2354
 /**
@@ -2361,23 +2361,23 @@  discard block
 block discarded – undo
2361 2361
  * @param string $file Full path to the file.
2362 2362
  * @return string|false The actual mime type or false if the type cannot be determined.
2363 2363
  */
2364
-function wp_get_image_mime( $file ) {
2364
+function wp_get_image_mime($file) {
2365 2365
 	/*
2366 2366
 	 * Use exif_imagetype() to check the mimetype if available or fall back to
2367 2367
 	 * getimagesize() if exif isn't avaialbe. If either function throws an Exception
2368 2368
 	 * we assume the file could not be validated.
2369 2369
 	 */
2370 2370
 	try {
2371
-		if ( is_callable( 'exif_imagetype' ) ) {
2372
-			$imagetype = exif_imagetype( $file );
2373
-			$mime = ( $imagetype ) ? image_type_to_mime_type( $imagetype ) : false;
2374
-		} elseif ( function_exists( 'getimagesize' ) ) {
2375
-			$imagesize = getimagesize( $file );
2376
-			$mime = ( isset( $imagesize['mime'] ) ) ? $imagesize['mime'] : false;
2371
+		if (is_callable('exif_imagetype')) {
2372
+			$imagetype = exif_imagetype($file);
2373
+			$mime = ($imagetype) ? image_type_to_mime_type($imagetype) : false;
2374
+		} elseif (function_exists('getimagesize')) {
2375
+			$imagesize = getimagesize($file);
2376
+			$mime = (isset($imagesize['mime'])) ? $imagesize['mime'] : false;
2377 2377
 		} else {
2378 2378
 			$mime = false;
2379 2379
 		}
2380
-	} catch ( Exception $e ) {
2380
+	} catch (Exception $e) {
2381 2381
 		$mime = false;
2382 2382
 	}
2383 2383
 
@@ -2404,7 +2404,7 @@  discard block
 block discarded – undo
2404 2404
 	 * @param array $wp_get_mime_types Mime types keyed by the file extension regex
2405 2405
 	 *                                 corresponding to those types.
2406 2406
 	 */
2407
-	return apply_filters( 'mime_types', array(
2407
+	return apply_filters('mime_types', array(
2408 2408
 	// Image formats.
2409 2409
 	'jpg|jpeg|jpe' => 'image/jpeg',
2410 2410
 	'gif' => 'image/gif',
@@ -2504,7 +2504,7 @@  discard block
 block discarded – undo
2504 2504
 	'key' => 'application/vnd.apple.keynote',
2505 2505
 	'numbers' => 'application/vnd.apple.numbers',
2506 2506
 	'pages' => 'application/vnd.apple.pages',
2507
-	) );
2507
+	));
2508 2508
 }
2509 2509
 
2510 2510
 /**
@@ -2526,17 +2526,17 @@  discard block
 block discarded – undo
2526 2526
 	 * @param array $ext2type Multi-dimensional array with extensions for a default set
2527 2527
 	 *                        of file types.
2528 2528
 	 */
2529
-	return apply_filters( 'ext2type', array(
2530
-		'image'       => array( 'jpg', 'jpeg', 'jpe',  'gif',  'png',  'bmp',   'tif',  'tiff', 'ico' ),
2531
-		'audio'       => array( 'aac', 'ac3',  'aif',  'aiff', 'm3a',  'm4a',   'm4b',  'mka',  'mp1',  'mp2',  'mp3', 'ogg', 'oga', 'ram', 'wav', 'wma' ),
2532
-		'video'       => array( '3g2',  '3gp', '3gpp', 'asf', 'avi',  'divx', 'dv',   'flv',  'm4v',   'mkv',  'mov',  'mp4',  'mpeg', 'mpg', 'mpv', 'ogm', 'ogv', 'qt',  'rm', 'vob', 'wmv' ),
2533
-		'document'    => array( 'doc', 'docx', 'docm', 'dotm', 'odt',  'pages', 'pdf',  'xps',  'oxps', 'rtf',  'wp', 'wpd', 'psd', 'xcf' ),
2534
-		'spreadsheet' => array( 'numbers',     'ods',  'xls',  'xlsx', 'xlsm',  'xlsb' ),
2535
-		'interactive' => array( 'swf', 'key',  'ppt',  'pptx', 'pptm', 'pps',   'ppsx', 'ppsm', 'sldx', 'sldm', 'odp' ),
2536
-		'text'        => array( 'asc', 'csv',  'tsv',  'txt' ),
2537
-		'archive'     => array( 'bz2', 'cab',  'dmg',  'gz',   'rar',  'sea',   'sit',  'sqx',  'tar',  'tgz',  'zip', '7z' ),
2538
-		'code'        => array( 'css', 'htm',  'html', 'php',  'js' ),
2539
-	) );
2529
+	return apply_filters('ext2type', array(
2530
+		'image'       => array('jpg', 'jpeg', 'jpe', 'gif', 'png', 'bmp', 'tif', 'tiff', 'ico'),
2531
+		'audio'       => array('aac', 'ac3', 'aif', 'aiff', 'm3a', 'm4a', 'm4b', 'mka', 'mp1', 'mp2', 'mp3', 'ogg', 'oga', 'ram', 'wav', 'wma'),
2532
+		'video'       => array('3g2', '3gp', '3gpp', 'asf', 'avi', 'divx', 'dv', 'flv', 'm4v', 'mkv', 'mov', 'mp4', 'mpeg', 'mpg', 'mpv', 'ogm', 'ogv', 'qt', 'rm', 'vob', 'wmv'),
2533
+		'document'    => array('doc', 'docx', 'docm', 'dotm', 'odt', 'pages', 'pdf', 'xps', 'oxps', 'rtf', 'wp', 'wpd', 'psd', 'xcf'),
2534
+		'spreadsheet' => array('numbers', 'ods', 'xls', 'xlsx', 'xlsm', 'xlsb'),
2535
+		'interactive' => array('swf', 'key', 'ppt', 'pptx', 'pptm', 'pps', 'ppsx', 'ppsm', 'sldx', 'sldm', 'odp'),
2536
+		'text'        => array('asc', 'csv', 'tsv', 'txt'),
2537
+		'archive'     => array('bz2', 'cab', 'dmg', 'gz', 'rar', 'sea', 'sit', 'sqx', 'tar', 'tgz', 'zip', '7z'),
2538
+		'code'        => array('css', 'htm', 'html', 'php', 'js'),
2539
+	));
2540 2540
 }
2541 2541
 
2542 2542
 /**
@@ -2548,15 +2548,15 @@  discard block
 block discarded – undo
2548 2548
  * @return array Array of mime types keyed by the file extension regex corresponding
2549 2549
  *               to those types.
2550 2550
  */
2551
-function get_allowed_mime_types( $user = null ) {
2551
+function get_allowed_mime_types($user = null) {
2552 2552
 	$t = wp_get_mime_types();
2553 2553
 
2554
-	unset( $t['swf'], $t['exe'] );
2555
-	if ( function_exists( 'current_user_can' ) )
2556
-		$unfiltered = $user ? user_can( $user, 'unfiltered_html' ) : current_user_can( 'unfiltered_html' );
2554
+	unset($t['swf'], $t['exe']);
2555
+	if (function_exists('current_user_can'))
2556
+		$unfiltered = $user ? user_can($user, 'unfiltered_html') : current_user_can('unfiltered_html');
2557 2557
 
2558
-	if ( empty( $unfiltered ) )
2559
-		unset( $t['htm|html'] );
2558
+	if (empty($unfiltered))
2559
+		unset($t['htm|html']);
2560 2560
 
2561 2561
 	/**
2562 2562
 	 * Filters list of allowed mime types and file extensions.
@@ -2568,7 +2568,7 @@  discard block
 block discarded – undo
2568 2568
 	 *                               removed depending on '$user' capabilities.
2569 2569
 	 * @param int|WP_User|null $user User ID, User object or null if not provided (indicates current user).
2570 2570
 	 */
2571
-	return apply_filters( 'upload_mimes', $t, $user );
2571
+	return apply_filters('upload_mimes', $t, $user);
2572 2572
 }
2573 2573
 
2574 2574
 /**
@@ -2581,32 +2581,32 @@  discard block
 block discarded – undo
2581 2581
  *
2582 2582
  * @param string $action The nonce action.
2583 2583
  */
2584
-function wp_nonce_ays( $action ) {
2585
-	if ( 'log-out' == $action ) {
2584
+function wp_nonce_ays($action) {
2585
+	if ('log-out' == $action) {
2586 2586
 		$html = sprintf(
2587 2587
 			/* translators: %s: site name */
2588
-			__( 'You are attempting to log out of %s' ),
2589
-			get_bloginfo( 'name' )
2588
+			__('You are attempting to log out of %s'),
2589
+			get_bloginfo('name')
2590 2590
 		);
2591 2591
 		$html .= '</p><p>';
2592
-		$redirect_to = isset( $_REQUEST['redirect_to'] ) ? $_REQUEST['redirect_to'] : '';
2592
+		$redirect_to = isset($_REQUEST['redirect_to']) ? $_REQUEST['redirect_to'] : '';
2593 2593
 		$html .= sprintf(
2594 2594
 			/* translators: %s: logout URL */
2595
-			__( 'Do you really want to <a href="%s">log out</a>?' ),
2596
-			wp_logout_url( $redirect_to )
2595
+			__('Do you really want to <a href="%s">log out</a>?'),
2596
+			wp_logout_url($redirect_to)
2597 2597
 		);
2598 2598
 	} else {
2599
-		$html = __( 'Are you sure you want to do this?' );
2600
-		if ( wp_get_referer() ) {
2599
+		$html = __('Are you sure you want to do this?');
2600
+		if (wp_get_referer()) {
2601 2601
 			$html .= '</p><p>';
2602
-			$html .= sprintf( '<a href="%s">%s</a>',
2603
-				esc_url( remove_query_arg( 'updated', wp_get_referer() ) ),
2604
-				__( 'Please try again.' )
2602
+			$html .= sprintf('<a href="%s">%s</a>',
2603
+				esc_url(remove_query_arg('updated', wp_get_referer())),
2604
+				__('Please try again.')
2605 2605
 			);
2606 2606
 		}
2607 2607
 	}
2608 2608
 
2609
-	wp_die( $html, __( 'WordPress Failure Notice' ), 403 );
2609
+	wp_die($html, __('WordPress Failure Notice'), 403);
2610 2610
 }
2611 2611
 
2612 2612
 /**
@@ -2643,16 +2643,16 @@  discard block
 block discarded – undo
2643 2643
  *                                  Default is the value of is_rtl().
2644 2644
  * }
2645 2645
  */
2646
-function wp_die( $message = '', $title = '', $args = array() ) {
2646
+function wp_die($message = '', $title = '', $args = array()) {
2647 2647
 
2648
-	if ( is_int( $args ) ) {
2649
-		$args = array( 'response' => $args );
2650
-	} elseif ( is_int( $title ) ) {
2651
-		$args  = array( 'response' => $title );
2648
+	if (is_int($args)) {
2649
+		$args = array('response' => $args);
2650
+	} elseif (is_int($title)) {
2651
+		$args  = array('response' => $title);
2652 2652
 		$title = '';
2653 2653
 	}
2654 2654
 
2655
-	if ( wp_doing_ajax() ) {
2655
+	if (wp_doing_ajax()) {
2656 2656
 		/**
2657 2657
 		 * Filters the callback for killing WordPress execution for Ajax requests.
2658 2658
 		 *
@@ -2660,8 +2660,8 @@  discard block
 block discarded – undo
2660 2660
 		 *
2661 2661
 		 * @param callable $function Callback function name.
2662 2662
 		 */
2663
-		$function = apply_filters( 'wp_die_ajax_handler', '_ajax_wp_die_handler' );
2664
-	} elseif ( defined( 'XMLRPC_REQUEST' ) && XMLRPC_REQUEST ) {
2663
+		$function = apply_filters('wp_die_ajax_handler', '_ajax_wp_die_handler');
2664
+	} elseif (defined('XMLRPC_REQUEST') && XMLRPC_REQUEST) {
2665 2665
 		/**
2666 2666
 		 * Filters the callback for killing WordPress execution for XML-RPC requests.
2667 2667
 		 *
@@ -2669,7 +2669,7 @@  discard block
 block discarded – undo
2669 2669
 		 *
2670 2670
 		 * @param callable $function Callback function name.
2671 2671
 		 */
2672
-		$function = apply_filters( 'wp_die_xmlrpc_handler', '_xmlrpc_wp_die_handler' );
2672
+		$function = apply_filters('wp_die_xmlrpc_handler', '_xmlrpc_wp_die_handler');
2673 2673
 	} else {
2674 2674
 		/**
2675 2675
 		 * Filters the callback for killing WordPress execution for all non-Ajax, non-XML-RPC requests.
@@ -2678,10 +2678,10 @@  discard block
 block discarded – undo
2678 2678
 		 *
2679 2679
 		 * @param callable $function Callback function name.
2680 2680
 		 */
2681
-		$function = apply_filters( 'wp_die_handler', '_default_wp_die_handler' );
2681
+		$function = apply_filters('wp_die_handler', '_default_wp_die_handler');
2682 2682
 	}
2683 2683
 
2684
-	call_user_func( $function, $message, $title, $args );
2684
+	call_user_func($function, $message, $title, $args);
2685 2685
 }
2686 2686
 
2687 2687
 /**
@@ -2697,20 +2697,20 @@  discard block
 block discarded – undo
2697 2697
  * @param string          $title   Optional. Error title. Default empty.
2698 2698
  * @param string|array    $args    Optional. Arguments to control behavior. Default empty array.
2699 2699
  */
2700
-function _default_wp_die_handler( $message, $title = '', $args = array() ) {
2701
-	$defaults = array( 'response' => 500 );
2700
+function _default_wp_die_handler($message, $title = '', $args = array()) {
2701
+	$defaults = array('response' => 500);
2702 2702
 	$r = wp_parse_args($args, $defaults);
2703 2703
 
2704 2704
 	$have_gettext = function_exists('__');
2705 2705
 
2706
-	if ( function_exists( 'is_wp_error' ) && is_wp_error( $message ) ) {
2707
-		if ( empty( $title ) ) {
2706
+	if (function_exists('is_wp_error') && is_wp_error($message)) {
2707
+		if (empty($title)) {
2708 2708
 			$error_data = $message->get_error_data();
2709
-			if ( is_array( $error_data ) && isset( $error_data['title'] ) )
2709
+			if (is_array($error_data) && isset($error_data['title']))
2710 2710
 				$title = $error_data['title'];
2711 2711
 		}
2712 2712
 		$errors = $message->get_error_messages();
2713
-		switch ( count( $errors ) ) {
2713
+		switch (count($errors)) {
2714 2714
 		case 0 :
2715 2715
 			$message = '';
2716 2716
 			break;
@@ -2718,43 +2718,43 @@  discard block
 block discarded – undo
2718 2718
 			$message = "<p>{$errors[0]}</p>";
2719 2719
 			break;
2720 2720
 		default :
2721
-			$message = "<ul>\n\t\t<li>" . join( "</li>\n\t\t<li>", $errors ) . "</li>\n\t</ul>";
2721
+			$message = "<ul>\n\t\t<li>".join("</li>\n\t\t<li>", $errors)."</li>\n\t</ul>";
2722 2722
 			break;
2723 2723
 		}
2724
-	} elseif ( is_string( $message ) ) {
2724
+	} elseif (is_string($message)) {
2725 2725
 		$message = "<p>$message</p>";
2726 2726
 	}
2727 2727
 
2728
-	if ( isset( $r['back_link'] ) && $r['back_link'] ) {
2729
-		$back_text = $have_gettext? __('&laquo; Back') : '&laquo; Back';
2728
+	if (isset($r['back_link']) && $r['back_link']) {
2729
+		$back_text = $have_gettext ? __('&laquo; Back') : '&laquo; Back';
2730 2730
 		$message .= "\n<p><a href='javascript:history.back()'>$back_text</a></p>";
2731 2731
 	}
2732 2732
 
2733
-	if ( ! did_action( 'admin_head' ) ) :
2734
-		if ( !headers_sent() ) {
2735
-			status_header( $r['response'] );
2733
+	if ( ! did_action('admin_head')) :
2734
+		if ( ! headers_sent()) {
2735
+			status_header($r['response']);
2736 2736
 			nocache_headers();
2737
-			header( 'Content-Type: text/html; charset=utf-8' );
2737
+			header('Content-Type: text/html; charset=utf-8');
2738 2738
 		}
2739 2739
 
2740
-		if ( empty($title) )
2740
+		if (empty($title))
2741 2741
 			$title = $have_gettext ? __('WordPress &rsaquo; Error') : 'WordPress &rsaquo; Error';
2742 2742
 
2743 2743
 		$text_direction = 'ltr';
2744
-		if ( isset($r['text_direction']) && 'rtl' == $r['text_direction'] )
2744
+		if (isset($r['text_direction']) && 'rtl' == $r['text_direction'])
2745 2745
 			$text_direction = 'rtl';
2746
-		elseif ( function_exists( 'is_rtl' ) && is_rtl() )
2746
+		elseif (function_exists('is_rtl') && is_rtl())
2747 2747
 			$text_direction = 'rtl';
2748 2748
 ?>
2749 2749
 <!DOCTYPE html>
2750 2750
 <!-- Ticket #11289, IE bug fix: always pad the error page with enough characters such that it is greater than 512 bytes, even after gzip compression abcdefghijklmnopqrstuvwxyz1234567890aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz11223344556677889900abacbcbdcdcededfefegfgfhghgihihjijikjkjlklkmlmlnmnmononpopoqpqprqrqsrsrtstsubcbcdcdedefefgfabcadefbghicjkldmnoepqrfstugvwxhyz1i234j567k890laabmbccnddeoeffpgghqhiirjjksklltmmnunoovppqwqrrxsstytuuzvvw0wxx1yyz2z113223434455666777889890091abc2def3ghi4jkl5mno6pqr7stu8vwx9yz11aab2bcc3dd4ee5ff6gg7hh8ii9j0jk1kl2lmm3nnoo4p5pq6qrr7ss8tt9uuvv0wwx1x2yyzz13aba4cbcb5dcdc6dedfef8egf9gfh0ghg1ihi2hji3jik4jkj5lkl6kml7mln8mnm9ono
2751 2751
 -->
2752
-<html xmlns="http://www.w3.org/1999/xhtml" <?php if ( function_exists( 'language_attributes' ) && function_exists( 'is_rtl' ) ) language_attributes(); else echo "dir='$text_direction'"; ?>>
2752
+<html xmlns="http://www.w3.org/1999/xhtml" <?php if (function_exists('language_attributes') && function_exists('is_rtl')) language_attributes(); else echo "dir='$text_direction'"; ?>>
2753 2753
 <head>
2754 2754
 	<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
2755 2755
 	<meta name="viewport" content="width=device-width">
2756 2756
 	<?php
2757
-	if ( function_exists( 'wp_no_robots' ) ) {
2757
+	if (function_exists('wp_no_robots')) {
2758 2758
 		wp_no_robots();
2759 2759
 	}
2760 2760
 	?>
@@ -2870,7 +2870,7 @@  discard block
 block discarded – undo
2870 2870
 		}
2871 2871
 
2872 2872
 		<?php
2873
-		if ( 'rtl' == $text_direction ) {
2873
+		if ('rtl' == $text_direction) {
2874 2874
 			echo 'body { font-family: Tahoma, Arial; }';
2875 2875
 		}
2876 2876
 		?>
@@ -2899,15 +2899,15 @@  discard block
 block discarded – undo
2899 2899
  * @param string       $title   Optional. Error title. Default empty.
2900 2900
  * @param string|array $args    Optional. Arguments to control behavior. Default empty array.
2901 2901
  */
2902
-function _xmlrpc_wp_die_handler( $message, $title = '', $args = array() ) {
2902
+function _xmlrpc_wp_die_handler($message, $title = '', $args = array()) {
2903 2903
 	global $wp_xmlrpc_server;
2904
-	$defaults = array( 'response' => 500 );
2904
+	$defaults = array('response' => 500);
2905 2905
 
2906 2906
 	$r = wp_parse_args($args, $defaults);
2907 2907
 
2908
-	if ( $wp_xmlrpc_server ) {
2909
-		$error = new IXR_Error( $r['response'] , $message);
2910
-		$wp_xmlrpc_server->output( $error->getXml() );
2908
+	if ($wp_xmlrpc_server) {
2909
+		$error = new IXR_Error($r['response'], $message);
2910
+		$wp_xmlrpc_server->output($error->getXml());
2911 2911
 	}
2912 2912
 	die();
2913 2913
 }
@@ -2924,19 +2924,19 @@  discard block
 block discarded – undo
2924 2924
  * @param string       $title   Optional. Error title (unused). Default empty.
2925 2925
  * @param string|array $args    Optional. Arguments to control behavior. Default empty array.
2926 2926
  */
2927
-function _ajax_wp_die_handler( $message, $title = '', $args = array() ) {
2927
+function _ajax_wp_die_handler($message, $title = '', $args = array()) {
2928 2928
 	$defaults = array(
2929 2929
 		'response' => 200,
2930 2930
 	);
2931
-	$r = wp_parse_args( $args, $defaults );
2931
+	$r = wp_parse_args($args, $defaults);
2932 2932
 
2933
-	if ( ! headers_sent() && null !== $r['response'] ) {
2934
-		status_header( $r['response'] );
2933
+	if ( ! headers_sent() && null !== $r['response']) {
2934
+		status_header($r['response']);
2935 2935
 	}
2936 2936
 
2937
-	if ( is_scalar( $message ) )
2938
-		die( (string) $message );
2939
-	die( '0' );
2937
+	if (is_scalar($message))
2938
+		die((string) $message);
2939
+	die('0');
2940 2940
 }
2941 2941
 
2942 2942
 /**
@@ -2949,9 +2949,9 @@  discard block
 block discarded – undo
2949 2949
  *
2950 2950
  * @param string $message Optional. Response to print. Default empty.
2951 2951
  */
2952
-function _scalar_wp_die_handler( $message = '' ) {
2953
-	if ( is_scalar( $message ) )
2954
-		die( (string) $message );
2952
+function _scalar_wp_die_handler($message = '') {
2953
+	if (is_scalar($message))
2954
+		die((string) $message);
2955 2955
 	die();
2956 2956
 }
2957 2957
 
@@ -2966,39 +2966,39 @@  discard block
 block discarded – undo
2966 2966
  *                       greater than 0. Default 512.
2967 2967
  * @return string|false The JSON encoded string, or false if it cannot be encoded.
2968 2968
  */
2969
-function wp_json_encode( $data, $options = 0, $depth = 512 ) {
2969
+function wp_json_encode($data, $options = 0, $depth = 512) {
2970 2970
 	/*
2971 2971
 	 * json_encode() has had extra params added over the years.
2972 2972
 	 * $options was added in 5.3, and $depth in 5.5.
2973 2973
 	 * We need to make sure we call it with the correct arguments.
2974 2974
 	 */
2975
-	if ( version_compare( PHP_VERSION, '5.5', '>=' ) ) {
2976
-		$args = array( $data, $options, $depth );
2977
-	} elseif ( version_compare( PHP_VERSION, '5.3', '>=' ) ) {
2978
-		$args = array( $data, $options );
2975
+	if (version_compare(PHP_VERSION, '5.5', '>=')) {
2976
+		$args = array($data, $options, $depth);
2977
+	} elseif (version_compare(PHP_VERSION, '5.3', '>=')) {
2978
+		$args = array($data, $options);
2979 2979
 	} else {
2980
-		$args = array( $data );
2980
+		$args = array($data);
2981 2981
 	}
2982 2982
 
2983 2983
 	// Prepare the data for JSON serialization.
2984
-	$args[0] = _wp_json_prepare_data( $data );
2984
+	$args[0] = _wp_json_prepare_data($data);
2985 2985
 
2986
-	$json = @call_user_func_array( 'json_encode', $args );
2986
+	$json = @call_user_func_array('json_encode', $args);
2987 2987
 
2988 2988
 	// If json_encode() was successful, no need to do more sanity checking.
2989 2989
 	// ... unless we're in an old version of PHP, and json_encode() returned
2990 2990
 	// a string containing 'null'. Then we need to do more sanity checking.
2991
-	if ( false !== $json && ( version_compare( PHP_VERSION, '5.5', '>=' ) || false === strpos( $json, 'null' ) ) )  {
2991
+	if (false !== $json && (version_compare(PHP_VERSION, '5.5', '>=') || false === strpos($json, 'null'))) {
2992 2992
 		return $json;
2993 2993
 	}
2994 2994
 
2995 2995
 	try {
2996
-		$args[0] = _wp_json_sanity_check( $data, $depth );
2997
-	} catch ( Exception $e ) {
2996
+		$args[0] = _wp_json_sanity_check($data, $depth);
2997
+	} catch (Exception $e) {
2998 2998
 		return false;
2999 2999
 	}
3000 3000
 
3001
-	return call_user_func_array( 'json_encode', $args );
3001
+	return call_user_func_array('json_encode', $args);
3002 3002
 }
3003 3003
 
3004 3004
 /**
@@ -3014,49 +3014,49 @@  discard block
 block discarded – undo
3014 3014
  * @param int   $depth Maximum depth to walk through $data. Must be greater than 0.
3015 3015
  * @return mixed The sanitized data that shall be encoded to JSON.
3016 3016
  */
3017
-function _wp_json_sanity_check( $data, $depth ) {
3018
-	if ( $depth < 0 ) {
3019
-		throw new Exception( 'Reached depth limit' );
3017
+function _wp_json_sanity_check($data, $depth) {
3018
+	if ($depth < 0) {
3019
+		throw new Exception('Reached depth limit');
3020 3020
 	}
3021 3021
 
3022
-	if ( is_array( $data ) ) {
3022
+	if (is_array($data)) {
3023 3023
 		$output = array();
3024
-		foreach ( $data as $id => $el ) {
3024
+		foreach ($data as $id => $el) {
3025 3025
 			// Don't forget to sanitize the ID!
3026
-			if ( is_string( $id ) ) {
3027
-				$clean_id = _wp_json_convert_string( $id );
3026
+			if (is_string($id)) {
3027
+				$clean_id = _wp_json_convert_string($id);
3028 3028
 			} else {
3029 3029
 				$clean_id = $id;
3030 3030
 			}
3031 3031
 
3032 3032
 			// Check the element type, so that we're only recursing if we really have to.
3033
-			if ( is_array( $el ) || is_object( $el ) ) {
3034
-				$output[ $clean_id ] = _wp_json_sanity_check( $el, $depth - 1 );
3035
-			} elseif ( is_string( $el ) ) {
3036
-				$output[ $clean_id ] = _wp_json_convert_string( $el );
3033
+			if (is_array($el) || is_object($el)) {
3034
+				$output[$clean_id] = _wp_json_sanity_check($el, $depth - 1);
3035
+			} elseif (is_string($el)) {
3036
+				$output[$clean_id] = _wp_json_convert_string($el);
3037 3037
 			} else {
3038
-				$output[ $clean_id ] = $el;
3038
+				$output[$clean_id] = $el;
3039 3039
 			}
3040 3040
 		}
3041
-	} elseif ( is_object( $data ) ) {
3041
+	} elseif (is_object($data)) {
3042 3042
 		$output = new stdClass;
3043
-		foreach ( $data as $id => $el ) {
3044
-			if ( is_string( $id ) ) {
3045
-				$clean_id = _wp_json_convert_string( $id );
3043
+		foreach ($data as $id => $el) {
3044
+			if (is_string($id)) {
3045
+				$clean_id = _wp_json_convert_string($id);
3046 3046
 			} else {
3047 3047
 				$clean_id = $id;
3048 3048
 			}
3049 3049
 
3050
-			if ( is_array( $el ) || is_object( $el ) ) {
3051
-				$output->$clean_id = _wp_json_sanity_check( $el, $depth - 1 );
3052
-			} elseif ( is_string( $el ) ) {
3053
-				$output->$clean_id = _wp_json_convert_string( $el );
3050
+			if (is_array($el) || is_object($el)) {
3051
+				$output->$clean_id = _wp_json_sanity_check($el, $depth - 1);
3052
+			} elseif (is_string($el)) {
3053
+				$output->$clean_id = _wp_json_convert_string($el);
3054 3054
 			} else {
3055 3055
 				$output->$clean_id = $el;
3056 3056
 			}
3057 3057
 		}
3058
-	} elseif ( is_string( $data ) ) {
3059
-		return _wp_json_convert_string( $data );
3058
+	} elseif (is_string($data)) {
3059
+		return _wp_json_convert_string($data);
3060 3060
 	} else {
3061 3061
 		return $data;
3062 3062
 	}
@@ -3078,21 +3078,21 @@  discard block
 block discarded – undo
3078 3078
  * @param string $string The string which is to be converted.
3079 3079
  * @return string The checked string.
3080 3080
  */
3081
-function _wp_json_convert_string( $string ) {
3081
+function _wp_json_convert_string($string) {
3082 3082
 	static $use_mb = null;
3083
-	if ( is_null( $use_mb ) ) {
3084
-		$use_mb = function_exists( 'mb_convert_encoding' );
3083
+	if (is_null($use_mb)) {
3084
+		$use_mb = function_exists('mb_convert_encoding');
3085 3085
 	}
3086 3086
 
3087
-	if ( $use_mb ) {
3088
-		$encoding = mb_detect_encoding( $string, mb_detect_order(), true );
3089
-		if ( $encoding ) {
3090
-			return mb_convert_encoding( $string, 'UTF-8', $encoding );
3087
+	if ($use_mb) {
3088
+		$encoding = mb_detect_encoding($string, mb_detect_order(), true);
3089
+		if ($encoding) {
3090
+			return mb_convert_encoding($string, 'UTF-8', $encoding);
3091 3091
 		} else {
3092
-			return mb_convert_encoding( $string, 'UTF-8', 'UTF-8' );
3092
+			return mb_convert_encoding($string, 'UTF-8', 'UTF-8');
3093 3093
 		}
3094 3094
 	} else {
3095
-		return wp_check_invalid_utf8( $string, true );
3095
+		return wp_check_invalid_utf8($string, true);
3096 3096
 	}
3097 3097
 }
3098 3098
 
@@ -3108,12 +3108,12 @@  discard block
 block discarded – undo
3108 3108
  * @param mixed $data Native representation.
3109 3109
  * @return bool|int|float|null|string|array Data ready for `json_encode()`.
3110 3110
  */
3111
-function _wp_json_prepare_data( $data ) {
3112
-	if ( ! defined( 'WP_JSON_SERIALIZE_COMPATIBLE' ) || WP_JSON_SERIALIZE_COMPATIBLE === false ) {
3111
+function _wp_json_prepare_data($data) {
3112
+	if ( ! defined('WP_JSON_SERIALIZE_COMPATIBLE') || WP_JSON_SERIALIZE_COMPATIBLE === false) {
3113 3113
 		return $data;
3114 3114
 	}
3115 3115
 
3116
-	switch ( gettype( $data ) ) {
3116
+	switch (gettype($data)) {
3117 3117
 		case 'boolean':
3118 3118
 		case 'integer':
3119 3119
 		case 'double':
@@ -3124,22 +3124,22 @@  discard block
 block discarded – undo
3124 3124
 
3125 3125
 		case 'array':
3126 3126
 			// Arrays must be mapped in case they also return objects.
3127
-			return array_map( '_wp_json_prepare_data', $data );
3127
+			return array_map('_wp_json_prepare_data', $data);
3128 3128
 
3129 3129
 		case 'object':
3130 3130
 			// If this is an incomplete object (__PHP_Incomplete_Class), bail.
3131
-			if ( ! is_object( $data ) ) {
3131
+			if ( ! is_object($data)) {
3132 3132
 				return null;
3133 3133
 			}
3134 3134
 
3135
-			if ( $data instanceof JsonSerializable ) {
3135
+			if ($data instanceof JsonSerializable) {
3136 3136
 				$data = $data->jsonSerialize();
3137 3137
 			} else {
3138
-				$data = get_object_vars( $data );
3138
+				$data = get_object_vars($data);
3139 3139
 			}
3140 3140
 
3141 3141
 			// Now, pass the array (or whatever was returned from jsonSerialize through).
3142
-			return _wp_json_prepare_data( $data );
3142
+			return _wp_json_prepare_data($data);
3143 3143
 
3144 3144
 		default:
3145 3145
 			return null;
@@ -3156,17 +3156,17 @@  discard block
 block discarded – undo
3156 3156
  *                           then print and die.
3157 3157
  * @param int   $status_code The HTTP status code to output.
3158 3158
  */
3159
-function wp_send_json( $response, $status_code = null ) {
3160
-	@header( 'Content-Type: application/json; charset=' . get_option( 'blog_charset' ) );
3161
-	if ( null !== $status_code ) {
3162
-		status_header( $status_code );
3159
+function wp_send_json($response, $status_code = null) {
3160
+	@header('Content-Type: application/json; charset='.get_option('blog_charset'));
3161
+	if (null !== $status_code) {
3162
+		status_header($status_code);
3163 3163
 	}
3164
-	echo wp_json_encode( $response );
3164
+	echo wp_json_encode($response);
3165 3165
 
3166
-	if ( wp_doing_ajax() ) {
3167
-		wp_die( '', '', array(
3166
+	if (wp_doing_ajax()) {
3167
+		wp_die('', '', array(
3168 3168
 			'response' => null,
3169
-		) );
3169
+		));
3170 3170
 	} else {
3171 3171
 		die;
3172 3172
 	}
@@ -3181,13 +3181,13 @@  discard block
 block discarded – undo
3181 3181
  * @param mixed $data        Data to encode as JSON, then print and die.
3182 3182
  * @param int   $status_code The HTTP status code to output.
3183 3183
  */
3184
-function wp_send_json_success( $data = null, $status_code = null ) {
3185
-	$response = array( 'success' => true );
3184
+function wp_send_json_success($data = null, $status_code = null) {
3185
+	$response = array('success' => true);
3186 3186
 
3187
-	if ( isset( $data ) )
3187
+	if (isset($data))
3188 3188
 		$response['data'] = $data;
3189 3189
 
3190
-	wp_send_json( $response, $status_code );
3190
+	wp_send_json($response, $status_code);
3191 3191
 }
3192 3192
 
3193 3193
 /**
@@ -3205,15 +3205,15 @@  discard block
 block discarded – undo
3205 3205
  * @param mixed $data        Data to encode as JSON, then print and die.
3206 3206
  * @param int   $status_code The HTTP status code to output.
3207 3207
  */
3208
-function wp_send_json_error( $data = null, $status_code = null ) {
3209
-	$response = array( 'success' => false );
3208
+function wp_send_json_error($data = null, $status_code = null) {
3209
+	$response = array('success' => false);
3210 3210
 
3211
-	if ( isset( $data ) ) {
3212
-		if ( is_wp_error( $data ) ) {
3211
+	if (isset($data)) {
3212
+		if (is_wp_error($data)) {
3213 3213
 			$result = array();
3214
-			foreach ( $data->errors as $code => $messages ) {
3215
-				foreach ( $messages as $message ) {
3216
-					$result[] = array( 'code' => $code, 'message' => $message );
3214
+			foreach ($data->errors as $code => $messages) {
3215
+				foreach ($messages as $message) {
3216
+					$result[] = array('code' => $code, 'message' => $message);
3217 3217
 				}
3218 3218
 			}
3219 3219
 
@@ -3223,7 +3223,7 @@  discard block
 block discarded – undo
3223 3223
 		}
3224 3224
 	}
3225 3225
 
3226
-	wp_send_json( $response, $status_code );
3226
+	wp_send_json($response, $status_code);
3227 3227
 }
3228 3228
 
3229 3229
 /**
@@ -3238,12 +3238,12 @@  discard block
 block discarded – undo
3238 3238
  * @param string $callback Supplied JSONP callback function.
3239 3239
  * @return bool True if valid callback, otherwise false.
3240 3240
  */
3241
-function wp_check_jsonp_callback( $callback ) {
3242
-	if ( ! is_string( $callback ) ) {
3241
+function wp_check_jsonp_callback($callback) {
3242
+	if ( ! is_string($callback)) {
3243 3243
 		return false;
3244 3244
 	}
3245 3245
 
3246
-	preg_replace( '/[^\w\.]/', '', $callback, -1, $illegal_char_count );
3246
+	preg_replace('/[^\w\.]/', '', $callback, -1, $illegal_char_count);
3247 3247
 
3248 3248
 	return 0 === $illegal_char_count;
3249 3249
 }
@@ -3263,9 +3263,9 @@  discard block
 block discarded – undo
3263 3263
  * @param string $url URL for the home location.
3264 3264
  * @return string Homepage location.
3265 3265
  */
3266
-function _config_wp_home( $url = '' ) {
3267
-	if ( defined( 'WP_HOME' ) )
3268
-		return untrailingslashit( WP_HOME );
3266
+function _config_wp_home($url = '') {
3267
+	if (defined('WP_HOME'))
3268
+		return untrailingslashit(WP_HOME);
3269 3269
 	return $url;
3270 3270
 }
3271 3271
 
@@ -3284,9 +3284,9 @@  discard block
 block discarded – undo
3284 3284
  * @param string $url URL to set the WordPress site location.
3285 3285
  * @return string The WordPress Site URL.
3286 3286
  */
3287
-function _config_wp_siteurl( $url = '' ) {
3288
-	if ( defined( 'WP_SITEURL' ) )
3289
-		return untrailingslashit( WP_SITEURL );
3287
+function _config_wp_siteurl($url = '') {
3288
+	if (defined('WP_SITEURL'))
3289
+		return untrailingslashit(WP_SITEURL);
3290 3290
 	return $url;
3291 3291
 }
3292 3292
 
@@ -3297,7 +3297,7 @@  discard block
 block discarded – undo
3297 3297
  * @access private
3298 3298
  */
3299 3299
 function _delete_option_fresh_site() {
3300
-	update_option( 'fresh_site', 0 );
3300
+	update_option('fresh_site', 0);
3301 3301
 }
3302 3302
 
3303 3303
 /**
@@ -3317,16 +3317,16 @@  discard block
 block discarded – undo
3317 3317
  * @param array $mce_init MCE settings array.
3318 3318
  * @return array Direction set for 'rtl', if needed by locale.
3319 3319
  */
3320
-function _mce_set_direction( $mce_init ) {
3321
-	if ( is_rtl() ) {
3320
+function _mce_set_direction($mce_init) {
3321
+	if (is_rtl()) {
3322 3322
 		$mce_init['directionality'] = 'rtl';
3323 3323
 		$mce_init['rtl_ui'] = true;
3324 3324
 
3325
-		if ( ! empty( $mce_init['plugins'] ) && strpos( $mce_init['plugins'], 'directionality' ) === false ) {
3325
+		if ( ! empty($mce_init['plugins']) && strpos($mce_init['plugins'], 'directionality') === false) {
3326 3326
 			$mce_init['plugins'] .= ',directionality';
3327 3327
 		}
3328 3328
 
3329
-		if ( ! empty( $mce_init['toolbar1'] ) && ! preg_match( '/\bltr\b/', $mce_init['toolbar1'] ) ) {
3329
+		if ( ! empty($mce_init['toolbar1']) && ! preg_match('/\bltr\b/', $mce_init['toolbar1'])) {
3330 3330
 			$mce_init['toolbar1'] .= ',ltr';
3331 3331
 		}
3332 3332
 	}
@@ -3361,10 +3361,10 @@  discard block
 block discarded – undo
3361 3361
 	global $wpsmiliestrans, $wp_smiliessearch;
3362 3362
 
3363 3363
 	// don't bother setting up smilies if they are disabled
3364
-	if ( !get_option( 'use_smilies' ) )
3364
+	if ( ! get_option('use_smilies'))
3365 3365
 		return;
3366 3366
 
3367
-	if ( !isset( $wpsmiliestrans ) ) {
3367
+	if ( ! isset($wpsmiliestrans)) {
3368 3368
 		$wpsmiliestrans = array(
3369 3369
 		':mrgreen:' => 'mrgreen.png',
3370 3370
 		':neutral:' => "\xf0\x9f\x98\x90",
@@ -3440,28 +3440,28 @@  discard block
 block discarded – undo
3440 3440
 	$spaces = wp_spaces_regexp();
3441 3441
 
3442 3442
 	// Begin first "subpattern"
3443
-	$wp_smiliessearch = '/(?<=' . $spaces . '|^)';
3443
+	$wp_smiliessearch = '/(?<='.$spaces.'|^)';
3444 3444
 
3445 3445
 	$subchar = '';
3446
-	foreach ( (array) $wpsmiliestrans as $smiley => $img ) {
3446
+	foreach ((array) $wpsmiliestrans as $smiley => $img) {
3447 3447
 		$firstchar = substr($smiley, 0, 1);
3448 3448
 		$rest = substr($smiley, 1);
3449 3449
 
3450 3450
 		// new subpattern?
3451 3451
 		if ($firstchar != $subchar) {
3452 3452
 			if ($subchar != '') {
3453
-				$wp_smiliessearch .= ')(?=' . $spaces . '|$)';  // End previous "subpattern"
3454
-				$wp_smiliessearch .= '|(?<=' . $spaces . '|^)'; // Begin another "subpattern"
3453
+				$wp_smiliessearch .= ')(?='.$spaces.'|$)'; // End previous "subpattern"
3454
+				$wp_smiliessearch .= '|(?<='.$spaces.'|^)'; // Begin another "subpattern"
3455 3455
 			}
3456 3456
 			$subchar = $firstchar;
3457
-			$wp_smiliessearch .= preg_quote($firstchar, '/') . '(?:';
3457
+			$wp_smiliessearch .= preg_quote($firstchar, '/').'(?:';
3458 3458
 		} else {
3459 3459
 			$wp_smiliessearch .= '|';
3460 3460
 		}
3461 3461
 		$wp_smiliessearch .= preg_quote($rest, '/');
3462 3462
 	}
3463 3463
 
3464
-	$wp_smiliessearch .= ')(?=' . $spaces . '|$)/m';
3464
+	$wp_smiliessearch .= ')(?='.$spaces.'|$)/m';
3465 3465
 
3466 3466
 }
3467 3467
 
@@ -3478,16 +3478,16 @@  discard block
 block discarded – undo
3478 3478
  * @param array               $defaults Optional. Array that serves as the defaults. Default empty.
3479 3479
  * @return array Merged user defined values with defaults.
3480 3480
  */
3481
-function wp_parse_args( $args, $defaults = '' ) {
3482
-	if ( is_object( $args ) )
3483
-		$r = get_object_vars( $args );
3484
-	elseif ( is_array( $args ) )
3485
-		$r =& $args;
3481
+function wp_parse_args($args, $defaults = '') {
3482
+	if (is_object($args))
3483
+		$r = get_object_vars($args);
3484
+	elseif (is_array($args))
3485
+		$r = & $args;
3486 3486
 	else
3487
-		wp_parse_str( $args, $r );
3487
+		wp_parse_str($args, $r);
3488 3488
 
3489
-	if ( is_array( $defaults ) )
3490
-		return array_merge( $defaults, $r );
3489
+	if (is_array($defaults))
3490
+		return array_merge($defaults, $r);
3491 3491
 	return $r;
3492 3492
 }
3493 3493
 
@@ -3499,8 +3499,8 @@  discard block
 block discarded – undo
3499 3499
  * @param array|string $list List of ids.
3500 3500
  * @return array Sanitized array of IDs.
3501 3501
  */
3502
-function wp_parse_id_list( $list ) {
3503
-	if ( !is_array($list) )
3502
+function wp_parse_id_list($list) {
3503
+	if ( ! is_array($list))
3504 3504
 		$list = preg_split('/[\s,]+/', $list);
3505 3505
 
3506 3506
 	return array_unique(array_map('absint', $list));
@@ -3514,16 +3514,16 @@  discard block
 block discarded – undo
3514 3514
  * @param  array|string $list List of slugs.
3515 3515
  * @return array Sanitized array of slugs.
3516 3516
  */
3517
-function wp_parse_slug_list( $list ) {
3518
-	if ( ! is_array( $list ) ) {
3519
-		$list = preg_split( '/[\s,]+/', $list );
3517
+function wp_parse_slug_list($list) {
3518
+	if ( ! is_array($list)) {
3519
+		$list = preg_split('/[\s,]+/', $list);
3520 3520
 	}
3521 3521
 
3522
-	foreach ( $list as $key => $value ) {
3523
-		$list[ $key ] = sanitize_title( $value );
3522
+	foreach ($list as $key => $value) {
3523
+		$list[$key] = sanitize_title($value);
3524 3524
 	}
3525 3525
 
3526
-	return array_unique( $list );
3526
+	return array_unique($list);
3527 3527
 }
3528 3528
 
3529 3529
 /**
@@ -3535,11 +3535,11 @@  discard block
 block discarded – undo
3535 3535
  * @param array $keys  The list of keys.
3536 3536
  * @return array The array slice.
3537 3537
  */
3538
-function wp_array_slice_assoc( $array, $keys ) {
3538
+function wp_array_slice_assoc($array, $keys) {
3539 3539
 	$slice = array();
3540
-	foreach ( $keys as $key )
3541
-		if ( isset( $array[ $key ] ) )
3542
-			$slice[ $key ] = $array[ $key ];
3540
+	foreach ($keys as $key)
3541
+		if (isset($array[$key]))
3542
+			$slice[$key] = $array[$key];
3543 3543
 
3544 3544
 	return $slice;
3545 3545
 }
@@ -3552,14 +3552,14 @@  discard block
 block discarded – undo
3552 3552
  * @param mixed $data Variable to check.
3553 3553
  * @return bool Whether the variable is a list.
3554 3554
  */
3555
-function wp_is_numeric_array( $data ) {
3556
-	if ( ! is_array( $data ) ) {
3555
+function wp_is_numeric_array($data) {
3556
+	if ( ! is_array($data)) {
3557 3557
 		return false;
3558 3558
 	}
3559 3559
 
3560
-	$keys = array_keys( $data );
3561
-	$string_keys = array_filter( $keys, 'is_string' );
3562
-	return count( $string_keys ) === 0;
3560
+	$keys = array_keys($data);
3561
+	$string_keys = array_filter($keys, 'is_string');
3562
+	return count($string_keys) === 0;
3563 3563
 }
3564 3564
 
3565 3565
 /**
@@ -3579,17 +3579,17 @@  discard block
 block discarded – undo
3579 3579
  *                              Default false.
3580 3580
  * @return array A list of objects or object fields.
3581 3581
  */
3582
-function wp_filter_object_list( $list, $args = array(), $operator = 'and', $field = false ) {
3583
-	if ( ! is_array( $list ) ) {
3582
+function wp_filter_object_list($list, $args = array(), $operator = 'and', $field = false) {
3583
+	if ( ! is_array($list)) {
3584 3584
 		return array();
3585 3585
 	}
3586 3586
 
3587
-	$util = new WP_List_Util( $list );
3587
+	$util = new WP_List_Util($list);
3588 3588
 
3589
-	$util->filter( $args, $operator );
3589
+	$util->filter($args, $operator);
3590 3590
 
3591
-	if ( $field ) {
3592
-		$util->pluck( $field );
3591
+	if ($field) {
3592
+		$util->pluck($field);
3593 3593
 	}
3594 3594
 
3595 3595
 	return $util->get_output();
@@ -3610,13 +3610,13 @@  discard block
 block discarded – undo
3610 3610
  *                         match. Default 'AND'.
3611 3611
  * @return array Array of found values.
3612 3612
  */
3613
-function wp_list_filter( $list, $args = array(), $operator = 'AND' ) {
3614
-	if ( ! is_array( $list ) ) {
3613
+function wp_list_filter($list, $args = array(), $operator = 'AND') {
3614
+	if ( ! is_array($list)) {
3615 3615
 		return array();
3616 3616
 	}
3617 3617
 
3618
-	$util = new WP_List_Util( $list );
3619
-	return $util->filter( $args, $operator );
3618
+	$util = new WP_List_Util($list);
3619
+	return $util->filter($args, $operator);
3620 3620
 }
3621 3621
 
3622 3622
 /**
@@ -3637,9 +3637,9 @@  discard block
 block discarded – undo
3637 3637
  *               corresponding to `$index_key`. If `$index_key` is null, array keys from the original
3638 3638
  *               `$list` will be preserved in the results.
3639 3639
  */
3640
-function wp_list_pluck( $list, $field, $index_key = null ) {
3641
-	$util = new WP_List_Util( $list );
3642
-	return $util->pluck( $field, $index_key );
3640
+function wp_list_pluck($list, $field, $index_key = null) {
3641
+	$util = new WP_List_Util($list);
3642
+	return $util->pluck($field, $index_key);
3643 3643
 }
3644 3644
 
3645 3645
 /**
@@ -3655,13 +3655,13 @@  discard block
 block discarded – undo
3655 3655
  * @param bool         $preserve_keys Optional. Whether to preserve keys. Default false.
3656 3656
  * @return array The sorted array.
3657 3657
  */
3658
-function wp_list_sort( $list, $orderby = array(), $order = 'ASC', $preserve_keys = false ) {
3659
-	if ( ! is_array( $list ) ) {
3658
+function wp_list_sort($list, $orderby = array(), $order = 'ASC', $preserve_keys = false) {
3659
+	if ( ! is_array($list)) {
3660 3660
 		return array();
3661 3661
 	}
3662 3662
 
3663
-	$util = new WP_List_Util( $list );
3664
-	return $util->sort( $orderby, $order, $preserve_keys );
3663
+	$util = new WP_List_Util($list);
3664
+	return $util->sort($orderby, $order, $preserve_keys);
3665 3665
 }
3666 3666
 
3667 3667
 /**
@@ -3684,13 +3684,13 @@  discard block
 block discarded – undo
3684 3684
 	 * @param bool $wp_maybe_load_widgets Whether to load the Widgets library.
3685 3685
 	 *                                    Default true.
3686 3686
 	 */
3687
-	if ( ! apply_filters( 'load_default_widgets', true ) ) {
3687
+	if ( ! apply_filters('load_default_widgets', true)) {
3688 3688
 		return;
3689 3689
 	}
3690 3690
 
3691
-	require_once( ABSPATH . WPINC . '/default-widgets.php' );
3691
+	require_once(ABSPATH.WPINC.'/default-widgets.php');
3692 3692
 
3693
-	add_action( '_admin_menu', 'wp_widgets_add_menu' );
3693
+	add_action('_admin_menu', 'wp_widgets_add_menu');
3694 3694
 }
3695 3695
 
3696 3696
 /**
@@ -3703,11 +3703,11 @@  discard block
 block discarded – undo
3703 3703
 function wp_widgets_add_menu() {
3704 3704
 	global $submenu;
3705 3705
 
3706
-	if ( ! current_theme_supports( 'widgets' ) )
3706
+	if ( ! current_theme_supports('widgets'))
3707 3707
 		return;
3708 3708
 
3709
-	$submenu['themes.php'][7] = array( __( 'Widgets' ), 'edit_theme_options', 'widgets.php' );
3710
-	ksort( $submenu['themes.php'], SORT_NUMERIC );
3709
+	$submenu['themes.php'][7] = array(__('Widgets'), 'edit_theme_options', 'widgets.php');
3710
+	ksort($submenu['themes.php'], SORT_NUMERIC);
3711 3711
 }
3712 3712
 
3713 3713
 /**
@@ -3719,7 +3719,7 @@  discard block
 block discarded – undo
3719 3719
  */
3720 3720
 function wp_ob_end_flush_all() {
3721 3721
 	$levels = ob_get_level();
3722
-	for ($i=0; $i<$levels; $i++)
3722
+	for ($i = 0; $i < $levels; $i++)
3723 3723
 		ob_end_flush();
3724 3724
 }
3725 3725
 
@@ -3747,29 +3747,29 @@  discard block
 block discarded – undo
3747 3747
 	wp_load_translations_early();
3748 3748
 
3749 3749
 	// Load custom DB error template, if present.
3750
-	if ( file_exists( WP_CONTENT_DIR . '/db-error.php' ) ) {
3751
-		require_once( WP_CONTENT_DIR . '/db-error.php' );
3750
+	if (file_exists(WP_CONTENT_DIR.'/db-error.php')) {
3751
+		require_once(WP_CONTENT_DIR.'/db-error.php');
3752 3752
 		die();
3753 3753
 	}
3754 3754
 
3755 3755
 	// If installing or in the admin, provide the verbose message.
3756
-	if ( wp_installing() || defined( 'WP_ADMIN' ) )
3756
+	if (wp_installing() || defined('WP_ADMIN'))
3757 3757
 		wp_die($wpdb->error);
3758 3758
 
3759 3759
 	// Otherwise, be terse.
3760
-	status_header( 500 );
3760
+	status_header(500);
3761 3761
 	nocache_headers();
3762
-	header( 'Content-Type: text/html; charset=utf-8' );
3762
+	header('Content-Type: text/html; charset=utf-8');
3763 3763
 ?>
3764 3764
 <!DOCTYPE html>
3765
-<html xmlns="http://www.w3.org/1999/xhtml"<?php if ( is_rtl() ) echo ' dir="rtl"'; ?>>
3765
+<html xmlns="http://www.w3.org/1999/xhtml"<?php if (is_rtl()) echo ' dir="rtl"'; ?>>
3766 3766
 <head>
3767 3767
 <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
3768
-	<title><?php _e( 'Database Error' ); ?></title>
3768
+	<title><?php _e('Database Error'); ?></title>
3769 3769
 
3770 3770
 </head>
3771 3771
 <body>
3772
-	<h1><?php _e( 'Error establishing a database connection' ); ?></h1>
3772
+	<h1><?php _e('Error establishing a database connection'); ?></h1>
3773 3773
 </body>
3774 3774
 </html>
3775 3775
 <?php
@@ -3784,8 +3784,8 @@  discard block
 block discarded – undo
3784 3784
  * @param mixed $maybeint Data you wish to have converted to a non-negative integer.
3785 3785
  * @return int A non-negative integer.
3786 3786
  */
3787
-function absint( $maybeint ) {
3788
-	return abs( intval( $maybeint ) );
3787
+function absint($maybeint) {
3788
+	return abs(intval($maybeint));
3789 3789
 }
3790 3790
 
3791 3791
 /**
@@ -3806,7 +3806,7 @@  discard block
 block discarded – undo
3806 3806
  * @param string $version     The version of WordPress that deprecated the function.
3807 3807
  * @param string $replacement Optional. The function that should have been called. Default null.
3808 3808
  */
3809
-function _deprecated_function( $function, $version, $replacement = null ) {
3809
+function _deprecated_function($function, $version, $replacement = null) {
3810 3810
 
3811 3811
 	/**
3812 3812
 	 * Fires when a deprecated function is called.
@@ -3817,7 +3817,7 @@  discard block
 block discarded – undo
3817 3817
 	 * @param string $replacement The function that should have been called.
3818 3818
 	 * @param string $version     The version of WordPress that deprecated the function.
3819 3819
 	 */
3820
-	do_action( 'deprecated_function_run', $function, $replacement, $version );
3820
+	do_action('deprecated_function_run', $function, $replacement, $version);
3821 3821
 
3822 3822
 	/**
3823 3823
 	 * Filters whether to trigger an error for deprecated functions.
@@ -3826,20 +3826,20 @@  discard block
 block discarded – undo
3826 3826
 	 *
3827 3827
 	 * @param bool $trigger Whether to trigger the error for deprecated functions. Default true.
3828 3828
 	 */
3829
-	if ( WP_DEBUG && apply_filters( 'deprecated_function_trigger_error', true ) ) {
3830
-		if ( function_exists( '__' ) ) {
3831
-			if ( ! is_null( $replacement ) ) {
3829
+	if (WP_DEBUG && apply_filters('deprecated_function_trigger_error', true)) {
3830
+		if (function_exists('__')) {
3831
+			if ( ! is_null($replacement)) {
3832 3832
 				/* translators: 1: PHP function name, 2: version number, 3: alternative function name */
3833
-				trigger_error( sprintf( __('%1$s is <strong>deprecated</strong> since version %2$s! Use %3$s instead.'), $function, $version, $replacement ) );
3833
+				trigger_error(sprintf(__('%1$s is <strong>deprecated</strong> since version %2$s! Use %3$s instead.'), $function, $version, $replacement));
3834 3834
 			} else {
3835 3835
 				/* translators: 1: PHP function name, 2: version number */
3836
-				trigger_error( sprintf( __('%1$s is <strong>deprecated</strong> since version %2$s with no alternative available.'), $function, $version ) );
3836
+				trigger_error(sprintf(__('%1$s is <strong>deprecated</strong> since version %2$s with no alternative available.'), $function, $version));
3837 3837
 			}
3838 3838
 		} else {
3839
-			if ( ! is_null( $replacement ) ) {
3840
-				trigger_error( sprintf( '%1$s is <strong>deprecated</strong> since version %2$s! Use %3$s instead.', $function, $version, $replacement ) );
3839
+			if ( ! is_null($replacement)) {
3840
+				trigger_error(sprintf('%1$s is <strong>deprecated</strong> since version %2$s! Use %3$s instead.', $function, $version, $replacement));
3841 3841
 			} else {
3842
-				trigger_error( sprintf( '%1$s is <strong>deprecated</strong> since version %2$s with no alternative available.', $function, $version ) );
3842
+				trigger_error(sprintf('%1$s is <strong>deprecated</strong> since version %2$s with no alternative available.', $function, $version));
3843 3843
 			}
3844 3844
 		}
3845 3845
 	}
@@ -3865,7 +3865,7 @@  discard block
 block discarded – undo
3865 3865
  * @param string $parent_class Optional. The parent class calling the deprecated constructor.
3866 3866
  *                             Default empty string.
3867 3867
  */
3868
-function _deprecated_constructor( $class, $version, $parent_class = '' ) {
3868
+function _deprecated_constructor($class, $version, $parent_class = '') {
3869 3869
 
3870 3870
 	/**
3871 3871
 	 * Fires when a deprecated constructor is called.
@@ -3877,7 +3877,7 @@  discard block
 block discarded – undo
3877 3877
 	 * @param string $version      The version of WordPress that deprecated the function.
3878 3878
 	 * @param string $parent_class The parent class calling the deprecated constructor.
3879 3879
 	 */
3880
-	do_action( 'deprecated_constructor_run', $class, $version, $parent_class );
3880
+	do_action('deprecated_constructor_run', $class, $version, $parent_class);
3881 3881
 
3882 3882
 	/**
3883 3883
 	 * Filters whether to trigger an error for deprecated functions.
@@ -3888,24 +3888,24 @@  discard block
 block discarded – undo
3888 3888
 	 *
3889 3889
 	 * @param bool $trigger Whether to trigger the error for deprecated functions. Default true.
3890 3890
 	 */
3891
-	if ( WP_DEBUG && apply_filters( 'deprecated_constructor_trigger_error', true ) ) {
3892
-		if ( function_exists( '__' ) ) {
3893
-			if ( ! empty( $parent_class ) ) {
3891
+	if (WP_DEBUG && apply_filters('deprecated_constructor_trigger_error', true)) {
3892
+		if (function_exists('__')) {
3893
+			if ( ! empty($parent_class)) {
3894 3894
 				/* translators: 1: PHP class name, 2: PHP parent class name, 3: version number, 4: __construct() method */
3895
-				trigger_error( sprintf( __( 'The called constructor method for %1$s in %2$s is <strong>deprecated</strong> since version %3$s! Use %4$s instead.' ),
3896
-					$class, $parent_class, $version, '<pre>__construct()</pre>' ) );
3895
+				trigger_error(sprintf(__('The called constructor method for %1$s in %2$s is <strong>deprecated</strong> since version %3$s! Use %4$s instead.'),
3896
+					$class, $parent_class, $version, '<pre>__construct()</pre>'));
3897 3897
 			} else {
3898 3898
 				/* translators: 1: PHP class name, 2: version number, 3: __construct() method */
3899
-				trigger_error( sprintf( __( 'The called constructor method for %1$s is <strong>deprecated</strong> since version %2$s! Use %3$s instead.' ),
3900
-					$class, $version, '<pre>__construct()</pre>' ) );
3899
+				trigger_error(sprintf(__('The called constructor method for %1$s is <strong>deprecated</strong> since version %2$s! Use %3$s instead.'),
3900
+					$class, $version, '<pre>__construct()</pre>'));
3901 3901
 			}
3902 3902
 		} else {
3903
-			if ( ! empty( $parent_class ) ) {
3904
-				trigger_error( sprintf( 'The called constructor method for %1$s in %2$s is <strong>deprecated</strong> since version %3$s! Use %4$s instead.',
3905
-					$class, $parent_class, $version, '<pre>__construct()</pre>' ) );
3903
+			if ( ! empty($parent_class)) {
3904
+				trigger_error(sprintf('The called constructor method for %1$s in %2$s is <strong>deprecated</strong> since version %3$s! Use %4$s instead.',
3905
+					$class, $parent_class, $version, '<pre>__construct()</pre>'));
3906 3906
 			} else {
3907
-				trigger_error( sprintf( 'The called constructor method for %1$s is <strong>deprecated</strong> since version %2$s! Use %3$s instead.',
3908
-					$class, $version, '<pre>__construct()</pre>' ) );
3907
+				trigger_error(sprintf('The called constructor method for %1$s is <strong>deprecated</strong> since version %2$s! Use %3$s instead.',
3908
+					$class, $version, '<pre>__construct()</pre>'));
3909 3909
 			}
3910 3910
 		}
3911 3911
 	}
@@ -3932,7 +3932,7 @@  discard block
 block discarded – undo
3932 3932
  *                            Default null.
3933 3933
  * @param string $message     Optional. A message regarding the change. Default empty.
3934 3934
  */
3935
-function _deprecated_file( $file, $version, $replacement = null, $message = '' ) {
3935
+function _deprecated_file($file, $version, $replacement = null, $message = '') {
3936 3936
 
3937 3937
 	/**
3938 3938
 	 * Fires when a deprecated file is called.
@@ -3944,7 +3944,7 @@  discard block
 block discarded – undo
3944 3944
 	 * @param string $version     The version of WordPress that deprecated the file.
3945 3945
 	 * @param string $message     A message regarding the change.
3946 3946
 	 */
3947
-	do_action( 'deprecated_file_included', $file, $replacement, $version, $message );
3947
+	do_action('deprecated_file_included', $file, $replacement, $version, $message);
3948 3948
 
3949 3949
 	/**
3950 3950
 	 * Filters whether to trigger an error for deprecated files.
@@ -3953,21 +3953,21 @@  discard block
 block discarded – undo
3953 3953
 	 *
3954 3954
 	 * @param bool $trigger Whether to trigger the error for deprecated files. Default true.
3955 3955
 	 */
3956
-	if ( WP_DEBUG && apply_filters( 'deprecated_file_trigger_error', true ) ) {
3957
-		$message = empty( $message ) ? '' : ' ' . $message;
3958
-		if ( function_exists( '__' ) ) {
3959
-			if ( ! is_null( $replacement ) ) {
3956
+	if (WP_DEBUG && apply_filters('deprecated_file_trigger_error', true)) {
3957
+		$message = empty($message) ? '' : ' '.$message;
3958
+		if (function_exists('__')) {
3959
+			if ( ! is_null($replacement)) {
3960 3960
 				/* translators: 1: PHP file name, 2: version number, 3: alternative file name */
3961
-				trigger_error( sprintf( __('%1$s is <strong>deprecated</strong> since version %2$s! Use %3$s instead.'), $file, $version, $replacement ) . $message );
3961
+				trigger_error(sprintf(__('%1$s is <strong>deprecated</strong> since version %2$s! Use %3$s instead.'), $file, $version, $replacement).$message);
3962 3962
 			} else {
3963 3963
 				/* translators: 1: PHP file name, 2: version number */
3964
-				trigger_error( sprintf( __('%1$s is <strong>deprecated</strong> since version %2$s with no alternative available.'), $file, $version ) . $message );
3964
+				trigger_error(sprintf(__('%1$s is <strong>deprecated</strong> since version %2$s with no alternative available.'), $file, $version).$message);
3965 3965
 			}
3966 3966
 		} else {
3967
-			if ( ! is_null( $replacement ) ) {
3968
-				trigger_error( sprintf( '%1$s is <strong>deprecated</strong> since version %2$s! Use %3$s instead.', $file, $version, $replacement ) . $message );
3967
+			if ( ! is_null($replacement)) {
3968
+				trigger_error(sprintf('%1$s is <strong>deprecated</strong> since version %2$s! Use %3$s instead.', $file, $version, $replacement).$message);
3969 3969
 			} else {
3970
-				trigger_error( sprintf( '%1$s is <strong>deprecated</strong> since version %2$s with no alternative available.', $file, $version ) . $message );
3970
+				trigger_error(sprintf('%1$s is <strong>deprecated</strong> since version %2$s with no alternative available.', $file, $version).$message);
3971 3971
 			}
3972 3972
 		}
3973 3973
 	}
@@ -3998,7 +3998,7 @@  discard block
 block discarded – undo
3998 3998
  * @param string $version  The version of WordPress that deprecated the argument used.
3999 3999
  * @param string $message  Optional. A message regarding the change. Default null.
4000 4000
  */
4001
-function _deprecated_argument( $function, $version, $message = null ) {
4001
+function _deprecated_argument($function, $version, $message = null) {
4002 4002
 
4003 4003
 	/**
4004 4004
 	 * Fires when a deprecated argument is called.
@@ -4009,7 +4009,7 @@  discard block
 block discarded – undo
4009 4009
 	 * @param string $message  A message regarding the change.
4010 4010
 	 * @param string $version  The version of WordPress that deprecated the argument used.
4011 4011
 	 */
4012
-	do_action( 'deprecated_argument_run', $function, $message, $version );
4012
+	do_action('deprecated_argument_run', $function, $message, $version);
4013 4013
 
4014 4014
 	/**
4015 4015
 	 * Filters whether to trigger an error for deprecated arguments.
@@ -4018,20 +4018,20 @@  discard block
 block discarded – undo
4018 4018
 	 *
4019 4019
 	 * @param bool $trigger Whether to trigger the error for deprecated arguments. Default true.
4020 4020
 	 */
4021
-	if ( WP_DEBUG && apply_filters( 'deprecated_argument_trigger_error', true ) ) {
4022
-		if ( function_exists( '__' ) ) {
4023
-			if ( ! is_null( $message ) ) {
4021
+	if (WP_DEBUG && apply_filters('deprecated_argument_trigger_error', true)) {
4022
+		if (function_exists('__')) {
4023
+			if ( ! is_null($message)) {
4024 4024
 				/* translators: 1: PHP function name, 2: version number, 3: optional message regarding the change */
4025
-				trigger_error( sprintf( __('%1$s was called with an argument that is <strong>deprecated</strong> since version %2$s! %3$s'), $function, $version, $message ) );
4025
+				trigger_error(sprintf(__('%1$s was called with an argument that is <strong>deprecated</strong> since version %2$s! %3$s'), $function, $version, $message));
4026 4026
 			} else {
4027 4027
 				/* translators: 1: PHP function name, 2: version number */
4028
-				trigger_error( sprintf( __('%1$s was called with an argument that is <strong>deprecated</strong> since version %2$s with no alternative available.'), $function, $version ) );
4028
+				trigger_error(sprintf(__('%1$s was called with an argument that is <strong>deprecated</strong> since version %2$s with no alternative available.'), $function, $version));
4029 4029
 			}
4030 4030
 		} else {
4031
-			if ( ! is_null( $message ) ) {
4032
-				trigger_error( sprintf( '%1$s was called with an argument that is <strong>deprecated</strong> since version %2$s! %3$s', $function, $version, $message ) );
4031
+			if ( ! is_null($message)) {
4032
+				trigger_error(sprintf('%1$s was called with an argument that is <strong>deprecated</strong> since version %2$s! %3$s', $function, $version, $message));
4033 4033
 			} else {
4034
-				trigger_error( sprintf( '%1$s was called with an argument that is <strong>deprecated</strong> since version %2$s with no alternative available.', $function, $version ) );
4034
+				trigger_error(sprintf('%1$s was called with an argument that is <strong>deprecated</strong> since version %2$s with no alternative available.', $function, $version));
4035 4035
 			}
4036 4036
 		}
4037 4037
 	}
@@ -4056,7 +4056,7 @@  discard block
 block discarded – undo
4056 4056
  * @param string $replacement Optional. The hook that should have been used.
4057 4057
  * @param string $message     Optional. A message regarding the change.
4058 4058
  */
4059
-function _deprecated_hook( $hook, $version, $replacement = null, $message = null ) {
4059
+function _deprecated_hook($hook, $version, $replacement = null, $message = null) {
4060 4060
 	/**
4061 4061
 	 * Fires when a deprecated hook is called.
4062 4062
 	 *
@@ -4067,7 +4067,7 @@  discard block
 block discarded – undo
4067 4067
 	 * @param string $version     The version of WordPress that deprecated the argument used.
4068 4068
 	 * @param string $message     A message regarding the change.
4069 4069
 	 */
4070
-	do_action( 'deprecated_hook_run', $hook, $replacement, $version, $message );
4070
+	do_action('deprecated_hook_run', $hook, $replacement, $version, $message);
4071 4071
 
4072 4072
 	/**
4073 4073
 	 * Filters whether to trigger deprecated hook errors.
@@ -4077,14 +4077,14 @@  discard block
 block discarded – undo
4077 4077
 	 * @param bool $trigger Whether to trigger deprecated hook errors. Requires
4078 4078
 	 *                      `WP_DEBUG` to be defined true.
4079 4079
 	 */
4080
-	if ( WP_DEBUG && apply_filters( 'deprecated_hook_trigger_error', true ) ) {
4081
-		$message = empty( $message ) ? '' : ' ' . $message;
4082
-		if ( ! is_null( $replacement ) ) {
4080
+	if (WP_DEBUG && apply_filters('deprecated_hook_trigger_error', true)) {
4081
+		$message = empty($message) ? '' : ' '.$message;
4082
+		if ( ! is_null($replacement)) {
4083 4083
 			/* translators: 1: WordPress hook name, 2: version number, 3: alternative hook name */
4084
-			trigger_error( sprintf( __( '%1$s is <strong>deprecated</strong> since version %2$s! Use %3$s instead.' ), $hook, $version, $replacement ) . $message );
4084
+			trigger_error(sprintf(__('%1$s is <strong>deprecated</strong> since version %2$s! Use %3$s instead.'), $hook, $version, $replacement).$message);
4085 4085
 		} else {
4086 4086
 			/* translators: 1: WordPress hook name, 2: version number */
4087
-			trigger_error( sprintf( __( '%1$s is <strong>deprecated</strong> since version %2$s with no alternative available.' ), $hook, $version ) . $message );
4087
+			trigger_error(sprintf(__('%1$s is <strong>deprecated</strong> since version %2$s with no alternative available.'), $hook, $version).$message);
4088 4088
 		}
4089 4089
 	}
4090 4090
 }
@@ -4105,7 +4105,7 @@  discard block
 block discarded – undo
4105 4105
  * @param string $message  A message explaining what has been done incorrectly.
4106 4106
  * @param string $version  The version of WordPress where the message was added.
4107 4107
  */
4108
-function _doing_it_wrong( $function, $message, $version ) {
4108
+function _doing_it_wrong($function, $message, $version) {
4109 4109
 
4110 4110
 	/**
4111 4111
 	 * Fires when the given function is being used incorrectly.
@@ -4116,7 +4116,7 @@  discard block
 block discarded – undo
4116 4116
 	 * @param string $message  A message explaining what has been done incorrectly.
4117 4117
 	 * @param string $version  The version of WordPress where the message was added.
4118 4118
 	 */
4119
-	do_action( 'doing_it_wrong_run', $function, $message, $version );
4119
+	do_action('doing_it_wrong_run', $function, $message, $version);
4120 4120
 
4121 4121
 	/**
4122 4122
 	 * Filters whether to trigger an error for _doing_it_wrong() calls.
@@ -4125,30 +4125,30 @@  discard block
 block discarded – undo
4125 4125
 	 *
4126 4126
 	 * @param bool $trigger Whether to trigger the error for _doing_it_wrong() calls. Default true.
4127 4127
 	 */
4128
-	if ( WP_DEBUG && apply_filters( 'doing_it_wrong_trigger_error', true ) ) {
4129
-		if ( function_exists( '__' ) ) {
4130
-			if ( is_null( $version ) ) {
4128
+	if (WP_DEBUG && apply_filters('doing_it_wrong_trigger_error', true)) {
4129
+		if (function_exists('__')) {
4130
+			if (is_null($version)) {
4131 4131
 				$version = '';
4132 4132
 			} else {
4133 4133
 				/* translators: %s: version number */
4134
-				$version = sprintf( __( '(This message was added in version %s.)' ), $version );
4134
+				$version = sprintf(__('(This message was added in version %s.)'), $version);
4135 4135
 			}
4136 4136
 			/* translators: %s: Codex URL */
4137
-			$message .= ' ' . sprintf( __( 'Please see <a href="%s">Debugging in WordPress</a> for more information.' ),
4138
-				__( 'https://codex.wordpress.org/Debugging_in_WordPress' )
4137
+			$message .= ' '.sprintf(__('Please see <a href="%s">Debugging in WordPress</a> for more information.'),
4138
+				__('https://codex.wordpress.org/Debugging_in_WordPress')
4139 4139
 			);
4140 4140
 			/* translators: Developer debugging message. 1: PHP function name, 2: Explanatory message, 3: Version information message */
4141
-			trigger_error( sprintf( __( '%1$s was called <strong>incorrectly</strong>. %2$s %3$s' ), $function, $message, $version ) );
4141
+			trigger_error(sprintf(__('%1$s was called <strong>incorrectly</strong>. %2$s %3$s'), $function, $message, $version));
4142 4142
 		} else {
4143
-			if ( is_null( $version ) ) {
4143
+			if (is_null($version)) {
4144 4144
 				$version = '';
4145 4145
 			} else {
4146
-				$version = sprintf( '(This message was added in version %s.)', $version );
4146
+				$version = sprintf('(This message was added in version %s.)', $version);
4147 4147
 			}
4148
-			$message .= sprintf( ' Please see <a href="%s">Debugging in WordPress</a> for more information.',
4148
+			$message .= sprintf(' Please see <a href="%s">Debugging in WordPress</a> for more information.',
4149 4149
 				'https://codex.wordpress.org/Debugging_in_WordPress'
4150 4150
 			);
4151
-			trigger_error( sprintf( '%1$s was called <strong>incorrectly</strong>. %2$s %3$s', $function, $message, $version ) );
4151
+			trigger_error(sprintf('%1$s was called <strong>incorrectly</strong>. %2$s %3$s', $function, $message, $version));
4152 4152
 		}
4153 4153
 	}
4154 4154
 }
@@ -4161,9 +4161,9 @@  discard block
 block discarded – undo
4161 4161
  * @return bool Whether the server is running lighttpd < 1.5.0.
4162 4162
  */
4163 4163
 function is_lighttpd_before_150() {
4164
-	$server_parts = explode( '/', isset( $_SERVER['SERVER_SOFTWARE'] )? $_SERVER['SERVER_SOFTWARE'] : '' );
4165
-	$server_parts[1] = isset( $server_parts[1] )? $server_parts[1] : '';
4166
-	return  'lighttpd' == $server_parts[0] && -1 == version_compare( $server_parts[1], '1.5.0' );
4164
+	$server_parts = explode('/', isset($_SERVER['SERVER_SOFTWARE']) ? $_SERVER['SERVER_SOFTWARE'] : '');
4165
+	$server_parts[1] = isset($server_parts[1]) ? $server_parts[1] : '';
4166
+	return  'lighttpd' == $server_parts[0] && -1 == version_compare($server_parts[1], '1.5.0');
4167 4167
 }
4168 4168
 
4169 4169
 /**
@@ -4180,18 +4180,18 @@  discard block
 block discarded – undo
4180 4180
 function apache_mod_loaded($mod, $default = false) {
4181 4181
 	global $is_apache;
4182 4182
 
4183
-	if ( !$is_apache )
4183
+	if ( ! $is_apache)
4184 4184
 		return false;
4185 4185
 
4186
-	if ( function_exists( 'apache_get_modules' ) ) {
4186
+	if (function_exists('apache_get_modules')) {
4187 4187
 		$mods = apache_get_modules();
4188
-		if ( in_array($mod, $mods) )
4188
+		if (in_array($mod, $mods))
4189 4189
 			return true;
4190
-	} elseif ( function_exists( 'phpinfo' ) && false === strpos( ini_get( 'disable_functions' ), 'phpinfo' ) ) {
4190
+	} elseif (function_exists('phpinfo') && false === strpos(ini_get('disable_functions'), 'phpinfo')) {
4191 4191
 			ob_start();
4192 4192
 			phpinfo(8);
4193 4193
 			$phpinfo = ob_get_clean();
4194
-			if ( false !== strpos($phpinfo, $mod) )
4194
+			if (false !== strpos($phpinfo, $mod))
4195 4195
 				return true;
4196 4196
 	}
4197 4197
 	return $default;
@@ -4210,7 +4210,7 @@  discard block
 block discarded – undo
4210 4210
 	global $is_iis7;
4211 4211
 
4212 4212
 	$supports_permalinks = false;
4213
-	if ( $is_iis7 ) {
4213
+	if ($is_iis7) {
4214 4214
 		/* First we check if the DOMDocument class exists. If it does not exist, then we cannot
4215 4215
 		 * easily update the xml configuration file, hence we just bail out and tell user that
4216 4216
 		 * pretty permalinks cannot be used.
@@ -4220,7 +4220,7 @@  discard block
 block discarded – undo
4220 4220
 		 * Lastly we make sure that PHP is running via FastCGI. This is important because if it runs
4221 4221
 		 * via ISAPI then pretty permalinks will not work.
4222 4222
 		 */
4223
-		$supports_permalinks = class_exists( 'DOMDocument', false ) && isset($_SERVER['IIS_UrlRewriteModule']) && ( PHP_SAPI == 'cgi-fcgi' );
4223
+		$supports_permalinks = class_exists('DOMDocument', false) && isset($_SERVER['IIS_UrlRewriteModule']) && (PHP_SAPI == 'cgi-fcgi');
4224 4224
 	}
4225 4225
 
4226 4226
 	/**
@@ -4230,7 +4230,7 @@  discard block
 block discarded – undo
4230 4230
 	 *
4231 4231
 	 * @param bool $supports_permalinks Whether IIS7 supports permalinks. Default false.
4232 4232
 	 */
4233
-	return apply_filters( 'iis7_supports_permalinks', $supports_permalinks );
4233
+	return apply_filters('iis7_supports_permalinks', $supports_permalinks);
4234 4234
 }
4235 4235
 
4236 4236
 /**
@@ -4247,17 +4247,17 @@  discard block
 block discarded – undo
4247 4247
  * @param array  $allowed_files List of allowed files.
4248 4248
  * @return int 0 means nothing is wrong, greater than 0 means something was wrong.
4249 4249
  */
4250
-function validate_file( $file, $allowed_files = '' ) {
4251
-	if ( false !== strpos( $file, '..' ) )
4250
+function validate_file($file, $allowed_files = '') {
4251
+	if (false !== strpos($file, '..'))
4252 4252
 		return 1;
4253 4253
 
4254
-	if ( false !== strpos( $file, './' ) )
4254
+	if (false !== strpos($file, './'))
4255 4255
 		return 1;
4256 4256
 
4257
-	if ( ! empty( $allowed_files ) && ! in_array( $file, $allowed_files ) )
4257
+	if ( ! empty($allowed_files) && ! in_array($file, $allowed_files))
4258 4258
 		return 3;
4259 4259
 
4260
-	if (':' == substr( $file, 1, 1 ) )
4260
+	if (':' == substr($file, 1, 1))
4261 4261
 		return 2;
4262 4262
 
4263 4263
 	return 0;
@@ -4273,10 +4273,10 @@  discard block
 block discarded – undo
4273 4273
  * @param string|bool $force Optional. Whether to force SSL in admin screens. Default null.
4274 4274
  * @return bool True if forced, false if not forced.
4275 4275
  */
4276
-function force_ssl_admin( $force = null ) {
4276
+function force_ssl_admin($force = null) {
4277 4277
 	static $forced = false;
4278 4278
 
4279
-	if ( !is_null( $force ) ) {
4279
+	if ( ! is_null($force)) {
4280 4280
 		$old_forced = $forced;
4281 4281
 		$forced = $force;
4282 4282
 		return $old_forced;
@@ -4296,39 +4296,39 @@  discard block
 block discarded – undo
4296 4296
  * @return string The guessed URL.
4297 4297
  */
4298 4298
 function wp_guess_url() {
4299
-	if ( defined('WP_SITEURL') && '' != WP_SITEURL ) {
4299
+	if (defined('WP_SITEURL') && '' != WP_SITEURL) {
4300 4300
 		$url = WP_SITEURL;
4301 4301
 	} else {
4302
-		$abspath_fix = str_replace( '\\', '/', ABSPATH );
4303
-		$script_filename_dir = dirname( $_SERVER['SCRIPT_FILENAME'] );
4302
+		$abspath_fix = str_replace('\\', '/', ABSPATH);
4303
+		$script_filename_dir = dirname($_SERVER['SCRIPT_FILENAME']);
4304 4304
 
4305 4305
 		// The request is for the admin
4306
-		if ( strpos( $_SERVER['REQUEST_URI'], 'wp-admin' ) !== false || strpos( $_SERVER['REQUEST_URI'], 'wp-login.php' ) !== false ) {
4307
-			$path = preg_replace( '#/(wp-admin/.*|wp-login.php)#i', '', $_SERVER['REQUEST_URI'] );
4306
+		if (strpos($_SERVER['REQUEST_URI'], 'wp-admin') !== false || strpos($_SERVER['REQUEST_URI'], 'wp-login.php') !== false) {
4307
+			$path = preg_replace('#/(wp-admin/.*|wp-login.php)#i', '', $_SERVER['REQUEST_URI']);
4308 4308
 
4309 4309
 		// The request is for a file in ABSPATH
4310
-		} elseif ( $script_filename_dir . '/' == $abspath_fix ) {
4310
+		} elseif ($script_filename_dir.'/' == $abspath_fix) {
4311 4311
 			// Strip off any file/query params in the path
4312
-			$path = preg_replace( '#/[^/]*$#i', '', $_SERVER['PHP_SELF'] );
4312
+			$path = preg_replace('#/[^/]*$#i', '', $_SERVER['PHP_SELF']);
4313 4313
 
4314 4314
 		} else {
4315
-			if ( false !== strpos( $_SERVER['SCRIPT_FILENAME'], $abspath_fix ) ) {
4315
+			if (false !== strpos($_SERVER['SCRIPT_FILENAME'], $abspath_fix)) {
4316 4316
 				// Request is hitting a file inside ABSPATH
4317
-				$directory = str_replace( ABSPATH, '', $script_filename_dir );
4317
+				$directory = str_replace(ABSPATH, '', $script_filename_dir);
4318 4318
 				// Strip off the sub directory, and any file/query params
4319
-				$path = preg_replace( '#/' . preg_quote( $directory, '#' ) . '/[^/]*$#i', '' , $_SERVER['REQUEST_URI'] );
4320
-			} elseif ( false !== strpos( $abspath_fix, $script_filename_dir ) ) {
4319
+				$path = preg_replace('#/'.preg_quote($directory, '#').'/[^/]*$#i', '', $_SERVER['REQUEST_URI']);
4320
+			} elseif (false !== strpos($abspath_fix, $script_filename_dir)) {
4321 4321
 				// Request is hitting a file above ABSPATH
4322
-				$subdirectory = substr( $abspath_fix, strpos( $abspath_fix, $script_filename_dir ) + strlen( $script_filename_dir ) );
4322
+				$subdirectory = substr($abspath_fix, strpos($abspath_fix, $script_filename_dir) + strlen($script_filename_dir));
4323 4323
 				// Strip off any file/query params from the path, appending the sub directory to the install
4324
-				$path = preg_replace( '#/[^/]*$#i', '' , $_SERVER['REQUEST_URI'] ) . $subdirectory;
4324
+				$path = preg_replace('#/[^/]*$#i', '', $_SERVER['REQUEST_URI']).$subdirectory;
4325 4325
 			} else {
4326 4326
 				$path = $_SERVER['REQUEST_URI'];
4327 4327
 			}
4328 4328
 		}
4329 4329
 
4330 4330
 		$schema = is_ssl() ? 'https://' : 'http://'; // set_url_scheme() is not defined yet
4331
-		$url = $schema . $_SERVER['HTTP_HOST'] . $path;
4331
+		$url = $schema.$_SERVER['HTTP_HOST'].$path;
4332 4332
 	}
4333 4333
 
4334 4334
 	return rtrim($url, '/');
@@ -4351,10 +4351,10 @@  discard block
 block discarded – undo
4351 4351
  * @param bool $suspend Optional. Suspends additions if true, re-enables them if false.
4352 4352
  * @return bool The current suspend setting
4353 4353
  */
4354
-function wp_suspend_cache_addition( $suspend = null ) {
4354
+function wp_suspend_cache_addition($suspend = null) {
4355 4355
 	static $_suspend = false;
4356 4356
 
4357
-	if ( is_bool( $suspend ) )
4357
+	if (is_bool($suspend))
4358 4358
 		$_suspend = $suspend;
4359 4359
 
4360 4360
 	return $_suspend;
@@ -4374,7 +4374,7 @@  discard block
 block discarded – undo
4374 4374
  * @param bool $suspend Optional. Whether to suspend or enable cache invalidation. Default true.
4375 4375
  * @return bool The current suspend setting.
4376 4376
  */
4377
-function wp_suspend_cache_invalidation( $suspend = true ) {
4377
+function wp_suspend_cache_invalidation($suspend = true) {
4378 4378
 	global $_wp_suspend_cache_invalidation;
4379 4379
 
4380 4380
 	$current_suspend = $_wp_suspend_cache_invalidation;
@@ -4391,11 +4391,11 @@  discard block
 block discarded – undo
4391 4391
  * @return bool True if $site_id is the main site of the network, or if not
4392 4392
  *              running Multisite.
4393 4393
  */
4394
-function is_main_site( $site_id = null ) {
4395
-	if ( ! is_multisite() )
4394
+function is_main_site($site_id = null) {
4395
+	if ( ! is_multisite())
4396 4396
 		return true;
4397 4397
 
4398
-	if ( ! $site_id )
4398
+	if ( ! $site_id)
4399 4399
 		$site_id = get_current_blog_id();
4400 4400
 
4401 4401
 	return (int) $site_id === (int) get_network()->site_id;
@@ -4409,18 +4409,18 @@  discard block
 block discarded – undo
4409 4409
  * @param int $network_id Optional. Network ID to test. Defaults to current network.
4410 4410
  * @return bool True if $network_id is the main network, or if not running Multisite.
4411 4411
  */
4412
-function is_main_network( $network_id = null ) {
4413
-	if ( ! is_multisite() ) {
4412
+function is_main_network($network_id = null) {
4413
+	if ( ! is_multisite()) {
4414 4414
 		return true;
4415 4415
 	}
4416 4416
 
4417
-	if ( null === $network_id ) {
4417
+	if (null === $network_id) {
4418 4418
 		$network_id = get_current_network_id();
4419 4419
 	}
4420 4420
 
4421 4421
 	$network_id = (int) $network_id;
4422 4422
 
4423
-	return ( $network_id === get_main_network_id() );
4423
+	return ($network_id === get_main_network_id());
4424 4424
 }
4425 4425
 
4426 4426
 /**
@@ -4431,20 +4431,20 @@  discard block
 block discarded – undo
4431 4431
  * @return int The ID of the main network.
4432 4432
  */
4433 4433
 function get_main_network_id() {
4434
-	if ( ! is_multisite() ) {
4434
+	if ( ! is_multisite()) {
4435 4435
 		return 1;
4436 4436
 	}
4437 4437
 
4438 4438
 	$current_network = get_network();
4439 4439
 
4440
-	if ( defined( 'PRIMARY_NETWORK_ID' ) ) {
4440
+	if (defined('PRIMARY_NETWORK_ID')) {
4441 4441
 		$main_network_id = PRIMARY_NETWORK_ID;
4442
-	} elseif ( isset( $current_network->id ) && 1 === (int) $current_network->id ) {
4442
+	} elseif (isset($current_network->id) && 1 === (int) $current_network->id) {
4443 4443
 		// If the current network has an ID of 1, assume it is the main network.
4444 4444
 		$main_network_id = 1;
4445 4445
 	} else {
4446
-		$_networks = get_networks( array( 'fields' => 'ids', 'number' => 1 ) );
4447
-		$main_network_id = array_shift( $_networks );
4446
+		$_networks = get_networks(array('fields' => 'ids', 'number' => 1));
4447
+		$main_network_id = array_shift($_networks);
4448 4448
 	}
4449 4449
 
4450 4450
 	/**
@@ -4454,7 +4454,7 @@  discard block
 block discarded – undo
4454 4454
 	 *
4455 4455
 	 * @param int $main_network_id The ID of the main network.
4456 4456
 	 */
4457
-	return (int) apply_filters( 'get_main_network_id', $main_network_id );
4457
+	return (int) apply_filters('get_main_network_id', $main_network_id);
4458 4458
 }
4459 4459
 
4460 4460
 /**
@@ -4467,11 +4467,11 @@  discard block
 block discarded – undo
4467 4467
  * @return bool True if multisite and global terms enabled.
4468 4468
  */
4469 4469
 function global_terms_enabled() {
4470
-	if ( ! is_multisite() )
4470
+	if ( ! is_multisite())
4471 4471
 		return false;
4472 4472
 
4473 4473
 	static $global_terms = null;
4474
-	if ( is_null( $global_terms ) ) {
4474
+	if (is_null($global_terms)) {
4475 4475
 
4476 4476
 		/**
4477 4477
 		 * Filters whether global terms are enabled.
@@ -4483,11 +4483,11 @@  discard block
 block discarded – undo
4483 4483
 		 *
4484 4484
 		 * @param null $enabled Whether global terms are enabled.
4485 4485
 		 */
4486
-		$filter = apply_filters( 'global_terms_enabled', null );
4487
-		if ( ! is_null( $filter ) )
4486
+		$filter = apply_filters('global_terms_enabled', null);
4487
+		if ( ! is_null($filter))
4488 4488
 			$global_terms = (bool) $filter;
4489 4489
 		else
4490
-			$global_terms = (bool) get_site_option( 'global_terms_enabled', false );
4490
+			$global_terms = (bool) get_site_option('global_terms_enabled', false);
4491 4491
 	}
4492 4492
 	return $global_terms;
4493 4493
 }
@@ -4502,16 +4502,16 @@  discard block
 block discarded – undo
4502 4502
  * @return float|false Timezone GMT offset, false otherwise.
4503 4503
  */
4504 4504
 function wp_timezone_override_offset() {
4505
-	if ( !$timezone_string = get_option( 'timezone_string' ) ) {
4505
+	if ( ! $timezone_string = get_option('timezone_string')) {
4506 4506
 		return false;
4507 4507
 	}
4508 4508
 
4509
-	$timezone_object = timezone_open( $timezone_string );
4509
+	$timezone_object = timezone_open($timezone_string);
4510 4510
 	$datetime_object = date_create();
4511
-	if ( false === $timezone_object || false === $datetime_object ) {
4511
+	if (false === $timezone_object || false === $datetime_object) {
4512 4512
 		return false;
4513 4513
 	}
4514
-	return round( timezone_offset_get( $timezone_object, $datetime_object ) / HOUR_IN_SECONDS, 2 );
4514
+	return round(timezone_offset_get($timezone_object, $datetime_object) / HOUR_IN_SECONDS, 2);
4515 4515
 }
4516 4516
 
4517 4517
 /**
@@ -4524,41 +4524,41 @@  discard block
 block discarded – undo
4524 4524
  * @param array $b
4525 4525
  * @return int
4526 4526
  */
4527
-function _wp_timezone_choice_usort_callback( $a, $b ) {
4527
+function _wp_timezone_choice_usort_callback($a, $b) {
4528 4528
 	// Don't use translated versions of Etc
4529
-	if ( 'Etc' === $a['continent'] && 'Etc' === $b['continent'] ) {
4529
+	if ('Etc' === $a['continent'] && 'Etc' === $b['continent']) {
4530 4530
 		// Make the order of these more like the old dropdown
4531
-		if ( 'GMT+' === substr( $a['city'], 0, 4 ) && 'GMT+' === substr( $b['city'], 0, 4 ) ) {
4532
-			return -1 * ( strnatcasecmp( $a['city'], $b['city'] ) );
4531
+		if ('GMT+' === substr($a['city'], 0, 4) && 'GMT+' === substr($b['city'], 0, 4)) {
4532
+			return -1 * (strnatcasecmp($a['city'], $b['city']));
4533 4533
 		}
4534
-		if ( 'UTC' === $a['city'] ) {
4535
-			if ( 'GMT+' === substr( $b['city'], 0, 4 ) ) {
4534
+		if ('UTC' === $a['city']) {
4535
+			if ('GMT+' === substr($b['city'], 0, 4)) {
4536 4536
 				return 1;
4537 4537
 			}
4538 4538
 			return -1;
4539 4539
 		}
4540
-		if ( 'UTC' === $b['city'] ) {
4541
-			if ( 'GMT+' === substr( $a['city'], 0, 4 ) ) {
4540
+		if ('UTC' === $b['city']) {
4541
+			if ('GMT+' === substr($a['city'], 0, 4)) {
4542 4542
 				return -1;
4543 4543
 			}
4544 4544
 			return 1;
4545 4545
 		}
4546
-		return strnatcasecmp( $a['city'], $b['city'] );
4546
+		return strnatcasecmp($a['city'], $b['city']);
4547 4547
 	}
4548
-	if ( $a['t_continent'] == $b['t_continent'] ) {
4549
-		if ( $a['t_city'] == $b['t_city'] ) {
4550
-			return strnatcasecmp( $a['t_subcity'], $b['t_subcity'] );
4548
+	if ($a['t_continent'] == $b['t_continent']) {
4549
+		if ($a['t_city'] == $b['t_city']) {
4550
+			return strnatcasecmp($a['t_subcity'], $b['t_subcity']);
4551 4551
 		}
4552
-		return strnatcasecmp( $a['t_city'], $b['t_city'] );
4552
+		return strnatcasecmp($a['t_city'], $b['t_city']);
4553 4553
 	} else {
4554 4554
 		// Force Etc to the bottom of the list
4555
-		if ( 'Etc' === $a['continent'] ) {
4555
+		if ('Etc' === $a['continent']) {
4556 4556
 			return 1;
4557 4557
 		}
4558
-		if ( 'Etc' === $b['continent'] ) {
4558
+		if ('Etc' === $b['continent']) {
4559 4559
 			return -1;
4560 4560
 		}
4561
-		return strnatcasecmp( $a['t_continent'], $b['t_continent'] );
4561
+		return strnatcasecmp($a['t_continent'], $b['t_continent']);
4562 4562
 	}
4563 4563
 }
4564 4564
 
@@ -4575,126 +4575,126 @@  discard block
 block discarded – undo
4575 4575
  * @param string $locale        Optional. Locale to load the timezones in. Default current site locale.
4576 4576
  * @return string
4577 4577
  */
4578
-function wp_timezone_choice( $selected_zone, $locale = null ) {
4578
+function wp_timezone_choice($selected_zone, $locale = null) {
4579 4579
 	static $mo_loaded = false, $locale_loaded = null;
4580 4580
 
4581
-	$continents = array( 'Africa', 'America', 'Antarctica', 'Arctic', 'Asia', 'Atlantic', 'Australia', 'Europe', 'Indian', 'Pacific');
4581
+	$continents = array('Africa', 'America', 'Antarctica', 'Arctic', 'Asia', 'Atlantic', 'Australia', 'Europe', 'Indian', 'Pacific');
4582 4582
 
4583 4583
 	// Load translations for continents and cities.
4584
-	if ( ! $mo_loaded || $locale !== $locale_loaded ) {
4584
+	if ( ! $mo_loaded || $locale !== $locale_loaded) {
4585 4585
 		$locale_loaded = $locale ? $locale : get_locale();
4586
-		$mofile = WP_LANG_DIR . '/continents-cities-' . $locale_loaded . '.mo';
4587
-		unload_textdomain( 'continents-cities' );
4588
-		load_textdomain( 'continents-cities', $mofile );
4586
+		$mofile = WP_LANG_DIR.'/continents-cities-'.$locale_loaded.'.mo';
4587
+		unload_textdomain('continents-cities');
4588
+		load_textdomain('continents-cities', $mofile);
4589 4589
 		$mo_loaded = true;
4590 4590
 	}
4591 4591
 
4592 4592
 	$zonen = array();
4593
-	foreach ( timezone_identifiers_list() as $zone ) {
4594
-		$zone = explode( '/', $zone );
4595
-		if ( !in_array( $zone[0], $continents ) ) {
4593
+	foreach (timezone_identifiers_list() as $zone) {
4594
+		$zone = explode('/', $zone);
4595
+		if ( ! in_array($zone[0], $continents)) {
4596 4596
 			continue;
4597 4597
 		}
4598 4598
 
4599 4599
 		// This determines what gets set and translated - we don't translate Etc/* strings here, they are done later
4600 4600
 		$exists = array(
4601
-			0 => ( isset( $zone[0] ) && $zone[0] ),
4602
-			1 => ( isset( $zone[1] ) && $zone[1] ),
4603
-			2 => ( isset( $zone[2] ) && $zone[2] ),
4601
+			0 => (isset($zone[0]) && $zone[0]),
4602
+			1 => (isset($zone[1]) && $zone[1]),
4603
+			2 => (isset($zone[2]) && $zone[2]),
4604 4604
 		);
4605
-		$exists[3] = ( $exists[0] && 'Etc' !== $zone[0] );
4606
-		$exists[4] = ( $exists[1] && $exists[3] );
4607
-		$exists[5] = ( $exists[2] && $exists[3] );
4605
+		$exists[3] = ($exists[0] && 'Etc' !== $zone[0]);
4606
+		$exists[4] = ($exists[1] && $exists[3]);
4607
+		$exists[5] = ($exists[2] && $exists[3]);
4608 4608
 
4609 4609
 		$zonen[] = array(
4610
-			'continent'   => ( $exists[0] ? $zone[0] : '' ),
4611
-			'city'        => ( $exists[1] ? $zone[1] : '' ),
4612
-			'subcity'     => ( $exists[2] ? $zone[2] : '' ),
4613
-			't_continent' => ( $exists[3] ? translate( str_replace( '_', ' ', $zone[0] ), 'continents-cities' ) : '' ),
4614
-			't_city'      => ( $exists[4] ? translate( str_replace( '_', ' ', $zone[1] ), 'continents-cities' ) : '' ),
4615
-			't_subcity'   => ( $exists[5] ? translate( str_replace( '_', ' ', $zone[2] ), 'continents-cities' ) : '' )
4610
+			'continent'   => ($exists[0] ? $zone[0] : ''),
4611
+			'city'        => ($exists[1] ? $zone[1] : ''),
4612
+			'subcity'     => ($exists[2] ? $zone[2] : ''),
4613
+			't_continent' => ($exists[3] ? translate(str_replace('_', ' ', $zone[0]), 'continents-cities') : ''),
4614
+			't_city'      => ($exists[4] ? translate(str_replace('_', ' ', $zone[1]), 'continents-cities') : ''),
4615
+			't_subcity'   => ($exists[5] ? translate(str_replace('_', ' ', $zone[2]), 'continents-cities') : '')
4616 4616
 		);
4617 4617
 	}
4618
-	usort( $zonen, '_wp_timezone_choice_usort_callback' );
4618
+	usort($zonen, '_wp_timezone_choice_usort_callback');
4619 4619
 
4620 4620
 	$structure = array();
4621 4621
 
4622
-	if ( empty( $selected_zone ) ) {
4623
-		$structure[] = '<option selected="selected" value="">' . __( 'Select a city' ) . '</option>';
4622
+	if (empty($selected_zone)) {
4623
+		$structure[] = '<option selected="selected" value="">'.__('Select a city').'</option>';
4624 4624
 	}
4625 4625
 
4626
-	foreach ( $zonen as $key => $zone ) {
4626
+	foreach ($zonen as $key => $zone) {
4627 4627
 		// Build value in an array to join later
4628
-		$value = array( $zone['continent'] );
4628
+		$value = array($zone['continent']);
4629 4629
 
4630
-		if ( empty( $zone['city'] ) ) {
4630
+		if (empty($zone['city'])) {
4631 4631
 			// It's at the continent level (generally won't happen)
4632 4632
 			$display = $zone['t_continent'];
4633 4633
 		} else {
4634 4634
 			// It's inside a continent group
4635 4635
 
4636 4636
 			// Continent optgroup
4637
-			if ( !isset( $zonen[$key - 1] ) || $zonen[$key - 1]['continent'] !== $zone['continent'] ) {
4637
+			if ( ! isset($zonen[$key - 1]) || $zonen[$key - 1]['continent'] !== $zone['continent']) {
4638 4638
 				$label = $zone['t_continent'];
4639
-				$structure[] = '<optgroup label="'. esc_attr( $label ) .'">';
4639
+				$structure[] = '<optgroup label="'.esc_attr($label).'">';
4640 4640
 			}
4641 4641
 
4642 4642
 			// Add the city to the value
4643 4643
 			$value[] = $zone['city'];
4644 4644
 
4645 4645
 			$display = $zone['t_city'];
4646
-			if ( !empty( $zone['subcity'] ) ) {
4646
+			if ( ! empty($zone['subcity'])) {
4647 4647
 				// Add the subcity to the value
4648 4648
 				$value[] = $zone['subcity'];
4649
-				$display .= ' - ' . $zone['t_subcity'];
4649
+				$display .= ' - '.$zone['t_subcity'];
4650 4650
 			}
4651 4651
 		}
4652 4652
 
4653 4653
 		// Build the value
4654
-		$value = join( '/', $value );
4654
+		$value = join('/', $value);
4655 4655
 		$selected = '';
4656
-		if ( $value === $selected_zone ) {
4656
+		if ($value === $selected_zone) {
4657 4657
 			$selected = 'selected="selected" ';
4658 4658
 		}
4659
-		$structure[] = '<option ' . $selected . 'value="' . esc_attr( $value ) . '">' . esc_html( $display ) . "</option>";
4659
+		$structure[] = '<option '.$selected.'value="'.esc_attr($value).'">'.esc_html($display)."</option>";
4660 4660
 
4661 4661
 		// Close continent optgroup
4662
-		if ( !empty( $zone['city'] ) && ( !isset($zonen[$key + 1]) || (isset( $zonen[$key + 1] ) && $zonen[$key + 1]['continent'] !== $zone['continent']) ) ) {
4662
+		if ( ! empty($zone['city']) && ( ! isset($zonen[$key + 1]) || (isset($zonen[$key + 1]) && $zonen[$key + 1]['continent'] !== $zone['continent']))) {
4663 4663
 			$structure[] = '</optgroup>';
4664 4664
 		}
4665 4665
 	}
4666 4666
 
4667 4667
 	// Do UTC
4668
-	$structure[] = '<optgroup label="'. esc_attr__( 'UTC' ) .'">';
4668
+	$structure[] = '<optgroup label="'.esc_attr__('UTC').'">';
4669 4669
 	$selected = '';
4670
-	if ( 'UTC' === $selected_zone )
4670
+	if ('UTC' === $selected_zone)
4671 4671
 		$selected = 'selected="selected" ';
4672
-	$structure[] = '<option ' . $selected . 'value="' . esc_attr( 'UTC' ) . '">' . __('UTC') . '</option>';
4672
+	$structure[] = '<option '.$selected.'value="'.esc_attr('UTC').'">'.__('UTC').'</option>';
4673 4673
 	$structure[] = '</optgroup>';
4674 4674
 
4675 4675
 	// Do manual UTC offsets
4676
-	$structure[] = '<optgroup label="'. esc_attr__( 'Manual Offsets' ) .'">';
4677
-	$offset_range = array (-12, -11.5, -11, -10.5, -10, -9.5, -9, -8.5, -8, -7.5, -7, -6.5, -6, -5.5, -5, -4.5, -4, -3.5, -3, -2.5, -2, -1.5, -1, -0.5,
4676
+	$structure[] = '<optgroup label="'.esc_attr__('Manual Offsets').'">';
4677
+	$offset_range = array(-12, -11.5, -11, -10.5, -10, -9.5, -9, -8.5, -8, -7.5, -7, -6.5, -6, -5.5, -5, -4.5, -4, -3.5, -3, -2.5, -2, -1.5, -1, -0.5,
4678 4678
 		0, 0.5, 1, 1.5, 2, 2.5, 3, 3.5, 4, 4.5, 5, 5.5, 5.75, 6, 6.5, 7, 7.5, 8, 8.5, 8.75, 9, 9.5, 10, 10.5, 11, 11.5, 12, 12.75, 13, 13.75, 14);
4679
-	foreach ( $offset_range as $offset ) {
4680
-		if ( 0 <= $offset )
4681
-			$offset_name = '+' . $offset;
4679
+	foreach ($offset_range as $offset) {
4680
+		if (0 <= $offset)
4681
+			$offset_name = '+'.$offset;
4682 4682
 		else
4683 4683
 			$offset_name = (string) $offset;
4684 4684
 
4685 4685
 		$offset_value = $offset_name;
4686
-		$offset_name = str_replace(array('.25','.5','.75'), array(':15',':30',':45'), $offset_name);
4687
-		$offset_name = 'UTC' . $offset_name;
4688
-		$offset_value = 'UTC' . $offset_value;
4686
+		$offset_name = str_replace(array('.25', '.5', '.75'), array(':15', ':30', ':45'), $offset_name);
4687
+		$offset_name = 'UTC'.$offset_name;
4688
+		$offset_value = 'UTC'.$offset_value;
4689 4689
 		$selected = '';
4690
-		if ( $offset_value === $selected_zone )
4690
+		if ($offset_value === $selected_zone)
4691 4691
 			$selected = 'selected="selected" ';
4692
-		$structure[] = '<option ' . $selected . 'value="' . esc_attr( $offset_value ) . '">' . esc_html( $offset_name ) . "</option>";
4692
+		$structure[] = '<option '.$selected.'value="'.esc_attr($offset_value).'">'.esc_html($offset_name)."</option>";
4693 4693
 
4694 4694
 	}
4695 4695
 	$structure[] = '</optgroup>';
4696 4696
 
4697
-	return join( "\n", $structure );
4697
+	return join("\n", $structure);
4698 4698
 }
4699 4699
 
4700 4700
 /**
@@ -4708,7 +4708,7 @@  discard block
 block discarded – undo
4708 4708
  * @param string $str Header comment to clean up.
4709 4709
  * @return string
4710 4710
  */
4711
-function _cleanup_header_comment( $str ) {
4711
+function _cleanup_header_comment($str) {
4712 4712
 	return trim(preg_replace("/\s*(?:\*\/|\?>).*/", '', $str));
4713 4713
 }
4714 4714
 
@@ -4725,18 +4725,18 @@  discard block
 block discarded – undo
4725 4725
 function wp_scheduled_delete() {
4726 4726
 	global $wpdb;
4727 4727
 
4728
-	$delete_timestamp = time() - ( DAY_IN_SECONDS * EMPTY_TRASH_DAYS );
4728
+	$delete_timestamp = time() - (DAY_IN_SECONDS * EMPTY_TRASH_DAYS);
4729 4729
 
4730 4730
 	$posts_to_delete = $wpdb->get_results($wpdb->prepare("SELECT post_id FROM $wpdb->postmeta WHERE meta_key = '_wp_trash_meta_time' AND meta_value < '%d'", $delete_timestamp), ARRAY_A);
4731 4731
 
4732
-	foreach ( (array) $posts_to_delete as $post ) {
4732
+	foreach ((array) $posts_to_delete as $post) {
4733 4733
 		$post_id = (int) $post['post_id'];
4734
-		if ( !$post_id )
4734
+		if ( ! $post_id)
4735 4735
 			continue;
4736 4736
 
4737 4737
 		$del_post = get_post($post_id);
4738 4738
 
4739
-		if ( !$del_post || 'trash' != $del_post->post_status ) {
4739
+		if ( ! $del_post || 'trash' != $del_post->post_status) {
4740 4740
 			delete_post_meta($post_id, '_wp_trash_meta_status');
4741 4741
 			delete_post_meta($post_id, '_wp_trash_meta_time');
4742 4742
 		} else {
@@ -4746,18 +4746,18 @@  discard block
 block discarded – undo
4746 4746
 
4747 4747
 	$comments_to_delete = $wpdb->get_results($wpdb->prepare("SELECT comment_id FROM $wpdb->commentmeta WHERE meta_key = '_wp_trash_meta_time' AND meta_value < '%d'", $delete_timestamp), ARRAY_A);
4748 4748
 
4749
-	foreach ( (array) $comments_to_delete as $comment ) {
4749
+	foreach ((array) $comments_to_delete as $comment) {
4750 4750
 		$comment_id = (int) $comment['comment_id'];
4751
-		if ( !$comment_id )
4751
+		if ( ! $comment_id)
4752 4752
 			continue;
4753 4753
 
4754 4754
 		$del_comment = get_comment($comment_id);
4755 4755
 
4756
-		if ( !$del_comment || 'trash' != $del_comment->comment_approved ) {
4756
+		if ( ! $del_comment || 'trash' != $del_comment->comment_approved) {
4757 4757
 			delete_comment_meta($comment_id, '_wp_trash_meta_time');
4758 4758
 			delete_comment_meta($comment_id, '_wp_trash_meta_status');
4759 4759
 		} else {
4760
-			wp_delete_comment( $del_comment );
4760
+			wp_delete_comment($del_comment);
4761 4761
 		}
4762 4762
 	}
4763 4763
 }
@@ -4782,18 +4782,18 @@  discard block
 block discarded – undo
4782 4782
  *                                Default empty.
4783 4783
  * @return array Array of file headers in `HeaderKey => Header Value` format.
4784 4784
  */
4785
-function get_file_data( $file, $default_headers, $context = '' ) {
4785
+function get_file_data($file, $default_headers, $context = '') {
4786 4786
 	// We don't need to write to the file, so just open for reading.
4787
-	$fp = fopen( $file, 'r' );
4787
+	$fp = fopen($file, 'r');
4788 4788
 
4789 4789
 	// Pull only the first 8kiB of the file in.
4790
-	$file_data = fread( $fp, 8192 );
4790
+	$file_data = fread($fp, 8192);
4791 4791
 
4792 4792
 	// PHP will close file handle, but we are good citizens.
4793
-	fclose( $fp );
4793
+	fclose($fp);
4794 4794
 
4795 4795
 	// Make sure we catch CR-only line endings.
4796
-	$file_data = str_replace( "\r", "\n", $file_data );
4796
+	$file_data = str_replace("\r", "\n", $file_data);
4797 4797
 
4798 4798
 	/**
4799 4799
 	 * Filters extra file headers by context.
@@ -4805,18 +4805,18 @@  discard block
 block discarded – undo
4805 4805
 	 *
4806 4806
 	 * @param array $extra_context_headers Empty array by default.
4807 4807
 	 */
4808
-	if ( $context && $extra_headers = apply_filters( "extra_{$context}_headers", array() ) ) {
4809
-		$extra_headers = array_combine( $extra_headers, $extra_headers ); // keys equal values
4810
-		$all_headers = array_merge( $extra_headers, (array) $default_headers );
4808
+	if ($context && $extra_headers = apply_filters("extra_{$context}_headers", array())) {
4809
+		$extra_headers = array_combine($extra_headers, $extra_headers); // keys equal values
4810
+		$all_headers = array_merge($extra_headers, (array) $default_headers);
4811 4811
 	} else {
4812 4812
 		$all_headers = $default_headers;
4813 4813
 	}
4814 4814
 
4815
-	foreach ( $all_headers as $field => $regex ) {
4816
-		if ( preg_match( '/^[ \t\/*#@]*' . preg_quote( $regex, '/' ) . ':(.*)$/mi', $file_data, $match ) && $match[1] )
4817
-			$all_headers[ $field ] = _cleanup_header_comment( $match[1] );
4815
+	foreach ($all_headers as $field => $regex) {
4816
+		if (preg_match('/^[ \t\/*#@]*'.preg_quote($regex, '/').':(.*)$/mi', $file_data, $match) && $match[1])
4817
+			$all_headers[$field] = _cleanup_header_comment($match[1]);
4818 4818
 		else
4819
-			$all_headers[ $field ] = '';
4819
+			$all_headers[$field] = '';
4820 4820
 	}
4821 4821
 
4822 4822
 	return $all_headers;
@@ -4915,7 +4915,7 @@  discard block
 block discarded – undo
4915 4915
  * @see https://src.chromium.org/viewvc/chrome?view=rev&revision=6985
4916 4916
  */
4917 4917
 function send_nosniff_header() {
4918
-	@header( 'X-Content-Type-Options: nosniff' );
4918
+	@header('X-Content-Type-Options: nosniff');
4919 4919
 }
4920 4920
 
4921 4921
 /**
@@ -4927,8 +4927,8 @@  discard block
 block discarded – undo
4927 4927
  * @param string $column Database column.
4928 4928
  * @return string SQL clause.
4929 4929
  */
4930
-function _wp_mysql_week( $column ) {
4931
-	switch ( $start_of_week = (int) get_option( 'start_of_week' ) ) {
4930
+function _wp_mysql_week($column) {
4931
+	switch ($start_of_week = (int) get_option('start_of_week')) {
4932 4932
 	case 1 :
4933 4933
 		return "WEEK( $column, 1 )";
4934 4934
 	case 2 :
@@ -4956,13 +4956,13 @@  discard block
 block discarded – undo
4956 4956
  * @param array    $callback_args Optional. Additional arguments to send to $callback.
4957 4957
  * @return array IDs of all members of loop.
4958 4958
  */
4959
-function wp_find_hierarchy_loop( $callback, $start, $start_parent, $callback_args = array() ) {
4960
-	$override = is_null( $start_parent ) ? array() : array( $start => $start_parent );
4959
+function wp_find_hierarchy_loop($callback, $start, $start_parent, $callback_args = array()) {
4960
+	$override = is_null($start_parent) ? array() : array($start => $start_parent);
4961 4961
 
4962
-	if ( !$arbitrary_loop_member = wp_find_hierarchy_loop_tortoise_hare( $callback, $start, $override, $callback_args ) )
4962
+	if ( ! $arbitrary_loop_member = wp_find_hierarchy_loop_tortoise_hare($callback, $start, $override, $callback_args))
4963 4963
 		return array();
4964 4964
 
4965
-	return wp_find_hierarchy_loop_tortoise_hare( $callback, $arbitrary_loop_member, $override, $callback_args, true );
4965
+	return wp_find_hierarchy_loop_tortoise_hare($callback, $arbitrary_loop_member, $override, $callback_args, true);
4966 4966
 }
4967 4967
 
4968 4968
 /**
@@ -4985,7 +4985,7 @@  discard block
 block discarded – undo
4985 4985
  * @return mixed Scalar ID of some arbitrary member of the loop, or array of IDs of all members of loop if
4986 4986
  *               $_return_loop
4987 4987
  */
4988
-function wp_find_hierarchy_loop_tortoise_hare( $callback, $start, $override = array(), $callback_args = array(), $_return_loop = false ) {
4988
+function wp_find_hierarchy_loop_tortoise_hare($callback, $start, $override = array(), $callback_args = array(), $_return_loop = false) {
4989 4989
 	$tortoise = $hare = $evanescent_hare = $start;
4990 4990
 	$return = array();
4991 4991
 
@@ -4994,19 +4994,19 @@  discard block
 block discarded – undo
4994 4994
 	while (
4995 4995
 		$tortoise
4996 4996
 	&&
4997
-		( $evanescent_hare = isset( $override[$hare] ) ? $override[$hare] : call_user_func_array( $callback, array_merge( array( $hare ), $callback_args ) ) )
4997
+		($evanescent_hare = isset($override[$hare]) ? $override[$hare] : call_user_func_array($callback, array_merge(array($hare), $callback_args)))
4998 4998
 	&&
4999
-		( $hare = isset( $override[$evanescent_hare] ) ? $override[$evanescent_hare] : call_user_func_array( $callback, array_merge( array( $evanescent_hare ), $callback_args ) ) )
4999
+		($hare = isset($override[$evanescent_hare]) ? $override[$evanescent_hare] : call_user_func_array($callback, array_merge(array($evanescent_hare), $callback_args)))
5000 5000
 	) {
5001
-		if ( $_return_loop )
5001
+		if ($_return_loop)
5002 5002
 			$return[$tortoise] = $return[$evanescent_hare] = $return[$hare] = true;
5003 5003
 
5004 5004
 		// tortoise got lapped - must be a loop
5005
-		if ( $tortoise == $evanescent_hare || $tortoise == $hare )
5005
+		if ($tortoise == $evanescent_hare || $tortoise == $hare)
5006 5006
 			return $_return_loop ? $return : $tortoise;
5007 5007
 
5008 5008
 		// Increment tortoise by one step
5009
-		$tortoise = isset( $override[$tortoise] ) ? $override[$tortoise] : call_user_func_array( $callback, array_merge( array( $tortoise ), $callback_args ) );
5009
+		$tortoise = isset($override[$tortoise]) ? $override[$tortoise] : call_user_func_array($callback, array_merge(array($tortoise), $callback_args));
5010 5010
 	}
5011 5011
 
5012 5012
 	return false;
@@ -5020,7 +5020,7 @@  discard block
 block discarded – undo
5020 5020
  * @see https://developer.mozilla.org/en/the_x-frame-options_response_header
5021 5021
  */
5022 5022
 function send_frame_options_header() {
5023
-	@header( 'X-Frame-Options: SAMEORIGIN' );
5023
+	@header('X-Frame-Options: SAMEORIGIN');
5024 5024
 }
5025 5025
 
5026 5026
 /**
@@ -5042,8 +5042,8 @@  discard block
 block discarded – undo
5042 5042
 function wp_allowed_protocols() {
5043 5043
 	static $protocols = array();
5044 5044
 
5045
-	if ( empty( $protocols ) ) {
5046
-		$protocols = array( 'http', 'https', 'ftp', 'ftps', 'mailto', 'news', 'irc', 'gopher', 'nntp', 'feed', 'telnet', 'mms', 'rtsp', 'svn', 'tel', 'fax', 'xmpp', 'webcal', 'urn' );
5045
+	if (empty($protocols)) {
5046
+		$protocols = array('http', 'https', 'ftp', 'ftps', 'mailto', 'news', 'irc', 'gopher', 'nntp', 'feed', 'telnet', 'mms', 'rtsp', 'svn', 'tel', 'fax', 'xmpp', 'webcal', 'urn');
5047 5047
 
5048 5048
 		/**
5049 5049
 		 * Filters the list of protocols allowed in HTML attributes.
@@ -5052,7 +5052,7 @@  discard block
 block discarded – undo
5052 5052
 		 *
5053 5053
 		 * @param array $protocols Array of allowed protocols e.g. 'http', 'ftp', 'tel', and more.
5054 5054
 		 */
5055
-		$protocols = apply_filters( 'kses_allowed_protocols', $protocols );
5055
+		$protocols = apply_filters('kses_allowed_protocols', $protocols);
5056 5056
 	}
5057 5057
 
5058 5058
 	return $protocols;
@@ -5075,36 +5075,36 @@  discard block
 block discarded – undo
5075 5075
  * @return string|array Either a string containing a reversed comma separated trace or an array
5076 5076
  *                      of individual calls.
5077 5077
  */
5078
-function wp_debug_backtrace_summary( $ignore_class = null, $skip_frames = 0, $pretty = true ) {
5079
-	if ( version_compare( PHP_VERSION, '5.2.5', '>=' ) )
5080
-		$trace = debug_backtrace( false );
5078
+function wp_debug_backtrace_summary($ignore_class = null, $skip_frames = 0, $pretty = true) {
5079
+	if (version_compare(PHP_VERSION, '5.2.5', '>='))
5080
+		$trace = debug_backtrace(false);
5081 5081
 	else
5082 5082
 		$trace = debug_backtrace();
5083 5083
 
5084 5084
 	$caller = array();
5085
-	$check_class = ! is_null( $ignore_class );
5085
+	$check_class = ! is_null($ignore_class);
5086 5086
 	$skip_frames++; // skip this function
5087 5087
 
5088
-	foreach ( $trace as $call ) {
5089
-		if ( $skip_frames > 0 ) {
5088
+	foreach ($trace as $call) {
5089
+		if ($skip_frames > 0) {
5090 5090
 			$skip_frames--;
5091
-		} elseif ( isset( $call['class'] ) ) {
5092
-			if ( $check_class && $ignore_class == $call['class'] )
5091
+		} elseif (isset($call['class'])) {
5092
+			if ($check_class && $ignore_class == $call['class'])
5093 5093
 				continue; // Filter out calls
5094 5094
 
5095 5095
 			$caller[] = "{$call['class']}{$call['type']}{$call['function']}";
5096 5096
 		} else {
5097
-			if ( in_array( $call['function'], array( 'do_action', 'apply_filters' ) ) ) {
5097
+			if (in_array($call['function'], array('do_action', 'apply_filters'))) {
5098 5098
 				$caller[] = "{$call['function']}('{$call['args'][0]}')";
5099
-			} elseif ( in_array( $call['function'], array( 'include', 'include_once', 'require', 'require_once' ) ) ) {
5100
-				$caller[] = $call['function'] . "('" . str_replace( array( WP_CONTENT_DIR, ABSPATH ) , '', $call['args'][0] ) . "')";
5099
+			} elseif (in_array($call['function'], array('include', 'include_once', 'require', 'require_once'))) {
5100
+				$caller[] = $call['function']."('".str_replace(array(WP_CONTENT_DIR, ABSPATH), '', $call['args'][0])."')";
5101 5101
 			} else {
5102 5102
 				$caller[] = $call['function'];
5103 5103
 			}
5104 5104
 		}
5105 5105
 	}
5106
-	if ( $pretty )
5107
-		return join( ', ', array_reverse( $caller ) );
5106
+	if ($pretty)
5107
+		return join(', ', array_reverse($caller));
5108 5108
 	else
5109 5109
 		return $caller;
5110 5110
 }
@@ -5120,11 +5120,11 @@  discard block
 block discarded – undo
5120 5120
  *
5121 5121
  * @return array List of ids not present in the cache.
5122 5122
  */
5123
-function _get_non_cached_ids( $object_ids, $cache_key ) {
5123
+function _get_non_cached_ids($object_ids, $cache_key) {
5124 5124
 	$clean = array();
5125
-	foreach ( $object_ids as $id ) {
5125
+	foreach ($object_ids as $id) {
5126 5126
 		$id = (int) $id;
5127
-		if ( !wp_cache_get( $id, $cache_key ) ) {
5127
+		if ( ! wp_cache_get($id, $cache_key)) {
5128 5128
 			$clean[] = $id;
5129 5129
 		}
5130 5130
 	}
@@ -5141,15 +5141,15 @@  discard block
 block discarded – undo
5141 5141
  * @return bool Whether the device is able to upload files.
5142 5142
  */
5143 5143
 function _device_can_upload() {
5144
-	if ( ! wp_is_mobile() )
5144
+	if ( ! wp_is_mobile())
5145 5145
 		return true;
5146 5146
 
5147 5147
 	$ua = $_SERVER['HTTP_USER_AGENT'];
5148 5148
 
5149
-	if ( strpos($ua, 'iPhone') !== false
5149
+	if (strpos($ua, 'iPhone') !== false
5150 5150
 		|| strpos($ua, 'iPad') !== false
5151
-		|| strpos($ua, 'iPod') !== false ) {
5152
-			return preg_match( '#OS ([\d_]+) like Mac OS X#', $ua, $version ) && version_compare( $version[1], '6', '>=' );
5151
+		|| strpos($ua, 'iPod') !== false) {
5152
+			return preg_match('#OS ([\d_]+) like Mac OS X#', $ua, $version) && version_compare($version[1], '6', '>=');
5153 5153
 	}
5154 5154
 
5155 5155
 	return true;
@@ -5163,11 +5163,11 @@  discard block
 block discarded – undo
5163 5163
  * @param string $path The resource path or URL.
5164 5164
  * @return bool True if the path is a stream URL.
5165 5165
  */
5166
-function wp_is_stream( $path ) {
5166
+function wp_is_stream($path) {
5167 5167
 	$wrappers = stream_get_wrappers();
5168
-	$wrappers_re = '(' . join('|', $wrappers) . ')';
5168
+	$wrappers_re = '('.join('|', $wrappers).')';
5169 5169
 
5170
-	return preg_match( "!^$wrappers_re://!", $path ) === 1;
5170
+	return preg_match("!^$wrappers_re://!", $path) === 1;
5171 5171
 }
5172 5172
 
5173 5173
 /**
@@ -5183,7 +5183,7 @@  discard block
 block discarded – undo
5183 5183
  * @param  string $source_date The date to filter.
5184 5184
  * @return bool True if valid date, false if not valid date.
5185 5185
  */
5186
-function wp_checkdate( $month, $day, $year, $source_date ) {
5186
+function wp_checkdate($month, $day, $year, $source_date) {
5187 5187
 	/**
5188 5188
 	 * Filters whether the given date is valid for the Gregorian calendar.
5189 5189
 	 *
@@ -5192,7 +5192,7 @@  discard block
 block discarded – undo
5192 5192
 	 * @param bool   $checkdate   Whether the given date is valid.
5193 5193
 	 * @param string $source_date Date to check.
5194 5194
 	 */
5195
-	return apply_filters( 'wp_checkdate', checkdate( $month, $day, $year ), $source_date );
5195
+	return apply_filters('wp_checkdate', checkdate($month, $day, $year), $source_date);
5196 5196
 }
5197 5197
 
5198 5198
 /**
@@ -5207,15 +5207,15 @@  discard block
 block discarded – undo
5207 5207
  * @since 3.6.0
5208 5208
  */
5209 5209
 function wp_auth_check_load() {
5210
-	if ( ! is_admin() && ! is_user_logged_in() )
5210
+	if ( ! is_admin() && ! is_user_logged_in())
5211 5211
 		return;
5212 5212
 
5213
-	if ( defined( 'IFRAME_REQUEST' ) )
5213
+	if (defined('IFRAME_REQUEST'))
5214 5214
 		return;
5215 5215
 
5216 5216
 	$screen = get_current_screen();
5217
-	$hidden = array( 'update', 'update-network', 'update-core', 'update-core-network', 'upgrade', 'upgrade-network', 'network' );
5218
-	$show = ! in_array( $screen->id, $hidden );
5217
+	$hidden = array('update', 'update-network', 'update-core', 'update-core-network', 'upgrade', 'upgrade-network', 'network');
5218
+	$show = ! in_array($screen->id, $hidden);
5219 5219
 
5220 5220
 	/**
5221 5221
 	 * Filters whether to load the authentication check.
@@ -5228,12 +5228,12 @@  discard block
 block discarded – undo
5228 5228
 	 * @param bool      $show   Whether to load the authentication check.
5229 5229
 	 * @param WP_Screen $screen The current screen object.
5230 5230
 	 */
5231
-	if ( apply_filters( 'wp_auth_check_load', $show, $screen ) ) {
5232
-		wp_enqueue_style( 'wp-auth-check' );
5233
-		wp_enqueue_script( 'wp-auth-check' );
5231
+	if (apply_filters('wp_auth_check_load', $show, $screen)) {
5232
+		wp_enqueue_style('wp-auth-check');
5233
+		wp_enqueue_script('wp-auth-check');
5234 5234
 
5235
-		add_action( 'admin_print_footer_scripts', 'wp_auth_check_html', 5 );
5236
-		add_action( 'wp_print_footer_scripts', 'wp_auth_check_html', 5 );
5235
+		add_action('admin_print_footer_scripts', 'wp_auth_check_html', 5);
5236
+		add_action('wp_print_footer_scripts', 'wp_auth_check_html', 5);
5237 5237
 	}
5238 5238
 }
5239 5239
 
@@ -5244,8 +5244,8 @@  discard block
 block discarded – undo
5244 5244
  */
5245 5245
 function wp_auth_check_html() {
5246 5246
 	$login_url = wp_login_url();
5247
-	$current_domain = ( is_ssl() ? 'https://' : 'http://' ) . $_SERVER['HTTP_HOST'];
5248
-	$same_domain = ( strpos( $login_url, $current_domain ) === 0 );
5247
+	$current_domain = (is_ssl() ? 'https://' : 'http://').$_SERVER['HTTP_HOST'];
5248
+	$same_domain = (strpos($login_url, $current_domain) === 0);
5249 5249
 
5250 5250
 	/**
5251 5251
 	 * Filters whether the authentication check originated at the same domain.
@@ -5254,26 +5254,26 @@  discard block
 block discarded – undo
5254 5254
 	 *
5255 5255
 	 * @param bool $same_domain Whether the authentication check originated at the same domain.
5256 5256
 	 */
5257
-	$same_domain = apply_filters( 'wp_auth_check_same_domain', $same_domain );
5257
+	$same_domain = apply_filters('wp_auth_check_same_domain', $same_domain);
5258 5258
 	$wrap_class = $same_domain ? 'hidden' : 'hidden fallback';
5259 5259
 
5260 5260
 	?>
5261 5261
 	<div id="wp-auth-check-wrap" class="<?php echo $wrap_class; ?>">
5262 5262
 	<div id="wp-auth-check-bg"></div>
5263 5263
 	<div id="wp-auth-check">
5264
-	<button type="button" class="wp-auth-check-close button-link"><span class="screen-reader-text"><?php _e( 'Close dialog' ); ?></span></button>
5264
+	<button type="button" class="wp-auth-check-close button-link"><span class="screen-reader-text"><?php _e('Close dialog'); ?></span></button>
5265 5265
 	<?php
5266 5266
 
5267
-	if ( $same_domain ) {
5267
+	if ($same_domain) {
5268 5268
 		?>
5269
-		<div id="wp-auth-check-form" class="loading" data-src="<?php echo esc_url( add_query_arg( array( 'interim-login' => 1 ), $login_url ) ); ?>"></div>
5269
+		<div id="wp-auth-check-form" class="loading" data-src="<?php echo esc_url(add_query_arg(array('interim-login' => 1), $login_url)); ?>"></div>
5270 5270
 		<?php
5271 5271
 	}
5272 5272
 
5273 5273
 	?>
5274 5274
 	<div class="wp-auth-fallback">
5275 5275
 		<p><b class="wp-auth-fallback-expired" tabindex="0"><?php _e('Session expired'); ?></b></p>
5276
-		<p><a href="<?php echo esc_url( $login_url ); ?>" target="_blank"><?php _e('Please log in again.'); ?></a>
5276
+		<p><a href="<?php echo esc_url($login_url); ?>" target="_blank"><?php _e('Please log in again.'); ?></a>
5277 5277
 		<?php _e('The login page will open in a new window. After logging in you can close it and return to this page.'); ?></p>
5278 5278
 	</div>
5279 5279
 	</div>
@@ -5294,8 +5294,8 @@  discard block
 block discarded – undo
5294 5294
  * @param array $response  The Heartbeat response.
5295 5295
  * @return array $response The Heartbeat response with 'wp-auth-check' value set.
5296 5296
  */
5297
-function wp_auth_check( $response ) {
5298
-	$response['wp-auth-check'] = is_user_logged_in() && empty( $GLOBALS['login_grace_period'] );
5297
+function wp_auth_check($response) {
5298
+	$response['wp-auth-check'] = is_user_logged_in() && empty($GLOBALS['login_grace_period']);
5299 5299
 	return $response;
5300 5300
 }
5301 5301
 
@@ -5315,10 +5315,10 @@  discard block
 block discarded – undo
5315 5315
  * @param string $tag An HTML tag name. Example: 'video'.
5316 5316
  * @return string Tag RegEx.
5317 5317
  */
5318
-function get_tag_regex( $tag ) {
5319
-	if ( empty( $tag ) )
5318
+function get_tag_regex($tag) {
5319
+	if (empty($tag))
5320 5320
 		return;
5321
-	return sprintf( '<%1$s[^<]*(?:>[\s\S]*<\/%1$s>|\s*\/>)', tag_escape( $tag ) );
5321
+	return sprintf('<%1$s[^<]*(?:>[\s\S]*<\/%1$s>|\s*\/>)', tag_escape($tag));
5322 5322
 }
5323 5323
 
5324 5324
 /**
@@ -5333,13 +5333,13 @@  discard block
 block discarded – undo
5333 5333
  * @param string $charset A charset name.
5334 5334
  * @return string The canonical form of the charset.
5335 5335
  */
5336
-function _canonical_charset( $charset ) {
5337
-	if ( 'utf-8' === strtolower( $charset ) || 'utf8' === strtolower( $charset) ) {
5336
+function _canonical_charset($charset) {
5337
+	if ('utf-8' === strtolower($charset) || 'utf8' === strtolower($charset)) {
5338 5338
 
5339 5339
 		return 'UTF-8';
5340 5340
 	}
5341 5341
 
5342
-	if ( 'iso-8859-1' === strtolower( $charset ) || 'iso8859-1' === strtolower( $charset ) ) {
5342
+	if ('iso-8859-1' === strtolower($charset) || 'iso8859-1' === strtolower($charset)) {
5343 5343
 
5344 5344
 		return 'ISO-8859-1';
5345 5345
 	}
@@ -5373,25 +5373,25 @@  discard block
 block discarded – undo
5373 5373
  * @param bool $reset Optional. Whether to reset the encoding back to a previously-set encoding.
5374 5374
  *                    Default false.
5375 5375
  */
5376
-function mbstring_binary_safe_encoding( $reset = false ) {
5376
+function mbstring_binary_safe_encoding($reset = false) {
5377 5377
 	static $encodings = array();
5378 5378
 	static $overloaded = null;
5379 5379
 
5380
-	if ( is_null( $overloaded ) )
5381
-		$overloaded = function_exists( 'mb_internal_encoding' ) && ( ini_get( 'mbstring.func_overload' ) & 2 );
5380
+	if (is_null($overloaded))
5381
+		$overloaded = function_exists('mb_internal_encoding') && (ini_get('mbstring.func_overload') & 2);
5382 5382
 
5383
-	if ( false === $overloaded )
5383
+	if (false === $overloaded)
5384 5384
 		return;
5385 5385
 
5386
-	if ( ! $reset ) {
5386
+	if ( ! $reset) {
5387 5387
 		$encoding = mb_internal_encoding();
5388
-		array_push( $encodings, $encoding );
5389
-		mb_internal_encoding( 'ISO-8859-1' );
5388
+		array_push($encodings, $encoding);
5389
+		mb_internal_encoding('ISO-8859-1');
5390 5390
 	}
5391 5391
 
5392
-	if ( $reset && $encodings ) {
5393
-		$encoding = array_pop( $encodings );
5394
-		mb_internal_encoding( $encoding );
5392
+	if ($reset && $encodings) {
5393
+		$encoding = array_pop($encodings);
5394
+		mb_internal_encoding($encoding);
5395 5395
 	}
5396 5396
 }
5397 5397
 
@@ -5403,7 +5403,7 @@  discard block
 block discarded – undo
5403 5403
  * @since 3.7.0
5404 5404
  */
5405 5405
 function reset_mbstring_encoding() {
5406
-	mbstring_binary_safe_encoding( true );
5406
+	mbstring_binary_safe_encoding(true);
5407 5407
 }
5408 5408
 
5409 5409
 /**
@@ -5416,12 +5416,12 @@  discard block
 block discarded – undo
5416 5416
  * @param mixed $var Boolean value to validate.
5417 5417
  * @return bool Whether the value is validated.
5418 5418
  */
5419
-function wp_validate_boolean( $var ) {
5420
-	if ( is_bool( $var ) ) {
5419
+function wp_validate_boolean($var) {
5420
+	if (is_bool($var)) {
5421 5421
 		return $var;
5422 5422
 	}
5423 5423
 
5424
-	if ( is_string( $var ) && 'false' === strtolower( $var ) ) {
5424
+	if (is_string($var) && 'false' === strtolower($var)) {
5425 5425
 		return false;
5426 5426
 	}
5427 5427
 
@@ -5435,7 +5435,7 @@  discard block
 block discarded – undo
5435 5435
  *
5436 5436
  * @param string $file The path to the file to delete.
5437 5437
  */
5438
-function wp_delete_file( $file ) {
5438
+function wp_delete_file($file) {
5439 5439
 	/**
5440 5440
 	 * Filters the path of the file to delete.
5441 5441
 	 *
@@ -5443,9 +5443,9 @@  discard block
 block discarded – undo
5443 5443
 	 *
5444 5444
 	 * @param string $file Path to the file to delete.
5445 5445
 	 */
5446
-	$delete = apply_filters( 'wp_delete_file', $file );
5447
-	if ( ! empty( $delete ) ) {
5448
-		@unlink( $delete );
5446
+	$delete = apply_filters('wp_delete_file', $file);
5447
+	if ( ! empty($delete)) {
5448
+		@unlink($delete);
5449 5449
 	}
5450 5450
 }
5451 5451
 
@@ -5459,12 +5459,12 @@  discard block
 block discarded – undo
5459 5459
 function wp_post_preview_js() {
5460 5460
 	global $post;
5461 5461
 
5462
-	if ( ! is_preview() || empty( $post ) ) {
5462
+	if ( ! is_preview() || empty($post)) {
5463 5463
 		return;
5464 5464
 	}
5465 5465
 
5466 5466
 	// Has to match the window name used in post_submit_meta_box()
5467
-	$name = 'wp-preview-' . (int) $post->ID;
5467
+	$name = 'wp-preview-'.(int) $post->ID;
5468 5468
 
5469 5469
 	?>
5470 5470
 	<script>
@@ -5494,11 +5494,11 @@  discard block
 block discarded – undo
5494 5494
  * @param string $date_string Date string to parse and format.
5495 5495
  * @return string Date formatted for ISO8601/RFC3339.
5496 5496
  */
5497
-function mysql_to_rfc3339( $date_string ) {
5498
-	$formatted = mysql2date( 'c', $date_string, false );
5497
+function mysql_to_rfc3339($date_string) {
5498
+	$formatted = mysql2date('c', $date_string, false);
5499 5499
 
5500 5500
 	// Strip timezone information
5501
-	return preg_replace( '/(?:Z|[+-]\d{2}(?::\d{2})?)$/', '', $formatted );
5501
+	return preg_replace('/(?:Z|[+-]\d{2}(?::\d{2})?)$/', '', $formatted);
5502 5502
 }
5503 5503
 
5504 5504
 /**
@@ -5514,24 +5514,24 @@  discard block
 block discarded – undo
5514 5514
  *                        invoked. Default 'admin'.
5515 5515
  * @return bool|int|string The limit that was set or false on failure.
5516 5516
  */
5517
-function wp_raise_memory_limit( $context = 'admin' ) {
5517
+function wp_raise_memory_limit($context = 'admin') {
5518 5518
 	// Exit early if the limit cannot be changed.
5519
-	if ( false === wp_is_ini_value_changeable( 'memory_limit' ) ) {
5519
+	if (false === wp_is_ini_value_changeable('memory_limit')) {
5520 5520
 		return false;
5521 5521
 	}
5522 5522
 
5523
-	$current_limit     = @ini_get( 'memory_limit' );
5524
-	$current_limit_int = wp_convert_hr_to_bytes( $current_limit );
5523
+	$current_limit     = @ini_get('memory_limit');
5524
+	$current_limit_int = wp_convert_hr_to_bytes($current_limit);
5525 5525
 
5526 5526
 	if ( -1 === $current_limit_int ) {
5527 5527
 		return false;
5528 5528
 	}
5529 5529
 
5530 5530
 	$wp_max_limit     = WP_MAX_MEMORY_LIMIT;
5531
-	$wp_max_limit_int = wp_convert_hr_to_bytes( $wp_max_limit );
5531
+	$wp_max_limit_int = wp_convert_hr_to_bytes($wp_max_limit);
5532 5532
 	$filtered_limit   = $wp_max_limit;
5533 5533
 
5534
-	switch ( $context ) {
5534
+	switch ($context) {
5535 5535
 		case 'admin':
5536 5536
 			/**
5537 5537
 			 * Filters the maximum memory limit available for administration screens.
@@ -5551,7 +5551,7 @@  discard block
 block discarded – undo
5551 5551
 			 * @param int|string $filtered_limit The maximum WordPress memory limit. Accepts an integer
5552 5552
 			 *                                   (bytes), or a shorthand string notation, such as '256M'.
5553 5553
 			 */
5554
-			$filtered_limit = apply_filters( 'admin_memory_limit', $filtered_limit );
5554
+			$filtered_limit = apply_filters('admin_memory_limit', $filtered_limit);
5555 5555
 			break;
5556 5556
 
5557 5557
 		case 'image':
@@ -5567,7 +5567,7 @@  discard block
 block discarded – undo
5567 5567
 			 *                                   Accepts an integer (bytes), or a shorthand string
5568 5568
 			 *                                   notation, such as '256M'.
5569 5569
 			 */
5570
-			$filtered_limit = apply_filters( 'image_memory_limit', $filtered_limit );
5570
+			$filtered_limit = apply_filters('image_memory_limit', $filtered_limit);
5571 5571
 			break;
5572 5572
 
5573 5573
 		default:
@@ -5585,20 +5585,20 @@  discard block
 block discarded – undo
5585 5585
 			 *                                   whichever is higher. Accepts an integer (bytes), or a
5586 5586
 			 *                                   shorthand string notation, such as '256M'.
5587 5587
 			 */
5588
-			$filtered_limit = apply_filters( "{$context}_memory_limit", $filtered_limit );
5588
+			$filtered_limit = apply_filters("{$context}_memory_limit", $filtered_limit);
5589 5589
 			break;
5590 5590
 	}
5591 5591
 
5592
-	$filtered_limit_int = wp_convert_hr_to_bytes( $filtered_limit );
5592
+	$filtered_limit_int = wp_convert_hr_to_bytes($filtered_limit);
5593 5593
 
5594
-	if ( -1 === $filtered_limit_int || ( $filtered_limit_int > $wp_max_limit_int && $filtered_limit_int > $current_limit_int ) ) {
5595
-		if ( false !== @ini_set( 'memory_limit', $filtered_limit ) ) {
5594
+	if ( -1 === $filtered_limit_int || ($filtered_limit_int > $wp_max_limit_int && $filtered_limit_int > $current_limit_int) ) {
5595
+		if (false !== @ini_set('memory_limit', $filtered_limit)) {
5596 5596
 			return $filtered_limit;
5597 5597
 		} else {
5598 5598
 			return false;
5599 5599
 		}
5600 5600
 	} elseif ( -1 === $wp_max_limit_int || $wp_max_limit_int > $current_limit_int ) {
5601
-		if ( false !== @ini_set( 'memory_limit', $wp_max_limit ) ) {
5601
+		if (false !== @ini_set('memory_limit', $wp_max_limit)) {
5602 5602
 			return $wp_max_limit;
5603 5603
 		} else {
5604 5604
 			return false;
@@ -5616,12 +5616,12 @@  discard block
 block discarded – undo
5616 5616
  * @return string UUID.
5617 5617
  */
5618 5618
 function wp_generate_uuid4() {
5619
-	return sprintf( '%04x%04x-%04x-%04x-%04x-%04x%04x%04x',
5620
-		mt_rand( 0, 0xffff ), mt_rand( 0, 0xffff ),
5621
-		mt_rand( 0, 0xffff ),
5622
-		mt_rand( 0, 0x0fff ) | 0x4000,
5623
-		mt_rand( 0, 0x3fff ) | 0x8000,
5624
-		mt_rand( 0, 0xffff ), mt_rand( 0, 0xffff ), mt_rand( 0, 0xffff )
5619
+	return sprintf('%04x%04x-%04x-%04x-%04x-%04x%04x%04x',
5620
+		mt_rand(0, 0xffff), mt_rand(0, 0xffff),
5621
+		mt_rand(0, 0xffff),
5622
+		mt_rand(0, 0x0fff) | 0x4000,
5623
+		mt_rand(0, 0x3fff) | 0x8000,
5624
+		mt_rand(0, 0xffff), mt_rand(0, 0xffff), mt_rand(0, 0xffff)
5625 5625
 	);
5626 5626
 }
5627 5627
 
@@ -5634,12 +5634,12 @@  discard block
 block discarded – undo
5634 5634
  *
5635 5635
  * @return string $last_changed UNIX timestamp with microseconds representing when the group was last changed.
5636 5636
  */
5637
-function wp_cache_get_last_changed( $group ) {
5638
-	$last_changed = wp_cache_get( 'last_changed', $group );
5637
+function wp_cache_get_last_changed($group) {
5638
+	$last_changed = wp_cache_get('last_changed', $group);
5639 5639
 
5640
-	if ( ! $last_changed ) {
5640
+	if ( ! $last_changed) {
5641 5641
 		$last_changed = microtime();
5642
-		wp_cache_set( 'last_changed', $last_changed, $group );
5642
+		wp_cache_set('last_changed', $last_changed, $group);
5643 5643
 	}
5644 5644
 
5645 5645
 	return $last_changed;
Please login to merge, or discard this patch.
Braces   +448 added lines, -314 removed lines patch added patch discarded remove patch
@@ -24,22 +24,26 @@  discard block
 block discarded – undo
24 24
  * @return string|int|bool Formatted date string or Unix timestamp. False if $date is empty.
25 25
  */
26 26
 function mysql2date( $format, $date, $translate = true ) {
27
-	if ( empty( $date ) )
28
-		return false;
27
+	if ( empty( $date ) ) {
28
+			return false;
29
+	}
29 30
 
30
-	if ( 'G' == $format )
31
-		return strtotime( $date . ' +0000' );
31
+	if ( 'G' == $format ) {
32
+			return strtotime( $date . ' +0000' );
33
+	}
32 34
 
33 35
 	$i = strtotime( $date );
34 36
 
35
-	if ( 'U' == $format )
36
-		return $i;
37
+	if ( 'U' == $format ) {
38
+			return $i;
39
+	}
37 40
 
38
-	if ( $translate )
39
-		return date_i18n( $format, $i );
40
-	else
41
-		return date( $format, $i );
42
-}
41
+	if ( $translate ) {
42
+			return date_i18n( $format, $i );
43
+	} else {
44
+			return date( $format, $i );
45
+	}
46
+	}
43 47
 
44 48
 /**
45 49
  * Retrieve the current time based on specified type.
@@ -300,11 +304,13 @@  discard block
 block discarded – undo
300 304
 	// The day of the week from the timestamp.
301 305
 	$weekday = date( 'w', $day );
302 306
 
303
-	if ( !is_numeric($start_of_week) )
304
-		$start_of_week = get_option( 'start_of_week' );
307
+	if ( !is_numeric($start_of_week) ) {
308
+			$start_of_week = get_option( 'start_of_week' );
309
+	}
305 310
 
306
-	if ( $weekday < $start_of_week )
307
-		$weekday += 7;
311
+	if ( $weekday < $start_of_week ) {
312
+			$weekday += 7;
313
+	}
308 314
 
309 315
 	// The most recent week start day on or before $day.
310 316
 	$start = $day - DAY_IN_SECONDS * ( $weekday - $start_of_week );
@@ -323,8 +329,10 @@  discard block
 block discarded – undo
323 329
  * @return mixed Unserialized data can be any type.
324 330
  */
325 331
 function maybe_unserialize( $original ) {
326
-	if ( is_serialized( $original ) ) // don't attempt to unserialize data that wasn't serialized going in
332
+	if ( is_serialized( $original ) ) {
333
+		// don't attempt to unserialize data that wasn't serialized going in
327 334
 		return @unserialize( $original );
335
+	}
328 336
 	return $original;
329 337
 }
330 338
 
@@ -364,13 +372,16 @@  discard block
 block discarded – undo
364 372
 		$semicolon = strpos( $data, ';' );
365 373
 		$brace     = strpos( $data, '}' );
366 374
 		// Either ; or } must exist.
367
-		if ( false === $semicolon && false === $brace )
368
-			return false;
375
+		if ( false === $semicolon && false === $brace ) {
376
+					return false;
377
+		}
369 378
 		// But neither must be in the first X characters.
370
-		if ( false !== $semicolon && $semicolon < 3 )
371
-			return false;
372
-		if ( false !== $brace && $brace < 4 )
373
-			return false;
379
+		if ( false !== $semicolon && $semicolon < 3 ) {
380
+					return false;
381
+		}
382
+		if ( false !== $brace && $brace < 4 ) {
383
+					return false;
384
+		}
374 385
 	}
375 386
 	$token = $data[0];
376 387
 	switch ( $token ) {
@@ -433,14 +444,16 @@  discard block
 block discarded – undo
433 444
  * @return mixed A scalar data
434 445
  */
435 446
 function maybe_serialize( $data ) {
436
-	if ( is_array( $data ) || is_object( $data ) )
437
-		return serialize( $data );
447
+	if ( is_array( $data ) || is_object( $data ) ) {
448
+			return serialize( $data );
449
+	}
438 450
 
439 451
 	// Double serialization is required for backward compatibility.
440 452
 	// See https://core.trac.wordpress.org/ticket/12930
441 453
 	// Also the world will end. See WP 3.6.1.
442
-	if ( is_serialized( $data, false ) )
443
-		return serialize( $data );
454
+	if ( is_serialized( $data, false ) ) {
455
+			return serialize( $data );
456
+	}
444 457
 
445 458
 	return $data;
446 459
 }
@@ -568,20 +581,23 @@  discard block
 block discarded – undo
568 581
 	foreach ( $pung as $link_test ) {
569 582
 		if ( ! in_array( $link_test, $post_links_temp ) ) { // link no longer in post
570 583
 			$mids = $wpdb->get_col( $wpdb->prepare("SELECT meta_id FROM $wpdb->postmeta WHERE post_id = %d AND meta_key = 'enclosure' AND meta_value LIKE %s", $post_ID, $wpdb->esc_like( $link_test ) . '%') );
571
-			foreach ( $mids as $mid )
572
-				delete_metadata_by_mid( 'post', $mid );
584
+			foreach ( $mids as $mid ) {
585
+							delete_metadata_by_mid( 'post', $mid );
586
+			}
573 587
 		}
574 588
 	}
575 589
 
576 590
 	foreach ( (array) $post_links_temp as $link_test ) {
577 591
 		if ( !in_array( $link_test, $pung ) ) { // If we haven't pung it already
578 592
 			$test = @parse_url( $link_test );
579
-			if ( false === $test )
580
-				continue;
581
-			if ( isset( $test['query'] ) )
582
-				$post_links[] = $link_test;
583
-			elseif ( isset($test['path']) && ( $test['path'] != '/' ) &&  ($test['path'] != '' ) )
584
-				$post_links[] = $link_test;
593
+			if ( false === $test ) {
594
+							continue;
595
+			}
596
+			if ( isset( $test['query'] ) ) {
597
+							$post_links[] = $link_test;
598
+			} elseif ( isset($test['path']) && ( $test['path'] != '/' ) &&  ($test['path'] != '' ) ) {
599
+							$post_links[] = $link_test;
600
+			}
585 601
 		}
586 602
 	}
587 603
 
@@ -639,13 +655,15 @@  discard block
 block discarded – undo
639 655
  * @return bool|string False on failure, headers on success.
640 656
  */
641 657
 function wp_get_http_headers( $url, $deprecated = false ) {
642
-	if ( !empty( $deprecated ) )
643
-		_deprecated_argument( __FUNCTION__, '2.7.0' );
658
+	if ( !empty( $deprecated ) ) {
659
+			_deprecated_argument( __FUNCTION__, '2.7.0' );
660
+	}
644 661
 
645 662
 	$response = wp_safe_remote_head( $url );
646 663
 
647
-	if ( is_wp_error( $response ) )
648
-		return false;
664
+	if ( is_wp_error( $response ) ) {
665
+			return false;
666
+	}
649 667
 
650 668
 	return wp_remote_retrieve_headers( $response );
651 669
 }
@@ -663,11 +681,12 @@  discard block
 block discarded – undo
663 681
  */
664 682
 function is_new_day() {
665 683
 	global $currentday, $previousday;
666
-	if ( $currentday != $previousday )
667
-		return 1;
668
-	else
669
-		return 0;
670
-}
684
+	if ( $currentday != $previousday ) {
685
+			return 1;
686
+	} else {
687
+			return 0;
688
+	}
689
+	}
671 690
 
672 691
 /**
673 692
  * Build URL query based on an associative and, or indexed array.
@@ -710,27 +729,33 @@  discard block
 block discarded – undo
710 729
 	$ret = array();
711 730
 
712 731
 	foreach ( (array) $data as $k => $v ) {
713
-		if ( $urlencode)
714
-			$k = urlencode($k);
715
-		if ( is_int($k) && $prefix != null )
716
-			$k = $prefix.$k;
717
-		if ( !empty($key) )
718
-			$k = $key . '%5B' . $k . '%5D';
719
-		if ( $v === null )
720
-			continue;
721
-		elseif ( $v === false )
722
-			$v = '0';
732
+		if ( $urlencode) {
733
+					$k = urlencode($k);
734
+		}
735
+		if ( is_int($k) && $prefix != null ) {
736
+					$k = $prefix.$k;
737
+		}
738
+		if ( !empty($key) ) {
739
+					$k = $key . '%5B' . $k . '%5D';
740
+		}
741
+		if ( $v === null ) {
742
+					continue;
743
+		} elseif ( $v === false ) {
744
+					$v = '0';
745
+		}
723 746
 
724
-		if ( is_array($v) || is_object($v) )
725
-			array_push($ret,_http_build_query($v, '', $sep, $k, $urlencode));
726
-		elseif ( $urlencode )
727
-			array_push($ret, $k.'='.urlencode($v));
728
-		else
729
-			array_push($ret, $k.'='.$v);
747
+		if ( is_array($v) || is_object($v) ) {
748
+					array_push($ret,_http_build_query($v, '', $sep, $k, $urlencode));
749
+		} elseif ( $urlencode ) {
750
+					array_push($ret, $k.'='.urlencode($v));
751
+		} else {
752
+					array_push($ret, $k.'='.$v);
753
+		}
730 754
 	}
731 755
 
732
-	if ( null === $sep )
733
-		$sep = ini_get('arg_separator.output');
756
+	if ( null === $sep ) {
757
+			$sep = ini_get('arg_separator.output');
758
+	}
734 759
 
735 760
 	return implode($sep, $ret);
736 761
 }
@@ -773,21 +798,24 @@  discard block
 block discarded – undo
773 798
 function add_query_arg() {
774 799
 	$args = func_get_args();
775 800
 	if ( is_array( $args[0] ) ) {
776
-		if ( count( $args ) < 2 || false === $args[1] )
777
-			$uri = $_SERVER['REQUEST_URI'];
778
-		else
779
-			$uri = $args[1];
801
+		if ( count( $args ) < 2 || false === $args[1] ) {
802
+					$uri = $_SERVER['REQUEST_URI'];
803
+		} else {
804
+					$uri = $args[1];
805
+		}
780 806
 	} else {
781
-		if ( count( $args ) < 3 || false === $args[2] )
782
-			$uri = $_SERVER['REQUEST_URI'];
783
-		else
784
-			$uri = $args[2];
807
+		if ( count( $args ) < 3 || false === $args[2] ) {
808
+					$uri = $_SERVER['REQUEST_URI'];
809
+		} else {
810
+					$uri = $args[2];
811
+		}
785 812
 	}
786 813
 
787
-	if ( $frag = strstr( $uri, '#' ) )
788
-		$uri = substr( $uri, 0, -strlen( $frag ) );
789
-	else
790
-		$frag = '';
814
+	if ( $frag = strstr( $uri, '#' ) ) {
815
+			$uri = substr( $uri, 0, -strlen( $frag ) );
816
+	} else {
817
+			$frag = '';
818
+	}
791 819
 
792 820
 	if ( 0 === stripos( $uri, 'http://' ) ) {
793 821
 		$protocol = 'http://';
@@ -821,8 +849,9 @@  discard block
 block discarded – undo
821 849
 	}
822 850
 
823 851
 	foreach ( $qs as $k => $v ) {
824
-		if ( $v === false )
825
-			unset( $qs[$k] );
852
+		if ( $v === false ) {
853
+					unset( $qs[$k] );
854
+		}
826 855
 	}
827 856
 
828 857
 	$ret = build_query( $qs );
@@ -844,8 +873,9 @@  discard block
 block discarded – undo
844 873
  */
845 874
 function remove_query_arg( $key, $query = false ) {
846 875
 	if ( is_array( $key ) ) { // removing multiple keys
847
-		foreach ( $key as $k )
848
-			$query = add_query_arg( $k, false, $query );
876
+		foreach ( $key as $k ) {
877
+					$query = add_query_arg( $k, false, $query );
878
+		}
849 879
 		return $query;
850 880
 	}
851 881
 	return add_query_arg( $key, false, $query );
@@ -927,16 +957,18 @@  discard block
 block discarded – undo
927 957
 function wp_remote_fopen( $uri ) {
928 958
 	$parsed_url = @parse_url( $uri );
929 959
 
930
-	if ( !$parsed_url || !is_array( $parsed_url ) )
931
-		return false;
960
+	if ( !$parsed_url || !is_array( $parsed_url ) ) {
961
+			return false;
962
+	}
932 963
 
933 964
 	$options = array();
934 965
 	$options['timeout'] = 10;
935 966
 
936 967
 	$response = wp_safe_remote_get( $uri, $options );
937 968
 
938
-	if ( is_wp_error( $response ) )
939
-		return false;
969
+	if ( is_wp_error( $response ) ) {
970
+			return false;
971
+	}
940 972
 
941 973
 	return wp_remote_retrieve_body( $response );
942 974
 }
@@ -956,9 +988,10 @@  discard block
 block discarded – undo
956 988
 	global $wp, $wp_query, $wp_the_query;
957 989
 	$wp->main( $query_vars );
958 990
 
959
-	if ( !isset($wp_the_query) )
960
-		$wp_the_query = $wp_query;
961
-}
991
+	if ( !isset($wp_the_query) ) {
992
+			$wp_the_query = $wp_query;
993
+	}
994
+	}
962 995
 
963 996
 /**
964 997
  * Retrieve the description for the HTTP status.
@@ -1043,11 +1076,12 @@  discard block
 block discarded – undo
1043 1076
 		);
1044 1077
 	}
1045 1078
 
1046
-	if ( isset( $wp_header_to_desc[$code] ) )
1047
-		return $wp_header_to_desc[$code];
1048
-	else
1049
-		return '';
1050
-}
1079
+	if ( isset( $wp_header_to_desc[$code] ) ) {
1080
+			return $wp_header_to_desc[$code];
1081
+	} else {
1082
+			return '';
1083
+	}
1084
+	}
1051 1085
 
1052 1086
 /**
1053 1087
  * Set HTTP status header.
@@ -1071,8 +1105,8 @@  discard block
 block discarded – undo
1071 1105
 
1072 1106
 	$protocol = wp_get_server_protocol();
1073 1107
 	$status_header = "$protocol $code $description";
1074
-	if ( function_exists( 'apply_filters' ) )
1075
-
1108
+	if ( function_exists( 'apply_filters' ) ) {
1109
+	
1076 1110
 		/**
1077 1111
 		 * Filters an HTTP status header.
1078 1112
 		 *
@@ -1084,6 +1118,7 @@  discard block
 block discarded – undo
1084 1118
 		 * @param string $protocol      Server protocol.
1085 1119
 		 */
1086 1120
 		$status_header = apply_filters( 'status_header', $status_header, $code, $description, $protocol );
1121
+	}
1087 1122
 
1088 1123
 	@header( $status_header, true, $code );
1089 1124
 }
@@ -1155,9 +1190,10 @@  discard block
 block discarded – undo
1155 1190
 		}
1156 1191
 	}
1157 1192
 
1158
-	foreach ( $headers as $name => $field_value )
1159
-		@header("{$name}: {$field_value}");
1160
-}
1193
+	foreach ( $headers as $name => $field_value ) {
1194
+			@header("{$name}: {$field_value}");
1195
+	}
1196
+	}
1161 1197
 
1162 1198
 /**
1163 1199
  * Set the headers for caching for 10 days with JavaScript content type.
@@ -1220,8 +1256,9 @@  discard block
 block discarded – undo
1220 1256
 	// Remove the pad, if present.
1221 1257
 	$feed = preg_replace( '/^_+/', '', $feed );
1222 1258
 
1223
-	if ( $feed == '' || $feed == 'feed' )
1224
-		$feed = get_default_feed();
1259
+	if ( $feed == '' || $feed == 'feed' ) {
1260
+			$feed = get_default_feed();
1261
+	}
1225 1262
 
1226 1263
 	if ( ! has_action( "do_feed_{$feed}" ) ) {
1227 1264
 		wp_die( __( 'ERROR: This is not a valid feed template.' ), '', array( 'response' => 404 ) );
@@ -1274,11 +1311,12 @@  discard block
 block discarded – undo
1274 1311
  * @param bool $for_comments True for the comment feed, false for normal feed.
1275 1312
  */
1276 1313
 function do_feed_rss2( $for_comments ) {
1277
-	if ( $for_comments )
1278
-		load_template( ABSPATH . WPINC . '/feed-rss2-comments.php' );
1279
-	else
1280
-		load_template( ABSPATH . WPINC . '/feed-rss2.php' );
1281
-}
1314
+	if ( $for_comments ) {
1315
+			load_template( ABSPATH . WPINC . '/feed-rss2-comments.php' );
1316
+	} else {
1317
+			load_template( ABSPATH . WPINC . '/feed-rss2.php' );
1318
+	}
1319
+	}
1282 1320
 
1283 1321
 /**
1284 1322
  * Load either Atom comment feed or Atom posts feed.
@@ -1290,11 +1328,12 @@  discard block
 block discarded – undo
1290 1328
  * @param bool $for_comments True for the comment feed, false for normal feed.
1291 1329
  */
1292 1330
 function do_feed_atom( $for_comments ) {
1293
-	if ($for_comments)
1294
-		load_template( ABSPATH . WPINC . '/feed-atom-comments.php');
1295
-	else
1296
-		load_template( ABSPATH . WPINC . '/feed-atom.php' );
1297
-}
1331
+	if ($for_comments) {
1332
+			load_template( ABSPATH . WPINC . '/feed-atom-comments.php');
1333
+	} else {
1334
+			load_template( ABSPATH . WPINC . '/feed-atom.php' );
1335
+	}
1336
+	}
1298 1337
 
1299 1338
 /**
1300 1339
  * Display the robots.txt file content.
@@ -1358,29 +1397,33 @@  discard block
 block discarded – undo
1358 1397
 	 * Check cache first. If options table goes away and we have true
1359 1398
 	 * cached, oh well.
1360 1399
 	 */
1361
-	if ( wp_cache_get( 'is_blog_installed' ) )
1362
-		return true;
1400
+	if ( wp_cache_get( 'is_blog_installed' ) ) {
1401
+			return true;
1402
+	}
1363 1403
 
1364 1404
 	$suppress = $wpdb->suppress_errors();
1365 1405
 	if ( ! wp_installing() ) {
1366 1406
 		$alloptions = wp_load_alloptions();
1367 1407
 	}
1368 1408
 	// If siteurl is not set to autoload, check it specifically
1369
-	if ( !isset( $alloptions['siteurl'] ) )
1370
-		$installed = $wpdb->get_var( "SELECT option_value FROM $wpdb->options WHERE option_name = 'siteurl'" );
1371
-	else
1372
-		$installed = $alloptions['siteurl'];
1409
+	if ( !isset( $alloptions['siteurl'] ) ) {
1410
+			$installed = $wpdb->get_var( "SELECT option_value FROM $wpdb->options WHERE option_name = 'siteurl'" );
1411
+	} else {
1412
+			$installed = $alloptions['siteurl'];
1413
+	}
1373 1414
 	$wpdb->suppress_errors( $suppress );
1374 1415
 
1375 1416
 	$installed = !empty( $installed );
1376 1417
 	wp_cache_set( 'is_blog_installed', $installed );
1377 1418
 
1378
-	if ( $installed )
1379
-		return true;
1419
+	if ( $installed ) {
1420
+			return true;
1421
+	}
1380 1422
 
1381 1423
 	// If visiting repair.php, return true and let it take over.
1382
-	if ( defined( 'WP_REPAIRING' ) )
1383
-		return true;
1424
+	if ( defined( 'WP_REPAIRING' ) ) {
1425
+			return true;
1426
+	}
1384 1427
 
1385 1428
 	$suppress = $wpdb->suppress_errors();
1386 1429
 
@@ -1392,13 +1435,16 @@  discard block
 block discarded – undo
1392 1435
 	$wp_tables = $wpdb->tables();
1393 1436
 	foreach ( $wp_tables as $table ) {
1394 1437
 		// The existence of custom user tables shouldn't suggest an insane state or prevent a clean install.
1395
-		if ( defined( 'CUSTOM_USER_TABLE' ) && CUSTOM_USER_TABLE == $table )
1396
-			continue;
1397
-		if ( defined( 'CUSTOM_USER_META_TABLE' ) && CUSTOM_USER_META_TABLE == $table )
1398
-			continue;
1438
+		if ( defined( 'CUSTOM_USER_TABLE' ) && CUSTOM_USER_TABLE == $table ) {
1439
+					continue;
1440
+		}
1441
+		if ( defined( 'CUSTOM_USER_META_TABLE' ) && CUSTOM_USER_META_TABLE == $table ) {
1442
+					continue;
1443
+		}
1399 1444
 
1400
-		if ( ! $wpdb->get_results( "DESCRIBE $table;" ) )
1401
-			continue;
1445
+		if ( ! $wpdb->get_results( "DESCRIBE $table;" ) ) {
1446
+					continue;
1447
+		}
1402 1448
 
1403 1449
 		// One or more tables exist. We are insane.
1404 1450
 
@@ -1466,11 +1512,13 @@  discard block
 block discarded – undo
1466 1512
 	$name = esc_attr( $name );
1467 1513
 	$nonce_field = '<input type="hidden" id="' . $name . '" name="' . $name . '" value="' . wp_create_nonce( $action ) . '" />';
1468 1514
 
1469
-	if ( $referer )
1470
-		$nonce_field .= wp_referer_field( false );
1515
+	if ( $referer ) {
1516
+			$nonce_field .= wp_referer_field( false );
1517
+	}
1471 1518
 
1472
-	if ( $echo )
1473
-		echo $nonce_field;
1519
+	if ( $echo ) {
1520
+			echo $nonce_field;
1521
+	}
1474 1522
 
1475 1523
 	return $nonce_field;
1476 1524
 }
@@ -1489,8 +1537,9 @@  discard block
 block discarded – undo
1489 1537
 function wp_referer_field( $echo = true ) {
1490 1538
 	$referer_field = '<input type="hidden" name="_wp_http_referer" value="'. esc_attr( wp_unslash( $_SERVER['REQUEST_URI'] ) ) . '" />';
1491 1539
 
1492
-	if ( $echo )
1493
-		echo $referer_field;
1540
+	if ( $echo ) {
1541
+			echo $referer_field;
1542
+	}
1494 1543
 	return $referer_field;
1495 1544
 }
1496 1545
 
@@ -1513,8 +1562,9 @@  discard block
 block discarded – undo
1513 1562
 		$ref = 'previous' == $jump_back_to ? wp_get_referer() : wp_unslash( $_SERVER['REQUEST_URI'] );
1514 1563
 	}
1515 1564
 	$orig_referer_field = '<input type="hidden" name="_wp_original_http_referer" value="' . esc_attr( $ref ) . '" />';
1516
-	if ( $echo )
1517
-		echo $orig_referer_field;
1565
+	if ( $echo ) {
1566
+			echo $orig_referer_field;
1567
+	}
1518 1568
 	return $orig_referer_field;
1519 1569
 }
1520 1570
 
@@ -1568,8 +1618,9 @@  discard block
 block discarded – undo
1568 1618
  * @return string|false False if no original referer or original referer if set.
1569 1619
  */
1570 1620
 function wp_get_original_referer() {
1571
-	if ( ! empty( $_REQUEST['_wp_original_http_referer'] ) && function_exists( 'wp_validate_redirect' ) )
1572
-		return wp_validate_redirect( wp_unslash( $_REQUEST['_wp_original_http_referer'] ), false );
1621
+	if ( ! empty( $_REQUEST['_wp_original_http_referer'] ) && function_exists( 'wp_validate_redirect' ) ) {
1622
+			return wp_validate_redirect( wp_unslash( $_REQUEST['_wp_original_http_referer'] ), false );
1623
+	}
1573 1624
 	return false;
1574 1625
 }
1575 1626
 
@@ -1604,11 +1655,13 @@  discard block
 block discarded – undo
1604 1655
 	 * Use rtrim() instead of untrailingslashit to avoid formatting.php dependency.
1605 1656
 	 */
1606 1657
 	$target = rtrim($target, '/');
1607
-	if ( empty($target) )
1608
-		$target = '/';
1658
+	if ( empty($target) ) {
1659
+			$target = '/';
1660
+	}
1609 1661
 
1610
-	if ( file_exists( $target ) )
1611
-		return @is_dir( $target );
1662
+	if ( file_exists( $target ) ) {
1663
+			return @is_dir( $target );
1664
+	}
1612 1665
 
1613 1666
 	// We need to find the permissions of the parent folder that exists and inherit that.
1614 1667
 	$target_parent = dirname( $target );
@@ -1657,15 +1710,18 @@  discard block
 block discarded – undo
1657 1710
 	 * This is definitive if true but fails if $path does not exist or contains
1658 1711
 	 * a symbolic link.
1659 1712
 	 */
1660
-	if ( realpath($path) == $path )
1661
-		return true;
1713
+	if ( realpath($path) == $path ) {
1714
+			return true;
1715
+	}
1662 1716
 
1663
-	if ( strlen($path) == 0 || $path[0] == '.' )
1664
-		return false;
1717
+	if ( strlen($path) == 0 || $path[0] == '.' ) {
1718
+			return false;
1719
+	}
1665 1720
 
1666 1721
 	// Windows allows absolute paths like this.
1667
-	if ( preg_match('#^[a-zA-Z]:\\\\#', $path) )
1668
-		return true;
1722
+	if ( preg_match('#^[a-zA-Z]:\\\\#', $path) ) {
1723
+			return true;
1724
+	}
1669 1725
 
1670 1726
 	// A path starting with / or \ is absolute; anything else is relative.
1671 1727
 	return ( $path[0] == '/' || $path[0] == '\\' );
@@ -1684,8 +1740,9 @@  discard block
 block discarded – undo
1684 1740
  * @return string The path with the base or absolute path.
1685 1741
  */
1686 1742
 function path_join( $base, $path ) {
1687
-	if ( path_is_absolute($path) )
1688
-		return $path;
1743
+	if ( path_is_absolute($path) ) {
1744
+			return $path;
1745
+	}
1689 1746
 
1690 1747
 	return rtrim($base, '/') . '/' . ltrim($path, '/');
1691 1748
 }
@@ -1732,25 +1789,30 @@  discard block
 block discarded – undo
1732 1789
  */
1733 1790
 function get_temp_dir() {
1734 1791
 	static $temp = '';
1735
-	if ( defined('WP_TEMP_DIR') )
1736
-		return trailingslashit(WP_TEMP_DIR);
1792
+	if ( defined('WP_TEMP_DIR') ) {
1793
+			return trailingslashit(WP_TEMP_DIR);
1794
+	}
1737 1795
 
1738
-	if ( $temp )
1739
-		return trailingslashit( $temp );
1796
+	if ( $temp ) {
1797
+			return trailingslashit( $temp );
1798
+	}
1740 1799
 
1741 1800
 	if ( function_exists('sys_get_temp_dir') ) {
1742 1801
 		$temp = sys_get_temp_dir();
1743
-		if ( @is_dir( $temp ) && wp_is_writable( $temp ) )
1744
-			return trailingslashit( $temp );
1802
+		if ( @is_dir( $temp ) && wp_is_writable( $temp ) ) {
1803
+					return trailingslashit( $temp );
1804
+		}
1745 1805
 	}
1746 1806
 
1747 1807
 	$temp = ini_get('upload_tmp_dir');
1748
-	if ( @is_dir( $temp ) && wp_is_writable( $temp ) )
1749
-		return trailingslashit( $temp );
1808
+	if ( @is_dir( $temp ) && wp_is_writable( $temp ) ) {
1809
+			return trailingslashit( $temp );
1810
+	}
1750 1811
 
1751 1812
 	$temp = WP_CONTENT_DIR . '/';
1752
-	if ( is_dir( $temp ) && wp_is_writable( $temp ) )
1753
-		return $temp;
1813
+	if ( is_dir( $temp ) && wp_is_writable( $temp ) ) {
1814
+			return $temp;
1815
+	}
1754 1816
 
1755 1817
 	return '/tmp/';
1756 1818
 }
@@ -1769,11 +1831,12 @@  discard block
 block discarded – undo
1769 1831
  * @return bool Whether the path is writable.
1770 1832
  */
1771 1833
 function wp_is_writable( $path ) {
1772
-	if ( 'WIN' === strtoupper( substr( PHP_OS, 0, 3 ) ) )
1773
-		return win_is_writable( $path );
1774
-	else
1775
-		return @is_writable( $path );
1776
-}
1834
+	if ( 'WIN' === strtoupper( substr( PHP_OS, 0, 3 ) ) ) {
1835
+			return win_is_writable( $path );
1836
+	} else {
1837
+			return @is_writable( $path );
1838
+	}
1839
+	}
1777 1840
 
1778 1841
 /**
1779 1842
  * Workaround for Windows bug in is_writable() function
@@ -1801,11 +1864,13 @@  discard block
 block discarded – undo
1801 1864
 	// check tmp file for read/write capabilities
1802 1865
 	$should_delete_tmp_file = !file_exists( $path );
1803 1866
 	$f = @fopen( $path, 'a' );
1804
-	if ( $f === false )
1805
-		return false;
1867
+	if ( $f === false ) {
1868
+			return false;
1869
+	}
1806 1870
 	fclose( $f );
1807
-	if ( $should_delete_tmp_file )
1808
-		unlink( $path );
1871
+	if ( $should_delete_tmp_file ) {
1872
+			unlink( $path );
1873
+	}
1809 1874
 	return true;
1810 1875
 }
1811 1876
 
@@ -1931,10 +1996,11 @@  discard block
 block discarded – undo
1931 1996
 	}
1932 1997
 
1933 1998
 	if ( !$url = get_option( 'upload_url_path' ) ) {
1934
-		if ( empty($upload_path) || ( 'wp-content/uploads' == $upload_path ) || ( $upload_path == $dir ) )
1935
-			$url = WP_CONTENT_URL . '/uploads';
1936
-		else
1937
-			$url = trailingslashit( $siteurl ) . $upload_path;
1999
+		if ( empty($upload_path) || ( 'wp-content/uploads' == $upload_path ) || ( $upload_path == $dir ) ) {
2000
+					$url = WP_CONTENT_URL . '/uploads';
2001
+		} else {
2002
+					$url = trailingslashit( $siteurl ) . $upload_path;
2003
+		}
1938 2004
 	}
1939 2005
 
1940 2006
 	/*
@@ -1959,10 +2025,11 @@  discard block
 block discarded – undo
1959 2025
 			 * had wp-content/uploads for the main site.)
1960 2026
 			 */
1961 2027
 
1962
-			if ( defined( 'MULTISITE' ) )
1963
-				$ms_dir = '/sites/' . get_current_blog_id();
1964
-			else
1965
-				$ms_dir = '/' . get_current_blog_id();
2028
+			if ( defined( 'MULTISITE' ) ) {
2029
+							$ms_dir = '/sites/' . get_current_blog_id();
2030
+			} else {
2031
+							$ms_dir = '/' . get_current_blog_id();
2032
+			}
1966 2033
 
1967 2034
 			$dir .= $ms_dir;
1968 2035
 			$url .= $ms_dir;
@@ -1982,10 +2049,11 @@  discard block
 block discarded – undo
1982 2049
 			 * rewriting in multisite, the resulting URL is /files. (#WP22702 for background.)
1983 2050
 			 */
1984 2051
 
1985
-			if ( defined( 'BLOGUPLOADDIR' ) )
1986
-				$dir = untrailingslashit( BLOGUPLOADDIR );
1987
-			else
1988
-				$dir = ABSPATH . UPLOADS;
2052
+			if ( defined( 'BLOGUPLOADDIR' ) ) {
2053
+							$dir = untrailingslashit( BLOGUPLOADDIR );
2054
+			} else {
2055
+							$dir = ABSPATH . UPLOADS;
2056
+			}
1989 2057
 			$url = trailingslashit( $siteurl ) . 'files';
1990 2058
 		}
1991 2059
 	}
@@ -1996,8 +2064,9 @@  discard block
 block discarded – undo
1996 2064
 	$subdir = '';
1997 2065
 	if ( get_option( 'uploads_use_yearmonth_folders' ) ) {
1998 2066
 		// Generate the yearly and monthly dirs
1999
-		if ( !$time )
2000
-			$time = current_time( 'mysql' );
2067
+		if ( !$time ) {
2068
+					$time = current_time( 'mysql' );
2069
+		}
2001 2070
 		$y = substr( $time, 0, 4 );
2002 2071
 		$m = substr( $time, 5, 2 );
2003 2072
 		$subdir = "/$y/$m";
@@ -2123,20 +2192,24 @@  discard block
 block discarded – undo
2123 2192
  * @return array
2124 2193
  */
2125 2194
 function wp_upload_bits( $name, $deprecated, $bits, $time = null ) {
2126
-	if ( !empty( $deprecated ) )
2127
-		_deprecated_argument( __FUNCTION__, '2.0.0' );
2195
+	if ( !empty( $deprecated ) ) {
2196
+			_deprecated_argument( __FUNCTION__, '2.0.0' );
2197
+	}
2128 2198
 
2129
-	if ( empty( $name ) )
2130
-		return array( 'error' => __( 'Empty filename' ) );
2199
+	if ( empty( $name ) ) {
2200
+			return array( 'error' => __( 'Empty filename' ) );
2201
+	}
2131 2202
 
2132 2203
 	$wp_filetype = wp_check_filetype( $name );
2133
-	if ( ! $wp_filetype['ext'] && ! current_user_can( 'unfiltered_upload' ) )
2134
-		return array( 'error' => __( 'Sorry, this file type is not permitted for security reasons.' ) );
2204
+	if ( ! $wp_filetype['ext'] && ! current_user_can( 'unfiltered_upload' ) ) {
2205
+			return array( 'error' => __( 'Sorry, this file type is not permitted for security reasons.' ) );
2206
+	}
2135 2207
 
2136 2208
 	$upload = wp_upload_dir( $time );
2137 2209
 
2138
-	if ( $upload['error'] !== false )
2139
-		return $upload;
2210
+	if ( $upload['error'] !== false ) {
2211
+			return $upload;
2212
+	}
2140 2213
 
2141 2214
 	/**
2142 2215
 	 * Filters whether to treat the upload bits as an error.
@@ -2158,10 +2231,11 @@  discard block
 block discarded – undo
2158 2231
 
2159 2232
 	$new_file = $upload['path'] . "/$filename";
2160 2233
 	if ( ! wp_mkdir_p( dirname( $new_file ) ) ) {
2161
-		if ( 0 === strpos( $upload['basedir'], ABSPATH ) )
2162
-			$error_path = str_replace( ABSPATH, '', $upload['basedir'] ) . $upload['subdir'];
2163
-		else
2164
-			$error_path = basename( $upload['basedir'] ) . $upload['subdir'];
2234
+		if ( 0 === strpos( $upload['basedir'], ABSPATH ) ) {
2235
+					$error_path = str_replace( ABSPATH, '', $upload['basedir'] ) . $upload['subdir'];
2236
+		} else {
2237
+					$error_path = basename( $upload['basedir'] ) . $upload['subdir'];
2238
+		}
2165 2239
 
2166 2240
 		$message = sprintf(
2167 2241
 			/* translators: %s: directory path */
@@ -2172,8 +2246,9 @@  discard block
 block discarded – undo
2172 2246
 	}
2173 2247
 
2174 2248
 	$ifp = @ fopen( $new_file, 'wb' );
2175
-	if ( ! $ifp )
2176
-		return array( 'error' => sprintf( __( 'Could not write file %s' ), $new_file ) );
2249
+	if ( ! $ifp ) {
2250
+			return array( 'error' => sprintf( __( 'Could not write file %s' ), $new_file ) );
2251
+	}
2177 2252
 
2178 2253
 	@fwrite( $ifp, $bits );
2179 2254
 	fclose( $ifp );
@@ -2205,10 +2280,11 @@  discard block
 block discarded – undo
2205 2280
 	$ext = strtolower( $ext );
2206 2281
 
2207 2282
 	$ext2type = wp_get_ext_types();
2208
-	foreach ( $ext2type as $type => $exts )
2209
-		if ( in_array( $ext, $exts ) )
2283
+	foreach ( $ext2type as $type => $exts ) {
2284
+			if ( in_array( $ext, $exts ) )
2210 2285
 			return $type;
2211
-}
2286
+	}
2287
+	}
2212 2288
 
2213 2289
 /**
2214 2290
  * Retrieve the file type from the file name.
@@ -2222,8 +2298,9 @@  discard block
 block discarded – undo
2222 2298
  * @return array Values with extension first and mime type.
2223 2299
  */
2224 2300
 function wp_check_filetype( $filename, $mimes = null ) {
2225
-	if ( empty($mimes) )
2226
-		$mimes = get_allowed_mime_types();
2301
+	if ( empty($mimes) ) {
2302
+			$mimes = get_allowed_mime_types();
2303
+	}
2227 2304
 	$type = false;
2228 2305
 	$ext = false;
2229 2306
 
@@ -2552,11 +2629,13 @@  discard block
 block discarded – undo
2552 2629
 	$t = wp_get_mime_types();
2553 2630
 
2554 2631
 	unset( $t['swf'], $t['exe'] );
2555
-	if ( function_exists( 'current_user_can' ) )
2556
-		$unfiltered = $user ? user_can( $user, 'unfiltered_html' ) : current_user_can( 'unfiltered_html' );
2632
+	if ( function_exists( 'current_user_can' ) ) {
2633
+			$unfiltered = $user ? user_can( $user, 'unfiltered_html' ) : current_user_can( 'unfiltered_html' );
2634
+	}
2557 2635
 
2558
-	if ( empty( $unfiltered ) )
2559
-		unset( $t['htm|html'] );
2636
+	if ( empty( $unfiltered ) ) {
2637
+			unset( $t['htm|html'] );
2638
+	}
2560 2639
 
2561 2640
 	/**
2562 2641
 	 * Filters list of allowed mime types and file extensions.
@@ -2706,8 +2785,9 @@  discard block
 block discarded – undo
2706 2785
 	if ( function_exists( 'is_wp_error' ) && is_wp_error( $message ) ) {
2707 2786
 		if ( empty( $title ) ) {
2708 2787
 			$error_data = $message->get_error_data();
2709
-			if ( is_array( $error_data ) && isset( $error_data['title'] ) )
2710
-				$title = $error_data['title'];
2788
+			if ( is_array( $error_data ) && isset( $error_data['title'] ) ) {
2789
+							$title = $error_data['title'];
2790
+			}
2711 2791
 		}
2712 2792
 		$errors = $message->get_error_messages();
2713 2793
 		switch ( count( $errors ) ) {
@@ -2737,19 +2817,26 @@  discard block
 block discarded – undo
2737 2817
 			header( 'Content-Type: text/html; charset=utf-8' );
2738 2818
 		}
2739 2819
 
2740
-		if ( empty($title) )
2741
-			$title = $have_gettext ? __('WordPress &rsaquo; Error') : 'WordPress &rsaquo; Error';
2820
+		if ( empty($title) ) {
2821
+					$title = $have_gettext ? __('WordPress &rsaquo; Error') : 'WordPress &rsaquo; Error';
2822
+		}
2742 2823
 
2743 2824
 		$text_direction = 'ltr';
2744
-		if ( isset($r['text_direction']) && 'rtl' == $r['text_direction'] )
2745
-			$text_direction = 'rtl';
2746
-		elseif ( function_exists( 'is_rtl' ) && is_rtl() )
2747
-			$text_direction = 'rtl';
2748
-?>
2825
+		if ( isset($r['text_direction']) && 'rtl' == $r['text_direction'] ) {
2826
+					$text_direction = 'rtl';
2827
+		} elseif ( function_exists( 'is_rtl' ) && is_rtl() ) {
2828
+					$text_direction = 'rtl';
2829
+		}
2830
+		?>
2749 2831
 <!DOCTYPE html>
2750 2832
 <!-- Ticket #11289, IE bug fix: always pad the error page with enough characters such that it is greater than 512 bytes, even after gzip compression abcdefghijklmnopqrstuvwxyz1234567890aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz11223344556677889900abacbcbdcdcededfefegfgfhghgihihjijikjkjlklkmlmlnmnmononpopoqpqprqrqsrsrtstsubcbcdcdedefefgfabcadefbghicjkldmnoepqrfstugvwxhyz1i234j567k890laabmbccnddeoeffpgghqhiirjjksklltmmnunoovppqwqrrxsstytuuzvvw0wxx1yyz2z113223434455666777889890091abc2def3ghi4jkl5mno6pqr7stu8vwx9yz11aab2bcc3dd4ee5ff6gg7hh8ii9j0jk1kl2lmm3nnoo4p5pq6qrr7ss8tt9uuvv0wwx1x2yyzz13aba4cbcb5dcdc6dedfef8egf9gfh0ghg1ihi2hji3jik4jkj5lkl6kml7mln8mnm9ono
2751 2833
 -->
2752
-<html xmlns="http://www.w3.org/1999/xhtml" <?php if ( function_exists( 'language_attributes' ) && function_exists( 'is_rtl' ) ) language_attributes(); else echo "dir='$text_direction'"; ?>>
2834
+<html xmlns="http://www.w3.org/1999/xhtml" <?php if ( function_exists( 'language_attributes' ) && function_exists( 'is_rtl' ) ) {
2835
+	language_attributes();
2836
+} else {
2837
+	echo "dir='$text_direction'";
2838
+}
2839
+?>>
2753 2840
 <head>
2754 2841
 	<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
2755 2842
 	<meta name="viewport" content="width=device-width">
@@ -2934,8 +3021,9 @@  discard block
 block discarded – undo
2934 3021
 		status_header( $r['response'] );
2935 3022
 	}
2936 3023
 
2937
-	if ( is_scalar( $message ) )
2938
-		die( (string) $message );
3024
+	if ( is_scalar( $message ) ) {
3025
+			die( (string) $message );
3026
+	}
2939 3027
 	die( '0' );
2940 3028
 }
2941 3029
 
@@ -2950,8 +3038,9 @@  discard block
 block discarded – undo
2950 3038
  * @param string $message Optional. Response to print. Default empty.
2951 3039
  */
2952 3040
 function _scalar_wp_die_handler( $message = '' ) {
2953
-	if ( is_scalar( $message ) )
2954
-		die( (string) $message );
3041
+	if ( is_scalar( $message ) ) {
3042
+			die( (string) $message );
3043
+	}
2955 3044
 	die();
2956 3045
 }
2957 3046
 
@@ -3184,8 +3273,9 @@  discard block
 block discarded – undo
3184 3273
 function wp_send_json_success( $data = null, $status_code = null ) {
3185 3274
 	$response = array( 'success' => true );
3186 3275
 
3187
-	if ( isset( $data ) )
3188
-		$response['data'] = $data;
3276
+	if ( isset( $data ) ) {
3277
+			$response['data'] = $data;
3278
+	}
3189 3279
 
3190 3280
 	wp_send_json( $response, $status_code );
3191 3281
 }
@@ -3264,8 +3354,9 @@  discard block
 block discarded – undo
3264 3354
  * @return string Homepage location.
3265 3355
  */
3266 3356
 function _config_wp_home( $url = '' ) {
3267
-	if ( defined( 'WP_HOME' ) )
3268
-		return untrailingslashit( WP_HOME );
3357
+	if ( defined( 'WP_HOME' ) ) {
3358
+			return untrailingslashit( WP_HOME );
3359
+	}
3269 3360
 	return $url;
3270 3361
 }
3271 3362
 
@@ -3285,8 +3376,9 @@  discard block
 block discarded – undo
3285 3376
  * @return string The WordPress Site URL.
3286 3377
  */
3287 3378
 function _config_wp_siteurl( $url = '' ) {
3288
-	if ( defined( 'WP_SITEURL' ) )
3289
-		return untrailingslashit( WP_SITEURL );
3379
+	if ( defined( 'WP_SITEURL' ) ) {
3380
+			return untrailingslashit( WP_SITEURL );
3381
+	}
3290 3382
 	return $url;
3291 3383
 }
3292 3384
 
@@ -3361,8 +3453,9 @@  discard block
 block discarded – undo
3361 3453
 	global $wpsmiliestrans, $wp_smiliessearch;
3362 3454
 
3363 3455
 	// don't bother setting up smilies if they are disabled
3364
-	if ( !get_option( 'use_smilies' ) )
3365
-		return;
3456
+	if ( !get_option( 'use_smilies' ) ) {
3457
+			return;
3458
+	}
3366 3459
 
3367 3460
 	if ( !isset( $wpsmiliestrans ) ) {
3368 3461
 		$wpsmiliestrans = array(
@@ -3479,15 +3572,17 @@  discard block
 block discarded – undo
3479 3572
  * @return array Merged user defined values with defaults.
3480 3573
  */
3481 3574
 function wp_parse_args( $args, $defaults = '' ) {
3482
-	if ( is_object( $args ) )
3483
-		$r = get_object_vars( $args );
3484
-	elseif ( is_array( $args ) )
3485
-		$r =& $args;
3486
-	else
3487
-		wp_parse_str( $args, $r );
3488
-
3489
-	if ( is_array( $defaults ) )
3490
-		return array_merge( $defaults, $r );
3575
+	if ( is_object( $args ) ) {
3576
+			$r = get_object_vars( $args );
3577
+	} elseif ( is_array( $args ) ) {
3578
+			$r =& $args;
3579
+	} else {
3580
+			wp_parse_str( $args, $r );
3581
+	}
3582
+
3583
+	if ( is_array( $defaults ) ) {
3584
+			return array_merge( $defaults, $r );
3585
+	}
3491 3586
 	return $r;
3492 3587
 }
3493 3588
 
@@ -3500,8 +3595,9 @@  discard block
 block discarded – undo
3500 3595
  * @return array Sanitized array of IDs.
3501 3596
  */
3502 3597
 function wp_parse_id_list( $list ) {
3503
-	if ( !is_array($list) )
3504
-		$list = preg_split('/[\s,]+/', $list);
3598
+	if ( !is_array($list) ) {
3599
+			$list = preg_split('/[\s,]+/', $list);
3600
+	}
3505 3601
 
3506 3602
 	return array_unique(array_map('absint', $list));
3507 3603
 }
@@ -3537,9 +3633,10 @@  discard block
 block discarded – undo
3537 3633
  */
3538 3634
 function wp_array_slice_assoc( $array, $keys ) {
3539 3635
 	$slice = array();
3540
-	foreach ( $keys as $key )
3541
-		if ( isset( $array[ $key ] ) )
3636
+	foreach ( $keys as $key ) {
3637
+			if ( isset( $array[ $key ] ) )
3542 3638
 			$slice[ $key ] = $array[ $key ];
3639
+	}
3543 3640
 
3544 3641
 	return $slice;
3545 3642
 }
@@ -3703,8 +3800,9 @@  discard block
 block discarded – undo
3703 3800
 function wp_widgets_add_menu() {
3704 3801
 	global $submenu;
3705 3802
 
3706
-	if ( ! current_theme_supports( 'widgets' ) )
3707
-		return;
3803
+	if ( ! current_theme_supports( 'widgets' ) ) {
3804
+			return;
3805
+	}
3708 3806
 
3709 3807
 	$submenu['themes.php'][7] = array( __( 'Widgets' ), 'edit_theme_options', 'widgets.php' );
3710 3808
 	ksort( $submenu['themes.php'], SORT_NUMERIC );
@@ -3719,9 +3817,10 @@  discard block
 block discarded – undo
3719 3817
  */
3720 3818
 function wp_ob_end_flush_all() {
3721 3819
 	$levels = ob_get_level();
3722
-	for ($i=0; $i<$levels; $i++)
3723
-		ob_end_flush();
3724
-}
3820
+	for ($i=0; $i<$levels; $i++) {
3821
+			ob_end_flush();
3822
+	}
3823
+	}
3725 3824
 
3726 3825
 /**
3727 3826
  * Load custom DB error or display WordPress DB error.
@@ -3753,8 +3852,9 @@  discard block
 block discarded – undo
3753 3852
 	}
3754 3853
 
3755 3854
 	// If installing or in the admin, provide the verbose message.
3756
-	if ( wp_installing() || defined( 'WP_ADMIN' ) )
3757
-		wp_die($wpdb->error);
3855
+	if ( wp_installing() || defined( 'WP_ADMIN' ) ) {
3856
+			wp_die($wpdb->error);
3857
+	}
3758 3858
 
3759 3859
 	// Otherwise, be terse.
3760 3860
 	status_header( 500 );
@@ -3762,7 +3862,10 @@  discard block
 block discarded – undo
3762 3862
 	header( 'Content-Type: text/html; charset=utf-8' );
3763 3863
 ?>
3764 3864
 <!DOCTYPE html>
3765
-<html xmlns="http://www.w3.org/1999/xhtml"<?php if ( is_rtl() ) echo ' dir="rtl"'; ?>>
3865
+<html xmlns="http://www.w3.org/1999/xhtml"<?php if ( is_rtl() ) {
3866
+	echo ' dir="rtl"';
3867
+}
3868
+?>>
3766 3869
 <head>
3767 3870
 <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
3768 3871
 	<title><?php _e( 'Database Error' ); ?></title>
@@ -4180,19 +4283,22 @@  discard block
 block discarded – undo
4180 4283
 function apache_mod_loaded($mod, $default = false) {
4181 4284
 	global $is_apache;
4182 4285
 
4183
-	if ( !$is_apache )
4184
-		return false;
4286
+	if ( !$is_apache ) {
4287
+			return false;
4288
+	}
4185 4289
 
4186 4290
 	if ( function_exists( 'apache_get_modules' ) ) {
4187 4291
 		$mods = apache_get_modules();
4188
-		if ( in_array($mod, $mods) )
4189
-			return true;
4292
+		if ( in_array($mod, $mods) ) {
4293
+					return true;
4294
+		}
4190 4295
 	} elseif ( function_exists( 'phpinfo' ) && false === strpos( ini_get( 'disable_functions' ), 'phpinfo' ) ) {
4191 4296
 			ob_start();
4192 4297
 			phpinfo(8);
4193 4298
 			$phpinfo = ob_get_clean();
4194
-			if ( false !== strpos($phpinfo, $mod) )
4195
-				return true;
4299
+			if ( false !== strpos($phpinfo, $mod) ) {
4300
+							return true;
4301
+			}
4196 4302
 	}
4197 4303
 	return $default;
4198 4304
 }
@@ -4248,17 +4354,21 @@  discard block
 block discarded – undo
4248 4354
  * @return int 0 means nothing is wrong, greater than 0 means something was wrong.
4249 4355
  */
4250 4356
 function validate_file( $file, $allowed_files = '' ) {
4251
-	if ( false !== strpos( $file, '..' ) )
4252
-		return 1;
4357
+	if ( false !== strpos( $file, '..' ) ) {
4358
+			return 1;
4359
+	}
4253 4360
 
4254
-	if ( false !== strpos( $file, './' ) )
4255
-		return 1;
4361
+	if ( false !== strpos( $file, './' ) ) {
4362
+			return 1;
4363
+	}
4256 4364
 
4257
-	if ( ! empty( $allowed_files ) && ! in_array( $file, $allowed_files ) )
4258
-		return 3;
4365
+	if ( ! empty( $allowed_files ) && ! in_array( $file, $allowed_files ) ) {
4366
+			return 3;
4367
+	}
4259 4368
 
4260
-	if (':' == substr( $file, 1, 1 ) )
4261
-		return 2;
4369
+	if (':' == substr( $file, 1, 1 ) ) {
4370
+			return 2;
4371
+	}
4262 4372
 
4263 4373
 	return 0;
4264 4374
 }
@@ -4354,8 +4464,9 @@  discard block
 block discarded – undo
4354 4464
 function wp_suspend_cache_addition( $suspend = null ) {
4355 4465
 	static $_suspend = false;
4356 4466
 
4357
-	if ( is_bool( $suspend ) )
4358
-		$_suspend = $suspend;
4467
+	if ( is_bool( $suspend ) ) {
4468
+			$_suspend = $suspend;
4469
+	}
4359 4470
 
4360 4471
 	return $_suspend;
4361 4472
 }
@@ -4392,11 +4503,13 @@  discard block
 block discarded – undo
4392 4503
  *              running Multisite.
4393 4504
  */
4394 4505
 function is_main_site( $site_id = null ) {
4395
-	if ( ! is_multisite() )
4396
-		return true;
4506
+	if ( ! is_multisite() ) {
4507
+			return true;
4508
+	}
4397 4509
 
4398
-	if ( ! $site_id )
4399
-		$site_id = get_current_blog_id();
4510
+	if ( ! $site_id ) {
4511
+			$site_id = get_current_blog_id();
4512
+	}
4400 4513
 
4401 4514
 	return (int) $site_id === (int) get_network()->site_id;
4402 4515
 }
@@ -4467,8 +4580,9 @@  discard block
 block discarded – undo
4467 4580
  * @return bool True if multisite and global terms enabled.
4468 4581
  */
4469 4582
 function global_terms_enabled() {
4470
-	if ( ! is_multisite() )
4471
-		return false;
4583
+	if ( ! is_multisite() ) {
4584
+			return false;
4585
+	}
4472 4586
 
4473 4587
 	static $global_terms = null;
4474 4588
 	if ( is_null( $global_terms ) ) {
@@ -4484,10 +4598,11 @@  discard block
 block discarded – undo
4484 4598
 		 * @param null $enabled Whether global terms are enabled.
4485 4599
 		 */
4486 4600
 		$filter = apply_filters( 'global_terms_enabled', null );
4487
-		if ( ! is_null( $filter ) )
4488
-			$global_terms = (bool) $filter;
4489
-		else
4490
-			$global_terms = (bool) get_site_option( 'global_terms_enabled', false );
4601
+		if ( ! is_null( $filter ) ) {
4602
+					$global_terms = (bool) $filter;
4603
+		} else {
4604
+					$global_terms = (bool) get_site_option( 'global_terms_enabled', false );
4605
+		}
4491 4606
 	}
4492 4607
 	return $global_terms;
4493 4608
 }
@@ -4667,8 +4782,9 @@  discard block
 block discarded – undo
4667 4782
 	// Do UTC
4668 4783
 	$structure[] = '<optgroup label="'. esc_attr__( 'UTC' ) .'">';
4669 4784
 	$selected = '';
4670
-	if ( 'UTC' === $selected_zone )
4671
-		$selected = 'selected="selected" ';
4785
+	if ( 'UTC' === $selected_zone ) {
4786
+			$selected = 'selected="selected" ';
4787
+	}
4672 4788
 	$structure[] = '<option ' . $selected . 'value="' . esc_attr( 'UTC' ) . '">' . __('UTC') . '</option>';
4673 4789
 	$structure[] = '</optgroup>';
4674 4790
 
@@ -4677,18 +4793,20 @@  discard block
 block discarded – undo
4677 4793
 	$offset_range = array (-12, -11.5, -11, -10.5, -10, -9.5, -9, -8.5, -8, -7.5, -7, -6.5, -6, -5.5, -5, -4.5, -4, -3.5, -3, -2.5, -2, -1.5, -1, -0.5,
4678 4794
 		0, 0.5, 1, 1.5, 2, 2.5, 3, 3.5, 4, 4.5, 5, 5.5, 5.75, 6, 6.5, 7, 7.5, 8, 8.5, 8.75, 9, 9.5, 10, 10.5, 11, 11.5, 12, 12.75, 13, 13.75, 14);
4679 4795
 	foreach ( $offset_range as $offset ) {
4680
-		if ( 0 <= $offset )
4681
-			$offset_name = '+' . $offset;
4682
-		else
4683
-			$offset_name = (string) $offset;
4796
+		if ( 0 <= $offset ) {
4797
+					$offset_name = '+' . $offset;
4798
+		} else {
4799
+					$offset_name = (string) $offset;
4800
+		}
4684 4801
 
4685 4802
 		$offset_value = $offset_name;
4686 4803
 		$offset_name = str_replace(array('.25','.5','.75'), array(':15',':30',':45'), $offset_name);
4687 4804
 		$offset_name = 'UTC' . $offset_name;
4688 4805
 		$offset_value = 'UTC' . $offset_value;
4689 4806
 		$selected = '';
4690
-		if ( $offset_value === $selected_zone )
4691
-			$selected = 'selected="selected" ';
4807
+		if ( $offset_value === $selected_zone ) {
4808
+					$selected = 'selected="selected" ';
4809
+		}
4692 4810
 		$structure[] = '<option ' . $selected . 'value="' . esc_attr( $offset_value ) . '">' . esc_html( $offset_name ) . "</option>";
4693 4811
 
4694 4812
 	}
@@ -4731,8 +4849,9 @@  discard block
 block discarded – undo
4731 4849
 
4732 4850
 	foreach ( (array) $posts_to_delete as $post ) {
4733 4851
 		$post_id = (int) $post['post_id'];
4734
-		if ( !$post_id )
4735
-			continue;
4852
+		if ( !$post_id ) {
4853
+					continue;
4854
+		}
4736 4855
 
4737 4856
 		$del_post = get_post($post_id);
4738 4857
 
@@ -4748,8 +4867,9 @@  discard block
 block discarded – undo
4748 4867
 
4749 4868
 	foreach ( (array) $comments_to_delete as $comment ) {
4750 4869
 		$comment_id = (int) $comment['comment_id'];
4751
-		if ( !$comment_id )
4752
-			continue;
4870
+		if ( !$comment_id ) {
4871
+					continue;
4872
+		}
4753 4873
 
4754 4874
 		$del_comment = get_comment($comment_id);
4755 4875
 
@@ -4813,10 +4933,11 @@  discard block
 block discarded – undo
4813 4933
 	}
4814 4934
 
4815 4935
 	foreach ( $all_headers as $field => $regex ) {
4816
-		if ( preg_match( '/^[ \t\/*#@]*' . preg_quote( $regex, '/' ) . ':(.*)$/mi', $file_data, $match ) && $match[1] )
4817
-			$all_headers[ $field ] = _cleanup_header_comment( $match[1] );
4818
-		else
4819
-			$all_headers[ $field ] = '';
4936
+		if ( preg_match( '/^[ \t\/*#@]*' . preg_quote( $regex, '/' ) . ':(.*)$/mi', $file_data, $match ) && $match[1] ) {
4937
+					$all_headers[ $field ] = _cleanup_header_comment( $match[1] );
4938
+		} else {
4939
+					$all_headers[ $field ] = '';
4940
+		}
4820 4941
 	}
4821 4942
 
4822 4943
 	return $all_headers;
@@ -4959,8 +5080,9 @@  discard block
 block discarded – undo
4959 5080
 function wp_find_hierarchy_loop( $callback, $start, $start_parent, $callback_args = array() ) {
4960 5081
 	$override = is_null( $start_parent ) ? array() : array( $start => $start_parent );
4961 5082
 
4962
-	if ( !$arbitrary_loop_member = wp_find_hierarchy_loop_tortoise_hare( $callback, $start, $override, $callback_args ) )
4963
-		return array();
5083
+	if ( !$arbitrary_loop_member = wp_find_hierarchy_loop_tortoise_hare( $callback, $start, $override, $callback_args ) ) {
5084
+			return array();
5085
+	}
4964 5086
 
4965 5087
 	return wp_find_hierarchy_loop_tortoise_hare( $callback, $arbitrary_loop_member, $override, $callback_args, true );
4966 5088
 }
@@ -4998,12 +5120,14 @@  discard block
 block discarded – undo
4998 5120
 	&&
4999 5121
 		( $hare = isset( $override[$evanescent_hare] ) ? $override[$evanescent_hare] : call_user_func_array( $callback, array_merge( array( $evanescent_hare ), $callback_args ) ) )
5000 5122
 	) {
5001
-		if ( $_return_loop )
5002
-			$return[$tortoise] = $return[$evanescent_hare] = $return[$hare] = true;
5123
+		if ( $_return_loop ) {
5124
+					$return[$tortoise] = $return[$evanescent_hare] = $return[$hare] = true;
5125
+		}
5003 5126
 
5004 5127
 		// tortoise got lapped - must be a loop
5005
-		if ( $tortoise == $evanescent_hare || $tortoise == $hare )
5006
-			return $_return_loop ? $return : $tortoise;
5128
+		if ( $tortoise == $evanescent_hare || $tortoise == $hare ) {
5129
+					return $_return_loop ? $return : $tortoise;
5130
+		}
5007 5131
 
5008 5132
 		// Increment tortoise by one step
5009 5133
 		$tortoise = isset( $override[$tortoise] ) ? $override[$tortoise] : call_user_func_array( $callback, array_merge( array( $tortoise ), $callback_args ) );
@@ -5076,10 +5200,11 @@  discard block
 block discarded – undo
5076 5200
  *                      of individual calls.
5077 5201
  */
5078 5202
 function wp_debug_backtrace_summary( $ignore_class = null, $skip_frames = 0, $pretty = true ) {
5079
-	if ( version_compare( PHP_VERSION, '5.2.5', '>=' ) )
5080
-		$trace = debug_backtrace( false );
5081
-	else
5082
-		$trace = debug_backtrace();
5203
+	if ( version_compare( PHP_VERSION, '5.2.5', '>=' ) ) {
5204
+			$trace = debug_backtrace( false );
5205
+	} else {
5206
+			$trace = debug_backtrace();
5207
+	}
5083 5208
 
5084 5209
 	$caller = array();
5085 5210
 	$check_class = ! is_null( $ignore_class );
@@ -5089,8 +5214,10 @@  discard block
 block discarded – undo
5089 5214
 		if ( $skip_frames > 0 ) {
5090 5215
 			$skip_frames--;
5091 5216
 		} elseif ( isset( $call['class'] ) ) {
5092
-			if ( $check_class && $ignore_class == $call['class'] )
5093
-				continue; // Filter out calls
5217
+			if ( $check_class && $ignore_class == $call['class'] ) {
5218
+							continue;
5219
+			}
5220
+			// Filter out calls
5094 5221
 
5095 5222
 			$caller[] = "{$call['class']}{$call['type']}{$call['function']}";
5096 5223
 		} else {
@@ -5103,11 +5230,12 @@  discard block
 block discarded – undo
5103 5230
 			}
5104 5231
 		}
5105 5232
 	}
5106
-	if ( $pretty )
5107
-		return join( ', ', array_reverse( $caller ) );
5108
-	else
5109
-		return $caller;
5110
-}
5233
+	if ( $pretty ) {
5234
+			return join( ', ', array_reverse( $caller ) );
5235
+	} else {
5236
+			return $caller;
5237
+	}
5238
+	}
5111 5239
 
5112 5240
 /**
5113 5241
  * Retrieve ids that are not already present in the cache.
@@ -5141,8 +5269,9 @@  discard block
 block discarded – undo
5141 5269
  * @return bool Whether the device is able to upload files.
5142 5270
  */
5143 5271
 function _device_can_upload() {
5144
-	if ( ! wp_is_mobile() )
5145
-		return true;
5272
+	if ( ! wp_is_mobile() ) {
5273
+			return true;
5274
+	}
5146 5275
 
5147 5276
 	$ua = $_SERVER['HTTP_USER_AGENT'];
5148 5277
 
@@ -5207,11 +5336,13 @@  discard block
 block discarded – undo
5207 5336
  * @since 3.6.0
5208 5337
  */
5209 5338
 function wp_auth_check_load() {
5210
-	if ( ! is_admin() && ! is_user_logged_in() )
5211
-		return;
5339
+	if ( ! is_admin() && ! is_user_logged_in() ) {
5340
+			return;
5341
+	}
5212 5342
 
5213
-	if ( defined( 'IFRAME_REQUEST' ) )
5214
-		return;
5343
+	if ( defined( 'IFRAME_REQUEST' ) ) {
5344
+			return;
5345
+	}
5215 5346
 
5216 5347
 	$screen = get_current_screen();
5217 5348
 	$hidden = array( 'update', 'update-network', 'update-core', 'update-core-network', 'upgrade', 'upgrade-network', 'network' );
@@ -5316,8 +5447,9 @@  discard block
 block discarded – undo
5316 5447
  * @return string Tag RegEx.
5317 5448
  */
5318 5449
 function get_tag_regex( $tag ) {
5319
-	if ( empty( $tag ) )
5320
-		return;
5450
+	if ( empty( $tag ) ) {
5451
+			return;
5452
+	}
5321 5453
 	return sprintf( '<%1$s[^<]*(?:>[\s\S]*<\/%1$s>|\s*\/>)', tag_escape( $tag ) );
5322 5454
 }
5323 5455
 
@@ -5377,11 +5509,13 @@  discard block
 block discarded – undo
5377 5509
 	static $encodings = array();
5378 5510
 	static $overloaded = null;
5379 5511
 
5380
-	if ( is_null( $overloaded ) )
5381
-		$overloaded = function_exists( 'mb_internal_encoding' ) && ( ini_get( 'mbstring.func_overload' ) & 2 );
5512
+	if ( is_null( $overloaded ) ) {
5513
+			$overloaded = function_exists( 'mb_internal_encoding' ) && ( ini_get( 'mbstring.func_overload' ) & 2 );
5514
+	}
5382 5515
 
5383
-	if ( false === $overloaded )
5384
-		return;
5516
+	if ( false === $overloaded ) {
5517
+			return;
5518
+	}
5385 5519
 
5386 5520
 	if ( ! $reset ) {
5387 5521
 		$encoding = mb_internal_encoding();
Please login to merge, or discard this patch.
src/wp-includes/class-json.php 4 patches
Spacing   +47 added lines, -47 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
1 1
 <?php
2
-if ( ! class_exists( 'Services_JSON' ) ) :
2
+if ( ! class_exists('Services_JSON')) :
3 3
 /* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
4 4
 /**
5 5
  * Converts to and from JSON format.
@@ -59,22 +59,22 @@  discard block
 block discarded – undo
59 59
 /**
60 60
  * Marker constant for Services_JSON::decode(), used to flag stack state
61 61
  */
62
-define('SERVICES_JSON_SLICE',   1);
62
+define('SERVICES_JSON_SLICE', 1);
63 63
 
64 64
 /**
65 65
  * Marker constant for Services_JSON::decode(), used to flag stack state
66 66
  */
67
-define('SERVICES_JSON_IN_STR',  2);
67
+define('SERVICES_JSON_IN_STR', 2);
68 68
 
69 69
 /**
70 70
  * Marker constant for Services_JSON::decode(), used to flag stack state
71 71
  */
72
-define('SERVICES_JSON_IN_ARR',  3);
72
+define('SERVICES_JSON_IN_ARR', 3);
73 73
 
74 74
 /**
75 75
  * Marker constant for Services_JSON::decode(), used to flag stack state
76 76
  */
77
-define('SERVICES_JSON_IN_OBJ',  4);
77
+define('SERVICES_JSON_IN_OBJ', 4);
78 78
 
79 79
 /**
80 80
  * Marker constant for Services_JSON::decode(), used to flag stack state
@@ -140,7 +140,7 @@  discard block
 block discarded – undo
140 140
     *                                   strings or numbers, if you return an object, make sure it does
141 141
     *                                   not have a toJSON method, otherwise an error will occur.
142 142
     */
143
-    function __construct( $use = 0 )
143
+    function __construct($use = 0)
144 144
     {
145 145
         $this->use = $use;
146 146
         $this->_mb_strlen            = function_exists('mb_strlen');
@@ -151,8 +151,8 @@  discard block
 block discarded – undo
151 151
 	/**
152 152
 	 * PHP4 constructor.
153 153
 	 */
154
-	public function Services_JSON( $use = 0 ) {
155
-		self::__construct( $use );
154
+	public function Services_JSON($use = 0) {
155
+		self::__construct($use);
156 156
 	}
157 157
     // private - cache the mbstring lookup results..
158 158
     var $_mb_strlen = false;
@@ -173,13 +173,13 @@  discard block
 block discarded – undo
173 173
     function utf162utf8($utf16)
174 174
     {
175 175
         // oh please oh please oh please oh please oh please
176
-        if($this->_mb_convert_encoding) {
176
+        if ($this->_mb_convert_encoding) {
177 177
             return mb_convert_encoding($utf16, 'UTF-8', 'UTF-16');
178 178
         }
179 179
 
180 180
         $bytes = (ord($utf16{0}) << 8) | ord($utf16{1});
181 181
 
182
-        switch(true) {
182
+        switch (true) {
183 183
             case ((0x7F & $bytes) == $bytes):
184 184
                 // this case should never be reached, because we are in ASCII range
185 185
                 // see: http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
@@ -217,11 +217,11 @@  discard block
 block discarded – undo
217 217
     function utf82utf16($utf8)
218 218
     {
219 219
         // oh please oh please oh please oh please oh please
220
-        if($this->_mb_convert_encoding) {
220
+        if ($this->_mb_convert_encoding) {
221 221
             return mb_convert_encoding($utf8, 'UTF-16', 'UTF-8');
222 222
         }
223 223
 
224
-        switch($this->strlen8($utf8)) {
224
+        switch ($this->strlen8($utf8)) {
225 225
             case 1:
226 226
                 // this case should never be reached, because we are in ASCII range
227 227
                 // see: http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
@@ -357,7 +357,7 @@  discard block
 block discarded – undo
357 357
                         case (($ord_var_c & 0xE0) == 0xC0):
358 358
                             // characters U-00000080 - U-000007FF, mask 110XXXXX
359 359
                             // see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
360
-                            if ($c+1 >= $strlen_var) {
360
+                            if ($c + 1 >= $strlen_var) {
361 361
                                 $c += 1;
362 362
                                 $ascii .= '?';
363 363
                                 break;
@@ -370,7 +370,7 @@  discard block
 block discarded – undo
370 370
                             break;
371 371
 
372 372
                         case (($ord_var_c & 0xF0) == 0xE0):
373
-                            if ($c+2 >= $strlen_var) {
373
+                            if ($c + 2 >= $strlen_var) {
374 374
                                 $c += 2;
375 375
                                 $ascii .= '?';
376 376
                                 break;
@@ -386,7 +386,7 @@  discard block
 block discarded – undo
386 386
                             break;
387 387
 
388 388
                         case (($ord_var_c & 0xF8) == 0xF0):
389
-                            if ($c+3 >= $strlen_var) {
389
+                            if ($c + 3 >= $strlen_var) {
390 390
                                 $c += 3;
391 391
                                 $ascii .= '?';
392 392
                                 break;
@@ -405,7 +405,7 @@  discard block
 block discarded – undo
405 405
                         case (($ord_var_c & 0xFC) == 0xF8):
406 406
                             // characters U-00200000 - U-03FFFFFF, mask 111110XX
407 407
                             // see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
408
-                            if ($c+4 >= $strlen_var) {
408
+                            if ($c + 4 >= $strlen_var) {
409 409
                                 $c += 4;
410 410
                                 $ascii .= '?';
411 411
                                 break;
@@ -421,7 +421,7 @@  discard block
 block discarded – undo
421 421
                             break;
422 422
 
423 423
                         case (($ord_var_c & 0xFE) == 0xFC):
424
-                        if ($c+5 >= $strlen_var) {
424
+                        if ($c + 5 >= $strlen_var) {
425 425
                                 $c += 5;
426 426
                                 $ascii .= '?';
427 427
                                 break;
@@ -467,25 +467,25 @@  discard block
 block discarded – undo
467 467
                                             array_keys($var),
468 468
                                             array_values($var));
469 469
 
470
-                    foreach($properties as $property) {
471
-                        if(Services_JSON::isError($property)) {
470
+                    foreach ($properties as $property) {
471
+                        if (Services_JSON::isError($property)) {
472 472
                             return $property;
473 473
                         }
474 474
                     }
475 475
 
476
-                    return '{' . join(',', $properties) . '}';
476
+                    return '{'.join(',', $properties).'}';
477 477
                 }
478 478
 
479 479
                 // treat it like a regular array
480 480
                 $elements = array_map(array($this, '_encode'), $var);
481 481
 
482
-                foreach($elements as $element) {
483
-                    if(Services_JSON::isError($element)) {
482
+                foreach ($elements as $element) {
483
+                    if (Services_JSON::isError($element)) {
484 484
                         return $element;
485 485
                     }
486 486
                 }
487 487
 
488
-                return '[' . join(',', $elements) . ']';
488
+                return '['.join(',', $elements).']';
489 489
 
490 490
             case 'object':
491 491
             
@@ -504,7 +504,7 @@  discard block
 block discarded – undo
504 504
                             
505 505
                     }
506 506
                     
507
-                    return $this->_encode( $recode );
507
+                    return $this->_encode($recode);
508 508
                 } 
509 509
                 
510 510
                 $vars = get_object_vars($var);
@@ -513,13 +513,13 @@  discard block
 block discarded – undo
513 513
                                         array_keys($vars),
514 514
                                         array_values($vars));
515 515
 
516
-                foreach($properties as $property) {
517
-                    if(Services_JSON::isError($property)) {
516
+                foreach ($properties as $property) {
517
+                    if (Services_JSON::isError($property)) {
518 518
                         return $property;
519 519
                     }
520 520
                 }
521 521
 
522
-                return '{' . join(',', $properties) . '}';
522
+                return '{'.join(',', $properties).'}';
523 523
 
524 524
             default:
525 525
                 return ($this->use & SERVICES_JSON_SUPPRESS_ERRORS)
@@ -541,11 +541,11 @@  discard block
 block discarded – undo
541 541
     {
542 542
         $encoded_value = $this->_encode($value);
543 543
 
544
-        if(Services_JSON::isError($encoded_value)) {
544
+        if (Services_JSON::isError($encoded_value)) {
545 545
             return $encoded_value;
546 546
         }
547 547
 
548
-        return $this->_encode(strval($name)) . ':' . $encoded_value;
548
+        return $this->_encode(strval($name)).':'.$encoded_value;
549 549
     }
550 550
 
551 551
    /**
@@ -612,9 +612,9 @@  discard block
 block discarded – undo
612 612
                     // return (float)$str;
613 613
 
614 614
                     // Return float or int, as appropriate
615
-                    return ((float)$str == (integer)$str)
616
-                        ? (integer)$str
617
-                        : (float)$str;
615
+                    return ((float) $str == (integer) $str)
616
+                        ? (integer) $str
617
+                        : (float) $str;
618 618
 
619 619
                 } elseif (preg_match('/^("|\').*(\1)$/s', $str, $m) && $m[1] == $m[2]) {
620 620
                     // STRINGS RETURNED IN UTF-8 FORMAT
@@ -885,12 +885,12 @@  discard block
 block discarded – undo
885 885
     * @param string 
886 886
     * @return integer length
887 887
     */
888
-    function strlen8( $str ) 
888
+    function strlen8($str) 
889 889
     {
890
-        if ( $this->_mb_strlen ) {
891
-            return mb_strlen( $str, "8bit" );
890
+        if ($this->_mb_strlen) {
891
+            return mb_strlen($str, "8bit");
892 892
         }
893
-        return strlen( $str );
893
+        return strlen($str);
894 894
     }
895 895
     
896 896
     /**
@@ -900,15 +900,15 @@  discard block
 block discarded – undo
900 900
     * @param integer length 
901 901
     * @return integer length
902 902
     */
903
-    function substr8( $string, $start, $length=false ) 
903
+    function substr8($string, $start, $length = false) 
904 904
     {
905
-        if ( $length === false ) {
906
-            $length = $this->strlen8( $string ) - $start;
905
+        if ($length === false) {
906
+            $length = $this->strlen8($string) - $start;
907 907
         }
908
-        if ( $this->_mb_substr ) {
909
-            return mb_substr( $string, $start, $length, "8bit" );
908
+        if ($this->_mb_substr) {
909
+            return mb_substr($string, $start, $length, "8bit");
910 910
         }
911
-        return substr( $string, $start, $length );
911
+        return substr($string, $start, $length);
912 912
     }
913 913
 
914 914
 }
@@ -940,8 +940,8 @@  discard block
 block discarded – undo
940 940
 	    /**
941 941
 	     * PHP5 constructor.
942 942
 	     */
943
-        function __construct( $message = 'unknown error', $code = null,
944
-                                     $mode = null, $options = null, $userinfo = null )
943
+        function __construct($message = 'unknown error', $code = null,
944
+                                     $mode = null, $options = null, $userinfo = null)
945 945
         {
946 946
 
947 947
         }
@@ -949,9 +949,9 @@  discard block
 block discarded – undo
949 949
 	    /**
950 950
 	     * PHP4 constructor.
951 951
 	     */
952
-		public function Services_JSON_Error( $message = 'unknown error', $code = null,
953
-	                                     $mode = null, $options = null, $userinfo = null ) {
954
-			self::__construct( $message, $code, $mode, $options, $userinfo );
952
+		public function Services_JSON_Error($message = 'unknown error', $code = null,
953
+	                                     $mode = null, $options = null, $userinfo = null) {
954
+			self::__construct($message, $code, $mode, $options, $userinfo);
955 955
 		}
956 956
     }
957 957
     
Please login to merge, or discard this patch.
Braces   +3 added lines, -2 removed lines patch added patch discarded remove patch
@@ -844,8 +844,9 @@
 block discarded – undo
844 844
                             array_pop($stk);
845 845
                             $c++;
846 846
 
847
-                            for ($i = $top['where']; $i <= $c; ++$i)
848
-                                $chrs = substr_replace($chrs, ' ', $i, 1);
847
+                            for ($i = $top['where']; $i <= $c; ++$i) {
848
+                                                            $chrs = substr_replace($chrs, ' ', $i, 1);
849
+                            }
849 850
 
850 851
                             //print("Found end of comment at {$c}: ".$this->substr8($chrs, $top['where'], (1 + $c - $top['where']))."\n");
851 852
 
Please login to merge, or discard this patch.
Doc Comments   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -551,7 +551,7 @@  discard block
 block discarded – undo
551 551
    /**
552 552
     * reduce a string by removing leading and trailing comments and whitespace
553 553
     *
554
-    * @param    $str    string      string value to strip of comments and whitespace
554
+    * @param    string $str    string      string value to strip of comments and whitespace
555 555
     *
556 556
     * @return   string  string value stripped of comments and whitespace
557 557
     * @access   private
@@ -898,7 +898,7 @@  discard block
 block discarded – undo
898 898
     * @param string 
899 899
     * @param integer start 
900 900
     * @param integer length 
901
-    * @return integer length
901
+    * @return string length
902 902
     */
903 903
     function substr8( $string, $start, $length=false ) 
904 904
     {
Please login to merge, or discard this patch.
Indentation   +673 added lines, -673 removed lines patch added patch discarded remove patch
@@ -140,13 +140,13 @@  discard block
 block discarded – undo
140 140
     *                                   strings or numbers, if you return an object, make sure it does
141 141
     *                                   not have a toJSON method, otherwise an error will occur.
142 142
     */
143
-    function __construct( $use = 0 )
144
-    {
145
-        $this->use = $use;
146
-        $this->_mb_strlen            = function_exists('mb_strlen');
147
-        $this->_mb_convert_encoding  = function_exists('mb_convert_encoding');
148
-        $this->_mb_substr            = function_exists('mb_substr');
149
-    }
143
+	function __construct( $use = 0 )
144
+	{
145
+		$this->use = $use;
146
+		$this->_mb_strlen            = function_exists('mb_strlen');
147
+		$this->_mb_convert_encoding  = function_exists('mb_convert_encoding');
148
+		$this->_mb_substr            = function_exists('mb_substr');
149
+	}
150 150
 
151 151
 	/**
152 152
 	 * PHP4 constructor.
@@ -154,10 +154,10 @@  discard block
 block discarded – undo
154 154
 	public function Services_JSON( $use = 0 ) {
155 155
 		self::__construct( $use );
156 156
 	}
157
-    // private - cache the mbstring lookup results..
158
-    var $_mb_strlen = false;
159
-    var $_mb_substr = false;
160
-    var $_mb_convert_encoding = false;
157
+	// private - cache the mbstring lookup results..
158
+	var $_mb_strlen = false;
159
+	var $_mb_substr = false;
160
+	var $_mb_convert_encoding = false;
161 161
     
162 162
    /**
163 163
     * convert a string from one UTF-16 char to one UTF-8 char
@@ -170,38 +170,38 @@  discard block
 block discarded – undo
170 170
     * @return   string  UTF-8 character
171 171
     * @access   private
172 172
     */
173
-    function utf162utf8($utf16)
174
-    {
175
-        // oh please oh please oh please oh please oh please
176
-        if($this->_mb_convert_encoding) {
177
-            return mb_convert_encoding($utf16, 'UTF-8', 'UTF-16');
178
-        }
179
-
180
-        $bytes = (ord($utf16{0}) << 8) | ord($utf16{1});
181
-
182
-        switch(true) {
183
-            case ((0x7F & $bytes) == $bytes):
184
-                // this case should never be reached, because we are in ASCII range
185
-                // see: http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
186
-                return chr(0x7F & $bytes);
187
-
188
-            case (0x07FF & $bytes) == $bytes:
189
-                // return a 2-byte UTF-8 character
190
-                // see: http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
191
-                return chr(0xC0 | (($bytes >> 6) & 0x1F))
192
-                     . chr(0x80 | ($bytes & 0x3F));
193
-
194
-            case (0xFFFF & $bytes) == $bytes:
195
-                // return a 3-byte UTF-8 character
196
-                // see: http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
197
-                return chr(0xE0 | (($bytes >> 12) & 0x0F))
198
-                     . chr(0x80 | (($bytes >> 6) & 0x3F))
199
-                     . chr(0x80 | ($bytes & 0x3F));
200
-        }
201
-
202
-        // ignoring UTF-32 for now, sorry
203
-        return '';
204
-    }
173
+	function utf162utf8($utf16)
174
+	{
175
+		// oh please oh please oh please oh please oh please
176
+		if($this->_mb_convert_encoding) {
177
+			return mb_convert_encoding($utf16, 'UTF-8', 'UTF-16');
178
+		}
179
+
180
+		$bytes = (ord($utf16{0}) << 8) | ord($utf16{1});
181
+
182
+		switch(true) {
183
+			case ((0x7F & $bytes) == $bytes):
184
+				// this case should never be reached, because we are in ASCII range
185
+				// see: http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
186
+				return chr(0x7F & $bytes);
187
+
188
+			case (0x07FF & $bytes) == $bytes:
189
+				// return a 2-byte UTF-8 character
190
+				// see: http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
191
+				return chr(0xC0 | (($bytes >> 6) & 0x1F))
192
+					 . chr(0x80 | ($bytes & 0x3F));
193
+
194
+			case (0xFFFF & $bytes) == $bytes:
195
+				// return a 3-byte UTF-8 character
196
+				// see: http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
197
+				return chr(0xE0 | (($bytes >> 12) & 0x0F))
198
+					 . chr(0x80 | (($bytes >> 6) & 0x3F))
199
+					 . chr(0x80 | ($bytes & 0x3F));
200
+		}
201
+
202
+		// ignoring UTF-32 for now, sorry
203
+		return '';
204
+	}
205 205
 
206 206
    /**
207 207
     * convert a string from one UTF-8 char to one UTF-16 char
@@ -214,38 +214,38 @@  discard block
 block discarded – undo
214 214
     * @return   string  UTF-16 character
215 215
     * @access   private
216 216
     */
217
-    function utf82utf16($utf8)
218
-    {
219
-        // oh please oh please oh please oh please oh please
220
-        if($this->_mb_convert_encoding) {
221
-            return mb_convert_encoding($utf8, 'UTF-16', 'UTF-8');
222
-        }
223
-
224
-        switch($this->strlen8($utf8)) {
225
-            case 1:
226
-                // this case should never be reached, because we are in ASCII range
227
-                // see: http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
228
-                return $utf8;
229
-
230
-            case 2:
231
-                // return a UTF-16 character from a 2-byte UTF-8 char
232
-                // see: http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
233
-                return chr(0x07 & (ord($utf8{0}) >> 2))
234
-                     . chr((0xC0 & (ord($utf8{0}) << 6))
235
-                         | (0x3F & ord($utf8{1})));
236
-
237
-            case 3:
238
-                // return a UTF-16 character from a 3-byte UTF-8 char
239
-                // see: http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
240
-                return chr((0xF0 & (ord($utf8{0}) << 4))
241
-                         | (0x0F & (ord($utf8{1}) >> 2)))
242
-                     . chr((0xC0 & (ord($utf8{1}) << 6))
243
-                         | (0x7F & ord($utf8{2})));
244
-        }
245
-
246
-        // ignoring UTF-32 for now, sorry
247
-        return '';
248
-    }
217
+	function utf82utf16($utf8)
218
+	{
219
+		// oh please oh please oh please oh please oh please
220
+		if($this->_mb_convert_encoding) {
221
+			return mb_convert_encoding($utf8, 'UTF-16', 'UTF-8');
222
+		}
223
+
224
+		switch($this->strlen8($utf8)) {
225
+			case 1:
226
+				// this case should never be reached, because we are in ASCII range
227
+				// see: http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
228
+				return $utf8;
229
+
230
+			case 2:
231
+				// return a UTF-16 character from a 2-byte UTF-8 char
232
+				// see: http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
233
+				return chr(0x07 & (ord($utf8{0}) >> 2))
234
+					 . chr((0xC0 & (ord($utf8{0}) << 6))
235
+						 | (0x3F & ord($utf8{1})));
236
+
237
+			case 3:
238
+				// return a UTF-16 character from a 3-byte UTF-8 char
239
+				// see: http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
240
+				return chr((0xF0 & (ord($utf8{0}) << 4))
241
+						 | (0x0F & (ord($utf8{1}) >> 2)))
242
+					 . chr((0xC0 & (ord($utf8{1}) << 6))
243
+						 | (0x7F & ord($utf8{2})));
244
+		}
245
+
246
+		// ignoring UTF-32 for now, sorry
247
+		return '';
248
+	}
249 249
 
250 250
    /**
251 251
     * encodes an arbitrary variable into JSON format (and sends JSON Header)
@@ -258,192 +258,192 @@  discard block
 block discarded – undo
258 258
     * @return   mixed   JSON string representation of input var or an error if a problem occurs
259 259
     * @access   public
260 260
     */
261
-    function encode($var)
262
-    {
263
-        header('Content-type: application/json');
264
-        return $this->encodeUnsafe($var);
265
-    }
266
-    /**
267
-    * encodes an arbitrary variable into JSON format without JSON Header - warning - may allow XSS!!!!)
268
-    *
269
-    * @param    mixed   $var    any number, boolean, string, array, or object to be encoded.
270
-    *                           see argument 1 to Services_JSON() above for array-parsing behavior.
271
-    *                           if var is a strng, note that encode() always expects it
272
-    *                           to be in ASCII or UTF-8 format!
273
-    *
274
-    * @return   mixed   JSON string representation of input var or an error if a problem occurs
275
-    * @access   public
276
-    */
277
-    function encodeUnsafe($var)
278
-    {
279
-        // see bug #16908 - regarding numeric locale printing
280
-        $lc = setlocale(LC_NUMERIC, 0);
281
-        setlocale(LC_NUMERIC, 'C');
282
-        $ret = $this->_encode($var);
283
-        setlocale(LC_NUMERIC, $lc);
284
-        return $ret;
261
+	function encode($var)
262
+	{
263
+		header('Content-type: application/json');
264
+		return $this->encodeUnsafe($var);
265
+	}
266
+	/**
267
+	 * encodes an arbitrary variable into JSON format without JSON Header - warning - may allow XSS!!!!)
268
+	 *
269
+	 * @param    mixed   $var    any number, boolean, string, array, or object to be encoded.
270
+	 *                           see argument 1 to Services_JSON() above for array-parsing behavior.
271
+	 *                           if var is a strng, note that encode() always expects it
272
+	 *                           to be in ASCII or UTF-8 format!
273
+	 *
274
+	 * @return   mixed   JSON string representation of input var or an error if a problem occurs
275
+	 * @access   public
276
+	 */
277
+	function encodeUnsafe($var)
278
+	{
279
+		// see bug #16908 - regarding numeric locale printing
280
+		$lc = setlocale(LC_NUMERIC, 0);
281
+		setlocale(LC_NUMERIC, 'C');
282
+		$ret = $this->_encode($var);
283
+		setlocale(LC_NUMERIC, $lc);
284
+		return $ret;
285 285
         
286
-    }
287
-    /**
288
-    * PRIVATE CODE that does the work of encodes an arbitrary variable into JSON format 
289
-    *
290
-    * @param    mixed   $var    any number, boolean, string, array, or object to be encoded.
291
-    *                           see argument 1 to Services_JSON() above for array-parsing behavior.
292
-    *                           if var is a strng, note that encode() always expects it
293
-    *                           to be in ASCII or UTF-8 format!
294
-    *
295
-    * @return   mixed   JSON string representation of input var or an error if a problem occurs
296
-    * @access   public
297
-    */
298
-    function _encode($var) 
299
-    {
286
+	}
287
+	/**
288
+	 * PRIVATE CODE that does the work of encodes an arbitrary variable into JSON format 
289
+	 *
290
+	 * @param    mixed   $var    any number, boolean, string, array, or object to be encoded.
291
+	 *                           see argument 1 to Services_JSON() above for array-parsing behavior.
292
+	 *                           if var is a strng, note that encode() always expects it
293
+	 *                           to be in ASCII or UTF-8 format!
294
+	 *
295
+	 * @return   mixed   JSON string representation of input var or an error if a problem occurs
296
+	 * @access   public
297
+	 */
298
+	function _encode($var) 
299
+	{
300 300
          
301
-        switch (gettype($var)) {
302
-            case 'boolean':
303
-                return $var ? 'true' : 'false';
301
+		switch (gettype($var)) {
302
+			case 'boolean':
303
+				return $var ? 'true' : 'false';
304 304
 
305
-            case 'NULL':
306
-                return 'null';
305
+			case 'NULL':
306
+				return 'null';
307 307
 
308
-            case 'integer':
309
-                return (int) $var;
308
+			case 'integer':
309
+				return (int) $var;
310 310
 
311
-            case 'double':
312
-            case 'float':
313
-                return  (float) $var;
311
+			case 'double':
312
+			case 'float':
313
+				return  (float) $var;
314 314
 
315
-            case 'string':
316
-                // STRINGS ARE EXPECTED TO BE IN ASCII OR UTF-8 FORMAT
317
-                $ascii = '';
318
-                $strlen_var = $this->strlen8($var);
315
+			case 'string':
316
+				// STRINGS ARE EXPECTED TO BE IN ASCII OR UTF-8 FORMAT
317
+				$ascii = '';
318
+				$strlen_var = $this->strlen8($var);
319 319
 
320
-               /*
320
+			   /*
321 321
                 * Iterate over every character in the string,
322 322
                 * escaping with a slash or encoding to UTF-8 where necessary
323 323
                 */
324
-                for ($c = 0; $c < $strlen_var; ++$c) {
325
-
326
-                    $ord_var_c = ord($var{$c});
327
-
328
-                    switch (true) {
329
-                        case $ord_var_c == 0x08:
330
-                            $ascii .= '\b';
331
-                            break;
332
-                        case $ord_var_c == 0x09:
333
-                            $ascii .= '\t';
334
-                            break;
335
-                        case $ord_var_c == 0x0A:
336
-                            $ascii .= '\n';
337
-                            break;
338
-                        case $ord_var_c == 0x0C:
339
-                            $ascii .= '\f';
340
-                            break;
341
-                        case $ord_var_c == 0x0D:
342
-                            $ascii .= '\r';
343
-                            break;
344
-
345
-                        case $ord_var_c == 0x22:
346
-                        case $ord_var_c == 0x2F:
347
-                        case $ord_var_c == 0x5C:
348
-                            // double quote, slash, slosh
349
-                            $ascii .= '\\'.$var{$c};
350
-                            break;
351
-
352
-                        case (($ord_var_c >= 0x20) && ($ord_var_c <= 0x7F)):
353
-                            // characters U-00000000 - U-0000007F (same as ASCII)
354
-                            $ascii .= $var{$c};
355
-                            break;
356
-
357
-                        case (($ord_var_c & 0xE0) == 0xC0):
358
-                            // characters U-00000080 - U-000007FF, mask 110XXXXX
359
-                            // see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
360
-                            if ($c+1 >= $strlen_var) {
361
-                                $c += 1;
362
-                                $ascii .= '?';
363
-                                break;
364
-                            }
324
+				for ($c = 0; $c < $strlen_var; ++$c) {
325
+
326
+					$ord_var_c = ord($var{$c});
327
+
328
+					switch (true) {
329
+						case $ord_var_c == 0x08:
330
+							$ascii .= '\b';
331
+							break;
332
+						case $ord_var_c == 0x09:
333
+							$ascii .= '\t';
334
+							break;
335
+						case $ord_var_c == 0x0A:
336
+							$ascii .= '\n';
337
+							break;
338
+						case $ord_var_c == 0x0C:
339
+							$ascii .= '\f';
340
+							break;
341
+						case $ord_var_c == 0x0D:
342
+							$ascii .= '\r';
343
+							break;
344
+
345
+						case $ord_var_c == 0x22:
346
+						case $ord_var_c == 0x2F:
347
+						case $ord_var_c == 0x5C:
348
+							// double quote, slash, slosh
349
+							$ascii .= '\\'.$var{$c};
350
+							break;
351
+
352
+						case (($ord_var_c >= 0x20) && ($ord_var_c <= 0x7F)):
353
+							// characters U-00000000 - U-0000007F (same as ASCII)
354
+							$ascii .= $var{$c};
355
+							break;
356
+
357
+						case (($ord_var_c & 0xE0) == 0xC0):
358
+							// characters U-00000080 - U-000007FF, mask 110XXXXX
359
+							// see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
360
+							if ($c+1 >= $strlen_var) {
361
+								$c += 1;
362
+								$ascii .= '?';
363
+								break;
364
+							}
365 365
                             
366
-                            $char = pack('C*', $ord_var_c, ord($var{$c + 1}));
367
-                            $c += 1;
368
-                            $utf16 = $this->utf82utf16($char);
369
-                            $ascii .= sprintf('\u%04s', bin2hex($utf16));
370
-                            break;
371
-
372
-                        case (($ord_var_c & 0xF0) == 0xE0):
373
-                            if ($c+2 >= $strlen_var) {
374
-                                $c += 2;
375
-                                $ascii .= '?';
376
-                                break;
377
-                            }
378
-                            // characters U-00000800 - U-0000FFFF, mask 1110XXXX
379
-                            // see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
380
-                            $char = pack('C*', $ord_var_c,
381
-                                         @ord($var{$c + 1}),
382
-                                         @ord($var{$c + 2}));
383
-                            $c += 2;
384
-                            $utf16 = $this->utf82utf16($char);
385
-                            $ascii .= sprintf('\u%04s', bin2hex($utf16));
386
-                            break;
387
-
388
-                        case (($ord_var_c & 0xF8) == 0xF0):
389
-                            if ($c+3 >= $strlen_var) {
390
-                                $c += 3;
391
-                                $ascii .= '?';
392
-                                break;
393
-                            }
394
-                            // characters U-00010000 - U-001FFFFF, mask 11110XXX
395
-                            // see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
396
-                            $char = pack('C*', $ord_var_c,
397
-                                         ord($var{$c + 1}),
398
-                                         ord($var{$c + 2}),
399
-                                         ord($var{$c + 3}));
400
-                            $c += 3;
401
-                            $utf16 = $this->utf82utf16($char);
402
-                            $ascii .= sprintf('\u%04s', bin2hex($utf16));
403
-                            break;
404
-
405
-                        case (($ord_var_c & 0xFC) == 0xF8):
406
-                            // characters U-00200000 - U-03FFFFFF, mask 111110XX
407
-                            // see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
408
-                            if ($c+4 >= $strlen_var) {
409
-                                $c += 4;
410
-                                $ascii .= '?';
411
-                                break;
412
-                            }
413
-                            $char = pack('C*', $ord_var_c,
414
-                                         ord($var{$c + 1}),
415
-                                         ord($var{$c + 2}),
416
-                                         ord($var{$c + 3}),
417
-                                         ord($var{$c + 4}));
418
-                            $c += 4;
419
-                            $utf16 = $this->utf82utf16($char);
420
-                            $ascii .= sprintf('\u%04s', bin2hex($utf16));
421
-                            break;
422
-
423
-                        case (($ord_var_c & 0xFE) == 0xFC):
424
-                        if ($c+5 >= $strlen_var) {
425
-                                $c += 5;
426
-                                $ascii .= '?';
427
-                                break;
428
-                            }
429
-                            // characters U-04000000 - U-7FFFFFFF, mask 1111110X
430
-                            // see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
431
-                            $char = pack('C*', $ord_var_c,
432
-                                         ord($var{$c + 1}),
433
-                                         ord($var{$c + 2}),
434
-                                         ord($var{$c + 3}),
435
-                                         ord($var{$c + 4}),
436
-                                         ord($var{$c + 5}));
437
-                            $c += 5;
438
-                            $utf16 = $this->utf82utf16($char);
439
-                            $ascii .= sprintf('\u%04s', bin2hex($utf16));
440
-                            break;
441
-                    }
442
-                }
443
-                return  '"'.$ascii.'"';
444
-
445
-            case 'array':
446
-               /*
366
+							$char = pack('C*', $ord_var_c, ord($var{$c + 1}));
367
+							$c += 1;
368
+							$utf16 = $this->utf82utf16($char);
369
+							$ascii .= sprintf('\u%04s', bin2hex($utf16));
370
+							break;
371
+
372
+						case (($ord_var_c & 0xF0) == 0xE0):
373
+							if ($c+2 >= $strlen_var) {
374
+								$c += 2;
375
+								$ascii .= '?';
376
+								break;
377
+							}
378
+							// characters U-00000800 - U-0000FFFF, mask 1110XXXX
379
+							// see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
380
+							$char = pack('C*', $ord_var_c,
381
+										 @ord($var{$c + 1}),
382
+										 @ord($var{$c + 2}));
383
+							$c += 2;
384
+							$utf16 = $this->utf82utf16($char);
385
+							$ascii .= sprintf('\u%04s', bin2hex($utf16));
386
+							break;
387
+
388
+						case (($ord_var_c & 0xF8) == 0xF0):
389
+							if ($c+3 >= $strlen_var) {
390
+								$c += 3;
391
+								$ascii .= '?';
392
+								break;
393
+							}
394
+							// characters U-00010000 - U-001FFFFF, mask 11110XXX
395
+							// see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
396
+							$char = pack('C*', $ord_var_c,
397
+										 ord($var{$c + 1}),
398
+										 ord($var{$c + 2}),
399
+										 ord($var{$c + 3}));
400
+							$c += 3;
401
+							$utf16 = $this->utf82utf16($char);
402
+							$ascii .= sprintf('\u%04s', bin2hex($utf16));
403
+							break;
404
+
405
+						case (($ord_var_c & 0xFC) == 0xF8):
406
+							// characters U-00200000 - U-03FFFFFF, mask 111110XX
407
+							// see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
408
+							if ($c+4 >= $strlen_var) {
409
+								$c += 4;
410
+								$ascii .= '?';
411
+								break;
412
+							}
413
+							$char = pack('C*', $ord_var_c,
414
+										 ord($var{$c + 1}),
415
+										 ord($var{$c + 2}),
416
+										 ord($var{$c + 3}),
417
+										 ord($var{$c + 4}));
418
+							$c += 4;
419
+							$utf16 = $this->utf82utf16($char);
420
+							$ascii .= sprintf('\u%04s', bin2hex($utf16));
421
+							break;
422
+
423
+						case (($ord_var_c & 0xFE) == 0xFC):
424
+						if ($c+5 >= $strlen_var) {
425
+								$c += 5;
426
+								$ascii .= '?';
427
+								break;
428
+							}
429
+							// characters U-04000000 - U-7FFFFFFF, mask 1111110X
430
+							// see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
431
+							$char = pack('C*', $ord_var_c,
432
+										 ord($var{$c + 1}),
433
+										 ord($var{$c + 2}),
434
+										 ord($var{$c + 3}),
435
+										 ord($var{$c + 4}),
436
+										 ord($var{$c + 5}));
437
+							$c += 5;
438
+							$utf16 = $this->utf82utf16($char);
439
+							$ascii .= sprintf('\u%04s', bin2hex($utf16));
440
+							break;
441
+					}
442
+				}
443
+				return  '"'.$ascii.'"';
444
+
445
+			case 'array':
446
+			   /*
447 447
                 * As per JSON spec if any array key is not an integer
448 448
                 * we must treat the whole array as an object. We
449 449
                 * also try to catch a sparsely populated associative
@@ -461,72 +461,72 @@  discard block
 block discarded – undo
461 461
                 * bracket notation.
462 462
                 */
463 463
 
464
-                // treat as a JSON object
465
-                if (is_array($var) && count($var) && (array_keys($var) !== range(0, sizeof($var) - 1))) {
466
-                    $properties = array_map(array($this, 'name_value'),
467
-                                            array_keys($var),
468
-                                            array_values($var));
464
+				// treat as a JSON object
465
+				if (is_array($var) && count($var) && (array_keys($var) !== range(0, sizeof($var) - 1))) {
466
+					$properties = array_map(array($this, 'name_value'),
467
+											array_keys($var),
468
+											array_values($var));
469 469
 
470
-                    foreach($properties as $property) {
471
-                        if(Services_JSON::isError($property)) {
472
-                            return $property;
473
-                        }
474
-                    }
470
+					foreach($properties as $property) {
471
+						if(Services_JSON::isError($property)) {
472
+							return $property;
473
+						}
474
+					}
475 475
 
476
-                    return '{' . join(',', $properties) . '}';
477
-                }
476
+					return '{' . join(',', $properties) . '}';
477
+				}
478 478
 
479
-                // treat it like a regular array
480
-                $elements = array_map(array($this, '_encode'), $var);
479
+				// treat it like a regular array
480
+				$elements = array_map(array($this, '_encode'), $var);
481 481
 
482
-                foreach($elements as $element) {
483
-                    if(Services_JSON::isError($element)) {
484
-                        return $element;
485
-                    }
486
-                }
482
+				foreach($elements as $element) {
483
+					if(Services_JSON::isError($element)) {
484
+						return $element;
485
+					}
486
+				}
487 487
 
488
-                return '[' . join(',', $elements) . ']';
488
+				return '[' . join(',', $elements) . ']';
489 489
 
490
-            case 'object':
490
+			case 'object':
491 491
             
492
-                // support toJSON methods.
493
-                if (($this->use & SERVICES_JSON_USE_TO_JSON) && method_exists($var, 'toJSON')) {
494
-                    // this may end up allowing unlimited recursion
495
-                    // so we check the return value to make sure it's not got the same method.
496
-                    $recode = $var->toJSON();
492
+				// support toJSON methods.
493
+				if (($this->use & SERVICES_JSON_USE_TO_JSON) && method_exists($var, 'toJSON')) {
494
+					// this may end up allowing unlimited recursion
495
+					// so we check the return value to make sure it's not got the same method.
496
+					$recode = $var->toJSON();
497 497
                     
498
-                    if (method_exists($recode, 'toJSON')) {
498
+					if (method_exists($recode, 'toJSON')) {
499 499
                         
500
-                        return ($this->use & SERVICES_JSON_SUPPRESS_ERRORS)
501
-                        ? 'null'
502
-                        : new Services_JSON_Error(get_class($var).
503
-                            " toJSON returned an object with a toJSON method.");
500
+						return ($this->use & SERVICES_JSON_SUPPRESS_ERRORS)
501
+						? 'null'
502
+						: new Services_JSON_Error(get_class($var).
503
+							" toJSON returned an object with a toJSON method.");
504 504
                             
505
-                    }
505
+					}
506 506
                     
507
-                    return $this->_encode( $recode );
508
-                } 
507
+					return $this->_encode( $recode );
508
+				} 
509 509
                 
510
-                $vars = get_object_vars($var);
510
+				$vars = get_object_vars($var);
511 511
                 
512
-                $properties = array_map(array($this, 'name_value'),
513
-                                        array_keys($vars),
514
-                                        array_values($vars));
515
-
516
-                foreach($properties as $property) {
517
-                    if(Services_JSON::isError($property)) {
518
-                        return $property;
519
-                    }
520
-                }
521
-
522
-                return '{' . join(',', $properties) . '}';
523
-
524
-            default:
525
-                return ($this->use & SERVICES_JSON_SUPPRESS_ERRORS)
526
-                    ? 'null'
527
-                    : new Services_JSON_Error(gettype($var)." can not be encoded as JSON string");
528
-        }
529
-    }
512
+				$properties = array_map(array($this, 'name_value'),
513
+										array_keys($vars),
514
+										array_values($vars));
515
+
516
+				foreach($properties as $property) {
517
+					if(Services_JSON::isError($property)) {
518
+						return $property;
519
+					}
520
+				}
521
+
522
+				return '{' . join(',', $properties) . '}';
523
+
524
+			default:
525
+				return ($this->use & SERVICES_JSON_SUPPRESS_ERRORS)
526
+					? 'null'
527
+					: new Services_JSON_Error(gettype($var)." can not be encoded as JSON string");
528
+		}
529
+	}
530 530
 
531 531
    /**
532 532
     * array-walking function for use in generating JSON-formatted name-value pairs
@@ -537,16 +537,16 @@  discard block
 block discarded – undo
537 537
     * @return   string  JSON-formatted name-value pair, like '"name":value'
538 538
     * @access   private
539 539
     */
540
-    function name_value($name, $value)
541
-    {
542
-        $encoded_value = $this->_encode($value);
540
+	function name_value($name, $value)
541
+	{
542
+		$encoded_value = $this->_encode($value);
543 543
 
544
-        if(Services_JSON::isError($encoded_value)) {
545
-            return $encoded_value;
546
-        }
544
+		if(Services_JSON::isError($encoded_value)) {
545
+			return $encoded_value;
546
+		}
547 547
 
548
-        return $this->_encode(strval($name)) . ':' . $encoded_value;
549
-    }
548
+		return $this->_encode(strval($name)) . ':' . $encoded_value;
549
+	}
550 550
 
551 551
    /**
552 552
     * reduce a string by removing leading and trailing comments and whitespace
@@ -556,24 +556,24 @@  discard block
 block discarded – undo
556 556
     * @return   string  string value stripped of comments and whitespace
557 557
     * @access   private
558 558
     */
559
-    function reduce_string($str)
560
-    {
561
-        $str = preg_replace(array(
559
+	function reduce_string($str)
560
+	{
561
+		$str = preg_replace(array(
562 562
 
563
-                // eliminate single line comments in '// ...' form
564
-                '#^\s*//(.+)$#m',
563
+				// eliminate single line comments in '// ...' form
564
+				'#^\s*//(.+)$#m',
565 565
 
566
-                // eliminate multi-line comments in '/* ... */' form, at start of string
567
-                '#^\s*/\*(.+)\*/#Us',
566
+				// eliminate multi-line comments in '/* ... */' form, at start of string
567
+				'#^\s*/\*(.+)\*/#Us',
568 568
 
569
-                // eliminate multi-line comments in '/* ... */' form, at end of string
570
-                '#/\*(.+)\*/\s*$#Us'
569
+				// eliminate multi-line comments in '/* ... */' form, at end of string
570
+				'#/\*(.+)\*/\s*$#Us'
571 571
 
572
-            ), '', $str);
572
+			), '', $str);
573 573
 
574
-        // eliminate extraneous space
575
-        return trim($str);
576
-    }
574
+		// eliminate extraneous space
575
+		return trim($str);
576
+	}
577 577
 
578 578
    /**
579 579
     * decodes a JSON string into appropriate variable
@@ -587,373 +587,373 @@  discard block
 block discarded – undo
587 587
     *                   in ASCII or UTF-8 format!
588 588
     * @access   public
589 589
     */
590
-    function decode($str)
591
-    {
592
-        $str = $this->reduce_string($str);
593
-
594
-        switch (strtolower($str)) {
595
-            case 'true':
596
-                return true;
597
-
598
-            case 'false':
599
-                return false;
600
-
601
-            case 'null':
602
-                return null;
603
-
604
-            default:
605
-                $m = array();
606
-
607
-                if (is_numeric($str)) {
608
-                    // Lookie-loo, it's a number
609
-
610
-                    // This would work on its own, but I'm trying to be
611
-                    // good about returning integers where appropriate:
612
-                    // return (float)$str;
613
-
614
-                    // Return float or int, as appropriate
615
-                    return ((float)$str == (integer)$str)
616
-                        ? (integer)$str
617
-                        : (float)$str;
618
-
619
-                } elseif (preg_match('/^("|\').*(\1)$/s', $str, $m) && $m[1] == $m[2]) {
620
-                    // STRINGS RETURNED IN UTF-8 FORMAT
621
-                    $delim = $this->substr8($str, 0, 1);
622
-                    $chrs = $this->substr8($str, 1, -1);
623
-                    $utf8 = '';
624
-                    $strlen_chrs = $this->strlen8($chrs);
625
-
626
-                    for ($c = 0; $c < $strlen_chrs; ++$c) {
627
-
628
-                        $substr_chrs_c_2 = $this->substr8($chrs, $c, 2);
629
-                        $ord_chrs_c = ord($chrs{$c});
630
-
631
-                        switch (true) {
632
-                            case $substr_chrs_c_2 == '\b':
633
-                                $utf8 .= chr(0x08);
634
-                                ++$c;
635
-                                break;
636
-                            case $substr_chrs_c_2 == '\t':
637
-                                $utf8 .= chr(0x09);
638
-                                ++$c;
639
-                                break;
640
-                            case $substr_chrs_c_2 == '\n':
641
-                                $utf8 .= chr(0x0A);
642
-                                ++$c;
643
-                                break;
644
-                            case $substr_chrs_c_2 == '\f':
645
-                                $utf8 .= chr(0x0C);
646
-                                ++$c;
647
-                                break;
648
-                            case $substr_chrs_c_2 == '\r':
649
-                                $utf8 .= chr(0x0D);
650
-                                ++$c;
651
-                                break;
652
-
653
-                            case $substr_chrs_c_2 == '\\"':
654
-                            case $substr_chrs_c_2 == '\\\'':
655
-                            case $substr_chrs_c_2 == '\\\\':
656
-                            case $substr_chrs_c_2 == '\\/':
657
-                                if (($delim == '"' && $substr_chrs_c_2 != '\\\'') ||
658
-                                   ($delim == "'" && $substr_chrs_c_2 != '\\"')) {
659
-                                    $utf8 .= $chrs{++$c};
660
-                                }
661
-                                break;
662
-
663
-                            case preg_match('/\\\u[0-9A-F]{4}/i', $this->substr8($chrs, $c, 6)):
664
-                                // single, escaped unicode character
665
-                                $utf16 = chr(hexdec($this->substr8($chrs, ($c + 2), 2)))
666
-                                       . chr(hexdec($this->substr8($chrs, ($c + 4), 2)));
667
-                                $utf8 .= $this->utf162utf8($utf16);
668
-                                $c += 5;
669
-                                break;
670
-
671
-                            case ($ord_chrs_c >= 0x20) && ($ord_chrs_c <= 0x7F):
672
-                                $utf8 .= $chrs{$c};
673
-                                break;
674
-
675
-                            case ($ord_chrs_c & 0xE0) == 0xC0:
676
-                                // characters U-00000080 - U-000007FF, mask 110XXXXX
677
-                                //see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
678
-                                $utf8 .= $this->substr8($chrs, $c, 2);
679
-                                ++$c;
680
-                                break;
681
-
682
-                            case ($ord_chrs_c & 0xF0) == 0xE0:
683
-                                // characters U-00000800 - U-0000FFFF, mask 1110XXXX
684
-                                // see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
685
-                                $utf8 .= $this->substr8($chrs, $c, 3);
686
-                                $c += 2;
687
-                                break;
688
-
689
-                            case ($ord_chrs_c & 0xF8) == 0xF0:
690
-                                // characters U-00010000 - U-001FFFFF, mask 11110XXX
691
-                                // see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
692
-                                $utf8 .= $this->substr8($chrs, $c, 4);
693
-                                $c += 3;
694
-                                break;
695
-
696
-                            case ($ord_chrs_c & 0xFC) == 0xF8:
697
-                                // characters U-00200000 - U-03FFFFFF, mask 111110XX
698
-                                // see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
699
-                                $utf8 .= $this->substr8($chrs, $c, 5);
700
-                                $c += 4;
701
-                                break;
702
-
703
-                            case ($ord_chrs_c & 0xFE) == 0xFC:
704
-                                // characters U-04000000 - U-7FFFFFFF, mask 1111110X
705
-                                // see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
706
-                                $utf8 .= $this->substr8($chrs, $c, 6);
707
-                                $c += 5;
708
-                                break;
709
-
710
-                        }
711
-
712
-                    }
713
-
714
-                    return $utf8;
715
-
716
-                } elseif (preg_match('/^\[.*\]$/s', $str) || preg_match('/^\{.*\}$/s', $str)) {
717
-                    // array, or object notation
718
-
719
-                    if ($str{0} == '[') {
720
-                        $stk = array(SERVICES_JSON_IN_ARR);
721
-                        $arr = array();
722
-                    } else {
723
-                        if ($this->use & SERVICES_JSON_LOOSE_TYPE) {
724
-                            $stk = array(SERVICES_JSON_IN_OBJ);
725
-                            $obj = array();
726
-                        } else {
727
-                            $stk = array(SERVICES_JSON_IN_OBJ);
728
-                            $obj = new stdClass();
729
-                        }
730
-                    }
731
-
732
-                    array_push($stk, array('what'  => SERVICES_JSON_SLICE,
733
-                                           'where' => 0,
734
-                                           'delim' => false));
735
-
736
-                    $chrs = $this->substr8($str, 1, -1);
737
-                    $chrs = $this->reduce_string($chrs);
738
-
739
-                    if ($chrs == '') {
740
-                        if (reset($stk) == SERVICES_JSON_IN_ARR) {
741
-                            return $arr;
742
-
743
-                        } else {
744
-                            return $obj;
745
-
746
-                        }
747
-                    }
748
-
749
-                    //print("\nparsing {$chrs}\n");
750
-
751
-                    $strlen_chrs = $this->strlen8($chrs);
752
-
753
-                    for ($c = 0; $c <= $strlen_chrs; ++$c) {
754
-
755
-                        $top = end($stk);
756
-                        $substr_chrs_c_2 = $this->substr8($chrs, $c, 2);
757
-
758
-                        if (($c == $strlen_chrs) || (($chrs{$c} == ',') && ($top['what'] == SERVICES_JSON_SLICE))) {
759
-                            // found a comma that is not inside a string, array, etc.,
760
-                            // OR we've reached the end of the character list
761
-                            $slice = $this->substr8($chrs, $top['where'], ($c - $top['where']));
762
-                            array_push($stk, array('what' => SERVICES_JSON_SLICE, 'where' => ($c + 1), 'delim' => false));
763
-                            //print("Found split at {$c}: ".$this->substr8($chrs, $top['where'], (1 + $c - $top['where']))."\n");
764
-
765
-                            if (reset($stk) == SERVICES_JSON_IN_ARR) {
766
-                                // we are in an array, so just push an element onto the stack
767
-                                array_push($arr, $this->decode($slice));
768
-
769
-                            } elseif (reset($stk) == SERVICES_JSON_IN_OBJ) {
770
-                                // we are in an object, so figure
771
-                                // out the property name and set an
772
-                                // element in an associative array,
773
-                                // for now
774
-                                $parts = array();
590
+	function decode($str)
591
+	{
592
+		$str = $this->reduce_string($str);
593
+
594
+		switch (strtolower($str)) {
595
+			case 'true':
596
+				return true;
597
+
598
+			case 'false':
599
+				return false;
600
+
601
+			case 'null':
602
+				return null;
603
+
604
+			default:
605
+				$m = array();
606
+
607
+				if (is_numeric($str)) {
608
+					// Lookie-loo, it's a number
609
+
610
+					// This would work on its own, but I'm trying to be
611
+					// good about returning integers where appropriate:
612
+					// return (float)$str;
613
+
614
+					// Return float or int, as appropriate
615
+					return ((float)$str == (integer)$str)
616
+						? (integer)$str
617
+						: (float)$str;
618
+
619
+				} elseif (preg_match('/^("|\').*(\1)$/s', $str, $m) && $m[1] == $m[2]) {
620
+					// STRINGS RETURNED IN UTF-8 FORMAT
621
+					$delim = $this->substr8($str, 0, 1);
622
+					$chrs = $this->substr8($str, 1, -1);
623
+					$utf8 = '';
624
+					$strlen_chrs = $this->strlen8($chrs);
625
+
626
+					for ($c = 0; $c < $strlen_chrs; ++$c) {
627
+
628
+						$substr_chrs_c_2 = $this->substr8($chrs, $c, 2);
629
+						$ord_chrs_c = ord($chrs{$c});
630
+
631
+						switch (true) {
632
+							case $substr_chrs_c_2 == '\b':
633
+								$utf8 .= chr(0x08);
634
+								++$c;
635
+								break;
636
+							case $substr_chrs_c_2 == '\t':
637
+								$utf8 .= chr(0x09);
638
+								++$c;
639
+								break;
640
+							case $substr_chrs_c_2 == '\n':
641
+								$utf8 .= chr(0x0A);
642
+								++$c;
643
+								break;
644
+							case $substr_chrs_c_2 == '\f':
645
+								$utf8 .= chr(0x0C);
646
+								++$c;
647
+								break;
648
+							case $substr_chrs_c_2 == '\r':
649
+								$utf8 .= chr(0x0D);
650
+								++$c;
651
+								break;
652
+
653
+							case $substr_chrs_c_2 == '\\"':
654
+							case $substr_chrs_c_2 == '\\\'':
655
+							case $substr_chrs_c_2 == '\\\\':
656
+							case $substr_chrs_c_2 == '\\/':
657
+								if (($delim == '"' && $substr_chrs_c_2 != '\\\'') ||
658
+								   ($delim == "'" && $substr_chrs_c_2 != '\\"')) {
659
+									$utf8 .= $chrs{++$c};
660
+								}
661
+								break;
662
+
663
+							case preg_match('/\\\u[0-9A-F]{4}/i', $this->substr8($chrs, $c, 6)):
664
+								// single, escaped unicode character
665
+								$utf16 = chr(hexdec($this->substr8($chrs, ($c + 2), 2)))
666
+									   . chr(hexdec($this->substr8($chrs, ($c + 4), 2)));
667
+								$utf8 .= $this->utf162utf8($utf16);
668
+								$c += 5;
669
+								break;
670
+
671
+							case ($ord_chrs_c >= 0x20) && ($ord_chrs_c <= 0x7F):
672
+								$utf8 .= $chrs{$c};
673
+								break;
674
+
675
+							case ($ord_chrs_c & 0xE0) == 0xC0:
676
+								// characters U-00000080 - U-000007FF, mask 110XXXXX
677
+								//see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
678
+								$utf8 .= $this->substr8($chrs, $c, 2);
679
+								++$c;
680
+								break;
681
+
682
+							case ($ord_chrs_c & 0xF0) == 0xE0:
683
+								// characters U-00000800 - U-0000FFFF, mask 1110XXXX
684
+								// see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
685
+								$utf8 .= $this->substr8($chrs, $c, 3);
686
+								$c += 2;
687
+								break;
688
+
689
+							case ($ord_chrs_c & 0xF8) == 0xF0:
690
+								// characters U-00010000 - U-001FFFFF, mask 11110XXX
691
+								// see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
692
+								$utf8 .= $this->substr8($chrs, $c, 4);
693
+								$c += 3;
694
+								break;
695
+
696
+							case ($ord_chrs_c & 0xFC) == 0xF8:
697
+								// characters U-00200000 - U-03FFFFFF, mask 111110XX
698
+								// see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
699
+								$utf8 .= $this->substr8($chrs, $c, 5);
700
+								$c += 4;
701
+								break;
702
+
703
+							case ($ord_chrs_c & 0xFE) == 0xFC:
704
+								// characters U-04000000 - U-7FFFFFFF, mask 1111110X
705
+								// see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
706
+								$utf8 .= $this->substr8($chrs, $c, 6);
707
+								$c += 5;
708
+								break;
709
+
710
+						}
711
+
712
+					}
713
+
714
+					return $utf8;
715
+
716
+				} elseif (preg_match('/^\[.*\]$/s', $str) || preg_match('/^\{.*\}$/s', $str)) {
717
+					// array, or object notation
718
+
719
+					if ($str{0} == '[') {
720
+						$stk = array(SERVICES_JSON_IN_ARR);
721
+						$arr = array();
722
+					} else {
723
+						if ($this->use & SERVICES_JSON_LOOSE_TYPE) {
724
+							$stk = array(SERVICES_JSON_IN_OBJ);
725
+							$obj = array();
726
+						} else {
727
+							$stk = array(SERVICES_JSON_IN_OBJ);
728
+							$obj = new stdClass();
729
+						}
730
+					}
731
+
732
+					array_push($stk, array('what'  => SERVICES_JSON_SLICE,
733
+										   'where' => 0,
734
+										   'delim' => false));
735
+
736
+					$chrs = $this->substr8($str, 1, -1);
737
+					$chrs = $this->reduce_string($chrs);
738
+
739
+					if ($chrs == '') {
740
+						if (reset($stk) == SERVICES_JSON_IN_ARR) {
741
+							return $arr;
742
+
743
+						} else {
744
+							return $obj;
745
+
746
+						}
747
+					}
748
+
749
+					//print("\nparsing {$chrs}\n");
750
+
751
+					$strlen_chrs = $this->strlen8($chrs);
752
+
753
+					for ($c = 0; $c <= $strlen_chrs; ++$c) {
754
+
755
+						$top = end($stk);
756
+						$substr_chrs_c_2 = $this->substr8($chrs, $c, 2);
757
+
758
+						if (($c == $strlen_chrs) || (($chrs{$c} == ',') && ($top['what'] == SERVICES_JSON_SLICE))) {
759
+							// found a comma that is not inside a string, array, etc.,
760
+							// OR we've reached the end of the character list
761
+							$slice = $this->substr8($chrs, $top['where'], ($c - $top['where']));
762
+							array_push($stk, array('what' => SERVICES_JSON_SLICE, 'where' => ($c + 1), 'delim' => false));
763
+							//print("Found split at {$c}: ".$this->substr8($chrs, $top['where'], (1 + $c - $top['where']))."\n");
764
+
765
+							if (reset($stk) == SERVICES_JSON_IN_ARR) {
766
+								// we are in an array, so just push an element onto the stack
767
+								array_push($arr, $this->decode($slice));
768
+
769
+							} elseif (reset($stk) == SERVICES_JSON_IN_OBJ) {
770
+								// we are in an object, so figure
771
+								// out the property name and set an
772
+								// element in an associative array,
773
+								// for now
774
+								$parts = array();
775 775
                                 
776
-                               if (preg_match('/^\s*(["\'].*[^\\\]["\'])\s*:/Uis', $slice, $parts)) {
777
- 	                              // "name":value pair
778
-                                    $key = $this->decode($parts[1]);
779
-                                    $val = $this->decode(trim(substr($slice, strlen($parts[0])), ", \t\n\r\0\x0B"));
780
-                                    if ($this->use & SERVICES_JSON_LOOSE_TYPE) {
781
-                                        $obj[$key] = $val;
782
-                                    } else {
783
-                                        $obj->$key = $val;
784
-                                    }
785
-                                } elseif (preg_match('/^\s*(\w+)\s*:/Uis', $slice, $parts)) {
786
-                                    // name:value pair, where name is unquoted
787
-                                    $key = $parts[1];
788
-                                    $val = $this->decode(trim(substr($slice, strlen($parts[0])), ", \t\n\r\0\x0B"));
789
-
790
-                                    if ($this->use & SERVICES_JSON_LOOSE_TYPE) {
791
-                                        $obj[$key] = $val;
792
-                                    } else {
793
-                                        $obj->$key = $val;
794
-                                    }
795
-                                }
796
-
797
-                            }
798
-
799
-                        } elseif ((($chrs{$c} == '"') || ($chrs{$c} == "'")) && ($top['what'] != SERVICES_JSON_IN_STR)) {
800
-                            // found a quote, and we are not inside a string
801
-                            array_push($stk, array('what' => SERVICES_JSON_IN_STR, 'where' => $c, 'delim' => $chrs{$c}));
802
-                            //print("Found start of string at {$c}\n");
803
-
804
-                        } elseif (($chrs{$c} == $top['delim']) &&
805
-                                 ($top['what'] == SERVICES_JSON_IN_STR) &&
806
-                                 (($this->strlen8($this->substr8($chrs, 0, $c)) - $this->strlen8(rtrim($this->substr8($chrs, 0, $c), '\\'))) % 2 != 1)) {
807
-                            // found a quote, we're in a string, and it's not escaped
808
-                            // we know that it's not escaped becase there is _not_ an
809
-                            // odd number of backslashes at the end of the string so far
810
-                            array_pop($stk);
811
-                            //print("Found end of string at {$c}: ".$this->substr8($chrs, $top['where'], (1 + 1 + $c - $top['where']))."\n");
812
-
813
-                        } elseif (($chrs{$c} == '[') &&
814
-                                 in_array($top['what'], array(SERVICES_JSON_SLICE, SERVICES_JSON_IN_ARR, SERVICES_JSON_IN_OBJ))) {
815
-                            // found a left-bracket, and we are in an array, object, or slice
816
-                            array_push($stk, array('what' => SERVICES_JSON_IN_ARR, 'where' => $c, 'delim' => false));
817
-                            //print("Found start of array at {$c}\n");
818
-
819
-                        } elseif (($chrs{$c} == ']') && ($top['what'] == SERVICES_JSON_IN_ARR)) {
820
-                            // found a right-bracket, and we're in an array
821
-                            array_pop($stk);
822
-                            //print("Found end of array at {$c}: ".$this->substr8($chrs, $top['where'], (1 + $c - $top['where']))."\n");
823
-
824
-                        } elseif (($chrs{$c} == '{') &&
825
-                                 in_array($top['what'], array(SERVICES_JSON_SLICE, SERVICES_JSON_IN_ARR, SERVICES_JSON_IN_OBJ))) {
826
-                            // found a left-brace, and we are in an array, object, or slice
827
-                            array_push($stk, array('what' => SERVICES_JSON_IN_OBJ, 'where' => $c, 'delim' => false));
828
-                            //print("Found start of object at {$c}\n");
829
-
830
-                        } elseif (($chrs{$c} == '}') && ($top['what'] == SERVICES_JSON_IN_OBJ)) {
831
-                            // found a right-brace, and we're in an object
832
-                            array_pop($stk);
833
-                            //print("Found end of object at {$c}: ".$this->substr8($chrs, $top['where'], (1 + $c - $top['where']))."\n");
834
-
835
-                        } elseif (($substr_chrs_c_2 == '/*') &&
836
-                                 in_array($top['what'], array(SERVICES_JSON_SLICE, SERVICES_JSON_IN_ARR, SERVICES_JSON_IN_OBJ))) {
837
-                            // found a comment start, and we are in an array, object, or slice
838
-                            array_push($stk, array('what' => SERVICES_JSON_IN_CMT, 'where' => $c, 'delim' => false));
839
-                            $c++;
840
-                            //print("Found start of comment at {$c}\n");
841
-
842
-                        } elseif (($substr_chrs_c_2 == '*/') && ($top['what'] == SERVICES_JSON_IN_CMT)) {
843
-                            // found a comment end, and we're in one now
844
-                            array_pop($stk);
845
-                            $c++;
846
-
847
-                            for ($i = $top['where']; $i <= $c; ++$i)
848
-                                $chrs = substr_replace($chrs, ' ', $i, 1);
849
-
850
-                            //print("Found end of comment at {$c}: ".$this->substr8($chrs, $top['where'], (1 + $c - $top['where']))."\n");
851
-
852
-                        }
853
-
854
-                    }
855
-
856
-                    if (reset($stk) == SERVICES_JSON_IN_ARR) {
857
-                        return $arr;
858
-
859
-                    } elseif (reset($stk) == SERVICES_JSON_IN_OBJ) {
860
-                        return $obj;
861
-
862
-                    }
863
-
864
-                }
865
-        }
866
-    }
867
-
868
-    /**
869
-     * @todo Ultimately, this should just call PEAR::isError()
870
-     */
871
-    function isError($data, $code = null)
872
-    {
873
-        if (class_exists('pear')) {
874
-            return PEAR::isError($data, $code);
875
-        } elseif (is_object($data) && (get_class($data) == 'services_json_error' ||
876
-                                 is_subclass_of($data, 'services_json_error'))) {
877
-            return true;
878
-        }
879
-
880
-        return false;
881
-    }
776
+							   if (preg_match('/^\s*(["\'].*[^\\\]["\'])\s*:/Uis', $slice, $parts)) {
777
+ 								  // "name":value pair
778
+									$key = $this->decode($parts[1]);
779
+									$val = $this->decode(trim(substr($slice, strlen($parts[0])), ", \t\n\r\0\x0B"));
780
+									if ($this->use & SERVICES_JSON_LOOSE_TYPE) {
781
+										$obj[$key] = $val;
782
+									} else {
783
+										$obj->$key = $val;
784
+									}
785
+								} elseif (preg_match('/^\s*(\w+)\s*:/Uis', $slice, $parts)) {
786
+									// name:value pair, where name is unquoted
787
+									$key = $parts[1];
788
+									$val = $this->decode(trim(substr($slice, strlen($parts[0])), ", \t\n\r\0\x0B"));
789
+
790
+									if ($this->use & SERVICES_JSON_LOOSE_TYPE) {
791
+										$obj[$key] = $val;
792
+									} else {
793
+										$obj->$key = $val;
794
+									}
795
+								}
796
+
797
+							}
798
+
799
+						} elseif ((($chrs{$c} == '"') || ($chrs{$c} == "'")) && ($top['what'] != SERVICES_JSON_IN_STR)) {
800
+							// found a quote, and we are not inside a string
801
+							array_push($stk, array('what' => SERVICES_JSON_IN_STR, 'where' => $c, 'delim' => $chrs{$c}));
802
+							//print("Found start of string at {$c}\n");
803
+
804
+						} elseif (($chrs{$c} == $top['delim']) &&
805
+								 ($top['what'] == SERVICES_JSON_IN_STR) &&
806
+								 (($this->strlen8($this->substr8($chrs, 0, $c)) - $this->strlen8(rtrim($this->substr8($chrs, 0, $c), '\\'))) % 2 != 1)) {
807
+							// found a quote, we're in a string, and it's not escaped
808
+							// we know that it's not escaped becase there is _not_ an
809
+							// odd number of backslashes at the end of the string so far
810
+							array_pop($stk);
811
+							//print("Found end of string at {$c}: ".$this->substr8($chrs, $top['where'], (1 + 1 + $c - $top['where']))."\n");
812
+
813
+						} elseif (($chrs{$c} == '[') &&
814
+								 in_array($top['what'], array(SERVICES_JSON_SLICE, SERVICES_JSON_IN_ARR, SERVICES_JSON_IN_OBJ))) {
815
+							// found a left-bracket, and we are in an array, object, or slice
816
+							array_push($stk, array('what' => SERVICES_JSON_IN_ARR, 'where' => $c, 'delim' => false));
817
+							//print("Found start of array at {$c}\n");
818
+
819
+						} elseif (($chrs{$c} == ']') && ($top['what'] == SERVICES_JSON_IN_ARR)) {
820
+							// found a right-bracket, and we're in an array
821
+							array_pop($stk);
822
+							//print("Found end of array at {$c}: ".$this->substr8($chrs, $top['where'], (1 + $c - $top['where']))."\n");
823
+
824
+						} elseif (($chrs{$c} == '{') &&
825
+								 in_array($top['what'], array(SERVICES_JSON_SLICE, SERVICES_JSON_IN_ARR, SERVICES_JSON_IN_OBJ))) {
826
+							// found a left-brace, and we are in an array, object, or slice
827
+							array_push($stk, array('what' => SERVICES_JSON_IN_OBJ, 'where' => $c, 'delim' => false));
828
+							//print("Found start of object at {$c}\n");
829
+
830
+						} elseif (($chrs{$c} == '}') && ($top['what'] == SERVICES_JSON_IN_OBJ)) {
831
+							// found a right-brace, and we're in an object
832
+							array_pop($stk);
833
+							//print("Found end of object at {$c}: ".$this->substr8($chrs, $top['where'], (1 + $c - $top['where']))."\n");
834
+
835
+						} elseif (($substr_chrs_c_2 == '/*') &&
836
+								 in_array($top['what'], array(SERVICES_JSON_SLICE, SERVICES_JSON_IN_ARR, SERVICES_JSON_IN_OBJ))) {
837
+							// found a comment start, and we are in an array, object, or slice
838
+							array_push($stk, array('what' => SERVICES_JSON_IN_CMT, 'where' => $c, 'delim' => false));
839
+							$c++;
840
+							//print("Found start of comment at {$c}\n");
841
+
842
+						} elseif (($substr_chrs_c_2 == '*/') && ($top['what'] == SERVICES_JSON_IN_CMT)) {
843
+							// found a comment end, and we're in one now
844
+							array_pop($stk);
845
+							$c++;
846
+
847
+							for ($i = $top['where']; $i <= $c; ++$i)
848
+								$chrs = substr_replace($chrs, ' ', $i, 1);
849
+
850
+							//print("Found end of comment at {$c}: ".$this->substr8($chrs, $top['where'], (1 + $c - $top['where']))."\n");
851
+
852
+						}
853
+
854
+					}
855
+
856
+					if (reset($stk) == SERVICES_JSON_IN_ARR) {
857
+						return $arr;
858
+
859
+					} elseif (reset($stk) == SERVICES_JSON_IN_OBJ) {
860
+						return $obj;
861
+
862
+					}
863
+
864
+				}
865
+		}
866
+	}
867
+
868
+	/**
869
+	 * @todo Ultimately, this should just call PEAR::isError()
870
+	 */
871
+	function isError($data, $code = null)
872
+	{
873
+		if (class_exists('pear')) {
874
+			return PEAR::isError($data, $code);
875
+		} elseif (is_object($data) && (get_class($data) == 'services_json_error' ||
876
+								 is_subclass_of($data, 'services_json_error'))) {
877
+			return true;
878
+		}
879
+
880
+		return false;
881
+	}
882 882
     
883
-    /**
884
-    * Calculates length of string in bytes
885
-    * @param string 
886
-    * @return integer length
887
-    */
888
-    function strlen8( $str ) 
889
-    {
890
-        if ( $this->_mb_strlen ) {
891
-            return mb_strlen( $str, "8bit" );
892
-        }
893
-        return strlen( $str );
894
-    }
883
+	/**
884
+	 * Calculates length of string in bytes
885
+	 * @param string 
886
+	 * @return integer length
887
+	 */
888
+	function strlen8( $str ) 
889
+	{
890
+		if ( $this->_mb_strlen ) {
891
+			return mb_strlen( $str, "8bit" );
892
+		}
893
+		return strlen( $str );
894
+	}
895 895
     
896
-    /**
897
-    * Returns part of a string, interpreting $start and $length as number of bytes.
898
-    * @param string 
899
-    * @param integer start 
900
-    * @param integer length 
901
-    * @return integer length
902
-    */
903
-    function substr8( $string, $start, $length=false ) 
904
-    {
905
-        if ( $length === false ) {
906
-            $length = $this->strlen8( $string ) - $start;
907
-        }
908
-        if ( $this->_mb_substr ) {
909
-            return mb_substr( $string, $start, $length, "8bit" );
910
-        }
911
-        return substr( $string, $start, $length );
912
-    }
896
+	/**
897
+	 * Returns part of a string, interpreting $start and $length as number of bytes.
898
+	 * @param string 
899
+	 * @param integer start 
900
+	 * @param integer length 
901
+	 * @return integer length
902
+	 */
903
+	function substr8( $string, $start, $length=false ) 
904
+	{
905
+		if ( $length === false ) {
906
+			$length = $this->strlen8( $string ) - $start;
907
+		}
908
+		if ( $this->_mb_substr ) {
909
+			return mb_substr( $string, $start, $length, "8bit" );
910
+		}
911
+		return substr( $string, $start, $length );
912
+	}
913 913
 
914 914
 }
915 915
 
916 916
 if (class_exists('PEAR_Error')) {
917 917
 
918
-    class Services_JSON_Error extends PEAR_Error
919
-    {
920
-        function __construct($message = 'unknown error', $code = null,
921
-                                     $mode = null, $options = null, $userinfo = null)
922
-        {
923
-            parent::PEAR_Error($message, $code, $mode, $options, $userinfo);
924
-        }
918
+	class Services_JSON_Error extends PEAR_Error
919
+	{
920
+		function __construct($message = 'unknown error', $code = null,
921
+									 $mode = null, $options = null, $userinfo = null)
922
+		{
923
+			parent::PEAR_Error($message, $code, $mode, $options, $userinfo);
924
+		}
925 925
 
926 926
 	public function Services_JSON_Error($message = 'unknown error', $code = null,
927
-                                     $mode = null, $options = null, $userinfo = null) {
927
+									 $mode = null, $options = null, $userinfo = null) {
928 928
 		self::__construct($message = 'unknown error', $code = null,
929
-                                     $mode = null, $options = null, $userinfo = null);
929
+									 $mode = null, $options = null, $userinfo = null);
930
+	}
930 931
 	}
931
-    }
932 932
 
933 933
 } else {
934 934
 
935
-    /**
936
-     * @todo Ultimately, this class shall be descended from PEAR_Error
937
-     */
938
-    class Services_JSON_Error
939
-    {
940
-	    /**
941
-	     * PHP5 constructor.
942
-	     */
943
-        function __construct( $message = 'unknown error', $code = null,
944
-                                     $mode = null, $options = null, $userinfo = null )
945
-        {
946
-
947
-        }
948
-
949
-	    /**
950
-	     * PHP4 constructor.
951
-	     */
935
+	/**
936
+	 * @todo Ultimately, this class shall be descended from PEAR_Error
937
+	 */
938
+	class Services_JSON_Error
939
+	{
940
+		/**
941
+		 * PHP5 constructor.
942
+		 */
943
+		function __construct( $message = 'unknown error', $code = null,
944
+									 $mode = null, $options = null, $userinfo = null )
945
+		{
946
+
947
+		}
948
+
949
+		/**
950
+		 * PHP4 constructor.
951
+		 */
952 952
 		public function Services_JSON_Error( $message = 'unknown error', $code = null,
953
-	                                     $mode = null, $options = null, $userinfo = null ) {
953
+										 $mode = null, $options = null, $userinfo = null ) {
954 954
 			self::__construct( $message, $code, $mode, $options, $userinfo );
955 955
 		}
956
-    }
956
+	}
957 957
     
958 958
 }
959 959
 
Please login to merge, or discard this patch.
src/wp-includes/post.php 4 patches
Switch Indentation   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -5208,18 +5208,18 @@
 block discarded – undo
5208 5208
 	}
5209 5209
 
5210 5210
 	switch ( $type ) {
5211
-	case 'image':
5212
-		$image_exts = array( 'jpg', 'jpeg', 'jpe', 'gif', 'png' );
5213
-		return in_array( $ext, $image_exts );
5211
+		case 'image':
5212
+			$image_exts = array( 'jpg', 'jpeg', 'jpe', 'gif', 'png' );
5213
+			return in_array( $ext, $image_exts );
5214 5214
 
5215
-	case 'audio':
5216
-		return in_array( $ext, wp_get_audio_extensions() );
5215
+		case 'audio':
5216
+			return in_array( $ext, wp_get_audio_extensions() );
5217 5217
 
5218
-	case 'video':
5219
-		return in_array( $ext, wp_get_video_extensions() );
5218
+		case 'video':
5219
+			return in_array( $ext, wp_get_video_extensions() );
5220 5220
 
5221
-	default:
5222
-		return $type === $ext;
5221
+		default:
5222
+			return $type === $ext;
5223 5223
 	}
5224 5224
 }
5225 5225
 
Please login to merge, or discard this patch.
Doc Comments   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -473,7 +473,7 @@  discard block
 block discarded – undo
473 473
  * @since 1.0.0
474 474
  *
475 475
  * @param string $post Post content.
476
- * @return array Post before ('main'), after ('extended'), and custom read more ('more_text').
476
+ * @return integer Post before ('main'), after ('extended'), and custom read more ('more_text').
477 477
  */
478 478
 function get_extended( $post ) {
479 479
 	//Match the new style more links.
@@ -1362,7 +1362,7 @@  discard block
 block discarded – undo
1362 1362
  *
1363 1363
  * @access private
1364 1364
  *
1365
- * @param object|WP_Post_Type $post_type_object Post type object.
1365
+ * @param WP_Post_Type $post_type_object Post type object.
1366 1366
  * @return object Object with all the labels as member variables.
1367 1367
  */
1368 1368
 function get_post_type_labels( $post_type_object ) {
@@ -1727,7 +1727,7 @@  discard block
 block discarded – undo
1727 1727
  *
1728 1728
  * @param int    $post_id    Post ID.
1729 1729
  * @param string $meta_key   Metadata name.
1730
- * @param mixed  $meta_value Optional. Metadata value. Must be serializable if
1730
+ * @param string  $meta_value Optional. Metadata value. Must be serializable if
1731 1731
  *                           non-scalar. Default empty.
1732 1732
  * @return bool True on success, false on failure.
1733 1733
  */
@@ -2420,7 +2420,7 @@  discard block
 block discarded – undo
2420 2420
  * @param int  $postid       Optional. Post ID. Default 0.
2421 2421
  * @param bool $force_delete Optional. Whether to bypass trash and force deletion.
2422 2422
  *                           Default false.
2423
- * @return array|false|WP_Post False on failure.
2423
+ * @return string False on failure.
2424 2424
  */
2425 2425
 function wp_delete_post( $postid = 0, $force_delete = false ) {
2426 2426
 	global $wpdb;
@@ -2678,7 +2678,7 @@  discard block
 block discarded – undo
2678 2678
  *
2679 2679
  * @global wpdb $wpdb WordPress database abstraction object.
2680 2680
  *
2681
- * @param int|WP_Post|null $post Optional. Post ID or post object. Defaults to global $post.
2681
+ * @param integer $post Optional. Post ID or post object. Defaults to global $post.
2682 2682
  * @return mixed|void False on failure.
2683 2683
  */
2684 2684
 function wp_trash_post_comments( $post = null ) {
@@ -2734,8 +2734,8 @@  discard block
 block discarded – undo
2734 2734
  *
2735 2735
  * @global wpdb $wpdb WordPress database abstraction object.
2736 2736
  *
2737
- * @param int|WP_Post|null $post Optional. Post ID or post object. Defaults to global $post.
2738
- * @return true|void
2737
+ * @param integer $post Optional. Post ID or post object. Defaults to global $post.
2738
+ * @return null|boolean
2739 2739
  */
2740 2740
 function wp_untrash_post_comments( $post = null ) {
2741 2741
 	global $wpdb;
@@ -4439,7 +4439,7 @@  discard block
 block discarded – undo
4439 4439
  * @since 1.5.0
4440 4440
  * @since 4.6.0 Converted the `$page` parameter to optional.
4441 4441
  *
4442
- * @param WP_Post|object|int $page Optional. Page ID or WP_Post object. Default is global $post.
4442
+ * @param integer $page Optional. Page ID or WP_Post object. Default is global $post.
4443 4443
  * @return string|false Page URI, false on error.
4444 4444
  */
4445 4445
 function get_page_uri( $page = 0 ) {
@@ -5242,7 +5242,7 @@  discard block
 block discarded – undo
5242 5242
  *
5243 5243
  * @since 2.1.0
5244 5244
  *
5245
- * @param string|int $mime MIME type or attachment ID.
5245
+ * @param integer $mime MIME type or attachment ID.
5246 5246
  * @return string|false Icon, false otherwise.
5247 5247
  */
5248 5248
 function wp_mime_type_icon( $mime = 0 ) {
@@ -6142,7 +6142,7 @@  discard block
 block discarded – undo
6142 6142
  * @access private
6143 6143
  *
6144 6144
  * @param string $post_name Slug.
6145
- * @param string $post_ID   Optional. Post ID that should be ignored. Default 0.
6145
+ * @param integer $post_ID   Optional. Post ID that should be ignored. Default 0.
6146 6146
  */
6147 6147
 function wp_add_trashed_suffix_to_post_name_for_trashed_posts( $post_name, $post_ID = 0 ) {
6148 6148
 	$trashed_posts_with_desired_slug = get_posts( array(
Please login to merge, or discard this patch.
Spacing   +1265 added lines, -1265 removed lines patch added patch discarded remove patch
@@ -18,9 +18,9 @@  discard block
 block discarded – undo
18 18
  * @since 2.9.0
19 19
  */
20 20
 function create_initial_post_types() {
21
-	register_post_type( 'post', array(
21
+	register_post_type('post', array(
22 22
 		'labels' => array(
23
-			'name_admin_bar' => _x( 'Post', 'add new from admin bar' ),
23
+			'name_admin_bar' => _x('Post', 'add new from admin bar'),
24 24
 		),
25 25
 		'public'  => true,
26 26
 		'_builtin' => true, /* internal use only. don't use this when registering your own post type. */
@@ -32,15 +32,15 @@  discard block
 block discarded – undo
32 32
 		'rewrite' => false,
33 33
 		'query_var' => false,
34 34
 		'delete_with_user' => true,
35
-		'supports' => array( 'title', 'editor', 'author', 'thumbnail', 'excerpt', 'trackbacks', 'custom-fields', 'comments', 'revisions', 'post-formats' ),
35
+		'supports' => array('title', 'editor', 'author', 'thumbnail', 'excerpt', 'trackbacks', 'custom-fields', 'comments', 'revisions', 'post-formats'),
36 36
 		'show_in_rest' => true,
37 37
 		'rest_base' => 'posts',
38 38
 		'rest_controller_class' => 'WP_REST_Posts_Controller',
39
-	) );
39
+	));
40 40
 
41
-	register_post_type( 'page', array(
41
+	register_post_type('page', array(
42 42
 		'labels' => array(
43
-			'name_admin_bar' => _x( 'Page', 'add new from admin bar' ),
43
+			'name_admin_bar' => _x('Page', 'add new from admin bar'),
44 44
 		),
45 45
 		'public' => true,
46 46
 		'publicly_queryable' => false,
@@ -53,20 +53,20 @@  discard block
 block discarded – undo
53 53
 		'rewrite' => false,
54 54
 		'query_var' => false,
55 55
 		'delete_with_user' => true,
56
-		'supports' => array( 'title', 'editor', 'author', 'thumbnail', 'page-attributes', 'custom-fields', 'comments', 'revisions' ),
56
+		'supports' => array('title', 'editor', 'author', 'thumbnail', 'page-attributes', 'custom-fields', 'comments', 'revisions'),
57 57
 		'show_in_rest' => true,
58 58
 		'rest_base' => 'pages',
59 59
 		'rest_controller_class' => 'WP_REST_Posts_Controller',
60
-	) );
60
+	));
61 61
 
62
-	register_post_type( 'attachment', array(
62
+	register_post_type('attachment', array(
63 63
 		'labels' => array(
64 64
 			'name' => _x('Media', 'post type general name'),
65
-			'name_admin_bar' => _x( 'Media', 'add new from admin bar' ),
66
-			'add_new' => _x( 'Add New', 'add new media' ),
67
- 			'edit_item' => __( 'Edit Media' ),
68
- 			'view_item' => __( 'View Attachment Page' ),
69
-			'attributes' => __( 'Attachment Attributes' ),
65
+			'name_admin_bar' => _x('Media', 'add new from admin bar'),
66
+			'add_new' => _x('Add New', 'add new media'),
67
+ 			'edit_item' => __('Edit Media'),
68
+ 			'view_item' => __('View Attachment Page'),
69
+			'attributes' => __('Attachment Attributes'),
70 70
 		),
71 71
 		'public' => true,
72 72
 		'show_ui' => true,
@@ -82,18 +82,18 @@  discard block
 block discarded – undo
82 82
 		'query_var' => false,
83 83
 		'show_in_nav_menus' => false,
84 84
 		'delete_with_user' => true,
85
-		'supports' => array( 'title', 'author', 'comments' ),
85
+		'supports' => array('title', 'author', 'comments'),
86 86
 		'show_in_rest' => true,
87 87
 		'rest_base' => 'media',
88 88
 		'rest_controller_class' => 'WP_REST_Attachments_Controller',
89
-	) );
90
-	add_post_type_support( 'attachment:audio', 'thumbnail' );
91
-	add_post_type_support( 'attachment:video', 'thumbnail' );
89
+	));
90
+	add_post_type_support('attachment:audio', 'thumbnail');
91
+	add_post_type_support('attachment:video', 'thumbnail');
92 92
 
93
-	register_post_type( 'revision', array(
93
+	register_post_type('revision', array(
94 94
 		'labels' => array(
95
-			'name' => __( 'Revisions' ),
96
-			'singular_name' => __( 'Revision' ),
95
+			'name' => __('Revisions'),
96
+			'singular_name' => __('Revision'),
97 97
 		),
98 98
 		'public' => false,
99 99
 		'_builtin' => true, /* internal use only. don't use this when registering your own post type. */
@@ -105,13 +105,13 @@  discard block
 block discarded – undo
105 105
 		'query_var' => false,
106 106
 		'can_export' => false,
107 107
 		'delete_with_user' => true,
108
-		'supports' => array( 'author' ),
109
-	) );
108
+		'supports' => array('author'),
109
+	));
110 110
 
111
-	register_post_type( 'nav_menu_item', array(
111
+	register_post_type('nav_menu_item', array(
112 112
 		'labels' => array(
113
-			'name' => __( 'Navigation Menu Items' ),
114
-			'singular_name' => __( 'Navigation Menu Item' ),
113
+			'name' => __('Navigation Menu Items'),
114
+			'singular_name' => __('Navigation Menu Item'),
115 115
 		),
116 116
 		'public' => false,
117 117
 		'_builtin' => true, /* internal use only. don't use this when registering your own post type. */
@@ -119,12 +119,12 @@  discard block
 block discarded – undo
119 119
 		'rewrite' => false,
120 120
 		'delete_with_user' => false,
121 121
 		'query_var' => false,
122
-	) );
122
+	));
123 123
 
124
-	register_post_type( 'custom_css', array(
124
+	register_post_type('custom_css', array(
125 125
 		'labels' => array(
126
-			'name'          => __( 'Custom CSS' ),
127
-			'singular_name' => __( 'Custom CSS' ),
126
+			'name'          => __('Custom CSS'),
127
+			'singular_name' => __('Custom CSS'),
128 128
 		),
129 129
 		'public'           => false,
130 130
 		'hierarchical'     => false,
@@ -133,7 +133,7 @@  discard block
 block discarded – undo
133 133
 		'delete_with_user' => false,
134 134
 		'can_export'       => true,
135 135
 		'_builtin'         => true, /* internal use only. don't use this when registering your own post type. */
136
-		'supports'         => array( 'title', 'revisions' ),
136
+		'supports'         => array('title', 'revisions'),
137 137
 		'capabilities'     => array(
138 138
 			'delete_posts'           => 'edit_theme_options',
139 139
 			'delete_post'            => 'edit_theme_options',
@@ -148,23 +148,23 @@  discard block
 block discarded – undo
148 148
 			'read_private_posts'     => 'read',
149 149
 			'publish_posts'          => 'edit_theme_options',
150 150
 		),
151
-	) );
151
+	));
152 152
 
153
-	register_post_type( 'customize_changeset', array(
153
+	register_post_type('customize_changeset', array(
154 154
 		'labels' => array(
155
-			'name'               => _x( 'Changesets', 'post type general name' ),
156
-			'singular_name'      => _x( 'Changeset', 'post type singular name' ),
157
-			'menu_name'          => _x( 'Changesets', 'admin menu' ),
158
-			'name_admin_bar'     => _x( 'Changeset', 'add new on admin bar' ),
159
-			'add_new'            => _x( 'Add New', 'Customize Changeset' ),
160
-			'add_new_item'       => __( 'Add New Changeset' ),
161
-			'new_item'           => __( 'New Changeset' ),
162
-			'edit_item'          => __( 'Edit Changeset' ),
163
-			'view_item'          => __( 'View Changeset' ),
164
-			'all_items'          => __( 'All Changesets' ),
165
-			'search_items'       => __( 'Search Changesets' ),
166
-			'not_found'          => __( 'No changesets found.' ),
167
-			'not_found_in_trash' => __( 'No changesets found in Trash.' ),
155
+			'name'               => _x('Changesets', 'post type general name'),
156
+			'singular_name'      => _x('Changeset', 'post type singular name'),
157
+			'menu_name'          => _x('Changesets', 'admin menu'),
158
+			'name_admin_bar'     => _x('Changeset', 'add new on admin bar'),
159
+			'add_new'            => _x('Add New', 'Customize Changeset'),
160
+			'add_new_item'       => __('Add New Changeset'),
161
+			'new_item'           => __('New Changeset'),
162
+			'edit_item'          => __('Edit Changeset'),
163
+			'view_item'          => __('View Changeset'),
164
+			'all_items'          => __('All Changesets'),
165
+			'search_items'       => __('Search Changesets'),
166
+			'not_found'          => __('No changesets found.'),
167
+			'not_found_in_trash' => __('No changesets found in Trash.'),
168 168
 		),
169 169
 		'public' => false,
170 170
 		'_builtin' => true, /* internal use only. don't use this when registering your own post type. */
@@ -174,7 +174,7 @@  discard block
 block discarded – undo
174 174
 		'query_var' => false,
175 175
 		'can_export' => false,
176 176
 		'delete_with_user' => false,
177
-		'supports' => array( 'title', 'author' ),
177
+		'supports' => array('title', 'author'),
178 178
 		'capability_type' => 'customize_changeset',
179 179
 		'capabilities' => array(
180 180
 			'create_posts' => 'customize',
@@ -193,63 +193,63 @@  discard block
 block discarded – undo
193 193
 			'read_post' => 'customize',
194 194
 			'read_private_posts' => 'customize',
195 195
 		),
196
-	) );
196
+	));
197 197
 
198
-	register_post_status( 'publish', array(
199
-		'label'       => _x( 'Published', 'post status' ),
198
+	register_post_status('publish', array(
199
+		'label'       => _x('Published', 'post status'),
200 200
 		'public'      => true,
201 201
 		'_builtin'    => true, /* internal use only. */
202
-		'label_count' => _n_noop( 'Published <span class="count">(%s)</span>', 'Published <span class="count">(%s)</span>' ),
203
-	) );
202
+		'label_count' => _n_noop('Published <span class="count">(%s)</span>', 'Published <span class="count">(%s)</span>'),
203
+	));
204 204
 
205
-	register_post_status( 'future', array(
206
-		'label'       => _x( 'Scheduled', 'post status' ),
205
+	register_post_status('future', array(
206
+		'label'       => _x('Scheduled', 'post status'),
207 207
 		'protected'   => true,
208 208
 		'_builtin'    => true, /* internal use only. */
209
-		'label_count' => _n_noop('Scheduled <span class="count">(%s)</span>', 'Scheduled <span class="count">(%s)</span>' ),
210
-	) );
209
+		'label_count' => _n_noop('Scheduled <span class="count">(%s)</span>', 'Scheduled <span class="count">(%s)</span>'),
210
+	));
211 211
 
212
-	register_post_status( 'draft', array(
213
-		'label'       => _x( 'Draft', 'post status' ),
212
+	register_post_status('draft', array(
213
+		'label'       => _x('Draft', 'post status'),
214 214
 		'protected'   => true,
215 215
 		'_builtin'    => true, /* internal use only. */
216
-		'label_count' => _n_noop( 'Draft <span class="count">(%s)</span>', 'Drafts <span class="count">(%s)</span>' ),
217
-	) );
216
+		'label_count' => _n_noop('Draft <span class="count">(%s)</span>', 'Drafts <span class="count">(%s)</span>'),
217
+	));
218 218
 
219
-	register_post_status( 'pending', array(
220
-		'label'       => _x( 'Pending', 'post status' ),
219
+	register_post_status('pending', array(
220
+		'label'       => _x('Pending', 'post status'),
221 221
 		'protected'   => true,
222 222
 		'_builtin'    => true, /* internal use only. */
223
-		'label_count' => _n_noop( 'Pending <span class="count">(%s)</span>', 'Pending <span class="count">(%s)</span>' ),
224
-	) );
223
+		'label_count' => _n_noop('Pending <span class="count">(%s)</span>', 'Pending <span class="count">(%s)</span>'),
224
+	));
225 225
 
226
-	register_post_status( 'private', array(
227
-		'label'       => _x( 'Private', 'post status' ),
226
+	register_post_status('private', array(
227
+		'label'       => _x('Private', 'post status'),
228 228
 		'private'     => true,
229 229
 		'_builtin'    => true, /* internal use only. */
230
-		'label_count' => _n_noop( 'Private <span class="count">(%s)</span>', 'Private <span class="count">(%s)</span>' ),
231
-	) );
230
+		'label_count' => _n_noop('Private <span class="count">(%s)</span>', 'Private <span class="count">(%s)</span>'),
231
+	));
232 232
 
233
-	register_post_status( 'trash', array(
234
-		'label'       => _x( 'Trash', 'post status' ),
233
+	register_post_status('trash', array(
234
+		'label'       => _x('Trash', 'post status'),
235 235
 		'internal'    => true,
236 236
 		'_builtin'    => true, /* internal use only. */
237
-		'label_count' => _n_noop( 'Trash <span class="count">(%s)</span>', 'Trash <span class="count">(%s)</span>' ),
237
+		'label_count' => _n_noop('Trash <span class="count">(%s)</span>', 'Trash <span class="count">(%s)</span>'),
238 238
 		'show_in_admin_status_list' => true,
239
-	) );
239
+	));
240 240
 
241
-	register_post_status( 'auto-draft', array(
241
+	register_post_status('auto-draft', array(
242 242
 		'label'    => 'auto-draft',
243 243
 		'internal' => true,
244 244
 		'_builtin' => true, /* internal use only. */
245
-	) );
245
+	));
246 246
 
247
-	register_post_status( 'inherit', array(
247
+	register_post_status('inherit', array(
248 248
 		'label'    => 'inherit',
249 249
 		'internal' => true,
250 250
 		'_builtin' => true, /* internal use only. */
251 251
 		'exclude_from_search' => false,
252
-	) );
252
+	));
253 253
 }
254 254
 
255 255
 /**
@@ -270,15 +270,15 @@  discard block
 block discarded – undo
270 270
  * @param bool $unfiltered    Optional. Whether to apply filters. Default false.
271 271
  * @return string|false The file path to where the attached file should be, false otherwise.
272 272
  */
273
-function get_attached_file( $attachment_id, $unfiltered = false ) {
274
-	$file = get_post_meta( $attachment_id, '_wp_attached_file', true );
273
+function get_attached_file($attachment_id, $unfiltered = false) {
274
+	$file = get_post_meta($attachment_id, '_wp_attached_file', true);
275 275
 
276 276
 	// If the file is relative, prepend upload dir.
277
-	if ( $file && 0 !== strpos( $file, '/' ) && ! preg_match( '|^.:\\\|', $file ) && ( ( $uploads = wp_get_upload_dir() ) && false === $uploads['error'] ) ) {
278
-		$file = $uploads['basedir'] . "/$file";
277
+	if ($file && 0 !== strpos($file, '/') && ! preg_match('|^.:\\\|', $file) && (($uploads = wp_get_upload_dir()) && false === $uploads['error'])) {
278
+		$file = $uploads['basedir']."/$file";
279 279
 	}
280 280
 
281
-	if ( $unfiltered ) {
281
+	if ($unfiltered) {
282 282
 		return $file;
283 283
 	}
284 284
 
@@ -290,7 +290,7 @@  discard block
 block discarded – undo
290 290
 	 * @param string $file          Path to attached file.
291 291
 	 * @param int    $attachment_id Attachment ID.
292 292
 	 */
293
-	return apply_filters( 'get_attached_file', $file, $attachment_id );
293
+	return apply_filters('get_attached_file', $file, $attachment_id);
294 294
 }
295 295
 
296 296
 /**
@@ -305,8 +305,8 @@  discard block
 block discarded – undo
305 305
  * @param string $file          File path for the attachment.
306 306
  * @return bool True on success, false on failure.
307 307
  */
308
-function update_attached_file( $attachment_id, $file ) {
309
-	if ( !get_post( $attachment_id ) )
308
+function update_attached_file($attachment_id, $file) {
309
+	if ( ! get_post($attachment_id))
310 310
 		return false;
311 311
 
312 312
 	/**
@@ -317,12 +317,12 @@  discard block
 block discarded – undo
317 317
 	 * @param string $file          Path to the attached file to update.
318 318
 	 * @param int    $attachment_id Attachment ID.
319 319
 	 */
320
-	$file = apply_filters( 'update_attached_file', $file, $attachment_id );
320
+	$file = apply_filters('update_attached_file', $file, $attachment_id);
321 321
 
322
-	if ( $file = _wp_relative_upload_path( $file ) )
323
-		return update_post_meta( $attachment_id, '_wp_attached_file', $file );
322
+	if ($file = _wp_relative_upload_path($file))
323
+		return update_post_meta($attachment_id, '_wp_attached_file', $file);
324 324
 	else
325
-		return delete_post_meta( $attachment_id, '_wp_attached_file' );
325
+		return delete_post_meta($attachment_id, '_wp_attached_file');
326 326
 }
327 327
 
328 328
 /**
@@ -335,13 +335,13 @@  discard block
 block discarded – undo
335 335
  * @param string $path Full path to the file.
336 336
  * @return string Relative path on success, unchanged path on failure.
337 337
  */
338
-function _wp_relative_upload_path( $path ) {
338
+function _wp_relative_upload_path($path) {
339 339
 	$new_path = $path;
340 340
 
341 341
 	$uploads = wp_get_upload_dir();
342
-	if ( 0 === strpos( $new_path, $uploads['basedir'] ) ) {
343
-			$new_path = str_replace( $uploads['basedir'], '', $new_path );
344
-			$new_path = ltrim( $new_path, '/' );
342
+	if (0 === strpos($new_path, $uploads['basedir'])) {
343
+			$new_path = str_replace($uploads['basedir'], '', $new_path);
344
+			$new_path = ltrim($new_path, '/');
345 345
 	}
346 346
 
347 347
 	/**
@@ -352,7 +352,7 @@  discard block
 block discarded – undo
352 352
 	 * @param string $new_path Relative path to the file.
353 353
 	 * @param string $path     Full path to the file.
354 354
 	 */
355
-	return apply_filters( '_wp_relative_upload_path', $new_path, $path );
355
+	return apply_filters('_wp_relative_upload_path', $new_path, $path);
356 356
 }
357 357
 
358 358
 /**
@@ -406,17 +406,17 @@  discard block
 block discarded – undo
406 406
  * @return array Array of children, where the type of each element is determined by $output parameter.
407 407
  *               Empty array on failure.
408 408
  */
409
-function get_children( $args = '', $output = OBJECT ) {
409
+function get_children($args = '', $output = OBJECT) {
410 410
 	$kids = array();
411
-	if ( empty( $args ) ) {
412
-		if ( isset( $GLOBALS['post'] ) ) {
413
-			$args = array('post_parent' => (int) $GLOBALS['post']->post_parent );
411
+	if (empty($args)) {
412
+		if (isset($GLOBALS['post'])) {
413
+			$args = array('post_parent' => (int) $GLOBALS['post']->post_parent);
414 414
 		} else {
415 415
 			return $kids;
416 416
 		}
417
-	} elseif ( is_object( $args ) ) {
418
-		$args = array('post_parent' => (int) $args->post_parent );
419
-	} elseif ( is_numeric( $args ) ) {
417
+	} elseif (is_object($args)) {
418
+		$args = array('post_parent' => (int) $args->post_parent);
419
+	} elseif (is_numeric($args)) {
420 420
 		$args = array('post_parent' => (int) $args);
421 421
 	}
422 422
 
@@ -425,32 +425,32 @@  discard block
 block discarded – undo
425 425
 		'post_status' => 'any', 'post_parent' => 0,
426 426
 	);
427 427
 
428
-	$r = wp_parse_args( $args, $defaults );
428
+	$r = wp_parse_args($args, $defaults);
429 429
 
430
-	$children = get_posts( $r );
430
+	$children = get_posts($r);
431 431
 
432
-	if ( ! $children )
432
+	if ( ! $children)
433 433
 		return $kids;
434 434
 
435
-	if ( ! empty( $r['fields'] ) )
435
+	if ( ! empty($r['fields']))
436 436
 		return $children;
437 437
 
438 438
 	update_post_cache($children);
439 439
 
440
-	foreach ( $children as $key => $child )
440
+	foreach ($children as $key => $child)
441 441
 		$kids[$child->ID] = $children[$key];
442 442
 
443
-	if ( $output == OBJECT ) {
443
+	if ($output == OBJECT) {
444 444
 		return $kids;
445
-	} elseif ( $output == ARRAY_A ) {
445
+	} elseif ($output == ARRAY_A) {
446 446
 		$weeuns = array();
447
-		foreach ( (array) $kids as $kid ) {
447
+		foreach ((array) $kids as $kid) {
448 448
 			$weeuns[$kid->ID] = get_object_vars($kids[$kid->ID]);
449 449
 		}
450 450
 		return $weeuns;
451
-	} elseif ( $output == ARRAY_N ) {
451
+	} elseif ($output == ARRAY_N) {
452 452
 		$babes = array();
453
-		foreach ( (array) $kids as $kid ) {
453
+		foreach ((array) $kids as $kid) {
454 454
 			$babes[$kid->ID] = array_values(get_object_vars($kids[$kid->ID]));
455 455
 		}
456 456
 		return $babes;
@@ -475,9 +475,9 @@  discard block
 block discarded – undo
475 475
  * @param string $post Post content.
476 476
  * @return array Post before ('main'), after ('extended'), and custom read more ('more_text').
477 477
  */
478
-function get_extended( $post ) {
478
+function get_extended($post) {
479 479
 	//Match the new style more links.
480
-	if ( preg_match('/<!--more(.*?)?-->/', $post, $matches) ) {
480
+	if (preg_match('/<!--more(.*?)?-->/', $post, $matches)) {
481 481
 		list($main, $extended) = explode($matches[0], $post, 2);
482 482
 		$more_text = $matches[1];
483 483
 	} else {
@@ -491,7 +491,7 @@  discard block
 block discarded – undo
491 491
 	$extended = preg_replace('/^[\s]*(.*)[\s]*$/', '\\1', $extended);
492 492
 	$more_text = preg_replace('/^[\s]*(.*)[\s]*$/', '\\1', $more_text);
493 493
 
494
-	return array( 'main' => $main, 'extended' => $extended, 'more_text' => $more_text );
494
+	return array('main' => $main, 'extended' => $extended, 'more_text' => $more_text);
495 495
 }
496 496
 
497 497
 /**
@@ -512,34 +512,34 @@  discard block
 block discarded – undo
512 512
  * @return WP_Post|array|null Type corresponding to $output on success or null on failure.
513 513
  *                            When $output is OBJECT, a `WP_Post` instance is returned.
514 514
  */
515
-function get_post( $post = null, $output = OBJECT, $filter = 'raw' ) {
516
-	if ( empty( $post ) && isset( $GLOBALS['post'] ) )
515
+function get_post($post = null, $output = OBJECT, $filter = 'raw') {
516
+	if (empty($post) && isset($GLOBALS['post']))
517 517
 		$post = $GLOBALS['post'];
518 518
 
519
-	if ( $post instanceof WP_Post ) {
519
+	if ($post instanceof WP_Post) {
520 520
 		$_post = $post;
521
-	} elseif ( is_object( $post ) ) {
522
-		if ( empty( $post->filter ) ) {
523
-			$_post = sanitize_post( $post, 'raw' );
524
-			$_post = new WP_Post( $_post );
525
-		} elseif ( 'raw' == $post->filter ) {
526
-			$_post = new WP_Post( $post );
521
+	} elseif (is_object($post)) {
522
+		if (empty($post->filter)) {
523
+			$_post = sanitize_post($post, 'raw');
524
+			$_post = new WP_Post($_post);
525
+		} elseif ('raw' == $post->filter) {
526
+			$_post = new WP_Post($post);
527 527
 		} else {
528
-			$_post = WP_Post::get_instance( $post->ID );
528
+			$_post = WP_Post::get_instance($post->ID);
529 529
 		}
530 530
 	} else {
531
-		$_post = WP_Post::get_instance( $post );
531
+		$_post = WP_Post::get_instance($post);
532 532
 	}
533 533
 
534
-	if ( ! $_post )
534
+	if ( ! $_post)
535 535
 		return null;
536 536
 
537
-	$_post = $_post->filter( $filter );
537
+	$_post = $_post->filter($filter);
538 538
 
539
-	if ( $output == ARRAY_A )
539
+	if ($output == ARRAY_A)
540 540
 		return $_post->to_array();
541
-	elseif ( $output == ARRAY_N )
542
-		return array_values( $_post->to_array() );
541
+	elseif ($output == ARRAY_N)
542
+		return array_values($_post->to_array());
543 543
 
544 544
 	return $_post;
545 545
 }
@@ -552,19 +552,19 @@  discard block
 block discarded – undo
552 552
  * @param int|WP_Post $post Post ID or post object.
553 553
  * @return array Ancestor IDs or empty array if none are found.
554 554
  */
555
-function get_post_ancestors( $post ) {
556
-	$post = get_post( $post );
555
+function get_post_ancestors($post) {
556
+	$post = get_post($post);
557 557
 
558
-	if ( ! $post || empty( $post->post_parent ) || $post->post_parent == $post->ID )
558
+	if ( ! $post || empty($post->post_parent) || $post->post_parent == $post->ID)
559 559
 		return array();
560 560
 
561 561
 	$ancestors = array();
562 562
 
563 563
 	$id = $ancestors[] = $post->post_parent;
564 564
 
565
-	while ( $ancestor = get_post( $id ) ) {
565
+	while ($ancestor = get_post($id)) {
566 566
 		// Loop detection: If the ancestor has been seen before, break.
567
-		if ( empty( $ancestor->post_parent ) || ( $ancestor->post_parent == $post->ID ) || in_array( $ancestor->post_parent, $ancestors ) )
567
+		if (empty($ancestor->post_parent) || ($ancestor->post_parent == $post->ID) || in_array($ancestor->post_parent, $ancestors))
568 568
 			break;
569 569
 
570 570
 		$id = $ancestors[] = $ancestor->post_parent;
@@ -593,13 +593,13 @@  discard block
 block discarded – undo
593 593
  *                             or 'display'. Default 'display'.
594 594
  * @return string The value of the post field on success, empty string on failure.
595 595
  */
596
-function get_post_field( $field, $post = null, $context = 'display' ) {
597
-	$post = get_post( $post );
596
+function get_post_field($field, $post = null, $context = 'display') {
597
+	$post = get_post($post);
598 598
 
599
-	if ( !$post )
599
+	if ( ! $post)
600 600
 		return '';
601 601
 
602
-	if ( !isset($post->$field) )
602
+	if ( ! isset($post->$field))
603 603
 		return '';
604 604
 
605 605
 	return sanitize_post_field($field, $post->$field, $post->ID, $context);
@@ -616,10 +616,10 @@  discard block
 block discarded – undo
616 616
  * @param int|WP_Post $ID Optional. Post ID or post object. Default empty.
617 617
  * @return string|false The mime type on success, false on failure.
618 618
  */
619
-function get_post_mime_type( $ID = '' ) {
619
+function get_post_mime_type($ID = '') {
620 620
 	$post = get_post($ID);
621 621
 
622
-	if ( is_object($post) )
622
+	if (is_object($post))
623 623
 		return $post->post_mime_type;
624 624
 
625 625
 	return false;
@@ -636,25 +636,25 @@  discard block
 block discarded – undo
636 636
  * @param int|WP_Post $ID Optional. Post ID or post object. Default empty.
637 637
  * @return string|false Post status on success, false on failure.
638 638
  */
639
-function get_post_status( $ID = '' ) {
639
+function get_post_status($ID = '') {
640 640
 	$post = get_post($ID);
641 641
 
642
-	if ( !is_object($post) )
642
+	if ( ! is_object($post))
643 643
 		return false;
644 644
 
645
-	if ( 'attachment' == $post->post_type ) {
646
-		if ( 'private' == $post->post_status )
645
+	if ('attachment' == $post->post_type) {
646
+		if ('private' == $post->post_status)
647 647
 			return 'private';
648 648
 
649 649
 		// Unattached attachments are assumed to be published.
650
-		if ( ( 'inherit' == $post->post_status ) && ( 0 == $post->post_parent) )
650
+		if (('inherit' == $post->post_status) && (0 == $post->post_parent))
651 651
 			return 'publish';
652 652
 
653 653
 		// Inherit status from the parent.
654
-		if ( $post->post_parent && ( $post->ID != $post->post_parent ) ) {
655
-			$parent_post_status = get_post_status( $post->post_parent );
656
-			if ( 'trash' == $parent_post_status ) {
657
-				return get_post_meta( $post->post_parent, '_wp_trash_meta_status', true );
654
+		if ($post->post_parent && ($post->ID != $post->post_parent)) {
655
+			$parent_post_status = get_post_status($post->post_parent);
656
+			if ('trash' == $parent_post_status) {
657
+				return get_post_meta($post->post_parent, '_wp_trash_meta_status', true);
658 658
 			} else {
659 659
 				return $parent_post_status;
660 660
 			}
@@ -670,7 +670,7 @@  discard block
 block discarded – undo
670 670
 	 * @param string  $post_status The post status.
671 671
 	 * @param WP_Post $post        The post object.
672 672
 	 */
673
-	return apply_filters( 'get_post_status', $post->post_status, $post );
673
+	return apply_filters('get_post_status', $post->post_status, $post);
674 674
 }
675 675
 
676 676
 /**
@@ -685,10 +685,10 @@  discard block
 block discarded – undo
685 685
  */
686 686
 function get_post_statuses() {
687 687
 	$status = array(
688
-		'draft'   => __( 'Draft' ),
689
-		'pending' => __( 'Pending Review' ),
690
-		'private' => __( 'Private' ),
691
-		'publish' => __( 'Published' )
688
+		'draft'   => __('Draft'),
689
+		'pending' => __('Pending Review'),
690
+		'private' => __('Private'),
691
+		'publish' => __('Published')
692 692
 	);
693 693
 
694 694
 	return $status;
@@ -706,9 +706,9 @@  discard block
 block discarded – undo
706 706
  */
707 707
 function get_page_statuses() {
708 708
 	$status = array(
709
-		'draft'   => __( 'Draft' ),
710
-		'private' => __( 'Private' ),
711
-		'publish' => __( 'Published' )
709
+		'draft'   => __('Draft'),
710
+		'private' => __('Private'),
711
+		'publish' => __('Published')
712 712
 	);
713 713
 
714 714
 	return $status;
@@ -757,10 +757,10 @@  discard block
 block discarded – undo
757 757
  * }
758 758
  * @return object
759 759
  */
760
-function register_post_status( $post_status, $args = array() ) {
760
+function register_post_status($post_status, $args = array()) {
761 761
 	global $wp_post_statuses;
762 762
 
763
-	if (!is_array($wp_post_statuses))
763
+	if ( ! is_array($wp_post_statuses))
764 764
 		$wp_post_statuses = array();
765 765
 
766 766
 	// Args prefixed with an underscore are reserved for internal use.
@@ -784,38 +784,38 @@  discard block
 block discarded – undo
784 784
 	$args->name = $post_status;
785 785
 
786 786
 	// Set various defaults.
787
-	if ( null === $args->public && null === $args->internal && null === $args->protected && null === $args->private )
787
+	if (null === $args->public && null === $args->internal && null === $args->protected && null === $args->private)
788 788
 		$args->internal = true;
789 789
 
790
-	if ( null === $args->public  )
790
+	if (null === $args->public)
791 791
 		$args->public = false;
792 792
 
793
-	if ( null === $args->private  )
793
+	if (null === $args->private)
794 794
 		$args->private = false;
795 795
 
796
-	if ( null === $args->protected  )
796
+	if (null === $args->protected)
797 797
 		$args->protected = false;
798 798
 
799
-	if ( null === $args->internal  )
799
+	if (null === $args->internal)
800 800
 		$args->internal = false;
801 801
 
802
-	if ( null === $args->publicly_queryable )
802
+	if (null === $args->publicly_queryable)
803 803
 		$args->publicly_queryable = $args->public;
804 804
 
805
-	if ( null === $args->exclude_from_search )
805
+	if (null === $args->exclude_from_search)
806 806
 		$args->exclude_from_search = $args->internal;
807 807
 
808
-	if ( null === $args->show_in_admin_all_list )
809
-		$args->show_in_admin_all_list = !$args->internal;
808
+	if (null === $args->show_in_admin_all_list)
809
+		$args->show_in_admin_all_list = ! $args->internal;
810 810
 
811
-	if ( null === $args->show_in_admin_status_list )
812
-		$args->show_in_admin_status_list = !$args->internal;
811
+	if (null === $args->show_in_admin_status_list)
812
+		$args->show_in_admin_status_list = ! $args->internal;
813 813
 
814
-	if ( false === $args->label )
814
+	if (false === $args->label)
815 815
 		$args->label = $post_status;
816 816
 
817
-	if ( false === $args->label_count )
818
-		$args->label_count = _n_noop( $args->label, $args->label );
817
+	if (false === $args->label_count)
818
+		$args->label_count = _n_noop($args->label, $args->label);
819 819
 
820 820
 	$wp_post_statuses[$post_status] = $args;
821 821
 
@@ -834,10 +834,10 @@  discard block
 block discarded – undo
834 834
  * @param string $post_status The name of a registered post status.
835 835
  * @return object|null A post status object.
836 836
  */
837
-function get_post_status_object( $post_status ) {
837
+function get_post_status_object($post_status) {
838 838
 	global $wp_post_statuses;
839 839
 
840
-	if ( empty($wp_post_statuses[$post_status]) )
840
+	if (empty($wp_post_statuses[$post_status]))
841 841
 		return null;
842 842
 
843 843
 	return $wp_post_statuses[$post_status];
@@ -860,7 +860,7 @@  discard block
 block discarded – undo
860 860
  *                               Default 'and'.
861 861
  * @return array A list of post status names or objects.
862 862
  */
863
-function get_post_stati( $args = array(), $output = 'names', $operator = 'and' ) {
863
+function get_post_stati($args = array(), $output = 'names', $operator = 'and') {
864 864
 	global $wp_post_statuses;
865 865
 
866 866
 	$field = ('names' == $output) ? 'name' : false;
@@ -880,11 +880,11 @@  discard block
 block discarded – undo
880 880
  * @param string $post_type Post type name
881 881
  * @return bool Whether post type is hierarchical.
882 882
  */
883
-function is_post_type_hierarchical( $post_type ) {
884
-	if ( ! post_type_exists( $post_type ) )
883
+function is_post_type_hierarchical($post_type) {
884
+	if ( ! post_type_exists($post_type))
885 885
 		return false;
886 886
 
887
-	$post_type = get_post_type_object( $post_type );
887
+	$post_type = get_post_type_object($post_type);
888 888
 	return $post_type->hierarchical;
889 889
 }
890 890
 
@@ -898,8 +898,8 @@  discard block
 block discarded – undo
898 898
  * @param string $post_type Post type name.
899 899
  * @return bool Whether post type is registered.
900 900
  */
901
-function post_type_exists( $post_type ) {
902
-	return (bool) get_post_type_object( $post_type );
901
+function post_type_exists($post_type) {
902
+	return (bool) get_post_type_object($post_type);
903 903
 }
904 904
 
905 905
 /**
@@ -910,8 +910,8 @@  discard block
 block discarded – undo
910 910
  * @param int|WP_Post|null $post Optional. Post ID or post object. Default is global $post.
911 911
  * @return string|false          Post type on success, false on failure.
912 912
  */
913
-function get_post_type( $post = null ) {
914
-	if ( $post = get_post( $post ) )
913
+function get_post_type($post = null) {
914
+	if ($post = get_post($post))
915 915
 		return $post->post_type;
916 916
 
917 917
 	return false;
@@ -930,14 +930,14 @@  discard block
 block discarded – undo
930 930
  * @param string $post_type The name of a registered post type.
931 931
  * @return WP_Post_Type|null WP_Post_Type object if it exists, null otherwise.
932 932
  */
933
-function get_post_type_object( $post_type ) {
933
+function get_post_type_object($post_type) {
934 934
 	global $wp_post_types;
935 935
 
936
-	if ( ! is_scalar( $post_type ) || empty( $wp_post_types[ $post_type ] ) ) {
936
+	if ( ! is_scalar($post_type) || empty($wp_post_types[$post_type])) {
937 937
 		return null;
938 938
 	}
939 939
 
940
-	return $wp_post_types[ $post_type ];
940
+	return $wp_post_types[$post_type];
941 941
 }
942 942
 
943 943
 /**
@@ -958,7 +958,7 @@  discard block
 block discarded – undo
958 958
  *                               must match; 'not' means no elements may match. Default 'and'.
959 959
  * @return array A list of post type names or objects.
960 960
  */
961
-function get_post_types( $args = array(), $output = 'names', $operator = 'and' ) {
961
+function get_post_types($args = array(), $output = 'names', $operator = 'and') {
962 962
 	global $wp_post_types;
963 963
 
964 964
 	$field = ('names' == $output) ? 'name' : false;
@@ -1102,27 +1102,27 @@  discard block
 block discarded – undo
1102 1102
  * }
1103 1103
  * @return WP_Post_Type|WP_Error The registered post type object, or an error object.
1104 1104
  */
1105
-function register_post_type( $post_type, $args = array() ) {
1105
+function register_post_type($post_type, $args = array()) {
1106 1106
 	global $wp_post_types;
1107 1107
 
1108
-	if ( ! is_array( $wp_post_types ) ) {
1108
+	if ( ! is_array($wp_post_types)) {
1109 1109
 		$wp_post_types = array();
1110 1110
 	}
1111 1111
 
1112 1112
 	// Sanitize post type name
1113
-	$post_type = sanitize_key( $post_type );
1113
+	$post_type = sanitize_key($post_type);
1114 1114
 
1115
-	if ( empty( $post_type ) || strlen( $post_type ) > 20 ) {
1116
-		_doing_it_wrong( __FUNCTION__, __( 'Post type names must be between 1 and 20 characters in length.' ), '4.2.0' );
1117
-		return new WP_Error( 'post_type_length_invalid', __( 'Post type names must be between 1 and 20 characters in length.' ) );
1115
+	if (empty($post_type) || strlen($post_type) > 20) {
1116
+		_doing_it_wrong(__FUNCTION__, __('Post type names must be between 1 and 20 characters in length.'), '4.2.0');
1117
+		return new WP_Error('post_type_length_invalid', __('Post type names must be between 1 and 20 characters in length.'));
1118 1118
 	}
1119 1119
 
1120
-	$post_type_object = new WP_Post_Type( $post_type, $args );
1120
+	$post_type_object = new WP_Post_Type($post_type, $args);
1121 1121
 	$post_type_object->add_supports();
1122 1122
 	$post_type_object->add_rewrite_rules();
1123 1123
 	$post_type_object->register_meta_boxes();
1124 1124
 
1125
-	$wp_post_types[ $post_type ] = $post_type_object;
1125
+	$wp_post_types[$post_type] = $post_type_object;
1126 1126
 
1127 1127
 	$post_type_object->add_hooks();
1128 1128
 	$post_type_object->register_taxonomies();
@@ -1136,7 +1136,7 @@  discard block
 block discarded – undo
1136 1136
 	 * @param string       $post_type        Post type.
1137 1137
 	 * @param WP_Post_Type $post_type_object Arguments used to register the post type.
1138 1138
 	 */
1139
-	do_action( 'registered_post_type', $post_type, $post_type_object );
1139
+	do_action('registered_post_type', $post_type, $post_type_object);
1140 1140
 
1141 1141
 	return $post_type_object;
1142 1142
 }
@@ -1153,18 +1153,18 @@  discard block
 block discarded – undo
1153 1153
  * @param string $post_type Post type to unregister.
1154 1154
  * @return bool|WP_Error True on success, WP_Error on failure or if the post type doesn't exist.
1155 1155
  */
1156
-function unregister_post_type( $post_type ) {
1156
+function unregister_post_type($post_type) {
1157 1157
 	global $wp_post_types;
1158 1158
 
1159
-	if ( ! post_type_exists( $post_type ) ) {
1160
-		return new WP_Error( 'invalid_post_type', __( 'Invalid post type.' ) );
1159
+	if ( ! post_type_exists($post_type)) {
1160
+		return new WP_Error('invalid_post_type', __('Invalid post type.'));
1161 1161
 	}
1162 1162
 
1163
-	$post_type_object = get_post_type_object( $post_type );
1163
+	$post_type_object = get_post_type_object($post_type);
1164 1164
 
1165 1165
 	// Do not allow unregistering internal post types.
1166
-	if ( $post_type_object->_builtin ) {
1167
-		return new WP_Error( 'invalid_post_type', __( 'Unregistering a built-in post type is not allowed' ) );
1166
+	if ($post_type_object->_builtin) {
1167
+		return new WP_Error('invalid_post_type', __('Unregistering a built-in post type is not allowed'));
1168 1168
 	}
1169 1169
 
1170 1170
 	$post_type_object->remove_supports();
@@ -1173,7 +1173,7 @@  discard block
 block discarded – undo
1173 1173
 	$post_type_object->remove_hooks();
1174 1174
 	$post_type_object->unregister_taxonomies();
1175 1175
 
1176
-	unset( $wp_post_types[ $post_type ] );
1176
+	unset($wp_post_types[$post_type]);
1177 1177
 
1178 1178
 	/**
1179 1179
 	 * Fires after a post type was unregistered.
@@ -1182,7 +1182,7 @@  discard block
 block discarded – undo
1182 1182
 	 *
1183 1183
 	 * @param string $post_type Post type key.
1184 1184
 	 */
1185
-	do_action( 'unregistered_post_type', $post_type );
1185
+	do_action('unregistered_post_type', $post_type);
1186 1186
 
1187 1187
 	return true;
1188 1188
 }
@@ -1242,48 +1242,48 @@  discard block
 block discarded – undo
1242 1242
  * @param object $args Post type registration arguments.
1243 1243
  * @return object object with all the capabilities as member variables.
1244 1244
  */
1245
-function get_post_type_capabilities( $args ) {
1246
-	if ( ! is_array( $args->capability_type ) )
1247
-		$args->capability_type = array( $args->capability_type, $args->capability_type . 's' );
1245
+function get_post_type_capabilities($args) {
1246
+	if ( ! is_array($args->capability_type))
1247
+		$args->capability_type = array($args->capability_type, $args->capability_type.'s');
1248 1248
 
1249 1249
 	// Singular base for meta capabilities, plural base for primitive capabilities.
1250
-	list( $singular_base, $plural_base ) = $args->capability_type;
1250
+	list($singular_base, $plural_base) = $args->capability_type;
1251 1251
 
1252 1252
 	$default_capabilities = array(
1253 1253
 		// Meta capabilities
1254
-		'edit_post'          => 'edit_'         . $singular_base,
1255
-		'read_post'          => 'read_'         . $singular_base,
1256
-		'delete_post'        => 'delete_'       . $singular_base,
1254
+		'edit_post'          => 'edit_'.$singular_base,
1255
+		'read_post'          => 'read_'.$singular_base,
1256
+		'delete_post'        => 'delete_'.$singular_base,
1257 1257
 		// Primitive capabilities used outside of map_meta_cap():
1258
-		'edit_posts'         => 'edit_'         . $plural_base,
1259
-		'edit_others_posts'  => 'edit_others_'  . $plural_base,
1260
-		'publish_posts'      => 'publish_'      . $plural_base,
1261
-		'read_private_posts' => 'read_private_' . $plural_base,
1258
+		'edit_posts'         => 'edit_'.$plural_base,
1259
+		'edit_others_posts'  => 'edit_others_'.$plural_base,
1260
+		'publish_posts'      => 'publish_'.$plural_base,
1261
+		'read_private_posts' => 'read_private_'.$plural_base,
1262 1262
 	);
1263 1263
 
1264 1264
 	// Primitive capabilities used within map_meta_cap():
1265
-	if ( $args->map_meta_cap ) {
1265
+	if ($args->map_meta_cap) {
1266 1266
 		$default_capabilities_for_mapping = array(
1267 1267
 			'read'                   => 'read',
1268
-			'delete_posts'           => 'delete_'           . $plural_base,
1269
-			'delete_private_posts'   => 'delete_private_'   . $plural_base,
1270
-			'delete_published_posts' => 'delete_published_' . $plural_base,
1271
-			'delete_others_posts'    => 'delete_others_'    . $plural_base,
1272
-			'edit_private_posts'     => 'edit_private_'     . $plural_base,
1273
-			'edit_published_posts'   => 'edit_published_'   . $plural_base,
1268
+			'delete_posts'           => 'delete_'.$plural_base,
1269
+			'delete_private_posts'   => 'delete_private_'.$plural_base,
1270
+			'delete_published_posts' => 'delete_published_'.$plural_base,
1271
+			'delete_others_posts'    => 'delete_others_'.$plural_base,
1272
+			'edit_private_posts'     => 'edit_private_'.$plural_base,
1273
+			'edit_published_posts'   => 'edit_published_'.$plural_base,
1274 1274
 		);
1275
-		$default_capabilities = array_merge( $default_capabilities, $default_capabilities_for_mapping );
1275
+		$default_capabilities = array_merge($default_capabilities, $default_capabilities_for_mapping);
1276 1276
 	}
1277 1277
 
1278
-	$capabilities = array_merge( $default_capabilities, $args->capabilities );
1278
+	$capabilities = array_merge($default_capabilities, $args->capabilities);
1279 1279
 
1280 1280
 	// Post creation capability simply maps to edit_posts by default:
1281
-	if ( ! isset( $capabilities['create_posts'] ) )
1281
+	if ( ! isset($capabilities['create_posts']))
1282 1282
 		$capabilities['create_posts'] = $capabilities['edit_posts'];
1283 1283
 
1284 1284
 	// Remember meta capabilities for future reference.
1285
-	if ( $args->map_meta_cap )
1286
-		_post_type_meta_capabilities( $capabilities );
1285
+	if ($args->map_meta_cap)
1286
+		_post_type_meta_capabilities($capabilities);
1287 1287
 
1288 1288
 	return (object) $capabilities;
1289 1289
 }
@@ -1298,12 +1298,12 @@  discard block
 block discarded – undo
1298 1298
  *
1299 1299
  * @param array $capabilities Post type meta capabilities.
1300 1300
  */
1301
-function _post_type_meta_capabilities( $capabilities = null ) {
1301
+function _post_type_meta_capabilities($capabilities = null) {
1302 1302
 	global $post_type_meta_caps;
1303 1303
 
1304
-	foreach ( $capabilities as $core => $custom ) {
1305
-		if ( in_array( $core, array( 'read_post', 'delete_post', 'edit_post' ) ) ) {
1306
-			$post_type_meta_caps[ $custom ] = $core;
1304
+	foreach ($capabilities as $core => $custom) {
1305
+		if (in_array($core, array('read_post', 'delete_post', 'edit_post'))) {
1306
+			$post_type_meta_caps[$custom] = $core;
1307 1307
 		}
1308 1308
 	}
1309 1309
 }
@@ -1365,36 +1365,36 @@  discard block
 block discarded – undo
1365 1365
  * @param object|WP_Post_Type $post_type_object Post type object.
1366 1366
  * @return object Object with all the labels as member variables.
1367 1367
  */
1368
-function get_post_type_labels( $post_type_object ) {
1368
+function get_post_type_labels($post_type_object) {
1369 1369
 	$nohier_vs_hier_defaults = array(
1370
-		'name' => array( _x('Posts', 'post type general name'), _x('Pages', 'post type general name') ),
1371
-		'singular_name' => array( _x('Post', 'post type singular name'), _x('Page', 'post type singular name') ),
1372
-		'add_new' => array( _x('Add New', 'post'), _x('Add New', 'page') ),
1373
-		'add_new_item' => array( __('Add New Post'), __('Add New Page') ),
1374
-		'edit_item' => array( __('Edit Post'), __('Edit Page') ),
1375
-		'new_item' => array( __('New Post'), __('New Page') ),
1376
-		'view_item' => array( __('View Post'), __('View Page') ),
1377
-		'view_items' => array( __('View Posts'), __('View Pages') ),
1378
-		'search_items' => array( __('Search Posts'), __('Search Pages') ),
1379
-		'not_found' => array( __('No posts found.'), __('No pages found.') ),
1380
-		'not_found_in_trash' => array( __('No posts found in Trash.'), __('No pages found in Trash.') ),
1381
-		'parent_item_colon' => array( null, __('Parent Page:') ),
1382
-		'all_items' => array( __( 'All Posts' ), __( 'All Pages' ) ),
1383
-		'archives' => array( __( 'Post Archives' ), __( 'Page Archives' ) ),
1384
-		'attributes' => array( __( 'Post Attributes' ), __( 'Page Attributes' ) ),
1385
-		'insert_into_item' => array( __( 'Insert into post' ), __( 'Insert into page' ) ),
1386
-		'uploaded_to_this_item' => array( __( 'Uploaded to this post' ), __( 'Uploaded to this page' ) ),
1387
-		'featured_image' => array( _x( 'Featured Image', 'post' ), _x( 'Featured Image', 'page' ) ),
1388
-		'set_featured_image' => array( _x( 'Set featured image', 'post' ), _x( 'Set featured image', 'page' ) ),
1389
-		'remove_featured_image' => array( _x( 'Remove featured image', 'post' ), _x( 'Remove featured image', 'page' ) ),
1390
-		'use_featured_image' => array( _x( 'Use as featured image', 'post' ), _x( 'Use as featured image', 'page' ) ),
1391
-		'filter_items_list' => array( __( 'Filter posts list' ), __( 'Filter pages list' ) ),
1392
-		'items_list_navigation' => array( __( 'Posts list navigation' ), __( 'Pages list navigation' ) ),
1393
-		'items_list' => array( __( 'Posts list' ), __( 'Pages list' ) ),
1370
+		'name' => array(_x('Posts', 'post type general name'), _x('Pages', 'post type general name')),
1371
+		'singular_name' => array(_x('Post', 'post type singular name'), _x('Page', 'post type singular name')),
1372
+		'add_new' => array(_x('Add New', 'post'), _x('Add New', 'page')),
1373
+		'add_new_item' => array(__('Add New Post'), __('Add New Page')),
1374
+		'edit_item' => array(__('Edit Post'), __('Edit Page')),
1375
+		'new_item' => array(__('New Post'), __('New Page')),
1376
+		'view_item' => array(__('View Post'), __('View Page')),
1377
+		'view_items' => array(__('View Posts'), __('View Pages')),
1378
+		'search_items' => array(__('Search Posts'), __('Search Pages')),
1379
+		'not_found' => array(__('No posts found.'), __('No pages found.')),
1380
+		'not_found_in_trash' => array(__('No posts found in Trash.'), __('No pages found in Trash.')),
1381
+		'parent_item_colon' => array(null, __('Parent Page:')),
1382
+		'all_items' => array(__('All Posts'), __('All Pages')),
1383
+		'archives' => array(__('Post Archives'), __('Page Archives')),
1384
+		'attributes' => array(__('Post Attributes'), __('Page Attributes')),
1385
+		'insert_into_item' => array(__('Insert into post'), __('Insert into page')),
1386
+		'uploaded_to_this_item' => array(__('Uploaded to this post'), __('Uploaded to this page')),
1387
+		'featured_image' => array(_x('Featured Image', 'post'), _x('Featured Image', 'page')),
1388
+		'set_featured_image' => array(_x('Set featured image', 'post'), _x('Set featured image', 'page')),
1389
+		'remove_featured_image' => array(_x('Remove featured image', 'post'), _x('Remove featured image', 'page')),
1390
+		'use_featured_image' => array(_x('Use as featured image', 'post'), _x('Use as featured image', 'page')),
1391
+		'filter_items_list' => array(__('Filter posts list'), __('Filter pages list')),
1392
+		'items_list_navigation' => array(__('Posts list navigation'), __('Pages list navigation')),
1393
+		'items_list' => array(__('Posts list'), __('Pages list')),
1394 1394
 	);
1395 1395
 	$nohier_vs_hier_defaults['menu_name'] = $nohier_vs_hier_defaults['name'];
1396 1396
 
1397
-	$labels = _get_custom_object_labels( $post_type_object, $nohier_vs_hier_defaults );
1397
+	$labels = _get_custom_object_labels($post_type_object, $nohier_vs_hier_defaults);
1398 1398
 
1399 1399
 	$post_type = $post_type_object->name;
1400 1400
 
@@ -1412,10 +1412,10 @@  discard block
 block discarded – undo
1412 1412
 	 *
1413 1413
 	 * @param object $labels Object with labels for the post type as member variables.
1414 1414
 	 */
1415
-	$labels = apply_filters( "post_type_labels_{$post_type}", $labels );
1415
+	$labels = apply_filters("post_type_labels_{$post_type}", $labels);
1416 1416
 
1417 1417
 	// Ensure that the filtered labels contain all required default values.
1418
-	$labels = (object) array_merge( (array) $default_labels, (array) $labels );
1418
+	$labels = (object) array_merge((array) $default_labels, (array) $labels);
1419 1419
 
1420 1420
 	return $labels;
1421 1421
 }
@@ -1431,33 +1431,33 @@  discard block
 block discarded – undo
1431 1431
  * @param array  $nohier_vs_hier_defaults Hierarchical vs non-hierarchical default labels.
1432 1432
  * @return object Object containing labels for the given custom-something object.
1433 1433
  */
1434
-function _get_custom_object_labels( $object, $nohier_vs_hier_defaults ) {
1434
+function _get_custom_object_labels($object, $nohier_vs_hier_defaults) {
1435 1435
 	$object->labels = (array) $object->labels;
1436 1436
 
1437
-	if ( isset( $object->label ) && empty( $object->labels['name'] ) )
1437
+	if (isset($object->label) && empty($object->labels['name']))
1438 1438
 		$object->labels['name'] = $object->label;
1439 1439
 
1440
-	if ( !isset( $object->labels['singular_name'] ) && isset( $object->labels['name'] ) )
1440
+	if ( ! isset($object->labels['singular_name']) && isset($object->labels['name']))
1441 1441
 		$object->labels['singular_name'] = $object->labels['name'];
1442 1442
 
1443
-	if ( ! isset( $object->labels['name_admin_bar'] ) )
1444
-		$object->labels['name_admin_bar'] = isset( $object->labels['singular_name'] ) ? $object->labels['singular_name'] : $object->name;
1443
+	if ( ! isset($object->labels['name_admin_bar']))
1444
+		$object->labels['name_admin_bar'] = isset($object->labels['singular_name']) ? $object->labels['singular_name'] : $object->name;
1445 1445
 
1446
-	if ( !isset( $object->labels['menu_name'] ) && isset( $object->labels['name'] ) )
1446
+	if ( ! isset($object->labels['menu_name']) && isset($object->labels['name']))
1447 1447
 		$object->labels['menu_name'] = $object->labels['name'];
1448 1448
 
1449
-	if ( !isset( $object->labels['all_items'] ) && isset( $object->labels['menu_name'] ) )
1449
+	if ( ! isset($object->labels['all_items']) && isset($object->labels['menu_name']))
1450 1450
 		$object->labels['all_items'] = $object->labels['menu_name'];
1451 1451
 
1452
-	if ( !isset( $object->labels['archives'] ) && isset( $object->labels['all_items'] ) ) {
1452
+	if ( ! isset($object->labels['archives']) && isset($object->labels['all_items'])) {
1453 1453
 		$object->labels['archives'] = $object->labels['all_items'];
1454 1454
 	}
1455 1455
 
1456 1456
 	$defaults = array();
1457
-	foreach ( $nohier_vs_hier_defaults as $key => $value ) {
1457
+	foreach ($nohier_vs_hier_defaults as $key => $value) {
1458 1458
 		$defaults[$key] = $object->hierarchical ? $value[1] : $value[0];
1459 1459
 	}
1460
-	$labels = array_merge( $defaults, $object->labels );
1460
+	$labels = array_merge($defaults, $object->labels);
1461 1461
 	$object->labels = (object) $object->labels;
1462 1462
 
1463 1463
 	return (object) $labels;
@@ -1470,12 +1470,12 @@  discard block
 block discarded – undo
1470 1470
  * @since 3.1.0
1471 1471
  */
1472 1472
 function _add_post_type_submenus() {
1473
-	foreach ( get_post_types( array( 'show_ui' => true ) ) as $ptype ) {
1474
-		$ptype_obj = get_post_type_object( $ptype );
1473
+	foreach (get_post_types(array('show_ui' => true)) as $ptype) {
1474
+		$ptype_obj = get_post_type_object($ptype);
1475 1475
 		// Sub-menus only.
1476
-		if ( ! $ptype_obj->show_in_menu || $ptype_obj->show_in_menu === true )
1476
+		if ( ! $ptype_obj->show_in_menu || $ptype_obj->show_in_menu === true)
1477 1477
 			continue;
1478
-		add_submenu_page( $ptype_obj->show_in_menu, $ptype_obj->labels->name, $ptype_obj->labels->all_items, $ptype_obj->cap->edit_posts, "edit.php?post_type=$ptype" );
1478
+		add_submenu_page($ptype_obj->show_in_menu, $ptype_obj->labels->name, $ptype_obj->labels->all_items, $ptype_obj->cap->edit_posts, "edit.php?post_type=$ptype");
1479 1479
 	}
1480 1480
 }
1481 1481
 
@@ -1499,15 +1499,15 @@  discard block
 block discarded – undo
1499 1499
  * @param string|array $feature   The feature being added, accepts an array of
1500 1500
  *                                feature strings or a single string.
1501 1501
  */
1502
-function add_post_type_support( $post_type, $feature ) {
1502
+function add_post_type_support($post_type, $feature) {
1503 1503
 	global $_wp_post_type_features;
1504 1504
 
1505 1505
 	$features = (array) $feature;
1506 1506
 	foreach ($features as $feature) {
1507
-		if ( func_num_args() == 2 )
1507
+		if (func_num_args() == 2)
1508 1508
 			$_wp_post_type_features[$post_type][$feature] = true;
1509 1509
 		else
1510
-			$_wp_post_type_features[$post_type][$feature] = array_slice( func_get_args(), 2 );
1510
+			$_wp_post_type_features[$post_type][$feature] = array_slice(func_get_args(), 2);
1511 1511
 	}
1512 1512
 }
1513 1513
 
@@ -1521,10 +1521,10 @@  discard block
 block discarded – undo
1521 1521
  * @param string $post_type The post type for which to remove the feature.
1522 1522
  * @param string $feature   The feature being removed.
1523 1523
  */
1524
-function remove_post_type_support( $post_type, $feature ) {
1524
+function remove_post_type_support($post_type, $feature) {
1525 1525
 	global $_wp_post_type_features;
1526 1526
 
1527
-	unset( $_wp_post_type_features[ $post_type ][ $feature ] );
1527
+	unset($_wp_post_type_features[$post_type][$feature]);
1528 1528
 }
1529 1529
 
1530 1530
 /**
@@ -1537,10 +1537,10 @@  discard block
 block discarded – undo
1537 1537
  * @param string $post_type The post type.
1538 1538
  * @return array Post type supports list.
1539 1539
  */
1540
-function get_all_post_type_supports( $post_type ) {
1540
+function get_all_post_type_supports($post_type) {
1541 1541
 	global $_wp_post_type_features;
1542 1542
 
1543
-	if ( isset( $_wp_post_type_features[$post_type] ) )
1543
+	if (isset($_wp_post_type_features[$post_type]))
1544 1544
 		return $_wp_post_type_features[$post_type];
1545 1545
 
1546 1546
 	return array();
@@ -1557,10 +1557,10 @@  discard block
 block discarded – undo
1557 1557
  * @param string $feature   The feature being checked.
1558 1558
  * @return bool Whether the post type supports the given feature.
1559 1559
  */
1560
-function post_type_supports( $post_type, $feature ) {
1560
+function post_type_supports($post_type, $feature) {
1561 1561
 	global $_wp_post_type_features;
1562 1562
 
1563
-	return ( isset( $_wp_post_type_features[$post_type][$feature] ) );
1563
+	return (isset($_wp_post_type_features[$post_type][$feature]));
1564 1564
 }
1565 1565
 
1566 1566
 /**
@@ -1577,12 +1577,12 @@  discard block
 block discarded – undo
1577 1577
  *                               match. Default 'and'.
1578 1578
  * @return array A list of post type names.
1579 1579
  */
1580
-function get_post_types_by_support( $feature, $operator = 'and' ) {
1580
+function get_post_types_by_support($feature, $operator = 'and') {
1581 1581
 	global $_wp_post_type_features;
1582 1582
 
1583
-	$features = array_fill_keys( (array) $feature, true );
1583
+	$features = array_fill_keys((array) $feature, true);
1584 1584
 
1585
-	return array_keys( wp_filter_object_list( $_wp_post_type_features, $features, $operator ) );
1585
+	return array_keys(wp_filter_object_list($_wp_post_type_features, $features, $operator));
1586 1586
 }
1587 1587
 
1588 1588
 /**
@@ -1599,13 +1599,13 @@  discard block
 block discarded – undo
1599 1599
  *                          name a few. Default 'post'.
1600 1600
  * @return int|false Amount of rows changed. Should be 1 for success and 0 for failure.
1601 1601
  */
1602
-function set_post_type( $post_id = 0, $post_type = 'post' ) {
1602
+function set_post_type($post_id = 0, $post_type = 'post') {
1603 1603
 	global $wpdb;
1604 1604
 
1605 1605
 	$post_type = sanitize_post_field('post_type', $post_type, $post_id, 'db');
1606
-	$return = $wpdb->update( $wpdb->posts, array('post_type' => $post_type), array('ID' => $post_id) );
1606
+	$return = $wpdb->update($wpdb->posts, array('post_type' => $post_type), array('ID' => $post_id));
1607 1607
 
1608
-	clean_post_cache( $post_id );
1608
+	clean_post_cache($post_id);
1609 1609
 
1610 1610
 	return $return;
1611 1611
 }
@@ -1623,15 +1623,15 @@  discard block
 block discarded – undo
1623 1623
  * @param string|WP_Post_Type $post_type Post type name or object.
1624 1624
  * @return bool Whether the post type should be considered viewable.
1625 1625
  */
1626
-function is_post_type_viewable( $post_type ) {
1627
-	if ( is_scalar( $post_type ) ) {
1628
-		$post_type = get_post_type_object( $post_type );
1629
-		if ( ! $post_type ) {
1626
+function is_post_type_viewable($post_type) {
1627
+	if (is_scalar($post_type)) {
1628
+		$post_type = get_post_type_object($post_type);
1629
+		if ( ! $post_type) {
1630 1630
 			return false;
1631 1631
 		}
1632 1632
 	}
1633 1633
 
1634
-	return $post_type->publicly_queryable || ( $post_type->_builtin && $post_type->public );
1634
+	return $post_type->publicly_queryable || ($post_type->_builtin && $post_type->public);
1635 1635
 }
1636 1636
 
1637 1637
 /**
@@ -1658,7 +1658,7 @@  discard block
 block discarded – undo
1658 1658
  * }
1659 1659
  * @return array List of posts.
1660 1660
  */
1661
-function get_posts( $args = null ) {
1661
+function get_posts($args = null) {
1662 1662
 	$defaults = array(
1663 1663
 		'numberposts' => 5,
1664 1664
 		'category' => 0, 'orderby' => 'date',
@@ -1668,19 +1668,19 @@  discard block
 block discarded – undo
1668 1668
 		'suppress_filters' => true
1669 1669
 	);
1670 1670
 
1671
-	$r = wp_parse_args( $args, $defaults );
1672
-	if ( empty( $r['post_status'] ) )
1673
-		$r['post_status'] = ( 'attachment' == $r['post_type'] ) ? 'inherit' : 'publish';
1674
-	if ( ! empty($r['numberposts']) && empty($r['posts_per_page']) )
1671
+	$r = wp_parse_args($args, $defaults);
1672
+	if (empty($r['post_status']))
1673
+		$r['post_status'] = ('attachment' == $r['post_type']) ? 'inherit' : 'publish';
1674
+	if ( ! empty($r['numberposts']) && empty($r['posts_per_page']))
1675 1675
 		$r['posts_per_page'] = $r['numberposts'];
1676
-	if ( ! empty($r['category']) )
1676
+	if ( ! empty($r['category']))
1677 1677
 		$r['cat'] = $r['category'];
1678
-	if ( ! empty($r['include']) ) {
1679
-		$incposts = wp_parse_id_list( $r['include'] );
1680
-		$r['posts_per_page'] = count($incposts);  // only the number of posts included
1678
+	if ( ! empty($r['include'])) {
1679
+		$incposts = wp_parse_id_list($r['include']);
1680
+		$r['posts_per_page'] = count($incposts); // only the number of posts included
1681 1681
 		$r['post__in'] = $incposts;
1682
-	} elseif ( ! empty($r['exclude']) )
1683
-		$r['post__not_in'] = wp_parse_id_list( $r['exclude'] );
1682
+	} elseif ( ! empty($r['exclude']))
1683
+		$r['post__not_in'] = wp_parse_id_list($r['exclude']);
1684 1684
 
1685 1685
 	$r['ignore_sticky_posts'] = true;
1686 1686
 	$r['no_found_rows'] = true;
@@ -1708,9 +1708,9 @@  discard block
 block discarded – undo
1708 1708
  *                           Default false.
1709 1709
  * @return int|false Meta ID on success, false on failure.
1710 1710
  */
1711
-function add_post_meta( $post_id, $meta_key, $meta_value, $unique = false ) {
1711
+function add_post_meta($post_id, $meta_key, $meta_value, $unique = false) {
1712 1712
 	// Make sure meta is added to the post, not a revision.
1713
-	if ( $the_post = wp_is_post_revision($post_id) )
1713
+	if ($the_post = wp_is_post_revision($post_id))
1714 1714
 		$post_id = $the_post;
1715 1715
 
1716 1716
 	return add_metadata('post', $post_id, $meta_key, $meta_value, $unique);
@@ -1731,9 +1731,9 @@  discard block
 block discarded – undo
1731 1731
  *                           non-scalar. Default empty.
1732 1732
  * @return bool True on success, false on failure.
1733 1733
  */
1734
-function delete_post_meta( $post_id, $meta_key, $meta_value = '' ) {
1734
+function delete_post_meta($post_id, $meta_key, $meta_value = '') {
1735 1735
 	// Make sure meta is added to the post, not a revision.
1736
-	if ( $the_post = wp_is_post_revision($post_id) )
1736
+	if ($the_post = wp_is_post_revision($post_id))
1737 1737
 		$post_id = $the_post;
1738 1738
 
1739 1739
 	return delete_metadata('post', $post_id, $meta_key, $meta_value);
@@ -1751,7 +1751,7 @@  discard block
 block discarded – undo
1751 1751
  * @return mixed Will be an array if $single is false. Will be value of meta data
1752 1752
  *               field if $single is true.
1753 1753
  */
1754
-function get_post_meta( $post_id, $key = '', $single = false ) {
1754
+function get_post_meta($post_id, $key = '', $single = false) {
1755 1755
 	return get_metadata('post', $post_id, $key, $single);
1756 1756
 }
1757 1757
 
@@ -1773,9 +1773,9 @@  discard block
 block discarded – undo
1773 1773
  * @return int|bool Meta ID if the key didn't exist, true on successful update,
1774 1774
  *                  false on failure.
1775 1775
  */
1776
-function update_post_meta( $post_id, $meta_key, $meta_value, $prev_value = '' ) {
1776
+function update_post_meta($post_id, $meta_key, $meta_value, $prev_value = '') {
1777 1777
 	// Make sure meta is added to the post, not a revision.
1778
-	if ( $the_post = wp_is_post_revision($post_id) )
1778
+	if ($the_post = wp_is_post_revision($post_id))
1779 1779
 		$post_id = $the_post;
1780 1780
 
1781 1781
 	return update_metadata('post', $post_id, $meta_key, $meta_value, $prev_value);
@@ -1789,8 +1789,8 @@  discard block
 block discarded – undo
1789 1789
  * @param string $post_meta_key Key to search for when deleting.
1790 1790
  * @return bool Whether the post meta key was deleted from the database.
1791 1791
  */
1792
-function delete_post_meta_by_key( $post_meta_key ) {
1793
-	return delete_metadata( 'post', null, $post_meta_key, '', true );
1792
+function delete_post_meta_by_key($post_meta_key) {
1793
+	return delete_metadata('post', null, $post_meta_key, '', true);
1794 1794
 }
1795 1795
 
1796 1796
 /**
@@ -1804,12 +1804,12 @@  discard block
 block discarded – undo
1804 1804
  * @param int $post_id Optional. Post ID. Default is ID of the global $post.
1805 1805
  * @return array Post meta for the given post.
1806 1806
  */
1807
-function get_post_custom( $post_id = 0 ) {
1808
-	$post_id = absint( $post_id );
1809
-	if ( ! $post_id )
1807
+function get_post_custom($post_id = 0) {
1808
+	$post_id = absint($post_id);
1809
+	if ( ! $post_id)
1810 1810
 		$post_id = get_the_ID();
1811 1811
 
1812
-	return get_post_meta( $post_id );
1812
+	return get_post_meta($post_id);
1813 1813
 }
1814 1814
 
1815 1815
 /**
@@ -1822,13 +1822,13 @@  discard block
 block discarded – undo
1822 1822
  * @param int $post_id Optional. Post ID. Default is ID of the global $post.
1823 1823
  * @return array|void Array of the keys, if retrieved.
1824 1824
  */
1825
-function get_post_custom_keys( $post_id = 0 ) {
1826
-	$custom = get_post_custom( $post_id );
1825
+function get_post_custom_keys($post_id = 0) {
1826
+	$custom = get_post_custom($post_id);
1827 1827
 
1828
-	if ( !is_array($custom) )
1828
+	if ( ! is_array($custom))
1829 1829
 		return;
1830 1830
 
1831
-	if ( $keys = array_keys($custom) )
1831
+	if ($keys = array_keys($custom))
1832 1832
 		return $keys;
1833 1833
 }
1834 1834
 
@@ -1844,8 +1844,8 @@  discard block
 block discarded – undo
1844 1844
  * @param int    $post_id Optional. Post ID. Default is ID of the global $post.
1845 1845
  * @return array|null Meta field values.
1846 1846
  */
1847
-function get_post_custom_values( $key = '', $post_id = 0 ) {
1848
-	if ( !$key )
1847
+function get_post_custom_values($key = '', $post_id = 0) {
1848
+	if ( ! $key)
1849 1849
 		return null;
1850 1850
 
1851 1851
 	$custom = get_post_custom($post_id);
@@ -1864,18 +1864,18 @@  discard block
 block discarded – undo
1864 1864
  * @param int $post_id Optional. Post ID. Default is ID of the global $post.
1865 1865
  * @return bool Whether post is sticky.
1866 1866
  */
1867
-function is_sticky( $post_id = 0 ) {
1868
-	$post_id = absint( $post_id );
1867
+function is_sticky($post_id = 0) {
1868
+	$post_id = absint($post_id);
1869 1869
 
1870
-	if ( ! $post_id )
1870
+	if ( ! $post_id)
1871 1871
 		$post_id = get_the_ID();
1872 1872
 
1873
-	$stickies = get_option( 'sticky_posts' );
1873
+	$stickies = get_option('sticky_posts');
1874 1874
 
1875
-	if ( ! is_array( $stickies ) )
1875
+	if ( ! is_array($stickies))
1876 1876
 		return false;
1877 1877
 
1878
-	if ( in_array( $post_id, $stickies ) )
1878
+	if (in_array($post_id, $stickies))
1879 1879
 		return true;
1880 1880
 
1881 1881
 	return false;
@@ -1898,23 +1898,23 @@  discard block
 block discarded – undo
1898 1898
  * @return object|WP_Post|array The now sanitized Post Object or Array (will be the
1899 1899
  *                              same type as $post).
1900 1900
  */
1901
-function sanitize_post( $post, $context = 'display' ) {
1902
-	if ( is_object($post) ) {
1901
+function sanitize_post($post, $context = 'display') {
1902
+	if (is_object($post)) {
1903 1903
 		// Check if post already filtered for this context.
1904
-		if ( isset($post->filter) && $context == $post->filter )
1904
+		if (isset($post->filter) && $context == $post->filter)
1905 1905
 			return $post;
1906
-		if ( !isset($post->ID) )
1906
+		if ( ! isset($post->ID))
1907 1907
 			$post->ID = 0;
1908
-		foreach ( array_keys(get_object_vars($post)) as $field )
1908
+		foreach (array_keys(get_object_vars($post)) as $field)
1909 1909
 			$post->$field = sanitize_post_field($field, $post->$field, $post->ID, $context);
1910 1910
 		$post->filter = $context;
1911
-	} elseif ( is_array( $post ) ) {
1911
+	} elseif (is_array($post)) {
1912 1912
 		// Check if post already filtered for this context.
1913
-		if ( isset($post['filter']) && $context == $post['filter'] )
1913
+		if (isset($post['filter']) && $context == $post['filter'])
1914 1914
 			return $post;
1915
-		if ( !isset($post['ID']) )
1915
+		if ( ! isset($post['ID']))
1916 1916
 			$post['ID'] = 0;
1917
-		foreach ( array_keys($post) as $field )
1917
+		foreach (array_keys($post) as $field)
1918 1918
 			$post[$field] = sanitize_post_field($field, $post[$field], $post['ID'], $context);
1919 1919
 		$post['filter'] = $context;
1920 1920
 	}
@@ -1938,31 +1938,31 @@  discard block
 block discarded – undo
1938 1938
  *                        'db', 'display', 'attribute' and 'js'. Default 'display'.
1939 1939
  * @return mixed Sanitized value.
1940 1940
  */
1941
-function sanitize_post_field( $field, $value, $post_id, $context = 'display' ) {
1941
+function sanitize_post_field($field, $value, $post_id, $context = 'display') {
1942 1942
 	$int_fields = array('ID', 'post_parent', 'menu_order');
1943
-	if ( in_array($field, $int_fields) )
1943
+	if (in_array($field, $int_fields))
1944 1944
 		$value = (int) $value;
1945 1945
 
1946 1946
 	// Fields which contain arrays of integers.
1947
-	$array_int_fields = array( 'ancestors' );
1948
-	if ( in_array($field, $array_int_fields) ) {
1949
-		$value = array_map( 'absint', $value);
1947
+	$array_int_fields = array('ancestors');
1948
+	if (in_array($field, $array_int_fields)) {
1949
+		$value = array_map('absint', $value);
1950 1950
 		return $value;
1951 1951
 	}
1952 1952
 
1953
-	if ( 'raw' == $context )
1953
+	if ('raw' == $context)
1954 1954
 		return $value;
1955 1955
 
1956 1956
 	$prefixed = false;
1957
-	if ( false !== strpos($field, 'post_') ) {
1957
+	if (false !== strpos($field, 'post_')) {
1958 1958
 		$prefixed = true;
1959 1959
 		$field_no_prefix = str_replace('post_', '', $field);
1960 1960
 	}
1961 1961
 
1962
-	if ( 'edit' == $context ) {
1962
+	if ('edit' == $context) {
1963 1963
 		$format_to_edit = array('post_content', 'post_excerpt', 'post_title', 'post_password');
1964 1964
 
1965
-		if ( $prefixed ) {
1965
+		if ($prefixed) {
1966 1966
 
1967 1967
 			/**
1968 1968
 			 * Filters the value of a specific post field to edit.
@@ -1975,7 +1975,7 @@  discard block
 block discarded – undo
1975 1975
 			 * @param mixed $value   Value of the post field.
1976 1976
 			 * @param int   $post_id Post ID.
1977 1977
 			 */
1978
-			$value = apply_filters( "edit_{$field}", $value, $post_id );
1978
+			$value = apply_filters("edit_{$field}", $value, $post_id);
1979 1979
 
1980 1980
 			/**
1981 1981
 			 * Filters the value of a specific post field to edit.
@@ -1988,21 +1988,21 @@  discard block
 block discarded – undo
1988 1988
 			 * @param mixed $value   Value of the post field.
1989 1989
 			 * @param int   $post_id Post ID.
1990 1990
 			 */
1991
-			$value = apply_filters( "{$field_no_prefix}_edit_pre", $value, $post_id );
1991
+			$value = apply_filters("{$field_no_prefix}_edit_pre", $value, $post_id);
1992 1992
 		} else {
1993
-			$value = apply_filters( "edit_post_{$field}", $value, $post_id );
1993
+			$value = apply_filters("edit_post_{$field}", $value, $post_id);
1994 1994
 		}
1995 1995
 
1996
-		if ( in_array($field, $format_to_edit) ) {
1997
-			if ( 'post_content' == $field )
1996
+		if (in_array($field, $format_to_edit)) {
1997
+			if ('post_content' == $field)
1998 1998
 				$value = format_to_edit($value, user_can_richedit());
1999 1999
 			else
2000 2000
 				$value = format_to_edit($value);
2001 2001
 		} else {
2002 2002
 			$value = esc_attr($value);
2003 2003
 		}
2004
-	} elseif ( 'db' == $context ) {
2005
-		if ( $prefixed ) {
2004
+	} elseif ('db' == $context) {
2005
+		if ($prefixed) {
2006 2006
 
2007 2007
 			/**
2008 2008
 			 * Filters the value of a specific post field before saving.
@@ -2014,7 +2014,7 @@  discard block
 block discarded – undo
2014 2014
 			 *
2015 2015
 			 * @param mixed $value Value of the post field.
2016 2016
 			 */
2017
-			$value = apply_filters( "pre_{$field}", $value );
2017
+			$value = apply_filters("pre_{$field}", $value);
2018 2018
 
2019 2019
 			/**
2020 2020
 			 * Filters the value of a specific field before saving.
@@ -2026,9 +2026,9 @@  discard block
 block discarded – undo
2026 2026
 			 *
2027 2027
 			 * @param mixed $value Value of the post field.
2028 2028
 			 */
2029
-			$value = apply_filters( "{$field_no_prefix}_save_pre", $value );
2029
+			$value = apply_filters("{$field_no_prefix}_save_pre", $value);
2030 2030
 		} else {
2031
-			$value = apply_filters( "pre_post_{$field}", $value );
2031
+			$value = apply_filters("pre_post_{$field}", $value);
2032 2032
 
2033 2033
 			/**
2034 2034
 			 * Filters the value of a specific post field before saving.
@@ -2040,12 +2040,12 @@  discard block
 block discarded – undo
2040 2040
 			 *
2041 2041
 			 * @param mixed $value Value of the post field.
2042 2042
 			 */
2043
-			$value = apply_filters( "{$field}_pre", $value );
2043
+			$value = apply_filters("{$field}_pre", $value);
2044 2044
 		}
2045 2045
 	} else {
2046 2046
 
2047 2047
 		// Use display filters by default.
2048
-		if ( $prefixed ) {
2048
+		if ($prefixed) {
2049 2049
 
2050 2050
 			/**
2051 2051
 			 * Filters the value of a specific post field for display.
@@ -2061,15 +2061,15 @@  discard block
 block discarded – undo
2061 2061
 			 *                        values include 'raw', 'edit', 'db', 'display',
2062 2062
 			 *                        'attribute' and 'js'.
2063 2063
 			 */
2064
-			$value = apply_filters( "{$field}", $value, $post_id, $context );
2064
+			$value = apply_filters("{$field}", $value, $post_id, $context);
2065 2065
 		} else {
2066
-			$value = apply_filters( "post_{$field}", $value, $post_id, $context );
2066
+			$value = apply_filters("post_{$field}", $value, $post_id, $context);
2067 2067
 		}
2068 2068
 
2069
-		if ( 'attribute' == $context ) {
2070
-			$value = esc_attr( $value );
2071
-		} elseif ( 'js' == $context ) {
2072
-			$value = esc_js( $value );
2069
+		if ('attribute' == $context) {
2070
+			$value = esc_attr($value);
2071
+		} elseif ('js' == $context) {
2072
+			$value = esc_js($value);
2073 2073
 		}
2074 2074
 	}
2075 2075
 
@@ -2085,18 +2085,18 @@  discard block
 block discarded – undo
2085 2085
  *
2086 2086
  * @param int $post_id Post ID.
2087 2087
  */
2088
-function stick_post( $post_id ) {
2088
+function stick_post($post_id) {
2089 2089
 	$stickies = get_option('sticky_posts');
2090 2090
 
2091
-	if ( !is_array($stickies) )
2091
+	if ( ! is_array($stickies))
2092 2092
 		$stickies = array($post_id);
2093 2093
 
2094
-	if ( ! in_array($post_id, $stickies) )
2094
+	if ( ! in_array($post_id, $stickies))
2095 2095
 		$stickies[] = $post_id;
2096 2096
 
2097
-	$updated = update_option( 'sticky_posts', $stickies );
2097
+	$updated = update_option('sticky_posts', $stickies);
2098 2098
 
2099
-	if ( $updated ) {
2099
+	if ($updated) {
2100 2100
 		/**
2101 2101
 		 * Fires once a post has been added to the sticky list.
2102 2102
 		 *
@@ -2104,7 +2104,7 @@  discard block
 block discarded – undo
2104 2104
 		 *
2105 2105
 		 * @param int $post_id ID of the post that was stuck.
2106 2106
 		 */
2107
-		do_action( 'post_stuck', $post_id );
2107
+		do_action('post_stuck', $post_id);
2108 2108
 	}
2109 2109
 }
2110 2110
 
@@ -2117,24 +2117,24 @@  discard block
 block discarded – undo
2117 2117
  *
2118 2118
  * @param int $post_id Post ID.
2119 2119
  */
2120
-function unstick_post( $post_id ) {
2120
+function unstick_post($post_id) {
2121 2121
 	$stickies = get_option('sticky_posts');
2122 2122
 
2123
-	if ( !is_array($stickies) )
2123
+	if ( ! is_array($stickies))
2124 2124
 		return;
2125 2125
 
2126
-	if ( ! in_array($post_id, $stickies) )
2126
+	if ( ! in_array($post_id, $stickies))
2127 2127
 		return;
2128 2128
 
2129 2129
 	$offset = array_search($post_id, $stickies);
2130
-	if ( false === $offset )
2130
+	if (false === $offset)
2131 2131
 		return;
2132 2132
 
2133 2133
 	array_splice($stickies, $offset, 1);
2134 2134
 
2135
-	$updated = update_option( 'sticky_posts', $stickies );
2135
+	$updated = update_option('sticky_posts', $stickies);
2136 2136
 
2137
-	if ( $updated ) {
2137
+	if ($updated) {
2138 2138
 		/**
2139 2139
 		 * Fires once a post has been removed from the sticky list.
2140 2140
 		 *
@@ -2142,7 +2142,7 @@  discard block
 block discarded – undo
2142 2142
 		 *
2143 2143
 		 * @param int $post_id ID of the post that was unstuck.
2144 2144
 		 */
2145
-		do_action( 'post_unstuck', $post_id );
2145
+		do_action('post_unstuck', $post_id);
2146 2146
 	}
2147 2147
 }
2148 2148
 
@@ -2155,12 +2155,12 @@  discard block
 block discarded – undo
2155 2155
  * @param string $perm Optional. 'readable' or empty. Default empty.
2156 2156
  * @return string The cache key.
2157 2157
  */
2158
-function _count_posts_cache_key( $type = 'post', $perm = '' ) {
2159
-	$cache_key = 'posts-' . $type;
2160
-	if ( 'readable' == $perm && is_user_logged_in() ) {
2161
-		$post_type_object = get_post_type_object( $type );
2162
-		if ( $post_type_object && ! current_user_can( $post_type_object->cap->read_private_posts ) ) {
2163
-			$cache_key .= '_' . $perm . '_' . get_current_user_id();
2158
+function _count_posts_cache_key($type = 'post', $perm = '') {
2159
+	$cache_key = 'posts-'.$type;
2160
+	if ('readable' == $perm && is_user_logged_in()) {
2161
+		$post_type_object = get_post_type_object($type);
2162
+		if ($post_type_object && ! current_user_can($post_type_object->cap->read_private_posts)) {
2163
+			$cache_key .= '_'.$perm.'_'.get_current_user_id();
2164 2164
 		}
2165 2165
 	}
2166 2166
 	return $cache_key;
@@ -2185,40 +2185,40 @@  discard block
 block discarded – undo
2185 2185
  * @param string $perm Optional. 'readable' or empty. Default empty.
2186 2186
  * @return object Number of posts for each status.
2187 2187
  */
2188
-function wp_count_posts( $type = 'post', $perm = '' ) {
2188
+function wp_count_posts($type = 'post', $perm = '') {
2189 2189
 	global $wpdb;
2190 2190
 
2191
-	if ( ! post_type_exists( $type ) )
2191
+	if ( ! post_type_exists($type))
2192 2192
 		return new stdClass;
2193 2193
 
2194
-	$cache_key = _count_posts_cache_key( $type, $perm );
2194
+	$cache_key = _count_posts_cache_key($type, $perm);
2195 2195
 
2196
-	$counts = wp_cache_get( $cache_key, 'counts' );
2197
-	if ( false !== $counts ) {
2196
+	$counts = wp_cache_get($cache_key, 'counts');
2197
+	if (false !== $counts) {
2198 2198
 		/** This filter is documented in wp-includes/post.php */
2199
-		return apply_filters( 'wp_count_posts', $counts, $type, $perm );
2199
+		return apply_filters('wp_count_posts', $counts, $type, $perm);
2200 2200
 	}
2201 2201
 
2202 2202
 	$query = "SELECT post_status, COUNT( * ) AS num_posts FROM {$wpdb->posts} WHERE post_type = %s";
2203
-	if ( 'readable' == $perm && is_user_logged_in() ) {
2203
+	if ('readable' == $perm && is_user_logged_in()) {
2204 2204
 		$post_type_object = get_post_type_object($type);
2205
-		if ( ! current_user_can( $post_type_object->cap->read_private_posts ) ) {
2206
-			$query .= $wpdb->prepare( " AND (post_status != 'private' OR ( post_author = %d AND post_status = 'private' ))",
2205
+		if ( ! current_user_can($post_type_object->cap->read_private_posts)) {
2206
+			$query .= $wpdb->prepare(" AND (post_status != 'private' OR ( post_author = %d AND post_status = 'private' ))",
2207 2207
 				get_current_user_id()
2208 2208
 			);
2209 2209
 		}
2210 2210
 	}
2211 2211
 	$query .= ' GROUP BY post_status';
2212 2212
 
2213
-	$results = (array) $wpdb->get_results( $wpdb->prepare( $query, $type ), ARRAY_A );
2214
-	$counts = array_fill_keys( get_post_stati(), 0 );
2213
+	$results = (array) $wpdb->get_results($wpdb->prepare($query, $type), ARRAY_A);
2214
+	$counts = array_fill_keys(get_post_stati(), 0);
2215 2215
 
2216
-	foreach ( $results as $row ) {
2217
-		$counts[ $row['post_status'] ] = $row['num_posts'];
2216
+	foreach ($results as $row) {
2217
+		$counts[$row['post_status']] = $row['num_posts'];
2218 2218
 	}
2219 2219
 
2220 2220
 	$counts = (object) $counts;
2221
-	wp_cache_set( $cache_key, $counts, 'counts' );
2221
+	wp_cache_set($cache_key, $counts, 'counts');
2222 2222
 
2223 2223
 	/**
2224 2224
 	 * Modify returned post counts by status for the current post type.
@@ -2231,7 +2231,7 @@  discard block
 block discarded – undo
2231 2231
 	 * @param string $perm   The permission to determine if the posts are 'readable'
2232 2232
 	 *                       by the current user.
2233 2233
 	 */
2234
-	return apply_filters( 'wp_count_posts', $counts, $type, $perm );
2234
+	return apply_filters('wp_count_posts', $counts, $type, $perm);
2235 2235
 }
2236 2236
 
2237 2237
 /**
@@ -2250,17 +2250,17 @@  discard block
 block discarded – undo
2250 2250
  *                                MIME patterns. Default empty.
2251 2251
  * @return object An object containing the attachment counts by mime type.
2252 2252
  */
2253
-function wp_count_attachments( $mime_type = '' ) {
2253
+function wp_count_attachments($mime_type = '') {
2254 2254
 	global $wpdb;
2255 2255
 
2256
-	$and = wp_post_mime_type_where( $mime_type );
2257
-	$count = $wpdb->get_results( "SELECT post_mime_type, COUNT( * ) AS num_posts FROM $wpdb->posts WHERE post_type = 'attachment' AND post_status != 'trash' $and GROUP BY post_mime_type", ARRAY_A );
2256
+	$and = wp_post_mime_type_where($mime_type);
2257
+	$count = $wpdb->get_results("SELECT post_mime_type, COUNT( * ) AS num_posts FROM $wpdb->posts WHERE post_type = 'attachment' AND post_status != 'trash' $and GROUP BY post_mime_type", ARRAY_A);
2258 2258
 
2259 2259
 	$counts = array();
2260
-	foreach ( (array) $count as $row ) {
2261
-		$counts[ $row['post_mime_type'] ] = $row['num_posts'];
2260
+	foreach ((array) $count as $row) {
2261
+		$counts[$row['post_mime_type']] = $row['num_posts'];
2262 2262
 	}
2263
-	$counts['trash'] = $wpdb->get_var( "SELECT COUNT( * ) FROM $wpdb->posts WHERE post_type = 'attachment' AND post_status = 'trash' $and");
2263
+	$counts['trash'] = $wpdb->get_var("SELECT COUNT( * ) FROM $wpdb->posts WHERE post_type = 'attachment' AND post_status = 'trash' $and");
2264 2264
 
2265 2265
 	/**
2266 2266
 	 * Modify returned attachment counts by mime type.
@@ -2272,7 +2272,7 @@  discard block
 block discarded – undo
2272 2272
 	 * @param string $mime_type The mime type pattern used to filter the attachments
2273 2273
 	 *                          counted.
2274 2274
 	 */
2275
-	return apply_filters( 'wp_count_attachments', (object) $counts, $mime_type );
2275
+	return apply_filters('wp_count_attachments', (object) $counts, $mime_type);
2276 2276
 }
2277 2277
 
2278 2278
 /**
@@ -2296,7 +2296,7 @@  discard block
 block discarded – undo
2296 2296
 	 *
2297 2297
 	 * @param array $post_mime_types Default list of post mime types.
2298 2298
 	 */
2299
-	return apply_filters( 'post_mime_types', $post_mime_types );
2299
+	return apply_filters('post_mime_types', $post_mime_types);
2300 2300
 }
2301 2301
 
2302 2302
 /**
@@ -2313,35 +2313,35 @@  discard block
 block discarded – undo
2313 2313
  * @param string|array $real_mime_types     Real post mime type values.
2314 2314
  * @return array array(wildcard=>array(real types)).
2315 2315
  */
2316
-function wp_match_mime_types( $wildcard_mime_types, $real_mime_types ) {
2316
+function wp_match_mime_types($wildcard_mime_types, $real_mime_types) {
2317 2317
 	$matches = array();
2318
-	if ( is_string( $wildcard_mime_types ) ) {
2319
-		$wildcard_mime_types = array_map( 'trim', explode( ',', $wildcard_mime_types ) );
2318
+	if (is_string($wildcard_mime_types)) {
2319
+		$wildcard_mime_types = array_map('trim', explode(',', $wildcard_mime_types));
2320 2320
 	}
2321
-	if ( is_string( $real_mime_types ) ) {
2322
-		$real_mime_types = array_map( 'trim', explode( ',', $real_mime_types ) );
2321
+	if (is_string($real_mime_types)) {
2322
+		$real_mime_types = array_map('trim', explode(',', $real_mime_types));
2323 2323
 	}
2324 2324
 
2325 2325
 	$patternses = array();
2326 2326
 	$wild = '[-._a-z0-9]*';
2327 2327
 
2328
-	foreach ( (array) $wildcard_mime_types as $type ) {
2329
-		$mimes = array_map( 'trim', explode( ',', $type ) );
2330
-		foreach ( $mimes as $mime ) {
2331
-			$regex = str_replace( '__wildcard__', $wild, preg_quote( str_replace( '*', '__wildcard__', $mime ) ) );
2328
+	foreach ((array) $wildcard_mime_types as $type) {
2329
+		$mimes = array_map('trim', explode(',', $type));
2330
+		foreach ($mimes as $mime) {
2331
+			$regex = str_replace('__wildcard__', $wild, preg_quote(str_replace('*', '__wildcard__', $mime)));
2332 2332
 			$patternses[][$type] = "^$regex$";
2333
-			if ( false === strpos( $mime, '/' ) ) {
2333
+			if (false === strpos($mime, '/')) {
2334 2334
 				$patternses[][$type] = "^$regex/";
2335 2335
 				$patternses[][$type] = $regex;
2336 2336
 			}
2337 2337
 		}
2338 2338
 	}
2339
-	asort( $patternses );
2339
+	asort($patternses);
2340 2340
 
2341
-	foreach ( $patternses as $patterns ) {
2342
-		foreach ( $patterns as $type => $pattern ) {
2343
-			foreach ( (array) $real_mime_types as $real ) {
2344
-				if ( preg_match( "#$pattern#", $real ) && ( empty( $matches[$type] ) || false === array_search( $real, $matches[$type] ) ) ) {
2341
+	foreach ($patternses as $patterns) {
2342
+		foreach ($patterns as $type => $pattern) {
2343
+			foreach ((array) $real_mime_types as $real) {
2344
+				if (preg_match("#$pattern#", $real) && (empty($matches[$type]) || false === array_search($real, $matches[$type]))) {
2345 2345
 					$matches[$type][] = $real;
2346 2346
 				}
2347 2347
 			}
@@ -2361,43 +2361,43 @@  discard block
 block discarded – undo
2361 2361
  *                                      Default empty.
2362 2362
  * @return string The SQL AND clause for mime searching.
2363 2363
  */
2364
-function wp_post_mime_type_where( $post_mime_types, $table_alias = '' ) {
2364
+function wp_post_mime_type_where($post_mime_types, $table_alias = '') {
2365 2365
 	$where = '';
2366 2366
 	$wildcards = array('', '%', '%/%');
2367
-	if ( is_string($post_mime_types) )
2367
+	if (is_string($post_mime_types))
2368 2368
 		$post_mime_types = array_map('trim', explode(',', $post_mime_types));
2369 2369
 
2370 2370
 	$wheres = array();
2371 2371
 
2372
-	foreach ( (array) $post_mime_types as $mime_type ) {
2372
+	foreach ((array) $post_mime_types as $mime_type) {
2373 2373
 		$mime_type = preg_replace('/\s/', '', $mime_type);
2374 2374
 		$slashpos = strpos($mime_type, '/');
2375
-		if ( false !== $slashpos ) {
2375
+		if (false !== $slashpos) {
2376 2376
 			$mime_group = preg_replace('/[^-*.a-zA-Z0-9]/', '', substr($mime_type, 0, $slashpos));
2377 2377
 			$mime_subgroup = preg_replace('/[^-*.+a-zA-Z0-9]/', '', substr($mime_type, $slashpos + 1));
2378
-			if ( empty($mime_subgroup) )
2378
+			if (empty($mime_subgroup))
2379 2379
 				$mime_subgroup = '*';
2380 2380
 			else
2381 2381
 				$mime_subgroup = str_replace('/', '', $mime_subgroup);
2382 2382
 			$mime_pattern = "$mime_group/$mime_subgroup";
2383 2383
 		} else {
2384 2384
 			$mime_pattern = preg_replace('/[^-*.a-zA-Z0-9]/', '', $mime_type);
2385
-			if ( false === strpos($mime_pattern, '*') )
2385
+			if (false === strpos($mime_pattern, '*'))
2386 2386
 				$mime_pattern .= '/*';
2387 2387
 		}
2388 2388
 
2389 2389
 		$mime_pattern = preg_replace('/\*+/', '%', $mime_pattern);
2390 2390
 
2391
-		if ( in_array( $mime_type, $wildcards ) )
2391
+		if (in_array($mime_type, $wildcards))
2392 2392
 			return '';
2393 2393
 
2394
-		if ( false !== strpos($mime_pattern, '%') )
2394
+		if (false !== strpos($mime_pattern, '%'))
2395 2395
 			$wheres[] = empty($table_alias) ? "post_mime_type LIKE '$mime_pattern'" : "$table_alias.post_mime_type LIKE '$mime_pattern'";
2396 2396
 		else
2397 2397
 			$wheres[] = empty($table_alias) ? "post_mime_type = '$mime_pattern'" : "$table_alias.post_mime_type = '$mime_pattern'";
2398 2398
 	}
2399
-	if ( !empty($wheres) )
2400
-		$where = ' AND (' . join(' OR ', $wheres) . ') ';
2399
+	if ( ! empty($wheres))
2400
+		$where = ' AND ('.join(' OR ', $wheres).') ';
2401 2401
 	return $where;
2402 2402
 }
2403 2403
 
@@ -2422,17 +2422,17 @@  discard block
 block discarded – undo
2422 2422
  *                           Default false.
2423 2423
  * @return array|false|WP_Post False on failure.
2424 2424
  */
2425
-function wp_delete_post( $postid = 0, $force_delete = false ) {
2425
+function wp_delete_post($postid = 0, $force_delete = false) {
2426 2426
 	global $wpdb;
2427 2427
 
2428
-	if ( !$post = $wpdb->get_row($wpdb->prepare("SELECT * FROM $wpdb->posts WHERE ID = %d", $postid)) )
2428
+	if ( ! $post = $wpdb->get_row($wpdb->prepare("SELECT * FROM $wpdb->posts WHERE ID = %d", $postid)))
2429 2429
 		return $post;
2430 2430
 
2431
-	if ( !$force_delete && ( $post->post_type == 'post' || $post->post_type == 'page') && get_post_status( $postid ) != 'trash' && EMPTY_TRASH_DAYS )
2432
-		return wp_trash_post( $postid );
2431
+	if ( ! $force_delete && ($post->post_type == 'post' || $post->post_type == 'page') && get_post_status($postid) != 'trash' && EMPTY_TRASH_DAYS)
2432
+		return wp_trash_post($postid);
2433 2433
 
2434
-	if ( $post->post_type == 'attachment' )
2435
-		return wp_delete_attachment( $postid, $force_delete );
2434
+	if ($post->post_type == 'attachment')
2435
+		return wp_delete_attachment($postid, $force_delete);
2436 2436
 
2437 2437
 	/**
2438 2438
 	 * Filters whether a post deletion should take place.
@@ -2443,8 +2443,8 @@  discard block
 block discarded – undo
2443 2443
 	 * @param WP_Post $post         Post object.
2444 2444
 	 * @param bool    $force_delete Whether to bypass the trash.
2445 2445
 	 */
2446
-	$check = apply_filters( 'pre_delete_post', null, $post, $force_delete );
2447
-	if ( null !== $check ) {
2446
+	$check = apply_filters('pre_delete_post', null, $post, $force_delete);
2447
+	if (null !== $check) {
2448 2448
 		return $check;
2449 2449
 	}
2450 2450
 
@@ -2457,46 +2457,46 @@  discard block
 block discarded – undo
2457 2457
 	 *
2458 2458
 	 * @param int $postid Post ID.
2459 2459
 	 */
2460
-	do_action( 'before_delete_post', $postid );
2460
+	do_action('before_delete_post', $postid);
2461 2461
 
2462
-	delete_post_meta($postid,'_wp_trash_meta_status');
2463
-	delete_post_meta($postid,'_wp_trash_meta_time');
2462
+	delete_post_meta($postid, '_wp_trash_meta_status');
2463
+	delete_post_meta($postid, '_wp_trash_meta_time');
2464 2464
 
2465 2465
 	wp_delete_object_term_relationships($postid, get_object_taxonomies($post->post_type));
2466 2466
 
2467
-	$parent_data = array( 'post_parent' => $post->post_parent );
2468
-	$parent_where = array( 'post_parent' => $postid );
2467
+	$parent_data = array('post_parent' => $post->post_parent);
2468
+	$parent_where = array('post_parent' => $postid);
2469 2469
 
2470
-	if ( is_post_type_hierarchical( $post->post_type ) ) {
2470
+	if (is_post_type_hierarchical($post->post_type)) {
2471 2471
 		// Point children of this page to its parent, also clean the cache of affected children.
2472
-		$children_query = $wpdb->prepare( "SELECT * FROM $wpdb->posts WHERE post_parent = %d AND post_type = %s", $postid, $post->post_type );
2473
-		$children = $wpdb->get_results( $children_query );
2474
-		if ( $children ) {
2475
-			$wpdb->update( $wpdb->posts, $parent_data, $parent_where + array( 'post_type' => $post->post_type ) );
2472
+		$children_query = $wpdb->prepare("SELECT * FROM $wpdb->posts WHERE post_parent = %d AND post_type = %s", $postid, $post->post_type);
2473
+		$children = $wpdb->get_results($children_query);
2474
+		if ($children) {
2475
+			$wpdb->update($wpdb->posts, $parent_data, $parent_where + array('post_type' => $post->post_type));
2476 2476
 		}
2477 2477
 	}
2478 2478
 
2479 2479
 	// Do raw query. wp_get_post_revisions() is filtered.
2480
-	$revision_ids = $wpdb->get_col( $wpdb->prepare( "SELECT ID FROM $wpdb->posts WHERE post_parent = %d AND post_type = 'revision'", $postid ) );
2480
+	$revision_ids = $wpdb->get_col($wpdb->prepare("SELECT ID FROM $wpdb->posts WHERE post_parent = %d AND post_type = 'revision'", $postid));
2481 2481
 	// Use wp_delete_post (via wp_delete_post_revision) again. Ensures any meta/misplaced data gets cleaned up.
2482
-	foreach ( $revision_ids as $revision_id )
2483
-		wp_delete_post_revision( $revision_id );
2482
+	foreach ($revision_ids as $revision_id)
2483
+		wp_delete_post_revision($revision_id);
2484 2484
 
2485 2485
 	// Point all attachments to this post up one level.
2486
-	$wpdb->update( $wpdb->posts, $parent_data, $parent_where + array( 'post_type' => 'attachment' ) );
2486
+	$wpdb->update($wpdb->posts, $parent_data, $parent_where + array('post_type' => 'attachment'));
2487 2487
 
2488
-	wp_defer_comment_counting( true );
2488
+	wp_defer_comment_counting(true);
2489 2489
 
2490
-	$comment_ids = $wpdb->get_col( $wpdb->prepare( "SELECT comment_ID FROM $wpdb->comments WHERE comment_post_ID = %d", $postid ));
2491
-	foreach ( $comment_ids as $comment_id ) {
2492
-		wp_delete_comment( $comment_id, true );
2490
+	$comment_ids = $wpdb->get_col($wpdb->prepare("SELECT comment_ID FROM $wpdb->comments WHERE comment_post_ID = %d", $postid));
2491
+	foreach ($comment_ids as $comment_id) {
2492
+		wp_delete_comment($comment_id, true);
2493 2493
 	}
2494 2494
 
2495
-	wp_defer_comment_counting( false );
2495
+	wp_defer_comment_counting(false);
2496 2496
 
2497
-	$post_meta_ids = $wpdb->get_col( $wpdb->prepare( "SELECT meta_id FROM $wpdb->postmeta WHERE post_id = %d ", $postid ));
2498
-	foreach ( $post_meta_ids as $mid )
2499
-		delete_metadata_by_mid( 'post', $mid );
2497
+	$post_meta_ids = $wpdb->get_col($wpdb->prepare("SELECT meta_id FROM $wpdb->postmeta WHERE post_id = %d ", $postid));
2498
+	foreach ($post_meta_ids as $mid)
2499
+		delete_metadata_by_mid('post', $mid);
2500 2500
 
2501 2501
 	/**
2502 2502
 	 * Fires immediately before a post is deleted from the database.
@@ -2505,9 +2505,9 @@  discard block
 block discarded – undo
2505 2505
 	 *
2506 2506
 	 * @param int $postid Post ID.
2507 2507
 	 */
2508
-	do_action( 'delete_post', $postid );
2509
-	$result = $wpdb->delete( $wpdb->posts, array( 'ID' => $postid ) );
2510
-	if ( ! $result ) {
2508
+	do_action('delete_post', $postid);
2509
+	$result = $wpdb->delete($wpdb->posts, array('ID' => $postid));
2510
+	if ( ! $result) {
2511 2511
 		return false;
2512 2512
 	}
2513 2513
 
@@ -2518,16 +2518,16 @@  discard block
 block discarded – undo
2518 2518
 	 *
2519 2519
 	 * @param int $postid Post ID.
2520 2520
 	 */
2521
-	do_action( 'deleted_post', $postid );
2521
+	do_action('deleted_post', $postid);
2522 2522
 
2523
-	clean_post_cache( $post );
2523
+	clean_post_cache($post);
2524 2524
 
2525
-	if ( is_post_type_hierarchical( $post->post_type ) && $children ) {
2526
-		foreach ( $children as $child )
2527
-			clean_post_cache( $child );
2525
+	if (is_post_type_hierarchical($post->post_type) && $children) {
2526
+		foreach ($children as $child)
2527
+			clean_post_cache($child);
2528 2528
 	}
2529 2529
 
2530
-	wp_clear_scheduled_hook('publish_future_post', array( $postid ) );
2530
+	wp_clear_scheduled_hook('publish_future_post', array($postid));
2531 2531
 
2532 2532
 	/**
2533 2533
 	 * Fires after a post is deleted, at the conclusion of wp_delete_post().
@@ -2538,7 +2538,7 @@  discard block
 block discarded – undo
2538 2538
 	 *
2539 2539
 	 * @param int $postid Post ID.
2540 2540
 	 */
2541
-	do_action( 'after_delete_post', $postid );
2541
+	do_action('after_delete_post', $postid);
2542 2542
 
2543 2543
 	return $post;
2544 2544
 }
@@ -2554,22 +2554,22 @@  discard block
 block discarded – undo
2554 2554
  *
2555 2555
  * @param int $post_id Post ID.
2556 2556
  */
2557
-function _reset_front_page_settings_for_post( $post_id ) {
2558
-	$post = get_post( $post_id );
2559
-	if ( 'page' == $post->post_type ) {
2557
+function _reset_front_page_settings_for_post($post_id) {
2558
+	$post = get_post($post_id);
2559
+	if ('page' == $post->post_type) {
2560 2560
 	 	/*
2561 2561
 	 	 * If the page is defined in option page_on_front or post_for_posts,
2562 2562
 	 	 * adjust the corresponding options.
2563 2563
 	 	 */
2564
-		if ( get_option( 'page_on_front' ) == $post->ID ) {
2565
-			update_option( 'show_on_front', 'posts' );
2566
-			update_option( 'page_on_front', 0 );
2564
+		if (get_option('page_on_front') == $post->ID) {
2565
+			update_option('show_on_front', 'posts');
2566
+			update_option('page_on_front', 0);
2567 2567
 		}
2568
-		if ( get_option( 'page_for_posts' ) == $post->ID ) {
2569
-			delete_option( 'page_for_posts', 0 );
2568
+		if (get_option('page_for_posts') == $post->ID) {
2569
+			delete_option('page_for_posts', 0);
2570 2570
 		}
2571 2571
 	}
2572
-	unstick_post( $post->ID );
2572
+	unstick_post($post->ID);
2573 2573
 }
2574 2574
 
2575 2575
 /**
@@ -2585,14 +2585,14 @@  discard block
 block discarded – undo
2585 2585
  *                     if EMPTY_TRASH_DAYS equals true.
2586 2586
  * @return false|array|WP_Post|null Post data array, otherwise false.
2587 2587
  */
2588
-function wp_trash_post( $post_id = 0 ) {
2589
-	if ( !EMPTY_TRASH_DAYS )
2588
+function wp_trash_post($post_id = 0) {
2589
+	if ( ! EMPTY_TRASH_DAYS)
2590 2590
 		return wp_delete_post($post_id, true);
2591 2591
 
2592
-	if ( !$post = get_post($post_id, ARRAY_A) )
2592
+	if ( ! $post = get_post($post_id, ARRAY_A))
2593 2593
 		return $post;
2594 2594
 
2595
-	if ( $post['post_status'] == 'trash' )
2595
+	if ($post['post_status'] == 'trash')
2596 2596
 		return false;
2597 2597
 
2598 2598
 	/**
@@ -2602,13 +2602,13 @@  discard block
 block discarded – undo
2602 2602
 	 *
2603 2603
 	 * @param int $post_id Post ID.
2604 2604
 	 */
2605
-	do_action( 'wp_trash_post', $post_id );
2605
+	do_action('wp_trash_post', $post_id);
2606 2606
 
2607
-	add_post_meta($post_id,'_wp_trash_meta_status', $post['post_status']);
2608
-	add_post_meta($post_id,'_wp_trash_meta_time', time());
2607
+	add_post_meta($post_id, '_wp_trash_meta_status', $post['post_status']);
2608
+	add_post_meta($post_id, '_wp_trash_meta_time', time());
2609 2609
 
2610 2610
 	$post['post_status'] = 'trash';
2611
-	wp_insert_post( wp_slash( $post ) );
2611
+	wp_insert_post(wp_slash($post));
2612 2612
 
2613 2613
 	wp_trash_post_comments($post_id);
2614 2614
 
@@ -2619,7 +2619,7 @@  discard block
 block discarded – undo
2619 2619
 	 *
2620 2620
 	 * @param int $post_id Post ID.
2621 2621
 	 */
2622
-	do_action( 'trashed_post', $post_id );
2622
+	do_action('trashed_post', $post_id);
2623 2623
 
2624 2624
 	return $post;
2625 2625
 }
@@ -2632,11 +2632,11 @@  discard block
 block discarded – undo
2632 2632
  * @param int $post_id Optional. Post ID. Default is ID of the global $post.
2633 2633
  * @return WP_Post|false WP_Post object. False on failure.
2634 2634
  */
2635
-function wp_untrash_post( $post_id = 0 ) {
2636
-	if ( !$post = get_post($post_id, ARRAY_A) )
2635
+function wp_untrash_post($post_id = 0) {
2636
+	if ( ! $post = get_post($post_id, ARRAY_A))
2637 2637
 		return $post;
2638 2638
 
2639
-	if ( $post['post_status'] != 'trash' )
2639
+	if ($post['post_status'] != 'trash')
2640 2640
 		return false;
2641 2641
 
2642 2642
 	/**
@@ -2646,7 +2646,7 @@  discard block
 block discarded – undo
2646 2646
 	 *
2647 2647
 	 * @param int $post_id Post ID.
2648 2648
 	 */
2649
-	do_action( 'untrash_post', $post_id );
2649
+	do_action('untrash_post', $post_id);
2650 2650
 
2651 2651
 	$post_status = get_post_meta($post_id, '_wp_trash_meta_status', true);
2652 2652
 
@@ -2655,7 +2655,7 @@  discard block
 block discarded – undo
2655 2655
 	delete_post_meta($post_id, '_wp_trash_meta_status');
2656 2656
 	delete_post_meta($post_id, '_wp_trash_meta_time');
2657 2657
 
2658
-	wp_insert_post( wp_slash( $post ) );
2658
+	wp_insert_post(wp_slash($post));
2659 2659
 
2660 2660
 	wp_untrash_post_comments($post_id);
2661 2661
 
@@ -2666,7 +2666,7 @@  discard block
 block discarded – undo
2666 2666
 	 *
2667 2667
 	 * @param int $post_id Post ID.
2668 2668
 	 */
2669
-	do_action( 'untrashed_post', $post_id );
2669
+	do_action('untrashed_post', $post_id);
2670 2670
 
2671 2671
 	return $post;
2672 2672
 }
@@ -2681,11 +2681,11 @@  discard block
 block discarded – undo
2681 2681
  * @param int|WP_Post|null $post Optional. Post ID or post object. Defaults to global $post.
2682 2682
  * @return mixed|void False on failure.
2683 2683
  */
2684
-function wp_trash_post_comments( $post = null ) {
2684
+function wp_trash_post_comments($post = null) {
2685 2685
 	global $wpdb;
2686 2686
 
2687 2687
 	$post = get_post($post);
2688
-	if ( empty($post) )
2688
+	if (empty($post))
2689 2689
 		return;
2690 2690
 
2691 2691
 	$post_id = $post->ID;
@@ -2697,22 +2697,22 @@  discard block
 block discarded – undo
2697 2697
 	 *
2698 2698
 	 * @param int $post_id Post ID.
2699 2699
 	 */
2700
-	do_action( 'trash_post_comments', $post_id );
2700
+	do_action('trash_post_comments', $post_id);
2701 2701
 
2702
-	$comments = $wpdb->get_results( $wpdb->prepare("SELECT comment_ID, comment_approved FROM $wpdb->comments WHERE comment_post_ID = %d", $post_id) );
2703
-	if ( empty($comments) )
2702
+	$comments = $wpdb->get_results($wpdb->prepare("SELECT comment_ID, comment_approved FROM $wpdb->comments WHERE comment_post_ID = %d", $post_id));
2703
+	if (empty($comments))
2704 2704
 		return;
2705 2705
 
2706 2706
 	// Cache current status for each comment.
2707 2707
 	$statuses = array();
2708
-	foreach ( $comments as $comment )
2708
+	foreach ($comments as $comment)
2709 2709
 		$statuses[$comment->comment_ID] = $comment->comment_approved;
2710 2710
 	add_post_meta($post_id, '_wp_trash_meta_comments_status', $statuses);
2711 2711
 
2712 2712
 	// Set status for all comments to post-trashed.
2713 2713
 	$result = $wpdb->update($wpdb->comments, array('comment_approved' => 'post-trashed'), array('comment_post_ID' => $post_id));
2714 2714
 
2715
-	clean_comment_cache( array_keys($statuses) );
2715
+	clean_comment_cache(array_keys($statuses));
2716 2716
 
2717 2717
 	/**
2718 2718
 	 * Fires after comments are sent to the trash.
@@ -2722,7 +2722,7 @@  discard block
 block discarded – undo
2722 2722
 	 * @param int   $post_id  Post ID.
2723 2723
 	 * @param array $statuses Array of comment statuses.
2724 2724
 	 */
2725
-	do_action( 'trashed_post_comments', $post_id, $statuses );
2725
+	do_action('trashed_post_comments', $post_id, $statuses);
2726 2726
 
2727 2727
 	return $result;
2728 2728
 }
@@ -2737,18 +2737,18 @@  discard block
 block discarded – undo
2737 2737
  * @param int|WP_Post|null $post Optional. Post ID or post object. Defaults to global $post.
2738 2738
  * @return true|void
2739 2739
  */
2740
-function wp_untrash_post_comments( $post = null ) {
2740
+function wp_untrash_post_comments($post = null) {
2741 2741
 	global $wpdb;
2742 2742
 
2743 2743
 	$post = get_post($post);
2744
-	if ( empty($post) )
2744
+	if (empty($post))
2745 2745
 		return;
2746 2746
 
2747 2747
 	$post_id = $post->ID;
2748 2748
 
2749 2749
 	$statuses = get_post_meta($post_id, '_wp_trash_meta_comments_status', true);
2750 2750
 
2751
-	if ( empty($statuses) )
2751
+	if (empty($statuses))
2752 2752
 		return true;
2753 2753
 
2754 2754
 	/**
@@ -2758,23 +2758,23 @@  discard block
 block discarded – undo
2758 2758
 	 *
2759 2759
 	 * @param int $post_id Post ID.
2760 2760
 	 */
2761
-	do_action( 'untrash_post_comments', $post_id );
2761
+	do_action('untrash_post_comments', $post_id);
2762 2762
 
2763 2763
 	// Restore each comment to its original status.
2764 2764
 	$group_by_status = array();
2765
-	foreach ( $statuses as $comment_id => $comment_status )
2765
+	foreach ($statuses as $comment_id => $comment_status)
2766 2766
 		$group_by_status[$comment_status][] = $comment_id;
2767 2767
 
2768
-	foreach ( $group_by_status as $status => $comments ) {
2768
+	foreach ($group_by_status as $status => $comments) {
2769 2769
 		// Sanity check. This shouldn't happen.
2770
-		if ( 'post-trashed' == $status ) {
2770
+		if ('post-trashed' == $status) {
2771 2771
 			$status = '0';
2772 2772
 		}
2773
-		$comments_in = implode( ', ', array_map( 'intval', $comments ) );
2774
-		$wpdb->query( $wpdb->prepare( "UPDATE $wpdb->comments SET comment_approved = %s WHERE comment_ID IN ($comments_in)", $status ) );
2773
+		$comments_in = implode(', ', array_map('intval', $comments));
2774
+		$wpdb->query($wpdb->prepare("UPDATE $wpdb->comments SET comment_approved = %s WHERE comment_ID IN ($comments_in)", $status));
2775 2775
 	}
2776 2776
 
2777
-	clean_comment_cache( array_keys($statuses) );
2777
+	clean_comment_cache(array_keys($statuses));
2778 2778
 
2779 2779
 	delete_post_meta($post_id, '_wp_trash_meta_comments_status');
2780 2780
 
@@ -2785,7 +2785,7 @@  discard block
 block discarded – undo
2785 2785
 	 *
2786 2786
 	 * @param int $post_id Post ID.
2787 2787
 	 */
2788
-	do_action( 'untrashed_post_comments', $post_id );
2788
+	do_action('untrashed_post_comments', $post_id);
2789 2789
 }
2790 2790
 
2791 2791
 /**
@@ -2807,11 +2807,11 @@  discard block
 block discarded – undo
2807 2807
  *                        is 'ids', an array of category ids. If `$fields` is 'names', an array of category names.
2808 2808
  *                        WP_Error object if 'category' taxonomy doesn't exist.
2809 2809
  */
2810
-function wp_get_post_categories( $post_id = 0, $args = array() ) {
2810
+function wp_get_post_categories($post_id = 0, $args = array()) {
2811 2811
 	$post_id = (int) $post_id;
2812 2812
 
2813 2813
 	$defaults = array('fields' => 'ids');
2814
-	$args = wp_parse_args( $args, $defaults );
2814
+	$args = wp_parse_args($args, $defaults);
2815 2815
 
2816 2816
 	$cats = wp_get_object_terms($post_id, 'category', $args);
2817 2817
 	return $cats;
@@ -2833,8 +2833,8 @@  discard block
 block discarded – undo
2833 2833
  * @return array|WP_Error Array of WP_Term objects on success or empty array if no tags were found.
2834 2834
  *                        WP_Error object if 'post_tag' taxonomy doesn't exist.
2835 2835
  */
2836
-function wp_get_post_tags( $post_id = 0, $args = array() ) {
2837
-	return wp_get_post_terms( $post_id, 'post_tag', $args);
2836
+function wp_get_post_tags($post_id = 0, $args = array()) {
2837
+	return wp_get_post_terms($post_id, 'post_tag', $args);
2838 2838
 }
2839 2839
 
2840 2840
 /**
@@ -2854,11 +2854,11 @@  discard block
 block discarded – undo
2854 2854
  * @return array|WP_Error  Array of WP_Term objects on success or empty array if no terms were found.
2855 2855
  *                         WP_Error object if `$taxonomy` doesn't exist.
2856 2856
  */
2857
-function wp_get_post_terms( $post_id = 0, $taxonomy = 'post_tag', $args = array() ) {
2857
+function wp_get_post_terms($post_id = 0, $taxonomy = 'post_tag', $args = array()) {
2858 2858
 	$post_id = (int) $post_id;
2859 2859
 
2860 2860
 	$defaults = array('fields' => 'all');
2861
-	$args = wp_parse_args( $args, $defaults );
2861
+	$args = wp_parse_args($args, $defaults);
2862 2862
 
2863 2863
 	$tags = wp_get_object_terms($post_id, $taxonomy, $args);
2864 2864
 
@@ -2878,11 +2878,11 @@  discard block
 block discarded – undo
2878 2878
  * @return array|false Array of recent posts, where the type of each element is determined by $output parameter.
2879 2879
  *                     Empty array on failure.
2880 2880
  */
2881
-function wp_get_recent_posts( $args = array(), $output = ARRAY_A ) {
2881
+function wp_get_recent_posts($args = array(), $output = ARRAY_A) {
2882 2882
 
2883
-	if ( is_numeric( $args ) ) {
2884
-		_deprecated_argument( __FUNCTION__, '3.1.0', __( 'Passing an integer number of posts is deprecated. Pass an array of arguments instead.' ) );
2885
-		$args = array( 'numberposts' => absint( $args ) );
2883
+	if (is_numeric($args)) {
2884
+		_deprecated_argument(__FUNCTION__, '3.1.0', __('Passing an integer number of posts is deprecated. Pass an array of arguments instead.'));
2885
+		$args = array('numberposts' => absint($args));
2886 2886
 	}
2887 2887
 
2888 2888
 	// Set default arguments.
@@ -2895,14 +2895,14 @@  discard block
 block discarded – undo
2895 2895
 		'suppress_filters' => true
2896 2896
 	);
2897 2897
 
2898
-	$r = wp_parse_args( $args, $defaults );
2898
+	$r = wp_parse_args($args, $defaults);
2899 2899
 
2900
-	$results = get_posts( $r );
2900
+	$results = get_posts($r);
2901 2901
 
2902 2902
 	// Backward compatibility. Prior to 3.1 expected posts to be returned in array.
2903
-	if ( ARRAY_A == $output ){
2904
-		foreach ( $results as $key => $result ) {
2905
-			$results[$key] = get_object_vars( $result );
2903
+	if (ARRAY_A == $output) {
2904
+		foreach ($results as $key => $result) {
2905
+			$results[$key] = get_object_vars($result);
2906 2906
 		}
2907 2907
 		return $results ? $results : array();
2908 2908
 	}
@@ -2970,7 +2970,7 @@  discard block
 block discarded – undo
2970 2970
  * @param bool  $wp_error Optional. Whether to return a WP_Error on failure. Default false.
2971 2971
  * @return int|WP_Error The post ID on success. The value 0 or WP_Error on failure.
2972 2972
  */
2973
-function wp_insert_post( $postarr, $wp_error = false ) {
2973
+function wp_insert_post($postarr, $wp_error = false) {
2974 2974
 	global $wpdb;
2975 2975
 
2976 2976
 	$user_id = get_current_user_id();
@@ -2997,7 +2997,7 @@  discard block
 block discarded – undo
2997 2997
 
2998 2998
 	$postarr = wp_parse_args($postarr, $defaults);
2999 2999
 
3000
-	unset( $postarr[ 'filter' ] );
3000
+	unset($postarr['filter']);
3001 3001
 
3002 3002
 	$postarr = sanitize_post($postarr, 'db');
3003 3003
 
@@ -3006,42 +3006,42 @@  discard block
 block discarded – undo
3006 3006
 	$update = false;
3007 3007
 	$guid = $postarr['guid'];
3008 3008
 
3009
-	if ( ! empty( $postarr['ID'] ) ) {
3009
+	if ( ! empty($postarr['ID'])) {
3010 3010
 		$update = true;
3011 3011
 
3012 3012
 		// Get the post ID and GUID.
3013 3013
 		$post_ID = $postarr['ID'];
3014
-		$post_before = get_post( $post_ID );
3015
-		if ( is_null( $post_before ) ) {
3016
-			if ( $wp_error ) {
3017
-				return new WP_Error( 'invalid_post', __( 'Invalid post ID.' ) );
3014
+		$post_before = get_post($post_ID);
3015
+		if (is_null($post_before)) {
3016
+			if ($wp_error) {
3017
+				return new WP_Error('invalid_post', __('Invalid post ID.'));
3018 3018
 			}
3019 3019
 			return 0;
3020 3020
 		}
3021 3021
 
3022
-		$guid = get_post_field( 'guid', $post_ID );
3023
-		$previous_status = get_post_field('post_status', $post_ID );
3022
+		$guid = get_post_field('guid', $post_ID);
3023
+		$previous_status = get_post_field('post_status', $post_ID);
3024 3024
 	} else {
3025 3025
 		$previous_status = 'new';
3026 3026
 	}
3027 3027
 
3028
-	$post_type = empty( $postarr['post_type'] ) ? 'post' : $postarr['post_type'];
3028
+	$post_type = empty($postarr['post_type']) ? 'post' : $postarr['post_type'];
3029 3029
 
3030 3030
 	$post_title = $postarr['post_title'];
3031 3031
 	$post_content = $postarr['post_content'];
3032 3032
 	$post_excerpt = $postarr['post_excerpt'];
3033
-	if ( isset( $postarr['post_name'] ) ) {
3033
+	if (isset($postarr['post_name'])) {
3034 3034
 		$post_name = $postarr['post_name'];
3035
-	} elseif ( $update ) {
3035
+	} elseif ($update) {
3036 3036
 		// For an update, don't modify the post_name if it wasn't supplied as an argument.
3037 3037
 		$post_name = $post_before->post_name;
3038 3038
 	}
3039 3039
 
3040 3040
 	$maybe_empty = 'attachment' !== $post_type
3041 3041
 		&& ! $post_content && ! $post_title && ! $post_excerpt
3042
-		&& post_type_supports( $post_type, 'editor' )
3043
-		&& post_type_supports( $post_type, 'title' )
3044
-		&& post_type_supports( $post_type, 'excerpt' );
3042
+		&& post_type_supports($post_type, 'editor')
3043
+		&& post_type_supports($post_type, 'title')
3044
+		&& post_type_supports($post_type, 'excerpt');
3045 3045
 
3046 3046
 	/**
3047 3047
 	 * Filters whether the post should be considered "empty".
@@ -3059,36 +3059,36 @@  discard block
 block discarded – undo
3059 3059
 	 * @param bool  $maybe_empty Whether the post should be considered "empty".
3060 3060
 	 * @param array $postarr     Array of post data.
3061 3061
 	 */
3062
-	if ( apply_filters( 'wp_insert_post_empty_content', $maybe_empty, $postarr ) ) {
3063
-		if ( $wp_error ) {
3064
-			return new WP_Error( 'empty_content', __( 'Content, title, and excerpt are empty.' ) );
3062
+	if (apply_filters('wp_insert_post_empty_content', $maybe_empty, $postarr)) {
3063
+		if ($wp_error) {
3064
+			return new WP_Error('empty_content', __('Content, title, and excerpt are empty.'));
3065 3065
 		} else {
3066 3066
 			return 0;
3067 3067
 		}
3068 3068
 	}
3069 3069
 
3070
-	$post_status = empty( $postarr['post_status'] ) ? 'draft' : $postarr['post_status'];
3071
-	if ( 'attachment' === $post_type && ! in_array( $post_status, array( 'inherit', 'private', 'trash', 'auto-draft' ), true ) ) {
3070
+	$post_status = empty($postarr['post_status']) ? 'draft' : $postarr['post_status'];
3071
+	if ('attachment' === $post_type && ! in_array($post_status, array('inherit', 'private', 'trash', 'auto-draft'), true)) {
3072 3072
 		$post_status = 'inherit';
3073 3073
 	}
3074 3074
 
3075
-	if ( ! empty( $postarr['post_category'] ) ) {
3075
+	if ( ! empty($postarr['post_category'])) {
3076 3076
 		// Filter out empty terms.
3077
-		$post_category = array_filter( $postarr['post_category'] );
3077
+		$post_category = array_filter($postarr['post_category']);
3078 3078
 	}
3079 3079
 
3080 3080
 	// Make sure we set a valid category.
3081
-	if ( empty( $post_category ) || 0 == count( $post_category ) || ! is_array( $post_category ) ) {
3081
+	if (empty($post_category) || 0 == count($post_category) || ! is_array($post_category)) {
3082 3082
 		// 'post' requires at least one category.
3083
-		if ( 'post' == $post_type && 'auto-draft' != $post_status ) {
3084
-			$post_category = array( get_option('default_category') );
3083
+		if ('post' == $post_type && 'auto-draft' != $post_status) {
3084
+			$post_category = array(get_option('default_category'));
3085 3085
 		} else {
3086 3086
 			$post_category = array();
3087 3087
 		}
3088 3088
 	}
3089 3089
 
3090 3090
 	// Don't allow contributors to set the post slug for pending review posts.
3091
-	if ( 'pending' == $post_status && !current_user_can( 'publish_posts' ) ) {
3091
+	if ('pending' == $post_status && ! current_user_can('publish_posts')) {
3092 3092
 		$post_name = '';
3093 3093
 	}
3094 3094
 
@@ -3096,16 +3096,16 @@  discard block
 block discarded – undo
3096 3096
 	 * Create a valid post name. Drafts and pending posts are allowed to have
3097 3097
 	 * an empty post name.
3098 3098
 	 */
3099
-	if ( empty($post_name) ) {
3100
-		if ( !in_array( $post_status, array( 'draft', 'pending', 'auto-draft' ) ) ) {
3099
+	if (empty($post_name)) {
3100
+		if ( ! in_array($post_status, array('draft', 'pending', 'auto-draft'))) {
3101 3101
 			$post_name = sanitize_title($post_title);
3102 3102
 		} else {
3103 3103
 			$post_name = '';
3104 3104
 		}
3105 3105
 	} else {
3106 3106
 		// On updates, we need to check to see if it's using the old, fixed sanitization context.
3107
-		$check_name = sanitize_title( $post_name, '', 'old-save' );
3108
-		if ( $update && strtolower( urlencode( $post_name ) ) == $check_name && get_post_field( 'post_name', $post_ID ) == $check_name ) {
3107
+		$check_name = sanitize_title($post_name, '', 'old-save');
3108
+		if ($update && strtolower(urlencode($post_name)) == $check_name && get_post_field('post_name', $post_ID) == $check_name) {
3109 3109
 			$post_name = $check_name;
3110 3110
 		} else { // new post, or slug has changed.
3111 3111
 			$post_name = sanitize_title($post_name);
@@ -3116,32 +3116,32 @@  discard block
 block discarded – undo
3116 3116
 	 * If the post date is empty (due to having been new or a draft) and status
3117 3117
 	 * is not 'draft' or 'pending', set date to now.
3118 3118
 	 */
3119
-	if ( empty( $postarr['post_date'] ) || '0000-00-00 00:00:00' == $postarr['post_date'] ) {
3120
-		if ( empty( $postarr['post_date_gmt'] ) || '0000-00-00 00:00:00' == $postarr['post_date_gmt'] ) {
3121
-			$post_date = current_time( 'mysql' );
3119
+	if (empty($postarr['post_date']) || '0000-00-00 00:00:00' == $postarr['post_date']) {
3120
+		if (empty($postarr['post_date_gmt']) || '0000-00-00 00:00:00' == $postarr['post_date_gmt']) {
3121
+			$post_date = current_time('mysql');
3122 3122
 		} else {
3123
-			$post_date = get_date_from_gmt( $postarr['post_date_gmt'] );
3123
+			$post_date = get_date_from_gmt($postarr['post_date_gmt']);
3124 3124
 		}
3125 3125
 	} else {
3126 3126
 		$post_date = $postarr['post_date'];
3127 3127
 	}
3128 3128
 
3129 3129
 	// Validate the date.
3130
-	$mm = substr( $post_date, 5, 2 );
3131
-	$jj = substr( $post_date, 8, 2 );
3132
-	$aa = substr( $post_date, 0, 4 );
3133
-	$valid_date = wp_checkdate( $mm, $jj, $aa, $post_date );
3134
-	if ( ! $valid_date ) {
3135
-		if ( $wp_error ) {
3136
-			return new WP_Error( 'invalid_date', __( 'Invalid date.' ) );
3130
+	$mm = substr($post_date, 5, 2);
3131
+	$jj = substr($post_date, 8, 2);
3132
+	$aa = substr($post_date, 0, 4);
3133
+	$valid_date = wp_checkdate($mm, $jj, $aa, $post_date);
3134
+	if ( ! $valid_date) {
3135
+		if ($wp_error) {
3136
+			return new WP_Error('invalid_date', __('Invalid date.'));
3137 3137
 		} else {
3138 3138
 			return 0;
3139 3139
 		}
3140 3140
 	}
3141 3141
 
3142
-	if ( empty( $postarr['post_date_gmt'] ) || '0000-00-00 00:00:00' == $postarr['post_date_gmt'] ) {
3143
-		if ( ! in_array( $post_status, array( 'draft', 'pending', 'auto-draft' ) ) ) {
3144
-			$post_date_gmt = get_gmt_from_date( $post_date );
3142
+	if (empty($postarr['post_date_gmt']) || '0000-00-00 00:00:00' == $postarr['post_date_gmt']) {
3143
+		if ( ! in_array($post_status, array('draft', 'pending', 'auto-draft'))) {
3144
+			$post_date_gmt = get_gmt_from_date($post_date);
3145 3145
 		} else {
3146 3146
 			$post_date_gmt = '0000-00-00 00:00:00';
3147 3147
 		}
@@ -3149,34 +3149,34 @@  discard block
 block discarded – undo
3149 3149
 		$post_date_gmt = $postarr['post_date_gmt'];
3150 3150
 	}
3151 3151
 
3152
-	if ( $update || '0000-00-00 00:00:00' == $post_date ) {
3153
-		$post_modified     = current_time( 'mysql' );
3154
-		$post_modified_gmt = current_time( 'mysql', 1 );
3152
+	if ($update || '0000-00-00 00:00:00' == $post_date) {
3153
+		$post_modified     = current_time('mysql');
3154
+		$post_modified_gmt = current_time('mysql', 1);
3155 3155
 	} else {
3156 3156
 		$post_modified     = $post_date;
3157 3157
 		$post_modified_gmt = $post_date_gmt;
3158 3158
 	}
3159 3159
 
3160
-	if ( 'attachment' !== $post_type ) {
3161
-		if ( 'publish' == $post_status ) {
3160
+	if ('attachment' !== $post_type) {
3161
+		if ('publish' == $post_status) {
3162 3162
 			$now = gmdate('Y-m-d H:i:59');
3163
-			if ( mysql2date('U', $post_date_gmt, false) > mysql2date('U', $now, false) ) {
3163
+			if (mysql2date('U', $post_date_gmt, false) > mysql2date('U', $now, false)) {
3164 3164
 				$post_status = 'future';
3165 3165
 			}
3166
-		} elseif ( 'future' == $post_status ) {
3166
+		} elseif ('future' == $post_status) {
3167 3167
 			$now = gmdate('Y-m-d H:i:59');
3168
-			if ( mysql2date('U', $post_date_gmt, false) <= mysql2date('U', $now, false) ) {
3168
+			if (mysql2date('U', $post_date_gmt, false) <= mysql2date('U', $now, false)) {
3169 3169
 				$post_status = 'publish';
3170 3170
 			}
3171 3171
 		}
3172 3172
 	}
3173 3173
 
3174 3174
 	// Comment status.
3175
-	if ( empty( $postarr['comment_status'] ) ) {
3176
-		if ( $update ) {
3175
+	if (empty($postarr['comment_status'])) {
3176
+		if ($update) {
3177 3177
 			$comment_status = 'closed';
3178 3178
 		} else {
3179
-			$comment_status = get_default_comment_status( $post_type );
3179
+			$comment_status = get_default_comment_status($post_type);
3180 3180
 		}
3181 3181
 	} else {
3182 3182
 		$comment_status = $postarr['comment_status'];
@@ -3184,28 +3184,28 @@  discard block
 block discarded – undo
3184 3184
 
3185 3185
 	// These variables are needed by compact() later.
3186 3186
 	$post_content_filtered = $postarr['post_content_filtered'];
3187
-	$post_author = isset( $postarr['post_author'] ) ? $postarr['post_author'] : $user_id;
3188
-	$ping_status = empty( $postarr['ping_status'] ) ? get_default_comment_status( $post_type, 'pingback' ) : $postarr['ping_status'];
3189
-	$to_ping = isset( $postarr['to_ping'] ) ? sanitize_trackback_urls( $postarr['to_ping'] ) : '';
3190
-	$pinged = isset( $postarr['pinged'] ) ? $postarr['pinged'] : '';
3191
-	$import_id = isset( $postarr['import_id'] ) ? $postarr['import_id'] : 0;
3187
+	$post_author = isset($postarr['post_author']) ? $postarr['post_author'] : $user_id;
3188
+	$ping_status = empty($postarr['ping_status']) ? get_default_comment_status($post_type, 'pingback') : $postarr['ping_status'];
3189
+	$to_ping = isset($postarr['to_ping']) ? sanitize_trackback_urls($postarr['to_ping']) : '';
3190
+	$pinged = isset($postarr['pinged']) ? $postarr['pinged'] : '';
3191
+	$import_id = isset($postarr['import_id']) ? $postarr['import_id'] : 0;
3192 3192
 
3193 3193
 	/*
3194 3194
 	 * The 'wp_insert_post_parent' filter expects all variables to be present.
3195 3195
 	 * Previously, these variables would have already been extracted
3196 3196
 	 */
3197
-	if ( isset( $postarr['menu_order'] ) ) {
3197
+	if (isset($postarr['menu_order'])) {
3198 3198
 		$menu_order = (int) $postarr['menu_order'];
3199 3199
 	} else {
3200 3200
 		$menu_order = 0;
3201 3201
 	}
3202 3202
 
3203
-	$post_password = isset( $postarr['post_password'] ) ? $postarr['post_password'] : '';
3204
-	if ( 'private' == $post_status ) {
3203
+	$post_password = isset($postarr['post_password']) ? $postarr['post_password'] : '';
3204
+	if ('private' == $post_status) {
3205 3205
 		$post_password = '';
3206 3206
 	}
3207 3207
 
3208
-	if ( isset( $postarr['post_parent'] ) ) {
3208
+	if (isset($postarr['post_parent'])) {
3209 3209
 		$post_parent = (int) $postarr['post_parent'];
3210 3210
 	} else {
3211 3211
 		$post_parent = 0;
@@ -3221,50 +3221,50 @@  discard block
 block discarded – undo
3221 3221
 	 * @param array $new_postarr Array of parsed post data.
3222 3222
 	 * @param array $postarr     Array of sanitized, but otherwise unmodified post data.
3223 3223
 	 */
3224
-	$post_parent = apply_filters( 'wp_insert_post_parent', $post_parent, $post_ID, compact( array_keys( $postarr ) ), $postarr );
3224
+	$post_parent = apply_filters('wp_insert_post_parent', $post_parent, $post_ID, compact(array_keys($postarr)), $postarr);
3225 3225
 
3226 3226
 	/*
3227 3227
 	 * If the post is being untrashed and it has a desired slug stored in post meta,
3228 3228
 	 * reassign it.
3229 3229
 	 */
3230
-	if ( 'trash' === $previous_status && 'trash' !== $post_status ) {
3231
-		$desired_post_slug = get_post_meta( $post_ID, '_wp_desired_post_slug', true );
3232
-		if ( $desired_post_slug ) {
3233
-			delete_post_meta( $post_ID, '_wp_desired_post_slug' );
3230
+	if ('trash' === $previous_status && 'trash' !== $post_status) {
3231
+		$desired_post_slug = get_post_meta($post_ID, '_wp_desired_post_slug', true);
3232
+		if ($desired_post_slug) {
3233
+			delete_post_meta($post_ID, '_wp_desired_post_slug');
3234 3234
 			$post_name = $desired_post_slug;
3235 3235
 		}
3236 3236
 	}
3237 3237
 
3238 3238
 	// If a trashed post has the desired slug, change it and let this post have it.
3239
-	if ( 'trash' !== $post_status && $post_name ) {
3240
-		wp_add_trashed_suffix_to_post_name_for_trashed_posts( $post_name, $post_ID );
3239
+	if ('trash' !== $post_status && $post_name) {
3240
+		wp_add_trashed_suffix_to_post_name_for_trashed_posts($post_name, $post_ID);
3241 3241
 	}
3242 3242
 
3243 3243
 	// When trashing an existing post, change its slug to allow non-trashed posts to use it.
3244
-	if ( 'trash' === $post_status && 'trash' !== $previous_status && 'new' !== $previous_status ) {
3245
-		$post_name = wp_add_trashed_suffix_to_post_name_for_post( $post_ID );
3244
+	if ('trash' === $post_status && 'trash' !== $previous_status && 'new' !== $previous_status) {
3245
+		$post_name = wp_add_trashed_suffix_to_post_name_for_post($post_ID);
3246 3246
 	}
3247 3247
 
3248
-	$post_name = wp_unique_post_slug( $post_name, $post_ID, $post_status, $post_type, $post_parent );
3248
+	$post_name = wp_unique_post_slug($post_name, $post_ID, $post_status, $post_type, $post_parent);
3249 3249
 
3250 3250
 	// Don't unslash.
3251
-	$post_mime_type = isset( $postarr['post_mime_type'] ) ? $postarr['post_mime_type'] : '';
3251
+	$post_mime_type = isset($postarr['post_mime_type']) ? $postarr['post_mime_type'] : '';
3252 3252
 
3253 3253
 	// Expected_slashed (everything!).
3254
-	$data = compact( 'post_author', 'post_date', 'post_date_gmt', 'post_content', 'post_content_filtered', 'post_title', 'post_excerpt', 'post_status', 'post_type', 'comment_status', 'ping_status', 'post_password', 'post_name', 'to_ping', 'pinged', 'post_modified', 'post_modified_gmt', 'post_parent', 'menu_order', 'post_mime_type', 'guid' );
3254
+	$data = compact('post_author', 'post_date', 'post_date_gmt', 'post_content', 'post_content_filtered', 'post_title', 'post_excerpt', 'post_status', 'post_type', 'comment_status', 'ping_status', 'post_password', 'post_name', 'to_ping', 'pinged', 'post_modified', 'post_modified_gmt', 'post_parent', 'menu_order', 'post_mime_type', 'guid');
3255 3255
 
3256
-	$emoji_fields = array( 'post_title', 'post_content', 'post_excerpt' );
3256
+	$emoji_fields = array('post_title', 'post_content', 'post_excerpt');
3257 3257
 
3258
-	foreach ( $emoji_fields as $emoji_field ) {
3259
-		if ( isset( $data[ $emoji_field ] ) ) {
3260
-			$charset = $wpdb->get_col_charset( $wpdb->posts, $emoji_field );
3261
-			if ( 'utf8' === $charset ) {
3262
-				$data[ $emoji_field ] = wp_encode_emoji( $data[ $emoji_field ] );
3258
+	foreach ($emoji_fields as $emoji_field) {
3259
+		if (isset($data[$emoji_field])) {
3260
+			$charset = $wpdb->get_col_charset($wpdb->posts, $emoji_field);
3261
+			if ('utf8' === $charset) {
3262
+				$data[$emoji_field] = wp_encode_emoji($data[$emoji_field]);
3263 3263
 			}
3264 3264
 		}
3265 3265
 	}
3266 3266
 
3267
-	if ( 'attachment' === $post_type ) {
3267
+	if ('attachment' === $post_type) {
3268 3268
 		/**
3269 3269
 		 * Filters attachment post data before it is updated in or added to the database.
3270 3270
 		 *
@@ -3273,7 +3273,7 @@  discard block
 block discarded – undo
3273 3273
 		 * @param array $data    An array of sanitized attachment post data.
3274 3274
 		 * @param array $postarr An array of unsanitized attachment post data.
3275 3275
 		 */
3276
-		$data = apply_filters( 'wp_insert_attachment_data', $data, $postarr );
3276
+		$data = apply_filters('wp_insert_attachment_data', $data, $postarr);
3277 3277
 	} else {
3278 3278
 		/**
3279 3279
 		 * Filters slashed post data just before it is inserted into the database.
@@ -3283,12 +3283,12 @@  discard block
 block discarded – undo
3283 3283
 		 * @param array $data    An array of slashed post data.
3284 3284
 		 * @param array $postarr An array of sanitized, but otherwise unmodified post data.
3285 3285
 		 */
3286
-		$data = apply_filters( 'wp_insert_post_data', $data, $postarr );
3286
+		$data = apply_filters('wp_insert_post_data', $data, $postarr);
3287 3287
 	}
3288
-	$data = wp_unslash( $data );
3289
-	$where = array( 'ID' => $post_ID );
3288
+	$data = wp_unslash($data);
3289
+	$where = array('ID' => $post_ID);
3290 3290
 
3291
-	if ( $update ) {
3291
+	if ($update) {
3292 3292
 		/**
3293 3293
 		 * Fires immediately before an existing post is updated in the database.
3294 3294
 		 *
@@ -3297,9 +3297,9 @@  discard block
 block discarded – undo
3297 3297
 		 * @param int   $post_ID Post ID.
3298 3298
 		 * @param array $data    Array of unslashed post data.
3299 3299
 		 */
3300
-		do_action( 'pre_post_update', $post_ID, $data );
3301
-		if ( false === $wpdb->update( $wpdb->posts, $data, $where ) ) {
3302
-			if ( $wp_error ) {
3300
+		do_action('pre_post_update', $post_ID, $data);
3301
+		if (false === $wpdb->update($wpdb->posts, $data, $where)) {
3302
+			if ($wp_error) {
3303 3303
 				return new WP_Error('db_update_error', __('Could not update post in the database'), $wpdb->last_error);
3304 3304
 			} else {
3305 3305
 				return 0;
@@ -3307,14 +3307,14 @@  discard block
 block discarded – undo
3307 3307
 		}
3308 3308
 	} else {
3309 3309
 		// If there is a suggested ID, use it if not already present.
3310
-		if ( ! empty( $import_id ) ) {
3310
+		if ( ! empty($import_id)) {
3311 3311
 			$import_id = (int) $import_id;
3312
-			if ( ! $wpdb->get_var( $wpdb->prepare("SELECT ID FROM $wpdb->posts WHERE ID = %d", $import_id) ) ) {
3312
+			if ( ! $wpdb->get_var($wpdb->prepare("SELECT ID FROM $wpdb->posts WHERE ID = %d", $import_id))) {
3313 3313
 				$data['ID'] = $import_id;
3314 3314
 			}
3315 3315
 		}
3316
-		if ( false === $wpdb->insert( $wpdb->posts, $data ) ) {
3317
-			if ( $wp_error ) {
3316
+		if (false === $wpdb->insert($wpdb->posts, $data)) {
3317
+			if ($wp_error) {
3318 3318
 				return new WP_Error('db_insert_error', __('Could not insert post into the database'), $wpdb->last_error);
3319 3319
 			} else {
3320 3320
 				return 0;
@@ -3323,108 +3323,108 @@  discard block
 block discarded – undo
3323 3323
 		$post_ID = (int) $wpdb->insert_id;
3324 3324
 
3325 3325
 		// Use the newly generated $post_ID.
3326
-		$where = array( 'ID' => $post_ID );
3326
+		$where = array('ID' => $post_ID);
3327 3327
 	}
3328 3328
 
3329
-	if ( empty( $data['post_name'] ) && ! in_array( $data['post_status'], array( 'draft', 'pending', 'auto-draft' ) ) ) {
3330
-		$data['post_name'] = wp_unique_post_slug( sanitize_title( $data['post_title'], $post_ID ), $post_ID, $data['post_status'], $post_type, $post_parent );
3331
-		$wpdb->update( $wpdb->posts, array( 'post_name' => $data['post_name'] ), $where );
3332
-		clean_post_cache( $post_ID );
3329
+	if (empty($data['post_name']) && ! in_array($data['post_status'], array('draft', 'pending', 'auto-draft'))) {
3330
+		$data['post_name'] = wp_unique_post_slug(sanitize_title($data['post_title'], $post_ID), $post_ID, $data['post_status'], $post_type, $post_parent);
3331
+		$wpdb->update($wpdb->posts, array('post_name' => $data['post_name']), $where);
3332
+		clean_post_cache($post_ID);
3333 3333
 	}
3334 3334
 
3335
-	if ( is_object_in_taxonomy( $post_type, 'category' ) ) {
3336
-		wp_set_post_categories( $post_ID, $post_category );
3335
+	if (is_object_in_taxonomy($post_type, 'category')) {
3336
+		wp_set_post_categories($post_ID, $post_category);
3337 3337
 	}
3338 3338
 
3339
-	if ( isset( $postarr['tags_input'] ) && is_object_in_taxonomy( $post_type, 'post_tag' ) ) {
3340
-		wp_set_post_tags( $post_ID, $postarr['tags_input'] );
3339
+	if (isset($postarr['tags_input']) && is_object_in_taxonomy($post_type, 'post_tag')) {
3340
+		wp_set_post_tags($post_ID, $postarr['tags_input']);
3341 3341
 	}
3342 3342
 
3343 3343
 	// New-style support for all custom taxonomies.
3344
-	if ( ! empty( $postarr['tax_input'] ) ) {
3345
-		foreach ( $postarr['tax_input'] as $taxonomy => $tags ) {
3344
+	if ( ! empty($postarr['tax_input'])) {
3345
+		foreach ($postarr['tax_input'] as $taxonomy => $tags) {
3346 3346
 			$taxonomy_obj = get_taxonomy($taxonomy);
3347
-			if ( ! $taxonomy_obj ) {
3347
+			if ( ! $taxonomy_obj) {
3348 3348
 				/* translators: %s: taxonomy name */
3349
-				_doing_it_wrong( __FUNCTION__, sprintf( __( 'Invalid taxonomy: %s.' ), $taxonomy ), '4.4.0' );
3349
+				_doing_it_wrong(__FUNCTION__, sprintf(__('Invalid taxonomy: %s.'), $taxonomy), '4.4.0');
3350 3350
 				continue;
3351 3351
 			}
3352 3352
 
3353 3353
 			// array = hierarchical, string = non-hierarchical.
3354
-			if ( is_array( $tags ) ) {
3354
+			if (is_array($tags)) {
3355 3355
 				$tags = array_filter($tags);
3356 3356
 			}
3357
-			if ( current_user_can( $taxonomy_obj->cap->assign_terms ) ) {
3358
-				wp_set_post_terms( $post_ID, $tags, $taxonomy );
3357
+			if (current_user_can($taxonomy_obj->cap->assign_terms)) {
3358
+				wp_set_post_terms($post_ID, $tags, $taxonomy);
3359 3359
 			}
3360 3360
 		}
3361 3361
 	}
3362 3362
 
3363
-	if ( ! empty( $postarr['meta_input'] ) ) {
3364
-		foreach ( $postarr['meta_input'] as $field => $value ) {
3365
-			update_post_meta( $post_ID, $field, $value );
3363
+	if ( ! empty($postarr['meta_input'])) {
3364
+		foreach ($postarr['meta_input'] as $field => $value) {
3365
+			update_post_meta($post_ID, $field, $value);
3366 3366
 		}
3367 3367
 	}
3368 3368
 
3369
-	$current_guid = get_post_field( 'guid', $post_ID );
3369
+	$current_guid = get_post_field('guid', $post_ID);
3370 3370
 
3371 3371
 	// Set GUID.
3372
-	if ( ! $update && '' == $current_guid ) {
3373
-		$wpdb->update( $wpdb->posts, array( 'guid' => get_permalink( $post_ID ) ), $where );
3372
+	if ( ! $update && '' == $current_guid) {
3373
+		$wpdb->update($wpdb->posts, array('guid' => get_permalink($post_ID)), $where);
3374 3374
 	}
3375 3375
 
3376
-	if ( 'attachment' === $postarr['post_type'] ) {
3377
-		if ( ! empty( $postarr['file'] ) ) {
3378
-			update_attached_file( $post_ID, $postarr['file'] );
3376
+	if ('attachment' === $postarr['post_type']) {
3377
+		if ( ! empty($postarr['file'])) {
3378
+			update_attached_file($post_ID, $postarr['file']);
3379 3379
 		}
3380 3380
 
3381
-		if ( ! empty( $postarr['context'] ) ) {
3382
-			add_post_meta( $post_ID, '_wp_attachment_context', $postarr['context'], true );
3381
+		if ( ! empty($postarr['context'])) {
3382
+			add_post_meta($post_ID, '_wp_attachment_context', $postarr['context'], true);
3383 3383
 		}
3384 3384
 	}
3385 3385
 
3386 3386
 	// Set or remove featured image.
3387
-	if ( isset( $postarr['_thumbnail_id'] ) ) {
3388
-		$thumbnail_support = current_theme_supports( 'post-thumbnails', $post_type ) && post_type_supports( $post_type, 'thumbnail' ) || 'revision' === $post_type;
3389
-		if ( ! $thumbnail_support && 'attachment' === $post_type && $post_mime_type ) {
3390
-			if ( wp_attachment_is( 'audio', $post_ID ) ) {
3391
-				$thumbnail_support = post_type_supports( 'attachment:audio', 'thumbnail' ) || current_theme_supports( 'post-thumbnails', 'attachment:audio' );
3392
-			} elseif ( wp_attachment_is( 'video', $post_ID ) ) {
3393
-				$thumbnail_support = post_type_supports( 'attachment:video', 'thumbnail' ) || current_theme_supports( 'post-thumbnails', 'attachment:video' );
3387
+	if (isset($postarr['_thumbnail_id'])) {
3388
+		$thumbnail_support = current_theme_supports('post-thumbnails', $post_type) && post_type_supports($post_type, 'thumbnail') || 'revision' === $post_type;
3389
+		if ( ! $thumbnail_support && 'attachment' === $post_type && $post_mime_type) {
3390
+			if (wp_attachment_is('audio', $post_ID)) {
3391
+				$thumbnail_support = post_type_supports('attachment:audio', 'thumbnail') || current_theme_supports('post-thumbnails', 'attachment:audio');
3392
+			} elseif (wp_attachment_is('video', $post_ID)) {
3393
+				$thumbnail_support = post_type_supports('attachment:video', 'thumbnail') || current_theme_supports('post-thumbnails', 'attachment:video');
3394 3394
 			}
3395 3395
 		}
3396 3396
 
3397
-		if ( $thumbnail_support ) {
3398
-			$thumbnail_id = intval( $postarr['_thumbnail_id'] );
3397
+		if ($thumbnail_support) {
3398
+			$thumbnail_id = intval($postarr['_thumbnail_id']);
3399 3399
 			if ( -1 === $thumbnail_id ) {
3400
-				delete_post_thumbnail( $post_ID );
3400
+				delete_post_thumbnail($post_ID);
3401 3401
 			} else {
3402
-				set_post_thumbnail( $post_ID, $thumbnail_id );
3402
+				set_post_thumbnail($post_ID, $thumbnail_id);
3403 3403
 			}
3404 3404
 		}
3405 3405
 	}
3406 3406
 
3407
-	clean_post_cache( $post_ID );
3407
+	clean_post_cache($post_ID);
3408 3408
 
3409
-	$post = get_post( $post_ID );
3409
+	$post = get_post($post_ID);
3410 3410
 
3411
-	if ( ! empty( $postarr['page_template'] ) ) {
3411
+	if ( ! empty($postarr['page_template'])) {
3412 3412
 		$post->page_template = $postarr['page_template'];
3413
-		$page_templates = wp_get_theme()->get_page_templates( $post );
3414
-		if ( 'default' != $postarr['page_template'] && ! isset( $page_templates[ $postarr['page_template'] ] ) ) {
3415
-			if ( $wp_error ) {
3416
-				return new WP_Error( 'invalid_page_template', __( 'Invalid page template.' ) );
3413
+		$page_templates = wp_get_theme()->get_page_templates($post);
3414
+		if ('default' != $postarr['page_template'] && ! isset($page_templates[$postarr['page_template']])) {
3415
+			if ($wp_error) {
3416
+				return new WP_Error('invalid_page_template', __('Invalid page template.'));
3417 3417
 			}
3418
-			update_post_meta( $post_ID, '_wp_page_template', 'default' );
3418
+			update_post_meta($post_ID, '_wp_page_template', 'default');
3419 3419
 		} else {
3420
-			update_post_meta( $post_ID, '_wp_page_template', $postarr['page_template'] );
3420
+			update_post_meta($post_ID, '_wp_page_template', $postarr['page_template']);
3421 3421
 		}
3422 3422
 	}
3423 3423
 
3424
-	if ( 'attachment' !== $postarr['post_type'] ) {
3425
-		wp_transition_post_status( $data['post_status'], $previous_status, $post );
3424
+	if ('attachment' !== $postarr['post_type']) {
3425
+		wp_transition_post_status($data['post_status'], $previous_status, $post);
3426 3426
 	} else {
3427
-		if ( $update ) {
3427
+		if ($update) {
3428 3428
 			/**
3429 3429
 			 * Fires once an existing attachment has been updated.
3430 3430
 			 *
@@ -3432,8 +3432,8 @@  discard block
 block discarded – undo
3432 3432
 			 *
3433 3433
 			 * @param int $post_ID Attachment ID.
3434 3434
 			 */
3435
-			do_action( 'edit_attachment', $post_ID );
3436
-			$post_after = get_post( $post_ID );
3435
+			do_action('edit_attachment', $post_ID);
3436
+			$post_after = get_post($post_ID);
3437 3437
 
3438 3438
 			/**
3439 3439
 			 * Fires once an existing attachment has been updated.
@@ -3444,7 +3444,7 @@  discard block
 block discarded – undo
3444 3444
 			 * @param WP_Post $post_after   Post object following the update.
3445 3445
 			 * @param WP_Post $post_before  Post object before the update.
3446 3446
 			 */
3447
-			do_action( 'attachment_updated', $post_ID, $post_after, $post_before );
3447
+			do_action('attachment_updated', $post_ID, $post_after, $post_before);
3448 3448
 		} else {
3449 3449
 
3450 3450
 			/**
@@ -3454,13 +3454,13 @@  discard block
 block discarded – undo
3454 3454
 			 *
3455 3455
 			 * @param int $post_ID Attachment ID.
3456 3456
 			 */
3457
-			do_action( 'add_attachment', $post_ID );
3457
+			do_action('add_attachment', $post_ID);
3458 3458
 		}
3459 3459
 
3460 3460
 		return $post_ID;
3461 3461
 	}
3462 3462
 
3463
-	if ( $update ) {
3463
+	if ($update) {
3464 3464
 		/**
3465 3465
 		 * Fires once an existing post has been updated.
3466 3466
 		 *
@@ -3469,7 +3469,7 @@  discard block
 block discarded – undo
3469 3469
 		 * @param int     $post_ID Post ID.
3470 3470
 		 * @param WP_Post $post    Post object.
3471 3471
 		 */
3472
-		do_action( 'edit_post', $post_ID, $post );
3472
+		do_action('edit_post', $post_ID, $post);
3473 3473
 		$post_after = get_post($post_ID);
3474 3474
 
3475 3475
 		/**
@@ -3481,7 +3481,7 @@  discard block
 block discarded – undo
3481 3481
 		 * @param WP_Post $post_after   Post object following the update.
3482 3482
 		 * @param WP_Post $post_before  Post object before the update.
3483 3483
 		 */
3484
-		do_action( 'post_updated', $post_ID, $post_after, $post_before);
3484
+		do_action('post_updated', $post_ID, $post_after, $post_before);
3485 3485
 	}
3486 3486
 
3487 3487
 	/**
@@ -3496,7 +3496,7 @@  discard block
 block discarded – undo
3496 3496
 	 * @param WP_Post $post    Post object.
3497 3497
 	 * @param bool    $update  Whether this is an existing post being updated or not.
3498 3498
 	 */
3499
-	do_action( "save_post_{$post->post_type}", $post_ID, $post, $update );
3499
+	do_action("save_post_{$post->post_type}", $post_ID, $post, $update);
3500 3500
 
3501 3501
 	/**
3502 3502
 	 * Fires once a post has been saved.
@@ -3507,7 +3507,7 @@  discard block
 block discarded – undo
3507 3507
 	 * @param WP_Post $post    Post object.
3508 3508
 	 * @param bool    $update  Whether this is an existing post being updated or not.
3509 3509
 	 */
3510
-	do_action( 'save_post', $post_ID, $post, $update );
3510
+	do_action('save_post', $post_ID, $post, $update);
3511 3511
 
3512 3512
 	/**
3513 3513
 	 * Fires once a post has been saved.
@@ -3518,7 +3518,7 @@  discard block
 block discarded – undo
3518 3518
 	 * @param WP_Post $post    Post object.
3519 3519
 	 * @param bool    $update  Whether this is an existing post being updated or not.
3520 3520
 	 */
3521
-	do_action( 'wp_insert_post', $post_ID, $post, $update );
3521
+	do_action('wp_insert_post', $post_ID, $post, $update);
3522 3522
 
3523 3523
 	return $post_ID;
3524 3524
 }
@@ -3536,8 +3536,8 @@  discard block
 block discarded – undo
3536 3536
  * @param bool         $wp_error Optional. Allow return of WP_Error on failure. Default false.
3537 3537
  * @return int|WP_Error The value 0 or WP_Error on failure. The post ID on success.
3538 3538
  */
3539
-function wp_update_post( $postarr = array(), $wp_error = false ) {
3540
-	if ( is_object($postarr) ) {
3539
+function wp_update_post($postarr = array(), $wp_error = false) {
3540
+	if (is_object($postarr)) {
3541 3541
 		// Non-escaped post was passed.
3542 3542
 		$postarr = get_object_vars($postarr);
3543 3543
 		$postarr = wp_slash($postarr);
@@ -3546,9 +3546,9 @@  discard block
 block discarded – undo
3546 3546
 	// First, get all of the original fields.
3547 3547
 	$post = get_post($postarr['ID'], ARRAY_A);
3548 3548
 
3549
-	if ( is_null( $post ) ) {
3550
-		if ( $wp_error )
3551
-			return new WP_Error( 'invalid_post', __( 'Invalid post ID.' ) );
3549
+	if (is_null($post)) {
3550
+		if ($wp_error)
3551
+			return new WP_Error('invalid_post', __('Invalid post ID.'));
3552 3552
 		return 0;
3553 3553
 	}
3554 3554
 
@@ -3556,15 +3556,15 @@  discard block
 block discarded – undo
3556 3556
 	$post = wp_slash($post);
3557 3557
 
3558 3558
 	// Passed post category list overwrites existing category list if not empty.
3559
-	if ( isset($postarr['post_category']) && is_array($postarr['post_category'])
3560
-			 && 0 != count($postarr['post_category']) )
3559
+	if (isset($postarr['post_category']) && is_array($postarr['post_category'])
3560
+			 && 0 != count($postarr['post_category']))
3561 3561
 		$post_cats = $postarr['post_category'];
3562 3562
 	else
3563 3563
 		$post_cats = $post['post_category'];
3564 3564
 
3565 3565
 	// Drafts shouldn't be assigned a date unless explicitly done so by the user.
3566
-	if ( isset( $post['post_status'] ) && in_array($post['post_status'], array('draft', 'pending', 'auto-draft')) && empty($postarr['edit_date']) &&
3567
-			 ('0000-00-00 00:00:00' == $post['post_date_gmt']) )
3566
+	if (isset($post['post_status']) && in_array($post['post_status'], array('draft', 'pending', 'auto-draft')) && empty($postarr['edit_date']) &&
3567
+			 ('0000-00-00 00:00:00' == $post['post_date_gmt']))
3568 3568
 		$clear_date = true;
3569 3569
 	else
3570 3570
 		$clear_date = false;
@@ -3572,7 +3572,7 @@  discard block
 block discarded – undo
3572 3572
 	// Merge old and new fields with new fields overwriting old ones.
3573 3573
 	$postarr = array_merge($post, $postarr);
3574 3574
 	$postarr['post_category'] = $post_cats;
3575
-	if ( $clear_date ) {
3575
+	if ($clear_date) {
3576 3576
 		$postarr['post_date'] = current_time('mysql');
3577 3577
 		$postarr['post_date_gmt'] = '';
3578 3578
 	}
@@ -3580,7 +3580,7 @@  discard block
 block discarded – undo
3580 3580
 	if ($postarr['post_type'] == 'attachment')
3581 3581
 		return wp_insert_attachment($postarr);
3582 3582
 
3583
-	return wp_insert_post( $postarr, $wp_error );
3583
+	return wp_insert_post($postarr, $wp_error);
3584 3584
 }
3585 3585
 
3586 3586
 /**
@@ -3592,34 +3592,34 @@  discard block
 block discarded – undo
3592 3592
  *
3593 3593
  * @param int|WP_Post $post Post ID or post object.
3594 3594
  */
3595
-function wp_publish_post( $post ) {
3595
+function wp_publish_post($post) {
3596 3596
 	global $wpdb;
3597 3597
 
3598
-	if ( ! $post = get_post( $post ) )
3598
+	if ( ! $post = get_post($post))
3599 3599
 		return;
3600 3600
 
3601
-	if ( 'publish' == $post->post_status )
3601
+	if ('publish' == $post->post_status)
3602 3602
 		return;
3603 3603
 
3604
-	$wpdb->update( $wpdb->posts, array( 'post_status' => 'publish' ), array( 'ID' => $post->ID ) );
3604
+	$wpdb->update($wpdb->posts, array('post_status' => 'publish'), array('ID' => $post->ID));
3605 3605
 
3606
-	clean_post_cache( $post->ID );
3606
+	clean_post_cache($post->ID);
3607 3607
 
3608 3608
 	$old_status = $post->post_status;
3609 3609
 	$post->post_status = 'publish';
3610
-	wp_transition_post_status( 'publish', $old_status, $post );
3610
+	wp_transition_post_status('publish', $old_status, $post);
3611 3611
 
3612 3612
 	/** This action is documented in wp-includes/post.php */
3613
-	do_action( 'edit_post', $post->ID, $post );
3613
+	do_action('edit_post', $post->ID, $post);
3614 3614
 
3615 3615
 	/** This action is documented in wp-includes/post.php */
3616
-	do_action( "save_post_{$post->post_type}", $post->ID, $post, true );
3616
+	do_action("save_post_{$post->post_type}", $post->ID, $post, true);
3617 3617
 
3618 3618
 	/** This action is documented in wp-includes/post.php */
3619
-	do_action( 'save_post', $post->ID, $post, true );
3619
+	do_action('save_post', $post->ID, $post, true);
3620 3620
 
3621 3621
 	/** This action is documented in wp-includes/post.php */
3622
-	do_action( 'wp_insert_post', $post->ID, $post, true );
3622
+	do_action('wp_insert_post', $post->ID, $post, true);
3623 3623
 }
3624 3624
 
3625 3625
 /**
@@ -3632,26 +3632,26 @@  discard block
 block discarded – undo
3632 3632
  *
3633 3633
  * @param int|WP_Post $post_id Post ID or post object.
3634 3634
  */
3635
-function check_and_publish_future_post( $post_id ) {
3635
+function check_and_publish_future_post($post_id) {
3636 3636
 	$post = get_post($post_id);
3637 3637
 
3638
-	if ( empty($post) )
3638
+	if (empty($post))
3639 3639
 		return;
3640 3640
 
3641
-	if ( 'future' != $post->post_status )
3641
+	if ('future' != $post->post_status)
3642 3642
 		return;
3643 3643
 
3644
-	$time = strtotime( $post->post_date_gmt . ' GMT' );
3644
+	$time = strtotime($post->post_date_gmt.' GMT');
3645 3645
 
3646 3646
 	// Uh oh, someone jumped the gun!
3647
-	if ( $time > time() ) {
3648
-		wp_clear_scheduled_hook( 'publish_future_post', array( $post_id ) ); // clear anything else in the system
3649
-		wp_schedule_single_event( $time, 'publish_future_post', array( $post_id ) );
3647
+	if ($time > time()) {
3648
+		wp_clear_scheduled_hook('publish_future_post', array($post_id)); // clear anything else in the system
3649
+		wp_schedule_single_event($time, 'publish_future_post', array($post_id));
3650 3650
 		return;
3651 3651
 	}
3652 3652
 
3653 3653
 	// wp_publish_post() returns no meaningful value.
3654
-	wp_publish_post( $post_id );
3654
+	wp_publish_post($post_id);
3655 3655
 }
3656 3656
 
3657 3657
 /**
@@ -3669,8 +3669,8 @@  discard block
 block discarded – undo
3669 3669
  * @param int    $post_parent Post parent ID.
3670 3670
  * @return string Unique slug for the post, based on $post_name (with a -1, -2, etc. suffix)
3671 3671
  */
3672
-function wp_unique_post_slug( $slug, $post_ID, $post_status, $post_type, $post_parent ) {
3673
-	if ( in_array( $post_status, array( 'draft', 'pending', 'auto-draft' ) ) || ( 'inherit' == $post_status && 'revision' == $post_type ) )
3672
+function wp_unique_post_slug($slug, $post_ID, $post_status, $post_type, $post_parent) {
3673
+	if (in_array($post_status, array('draft', 'pending', 'auto-draft')) || ('inherit' == $post_status && 'revision' == $post_type))
3674 3674
 		return $slug;
3675 3675
 
3676 3676
 	global $wpdb, $wp_rewrite;
@@ -3678,13 +3678,13 @@  discard block
 block discarded – undo
3678 3678
 	$original_slug = $slug;
3679 3679
 
3680 3680
 	$feeds = $wp_rewrite->feeds;
3681
-	if ( ! is_array( $feeds ) )
3681
+	if ( ! is_array($feeds))
3682 3682
 		$feeds = array();
3683 3683
 
3684
-	if ( 'attachment' == $post_type ) {
3684
+	if ('attachment' == $post_type) {
3685 3685
 		// Attachment slugs must be unique across all types.
3686 3686
 		$check_sql = "SELECT post_name FROM $wpdb->posts WHERE post_name = %s AND ID != %d LIMIT 1";
3687
-		$post_name_check = $wpdb->get_var( $wpdb->prepare( $check_sql, $slug, $post_ID ) );
3687
+		$post_name_check = $wpdb->get_var($wpdb->prepare($check_sql, $slug, $post_ID));
3688 3688
 
3689 3689
 		/**
3690 3690
 		 * Filters whether the post slug would make a bad attachment slug.
@@ -3694,17 +3694,17 @@  discard block
 block discarded – undo
3694 3694
 		 * @param bool   $bad_slug Whether the slug would be bad as an attachment slug.
3695 3695
 		 * @param string $slug     The post slug.
3696 3696
 		 */
3697
-		if ( $post_name_check || in_array( $slug, $feeds ) || 'embed' === $slug || apply_filters( 'wp_unique_post_slug_is_bad_attachment_slug', false, $slug ) ) {
3697
+		if ($post_name_check || in_array($slug, $feeds) || 'embed' === $slug || apply_filters('wp_unique_post_slug_is_bad_attachment_slug', false, $slug)) {
3698 3698
 			$suffix = 2;
3699 3699
 			do {
3700
-				$alt_post_name = _truncate_post_slug( $slug, 200 - ( strlen( $suffix ) + 1 ) ) . "-$suffix";
3701
-				$post_name_check = $wpdb->get_var( $wpdb->prepare( $check_sql, $alt_post_name, $post_ID ) );
3700
+				$alt_post_name = _truncate_post_slug($slug, 200 - (strlen($suffix) + 1))."-$suffix";
3701
+				$post_name_check = $wpdb->get_var($wpdb->prepare($check_sql, $alt_post_name, $post_ID));
3702 3702
 				$suffix++;
3703
-			} while ( $post_name_check );
3703
+			} while ($post_name_check);
3704 3704
 			$slug = $alt_post_name;
3705 3705
 		}
3706
-	} elseif ( is_post_type_hierarchical( $post_type ) ) {
3707
-		if ( 'nav_menu_item' == $post_type )
3706
+	} elseif (is_post_type_hierarchical($post_type)) {
3707
+		if ('nav_menu_item' == $post_type)
3708 3708
 			return $slug;
3709 3709
 
3710 3710
 		/*
@@ -3712,7 +3712,7 @@  discard block
 block discarded – undo
3712 3712
 		 * namespace than posts so page slugs are allowed to overlap post slugs.
3713 3713
 		 */
3714 3714
 		$check_sql = "SELECT post_name FROM $wpdb->posts WHERE post_name = %s AND post_type IN ( %s, 'attachment' ) AND ID != %d AND post_parent = %d LIMIT 1";
3715
-		$post_name_check = $wpdb->get_var( $wpdb->prepare( $check_sql, $slug, $post_type, $post_ID, $post_parent ) );
3715
+		$post_name_check = $wpdb->get_var($wpdb->prepare($check_sql, $slug, $post_type, $post_ID, $post_parent));
3716 3716
 
3717 3717
 		/**
3718 3718
 		 * Filters whether the post slug would make a bad hierarchical post slug.
@@ -3724,26 +3724,26 @@  discard block
 block discarded – undo
3724 3724
 		 * @param string $post_type   Post type.
3725 3725
 		 * @param int    $post_parent Post parent ID.
3726 3726
 		 */
3727
-		if ( $post_name_check || in_array( $slug, $feeds ) || 'embed' === $slug || preg_match( "@^($wp_rewrite->pagination_base)?\d+$@", $slug )  || apply_filters( 'wp_unique_post_slug_is_bad_hierarchical_slug', false, $slug, $post_type, $post_parent ) ) {
3727
+		if ($post_name_check || in_array($slug, $feeds) || 'embed' === $slug || preg_match("@^($wp_rewrite->pagination_base)?\d+$@", $slug) || apply_filters('wp_unique_post_slug_is_bad_hierarchical_slug', false, $slug, $post_type, $post_parent)) {
3728 3728
 			$suffix = 2;
3729 3729
 			do {
3730
-				$alt_post_name = _truncate_post_slug( $slug, 200 - ( strlen( $suffix ) + 1 ) ) . "-$suffix";
3731
-				$post_name_check = $wpdb->get_var( $wpdb->prepare( $check_sql, $alt_post_name, $post_type, $post_ID, $post_parent ) );
3730
+				$alt_post_name = _truncate_post_slug($slug, 200 - (strlen($suffix) + 1))."-$suffix";
3731
+				$post_name_check = $wpdb->get_var($wpdb->prepare($check_sql, $alt_post_name, $post_type, $post_ID, $post_parent));
3732 3732
 				$suffix++;
3733
-			} while ( $post_name_check );
3733
+			} while ($post_name_check);
3734 3734
 			$slug = $alt_post_name;
3735 3735
 		}
3736 3736
 	} else {
3737 3737
 		// Post slugs must be unique across all posts.
3738 3738
 		$check_sql = "SELECT post_name FROM $wpdb->posts WHERE post_name = %s AND post_type = %s AND ID != %d LIMIT 1";
3739
-		$post_name_check = $wpdb->get_var( $wpdb->prepare( $check_sql, $slug, $post_type, $post_ID ) );
3739
+		$post_name_check = $wpdb->get_var($wpdb->prepare($check_sql, $slug, $post_type, $post_ID));
3740 3740
 
3741 3741
 		// Prevent new post slugs that could result in URLs that conflict with date archives.
3742
-		$post = get_post( $post_ID );
3742
+		$post = get_post($post_ID);
3743 3743
 		$conflicts_with_date_archive = false;
3744
-		if ( 'post' === $post_type && ( ! $post || $post->post_name !== $slug ) && preg_match( '/^[0-9]+$/', $slug ) && $slug_num = intval( $slug ) ) {
3745
-			$permastructs   = array_values( array_filter( explode( '/', get_option( 'permalink_structure' ) ) ) );
3746
-			$postname_index = array_search( '%postname%', $permastructs );
3744
+		if ('post' === $post_type && ( ! $post || $post->post_name !== $slug) && preg_match('/^[0-9]+$/', $slug) && $slug_num = intval($slug)) {
3745
+			$permastructs   = array_values(array_filter(explode('/', get_option('permalink_structure'))));
3746
+			$postname_index = array_search('%postname%', $permastructs);
3747 3747
 
3748 3748
 			/*
3749 3749
 			 * Potential date clashes are as follows:
@@ -3752,9 +3752,9 @@  discard block
 block discarded – undo
3752 3752
 			 * - An integer between 1 and 12 that follows 'year' conflicts with 'monthnum'.
3753 3753
 			 * - An integer between 1 and 31 that follows 'monthnum' conflicts with 'day'.
3754 3754
 			 */
3755
-			if ( 0 === $postname_index ||
3756
-				( $postname_index && '%year%' === $permastructs[ $postname_index - 1 ] && 13 > $slug_num ) ||
3757
-				( $postname_index && '%monthnum%' === $permastructs[ $postname_index - 1 ] && 32 > $slug_num )
3755
+			if (0 === $postname_index ||
3756
+				($postname_index && '%year%' === $permastructs[$postname_index - 1] && 13 > $slug_num) ||
3757
+				($postname_index && '%monthnum%' === $permastructs[$postname_index - 1] && 32 > $slug_num)
3758 3758
 			) {
3759 3759
 				$conflicts_with_date_archive = true;
3760 3760
 			}
@@ -3769,13 +3769,13 @@  discard block
 block discarded – undo
3769 3769
 		 * @param string $slug      The post slug.
3770 3770
 		 * @param string $post_type Post type.
3771 3771
 		 */
3772
-		if ( $post_name_check || in_array( $slug, $feeds ) || 'embed' === $slug || $conflicts_with_date_archive || apply_filters( 'wp_unique_post_slug_is_bad_flat_slug', false, $slug, $post_type ) ) {
3772
+		if ($post_name_check || in_array($slug, $feeds) || 'embed' === $slug || $conflicts_with_date_archive || apply_filters('wp_unique_post_slug_is_bad_flat_slug', false, $slug, $post_type)) {
3773 3773
 			$suffix = 2;
3774 3774
 			do {
3775
-				$alt_post_name = _truncate_post_slug( $slug, 200 - ( strlen( $suffix ) + 1 ) ) . "-$suffix";
3776
-				$post_name_check = $wpdb->get_var( $wpdb->prepare( $check_sql, $alt_post_name, $post_type, $post_ID ) );
3775
+				$alt_post_name = _truncate_post_slug($slug, 200 - (strlen($suffix) + 1))."-$suffix";
3776
+				$post_name_check = $wpdb->get_var($wpdb->prepare($check_sql, $alt_post_name, $post_type, $post_ID));
3777 3777
 				$suffix++;
3778
-			} while ( $post_name_check );
3778
+			} while ($post_name_check);
3779 3779
 			$slug = $alt_post_name;
3780 3780
 		}
3781 3781
 	}
@@ -3792,7 +3792,7 @@  discard block
 block discarded – undo
3792 3792
 	 * @param int    $post_parent   Post parent ID
3793 3793
 	 * @param string $original_slug The original post slug.
3794 3794
 	 */
3795
-	return apply_filters( 'wp_unique_post_slug', $slug, $post_ID, $post_status, $post_type, $post_parent, $original_slug );
3795
+	return apply_filters('wp_unique_post_slug', $slug, $post_ID, $post_status, $post_type, $post_parent, $original_slug);
3796 3796
 }
3797 3797
 
3798 3798
 /**
@@ -3807,16 +3807,16 @@  discard block
 block discarded – undo
3807 3807
  * @param int    $length Optional. Max length of the slug. Default 200 (characters).
3808 3808
  * @return string The truncated slug.
3809 3809
  */
3810
-function _truncate_post_slug( $slug, $length = 200 ) {
3811
-	if ( strlen( $slug ) > $length ) {
3812
-		$decoded_slug = urldecode( $slug );
3813
-		if ( $decoded_slug === $slug )
3814
-			$slug = substr( $slug, 0, $length );
3810
+function _truncate_post_slug($slug, $length = 200) {
3811
+	if (strlen($slug) > $length) {
3812
+		$decoded_slug = urldecode($slug);
3813
+		if ($decoded_slug === $slug)
3814
+			$slug = substr($slug, 0, $length);
3815 3815
 		else
3816
-			$slug = utf8_uri_encode( $decoded_slug, $length );
3816
+			$slug = utf8_uri_encode($decoded_slug, $length);
3817 3817
 	}
3818 3818
 
3819
-	return rtrim( $slug, '-' );
3819
+	return rtrim($slug, '-');
3820 3820
 }
3821 3821
 
3822 3822
 /**
@@ -3831,7 +3831,7 @@  discard block
 block discarded – undo
3831 3831
  *                              separated by commas. Default empty.
3832 3832
  * @return array|false|WP_Error Array of affected term IDs. WP_Error or false on failure.
3833 3833
  */
3834
-function wp_add_post_tags( $post_id = 0, $tags = '' ) {
3834
+function wp_add_post_tags($post_id = 0, $tags = '') {
3835 3835
 	return wp_set_post_tags($post_id, $tags, true);
3836 3836
 }
3837 3837
 
@@ -3849,8 +3849,8 @@  discard block
 block discarded – undo
3849 3849
  *                              replace the tags with the new tags. Default false.
3850 3850
  * @return array|false|WP_Error Array of term taxonomy IDs of affected terms. WP_Error or false on failure.
3851 3851
  */
3852
-function wp_set_post_tags( $post_id = 0, $tags = '', $append = false ) {
3853
-	return wp_set_post_terms( $post_id, $tags, 'post_tag', $append);
3852
+function wp_set_post_tags($post_id = 0, $tags = '', $append = false) {
3853
+	return wp_set_post_terms($post_id, $tags, 'post_tag', $append);
3854 3854
 }
3855 3855
 
3856 3856
 /**
@@ -3868,31 +3868,31 @@  discard block
 block discarded – undo
3868 3868
  *                               replace the terms with the new terms. Default false.
3869 3869
  * @return array|false|WP_Error Array of term taxonomy IDs of affected terms. WP_Error or false on failure.
3870 3870
  */
3871
-function wp_set_post_terms( $post_id = 0, $tags = '', $taxonomy = 'post_tag', $append = false ) {
3871
+function wp_set_post_terms($post_id = 0, $tags = '', $taxonomy = 'post_tag', $append = false) {
3872 3872
 	$post_id = (int) $post_id;
3873 3873
 
3874
-	if ( !$post_id )
3874
+	if ( ! $post_id)
3875 3875
 		return false;
3876 3876
 
3877
-	if ( empty($tags) )
3877
+	if (empty($tags))
3878 3878
 		$tags = array();
3879 3879
 
3880
-	if ( ! is_array( $tags ) ) {
3881
-		$comma = _x( ',', 'tag delimiter' );
3882
-		if ( ',' !== $comma )
3883
-			$tags = str_replace( $comma, ',', $tags );
3884
-		$tags = explode( ',', trim( $tags, " \n\t\r\0\x0B," ) );
3880
+	if ( ! is_array($tags)) {
3881
+		$comma = _x(',', 'tag delimiter');
3882
+		if (',' !== $comma)
3883
+			$tags = str_replace($comma, ',', $tags);
3884
+		$tags = explode(',', trim($tags, " \n\t\r\0\x0B,"));
3885 3885
 	}
3886 3886
 
3887 3887
 	/*
3888 3888
 	 * Hierarchical taxonomies must always pass IDs rather than names so that
3889 3889
 	 * children with the same names but different parents aren't confused.
3890 3890
 	 */
3891
-	if ( is_taxonomy_hierarchical( $taxonomy ) ) {
3892
-		$tags = array_unique( array_map( 'intval', $tags ) );
3891
+	if (is_taxonomy_hierarchical($taxonomy)) {
3892
+		$tags = array_unique(array_map('intval', $tags));
3893 3893
 	}
3894 3894
 
3895
-	return wp_set_object_terms( $post_id, $tags, $taxonomy, $append );
3895
+	return wp_set_object_terms($post_id, $tags, $taxonomy, $append);
3896 3896
 }
3897 3897
 
3898 3898
 /**
@@ -3911,24 +3911,24 @@  discard block
 block discarded – undo
3911 3911
  *                                  If false, replace the categories with the new categories.
3912 3912
  * @return array|false|WP_Error Array of term taxonomy IDs of affected categories. WP_Error or false on failure.
3913 3913
  */
3914
-function wp_set_post_categories( $post_ID = 0, $post_categories = array(), $append = false ) {
3914
+function wp_set_post_categories($post_ID = 0, $post_categories = array(), $append = false) {
3915 3915
 	$post_ID = (int) $post_ID;
3916
-	$post_type = get_post_type( $post_ID );
3917
-	$post_status = get_post_status( $post_ID );
3916
+	$post_type = get_post_type($post_ID);
3917
+	$post_status = get_post_status($post_ID);
3918 3918
 	// If $post_categories isn't already an array, make it one:
3919 3919
 	$post_categories = (array) $post_categories;
3920
-	if ( empty( $post_categories ) ) {
3921
-		if ( 'post' == $post_type && 'auto-draft' != $post_status ) {
3922
-			$post_categories = array( get_option('default_category') );
3920
+	if (empty($post_categories)) {
3921
+		if ('post' == $post_type && 'auto-draft' != $post_status) {
3922
+			$post_categories = array(get_option('default_category'));
3923 3923
 			$append = false;
3924 3924
 		} else {
3925 3925
 			$post_categories = array();
3926 3926
 		}
3927
-	} elseif ( 1 == count( $post_categories ) && '' == reset( $post_categories ) ) {
3927
+	} elseif (1 == count($post_categories) && '' == reset($post_categories)) {
3928 3928
 		return true;
3929 3929
 	}
3930 3930
 
3931
-	return wp_set_post_terms( $post_ID, $post_categories, 'category', $append );
3931
+	return wp_set_post_terms($post_ID, $post_categories, 'category', $append);
3932 3932
 }
3933 3933
 
3934 3934
 /**
@@ -3952,7 +3952,7 @@  discard block
 block discarded – undo
3952 3952
  * @param string  $old_status Previous post status.
3953 3953
  * @param WP_Post $post Post data.
3954 3954
  */
3955
-function wp_transition_post_status( $new_status, $old_status, $post ) {
3955
+function wp_transition_post_status($new_status, $old_status, $post) {
3956 3956
 	/**
3957 3957
 	 * Fires when a post is transitioned from one status to another.
3958 3958
 	 *
@@ -3962,7 +3962,7 @@  discard block
 block discarded – undo
3962 3962
 	 * @param string  $old_status Old post status.
3963 3963
 	 * @param WP_Post $post       Post object.
3964 3964
 	 */
3965
-	do_action( 'transition_post_status', $new_status, $old_status, $post );
3965
+	do_action('transition_post_status', $new_status, $old_status, $post);
3966 3966
 
3967 3967
 	/**
3968 3968
 	 * Fires when a post is transitioned from one status to another.
@@ -3974,7 +3974,7 @@  discard block
 block discarded – undo
3974 3974
 	 *
3975 3975
 	 * @param WP_Post $post Post object.
3976 3976
 	 */
3977
-	do_action( "{$old_status}_to_{$new_status}", $post );
3977
+	do_action("{$old_status}_to_{$new_status}", $post);
3978 3978
 
3979 3979
 	/**
3980 3980
 	 * Fires when a post is transitioned from one status to another.
@@ -3995,7 +3995,7 @@  discard block
 block discarded – undo
3995 3995
 	 * @param int     $post_id Post ID.
3996 3996
 	 * @param WP_Post $post    Post object.
3997 3997
 	 */
3998
-	do_action( "{$new_status}_{$post->post_type}", $post->ID, $post );
3998
+	do_action("{$new_status}_{$post->post_type}", $post->ID, $post);
3999 3999
 }
4000 4000
 
4001 4001
 //
@@ -4015,19 +4015,19 @@  discard block
 block discarded – undo
4015 4015
  * @param string|array $uri     Ping URI or array of URIs.
4016 4016
  * @return int|false How many rows were updated.
4017 4017
  */
4018
-function add_ping( $post_id, $uri ) {
4018
+function add_ping($post_id, $uri) {
4019 4019
 	global $wpdb;
4020 4020
 
4021
-	$post = get_post( $post_id );
4022
-	if ( ! $post ) {
4021
+	$post = get_post($post_id);
4022
+	if ( ! $post) {
4023 4023
 		return false;
4024 4024
 	}
4025 4025
 
4026
-	$pung = trim( $post->pinged );
4027
-	$pung = preg_split( '/\s/', $pung );
4026
+	$pung = trim($post->pinged);
4027
+	$pung = preg_split('/\s/', $pung);
4028 4028
 
4029
-	if ( is_array( $uri ) ) {
4030
-		$pung = array_merge( $pung, $uri );
4029
+	if (is_array($uri)) {
4030
+		$pung = array_merge($pung, $uri);
4031 4031
 	}
4032 4032
 	else {
4033 4033
 		$pung[] = $uri;
@@ -4041,10 +4041,10 @@  discard block
 block discarded – undo
4041 4041
 	 *
4042 4042
 	 * @param string $new New ping URL to add.
4043 4043
 	 */
4044
-	$new = apply_filters( 'add_ping', $new );
4044
+	$new = apply_filters('add_ping', $new);
4045 4045
 
4046
-	$return = $wpdb->update( $wpdb->posts, array( 'pinged' => $new ), array( 'ID' => $post->ID ) );
4047
-	clean_post_cache( $post->ID );
4046
+	$return = $wpdb->update($wpdb->posts, array('pinged' => $new), array('ID' => $post->ID));
4047
+	clean_post_cache($post->ID);
4048 4048
 	return $return;
4049 4049
 }
4050 4050
 
@@ -4056,18 +4056,18 @@  discard block
 block discarded – undo
4056 4056
  * @param int $post_id Post ID.
4057 4057
  * @return array List of enclosures.
4058 4058
  */
4059
-function get_enclosed( $post_id ) {
4060
-	$custom_fields = get_post_custom( $post_id );
4059
+function get_enclosed($post_id) {
4060
+	$custom_fields = get_post_custom($post_id);
4061 4061
 	$pung = array();
4062
-	if ( !is_array( $custom_fields ) )
4062
+	if ( ! is_array($custom_fields))
4063 4063
 		return $pung;
4064 4064
 
4065
-	foreach ( $custom_fields as $key => $val ) {
4066
-		if ( 'enclosure' != $key || !is_array( $val ) )
4065
+	foreach ($custom_fields as $key => $val) {
4066
+		if ('enclosure' != $key || ! is_array($val))
4067 4067
 			continue;
4068
-		foreach ( $val as $enc ) {
4069
-			$enclosure = explode( "\n", $enc );
4070
-			$pung[] = trim( $enclosure[ 0 ] );
4068
+		foreach ($val as $enc) {
4069
+			$enclosure = explode("\n", $enc);
4070
+			$pung[] = trim($enclosure[0]);
4071 4071
 		}
4072 4072
 	}
4073 4073
 
@@ -4079,7 +4079,7 @@  discard block
 block discarded – undo
4079 4079
 	 * @param array $pung    Array of enclosures for the given post.
4080 4080
 	 * @param int   $post_id Post ID.
4081 4081
 	 */
4082
-	return apply_filters( 'get_enclosed', $pung, $post_id );
4082
+	return apply_filters('get_enclosed', $pung, $post_id);
4083 4083
 }
4084 4084
 
4085 4085
 /**
@@ -4092,14 +4092,14 @@  discard block
 block discarded – undo
4092 4092
  * @param int|WP_Post $post_id Post ID or object.
4093 4093
  * @return array
4094 4094
  */
4095
-function get_pung( $post_id ) {
4096
-	$post = get_post( $post_id );
4097
-	if ( ! $post ) {
4095
+function get_pung($post_id) {
4096
+	$post = get_post($post_id);
4097
+	if ( ! $post) {
4098 4098
 		return false;
4099 4099
 	}
4100 4100
 
4101
-	$pung = trim( $post->pinged );
4102
-	$pung = preg_split( '/\s/', $pung );
4101
+	$pung = trim($post->pinged);
4102
+	$pung = preg_split('/\s/', $pung);
4103 4103
 
4104 4104
 	/**
4105 4105
 	 * Filters the list of already-pinged URLs for the given post.
@@ -4108,7 +4108,7 @@  discard block
 block discarded – undo
4108 4108
 	 *
4109 4109
 	 * @param array $pung Array of URLs already pinged for the given post.
4110 4110
 	 */
4111
-	return apply_filters( 'get_pung', $pung );
4111
+	return apply_filters('get_pung', $pung);
4112 4112
 }
4113 4113
 
4114 4114
 /**
@@ -4120,14 +4120,14 @@  discard block
 block discarded – undo
4120 4120
  * @param int|WP_Post $post_id Post Object or ID
4121 4121
  * @return array
4122 4122
  */
4123
-function get_to_ping( $post_id ) {
4124
-	$post = get_post( $post_id );
4123
+function get_to_ping($post_id) {
4124
+	$post = get_post($post_id);
4125 4125
 
4126
-	if ( ! $post ) {
4126
+	if ( ! $post) {
4127 4127
 		return false;
4128 4128
 	}
4129 4129
 
4130
-	$to_ping = sanitize_trackback_urls( $post->to_ping );
4130
+	$to_ping = sanitize_trackback_urls($post->to_ping);
4131 4131
 	$to_ping = preg_split('/\s/', $to_ping, -1, PREG_SPLIT_NO_EMPTY);
4132 4132
 
4133 4133
 	/**
@@ -4137,7 +4137,7 @@  discard block
 block discarded – undo
4137 4137
 	 *
4138 4138
 	 * @param array $to_ping List of URLs yet to ping.
4139 4139
 	 */
4140
-	return apply_filters( 'get_to_ping', $to_ping );
4140
+	return apply_filters('get_to_ping', $to_ping);
4141 4141
 }
4142 4142
 
4143 4143
 /**
@@ -4148,22 +4148,22 @@  discard block
 block discarded – undo
4148 4148
  * @param string $tb_list Comma separated list of URLs.
4149 4149
  * @param int    $post_id Post ID.
4150 4150
  */
4151
-function trackback_url_list( $tb_list, $post_id ) {
4152
-	if ( ! empty( $tb_list ) ) {
4151
+function trackback_url_list($tb_list, $post_id) {
4152
+	if ( ! empty($tb_list)) {
4153 4153
 		// Get post data.
4154
-		$postdata = get_post( $post_id, ARRAY_A );
4154
+		$postdata = get_post($post_id, ARRAY_A);
4155 4155
 
4156 4156
 		// Form an excerpt.
4157
-		$excerpt = strip_tags( $postdata['post_excerpt'] ? $postdata['post_excerpt'] : $postdata['post_content'] );
4157
+		$excerpt = strip_tags($postdata['post_excerpt'] ? $postdata['post_excerpt'] : $postdata['post_content']);
4158 4158
 
4159
-		if ( strlen( $excerpt ) > 255 ) {
4160
-			$excerpt = substr( $excerpt, 0, 252 ) . '&hellip;';
4159
+		if (strlen($excerpt) > 255) {
4160
+			$excerpt = substr($excerpt, 0, 252).'&hellip;';
4161 4161
 		}
4162 4162
 
4163
-		$trackback_urls = explode( ',', $tb_list );
4164
-		foreach ( (array) $trackback_urls as $tb_url ) {
4165
-			$tb_url = trim( $tb_url );
4166
-			trackback( $tb_url, wp_unslash( $postdata['post_title'] ), $excerpt, $post_id );
4163
+		$trackback_urls = explode(',', $tb_list);
4164
+		foreach ((array) $trackback_urls as $tb_url) {
4165
+			$tb_url = trim($tb_url);
4166
+			trackback($tb_url, wp_unslash($postdata['post_title']), $excerpt, $post_id);
4167 4167
 		}
4168 4168
 	}
4169 4169
 }
@@ -4185,7 +4185,7 @@  discard block
 block discarded – undo
4185 4185
 	global $wpdb;
4186 4186
 
4187 4187
 	$page_ids = wp_cache_get('all_page_ids', 'posts');
4188
-	if ( ! is_array( $page_ids ) ) {
4188
+	if ( ! is_array($page_ids)) {
4189 4189
 		$page_ids = $wpdb->get_col("SELECT ID FROM $wpdb->posts WHERE post_type = 'page'");
4190 4190
 		wp_cache_add('all_page_ids', $page_ids, 'posts');
4191 4191
 	}
@@ -4208,8 +4208,8 @@  discard block
 block discarded – undo
4208 4208
  *                       'edit', 'db', 'display'. Default 'raw'.
4209 4209
  * @return WP_Post|array|null WP_Post (or array) on success, or null on failure.
4210 4210
  */
4211
-function get_page( $page, $output = OBJECT, $filter = 'raw') {
4212
-	return get_post( $page, $output, $filter );
4211
+function get_page($page, $output = OBJECT, $filter = 'raw') {
4212
+	return get_post($page, $output, $filter);
4213 4213
 }
4214 4214
 
4215 4215
 /**
@@ -4225,40 +4225,40 @@  discard block
 block discarded – undo
4225 4225
  * @param string|array $post_type Optional. Post type or array of post types. Default 'page'.
4226 4226
  * @return WP_Post|array|null WP_Post (or array) on success, or null on failure.
4227 4227
  */
4228
-function get_page_by_path( $page_path, $output = OBJECT, $post_type = 'page' ) {
4228
+function get_page_by_path($page_path, $output = OBJECT, $post_type = 'page') {
4229 4229
 	global $wpdb;
4230 4230
 
4231
-	$last_changed = wp_cache_get_last_changed( 'posts' );
4231
+	$last_changed = wp_cache_get_last_changed('posts');
4232 4232
 
4233
-	$hash = md5( $page_path . serialize( $post_type ) );
4233
+	$hash = md5($page_path.serialize($post_type));
4234 4234
 	$cache_key = "get_page_by_path:$hash:$last_changed";
4235
-	$cached = wp_cache_get( $cache_key, 'posts' );
4236
-	if ( false !== $cached ) {
4235
+	$cached = wp_cache_get($cache_key, 'posts');
4236
+	if (false !== $cached) {
4237 4237
 		// Special case: '0' is a bad `$page_path`.
4238
-		if ( '0' === $cached || 0 === $cached ) {
4238
+		if ('0' === $cached || 0 === $cached) {
4239 4239
 			return;
4240 4240
 		} else {
4241
-			return get_post( $cached, $output );
4241
+			return get_post($cached, $output);
4242 4242
 		}
4243 4243
 	}
4244 4244
 
4245 4245
 	$page_path = rawurlencode(urldecode($page_path));
4246 4246
 	$page_path = str_replace('%2F', '/', $page_path);
4247 4247
 	$page_path = str_replace('%20', ' ', $page_path);
4248
-	$parts = explode( '/', trim( $page_path, '/' ) );
4249
-	$parts = esc_sql( $parts );
4250
-	$parts = array_map( 'sanitize_title_for_query', $parts );
4248
+	$parts = explode('/', trim($page_path, '/'));
4249
+	$parts = esc_sql($parts);
4250
+	$parts = array_map('sanitize_title_for_query', $parts);
4251 4251
 
4252
-	$in_string = "'" . implode( "','", $parts ) . "'";
4252
+	$in_string = "'".implode("','", $parts)."'";
4253 4253
 
4254
-	if ( is_array( $post_type ) ) {
4254
+	if (is_array($post_type)) {
4255 4255
 		$post_types = $post_type;
4256 4256
 	} else {
4257
-		$post_types = array( $post_type, 'attachment' );
4257
+		$post_types = array($post_type, 'attachment');
4258 4258
 	}
4259 4259
 
4260
-	$post_types = esc_sql( $post_types );
4261
-	$post_type_in_string = "'" . implode( "','", $post_types ) . "'";
4260
+	$post_types = esc_sql($post_types);
4261
+	$post_type_in_string = "'".implode("','", $post_types)."'";
4262 4262
 	$sql = "
4263 4263
 		SELECT ID, post_name, post_parent, post_type
4264 4264
 		FROM $wpdb->posts
@@ -4266,13 +4266,13 @@  discard block
 block discarded – undo
4266 4266
 		AND post_type IN ($post_type_in_string)
4267 4267
 	";
4268 4268
 
4269
-	$pages = $wpdb->get_results( $sql, OBJECT_K );
4269
+	$pages = $wpdb->get_results($sql, OBJECT_K);
4270 4270
 
4271
-	$revparts = array_reverse( $parts );
4271
+	$revparts = array_reverse($parts);
4272 4272
 
4273 4273
 	$foundid = 0;
4274
-	foreach ( (array) $pages as $page ) {
4275
-		if ( $page->post_name == $revparts[0] ) {
4274
+	foreach ((array) $pages as $page) {
4275
+		if ($page->post_name == $revparts[0]) {
4276 4276
 			$count = 0;
4277 4277
 			$p = $page;
4278 4278
 
@@ -4280,27 +4280,27 @@  discard block
 block discarded – undo
4280 4280
 			 * Loop through the given path parts from right to left,
4281 4281
 			 * ensuring each matches the post ancestry.
4282 4282
 			 */
4283
-			while ( $p->post_parent != 0 && isset( $pages[ $p->post_parent ] ) ) {
4283
+			while ($p->post_parent != 0 && isset($pages[$p->post_parent])) {
4284 4284
 				$count++;
4285
-				$parent = $pages[ $p->post_parent ];
4286
-				if ( ! isset( $revparts[ $count ] ) || $parent->post_name != $revparts[ $count ] )
4285
+				$parent = $pages[$p->post_parent];
4286
+				if ( ! isset($revparts[$count]) || $parent->post_name != $revparts[$count])
4287 4287
 					break;
4288 4288
 				$p = $parent;
4289 4289
 			}
4290 4290
 
4291
-			if ( $p->post_parent == 0 && $count+1 == count( $revparts ) && $p->post_name == $revparts[ $count ] ) {
4291
+			if ($p->post_parent == 0 && $count + 1 == count($revparts) && $p->post_name == $revparts[$count]) {
4292 4292
 				$foundid = $page->ID;
4293
-				if ( $page->post_type == $post_type )
4293
+				if ($page->post_type == $post_type)
4294 4294
 					break;
4295 4295
 			}
4296 4296
 		}
4297 4297
 	}
4298 4298
 
4299 4299
 	// We cache misses as well as hits.
4300
-	wp_cache_set( $cache_key, $foundid, 'posts' );
4300
+	wp_cache_set($cache_key, $foundid, 'posts');
4301 4301
 
4302
-	if ( $foundid ) {
4303
-		return get_post( $foundid, $output );
4302
+	if ($foundid) {
4303
+		return get_post($foundid, $output);
4304 4304
 	}
4305 4305
 }
4306 4306
 
@@ -4317,31 +4317,31 @@  discard block
 block discarded – undo
4317 4317
  * @param string|array $post_type  Optional. Post type or array of post types. Default 'page'.
4318 4318
  * @return WP_Post|array|null WP_Post (or array) on success, or null on failure.
4319 4319
  */
4320
-function get_page_by_title( $page_title, $output = OBJECT, $post_type = 'page' ) {
4320
+function get_page_by_title($page_title, $output = OBJECT, $post_type = 'page') {
4321 4321
 	global $wpdb;
4322 4322
 
4323
-	if ( is_array( $post_type ) ) {
4324
-		$post_type = esc_sql( $post_type );
4325
-		$post_type_in_string = "'" . implode( "','", $post_type ) . "'";
4326
-		$sql = $wpdb->prepare( "
4323
+	if (is_array($post_type)) {
4324
+		$post_type = esc_sql($post_type);
4325
+		$post_type_in_string = "'".implode("','", $post_type)."'";
4326
+		$sql = $wpdb->prepare("
4327 4327
 			SELECT ID
4328 4328
 			FROM $wpdb->posts
4329 4329
 			WHERE post_title = %s
4330 4330
 			AND post_type IN ($post_type_in_string)
4331
-		", $page_title );
4331
+		", $page_title);
4332 4332
 	} else {
4333
-		$sql = $wpdb->prepare( "
4333
+		$sql = $wpdb->prepare("
4334 4334
 			SELECT ID
4335 4335
 			FROM $wpdb->posts
4336 4336
 			WHERE post_title = %s
4337 4337
 			AND post_type = %s
4338
-		", $page_title, $post_type );
4338
+		", $page_title, $post_type);
4339 4339
 	}
4340 4340
 
4341
-	$page = $wpdb->get_var( $sql );
4341
+	$page = $wpdb->get_var($sql);
4342 4342
 
4343
-	if ( $page ) {
4344
-		return get_post( $page, $output );
4343
+	if ($page) {
4344
+		return get_post($page, $output);
4345 4345
 	}
4346 4346
 }
4347 4347
 
@@ -4356,25 +4356,25 @@  discard block
 block discarded – undo
4356 4356
  * @param array $pages   List of page objects from which descendants should be identified.
4357 4357
  * @return array List of page children.
4358 4358
  */
4359
-function get_page_children( $page_id, $pages ) {
4359
+function get_page_children($page_id, $pages) {
4360 4360
 	// Build a hash of ID -> children.
4361 4361
 	$children = array();
4362
-	foreach ( (array) $pages as $page ) {
4363
-		$children[ intval( $page->post_parent ) ][] = $page;
4362
+	foreach ((array) $pages as $page) {
4363
+		$children[intval($page->post_parent)][] = $page;
4364 4364
 	}
4365 4365
 
4366 4366
 	$page_list = array();
4367 4367
 
4368 4368
 	// Start the search by looking at immediate children.
4369
-	if ( isset( $children[ $page_id ] ) ) {
4369
+	if (isset($children[$page_id])) {
4370 4370
 		// Always start at the end of the stack in order to preserve original `$pages` order.
4371
-		$to_look = array_reverse( $children[ $page_id ] );
4371
+		$to_look = array_reverse($children[$page_id]);
4372 4372
 
4373
-		while ( $to_look ) {
4374
-			$p = array_pop( $to_look );
4373
+		while ($to_look) {
4374
+			$p = array_pop($to_look);
4375 4375
 			$page_list[] = $p;
4376
-			if ( isset( $children[ $p->ID ] ) ) {
4377
-				foreach ( array_reverse( $children[ $p->ID ] ) as $child ) {
4376
+			if (isset($children[$p->ID])) {
4377
+				foreach (array_reverse($children[$p->ID]) as $child) {
4378 4378
 					// Append to the `$to_look` stack to descend the tree.
4379 4379
 					$to_look[] = $child;
4380 4380
 				}
@@ -4397,19 +4397,19 @@  discard block
 block discarded – undo
4397 4397
  * @param int   $page_id Optional. Parent page ID. Default 0.
4398 4398
  * @return array A list arranged by hierarchy. Children immediately follow their parents.
4399 4399
  */
4400
-function get_page_hierarchy( &$pages, $page_id = 0 ) {
4401
-	if ( empty( $pages ) ) {
4400
+function get_page_hierarchy(&$pages, $page_id = 0) {
4401
+	if (empty($pages)) {
4402 4402
 		return array();
4403 4403
 	}
4404 4404
 
4405 4405
 	$children = array();
4406
-	foreach ( (array) $pages as $p ) {
4407
-		$parent_id = intval( $p->post_parent );
4408
-		$children[ $parent_id ][] = $p;
4406
+	foreach ((array) $pages as $p) {
4407
+		$parent_id = intval($p->post_parent);
4408
+		$children[$parent_id][] = $p;
4409 4409
 	}
4410 4410
 
4411 4411
 	$result = array();
4412
-	_page_traverse_name( $page_id, $children, $result );
4412
+	_page_traverse_name($page_id, $children, $result);
4413 4413
 
4414 4414
 	return $result;
4415 4415
 }
@@ -4427,11 +4427,11 @@  discard block
 block discarded – undo
4427 4427
  * @param array $children  Parent-children relations, passed by reference.
4428 4428
  * @param array $result    Result, passed by reference.
4429 4429
  */
4430
-function _page_traverse_name( $page_id, &$children, &$result ){
4431
-	if ( isset( $children[ $page_id ] ) ){
4432
-		foreach ( (array)$children[ $page_id ] as $child ) {
4433
-			$result[ $child->ID ] = $child->post_name;
4434
-			_page_traverse_name( $child->ID, $children, $result );
4430
+function _page_traverse_name($page_id, &$children, &$result) {
4431
+	if (isset($children[$page_id])) {
4432
+		foreach ((array) $children[$page_id] as $child) {
4433
+			$result[$child->ID] = $child->post_name;
4434
+			_page_traverse_name($child->ID, $children, $result);
4435 4435
 		}
4436 4436
 	}
4437 4437
 }
@@ -4447,20 +4447,20 @@  discard block
 block discarded – undo
4447 4447
  * @param WP_Post|object|int $page Optional. Page ID or WP_Post object. Default is global $post.
4448 4448
  * @return string|false Page URI, false on error.
4449 4449
  */
4450
-function get_page_uri( $page = 0 ) {
4451
-	if ( ! $page instanceof WP_Post ) {
4452
-		$page = get_post( $page );
4450
+function get_page_uri($page = 0) {
4451
+	if ( ! $page instanceof WP_Post) {
4452
+		$page = get_post($page);
4453 4453
 	}
4454 4454
 
4455
-	if ( ! $page )
4455
+	if ( ! $page)
4456 4456
 		return false;
4457 4457
 
4458 4458
 	$uri = $page->post_name;
4459 4459
 
4460
-	foreach ( $page->ancestors as $parent ) {
4461
-		$parent = get_post( $parent );
4462
-		if ( $parent && $parent->post_name ) {
4463
-			$uri = $parent->post_name . '/' . $uri;
4460
+	foreach ($page->ancestors as $parent) {
4461
+		$parent = get_post($parent);
4462
+		if ($parent && $parent->post_name) {
4463
+			$uri = $parent->post_name.'/'.$uri;
4464 4464
 		}
4465 4465
 	}
4466 4466
 
@@ -4472,7 +4472,7 @@  discard block
 block discarded – undo
4472 4472
 	 * @param string  $uri  Page URI.
4473 4473
 	 * @param WP_Post $page Page object.
4474 4474
 	 */
4475
-	return apply_filters( 'get_page_uri', $uri, $page );
4475
+	return apply_filters('get_page_uri', $uri, $page);
4476 4476
 }
4477 4477
 
4478 4478
 /**
@@ -4517,7 +4517,7 @@  discard block
 block discarded – undo
4517 4517
  * }
4518 4518
  * @return array|false List of pages matching defaults or `$args`.
4519 4519
  */
4520
-function get_pages( $args = array() ) {
4520
+function get_pages($args = array()) {
4521 4521
 	global $wpdb;
4522 4522
 
4523 4523
 	$defaults = array(
@@ -4538,7 +4538,7 @@  discard block
 block discarded – undo
4538 4538
 		'post_status'  => 'publish',
4539 4539
 	);
4540 4540
 
4541
-	$r = wp_parse_args( $args, $defaults );
4541
+	$r = wp_parse_args($args, $defaults);
4542 4542
 
4543 4543
 	$number = (int) $r['number'];
4544 4544
 	$offset = (int) $r['offset'];
@@ -4551,83 +4551,83 @@  discard block
 block discarded – undo
4551 4551
 	$post_status = $r['post_status'];
4552 4552
 
4553 4553
 	// Make sure the post type is hierarchical.
4554
-	$hierarchical_post_types = get_post_types( array( 'hierarchical' => true ) );
4555
-	if ( ! in_array( $r['post_type'], $hierarchical_post_types ) ) {
4554
+	$hierarchical_post_types = get_post_types(array('hierarchical' => true));
4555
+	if ( ! in_array($r['post_type'], $hierarchical_post_types)) {
4556 4556
 		return false;
4557 4557
 	}
4558 4558
 
4559
-	if ( $parent > 0 && ! $child_of ) {
4559
+	if ($parent > 0 && ! $child_of) {
4560 4560
 		$hierarchical = false;
4561 4561
 	}
4562 4562
 
4563 4563
 	// Make sure we have a valid post status.
4564
-	if ( ! is_array( $post_status ) ) {
4565
-		$post_status = explode( ',', $post_status );
4564
+	if ( ! is_array($post_status)) {
4565
+		$post_status = explode(',', $post_status);
4566 4566
 	}
4567
-	if ( array_diff( $post_status, get_post_stati() ) ) {
4567
+	if (array_diff($post_status, get_post_stati())) {
4568 4568
 		return false;
4569 4569
 	}
4570 4570
 
4571 4571
 	// $args can be whatever, only use the args defined in defaults to compute the key.
4572
-	$key = md5( serialize( wp_array_slice_assoc( $r, array_keys( $defaults ) ) ) );
4573
-	$last_changed = wp_cache_get_last_changed( 'posts' );
4572
+	$key = md5(serialize(wp_array_slice_assoc($r, array_keys($defaults))));
4573
+	$last_changed = wp_cache_get_last_changed('posts');
4574 4574
 
4575 4575
 	$cache_key = "get_pages:$key:$last_changed";
4576
-	if ( $cache = wp_cache_get( $cache_key, 'posts' ) ) {
4576
+	if ($cache = wp_cache_get($cache_key, 'posts')) {
4577 4577
 		// Convert to WP_Post instances.
4578
-		$pages = array_map( 'get_post', $cache );
4578
+		$pages = array_map('get_post', $cache);
4579 4579
 		/** This filter is documented in wp-includes/post.php */
4580
-		$pages = apply_filters( 'get_pages', $pages, $r );
4580
+		$pages = apply_filters('get_pages', $pages, $r);
4581 4581
 		return $pages;
4582 4582
 	}
4583 4583
 
4584 4584
 	$inclusions = '';
4585
-	if ( ! empty( $r['include'] ) ) {
4585
+	if ( ! empty($r['include'])) {
4586 4586
 		$child_of = 0; //ignore child_of, parent, exclude, meta_key, and meta_value params if using include
4587 4587
 		$parent = -1;
4588 4588
 		$exclude = '';
4589 4589
 		$meta_key = '';
4590 4590
 		$meta_value = '';
4591 4591
 		$hierarchical = false;
4592
-		$incpages = wp_parse_id_list( $r['include'] );
4593
-		if ( ! empty( $incpages ) ) {
4594
-			$inclusions = ' AND ID IN (' . implode( ',', $incpages ) .  ')';
4592
+		$incpages = wp_parse_id_list($r['include']);
4593
+		if ( ! empty($incpages)) {
4594
+			$inclusions = ' AND ID IN ('.implode(',', $incpages).')';
4595 4595
 		}
4596 4596
 	}
4597 4597
 
4598 4598
 	$exclusions = '';
4599
-	if ( ! empty( $exclude ) ) {
4600
-		$expages = wp_parse_id_list( $exclude );
4601
-		if ( ! empty( $expages ) ) {
4602
-			$exclusions = ' AND ID NOT IN (' . implode( ',', $expages ) .  ')';
4599
+	if ( ! empty($exclude)) {
4600
+		$expages = wp_parse_id_list($exclude);
4601
+		if ( ! empty($expages)) {
4602
+			$exclusions = ' AND ID NOT IN ('.implode(',', $expages).')';
4603 4603
 		}
4604 4604
 	}
4605 4605
 
4606 4606
 	$author_query = '';
4607
-	if ( ! empty( $r['authors'] ) ) {
4608
-		$post_authors = preg_split( '/[\s,]+/', $r['authors'] );
4607
+	if ( ! empty($r['authors'])) {
4608
+		$post_authors = preg_split('/[\s,]+/', $r['authors']);
4609 4609
 
4610
-		if ( ! empty( $post_authors ) ) {
4611
-			foreach ( $post_authors as $post_author ) {
4610
+		if ( ! empty($post_authors)) {
4611
+			foreach ($post_authors as $post_author) {
4612 4612
 				//Do we have an author id or an author login?
4613
-				if ( 0 == intval($post_author) ) {
4613
+				if (0 == intval($post_author)) {
4614 4614
 					$post_author = get_user_by('login', $post_author);
4615
-					if ( empty( $post_author ) ) {
4615
+					if (empty($post_author)) {
4616 4616
 						continue;
4617 4617
 					}
4618
-					if ( empty( $post_author->ID ) ) {
4618
+					if (empty($post_author->ID)) {
4619 4619
 						continue;
4620 4620
 					}
4621 4621
 					$post_author = $post_author->ID;
4622 4622
 				}
4623 4623
 
4624
-				if ( '' == $author_query ) {
4624
+				if ('' == $author_query) {
4625 4625
 					$author_query = $wpdb->prepare(' post_author = %d ', $post_author);
4626 4626
 				} else {
4627 4627
 					$author_query .= $wpdb->prepare(' OR post_author = %d ', $post_author);
4628 4628
 				}
4629 4629
 			}
4630
-			if ( '' != $author_query ) {
4630
+			if ('' != $author_query) {
4631 4631
 				$author_query = " AND ($author_query)";
4632 4632
 			}
4633 4633
 		}
@@ -4635,49 +4635,49 @@  discard block
 block discarded – undo
4635 4635
 
4636 4636
 	$join = '';
4637 4637
 	$where = "$exclusions $inclusions ";
4638
-	if ( '' !== $meta_key || '' !== $meta_value ) {
4638
+	if ('' !== $meta_key || '' !== $meta_value) {
4639 4639
 		$join = " LEFT JOIN $wpdb->postmeta ON ( $wpdb->posts.ID = $wpdb->postmeta.post_id )";
4640 4640
 
4641 4641
 		// meta_key and meta_value might be slashed
4642 4642
 		$meta_key = wp_unslash($meta_key);
4643 4643
 		$meta_value = wp_unslash($meta_value);
4644
-		if ( '' !== $meta_key ) {
4644
+		if ('' !== $meta_key) {
4645 4645
 			$where .= $wpdb->prepare(" AND $wpdb->postmeta.meta_key = %s", $meta_key);
4646 4646
 		}
4647
-		if ( '' !== $meta_value ) {
4647
+		if ('' !== $meta_value) {
4648 4648
 			$where .= $wpdb->prepare(" AND $wpdb->postmeta.meta_value = %s", $meta_value);
4649 4649
 		}
4650 4650
 
4651 4651
 	}
4652 4652
 
4653
-	if ( is_array( $parent ) ) {
4654
-		$post_parent__in = implode( ',', array_map( 'absint', (array) $parent ) );
4655
-		if ( ! empty( $post_parent__in ) ) {
4653
+	if (is_array($parent)) {
4654
+		$post_parent__in = implode(',', array_map('absint', (array) $parent));
4655
+		if ( ! empty($post_parent__in)) {
4656 4656
 			$where .= " AND post_parent IN ($post_parent__in)";
4657 4657
 		}
4658
-	} elseif ( $parent >= 0 ) {
4658
+	} elseif ($parent >= 0) {
4659 4659
 		$where .= $wpdb->prepare(' AND post_parent = %d ', $parent);
4660 4660
 	}
4661 4661
 
4662
-	if ( 1 == count( $post_status ) ) {
4663
-		$where_post_type = $wpdb->prepare( "post_type = %s AND post_status = %s", $r['post_type'], reset( $post_status ) );
4662
+	if (1 == count($post_status)) {
4663
+		$where_post_type = $wpdb->prepare("post_type = %s AND post_status = %s", $r['post_type'], reset($post_status));
4664 4664
 	} else {
4665
-		$post_status = implode( "', '", $post_status );
4666
-		$where_post_type = $wpdb->prepare( "post_type = %s AND post_status IN ('$post_status')", $r['post_type'] );
4665
+		$post_status = implode("', '", $post_status);
4666
+		$where_post_type = $wpdb->prepare("post_type = %s AND post_status IN ('$post_status')", $r['post_type']);
4667 4667
 	}
4668 4668
 
4669 4669
 	$orderby_array = array();
4670
-	$allowed_keys = array( 'author', 'post_author', 'date', 'post_date', 'title', 'post_title', 'name', 'post_name', 'modified',
4670
+	$allowed_keys = array('author', 'post_author', 'date', 'post_date', 'title', 'post_title', 'name', 'post_name', 'modified',
4671 4671
 		'post_modified', 'modified_gmt', 'post_modified_gmt', 'menu_order', 'parent', 'post_parent',
4672
-		'ID', 'rand', 'comment_count' );
4672
+		'ID', 'rand', 'comment_count');
4673 4673
 
4674
-	foreach ( explode( ',', $r['sort_column'] ) as $orderby ) {
4675
-		$orderby = trim( $orderby );
4676
-		if ( ! in_array( $orderby, $allowed_keys ) ) {
4674
+	foreach (explode(',', $r['sort_column']) as $orderby) {
4675
+		$orderby = trim($orderby);
4676
+		if ( ! in_array($orderby, $allowed_keys)) {
4677 4677
 			continue;
4678 4678
 		}
4679 4679
 
4680
-		switch ( $orderby ) {
4680
+		switch ($orderby) {
4681 4681
 			case 'menu_order':
4682 4682
 				break;
4683 4683
 			case 'ID':
@@ -4690,36 +4690,36 @@  discard block
 block discarded – undo
4690 4690
 				$orderby = "$wpdb->posts.comment_count";
4691 4691
 				break;
4692 4692
 			default:
4693
-				if ( 0 === strpos( $orderby, 'post_' ) ) {
4694
-					$orderby = "$wpdb->posts." . $orderby;
4693
+				if (0 === strpos($orderby, 'post_')) {
4694
+					$orderby = "$wpdb->posts.".$orderby;
4695 4695
 				} else {
4696
-					$orderby = "$wpdb->posts.post_" . $orderby;
4696
+					$orderby = "$wpdb->posts.post_".$orderby;
4697 4697
 				}
4698 4698
 		}
4699 4699
 
4700 4700
 		$orderby_array[] = $orderby;
4701 4701
 
4702 4702
 	}
4703
-	$sort_column = ! empty( $orderby_array ) ? implode( ',', $orderby_array ) : "$wpdb->posts.post_title";
4703
+	$sort_column = ! empty($orderby_array) ? implode(',', $orderby_array) : "$wpdb->posts.post_title";
4704 4704
 
4705
-	$sort_order = strtoupper( $r['sort_order'] );
4706
-	if ( '' !== $sort_order && ! in_array( $sort_order, array( 'ASC', 'DESC' ) ) ) {
4705
+	$sort_order = strtoupper($r['sort_order']);
4706
+	if ('' !== $sort_order && ! in_array($sort_order, array('ASC', 'DESC'))) {
4707 4707
 		$sort_order = 'ASC';
4708 4708
 	}
4709 4709
 
4710 4710
 	$query = "SELECT * FROM $wpdb->posts $join WHERE ($where_post_type) $where ";
4711 4711
 	$query .= $author_query;
4712
-	$query .= " ORDER BY " . $sort_column . " " . $sort_order ;
4712
+	$query .= " ORDER BY ".$sort_column." ".$sort_order;
4713 4713
 
4714
-	if ( ! empty( $number ) ) {
4715
-		$query .= ' LIMIT ' . $offset . ',' . $number;
4714
+	if ( ! empty($number)) {
4715
+		$query .= ' LIMIT '.$offset.','.$number;
4716 4716
 	}
4717 4717
 
4718 4718
 	$pages = $wpdb->get_results($query);
4719 4719
 
4720
-	if ( empty($pages) ) {
4720
+	if (empty($pages)) {
4721 4721
 		/** This filter is documented in wp-includes/post.php */
4722
-		$pages = apply_filters( 'get_pages', array(), $r );
4722
+		$pages = apply_filters('get_pages', array(), $r);
4723 4723
 		return $pages;
4724 4724
 	}
4725 4725
 
@@ -4730,38 +4730,38 @@  discard block
 block discarded – undo
4730 4730
 	}
4731 4731
 
4732 4732
 	// Update cache.
4733
-	update_post_cache( $pages );
4733
+	update_post_cache($pages);
4734 4734
 
4735
-	if ( $child_of || $hierarchical ) {
4735
+	if ($child_of || $hierarchical) {
4736 4736
 		$pages = get_page_children($child_of, $pages);
4737 4737
 	}
4738 4738
 
4739
-	if ( ! empty( $r['exclude_tree'] ) ) {
4740
-		$exclude = wp_parse_id_list( $r['exclude_tree'] );
4741
-		foreach ( $exclude as $id ) {
4742
-			$children = get_page_children( $id, $pages );
4743
-			foreach ( $children as $child ) {
4739
+	if ( ! empty($r['exclude_tree'])) {
4740
+		$exclude = wp_parse_id_list($r['exclude_tree']);
4741
+		foreach ($exclude as $id) {
4742
+			$children = get_page_children($id, $pages);
4743
+			foreach ($children as $child) {
4744 4744
 				$exclude[] = $child->ID;
4745 4745
 			}
4746 4746
 		}
4747 4747
 
4748
-		$num_pages = count( $pages );
4749
-		for ( $i = 0; $i < $num_pages; $i++ ) {
4750
-			if ( in_array( $pages[$i]->ID, $exclude ) ) {
4751
-				unset( $pages[$i] );
4748
+		$num_pages = count($pages);
4749
+		for ($i = 0; $i < $num_pages; $i++) {
4750
+			if (in_array($pages[$i]->ID, $exclude)) {
4751
+				unset($pages[$i]);
4752 4752
 			}
4753 4753
 		}
4754 4754
 	}
4755 4755
 
4756 4756
 	$page_structure = array();
4757
-	foreach ( $pages as $page ) {
4757
+	foreach ($pages as $page) {
4758 4758
 		$page_structure[] = $page->ID;
4759 4759
 	}
4760 4760
 
4761
-	wp_cache_set( $cache_key, $page_structure, 'posts' );
4761
+	wp_cache_set($cache_key, $page_structure, 'posts');
4762 4762
 
4763 4763
 	// Convert to WP_Post instances
4764
-	$pages = array_map( 'get_post', $pages );
4764
+	$pages = array_map('get_post', $pages);
4765 4765
 
4766 4766
 	/**
4767 4767
 	 * Filters the retrieved list of pages.
@@ -4771,7 +4771,7 @@  discard block
 block discarded – undo
4771 4771
 	 * @param array $pages List of pages to retrieve.
4772 4772
 	 * @param array $r     Array of get_pages() arguments.
4773 4773
 	 */
4774
-	return apply_filters( 'get_pages', $pages, $r );
4774
+	return apply_filters('get_pages', $pages, $r);
4775 4775
 }
4776 4776
 
4777 4777
 //
@@ -4791,9 +4791,9 @@  discard block
 block discarded – undo
4791 4791
 		return false;
4792 4792
 	if (strpos($url, home_url('/?attachment_id=')) !== false)
4793 4793
 		return true;
4794
-	if ( $id = url_to_postid($url) ) {
4794
+	if ($id = url_to_postid($url)) {
4795 4795
 		$post = get_post($id);
4796
-		if ( 'attachment' == $post->post_type )
4796
+		if ('attachment' == $post->post_type)
4797 4797
 			return true;
4798 4798
 	}
4799 4799
 	return false;
@@ -4824,21 +4824,21 @@  discard block
 block discarded – undo
4824 4824
  * @param bool         $wp_error Optional. Whether to return a WP_Error on failure. Default false.
4825 4825
  * @return int|WP_Error The attachment ID on success. The value 0 or WP_Error on failure.
4826 4826
  */
4827
-function wp_insert_attachment( $args, $file = false, $parent = 0, $wp_error = false ) {
4827
+function wp_insert_attachment($args, $file = false, $parent = 0, $wp_error = false) {
4828 4828
 	$defaults = array(
4829 4829
 		'file'        => $file,
4830 4830
 		'post_parent' => 0
4831 4831
 	);
4832 4832
 
4833
-	$data = wp_parse_args( $args, $defaults );
4833
+	$data = wp_parse_args($args, $defaults);
4834 4834
 
4835
-	if ( ! empty( $parent ) ) {
4835
+	if ( ! empty($parent)) {
4836 4836
 		$data['post_parent'] = $parent;
4837 4837
 	}
4838 4838
 
4839 4839
 	$data['post_type'] = 'attachment';
4840 4840
 
4841
-	return wp_insert_post( $data, $wp_error );
4841
+	return wp_insert_post($data, $wp_error);
4842 4842
 }
4843 4843
 
4844 4844
 /**
@@ -4860,27 +4860,27 @@  discard block
 block discarded – undo
4860 4860
  *                           Default false.
4861 4861
  * @return mixed False on failure. Post data on success.
4862 4862
  */
4863
-function wp_delete_attachment( $post_id, $force_delete = false ) {
4863
+function wp_delete_attachment($post_id, $force_delete = false) {
4864 4864
 	global $wpdb;
4865 4865
 
4866
-	if ( !$post = $wpdb->get_row( $wpdb->prepare("SELECT * FROM $wpdb->posts WHERE ID = %d", $post_id) ) )
4866
+	if ( ! $post = $wpdb->get_row($wpdb->prepare("SELECT * FROM $wpdb->posts WHERE ID = %d", $post_id)))
4867 4867
 		return $post;
4868 4868
 
4869
-	if ( 'attachment' != $post->post_type )
4869
+	if ('attachment' != $post->post_type)
4870 4870
 		return false;
4871 4871
 
4872
-	if ( !$force_delete && EMPTY_TRASH_DAYS && MEDIA_TRASH && 'trash' != $post->post_status )
4873
-		return wp_trash_post( $post_id );
4872
+	if ( ! $force_delete && EMPTY_TRASH_DAYS && MEDIA_TRASH && 'trash' != $post->post_status)
4873
+		return wp_trash_post($post_id);
4874 4874
 
4875 4875
 	delete_post_meta($post_id, '_wp_trash_meta_status');
4876 4876
 	delete_post_meta($post_id, '_wp_trash_meta_time');
4877 4877
 
4878
-	$meta = wp_get_attachment_metadata( $post_id );
4879
-	$backup_sizes = get_post_meta( $post->ID, '_wp_attachment_backup_sizes', true );
4880
-	$file = get_attached_file( $post_id );
4878
+	$meta = wp_get_attachment_metadata($post_id);
4879
+	$backup_sizes = get_post_meta($post->ID, '_wp_attachment_backup_sizes', true);
4880
+	$file = get_attached_file($post_id);
4881 4881
 
4882
-	if ( is_multisite() )
4883
-		delete_transient( 'dirsize_cache' );
4882
+	if (is_multisite())
4883
+		delete_transient('dirsize_cache');
4884 4884
 
4885 4885
 	/**
4886 4886
 	 * Fires before an attachment is deleted, at the start of wp_delete_attachment().
@@ -4889,70 +4889,70 @@  discard block
 block discarded – undo
4889 4889
 	 *
4890 4890
 	 * @param int $post_id Attachment ID.
4891 4891
 	 */
4892
-	do_action( 'delete_attachment', $post_id );
4892
+	do_action('delete_attachment', $post_id);
4893 4893
 
4894 4894
 	wp_delete_object_term_relationships($post_id, array('category', 'post_tag'));
4895 4895
 	wp_delete_object_term_relationships($post_id, get_object_taxonomies($post->post_type));
4896 4896
 
4897 4897
 	// Delete all for any posts.
4898
-	delete_metadata( 'post', null, '_thumbnail_id', $post_id, true );
4898
+	delete_metadata('post', null, '_thumbnail_id', $post_id, true);
4899 4899
 
4900
-	wp_defer_comment_counting( true );
4900
+	wp_defer_comment_counting(true);
4901 4901
 
4902
-	$comment_ids = $wpdb->get_col( $wpdb->prepare( "SELECT comment_ID FROM $wpdb->comments WHERE comment_post_ID = %d", $post_id ));
4903
-	foreach ( $comment_ids as $comment_id ) {
4904
-		wp_delete_comment( $comment_id, true );
4902
+	$comment_ids = $wpdb->get_col($wpdb->prepare("SELECT comment_ID FROM $wpdb->comments WHERE comment_post_ID = %d", $post_id));
4903
+	foreach ($comment_ids as $comment_id) {
4904
+		wp_delete_comment($comment_id, true);
4905 4905
 	}
4906 4906
 
4907
-	wp_defer_comment_counting( false );
4907
+	wp_defer_comment_counting(false);
4908 4908
 
4909
-	$post_meta_ids = $wpdb->get_col( $wpdb->prepare( "SELECT meta_id FROM $wpdb->postmeta WHERE post_id = %d ", $post_id ));
4910
-	foreach ( $post_meta_ids as $mid )
4911
-		delete_metadata_by_mid( 'post', $mid );
4909
+	$post_meta_ids = $wpdb->get_col($wpdb->prepare("SELECT meta_id FROM $wpdb->postmeta WHERE post_id = %d ", $post_id));
4910
+	foreach ($post_meta_ids as $mid)
4911
+		delete_metadata_by_mid('post', $mid);
4912 4912
 
4913 4913
 	/** This action is documented in wp-includes/post.php */
4914
-	do_action( 'delete_post', $post_id );
4915
-	$result = $wpdb->delete( $wpdb->posts, array( 'ID' => $post_id ) );
4916
-	if ( ! $result ) {
4914
+	do_action('delete_post', $post_id);
4915
+	$result = $wpdb->delete($wpdb->posts, array('ID' => $post_id));
4916
+	if ( ! $result) {
4917 4917
 		return false;
4918 4918
 	}
4919 4919
 	/** This action is documented in wp-includes/post.php */
4920
-	do_action( 'deleted_post', $post_id );
4920
+	do_action('deleted_post', $post_id);
4921 4921
 
4922 4922
 	$uploadpath = wp_get_upload_dir();
4923 4923
 
4924
-	if ( ! empty($meta['thumb']) ) {
4924
+	if ( ! empty($meta['thumb'])) {
4925 4925
 		// Don't delete the thumb if another attachment uses it.
4926
-		if (! $wpdb->get_row( $wpdb->prepare( "SELECT meta_id FROM $wpdb->postmeta WHERE meta_key = '_wp_attachment_metadata' AND meta_value LIKE %s AND post_id <> %d", '%' . $wpdb->esc_like( $meta['thumb'] ) . '%', $post_id)) ) {
4926
+		if ( ! $wpdb->get_row($wpdb->prepare("SELECT meta_id FROM $wpdb->postmeta WHERE meta_key = '_wp_attachment_metadata' AND meta_value LIKE %s AND post_id <> %d", '%'.$wpdb->esc_like($meta['thumb']).'%', $post_id))) {
4927 4927
 			$thumbfile = str_replace(basename($file), $meta['thumb'], $file);
4928 4928
 			/** This filter is documented in wp-includes/functions.php */
4929
-			$thumbfile = apply_filters( 'wp_delete_file', $thumbfile );
4930
-			@ unlink( path_join($uploadpath['basedir'], $thumbfile) );
4929
+			$thumbfile = apply_filters('wp_delete_file', $thumbfile);
4930
+			@ unlink(path_join($uploadpath['basedir'], $thumbfile));
4931 4931
 		}
4932 4932
 	}
4933 4933
 
4934 4934
 	// Remove intermediate and backup images if there are any.
4935
-	if ( isset( $meta['sizes'] ) && is_array( $meta['sizes'] ) ) {
4936
-		foreach ( $meta['sizes'] as $size => $sizeinfo ) {
4937
-			$intermediate_file = str_replace( basename( $file ), $sizeinfo['file'], $file );
4935
+	if (isset($meta['sizes']) && is_array($meta['sizes'])) {
4936
+		foreach ($meta['sizes'] as $size => $sizeinfo) {
4937
+			$intermediate_file = str_replace(basename($file), $sizeinfo['file'], $file);
4938 4938
 			/** This filter is documented in wp-includes/functions.php */
4939
-			$intermediate_file = apply_filters( 'wp_delete_file', $intermediate_file );
4940
-			@ unlink( path_join( $uploadpath['basedir'], $intermediate_file ) );
4939
+			$intermediate_file = apply_filters('wp_delete_file', $intermediate_file);
4940
+			@ unlink(path_join($uploadpath['basedir'], $intermediate_file));
4941 4941
 		}
4942 4942
 	}
4943 4943
 
4944
-	if ( is_array($backup_sizes) ) {
4945
-		foreach ( $backup_sizes as $size ) {
4946
-			$del_file = path_join( dirname($meta['file']), $size['file'] );
4944
+	if (is_array($backup_sizes)) {
4945
+		foreach ($backup_sizes as $size) {
4946
+			$del_file = path_join(dirname($meta['file']), $size['file']);
4947 4947
 			/** This filter is documented in wp-includes/functions.php */
4948
-			$del_file = apply_filters( 'wp_delete_file', $del_file );
4949
-			@ unlink( path_join($uploadpath['basedir'], $del_file) );
4948
+			$del_file = apply_filters('wp_delete_file', $del_file);
4949
+			@ unlink(path_join($uploadpath['basedir'], $del_file));
4950 4950
 		}
4951 4951
 	}
4952 4952
 
4953
-	wp_delete_file( $file );
4953
+	wp_delete_file($file);
4954 4954
 
4955
-	clean_post_cache( $post );
4955
+	clean_post_cache($post);
4956 4956
 
4957 4957
 	return $post;
4958 4958
 }
@@ -4966,14 +4966,14 @@  discard block
 block discarded – undo
4966 4966
  * @param bool $unfiltered Optional. If true, filters are not run. Default false.
4967 4967
  * @return mixed Attachment meta field. False on failure.
4968 4968
  */
4969
-function wp_get_attachment_metadata( $post_id = 0, $unfiltered = false ) {
4969
+function wp_get_attachment_metadata($post_id = 0, $unfiltered = false) {
4970 4970
 	$post_id = (int) $post_id;
4971
-	if ( !$post = get_post( $post_id ) )
4971
+	if ( ! $post = get_post($post_id))
4972 4972
 		return false;
4973 4973
 
4974
-	$data = get_post_meta( $post->ID, '_wp_attachment_metadata', true );
4974
+	$data = get_post_meta($post->ID, '_wp_attachment_metadata', true);
4975 4975
 
4976
-	if ( $unfiltered )
4976
+	if ($unfiltered)
4977 4977
 		return $data;
4978 4978
 
4979 4979
 	/**
@@ -4985,7 +4985,7 @@  discard block
 block discarded – undo
4985 4985
 	 *                            if the object does not exist.
4986 4986
 	 * @param int        $post_id Attachment ID.
4987 4987
 	 */
4988
-	return apply_filters( 'wp_get_attachment_metadata', $data, $post->ID );
4988
+	return apply_filters('wp_get_attachment_metadata', $data, $post->ID);
4989 4989
 }
4990 4990
 
4991 4991
 /**
@@ -4997,9 +4997,9 @@  discard block
 block discarded – undo
4997 4997
  * @param array $data    Attachment data.
4998 4998
  * @return int|bool False if $post is invalid.
4999 4999
  */
5000
-function wp_update_attachment_metadata( $post_id, $data ) {
5000
+function wp_update_attachment_metadata($post_id, $data) {
5001 5001
 	$post_id = (int) $post_id;
5002
-	if ( !$post = get_post( $post_id ) )
5002
+	if ( ! $post = get_post($post_id))
5003 5003
 		return false;
5004 5004
 
5005 5005
 	/**
@@ -5010,10 +5010,10 @@  discard block
 block discarded – undo
5010 5010
 	 * @param array $data    Array of updated attachment meta data.
5011 5011
 	 * @param int   $post_id Attachment ID.
5012 5012
 	 */
5013
-	if ( $data = apply_filters( 'wp_update_attachment_metadata', $data, $post->ID ) )
5014
-		return update_post_meta( $post->ID, '_wp_attachment_metadata', $data );
5013
+	if ($data = apply_filters('wp_update_attachment_metadata', $data, $post->ID))
5014
+		return update_post_meta($post->ID, '_wp_attachment_metadata', $data);
5015 5015
 	else
5016
-		return delete_post_meta( $post->ID, '_wp_attachment_metadata' );
5016
+		return delete_post_meta($post->ID, '_wp_attachment_metadata');
5017 5017
 }
5018 5018
 
5019 5019
 /**
@@ -5026,29 +5026,29 @@  discard block
 block discarded – undo
5026 5026
  * @param int $post_id Optional. Attachment ID. Default 0.
5027 5027
  * @return string|false Attachment URL, otherwise false.
5028 5028
  */
5029
-function wp_get_attachment_url( $post_id = 0 ) {
5029
+function wp_get_attachment_url($post_id = 0) {
5030 5030
 	$post_id = (int) $post_id;
5031
-	if ( !$post = get_post( $post_id ) )
5031
+	if ( ! $post = get_post($post_id))
5032 5032
 		return false;
5033 5033
 
5034
-	if ( 'attachment' != $post->post_type )
5034
+	if ('attachment' != $post->post_type)
5035 5035
 		return false;
5036 5036
 
5037 5037
 	$url = '';
5038 5038
 	// Get attached file.
5039
-	if ( $file = get_post_meta( $post->ID, '_wp_attached_file', true ) ) {
5039
+	if ($file = get_post_meta($post->ID, '_wp_attached_file', true)) {
5040 5040
 		// Get upload directory.
5041
-		if ( ( $uploads = wp_get_upload_dir() ) && false === $uploads['error'] ) {
5041
+		if (($uploads = wp_get_upload_dir()) && false === $uploads['error']) {
5042 5042
 			// Check that the upload base exists in the file location.
5043
-			if ( 0 === strpos( $file, $uploads['basedir'] ) ) {
5043
+			if (0 === strpos($file, $uploads['basedir'])) {
5044 5044
 				// Replace file location with url location.
5045 5045
 				$url = str_replace($uploads['basedir'], $uploads['baseurl'], $file);
5046
-			} elseif ( false !== strpos($file, 'wp-content/uploads') ) {
5046
+			} elseif (false !== strpos($file, 'wp-content/uploads')) {
5047 5047
 				// Get the directory name relative to the basedir (back compat for pre-2.7 uploads)
5048
-				$url = trailingslashit( $uploads['baseurl'] . '/' . _wp_get_attachment_relative_path( $file ) ) . basename( $file );
5048
+				$url = trailingslashit($uploads['baseurl'].'/'._wp_get_attachment_relative_path($file)).basename($file);
5049 5049
 			} else {
5050 5050
 				// It's a newly-uploaded file, therefore $file is relative to the basedir.
5051
-				$url = $uploads['baseurl'] . "/$file";
5051
+				$url = $uploads['baseurl']."/$file";
5052 5052
 			}
5053 5053
 		}
5054 5054
 	}
@@ -5057,13 +5057,13 @@  discard block
 block discarded – undo
5057 5057
 	 * If any of the above options failed, Fallback on the GUID as used pre-2.7,
5058 5058
 	 * not recommended to rely upon this.
5059 5059
 	 */
5060
-	if ( empty($url) ) {
5061
-		$url = get_the_guid( $post->ID );
5060
+	if (empty($url)) {
5061
+		$url = get_the_guid($post->ID);
5062 5062
 	}
5063 5063
 
5064 5064
 	// On SSL front end, URLs should be HTTPS.
5065
-	if ( is_ssl() && ! is_admin() && 'wp-login.php' !== $GLOBALS['pagenow'] ) {
5066
-		$url = set_url_scheme( $url );
5065
+	if (is_ssl() && ! is_admin() && 'wp-login.php' !== $GLOBALS['pagenow']) {
5066
+		$url = set_url_scheme($url);
5067 5067
 	}
5068 5068
 
5069 5069
 	/**
@@ -5074,9 +5074,9 @@  discard block
 block discarded – undo
5074 5074
 	 * @param string $url     URL for the given attachment.
5075 5075
 	 * @param int    $post_id Attachment ID.
5076 5076
 	 */
5077
-	$url = apply_filters( 'wp_get_attachment_url', $url, $post->ID );
5077
+	$url = apply_filters('wp_get_attachment_url', $url, $post->ID);
5078 5078
 
5079
-	if ( empty( $url ) )
5079
+	if (empty($url))
5080 5080
 		return false;
5081 5081
 
5082 5082
 	return $url;
@@ -5090,13 +5090,13 @@  discard block
 block discarded – undo
5090 5090
  * @param int $post_id Optional. Attachment ID. Default is the ID of the global `$post`.
5091 5091
  * @return string|false False on failure. Attachment caption on success.
5092 5092
  */
5093
-function wp_get_attachment_caption( $post_id = 0 ) {
5093
+function wp_get_attachment_caption($post_id = 0) {
5094 5094
 	$post_id = (int) $post_id;
5095
-	if ( ! $post = get_post( $post_id ) ) {
5095
+	if ( ! $post = get_post($post_id)) {
5096 5096
 		return false;
5097 5097
 	}
5098 5098
 
5099
-	if ( 'attachment' !== $post->post_type ) {
5099
+	if ('attachment' !== $post->post_type) {
5100 5100
 		return false;
5101 5101
 	}
5102 5102
 
@@ -5110,7 +5110,7 @@  discard block
 block discarded – undo
5110 5110
 	 * @param string $caption Caption for the given attachment.
5111 5111
 	 * @param int    $post_id Attachment ID.
5112 5112
 	 */
5113
-	return apply_filters( 'wp_get_attachment_caption', $caption, $post->ID );
5113
+	return apply_filters('wp_get_attachment_caption', $caption, $post->ID);
5114 5114
 }
5115 5115
 
5116 5116
 /**
@@ -5121,16 +5121,16 @@  discard block
 block discarded – undo
5121 5121
  * @param int $post_id Optional. Attachment ID. Default 0.
5122 5122
  * @return string|false False on failure. Thumbnail file path on success.
5123 5123
  */
5124
-function wp_get_attachment_thumb_file( $post_id = 0 ) {
5124
+function wp_get_attachment_thumb_file($post_id = 0) {
5125 5125
 	$post_id = (int) $post_id;
5126
-	if ( !$post = get_post( $post_id ) )
5126
+	if ( ! $post = get_post($post_id))
5127 5127
 		return false;
5128
-	if ( !is_array( $imagedata = wp_get_attachment_metadata( $post->ID ) ) )
5128
+	if ( ! is_array($imagedata = wp_get_attachment_metadata($post->ID)))
5129 5129
 		return false;
5130 5130
 
5131
-	$file = get_attached_file( $post->ID );
5131
+	$file = get_attached_file($post->ID);
5132 5132
 
5133
-	if ( !empty($imagedata['thumb']) && ($thumbfile = str_replace(basename($file), $imagedata['thumb'], $file)) && file_exists($thumbfile) ) {
5133
+	if ( ! empty($imagedata['thumb']) && ($thumbfile = str_replace(basename($file), $imagedata['thumb'], $file)) && file_exists($thumbfile)) {
5134 5134
 		/**
5135 5135
 		 * Filters the attachment thumbnail file path.
5136 5136
 		 *
@@ -5139,7 +5139,7 @@  discard block
 block discarded – undo
5139 5139
 		 * @param string $thumbfile File path to the attachment thumbnail.
5140 5140
 		 * @param int    $post_id   Attachment ID.
5141 5141
 		 */
5142
-		return apply_filters( 'wp_get_attachment_thumb_file', $thumbfile, $post->ID );
5142
+		return apply_filters('wp_get_attachment_thumb_file', $thumbfile, $post->ID);
5143 5143
 	}
5144 5144
 	return false;
5145 5145
 }
@@ -5152,18 +5152,18 @@  discard block
 block discarded – undo
5152 5152
  * @param int $post_id Optional. Attachment ID. Default 0.
5153 5153
  * @return string|false False on failure. Thumbnail URL on success.
5154 5154
  */
5155
-function wp_get_attachment_thumb_url( $post_id = 0 ) {
5155
+function wp_get_attachment_thumb_url($post_id = 0) {
5156 5156
 	$post_id = (int) $post_id;
5157
-	if ( !$post = get_post( $post_id ) )
5157
+	if ( ! $post = get_post($post_id))
5158 5158
 		return false;
5159
-	if ( !$url = wp_get_attachment_url( $post->ID ) )
5159
+	if ( ! $url = wp_get_attachment_url($post->ID))
5160 5160
 		return false;
5161 5161
 
5162
-	$sized = image_downsize( $post_id, 'thumbnail' );
5163
-	if ( $sized )
5162
+	$sized = image_downsize($post_id, 'thumbnail');
5163
+	if ($sized)
5164 5164
 		return $sized[0];
5165 5165
 
5166
-	if ( !$thumb = wp_get_attachment_thumb_file( $post->ID ) )
5166
+	if ( ! $thumb = wp_get_attachment_thumb_file($post->ID))
5167 5167
 		return false;
5168 5168
 
5169 5169
 	$url = str_replace(basename($url), basename($thumb), $url);
@@ -5176,7 +5176,7 @@  discard block
 block discarded – undo
5176 5176
 	 * @param string $url     URL for the attachment thumbnail.
5177 5177
 	 * @param int    $post_id Attachment ID.
5178 5178
 	 */
5179
-	return apply_filters( 'wp_get_attachment_thumb_url', $url, $post->ID );
5179
+	return apply_filters('wp_get_attachment_thumb_url', $url, $post->ID);
5180 5180
 }
5181 5181
 
5182 5182
 /**
@@ -5188,40 +5188,40 @@  discard block
 block discarded – undo
5188 5188
  * @param int|WP_Post $post Optional. Attachment ID or object. Default is global $post.
5189 5189
  * @return bool True if one of the accepted types, false otherwise.
5190 5190
  */
5191
-function wp_attachment_is( $type, $post = null ) {
5192
-	if ( ! $post = get_post( $post ) ) {
5191
+function wp_attachment_is($type, $post = null) {
5192
+	if ( ! $post = get_post($post)) {
5193 5193
 		return false;
5194 5194
 	}
5195 5195
 
5196
-	if ( ! $file = get_attached_file( $post->ID ) ) {
5196
+	if ( ! $file = get_attached_file($post->ID)) {
5197 5197
 		return false;
5198 5198
 	}
5199 5199
 
5200
-	if ( 0 === strpos( $post->post_mime_type, $type . '/' ) ) {
5200
+	if (0 === strpos($post->post_mime_type, $type.'/')) {
5201 5201
 		return true;
5202 5202
 	}
5203 5203
 
5204
-	$check = wp_check_filetype( $file );
5205
-	if ( empty( $check['ext'] ) ) {
5204
+	$check = wp_check_filetype($file);
5205
+	if (empty($check['ext'])) {
5206 5206
 		return false;
5207 5207
 	}
5208 5208
 
5209 5209
 	$ext = $check['ext'];
5210 5210
 
5211
-	if ( 'import' !== $post->post_mime_type ) {
5211
+	if ('import' !== $post->post_mime_type) {
5212 5212
 		return $type === $ext;
5213 5213
 	}
5214 5214
 
5215
-	switch ( $type ) {
5215
+	switch ($type) {
5216 5216
 	case 'image':
5217
-		$image_exts = array( 'jpg', 'jpeg', 'jpe', 'gif', 'png' );
5218
-		return in_array( $ext, $image_exts );
5217
+		$image_exts = array('jpg', 'jpeg', 'jpe', 'gif', 'png');
5218
+		return in_array($ext, $image_exts);
5219 5219
 
5220 5220
 	case 'audio':
5221
-		return in_array( $ext, wp_get_audio_extensions() );
5221
+		return in_array($ext, wp_get_audio_extensions());
5222 5222
 
5223 5223
 	case 'video':
5224
-		return in_array( $ext, wp_get_video_extensions() );
5224
+		return in_array($ext, wp_get_video_extensions());
5225 5225
 
5226 5226
 	default:
5227 5227
 		return $type === $ext;
@@ -5238,8 +5238,8 @@  discard block
 block discarded – undo
5238 5238
  * @param int|WP_Post $post Optional. Attachment ID or object. Default is global $post.
5239 5239
  * @return bool Whether the attachment is an image.
5240 5240
  */
5241
-function wp_attachment_is_image( $post = null ) {
5242
-	return wp_attachment_is( 'image', $post );
5241
+function wp_attachment_is_image($post = null) {
5242
+	return wp_attachment_is('image', $post);
5243 5243
 }
5244 5244
 
5245 5245
 /**
@@ -5250,22 +5250,22 @@  discard block
 block discarded – undo
5250 5250
  * @param string|int $mime MIME type or attachment ID.
5251 5251
  * @return string|false Icon, false otherwise.
5252 5252
  */
5253
-function wp_mime_type_icon( $mime = 0 ) {
5254
-	if ( !is_numeric($mime) )
5253
+function wp_mime_type_icon($mime = 0) {
5254
+	if ( ! is_numeric($mime))
5255 5255
 		$icon = wp_cache_get("mime_type_icon_$mime");
5256 5256
 
5257 5257
 	$post_id = 0;
5258
-	if ( empty($icon) ) {
5258
+	if (empty($icon)) {
5259 5259
 		$post_mimes = array();
5260
-		if ( is_numeric($mime) ) {
5260
+		if (is_numeric($mime)) {
5261 5261
 			$mime = (int) $mime;
5262
-			if ( $post = get_post( $mime ) ) {
5262
+			if ($post = get_post($mime)) {
5263 5263
 				$post_id = (int) $post->ID;
5264
-				$file = get_attached_file( $post_id );
5264
+				$file = get_attached_file($post_id);
5265 5265
 				$ext = preg_replace('/^.+?\.([^.]+)$/', '$1', $file);
5266
-				if ( !empty($ext) ) {
5266
+				if ( ! empty($ext)) {
5267 5267
 					$post_mimes[] = $ext;
5268
-					if ( $ext_type = wp_ext2type( $ext ) )
5268
+					if ($ext_type = wp_ext2type($ext))
5269 5269
 						$post_mimes[] = $ext_type;
5270 5270
 				}
5271 5271
 				$mime = $post->post_mime_type;
@@ -5278,7 +5278,7 @@  discard block
 block discarded – undo
5278 5278
 
5279 5279
 		$icon_files = wp_cache_get('icon_files');
5280 5280
 
5281
-		if ( !is_array($icon_files) ) {
5281
+		if ( ! is_array($icon_files)) {
5282 5282
 			/**
5283 5283
 			 * Filters the icon directory path.
5284 5284
 			 *
@@ -5286,7 +5286,7 @@  discard block
 block discarded – undo
5286 5286
 			 *
5287 5287
 			 * @param string $path Icon directory absolute path.
5288 5288
 			 */
5289
-			$icon_dir = apply_filters( 'icon_dir', ABSPATH . WPINC . '/images/media' );
5289
+			$icon_dir = apply_filters('icon_dir', ABSPATH.WPINC.'/images/media');
5290 5290
 
5291 5291
 			/**
5292 5292
 			 * Filters the icon directory URI.
@@ -5295,7 +5295,7 @@  discard block
 block discarded – undo
5295 5295
 			 *
5296 5296
 			 * @param string $uri Icon directory URI.
5297 5297
 			 */
5298
-			$icon_dir_uri = apply_filters( 'icon_dir_uri', includes_url( 'images/media' ) );
5298
+			$icon_dir_uri = apply_filters('icon_dir_uri', includes_url('images/media'));
5299 5299
 
5300 5300
 			/**
5301 5301
 			 * Filters the list of icon directory URIs.
@@ -5304,19 +5304,19 @@  discard block
 block discarded – undo
5304 5304
 			 *
5305 5305
 			 * @param array $uris List of icon directory URIs.
5306 5306
 			 */
5307
-			$dirs = apply_filters( 'icon_dirs', array( $icon_dir => $icon_dir_uri ) );
5307
+			$dirs = apply_filters('icon_dirs', array($icon_dir => $icon_dir_uri));
5308 5308
 			$icon_files = array();
5309
-			while ( $dirs ) {
5310
-				$keys = array_keys( $dirs );
5311
-				$dir = array_shift( $keys );
5309
+			while ($dirs) {
5310
+				$keys = array_keys($dirs);
5311
+				$dir = array_shift($keys);
5312 5312
 				$uri = array_shift($dirs);
5313
-				if ( $dh = opendir($dir) ) {
5314
-					while ( false !== $file = readdir($dh) ) {
5313
+				if ($dh = opendir($dir)) {
5314
+					while (false !== $file = readdir($dh)) {
5315 5315
 						$file = basename($file);
5316
-						if ( substr($file, 0, 1) == '.' )
5316
+						if (substr($file, 0, 1) == '.')
5317 5317
 							continue;
5318
-						if ( !in_array(strtolower(substr($file, -4)), array('.png', '.gif', '.jpg') ) ) {
5319
-							if ( is_dir("$dir/$file") )
5318
+						if ( ! in_array(strtolower(substr($file, -4)), array('.png', '.gif', '.jpg'))) {
5319
+							if (is_dir("$dir/$file"))
5320 5320
 								$dirs["$dir/$file"] = "$uri/$file";
5321 5321
 							continue;
5322 5322
 						}
@@ -5325,15 +5325,15 @@  discard block
 block discarded – undo
5325 5325
 					closedir($dh);
5326 5326
 				}
5327 5327
 			}
5328
-			wp_cache_add( 'icon_files', $icon_files, 'default', 600 );
5328
+			wp_cache_add('icon_files', $icon_files, 'default', 600);
5329 5329
 		}
5330 5330
 
5331 5331
 		$types = array();
5332 5332
 		// Icon basename - extension = MIME wildcard.
5333
-		foreach ( $icon_files as $file => $uri )
5334
-			$types[ preg_replace('/^([^.]*).*$/', '$1', basename($file)) ] =& $icon_files[$file];
5333
+		foreach ($icon_files as $file => $uri)
5334
+			$types[preg_replace('/^([^.]*).*$/', '$1', basename($file))] = & $icon_files[$file];
5335 5335
 
5336
-		if ( ! empty($mime) ) {
5336
+		if ( ! empty($mime)) {
5337 5337
 			$post_mimes[] = substr($mime, 0, strpos($mime, '/'));
5338 5338
 			$post_mimes[] = substr($mime, strpos($mime, '/') + 1);
5339 5339
 			$post_mimes[] = str_replace('/', '_', $mime);
@@ -5342,15 +5342,15 @@  discard block
 block discarded – undo
5342 5342
 		$matches = wp_match_mime_types(array_keys($types), $post_mimes);
5343 5343
 		$matches['default'] = array('default');
5344 5344
 
5345
-		foreach ( $matches as $match => $wilds ) {
5346
-			foreach ( $wilds as $wild ) {
5347
-				if ( ! isset( $types[ $wild ] ) ) {
5345
+		foreach ($matches as $match => $wilds) {
5346
+			foreach ($wilds as $wild) {
5347
+				if ( ! isset($types[$wild])) {
5348 5348
 					continue;
5349 5349
 				}
5350 5350
 
5351
-				$icon = $types[ $wild ];
5352
-				if ( ! is_numeric( $mime ) ) {
5353
-					wp_cache_add( "mime_type_icon_$mime", $icon );
5351
+				$icon = $types[$wild];
5352
+				if ( ! is_numeric($mime)) {
5353
+					wp_cache_add("mime_type_icon_$mime", $icon);
5354 5354
 				}
5355 5355
 				break 2;
5356 5356
 			}
@@ -5367,7 +5367,7 @@  discard block
 block discarded – undo
5367 5367
 	 * @param int    $post_id Attachment ID. Will equal 0 if the function passed
5368 5368
 	 *                        the mime type.
5369 5369
 	 */
5370
-	return apply_filters( 'wp_mime_type_icon', $icon, $mime, $post_id );
5370
+	return apply_filters('wp_mime_type_icon', $icon, $mime, $post_id);
5371 5371
 }
5372 5372
 
5373 5373
 /**
@@ -5389,27 +5389,27 @@  discard block
 block discarded – undo
5389 5389
  * @param WP_Post $post        The Post Object
5390 5390
  * @param WP_Post $post_before The Previous Post Object
5391 5391
  */
5392
-function wp_check_for_changed_slugs( $post_id, $post, $post_before ) {
5392
+function wp_check_for_changed_slugs($post_id, $post, $post_before) {
5393 5393
 	// Don't bother if it hasn't changed.
5394
-	if ( $post->post_name == $post_before->post_name ) {
5394
+	if ($post->post_name == $post_before->post_name) {
5395 5395
 		return;
5396 5396
 	}
5397 5397
 
5398 5398
 	// We're only concerned with published, non-hierarchical objects.
5399
-	if ( ! ( 'publish' === $post->post_status || ( 'attachment' === get_post_type( $post ) && 'inherit' === $post->post_status ) ) || is_post_type_hierarchical( $post->post_type ) ) {
5399
+	if ( ! ('publish' === $post->post_status || ('attachment' === get_post_type($post) && 'inherit' === $post->post_status)) || is_post_type_hierarchical($post->post_type)) {
5400 5400
 		return;
5401 5401
 	}
5402 5402
 
5403
-	$old_slugs = (array) get_post_meta( $post_id, '_wp_old_slug' );
5403
+	$old_slugs = (array) get_post_meta($post_id, '_wp_old_slug');
5404 5404
 
5405 5405
 	// If we haven't added this old slug before, add it now.
5406
-	if ( ! empty( $post_before->post_name ) && ! in_array( $post_before->post_name, $old_slugs ) ) {
5407
-		add_post_meta( $post_id, '_wp_old_slug', $post_before->post_name );
5406
+	if ( ! empty($post_before->post_name) && ! in_array($post_before->post_name, $old_slugs)) {
5407
+		add_post_meta($post_id, '_wp_old_slug', $post_before->post_name);
5408 5408
 	}
5409 5409
 
5410 5410
 	// If the new slug was used previously, delete it from the list.
5411
-	if ( in_array( $post->post_name, $old_slugs ) ) {
5412
-		delete_post_meta( $post_id, '_wp_old_slug', $post->post_name );
5411
+	if (in_array($post->post_name, $old_slugs)) {
5412
+		delete_post_meta($post_id, '_wp_old_slug', $post->post_name);
5413 5413
 	}
5414 5414
 }
5415 5415
 
@@ -5427,8 +5427,8 @@  discard block
 block discarded – undo
5427 5427
  * @param string|array $post_type Single post type or an array of post types. Currently only supports 'post' or 'page'.
5428 5428
  * @return string SQL code that can be added to a where clause.
5429 5429
  */
5430
-function get_private_posts_cap_sql( $post_type ) {
5431
-	return get_posts_by_author_sql( $post_type, false );
5430
+function get_private_posts_cap_sql($post_type) {
5431
+	return get_posts_by_author_sql($post_type, false);
5432 5432
 }
5433 5433
 
5434 5434
 /**
@@ -5448,19 +5448,19 @@  discard block
 block discarded – undo
5448 5448
  *                                    $current_user.  Default false.
5449 5449
  * @return string SQL WHERE code that can be added to a query.
5450 5450
  */
5451
-function get_posts_by_author_sql( $post_type, $full = true, $post_author = null, $public_only = false ) {
5451
+function get_posts_by_author_sql($post_type, $full = true, $post_author = null, $public_only = false) {
5452 5452
 	global $wpdb;
5453 5453
 
5454
-	if ( is_array( $post_type ) ) {
5454
+	if (is_array($post_type)) {
5455 5455
 		$post_types = $post_type;
5456 5456
 	} else {
5457
-		$post_types = array( $post_type );
5457
+		$post_types = array($post_type);
5458 5458
 	}
5459 5459
 
5460 5460
 	$post_type_clauses = array();
5461
-	foreach ( $post_types as $post_type ) {
5462
-		$post_type_obj = get_post_type_object( $post_type );
5463
-		if ( ! $post_type_obj ) {
5461
+	foreach ($post_types as $post_type) {
5462
+		$post_type_obj = get_post_type_object($post_type);
5463
+		if ( ! $post_type_obj) {
5464 5464
 			continue;
5465 5465
 		}
5466 5466
 
@@ -5473,42 +5473,42 @@  discard block
 block discarded – undo
5473 5473
 		 *
5474 5474
 		 * @param string $cap Capability.
5475 5475
 		 */
5476
-		if ( ! $cap = apply_filters( 'pub_priv_sql_capability', '' ) ) {
5477
-			$cap = current_user_can( $post_type_obj->cap->read_private_posts );
5476
+		if ( ! $cap = apply_filters('pub_priv_sql_capability', '')) {
5477
+			$cap = current_user_can($post_type_obj->cap->read_private_posts);
5478 5478
 		}
5479 5479
 
5480 5480
 		// Only need to check the cap if $public_only is false.
5481 5481
 		$post_status_sql = "post_status = 'publish'";
5482
-		if ( false === $public_only ) {
5483
-			if ( $cap ) {
5482
+		if (false === $public_only) {
5483
+			if ($cap) {
5484 5484
 				// Does the user have the capability to view private posts? Guess so.
5485 5485
 				$post_status_sql .= " OR post_status = 'private'";
5486
-			} elseif ( is_user_logged_in() ) {
5486
+			} elseif (is_user_logged_in()) {
5487 5487
 				// Users can view their own private posts.
5488 5488
 				$id = get_current_user_id();
5489
-				if ( null === $post_author || ! $full ) {
5489
+				if (null === $post_author || ! $full) {
5490 5490
 					$post_status_sql .= " OR post_status = 'private' AND post_author = $id";
5491
-				} elseif ( $id == (int) $post_author ) {
5491
+				} elseif ($id == (int) $post_author) {
5492 5492
 					$post_status_sql .= " OR post_status = 'private'";
5493 5493
 				} // else none
5494 5494
 			} // else none
5495 5495
 		}
5496 5496
 
5497
-		$post_type_clauses[] = "( post_type = '" . $post_type . "' AND ( $post_status_sql ) )";
5497
+		$post_type_clauses[] = "( post_type = '".$post_type."' AND ( $post_status_sql ) )";
5498 5498
 	}
5499 5499
 
5500
-	if ( empty( $post_type_clauses ) ) {
5500
+	if (empty($post_type_clauses)) {
5501 5501
 		return $full ? 'WHERE 1 = 0' : '1 = 0';
5502 5502
 	}
5503 5503
 
5504
-	$sql = '( '. implode( ' OR ', $post_type_clauses ) . ' )';
5504
+	$sql = '( '.implode(' OR ', $post_type_clauses).' )';
5505 5505
 
5506
-	if ( null !== $post_author ) {
5507
-		$sql .= $wpdb->prepare( ' AND post_author = %d', $post_author );
5506
+	if (null !== $post_author) {
5507
+		$sql .= $wpdb->prepare(' AND post_author = %d', $post_author);
5508 5508
 	}
5509 5509
 
5510
-	if ( $full ) {
5511
-		$sql = 'WHERE ' . $sql;
5510
+	if ($full) {
5511
+		$sql = 'WHERE '.$sql;
5512 5512
 	}
5513 5513
 
5514 5514
 	return $sql;
@@ -5532,7 +5532,7 @@  discard block
 block discarded – undo
5532 5532
  * @param string $post_type Optional. The post type to check. Default 'any'.
5533 5533
  * @return string The date of the last post.
5534 5534
  */
5535
-function get_lastpostdate( $timezone = 'server', $post_type = 'any' ) {
5535
+function get_lastpostdate($timezone = 'server', $post_type = 'any') {
5536 5536
 	/**
5537 5537
 	 * Filters the date the last post was published.
5538 5538
 	 *
@@ -5542,7 +5542,7 @@  discard block
 block discarded – undo
5542 5542
 	 * @param string $timezone Location to use for getting the post published date.
5543 5543
 	 *                         See get_lastpostdate() for accepted `$timezone` values.
5544 5544
 	 */
5545
-	return apply_filters( 'get_lastpostdate', _get_last_post_time( $timezone, 'date', $post_type ), $timezone );
5545
+	return apply_filters('get_lastpostdate', _get_last_post_time($timezone, 'date', $post_type), $timezone);
5546 5546
 }
5547 5547
 
5548 5548
 /**
@@ -5561,7 +5561,7 @@  discard block
 block discarded – undo
5561 5561
  * @param string $post_type Optional. The post type to check. Default 'any'.
5562 5562
  * @return string The timestamp.
5563 5563
  */
5564
-function get_lastpostmodified( $timezone = 'server', $post_type = 'any' ) {
5564
+function get_lastpostmodified($timezone = 'server', $post_type = 'any') {
5565 5565
 	/**
5566 5566
 	 * Pre-filter the return value of get_lastpostmodified() before the query is run.
5567 5567
 	 *
@@ -5573,15 +5573,15 @@  discard block
 block discarded – undo
5573 5573
 	 *                                 See get_lastpostdate() for accepted `$timezone` values.
5574 5574
 	 * @param string $post_type        The post type to check.
5575 5575
 	 */
5576
-	$lastpostmodified = apply_filters( 'pre_get_lastpostmodified', false, $timezone, $post_type );
5577
-	if ( false !== $lastpostmodified ) {
5576
+	$lastpostmodified = apply_filters('pre_get_lastpostmodified', false, $timezone, $post_type);
5577
+	if (false !== $lastpostmodified) {
5578 5578
 		return $lastpostmodified;
5579 5579
 	}
5580 5580
 
5581
-	$lastpostmodified = _get_last_post_time( $timezone, 'modified', $post_type );
5581
+	$lastpostmodified = _get_last_post_time($timezone, 'modified', $post_type);
5582 5582
 
5583 5583
 	$lastpostdate = get_lastpostdate($timezone);
5584
-	if ( $lastpostdate > $lastpostmodified ) {
5584
+	if ($lastpostdate > $lastpostmodified) {
5585 5585
 		$lastpostmodified = $lastpostdate;
5586 5586
 	}
5587 5587
 
@@ -5594,7 +5594,7 @@  discard block
 block discarded – undo
5594 5594
 	 * @param string $timezone         Location to use for getting the post modified date.
5595 5595
 	 *                                 See get_lastpostdate() for accepted `$timezone` values.
5596 5596
 	 */
5597
-	return apply_filters( 'get_lastpostmodified', $lastpostmodified, $timezone );
5597
+	return apply_filters('get_lastpostmodified', $lastpostmodified, $timezone);
5598 5598
 }
5599 5599
 
5600 5600
 /**
@@ -5612,34 +5612,34 @@  discard block
 block discarded – undo
5612 5612
  * @param string $post_type Optional. The post type to check. Default 'any'.
5613 5613
  * @return string|false The timestamp.
5614 5614
  */
5615
-function _get_last_post_time( $timezone, $field, $post_type = 'any' ) {
5615
+function _get_last_post_time($timezone, $field, $post_type = 'any') {
5616 5616
 	global $wpdb;
5617 5617
 
5618
-	if ( ! in_array( $field, array( 'date', 'modified' ) ) ) {
5618
+	if ( ! in_array($field, array('date', 'modified'))) {
5619 5619
 		return false;
5620 5620
 	}
5621 5621
 
5622
-	$timezone = strtolower( $timezone );
5622
+	$timezone = strtolower($timezone);
5623 5623
 
5624 5624
 	$key = "lastpost{$field}:$timezone";
5625
-	if ( 'any' !== $post_type ) {
5626
-		$key .= ':' . sanitize_key( $post_type );
5625
+	if ('any' !== $post_type) {
5626
+		$key .= ':'.sanitize_key($post_type);
5627 5627
 	}
5628 5628
 
5629
-	$date = wp_cache_get( $key, 'timeinfo' );
5630
-	if ( false !== $date ) {
5629
+	$date = wp_cache_get($key, 'timeinfo');
5630
+	if (false !== $date) {
5631 5631
 		return $date;
5632 5632
 	}
5633 5633
 
5634
-	if ( 'any' === $post_type ) {
5635
-		$post_types = get_post_types( array( 'public' => true ) );
5636
-		array_walk( $post_types, array( $wpdb, 'escape_by_ref' ) );
5637
-		$post_types = "'" . implode( "', '", $post_types ) . "'";
5634
+	if ('any' === $post_type) {
5635
+		$post_types = get_post_types(array('public' => true));
5636
+		array_walk($post_types, array($wpdb, 'escape_by_ref'));
5637
+		$post_types = "'".implode("', '", $post_types)."'";
5638 5638
 	} else {
5639
-		$post_types = "'" . sanitize_key( $post_type ) . "'";
5639
+		$post_types = "'".sanitize_key($post_type)."'";
5640 5640
 	}
5641 5641
 
5642
-	switch ( $timezone ) {
5642
+	switch ($timezone) {
5643 5643
 		case 'gmt':
5644 5644
 			$date = $wpdb->get_var("SELECT post_{$field}_gmt FROM $wpdb->posts WHERE post_status = 'publish' AND post_type IN ({$post_types}) ORDER BY post_{$field}_gmt DESC LIMIT 1");
5645 5645
 			break;
@@ -5647,13 +5647,13 @@  discard block
 block discarded – undo
5647 5647
 			$date = $wpdb->get_var("SELECT post_{$field} FROM $wpdb->posts WHERE post_status = 'publish' AND post_type IN ({$post_types}) ORDER BY post_{$field}_gmt DESC LIMIT 1");
5648 5648
 			break;
5649 5649
 		case 'server':
5650
-			$add_seconds_server = date( 'Z' );
5650
+			$add_seconds_server = date('Z');
5651 5651
 			$date = $wpdb->get_var("SELECT DATE_ADD(post_{$field}_gmt, INTERVAL '$add_seconds_server' SECOND) FROM $wpdb->posts WHERE post_status = 'publish' AND post_type IN ({$post_types}) ORDER BY post_{$field}_gmt DESC LIMIT 1");
5652 5652
 			break;
5653 5653
 	}
5654 5654
 
5655
-	if ( $date ) {
5656
-		wp_cache_set( $key, $date, 'timeinfo' );
5655
+	if ($date) {
5656
+		wp_cache_set($key, $date, 'timeinfo');
5657 5657
 
5658 5658
 		return $date;
5659 5659
 	}
@@ -5668,12 +5668,12 @@  discard block
 block discarded – undo
5668 5668
  *
5669 5669
  * @param array $posts Array of post objects, passed by reference.
5670 5670
  */
5671
-function update_post_cache( &$posts ) {
5672
-	if ( ! $posts )
5671
+function update_post_cache(&$posts) {
5672
+	if ( ! $posts)
5673 5673
 		return;
5674 5674
 
5675
-	foreach ( $posts as $post )
5676
-		wp_cache_add( $post->ID, $post, 'posts' );
5675
+	foreach ($posts as $post)
5676
+		wp_cache_add($post->ID, $post, 'posts');
5677 5677
 }
5678 5678
 
5679 5679
 /**
@@ -5691,22 +5691,22 @@  discard block
 block discarded – undo
5691 5691
  *
5692 5692
  * @param int|WP_Post $post Post ID or post object to remove from the cache.
5693 5693
  */
5694
-function clean_post_cache( $post ) {
5694
+function clean_post_cache($post) {
5695 5695
 	global $_wp_suspend_cache_invalidation;
5696 5696
 
5697
-	if ( ! empty( $_wp_suspend_cache_invalidation ) )
5697
+	if ( ! empty($_wp_suspend_cache_invalidation))
5698 5698
 		return;
5699 5699
 
5700
-	$post = get_post( $post );
5701
-	if ( empty( $post ) )
5700
+	$post = get_post($post);
5701
+	if (empty($post))
5702 5702
 		return;
5703 5703
 
5704
-	wp_cache_delete( $post->ID, 'posts' );
5705
-	wp_cache_delete( $post->ID, 'post_meta' );
5704
+	wp_cache_delete($post->ID, 'posts');
5705
+	wp_cache_delete($post->ID, 'post_meta');
5706 5706
 
5707
-	clean_object_term_cache( $post->ID, $post->post_type );
5707
+	clean_object_term_cache($post->ID, $post->post_type);
5708 5708
 
5709
-	wp_cache_delete( 'wp_get_archives', 'general' );
5709
+	wp_cache_delete('wp_get_archives', 'general');
5710 5710
 
5711 5711
 	/**
5712 5712
 	 * Fires immediately after the given post's cache is cleaned.
@@ -5716,10 +5716,10 @@  discard block
 block discarded – undo
5716 5716
 	 * @param int     $post_id Post ID.
5717 5717
 	 * @param WP_Post $post    Post object.
5718 5718
 	 */
5719
-	do_action( 'clean_post_cache', $post->ID, $post );
5719
+	do_action('clean_post_cache', $post->ID, $post);
5720 5720
 
5721
-	if ( 'page' == $post->post_type ) {
5722
-		wp_cache_delete( 'all_page_ids', 'posts' );
5721
+	if ('page' == $post->post_type) {
5722
+		wp_cache_delete('all_page_ids', 'posts');
5723 5723
 
5724 5724
 		/**
5725 5725
 		 * Fires immediately after the given page's cache is cleaned.
@@ -5728,10 +5728,10 @@  discard block
 block discarded – undo
5728 5728
 		 *
5729 5729
 		 * @param int $post_id Post ID.
5730 5730
 		 */
5731
-		do_action( 'clean_page_cache', $post->ID );
5731
+		do_action('clean_page_cache', $post->ID);
5732 5732
 	}
5733 5733
 
5734
-	wp_cache_set( 'last_changed', microtime(), 'posts' );
5734
+	wp_cache_set('last_changed', microtime(), 'posts');
5735 5735
 }
5736 5736
 
5737 5737
 /**
@@ -5744,27 +5744,27 @@  discard block
 block discarded – undo
5744 5744
  * @param bool   $update_term_cache Optional. Whether to update the term cache. Default true.
5745 5745
  * @param bool   $update_meta_cache Optional. Whether to update the meta cache. Default true.
5746 5746
  */
5747
-function update_post_caches( &$posts, $post_type = 'post', $update_term_cache = true, $update_meta_cache = true ) {
5747
+function update_post_caches(&$posts, $post_type = 'post', $update_term_cache = true, $update_meta_cache = true) {
5748 5748
 	// No point in doing all this work if we didn't match any posts.
5749
-	if ( !$posts )
5749
+	if ( ! $posts)
5750 5750
 		return;
5751 5751
 
5752 5752
 	update_post_cache($posts);
5753 5753
 
5754 5754
 	$post_ids = array();
5755
-	foreach ( $posts as $post )
5755
+	foreach ($posts as $post)
5756 5756
 		$post_ids[] = $post->ID;
5757 5757
 
5758
-	if ( ! $post_type )
5758
+	if ( ! $post_type)
5759 5759
 		$post_type = 'any';
5760 5760
 
5761
-	if ( $update_term_cache ) {
5762
-		if ( is_array($post_type) ) {
5761
+	if ($update_term_cache) {
5762
+		if (is_array($post_type)) {
5763 5763
 			$ptypes = $post_type;
5764
-		} elseif ( 'any' == $post_type ) {
5764
+		} elseif ('any' == $post_type) {
5765 5765
 			$ptypes = array();
5766 5766
 			// Just use the post_types in the supplied posts.
5767
-			foreach ( $posts as $post ) {
5767
+			foreach ($posts as $post) {
5768 5768
 				$ptypes[] = $post->post_type;
5769 5769
 			}
5770 5770
 			$ptypes = array_unique($ptypes);
@@ -5772,11 +5772,11 @@  discard block
 block discarded – undo
5772 5772
 			$ptypes = array($post_type);
5773 5773
 		}
5774 5774
 
5775
-		if ( ! empty($ptypes) )
5775
+		if ( ! empty($ptypes))
5776 5776
 			update_object_term_cache($post_ids, $ptypes);
5777 5777
 	}
5778 5778
 
5779
-	if ( $update_meta_cache )
5779
+	if ($update_meta_cache)
5780 5780
 		update_postmeta_cache($post_ids);
5781 5781
 }
5782 5782
 
@@ -5793,7 +5793,7 @@  discard block
 block discarded – undo
5793 5793
  * @return array|false Returns false if there is nothing to update or an array
5794 5794
  *                     of metadata.
5795 5795
  */
5796
-function update_postmeta_cache( $post_ids ) {
5796
+function update_postmeta_cache($post_ids) {
5797 5797
 	return update_meta_cache('post', $post_ids);
5798 5798
 }
5799 5799
 
@@ -5812,10 +5812,10 @@  discard block
 block discarded – undo
5812 5812
  * @param int  $id          The attachment ID in the cache to clean.
5813 5813
  * @param bool $clean_terms Optional. Whether to clean terms cache. Default false.
5814 5814
  */
5815
-function clean_attachment_cache( $id, $clean_terms = false ) {
5815
+function clean_attachment_cache($id, $clean_terms = false) {
5816 5816
 	global $_wp_suspend_cache_invalidation;
5817 5817
 
5818
-	if ( !empty($_wp_suspend_cache_invalidation) )
5818
+	if ( ! empty($_wp_suspend_cache_invalidation))
5819 5819
 		return;
5820 5820
 
5821 5821
 	$id = (int) $id;
@@ -5823,7 +5823,7 @@  discard block
 block discarded – undo
5823 5823
 	wp_cache_delete($id, 'posts');
5824 5824
 	wp_cache_delete($id, 'post_meta');
5825 5825
 
5826
-	if ( $clean_terms )
5826
+	if ($clean_terms)
5827 5827
 		clean_object_term_cache($id, 'attachment');
5828 5828
 
5829 5829
 	/**
@@ -5833,7 +5833,7 @@  discard block
 block discarded – undo
5833 5833
 	 *
5834 5834
 	 * @param int $id Attachment ID.
5835 5835
 	 */
5836
-	do_action( 'clean_attachment_cache', $id );
5836
+	do_action('clean_attachment_cache', $id);
5837 5837
 }
5838 5838
 
5839 5839
 //
@@ -5853,13 +5853,13 @@  discard block
 block discarded – undo
5853 5853
  * @param string  $old_status Previous post status.
5854 5854
  * @param WP_Post $post       Post object.
5855 5855
  */
5856
-function _transition_post_status( $new_status, $old_status, $post ) {
5856
+function _transition_post_status($new_status, $old_status, $post) {
5857 5857
 	global $wpdb;
5858 5858
 
5859
-	if ( $old_status != 'publish' && $new_status == 'publish' ) {
5859
+	if ($old_status != 'publish' && $new_status == 'publish') {
5860 5860
 		// Reset GUID if transitioning to publish and it is empty.
5861
-		if ( '' == get_the_guid($post->ID) )
5862
-			$wpdb->update( $wpdb->posts, array( 'guid' => get_permalink( $post->ID ) ), array( 'ID' => $post->ID ) );
5861
+		if ('' == get_the_guid($post->ID))
5862
+			$wpdb->update($wpdb->posts, array('guid' => get_permalink($post->ID)), array('ID' => $post->ID));
5863 5863
 
5864 5864
 		/**
5865 5865
 		 * Fires when a post's status is transitioned from private to published.
@@ -5873,21 +5873,21 @@  discard block
 block discarded – undo
5873 5873
 	}
5874 5874
 
5875 5875
 	// If published posts changed clear the lastpostmodified cache.
5876
-	if ( 'publish' == $new_status || 'publish' == $old_status) {
5877
-		foreach ( array( 'server', 'gmt', 'blog' ) as $timezone ) {
5878
-			wp_cache_delete( "lastpostmodified:$timezone", 'timeinfo' );
5879
-			wp_cache_delete( "lastpostdate:$timezone", 'timeinfo' );
5880
-			wp_cache_delete( "lastpostdate:$timezone:{$post->post_type}", 'timeinfo' );
5876
+	if ('publish' == $new_status || 'publish' == $old_status) {
5877
+		foreach (array('server', 'gmt', 'blog') as $timezone) {
5878
+			wp_cache_delete("lastpostmodified:$timezone", 'timeinfo');
5879
+			wp_cache_delete("lastpostdate:$timezone", 'timeinfo');
5880
+			wp_cache_delete("lastpostdate:$timezone:{$post->post_type}", 'timeinfo');
5881 5881
 		}
5882 5882
 	}
5883 5883
 
5884
-	if ( $new_status !== $old_status ) {
5885
-		wp_cache_delete( _count_posts_cache_key( $post->post_type ), 'counts' );
5886
-		wp_cache_delete( _count_posts_cache_key( $post->post_type, 'readable' ), 'counts' );
5884
+	if ($new_status !== $old_status) {
5885
+		wp_cache_delete(_count_posts_cache_key($post->post_type), 'counts');
5886
+		wp_cache_delete(_count_posts_cache_key($post->post_type, 'readable'), 'counts');
5887 5887
 	}
5888 5888
 
5889 5889
 	// Always clears the hook in case the post status bounced from future to draft.
5890
-	wp_clear_scheduled_hook('publish_future_post', array( $post->ID ) );
5890
+	wp_clear_scheduled_hook('publish_future_post', array($post->ID));
5891 5891
 }
5892 5892
 
5893 5893
 /**
@@ -5903,9 +5903,9 @@  discard block
 block discarded – undo
5903 5903
  *                            wp_transition_post_status() and the default filter for _future_post_hook().
5904 5904
  * @param WP_Post $post       Post object.
5905 5905
  */
5906
-function _future_post_hook( $deprecated, $post ) {
5907
-	wp_clear_scheduled_hook( 'publish_future_post', array( $post->ID ) );
5908
-	wp_schedule_single_event( strtotime( get_gmt_from_date( $post->post_date ) . ' GMT') , 'publish_future_post', array( $post->ID ) );
5906
+function _future_post_hook($deprecated, $post) {
5907
+	wp_clear_scheduled_hook('publish_future_post', array($post->ID));
5908
+	wp_schedule_single_event(strtotime(get_gmt_from_date($post->post_date).' GMT'), 'publish_future_post', array($post->ID));
5909 5909
 }
5910 5910
 
5911 5911
 /**
@@ -5918,8 +5918,8 @@  discard block
 block discarded – undo
5918 5918
  *
5919 5919
  * @param int $post_id The ID in the database table of the post being published.
5920 5920
  */
5921
-function _publish_post_hook( $post_id ) {
5922
-	if ( defined( 'XMLRPC_REQUEST' ) ) {
5921
+function _publish_post_hook($post_id) {
5922
+	if (defined('XMLRPC_REQUEST')) {
5923 5923
 		/**
5924 5924
 		 * Fires when _publish_post_hook() is called during an XML-RPC request.
5925 5925
 		 *
@@ -5927,18 +5927,18 @@  discard block
 block discarded – undo
5927 5927
 		 *
5928 5928
 		 * @param int $post_id Post ID.
5929 5929
 		 */
5930
-		do_action( 'xmlrpc_publish_post', $post_id );
5930
+		do_action('xmlrpc_publish_post', $post_id);
5931 5931
 	}
5932 5932
 
5933
-	if ( defined('WP_IMPORTING') )
5933
+	if (defined('WP_IMPORTING'))
5934 5934
 		return;
5935 5935
 
5936
-	if ( get_option('default_pingback_flag') )
5937
-		add_post_meta( $post_id, '_pingme', '1' );
5938
-	add_post_meta( $post_id, '_encloseme', '1' );
5936
+	if (get_option('default_pingback_flag'))
5937
+		add_post_meta($post_id, '_pingme', '1');
5938
+	add_post_meta($post_id, '_encloseme', '1');
5939 5939
 
5940
-	if ( ! wp_next_scheduled( 'do_pings' ) ) {
5941
-		wp_schedule_single_event( time(), 'do_pings' );
5940
+	if ( ! wp_next_scheduled('do_pings')) {
5941
+		wp_schedule_single_event(time(), 'do_pings');
5942 5942
 	}
5943 5943
 }
5944 5944
 
@@ -5951,9 +5951,9 @@  discard block
 block discarded – undo
5951 5951
  *
5952 5952
  * @return int|false Post parent ID, otherwise false.
5953 5953
  */
5954
-function wp_get_post_parent_id( $post_ID ) {
5955
-	$post = get_post( $post_ID );
5956
-	if ( !$post || is_wp_error( $post ) )
5954
+function wp_get_post_parent_id($post_ID) {
5955
+	$post = get_post($post_ID);
5956
+	if ( ! $post || is_wp_error($post))
5957 5957
 		return false;
5958 5958
 	return (int) $post->post_parent;
5959 5959
 }
@@ -5972,30 +5972,30 @@  discard block
 block discarded – undo
5972 5972
  * @param int $post_ID     ID of the post we're checking.
5973 5973
  * @return int The new post_parent for the post, 0 otherwise.
5974 5974
  */
5975
-function wp_check_post_hierarchy_for_loops( $post_parent, $post_ID ) {
5975
+function wp_check_post_hierarchy_for_loops($post_parent, $post_ID) {
5976 5976
 	// Nothing fancy here - bail.
5977
-	if ( !$post_parent )
5977
+	if ( ! $post_parent)
5978 5978
 		return 0;
5979 5979
 
5980 5980
 	// New post can't cause a loop.
5981
-	if ( empty( $post_ID ) )
5981
+	if (empty($post_ID))
5982 5982
 		return $post_parent;
5983 5983
 
5984 5984
 	// Can't be its own parent.
5985
-	if ( $post_parent == $post_ID )
5985
+	if ($post_parent == $post_ID)
5986 5986
 		return 0;
5987 5987
 
5988 5988
 	// Now look for larger loops.
5989
-	if ( !$loop = wp_find_hierarchy_loop( 'wp_get_post_parent_id', $post_ID, $post_parent ) )
5989
+	if ( ! $loop = wp_find_hierarchy_loop('wp_get_post_parent_id', $post_ID, $post_parent))
5990 5990
 		return $post_parent; // No loop
5991 5991
 
5992 5992
 	// Setting $post_parent to the given value causes a loop.
5993
-	if ( isset( $loop[$post_ID] ) )
5993
+	if (isset($loop[$post_ID]))
5994 5994
 		return 0;
5995 5995
 
5996 5996
 	// There's a loop, but it doesn't contain $post_ID. Break the loop.
5997
-	foreach ( array_keys( $loop ) as $loop_member )
5998
-		wp_update_post( array( 'ID' => $loop_member, 'post_parent' => 0 ) );
5997
+	foreach (array_keys($loop) as $loop_member)
5998
+		wp_update_post(array('ID' => $loop_member, 'post_parent' => 0));
5999 5999
 
6000 6000
 	return $post_parent;
6001 6001
 }
@@ -6009,14 +6009,14 @@  discard block
 block discarded – undo
6009 6009
  * @param int         $thumbnail_id Thumbnail to attach.
6010 6010
  * @return int|bool True on success, false on failure.
6011 6011
  */
6012
-function set_post_thumbnail( $post, $thumbnail_id ) {
6013
-	$post = get_post( $post );
6014
-	$thumbnail_id = absint( $thumbnail_id );
6015
-	if ( $post && $thumbnail_id && get_post( $thumbnail_id ) ) {
6016
-		if ( wp_get_attachment_image( $thumbnail_id, 'thumbnail' ) )
6017
-			return update_post_meta( $post->ID, '_thumbnail_id', $thumbnail_id );
6012
+function set_post_thumbnail($post, $thumbnail_id) {
6013
+	$post = get_post($post);
6014
+	$thumbnail_id = absint($thumbnail_id);
6015
+	if ($post && $thumbnail_id && get_post($thumbnail_id)) {
6016
+		if (wp_get_attachment_image($thumbnail_id, 'thumbnail'))
6017
+			return update_post_meta($post->ID, '_thumbnail_id', $thumbnail_id);
6018 6018
 		else
6019
-			return delete_post_meta( $post->ID, '_thumbnail_id' );
6019
+			return delete_post_meta($post->ID, '_thumbnail_id');
6020 6020
 	}
6021 6021
 	return false;
6022 6022
 }
@@ -6029,10 +6029,10 @@  discard block
 block discarded – undo
6029 6029
  * @param int|WP_Post $post Post ID or post object where thumbnail should be removed from.
6030 6030
  * @return bool True on success, false on failure.
6031 6031
  */
6032
-function delete_post_thumbnail( $post ) {
6033
-	$post = get_post( $post );
6034
-	if ( $post )
6035
-		return delete_post_meta( $post->ID, '_thumbnail_id' );
6032
+function delete_post_thumbnail($post) {
6033
+	$post = get_post($post);
6034
+	if ($post)
6035
+		return delete_post_meta($post->ID, '_thumbnail_id');
6036 6036
 	return false;
6037 6037
 }
6038 6038
 
@@ -6047,10 +6047,10 @@  discard block
 block discarded – undo
6047 6047
 	global $wpdb;
6048 6048
 
6049 6049
 	// Cleanup old auto-drafts more than 7 days old.
6050
-	$old_posts = $wpdb->get_col( "SELECT ID FROM $wpdb->posts WHERE post_status = 'auto-draft' AND DATE_SUB( NOW(), INTERVAL 7 DAY ) > post_date" );
6051
-	foreach ( (array) $old_posts as $delete ) {
6050
+	$old_posts = $wpdb->get_col("SELECT ID FROM $wpdb->posts WHERE post_status = 'auto-draft' AND DATE_SUB( NOW(), INTERVAL 7 DAY ) > post_date");
6051
+	foreach ((array) $old_posts as $delete) {
6052 6052
 		// Force delete.
6053
-		wp_delete_post( $delete, true );
6053
+		wp_delete_post($delete, true);
6054 6054
 	}
6055 6055
 }
6056 6056
 
@@ -6061,23 +6061,23 @@  discard block
 block discarded – undo
6061 6061
  *
6062 6062
  * @param array $posts Array of WP_Post objects.
6063 6063
  */
6064
-function wp_queue_posts_for_term_meta_lazyload( $posts ) {
6064
+function wp_queue_posts_for_term_meta_lazyload($posts) {
6065 6065
 	$post_type_taxonomies = $term_ids = array();
6066
-	foreach ( $posts as $post ) {
6067
-		if ( ! ( $post instanceof WP_Post ) ) {
6066
+	foreach ($posts as $post) {
6067
+		if ( ! ($post instanceof WP_Post)) {
6068 6068
 			continue;
6069 6069
 		}
6070 6070
 
6071
-		if ( ! isset( $post_type_taxonomies[ $post->post_type ] ) ) {
6072
-			$post_type_taxonomies[ $post->post_type ] = get_object_taxonomies( $post->post_type );
6071
+		if ( ! isset($post_type_taxonomies[$post->post_type])) {
6072
+			$post_type_taxonomies[$post->post_type] = get_object_taxonomies($post->post_type);
6073 6073
 		}
6074 6074
 
6075
-		foreach ( $post_type_taxonomies[ $post->post_type ] as $taxonomy ) {
6075
+		foreach ($post_type_taxonomies[$post->post_type] as $taxonomy) {
6076 6076
 			// Term cache should already be primed by `update_post_term_cache()`.
6077
-			$terms = get_object_term_cache( $post->ID, $taxonomy );
6078
-			if ( false !== $terms ) {
6079
-				foreach ( $terms as $term ) {
6080
-					if ( ! isset( $term_ids[ $term->term_id ] ) ) {
6077
+			$terms = get_object_term_cache($post->ID, $taxonomy);
6078
+			if (false !== $terms) {
6079
+				foreach ($terms as $term) {
6080
+					if ( ! isset($term_ids[$term->term_id])) {
6081 6081
 						$term_ids[] = $term->term_id;
6082 6082
 					}
6083 6083
 				}
@@ -6085,9 +6085,9 @@  discard block
 block discarded – undo
6085 6085
 		}
6086 6086
 	}
6087 6087
 
6088
-	if ( $term_ids ) {
6088
+	if ($term_ids) {
6089 6089
 		$lazyloader = wp_metadata_lazyloader();
6090
-		$lazyloader->queue_objects( 'term', $term_ids );
6090
+		$lazyloader->queue_objects('term', $term_ids);
6091 6091
 	}
6092 6092
 }
6093 6093
 
@@ -6104,11 +6104,11 @@  discard block
 block discarded – undo
6104 6104
  * @param string  $old_status Old post status.
6105 6105
  * @param WP_Post $post       Post object.
6106 6106
  */
6107
-function _update_term_count_on_transition_post_status( $new_status, $old_status, $post ) {
6107
+function _update_term_count_on_transition_post_status($new_status, $old_status, $post) {
6108 6108
 	// Update counts for the post's terms.
6109
-	foreach ( (array) get_object_taxonomies( $post->post_type ) as $taxonomy ) {
6110
-		$tt_ids = wp_get_object_terms( $post->ID, $taxonomy, array( 'fields' => 'tt_ids' ) );
6111
-		wp_update_term_count( $tt_ids, $taxonomy );
6109
+	foreach ((array) get_object_taxonomies($post->post_type) as $taxonomy) {
6110
+		$tt_ids = wp_get_object_terms($post->ID, $taxonomy, array('fields' => 'tt_ids'));
6111
+		wp_update_term_count($tt_ids, $taxonomy);
6112 6112
 	}
6113 6113
 }
6114 6114
 
@@ -6126,14 +6126,14 @@  discard block
 block discarded – undo
6126 6126
  * @param bool  $update_term_cache Optional. Whether to update the term cache. Default true.
6127 6127
  * @param bool  $update_meta_cache Optional. Whether to update the meta cache. Default true.
6128 6128
  */
6129
-function _prime_post_caches( $ids, $update_term_cache = true, $update_meta_cache = true ) {
6129
+function _prime_post_caches($ids, $update_term_cache = true, $update_meta_cache = true) {
6130 6130
 	global $wpdb;
6131 6131
 
6132
-	$non_cached_ids = _get_non_cached_ids( $ids, 'posts' );
6133
-	if ( !empty( $non_cached_ids ) ) {
6134
-		$fresh_posts = $wpdb->get_results( sprintf( "SELECT $wpdb->posts.* FROM $wpdb->posts WHERE ID IN (%s)", join( ",", $non_cached_ids ) ) );
6132
+	$non_cached_ids = _get_non_cached_ids($ids, 'posts');
6133
+	if ( ! empty($non_cached_ids)) {
6134
+		$fresh_posts = $wpdb->get_results(sprintf("SELECT $wpdb->posts.* FROM $wpdb->posts WHERE ID IN (%s)", join(",", $non_cached_ids)));
6135 6135
 
6136
-		update_post_caches( $fresh_posts, 'any', $update_term_cache, $update_meta_cache );
6136
+		update_post_caches($fresh_posts, 'any', $update_term_cache, $update_meta_cache);
6137 6137
 	}
6138 6138
 }
6139 6139
 
@@ -6151,18 +6151,18 @@  discard block
 block discarded – undo
6151 6151
  * @param string $post_name Slug.
6152 6152
  * @param string $post_ID   Optional. Post ID that should be ignored. Default 0.
6153 6153
  */
6154
-function wp_add_trashed_suffix_to_post_name_for_trashed_posts( $post_name, $post_ID = 0 ) {
6155
-	$trashed_posts_with_desired_slug = get_posts( array(
6154
+function wp_add_trashed_suffix_to_post_name_for_trashed_posts($post_name, $post_ID = 0) {
6155
+	$trashed_posts_with_desired_slug = get_posts(array(
6156 6156
 		'name' => $post_name,
6157 6157
 		'post_status' => 'trash',
6158 6158
 		'post_type' => 'any',
6159 6159
 		'nopaging' => true,
6160
-		'post__not_in' => array( $post_ID )
6161
-	) );
6160
+		'post__not_in' => array($post_ID)
6161
+	));
6162 6162
 
6163
-	if ( ! empty( $trashed_posts_with_desired_slug ) ) {
6164
-		foreach ( $trashed_posts_with_desired_slug as $_post ) {
6165
-			wp_add_trashed_suffix_to_post_name_for_post( $_post );
6163
+	if ( ! empty($trashed_posts_with_desired_slug)) {
6164
+		foreach ($trashed_posts_with_desired_slug as $_post) {
6165
+			wp_add_trashed_suffix_to_post_name_for_post($_post);
6166 6166
 		}
6167 6167
 	}
6168 6168
 }
@@ -6181,18 +6181,18 @@  discard block
 block discarded – undo
6181 6181
  * @param WP_Post $post The post.
6182 6182
  * @return string New slug for the post.
6183 6183
  */
6184
-function wp_add_trashed_suffix_to_post_name_for_post( $post ) {
6184
+function wp_add_trashed_suffix_to_post_name_for_post($post) {
6185 6185
 	global $wpdb;
6186 6186
 
6187
-	$post = get_post( $post );
6187
+	$post = get_post($post);
6188 6188
 
6189
-	if ( '__trashed' === substr( $post->post_name, -9 ) ) {
6189
+	if ('__trashed' === substr($post->post_name, -9)) {
6190 6190
 		return $post->post_name;
6191 6191
 	}
6192
-	add_post_meta( $post->ID, '_wp_desired_post_slug', $post->post_name );
6193
-	$post_name = _truncate_post_slug( $post->post_name, 191 ) . '__trashed';
6194
-	$wpdb->update( $wpdb->posts, array( 'post_name' => $post_name ), array( 'ID' => $post->ID ) );
6195
-	clean_post_cache( $post->ID );
6192
+	add_post_meta($post->ID, '_wp_desired_post_slug', $post->post_name);
6193
+	$post_name = _truncate_post_slug($post->post_name, 191).'__trashed';
6194
+	$wpdb->update($wpdb->posts, array('post_name' => $post_name), array('ID' => $post->ID));
6195
+	clean_post_cache($post->ID);
6196 6196
 	return $post_name;
6197 6197
 }
6198 6198
 
@@ -6208,9 +6208,9 @@  discard block
 block discarded – undo
6208 6208
  *                       DISTINCT, fields (SELECT), and LIMITS clauses.
6209 6209
  * @return array The modified clauses.
6210 6210
  */
6211
-function _filter_query_attachment_filenames( $clauses ) {
6211
+function _filter_query_attachment_filenames($clauses) {
6212 6212
 	global $wpdb;
6213
-	remove_filter( 'posts_clauses', __FUNCTION__ );
6213
+	remove_filter('posts_clauses', __FUNCTION__);
6214 6214
 
6215 6215
 	// Add a LEFT JOIN of the postmeta table so we don't trample existing JOINs.
6216 6216
 	$clauses['join'] .= " LEFT JOIN {$wpdb->postmeta} AS sq1 ON ( {$wpdb->posts}.ID = sq1.post_id AND sq1.meta_key = '_wp_attached_file' )";
Please login to merge, or discard this patch.
Braces   +518 added lines, -355 removed lines patch added patch discarded remove patch
@@ -306,8 +306,9 @@  discard block
 block discarded – undo
306 306
  * @return bool True on success, false on failure.
307 307
  */
308 308
 function update_attached_file( $attachment_id, $file ) {
309
-	if ( !get_post( $attachment_id ) )
310
-		return false;
309
+	if ( !get_post( $attachment_id ) ) {
310
+			return false;
311
+	}
311 312
 
312 313
 	/**
313 314
 	 * Filters the path to the attached file to update.
@@ -319,11 +320,12 @@  discard block
 block discarded – undo
319 320
 	 */
320 321
 	$file = apply_filters( 'update_attached_file', $file, $attachment_id );
321 322
 
322
-	if ( $file = _wp_relative_upload_path( $file ) )
323
-		return update_post_meta( $attachment_id, '_wp_attached_file', $file );
324
-	else
325
-		return delete_post_meta( $attachment_id, '_wp_attached_file' );
326
-}
323
+	if ( $file = _wp_relative_upload_path( $file ) ) {
324
+			return update_post_meta( $attachment_id, '_wp_attached_file', $file );
325
+	} else {
326
+			return delete_post_meta( $attachment_id, '_wp_attached_file' );
327
+	}
328
+	}
327 329
 
328 330
 /**
329 331
  * Return relative path to an uploaded file.
@@ -429,16 +431,19 @@  discard block
 block discarded – undo
429 431
 
430 432
 	$children = get_posts( $r );
431 433
 
432
-	if ( ! $children )
433
-		return $kids;
434
+	if ( ! $children ) {
435
+			return $kids;
436
+	}
434 437
 
435
-	if ( ! empty( $r['fields'] ) )
436
-		return $children;
438
+	if ( ! empty( $r['fields'] ) ) {
439
+			return $children;
440
+	}
437 441
 
438 442
 	update_post_cache($children);
439 443
 
440
-	foreach ( $children as $key => $child )
441
-		$kids[$child->ID] = $children[$key];
444
+	foreach ( $children as $key => $child ) {
445
+			$kids[$child->ID] = $children[$key];
446
+	}
442 447
 
443 448
 	if ( $output == OBJECT ) {
444 449
 		return $kids;
@@ -513,8 +518,9 @@  discard block
 block discarded – undo
513 518
  *                            When $output is OBJECT, a `WP_Post` instance is returned.
514 519
  */
515 520
 function get_post( $post = null, $output = OBJECT, $filter = 'raw' ) {
516
-	if ( empty( $post ) && isset( $GLOBALS['post'] ) )
517
-		$post = $GLOBALS['post'];
521
+	if ( empty( $post ) && isset( $GLOBALS['post'] ) ) {
522
+			$post = $GLOBALS['post'];
523
+	}
518 524
 
519 525
 	if ( $post instanceof WP_Post ) {
520 526
 		$_post = $post;
@@ -531,15 +537,17 @@  discard block
 block discarded – undo
531 537
 		$_post = WP_Post::get_instance( $post );
532 538
 	}
533 539
 
534
-	if ( ! $_post )
535
-		return null;
540
+	if ( ! $_post ) {
541
+			return null;
542
+	}
536 543
 
537 544
 	$_post = $_post->filter( $filter );
538 545
 
539
-	if ( $output == ARRAY_A )
540
-		return $_post->to_array();
541
-	elseif ( $output == ARRAY_N )
542
-		return array_values( $_post->to_array() );
546
+	if ( $output == ARRAY_A ) {
547
+			return $_post->to_array();
548
+	} elseif ( $output == ARRAY_N ) {
549
+			return array_values( $_post->to_array() );
550
+	}
543 551
 
544 552
 	return $_post;
545 553
 }
@@ -555,8 +563,9 @@  discard block
 block discarded – undo
555 563
 function get_post_ancestors( $post ) {
556 564
 	$post = get_post( $post );
557 565
 
558
-	if ( ! $post || empty( $post->post_parent ) || $post->post_parent == $post->ID )
559
-		return array();
566
+	if ( ! $post || empty( $post->post_parent ) || $post->post_parent == $post->ID ) {
567
+			return array();
568
+	}
560 569
 
561 570
 	$ancestors = array();
562 571
 
@@ -564,8 +573,9 @@  discard block
 block discarded – undo
564 573
 
565 574
 	while ( $ancestor = get_post( $id ) ) {
566 575
 		// Loop detection: If the ancestor has been seen before, break.
567
-		if ( empty( $ancestor->post_parent ) || ( $ancestor->post_parent == $post->ID ) || in_array( $ancestor->post_parent, $ancestors ) )
568
-			break;
576
+		if ( empty( $ancestor->post_parent ) || ( $ancestor->post_parent == $post->ID ) || in_array( $ancestor->post_parent, $ancestors ) ) {
577
+					break;
578
+		}
569 579
 
570 580
 		$id = $ancestors[] = $ancestor->post_parent;
571 581
 	}
@@ -596,11 +606,13 @@  discard block
 block discarded – undo
596 606
 function get_post_field( $field, $post = null, $context = 'display' ) {
597 607
 	$post = get_post( $post );
598 608
 
599
-	if ( !$post )
600
-		return '';
609
+	if ( !$post ) {
610
+			return '';
611
+	}
601 612
 
602
-	if ( !isset($post->$field) )
603
-		return '';
613
+	if ( !isset($post->$field) ) {
614
+			return '';
615
+	}
604 616
 
605 617
 	return sanitize_post_field($field, $post->$field, $post->ID, $context);
606 618
 }
@@ -619,8 +631,9 @@  discard block
 block discarded – undo
619 631
 function get_post_mime_type( $ID = '' ) {
620 632
 	$post = get_post($ID);
621 633
 
622
-	if ( is_object($post) )
623
-		return $post->post_mime_type;
634
+	if ( is_object($post) ) {
635
+			return $post->post_mime_type;
636
+	}
624 637
 
625 638
 	return false;
626 639
 }
@@ -639,16 +652,19 @@  discard block
 block discarded – undo
639 652
 function get_post_status( $ID = '' ) {
640 653
 	$post = get_post($ID);
641 654
 
642
-	if ( !is_object($post) )
643
-		return false;
655
+	if ( !is_object($post) ) {
656
+			return false;
657
+	}
644 658
 
645 659
 	if ( 'attachment' == $post->post_type ) {
646
-		if ( 'private' == $post->post_status )
647
-			return 'private';
660
+		if ( 'private' == $post->post_status ) {
661
+					return 'private';
662
+		}
648 663
 
649 664
 		// Unattached attachments are assumed to be published.
650
-		if ( ( 'inherit' == $post->post_status ) && ( 0 == $post->post_parent) )
651
-			return 'publish';
665
+		if ( ( 'inherit' == $post->post_status ) && ( 0 == $post->post_parent) ) {
666
+					return 'publish';
667
+		}
652 668
 
653 669
 		// Inherit status from the parent.
654 670
 		if ( $post->post_parent && ( $post->ID != $post->post_parent ) ) {
@@ -760,8 +776,9 @@  discard block
 block discarded – undo
760 776
 function register_post_status( $post_status, $args = array() ) {
761 777
 	global $wp_post_statuses;
762 778
 
763
-	if (!is_array($wp_post_statuses))
764
-		$wp_post_statuses = array();
779
+	if (!is_array($wp_post_statuses)) {
780
+			$wp_post_statuses = array();
781
+	}
765 782
 
766 783
 	// Args prefixed with an underscore are reserved for internal use.
767 784
 	$defaults = array(
@@ -784,38 +801,49 @@  discard block
 block discarded – undo
784 801
 	$args->name = $post_status;
785 802
 
786 803
 	// Set various defaults.
787
-	if ( null === $args->public && null === $args->internal && null === $args->protected && null === $args->private )
788
-		$args->internal = true;
804
+	if ( null === $args->public && null === $args->internal && null === $args->protected && null === $args->private ) {
805
+			$args->internal = true;
806
+	}
789 807
 
790
-	if ( null === $args->public  )
791
-		$args->public = false;
808
+	if ( null === $args->public  ) {
809
+			$args->public = false;
810
+	}
792 811
 
793
-	if ( null === $args->private  )
794
-		$args->private = false;
812
+	if ( null === $args->private  ) {
813
+			$args->private = false;
814
+	}
795 815
 
796
-	if ( null === $args->protected  )
797
-		$args->protected = false;
816
+	if ( null === $args->protected  ) {
817
+			$args->protected = false;
818
+	}
798 819
 
799
-	if ( null === $args->internal  )
800
-		$args->internal = false;
820
+	if ( null === $args->internal  ) {
821
+			$args->internal = false;
822
+	}
801 823
 
802
-	if ( null === $args->publicly_queryable )
803
-		$args->publicly_queryable = $args->public;
824
+	if ( null === $args->publicly_queryable ) {
825
+			$args->publicly_queryable = $args->public;
826
+	}
804 827
 
805
-	if ( null === $args->exclude_from_search )
806
-		$args->exclude_from_search = $args->internal;
828
+	if ( null === $args->exclude_from_search ) {
829
+			$args->exclude_from_search = $args->internal;
830
+	}
807 831
 
808
-	if ( null === $args->show_in_admin_all_list )
809
-		$args->show_in_admin_all_list = !$args->internal;
832
+	if ( null === $args->show_in_admin_all_list ) {
833
+			$args->show_in_admin_all_list = !$args->internal;
834
+	}
810 835
 
811
-	if ( null === $args->show_in_admin_status_list )
812
-		$args->show_in_admin_status_list = !$args->internal;
836
+	if ( null === $args->show_in_admin_status_list ) {
837
+			$args->show_in_admin_status_list = !$args->internal;
838
+	}
813 839
 
814
-	if ( false === $args->label )
815
-		$args->label = $post_status;
840
+	if ( false === $args->label ) {
841
+			$args->label = $post_status;
842
+	}
816 843
 
817
-	if ( false === $args->label_count )
818
-		$args->label_count = _n_noop( $args->label, $args->label );
844
+	if ( false === $args->label_count ) {
845
+			$args->label_count = _n_noop( $args->label, $args->label );
846
+	}
819 847
 
820 848
 	$wp_post_statuses[$post_status] = $args;
821 849
 
@@ -837,8 +865,9 @@  discard block
 block discarded – undo
837 865
 function get_post_status_object( $post_status ) {
838 866
 	global $wp_post_statuses;
839 867
 
840
-	if ( empty($wp_post_statuses[$post_status]) )
841
-		return null;
868
+	if ( empty($wp_post_statuses[$post_status]) ) {
869
+			return null;
870
+	}
842 871
 
843 872
 	return $wp_post_statuses[$post_status];
844 873
 }
@@ -881,8 +910,9 @@  discard block
 block discarded – undo
881 910
  * @return bool Whether post type is hierarchical.
882 911
  */
883 912
 function is_post_type_hierarchical( $post_type ) {
884
-	if ( ! post_type_exists( $post_type ) )
885
-		return false;
913
+	if ( ! post_type_exists( $post_type ) ) {
914
+			return false;
915
+	}
886 916
 
887 917
 	$post_type = get_post_type_object( $post_type );
888 918
 	return $post_type->hierarchical;
@@ -911,8 +941,9 @@  discard block
 block discarded – undo
911 941
  * @return string|false          Post type on success, false on failure.
912 942
  */
913 943
 function get_post_type( $post = null ) {
914
-	if ( $post = get_post( $post ) )
915
-		return $post->post_type;
944
+	if ( $post = get_post( $post ) ) {
945
+			return $post->post_type;
946
+	}
916 947
 
917 948
 	return false;
918 949
 }
@@ -1243,8 +1274,9 @@  discard block
 block discarded – undo
1243 1274
  * @return object object with all the capabilities as member variables.
1244 1275
  */
1245 1276
 function get_post_type_capabilities( $args ) {
1246
-	if ( ! is_array( $args->capability_type ) )
1247
-		$args->capability_type = array( $args->capability_type, $args->capability_type . 's' );
1277
+	if ( ! is_array( $args->capability_type ) ) {
1278
+			$args->capability_type = array( $args->capability_type, $args->capability_type . 's' );
1279
+	}
1248 1280
 
1249 1281
 	// Singular base for meta capabilities, plural base for primitive capabilities.
1250 1282
 	list( $singular_base, $plural_base ) = $args->capability_type;
@@ -1278,12 +1310,14 @@  discard block
 block discarded – undo
1278 1310
 	$capabilities = array_merge( $default_capabilities, $args->capabilities );
1279 1311
 
1280 1312
 	// Post creation capability simply maps to edit_posts by default:
1281
-	if ( ! isset( $capabilities['create_posts'] ) )
1282
-		$capabilities['create_posts'] = $capabilities['edit_posts'];
1313
+	if ( ! isset( $capabilities['create_posts'] ) ) {
1314
+			$capabilities['create_posts'] = $capabilities['edit_posts'];
1315
+	}
1283 1316
 
1284 1317
 	// Remember meta capabilities for future reference.
1285
-	if ( $args->map_meta_cap )
1286
-		_post_type_meta_capabilities( $capabilities );
1318
+	if ( $args->map_meta_cap ) {
1319
+			_post_type_meta_capabilities( $capabilities );
1320
+	}
1287 1321
 
1288 1322
 	return (object) $capabilities;
1289 1323
 }
@@ -1434,20 +1468,25 @@  discard block
 block discarded – undo
1434 1468
 function _get_custom_object_labels( $object, $nohier_vs_hier_defaults ) {
1435 1469
 	$object->labels = (array) $object->labels;
1436 1470
 
1437
-	if ( isset( $object->label ) && empty( $object->labels['name'] ) )
1438
-		$object->labels['name'] = $object->label;
1471
+	if ( isset( $object->label ) && empty( $object->labels['name'] ) ) {
1472
+			$object->labels['name'] = $object->label;
1473
+	}
1439 1474
 
1440
-	if ( !isset( $object->labels['singular_name'] ) && isset( $object->labels['name'] ) )
1441
-		$object->labels['singular_name'] = $object->labels['name'];
1475
+	if ( !isset( $object->labels['singular_name'] ) && isset( $object->labels['name'] ) ) {
1476
+			$object->labels['singular_name'] = $object->labels['name'];
1477
+	}
1442 1478
 
1443
-	if ( ! isset( $object->labels['name_admin_bar'] ) )
1444
-		$object->labels['name_admin_bar'] = isset( $object->labels['singular_name'] ) ? $object->labels['singular_name'] : $object->name;
1479
+	if ( ! isset( $object->labels['name_admin_bar'] ) ) {
1480
+			$object->labels['name_admin_bar'] = isset( $object->labels['singular_name'] ) ? $object->labels['singular_name'] : $object->name;
1481
+	}
1445 1482
 
1446
-	if ( !isset( $object->labels['menu_name'] ) && isset( $object->labels['name'] ) )
1447
-		$object->labels['menu_name'] = $object->labels['name'];
1483
+	if ( !isset( $object->labels['menu_name'] ) && isset( $object->labels['name'] ) ) {
1484
+			$object->labels['menu_name'] = $object->labels['name'];
1485
+	}
1448 1486
 
1449
-	if ( !isset( $object->labels['all_items'] ) && isset( $object->labels['menu_name'] ) )
1450
-		$object->labels['all_items'] = $object->labels['menu_name'];
1487
+	if ( !isset( $object->labels['all_items'] ) && isset( $object->labels['menu_name'] ) ) {
1488
+			$object->labels['all_items'] = $object->labels['menu_name'];
1489
+	}
1451 1490
 
1452 1491
 	if ( !isset( $object->labels['archives'] ) && isset( $object->labels['all_items'] ) ) {
1453 1492
 		$object->labels['archives'] = $object->labels['all_items'];
@@ -1473,8 +1512,9 @@  discard block
 block discarded – undo
1473 1512
 	foreach ( get_post_types( array( 'show_ui' => true ) ) as $ptype ) {
1474 1513
 		$ptype_obj = get_post_type_object( $ptype );
1475 1514
 		// Sub-menus only.
1476
-		if ( ! $ptype_obj->show_in_menu || $ptype_obj->show_in_menu === true )
1477
-			continue;
1515
+		if ( ! $ptype_obj->show_in_menu || $ptype_obj->show_in_menu === true ) {
1516
+					continue;
1517
+		}
1478 1518
 		add_submenu_page( $ptype_obj->show_in_menu, $ptype_obj->labels->name, $ptype_obj->labels->all_items, $ptype_obj->cap->edit_posts, "edit.php?post_type=$ptype" );
1479 1519
 	}
1480 1520
 }
@@ -1504,10 +1544,11 @@  discard block
 block discarded – undo
1504 1544
 
1505 1545
 	$features = (array) $feature;
1506 1546
 	foreach ($features as $feature) {
1507
-		if ( func_num_args() == 2 )
1508
-			$_wp_post_type_features[$post_type][$feature] = true;
1509
-		else
1510
-			$_wp_post_type_features[$post_type][$feature] = array_slice( func_get_args(), 2 );
1547
+		if ( func_num_args() == 2 ) {
1548
+					$_wp_post_type_features[$post_type][$feature] = true;
1549
+		} else {
1550
+					$_wp_post_type_features[$post_type][$feature] = array_slice( func_get_args(), 2 );
1551
+		}
1511 1552
 	}
1512 1553
 }
1513 1554
 
@@ -1540,8 +1581,9 @@  discard block
 block discarded – undo
1540 1581
 function get_all_post_type_supports( $post_type ) {
1541 1582
 	global $_wp_post_type_features;
1542 1583
 
1543
-	if ( isset( $_wp_post_type_features[$post_type] ) )
1544
-		return $_wp_post_type_features[$post_type];
1584
+	if ( isset( $_wp_post_type_features[$post_type] ) ) {
1585
+			return $_wp_post_type_features[$post_type];
1586
+	}
1545 1587
 
1546 1588
 	return array();
1547 1589
 }
@@ -1669,18 +1711,22 @@  discard block
 block discarded – undo
1669 1711
 	);
1670 1712
 
1671 1713
 	$r = wp_parse_args( $args, $defaults );
1672
-	if ( empty( $r['post_status'] ) )
1673
-		$r['post_status'] = ( 'attachment' == $r['post_type'] ) ? 'inherit' : 'publish';
1674
-	if ( ! empty($r['numberposts']) && empty($r['posts_per_page']) )
1675
-		$r['posts_per_page'] = $r['numberposts'];
1676
-	if ( ! empty($r['category']) )
1677
-		$r['cat'] = $r['category'];
1714
+	if ( empty( $r['post_status'] ) ) {
1715
+			$r['post_status'] = ( 'attachment' == $r['post_type'] ) ? 'inherit' : 'publish';
1716
+	}
1717
+	if ( ! empty($r['numberposts']) && empty($r['posts_per_page']) ) {
1718
+			$r['posts_per_page'] = $r['numberposts'];
1719
+	}
1720
+	if ( ! empty($r['category']) ) {
1721
+			$r['cat'] = $r['category'];
1722
+	}
1678 1723
 	if ( ! empty($r['include']) ) {
1679 1724
 		$incposts = wp_parse_id_list( $r['include'] );
1680 1725
 		$r['posts_per_page'] = count($incposts);  // only the number of posts included
1681 1726
 		$r['post__in'] = $incposts;
1682
-	} elseif ( ! empty($r['exclude']) )
1683
-		$r['post__not_in'] = wp_parse_id_list( $r['exclude'] );
1727
+	} elseif ( ! empty($r['exclude']) ) {
1728
+			$r['post__not_in'] = wp_parse_id_list( $r['exclude'] );
1729
+	}
1684 1730
 
1685 1731
 	$r['ignore_sticky_posts'] = true;
1686 1732
 	$r['no_found_rows'] = true;
@@ -1710,8 +1756,9 @@  discard block
 block discarded – undo
1710 1756
  */
1711 1757
 function add_post_meta( $post_id, $meta_key, $meta_value, $unique = false ) {
1712 1758
 	// Make sure meta is added to the post, not a revision.
1713
-	if ( $the_post = wp_is_post_revision($post_id) )
1714
-		$post_id = $the_post;
1759
+	if ( $the_post = wp_is_post_revision($post_id) ) {
1760
+			$post_id = $the_post;
1761
+	}
1715 1762
 
1716 1763
 	return add_metadata('post', $post_id, $meta_key, $meta_value, $unique);
1717 1764
 }
@@ -1733,8 +1780,9 @@  discard block
 block discarded – undo
1733 1780
  */
1734 1781
 function delete_post_meta( $post_id, $meta_key, $meta_value = '' ) {
1735 1782
 	// Make sure meta is added to the post, not a revision.
1736
-	if ( $the_post = wp_is_post_revision($post_id) )
1737
-		$post_id = $the_post;
1783
+	if ( $the_post = wp_is_post_revision($post_id) ) {
1784
+			$post_id = $the_post;
1785
+	}
1738 1786
 
1739 1787
 	return delete_metadata('post', $post_id, $meta_key, $meta_value);
1740 1788
 }
@@ -1775,8 +1823,9 @@  discard block
 block discarded – undo
1775 1823
  */
1776 1824
 function update_post_meta( $post_id, $meta_key, $meta_value, $prev_value = '' ) {
1777 1825
 	// Make sure meta is added to the post, not a revision.
1778
-	if ( $the_post = wp_is_post_revision($post_id) )
1779
-		$post_id = $the_post;
1826
+	if ( $the_post = wp_is_post_revision($post_id) ) {
1827
+			$post_id = $the_post;
1828
+	}
1780 1829
 
1781 1830
 	return update_metadata('post', $post_id, $meta_key, $meta_value, $prev_value);
1782 1831
 }
@@ -1806,8 +1855,9 @@  discard block
 block discarded – undo
1806 1855
  */
1807 1856
 function get_post_custom( $post_id = 0 ) {
1808 1857
 	$post_id = absint( $post_id );
1809
-	if ( ! $post_id )
1810
-		$post_id = get_the_ID();
1858
+	if ( ! $post_id ) {
1859
+			$post_id = get_the_ID();
1860
+	}
1811 1861
 
1812 1862
 	return get_post_meta( $post_id );
1813 1863
 }
@@ -1825,12 +1875,14 @@  discard block
 block discarded – undo
1825 1875
 function get_post_custom_keys( $post_id = 0 ) {
1826 1876
 	$custom = get_post_custom( $post_id );
1827 1877
 
1828
-	if ( !is_array($custom) )
1829
-		return;
1878
+	if ( !is_array($custom) ) {
1879
+			return;
1880
+	}
1830 1881
 
1831
-	if ( $keys = array_keys($custom) )
1832
-		return $keys;
1833
-}
1882
+	if ( $keys = array_keys($custom) ) {
1883
+			return $keys;
1884
+	}
1885
+	}
1834 1886
 
1835 1887
 /**
1836 1888
  * Retrieve values for a custom post field.
@@ -1845,8 +1897,9 @@  discard block
 block discarded – undo
1845 1897
  * @return array|null Meta field values.
1846 1898
  */
1847 1899
 function get_post_custom_values( $key = '', $post_id = 0 ) {
1848
-	if ( !$key )
1849
-		return null;
1900
+	if ( !$key ) {
1901
+			return null;
1902
+	}
1850 1903
 
1851 1904
 	$custom = get_post_custom($post_id);
1852 1905
 
@@ -1867,16 +1920,19 @@  discard block
 block discarded – undo
1867 1920
 function is_sticky( $post_id = 0 ) {
1868 1921
 	$post_id = absint( $post_id );
1869 1922
 
1870
-	if ( ! $post_id )
1871
-		$post_id = get_the_ID();
1923
+	if ( ! $post_id ) {
1924
+			$post_id = get_the_ID();
1925
+	}
1872 1926
 
1873 1927
 	$stickies = get_option( 'sticky_posts' );
1874 1928
 
1875
-	if ( ! is_array( $stickies ) )
1876
-		return false;
1929
+	if ( ! is_array( $stickies ) ) {
1930
+			return false;
1931
+	}
1877 1932
 
1878
-	if ( in_array( $post_id, $stickies ) )
1879
-		return true;
1933
+	if ( in_array( $post_id, $stickies ) ) {
1934
+			return true;
1935
+	}
1880 1936
 
1881 1937
 	return false;
1882 1938
 }
@@ -1901,21 +1957,27 @@  discard block
 block discarded – undo
1901 1957
 function sanitize_post( $post, $context = 'display' ) {
1902 1958
 	if ( is_object($post) ) {
1903 1959
 		// Check if post already filtered for this context.
1904
-		if ( isset($post->filter) && $context == $post->filter )
1905
-			return $post;
1906
-		if ( !isset($post->ID) )
1907
-			$post->ID = 0;
1908
-		foreach ( array_keys(get_object_vars($post)) as $field )
1909
-			$post->$field = sanitize_post_field($field, $post->$field, $post->ID, $context);
1960
+		if ( isset($post->filter) && $context == $post->filter ) {
1961
+					return $post;
1962
+		}
1963
+		if ( !isset($post->ID) ) {
1964
+					$post->ID = 0;
1965
+		}
1966
+		foreach ( array_keys(get_object_vars($post)) as $field ) {
1967
+					$post->$field = sanitize_post_field($field, $post->$field, $post->ID, $context);
1968
+		}
1910 1969
 		$post->filter = $context;
1911 1970
 	} elseif ( is_array( $post ) ) {
1912 1971
 		// Check if post already filtered for this context.
1913
-		if ( isset($post['filter']) && $context == $post['filter'] )
1914
-			return $post;
1915
-		if ( !isset($post['ID']) )
1916
-			$post['ID'] = 0;
1917
-		foreach ( array_keys($post) as $field )
1918
-			$post[$field] = sanitize_post_field($field, $post[$field], $post['ID'], $context);
1972
+		if ( isset($post['filter']) && $context == $post['filter'] ) {
1973
+					return $post;
1974
+		}
1975
+		if ( !isset($post['ID']) ) {
1976
+					$post['ID'] = 0;
1977
+		}
1978
+		foreach ( array_keys($post) as $field ) {
1979
+					$post[$field] = sanitize_post_field($field, $post[$field], $post['ID'], $context);
1980
+		}
1919 1981
 		$post['filter'] = $context;
1920 1982
 	}
1921 1983
 	return $post;
@@ -1940,8 +2002,9 @@  discard block
 block discarded – undo
1940 2002
  */
1941 2003
 function sanitize_post_field( $field, $value, $post_id, $context = 'display' ) {
1942 2004
 	$int_fields = array('ID', 'post_parent', 'menu_order');
1943
-	if ( in_array($field, $int_fields) )
1944
-		$value = (int) $value;
2005
+	if ( in_array($field, $int_fields) ) {
2006
+			$value = (int) $value;
2007
+	}
1945 2008
 
1946 2009
 	// Fields which contain arrays of integers.
1947 2010
 	$array_int_fields = array( 'ancestors' );
@@ -1950,8 +2013,9 @@  discard block
 block discarded – undo
1950 2013
 		return $value;
1951 2014
 	}
1952 2015
 
1953
-	if ( 'raw' == $context )
1954
-		return $value;
2016
+	if ( 'raw' == $context ) {
2017
+			return $value;
2018
+	}
1955 2019
 
1956 2020
 	$prefixed = false;
1957 2021
 	if ( false !== strpos($field, 'post_') ) {
@@ -1994,10 +2058,11 @@  discard block
 block discarded – undo
1994 2058
 		}
1995 2059
 
1996 2060
 		if ( in_array($field, $format_to_edit) ) {
1997
-			if ( 'post_content' == $field )
1998
-				$value = format_to_edit($value, user_can_richedit());
1999
-			else
2000
-				$value = format_to_edit($value);
2061
+			if ( 'post_content' == $field ) {
2062
+							$value = format_to_edit($value, user_can_richedit());
2063
+			} else {
2064
+							$value = format_to_edit($value);
2065
+			}
2001 2066
 		} else {
2002 2067
 			$value = esc_attr($value);
2003 2068
 		}
@@ -2088,11 +2153,13 @@  discard block
 block discarded – undo
2088 2153
 function stick_post( $post_id ) {
2089 2154
 	$stickies = get_option('sticky_posts');
2090 2155
 
2091
-	if ( !is_array($stickies) )
2092
-		$stickies = array($post_id);
2156
+	if ( !is_array($stickies) ) {
2157
+			$stickies = array($post_id);
2158
+	}
2093 2159
 
2094
-	if ( ! in_array($post_id, $stickies) )
2095
-		$stickies[] = $post_id;
2160
+	if ( ! in_array($post_id, $stickies) ) {
2161
+			$stickies[] = $post_id;
2162
+	}
2096 2163
 
2097 2164
 	$updated = update_option( 'sticky_posts', $stickies );
2098 2165
 
@@ -2120,15 +2187,18 @@  discard block
 block discarded – undo
2120 2187
 function unstick_post( $post_id ) {
2121 2188
 	$stickies = get_option('sticky_posts');
2122 2189
 
2123
-	if ( !is_array($stickies) )
2124
-		return;
2190
+	if ( !is_array($stickies) ) {
2191
+			return;
2192
+	}
2125 2193
 
2126
-	if ( ! in_array($post_id, $stickies) )
2127
-		return;
2194
+	if ( ! in_array($post_id, $stickies) ) {
2195
+			return;
2196
+	}
2128 2197
 
2129 2198
 	$offset = array_search($post_id, $stickies);
2130
-	if ( false === $offset )
2131
-		return;
2199
+	if ( false === $offset ) {
2200
+			return;
2201
+	}
2132 2202
 
2133 2203
 	array_splice($stickies, $offset, 1);
2134 2204
 
@@ -2188,8 +2258,9 @@  discard block
 block discarded – undo
2188 2258
 function wp_count_posts( $type = 'post', $perm = '' ) {
2189 2259
 	global $wpdb;
2190 2260
 
2191
-	if ( ! post_type_exists( $type ) )
2192
-		return new stdClass;
2261
+	if ( ! post_type_exists( $type ) ) {
2262
+			return new stdClass;
2263
+	}
2193 2264
 
2194 2265
 	$cache_key = _count_posts_cache_key( $type, $perm );
2195 2266
 
@@ -2364,8 +2435,9 @@  discard block
 block discarded – undo
2364 2435
 function wp_post_mime_type_where( $post_mime_types, $table_alias = '' ) {
2365 2436
 	$where = '';
2366 2437
 	$wildcards = array('', '%', '%/%');
2367
-	if ( is_string($post_mime_types) )
2368
-		$post_mime_types = array_map('trim', explode(',', $post_mime_types));
2438
+	if ( is_string($post_mime_types) ) {
2439
+			$post_mime_types = array_map('trim', explode(',', $post_mime_types));
2440
+	}
2369 2441
 
2370 2442
 	$wheres = array();
2371 2443
 
@@ -2375,29 +2447,34 @@  discard block
 block discarded – undo
2375 2447
 		if ( false !== $slashpos ) {
2376 2448
 			$mime_group = preg_replace('/[^-*.a-zA-Z0-9]/', '', substr($mime_type, 0, $slashpos));
2377 2449
 			$mime_subgroup = preg_replace('/[^-*.+a-zA-Z0-9]/', '', substr($mime_type, $slashpos + 1));
2378
-			if ( empty($mime_subgroup) )
2379
-				$mime_subgroup = '*';
2380
-			else
2381
-				$mime_subgroup = str_replace('/', '', $mime_subgroup);
2450
+			if ( empty($mime_subgroup) ) {
2451
+							$mime_subgroup = '*';
2452
+			} else {
2453
+							$mime_subgroup = str_replace('/', '', $mime_subgroup);
2454
+			}
2382 2455
 			$mime_pattern = "$mime_group/$mime_subgroup";
2383 2456
 		} else {
2384 2457
 			$mime_pattern = preg_replace('/[^-*.a-zA-Z0-9]/', '', $mime_type);
2385
-			if ( false === strpos($mime_pattern, '*') )
2386
-				$mime_pattern .= '/*';
2458
+			if ( false === strpos($mime_pattern, '*') ) {
2459
+							$mime_pattern .= '/*';
2460
+			}
2387 2461
 		}
2388 2462
 
2389 2463
 		$mime_pattern = preg_replace('/\*+/', '%', $mime_pattern);
2390 2464
 
2391
-		if ( in_array( $mime_type, $wildcards ) )
2392
-			return '';
2465
+		if ( in_array( $mime_type, $wildcards ) ) {
2466
+					return '';
2467
+		}
2393 2468
 
2394
-		if ( false !== strpos($mime_pattern, '%') )
2395
-			$wheres[] = empty($table_alias) ? "post_mime_type LIKE '$mime_pattern'" : "$table_alias.post_mime_type LIKE '$mime_pattern'";
2396
-		else
2397
-			$wheres[] = empty($table_alias) ? "post_mime_type = '$mime_pattern'" : "$table_alias.post_mime_type = '$mime_pattern'";
2469
+		if ( false !== strpos($mime_pattern, '%') ) {
2470
+					$wheres[] = empty($table_alias) ? "post_mime_type LIKE '$mime_pattern'" : "$table_alias.post_mime_type LIKE '$mime_pattern'";
2471
+		} else {
2472
+					$wheres[] = empty($table_alias) ? "post_mime_type = '$mime_pattern'" : "$table_alias.post_mime_type = '$mime_pattern'";
2473
+		}
2474
+	}
2475
+	if ( !empty($wheres) ) {
2476
+			$where = ' AND (' . join(' OR ', $wheres) . ') ';
2398 2477
 	}
2399
-	if ( !empty($wheres) )
2400
-		$where = ' AND (' . join(' OR ', $wheres) . ') ';
2401 2478
 	return $where;
2402 2479
 }
2403 2480
 
@@ -2425,14 +2502,17 @@  discard block
 block discarded – undo
2425 2502
 function wp_delete_post( $postid = 0, $force_delete = false ) {
2426 2503
 	global $wpdb;
2427 2504
 
2428
-	if ( !$post = $wpdb->get_row($wpdb->prepare("SELECT * FROM $wpdb->posts WHERE ID = %d", $postid)) )
2429
-		return $post;
2505
+	if ( !$post = $wpdb->get_row($wpdb->prepare("SELECT * FROM $wpdb->posts WHERE ID = %d", $postid)) ) {
2506
+			return $post;
2507
+	}
2430 2508
 
2431
-	if ( !$force_delete && ( $post->post_type == 'post' || $post->post_type == 'page') && get_post_status( $postid ) != 'trash' && EMPTY_TRASH_DAYS )
2432
-		return wp_trash_post( $postid );
2509
+	if ( !$force_delete && ( $post->post_type == 'post' || $post->post_type == 'page') && get_post_status( $postid ) != 'trash' && EMPTY_TRASH_DAYS ) {
2510
+			return wp_trash_post( $postid );
2511
+	}
2433 2512
 
2434
-	if ( $post->post_type == 'attachment' )
2435
-		return wp_delete_attachment( $postid, $force_delete );
2513
+	if ( $post->post_type == 'attachment' ) {
2514
+			return wp_delete_attachment( $postid, $force_delete );
2515
+	}
2436 2516
 
2437 2517
 	/**
2438 2518
 	 * Filters whether a post deletion should take place.
@@ -2479,8 +2559,9 @@  discard block
 block discarded – undo
2479 2559
 	// Do raw query. wp_get_post_revisions() is filtered.
2480 2560
 	$revision_ids = $wpdb->get_col( $wpdb->prepare( "SELECT ID FROM $wpdb->posts WHERE post_parent = %d AND post_type = 'revision'", $postid ) );
2481 2561
 	// Use wp_delete_post (via wp_delete_post_revision) again. Ensures any meta/misplaced data gets cleaned up.
2482
-	foreach ( $revision_ids as $revision_id )
2483
-		wp_delete_post_revision( $revision_id );
2562
+	foreach ( $revision_ids as $revision_id ) {
2563
+			wp_delete_post_revision( $revision_id );
2564
+	}
2484 2565
 
2485 2566
 	// Point all attachments to this post up one level.
2486 2567
 	$wpdb->update( $wpdb->posts, $parent_data, $parent_where + array( 'post_type' => 'attachment' ) );
@@ -2495,8 +2576,9 @@  discard block
 block discarded – undo
2495 2576
 	wp_defer_comment_counting( false );
2496 2577
 
2497 2578
 	$post_meta_ids = $wpdb->get_col( $wpdb->prepare( "SELECT meta_id FROM $wpdb->postmeta WHERE post_id = %d ", $postid ));
2498
-	foreach ( $post_meta_ids as $mid )
2499
-		delete_metadata_by_mid( 'post', $mid );
2579
+	foreach ( $post_meta_ids as $mid ) {
2580
+			delete_metadata_by_mid( 'post', $mid );
2581
+	}
2500 2582
 
2501 2583
 	/**
2502 2584
 	 * Fires immediately before a post is deleted from the database.
@@ -2523,8 +2605,9 @@  discard block
 block discarded – undo
2523 2605
 	clean_post_cache( $post );
2524 2606
 
2525 2607
 	if ( is_post_type_hierarchical( $post->post_type ) && $children ) {
2526
-		foreach ( $children as $child )
2527
-			clean_post_cache( $child );
2608
+		foreach ( $children as $child ) {
2609
+					clean_post_cache( $child );
2610
+		}
2528 2611
 	}
2529 2612
 
2530 2613
 	wp_clear_scheduled_hook('publish_future_post', array( $postid ) );
@@ -2586,14 +2669,17 @@  discard block
 block discarded – undo
2586 2669
  * @return false|array|WP_Post|null Post data array, otherwise false.
2587 2670
  */
2588 2671
 function wp_trash_post( $post_id = 0 ) {
2589
-	if ( !EMPTY_TRASH_DAYS )
2590
-		return wp_delete_post($post_id, true);
2672
+	if ( !EMPTY_TRASH_DAYS ) {
2673
+			return wp_delete_post($post_id, true);
2674
+	}
2591 2675
 
2592
-	if ( !$post = get_post($post_id, ARRAY_A) )
2593
-		return $post;
2676
+	if ( !$post = get_post($post_id, ARRAY_A) ) {
2677
+			return $post;
2678
+	}
2594 2679
 
2595
-	if ( $post['post_status'] == 'trash' )
2596
-		return false;
2680
+	if ( $post['post_status'] == 'trash' ) {
2681
+			return false;
2682
+	}
2597 2683
 
2598 2684
 	/**
2599 2685
 	 * Fires before a post is sent to the trash.
@@ -2633,11 +2719,13 @@  discard block
 block discarded – undo
2633 2719
  * @return WP_Post|false WP_Post object. False on failure.
2634 2720
  */
2635 2721
 function wp_untrash_post( $post_id = 0 ) {
2636
-	if ( !$post = get_post($post_id, ARRAY_A) )
2637
-		return $post;
2722
+	if ( !$post = get_post($post_id, ARRAY_A) ) {
2723
+			return $post;
2724
+	}
2638 2725
 
2639
-	if ( $post['post_status'] != 'trash' )
2640
-		return false;
2726
+	if ( $post['post_status'] != 'trash' ) {
2727
+			return false;
2728
+	}
2641 2729
 
2642 2730
 	/**
2643 2731
 	 * Fires before a post is restored from the trash.
@@ -2685,8 +2773,9 @@  discard block
 block discarded – undo
2685 2773
 	global $wpdb;
2686 2774
 
2687 2775
 	$post = get_post($post);
2688
-	if ( empty($post) )
2689
-		return;
2776
+	if ( empty($post) ) {
2777
+			return;
2778
+	}
2690 2779
 
2691 2780
 	$post_id = $post->ID;
2692 2781
 
@@ -2700,13 +2789,15 @@  discard block
 block discarded – undo
2700 2789
 	do_action( 'trash_post_comments', $post_id );
2701 2790
 
2702 2791
 	$comments = $wpdb->get_results( $wpdb->prepare("SELECT comment_ID, comment_approved FROM $wpdb->comments WHERE comment_post_ID = %d", $post_id) );
2703
-	if ( empty($comments) )
2704
-		return;
2792
+	if ( empty($comments) ) {
2793
+			return;
2794
+	}
2705 2795
 
2706 2796
 	// Cache current status for each comment.
2707 2797
 	$statuses = array();
2708
-	foreach ( $comments as $comment )
2709
-		$statuses[$comment->comment_ID] = $comment->comment_approved;
2798
+	foreach ( $comments as $comment ) {
2799
+			$statuses[$comment->comment_ID] = $comment->comment_approved;
2800
+	}
2710 2801
 	add_post_meta($post_id, '_wp_trash_meta_comments_status', $statuses);
2711 2802
 
2712 2803
 	// Set status for all comments to post-trashed.
@@ -2741,15 +2832,17 @@  discard block
 block discarded – undo
2741 2832
 	global $wpdb;
2742 2833
 
2743 2834
 	$post = get_post($post);
2744
-	if ( empty($post) )
2745
-		return;
2835
+	if ( empty($post) ) {
2836
+			return;
2837
+	}
2746 2838
 
2747 2839
 	$post_id = $post->ID;
2748 2840
 
2749 2841
 	$statuses = get_post_meta($post_id, '_wp_trash_meta_comments_status', true);
2750 2842
 
2751
-	if ( empty($statuses) )
2752
-		return true;
2843
+	if ( empty($statuses) ) {
2844
+			return true;
2845
+	}
2753 2846
 
2754 2847
 	/**
2755 2848
 	 * Fires before comments are restored for a post from the trash.
@@ -2762,8 +2855,9 @@  discard block
 block discarded – undo
2762 2855
 
2763 2856
 	// Restore each comment to its original status.
2764 2857
 	$group_by_status = array();
2765
-	foreach ( $statuses as $comment_id => $comment_status )
2766
-		$group_by_status[$comment_status][] = $comment_id;
2858
+	foreach ( $statuses as $comment_id => $comment_status ) {
2859
+			$group_by_status[$comment_status][] = $comment_id;
2860
+	}
2767 2861
 
2768 2862
 	foreach ( $group_by_status as $status => $comments ) {
2769 2863
 		// Sanity check. This shouldn't happen.
@@ -3547,8 +3641,9 @@  discard block
 block discarded – undo
3547 3641
 	$post = get_post($postarr['ID'], ARRAY_A);
3548 3642
 
3549 3643
 	if ( is_null( $post ) ) {
3550
-		if ( $wp_error )
3551
-			return new WP_Error( 'invalid_post', __( 'Invalid post ID.' ) );
3644
+		if ( $wp_error ) {
3645
+					return new WP_Error( 'invalid_post', __( 'Invalid post ID.' ) );
3646
+		}
3552 3647
 		return 0;
3553 3648
 	}
3554 3649
 
@@ -3557,17 +3652,19 @@  discard block
 block discarded – undo
3557 3652
 
3558 3653
 	// Passed post category list overwrites existing category list if not empty.
3559 3654
 	if ( isset($postarr['post_category']) && is_array($postarr['post_category'])
3560
-			 && 0 != count($postarr['post_category']) )
3561
-		$post_cats = $postarr['post_category'];
3562
-	else
3563
-		$post_cats = $post['post_category'];
3655
+			 && 0 != count($postarr['post_category']) ) {
3656
+			$post_cats = $postarr['post_category'];
3657
+	} else {
3658
+			$post_cats = $post['post_category'];
3659
+	}
3564 3660
 
3565 3661
 	// Drafts shouldn't be assigned a date unless explicitly done so by the user.
3566 3662
 	if ( isset( $post['post_status'] ) && in_array($post['post_status'], array('draft', 'pending', 'auto-draft')) && empty($postarr['edit_date']) &&
3567
-			 ('0000-00-00 00:00:00' == $post['post_date_gmt']) )
3568
-		$clear_date = true;
3569
-	else
3570
-		$clear_date = false;
3663
+			 ('0000-00-00 00:00:00' == $post['post_date_gmt']) ) {
3664
+			$clear_date = true;
3665
+	} else {
3666
+			$clear_date = false;
3667
+	}
3571 3668
 
3572 3669
 	// Merge old and new fields with new fields overwriting old ones.
3573 3670
 	$postarr = array_merge($post, $postarr);
@@ -3577,8 +3674,9 @@  discard block
 block discarded – undo
3577 3674
 		$postarr['post_date_gmt'] = '';
3578 3675
 	}
3579 3676
 
3580
-	if ($postarr['post_type'] == 'attachment')
3581
-		return wp_insert_attachment($postarr);
3677
+	if ($postarr['post_type'] == 'attachment') {
3678
+			return wp_insert_attachment($postarr);
3679
+	}
3582 3680
 
3583 3681
 	return wp_insert_post( $postarr, $wp_error );
3584 3682
 }
@@ -3595,11 +3693,13 @@  discard block
 block discarded – undo
3595 3693
 function wp_publish_post( $post ) {
3596 3694
 	global $wpdb;
3597 3695
 
3598
-	if ( ! $post = get_post( $post ) )
3599
-		return;
3696
+	if ( ! $post = get_post( $post ) ) {
3697
+			return;
3698
+	}
3600 3699
 
3601
-	if ( 'publish' == $post->post_status )
3602
-		return;
3700
+	if ( 'publish' == $post->post_status ) {
3701
+			return;
3702
+	}
3603 3703
 
3604 3704
 	$wpdb->update( $wpdb->posts, array( 'post_status' => 'publish' ), array( 'ID' => $post->ID ) );
3605 3705
 
@@ -3635,11 +3735,13 @@  discard block
 block discarded – undo
3635 3735
 function check_and_publish_future_post( $post_id ) {
3636 3736
 	$post = get_post($post_id);
3637 3737
 
3638
-	if ( empty($post) )
3639
-		return;
3738
+	if ( empty($post) ) {
3739
+			return;
3740
+	}
3640 3741
 
3641
-	if ( 'future' != $post->post_status )
3642
-		return;
3742
+	if ( 'future' != $post->post_status ) {
3743
+			return;
3744
+	}
3643 3745
 
3644 3746
 	$time = strtotime( $post->post_date_gmt . ' GMT' );
3645 3747
 
@@ -3670,16 +3772,18 @@  discard block
 block discarded – undo
3670 3772
  * @return string Unique slug for the post, based on $post_name (with a -1, -2, etc. suffix)
3671 3773
  */
3672 3774
 function wp_unique_post_slug( $slug, $post_ID, $post_status, $post_type, $post_parent ) {
3673
-	if ( in_array( $post_status, array( 'draft', 'pending', 'auto-draft' ) ) || ( 'inherit' == $post_status && 'revision' == $post_type ) )
3674
-		return $slug;
3775
+	if ( in_array( $post_status, array( 'draft', 'pending', 'auto-draft' ) ) || ( 'inherit' == $post_status && 'revision' == $post_type ) ) {
3776
+			return $slug;
3777
+	}
3675 3778
 
3676 3779
 	global $wpdb, $wp_rewrite;
3677 3780
 
3678 3781
 	$original_slug = $slug;
3679 3782
 
3680 3783
 	$feeds = $wp_rewrite->feeds;
3681
-	if ( ! is_array( $feeds ) )
3682
-		$feeds = array();
3784
+	if ( ! is_array( $feeds ) ) {
3785
+			$feeds = array();
3786
+	}
3683 3787
 
3684 3788
 	if ( 'attachment' == $post_type ) {
3685 3789
 		// Attachment slugs must be unique across all types.
@@ -3704,8 +3808,9 @@  discard block
 block discarded – undo
3704 3808
 			$slug = $alt_post_name;
3705 3809
 		}
3706 3810
 	} elseif ( is_post_type_hierarchical( $post_type ) ) {
3707
-		if ( 'nav_menu_item' == $post_type )
3708
-			return $slug;
3811
+		if ( 'nav_menu_item' == $post_type ) {
3812
+					return $slug;
3813
+		}
3709 3814
 
3710 3815
 		/*
3711 3816
 		 * Page slugs must be unique within their own trees. Pages are in a separate
@@ -3810,10 +3915,11 @@  discard block
 block discarded – undo
3810 3915
 function _truncate_post_slug( $slug, $length = 200 ) {
3811 3916
 	if ( strlen( $slug ) > $length ) {
3812 3917
 		$decoded_slug = urldecode( $slug );
3813
-		if ( $decoded_slug === $slug )
3814
-			$slug = substr( $slug, 0, $length );
3815
-		else
3816
-			$slug = utf8_uri_encode( $decoded_slug, $length );
3918
+		if ( $decoded_slug === $slug ) {
3919
+					$slug = substr( $slug, 0, $length );
3920
+		} else {
3921
+					$slug = utf8_uri_encode( $decoded_slug, $length );
3922
+		}
3817 3923
 	}
3818 3924
 
3819 3925
 	return rtrim( $slug, '-' );
@@ -3871,16 +3977,19 @@  discard block
 block discarded – undo
3871 3977
 function wp_set_post_terms( $post_id = 0, $tags = '', $taxonomy = 'post_tag', $append = false ) {
3872 3978
 	$post_id = (int) $post_id;
3873 3979
 
3874
-	if ( !$post_id )
3875
-		return false;
3980
+	if ( !$post_id ) {
3981
+			return false;
3982
+	}
3876 3983
 
3877
-	if ( empty($tags) )
3878
-		$tags = array();
3984
+	if ( empty($tags) ) {
3985
+			$tags = array();
3986
+	}
3879 3987
 
3880 3988
 	if ( ! is_array( $tags ) ) {
3881 3989
 		$comma = _x( ',', 'tag delimiter' );
3882
-		if ( ',' !== $comma )
3883
-			$tags = str_replace( $comma, ',', $tags );
3990
+		if ( ',' !== $comma ) {
3991
+					$tags = str_replace( $comma, ',', $tags );
3992
+		}
3884 3993
 		$tags = explode( ',', trim( $tags, " \n\t\r\0\x0B," ) );
3885 3994
 	}
3886 3995
 
@@ -4028,8 +4137,7 @@  discard block
 block discarded – undo
4028 4137
 
4029 4138
 	if ( is_array( $uri ) ) {
4030 4139
 		$pung = array_merge( $pung, $uri );
4031
-	}
4032
-	else {
4140
+	} else {
4033 4141
 		$pung[] = $uri;
4034 4142
 	}
4035 4143
 	$new = implode("\n", $pung);
@@ -4059,12 +4167,14 @@  discard block
 block discarded – undo
4059 4167
 function get_enclosed( $post_id ) {
4060 4168
 	$custom_fields = get_post_custom( $post_id );
4061 4169
 	$pung = array();
4062
-	if ( !is_array( $custom_fields ) )
4063
-		return $pung;
4170
+	if ( !is_array( $custom_fields ) ) {
4171
+			return $pung;
4172
+	}
4064 4173
 
4065 4174
 	foreach ( $custom_fields as $key => $val ) {
4066
-		if ( 'enclosure' != $key || !is_array( $val ) )
4067
-			continue;
4175
+		if ( 'enclosure' != $key || !is_array( $val ) ) {
4176
+					continue;
4177
+		}
4068 4178
 		foreach ( $val as $enc ) {
4069 4179
 			$enclosure = explode( "\n", $enc );
4070 4180
 			$pung[] = trim( $enclosure[ 0 ] );
@@ -4283,15 +4393,17 @@  discard block
 block discarded – undo
4283 4393
 			while ( $p->post_parent != 0 && isset( $pages[ $p->post_parent ] ) ) {
4284 4394
 				$count++;
4285 4395
 				$parent = $pages[ $p->post_parent ];
4286
-				if ( ! isset( $revparts[ $count ] ) || $parent->post_name != $revparts[ $count ] )
4287
-					break;
4396
+				if ( ! isset( $revparts[ $count ] ) || $parent->post_name != $revparts[ $count ] ) {
4397
+									break;
4398
+				}
4288 4399
 				$p = $parent;
4289 4400
 			}
4290 4401
 
4291 4402
 			if ( $p->post_parent == 0 && $count+1 == count( $revparts ) && $p->post_name == $revparts[ $count ] ) {
4292 4403
 				$foundid = $page->ID;
4293
-				if ( $page->post_type == $post_type )
4294
-					break;
4404
+				if ( $page->post_type == $post_type ) {
4405
+									break;
4406
+				}
4295 4407
 			}
4296 4408
 		}
4297 4409
 	}
@@ -4452,8 +4564,9 @@  discard block
 block discarded – undo
4452 4564
 		$page = get_post( $page );
4453 4565
 	}
4454 4566
 
4455
-	if ( ! $page )
4456
-		return false;
4567
+	if ( ! $page ) {
4568
+			return false;
4569
+	}
4457 4570
 
4458 4571
 	$uri = $page->post_name;
4459 4572
 
@@ -4787,14 +4900,17 @@  discard block
 block discarded – undo
4787 4900
  * @return bool True on success, false on failure.
4788 4901
  */
4789 4902
 function is_local_attachment($url) {
4790
-	if (strpos($url, home_url()) === false)
4791
-		return false;
4792
-	if (strpos($url, home_url('/?attachment_id=')) !== false)
4793
-		return true;
4903
+	if (strpos($url, home_url()) === false) {
4904
+			return false;
4905
+	}
4906
+	if (strpos($url, home_url('/?attachment_id=')) !== false) {
4907
+			return true;
4908
+	}
4794 4909
 	if ( $id = url_to_postid($url) ) {
4795 4910
 		$post = get_post($id);
4796
-		if ( 'attachment' == $post->post_type )
4797
-			return true;
4911
+		if ( 'attachment' == $post->post_type ) {
4912
+					return true;
4913
+		}
4798 4914
 	}
4799 4915
 	return false;
4800 4916
 }
@@ -4863,14 +4979,17 @@  discard block
 block discarded – undo
4863 4979
 function wp_delete_attachment( $post_id, $force_delete = false ) {
4864 4980
 	global $wpdb;
4865 4981
 
4866
-	if ( !$post = $wpdb->get_row( $wpdb->prepare("SELECT * FROM $wpdb->posts WHERE ID = %d", $post_id) ) )
4867
-		return $post;
4982
+	if ( !$post = $wpdb->get_row( $wpdb->prepare("SELECT * FROM $wpdb->posts WHERE ID = %d", $post_id) ) ) {
4983
+			return $post;
4984
+	}
4868 4985
 
4869
-	if ( 'attachment' != $post->post_type )
4870
-		return false;
4986
+	if ( 'attachment' != $post->post_type ) {
4987
+			return false;
4988
+	}
4871 4989
 
4872
-	if ( !$force_delete && EMPTY_TRASH_DAYS && MEDIA_TRASH && 'trash' != $post->post_status )
4873
-		return wp_trash_post( $post_id );
4990
+	if ( !$force_delete && EMPTY_TRASH_DAYS && MEDIA_TRASH && 'trash' != $post->post_status ) {
4991
+			return wp_trash_post( $post_id );
4992
+	}
4874 4993
 
4875 4994
 	delete_post_meta($post_id, '_wp_trash_meta_status');
4876 4995
 	delete_post_meta($post_id, '_wp_trash_meta_time');
@@ -4879,8 +4998,9 @@  discard block
 block discarded – undo
4879 4998
 	$backup_sizes = get_post_meta( $post->ID, '_wp_attachment_backup_sizes', true );
4880 4999
 	$file = get_attached_file( $post_id );
4881 5000
 
4882
-	if ( is_multisite() )
4883
-		delete_transient( 'dirsize_cache' );
5001
+	if ( is_multisite() ) {
5002
+			delete_transient( 'dirsize_cache' );
5003
+	}
4884 5004
 
4885 5005
 	/**
4886 5006
 	 * Fires before an attachment is deleted, at the start of wp_delete_attachment().
@@ -4907,8 +5027,9 @@  discard block
 block discarded – undo
4907 5027
 	wp_defer_comment_counting( false );
4908 5028
 
4909 5029
 	$post_meta_ids = $wpdb->get_col( $wpdb->prepare( "SELECT meta_id FROM $wpdb->postmeta WHERE post_id = %d ", $post_id ));
4910
-	foreach ( $post_meta_ids as $mid )
4911
-		delete_metadata_by_mid( 'post', $mid );
5030
+	foreach ( $post_meta_ids as $mid ) {
5031
+			delete_metadata_by_mid( 'post', $mid );
5032
+	}
4912 5033
 
4913 5034
 	/** This action is documented in wp-includes/post.php */
4914 5035
 	do_action( 'delete_post', $post_id );
@@ -4968,13 +5089,15 @@  discard block
 block discarded – undo
4968 5089
  */
4969 5090
 function wp_get_attachment_metadata( $post_id = 0, $unfiltered = false ) {
4970 5091
 	$post_id = (int) $post_id;
4971
-	if ( !$post = get_post( $post_id ) )
4972
-		return false;
5092
+	if ( !$post = get_post( $post_id ) ) {
5093
+			return false;
5094
+	}
4973 5095
 
4974 5096
 	$data = get_post_meta( $post->ID, '_wp_attachment_metadata', true );
4975 5097
 
4976
-	if ( $unfiltered )
4977
-		return $data;
5098
+	if ( $unfiltered ) {
5099
+			return $data;
5100
+	}
4978 5101
 
4979 5102
 	/**
4980 5103
 	 * Filters the attachment meta data.
@@ -4999,8 +5122,9 @@  discard block
 block discarded – undo
4999 5122
  */
5000 5123
 function wp_update_attachment_metadata( $post_id, $data ) {
5001 5124
 	$post_id = (int) $post_id;
5002
-	if ( !$post = get_post( $post_id ) )
5003
-		return false;
5125
+	if ( !$post = get_post( $post_id ) ) {
5126
+			return false;
5127
+	}
5004 5128
 
5005 5129
 	/**
5006 5130
 	 * Filters the updated attachment meta data.
@@ -5010,11 +5134,12 @@  discard block
 block discarded – undo
5010 5134
 	 * @param array $data    Array of updated attachment meta data.
5011 5135
 	 * @param int   $post_id Attachment ID.
5012 5136
 	 */
5013
-	if ( $data = apply_filters( 'wp_update_attachment_metadata', $data, $post->ID ) )
5014
-		return update_post_meta( $post->ID, '_wp_attachment_metadata', $data );
5015
-	else
5016
-		return delete_post_meta( $post->ID, '_wp_attachment_metadata' );
5017
-}
5137
+	if ( $data = apply_filters( 'wp_update_attachment_metadata', $data, $post->ID ) ) {
5138
+			return update_post_meta( $post->ID, '_wp_attachment_metadata', $data );
5139
+	} else {
5140
+			return delete_post_meta( $post->ID, '_wp_attachment_metadata' );
5141
+	}
5142
+	}
5018 5143
 
5019 5144
 /**
5020 5145
  * Retrieve the URL for an attachment.
@@ -5028,11 +5153,13 @@  discard block
 block discarded – undo
5028 5153
  */
5029 5154
 function wp_get_attachment_url( $post_id = 0 ) {
5030 5155
 	$post_id = (int) $post_id;
5031
-	if ( !$post = get_post( $post_id ) )
5032
-		return false;
5156
+	if ( !$post = get_post( $post_id ) ) {
5157
+			return false;
5158
+	}
5033 5159
 
5034
-	if ( 'attachment' != $post->post_type )
5035
-		return false;
5160
+	if ( 'attachment' != $post->post_type ) {
5161
+			return false;
5162
+	}
5036 5163
 
5037 5164
 	$url = '';
5038 5165
 	// Get attached file.
@@ -5076,8 +5203,9 @@  discard block
 block discarded – undo
5076 5203
 	 */
5077 5204
 	$url = apply_filters( 'wp_get_attachment_url', $url, $post->ID );
5078 5205
 
5079
-	if ( empty( $url ) )
5080
-		return false;
5206
+	if ( empty( $url ) ) {
5207
+			return false;
5208
+	}
5081 5209
 
5082 5210
 	return $url;
5083 5211
 }
@@ -5123,10 +5251,12 @@  discard block
 block discarded – undo
5123 5251
  */
5124 5252
 function wp_get_attachment_thumb_file( $post_id = 0 ) {
5125 5253
 	$post_id = (int) $post_id;
5126
-	if ( !$post = get_post( $post_id ) )
5127
-		return false;
5128
-	if ( !is_array( $imagedata = wp_get_attachment_metadata( $post->ID ) ) )
5129
-		return false;
5254
+	if ( !$post = get_post( $post_id ) ) {
5255
+			return false;
5256
+	}
5257
+	if ( !is_array( $imagedata = wp_get_attachment_metadata( $post->ID ) ) ) {
5258
+			return false;
5259
+	}
5130 5260
 
5131 5261
 	$file = get_attached_file( $post->ID );
5132 5262
 
@@ -5154,17 +5284,21 @@  discard block
 block discarded – undo
5154 5284
  */
5155 5285
 function wp_get_attachment_thumb_url( $post_id = 0 ) {
5156 5286
 	$post_id = (int) $post_id;
5157
-	if ( !$post = get_post( $post_id ) )
5158
-		return false;
5159
-	if ( !$url = wp_get_attachment_url( $post->ID ) )
5160
-		return false;
5287
+	if ( !$post = get_post( $post_id ) ) {
5288
+			return false;
5289
+	}
5290
+	if ( !$url = wp_get_attachment_url( $post->ID ) ) {
5291
+			return false;
5292
+	}
5161 5293
 
5162 5294
 	$sized = image_downsize( $post_id, 'thumbnail' );
5163
-	if ( $sized )
5164
-		return $sized[0];
5295
+	if ( $sized ) {
5296
+			return $sized[0];
5297
+	}
5165 5298
 
5166
-	if ( !$thumb = wp_get_attachment_thumb_file( $post->ID ) )
5167
-		return false;
5299
+	if ( !$thumb = wp_get_attachment_thumb_file( $post->ID ) ) {
5300
+			return false;
5301
+	}
5168 5302
 
5169 5303
 	$url = str_replace(basename($url), basename($thumb), $url);
5170 5304
 
@@ -5251,8 +5385,9 @@  discard block
 block discarded – undo
5251 5385
  * @return string|false Icon, false otherwise.
5252 5386
  */
5253 5387
 function wp_mime_type_icon( $mime = 0 ) {
5254
-	if ( !is_numeric($mime) )
5255
-		$icon = wp_cache_get("mime_type_icon_$mime");
5388
+	if ( !is_numeric($mime) ) {
5389
+			$icon = wp_cache_get("mime_type_icon_$mime");
5390
+	}
5256 5391
 
5257 5392
 	$post_id = 0;
5258 5393
 	if ( empty($icon) ) {
@@ -5265,8 +5400,9 @@  discard block
 block discarded – undo
5265 5400
 				$ext = preg_replace('/^.+?\.([^.]+)$/', '$1', $file);
5266 5401
 				if ( !empty($ext) ) {
5267 5402
 					$post_mimes[] = $ext;
5268
-					if ( $ext_type = wp_ext2type( $ext ) )
5269
-						$post_mimes[] = $ext_type;
5403
+					if ( $ext_type = wp_ext2type( $ext ) ) {
5404
+											$post_mimes[] = $ext_type;
5405
+					}
5270 5406
 				}
5271 5407
 				$mime = $post->post_mime_type;
5272 5408
 			} else {
@@ -5313,11 +5449,13 @@  discard block
 block discarded – undo
5313 5449
 				if ( $dh = opendir($dir) ) {
5314 5450
 					while ( false !== $file = readdir($dh) ) {
5315 5451
 						$file = basename($file);
5316
-						if ( substr($file, 0, 1) == '.' )
5317
-							continue;
5452
+						if ( substr($file, 0, 1) == '.' ) {
5453
+													continue;
5454
+						}
5318 5455
 						if ( !in_array(strtolower(substr($file, -4)), array('.png', '.gif', '.jpg') ) ) {
5319
-							if ( is_dir("$dir/$file") )
5320
-								$dirs["$dir/$file"] = "$uri/$file";
5456
+							if ( is_dir("$dir/$file") ) {
5457
+															$dirs["$dir/$file"] = "$uri/$file";
5458
+							}
5321 5459
 							continue;
5322 5460
 						}
5323 5461
 						$icon_files["$dir/$file"] = "$uri/$file";
@@ -5330,8 +5468,9 @@  discard block
 block discarded – undo
5330 5468
 
5331 5469
 		$types = array();
5332 5470
 		// Icon basename - extension = MIME wildcard.
5333
-		foreach ( $icon_files as $file => $uri )
5334
-			$types[ preg_replace('/^([^.]*).*$/', '$1', basename($file)) ] =& $icon_files[$file];
5471
+		foreach ( $icon_files as $file => $uri ) {
5472
+					$types[ preg_replace('/^([^.]*).*$/', '$1', basename($file)) ] =& $icon_files[$file];
5473
+		}
5335 5474
 
5336 5475
 		if ( ! empty($mime) ) {
5337 5476
 			$post_mimes[] = substr($mime, 0, strpos($mime, '/'));
@@ -5669,12 +5808,14 @@  discard block
 block discarded – undo
5669 5808
  * @param array $posts Array of post objects, passed by reference.
5670 5809
  */
5671 5810
 function update_post_cache( &$posts ) {
5672
-	if ( ! $posts )
5673
-		return;
5811
+	if ( ! $posts ) {
5812
+			return;
5813
+	}
5674 5814
 
5675
-	foreach ( $posts as $post )
5676
-		wp_cache_add( $post->ID, $post, 'posts' );
5677
-}
5815
+	foreach ( $posts as $post ) {
5816
+			wp_cache_add( $post->ID, $post, 'posts' );
5817
+	}
5818
+	}
5678 5819
 
5679 5820
 /**
5680 5821
  * Will clean the post in the cache.
@@ -5694,12 +5835,14 @@  discard block
 block discarded – undo
5694 5835
 function clean_post_cache( $post ) {
5695 5836
 	global $_wp_suspend_cache_invalidation;
5696 5837
 
5697
-	if ( ! empty( $_wp_suspend_cache_invalidation ) )
5698
-		return;
5838
+	if ( ! empty( $_wp_suspend_cache_invalidation ) ) {
5839
+			return;
5840
+	}
5699 5841
 
5700 5842
 	$post = get_post( $post );
5701
-	if ( empty( $post ) )
5702
-		return;
5843
+	if ( empty( $post ) ) {
5844
+			return;
5845
+	}
5703 5846
 
5704 5847
 	wp_cache_delete( $post->ID, 'posts' );
5705 5848
 	wp_cache_delete( $post->ID, 'post_meta' );
@@ -5746,17 +5889,20 @@  discard block
 block discarded – undo
5746 5889
  */
5747 5890
 function update_post_caches( &$posts, $post_type = 'post', $update_term_cache = true, $update_meta_cache = true ) {
5748 5891
 	// No point in doing all this work if we didn't match any posts.
5749
-	if ( !$posts )
5750
-		return;
5892
+	if ( !$posts ) {
5893
+			return;
5894
+	}
5751 5895
 
5752 5896
 	update_post_cache($posts);
5753 5897
 
5754 5898
 	$post_ids = array();
5755
-	foreach ( $posts as $post )
5756
-		$post_ids[] = $post->ID;
5899
+	foreach ( $posts as $post ) {
5900
+			$post_ids[] = $post->ID;
5901
+	}
5757 5902
 
5758
-	if ( ! $post_type )
5759
-		$post_type = 'any';
5903
+	if ( ! $post_type ) {
5904
+			$post_type = 'any';
5905
+	}
5760 5906
 
5761 5907
 	if ( $update_term_cache ) {
5762 5908
 		if ( is_array($post_type) ) {
@@ -5772,13 +5918,15 @@  discard block
 block discarded – undo
5772 5918
 			$ptypes = array($post_type);
5773 5919
 		}
5774 5920
 
5775
-		if ( ! empty($ptypes) )
5776
-			update_object_term_cache($post_ids, $ptypes);
5921
+		if ( ! empty($ptypes) ) {
5922
+					update_object_term_cache($post_ids, $ptypes);
5923
+		}
5777 5924
 	}
5778 5925
 
5779
-	if ( $update_meta_cache )
5780
-		update_postmeta_cache($post_ids);
5781
-}
5926
+	if ( $update_meta_cache ) {
5927
+			update_postmeta_cache($post_ids);
5928
+	}
5929
+	}
5782 5930
 
5783 5931
 /**
5784 5932
  * Updates metadata cache for list of post IDs.
@@ -5815,16 +5963,18 @@  discard block
 block discarded – undo
5815 5963
 function clean_attachment_cache( $id, $clean_terms = false ) {
5816 5964
 	global $_wp_suspend_cache_invalidation;
5817 5965
 
5818
-	if ( !empty($_wp_suspend_cache_invalidation) )
5819
-		return;
5966
+	if ( !empty($_wp_suspend_cache_invalidation) ) {
5967
+			return;
5968
+	}
5820 5969
 
5821 5970
 	$id = (int) $id;
5822 5971
 
5823 5972
 	wp_cache_delete($id, 'posts');
5824 5973
 	wp_cache_delete($id, 'post_meta');
5825 5974
 
5826
-	if ( $clean_terms )
5827
-		clean_object_term_cache($id, 'attachment');
5975
+	if ( $clean_terms ) {
5976
+			clean_object_term_cache($id, 'attachment');
5977
+	}
5828 5978
 
5829 5979
 	/**
5830 5980
 	 * Fires after the given attachment's cache is cleaned.
@@ -5858,8 +6008,9 @@  discard block
 block discarded – undo
5858 6008
 
5859 6009
 	if ( $old_status != 'publish' && $new_status == 'publish' ) {
5860 6010
 		// Reset GUID if transitioning to publish and it is empty.
5861
-		if ( '' == get_the_guid($post->ID) )
5862
-			$wpdb->update( $wpdb->posts, array( 'guid' => get_permalink( $post->ID ) ), array( 'ID' => $post->ID ) );
6011
+		if ( '' == get_the_guid($post->ID) ) {
6012
+					$wpdb->update( $wpdb->posts, array( 'guid' => get_permalink( $post->ID ) ), array( 'ID' => $post->ID ) );
6013
+		}
5863 6014
 
5864 6015
 		/**
5865 6016
 		 * Fires when a post's status is transitioned from private to published.
@@ -5930,11 +6081,13 @@  discard block
 block discarded – undo
5930 6081
 		do_action( 'xmlrpc_publish_post', $post_id );
5931 6082
 	}
5932 6083
 
5933
-	if ( defined('WP_IMPORTING') )
5934
-		return;
6084
+	if ( defined('WP_IMPORTING') ) {
6085
+			return;
6086
+	}
5935 6087
 
5936
-	if ( get_option('default_pingback_flag') )
5937
-		add_post_meta( $post_id, '_pingme', '1' );
6088
+	if ( get_option('default_pingback_flag') ) {
6089
+			add_post_meta( $post_id, '_pingme', '1' );
6090
+	}
5938 6091
 	add_post_meta( $post_id, '_encloseme', '1' );
5939 6092
 
5940 6093
 	if ( ! wp_next_scheduled( 'do_pings' ) ) {
@@ -5953,8 +6106,9 @@  discard block
 block discarded – undo
5953 6106
  */
5954 6107
 function wp_get_post_parent_id( $post_ID ) {
5955 6108
 	$post = get_post( $post_ID );
5956
-	if ( !$post || is_wp_error( $post ) )
5957
-		return false;
6109
+	if ( !$post || is_wp_error( $post ) ) {
6110
+			return false;
6111
+	}
5958 6112
 	return (int) $post->post_parent;
5959 6113
 }
5960 6114
 
@@ -5974,28 +6128,35 @@  discard block
 block discarded – undo
5974 6128
  */
5975 6129
 function wp_check_post_hierarchy_for_loops( $post_parent, $post_ID ) {
5976 6130
 	// Nothing fancy here - bail.
5977
-	if ( !$post_parent )
5978
-		return 0;
6131
+	if ( !$post_parent ) {
6132
+			return 0;
6133
+	}
5979 6134
 
5980 6135
 	// New post can't cause a loop.
5981
-	if ( empty( $post_ID ) )
5982
-		return $post_parent;
6136
+	if ( empty( $post_ID ) ) {
6137
+			return $post_parent;
6138
+	}
5983 6139
 
5984 6140
 	// Can't be its own parent.
5985
-	if ( $post_parent == $post_ID )
5986
-		return 0;
6141
+	if ( $post_parent == $post_ID ) {
6142
+			return 0;
6143
+	}
5987 6144
 
5988 6145
 	// Now look for larger loops.
5989
-	if ( !$loop = wp_find_hierarchy_loop( 'wp_get_post_parent_id', $post_ID, $post_parent ) )
5990
-		return $post_parent; // No loop
6146
+	if ( !$loop = wp_find_hierarchy_loop( 'wp_get_post_parent_id', $post_ID, $post_parent ) ) {
6147
+			return $post_parent;
6148
+	}
6149
+	// No loop
5991 6150
 
5992 6151
 	// Setting $post_parent to the given value causes a loop.
5993
-	if ( isset( $loop[$post_ID] ) )
5994
-		return 0;
6152
+	if ( isset( $loop[$post_ID] ) ) {
6153
+			return 0;
6154
+	}
5995 6155
 
5996 6156
 	// There's a loop, but it doesn't contain $post_ID. Break the loop.
5997
-	foreach ( array_keys( $loop ) as $loop_member )
5998
-		wp_update_post( array( 'ID' => $loop_member, 'post_parent' => 0 ) );
6157
+	foreach ( array_keys( $loop ) as $loop_member ) {
6158
+			wp_update_post( array( 'ID' => $loop_member, 'post_parent' => 0 ) );
6159
+	}
5999 6160
 
6000 6161
 	return $post_parent;
6001 6162
 }
@@ -6013,10 +6174,11 @@  discard block
 block discarded – undo
6013 6174
 	$post = get_post( $post );
6014 6175
 	$thumbnail_id = absint( $thumbnail_id );
6015 6176
 	if ( $post && $thumbnail_id && get_post( $thumbnail_id ) ) {
6016
-		if ( wp_get_attachment_image( $thumbnail_id, 'thumbnail' ) )
6017
-			return update_post_meta( $post->ID, '_thumbnail_id', $thumbnail_id );
6018
-		else
6019
-			return delete_post_meta( $post->ID, '_thumbnail_id' );
6177
+		if ( wp_get_attachment_image( $thumbnail_id, 'thumbnail' ) ) {
6178
+					return update_post_meta( $post->ID, '_thumbnail_id', $thumbnail_id );
6179
+		} else {
6180
+					return delete_post_meta( $post->ID, '_thumbnail_id' );
6181
+		}
6020 6182
 	}
6021 6183
 	return false;
6022 6184
 }
@@ -6031,8 +6193,9 @@  discard block
 block discarded – undo
6031 6193
  */
6032 6194
 function delete_post_thumbnail( $post ) {
6033 6195
 	$post = get_post( $post );
6034
-	if ( $post )
6035
-		return delete_post_meta( $post->ID, '_thumbnail_id' );
6196
+	if ( $post ) {
6197
+			return delete_post_meta( $post->ID, '_thumbnail_id' );
6198
+	}
6036 6199
 	return false;
6037 6200
 }
6038 6201
 
Please login to merge, or discard this patch.
src/wp-includes/ms-blogs.php 4 patches
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -845,7 +845,7 @@
 block discarded – undo
845 845
 		 *
846 846
 		 * @param int    $blog_id Blog ID.
847 847
 		 * @param string $value   The value of blog status.
848
- 		 */
848
+		 */
849 849
 		do_action( 'update_blog_public', $blog_id, $value ); // Moved here from update_blog_public().
850 850
 	}
851 851
 
Please login to merge, or discard this patch.
Braces   +71 added lines, -48 removed lines patch added patch discarded remove patch
@@ -60,11 +60,13 @@  discard block
 block discarded – undo
60 60
  */
61 61
 function get_blogaddress_by_name( $blogname ) {
62 62
 	if ( is_subdomain_install() ) {
63
-		if ( $blogname == 'main' )
64
-			$blogname = 'www';
63
+		if ( $blogname == 'main' ) {
64
+					$blogname = 'www';
65
+		}
65 66
 		$url = rtrim( network_home_url(), '/' );
66
-		if ( !empty( $blogname ) )
67
-			$url = preg_replace( '|^([^\.]+://)|', "\${1}" . $blogname . '.', $url );
67
+		if ( !empty( $blogname ) ) {
68
+					$url = preg_replace( '|^([^\.]+://)|', "\${1}" . $blogname . '.', $url );
69
+		}
68 70
 	} else {
69 71
 		$url = network_home_url( $blogname );
70 72
 	}
@@ -128,8 +130,9 @@  discard block
 block discarded – undo
128 130
 		} elseif ( isset($fields['domain']) && isset($fields['path']) ) {
129 131
 			$key = md5( $fields['domain'] . $fields['path'] );
130 132
 			$blog = wp_cache_get($key, 'blog-lookup');
131
-			if ( false !== $blog )
132
-				return $blog;
133
+			if ( false !== $blog ) {
134
+							return $blog;
135
+			}
133 136
 			if ( substr( $fields['domain'], 0, 4 ) == 'www.' ) {
134 137
 				$nowww = substr( $fields['domain'], 4 );
135 138
 				$blog = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM $wpdb->blogs WHERE domain IN (%s,%s) AND path = %s ORDER BY CHAR_LENGTH(domain) DESC", $nowww, $fields['domain'], $fields['path'] ) );
@@ -145,8 +148,9 @@  discard block
 block discarded – undo
145 148
 		} elseif ( isset($fields['domain']) && is_subdomain_install() ) {
146 149
 			$key = md5( $fields['domain'] );
147 150
 			$blog = wp_cache_get($key, 'blog-lookup');
148
-			if ( false !== $blog )
149
-				return $blog;
151
+			if ( false !== $blog ) {
152
+							return $blog;
153
+			}
150 154
 			if ( substr( $fields['domain'], 0, 4 ) == 'www.' ) {
151 155
 				$nowww = substr( $fields['domain'], 4 );
152 156
 				$blog = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM $wpdb->blogs WHERE domain IN (%s,%s) ORDER BY CHAR_LENGTH(domain) DESC", $nowww, $fields['domain'] ) );
@@ -163,12 +167,13 @@  discard block
 block discarded – undo
163 167
 			return false;
164 168
 		}
165 169
 	} else {
166
-		if ( ! $fields )
167
-			$blog_id = get_current_blog_id();
168
-		elseif ( ! is_numeric( $fields ) )
169
-			$blog_id = get_id_from_blogname( $fields );
170
-		else
171
-			$blog_id = $fields;
170
+		if ( ! $fields ) {
171
+					$blog_id = get_current_blog_id();
172
+		} elseif ( ! is_numeric( $fields ) ) {
173
+					$blog_id = get_id_from_blogname( $fields );
174
+		} else {
175
+					$blog_id = $fields;
176
+		}
172 177
 	}
173 178
 
174 179
 	$blog_id = (int) $blog_id;
@@ -305,15 +310,18 @@  discard block
 block discarded – undo
305 310
 function update_blog_details( $blog_id, $details = array() ) {
306 311
 	global $wpdb;
307 312
 
308
-	if ( empty($details) )
309
-		return false;
313
+	if ( empty($details) ) {
314
+			return false;
315
+	}
310 316
 
311
-	if ( is_object($details) )
312
-		$details = get_object_vars($details);
317
+	if ( is_object($details) ) {
318
+			$details = get_object_vars($details);
319
+	}
313 320
 
314 321
 	$current_details = get_site( $blog_id );
315
-	if ( empty($current_details) )
316
-		return false;
322
+	if ( empty($current_details) ) {
323
+			return false;
324
+	}
317 325
 
318 326
 	$current_details = get_object_vars($current_details);
319 327
 
@@ -332,8 +340,9 @@  discard block
 block discarded – undo
332 340
 
333 341
 	$result = $wpdb->update( $wpdb->blogs, $update_details, array('blog_id' => $blog_id) );
334 342
 
335
-	if ( false === $result )
336
-		return false;
343
+	if ( false === $result ) {
344
+			return false;
345
+	}
337 346
 
338 347
 	// If spam status changed, issue actions.
339 348
 	if ( $details['spam'] != $current_details['spam'] ) {
@@ -629,11 +638,13 @@  discard block
 block discarded – undo
629 638
 function get_blog_option( $id, $option, $default = false ) {
630 639
 	$id = (int) $id;
631 640
 
632
-	if ( empty( $id ) )
633
-		$id = get_current_blog_id();
641
+	if ( empty( $id ) ) {
642
+			$id = get_current_blog_id();
643
+	}
634 644
 
635
-	if ( get_current_blog_id() == $id )
636
-		return get_option( $option, $default );
645
+	if ( get_current_blog_id() == $id ) {
646
+			return get_option( $option, $default );
647
+	}
637 648
 
638 649
 	switch_to_blog( $id );
639 650
 	$value = get_option( $option, $default );
@@ -674,11 +685,13 @@  discard block
 block discarded – undo
674 685
 function add_blog_option( $id, $option, $value ) {
675 686
 	$id = (int) $id;
676 687
 
677
-	if ( empty( $id ) )
678
-		$id = get_current_blog_id();
688
+	if ( empty( $id ) ) {
689
+			$id = get_current_blog_id();
690
+	}
679 691
 
680
-	if ( get_current_blog_id() == $id )
681
-		return add_option( $option, $value );
692
+	if ( get_current_blog_id() == $id ) {
693
+			return add_option( $option, $value );
694
+	}
682 695
 
683 696
 	switch_to_blog( $id );
684 697
 	$return = add_option( $option, $value );
@@ -699,11 +712,13 @@  discard block
 block discarded – undo
699 712
 function delete_blog_option( $id, $option ) {
700 713
 	$id = (int) $id;
701 714
 
702
-	if ( empty( $id ) )
703
-		$id = get_current_blog_id();
715
+	if ( empty( $id ) ) {
716
+			$id = get_current_blog_id();
717
+	}
704 718
 
705
-	if ( get_current_blog_id() == $id )
706
-		return delete_option( $option );
719
+	if ( get_current_blog_id() == $id ) {
720
+			return delete_option( $option );
721
+	}
707 722
 
708 723
 	switch_to_blog( $id );
709 724
 	$return = delete_option( $option );
@@ -726,11 +741,13 @@  discard block
 block discarded – undo
726 741
 function update_blog_option( $id, $option, $value, $deprecated = null ) {
727 742
 	$id = (int) $id;
728 743
 
729
-	if ( null !== $deprecated  )
730
-		_deprecated_argument( __FUNCTION__, '3.1.0' );
744
+	if ( null !== $deprecated  ) {
745
+			_deprecated_argument( __FUNCTION__, '3.1.0' );
746
+	}
731 747
 
732
-	if ( get_current_blog_id() == $id )
733
-		return update_option( $option, $value );
748
+	if ( get_current_blog_id() == $id ) {
749
+			return update_option( $option, $value );
750
+	}
734 751
 
735 752
 	switch_to_blog( $id );
736 753
 	$return = update_option( $option, $value );
@@ -965,16 +982,19 @@  discard block
 block discarded – undo
965 982
 function update_blog_status( $blog_id, $pref, $value, $deprecated = null ) {
966 983
 	global $wpdb;
967 984
 
968
-	if ( null !== $deprecated  )
969
-		_deprecated_argument( __FUNCTION__, '3.1.0' );
985
+	if ( null !== $deprecated  ) {
986
+			_deprecated_argument( __FUNCTION__, '3.1.0' );
987
+	}
970 988
 
971
-	if ( ! in_array( $pref, array( 'site_id', 'domain', 'path', 'registered', 'last_updated', 'public', 'archived', 'mature', 'spam', 'deleted', 'lang_id') ) )
972
-		return $value;
989
+	if ( ! in_array( $pref, array( 'site_id', 'domain', 'path', 'registered', 'last_updated', 'public', 'archived', 'mature', 'spam', 'deleted', 'lang_id') ) ) {
990
+			return $value;
991
+	}
973 992
 
974 993
 	$result = $wpdb->update( $wpdb->blogs, array($pref => $value, 'last_updated' => current_time('mysql', true)), array('blog_id' => $blog_id) );
975 994
 
976
-	if ( false === $result )
977
-		return false;
995
+	if ( false === $result ) {
996
+			return false;
997
+	}
978 998
 
979 999
 	refresh_blog_details( $blog_id );
980 1000
 
@@ -1040,8 +1060,9 @@  discard block
 block discarded – undo
1040 1060
 	global $wpdb;
1041 1061
 
1042 1062
 	$details = get_site( $id );
1043
-	if ( $details )
1044
-		return $details->$pref;
1063
+	if ( $details ) {
1064
+			return $details->$pref;
1065
+	}
1045 1066
 
1046 1067
 	return $wpdb->get_var( $wpdb->prepare("SELECT %s FROM {$wpdb->blogs} WHERE blog_id = %d", $pref, $id) );
1047 1068
 }
@@ -1061,8 +1082,10 @@  discard block
 block discarded – undo
1061 1082
 function get_last_updated( $deprecated = '', $start = 0, $quantity = 40 ) {
1062 1083
 	global $wpdb;
1063 1084
 
1064
-	if ( ! empty( $deprecated ) )
1065
-		_deprecated_argument( __FUNCTION__, 'MU' ); // never used
1085
+	if ( ! empty( $deprecated ) ) {
1086
+			_deprecated_argument( __FUNCTION__, 'MU' );
1087
+	}
1088
+	// never used
1066 1089
 
1067 1090
 	return $wpdb->get_results( $wpdb->prepare("SELECT blog_id, domain, path FROM $wpdb->blogs WHERE site_id = %d AND public = '1' AND archived = '0' AND mature = '0' AND spam = '0' AND deleted = '0' AND last_updated != '0000-00-00 00:00:00' ORDER BY last_updated DESC limit %d, %d", $wpdb->siteid, $start, $quantity ) , ARRAY_A );
1068 1091
 }
Please login to merge, or discard this patch.
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -790,7 +790,7 @@
 block discarded – undo
790 790
  *
791 791
  * @param int  $new_blog   The id of the blog you want to switch to. Default: current blog
792 792
  * @param bool $deprecated Deprecated argument
793
- * @return true Always returns True.
793
+ * @return boolean Always returns True.
794 794
  */
795 795
 function switch_to_blog( $new_blog, $deprecated = null ) {
796 796
 	global $wpdb, $wp_roles;
Please login to merge, or discard this patch.
Spacing   +287 added lines, -287 removed lines patch added patch discarded remove patch
@@ -18,7 +18,7 @@  discard block
 block discarded – undo
18 18
 function wpmu_update_blogs_date() {
19 19
 	global $wpdb;
20 20
 
21
-	update_blog_details( $wpdb->blogid, array('last_updated' => current_time('mysql', true)) );
21
+	update_blog_details($wpdb->blogid, array('last_updated' => current_time('mysql', true)));
22 22
 	/**
23 23
 	 * Fires after the blog details are updated.
24 24
 	 *
@@ -26,7 +26,7 @@  discard block
 block discarded – undo
26 26
 	 *
27 27
 	 * @param int $blog_id Site ID.
28 28
 	 */
29
-	do_action( 'wpmu_blog_updated', $wpdb->blogid );
29
+	do_action('wpmu_blog_updated', $wpdb->blogid);
30 30
 }
31 31
 
32 32
 /**
@@ -37,17 +37,17 @@  discard block
 block discarded – undo
37 37
  * @param int $blog_id Blog ID
38 38
  * @return string Full URL of the blog if found. Empty string if not.
39 39
  */
40
-function get_blogaddress_by_id( $blog_id ) {
41
-	$bloginfo = get_site( (int) $blog_id );
40
+function get_blogaddress_by_id($blog_id) {
41
+	$bloginfo = get_site((int) $blog_id);
42 42
 
43
-	if ( empty( $bloginfo ) ) {
43
+	if (empty($bloginfo)) {
44 44
 		return '';
45 45
 	}
46 46
 
47
-	$scheme = parse_url( $bloginfo->home, PHP_URL_SCHEME );
48
-	$scheme = empty( $scheme ) ? 'http' : $scheme;
47
+	$scheme = parse_url($bloginfo->home, PHP_URL_SCHEME);
48
+	$scheme = empty($scheme) ? 'http' : $scheme;
49 49
 
50
-	return esc_url( $scheme . '://' . $bloginfo->domain . $bloginfo->path );
50
+	return esc_url($scheme.'://'.$bloginfo->domain.$bloginfo->path);
51 51
 }
52 52
 
53 53
 /**
@@ -58,17 +58,17 @@  discard block
 block discarded – undo
58 58
  * @param string $blogname The (subdomain or directory) name
59 59
  * @return string
60 60
  */
61
-function get_blogaddress_by_name( $blogname ) {
62
-	if ( is_subdomain_install() ) {
63
-		if ( $blogname == 'main' )
61
+function get_blogaddress_by_name($blogname) {
62
+	if (is_subdomain_install()) {
63
+		if ($blogname == 'main')
64 64
 			$blogname = 'www';
65
-		$url = rtrim( network_home_url(), '/' );
66
-		if ( !empty( $blogname ) )
67
-			$url = preg_replace( '|^([^\.]+://)|', "\${1}" . $blogname . '.', $url );
65
+		$url = rtrim(network_home_url(), '/');
66
+		if ( ! empty($blogname))
67
+			$url = preg_replace('|^([^\.]+://)|', "\${1}".$blogname.'.', $url);
68 68
 	} else {
69
-		$url = network_home_url( $blogname );
69
+		$url = network_home_url($blogname);
70 70
 	}
71
-	return esc_url( $url . '/' );
71
+	return esc_url($url.'/');
72 72
 }
73 73
 
74 74
 /**
@@ -80,30 +80,30 @@  discard block
 block discarded – undo
80 80
  * @param string $slug A site's slug.
81 81
  * @return int|null The site ID, or null if no site is found for the given slug.
82 82
  */
83
-function get_id_from_blogname( $slug ) {
83
+function get_id_from_blogname($slug) {
84 84
 	$current_network = get_network();
85
-	$slug = trim( $slug, '/' );
85
+	$slug = trim($slug, '/');
86 86
 
87
-	if ( is_subdomain_install() ) {
88
-		$domain = $slug . '.' . preg_replace( '|^www\.|', '', $current_network->domain );
87
+	if (is_subdomain_install()) {
88
+		$domain = $slug.'.'.preg_replace('|^www\.|', '', $current_network->domain);
89 89
 		$path = $current_network->path;
90 90
 	} else {
91 91
 		$domain = $current_network->domain;
92
-		$path = $current_network->path . $slug . '/';
92
+		$path = $current_network->path.$slug.'/';
93 93
 	}
94 94
 
95
-	$site_ids = get_sites( array(
95
+	$site_ids = get_sites(array(
96 96
 		'number' => 1,
97 97
 		'fields' => 'ids',
98 98
 		'domain' => $domain,
99 99
 		'path' => $path,
100
-	) );
100
+	));
101 101
 
102
-	if ( empty( $site_ids ) ) {
102
+	if (empty($site_ids)) {
103 103
 		return null;
104 104
 	}
105 105
 
106
-	return array_shift( $site_ids );
106
+	return array_shift($site_ids);
107 107
 }
108 108
 
109 109
 /**
@@ -119,42 +119,42 @@  discard block
 block discarded – undo
119 119
  *                                  Default is true.
120 120
  * @return WP_Site|false Blog details on success. False on failure.
121 121
  */
122
-function get_blog_details( $fields = null, $get_all = true ) {
122
+function get_blog_details($fields = null, $get_all = true) {
123 123
 	global $wpdb;
124 124
 
125
-	if ( is_array($fields ) ) {
126
-		if ( isset($fields['blog_id']) ) {
125
+	if (is_array($fields)) {
126
+		if (isset($fields['blog_id'])) {
127 127
 			$blog_id = $fields['blog_id'];
128
-		} elseif ( isset($fields['domain']) && isset($fields['path']) ) {
129
-			$key = md5( $fields['domain'] . $fields['path'] );
128
+		} elseif (isset($fields['domain']) && isset($fields['path'])) {
129
+			$key = md5($fields['domain'].$fields['path']);
130 130
 			$blog = wp_cache_get($key, 'blog-lookup');
131
-			if ( false !== $blog )
131
+			if (false !== $blog)
132 132
 				return $blog;
133
-			if ( substr( $fields['domain'], 0, 4 ) == 'www.' ) {
134
-				$nowww = substr( $fields['domain'], 4 );
135
-				$blog = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM $wpdb->blogs WHERE domain IN (%s,%s) AND path = %s ORDER BY CHAR_LENGTH(domain) DESC", $nowww, $fields['domain'], $fields['path'] ) );
133
+			if (substr($fields['domain'], 0, 4) == 'www.') {
134
+				$nowww = substr($fields['domain'], 4);
135
+				$blog = $wpdb->get_row($wpdb->prepare("SELECT * FROM $wpdb->blogs WHERE domain IN (%s,%s) AND path = %s ORDER BY CHAR_LENGTH(domain) DESC", $nowww, $fields['domain'], $fields['path']));
136 136
 			} else {
137
-				$blog = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM $wpdb->blogs WHERE domain = %s AND path = %s", $fields['domain'], $fields['path'] ) );
137
+				$blog = $wpdb->get_row($wpdb->prepare("SELECT * FROM $wpdb->blogs WHERE domain = %s AND path = %s", $fields['domain'], $fields['path']));
138 138
 			}
139
-			if ( $blog ) {
140
-				wp_cache_set($blog->blog_id . 'short', $blog, 'blog-details');
139
+			if ($blog) {
140
+				wp_cache_set($blog->blog_id.'short', $blog, 'blog-details');
141 141
 				$blog_id = $blog->blog_id;
142 142
 			} else {
143 143
 				return false;
144 144
 			}
145
-		} elseif ( isset($fields['domain']) && is_subdomain_install() ) {
146
-			$key = md5( $fields['domain'] );
145
+		} elseif (isset($fields['domain']) && is_subdomain_install()) {
146
+			$key = md5($fields['domain']);
147 147
 			$blog = wp_cache_get($key, 'blog-lookup');
148
-			if ( false !== $blog )
148
+			if (false !== $blog)
149 149
 				return $blog;
150
-			if ( substr( $fields['domain'], 0, 4 ) == 'www.' ) {
151
-				$nowww = substr( $fields['domain'], 4 );
152
-				$blog = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM $wpdb->blogs WHERE domain IN (%s,%s) ORDER BY CHAR_LENGTH(domain) DESC", $nowww, $fields['domain'] ) );
150
+			if (substr($fields['domain'], 0, 4) == 'www.') {
151
+				$nowww = substr($fields['domain'], 4);
152
+				$blog = $wpdb->get_row($wpdb->prepare("SELECT * FROM $wpdb->blogs WHERE domain IN (%s,%s) ORDER BY CHAR_LENGTH(domain) DESC", $nowww, $fields['domain']));
153 153
 			} else {
154
-				$blog = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM $wpdb->blogs WHERE domain = %s", $fields['domain'] ) );
154
+				$blog = $wpdb->get_row($wpdb->prepare("SELECT * FROM $wpdb->blogs WHERE domain = %s", $fields['domain']));
155 155
 			}
156
-			if ( $blog ) {
157
-				wp_cache_set($blog->blog_id . 'short', $blog, 'blog-details');
156
+			if ($blog) {
157
+				wp_cache_set($blog->blog_id.'short', $blog, 'blog-details');
158 158
 				$blog_id = $blog->blog_id;
159 159
 			} else {
160 160
 				return false;
@@ -163,10 +163,10 @@  discard block
 block discarded – undo
163 163
 			return false;
164 164
 		}
165 165
 	} else {
166
-		if ( ! $fields )
166
+		if ( ! $fields)
167 167
 			$blog_id = get_current_blog_id();
168
-		elseif ( ! is_numeric( $fields ) )
169
-			$blog_id = get_id_from_blogname( $fields );
168
+		elseif ( ! is_numeric($fields))
169
+			$blog_id = get_id_from_blogname($fields);
170 170
 		else
171 171
 			$blog_id = $fields;
172 172
 	}
@@ -174,15 +174,15 @@  discard block
 block discarded – undo
174 174
 	$blog_id = (int) $blog_id;
175 175
 
176 176
 	$all = $get_all == true ? '' : 'short';
177
-	$details = wp_cache_get( $blog_id . $all, 'blog-details' );
177
+	$details = wp_cache_get($blog_id.$all, 'blog-details');
178 178
 
179
-	if ( $details ) {
180
-		if ( ! is_object( $details ) ) {
181
-			if ( $details == -1 ) {
179
+	if ($details) {
180
+		if ( ! is_object($details)) {
181
+			if ($details == -1) {
182 182
 				return false;
183 183
 			} else {
184 184
 				// Clear old pre-serialized objects. Cache clients do better with that.
185
-				wp_cache_delete( $blog_id . $all, 'blog-details' );
185
+				wp_cache_delete($blog_id.$all, 'blog-details');
186 186
 				unset($details);
187 187
 			}
188 188
 		} else {
@@ -191,18 +191,18 @@  discard block
 block discarded – undo
191 191
 	}
192 192
 
193 193
 	// Try the other cache.
194
-	if ( $get_all ) {
195
-		$details = wp_cache_get( $blog_id . 'short', 'blog-details' );
194
+	if ($get_all) {
195
+		$details = wp_cache_get($blog_id.'short', 'blog-details');
196 196
 	} else {
197
-		$details = wp_cache_get( $blog_id, 'blog-details' );
197
+		$details = wp_cache_get($blog_id, 'blog-details');
198 198
 		// If short was requested and full cache is set, we can return.
199
-		if ( $details ) {
200
-			if ( ! is_object( $details ) ) {
201
-				if ( $details == -1 ) {
199
+		if ($details) {
200
+			if ( ! is_object($details)) {
201
+				if ($details == -1) {
202 202
 					return false;
203 203
 				} else {
204 204
 					// Clear old pre-serialized objects. Cache clients do better with that.
205
-					wp_cache_delete( $blog_id, 'blog-details' );
205
+					wp_cache_delete($blog_id, 'blog-details');
206 206
 					unset($details);
207 207
 				}
208 208
 			} else {
@@ -211,29 +211,29 @@  discard block
 block discarded – undo
211 211
 		}
212 212
 	}
213 213
 
214
-	if ( empty($details) ) {
215
-		$details = WP_Site::get_instance( $blog_id );
216
-		if ( ! $details ) {
214
+	if (empty($details)) {
215
+		$details = WP_Site::get_instance($blog_id);
216
+		if ( ! $details) {
217 217
 			// Set the full cache.
218
-			wp_cache_set( $blog_id, -1, 'blog-details' );
218
+			wp_cache_set($blog_id, -1, 'blog-details');
219 219
 			return false;
220 220
 		}
221 221
 	}
222 222
 
223
-	if ( ! $details instanceof WP_Site ) {
224
-		$details = new WP_Site( $details );
223
+	if ( ! $details instanceof WP_Site) {
224
+		$details = new WP_Site($details);
225 225
 	}
226 226
 
227
-	if ( ! $get_all ) {
228
-		wp_cache_set( $blog_id . $all, $details, 'blog-details' );
227
+	if ( ! $get_all) {
228
+		wp_cache_set($blog_id.$all, $details, 'blog-details');
229 229
 		return $details;
230 230
 	}
231 231
 
232
-	switch_to_blog( $blog_id );
233
-	$details->blogname   = get_option( 'blogname' );
234
-	$details->siteurl    = get_option( 'siteurl' );
235
-	$details->post_count = get_option( 'post_count' );
236
-	$details->home       = get_option( 'home' );
232
+	switch_to_blog($blog_id);
233
+	$details->blogname   = get_option('blogname');
234
+	$details->siteurl    = get_option('siteurl');
235
+	$details->post_count = get_option('post_count');
236
+	$details->home       = get_option('home');
237 237
 	restore_current_blog();
238 238
 
239 239
 	/**
@@ -244,12 +244,12 @@  discard block
 block discarded – undo
244 244
 	 *
245 245
 	 * @param object $details The blog details.
246 246
 	 */
247
-	$details = apply_filters_deprecated( 'blog_details', array( $details ), '4.7.0', 'site_details' );
247
+	$details = apply_filters_deprecated('blog_details', array($details), '4.7.0', 'site_details');
248 248
 
249
-	wp_cache_set( $blog_id . $all, $details, 'blog-details' );
249
+	wp_cache_set($blog_id.$all, $details, 'blog-details');
250 250
 
251
-	$key = md5( $details->domain . $details->path );
252
-	wp_cache_set( $key, $details, 'blog-lookup' );
251
+	$key = md5($details->domain.$details->path);
252
+	wp_cache_set($key, $details, 'blog-lookup');
253 253
 
254 254
 	return $details;
255 255
 }
@@ -261,14 +261,14 @@  discard block
 block discarded – undo
261 261
  *
262 262
  * @param int $blog_id Optional. Blog ID. Defaults to current blog.
263 263
  */
264
-function refresh_blog_details( $blog_id = 0 ) {
264
+function refresh_blog_details($blog_id = 0) {
265 265
 	$blog_id = (int) $blog_id;
266
-	if ( ! $blog_id ) {
266
+	if ( ! $blog_id) {
267 267
 		$blog_id = get_current_blog_id();
268 268
 	}
269 269
 
270
-	$details = get_site( $blog_id );
271
-	if ( ! $details ) {
270
+	$details = get_site($blog_id);
271
+	if ( ! $details) {
272 272
 		// Make sure clean_blog_cache() gets the blog ID
273 273
 		// when the blog has been previously cached as
274 274
 		// non-existent.
@@ -279,7 +279,7 @@  discard block
 block discarded – undo
279 279
 		);
280 280
 	}
281 281
 
282
-	clean_blog_cache( $details );
282
+	clean_blog_cache($details);
283 283
 
284 284
 	/**
285 285
 	 * Fires after the blog details cache is cleared.
@@ -288,7 +288,7 @@  discard block
 block discarded – undo
288 288
 	 *
289 289
 	 * @param int $blog_id Blog ID.
290 290
 	 */
291
-	do_action( 'refresh_blog_details', $blog_id );
291
+	do_action('refresh_blog_details', $blog_id);
292 292
 }
293 293
 
294 294
 /**
@@ -302,17 +302,17 @@  discard block
 block discarded – undo
302 302
  * @param array $details Array of details keyed by blogs table field names.
303 303
  * @return bool True if update succeeds, false otherwise.
304 304
  */
305
-function update_blog_details( $blog_id, $details = array() ) {
305
+function update_blog_details($blog_id, $details = array()) {
306 306
 	global $wpdb;
307 307
 
308
-	if ( empty($details) )
308
+	if (empty($details))
309 309
 		return false;
310 310
 
311
-	if ( is_object($details) )
311
+	if (is_object($details))
312 312
 		$details = get_object_vars($details);
313 313
 
314
-	$current_details = get_site( $blog_id );
315
-	if ( empty($current_details) )
314
+	$current_details = get_site($blog_id);
315
+	if (empty($current_details))
316 316
 		return false;
317 317
 
318 318
 	$current_details = get_object_vars($current_details);
@@ -321,23 +321,23 @@  discard block
 block discarded – undo
321 321
 	$details['last_updated'] = current_time('mysql', true);
322 322
 
323 323
 	$update_details = array();
324
-	$fields = array( 'site_id', 'domain', 'path', 'registered', 'last_updated', 'public', 'archived', 'mature', 'spam', 'deleted', 'lang_id');
325
-	foreach ( array_intersect( array_keys( $details ), $fields ) as $field ) {
326
-		if ( 'path' === $field ) {
327
-			$details[ $field ] = trailingslashit( '/' . trim( $details[ $field ], '/' ) );
324
+	$fields = array('site_id', 'domain', 'path', 'registered', 'last_updated', 'public', 'archived', 'mature', 'spam', 'deleted', 'lang_id');
325
+	foreach (array_intersect(array_keys($details), $fields) as $field) {
326
+		if ('path' === $field) {
327
+			$details[$field] = trailingslashit('/'.trim($details[$field], '/'));
328 328
 		}
329 329
 
330
-		$update_details[ $field ] = $details[ $field ];
330
+		$update_details[$field] = $details[$field];
331 331
 	}
332 332
 
333
-	$result = $wpdb->update( $wpdb->blogs, $update_details, array('blog_id' => $blog_id) );
333
+	$result = $wpdb->update($wpdb->blogs, $update_details, array('blog_id' => $blog_id));
334 334
 
335
-	if ( false === $result )
335
+	if (false === $result)
336 336
 		return false;
337 337
 
338 338
 	// If spam status changed, issue actions.
339
-	if ( $details['spam'] != $current_details['spam'] ) {
340
-		if ( $details['spam'] == 1 ) {
339
+	if ($details['spam'] != $current_details['spam']) {
340
+		if ($details['spam'] == 1) {
341 341
 			/**
342 342
 			 * Fires when the 'spam' status is added to a blog.
343 343
 			 *
@@ -345,7 +345,7 @@  discard block
 block discarded – undo
345 345
 			 *
346 346
 			 * @param int $blog_id Blog ID.
347 347
 			 */
348
-			do_action( 'make_spam_blog', $blog_id );
348
+			do_action('make_spam_blog', $blog_id);
349 349
 		} else {
350 350
 			/**
351 351
 			 * Fires when the 'spam' status is removed from a blog.
@@ -354,13 +354,13 @@  discard block
 block discarded – undo
354 354
 			 *
355 355
 			 * @param int $blog_id Blog ID.
356 356
 			 */
357
-			do_action( 'make_ham_blog', $blog_id );
357
+			do_action('make_ham_blog', $blog_id);
358 358
 		}
359 359
 	}
360 360
 
361 361
 	// If mature status changed, issue actions.
362
-	if ( $details['mature'] != $current_details['mature'] ) {
363
-		if ( $details['mature'] == 1 ) {
362
+	if ($details['mature'] != $current_details['mature']) {
363
+		if ($details['mature'] == 1) {
364 364
 			/**
365 365
 			 * Fires when the 'mature' status is added to a blog.
366 366
 			 *
@@ -368,7 +368,7 @@  discard block
 block discarded – undo
368 368
 			 *
369 369
 			 * @param int $blog_id Blog ID.
370 370
 			 */
371
-			do_action( 'mature_blog', $blog_id );
371
+			do_action('mature_blog', $blog_id);
372 372
 		} else {
373 373
 			/**
374 374
 			 * Fires when the 'mature' status is removed from a blog.
@@ -377,13 +377,13 @@  discard block
 block discarded – undo
377 377
 			 *
378 378
 			 * @param int $blog_id Blog ID.
379 379
 			 */
380
-			do_action( 'unmature_blog', $blog_id );
380
+			do_action('unmature_blog', $blog_id);
381 381
 		}
382 382
 	}
383 383
 
384 384
 	// If archived status changed, issue actions.
385
-	if ( $details['archived'] != $current_details['archived'] ) {
386
-		if ( $details['archived'] == 1 ) {
385
+	if ($details['archived'] != $current_details['archived']) {
386
+		if ($details['archived'] == 1) {
387 387
 			/**
388 388
 			 * Fires when the 'archived' status is added to a blog.
389 389
 			 *
@@ -391,7 +391,7 @@  discard block
 block discarded – undo
391 391
 			 *
392 392
 			 * @param int $blog_id Blog ID.
393 393
 			 */
394
-			do_action( 'archive_blog', $blog_id );
394
+			do_action('archive_blog', $blog_id);
395 395
 		} else {
396 396
 			/**
397 397
 			 * Fires when the 'archived' status is removed from a blog.
@@ -400,13 +400,13 @@  discard block
 block discarded – undo
400 400
 			 *
401 401
 			 * @param int $blog_id Blog ID.
402 402
 			 */
403
-			do_action( 'unarchive_blog', $blog_id );
403
+			do_action('unarchive_blog', $blog_id);
404 404
 		}
405 405
 	}
406 406
 
407 407
 	// If deleted status changed, issue actions.
408
-	if ( $details['deleted'] != $current_details['deleted'] ) {
409
-		if ( $details['deleted'] == 1 ) {
408
+	if ($details['deleted'] != $current_details['deleted']) {
409
+		if ($details['deleted'] == 1) {
410 410
 			/**
411 411
 			 * Fires when the 'deleted' status is added to a blog.
412 412
 			 *
@@ -414,7 +414,7 @@  discard block
 block discarded – undo
414 414
 			 *
415 415
 			 * @param int $blog_id Blog ID.
416 416
 			 */
417
-			do_action( 'make_delete_blog', $blog_id );
417
+			do_action('make_delete_blog', $blog_id);
418 418
 		} else {
419 419
 			/**
420 420
 			 * Fires when the 'deleted' status is removed from a blog.
@@ -423,13 +423,13 @@  discard block
 block discarded – undo
423 423
 			 *
424 424
 			 * @param int $blog_id Blog ID.
425 425
 			 */
426
-			do_action( 'make_undelete_blog', $blog_id );
426
+			do_action('make_undelete_blog', $blog_id);
427 427
 		}
428 428
 	}
429 429
 
430
-	if ( isset( $details['public'] ) ) {
431
-		switch_to_blog( $blog_id );
432
-		update_option( 'blog_public', $details['public'] );
430
+	if (isset($details['public'])) {
431
+		switch_to_blog($blog_id);
432
+		update_option('blog_public', $details['public']);
433 433
 		restore_current_blog();
434 434
 	}
435 435
 
@@ -447,24 +447,24 @@  discard block
 block discarded – undo
447 447
  *
448 448
  * @param WP_Site $blog The site object to be cleared from cache.
449 449
  */
450
-function clean_blog_cache( $blog ) {
450
+function clean_blog_cache($blog) {
451 451
 	global $_wp_suspend_cache_invalidation;
452 452
 
453
-	if ( ! empty( $_wp_suspend_cache_invalidation ) ) {
453
+	if ( ! empty($_wp_suspend_cache_invalidation)) {
454 454
 		return;
455 455
 	}
456 456
 
457 457
 	$blog_id = $blog->blog_id;
458
-	$domain_path_key = md5( $blog->domain . $blog->path );
458
+	$domain_path_key = md5($blog->domain.$blog->path);
459 459
 
460
-	wp_cache_delete( $blog_id, 'sites' );
461
-	wp_cache_delete( $blog_id, 'site-details' );
462
-	wp_cache_delete( $blog_id, 'blog-details' );
463
-	wp_cache_delete( $blog_id . 'short' , 'blog-details' );
464
-	wp_cache_delete( $domain_path_key, 'blog-lookup' );
465
-	wp_cache_delete( $domain_path_key, 'blog-id-cache' );
466
-	wp_cache_delete( 'current_blog_' . $blog->domain, 'site-options' );
467
-	wp_cache_delete( 'current_blog_' . $blog->domain . $blog->path, 'site-options' );
460
+	wp_cache_delete($blog_id, 'sites');
461
+	wp_cache_delete($blog_id, 'site-details');
462
+	wp_cache_delete($blog_id, 'blog-details');
463
+	wp_cache_delete($blog_id.'short', 'blog-details');
464
+	wp_cache_delete($domain_path_key, 'blog-lookup');
465
+	wp_cache_delete($domain_path_key, 'blog-id-cache');
466
+	wp_cache_delete('current_blog_'.$blog->domain, 'site-options');
467
+	wp_cache_delete('current_blog_'.$blog->domain.$blog->path, 'site-options');
468 468
 
469 469
 	/**
470 470
 	 * Fires immediately after a site has been removed from the object cache.
@@ -475,9 +475,9 @@  discard block
 block discarded – undo
475 475
 	 * @param WP_Site $blog            Site object.
476 476
 	 * @param string  $domain_path_key md5 hash of domain and path.
477 477
 	 */
478
-	do_action( 'clean_site_cache', $blog_id, $blog, $domain_path_key );
478
+	do_action('clean_site_cache', $blog_id, $blog, $domain_path_key);
479 479
 
480
-	wp_cache_set( 'last_changed', microtime(), 'sites' );
480
+	wp_cache_set('last_changed', microtime(), 'sites');
481 481
 }
482 482
 
483 483
 /**
@@ -487,14 +487,14 @@  discard block
 block discarded – undo
487 487
  *
488 488
  * @param int $site_id Optional. Site ID. Default is the current site ID.
489 489
  */
490
-function clean_site_details_cache( $site_id = 0 ) {
490
+function clean_site_details_cache($site_id = 0) {
491 491
 	$site_id = (int) $site_id;
492
-	if ( ! $site_id ) {
492
+	if ( ! $site_id) {
493 493
 		$site_id = get_current_blog_id();
494 494
 	}
495 495
 
496
-	wp_cache_delete( $site_id, 'site-details' );
497
-	wp_cache_delete( $site_id, 'blog-details' );
496
+	wp_cache_delete($site_id, 'site-details');
497
+	wp_cache_delete($site_id, 'blog-details');
498 498
 }
499 499
 
500 500
 /**
@@ -508,20 +508,20 @@  discard block
 block discarded – undo
508 508
  * @param WP_Site|int|null $site Optional. Site to retrieve. Default is the current site.
509 509
  * @return WP_Site|null The site object or null if not found.
510 510
  */
511
-function get_site( $site = null ) {
512
-	if ( empty( $site ) ) {
511
+function get_site($site = null) {
512
+	if (empty($site)) {
513 513
 		$site = get_current_blog_id();
514 514
 	}
515 515
 
516
-	if ( $site instanceof WP_Site ) {
516
+	if ($site instanceof WP_Site) {
517 517
 		$_site = $site;
518
-	} elseif ( is_object( $site ) ) {
519
-		$_site = new WP_Site( $site );
518
+	} elseif (is_object($site)) {
519
+		$_site = new WP_Site($site);
520 520
 	} else {
521
-		$_site = WP_Site::get_instance( $site );
521
+		$_site = WP_Site::get_instance($site);
522 522
 	}
523 523
 
524
-	if ( ! $_site ) {
524
+	if ( ! $_site) {
525 525
 		return null;
526 526
 	}
527 527
 
@@ -532,7 +532,7 @@  discard block
 block discarded – undo
532 532
 	 *
533 533
 	 * @param WP_Site $_site Site data.
534 534
 	 */
535
-	$_site = apply_filters( 'get_site', $_site );
535
+	$_site = apply_filters('get_site', $_site);
536 536
 
537 537
 	return $_site;
538 538
 }
@@ -548,14 +548,14 @@  discard block
 block discarded – undo
548 548
  *
549 549
  * @param array $ids ID list.
550 550
  */
551
-function _prime_site_caches( $ids ) {
551
+function _prime_site_caches($ids) {
552 552
 	global $wpdb;
553 553
 
554
-	$non_cached_ids = _get_non_cached_ids( $ids, 'sites' );
555
-	if ( ! empty( $non_cached_ids ) ) {
556
-		$fresh_sites = $wpdb->get_results( sprintf( "SELECT * FROM $wpdb->blogs WHERE blog_id IN (%s)", join( ",", array_map( 'intval', $non_cached_ids ) ) ) );
554
+	$non_cached_ids = _get_non_cached_ids($ids, 'sites');
555
+	if ( ! empty($non_cached_ids)) {
556
+		$fresh_sites = $wpdb->get_results(sprintf("SELECT * FROM $wpdb->blogs WHERE blog_id IN (%s)", join(",", array_map('intval', $non_cached_ids))));
557 557
 
558
-		update_site_cache( $fresh_sites );
558
+		update_site_cache($fresh_sites);
559 559
 	}
560 560
 }
561 561
 
@@ -566,14 +566,14 @@  discard block
 block discarded – undo
566 566
  *
567 567
  * @param array $sites Array of site objects.
568 568
  */
569
-function update_site_cache( $sites ) {
570
-	if ( ! $sites ) {
569
+function update_site_cache($sites) {
570
+	if ( ! $sites) {
571 571
 		return;
572 572
 	}
573 573
 
574
-	foreach ( $sites as $site ) {
575
-		wp_cache_add( $site->blog_id, $site, 'sites' );
576
-		wp_cache_add( $site->blog_id . 'short', $site, 'blog-details' );
574
+	foreach ($sites as $site) {
575
+		wp_cache_add($site->blog_id, $site, 'sites');
576
+		wp_cache_add($site->blog_id.'short', $site, 'blog-details');
577 577
 	}
578 578
 }
579 579
 
@@ -632,10 +632,10 @@  discard block
 block discarded – undo
632 632
  * }
633 633
  * @return array List of sites.
634 634
  */
635
-function get_sites( $args = array() ) {
635
+function get_sites($args = array()) {
636 636
 	$query = new WP_Site_Query();
637 637
 
638
-	return $query->query( $args );
638
+	return $query->query($args);
639 639
 }
640 640
 
641 641
 /**
@@ -655,17 +655,17 @@  discard block
 block discarded – undo
655 655
  * @param mixed  $default Optional. Default value to return if the option does not exist.
656 656
  * @return mixed Value set for the option.
657 657
  */
658
-function get_blog_option( $id, $option, $default = false ) {
658
+function get_blog_option($id, $option, $default = false) {
659 659
 	$id = (int) $id;
660 660
 
661
-	if ( empty( $id ) )
661
+	if (empty($id))
662 662
 		$id = get_current_blog_id();
663 663
 
664
-	if ( get_current_blog_id() == $id )
665
-		return get_option( $option, $default );
664
+	if (get_current_blog_id() == $id)
665
+		return get_option($option, $default);
666 666
 
667
-	switch_to_blog( $id );
668
-	$value = get_option( $option, $default );
667
+	switch_to_blog($id);
668
+	$value = get_option($option, $default);
669 669
 	restore_current_blog();
670 670
 
671 671
 	/**
@@ -678,7 +678,7 @@  discard block
 block discarded – undo
678 678
 	 * @param string  $value The option value.
679 679
 	 * @param int     $id    Blog ID.
680 680
 	 */
681
-	return apply_filters( "blog_option_{$option}", $value, $id );
681
+	return apply_filters("blog_option_{$option}", $value, $id);
682 682
 }
683 683
 
684 684
 /**
@@ -700,17 +700,17 @@  discard block
 block discarded – undo
700 700
  * @param mixed  $value  Optional. Option value, can be anything. Expected to not be SQL-escaped.
701 701
  * @return bool False if option was not added and true if option was added.
702 702
  */
703
-function add_blog_option( $id, $option, $value ) {
703
+function add_blog_option($id, $option, $value) {
704 704
 	$id = (int) $id;
705 705
 
706
-	if ( empty( $id ) )
706
+	if (empty($id))
707 707
 		$id = get_current_blog_id();
708 708
 
709
-	if ( get_current_blog_id() == $id )
710
-		return add_option( $option, $value );
709
+	if (get_current_blog_id() == $id)
710
+		return add_option($option, $value);
711 711
 
712
-	switch_to_blog( $id );
713
-	$return = add_option( $option, $value );
712
+	switch_to_blog($id);
713
+	$return = add_option($option, $value);
714 714
 	restore_current_blog();
715 715
 
716 716
 	return $return;
@@ -725,17 +725,17 @@  discard block
 block discarded – undo
725 725
  * @param string $option Name of option to remove. Expected to not be SQL-escaped.
726 726
  * @return bool True, if option is successfully deleted. False on failure.
727 727
  */
728
-function delete_blog_option( $id, $option ) {
728
+function delete_blog_option($id, $option) {
729 729
 	$id = (int) $id;
730 730
 
731
-	if ( empty( $id ) )
731
+	if (empty($id))
732 732
 		$id = get_current_blog_id();
733 733
 
734
-	if ( get_current_blog_id() == $id )
735
-		return delete_option( $option );
734
+	if (get_current_blog_id() == $id)
735
+		return delete_option($option);
736 736
 
737
-	switch_to_blog( $id );
738
-	$return = delete_option( $option );
737
+	switch_to_blog($id);
738
+	$return = delete_option($option);
739 739
 	restore_current_blog();
740 740
 
741 741
 	return $return;
@@ -752,17 +752,17 @@  discard block
 block discarded – undo
752 752
  * @param mixed  $deprecated Not used.
753 753
  * @return bool True on success, false on failure.
754 754
  */
755
-function update_blog_option( $id, $option, $value, $deprecated = null ) {
755
+function update_blog_option($id, $option, $value, $deprecated = null) {
756 756
 	$id = (int) $id;
757 757
 
758
-	if ( null !== $deprecated  )
759
-		_deprecated_argument( __FUNCTION__, '3.1.0' );
758
+	if (null !== $deprecated)
759
+		_deprecated_argument(__FUNCTION__, '3.1.0');
760 760
 
761
-	if ( get_current_blog_id() == $id )
762
-		return update_option( $option, $value );
761
+	if (get_current_blog_id() == $id)
762
+		return update_option($option, $value);
763 763
 
764
-	switch_to_blog( $id );
765
-	$return = update_option( $option, $value );
764
+	switch_to_blog($id);
765
+	$return = update_option($option, $value);
766 766
 	restore_current_blog();
767 767
 
768 768
 	return $return;
@@ -792,11 +792,11 @@  discard block
 block discarded – undo
792 792
  * @param bool $deprecated Deprecated argument
793 793
  * @return true Always returns True.
794 794
  */
795
-function switch_to_blog( $new_blog, $deprecated = null ) {
795
+function switch_to_blog($new_blog, $deprecated = null) {
796 796
 	global $wpdb, $wp_roles;
797 797
 
798 798
 	$blog_id = get_current_blog_id();
799
-	if ( empty( $new_blog ) ) {
799
+	if (empty($new_blog)) {
800 800
 		$new_blog = $blog_id;
801 801
 	}
802 802
 
@@ -807,7 +807,7 @@  discard block
 block discarded – undo
807 807
 	 * set the right vars, do the associated actions, but skip
808 808
 	 * the extra unnecessary work
809 809
 	 */
810
-	if ( $new_blog == $blog_id ) {
810
+	if ($new_blog == $blog_id) {
811 811
 		/**
812 812
 		 * Fires when the blog is switched.
813 813
 		 *
@@ -816,46 +816,46 @@  discard block
 block discarded – undo
816 816
 		 * @param int $new_blog New blog ID.
817 817
 		 * @param int $new_blog Blog ID.
818 818
 		 */
819
-		do_action( 'switch_blog', $new_blog, $new_blog );
819
+		do_action('switch_blog', $new_blog, $new_blog);
820 820
 		$GLOBALS['switched'] = true;
821 821
 		return true;
822 822
 	}
823 823
 
824
-	$wpdb->set_blog_id( $new_blog );
824
+	$wpdb->set_blog_id($new_blog);
825 825
 	$GLOBALS['table_prefix'] = $wpdb->get_blog_prefix();
826 826
 	$prev_blog_id = $blog_id;
827 827
 	$GLOBALS['blog_id'] = $new_blog;
828 828
 
829
-	if ( function_exists( 'wp_cache_switch_to_blog' ) ) {
830
-		wp_cache_switch_to_blog( $new_blog );
829
+	if (function_exists('wp_cache_switch_to_blog')) {
830
+		wp_cache_switch_to_blog($new_blog);
831 831
 	} else {
832 832
 		global $wp_object_cache;
833 833
 
834
-		if ( is_object( $wp_object_cache ) && isset( $wp_object_cache->global_groups ) ) {
834
+		if (is_object($wp_object_cache) && isset($wp_object_cache->global_groups)) {
835 835
 			$global_groups = $wp_object_cache->global_groups;
836 836
 		} else {
837 837
 			$global_groups = false;
838 838
 		}
839 839
 		wp_cache_init();
840 840
 
841
-		if ( function_exists( 'wp_cache_add_global_groups' ) ) {
842
-			if ( is_array( $global_groups ) ) {
843
-				wp_cache_add_global_groups( $global_groups );
841
+		if (function_exists('wp_cache_add_global_groups')) {
842
+			if (is_array($global_groups)) {
843
+				wp_cache_add_global_groups($global_groups);
844 844
 			} else {
845
-				wp_cache_add_global_groups( array( 'users', 'userlogins', 'usermeta', 'user_meta', 'useremail', 'userslugs', 'site-transient', 'site-options', 'blog-lookup', 'blog-details', 'rss', 'global-posts', 'blog-id-cache', 'networks', 'sites', 'site-details' ) );
845
+				wp_cache_add_global_groups(array('users', 'userlogins', 'usermeta', 'user_meta', 'useremail', 'userslugs', 'site-transient', 'site-options', 'blog-lookup', 'blog-details', 'rss', 'global-posts', 'blog-id-cache', 'networks', 'sites', 'site-details'));
846 846
 			}
847
-			wp_cache_add_non_persistent_groups( array( 'counts', 'plugins' ) );
847
+			wp_cache_add_non_persistent_groups(array('counts', 'plugins'));
848 848
 		}
849 849
 	}
850 850
 
851
-	if ( did_action( 'init' ) ) {
851
+	if (did_action('init')) {
852 852
 		$wp_roles = new WP_Roles();
853 853
 		$current_user = wp_get_current_user();
854
-		$current_user->for_blog( $new_blog );
854
+		$current_user->for_blog($new_blog);
855 855
 	}
856 856
 
857 857
 	/** This filter is documented in wp-includes/ms-blogs.php */
858
-	do_action( 'switch_blog', $new_blog, $prev_blog_id );
858
+	do_action('switch_blog', $new_blog, $prev_blog_id);
859 859
 	$GLOBALS['switched'] = true;
860 860
 
861 861
 	return true;
@@ -879,32 +879,32 @@  discard block
 block discarded – undo
879 879
 function restore_current_blog() {
880 880
 	global $wpdb, $wp_roles;
881 881
 
882
-	if ( empty( $GLOBALS['_wp_switched_stack'] ) ) {
882
+	if (empty($GLOBALS['_wp_switched_stack'])) {
883 883
 		return false;
884 884
 	}
885 885
 
886
-	$blog = array_pop( $GLOBALS['_wp_switched_stack'] );
886
+	$blog = array_pop($GLOBALS['_wp_switched_stack']);
887 887
 	$blog_id = get_current_blog_id();
888 888
 
889
-	if ( $blog_id == $blog ) {
889
+	if ($blog_id == $blog) {
890 890
 		/** This filter is documented in wp-includes/ms-blogs.php */
891
-		do_action( 'switch_blog', $blog, $blog );
891
+		do_action('switch_blog', $blog, $blog);
892 892
 		// If we still have items in the switched stack, consider ourselves still 'switched'
893
-		$GLOBALS['switched'] = ! empty( $GLOBALS['_wp_switched_stack'] );
893
+		$GLOBALS['switched'] = ! empty($GLOBALS['_wp_switched_stack']);
894 894
 		return true;
895 895
 	}
896 896
 
897
-	$wpdb->set_blog_id( $blog );
897
+	$wpdb->set_blog_id($blog);
898 898
 	$prev_blog_id = $blog_id;
899 899
 	$GLOBALS['blog_id'] = $blog;
900 900
 	$GLOBALS['table_prefix'] = $wpdb->get_blog_prefix();
901 901
 
902
-	if ( function_exists( 'wp_cache_switch_to_blog' ) ) {
903
-		wp_cache_switch_to_blog( $blog );
902
+	if (function_exists('wp_cache_switch_to_blog')) {
903
+		wp_cache_switch_to_blog($blog);
904 904
 	} else {
905 905
 		global $wp_object_cache;
906 906
 
907
-		if ( is_object( $wp_object_cache ) && isset( $wp_object_cache->global_groups ) ) {
907
+		if (is_object($wp_object_cache) && isset($wp_object_cache->global_groups)) {
908 908
 			$global_groups = $wp_object_cache->global_groups;
909 909
 		} else {
910 910
 			$global_groups = false;
@@ -912,27 +912,27 @@  discard block
 block discarded – undo
912 912
 
913 913
 		wp_cache_init();
914 914
 
915
-		if ( function_exists( 'wp_cache_add_global_groups' ) ) {
916
-			if ( is_array( $global_groups ) ) {
917
-				wp_cache_add_global_groups( $global_groups );
915
+		if (function_exists('wp_cache_add_global_groups')) {
916
+			if (is_array($global_groups)) {
917
+				wp_cache_add_global_groups($global_groups);
918 918
 			} else {
919
-				wp_cache_add_global_groups( array( 'users', 'userlogins', 'usermeta', 'user_meta', 'useremail', 'userslugs', 'site-transient', 'site-options', 'blog-lookup', 'blog-details', 'rss', 'global-posts', 'blog-id-cache', 'networks', 'sites', 'site-details' ) );
919
+				wp_cache_add_global_groups(array('users', 'userlogins', 'usermeta', 'user_meta', 'useremail', 'userslugs', 'site-transient', 'site-options', 'blog-lookup', 'blog-details', 'rss', 'global-posts', 'blog-id-cache', 'networks', 'sites', 'site-details'));
920 920
 			}
921
-			wp_cache_add_non_persistent_groups( array( 'counts', 'plugins' ) );
921
+			wp_cache_add_non_persistent_groups(array('counts', 'plugins'));
922 922
 		}
923 923
 	}
924 924
 
925
-	if ( did_action( 'init' ) ) {
925
+	if (did_action('init')) {
926 926
 		$wp_roles = new WP_Roles();
927 927
 		$current_user = wp_get_current_user();
928
-		$current_user->for_blog( $blog );
928
+		$current_user->for_blog($blog);
929 929
 	}
930 930
 
931 931
 	/** This filter is documented in wp-includes/ms-blogs.php */
932
-	do_action( 'switch_blog', $blog, $prev_blog_id );
932
+	do_action('switch_blog', $blog, $prev_blog_id);
933 933
 
934 934
 	// If we still have items in the switched stack, consider ourselves still 'switched'
935
-	$GLOBALS['switched'] = ! empty( $GLOBALS['_wp_switched_stack'] );
935
+	$GLOBALS['switched'] = ! empty($GLOBALS['_wp_switched_stack']);
936 936
 
937 937
 	return true;
938 938
 }
@@ -947,7 +947,7 @@  discard block
 block discarded – undo
947 947
  * @return bool True if switched, false otherwise.
948 948
  */
949 949
 function ms_is_switched() {
950
-	return ! empty( $GLOBALS['_wp_switched_stack'] );
950
+	return ! empty($GLOBALS['_wp_switched_stack']);
951 951
 }
952 952
 
953 953
 /**
@@ -958,7 +958,7 @@  discard block
 block discarded – undo
958 958
  * @param int $id The blog id
959 959
  * @return string Whether the blog is archived or not
960 960
  */
961
-function is_archived( $id ) {
961
+function is_archived($id) {
962 962
 	return get_blog_status($id, 'archived');
963 963
 }
964 964
 
@@ -971,7 +971,7 @@  discard block
 block discarded – undo
971 971
  * @param string $archived The new status
972 972
  * @return string $archived
973 973
  */
974
-function update_archived( $id, $archived ) {
974
+function update_archived($id, $archived) {
975 975
 	update_blog_status($id, 'archived', $archived);
976 976
 	return $archived;
977 977
 }
@@ -989,55 +989,55 @@  discard block
 block discarded – undo
989 989
  * @param null   $deprecated
990 990
  * @return string|false $value
991 991
  */
992
-function update_blog_status( $blog_id, $pref, $value, $deprecated = null ) {
992
+function update_blog_status($blog_id, $pref, $value, $deprecated = null) {
993 993
 	global $wpdb;
994 994
 
995
-	if ( null !== $deprecated  )
996
-		_deprecated_argument( __FUNCTION__, '3.1.0' );
995
+	if (null !== $deprecated)
996
+		_deprecated_argument(__FUNCTION__, '3.1.0');
997 997
 
998
-	if ( ! in_array( $pref, array( 'site_id', 'domain', 'path', 'registered', 'last_updated', 'public', 'archived', 'mature', 'spam', 'deleted', 'lang_id') ) )
998
+	if ( ! in_array($pref, array('site_id', 'domain', 'path', 'registered', 'last_updated', 'public', 'archived', 'mature', 'spam', 'deleted', 'lang_id')))
999 999
 		return $value;
1000 1000
 
1001
-	$result = $wpdb->update( $wpdb->blogs, array($pref => $value, 'last_updated' => current_time('mysql', true)), array('blog_id' => $blog_id) );
1001
+	$result = $wpdb->update($wpdb->blogs, array($pref => $value, 'last_updated' => current_time('mysql', true)), array('blog_id' => $blog_id));
1002 1002
 
1003
-	if ( false === $result )
1003
+	if (false === $result)
1004 1004
 		return false;
1005 1005
 
1006
-	refresh_blog_details( $blog_id );
1006
+	refresh_blog_details($blog_id);
1007 1007
 
1008
-	if ( 'spam' == $pref ) {
1009
-		if ( $value == 1 ) {
1008
+	if ('spam' == $pref) {
1009
+		if ($value == 1) {
1010 1010
 			/** This filter is documented in wp-includes/ms-blogs.php */
1011
-			do_action( 'make_spam_blog', $blog_id );
1011
+			do_action('make_spam_blog', $blog_id);
1012 1012
 		} else {
1013 1013
 			/** This filter is documented in wp-includes/ms-blogs.php */
1014
-			do_action( 'make_ham_blog', $blog_id );
1014
+			do_action('make_ham_blog', $blog_id);
1015 1015
 		}
1016
-	} elseif ( 'mature' == $pref ) {
1017
-		if ( $value == 1 ) {
1016
+	} elseif ('mature' == $pref) {
1017
+		if ($value == 1) {
1018 1018
 			/** This filter is documented in wp-includes/ms-blogs.php */
1019
-			do_action( 'mature_blog', $blog_id );
1019
+			do_action('mature_blog', $blog_id);
1020 1020
 		} else {
1021 1021
 			/** This filter is documented in wp-includes/ms-blogs.php */
1022
-			do_action( 'unmature_blog', $blog_id );
1022
+			do_action('unmature_blog', $blog_id);
1023 1023
 		}
1024
-	} elseif ( 'archived' == $pref ) {
1025
-		if ( $value == 1 ) {
1024
+	} elseif ('archived' == $pref) {
1025
+		if ($value == 1) {
1026 1026
 			/** This filter is documented in wp-includes/ms-blogs.php */
1027
-			do_action( 'archive_blog', $blog_id );
1027
+			do_action('archive_blog', $blog_id);
1028 1028
 		} else {
1029 1029
 			/** This filter is documented in wp-includes/ms-blogs.php */
1030
-			do_action( 'unarchive_blog', $blog_id );
1030
+			do_action('unarchive_blog', $blog_id);
1031 1031
 		}
1032
-	} elseif ( 'deleted' == $pref ) {
1033
-		if ( $value == 1 ) {
1032
+	} elseif ('deleted' == $pref) {
1033
+		if ($value == 1) {
1034 1034
 			/** This filter is documented in wp-includes/ms-blogs.php */
1035
-			do_action( 'make_delete_blog', $blog_id );
1035
+			do_action('make_delete_blog', $blog_id);
1036 1036
 		} else {
1037 1037
 			/** This filter is documented in wp-includes/ms-blogs.php */
1038
-			do_action( 'make_undelete_blog', $blog_id );
1038
+			do_action('make_undelete_blog', $blog_id);
1039 1039
 		}
1040
-	} elseif ( 'public' == $pref ) {
1040
+	} elseif ('public' == $pref) {
1041 1041
 		/**
1042 1042
 		 * Fires after the current blog's 'public' setting is updated.
1043 1043
 		 *
@@ -1046,7 +1046,7 @@  discard block
 block discarded – undo
1046 1046
 		 * @param int    $blog_id Blog ID.
1047 1047
 		 * @param string $value   The value of blog status.
1048 1048
  		 */
1049
-		do_action( 'update_blog_public', $blog_id, $value ); // Moved here from update_blog_public().
1049
+		do_action('update_blog_public', $blog_id, $value); // Moved here from update_blog_public().
1050 1050
 	}
1051 1051
 
1052 1052
 	return $value;
@@ -1063,14 +1063,14 @@  discard block
 block discarded – undo
1063 1063
  * @param string $pref A field name
1064 1064
  * @return bool|string|null $value
1065 1065
  */
1066
-function get_blog_status( $id, $pref ) {
1066
+function get_blog_status($id, $pref) {
1067 1067
 	global $wpdb;
1068 1068
 
1069
-	$details = get_site( $id );
1070
-	if ( $details )
1069
+	$details = get_site($id);
1070
+	if ($details)
1071 1071
 		return $details->$pref;
1072 1072
 
1073
-	return $wpdb->get_var( $wpdb->prepare("SELECT %s FROM {$wpdb->blogs} WHERE blog_id = %d", $pref, $id) );
1073
+	return $wpdb->get_var($wpdb->prepare("SELECT %s FROM {$wpdb->blogs} WHERE blog_id = %d", $pref, $id));
1074 1074
 }
1075 1075
 
1076 1076
 /**
@@ -1085,13 +1085,13 @@  discard block
 block discarded – undo
1085 1085
  * @param int   $quantity   The maximum number of blogs to retrieve. Default is 40.
1086 1086
  * @return array The list of blogs
1087 1087
  */
1088
-function get_last_updated( $deprecated = '', $start = 0, $quantity = 40 ) {
1088
+function get_last_updated($deprecated = '', $start = 0, $quantity = 40) {
1089 1089
 	global $wpdb;
1090 1090
 
1091
-	if ( ! empty( $deprecated ) )
1092
-		_deprecated_argument( __FUNCTION__, 'MU' ); // never used
1091
+	if ( ! empty($deprecated))
1092
+		_deprecated_argument(__FUNCTION__, 'MU'); // never used
1093 1093
 
1094
-	return $wpdb->get_results( $wpdb->prepare("SELECT blog_id, domain, path FROM $wpdb->blogs WHERE site_id = %d AND public = '1' AND archived = '0' AND mature = '0' AND spam = '0' AND deleted = '0' AND last_updated != '0000-00-00 00:00:00' ORDER BY last_updated DESC limit %d, %d", $wpdb->siteid, $start, $quantity ) , ARRAY_A );
1094
+	return $wpdb->get_results($wpdb->prepare("SELECT blog_id, domain, path FROM $wpdb->blogs WHERE site_id = %d AND public = '1' AND archived = '0' AND mature = '0' AND spam = '0' AND deleted = '0' AND last_updated != '0000-00-00 00:00:00' ORDER BY last_updated DESC limit %d, %d", $wpdb->siteid, $start, $quantity), ARRAY_A);
1095 1095
 }
1096 1096
 
1097 1097
 /**
@@ -1103,10 +1103,10 @@  discard block
 block discarded – undo
1103 1103
  *                           for information on accepted arguments. Default empty array.
1104 1104
  * @return int|array List of networks or number of found networks if `$count` argument is true.
1105 1105
  */
1106
-function get_networks( $args = array() ) {
1106
+function get_networks($args = array()) {
1107 1107
 	$query = new WP_Network_Query();
1108 1108
 
1109
-	return $query->query( $args );
1109
+	return $query->query($args);
1110 1110
 }
1111 1111
 
1112 1112
 /**
@@ -1122,21 +1122,21 @@  discard block
 block discarded – undo
1122 1122
  * @param WP_Network|int|null $network Optional. Network to retrieve. Default is the current network.
1123 1123
  * @return WP_Network|null The network object or null if not found.
1124 1124
  */
1125
-function get_network( $network = null ) {
1125
+function get_network($network = null) {
1126 1126
 	global $current_site;
1127
-	if ( empty( $network ) && isset( $current_site ) ) {
1127
+	if (empty($network) && isset($current_site)) {
1128 1128
 		$network = $current_site;
1129 1129
 	}
1130 1130
 
1131
-	if ( $network instanceof WP_Network ) {
1131
+	if ($network instanceof WP_Network) {
1132 1132
 		$_network = $network;
1133
-	} elseif ( is_object( $network ) ) {
1134
-		$_network = new WP_Network( $network );
1133
+	} elseif (is_object($network)) {
1134
+		$_network = new WP_Network($network);
1135 1135
 	} else {
1136
-		$_network = WP_Network::get_instance( $network );
1136
+		$_network = WP_Network::get_instance($network);
1137 1137
 	}
1138 1138
 
1139
-	if ( ! $_network ) {
1139
+	if ( ! $_network) {
1140 1140
 		return null;
1141 1141
 	}
1142 1142
 
@@ -1147,7 +1147,7 @@  discard block
 block discarded – undo
1147 1147
 	 *
1148 1148
 	 * @param WP_Network $_network Network data.
1149 1149
 	 */
1150
-	$_network = apply_filters( 'get_network', $_network );
1150
+	$_network = apply_filters('get_network', $_network);
1151 1151
 
1152 1152
 	return $_network;
1153 1153
 }
@@ -1161,15 +1161,15 @@  discard block
 block discarded – undo
1161 1161
  *
1162 1162
  * @param int|array $ids Network ID or an array of network IDs to remove from cache.
1163 1163
  */
1164
-function clean_network_cache( $ids ) {
1164
+function clean_network_cache($ids) {
1165 1165
 	global $_wp_suspend_cache_invalidation;
1166 1166
 
1167
-	if ( ! empty( $_wp_suspend_cache_invalidation ) ) {
1167
+	if ( ! empty($_wp_suspend_cache_invalidation)) {
1168 1168
 		return;
1169 1169
 	}
1170 1170
 
1171
-	foreach ( (array) $ids as $id ) {
1172
-		wp_cache_delete( $id, 'networks' );
1171
+	foreach ((array) $ids as $id) {
1172
+		wp_cache_delete($id, 'networks');
1173 1173
 
1174 1174
 		/**
1175 1175
 		 * Fires immediately after a network has been removed from the object cache.
@@ -1178,10 +1178,10 @@  discard block
 block discarded – undo
1178 1178
 		 *
1179 1179
 		 * @param int $id Network ID.
1180 1180
 		 */
1181
-		do_action( 'clean_network_cache', $id );
1181
+		do_action('clean_network_cache', $id);
1182 1182
 	}
1183 1183
 
1184
-	wp_cache_set( 'last_changed', microtime(), 'networks' );
1184
+	wp_cache_set('last_changed', microtime(), 'networks');
1185 1185
 }
1186 1186
 
1187 1187
 /**
@@ -1195,9 +1195,9 @@  discard block
 block discarded – undo
1195 1195
  *
1196 1196
  * @param array $networks Array of network row objects.
1197 1197
  */
1198
-function update_network_cache( $networks ) {
1199
-	foreach ( (array) $networks as $network ) {
1200
-		wp_cache_add( $network->id, $network, 'networks' );
1198
+function update_network_cache($networks) {
1199
+	foreach ((array) $networks as $network) {
1200
+		wp_cache_add($network->id, $network, 'networks');
1201 1201
 	}
1202 1202
 }
1203 1203
 
@@ -1212,14 +1212,14 @@  discard block
 block discarded – undo
1212 1212
  *
1213 1213
  * @param array $network_ids Array of network IDs.
1214 1214
  */
1215
-function _prime_network_caches( $network_ids ) {
1215
+function _prime_network_caches($network_ids) {
1216 1216
 	global $wpdb;
1217 1217
 
1218
-	$non_cached_ids = _get_non_cached_ids( $network_ids, 'networks' );
1219
-	if ( !empty( $non_cached_ids ) ) {
1220
-		$fresh_networks = $wpdb->get_results( sprintf( "SELECT $wpdb->site.* FROM $wpdb->site WHERE id IN (%s)", join( ",", array_map( 'intval', $non_cached_ids ) ) ) );
1218
+	$non_cached_ids = _get_non_cached_ids($network_ids, 'networks');
1219
+	if ( ! empty($non_cached_ids)) {
1220
+		$fresh_networks = $wpdb->get_results(sprintf("SELECT $wpdb->site.* FROM $wpdb->site WHERE id IN (%s)", join(",", array_map('intval', $non_cached_ids))));
1221 1221
 
1222
-		update_network_cache( $fresh_networks );
1222
+		update_network_cache($fresh_networks);
1223 1223
 	}
1224 1224
 }
1225 1225
 
@@ -1232,13 +1232,13 @@  discard block
 block discarded – undo
1232 1232
  * @param string $old_status The old post status
1233 1233
  * @param object $post       Post object
1234 1234
  */
1235
-function _update_blog_date_on_post_publish( $new_status, $old_status, $post ) {
1236
-	$post_type_obj = get_post_type_object( $post->post_type );
1237
-	if ( ! $post_type_obj || ! $post_type_obj->public ) {
1235
+function _update_blog_date_on_post_publish($new_status, $old_status, $post) {
1236
+	$post_type_obj = get_post_type_object($post->post_type);
1237
+	if ( ! $post_type_obj || ! $post_type_obj->public) {
1238 1238
 		return;
1239 1239
 	}
1240 1240
 
1241
-	if ( 'publish' != $new_status && 'publish' != $old_status ) {
1241
+	if ('publish' != $new_status && 'publish' != $old_status) {
1242 1242
 		return;
1243 1243
 	}
1244 1244
 
@@ -1254,15 +1254,15 @@  discard block
 block discarded – undo
1254 1254
  *
1255 1255
  * @param int $post_id Post ID
1256 1256
  */
1257
-function _update_blog_date_on_post_delete( $post_id ) {
1258
-	$post = get_post( $post_id );
1257
+function _update_blog_date_on_post_delete($post_id) {
1258
+	$post = get_post($post_id);
1259 1259
 
1260
-	$post_type_obj = get_post_type_object( $post->post_type );
1261
-	if ( ! $post_type_obj || ! $post_type_obj->public ) {
1260
+	$post_type_obj = get_post_type_object($post->post_type);
1261
+	if ( ! $post_type_obj || ! $post_type_obj->public) {
1262 1262
 		return;
1263 1263
 	}
1264 1264
 
1265
-	if ( 'publish' != $post->post_status ) {
1265
+	if ('publish' != $post->post_status) {
1266 1266
 		return;
1267 1267
 	}
1268 1268
 
@@ -1276,10 +1276,10 @@  discard block
 block discarded – undo
1276 1276
  *
1277 1277
  * @param int $post_id Post ID.
1278 1278
  */
1279
-function _update_posts_count_on_delete( $post_id ) {
1280
-	$post = get_post( $post_id );
1279
+function _update_posts_count_on_delete($post_id) {
1280
+	$post = get_post($post_id);
1281 1281
 
1282
-	if ( ! $post || 'publish' !== $post->post_status ) {
1282
+	if ( ! $post || 'publish' !== $post->post_status) {
1283 1283
 		return;
1284 1284
 	}
1285 1285
 
@@ -1294,12 +1294,12 @@  discard block
 block discarded – undo
1294 1294
  * @param string $new_status The status the post is changing to.
1295 1295
  * @param string $old_status The status the post is changing from.
1296 1296
  */
1297
-function _update_posts_count_on_transition_post_status( $new_status, $old_status ) {
1298
-	if ( $new_status === $old_status ) {
1297
+function _update_posts_count_on_transition_post_status($new_status, $old_status) {
1298
+	if ($new_status === $old_status) {
1299 1299
 		return;
1300 1300
 	}
1301 1301
 
1302
-	if ( 'publish' !== $new_status && 'publish' !== $old_status ) {
1302
+	if ('publish' !== $new_status && 'publish' !== $old_status) {
1303 1303
 		return;
1304 1304
 	}
1305 1305
 
Please login to merge, or discard this patch.
src/wp-includes/ms-files.php 2 patches
Braces   +11 added lines, -6 removed lines patch added patch discarded remove patch
@@ -11,8 +11,9 @@  discard block
 block discarded – undo
11 11
 define( 'SHORTINIT', true );
12 12
 require_once( dirname( dirname( __FILE__ ) ) . '/wp-load.php' );
13 13
 
14
-if ( !is_multisite() )
14
+if ( !is_multisite() ) {
15 15
 	die( 'Multisite support not enabled' );
16
+}
16 17
 
17 18
 ms_file_constants();
18 19
 
@@ -30,17 +31,20 @@  discard block
 block discarded – undo
30 31
 }
31 32
 
32 33
 $mime = wp_check_filetype( $file );
33
-if ( false === $mime[ 'type' ] && function_exists( 'mime_content_type' ) )
34
+if ( false === $mime[ 'type' ] && function_exists( 'mime_content_type' ) ) {
34 35
 	$mime[ 'type' ] = mime_content_type( $file );
36
+}
35 37
 
36
-if ( $mime[ 'type' ] )
38
+if ( $mime[ 'type' ] ) {
37 39
 	$mimetype = $mime[ 'type' ];
38
-else
40
+} else {
39 41
 	$mimetype = 'image/' . substr( $file, strrpos( $file, '.' ) + 1 );
42
+}
40 43
 
41 44
 header( 'Content-Type: ' . $mimetype ); // always send this
42
-if ( false === strpos( $_SERVER['SERVER_SOFTWARE'], 'Microsoft-IIS' ) )
45
+if ( false === strpos( $_SERVER['SERVER_SOFTWARE'], 'Microsoft-IIS' ) ) {
43 46
 	header( 'Content-Length: ' . filesize( $file ) );
47
+}
44 48
 
45 49
 // Optional support for X-Sendfile and X-Accel-Redirect
46 50
 if ( WPMU_ACCEL_REDIRECT ) {
@@ -60,8 +64,9 @@  discard block
 block discarded – undo
60 64
 // Support for Conditional GET - use stripslashes to avoid formatting.php dependency
61 65
 $client_etag = isset( $_SERVER['HTTP_IF_NONE_MATCH'] ) ? stripslashes( $_SERVER['HTTP_IF_NONE_MATCH'] ) : false;
62 66
 
63
-if ( ! isset( $_SERVER['HTTP_IF_MODIFIED_SINCE'] ) )
67
+if ( ! isset( $_SERVER['HTTP_IF_MODIFIED_SINCE'] ) ) {
64 68
 	$_SERVER['HTTP_IF_MODIFIED_SINCE'] = false;
69
+}
65 70
 
66 71
 $client_last_modified = trim( $_SERVER['HTTP_IF_MODIFIED_SINCE'] );
67 72
 // If string is empty, return 0. If not, attempt to parse into a timestamp
Please login to merge, or discard this patch.
Spacing   +39 added lines, -39 removed lines patch added patch discarded remove patch
@@ -8,76 +8,76 @@
 block discarded – undo
8 8
  * @subpackage Multisite
9 9
  */
10 10
 
11
-define( 'SHORTINIT', true );
12
-require_once( dirname( dirname( __FILE__ ) ) . '/wp-load.php' );
11
+define('SHORTINIT', true);
12
+require_once(dirname(dirname(__FILE__)).'/wp-load.php');
13 13
 
14
-if ( !is_multisite() )
15
-	die( 'Multisite support not enabled' );
14
+if ( ! is_multisite())
15
+	die('Multisite support not enabled');
16 16
 
17 17
 ms_file_constants();
18 18
 
19
-error_reporting( 0 );
19
+error_reporting(0);
20 20
 
21
-if ( $current_blog->archived == '1' || $current_blog->spam == '1' || $current_blog->deleted == '1' ) {
22
-	status_header( 404 );
23
-	die( '404 &#8212; File not found.' );
21
+if ($current_blog->archived == '1' || $current_blog->spam == '1' || $current_blog->deleted == '1') {
22
+	status_header(404);
23
+	die('404 &#8212; File not found.');
24 24
 }
25 25
 
26
-$file = rtrim( BLOGUPLOADDIR, '/' ) . '/' . str_replace( '..', '', $_GET[ 'file' ] );
27
-if ( !is_file( $file ) ) {
28
-	status_header( 404 );
29
-	die( '404 &#8212; File not found.' );
26
+$file = rtrim(BLOGUPLOADDIR, '/').'/'.str_replace('..', '', $_GET['file']);
27
+if ( ! is_file($file)) {
28
+	status_header(404);
29
+	die('404 &#8212; File not found.');
30 30
 }
31 31
 
32
-$mime = wp_check_filetype( $file );
33
-if ( false === $mime[ 'type' ] && function_exists( 'mime_content_type' ) )
34
-	$mime[ 'type' ] = mime_content_type( $file );
32
+$mime = wp_check_filetype($file);
33
+if (false === $mime['type'] && function_exists('mime_content_type'))
34
+	$mime['type'] = mime_content_type($file);
35 35
 
36
-if ( $mime[ 'type' ] )
37
-	$mimetype = $mime[ 'type' ];
36
+if ($mime['type'])
37
+	$mimetype = $mime['type'];
38 38
 else
39
-	$mimetype = 'image/' . substr( $file, strrpos( $file, '.' ) + 1 );
39
+	$mimetype = 'image/'.substr($file, strrpos($file, '.') + 1);
40 40
 
41
-header( 'Content-Type: ' . $mimetype ); // always send this
42
-if ( false === strpos( $_SERVER['SERVER_SOFTWARE'], 'Microsoft-IIS' ) )
43
-	header( 'Content-Length: ' . filesize( $file ) );
41
+header('Content-Type: '.$mimetype); // always send this
42
+if (false === strpos($_SERVER['SERVER_SOFTWARE'], 'Microsoft-IIS'))
43
+	header('Content-Length: '.filesize($file));
44 44
 
45 45
 // Optional support for X-Sendfile and X-Accel-Redirect
46
-if ( WPMU_ACCEL_REDIRECT ) {
47
-	header( 'X-Accel-Redirect: ' . str_replace( WP_CONTENT_DIR, '', $file ) );
46
+if (WPMU_ACCEL_REDIRECT) {
47
+	header('X-Accel-Redirect: '.str_replace(WP_CONTENT_DIR, '', $file));
48 48
 	exit;
49
-} elseif ( WPMU_SENDFILE ) {
50
-	header( 'X-Sendfile: ' . $file );
49
+} elseif (WPMU_SENDFILE) {
50
+	header('X-Sendfile: '.$file);
51 51
 	exit;
52 52
 }
53 53
 
54
-$last_modified = gmdate( 'D, d M Y H:i:s', filemtime( $file ) );
55
-$etag = '"' . md5( $last_modified ) . '"';
56
-header( "Last-Modified: $last_modified GMT" );
57
-header( 'ETag: ' . $etag );
58
-header( 'Expires: ' . gmdate( 'D, d M Y H:i:s', time() + 100000000 ) . ' GMT' );
54
+$last_modified = gmdate('D, d M Y H:i:s', filemtime($file));
55
+$etag = '"'.md5($last_modified).'"';
56
+header("Last-Modified: $last_modified GMT");
57
+header('ETag: '.$etag);
58
+header('Expires: '.gmdate('D, d M Y H:i:s', time() + 100000000).' GMT');
59 59
 
60 60
 // Support for Conditional GET - use stripslashes to avoid formatting.php dependency
61
-$client_etag = isset( $_SERVER['HTTP_IF_NONE_MATCH'] ) ? stripslashes( $_SERVER['HTTP_IF_NONE_MATCH'] ) : false;
61
+$client_etag = isset($_SERVER['HTTP_IF_NONE_MATCH']) ? stripslashes($_SERVER['HTTP_IF_NONE_MATCH']) : false;
62 62
 
63
-if ( ! isset( $_SERVER['HTTP_IF_MODIFIED_SINCE'] ) )
63
+if ( ! isset($_SERVER['HTTP_IF_MODIFIED_SINCE']))
64 64
 	$_SERVER['HTTP_IF_MODIFIED_SINCE'] = false;
65 65
 
66
-$client_last_modified = trim( $_SERVER['HTTP_IF_MODIFIED_SINCE'] );
66
+$client_last_modified = trim($_SERVER['HTTP_IF_MODIFIED_SINCE']);
67 67
 // If string is empty, return 0. If not, attempt to parse into a timestamp
68
-$client_modified_timestamp = $client_last_modified ? strtotime( $client_last_modified ) : 0;
68
+$client_modified_timestamp = $client_last_modified ? strtotime($client_last_modified) : 0;
69 69
 
70 70
 // Make a timestamp for our most recent modification...
71 71
 $modified_timestamp = strtotime($last_modified);
72 72
 
73
-if ( ( $client_last_modified && $client_etag )
74
-	? ( ( $client_modified_timestamp >= $modified_timestamp) && ( $client_etag == $etag ) )
75
-	: ( ( $client_modified_timestamp >= $modified_timestamp) || ( $client_etag == $etag ) )
73
+if (($client_last_modified && $client_etag)
74
+	? (($client_modified_timestamp >= $modified_timestamp) && ($client_etag == $etag))
75
+	: (($client_modified_timestamp >= $modified_timestamp) || ($client_etag == $etag))
76 76
 	) {
77
-	status_header( 304 );
77
+	status_header(304);
78 78
 	exit;
79 79
 }
80 80
 
81 81
 // If we made it this far, just serve the file
82
-readfile( $file );
82
+readfile($file);
83 83
 flush();
Please login to merge, or discard this patch.
src/wp-includes/compat.php 4 patches
Braces   +15 added lines, -10 removed lines patch added patch discarded remove patch
@@ -161,13 +161,15 @@  discard block
 block discarded – undo
161 161
 function _hash_hmac($algo, $data, $key, $raw_output = false) {
162 162
 	$packs = array('md5' => 'H32', 'sha1' => 'H40');
163 163
 
164
-	if ( !isset($packs[$algo]) )
165
-		return false;
164
+	if ( !isset($packs[$algo]) ) {
165
+			return false;
166
+	}
166 167
 
167 168
 	$pack = $packs[$algo];
168 169
 
169
-	if (strlen($key) > 64)
170
-		$key = pack($pack, $algo($key));
170
+	if (strlen($key) > 64) {
171
+			$key = pack($pack, $algo($key));
172
+	}
171 173
 
172 174
 	$key = str_pad($key, 64, chr(0));
173 175
 
@@ -176,8 +178,9 @@  discard block
 block discarded – undo
176 178
 
177 179
 	$hmac = $algo($opad . pack($pack, $algo($ipad . $data)));
178 180
 
179
-	if ( $raw_output )
180
-		return pack( $pack, $hmac );
181
+	if ( $raw_output ) {
182
+			return pack( $pack, $hmac );
183
+	}
181 184
 	return $hmac;
182 185
 }
183 186
 
@@ -210,8 +213,9 @@  discard block
 block discarded – undo
210 213
 		}
211 214
 
212 215
 		$res = $wp_json->decode( $string );
213
-		if ( $assoc_array )
214
-			$res = _json_decode_object_helper( $res );
216
+		if ( $assoc_array ) {
217
+					$res = _json_decode_object_helper( $res );
218
+		}
215 219
 		return $res;
216 220
 	}
217 221
 
@@ -220,8 +224,9 @@  discard block
 block discarded – undo
220 224
 	 * @return array
221 225
 	 */
222 226
 	function _json_decode_object_helper($data) {
223
-		if ( is_object($data) )
224
-			$data = get_object_vars($data);
227
+		if ( is_object($data) ) {
228
+					$data = get_object_vars($data);
229
+		}
225 230
 		return is_array($data) ? array_map(__FUNCTION__, $data) : $data;
226 231
 	}
227 232
 }
Please login to merge, or discard this patch.
Doc Comments   +5 added lines, -1 removed lines patch added patch discarded remove patch
@@ -8,6 +8,10 @@  discard block
 block discarded – undo
8 8
 
9 9
 // If gettext isn't available
10 10
 if ( !function_exists('_') ) {
11
+
12
+	/**
13
+	 * @param string $string
14
+	 */
11 15
 	function _($string) {
12 16
 		return $string;
13 17
 	}
@@ -366,7 +370,7 @@  discard block
 block discarded – undo
366 370
 	 *
367 371
 	 * @internal This is a compatibility function for PHP <5.5
368 372
 	 *
369
-	 * @return bool|string Returns the error message on success, "No Error" if no error has occurred,
373
+	 * @return false|string Returns the error message on success, "No Error" if no error has occurred,
370 374
 	 *                     or false on failure.
371 375
 	 */
372 376
 	function json_last_error_msg() {
Please login to merge, or discard this patch.
Indentation   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -472,8 +472,8 @@
 block discarded – undo
472 472
 
473 473
 				foreach ( array_keys( $head ) as $key ) {
474 474
 					if ( isset( $key, $bref ) &&
475
-					     isset( $bref[ $key ] ) && is_array( $bref[ $key ] ) &&
476
-					     isset( $head[ $key ] ) && is_array( $head[ $key ] )
475
+						 isset( $bref[ $key ] ) && is_array( $bref[ $key ] ) &&
476
+						 isset( $head[ $key ] ) && is_array( $head[ $key ] )
477 477
 					) {
478 478
 						$bref_stack[] = &$bref[ $key ];
479 479
 						$head_stack[] = $head[ $key ];
Please login to merge, or discard this patch.
Spacing   +112 added lines, -112 removed lines patch added patch discarded remove patch
@@ -7,7 +7,7 @@  discard block
 block discarded – undo
7 7
  */
8 8
 
9 9
 // If gettext isn't available
10
-if ( !function_exists('_') ) {
10
+if ( ! function_exists('_')) {
11 11
 	function _($string) {
12 12
 		return $string;
13 13
 	}
@@ -27,21 +27,21 @@  discard block
 block discarded – undo
27 27
  *             false  : Used for testing - return false for future calls to this function
28 28
  *             'reset': Used for testing - restore default behavior of this function
29 29
  */
30
-function _wp_can_use_pcre_u( $set = null ) {
30
+function _wp_can_use_pcre_u($set = null) {
31 31
 	static $utf8_pcre = 'reset';
32 32
 
33
-	if ( null !== $set ) {
33
+	if (null !== $set) {
34 34
 		$utf8_pcre = $set;
35 35
 	}
36 36
 
37
-	if ( 'reset' === $utf8_pcre ) {
38
-		$utf8_pcre = @preg_match( '/^./u', 'a' );
37
+	if ('reset' === $utf8_pcre) {
38
+		$utf8_pcre = @preg_match('/^./u', 'a');
39 39
 	}
40 40
 
41 41
 	return $utf8_pcre;
42 42
 }
43 43
 
44
-if ( ! function_exists( 'mb_substr' ) ) :
44
+if ( ! function_exists('mb_substr')) :
45 45
 	/**
46 46
 	 * Compat function to mimic mb_substr().
47 47
 	 *
@@ -57,8 +57,8 @@  discard block
 block discarded – undo
57 57
 	 * @param string|null $encoding Optional. Character encoding to use. Default null.
58 58
 	 * @return string Extracted substring.
59 59
 	 */
60
-	function mb_substr( $str, $start, $length = null, $encoding = null ) {
61
-		return _mb_substr( $str, $start, $length, $encoding );
60
+	function mb_substr($str, $start, $length = null, $encoding = null) {
61
+		return _mb_substr($str, $start, $length, $encoding);
62 62
 	}
63 63
 endif;
64 64
 
@@ -79,24 +79,24 @@  discard block
 block discarded – undo
79 79
  * @param string|null $encoding Optional. Character encoding to use. Default null.
80 80
  * @return string Extracted substring.
81 81
  */
82
-function _mb_substr( $str, $start, $length = null, $encoding = null ) {
83
-	if ( null === $encoding ) {
84
-		$encoding = get_option( 'blog_charset' );
82
+function _mb_substr($str, $start, $length = null, $encoding = null) {
83
+	if (null === $encoding) {
84
+		$encoding = get_option('blog_charset');
85 85
 	}
86 86
 
87 87
 	/*
88 88
 	 * The solution below works only for UTF-8, so in case of a different
89 89
 	 * charset just use built-in substr().
90 90
 	 */
91
-	if ( ! in_array( $encoding, array( 'utf8', 'utf-8', 'UTF8', 'UTF-8' ) ) ) {
92
-		return is_null( $length ) ? substr( $str, $start ) : substr( $str, $start, $length );
91
+	if ( ! in_array($encoding, array('utf8', 'utf-8', 'UTF8', 'UTF-8'))) {
92
+		return is_null($length) ? substr($str, $start) : substr($str, $start, $length);
93 93
 	}
94 94
 
95
-	if ( _wp_can_use_pcre_u() ) {
95
+	if (_wp_can_use_pcre_u()) {
96 96
 		// Use the regex unicode support to separate the UTF-8 characters into an array.
97
-		preg_match_all( '/./us', $str, $match );
98
-		$chars = is_null( $length ) ? array_slice( $match[0], $start ) : array_slice( $match[0], $start, $length );
99
-		return implode( '', $chars );
97
+		preg_match_all('/./us', $str, $match);
98
+		$chars = is_null($length) ? array_slice($match[0], $start) : array_slice($match[0], $start, $length);
99
+		return implode('', $chars);
100 100
 	}
101 101
 
102 102
 	$regex = '/(
@@ -112,26 +112,26 @@  discard block
 block discarded – undo
112 112
 	)/x';
113 113
 
114 114
 	// Start with 1 element instead of 0 since the first thing we do is pop.
115
-	$chars = array( '' );
115
+	$chars = array('');
116 116
 	do {
117 117
 		// We had some string left over from the last round, but we counted it in that last round.
118
-		array_pop( $chars );
118
+		array_pop($chars);
119 119
 
120 120
 		/*
121 121
 		 * Split by UTF-8 character, limit to 1000 characters (last array element will contain
122 122
 		 * the rest of the string).
123 123
 		 */
124
-		$pieces = preg_split( $regex, $str, 1000, PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY );
124
+		$pieces = preg_split($regex, $str, 1000, PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY);
125 125
 
126
-		$chars = array_merge( $chars, $pieces );
126
+		$chars = array_merge($chars, $pieces);
127 127
 
128 128
 	// If there's anything left over, repeat the loop.
129
-	} while ( count( $pieces ) > 1 && $str = array_pop( $pieces ) );
129
+	} while (count($pieces) > 1 && $str = array_pop($pieces));
130 130
 
131
-	return join( '', array_slice( $chars, $start, $length ) );
131
+	return join('', array_slice($chars, $start, $length));
132 132
 }
133 133
 
134
-if ( ! function_exists( 'mb_strlen' ) ) :
134
+if ( ! function_exists('mb_strlen')) :
135 135
 	/**
136 136
 	 * Compat function to mimic mb_strlen().
137 137
 	 *
@@ -144,8 +144,8 @@  discard block
 block discarded – undo
144 144
 	 * @param string|null $encoding Optional. Character encoding to use. Default null.
145 145
 	 * @return int String length of `$str`.
146 146
 	 */
147
-	function mb_strlen( $str, $encoding = null ) {
148
-		return _mb_strlen( $str, $encoding );
147
+	function mb_strlen($str, $encoding = null) {
148
+		return _mb_strlen($str, $encoding);
149 149
 	}
150 150
 endif;
151 151
 
@@ -163,23 +163,23 @@  discard block
 block discarded – undo
163 163
  * @param string|null $encoding Optional. Character encoding to use. Default null.
164 164
  * @return int String length of `$str`.
165 165
  */
166
-function _mb_strlen( $str, $encoding = null ) {
167
-	if ( null === $encoding ) {
168
-		$encoding = get_option( 'blog_charset' );
166
+function _mb_strlen($str, $encoding = null) {
167
+	if (null === $encoding) {
168
+		$encoding = get_option('blog_charset');
169 169
 	}
170 170
 
171 171
 	/*
172 172
 	 * The solution below works only for UTF-8, so in case of a different charset
173 173
 	 * just use built-in strlen().
174 174
 	 */
175
-	if ( ! in_array( $encoding, array( 'utf8', 'utf-8', 'UTF8', 'UTF-8' ) ) ) {
176
-		return strlen( $str );
175
+	if ( ! in_array($encoding, array('utf8', 'utf-8', 'UTF8', 'UTF-8'))) {
176
+		return strlen($str);
177 177
 	}
178 178
 
179
-	if ( _wp_can_use_pcre_u() ) {
179
+	if (_wp_can_use_pcre_u()) {
180 180
 		// Use the regex unicode support to separate the UTF-8 characters into an array.
181
-		preg_match_all( '/./us', $str, $match );
182
-		return count( $match[0] );
181
+		preg_match_all('/./us', $str, $match);
182
+		return count($match[0]);
183 183
 	}
184 184
 
185 185
 	$regex = '/(?:
@@ -204,19 +204,19 @@  discard block
 block discarded – undo
204 204
 		 * Split by UTF-8 character, limit to 1000 characters (last array element will contain
205 205
 		 * the rest of the string).
206 206
 		 */
207
-		$pieces = preg_split( $regex, $str, 1000 );
207
+		$pieces = preg_split($regex, $str, 1000);
208 208
 
209 209
 		// Increment.
210
-		$count += count( $pieces );
210
+		$count += count($pieces);
211 211
 
212 212
 	// If there's anything left over, repeat the loop.
213
-	} while ( $str = array_pop( $pieces ) );
213
+	} while ($str = array_pop($pieces));
214 214
 
215 215
 	// Fencepost: preg_split() always returns one extra item in the array.
216 216
 	return --$count;
217 217
 }
218 218
 
219
-if ( !function_exists('hash_hmac') ):
219
+if ( ! function_exists('hash_hmac')):
220 220
 /**
221 221
  * Compat function to mimic hash_hmac().
222 222
  *
@@ -255,7 +255,7 @@  discard block
 block discarded – undo
255 255
 function _hash_hmac($algo, $data, $key, $raw_output = false) {
256 256
 	$packs = array('md5' => 'H32', 'sha1' => 'H40');
257 257
 
258
-	if ( !isset($packs[$algo]) )
258
+	if ( ! isset($packs[$algo]))
259 259
 		return false;
260 260
 
261 261
 	$pack = $packs[$algo];
@@ -268,44 +268,44 @@  discard block
 block discarded – undo
268 268
 	$ipad = (substr($key, 0, 64) ^ str_repeat(chr(0x36), 64));
269 269
 	$opad = (substr($key, 0, 64) ^ str_repeat(chr(0x5C), 64));
270 270
 
271
-	$hmac = $algo($opad . pack($pack, $algo($ipad . $data)));
271
+	$hmac = $algo($opad.pack($pack, $algo($ipad.$data)));
272 272
 
273
-	if ( $raw_output )
274
-		return pack( $pack, $hmac );
273
+	if ($raw_output)
274
+		return pack($pack, $hmac);
275 275
 	return $hmac;
276 276
 }
277 277
 
278
-if ( !function_exists('json_encode') ) {
279
-	function json_encode( $string ) {
278
+if ( ! function_exists('json_encode')) {
279
+	function json_encode($string) {
280 280
 		global $wp_json;
281 281
 
282
-		if ( ! ( $wp_json instanceof Services_JSON ) ) {
283
-			require_once( ABSPATH . WPINC . '/class-json.php' );
282
+		if ( ! ($wp_json instanceof Services_JSON)) {
283
+			require_once(ABSPATH.WPINC.'/class-json.php');
284 284
 			$wp_json = new Services_JSON();
285 285
 		}
286 286
 
287
-		return $wp_json->encodeUnsafe( $string );
287
+		return $wp_json->encodeUnsafe($string);
288 288
 	}
289 289
 }
290 290
 
291
-if ( !function_exists('json_decode') ) {
291
+if ( ! function_exists('json_decode')) {
292 292
 	/**
293 293
 	 * @global Services_JSON $wp_json
294 294
 	 * @param string $string
295 295
 	 * @param bool   $assoc_array
296 296
 	 * @return object|array
297 297
 	 */
298
-	function json_decode( $string, $assoc_array = false ) {
298
+	function json_decode($string, $assoc_array = false) {
299 299
 		global $wp_json;
300 300
 
301
-		if ( ! ($wp_json instanceof Services_JSON ) ) {
302
-			require_once( ABSPATH . WPINC . '/class-json.php' );
301
+		if ( ! ($wp_json instanceof Services_JSON)) {
302
+			require_once(ABSPATH.WPINC.'/class-json.php');
303 303
 			$wp_json = new Services_JSON();
304 304
 		}
305 305
 
306
-		$res = $wp_json->decode( $string );
307
-		if ( $assoc_array )
308
-			$res = _json_decode_object_helper( $res );
306
+		$res = $wp_json->decode($string);
307
+		if ($assoc_array)
308
+			$res = _json_decode_object_helper($res);
309 309
 		return $res;
310 310
 	}
311 311
 
@@ -314,13 +314,13 @@  discard block
 block discarded – undo
314 314
 	 * @return array
315 315
 	 */
316 316
 	function _json_decode_object_helper($data) {
317
-		if ( is_object($data) )
317
+		if (is_object($data))
318 318
 			$data = get_object_vars($data);
319 319
 		return is_array($data) ? array_map(__FUNCTION__, $data) : $data;
320 320
 	}
321 321
 }
322 322
 
323
-if ( ! function_exists( 'hash_equals' ) ) :
323
+if ( ! function_exists('hash_equals')) :
324 324
 /**
325 325
  * Timing attack safe string comparison
326 326
  *
@@ -336,16 +336,16 @@  discard block
 block discarded – undo
336 336
  * @param string $b Actual, user supplied, string.
337 337
  * @return bool Whether strings are equal.
338 338
  */
339
-function hash_equals( $a, $b ) {
340
-	$a_length = strlen( $a );
341
-	if ( $a_length !== strlen( $b ) ) {
339
+function hash_equals($a, $b) {
340
+	$a_length = strlen($a);
341
+	if ($a_length !== strlen($b)) {
342 342
 		return false;
343 343
 	}
344 344
 	$result = 0;
345 345
 
346 346
 	// Do not attempt to "optimize" this.
347
-	for ( $i = 0; $i < $a_length; $i++ ) {
348
-		$result |= ord( $a[ $i ] ) ^ ord( $b[ $i ] );
347
+	for ($i = 0; $i < $a_length; $i++) {
348
+		$result |= ord($a[$i]) ^ ord($b[$i]);
349 349
 	}
350 350
 
351 351
 	return $result === 0;
@@ -354,11 +354,11 @@  discard block
 block discarded – undo
354 354
 
355 355
 // JSON_PRETTY_PRINT was introduced in PHP 5.4
356 356
 // Defined here to prevent a notice when using it with wp_json_encode()
357
-if ( ! defined( 'JSON_PRETTY_PRINT' ) ) {
358
-	define( 'JSON_PRETTY_PRINT', 128 );
357
+if ( ! defined('JSON_PRETTY_PRINT')) {
358
+	define('JSON_PRETTY_PRINT', 128);
359 359
 }
360 360
 
361
-if ( ! function_exists( 'json_last_error_msg' ) ) :
361
+if ( ! function_exists('json_last_error_msg')) :
362 362
 	/**
363 363
 	 * Retrieves the error string of the last json_encode() or json_decode() call.
364 364
 	 *
@@ -371,41 +371,41 @@  discard block
 block discarded – undo
371 371
 	 */
372 372
 	function json_last_error_msg() {
373 373
 		// See https://core.trac.wordpress.org/ticket/27799.
374
-		if ( ! function_exists( 'json_last_error' ) ) {
374
+		if ( ! function_exists('json_last_error')) {
375 375
 			return false;
376 376
 		}
377 377
 
378 378
 		$last_error_code = json_last_error();
379 379
 
380 380
 		// Just in case JSON_ERROR_NONE is not defined.
381
-		$error_code_none = defined( 'JSON_ERROR_NONE' ) ? JSON_ERROR_NONE : 0;
381
+		$error_code_none = defined('JSON_ERROR_NONE') ? JSON_ERROR_NONE : 0;
382 382
 
383
-		switch ( true ) {
383
+		switch (true) {
384 384
 			case $last_error_code === $error_code_none:
385 385
 				return 'No error';
386 386
 
387
-			case defined( 'JSON_ERROR_DEPTH' ) && JSON_ERROR_DEPTH === $last_error_code:
387
+			case defined('JSON_ERROR_DEPTH') && JSON_ERROR_DEPTH === $last_error_code:
388 388
 				return 'Maximum stack depth exceeded';
389 389
 
390
-			case defined( 'JSON_ERROR_STATE_MISMATCH' ) && JSON_ERROR_STATE_MISMATCH === $last_error_code:
390
+			case defined('JSON_ERROR_STATE_MISMATCH') && JSON_ERROR_STATE_MISMATCH === $last_error_code:
391 391
 				return 'State mismatch (invalid or malformed JSON)';
392 392
 
393
-			case defined( 'JSON_ERROR_CTRL_CHAR' ) && JSON_ERROR_CTRL_CHAR === $last_error_code:
393
+			case defined('JSON_ERROR_CTRL_CHAR') && JSON_ERROR_CTRL_CHAR === $last_error_code:
394 394
 				return 'Control character error, possibly incorrectly encoded';
395 395
 
396
-			case defined( 'JSON_ERROR_SYNTAX' ) && JSON_ERROR_SYNTAX === $last_error_code:
396
+			case defined('JSON_ERROR_SYNTAX') && JSON_ERROR_SYNTAX === $last_error_code:
397 397
 				return 'Syntax error';
398 398
 
399
-			case defined( 'JSON_ERROR_UTF8' ) && JSON_ERROR_UTF8 === $last_error_code:
399
+			case defined('JSON_ERROR_UTF8') && JSON_ERROR_UTF8 === $last_error_code:
400 400
 				return 'Malformed UTF-8 characters, possibly incorrectly encoded';
401 401
 
402
-			case defined( 'JSON_ERROR_RECURSION' ) && JSON_ERROR_RECURSION === $last_error_code:
402
+			case defined('JSON_ERROR_RECURSION') && JSON_ERROR_RECURSION === $last_error_code:
403 403
 				return 'Recursion detected';
404 404
 
405
-			case defined( 'JSON_ERROR_INF_OR_NAN' ) && JSON_ERROR_INF_OR_NAN === $last_error_code:
405
+			case defined('JSON_ERROR_INF_OR_NAN') && JSON_ERROR_INF_OR_NAN === $last_error_code:
406 406
 				return 'Inf and NaN cannot be JSON encoded';
407 407
 
408
-			case defined( 'JSON_ERROR_UNSUPPORTED_TYPE' ) && JSON_ERROR_UNSUPPORTED_TYPE === $last_error_code:
408
+			case defined('JSON_ERROR_UNSUPPORTED_TYPE') && JSON_ERROR_UNSUPPORTED_TYPE === $last_error_code:
409 409
 				return 'Type is not supported';
410 410
 
411 411
 			default:
@@ -414,8 +414,8 @@  discard block
 block discarded – undo
414 414
 	}
415 415
 endif;
416 416
 
417
-if ( ! interface_exists( 'JsonSerializable' ) ) {
418
-	define( 'WP_JSON_SERIALIZE_COMPATIBLE', true );
417
+if ( ! interface_exists('JsonSerializable')) {
418
+	define('WP_JSON_SERIALIZE_COMPATIBLE', true);
419 419
 	/**
420 420
 	 * JsonSerializable interface.
421 421
 	 *
@@ -431,11 +431,11 @@  discard block
 block discarded – undo
431 431
 }
432 432
 
433 433
 // random_int was introduced in PHP 7.0
434
-if ( ! function_exists( 'random_int' ) ) {
435
-	require ABSPATH . WPINC . '/random_compat/random.php';
434
+if ( ! function_exists('random_int')) {
435
+	require ABSPATH.WPINC.'/random_compat/random.php';
436 436
 }
437 437
 
438
-if ( ! function_exists( 'array_replace_recursive' ) ) :
438
+if ( ! function_exists('array_replace_recursive')) :
439 439
 	/**
440 440
 	 * PHP-agnostic version of {@link array_replace_recursive()}.
441 441
 	 *
@@ -457,31 +457,31 @@  discard block
 block discarded – undo
457 457
 	 *
458 458
 	 * @return array
459 459
 	 */
460
-	function array_replace_recursive( $base = array(), $replacements = array() ) {
461
-		foreach ( array_slice( func_get_args(), 1 ) as $replacements ) {
462
-			$bref_stack = array( &$base );
463
-			$head_stack = array( $replacements );
460
+	function array_replace_recursive($base = array(), $replacements = array()) {
461
+		foreach (array_slice(func_get_args(), 1) as $replacements) {
462
+			$bref_stack = array(&$base);
463
+			$head_stack = array($replacements);
464 464
 
465 465
 			do {
466
-				end( $bref_stack );
466
+				end($bref_stack);
467 467
 
468
-				$bref = &$bref_stack[ key( $bref_stack ) ];
469
-				$head = array_pop( $head_stack );
468
+				$bref = &$bref_stack[key($bref_stack)];
469
+				$head = array_pop($head_stack);
470 470
 
471
-				unset( $bref_stack[ key( $bref_stack ) ] );
471
+				unset($bref_stack[key($bref_stack)]);
472 472
 
473
-				foreach ( array_keys( $head ) as $key ) {
474
-					if ( isset( $key, $bref ) &&
475
-					     isset( $bref[ $key ] ) && is_array( $bref[ $key ] ) &&
476
-					     isset( $head[ $key ] ) && is_array( $head[ $key ] )
473
+				foreach (array_keys($head) as $key) {
474
+					if (isset($key, $bref) &&
475
+					     isset($bref[$key]) && is_array($bref[$key]) &&
476
+					     isset($head[$key]) && is_array($head[$key])
477 477
 					) {
478
-						$bref_stack[] = &$bref[ $key ];
479
-						$head_stack[] = $head[ $key ];
478
+						$bref_stack[] = &$bref[$key];
479
+						$head_stack[] = $head[$key];
480 480
 					} else {
481
-						$bref[ $key ] = $head[ $key ];
481
+						$bref[$key] = $head[$key];
482 482
 					}
483 483
 				}
484
-			} while ( count( $head_stack ) );
484
+			} while (count($head_stack));
485 485
 		}
486 486
 
487 487
 		return $base;
@@ -489,7 +489,7 @@  discard block
 block discarded – undo
489 489
 endif;
490 490
 
491 491
 // SPL can be disabled on PHP 5.2
492
-if ( ! function_exists( 'spl_autoload_register' ) ):
492
+if ( ! function_exists('spl_autoload_register')):
493 493
 	$_wp_spl_autoloaders = array();
494 494
 
495 495
 	/**
@@ -499,18 +499,18 @@  discard block
 block discarded – undo
499 499
 	 *
500 500
 	 * @param string $classname Class to attempt autoloading.
501 501
 	 */
502
-	function __autoload( $classname ) {
502
+	function __autoload($classname) {
503 503
 		global $_wp_spl_autoloaders;
504
-		foreach ( $_wp_spl_autoloaders as $autoloader ) {
505
-			if ( ! is_callable( $autoloader ) ) {
504
+		foreach ($_wp_spl_autoloaders as $autoloader) {
505
+			if ( ! is_callable($autoloader)) {
506 506
 				// Avoid the extra warning if the autoloader isn't callable.
507 507
 				continue;
508 508
 			}
509 509
 
510
-			call_user_func( $autoloader, $classname );
510
+			call_user_func($autoloader, $classname);
511 511
 
512 512
 			// If it has been autoloaded, stop processing.
513
-			if ( class_exists( $classname, false ) ) {
513
+			if (class_exists($classname, false)) {
514 514
 				return;
515 515
 			}
516 516
 		}
@@ -527,21 +527,21 @@  discard block
 block discarded – undo
527 527
 	 * @param bool     $prepend           Whether the function should be prepended to the stack.
528 528
 	 *                                    Default false.
529 529
 	 */
530
-	function spl_autoload_register( $autoload_function, $throw = true, $prepend = false ) {
531
-		if ( $throw && ! is_callable( $autoload_function ) ) {
530
+	function spl_autoload_register($autoload_function, $throw = true, $prepend = false) {
531
+		if ($throw && ! is_callable($autoload_function)) {
532 532
 			// String not translated to match PHP core.
533
-			throw new Exception( 'Function not callable' );
533
+			throw new Exception('Function not callable');
534 534
 		}
535 535
 
536 536
 		global $_wp_spl_autoloaders;
537 537
 
538 538
 		// Don't allow multiple registration.
539
-		if ( in_array( $autoload_function, $_wp_spl_autoloaders ) ) {
539
+		if (in_array($autoload_function, $_wp_spl_autoloaders)) {
540 540
 			return;
541 541
 		}
542 542
 
543
-		if ( $prepend ) {
544
-			array_unshift( $_wp_spl_autoloaders, $autoload_function );
543
+		if ($prepend) {
544
+			array_unshift($_wp_spl_autoloaders, $autoload_function);
545 545
 		} else {
546 546
 			$_wp_spl_autoloaders[] = $autoload_function;
547 547
 		}
@@ -555,11 +555,11 @@  discard block
 block discarded – undo
555 555
 	 * @param callable $function The function to unregister.
556 556
 	 * @return bool True if the function was unregistered, false if it could not be.
557 557
 	 */
558
-	function spl_autoload_unregister( $function ) {
558
+	function spl_autoload_unregister($function) {
559 559
 		global $_wp_spl_autoloaders;
560
-		foreach ( $_wp_spl_autoloaders as &$autoloader ) {
561
-			if ( $autoloader === $function ) {
562
-				unset( $autoloader );
560
+		foreach ($_wp_spl_autoloaders as &$autoloader) {
561
+			if ($autoloader === $function) {
562
+				unset($autoloader);
563 563
 				return true;
564 564
 			}
565 565
 		}
Please login to merge, or discard this patch.
src/wp-includes/Text/Diff/Engine/shell.php 3 patches
Indentation   +142 added lines, -142 removed lines patch added patch discarded remove patch
@@ -16,147 +16,147 @@
 block discarded – undo
16 16
  */
17 17
 class Text_Diff_Engine_shell {
18 18
 
19
-    /**
20
-     * Path to the diff executable
21
-     *
22
-     * @var string
23
-     */
24
-    var $_diffCommand = 'diff';
25
-
26
-    /**
27
-     * Returns the array of differences.
28
-     *
29
-     * @param array $from_lines lines of text from old file
30
-     * @param array $to_lines   lines of text from new file
31
-     *
32
-     * @return array all changes made (array with Text_Diff_Op_* objects)
33
-     */
34
-    function diff($from_lines, $to_lines)
35
-    {
36
-        array_walk($from_lines, array('Text_Diff', 'trimNewlines'));
37
-        array_walk($to_lines, array('Text_Diff', 'trimNewlines'));
38
-
39
-        $temp_dir = Text_Diff::_getTempDir();
40
-
41
-        // Execute gnu diff or similar to get a standard diff file.
42
-        $from_file = tempnam($temp_dir, 'Text_Diff');
43
-        $to_file = tempnam($temp_dir, 'Text_Diff');
44
-        $fp = fopen($from_file, 'w');
45
-        fwrite($fp, implode("\n", $from_lines));
46
-        fclose($fp);
47
-        $fp = fopen($to_file, 'w');
48
-        fwrite($fp, implode("\n", $to_lines));
49
-        fclose($fp);
50
-        $diff = shell_exec($this->_diffCommand . ' ' . $from_file . ' ' . $to_file);
51
-        unlink($from_file);
52
-        unlink($to_file);
53
-
54
-        if (is_null($diff)) {
55
-            // No changes were made
56
-            return array(new Text_Diff_Op_copy($from_lines));
57
-        }
58
-
59
-        $from_line_no = 1;
60
-        $to_line_no = 1;
61
-        $edits = array();
62
-
63
-        // Get changed lines by parsing something like:
64
-        // 0a1,2
65
-        // 1,2c4,6
66
-        // 1,5d6
67
-        preg_match_all('#^(\d+)(?:,(\d+))?([adc])(\d+)(?:,(\d+))?$#m', $diff,
68
-            $matches, PREG_SET_ORDER);
69
-
70
-        foreach ($matches as $match) {
71
-            if (!isset($match[5])) {
72
-                // This paren is not set every time (see regex).
73
-                $match[5] = false;
74
-            }
75
-
76
-            if ($match[3] == 'a') {
77
-                $from_line_no--;
78
-            }
79
-
80
-            if ($match[3] == 'd') {
81
-                $to_line_no--;
82
-            }
83
-
84
-            if ($from_line_no < $match[1] || $to_line_no < $match[4]) {
85
-                // copied lines
86
-                assert('$match[1] - $from_line_no == $match[4] - $to_line_no');
87
-                array_push($edits,
88
-                    new Text_Diff_Op_copy(
89
-                        $this->_getLines($from_lines, $from_line_no, $match[1] - 1),
90
-                        $this->_getLines($to_lines, $to_line_no, $match[4] - 1)));
91
-            }
92
-
93
-            switch ($match[3]) {
94
-            case 'd':
95
-                // deleted lines
96
-                array_push($edits,
97
-                    new Text_Diff_Op_delete(
98
-                        $this->_getLines($from_lines, $from_line_no, $match[2])));
99
-                $to_line_no++;
100
-                break;
101
-
102
-            case 'c':
103
-                // changed lines
104
-                array_push($edits,
105
-                    new Text_Diff_Op_change(
106
-                        $this->_getLines($from_lines, $from_line_no, $match[2]),
107
-                        $this->_getLines($to_lines, $to_line_no, $match[5])));
108
-                break;
109
-
110
-            case 'a':
111
-                // added lines
112
-                array_push($edits,
113
-                    new Text_Diff_Op_add(
114
-                        $this->_getLines($to_lines, $to_line_no, $match[5])));
115
-                $from_line_no++;
116
-                break;
117
-            }
118
-        }
119
-
120
-        if (!empty($from_lines)) {
121
-            // Some lines might still be pending. Add them as copied
122
-            array_push($edits,
123
-                new Text_Diff_Op_copy(
124
-                    $this->_getLines($from_lines, $from_line_no,
125
-                                     $from_line_no + count($from_lines) - 1),
126
-                    $this->_getLines($to_lines, $to_line_no,
127
-                                     $to_line_no + count($to_lines) - 1)));
128
-        }
129
-
130
-        return $edits;
131
-    }
132
-
133
-    /**
134
-     * Get lines from either the old or new text
135
-     *
136
-     * @access private
137
-     *
138
-     * @param array &$text_lines Either $from_lines or $to_lines
139
-     * @param int   &$line_no    Current line number
140
-     * @param int   $end         Optional end line, when we want to chop more
141
-     *                           than one line.
142
-     *
143
-     * @return array The chopped lines
144
-     */
145
-    function _getLines(&$text_lines, &$line_no, $end = false)
146
-    {
147
-        if (!empty($end)) {
148
-            $lines = array();
149
-            // We can shift even more
150
-            while ($line_no <= $end) {
151
-                array_push($lines, array_shift($text_lines));
152
-                $line_no++;
153
-            }
154
-        } else {
155
-            $lines = array(array_shift($text_lines));
156
-            $line_no++;
157
-        }
158
-
159
-        return $lines;
160
-    }
19
+	/**
20
+	 * Path to the diff executable
21
+	 *
22
+	 * @var string
23
+	 */
24
+	var $_diffCommand = 'diff';
25
+
26
+	/**
27
+	 * Returns the array of differences.
28
+	 *
29
+	 * @param array $from_lines lines of text from old file
30
+	 * @param array $to_lines   lines of text from new file
31
+	 *
32
+	 * @return array all changes made (array with Text_Diff_Op_* objects)
33
+	 */
34
+	function diff($from_lines, $to_lines)
35
+	{
36
+		array_walk($from_lines, array('Text_Diff', 'trimNewlines'));
37
+		array_walk($to_lines, array('Text_Diff', 'trimNewlines'));
38
+
39
+		$temp_dir = Text_Diff::_getTempDir();
40
+
41
+		// Execute gnu diff or similar to get a standard diff file.
42
+		$from_file = tempnam($temp_dir, 'Text_Diff');
43
+		$to_file = tempnam($temp_dir, 'Text_Diff');
44
+		$fp = fopen($from_file, 'w');
45
+		fwrite($fp, implode("\n", $from_lines));
46
+		fclose($fp);
47
+		$fp = fopen($to_file, 'w');
48
+		fwrite($fp, implode("\n", $to_lines));
49
+		fclose($fp);
50
+		$diff = shell_exec($this->_diffCommand . ' ' . $from_file . ' ' . $to_file);
51
+		unlink($from_file);
52
+		unlink($to_file);
53
+
54
+		if (is_null($diff)) {
55
+			// No changes were made
56
+			return array(new Text_Diff_Op_copy($from_lines));
57
+		}
58
+
59
+		$from_line_no = 1;
60
+		$to_line_no = 1;
61
+		$edits = array();
62
+
63
+		// Get changed lines by parsing something like:
64
+		// 0a1,2
65
+		// 1,2c4,6
66
+		// 1,5d6
67
+		preg_match_all('#^(\d+)(?:,(\d+))?([adc])(\d+)(?:,(\d+))?$#m', $diff,
68
+			$matches, PREG_SET_ORDER);
69
+
70
+		foreach ($matches as $match) {
71
+			if (!isset($match[5])) {
72
+				// This paren is not set every time (see regex).
73
+				$match[5] = false;
74
+			}
75
+
76
+			if ($match[3] == 'a') {
77
+				$from_line_no--;
78
+			}
79
+
80
+			if ($match[3] == 'd') {
81
+				$to_line_no--;
82
+			}
83
+
84
+			if ($from_line_no < $match[1] || $to_line_no < $match[4]) {
85
+				// copied lines
86
+				assert('$match[1] - $from_line_no == $match[4] - $to_line_no');
87
+				array_push($edits,
88
+					new Text_Diff_Op_copy(
89
+						$this->_getLines($from_lines, $from_line_no, $match[1] - 1),
90
+						$this->_getLines($to_lines, $to_line_no, $match[4] - 1)));
91
+			}
92
+
93
+			switch ($match[3]) {
94
+			case 'd':
95
+				// deleted lines
96
+				array_push($edits,
97
+					new Text_Diff_Op_delete(
98
+						$this->_getLines($from_lines, $from_line_no, $match[2])));
99
+				$to_line_no++;
100
+				break;
101
+
102
+			case 'c':
103
+				// changed lines
104
+				array_push($edits,
105
+					new Text_Diff_Op_change(
106
+						$this->_getLines($from_lines, $from_line_no, $match[2]),
107
+						$this->_getLines($to_lines, $to_line_no, $match[5])));
108
+				break;
109
+
110
+			case 'a':
111
+				// added lines
112
+				array_push($edits,
113
+					new Text_Diff_Op_add(
114
+						$this->_getLines($to_lines, $to_line_no, $match[5])));
115
+				$from_line_no++;
116
+				break;
117
+			}
118
+		}
119
+
120
+		if (!empty($from_lines)) {
121
+			// Some lines might still be pending. Add them as copied
122
+			array_push($edits,
123
+				new Text_Diff_Op_copy(
124
+					$this->_getLines($from_lines, $from_line_no,
125
+									 $from_line_no + count($from_lines) - 1),
126
+					$this->_getLines($to_lines, $to_line_no,
127
+									 $to_line_no + count($to_lines) - 1)));
128
+		}
129
+
130
+		return $edits;
131
+	}
132
+
133
+	/**
134
+	 * Get lines from either the old or new text
135
+	 *
136
+	 * @access private
137
+	 *
138
+	 * @param array &$text_lines Either $from_lines or $to_lines
139
+	 * @param int   &$line_no    Current line number
140
+	 * @param int   $end         Optional end line, when we want to chop more
141
+	 *                           than one line.
142
+	 *
143
+	 * @return array The chopped lines
144
+	 */
145
+	function _getLines(&$text_lines, &$line_no, $end = false)
146
+	{
147
+		if (!empty($end)) {
148
+			$lines = array();
149
+			// We can shift even more
150
+			while ($line_no <= $end) {
151
+				array_push($lines, array_shift($text_lines));
152
+				$line_no++;
153
+			}
154
+		} else {
155
+			$lines = array(array_shift($text_lines));
156
+			$line_no++;
157
+		}
158
+
159
+		return $lines;
160
+	}
161 161
 
162 162
 }
Please login to merge, or discard this patch.
Switch Indentation   +23 added lines, -23 removed lines patch added patch discarded remove patch
@@ -91,29 +91,29 @@
 block discarded – undo
91 91
             }
92 92
 
93 93
             switch ($match[3]) {
94
-            case 'd':
95
-                // deleted lines
96
-                array_push($edits,
97
-                    new Text_Diff_Op_delete(
98
-                        $this->_getLines($from_lines, $from_line_no, $match[2])));
99
-                $to_line_no++;
100
-                break;
101
-
102
-            case 'c':
103
-                // changed lines
104
-                array_push($edits,
105
-                    new Text_Diff_Op_change(
106
-                        $this->_getLines($from_lines, $from_line_no, $match[2]),
107
-                        $this->_getLines($to_lines, $to_line_no, $match[5])));
108
-                break;
109
-
110
-            case 'a':
111
-                // added lines
112
-                array_push($edits,
113
-                    new Text_Diff_Op_add(
114
-                        $this->_getLines($to_lines, $to_line_no, $match[5])));
115
-                $from_line_no++;
116
-                break;
94
+            	case 'd':
95
+                	// deleted lines
96
+                	array_push($edits,
97
+                    	new Text_Diff_Op_delete(
98
+                        	$this->_getLines($from_lines, $from_line_no, $match[2])));
99
+                	$to_line_no++;
100
+                	break;
101
+
102
+            	case 'c':
103
+                	// changed lines
104
+                	array_push($edits,
105
+                    	new Text_Diff_Op_change(
106
+                        	$this->_getLines($from_lines, $from_line_no, $match[2]),
107
+                        	$this->_getLines($to_lines, $to_line_no, $match[5])));
108
+                	break;
109
+
110
+            	case 'a':
111
+                	// added lines
112
+                	array_push($edits,
113
+                    	new Text_Diff_Op_add(
114
+                        	$this->_getLines($to_lines, $to_line_no, $match[5])));
115
+                	$from_line_no++;
116
+                	break;
117 117
             }
118 118
         }
119 119
 
Please login to merge, or discard this patch.
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -47,7 +47,7 @@  discard block
 block discarded – undo
47 47
         $fp = fopen($to_file, 'w');
48 48
         fwrite($fp, implode("\n", $to_lines));
49 49
         fclose($fp);
50
-        $diff = shell_exec($this->_diffCommand . ' ' . $from_file . ' ' . $to_file);
50
+        $diff = shell_exec($this->_diffCommand.' '.$from_file.' '.$to_file);
51 51
         unlink($from_file);
52 52
         unlink($to_file);
53 53
 
@@ -68,7 +68,7 @@  discard block
 block discarded – undo
68 68
             $matches, PREG_SET_ORDER);
69 69
 
70 70
         foreach ($matches as $match) {
71
-            if (!isset($match[5])) {
71
+            if ( ! isset($match[5])) {
72 72
                 // This paren is not set every time (see regex).
73 73
                 $match[5] = false;
74 74
             }
@@ -117,7 +117,7 @@  discard block
 block discarded – undo
117 117
             }
118 118
         }
119 119
 
120
-        if (!empty($from_lines)) {
120
+        if ( ! empty($from_lines)) {
121 121
             // Some lines might still be pending. Add them as copied
122 122
             array_push($edits,
123 123
                 new Text_Diff_Op_copy(
@@ -144,7 +144,7 @@  discard block
 block discarded – undo
144 144
      */
145 145
     function _getLines(&$text_lines, &$line_no, $end = false)
146 146
     {
147
-        if (!empty($end)) {
147
+        if ( ! empty($end)) {
148 148
             $lines = array();
149 149
             // We can shift even more
150 150
             while ($line_no <= $end) {
Please login to merge, or discard this patch.
src/wp-includes/Text/Diff/Engine/xdiff.php 3 patches
Indentation   +32 added lines, -32 removed lines patch added patch discarded remove patch
@@ -15,22 +15,22 @@  discard block
 block discarded – undo
15 15
  */
16 16
 class Text_Diff_Engine_xdiff {
17 17
 
18
-    /**
19
-     */
20
-    function diff($from_lines, $to_lines)
21
-    {
22
-        array_walk($from_lines, array('Text_Diff', 'trimNewlines'));
23
-        array_walk($to_lines, array('Text_Diff', 'trimNewlines'));
18
+	/**
19
+	 */
20
+	function diff($from_lines, $to_lines)
21
+	{
22
+		array_walk($from_lines, array('Text_Diff', 'trimNewlines'));
23
+		array_walk($to_lines, array('Text_Diff', 'trimNewlines'));
24 24
 
25
-        /* Convert the two input arrays into strings for xdiff processing. */
26
-        $from_string = implode("\n", $from_lines);
27
-        $to_string = implode("\n", $to_lines);
25
+		/* Convert the two input arrays into strings for xdiff processing. */
26
+		$from_string = implode("\n", $from_lines);
27
+		$to_string = implode("\n", $to_lines);
28 28
 
29
-        /* Diff the two strings and convert the result to an array. */
30
-        $diff = xdiff_string_diff($from_string, $to_string, count($to_lines));
31
-        $diff = explode("\n", $diff);
29
+		/* Diff the two strings and convert the result to an array. */
30
+		$diff = xdiff_string_diff($from_string, $to_string, count($to_lines));
31
+		$diff = explode("\n", $diff);
32 32
 
33
-        /* Walk through the diff one line at a time.  We build the $edits
33
+		/* Walk through the diff one line at a time.  We build the $edits
34 34
          * array of diff operations by reading the first character of the
35 35
          * xdiff output (which is in the "unified diff" format).
36 36
          *
@@ -38,27 +38,27 @@  discard block
 block discarded – undo
38 38
          * lines using this approach, so we can't add Text_Diff_Op_changed
39 39
          * instances to the $edits array.  The result is still perfectly
40 40
          * valid, albeit a little less descriptive and efficient. */
41
-        $edits = array();
42
-        foreach ($diff as $line) {
43
-            if (!strlen($line)) {
44
-                continue;
45
-            }
46
-            switch ($line[0]) {
47
-            case ' ':
48
-                $edits[] = new Text_Diff_Op_copy(array(substr($line, 1)));
49
-                break;
41
+		$edits = array();
42
+		foreach ($diff as $line) {
43
+			if (!strlen($line)) {
44
+				continue;
45
+			}
46
+			switch ($line[0]) {
47
+			case ' ':
48
+				$edits[] = new Text_Diff_Op_copy(array(substr($line, 1)));
49
+				break;
50 50
 
51
-            case '+':
52
-                $edits[] = new Text_Diff_Op_add(array(substr($line, 1)));
53
-                break;
51
+			case '+':
52
+				$edits[] = new Text_Diff_Op_add(array(substr($line, 1)));
53
+				break;
54 54
 
55
-            case '-':
56
-                $edits[] = new Text_Diff_Op_delete(array(substr($line, 1)));
57
-                break;
58
-            }
59
-        }
55
+			case '-':
56
+				$edits[] = new Text_Diff_Op_delete(array(substr($line, 1)));
57
+				break;
58
+			}
59
+		}
60 60
 
61
-        return $edits;
62
-    }
61
+		return $edits;
62
+	}
63 63
 
64 64
 }
Please login to merge, or discard this patch.
Switch Indentation   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -44,17 +44,17 @@
 block discarded – undo
44 44
                 continue;
45 45
             }
46 46
             switch ($line[0]) {
47
-            case ' ':
48
-                $edits[] = new Text_Diff_Op_copy(array(substr($line, 1)));
49
-                break;
47
+            	case ' ':
48
+                	$edits[] = new Text_Diff_Op_copy(array(substr($line, 1)));
49
+                	break;
50 50
 
51
-            case '+':
52
-                $edits[] = new Text_Diff_Op_add(array(substr($line, 1)));
53
-                break;
51
+            	case '+':
52
+                	$edits[] = new Text_Diff_Op_add(array(substr($line, 1)));
53
+                	break;
54 54
 
55
-            case '-':
56
-                $edits[] = new Text_Diff_Op_delete(array(substr($line, 1)));
57
-                break;
55
+            	case '-':
56
+                	$edits[] = new Text_Diff_Op_delete(array(substr($line, 1)));
57
+                	break;
58 58
             }
59 59
         }
60 60
 
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -40,7 +40,7 @@
 block discarded – undo
40 40
          * valid, albeit a little less descriptive and efficient. */
41 41
         $edits = array();
42 42
         foreach ($diff as $line) {
43
-            if (!strlen($line)) {
43
+            if ( ! strlen($line)) {
44 44
                 continue;
45 45
             }
46 46
             switch ($line[0]) {
Please login to merge, or discard this patch.
src/wp-includes/Text/Diff.php 2 patches
Indentation   +356 added lines, -356 removed lines patch added patch discarded remove patch
@@ -17,43 +17,43 @@  discard block
 block discarded – undo
17 17
  */
18 18
 class Text_Diff {
19 19
 
20
-    /**
21
-     * Array of changes.
22
-     *
23
-     * @var array
24
-     */
25
-    var $_edits;
26
-
27
-    /**
28
-     * Computes diffs between sequences of strings.
29
-     *
30
-     * @param string $engine     Name of the diffing engine to use.  'auto'
31
-     *                           will automatically select the best.
32
-     * @param array $params      Parameters to pass to the diffing engine.
33
-     *                           Normally an array of two arrays, each
34
-     *                           containing the lines from a file.
35
-     */
36
-    function __construct( $engine, $params )
37
-    {
38
-        // Backward compatibility workaround.
39
-        if (!is_string($engine)) {
40
-            $params = array($engine, $params);
41
-            $engine = 'auto';
42
-        }
43
-
44
-        if ($engine == 'auto') {
45
-            $engine = extension_loaded('xdiff') ? 'xdiff' : 'native';
46
-        } else {
47
-            $engine = basename($engine);
48
-        }
49
-
50
-        // WP #7391
51
-        require_once dirname(__FILE__).'/Diff/Engine/' . $engine . '.php';
52
-        $class = 'Text_Diff_Engine_' . $engine;
53
-        $diff_engine = new $class();
54
-
55
-        $this->_edits = call_user_func_array(array($diff_engine, 'diff'), $params);
56
-    }
20
+	/**
21
+	 * Array of changes.
22
+	 *
23
+	 * @var array
24
+	 */
25
+	var $_edits;
26
+
27
+	/**
28
+	 * Computes diffs between sequences of strings.
29
+	 *
30
+	 * @param string $engine     Name of the diffing engine to use.  'auto'
31
+	 *                           will automatically select the best.
32
+	 * @param array $params      Parameters to pass to the diffing engine.
33
+	 *                           Normally an array of two arrays, each
34
+	 *                           containing the lines from a file.
35
+	 */
36
+	function __construct( $engine, $params )
37
+	{
38
+		// Backward compatibility workaround.
39
+		if (!is_string($engine)) {
40
+			$params = array($engine, $params);
41
+			$engine = 'auto';
42
+		}
43
+
44
+		if ($engine == 'auto') {
45
+			$engine = extension_loaded('xdiff') ? 'xdiff' : 'native';
46
+		} else {
47
+			$engine = basename($engine);
48
+		}
49
+
50
+		// WP #7391
51
+		require_once dirname(__FILE__).'/Diff/Engine/' . $engine . '.php';
52
+		$class = 'Text_Diff_Engine_' . $engine;
53
+		$diff_engine = new $class();
54
+
55
+		$this->_edits = call_user_func_array(array($diff_engine, 'diff'), $params);
56
+	}
57 57
 
58 58
 	/**
59 59
 	 * PHP4 constructor.
@@ -62,230 +62,230 @@  discard block
 block discarded – undo
62 62
 		self::__construct( $engine, $params );
63 63
 	}
64 64
 
65
-    /**
66
-     * Returns the array of differences.
67
-     */
68
-    function getDiff()
69
-    {
70
-        return $this->_edits;
71
-    }
72
-
73
-    /**
74
-     * returns the number of new (added) lines in a given diff.
75
-     *
76
-     * @since Text_Diff 1.1.0
77
-     *
78
-     * @return integer The number of new lines
79
-     */
80
-    function countAddedLines()
81
-    {
82
-        $count = 0;
83
-        foreach ($this->_edits as $edit) {
84
-            if (is_a($edit, 'Text_Diff_Op_add') ||
85
-                is_a($edit, 'Text_Diff_Op_change')) {
86
-                $count += $edit->nfinal();
87
-            }
88
-        }
89
-        return $count;
90
-    }
91
-
92
-    /**
93
-     * Returns the number of deleted (removed) lines in a given diff.
94
-     *
95
-     * @since Text_Diff 1.1.0
96
-     *
97
-     * @return integer The number of deleted lines
98
-     */
99
-    function countDeletedLines()
100
-    {
101
-        $count = 0;
102
-        foreach ($this->_edits as $edit) {
103
-            if (is_a($edit, 'Text_Diff_Op_delete') ||
104
-                is_a($edit, 'Text_Diff_Op_change')) {
105
-                $count += $edit->norig();
106
-            }
107
-        }
108
-        return $count;
109
-    }
110
-
111
-    /**
112
-     * Computes a reversed diff.
113
-     *
114
-     * Example:
115
-     * <code>
116
-     * $diff = new Text_Diff($lines1, $lines2);
117
-     * $rev = $diff->reverse();
118
-     * </code>
119
-     *
120
-     * @return Text_Diff  A Diff object representing the inverse of the
121
-     *                    original diff.  Note that we purposely don't return a
122
-     *                    reference here, since this essentially is a clone()
123
-     *                    method.
124
-     */
125
-    function reverse()
126
-    {
127
-        if (version_compare(zend_version(), '2', '>')) {
128
-            $rev = clone($this);
129
-        } else {
130
-            $rev = $this;
131
-        }
132
-        $rev->_edits = array();
133
-        foreach ($this->_edits as $edit) {
134
-            $rev->_edits[] = $edit->reverse();
135
-        }
136
-        return $rev;
137
-    }
138
-
139
-    /**
140
-     * Checks for an empty diff.
141
-     *
142
-     * @return boolean  True if two sequences were identical.
143
-     */
144
-    function isEmpty()
145
-    {
146
-        foreach ($this->_edits as $edit) {
147
-            if (!is_a($edit, 'Text_Diff_Op_copy')) {
148
-                return false;
149
-            }
150
-        }
151
-        return true;
152
-    }
153
-
154
-    /**
155
-     * Computes the length of the Longest Common Subsequence (LCS).
156
-     *
157
-     * This is mostly for diagnostic purposes.
158
-     *
159
-     * @return integer  The length of the LCS.
160
-     */
161
-    function lcs()
162
-    {
163
-        $lcs = 0;
164
-        foreach ($this->_edits as $edit) {
165
-            if (is_a($edit, 'Text_Diff_Op_copy')) {
166
-                $lcs += count($edit->orig);
167
-            }
168
-        }
169
-        return $lcs;
170
-    }
171
-
172
-    /**
173
-     * Gets the original set of lines.
174
-     *
175
-     * This reconstructs the $from_lines parameter passed to the constructor.
176
-     *
177
-     * @return array  The original sequence of strings.
178
-     */
179
-    function getOriginal()
180
-    {
181
-        $lines = array();
182
-        foreach ($this->_edits as $edit) {
183
-            if ($edit->orig) {
184
-                array_splice($lines, count($lines), 0, $edit->orig);
185
-            }
186
-        }
187
-        return $lines;
188
-    }
189
-
190
-    /**
191
-     * Gets the final set of lines.
192
-     *
193
-     * This reconstructs the $to_lines parameter passed to the constructor.
194
-     *
195
-     * @return array  The sequence of strings.
196
-     */
197
-    function getFinal()
198
-    {
199
-        $lines = array();
200
-        foreach ($this->_edits as $edit) {
201
-            if ($edit->final) {
202
-                array_splice($lines, count($lines), 0, $edit->final);
203
-            }
204
-        }
205
-        return $lines;
206
-    }
207
-
208
-    /**
209
-     * Removes trailing newlines from a line of text. This is meant to be used
210
-     * with array_walk().
211
-     *
212
-     * @param string $line  The line to trim.
213
-     * @param integer $key  The index of the line in the array. Not used.
214
-     */
215
-    static function trimNewlines(&$line, $key)
216
-    {
217
-        $line = str_replace(array("\n", "\r"), '', $line);
218
-    }
219
-
220
-    /**
221
-     * Determines the location of the system temporary directory.
222
-     *
223
-     * @static
224
-     *
225
-     * @access protected
226
-     *
227
-     * @return string  A directory name which can be used for temp files.
228
-     *                 Returns false if one could not be found.
229
-     */
230
-    function _getTempDir()
231
-    {
232
-        $tmp_locations = array('/tmp', '/var/tmp', 'c:\WUTemp', 'c:\temp',
233
-                               'c:\windows\temp', 'c:\winnt\temp');
234
-
235
-        /* Try PHP's upload_tmp_dir directive. */
236
-        $tmp = ini_get('upload_tmp_dir');
237
-
238
-        /* Otherwise, try to determine the TMPDIR environment variable. */
239
-        if (!strlen($tmp)) {
240
-            $tmp = getenv('TMPDIR');
241
-        }
242
-
243
-        /* If we still cannot determine a value, then cycle through a list of
65
+	/**
66
+	 * Returns the array of differences.
67
+	 */
68
+	function getDiff()
69
+	{
70
+		return $this->_edits;
71
+	}
72
+
73
+	/**
74
+	 * returns the number of new (added) lines in a given diff.
75
+	 *
76
+	 * @since Text_Diff 1.1.0
77
+	 *
78
+	 * @return integer The number of new lines
79
+	 */
80
+	function countAddedLines()
81
+	{
82
+		$count = 0;
83
+		foreach ($this->_edits as $edit) {
84
+			if (is_a($edit, 'Text_Diff_Op_add') ||
85
+				is_a($edit, 'Text_Diff_Op_change')) {
86
+				$count += $edit->nfinal();
87
+			}
88
+		}
89
+		return $count;
90
+	}
91
+
92
+	/**
93
+	 * Returns the number of deleted (removed) lines in a given diff.
94
+	 *
95
+	 * @since Text_Diff 1.1.0
96
+	 *
97
+	 * @return integer The number of deleted lines
98
+	 */
99
+	function countDeletedLines()
100
+	{
101
+		$count = 0;
102
+		foreach ($this->_edits as $edit) {
103
+			if (is_a($edit, 'Text_Diff_Op_delete') ||
104
+				is_a($edit, 'Text_Diff_Op_change')) {
105
+				$count += $edit->norig();
106
+			}
107
+		}
108
+		return $count;
109
+	}
110
+
111
+	/**
112
+	 * Computes a reversed diff.
113
+	 *
114
+	 * Example:
115
+	 * <code>
116
+	 * $diff = new Text_Diff($lines1, $lines2);
117
+	 * $rev = $diff->reverse();
118
+	 * </code>
119
+	 *
120
+	 * @return Text_Diff  A Diff object representing the inverse of the
121
+	 *                    original diff.  Note that we purposely don't return a
122
+	 *                    reference here, since this essentially is a clone()
123
+	 *                    method.
124
+	 */
125
+	function reverse()
126
+	{
127
+		if (version_compare(zend_version(), '2', '>')) {
128
+			$rev = clone($this);
129
+		} else {
130
+			$rev = $this;
131
+		}
132
+		$rev->_edits = array();
133
+		foreach ($this->_edits as $edit) {
134
+			$rev->_edits[] = $edit->reverse();
135
+		}
136
+		return $rev;
137
+	}
138
+
139
+	/**
140
+	 * Checks for an empty diff.
141
+	 *
142
+	 * @return boolean  True if two sequences were identical.
143
+	 */
144
+	function isEmpty()
145
+	{
146
+		foreach ($this->_edits as $edit) {
147
+			if (!is_a($edit, 'Text_Diff_Op_copy')) {
148
+				return false;
149
+			}
150
+		}
151
+		return true;
152
+	}
153
+
154
+	/**
155
+	 * Computes the length of the Longest Common Subsequence (LCS).
156
+	 *
157
+	 * This is mostly for diagnostic purposes.
158
+	 *
159
+	 * @return integer  The length of the LCS.
160
+	 */
161
+	function lcs()
162
+	{
163
+		$lcs = 0;
164
+		foreach ($this->_edits as $edit) {
165
+			if (is_a($edit, 'Text_Diff_Op_copy')) {
166
+				$lcs += count($edit->orig);
167
+			}
168
+		}
169
+		return $lcs;
170
+	}
171
+
172
+	/**
173
+	 * Gets the original set of lines.
174
+	 *
175
+	 * This reconstructs the $from_lines parameter passed to the constructor.
176
+	 *
177
+	 * @return array  The original sequence of strings.
178
+	 */
179
+	function getOriginal()
180
+	{
181
+		$lines = array();
182
+		foreach ($this->_edits as $edit) {
183
+			if ($edit->orig) {
184
+				array_splice($lines, count($lines), 0, $edit->orig);
185
+			}
186
+		}
187
+		return $lines;
188
+	}
189
+
190
+	/**
191
+	 * Gets the final set of lines.
192
+	 *
193
+	 * This reconstructs the $to_lines parameter passed to the constructor.
194
+	 *
195
+	 * @return array  The sequence of strings.
196
+	 */
197
+	function getFinal()
198
+	{
199
+		$lines = array();
200
+		foreach ($this->_edits as $edit) {
201
+			if ($edit->final) {
202
+				array_splice($lines, count($lines), 0, $edit->final);
203
+			}
204
+		}
205
+		return $lines;
206
+	}
207
+
208
+	/**
209
+	 * Removes trailing newlines from a line of text. This is meant to be used
210
+	 * with array_walk().
211
+	 *
212
+	 * @param string $line  The line to trim.
213
+	 * @param integer $key  The index of the line in the array. Not used.
214
+	 */
215
+	static function trimNewlines(&$line, $key)
216
+	{
217
+		$line = str_replace(array("\n", "\r"), '', $line);
218
+	}
219
+
220
+	/**
221
+	 * Determines the location of the system temporary directory.
222
+	 *
223
+	 * @static
224
+	 *
225
+	 * @access protected
226
+	 *
227
+	 * @return string  A directory name which can be used for temp files.
228
+	 *                 Returns false if one could not be found.
229
+	 */
230
+	function _getTempDir()
231
+	{
232
+		$tmp_locations = array('/tmp', '/var/tmp', 'c:\WUTemp', 'c:\temp',
233
+							   'c:\windows\temp', 'c:\winnt\temp');
234
+
235
+		/* Try PHP's upload_tmp_dir directive. */
236
+		$tmp = ini_get('upload_tmp_dir');
237
+
238
+		/* Otherwise, try to determine the TMPDIR environment variable. */
239
+		if (!strlen($tmp)) {
240
+			$tmp = getenv('TMPDIR');
241
+		}
242
+
243
+		/* If we still cannot determine a value, then cycle through a list of
244 244
          * preset possibilities. */
245
-        while (!strlen($tmp) && count($tmp_locations)) {
246
-            $tmp_check = array_shift($tmp_locations);
247
-            if (@is_dir($tmp_check)) {
248
-                $tmp = $tmp_check;
249
-            }
250
-        }
251
-
252
-        /* If it is still empty, we have failed, so return false; otherwise
245
+		while (!strlen($tmp) && count($tmp_locations)) {
246
+			$tmp_check = array_shift($tmp_locations);
247
+			if (@is_dir($tmp_check)) {
248
+				$tmp = $tmp_check;
249
+			}
250
+		}
251
+
252
+		/* If it is still empty, we have failed, so return false; otherwise
253 253
          * return the directory determined. */
254
-        return strlen($tmp) ? $tmp : false;
255
-    }
256
-
257
-    /**
258
-     * Checks a diff for validity.
259
-     *
260
-     * This is here only for debugging purposes.
261
-     */
262
-    function _check($from_lines, $to_lines)
263
-    {
264
-        if (serialize($from_lines) != serialize($this->getOriginal())) {
265
-            trigger_error("Reconstructed original doesn't match", E_USER_ERROR);
266
-        }
267
-        if (serialize($to_lines) != serialize($this->getFinal())) {
268
-            trigger_error("Reconstructed final doesn't match", E_USER_ERROR);
269
-        }
270
-
271
-        $rev = $this->reverse();
272
-        if (serialize($to_lines) != serialize($rev->getOriginal())) {
273
-            trigger_error("Reversed original doesn't match", E_USER_ERROR);
274
-        }
275
-        if (serialize($from_lines) != serialize($rev->getFinal())) {
276
-            trigger_error("Reversed final doesn't match", E_USER_ERROR);
277
-        }
278
-
279
-        $prevtype = null;
280
-        foreach ($this->_edits as $edit) {
281
-            if ($prevtype == get_class($edit)) {
282
-                trigger_error("Edit sequence is non-optimal", E_USER_ERROR);
283
-            }
284
-            $prevtype = get_class($edit);
285
-        }
286
-
287
-        return true;
288
-    }
254
+		return strlen($tmp) ? $tmp : false;
255
+	}
256
+
257
+	/**
258
+	 * Checks a diff for validity.
259
+	 *
260
+	 * This is here only for debugging purposes.
261
+	 */
262
+	function _check($from_lines, $to_lines)
263
+	{
264
+		if (serialize($from_lines) != serialize($this->getOriginal())) {
265
+			trigger_error("Reconstructed original doesn't match", E_USER_ERROR);
266
+		}
267
+		if (serialize($to_lines) != serialize($this->getFinal())) {
268
+			trigger_error("Reconstructed final doesn't match", E_USER_ERROR);
269
+		}
270
+
271
+		$rev = $this->reverse();
272
+		if (serialize($to_lines) != serialize($rev->getOriginal())) {
273
+			trigger_error("Reversed original doesn't match", E_USER_ERROR);
274
+		}
275
+		if (serialize($from_lines) != serialize($rev->getFinal())) {
276
+			trigger_error("Reversed final doesn't match", E_USER_ERROR);
277
+		}
278
+
279
+		$prevtype = null;
280
+		foreach ($this->_edits as $edit) {
281
+			if ($prevtype == get_class($edit)) {
282
+				trigger_error("Edit sequence is non-optimal", E_USER_ERROR);
283
+			}
284
+			$prevtype = get_class($edit);
285
+		}
286
+
287
+		return true;
288
+	}
289 289
 
290 290
 }
291 291
 
@@ -295,53 +295,53 @@  discard block
 block discarded – undo
295 295
  */
296 296
 class Text_MappedDiff extends Text_Diff {
297 297
 
298
-    /**
299
-     * Computes a diff between sequences of strings.
300
-     *
301
-     * This can be used to compute things like case-insensitve diffs, or diffs
302
-     * which ignore changes in white-space.
303
-     *
304
-     * @param array $from_lines         An array of strings.
305
-     * @param array $to_lines           An array of strings.
306
-     * @param array $mapped_from_lines  This array should have the same size
307
-     *                                  number of elements as $from_lines.  The
308
-     *                                  elements in $mapped_from_lines and
309
-     *                                  $mapped_to_lines are what is actually
310
-     *                                  compared when computing the diff.
311
-     * @param array $mapped_to_lines    This array should have the same number
312
-     *                                  of elements as $to_lines.
313
-     */
314
-    function __construct($from_lines, $to_lines,
315
-                             $mapped_from_lines, $mapped_to_lines)
316
-    {
317
-        assert(count($from_lines) == count($mapped_from_lines));
318
-        assert(count($to_lines) == count($mapped_to_lines));
319
-
320
-        parent::Text_Diff($mapped_from_lines, $mapped_to_lines);
321
-
322
-        $xi = $yi = 0;
323
-        for ($i = 0; $i < count($this->_edits); $i++) {
324
-            $orig = &$this->_edits[$i]->orig;
325
-            if (is_array($orig)) {
326
-                $orig = array_slice($from_lines, $xi, count($orig));
327
-                $xi += count($orig);
328
-            }
329
-
330
-            $final = &$this->_edits[$i]->final;
331
-            if (is_array($final)) {
332
-                $final = array_slice($to_lines, $yi, count($final));
333
-                $yi += count($final);
334
-            }
335
-        }
336
-    }
298
+	/**
299
+	 * Computes a diff between sequences of strings.
300
+	 *
301
+	 * This can be used to compute things like case-insensitve diffs, or diffs
302
+	 * which ignore changes in white-space.
303
+	 *
304
+	 * @param array $from_lines         An array of strings.
305
+	 * @param array $to_lines           An array of strings.
306
+	 * @param array $mapped_from_lines  This array should have the same size
307
+	 *                                  number of elements as $from_lines.  The
308
+	 *                                  elements in $mapped_from_lines and
309
+	 *                                  $mapped_to_lines are what is actually
310
+	 *                                  compared when computing the diff.
311
+	 * @param array $mapped_to_lines    This array should have the same number
312
+	 *                                  of elements as $to_lines.
313
+	 */
314
+	function __construct($from_lines, $to_lines,
315
+							 $mapped_from_lines, $mapped_to_lines)
316
+	{
317
+		assert(count($from_lines) == count($mapped_from_lines));
318
+		assert(count($to_lines) == count($mapped_to_lines));
319
+
320
+		parent::Text_Diff($mapped_from_lines, $mapped_to_lines);
321
+
322
+		$xi = $yi = 0;
323
+		for ($i = 0; $i < count($this->_edits); $i++) {
324
+			$orig = &$this->_edits[$i]->orig;
325
+			if (is_array($orig)) {
326
+				$orig = array_slice($from_lines, $xi, count($orig));
327
+				$xi += count($orig);
328
+			}
329
+
330
+			$final = &$this->_edits[$i]->final;
331
+			if (is_array($final)) {
332
+				$final = array_slice($to_lines, $yi, count($final));
333
+				$yi += count($final);
334
+			}
335
+		}
336
+	}
337 337
 
338 338
 	/**
339 339
 	 * PHP4 constructor.
340 340
 	 */
341 341
 	public function Text_MappedDiff( $from_lines, $to_lines,
342
-                             $mapped_from_lines, $mapped_to_lines ) {
342
+							 $mapped_from_lines, $mapped_to_lines ) {
343 343
 		self::__construct( $from_lines, $to_lines,
344
-                             $mapped_from_lines, $mapped_to_lines );
344
+							 $mapped_from_lines, $mapped_to_lines );
345 345
 	}
346 346
 
347 347
 }
@@ -354,23 +354,23 @@  discard block
 block discarded – undo
354 354
  */
355 355
 class Text_Diff_Op {
356 356
 
357
-    var $orig;
358
-    var $final;
357
+	var $orig;
358
+	var $final;
359 359
 
360
-    function &reverse()
361
-    {
362
-        trigger_error('Abstract method', E_USER_ERROR);
363
-    }
360
+	function &reverse()
361
+	{
362
+		trigger_error('Abstract method', E_USER_ERROR);
363
+	}
364 364
 
365
-    function norig()
366
-    {
367
-        return $this->orig ? count($this->orig) : 0;
368
-    }
365
+	function norig()
366
+	{
367
+		return $this->orig ? count($this->orig) : 0;
368
+	}
369 369
 
370
-    function nfinal()
371
-    {
372
-        return $this->final ? count($this->final) : 0;
373
-    }
370
+	function nfinal()
371
+	{
372
+		return $this->final ? count($this->final) : 0;
373
+	}
374 374
 
375 375
 }
376 376
 
@@ -385,14 +385,14 @@  discard block
 block discarded – undo
385 385
 	/**
386 386
 	 * PHP5 constructor.
387 387
 	 */
388
-    function __construct( $orig, $final = false )
389
-    {
390
-        if (!is_array($final)) {
391
-            $final = $orig;
392
-        }
393
-        $this->orig = $orig;
394
-        $this->final = $final;
395
-    }
388
+	function __construct( $orig, $final = false )
389
+	{
390
+		if (!is_array($final)) {
391
+			$final = $orig;
392
+		}
393
+		$this->orig = $orig;
394
+		$this->final = $final;
395
+	}
396 396
 
397 397
 	/**
398 398
 	 * PHP4 constructor.
@@ -401,11 +401,11 @@  discard block
 block discarded – undo
401 401
 		self::__construct( $orig, $final );
402 402
 	}
403 403
 
404
-    function &reverse()
405
-    {
406
-        $reverse = new Text_Diff_Op_copy($this->final, $this->orig);
407
-        return $reverse;
408
-    }
404
+	function &reverse()
405
+	{
406
+		$reverse = new Text_Diff_Op_copy($this->final, $this->orig);
407
+		return $reverse;
408
+	}
409 409
 
410 410
 }
411 411
 
@@ -421,10 +421,10 @@  discard block
 block discarded – undo
421 421
 	 * PHP5 constructor.
422 422
 	 */
423 423
 	function __construct( $lines )
424
-    {
425
-        $this->orig = $lines;
426
-        $this->final = false;
427
-    }
424
+	{
425
+		$this->orig = $lines;
426
+		$this->final = false;
427
+	}
428 428
 
429 429
 	/**
430 430
 	 * PHP4 constructor.
@@ -433,11 +433,11 @@  discard block
 block discarded – undo
433 433
 		self::__construct( $lines );
434 434
 	}
435 435
 
436
-    function &reverse()
437
-    {
438
-        $reverse = new Text_Diff_Op_add($this->orig);
439
-        return $reverse;
440
-    }
436
+	function &reverse()
437
+	{
438
+		$reverse = new Text_Diff_Op_add($this->orig);
439
+		return $reverse;
440
+	}
441 441
 
442 442
 }
443 443
 
@@ -452,11 +452,11 @@  discard block
 block discarded – undo
452 452
 	/**
453 453
 	 * PHP5 constructor.
454 454
 	 */
455
-    function __construct( $lines )
456
-    {
457
-        $this->final = $lines;
458
-        $this->orig = false;
459
-    }
455
+	function __construct( $lines )
456
+	{
457
+		$this->final = $lines;
458
+		$this->orig = false;
459
+	}
460 460
 
461 461
 	/**
462 462
 	 * PHP4 constructor.
@@ -465,11 +465,11 @@  discard block
 block discarded – undo
465 465
 		self::__construct( $lines );
466 466
 	}
467 467
 
468
-    function &reverse()
469
-    {
470
-        $reverse = new Text_Diff_Op_delete($this->final);
471
-        return $reverse;
472
-    }
468
+	function &reverse()
469
+	{
470
+		$reverse = new Text_Diff_Op_delete($this->final);
471
+		return $reverse;
472
+	}
473 473
 
474 474
 }
475 475
 
@@ -484,11 +484,11 @@  discard block
 block discarded – undo
484 484
 	/**
485 485
 	 * PHP5 constructor.
486 486
 	 */
487
-    function __construct( $orig, $final )
488
-    {
489
-        $this->orig = $orig;
490
-        $this->final = $final;
491
-    }
487
+	function __construct( $orig, $final )
488
+	{
489
+		$this->orig = $orig;
490
+		$this->final = $final;
491
+	}
492 492
 
493 493
 	/**
494 494
 	 * PHP4 constructor.
@@ -497,10 +497,10 @@  discard block
 block discarded – undo
497 497
 		self::__construct( $orig, $final );
498 498
 	}
499 499
 
500
-    function &reverse()
501
-    {
502
-        $reverse = new Text_Diff_Op_change($this->final, $this->orig);
503
-        return $reverse;
504
-    }
500
+	function &reverse()
501
+	{
502
+		$reverse = new Text_Diff_Op_change($this->final, $this->orig);
503
+		return $reverse;
504
+	}
505 505
 
506 506
 }
Please login to merge, or discard this patch.
Spacing   +26 added lines, -26 removed lines patch added patch discarded remove patch
@@ -33,10 +33,10 @@  discard block
 block discarded – undo
33 33
      *                           Normally an array of two arrays, each
34 34
      *                           containing the lines from a file.
35 35
      */
36
-    function __construct( $engine, $params )
36
+    function __construct($engine, $params)
37 37
     {
38 38
         // Backward compatibility workaround.
39
-        if (!is_string($engine)) {
39
+        if ( ! is_string($engine)) {
40 40
             $params = array($engine, $params);
41 41
             $engine = 'auto';
42 42
         }
@@ -48,8 +48,8 @@  discard block
 block discarded – undo
48 48
         }
49 49
 
50 50
         // WP #7391
51
-        require_once dirname(__FILE__).'/Diff/Engine/' . $engine . '.php';
52
-        $class = 'Text_Diff_Engine_' . $engine;
51
+        require_once dirname(__FILE__).'/Diff/Engine/'.$engine.'.php';
52
+        $class = 'Text_Diff_Engine_'.$engine;
53 53
         $diff_engine = new $class();
54 54
 
55 55
         $this->_edits = call_user_func_array(array($diff_engine, 'diff'), $params);
@@ -58,8 +58,8 @@  discard block
 block discarded – undo
58 58
 	/**
59 59
 	 * PHP4 constructor.
60 60
 	 */
61
-	public function Text_Diff( $engine, $params ) {
62
-		self::__construct( $engine, $params );
61
+	public function Text_Diff($engine, $params) {
62
+		self::__construct($engine, $params);
63 63
 	}
64 64
 
65 65
     /**
@@ -144,7 +144,7 @@  discard block
 block discarded – undo
144 144
     function isEmpty()
145 145
     {
146 146
         foreach ($this->_edits as $edit) {
147
-            if (!is_a($edit, 'Text_Diff_Op_copy')) {
147
+            if ( ! is_a($edit, 'Text_Diff_Op_copy')) {
148 148
                 return false;
149 149
             }
150 150
         }
@@ -236,13 +236,13 @@  discard block
 block discarded – undo
236 236
         $tmp = ini_get('upload_tmp_dir');
237 237
 
238 238
         /* Otherwise, try to determine the TMPDIR environment variable. */
239
-        if (!strlen($tmp)) {
239
+        if ( ! strlen($tmp)) {
240 240
             $tmp = getenv('TMPDIR');
241 241
         }
242 242
 
243 243
         /* If we still cannot determine a value, then cycle through a list of
244 244
          * preset possibilities. */
245
-        while (!strlen($tmp) && count($tmp_locations)) {
245
+        while ( ! strlen($tmp) && count($tmp_locations)) {
246 246
             $tmp_check = array_shift($tmp_locations);
247 247
             if (@is_dir($tmp_check)) {
248 248
                 $tmp = $tmp_check;
@@ -338,10 +338,10 @@  discard block
 block discarded – undo
338 338
 	/**
339 339
 	 * PHP4 constructor.
340 340
 	 */
341
-	public function Text_MappedDiff( $from_lines, $to_lines,
342
-                             $mapped_from_lines, $mapped_to_lines ) {
343
-		self::__construct( $from_lines, $to_lines,
344
-                             $mapped_from_lines, $mapped_to_lines );
341
+	public function Text_MappedDiff($from_lines, $to_lines,
342
+                             $mapped_from_lines, $mapped_to_lines) {
343
+		self::__construct($from_lines, $to_lines,
344
+                             $mapped_from_lines, $mapped_to_lines);
345 345
 	}
346 346
 
347 347
 }
@@ -385,9 +385,9 @@  discard block
 block discarded – undo
385 385
 	/**
386 386
 	 * PHP5 constructor.
387 387
 	 */
388
-    function __construct( $orig, $final = false )
388
+    function __construct($orig, $final = false)
389 389
     {
390
-        if (!is_array($final)) {
390
+        if ( ! is_array($final)) {
391 391
             $final = $orig;
392 392
         }
393 393
         $this->orig = $orig;
@@ -397,8 +397,8 @@  discard block
 block discarded – undo
397 397
 	/**
398 398
 	 * PHP4 constructor.
399 399
 	 */
400
-	public function Text_Diff_Op_copy( $orig, $final = false ) {
401
-		self::__construct( $orig, $final );
400
+	public function Text_Diff_Op_copy($orig, $final = false) {
401
+		self::__construct($orig, $final);
402 402
 	}
403 403
 
404 404
     function &reverse()
@@ -420,7 +420,7 @@  discard block
 block discarded – undo
420 420
 	/**
421 421
 	 * PHP5 constructor.
422 422
 	 */
423
-	function __construct( $lines )
423
+	function __construct($lines)
424 424
     {
425 425
         $this->orig = $lines;
426 426
         $this->final = false;
@@ -429,8 +429,8 @@  discard block
 block discarded – undo
429 429
 	/**
430 430
 	 * PHP4 constructor.
431 431
 	 */
432
-	public function Text_Diff_Op_delete( $lines ) {
433
-		self::__construct( $lines );
432
+	public function Text_Diff_Op_delete($lines) {
433
+		self::__construct($lines);
434 434
 	}
435 435
 
436 436
     function &reverse()
@@ -452,7 +452,7 @@  discard block
 block discarded – undo
452 452
 	/**
453 453
 	 * PHP5 constructor.
454 454
 	 */
455
-    function __construct( $lines )
455
+    function __construct($lines)
456 456
     {
457 457
         $this->final = $lines;
458 458
         $this->orig = false;
@@ -461,8 +461,8 @@  discard block
 block discarded – undo
461 461
 	/**
462 462
 	 * PHP4 constructor.
463 463
 	 */
464
-	public function Text_Diff_Op_add( $lines ) {
465
-		self::__construct( $lines );
464
+	public function Text_Diff_Op_add($lines) {
465
+		self::__construct($lines);
466 466
 	}
467 467
 
468 468
     function &reverse()
@@ -484,7 +484,7 @@  discard block
 block discarded – undo
484 484
 	/**
485 485
 	 * PHP5 constructor.
486 486
 	 */
487
-    function __construct( $orig, $final )
487
+    function __construct($orig, $final)
488 488
     {
489 489
         $this->orig = $orig;
490 490
         $this->final = $final;
@@ -493,8 +493,8 @@  discard block
 block discarded – undo
493 493
 	/**
494 494
 	 * PHP4 constructor.
495 495
 	 */
496
-	public function Text_Diff_Op_change( $orig, $final ) {
497
-		self::__construct( $orig, $final );
496
+	public function Text_Diff_Op_change($orig, $final) {
497
+		self::__construct($orig, $final);
498 498
 	}
499 499
 
500 500
     function &reverse()
Please login to merge, or discard this patch.