Completed
Push — master ( cde0c6...d99bf9 )
by Stephen
15:46
created
src/wp-includes/cron.php 2 patches
Braces   +72 added lines, -47 removed lines patch added patch discarded remove patch
@@ -39,8 +39,9 @@  discard block
 block discarded – undo
39 39
 	$event = apply_filters( 'schedule_event', $event );
40 40
 
41 41
 	// A plugin disallowed this event
42
-	if ( ! $event )
43
-		return false;
42
+	if ( ! $event ) {
43
+			return false;
44
+	}
44 45
 
45 46
 	$key = md5(serialize($event->args));
46 47
 
@@ -73,16 +74,18 @@  discard block
 block discarded – undo
73 74
 	$crons = _get_cron_array();
74 75
 	$schedules = wp_get_schedules();
75 76
 
76
-	if ( !isset( $schedules[$recurrence] ) )
77
-		return false;
77
+	if ( !isset( $schedules[$recurrence] ) ) {
78
+			return false;
79
+	}
78 80
 
79 81
 	$event = (object) array( 'hook' => $hook, 'timestamp' => $timestamp, 'schedule' => $recurrence, 'args' => $args, 'interval' => $schedules[$recurrence]['interval'] );
80 82
 	/** This filter is documented in wp-includes/cron.php */
81 83
 	$event = apply_filters( 'schedule_event', $event );
82 84
 
83 85
 	// A plugin disallowed this event
84
-	if ( ! $event )
85
-		return false;
86
+	if ( ! $event ) {
87
+			return false;
88
+	}
86 89
 
87 90
 	$key = md5(serialize($event->args));
88 91
 
@@ -151,10 +154,12 @@  discard block
 block discarded – undo
151 154
 	$crons = _get_cron_array();
152 155
 	$key = md5(serialize($args));
153 156
 	unset( $crons[$timestamp][$hook][$key] );
154
-	if ( empty($crons[$timestamp][$hook]) )
155
-		unset( $crons[$timestamp][$hook] );
156
-	if ( empty($crons[$timestamp]) )
157
-		unset( $crons[$timestamp] );
157
+	if ( empty($crons[$timestamp][$hook]) ) {
158
+			unset( $crons[$timestamp][$hook] );
159
+	}
160
+	if ( empty($crons[$timestamp]) ) {
161
+			unset( $crons[$timestamp] );
162
+	}
158 163
 	_set_cron_array( $crons );
159 164
 }
160 165
 
@@ -178,8 +183,9 @@  discard block
 block discarded – undo
178 183
 	// It's required due to a scenario where wp_unschedule_event() fails due to update_option() failing,
179 184
 	// and, wp_next_scheduled() returns the same schedule in an infinite loop.
180 185
 	$crons = _get_cron_array();
181
-	if ( empty( $crons ) )
182
-		return;
186
+	if ( empty( $crons ) ) {
187
+			return;
188
+	}
183 189
 
184 190
 	$key = md5( serialize( $args ) );
185 191
 	foreach ( $crons as $timestamp => $cron ) {
@@ -201,11 +207,13 @@  discard block
 block discarded – undo
201 207
 function wp_next_scheduled( $hook, $args = array() ) {
202 208
 	$crons = _get_cron_array();
203 209
 	$key = md5(serialize($args));
204
-	if ( empty($crons) )
205
-		return false;
210
+	if ( empty($crons) ) {
211
+			return false;
212
+	}
206 213
 	foreach ( $crons as $timestamp => $cron ) {
207
-		if ( isset( $cron[$hook][$key] ) )
208
-			return $timestamp;
214
+		if ( isset( $cron[$hook][$key] ) ) {
215
+					return $timestamp;
216
+		}
209 217
 	}
210 218
 	return false;
211 219
 }
@@ -216,11 +224,13 @@  discard block
 block discarded – undo
216 224
  * @since 2.1.0
217 225
  */
218 226
 function spawn_cron( $gmt_time = 0 ) {
219
-	if ( ! $gmt_time )
220
-		$gmt_time = microtime( true );
227
+	if ( ! $gmt_time ) {
228
+			$gmt_time = microtime( true );
229
+	}
221 230
 
222
-	if ( defined('DOING_CRON') || isset($_GET['doing_wp_cron']) )
223
-		return;
231
+	if ( defined('DOING_CRON') || isset($_GET['doing_wp_cron']) ) {
232
+			return;
233
+	}
224 234
 
225 235
 	/*
226 236
 	 * Get the cron lock, which is a unix timestamp of when the last cron was spawned
@@ -231,21 +241,25 @@  discard block
 block discarded – undo
231 241
 	 */
232 242
 	$lock = get_transient('doing_cron');
233 243
 
234
-	if ( $lock > $gmt_time + 10 * MINUTE_IN_SECONDS )
235
-		$lock = 0;
244
+	if ( $lock > $gmt_time + 10 * MINUTE_IN_SECONDS ) {
245
+			$lock = 0;
246
+	}
236 247
 
237 248
 	// don't run if another process is currently running it or more than once every 60 sec.
238
-	if ( $lock + WP_CRON_LOCK_TIMEOUT > $gmt_time )
239
-		return;
249
+	if ( $lock + WP_CRON_LOCK_TIMEOUT > $gmt_time ) {
250
+			return;
251
+	}
240 252
 
241 253
 	//sanity check
242 254
 	$crons = _get_cron_array();
243
-	if ( !is_array($crons) )
244
-		return;
255
+	if ( !is_array($crons) ) {
256
+			return;
257
+	}
245 258
 
246 259
 	$keys = array_keys( $crons );
247
-	if ( isset($keys[0]) && $keys[0] > $gmt_time )
248
-		return;
260
+	if ( isset($keys[0]) && $keys[0] > $gmt_time ) {
261
+			return;
262
+	}
249 263
 
250 264
 	if ( defined( 'ALTERNATE_WP_CRON' ) && ALTERNATE_WP_CRON ) {
251 265
 		if ( ! empty( $_POST ) || defined( 'DOING_AJAX' ) ||  defined( 'XMLRPC_REQUEST' ) ) {
@@ -311,23 +325,29 @@  discard block
 block discarded – undo
311 325
  */
312 326
 function wp_cron() {
313 327
 	// Prevent infinite loops caused by lack of wp-cron.php
314
-	if ( strpos($_SERVER['REQUEST_URI'], '/wp-cron.php') !== false || ( defined('DISABLE_WP_CRON') && DISABLE_WP_CRON ) )
315
-		return;
328
+	if ( strpos($_SERVER['REQUEST_URI'], '/wp-cron.php') !== false || ( defined('DISABLE_WP_CRON') && DISABLE_WP_CRON ) ) {
329
+			return;
330
+	}
316 331
 
317
-	if ( false === $crons = _get_cron_array() )
318
-		return;
332
+	if ( false === $crons = _get_cron_array() ) {
333
+			return;
334
+	}
319 335
 
320 336
 	$gmt_time = microtime( true );
321 337
 	$keys = array_keys( $crons );
322
-	if ( isset($keys[0]) && $keys[0] > $gmt_time )
323
-		return;
338
+	if ( isset($keys[0]) && $keys[0] > $gmt_time ) {
339
+			return;
340
+	}
324 341
 
325 342
 	$schedules = wp_get_schedules();
326 343
 	foreach ( $crons as $timestamp => $cronhooks ) {
327
-		if ( $timestamp > $gmt_time ) break;
344
+		if ( $timestamp > $gmt_time ) {
345
+			break;
346
+		}
328 347
 		foreach ( (array) $cronhooks as $hook => $args ) {
329
-			if ( isset($schedules[$hook]['callback']) && !call_user_func( $schedules[$hook]['callback'] ) )
330
-				continue;
348
+			if ( isset($schedules[$hook]['callback']) && !call_user_func( $schedules[$hook]['callback'] ) ) {
349
+							continue;
350
+			}
331 351
 			spawn_cron( $gmt_time );
332 352
 			break 2;
333 353
 		}
@@ -392,11 +412,13 @@  discard block
 block discarded – undo
392 412
 function wp_get_schedule($hook, $args = array()) {
393 413
 	$crons = _get_cron_array();
394 414
 	$key = md5(serialize($args));
395
-	if ( empty($crons) )
396
-		return false;
415
+	if ( empty($crons) ) {
416
+			return false;
417
+	}
397 418
 	foreach ( $crons as $timestamp => $cron ) {
398
-		if ( isset( $cron[$hook][$key] ) )
399
-			return $cron[$hook][$key]['schedule'];
419
+		if ( isset( $cron[$hook][$key] ) ) {
420
+					return $cron[$hook][$key]['schedule'];
421
+		}
400 422
 	}
401 423
 	return false;
402 424
 }
@@ -415,11 +437,13 @@  discard block
 block discarded – undo
415 437
  */
416 438
 function _get_cron_array()  {
417 439
 	$cron = get_option('cron');
418
-	if ( ! is_array($cron) )
419
-		return false;
440
+	if ( ! is_array($cron) ) {
441
+			return false;
442
+	}
420 443
 
421
-	if ( !isset($cron['version']) )
422
-		$cron = _upgrade_cron_array($cron);
444
+	if ( !isset($cron['version']) ) {
445
+			$cron = _upgrade_cron_array($cron);
446
+	}
423 447
 
424 448
 	unset($cron['version']);
425 449
 
@@ -451,8 +475,9 @@  discard block
 block discarded – undo
451 475
  * @return array An upgraded Cron info array.
452 476
  */
453 477
 function _upgrade_cron_array($cron) {
454
-	if ( isset($cron['version']) && 2 == $cron['version'])
455
-		return $cron;
478
+	if ( isset($cron['version']) && 2 == $cron['version']) {
479
+			return $cron;
480
+	}
456 481
 
457 482
 	$new_cron = array();
458 483
 
Please login to merge, or discard this patch.
Spacing   +98 added lines, -98 removed lines patch added patch discarded remove patch
@@ -24,20 +24,20 @@  discard block
 block discarded – undo
24 24
  * @param array $args Optional. Arguments to pass to the hook's callback function.
25 25
  * @return false|void False when an event is not scheduled.
26 26
  */
27
-function wp_schedule_single_event( $timestamp, $hook, $args = array()) {
27
+function wp_schedule_single_event($timestamp, $hook, $args = array()) {
28 28
 	// Make sure timestamp is a positive integer
29
-	if ( ! is_numeric( $timestamp ) || $timestamp <= 0 ) {
29
+	if ( ! is_numeric($timestamp) || $timestamp <= 0) {
30 30
 		return false;
31 31
 	}
32 32
 
33 33
 	// Don't schedule a duplicate if there's already an identical event due within 10 minutes of it
34 34
 	$next = wp_next_scheduled($hook, $args);
35
-	if ( $next && abs( $next - $timestamp ) <= 10 * MINUTE_IN_SECONDS ) {
35
+	if ($next && abs($next - $timestamp) <= 10 * MINUTE_IN_SECONDS) {
36 36
 		return false;
37 37
 	}
38 38
 
39 39
 	$crons = _get_cron_array();
40
-	$event = (object) array( 'hook' => $hook, 'timestamp' => $timestamp, 'schedule' => false, 'args' => $args );
40
+	$event = (object) array('hook' => $hook, 'timestamp' => $timestamp, 'schedule' => false, 'args' => $args);
41 41
 	/**
42 42
 	 * Filters a single event before it is scheduled.
43 43
 	 *
@@ -45,17 +45,17 @@  discard block
 block discarded – undo
45 45
 	 *
46 46
 	 * @param object $event An object containing an event's data.
47 47
 	 */
48
-	$event = apply_filters( 'schedule_event', $event );
48
+	$event = apply_filters('schedule_event', $event);
49 49
 
50 50
 	// A plugin disallowed this event
51
-	if ( ! $event )
51
+	if ( ! $event)
52 52
 		return false;
53 53
 
54 54
 	$key = md5(serialize($event->args));
55 55
 
56
-	$crons[$event->timestamp][$event->hook][$key] = array( 'schedule' => $event->schedule, 'args' => $event->args );
57
-	uksort( $crons, "strnatcasecmp" );
58
-	_set_cron_array( $crons );
56
+	$crons[$event->timestamp][$event->hook][$key] = array('schedule' => $event->schedule, 'args' => $event->args);
57
+	uksort($crons, "strnatcasecmp");
58
+	_set_cron_array($crons);
59 59
 }
60 60
 
61 61
 /**
@@ -78,31 +78,31 @@  discard block
 block discarded – undo
78 78
  * @param array $args Optional. Arguments to pass to the hook's callback function.
79 79
  * @return false|void False when an event is not scheduled.
80 80
  */
81
-function wp_schedule_event( $timestamp, $recurrence, $hook, $args = array()) {
81
+function wp_schedule_event($timestamp, $recurrence, $hook, $args = array()) {
82 82
 	// Make sure timestamp is a positive integer
83
-	if ( ! is_numeric( $timestamp ) || $timestamp <= 0 ) {
83
+	if ( ! is_numeric($timestamp) || $timestamp <= 0) {
84 84
 		return false;
85 85
 	}
86 86
 
87 87
 	$crons = _get_cron_array();
88 88
 	$schedules = wp_get_schedules();
89 89
 
90
-	if ( !isset( $schedules[$recurrence] ) )
90
+	if ( ! isset($schedules[$recurrence]))
91 91
 		return false;
92 92
 
93
-	$event = (object) array( 'hook' => $hook, 'timestamp' => $timestamp, 'schedule' => $recurrence, 'args' => $args, 'interval' => $schedules[$recurrence]['interval'] );
93
+	$event = (object) array('hook' => $hook, 'timestamp' => $timestamp, 'schedule' => $recurrence, 'args' => $args, 'interval' => $schedules[$recurrence]['interval']);
94 94
 	/** This filter is documented in wp-includes/cron.php */
95
-	$event = apply_filters( 'schedule_event', $event );
95
+	$event = apply_filters('schedule_event', $event);
96 96
 
97 97
 	// A plugin disallowed this event
98
-	if ( ! $event )
98
+	if ( ! $event)
99 99
 		return false;
100 100
 
101 101
 	$key = md5(serialize($event->args));
102 102
 
103
-	$crons[$event->timestamp][$event->hook][$key] = array( 'schedule' => $event->schedule, 'args' => $event->args, 'interval' => $event->interval );
104
-	uksort( $crons, "strnatcasecmp" );
105
-	_set_cron_array( $crons );
103
+	$crons[$event->timestamp][$event->hook][$key] = array('schedule' => $event->schedule, 'args' => $event->args, 'interval' => $event->interval);
104
+	uksort($crons, "strnatcasecmp");
105
+	_set_cron_array($crons);
106 106
 }
107 107
 
108 108
 /**
@@ -116,39 +116,39 @@  discard block
 block discarded – undo
116 116
  * @param array $args Optional. Arguments to pass to the hook's callback function.
117 117
  * @return false|void False when an event is not scheduled.
118 118
  */
119
-function wp_reschedule_event( $timestamp, $recurrence, $hook, $args = array() ) {
119
+function wp_reschedule_event($timestamp, $recurrence, $hook, $args = array()) {
120 120
 	// Make sure timestamp is a positive integer
121
-	if ( ! is_numeric( $timestamp ) || $timestamp <= 0 ) {
121
+	if ( ! is_numeric($timestamp) || $timestamp <= 0) {
122 122
 		return false;
123 123
 	}
124 124
 
125 125
 	$crons = _get_cron_array();
126 126
 	$schedules = wp_get_schedules();
127
-	$key = md5( serialize( $args ) );
127
+	$key = md5(serialize($args));
128 128
 	$interval = 0;
129 129
 
130 130
 	// First we try to get it from the schedule
131
-	if ( isset( $schedules[ $recurrence ] ) ) {
132
-		$interval = $schedules[ $recurrence ]['interval'];
131
+	if (isset($schedules[$recurrence])) {
132
+		$interval = $schedules[$recurrence]['interval'];
133 133
 	}
134 134
 	// Now we try to get it from the saved interval in case the schedule disappears
135
-	if ( 0 == $interval ) {
136
-		$interval = $crons[ $timestamp ][ $hook ][ $key ]['interval'];
135
+	if (0 == $interval) {
136
+		$interval = $crons[$timestamp][$hook][$key]['interval'];
137 137
 	}
138 138
 	// Now we assume something is wrong and fail to schedule
139
-	if ( 0 == $interval ) {
139
+	if (0 == $interval) {
140 140
 		return false;
141 141
 	}
142 142
 
143 143
 	$now = time();
144 144
 
145
-	if ( $timestamp >= $now ) {
145
+	if ($timestamp >= $now) {
146 146
 		$timestamp = $now + $interval;
147 147
 	} else {
148
-		$timestamp = $now + ( $interval - ( ( $now - $timestamp ) % $interval ) );
148
+		$timestamp = $now + ($interval - (($now - $timestamp) % $interval));
149 149
 	}
150 150
 
151
-	wp_schedule_event( $timestamp, $recurrence, $hook, $args );
151
+	wp_schedule_event($timestamp, $recurrence, $hook, $args);
152 152
 }
153 153
 
154 154
 /**
@@ -167,20 +167,20 @@  discard block
 block discarded – undo
167 167
  * as those used when originally scheduling the event.
168 168
  * @return false|void False when an event is not unscheduled.
169 169
  */
170
-function wp_unschedule_event( $timestamp, $hook, $args = array() ) {
170
+function wp_unschedule_event($timestamp, $hook, $args = array()) {
171 171
 	// Make sure timestamp is a positive integer
172
-	if ( ! is_numeric( $timestamp ) || $timestamp <= 0 ) {
172
+	if ( ! is_numeric($timestamp) || $timestamp <= 0) {
173 173
 		return false;
174 174
 	}
175 175
 
176 176
 	$crons = _get_cron_array();
177 177
 	$key = md5(serialize($args));
178
-	unset( $crons[$timestamp][$hook][$key] );
179
-	if ( empty($crons[$timestamp][$hook]) )
180
-		unset( $crons[$timestamp][$hook] );
181
-	if ( empty($crons[$timestamp]) )
182
-		unset( $crons[$timestamp] );
183
-	_set_cron_array( $crons );
178
+	unset($crons[$timestamp][$hook][$key]);
179
+	if (empty($crons[$timestamp][$hook]))
180
+		unset($crons[$timestamp][$hook]);
181
+	if (empty($crons[$timestamp]))
182
+		unset($crons[$timestamp]);
183
+	_set_cron_array($crons);
184 184
 }
185 185
 
186 186
 /**
@@ -191,25 +191,25 @@  discard block
 block discarded – undo
191 191
  * @param string $hook Action hook, the execution of which will be unscheduled.
192 192
  * @param array $args Optional. Arguments that were to be pass to the hook's callback function.
193 193
  */
194
-function wp_clear_scheduled_hook( $hook, $args = array() ) {
194
+function wp_clear_scheduled_hook($hook, $args = array()) {
195 195
 	// Backward compatibility
196 196
 	// Previously this function took the arguments as discrete vars rather than an array like the rest of the API
197
-	if ( !is_array($args) ) {
198
-		_deprecated_argument( __FUNCTION__, '3.0.0', __('This argument has changed to an array to match the behavior of the other cron functions.') );
199
-		$args = array_slice( func_get_args(), 1 );
197
+	if ( ! is_array($args)) {
198
+		_deprecated_argument(__FUNCTION__, '3.0.0', __('This argument has changed to an array to match the behavior of the other cron functions.'));
199
+		$args = array_slice(func_get_args(), 1);
200 200
 	}
201 201
 
202 202
 	// This logic duplicates wp_next_scheduled()
203 203
 	// It's required due to a scenario where wp_unschedule_event() fails due to update_option() failing,
204 204
 	// and, wp_next_scheduled() returns the same schedule in an infinite loop.
205 205
 	$crons = _get_cron_array();
206
-	if ( empty( $crons ) )
206
+	if (empty($crons))
207 207
 		return;
208 208
 
209
-	$key = md5( serialize( $args ) );
210
-	foreach ( $crons as $timestamp => $cron ) {
211
-		if ( isset( $cron[ $hook ][ $key ] ) ) {
212
-			wp_unschedule_event( $timestamp, $hook, $args );
209
+	$key = md5(serialize($args));
210
+	foreach ($crons as $timestamp => $cron) {
211
+		if (isset($cron[$hook][$key])) {
212
+			wp_unschedule_event($timestamp, $hook, $args);
213 213
 		}
214 214
 	}
215 215
 }
@@ -223,13 +223,13 @@  discard block
 block discarded – undo
223 223
  * @param array $args Optional. Arguments to pass to the hook's callback function.
224 224
  * @return false|int The UNIX timestamp of the next time the scheduled event will occur.
225 225
  */
226
-function wp_next_scheduled( $hook, $args = array() ) {
226
+function wp_next_scheduled($hook, $args = array()) {
227 227
 	$crons = _get_cron_array();
228 228
 	$key = md5(serialize($args));
229
-	if ( empty($crons) )
229
+	if (empty($crons))
230 230
 		return false;
231
-	foreach ( $crons as $timestamp => $cron ) {
232
-		if ( isset( $cron[$hook][$key] ) )
231
+	foreach ($crons as $timestamp => $cron) {
232
+		if (isset($cron[$hook][$key]))
233 233
 			return $timestamp;
234 234
 	}
235 235
 	return false;
@@ -242,11 +242,11 @@  discard block
 block discarded – undo
242 242
  *
243 243
  * @param int $gmt_time Optional. Unix timestamp. Default 0 (current time is used).
244 244
  */
245
-function spawn_cron( $gmt_time = 0 ) {
246
-	if ( ! $gmt_time )
247
-		$gmt_time = microtime( true );
245
+function spawn_cron($gmt_time = 0) {
246
+	if ( ! $gmt_time)
247
+		$gmt_time = microtime(true);
248 248
 
249
-	if ( defined('DOING_CRON') || isset($_GET['doing_wp_cron']) )
249
+	if (defined('DOING_CRON') || isset($_GET['doing_wp_cron']))
250 250
 		return;
251 251
 
252 252
 	/*
@@ -258,45 +258,45 @@  discard block
 block discarded – undo
258 258
 	 */
259 259
 	$lock = get_transient('doing_cron');
260 260
 
261
-	if ( $lock > $gmt_time + 10 * MINUTE_IN_SECONDS )
261
+	if ($lock > $gmt_time + 10 * MINUTE_IN_SECONDS)
262 262
 		$lock = 0;
263 263
 
264 264
 	// don't run if another process is currently running it or more than once every 60 sec.
265
-	if ( $lock + WP_CRON_LOCK_TIMEOUT > $gmt_time )
265
+	if ($lock + WP_CRON_LOCK_TIMEOUT > $gmt_time)
266 266
 		return;
267 267
 
268 268
 	//sanity check
269 269
 	$crons = _get_cron_array();
270
-	if ( !is_array($crons) )
270
+	if ( ! is_array($crons))
271 271
 		return;
272 272
 
273
-	$keys = array_keys( $crons );
274
-	if ( isset($keys[0]) && $keys[0] > $gmt_time )
273
+	$keys = array_keys($crons);
274
+	if (isset($keys[0]) && $keys[0] > $gmt_time)
275 275
 		return;
276 276
 
277
-	if ( defined( 'ALTERNATE_WP_CRON' ) && ALTERNATE_WP_CRON ) {
278
-		if ( 'GET' !== $_SERVER['REQUEST_METHOD'] || defined( 'DOING_AJAX' ) ||  defined( 'XMLRPC_REQUEST' ) ) {
277
+	if (defined('ALTERNATE_WP_CRON') && ALTERNATE_WP_CRON) {
278
+		if ('GET' !== $_SERVER['REQUEST_METHOD'] || defined('DOING_AJAX') || defined('XMLRPC_REQUEST')) {
279 279
 			return;
280 280
 		}
281 281
 
282
-		$doing_wp_cron = sprintf( '%.22F', $gmt_time );
283
-		set_transient( 'doing_cron', $doing_wp_cron );
282
+		$doing_wp_cron = sprintf('%.22F', $gmt_time);
283
+		set_transient('doing_cron', $doing_wp_cron);
284 284
 
285 285
 		ob_start();
286
-		wp_redirect( add_query_arg( 'doing_wp_cron', $doing_wp_cron, wp_unslash( $_SERVER['REQUEST_URI'] ) ) );
286
+		wp_redirect(add_query_arg('doing_wp_cron', $doing_wp_cron, wp_unslash($_SERVER['REQUEST_URI'])));
287 287
 		echo ' ';
288 288
 
289 289
 		// flush any buffers and send the headers
290
-		while ( @ob_end_flush() );
290
+		while (@ob_end_flush());
291 291
 		flush();
292 292
 
293
-		WP_DEBUG ? include_once( ABSPATH . 'wp-cron.php' ) : @include_once( ABSPATH . 'wp-cron.php' );
293
+		WP_DEBUG ? include_once(ABSPATH.'wp-cron.php') : @include_once(ABSPATH.'wp-cron.php');
294 294
 		return;
295 295
 	}
296 296
 
297 297
 	// Set the cron lock with the current unix timestamp, when the cron is being spawned.
298
-	$doing_wp_cron = sprintf( '%.22F', $gmt_time );
299
-	set_transient( 'doing_cron', $doing_wp_cron );
298
+	$doing_wp_cron = sprintf('%.22F', $gmt_time);
299
+	set_transient('doing_cron', $doing_wp_cron);
300 300
 
301 301
 	/**
302 302
 	 * Filters the cron request arguments.
@@ -319,18 +319,18 @@  discard block
 block discarded – undo
319 319
 	 * }
320 320
 	 * @param string $doing_wp_cron The unix timestamp of the cron lock.
321 321
 	 */
322
-	$cron_request = apply_filters( 'cron_request', array(
323
-		'url'  => add_query_arg( 'doing_wp_cron', $doing_wp_cron, site_url( 'wp-cron.php' ) ),
322
+	$cron_request = apply_filters('cron_request', array(
323
+		'url'  => add_query_arg('doing_wp_cron', $doing_wp_cron, site_url('wp-cron.php')),
324 324
 		'key'  => $doing_wp_cron,
325 325
 		'args' => array(
326 326
 			'timeout'   => 0.01,
327 327
 			'blocking'  => false,
328 328
 			/** This filter is documented in wp-includes/class-wp-http-streams.php */
329
-			'sslverify' => apply_filters( 'https_local_ssl_verify', false )
329
+			'sslverify' => apply_filters('https_local_ssl_verify', false)
330 330
 		)
331
-	), $doing_wp_cron );
331
+	), $doing_wp_cron);
332 332
 
333
-	wp_remote_post( $cron_request['url'], $cron_request['args'] );
333
+	wp_remote_post($cron_request['url'], $cron_request['args']);
334 334
 }
335 335
 
336 336
 /**
@@ -340,24 +340,24 @@  discard block
 block discarded – undo
340 340
  */
341 341
 function wp_cron() {
342 342
 	// Prevent infinite loops caused by lack of wp-cron.php
343
-	if ( strpos($_SERVER['REQUEST_URI'], '/wp-cron.php') !== false || ( defined('DISABLE_WP_CRON') && DISABLE_WP_CRON ) )
343
+	if (strpos($_SERVER['REQUEST_URI'], '/wp-cron.php') !== false || (defined('DISABLE_WP_CRON') && DISABLE_WP_CRON))
344 344
 		return;
345 345
 
346
-	if ( false === $crons = _get_cron_array() )
346
+	if (false === $crons = _get_cron_array())
347 347
 		return;
348 348
 
349
-	$gmt_time = microtime( true );
350
-	$keys = array_keys( $crons );
351
-	if ( isset($keys[0]) && $keys[0] > $gmt_time )
349
+	$gmt_time = microtime(true);
350
+	$keys = array_keys($crons);
351
+	if (isset($keys[0]) && $keys[0] > $gmt_time)
352 352
 		return;
353 353
 
354 354
 	$schedules = wp_get_schedules();
355
-	foreach ( $crons as $timestamp => $cronhooks ) {
356
-		if ( $timestamp > $gmt_time ) break;
357
-		foreach ( (array) $cronhooks as $hook => $args ) {
358
-			if ( isset($schedules[$hook]['callback']) && !call_user_func( $schedules[$hook]['callback'] ) )
355
+	foreach ($crons as $timestamp => $cronhooks) {
356
+		if ($timestamp > $gmt_time) break;
357
+		foreach ((array) $cronhooks as $hook => $args) {
358
+			if (isset($schedules[$hook]['callback']) && ! call_user_func($schedules[$hook]['callback']))
359 359
 				continue;
360
-			spawn_cron( $gmt_time );
360
+			spawn_cron($gmt_time);
361 361
 			break 2;
362 362
 		}
363 363
 	}
@@ -395,9 +395,9 @@  discard block
 block discarded – undo
395 395
  */
396 396
 function wp_get_schedules() {
397 397
 	$schedules = array(
398
-		'hourly'     => array( 'interval' => HOUR_IN_SECONDS,      'display' => __( 'Once Hourly' ) ),
399
-		'twicedaily' => array( 'interval' => 12 * HOUR_IN_SECONDS, 'display' => __( 'Twice Daily' ) ),
400
-		'daily'      => array( 'interval' => DAY_IN_SECONDS,       'display' => __( 'Once Daily' ) ),
398
+		'hourly'     => array('interval' => HOUR_IN_SECONDS, 'display' => __('Once Hourly')),
399
+		'twicedaily' => array('interval' => 12 * HOUR_IN_SECONDS, 'display' => __('Twice Daily')),
400
+		'daily'      => array('interval' => DAY_IN_SECONDS, 'display' => __('Once Daily')),
401 401
 	);
402 402
 	/**
403 403
 	 * Filters the non-default cron schedules.
@@ -406,7 +406,7 @@  discard block
 block discarded – undo
406 406
 	 *
407 407
 	 * @param array $new_schedules An array of non-default cron schedules. Default empty.
408 408
 	 */
409
-	return array_merge( apply_filters( 'cron_schedules', array() ), $schedules );
409
+	return array_merge(apply_filters('cron_schedules', array()), $schedules);
410 410
 }
411 411
 
412 412
 /**
@@ -421,10 +421,10 @@  discard block
 block discarded – undo
421 421
 function wp_get_schedule($hook, $args = array()) {
422 422
 	$crons = _get_cron_array();
423 423
 	$key = md5(serialize($args));
424
-	if ( empty($crons) )
424
+	if (empty($crons))
425 425
 		return false;
426
-	foreach ( $crons as $timestamp => $cron ) {
427
-		if ( isset( $cron[$hook][$key] ) )
426
+	foreach ($crons as $timestamp => $cron) {
427
+		if (isset($cron[$hook][$key]))
428 428
 			return $cron[$hook][$key]['schedule'];
429 429
 	}
430 430
 	return false;
@@ -442,12 +442,12 @@  discard block
 block discarded – undo
442 442
  *
443 443
  * @return false|array CRON info array.
444 444
  */
445
-function _get_cron_array()  {
445
+function _get_cron_array() {
446 446
 	$cron = get_option('cron');
447
-	if ( ! is_array($cron) )
447
+	if ( ! is_array($cron))
448 448
 		return false;
449 449
 
450
-	if ( !isset($cron['version']) )
450
+	if ( ! isset($cron['version']))
451 451
 		$cron = _upgrade_cron_array($cron);
452 452
 
453 453
 	unset($cron['version']);
@@ -465,7 +465,7 @@  discard block
 block discarded – undo
465 465
  */
466 466
 function _set_cron_array($cron) {
467 467
 	$cron['version'] = 2;
468
-	update_option( 'cron', $cron );
468
+	update_option('cron', $cron);
469 469
 }
470 470
 
471 471
 /**
@@ -480,19 +480,19 @@  discard block
 block discarded – undo
480 480
  * @return array An upgraded Cron info array.
481 481
  */
482 482
 function _upgrade_cron_array($cron) {
483
-	if ( isset($cron['version']) && 2 == $cron['version'])
483
+	if (isset($cron['version']) && 2 == $cron['version'])
484 484
 		return $cron;
485 485
 
486 486
 	$new_cron = array();
487 487
 
488
-	foreach ( (array) $cron as $timestamp => $hooks) {
489
-		foreach ( (array) $hooks as $hook => $args ) {
488
+	foreach ((array) $cron as $timestamp => $hooks) {
489
+		foreach ((array) $hooks as $hook => $args) {
490 490
 			$key = md5(serialize($args['args']));
491 491
 			$new_cron[$timestamp][$hook][$key] = $args;
492 492
 		}
493 493
 	}
494 494
 
495 495
 	$new_cron['version'] = 2;
496
-	update_option( 'cron', $new_cron );
496
+	update_option('cron', $new_cron);
497 497
 	return $new_cron;
498 498
 }
Please login to merge, or discard this patch.
src/wp-includes/ms-default-filters.php 2 patches
Braces   +10 added lines, -4 removed lines patch added patch discarded remove patch
@@ -49,10 +49,12 @@  discard block
 block discarded – undo
49 49
 // Counts
50 50
 add_action( 'admin_init', 'wp_schedule_update_network_counts');
51 51
 add_action( 'update_network_counts', 'wp_update_network_counts');
52
-foreach ( array( 'user_register', 'deleted_user', 'wpmu_new_user', 'make_spam_user', 'make_ham_user' ) as $action )
52
+foreach ( array( 'user_register', 'deleted_user', 'wpmu_new_user', 'make_spam_user', 'make_ham_user' ) as $action ) {
53 53
 	add_action( $action, 'wp_maybe_update_network_user_counts' );
54
-foreach ( array( 'make_spam_blog', 'make_ham_blog', 'archive_blog', 'unarchive_blog', 'make_delete_blog', 'make_undelete_blog' ) as $action )
54
+}
55
+foreach ( array( 'make_spam_blog', 'make_ham_blog', 'archive_blog', 'unarchive_blog', 'make_delete_blog', 'make_undelete_blog' ) as $action ) {
55 56
 	add_action( $action, 'wp_maybe_update_network_site_counts' );
57
+}
56 58
 unset( $action );
57 59
 
58 60
 // Files
@@ -67,10 +69,14 @@  discard block
 block discarded – undo
67 69
 
68 70
 // Disable somethings by default for multisite
69 71
 add_filter( 'enable_update_services_configuration', '__return_false' );
70
-if ( ! defined('POST_BY_EMAIL') || ! POST_BY_EMAIL ) // back compat constant.
72
+if ( ! defined('POST_BY_EMAIL') || ! POST_BY_EMAIL ) {
73
+	// back compat constant.
71 74
 	add_filter( 'enable_post_by_email_configuration', '__return_false' );
72
-if ( ! defined('EDIT_ANY_USER') || ! EDIT_ANY_USER ) // back compat constant.
75
+}
76
+if ( ! defined('EDIT_ANY_USER') || ! EDIT_ANY_USER ) {
77
+	// back compat constant.
73 78
 	add_filter( 'enable_edit_any_user_configuration', '__return_false' );
79
+}
74 80
 add_filter( 'force_filtered_html_on_import', '__return_true' );
75 81
 
76 82
 // WP_HOME and WP_SITEURL should not have any effect in MS
Please login to merge, or discard this patch.
Spacing   +53 added lines, -53 removed lines patch added patch discarded remove patch
@@ -13,84 +13,84 @@
 block discarded – undo
13 13
  * @since 3.0.0
14 14
  */
15 15
 
16
-add_action( 'init', 'ms_subdomain_constants' );
16
+add_action('init', 'ms_subdomain_constants');
17 17
 
18 18
 // Functions
19
-add_action( 'update_option_blog_public', 'update_blog_public', 10, 2 );
20
-add_filter( 'option_users_can_register', 'users_can_register_signup_filter' );
21
-add_filter( 'site_option_welcome_user_email', 'welcome_user_msg_filter' );
19
+add_action('update_option_blog_public', 'update_blog_public', 10, 2);
20
+add_filter('option_users_can_register', 'users_can_register_signup_filter');
21
+add_filter('site_option_welcome_user_email', 'welcome_user_msg_filter');
22 22
 
23 23
 // Users
24
-add_filter( 'wpmu_validate_user_signup', 'signup_nonce_check' );
25
-add_action( 'init', 'maybe_add_existing_user_to_blog' );
26
-add_action( 'wpmu_new_user', 'newuser_notify_siteadmin' );
27
-add_action( 'wpmu_activate_user', 'add_new_user_to_blog', 10, 3 );
28
-add_action( 'wpmu_activate_user', 'wpmu_welcome_user_notification', 10, 3 );
29
-add_action( 'after_signup_user', 'wpmu_signup_user_notification', 10, 4 );
30
-add_action( 'network_site_new_created_user',   'wp_send_new_user_notifications' );
31
-add_action( 'network_site_users_created_user', 'wp_send_new_user_notifications' );
32
-add_action( 'network_user_new_created_user',   'wp_send_new_user_notifications' );
33
-add_filter( 'sanitize_user', 'strtolower' );
24
+add_filter('wpmu_validate_user_signup', 'signup_nonce_check');
25
+add_action('init', 'maybe_add_existing_user_to_blog');
26
+add_action('wpmu_new_user', 'newuser_notify_siteadmin');
27
+add_action('wpmu_activate_user', 'add_new_user_to_blog', 10, 3);
28
+add_action('wpmu_activate_user', 'wpmu_welcome_user_notification', 10, 3);
29
+add_action('after_signup_user', 'wpmu_signup_user_notification', 10, 4);
30
+add_action('network_site_new_created_user', 'wp_send_new_user_notifications');
31
+add_action('network_site_users_created_user', 'wp_send_new_user_notifications');
32
+add_action('network_user_new_created_user', 'wp_send_new_user_notifications');
33
+add_filter('sanitize_user', 'strtolower');
34 34
 
35 35
 // Blogs
36
-add_filter( 'wpmu_validate_blog_signup', 'signup_nonce_check' );
37
-add_action( 'wpmu_new_blog', 'wpmu_log_new_registrations', 10, 2 );
38
-add_action( 'wpmu_new_blog', 'newblog_notify_siteadmin', 10, 2 );
39
-add_action( 'wpmu_activate_blog', 'wpmu_welcome_notification', 10, 5 );
40
-add_action( 'after_signup_site', 'wpmu_signup_blog_notification', 10, 7 );
36
+add_filter('wpmu_validate_blog_signup', 'signup_nonce_check');
37
+add_action('wpmu_new_blog', 'wpmu_log_new_registrations', 10, 2);
38
+add_action('wpmu_new_blog', 'newblog_notify_siteadmin', 10, 2);
39
+add_action('wpmu_activate_blog', 'wpmu_welcome_notification', 10, 5);
40
+add_action('after_signup_site', 'wpmu_signup_blog_notification', 10, 7);
41 41
 
42 42
 // Register Nonce
43
-add_action( 'signup_hidden_fields', 'signup_nonce_fields' );
43
+add_action('signup_hidden_fields', 'signup_nonce_fields');
44 44
 
45 45
 // Template
46
-add_action( 'template_redirect', 'maybe_redirect_404' );
47
-add_filter( 'allowed_redirect_hosts', 'redirect_this_site' );
46
+add_action('template_redirect', 'maybe_redirect_404');
47
+add_filter('allowed_redirect_hosts', 'redirect_this_site');
48 48
 
49 49
 // Administration
50
-add_filter( 'term_id_filter', 'global_terms', 10, 2 );
51
-add_action( 'delete_post', '_update_posts_count_on_delete' );
52
-add_action( 'delete_post', '_update_blog_date_on_post_delete' );
53
-add_action( 'transition_post_status', '_update_blog_date_on_post_publish', 10, 3 );
54
-add_action( 'transition_post_status', '_update_posts_count_on_transition_post_status', 10, 2 );
50
+add_filter('term_id_filter', 'global_terms', 10, 2);
51
+add_action('delete_post', '_update_posts_count_on_delete');
52
+add_action('delete_post', '_update_blog_date_on_post_delete');
53
+add_action('transition_post_status', '_update_blog_date_on_post_publish', 10, 3);
54
+add_action('transition_post_status', '_update_posts_count_on_transition_post_status', 10, 2);
55 55
 
56 56
 // Counts
57
-add_action( 'admin_init', 'wp_schedule_update_network_counts');
58
-add_action( 'update_network_counts', 'wp_update_network_counts');
59
-foreach ( array( 'user_register', 'deleted_user', 'wpmu_new_user', 'make_spam_user', 'make_ham_user' ) as $action )
60
-	add_action( $action, 'wp_maybe_update_network_user_counts' );
61
-foreach ( array( 'make_spam_blog', 'make_ham_blog', 'archive_blog', 'unarchive_blog', 'make_delete_blog', 'make_undelete_blog' ) as $action )
62
-	add_action( $action, 'wp_maybe_update_network_site_counts' );
63
-unset( $action );
57
+add_action('admin_init', 'wp_schedule_update_network_counts');
58
+add_action('update_network_counts', 'wp_update_network_counts');
59
+foreach (array('user_register', 'deleted_user', 'wpmu_new_user', 'make_spam_user', 'make_ham_user') as $action)
60
+	add_action($action, 'wp_maybe_update_network_user_counts');
61
+foreach (array('make_spam_blog', 'make_ham_blog', 'archive_blog', 'unarchive_blog', 'make_delete_blog', 'make_undelete_blog') as $action)
62
+	add_action($action, 'wp_maybe_update_network_site_counts');
63
+unset($action);
64 64
 
65 65
 // Files
66
-add_filter( 'wp_upload_bits', 'upload_is_file_too_big' );
67
-add_filter( 'import_upload_size_limit', 'fix_import_form_size' );
68
-add_filter( 'upload_mimes', 'check_upload_mimes' );
69
-add_filter( 'upload_size_limit', 'upload_size_limit_filter' );
70
-add_action( 'upload_ui_over_quota', 'multisite_over_quota_message' );
66
+add_filter('wp_upload_bits', 'upload_is_file_too_big');
67
+add_filter('import_upload_size_limit', 'fix_import_form_size');
68
+add_filter('upload_mimes', 'check_upload_mimes');
69
+add_filter('upload_size_limit', 'upload_size_limit_filter');
70
+add_action('upload_ui_over_quota', 'multisite_over_quota_message');
71 71
 
72 72
 // Mail
73
-add_action( 'phpmailer_init', 'fix_phpmailer_messageid' );
73
+add_action('phpmailer_init', 'fix_phpmailer_messageid');
74 74
 
75 75
 // Disable somethings by default for multisite
76
-add_filter( 'enable_update_services_configuration', '__return_false' );
77
-if ( ! defined('POST_BY_EMAIL') || ! POST_BY_EMAIL ) // back compat constant.
78
-	add_filter( 'enable_post_by_email_configuration', '__return_false' );
79
-if ( ! defined('EDIT_ANY_USER') || ! EDIT_ANY_USER ) // back compat constant.
80
-	add_filter( 'enable_edit_any_user_configuration', '__return_false' );
81
-add_filter( 'force_filtered_html_on_import', '__return_true' );
76
+add_filter('enable_update_services_configuration', '__return_false');
77
+if ( ! defined('POST_BY_EMAIL') || ! POST_BY_EMAIL) // back compat constant.
78
+	add_filter('enable_post_by_email_configuration', '__return_false');
79
+if ( ! defined('EDIT_ANY_USER') || ! EDIT_ANY_USER) // back compat constant.
80
+	add_filter('enable_edit_any_user_configuration', '__return_false');
81
+add_filter('force_filtered_html_on_import', '__return_true');
82 82
 
83 83
 // WP_HOME and WP_SITEURL should not have any effect in MS
84
-remove_filter( 'option_siteurl', '_config_wp_siteurl' );
85
-remove_filter( 'option_home',    '_config_wp_home'    );
84
+remove_filter('option_siteurl', '_config_wp_siteurl');
85
+remove_filter('option_home', '_config_wp_home');
86 86
 
87 87
 // Some options changes should trigger blog details refresh.
88
-add_action( 'update_option_blogname',   'refresh_blog_details', 10, 0 );
89
-add_action( 'update_option_siteurl',    'refresh_blog_details', 10, 0 );
90
-add_action( 'update_option_post_count', 'refresh_blog_details', 10, 0 );
88
+add_action('update_option_blogname', 'refresh_blog_details', 10, 0);
89
+add_action('update_option_siteurl', 'refresh_blog_details', 10, 0);
90
+add_action('update_option_post_count', 'refresh_blog_details', 10, 0);
91 91
 
92 92
 // If the network upgrade hasn't run yet, assume ms-files.php rewriting is used.
93
-add_filter( 'default_site_option_ms_files_rewriting', '__return_true' );
93
+add_filter('default_site_option_ms_files_rewriting', '__return_true');
94 94
 
95 95
 // Whitelist multisite domains for HTTP requests
96
-add_filter( 'http_request_host_is_external', 'ms_allowed_http_request_hosts', 20, 2 );
96
+add_filter('http_request_host_is_external', 'ms_allowed_http_request_hosts', 20, 2);
Please login to merge, or discard this patch.
src/wp-includes/ID3/module.audio.flac.php 3 patches
Indentation   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -167,7 +167,7 @@  discard block
 block discarded – undo
167 167
 		if (isset($info['flac']['STREAMINFO']['audio_signature'])) {
168 168
 
169 169
 			if ($info['flac']['STREAMINFO']['audio_signature'] === str_repeat("\x00", 16)) {
170
-                $this->warning('FLAC STREAMINFO.audio_signature is null (known issue with libOggFLAC)');
170
+				$this->warning('FLAC STREAMINFO.audio_signature is null (known issue with libOggFLAC)');
171 171
 			}
172 172
 			else {
173 173
 				$info['md5_data_source'] = '';
@@ -346,9 +346,9 @@  discard block
 block discarded – undo
346 346
 	}
347 347
 
348 348
 	/**
349
-	* Parse METADATA_BLOCK_PICTURE flac structure and extract attachment
350
-	* External usage: audio.ogg
351
-	*/
349
+	 * Parse METADATA_BLOCK_PICTURE flac structure and extract attachment
350
+	 * External usage: audio.ogg
351
+	 */
352 352
 	public function parsePICTURE() {
353 353
 		$info = &$this->getid3->info;
354 354
 
Please login to merge, or discard this patch.
Spacing   +49 added lines, -49 removed lines patch added patch discarded remove patch
@@ -48,7 +48,7 @@  discard block
 block discarded – undo
48 48
 			$BlockHeader   = $this->fread(4);
49 49
 			$LBFBT         = getid3_lib::BigEndian2Int(substr($BlockHeader, 0, 1));
50 50
 			$LastBlockFlag = (bool) ($LBFBT & 0x80);
51
-			$BlockType     =        ($LBFBT & 0x7F);
51
+			$BlockType     = ($LBFBT & 0x7F);
52 52
 			$BlockLength   = getid3_lib::BigEndian2Int(substr($BlockHeader, 1, 3));
53 53
 			$BlockTypeText = self::metaBlockTypeLookup($BlockType);
54 54
 
@@ -70,12 +70,12 @@  discard block
 block discarded – undo
70 70
 			$BlockTypeText_raw['block_type_text'] = $BlockTypeText;
71 71
 			$BlockTypeText_raw['block_length']    = $BlockLength;
72 72
 			if ($BlockTypeText_raw['block_type'] != 0x06) { // do not read attachment data automatically
73
-				$BlockTypeText_raw['block_data']  = $this->fread($BlockLength);
73
+				$BlockTypeText_raw['block_data'] = $this->fread($BlockLength);
74 74
 			}
75 75
 
76 76
 			switch ($BlockTypeText) {
77 77
 				case 'STREAMINFO':     // 0x00
78
-					if (!$this->parseSTREAMINFO($BlockTypeText_raw['block_data'])) {
78
+					if ( ! $this->parseSTREAMINFO($BlockTypeText_raw['block_data'])) {
79 79
 						return false;
80 80
 					}
81 81
 					break;
@@ -85,31 +85,31 @@  discard block
 block discarded – undo
85 85
 					break;
86 86
 
87 87
 				case 'APPLICATION':    // 0x02
88
-					if (!$this->parseAPPLICATION($BlockTypeText_raw['block_data'])) {
88
+					if ( ! $this->parseAPPLICATION($BlockTypeText_raw['block_data'])) {
89 89
 						return false;
90 90
 					}
91 91
 					break;
92 92
 
93 93
 				case 'SEEKTABLE':      // 0x03
94
-					if (!$this->parseSEEKTABLE($BlockTypeText_raw['block_data'])) {
94
+					if ( ! $this->parseSEEKTABLE($BlockTypeText_raw['block_data'])) {
95 95
 						return false;
96 96
 					}
97 97
 					break;
98 98
 
99 99
 				case 'VORBIS_COMMENT': // 0x04
100
-					if (!$this->parseVORBIS_COMMENT($BlockTypeText_raw['block_data'])) {
100
+					if ( ! $this->parseVORBIS_COMMENT($BlockTypeText_raw['block_data'])) {
101 101
 						return false;
102 102
 					}
103 103
 					break;
104 104
 
105 105
 				case 'CUESHEET':       // 0x05
106
-					if (!$this->parseCUESHEET($BlockTypeText_raw['block_data'])) {
106
+					if ( ! $this->parseCUESHEET($BlockTypeText_raw['block_data'])) {
107 107
 						return false;
108 108
 					}
109 109
 					break;
110 110
 
111 111
 				case 'PICTURE':        // 0x06
112
-					if (!$this->parsePICTURE()) {
112
+					if ( ! $this->parsePICTURE()) {
113 113
 						return false;
114 114
 					}
115 115
 					break;
@@ -124,18 +124,18 @@  discard block
 block discarded – undo
124 124
 		while ($LastBlockFlag === false);
125 125
 
126 126
 		// handle tags
127
-		if (!empty($info['flac']['VORBIS_COMMENT']['comments'])) {
127
+		if ( ! empty($info['flac']['VORBIS_COMMENT']['comments'])) {
128 128
 			$info['flac']['comments'] = $info['flac']['VORBIS_COMMENT']['comments'];
129 129
 		}
130
-		if (!empty($info['flac']['VORBIS_COMMENT']['vendor'])) {
130
+		if ( ! empty($info['flac']['VORBIS_COMMENT']['vendor'])) {
131 131
 			$info['audio']['encoder'] = str_replace('reference ', '', $info['flac']['VORBIS_COMMENT']['vendor']);
132 132
 		}
133 133
 
134 134
 		// copy attachments to 'comments' array if nesesary
135 135
 		if (isset($info['flac']['PICTURE']) && ($this->getid3->option_save_attachments !== getID3::ATTACHMENTS_NONE)) {
136 136
 			foreach ($info['flac']['PICTURE'] as $entry) {
137
-				if (!empty($entry['data'])) {
138
-					if (!isset($info['flac']['comments']['picture'])) {
137
+				if ( ! empty($entry['data'])) {
138
+					if ( ! isset($info['flac']['comments']['picture'])) {
139 139
 						$info['flac']['comments']['picture'] = array();
140 140
 					}
141 141
 					$comments_picture_data = array();
@@ -151,14 +151,14 @@  discard block
 block discarded – undo
151 151
 		}
152 152
 
153 153
 		if (isset($info['flac']['STREAMINFO'])) {
154
-			if (!$this->isDependencyFor('matroska')) {
154
+			if ( ! $this->isDependencyFor('matroska')) {
155 155
 				$info['flac']['compressed_audio_bytes'] = $info['avdataend'] - $info['avdataoffset'];
156 156
 			}
157 157
 			$info['flac']['uncompressed_audio_bytes'] = $info['flac']['STREAMINFO']['samples_stream'] * $info['flac']['STREAMINFO']['channels'] * ($info['flac']['STREAMINFO']['bits_per_sample'] / 8);
158 158
 			if ($info['flac']['uncompressed_audio_bytes'] == 0) {
159 159
 				return $this->error('Corrupt FLAC file: uncompressed_audio_bytes == zero');
160 160
 			}
161
-			if (!empty($info['flac']['compressed_audio_bytes'])) {
161
+			if ( ! empty($info['flac']['compressed_audio_bytes'])) {
162 162
 				$info['flac']['compression_ratio'] = $info['flac']['compressed_audio_bytes'] / $info['flac']['uncompressed_audio_bytes'];
163 163
 			}
164 164
 		}
@@ -175,7 +175,7 @@  discard block
 block discarded – undo
175 175
 				for ($i = 0; $i < strlen($md5); $i++) {
176 176
 					$info['md5_data_source'] .= str_pad(dechex(ord($md5[$i])), 2, '00', STR_PAD_LEFT);
177 177
 				}
178
-				if (!preg_match('/^[0-9a-f]{32}$/', $info['md5_data_source'])) {
178
+				if ( ! preg_match('/^[0-9a-f]{32}$/', $info['md5_data_source'])) {
179 179
 					unset($info['md5_data_source']);
180 180
 				}
181 181
 			}
@@ -206,14 +206,14 @@  discard block
 block discarded – undo
206 206
 		$streaminfo['max_frame_size']  = getid3_lib::BigEndian2Int(substr($BlockData, 7, 3));
207 207
 
208 208
 		$SRCSBSS                       = getid3_lib::BigEndian2Bin(substr($BlockData, 10, 8));
209
-		$streaminfo['sample_rate']     = getid3_lib::Bin2Dec(substr($SRCSBSS,  0, 20));
210
-		$streaminfo['channels']        = getid3_lib::Bin2Dec(substr($SRCSBSS, 20,  3)) + 1;
211
-		$streaminfo['bits_per_sample'] = getid3_lib::Bin2Dec(substr($SRCSBSS, 23,  5)) + 1;
209
+		$streaminfo['sample_rate']     = getid3_lib::Bin2Dec(substr($SRCSBSS, 0, 20));
210
+		$streaminfo['channels']        = getid3_lib::Bin2Dec(substr($SRCSBSS, 20, 3)) + 1;
211
+		$streaminfo['bits_per_sample'] = getid3_lib::Bin2Dec(substr($SRCSBSS, 23, 5)) + 1;
212 212
 		$streaminfo['samples_stream']  = getid3_lib::Bin2Dec(substr($SRCSBSS, 28, 36));
213 213
 
214 214
 		$streaminfo['audio_signature'] = substr($BlockData, 18, 16);
215 215
 
216
-		if (!empty($streaminfo['sample_rate'])) {
216
+		if ( ! empty($streaminfo['sample_rate'])) {
217 217
 
218 218
 			$info['audio']['bitrate_mode']    = 'vbr';
219 219
 			$info['audio']['sample_rate']     = $streaminfo['sample_rate'];
@@ -221,7 +221,7 @@  discard block
 block discarded – undo
221 221
 			$info['audio']['bits_per_sample'] = $streaminfo['bits_per_sample'];
222 222
 			$info['playtime_seconds']         = $streaminfo['samples_stream'] / $streaminfo['sample_rate'];
223 223
 			if ($info['playtime_seconds'] > 0) {
224
-				if (!$this->isDependencyFor('matroska')) {
224
+				if ( ! $this->isDependencyFor('matroska')) {
225 225
 					$info['audio']['bitrate'] = (($info['avdataend'] - $info['avdataoffset']) * 8) / $info['playtime_seconds'];
226 226
 				}
227 227
 				else {
@@ -297,16 +297,16 @@  discard block
 block discarded – undo
297 297
 	private function parseCUESHEET($BlockData) {
298 298
 		$info = &$this->getid3->info;
299 299
 		$offset = 0;
300
-		$info['flac']['CUESHEET']['media_catalog_number'] =                              trim(substr($BlockData, $offset, 128), "\0");
300
+		$info['flac']['CUESHEET']['media_catalog_number'] = trim(substr($BlockData, $offset, 128), "\0");
301 301
 		$offset += 128;
302
-		$info['flac']['CUESHEET']['lead_in_samples']      =         getid3_lib::BigEndian2Int(substr($BlockData, $offset, 8));
302
+		$info['flac']['CUESHEET']['lead_in_samples']      = getid3_lib::BigEndian2Int(substr($BlockData, $offset, 8));
303 303
 		$offset += 8;
304 304
 		$info['flac']['CUESHEET']['flags']['is_cd']       = (bool) (getid3_lib::BigEndian2Int(substr($BlockData, $offset, 1)) & 0x80);
305 305
 		$offset += 1;
306 306
 
307 307
 		$offset += 258; // reserved
308 308
 
309
-		$info['flac']['CUESHEET']['number_tracks']        =         getid3_lib::BigEndian2Int(substr($BlockData, $offset, 1));
309
+		$info['flac']['CUESHEET']['number_tracks'] = getid3_lib::BigEndian2Int(substr($BlockData, $offset, 1));
310 310
 		$offset += 1;
311 311
 
312 312
 		for ($track = 0; $track < $info['flac']['CUESHEET']['number_tracks']; $track++) {
@@ -317,7 +317,7 @@  discard block
 block discarded – undo
317 317
 
318 318
 			$info['flac']['CUESHEET']['tracks'][$TrackNumber]['sample_offset']         = $TrackSampleOffset;
319 319
 
320
-			$info['flac']['CUESHEET']['tracks'][$TrackNumber]['isrc']                  =                           substr($BlockData, $offset, 12);
320
+			$info['flac']['CUESHEET']['tracks'][$TrackNumber]['isrc']                  = substr($BlockData, $offset, 12);
321 321
 			$offset += 12;
322 322
 
323 323
 			$TrackFlagsRaw                                                             = getid3_lib::BigEndian2Int(substr($BlockData, $offset, 1));
@@ -327,7 +327,7 @@  discard block
 block discarded – undo
327 327
 
328 328
 			$offset += 13; // reserved
329 329
 
330
-			$info['flac']['CUESHEET']['tracks'][$TrackNumber]['index_points']          = getid3_lib::BigEndian2Int(substr($BlockData, $offset, 1));
330
+			$info['flac']['CUESHEET']['tracks'][$TrackNumber]['index_points'] = getid3_lib::BigEndian2Int(substr($BlockData, $offset, 1));
331 331
 			$offset += 1;
332 332
 
333 333
 			for ($index = 0; $index < $info['flac']['CUESHEET']['tracks'][$TrackNumber]['index_points']; $index++) {
@@ -396,35 +396,35 @@  discard block
 block discarded – undo
396 396
 	public static function applicationIDLookup($applicationid) {
397 397
 		// http://flac.sourceforge.net/id.html
398 398
 		static $lookup = array(
399
-			0x41544348 => 'FlacFile',                                                                           // "ATCH"
400
-			0x42534F4C => 'beSolo',                                                                             // "BSOL"
401
-			0x42554753 => 'Bugs Player',                                                                        // "BUGS"
402
-			0x43756573 => 'GoldWave cue points (specification)',                                                // "Cues"
403
-			0x46696361 => 'CUE Splitter',                                                                       // "Fica"
404
-			0x46746F6C => 'flac-tools',                                                                         // "Ftol"
405
-			0x4D4F5442 => 'MOTB MetaCzar',                                                                      // "MOTB"
406
-			0x4D505345 => 'MP3 Stream Editor',                                                                  // "MPSE"
407
-			0x4D754D4C => 'MusicML: Music Metadata Language',                                                   // "MuML"
408
-			0x52494646 => 'Sound Devices RIFF chunk storage',                                                   // "RIFF"
409
-			0x5346464C => 'Sound Font FLAC',                                                                    // "SFFL"
410
-			0x534F4E59 => 'Sony Creative Software',                                                             // "SONY"
411
-			0x5351455A => 'flacsqueeze',                                                                        // "SQEZ"
412
-			0x54745776 => 'TwistedWave',                                                                        // "TtWv"
413
-			0x55495453 => 'UITS Embedding tools',                                                               // "UITS"
414
-			0x61696666 => 'FLAC AIFF chunk storage',                                                            // "aiff"
415
-			0x696D6167 => 'flac-image application for storing arbitrary files in APPLICATION metadata blocks',  // "imag"
416
-			0x7065656D => 'Parseable Embedded Extensible Metadata (specification)',                             // "peem"
417
-			0x71667374 => 'QFLAC Studio',                                                                       // "qfst"
418
-			0x72696666 => 'FLAC RIFF chunk storage',                                                            // "riff"
419
-			0x74756E65 => 'TagTuner',                                                                           // "tune"
420
-			0x78626174 => 'XBAT',                                                                               // "xbat"
421
-			0x786D6364 => 'xmcd',                                                                               // "xmcd"
399
+			0x41544348 => 'FlacFile', // "ATCH"
400
+			0x42534F4C => 'beSolo', // "BSOL"
401
+			0x42554753 => 'Bugs Player', // "BUGS"
402
+			0x43756573 => 'GoldWave cue points (specification)', // "Cues"
403
+			0x46696361 => 'CUE Splitter', // "Fica"
404
+			0x46746F6C => 'flac-tools', // "Ftol"
405
+			0x4D4F5442 => 'MOTB MetaCzar', // "MOTB"
406
+			0x4D505345 => 'MP3 Stream Editor', // "MPSE"
407
+			0x4D754D4C => 'MusicML: Music Metadata Language', // "MuML"
408
+			0x52494646 => 'Sound Devices RIFF chunk storage', // "RIFF"
409
+			0x5346464C => 'Sound Font FLAC', // "SFFL"
410
+			0x534F4E59 => 'Sony Creative Software', // "SONY"
411
+			0x5351455A => 'flacsqueeze', // "SQEZ"
412
+			0x54745776 => 'TwistedWave', // "TtWv"
413
+			0x55495453 => 'UITS Embedding tools', // "UITS"
414
+			0x61696666 => 'FLAC AIFF chunk storage', // "aiff"
415
+			0x696D6167 => 'flac-image application for storing arbitrary files in APPLICATION metadata blocks', // "imag"
416
+			0x7065656D => 'Parseable Embedded Extensible Metadata (specification)', // "peem"
417
+			0x71667374 => 'QFLAC Studio', // "qfst"
418
+			0x72696666 => 'FLAC RIFF chunk storage', // "riff"
419
+			0x74756E65 => 'TagTuner', // "tune"
420
+			0x78626174 => 'XBAT', // "xbat"
421
+			0x786D6364 => 'xmcd', // "xmcd"
422 422
 		);
423 423
 		return (isset($lookup[$applicationid]) ? $lookup[$applicationid] : 'reserved');
424 424
 	}
425 425
 
426 426
 	public static function pictureTypeLookup($type_id) {
427
-		static $lookup = array (
427
+		static $lookup = array(
428 428
 			 0 => 'Other',
429 429
 			 1 => '32x32 pixels \'file icon\' (PNG only)',
430 430
 			 2 => 'Other file icon',
Please login to merge, or discard this patch.
Braces   +2 added lines, -4 removed lines patch added patch discarded remove patch
@@ -168,8 +168,7 @@  discard block
 block discarded – undo
168 168
 
169 169
 			if ($info['flac']['STREAMINFO']['audio_signature'] === str_repeat("\x00", 16)) {
170 170
                 $this->warning('FLAC STREAMINFO.audio_signature is null (known issue with libOggFLAC)');
171
-			}
172
-			else {
171
+			} else {
173 172
 				$info['md5_data_source'] = '';
174 173
 				$md5 = $info['flac']['STREAMINFO']['audio_signature'];
175 174
 				for ($i = 0; $i < strlen($md5); $i++) {
@@ -223,8 +222,7 @@  discard block
 block discarded – undo
223 222
 			if ($info['playtime_seconds'] > 0) {
224 223
 				if (!$this->isDependencyFor('matroska')) {
225 224
 					$info['audio']['bitrate'] = (($info['avdataend'] - $info['avdataoffset']) * 8) / $info['playtime_seconds'];
226
-				}
227
-				else {
225
+				} else {
228 226
 					$this->warning('Cannot determine audio bitrate because total stream size is unknown');
229 227
 				}
230 228
 			}
Please login to merge, or discard this patch.
src/wp-includes/ID3/module.tag.id3v1.php 1 patch
Spacing   +20 added lines, -20 removed lines patch added patch discarded remove patch
@@ -21,7 +21,7 @@  discard block
 block discarded – undo
21 21
 	public function Analyze() {
22 22
 		$info = &$this->getid3->info;
23 23
 
24
-		if (!getid3_lib::intValueSupported($info['filesize'])) {
24
+		if ( ! getid3_lib::intValueSupported($info['filesize'])) {
25 25
 			$info['warning'][] = 'Unable to check for ID3v1 because file is larger than '.round(PHP_INT_MAX / 1073741824).'GB';
26 26
 			return false;
27 27
 		}
@@ -34,23 +34,23 @@  discard block
 block discarded – undo
34 34
 
35 35
 			$info['avdataend'] = $info['filesize'] - 128;
36 36
 
37
-			$ParsedID3v1['title']   = $this->cutfield(substr($id3v1tag,   3, 30));
38
-			$ParsedID3v1['artist']  = $this->cutfield(substr($id3v1tag,  33, 30));
39
-			$ParsedID3v1['album']   = $this->cutfield(substr($id3v1tag,  63, 30));
40
-			$ParsedID3v1['year']    = $this->cutfield(substr($id3v1tag,  93,  4));
41
-			$ParsedID3v1['comment'] =                 substr($id3v1tag,  97, 30);  // can't remove nulls yet, track detection depends on them
42
-			$ParsedID3v1['genreid'] =             ord(substr($id3v1tag, 127,  1));
37
+			$ParsedID3v1['title']   = $this->cutfield(substr($id3v1tag, 3, 30));
38
+			$ParsedID3v1['artist']  = $this->cutfield(substr($id3v1tag, 33, 30));
39
+			$ParsedID3v1['album']   = $this->cutfield(substr($id3v1tag, 63, 30));
40
+			$ParsedID3v1['year']    = $this->cutfield(substr($id3v1tag, 93, 4));
41
+			$ParsedID3v1['comment'] = substr($id3v1tag, 97, 30); // can't remove nulls yet, track detection depends on them
42
+			$ParsedID3v1['genreid'] = ord(substr($id3v1tag, 127, 1));
43 43
 
44 44
 			// If second-last byte of comment field is null and last byte of comment field is non-null
45 45
 			// then this is ID3v1.1 and the comment field is 28 bytes long and the 30th byte is the track number
46 46
 			if (($id3v1tag{125} === "\x00") && ($id3v1tag{126} !== "\x00")) {
47
-				$ParsedID3v1['track']   = ord(substr($ParsedID3v1['comment'], 29,  1));
48
-				$ParsedID3v1['comment'] =     substr($ParsedID3v1['comment'],  0, 28);
47
+				$ParsedID3v1['track']   = ord(substr($ParsedID3v1['comment'], 29, 1));
48
+				$ParsedID3v1['comment'] = substr($ParsedID3v1['comment'], 0, 28);
49 49
 			}
50 50
 			$ParsedID3v1['comment'] = $this->cutfield($ParsedID3v1['comment']);
51 51
 
52 52
 			$ParsedID3v1['genre'] = $this->LookupGenreName($ParsedID3v1['genreid']);
53
-			if (!empty($ParsedID3v1['genre'])) {
53
+			if ( ! empty($ParsedID3v1['genre'])) {
54 54
 				unset($ParsedID3v1['genreid']);
55 55
 			}
56 56
 			if (isset($ParsedID3v1['genre']) && (empty($ParsedID3v1['genre']) || ($ParsedID3v1['genre'] == 'Unknown'))) {
@@ -69,7 +69,7 @@  discard block
 block discarded – undo
69 69
 											$ParsedID3v1['year'],
70 70
 											(isset($ParsedID3v1['genre']) ? $this->LookupGenreID($ParsedID3v1['genre']) : false),
71 71
 											$ParsedID3v1['comment'],
72
-											(!empty($ParsedID3v1['track']) ? $ParsedID3v1['track'] : ''));
72
+											( ! empty($ParsedID3v1['track']) ? $ParsedID3v1['track'] : ''));
73 73
 			$ParsedID3v1['padding_valid'] = true;
74 74
 			if ($id3v1tag !== $GoodFormatID3v1tag) {
75 75
 				$ParsedID3v1['padding_valid'] = false;
@@ -107,7 +107,7 @@  discard block
 block discarded – undo
107 107
 		return trim(substr($str, 0, strcspn($str, "\x00")));
108 108
 	}
109 109
 
110
-	public static function ArrayOfGenres($allowSCMPXextended=false) {
110
+	public static function ArrayOfGenres($allowSCMPXextended = false) {
111 111
 		static $GenreLookup = array(
112 112
 			0    => 'Blues',
113 113
 			1    => 'Classic Rock',
@@ -291,13 +291,13 @@  discard block
 block discarded – undo
291 291
 		return ($allowSCMPXextended ? $GenreLookupSCMPX : $GenreLookup);
292 292
 	}
293 293
 
294
-	public static function LookupGenreName($genreid, $allowSCMPXextended=true) {
294
+	public static function LookupGenreName($genreid, $allowSCMPXextended = true) {
295 295
 		switch ($genreid) {
296 296
 			case 'RX':
297 297
 			case 'CR':
298 298
 				break;
299 299
 			default:
300
-				if (!is_numeric($genreid)) {
300
+				if ( ! is_numeric($genreid)) {
301 301
 					return false;
302 302
 				}
303 303
 				$genreid = intval($genreid); // to handle 3 or '3' or '03'
@@ -307,7 +307,7 @@  discard block
 block discarded – undo
307 307
 		return (isset($GenreLookup[$genreid]) ? $GenreLookup[$genreid] : false);
308 308
 	}
309 309
 
310
-	public static function LookupGenreID($genre, $allowSCMPXextended=false) {
310
+	public static function LookupGenreID($genre, $allowSCMPXextended = false) {
311 311
 		$GenreLookup = self::ArrayOfGenres($allowSCMPXextended);
312 312
 		$LowerCaseNoSpaceSearchTerm = strtolower(str_replace(' ', '', $genre));
313 313
 		foreach ($GenreLookup as $key => $value) {
@@ -325,13 +325,13 @@  discard block
 block discarded – undo
325 325
 		return $OriginalGenre;
326 326
 	}
327 327
 
328
-	public static function GenerateID3v1Tag($title, $artist, $album, $year, $genreid, $comment, $track='') {
328
+	public static function GenerateID3v1Tag($title, $artist, $album, $year, $genreid, $comment, $track = '') {
329 329
 		$ID3v1Tag  = 'TAG';
330
-		$ID3v1Tag .= str_pad(trim(substr($title,  0, 30)), 30, "\x00", STR_PAD_RIGHT);
330
+		$ID3v1Tag .= str_pad(trim(substr($title, 0, 30)), 30, "\x00", STR_PAD_RIGHT);
331 331
 		$ID3v1Tag .= str_pad(trim(substr($artist, 0, 30)), 30, "\x00", STR_PAD_RIGHT);
332
-		$ID3v1Tag .= str_pad(trim(substr($album,  0, 30)), 30, "\x00", STR_PAD_RIGHT);
333
-		$ID3v1Tag .= str_pad(trim(substr($year,   0,  4)),  4, "\x00", STR_PAD_LEFT);
334
-		if (!empty($track) && ($track > 0) && ($track <= 255)) {
332
+		$ID3v1Tag .= str_pad(trim(substr($album, 0, 30)), 30, "\x00", STR_PAD_RIGHT);
333
+		$ID3v1Tag .= str_pad(trim(substr($year, 0, 4)), 4, "\x00", STR_PAD_LEFT);
334
+		if ( ! empty($track) && ($track > 0) && ($track <= 255)) {
335 335
 			$ID3v1Tag .= str_pad(trim(substr($comment, 0, 28)), 28, "\x00", STR_PAD_RIGHT);
336 336
 			$ID3v1Tag .= "\x00";
337 337
 			if (gettype($track) == 'string') {
Please login to merge, or discard this patch.
src/wp-includes/default-filters.php 3 patches
Braces   +17 added lines, -11 removed lines patch added patch discarded remove patch
@@ -52,9 +52,10 @@  discard block
 block discarded – undo
52 52
 // Email admin display
53 53
 foreach ( array( 'comment_author_email', 'user_email' ) as $filter ) {
54 54
 	add_filter( $filter, 'sanitize_email' );
55
-	if ( is_admin() )
56
-		add_filter( $filter, 'wp_kses_data' );
57
-}
55
+	if ( is_admin() ) {
56
+			add_filter( $filter, 'wp_kses_data' );
57
+	}
58
+	}
58 59
 
59 60
 // Save URL
60 61
 foreach ( array( 'pre_comment_author_url', 'pre_user_url', 'pre_link_url', 'pre_link_image',
@@ -66,12 +67,14 @@  discard block
 block discarded – undo
66 67
 
67 68
 // Display URL
68 69
 foreach ( array( 'user_url', 'link_url', 'link_image', 'link_rss', 'comment_url', 'post_guid' ) as $filter ) {
69
-	if ( is_admin() )
70
-		add_filter( $filter, 'wp_strip_all_tags' );
70
+	if ( is_admin() ) {
71
+			add_filter( $filter, 'wp_strip_all_tags' );
72
+	}
71 73
 	add_filter( $filter, 'esc_url'           );
72
-	if ( is_admin() )
73
-		add_filter( $filter, 'wp_kses_data'    );
74
-}
74
+	if ( is_admin() ) {
75
+			add_filter( $filter, 'wp_kses_data'    );
76
+	}
77
+	}
75 78
 
76 79
 // Slugs
77 80
 add_filter( 'pre_term_slug', 'sanitize_title' );
@@ -99,8 +102,9 @@  discard block
 block discarded – undo
99 102
 }
100 103
 
101 104
 // Format WordPress
102
-foreach ( array( 'the_content', 'the_title', 'wp_title' ) as $filter )
105
+foreach ( array( 'the_content', 'the_title', 'wp_title' ) as $filter ) {
103 106
 	add_filter( $filter, 'capital_P_dangit', 11 );
107
+}
104 108
 add_filter( 'comment_text', 'capital_P_dangit', 31 );
105 109
 
106 110
 // Format titles
@@ -228,8 +232,9 @@  discard block
 block discarded – undo
228 232
 add_action( 'after_switch_theme',  '_wp_sidebars_changed'                   );
229 233
 add_action( 'wp_print_styles',     'print_emoji_styles'                     );
230 234
 
231
-if ( isset( $_GET['replytocom'] ) )
235
+if ( isset( $_GET['replytocom'] ) ) {
232 236
     add_action( 'wp_head', 'wp_no_robots' );
237
+}
233 238
 
234 239
 // Login actions
235 240
 add_action( 'login_head',          'wp_print_head_scripts',         9     );
@@ -247,8 +252,9 @@  discard block
 block discarded – undo
247 252
 
248 253
 
249 254
 // WP Cron
250
-if ( !defined( 'DOING_CRON' ) )
255
+if ( !defined( 'DOING_CRON' ) ) {
251 256
 	add_action( 'init', 'wp_cron' );
257
+}
252 258
 
253 259
 // 2 Actions 2 Furious
254 260
 add_action( 'do_feed_rdf',                'do_feed_rdf',                             10, 1 );
Please login to merge, or discard this patch.
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -245,7 +245,7 @@
 block discarded – undo
245 245
 add_action( 'wp_print_styles',     'print_emoji_styles'                     );
246 246
 
247 247
 if ( isset( $_GET['replytocom'] ) )
248
-    add_action( 'wp_head', 'wp_no_robots' );
248
+	add_action( 'wp_head', 'wp_no_robots' );
249 249
 
250 250
 // Login actions
251 251
 add_action( 'login_head',          'wp_print_head_scripts',         9     );
Please login to merge, or discard this patch.
Spacing   +336 added lines, -336 removed lines patch added patch discarded remove patch
@@ -13,495 +13,495 @@
 block discarded – undo
13 13
  */
14 14
 
15 15
 // Strip, trim, kses, special chars for string saves
16
-foreach ( array( 'pre_term_name', 'pre_comment_author_name', 'pre_link_name', 'pre_link_target', 'pre_link_rel', 'pre_user_display_name', 'pre_user_first_name', 'pre_user_last_name', 'pre_user_nickname' ) as $filter ) {
17
-	add_filter( $filter, 'sanitize_text_field'  );
18
-	add_filter( $filter, 'wp_filter_kses'       );
19
-	add_filter( $filter, '_wp_specialchars', 30 );
16
+foreach (array('pre_term_name', 'pre_comment_author_name', 'pre_link_name', 'pre_link_target', 'pre_link_rel', 'pre_user_display_name', 'pre_user_first_name', 'pre_user_last_name', 'pre_user_nickname') as $filter) {
17
+	add_filter($filter, 'sanitize_text_field');
18
+	add_filter($filter, 'wp_filter_kses');
19
+	add_filter($filter, '_wp_specialchars', 30);
20 20
 }
21 21
 
22 22
 // Strip, kses, special chars for string display
23
-foreach ( array( 'term_name', 'comment_author_name', 'link_name', 'link_target', 'link_rel', 'user_display_name', 'user_first_name', 'user_last_name', 'user_nickname' ) as $filter ) {
24
-	if ( is_admin() ) {
23
+foreach (array('term_name', 'comment_author_name', 'link_name', 'link_target', 'link_rel', 'user_display_name', 'user_first_name', 'user_last_name', 'user_nickname') as $filter) {
24
+	if (is_admin()) {
25 25
 		// These are expensive. Run only on admin pages for defense in depth.
26
-		add_filter( $filter, 'sanitize_text_field'  );
27
-		add_filter( $filter, 'wp_kses_data'       );
26
+		add_filter($filter, 'sanitize_text_field');
27
+		add_filter($filter, 'wp_kses_data');
28 28
 	}
29
-	add_filter( $filter, '_wp_specialchars', 30 );
29
+	add_filter($filter, '_wp_specialchars', 30);
30 30
 }
31 31
 
32 32
 // Kses only for textarea saves
33
-foreach ( array( 'pre_term_description', 'pre_link_description', 'pre_link_notes', 'pre_user_description' ) as $filter ) {
34
-	add_filter( $filter, 'wp_filter_kses' );
33
+foreach (array('pre_term_description', 'pre_link_description', 'pre_link_notes', 'pre_user_description') as $filter) {
34
+	add_filter($filter, 'wp_filter_kses');
35 35
 }
36 36
 
37 37
 // Kses only for textarea admin displays
38
-if ( is_admin() ) {
39
-	foreach ( array( 'term_description', 'link_description', 'link_notes', 'user_description' ) as $filter ) {
40
-		add_filter( $filter, 'wp_kses_data' );
38
+if (is_admin()) {
39
+	foreach (array('term_description', 'link_description', 'link_notes', 'user_description') as $filter) {
40
+		add_filter($filter, 'wp_kses_data');
41 41
 	}
42
-	add_filter( 'comment_text', 'wp_kses_post' );
42
+	add_filter('comment_text', 'wp_kses_post');
43 43
 }
44 44
 
45 45
 // Email saves
46
-foreach ( array( 'pre_comment_author_email', 'pre_user_email' ) as $filter ) {
47
-	add_filter( $filter, 'trim'           );
48
-	add_filter( $filter, 'sanitize_email' );
49
-	add_filter( $filter, 'wp_filter_kses' );
46
+foreach (array('pre_comment_author_email', 'pre_user_email') as $filter) {
47
+	add_filter($filter, 'trim');
48
+	add_filter($filter, 'sanitize_email');
49
+	add_filter($filter, 'wp_filter_kses');
50 50
 }
51 51
 
52 52
 // Email admin display
53
-foreach ( array( 'comment_author_email', 'user_email' ) as $filter ) {
54
-	add_filter( $filter, 'sanitize_email' );
55
-	if ( is_admin() )
56
-		add_filter( $filter, 'wp_kses_data' );
53
+foreach (array('comment_author_email', 'user_email') as $filter) {
54
+	add_filter($filter, 'sanitize_email');
55
+	if (is_admin())
56
+		add_filter($filter, 'wp_kses_data');
57 57
 }
58 58
 
59 59
 // Save URL
60
-foreach ( array( 'pre_comment_author_url', 'pre_user_url', 'pre_link_url', 'pre_link_image',
61
-	'pre_link_rss', 'pre_post_guid' ) as $filter ) {
62
-	add_filter( $filter, 'wp_strip_all_tags' );
63
-	add_filter( $filter, 'esc_url_raw'       );
64
-	add_filter( $filter, 'wp_filter_kses'    );
60
+foreach (array('pre_comment_author_url', 'pre_user_url', 'pre_link_url', 'pre_link_image',
61
+	'pre_link_rss', 'pre_post_guid') as $filter) {
62
+	add_filter($filter, 'wp_strip_all_tags');
63
+	add_filter($filter, 'esc_url_raw');
64
+	add_filter($filter, 'wp_filter_kses');
65 65
 }
66 66
 
67 67
 // Display URL
68
-foreach ( array( 'user_url', 'link_url', 'link_image', 'link_rss', 'comment_url', 'post_guid' ) as $filter ) {
69
-	if ( is_admin() )
70
-		add_filter( $filter, 'wp_strip_all_tags' );
71
-	add_filter( $filter, 'esc_url'           );
72
-	if ( is_admin() )
73
-		add_filter( $filter, 'wp_kses_data'    );
68
+foreach (array('user_url', 'link_url', 'link_image', 'link_rss', 'comment_url', 'post_guid') as $filter) {
69
+	if (is_admin())
70
+		add_filter($filter, 'wp_strip_all_tags');
71
+	add_filter($filter, 'esc_url');
72
+	if (is_admin())
73
+		add_filter($filter, 'wp_kses_data');
74 74
 }
75 75
 
76 76
 // Slugs
77
-add_filter( 'pre_term_slug', 'sanitize_title' );
78
-add_filter( 'wp_insert_post_data', '_wp_customize_changeset_filter_insert_post_data', 10, 2 );
77
+add_filter('pre_term_slug', 'sanitize_title');
78
+add_filter('wp_insert_post_data', '_wp_customize_changeset_filter_insert_post_data', 10, 2);
79 79
 
80 80
 // Keys
81
-foreach ( array( 'pre_post_type', 'pre_post_status', 'pre_post_comment_status', 'pre_post_ping_status' ) as $filter ) {
82
-	add_filter( $filter, 'sanitize_key' );
81
+foreach (array('pre_post_type', 'pre_post_status', 'pre_post_comment_status', 'pre_post_ping_status') as $filter) {
82
+	add_filter($filter, 'sanitize_key');
83 83
 }
84 84
 
85 85
 // Mime types
86
-add_filter( 'pre_post_mime_type', 'sanitize_mime_type' );
87
-add_filter( 'post_mime_type', 'sanitize_mime_type' );
86
+add_filter('pre_post_mime_type', 'sanitize_mime_type');
87
+add_filter('post_mime_type', 'sanitize_mime_type');
88 88
 
89 89
 // Meta
90
-add_filter( 'register_meta_args', '_wp_register_meta_args_whitelist', 10, 2 );
90
+add_filter('register_meta_args', '_wp_register_meta_args_whitelist', 10, 2);
91 91
 
92 92
 // Places to balance tags on input
93
-foreach ( array( 'content_save_pre', 'excerpt_save_pre', 'comment_save_pre', 'pre_comment_content' ) as $filter ) {
94
-	add_filter( $filter, 'convert_invalid_entities' );
95
-	add_filter( $filter, 'balanceTags', 50 );
93
+foreach (array('content_save_pre', 'excerpt_save_pre', 'comment_save_pre', 'pre_comment_content') as $filter) {
94
+	add_filter($filter, 'convert_invalid_entities');
95
+	add_filter($filter, 'balanceTags', 50);
96 96
 }
97 97
 
98 98
 // Format strings for display.
99
-foreach ( array( 'comment_author', 'term_name', 'link_name', 'link_description', 'link_notes', 'bloginfo', 'wp_title', 'widget_title' ) as $filter ) {
100
-	add_filter( $filter, 'wptexturize'   );
101
-	add_filter( $filter, 'convert_chars' );
102
-	add_filter( $filter, 'esc_html'      );
99
+foreach (array('comment_author', 'term_name', 'link_name', 'link_description', 'link_notes', 'bloginfo', 'wp_title', 'widget_title') as $filter) {
100
+	add_filter($filter, 'wptexturize');
101
+	add_filter($filter, 'convert_chars');
102
+	add_filter($filter, 'esc_html');
103 103
 }
104 104
 
105 105
 // Format WordPress
106
-foreach ( array( 'the_content', 'the_title', 'wp_title' ) as $filter )
107
-	add_filter( $filter, 'capital_P_dangit', 11 );
108
-add_filter( 'comment_text', 'capital_P_dangit', 31 );
106
+foreach (array('the_content', 'the_title', 'wp_title') as $filter)
107
+	add_filter($filter, 'capital_P_dangit', 11);
108
+add_filter('comment_text', 'capital_P_dangit', 31);
109 109
 
110 110
 // Format titles
111
-foreach ( array( 'single_post_title', 'single_cat_title', 'single_tag_title', 'single_month_title', 'nav_menu_attr_title', 'nav_menu_description' ) as $filter ) {
112
-	add_filter( $filter, 'wptexturize' );
113
-	add_filter( $filter, 'strip_tags'  );
111
+foreach (array('single_post_title', 'single_cat_title', 'single_tag_title', 'single_month_title', 'nav_menu_attr_title', 'nav_menu_description') as $filter) {
112
+	add_filter($filter, 'wptexturize');
113
+	add_filter($filter, 'strip_tags');
114 114
 }
115 115
 
116 116
 // Format text area for display.
117
-foreach ( array( 'term_description' ) as $filter ) {
118
-	add_filter( $filter, 'wptexturize'      );
119
-	add_filter( $filter, 'convert_chars'    );
120
-	add_filter( $filter, 'wpautop'          );
121
-	add_filter( $filter, 'shortcode_unautop');
117
+foreach (array('term_description') as $filter) {
118
+	add_filter($filter, 'wptexturize');
119
+	add_filter($filter, 'convert_chars');
120
+	add_filter($filter, 'wpautop');
121
+	add_filter($filter, 'shortcode_unautop');
122 122
 }
123 123
 
124 124
 // Format for RSS
125
-add_filter( 'term_name_rss', 'convert_chars' );
125
+add_filter('term_name_rss', 'convert_chars');
126 126
 
127 127
 // Pre save hierarchy
128
-add_filter( 'wp_insert_post_parent', 'wp_check_post_hierarchy_for_loops', 10, 2 );
129
-add_filter( 'wp_update_term_parent', 'wp_check_term_hierarchy_for_loops', 10, 3 );
128
+add_filter('wp_insert_post_parent', 'wp_check_post_hierarchy_for_loops', 10, 2);
129
+add_filter('wp_update_term_parent', 'wp_check_term_hierarchy_for_loops', 10, 3);
130 130
 
131 131
 // Display filters
132
-add_filter( 'the_title', 'wptexturize'   );
133
-add_filter( 'the_title', 'convert_chars' );
134
-add_filter( 'the_title', 'trim'          );
132
+add_filter('the_title', 'wptexturize');
133
+add_filter('the_title', 'convert_chars');
134
+add_filter('the_title', 'trim');
135 135
 
136
-add_filter( 'the_content', 'wptexturize'                       );
137
-add_filter( 'the_content', 'convert_smilies',               20 );
138
-add_filter( 'the_content', 'wpautop'                           );
139
-add_filter( 'the_content', 'shortcode_unautop'                 );
140
-add_filter( 'the_content', 'prepend_attachment'                );
141
-add_filter( 'the_content', 'wp_make_content_images_responsive' );
136
+add_filter('the_content', 'wptexturize');
137
+add_filter('the_content', 'convert_smilies', 20);
138
+add_filter('the_content', 'wpautop');
139
+add_filter('the_content', 'shortcode_unautop');
140
+add_filter('the_content', 'prepend_attachment');
141
+add_filter('the_content', 'wp_make_content_images_responsive');
142 142
 
143
-add_filter( 'the_excerpt',     'wptexturize'      );
144
-add_filter( 'the_excerpt',     'convert_smilies'  );
145
-add_filter( 'the_excerpt',     'convert_chars'    );
146
-add_filter( 'the_excerpt',     'wpautop'          );
147
-add_filter( 'the_excerpt',     'shortcode_unautop');
148
-add_filter( 'get_the_excerpt', 'wp_trim_excerpt'  );
143
+add_filter('the_excerpt', 'wptexturize');
144
+add_filter('the_excerpt', 'convert_smilies');
145
+add_filter('the_excerpt', 'convert_chars');
146
+add_filter('the_excerpt', 'wpautop');
147
+add_filter('the_excerpt', 'shortcode_unautop');
148
+add_filter('get_the_excerpt', 'wp_trim_excerpt');
149 149
 
150
-add_filter( 'the_post_thumbnail_caption', 'wptexturize'     );
151
-add_filter( 'the_post_thumbnail_caption', 'convert_smilies' );
152
-add_filter( 'the_post_thumbnail_caption', 'convert_chars'   );
150
+add_filter('the_post_thumbnail_caption', 'wptexturize');
151
+add_filter('the_post_thumbnail_caption', 'convert_smilies');
152
+add_filter('the_post_thumbnail_caption', 'convert_chars');
153 153
 
154
-add_filter( 'comment_text', 'wptexturize'            );
155
-add_filter( 'comment_text', 'convert_chars'          );
156
-add_filter( 'comment_text', 'make_clickable',      9 );
157
-add_filter( 'comment_text', 'force_balance_tags', 25 );
158
-add_filter( 'comment_text', 'convert_smilies',    20 );
159
-add_filter( 'comment_text', 'wpautop',            30 );
154
+add_filter('comment_text', 'wptexturize');
155
+add_filter('comment_text', 'convert_chars');
156
+add_filter('comment_text', 'make_clickable', 9);
157
+add_filter('comment_text', 'force_balance_tags', 25);
158
+add_filter('comment_text', 'convert_smilies', 20);
159
+add_filter('comment_text', 'wpautop', 30);
160 160
 
161
-add_filter( 'comment_excerpt', 'convert_chars' );
161
+add_filter('comment_excerpt', 'convert_chars');
162 162
 
163
-add_filter( 'list_cats',         'wptexturize' );
163
+add_filter('list_cats', 'wptexturize');
164 164
 
165
-add_filter( 'wp_sprintf', 'wp_sprintf_l', 10, 2 );
165
+add_filter('wp_sprintf', 'wp_sprintf_l', 10, 2);
166 166
 
167
-add_filter( 'widget_text', 'balanceTags' );
167
+add_filter('widget_text', 'balanceTags');
168 168
 
169
-add_filter( 'date_i18n', 'wp_maybe_decline_date' );
169
+add_filter('date_i18n', 'wp_maybe_decline_date');
170 170
 
171 171
 // RSS filters
172
-add_filter( 'the_title_rss',      'strip_tags'                    );
173
-add_filter( 'the_title_rss',      'ent2ncr',                    8 );
174
-add_filter( 'the_title_rss',      'esc_html'                      );
175
-add_filter( 'the_content_rss',    'ent2ncr',                    8 );
176
-add_filter( 'the_content_feed',   'wp_staticize_emoji'            );
177
-add_filter( 'the_content_feed',   '_oembed_filter_feed_content'   );
178
-add_filter( 'the_excerpt_rss',    'convert_chars'                 );
179
-add_filter( 'the_excerpt_rss',    'ent2ncr',                    8 );
180
-add_filter( 'comment_author_rss', 'ent2ncr',                    8 );
181
-add_filter( 'comment_text_rss',   'ent2ncr',                    8 );
182
-add_filter( 'comment_text_rss',   'esc_html'                      );
183
-add_filter( 'comment_text_rss',   'wp_staticize_emoji'            );
184
-add_filter( 'bloginfo_rss',       'ent2ncr',                    8 );
185
-add_filter( 'the_author',         'ent2ncr',                    8 );
186
-add_filter( 'the_guid',           'esc_url'                       );
172
+add_filter('the_title_rss', 'strip_tags');
173
+add_filter('the_title_rss', 'ent2ncr', 8);
174
+add_filter('the_title_rss', 'esc_html');
175
+add_filter('the_content_rss', 'ent2ncr', 8);
176
+add_filter('the_content_feed', 'wp_staticize_emoji');
177
+add_filter('the_content_feed', '_oembed_filter_feed_content');
178
+add_filter('the_excerpt_rss', 'convert_chars');
179
+add_filter('the_excerpt_rss', 'ent2ncr', 8);
180
+add_filter('comment_author_rss', 'ent2ncr', 8);
181
+add_filter('comment_text_rss', 'ent2ncr', 8);
182
+add_filter('comment_text_rss', 'esc_html');
183
+add_filter('comment_text_rss', 'wp_staticize_emoji');
184
+add_filter('bloginfo_rss', 'ent2ncr', 8);
185
+add_filter('the_author', 'ent2ncr', 8);
186
+add_filter('the_guid', 'esc_url');
187 187
 
188 188
 // Email filters
189
-add_filter( 'wp_mail', 'wp_staticize_emoji_for_email' );
189
+add_filter('wp_mail', 'wp_staticize_emoji_for_email');
190 190
 
191 191
 // Mark site as no longer fresh
192
-foreach ( array( 'publish_post', 'publish_page', 'wp_ajax_save-widget', 'wp_ajax_widgets-order', 'customize_save_after' ) as $action ) {
193
-	add_action( $action, '_delete_option_fresh_site' );
192
+foreach (array('publish_post', 'publish_page', 'wp_ajax_save-widget', 'wp_ajax_widgets-order', 'customize_save_after') as $action) {
193
+	add_action($action, '_delete_option_fresh_site');
194 194
 }
195 195
 
196 196
 // Misc filters
197
-add_filter( 'option_ping_sites',        'privacy_ping_filter'                 );
198
-add_filter( 'option_blog_charset',      '_wp_specialchars'                    ); // IMPORTANT: This must not be wp_specialchars() or esc_html() or it'll cause an infinite loop
199
-add_filter( 'option_blog_charset',      '_canonical_charset'                  );
200
-add_filter( 'option_home',              '_config_wp_home'                     );
201
-add_filter( 'option_siteurl',           '_config_wp_siteurl'                  );
202
-add_filter( 'tiny_mce_before_init',     '_mce_set_direction'                  );
203
-add_filter( 'teeny_mce_before_init',    '_mce_set_direction'                  );
204
-add_filter( 'pre_kses',                 'wp_pre_kses_less_than'               );
205
-add_filter( 'sanitize_title',           'sanitize_title_with_dashes',   10, 3 );
206
-add_action( 'check_comment_flood',      'check_comment_flood_db',       10, 4 );
207
-add_filter( 'comment_flood_filter',     'wp_throttle_comment_flood',    10, 3 );
208
-add_filter( 'pre_comment_content',      'wp_rel_nofollow',              15    );
209
-add_filter( 'comment_email',            'antispambot'                         );
210
-add_filter( 'option_tag_base',          '_wp_filter_taxonomy_base'            );
211
-add_filter( 'option_category_base',     '_wp_filter_taxonomy_base'            );
212
-add_filter( 'the_posts',                '_close_comments_for_old_posts', 10, 2);
213
-add_filter( 'comments_open',            '_close_comments_for_old_post', 10, 2 );
214
-add_filter( 'pings_open',               '_close_comments_for_old_post', 10, 2 );
215
-add_filter( 'editable_slug',            'urldecode'                           );
216
-add_filter( 'editable_slug',            'esc_textarea'                        );
217
-add_filter( 'nav_menu_meta_box_object', '_wp_nav_menu_meta_box_object'        );
218
-add_filter( 'pingback_ping_source_uri', 'pingback_ping_source_uri'            );
219
-add_filter( 'xmlrpc_pingback_error',    'xmlrpc_pingback_error'               );
220
-add_filter( 'title_save_pre',           'trim'                                );
221
-
222
-add_action( 'transition_comment_status', '_clear_modified_cache_on_transition_comment_status', 10, 2 );
223
-
224
-add_filter( 'http_request_host_is_external',    'allowed_http_request_hosts', 10, 2 );
197
+add_filter('option_ping_sites', 'privacy_ping_filter');
198
+add_filter('option_blog_charset', '_wp_specialchars'); // IMPORTANT: This must not be wp_specialchars() or esc_html() or it'll cause an infinite loop
199
+add_filter('option_blog_charset', '_canonical_charset');
200
+add_filter('option_home', '_config_wp_home');
201
+add_filter('option_siteurl', '_config_wp_siteurl');
202
+add_filter('tiny_mce_before_init', '_mce_set_direction');
203
+add_filter('teeny_mce_before_init', '_mce_set_direction');
204
+add_filter('pre_kses', 'wp_pre_kses_less_than');
205
+add_filter('sanitize_title', 'sanitize_title_with_dashes', 10, 3);
206
+add_action('check_comment_flood', 'check_comment_flood_db', 10, 4);
207
+add_filter('comment_flood_filter', 'wp_throttle_comment_flood', 10, 3);
208
+add_filter('pre_comment_content', 'wp_rel_nofollow', 15);
209
+add_filter('comment_email', 'antispambot');
210
+add_filter('option_tag_base', '_wp_filter_taxonomy_base');
211
+add_filter('option_category_base', '_wp_filter_taxonomy_base');
212
+add_filter('the_posts', '_close_comments_for_old_posts', 10, 2);
213
+add_filter('comments_open', '_close_comments_for_old_post', 10, 2);
214
+add_filter('pings_open', '_close_comments_for_old_post', 10, 2);
215
+add_filter('editable_slug', 'urldecode');
216
+add_filter('editable_slug', 'esc_textarea');
217
+add_filter('nav_menu_meta_box_object', '_wp_nav_menu_meta_box_object');
218
+add_filter('pingback_ping_source_uri', 'pingback_ping_source_uri');
219
+add_filter('xmlrpc_pingback_error', 'xmlrpc_pingback_error');
220
+add_filter('title_save_pre', 'trim');
221
+
222
+add_action('transition_comment_status', '_clear_modified_cache_on_transition_comment_status', 10, 2);
223
+
224
+add_filter('http_request_host_is_external', 'allowed_http_request_hosts', 10, 2);
225 225
 
226 226
 // REST API filters.
227
-add_action( 'xmlrpc_rsd_apis',            'rest_output_rsd' );
228
-add_action( 'wp_head',                    'rest_output_link_wp_head', 10, 0 );
229
-add_action( 'template_redirect',          'rest_output_link_header', 11, 0 );
230
-add_action( 'auth_cookie_malformed',      'rest_cookie_collect_status' );
231
-add_action( 'auth_cookie_expired',        'rest_cookie_collect_status' );
232
-add_action( 'auth_cookie_bad_username',   'rest_cookie_collect_status' );
233
-add_action( 'auth_cookie_bad_hash',       'rest_cookie_collect_status' );
234
-add_action( 'auth_cookie_valid',          'rest_cookie_collect_status' );
235
-add_filter( 'rest_authentication_errors', 'rest_cookie_check_errors', 100 );
227
+add_action('xmlrpc_rsd_apis', 'rest_output_rsd');
228
+add_action('wp_head', 'rest_output_link_wp_head', 10, 0);
229
+add_action('template_redirect', 'rest_output_link_header', 11, 0);
230
+add_action('auth_cookie_malformed', 'rest_cookie_collect_status');
231
+add_action('auth_cookie_expired', 'rest_cookie_collect_status');
232
+add_action('auth_cookie_bad_username', 'rest_cookie_collect_status');
233
+add_action('auth_cookie_bad_hash', 'rest_cookie_collect_status');
234
+add_action('auth_cookie_valid', 'rest_cookie_collect_status');
235
+add_filter('rest_authentication_errors', 'rest_cookie_check_errors', 100);
236 236
 
237 237
 // Actions
238
-add_action( 'wp_head',             '_wp_render_title_tag',            1     );
239
-add_action( 'wp_head',             'wp_enqueue_scripts',              1     );
240
-add_action( 'wp_head',             'wp_resource_hints',               2     );
241
-add_action( 'wp_head',             'feed_links',                      2     );
242
-add_action( 'wp_head',             'feed_links_extra',                3     );
243
-add_action( 'wp_head',             'rsd_link'                               );
244
-add_action( 'wp_head',             'wlwmanifest_link'                       );
245
-add_action( 'wp_head',             'adjacent_posts_rel_link_wp_head', 10, 0 );
246
-add_action( 'wp_head',             'locale_stylesheet'                      );
247
-add_action( 'publish_future_post', 'check_and_publish_future_post',   10, 1 );
248
-add_action( 'wp_head',             'noindex',                          1    );
249
-add_action( 'wp_head',             'print_emoji_detection_script',     7    );
250
-add_action( 'wp_head',             'wp_print_styles',                  8    );
251
-add_action( 'wp_head',             'wp_print_head_scripts',            9    );
252
-add_action( 'wp_head',             'wp_generator'                           );
253
-add_action( 'wp_head',             'rel_canonical'                          );
254
-add_action( 'wp_head',             'wp_shortlink_wp_head',            10, 0 );
255
-add_action( 'wp_head',             'wp_custom_css_cb',                101   );
256
-add_action( 'wp_head',             'wp_site_icon',                    99    );
257
-add_action( 'wp_footer',           'wp_print_footer_scripts',         20    );
258
-add_action( 'template_redirect',   'wp_shortlink_header',             11, 0 );
259
-add_action( 'wp_print_footer_scripts', '_wp_footer_scripts'                 );
260
-add_action( 'init',                'check_theme_switched',            99    );
261
-add_action( 'after_switch_theme',  '_wp_sidebars_changed'                   );
262
-add_action( 'wp_print_styles',     'print_emoji_styles'                     );
263
-
264
-if ( isset( $_GET['replytocom'] ) )
265
-    add_action( 'wp_head', 'wp_no_robots' );
238
+add_action('wp_head', '_wp_render_title_tag', 1);
239
+add_action('wp_head', 'wp_enqueue_scripts', 1);
240
+add_action('wp_head', 'wp_resource_hints', 2);
241
+add_action('wp_head', 'feed_links', 2);
242
+add_action('wp_head', 'feed_links_extra', 3);
243
+add_action('wp_head', 'rsd_link');
244
+add_action('wp_head', 'wlwmanifest_link');
245
+add_action('wp_head', 'adjacent_posts_rel_link_wp_head', 10, 0);
246
+add_action('wp_head', 'locale_stylesheet');
247
+add_action('publish_future_post', 'check_and_publish_future_post', 10, 1);
248
+add_action('wp_head', 'noindex', 1);
249
+add_action('wp_head', 'print_emoji_detection_script', 7);
250
+add_action('wp_head', 'wp_print_styles', 8);
251
+add_action('wp_head', 'wp_print_head_scripts', 9);
252
+add_action('wp_head', 'wp_generator');
253
+add_action('wp_head', 'rel_canonical');
254
+add_action('wp_head', 'wp_shortlink_wp_head', 10, 0);
255
+add_action('wp_head', 'wp_custom_css_cb', 101);
256
+add_action('wp_head', 'wp_site_icon', 99);
257
+add_action('wp_footer', 'wp_print_footer_scripts', 20);
258
+add_action('template_redirect', 'wp_shortlink_header', 11, 0);
259
+add_action('wp_print_footer_scripts', '_wp_footer_scripts');
260
+add_action('init', 'check_theme_switched', 99);
261
+add_action('after_switch_theme', '_wp_sidebars_changed');
262
+add_action('wp_print_styles', 'print_emoji_styles');
263
+
264
+if (isset($_GET['replytocom']))
265
+    add_action('wp_head', 'wp_no_robots');
266 266
 
267 267
 // Login actions
268
-add_filter( 'login_head',          'wp_resource_hints',             8     );
269
-add_action( 'login_head',          'wp_print_head_scripts',         9     );
270
-add_action( 'login_head',          'print_admin_styles',            9     );
271
-add_action( 'login_head',          'wp_site_icon',                  99    );
272
-add_action( 'login_footer',        'wp_print_footer_scripts',       20    );
273
-add_action( 'login_init',          'send_frame_options_header',     10, 0 );
268
+add_filter('login_head', 'wp_resource_hints', 8);
269
+add_action('login_head', 'wp_print_head_scripts', 9);
270
+add_action('login_head', 'print_admin_styles', 9);
271
+add_action('login_head', 'wp_site_icon', 99);
272
+add_action('login_footer', 'wp_print_footer_scripts', 20);
273
+add_action('login_init', 'send_frame_options_header', 10, 0);
274 274
 
275 275
 // Feed Generator Tags
276
-foreach ( array( 'rss2_head', 'commentsrss2_head', 'rss_head', 'rdf_header', 'atom_head', 'comments_atom_head', 'opml_head', 'app_head' ) as $action ) {
277
-	add_action( $action, 'the_generator' );
276
+foreach (array('rss2_head', 'commentsrss2_head', 'rss_head', 'rdf_header', 'atom_head', 'comments_atom_head', 'opml_head', 'app_head') as $action) {
277
+	add_action($action, 'the_generator');
278 278
 }
279 279
 
280 280
 // Feed Site Icon
281
-add_action( 'atom_head', 'atom_site_icon' );
282
-add_action( 'rss2_head', 'rss2_site_icon' );
281
+add_action('atom_head', 'atom_site_icon');
282
+add_action('rss2_head', 'rss2_site_icon');
283 283
 
284 284
 
285 285
 // WP Cron
286
-if ( !defined( 'DOING_CRON' ) )
287
-	add_action( 'init', 'wp_cron' );
286
+if ( ! defined('DOING_CRON'))
287
+	add_action('init', 'wp_cron');
288 288
 
289 289
 // 2 Actions 2 Furious
290
-add_action( 'do_feed_rdf',                'do_feed_rdf',                             10, 1 );
291
-add_action( 'do_feed_rss',                'do_feed_rss',                             10, 1 );
292
-add_action( 'do_feed_rss2',               'do_feed_rss2',                            10, 1 );
293
-add_action( 'do_feed_atom',               'do_feed_atom',                            10, 1 );
294
-add_action( 'do_pings',                   'do_all_pings',                            10, 1 );
295
-add_action( 'do_robots',                  'do_robots'                                      );
296
-add_action( 'set_comment_cookies',        'wp_set_comment_cookies',                  10, 2 );
297
-add_action( 'sanitize_comment_cookies',   'sanitize_comment_cookies'                       );
298
-add_action( 'admin_print_scripts',        'print_emoji_detection_script'                   );
299
-add_action( 'admin_print_scripts',        'print_head_scripts',                      20    );
300
-add_action( 'admin_print_footer_scripts', '_wp_footer_scripts'                             );
301
-add_action( 'admin_print_styles',         'print_emoji_styles'                             );
302
-add_action( 'admin_print_styles',         'print_admin_styles',                      20    );
303
-add_action( 'init',                       'smilies_init',                             5    );
304
-add_action( 'plugins_loaded',             'wp_maybe_load_widgets',                    0    );
305
-add_action( 'plugins_loaded',             'wp_maybe_load_embeds',                     0    );
306
-add_action( 'shutdown',                   'wp_ob_end_flush_all',                      1    );
290
+add_action('do_feed_rdf', 'do_feed_rdf', 10, 1);
291
+add_action('do_feed_rss', 'do_feed_rss', 10, 1);
292
+add_action('do_feed_rss2', 'do_feed_rss2', 10, 1);
293
+add_action('do_feed_atom', 'do_feed_atom', 10, 1);
294
+add_action('do_pings', 'do_all_pings', 10, 1);
295
+add_action('do_robots', 'do_robots');
296
+add_action('set_comment_cookies', 'wp_set_comment_cookies', 10, 2);
297
+add_action('sanitize_comment_cookies', 'sanitize_comment_cookies');
298
+add_action('admin_print_scripts', 'print_emoji_detection_script');
299
+add_action('admin_print_scripts', 'print_head_scripts', 20);
300
+add_action('admin_print_footer_scripts', '_wp_footer_scripts');
301
+add_action('admin_print_styles', 'print_emoji_styles');
302
+add_action('admin_print_styles', 'print_admin_styles', 20);
303
+add_action('init', 'smilies_init', 5);
304
+add_action('plugins_loaded', 'wp_maybe_load_widgets', 0);
305
+add_action('plugins_loaded', 'wp_maybe_load_embeds', 0);
306
+add_action('shutdown', 'wp_ob_end_flush_all', 1);
307 307
 // Create a revision whenever a post is updated.
308
-add_action( 'post_updated',               'wp_save_post_revision',                   10, 1 );
309
-add_action( 'publish_post',               '_publish_post_hook',                       5, 1 );
310
-add_action( 'transition_post_status',     '_transition_post_status',                  5, 3 );
311
-add_action( 'transition_post_status',     '_update_term_count_on_transition_post_status', 10, 3 );
312
-add_action( 'comment_form',               'wp_comment_form_unfiltered_html_nonce'          );
313
-add_action( 'wp_scheduled_delete',        'wp_scheduled_delete'                            );
314
-add_action( 'wp_scheduled_auto_draft_delete', 'wp_delete_auto_drafts'                      );
315
-add_action( 'admin_init',                 'send_frame_options_header',               10, 0 );
316
-add_action( 'importer_scheduled_cleanup', 'wp_delete_attachment'                           );
317
-add_action( 'upgrader_scheduled_cleanup', 'wp_delete_attachment'                           );
318
-add_action( 'welcome_panel',              'wp_welcome_panel'                               );
308
+add_action('post_updated', 'wp_save_post_revision', 10, 1);
309
+add_action('publish_post', '_publish_post_hook', 5, 1);
310
+add_action('transition_post_status', '_transition_post_status', 5, 3);
311
+add_action('transition_post_status', '_update_term_count_on_transition_post_status', 10, 3);
312
+add_action('comment_form', 'wp_comment_form_unfiltered_html_nonce');
313
+add_action('wp_scheduled_delete', 'wp_scheduled_delete');
314
+add_action('wp_scheduled_auto_draft_delete', 'wp_delete_auto_drafts');
315
+add_action('admin_init', 'send_frame_options_header', 10, 0);
316
+add_action('importer_scheduled_cleanup', 'wp_delete_attachment');
317
+add_action('upgrader_scheduled_cleanup', 'wp_delete_attachment');
318
+add_action('welcome_panel', 'wp_welcome_panel');
319 319
 
320 320
 // Navigation menu actions
321
-add_action( 'delete_post',                '_wp_delete_post_menu_item'         );
322
-add_action( 'delete_term',                '_wp_delete_tax_menu_item',   10, 3 );
323
-add_action( 'transition_post_status',     '_wp_auto_add_pages_to_menu', 10, 3 );
321
+add_action('delete_post', '_wp_delete_post_menu_item');
322
+add_action('delete_term', '_wp_delete_tax_menu_item', 10, 3);
323
+add_action('transition_post_status', '_wp_auto_add_pages_to_menu', 10, 3);
324 324
 
325 325
 // Post Thumbnail CSS class filtering
326
-add_action( 'begin_fetch_post_thumbnail_html', '_wp_post_thumbnail_class_filter_add'    );
327
-add_action( 'end_fetch_post_thumbnail_html',   '_wp_post_thumbnail_class_filter_remove' );
326
+add_action('begin_fetch_post_thumbnail_html', '_wp_post_thumbnail_class_filter_add');
327
+add_action('end_fetch_post_thumbnail_html', '_wp_post_thumbnail_class_filter_remove');
328 328
 
329 329
 // Redirect Old Slugs
330
-add_action( 'template_redirect',  'wp_old_slug_redirect'              );
331
-add_action( 'post_updated',       'wp_check_for_changed_slugs', 12, 3 );
332
-add_action( 'attachment_updated', 'wp_check_for_changed_slugs', 12, 3 );
330
+add_action('template_redirect', 'wp_old_slug_redirect');
331
+add_action('post_updated', 'wp_check_for_changed_slugs', 12, 3);
332
+add_action('attachment_updated', 'wp_check_for_changed_slugs', 12, 3);
333 333
 
334 334
 // Nonce check for Post Previews
335
-add_action( 'init', '_show_post_preview' );
335
+add_action('init', '_show_post_preview');
336 336
 
337 337
 // Output JS to reset window.name for previews
338
-add_action( 'wp_head', 'wp_post_preview_js', 1 );
338
+add_action('wp_head', 'wp_post_preview_js', 1);
339 339
 
340 340
 // Timezone
341
-add_filter( 'pre_option_gmt_offset','wp_timezone_override_offset' );
341
+add_filter('pre_option_gmt_offset', 'wp_timezone_override_offset');
342 342
 
343 343
 // Admin Color Schemes
344
-add_action( 'admin_init', 'register_admin_color_schemes', 1);
345
-add_action( 'admin_color_scheme_picker', 'admin_color_scheme_picker' );
344
+add_action('admin_init', 'register_admin_color_schemes', 1);
345
+add_action('admin_color_scheme_picker', 'admin_color_scheme_picker');
346 346
 
347 347
 // If the upgrade hasn't run yet, assume link manager is used.
348
-add_filter( 'default_option_link_manager_enabled', '__return_true' );
348
+add_filter('default_option_link_manager_enabled', '__return_true');
349 349
 
350 350
 // This option no longer exists; tell plugins we always support auto-embedding.
351
-add_filter( 'default_option_embed_autourls', '__return_true' );
351
+add_filter('default_option_embed_autourls', '__return_true');
352 352
 
353 353
 // Default settings for heartbeat
354
-add_filter( 'heartbeat_settings', 'wp_heartbeat_settings' );
354
+add_filter('heartbeat_settings', 'wp_heartbeat_settings');
355 355
 
356 356
 // Check if the user is logged out
357
-add_action( 'admin_enqueue_scripts', 'wp_auth_check_load' );
358
-add_filter( 'heartbeat_send',        'wp_auth_check' );
359
-add_filter( 'heartbeat_nopriv_send', 'wp_auth_check' );
357
+add_action('admin_enqueue_scripts', 'wp_auth_check_load');
358
+add_filter('heartbeat_send', 'wp_auth_check');
359
+add_filter('heartbeat_nopriv_send', 'wp_auth_check');
360 360
 
361 361
 // Default authentication filters
362
-add_filter( 'authenticate', 'wp_authenticate_username_password',  20, 3 );
363
-add_filter( 'authenticate', 'wp_authenticate_email_password',     20, 3 );
364
-add_filter( 'authenticate', 'wp_authenticate_spam_check',         99    );
365
-add_filter( 'determine_current_user', 'wp_validate_auth_cookie'          );
366
-add_filter( 'determine_current_user', 'wp_validate_logged_in_cookie', 20 );
362
+add_filter('authenticate', 'wp_authenticate_username_password', 20, 3);
363
+add_filter('authenticate', 'wp_authenticate_email_password', 20, 3);
364
+add_filter('authenticate', 'wp_authenticate_spam_check', 99);
365
+add_filter('determine_current_user', 'wp_validate_auth_cookie');
366
+add_filter('determine_current_user', 'wp_validate_logged_in_cookie', 20);
367 367
 
368 368
 // Split term updates.
369
-add_action( 'admin_init',        '_wp_check_for_scheduled_split_terms' );
370
-add_action( 'split_shared_term', '_wp_check_split_default_terms',  10, 4 );
371
-add_action( 'split_shared_term', '_wp_check_split_terms_in_menus', 10, 4 );
372
-add_action( 'split_shared_term', '_wp_check_split_nav_menu_terms', 10, 4 );
373
-add_action( 'wp_split_shared_term_batch', '_wp_batch_split_terms' );
369
+add_action('admin_init', '_wp_check_for_scheduled_split_terms');
370
+add_action('split_shared_term', '_wp_check_split_default_terms', 10, 4);
371
+add_action('split_shared_term', '_wp_check_split_terms_in_menus', 10, 4);
372
+add_action('split_shared_term', '_wp_check_split_nav_menu_terms', 10, 4);
373
+add_action('wp_split_shared_term_batch', '_wp_batch_split_terms');
374 374
 
375 375
 // Email notifications.
376
-add_action( 'comment_post', 'wp_new_comment_notify_moderator' );
377
-add_action( 'comment_post', 'wp_new_comment_notify_postauthor' );
378
-add_action( 'after_password_reset', 'wp_password_change_notification' );
379
-add_action( 'register_new_user',      'wp_send_new_user_notifications' );
380
-add_action( 'edit_user_created_user', 'wp_send_new_user_notifications', 10, 2 );
376
+add_action('comment_post', 'wp_new_comment_notify_moderator');
377
+add_action('comment_post', 'wp_new_comment_notify_postauthor');
378
+add_action('after_password_reset', 'wp_password_change_notification');
379
+add_action('register_new_user', 'wp_send_new_user_notifications');
380
+add_action('edit_user_created_user', 'wp_send_new_user_notifications', 10, 2);
381 381
 
382 382
 // REST API actions.
383
-add_action( 'init',          'rest_api_init' );
384
-add_action( 'rest_api_init', 'rest_api_default_filters',   10, 1 );
385
-add_action( 'rest_api_init', 'register_initial_settings',  10 );
386
-add_action( 'rest_api_init', 'create_initial_rest_routes', 99 );
387
-add_action( 'parse_request', 'rest_api_loaded' );
383
+add_action('init', 'rest_api_init');
384
+add_action('rest_api_init', 'rest_api_default_filters', 10, 1);
385
+add_action('rest_api_init', 'register_initial_settings', 10);
386
+add_action('rest_api_init', 'create_initial_rest_routes', 99);
387
+add_action('parse_request', 'rest_api_loaded');
388 388
 
389 389
 /**
390 390
  * Filters formerly mixed into wp-includes
391 391
  */
392 392
 // Theme
393
-add_action( 'wp_loaded', '_custom_header_background_just_in_time' );
394
-add_action( 'wp_head', '_custom_logo_header_styles' );
395
-add_action( 'plugins_loaded', '_wp_customize_include' );
396
-add_action( 'transition_post_status', '_wp_customize_publish_changeset', 10, 3 );
397
-add_action( 'admin_enqueue_scripts', '_wp_customize_loader_settings' );
398
-add_action( 'delete_attachment', '_delete_attachment_theme_mod' );
393
+add_action('wp_loaded', '_custom_header_background_just_in_time');
394
+add_action('wp_head', '_custom_logo_header_styles');
395
+add_action('plugins_loaded', '_wp_customize_include');
396
+add_action('transition_post_status', '_wp_customize_publish_changeset', 10, 3);
397
+add_action('admin_enqueue_scripts', '_wp_customize_loader_settings');
398
+add_action('delete_attachment', '_delete_attachment_theme_mod');
399 399
 
400 400
 // Calendar widget cache
401
-add_action( 'save_post', 'delete_get_calendar_cache' );
402
-add_action( 'delete_post', 'delete_get_calendar_cache' );
403
-add_action( 'update_option_start_of_week', 'delete_get_calendar_cache' );
404
-add_action( 'update_option_gmt_offset', 'delete_get_calendar_cache' );
401
+add_action('save_post', 'delete_get_calendar_cache');
402
+add_action('delete_post', 'delete_get_calendar_cache');
403
+add_action('update_option_start_of_week', 'delete_get_calendar_cache');
404
+add_action('update_option_gmt_offset', 'delete_get_calendar_cache');
405 405
 
406 406
 // Author
407
-add_action( 'transition_post_status', '__clear_multi_author_cache' );
407
+add_action('transition_post_status', '__clear_multi_author_cache');
408 408
 
409 409
 // Post
410
-add_action( 'init', 'create_initial_post_types', 0 ); // highest priority
411
-add_action( 'admin_menu', '_add_post_type_submenus' );
412
-add_action( 'before_delete_post', '_reset_front_page_settings_for_post' );
413
-add_action( 'wp_trash_post',      '_reset_front_page_settings_for_post' );
414
-add_action( 'change_locale', 'create_initial_post_types' );
410
+add_action('init', 'create_initial_post_types', 0); // highest priority
411
+add_action('admin_menu', '_add_post_type_submenus');
412
+add_action('before_delete_post', '_reset_front_page_settings_for_post');
413
+add_action('wp_trash_post', '_reset_front_page_settings_for_post');
414
+add_action('change_locale', 'create_initial_post_types');
415 415
 
416 416
 // Post Formats
417
-add_filter( 'request', '_post_format_request' );
418
-add_filter( 'term_link', '_post_format_link', 10, 3 );
419
-add_filter( 'get_post_format', '_post_format_get_term' );
420
-add_filter( 'get_terms', '_post_format_get_terms', 10, 3 );
421
-add_filter( 'wp_get_object_terms', '_post_format_wp_get_object_terms' );
417
+add_filter('request', '_post_format_request');
418
+add_filter('term_link', '_post_format_link', 10, 3);
419
+add_filter('get_post_format', '_post_format_get_term');
420
+add_filter('get_terms', '_post_format_get_terms', 10, 3);
421
+add_filter('wp_get_object_terms', '_post_format_wp_get_object_terms');
422 422
 
423 423
 // KSES
424
-add_action( 'init', 'kses_init' );
425
-add_action( 'set_current_user', 'kses_init' );
424
+add_action('init', 'kses_init');
425
+add_action('set_current_user', 'kses_init');
426 426
 
427 427
 // Script Loader
428
-add_action( 'wp_default_scripts', 'wp_default_scripts' );
429
-add_action( 'wp_enqueue_scripts', 'wp_localize_jquery_ui_datepicker', 1000 );
430
-add_action( 'admin_enqueue_scripts', 'wp_localize_jquery_ui_datepicker', 1000 );
431
-add_filter( 'wp_print_scripts', 'wp_just_in_time_script_localization' );
432
-add_filter( 'print_scripts_array', 'wp_prototype_before_jquery' );
433
-add_filter( 'customize_controls_print_styles', 'wp_resource_hints', 1 );
428
+add_action('wp_default_scripts', 'wp_default_scripts');
429
+add_action('wp_enqueue_scripts', 'wp_localize_jquery_ui_datepicker', 1000);
430
+add_action('admin_enqueue_scripts', 'wp_localize_jquery_ui_datepicker', 1000);
431
+add_filter('wp_print_scripts', 'wp_just_in_time_script_localization');
432
+add_filter('print_scripts_array', 'wp_prototype_before_jquery');
433
+add_filter('customize_controls_print_styles', 'wp_resource_hints', 1);
434 434
 
435
-add_action( 'wp_default_styles', 'wp_default_styles' );
436
-add_filter( 'style_loader_src', 'wp_style_loader_src', 10, 2 );
435
+add_action('wp_default_styles', 'wp_default_styles');
436
+add_filter('style_loader_src', 'wp_style_loader_src', 10, 2);
437 437
 
438 438
 // Taxonomy
439
-add_action( 'init', 'create_initial_taxonomies', 0 ); // highest priority
440
-add_action( 'change_locale', 'create_initial_taxonomies' );
439
+add_action('init', 'create_initial_taxonomies', 0); // highest priority
440
+add_action('change_locale', 'create_initial_taxonomies');
441 441
 
442 442
 // Canonical
443
-add_action( 'template_redirect', 'redirect_canonical' );
444
-add_action( 'template_redirect', 'wp_redirect_admin_locations', 1000 );
443
+add_action('template_redirect', 'redirect_canonical');
444
+add_action('template_redirect', 'wp_redirect_admin_locations', 1000);
445 445
 
446 446
 // Shortcodes
447
-add_filter( 'the_content', 'do_shortcode', 11 ); // AFTER wpautop()
447
+add_filter('the_content', 'do_shortcode', 11); // AFTER wpautop()
448 448
 
449 449
 // Media
450
-add_action( 'wp_playlist_scripts', 'wp_playlist_scripts' );
451
-add_action( 'customize_controls_enqueue_scripts', 'wp_plupload_default_settings' );
450
+add_action('wp_playlist_scripts', 'wp_playlist_scripts');
451
+add_action('customize_controls_enqueue_scripts', 'wp_plupload_default_settings');
452 452
 
453 453
 // Nav menu
454
-add_filter( 'nav_menu_item_id', '_nav_menu_item_id_use_once', 10, 2 );
454
+add_filter('nav_menu_item_id', '_nav_menu_item_id_use_once', 10, 2);
455 455
 
456 456
 // Widgets
457
-add_action( 'init', 'wp_widgets_init', 1 );
457
+add_action('init', 'wp_widgets_init', 1);
458 458
 
459 459
 // Admin Bar
460 460
 // Don't remove. Wrong way to disable.
461
-add_action( 'template_redirect', '_wp_admin_bar_init', 0 );
462
-add_action( 'admin_init', '_wp_admin_bar_init' );
463
-add_action( 'before_signup_header', '_wp_admin_bar_init' );
464
-add_action( 'activate_header', '_wp_admin_bar_init' );
465
-add_action( 'wp_footer', 'wp_admin_bar_render', 1000 );
466
-add_action( 'in_admin_header', 'wp_admin_bar_render', 0 );
461
+add_action('template_redirect', '_wp_admin_bar_init', 0);
462
+add_action('admin_init', '_wp_admin_bar_init');
463
+add_action('before_signup_header', '_wp_admin_bar_init');
464
+add_action('activate_header', '_wp_admin_bar_init');
465
+add_action('wp_footer', 'wp_admin_bar_render', 1000);
466
+add_action('in_admin_header', 'wp_admin_bar_render', 0);
467 467
 
468 468
 // Former admin filters that can also be hooked on the front end
469
-add_action( 'media_buttons', 'media_buttons' );
470
-add_filter( 'image_send_to_editor', 'image_add_caption', 20, 8 );
471
-add_filter( 'media_send_to_editor', 'image_media_send_to_editor', 10, 3 );
469
+add_action('media_buttons', 'media_buttons');
470
+add_filter('image_send_to_editor', 'image_add_caption', 20, 8);
471
+add_filter('media_send_to_editor', 'image_media_send_to_editor', 10, 3);
472 472
 
473 473
 // Embeds
474
-add_action( 'rest_api_init',          'wp_oembed_register_route'              );
475
-add_filter( 'rest_pre_serve_request', '_oembed_rest_pre_serve_request', 10, 4 );
476
-
477
-add_action( 'wp_head',                'wp_oembed_add_discovery_links'         );
478
-add_action( 'wp_head',                'wp_oembed_add_host_js'                 );
479
-
480
-add_action( 'embed_head',             'enqueue_embed_scripts',           1    );
481
-add_action( 'embed_head',             'print_emoji_detection_script'          );
482
-add_action( 'embed_head',             'print_embed_styles'                    );
483
-add_action( 'embed_head',             'wp_print_head_scripts',          20    );
484
-add_action( 'embed_head',             'wp_print_styles',                20    );
485
-add_action( 'embed_head',             'wp_no_robots'                          );
486
-add_action( 'embed_head',             'rel_canonical'                         );
487
-add_action( 'embed_head',             'locale_stylesheet',              30    );
488
-
489
-add_action( 'embed_content_meta',     'print_embed_comments_button'           );
490
-add_action( 'embed_content_meta',     'print_embed_sharing_button'            );
491
-
492
-add_action( 'embed_footer',           'print_embed_sharing_dialog'            );
493
-add_action( 'embed_footer',           'print_embed_scripts'                   );
494
-add_action( 'embed_footer',           'wp_print_footer_scripts',        20    );
495
-
496
-add_filter( 'excerpt_more',           'wp_embed_excerpt_more',          20    );
497
-add_filter( 'the_excerpt_embed',      'wptexturize'                           );
498
-add_filter( 'the_excerpt_embed',      'convert_chars'                         );
499
-add_filter( 'the_excerpt_embed',      'wpautop'                               );
500
-add_filter( 'the_excerpt_embed',      'shortcode_unautop'                     );
501
-add_filter( 'the_excerpt_embed',      'wp_embed_excerpt_attachment'           );
502
-
503
-add_filter( 'oembed_dataparse',       'wp_filter_oembed_result',        10, 3 );
504
-add_filter( 'oembed_response_data',   'get_oembed_response_data_rich',  10, 4 );
505
-add_filter( 'pre_oembed_result',      'wp_filter_pre_oembed_result',    10, 3 );
506
-
507
-unset( $filter, $action );
474
+add_action('rest_api_init', 'wp_oembed_register_route');
475
+add_filter('rest_pre_serve_request', '_oembed_rest_pre_serve_request', 10, 4);
476
+
477
+add_action('wp_head', 'wp_oembed_add_discovery_links');
478
+add_action('wp_head', 'wp_oembed_add_host_js');
479
+
480
+add_action('embed_head', 'enqueue_embed_scripts', 1);
481
+add_action('embed_head', 'print_emoji_detection_script');
482
+add_action('embed_head', 'print_embed_styles');
483
+add_action('embed_head', 'wp_print_head_scripts', 20);
484
+add_action('embed_head', 'wp_print_styles', 20);
485
+add_action('embed_head', 'wp_no_robots');
486
+add_action('embed_head', 'rel_canonical');
487
+add_action('embed_head', 'locale_stylesheet', 30);
488
+
489
+add_action('embed_content_meta', 'print_embed_comments_button');
490
+add_action('embed_content_meta', 'print_embed_sharing_button');
491
+
492
+add_action('embed_footer', 'print_embed_sharing_dialog');
493
+add_action('embed_footer', 'print_embed_scripts');
494
+add_action('embed_footer', 'wp_print_footer_scripts', 20);
495
+
496
+add_filter('excerpt_more', 'wp_embed_excerpt_more', 20);
497
+add_filter('the_excerpt_embed', 'wptexturize');
498
+add_filter('the_excerpt_embed', 'convert_chars');
499
+add_filter('the_excerpt_embed', 'wpautop');
500
+add_filter('the_excerpt_embed', 'shortcode_unautop');
501
+add_filter('the_excerpt_embed', 'wp_embed_excerpt_attachment');
502
+
503
+add_filter('oembed_dataparse', 'wp_filter_oembed_result', 10, 3);
504
+add_filter('oembed_response_data', 'get_oembed_response_data_rich', 10, 4);
505
+add_filter('pre_oembed_result', 'wp_filter_pre_oembed_result', 10, 3);
506
+
507
+unset($filter, $action);
Please login to merge, or discard this patch.
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   +9 added lines, -12 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 ) {
@@ -428,7 +428,7 @@  discard block
 block discarded – undo
428 428
  * @since 2.0.5
429 429
  *
430 430
  * @param string|array|object $data Data that might be serialized.
431
- * @return mixed A scalar data
431
+ * @return string A scalar data
432 432
  */
433 433
 function maybe_serialize( $data ) {
434 434
 	if ( is_array( $data ) || is_object( $data ) )
@@ -763,9 +763,6 @@  discard block
 block discarded – undo
763 763
  *
764 764
  * @since 1.5.0
765 765
  *
766
- * @param string|array $key   Either a query variable key, or an associative array of query variables.
767
- * @param string       $value Optional. Either a query variable value, or a URL to act upon.
768
- * @param string       $url   Optional. A URL to act upon.
769 766
  * @return string New URL query string (unescaped).
770 767
  */
771 768
 function add_query_arg() {
@@ -1437,7 +1434,7 @@  discard block
 block discarded – undo
1437 1434
  * @since 2.0.4
1438 1435
  *
1439 1436
  * @param string     $actionurl URL to add nonce action.
1440
- * @param int|string $action    Optional. Nonce action name. Default -1.
1437
+ * @param integer $action    Optional. Nonce action name. Default -1.
1441 1438
  * @param string     $name      Optional. Nonce name. Default '_wpnonce'.
1442 1439
  * @return string Escaped URL with nonce action added.
1443 1440
  */
@@ -1466,7 +1463,7 @@  discard block
 block discarded – undo
1466 1463
  *
1467 1464
  * @since 2.0.4
1468 1465
  *
1469
- * @param int|string $action  Optional. Action name. Default -1.
1466
+ * @param integer $action  Optional. Action name. Default -1.
1470 1467
  * @param string     $name    Optional. Nonce name. Default '_wpnonce'.
1471 1468
  * @param bool       $referer Optional. Whether to set the referer field for validation. Default true.
1472 1469
  * @param bool       $echo    Optional. Whether to display or return hidden form field. Default true.
@@ -1558,7 +1555,7 @@  discard block
 block discarded – undo
1558 1555
  *
1559 1556
  * @since 4.5.0
1560 1557
  *
1561
- * @return string|false Referer URL on success, false on failure.
1558
+ * @return string Referer URL on success, false on failure.
1562 1559
  */
1563 1560
 function wp_get_raw_referer() {
1564 1561
 	if ( ! empty( $_REQUEST['_wp_http_referer'] ) ) {
@@ -1870,7 +1867,7 @@  discard block
 block discarded – undo
1870 1867
  * @param bool   $create_dir Optional. Whether to check and create the uploads directory.
1871 1868
  *                           Default true for backward compatibility.
1872 1869
  * @param bool   $refresh_cache Optional. Whether to refresh the cache. Default false.
1873
- * @return array See above for description.
1870
+ * @return callable|null See above for description.
1874 1871
  */
1875 1872
 function wp_upload_dir( $time = null, $create_dir = true, $refresh_cache = false ) {
1876 1873
 	static $cache = array(), $tested_paths = array();
@@ -4782,7 +4779,7 @@  discard block
 block discarded – undo
4782 4779
  *
4783 4780
  * @see __return_false()
4784 4781
  *
4785
- * @return true True.
4782
+ * @return boolean True.
4786 4783
  */
4787 4784
 function __return_true() {
4788 4785
 	return true;
@@ -4904,7 +4901,7 @@  discard block
 block discarded – undo
4904 4901
  * @param int      $start         The ID to start the loop check at.
4905 4902
  * @param int      $start_parent  The parent_ID of $start to use instead of calling $callback( $start ).
4906 4903
  *                                Use null to always use $callback
4907
- * @param array    $callback_args Optional. Additional arguments to send to $callback.
4904
+ * @param string[]    $callback_args Optional. Additional arguments to send to $callback.
4908 4905
  * @return array IDs of all members of loop.
4909 4906
  */
4910 4907
 function wp_find_hierarchy_loop( $callback, $start, $start_parent, $callback_args = array() ) {
@@ -5581,7 +5578,7 @@  discard block
 block discarded – undo
5581 5578
  *
5582 5579
  * @since 4.7.0
5583 5580
  *
5584
- * @param $group Where the cache contents are grouped.
5581
+ * @param string $group Where the cache contents are grouped.
5585 5582
  *
5586 5583
  * @return string $last_changed UNIX timestamp with microseconds representing when the group was last changed.
5587 5584
  */
Please login to merge, or discard this patch.
Spacing   +1047 added lines, -1047 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
 
@@ -161,41 +161,41 @@  discard block
 block discarded – undo
161 161
  * @param string $date Formatted date string.
162 162
  * @return string The date, declined if locale specifies it.
163 163
  */
164
-function wp_maybe_decline_date( $date ) {
164
+function wp_maybe_decline_date($date) {
165 165
 	global $wp_locale;
166 166
 
167 167
 	// i18n functions are not available in SHORTINIT mode
168
-	if ( ! function_exists( '_x' ) ) {
168
+	if ( ! function_exists('_x')) {
169 169
 		return $date;
170 170
 	}
171 171
 
172 172
 	/* translators: If months in your language require a genitive case,
173 173
 	 * translate this to 'on'. Do not translate into your own language.
174 174
 	 */
175
-	if ( 'on' === _x( 'off', 'decline months names: on or off' ) ) {
175
+	if ('on' === _x('off', 'decline months names: on or off')) {
176 176
 		// Match a format like 'j F Y' or 'j. F'
177
-		if ( @preg_match( '#^\d{1,2}\.? [^\d ]+#u', $date ) ) {
177
+		if (@preg_match('#^\d{1,2}\.? [^\d ]+#u', $date)) {
178 178
 			$months          = $wp_locale->month;
179 179
 			$months_genitive = $wp_locale->month_genitive;
180 180
 
181
-			foreach ( $months as $key => $month ) {
182
-				$months[ $key ] = '# ' . $month . '( |$)#u';
181
+			foreach ($months as $key => $month) {
182
+				$months[$key] = '# '.$month.'( |$)#u';
183 183
 			}
184 184
 
185
-			foreach ( $months_genitive as $key => $month ) {
186
-				$months_genitive[ $key ] = ' ' . $month . '$1';
185
+			foreach ($months_genitive as $key => $month) {
186
+				$months_genitive[$key] = ' '.$month.'$1';
187 187
 			}
188 188
 
189
-			$date = preg_replace( $months, $months_genitive, $date );
189
+			$date = preg_replace($months, $months_genitive, $date);
190 190
 		}
191 191
 	}
192 192
 
193 193
 	// Used for locale-specific rules
194 194
 	$locale = get_locale();
195 195
 
196
-	if ( 'ca' === $locale ) {
196
+	if ('ca' === $locale) {
197 197
 		// " de abril| de agost| de octubre..." -> " d'abril| d'agost| d'octubre..."
198
-		$date = preg_replace( '# de ([ao])#i', " d'\\1", $date );
198
+		$date = preg_replace('# de ([ao])#i', " d'\\1", $date);
199 199
 	}
200 200
 
201 201
 	return $date;
@@ -212,13 +212,13 @@  discard block
 block discarded – undo
212 212
  * @param int   $decimals Optional. Precision of the number of decimal places. Default 0.
213 213
  * @return string Converted number in string format.
214 214
  */
215
-function number_format_i18n( $number, $decimals = 0 ) {
215
+function number_format_i18n($number, $decimals = 0) {
216 216
 	global $wp_locale;
217 217
 
218
-	if ( isset( $wp_locale ) ) {
219
-		$formatted = number_format( $number, absint( $decimals ), $wp_locale->number_format['decimal_point'], $wp_locale->number_format['thousands_sep'] );
218
+	if (isset($wp_locale)) {
219
+		$formatted = number_format($number, absint($decimals), $wp_locale->number_format['decimal_point'], $wp_locale->number_format['thousands_sep']);
220 220
 	} else {
221
-		$formatted = number_format( $number, absint( $decimals ) );
221
+		$formatted = number_format($number, absint($decimals));
222 222
 	}
223 223
 
224 224
 	/**
@@ -228,7 +228,7 @@  discard block
 block discarded – undo
228 228
 	 *
229 229
 	 * @param string $formatted Converted number in string format.
230 230
 	 */
231
-	return apply_filters( 'number_format_i18n', $formatted );
231
+	return apply_filters('number_format_i18n', $formatted);
232 232
 }
233 233
 
234 234
 /**
@@ -251,7 +251,7 @@  discard block
 block discarded – undo
251 251
  * @param int        $decimals Optional. Precision of number of decimal places. Default 0.
252 252
  * @return string|false False on failure. Number string on success.
253 253
  */
254
-function size_format( $bytes, $decimals = 0 ) {
254
+function size_format($bytes, $decimals = 0) {
255 255
 	$quant = array(
256 256
 		'TB' => TB_IN_BYTES,
257 257
 		'GB' => GB_IN_BYTES,
@@ -260,13 +260,13 @@  discard block
 block discarded – undo
260 260
 		'B'  => 1,
261 261
 	);
262 262
 
263
-	if ( 0 === $bytes ) {
264
-		return number_format_i18n( 0, $decimals ) . ' B';
263
+	if (0 === $bytes) {
264
+		return number_format_i18n(0, $decimals).' B';
265 265
 	}
266 266
 
267
-	foreach ( $quant as $unit => $mag ) {
268
-		if ( doubleval( $bytes ) >= $mag ) {
269
-			return number_format_i18n( $bytes / $mag, $decimals ) . ' ' . $unit;
267
+	foreach ($quant as $unit => $mag) {
268
+		if (doubleval($bytes) >= $mag) {
269
+			return number_format_i18n($bytes / $mag, $decimals).' '.$unit;
270 270
 		}
271 271
 	}
272 272
 
@@ -282,34 +282,34 @@  discard block
 block discarded – undo
282 282
  * @param int|string $start_of_week Optional. Start of the week as an integer. Default empty string.
283 283
  * @return array Keys are 'start' and 'end'.
284 284
  */
285
-function get_weekstartend( $mysqlstring, $start_of_week = '' ) {
285
+function get_weekstartend($mysqlstring, $start_of_week = '') {
286 286
 	// MySQL string year.
287
-	$my = substr( $mysqlstring, 0, 4 );
287
+	$my = substr($mysqlstring, 0, 4);
288 288
 
289 289
 	// MySQL string month.
290
-	$mm = substr( $mysqlstring, 8, 2 );
290
+	$mm = substr($mysqlstring, 8, 2);
291 291
 
292 292
 	// MySQL string day.
293
-	$md = substr( $mysqlstring, 5, 2 );
293
+	$md = substr($mysqlstring, 5, 2);
294 294
 
295 295
 	// The timestamp for MySQL string day.
296
-	$day = mktime( 0, 0, 0, $md, $mm, $my );
296
+	$day = mktime(0, 0, 0, $md, $mm, $my);
297 297
 
298 298
 	// The day of the week from the timestamp.
299
-	$weekday = date( 'w', $day );
299
+	$weekday = date('w', $day);
300 300
 
301
-	if ( !is_numeric($start_of_week) )
302
-		$start_of_week = get_option( 'start_of_week' );
301
+	if ( ! is_numeric($start_of_week))
302
+		$start_of_week = get_option('start_of_week');
303 303
 
304
-	if ( $weekday < $start_of_week )
304
+	if ($weekday < $start_of_week)
305 305
 		$weekday += 7;
306 306
 
307 307
 	// The most recent week start day on or before $day.
308
-	$start = $day - DAY_IN_SECONDS * ( $weekday - $start_of_week );
308
+	$start = $day - DAY_IN_SECONDS * ($weekday - $start_of_week);
309 309
 
310 310
 	// $start + 1 week - 1 second.
311 311
 	$end = $start + WEEK_IN_SECONDS - 1;
312
-	return compact( 'start', 'end' );
312
+	return compact('start', 'end');
313 313
 }
314 314
 
315 315
 /**
@@ -320,9 +320,9 @@  discard block
 block discarded – undo
320 320
  * @param string $original Maybe unserialized original, if is needed.
321 321
  * @return mixed Unserialized data can be any type.
322 322
  */
323
-function maybe_unserialize( $original ) {
324
-	if ( is_serialized( $original ) ) // don't attempt to unserialize data that wasn't serialized going in
325
-		return @unserialize( $original );
323
+function maybe_unserialize($original) {
324
+	if (is_serialized($original)) // don't attempt to unserialize data that wasn't serialized going in
325
+		return @unserialize($original);
326 326
 	return $original;
327 327
 }
328 328
 
@@ -338,57 +338,57 @@  discard block
 block discarded – undo
338 338
  * @param bool   $strict Optional. Whether to be strict about the end of the string. Default true.
339 339
  * @return bool False if not serialized and true if it was.
340 340
  */
341
-function is_serialized( $data, $strict = true ) {
341
+function is_serialized($data, $strict = true) {
342 342
 	// if it isn't a string, it isn't serialized.
343
-	if ( ! is_string( $data ) ) {
343
+	if ( ! is_string($data)) {
344 344
 		return false;
345 345
 	}
346
-	$data = trim( $data );
347
- 	if ( 'N;' == $data ) {
346
+	$data = trim($data);
347
+ 	if ('N;' == $data) {
348 348
 		return true;
349 349
 	}
350
-	if ( strlen( $data ) < 4 ) {
350
+	if (strlen($data) < 4) {
351 351
 		return false;
352 352
 	}
353
-	if ( ':' !== $data[1] ) {
353
+	if (':' !== $data[1]) {
354 354
 		return false;
355 355
 	}
356
-	if ( $strict ) {
357
-		$lastc = substr( $data, -1 );
358
-		if ( ';' !== $lastc && '}' !== $lastc ) {
356
+	if ($strict) {
357
+		$lastc = substr($data, -1);
358
+		if (';' !== $lastc && '}' !== $lastc) {
359 359
 			return false;
360 360
 		}
361 361
 	} else {
362
-		$semicolon = strpos( $data, ';' );
363
-		$brace     = strpos( $data, '}' );
362
+		$semicolon = strpos($data, ';');
363
+		$brace     = strpos($data, '}');
364 364
 		// Either ; or } must exist.
365
-		if ( false === $semicolon && false === $brace )
365
+		if (false === $semicolon && false === $brace)
366 366
 			return false;
367 367
 		// But neither must be in the first X characters.
368
-		if ( false !== $semicolon && $semicolon < 3 )
368
+		if (false !== $semicolon && $semicolon < 3)
369 369
 			return false;
370
-		if ( false !== $brace && $brace < 4 )
370
+		if (false !== $brace && $brace < 4)
371 371
 			return false;
372 372
 	}
373 373
 	$token = $data[0];
374
-	switch ( $token ) {
374
+	switch ($token) {
375 375
 		case 's' :
376
-			if ( $strict ) {
377
-				if ( '"' !== substr( $data, -2, 1 ) ) {
376
+			if ($strict) {
377
+				if ('"' !== substr($data, -2, 1)) {
378 378
 					return false;
379 379
 				}
380
-			} elseif ( false === strpos( $data, '"' ) ) {
380
+			} elseif (false === strpos($data, '"')) {
381 381
 				return false;
382 382
 			}
383 383
 			// or else fall through
384 384
 		case 'a' :
385 385
 		case 'O' :
386
-			return (bool) preg_match( "/^{$token}:[0-9]+:/s", $data );
386
+			return (bool) preg_match("/^{$token}:[0-9]+:/s", $data);
387 387
 		case 'b' :
388 388
 		case 'i' :
389 389
 		case 'd' :
390 390
 			$end = $strict ? '$' : '';
391
-			return (bool) preg_match( "/^{$token}:[0-9.E-]+;$end/", $data );
391
+			return (bool) preg_match("/^{$token}:[0-9.E-]+;$end/", $data);
392 392
 	}
393 393
 	return false;
394 394
 }
@@ -401,21 +401,21 @@  discard block
 block discarded – undo
401 401
  * @param string $data Serialized data.
402 402
  * @return bool False if not a serialized string, true if it is.
403 403
  */
404
-function is_serialized_string( $data ) {
404
+function is_serialized_string($data) {
405 405
 	// if it isn't a string, it isn't a serialized string.
406
-	if ( ! is_string( $data ) ) {
406
+	if ( ! is_string($data)) {
407 407
 		return false;
408 408
 	}
409
-	$data = trim( $data );
410
-	if ( strlen( $data ) < 4 ) {
409
+	$data = trim($data);
410
+	if (strlen($data) < 4) {
411 411
 		return false;
412
-	} elseif ( ':' !== $data[1] ) {
412
+	} elseif (':' !== $data[1]) {
413 413
 		return false;
414
-	} elseif ( ';' !== substr( $data, -1 ) ) {
414
+	} elseif (';' !== substr($data, -1)) {
415 415
 		return false;
416
-	} elseif ( $data[0] !== 's' ) {
416
+	} elseif ($data[0] !== 's') {
417 417
 		return false;
418
-	} elseif ( '"' !== substr( $data, -2, 1 ) ) {
418
+	} elseif ('"' !== substr($data, -2, 1)) {
419 419
 		return false;
420 420
 	} else {
421 421
 		return true;
@@ -430,15 +430,15 @@  discard block
 block discarded – undo
430 430
  * @param string|array|object $data Data that might be serialized.
431 431
  * @return mixed A scalar data
432 432
  */
433
-function maybe_serialize( $data ) {
434
-	if ( is_array( $data ) || is_object( $data ) )
435
-		return serialize( $data );
433
+function maybe_serialize($data) {
434
+	if (is_array($data) || is_object($data))
435
+		return serialize($data);
436 436
 
437 437
 	// Double serialization is required for backward compatibility.
438 438
 	// See https://core.trac.wordpress.org/ticket/12930
439 439
 	// Also the world will end. See WP 3.6.1.
440
-	if ( is_serialized( $data, false ) )
441
-		return serialize( $data );
440
+	if (is_serialized($data, false))
441
+		return serialize($data);
442 442
 
443 443
 	return $data;
444 444
 }
@@ -456,9 +456,9 @@  discard block
 block discarded – undo
456 456
  * @param string $content XMLRPC XML Request content
457 457
  * @return string Post title
458 458
  */
459
-function xmlrpc_getposttitle( $content ) {
459
+function xmlrpc_getposttitle($content) {
460 460
 	global $post_default_title;
461
-	if ( preg_match( '/<title>(.+?)<\/title>/is', $content, $matchtitle ) ) {
461
+	if (preg_match('/<title>(.+?)<\/title>/is', $content, $matchtitle)) {
462 462
 		$post_title = $matchtitle[1];
463 463
 	} else {
464 464
 		$post_title = $post_default_title;
@@ -480,11 +480,11 @@  discard block
 block discarded – undo
480 480
  * @param string $content XMLRPC XML Request content
481 481
  * @return string|array List of categories or category name.
482 482
  */
483
-function xmlrpc_getpostcategory( $content ) {
483
+function xmlrpc_getpostcategory($content) {
484 484
 	global $post_default_category;
485
-	if ( preg_match( '/<category>(.+?)<\/category>/is', $content, $matchcat ) ) {
486
-		$post_category = trim( $matchcat[1], ',' );
487
-		$post_category = explode( ',', $post_category );
485
+	if (preg_match('/<category>(.+?)<\/category>/is', $content, $matchcat)) {
486
+		$post_category = trim($matchcat[1], ',');
487
+		$post_category = explode(',', $post_category);
488 488
 	} else {
489 489
 		$post_category = $post_default_category;
490 490
 	}
@@ -499,10 +499,10 @@  discard block
 block discarded – undo
499 499
  * @param string $content XML-RPC XML Request content.
500 500
  * @return string XMLRPC XML Request content without title and category elements.
501 501
  */
502
-function xmlrpc_removepostdata( $content ) {
503
-	$content = preg_replace( '/<title>(.+?)<\/title>/si', '', $content );
504
-	$content = preg_replace( '/<category>(.+?)<\/category>/si', '', $content );
505
-	$content = trim( $content );
502
+function xmlrpc_removepostdata($content) {
503
+	$content = preg_replace('/<title>(.+?)<\/title>/si', '', $content);
504
+	$content = preg_replace('/<category>(.+?)<\/category>/si', '', $content);
505
+	$content = trim($content);
506 506
 	return $content;
507 507
 }
508 508
 
@@ -514,7 +514,7 @@  discard block
 block discarded – undo
514 514
  * @param string $content Content to extract URLs from.
515 515
  * @return array URLs found in passed string.
516 516
  */
517
-function wp_extract_urls( $content ) {
517
+function wp_extract_urls($content) {
518 518
 	preg_match_all(
519 519
 		"#([\"']?)("
520 520
 			. "(?:([\w-]+:)?//?)"
@@ -532,9 +532,9 @@  discard block
 block discarded – undo
532 532
 		$post_links
533 533
 	);
534 534
 
535
-	$post_links = array_unique( array_map( 'html_entity_decode', $post_links[2] ) );
535
+	$post_links = array_unique(array_map('html_entity_decode', $post_links[2]));
536 536
 
537
-	return array_values( $post_links );
537
+	return array_values($post_links);
538 538
 }
539 539
 
540 540
 /**
@@ -551,34 +551,34 @@  discard block
 block discarded – undo
551 551
  * @param string $content Post Content.
552 552
  * @param int    $post_ID Post ID.
553 553
  */
554
-function do_enclose( $content, $post_ID ) {
554
+function do_enclose($content, $post_ID) {
555 555
 	global $wpdb;
556 556
 
557 557
 	//TODO: Tidy this ghetto code up and make the debug code optional
558
-	include_once( ABSPATH . WPINC . '/class-IXR.php' );
558
+	include_once(ABSPATH.WPINC.'/class-IXR.php');
559 559
 
560 560
 	$post_links = array();
561 561
 
562
-	$pung = get_enclosed( $post_ID );
562
+	$pung = get_enclosed($post_ID);
563 563
 
564
-	$post_links_temp = wp_extract_urls( $content );
564
+	$post_links_temp = wp_extract_urls($content);
565 565
 
566
-	foreach ( $pung as $link_test ) {
567
-		if ( ! in_array( $link_test, $post_links_temp ) ) { // link no longer in post
568
-			$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 ) . '%') );
569
-			foreach ( $mids as $mid )
570
-				delete_metadata_by_mid( 'post', $mid );
566
+	foreach ($pung as $link_test) {
567
+		if ( ! in_array($link_test, $post_links_temp)) { // link no longer in post
568
+			$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).'%'));
569
+			foreach ($mids as $mid)
570
+				delete_metadata_by_mid('post', $mid);
571 571
 		}
572 572
 	}
573 573
 
574
-	foreach ( (array) $post_links_temp as $link_test ) {
575
-		if ( !in_array( $link_test, $pung ) ) { // If we haven't pung it already
576
-			$test = @parse_url( $link_test );
577
-			if ( false === $test )
574
+	foreach ((array) $post_links_temp as $link_test) {
575
+		if ( ! in_array($link_test, $pung)) { // If we haven't pung it already
576
+			$test = @parse_url($link_test);
577
+			if (false === $test)
578 578
 				continue;
579
-			if ( isset( $test['query'] ) )
579
+			if (isset($test['query']))
580 580
 				$post_links[] = $link_test;
581
-			elseif ( isset($test['path']) && ( $test['path'] != '/' ) &&  ($test['path'] != '' ) )
581
+			elseif (isset($test['path']) && ($test['path'] != '/') && ($test['path'] != ''))
582 582
 				$post_links[] = $link_test;
583 583
 		}
584 584
 	}
@@ -594,24 +594,24 @@  discard block
 block discarded – undo
594 594
 	 * @param array $post_links An array of enclosure links.
595 595
 	 * @param int   $post_ID    Post ID.
596 596
 	 */
597
-	$post_links = apply_filters( 'enclosure_links', $post_links, $post_ID );
597
+	$post_links = apply_filters('enclosure_links', $post_links, $post_ID);
598 598
 
599
-	foreach ( (array) $post_links as $url ) {
600
-		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 ) . '%' ) ) ) {
599
+	foreach ((array) $post_links as $url) {
600
+		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 601
 
602
-			if ( $headers = wp_get_http_headers( $url) ) {
603
-				$len = isset( $headers['content-length'] ) ? (int) $headers['content-length'] : 0;
604
-				$type = isset( $headers['content-type'] ) ? $headers['content-type'] : '';
605
-				$allowed_types = array( 'video', 'audio' );
602
+			if ($headers = wp_get_http_headers($url)) {
603
+				$len = isset($headers['content-length']) ? (int) $headers['content-length'] : 0;
604
+				$type = isset($headers['content-type']) ? $headers['content-type'] : '';
605
+				$allowed_types = array('video', 'audio');
606 606
 
607 607
 				// Check to see if we can figure out the mime type from
608 608
 				// the extension
609
-				$url_parts = @parse_url( $url );
610
-				if ( false !== $url_parts ) {
611
-					$extension = pathinfo( $url_parts['path'], PATHINFO_EXTENSION );
612
-					if ( !empty( $extension ) ) {
613
-						foreach ( wp_get_mime_types() as $exts => $mime ) {
614
-							if ( preg_match( '!^(' . $exts . ')$!i', $extension ) ) {
609
+				$url_parts = @parse_url($url);
610
+				if (false !== $url_parts) {
611
+					$extension = pathinfo($url_parts['path'], PATHINFO_EXTENSION);
612
+					if ( ! empty($extension)) {
613
+						foreach (wp_get_mime_types() as $exts => $mime) {
614
+							if (preg_match('!^('.$exts.')$!i', $extension)) {
615 615
 								$type = $mime;
616 616
 								break;
617 617
 							}
@@ -619,8 +619,8 @@  discard block
 block discarded – undo
619 619
 					}
620 620
 				}
621 621
 
622
-				if ( in_array( substr( $type, 0, strpos( $type, "/" ) ), $allowed_types ) ) {
623
-					add_post_meta( $post_ID, 'enclosure', "$url\n$len\n$mime\n" );
622
+				if (in_array(substr($type, 0, strpos($type, "/")), $allowed_types)) {
623
+					add_post_meta($post_ID, 'enclosure', "$url\n$len\n$mime\n");
624 624
 				}
625 625
 			}
626 626
 		}
@@ -636,16 +636,16 @@  discard block
 block discarded – undo
636 636
  * @param bool   $deprecated Not Used.
637 637
  * @return bool|string False on failure, headers on success.
638 638
  */
639
-function wp_get_http_headers( $url, $deprecated = false ) {
640
-	if ( !empty( $deprecated ) )
641
-		_deprecated_argument( __FUNCTION__, '2.7.0' );
639
+function wp_get_http_headers($url, $deprecated = false) {
640
+	if ( ! empty($deprecated))
641
+		_deprecated_argument(__FUNCTION__, '2.7.0');
642 642
 
643
-	$response = wp_safe_remote_head( $url );
643
+	$response = wp_safe_remote_head($url);
644 644
 
645
-	if ( is_wp_error( $response ) )
645
+	if (is_wp_error($response))
646 646
 		return false;
647 647
 
648
-	return wp_remote_retrieve_headers( $response );
648
+	return wp_remote_retrieve_headers($response);
649 649
 }
650 650
 
651 651
 /**
@@ -661,7 +661,7 @@  discard block
 block discarded – undo
661 661
  */
662 662
 function is_new_day() {
663 663
 	global $currentday, $previousday;
664
-	if ( $currentday != $previousday )
664
+	if ($currentday != $previousday)
665 665
 		return 1;
666 666
 	else
667 667
 		return 0;
@@ -682,8 +682,8 @@  discard block
 block discarded – undo
682 682
  * @param array $data URL-encode key/value pairs.
683 683
  * @return string URL-encoded string.
684 684
  */
685
-function build_query( $data ) {
686
-	return _http_build_query( $data, null, '&', '', false );
685
+function build_query($data) {
686
+	return _http_build_query($data, null, '&', '', false);
687 687
 }
688 688
 
689 689
 /**
@@ -704,30 +704,30 @@  discard block
 block discarded – undo
704 704
  *
705 705
  * @return string The query string.
706 706
  */
707
-function _http_build_query( $data, $prefix = null, $sep = null, $key = '', $urlencode = true ) {
707
+function _http_build_query($data, $prefix = null, $sep = null, $key = '', $urlencode = true) {
708 708
 	$ret = array();
709 709
 
710
-	foreach ( (array) $data as $k => $v ) {
711
-		if ( $urlencode)
710
+	foreach ((array) $data as $k => $v) {
711
+		if ($urlencode)
712 712
 			$k = urlencode($k);
713
-		if ( is_int($k) && $prefix != null )
713
+		if (is_int($k) && $prefix != null)
714 714
 			$k = $prefix.$k;
715
-		if ( !empty($key) )
716
-			$k = $key . '%5B' . $k . '%5D';
717
-		if ( $v === null )
715
+		if ( ! empty($key))
716
+			$k = $key.'%5B'.$k.'%5D';
717
+		if ($v === null)
718 718
 			continue;
719
-		elseif ( $v === false )
719
+		elseif ($v === false)
720 720
 			$v = '0';
721 721
 
722
-		if ( is_array($v) || is_object($v) )
723
-			array_push($ret,_http_build_query($v, '', $sep, $k, $urlencode));
724
-		elseif ( $urlencode )
722
+		if (is_array($v) || is_object($v))
723
+			array_push($ret, _http_build_query($v, '', $sep, $k, $urlencode));
724
+		elseif ($urlencode)
725 725
 			array_push($ret, $k.'='.urlencode($v));
726 726
 		else
727 727
 			array_push($ret, $k.'='.$v);
728 728
 	}
729 729
 
730
-	if ( null === $sep )
730
+	if (null === $sep)
731 731
 		$sep = ini_get('arg_separator.output');
732 732
 
733 733
 	return implode($sep, $ret);
@@ -770,64 +770,64 @@  discard block
 block discarded – undo
770 770
  */
771 771
 function add_query_arg() {
772 772
 	$args = func_get_args();
773
-	if ( is_array( $args[0] ) ) {
774
-		if ( count( $args ) < 2 || false === $args[1] )
773
+	if (is_array($args[0])) {
774
+		if (count($args) < 2 || false === $args[1])
775 775
 			$uri = $_SERVER['REQUEST_URI'];
776 776
 		else
777 777
 			$uri = $args[1];
778 778
 	} else {
779
-		if ( count( $args ) < 3 || false === $args[2] )
779
+		if (count($args) < 3 || false === $args[2])
780 780
 			$uri = $_SERVER['REQUEST_URI'];
781 781
 		else
782 782
 			$uri = $args[2];
783 783
 	}
784 784
 
785
-	if ( $frag = strstr( $uri, '#' ) )
786
-		$uri = substr( $uri, 0, -strlen( $frag ) );
785
+	if ($frag = strstr($uri, '#'))
786
+		$uri = substr($uri, 0, -strlen($frag));
787 787
 	else
788 788
 		$frag = '';
789 789
 
790
-	if ( 0 === stripos( $uri, 'http://' ) ) {
790
+	if (0 === stripos($uri, 'http://')) {
791 791
 		$protocol = 'http://';
792
-		$uri = substr( $uri, 7 );
793
-	} elseif ( 0 === stripos( $uri, 'https://' ) ) {
792
+		$uri = substr($uri, 7);
793
+	} elseif (0 === stripos($uri, 'https://')) {
794 794
 		$protocol = 'https://';
795
-		$uri = substr( $uri, 8 );
795
+		$uri = substr($uri, 8);
796 796
 	} else {
797 797
 		$protocol = '';
798 798
 	}
799 799
 
800
-	if ( strpos( $uri, '?' ) !== false ) {
801
-		list( $base, $query ) = explode( '?', $uri, 2 );
800
+	if (strpos($uri, '?') !== false) {
801
+		list($base, $query) = explode('?', $uri, 2);
802 802
 		$base .= '?';
803
-	} elseif ( $protocol || strpos( $uri, '=' ) === false ) {
804
-		$base = $uri . '?';
803
+	} elseif ($protocol || strpos($uri, '=') === false) {
804
+		$base = $uri.'?';
805 805
 		$query = '';
806 806
 	} else {
807 807
 		$base = '';
808 808
 		$query = $uri;
809 809
 	}
810 810
 
811
-	wp_parse_str( $query, $qs );
812
-	$qs = urlencode_deep( $qs ); // this re-URL-encodes things that were already in the query string
813
-	if ( is_array( $args[0] ) ) {
814
-		foreach ( $args[0] as $k => $v ) {
815
-			$qs[ $k ] = $v;
811
+	wp_parse_str($query, $qs);
812
+	$qs = urlencode_deep($qs); // this re-URL-encodes things that were already in the query string
813
+	if (is_array($args[0])) {
814
+		foreach ($args[0] as $k => $v) {
815
+			$qs[$k] = $v;
816 816
 		}
817 817
 	} else {
818
-		$qs[ $args[0] ] = $args[1];
818
+		$qs[$args[0]] = $args[1];
819 819
 	}
820 820
 
821
-	foreach ( $qs as $k => $v ) {
822
-		if ( $v === false )
823
-			unset( $qs[$k] );
821
+	foreach ($qs as $k => $v) {
822
+		if ($v === false)
823
+			unset($qs[$k]);
824 824
 	}
825 825
 
826
-	$ret = build_query( $qs );
827
-	$ret = trim( $ret, '?' );
828
-	$ret = preg_replace( '#=(&|$)#', '$1', $ret );
829
-	$ret = $protocol . $base . $ret . $frag;
830
-	$ret = rtrim( $ret, '?' );
826
+	$ret = build_query($qs);
827
+	$ret = trim($ret, '?');
828
+	$ret = preg_replace('#=(&|$)#', '$1', $ret);
829
+	$ret = $protocol.$base.$ret.$frag;
830
+	$ret = rtrim($ret, '?');
831 831
 	return $ret;
832 832
 }
833 833
 
@@ -840,13 +840,13 @@  discard block
 block discarded – undo
840 840
  * @param bool|string  $query Optional. When false uses the current URL. Default false.
841 841
  * @return string New URL query string.
842 842
  */
843
-function remove_query_arg( $key, $query = false ) {
844
-	if ( is_array( $key ) ) { // removing multiple keys
845
-		foreach ( $key as $k )
846
-			$query = add_query_arg( $k, false, $query );
843
+function remove_query_arg($key, $query = false) {
844
+	if (is_array($key)) { // removing multiple keys
845
+		foreach ($key as $k)
846
+			$query = add_query_arg($k, false, $query);
847 847
 		return $query;
848 848
 	}
849
-	return add_query_arg( $key, false, $query );
849
+	return add_query_arg($key, false, $query);
850 850
 }
851 851
 
852 852
 /**
@@ -890,7 +890,7 @@  discard block
 block discarded – undo
890 890
 	 *
891 891
 	 * @param array $removable_query_args An array of query variables to remove from a URL.
892 892
 	 */
893
-	return apply_filters( 'removable_query_args', $removable_query_args );
893
+	return apply_filters('removable_query_args', $removable_query_args);
894 894
 }
895 895
 
896 896
 /**
@@ -901,12 +901,12 @@  discard block
 block discarded – undo
901 901
  * @param array $array Array to walk while sanitizing contents.
902 902
  * @return array Sanitized $array.
903 903
  */
904
-function add_magic_quotes( $array ) {
905
-	foreach ( (array) $array as $k => $v ) {
906
-		if ( is_array( $v ) ) {
907
-			$array[$k] = add_magic_quotes( $v );
904
+function add_magic_quotes($array) {
905
+	foreach ((array) $array as $k => $v) {
906
+		if (is_array($v)) {
907
+			$array[$k] = add_magic_quotes($v);
908 908
 		} else {
909
-			$array[$k] = addslashes( $v );
909
+			$array[$k] = addslashes($v);
910 910
 		}
911 911
 	}
912 912
 	return $array;
@@ -922,21 +922,21 @@  discard block
 block discarded – undo
922 922
  * @param string $uri URI/URL of web page to retrieve.
923 923
  * @return false|string HTTP content. False on failure.
924 924
  */
925
-function wp_remote_fopen( $uri ) {
926
-	$parsed_url = @parse_url( $uri );
925
+function wp_remote_fopen($uri) {
926
+	$parsed_url = @parse_url($uri);
927 927
 
928
-	if ( !$parsed_url || !is_array( $parsed_url ) )
928
+	if ( ! $parsed_url || ! is_array($parsed_url))
929 929
 		return false;
930 930
 
931 931
 	$options = array();
932 932
 	$options['timeout'] = 10;
933 933
 
934
-	$response = wp_safe_remote_get( $uri, $options );
934
+	$response = wp_safe_remote_get($uri, $options);
935 935
 
936
-	if ( is_wp_error( $response ) )
936
+	if (is_wp_error($response))
937 937
 		return false;
938 938
 
939
-	return wp_remote_retrieve_body( $response );
939
+	return wp_remote_retrieve_body($response);
940 940
 }
941 941
 
942 942
 /**
@@ -950,11 +950,11 @@  discard block
 block discarded – undo
950 950
  *
951 951
  * @param string|array $query_vars Default WP_Query arguments.
952 952
  */
953
-function wp( $query_vars = '' ) {
953
+function wp($query_vars = '') {
954 954
 	global $wp, $wp_query, $wp_the_query;
955
-	$wp->main( $query_vars );
955
+	$wp->main($query_vars);
956 956
 
957
-	if ( !isset($wp_the_query) )
957
+	if ( ! isset($wp_the_query))
958 958
 		$wp_the_query = $wp_query;
959 959
 }
960 960
 
@@ -968,12 +968,12 @@  discard block
 block discarded – undo
968 968
  * @param int $code HTTP status code.
969 969
  * @return string Empty string if not found, or description if found.
970 970
  */
971
-function get_status_header_desc( $code ) {
971
+function get_status_header_desc($code) {
972 972
 	global $wp_header_to_desc;
973 973
 
974
-	$code = absint( $code );
974
+	$code = absint($code);
975 975
 
976
-	if ( !isset( $wp_header_to_desc ) ) {
976
+	if ( ! isset($wp_header_to_desc)) {
977 977
 		$wp_header_to_desc = array(
978 978
 			100 => 'Continue',
979 979
 			101 => 'Switching Protocols',
@@ -1041,7 +1041,7 @@  discard block
 block discarded – undo
1041 1041
 		);
1042 1042
 	}
1043 1043
 
1044
-	if ( isset( $wp_header_to_desc[$code] ) )
1044
+	if (isset($wp_header_to_desc[$code]))
1045 1045
 		return $wp_header_to_desc[$code];
1046 1046
 	else
1047 1047
 		return '';
@@ -1058,18 +1058,18 @@  discard block
 block discarded – undo
1058 1058
  * @param int    $code        HTTP status code.
1059 1059
  * @param string $description Optional. A custom description for the HTTP status.
1060 1060
  */
1061
-function status_header( $code, $description = '' ) {
1062
-	if ( ! $description ) {
1063
-		$description = get_status_header_desc( $code );
1061
+function status_header($code, $description = '') {
1062
+	if ( ! $description) {
1063
+		$description = get_status_header_desc($code);
1064 1064
 	}
1065 1065
 
1066
-	if ( empty( $description ) ) {
1066
+	if (empty($description)) {
1067 1067
 		return;
1068 1068
 	}
1069 1069
 
1070 1070
 	$protocol = wp_get_server_protocol();
1071 1071
 	$status_header = "$protocol $code $description";
1072
-	if ( function_exists( 'apply_filters' ) )
1072
+	if (function_exists('apply_filters'))
1073 1073
 
1074 1074
 		/**
1075 1075
 		 * Filters an HTTP status header.
@@ -1081,9 +1081,9 @@  discard block
 block discarded – undo
1081 1081
 		 * @param string $description   Description for the status code.
1082 1082
 		 * @param string $protocol      Server protocol.
1083 1083
 		 */
1084
-		$status_header = apply_filters( 'status_header', $status_header, $code, $description, $protocol );
1084
+		$status_header = apply_filters('status_header', $status_header, $code, $description, $protocol);
1085 1085
 
1086
-	@header( $status_header, true, $code );
1086
+	@header($status_header, true, $code);
1087 1087
 }
1088 1088
 
1089 1089
 /**
@@ -1102,7 +1102,7 @@  discard block
 block discarded – undo
1102 1102
 		'Cache-Control' => 'no-cache, must-revalidate, max-age=0',
1103 1103
 	);
1104 1104
 
1105
-	if ( function_exists('apply_filters') ) {
1105
+	if (function_exists('apply_filters')) {
1106 1106
 		/**
1107 1107
 		 * Filters the cache-controlling headers.
1108 1108
 		 *
@@ -1117,7 +1117,7 @@  discard block
 block discarded – undo
1117 1117
 		 *     @type string $Cache-Control Cache-Control header.
1118 1118
 		 * }
1119 1119
 		 */
1120
-		$headers = (array) apply_filters( 'nocache_headers', $headers );
1120
+		$headers = (array) apply_filters('nocache_headers', $headers);
1121 1121
 	}
1122 1122
 	$headers['Last-Modified'] = false;
1123 1123
 	return $headers;
@@ -1137,23 +1137,23 @@  discard block
 block discarded – undo
1137 1137
 function nocache_headers() {
1138 1138
 	$headers = wp_get_nocache_headers();
1139 1139
 
1140
-	unset( $headers['Last-Modified'] );
1140
+	unset($headers['Last-Modified']);
1141 1141
 
1142 1142
 	// In PHP 5.3+, make sure we are not sending a Last-Modified header.
1143
-	if ( function_exists( 'header_remove' ) ) {
1144
-		@header_remove( 'Last-Modified' );
1143
+	if (function_exists('header_remove')) {
1144
+		@header_remove('Last-Modified');
1145 1145
 	} else {
1146 1146
 		// In PHP 5.2, send an empty Last-Modified header, but only as a
1147 1147
 		// last resort to override a header already sent. #WP23021
1148
-		foreach ( headers_list() as $header ) {
1149
-			if ( 0 === stripos( $header, 'Last-Modified' ) ) {
1148
+		foreach (headers_list() as $header) {
1149
+			if (0 === stripos($header, 'Last-Modified')) {
1150 1150
 				$headers['Last-Modified'] = '';
1151 1151
 				break;
1152 1152
 			}
1153 1153
 		}
1154 1154
 	}
1155 1155
 
1156
-	foreach ( $headers as $name => $field_value )
1156
+	foreach ($headers as $name => $field_value)
1157 1157
 		@header("{$name}: {$field_value}");
1158 1158
 }
1159 1159
 
@@ -1165,9 +1165,9 @@  discard block
 block discarded – undo
1165 1165
 function cache_javascript_headers() {
1166 1166
 	$expiresOffset = 10 * DAY_IN_SECONDS;
1167 1167
 
1168
-	header( "Content-Type: text/javascript; charset=" . get_bloginfo( 'charset' ) );
1169
-	header( "Vary: Accept-Encoding" ); // Handle proxies
1170
-	header( "Expires: " . gmdate( "D, d M Y H:i:s", time() + $expiresOffset ) . " GMT" );
1168
+	header("Content-Type: text/javascript; charset=".get_bloginfo('charset'));
1169
+	header("Vary: Accept-Encoding"); // Handle proxies
1170
+	header("Expires: ".gmdate("D, d M Y H:i:s", time() + $expiresOffset)." GMT");
1171 1171
 }
1172 1172
 
1173 1173
 /**
@@ -1194,8 +1194,8 @@  discard block
 block discarded – undo
1194 1194
  * @param string $yn Character string containing either 'y' (yes) or 'n' (no).
1195 1195
  * @return bool True if yes, false on anything else.
1196 1196
  */
1197
-function bool_from_yn( $yn ) {
1198
-	return ( strtolower( $yn ) == 'y' );
1197
+function bool_from_yn($yn) {
1198
+	return (strtolower($yn) == 'y');
1199 1199
 }
1200 1200
 
1201 1201
 /**
@@ -1214,27 +1214,27 @@  discard block
 block discarded – undo
1214 1214
 	global $wp_query;
1215 1215
 
1216 1216
 	// Determine if we are looking at the main comment feed
1217
-	$is_main_comments_feed = ( $wp_query->is_comment_feed() && ! $wp_query->is_singular() );
1217
+	$is_main_comments_feed = ($wp_query->is_comment_feed() && ! $wp_query->is_singular());
1218 1218
 
1219 1219
 	/*
1220 1220
 	 * Check the queried object for the existence of posts if it is not a feed for an archive,
1221 1221
 	 * search result, or main comments. By checking for the absense of posts we can prevent rendering the feed
1222 1222
 	 * templates at invalid endpoints. e.g.) /wp-content/plugins/feed/
1223 1223
 	 */
1224
-	if ( ! $wp_query->have_posts() && ! ( $wp_query->is_archive() || $wp_query->is_search() || $is_main_comments_feed ) ) {
1225
-		wp_die( __( 'ERROR: This is not a valid feed.' ), '', array( 'response' => 404 ) );
1224
+	if ( ! $wp_query->have_posts() && ! ($wp_query->is_archive() || $wp_query->is_search() || $is_main_comments_feed)) {
1225
+		wp_die(__('ERROR: This is not a valid feed.'), '', array('response' => 404));
1226 1226
 	}
1227 1227
 
1228
-	$feed = get_query_var( 'feed' );
1228
+	$feed = get_query_var('feed');
1229 1229
 
1230 1230
 	// Remove the pad, if present.
1231
-	$feed = preg_replace( '/^_+/', '', $feed );
1231
+	$feed = preg_replace('/^_+/', '', $feed);
1232 1232
 
1233
-	if ( $feed == '' || $feed == 'feed' )
1233
+	if ($feed == '' || $feed == 'feed')
1234 1234
 		$feed = get_default_feed();
1235 1235
 
1236
-	if ( ! has_action( "do_feed_{$feed}" ) ) {
1237
-		wp_die( __( 'ERROR: This is not a valid feed template.' ), '', array( 'response' => 404 ) );
1236
+	if ( ! has_action("do_feed_{$feed}")) {
1237
+		wp_die(__('ERROR: This is not a valid feed template.'), '', array('response' => 404));
1238 1238
 	}
1239 1239
 
1240 1240
 	/**
@@ -1249,7 +1249,7 @@  discard block
 block discarded – undo
1249 1249
 	 * @param bool   $is_comment_feed Whether the feed is a comment feed.
1250 1250
 	 * @param string $feed            The feed name.
1251 1251
 	 */
1252
-	do_action( "do_feed_{$feed}", $wp_query->is_comment_feed, $feed );
1252
+	do_action("do_feed_{$feed}", $wp_query->is_comment_feed, $feed);
1253 1253
 }
1254 1254
 
1255 1255
 /**
@@ -1260,7 +1260,7 @@  discard block
 block discarded – undo
1260 1260
  * @see load_template()
1261 1261
  */
1262 1262
 function do_feed_rdf() {
1263
-	load_template( ABSPATH . WPINC . '/feed-rdf.php' );
1263
+	load_template(ABSPATH.WPINC.'/feed-rdf.php');
1264 1264
 }
1265 1265
 
1266 1266
 /**
@@ -1271,7 +1271,7 @@  discard block
 block discarded – undo
1271 1271
  * @see load_template()
1272 1272
  */
1273 1273
 function do_feed_rss() {
1274
-	load_template( ABSPATH . WPINC . '/feed-rss.php' );
1274
+	load_template(ABSPATH.WPINC.'/feed-rss.php');
1275 1275
 }
1276 1276
 
1277 1277
 /**
@@ -1283,11 +1283,11 @@  discard block
 block discarded – undo
1283 1283
  *
1284 1284
  * @param bool $for_comments True for the comment feed, false for normal feed.
1285 1285
  */
1286
-function do_feed_rss2( $for_comments ) {
1287
-	if ( $for_comments )
1288
-		load_template( ABSPATH . WPINC . '/feed-rss2-comments.php' );
1286
+function do_feed_rss2($for_comments) {
1287
+	if ($for_comments)
1288
+		load_template(ABSPATH.WPINC.'/feed-rss2-comments.php');
1289 1289
 	else
1290
-		load_template( ABSPATH . WPINC . '/feed-rss2.php' );
1290
+		load_template(ABSPATH.WPINC.'/feed-rss2.php');
1291 1291
 }
1292 1292
 
1293 1293
 /**
@@ -1299,11 +1299,11 @@  discard block
 block discarded – undo
1299 1299
  *
1300 1300
  * @param bool $for_comments True for the comment feed, false for normal feed.
1301 1301
  */
1302
-function do_feed_atom( $for_comments ) {
1302
+function do_feed_atom($for_comments) {
1303 1303
 	if ($for_comments)
1304
-		load_template( ABSPATH . WPINC . '/feed-atom-comments.php');
1304
+		load_template(ABSPATH.WPINC.'/feed-atom-comments.php');
1305 1305
 	else
1306
-		load_template( ABSPATH . WPINC . '/feed-atom.php' );
1306
+		load_template(ABSPATH.WPINC.'/feed-atom.php');
1307 1307
 }
1308 1308
 
1309 1309
 /**
@@ -1315,22 +1315,22 @@  discard block
 block discarded – undo
1315 1315
  * @since 2.1.0
1316 1316
  */
1317 1317
 function do_robots() {
1318
-	header( 'Content-Type: text/plain; charset=utf-8' );
1318
+	header('Content-Type: text/plain; charset=utf-8');
1319 1319
 
1320 1320
 	/**
1321 1321
 	 * Fires when displaying the robots.txt file.
1322 1322
 	 *
1323 1323
 	 * @since 2.1.0
1324 1324
 	 */
1325
-	do_action( 'do_robotstxt' );
1325
+	do_action('do_robotstxt');
1326 1326
 
1327 1327
 	$output = "User-agent: *\n";
1328
-	$public = get_option( 'blog_public' );
1329
-	if ( '0' == $public ) {
1328
+	$public = get_option('blog_public');
1329
+	if ('0' == $public) {
1330 1330
 		$output .= "Disallow: /\n";
1331 1331
 	} else {
1332
-		$site_url = parse_url( site_url() );
1333
-		$path = ( !empty( $site_url['path'] ) ) ? $site_url['path'] : '';
1332
+		$site_url = parse_url(site_url());
1333
+		$path = ( ! empty($site_url['path'])) ? $site_url['path'] : '';
1334 1334
 		$output .= "Disallow: $path/wp-admin/\n";
1335 1335
 		$output .= "Allow: $path/wp-admin/admin-ajax.php\n";
1336 1336
 	}
@@ -1343,7 +1343,7 @@  discard block
 block discarded – undo
1343 1343
 	 * @param string $output Robots.txt output.
1344 1344
 	 * @param bool   $public Whether the site is considered "public".
1345 1345
 	 */
1346
-	echo apply_filters( 'robots_txt', $output, $public );
1346
+	echo apply_filters('robots_txt', $output, $public);
1347 1347
 }
1348 1348
 
1349 1349
 /**
@@ -1368,28 +1368,28 @@  discard block
 block discarded – undo
1368 1368
 	 * Check cache first. If options table goes away and we have true
1369 1369
 	 * cached, oh well.
1370 1370
 	 */
1371
-	if ( wp_cache_get( 'is_blog_installed' ) )
1371
+	if (wp_cache_get('is_blog_installed'))
1372 1372
 		return true;
1373 1373
 
1374 1374
 	$suppress = $wpdb->suppress_errors();
1375
-	if ( ! wp_installing() ) {
1375
+	if ( ! wp_installing()) {
1376 1376
 		$alloptions = wp_load_alloptions();
1377 1377
 	}
1378 1378
 	// If siteurl is not set to autoload, check it specifically
1379
-	if ( !isset( $alloptions['siteurl'] ) )
1380
-		$installed = $wpdb->get_var( "SELECT option_value FROM $wpdb->options WHERE option_name = 'siteurl'" );
1379
+	if ( ! isset($alloptions['siteurl']))
1380
+		$installed = $wpdb->get_var("SELECT option_value FROM $wpdb->options WHERE option_name = 'siteurl'");
1381 1381
 	else
1382 1382
 		$installed = $alloptions['siteurl'];
1383
-	$wpdb->suppress_errors( $suppress );
1383
+	$wpdb->suppress_errors($suppress);
1384 1384
 
1385
-	$installed = !empty( $installed );
1386
-	wp_cache_set( 'is_blog_installed', $installed );
1385
+	$installed = ! empty($installed);
1386
+	wp_cache_set('is_blog_installed', $installed);
1387 1387
 
1388
-	if ( $installed )
1388
+	if ($installed)
1389 1389
 		return true;
1390 1390
 
1391 1391
 	// If visiting repair.php, return true and let it take over.
1392
-	if ( defined( 'WP_REPAIRING' ) )
1392
+	if (defined('WP_REPAIRING'))
1393 1393
 		return true;
1394 1394
 
1395 1395
 	$suppress = $wpdb->suppress_errors();
@@ -1400,14 +1400,14 @@  discard block
 block discarded – undo
1400 1400
 	 * options table could not be accessed.
1401 1401
 	 */
1402 1402
 	$wp_tables = $wpdb->tables();
1403
-	foreach ( $wp_tables as $table ) {
1403
+	foreach ($wp_tables as $table) {
1404 1404
 		// The existence of custom user tables shouldn't suggest an insane state or prevent a clean install.
1405
-		if ( defined( 'CUSTOM_USER_TABLE' ) && CUSTOM_USER_TABLE == $table )
1405
+		if (defined('CUSTOM_USER_TABLE') && CUSTOM_USER_TABLE == $table)
1406 1406
 			continue;
1407
-		if ( defined( 'CUSTOM_USER_META_TABLE' ) && CUSTOM_USER_META_TABLE == $table )
1407
+		if (defined('CUSTOM_USER_META_TABLE') && CUSTOM_USER_META_TABLE == $table)
1408 1408
 			continue;
1409 1409
 
1410
-		if ( ! $wpdb->get_results( "DESCRIBE $table;" ) )
1410
+		if ( ! $wpdb->get_results("DESCRIBE $table;"))
1411 1411
 			continue;
1412 1412
 
1413 1413
 		// One or more tables exist. We are insane.
@@ -1417,16 +1417,16 @@  discard block
 block discarded – undo
1417 1417
 		// Die with a DB error.
1418 1418
 		$wpdb->error = sprintf(
1419 1419
 			/* translators: %s: database repair URL */
1420
-			__( 'One or more database tables are unavailable. The database may need to be <a href="%s">repaired</a>.' ),
1420
+			__('One or more database tables are unavailable. The database may need to be <a href="%s">repaired</a>.'),
1421 1421
 			'maint/repair.php?referrer=is_blog_installed'
1422 1422
 		);
1423 1423
 
1424 1424
 		dead_db();
1425 1425
 	}
1426 1426
 
1427
-	$wpdb->suppress_errors( $suppress );
1427
+	$wpdb->suppress_errors($suppress);
1428 1428
 
1429
-	wp_cache_set( 'is_blog_installed', false );
1429
+	wp_cache_set('is_blog_installed', false);
1430 1430
 
1431 1431
 	return false;
1432 1432
 }
@@ -1441,9 +1441,9 @@  discard block
 block discarded – undo
1441 1441
  * @param string     $name      Optional. Nonce name. Default '_wpnonce'.
1442 1442
  * @return string Escaped URL with nonce action added.
1443 1443
  */
1444
-function wp_nonce_url( $actionurl, $action = -1, $name = '_wpnonce' ) {
1445
-	$actionurl = str_replace( '&amp;', '&', $actionurl );
1446
-	return esc_html( add_query_arg( $name, wp_create_nonce( $action ), $actionurl ) );
1444
+function wp_nonce_url($actionurl, $action = -1, $name = '_wpnonce') {
1445
+	$actionurl = str_replace('&amp;', '&', $actionurl);
1446
+	return esc_html(add_query_arg($name, wp_create_nonce($action), $actionurl));
1447 1447
 }
1448 1448
 
1449 1449
 /**
@@ -1472,14 +1472,14 @@  discard block
 block discarded – undo
1472 1472
  * @param bool       $echo    Optional. Whether to display or return hidden form field. Default true.
1473 1473
  * @return string Nonce field HTML markup.
1474 1474
  */
1475
-function wp_nonce_field( $action = -1, $name = "_wpnonce", $referer = true , $echo = true ) {
1476
-	$name = esc_attr( $name );
1477
-	$nonce_field = '<input type="hidden" id="' . $name . '" name="' . $name . '" value="' . wp_create_nonce( $action ) . '" />';
1475
+function wp_nonce_field($action = -1, $name = "_wpnonce", $referer = true, $echo = true) {
1476
+	$name = esc_attr($name);
1477
+	$nonce_field = '<input type="hidden" id="'.$name.'" name="'.$name.'" value="'.wp_create_nonce($action).'" />';
1478 1478
 
1479
-	if ( $referer )
1480
-		$nonce_field .= wp_referer_field( false );
1479
+	if ($referer)
1480
+		$nonce_field .= wp_referer_field(false);
1481 1481
 
1482
-	if ( $echo )
1482
+	if ($echo)
1483 1483
 		echo $nonce_field;
1484 1484
 
1485 1485
 	return $nonce_field;
@@ -1496,10 +1496,10 @@  discard block
 block discarded – undo
1496 1496
  * @param bool $echo Optional. Whether to echo or return the referer field. Default true.
1497 1497
  * @return string Referer field HTML markup.
1498 1498
  */
1499
-function wp_referer_field( $echo = true ) {
1500
-	$referer_field = '<input type="hidden" name="_wp_http_referer" value="'. esc_attr( wp_unslash( $_SERVER['REQUEST_URI'] ) ) . '" />';
1499
+function wp_referer_field($echo = true) {
1500
+	$referer_field = '<input type="hidden" name="_wp_http_referer" value="'.esc_attr(wp_unslash($_SERVER['REQUEST_URI'])).'" />';
1501 1501
 
1502
-	if ( $echo )
1502
+	if ($echo)
1503 1503
 		echo $referer_field;
1504 1504
 	return $referer_field;
1505 1505
 }
@@ -1518,12 +1518,12 @@  discard block
 block discarded – undo
1518 1518
  *                             Default 'current'.
1519 1519
  * @return string Original referer field.
1520 1520
  */
1521
-function wp_original_referer_field( $echo = true, $jump_back_to = 'current' ) {
1522
-	if ( ! $ref = wp_get_original_referer() ) {
1523
-		$ref = 'previous' == $jump_back_to ? wp_get_referer() : wp_unslash( $_SERVER['REQUEST_URI'] );
1521
+function wp_original_referer_field($echo = true, $jump_back_to = 'current') {
1522
+	if ( ! $ref = wp_get_original_referer()) {
1523
+		$ref = 'previous' == $jump_back_to ? wp_get_referer() : wp_unslash($_SERVER['REQUEST_URI']);
1524 1524
 	}
1525
-	$orig_referer_field = '<input type="hidden" name="_wp_original_http_referer" value="' . esc_attr( $ref ) . '" />';
1526
-	if ( $echo )
1525
+	$orig_referer_field = '<input type="hidden" name="_wp_original_http_referer" value="'.esc_attr($ref).'" />';
1526
+	if ($echo)
1527 1527
 		echo $orig_referer_field;
1528 1528
 	return $orig_referer_field;
1529 1529
 }
@@ -1538,14 +1538,14 @@  discard block
 block discarded – undo
1538 1538
  * @return false|string False on failure. Referer URL on success.
1539 1539
  */
1540 1540
 function wp_get_referer() {
1541
-	if ( ! function_exists( 'wp_validate_redirect' ) ) {
1541
+	if ( ! function_exists('wp_validate_redirect')) {
1542 1542
 		return false;
1543 1543
 	}
1544 1544
 
1545 1545
 	$ref = wp_get_raw_referer();
1546 1546
 
1547
-	if ( $ref && $ref !== wp_unslash( $_SERVER['REQUEST_URI'] ) && $ref !== home_url() . wp_unslash( $_SERVER['REQUEST_URI'] ) ) {
1548
-		return wp_validate_redirect( $ref, false );
1547
+	if ($ref && $ref !== wp_unslash($_SERVER['REQUEST_URI']) && $ref !== home_url().wp_unslash($_SERVER['REQUEST_URI'])) {
1548
+		return wp_validate_redirect($ref, false);
1549 1549
 	}
1550 1550
 
1551 1551
 	return false;
@@ -1561,10 +1561,10 @@  discard block
 block discarded – undo
1561 1561
  * @return string|false Referer URL on success, false on failure.
1562 1562
  */
1563 1563
 function wp_get_raw_referer() {
1564
-	if ( ! empty( $_REQUEST['_wp_http_referer'] ) ) {
1565
-		return wp_unslash( $_REQUEST['_wp_http_referer'] );
1566
-	} else if ( ! empty( $_SERVER['HTTP_REFERER'] ) ) {
1567
-		return wp_unslash( $_SERVER['HTTP_REFERER'] );
1564
+	if ( ! empty($_REQUEST['_wp_http_referer'])) {
1565
+		return wp_unslash($_REQUEST['_wp_http_referer']);
1566
+	} else if ( ! empty($_SERVER['HTTP_REFERER'])) {
1567
+		return wp_unslash($_SERVER['HTTP_REFERER']);
1568 1568
 	}
1569 1569
 
1570 1570
 	return false;
@@ -1578,8 +1578,8 @@  discard block
 block discarded – undo
1578 1578
  * @return string|false False if no original referer or original referer if set.
1579 1579
  */
1580 1580
 function wp_get_original_referer() {
1581
-	if ( ! empty( $_REQUEST['_wp_original_http_referer'] ) && function_exists( 'wp_validate_redirect' ) )
1582
-		return wp_validate_redirect( wp_unslash( $_REQUEST['_wp_original_http_referer'] ), false );
1581
+	if ( ! empty($_REQUEST['_wp_original_http_referer']) && function_exists('wp_validate_redirect'))
1582
+		return wp_validate_redirect(wp_unslash($_REQUEST['_wp_original_http_referer']), false);
1583 1583
 	return false;
1584 1584
 }
1585 1585
 
@@ -1593,20 +1593,20 @@  discard block
 block discarded – undo
1593 1593
  * @param string $target Full path to attempt to create.
1594 1594
  * @return bool Whether the path was created. True if path already exists.
1595 1595
  */
1596
-function wp_mkdir_p( $target ) {
1596
+function wp_mkdir_p($target) {
1597 1597
 	$wrapper = null;
1598 1598
 
1599 1599
 	// Strip the protocol.
1600
-	if ( wp_is_stream( $target ) ) {
1601
-		list( $wrapper, $target ) = explode( '://', $target, 2 );
1600
+	if (wp_is_stream($target)) {
1601
+		list($wrapper, $target) = explode('://', $target, 2);
1602 1602
 	}
1603 1603
 
1604 1604
 	// From php.net/mkdir user contributed notes.
1605
-	$target = str_replace( '//', '/', $target );
1605
+	$target = str_replace('//', '/', $target);
1606 1606
 
1607 1607
 	// Put the wrapper back on the target.
1608
-	if ( $wrapper !== null ) {
1609
-		$target = $wrapper . '://' . $target;
1608
+	if ($wrapper !== null) {
1609
+		$target = $wrapper.'://'.$target;
1610 1610
 	}
1611 1611
 
1612 1612
 	/*
@@ -1614,35 +1614,35 @@  discard block
 block discarded – undo
1614 1614
 	 * Use rtrim() instead of untrailingslashit to avoid formatting.php dependency.
1615 1615
 	 */
1616 1616
 	$target = rtrim($target, '/');
1617
-	if ( empty($target) )
1617
+	if (empty($target))
1618 1618
 		$target = '/';
1619 1619
 
1620
-	if ( file_exists( $target ) )
1621
-		return @is_dir( $target );
1620
+	if (file_exists($target))
1621
+		return @is_dir($target);
1622 1622
 
1623 1623
 	// We need to find the permissions of the parent folder that exists and inherit that.
1624
-	$target_parent = dirname( $target );
1625
-	while ( '.' != $target_parent && ! is_dir( $target_parent ) ) {
1626
-		$target_parent = dirname( $target_parent );
1624
+	$target_parent = dirname($target);
1625
+	while ('.' != $target_parent && ! is_dir($target_parent)) {
1626
+		$target_parent = dirname($target_parent);
1627 1627
 	}
1628 1628
 
1629 1629
 	// Get the permission bits.
1630
-	if ( $stat = @stat( $target_parent ) ) {
1630
+	if ($stat = @stat($target_parent)) {
1631 1631
 		$dir_perms = $stat['mode'] & 0007777;
1632 1632
 	} else {
1633 1633
 		$dir_perms = 0777;
1634 1634
 	}
1635 1635
 
1636
-	if ( @mkdir( $target, $dir_perms, true ) ) {
1636
+	if (@mkdir($target, $dir_perms, true)) {
1637 1637
 
1638 1638
 		/*
1639 1639
 		 * If a umask is set that modifies $dir_perms, we'll have to re-set
1640 1640
 		 * the $dir_perms correctly with chmod()
1641 1641
 		 */
1642
-		if ( $dir_perms != ( $dir_perms & ~umask() ) ) {
1643
-			$folder_parts = explode( '/', substr( $target, strlen( $target_parent ) + 1 ) );
1644
-			for ( $i = 1, $c = count( $folder_parts ); $i <= $c; $i++ ) {
1645
-				@chmod( $target_parent . '/' . implode( '/', array_slice( $folder_parts, 0, $i ) ), $dir_perms );
1642
+		if ($dir_perms != ($dir_perms & ~umask())) {
1643
+			$folder_parts = explode('/', substr($target, strlen($target_parent) + 1));
1644
+			for ($i = 1, $c = count($folder_parts); $i <= $c; $i++) {
1645
+				@chmod($target_parent.'/'.implode('/', array_slice($folder_parts, 0, $i)), $dir_perms);
1646 1646
 			}
1647 1647
 		}
1648 1648
 
@@ -1662,23 +1662,23 @@  discard block
 block discarded – undo
1662 1662
  * @param string $path File path.
1663 1663
  * @return bool True if path is absolute, false is not absolute.
1664 1664
  */
1665
-function path_is_absolute( $path ) {
1665
+function path_is_absolute($path) {
1666 1666
 	/*
1667 1667
 	 * This is definitive if true but fails if $path does not exist or contains
1668 1668
 	 * a symbolic link.
1669 1669
 	 */
1670
-	if ( realpath($path) == $path )
1670
+	if (realpath($path) == $path)
1671 1671
 		return true;
1672 1672
 
1673
-	if ( strlen($path) == 0 || $path[0] == '.' )
1673
+	if (strlen($path) == 0 || $path[0] == '.')
1674 1674
 		return false;
1675 1675
 
1676 1676
 	// Windows allows absolute paths like this.
1677
-	if ( preg_match('#^[a-zA-Z]:\\\\#', $path) )
1677
+	if (preg_match('#^[a-zA-Z]:\\\\#', $path))
1678 1678
 		return true;
1679 1679
 
1680 1680
 	// A path starting with / or \ is absolute; anything else is relative.
1681
-	return ( $path[0] == '/' || $path[0] == '\\' );
1681
+	return ($path[0] == '/' || $path[0] == '\\');
1682 1682
 }
1683 1683
 
1684 1684
 /**
@@ -1693,11 +1693,11 @@  discard block
 block discarded – undo
1693 1693
  * @param string $path Path relative to $base.
1694 1694
  * @return string The path with the base or absolute path.
1695 1695
  */
1696
-function path_join( $base, $path ) {
1697
-	if ( path_is_absolute($path) )
1696
+function path_join($base, $path) {
1697
+	if (path_is_absolute($path))
1698 1698
 		return $path;
1699 1699
 
1700
-	return rtrim($base, '/') . '/' . ltrim($path, '/');
1700
+	return rtrim($base, '/').'/'.ltrim($path, '/');
1701 1701
 }
1702 1702
 
1703 1703
 /**
@@ -1715,11 +1715,11 @@  discard block
 block discarded – undo
1715 1715
  * @param string $path Path to normalize.
1716 1716
  * @return string Normalized path.
1717 1717
  */
1718
-function wp_normalize_path( $path ) {
1719
-	$path = str_replace( '\\', '/', $path );
1720
-	$path = preg_replace( '|(?<=.)/+|', '/', $path );
1721
-	if ( ':' === substr( $path, 1, 1 ) ) {
1722
-		$path = ucfirst( $path );
1718
+function wp_normalize_path($path) {
1719
+	$path = str_replace('\\', '/', $path);
1720
+	$path = preg_replace('|(?<=.)/+|', '/', $path);
1721
+	if (':' === substr($path, 1, 1)) {
1722
+		$path = ucfirst($path);
1723 1723
 	}
1724 1724
 	return $path;
1725 1725
 }
@@ -1742,24 +1742,24 @@  discard block
 block discarded – undo
1742 1742
  */
1743 1743
 function get_temp_dir() {
1744 1744
 	static $temp = '';
1745
-	if ( defined('WP_TEMP_DIR') )
1745
+	if (defined('WP_TEMP_DIR'))
1746 1746
 		return trailingslashit(WP_TEMP_DIR);
1747 1747
 
1748
-	if ( $temp )
1749
-		return trailingslashit( $temp );
1748
+	if ($temp)
1749
+		return trailingslashit($temp);
1750 1750
 
1751
-	if ( function_exists('sys_get_temp_dir') ) {
1751
+	if (function_exists('sys_get_temp_dir')) {
1752 1752
 		$temp = sys_get_temp_dir();
1753
-		if ( @is_dir( $temp ) && wp_is_writable( $temp ) )
1754
-			return trailingslashit( $temp );
1753
+		if (@is_dir($temp) && wp_is_writable($temp))
1754
+			return trailingslashit($temp);
1755 1755
 	}
1756 1756
 
1757 1757
 	$temp = ini_get('upload_tmp_dir');
1758
-	if ( @is_dir( $temp ) && wp_is_writable( $temp ) )
1759
-		return trailingslashit( $temp );
1758
+	if (@is_dir($temp) && wp_is_writable($temp))
1759
+		return trailingslashit($temp);
1760 1760
 
1761
-	$temp = WP_CONTENT_DIR . '/';
1762
-	if ( is_dir( $temp ) && wp_is_writable( $temp ) )
1761
+	$temp = WP_CONTENT_DIR.'/';
1762
+	if (is_dir($temp) && wp_is_writable($temp))
1763 1763
 		return $temp;
1764 1764
 
1765 1765
 	return '/tmp/';
@@ -1778,11 +1778,11 @@  discard block
 block discarded – undo
1778 1778
  * @param string $path Path to check for write-ability.
1779 1779
  * @return bool Whether the path is writable.
1780 1780
  */
1781
-function wp_is_writable( $path ) {
1782
-	if ( 'WIN' === strtoupper( substr( PHP_OS, 0, 3 ) ) )
1783
-		return win_is_writable( $path );
1781
+function wp_is_writable($path) {
1782
+	if ('WIN' === strtoupper(substr(PHP_OS, 0, 3)))
1783
+		return win_is_writable($path);
1784 1784
 	else
1785
-		return @is_writable( $path );
1785
+		return @is_writable($path);
1786 1786
 }
1787 1787
 
1788 1788
 /**
@@ -1801,21 +1801,21 @@  discard block
 block discarded – undo
1801 1801
  * @param string $path Windows path to check for write-ability.
1802 1802
  * @return bool Whether the path is writable.
1803 1803
  */
1804
-function win_is_writable( $path ) {
1804
+function win_is_writable($path) {
1805 1805
 
1806
-	if ( $path[strlen( $path ) - 1] == '/' ) { // if it looks like a directory, check a random file within the directory
1807
-		return win_is_writable( $path . uniqid( mt_rand() ) . '.tmp');
1808
-	} elseif ( is_dir( $path ) ) { // If it's a directory (and not a file) check a random file within the directory
1809
-		return win_is_writable( $path . '/' . uniqid( mt_rand() ) . '.tmp' );
1806
+	if ($path[strlen($path) - 1] == '/') { // if it looks like a directory, check a random file within the directory
1807
+		return win_is_writable($path.uniqid(mt_rand()).'.tmp');
1808
+	} elseif (is_dir($path)) { // If it's a directory (and not a file) check a random file within the directory
1809
+		return win_is_writable($path.'/'.uniqid(mt_rand()).'.tmp');
1810 1810
 	}
1811 1811
 	// check tmp file for read/write capabilities
1812
-	$should_delete_tmp_file = !file_exists( $path );
1813
-	$f = @fopen( $path, 'a' );
1814
-	if ( $f === false )
1812
+	$should_delete_tmp_file = ! file_exists($path);
1813
+	$f = @fopen($path, 'a');
1814
+	if ($f === false)
1815 1815
 		return false;
1816
-	fclose( $f );
1817
-	if ( $should_delete_tmp_file )
1818
-		unlink( $path );
1816
+	fclose($f);
1817
+	if ($should_delete_tmp_file)
1818
+		unlink($path);
1819 1819
 	return true;
1820 1820
 }
1821 1821
 
@@ -1833,7 +1833,7 @@  discard block
 block discarded – undo
1833 1833
  * @return array See wp_upload_dir() for description.
1834 1834
  */
1835 1835
 function wp_get_upload_dir() {
1836
-	return wp_upload_dir( null, false );
1836
+	return wp_upload_dir(null, false);
1837 1837
 }
1838 1838
 
1839 1839
 /**
@@ -1872,13 +1872,13 @@  discard block
 block discarded – undo
1872 1872
  * @param bool   $refresh_cache Optional. Whether to refresh the cache. Default false.
1873 1873
  * @return array See above for description.
1874 1874
  */
1875
-function wp_upload_dir( $time = null, $create_dir = true, $refresh_cache = false ) {
1875
+function wp_upload_dir($time = null, $create_dir = true, $refresh_cache = false) {
1876 1876
 	static $cache = array(), $tested_paths = array();
1877 1877
 
1878
-	$key = sprintf( '%d-%s', get_current_blog_id(), (string) $time );
1878
+	$key = sprintf('%d-%s', get_current_blog_id(), (string) $time);
1879 1879
 
1880
-	if ( $refresh_cache || empty( $cache[ $key ] ) ) {
1881
-		$cache[ $key ] = _wp_upload_dir( $time );
1880
+	if ($refresh_cache || empty($cache[$key])) {
1881
+		$cache[$key] = _wp_upload_dir($time);
1882 1882
 	}
1883 1883
 
1884 1884
 	/**
@@ -1889,29 +1889,29 @@  discard block
 block discarded – undo
1889 1889
 	 * @param array $uploads Array of upload directory data with keys of 'path',
1890 1890
 	 *                       'url', 'subdir, 'basedir', and 'error'.
1891 1891
 	 */
1892
-	$uploads = apply_filters( 'upload_dir', $cache[ $key ] );
1892
+	$uploads = apply_filters('upload_dir', $cache[$key]);
1893 1893
 
1894
-	if ( $create_dir ) {
1894
+	if ($create_dir) {
1895 1895
 		$path = $uploads['path'];
1896 1896
 
1897
-		if ( array_key_exists( $path, $tested_paths ) ) {
1898
-			$uploads['error'] = $tested_paths[ $path ];
1897
+		if (array_key_exists($path, $tested_paths)) {
1898
+			$uploads['error'] = $tested_paths[$path];
1899 1899
 		} else {
1900
-			if ( ! wp_mkdir_p( $path ) ) {
1901
-				if ( 0 === strpos( $uploads['basedir'], ABSPATH ) ) {
1902
-					$error_path = str_replace( ABSPATH, '', $uploads['basedir'] ) . $uploads['subdir'];
1900
+			if ( ! wp_mkdir_p($path)) {
1901
+				if (0 === strpos($uploads['basedir'], ABSPATH)) {
1902
+					$error_path = str_replace(ABSPATH, '', $uploads['basedir']).$uploads['subdir'];
1903 1903
 				} else {
1904
-					$error_path = basename( $uploads['basedir'] ) . $uploads['subdir'];
1904
+					$error_path = basename($uploads['basedir']).$uploads['subdir'];
1905 1905
 				}
1906 1906
 
1907 1907
 				$uploads['error'] = sprintf(
1908 1908
 					/* translators: %s: directory path */
1909
-					__( 'Unable to create directory %s. Is its parent directory writable by the server?' ),
1910
-					esc_html( $error_path )
1909
+					__('Unable to create directory %s. Is its parent directory writable by the server?'),
1910
+					esc_html($error_path)
1911 1911
 				);
1912 1912
 			}
1913 1913
 
1914
-			$tested_paths[ $path ] = $uploads['error'];
1914
+			$tested_paths[$path] = $uploads['error'];
1915 1915
 		}
1916 1916
 	}
1917 1917
 
@@ -1927,39 +1927,39 @@  discard block
 block discarded – undo
1927 1927
  * @param string $time Optional. Time formatted in 'yyyy/mm'. Default null.
1928 1928
  * @return array See wp_upload_dir()
1929 1929
  */
1930
-function _wp_upload_dir( $time = null ) {
1931
-	$siteurl = get_option( 'siteurl' );
1932
-	$upload_path = trim( get_option( 'upload_path' ) );
1930
+function _wp_upload_dir($time = null) {
1931
+	$siteurl = get_option('siteurl');
1932
+	$upload_path = trim(get_option('upload_path'));
1933 1933
 
1934
-	if ( empty( $upload_path ) || 'wp-content/uploads' == $upload_path ) {
1935
-		$dir = WP_CONTENT_DIR . '/uploads';
1936
-	} elseif ( 0 !== strpos( $upload_path, ABSPATH ) ) {
1934
+	if (empty($upload_path) || 'wp-content/uploads' == $upload_path) {
1935
+		$dir = WP_CONTENT_DIR.'/uploads';
1936
+	} elseif (0 !== strpos($upload_path, ABSPATH)) {
1937 1937
 		// $dir is absolute, $upload_path is (maybe) relative to ABSPATH
1938
-		$dir = path_join( ABSPATH, $upload_path );
1938
+		$dir = path_join(ABSPATH, $upload_path);
1939 1939
 	} else {
1940 1940
 		$dir = $upload_path;
1941 1941
 	}
1942 1942
 
1943
-	if ( !$url = get_option( 'upload_url_path' ) ) {
1944
-		if ( empty($upload_path) || ( 'wp-content/uploads' == $upload_path ) || ( $upload_path == $dir ) )
1945
-			$url = WP_CONTENT_URL . '/uploads';
1943
+	if ( ! $url = get_option('upload_url_path')) {
1944
+		if (empty($upload_path) || ('wp-content/uploads' == $upload_path) || ($upload_path == $dir))
1945
+			$url = WP_CONTENT_URL.'/uploads';
1946 1946
 		else
1947
-			$url = trailingslashit( $siteurl ) . $upload_path;
1947
+			$url = trailingslashit($siteurl).$upload_path;
1948 1948
 	}
1949 1949
 
1950 1950
 	/*
1951 1951
 	 * Honor the value of UPLOADS. This happens as long as ms-files rewriting is disabled.
1952 1952
 	 * We also sometimes obey UPLOADS when rewriting is enabled -- see the next block.
1953 1953
 	 */
1954
-	if ( defined( 'UPLOADS' ) && ! ( is_multisite() && get_site_option( 'ms_files_rewriting' ) ) ) {
1955
-		$dir = ABSPATH . UPLOADS;
1956
-		$url = trailingslashit( $siteurl ) . UPLOADS;
1954
+	if (defined('UPLOADS') && ! (is_multisite() && get_site_option('ms_files_rewriting'))) {
1955
+		$dir = ABSPATH.UPLOADS;
1956
+		$url = trailingslashit($siteurl).UPLOADS;
1957 1957
 	}
1958 1958
 
1959 1959
 	// If multisite (and if not the main site in a post-MU network)
1960
-	if ( is_multisite() && ! ( is_main_network() && is_main_site() && defined( 'MULTISITE' ) ) ) {
1960
+	if (is_multisite() && ! (is_main_network() && is_main_site() && defined('MULTISITE'))) {
1961 1961
 
1962
-		if ( ! get_site_option( 'ms_files_rewriting' ) ) {
1962
+		if ( ! get_site_option('ms_files_rewriting')) {
1963 1963
 			/*
1964 1964
 			 * If ms-files rewriting is disabled (networks created post-3.5), it is fairly
1965 1965
 			 * straightforward: Append sites/%d if we're not on the main site (for post-MU
@@ -1969,15 +1969,15 @@  discard block
 block discarded – undo
1969 1969
 			 * had wp-content/uploads for the main site.)
1970 1970
 			 */
1971 1971
 
1972
-			if ( defined( 'MULTISITE' ) )
1973
-				$ms_dir = '/sites/' . get_current_blog_id();
1972
+			if (defined('MULTISITE'))
1973
+				$ms_dir = '/sites/'.get_current_blog_id();
1974 1974
 			else
1975
-				$ms_dir = '/' . get_current_blog_id();
1975
+				$ms_dir = '/'.get_current_blog_id();
1976 1976
 
1977 1977
 			$dir .= $ms_dir;
1978 1978
 			$url .= $ms_dir;
1979 1979
 
1980
-		} elseif ( defined( 'UPLOADS' ) && ! ms_is_switched() ) {
1980
+		} elseif (defined('UPLOADS') && ! ms_is_switched()) {
1981 1981
 			/*
1982 1982
 			 * Handle the old-form ms-files.php rewriting if the network still has that enabled.
1983 1983
 			 * When ms-files rewriting is enabled, then we only listen to UPLOADS when:
@@ -1992,11 +1992,11 @@  discard block
 block discarded – undo
1992 1992
 			 * rewriting in multisite, the resulting URL is /files. (#WP22702 for background.)
1993 1993
 			 */
1994 1994
 
1995
-			if ( defined( 'BLOGUPLOADDIR' ) )
1996
-				$dir = untrailingslashit( BLOGUPLOADDIR );
1995
+			if (defined('BLOGUPLOADDIR'))
1996
+				$dir = untrailingslashit(BLOGUPLOADDIR);
1997 1997
 			else
1998
-				$dir = ABSPATH . UPLOADS;
1999
-			$url = trailingslashit( $siteurl ) . 'files';
1998
+				$dir = ABSPATH.UPLOADS;
1999
+			$url = trailingslashit($siteurl).'files';
2000 2000
 		}
2001 2001
 	}
2002 2002
 
@@ -2004,12 +2004,12 @@  discard block
 block discarded – undo
2004 2004
 	$baseurl = $url;
2005 2005
 
2006 2006
 	$subdir = '';
2007
-	if ( get_option( 'uploads_use_yearmonth_folders' ) ) {
2007
+	if (get_option('uploads_use_yearmonth_folders')) {
2008 2008
 		// Generate the yearly and monthly dirs
2009
-		if ( !$time )
2010
-			$time = current_time( 'mysql' );
2011
-		$y = substr( $time, 0, 4 );
2012
-		$m = substr( $time, 5, 2 );
2009
+		if ( ! $time)
2010
+			$time = current_time('mysql');
2011
+		$y = substr($time, 0, 4);
2012
+		$m = substr($time, 5, 2);
2013 2013
 		$subdir = "/$y/$m";
2014 2014
 	}
2015 2015
 
@@ -2043,19 +2043,19 @@  discard block
 block discarded – undo
2043 2043
  * @param callable $unique_filename_callback Callback. Default null.
2044 2044
  * @return string New filename, if given wasn't unique.
2045 2045
  */
2046
-function wp_unique_filename( $dir, $filename, $unique_filename_callback = null ) {
2046
+function wp_unique_filename($dir, $filename, $unique_filename_callback = null) {
2047 2047
 	// Sanitize the file name before we begin processing.
2048 2048
 	$filename = sanitize_file_name($filename);
2049 2049
 
2050 2050
 	// Separate the filename into a name and extension.
2051
-	$ext = pathinfo( $filename, PATHINFO_EXTENSION );
2052
-	$name = pathinfo( $filename, PATHINFO_BASENAME );
2053
-	if ( $ext ) {
2054
-		$ext = '.' . $ext;
2051
+	$ext = pathinfo($filename, PATHINFO_EXTENSION);
2052
+	$name = pathinfo($filename, PATHINFO_BASENAME);
2053
+	if ($ext) {
2054
+		$ext = '.'.$ext;
2055 2055
 	}
2056 2056
 
2057 2057
 	// Edge case: if file is named '.ext', treat as an empty name.
2058
-	if ( $name === $ext ) {
2058
+	if ($name === $ext) {
2059 2059
 		$name = '';
2060 2060
 	}
2061 2061
 
@@ -2063,21 +2063,21 @@  discard block
 block discarded – undo
2063 2063
 	 * Increment the file number until we have a unique file to save in $dir.
2064 2064
 	 * Use callback if supplied.
2065 2065
 	 */
2066
-	if ( $unique_filename_callback && is_callable( $unique_filename_callback ) ) {
2067
-		$filename = call_user_func( $unique_filename_callback, $dir, $name, $ext );
2066
+	if ($unique_filename_callback && is_callable($unique_filename_callback)) {
2067
+		$filename = call_user_func($unique_filename_callback, $dir, $name, $ext);
2068 2068
 	} else {
2069 2069
 		$number = '';
2070 2070
 
2071 2071
 		// Change '.ext' to lower case.
2072
-		if ( $ext && strtolower($ext) != $ext ) {
2072
+		if ($ext && strtolower($ext) != $ext) {
2073 2073
 			$ext2 = strtolower($ext);
2074
-			$filename2 = preg_replace( '|' . preg_quote($ext) . '$|', $ext2, $filename );
2074
+			$filename2 = preg_replace('|'.preg_quote($ext).'$|', $ext2, $filename);
2075 2075
 
2076 2076
 			// Check for both lower and upper case extension or image sub-sizes may be overwritten.
2077
-			while ( file_exists($dir . "/$filename") || file_exists($dir . "/$filename2") ) {
2077
+			while (file_exists($dir."/$filename") || file_exists($dir."/$filename2")) {
2078 2078
 				$new_number = $number + 1;
2079
-				$filename = str_replace( array( "-$number$ext", "$number$ext" ), "-$new_number$ext", $filename );
2080
-				$filename2 = str_replace( array( "-$number$ext2", "$number$ext2" ), "-$new_number$ext2", $filename2 );
2079
+				$filename = str_replace(array("-$number$ext", "$number$ext"), "-$new_number$ext", $filename);
2080
+				$filename2 = str_replace(array("-$number$ext2", "$number$ext2"), "-$new_number$ext2", $filename2);
2081 2081
 				$number = $new_number;
2082 2082
 			}
2083 2083
 
@@ -2091,20 +2091,20 @@  discard block
 block discarded – undo
2091 2091
 			 * @param string        $dir                      Directory path.
2092 2092
 			 * @param callable|null $unique_filename_callback Callback function that generates the unique file name.
2093 2093
 			 */
2094
-			return apply_filters( 'wp_unique_filename', $filename2, $ext, $dir, $unique_filename_callback );
2094
+			return apply_filters('wp_unique_filename', $filename2, $ext, $dir, $unique_filename_callback);
2095 2095
 		}
2096 2096
 
2097
-		while ( file_exists( $dir . "/$filename" ) ) {
2098
-			if ( '' == "$number$ext" ) {
2099
-				$filename = "$filename-" . ++$number;
2097
+		while (file_exists($dir."/$filename")) {
2098
+			if ('' == "$number$ext") {
2099
+				$filename = "$filename-".++$number;
2100 2100
 			} else {
2101
-				$filename = str_replace( array( "-$number$ext", "$number$ext" ), "-" . ++$number . $ext, $filename );
2101
+				$filename = str_replace(array("-$number$ext", "$number$ext"), "-".++$number.$ext, $filename);
2102 2102
 			}
2103 2103
 		}
2104 2104
 	}
2105 2105
 
2106 2106
 	/** This filter is documented in wp-includes/functions.php */
2107
-	return apply_filters( 'wp_unique_filename', $filename, $ext, $dir, $unique_filename_callback );
2107
+	return apply_filters('wp_unique_filename', $filename, $ext, $dir, $unique_filename_callback);
2108 2108
 }
2109 2109
 
2110 2110
 /**
@@ -2130,20 +2130,20 @@  discard block
 block discarded – undo
2130 2130
  * @param string       $time       Optional. Time formatted in 'yyyy/mm'. Default null.
2131 2131
  * @return array
2132 2132
  */
2133
-function wp_upload_bits( $name, $deprecated, $bits, $time = null ) {
2134
-	if ( !empty( $deprecated ) )
2135
-		_deprecated_argument( __FUNCTION__, '2.0.0' );
2133
+function wp_upload_bits($name, $deprecated, $bits, $time = null) {
2134
+	if ( ! empty($deprecated))
2135
+		_deprecated_argument(__FUNCTION__, '2.0.0');
2136 2136
 
2137
-	if ( empty( $name ) )
2138
-		return array( 'error' => __( 'Empty filename' ) );
2137
+	if (empty($name))
2138
+		return array('error' => __('Empty filename'));
2139 2139
 
2140
-	$wp_filetype = wp_check_filetype( $name );
2141
-	if ( ! $wp_filetype['ext'] && ! current_user_can( 'unfiltered_upload' ) )
2142
-		return array( 'error' => __( 'Invalid file type' ) );
2140
+	$wp_filetype = wp_check_filetype($name);
2141
+	if ( ! $wp_filetype['ext'] && ! current_user_can('unfiltered_upload'))
2142
+		return array('error' => __('Invalid file type'));
2143 2143
 
2144
-	$upload = wp_upload_dir( $time );
2144
+	$upload = wp_upload_dir($time);
2145 2145
 
2146
-	if ( $upload['error'] !== false )
2146
+	if ($upload['error'] !== false)
2147 2147
 		return $upload;
2148 2148
 
2149 2149
 	/**
@@ -2156,49 +2156,49 @@  discard block
 block discarded – undo
2156 2156
 	 *
2157 2157
 	 * @param mixed $upload_bits_error An array of upload bits data, or a non-array error to return.
2158 2158
 	 */
2159
-	$upload_bits_error = apply_filters( 'wp_upload_bits', array( 'name' => $name, 'bits' => $bits, 'time' => $time ) );
2160
-	if ( !is_array( $upload_bits_error ) ) {
2161
-		$upload[ 'error' ] = $upload_bits_error;
2159
+	$upload_bits_error = apply_filters('wp_upload_bits', array('name' => $name, 'bits' => $bits, 'time' => $time));
2160
+	if ( ! is_array($upload_bits_error)) {
2161
+		$upload['error'] = $upload_bits_error;
2162 2162
 		return $upload;
2163 2163
 	}
2164 2164
 
2165
-	$filename = wp_unique_filename( $upload['path'], $name );
2165
+	$filename = wp_unique_filename($upload['path'], $name);
2166 2166
 
2167
-	$new_file = $upload['path'] . "/$filename";
2168
-	if ( ! wp_mkdir_p( dirname( $new_file ) ) ) {
2169
-		if ( 0 === strpos( $upload['basedir'], ABSPATH ) )
2170
-			$error_path = str_replace( ABSPATH, '', $upload['basedir'] ) . $upload['subdir'];
2167
+	$new_file = $upload['path']."/$filename";
2168
+	if ( ! wp_mkdir_p(dirname($new_file))) {
2169
+		if (0 === strpos($upload['basedir'], ABSPATH))
2170
+			$error_path = str_replace(ABSPATH, '', $upload['basedir']).$upload['subdir'];
2171 2171
 		else
2172
-			$error_path = basename( $upload['basedir'] ) . $upload['subdir'];
2172
+			$error_path = basename($upload['basedir']).$upload['subdir'];
2173 2173
 
2174 2174
 		$message = sprintf(
2175 2175
 			/* translators: %s: directory path */
2176
-			__( 'Unable to create directory %s. Is its parent directory writable by the server?' ),
2176
+			__('Unable to create directory %s. Is its parent directory writable by the server?'),
2177 2177
 			$error_path
2178 2178
 		);
2179
-		return array( 'error' => $message );
2179
+		return array('error' => $message);
2180 2180
 	}
2181 2181
 
2182
-	$ifp = @ fopen( $new_file, 'wb' );
2183
-	if ( ! $ifp )
2184
-		return array( 'error' => sprintf( __( 'Could not write file %s' ), $new_file ) );
2182
+	$ifp = @ fopen($new_file, 'wb');
2183
+	if ( ! $ifp)
2184
+		return array('error' => sprintf(__('Could not write file %s'), $new_file));
2185 2185
 
2186
-	@fwrite( $ifp, $bits );
2187
-	fclose( $ifp );
2186
+	@fwrite($ifp, $bits);
2187
+	fclose($ifp);
2188 2188
 	clearstatcache();
2189 2189
 
2190 2190
 	// Set correct file permissions
2191
-	$stat = @ stat( dirname( $new_file ) );
2191
+	$stat = @ stat(dirname($new_file));
2192 2192
 	$perms = $stat['mode'] & 0007777;
2193 2193
 	$perms = $perms & 0000666;
2194
-	@ chmod( $new_file, $perms );
2194
+	@ chmod($new_file, $perms);
2195 2195
 	clearstatcache();
2196 2196
 
2197 2197
 	// Compute the URL
2198
-	$url = $upload['url'] . "/$filename";
2198
+	$url = $upload['url']."/$filename";
2199 2199
 
2200 2200
 	/** This filter is documented in wp-admin/includes/file.php */
2201
-	return apply_filters( 'wp_handle_upload', array( 'file' => $new_file, 'url' => $url, 'type' => $wp_filetype['type'], 'error' => false ), 'sideload' );
2201
+	return apply_filters('wp_handle_upload', array('file' => $new_file, 'url' => $url, 'type' => $wp_filetype['type'], 'error' => false), 'sideload');
2202 2202
 }
2203 2203
 
2204 2204
 /**
@@ -2209,12 +2209,12 @@  discard block
 block discarded – undo
2209 2209
  * @param string $ext The extension to search.
2210 2210
  * @return string|void The file type, example: audio, video, document, spreadsheet, etc.
2211 2211
  */
2212
-function wp_ext2type( $ext ) {
2213
-	$ext = strtolower( $ext );
2212
+function wp_ext2type($ext) {
2213
+	$ext = strtolower($ext);
2214 2214
 
2215 2215
 	$ext2type = wp_get_ext_types();
2216
-	foreach ( $ext2type as $type => $exts )
2217
-		if ( in_array( $ext, $exts ) )
2216
+	foreach ($ext2type as $type => $exts)
2217
+		if (in_array($ext, $exts))
2218 2218
 			return $type;
2219 2219
 }
2220 2220
 
@@ -2229,22 +2229,22 @@  discard block
 block discarded – undo
2229 2229
  * @param array  $mimes    Optional. Key is the file extension with value as the mime type.
2230 2230
  * @return array Values with extension first and mime type.
2231 2231
  */
2232
-function wp_check_filetype( $filename, $mimes = null ) {
2233
-	if ( empty($mimes) )
2232
+function wp_check_filetype($filename, $mimes = null) {
2233
+	if (empty($mimes))
2234 2234
 		$mimes = get_allowed_mime_types();
2235 2235
 	$type = false;
2236 2236
 	$ext = false;
2237 2237
 
2238
-	foreach ( $mimes as $ext_preg => $mime_match ) {
2239
-		$ext_preg = '!\.(' . $ext_preg . ')$!i';
2240
-		if ( preg_match( $ext_preg, $filename, $ext_matches ) ) {
2238
+	foreach ($mimes as $ext_preg => $mime_match) {
2239
+		$ext_preg = '!\.('.$ext_preg.')$!i';
2240
+		if (preg_match($ext_preg, $filename, $ext_matches)) {
2241 2241
 			$type = $mime_match;
2242 2242
 			$ext = $ext_matches[1];
2243 2243
 			break;
2244 2244
 		}
2245 2245
 	}
2246 2246
 
2247
-	return compact( 'ext', 'type' );
2247
+	return compact('ext', 'type');
2248 2248
 }
2249 2249
 
2250 2250
 /**
@@ -2266,27 +2266,27 @@  discard block
 block discarded – undo
2266 2266
  * @return array Values for the extension, MIME, and either a corrected filename or false
2267 2267
  *               if original $filename is valid.
2268 2268
  */
2269
-function wp_check_filetype_and_ext( $file, $filename, $mimes = null ) {
2269
+function wp_check_filetype_and_ext($file, $filename, $mimes = null) {
2270 2270
 	$proper_filename = false;
2271 2271
 
2272 2272
 	// Do basic extension validation and MIME mapping
2273
-	$wp_filetype = wp_check_filetype( $filename, $mimes );
2273
+	$wp_filetype = wp_check_filetype($filename, $mimes);
2274 2274
 	$ext = $wp_filetype['ext'];
2275 2275
 	$type = $wp_filetype['type'];
2276 2276
 
2277 2277
 	// We can't do any further validation without a file to work with
2278
-	if ( ! file_exists( $file ) ) {
2279
-		return compact( 'ext', 'type', 'proper_filename' );
2278
+	if ( ! file_exists($file)) {
2279
+		return compact('ext', 'type', 'proper_filename');
2280 2280
 	}
2281 2281
 
2282 2282
 	// We're able to validate images using GD
2283
-	if ( $type && 0 === strpos( $type, 'image/' ) && function_exists('getimagesize') ) {
2283
+	if ($type && 0 === strpos($type, 'image/') && function_exists('getimagesize')) {
2284 2284
 
2285 2285
 		// Attempt to figure out what type of image it actually is
2286
-		$imgstats = @getimagesize( $file );
2286
+		$imgstats = @getimagesize($file);
2287 2287
 
2288 2288
 		// If getimagesize() knows what kind of image it really is and if the real MIME doesn't match the claimed MIME
2289
-		if ( !empty($imgstats['mime']) && $imgstats['mime'] != $type ) {
2289
+		if ( ! empty($imgstats['mime']) && $imgstats['mime'] != $type) {
2290 2290
 			/**
2291 2291
 			 * Filters the list mapping image mime types to their respective extensions.
2292 2292
 			 *
@@ -2294,26 +2294,26 @@  discard block
 block discarded – undo
2294 2294
 			 *
2295 2295
 			 * @param  array $mime_to_ext Array of image mime types and their matching extensions.
2296 2296
 			 */
2297
-			$mime_to_ext = apply_filters( 'getimagesize_mimes_to_exts', array(
2297
+			$mime_to_ext = apply_filters('getimagesize_mimes_to_exts', array(
2298 2298
 				'image/jpeg' => 'jpg',
2299 2299
 				'image/png'  => 'png',
2300 2300
 				'image/gif'  => 'gif',
2301 2301
 				'image/bmp'  => 'bmp',
2302 2302
 				'image/tiff' => 'tif',
2303
-			) );
2303
+			));
2304 2304
 
2305 2305
 			// Replace whatever is after the last period in the filename with the correct extension
2306
-			if ( ! empty( $mime_to_ext[ $imgstats['mime'] ] ) ) {
2307
-				$filename_parts = explode( '.', $filename );
2308
-				array_pop( $filename_parts );
2309
-				$filename_parts[] = $mime_to_ext[ $imgstats['mime'] ];
2310
-				$new_filename = implode( '.', $filename_parts );
2306
+			if ( ! empty($mime_to_ext[$imgstats['mime']])) {
2307
+				$filename_parts = explode('.', $filename);
2308
+				array_pop($filename_parts);
2309
+				$filename_parts[] = $mime_to_ext[$imgstats['mime']];
2310
+				$new_filename = implode('.', $filename_parts);
2311 2311
 
2312
-				if ( $new_filename != $filename ) {
2312
+				if ($new_filename != $filename) {
2313 2313
 					$proper_filename = $new_filename; // Mark that it changed
2314 2314
 				}
2315 2315
 				// Redefine the extension / MIME
2316
-				$wp_filetype = wp_check_filetype( $new_filename, $mimes );
2316
+				$wp_filetype = wp_check_filetype($new_filename, $mimes);
2317 2317
 				$ext = $wp_filetype['ext'];
2318 2318
 				$type = $wp_filetype['type'];
2319 2319
 			}
@@ -2332,7 +2332,7 @@  discard block
 block discarded – undo
2332 2332
 	 *                                          $file being in a tmp directory).
2333 2333
 	 * @param array  $mimes                     Key is the file extension with value as the mime type.
2334 2334
 	 */
2335
-	return apply_filters( 'wp_check_filetype_and_ext', compact( 'ext', 'type', 'proper_filename' ), $file, $filename, $mimes );
2335
+	return apply_filters('wp_check_filetype_and_ext', compact('ext', 'type', 'proper_filename'), $file, $filename, $mimes);
2336 2336
 }
2337 2337
 
2338 2338
 /**
@@ -2355,7 +2355,7 @@  discard block
 block discarded – undo
2355 2355
 	 * @param array $wp_get_mime_types Mime types keyed by the file extension regex
2356 2356
 	 *                                 corresponding to those types.
2357 2357
 	 */
2358
-	return apply_filters( 'mime_types', array(
2358
+	return apply_filters('mime_types', array(
2359 2359
 	// Image formats.
2360 2360
 	'jpg|jpeg|jpe' => 'image/jpeg',
2361 2361
 	'gif' => 'image/gif',
@@ -2455,7 +2455,7 @@  discard block
 block discarded – undo
2455 2455
 	'key' => 'application/vnd.apple.keynote',
2456 2456
 	'numbers' => 'application/vnd.apple.numbers',
2457 2457
 	'pages' => 'application/vnd.apple.pages',
2458
-	) );
2458
+	));
2459 2459
 }
2460 2460
 
2461 2461
 /**
@@ -2477,17 +2477,17 @@  discard block
 block discarded – undo
2477 2477
 	 * @param array $ext2type Multi-dimensional array with extensions for a default set
2478 2478
 	 *                        of file types.
2479 2479
 	 */
2480
-	return apply_filters( 'ext2type', array(
2481
-		'image'       => array( 'jpg', 'jpeg', 'jpe',  'gif',  'png',  'bmp',   'tif',  'tiff', 'ico' ),
2482
-		'audio'       => array( 'aac', 'ac3',  'aif',  'aiff', 'm3a',  'm4a',   'm4b',  'mka',  'mp1',  'mp2',  'mp3', 'ogg', 'oga', 'ram', 'wav', 'wma' ),
2483
-		'video'       => array( '3g2',  '3gp', '3gpp', 'asf', 'avi',  'divx', 'dv',   'flv',  'm4v',   'mkv',  'mov',  'mp4',  'mpeg', 'mpg', 'mpv', 'ogm', 'ogv', 'qt',  'rm', 'vob', 'wmv' ),
2484
-		'document'    => array( 'doc', 'docx', 'docm', 'dotm', 'odt',  'pages', 'pdf',  'xps',  'oxps', 'rtf',  'wp', 'wpd', 'psd', 'xcf' ),
2485
-		'spreadsheet' => array( 'numbers',     'ods',  'xls',  'xlsx', 'xlsm',  'xlsb' ),
2486
-		'interactive' => array( 'swf', 'key',  'ppt',  'pptx', 'pptm', 'pps',   'ppsx', 'ppsm', 'sldx', 'sldm', 'odp' ),
2487
-		'text'        => array( 'asc', 'csv',  'tsv',  'txt' ),
2488
-		'archive'     => array( 'bz2', 'cab',  'dmg',  'gz',   'rar',  'sea',   'sit',  'sqx',  'tar',  'tgz',  'zip', '7z' ),
2489
-		'code'        => array( 'css', 'htm',  'html', 'php',  'js' ),
2490
-	) );
2480
+	return apply_filters('ext2type', array(
2481
+		'image'       => array('jpg', 'jpeg', 'jpe', 'gif', 'png', 'bmp', 'tif', 'tiff', 'ico'),
2482
+		'audio'       => array('aac', 'ac3', 'aif', 'aiff', 'm3a', 'm4a', 'm4b', 'mka', 'mp1', 'mp2', 'mp3', 'ogg', 'oga', 'ram', 'wav', 'wma'),
2483
+		'video'       => array('3g2', '3gp', '3gpp', 'asf', 'avi', 'divx', 'dv', 'flv', 'm4v', 'mkv', 'mov', 'mp4', 'mpeg', 'mpg', 'mpv', 'ogm', 'ogv', 'qt', 'rm', 'vob', 'wmv'),
2484
+		'document'    => array('doc', 'docx', 'docm', 'dotm', 'odt', 'pages', 'pdf', 'xps', 'oxps', 'rtf', 'wp', 'wpd', 'psd', 'xcf'),
2485
+		'spreadsheet' => array('numbers', 'ods', 'xls', 'xlsx', 'xlsm', 'xlsb'),
2486
+		'interactive' => array('swf', 'key', 'ppt', 'pptx', 'pptm', 'pps', 'ppsx', 'ppsm', 'sldx', 'sldm', 'odp'),
2487
+		'text'        => array('asc', 'csv', 'tsv', 'txt'),
2488
+		'archive'     => array('bz2', 'cab', 'dmg', 'gz', 'rar', 'sea', 'sit', 'sqx', 'tar', 'tgz', 'zip', '7z'),
2489
+		'code'        => array('css', 'htm', 'html', 'php', 'js'),
2490
+	));
2491 2491
 }
2492 2492
 
2493 2493
 /**
@@ -2499,15 +2499,15 @@  discard block
 block discarded – undo
2499 2499
  * @return array Array of mime types keyed by the file extension regex corresponding
2500 2500
  *               to those types.
2501 2501
  */
2502
-function get_allowed_mime_types( $user = null ) {
2502
+function get_allowed_mime_types($user = null) {
2503 2503
 	$t = wp_get_mime_types();
2504 2504
 
2505
-	unset( $t['swf'], $t['exe'] );
2506
-	if ( function_exists( 'current_user_can' ) )
2507
-		$unfiltered = $user ? user_can( $user, 'unfiltered_html' ) : current_user_can( 'unfiltered_html' );
2505
+	unset($t['swf'], $t['exe']);
2506
+	if (function_exists('current_user_can'))
2507
+		$unfiltered = $user ? user_can($user, 'unfiltered_html') : current_user_can('unfiltered_html');
2508 2508
 
2509
-	if ( empty( $unfiltered ) )
2510
-		unset( $t['htm|html'] );
2509
+	if (empty($unfiltered))
2510
+		unset($t['htm|html']);
2511 2511
 
2512 2512
 	/**
2513 2513
 	 * Filters list of allowed mime types and file extensions.
@@ -2519,7 +2519,7 @@  discard block
 block discarded – undo
2519 2519
 	 *                               removed depending on '$user' capabilities.
2520 2520
 	 * @param int|WP_User|null $user User ID, User object or null if not provided (indicates current user).
2521 2521
 	 */
2522
-	return apply_filters( 'upload_mimes', $t, $user );
2522
+	return apply_filters('upload_mimes', $t, $user);
2523 2523
 }
2524 2524
 
2525 2525
 /**
@@ -2532,32 +2532,32 @@  discard block
 block discarded – undo
2532 2532
  *
2533 2533
  * @param string $action The nonce action.
2534 2534
  */
2535
-function wp_nonce_ays( $action ) {
2536
-	if ( 'log-out' == $action ) {
2535
+function wp_nonce_ays($action) {
2536
+	if ('log-out' == $action) {
2537 2537
 		$html = sprintf(
2538 2538
 			/* translators: %s: site name */
2539
-			__( 'You are attempting to log out of %s' ),
2540
-			get_bloginfo( 'name' )
2539
+			__('You are attempting to log out of %s'),
2540
+			get_bloginfo('name')
2541 2541
 		);
2542 2542
 		$html .= '</p><p>';
2543
-		$redirect_to = isset( $_REQUEST['redirect_to'] ) ? $_REQUEST['redirect_to'] : '';
2543
+		$redirect_to = isset($_REQUEST['redirect_to']) ? $_REQUEST['redirect_to'] : '';
2544 2544
 		$html .= sprintf(
2545 2545
 			/* translators: %s: logout URL */
2546
-			__( 'Do you really want to <a href="%s">log out</a>?' ),
2547
-			wp_logout_url( $redirect_to )
2546
+			__('Do you really want to <a href="%s">log out</a>?'),
2547
+			wp_logout_url($redirect_to)
2548 2548
 		);
2549 2549
 	} else {
2550
-		$html = __( 'Are you sure you want to do this?' );
2551
-		if ( wp_get_referer() ) {
2550
+		$html = __('Are you sure you want to do this?');
2551
+		if (wp_get_referer()) {
2552 2552
 			$html .= '</p><p>';
2553
-			$html .= sprintf( '<a href="%s">%s</a>',
2554
-				esc_url( remove_query_arg( 'updated', wp_get_referer() ) ),
2555
-				__( 'Please try again.' )
2553
+			$html .= sprintf('<a href="%s">%s</a>',
2554
+				esc_url(remove_query_arg('updated', wp_get_referer())),
2555
+				__('Please try again.')
2556 2556
 			);
2557 2557
 		}
2558 2558
 	}
2559 2559
 
2560
-	wp_die( $html, __( 'WordPress Failure Notice' ), 403 );
2560
+	wp_die($html, __('WordPress Failure Notice'), 403);
2561 2561
 }
2562 2562
 
2563 2563
 /**
@@ -2594,16 +2594,16 @@  discard block
 block discarded – undo
2594 2594
  *                                  Default is the value of is_rtl().
2595 2595
  * }
2596 2596
  */
2597
-function wp_die( $message = '', $title = '', $args = array() ) {
2597
+function wp_die($message = '', $title = '', $args = array()) {
2598 2598
 
2599
-	if ( is_int( $args ) ) {
2600
-		$args = array( 'response' => $args );
2601
-	} elseif ( is_int( $title ) ) {
2602
-		$args  = array( 'response' => $title );
2599
+	if (is_int($args)) {
2600
+		$args = array('response' => $args);
2601
+	} elseif (is_int($title)) {
2602
+		$args  = array('response' => $title);
2603 2603
 		$title = '';
2604 2604
 	}
2605 2605
 
2606
-	if ( wp_doing_ajax() ) {
2606
+	if (wp_doing_ajax()) {
2607 2607
 		/**
2608 2608
 		 * Filters the callback for killing WordPress execution for Ajax requests.
2609 2609
 		 *
@@ -2611,8 +2611,8 @@  discard block
 block discarded – undo
2611 2611
 		 *
2612 2612
 		 * @param callable $function Callback function name.
2613 2613
 		 */
2614
-		$function = apply_filters( 'wp_die_ajax_handler', '_ajax_wp_die_handler' );
2615
-	} elseif ( defined( 'XMLRPC_REQUEST' ) && XMLRPC_REQUEST ) {
2614
+		$function = apply_filters('wp_die_ajax_handler', '_ajax_wp_die_handler');
2615
+	} elseif (defined('XMLRPC_REQUEST') && XMLRPC_REQUEST) {
2616 2616
 		/**
2617 2617
 		 * Filters the callback for killing WordPress execution for XML-RPC requests.
2618 2618
 		 *
@@ -2620,7 +2620,7 @@  discard block
 block discarded – undo
2620 2620
 		 *
2621 2621
 		 * @param callable $function Callback function name.
2622 2622
 		 */
2623
-		$function = apply_filters( 'wp_die_xmlrpc_handler', '_xmlrpc_wp_die_handler' );
2623
+		$function = apply_filters('wp_die_xmlrpc_handler', '_xmlrpc_wp_die_handler');
2624 2624
 	} else {
2625 2625
 		/**
2626 2626
 		 * Filters the callback for killing WordPress execution for all non-Ajax, non-XML-RPC requests.
@@ -2629,10 +2629,10 @@  discard block
 block discarded – undo
2629 2629
 		 *
2630 2630
 		 * @param callable $function Callback function name.
2631 2631
 		 */
2632
-		$function = apply_filters( 'wp_die_handler', '_default_wp_die_handler' );
2632
+		$function = apply_filters('wp_die_handler', '_default_wp_die_handler');
2633 2633
 	}
2634 2634
 
2635
-	call_user_func( $function, $message, $title, $args );
2635
+	call_user_func($function, $message, $title, $args);
2636 2636
 }
2637 2637
 
2638 2638
 /**
@@ -2648,20 +2648,20 @@  discard block
 block discarded – undo
2648 2648
  * @param string          $title   Optional. Error title. Default empty.
2649 2649
  * @param string|array    $args    Optional. Arguments to control behavior. Default empty array.
2650 2650
  */
2651
-function _default_wp_die_handler( $message, $title = '', $args = array() ) {
2652
-	$defaults = array( 'response' => 500 );
2651
+function _default_wp_die_handler($message, $title = '', $args = array()) {
2652
+	$defaults = array('response' => 500);
2653 2653
 	$r = wp_parse_args($args, $defaults);
2654 2654
 
2655 2655
 	$have_gettext = function_exists('__');
2656 2656
 
2657
-	if ( function_exists( 'is_wp_error' ) && is_wp_error( $message ) ) {
2658
-		if ( empty( $title ) ) {
2657
+	if (function_exists('is_wp_error') && is_wp_error($message)) {
2658
+		if (empty($title)) {
2659 2659
 			$error_data = $message->get_error_data();
2660
-			if ( is_array( $error_data ) && isset( $error_data['title'] ) )
2660
+			if (is_array($error_data) && isset($error_data['title']))
2661 2661
 				$title = $error_data['title'];
2662 2662
 		}
2663 2663
 		$errors = $message->get_error_messages();
2664
-		switch ( count( $errors ) ) {
2664
+		switch (count($errors)) {
2665 2665
 		case 0 :
2666 2666
 			$message = '';
2667 2667
 			break;
@@ -2669,43 +2669,43 @@  discard block
 block discarded – undo
2669 2669
 			$message = "<p>{$errors[0]}</p>";
2670 2670
 			break;
2671 2671
 		default :
2672
-			$message = "<ul>\n\t\t<li>" . join( "</li>\n\t\t<li>", $errors ) . "</li>\n\t</ul>";
2672
+			$message = "<ul>\n\t\t<li>".join("</li>\n\t\t<li>", $errors)."</li>\n\t</ul>";
2673 2673
 			break;
2674 2674
 		}
2675
-	} elseif ( is_string( $message ) ) {
2675
+	} elseif (is_string($message)) {
2676 2676
 		$message = "<p>$message</p>";
2677 2677
 	}
2678 2678
 
2679
-	if ( isset( $r['back_link'] ) && $r['back_link'] ) {
2680
-		$back_text = $have_gettext? __('&laquo; Back') : '&laquo; Back';
2679
+	if (isset($r['back_link']) && $r['back_link']) {
2680
+		$back_text = $have_gettext ? __('&laquo; Back') : '&laquo; Back';
2681 2681
 		$message .= "\n<p><a href='javascript:history.back()'>$back_text</a></p>";
2682 2682
 	}
2683 2683
 
2684
-	if ( ! did_action( 'admin_head' ) ) :
2685
-		if ( !headers_sent() ) {
2686
-			status_header( $r['response'] );
2684
+	if ( ! did_action('admin_head')) :
2685
+		if ( ! headers_sent()) {
2686
+			status_header($r['response']);
2687 2687
 			nocache_headers();
2688
-			header( 'Content-Type: text/html; charset=utf-8' );
2688
+			header('Content-Type: text/html; charset=utf-8');
2689 2689
 		}
2690 2690
 
2691
-		if ( empty($title) )
2691
+		if (empty($title))
2692 2692
 			$title = $have_gettext ? __('WordPress &rsaquo; Error') : 'WordPress &rsaquo; Error';
2693 2693
 
2694 2694
 		$text_direction = 'ltr';
2695
-		if ( isset($r['text_direction']) && 'rtl' == $r['text_direction'] )
2695
+		if (isset($r['text_direction']) && 'rtl' == $r['text_direction'])
2696 2696
 			$text_direction = 'rtl';
2697
-		elseif ( function_exists( 'is_rtl' ) && is_rtl() )
2697
+		elseif (function_exists('is_rtl') && is_rtl())
2698 2698
 			$text_direction = 'rtl';
2699 2699
 ?>
2700 2700
 <!DOCTYPE html>
2701 2701
 <!-- 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
2702 2702
 -->
2703
-<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'"; ?>>
2703
+<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'"; ?>>
2704 2704
 <head>
2705 2705
 	<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
2706 2706
 	<meta name="viewport" content="width=device-width">
2707 2707
 	<?php
2708
-	if ( function_exists( 'wp_no_robots' ) ) {
2708
+	if (function_exists('wp_no_robots')) {
2709 2709
 		wp_no_robots();
2710 2710
 	}
2711 2711
 	?>
@@ -2821,7 +2821,7 @@  discard block
 block discarded – undo
2821 2821
 		}
2822 2822
 
2823 2823
 		<?php
2824
-		if ( 'rtl' == $text_direction ) {
2824
+		if ('rtl' == $text_direction) {
2825 2825
 			echo 'body { font-family: Tahoma, Arial; }';
2826 2826
 		}
2827 2827
 		?>
@@ -2850,15 +2850,15 @@  discard block
 block discarded – undo
2850 2850
  * @param string       $title   Optional. Error title. Default empty.
2851 2851
  * @param string|array $args    Optional. Arguments to control behavior. Default empty array.
2852 2852
  */
2853
-function _xmlrpc_wp_die_handler( $message, $title = '', $args = array() ) {
2853
+function _xmlrpc_wp_die_handler($message, $title = '', $args = array()) {
2854 2854
 	global $wp_xmlrpc_server;
2855
-	$defaults = array( 'response' => 500 );
2855
+	$defaults = array('response' => 500);
2856 2856
 
2857 2857
 	$r = wp_parse_args($args, $defaults);
2858 2858
 
2859
-	if ( $wp_xmlrpc_server ) {
2860
-		$error = new IXR_Error( $r['response'] , $message);
2861
-		$wp_xmlrpc_server->output( $error->getXml() );
2859
+	if ($wp_xmlrpc_server) {
2860
+		$error = new IXR_Error($r['response'], $message);
2861
+		$wp_xmlrpc_server->output($error->getXml());
2862 2862
 	}
2863 2863
 	die();
2864 2864
 }
@@ -2875,19 +2875,19 @@  discard block
 block discarded – undo
2875 2875
  * @param string       $title   Optional. Error title (unused). Default empty.
2876 2876
  * @param string|array $args    Optional. Arguments to control behavior. Default empty array.
2877 2877
  */
2878
-function _ajax_wp_die_handler( $message, $title = '', $args = array() ) {
2878
+function _ajax_wp_die_handler($message, $title = '', $args = array()) {
2879 2879
 	$defaults = array(
2880 2880
 		'response' => 200,
2881 2881
 	);
2882
-	$r = wp_parse_args( $args, $defaults );
2882
+	$r = wp_parse_args($args, $defaults);
2883 2883
 
2884
-	if ( ! headers_sent() && null !== $r['response'] ) {
2885
-		status_header( $r['response'] );
2884
+	if ( ! headers_sent() && null !== $r['response']) {
2885
+		status_header($r['response']);
2886 2886
 	}
2887 2887
 
2888
-	if ( is_scalar( $message ) )
2889
-		die( (string) $message );
2890
-	die( '0' );
2888
+	if (is_scalar($message))
2889
+		die((string) $message);
2890
+	die('0');
2891 2891
 }
2892 2892
 
2893 2893
 /**
@@ -2900,9 +2900,9 @@  discard block
 block discarded – undo
2900 2900
  *
2901 2901
  * @param string $message Optional. Response to print. Default empty.
2902 2902
  */
2903
-function _scalar_wp_die_handler( $message = '' ) {
2904
-	if ( is_scalar( $message ) )
2905
-		die( (string) $message );
2903
+function _scalar_wp_die_handler($message = '') {
2904
+	if (is_scalar($message))
2905
+		die((string) $message);
2906 2906
 	die();
2907 2907
 }
2908 2908
 
@@ -2917,39 +2917,39 @@  discard block
 block discarded – undo
2917 2917
  *                       greater than 0. Default 512.
2918 2918
  * @return string|false The JSON encoded string, or false if it cannot be encoded.
2919 2919
  */
2920
-function wp_json_encode( $data, $options = 0, $depth = 512 ) {
2920
+function wp_json_encode($data, $options = 0, $depth = 512) {
2921 2921
 	/*
2922 2922
 	 * json_encode() has had extra params added over the years.
2923 2923
 	 * $options was added in 5.3, and $depth in 5.5.
2924 2924
 	 * We need to make sure we call it with the correct arguments.
2925 2925
 	 */
2926
-	if ( version_compare( PHP_VERSION, '5.5', '>=' ) ) {
2927
-		$args = array( $data, $options, $depth );
2928
-	} elseif ( version_compare( PHP_VERSION, '5.3', '>=' ) ) {
2929
-		$args = array( $data, $options );
2926
+	if (version_compare(PHP_VERSION, '5.5', '>=')) {
2927
+		$args = array($data, $options, $depth);
2928
+	} elseif (version_compare(PHP_VERSION, '5.3', '>=')) {
2929
+		$args = array($data, $options);
2930 2930
 	} else {
2931
-		$args = array( $data );
2931
+		$args = array($data);
2932 2932
 	}
2933 2933
 
2934 2934
 	// Prepare the data for JSON serialization.
2935
-	$args[0] = _wp_json_prepare_data( $data );
2935
+	$args[0] = _wp_json_prepare_data($data);
2936 2936
 
2937
-	$json = @call_user_func_array( 'json_encode', $args );
2937
+	$json = @call_user_func_array('json_encode', $args);
2938 2938
 
2939 2939
 	// If json_encode() was successful, no need to do more sanity checking.
2940 2940
 	// ... unless we're in an old version of PHP, and json_encode() returned
2941 2941
 	// a string containing 'null'. Then we need to do more sanity checking.
2942
-	if ( false !== $json && ( version_compare( PHP_VERSION, '5.5', '>=' ) || false === strpos( $json, 'null' ) ) )  {
2942
+	if (false !== $json && (version_compare(PHP_VERSION, '5.5', '>=') || false === strpos($json, 'null'))) {
2943 2943
 		return $json;
2944 2944
 	}
2945 2945
 
2946 2946
 	try {
2947
-		$args[0] = _wp_json_sanity_check( $data, $depth );
2948
-	} catch ( Exception $e ) {
2947
+		$args[0] = _wp_json_sanity_check($data, $depth);
2948
+	} catch (Exception $e) {
2949 2949
 		return false;
2950 2950
 	}
2951 2951
 
2952
-	return call_user_func_array( 'json_encode', $args );
2952
+	return call_user_func_array('json_encode', $args);
2953 2953
 }
2954 2954
 
2955 2955
 /**
@@ -2965,49 +2965,49 @@  discard block
 block discarded – undo
2965 2965
  * @param int   $depth Maximum depth to walk through $data. Must be greater than 0.
2966 2966
  * @return mixed The sanitized data that shall be encoded to JSON.
2967 2967
  */
2968
-function _wp_json_sanity_check( $data, $depth ) {
2969
-	if ( $depth < 0 ) {
2970
-		throw new Exception( 'Reached depth limit' );
2968
+function _wp_json_sanity_check($data, $depth) {
2969
+	if ($depth < 0) {
2970
+		throw new Exception('Reached depth limit');
2971 2971
 	}
2972 2972
 
2973
-	if ( is_array( $data ) ) {
2973
+	if (is_array($data)) {
2974 2974
 		$output = array();
2975
-		foreach ( $data as $id => $el ) {
2975
+		foreach ($data as $id => $el) {
2976 2976
 			// Don't forget to sanitize the ID!
2977
-			if ( is_string( $id ) ) {
2978
-				$clean_id = _wp_json_convert_string( $id );
2977
+			if (is_string($id)) {
2978
+				$clean_id = _wp_json_convert_string($id);
2979 2979
 			} else {
2980 2980
 				$clean_id = $id;
2981 2981
 			}
2982 2982
 
2983 2983
 			// Check the element type, so that we're only recursing if we really have to.
2984
-			if ( is_array( $el ) || is_object( $el ) ) {
2985
-				$output[ $clean_id ] = _wp_json_sanity_check( $el, $depth - 1 );
2986
-			} elseif ( is_string( $el ) ) {
2987
-				$output[ $clean_id ] = _wp_json_convert_string( $el );
2984
+			if (is_array($el) || is_object($el)) {
2985
+				$output[$clean_id] = _wp_json_sanity_check($el, $depth - 1);
2986
+			} elseif (is_string($el)) {
2987
+				$output[$clean_id] = _wp_json_convert_string($el);
2988 2988
 			} else {
2989
-				$output[ $clean_id ] = $el;
2989
+				$output[$clean_id] = $el;
2990 2990
 			}
2991 2991
 		}
2992
-	} elseif ( is_object( $data ) ) {
2992
+	} elseif (is_object($data)) {
2993 2993
 		$output = new stdClass;
2994
-		foreach ( $data as $id => $el ) {
2995
-			if ( is_string( $id ) ) {
2996
-				$clean_id = _wp_json_convert_string( $id );
2994
+		foreach ($data as $id => $el) {
2995
+			if (is_string($id)) {
2996
+				$clean_id = _wp_json_convert_string($id);
2997 2997
 			} else {
2998 2998
 				$clean_id = $id;
2999 2999
 			}
3000 3000
 
3001
-			if ( is_array( $el ) || is_object( $el ) ) {
3002
-				$output->$clean_id = _wp_json_sanity_check( $el, $depth - 1 );
3003
-			} elseif ( is_string( $el ) ) {
3004
-				$output->$clean_id = _wp_json_convert_string( $el );
3001
+			if (is_array($el) || is_object($el)) {
3002
+				$output->$clean_id = _wp_json_sanity_check($el, $depth - 1);
3003
+			} elseif (is_string($el)) {
3004
+				$output->$clean_id = _wp_json_convert_string($el);
3005 3005
 			} else {
3006 3006
 				$output->$clean_id = $el;
3007 3007
 			}
3008 3008
 		}
3009
-	} elseif ( is_string( $data ) ) {
3010
-		return _wp_json_convert_string( $data );
3009
+	} elseif (is_string($data)) {
3010
+		return _wp_json_convert_string($data);
3011 3011
 	} else {
3012 3012
 		return $data;
3013 3013
 	}
@@ -3029,21 +3029,21 @@  discard block
 block discarded – undo
3029 3029
  * @param string $string The string which is to be converted.
3030 3030
  * @return string The checked string.
3031 3031
  */
3032
-function _wp_json_convert_string( $string ) {
3032
+function _wp_json_convert_string($string) {
3033 3033
 	static $use_mb = null;
3034
-	if ( is_null( $use_mb ) ) {
3035
-		$use_mb = function_exists( 'mb_convert_encoding' );
3034
+	if (is_null($use_mb)) {
3035
+		$use_mb = function_exists('mb_convert_encoding');
3036 3036
 	}
3037 3037
 
3038
-	if ( $use_mb ) {
3039
-		$encoding = mb_detect_encoding( $string, mb_detect_order(), true );
3040
-		if ( $encoding ) {
3041
-			return mb_convert_encoding( $string, 'UTF-8', $encoding );
3038
+	if ($use_mb) {
3039
+		$encoding = mb_detect_encoding($string, mb_detect_order(), true);
3040
+		if ($encoding) {
3041
+			return mb_convert_encoding($string, 'UTF-8', $encoding);
3042 3042
 		} else {
3043
-			return mb_convert_encoding( $string, 'UTF-8', 'UTF-8' );
3043
+			return mb_convert_encoding($string, 'UTF-8', 'UTF-8');
3044 3044
 		}
3045 3045
 	} else {
3046
-		return wp_check_invalid_utf8( $string, true );
3046
+		return wp_check_invalid_utf8($string, true);
3047 3047
 	}
3048 3048
 }
3049 3049
 
@@ -3059,12 +3059,12 @@  discard block
 block discarded – undo
3059 3059
  * @param mixed $data Native representation.
3060 3060
  * @return bool|int|float|null|string|array Data ready for `json_encode()`.
3061 3061
  */
3062
-function _wp_json_prepare_data( $data ) {
3063
-	if ( ! defined( 'WP_JSON_SERIALIZE_COMPATIBLE' ) || WP_JSON_SERIALIZE_COMPATIBLE === false ) {
3062
+function _wp_json_prepare_data($data) {
3063
+	if ( ! defined('WP_JSON_SERIALIZE_COMPATIBLE') || WP_JSON_SERIALIZE_COMPATIBLE === false) {
3064 3064
 		return $data;
3065 3065
 	}
3066 3066
 
3067
-	switch ( gettype( $data ) ) {
3067
+	switch (gettype($data)) {
3068 3068
 		case 'boolean':
3069 3069
 		case 'integer':
3070 3070
 		case 'double':
@@ -3075,22 +3075,22 @@  discard block
 block discarded – undo
3075 3075
 
3076 3076
 		case 'array':
3077 3077
 			// Arrays must be mapped in case they also return objects.
3078
-			return array_map( '_wp_json_prepare_data', $data );
3078
+			return array_map('_wp_json_prepare_data', $data);
3079 3079
 
3080 3080
 		case 'object':
3081 3081
 			// If this is an incomplete object (__PHP_Incomplete_Class), bail.
3082
-			if ( ! is_object( $data ) ) {
3082
+			if ( ! is_object($data)) {
3083 3083
 				return null;
3084 3084
 			}
3085 3085
 
3086
-			if ( $data instanceof JsonSerializable ) {
3086
+			if ($data instanceof JsonSerializable) {
3087 3087
 				$data = $data->jsonSerialize();
3088 3088
 			} else {
3089
-				$data = get_object_vars( $data );
3089
+				$data = get_object_vars($data);
3090 3090
 			}
3091 3091
 
3092 3092
 			// Now, pass the array (or whatever was returned from jsonSerialize through).
3093
-			return _wp_json_prepare_data( $data );
3093
+			return _wp_json_prepare_data($data);
3094 3094
 
3095 3095
 		default:
3096 3096
 			return null;
@@ -3107,17 +3107,17 @@  discard block
 block discarded – undo
3107 3107
  *                           then print and die.
3108 3108
  * @param int   $status_code The HTTP status code to output.
3109 3109
  */
3110
-function wp_send_json( $response, $status_code = null ) {
3111
-	@header( 'Content-Type: application/json; charset=' . get_option( 'blog_charset' ) );
3112
-	if ( null !== $status_code ) {
3113
-		status_header( $status_code );
3110
+function wp_send_json($response, $status_code = null) {
3111
+	@header('Content-Type: application/json; charset='.get_option('blog_charset'));
3112
+	if (null !== $status_code) {
3113
+		status_header($status_code);
3114 3114
 	}
3115
-	echo wp_json_encode( $response );
3115
+	echo wp_json_encode($response);
3116 3116
 
3117
-	if ( wp_doing_ajax() ) {
3118
-		wp_die( '', '', array(
3117
+	if (wp_doing_ajax()) {
3118
+		wp_die('', '', array(
3119 3119
 			'response' => null,
3120
-		) );
3120
+		));
3121 3121
 	} else {
3122 3122
 		die;
3123 3123
 	}
@@ -3132,13 +3132,13 @@  discard block
 block discarded – undo
3132 3132
  * @param mixed $data        Data to encode as JSON, then print and die.
3133 3133
  * @param int   $status_code The HTTP status code to output.
3134 3134
  */
3135
-function wp_send_json_success( $data = null, $status_code = null ) {
3136
-	$response = array( 'success' => true );
3135
+function wp_send_json_success($data = null, $status_code = null) {
3136
+	$response = array('success' => true);
3137 3137
 
3138
-	if ( isset( $data ) )
3138
+	if (isset($data))
3139 3139
 		$response['data'] = $data;
3140 3140
 
3141
-	wp_send_json( $response, $status_code );
3141
+	wp_send_json($response, $status_code);
3142 3142
 }
3143 3143
 
3144 3144
 /**
@@ -3156,15 +3156,15 @@  discard block
 block discarded – undo
3156 3156
  * @param mixed $data        Data to encode as JSON, then print and die.
3157 3157
  * @param int   $status_code The HTTP status code to output.
3158 3158
  */
3159
-function wp_send_json_error( $data = null, $status_code = null ) {
3160
-	$response = array( 'success' => false );
3159
+function wp_send_json_error($data = null, $status_code = null) {
3160
+	$response = array('success' => false);
3161 3161
 
3162
-	if ( isset( $data ) ) {
3163
-		if ( is_wp_error( $data ) ) {
3162
+	if (isset($data)) {
3163
+		if (is_wp_error($data)) {
3164 3164
 			$result = array();
3165
-			foreach ( $data->errors as $code => $messages ) {
3166
-				foreach ( $messages as $message ) {
3167
-					$result[] = array( 'code' => $code, 'message' => $message );
3165
+			foreach ($data->errors as $code => $messages) {
3166
+				foreach ($messages as $message) {
3167
+					$result[] = array('code' => $code, 'message' => $message);
3168 3168
 				}
3169 3169
 			}
3170 3170
 
@@ -3174,7 +3174,7 @@  discard block
 block discarded – undo
3174 3174
 		}
3175 3175
 	}
3176 3176
 
3177
-	wp_send_json( $response, $status_code );
3177
+	wp_send_json($response, $status_code);
3178 3178
 }
3179 3179
 
3180 3180
 /**
@@ -3189,12 +3189,12 @@  discard block
 block discarded – undo
3189 3189
  * @param string $callback Supplied JSONP callback function.
3190 3190
  * @return bool True if valid callback, otherwise false.
3191 3191
  */
3192
-function wp_check_jsonp_callback( $callback ) {
3193
-	if ( ! is_string( $callback ) ) {
3192
+function wp_check_jsonp_callback($callback) {
3193
+	if ( ! is_string($callback)) {
3194 3194
 		return false;
3195 3195
 	}
3196 3196
 
3197
-	preg_replace( '/[^\w\.]/', '', $callback, -1, $illegal_char_count );
3197
+	preg_replace('/[^\w\.]/', '', $callback, -1, $illegal_char_count);
3198 3198
 
3199 3199
 	return 0 === $illegal_char_count;
3200 3200
 }
@@ -3214,9 +3214,9 @@  discard block
 block discarded – undo
3214 3214
  * @param string $url URL for the home location.
3215 3215
  * @return string Homepage location.
3216 3216
  */
3217
-function _config_wp_home( $url = '' ) {
3218
-	if ( defined( 'WP_HOME' ) )
3219
-		return untrailingslashit( WP_HOME );
3217
+function _config_wp_home($url = '') {
3218
+	if (defined('WP_HOME'))
3219
+		return untrailingslashit(WP_HOME);
3220 3220
 	return $url;
3221 3221
 }
3222 3222
 
@@ -3235,9 +3235,9 @@  discard block
 block discarded – undo
3235 3235
  * @param string $url URL to set the WordPress site location.
3236 3236
  * @return string The WordPress Site URL.
3237 3237
  */
3238
-function _config_wp_siteurl( $url = '' ) {
3239
-	if ( defined( 'WP_SITEURL' ) )
3240
-		return untrailingslashit( WP_SITEURL );
3238
+function _config_wp_siteurl($url = '') {
3239
+	if (defined('WP_SITEURL'))
3240
+		return untrailingslashit(WP_SITEURL);
3241 3241
 	return $url;
3242 3242
 }
3243 3243
 
@@ -3248,7 +3248,7 @@  discard block
 block discarded – undo
3248 3248
  * @access private
3249 3249
  */
3250 3250
 function _delete_option_fresh_site() {
3251
-	update_option( 'fresh_site', 0 );
3251
+	update_option('fresh_site', 0);
3252 3252
 }
3253 3253
 
3254 3254
 /**
@@ -3268,16 +3268,16 @@  discard block
 block discarded – undo
3268 3268
  * @param array $mce_init MCE settings array.
3269 3269
  * @return array Direction set for 'rtl', if needed by locale.
3270 3270
  */
3271
-function _mce_set_direction( $mce_init ) {
3272
-	if ( is_rtl() ) {
3271
+function _mce_set_direction($mce_init) {
3272
+	if (is_rtl()) {
3273 3273
 		$mce_init['directionality'] = 'rtl';
3274 3274
 		$mce_init['rtl_ui'] = true;
3275 3275
 
3276
-		if ( ! empty( $mce_init['plugins'] ) && strpos( $mce_init['plugins'], 'directionality' ) === false ) {
3276
+		if ( ! empty($mce_init['plugins']) && strpos($mce_init['plugins'], 'directionality') === false) {
3277 3277
 			$mce_init['plugins'] .= ',directionality';
3278 3278
 		}
3279 3279
 
3280
-		if ( ! empty( $mce_init['toolbar1'] ) && ! preg_match( '/\bltr\b/', $mce_init['toolbar1'] ) ) {
3280
+		if ( ! empty($mce_init['toolbar1']) && ! preg_match('/\bltr\b/', $mce_init['toolbar1'])) {
3281 3281
 			$mce_init['toolbar1'] .= ',ltr';
3282 3282
 		}
3283 3283
 	}
@@ -3312,10 +3312,10 @@  discard block
 block discarded – undo
3312 3312
 	global $wpsmiliestrans, $wp_smiliessearch;
3313 3313
 
3314 3314
 	// don't bother setting up smilies if they are disabled
3315
-	if ( !get_option( 'use_smilies' ) )
3315
+	if ( ! get_option('use_smilies'))
3316 3316
 		return;
3317 3317
 
3318
-	if ( !isset( $wpsmiliestrans ) ) {
3318
+	if ( ! isset($wpsmiliestrans)) {
3319 3319
 		$wpsmiliestrans = array(
3320 3320
 		':mrgreen:' => 'mrgreen.png',
3321 3321
 		':neutral:' => "\xf0\x9f\x98\x90",
@@ -3391,28 +3391,28 @@  discard block
 block discarded – undo
3391 3391
 	$spaces = wp_spaces_regexp();
3392 3392
 
3393 3393
 	// Begin first "subpattern"
3394
-	$wp_smiliessearch = '/(?<=' . $spaces . '|^)';
3394
+	$wp_smiliessearch = '/(?<='.$spaces.'|^)';
3395 3395
 
3396 3396
 	$subchar = '';
3397
-	foreach ( (array) $wpsmiliestrans as $smiley => $img ) {
3397
+	foreach ((array) $wpsmiliestrans as $smiley => $img) {
3398 3398
 		$firstchar = substr($smiley, 0, 1);
3399 3399
 		$rest = substr($smiley, 1);
3400 3400
 
3401 3401
 		// new subpattern?
3402 3402
 		if ($firstchar != $subchar) {
3403 3403
 			if ($subchar != '') {
3404
-				$wp_smiliessearch .= ')(?=' . $spaces . '|$)';  // End previous "subpattern"
3405
-				$wp_smiliessearch .= '|(?<=' . $spaces . '|^)'; // Begin another "subpattern"
3404
+				$wp_smiliessearch .= ')(?='.$spaces.'|$)'; // End previous "subpattern"
3405
+				$wp_smiliessearch .= '|(?<='.$spaces.'|^)'; // Begin another "subpattern"
3406 3406
 			}
3407 3407
 			$subchar = $firstchar;
3408
-			$wp_smiliessearch .= preg_quote($firstchar, '/') . '(?:';
3408
+			$wp_smiliessearch .= preg_quote($firstchar, '/').'(?:';
3409 3409
 		} else {
3410 3410
 			$wp_smiliessearch .= '|';
3411 3411
 		}
3412 3412
 		$wp_smiliessearch .= preg_quote($rest, '/');
3413 3413
 	}
3414 3414
 
3415
-	$wp_smiliessearch .= ')(?=' . $spaces . '|$)/m';
3415
+	$wp_smiliessearch .= ')(?='.$spaces.'|$)/m';
3416 3416
 
3417 3417
 }
3418 3418
 
@@ -3429,16 +3429,16 @@  discard block
 block discarded – undo
3429 3429
  * @param array               $defaults Optional. Array that serves as the defaults. Default empty.
3430 3430
  * @return array Merged user defined values with defaults.
3431 3431
  */
3432
-function wp_parse_args( $args, $defaults = '' ) {
3433
-	if ( is_object( $args ) )
3434
-		$r = get_object_vars( $args );
3435
-	elseif ( is_array( $args ) )
3436
-		$r =& $args;
3432
+function wp_parse_args($args, $defaults = '') {
3433
+	if (is_object($args))
3434
+		$r = get_object_vars($args);
3435
+	elseif (is_array($args))
3436
+		$r = & $args;
3437 3437
 	else
3438
-		wp_parse_str( $args, $r );
3438
+		wp_parse_str($args, $r);
3439 3439
 
3440
-	if ( is_array( $defaults ) )
3441
-		return array_merge( $defaults, $r );
3440
+	if (is_array($defaults))
3441
+		return array_merge($defaults, $r);
3442 3442
 	return $r;
3443 3443
 }
3444 3444
 
@@ -3450,8 +3450,8 @@  discard block
 block discarded – undo
3450 3450
  * @param array|string $list List of ids.
3451 3451
  * @return array Sanitized array of IDs.
3452 3452
  */
3453
-function wp_parse_id_list( $list ) {
3454
-	if ( !is_array($list) )
3453
+function wp_parse_id_list($list) {
3454
+	if ( ! is_array($list))
3455 3455
 		$list = preg_split('/[\s,]+/', $list);
3456 3456
 
3457 3457
 	return array_unique(array_map('absint', $list));
@@ -3465,16 +3465,16 @@  discard block
 block discarded – undo
3465 3465
  * @param  array|string $list List of slugs.
3466 3466
  * @return array Sanitized array of slugs.
3467 3467
  */
3468
-function wp_parse_slug_list( $list ) {
3469
-	if ( ! is_array( $list ) ) {
3470
-		$list = preg_split( '/[\s,]+/', $list );
3468
+function wp_parse_slug_list($list) {
3469
+	if ( ! is_array($list)) {
3470
+		$list = preg_split('/[\s,]+/', $list);
3471 3471
 	}
3472 3472
 
3473
-	foreach ( $list as $key => $value ) {
3474
-		$list[ $key ] = sanitize_title( $value );
3473
+	foreach ($list as $key => $value) {
3474
+		$list[$key] = sanitize_title($value);
3475 3475
 	}
3476 3476
 
3477
-	return array_unique( $list );
3477
+	return array_unique($list);
3478 3478
 }
3479 3479
 
3480 3480
 /**
@@ -3486,11 +3486,11 @@  discard block
 block discarded – undo
3486 3486
  * @param array $keys  The list of keys.
3487 3487
  * @return array The array slice.
3488 3488
  */
3489
-function wp_array_slice_assoc( $array, $keys ) {
3489
+function wp_array_slice_assoc($array, $keys) {
3490 3490
 	$slice = array();
3491
-	foreach ( $keys as $key )
3492
-		if ( isset( $array[ $key ] ) )
3493
-			$slice[ $key ] = $array[ $key ];
3491
+	foreach ($keys as $key)
3492
+		if (isset($array[$key]))
3493
+			$slice[$key] = $array[$key];
3494 3494
 
3495 3495
 	return $slice;
3496 3496
 }
@@ -3503,14 +3503,14 @@  discard block
 block discarded – undo
3503 3503
  * @param mixed $data Variable to check.
3504 3504
  * @return bool Whether the variable is a list.
3505 3505
  */
3506
-function wp_is_numeric_array( $data ) {
3507
-	if ( ! is_array( $data ) ) {
3506
+function wp_is_numeric_array($data) {
3507
+	if ( ! is_array($data)) {
3508 3508
 		return false;
3509 3509
 	}
3510 3510
 
3511
-	$keys = array_keys( $data );
3512
-	$string_keys = array_filter( $keys, 'is_string' );
3513
-	return count( $string_keys ) === 0;
3511
+	$keys = array_keys($data);
3512
+	$string_keys = array_filter($keys, 'is_string');
3513
+	return count($string_keys) === 0;
3514 3514
 }
3515 3515
 
3516 3516
 /**
@@ -3530,17 +3530,17 @@  discard block
 block discarded – undo
3530 3530
  *                              Default false.
3531 3531
  * @return array A list of objects or object fields.
3532 3532
  */
3533
-function wp_filter_object_list( $list, $args = array(), $operator = 'and', $field = false ) {
3534
-	if ( ! is_array( $list ) ) {
3533
+function wp_filter_object_list($list, $args = array(), $operator = 'and', $field = false) {
3534
+	if ( ! is_array($list)) {
3535 3535
 		return array();
3536 3536
 	}
3537 3537
 
3538
-	$util = new WP_List_Util( $list );
3538
+	$util = new WP_List_Util($list);
3539 3539
 
3540
-	$util->filter( $args, $operator );
3540
+	$util->filter($args, $operator);
3541 3541
 
3542
-	if ( $field ) {
3543
-		$util->pluck( $field );
3542
+	if ($field) {
3543
+		$util->pluck($field);
3544 3544
 	}
3545 3545
 
3546 3546
 	return $util->get_output();
@@ -3561,13 +3561,13 @@  discard block
 block discarded – undo
3561 3561
  *                         match. Default 'AND'.
3562 3562
  * @return array Array of found values.
3563 3563
  */
3564
-function wp_list_filter( $list, $args = array(), $operator = 'AND' ) {
3565
-	if ( ! is_array( $list ) ) {
3564
+function wp_list_filter($list, $args = array(), $operator = 'AND') {
3565
+	if ( ! is_array($list)) {
3566 3566
 		return array();
3567 3567
 	}
3568 3568
 
3569
-	$util = new WP_List_Util( $list );
3570
-	return $util->filter( $args, $operator );
3569
+	$util = new WP_List_Util($list);
3570
+	return $util->filter($args, $operator);
3571 3571
 }
3572 3572
 
3573 3573
 /**
@@ -3588,9 +3588,9 @@  discard block
 block discarded – undo
3588 3588
  *               corresponding to `$index_key`. If `$index_key` is null, array keys from the original
3589 3589
  *               `$list` will be preserved in the results.
3590 3590
  */
3591
-function wp_list_pluck( $list, $field, $index_key = null ) {
3592
-	$util = new WP_List_Util( $list );
3593
-	return $util->pluck( $field, $index_key );
3591
+function wp_list_pluck($list, $field, $index_key = null) {
3592
+	$util = new WP_List_Util($list);
3593
+	return $util->pluck($field, $index_key);
3594 3594
 }
3595 3595
 
3596 3596
 /**
@@ -3606,13 +3606,13 @@  discard block
 block discarded – undo
3606 3606
  * @param bool         $preserve_keys Optional. Whether to preserve keys. Default false.
3607 3607
  * @return array The sorted array.
3608 3608
  */
3609
-function wp_list_sort( $list, $orderby = array(), $order = 'ASC', $preserve_keys = false ) {
3610
-	if ( ! is_array( $list ) ) {
3609
+function wp_list_sort($list, $orderby = array(), $order = 'ASC', $preserve_keys = false) {
3610
+	if ( ! is_array($list)) {
3611 3611
 		return array();
3612 3612
 	}
3613 3613
 
3614
-	$util = new WP_List_Util( $list );
3615
-	return $util->sort( $orderby, $order, $preserve_keys );
3614
+	$util = new WP_List_Util($list);
3615
+	return $util->sort($orderby, $order, $preserve_keys);
3616 3616
 }
3617 3617
 
3618 3618
 /**
@@ -3635,13 +3635,13 @@  discard block
 block discarded – undo
3635 3635
 	 * @param bool $wp_maybe_load_widgets Whether to load the Widgets library.
3636 3636
 	 *                                    Default true.
3637 3637
 	 */
3638
-	if ( ! apply_filters( 'load_default_widgets', true ) ) {
3638
+	if ( ! apply_filters('load_default_widgets', true)) {
3639 3639
 		return;
3640 3640
 	}
3641 3641
 
3642
-	require_once( ABSPATH . WPINC . '/default-widgets.php' );
3642
+	require_once(ABSPATH.WPINC.'/default-widgets.php');
3643 3643
 
3644
-	add_action( '_admin_menu', 'wp_widgets_add_menu' );
3644
+	add_action('_admin_menu', 'wp_widgets_add_menu');
3645 3645
 }
3646 3646
 
3647 3647
 /**
@@ -3654,11 +3654,11 @@  discard block
 block discarded – undo
3654 3654
 function wp_widgets_add_menu() {
3655 3655
 	global $submenu;
3656 3656
 
3657
-	if ( ! current_theme_supports( 'widgets' ) )
3657
+	if ( ! current_theme_supports('widgets'))
3658 3658
 		return;
3659 3659
 
3660
-	$submenu['themes.php'][7] = array( __( 'Widgets' ), 'edit_theme_options', 'widgets.php' );
3661
-	ksort( $submenu['themes.php'], SORT_NUMERIC );
3660
+	$submenu['themes.php'][7] = array(__('Widgets'), 'edit_theme_options', 'widgets.php');
3661
+	ksort($submenu['themes.php'], SORT_NUMERIC);
3662 3662
 }
3663 3663
 
3664 3664
 /**
@@ -3670,7 +3670,7 @@  discard block
 block discarded – undo
3670 3670
  */
3671 3671
 function wp_ob_end_flush_all() {
3672 3672
 	$levels = ob_get_level();
3673
-	for ($i=0; $i<$levels; $i++)
3673
+	for ($i = 0; $i < $levels; $i++)
3674 3674
 		ob_end_flush();
3675 3675
 }
3676 3676
 
@@ -3698,29 +3698,29 @@  discard block
 block discarded – undo
3698 3698
 	wp_load_translations_early();
3699 3699
 
3700 3700
 	// Load custom DB error template, if present.
3701
-	if ( file_exists( WP_CONTENT_DIR . '/db-error.php' ) ) {
3702
-		require_once( WP_CONTENT_DIR . '/db-error.php' );
3701
+	if (file_exists(WP_CONTENT_DIR.'/db-error.php')) {
3702
+		require_once(WP_CONTENT_DIR.'/db-error.php');
3703 3703
 		die();
3704 3704
 	}
3705 3705
 
3706 3706
 	// If installing or in the admin, provide the verbose message.
3707
-	if ( wp_installing() || defined( 'WP_ADMIN' ) )
3707
+	if (wp_installing() || defined('WP_ADMIN'))
3708 3708
 		wp_die($wpdb->error);
3709 3709
 
3710 3710
 	// Otherwise, be terse.
3711
-	status_header( 500 );
3711
+	status_header(500);
3712 3712
 	nocache_headers();
3713
-	header( 'Content-Type: text/html; charset=utf-8' );
3713
+	header('Content-Type: text/html; charset=utf-8');
3714 3714
 ?>
3715 3715
 <!DOCTYPE html>
3716
-<html xmlns="http://www.w3.org/1999/xhtml"<?php if ( is_rtl() ) echo ' dir="rtl"'; ?>>
3716
+<html xmlns="http://www.w3.org/1999/xhtml"<?php if (is_rtl()) echo ' dir="rtl"'; ?>>
3717 3717
 <head>
3718 3718
 <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
3719
-	<title><?php _e( 'Database Error' ); ?></title>
3719
+	<title><?php _e('Database Error'); ?></title>
3720 3720
 
3721 3721
 </head>
3722 3722
 <body>
3723
-	<h1><?php _e( 'Error establishing a database connection' ); ?></h1>
3723
+	<h1><?php _e('Error establishing a database connection'); ?></h1>
3724 3724
 </body>
3725 3725
 </html>
3726 3726
 <?php
@@ -3735,8 +3735,8 @@  discard block
 block discarded – undo
3735 3735
  * @param mixed $maybeint Data you wish to have converted to a non-negative integer.
3736 3736
  * @return int A non-negative integer.
3737 3737
  */
3738
-function absint( $maybeint ) {
3739
-	return abs( intval( $maybeint ) );
3738
+function absint($maybeint) {
3739
+	return abs(intval($maybeint));
3740 3740
 }
3741 3741
 
3742 3742
 /**
@@ -3757,7 +3757,7 @@  discard block
 block discarded – undo
3757 3757
  * @param string $version     The version of WordPress that deprecated the function.
3758 3758
  * @param string $replacement Optional. The function that should have been called. Default null.
3759 3759
  */
3760
-function _deprecated_function( $function, $version, $replacement = null ) {
3760
+function _deprecated_function($function, $version, $replacement = null) {
3761 3761
 
3762 3762
 	/**
3763 3763
 	 * Fires when a deprecated function is called.
@@ -3768,7 +3768,7 @@  discard block
 block discarded – undo
3768 3768
 	 * @param string $replacement The function that should have been called.
3769 3769
 	 * @param string $version     The version of WordPress that deprecated the function.
3770 3770
 	 */
3771
-	do_action( 'deprecated_function_run', $function, $replacement, $version );
3771
+	do_action('deprecated_function_run', $function, $replacement, $version);
3772 3772
 
3773 3773
 	/**
3774 3774
 	 * Filters whether to trigger an error for deprecated functions.
@@ -3777,20 +3777,20 @@  discard block
 block discarded – undo
3777 3777
 	 *
3778 3778
 	 * @param bool $trigger Whether to trigger the error for deprecated functions. Default true.
3779 3779
 	 */
3780
-	if ( WP_DEBUG && apply_filters( 'deprecated_function_trigger_error', true ) ) {
3781
-		if ( function_exists( '__' ) ) {
3782
-			if ( ! is_null( $replacement ) ) {
3780
+	if (WP_DEBUG && apply_filters('deprecated_function_trigger_error', true)) {
3781
+		if (function_exists('__')) {
3782
+			if ( ! is_null($replacement)) {
3783 3783
 				/* translators: 1: PHP function name, 2: version number, 3: alternative function name */
3784
-				trigger_error( sprintf( __('%1$s is <strong>deprecated</strong> since version %2$s! Use %3$s instead.'), $function, $version, $replacement ) );
3784
+				trigger_error(sprintf(__('%1$s is <strong>deprecated</strong> since version %2$s! Use %3$s instead.'), $function, $version, $replacement));
3785 3785
 			} else {
3786 3786
 				/* translators: 1: PHP function name, 2: version number */
3787
-				trigger_error( sprintf( __('%1$s is <strong>deprecated</strong> since version %2$s with no alternative available.'), $function, $version ) );
3787
+				trigger_error(sprintf(__('%1$s is <strong>deprecated</strong> since version %2$s with no alternative available.'), $function, $version));
3788 3788
 			}
3789 3789
 		} else {
3790
-			if ( ! is_null( $replacement ) ) {
3791
-				trigger_error( sprintf( '%1$s is <strong>deprecated</strong> since version %2$s! Use %3$s instead.', $function, $version, $replacement ) );
3790
+			if ( ! is_null($replacement)) {
3791
+				trigger_error(sprintf('%1$s is <strong>deprecated</strong> since version %2$s! Use %3$s instead.', $function, $version, $replacement));
3792 3792
 			} else {
3793
-				trigger_error( sprintf( '%1$s is <strong>deprecated</strong> since version %2$s with no alternative available.', $function, $version ) );
3793
+				trigger_error(sprintf('%1$s is <strong>deprecated</strong> since version %2$s with no alternative available.', $function, $version));
3794 3794
 			}
3795 3795
 		}
3796 3796
 	}
@@ -3816,7 +3816,7 @@  discard block
 block discarded – undo
3816 3816
  * @param string $parent_class Optional. The parent class calling the deprecated constructor.
3817 3817
  *                             Default empty string.
3818 3818
  */
3819
-function _deprecated_constructor( $class, $version, $parent_class = '' ) {
3819
+function _deprecated_constructor($class, $version, $parent_class = '') {
3820 3820
 
3821 3821
 	/**
3822 3822
 	 * Fires when a deprecated constructor is called.
@@ -3828,7 +3828,7 @@  discard block
 block discarded – undo
3828 3828
 	 * @param string $version      The version of WordPress that deprecated the function.
3829 3829
 	 * @param string $parent_class The parent class calling the deprecated constructor.
3830 3830
 	 */
3831
-	do_action( 'deprecated_constructor_run', $class, $version, $parent_class );
3831
+	do_action('deprecated_constructor_run', $class, $version, $parent_class);
3832 3832
 
3833 3833
 	/**
3834 3834
 	 * Filters whether to trigger an error for deprecated functions.
@@ -3839,24 +3839,24 @@  discard block
 block discarded – undo
3839 3839
 	 *
3840 3840
 	 * @param bool $trigger Whether to trigger the error for deprecated functions. Default true.
3841 3841
 	 */
3842
-	if ( WP_DEBUG && apply_filters( 'deprecated_constructor_trigger_error', true ) ) {
3843
-		if ( function_exists( '__' ) ) {
3844
-			if ( ! empty( $parent_class ) ) {
3842
+	if (WP_DEBUG && apply_filters('deprecated_constructor_trigger_error', true)) {
3843
+		if (function_exists('__')) {
3844
+			if ( ! empty($parent_class)) {
3845 3845
 				/* translators: 1: PHP class name, 2: PHP parent class name, 3: version number, 4: __construct() method */
3846
-				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.' ),
3847
-					$class, $parent_class, $version, '<pre>__construct()</pre>' ) );
3846
+				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.'),
3847
+					$class, $parent_class, $version, '<pre>__construct()</pre>'));
3848 3848
 			} else {
3849 3849
 				/* translators: 1: PHP class name, 2: version number, 3: __construct() method */
3850
-				trigger_error( sprintf( __( 'The called constructor method for %1$s is <strong>deprecated</strong> since version %2$s! Use %3$s instead.' ),
3851
-					$class, $version, '<pre>__construct()</pre>' ) );
3850
+				trigger_error(sprintf(__('The called constructor method for %1$s is <strong>deprecated</strong> since version %2$s! Use %3$s instead.'),
3851
+					$class, $version, '<pre>__construct()</pre>'));
3852 3852
 			}
3853 3853
 		} else {
3854
-			if ( ! empty( $parent_class ) ) {
3855
-				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.',
3856
-					$class, $parent_class, $version, '<pre>__construct()</pre>' ) );
3854
+			if ( ! empty($parent_class)) {
3855
+				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.',
3856
+					$class, $parent_class, $version, '<pre>__construct()</pre>'));
3857 3857
 			} else {
3858
-				trigger_error( sprintf( 'The called constructor method for %1$s is <strong>deprecated</strong> since version %2$s! Use %3$s instead.',
3859
-					$class, $version, '<pre>__construct()</pre>' ) );
3858
+				trigger_error(sprintf('The called constructor method for %1$s is <strong>deprecated</strong> since version %2$s! Use %3$s instead.',
3859
+					$class, $version, '<pre>__construct()</pre>'));
3860 3860
 			}
3861 3861
 		}
3862 3862
 	}
@@ -3883,7 +3883,7 @@  discard block
 block discarded – undo
3883 3883
  *                            Default null.
3884 3884
  * @param string $message     Optional. A message regarding the change. Default empty.
3885 3885
  */
3886
-function _deprecated_file( $file, $version, $replacement = null, $message = '' ) {
3886
+function _deprecated_file($file, $version, $replacement = null, $message = '') {
3887 3887
 
3888 3888
 	/**
3889 3889
 	 * Fires when a deprecated file is called.
@@ -3895,7 +3895,7 @@  discard block
 block discarded – undo
3895 3895
 	 * @param string $version     The version of WordPress that deprecated the file.
3896 3896
 	 * @param string $message     A message regarding the change.
3897 3897
 	 */
3898
-	do_action( 'deprecated_file_included', $file, $replacement, $version, $message );
3898
+	do_action('deprecated_file_included', $file, $replacement, $version, $message);
3899 3899
 
3900 3900
 	/**
3901 3901
 	 * Filters whether to trigger an error for deprecated files.
@@ -3904,21 +3904,21 @@  discard block
 block discarded – undo
3904 3904
 	 *
3905 3905
 	 * @param bool $trigger Whether to trigger the error for deprecated files. Default true.
3906 3906
 	 */
3907
-	if ( WP_DEBUG && apply_filters( 'deprecated_file_trigger_error', true ) ) {
3908
-		$message = empty( $message ) ? '' : ' ' . $message;
3909
-		if ( function_exists( '__' ) ) {
3910
-			if ( ! is_null( $replacement ) ) {
3907
+	if (WP_DEBUG && apply_filters('deprecated_file_trigger_error', true)) {
3908
+		$message = empty($message) ? '' : ' '.$message;
3909
+		if (function_exists('__')) {
3910
+			if ( ! is_null($replacement)) {
3911 3911
 				/* translators: 1: PHP file name, 2: version number, 3: alternative file name */
3912
-				trigger_error( sprintf( __('%1$s is <strong>deprecated</strong> since version %2$s! Use %3$s instead.'), $file, $version, $replacement ) . $message );
3912
+				trigger_error(sprintf(__('%1$s is <strong>deprecated</strong> since version %2$s! Use %3$s instead.'), $file, $version, $replacement).$message);
3913 3913
 			} else {
3914 3914
 				/* translators: 1: PHP file name, 2: version number */
3915
-				trigger_error( sprintf( __('%1$s is <strong>deprecated</strong> since version %2$s with no alternative available.'), $file, $version ) . $message );
3915
+				trigger_error(sprintf(__('%1$s is <strong>deprecated</strong> since version %2$s with no alternative available.'), $file, $version).$message);
3916 3916
 			}
3917 3917
 		} else {
3918
-			if ( ! is_null( $replacement ) ) {
3919
-				trigger_error( sprintf( '%1$s is <strong>deprecated</strong> since version %2$s! Use %3$s instead.', $file, $version, $replacement ) . $message );
3918
+			if ( ! is_null($replacement)) {
3919
+				trigger_error(sprintf('%1$s is <strong>deprecated</strong> since version %2$s! Use %3$s instead.', $file, $version, $replacement).$message);
3920 3920
 			} else {
3921
-				trigger_error( sprintf( '%1$s is <strong>deprecated</strong> since version %2$s with no alternative available.', $file, $version ) . $message );
3921
+				trigger_error(sprintf('%1$s is <strong>deprecated</strong> since version %2$s with no alternative available.', $file, $version).$message);
3922 3922
 			}
3923 3923
 		}
3924 3924
 	}
@@ -3949,7 +3949,7 @@  discard block
 block discarded – undo
3949 3949
  * @param string $version  The version of WordPress that deprecated the argument used.
3950 3950
  * @param string $message  Optional. A message regarding the change. Default null.
3951 3951
  */
3952
-function _deprecated_argument( $function, $version, $message = null ) {
3952
+function _deprecated_argument($function, $version, $message = null) {
3953 3953
 
3954 3954
 	/**
3955 3955
 	 * Fires when a deprecated argument is called.
@@ -3960,7 +3960,7 @@  discard block
 block discarded – undo
3960 3960
 	 * @param string $message  A message regarding the change.
3961 3961
 	 * @param string $version  The version of WordPress that deprecated the argument used.
3962 3962
 	 */
3963
-	do_action( 'deprecated_argument_run', $function, $message, $version );
3963
+	do_action('deprecated_argument_run', $function, $message, $version);
3964 3964
 
3965 3965
 	/**
3966 3966
 	 * Filters whether to trigger an error for deprecated arguments.
@@ -3969,20 +3969,20 @@  discard block
 block discarded – undo
3969 3969
 	 *
3970 3970
 	 * @param bool $trigger Whether to trigger the error for deprecated arguments. Default true.
3971 3971
 	 */
3972
-	if ( WP_DEBUG && apply_filters( 'deprecated_argument_trigger_error', true ) ) {
3973
-		if ( function_exists( '__' ) ) {
3974
-			if ( ! is_null( $message ) ) {
3972
+	if (WP_DEBUG && apply_filters('deprecated_argument_trigger_error', true)) {
3973
+		if (function_exists('__')) {
3974
+			if ( ! is_null($message)) {
3975 3975
 				/* translators: 1: PHP function name, 2: version number, 3: optional message regarding the change */
3976
-				trigger_error( sprintf( __('%1$s was called with an argument that is <strong>deprecated</strong> since version %2$s! %3$s'), $function, $version, $message ) );
3976
+				trigger_error(sprintf(__('%1$s was called with an argument that is <strong>deprecated</strong> since version %2$s! %3$s'), $function, $version, $message));
3977 3977
 			} else {
3978 3978
 				/* translators: 1: PHP function name, 2: version number */
3979
-				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 ) );
3979
+				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));
3980 3980
 			}
3981 3981
 		} else {
3982
-			if ( ! is_null( $message ) ) {
3983
-				trigger_error( sprintf( '%1$s was called with an argument that is <strong>deprecated</strong> since version %2$s! %3$s', $function, $version, $message ) );
3982
+			if ( ! is_null($message)) {
3983
+				trigger_error(sprintf('%1$s was called with an argument that is <strong>deprecated</strong> since version %2$s! %3$s', $function, $version, $message));
3984 3984
 			} else {
3985
-				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 ) );
3985
+				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));
3986 3986
 			}
3987 3987
 		}
3988 3988
 	}
@@ -4007,7 +4007,7 @@  discard block
 block discarded – undo
4007 4007
  * @param string $replacement Optional. The hook that should have been used.
4008 4008
  * @param string $message     Optional. A message regarding the change.
4009 4009
  */
4010
-function _deprecated_hook( $hook, $version, $replacement = null, $message = null ) {
4010
+function _deprecated_hook($hook, $version, $replacement = null, $message = null) {
4011 4011
 	/**
4012 4012
 	 * Fires when a deprecated hook is called.
4013 4013
 	 *
@@ -4018,7 +4018,7 @@  discard block
 block discarded – undo
4018 4018
 	 * @param string $version     The version of WordPress that deprecated the argument used.
4019 4019
 	 * @param string $message     A message regarding the change.
4020 4020
 	 */
4021
-	do_action( 'deprecated_hook_run', $hook, $replacement, $version, $message );
4021
+	do_action('deprecated_hook_run', $hook, $replacement, $version, $message);
4022 4022
 
4023 4023
 	/**
4024 4024
 	 * Filters whether to trigger deprecated hook errors.
@@ -4028,14 +4028,14 @@  discard block
 block discarded – undo
4028 4028
 	 * @param bool $trigger Whether to trigger deprecated hook errors. Requires
4029 4029
 	 *                      `WP_DEBUG` to be defined true.
4030 4030
 	 */
4031
-	if ( WP_DEBUG && apply_filters( 'deprecated_hook_trigger_error', true ) ) {
4032
-		$message = empty( $message ) ? '' : ' ' . $message;
4033
-		if ( ! is_null( $replacement ) ) {
4031
+	if (WP_DEBUG && apply_filters('deprecated_hook_trigger_error', true)) {
4032
+		$message = empty($message) ? '' : ' '.$message;
4033
+		if ( ! is_null($replacement)) {
4034 4034
 			/* translators: 1: WordPress hook name, 2: version number, 3: alternative hook name */
4035
-			trigger_error( sprintf( __( '%1$s is <strong>deprecated</strong> since version %2$s! Use %3$s instead.' ), $hook, $version, $replacement ) . $message );
4035
+			trigger_error(sprintf(__('%1$s is <strong>deprecated</strong> since version %2$s! Use %3$s instead.'), $hook, $version, $replacement).$message);
4036 4036
 		} else {
4037 4037
 			/* translators: 1: WordPress hook name, 2: version number */
4038
-			trigger_error( sprintf( __( '%1$s is <strong>deprecated</strong> since version %2$s with no alternative available.' ), $hook, $version ) . $message );
4038
+			trigger_error(sprintf(__('%1$s is <strong>deprecated</strong> since version %2$s with no alternative available.'), $hook, $version).$message);
4039 4039
 		}
4040 4040
 	}
4041 4041
 }
@@ -4056,7 +4056,7 @@  discard block
 block discarded – undo
4056 4056
  * @param string $message  A message explaining what has been done incorrectly.
4057 4057
  * @param string $version  The version of WordPress where the message was added.
4058 4058
  */
4059
-function _doing_it_wrong( $function, $message, $version ) {
4059
+function _doing_it_wrong($function, $message, $version) {
4060 4060
 
4061 4061
 	/**
4062 4062
 	 * Fires when the given function is being used incorrectly.
@@ -4067,7 +4067,7 @@  discard block
 block discarded – undo
4067 4067
 	 * @param string $message  A message explaining what has been done incorrectly.
4068 4068
 	 * @param string $version  The version of WordPress where the message was added.
4069 4069
 	 */
4070
-	do_action( 'doing_it_wrong_run', $function, $message, $version );
4070
+	do_action('doing_it_wrong_run', $function, $message, $version);
4071 4071
 
4072 4072
 	/**
4073 4073
 	 * Filters whether to trigger an error for _doing_it_wrong() calls.
@@ -4076,30 +4076,30 @@  discard block
 block discarded – undo
4076 4076
 	 *
4077 4077
 	 * @param bool $trigger Whether to trigger the error for _doing_it_wrong() calls. Default true.
4078 4078
 	 */
4079
-	if ( WP_DEBUG && apply_filters( 'doing_it_wrong_trigger_error', true ) ) {
4080
-		if ( function_exists( '__' ) ) {
4081
-			if ( is_null( $version ) ) {
4079
+	if (WP_DEBUG && apply_filters('doing_it_wrong_trigger_error', true)) {
4080
+		if (function_exists('__')) {
4081
+			if (is_null($version)) {
4082 4082
 				$version = '';
4083 4083
 			} else {
4084 4084
 				/* translators: %s: version number */
4085
-				$version = sprintf( __( '(This message was added in version %s.)' ), $version );
4085
+				$version = sprintf(__('(This message was added in version %s.)'), $version);
4086 4086
 			}
4087 4087
 			/* translators: %s: Codex URL */
4088
-			$message .= ' ' . sprintf( __( 'Please see <a href="%s">Debugging in WordPress</a> for more information.' ),
4089
-				__( 'https://codex.wordpress.org/Debugging_in_WordPress' )
4088
+			$message .= ' '.sprintf(__('Please see <a href="%s">Debugging in WordPress</a> for more information.'),
4089
+				__('https://codex.wordpress.org/Debugging_in_WordPress')
4090 4090
 			);
4091 4091
 			/* translators: Developer debugging message. 1: PHP function name, 2: Explanatory message, 3: Version information message */
4092
-			trigger_error( sprintf( __( '%1$s was called <strong>incorrectly</strong>. %2$s %3$s' ), $function, $message, $version ) );
4092
+			trigger_error(sprintf(__('%1$s was called <strong>incorrectly</strong>. %2$s %3$s'), $function, $message, $version));
4093 4093
 		} else {
4094
-			if ( is_null( $version ) ) {
4094
+			if (is_null($version)) {
4095 4095
 				$version = '';
4096 4096
 			} else {
4097
-				$version = sprintf( '(This message was added in version %s.)', $version );
4097
+				$version = sprintf('(This message was added in version %s.)', $version);
4098 4098
 			}
4099
-			$message .= sprintf( ' Please see <a href="%s">Debugging in WordPress</a> for more information.',
4099
+			$message .= sprintf(' Please see <a href="%s">Debugging in WordPress</a> for more information.',
4100 4100
 				'https://codex.wordpress.org/Debugging_in_WordPress'
4101 4101
 			);
4102
-			trigger_error( sprintf( '%1$s was called <strong>incorrectly</strong>. %2$s %3$s', $function, $message, $version ) );
4102
+			trigger_error(sprintf('%1$s was called <strong>incorrectly</strong>. %2$s %3$s', $function, $message, $version));
4103 4103
 		}
4104 4104
 	}
4105 4105
 }
@@ -4112,9 +4112,9 @@  discard block
 block discarded – undo
4112 4112
  * @return bool Whether the server is running lighttpd < 1.5.0.
4113 4113
  */
4114 4114
 function is_lighttpd_before_150() {
4115
-	$server_parts = explode( '/', isset( $_SERVER['SERVER_SOFTWARE'] )? $_SERVER['SERVER_SOFTWARE'] : '' );
4116
-	$server_parts[1] = isset( $server_parts[1] )? $server_parts[1] : '';
4117
-	return  'lighttpd' == $server_parts[0] && -1 == version_compare( $server_parts[1], '1.5.0' );
4115
+	$server_parts = explode('/', isset($_SERVER['SERVER_SOFTWARE']) ? $_SERVER['SERVER_SOFTWARE'] : '');
4116
+	$server_parts[1] = isset($server_parts[1]) ? $server_parts[1] : '';
4117
+	return  'lighttpd' == $server_parts[0] && -1 == version_compare($server_parts[1], '1.5.0');
4118 4118
 }
4119 4119
 
4120 4120
 /**
@@ -4131,18 +4131,18 @@  discard block
 block discarded – undo
4131 4131
 function apache_mod_loaded($mod, $default = false) {
4132 4132
 	global $is_apache;
4133 4133
 
4134
-	if ( !$is_apache )
4134
+	if ( ! $is_apache)
4135 4135
 		return false;
4136 4136
 
4137
-	if ( function_exists( 'apache_get_modules' ) ) {
4137
+	if (function_exists('apache_get_modules')) {
4138 4138
 		$mods = apache_get_modules();
4139
-		if ( in_array($mod, $mods) )
4139
+		if (in_array($mod, $mods))
4140 4140
 			return true;
4141
-	} elseif ( function_exists( 'phpinfo' ) && false === strpos( ini_get( 'disable_functions' ), 'phpinfo' ) ) {
4141
+	} elseif (function_exists('phpinfo') && false === strpos(ini_get('disable_functions'), 'phpinfo')) {
4142 4142
 			ob_start();
4143 4143
 			phpinfo(8);
4144 4144
 			$phpinfo = ob_get_clean();
4145
-			if ( false !== strpos($phpinfo, $mod) )
4145
+			if (false !== strpos($phpinfo, $mod))
4146 4146
 				return true;
4147 4147
 	}
4148 4148
 	return $default;
@@ -4161,7 +4161,7 @@  discard block
 block discarded – undo
4161 4161
 	global $is_iis7;
4162 4162
 
4163 4163
 	$supports_permalinks = false;
4164
-	if ( $is_iis7 ) {
4164
+	if ($is_iis7) {
4165 4165
 		/* First we check if the DOMDocument class exists. If it does not exist, then we cannot
4166 4166
 		 * easily update the xml configuration file, hence we just bail out and tell user that
4167 4167
 		 * pretty permalinks cannot be used.
@@ -4171,7 +4171,7 @@  discard block
 block discarded – undo
4171 4171
 		 * Lastly we make sure that PHP is running via FastCGI. This is important because if it runs
4172 4172
 		 * via ISAPI then pretty permalinks will not work.
4173 4173
 		 */
4174
-		$supports_permalinks = class_exists( 'DOMDocument', false ) && isset($_SERVER['IIS_UrlRewriteModule']) && ( PHP_SAPI == 'cgi-fcgi' );
4174
+		$supports_permalinks = class_exists('DOMDocument', false) && isset($_SERVER['IIS_UrlRewriteModule']) && (PHP_SAPI == 'cgi-fcgi');
4175 4175
 	}
4176 4176
 
4177 4177
 	/**
@@ -4181,7 +4181,7 @@  discard block
 block discarded – undo
4181 4181
 	 *
4182 4182
 	 * @param bool $supports_permalinks Whether IIS7 supports permalinks. Default false.
4183 4183
 	 */
4184
-	return apply_filters( 'iis7_supports_permalinks', $supports_permalinks );
4184
+	return apply_filters('iis7_supports_permalinks', $supports_permalinks);
4185 4185
 }
4186 4186
 
4187 4187
 /**
@@ -4198,17 +4198,17 @@  discard block
 block discarded – undo
4198 4198
  * @param array  $allowed_files List of allowed files.
4199 4199
  * @return int 0 means nothing is wrong, greater than 0 means something was wrong.
4200 4200
  */
4201
-function validate_file( $file, $allowed_files = '' ) {
4202
-	if ( false !== strpos( $file, '..' ) )
4201
+function validate_file($file, $allowed_files = '') {
4202
+	if (false !== strpos($file, '..'))
4203 4203
 		return 1;
4204 4204
 
4205
-	if ( false !== strpos( $file, './' ) )
4205
+	if (false !== strpos($file, './'))
4206 4206
 		return 1;
4207 4207
 
4208
-	if ( ! empty( $allowed_files ) && ! in_array( $file, $allowed_files ) )
4208
+	if ( ! empty($allowed_files) && ! in_array($file, $allowed_files))
4209 4209
 		return 3;
4210 4210
 
4211
-	if (':' == substr( $file, 1, 1 ) )
4211
+	if (':' == substr($file, 1, 1))
4212 4212
 		return 2;
4213 4213
 
4214 4214
 	return 0;
@@ -4224,10 +4224,10 @@  discard block
 block discarded – undo
4224 4224
  * @param string|bool $force Optional. Whether to force SSL in admin screens. Default null.
4225 4225
  * @return bool True if forced, false if not forced.
4226 4226
  */
4227
-function force_ssl_admin( $force = null ) {
4227
+function force_ssl_admin($force = null) {
4228 4228
 	static $forced = false;
4229 4229
 
4230
-	if ( !is_null( $force ) ) {
4230
+	if ( ! is_null($force)) {
4231 4231
 		$old_forced = $forced;
4232 4232
 		$forced = $force;
4233 4233
 		return $old_forced;
@@ -4247,39 +4247,39 @@  discard block
 block discarded – undo
4247 4247
  * @return string The guessed URL.
4248 4248
  */
4249 4249
 function wp_guess_url() {
4250
-	if ( defined('WP_SITEURL') && '' != WP_SITEURL ) {
4250
+	if (defined('WP_SITEURL') && '' != WP_SITEURL) {
4251 4251
 		$url = WP_SITEURL;
4252 4252
 	} else {
4253
-		$abspath_fix = str_replace( '\\', '/', ABSPATH );
4254
-		$script_filename_dir = dirname( $_SERVER['SCRIPT_FILENAME'] );
4253
+		$abspath_fix = str_replace('\\', '/', ABSPATH);
4254
+		$script_filename_dir = dirname($_SERVER['SCRIPT_FILENAME']);
4255 4255
 
4256 4256
 		// The request is for the admin
4257
-		if ( strpos( $_SERVER['REQUEST_URI'], 'wp-admin' ) !== false || strpos( $_SERVER['REQUEST_URI'], 'wp-login.php' ) !== false ) {
4258
-			$path = preg_replace( '#/(wp-admin/.*|wp-login.php)#i', '', $_SERVER['REQUEST_URI'] );
4257
+		if (strpos($_SERVER['REQUEST_URI'], 'wp-admin') !== false || strpos($_SERVER['REQUEST_URI'], 'wp-login.php') !== false) {
4258
+			$path = preg_replace('#/(wp-admin/.*|wp-login.php)#i', '', $_SERVER['REQUEST_URI']);
4259 4259
 
4260 4260
 		// The request is for a file in ABSPATH
4261
-		} elseif ( $script_filename_dir . '/' == $abspath_fix ) {
4261
+		} elseif ($script_filename_dir.'/' == $abspath_fix) {
4262 4262
 			// Strip off any file/query params in the path
4263
-			$path = preg_replace( '#/[^/]*$#i', '', $_SERVER['PHP_SELF'] );
4263
+			$path = preg_replace('#/[^/]*$#i', '', $_SERVER['PHP_SELF']);
4264 4264
 
4265 4265
 		} else {
4266
-			if ( false !== strpos( $_SERVER['SCRIPT_FILENAME'], $abspath_fix ) ) {
4266
+			if (false !== strpos($_SERVER['SCRIPT_FILENAME'], $abspath_fix)) {
4267 4267
 				// Request is hitting a file inside ABSPATH
4268
-				$directory = str_replace( ABSPATH, '', $script_filename_dir );
4268
+				$directory = str_replace(ABSPATH, '', $script_filename_dir);
4269 4269
 				// Strip off the sub directory, and any file/query params
4270
-				$path = preg_replace( '#/' . preg_quote( $directory, '#' ) . '/[^/]*$#i', '' , $_SERVER['REQUEST_URI'] );
4271
-			} elseif ( false !== strpos( $abspath_fix, $script_filename_dir ) ) {
4270
+				$path = preg_replace('#/'.preg_quote($directory, '#').'/[^/]*$#i', '', $_SERVER['REQUEST_URI']);
4271
+			} elseif (false !== strpos($abspath_fix, $script_filename_dir)) {
4272 4272
 				// Request is hitting a file above ABSPATH
4273
-				$subdirectory = substr( $abspath_fix, strpos( $abspath_fix, $script_filename_dir ) + strlen( $script_filename_dir ) );
4273
+				$subdirectory = substr($abspath_fix, strpos($abspath_fix, $script_filename_dir) + strlen($script_filename_dir));
4274 4274
 				// Strip off any file/query params from the path, appending the sub directory to the install
4275
-				$path = preg_replace( '#/[^/]*$#i', '' , $_SERVER['REQUEST_URI'] ) . $subdirectory;
4275
+				$path = preg_replace('#/[^/]*$#i', '', $_SERVER['REQUEST_URI']).$subdirectory;
4276 4276
 			} else {
4277 4277
 				$path = $_SERVER['REQUEST_URI'];
4278 4278
 			}
4279 4279
 		}
4280 4280
 
4281 4281
 		$schema = is_ssl() ? 'https://' : 'http://'; // set_url_scheme() is not defined yet
4282
-		$url = $schema . $_SERVER['HTTP_HOST'] . $path;
4282
+		$url = $schema.$_SERVER['HTTP_HOST'].$path;
4283 4283
 	}
4284 4284
 
4285 4285
 	return rtrim($url, '/');
@@ -4302,10 +4302,10 @@  discard block
 block discarded – undo
4302 4302
  * @param bool $suspend Optional. Suspends additions if true, re-enables them if false.
4303 4303
  * @return bool The current suspend setting
4304 4304
  */
4305
-function wp_suspend_cache_addition( $suspend = null ) {
4305
+function wp_suspend_cache_addition($suspend = null) {
4306 4306
 	static $_suspend = false;
4307 4307
 
4308
-	if ( is_bool( $suspend ) )
4308
+	if (is_bool($suspend))
4309 4309
 		$_suspend = $suspend;
4310 4310
 
4311 4311
 	return $_suspend;
@@ -4325,7 +4325,7 @@  discard block
 block discarded – undo
4325 4325
  * @param bool $suspend Optional. Whether to suspend or enable cache invalidation. Default true.
4326 4326
  * @return bool The current suspend setting.
4327 4327
  */
4328
-function wp_suspend_cache_invalidation( $suspend = true ) {
4328
+function wp_suspend_cache_invalidation($suspend = true) {
4329 4329
 	global $_wp_suspend_cache_invalidation;
4330 4330
 
4331 4331
 	$current_suspend = $_wp_suspend_cache_invalidation;
@@ -4342,11 +4342,11 @@  discard block
 block discarded – undo
4342 4342
  * @return bool True if $site_id is the main site of the network, or if not
4343 4343
  *              running Multisite.
4344 4344
  */
4345
-function is_main_site( $site_id = null ) {
4346
-	if ( ! is_multisite() )
4345
+function is_main_site($site_id = null) {
4346
+	if ( ! is_multisite())
4347 4347
 		return true;
4348 4348
 
4349
-	if ( ! $site_id )
4349
+	if ( ! $site_id)
4350 4350
 		$site_id = get_current_blog_id();
4351 4351
 
4352 4352
 	return (int) $site_id === (int) get_network()->site_id;
@@ -4360,18 +4360,18 @@  discard block
 block discarded – undo
4360 4360
  * @param int $network_id Optional. Network ID to test. Defaults to current network.
4361 4361
  * @return bool True if $network_id is the main network, or if not running Multisite.
4362 4362
  */
4363
-function is_main_network( $network_id = null ) {
4364
-	if ( ! is_multisite() ) {
4363
+function is_main_network($network_id = null) {
4364
+	if ( ! is_multisite()) {
4365 4365
 		return true;
4366 4366
 	}
4367 4367
 
4368
-	if ( null === $network_id ) {
4368
+	if (null === $network_id) {
4369 4369
 		$network_id = get_current_network_id();
4370 4370
 	}
4371 4371
 
4372 4372
 	$network_id = (int) $network_id;
4373 4373
 
4374
-	return ( $network_id === get_main_network_id() );
4374
+	return ($network_id === get_main_network_id());
4375 4375
 }
4376 4376
 
4377 4377
 /**
@@ -4382,20 +4382,20 @@  discard block
 block discarded – undo
4382 4382
  * @return int The ID of the main network.
4383 4383
  */
4384 4384
 function get_main_network_id() {
4385
-	if ( ! is_multisite() ) {
4385
+	if ( ! is_multisite()) {
4386 4386
 		return 1;
4387 4387
 	}
4388 4388
 
4389 4389
 	$current_network = get_network();
4390 4390
 
4391
-	if ( defined( 'PRIMARY_NETWORK_ID' ) ) {
4391
+	if (defined('PRIMARY_NETWORK_ID')) {
4392 4392
 		$main_network_id = PRIMARY_NETWORK_ID;
4393
-	} elseif ( isset( $current_network->id ) && 1 === (int) $current_network->id ) {
4393
+	} elseif (isset($current_network->id) && 1 === (int) $current_network->id) {
4394 4394
 		// If the current network has an ID of 1, assume it is the main network.
4395 4395
 		$main_network_id = 1;
4396 4396
 	} else {
4397
-		$_networks = get_networks( array( 'fields' => 'ids', 'number' => 1 ) );
4398
-		$main_network_id = array_shift( $_networks );
4397
+		$_networks = get_networks(array('fields' => 'ids', 'number' => 1));
4398
+		$main_network_id = array_shift($_networks);
4399 4399
 	}
4400 4400
 
4401 4401
 	/**
@@ -4405,7 +4405,7 @@  discard block
 block discarded – undo
4405 4405
 	 *
4406 4406
 	 * @param int $main_network_id The ID of the main network.
4407 4407
 	 */
4408
-	return (int) apply_filters( 'get_main_network_id', $main_network_id );
4408
+	return (int) apply_filters('get_main_network_id', $main_network_id);
4409 4409
 }
4410 4410
 
4411 4411
 /**
@@ -4418,11 +4418,11 @@  discard block
 block discarded – undo
4418 4418
  * @return bool True if multisite and global terms enabled.
4419 4419
  */
4420 4420
 function global_terms_enabled() {
4421
-	if ( ! is_multisite() )
4421
+	if ( ! is_multisite())
4422 4422
 		return false;
4423 4423
 
4424 4424
 	static $global_terms = null;
4425
-	if ( is_null( $global_terms ) ) {
4425
+	if (is_null($global_terms)) {
4426 4426
 
4427 4427
 		/**
4428 4428
 		 * Filters whether global terms are enabled.
@@ -4434,11 +4434,11 @@  discard block
 block discarded – undo
4434 4434
 		 *
4435 4435
 		 * @param null $enabled Whether global terms are enabled.
4436 4436
 		 */
4437
-		$filter = apply_filters( 'global_terms_enabled', null );
4438
-		if ( ! is_null( $filter ) )
4437
+		$filter = apply_filters('global_terms_enabled', null);
4438
+		if ( ! is_null($filter))
4439 4439
 			$global_terms = (bool) $filter;
4440 4440
 		else
4441
-			$global_terms = (bool) get_site_option( 'global_terms_enabled', false );
4441
+			$global_terms = (bool) get_site_option('global_terms_enabled', false);
4442 4442
 	}
4443 4443
 	return $global_terms;
4444 4444
 }
@@ -4453,16 +4453,16 @@  discard block
 block discarded – undo
4453 4453
  * @return float|false Timezone GMT offset, false otherwise.
4454 4454
  */
4455 4455
 function wp_timezone_override_offset() {
4456
-	if ( !$timezone_string = get_option( 'timezone_string' ) ) {
4456
+	if ( ! $timezone_string = get_option('timezone_string')) {
4457 4457
 		return false;
4458 4458
 	}
4459 4459
 
4460
-	$timezone_object = timezone_open( $timezone_string );
4460
+	$timezone_object = timezone_open($timezone_string);
4461 4461
 	$datetime_object = date_create();
4462
-	if ( false === $timezone_object || false === $datetime_object ) {
4462
+	if (false === $timezone_object || false === $datetime_object) {
4463 4463
 		return false;
4464 4464
 	}
4465
-	return round( timezone_offset_get( $timezone_object, $datetime_object ) / HOUR_IN_SECONDS, 2 );
4465
+	return round(timezone_offset_get($timezone_object, $datetime_object) / HOUR_IN_SECONDS, 2);
4466 4466
 }
4467 4467
 
4468 4468
 /**
@@ -4475,41 +4475,41 @@  discard block
 block discarded – undo
4475 4475
  * @param array $b
4476 4476
  * @return int
4477 4477
  */
4478
-function _wp_timezone_choice_usort_callback( $a, $b ) {
4478
+function _wp_timezone_choice_usort_callback($a, $b) {
4479 4479
 	// Don't use translated versions of Etc
4480
-	if ( 'Etc' === $a['continent'] && 'Etc' === $b['continent'] ) {
4480
+	if ('Etc' === $a['continent'] && 'Etc' === $b['continent']) {
4481 4481
 		// Make the order of these more like the old dropdown
4482
-		if ( 'GMT+' === substr( $a['city'], 0, 4 ) && 'GMT+' === substr( $b['city'], 0, 4 ) ) {
4483
-			return -1 * ( strnatcasecmp( $a['city'], $b['city'] ) );
4482
+		if ('GMT+' === substr($a['city'], 0, 4) && 'GMT+' === substr($b['city'], 0, 4)) {
4483
+			return -1 * (strnatcasecmp($a['city'], $b['city']));
4484 4484
 		}
4485
-		if ( 'UTC' === $a['city'] ) {
4486
-			if ( 'GMT+' === substr( $b['city'], 0, 4 ) ) {
4485
+		if ('UTC' === $a['city']) {
4486
+			if ('GMT+' === substr($b['city'], 0, 4)) {
4487 4487
 				return 1;
4488 4488
 			}
4489 4489
 			return -1;
4490 4490
 		}
4491
-		if ( 'UTC' === $b['city'] ) {
4492
-			if ( 'GMT+' === substr( $a['city'], 0, 4 ) ) {
4491
+		if ('UTC' === $b['city']) {
4492
+			if ('GMT+' === substr($a['city'], 0, 4)) {
4493 4493
 				return -1;
4494 4494
 			}
4495 4495
 			return 1;
4496 4496
 		}
4497
-		return strnatcasecmp( $a['city'], $b['city'] );
4497
+		return strnatcasecmp($a['city'], $b['city']);
4498 4498
 	}
4499
-	if ( $a['t_continent'] == $b['t_continent'] ) {
4500
-		if ( $a['t_city'] == $b['t_city'] ) {
4501
-			return strnatcasecmp( $a['t_subcity'], $b['t_subcity'] );
4499
+	if ($a['t_continent'] == $b['t_continent']) {
4500
+		if ($a['t_city'] == $b['t_city']) {
4501
+			return strnatcasecmp($a['t_subcity'], $b['t_subcity']);
4502 4502
 		}
4503
-		return strnatcasecmp( $a['t_city'], $b['t_city'] );
4503
+		return strnatcasecmp($a['t_city'], $b['t_city']);
4504 4504
 	} else {
4505 4505
 		// Force Etc to the bottom of the list
4506
-		if ( 'Etc' === $a['continent'] ) {
4506
+		if ('Etc' === $a['continent']) {
4507 4507
 			return 1;
4508 4508
 		}
4509
-		if ( 'Etc' === $b['continent'] ) {
4509
+		if ('Etc' === $b['continent']) {
4510 4510
 			return -1;
4511 4511
 		}
4512
-		return strnatcasecmp( $a['t_continent'], $b['t_continent'] );
4512
+		return strnatcasecmp($a['t_continent'], $b['t_continent']);
4513 4513
 	}
4514 4514
 }
4515 4515
 
@@ -4526,126 +4526,126 @@  discard block
 block discarded – undo
4526 4526
  * @param string $locale        Optional. Locale to load the timezones in. Default current site locale.
4527 4527
  * @return string
4528 4528
  */
4529
-function wp_timezone_choice( $selected_zone, $locale = null ) {
4529
+function wp_timezone_choice($selected_zone, $locale = null) {
4530 4530
 	static $mo_loaded = false, $locale_loaded = null;
4531 4531
 
4532
-	$continents = array( 'Africa', 'America', 'Antarctica', 'Arctic', 'Asia', 'Atlantic', 'Australia', 'Europe', 'Indian', 'Pacific');
4532
+	$continents = array('Africa', 'America', 'Antarctica', 'Arctic', 'Asia', 'Atlantic', 'Australia', 'Europe', 'Indian', 'Pacific');
4533 4533
 
4534 4534
 	// Load translations for continents and cities.
4535
-	if ( ! $mo_loaded || $locale !== $locale_loaded ) {
4535
+	if ( ! $mo_loaded || $locale !== $locale_loaded) {
4536 4536
 		$locale_loaded = $locale ? $locale : get_locale();
4537
-		$mofile = WP_LANG_DIR . '/continents-cities-' . $locale_loaded . '.mo';
4538
-		unload_textdomain( 'continents-cities' );
4539
-		load_textdomain( 'continents-cities', $mofile );
4537
+		$mofile = WP_LANG_DIR.'/continents-cities-'.$locale_loaded.'.mo';
4538
+		unload_textdomain('continents-cities');
4539
+		load_textdomain('continents-cities', $mofile);
4540 4540
 		$mo_loaded = true;
4541 4541
 	}
4542 4542
 
4543 4543
 	$zonen = array();
4544
-	foreach ( timezone_identifiers_list() as $zone ) {
4545
-		$zone = explode( '/', $zone );
4546
-		if ( !in_array( $zone[0], $continents ) ) {
4544
+	foreach (timezone_identifiers_list() as $zone) {
4545
+		$zone = explode('/', $zone);
4546
+		if ( ! in_array($zone[0], $continents)) {
4547 4547
 			continue;
4548 4548
 		}
4549 4549
 
4550 4550
 		// This determines what gets set and translated - we don't translate Etc/* strings here, they are done later
4551 4551
 		$exists = array(
4552
-			0 => ( isset( $zone[0] ) && $zone[0] ),
4553
-			1 => ( isset( $zone[1] ) && $zone[1] ),
4554
-			2 => ( isset( $zone[2] ) && $zone[2] ),
4552
+			0 => (isset($zone[0]) && $zone[0]),
4553
+			1 => (isset($zone[1]) && $zone[1]),
4554
+			2 => (isset($zone[2]) && $zone[2]),
4555 4555
 		);
4556
-		$exists[3] = ( $exists[0] && 'Etc' !== $zone[0] );
4557
-		$exists[4] = ( $exists[1] && $exists[3] );
4558
-		$exists[5] = ( $exists[2] && $exists[3] );
4556
+		$exists[3] = ($exists[0] && 'Etc' !== $zone[0]);
4557
+		$exists[4] = ($exists[1] && $exists[3]);
4558
+		$exists[5] = ($exists[2] && $exists[3]);
4559 4559
 
4560 4560
 		$zonen[] = array(
4561
-			'continent'   => ( $exists[0] ? $zone[0] : '' ),
4562
-			'city'        => ( $exists[1] ? $zone[1] : '' ),
4563
-			'subcity'     => ( $exists[2] ? $zone[2] : '' ),
4564
-			't_continent' => ( $exists[3] ? translate( str_replace( '_', ' ', $zone[0] ), 'continents-cities' ) : '' ),
4565
-			't_city'      => ( $exists[4] ? translate( str_replace( '_', ' ', $zone[1] ), 'continents-cities' ) : '' ),
4566
-			't_subcity'   => ( $exists[5] ? translate( str_replace( '_', ' ', $zone[2] ), 'continents-cities' ) : '' )
4561
+			'continent'   => ($exists[0] ? $zone[0] : ''),
4562
+			'city'        => ($exists[1] ? $zone[1] : ''),
4563
+			'subcity'     => ($exists[2] ? $zone[2] : ''),
4564
+			't_continent' => ($exists[3] ? translate(str_replace('_', ' ', $zone[0]), 'continents-cities') : ''),
4565
+			't_city'      => ($exists[4] ? translate(str_replace('_', ' ', $zone[1]), 'continents-cities') : ''),
4566
+			't_subcity'   => ($exists[5] ? translate(str_replace('_', ' ', $zone[2]), 'continents-cities') : '')
4567 4567
 		);
4568 4568
 	}
4569
-	usort( $zonen, '_wp_timezone_choice_usort_callback' );
4569
+	usort($zonen, '_wp_timezone_choice_usort_callback');
4570 4570
 
4571 4571
 	$structure = array();
4572 4572
 
4573
-	if ( empty( $selected_zone ) ) {
4574
-		$structure[] = '<option selected="selected" value="">' . __( 'Select a city' ) . '</option>';
4573
+	if (empty($selected_zone)) {
4574
+		$structure[] = '<option selected="selected" value="">'.__('Select a city').'</option>';
4575 4575
 	}
4576 4576
 
4577
-	foreach ( $zonen as $key => $zone ) {
4577
+	foreach ($zonen as $key => $zone) {
4578 4578
 		// Build value in an array to join later
4579
-		$value = array( $zone['continent'] );
4579
+		$value = array($zone['continent']);
4580 4580
 
4581
-		if ( empty( $zone['city'] ) ) {
4581
+		if (empty($zone['city'])) {
4582 4582
 			// It's at the continent level (generally won't happen)
4583 4583
 			$display = $zone['t_continent'];
4584 4584
 		} else {
4585 4585
 			// It's inside a continent group
4586 4586
 
4587 4587
 			// Continent optgroup
4588
-			if ( !isset( $zonen[$key - 1] ) || $zonen[$key - 1]['continent'] !== $zone['continent'] ) {
4588
+			if ( ! isset($zonen[$key - 1]) || $zonen[$key - 1]['continent'] !== $zone['continent']) {
4589 4589
 				$label = $zone['t_continent'];
4590
-				$structure[] = '<optgroup label="'. esc_attr( $label ) .'">';
4590
+				$structure[] = '<optgroup label="'.esc_attr($label).'">';
4591 4591
 			}
4592 4592
 
4593 4593
 			// Add the city to the value
4594 4594
 			$value[] = $zone['city'];
4595 4595
 
4596 4596
 			$display = $zone['t_city'];
4597
-			if ( !empty( $zone['subcity'] ) ) {
4597
+			if ( ! empty($zone['subcity'])) {
4598 4598
 				// Add the subcity to the value
4599 4599
 				$value[] = $zone['subcity'];
4600
-				$display .= ' - ' . $zone['t_subcity'];
4600
+				$display .= ' - '.$zone['t_subcity'];
4601 4601
 			}
4602 4602
 		}
4603 4603
 
4604 4604
 		// Build the value
4605
-		$value = join( '/', $value );
4605
+		$value = join('/', $value);
4606 4606
 		$selected = '';
4607
-		if ( $value === $selected_zone ) {
4607
+		if ($value === $selected_zone) {
4608 4608
 			$selected = 'selected="selected" ';
4609 4609
 		}
4610
-		$structure[] = '<option ' . $selected . 'value="' . esc_attr( $value ) . '">' . esc_html( $display ) . "</option>";
4610
+		$structure[] = '<option '.$selected.'value="'.esc_attr($value).'">'.esc_html($display)."</option>";
4611 4611
 
4612 4612
 		// Close continent optgroup
4613
-		if ( !empty( $zone['city'] ) && ( !isset($zonen[$key + 1]) || (isset( $zonen[$key + 1] ) && $zonen[$key + 1]['continent'] !== $zone['continent']) ) ) {
4613
+		if ( ! empty($zone['city']) && ( ! isset($zonen[$key + 1]) || (isset($zonen[$key + 1]) && $zonen[$key + 1]['continent'] !== $zone['continent']))) {
4614 4614
 			$structure[] = '</optgroup>';
4615 4615
 		}
4616 4616
 	}
4617 4617
 
4618 4618
 	// Do UTC
4619
-	$structure[] = '<optgroup label="'. esc_attr__( 'UTC' ) .'">';
4619
+	$structure[] = '<optgroup label="'.esc_attr__('UTC').'">';
4620 4620
 	$selected = '';
4621
-	if ( 'UTC' === $selected_zone )
4621
+	if ('UTC' === $selected_zone)
4622 4622
 		$selected = 'selected="selected" ';
4623
-	$structure[] = '<option ' . $selected . 'value="' . esc_attr( 'UTC' ) . '">' . __('UTC') . '</option>';
4623
+	$structure[] = '<option '.$selected.'value="'.esc_attr('UTC').'">'.__('UTC').'</option>';
4624 4624
 	$structure[] = '</optgroup>';
4625 4625
 
4626 4626
 	// Do manual UTC offsets
4627
-	$structure[] = '<optgroup label="'. esc_attr__( 'Manual Offsets' ) .'">';
4628
-	$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,
4627
+	$structure[] = '<optgroup label="'.esc_attr__('Manual Offsets').'">';
4628
+	$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,
4629 4629
 		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);
4630
-	foreach ( $offset_range as $offset ) {
4631
-		if ( 0 <= $offset )
4632
-			$offset_name = '+' . $offset;
4630
+	foreach ($offset_range as $offset) {
4631
+		if (0 <= $offset)
4632
+			$offset_name = '+'.$offset;
4633 4633
 		else
4634 4634
 			$offset_name = (string) $offset;
4635 4635
 
4636 4636
 		$offset_value = $offset_name;
4637
-		$offset_name = str_replace(array('.25','.5','.75'), array(':15',':30',':45'), $offset_name);
4638
-		$offset_name = 'UTC' . $offset_name;
4639
-		$offset_value = 'UTC' . $offset_value;
4637
+		$offset_name = str_replace(array('.25', '.5', '.75'), array(':15', ':30', ':45'), $offset_name);
4638
+		$offset_name = 'UTC'.$offset_name;
4639
+		$offset_value = 'UTC'.$offset_value;
4640 4640
 		$selected = '';
4641
-		if ( $offset_value === $selected_zone )
4641
+		if ($offset_value === $selected_zone)
4642 4642
 			$selected = 'selected="selected" ';
4643
-		$structure[] = '<option ' . $selected . 'value="' . esc_attr( $offset_value ) . '">' . esc_html( $offset_name ) . "</option>";
4643
+		$structure[] = '<option '.$selected.'value="'.esc_attr($offset_value).'">'.esc_html($offset_name)."</option>";
4644 4644
 
4645 4645
 	}
4646 4646
 	$structure[] = '</optgroup>';
4647 4647
 
4648
-	return join( "\n", $structure );
4648
+	return join("\n", $structure);
4649 4649
 }
4650 4650
 
4651 4651
 /**
@@ -4659,7 +4659,7 @@  discard block
 block discarded – undo
4659 4659
  * @param string $str Header comment to clean up.
4660 4660
  * @return string
4661 4661
  */
4662
-function _cleanup_header_comment( $str ) {
4662
+function _cleanup_header_comment($str) {
4663 4663
 	return trim(preg_replace("/\s*(?:\*\/|\?>).*/", '', $str));
4664 4664
 }
4665 4665
 
@@ -4676,18 +4676,18 @@  discard block
 block discarded – undo
4676 4676
 function wp_scheduled_delete() {
4677 4677
 	global $wpdb;
4678 4678
 
4679
-	$delete_timestamp = time() - ( DAY_IN_SECONDS * EMPTY_TRASH_DAYS );
4679
+	$delete_timestamp = time() - (DAY_IN_SECONDS * EMPTY_TRASH_DAYS);
4680 4680
 
4681 4681
 	$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);
4682 4682
 
4683
-	foreach ( (array) $posts_to_delete as $post ) {
4683
+	foreach ((array) $posts_to_delete as $post) {
4684 4684
 		$post_id = (int) $post['post_id'];
4685
-		if ( !$post_id )
4685
+		if ( ! $post_id)
4686 4686
 			continue;
4687 4687
 
4688 4688
 		$del_post = get_post($post_id);
4689 4689
 
4690
-		if ( !$del_post || 'trash' != $del_post->post_status ) {
4690
+		if ( ! $del_post || 'trash' != $del_post->post_status) {
4691 4691
 			delete_post_meta($post_id, '_wp_trash_meta_status');
4692 4692
 			delete_post_meta($post_id, '_wp_trash_meta_time');
4693 4693
 		} else {
@@ -4697,18 +4697,18 @@  discard block
 block discarded – undo
4697 4697
 
4698 4698
 	$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);
4699 4699
 
4700
-	foreach ( (array) $comments_to_delete as $comment ) {
4700
+	foreach ((array) $comments_to_delete as $comment) {
4701 4701
 		$comment_id = (int) $comment['comment_id'];
4702
-		if ( !$comment_id )
4702
+		if ( ! $comment_id)
4703 4703
 			continue;
4704 4704
 
4705 4705
 		$del_comment = get_comment($comment_id);
4706 4706
 
4707
-		if ( !$del_comment || 'trash' != $del_comment->comment_approved ) {
4707
+		if ( ! $del_comment || 'trash' != $del_comment->comment_approved) {
4708 4708
 			delete_comment_meta($comment_id, '_wp_trash_meta_time');
4709 4709
 			delete_comment_meta($comment_id, '_wp_trash_meta_status');
4710 4710
 		} else {
4711
-			wp_delete_comment( $del_comment );
4711
+			wp_delete_comment($del_comment);
4712 4712
 		}
4713 4713
 	}
4714 4714
 }
@@ -4733,18 +4733,18 @@  discard block
 block discarded – undo
4733 4733
  *                                Default empty.
4734 4734
  * @return array Array of file headers in `HeaderKey => Header Value` format.
4735 4735
  */
4736
-function get_file_data( $file, $default_headers, $context = '' ) {
4736
+function get_file_data($file, $default_headers, $context = '') {
4737 4737
 	// We don't need to write to the file, so just open for reading.
4738
-	$fp = fopen( $file, 'r' );
4738
+	$fp = fopen($file, 'r');
4739 4739
 
4740 4740
 	// Pull only the first 8kiB of the file in.
4741
-	$file_data = fread( $fp, 8192 );
4741
+	$file_data = fread($fp, 8192);
4742 4742
 
4743 4743
 	// PHP will close file handle, but we are good citizens.
4744
-	fclose( $fp );
4744
+	fclose($fp);
4745 4745
 
4746 4746
 	// Make sure we catch CR-only line endings.
4747
-	$file_data = str_replace( "\r", "\n", $file_data );
4747
+	$file_data = str_replace("\r", "\n", $file_data);
4748 4748
 
4749 4749
 	/**
4750 4750
 	 * Filters extra file headers by context.
@@ -4756,18 +4756,18 @@  discard block
 block discarded – undo
4756 4756
 	 *
4757 4757
 	 * @param array $extra_context_headers Empty array by default.
4758 4758
 	 */
4759
-	if ( $context && $extra_headers = apply_filters( "extra_{$context}_headers", array() ) ) {
4760
-		$extra_headers = array_combine( $extra_headers, $extra_headers ); // keys equal values
4761
-		$all_headers = array_merge( $extra_headers, (array) $default_headers );
4759
+	if ($context && $extra_headers = apply_filters("extra_{$context}_headers", array())) {
4760
+		$extra_headers = array_combine($extra_headers, $extra_headers); // keys equal values
4761
+		$all_headers = array_merge($extra_headers, (array) $default_headers);
4762 4762
 	} else {
4763 4763
 		$all_headers = $default_headers;
4764 4764
 	}
4765 4765
 
4766
-	foreach ( $all_headers as $field => $regex ) {
4767
-		if ( preg_match( '/^[ \t\/*#@]*' . preg_quote( $regex, '/' ) . ':(.*)$/mi', $file_data, $match ) && $match[1] )
4768
-			$all_headers[ $field ] = _cleanup_header_comment( $match[1] );
4766
+	foreach ($all_headers as $field => $regex) {
4767
+		if (preg_match('/^[ \t\/*#@]*'.preg_quote($regex, '/').':(.*)$/mi', $file_data, $match) && $match[1])
4768
+			$all_headers[$field] = _cleanup_header_comment($match[1]);
4769 4769
 		else
4770
-			$all_headers[ $field ] = '';
4770
+			$all_headers[$field] = '';
4771 4771
 	}
4772 4772
 
4773 4773
 	return $all_headers;
@@ -4866,7 +4866,7 @@  discard block
 block discarded – undo
4866 4866
  * @see https://src.chromium.org/viewvc/chrome?view=rev&revision=6985
4867 4867
  */
4868 4868
 function send_nosniff_header() {
4869
-	@header( 'X-Content-Type-Options: nosniff' );
4869
+	@header('X-Content-Type-Options: nosniff');
4870 4870
 }
4871 4871
 
4872 4872
 /**
@@ -4878,8 +4878,8 @@  discard block
 block discarded – undo
4878 4878
  * @param string $column Database column.
4879 4879
  * @return string SQL clause.
4880 4880
  */
4881
-function _wp_mysql_week( $column ) {
4882
-	switch ( $start_of_week = (int) get_option( 'start_of_week' ) ) {
4881
+function _wp_mysql_week($column) {
4882
+	switch ($start_of_week = (int) get_option('start_of_week')) {
4883 4883
 	case 1 :
4884 4884
 		return "WEEK( $column, 1 )";
4885 4885
 	case 2 :
@@ -4907,13 +4907,13 @@  discard block
 block discarded – undo
4907 4907
  * @param array    $callback_args Optional. Additional arguments to send to $callback.
4908 4908
  * @return array IDs of all members of loop.
4909 4909
  */
4910
-function wp_find_hierarchy_loop( $callback, $start, $start_parent, $callback_args = array() ) {
4911
-	$override = is_null( $start_parent ) ? array() : array( $start => $start_parent );
4910
+function wp_find_hierarchy_loop($callback, $start, $start_parent, $callback_args = array()) {
4911
+	$override = is_null($start_parent) ? array() : array($start => $start_parent);
4912 4912
 
4913
-	if ( !$arbitrary_loop_member = wp_find_hierarchy_loop_tortoise_hare( $callback, $start, $override, $callback_args ) )
4913
+	if ( ! $arbitrary_loop_member = wp_find_hierarchy_loop_tortoise_hare($callback, $start, $override, $callback_args))
4914 4914
 		return array();
4915 4915
 
4916
-	return wp_find_hierarchy_loop_tortoise_hare( $callback, $arbitrary_loop_member, $override, $callback_args, true );
4916
+	return wp_find_hierarchy_loop_tortoise_hare($callback, $arbitrary_loop_member, $override, $callback_args, true);
4917 4917
 }
4918 4918
 
4919 4919
 /**
@@ -4936,7 +4936,7 @@  discard block
 block discarded – undo
4936 4936
  * @return mixed Scalar ID of some arbitrary member of the loop, or array of IDs of all members of loop if
4937 4937
  *               $_return_loop
4938 4938
  */
4939
-function wp_find_hierarchy_loop_tortoise_hare( $callback, $start, $override = array(), $callback_args = array(), $_return_loop = false ) {
4939
+function wp_find_hierarchy_loop_tortoise_hare($callback, $start, $override = array(), $callback_args = array(), $_return_loop = false) {
4940 4940
 	$tortoise = $hare = $evanescent_hare = $start;
4941 4941
 	$return = array();
4942 4942
 
@@ -4945,19 +4945,19 @@  discard block
 block discarded – undo
4945 4945
 	while (
4946 4946
 		$tortoise
4947 4947
 	&&
4948
-		( $evanescent_hare = isset( $override[$hare] ) ? $override[$hare] : call_user_func_array( $callback, array_merge( array( $hare ), $callback_args ) ) )
4948
+		($evanescent_hare = isset($override[$hare]) ? $override[$hare] : call_user_func_array($callback, array_merge(array($hare), $callback_args)))
4949 4949
 	&&
4950
-		( $hare = isset( $override[$evanescent_hare] ) ? $override[$evanescent_hare] : call_user_func_array( $callback, array_merge( array( $evanescent_hare ), $callback_args ) ) )
4950
+		($hare = isset($override[$evanescent_hare]) ? $override[$evanescent_hare] : call_user_func_array($callback, array_merge(array($evanescent_hare), $callback_args)))
4951 4951
 	) {
4952
-		if ( $_return_loop )
4952
+		if ($_return_loop)
4953 4953
 			$return[$tortoise] = $return[$evanescent_hare] = $return[$hare] = true;
4954 4954
 
4955 4955
 		// tortoise got lapped - must be a loop
4956
-		if ( $tortoise == $evanescent_hare || $tortoise == $hare )
4956
+		if ($tortoise == $evanescent_hare || $tortoise == $hare)
4957 4957
 			return $_return_loop ? $return : $tortoise;
4958 4958
 
4959 4959
 		// Increment tortoise by one step
4960
-		$tortoise = isset( $override[$tortoise] ) ? $override[$tortoise] : call_user_func_array( $callback, array_merge( array( $tortoise ), $callback_args ) );
4960
+		$tortoise = isset($override[$tortoise]) ? $override[$tortoise] : call_user_func_array($callback, array_merge(array($tortoise), $callback_args));
4961 4961
 	}
4962 4962
 
4963 4963
 	return false;
@@ -4971,7 +4971,7 @@  discard block
 block discarded – undo
4971 4971
  * @see https://developer.mozilla.org/en/the_x-frame-options_response_header
4972 4972
  */
4973 4973
 function send_frame_options_header() {
4974
-	@header( 'X-Frame-Options: SAMEORIGIN' );
4974
+	@header('X-Frame-Options: SAMEORIGIN');
4975 4975
 }
4976 4976
 
4977 4977
 /**
@@ -4993,8 +4993,8 @@  discard block
 block discarded – undo
4993 4993
 function wp_allowed_protocols() {
4994 4994
 	static $protocols = array();
4995 4995
 
4996
-	if ( empty( $protocols ) ) {
4997
-		$protocols = array( 'http', 'https', 'ftp', 'ftps', 'mailto', 'news', 'irc', 'gopher', 'nntp', 'feed', 'telnet', 'mms', 'rtsp', 'svn', 'tel', 'fax', 'xmpp', 'webcal', 'urn' );
4996
+	if (empty($protocols)) {
4997
+		$protocols = array('http', 'https', 'ftp', 'ftps', 'mailto', 'news', 'irc', 'gopher', 'nntp', 'feed', 'telnet', 'mms', 'rtsp', 'svn', 'tel', 'fax', 'xmpp', 'webcal', 'urn');
4998 4998
 
4999 4999
 		/**
5000 5000
 		 * Filters the list of protocols allowed in HTML attributes.
@@ -5003,7 +5003,7 @@  discard block
 block discarded – undo
5003 5003
 		 *
5004 5004
 		 * @param array $protocols Array of allowed protocols e.g. 'http', 'ftp', 'tel', and more.
5005 5005
 		 */
5006
-		$protocols = apply_filters( 'kses_allowed_protocols', $protocols );
5006
+		$protocols = apply_filters('kses_allowed_protocols', $protocols);
5007 5007
 	}
5008 5008
 
5009 5009
 	return $protocols;
@@ -5026,36 +5026,36 @@  discard block
 block discarded – undo
5026 5026
  * @return string|array Either a string containing a reversed comma separated trace or an array
5027 5027
  *                      of individual calls.
5028 5028
  */
5029
-function wp_debug_backtrace_summary( $ignore_class = null, $skip_frames = 0, $pretty = true ) {
5030
-	if ( version_compare( PHP_VERSION, '5.2.5', '>=' ) )
5031
-		$trace = debug_backtrace( false );
5029
+function wp_debug_backtrace_summary($ignore_class = null, $skip_frames = 0, $pretty = true) {
5030
+	if (version_compare(PHP_VERSION, '5.2.5', '>='))
5031
+		$trace = debug_backtrace(false);
5032 5032
 	else
5033 5033
 		$trace = debug_backtrace();
5034 5034
 
5035 5035
 	$caller = array();
5036
-	$check_class = ! is_null( $ignore_class );
5036
+	$check_class = ! is_null($ignore_class);
5037 5037
 	$skip_frames++; // skip this function
5038 5038
 
5039
-	foreach ( $trace as $call ) {
5040
-		if ( $skip_frames > 0 ) {
5039
+	foreach ($trace as $call) {
5040
+		if ($skip_frames > 0) {
5041 5041
 			$skip_frames--;
5042
-		} elseif ( isset( $call['class'] ) ) {
5043
-			if ( $check_class && $ignore_class == $call['class'] )
5042
+		} elseif (isset($call['class'])) {
5043
+			if ($check_class && $ignore_class == $call['class'])
5044 5044
 				continue; // Filter out calls
5045 5045
 
5046 5046
 			$caller[] = "{$call['class']}{$call['type']}{$call['function']}";
5047 5047
 		} else {
5048
-			if ( in_array( $call['function'], array( 'do_action', 'apply_filters' ) ) ) {
5048
+			if (in_array($call['function'], array('do_action', 'apply_filters'))) {
5049 5049
 				$caller[] = "{$call['function']}('{$call['args'][0]}')";
5050
-			} elseif ( in_array( $call['function'], array( 'include', 'include_once', 'require', 'require_once' ) ) ) {
5051
-				$caller[] = $call['function'] . "('" . str_replace( array( WP_CONTENT_DIR, ABSPATH ) , '', $call['args'][0] ) . "')";
5050
+			} elseif (in_array($call['function'], array('include', 'include_once', 'require', 'require_once'))) {
5051
+				$caller[] = $call['function']."('".str_replace(array(WP_CONTENT_DIR, ABSPATH), '', $call['args'][0])."')";
5052 5052
 			} else {
5053 5053
 				$caller[] = $call['function'];
5054 5054
 			}
5055 5055
 		}
5056 5056
 	}
5057
-	if ( $pretty )
5058
-		return join( ', ', array_reverse( $caller ) );
5057
+	if ($pretty)
5058
+		return join(', ', array_reverse($caller));
5059 5059
 	else
5060 5060
 		return $caller;
5061 5061
 }
@@ -5071,11 +5071,11 @@  discard block
 block discarded – undo
5071 5071
  *
5072 5072
  * @return array List of ids not present in the cache.
5073 5073
  */
5074
-function _get_non_cached_ids( $object_ids, $cache_key ) {
5074
+function _get_non_cached_ids($object_ids, $cache_key) {
5075 5075
 	$clean = array();
5076
-	foreach ( $object_ids as $id ) {
5076
+	foreach ($object_ids as $id) {
5077 5077
 		$id = (int) $id;
5078
-		if ( !wp_cache_get( $id, $cache_key ) ) {
5078
+		if ( ! wp_cache_get($id, $cache_key)) {
5079 5079
 			$clean[] = $id;
5080 5080
 		}
5081 5081
 	}
@@ -5092,15 +5092,15 @@  discard block
 block discarded – undo
5092 5092
  * @return bool Whether the device is able to upload files.
5093 5093
  */
5094 5094
 function _device_can_upload() {
5095
-	if ( ! wp_is_mobile() )
5095
+	if ( ! wp_is_mobile())
5096 5096
 		return true;
5097 5097
 
5098 5098
 	$ua = $_SERVER['HTTP_USER_AGENT'];
5099 5099
 
5100
-	if ( strpos($ua, 'iPhone') !== false
5100
+	if (strpos($ua, 'iPhone') !== false
5101 5101
 		|| strpos($ua, 'iPad') !== false
5102
-		|| strpos($ua, 'iPod') !== false ) {
5103
-			return preg_match( '#OS ([\d_]+) like Mac OS X#', $ua, $version ) && version_compare( $version[1], '6', '>=' );
5102
+		|| strpos($ua, 'iPod') !== false) {
5103
+			return preg_match('#OS ([\d_]+) like Mac OS X#', $ua, $version) && version_compare($version[1], '6', '>=');
5104 5104
 	}
5105 5105
 
5106 5106
 	return true;
@@ -5114,11 +5114,11 @@  discard block
 block discarded – undo
5114 5114
  * @param string $path The resource path or URL.
5115 5115
  * @return bool True if the path is a stream URL.
5116 5116
  */
5117
-function wp_is_stream( $path ) {
5117
+function wp_is_stream($path) {
5118 5118
 	$wrappers = stream_get_wrappers();
5119
-	$wrappers_re = '(' . join('|', $wrappers) . ')';
5119
+	$wrappers_re = '('.join('|', $wrappers).')';
5120 5120
 
5121
-	return preg_match( "!^$wrappers_re://!", $path ) === 1;
5121
+	return preg_match("!^$wrappers_re://!", $path) === 1;
5122 5122
 }
5123 5123
 
5124 5124
 /**
@@ -5134,7 +5134,7 @@  discard block
 block discarded – undo
5134 5134
  * @param  string $source_date The date to filter.
5135 5135
  * @return bool True if valid date, false if not valid date.
5136 5136
  */
5137
-function wp_checkdate( $month, $day, $year, $source_date ) {
5137
+function wp_checkdate($month, $day, $year, $source_date) {
5138 5138
 	/**
5139 5139
 	 * Filters whether the given date is valid for the Gregorian calendar.
5140 5140
 	 *
@@ -5143,7 +5143,7 @@  discard block
 block discarded – undo
5143 5143
 	 * @param bool   $checkdate   Whether the given date is valid.
5144 5144
 	 * @param string $source_date Date to check.
5145 5145
 	 */
5146
-	return apply_filters( 'wp_checkdate', checkdate( $month, $day, $year ), $source_date );
5146
+	return apply_filters('wp_checkdate', checkdate($month, $day, $year), $source_date);
5147 5147
 }
5148 5148
 
5149 5149
 /**
@@ -5158,15 +5158,15 @@  discard block
 block discarded – undo
5158 5158
  * @since 3.6.0
5159 5159
  */
5160 5160
 function wp_auth_check_load() {
5161
-	if ( ! is_admin() && ! is_user_logged_in() )
5161
+	if ( ! is_admin() && ! is_user_logged_in())
5162 5162
 		return;
5163 5163
 
5164
-	if ( defined( 'IFRAME_REQUEST' ) )
5164
+	if (defined('IFRAME_REQUEST'))
5165 5165
 		return;
5166 5166
 
5167 5167
 	$screen = get_current_screen();
5168
-	$hidden = array( 'update', 'update-network', 'update-core', 'update-core-network', 'upgrade', 'upgrade-network', 'network' );
5169
-	$show = ! in_array( $screen->id, $hidden );
5168
+	$hidden = array('update', 'update-network', 'update-core', 'update-core-network', 'upgrade', 'upgrade-network', 'network');
5169
+	$show = ! in_array($screen->id, $hidden);
5170 5170
 
5171 5171
 	/**
5172 5172
 	 * Filters whether to load the authentication check.
@@ -5179,12 +5179,12 @@  discard block
 block discarded – undo
5179 5179
 	 * @param bool      $show   Whether to load the authentication check.
5180 5180
 	 * @param WP_Screen $screen The current screen object.
5181 5181
 	 */
5182
-	if ( apply_filters( 'wp_auth_check_load', $show, $screen ) ) {
5183
-		wp_enqueue_style( 'wp-auth-check' );
5184
-		wp_enqueue_script( 'wp-auth-check' );
5182
+	if (apply_filters('wp_auth_check_load', $show, $screen)) {
5183
+		wp_enqueue_style('wp-auth-check');
5184
+		wp_enqueue_script('wp-auth-check');
5185 5185
 
5186
-		add_action( 'admin_print_footer_scripts', 'wp_auth_check_html', 5 );
5187
-		add_action( 'wp_print_footer_scripts', 'wp_auth_check_html', 5 );
5186
+		add_action('admin_print_footer_scripts', 'wp_auth_check_html', 5);
5187
+		add_action('wp_print_footer_scripts', 'wp_auth_check_html', 5);
5188 5188
 	}
5189 5189
 }
5190 5190
 
@@ -5195,8 +5195,8 @@  discard block
 block discarded – undo
5195 5195
  */
5196 5196
 function wp_auth_check_html() {
5197 5197
 	$login_url = wp_login_url();
5198
-	$current_domain = ( is_ssl() ? 'https://' : 'http://' ) . $_SERVER['HTTP_HOST'];
5199
-	$same_domain = ( strpos( $login_url, $current_domain ) === 0 );
5198
+	$current_domain = (is_ssl() ? 'https://' : 'http://').$_SERVER['HTTP_HOST'];
5199
+	$same_domain = (strpos($login_url, $current_domain) === 0);
5200 5200
 
5201 5201
 	/**
5202 5202
 	 * Filters whether the authentication check originated at the same domain.
@@ -5205,26 +5205,26 @@  discard block
 block discarded – undo
5205 5205
 	 *
5206 5206
 	 * @param bool $same_domain Whether the authentication check originated at the same domain.
5207 5207
 	 */
5208
-	$same_domain = apply_filters( 'wp_auth_check_same_domain', $same_domain );
5208
+	$same_domain = apply_filters('wp_auth_check_same_domain', $same_domain);
5209 5209
 	$wrap_class = $same_domain ? 'hidden' : 'hidden fallback';
5210 5210
 
5211 5211
 	?>
5212 5212
 	<div id="wp-auth-check-wrap" class="<?php echo $wrap_class; ?>">
5213 5213
 	<div id="wp-auth-check-bg"></div>
5214 5214
 	<div id="wp-auth-check">
5215
-	<button type="button" class="wp-auth-check-close button-link"><span class="screen-reader-text"><?php _e( 'Close dialog' ); ?></span></button>
5215
+	<button type="button" class="wp-auth-check-close button-link"><span class="screen-reader-text"><?php _e('Close dialog'); ?></span></button>
5216 5216
 	<?php
5217 5217
 
5218
-	if ( $same_domain ) {
5218
+	if ($same_domain) {
5219 5219
 		?>
5220
-		<div id="wp-auth-check-form" class="loading" data-src="<?php echo esc_url( add_query_arg( array( 'interim-login' => 1 ), $login_url ) ); ?>"></div>
5220
+		<div id="wp-auth-check-form" class="loading" data-src="<?php echo esc_url(add_query_arg(array('interim-login' => 1), $login_url)); ?>"></div>
5221 5221
 		<?php
5222 5222
 	}
5223 5223
 
5224 5224
 	?>
5225 5225
 	<div class="wp-auth-fallback">
5226 5226
 		<p><b class="wp-auth-fallback-expired" tabindex="0"><?php _e('Session expired'); ?></b></p>
5227
-		<p><a href="<?php echo esc_url( $login_url ); ?>" target="_blank"><?php _e('Please log in again.'); ?></a>
5227
+		<p><a href="<?php echo esc_url($login_url); ?>" target="_blank"><?php _e('Please log in again.'); ?></a>
5228 5228
 		<?php _e('The login page will open in a new window. After logging in you can close it and return to this page.'); ?></p>
5229 5229
 	</div>
5230 5230
 	</div>
@@ -5245,8 +5245,8 @@  discard block
 block discarded – undo
5245 5245
  * @param array $response  The Heartbeat response.
5246 5246
  * @return array $response The Heartbeat response with 'wp-auth-check' value set.
5247 5247
  */
5248
-function wp_auth_check( $response ) {
5249
-	$response['wp-auth-check'] = is_user_logged_in() && empty( $GLOBALS['login_grace_period'] );
5248
+function wp_auth_check($response) {
5249
+	$response['wp-auth-check'] = is_user_logged_in() && empty($GLOBALS['login_grace_period']);
5250 5250
 	return $response;
5251 5251
 }
5252 5252
 
@@ -5266,10 +5266,10 @@  discard block
 block discarded – undo
5266 5266
  * @param string $tag An HTML tag name. Example: 'video'.
5267 5267
  * @return string Tag RegEx.
5268 5268
  */
5269
-function get_tag_regex( $tag ) {
5270
-	if ( empty( $tag ) )
5269
+function get_tag_regex($tag) {
5270
+	if (empty($tag))
5271 5271
 		return;
5272
-	return sprintf( '<%1$s[^<]*(?:>[\s\S]*<\/%1$s>|\s*\/>)', tag_escape( $tag ) );
5272
+	return sprintf('<%1$s[^<]*(?:>[\s\S]*<\/%1$s>|\s*\/>)', tag_escape($tag));
5273 5273
 }
5274 5274
 
5275 5275
 /**
@@ -5284,13 +5284,13 @@  discard block
 block discarded – undo
5284 5284
  * @param string $charset A charset name.
5285 5285
  * @return string The canonical form of the charset.
5286 5286
  */
5287
-function _canonical_charset( $charset ) {
5288
-	if ( 'utf-8' === strtolower( $charset ) || 'utf8' === strtolower( $charset) ) {
5287
+function _canonical_charset($charset) {
5288
+	if ('utf-8' === strtolower($charset) || 'utf8' === strtolower($charset)) {
5289 5289
 
5290 5290
 		return 'UTF-8';
5291 5291
 	}
5292 5292
 
5293
-	if ( 'iso-8859-1' === strtolower( $charset ) || 'iso8859-1' === strtolower( $charset ) ) {
5293
+	if ('iso-8859-1' === strtolower($charset) || 'iso8859-1' === strtolower($charset)) {
5294 5294
 
5295 5295
 		return 'ISO-8859-1';
5296 5296
 	}
@@ -5324,25 +5324,25 @@  discard block
 block discarded – undo
5324 5324
  * @param bool $reset Optional. Whether to reset the encoding back to a previously-set encoding.
5325 5325
  *                    Default false.
5326 5326
  */
5327
-function mbstring_binary_safe_encoding( $reset = false ) {
5327
+function mbstring_binary_safe_encoding($reset = false) {
5328 5328
 	static $encodings = array();
5329 5329
 	static $overloaded = null;
5330 5330
 
5331
-	if ( is_null( $overloaded ) )
5332
-		$overloaded = function_exists( 'mb_internal_encoding' ) && ( ini_get( 'mbstring.func_overload' ) & 2 );
5331
+	if (is_null($overloaded))
5332
+		$overloaded = function_exists('mb_internal_encoding') && (ini_get('mbstring.func_overload') & 2);
5333 5333
 
5334
-	if ( false === $overloaded )
5334
+	if (false === $overloaded)
5335 5335
 		return;
5336 5336
 
5337
-	if ( ! $reset ) {
5337
+	if ( ! $reset) {
5338 5338
 		$encoding = mb_internal_encoding();
5339
-		array_push( $encodings, $encoding );
5340
-		mb_internal_encoding( 'ISO-8859-1' );
5339
+		array_push($encodings, $encoding);
5340
+		mb_internal_encoding('ISO-8859-1');
5341 5341
 	}
5342 5342
 
5343
-	if ( $reset && $encodings ) {
5344
-		$encoding = array_pop( $encodings );
5345
-		mb_internal_encoding( $encoding );
5343
+	if ($reset && $encodings) {
5344
+		$encoding = array_pop($encodings);
5345
+		mb_internal_encoding($encoding);
5346 5346
 	}
5347 5347
 }
5348 5348
 
@@ -5354,7 +5354,7 @@  discard block
 block discarded – undo
5354 5354
  * @since 3.7.0
5355 5355
  */
5356 5356
 function reset_mbstring_encoding() {
5357
-	mbstring_binary_safe_encoding( true );
5357
+	mbstring_binary_safe_encoding(true);
5358 5358
 }
5359 5359
 
5360 5360
 /**
@@ -5367,12 +5367,12 @@  discard block
 block discarded – undo
5367 5367
  * @param mixed $var Boolean value to validate.
5368 5368
  * @return bool Whether the value is validated.
5369 5369
  */
5370
-function wp_validate_boolean( $var ) {
5371
-	if ( is_bool( $var ) ) {
5370
+function wp_validate_boolean($var) {
5371
+	if (is_bool($var)) {
5372 5372
 		return $var;
5373 5373
 	}
5374 5374
 
5375
-	if ( is_string( $var ) && 'false' === strtolower( $var ) ) {
5375
+	if (is_string($var) && 'false' === strtolower($var)) {
5376 5376
 		return false;
5377 5377
 	}
5378 5378
 
@@ -5386,7 +5386,7 @@  discard block
 block discarded – undo
5386 5386
  *
5387 5387
  * @param string $file The path to the file to delete.
5388 5388
  */
5389
-function wp_delete_file( $file ) {
5389
+function wp_delete_file($file) {
5390 5390
 	/**
5391 5391
 	 * Filters the path of the file to delete.
5392 5392
 	 *
@@ -5394,9 +5394,9 @@  discard block
 block discarded – undo
5394 5394
 	 *
5395 5395
 	 * @param string $file Path to the file to delete.
5396 5396
 	 */
5397
-	$delete = apply_filters( 'wp_delete_file', $file );
5398
-	if ( ! empty( $delete ) ) {
5399
-		@unlink( $delete );
5397
+	$delete = apply_filters('wp_delete_file', $file);
5398
+	if ( ! empty($delete)) {
5399
+		@unlink($delete);
5400 5400
 	}
5401 5401
 }
5402 5402
 
@@ -5410,12 +5410,12 @@  discard block
 block discarded – undo
5410 5410
 function wp_post_preview_js() {
5411 5411
 	global $post;
5412 5412
 
5413
-	if ( ! is_preview() || empty( $post ) ) {
5413
+	if ( ! is_preview() || empty($post)) {
5414 5414
 		return;
5415 5415
 	}
5416 5416
 
5417 5417
 	// Has to match the window name used in post_submit_meta_box()
5418
-	$name = 'wp-preview-' . (int) $post->ID;
5418
+	$name = 'wp-preview-'.(int) $post->ID;
5419 5419
 
5420 5420
 	?>
5421 5421
 	<script>
@@ -5445,11 +5445,11 @@  discard block
 block discarded – undo
5445 5445
  * @param string $date_string Date string to parse and format.
5446 5446
  * @return string Date formatted for ISO8601/RFC3339.
5447 5447
  */
5448
-function mysql_to_rfc3339( $date_string ) {
5449
-	$formatted = mysql2date( 'c', $date_string, false );
5448
+function mysql_to_rfc3339($date_string) {
5449
+	$formatted = mysql2date('c', $date_string, false);
5450 5450
 
5451 5451
 	// Strip timezone information
5452
-	return preg_replace( '/(?:Z|[+-]\d{2}(?::\d{2})?)$/', '', $formatted );
5452
+	return preg_replace('/(?:Z|[+-]\d{2}(?::\d{2})?)$/', '', $formatted);
5453 5453
 }
5454 5454
 
5455 5455
 /**
@@ -5465,24 +5465,24 @@  discard block
 block discarded – undo
5465 5465
  *                        invoked. Default 'admin'.
5466 5466
  * @return bool|int|string The limit that was set or false on failure.
5467 5467
  */
5468
-function wp_raise_memory_limit( $context = 'admin' ) {
5468
+function wp_raise_memory_limit($context = 'admin') {
5469 5469
 	// Exit early if the limit cannot be changed.
5470
-	if ( false === wp_is_ini_value_changeable( 'memory_limit' ) ) {
5470
+	if (false === wp_is_ini_value_changeable('memory_limit')) {
5471 5471
 		return false;
5472 5472
 	}
5473 5473
 
5474
-	$current_limit     = @ini_get( 'memory_limit' );
5475
-	$current_limit_int = wp_convert_hr_to_bytes( $current_limit );
5474
+	$current_limit     = @ini_get('memory_limit');
5475
+	$current_limit_int = wp_convert_hr_to_bytes($current_limit);
5476 5476
 
5477 5477
 	if ( -1 === $current_limit_int ) {
5478 5478
 		return false;
5479 5479
 	}
5480 5480
 
5481 5481
 	$wp_max_limit     = WP_MAX_MEMORY_LIMIT;
5482
-	$wp_max_limit_int = wp_convert_hr_to_bytes( $wp_max_limit );
5482
+	$wp_max_limit_int = wp_convert_hr_to_bytes($wp_max_limit);
5483 5483
 	$filtered_limit   = $wp_max_limit;
5484 5484
 
5485
-	switch ( $context ) {
5485
+	switch ($context) {
5486 5486
 		case 'admin':
5487 5487
 			/**
5488 5488
 			 * Filters the maximum memory limit available for administration screens.
@@ -5502,7 +5502,7 @@  discard block
 block discarded – undo
5502 5502
 			 * @param int|string $filtered_limit The maximum WordPress memory limit. Accepts an integer
5503 5503
 			 *                                   (bytes), or a shorthand string notation, such as '256M'.
5504 5504
 			 */
5505
-			$filtered_limit = apply_filters( 'admin_memory_limit', $filtered_limit );
5505
+			$filtered_limit = apply_filters('admin_memory_limit', $filtered_limit);
5506 5506
 			break;
5507 5507
 
5508 5508
 		case 'image':
@@ -5518,7 +5518,7 @@  discard block
 block discarded – undo
5518 5518
 			 *                                   Accepts an integer (bytes), or a shorthand string
5519 5519
 			 *                                   notation, such as '256M'.
5520 5520
 			 */
5521
-			$filtered_limit = apply_filters( 'image_memory_limit', $filtered_limit );
5521
+			$filtered_limit = apply_filters('image_memory_limit', $filtered_limit);
5522 5522
 			break;
5523 5523
 
5524 5524
 		default:
@@ -5536,20 +5536,20 @@  discard block
 block discarded – undo
5536 5536
 			 *                                   whichever is higher. Accepts an integer (bytes), or a
5537 5537
 			 *                                   shorthand string notation, such as '256M'.
5538 5538
 			 */
5539
-			$filtered_limit = apply_filters( "{$context}_memory_limit", $filtered_limit );
5539
+			$filtered_limit = apply_filters("{$context}_memory_limit", $filtered_limit);
5540 5540
 			break;
5541 5541
 	}
5542 5542
 
5543
-	$filtered_limit_int = wp_convert_hr_to_bytes( $filtered_limit );
5543
+	$filtered_limit_int = wp_convert_hr_to_bytes($filtered_limit);
5544 5544
 
5545
-	if ( -1 === $filtered_limit_int || ( $filtered_limit_int > $wp_max_limit_int && $filtered_limit_int > $current_limit_int ) ) {
5546
-		if ( false !== @ini_set( 'memory_limit', $filtered_limit ) ) {
5545
+	if ( -1 === $filtered_limit_int || ($filtered_limit_int > $wp_max_limit_int && $filtered_limit_int > $current_limit_int) ) {
5546
+		if (false !== @ini_set('memory_limit', $filtered_limit)) {
5547 5547
 			return $filtered_limit;
5548 5548
 		} else {
5549 5549
 			return false;
5550 5550
 		}
5551 5551
 	} elseif ( -1 === $wp_max_limit_int || $wp_max_limit_int > $current_limit_int ) {
5552
-		if ( false !== @ini_set( 'memory_limit', $wp_max_limit ) ) {
5552
+		if (false !== @ini_set('memory_limit', $wp_max_limit)) {
5553 5553
 			return $wp_max_limit;
5554 5554
 		} else {
5555 5555
 			return false;
@@ -5567,12 +5567,12 @@  discard block
 block discarded – undo
5567 5567
  * @return string UUID.
5568 5568
  */
5569 5569
 function wp_generate_uuid4() {
5570
-	return sprintf( '%04x%04x-%04x-%04x-%04x-%04x%04x%04x',
5571
-		mt_rand( 0, 0xffff ), mt_rand( 0, 0xffff ),
5572
-		mt_rand( 0, 0xffff ),
5573
-		mt_rand( 0, 0x0fff ) | 0x4000,
5574
-		mt_rand( 0, 0x3fff ) | 0x8000,
5575
-		mt_rand( 0, 0xffff ), mt_rand( 0, 0xffff ), mt_rand( 0, 0xffff )
5570
+	return sprintf('%04x%04x-%04x-%04x-%04x-%04x%04x%04x',
5571
+		mt_rand(0, 0xffff), mt_rand(0, 0xffff),
5572
+		mt_rand(0, 0xffff),
5573
+		mt_rand(0, 0x0fff) | 0x4000,
5574
+		mt_rand(0, 0x3fff) | 0x8000,
5575
+		mt_rand(0, 0xffff), mt_rand(0, 0xffff), mt_rand(0, 0xffff)
5576 5576
 	);
5577 5577
 }
5578 5578
 
@@ -5585,12 +5585,12 @@  discard block
 block discarded – undo
5585 5585
  *
5586 5586
  * @return string $last_changed UNIX timestamp with microseconds representing when the group was last changed.
5587 5587
  */
5588
-function wp_cache_get_last_changed( $group ) {
5589
-	$last_changed = wp_cache_get( 'last_changed', $group );
5588
+function wp_cache_get_last_changed($group) {
5589
+	$last_changed = wp_cache_get('last_changed', $group);
5590 5590
 
5591
-	if ( ! $last_changed ) {
5591
+	if ( ! $last_changed) {
5592 5592
 		$last_changed = microtime();
5593
-		wp_cache_set( 'last_changed', $last_changed, $group );
5593
+		wp_cache_set('last_changed', $last_changed, $group);
5594 5594
 	}
5595 5595
 
5596 5596
 	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.
@@ -298,11 +302,13 @@  discard block
 block discarded – undo
298 302
 	// The day of the week from the timestamp.
299 303
 	$weekday = date( 'w', $day );
300 304
 
301
-	if ( !is_numeric($start_of_week) )
302
-		$start_of_week = get_option( 'start_of_week' );
305
+	if ( !is_numeric($start_of_week) ) {
306
+			$start_of_week = get_option( 'start_of_week' );
307
+	}
303 308
 
304
-	if ( $weekday < $start_of_week )
305
-		$weekday += 7;
309
+	if ( $weekday < $start_of_week ) {
310
+			$weekday += 7;
311
+	}
306 312
 
307 313
 	// The most recent week start day on or before $day.
308 314
 	$start = $day - DAY_IN_SECONDS * ( $weekday - $start_of_week );
@@ -321,8 +327,10 @@  discard block
 block discarded – undo
321 327
  * @return mixed Unserialized data can be any type.
322 328
  */
323 329
 function maybe_unserialize( $original ) {
324
-	if ( is_serialized( $original ) ) // don't attempt to unserialize data that wasn't serialized going in
330
+	if ( is_serialized( $original ) ) {
331
+		// don't attempt to unserialize data that wasn't serialized going in
325 332
 		return @unserialize( $original );
333
+	}
326 334
 	return $original;
327 335
 }
328 336
 
@@ -362,13 +370,16 @@  discard block
 block discarded – undo
362 370
 		$semicolon = strpos( $data, ';' );
363 371
 		$brace     = strpos( $data, '}' );
364 372
 		// Either ; or } must exist.
365
-		if ( false === $semicolon && false === $brace )
366
-			return false;
373
+		if ( false === $semicolon && false === $brace ) {
374
+					return false;
375
+		}
367 376
 		// But neither must be in the first X characters.
368
-		if ( false !== $semicolon && $semicolon < 3 )
369
-			return false;
370
-		if ( false !== $brace && $brace < 4 )
371
-			return false;
377
+		if ( false !== $semicolon && $semicolon < 3 ) {
378
+					return false;
379
+		}
380
+		if ( false !== $brace && $brace < 4 ) {
381
+					return false;
382
+		}
372 383
 	}
373 384
 	$token = $data[0];
374 385
 	switch ( $token ) {
@@ -431,14 +442,16 @@  discard block
 block discarded – undo
431 442
  * @return mixed A scalar data
432 443
  */
433 444
 function maybe_serialize( $data ) {
434
-	if ( is_array( $data ) || is_object( $data ) )
435
-		return serialize( $data );
445
+	if ( is_array( $data ) || is_object( $data ) ) {
446
+			return serialize( $data );
447
+	}
436 448
 
437 449
 	// Double serialization is required for backward compatibility.
438 450
 	// See https://core.trac.wordpress.org/ticket/12930
439 451
 	// Also the world will end. See WP 3.6.1.
440
-	if ( is_serialized( $data, false ) )
441
-		return serialize( $data );
452
+	if ( is_serialized( $data, false ) ) {
453
+			return serialize( $data );
454
+	}
442 455
 
443 456
 	return $data;
444 457
 }
@@ -566,20 +579,23 @@  discard block
 block discarded – undo
566 579
 	foreach ( $pung as $link_test ) {
567 580
 		if ( ! in_array( $link_test, $post_links_temp ) ) { // link no longer in post
568 581
 			$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 ) . '%') );
569
-			foreach ( $mids as $mid )
570
-				delete_metadata_by_mid( 'post', $mid );
582
+			foreach ( $mids as $mid ) {
583
+							delete_metadata_by_mid( 'post', $mid );
584
+			}
571 585
 		}
572 586
 	}
573 587
 
574 588
 	foreach ( (array) $post_links_temp as $link_test ) {
575 589
 		if ( !in_array( $link_test, $pung ) ) { // If we haven't pung it already
576 590
 			$test = @parse_url( $link_test );
577
-			if ( false === $test )
578
-				continue;
579
-			if ( isset( $test['query'] ) )
580
-				$post_links[] = $link_test;
581
-			elseif ( isset($test['path']) && ( $test['path'] != '/' ) &&  ($test['path'] != '' ) )
582
-				$post_links[] = $link_test;
591
+			if ( false === $test ) {
592
+							continue;
593
+			}
594
+			if ( isset( $test['query'] ) ) {
595
+							$post_links[] = $link_test;
596
+			} elseif ( isset($test['path']) && ( $test['path'] != '/' ) &&  ($test['path'] != '' ) ) {
597
+							$post_links[] = $link_test;
598
+			}
583 599
 		}
584 600
 	}
585 601
 
@@ -637,13 +653,15 @@  discard block
 block discarded – undo
637 653
  * @return bool|string False on failure, headers on success.
638 654
  */
639 655
 function wp_get_http_headers( $url, $deprecated = false ) {
640
-	if ( !empty( $deprecated ) )
641
-		_deprecated_argument( __FUNCTION__, '2.7.0' );
656
+	if ( !empty( $deprecated ) ) {
657
+			_deprecated_argument( __FUNCTION__, '2.7.0' );
658
+	}
642 659
 
643 660
 	$response = wp_safe_remote_head( $url );
644 661
 
645
-	if ( is_wp_error( $response ) )
646
-		return false;
662
+	if ( is_wp_error( $response ) ) {
663
+			return false;
664
+	}
647 665
 
648 666
 	return wp_remote_retrieve_headers( $response );
649 667
 }
@@ -661,11 +679,12 @@  discard block
 block discarded – undo
661 679
  */
662 680
 function is_new_day() {
663 681
 	global $currentday, $previousday;
664
-	if ( $currentday != $previousday )
665
-		return 1;
666
-	else
667
-		return 0;
668
-}
682
+	if ( $currentday != $previousday ) {
683
+			return 1;
684
+	} else {
685
+			return 0;
686
+	}
687
+	}
669 688
 
670 689
 /**
671 690
  * Build URL query based on an associative and, or indexed array.
@@ -708,27 +727,33 @@  discard block
 block discarded – undo
708 727
 	$ret = array();
709 728
 
710 729
 	foreach ( (array) $data as $k => $v ) {
711
-		if ( $urlencode)
712
-			$k = urlencode($k);
713
-		if ( is_int($k) && $prefix != null )
714
-			$k = $prefix.$k;
715
-		if ( !empty($key) )
716
-			$k = $key . '%5B' . $k . '%5D';
717
-		if ( $v === null )
718
-			continue;
719
-		elseif ( $v === false )
720
-			$v = '0';
730
+		if ( $urlencode) {
731
+					$k = urlencode($k);
732
+		}
733
+		if ( is_int($k) && $prefix != null ) {
734
+					$k = $prefix.$k;
735
+		}
736
+		if ( !empty($key) ) {
737
+					$k = $key . '%5B' . $k . '%5D';
738
+		}
739
+		if ( $v === null ) {
740
+					continue;
741
+		} elseif ( $v === false ) {
742
+					$v = '0';
743
+		}
721 744
 
722
-		if ( is_array($v) || is_object($v) )
723
-			array_push($ret,_http_build_query($v, '', $sep, $k, $urlencode));
724
-		elseif ( $urlencode )
725
-			array_push($ret, $k.'='.urlencode($v));
726
-		else
727
-			array_push($ret, $k.'='.$v);
745
+		if ( is_array($v) || is_object($v) ) {
746
+					array_push($ret,_http_build_query($v, '', $sep, $k, $urlencode));
747
+		} elseif ( $urlencode ) {
748
+					array_push($ret, $k.'='.urlencode($v));
749
+		} else {
750
+					array_push($ret, $k.'='.$v);
751
+		}
728 752
 	}
729 753
 
730
-	if ( null === $sep )
731
-		$sep = ini_get('arg_separator.output');
754
+	if ( null === $sep ) {
755
+			$sep = ini_get('arg_separator.output');
756
+	}
732 757
 
733 758
 	return implode($sep, $ret);
734 759
 }
@@ -771,21 +796,24 @@  discard block
 block discarded – undo
771 796
 function add_query_arg() {
772 797
 	$args = func_get_args();
773 798
 	if ( is_array( $args[0] ) ) {
774
-		if ( count( $args ) < 2 || false === $args[1] )
775
-			$uri = $_SERVER['REQUEST_URI'];
776
-		else
777
-			$uri = $args[1];
799
+		if ( count( $args ) < 2 || false === $args[1] ) {
800
+					$uri = $_SERVER['REQUEST_URI'];
801
+		} else {
802
+					$uri = $args[1];
803
+		}
778 804
 	} else {
779
-		if ( count( $args ) < 3 || false === $args[2] )
780
-			$uri = $_SERVER['REQUEST_URI'];
781
-		else
782
-			$uri = $args[2];
805
+		if ( count( $args ) < 3 || false === $args[2] ) {
806
+					$uri = $_SERVER['REQUEST_URI'];
807
+		} else {
808
+					$uri = $args[2];
809
+		}
783 810
 	}
784 811
 
785
-	if ( $frag = strstr( $uri, '#' ) )
786
-		$uri = substr( $uri, 0, -strlen( $frag ) );
787
-	else
788
-		$frag = '';
812
+	if ( $frag = strstr( $uri, '#' ) ) {
813
+			$uri = substr( $uri, 0, -strlen( $frag ) );
814
+	} else {
815
+			$frag = '';
816
+	}
789 817
 
790 818
 	if ( 0 === stripos( $uri, 'http://' ) ) {
791 819
 		$protocol = 'http://';
@@ -819,8 +847,9 @@  discard block
 block discarded – undo
819 847
 	}
820 848
 
821 849
 	foreach ( $qs as $k => $v ) {
822
-		if ( $v === false )
823
-			unset( $qs[$k] );
850
+		if ( $v === false ) {
851
+					unset( $qs[$k] );
852
+		}
824 853
 	}
825 854
 
826 855
 	$ret = build_query( $qs );
@@ -842,8 +871,9 @@  discard block
 block discarded – undo
842 871
  */
843 872
 function remove_query_arg( $key, $query = false ) {
844 873
 	if ( is_array( $key ) ) { // removing multiple keys
845
-		foreach ( $key as $k )
846
-			$query = add_query_arg( $k, false, $query );
874
+		foreach ( $key as $k ) {
875
+					$query = add_query_arg( $k, false, $query );
876
+		}
847 877
 		return $query;
848 878
 	}
849 879
 	return add_query_arg( $key, false, $query );
@@ -925,16 +955,18 @@  discard block
 block discarded – undo
925 955
 function wp_remote_fopen( $uri ) {
926 956
 	$parsed_url = @parse_url( $uri );
927 957
 
928
-	if ( !$parsed_url || !is_array( $parsed_url ) )
929
-		return false;
958
+	if ( !$parsed_url || !is_array( $parsed_url ) ) {
959
+			return false;
960
+	}
930 961
 
931 962
 	$options = array();
932 963
 	$options['timeout'] = 10;
933 964
 
934 965
 	$response = wp_safe_remote_get( $uri, $options );
935 966
 
936
-	if ( is_wp_error( $response ) )
937
-		return false;
967
+	if ( is_wp_error( $response ) ) {
968
+			return false;
969
+	}
938 970
 
939 971
 	return wp_remote_retrieve_body( $response );
940 972
 }
@@ -954,9 +986,10 @@  discard block
 block discarded – undo
954 986
 	global $wp, $wp_query, $wp_the_query;
955 987
 	$wp->main( $query_vars );
956 988
 
957
-	if ( !isset($wp_the_query) )
958
-		$wp_the_query = $wp_query;
959
-}
989
+	if ( !isset($wp_the_query) ) {
990
+			$wp_the_query = $wp_query;
991
+	}
992
+	}
960 993
 
961 994
 /**
962 995
  * Retrieve the description for the HTTP status.
@@ -1041,11 +1074,12 @@  discard block
 block discarded – undo
1041 1074
 		);
1042 1075
 	}
1043 1076
 
1044
-	if ( isset( $wp_header_to_desc[$code] ) )
1045
-		return $wp_header_to_desc[$code];
1046
-	else
1047
-		return '';
1048
-}
1077
+	if ( isset( $wp_header_to_desc[$code] ) ) {
1078
+			return $wp_header_to_desc[$code];
1079
+	} else {
1080
+			return '';
1081
+	}
1082
+	}
1049 1083
 
1050 1084
 /**
1051 1085
  * Set HTTP status header.
@@ -1069,8 +1103,8 @@  discard block
 block discarded – undo
1069 1103
 
1070 1104
 	$protocol = wp_get_server_protocol();
1071 1105
 	$status_header = "$protocol $code $description";
1072
-	if ( function_exists( 'apply_filters' ) )
1073
-
1106
+	if ( function_exists( 'apply_filters' ) ) {
1107
+	
1074 1108
 		/**
1075 1109
 		 * Filters an HTTP status header.
1076 1110
 		 *
@@ -1082,6 +1116,7 @@  discard block
 block discarded – undo
1082 1116
 		 * @param string $protocol      Server protocol.
1083 1117
 		 */
1084 1118
 		$status_header = apply_filters( 'status_header', $status_header, $code, $description, $protocol );
1119
+	}
1085 1120
 
1086 1121
 	@header( $status_header, true, $code );
1087 1122
 }
@@ -1153,9 +1188,10 @@  discard block
 block discarded – undo
1153 1188
 		}
1154 1189
 	}
1155 1190
 
1156
-	foreach ( $headers as $name => $field_value )
1157
-		@header("{$name}: {$field_value}");
1158
-}
1191
+	foreach ( $headers as $name => $field_value ) {
1192
+			@header("{$name}: {$field_value}");
1193
+	}
1194
+	}
1159 1195
 
1160 1196
 /**
1161 1197
  * Set the headers for caching for 10 days with JavaScript content type.
@@ -1230,8 +1266,9 @@  discard block
 block discarded – undo
1230 1266
 	// Remove the pad, if present.
1231 1267
 	$feed = preg_replace( '/^_+/', '', $feed );
1232 1268
 
1233
-	if ( $feed == '' || $feed == 'feed' )
1234
-		$feed = get_default_feed();
1269
+	if ( $feed == '' || $feed == 'feed' ) {
1270
+			$feed = get_default_feed();
1271
+	}
1235 1272
 
1236 1273
 	if ( ! has_action( "do_feed_{$feed}" ) ) {
1237 1274
 		wp_die( __( 'ERROR: This is not a valid feed template.' ), '', array( 'response' => 404 ) );
@@ -1284,11 +1321,12 @@  discard block
 block discarded – undo
1284 1321
  * @param bool $for_comments True for the comment feed, false for normal feed.
1285 1322
  */
1286 1323
 function do_feed_rss2( $for_comments ) {
1287
-	if ( $for_comments )
1288
-		load_template( ABSPATH . WPINC . '/feed-rss2-comments.php' );
1289
-	else
1290
-		load_template( ABSPATH . WPINC . '/feed-rss2.php' );
1291
-}
1324
+	if ( $for_comments ) {
1325
+			load_template( ABSPATH . WPINC . '/feed-rss2-comments.php' );
1326
+	} else {
1327
+			load_template( ABSPATH . WPINC . '/feed-rss2.php' );
1328
+	}
1329
+	}
1292 1330
 
1293 1331
 /**
1294 1332
  * Load either Atom comment feed or Atom posts feed.
@@ -1300,11 +1338,12 @@  discard block
 block discarded – undo
1300 1338
  * @param bool $for_comments True for the comment feed, false for normal feed.
1301 1339
  */
1302 1340
 function do_feed_atom( $for_comments ) {
1303
-	if ($for_comments)
1304
-		load_template( ABSPATH . WPINC . '/feed-atom-comments.php');
1305
-	else
1306
-		load_template( ABSPATH . WPINC . '/feed-atom.php' );
1307
-}
1341
+	if ($for_comments) {
1342
+			load_template( ABSPATH . WPINC . '/feed-atom-comments.php');
1343
+	} else {
1344
+			load_template( ABSPATH . WPINC . '/feed-atom.php' );
1345
+	}
1346
+	}
1308 1347
 
1309 1348
 /**
1310 1349
  * Display the robots.txt file content.
@@ -1368,29 +1407,33 @@  discard block
 block discarded – undo
1368 1407
 	 * Check cache first. If options table goes away and we have true
1369 1408
 	 * cached, oh well.
1370 1409
 	 */
1371
-	if ( wp_cache_get( 'is_blog_installed' ) )
1372
-		return true;
1410
+	if ( wp_cache_get( 'is_blog_installed' ) ) {
1411
+			return true;
1412
+	}
1373 1413
 
1374 1414
 	$suppress = $wpdb->suppress_errors();
1375 1415
 	if ( ! wp_installing() ) {
1376 1416
 		$alloptions = wp_load_alloptions();
1377 1417
 	}
1378 1418
 	// If siteurl is not set to autoload, check it specifically
1379
-	if ( !isset( $alloptions['siteurl'] ) )
1380
-		$installed = $wpdb->get_var( "SELECT option_value FROM $wpdb->options WHERE option_name = 'siteurl'" );
1381
-	else
1382
-		$installed = $alloptions['siteurl'];
1419
+	if ( !isset( $alloptions['siteurl'] ) ) {
1420
+			$installed = $wpdb->get_var( "SELECT option_value FROM $wpdb->options WHERE option_name = 'siteurl'" );
1421
+	} else {
1422
+			$installed = $alloptions['siteurl'];
1423
+	}
1383 1424
 	$wpdb->suppress_errors( $suppress );
1384 1425
 
1385 1426
 	$installed = !empty( $installed );
1386 1427
 	wp_cache_set( 'is_blog_installed', $installed );
1387 1428
 
1388
-	if ( $installed )
1389
-		return true;
1429
+	if ( $installed ) {
1430
+			return true;
1431
+	}
1390 1432
 
1391 1433
 	// If visiting repair.php, return true and let it take over.
1392
-	if ( defined( 'WP_REPAIRING' ) )
1393
-		return true;
1434
+	if ( defined( 'WP_REPAIRING' ) ) {
1435
+			return true;
1436
+	}
1394 1437
 
1395 1438
 	$suppress = $wpdb->suppress_errors();
1396 1439
 
@@ -1402,13 +1445,16 @@  discard block
 block discarded – undo
1402 1445
 	$wp_tables = $wpdb->tables();
1403 1446
 	foreach ( $wp_tables as $table ) {
1404 1447
 		// The existence of custom user tables shouldn't suggest an insane state or prevent a clean install.
1405
-		if ( defined( 'CUSTOM_USER_TABLE' ) && CUSTOM_USER_TABLE == $table )
1406
-			continue;
1407
-		if ( defined( 'CUSTOM_USER_META_TABLE' ) && CUSTOM_USER_META_TABLE == $table )
1408
-			continue;
1448
+		if ( defined( 'CUSTOM_USER_TABLE' ) && CUSTOM_USER_TABLE == $table ) {
1449
+					continue;
1450
+		}
1451
+		if ( defined( 'CUSTOM_USER_META_TABLE' ) && CUSTOM_USER_META_TABLE == $table ) {
1452
+					continue;
1453
+		}
1409 1454
 
1410
-		if ( ! $wpdb->get_results( "DESCRIBE $table;" ) )
1411
-			continue;
1455
+		if ( ! $wpdb->get_results( "DESCRIBE $table;" ) ) {
1456
+					continue;
1457
+		}
1412 1458
 
1413 1459
 		// One or more tables exist. We are insane.
1414 1460
 
@@ -1476,11 +1522,13 @@  discard block
 block discarded – undo
1476 1522
 	$name = esc_attr( $name );
1477 1523
 	$nonce_field = '<input type="hidden" id="' . $name . '" name="' . $name . '" value="' . wp_create_nonce( $action ) . '" />';
1478 1524
 
1479
-	if ( $referer )
1480
-		$nonce_field .= wp_referer_field( false );
1525
+	if ( $referer ) {
1526
+			$nonce_field .= wp_referer_field( false );
1527
+	}
1481 1528
 
1482
-	if ( $echo )
1483
-		echo $nonce_field;
1529
+	if ( $echo ) {
1530
+			echo $nonce_field;
1531
+	}
1484 1532
 
1485 1533
 	return $nonce_field;
1486 1534
 }
@@ -1499,8 +1547,9 @@  discard block
 block discarded – undo
1499 1547
 function wp_referer_field( $echo = true ) {
1500 1548
 	$referer_field = '<input type="hidden" name="_wp_http_referer" value="'. esc_attr( wp_unslash( $_SERVER['REQUEST_URI'] ) ) . '" />';
1501 1549
 
1502
-	if ( $echo )
1503
-		echo $referer_field;
1550
+	if ( $echo ) {
1551
+			echo $referer_field;
1552
+	}
1504 1553
 	return $referer_field;
1505 1554
 }
1506 1555
 
@@ -1523,8 +1572,9 @@  discard block
 block discarded – undo
1523 1572
 		$ref = 'previous' == $jump_back_to ? wp_get_referer() : wp_unslash( $_SERVER['REQUEST_URI'] );
1524 1573
 	}
1525 1574
 	$orig_referer_field = '<input type="hidden" name="_wp_original_http_referer" value="' . esc_attr( $ref ) . '" />';
1526
-	if ( $echo )
1527
-		echo $orig_referer_field;
1575
+	if ( $echo ) {
1576
+			echo $orig_referer_field;
1577
+	}
1528 1578
 	return $orig_referer_field;
1529 1579
 }
1530 1580
 
@@ -1578,8 +1628,9 @@  discard block
 block discarded – undo
1578 1628
  * @return string|false False if no original referer or original referer if set.
1579 1629
  */
1580 1630
 function wp_get_original_referer() {
1581
-	if ( ! empty( $_REQUEST['_wp_original_http_referer'] ) && function_exists( 'wp_validate_redirect' ) )
1582
-		return wp_validate_redirect( wp_unslash( $_REQUEST['_wp_original_http_referer'] ), false );
1631
+	if ( ! empty( $_REQUEST['_wp_original_http_referer'] ) && function_exists( 'wp_validate_redirect' ) ) {
1632
+			return wp_validate_redirect( wp_unslash( $_REQUEST['_wp_original_http_referer'] ), false );
1633
+	}
1583 1634
 	return false;
1584 1635
 }
1585 1636
 
@@ -1614,11 +1665,13 @@  discard block
 block discarded – undo
1614 1665
 	 * Use rtrim() instead of untrailingslashit to avoid formatting.php dependency.
1615 1666
 	 */
1616 1667
 	$target = rtrim($target, '/');
1617
-	if ( empty($target) )
1618
-		$target = '/';
1668
+	if ( empty($target) ) {
1669
+			$target = '/';
1670
+	}
1619 1671
 
1620
-	if ( file_exists( $target ) )
1621
-		return @is_dir( $target );
1672
+	if ( file_exists( $target ) ) {
1673
+			return @is_dir( $target );
1674
+	}
1622 1675
 
1623 1676
 	// We need to find the permissions of the parent folder that exists and inherit that.
1624 1677
 	$target_parent = dirname( $target );
@@ -1667,15 +1720,18 @@  discard block
 block discarded – undo
1667 1720
 	 * This is definitive if true but fails if $path does not exist or contains
1668 1721
 	 * a symbolic link.
1669 1722
 	 */
1670
-	if ( realpath($path) == $path )
1671
-		return true;
1723
+	if ( realpath($path) == $path ) {
1724
+			return true;
1725
+	}
1672 1726
 
1673
-	if ( strlen($path) == 0 || $path[0] == '.' )
1674
-		return false;
1727
+	if ( strlen($path) == 0 || $path[0] == '.' ) {
1728
+			return false;
1729
+	}
1675 1730
 
1676 1731
 	// Windows allows absolute paths like this.
1677
-	if ( preg_match('#^[a-zA-Z]:\\\\#', $path) )
1678
-		return true;
1732
+	if ( preg_match('#^[a-zA-Z]:\\\\#', $path) ) {
1733
+			return true;
1734
+	}
1679 1735
 
1680 1736
 	// A path starting with / or \ is absolute; anything else is relative.
1681 1737
 	return ( $path[0] == '/' || $path[0] == '\\' );
@@ -1694,8 +1750,9 @@  discard block
 block discarded – undo
1694 1750
  * @return string The path with the base or absolute path.
1695 1751
  */
1696 1752
 function path_join( $base, $path ) {
1697
-	if ( path_is_absolute($path) )
1698
-		return $path;
1753
+	if ( path_is_absolute($path) ) {
1754
+			return $path;
1755
+	}
1699 1756
 
1700 1757
 	return rtrim($base, '/') . '/' . ltrim($path, '/');
1701 1758
 }
@@ -1742,25 +1799,30 @@  discard block
 block discarded – undo
1742 1799
  */
1743 1800
 function get_temp_dir() {
1744 1801
 	static $temp = '';
1745
-	if ( defined('WP_TEMP_DIR') )
1746
-		return trailingslashit(WP_TEMP_DIR);
1802
+	if ( defined('WP_TEMP_DIR') ) {
1803
+			return trailingslashit(WP_TEMP_DIR);
1804
+	}
1747 1805
 
1748
-	if ( $temp )
1749
-		return trailingslashit( $temp );
1806
+	if ( $temp ) {
1807
+			return trailingslashit( $temp );
1808
+	}
1750 1809
 
1751 1810
 	if ( function_exists('sys_get_temp_dir') ) {
1752 1811
 		$temp = sys_get_temp_dir();
1753
-		if ( @is_dir( $temp ) && wp_is_writable( $temp ) )
1754
-			return trailingslashit( $temp );
1812
+		if ( @is_dir( $temp ) && wp_is_writable( $temp ) ) {
1813
+					return trailingslashit( $temp );
1814
+		}
1755 1815
 	}
1756 1816
 
1757 1817
 	$temp = ini_get('upload_tmp_dir');
1758
-	if ( @is_dir( $temp ) && wp_is_writable( $temp ) )
1759
-		return trailingslashit( $temp );
1818
+	if ( @is_dir( $temp ) && wp_is_writable( $temp ) ) {
1819
+			return trailingslashit( $temp );
1820
+	}
1760 1821
 
1761 1822
 	$temp = WP_CONTENT_DIR . '/';
1762
-	if ( is_dir( $temp ) && wp_is_writable( $temp ) )
1763
-		return $temp;
1823
+	if ( is_dir( $temp ) && wp_is_writable( $temp ) ) {
1824
+			return $temp;
1825
+	}
1764 1826
 
1765 1827
 	return '/tmp/';
1766 1828
 }
@@ -1779,11 +1841,12 @@  discard block
 block discarded – undo
1779 1841
  * @return bool Whether the path is writable.
1780 1842
  */
1781 1843
 function wp_is_writable( $path ) {
1782
-	if ( 'WIN' === strtoupper( substr( PHP_OS, 0, 3 ) ) )
1783
-		return win_is_writable( $path );
1784
-	else
1785
-		return @is_writable( $path );
1786
-}
1844
+	if ( 'WIN' === strtoupper( substr( PHP_OS, 0, 3 ) ) ) {
1845
+			return win_is_writable( $path );
1846
+	} else {
1847
+			return @is_writable( $path );
1848
+	}
1849
+	}
1787 1850
 
1788 1851
 /**
1789 1852
  * Workaround for Windows bug in is_writable() function
@@ -1811,11 +1874,13 @@  discard block
 block discarded – undo
1811 1874
 	// check tmp file for read/write capabilities
1812 1875
 	$should_delete_tmp_file = !file_exists( $path );
1813 1876
 	$f = @fopen( $path, 'a' );
1814
-	if ( $f === false )
1815
-		return false;
1877
+	if ( $f === false ) {
1878
+			return false;
1879
+	}
1816 1880
 	fclose( $f );
1817
-	if ( $should_delete_tmp_file )
1818
-		unlink( $path );
1881
+	if ( $should_delete_tmp_file ) {
1882
+			unlink( $path );
1883
+	}
1819 1884
 	return true;
1820 1885
 }
1821 1886
 
@@ -1941,10 +2006,11 @@  discard block
 block discarded – undo
1941 2006
 	}
1942 2007
 
1943 2008
 	if ( !$url = get_option( 'upload_url_path' ) ) {
1944
-		if ( empty($upload_path) || ( 'wp-content/uploads' == $upload_path ) || ( $upload_path == $dir ) )
1945
-			$url = WP_CONTENT_URL . '/uploads';
1946
-		else
1947
-			$url = trailingslashit( $siteurl ) . $upload_path;
2009
+		if ( empty($upload_path) || ( 'wp-content/uploads' == $upload_path ) || ( $upload_path == $dir ) ) {
2010
+					$url = WP_CONTENT_URL . '/uploads';
2011
+		} else {
2012
+					$url = trailingslashit( $siteurl ) . $upload_path;
2013
+		}
1948 2014
 	}
1949 2015
 
1950 2016
 	/*
@@ -1969,10 +2035,11 @@  discard block
 block discarded – undo
1969 2035
 			 * had wp-content/uploads for the main site.)
1970 2036
 			 */
1971 2037
 
1972
-			if ( defined( 'MULTISITE' ) )
1973
-				$ms_dir = '/sites/' . get_current_blog_id();
1974
-			else
1975
-				$ms_dir = '/' . get_current_blog_id();
2038
+			if ( defined( 'MULTISITE' ) ) {
2039
+							$ms_dir = '/sites/' . get_current_blog_id();
2040
+			} else {
2041
+							$ms_dir = '/' . get_current_blog_id();
2042
+			}
1976 2043
 
1977 2044
 			$dir .= $ms_dir;
1978 2045
 			$url .= $ms_dir;
@@ -1992,10 +2059,11 @@  discard block
 block discarded – undo
1992 2059
 			 * rewriting in multisite, the resulting URL is /files. (#WP22702 for background.)
1993 2060
 			 */
1994 2061
 
1995
-			if ( defined( 'BLOGUPLOADDIR' ) )
1996
-				$dir = untrailingslashit( BLOGUPLOADDIR );
1997
-			else
1998
-				$dir = ABSPATH . UPLOADS;
2062
+			if ( defined( 'BLOGUPLOADDIR' ) ) {
2063
+							$dir = untrailingslashit( BLOGUPLOADDIR );
2064
+			} else {
2065
+							$dir = ABSPATH . UPLOADS;
2066
+			}
1999 2067
 			$url = trailingslashit( $siteurl ) . 'files';
2000 2068
 		}
2001 2069
 	}
@@ -2006,8 +2074,9 @@  discard block
 block discarded – undo
2006 2074
 	$subdir = '';
2007 2075
 	if ( get_option( 'uploads_use_yearmonth_folders' ) ) {
2008 2076
 		// Generate the yearly and monthly dirs
2009
-		if ( !$time )
2010
-			$time = current_time( 'mysql' );
2077
+		if ( !$time ) {
2078
+					$time = current_time( 'mysql' );
2079
+		}
2011 2080
 		$y = substr( $time, 0, 4 );
2012 2081
 		$m = substr( $time, 5, 2 );
2013 2082
 		$subdir = "/$y/$m";
@@ -2131,20 +2200,24 @@  discard block
 block discarded – undo
2131 2200
  * @return array
2132 2201
  */
2133 2202
 function wp_upload_bits( $name, $deprecated, $bits, $time = null ) {
2134
-	if ( !empty( $deprecated ) )
2135
-		_deprecated_argument( __FUNCTION__, '2.0.0' );
2203
+	if ( !empty( $deprecated ) ) {
2204
+			_deprecated_argument( __FUNCTION__, '2.0.0' );
2205
+	}
2136 2206
 
2137
-	if ( empty( $name ) )
2138
-		return array( 'error' => __( 'Empty filename' ) );
2207
+	if ( empty( $name ) ) {
2208
+			return array( 'error' => __( 'Empty filename' ) );
2209
+	}
2139 2210
 
2140 2211
 	$wp_filetype = wp_check_filetype( $name );
2141
-	if ( ! $wp_filetype['ext'] && ! current_user_can( 'unfiltered_upload' ) )
2142
-		return array( 'error' => __( 'Invalid file type' ) );
2212
+	if ( ! $wp_filetype['ext'] && ! current_user_can( 'unfiltered_upload' ) ) {
2213
+			return array( 'error' => __( 'Invalid file type' ) );
2214
+	}
2143 2215
 
2144 2216
 	$upload = wp_upload_dir( $time );
2145 2217
 
2146
-	if ( $upload['error'] !== false )
2147
-		return $upload;
2218
+	if ( $upload['error'] !== false ) {
2219
+			return $upload;
2220
+	}
2148 2221
 
2149 2222
 	/**
2150 2223
 	 * Filters whether to treat the upload bits as an error.
@@ -2166,10 +2239,11 @@  discard block
 block discarded – undo
2166 2239
 
2167 2240
 	$new_file = $upload['path'] . "/$filename";
2168 2241
 	if ( ! wp_mkdir_p( dirname( $new_file ) ) ) {
2169
-		if ( 0 === strpos( $upload['basedir'], ABSPATH ) )
2170
-			$error_path = str_replace( ABSPATH, '', $upload['basedir'] ) . $upload['subdir'];
2171
-		else
2172
-			$error_path = basename( $upload['basedir'] ) . $upload['subdir'];
2242
+		if ( 0 === strpos( $upload['basedir'], ABSPATH ) ) {
2243
+					$error_path = str_replace( ABSPATH, '', $upload['basedir'] ) . $upload['subdir'];
2244
+		} else {
2245
+					$error_path = basename( $upload['basedir'] ) . $upload['subdir'];
2246
+		}
2173 2247
 
2174 2248
 		$message = sprintf(
2175 2249
 			/* translators: %s: directory path */
@@ -2180,8 +2254,9 @@  discard block
 block discarded – undo
2180 2254
 	}
2181 2255
 
2182 2256
 	$ifp = @ fopen( $new_file, 'wb' );
2183
-	if ( ! $ifp )
2184
-		return array( 'error' => sprintf( __( 'Could not write file %s' ), $new_file ) );
2257
+	if ( ! $ifp ) {
2258
+			return array( 'error' => sprintf( __( 'Could not write file %s' ), $new_file ) );
2259
+	}
2185 2260
 
2186 2261
 	@fwrite( $ifp, $bits );
2187 2262
 	fclose( $ifp );
@@ -2213,10 +2288,11 @@  discard block
 block discarded – undo
2213 2288
 	$ext = strtolower( $ext );
2214 2289
 
2215 2290
 	$ext2type = wp_get_ext_types();
2216
-	foreach ( $ext2type as $type => $exts )
2217
-		if ( in_array( $ext, $exts ) )
2291
+	foreach ( $ext2type as $type => $exts ) {
2292
+			if ( in_array( $ext, $exts ) )
2218 2293
 			return $type;
2219
-}
2294
+	}
2295
+	}
2220 2296
 
2221 2297
 /**
2222 2298
  * Retrieve the file type from the file name.
@@ -2230,8 +2306,9 @@  discard block
 block discarded – undo
2230 2306
  * @return array Values with extension first and mime type.
2231 2307
  */
2232 2308
 function wp_check_filetype( $filename, $mimes = null ) {
2233
-	if ( empty($mimes) )
2234
-		$mimes = get_allowed_mime_types();
2309
+	if ( empty($mimes) ) {
2310
+			$mimes = get_allowed_mime_types();
2311
+	}
2235 2312
 	$type = false;
2236 2313
 	$ext = false;
2237 2314
 
@@ -2503,11 +2580,13 @@  discard block
 block discarded – undo
2503 2580
 	$t = wp_get_mime_types();
2504 2581
 
2505 2582
 	unset( $t['swf'], $t['exe'] );
2506
-	if ( function_exists( 'current_user_can' ) )
2507
-		$unfiltered = $user ? user_can( $user, 'unfiltered_html' ) : current_user_can( 'unfiltered_html' );
2583
+	if ( function_exists( 'current_user_can' ) ) {
2584
+			$unfiltered = $user ? user_can( $user, 'unfiltered_html' ) : current_user_can( 'unfiltered_html' );
2585
+	}
2508 2586
 
2509
-	if ( empty( $unfiltered ) )
2510
-		unset( $t['htm|html'] );
2587
+	if ( empty( $unfiltered ) ) {
2588
+			unset( $t['htm|html'] );
2589
+	}
2511 2590
 
2512 2591
 	/**
2513 2592
 	 * Filters list of allowed mime types and file extensions.
@@ -2657,8 +2736,9 @@  discard block
 block discarded – undo
2657 2736
 	if ( function_exists( 'is_wp_error' ) && is_wp_error( $message ) ) {
2658 2737
 		if ( empty( $title ) ) {
2659 2738
 			$error_data = $message->get_error_data();
2660
-			if ( is_array( $error_data ) && isset( $error_data['title'] ) )
2661
-				$title = $error_data['title'];
2739
+			if ( is_array( $error_data ) && isset( $error_data['title'] ) ) {
2740
+							$title = $error_data['title'];
2741
+			}
2662 2742
 		}
2663 2743
 		$errors = $message->get_error_messages();
2664 2744
 		switch ( count( $errors ) ) {
@@ -2688,19 +2768,26 @@  discard block
 block discarded – undo
2688 2768
 			header( 'Content-Type: text/html; charset=utf-8' );
2689 2769
 		}
2690 2770
 
2691
-		if ( empty($title) )
2692
-			$title = $have_gettext ? __('WordPress &rsaquo; Error') : 'WordPress &rsaquo; Error';
2771
+		if ( empty($title) ) {
2772
+					$title = $have_gettext ? __('WordPress &rsaquo; Error') : 'WordPress &rsaquo; Error';
2773
+		}
2693 2774
 
2694 2775
 		$text_direction = 'ltr';
2695
-		if ( isset($r['text_direction']) && 'rtl' == $r['text_direction'] )
2696
-			$text_direction = 'rtl';
2697
-		elseif ( function_exists( 'is_rtl' ) && is_rtl() )
2698
-			$text_direction = 'rtl';
2699
-?>
2776
+		if ( isset($r['text_direction']) && 'rtl' == $r['text_direction'] ) {
2777
+					$text_direction = 'rtl';
2778
+		} elseif ( function_exists( 'is_rtl' ) && is_rtl() ) {
2779
+					$text_direction = 'rtl';
2780
+		}
2781
+		?>
2700 2782
 <!DOCTYPE html>
2701 2783
 <!-- 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
2702 2784
 -->
2703
-<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'"; ?>>
2785
+<html xmlns="http://www.w3.org/1999/xhtml" <?php if ( function_exists( 'language_attributes' ) && function_exists( 'is_rtl' ) ) {
2786
+	language_attributes();
2787
+} else {
2788
+	echo "dir='$text_direction'";
2789
+}
2790
+?>>
2704 2791
 <head>
2705 2792
 	<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
2706 2793
 	<meta name="viewport" content="width=device-width">
@@ -2885,8 +2972,9 @@  discard block
 block discarded – undo
2885 2972
 		status_header( $r['response'] );
2886 2973
 	}
2887 2974
 
2888
-	if ( is_scalar( $message ) )
2889
-		die( (string) $message );
2975
+	if ( is_scalar( $message ) ) {
2976
+			die( (string) $message );
2977
+	}
2890 2978
 	die( '0' );
2891 2979
 }
2892 2980
 
@@ -2901,8 +2989,9 @@  discard block
 block discarded – undo
2901 2989
  * @param string $message Optional. Response to print. Default empty.
2902 2990
  */
2903 2991
 function _scalar_wp_die_handler( $message = '' ) {
2904
-	if ( is_scalar( $message ) )
2905
-		die( (string) $message );
2992
+	if ( is_scalar( $message ) ) {
2993
+			die( (string) $message );
2994
+	}
2906 2995
 	die();
2907 2996
 }
2908 2997
 
@@ -3135,8 +3224,9 @@  discard block
 block discarded – undo
3135 3224
 function wp_send_json_success( $data = null, $status_code = null ) {
3136 3225
 	$response = array( 'success' => true );
3137 3226
 
3138
-	if ( isset( $data ) )
3139
-		$response['data'] = $data;
3227
+	if ( isset( $data ) ) {
3228
+			$response['data'] = $data;
3229
+	}
3140 3230
 
3141 3231
 	wp_send_json( $response, $status_code );
3142 3232
 }
@@ -3215,8 +3305,9 @@  discard block
 block discarded – undo
3215 3305
  * @return string Homepage location.
3216 3306
  */
3217 3307
 function _config_wp_home( $url = '' ) {
3218
-	if ( defined( 'WP_HOME' ) )
3219
-		return untrailingslashit( WP_HOME );
3308
+	if ( defined( 'WP_HOME' ) ) {
3309
+			return untrailingslashit( WP_HOME );
3310
+	}
3220 3311
 	return $url;
3221 3312
 }
3222 3313
 
@@ -3236,8 +3327,9 @@  discard block
 block discarded – undo
3236 3327
  * @return string The WordPress Site URL.
3237 3328
  */
3238 3329
 function _config_wp_siteurl( $url = '' ) {
3239
-	if ( defined( 'WP_SITEURL' ) )
3240
-		return untrailingslashit( WP_SITEURL );
3330
+	if ( defined( 'WP_SITEURL' ) ) {
3331
+			return untrailingslashit( WP_SITEURL );
3332
+	}
3241 3333
 	return $url;
3242 3334
 }
3243 3335
 
@@ -3312,8 +3404,9 @@  discard block
 block discarded – undo
3312 3404
 	global $wpsmiliestrans, $wp_smiliessearch;
3313 3405
 
3314 3406
 	// don't bother setting up smilies if they are disabled
3315
-	if ( !get_option( 'use_smilies' ) )
3316
-		return;
3407
+	if ( !get_option( 'use_smilies' ) ) {
3408
+			return;
3409
+	}
3317 3410
 
3318 3411
 	if ( !isset( $wpsmiliestrans ) ) {
3319 3412
 		$wpsmiliestrans = array(
@@ -3430,15 +3523,17 @@  discard block
 block discarded – undo
3430 3523
  * @return array Merged user defined values with defaults.
3431 3524
  */
3432 3525
 function wp_parse_args( $args, $defaults = '' ) {
3433
-	if ( is_object( $args ) )
3434
-		$r = get_object_vars( $args );
3435
-	elseif ( is_array( $args ) )
3436
-		$r =& $args;
3437
-	else
3438
-		wp_parse_str( $args, $r );
3439
-
3440
-	if ( is_array( $defaults ) )
3441
-		return array_merge( $defaults, $r );
3526
+	if ( is_object( $args ) ) {
3527
+			$r = get_object_vars( $args );
3528
+	} elseif ( is_array( $args ) ) {
3529
+			$r =& $args;
3530
+	} else {
3531
+			wp_parse_str( $args, $r );
3532
+	}
3533
+
3534
+	if ( is_array( $defaults ) ) {
3535
+			return array_merge( $defaults, $r );
3536
+	}
3442 3537
 	return $r;
3443 3538
 }
3444 3539
 
@@ -3451,8 +3546,9 @@  discard block
 block discarded – undo
3451 3546
  * @return array Sanitized array of IDs.
3452 3547
  */
3453 3548
 function wp_parse_id_list( $list ) {
3454
-	if ( !is_array($list) )
3455
-		$list = preg_split('/[\s,]+/', $list);
3549
+	if ( !is_array($list) ) {
3550
+			$list = preg_split('/[\s,]+/', $list);
3551
+	}
3456 3552
 
3457 3553
 	return array_unique(array_map('absint', $list));
3458 3554
 }
@@ -3488,9 +3584,10 @@  discard block
 block discarded – undo
3488 3584
  */
3489 3585
 function wp_array_slice_assoc( $array, $keys ) {
3490 3586
 	$slice = array();
3491
-	foreach ( $keys as $key )
3492
-		if ( isset( $array[ $key ] ) )
3587
+	foreach ( $keys as $key ) {
3588
+			if ( isset( $array[ $key ] ) )
3493 3589
 			$slice[ $key ] = $array[ $key ];
3590
+	}
3494 3591
 
3495 3592
 	return $slice;
3496 3593
 }
@@ -3654,8 +3751,9 @@  discard block
 block discarded – undo
3654 3751
 function wp_widgets_add_menu() {
3655 3752
 	global $submenu;
3656 3753
 
3657
-	if ( ! current_theme_supports( 'widgets' ) )
3658
-		return;
3754
+	if ( ! current_theme_supports( 'widgets' ) ) {
3755
+			return;
3756
+	}
3659 3757
 
3660 3758
 	$submenu['themes.php'][7] = array( __( 'Widgets' ), 'edit_theme_options', 'widgets.php' );
3661 3759
 	ksort( $submenu['themes.php'], SORT_NUMERIC );
@@ -3670,9 +3768,10 @@  discard block
 block discarded – undo
3670 3768
  */
3671 3769
 function wp_ob_end_flush_all() {
3672 3770
 	$levels = ob_get_level();
3673
-	for ($i=0; $i<$levels; $i++)
3674
-		ob_end_flush();
3675
-}
3771
+	for ($i=0; $i<$levels; $i++) {
3772
+			ob_end_flush();
3773
+	}
3774
+	}
3676 3775
 
3677 3776
 /**
3678 3777
  * Load custom DB error or display WordPress DB error.
@@ -3704,8 +3803,9 @@  discard block
 block discarded – undo
3704 3803
 	}
3705 3804
 
3706 3805
 	// If installing or in the admin, provide the verbose message.
3707
-	if ( wp_installing() || defined( 'WP_ADMIN' ) )
3708
-		wp_die($wpdb->error);
3806
+	if ( wp_installing() || defined( 'WP_ADMIN' ) ) {
3807
+			wp_die($wpdb->error);
3808
+	}
3709 3809
 
3710 3810
 	// Otherwise, be terse.
3711 3811
 	status_header( 500 );
@@ -3713,7 +3813,10 @@  discard block
 block discarded – undo
3713 3813
 	header( 'Content-Type: text/html; charset=utf-8' );
3714 3814
 ?>
3715 3815
 <!DOCTYPE html>
3716
-<html xmlns="http://www.w3.org/1999/xhtml"<?php if ( is_rtl() ) echo ' dir="rtl"'; ?>>
3816
+<html xmlns="http://www.w3.org/1999/xhtml"<?php if ( is_rtl() ) {
3817
+	echo ' dir="rtl"';
3818
+}
3819
+?>>
3717 3820
 <head>
3718 3821
 <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
3719 3822
 	<title><?php _e( 'Database Error' ); ?></title>
@@ -4131,19 +4234,22 @@  discard block
 block discarded – undo
4131 4234
 function apache_mod_loaded($mod, $default = false) {
4132 4235
 	global $is_apache;
4133 4236
 
4134
-	if ( !$is_apache )
4135
-		return false;
4237
+	if ( !$is_apache ) {
4238
+			return false;
4239
+	}
4136 4240
 
4137 4241
 	if ( function_exists( 'apache_get_modules' ) ) {
4138 4242
 		$mods = apache_get_modules();
4139
-		if ( in_array($mod, $mods) )
4140
-			return true;
4243
+		if ( in_array($mod, $mods) ) {
4244
+					return true;
4245
+		}
4141 4246
 	} elseif ( function_exists( 'phpinfo' ) && false === strpos( ini_get( 'disable_functions' ), 'phpinfo' ) ) {
4142 4247
 			ob_start();
4143 4248
 			phpinfo(8);
4144 4249
 			$phpinfo = ob_get_clean();
4145
-			if ( false !== strpos($phpinfo, $mod) )
4146
-				return true;
4250
+			if ( false !== strpos($phpinfo, $mod) ) {
4251
+							return true;
4252
+			}
4147 4253
 	}
4148 4254
 	return $default;
4149 4255
 }
@@ -4199,17 +4305,21 @@  discard block
 block discarded – undo
4199 4305
  * @return int 0 means nothing is wrong, greater than 0 means something was wrong.
4200 4306
  */
4201 4307
 function validate_file( $file, $allowed_files = '' ) {
4202
-	if ( false !== strpos( $file, '..' ) )
4203
-		return 1;
4308
+	if ( false !== strpos( $file, '..' ) ) {
4309
+			return 1;
4310
+	}
4204 4311
 
4205
-	if ( false !== strpos( $file, './' ) )
4206
-		return 1;
4312
+	if ( false !== strpos( $file, './' ) ) {
4313
+			return 1;
4314
+	}
4207 4315
 
4208
-	if ( ! empty( $allowed_files ) && ! in_array( $file, $allowed_files ) )
4209
-		return 3;
4316
+	if ( ! empty( $allowed_files ) && ! in_array( $file, $allowed_files ) ) {
4317
+			return 3;
4318
+	}
4210 4319
 
4211
-	if (':' == substr( $file, 1, 1 ) )
4212
-		return 2;
4320
+	if (':' == substr( $file, 1, 1 ) ) {
4321
+			return 2;
4322
+	}
4213 4323
 
4214 4324
 	return 0;
4215 4325
 }
@@ -4305,8 +4415,9 @@  discard block
 block discarded – undo
4305 4415
 function wp_suspend_cache_addition( $suspend = null ) {
4306 4416
 	static $_suspend = false;
4307 4417
 
4308
-	if ( is_bool( $suspend ) )
4309
-		$_suspend = $suspend;
4418
+	if ( is_bool( $suspend ) ) {
4419
+			$_suspend = $suspend;
4420
+	}
4310 4421
 
4311 4422
 	return $_suspend;
4312 4423
 }
@@ -4343,11 +4454,13 @@  discard block
 block discarded – undo
4343 4454
  *              running Multisite.
4344 4455
  */
4345 4456
 function is_main_site( $site_id = null ) {
4346
-	if ( ! is_multisite() )
4347
-		return true;
4457
+	if ( ! is_multisite() ) {
4458
+			return true;
4459
+	}
4348 4460
 
4349
-	if ( ! $site_id )
4350
-		$site_id = get_current_blog_id();
4461
+	if ( ! $site_id ) {
4462
+			$site_id = get_current_blog_id();
4463
+	}
4351 4464
 
4352 4465
 	return (int) $site_id === (int) get_network()->site_id;
4353 4466
 }
@@ -4418,8 +4531,9 @@  discard block
 block discarded – undo
4418 4531
  * @return bool True if multisite and global terms enabled.
4419 4532
  */
4420 4533
 function global_terms_enabled() {
4421
-	if ( ! is_multisite() )
4422
-		return false;
4534
+	if ( ! is_multisite() ) {
4535
+			return false;
4536
+	}
4423 4537
 
4424 4538
 	static $global_terms = null;
4425 4539
 	if ( is_null( $global_terms ) ) {
@@ -4435,10 +4549,11 @@  discard block
 block discarded – undo
4435 4549
 		 * @param null $enabled Whether global terms are enabled.
4436 4550
 		 */
4437 4551
 		$filter = apply_filters( 'global_terms_enabled', null );
4438
-		if ( ! is_null( $filter ) )
4439
-			$global_terms = (bool) $filter;
4440
-		else
4441
-			$global_terms = (bool) get_site_option( 'global_terms_enabled', false );
4552
+		if ( ! is_null( $filter ) ) {
4553
+					$global_terms = (bool) $filter;
4554
+		} else {
4555
+					$global_terms = (bool) get_site_option( 'global_terms_enabled', false );
4556
+		}
4442 4557
 	}
4443 4558
 	return $global_terms;
4444 4559
 }
@@ -4618,8 +4733,9 @@  discard block
 block discarded – undo
4618 4733
 	// Do UTC
4619 4734
 	$structure[] = '<optgroup label="'. esc_attr__( 'UTC' ) .'">';
4620 4735
 	$selected = '';
4621
-	if ( 'UTC' === $selected_zone )
4622
-		$selected = 'selected="selected" ';
4736
+	if ( 'UTC' === $selected_zone ) {
4737
+			$selected = 'selected="selected" ';
4738
+	}
4623 4739
 	$structure[] = '<option ' . $selected . 'value="' . esc_attr( 'UTC' ) . '">' . __('UTC') . '</option>';
4624 4740
 	$structure[] = '</optgroup>';
4625 4741
 
@@ -4628,18 +4744,20 @@  discard block
 block discarded – undo
4628 4744
 	$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,
4629 4745
 		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);
4630 4746
 	foreach ( $offset_range as $offset ) {
4631
-		if ( 0 <= $offset )
4632
-			$offset_name = '+' . $offset;
4633
-		else
4634
-			$offset_name = (string) $offset;
4747
+		if ( 0 <= $offset ) {
4748
+					$offset_name = '+' . $offset;
4749
+		} else {
4750
+					$offset_name = (string) $offset;
4751
+		}
4635 4752
 
4636 4753
 		$offset_value = $offset_name;
4637 4754
 		$offset_name = str_replace(array('.25','.5','.75'), array(':15',':30',':45'), $offset_name);
4638 4755
 		$offset_name = 'UTC' . $offset_name;
4639 4756
 		$offset_value = 'UTC' . $offset_value;
4640 4757
 		$selected = '';
4641
-		if ( $offset_value === $selected_zone )
4642
-			$selected = 'selected="selected" ';
4758
+		if ( $offset_value === $selected_zone ) {
4759
+					$selected = 'selected="selected" ';
4760
+		}
4643 4761
 		$structure[] = '<option ' . $selected . 'value="' . esc_attr( $offset_value ) . '">' . esc_html( $offset_name ) . "</option>";
4644 4762
 
4645 4763
 	}
@@ -4682,8 +4800,9 @@  discard block
 block discarded – undo
4682 4800
 
4683 4801
 	foreach ( (array) $posts_to_delete as $post ) {
4684 4802
 		$post_id = (int) $post['post_id'];
4685
-		if ( !$post_id )
4686
-			continue;
4803
+		if ( !$post_id ) {
4804
+					continue;
4805
+		}
4687 4806
 
4688 4807
 		$del_post = get_post($post_id);
4689 4808
 
@@ -4699,8 +4818,9 @@  discard block
 block discarded – undo
4699 4818
 
4700 4819
 	foreach ( (array) $comments_to_delete as $comment ) {
4701 4820
 		$comment_id = (int) $comment['comment_id'];
4702
-		if ( !$comment_id )
4703
-			continue;
4821
+		if ( !$comment_id ) {
4822
+					continue;
4823
+		}
4704 4824
 
4705 4825
 		$del_comment = get_comment($comment_id);
4706 4826
 
@@ -4764,10 +4884,11 @@  discard block
 block discarded – undo
4764 4884
 	}
4765 4885
 
4766 4886
 	foreach ( $all_headers as $field => $regex ) {
4767
-		if ( preg_match( '/^[ \t\/*#@]*' . preg_quote( $regex, '/' ) . ':(.*)$/mi', $file_data, $match ) && $match[1] )
4768
-			$all_headers[ $field ] = _cleanup_header_comment( $match[1] );
4769
-		else
4770
-			$all_headers[ $field ] = '';
4887
+		if ( preg_match( '/^[ \t\/*#@]*' . preg_quote( $regex, '/' ) . ':(.*)$/mi', $file_data, $match ) && $match[1] ) {
4888
+					$all_headers[ $field ] = _cleanup_header_comment( $match[1] );
4889
+		} else {
4890
+					$all_headers[ $field ] = '';
4891
+		}
4771 4892
 	}
4772 4893
 
4773 4894
 	return $all_headers;
@@ -4910,8 +5031,9 @@  discard block
 block discarded – undo
4910 5031
 function wp_find_hierarchy_loop( $callback, $start, $start_parent, $callback_args = array() ) {
4911 5032
 	$override = is_null( $start_parent ) ? array() : array( $start => $start_parent );
4912 5033
 
4913
-	if ( !$arbitrary_loop_member = wp_find_hierarchy_loop_tortoise_hare( $callback, $start, $override, $callback_args ) )
4914
-		return array();
5034
+	if ( !$arbitrary_loop_member = wp_find_hierarchy_loop_tortoise_hare( $callback, $start, $override, $callback_args ) ) {
5035
+			return array();
5036
+	}
4915 5037
 
4916 5038
 	return wp_find_hierarchy_loop_tortoise_hare( $callback, $arbitrary_loop_member, $override, $callback_args, true );
4917 5039
 }
@@ -4949,12 +5071,14 @@  discard block
 block discarded – undo
4949 5071
 	&&
4950 5072
 		( $hare = isset( $override[$evanescent_hare] ) ? $override[$evanescent_hare] : call_user_func_array( $callback, array_merge( array( $evanescent_hare ), $callback_args ) ) )
4951 5073
 	) {
4952
-		if ( $_return_loop )
4953
-			$return[$tortoise] = $return[$evanescent_hare] = $return[$hare] = true;
5074
+		if ( $_return_loop ) {
5075
+					$return[$tortoise] = $return[$evanescent_hare] = $return[$hare] = true;
5076
+		}
4954 5077
 
4955 5078
 		// tortoise got lapped - must be a loop
4956
-		if ( $tortoise == $evanescent_hare || $tortoise == $hare )
4957
-			return $_return_loop ? $return : $tortoise;
5079
+		if ( $tortoise == $evanescent_hare || $tortoise == $hare ) {
5080
+					return $_return_loop ? $return : $tortoise;
5081
+		}
4958 5082
 
4959 5083
 		// Increment tortoise by one step
4960 5084
 		$tortoise = isset( $override[$tortoise] ) ? $override[$tortoise] : call_user_func_array( $callback, array_merge( array( $tortoise ), $callback_args ) );
@@ -5027,10 +5151,11 @@  discard block
 block discarded – undo
5027 5151
  *                      of individual calls.
5028 5152
  */
5029 5153
 function wp_debug_backtrace_summary( $ignore_class = null, $skip_frames = 0, $pretty = true ) {
5030
-	if ( version_compare( PHP_VERSION, '5.2.5', '>=' ) )
5031
-		$trace = debug_backtrace( false );
5032
-	else
5033
-		$trace = debug_backtrace();
5154
+	if ( version_compare( PHP_VERSION, '5.2.5', '>=' ) ) {
5155
+			$trace = debug_backtrace( false );
5156
+	} else {
5157
+			$trace = debug_backtrace();
5158
+	}
5034 5159
 
5035 5160
 	$caller = array();
5036 5161
 	$check_class = ! is_null( $ignore_class );
@@ -5040,8 +5165,10 @@  discard block
 block discarded – undo
5040 5165
 		if ( $skip_frames > 0 ) {
5041 5166
 			$skip_frames--;
5042 5167
 		} elseif ( isset( $call['class'] ) ) {
5043
-			if ( $check_class && $ignore_class == $call['class'] )
5044
-				continue; // Filter out calls
5168
+			if ( $check_class && $ignore_class == $call['class'] ) {
5169
+							continue;
5170
+			}
5171
+			// Filter out calls
5045 5172
 
5046 5173
 			$caller[] = "{$call['class']}{$call['type']}{$call['function']}";
5047 5174
 		} else {
@@ -5054,11 +5181,12 @@  discard block
 block discarded – undo
5054 5181
 			}
5055 5182
 		}
5056 5183
 	}
5057
-	if ( $pretty )
5058
-		return join( ', ', array_reverse( $caller ) );
5059
-	else
5060
-		return $caller;
5061
-}
5184
+	if ( $pretty ) {
5185
+			return join( ', ', array_reverse( $caller ) );
5186
+	} else {
5187
+			return $caller;
5188
+	}
5189
+	}
5062 5190
 
5063 5191
 /**
5064 5192
  * Retrieve ids that are not already present in the cache.
@@ -5092,8 +5220,9 @@  discard block
 block discarded – undo
5092 5220
  * @return bool Whether the device is able to upload files.
5093 5221
  */
5094 5222
 function _device_can_upload() {
5095
-	if ( ! wp_is_mobile() )
5096
-		return true;
5223
+	if ( ! wp_is_mobile() ) {
5224
+			return true;
5225
+	}
5097 5226
 
5098 5227
 	$ua = $_SERVER['HTTP_USER_AGENT'];
5099 5228
 
@@ -5158,11 +5287,13 @@  discard block
 block discarded – undo
5158 5287
  * @since 3.6.0
5159 5288
  */
5160 5289
 function wp_auth_check_load() {
5161
-	if ( ! is_admin() && ! is_user_logged_in() )
5162
-		return;
5290
+	if ( ! is_admin() && ! is_user_logged_in() ) {
5291
+			return;
5292
+	}
5163 5293
 
5164
-	if ( defined( 'IFRAME_REQUEST' ) )
5165
-		return;
5294
+	if ( defined( 'IFRAME_REQUEST' ) ) {
5295
+			return;
5296
+	}
5166 5297
 
5167 5298
 	$screen = get_current_screen();
5168 5299
 	$hidden = array( 'update', 'update-network', 'update-core', 'update-core-network', 'upgrade', 'upgrade-network', 'network' );
@@ -5267,8 +5398,9 @@  discard block
 block discarded – undo
5267 5398
  * @return string Tag RegEx.
5268 5399
  */
5269 5400
 function get_tag_regex( $tag ) {
5270
-	if ( empty( $tag ) )
5271
-		return;
5401
+	if ( empty( $tag ) ) {
5402
+			return;
5403
+	}
5272 5404
 	return sprintf( '<%1$s[^<]*(?:>[\s\S]*<\/%1$s>|\s*\/>)', tag_escape( $tag ) );
5273 5405
 }
5274 5406
 
@@ -5328,11 +5460,13 @@  discard block
 block discarded – undo
5328 5460
 	static $encodings = array();
5329 5461
 	static $overloaded = null;
5330 5462
 
5331
-	if ( is_null( $overloaded ) )
5332
-		$overloaded = function_exists( 'mb_internal_encoding' ) && ( ini_get( 'mbstring.func_overload' ) & 2 );
5463
+	if ( is_null( $overloaded ) ) {
5464
+			$overloaded = function_exists( 'mb_internal_encoding' ) && ( ini_get( 'mbstring.func_overload' ) & 2 );
5465
+	}
5333 5466
 
5334
-	if ( false === $overloaded )
5335
-		return;
5467
+	if ( false === $overloaded ) {
5468
+			return;
5469
+	}
5336 5470
 
5337 5471
 	if ( ! $reset ) {
5338 5472
 		$encoding = mb_internal_encoding();
Please login to merge, or discard this patch.
src/wp-includes/class-json.php 4 patches
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 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.
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.
src/wp-includes/cache.php 3 patches
Braces   +83 added lines, -56 removed lines patch added patch discarded remove patch
@@ -388,18 +388,22 @@  discard block
 block discarded – undo
388 388
 	 * @return bool False if cache key and group already exist, true on success
389 389
 	 */
390 390
 	public function add( $key, $data, $group = 'default', $expire = 0 ) {
391
-		if ( wp_suspend_cache_addition() )
392
-			return false;
391
+		if ( wp_suspend_cache_addition() ) {
392
+					return false;
393
+		}
393 394
 
394
-		if ( empty( $group ) )
395
-			$group = 'default';
395
+		if ( empty( $group ) ) {
396
+					$group = 'default';
397
+		}
396 398
 
397 399
 		$id = $key;
398
-		if ( $this->multisite && ! isset( $this->global_groups[ $group ] ) )
399
-			$id = $this->blog_prefix . $key;
400
+		if ( $this->multisite && ! isset( $this->global_groups[ $group ] ) ) {
401
+					$id = $this->blog_prefix . $key;
402
+		}
400 403
 
401
-		if ( $this->_exists( $id, $group ) )
402
-			return false;
404
+		if ( $this->_exists( $id, $group ) ) {
405
+					return false;
406
+		}
403 407
 
404 408
 		return $this->set( $key, $data, $group, (int) $expire );
405 409
 	}
@@ -429,24 +433,29 @@  discard block
 block discarded – undo
429 433
 	 * @return false|int False on failure, the item's new value on success.
430 434
 	 */
431 435
 	public function decr( $key, $offset = 1, $group = 'default' ) {
432
-		if ( empty( $group ) )
433
-			$group = 'default';
436
+		if ( empty( $group ) ) {
437
+					$group = 'default';
438
+		}
434 439
 
435
-		if ( $this->multisite && ! isset( $this->global_groups[ $group ] ) )
436
-			$key = $this->blog_prefix . $key;
440
+		if ( $this->multisite && ! isset( $this->global_groups[ $group ] ) ) {
441
+					$key = $this->blog_prefix . $key;
442
+		}
437 443
 
438
-		if ( ! $this->_exists( $key, $group ) )
439
-			return false;
444
+		if ( ! $this->_exists( $key, $group ) ) {
445
+					return false;
446
+		}
440 447
 
441
-		if ( ! is_numeric( $this->cache[ $group ][ $key ] ) )
442
-			$this->cache[ $group ][ $key ] = 0;
448
+		if ( ! is_numeric( $this->cache[ $group ][ $key ] ) ) {
449
+					$this->cache[ $group ][ $key ] = 0;
450
+		}
443 451
 
444 452
 		$offset = (int) $offset;
445 453
 
446 454
 		$this->cache[ $group ][ $key ] -= $offset;
447 455
 
448
-		if ( $this->cache[ $group ][ $key ] < 0 )
449
-			$this->cache[ $group ][ $key ] = 0;
456
+		if ( $this->cache[ $group ][ $key ] < 0 ) {
457
+					$this->cache[ $group ][ $key ] = 0;
458
+		}
450 459
 
451 460
 		return $this->cache[ $group ][ $key ];
452 461
 	}
@@ -465,14 +474,17 @@  discard block
 block discarded – undo
465 474
 	 * @return bool False if the contents weren't deleted and true on success
466 475
 	 */
467 476
 	public function delete( $key, $group = 'default', $deprecated = false ) {
468
-		if ( empty( $group ) )
469
-			$group = 'default';
477
+		if ( empty( $group ) ) {
478
+					$group = 'default';
479
+		}
470 480
 
471
-		if ( $this->multisite && ! isset( $this->global_groups[ $group ] ) )
472
-			$key = $this->blog_prefix . $key;
481
+		if ( $this->multisite && ! isset( $this->global_groups[ $group ] ) ) {
482
+					$key = $this->blog_prefix . $key;
483
+		}
473 484
 
474
-		if ( ! $this->_exists( $key, $group ) )
475
-			return false;
485
+		if ( ! $this->_exists( $key, $group ) ) {
486
+					return false;
487
+		}
476 488
 
477 489
 		unset( $this->cache[$group][$key] );
478 490
 		return true;
@@ -509,19 +521,22 @@  discard block
 block discarded – undo
509 521
 	 *		               contents on success
510 522
 	 */
511 523
 	public function get( $key, $group = 'default', $force = false, &$found = null ) {
512
-		if ( empty( $group ) )
513
-			$group = 'default';
524
+		if ( empty( $group ) ) {
525
+					$group = 'default';
526
+		}
514 527
 
515
-		if ( $this->multisite && ! isset( $this->global_groups[ $group ] ) )
516
-			$key = $this->blog_prefix . $key;
528
+		if ( $this->multisite && ! isset( $this->global_groups[ $group ] ) ) {
529
+					$key = $this->blog_prefix . $key;
530
+		}
517 531
 
518 532
 		if ( $this->_exists( $key, $group ) ) {
519 533
 			$found = true;
520 534
 			$this->cache_hits += 1;
521
-			if ( is_object($this->cache[$group][$key]) )
522
-				return clone $this->cache[$group][$key];
523
-			else
524
-				return $this->cache[$group][$key];
535
+			if ( is_object($this->cache[$group][$key]) ) {
536
+							return clone $this->cache[$group][$key];
537
+			} else {
538
+							return $this->cache[$group][$key];
539
+			}
525 540
 		}
526 541
 
527 542
 		$found = false;
@@ -540,24 +555,29 @@  discard block
 block discarded – undo
540 555
 	 * @return false|int False on failure, the item's new value on success.
541 556
 	 */
542 557
 	public function incr( $key, $offset = 1, $group = 'default' ) {
543
-		if ( empty( $group ) )
544
-			$group = 'default';
558
+		if ( empty( $group ) ) {
559
+					$group = 'default';
560
+		}
545 561
 
546
-		if ( $this->multisite && ! isset( $this->global_groups[ $group ] ) )
547
-			$key = $this->blog_prefix . $key;
562
+		if ( $this->multisite && ! isset( $this->global_groups[ $group ] ) ) {
563
+					$key = $this->blog_prefix . $key;
564
+		}
548 565
 
549
-		if ( ! $this->_exists( $key, $group ) )
550
-			return false;
566
+		if ( ! $this->_exists( $key, $group ) ) {
567
+					return false;
568
+		}
551 569
 
552
-		if ( ! is_numeric( $this->cache[ $group ][ $key ] ) )
553
-			$this->cache[ $group ][ $key ] = 0;
570
+		if ( ! is_numeric( $this->cache[ $group ][ $key ] ) ) {
571
+					$this->cache[ $group ][ $key ] = 0;
572
+		}
554 573
 
555 574
 		$offset = (int) $offset;
556 575
 
557 576
 		$this->cache[ $group ][ $key ] += $offset;
558 577
 
559
-		if ( $this->cache[ $group ][ $key ] < 0 )
560
-			$this->cache[ $group ][ $key ] = 0;
578
+		if ( $this->cache[ $group ][ $key ] < 0 ) {
579
+					$this->cache[ $group ][ $key ] = 0;
580
+		}
561 581
 
562 582
 		return $this->cache[ $group ][ $key ];
563 583
 	}
@@ -575,15 +595,18 @@  discard block
 block discarded – undo
575 595
 	 * @return bool False if not exists, true if contents were replaced
576 596
 	 */
577 597
 	public function replace( $key, $data, $group = 'default', $expire = 0 ) {
578
-		if ( empty( $group ) )
579
-			$group = 'default';
598
+		if ( empty( $group ) ) {
599
+					$group = 'default';
600
+		}
580 601
 
581 602
 		$id = $key;
582
-		if ( $this->multisite && ! isset( $this->global_groups[ $group ] ) )
583
-			$id = $this->blog_prefix . $key;
603
+		if ( $this->multisite && ! isset( $this->global_groups[ $group ] ) ) {
604
+					$id = $this->blog_prefix . $key;
605
+		}
584 606
 
585
-		if ( ! $this->_exists( $id, $group ) )
586
-			return false;
607
+		if ( ! $this->_exists( $id, $group ) ) {
608
+					return false;
609
+		}
587 610
 
588 611
 		return $this->set( $key, $data, $group, (int) $expire );
589 612
 	}
@@ -600,8 +623,9 @@  discard block
 block discarded – undo
600 623
 
601 624
 		// Clear out non-global caches since the blog ID has changed.
602 625
 		foreach ( array_keys( $this->cache ) as $group ) {
603
-			if ( ! isset( $this->global_groups[ $group ] ) )
604
-				unset( $this->cache[ $group ] );
626
+			if ( ! isset( $this->global_groups[ $group ] ) ) {
627
+							unset( $this->cache[ $group ] );
628
+			}
605 629
 		}
606 630
 	}
607 631
 
@@ -626,14 +650,17 @@  discard block
 block discarded – undo
626 650
 	 * @return true Always returns true
627 651
 	 */
628 652
 	public function set( $key, $data, $group = 'default', $expire = 0 ) {
629
-		if ( empty( $group ) )
630
-			$group = 'default';
653
+		if ( empty( $group ) ) {
654
+					$group = 'default';
655
+		}
631 656
 
632
-		if ( $this->multisite && ! isset( $this->global_groups[ $group ] ) )
633
-			$key = $this->blog_prefix . $key;
657
+		if ( $this->multisite && ! isset( $this->global_groups[ $group ] ) ) {
658
+					$key = $this->blog_prefix . $key;
659
+		}
634 660
 
635
-		if ( is_object( $data ) )
636
-			$data = clone $data;
661
+		if ( is_object( $data ) ) {
662
+					$data = clone $data;
663
+		}
637 664
 
638 665
 		$this->cache[$group][$key] = $data;
639 666
 		return true;
Please login to merge, or discard this patch.
Doc Comments   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -41,7 +41,7 @@  discard block
 block discarded – undo
41 41
  *
42 42
  * @since 2.0.0
43 43
  *
44
- * @return true Always returns true.
44
+ * @return boolean Always returns true.
45 45
  */
46 46
 function wp_cache_close() {
47 47
 	return true;
@@ -510,7 +510,7 @@  discard block
 block discarded – undo
510 510
 	 * @since 2.0.0
511 511
 	 * @access public
512 512
 	 *
513
-	 * @return true Always returns true.
513
+	 * @return boolean Always returns true.
514 514
 	 */
515 515
 	public function flush() {
516 516
 		$this->cache = array();
@@ -659,7 +659,7 @@  discard block
 block discarded – undo
659 659
 	 * @param mixed      $data   The contents to store in the cache.
660 660
 	 * @param string     $group  Optional. Where to group the cache contents. Default 'default'.
661 661
 	 * @param int        $expire Not Used.
662
-	 * @return true Always returns true.
662
+	 * @return boolean Always returns true.
663 663
 	 */
664 664
 	public function set( $key, $data, $group = 'default', $expire = 0 ) {
665 665
 		if ( empty( $group ) )
@@ -753,7 +753,7 @@  discard block
 block discarded – undo
753 753
 	 *
754 754
 	 * @since 2.0.8
755 755
 	 *
756
-	 * @return true Always returns true.
756
+	 * @return boolean Always returns true.
757 757
 	 */
758 758
 	public function __destruct() {
759 759
 		return true;
Please login to merge, or discard this patch.
Spacing   +91 added lines, -91 removed lines patch added patch discarded remove patch
@@ -24,10 +24,10 @@  discard block
 block discarded – undo
24 24
  *                           Default 0 (no expiration).
25 25
  * @return bool False if cache key and group already exist, true on success.
26 26
  */
27
-function wp_cache_add( $key, $data, $group = '', $expire = 0 ) {
27
+function wp_cache_add($key, $data, $group = '', $expire = 0) {
28 28
 	global $wp_object_cache;
29 29
 
30
-	return $wp_object_cache->add( $key, $data, $group, (int) $expire );
30
+	return $wp_object_cache->add($key, $data, $group, (int) $expire);
31 31
 }
32 32
 
33 33
 /**
@@ -60,10 +60,10 @@  discard block
 block discarded – undo
60 60
  * @param string     $group  Optional. The group the key is in. Default empty.
61 61
  * @return false|int False on failure, the item's new value on success.
62 62
  */
63
-function wp_cache_decr( $key, $offset = 1, $group = '' ) {
63
+function wp_cache_decr($key, $offset = 1, $group = '') {
64 64
 	global $wp_object_cache;
65 65
 
66
-	return $wp_object_cache->decr( $key, $offset, $group );
66
+	return $wp_object_cache->decr($key, $offset, $group);
67 67
 }
68 68
 
69 69
 /**
@@ -78,7 +78,7 @@  discard block
 block discarded – undo
78 78
  * @param string     $group Optional. Where the cache contents are grouped. Default empty.
79 79
  * @return bool True on successful removal, false on failure.
80 80
  */
81
-function wp_cache_delete( $key, $group = '' ) {
81
+function wp_cache_delete($key, $group = '') {
82 82
 	global $wp_object_cache;
83 83
 
84 84
 	return $wp_object_cache->delete($key, $group);
@@ -117,10 +117,10 @@  discard block
 block discarded – undo
117 117
  * @return bool|mixed False on failure to retrieve contents or the cache
118 118
  *		              contents on success
119 119
  */
120
-function wp_cache_get( $key, $group = '', $force = false, &$found = null ) {
120
+function wp_cache_get($key, $group = '', $force = false, &$found = null) {
121 121
 	global $wp_object_cache;
122 122
 
123
-	return $wp_object_cache->get( $key, $group, $force, $found );
123
+	return $wp_object_cache->get($key, $group, $force, $found);
124 124
 }
125 125
 
126 126
 /**
@@ -136,10 +136,10 @@  discard block
 block discarded – undo
136 136
  * @param string     $group  Optional. The group the key is in. Default empty.
137 137
  * @return false|int False on failure, the item's new value on success.
138 138
  */
139
-function wp_cache_incr( $key, $offset = 1, $group = '' ) {
139
+function wp_cache_incr($key, $offset = 1, $group = '') {
140 140
 	global $wp_object_cache;
141 141
 
142
-	return $wp_object_cache->incr( $key, $offset, $group );
142
+	return $wp_object_cache->incr($key, $offset, $group);
143 143
 }
144 144
 
145 145
 /**
@@ -169,10 +169,10 @@  discard block
 block discarded – undo
169 169
  *                           Default 0 (no expiration).
170 170
  * @return bool False if original value does not exist, true if contents were replaced
171 171
  */
172
-function wp_cache_replace( $key, $data, $group = '', $expire = 0 ) {
172
+function wp_cache_replace($key, $data, $group = '', $expire = 0) {
173 173
 	global $wp_object_cache;
174 174
 
175
-	return $wp_object_cache->replace( $key, $data, $group, (int) $expire );
175
+	return $wp_object_cache->replace($key, $data, $group, (int) $expire);
176 176
 }
177 177
 
178 178
 /**
@@ -193,10 +193,10 @@  discard block
 block discarded – undo
193 193
  *                           Default 0 (no expiration).
194 194
  * @return bool False on failure, true on success
195 195
  */
196
-function wp_cache_set( $key, $data, $group = '', $expire = 0 ) {
196
+function wp_cache_set($key, $data, $group = '', $expire = 0) {
197 197
 	global $wp_object_cache;
198 198
 
199
-	return $wp_object_cache->set( $key, $data, $group, (int) $expire );
199
+	return $wp_object_cache->set($key, $data, $group, (int) $expire);
200 200
 }
201 201
 
202 202
 /**
@@ -211,10 +211,10 @@  discard block
 block discarded – undo
211 211
  *
212 212
  * @param int $blog_id Site ID.
213 213
  */
214
-function wp_cache_switch_to_blog( $blog_id ) {
214
+function wp_cache_switch_to_blog($blog_id) {
215 215
 	global $wp_object_cache;
216 216
 
217
-	$wp_object_cache->switch_to_blog( $blog_id );
217
+	$wp_object_cache->switch_to_blog($blog_id);
218 218
 }
219 219
 
220 220
 /**
@@ -227,10 +227,10 @@  discard block
 block discarded – undo
227 227
  *
228 228
  * @param string|array $groups A group or an array of groups to add.
229 229
  */
230
-function wp_cache_add_global_groups( $groups ) {
230
+function wp_cache_add_global_groups($groups) {
231 231
 	global $wp_object_cache;
232 232
 
233
-	$wp_object_cache->add_global_groups( $groups );
233
+	$wp_object_cache->add_global_groups($groups);
234 234
 }
235 235
 
236 236
 /**
@@ -240,7 +240,7 @@  discard block
 block discarded – undo
240 240
  *
241 241
  * @param string|array $groups A group or an array of groups to add.
242 242
  */
243
-function wp_cache_add_non_persistent_groups( $groups ) {
243
+function wp_cache_add_non_persistent_groups($groups) {
244 244
 	// Default cache doesn't persist so nothing to do here.
245 245
 }
246 246
 
@@ -264,7 +264,7 @@  discard block
 block discarded – undo
264 264
  * @global WP_Object_Cache $wp_object_cache Object cache global instance.
265 265
  */
266 266
 function wp_cache_reset() {
267
-	_deprecated_function( __FUNCTION__, '3.5.0' );
267
+	_deprecated_function(__FUNCTION__, '3.5.0');
268 268
 
269 269
 	global $wp_object_cache;
270 270
 
@@ -352,7 +352,7 @@  discard block
 block discarded – undo
352 352
 	 * @param string $name Property to get.
353 353
 	 * @return mixed Property.
354 354
 	 */
355
-	public function __get( $name ) {
355
+	public function __get($name) {
356 356
 		return $this->$name;
357 357
 	}
358 358
 
@@ -366,7 +366,7 @@  discard block
 block discarded – undo
366 366
 	 * @param mixed  $value Property value.
367 367
 	 * @return mixed Newly-set property.
368 368
 	 */
369
-	public function __set( $name, $value ) {
369
+	public function __set($name, $value) {
370 370
 		return $this->$name = $value;
371 371
 	}
372 372
 
@@ -379,8 +379,8 @@  discard block
 block discarded – undo
379 379
 	 * @param string $name Property to check if set.
380 380
 	 * @return bool Whether the property is set.
381 381
 	 */
382
-	public function __isset( $name ) {
383
-		return isset( $this->$name );
382
+	public function __isset($name) {
383
+		return isset($this->$name);
384 384
 	}
385 385
 
386 386
 	/**
@@ -391,8 +391,8 @@  discard block
 block discarded – undo
391 391
 	 *
392 392
 	 * @param string $name Property to unset.
393 393
 	 */
394
-	public function __unset( $name ) {
395
-		unset( $this->$name );
394
+	public function __unset($name) {
395
+		unset($this->$name);
396 396
 	}
397 397
 
398 398
 	/**
@@ -411,21 +411,21 @@  discard block
 block discarded – undo
411 411
 	 * @param int        $expire Optional. When to expire the cache contents. Default 0 (no expiration).
412 412
 	 * @return bool False if cache key and group already exist, true on success
413 413
 	 */
414
-	public function add( $key, $data, $group = 'default', $expire = 0 ) {
415
-		if ( wp_suspend_cache_addition() )
414
+	public function add($key, $data, $group = 'default', $expire = 0) {
415
+		if (wp_suspend_cache_addition())
416 416
 			return false;
417 417
 
418
-		if ( empty( $group ) )
418
+		if (empty($group))
419 419
 			$group = 'default';
420 420
 
421 421
 		$id = $key;
422
-		if ( $this->multisite && ! isset( $this->global_groups[ $group ] ) )
423
-			$id = $this->blog_prefix . $key;
422
+		if ($this->multisite && ! isset($this->global_groups[$group]))
423
+			$id = $this->blog_prefix.$key;
424 424
 
425
-		if ( $this->_exists( $id, $group ) )
425
+		if ($this->_exists($id, $group))
426 426
 			return false;
427 427
 
428
-		return $this->set( $key, $data, $group, (int) $expire );
428
+		return $this->set($key, $data, $group, (int) $expire);
429 429
 	}
430 430
 
431 431
 	/**
@@ -436,11 +436,11 @@  discard block
 block discarded – undo
436 436
 	 *
437 437
 	 * @param array $groups List of groups that are global.
438 438
 	 */
439
-	public function add_global_groups( $groups ) {
439
+	public function add_global_groups($groups) {
440 440
 		$groups = (array) $groups;
441 441
 
442
-		$groups = array_fill_keys( $groups, true );
443
-		$this->global_groups = array_merge( $this->global_groups, $groups );
442
+		$groups = array_fill_keys($groups, true);
443
+		$this->global_groups = array_merge($this->global_groups, $groups);
444 444
 	}
445 445
 
446 446
 	/**
@@ -454,27 +454,27 @@  discard block
 block discarded – undo
454 454
 	 * @param string     $group  Optional. The group the key is in. Default 'default'.
455 455
 	 * @return false|int False on failure, the item's new value on success.
456 456
 	 */
457
-	public function decr( $key, $offset = 1, $group = 'default' ) {
458
-		if ( empty( $group ) )
457
+	public function decr($key, $offset = 1, $group = 'default') {
458
+		if (empty($group))
459 459
 			$group = 'default';
460 460
 
461
-		if ( $this->multisite && ! isset( $this->global_groups[ $group ] ) )
462
-			$key = $this->blog_prefix . $key;
461
+		if ($this->multisite && ! isset($this->global_groups[$group]))
462
+			$key = $this->blog_prefix.$key;
463 463
 
464
-		if ( ! $this->_exists( $key, $group ) )
464
+		if ( ! $this->_exists($key, $group))
465 465
 			return false;
466 466
 
467
-		if ( ! is_numeric( $this->cache[ $group ][ $key ] ) )
468
-			$this->cache[ $group ][ $key ] = 0;
467
+		if ( ! is_numeric($this->cache[$group][$key]))
468
+			$this->cache[$group][$key] = 0;
469 469
 
470 470
 		$offset = (int) $offset;
471 471
 
472
-		$this->cache[ $group ][ $key ] -= $offset;
472
+		$this->cache[$group][$key] -= $offset;
473 473
 
474
-		if ( $this->cache[ $group ][ $key ] < 0 )
475
-			$this->cache[ $group ][ $key ] = 0;
474
+		if ($this->cache[$group][$key] < 0)
475
+			$this->cache[$group][$key] = 0;
476 476
 
477
-		return $this->cache[ $group ][ $key ];
477
+		return $this->cache[$group][$key];
478 478
 	}
479 479
 
480 480
 	/**
@@ -490,17 +490,17 @@  discard block
 block discarded – undo
490 490
 	 * @param bool       $deprecated Optional. Unused. Default false.
491 491
 	 * @return bool False if the contents weren't deleted and true on success.
492 492
 	 */
493
-	public function delete( $key, $group = 'default', $deprecated = false ) {
494
-		if ( empty( $group ) )
493
+	public function delete($key, $group = 'default', $deprecated = false) {
494
+		if (empty($group))
495 495
 			$group = 'default';
496 496
 
497
-		if ( $this->multisite && ! isset( $this->global_groups[ $group ] ) )
498
-			$key = $this->blog_prefix . $key;
497
+		if ($this->multisite && ! isset($this->global_groups[$group]))
498
+			$key = $this->blog_prefix.$key;
499 499
 
500
-		if ( ! $this->_exists( $key, $group ) )
500
+		if ( ! $this->_exists($key, $group))
501 501
 			return false;
502 502
 
503
-		unset( $this->cache[$group][$key] );
503
+		unset($this->cache[$group][$key]);
504 504
 		return true;
505 505
 	}
506 506
 
@@ -538,17 +538,17 @@  discard block
 block discarded – undo
538 538
 	 *                           false, a storable value. Passed by reference. Default null.
539 539
 	 * @return false|mixed False on failure to retrieve contents or the cache contents on success.
540 540
 	 */
541
-	public function get( $key, $group = 'default', $force = false, &$found = null ) {
542
-		if ( empty( $group ) )
541
+	public function get($key, $group = 'default', $force = false, &$found = null) {
542
+		if (empty($group))
543 543
 			$group = 'default';
544 544
 
545
-		if ( $this->multisite && ! isset( $this->global_groups[ $group ] ) )
546
-			$key = $this->blog_prefix . $key;
545
+		if ($this->multisite && ! isset($this->global_groups[$group]))
546
+			$key = $this->blog_prefix.$key;
547 547
 
548
-		if ( $this->_exists( $key, $group ) ) {
548
+		if ($this->_exists($key, $group)) {
549 549
 			$found = true;
550 550
 			$this->cache_hits += 1;
551
-			if ( is_object($this->cache[$group][$key]) )
551
+			if (is_object($this->cache[$group][$key]))
552 552
 				return clone $this->cache[$group][$key];
553 553
 			else
554 554
 				return $this->cache[$group][$key];
@@ -570,27 +570,27 @@  discard block
 block discarded – undo
570 570
 	 * @param string     $group  Optional. The group the key is in. Default 'default'.
571 571
 	 * @return false|int False on failure, the item's new value on success.
572 572
 	 */
573
-	public function incr( $key, $offset = 1, $group = 'default' ) {
574
-		if ( empty( $group ) )
573
+	public function incr($key, $offset = 1, $group = 'default') {
574
+		if (empty($group))
575 575
 			$group = 'default';
576 576
 
577
-		if ( $this->multisite && ! isset( $this->global_groups[ $group ] ) )
578
-			$key = $this->blog_prefix . $key;
577
+		if ($this->multisite && ! isset($this->global_groups[$group]))
578
+			$key = $this->blog_prefix.$key;
579 579
 
580
-		if ( ! $this->_exists( $key, $group ) )
580
+		if ( ! $this->_exists($key, $group))
581 581
 			return false;
582 582
 
583
-		if ( ! is_numeric( $this->cache[ $group ][ $key ] ) )
584
-			$this->cache[ $group ][ $key ] = 0;
583
+		if ( ! is_numeric($this->cache[$group][$key]))
584
+			$this->cache[$group][$key] = 0;
585 585
 
586 586
 		$offset = (int) $offset;
587 587
 
588
-		$this->cache[ $group ][ $key ] += $offset;
588
+		$this->cache[$group][$key] += $offset;
589 589
 
590
-		if ( $this->cache[ $group ][ $key ] < 0 )
591
-			$this->cache[ $group ][ $key ] = 0;
590
+		if ($this->cache[$group][$key] < 0)
591
+			$this->cache[$group][$key] = 0;
592 592
 
593
-		return $this->cache[ $group ][ $key ];
593
+		return $this->cache[$group][$key];
594 594
 	}
595 595
 
596 596
 	/**
@@ -607,18 +607,18 @@  discard block
 block discarded – undo
607 607
 	 * @param int        $expire Optional. When to expire the cache contents. Default 0 (no expiration).
608 608
 	 * @return bool False if not exists, true if contents were replaced.
609 609
 	 */
610
-	public function replace( $key, $data, $group = 'default', $expire = 0 ) {
611
-		if ( empty( $group ) )
610
+	public function replace($key, $data, $group = 'default', $expire = 0) {
611
+		if (empty($group))
612 612
 			$group = 'default';
613 613
 
614 614
 		$id = $key;
615
-		if ( $this->multisite && ! isset( $this->global_groups[ $group ] ) )
616
-			$id = $this->blog_prefix . $key;
615
+		if ($this->multisite && ! isset($this->global_groups[$group]))
616
+			$id = $this->blog_prefix.$key;
617 617
 
618
-		if ( ! $this->_exists( $id, $group ) )
618
+		if ( ! $this->_exists($id, $group))
619 619
 			return false;
620 620
 
621
-		return $this->set( $key, $data, $group, (int) $expire );
621
+		return $this->set($key, $data, $group, (int) $expire);
622 622
 	}
623 623
 
624 624
 	/**
@@ -631,12 +631,12 @@  discard block
 block discarded – undo
631 631
 	 * @see switch_to_blog()
632 632
 	 */
633 633
 	public function reset() {
634
-		_deprecated_function( __FUNCTION__, '3.5.0', 'switch_to_blog()' );
634
+		_deprecated_function(__FUNCTION__, '3.5.0', 'switch_to_blog()');
635 635
 
636 636
 		// Clear out non-global caches since the blog ID has changed.
637
-		foreach ( array_keys( $this->cache ) as $group ) {
638
-			if ( ! isset( $this->global_groups[ $group ] ) )
639
-				unset( $this->cache[ $group ] );
637
+		foreach (array_keys($this->cache) as $group) {
638
+			if ( ! isset($this->global_groups[$group]))
639
+				unset($this->cache[$group]);
640 640
 		}
641 641
 	}
642 642
 
@@ -661,14 +661,14 @@  discard block
 block discarded – undo
661 661
 	 * @param int        $expire Not Used.
662 662
 	 * @return true Always returns true.
663 663
 	 */
664
-	public function set( $key, $data, $group = 'default', $expire = 0 ) {
665
-		if ( empty( $group ) )
664
+	public function set($key, $data, $group = 'default', $expire = 0) {
665
+		if (empty($group))
666 666
 			$group = 'default';
667 667
 
668
-		if ( $this->multisite && ! isset( $this->global_groups[ $group ] ) )
669
-			$key = $this->blog_prefix . $key;
668
+		if ($this->multisite && ! isset($this->global_groups[$group]))
669
+			$key = $this->blog_prefix.$key;
670 670
 
671
-		if ( is_object( $data ) )
671
+		if (is_object($data))
672 672
 			$data = clone $data;
673 673
 
674 674
 		$this->cache[$group][$key] = $data;
@@ -691,7 +691,7 @@  discard block
 block discarded – undo
691 691
 		echo "</p>";
692 692
 		echo '<ul>';
693 693
 		foreach ($this->cache as $group => $cache) {
694
-			echo "<li><strong>Group:</strong> $group - ( " . number_format( strlen( serialize( $cache ) ) / KB_IN_BYTES, 2 ) . 'k )</li>';
694
+			echo "<li><strong>Group:</strong> $group - ( ".number_format(strlen(serialize($cache)) / KB_IN_BYTES, 2).'k )</li>';
695 695
 		}
696 696
 		echo '</ul>';
697 697
 	}
@@ -706,9 +706,9 @@  discard block
 block discarded – undo
706 706
 	 *
707 707
 	 * @param int $blog_id Blog ID.
708 708
 	 */
709
-	public function switch_to_blog( $blog_id ) {
709
+	public function switch_to_blog($blog_id) {
710 710
 		$blog_id = (int) $blog_id;
711
-		$this->blog_prefix = $this->multisite ? $blog_id . ':' : '';
711
+		$this->blog_prefix = $this->multisite ? $blog_id.':' : '';
712 712
 	}
713 713
 
714 714
 	/**
@@ -721,8 +721,8 @@  discard block
 block discarded – undo
721 721
 	 * @param string     $group Cache group for the key existence check.
722 722
 	 * @return bool Whether the key exists in the cache for the given group.
723 723
 	 */
724
-	protected function _exists( $key, $group ) {
725
-		return isset( $this->cache[ $group ] ) && ( isset( $this->cache[ $group ][ $key ] ) || array_key_exists( $key, $this->cache[ $group ] ) );
724
+	protected function _exists($key, $group) {
725
+		return isset($this->cache[$group]) && (isset($this->cache[$group][$key]) || array_key_exists($key, $this->cache[$group]));
726 726
 	}
727 727
 
728 728
 	/**
@@ -732,14 +732,14 @@  discard block
 block discarded – undo
732 732
 	 */
733 733
 	public function __construct() {
734 734
 		$this->multisite = is_multisite();
735
-		$this->blog_prefix =  $this->multisite ? get_current_blog_id() . ':' : '';
735
+		$this->blog_prefix = $this->multisite ? get_current_blog_id().':' : '';
736 736
 
737 737
 
738 738
 		/**
739 739
 		 * @todo This should be moved to the PHP4 style constructor, PHP5
740 740
 		 * already calls __destruct()
741 741
 		 */
742
-		register_shutdown_function( array( $this, '__destruct' ) );
742
+		register_shutdown_function(array($this, '__destruct'));
743 743
 	}
744 744
 
745 745
 	/**
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   +1263 added lines, -1263 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 = array( $args->label, $args->label );
817
+	if (false === $args->label_count)
818
+		$args->label_count = array($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
 /**
@@ -2805,11 +2805,11 @@  discard block
 block discarded – undo
2805 2805
  *               'all_with_object_id', an array of WP_Term objects will be returned. If `$fields`
2806 2806
  *               is 'ids', an array of category ids. If `$fields` is 'names', an array of category names.
2807 2807
  */
2808
-function wp_get_post_categories( $post_id = 0, $args = array() ) {
2808
+function wp_get_post_categories($post_id = 0, $args = array()) {
2809 2809
 	$post_id = (int) $post_id;
2810 2810
 
2811 2811
 	$defaults = array('fields' => 'ids');
2812
-	$args = wp_parse_args( $args, $defaults );
2812
+	$args = wp_parse_args($args, $defaults);
2813 2813
 
2814 2814
 	$cats = wp_get_object_terms($post_id, 'category', $args);
2815 2815
 	return $cats;
@@ -2829,8 +2829,8 @@  discard block
 block discarded – undo
2829 2829
  * @param array $args Optional. Overwrite the defaults
2830 2830
  * @return array List of post tags.
2831 2831
  */
2832
-function wp_get_post_tags( $post_id = 0, $args = array() ) {
2833
-	return wp_get_post_terms( $post_id, 'post_tag', $args);
2832
+function wp_get_post_tags($post_id = 0, $args = array()) {
2833
+	return wp_get_post_terms($post_id, 'post_tag', $args);
2834 2834
 }
2835 2835
 
2836 2836
 /**
@@ -2849,11 +2849,11 @@  discard block
 block discarded – undo
2849 2849
  * @return array|WP_Error  List of post terms or empty array if no terms were found. WP_Error object
2850 2850
  *                         if `$taxonomy` doesn't exist.
2851 2851
  */
2852
-function wp_get_post_terms( $post_id = 0, $taxonomy = 'post_tag', $args = array() ) {
2852
+function wp_get_post_terms($post_id = 0, $taxonomy = 'post_tag', $args = array()) {
2853 2853
 	$post_id = (int) $post_id;
2854 2854
 
2855 2855
 	$defaults = array('fields' => 'all');
2856
-	$args = wp_parse_args( $args, $defaults );
2856
+	$args = wp_parse_args($args, $defaults);
2857 2857
 
2858 2858
 	$tags = wp_get_object_terms($post_id, $taxonomy, $args);
2859 2859
 
@@ -2873,11 +2873,11 @@  discard block
 block discarded – undo
2873 2873
  * @return array|false Array of recent posts, where the type of each element is determined by $output parameter.
2874 2874
  *                     Empty array on failure.
2875 2875
  */
2876
-function wp_get_recent_posts( $args = array(), $output = ARRAY_A ) {
2876
+function wp_get_recent_posts($args = array(), $output = ARRAY_A) {
2877 2877
 
2878
-	if ( is_numeric( $args ) ) {
2879
-		_deprecated_argument( __FUNCTION__, '3.1.0', __( 'Passing an integer number of posts is deprecated. Pass an array of arguments instead.' ) );
2880
-		$args = array( 'numberposts' => absint( $args ) );
2878
+	if (is_numeric($args)) {
2879
+		_deprecated_argument(__FUNCTION__, '3.1.0', __('Passing an integer number of posts is deprecated. Pass an array of arguments instead.'));
2880
+		$args = array('numberposts' => absint($args));
2881 2881
 	}
2882 2882
 
2883 2883
 	// Set default arguments.
@@ -2890,14 +2890,14 @@  discard block
 block discarded – undo
2890 2890
 		'suppress_filters' => true
2891 2891
 	);
2892 2892
 
2893
-	$r = wp_parse_args( $args, $defaults );
2893
+	$r = wp_parse_args($args, $defaults);
2894 2894
 
2895
-	$results = get_posts( $r );
2895
+	$results = get_posts($r);
2896 2896
 
2897 2897
 	// Backward compatibility. Prior to 3.1 expected posts to be returned in array.
2898
-	if ( ARRAY_A == $output ){
2899
-		foreach ( $results as $key => $result ) {
2900
-			$results[$key] = get_object_vars( $result );
2898
+	if (ARRAY_A == $output) {
2899
+		foreach ($results as $key => $result) {
2900
+			$results[$key] = get_object_vars($result);
2901 2901
 		}
2902 2902
 		return $results ? $results : array();
2903 2903
 	}
@@ -2965,7 +2965,7 @@  discard block
 block discarded – undo
2965 2965
  * @param bool  $wp_error Optional. Whether to return a WP_Error on failure. Default false.
2966 2966
  * @return int|WP_Error The post ID on success. The value 0 or WP_Error on failure.
2967 2967
  */
2968
-function wp_insert_post( $postarr, $wp_error = false ) {
2968
+function wp_insert_post($postarr, $wp_error = false) {
2969 2969
 	global $wpdb;
2970 2970
 
2971 2971
 	$user_id = get_current_user_id();
@@ -2992,7 +2992,7 @@  discard block
 block discarded – undo
2992 2992
 
2993 2993
 	$postarr = wp_parse_args($postarr, $defaults);
2994 2994
 
2995
-	unset( $postarr[ 'filter' ] );
2995
+	unset($postarr['filter']);
2996 2996
 
2997 2997
 	$postarr = sanitize_post($postarr, 'db');
2998 2998
 
@@ -3001,42 +3001,42 @@  discard block
 block discarded – undo
3001 3001
 	$update = false;
3002 3002
 	$guid = $postarr['guid'];
3003 3003
 
3004
-	if ( ! empty( $postarr['ID'] ) ) {
3004
+	if ( ! empty($postarr['ID'])) {
3005 3005
 		$update = true;
3006 3006
 
3007 3007
 		// Get the post ID and GUID.
3008 3008
 		$post_ID = $postarr['ID'];
3009
-		$post_before = get_post( $post_ID );
3010
-		if ( is_null( $post_before ) ) {
3011
-			if ( $wp_error ) {
3012
-				return new WP_Error( 'invalid_post', __( 'Invalid post ID.' ) );
3009
+		$post_before = get_post($post_ID);
3010
+		if (is_null($post_before)) {
3011
+			if ($wp_error) {
3012
+				return new WP_Error('invalid_post', __('Invalid post ID.'));
3013 3013
 			}
3014 3014
 			return 0;
3015 3015
 		}
3016 3016
 
3017
-		$guid = get_post_field( 'guid', $post_ID );
3018
-		$previous_status = get_post_field('post_status', $post_ID );
3017
+		$guid = get_post_field('guid', $post_ID);
3018
+		$previous_status = get_post_field('post_status', $post_ID);
3019 3019
 	} else {
3020 3020
 		$previous_status = 'new';
3021 3021
 	}
3022 3022
 
3023
-	$post_type = empty( $postarr['post_type'] ) ? 'post' : $postarr['post_type'];
3023
+	$post_type = empty($postarr['post_type']) ? 'post' : $postarr['post_type'];
3024 3024
 
3025 3025
 	$post_title = $postarr['post_title'];
3026 3026
 	$post_content = $postarr['post_content'];
3027 3027
 	$post_excerpt = $postarr['post_excerpt'];
3028
-	if ( isset( $postarr['post_name'] ) ) {
3028
+	if (isset($postarr['post_name'])) {
3029 3029
 		$post_name = $postarr['post_name'];
3030
-	} elseif ( $update ) {
3030
+	} elseif ($update) {
3031 3031
 		// For an update, don't modify the post_name if it wasn't supplied as an argument.
3032 3032
 		$post_name = $post_before->post_name;
3033 3033
 	}
3034 3034
 
3035 3035
 	$maybe_empty = 'attachment' !== $post_type
3036 3036
 		&& ! $post_content && ! $post_title && ! $post_excerpt
3037
-		&& post_type_supports( $post_type, 'editor' )
3038
-		&& post_type_supports( $post_type, 'title' )
3039
-		&& post_type_supports( $post_type, 'excerpt' );
3037
+		&& post_type_supports($post_type, 'editor')
3038
+		&& post_type_supports($post_type, 'title')
3039
+		&& post_type_supports($post_type, 'excerpt');
3040 3040
 
3041 3041
 	/**
3042 3042
 	 * Filters whether the post should be considered "empty".
@@ -3054,36 +3054,36 @@  discard block
 block discarded – undo
3054 3054
 	 * @param bool  $maybe_empty Whether the post should be considered "empty".
3055 3055
 	 * @param array $postarr     Array of post data.
3056 3056
 	 */
3057
-	if ( apply_filters( 'wp_insert_post_empty_content', $maybe_empty, $postarr ) ) {
3058
-		if ( $wp_error ) {
3059
-			return new WP_Error( 'empty_content', __( 'Content, title, and excerpt are empty.' ) );
3057
+	if (apply_filters('wp_insert_post_empty_content', $maybe_empty, $postarr)) {
3058
+		if ($wp_error) {
3059
+			return new WP_Error('empty_content', __('Content, title, and excerpt are empty.'));
3060 3060
 		} else {
3061 3061
 			return 0;
3062 3062
 		}
3063 3063
 	}
3064 3064
 
3065
-	$post_status = empty( $postarr['post_status'] ) ? 'draft' : $postarr['post_status'];
3066
-	if ( 'attachment' === $post_type && ! in_array( $post_status, array( 'inherit', 'private', 'trash', 'auto-draft' ), true ) ) {
3065
+	$post_status = empty($postarr['post_status']) ? 'draft' : $postarr['post_status'];
3066
+	if ('attachment' === $post_type && ! in_array($post_status, array('inherit', 'private', 'trash', 'auto-draft'), true)) {
3067 3067
 		$post_status = 'inherit';
3068 3068
 	}
3069 3069
 
3070
-	if ( ! empty( $postarr['post_category'] ) ) {
3070
+	if ( ! empty($postarr['post_category'])) {
3071 3071
 		// Filter out empty terms.
3072
-		$post_category = array_filter( $postarr['post_category'] );
3072
+		$post_category = array_filter($postarr['post_category']);
3073 3073
 	}
3074 3074
 
3075 3075
 	// Make sure we set a valid category.
3076
-	if ( empty( $post_category ) || 0 == count( $post_category ) || ! is_array( $post_category ) ) {
3076
+	if (empty($post_category) || 0 == count($post_category) || ! is_array($post_category)) {
3077 3077
 		// 'post' requires at least one category.
3078
-		if ( 'post' == $post_type && 'auto-draft' != $post_status ) {
3079
-			$post_category = array( get_option('default_category') );
3078
+		if ('post' == $post_type && 'auto-draft' != $post_status) {
3079
+			$post_category = array(get_option('default_category'));
3080 3080
 		} else {
3081 3081
 			$post_category = array();
3082 3082
 		}
3083 3083
 	}
3084 3084
 
3085 3085
 	// Don't allow contributors to set the post slug for pending review posts.
3086
-	if ( 'pending' == $post_status && !current_user_can( 'publish_posts' ) ) {
3086
+	if ('pending' == $post_status && ! current_user_can('publish_posts')) {
3087 3087
 		$post_name = '';
3088 3088
 	}
3089 3089
 
@@ -3091,16 +3091,16 @@  discard block
 block discarded – undo
3091 3091
 	 * Create a valid post name. Drafts and pending posts are allowed to have
3092 3092
 	 * an empty post name.
3093 3093
 	 */
3094
-	if ( empty($post_name) ) {
3095
-		if ( !in_array( $post_status, array( 'draft', 'pending', 'auto-draft' ) ) ) {
3094
+	if (empty($post_name)) {
3095
+		if ( ! in_array($post_status, array('draft', 'pending', 'auto-draft'))) {
3096 3096
 			$post_name = sanitize_title($post_title);
3097 3097
 		} else {
3098 3098
 			$post_name = '';
3099 3099
 		}
3100 3100
 	} else {
3101 3101
 		// On updates, we need to check to see if it's using the old, fixed sanitization context.
3102
-		$check_name = sanitize_title( $post_name, '', 'old-save' );
3103
-		if ( $update && strtolower( urlencode( $post_name ) ) == $check_name && get_post_field( 'post_name', $post_ID ) == $check_name ) {
3102
+		$check_name = sanitize_title($post_name, '', 'old-save');
3103
+		if ($update && strtolower(urlencode($post_name)) == $check_name && get_post_field('post_name', $post_ID) == $check_name) {
3104 3104
 			$post_name = $check_name;
3105 3105
 		} else { // new post, or slug has changed.
3106 3106
 			$post_name = sanitize_title($post_name);
@@ -3111,32 +3111,32 @@  discard block
 block discarded – undo
3111 3111
 	 * If the post date is empty (due to having been new or a draft) and status
3112 3112
 	 * is not 'draft' or 'pending', set date to now.
3113 3113
 	 */
3114
-	if ( empty( $postarr['post_date'] ) || '0000-00-00 00:00:00' == $postarr['post_date'] ) {
3115
-		if ( empty( $postarr['post_date_gmt'] ) || '0000-00-00 00:00:00' == $postarr['post_date_gmt'] ) {
3116
-			$post_date = current_time( 'mysql' );
3114
+	if (empty($postarr['post_date']) || '0000-00-00 00:00:00' == $postarr['post_date']) {
3115
+		if (empty($postarr['post_date_gmt']) || '0000-00-00 00:00:00' == $postarr['post_date_gmt']) {
3116
+			$post_date = current_time('mysql');
3117 3117
 		} else {
3118
-			$post_date = get_date_from_gmt( $postarr['post_date_gmt'] );
3118
+			$post_date = get_date_from_gmt($postarr['post_date_gmt']);
3119 3119
 		}
3120 3120
 	} else {
3121 3121
 		$post_date = $postarr['post_date'];
3122 3122
 	}
3123 3123
 
3124 3124
 	// Validate the date.
3125
-	$mm = substr( $post_date, 5, 2 );
3126
-	$jj = substr( $post_date, 8, 2 );
3127
-	$aa = substr( $post_date, 0, 4 );
3128
-	$valid_date = wp_checkdate( $mm, $jj, $aa, $post_date );
3129
-	if ( ! $valid_date ) {
3130
-		if ( $wp_error ) {
3131
-			return new WP_Error( 'invalid_date', __( 'Invalid date.' ) );
3125
+	$mm = substr($post_date, 5, 2);
3126
+	$jj = substr($post_date, 8, 2);
3127
+	$aa = substr($post_date, 0, 4);
3128
+	$valid_date = wp_checkdate($mm, $jj, $aa, $post_date);
3129
+	if ( ! $valid_date) {
3130
+		if ($wp_error) {
3131
+			return new WP_Error('invalid_date', __('Invalid date.'));
3132 3132
 		} else {
3133 3133
 			return 0;
3134 3134
 		}
3135 3135
 	}
3136 3136
 
3137
-	if ( empty( $postarr['post_date_gmt'] ) || '0000-00-00 00:00:00' == $postarr['post_date_gmt'] ) {
3138
-		if ( ! in_array( $post_status, array( 'draft', 'pending', 'auto-draft' ) ) ) {
3139
-			$post_date_gmt = get_gmt_from_date( $post_date );
3137
+	if (empty($postarr['post_date_gmt']) || '0000-00-00 00:00:00' == $postarr['post_date_gmt']) {
3138
+		if ( ! in_array($post_status, array('draft', 'pending', 'auto-draft'))) {
3139
+			$post_date_gmt = get_gmt_from_date($post_date);
3140 3140
 		} else {
3141 3141
 			$post_date_gmt = '0000-00-00 00:00:00';
3142 3142
 		}
@@ -3144,34 +3144,34 @@  discard block
 block discarded – undo
3144 3144
 		$post_date_gmt = $postarr['post_date_gmt'];
3145 3145
 	}
3146 3146
 
3147
-	if ( $update || '0000-00-00 00:00:00' == $post_date ) {
3148
-		$post_modified     = current_time( 'mysql' );
3149
-		$post_modified_gmt = current_time( 'mysql', 1 );
3147
+	if ($update || '0000-00-00 00:00:00' == $post_date) {
3148
+		$post_modified     = current_time('mysql');
3149
+		$post_modified_gmt = current_time('mysql', 1);
3150 3150
 	} else {
3151 3151
 		$post_modified     = $post_date;
3152 3152
 		$post_modified_gmt = $post_date_gmt;
3153 3153
 	}
3154 3154
 
3155
-	if ( 'attachment' !== $post_type ) {
3156
-		if ( 'publish' == $post_status ) {
3155
+	if ('attachment' !== $post_type) {
3156
+		if ('publish' == $post_status) {
3157 3157
 			$now = gmdate('Y-m-d H:i:59');
3158
-			if ( mysql2date('U', $post_date_gmt, false) > mysql2date('U', $now, false) ) {
3158
+			if (mysql2date('U', $post_date_gmt, false) > mysql2date('U', $now, false)) {
3159 3159
 				$post_status = 'future';
3160 3160
 			}
3161
-		} elseif ( 'future' == $post_status ) {
3161
+		} elseif ('future' == $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 = 'publish';
3165 3165
 			}
3166 3166
 		}
3167 3167
 	}
3168 3168
 
3169 3169
 	// Comment status.
3170
-	if ( empty( $postarr['comment_status'] ) ) {
3171
-		if ( $update ) {
3170
+	if (empty($postarr['comment_status'])) {
3171
+		if ($update) {
3172 3172
 			$comment_status = 'closed';
3173 3173
 		} else {
3174
-			$comment_status = get_default_comment_status( $post_type );
3174
+			$comment_status = get_default_comment_status($post_type);
3175 3175
 		}
3176 3176
 	} else {
3177 3177
 		$comment_status = $postarr['comment_status'];
@@ -3179,28 +3179,28 @@  discard block
 block discarded – undo
3179 3179
 
3180 3180
 	// These variables are needed by compact() later.
3181 3181
 	$post_content_filtered = $postarr['post_content_filtered'];
3182
-	$post_author = isset( $postarr['post_author'] ) ? $postarr['post_author'] : $user_id;
3183
-	$ping_status = empty( $postarr['ping_status'] ) ? get_default_comment_status( $post_type, 'pingback' ) : $postarr['ping_status'];
3184
-	$to_ping = isset( $postarr['to_ping'] ) ? sanitize_trackback_urls( $postarr['to_ping'] ) : '';
3185
-	$pinged = isset( $postarr['pinged'] ) ? $postarr['pinged'] : '';
3186
-	$import_id = isset( $postarr['import_id'] ) ? $postarr['import_id'] : 0;
3182
+	$post_author = isset($postarr['post_author']) ? $postarr['post_author'] : $user_id;
3183
+	$ping_status = empty($postarr['ping_status']) ? get_default_comment_status($post_type, 'pingback') : $postarr['ping_status'];
3184
+	$to_ping = isset($postarr['to_ping']) ? sanitize_trackback_urls($postarr['to_ping']) : '';
3185
+	$pinged = isset($postarr['pinged']) ? $postarr['pinged'] : '';
3186
+	$import_id = isset($postarr['import_id']) ? $postarr['import_id'] : 0;
3187 3187
 
3188 3188
 	/*
3189 3189
 	 * The 'wp_insert_post_parent' filter expects all variables to be present.
3190 3190
 	 * Previously, these variables would have already been extracted
3191 3191
 	 */
3192
-	if ( isset( $postarr['menu_order'] ) ) {
3192
+	if (isset($postarr['menu_order'])) {
3193 3193
 		$menu_order = (int) $postarr['menu_order'];
3194 3194
 	} else {
3195 3195
 		$menu_order = 0;
3196 3196
 	}
3197 3197
 
3198
-	$post_password = isset( $postarr['post_password'] ) ? $postarr['post_password'] : '';
3199
-	if ( 'private' == $post_status ) {
3198
+	$post_password = isset($postarr['post_password']) ? $postarr['post_password'] : '';
3199
+	if ('private' == $post_status) {
3200 3200
 		$post_password = '';
3201 3201
 	}
3202 3202
 
3203
-	if ( isset( $postarr['post_parent'] ) ) {
3203
+	if (isset($postarr['post_parent'])) {
3204 3204
 		$post_parent = (int) $postarr['post_parent'];
3205 3205
 	} else {
3206 3206
 		$post_parent = 0;
@@ -3216,50 +3216,50 @@  discard block
 block discarded – undo
3216 3216
 	 * @param array $new_postarr Array of parsed post data.
3217 3217
 	 * @param array $postarr     Array of sanitized, but otherwise unmodified post data.
3218 3218
 	 */
3219
-	$post_parent = apply_filters( 'wp_insert_post_parent', $post_parent, $post_ID, compact( array_keys( $postarr ) ), $postarr );
3219
+	$post_parent = apply_filters('wp_insert_post_parent', $post_parent, $post_ID, compact(array_keys($postarr)), $postarr);
3220 3220
 
3221 3221
 	/*
3222 3222
 	 * If the post is being untrashed and it has a desired slug stored in post meta,
3223 3223
 	 * reassign it.
3224 3224
 	 */
3225
-	if ( 'trash' === $previous_status && 'trash' !== $post_status ) {
3226
-		$desired_post_slug = get_post_meta( $post_ID, '_wp_desired_post_slug', true );
3227
-		if ( $desired_post_slug ) {
3228
-			delete_post_meta( $post_ID, '_wp_desired_post_slug' );
3225
+	if ('trash' === $previous_status && 'trash' !== $post_status) {
3226
+		$desired_post_slug = get_post_meta($post_ID, '_wp_desired_post_slug', true);
3227
+		if ($desired_post_slug) {
3228
+			delete_post_meta($post_ID, '_wp_desired_post_slug');
3229 3229
 			$post_name = $desired_post_slug;
3230 3230
 		}
3231 3231
 	}
3232 3232
 
3233 3233
 	// If a trashed post has the desired slug, change it and let this post have it.
3234
-	if ( 'trash' !== $post_status && $post_name ) {
3235
-		wp_add_trashed_suffix_to_post_name_for_trashed_posts( $post_name, $post_ID );
3234
+	if ('trash' !== $post_status && $post_name) {
3235
+		wp_add_trashed_suffix_to_post_name_for_trashed_posts($post_name, $post_ID);
3236 3236
 	}
3237 3237
 
3238 3238
 	// When trashing an existing post, change its slug to allow non-trashed posts to use it.
3239
-	if ( 'trash' === $post_status && 'trash' !== $previous_status && 'new' !== $previous_status ) {
3240
-		$post_name = wp_add_trashed_suffix_to_post_name_for_post( $post_ID );
3239
+	if ('trash' === $post_status && 'trash' !== $previous_status && 'new' !== $previous_status) {
3240
+		$post_name = wp_add_trashed_suffix_to_post_name_for_post($post_ID);
3241 3241
 	}
3242 3242
 
3243
-	$post_name = wp_unique_post_slug( $post_name, $post_ID, $post_status, $post_type, $post_parent );
3243
+	$post_name = wp_unique_post_slug($post_name, $post_ID, $post_status, $post_type, $post_parent);
3244 3244
 
3245 3245
 	// Don't unslash.
3246
-	$post_mime_type = isset( $postarr['post_mime_type'] ) ? $postarr['post_mime_type'] : '';
3246
+	$post_mime_type = isset($postarr['post_mime_type']) ? $postarr['post_mime_type'] : '';
3247 3247
 
3248 3248
 	// Expected_slashed (everything!).
3249
-	$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' );
3249
+	$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');
3250 3250
 
3251
-	$emoji_fields = array( 'post_title', 'post_content', 'post_excerpt' );
3251
+	$emoji_fields = array('post_title', 'post_content', 'post_excerpt');
3252 3252
 
3253
-	foreach ( $emoji_fields as $emoji_field ) {
3254
-		if ( isset( $data[ $emoji_field ] ) ) {
3255
-			$charset = $wpdb->get_col_charset( $wpdb->posts, $emoji_field );
3256
-			if ( 'utf8' === $charset ) {
3257
-				$data[ $emoji_field ] = wp_encode_emoji( $data[ $emoji_field ] );
3253
+	foreach ($emoji_fields as $emoji_field) {
3254
+		if (isset($data[$emoji_field])) {
3255
+			$charset = $wpdb->get_col_charset($wpdb->posts, $emoji_field);
3256
+			if ('utf8' === $charset) {
3257
+				$data[$emoji_field] = wp_encode_emoji($data[$emoji_field]);
3258 3258
 			}
3259 3259
 		}
3260 3260
 	}
3261 3261
 
3262
-	if ( 'attachment' === $post_type ) {
3262
+	if ('attachment' === $post_type) {
3263 3263
 		/**
3264 3264
 		 * Filters attachment post data before it is updated in or added to the database.
3265 3265
 		 *
@@ -3268,7 +3268,7 @@  discard block
 block discarded – undo
3268 3268
 		 * @param array $data    An array of sanitized attachment post data.
3269 3269
 		 * @param array $postarr An array of unsanitized attachment post data.
3270 3270
 		 */
3271
-		$data = apply_filters( 'wp_insert_attachment_data', $data, $postarr );
3271
+		$data = apply_filters('wp_insert_attachment_data', $data, $postarr);
3272 3272
 	} else {
3273 3273
 		/**
3274 3274
 		 * Filters slashed post data just before it is inserted into the database.
@@ -3278,12 +3278,12 @@  discard block
 block discarded – undo
3278 3278
 		 * @param array $data    An array of slashed post data.
3279 3279
 		 * @param array $postarr An array of sanitized, but otherwise unmodified post data.
3280 3280
 		 */
3281
-		$data = apply_filters( 'wp_insert_post_data', $data, $postarr );
3281
+		$data = apply_filters('wp_insert_post_data', $data, $postarr);
3282 3282
 	}
3283
-	$data = wp_unslash( $data );
3284
-	$where = array( 'ID' => $post_ID );
3283
+	$data = wp_unslash($data);
3284
+	$where = array('ID' => $post_ID);
3285 3285
 
3286
-	if ( $update ) {
3286
+	if ($update) {
3287 3287
 		/**
3288 3288
 		 * Fires immediately before an existing post is updated in the database.
3289 3289
 		 *
@@ -3292,9 +3292,9 @@  discard block
 block discarded – undo
3292 3292
 		 * @param int   $post_ID Post ID.
3293 3293
 		 * @param array $data    Array of unslashed post data.
3294 3294
 		 */
3295
-		do_action( 'pre_post_update', $post_ID, $data );
3296
-		if ( false === $wpdb->update( $wpdb->posts, $data, $where ) ) {
3297
-			if ( $wp_error ) {
3295
+		do_action('pre_post_update', $post_ID, $data);
3296
+		if (false === $wpdb->update($wpdb->posts, $data, $where)) {
3297
+			if ($wp_error) {
3298 3298
 				return new WP_Error('db_update_error', __('Could not update post in the database'), $wpdb->last_error);
3299 3299
 			} else {
3300 3300
 				return 0;
@@ -3302,14 +3302,14 @@  discard block
 block discarded – undo
3302 3302
 		}
3303 3303
 	} else {
3304 3304
 		// If there is a suggested ID, use it if not already present.
3305
-		if ( ! empty( $import_id ) ) {
3305
+		if ( ! empty($import_id)) {
3306 3306
 			$import_id = (int) $import_id;
3307
-			if ( ! $wpdb->get_var( $wpdb->prepare("SELECT ID FROM $wpdb->posts WHERE ID = %d", $import_id) ) ) {
3307
+			if ( ! $wpdb->get_var($wpdb->prepare("SELECT ID FROM $wpdb->posts WHERE ID = %d", $import_id))) {
3308 3308
 				$data['ID'] = $import_id;
3309 3309
 			}
3310 3310
 		}
3311
-		if ( false === $wpdb->insert( $wpdb->posts, $data ) ) {
3312
-			if ( $wp_error ) {
3311
+		if (false === $wpdb->insert($wpdb->posts, $data)) {
3312
+			if ($wp_error) {
3313 3313
 				return new WP_Error('db_insert_error', __('Could not insert post into the database'), $wpdb->last_error);
3314 3314
 			} else {
3315 3315
 				return 0;
@@ -3318,108 +3318,108 @@  discard block
 block discarded – undo
3318 3318
 		$post_ID = (int) $wpdb->insert_id;
3319 3319
 
3320 3320
 		// Use the newly generated $post_ID.
3321
-		$where = array( 'ID' => $post_ID );
3321
+		$where = array('ID' => $post_ID);
3322 3322
 	}
3323 3323
 
3324
-	if ( empty( $data['post_name'] ) && ! in_array( $data['post_status'], array( 'draft', 'pending', 'auto-draft' ) ) ) {
3325
-		$data['post_name'] = wp_unique_post_slug( sanitize_title( $data['post_title'], $post_ID ), $post_ID, $data['post_status'], $post_type, $post_parent );
3326
-		$wpdb->update( $wpdb->posts, array( 'post_name' => $data['post_name'] ), $where );
3327
-		clean_post_cache( $post_ID );
3324
+	if (empty($data['post_name']) && ! in_array($data['post_status'], array('draft', 'pending', 'auto-draft'))) {
3325
+		$data['post_name'] = wp_unique_post_slug(sanitize_title($data['post_title'], $post_ID), $post_ID, $data['post_status'], $post_type, $post_parent);
3326
+		$wpdb->update($wpdb->posts, array('post_name' => $data['post_name']), $where);
3327
+		clean_post_cache($post_ID);
3328 3328
 	}
3329 3329
 
3330
-	if ( is_object_in_taxonomy( $post_type, 'category' ) ) {
3331
-		wp_set_post_categories( $post_ID, $post_category );
3330
+	if (is_object_in_taxonomy($post_type, 'category')) {
3331
+		wp_set_post_categories($post_ID, $post_category);
3332 3332
 	}
3333 3333
 
3334
-	if ( isset( $postarr['tags_input'] ) && is_object_in_taxonomy( $post_type, 'post_tag' ) ) {
3335
-		wp_set_post_tags( $post_ID, $postarr['tags_input'] );
3334
+	if (isset($postarr['tags_input']) && is_object_in_taxonomy($post_type, 'post_tag')) {
3335
+		wp_set_post_tags($post_ID, $postarr['tags_input']);
3336 3336
 	}
3337 3337
 
3338 3338
 	// New-style support for all custom taxonomies.
3339
-	if ( ! empty( $postarr['tax_input'] ) ) {
3340
-		foreach ( $postarr['tax_input'] as $taxonomy => $tags ) {
3339
+	if ( ! empty($postarr['tax_input'])) {
3340
+		foreach ($postarr['tax_input'] as $taxonomy => $tags) {
3341 3341
 			$taxonomy_obj = get_taxonomy($taxonomy);
3342
-			if ( ! $taxonomy_obj ) {
3342
+			if ( ! $taxonomy_obj) {
3343 3343
 				/* translators: %s: taxonomy name */
3344
-				_doing_it_wrong( __FUNCTION__, sprintf( __( 'Invalid taxonomy: %s.' ), $taxonomy ), '4.4.0' );
3344
+				_doing_it_wrong(__FUNCTION__, sprintf(__('Invalid taxonomy: %s.'), $taxonomy), '4.4.0');
3345 3345
 				continue;
3346 3346
 			}
3347 3347
 
3348 3348
 			// array = hierarchical, string = non-hierarchical.
3349
-			if ( is_array( $tags ) ) {
3349
+			if (is_array($tags)) {
3350 3350
 				$tags = array_filter($tags);
3351 3351
 			}
3352
-			if ( current_user_can( $taxonomy_obj->cap->assign_terms ) ) {
3353
-				wp_set_post_terms( $post_ID, $tags, $taxonomy );
3352
+			if (current_user_can($taxonomy_obj->cap->assign_terms)) {
3353
+				wp_set_post_terms($post_ID, $tags, $taxonomy);
3354 3354
 			}
3355 3355
 		}
3356 3356
 	}
3357 3357
 
3358
-	if ( ! empty( $postarr['meta_input'] ) ) {
3359
-		foreach ( $postarr['meta_input'] as $field => $value ) {
3360
-			update_post_meta( $post_ID, $field, $value );
3358
+	if ( ! empty($postarr['meta_input'])) {
3359
+		foreach ($postarr['meta_input'] as $field => $value) {
3360
+			update_post_meta($post_ID, $field, $value);
3361 3361
 		}
3362 3362
 	}
3363 3363
 
3364
-	$current_guid = get_post_field( 'guid', $post_ID );
3364
+	$current_guid = get_post_field('guid', $post_ID);
3365 3365
 
3366 3366
 	// Set GUID.
3367
-	if ( ! $update && '' == $current_guid ) {
3368
-		$wpdb->update( $wpdb->posts, array( 'guid' => get_permalink( $post_ID ) ), $where );
3367
+	if ( ! $update && '' == $current_guid) {
3368
+		$wpdb->update($wpdb->posts, array('guid' => get_permalink($post_ID)), $where);
3369 3369
 	}
3370 3370
 
3371
-	if ( 'attachment' === $postarr['post_type'] ) {
3372
-		if ( ! empty( $postarr['file'] ) ) {
3373
-			update_attached_file( $post_ID, $postarr['file'] );
3371
+	if ('attachment' === $postarr['post_type']) {
3372
+		if ( ! empty($postarr['file'])) {
3373
+			update_attached_file($post_ID, $postarr['file']);
3374 3374
 		}
3375 3375
 
3376
-		if ( ! empty( $postarr['context'] ) ) {
3377
-			add_post_meta( $post_ID, '_wp_attachment_context', $postarr['context'], true );
3376
+		if ( ! empty($postarr['context'])) {
3377
+			add_post_meta($post_ID, '_wp_attachment_context', $postarr['context'], true);
3378 3378
 		}
3379 3379
 	}
3380 3380
 
3381 3381
 	// Set or remove featured image.
3382
-	if ( isset( $postarr['_thumbnail_id'] ) ) {
3383
-		$thumbnail_support = current_theme_supports( 'post-thumbnails', $post_type ) && post_type_supports( $post_type, 'thumbnail' ) || 'revision' === $post_type;
3384
-		if ( ! $thumbnail_support && 'attachment' === $post_type && $post_mime_type ) {
3385
-			if ( wp_attachment_is( 'audio', $post_ID ) ) {
3386
-				$thumbnail_support = post_type_supports( 'attachment:audio', 'thumbnail' ) || current_theme_supports( 'post-thumbnails', 'attachment:audio' );
3387
-			} elseif ( wp_attachment_is( 'video', $post_ID ) ) {
3388
-				$thumbnail_support = post_type_supports( 'attachment:video', 'thumbnail' ) || current_theme_supports( 'post-thumbnails', 'attachment:video' );
3382
+	if (isset($postarr['_thumbnail_id'])) {
3383
+		$thumbnail_support = current_theme_supports('post-thumbnails', $post_type) && post_type_supports($post_type, 'thumbnail') || 'revision' === $post_type;
3384
+		if ( ! $thumbnail_support && 'attachment' === $post_type && $post_mime_type) {
3385
+			if (wp_attachment_is('audio', $post_ID)) {
3386
+				$thumbnail_support = post_type_supports('attachment:audio', 'thumbnail') || current_theme_supports('post-thumbnails', 'attachment:audio');
3387
+			} elseif (wp_attachment_is('video', $post_ID)) {
3388
+				$thumbnail_support = post_type_supports('attachment:video', 'thumbnail') || current_theme_supports('post-thumbnails', 'attachment:video');
3389 3389
 			}
3390 3390
 		}
3391 3391
 
3392
-		if ( $thumbnail_support ) {
3393
-			$thumbnail_id = intval( $postarr['_thumbnail_id'] );
3392
+		if ($thumbnail_support) {
3393
+			$thumbnail_id = intval($postarr['_thumbnail_id']);
3394 3394
 			if ( -1 === $thumbnail_id ) {
3395
-				delete_post_thumbnail( $post_ID );
3395
+				delete_post_thumbnail($post_ID);
3396 3396
 			} else {
3397
-				set_post_thumbnail( $post_ID, $thumbnail_id );
3397
+				set_post_thumbnail($post_ID, $thumbnail_id);
3398 3398
 			}
3399 3399
 		}
3400 3400
 	}
3401 3401
 
3402
-	clean_post_cache( $post_ID );
3402
+	clean_post_cache($post_ID);
3403 3403
 
3404
-	$post = get_post( $post_ID );
3404
+	$post = get_post($post_ID);
3405 3405
 
3406
-	if ( ! empty( $postarr['page_template'] ) ) {
3406
+	if ( ! empty($postarr['page_template'])) {
3407 3407
 		$post->page_template = $postarr['page_template'];
3408
-		$page_templates = wp_get_theme()->get_page_templates( $post );
3409
-		if ( 'default' != $postarr['page_template'] && ! isset( $page_templates[ $postarr['page_template'] ] ) ) {
3410
-			if ( $wp_error ) {
3411
-				return new WP_Error( 'invalid_page_template', __( 'Invalid page template.' ) );
3408
+		$page_templates = wp_get_theme()->get_page_templates($post);
3409
+		if ('default' != $postarr['page_template'] && ! isset($page_templates[$postarr['page_template']])) {
3410
+			if ($wp_error) {
3411
+				return new WP_Error('invalid_page_template', __('Invalid page template.'));
3412 3412
 			}
3413
-			update_post_meta( $post_ID, '_wp_page_template', 'default' );
3413
+			update_post_meta($post_ID, '_wp_page_template', 'default');
3414 3414
 		} else {
3415
-			update_post_meta( $post_ID, '_wp_page_template', $postarr['page_template'] );
3415
+			update_post_meta($post_ID, '_wp_page_template', $postarr['page_template']);
3416 3416
 		}
3417 3417
 	}
3418 3418
 
3419
-	if ( 'attachment' !== $postarr['post_type'] ) {
3420
-		wp_transition_post_status( $data['post_status'], $previous_status, $post );
3419
+	if ('attachment' !== $postarr['post_type']) {
3420
+		wp_transition_post_status($data['post_status'], $previous_status, $post);
3421 3421
 	} else {
3422
-		if ( $update ) {
3422
+		if ($update) {
3423 3423
 			/**
3424 3424
 			 * Fires once an existing attachment has been updated.
3425 3425
 			 *
@@ -3427,8 +3427,8 @@  discard block
 block discarded – undo
3427 3427
 			 *
3428 3428
 			 * @param int $post_ID Attachment ID.
3429 3429
 			 */
3430
-			do_action( 'edit_attachment', $post_ID );
3431
-			$post_after = get_post( $post_ID );
3430
+			do_action('edit_attachment', $post_ID);
3431
+			$post_after = get_post($post_ID);
3432 3432
 
3433 3433
 			/**
3434 3434
 			 * Fires once an existing attachment has been updated.
@@ -3439,7 +3439,7 @@  discard block
 block discarded – undo
3439 3439
 			 * @param WP_Post $post_after   Post object following the update.
3440 3440
 			 * @param WP_Post $post_before  Post object before the update.
3441 3441
 			 */
3442
-			do_action( 'attachment_updated', $post_ID, $post_after, $post_before );
3442
+			do_action('attachment_updated', $post_ID, $post_after, $post_before);
3443 3443
 		} else {
3444 3444
 
3445 3445
 			/**
@@ -3449,13 +3449,13 @@  discard block
 block discarded – undo
3449 3449
 			 *
3450 3450
 			 * @param int $post_ID Attachment ID.
3451 3451
 			 */
3452
-			do_action( 'add_attachment', $post_ID );
3452
+			do_action('add_attachment', $post_ID);
3453 3453
 		}
3454 3454
 
3455 3455
 		return $post_ID;
3456 3456
 	}
3457 3457
 
3458
-	if ( $update ) {
3458
+	if ($update) {
3459 3459
 		/**
3460 3460
 		 * Fires once an existing post has been updated.
3461 3461
 		 *
@@ -3464,7 +3464,7 @@  discard block
 block discarded – undo
3464 3464
 		 * @param int     $post_ID Post ID.
3465 3465
 		 * @param WP_Post $post    Post object.
3466 3466
 		 */
3467
-		do_action( 'edit_post', $post_ID, $post );
3467
+		do_action('edit_post', $post_ID, $post);
3468 3468
 		$post_after = get_post($post_ID);
3469 3469
 
3470 3470
 		/**
@@ -3476,7 +3476,7 @@  discard block
 block discarded – undo
3476 3476
 		 * @param WP_Post $post_after   Post object following the update.
3477 3477
 		 * @param WP_Post $post_before  Post object before the update.
3478 3478
 		 */
3479
-		do_action( 'post_updated', $post_ID, $post_after, $post_before);
3479
+		do_action('post_updated', $post_ID, $post_after, $post_before);
3480 3480
 	}
3481 3481
 
3482 3482
 	/**
@@ -3491,7 +3491,7 @@  discard block
 block discarded – undo
3491 3491
 	 * @param WP_Post $post    Post object.
3492 3492
 	 * @param bool    $update  Whether this is an existing post being updated or not.
3493 3493
 	 */
3494
-	do_action( "save_post_{$post->post_type}", $post_ID, $post, $update );
3494
+	do_action("save_post_{$post->post_type}", $post_ID, $post, $update);
3495 3495
 
3496 3496
 	/**
3497 3497
 	 * Fires once a post has been saved.
@@ -3502,7 +3502,7 @@  discard block
 block discarded – undo
3502 3502
 	 * @param WP_Post $post    Post object.
3503 3503
 	 * @param bool    $update  Whether this is an existing post being updated or not.
3504 3504
 	 */
3505
-	do_action( 'save_post', $post_ID, $post, $update );
3505
+	do_action('save_post', $post_ID, $post, $update);
3506 3506
 
3507 3507
 	/**
3508 3508
 	 * Fires once a post has been saved.
@@ -3513,7 +3513,7 @@  discard block
 block discarded – undo
3513 3513
 	 * @param WP_Post $post    Post object.
3514 3514
 	 * @param bool    $update  Whether this is an existing post being updated or not.
3515 3515
 	 */
3516
-	do_action( 'wp_insert_post', $post_ID, $post, $update );
3516
+	do_action('wp_insert_post', $post_ID, $post, $update);
3517 3517
 
3518 3518
 	return $post_ID;
3519 3519
 }
@@ -3531,8 +3531,8 @@  discard block
 block discarded – undo
3531 3531
  * @param bool         $wp_error Optional. Allow return of WP_Error on failure. Default false.
3532 3532
  * @return int|WP_Error The value 0 or WP_Error on failure. The post ID on success.
3533 3533
  */
3534
-function wp_update_post( $postarr = array(), $wp_error = false ) {
3535
-	if ( is_object($postarr) ) {
3534
+function wp_update_post($postarr = array(), $wp_error = false) {
3535
+	if (is_object($postarr)) {
3536 3536
 		// Non-escaped post was passed.
3537 3537
 		$postarr = get_object_vars($postarr);
3538 3538
 		$postarr = wp_slash($postarr);
@@ -3541,9 +3541,9 @@  discard block
 block discarded – undo
3541 3541
 	// First, get all of the original fields.
3542 3542
 	$post = get_post($postarr['ID'], ARRAY_A);
3543 3543
 
3544
-	if ( is_null( $post ) ) {
3545
-		if ( $wp_error )
3546
-			return new WP_Error( 'invalid_post', __( 'Invalid post ID.' ) );
3544
+	if (is_null($post)) {
3545
+		if ($wp_error)
3546
+			return new WP_Error('invalid_post', __('Invalid post ID.'));
3547 3547
 		return 0;
3548 3548
 	}
3549 3549
 
@@ -3551,15 +3551,15 @@  discard block
 block discarded – undo
3551 3551
 	$post = wp_slash($post);
3552 3552
 
3553 3553
 	// Passed post category list overwrites existing category list if not empty.
3554
-	if ( isset($postarr['post_category']) && is_array($postarr['post_category'])
3555
-			 && 0 != count($postarr['post_category']) )
3554
+	if (isset($postarr['post_category']) && is_array($postarr['post_category'])
3555
+			 && 0 != count($postarr['post_category']))
3556 3556
 		$post_cats = $postarr['post_category'];
3557 3557
 	else
3558 3558
 		$post_cats = $post['post_category'];
3559 3559
 
3560 3560
 	// Drafts shouldn't be assigned a date unless explicitly done so by the user.
3561
-	if ( isset( $post['post_status'] ) && in_array($post['post_status'], array('draft', 'pending', 'auto-draft')) && empty($postarr['edit_date']) &&
3562
-			 ('0000-00-00 00:00:00' == $post['post_date_gmt']) )
3561
+	if (isset($post['post_status']) && in_array($post['post_status'], array('draft', 'pending', 'auto-draft')) && empty($postarr['edit_date']) &&
3562
+			 ('0000-00-00 00:00:00' == $post['post_date_gmt']))
3563 3563
 		$clear_date = true;
3564 3564
 	else
3565 3565
 		$clear_date = false;
@@ -3567,7 +3567,7 @@  discard block
 block discarded – undo
3567 3567
 	// Merge old and new fields with new fields overwriting old ones.
3568 3568
 	$postarr = array_merge($post, $postarr);
3569 3569
 	$postarr['post_category'] = $post_cats;
3570
-	if ( $clear_date ) {
3570
+	if ($clear_date) {
3571 3571
 		$postarr['post_date'] = current_time('mysql');
3572 3572
 		$postarr['post_date_gmt'] = '';
3573 3573
 	}
@@ -3575,7 +3575,7 @@  discard block
 block discarded – undo
3575 3575
 	if ($postarr['post_type'] == 'attachment')
3576 3576
 		return wp_insert_attachment($postarr);
3577 3577
 
3578
-	return wp_insert_post( $postarr, $wp_error );
3578
+	return wp_insert_post($postarr, $wp_error);
3579 3579
 }
3580 3580
 
3581 3581
 /**
@@ -3587,34 +3587,34 @@  discard block
 block discarded – undo
3587 3587
  *
3588 3588
  * @param int|WP_Post $post Post ID or post object.
3589 3589
  */
3590
-function wp_publish_post( $post ) {
3590
+function wp_publish_post($post) {
3591 3591
 	global $wpdb;
3592 3592
 
3593
-	if ( ! $post = get_post( $post ) )
3593
+	if ( ! $post = get_post($post))
3594 3594
 		return;
3595 3595
 
3596
-	if ( 'publish' == $post->post_status )
3596
+	if ('publish' == $post->post_status)
3597 3597
 		return;
3598 3598
 
3599
-	$wpdb->update( $wpdb->posts, array( 'post_status' => 'publish' ), array( 'ID' => $post->ID ) );
3599
+	$wpdb->update($wpdb->posts, array('post_status' => 'publish'), array('ID' => $post->ID));
3600 3600
 
3601
-	clean_post_cache( $post->ID );
3601
+	clean_post_cache($post->ID);
3602 3602
 
3603 3603
 	$old_status = $post->post_status;
3604 3604
 	$post->post_status = 'publish';
3605
-	wp_transition_post_status( 'publish', $old_status, $post );
3605
+	wp_transition_post_status('publish', $old_status, $post);
3606 3606
 
3607 3607
 	/** This action is documented in wp-includes/post.php */
3608
-	do_action( 'edit_post', $post->ID, $post );
3608
+	do_action('edit_post', $post->ID, $post);
3609 3609
 
3610 3610
 	/** This action is documented in wp-includes/post.php */
3611
-	do_action( "save_post_{$post->post_type}", $post->ID, $post, true );
3611
+	do_action("save_post_{$post->post_type}", $post->ID, $post, true);
3612 3612
 
3613 3613
 	/** This action is documented in wp-includes/post.php */
3614
-	do_action( 'save_post', $post->ID, $post, true );
3614
+	do_action('save_post', $post->ID, $post, true);
3615 3615
 
3616 3616
 	/** This action is documented in wp-includes/post.php */
3617
-	do_action( 'wp_insert_post', $post->ID, $post, true );
3617
+	do_action('wp_insert_post', $post->ID, $post, true);
3618 3618
 }
3619 3619
 
3620 3620
 /**
@@ -3627,26 +3627,26 @@  discard block
 block discarded – undo
3627 3627
  *
3628 3628
  * @param int|WP_Post $post_id Post ID or post object.
3629 3629
  */
3630
-function check_and_publish_future_post( $post_id ) {
3630
+function check_and_publish_future_post($post_id) {
3631 3631
 	$post = get_post($post_id);
3632 3632
 
3633
-	if ( empty($post) )
3633
+	if (empty($post))
3634 3634
 		return;
3635 3635
 
3636
-	if ( 'future' != $post->post_status )
3636
+	if ('future' != $post->post_status)
3637 3637
 		return;
3638 3638
 
3639
-	$time = strtotime( $post->post_date_gmt . ' GMT' );
3639
+	$time = strtotime($post->post_date_gmt.' GMT');
3640 3640
 
3641 3641
 	// Uh oh, someone jumped the gun!
3642
-	if ( $time > time() ) {
3643
-		wp_clear_scheduled_hook( 'publish_future_post', array( $post_id ) ); // clear anything else in the system
3644
-		wp_schedule_single_event( $time, 'publish_future_post', array( $post_id ) );
3642
+	if ($time > time()) {
3643
+		wp_clear_scheduled_hook('publish_future_post', array($post_id)); // clear anything else in the system
3644
+		wp_schedule_single_event($time, 'publish_future_post', array($post_id));
3645 3645
 		return;
3646 3646
 	}
3647 3647
 
3648 3648
 	// wp_publish_post() returns no meaningful value.
3649
-	wp_publish_post( $post_id );
3649
+	wp_publish_post($post_id);
3650 3650
 }
3651 3651
 
3652 3652
 /**
@@ -3664,8 +3664,8 @@  discard block
 block discarded – undo
3664 3664
  * @param int    $post_parent Post parent ID.
3665 3665
  * @return string Unique slug for the post, based on $post_name (with a -1, -2, etc. suffix)
3666 3666
  */
3667
-function wp_unique_post_slug( $slug, $post_ID, $post_status, $post_type, $post_parent ) {
3668
-	if ( in_array( $post_status, array( 'draft', 'pending', 'auto-draft' ) ) || ( 'inherit' == $post_status && 'revision' == $post_type ) )
3667
+function wp_unique_post_slug($slug, $post_ID, $post_status, $post_type, $post_parent) {
3668
+	if (in_array($post_status, array('draft', 'pending', 'auto-draft')) || ('inherit' == $post_status && 'revision' == $post_type))
3669 3669
 		return $slug;
3670 3670
 
3671 3671
 	global $wpdb, $wp_rewrite;
@@ -3673,13 +3673,13 @@  discard block
 block discarded – undo
3673 3673
 	$original_slug = $slug;
3674 3674
 
3675 3675
 	$feeds = $wp_rewrite->feeds;
3676
-	if ( ! is_array( $feeds ) )
3676
+	if ( ! is_array($feeds))
3677 3677
 		$feeds = array();
3678 3678
 
3679
-	if ( 'attachment' == $post_type ) {
3679
+	if ('attachment' == $post_type) {
3680 3680
 		// Attachment slugs must be unique across all types.
3681 3681
 		$check_sql = "SELECT post_name FROM $wpdb->posts WHERE post_name = %s AND ID != %d LIMIT 1";
3682
-		$post_name_check = $wpdb->get_var( $wpdb->prepare( $check_sql, $slug, $post_ID ) );
3682
+		$post_name_check = $wpdb->get_var($wpdb->prepare($check_sql, $slug, $post_ID));
3683 3683
 
3684 3684
 		/**
3685 3685
 		 * Filters whether the post slug would make a bad attachment slug.
@@ -3689,17 +3689,17 @@  discard block
 block discarded – undo
3689 3689
 		 * @param bool   $bad_slug Whether the slug would be bad as an attachment slug.
3690 3690
 		 * @param string $slug     The post slug.
3691 3691
 		 */
3692
-		if ( $post_name_check || in_array( $slug, $feeds ) || 'embed' === $slug || apply_filters( 'wp_unique_post_slug_is_bad_attachment_slug', false, $slug ) ) {
3692
+		if ($post_name_check || in_array($slug, $feeds) || 'embed' === $slug || apply_filters('wp_unique_post_slug_is_bad_attachment_slug', false, $slug)) {
3693 3693
 			$suffix = 2;
3694 3694
 			do {
3695
-				$alt_post_name = _truncate_post_slug( $slug, 200 - ( strlen( $suffix ) + 1 ) ) . "-$suffix";
3696
-				$post_name_check = $wpdb->get_var( $wpdb->prepare( $check_sql, $alt_post_name, $post_ID ) );
3695
+				$alt_post_name = _truncate_post_slug($slug, 200 - (strlen($suffix) + 1))."-$suffix";
3696
+				$post_name_check = $wpdb->get_var($wpdb->prepare($check_sql, $alt_post_name, $post_ID));
3697 3697
 				$suffix++;
3698
-			} while ( $post_name_check );
3698
+			} while ($post_name_check);
3699 3699
 			$slug = $alt_post_name;
3700 3700
 		}
3701
-	} elseif ( is_post_type_hierarchical( $post_type ) ) {
3702
-		if ( 'nav_menu_item' == $post_type )
3701
+	} elseif (is_post_type_hierarchical($post_type)) {
3702
+		if ('nav_menu_item' == $post_type)
3703 3703
 			return $slug;
3704 3704
 
3705 3705
 		/*
@@ -3707,7 +3707,7 @@  discard block
 block discarded – undo
3707 3707
 		 * namespace than posts so page slugs are allowed to overlap post slugs.
3708 3708
 		 */
3709 3709
 		$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";
3710
-		$post_name_check = $wpdb->get_var( $wpdb->prepare( $check_sql, $slug, $post_type, $post_ID, $post_parent ) );
3710
+		$post_name_check = $wpdb->get_var($wpdb->prepare($check_sql, $slug, $post_type, $post_ID, $post_parent));
3711 3711
 
3712 3712
 		/**
3713 3713
 		 * Filters whether the post slug would make a bad hierarchical post slug.
@@ -3719,26 +3719,26 @@  discard block
 block discarded – undo
3719 3719
 		 * @param string $post_type   Post type.
3720 3720
 		 * @param int    $post_parent Post parent ID.
3721 3721
 		 */
3722
-		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 ) ) {
3722
+		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)) {
3723 3723
 			$suffix = 2;
3724 3724
 			do {
3725
-				$alt_post_name = _truncate_post_slug( $slug, 200 - ( strlen( $suffix ) + 1 ) ) . "-$suffix";
3726
-				$post_name_check = $wpdb->get_var( $wpdb->prepare( $check_sql, $alt_post_name, $post_type, $post_ID, $post_parent ) );
3725
+				$alt_post_name = _truncate_post_slug($slug, 200 - (strlen($suffix) + 1))."-$suffix";
3726
+				$post_name_check = $wpdb->get_var($wpdb->prepare($check_sql, $alt_post_name, $post_type, $post_ID, $post_parent));
3727 3727
 				$suffix++;
3728
-			} while ( $post_name_check );
3728
+			} while ($post_name_check);
3729 3729
 			$slug = $alt_post_name;
3730 3730
 		}
3731 3731
 	} else {
3732 3732
 		// Post slugs must be unique across all posts.
3733 3733
 		$check_sql = "SELECT post_name FROM $wpdb->posts WHERE post_name = %s AND post_type = %s AND ID != %d LIMIT 1";
3734
-		$post_name_check = $wpdb->get_var( $wpdb->prepare( $check_sql, $slug, $post_type, $post_ID ) );
3734
+		$post_name_check = $wpdb->get_var($wpdb->prepare($check_sql, $slug, $post_type, $post_ID));
3735 3735
 
3736 3736
 		// Prevent new post slugs that could result in URLs that conflict with date archives.
3737
-		$post = get_post( $post_ID );
3737
+		$post = get_post($post_ID);
3738 3738
 		$conflicts_with_date_archive = false;
3739
-		if ( 'post' === $post_type && ( ! $post || $post->post_name !== $slug ) && preg_match( '/^[0-9]+$/', $slug ) && $slug_num = intval( $slug ) ) {
3740
-			$permastructs   = array_values( array_filter( explode( '/', get_option( 'permalink_structure' ) ) ) );
3741
-			$postname_index = array_search( '%postname%', $permastructs );
3739
+		if ('post' === $post_type && ( ! $post || $post->post_name !== $slug) && preg_match('/^[0-9]+$/', $slug) && $slug_num = intval($slug)) {
3740
+			$permastructs   = array_values(array_filter(explode('/', get_option('permalink_structure'))));
3741
+			$postname_index = array_search('%postname%', $permastructs);
3742 3742
 
3743 3743
 			/*
3744 3744
 			 * Potential date clashes are as follows:
@@ -3747,9 +3747,9 @@  discard block
 block discarded – undo
3747 3747
 			 * - An integer between 1 and 12 that follows 'year' conflicts with 'monthnum'.
3748 3748
 			 * - An integer between 1 and 31 that follows 'monthnum' conflicts with 'day'.
3749 3749
 			 */
3750
-			if ( 0 === $postname_index ||
3751
-				( $postname_index && '%year%' === $permastructs[ $postname_index - 1 ] && 13 > $slug_num ) ||
3752
-				( $postname_index && '%monthnum%' === $permastructs[ $postname_index - 1 ] && 32 > $slug_num )
3750
+			if (0 === $postname_index ||
3751
+				($postname_index && '%year%' === $permastructs[$postname_index - 1] && 13 > $slug_num) ||
3752
+				($postname_index && '%monthnum%' === $permastructs[$postname_index - 1] && 32 > $slug_num)
3753 3753
 			) {
3754 3754
 				$conflicts_with_date_archive = true;
3755 3755
 			}
@@ -3764,13 +3764,13 @@  discard block
 block discarded – undo
3764 3764
 		 * @param string $slug      The post slug.
3765 3765
 		 * @param string $post_type Post type.
3766 3766
 		 */
3767
-		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 ) ) {
3767
+		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)) {
3768 3768
 			$suffix = 2;
3769 3769
 			do {
3770
-				$alt_post_name = _truncate_post_slug( $slug, 200 - ( strlen( $suffix ) + 1 ) ) . "-$suffix";
3771
-				$post_name_check = $wpdb->get_var( $wpdb->prepare( $check_sql, $alt_post_name, $post_type, $post_ID ) );
3770
+				$alt_post_name = _truncate_post_slug($slug, 200 - (strlen($suffix) + 1))."-$suffix";
3771
+				$post_name_check = $wpdb->get_var($wpdb->prepare($check_sql, $alt_post_name, $post_type, $post_ID));
3772 3772
 				$suffix++;
3773
-			} while ( $post_name_check );
3773
+			} while ($post_name_check);
3774 3774
 			$slug = $alt_post_name;
3775 3775
 		}
3776 3776
 	}
@@ -3787,7 +3787,7 @@  discard block
 block discarded – undo
3787 3787
 	 * @param int    $post_parent   Post parent ID
3788 3788
 	 * @param string $original_slug The original post slug.
3789 3789
 	 */
3790
-	return apply_filters( 'wp_unique_post_slug', $slug, $post_ID, $post_status, $post_type, $post_parent, $original_slug );
3790
+	return apply_filters('wp_unique_post_slug', $slug, $post_ID, $post_status, $post_type, $post_parent, $original_slug);
3791 3791
 }
3792 3792
 
3793 3793
 /**
@@ -3802,16 +3802,16 @@  discard block
 block discarded – undo
3802 3802
  * @param int    $length Optional. Max length of the slug. Default 200 (characters).
3803 3803
  * @return string The truncated slug.
3804 3804
  */
3805
-function _truncate_post_slug( $slug, $length = 200 ) {
3806
-	if ( strlen( $slug ) > $length ) {
3807
-		$decoded_slug = urldecode( $slug );
3808
-		if ( $decoded_slug === $slug )
3809
-			$slug = substr( $slug, 0, $length );
3805
+function _truncate_post_slug($slug, $length = 200) {
3806
+	if (strlen($slug) > $length) {
3807
+		$decoded_slug = urldecode($slug);
3808
+		if ($decoded_slug === $slug)
3809
+			$slug = substr($slug, 0, $length);
3810 3810
 		else
3811
-			$slug = utf8_uri_encode( $decoded_slug, $length );
3811
+			$slug = utf8_uri_encode($decoded_slug, $length);
3812 3812
 	}
3813 3813
 
3814
-	return rtrim( $slug, '-' );
3814
+	return rtrim($slug, '-');
3815 3815
 }
3816 3816
 
3817 3817
 /**
@@ -3826,7 +3826,7 @@  discard block
 block discarded – undo
3826 3826
  *                              separated by commas. Default empty.
3827 3827
  * @return array|false|WP_Error Array of affected term IDs. WP_Error or false on failure.
3828 3828
  */
3829
-function wp_add_post_tags( $post_id = 0, $tags = '' ) {
3829
+function wp_add_post_tags($post_id = 0, $tags = '') {
3830 3830
 	return wp_set_post_tags($post_id, $tags, true);
3831 3831
 }
3832 3832
 
@@ -3844,8 +3844,8 @@  discard block
 block discarded – undo
3844 3844
  *                              replace the tags with the new tags. Default false.
3845 3845
  * @return array|false|WP_Error Array of term taxonomy IDs of affected terms. WP_Error or false on failure.
3846 3846
  */
3847
-function wp_set_post_tags( $post_id = 0, $tags = '', $append = false ) {
3848
-	return wp_set_post_terms( $post_id, $tags, 'post_tag', $append);
3847
+function wp_set_post_tags($post_id = 0, $tags = '', $append = false) {
3848
+	return wp_set_post_terms($post_id, $tags, 'post_tag', $append);
3849 3849
 }
3850 3850
 
3851 3851
 /**
@@ -3863,31 +3863,31 @@  discard block
 block discarded – undo
3863 3863
  *                               replace the terms with the new terms. Default false.
3864 3864
  * @return array|false|WP_Error Array of term taxonomy IDs of affected terms. WP_Error or false on failure.
3865 3865
  */
3866
-function wp_set_post_terms( $post_id = 0, $tags = '', $taxonomy = 'post_tag', $append = false ) {
3866
+function wp_set_post_terms($post_id = 0, $tags = '', $taxonomy = 'post_tag', $append = false) {
3867 3867
 	$post_id = (int) $post_id;
3868 3868
 
3869
-	if ( !$post_id )
3869
+	if ( ! $post_id)
3870 3870
 		return false;
3871 3871
 
3872
-	if ( empty($tags) )
3872
+	if (empty($tags))
3873 3873
 		$tags = array();
3874 3874
 
3875
-	if ( ! is_array( $tags ) ) {
3876
-		$comma = _x( ',', 'tag delimiter' );
3877
-		if ( ',' !== $comma )
3878
-			$tags = str_replace( $comma, ',', $tags );
3879
-		$tags = explode( ',', trim( $tags, " \n\t\r\0\x0B," ) );
3875
+	if ( ! is_array($tags)) {
3876
+		$comma = _x(',', 'tag delimiter');
3877
+		if (',' !== $comma)
3878
+			$tags = str_replace($comma, ',', $tags);
3879
+		$tags = explode(',', trim($tags, " \n\t\r\0\x0B,"));
3880 3880
 	}
3881 3881
 
3882 3882
 	/*
3883 3883
 	 * Hierarchical taxonomies must always pass IDs rather than names so that
3884 3884
 	 * children with the same names but different parents aren't confused.
3885 3885
 	 */
3886
-	if ( is_taxonomy_hierarchical( $taxonomy ) ) {
3887
-		$tags = array_unique( array_map( 'intval', $tags ) );
3886
+	if (is_taxonomy_hierarchical($taxonomy)) {
3887
+		$tags = array_unique(array_map('intval', $tags));
3888 3888
 	}
3889 3889
 
3890
-	return wp_set_object_terms( $post_id, $tags, $taxonomy, $append );
3890
+	return wp_set_object_terms($post_id, $tags, $taxonomy, $append);
3891 3891
 }
3892 3892
 
3893 3893
 /**
@@ -3906,24 +3906,24 @@  discard block
 block discarded – undo
3906 3906
  *                                  If false, replace the categories with the new categories.
3907 3907
  * @return array|false|WP_Error Array of term taxonomy IDs of affected categories. WP_Error or false on failure.
3908 3908
  */
3909
-function wp_set_post_categories( $post_ID = 0, $post_categories = array(), $append = false ) {
3909
+function wp_set_post_categories($post_ID = 0, $post_categories = array(), $append = false) {
3910 3910
 	$post_ID = (int) $post_ID;
3911
-	$post_type = get_post_type( $post_ID );
3912
-	$post_status = get_post_status( $post_ID );
3911
+	$post_type = get_post_type($post_ID);
3912
+	$post_status = get_post_status($post_ID);
3913 3913
 	// If $post_categories isn't already an array, make it one:
3914 3914
 	$post_categories = (array) $post_categories;
3915
-	if ( empty( $post_categories ) ) {
3916
-		if ( 'post' == $post_type && 'auto-draft' != $post_status ) {
3917
-			$post_categories = array( get_option('default_category') );
3915
+	if (empty($post_categories)) {
3916
+		if ('post' == $post_type && 'auto-draft' != $post_status) {
3917
+			$post_categories = array(get_option('default_category'));
3918 3918
 			$append = false;
3919 3919
 		} else {
3920 3920
 			$post_categories = array();
3921 3921
 		}
3922
-	} elseif ( 1 == count( $post_categories ) && '' == reset( $post_categories ) ) {
3922
+	} elseif (1 == count($post_categories) && '' == reset($post_categories)) {
3923 3923
 		return true;
3924 3924
 	}
3925 3925
 
3926
-	return wp_set_post_terms( $post_ID, $post_categories, 'category', $append );
3926
+	return wp_set_post_terms($post_ID, $post_categories, 'category', $append);
3927 3927
 }
3928 3928
 
3929 3929
 /**
@@ -3947,7 +3947,7 @@  discard block
 block discarded – undo
3947 3947
  * @param string  $old_status Previous post status.
3948 3948
  * @param WP_Post $post Post data.
3949 3949
  */
3950
-function wp_transition_post_status( $new_status, $old_status, $post ) {
3950
+function wp_transition_post_status($new_status, $old_status, $post) {
3951 3951
 	/**
3952 3952
 	 * Fires when a post is transitioned from one status to another.
3953 3953
 	 *
@@ -3957,7 +3957,7 @@  discard block
 block discarded – undo
3957 3957
 	 * @param string  $old_status Old post status.
3958 3958
 	 * @param WP_Post $post       Post object.
3959 3959
 	 */
3960
-	do_action( 'transition_post_status', $new_status, $old_status, $post );
3960
+	do_action('transition_post_status', $new_status, $old_status, $post);
3961 3961
 
3962 3962
 	/**
3963 3963
 	 * Fires when a post is transitioned from one status to another.
@@ -3969,7 +3969,7 @@  discard block
 block discarded – undo
3969 3969
 	 *
3970 3970
 	 * @param WP_Post $post Post object.
3971 3971
 	 */
3972
-	do_action( "{$old_status}_to_{$new_status}", $post );
3972
+	do_action("{$old_status}_to_{$new_status}", $post);
3973 3973
 
3974 3974
 	/**
3975 3975
 	 * Fires when a post is transitioned from one status to another.
@@ -3990,7 +3990,7 @@  discard block
 block discarded – undo
3990 3990
 	 * @param int     $post_id Post ID.
3991 3991
 	 * @param WP_Post $post    Post object.
3992 3992
 	 */
3993
-	do_action( "{$new_status}_{$post->post_type}", $post->ID, $post );
3993
+	do_action("{$new_status}_{$post->post_type}", $post->ID, $post);
3994 3994
 }
3995 3995
 
3996 3996
 //
@@ -4010,19 +4010,19 @@  discard block
 block discarded – undo
4010 4010
  * @param string|array $uri     Ping URI or array of URIs.
4011 4011
  * @return int|false How many rows were updated.
4012 4012
  */
4013
-function add_ping( $post_id, $uri ) {
4013
+function add_ping($post_id, $uri) {
4014 4014
 	global $wpdb;
4015 4015
 
4016
-	$post = get_post( $post_id );
4017
-	if ( ! $post ) {
4016
+	$post = get_post($post_id);
4017
+	if ( ! $post) {
4018 4018
 		return false;
4019 4019
 	}
4020 4020
 
4021
-	$pung = trim( $post->pinged );
4022
-	$pung = preg_split( '/\s/', $pung );
4021
+	$pung = trim($post->pinged);
4022
+	$pung = preg_split('/\s/', $pung);
4023 4023
 
4024
-	if ( is_array( $uri ) ) {
4025
-		$pung = array_merge( $pung, $uri );
4024
+	if (is_array($uri)) {
4025
+		$pung = array_merge($pung, $uri);
4026 4026
 	}
4027 4027
 	else {
4028 4028
 		$pung[] = $uri;
@@ -4036,10 +4036,10 @@  discard block
 block discarded – undo
4036 4036
 	 *
4037 4037
 	 * @param string $new New ping URL to add.
4038 4038
 	 */
4039
-	$new = apply_filters( 'add_ping', $new );
4039
+	$new = apply_filters('add_ping', $new);
4040 4040
 
4041
-	$return = $wpdb->update( $wpdb->posts, array( 'pinged' => $new ), array( 'ID' => $post->ID ) );
4042
-	clean_post_cache( $post->ID );
4041
+	$return = $wpdb->update($wpdb->posts, array('pinged' => $new), array('ID' => $post->ID));
4042
+	clean_post_cache($post->ID);
4043 4043
 	return $return;
4044 4044
 }
4045 4045
 
@@ -4051,18 +4051,18 @@  discard block
 block discarded – undo
4051 4051
  * @param int $post_id Post ID.
4052 4052
  * @return array List of enclosures.
4053 4053
  */
4054
-function get_enclosed( $post_id ) {
4055
-	$custom_fields = get_post_custom( $post_id );
4054
+function get_enclosed($post_id) {
4055
+	$custom_fields = get_post_custom($post_id);
4056 4056
 	$pung = array();
4057
-	if ( !is_array( $custom_fields ) )
4057
+	if ( ! is_array($custom_fields))
4058 4058
 		return $pung;
4059 4059
 
4060
-	foreach ( $custom_fields as $key => $val ) {
4061
-		if ( 'enclosure' != $key || !is_array( $val ) )
4060
+	foreach ($custom_fields as $key => $val) {
4061
+		if ('enclosure' != $key || ! is_array($val))
4062 4062
 			continue;
4063
-		foreach ( $val as $enc ) {
4064
-			$enclosure = explode( "\n", $enc );
4065
-			$pung[] = trim( $enclosure[ 0 ] );
4063
+		foreach ($val as $enc) {
4064
+			$enclosure = explode("\n", $enc);
4065
+			$pung[] = trim($enclosure[0]);
4066 4066
 		}
4067 4067
 	}
4068 4068
 
@@ -4074,7 +4074,7 @@  discard block
 block discarded – undo
4074 4074
 	 * @param array $pung    Array of enclosures for the given post.
4075 4075
 	 * @param int   $post_id Post ID.
4076 4076
 	 */
4077
-	return apply_filters( 'get_enclosed', $pung, $post_id );
4077
+	return apply_filters('get_enclosed', $pung, $post_id);
4078 4078
 }
4079 4079
 
4080 4080
 /**
@@ -4087,14 +4087,14 @@  discard block
 block discarded – undo
4087 4087
  * @param int|WP_Post $post_id Post ID or object.
4088 4088
  * @return array
4089 4089
  */
4090
-function get_pung( $post_id ) {
4091
-	$post = get_post( $post_id );
4092
-	if ( ! $post ) {
4090
+function get_pung($post_id) {
4091
+	$post = get_post($post_id);
4092
+	if ( ! $post) {
4093 4093
 		return false;
4094 4094
 	}
4095 4095
 
4096
-	$pung = trim( $post->pinged );
4097
-	$pung = preg_split( '/\s/', $pung );
4096
+	$pung = trim($post->pinged);
4097
+	$pung = preg_split('/\s/', $pung);
4098 4098
 
4099 4099
 	/**
4100 4100
 	 * Filters the list of already-pinged URLs for the given post.
@@ -4103,7 +4103,7 @@  discard block
 block discarded – undo
4103 4103
 	 *
4104 4104
 	 * @param array $pung Array of URLs already pinged for the given post.
4105 4105
 	 */
4106
-	return apply_filters( 'get_pung', $pung );
4106
+	return apply_filters('get_pung', $pung);
4107 4107
 }
4108 4108
 
4109 4109
 /**
@@ -4115,14 +4115,14 @@  discard block
 block discarded – undo
4115 4115
  * @param int|WP_Post $post_id Post Object or ID
4116 4116
  * @return array
4117 4117
  */
4118
-function get_to_ping( $post_id ) {
4119
-	$post = get_post( $post_id );
4118
+function get_to_ping($post_id) {
4119
+	$post = get_post($post_id);
4120 4120
 
4121
-	if ( ! $post ) {
4121
+	if ( ! $post) {
4122 4122
 		return false;
4123 4123
 	}
4124 4124
 
4125
-	$to_ping = sanitize_trackback_urls( $post->to_ping );
4125
+	$to_ping = sanitize_trackback_urls($post->to_ping);
4126 4126
 	$to_ping = preg_split('/\s/', $to_ping, -1, PREG_SPLIT_NO_EMPTY);
4127 4127
 
4128 4128
 	/**
@@ -4132,7 +4132,7 @@  discard block
 block discarded – undo
4132 4132
 	 *
4133 4133
 	 * @param array $to_ping List of URLs yet to ping.
4134 4134
 	 */
4135
-	return apply_filters( 'get_to_ping', $to_ping );
4135
+	return apply_filters('get_to_ping', $to_ping);
4136 4136
 }
4137 4137
 
4138 4138
 /**
@@ -4143,22 +4143,22 @@  discard block
 block discarded – undo
4143 4143
  * @param string $tb_list Comma separated list of URLs.
4144 4144
  * @param int    $post_id Post ID.
4145 4145
  */
4146
-function trackback_url_list( $tb_list, $post_id ) {
4147
-	if ( ! empty( $tb_list ) ) {
4146
+function trackback_url_list($tb_list, $post_id) {
4147
+	if ( ! empty($tb_list)) {
4148 4148
 		// Get post data.
4149
-		$postdata = get_post( $post_id, ARRAY_A );
4149
+		$postdata = get_post($post_id, ARRAY_A);
4150 4150
 
4151 4151
 		// Form an excerpt.
4152
-		$excerpt = strip_tags( $postdata['post_excerpt'] ? $postdata['post_excerpt'] : $postdata['post_content'] );
4152
+		$excerpt = strip_tags($postdata['post_excerpt'] ? $postdata['post_excerpt'] : $postdata['post_content']);
4153 4153
 
4154
-		if ( strlen( $excerpt ) > 255 ) {
4155
-			$excerpt = substr( $excerpt, 0, 252 ) . '&hellip;';
4154
+		if (strlen($excerpt) > 255) {
4155
+			$excerpt = substr($excerpt, 0, 252).'&hellip;';
4156 4156
 		}
4157 4157
 
4158
-		$trackback_urls = explode( ',', $tb_list );
4159
-		foreach ( (array) $trackback_urls as $tb_url ) {
4160
-			$tb_url = trim( $tb_url );
4161
-			trackback( $tb_url, wp_unslash( $postdata['post_title'] ), $excerpt, $post_id );
4158
+		$trackback_urls = explode(',', $tb_list);
4159
+		foreach ((array) $trackback_urls as $tb_url) {
4160
+			$tb_url = trim($tb_url);
4161
+			trackback($tb_url, wp_unslash($postdata['post_title']), $excerpt, $post_id);
4162 4162
 		}
4163 4163
 	}
4164 4164
 }
@@ -4180,7 +4180,7 @@  discard block
 block discarded – undo
4180 4180
 	global $wpdb;
4181 4181
 
4182 4182
 	$page_ids = wp_cache_get('all_page_ids', 'posts');
4183
-	if ( ! is_array( $page_ids ) ) {
4183
+	if ( ! is_array($page_ids)) {
4184 4184
 		$page_ids = $wpdb->get_col("SELECT ID FROM $wpdb->posts WHERE post_type = 'page'");
4185 4185
 		wp_cache_add('all_page_ids', $page_ids, 'posts');
4186 4186
 	}
@@ -4203,8 +4203,8 @@  discard block
 block discarded – undo
4203 4203
  *                       'edit', 'db', 'display'. Default 'raw'.
4204 4204
  * @return WP_Post|array|null WP_Post (or array) on success, or null on failure.
4205 4205
  */
4206
-function get_page( $page, $output = OBJECT, $filter = 'raw') {
4207
-	return get_post( $page, $output, $filter );
4206
+function get_page($page, $output = OBJECT, $filter = 'raw') {
4207
+	return get_post($page, $output, $filter);
4208 4208
 }
4209 4209
 
4210 4210
 /**
@@ -4220,40 +4220,40 @@  discard block
 block discarded – undo
4220 4220
  * @param string|array $post_type Optional. Post type or array of post types. Default 'page'.
4221 4221
  * @return WP_Post|array|null WP_Post (or array) on success, or null on failure.
4222 4222
  */
4223
-function get_page_by_path( $page_path, $output = OBJECT, $post_type = 'page' ) {
4223
+function get_page_by_path($page_path, $output = OBJECT, $post_type = 'page') {
4224 4224
 	global $wpdb;
4225 4225
 
4226
-	$last_changed = wp_cache_get_last_changed( 'posts' );
4226
+	$last_changed = wp_cache_get_last_changed('posts');
4227 4227
 
4228
-	$hash = md5( $page_path . serialize( $post_type ) );
4228
+	$hash = md5($page_path.serialize($post_type));
4229 4229
 	$cache_key = "get_page_by_path:$hash:$last_changed";
4230
-	$cached = wp_cache_get( $cache_key, 'posts' );
4231
-	if ( false !== $cached ) {
4230
+	$cached = wp_cache_get($cache_key, 'posts');
4231
+	if (false !== $cached) {
4232 4232
 		// Special case: '0' is a bad `$page_path`.
4233
-		if ( '0' === $cached || 0 === $cached ) {
4233
+		if ('0' === $cached || 0 === $cached) {
4234 4234
 			return;
4235 4235
 		} else {
4236
-			return get_post( $cached, $output );
4236
+			return get_post($cached, $output);
4237 4237
 		}
4238 4238
 	}
4239 4239
 
4240 4240
 	$page_path = rawurlencode(urldecode($page_path));
4241 4241
 	$page_path = str_replace('%2F', '/', $page_path);
4242 4242
 	$page_path = str_replace('%20', ' ', $page_path);
4243
-	$parts = explode( '/', trim( $page_path, '/' ) );
4244
-	$parts = esc_sql( $parts );
4245
-	$parts = array_map( 'sanitize_title_for_query', $parts );
4243
+	$parts = explode('/', trim($page_path, '/'));
4244
+	$parts = esc_sql($parts);
4245
+	$parts = array_map('sanitize_title_for_query', $parts);
4246 4246
 
4247
-	$in_string = "'" . implode( "','", $parts ) . "'";
4247
+	$in_string = "'".implode("','", $parts)."'";
4248 4248
 
4249
-	if ( is_array( $post_type ) ) {
4249
+	if (is_array($post_type)) {
4250 4250
 		$post_types = $post_type;
4251 4251
 	} else {
4252
-		$post_types = array( $post_type, 'attachment' );
4252
+		$post_types = array($post_type, 'attachment');
4253 4253
 	}
4254 4254
 
4255
-	$post_types = esc_sql( $post_types );
4256
-	$post_type_in_string = "'" . implode( "','", $post_types ) . "'";
4255
+	$post_types = esc_sql($post_types);
4256
+	$post_type_in_string = "'".implode("','", $post_types)."'";
4257 4257
 	$sql = "
4258 4258
 		SELECT ID, post_name, post_parent, post_type
4259 4259
 		FROM $wpdb->posts
@@ -4261,13 +4261,13 @@  discard block
 block discarded – undo
4261 4261
 		AND post_type IN ($post_type_in_string)
4262 4262
 	";
4263 4263
 
4264
-	$pages = $wpdb->get_results( $sql, OBJECT_K );
4264
+	$pages = $wpdb->get_results($sql, OBJECT_K);
4265 4265
 
4266
-	$revparts = array_reverse( $parts );
4266
+	$revparts = array_reverse($parts);
4267 4267
 
4268 4268
 	$foundid = 0;
4269
-	foreach ( (array) $pages as $page ) {
4270
-		if ( $page->post_name == $revparts[0] ) {
4269
+	foreach ((array) $pages as $page) {
4270
+		if ($page->post_name == $revparts[0]) {
4271 4271
 			$count = 0;
4272 4272
 			$p = $page;
4273 4273
 
@@ -4275,27 +4275,27 @@  discard block
 block discarded – undo
4275 4275
 			 * Loop through the given path parts from right to left,
4276 4276
 			 * ensuring each matches the post ancestry.
4277 4277
 			 */
4278
-			while ( $p->post_parent != 0 && isset( $pages[ $p->post_parent ] ) ) {
4278
+			while ($p->post_parent != 0 && isset($pages[$p->post_parent])) {
4279 4279
 				$count++;
4280
-				$parent = $pages[ $p->post_parent ];
4281
-				if ( ! isset( $revparts[ $count ] ) || $parent->post_name != $revparts[ $count ] )
4280
+				$parent = $pages[$p->post_parent];
4281
+				if ( ! isset($revparts[$count]) || $parent->post_name != $revparts[$count])
4282 4282
 					break;
4283 4283
 				$p = $parent;
4284 4284
 			}
4285 4285
 
4286
-			if ( $p->post_parent == 0 && $count+1 == count( $revparts ) && $p->post_name == $revparts[ $count ] ) {
4286
+			if ($p->post_parent == 0 && $count + 1 == count($revparts) && $p->post_name == $revparts[$count]) {
4287 4287
 				$foundid = $page->ID;
4288
-				if ( $page->post_type == $post_type )
4288
+				if ($page->post_type == $post_type)
4289 4289
 					break;
4290 4290
 			}
4291 4291
 		}
4292 4292
 	}
4293 4293
 
4294 4294
 	// We cache misses as well as hits.
4295
-	wp_cache_set( $cache_key, $foundid, 'posts' );
4295
+	wp_cache_set($cache_key, $foundid, 'posts');
4296 4296
 
4297
-	if ( $foundid ) {
4298
-		return get_post( $foundid, $output );
4297
+	if ($foundid) {
4298
+		return get_post($foundid, $output);
4299 4299
 	}
4300 4300
 }
4301 4301
 
@@ -4312,31 +4312,31 @@  discard block
 block discarded – undo
4312 4312
  * @param string|array $post_type  Optional. Post type or array of post types. Default 'page'.
4313 4313
  * @return WP_Post|array|null WP_Post (or array) on success, or null on failure.
4314 4314
  */
4315
-function get_page_by_title( $page_title, $output = OBJECT, $post_type = 'page' ) {
4315
+function get_page_by_title($page_title, $output = OBJECT, $post_type = 'page') {
4316 4316
 	global $wpdb;
4317 4317
 
4318
-	if ( is_array( $post_type ) ) {
4319
-		$post_type = esc_sql( $post_type );
4320
-		$post_type_in_string = "'" . implode( "','", $post_type ) . "'";
4321
-		$sql = $wpdb->prepare( "
4318
+	if (is_array($post_type)) {
4319
+		$post_type = esc_sql($post_type);
4320
+		$post_type_in_string = "'".implode("','", $post_type)."'";
4321
+		$sql = $wpdb->prepare("
4322 4322
 			SELECT ID
4323 4323
 			FROM $wpdb->posts
4324 4324
 			WHERE post_title = %s
4325 4325
 			AND post_type IN ($post_type_in_string)
4326
-		", $page_title );
4326
+		", $page_title);
4327 4327
 	} else {
4328
-		$sql = $wpdb->prepare( "
4328
+		$sql = $wpdb->prepare("
4329 4329
 			SELECT ID
4330 4330
 			FROM $wpdb->posts
4331 4331
 			WHERE post_title = %s
4332 4332
 			AND post_type = %s
4333
-		", $page_title, $post_type );
4333
+		", $page_title, $post_type);
4334 4334
 	}
4335 4335
 
4336
-	$page = $wpdb->get_var( $sql );
4336
+	$page = $wpdb->get_var($sql);
4337 4337
 
4338
-	if ( $page ) {
4339
-		return get_post( $page, $output );
4338
+	if ($page) {
4339
+		return get_post($page, $output);
4340 4340
 	}
4341 4341
 }
4342 4342
 
@@ -4351,25 +4351,25 @@  discard block
 block discarded – undo
4351 4351
  * @param array $pages   List of page objects from which descendants should be identified.
4352 4352
  * @return array List of page children.
4353 4353
  */
4354
-function get_page_children( $page_id, $pages ) {
4354
+function get_page_children($page_id, $pages) {
4355 4355
 	// Build a hash of ID -> children.
4356 4356
 	$children = array();
4357
-	foreach ( (array) $pages as $page ) {
4358
-		$children[ intval( $page->post_parent ) ][] = $page;
4357
+	foreach ((array) $pages as $page) {
4358
+		$children[intval($page->post_parent)][] = $page;
4359 4359
 	}
4360 4360
 
4361 4361
 	$page_list = array();
4362 4362
 
4363 4363
 	// Start the search by looking at immediate children.
4364
-	if ( isset( $children[ $page_id ] ) ) {
4364
+	if (isset($children[$page_id])) {
4365 4365
 		// Always start at the end of the stack in order to preserve original `$pages` order.
4366
-		$to_look = array_reverse( $children[ $page_id ] );
4366
+		$to_look = array_reverse($children[$page_id]);
4367 4367
 
4368
-		while ( $to_look ) {
4369
-			$p = array_pop( $to_look );
4368
+		while ($to_look) {
4369
+			$p = array_pop($to_look);
4370 4370
 			$page_list[] = $p;
4371
-			if ( isset( $children[ $p->ID ] ) ) {
4372
-				foreach ( array_reverse( $children[ $p->ID ] ) as $child ) {
4371
+			if (isset($children[$p->ID])) {
4372
+				foreach (array_reverse($children[$p->ID]) as $child) {
4373 4373
 					// Append to the `$to_look` stack to descend the tree.
4374 4374
 					$to_look[] = $child;
4375 4375
 				}
@@ -4392,19 +4392,19 @@  discard block
 block discarded – undo
4392 4392
  * @param int   $page_id Optional. Parent page ID. Default 0.
4393 4393
  * @return array A list arranged by hierarchy. Children immediately follow their parents.
4394 4394
  */
4395
-function get_page_hierarchy( &$pages, $page_id = 0 ) {
4396
-	if ( empty( $pages ) ) {
4395
+function get_page_hierarchy(&$pages, $page_id = 0) {
4396
+	if (empty($pages)) {
4397 4397
 		return array();
4398 4398
 	}
4399 4399
 
4400 4400
 	$children = array();
4401
-	foreach ( (array) $pages as $p ) {
4402
-		$parent_id = intval( $p->post_parent );
4403
-		$children[ $parent_id ][] = $p;
4401
+	foreach ((array) $pages as $p) {
4402
+		$parent_id = intval($p->post_parent);
4403
+		$children[$parent_id][] = $p;
4404 4404
 	}
4405 4405
 
4406 4406
 	$result = array();
4407
-	_page_traverse_name( $page_id, $children, $result );
4407
+	_page_traverse_name($page_id, $children, $result);
4408 4408
 
4409 4409
 	return $result;
4410 4410
 }
@@ -4422,11 +4422,11 @@  discard block
 block discarded – undo
4422 4422
  * @param array $children  Parent-children relations, passed by reference.
4423 4423
  * @param array $result    Result, passed by reference.
4424 4424
  */
4425
-function _page_traverse_name( $page_id, &$children, &$result ){
4426
-	if ( isset( $children[ $page_id ] ) ){
4427
-		foreach ( (array)$children[ $page_id ] as $child ) {
4428
-			$result[ $child->ID ] = $child->post_name;
4429
-			_page_traverse_name( $child->ID, $children, $result );
4425
+function _page_traverse_name($page_id, &$children, &$result) {
4426
+	if (isset($children[$page_id])) {
4427
+		foreach ((array) $children[$page_id] as $child) {
4428
+			$result[$child->ID] = $child->post_name;
4429
+			_page_traverse_name($child->ID, $children, $result);
4430 4430
 		}
4431 4431
 	}
4432 4432
 }
@@ -4442,20 +4442,20 @@  discard block
 block discarded – undo
4442 4442
  * @param WP_Post|object|int $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
-function get_page_uri( $page = 0 ) {
4446
-	if ( ! $page instanceof WP_Post ) {
4447
-		$page = get_post( $page );
4445
+function get_page_uri($page = 0) {
4446
+	if ( ! $page instanceof WP_Post) {
4447
+		$page = get_post($page);
4448 4448
 	}
4449 4449
 
4450
-	if ( ! $page )
4450
+	if ( ! $page)
4451 4451
 		return false;
4452 4452
 
4453 4453
 	$uri = $page->post_name;
4454 4454
 
4455
-	foreach ( $page->ancestors as $parent ) {
4456
-		$parent = get_post( $parent );
4457
-		if ( $parent && $parent->post_name ) {
4458
-			$uri = $parent->post_name . '/' . $uri;
4455
+	foreach ($page->ancestors as $parent) {
4456
+		$parent = get_post($parent);
4457
+		if ($parent && $parent->post_name) {
4458
+			$uri = $parent->post_name.'/'.$uri;
4459 4459
 		}
4460 4460
 	}
4461 4461
 
@@ -4467,7 +4467,7 @@  discard block
 block discarded – undo
4467 4467
 	 * @param string  $uri  Page URI.
4468 4468
 	 * @param WP_Post $page Page object.
4469 4469
 	 */
4470
-	return apply_filters( 'get_page_uri', $uri, $page );
4470
+	return apply_filters('get_page_uri', $uri, $page);
4471 4471
 }
4472 4472
 
4473 4473
 /**
@@ -4512,7 +4512,7 @@  discard block
 block discarded – undo
4512 4512
  * }
4513 4513
  * @return array|false List of pages matching defaults or `$args`.
4514 4514
  */
4515
-function get_pages( $args = array() ) {
4515
+function get_pages($args = array()) {
4516 4516
 	global $wpdb;
4517 4517
 
4518 4518
 	$defaults = array(
@@ -4533,7 +4533,7 @@  discard block
 block discarded – undo
4533 4533
 		'post_status'  => 'publish',
4534 4534
 	);
4535 4535
 
4536
-	$r = wp_parse_args( $args, $defaults );
4536
+	$r = wp_parse_args($args, $defaults);
4537 4537
 
4538 4538
 	$number = (int) $r['number'];
4539 4539
 	$offset = (int) $r['offset'];
@@ -4546,83 +4546,83 @@  discard block
 block discarded – undo
4546 4546
 	$post_status = $r['post_status'];
4547 4547
 
4548 4548
 	// Make sure the post type is hierarchical.
4549
-	$hierarchical_post_types = get_post_types( array( 'hierarchical' => true ) );
4550
-	if ( ! in_array( $r['post_type'], $hierarchical_post_types ) ) {
4549
+	$hierarchical_post_types = get_post_types(array('hierarchical' => true));
4550
+	if ( ! in_array($r['post_type'], $hierarchical_post_types)) {
4551 4551
 		return false;
4552 4552
 	}
4553 4553
 
4554
-	if ( $parent > 0 && ! $child_of ) {
4554
+	if ($parent > 0 && ! $child_of) {
4555 4555
 		$hierarchical = false;
4556 4556
 	}
4557 4557
 
4558 4558
 	// Make sure we have a valid post status.
4559
-	if ( ! is_array( $post_status ) ) {
4560
-		$post_status = explode( ',', $post_status );
4559
+	if ( ! is_array($post_status)) {
4560
+		$post_status = explode(',', $post_status);
4561 4561
 	}
4562
-	if ( array_diff( $post_status, get_post_stati() ) ) {
4562
+	if (array_diff($post_status, get_post_stati())) {
4563 4563
 		return false;
4564 4564
 	}
4565 4565
 
4566 4566
 	// $args can be whatever, only use the args defined in defaults to compute the key.
4567
-	$key = md5( serialize( wp_array_slice_assoc( $r, array_keys( $defaults ) ) ) );
4568
-	$last_changed = wp_cache_get_last_changed( 'posts' );
4567
+	$key = md5(serialize(wp_array_slice_assoc($r, array_keys($defaults))));
4568
+	$last_changed = wp_cache_get_last_changed('posts');
4569 4569
 
4570 4570
 	$cache_key = "get_pages:$key:$last_changed";
4571
-	if ( $cache = wp_cache_get( $cache_key, 'posts' ) ) {
4571
+	if ($cache = wp_cache_get($cache_key, 'posts')) {
4572 4572
 		// Convert to WP_Post instances.
4573
-		$pages = array_map( 'get_post', $cache );
4573
+		$pages = array_map('get_post', $cache);
4574 4574
 		/** This filter is documented in wp-includes/post.php */
4575
-		$pages = apply_filters( 'get_pages', $pages, $r );
4575
+		$pages = apply_filters('get_pages', $pages, $r);
4576 4576
 		return $pages;
4577 4577
 	}
4578 4578
 
4579 4579
 	$inclusions = '';
4580
-	if ( ! empty( $r['include'] ) ) {
4580
+	if ( ! empty($r['include'])) {
4581 4581
 		$child_of = 0; //ignore child_of, parent, exclude, meta_key, and meta_value params if using include
4582 4582
 		$parent = -1;
4583 4583
 		$exclude = '';
4584 4584
 		$meta_key = '';
4585 4585
 		$meta_value = '';
4586 4586
 		$hierarchical = false;
4587
-		$incpages = wp_parse_id_list( $r['include'] );
4588
-		if ( ! empty( $incpages ) ) {
4589
-			$inclusions = ' AND ID IN (' . implode( ',', $incpages ) .  ')';
4587
+		$incpages = wp_parse_id_list($r['include']);
4588
+		if ( ! empty($incpages)) {
4589
+			$inclusions = ' AND ID IN ('.implode(',', $incpages).')';
4590 4590
 		}
4591 4591
 	}
4592 4592
 
4593 4593
 	$exclusions = '';
4594
-	if ( ! empty( $exclude ) ) {
4595
-		$expages = wp_parse_id_list( $exclude );
4596
-		if ( ! empty( $expages ) ) {
4597
-			$exclusions = ' AND ID NOT IN (' . implode( ',', $expages ) .  ')';
4594
+	if ( ! empty($exclude)) {
4595
+		$expages = wp_parse_id_list($exclude);
4596
+		if ( ! empty($expages)) {
4597
+			$exclusions = ' AND ID NOT IN ('.implode(',', $expages).')';
4598 4598
 		}
4599 4599
 	}
4600 4600
 
4601 4601
 	$author_query = '';
4602
-	if ( ! empty( $r['authors'] ) ) {
4603
-		$post_authors = preg_split( '/[\s,]+/', $r['authors'] );
4602
+	if ( ! empty($r['authors'])) {
4603
+		$post_authors = preg_split('/[\s,]+/', $r['authors']);
4604 4604
 
4605
-		if ( ! empty( $post_authors ) ) {
4606
-			foreach ( $post_authors as $post_author ) {
4605
+		if ( ! empty($post_authors)) {
4606
+			foreach ($post_authors as $post_author) {
4607 4607
 				//Do we have an author id or an author login?
4608
-				if ( 0 == intval($post_author) ) {
4608
+				if (0 == intval($post_author)) {
4609 4609
 					$post_author = get_user_by('login', $post_author);
4610
-					if ( empty( $post_author ) ) {
4610
+					if (empty($post_author)) {
4611 4611
 						continue;
4612 4612
 					}
4613
-					if ( empty( $post_author->ID ) ) {
4613
+					if (empty($post_author->ID)) {
4614 4614
 						continue;
4615 4615
 					}
4616 4616
 					$post_author = $post_author->ID;
4617 4617
 				}
4618 4618
 
4619
-				if ( '' == $author_query ) {
4619
+				if ('' == $author_query) {
4620 4620
 					$author_query = $wpdb->prepare(' post_author = %d ', $post_author);
4621 4621
 				} else {
4622 4622
 					$author_query .= $wpdb->prepare(' OR post_author = %d ', $post_author);
4623 4623
 				}
4624 4624
 			}
4625
-			if ( '' != $author_query ) {
4625
+			if ('' != $author_query) {
4626 4626
 				$author_query = " AND ($author_query)";
4627 4627
 			}
4628 4628
 		}
@@ -4630,49 +4630,49 @@  discard block
 block discarded – undo
4630 4630
 
4631 4631
 	$join = '';
4632 4632
 	$where = "$exclusions $inclusions ";
4633
-	if ( '' !== $meta_key || '' !== $meta_value ) {
4633
+	if ('' !== $meta_key || '' !== $meta_value) {
4634 4634
 		$join = " LEFT JOIN $wpdb->postmeta ON ( $wpdb->posts.ID = $wpdb->postmeta.post_id )";
4635 4635
 
4636 4636
 		// meta_key and meta_value might be slashed
4637 4637
 		$meta_key = wp_unslash($meta_key);
4638 4638
 		$meta_value = wp_unslash($meta_value);
4639
-		if ( '' !== $meta_key ) {
4639
+		if ('' !== $meta_key) {
4640 4640
 			$where .= $wpdb->prepare(" AND $wpdb->postmeta.meta_key = %s", $meta_key);
4641 4641
 		}
4642
-		if ( '' !== $meta_value ) {
4642
+		if ('' !== $meta_value) {
4643 4643
 			$where .= $wpdb->prepare(" AND $wpdb->postmeta.meta_value = %s", $meta_value);
4644 4644
 		}
4645 4645
 
4646 4646
 	}
4647 4647
 
4648
-	if ( is_array( $parent ) ) {
4649
-		$post_parent__in = implode( ',', array_map( 'absint', (array) $parent ) );
4650
-		if ( ! empty( $post_parent__in ) ) {
4648
+	if (is_array($parent)) {
4649
+		$post_parent__in = implode(',', array_map('absint', (array) $parent));
4650
+		if ( ! empty($post_parent__in)) {
4651 4651
 			$where .= " AND post_parent IN ($post_parent__in)";
4652 4652
 		}
4653
-	} elseif ( $parent >= 0 ) {
4653
+	} elseif ($parent >= 0) {
4654 4654
 		$where .= $wpdb->prepare(' AND post_parent = %d ', $parent);
4655 4655
 	}
4656 4656
 
4657
-	if ( 1 == count( $post_status ) ) {
4658
-		$where_post_type = $wpdb->prepare( "post_type = %s AND post_status = %s", $r['post_type'], reset( $post_status ) );
4657
+	if (1 == count($post_status)) {
4658
+		$where_post_type = $wpdb->prepare("post_type = %s AND post_status = %s", $r['post_type'], reset($post_status));
4659 4659
 	} else {
4660
-		$post_status = implode( "', '", $post_status );
4661
-		$where_post_type = $wpdb->prepare( "post_type = %s AND post_status IN ('$post_status')", $r['post_type'] );
4660
+		$post_status = implode("', '", $post_status);
4661
+		$where_post_type = $wpdb->prepare("post_type = %s AND post_status IN ('$post_status')", $r['post_type']);
4662 4662
 	}
4663 4663
 
4664 4664
 	$orderby_array = array();
4665
-	$allowed_keys = array( 'author', 'post_author', 'date', 'post_date', 'title', 'post_title', 'name', 'post_name', 'modified',
4665
+	$allowed_keys = array('author', 'post_author', 'date', 'post_date', 'title', 'post_title', 'name', 'post_name', 'modified',
4666 4666
 		'post_modified', 'modified_gmt', 'post_modified_gmt', 'menu_order', 'parent', 'post_parent',
4667
-		'ID', 'rand', 'comment_count' );
4667
+		'ID', 'rand', 'comment_count');
4668 4668
 
4669
-	foreach ( explode( ',', $r['sort_column'] ) as $orderby ) {
4670
-		$orderby = trim( $orderby );
4671
-		if ( ! in_array( $orderby, $allowed_keys ) ) {
4669
+	foreach (explode(',', $r['sort_column']) as $orderby) {
4670
+		$orderby = trim($orderby);
4671
+		if ( ! in_array($orderby, $allowed_keys)) {
4672 4672
 			continue;
4673 4673
 		}
4674 4674
 
4675
-		switch ( $orderby ) {
4675
+		switch ($orderby) {
4676 4676
 			case 'menu_order':
4677 4677
 				break;
4678 4678
 			case 'ID':
@@ -4685,36 +4685,36 @@  discard block
 block discarded – undo
4685 4685
 				$orderby = "$wpdb->posts.comment_count";
4686 4686
 				break;
4687 4687
 			default:
4688
-				if ( 0 === strpos( $orderby, 'post_' ) ) {
4689
-					$orderby = "$wpdb->posts." . $orderby;
4688
+				if (0 === strpos($orderby, 'post_')) {
4689
+					$orderby = "$wpdb->posts.".$orderby;
4690 4690
 				} else {
4691
-					$orderby = "$wpdb->posts.post_" . $orderby;
4691
+					$orderby = "$wpdb->posts.post_".$orderby;
4692 4692
 				}
4693 4693
 		}
4694 4694
 
4695 4695
 		$orderby_array[] = $orderby;
4696 4696
 
4697 4697
 	}
4698
-	$sort_column = ! empty( $orderby_array ) ? implode( ',', $orderby_array ) : "$wpdb->posts.post_title";
4698
+	$sort_column = ! empty($orderby_array) ? implode(',', $orderby_array) : "$wpdb->posts.post_title";
4699 4699
 
4700
-	$sort_order = strtoupper( $r['sort_order'] );
4701
-	if ( '' !== $sort_order && ! in_array( $sort_order, array( 'ASC', 'DESC' ) ) ) {
4700
+	$sort_order = strtoupper($r['sort_order']);
4701
+	if ('' !== $sort_order && ! in_array($sort_order, array('ASC', 'DESC'))) {
4702 4702
 		$sort_order = 'ASC';
4703 4703
 	}
4704 4704
 
4705 4705
 	$query = "SELECT * FROM $wpdb->posts $join WHERE ($where_post_type) $where ";
4706 4706
 	$query .= $author_query;
4707
-	$query .= " ORDER BY " . $sort_column . " " . $sort_order ;
4707
+	$query .= " ORDER BY ".$sort_column." ".$sort_order;
4708 4708
 
4709
-	if ( ! empty( $number ) ) {
4710
-		$query .= ' LIMIT ' . $offset . ',' . $number;
4709
+	if ( ! empty($number)) {
4710
+		$query .= ' LIMIT '.$offset.','.$number;
4711 4711
 	}
4712 4712
 
4713 4713
 	$pages = $wpdb->get_results($query);
4714 4714
 
4715
-	if ( empty($pages) ) {
4715
+	if (empty($pages)) {
4716 4716
 		/** This filter is documented in wp-includes/post.php */
4717
-		$pages = apply_filters( 'get_pages', array(), $r );
4717
+		$pages = apply_filters('get_pages', array(), $r);
4718 4718
 		return $pages;
4719 4719
 	}
4720 4720
 
@@ -4725,38 +4725,38 @@  discard block
 block discarded – undo
4725 4725
 	}
4726 4726
 
4727 4727
 	// Update cache.
4728
-	update_post_cache( $pages );
4728
+	update_post_cache($pages);
4729 4729
 
4730
-	if ( $child_of || $hierarchical ) {
4730
+	if ($child_of || $hierarchical) {
4731 4731
 		$pages = get_page_children($child_of, $pages);
4732 4732
 	}
4733 4733
 
4734
-	if ( ! empty( $r['exclude_tree'] ) ) {
4735
-		$exclude = wp_parse_id_list( $r['exclude_tree'] );
4736
-		foreach ( $exclude as $id ) {
4737
-			$children = get_page_children( $id, $pages );
4738
-			foreach ( $children as $child ) {
4734
+	if ( ! empty($r['exclude_tree'])) {
4735
+		$exclude = wp_parse_id_list($r['exclude_tree']);
4736
+		foreach ($exclude as $id) {
4737
+			$children = get_page_children($id, $pages);
4738
+			foreach ($children as $child) {
4739 4739
 				$exclude[] = $child->ID;
4740 4740
 			}
4741 4741
 		}
4742 4742
 
4743
-		$num_pages = count( $pages );
4744
-		for ( $i = 0; $i < $num_pages; $i++ ) {
4745
-			if ( in_array( $pages[$i]->ID, $exclude ) ) {
4746
-				unset( $pages[$i] );
4743
+		$num_pages = count($pages);
4744
+		for ($i = 0; $i < $num_pages; $i++) {
4745
+			if (in_array($pages[$i]->ID, $exclude)) {
4746
+				unset($pages[$i]);
4747 4747
 			}
4748 4748
 		}
4749 4749
 	}
4750 4750
 
4751 4751
 	$page_structure = array();
4752
-	foreach ( $pages as $page ) {
4752
+	foreach ($pages as $page) {
4753 4753
 		$page_structure[] = $page->ID;
4754 4754
 	}
4755 4755
 
4756
-	wp_cache_set( $cache_key, $page_structure, 'posts' );
4756
+	wp_cache_set($cache_key, $page_structure, 'posts');
4757 4757
 
4758 4758
 	// Convert to WP_Post instances
4759
-	$pages = array_map( 'get_post', $pages );
4759
+	$pages = array_map('get_post', $pages);
4760 4760
 
4761 4761
 	/**
4762 4762
 	 * Filters the retrieved list of pages.
@@ -4766,7 +4766,7 @@  discard block
 block discarded – undo
4766 4766
 	 * @param array $pages List of pages to retrieve.
4767 4767
 	 * @param array $r     Array of get_pages() arguments.
4768 4768
 	 */
4769
-	return apply_filters( 'get_pages', $pages, $r );
4769
+	return apply_filters('get_pages', $pages, $r);
4770 4770
 }
4771 4771
 
4772 4772
 //
@@ -4786,9 +4786,9 @@  discard block
 block discarded – undo
4786 4786
 		return false;
4787 4787
 	if (strpos($url, home_url('/?attachment_id=')) !== false)
4788 4788
 		return true;
4789
-	if ( $id = url_to_postid($url) ) {
4789
+	if ($id = url_to_postid($url)) {
4790 4790
 		$post = get_post($id);
4791
-		if ( 'attachment' == $post->post_type )
4791
+		if ('attachment' == $post->post_type)
4792 4792
 			return true;
4793 4793
 	}
4794 4794
 	return false;
@@ -4819,21 +4819,21 @@  discard block
 block discarded – undo
4819 4819
  * @param bool         $wp_error Optional. Whether to return a WP_Error on failure. Default false.
4820 4820
  * @return int|WP_Error The attachment ID on success. The value 0 or WP_Error on failure.
4821 4821
  */
4822
-function wp_insert_attachment( $args, $file = false, $parent = 0, $wp_error = false ) {
4822
+function wp_insert_attachment($args, $file = false, $parent = 0, $wp_error = false) {
4823 4823
 	$defaults = array(
4824 4824
 		'file'        => $file,
4825 4825
 		'post_parent' => 0
4826 4826
 	);
4827 4827
 
4828
-	$data = wp_parse_args( $args, $defaults );
4828
+	$data = wp_parse_args($args, $defaults);
4829 4829
 
4830
-	if ( ! empty( $parent ) ) {
4830
+	if ( ! empty($parent)) {
4831 4831
 		$data['post_parent'] = $parent;
4832 4832
 	}
4833 4833
 
4834 4834
 	$data['post_type'] = 'attachment';
4835 4835
 
4836
-	return wp_insert_post( $data, $wp_error );
4836
+	return wp_insert_post($data, $wp_error);
4837 4837
 }
4838 4838
 
4839 4839
 /**
@@ -4855,27 +4855,27 @@  discard block
 block discarded – undo
4855 4855
  *                           Default false.
4856 4856
  * @return mixed False on failure. Post data on success.
4857 4857
  */
4858
-function wp_delete_attachment( $post_id, $force_delete = false ) {
4858
+function wp_delete_attachment($post_id, $force_delete = false) {
4859 4859
 	global $wpdb;
4860 4860
 
4861
-	if ( !$post = $wpdb->get_row( $wpdb->prepare("SELECT * FROM $wpdb->posts WHERE ID = %d", $post_id) ) )
4861
+	if ( ! $post = $wpdb->get_row($wpdb->prepare("SELECT * FROM $wpdb->posts WHERE ID = %d", $post_id)))
4862 4862
 		return $post;
4863 4863
 
4864
-	if ( 'attachment' != $post->post_type )
4864
+	if ('attachment' != $post->post_type)
4865 4865
 		return false;
4866 4866
 
4867
-	if ( !$force_delete && EMPTY_TRASH_DAYS && MEDIA_TRASH && 'trash' != $post->post_status )
4868
-		return wp_trash_post( $post_id );
4867
+	if ( ! $force_delete && EMPTY_TRASH_DAYS && MEDIA_TRASH && 'trash' != $post->post_status)
4868
+		return wp_trash_post($post_id);
4869 4869
 
4870 4870
 	delete_post_meta($post_id, '_wp_trash_meta_status');
4871 4871
 	delete_post_meta($post_id, '_wp_trash_meta_time');
4872 4872
 
4873
-	$meta = wp_get_attachment_metadata( $post_id );
4874
-	$backup_sizes = get_post_meta( $post->ID, '_wp_attachment_backup_sizes', true );
4875
-	$file = get_attached_file( $post_id );
4873
+	$meta = wp_get_attachment_metadata($post_id);
4874
+	$backup_sizes = get_post_meta($post->ID, '_wp_attachment_backup_sizes', true);
4875
+	$file = get_attached_file($post_id);
4876 4876
 
4877
-	if ( is_multisite() )
4878
-		delete_transient( 'dirsize_cache' );
4877
+	if (is_multisite())
4878
+		delete_transient('dirsize_cache');
4879 4879
 
4880 4880
 	/**
4881 4881
 	 * Fires before an attachment is deleted, at the start of wp_delete_attachment().
@@ -4884,70 +4884,70 @@  discard block
 block discarded – undo
4884 4884
 	 *
4885 4885
 	 * @param int $post_id Attachment ID.
4886 4886
 	 */
4887
-	do_action( 'delete_attachment', $post_id );
4887
+	do_action('delete_attachment', $post_id);
4888 4888
 
4889 4889
 	wp_delete_object_term_relationships($post_id, array('category', 'post_tag'));
4890 4890
 	wp_delete_object_term_relationships($post_id, get_object_taxonomies($post->post_type));
4891 4891
 
4892 4892
 	// Delete all for any posts.
4893
-	delete_metadata( 'post', null, '_thumbnail_id', $post_id, true );
4893
+	delete_metadata('post', null, '_thumbnail_id', $post_id, true);
4894 4894
 
4895
-	wp_defer_comment_counting( true );
4895
+	wp_defer_comment_counting(true);
4896 4896
 
4897
-	$comment_ids = $wpdb->get_col( $wpdb->prepare( "SELECT comment_ID FROM $wpdb->comments WHERE comment_post_ID = %d", $post_id ));
4898
-	foreach ( $comment_ids as $comment_id ) {
4899
-		wp_delete_comment( $comment_id, true );
4897
+	$comment_ids = $wpdb->get_col($wpdb->prepare("SELECT comment_ID FROM $wpdb->comments WHERE comment_post_ID = %d", $post_id));
4898
+	foreach ($comment_ids as $comment_id) {
4899
+		wp_delete_comment($comment_id, true);
4900 4900
 	}
4901 4901
 
4902
-	wp_defer_comment_counting( false );
4902
+	wp_defer_comment_counting(false);
4903 4903
 
4904
-	$post_meta_ids = $wpdb->get_col( $wpdb->prepare( "SELECT meta_id FROM $wpdb->postmeta WHERE post_id = %d ", $post_id ));
4905
-	foreach ( $post_meta_ids as $mid )
4906
-		delete_metadata_by_mid( 'post', $mid );
4904
+	$post_meta_ids = $wpdb->get_col($wpdb->prepare("SELECT meta_id FROM $wpdb->postmeta WHERE post_id = %d ", $post_id));
4905
+	foreach ($post_meta_ids as $mid)
4906
+		delete_metadata_by_mid('post', $mid);
4907 4907
 
4908 4908
 	/** This action is documented in wp-includes/post.php */
4909
-	do_action( 'delete_post', $post_id );
4910
-	$result = $wpdb->delete( $wpdb->posts, array( 'ID' => $post_id ) );
4911
-	if ( ! $result ) {
4909
+	do_action('delete_post', $post_id);
4910
+	$result = $wpdb->delete($wpdb->posts, array('ID' => $post_id));
4911
+	if ( ! $result) {
4912 4912
 		return false;
4913 4913
 	}
4914 4914
 	/** This action is documented in wp-includes/post.php */
4915
-	do_action( 'deleted_post', $post_id );
4915
+	do_action('deleted_post', $post_id);
4916 4916
 
4917 4917
 	$uploadpath = wp_get_upload_dir();
4918 4918
 
4919
-	if ( ! empty($meta['thumb']) ) {
4919
+	if ( ! empty($meta['thumb'])) {
4920 4920
 		// Don't delete the thumb if another attachment uses it.
4921
-		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)) ) {
4921
+		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))) {
4922 4922
 			$thumbfile = str_replace(basename($file), $meta['thumb'], $file);
4923 4923
 			/** This filter is documented in wp-includes/functions.php */
4924
-			$thumbfile = apply_filters( 'wp_delete_file', $thumbfile );
4925
-			@ unlink( path_join($uploadpath['basedir'], $thumbfile) );
4924
+			$thumbfile = apply_filters('wp_delete_file', $thumbfile);
4925
+			@ unlink(path_join($uploadpath['basedir'], $thumbfile));
4926 4926
 		}
4927 4927
 	}
4928 4928
 
4929 4929
 	// Remove intermediate and backup images if there are any.
4930
-	if ( isset( $meta['sizes'] ) && is_array( $meta['sizes'] ) ) {
4931
-		foreach ( $meta['sizes'] as $size => $sizeinfo ) {
4932
-			$intermediate_file = str_replace( basename( $file ), $sizeinfo['file'], $file );
4930
+	if (isset($meta['sizes']) && is_array($meta['sizes'])) {
4931
+		foreach ($meta['sizes'] as $size => $sizeinfo) {
4932
+			$intermediate_file = str_replace(basename($file), $sizeinfo['file'], $file);
4933 4933
 			/** This filter is documented in wp-includes/functions.php */
4934
-			$intermediate_file = apply_filters( 'wp_delete_file', $intermediate_file );
4935
-			@ unlink( path_join( $uploadpath['basedir'], $intermediate_file ) );
4934
+			$intermediate_file = apply_filters('wp_delete_file', $intermediate_file);
4935
+			@ unlink(path_join($uploadpath['basedir'], $intermediate_file));
4936 4936
 		}
4937 4937
 	}
4938 4938
 
4939
-	if ( is_array($backup_sizes) ) {
4940
-		foreach ( $backup_sizes as $size ) {
4941
-			$del_file = path_join( dirname($meta['file']), $size['file'] );
4939
+	if (is_array($backup_sizes)) {
4940
+		foreach ($backup_sizes as $size) {
4941
+			$del_file = path_join(dirname($meta['file']), $size['file']);
4942 4942
 			/** This filter is documented in wp-includes/functions.php */
4943
-			$del_file = apply_filters( 'wp_delete_file', $del_file );
4944
-			@ unlink( path_join($uploadpath['basedir'], $del_file) );
4943
+			$del_file = apply_filters('wp_delete_file', $del_file);
4944
+			@ unlink(path_join($uploadpath['basedir'], $del_file));
4945 4945
 		}
4946 4946
 	}
4947 4947
 
4948
-	wp_delete_file( $file );
4948
+	wp_delete_file($file);
4949 4949
 
4950
-	clean_post_cache( $post );
4950
+	clean_post_cache($post);
4951 4951
 
4952 4952
 	return $post;
4953 4953
 }
@@ -4961,14 +4961,14 @@  discard block
 block discarded – undo
4961 4961
  * @param bool $unfiltered Optional. If true, filters are not run. Default false.
4962 4962
  * @return mixed Attachment meta field. False on failure.
4963 4963
  */
4964
-function wp_get_attachment_metadata( $post_id = 0, $unfiltered = false ) {
4964
+function wp_get_attachment_metadata($post_id = 0, $unfiltered = false) {
4965 4965
 	$post_id = (int) $post_id;
4966
-	if ( !$post = get_post( $post_id ) )
4966
+	if ( ! $post = get_post($post_id))
4967 4967
 		return false;
4968 4968
 
4969
-	$data = get_post_meta( $post->ID, '_wp_attachment_metadata', true );
4969
+	$data = get_post_meta($post->ID, '_wp_attachment_metadata', true);
4970 4970
 
4971
-	if ( $unfiltered )
4971
+	if ($unfiltered)
4972 4972
 		return $data;
4973 4973
 
4974 4974
 	/**
@@ -4980,7 +4980,7 @@  discard block
 block discarded – undo
4980 4980
 	 *                            if the object does not exist.
4981 4981
 	 * @param int        $post_id Attachment ID.
4982 4982
 	 */
4983
-	return apply_filters( 'wp_get_attachment_metadata', $data, $post->ID );
4983
+	return apply_filters('wp_get_attachment_metadata', $data, $post->ID);
4984 4984
 }
4985 4985
 
4986 4986
 /**
@@ -4992,9 +4992,9 @@  discard block
 block discarded – undo
4992 4992
  * @param array $data    Attachment data.
4993 4993
  * @return int|bool False if $post is invalid.
4994 4994
  */
4995
-function wp_update_attachment_metadata( $post_id, $data ) {
4995
+function wp_update_attachment_metadata($post_id, $data) {
4996 4996
 	$post_id = (int) $post_id;
4997
-	if ( !$post = get_post( $post_id ) )
4997
+	if ( ! $post = get_post($post_id))
4998 4998
 		return false;
4999 4999
 
5000 5000
 	/**
@@ -5005,10 +5005,10 @@  discard block
 block discarded – undo
5005 5005
 	 * @param array $data    Array of updated attachment meta data.
5006 5006
 	 * @param int   $post_id Attachment ID.
5007 5007
 	 */
5008
-	if ( $data = apply_filters( 'wp_update_attachment_metadata', $data, $post->ID ) )
5009
-		return update_post_meta( $post->ID, '_wp_attachment_metadata', $data );
5008
+	if ($data = apply_filters('wp_update_attachment_metadata', $data, $post->ID))
5009
+		return update_post_meta($post->ID, '_wp_attachment_metadata', $data);
5010 5010
 	else
5011
-		return delete_post_meta( $post->ID, '_wp_attachment_metadata' );
5011
+		return delete_post_meta($post->ID, '_wp_attachment_metadata');
5012 5012
 }
5013 5013
 
5014 5014
 /**
@@ -5021,29 +5021,29 @@  discard block
 block discarded – undo
5021 5021
  * @param int $post_id Optional. Attachment ID. Default 0.
5022 5022
  * @return string|false Attachment URL, otherwise false.
5023 5023
  */
5024
-function wp_get_attachment_url( $post_id = 0 ) {
5024
+function wp_get_attachment_url($post_id = 0) {
5025 5025
 	$post_id = (int) $post_id;
5026
-	if ( !$post = get_post( $post_id ) )
5026
+	if ( ! $post = get_post($post_id))
5027 5027
 		return false;
5028 5028
 
5029
-	if ( 'attachment' != $post->post_type )
5029
+	if ('attachment' != $post->post_type)
5030 5030
 		return false;
5031 5031
 
5032 5032
 	$url = '';
5033 5033
 	// Get attached file.
5034
-	if ( $file = get_post_meta( $post->ID, '_wp_attached_file', true ) ) {
5034
+	if ($file = get_post_meta($post->ID, '_wp_attached_file', true)) {
5035 5035
 		// Get upload directory.
5036
-		if ( ( $uploads = wp_get_upload_dir() ) && false === $uploads['error'] ) {
5036
+		if (($uploads = wp_get_upload_dir()) && false === $uploads['error']) {
5037 5037
 			// Check that the upload base exists in the file location.
5038
-			if ( 0 === strpos( $file, $uploads['basedir'] ) ) {
5038
+			if (0 === strpos($file, $uploads['basedir'])) {
5039 5039
 				// Replace file location with url location.
5040 5040
 				$url = str_replace($uploads['basedir'], $uploads['baseurl'], $file);
5041
-			} elseif ( false !== strpos($file, 'wp-content/uploads') ) {
5041
+			} elseif (false !== strpos($file, 'wp-content/uploads')) {
5042 5042
 				// Get the directory name relative to the basedir (back compat for pre-2.7 uploads)
5043
-				$url = trailingslashit( $uploads['baseurl'] . '/' . _wp_get_attachment_relative_path( $file ) ) . basename( $file );
5043
+				$url = trailingslashit($uploads['baseurl'].'/'._wp_get_attachment_relative_path($file)).basename($file);
5044 5044
 			} else {
5045 5045
 				// It's a newly-uploaded file, therefore $file is relative to the basedir.
5046
-				$url = $uploads['baseurl'] . "/$file";
5046
+				$url = $uploads['baseurl']."/$file";
5047 5047
 			}
5048 5048
 		}
5049 5049
 	}
@@ -5052,13 +5052,13 @@  discard block
 block discarded – undo
5052 5052
 	 * If any of the above options failed, Fallback on the GUID as used pre-2.7,
5053 5053
 	 * not recommended to rely upon this.
5054 5054
 	 */
5055
-	if ( empty($url) ) {
5056
-		$url = get_the_guid( $post->ID );
5055
+	if (empty($url)) {
5056
+		$url = get_the_guid($post->ID);
5057 5057
 	}
5058 5058
 
5059 5059
 	// On SSL front end, URLs should be HTTPS.
5060
-	if ( is_ssl() && ! is_admin() && 'wp-login.php' !== $GLOBALS['pagenow'] ) {
5061
-		$url = set_url_scheme( $url );
5060
+	if (is_ssl() && ! is_admin() && 'wp-login.php' !== $GLOBALS['pagenow']) {
5061
+		$url = set_url_scheme($url);
5062 5062
 	}
5063 5063
 
5064 5064
 	/**
@@ -5069,9 +5069,9 @@  discard block
 block discarded – undo
5069 5069
 	 * @param string $url     URL for the given attachment.
5070 5070
 	 * @param int    $post_id Attachment ID.
5071 5071
 	 */
5072
-	$url = apply_filters( 'wp_get_attachment_url', $url, $post->ID );
5072
+	$url = apply_filters('wp_get_attachment_url', $url, $post->ID);
5073 5073
 
5074
-	if ( empty( $url ) )
5074
+	if (empty($url))
5075 5075
 		return false;
5076 5076
 
5077 5077
 	return $url;
@@ -5085,13 +5085,13 @@  discard block
 block discarded – undo
5085 5085
  * @param int $post_id Optional. Attachment ID. Default is the ID of the global `$post`.
5086 5086
  * @return string|false False on failure. Attachment caption on success.
5087 5087
  */
5088
-function wp_get_attachment_caption( $post_id = 0 ) {
5088
+function wp_get_attachment_caption($post_id = 0) {
5089 5089
 	$post_id = (int) $post_id;
5090
-	if ( ! $post = get_post( $post_id ) ) {
5090
+	if ( ! $post = get_post($post_id)) {
5091 5091
 		return false;
5092 5092
 	}
5093 5093
 
5094
-	if ( 'attachment' !== $post->post_type ) {
5094
+	if ('attachment' !== $post->post_type) {
5095 5095
 		return false;
5096 5096
 	}
5097 5097
 
@@ -5105,7 +5105,7 @@  discard block
 block discarded – undo
5105 5105
 	 * @param string $caption Caption for the given attachment.
5106 5106
 	 * @param int    $post_id Attachment ID.
5107 5107
 	 */
5108
-	return apply_filters( 'wp_get_attachment_caption', $caption, $post->ID );
5108
+	return apply_filters('wp_get_attachment_caption', $caption, $post->ID);
5109 5109
 }
5110 5110
 
5111 5111
 /**
@@ -5116,16 +5116,16 @@  discard block
 block discarded – undo
5116 5116
  * @param int $post_id Optional. Attachment ID. Default 0.
5117 5117
  * @return string|false False on failure. Thumbnail file path on success.
5118 5118
  */
5119
-function wp_get_attachment_thumb_file( $post_id = 0 ) {
5119
+function wp_get_attachment_thumb_file($post_id = 0) {
5120 5120
 	$post_id = (int) $post_id;
5121
-	if ( !$post = get_post( $post_id ) )
5121
+	if ( ! $post = get_post($post_id))
5122 5122
 		return false;
5123
-	if ( !is_array( $imagedata = wp_get_attachment_metadata( $post->ID ) ) )
5123
+	if ( ! is_array($imagedata = wp_get_attachment_metadata($post->ID)))
5124 5124
 		return false;
5125 5125
 
5126
-	$file = get_attached_file( $post->ID );
5126
+	$file = get_attached_file($post->ID);
5127 5127
 
5128
-	if ( !empty($imagedata['thumb']) && ($thumbfile = str_replace(basename($file), $imagedata['thumb'], $file)) && file_exists($thumbfile) ) {
5128
+	if ( ! empty($imagedata['thumb']) && ($thumbfile = str_replace(basename($file), $imagedata['thumb'], $file)) && file_exists($thumbfile)) {
5129 5129
 		/**
5130 5130
 		 * Filters the attachment thumbnail file path.
5131 5131
 		 *
@@ -5134,7 +5134,7 @@  discard block
 block discarded – undo
5134 5134
 		 * @param string $thumbfile File path to the attachment thumbnail.
5135 5135
 		 * @param int    $post_id   Attachment ID.
5136 5136
 		 */
5137
-		return apply_filters( 'wp_get_attachment_thumb_file', $thumbfile, $post->ID );
5137
+		return apply_filters('wp_get_attachment_thumb_file', $thumbfile, $post->ID);
5138 5138
 	}
5139 5139
 	return false;
5140 5140
 }
@@ -5147,18 +5147,18 @@  discard block
 block discarded – undo
5147 5147
  * @param int $post_id Optional. Attachment ID. Default 0.
5148 5148
  * @return string|false False on failure. Thumbnail URL on success.
5149 5149
  */
5150
-function wp_get_attachment_thumb_url( $post_id = 0 ) {
5150
+function wp_get_attachment_thumb_url($post_id = 0) {
5151 5151
 	$post_id = (int) $post_id;
5152
-	if ( !$post = get_post( $post_id ) )
5152
+	if ( ! $post = get_post($post_id))
5153 5153
 		return false;
5154
-	if ( !$url = wp_get_attachment_url( $post->ID ) )
5154
+	if ( ! $url = wp_get_attachment_url($post->ID))
5155 5155
 		return false;
5156 5156
 
5157
-	$sized = image_downsize( $post_id, 'thumbnail' );
5158
-	if ( $sized )
5157
+	$sized = image_downsize($post_id, 'thumbnail');
5158
+	if ($sized)
5159 5159
 		return $sized[0];
5160 5160
 
5161
-	if ( !$thumb = wp_get_attachment_thumb_file( $post->ID ) )
5161
+	if ( ! $thumb = wp_get_attachment_thumb_file($post->ID))
5162 5162
 		return false;
5163 5163
 
5164 5164
 	$url = str_replace(basename($url), basename($thumb), $url);
@@ -5171,7 +5171,7 @@  discard block
 block discarded – undo
5171 5171
 	 * @param string $url     URL for the attachment thumbnail.
5172 5172
 	 * @param int    $post_id Attachment ID.
5173 5173
 	 */
5174
-	return apply_filters( 'wp_get_attachment_thumb_url', $url, $post->ID );
5174
+	return apply_filters('wp_get_attachment_thumb_url', $url, $post->ID);
5175 5175
 }
5176 5176
 
5177 5177
 /**
@@ -5183,40 +5183,40 @@  discard block
 block discarded – undo
5183 5183
  * @param int|WP_Post $post Optional. Attachment ID or object. Default is global $post.
5184 5184
  * @return bool True if one of the accepted types, false otherwise.
5185 5185
  */
5186
-function wp_attachment_is( $type, $post = null ) {
5187
-	if ( ! $post = get_post( $post ) ) {
5186
+function wp_attachment_is($type, $post = null) {
5187
+	if ( ! $post = get_post($post)) {
5188 5188
 		return false;
5189 5189
 	}
5190 5190
 
5191
-	if ( ! $file = get_attached_file( $post->ID ) ) {
5191
+	if ( ! $file = get_attached_file($post->ID)) {
5192 5192
 		return false;
5193 5193
 	}
5194 5194
 
5195
-	if ( 0 === strpos( $post->post_mime_type, $type . '/' ) ) {
5195
+	if (0 === strpos($post->post_mime_type, $type.'/')) {
5196 5196
 		return true;
5197 5197
 	}
5198 5198
 
5199
-	$check = wp_check_filetype( $file );
5200
-	if ( empty( $check['ext'] ) ) {
5199
+	$check = wp_check_filetype($file);
5200
+	if (empty($check['ext'])) {
5201 5201
 		return false;
5202 5202
 	}
5203 5203
 
5204 5204
 	$ext = $check['ext'];
5205 5205
 
5206
-	if ( 'import' !== $post->post_mime_type ) {
5206
+	if ('import' !== $post->post_mime_type) {
5207 5207
 		return $type === $ext;
5208 5208
 	}
5209 5209
 
5210
-	switch ( $type ) {
5210
+	switch ($type) {
5211 5211
 	case 'image':
5212
-		$image_exts = array( 'jpg', 'jpeg', 'jpe', 'gif', 'png' );
5213
-		return in_array( $ext, $image_exts );
5212
+		$image_exts = array('jpg', 'jpeg', 'jpe', 'gif', 'png');
5213
+		return in_array($ext, $image_exts);
5214 5214
 
5215 5215
 	case 'audio':
5216
-		return in_array( $ext, wp_get_audio_extensions() );
5216
+		return in_array($ext, wp_get_audio_extensions());
5217 5217
 
5218 5218
 	case 'video':
5219
-		return in_array( $ext, wp_get_video_extensions() );
5219
+		return in_array($ext, wp_get_video_extensions());
5220 5220
 
5221 5221
 	default:
5222 5222
 		return $type === $ext;
@@ -5233,8 +5233,8 @@  discard block
 block discarded – undo
5233 5233
  * @param int|WP_Post $post Optional. Attachment ID or object. Default is global $post.
5234 5234
  * @return bool Whether the attachment is an image.
5235 5235
  */
5236
-function wp_attachment_is_image( $post = null ) {
5237
-	return wp_attachment_is( 'image', $post );
5236
+function wp_attachment_is_image($post = null) {
5237
+	return wp_attachment_is('image', $post);
5238 5238
 }
5239 5239
 
5240 5240
 /**
@@ -5245,22 +5245,22 @@  discard block
 block discarded – undo
5245 5245
  * @param string|int $mime MIME type or attachment ID.
5246 5246
  * @return string|false Icon, false otherwise.
5247 5247
  */
5248
-function wp_mime_type_icon( $mime = 0 ) {
5249
-	if ( !is_numeric($mime) )
5248
+function wp_mime_type_icon($mime = 0) {
5249
+	if ( ! is_numeric($mime))
5250 5250
 		$icon = wp_cache_get("mime_type_icon_$mime");
5251 5251
 
5252 5252
 	$post_id = 0;
5253
-	if ( empty($icon) ) {
5253
+	if (empty($icon)) {
5254 5254
 		$post_mimes = array();
5255
-		if ( is_numeric($mime) ) {
5255
+		if (is_numeric($mime)) {
5256 5256
 			$mime = (int) $mime;
5257
-			if ( $post = get_post( $mime ) ) {
5257
+			if ($post = get_post($mime)) {
5258 5258
 				$post_id = (int) $post->ID;
5259
-				$file = get_attached_file( $post_id );
5259
+				$file = get_attached_file($post_id);
5260 5260
 				$ext = preg_replace('/^.+?\.([^.]+)$/', '$1', $file);
5261
-				if ( !empty($ext) ) {
5261
+				if ( ! empty($ext)) {
5262 5262
 					$post_mimes[] = $ext;
5263
-					if ( $ext_type = wp_ext2type( $ext ) )
5263
+					if ($ext_type = wp_ext2type($ext))
5264 5264
 						$post_mimes[] = $ext_type;
5265 5265
 				}
5266 5266
 				$mime = $post->post_mime_type;
@@ -5273,7 +5273,7 @@  discard block
 block discarded – undo
5273 5273
 
5274 5274
 		$icon_files = wp_cache_get('icon_files');
5275 5275
 
5276
-		if ( !is_array($icon_files) ) {
5276
+		if ( ! is_array($icon_files)) {
5277 5277
 			/**
5278 5278
 			 * Filters the icon directory path.
5279 5279
 			 *
@@ -5281,7 +5281,7 @@  discard block
 block discarded – undo
5281 5281
 			 *
5282 5282
 			 * @param string $path Icon directory absolute path.
5283 5283
 			 */
5284
-			$icon_dir = apply_filters( 'icon_dir', ABSPATH . WPINC . '/images/media' );
5284
+			$icon_dir = apply_filters('icon_dir', ABSPATH.WPINC.'/images/media');
5285 5285
 
5286 5286
 			/**
5287 5287
 			 * Filters the icon directory URI.
@@ -5290,7 +5290,7 @@  discard block
 block discarded – undo
5290 5290
 			 *
5291 5291
 			 * @param string $uri Icon directory URI.
5292 5292
 			 */
5293
-			$icon_dir_uri = apply_filters( 'icon_dir_uri', includes_url( 'images/media' ) );
5293
+			$icon_dir_uri = apply_filters('icon_dir_uri', includes_url('images/media'));
5294 5294
 
5295 5295
 			/**
5296 5296
 			 * Filters the list of icon directory URIs.
@@ -5299,19 +5299,19 @@  discard block
 block discarded – undo
5299 5299
 			 *
5300 5300
 			 * @param array $uris List of icon directory URIs.
5301 5301
 			 */
5302
-			$dirs = apply_filters( 'icon_dirs', array( $icon_dir => $icon_dir_uri ) );
5302
+			$dirs = apply_filters('icon_dirs', array($icon_dir => $icon_dir_uri));
5303 5303
 			$icon_files = array();
5304
-			while ( $dirs ) {
5305
-				$keys = array_keys( $dirs );
5306
-				$dir = array_shift( $keys );
5304
+			while ($dirs) {
5305
+				$keys = array_keys($dirs);
5306
+				$dir = array_shift($keys);
5307 5307
 				$uri = array_shift($dirs);
5308
-				if ( $dh = opendir($dir) ) {
5309
-					while ( false !== $file = readdir($dh) ) {
5308
+				if ($dh = opendir($dir)) {
5309
+					while (false !== $file = readdir($dh)) {
5310 5310
 						$file = basename($file);
5311
-						if ( substr($file, 0, 1) == '.' )
5311
+						if (substr($file, 0, 1) == '.')
5312 5312
 							continue;
5313
-						if ( !in_array(strtolower(substr($file, -4)), array('.png', '.gif', '.jpg') ) ) {
5314
-							if ( is_dir("$dir/$file") )
5313
+						if ( ! in_array(strtolower(substr($file, -4)), array('.png', '.gif', '.jpg'))) {
5314
+							if (is_dir("$dir/$file"))
5315 5315
 								$dirs["$dir/$file"] = "$uri/$file";
5316 5316
 							continue;
5317 5317
 						}
@@ -5320,15 +5320,15 @@  discard block
 block discarded – undo
5320 5320
 					closedir($dh);
5321 5321
 				}
5322 5322
 			}
5323
-			wp_cache_add( 'icon_files', $icon_files, 'default', 600 );
5323
+			wp_cache_add('icon_files', $icon_files, 'default', 600);
5324 5324
 		}
5325 5325
 
5326 5326
 		$types = array();
5327 5327
 		// Icon basename - extension = MIME wildcard.
5328
-		foreach ( $icon_files as $file => $uri )
5329
-			$types[ preg_replace('/^([^.]*).*$/', '$1', basename($file)) ] =& $icon_files[$file];
5328
+		foreach ($icon_files as $file => $uri)
5329
+			$types[preg_replace('/^([^.]*).*$/', '$1', basename($file))] = & $icon_files[$file];
5330 5330
 
5331
-		if ( ! empty($mime) ) {
5331
+		if ( ! empty($mime)) {
5332 5332
 			$post_mimes[] = substr($mime, 0, strpos($mime, '/'));
5333 5333
 			$post_mimes[] = substr($mime, strpos($mime, '/') + 1);
5334 5334
 			$post_mimes[] = str_replace('/', '_', $mime);
@@ -5337,15 +5337,15 @@  discard block
 block discarded – undo
5337 5337
 		$matches = wp_match_mime_types(array_keys($types), $post_mimes);
5338 5338
 		$matches['default'] = array('default');
5339 5339
 
5340
-		foreach ( $matches as $match => $wilds ) {
5341
-			foreach ( $wilds as $wild ) {
5342
-				if ( ! isset( $types[ $wild ] ) ) {
5340
+		foreach ($matches as $match => $wilds) {
5341
+			foreach ($wilds as $wild) {
5342
+				if ( ! isset($types[$wild])) {
5343 5343
 					continue;
5344 5344
 				}
5345 5345
 
5346
-				$icon = $types[ $wild ];
5347
-				if ( ! is_numeric( $mime ) ) {
5348
-					wp_cache_add( "mime_type_icon_$mime", $icon );
5346
+				$icon = $types[$wild];
5347
+				if ( ! is_numeric($mime)) {
5348
+					wp_cache_add("mime_type_icon_$mime", $icon);
5349 5349
 				}
5350 5350
 				break 2;
5351 5351
 			}
@@ -5362,7 +5362,7 @@  discard block
 block discarded – undo
5362 5362
 	 * @param int    $post_id Attachment ID. Will equal 0 if the function passed
5363 5363
 	 *                        the mime type.
5364 5364
 	 */
5365
-	return apply_filters( 'wp_mime_type_icon', $icon, $mime, $post_id );
5365
+	return apply_filters('wp_mime_type_icon', $icon, $mime, $post_id);
5366 5366
 }
5367 5367
 
5368 5368
 /**
@@ -5384,27 +5384,27 @@  discard block
 block discarded – undo
5384 5384
  * @param WP_Post $post        The Post Object
5385 5385
  * @param WP_Post $post_before The Previous Post Object
5386 5386
  */
5387
-function wp_check_for_changed_slugs( $post_id, $post, $post_before ) {
5387
+function wp_check_for_changed_slugs($post_id, $post, $post_before) {
5388 5388
 	// Don't bother if it hasn't changed.
5389
-	if ( $post->post_name == $post_before->post_name ) {
5389
+	if ($post->post_name == $post_before->post_name) {
5390 5390
 		return;
5391 5391
 	}
5392 5392
 
5393 5393
 	// We're only concerned with published, non-hierarchical objects.
5394
-	if ( ! ( 'publish' === $post->post_status || ( 'attachment' === get_post_type( $post ) && 'inherit' === $post->post_status ) ) || is_post_type_hierarchical( $post->post_type ) ) {
5394
+	if ( ! ('publish' === $post->post_status || ('attachment' === get_post_type($post) && 'inherit' === $post->post_status)) || is_post_type_hierarchical($post->post_type)) {
5395 5395
 		return;
5396 5396
 	}
5397 5397
 
5398
-	$old_slugs = (array) get_post_meta( $post_id, '_wp_old_slug' );
5398
+	$old_slugs = (array) get_post_meta($post_id, '_wp_old_slug');
5399 5399
 
5400 5400
 	// If we haven't added this old slug before, add it now.
5401
-	if ( ! empty( $post_before->post_name ) && ! in_array( $post_before->post_name, $old_slugs ) ) {
5402
-		add_post_meta( $post_id, '_wp_old_slug', $post_before->post_name );
5401
+	if ( ! empty($post_before->post_name) && ! in_array($post_before->post_name, $old_slugs)) {
5402
+		add_post_meta($post_id, '_wp_old_slug', $post_before->post_name);
5403 5403
 	}
5404 5404
 
5405 5405
 	// If the new slug was used previously, delete it from the list.
5406
-	if ( in_array( $post->post_name, $old_slugs ) ) {
5407
-		delete_post_meta( $post_id, '_wp_old_slug', $post->post_name );
5406
+	if (in_array($post->post_name, $old_slugs)) {
5407
+		delete_post_meta($post_id, '_wp_old_slug', $post->post_name);
5408 5408
 	}
5409 5409
 }
5410 5410
 
@@ -5422,8 +5422,8 @@  discard block
 block discarded – undo
5422 5422
  * @param string|array $post_type Single post type or an array of post types. Currently only supports 'post' or 'page'.
5423 5423
  * @return string SQL code that can be added to a where clause.
5424 5424
  */
5425
-function get_private_posts_cap_sql( $post_type ) {
5426
-	return get_posts_by_author_sql( $post_type, false );
5425
+function get_private_posts_cap_sql($post_type) {
5426
+	return get_posts_by_author_sql($post_type, false);
5427 5427
 }
5428 5428
 
5429 5429
 /**
@@ -5443,19 +5443,19 @@  discard block
 block discarded – undo
5443 5443
  *                                    $current_user.  Default false.
5444 5444
  * @return string SQL WHERE code that can be added to a query.
5445 5445
  */
5446
-function get_posts_by_author_sql( $post_type, $full = true, $post_author = null, $public_only = false ) {
5446
+function get_posts_by_author_sql($post_type, $full = true, $post_author = null, $public_only = false) {
5447 5447
 	global $wpdb;
5448 5448
 
5449
-	if ( is_array( $post_type ) ) {
5449
+	if (is_array($post_type)) {
5450 5450
 		$post_types = $post_type;
5451 5451
 	} else {
5452
-		$post_types = array( $post_type );
5452
+		$post_types = array($post_type);
5453 5453
 	}
5454 5454
 
5455 5455
 	$post_type_clauses = array();
5456
-	foreach ( $post_types as $post_type ) {
5457
-		$post_type_obj = get_post_type_object( $post_type );
5458
-		if ( ! $post_type_obj ) {
5456
+	foreach ($post_types as $post_type) {
5457
+		$post_type_obj = get_post_type_object($post_type);
5458
+		if ( ! $post_type_obj) {
5459 5459
 			continue;
5460 5460
 		}
5461 5461
 
@@ -5468,42 +5468,42 @@  discard block
 block discarded – undo
5468 5468
 		 *
5469 5469
 		 * @param string $cap Capability.
5470 5470
 		 */
5471
-		if ( ! $cap = apply_filters( 'pub_priv_sql_capability', '' ) ) {
5472
-			$cap = current_user_can( $post_type_obj->cap->read_private_posts );
5471
+		if ( ! $cap = apply_filters('pub_priv_sql_capability', '')) {
5472
+			$cap = current_user_can($post_type_obj->cap->read_private_posts);
5473 5473
 		}
5474 5474
 
5475 5475
 		// Only need to check the cap if $public_only is false.
5476 5476
 		$post_status_sql = "post_status = 'publish'";
5477
-		if ( false === $public_only ) {
5478
-			if ( $cap ) {
5477
+		if (false === $public_only) {
5478
+			if ($cap) {
5479 5479
 				// Does the user have the capability to view private posts? Guess so.
5480 5480
 				$post_status_sql .= " OR post_status = 'private'";
5481
-			} elseif ( is_user_logged_in() ) {
5481
+			} elseif (is_user_logged_in()) {
5482 5482
 				// Users can view their own private posts.
5483 5483
 				$id = get_current_user_id();
5484
-				if ( null === $post_author || ! $full ) {
5484
+				if (null === $post_author || ! $full) {
5485 5485
 					$post_status_sql .= " OR post_status = 'private' AND post_author = $id";
5486
-				} elseif ( $id == (int) $post_author ) {
5486
+				} elseif ($id == (int) $post_author) {
5487 5487
 					$post_status_sql .= " OR post_status = 'private'";
5488 5488
 				} // else none
5489 5489
 			} // else none
5490 5490
 		}
5491 5491
 
5492
-		$post_type_clauses[] = "( post_type = '" . $post_type . "' AND ( $post_status_sql ) )";
5492
+		$post_type_clauses[] = "( post_type = '".$post_type."' AND ( $post_status_sql ) )";
5493 5493
 	}
5494 5494
 
5495
-	if ( empty( $post_type_clauses ) ) {
5495
+	if (empty($post_type_clauses)) {
5496 5496
 		return $full ? 'WHERE 1 = 0' : '1 = 0';
5497 5497
 	}
5498 5498
 
5499
-	$sql = '( '. implode( ' OR ', $post_type_clauses ) . ' )';
5499
+	$sql = '( '.implode(' OR ', $post_type_clauses).' )';
5500 5500
 
5501
-	if ( null !== $post_author ) {
5502
-		$sql .= $wpdb->prepare( ' AND post_author = %d', $post_author );
5501
+	if (null !== $post_author) {
5502
+		$sql .= $wpdb->prepare(' AND post_author = %d', $post_author);
5503 5503
 	}
5504 5504
 
5505
-	if ( $full ) {
5506
-		$sql = 'WHERE ' . $sql;
5505
+	if ($full) {
5506
+		$sql = 'WHERE '.$sql;
5507 5507
 	}
5508 5508
 
5509 5509
 	return $sql;
@@ -5527,7 +5527,7 @@  discard block
 block discarded – undo
5527 5527
  * @param string $post_type Optional. The post type to check. Default 'any'.
5528 5528
  * @return string The date of the last post.
5529 5529
  */
5530
-function get_lastpostdate( $timezone = 'server', $post_type = 'any' ) {
5530
+function get_lastpostdate($timezone = 'server', $post_type = 'any') {
5531 5531
 	/**
5532 5532
 	 * Filters the date the last post was published.
5533 5533
 	 *
@@ -5537,7 +5537,7 @@  discard block
 block discarded – undo
5537 5537
 	 * @param string $timezone Location to use for getting the post published date.
5538 5538
 	 *                         See get_lastpostdate() for accepted `$timezone` values.
5539 5539
 	 */
5540
-	return apply_filters( 'get_lastpostdate', _get_last_post_time( $timezone, 'date', $post_type ), $timezone );
5540
+	return apply_filters('get_lastpostdate', _get_last_post_time($timezone, 'date', $post_type), $timezone);
5541 5541
 }
5542 5542
 
5543 5543
 /**
@@ -5556,7 +5556,7 @@  discard block
 block discarded – undo
5556 5556
  * @param string $post_type Optional. The post type to check. Default 'any'.
5557 5557
  * @return string The timestamp.
5558 5558
  */
5559
-function get_lastpostmodified( $timezone = 'server', $post_type = 'any' ) {
5559
+function get_lastpostmodified($timezone = 'server', $post_type = 'any') {
5560 5560
 	/**
5561 5561
 	 * Pre-filter the return value of get_lastpostmodified() before the query is run.
5562 5562
 	 *
@@ -5568,15 +5568,15 @@  discard block
 block discarded – undo
5568 5568
 	 *                                 See get_lastpostdate() for accepted `$timezone` values.
5569 5569
 	 * @param string $post_type        The post type to check.
5570 5570
 	 */
5571
-	$lastpostmodified = apply_filters( 'pre_get_lastpostmodified', false, $timezone, $post_type );
5572
-	if ( false !== $lastpostmodified ) {
5571
+	$lastpostmodified = apply_filters('pre_get_lastpostmodified', false, $timezone, $post_type);
5572
+	if (false !== $lastpostmodified) {
5573 5573
 		return $lastpostmodified;
5574 5574
 	}
5575 5575
 
5576
-	$lastpostmodified = _get_last_post_time( $timezone, 'modified', $post_type );
5576
+	$lastpostmodified = _get_last_post_time($timezone, 'modified', $post_type);
5577 5577
 
5578 5578
 	$lastpostdate = get_lastpostdate($timezone);
5579
-	if ( $lastpostdate > $lastpostmodified ) {
5579
+	if ($lastpostdate > $lastpostmodified) {
5580 5580
 		$lastpostmodified = $lastpostdate;
5581 5581
 	}
5582 5582
 
@@ -5589,7 +5589,7 @@  discard block
 block discarded – undo
5589 5589
 	 * @param string $timezone         Location to use for getting the post modified date.
5590 5590
 	 *                                 See get_lastpostdate() for accepted `$timezone` values.
5591 5591
 	 */
5592
-	return apply_filters( 'get_lastpostmodified', $lastpostmodified, $timezone );
5592
+	return apply_filters('get_lastpostmodified', $lastpostmodified, $timezone);
5593 5593
 }
5594 5594
 
5595 5595
 /**
@@ -5607,34 +5607,34 @@  discard block
 block discarded – undo
5607 5607
  * @param string $post_type Optional. The post type to check. Default 'any'.
5608 5608
  * @return string|false The timestamp.
5609 5609
  */
5610
-function _get_last_post_time( $timezone, $field, $post_type = 'any' ) {
5610
+function _get_last_post_time($timezone, $field, $post_type = 'any') {
5611 5611
 	global $wpdb;
5612 5612
 
5613
-	if ( ! in_array( $field, array( 'date', 'modified' ) ) ) {
5613
+	if ( ! in_array($field, array('date', 'modified'))) {
5614 5614
 		return false;
5615 5615
 	}
5616 5616
 
5617
-	$timezone = strtolower( $timezone );
5617
+	$timezone = strtolower($timezone);
5618 5618
 
5619 5619
 	$key = "lastpost{$field}:$timezone";
5620
-	if ( 'any' !== $post_type ) {
5621
-		$key .= ':' . sanitize_key( $post_type );
5620
+	if ('any' !== $post_type) {
5621
+		$key .= ':'.sanitize_key($post_type);
5622 5622
 	}
5623 5623
 
5624
-	$date = wp_cache_get( $key, 'timeinfo' );
5625
-	if ( false !== $date ) {
5624
+	$date = wp_cache_get($key, 'timeinfo');
5625
+	if (false !== $date) {
5626 5626
 		return $date;
5627 5627
 	}
5628 5628
 
5629
-	if ( 'any' === $post_type ) {
5630
-		$post_types = get_post_types( array( 'public' => true ) );
5631
-		array_walk( $post_types, array( $wpdb, 'escape_by_ref' ) );
5632
-		$post_types = "'" . implode( "', '", $post_types ) . "'";
5629
+	if ('any' === $post_type) {
5630
+		$post_types = get_post_types(array('public' => true));
5631
+		array_walk($post_types, array($wpdb, 'escape_by_ref'));
5632
+		$post_types = "'".implode("', '", $post_types)."'";
5633 5633
 	} else {
5634
-		$post_types = "'" . sanitize_key( $post_type ) . "'";
5634
+		$post_types = "'".sanitize_key($post_type)."'";
5635 5635
 	}
5636 5636
 
5637
-	switch ( $timezone ) {
5637
+	switch ($timezone) {
5638 5638
 		case 'gmt':
5639 5639
 			$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");
5640 5640
 			break;
@@ -5642,13 +5642,13 @@  discard block
 block discarded – undo
5642 5642
 			$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");
5643 5643
 			break;
5644 5644
 		case 'server':
5645
-			$add_seconds_server = date( 'Z' );
5645
+			$add_seconds_server = date('Z');
5646 5646
 			$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");
5647 5647
 			break;
5648 5648
 	}
5649 5649
 
5650
-	if ( $date ) {
5651
-		wp_cache_set( $key, $date, 'timeinfo' );
5650
+	if ($date) {
5651
+		wp_cache_set($key, $date, 'timeinfo');
5652 5652
 
5653 5653
 		return $date;
5654 5654
 	}
@@ -5663,12 +5663,12 @@  discard block
 block discarded – undo
5663 5663
  *
5664 5664
  * @param array $posts Array of post objects, passed by reference.
5665 5665
  */
5666
-function update_post_cache( &$posts ) {
5667
-	if ( ! $posts )
5666
+function update_post_cache(&$posts) {
5667
+	if ( ! $posts)
5668 5668
 		return;
5669 5669
 
5670
-	foreach ( $posts as $post )
5671
-		wp_cache_add( $post->ID, $post, 'posts' );
5670
+	foreach ($posts as $post)
5671
+		wp_cache_add($post->ID, $post, 'posts');
5672 5672
 }
5673 5673
 
5674 5674
 /**
@@ -5686,22 +5686,22 @@  discard block
 block discarded – undo
5686 5686
  *
5687 5687
  * @param int|WP_Post $post Post ID or post object to remove from the cache.
5688 5688
  */
5689
-function clean_post_cache( $post ) {
5689
+function clean_post_cache($post) {
5690 5690
 	global $_wp_suspend_cache_invalidation;
5691 5691
 
5692
-	if ( ! empty( $_wp_suspend_cache_invalidation ) )
5692
+	if ( ! empty($_wp_suspend_cache_invalidation))
5693 5693
 		return;
5694 5694
 
5695
-	$post = get_post( $post );
5696
-	if ( empty( $post ) )
5695
+	$post = get_post($post);
5696
+	if (empty($post))
5697 5697
 		return;
5698 5698
 
5699
-	wp_cache_delete( $post->ID, 'posts' );
5700
-	wp_cache_delete( $post->ID, 'post_meta' );
5699
+	wp_cache_delete($post->ID, 'posts');
5700
+	wp_cache_delete($post->ID, 'post_meta');
5701 5701
 
5702
-	clean_object_term_cache( $post->ID, $post->post_type );
5702
+	clean_object_term_cache($post->ID, $post->post_type);
5703 5703
 
5704
-	wp_cache_delete( 'wp_get_archives', 'general' );
5704
+	wp_cache_delete('wp_get_archives', 'general');
5705 5705
 
5706 5706
 	/**
5707 5707
 	 * Fires immediately after the given post's cache is cleaned.
@@ -5711,10 +5711,10 @@  discard block
 block discarded – undo
5711 5711
 	 * @param int     $post_id Post ID.
5712 5712
 	 * @param WP_Post $post    Post object.
5713 5713
 	 */
5714
-	do_action( 'clean_post_cache', $post->ID, $post );
5714
+	do_action('clean_post_cache', $post->ID, $post);
5715 5715
 
5716
-	if ( 'page' == $post->post_type ) {
5717
-		wp_cache_delete( 'all_page_ids', 'posts' );
5716
+	if ('page' == $post->post_type) {
5717
+		wp_cache_delete('all_page_ids', 'posts');
5718 5718
 
5719 5719
 		/**
5720 5720
 		 * Fires immediately after the given page's cache is cleaned.
@@ -5723,10 +5723,10 @@  discard block
 block discarded – undo
5723 5723
 		 *
5724 5724
 		 * @param int $post_id Post ID.
5725 5725
 		 */
5726
-		do_action( 'clean_page_cache', $post->ID );
5726
+		do_action('clean_page_cache', $post->ID);
5727 5727
 	}
5728 5728
 
5729
-	wp_cache_set( 'last_changed', microtime(), 'posts' );
5729
+	wp_cache_set('last_changed', microtime(), 'posts');
5730 5730
 }
5731 5731
 
5732 5732
 /**
@@ -5739,27 +5739,27 @@  discard block
 block discarded – undo
5739 5739
  * @param bool   $update_term_cache Optional. Whether to update the term cache. Default true.
5740 5740
  * @param bool   $update_meta_cache Optional. Whether to update the meta cache. Default true.
5741 5741
  */
5742
-function update_post_caches( &$posts, $post_type = 'post', $update_term_cache = true, $update_meta_cache = true ) {
5742
+function update_post_caches(&$posts, $post_type = 'post', $update_term_cache = true, $update_meta_cache = true) {
5743 5743
 	// No point in doing all this work if we didn't match any posts.
5744
-	if ( !$posts )
5744
+	if ( ! $posts)
5745 5745
 		return;
5746 5746
 
5747 5747
 	update_post_cache($posts);
5748 5748
 
5749 5749
 	$post_ids = array();
5750
-	foreach ( $posts as $post )
5750
+	foreach ($posts as $post)
5751 5751
 		$post_ids[] = $post->ID;
5752 5752
 
5753
-	if ( ! $post_type )
5753
+	if ( ! $post_type)
5754 5754
 		$post_type = 'any';
5755 5755
 
5756
-	if ( $update_term_cache ) {
5757
-		if ( is_array($post_type) ) {
5756
+	if ($update_term_cache) {
5757
+		if (is_array($post_type)) {
5758 5758
 			$ptypes = $post_type;
5759
-		} elseif ( 'any' == $post_type ) {
5759
+		} elseif ('any' == $post_type) {
5760 5760
 			$ptypes = array();
5761 5761
 			// Just use the post_types in the supplied posts.
5762
-			foreach ( $posts as $post ) {
5762
+			foreach ($posts as $post) {
5763 5763
 				$ptypes[] = $post->post_type;
5764 5764
 			}
5765 5765
 			$ptypes = array_unique($ptypes);
@@ -5767,11 +5767,11 @@  discard block
 block discarded – undo
5767 5767
 			$ptypes = array($post_type);
5768 5768
 		}
5769 5769
 
5770
-		if ( ! empty($ptypes) )
5770
+		if ( ! empty($ptypes))
5771 5771
 			update_object_term_cache($post_ids, $ptypes);
5772 5772
 	}
5773 5773
 
5774
-	if ( $update_meta_cache )
5774
+	if ($update_meta_cache)
5775 5775
 		update_postmeta_cache($post_ids);
5776 5776
 }
5777 5777
 
@@ -5788,7 +5788,7 @@  discard block
 block discarded – undo
5788 5788
  * @return array|false Returns false if there is nothing to update or an array
5789 5789
  *                     of metadata.
5790 5790
  */
5791
-function update_postmeta_cache( $post_ids ) {
5791
+function update_postmeta_cache($post_ids) {
5792 5792
 	return update_meta_cache('post', $post_ids);
5793 5793
 }
5794 5794
 
@@ -5807,10 +5807,10 @@  discard block
 block discarded – undo
5807 5807
  * @param int  $id          The attachment ID in the cache to clean.
5808 5808
  * @param bool $clean_terms Optional. Whether to clean terms cache. Default false.
5809 5809
  */
5810
-function clean_attachment_cache( $id, $clean_terms = false ) {
5810
+function clean_attachment_cache($id, $clean_terms = false) {
5811 5811
 	global $_wp_suspend_cache_invalidation;
5812 5812
 
5813
-	if ( !empty($_wp_suspend_cache_invalidation) )
5813
+	if ( ! empty($_wp_suspend_cache_invalidation))
5814 5814
 		return;
5815 5815
 
5816 5816
 	$id = (int) $id;
@@ -5818,7 +5818,7 @@  discard block
 block discarded – undo
5818 5818
 	wp_cache_delete($id, 'posts');
5819 5819
 	wp_cache_delete($id, 'post_meta');
5820 5820
 
5821
-	if ( $clean_terms )
5821
+	if ($clean_terms)
5822 5822
 		clean_object_term_cache($id, 'attachment');
5823 5823
 
5824 5824
 	/**
@@ -5828,7 +5828,7 @@  discard block
 block discarded – undo
5828 5828
 	 *
5829 5829
 	 * @param int $id Attachment ID.
5830 5830
 	 */
5831
-	do_action( 'clean_attachment_cache', $id );
5831
+	do_action('clean_attachment_cache', $id);
5832 5832
 }
5833 5833
 
5834 5834
 //
@@ -5848,13 +5848,13 @@  discard block
 block discarded – undo
5848 5848
  * @param string  $old_status Previous post status.
5849 5849
  * @param WP_Post $post       Post object.
5850 5850
  */
5851
-function _transition_post_status( $new_status, $old_status, $post ) {
5851
+function _transition_post_status($new_status, $old_status, $post) {
5852 5852
 	global $wpdb;
5853 5853
 
5854
-	if ( $old_status != 'publish' && $new_status == 'publish' ) {
5854
+	if ($old_status != 'publish' && $new_status == 'publish') {
5855 5855
 		// Reset GUID if transitioning to publish and it is empty.
5856
-		if ( '' == get_the_guid($post->ID) )
5857
-			$wpdb->update( $wpdb->posts, array( 'guid' => get_permalink( $post->ID ) ), array( 'ID' => $post->ID ) );
5856
+		if ('' == get_the_guid($post->ID))
5857
+			$wpdb->update($wpdb->posts, array('guid' => get_permalink($post->ID)), array('ID' => $post->ID));
5858 5858
 
5859 5859
 		/**
5860 5860
 		 * Fires when a post's status is transitioned from private to published.
@@ -5868,21 +5868,21 @@  discard block
 block discarded – undo
5868 5868
 	}
5869 5869
 
5870 5870
 	// If published posts changed clear the lastpostmodified cache.
5871
-	if ( 'publish' == $new_status || 'publish' == $old_status) {
5872
-		foreach ( array( 'server', 'gmt', 'blog' ) as $timezone ) {
5873
-			wp_cache_delete( "lastpostmodified:$timezone", 'timeinfo' );
5874
-			wp_cache_delete( "lastpostdate:$timezone", 'timeinfo' );
5875
-			wp_cache_delete( "lastpostdate:$timezone:{$post->post_type}", 'timeinfo' );
5871
+	if ('publish' == $new_status || 'publish' == $old_status) {
5872
+		foreach (array('server', 'gmt', 'blog') as $timezone) {
5873
+			wp_cache_delete("lastpostmodified:$timezone", 'timeinfo');
5874
+			wp_cache_delete("lastpostdate:$timezone", 'timeinfo');
5875
+			wp_cache_delete("lastpostdate:$timezone:{$post->post_type}", 'timeinfo');
5876 5876
 		}
5877 5877
 	}
5878 5878
 
5879
-	if ( $new_status !== $old_status ) {
5880
-		wp_cache_delete( _count_posts_cache_key( $post->post_type ), 'counts' );
5881
-		wp_cache_delete( _count_posts_cache_key( $post->post_type, 'readable' ), 'counts' );
5879
+	if ($new_status !== $old_status) {
5880
+		wp_cache_delete(_count_posts_cache_key($post->post_type), 'counts');
5881
+		wp_cache_delete(_count_posts_cache_key($post->post_type, 'readable'), 'counts');
5882 5882
 	}
5883 5883
 
5884 5884
 	// Always clears the hook in case the post status bounced from future to draft.
5885
-	wp_clear_scheduled_hook('publish_future_post', array( $post->ID ) );
5885
+	wp_clear_scheduled_hook('publish_future_post', array($post->ID));
5886 5886
 }
5887 5887
 
5888 5888
 /**
@@ -5898,9 +5898,9 @@  discard block
 block discarded – undo
5898 5898
  *                            wp_transition_post_status() and the default filter for _future_post_hook().
5899 5899
  * @param WP_Post $post       Post object.
5900 5900
  */
5901
-function _future_post_hook( $deprecated, $post ) {
5902
-	wp_clear_scheduled_hook( 'publish_future_post', array( $post->ID ) );
5903
-	wp_schedule_single_event( strtotime( get_gmt_from_date( $post->post_date ) . ' GMT') , 'publish_future_post', array( $post->ID ) );
5901
+function _future_post_hook($deprecated, $post) {
5902
+	wp_clear_scheduled_hook('publish_future_post', array($post->ID));
5903
+	wp_schedule_single_event(strtotime(get_gmt_from_date($post->post_date).' GMT'), 'publish_future_post', array($post->ID));
5904 5904
 }
5905 5905
 
5906 5906
 /**
@@ -5913,8 +5913,8 @@  discard block
 block discarded – undo
5913 5913
  *
5914 5914
  * @param int $post_id The ID in the database table of the post being published.
5915 5915
  */
5916
-function _publish_post_hook( $post_id ) {
5917
-	if ( defined( 'XMLRPC_REQUEST' ) ) {
5916
+function _publish_post_hook($post_id) {
5917
+	if (defined('XMLRPC_REQUEST')) {
5918 5918
 		/**
5919 5919
 		 * Fires when _publish_post_hook() is called during an XML-RPC request.
5920 5920
 		 *
@@ -5922,15 +5922,15 @@  discard block
 block discarded – undo
5922 5922
 		 *
5923 5923
 		 * @param int $post_id Post ID.
5924 5924
 		 */
5925
-		do_action( 'xmlrpc_publish_post', $post_id );
5925
+		do_action('xmlrpc_publish_post', $post_id);
5926 5926
 	}
5927 5927
 
5928
-	if ( defined('WP_IMPORTING') )
5928
+	if (defined('WP_IMPORTING'))
5929 5929
 		return;
5930 5930
 
5931
-	if ( get_option('default_pingback_flag') )
5932
-		add_post_meta( $post_id, '_pingme', '1' );
5933
-	add_post_meta( $post_id, '_encloseme', '1' );
5931
+	if (get_option('default_pingback_flag'))
5932
+		add_post_meta($post_id, '_pingme', '1');
5933
+	add_post_meta($post_id, '_encloseme', '1');
5934 5934
 
5935 5935
 	wp_schedule_single_event(time(), 'do_pings');
5936 5936
 }
@@ -5944,9 +5944,9 @@  discard block
 block discarded – undo
5944 5944
  *
5945 5945
  * @return int|false Post parent ID, otherwise false.
5946 5946
  */
5947
-function wp_get_post_parent_id( $post_ID ) {
5948
-	$post = get_post( $post_ID );
5949
-	if ( !$post || is_wp_error( $post ) )
5947
+function wp_get_post_parent_id($post_ID) {
5948
+	$post = get_post($post_ID);
5949
+	if ( ! $post || is_wp_error($post))
5950 5950
 		return false;
5951 5951
 	return (int) $post->post_parent;
5952 5952
 }
@@ -5965,30 +5965,30 @@  discard block
 block discarded – undo
5965 5965
  * @param int $post_ID     ID of the post we're checking.
5966 5966
  * @return int The new post_parent for the post, 0 otherwise.
5967 5967
  */
5968
-function wp_check_post_hierarchy_for_loops( $post_parent, $post_ID ) {
5968
+function wp_check_post_hierarchy_for_loops($post_parent, $post_ID) {
5969 5969
 	// Nothing fancy here - bail.
5970
-	if ( !$post_parent )
5970
+	if ( ! $post_parent)
5971 5971
 		return 0;
5972 5972
 
5973 5973
 	// New post can't cause a loop.
5974
-	if ( empty( $post_ID ) )
5974
+	if (empty($post_ID))
5975 5975
 		return $post_parent;
5976 5976
 
5977 5977
 	// Can't be its own parent.
5978
-	if ( $post_parent == $post_ID )
5978
+	if ($post_parent == $post_ID)
5979 5979
 		return 0;
5980 5980
 
5981 5981
 	// Now look for larger loops.
5982
-	if ( !$loop = wp_find_hierarchy_loop( 'wp_get_post_parent_id', $post_ID, $post_parent ) )
5982
+	if ( ! $loop = wp_find_hierarchy_loop('wp_get_post_parent_id', $post_ID, $post_parent))
5983 5983
 		return $post_parent; // No loop
5984 5984
 
5985 5985
 	// Setting $post_parent to the given value causes a loop.
5986
-	if ( isset( $loop[$post_ID] ) )
5986
+	if (isset($loop[$post_ID]))
5987 5987
 		return 0;
5988 5988
 
5989 5989
 	// There's a loop, but it doesn't contain $post_ID. Break the loop.
5990
-	foreach ( array_keys( $loop ) as $loop_member )
5991
-		wp_update_post( array( 'ID' => $loop_member, 'post_parent' => 0 ) );
5990
+	foreach (array_keys($loop) as $loop_member)
5991
+		wp_update_post(array('ID' => $loop_member, 'post_parent' => 0));
5992 5992
 
5993 5993
 	return $post_parent;
5994 5994
 }
@@ -6002,14 +6002,14 @@  discard block
 block discarded – undo
6002 6002
  * @param int         $thumbnail_id Thumbnail to attach.
6003 6003
  * @return int|bool True on success, false on failure.
6004 6004
  */
6005
-function set_post_thumbnail( $post, $thumbnail_id ) {
6006
-	$post = get_post( $post );
6007
-	$thumbnail_id = absint( $thumbnail_id );
6008
-	if ( $post && $thumbnail_id && get_post( $thumbnail_id ) ) {
6009
-		if ( wp_get_attachment_image( $thumbnail_id, 'thumbnail' ) )
6010
-			return update_post_meta( $post->ID, '_thumbnail_id', $thumbnail_id );
6005
+function set_post_thumbnail($post, $thumbnail_id) {
6006
+	$post = get_post($post);
6007
+	$thumbnail_id = absint($thumbnail_id);
6008
+	if ($post && $thumbnail_id && get_post($thumbnail_id)) {
6009
+		if (wp_get_attachment_image($thumbnail_id, 'thumbnail'))
6010
+			return update_post_meta($post->ID, '_thumbnail_id', $thumbnail_id);
6011 6011
 		else
6012
-			return delete_post_meta( $post->ID, '_thumbnail_id' );
6012
+			return delete_post_meta($post->ID, '_thumbnail_id');
6013 6013
 	}
6014 6014
 	return false;
6015 6015
 }
@@ -6022,10 +6022,10 @@  discard block
 block discarded – undo
6022 6022
  * @param int|WP_Post $post Post ID or post object where thumbnail should be removed from.
6023 6023
  * @return bool True on success, false on failure.
6024 6024
  */
6025
-function delete_post_thumbnail( $post ) {
6026
-	$post = get_post( $post );
6027
-	if ( $post )
6028
-		return delete_post_meta( $post->ID, '_thumbnail_id' );
6025
+function delete_post_thumbnail($post) {
6026
+	$post = get_post($post);
6027
+	if ($post)
6028
+		return delete_post_meta($post->ID, '_thumbnail_id');
6029 6029
 	return false;
6030 6030
 }
6031 6031
 
@@ -6040,10 +6040,10 @@  discard block
 block discarded – undo
6040 6040
 	global $wpdb;
6041 6041
 
6042 6042
 	// Cleanup old auto-drafts more than 7 days old.
6043
-	$old_posts = $wpdb->get_col( "SELECT ID FROM $wpdb->posts WHERE post_status = 'auto-draft' AND DATE_SUB( NOW(), INTERVAL 7 DAY ) > post_date" );
6044
-	foreach ( (array) $old_posts as $delete ) {
6043
+	$old_posts = $wpdb->get_col("SELECT ID FROM $wpdb->posts WHERE post_status = 'auto-draft' AND DATE_SUB( NOW(), INTERVAL 7 DAY ) > post_date");
6044
+	foreach ((array) $old_posts as $delete) {
6045 6045
 		// Force delete.
6046
-		wp_delete_post( $delete, true );
6046
+		wp_delete_post($delete, true);
6047 6047
 	}
6048 6048
 }
6049 6049
 
@@ -6054,23 +6054,23 @@  discard block
 block discarded – undo
6054 6054
  *
6055 6055
  * @param array $posts Array of WP_Post objects.
6056 6056
  */
6057
-function wp_queue_posts_for_term_meta_lazyload( $posts ) {
6057
+function wp_queue_posts_for_term_meta_lazyload($posts) {
6058 6058
 	$post_type_taxonomies = $term_ids = array();
6059
-	foreach ( $posts as $post ) {
6060
-		if ( ! ( $post instanceof WP_Post ) ) {
6059
+	foreach ($posts as $post) {
6060
+		if ( ! ($post instanceof WP_Post)) {
6061 6061
 			continue;
6062 6062
 		}
6063 6063
 
6064
-		if ( ! isset( $post_type_taxonomies[ $post->post_type ] ) ) {
6065
-			$post_type_taxonomies[ $post->post_type ] = get_object_taxonomies( $post->post_type );
6064
+		if ( ! isset($post_type_taxonomies[$post->post_type])) {
6065
+			$post_type_taxonomies[$post->post_type] = get_object_taxonomies($post->post_type);
6066 6066
 		}
6067 6067
 
6068
-		foreach ( $post_type_taxonomies[ $post->post_type ] as $taxonomy ) {
6068
+		foreach ($post_type_taxonomies[$post->post_type] as $taxonomy) {
6069 6069
 			// Term cache should already be primed by `update_post_term_cache()`.
6070
-			$terms = get_object_term_cache( $post->ID, $taxonomy );
6071
-			if ( false !== $terms ) {
6072
-				foreach ( $terms as $term ) {
6073
-					if ( ! isset( $term_ids[ $term->term_id ] ) ) {
6070
+			$terms = get_object_term_cache($post->ID, $taxonomy);
6071
+			if (false !== $terms) {
6072
+				foreach ($terms as $term) {
6073
+					if ( ! isset($term_ids[$term->term_id])) {
6074 6074
 						$term_ids[] = $term->term_id;
6075 6075
 					}
6076 6076
 				}
@@ -6078,9 +6078,9 @@  discard block
 block discarded – undo
6078 6078
 		}
6079 6079
 	}
6080 6080
 
6081
-	if ( $term_ids ) {
6081
+	if ($term_ids) {
6082 6082
 		$lazyloader = wp_metadata_lazyloader();
6083
-		$lazyloader->queue_objects( 'term', $term_ids );
6083
+		$lazyloader->queue_objects('term', $term_ids);
6084 6084
 	}
6085 6085
 }
6086 6086
 
@@ -6097,11 +6097,11 @@  discard block
 block discarded – undo
6097 6097
  * @param string  $old_status Old post status.
6098 6098
  * @param WP_Post $post       Post object.
6099 6099
  */
6100
-function _update_term_count_on_transition_post_status( $new_status, $old_status, $post ) {
6100
+function _update_term_count_on_transition_post_status($new_status, $old_status, $post) {
6101 6101
 	// Update counts for the post's terms.
6102
-	foreach ( (array) get_object_taxonomies( $post->post_type ) as $taxonomy ) {
6103
-		$tt_ids = wp_get_object_terms( $post->ID, $taxonomy, array( 'fields' => 'tt_ids' ) );
6104
-		wp_update_term_count( $tt_ids, $taxonomy );
6102
+	foreach ((array) get_object_taxonomies($post->post_type) as $taxonomy) {
6103
+		$tt_ids = wp_get_object_terms($post->ID, $taxonomy, array('fields' => 'tt_ids'));
6104
+		wp_update_term_count($tt_ids, $taxonomy);
6105 6105
 	}
6106 6106
 }
6107 6107
 
@@ -6119,14 +6119,14 @@  discard block
 block discarded – undo
6119 6119
  * @param bool  $update_term_cache Optional. Whether to update the term cache. Default true.
6120 6120
  * @param bool  $update_meta_cache Optional. Whether to update the meta cache. Default true.
6121 6121
  */
6122
-function _prime_post_caches( $ids, $update_term_cache = true, $update_meta_cache = true ) {
6122
+function _prime_post_caches($ids, $update_term_cache = true, $update_meta_cache = true) {
6123 6123
 	global $wpdb;
6124 6124
 
6125
-	$non_cached_ids = _get_non_cached_ids( $ids, 'posts' );
6126
-	if ( !empty( $non_cached_ids ) ) {
6127
-		$fresh_posts = $wpdb->get_results( sprintf( "SELECT $wpdb->posts.* FROM $wpdb->posts WHERE ID IN (%s)", join( ",", $non_cached_ids ) ) );
6125
+	$non_cached_ids = _get_non_cached_ids($ids, 'posts');
6126
+	if ( ! empty($non_cached_ids)) {
6127
+		$fresh_posts = $wpdb->get_results(sprintf("SELECT $wpdb->posts.* FROM $wpdb->posts WHERE ID IN (%s)", join(",", $non_cached_ids)));
6128 6128
 
6129
-		update_post_caches( $fresh_posts, 'any', $update_term_cache, $update_meta_cache );
6129
+		update_post_caches($fresh_posts, 'any', $update_term_cache, $update_meta_cache);
6130 6130
 	}
6131 6131
 }
6132 6132
 
@@ -6144,18 +6144,18 @@  discard block
 block discarded – undo
6144 6144
  * @param string $post_name Slug.
6145 6145
  * @param string $post_ID   Optional. Post ID that should be ignored. Default 0.
6146 6146
  */
6147
-function wp_add_trashed_suffix_to_post_name_for_trashed_posts( $post_name, $post_ID = 0 ) {
6148
-	$trashed_posts_with_desired_slug = get_posts( array(
6147
+function wp_add_trashed_suffix_to_post_name_for_trashed_posts($post_name, $post_ID = 0) {
6148
+	$trashed_posts_with_desired_slug = get_posts(array(
6149 6149
 		'name' => $post_name,
6150 6150
 		'post_status' => 'trash',
6151 6151
 		'post_type' => 'any',
6152 6152
 		'nopaging' => true,
6153
-		'post__not_in' => array( $post_ID )
6154
-	) );
6153
+		'post__not_in' => array($post_ID)
6154
+	));
6155 6155
 
6156
-	if ( ! empty( $trashed_posts_with_desired_slug ) ) {
6157
-		foreach ( $trashed_posts_with_desired_slug as $_post ) {
6158
-			wp_add_trashed_suffix_to_post_name_for_post( $_post );
6156
+	if ( ! empty($trashed_posts_with_desired_slug)) {
6157
+		foreach ($trashed_posts_with_desired_slug as $_post) {
6158
+			wp_add_trashed_suffix_to_post_name_for_post($_post);
6159 6159
 		}
6160 6160
 	}
6161 6161
 }
@@ -6174,18 +6174,18 @@  discard block
 block discarded – undo
6174 6174
  * @param WP_Post $post The post.
6175 6175
  * @return string New slug for the post.
6176 6176
  */
6177
-function wp_add_trashed_suffix_to_post_name_for_post( $post ) {
6177
+function wp_add_trashed_suffix_to_post_name_for_post($post) {
6178 6178
 	global $wpdb;
6179 6179
 
6180
-	$post = get_post( $post );
6180
+	$post = get_post($post);
6181 6181
 
6182
-	if ( '__trashed' === substr( $post->post_name, -9 ) ) {
6182
+	if ('__trashed' === substr($post->post_name, -9)) {
6183 6183
 		return $post->post_name;
6184 6184
 	}
6185
-	add_post_meta( $post->ID, '_wp_desired_post_slug', $post->post_name );
6186
-	$post_name = _truncate_post_slug( $post->post_name, 191 ) . '__trashed';
6187
-	$wpdb->update( $wpdb->posts, array( 'post_name' => $post_name ), array( 'ID' => $post->ID ) );
6188
-	clean_post_cache( $post->ID );
6185
+	add_post_meta($post->ID, '_wp_desired_post_slug', $post->post_name);
6186
+	$post_name = _truncate_post_slug($post->post_name, 191).'__trashed';
6187
+	$wpdb->update($wpdb->posts, array('post_name' => $post_name), array('ID' => $post->ID));
6188
+	clean_post_cache($post->ID);
6189 6189
 	return $post_name;
6190 6190
 }
6191 6191
 
@@ -6201,9 +6201,9 @@  discard block
 block discarded – undo
6201 6201
  *                       DISTINCT, fields (SELECT), and LIMITS clauses.
6202 6202
  * @return array The modified clauses.
6203 6203
  */
6204
-function _filter_query_attachment_filenames( $clauses ) {
6204
+function _filter_query_attachment_filenames($clauses) {
6205 6205
 	global $wpdb;
6206
-	remove_filter( 'posts_clauses', __FUNCTION__ );
6206
+	remove_filter('posts_clauses', __FUNCTION__);
6207 6207
 
6208 6208
 	// Add a LEFT JOIN of the postmeta table so we don't trample existing JOINs.
6209 6209
 	$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 = array( $args->label, $args->label );
844
+	if ( false === $args->label_count ) {
845
+			$args->label_count = array( $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.
@@ -3542,8 +3636,9 @@  discard block
 block discarded – undo
3542 3636
 	$post = get_post($postarr['ID'], ARRAY_A);
3543 3637
 
3544 3638
 	if ( is_null( $post ) ) {
3545
-		if ( $wp_error )
3546
-			return new WP_Error( 'invalid_post', __( 'Invalid post ID.' ) );
3639
+		if ( $wp_error ) {
3640
+					return new WP_Error( 'invalid_post', __( 'Invalid post ID.' ) );
3641
+		}
3547 3642
 		return 0;
3548 3643
 	}
3549 3644
 
@@ -3552,17 +3647,19 @@  discard block
 block discarded – undo
3552 3647
 
3553 3648
 	// Passed post category list overwrites existing category list if not empty.
3554 3649
 	if ( isset($postarr['post_category']) && is_array($postarr['post_category'])
3555
-			 && 0 != count($postarr['post_category']) )
3556
-		$post_cats = $postarr['post_category'];
3557
-	else
3558
-		$post_cats = $post['post_category'];
3650
+			 && 0 != count($postarr['post_category']) ) {
3651
+			$post_cats = $postarr['post_category'];
3652
+	} else {
3653
+			$post_cats = $post['post_category'];
3654
+	}
3559 3655
 
3560 3656
 	// Drafts shouldn't be assigned a date unless explicitly done so by the user.
3561 3657
 	if ( isset( $post['post_status'] ) && in_array($post['post_status'], array('draft', 'pending', 'auto-draft')) && empty($postarr['edit_date']) &&
3562
-			 ('0000-00-00 00:00:00' == $post['post_date_gmt']) )
3563
-		$clear_date = true;
3564
-	else
3565
-		$clear_date = false;
3658
+			 ('0000-00-00 00:00:00' == $post['post_date_gmt']) ) {
3659
+			$clear_date = true;
3660
+	} else {
3661
+			$clear_date = false;
3662
+	}
3566 3663
 
3567 3664
 	// Merge old and new fields with new fields overwriting old ones.
3568 3665
 	$postarr = array_merge($post, $postarr);
@@ -3572,8 +3669,9 @@  discard block
 block discarded – undo
3572 3669
 		$postarr['post_date_gmt'] = '';
3573 3670
 	}
3574 3671
 
3575
-	if ($postarr['post_type'] == 'attachment')
3576
-		return wp_insert_attachment($postarr);
3672
+	if ($postarr['post_type'] == 'attachment') {
3673
+			return wp_insert_attachment($postarr);
3674
+	}
3577 3675
 
3578 3676
 	return wp_insert_post( $postarr, $wp_error );
3579 3677
 }
@@ -3590,11 +3688,13 @@  discard block
 block discarded – undo
3590 3688
 function wp_publish_post( $post ) {
3591 3689
 	global $wpdb;
3592 3690
 
3593
-	if ( ! $post = get_post( $post ) )
3594
-		return;
3691
+	if ( ! $post = get_post( $post ) ) {
3692
+			return;
3693
+	}
3595 3694
 
3596
-	if ( 'publish' == $post->post_status )
3597
-		return;
3695
+	if ( 'publish' == $post->post_status ) {
3696
+			return;
3697
+	}
3598 3698
 
3599 3699
 	$wpdb->update( $wpdb->posts, array( 'post_status' => 'publish' ), array( 'ID' => $post->ID ) );
3600 3700
 
@@ -3630,11 +3730,13 @@  discard block
 block discarded – undo
3630 3730
 function check_and_publish_future_post( $post_id ) {
3631 3731
 	$post = get_post($post_id);
3632 3732
 
3633
-	if ( empty($post) )
3634
-		return;
3733
+	if ( empty($post) ) {
3734
+			return;
3735
+	}
3635 3736
 
3636
-	if ( 'future' != $post->post_status )
3637
-		return;
3737
+	if ( 'future' != $post->post_status ) {
3738
+			return;
3739
+	}
3638 3740
 
3639 3741
 	$time = strtotime( $post->post_date_gmt . ' GMT' );
3640 3742
 
@@ -3665,16 +3767,18 @@  discard block
 block discarded – undo
3665 3767
  * @return string Unique slug for the post, based on $post_name (with a -1, -2, etc. suffix)
3666 3768
  */
3667 3769
 function wp_unique_post_slug( $slug, $post_ID, $post_status, $post_type, $post_parent ) {
3668
-	if ( in_array( $post_status, array( 'draft', 'pending', 'auto-draft' ) ) || ( 'inherit' == $post_status && 'revision' == $post_type ) )
3669
-		return $slug;
3770
+	if ( in_array( $post_status, array( 'draft', 'pending', 'auto-draft' ) ) || ( 'inherit' == $post_status && 'revision' == $post_type ) ) {
3771
+			return $slug;
3772
+	}
3670 3773
 
3671 3774
 	global $wpdb, $wp_rewrite;
3672 3775
 
3673 3776
 	$original_slug = $slug;
3674 3777
 
3675 3778
 	$feeds = $wp_rewrite->feeds;
3676
-	if ( ! is_array( $feeds ) )
3677
-		$feeds = array();
3779
+	if ( ! is_array( $feeds ) ) {
3780
+			$feeds = array();
3781
+	}
3678 3782
 
3679 3783
 	if ( 'attachment' == $post_type ) {
3680 3784
 		// Attachment slugs must be unique across all types.
@@ -3699,8 +3803,9 @@  discard block
 block discarded – undo
3699 3803
 			$slug = $alt_post_name;
3700 3804
 		}
3701 3805
 	} elseif ( is_post_type_hierarchical( $post_type ) ) {
3702
-		if ( 'nav_menu_item' == $post_type )
3703
-			return $slug;
3806
+		if ( 'nav_menu_item' == $post_type ) {
3807
+					return $slug;
3808
+		}
3704 3809
 
3705 3810
 		/*
3706 3811
 		 * Page slugs must be unique within their own trees. Pages are in a separate
@@ -3805,10 +3910,11 @@  discard block
 block discarded – undo
3805 3910
 function _truncate_post_slug( $slug, $length = 200 ) {
3806 3911
 	if ( strlen( $slug ) > $length ) {
3807 3912
 		$decoded_slug = urldecode( $slug );
3808
-		if ( $decoded_slug === $slug )
3809
-			$slug = substr( $slug, 0, $length );
3810
-		else
3811
-			$slug = utf8_uri_encode( $decoded_slug, $length );
3913
+		if ( $decoded_slug === $slug ) {
3914
+					$slug = substr( $slug, 0, $length );
3915
+		} else {
3916
+					$slug = utf8_uri_encode( $decoded_slug, $length );
3917
+		}
3812 3918
 	}
3813 3919
 
3814 3920
 	return rtrim( $slug, '-' );
@@ -3866,16 +3972,19 @@  discard block
 block discarded – undo
3866 3972
 function wp_set_post_terms( $post_id = 0, $tags = '', $taxonomy = 'post_tag', $append = false ) {
3867 3973
 	$post_id = (int) $post_id;
3868 3974
 
3869
-	if ( !$post_id )
3870
-		return false;
3975
+	if ( !$post_id ) {
3976
+			return false;
3977
+	}
3871 3978
 
3872
-	if ( empty($tags) )
3873
-		$tags = array();
3979
+	if ( empty($tags) ) {
3980
+			$tags = array();
3981
+	}
3874 3982
 
3875 3983
 	if ( ! is_array( $tags ) ) {
3876 3984
 		$comma = _x( ',', 'tag delimiter' );
3877
-		if ( ',' !== $comma )
3878
-			$tags = str_replace( $comma, ',', $tags );
3985
+		if ( ',' !== $comma ) {
3986
+					$tags = str_replace( $comma, ',', $tags );
3987
+		}
3879 3988
 		$tags = explode( ',', trim( $tags, " \n\t\r\0\x0B," ) );
3880 3989
 	}
3881 3990
 
@@ -4023,8 +4132,7 @@  discard block
 block discarded – undo
4023 4132
 
4024 4133
 	if ( is_array( $uri ) ) {
4025 4134
 		$pung = array_merge( $pung, $uri );
4026
-	}
4027
-	else {
4135
+	} else {
4028 4136
 		$pung[] = $uri;
4029 4137
 	}
4030 4138
 	$new = implode("\n", $pung);
@@ -4054,12 +4162,14 @@  discard block
 block discarded – undo
4054 4162
 function get_enclosed( $post_id ) {
4055 4163
 	$custom_fields = get_post_custom( $post_id );
4056 4164
 	$pung = array();
4057
-	if ( !is_array( $custom_fields ) )
4058
-		return $pung;
4165
+	if ( !is_array( $custom_fields ) ) {
4166
+			return $pung;
4167
+	}
4059 4168
 
4060 4169
 	foreach ( $custom_fields as $key => $val ) {
4061
-		if ( 'enclosure' != $key || !is_array( $val ) )
4062
-			continue;
4170
+		if ( 'enclosure' != $key || !is_array( $val ) ) {
4171
+					continue;
4172
+		}
4063 4173
 		foreach ( $val as $enc ) {
4064 4174
 			$enclosure = explode( "\n", $enc );
4065 4175
 			$pung[] = trim( $enclosure[ 0 ] );
@@ -4278,15 +4388,17 @@  discard block
 block discarded – undo
4278 4388
 			while ( $p->post_parent != 0 && isset( $pages[ $p->post_parent ] ) ) {
4279 4389
 				$count++;
4280 4390
 				$parent = $pages[ $p->post_parent ];
4281
-				if ( ! isset( $revparts[ $count ] ) || $parent->post_name != $revparts[ $count ] )
4282
-					break;
4391
+				if ( ! isset( $revparts[ $count ] ) || $parent->post_name != $revparts[ $count ] ) {
4392
+									break;
4393
+				}
4283 4394
 				$p = $parent;
4284 4395
 			}
4285 4396
 
4286 4397
 			if ( $p->post_parent == 0 && $count+1 == count( $revparts ) && $p->post_name == $revparts[ $count ] ) {
4287 4398
 				$foundid = $page->ID;
4288
-				if ( $page->post_type == $post_type )
4289
-					break;
4399
+				if ( $page->post_type == $post_type ) {
4400
+									break;
4401
+				}
4290 4402
 			}
4291 4403
 		}
4292 4404
 	}
@@ -4447,8 +4559,9 @@  discard block
 block discarded – undo
4447 4559
 		$page = get_post( $page );
4448 4560
 	}
4449 4561
 
4450
-	if ( ! $page )
4451
-		return false;
4562
+	if ( ! $page ) {
4563
+			return false;
4564
+	}
4452 4565
 
4453 4566
 	$uri = $page->post_name;
4454 4567
 
@@ -4782,14 +4895,17 @@  discard block
 block discarded – undo
4782 4895
  * @return bool True on success, false on failure.
4783 4896
  */
4784 4897
 function is_local_attachment($url) {
4785
-	if (strpos($url, home_url()) === false)
4786
-		return false;
4787
-	if (strpos($url, home_url('/?attachment_id=')) !== false)
4788
-		return true;
4898
+	if (strpos($url, home_url()) === false) {
4899
+			return false;
4900
+	}
4901
+	if (strpos($url, home_url('/?attachment_id=')) !== false) {
4902
+			return true;
4903
+	}
4789 4904
 	if ( $id = url_to_postid($url) ) {
4790 4905
 		$post = get_post($id);
4791
-		if ( 'attachment' == $post->post_type )
4792
-			return true;
4906
+		if ( 'attachment' == $post->post_type ) {
4907
+					return true;
4908
+		}
4793 4909
 	}
4794 4910
 	return false;
4795 4911
 }
@@ -4858,14 +4974,17 @@  discard block
 block discarded – undo
4858 4974
 function wp_delete_attachment( $post_id, $force_delete = false ) {
4859 4975
 	global $wpdb;
4860 4976
 
4861
-	if ( !$post = $wpdb->get_row( $wpdb->prepare("SELECT * FROM $wpdb->posts WHERE ID = %d", $post_id) ) )
4862
-		return $post;
4977
+	if ( !$post = $wpdb->get_row( $wpdb->prepare("SELECT * FROM $wpdb->posts WHERE ID = %d", $post_id) ) ) {
4978
+			return $post;
4979
+	}
4863 4980
 
4864
-	if ( 'attachment' != $post->post_type )
4865
-		return false;
4981
+	if ( 'attachment' != $post->post_type ) {
4982
+			return false;
4983
+	}
4866 4984
 
4867
-	if ( !$force_delete && EMPTY_TRASH_DAYS && MEDIA_TRASH && 'trash' != $post->post_status )
4868
-		return wp_trash_post( $post_id );
4985
+	if ( !$force_delete && EMPTY_TRASH_DAYS && MEDIA_TRASH && 'trash' != $post->post_status ) {
4986
+			return wp_trash_post( $post_id );
4987
+	}
4869 4988
 
4870 4989
 	delete_post_meta($post_id, '_wp_trash_meta_status');
4871 4990
 	delete_post_meta($post_id, '_wp_trash_meta_time');
@@ -4874,8 +4993,9 @@  discard block
 block discarded – undo
4874 4993
 	$backup_sizes = get_post_meta( $post->ID, '_wp_attachment_backup_sizes', true );
4875 4994
 	$file = get_attached_file( $post_id );
4876 4995
 
4877
-	if ( is_multisite() )
4878
-		delete_transient( 'dirsize_cache' );
4996
+	if ( is_multisite() ) {
4997
+			delete_transient( 'dirsize_cache' );
4998
+	}
4879 4999
 
4880 5000
 	/**
4881 5001
 	 * Fires before an attachment is deleted, at the start of wp_delete_attachment().
@@ -4902,8 +5022,9 @@  discard block
 block discarded – undo
4902 5022
 	wp_defer_comment_counting( false );
4903 5023
 
4904 5024
 	$post_meta_ids = $wpdb->get_col( $wpdb->prepare( "SELECT meta_id FROM $wpdb->postmeta WHERE post_id = %d ", $post_id ));
4905
-	foreach ( $post_meta_ids as $mid )
4906
-		delete_metadata_by_mid( 'post', $mid );
5025
+	foreach ( $post_meta_ids as $mid ) {
5026
+			delete_metadata_by_mid( 'post', $mid );
5027
+	}
4907 5028
 
4908 5029
 	/** This action is documented in wp-includes/post.php */
4909 5030
 	do_action( 'delete_post', $post_id );
@@ -4963,13 +5084,15 @@  discard block
 block discarded – undo
4963 5084
  */
4964 5085
 function wp_get_attachment_metadata( $post_id = 0, $unfiltered = false ) {
4965 5086
 	$post_id = (int) $post_id;
4966
-	if ( !$post = get_post( $post_id ) )
4967
-		return false;
5087
+	if ( !$post = get_post( $post_id ) ) {
5088
+			return false;
5089
+	}
4968 5090
 
4969 5091
 	$data = get_post_meta( $post->ID, '_wp_attachment_metadata', true );
4970 5092
 
4971
-	if ( $unfiltered )
4972
-		return $data;
5093
+	if ( $unfiltered ) {
5094
+			return $data;
5095
+	}
4973 5096
 
4974 5097
 	/**
4975 5098
 	 * Filters the attachment meta data.
@@ -4994,8 +5117,9 @@  discard block
 block discarded – undo
4994 5117
  */
4995 5118
 function wp_update_attachment_metadata( $post_id, $data ) {
4996 5119
 	$post_id = (int) $post_id;
4997
-	if ( !$post = get_post( $post_id ) )
4998
-		return false;
5120
+	if ( !$post = get_post( $post_id ) ) {
5121
+			return false;
5122
+	}
4999 5123
 
5000 5124
 	/**
5001 5125
 	 * Filters the updated attachment meta data.
@@ -5005,11 +5129,12 @@  discard block
 block discarded – undo
5005 5129
 	 * @param array $data    Array of updated attachment meta data.
5006 5130
 	 * @param int   $post_id Attachment ID.
5007 5131
 	 */
5008
-	if ( $data = apply_filters( 'wp_update_attachment_metadata', $data, $post->ID ) )
5009
-		return update_post_meta( $post->ID, '_wp_attachment_metadata', $data );
5010
-	else
5011
-		return delete_post_meta( $post->ID, '_wp_attachment_metadata' );
5012
-}
5132
+	if ( $data = apply_filters( 'wp_update_attachment_metadata', $data, $post->ID ) ) {
5133
+			return update_post_meta( $post->ID, '_wp_attachment_metadata', $data );
5134
+	} else {
5135
+			return delete_post_meta( $post->ID, '_wp_attachment_metadata' );
5136
+	}
5137
+	}
5013 5138
 
5014 5139
 /**
5015 5140
  * Retrieve the URL for an attachment.
@@ -5023,11 +5148,13 @@  discard block
 block discarded – undo
5023 5148
  */
5024 5149
 function wp_get_attachment_url( $post_id = 0 ) {
5025 5150
 	$post_id = (int) $post_id;
5026
-	if ( !$post = get_post( $post_id ) )
5027
-		return false;
5151
+	if ( !$post = get_post( $post_id ) ) {
5152
+			return false;
5153
+	}
5028 5154
 
5029
-	if ( 'attachment' != $post->post_type )
5030
-		return false;
5155
+	if ( 'attachment' != $post->post_type ) {
5156
+			return false;
5157
+	}
5031 5158
 
5032 5159
 	$url = '';
5033 5160
 	// Get attached file.
@@ -5071,8 +5198,9 @@  discard block
 block discarded – undo
5071 5198
 	 */
5072 5199
 	$url = apply_filters( 'wp_get_attachment_url', $url, $post->ID );
5073 5200
 
5074
-	if ( empty( $url ) )
5075
-		return false;
5201
+	if ( empty( $url ) ) {
5202
+			return false;
5203
+	}
5076 5204
 
5077 5205
 	return $url;
5078 5206
 }
@@ -5118,10 +5246,12 @@  discard block
 block discarded – undo
5118 5246
  */
5119 5247
 function wp_get_attachment_thumb_file( $post_id = 0 ) {
5120 5248
 	$post_id = (int) $post_id;
5121
-	if ( !$post = get_post( $post_id ) )
5122
-		return false;
5123
-	if ( !is_array( $imagedata = wp_get_attachment_metadata( $post->ID ) ) )
5124
-		return false;
5249
+	if ( !$post = get_post( $post_id ) ) {
5250
+			return false;
5251
+	}
5252
+	if ( !is_array( $imagedata = wp_get_attachment_metadata( $post->ID ) ) ) {
5253
+			return false;
5254
+	}
5125 5255
 
5126 5256
 	$file = get_attached_file( $post->ID );
5127 5257
 
@@ -5149,17 +5279,21 @@  discard block
 block discarded – undo
5149 5279
  */
5150 5280
 function wp_get_attachment_thumb_url( $post_id = 0 ) {
5151 5281
 	$post_id = (int) $post_id;
5152
-	if ( !$post = get_post( $post_id ) )
5153
-		return false;
5154
-	if ( !$url = wp_get_attachment_url( $post->ID ) )
5155
-		return false;
5282
+	if ( !$post = get_post( $post_id ) ) {
5283
+			return false;
5284
+	}
5285
+	if ( !$url = wp_get_attachment_url( $post->ID ) ) {
5286
+			return false;
5287
+	}
5156 5288
 
5157 5289
 	$sized = image_downsize( $post_id, 'thumbnail' );
5158
-	if ( $sized )
5159
-		return $sized[0];
5290
+	if ( $sized ) {
5291
+			return $sized[0];
5292
+	}
5160 5293
 
5161
-	if ( !$thumb = wp_get_attachment_thumb_file( $post->ID ) )
5162
-		return false;
5294
+	if ( !$thumb = wp_get_attachment_thumb_file( $post->ID ) ) {
5295
+			return false;
5296
+	}
5163 5297
 
5164 5298
 	$url = str_replace(basename($url), basename($thumb), $url);
5165 5299
 
@@ -5246,8 +5380,9 @@  discard block
 block discarded – undo
5246 5380
  * @return string|false Icon, false otherwise.
5247 5381
  */
5248 5382
 function wp_mime_type_icon( $mime = 0 ) {
5249
-	if ( !is_numeric($mime) )
5250
-		$icon = wp_cache_get("mime_type_icon_$mime");
5383
+	if ( !is_numeric($mime) ) {
5384
+			$icon = wp_cache_get("mime_type_icon_$mime");
5385
+	}
5251 5386
 
5252 5387
 	$post_id = 0;
5253 5388
 	if ( empty($icon) ) {
@@ -5260,8 +5395,9 @@  discard block
 block discarded – undo
5260 5395
 				$ext = preg_replace('/^.+?\.([^.]+)$/', '$1', $file);
5261 5396
 				if ( !empty($ext) ) {
5262 5397
 					$post_mimes[] = $ext;
5263
-					if ( $ext_type = wp_ext2type( $ext ) )
5264
-						$post_mimes[] = $ext_type;
5398
+					if ( $ext_type = wp_ext2type( $ext ) ) {
5399
+											$post_mimes[] = $ext_type;
5400
+					}
5265 5401
 				}
5266 5402
 				$mime = $post->post_mime_type;
5267 5403
 			} else {
@@ -5308,11 +5444,13 @@  discard block
 block discarded – undo
5308 5444
 				if ( $dh = opendir($dir) ) {
5309 5445
 					while ( false !== $file = readdir($dh) ) {
5310 5446
 						$file = basename($file);
5311
-						if ( substr($file, 0, 1) == '.' )
5312
-							continue;
5447
+						if ( substr($file, 0, 1) == '.' ) {
5448
+													continue;
5449
+						}
5313 5450
 						if ( !in_array(strtolower(substr($file, -4)), array('.png', '.gif', '.jpg') ) ) {
5314
-							if ( is_dir("$dir/$file") )
5315
-								$dirs["$dir/$file"] = "$uri/$file";
5451
+							if ( is_dir("$dir/$file") ) {
5452
+															$dirs["$dir/$file"] = "$uri/$file";
5453
+							}
5316 5454
 							continue;
5317 5455
 						}
5318 5456
 						$icon_files["$dir/$file"] = "$uri/$file";
@@ -5325,8 +5463,9 @@  discard block
 block discarded – undo
5325 5463
 
5326 5464
 		$types = array();
5327 5465
 		// Icon basename - extension = MIME wildcard.
5328
-		foreach ( $icon_files as $file => $uri )
5329
-			$types[ preg_replace('/^([^.]*).*$/', '$1', basename($file)) ] =& $icon_files[$file];
5466
+		foreach ( $icon_files as $file => $uri ) {
5467
+					$types[ preg_replace('/^([^.]*).*$/', '$1', basename($file)) ] =& $icon_files[$file];
5468
+		}
5330 5469
 
5331 5470
 		if ( ! empty($mime) ) {
5332 5471
 			$post_mimes[] = substr($mime, 0, strpos($mime, '/'));
@@ -5664,12 +5803,14 @@  discard block
 block discarded – undo
5664 5803
  * @param array $posts Array of post objects, passed by reference.
5665 5804
  */
5666 5805
 function update_post_cache( &$posts ) {
5667
-	if ( ! $posts )
5668
-		return;
5806
+	if ( ! $posts ) {
5807
+			return;
5808
+	}
5669 5809
 
5670
-	foreach ( $posts as $post )
5671
-		wp_cache_add( $post->ID, $post, 'posts' );
5672
-}
5810
+	foreach ( $posts as $post ) {
5811
+			wp_cache_add( $post->ID, $post, 'posts' );
5812
+	}
5813
+	}
5673 5814
 
5674 5815
 /**
5675 5816
  * Will clean the post in the cache.
@@ -5689,12 +5830,14 @@  discard block
 block discarded – undo
5689 5830
 function clean_post_cache( $post ) {
5690 5831
 	global $_wp_suspend_cache_invalidation;
5691 5832
 
5692
-	if ( ! empty( $_wp_suspend_cache_invalidation ) )
5693
-		return;
5833
+	if ( ! empty( $_wp_suspend_cache_invalidation ) ) {
5834
+			return;
5835
+	}
5694 5836
 
5695 5837
 	$post = get_post( $post );
5696
-	if ( empty( $post ) )
5697
-		return;
5838
+	if ( empty( $post ) ) {
5839
+			return;
5840
+	}
5698 5841
 
5699 5842
 	wp_cache_delete( $post->ID, 'posts' );
5700 5843
 	wp_cache_delete( $post->ID, 'post_meta' );
@@ -5741,17 +5884,20 @@  discard block
 block discarded – undo
5741 5884
  */
5742 5885
 function update_post_caches( &$posts, $post_type = 'post', $update_term_cache = true, $update_meta_cache = true ) {
5743 5886
 	// No point in doing all this work if we didn't match any posts.
5744
-	if ( !$posts )
5745
-		return;
5887
+	if ( !$posts ) {
5888
+			return;
5889
+	}
5746 5890
 
5747 5891
 	update_post_cache($posts);
5748 5892
 
5749 5893
 	$post_ids = array();
5750
-	foreach ( $posts as $post )
5751
-		$post_ids[] = $post->ID;
5894
+	foreach ( $posts as $post ) {
5895
+			$post_ids[] = $post->ID;
5896
+	}
5752 5897
 
5753
-	if ( ! $post_type )
5754
-		$post_type = 'any';
5898
+	if ( ! $post_type ) {
5899
+			$post_type = 'any';
5900
+	}
5755 5901
 
5756 5902
 	if ( $update_term_cache ) {
5757 5903
 		if ( is_array($post_type) ) {
@@ -5767,13 +5913,15 @@  discard block
 block discarded – undo
5767 5913
 			$ptypes = array($post_type);
5768 5914
 		}
5769 5915
 
5770
-		if ( ! empty($ptypes) )
5771
-			update_object_term_cache($post_ids, $ptypes);
5916
+		if ( ! empty($ptypes) ) {
5917
+					update_object_term_cache($post_ids, $ptypes);
5918
+		}
5772 5919
 	}
5773 5920
 
5774
-	if ( $update_meta_cache )
5775
-		update_postmeta_cache($post_ids);
5776
-}
5921
+	if ( $update_meta_cache ) {
5922
+			update_postmeta_cache($post_ids);
5923
+	}
5924
+	}
5777 5925
 
5778 5926
 /**
5779 5927
  * Updates metadata cache for list of post IDs.
@@ -5810,16 +5958,18 @@  discard block
 block discarded – undo
5810 5958
 function clean_attachment_cache( $id, $clean_terms = false ) {
5811 5959
 	global $_wp_suspend_cache_invalidation;
5812 5960
 
5813
-	if ( !empty($_wp_suspend_cache_invalidation) )
5814
-		return;
5961
+	if ( !empty($_wp_suspend_cache_invalidation) ) {
5962
+			return;
5963
+	}
5815 5964
 
5816 5965
 	$id = (int) $id;
5817 5966
 
5818 5967
 	wp_cache_delete($id, 'posts');
5819 5968
 	wp_cache_delete($id, 'post_meta');
5820 5969
 
5821
-	if ( $clean_terms )
5822
-		clean_object_term_cache($id, 'attachment');
5970
+	if ( $clean_terms ) {
5971
+			clean_object_term_cache($id, 'attachment');
5972
+	}
5823 5973
 
5824 5974
 	/**
5825 5975
 	 * Fires after the given attachment's cache is cleaned.
@@ -5853,8 +6003,9 @@  discard block
 block discarded – undo
5853 6003
 
5854 6004
 	if ( $old_status != 'publish' && $new_status == 'publish' ) {
5855 6005
 		// Reset GUID if transitioning to publish and it is empty.
5856
-		if ( '' == get_the_guid($post->ID) )
5857
-			$wpdb->update( $wpdb->posts, array( 'guid' => get_permalink( $post->ID ) ), array( 'ID' => $post->ID ) );
6006
+		if ( '' == get_the_guid($post->ID) ) {
6007
+					$wpdb->update( $wpdb->posts, array( 'guid' => get_permalink( $post->ID ) ), array( 'ID' => $post->ID ) );
6008
+		}
5858 6009
 
5859 6010
 		/**
5860 6011
 		 * Fires when a post's status is transitioned from private to published.
@@ -5925,11 +6076,13 @@  discard block
 block discarded – undo
5925 6076
 		do_action( 'xmlrpc_publish_post', $post_id );
5926 6077
 	}
5927 6078
 
5928
-	if ( defined('WP_IMPORTING') )
5929
-		return;
6079
+	if ( defined('WP_IMPORTING') ) {
6080
+			return;
6081
+	}
5930 6082
 
5931
-	if ( get_option('default_pingback_flag') )
5932
-		add_post_meta( $post_id, '_pingme', '1' );
6083
+	if ( get_option('default_pingback_flag') ) {
6084
+			add_post_meta( $post_id, '_pingme', '1' );
6085
+	}
5933 6086
 	add_post_meta( $post_id, '_encloseme', '1' );
5934 6087
 
5935 6088
 	wp_schedule_single_event(time(), 'do_pings');
@@ -5946,8 +6099,9 @@  discard block
 block discarded – undo
5946 6099
  */
5947 6100
 function wp_get_post_parent_id( $post_ID ) {
5948 6101
 	$post = get_post( $post_ID );
5949
-	if ( !$post || is_wp_error( $post ) )
5950
-		return false;
6102
+	if ( !$post || is_wp_error( $post ) ) {
6103
+			return false;
6104
+	}
5951 6105
 	return (int) $post->post_parent;
5952 6106
 }
5953 6107
 
@@ -5967,28 +6121,35 @@  discard block
 block discarded – undo
5967 6121
  */
5968 6122
 function wp_check_post_hierarchy_for_loops( $post_parent, $post_ID ) {
5969 6123
 	// Nothing fancy here - bail.
5970
-	if ( !$post_parent )
5971
-		return 0;
6124
+	if ( !$post_parent ) {
6125
+			return 0;
6126
+	}
5972 6127
 
5973 6128
 	// New post can't cause a loop.
5974
-	if ( empty( $post_ID ) )
5975
-		return $post_parent;
6129
+	if ( empty( $post_ID ) ) {
6130
+			return $post_parent;
6131
+	}
5976 6132
 
5977 6133
 	// Can't be its own parent.
5978
-	if ( $post_parent == $post_ID )
5979
-		return 0;
6134
+	if ( $post_parent == $post_ID ) {
6135
+			return 0;
6136
+	}
5980 6137
 
5981 6138
 	// Now look for larger loops.
5982
-	if ( !$loop = wp_find_hierarchy_loop( 'wp_get_post_parent_id', $post_ID, $post_parent ) )
5983
-		return $post_parent; // No loop
6139
+	if ( !$loop = wp_find_hierarchy_loop( 'wp_get_post_parent_id', $post_ID, $post_parent ) ) {
6140
+			return $post_parent;
6141
+	}
6142
+	// No loop
5984 6143
 
5985 6144
 	// Setting $post_parent to the given value causes a loop.
5986
-	if ( isset( $loop[$post_ID] ) )
5987
-		return 0;
6145
+	if ( isset( $loop[$post_ID] ) ) {
6146
+			return 0;
6147
+	}
5988 6148
 
5989 6149
 	// There's a loop, but it doesn't contain $post_ID. Break the loop.
5990
-	foreach ( array_keys( $loop ) as $loop_member )
5991
-		wp_update_post( array( 'ID' => $loop_member, 'post_parent' => 0 ) );
6150
+	foreach ( array_keys( $loop ) as $loop_member ) {
6151
+			wp_update_post( array( 'ID' => $loop_member, 'post_parent' => 0 ) );
6152
+	}
5992 6153
 
5993 6154
 	return $post_parent;
5994 6155
 }
@@ -6006,10 +6167,11 @@  discard block
 block discarded – undo
6006 6167
 	$post = get_post( $post );
6007 6168
 	$thumbnail_id = absint( $thumbnail_id );
6008 6169
 	if ( $post && $thumbnail_id && get_post( $thumbnail_id ) ) {
6009
-		if ( wp_get_attachment_image( $thumbnail_id, 'thumbnail' ) )
6010
-			return update_post_meta( $post->ID, '_thumbnail_id', $thumbnail_id );
6011
-		else
6012
-			return delete_post_meta( $post->ID, '_thumbnail_id' );
6170
+		if ( wp_get_attachment_image( $thumbnail_id, 'thumbnail' ) ) {
6171
+					return update_post_meta( $post->ID, '_thumbnail_id', $thumbnail_id );
6172
+		} else {
6173
+					return delete_post_meta( $post->ID, '_thumbnail_id' );
6174
+		}
6013 6175
 	}
6014 6176
 	return false;
6015 6177
 }
@@ -6024,8 +6186,9 @@  discard block
 block discarded – undo
6024 6186
  */
6025 6187
 function delete_post_thumbnail( $post ) {
6026 6188
 	$post = get_post( $post );
6027
-	if ( $post )
6028
-		return delete_post_meta( $post->ID, '_thumbnail_id' );
6189
+	if ( $post ) {
6190
+			return delete_post_meta( $post->ID, '_thumbnail_id' );
6191
+	}
6029 6192
 	return false;
6030 6193
 }
6031 6194
 
Please login to merge, or discard this patch.