Completed
Push — master ( d488ab...6453e7 )
by Stephen
53:31
created
src/wp-includes/author-template.php 3 patches
Indentation   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -1,14 +1,14 @@
 block discarded – undo
1 1
 <?php
2 2
 /**
3
- * Author Template functions for use in themes.
4
- *
5
- * These functions must be used within the WordPress Loop.
6
- *
7
- * @link https://codex.wordpress.org/Author_Templates
8
- *
9
- * @package WordPress
10
- * @subpackage Template
11
- */
3
+	 * Author Template functions for use in themes.
4
+	 *
5
+	 * These functions must be used within the WordPress Loop.
6
+	 *
7
+	 * @link https://codex.wordpress.org/Author_Templates
8
+	 *
9
+	 * @package WordPress
10
+	 * @subpackage Template
11
+	 */
12 12
 
13 13
 /**
14 14
  * Retrieve the author of the current post.
Please login to merge, or discard this patch.
Spacing   +70 added lines, -70 removed lines patch added patch discarded remove patch
@@ -23,8 +23,8 @@  discard block
 block discarded – undo
23 23
 function get_the_author($deprecated = '') {
24 24
 	global $authordata;
25 25
 
26
-	if ( !empty( $deprecated ) )
27
-		_deprecated_argument( __FUNCTION__, '2.1' );
26
+	if ( ! empty($deprecated))
27
+		_deprecated_argument(__FUNCTION__, '2.1');
28 28
 
29 29
 	/**
30 30
 	 * Filter the display name of the current post's author.
@@ -55,12 +55,12 @@  discard block
 block discarded – undo
55 55
  * @param string $deprecated_echo Deprecated. Use get_the_author(). Echo the string or return it.
56 56
  * @return string|null The author's display name, from get_the_author().
57 57
  */
58
-function the_author( $deprecated = '', $deprecated_echo = true ) {
59
-	if ( !empty( $deprecated ) )
60
-		_deprecated_argument( __FUNCTION__, '2.1' );
61
-	if ( $deprecated_echo !== true )
62
-		_deprecated_argument( __FUNCTION__, '1.5', __('Use <code>get_the_author()</code> instead if you do not want the value echoed.') );
63
-	if ( $deprecated_echo )
58
+function the_author($deprecated = '', $deprecated_echo = true) {
59
+	if ( ! empty($deprecated))
60
+		_deprecated_argument(__FUNCTION__, '2.1');
61
+	if ($deprecated_echo !== true)
62
+		_deprecated_argument(__FUNCTION__, '1.5', __('Use <code>get_the_author()</code> instead if you do not want the value echoed.'));
63
+	if ($deprecated_echo)
64 64
 		echo get_the_author();
65 65
 	return get_the_author();
66 66
 }
@@ -73,7 +73,7 @@  discard block
 block discarded – undo
73 73
  * @return string|void The author's display name.
74 74
  */
75 75
 function get_the_modified_author() {
76
-	if ( $last_id = get_post_meta( get_post()->ID, '_edit_last', true) ) {
76
+	if ($last_id = get_post_meta(get_post()->ID, '_edit_last', true)) {
77 77
 		$last_user = get_userdata($last_id);
78 78
 
79 79
 		/**
@@ -110,20 +110,20 @@  discard block
 block discarded – undo
110 110
  * @param int $user_id Optional. User ID.
111 111
  * @return string The author's field from the current author's DB object.
112 112
  */
113
-function get_the_author_meta( $field = '', $user_id = false ) {
113
+function get_the_author_meta($field = '', $user_id = false) {
114 114
 	$original_user_id = $user_id;
115 115
 
116
-	if ( ! $user_id ) {
116
+	if ( ! $user_id) {
117 117
 		global $authordata;
118
-		$user_id = isset( $authordata->ID ) ? $authordata->ID : 0;
118
+		$user_id = isset($authordata->ID) ? $authordata->ID : 0;
119 119
 	} else {
120
-		$authordata = get_userdata( $user_id );
120
+		$authordata = get_userdata($user_id);
121 121
 	}
122 122
 
123
-	if ( in_array( $field, array( 'login', 'pass', 'nicename', 'email', 'url', 'registered', 'activation_key', 'status' ) ) )
124
-		$field = 'user_' . $field;
123
+	if (in_array($field, array('login', 'pass', 'nicename', 'email', 'url', 'registered', 'activation_key', 'status')))
124
+		$field = 'user_'.$field;
125 125
 
126
-	$value = isset( $authordata->$field ) ? $authordata->$field : '';
126
+	$value = isset($authordata->$field) ? $authordata->$field : '';
127 127
 
128 128
 	/**
129 129
 	 * Filter the value of the requested user metadata.
@@ -137,7 +137,7 @@  discard block
 block discarded – undo
137 137
 	 * @param int      $user_id          The user ID for the value.
138 138
 	 * @param int|bool $original_user_id The original user ID, as passed to the function.
139 139
 	 */
140
-	return apply_filters( 'get_the_author_' . $field, $value, $user_id, $original_user_id );
140
+	return apply_filters('get_the_author_'.$field, $value, $user_id, $original_user_id);
141 141
 }
142 142
 
143 143
 /**
@@ -150,8 +150,8 @@  discard block
 block discarded – undo
150 150
  * @param string $field selects the field of the users record.
151 151
  * @param int $user_id Optional. User ID.
152 152
  */
153
-function the_author_meta( $field = '', $user_id = false ) {
154
-	$author_meta = get_the_author_meta( $field, $user_id );
153
+function the_author_meta($field = '', $user_id = false) {
154
+	$author_meta = get_the_author_meta($field, $user_id);
155 155
 
156 156
 	/**
157 157
 	 * The value of the requested user metadata.
@@ -163,7 +163,7 @@  discard block
 block discarded – undo
163 163
 	 * @param string $author_meta The value of the metadata.
164 164
 	 * @param int    $user_id     The user ID.
165 165
 	 */
166
-	echo apply_filters( 'the_author_' . $field, $author_meta, $user_id );
166
+	echo apply_filters('the_author_'.$field, $author_meta, $user_id);
167 167
 }
168 168
 
169 169
 /**
@@ -176,8 +176,8 @@  discard block
 block discarded – undo
176 176
  *                     else the result of get_the_author().
177 177
  */
178 178
 function get_the_author_link() {
179
-	if ( get_the_author_meta('url') ) {
180
-		return '<a href="' . esc_url( get_the_author_meta('url') ) . '" title="' . esc_attr( sprintf(__("Visit %s&#8217;s website"), get_the_author()) ) . '" rel="author external">' . get_the_author() . '</a>';
179
+	if (get_the_author_meta('url')) {
180
+		return '<a href="'.esc_url(get_the_author_meta('url')).'" title="'.esc_attr(sprintf(__("Visit %s&#8217;s website"), get_the_author())).'" rel="author external">'.get_the_author().'</a>';
181 181
 	} else {
182 182
 		return get_the_author();
183 183
 	}
@@ -206,10 +206,10 @@  discard block
 block discarded – undo
206 206
  */
207 207
 function get_the_author_posts() {
208 208
 	$post = get_post();
209
-	if ( ! $post ) {
209
+	if ( ! $post) {
210 210
 		return 0;
211 211
 	}
212
-	return count_user_posts( $post->post_author, $post->post_type );
212
+	return count_user_posts($post->post_author, $post->post_type);
213 213
 }
214 214
 
215 215
 /**
@@ -237,18 +237,18 @@  discard block
 block discarded – undo
237 237
  * @param string $deprecated Deprecated.
238 238
  */
239 239
 function the_author_posts_link($deprecated = '') {
240
-	if ( !empty( $deprecated ) )
241
-		_deprecated_argument( __FUNCTION__, '2.1' );
240
+	if ( ! empty($deprecated))
241
+		_deprecated_argument(__FUNCTION__, '2.1');
242 242
 
243 243
 	global $authordata;
244
-	if ( ! is_object( $authordata ) ) {
244
+	if ( ! is_object($authordata)) {
245 245
 		return;
246 246
 	}
247 247
 
248 248
 	$link = sprintf(
249 249
 		'<a href="%1$s" title="%2$s" rel="author">%3$s</a>',
250
-		esc_url( get_author_posts_url( $authordata->ID, $authordata->user_nicename ) ),
251
-		esc_attr( sprintf( __( 'Posts by %s' ), get_the_author() ) ),
250
+		esc_url(get_author_posts_url($authordata->ID, $authordata->user_nicename)),
251
+		esc_attr(sprintf(__('Posts by %s'), get_the_author())),
252 252
 		get_the_author()
253 253
 	);
254 254
 
@@ -259,7 +259,7 @@  discard block
 block discarded – undo
259 259
 	 *
260 260
 	 * @param string $link HTML link.
261 261
 	 */
262
-	echo apply_filters( 'the_author_posts_link', $link );
262
+	echo apply_filters('the_author_posts_link', $link);
263 263
 }
264 264
 
265 265
 /**
@@ -276,17 +276,17 @@  discard block
 block discarded – undo
276 276
 	$auth_ID = (int) $author_id;
277 277
 	$link = $wp_rewrite->get_author_permastruct();
278 278
 
279
-	if ( empty($link) ) {
280
-		$file = home_url( '/' );
281
-		$link = $file . '?author=' . $auth_ID;
279
+	if (empty($link)) {
280
+		$file = home_url('/');
281
+		$link = $file.'?author='.$auth_ID;
282 282
 	} else {
283
-		if ( '' == $author_nicename ) {
283
+		if ('' == $author_nicename) {
284 284
 			$user = get_userdata($author_id);
285
-			if ( !empty($user->user_nicename) )
285
+			if ( ! empty($user->user_nicename))
286 286
 				$author_nicename = $user->user_nicename;
287 287
 		}
288 288
 		$link = str_replace('%author%', $author_nicename, $link);
289
-		$link = home_url( user_trailingslashit( $link ) );
289
+		$link = home_url(user_trailingslashit($link));
290 290
 	}
291 291
 
292 292
 	/**
@@ -298,7 +298,7 @@  discard block
 block discarded – undo
298 298
 	 * @param int    $author_id       The author's id.
299 299
 	 * @param string $author_nicename The author's nice name.
300 300
 	 */
301
-	$link = apply_filters( 'author_link', $link, $author_id, $author_nicename );
301
+	$link = apply_filters('author_link', $link, $author_id, $author_nicename);
302 302
 
303 303
 	return $link;
304 304
 }
@@ -338,7 +338,7 @@  discard block
 block discarded – undo
338 338
  * }
339 339
  * @return string|void The output, if echo is set to false.
340 340
  */
341
-function wp_list_authors( $args = '' ) {
341
+function wp_list_authors($args = '') {
342 342
 	global $wpdb;
343 343
 
344 344
 	$defaults = array(
@@ -349,89 +349,89 @@  discard block
 block discarded – undo
349 349
 		'style' => 'list', 'html' => true, 'exclude' => '', 'include' => ''
350 350
 	);
351 351
 
352
-	$args = wp_parse_args( $args, $defaults );
352
+	$args = wp_parse_args($args, $defaults);
353 353
 
354 354
 	$return = '';
355 355
 
356
-	$query_args = wp_array_slice_assoc( $args, array( 'orderby', 'order', 'number', 'exclude', 'include' ) );
356
+	$query_args = wp_array_slice_assoc($args, array('orderby', 'order', 'number', 'exclude', 'include'));
357 357
 	$query_args['fields'] = 'ids';
358
-	$authors = get_users( $query_args );
358
+	$authors = get_users($query_args);
359 359
 
360 360
 	$author_count = array();
361
-	foreach ( (array) $wpdb->get_results( "SELECT DISTINCT post_author, COUNT(ID) AS count FROM $wpdb->posts WHERE " . get_private_posts_cap_sql( 'post' ) . " GROUP BY post_author" ) as $row ) {
361
+	foreach ((array) $wpdb->get_results("SELECT DISTINCT post_author, COUNT(ID) AS count FROM $wpdb->posts WHERE ".get_private_posts_cap_sql('post')." GROUP BY post_author") as $row) {
362 362
 		$author_count[$row->post_author] = $row->count;
363 363
 	}
364
-	foreach ( $authors as $author_id ) {
365
-		$author = get_userdata( $author_id );
364
+	foreach ($authors as $author_id) {
365
+		$author = get_userdata($author_id);
366 366
 
367
-		if ( $args['exclude_admin'] && 'admin' == $author->display_name ) {
367
+		if ($args['exclude_admin'] && 'admin' == $author->display_name) {
368 368
 			continue;
369 369
 		}
370 370
 
371
-		$posts = isset( $author_count[$author->ID] ) ? $author_count[$author->ID] : 0;
371
+		$posts = isset($author_count[$author->ID]) ? $author_count[$author->ID] : 0;
372 372
 
373
-		if ( ! $posts && $args['hide_empty'] ) {
373
+		if ( ! $posts && $args['hide_empty']) {
374 374
 			continue;
375 375
 		}
376 376
 
377
-		if ( $args['show_fullname'] && $author->first_name && $author->last_name ) {
377
+		if ($args['show_fullname'] && $author->first_name && $author->last_name) {
378 378
 			$name = "$author->first_name $author->last_name";
379 379
 		} else {
380 380
 			$name = $author->display_name;
381 381
 		}
382 382
 
383
-		if ( ! $args['html'] ) {
384
-			$return .= $name . ', ';
383
+		if ( ! $args['html']) {
384
+			$return .= $name.', ';
385 385
 
386 386
 			continue; // No need to go further to process HTML.
387 387
 		}
388 388
 
389
-		if ( 'list' == $args['style'] ) {
389
+		if ('list' == $args['style']) {
390 390
 			$return .= '<li>';
391 391
 		}
392 392
 
393
-		$link = '<a href="' . get_author_posts_url( $author->ID, $author->user_nicename ) . '" title="' . esc_attr( sprintf(__("Posts by %s"), $author->display_name) ) . '">' . $name . '</a>';
393
+		$link = '<a href="'.get_author_posts_url($author->ID, $author->user_nicename).'" title="'.esc_attr(sprintf(__("Posts by %s"), $author->display_name)).'">'.$name.'</a>';
394 394
 
395
-		if ( ! empty( $args['feed_image'] ) || ! empty( $args['feed'] ) ) {
395
+		if ( ! empty($args['feed_image']) || ! empty($args['feed'])) {
396 396
 			$link .= ' ';
397
-			if ( empty( $args['feed_image'] ) ) {
397
+			if (empty($args['feed_image'])) {
398 398
 				$link .= '(';
399 399
 			}
400 400
 
401
-			$link .= '<a href="' . get_author_feed_link( $author->ID, $args['feed_type'] ) . '"';
401
+			$link .= '<a href="'.get_author_feed_link($author->ID, $args['feed_type']).'"';
402 402
 
403 403
 			$alt = '';
404
-			if ( ! empty( $args['feed'] ) ) {
405
-				$alt = ' alt="' . esc_attr( $args['feed'] ) . '"';
404
+			if ( ! empty($args['feed'])) {
405
+				$alt = ' alt="'.esc_attr($args['feed']).'"';
406 406
 				$name = $args['feed'];
407 407
 			}
408 408
 
409 409
 			$link .= '>';
410 410
 
411
-			if ( ! empty( $args['feed_image'] ) ) {
412
-				$link .= '<img src="' . esc_url( $args['feed_image'] ) . '" style="border: none;"' . $alt . ' />';
411
+			if ( ! empty($args['feed_image'])) {
412
+				$link .= '<img src="'.esc_url($args['feed_image']).'" style="border: none;"'.$alt.' />';
413 413
 			} else {
414 414
 				$link .= $name;
415 415
 			}
416 416
 
417 417
 			$link .= '</a>';
418 418
 
419
-			if ( empty( $args['feed_image'] ) ) {
419
+			if (empty($args['feed_image'])) {
420 420
 				$link .= ')';
421 421
 			}
422 422
 		}
423 423
 
424
-		if ( $args['optioncount'] ) {
425
-			$link .= ' ('. $posts . ')';
424
+		if ($args['optioncount']) {
425
+			$link .= ' ('.$posts.')';
426 426
 		}
427 427
 
428 428
 		$return .= $link;
429
-		$return .= ( 'list' == $args['style'] ) ? '</li>' : ', ';
429
+		$return .= ('list' == $args['style']) ? '</li>' : ', ';
430 430
 	}
431 431
 
432
-	$return = rtrim( $return, ', ' );
432
+	$return = rtrim($return, ', ');
433 433
 
434
-	if ( ! $args['echo'] ) {
434
+	if ( ! $args['echo']) {
435 435
 		return $return;
436 436
 	}
437 437
 	echo $return;
@@ -451,10 +451,10 @@  discard block
 block discarded – undo
451 451
 function is_multi_author() {
452 452
 	global $wpdb;
453 453
 
454
-	if ( false === ( $is_multi_author = get_transient( 'is_multi_author' ) ) ) {
454
+	if (false === ($is_multi_author = get_transient('is_multi_author'))) {
455 455
 		$rows = (array) $wpdb->get_col("SELECT DISTINCT post_author FROM $wpdb->posts WHERE post_type = 'post' AND post_status = 'publish' LIMIT 2");
456
-		$is_multi_author = 1 < count( $rows ) ? 1 : 0;
457
-		set_transient( 'is_multi_author', $is_multi_author );
456
+		$is_multi_author = 1 < count($rows) ? 1 : 0;
457
+		set_transient('is_multi_author', $is_multi_author);
458 458
 	}
459 459
 
460 460
 	/**
@@ -464,7 +464,7 @@  discard block
 block discarded – undo
464 464
 	 *
465 465
 	 * @param bool $is_multi_author Whether $is_multi_author should evaluate as true.
466 466
 	 */
467
-	return apply_filters( 'is_multi_author', (bool) $is_multi_author );
467
+	return apply_filters('is_multi_author', (bool) $is_multi_author);
468 468
 }
469 469
 
470 470
 /**
@@ -473,5 +473,5 @@  discard block
 block discarded – undo
473 473
  * @private
474 474
  */
475 475
 function __clear_multi_author_cache() {
476
-	delete_transient( 'is_multi_author' );
476
+	delete_transient('is_multi_author');
477 477
 }
Please login to merge, or discard this patch.
Braces   +21 added lines, -14 removed lines patch added patch discarded remove patch
@@ -23,8 +23,9 @@  discard block
 block discarded – undo
23 23
 function get_the_author($deprecated = '') {
24 24
 	global $authordata;
25 25
 
26
-	if ( !empty( $deprecated ) )
27
-		_deprecated_argument( __FUNCTION__, '2.1' );
26
+	if ( !empty( $deprecated ) ) {
27
+			_deprecated_argument( __FUNCTION__, '2.1' );
28
+	}
28 29
 
29 30
 	/**
30 31
 	 * Filter the display name of the current post's author.
@@ -56,12 +57,15 @@  discard block
 block discarded – undo
56 57
  * @return string|null The author's display name, from get_the_author().
57 58
  */
58 59
 function the_author( $deprecated = '', $deprecated_echo = true ) {
59
-	if ( !empty( $deprecated ) )
60
-		_deprecated_argument( __FUNCTION__, '2.1' );
61
-	if ( $deprecated_echo !== true )
62
-		_deprecated_argument( __FUNCTION__, '1.5', __('Use <code>get_the_author()</code> instead if you do not want the value echoed.') );
63
-	if ( $deprecated_echo )
64
-		echo get_the_author();
60
+	if ( !empty( $deprecated ) ) {
61
+			_deprecated_argument( __FUNCTION__, '2.1' );
62
+	}
63
+	if ( $deprecated_echo !== true ) {
64
+			_deprecated_argument( __FUNCTION__, '1.5', __('Use <code>get_the_author()</code> instead if you do not want the value echoed.') );
65
+	}
66
+	if ( $deprecated_echo ) {
67
+			echo get_the_author();
68
+	}
65 69
 	return get_the_author();
66 70
 }
67 71
 
@@ -120,8 +124,9 @@  discard block
 block discarded – undo
120 124
 		$authordata = get_userdata( $user_id );
121 125
 	}
122 126
 
123
-	if ( in_array( $field, array( 'login', 'pass', 'nicename', 'email', 'url', 'registered', 'activation_key', 'status' ) ) )
124
-		$field = 'user_' . $field;
127
+	if ( in_array( $field, array( 'login', 'pass', 'nicename', 'email', 'url', 'registered', 'activation_key', 'status' ) ) ) {
128
+			$field = 'user_' . $field;
129
+	}
125 130
 
126 131
 	$value = isset( $authordata->$field ) ? $authordata->$field : '';
127 132
 
@@ -237,8 +242,9 @@  discard block
 block discarded – undo
237 242
  * @param string $deprecated Deprecated.
238 243
  */
239 244
 function the_author_posts_link($deprecated = '') {
240
-	if ( !empty( $deprecated ) )
241
-		_deprecated_argument( __FUNCTION__, '2.1' );
245
+	if ( !empty( $deprecated ) ) {
246
+			_deprecated_argument( __FUNCTION__, '2.1' );
247
+	}
242 248
 
243 249
 	global $authordata;
244 250
 	if ( ! is_object( $authordata ) ) {
@@ -282,8 +288,9 @@  discard block
 block discarded – undo
282 288
 	} else {
283 289
 		if ( '' == $author_nicename ) {
284 290
 			$user = get_userdata($author_id);
285
-			if ( !empty($user->user_nicename) )
286
-				$author_nicename = $user->user_nicename;
291
+			if ( !empty($user->user_nicename) ) {
292
+							$author_nicename = $user->user_nicename;
293
+			}
287 294
 		}
288 295
 		$link = str_replace('%author%', $author_nicename, $link);
289 296
 		$link = home_url( user_trailingslashit( $link ) );
Please login to merge, or discard this patch.
src/wp-includes/rewrite.php 3 patches
Indentation   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -1,10 +1,10 @@
 block discarded – undo
1 1
 <?php
2 2
 /**
3
- * WordPress Rewrite API
4
- *
5
- * @package WordPress
6
- * @subpackage Rewrite
7
- */
3
+	 * WordPress Rewrite API
4
+	 *
5
+	 * @package WordPress
6
+	 * @subpackage Rewrite
7
+	 */
8 8
 
9 9
 /**
10 10
  * Add a straight rewrite rule.
Please login to merge, or discard this patch.
Spacing   +296 added lines, -296 removed lines patch added patch discarded remove patch
@@ -38,20 +38,20 @@  discard block
 block discarded – undo
38 38
  * @param string $regex Regular expression to substitute the tag for in rewrite rules.
39 39
  * @param string $query String to append to the rewritten query. Must end in '='. Optional.
40 40
  */
41
-function add_rewrite_tag( $tag, $regex, $query = '' ) {
41
+function add_rewrite_tag($tag, $regex, $query = '') {
42 42
 	// validate the tag's name
43
-	if ( strlen( $tag ) < 3 || $tag[0] != '%' || $tag[ strlen($tag) - 1 ] != '%' )
43
+	if (strlen($tag) < 3 || $tag[0] != '%' || $tag[strlen($tag) - 1] != '%')
44 44
 		return;
45 45
 
46 46
 	global $wp_rewrite, $wp;
47 47
 
48
-	if ( empty( $query ) ) {
49
-		$qv = trim( $tag, '%' );
50
-		$wp->add_query_var( $qv );
51
-		$query = $qv . '=';
48
+	if (empty($query)) {
49
+		$qv = trim($tag, '%');
50
+		$wp->add_query_var($qv);
51
+		$query = $qv.'=';
52 52
 	}
53 53
 
54
-	$wp_rewrite->add_rewrite_tag( $tag, $regex, $query );
54
+	$wp_rewrite->add_rewrite_tag($tag, $regex, $query);
55 55
 }
56 56
 
57 57
 /**
@@ -66,16 +66,16 @@  discard block
 block discarded – undo
66 66
  * @param array  $args   Optional configuration for building the rules from the permalink structure,
67 67
  *                       see {@link WP_Rewrite::add_permastruct()} for full details.
68 68
  */
69
-function add_permastruct( $name, $struct, $args = array() ) {
69
+function add_permastruct($name, $struct, $args = array()) {
70 70
 	global $wp_rewrite;
71 71
 
72 72
 	// backwards compatibility for the old parameters: $with_front and $ep_mask
73
-	if ( ! is_array( $args ) )
74
-		$args = array( 'with_front' => $args );
75
-	if ( func_num_args() == 4 )
76
-		$args['ep_mask'] = func_get_arg( 3 );
73
+	if ( ! is_array($args))
74
+		$args = array('with_front' => $args);
75
+	if (func_num_args() == 4)
76
+		$args['ep_mask'] = func_get_arg(3);
77 77
 
78
-	$wp_rewrite->add_permastruct( $name, $struct, $args );
78
+	$wp_rewrite->add_permastruct($name, $struct, $args);
79 79
 }
80 80
 
81 81
 /**
@@ -91,9 +91,9 @@  discard block
 block discarded – undo
91 91
  */
92 92
 function add_feed($feedname, $function) {
93 93
 	global $wp_rewrite;
94
-	if ( ! in_array($feedname, $wp_rewrite->feeds) ) //override the file if it is
94
+	if ( ! in_array($feedname, $wp_rewrite->feeds)) //override the file if it is
95 95
 		$wp_rewrite->feeds[] = $feedname;
96
-	$hook = 'do_feed_' . $feedname;
96
+	$hook = 'do_feed_'.$feedname;
97 97
 	// Remove default function hook
98 98
 	remove_action($hook, $hook);
99 99
 	add_action($hook, $function, 10, 1);
@@ -110,9 +110,9 @@  discard block
 block discarded – undo
110 110
  * @param bool $hard Whether to update .htaccess (hard flush) or just update
111 111
  * 	                 rewrite_rules transient (soft flush). Default is true (hard).
112 112
  */
113
-function flush_rewrite_rules( $hard = true ) {
113
+function flush_rewrite_rules($hard = true) {
114 114
 	global $wp_rewrite;
115
-	$wp_rewrite->flush_rules( $hard );
115
+	$wp_rewrite->flush_rules($hard);
116 116
 }
117 117
 
118 118
 /**
@@ -218,14 +218,14 @@  discard block
 block discarded – undo
218 218
  *
219 219
  * @since 3.7.0
220 220
  */
221
-define( 'EP_ALL_ARCHIVES', EP_DATE | EP_YEAR | EP_MONTH | EP_DAY | EP_CATEGORIES | EP_TAGS | EP_AUTHORS );
221
+define('EP_ALL_ARCHIVES', EP_DATE | EP_YEAR | EP_MONTH | EP_DAY | EP_CATEGORIES | EP_TAGS | EP_AUTHORS);
222 222
 
223 223
 /**
224 224
  * Endpoint Mask for everything.
225 225
  *
226 226
  * @since 2.1.0
227 227
  */
228
-define( 'EP_ALL', EP_PERMALINK | EP_ATTACHMENT | EP_ROOT | EP_COMMENTS | EP_SEARCH | EP_PAGES | EP_ALL_ARCHIVES );
228
+define('EP_ALL', EP_PERMALINK | EP_ATTACHMENT | EP_ROOT | EP_COMMENTS | EP_SEARCH | EP_PAGES | EP_ALL_ARCHIVES);
229 229
 
230 230
 /**
231 231
  * Add an endpoint, like /trackback/.
@@ -259,9 +259,9 @@  discard block
 block discarded – undo
259 259
  * @param string|bool $query_var Name of the corresponding query variable. Pass `false` to skip registering a query_var
260 260
  *                               for this endpoint. Defaults to the value of `$name`.
261 261
  */
262
-function add_rewrite_endpoint( $name, $places, $query_var = true ) {
262
+function add_rewrite_endpoint($name, $places, $query_var = true) {
263 263
 	global $wp_rewrite;
264
-	$wp_rewrite->add_endpoint( $name, $places, $query_var );
264
+	$wp_rewrite->add_endpoint($name, $places, $query_var);
265 265
 }
266 266
 
267 267
 /**
@@ -275,10 +275,10 @@  discard block
 block discarded – undo
275 275
  * @param string $base The taxonomy base that we're going to filter
276 276
  * @return string
277 277
  */
278
-function _wp_filter_taxonomy_base( $base ) {
279
-	if ( !empty( $base ) ) {
280
-		$base = preg_replace( '|^/index\.php/|', '', $base );
281
-		$base = trim( $base, '/' );
278
+function _wp_filter_taxonomy_base($base) {
279
+	if ( ! empty($base)) {
280
+		$base = preg_replace('|^/index\.php/|', '', $base);
281
+		$base = trim($base, '/');
282 282
 	}
283 283
 	return $base;
284 284
 }
@@ -305,16 +305,16 @@  discard block
 block discarded – undo
305 305
  *                          WP::parse_request(). Default empty array.
306 306
  * @return array Returns the original array of query vars, with date/post conflicts resolved.
307 307
  */
308
-function wp_resolve_numeric_slug_conflicts( $query_vars = array() ) {
309
-	if ( ! isset( $query_vars['year'] ) && ! isset( $query_vars['monthnum'] ) && ! isset( $query_vars['day'] ) ) {
308
+function wp_resolve_numeric_slug_conflicts($query_vars = array()) {
309
+	if ( ! isset($query_vars['year']) && ! isset($query_vars['monthnum']) && ! isset($query_vars['day'])) {
310 310
 		return $query_vars;
311 311
 	}
312 312
 
313 313
 	// Identify the 'postname' position in the permastruct array.
314
-	$permastructs   = array_values( array_filter( explode( '/', get_option( 'permalink_structure' ) ) ) );
315
-	$postname_index = array_search( '%postname%', $permastructs );
314
+	$permastructs   = array_values(array_filter(explode('/', get_option('permalink_structure'))));
315
+	$postname_index = array_search('%postname%', $permastructs);
316 316
 
317
-	if ( false === $postname_index ) {
317
+	if (false === $postname_index) {
318 318
 		return $query_vars;
319 319
 	}
320 320
 
@@ -325,35 +325,35 @@  discard block
 block discarded – undo
325 325
 	 * for month-slug clashes when `is_month` *or* `is_day`.
326 326
 	 */
327 327
 	$compare = '';
328
-	if ( 0 === $postname_index && ( isset( $query_vars['year'] ) || isset( $query_vars['monthnum'] ) ) ) {
328
+	if (0 === $postname_index && (isset($query_vars['year']) || isset($query_vars['monthnum']))) {
329 329
 		$compare = 'year';
330
-	} elseif ( '%year%' === $permastructs[ $postname_index - 1 ] && ( isset( $query_vars['monthnum'] ) || isset( $query_vars['day'] ) ) ) {
330
+	} elseif ('%year%' === $permastructs[$postname_index - 1] && (isset($query_vars['monthnum']) || isset($query_vars['day']))) {
331 331
 		$compare = 'monthnum';
332
-	} elseif ( '%monthnum%' === $permastructs[ $postname_index - 1 ] && isset( $query_vars['day'] ) ) {
332
+	} elseif ('%monthnum%' === $permastructs[$postname_index - 1] && isset($query_vars['day'])) {
333 333
 		$compare = 'day';
334 334
 	}
335 335
 
336
-	if ( ! $compare ) {
336
+	if ( ! $compare) {
337 337
 		return $query_vars;
338 338
 	}
339 339
 
340 340
 	// This is the potentially clashing slug.
341
-	$value = $query_vars[ $compare ];
341
+	$value = $query_vars[$compare];
342 342
 
343
-	$post = get_page_by_path( $value, OBJECT, 'post' );
344
-	if ( ! ( $post instanceof WP_Post ) ) {
343
+	$post = get_page_by_path($value, OBJECT, 'post');
344
+	if ( ! ($post instanceof WP_Post)) {
345 345
 		return $query_vars;
346 346
 	}
347 347
 
348 348
 	// If the date of the post doesn't match the date specified in the URL, resolve to the date archive.
349
-	if ( preg_match( '/^([0-9]{4})\-([0-9]{2})/', $post->post_date, $matches ) && isset( $query_vars['year'] ) && ( 'monthnum' === $compare || 'day' === $compare ) ) {
349
+	if (preg_match('/^([0-9]{4})\-([0-9]{2})/', $post->post_date, $matches) && isset($query_vars['year']) && ('monthnum' === $compare || 'day' === $compare)) {
350 350
 		// $matches[1] is the year the post was published.
351
-		if ( intval( $query_vars['year'] ) !== intval( $matches[1] ) ) {
351
+		if (intval($query_vars['year']) !== intval($matches[1])) {
352 352
 			return $query_vars;
353 353
 		}
354 354
 
355 355
 		// $matches[2] is the month the post was published.
356
-		if ( 'day' === $compare && isset( $query_vars['monthnum'] ) && intval( $query_vars['monthnum'] ) !== intval( $matches[2] ) ) {
356
+		if ('day' === $compare && isset($query_vars['monthnum']) && intval($query_vars['monthnum']) !== intval($matches[2])) {
357 357
 			return $query_vars;
358 358
 		}
359 359
 	}
@@ -363,33 +363,33 @@  discard block
 block discarded – undo
363 363
 	 * intended as the page number. Verify that it's a valid page before resolving to it.
364 364
 	 */
365 365
 	$maybe_page = '';
366
-	if ( 'year' === $compare && isset( $query_vars['monthnum'] ) ) {
366
+	if ('year' === $compare && isset($query_vars['monthnum'])) {
367 367
 		$maybe_page = $query_vars['monthnum'];
368
-	} elseif ( 'monthnum' === $compare && isset( $query_vars['day'] ) ) {
368
+	} elseif ('monthnum' === $compare && isset($query_vars['day'])) {
369 369
 		$maybe_page = $query_vars['day'];
370 370
 	}
371 371
 
372
-	$post_page_count = substr_count( $post->post_content, '<!--nextpage-->' ) + 1;
372
+	$post_page_count = substr_count($post->post_content, '<!--nextpage-->') + 1;
373 373
 
374 374
 	// If the post doesn't have multiple pages, but a 'page' candidate is found, resolve to the date archive.
375
-	if ( 1 === $post_page_count && $maybe_page ) {
375
+	if (1 === $post_page_count && $maybe_page) {
376 376
 		return $query_vars;
377 377
 	}
378 378
 
379 379
 	// If the post has multiple pages and the 'page' number isn't valid, resolve to the date archive.
380
-	if ( $post_page_count > 1 && $maybe_page > $post_page_count ) {
380
+	if ($post_page_count > 1 && $maybe_page > $post_page_count) {
381 381
 		return $query_vars;
382 382
 	}
383 383
 
384 384
 	// If we've gotten to this point, we have a slug/date clash. First, adjust for nextpage.
385
-	if ( '' !== $maybe_page ) {
386
-		$query_vars['page'] = intval( $maybe_page );
385
+	if ('' !== $maybe_page) {
386
+		$query_vars['page'] = intval($maybe_page);
387 387
 	}
388 388
 
389 389
 	// Next, unset autodetected date-related query vars.
390
-	unset( $query_vars['year'] );
391
-	unset( $query_vars['monthnum'] );
392
-	unset( $query_vars['day'] );
390
+	unset($query_vars['year']);
391
+	unset($query_vars['monthnum']);
392
+	unset($query_vars['day']);
393 393
 
394 394
 	// Then, set the identified post.
395 395
 	$query_vars['name'] = $post->post_name;
@@ -411,7 +411,7 @@  discard block
 block discarded – undo
411 411
  * @param string $url Permalink to check.
412 412
  * @return int Post ID, or 0 on failure.
413 413
  */
414
-function url_to_postid( $url ) {
414
+function url_to_postid($url) {
415 415
 	global $wp_rewrite;
416 416
 
417 417
 	/**
@@ -421,12 +421,12 @@  discard block
 block discarded – undo
421 421
 	 *
422 422
 	 * @param string $url The URL to derive the post ID from.
423 423
 	 */
424
-	$url = apply_filters( 'url_to_postid', $url );
424
+	$url = apply_filters('url_to_postid', $url);
425 425
 
426 426
 	// First, check to see if there is a 'p=N' or 'page_id=N' to match against
427
-	if ( preg_match('#[?&](p|page_id|attachment_id)=(\d+)#', $url, $values) )	{
427
+	if (preg_match('#[?&](p|page_id|attachment_id)=(\d+)#', $url, $values)) {
428 428
 		$id = absint($values[2]);
429
-		if ( $id )
429
+		if ($id)
430 430
 			return $id;
431 431
 	}
432 432
 
@@ -434,7 +434,7 @@  discard block
 block discarded – undo
434 434
 	$rewrite = $wp_rewrite->wp_rewrite_rules();
435 435
 
436 436
 	// Not using rewrite rules, and 'p=N' and 'page_id=N' methods failed, so we're out of options
437
-	if ( empty($rewrite) )
437
+	if (empty($rewrite))
438 438
 		return 0;
439 439
 
440 440
 	// Get rid of the #anchor
@@ -446,25 +446,25 @@  discard block
 block discarded – undo
446 446
 	$url = $url_split[0];
447 447
 
448 448
 	// Add 'www.' if it is absent and should be there
449
-	if ( false !== strpos(home_url(), '://www.') && false === strpos($url, '://www.') )
449
+	if (false !== strpos(home_url(), '://www.') && false === strpos($url, '://www.'))
450 450
 		$url = str_replace('://', '://www.', $url);
451 451
 
452 452
 	// Strip 'www.' if it is present and shouldn't be
453
-	if ( false === strpos(home_url(), '://www.') )
453
+	if (false === strpos(home_url(), '://www.'))
454 454
 		$url = str_replace('://www.', '://', $url);
455 455
 
456 456
 	// Strip 'index.php/' if we're not using path info permalinks
457
-	if ( !$wp_rewrite->using_index_permalinks() )
458
-		$url = str_replace( $wp_rewrite->index . '/', '', $url );
457
+	if ( ! $wp_rewrite->using_index_permalinks())
458
+		$url = str_replace($wp_rewrite->index.'/', '', $url);
459 459
 
460
-	if ( false !== strpos( trailingslashit( $url ), home_url( '/' ) ) ) {
460
+	if (false !== strpos(trailingslashit($url), home_url('/'))) {
461 461
 		// Chop off http://domain.com/[path]
462 462
 		$url = str_replace(home_url(), '', $url);
463 463
 	} else {
464 464
 		// Chop off /path/to/blog
465
-		$home_path = parse_url( home_url( '/' ) );
466
-		$home_path = isset( $home_path['path'] ) ? $home_path['path'] : '' ;
467
-		$url = preg_replace( sprintf( '#^%s#', preg_quote( $home_path ) ), '', trailingslashit( $url ) );
465
+		$home_path = parse_url(home_url('/'));
466
+		$home_path = isset($home_path['path']) ? $home_path['path'] : '';
467
+		$url = preg_replace(sprintf('#^%s#', preg_quote($home_path)), '', trailingslashit($url));
468 468
 	}
469 469
 
470 470
 	// Trim leading and lagging slashes
@@ -473,25 +473,25 @@  discard block
 block discarded – undo
473 473
 	$request = $url;
474 474
 	$post_type_query_vars = array();
475 475
 
476
-	foreach ( get_post_types( array() , 'objects' ) as $post_type => $t ) {
477
-		if ( ! empty( $t->query_var ) )
478
-			$post_type_query_vars[ $t->query_var ] = $post_type;
476
+	foreach (get_post_types(array(), 'objects') as $post_type => $t) {
477
+		if ( ! empty($t->query_var))
478
+			$post_type_query_vars[$t->query_var] = $post_type;
479 479
 	}
480 480
 
481 481
 	// Look for matches.
482 482
 	$request_match = $request;
483
-	foreach ( (array)$rewrite as $match => $query) {
483
+	foreach ((array) $rewrite as $match => $query) {
484 484
 
485 485
 		// If the requesting file is the anchor of the match, prepend it
486 486
 		// to the path info.
487
-		if ( !empty($url) && ($url != $request) && (strpos($match, $url) === 0) )
488
-			$request_match = $url . '/' . $request;
487
+		if ( ! empty($url) && ($url != $request) && (strpos($match, $url) === 0))
488
+			$request_match = $url.'/'.$request;
489 489
 
490
-		if ( preg_match("#^$match#", $request_match, $matches) ) {
490
+		if (preg_match("#^$match#", $request_match, $matches)) {
491 491
 
492
-			if ( $wp_rewrite->use_verbose_page_rules && preg_match( '/pagename=\$matches\[([0-9]+)\]/', $query, $varmatch ) ) {
492
+			if ($wp_rewrite->use_verbose_page_rules && preg_match('/pagename=\$matches\[([0-9]+)\]/', $query, $varmatch)) {
493 493
 				// This is a verbose page match, let's check to be sure about it.
494
-				if ( ! get_page_by_path( $matches[ $varmatch[1] ] ) )
494
+				if ( ! get_page_by_path($matches[$varmatch[1]]))
495 495
 					continue;
496 496
 			}
497 497
 
@@ -504,12 +504,12 @@  discard block
 block discarded – undo
504 504
 
505 505
 			// Filter out non-public query vars
506 506
 			global $wp;
507
-			parse_str( $query, $query_vars );
507
+			parse_str($query, $query_vars);
508 508
 			$query = array();
509
-			foreach ( (array) $query_vars as $key => $value ) {
510
-				if ( in_array( $key, $wp->public_query_vars ) ){
509
+			foreach ((array) $query_vars as $key => $value) {
510
+				if (in_array($key, $wp->public_query_vars)) {
511 511
 					$query[$key] = $value;
512
-					if ( isset( $post_type_query_vars[$key] ) ) {
512
+					if (isset($post_type_query_vars[$key])) {
513 513
 						$query['post_type'] = $post_type_query_vars[$key];
514 514
 						$query['name'] = $value;
515 515
 					}
@@ -517,11 +517,11 @@  discard block
 block discarded – undo
517 517
 			}
518 518
 
519 519
 			// Resolve conflicts between posts with numeric slugs and date archive queries.
520
-			$query = wp_resolve_numeric_slug_conflicts( $query );
520
+			$query = wp_resolve_numeric_slug_conflicts($query);
521 521
 
522 522
 			// Do the query
523
-			$query = new WP_Query( $query );
524
-			if ( ! empty( $query->posts ) && $query->is_singular )
523
+			$query = new WP_Query($query);
524
+			if ( ! empty($query->posts) && $query->is_singular)
525 525
 				return $query->post->ID;
526 526
 			else
527 527
 				return 0;
@@ -882,7 +882,7 @@  discard block
 block discarded – undo
882 882
 	 * @since 1.5.0
883 883
 	 * @var array
884 884
 	 */
885
-	public $feeds = array( 'feed', 'rdf', 'rss', 'rss2', 'atom' );
885
+	public $feeds = array('feed', 'rdf', 'rss', 'rss2', 'atom');
886 886
 
887 887
 	/**
888 888
 	 * Whether permalinks are being used.
@@ -909,11 +909,11 @@  discard block
 block discarded – undo
909 909
 	 * @return bool
910 910
 	 */
911 911
 	public function using_index_permalinks() {
912
-		if ( empty( $this->permalink_structure ) ) {
912
+		if (empty($this->permalink_structure)) {
913 913
 			return false;
914 914
 		}
915 915
 		// If the index is not in the permalink, we're using mod_rewrite.
916
-		return preg_match( '#^/*' . $this->index . '#', $this->permalink_structure );
916
+		return preg_match('#^/*'.$this->index.'#', $this->permalink_structure);
917 917
 	}
918 918
 
919 919
 	/**
@@ -950,8 +950,8 @@  discard block
 block discarded – undo
950 950
 		$match_prefix = '$';
951 951
 		$match_suffix = '';
952 952
 
953
-		if ( ! empty($this->matches) ) {
954
-			$match_prefix = '$' . $this->matches . '[';
953
+		if ( ! empty($this->matches)) {
954
+			$match_prefix = '$'.$this->matches.'[';
955 955
 			$match_suffix = ']';
956 956
 		}
957 957
 
@@ -976,11 +976,11 @@  discard block
 block discarded – undo
976 976
 
977 977
 		//get pages in order of hierarchy, i.e. children after parents
978 978
 		$pages = $wpdb->get_results("SELECT ID, post_name, post_parent FROM $wpdb->posts WHERE post_type = 'page' AND post_status != 'auto-draft'");
979
-		$posts = get_page_hierarchy( $pages );
979
+		$posts = get_page_hierarchy($pages);
980 980
 
981 981
 		// If we have no pages get out quick
982
-		if ( !$posts )
983
-			return array( array(), array() );
982
+		if ( ! $posts)
983
+			return array(array(), array());
984 984
 
985 985
 		//now reverse it, because we need parents after children for rewrite rules to work properly
986 986
 		$posts = array_reverse($posts, true);
@@ -988,12 +988,12 @@  discard block
 block discarded – undo
988 988
 		$page_uris = array();
989 989
 		$page_attachment_uris = array();
990 990
 
991
-		foreach ( $posts as $id => $post ) {
991
+		foreach ($posts as $id => $post) {
992 992
 			// URL => page name
993 993
 			$uri = get_page_uri($id);
994
-			$attachments = $wpdb->get_results( $wpdb->prepare( "SELECT ID, post_name, post_parent FROM $wpdb->posts WHERE post_type = 'attachment' AND post_parent = %d", $id ));
995
-			if ( !empty($attachments) ) {
996
-				foreach ( $attachments as $attachment ) {
994
+			$attachments = $wpdb->get_results($wpdb->prepare("SELECT ID, post_name, post_parent FROM $wpdb->posts WHERE post_type = 'attachment' AND post_parent = %d", $id));
995
+			if ( ! empty($attachments)) {
996
+				foreach ($attachments as $attachment) {
997 997
 					$attach_uri = get_page_uri($attachment->ID);
998 998
 					$page_attachment_uris[$attach_uri] = $attachment->ID;
999 999
 				}
@@ -1002,7 +1002,7 @@  discard block
 block discarded – undo
1002 1002
 			$page_uris[$uri] = $id;
1003 1003
 		}
1004 1004
 
1005
-		return array( $page_uris, $page_attachment_uris );
1005
+		return array($page_uris, $page_attachment_uris);
1006 1006
 	}
1007 1007
 
1008 1008
 	/**
@@ -1015,9 +1015,9 @@  discard block
 block discarded – undo
1015 1015
 	 */
1016 1016
 	public function page_rewrite_rules() {
1017 1017
 		// the extra .? at the beginning prevents clashes with other regular expressions in the rules array
1018
-		$this->add_rewrite_tag( '%pagename%', '(.?.+?)', 'pagename=' );
1018
+		$this->add_rewrite_tag('%pagename%', '(.?.+?)', 'pagename=');
1019 1019
 
1020
-		return $this->generate_rewrite_rules( $this->get_page_permastruct(), EP_PAGES, true, true, false, false );
1020
+		return $this->generate_rewrite_rules($this->get_page_permastruct(), EP_PAGES, true, true, false, false);
1021 1021
 	}
1022 1022
 
1023 1023
 	/**
@@ -1041,10 +1041,10 @@  discard block
 block discarded – undo
1041 1041
 	 * @return string|false False on no permalink structure. Date permalink structure.
1042 1042
 	 */
1043 1043
 	public function get_date_permastruct() {
1044
-		if ( isset($this->date_structure) )
1044
+		if (isset($this->date_structure))
1045 1045
 			return $this->date_structure;
1046 1046
 
1047
-		if ( empty($this->permalink_structure) ) {
1047
+		if (empty($this->permalink_structure)) {
1048 1048
 			$this->date_structure = '';
1049 1049
 			return false;
1050 1050
 		}
@@ -1055,14 +1055,14 @@  discard block
 block discarded – undo
1055 1055
 		$this->date_structure = '';
1056 1056
 		$date_endian = '';
1057 1057
 
1058
-		foreach ( $endians as $endian ) {
1059
-			if ( false !== strpos($this->permalink_structure, $endian) ) {
1060
-				$date_endian= $endian;
1058
+		foreach ($endians as $endian) {
1059
+			if (false !== strpos($this->permalink_structure, $endian)) {
1060
+				$date_endian = $endian;
1061 1061
 				break;
1062 1062
 			}
1063 1063
 		}
1064 1064
 
1065
-		if ( empty($date_endian) )
1065
+		if (empty($date_endian))
1066 1066
 			$date_endian = '%year%/%monthnum%/%day%';
1067 1067
 
1068 1068
 		// Do not allow the date tags and %post_id% to overlap in the permalink
@@ -1070,15 +1070,15 @@  discard block
 block discarded – undo
1070 1070
 		$front = $this->front;
1071 1071
 		preg_match_all('/%.+?%/', $this->permalink_structure, $tokens);
1072 1072
 		$tok_index = 1;
1073
-		foreach ( (array) $tokens[0] as $token) {
1074
-			if ( '%post_id%' == $token && ($tok_index <= 3) ) {
1075
-				$front = $front . 'date/';
1073
+		foreach ((array) $tokens[0] as $token) {
1074
+			if ('%post_id%' == $token && ($tok_index <= 3)) {
1075
+				$front = $front.'date/';
1076 1076
 				break;
1077 1077
 			}
1078 1078
 			$tok_index++;
1079 1079
 		}
1080 1080
 
1081
-		$this->date_structure = $front . $date_endian;
1081
+		$this->date_structure = $front.$date_endian;
1082 1082
 
1083 1083
 		return $this->date_structure;
1084 1084
 	}
@@ -1097,7 +1097,7 @@  discard block
 block discarded – undo
1097 1097
 	public function get_year_permastruct() {
1098 1098
 		$structure = $this->get_date_permastruct();
1099 1099
 
1100
-		if ( empty($structure) )
1100
+		if (empty($structure))
1101 1101
 			return false;
1102 1102
 
1103 1103
 		$structure = str_replace('%monthnum%', '', $structure);
@@ -1121,7 +1121,7 @@  discard block
 block discarded – undo
1121 1121
 	public function get_month_permastruct() {
1122 1122
 		$structure = $this->get_date_permastruct();
1123 1123
 
1124
-		if ( empty($structure) )
1124
+		if (empty($structure))
1125 1125
 			return false;
1126 1126
 
1127 1127
 		$structure = str_replace('%day%', '', $structure);
@@ -1188,10 +1188,10 @@  discard block
 block discarded – undo
1188 1188
 	 * @return string|false False if not found. Permalink structure string.
1189 1189
 	 */
1190 1190
 	public function get_extra_permastruct($name) {
1191
-		if ( empty($this->permalink_structure) )
1191
+		if (empty($this->permalink_structure))
1192 1192
 			return false;
1193 1193
 
1194
-		if ( isset($this->extra_permastructs[$name]) )
1194
+		if (isset($this->extra_permastructs[$name]))
1195 1195
 			return $this->extra_permastructs[$name]['struct'];
1196 1196
 
1197 1197
 		return false;
@@ -1210,15 +1210,15 @@  discard block
 block discarded – undo
1210 1210
 	 * @return string|false False if not found. Permalink structure string.
1211 1211
 	 */
1212 1212
 	public function get_author_permastruct() {
1213
-		if ( isset($this->author_structure) )
1213
+		if (isset($this->author_structure))
1214 1214
 			return $this->author_structure;
1215 1215
 
1216
-		if ( empty($this->permalink_structure) ) {
1216
+		if (empty($this->permalink_structure)) {
1217 1217
 			$this->author_structure = '';
1218 1218
 			return false;
1219 1219
 		}
1220 1220
 
1221
-		$this->author_structure = $this->front . $this->author_base . '/%author%';
1221
+		$this->author_structure = $this->front.$this->author_base.'/%author%';
1222 1222
 
1223 1223
 		return $this->author_structure;
1224 1224
 	}
@@ -1236,15 +1236,15 @@  discard block
 block discarded – undo
1236 1236
 	 * @return string|false False if not found. Permalink structure string.
1237 1237
 	 */
1238 1238
 	public function get_search_permastruct() {
1239
-		if ( isset($this->search_structure) )
1239
+		if (isset($this->search_structure))
1240 1240
 			return $this->search_structure;
1241 1241
 
1242
-		if ( empty($this->permalink_structure) ) {
1242
+		if (empty($this->permalink_structure)) {
1243 1243
 			$this->search_structure = '';
1244 1244
 			return false;
1245 1245
 		}
1246 1246
 
1247
-		$this->search_structure = $this->root . $this->search_base . '/%search%';
1247
+		$this->search_structure = $this->root.$this->search_base.'/%search%';
1248 1248
 
1249 1249
 		return $this->search_structure;
1250 1250
 	}
@@ -1262,7 +1262,7 @@  discard block
 block discarded – undo
1262 1262
 	 * @return string|false False if not found. Permalink structure string.
1263 1263
 	 */
1264 1264
 	public function get_page_permastruct() {
1265
-		if ( isset($this->page_structure) )
1265
+		if (isset($this->page_structure))
1266 1266
 			return $this->page_structure;
1267 1267
 
1268 1268
 		if (empty($this->permalink_structure)) {
@@ -1270,7 +1270,7 @@  discard block
 block discarded – undo
1270 1270
 			return false;
1271 1271
 		}
1272 1272
 
1273
-		$this->page_structure = $this->root . '%pagename%';
1273
+		$this->page_structure = $this->root.'%pagename%';
1274 1274
 
1275 1275
 		return $this->page_structure;
1276 1276
 	}
@@ -1288,15 +1288,15 @@  discard block
 block discarded – undo
1288 1288
 	 * @return string|false False if not found. Permalink structure string.
1289 1289
 	 */
1290 1290
 	public function get_feed_permastruct() {
1291
-		if ( isset($this->feed_structure) )
1291
+		if (isset($this->feed_structure))
1292 1292
 			return $this->feed_structure;
1293 1293
 
1294
-		if ( empty($this->permalink_structure) ) {
1294
+		if (empty($this->permalink_structure)) {
1295 1295
 			$this->feed_structure = '';
1296 1296
 			return false;
1297 1297
 		}
1298 1298
 
1299
-		$this->feed_structure = $this->root . $this->feed_base . '/%feed%';
1299
+		$this->feed_structure = $this->root.$this->feed_base.'/%feed%';
1300 1300
 
1301 1301
 		return $this->feed_structure;
1302 1302
 	}
@@ -1314,7 +1314,7 @@  discard block
 block discarded – undo
1314 1314
 	 * @return string|false False if not found. Permalink structure string.
1315 1315
 	 */
1316 1316
 	public function get_comment_feed_permastruct() {
1317
-		if ( isset($this->comment_feed_structure) )
1317
+		if (isset($this->comment_feed_structure))
1318 1318
 			return $this->comment_feed_structure;
1319 1319
 
1320 1320
 		if (empty($this->permalink_structure)) {
@@ -1322,7 +1322,7 @@  discard block
 block discarded – undo
1322 1322
 			return false;
1323 1323
 		}
1324 1324
 
1325
-		$this->comment_feed_structure = $this->root . $this->comments_base . '/' . $this->feed_base . '/%feed%';
1325
+		$this->comment_feed_structure = $this->root.$this->comments_base.'/'.$this->feed_base.'/%feed%';
1326 1326
 
1327 1327
 		return $this->comment_feed_structure;
1328 1328
 	}
@@ -1343,11 +1343,11 @@  discard block
 block discarded – undo
1343 1343
 	 * @param string $regex Regular expression to substitute the tag for in rewrite rules.
1344 1344
 	 * @param string $query String to append to the rewritten query. Must end in '='.
1345 1345
 	 */
1346
-	public function add_rewrite_tag( $tag, $regex, $query ) {
1347
-		$position = array_search( $tag, $this->rewritecode );
1348
-		if ( false !== $position && null !== $position ) {
1349
-			$this->rewritereplace[ $position ] = $regex;
1350
-			$this->queryreplace[ $position ] = $query;
1346
+	public function add_rewrite_tag($tag, $regex, $query) {
1347
+		$position = array_search($tag, $this->rewritecode);
1348
+		if (false !== $position && null !== $position) {
1349
+			$this->rewritereplace[$position] = $regex;
1350
+			$this->queryreplace[$position] = $query;
1351 1351
 		} else {
1352 1352
 			$this->rewritecode[] = $tag;
1353 1353
 			$this->rewritereplace[] = $regex;
@@ -1378,28 +1378,28 @@  discard block
 block discarded – undo
1378 1378
 	public function generate_rewrite_rules($permalink_structure, $ep_mask = EP_NONE, $paged = true, $feed = true, $forcomments = false, $walk_dirs = true, $endpoints = true) {
1379 1379
 		//build a regex to match the feed section of URLs, something like (feed|atom|rss|rss2)/?
1380 1380
 		$feedregex2 = '';
1381
-		foreach ( (array) $this->feeds as $feed_name)
1382
-			$feedregex2 .= $feed_name . '|';
1383
-		$feedregex2 = '(' . trim($feedregex2, '|') . ')/?$';
1381
+		foreach ((array) $this->feeds as $feed_name)
1382
+			$feedregex2 .= $feed_name.'|';
1383
+		$feedregex2 = '('.trim($feedregex2, '|').')/?$';
1384 1384
 
1385 1385
 		//$feedregex is identical but with /feed/ added on as well, so URLs like <permalink>/feed/atom
1386 1386
 		//and <permalink>/atom are both possible
1387
-		$feedregex = $this->feed_base . '/' . $feedregex2;
1387
+		$feedregex = $this->feed_base.'/'.$feedregex2;
1388 1388
 
1389 1389
 		//build a regex to match the trackback and page/xx parts of URLs
1390 1390
 		$trackbackregex = 'trackback/?$';
1391
-		$pageregex = $this->pagination_base . '/?([0-9]{1,})/?$';
1392
-		$commentregex = $this->comments_pagination_base . '-([0-9]{1,})/?$';
1391
+		$pageregex = $this->pagination_base.'/?([0-9]{1,})/?$';
1392
+		$commentregex = $this->comments_pagination_base.'-([0-9]{1,})/?$';
1393 1393
 
1394 1394
 		//build up an array of endpoint regexes to append => queries to append
1395
-		if ( $endpoints ) {
1396
-			$ep_query_append = array ();
1397
-			foreach ( (array) $this->endpoints as $endpoint) {
1395
+		if ($endpoints) {
1396
+			$ep_query_append = array();
1397
+			foreach ((array) $this->endpoints as $endpoint) {
1398 1398
 				//match everything after the endpoint name, but allow for nothing to appear there
1399
-				$epmatch = $endpoint[1] . '(/(.*))?/?$';
1399
+				$epmatch = $endpoint[1].'(/(.*))?/?$';
1400 1400
 				//this will be appended on to the rest of the query for each dir
1401
-				$epquery = '&' . $endpoint[2] . '=';
1402
-				$ep_query_append[$epmatch] = array ( $endpoint[0], $epquery );
1401
+				$epquery = '&'.$endpoint[2].'=';
1402
+				$ep_query_append[$epmatch] = array($endpoint[0], $epquery);
1403 1403
 			}
1404 1404
 		}
1405 1405
 
@@ -1416,26 +1416,26 @@  discard block
 block discarded – undo
1416 1416
 		//build a list from the rewritecode and queryreplace arrays, that will look something like
1417 1417
 		//tagname=$matches[i] where i is the current $i
1418 1418
 		$queries = array();
1419
-		for ( $i = 0; $i < $num_tokens; ++$i ) {
1420
-			if ( 0 < $i )
1421
-				$queries[$i] = $queries[$i - 1] . '&';
1419
+		for ($i = 0; $i < $num_tokens; ++$i) {
1420
+			if (0 < $i)
1421
+				$queries[$i] = $queries[$i - 1].'&';
1422 1422
 			else
1423 1423
 				$queries[$i] = '';
1424 1424
 
1425
-			$query_token = str_replace($this->rewritecode, $this->queryreplace, $tokens[0][$i]) . $this->preg_index($i+1);
1425
+			$query_token = str_replace($this->rewritecode, $this->queryreplace, $tokens[0][$i]).$this->preg_index($i + 1);
1426 1426
 			$queries[$i] .= $query_token;
1427 1427
 		}
1428 1428
 
1429 1429
 		//get the structure, minus any cruft (stuff that isn't tags) at the front
1430 1430
 		$structure = $permalink_structure;
1431
-		if ( $front != '/' )
1431
+		if ($front != '/')
1432 1432
 			$structure = str_replace($front, '', $structure);
1433 1433
 
1434 1434
 		//create a list of dirs to walk over, making rewrite rules for each level
1435 1435
 		//so for example, a $structure of /%year%/%monthnum%/%postname% would create
1436 1436
 		//rewrite rules for /%year%/, /%year%/%monthnum%/ and /%year%/%monthnum%/%postname%
1437 1437
 		$structure = trim($structure, '/');
1438
-		$dirs = $walk_dirs ? explode('/', $structure) : array( $structure );
1438
+		$dirs = $walk_dirs ? explode('/', $structure) : array($structure);
1439 1439
 		$num_dirs = count($dirs);
1440 1440
 
1441 1441
 		//strip slashes from the front of $front
@@ -1444,9 +1444,9 @@  discard block
 block discarded – undo
1444 1444
 		//the main workhorse loop
1445 1445
 		$post_rewrite = array();
1446 1446
 		$struct = $front;
1447
-		for ( $j = 0; $j < $num_dirs; ++$j ) {
1447
+		for ($j = 0; $j < $num_dirs; ++$j) {
1448 1448
 			//get the struct for this dir, and trim slashes off the front
1449
-			$struct .= $dirs[$j] . '/'; //accumulate. see comment near explode('/', $structure) above
1449
+			$struct .= $dirs[$j].'/'; //accumulate. see comment near explode('/', $structure) above
1450 1450
 			$struct = ltrim($struct, '/');
1451 1451
 
1452 1452
 			//replace tags with regexes
@@ -1456,10 +1456,10 @@  discard block
 block discarded – undo
1456 1456
 			$num_toks = preg_match_all('/%.+?%/', $struct, $toks);
1457 1457
 
1458 1458
 			//get the 'tagname=$matches[i]'
1459
-			$query = ( ! empty( $num_toks ) && isset( $queries[$num_toks - 1] ) ) ? $queries[$num_toks - 1] : '';
1459
+			$query = ( ! empty($num_toks) && isset($queries[$num_toks - 1])) ? $queries[$num_toks - 1] : '';
1460 1460
 
1461 1461
 			//set up $ep_mask_specific which is used to match more specific URL types
1462
-			switch ( $dirs[$j] ) {
1462
+			switch ($dirs[$j]) {
1463 1463
 				case '%year%':
1464 1464
 					$ep_mask_specific = EP_YEAR;
1465 1465
 					break;
@@ -1474,57 +1474,57 @@  discard block
 block discarded – undo
1474 1474
 			}
1475 1475
 
1476 1476
 			//create query for /page/xx
1477
-			$pagematch = $match . $pageregex;
1478
-			$pagequery = $index . '?' . $query . '&paged=' . $this->preg_index($num_toks + 1);
1477
+			$pagematch = $match.$pageregex;
1478
+			$pagequery = $index.'?'.$query.'&paged='.$this->preg_index($num_toks + 1);
1479 1479
 
1480 1480
 			//create query for /comment-page-xx
1481
-			$commentmatch = $match . $commentregex;
1482
-			$commentquery = $index . '?' . $query . '&cpage=' . $this->preg_index($num_toks + 1);
1481
+			$commentmatch = $match.$commentregex;
1482
+			$commentquery = $index.'?'.$query.'&cpage='.$this->preg_index($num_toks + 1);
1483 1483
 
1484
-			if ( get_option('page_on_front') ) {
1484
+			if (get_option('page_on_front')) {
1485 1485
 				//create query for Root /comment-page-xx
1486
-				$rootcommentmatch = $match . $commentregex;
1487
-				$rootcommentquery = $index . '?' . $query . '&page_id=' . get_option('page_on_front') . '&cpage=' . $this->preg_index($num_toks + 1);
1486
+				$rootcommentmatch = $match.$commentregex;
1487
+				$rootcommentquery = $index.'?'.$query.'&page_id='.get_option('page_on_front').'&cpage='.$this->preg_index($num_toks + 1);
1488 1488
 			}
1489 1489
 
1490 1490
 			//create query for /feed/(feed|atom|rss|rss2|rdf)
1491
-			$feedmatch = $match . $feedregex;
1492
-			$feedquery = $feedindex . '?' . $query . '&feed=' . $this->preg_index($num_toks + 1);
1491
+			$feedmatch = $match.$feedregex;
1492
+			$feedquery = $feedindex.'?'.$query.'&feed='.$this->preg_index($num_toks + 1);
1493 1493
 
1494 1494
 			//create query for /(feed|atom|rss|rss2|rdf) (see comment near creation of $feedregex)
1495
-			$feedmatch2 = $match . $feedregex2;
1496
-			$feedquery2 = $feedindex . '?' . $query . '&feed=' . $this->preg_index($num_toks + 1);
1495
+			$feedmatch2 = $match.$feedregex2;
1496
+			$feedquery2 = $feedindex.'?'.$query.'&feed='.$this->preg_index($num_toks + 1);
1497 1497
 
1498 1498
 			//if asked to, turn the feed queries into comment feed ones
1499
-			if ( $forcomments ) {
1499
+			if ($forcomments) {
1500 1500
 				$feedquery .= '&withcomments=1';
1501 1501
 				$feedquery2 .= '&withcomments=1';
1502 1502
 			}
1503 1503
 
1504 1504
 			//start creating the array of rewrites for this dir
1505 1505
 			$rewrite = array();
1506
-			if ( $feed ) //...adding on /feed/ regexes => queries
1506
+			if ($feed) //...adding on /feed/ regexes => queries
1507 1507
 				$rewrite = array($feedmatch => $feedquery, $feedmatch2 => $feedquery2);
1508
-			if ( $paged ) //...and /page/xx ones
1508
+			if ($paged) //...and /page/xx ones
1509 1509
 				$rewrite = array_merge($rewrite, array($pagematch => $pagequery));
1510 1510
 
1511 1511
 			//only on pages with comments add ../comment-page-xx/
1512
-			if ( EP_PAGES & $ep_mask || EP_PERMALINK & $ep_mask ) {
1512
+			if (EP_PAGES & $ep_mask || EP_PERMALINK & $ep_mask) {
1513 1513
 				$rewrite = array_merge($rewrite, array($commentmatch => $commentquery));
1514
-			} elseif ( EP_ROOT & $ep_mask && get_option('page_on_front') ) {
1514
+			} elseif (EP_ROOT & $ep_mask && get_option('page_on_front')) {
1515 1515
 				$rewrite = array_merge($rewrite, array($rootcommentmatch => $rootcommentquery));
1516 1516
 			}
1517 1517
 			//do endpoints
1518
-			if ( $endpoints ) {
1519
-				foreach ( (array) $ep_query_append as $regex => $ep) {
1518
+			if ($endpoints) {
1519
+				foreach ((array) $ep_query_append as $regex => $ep) {
1520 1520
 					//add the endpoints on if the mask fits
1521
-					if ( $ep[0] & $ep_mask || $ep[0] & $ep_mask_specific )
1522
-						$rewrite[$match . $regex] = $index . '?' . $query . $ep[1] . $this->preg_index($num_toks + 2);
1521
+					if ($ep[0] & $ep_mask || $ep[0] & $ep_mask_specific)
1522
+						$rewrite[$match.$regex] = $index.'?'.$query.$ep[1].$this->preg_index($num_toks + 2);
1523 1523
 				}
1524 1524
 			}
1525 1525
 
1526 1526
 			//if we've got some tags in this dir
1527
-			if ( $num_toks ) {
1527
+			if ($num_toks) {
1528 1528
 				$post = false;
1529 1529
 				$page = false;
1530 1530
 
@@ -1532,64 +1532,64 @@  discard block
 block discarded – undo
1532 1532
 				//individual post. Do this by checking it contains at least one of 1) post name,
1533 1533
 				//2) post ID, 3) page name, 4) timestamp (year, month, day, hour, second and
1534 1534
 				//minute all present). Set these flags now as we need them for the endpoints.
1535
-				if ( strpos($struct, '%postname%') !== false
1535
+				if (strpos($struct, '%postname%') !== false
1536 1536
 						|| strpos($struct, '%post_id%') !== false
1537 1537
 						|| strpos($struct, '%pagename%') !== false
1538 1538
 						|| (strpos($struct, '%year%') !== false && strpos($struct, '%monthnum%') !== false && strpos($struct, '%day%') !== false && strpos($struct, '%hour%') !== false && strpos($struct, '%minute%') !== false && strpos($struct, '%second%') !== false)
1539 1539
 						) {
1540 1540
 					$post = true;
1541
-					if ( strpos($struct, '%pagename%') !== false )
1541
+					if (strpos($struct, '%pagename%') !== false)
1542 1542
 						$page = true;
1543 1543
 				}
1544 1544
 
1545
-				if ( ! $post ) {
1545
+				if ( ! $post) {
1546 1546
 					// For custom post types, we need to add on endpoints as well.
1547
-					foreach ( get_post_types( array('_builtin' => false ) ) as $ptype ) {
1548
-						if ( strpos($struct, "%$ptype%") !== false ) {
1547
+					foreach (get_post_types(array('_builtin' => false)) as $ptype) {
1548
+						if (strpos($struct, "%$ptype%") !== false) {
1549 1549
 							$post = true;
1550
-							$page = is_post_type_hierarchical( $ptype ); // This is for page style attachment url's
1550
+							$page = is_post_type_hierarchical($ptype); // This is for page style attachment url's
1551 1551
 							break;
1552 1552
 						}
1553 1553
 					}
1554 1554
 				}
1555 1555
 
1556 1556
 				//if we're creating rules for a permalink, do all the endpoints like attachments etc
1557
-				if ( $post ) {
1557
+				if ($post) {
1558 1558
 					//create query and regex for trackback
1559
-					$trackbackmatch = $match . $trackbackregex;
1560
-					$trackbackquery = $trackbackindex . '?' . $query . '&tb=1';
1559
+					$trackbackmatch = $match.$trackbackregex;
1560
+					$trackbackquery = $trackbackindex.'?'.$query.'&tb=1';
1561 1561
 					//trim slashes from the end of the regex for this dir
1562 1562
 					$match = rtrim($match, '/');
1563 1563
 					//get rid of brackets
1564
-					$submatchbase = str_replace( array('(', ')'), '', $match);
1564
+					$submatchbase = str_replace(array('(', ')'), '', $match);
1565 1565
 
1566 1566
 					//add a rule for at attachments, which take the form of <permalink>/some-text
1567
-					$sub1 = $submatchbase . '/([^/]+)/';
1568
-					$sub1tb = $sub1 . $trackbackregex; //add trackback regex <permalink>/trackback/...
1569
-					$sub1feed = $sub1 . $feedregex; //and <permalink>/feed/(atom|...)
1570
-					$sub1feed2 = $sub1 . $feedregex2; //and <permalink>/(feed|atom...)
1571
-					$sub1comment = $sub1 . $commentregex; //and <permalink>/comment-page-xx
1567
+					$sub1 = $submatchbase.'/([^/]+)/';
1568
+					$sub1tb = $sub1.$trackbackregex; //add trackback regex <permalink>/trackback/...
1569
+					$sub1feed = $sub1.$feedregex; //and <permalink>/feed/(atom|...)
1570
+					$sub1feed2 = $sub1.$feedregex2; //and <permalink>/(feed|atom...)
1571
+					$sub1comment = $sub1.$commentregex; //and <permalink>/comment-page-xx
1572 1572
 
1573 1573
 					//add another rule to match attachments in the explicit form:
1574 1574
 					//<permalink>/attachment/some-text
1575
-					$sub2 = $submatchbase . '/attachment/([^/]+)/';
1576
-					$sub2tb = $sub2 . $trackbackregex; //and add trackbacks <permalink>/attachment/trackback
1577
-					$sub2feed = $sub2 . $feedregex;    //feeds, <permalink>/attachment/feed/(atom|...)
1578
-					$sub2feed2 = $sub2 . $feedregex2;  //and feeds again on to this <permalink>/attachment/(feed|atom...)
1579
-					$sub2comment = $sub2 . $commentregex; //and <permalink>/comment-page-xx
1575
+					$sub2 = $submatchbase.'/attachment/([^/]+)/';
1576
+					$sub2tb = $sub2.$trackbackregex; //and add trackbacks <permalink>/attachment/trackback
1577
+					$sub2feed = $sub2.$feedregex; //feeds, <permalink>/attachment/feed/(atom|...)
1578
+					$sub2feed2 = $sub2.$feedregex2; //and feeds again on to this <permalink>/attachment/(feed|atom...)
1579
+					$sub2comment = $sub2.$commentregex; //and <permalink>/comment-page-xx
1580 1580
 
1581 1581
 					//create queries for these extra tag-ons we've just dealt with
1582
-					$subquery = $index . '?attachment=' . $this->preg_index(1);
1583
-					$subtbquery = $subquery . '&tb=1';
1584
-					$subfeedquery = $subquery . '&feed=' . $this->preg_index(2);
1585
-					$subcommentquery = $subquery . '&cpage=' . $this->preg_index(2);
1582
+					$subquery = $index.'?attachment='.$this->preg_index(1);
1583
+					$subtbquery = $subquery.'&tb=1';
1584
+					$subfeedquery = $subquery.'&feed='.$this->preg_index(2);
1585
+					$subcommentquery = $subquery.'&cpage='.$this->preg_index(2);
1586 1586
 
1587 1587
 					//do endpoints for attachments
1588
-					if ( !empty($endpoints) ) {
1589
-						foreach ( (array) $ep_query_append as $regex => $ep ) {
1590
-							if ( $ep[0] & EP_ATTACHMENT ) {
1591
-								$rewrite[$sub1 . $regex] = $subquery . $ep[1] . $this->preg_index(3);
1592
-								$rewrite[$sub2 . $regex] = $subquery . $ep[1] . $this->preg_index(3);
1588
+					if ( ! empty($endpoints)) {
1589
+						foreach ((array) $ep_query_append as $regex => $ep) {
1590
+							if ($ep[0] & EP_ATTACHMENT) {
1591
+								$rewrite[$sub1.$regex] = $subquery.$ep[1].$this->preg_index(3);
1592
+								$rewrite[$sub2.$regex] = $subquery.$ep[1].$this->preg_index(3);
1593 1593
 							}
1594 1594
 						}
1595 1595
 					}
@@ -1601,12 +1601,12 @@  discard block
 block discarded – undo
1601 1601
 					$sub2 .= '?$';
1602 1602
 
1603 1603
 					//post pagination, e.g. <permalink>/2/
1604
-					$match = $match . '(/[0-9]+)?/?$';
1605
-					$query = $index . '?' . $query . '&page=' . $this->preg_index($num_toks + 1);
1604
+					$match = $match.'(/[0-9]+)?/?$';
1605
+					$query = $index.'?'.$query.'&page='.$this->preg_index($num_toks + 1);
1606 1606
 				} else { //not matching a permalink so this is a lot simpler
1607 1607
 					//close the match and finalise the query
1608 1608
 					$match .= '?$';
1609
-					$query = $index . '?' . $query;
1609
+					$query = $index.'?'.$query;
1610 1610
 				}
1611 1611
 
1612 1612
 				//create the final array for this dir by joining the $rewrite array (which currently
@@ -1615,12 +1615,12 @@  discard block
 block discarded – undo
1615 1615
 				$rewrite = array_merge($rewrite, array($match => $query));
1616 1616
 
1617 1617
 				//if we're matching a permalink, add those extras (attachments etc) on
1618
-				if ( $post ) {
1618
+				if ($post) {
1619 1619
 					//add trackback
1620 1620
 					$rewrite = array_merge(array($trackbackmatch => $trackbackquery), $rewrite);
1621 1621
 
1622 1622
 					//add regexes/queries for attachments, attachment trackbacks and so on
1623
-					if ( ! $page ) //require <permalink>/attachment/stuff form for pages because of confusion with subpages
1623
+					if ( ! $page) //require <permalink>/attachment/stuff form for pages because of confusion with subpages
1624 1624
 						$rewrite = array_merge($rewrite, array($sub1 => $subquery, $sub1tb => $subtbquery, $sub1feed => $subfeedquery, $sub1feed2 => $subfeedquery, $sub1comment => $subcommentquery));
1625 1625
 					$rewrite = array_merge(array($sub2 => $subquery, $sub2tb => $subtbquery, $sub2feed => $subfeedquery, $sub2feed2 => $subfeedquery, $sub2comment => $subcommentquery), $rewrite);
1626 1626
 				}
@@ -1671,29 +1671,29 @@  discard block
 block discarded – undo
1671 1671
 	public function rewrite_rules() {
1672 1672
 		$rewrite = array();
1673 1673
 
1674
-		if ( empty($this->permalink_structure) )
1674
+		if (empty($this->permalink_structure))
1675 1675
 			return $rewrite;
1676 1676
 
1677 1677
 		// robots.txt -only if installed at the root
1678
-		$home_path = parse_url( home_url() );
1679
-		$robots_rewrite = ( empty( $home_path['path'] ) || '/' == $home_path['path'] ) ? array( 'robots\.txt$' => $this->index . '?robots=1' ) : array();
1678
+		$home_path = parse_url(home_url());
1679
+		$robots_rewrite = (empty($home_path['path']) || '/' == $home_path['path']) ? array('robots\.txt$' => $this->index.'?robots=1') : array();
1680 1680
 
1681 1681
 		// Old feed and service files
1682 1682
 		$deprecated_files = array(
1683
-			'.*wp-(atom|rdf|rss|rss2|feed|commentsrss2)\.php$' => $this->index . '?feed=old',
1684
-			'.*wp-app\.php(/.*)?$' => $this->index . '?error=403',
1683
+			'.*wp-(atom|rdf|rss|rss2|feed|commentsrss2)\.php$' => $this->index.'?feed=old',
1684
+			'.*wp-app\.php(/.*)?$' => $this->index.'?error=403',
1685 1685
 		);
1686 1686
 
1687 1687
 		// Registration rules
1688 1688
 		$registration_pages = array();
1689
-		if ( is_multisite() && is_main_site() ) {
1690
-			$registration_pages['.*wp-signup.php$'] = $this->index . '?signup=true';
1691
-			$registration_pages['.*wp-activate.php$'] = $this->index . '?activate=true';
1689
+		if (is_multisite() && is_main_site()) {
1690
+			$registration_pages['.*wp-signup.php$'] = $this->index.'?signup=true';
1691
+			$registration_pages['.*wp-activate.php$'] = $this->index.'?activate=true';
1692 1692
 		}
1693
-		$registration_pages['.*wp-register.php$'] = $this->index . '?register=true'; // Deprecated
1693
+		$registration_pages['.*wp-register.php$'] = $this->index.'?register=true'; // Deprecated
1694 1694
 
1695 1695
 		// Post rewrite rules.
1696
-		$post_rewrite = $this->generate_rewrite_rules( $this->permalink_structure, EP_PERMALINK );
1696
+		$post_rewrite = $this->generate_rewrite_rules($this->permalink_structure, EP_PERMALINK);
1697 1697
 
1698 1698
 		/**
1699 1699
 		 * Filter rewrite rules used for "post" archives.
@@ -1702,7 +1702,7 @@  discard block
 block discarded – undo
1702 1702
 		 *
1703 1703
 		 * @param array $post_rewrite The rewrite rules for posts.
1704 1704
 		 */
1705
-		$post_rewrite = apply_filters( 'post_rewrite_rules', $post_rewrite );
1705
+		$post_rewrite = apply_filters('post_rewrite_rules', $post_rewrite);
1706 1706
 
1707 1707
 		// Date rewrite rules.
1708 1708
 		$date_rewrite = $this->generate_rewrite_rules($this->get_date_permastruct(), EP_DATE);
@@ -1716,10 +1716,10 @@  discard block
 block discarded – undo
1716 1716
 		 *
1717 1717
 		 * @param array $date_rewrite The rewrite rules for date archives.
1718 1718
 		 */
1719
-		$date_rewrite = apply_filters( 'date_rewrite_rules', $date_rewrite );
1719
+		$date_rewrite = apply_filters('date_rewrite_rules', $date_rewrite);
1720 1720
 
1721 1721
 		// Root-level rewrite rules.
1722
-		$root_rewrite = $this->generate_rewrite_rules($this->root . '/', EP_ROOT);
1722
+		$root_rewrite = $this->generate_rewrite_rules($this->root.'/', EP_ROOT);
1723 1723
 
1724 1724
 		/**
1725 1725
 		 * Filter rewrite rules used for root-level archives.
@@ -1731,10 +1731,10 @@  discard block
 block discarded – undo
1731 1731
 		 *
1732 1732
 		 * @param array $root_rewrite The root-level rewrite rules.
1733 1733
 		 */
1734
-		$root_rewrite = apply_filters( 'root_rewrite_rules', $root_rewrite );
1734
+		$root_rewrite = apply_filters('root_rewrite_rules', $root_rewrite);
1735 1735
 
1736 1736
 		// Comments rewrite rules.
1737
-		$comments_rewrite = $this->generate_rewrite_rules($this->root . $this->comments_base, EP_COMMENTS, false, true, true, false);
1737
+		$comments_rewrite = $this->generate_rewrite_rules($this->root.$this->comments_base, EP_COMMENTS, false, true, true, false);
1738 1738
 
1739 1739
 		/**
1740 1740
 		 * Filter rewrite rules used for comment feed archives.
@@ -1745,7 +1745,7 @@  discard block
 block discarded – undo
1745 1745
 		 *
1746 1746
 		 * @param array $comments_rewrite The rewrite rules for the site-wide comments feeds.
1747 1747
 		 */
1748
-		$comments_rewrite = apply_filters( 'comments_rewrite_rules', $comments_rewrite );
1748
+		$comments_rewrite = apply_filters('comments_rewrite_rules', $comments_rewrite);
1749 1749
 
1750 1750
 		// Search rewrite rules.
1751 1751
 		$search_structure = $this->get_search_permastruct();
@@ -1761,7 +1761,7 @@  discard block
 block discarded – undo
1761 1761
 		 *
1762 1762
 		 * @param array $search_rewrite The rewrite rules for search queries.
1763 1763
 		 */
1764
-		$search_rewrite = apply_filters( 'search_rewrite_rules', $search_rewrite );
1764
+		$search_rewrite = apply_filters('search_rewrite_rules', $search_rewrite);
1765 1765
 
1766 1766
 		// Author rewrite rules.
1767 1767
 		$author_rewrite = $this->generate_rewrite_rules($this->get_author_permastruct(), EP_AUTHORS);
@@ -1776,7 +1776,7 @@  discard block
 block discarded – undo
1776 1776
 		 *
1777 1777
 		 * @param array $author_rewrite The rewrite rules for author archives.
1778 1778
 		 */
1779
-		$author_rewrite = apply_filters( 'author_rewrite_rules', $author_rewrite );
1779
+		$author_rewrite = apply_filters('author_rewrite_rules', $author_rewrite);
1780 1780
 
1781 1781
 		// Pages rewrite rules.
1782 1782
 		$page_rewrite = $this->page_rewrite_rules();
@@ -1788,17 +1788,17 @@  discard block
 block discarded – undo
1788 1788
 		 *
1789 1789
 		 * @param array $page_rewrite The rewrite rules for the "page" post type.
1790 1790
 		 */
1791
-		$page_rewrite = apply_filters( 'page_rewrite_rules', $page_rewrite );
1791
+		$page_rewrite = apply_filters('page_rewrite_rules', $page_rewrite);
1792 1792
 
1793 1793
 		// Extra permastructs.
1794
-		foreach ( $this->extra_permastructs as $permastructname => $struct ) {
1795
-			if ( is_array( $struct ) ) {
1796
-				if ( count( $struct ) == 2 )
1797
-					$rules = $this->generate_rewrite_rules( $struct[0], $struct[1] );
1794
+		foreach ($this->extra_permastructs as $permastructname => $struct) {
1795
+			if (is_array($struct)) {
1796
+				if (count($struct) == 2)
1797
+					$rules = $this->generate_rewrite_rules($struct[0], $struct[1]);
1798 1798
 				else
1799
-					$rules = $this->generate_rewrite_rules( $struct['struct'], $struct['ep_mask'], $struct['paged'], $struct['feed'], $struct['forcomments'], $struct['walk_dirs'], $struct['endpoints'] );
1799
+					$rules = $this->generate_rewrite_rules($struct['struct'], $struct['ep_mask'], $struct['paged'], $struct['feed'], $struct['forcomments'], $struct['walk_dirs'], $struct['endpoints']);
1800 1800
 			} else {
1801
-				$rules = $this->generate_rewrite_rules( $struct );
1801
+				$rules = $this->generate_rewrite_rules($struct);
1802 1802
 			}
1803 1803
 
1804 1804
 			/**
@@ -1812,8 +1812,8 @@  discard block
 block discarded – undo
1812 1812
 			 *
1813 1813
 			 * @param array $rules The rewrite rules generated for the current permastruct.
1814 1814
 			 */
1815
-			$rules = apply_filters( $permastructname . '_rewrite_rules', $rules );
1816
-			if ( 'post_tag' == $permastructname ) {
1815
+			$rules = apply_filters($permastructname.'_rewrite_rules', $rules);
1816
+			if ('post_tag' == $permastructname) {
1817 1817
 
1818 1818
 				/**
1819 1819
 				 * Filter rewrite rules used specifically for Tags.
@@ -1823,17 +1823,17 @@  discard block
 block discarded – undo
1823 1823
 				 *
1824 1824
 				 * @param array $rules The rewrite rules generated for tags.
1825 1825
 				 */
1826
-				$rules = apply_filters( 'tag_rewrite_rules', $rules );
1826
+				$rules = apply_filters('tag_rewrite_rules', $rules);
1827 1827
 			}
1828 1828
 
1829 1829
 			$this->extra_rules_top = array_merge($this->extra_rules_top, $rules);
1830 1830
 		}
1831 1831
 
1832 1832
 		// Put them together.
1833
-		if ( $this->use_verbose_page_rules )
1834
-			$this->rules = array_merge($this->extra_rules_top, $robots_rewrite, $deprecated_files, $registration_pages, $root_rewrite, $comments_rewrite, $search_rewrite,  $author_rewrite, $date_rewrite, $page_rewrite, $post_rewrite, $this->extra_rules);
1833
+		if ($this->use_verbose_page_rules)
1834
+			$this->rules = array_merge($this->extra_rules_top, $robots_rewrite, $deprecated_files, $registration_pages, $root_rewrite, $comments_rewrite, $search_rewrite, $author_rewrite, $date_rewrite, $page_rewrite, $post_rewrite, $this->extra_rules);
1835 1835
 		else
1836
-			$this->rules = array_merge($this->extra_rules_top, $robots_rewrite, $deprecated_files, $registration_pages, $root_rewrite, $comments_rewrite, $search_rewrite,  $author_rewrite, $date_rewrite, $post_rewrite, $page_rewrite, $this->extra_rules);
1836
+			$this->rules = array_merge($this->extra_rules_top, $robots_rewrite, $deprecated_files, $registration_pages, $root_rewrite, $comments_rewrite, $search_rewrite, $author_rewrite, $date_rewrite, $post_rewrite, $page_rewrite, $this->extra_rules);
1837 1837
 
1838 1838
 		/**
1839 1839
 		 * Fires after the rewrite rules are generated.
@@ -1842,7 +1842,7 @@  discard block
 block discarded – undo
1842 1842
 		 *
1843 1843
 		 * @param WP_Rewrite $this Current WP_Rewrite instance, passed by reference.
1844 1844
 		 */
1845
-		do_action_ref_array( 'generate_rewrite_rules', array( &$this ) );
1845
+		do_action_ref_array('generate_rewrite_rules', array(&$this));
1846 1846
 
1847 1847
 		/**
1848 1848
 		 * Filter the full set of generated rewrite rules.
@@ -1851,7 +1851,7 @@  discard block
 block discarded – undo
1851 1851
 		 *
1852 1852
 		 * @param array $this->rules The compiled array of rewrite rules.
1853 1853
 		 */
1854
-		$this->rules = apply_filters( 'rewrite_rules_array', $this->rules );
1854
+		$this->rules = apply_filters('rewrite_rules_array', $this->rules);
1855 1855
 
1856 1856
 		return $this->rules;
1857 1857
 	}
@@ -1872,7 +1872,7 @@  discard block
 block discarded – undo
1872 1872
 	 */
1873 1873
 	public function wp_rewrite_rules() {
1874 1874
 		$this->rules = get_option('rewrite_rules');
1875
-		if ( empty($this->rules) ) {
1875
+		if (empty($this->rules)) {
1876 1876
 			$this->matches = 'matches';
1877 1877
 			$this->rewrite_rules();
1878 1878
 			update_option('rewrite_rules', $this->rules);
@@ -1896,15 +1896,15 @@  discard block
 block discarded – undo
1896 1896
 	 * @return string
1897 1897
 	 */
1898 1898
 	public function mod_rewrite_rules() {
1899
-		if ( ! $this->using_permalinks() )
1899
+		if ( ! $this->using_permalinks())
1900 1900
 			return '';
1901 1901
 
1902
-		$site_root = parse_url( site_url() );
1903
-		if ( isset( $site_root['path'] ) )
1902
+		$site_root = parse_url(site_url());
1903
+		if (isset($site_root['path']))
1904 1904
 			$site_root = trailingslashit($site_root['path']);
1905 1905
 
1906 1906
 		$home_root = parse_url(home_url());
1907
-		if ( isset( $home_root['path'] ) )
1907
+		if (isset($home_root['path']))
1908 1908
 			$home_root = trailingslashit($home_root['path']);
1909 1909
 		else
1910 1910
 			$home_root = '/';
@@ -1915,7 +1915,7 @@  discard block
 block discarded – undo
1915 1915
 		$rules .= "RewriteRule ^index\.php$ - [L]\n"; // Prevent -f checks on index.php.
1916 1916
 
1917 1917
 		//add in the rules that don't redirect to WP's index.php (and thus shouldn't be handled by WP at all)
1918
-		foreach ( (array) $this->non_wp_rules as $match => $query) {
1918
+		foreach ((array) $this->non_wp_rules as $match => $query) {
1919 1919
 			// Apache 1.3 does not support the reluctant (non-greedy) modifier.
1920 1920
 			$match = str_replace('.+?', '.+', $match);
1921 1921
 
@@ -1925,18 +1925,18 @@  discard block
 block discarded – undo
1925 1925
 				//nada.
1926 1926
 			//}
1927 1927
 
1928
-			$rules .= 'RewriteRule ^' . $match . ' ' . $home_root . $query . " [QSA,L]\n";
1928
+			$rules .= 'RewriteRule ^'.$match.' '.$home_root.$query." [QSA,L]\n";
1929 1929
 		}
1930 1930
 
1931
-		if ( $this->use_verbose_rules ) {
1931
+		if ($this->use_verbose_rules) {
1932 1932
 			$this->matches = '';
1933 1933
 			$rewrite = $this->rewrite_rules();
1934 1934
 			$num_rules = count($rewrite);
1935
-			$rules .= "RewriteCond %{REQUEST_FILENAME} -f [OR]\n" .
1936
-				"RewriteCond %{REQUEST_FILENAME} -d\n" .
1935
+			$rules .= "RewriteCond %{REQUEST_FILENAME} -f [OR]\n".
1936
+				"RewriteCond %{REQUEST_FILENAME} -d\n".
1937 1937
 				"RewriteRule ^.*$ - [S=$num_rules]\n";
1938 1938
 
1939
-			foreach ( (array) $rewrite as $match => $query) {
1939
+			foreach ((array) $rewrite as $match => $query) {
1940 1940
 				// Apache 1.3 does not support the reluctant (non-greedy) modifier.
1941 1941
 				$match = str_replace('.+?', '.+', $match);
1942 1942
 
@@ -1946,14 +1946,14 @@  discard block
 block discarded – undo
1946 1946
 					//nada.
1947 1947
 				//}
1948 1948
 
1949
-				if ( strpos($query, $this->index) !== false )
1950
-					$rules .= 'RewriteRule ^' . $match . ' ' . $home_root . $query . " [QSA,L]\n";
1949
+				if (strpos($query, $this->index) !== false)
1950
+					$rules .= 'RewriteRule ^'.$match.' '.$home_root.$query." [QSA,L]\n";
1951 1951
 				else
1952
-					$rules .= 'RewriteRule ^' . $match . ' ' . $site_root . $query . " [QSA,L]\n";
1952
+					$rules .= 'RewriteRule ^'.$match.' '.$site_root.$query." [QSA,L]\n";
1953 1953
 			}
1954 1954
 		} else {
1955
-			$rules .= "RewriteCond %{REQUEST_FILENAME} !-f\n" .
1956
-				"RewriteCond %{REQUEST_FILENAME} !-d\n" .
1955
+			$rules .= "RewriteCond %{REQUEST_FILENAME} !-f\n".
1956
+				"RewriteCond %{REQUEST_FILENAME} !-d\n".
1957 1957
 				"RewriteRule . {$home_root}{$this->index} [L]\n";
1958 1958
 		}
1959 1959
 
@@ -1967,7 +1967,7 @@  discard block
 block discarded – undo
1967 1967
 		 *
1968 1968
 		 * @param string $rules mod_rewrite Rewrite rules formatted for .htaccess.
1969 1969
 		 */
1970
-		$rules = apply_filters( 'mod_rewrite_rules', $rules );
1970
+		$rules = apply_filters('mod_rewrite_rules', $rules);
1971 1971
 
1972 1972
 		/**
1973 1973
 		 * Filter the list of rewrite rules formatted for output to an .htaccess file.
@@ -1977,7 +1977,7 @@  discard block
 block discarded – undo
1977 1977
 		 *
1978 1978
 		 * @param string $rules mod_rewrite Rewrite rules formatted for .htaccess.
1979 1979
 		 */
1980
-		return apply_filters( 'rewrite_rules', $rules );
1980
+		return apply_filters('rewrite_rules', $rules);
1981 1981
 	}
1982 1982
 
1983 1983
 	/**
@@ -1991,11 +1991,11 @@  discard block
 block discarded – undo
1991 1991
 	 *
1992 1992
 	 * @return string
1993 1993
 	 */
1994
-	public function iis7_url_rewrite_rules( $add_parent_tags = false ) {
1995
-		if ( ! $this->using_permalinks() )
1994
+	public function iis7_url_rewrite_rules($add_parent_tags = false) {
1995
+		if ( ! $this->using_permalinks())
1996 1996
 			return '';
1997 1997
 		$rules = '';
1998
-		if ( $add_parent_tags ) {
1998
+		if ($add_parent_tags) {
1999 1999
 			$rules .= '<configuration>
2000 2000
 	<system.webServer>
2001 2001
 		<rewrite>
@@ -2012,7 +2012,7 @@  discard block
 block discarded – undo
2012 2012
 				<action type="Rewrite" url="index.php" />
2013 2013
 			</rule>';
2014 2014
 
2015
-		if ( $add_parent_tags ) {
2015
+		if ($add_parent_tags) {
2016 2016
 			$rules .= '
2017 2017
 			</rules>
2018 2018
 		</rewrite>
@@ -2027,7 +2027,7 @@  discard block
 block discarded – undo
2027 2027
 		 *
2028 2028
 		 * @param string $rules Rewrite rules formatted for IIS web.config.
2029 2029
 		 */
2030
-		return apply_filters( 'iis7_url_rewrite_rules', $rules );
2030
+		return apply_filters('iis7_url_rewrite_rules', $rules);
2031 2031
 	}
2032 2032
 
2033 2033
 	/**
@@ -2047,10 +2047,10 @@  discard block
 block discarded – undo
2047 2047
 		//get everything up to the first ?
2048 2048
 		$index = (strpos($redirect, '?') === false ? strlen($redirect) : strpos($redirect, '?'));
2049 2049
 		$front = substr($redirect, 0, $index);
2050
-		if ( $front != $this->index ) { //it doesn't redirect to WP's index.php
2050
+		if ($front != $this->index) { //it doesn't redirect to WP's index.php
2051 2051
 			$this->add_external_rule($regex, $redirect);
2052 2052
 		} else {
2053
-			if ( 'bottom' == $after)
2053
+			if ('bottom' == $after)
2054 2054
 				$this->extra_rules = array_merge($this->extra_rules, array($regex => $redirect));
2055 2055
 			else
2056 2056
 				$this->extra_rules_top = array_merge($this->extra_rules_top, array($regex => $redirect));
@@ -2091,17 +2091,17 @@  discard block
 block discarded – undo
2091 2091
 	 *                               skip registering a query_var for this endpoint. Defaults to the
2092 2092
 	 *                               value of `$name`.
2093 2093
 	 */
2094
-	public function add_endpoint( $name, $places, $query_var = true ) {
2094
+	public function add_endpoint($name, $places, $query_var = true) {
2095 2095
 		global $wp;
2096 2096
 
2097 2097
 		// For backward compatibility, if `null` has explicitly been passed as `$query_var`, assume `true`.
2098
-		if ( true === $query_var || null === func_get_arg( 2 ) ) {
2098
+		if (true === $query_var || null === func_get_arg(2)) {
2099 2099
 			$query_var = $name;
2100 2100
 		}
2101
-		$this->endpoints[] = array( $places, $name, $query_var );
2101
+		$this->endpoints[] = array($places, $name, $query_var);
2102 2102
 
2103
-		if ( $query_var ) {
2104
-			$wp->add_query_var( $query_var );
2103
+		if ($query_var) {
2104
+			$wp->add_query_var($query_var);
2105 2105
 		}
2106 2106
 	}
2107 2107
 
@@ -2133,12 +2133,12 @@  discard block
 block discarded – undo
2133 2133
 	 *                          rules built for each in turn? Default is true.
2134 2134
 	 *     - endpoints (bool) - Should endpoints be applied to the generated rewrite rules? Default is true.
2135 2135
 	 */
2136
-	public function add_permastruct( $name, $struct, $args = array() ) {
2136
+	public function add_permastruct($name, $struct, $args = array()) {
2137 2137
 		// backwards compatibility for the old parameters: $with_front and $ep_mask
2138
-		if ( ! is_array( $args ) )
2139
-			$args = array( 'with_front' => $args );
2140
-		if ( func_num_args() == 4 )
2141
-			$args['ep_mask'] = func_get_arg( 3 );
2138
+		if ( ! is_array($args))
2139
+			$args = array('with_front' => $args);
2140
+		if (func_num_args() == 4)
2141
+			$args['ep_mask'] = func_get_arg(3);
2142 2142
 
2143 2143
 		$defaults = array(
2144 2144
 			'with_front' => true,
@@ -2149,16 +2149,16 @@  discard block
 block discarded – undo
2149 2149
 			'walk_dirs' => true,
2150 2150
 			'endpoints' => true,
2151 2151
 		);
2152
-		$args = array_intersect_key( $args, $defaults );
2153
-		$args = wp_parse_args( $args, $defaults );
2152
+		$args = array_intersect_key($args, $defaults);
2153
+		$args = wp_parse_args($args, $defaults);
2154 2154
 
2155
-		if ( $args['with_front'] )
2156
-			$struct = $this->front . $struct;
2155
+		if ($args['with_front'])
2156
+			$struct = $this->front.$struct;
2157 2157
 		else
2158
-			$struct = $this->root . $struct;
2158
+			$struct = $this->root.$struct;
2159 2159
 		$args['struct'] = $struct;
2160 2160
 
2161
-		$this->extra_permastructs[ $name ] = $args;
2161
+		$this->extra_permastructs[$name] = $args;
2162 2162
 	}
2163 2163
 
2164 2164
 	/**
@@ -2175,19 +2175,19 @@  discard block
 block discarded – undo
2175 2175
 	 *
2176 2176
 	 * @param bool $hard Whether to update .htaccess (hard flush) or just update rewrite_rules option (soft flush). Default is true (hard).
2177 2177
 	 */
2178
-	public function flush_rules( $hard = true ) {
2178
+	public function flush_rules($hard = true) {
2179 2179
 		static $do_hard_later = null;
2180 2180
 
2181 2181
 		// Prevent this action from running before everyone has registered their rewrites
2182
-		if ( ! did_action( 'wp_loaded' ) ) {
2183
-			add_action( 'wp_loaded', array( $this, 'flush_rules' ) );
2184
-			$do_hard_later = ( isset( $do_hard_later ) ) ? $do_hard_later || $hard : $hard;
2182
+		if ( ! did_action('wp_loaded')) {
2183
+			add_action('wp_loaded', array($this, 'flush_rules'));
2184
+			$do_hard_later = (isset($do_hard_later)) ? $do_hard_later || $hard : $hard;
2185 2185
 			return;
2186 2186
 		}
2187 2187
 
2188
-		if ( isset( $do_hard_later ) ) {
2188
+		if (isset($do_hard_later)) {
2189 2189
 			$hard = $do_hard_later;
2190
-			unset( $do_hard_later );
2190
+			unset($do_hard_later);
2191 2191
 		}
2192 2192
 
2193 2193
 		delete_option('rewrite_rules');
@@ -2201,12 +2201,12 @@  discard block
 block discarded – undo
2201 2201
 		 *
2202 2202
 		 * @param bool $hard Whether to flush rewrite rules "hard". Default true.
2203 2203
 		 */
2204
-		if ( ! $hard || ! apply_filters( 'flush_rewrite_rules_hard', true ) ) {
2204
+		if ( ! $hard || ! apply_filters('flush_rewrite_rules_hard', true)) {
2205 2205
 			return;
2206 2206
 		}
2207
-		if ( function_exists( 'save_mod_rewrite_rules' ) )
2207
+		if (function_exists('save_mod_rewrite_rules'))
2208 2208
 			save_mod_rewrite_rules();
2209
-		if ( function_exists( 'iis7_save_url_rewrite_rules' ) )
2209
+		if (function_exists('iis7_save_url_rewrite_rules'))
2210 2210
 			iis7_save_url_rewrite_rules();
2211 2211
 	}
2212 2212
 
@@ -2225,18 +2225,18 @@  discard block
 block discarded – undo
2225 2225
 		$this->permalink_structure = get_option('permalink_structure');
2226 2226
 		$this->front = substr($this->permalink_structure, 0, strpos($this->permalink_structure, '%'));
2227 2227
 		$this->root = '';
2228
-		if ( $this->using_index_permalinks() )
2229
-			$this->root = $this->index . '/';
2228
+		if ($this->using_index_permalinks())
2229
+			$this->root = $this->index.'/';
2230 2230
 		unset($this->author_structure);
2231 2231
 		unset($this->date_structure);
2232 2232
 		unset($this->page_structure);
2233 2233
 		unset($this->search_structure);
2234 2234
 		unset($this->feed_structure);
2235 2235
 		unset($this->comment_feed_structure);
2236
-		$this->use_trailing_slashes = ( '/' == substr($this->permalink_structure, -1, 1) );
2236
+		$this->use_trailing_slashes = ('/' == substr($this->permalink_structure, -1, 1));
2237 2237
 
2238 2238
 		// Enable generic rules for pages if permalink structure doesn't begin with a wildcard.
2239
-		if ( preg_match("/^[^%]*%(?:postname|category|tag|author)%/", $this->permalink_structure) )
2239
+		if (preg_match("/^[^%]*%(?:postname|category|tag|author)%/", $this->permalink_structure))
2240 2240
 			 $this->use_verbose_page_rules = true;
2241 2241
 		else
2242 2242
 			$this->use_verbose_page_rules = false;
@@ -2258,7 +2258,7 @@  discard block
 block discarded – undo
2258 2258
 	 * @param string $permalink_structure Permalink structure.
2259 2259
 	 */
2260 2260
 	public function set_permalink_structure($permalink_structure) {
2261
-		if ( $permalink_structure != $this->permalink_structure ) {
2261
+		if ($permalink_structure != $this->permalink_structure) {
2262 2262
 			$old_permalink_structure = $this->permalink_structure;
2263 2263
 			update_option('permalink_structure', $permalink_structure);
2264 2264
 			$this->init();
@@ -2271,7 +2271,7 @@  discard block
 block discarded – undo
2271 2271
 			 * @param string $old_permalink_structure The previous permalink structure.
2272 2272
 			 * @param string $permalink_structure     The new permalink structure.
2273 2273
 			 */
2274
-			do_action( 'permalink_structure_changed', $old_permalink_structure, $permalink_structure );
2274
+			do_action('permalink_structure_changed', $old_permalink_structure, $permalink_structure);
2275 2275
 		}
2276 2276
 	}
2277 2277
 
@@ -2288,7 +2288,7 @@  discard block
 block discarded – undo
2288 2288
 	 * @param string $category_base Category permalink structure base.
2289 2289
 	 */
2290 2290
 	public function set_category_base($category_base) {
2291
-		if ( $category_base != get_option('category_base') ) {
2291
+		if ($category_base != get_option('category_base')) {
2292 2292
 			update_option('category_base', $category_base);
2293 2293
 			$this->init();
2294 2294
 		}
@@ -2306,9 +2306,9 @@  discard block
 block discarded – undo
2306 2306
 	 *
2307 2307
 	 * @param string $tag_base Tag permalink structure base.
2308 2308
 	 */
2309
-	public function set_tag_base( $tag_base ) {
2310
-		if ( $tag_base != get_option( 'tag_base') ) {
2311
-			update_option( 'tag_base', $tag_base );
2309
+	public function set_tag_base($tag_base) {
2310
+		if ($tag_base != get_option('tag_base')) {
2311
+			update_option('tag_base', $tag_base);
2312 2312
 			$this->init();
2313 2313
 		}
2314 2314
 	}
Please login to merge, or discard this patch.
Braces   +165 added lines, -112 removed lines patch added patch discarded remove patch
@@ -40,8 +40,9 @@  discard block
 block discarded – undo
40 40
  */
41 41
 function add_rewrite_tag( $tag, $regex, $query = '' ) {
42 42
 	// validate the tag's name
43
-	if ( strlen( $tag ) < 3 || $tag[0] != '%' || $tag[ strlen($tag) - 1 ] != '%' )
44
-		return;
43
+	if ( strlen( $tag ) < 3 || $tag[0] != '%' || $tag[ strlen($tag) - 1 ] != '%' ) {
44
+			return;
45
+	}
45 46
 
46 47
 	global $wp_rewrite, $wp;
47 48
 
@@ -70,10 +71,12 @@  discard block
 block discarded – undo
70 71
 	global $wp_rewrite;
71 72
 
72 73
 	// backwards compatibility for the old parameters: $with_front and $ep_mask
73
-	if ( ! is_array( $args ) )
74
-		$args = array( 'with_front' => $args );
75
-	if ( func_num_args() == 4 )
76
-		$args['ep_mask'] = func_get_arg( 3 );
74
+	if ( ! is_array( $args ) ) {
75
+			$args = array( 'with_front' => $args );
76
+	}
77
+	if ( func_num_args() == 4 ) {
78
+			$args['ep_mask'] = func_get_arg( 3 );
79
+	}
77 80
 
78 81
 	$wp_rewrite->add_permastruct( $name, $struct, $args );
79 82
 }
@@ -91,8 +94,10 @@  discard block
 block discarded – undo
91 94
  */
92 95
 function add_feed($feedname, $function) {
93 96
 	global $wp_rewrite;
94
-	if ( ! in_array($feedname, $wp_rewrite->feeds) ) //override the file if it is
97
+	if ( ! in_array($feedname, $wp_rewrite->feeds) ) {
98
+		//override the file if it is
95 99
 		$wp_rewrite->feeds[] = $feedname;
100
+	}
96 101
 	$hook = 'do_feed_' . $feedname;
97 102
 	// Remove default function hook
98 103
 	remove_action($hook, $hook);
@@ -426,16 +431,18 @@  discard block
 block discarded – undo
426 431
 	// First, check to see if there is a 'p=N' or 'page_id=N' to match against
427 432
 	if ( preg_match('#[?&](p|page_id|attachment_id)=(\d+)#', $url, $values) )	{
428 433
 		$id = absint($values[2]);
429
-		if ( $id )
430
-			return $id;
434
+		if ( $id ) {
435
+					return $id;
436
+		}
431 437
 	}
432 438
 
433 439
 	// Check to see if we are using rewrite rules
434 440
 	$rewrite = $wp_rewrite->wp_rewrite_rules();
435 441
 
436 442
 	// Not using rewrite rules, and 'p=N' and 'page_id=N' methods failed, so we're out of options
437
-	if ( empty($rewrite) )
438
-		return 0;
443
+	if ( empty($rewrite) ) {
444
+			return 0;
445
+	}
439 446
 
440 447
 	// Get rid of the #anchor
441 448
 	$url_split = explode('#', $url);
@@ -446,16 +453,19 @@  discard block
 block discarded – undo
446 453
 	$url = $url_split[0];
447 454
 
448 455
 	// Add 'www.' if it is absent and should be there
449
-	if ( false !== strpos(home_url(), '://www.') && false === strpos($url, '://www.') )
450
-		$url = str_replace('://', '://www.', $url);
456
+	if ( false !== strpos(home_url(), '://www.') && false === strpos($url, '://www.') ) {
457
+			$url = str_replace('://', '://www.', $url);
458
+	}
451 459
 
452 460
 	// Strip 'www.' if it is present and shouldn't be
453
-	if ( false === strpos(home_url(), '://www.') )
454
-		$url = str_replace('://www.', '://', $url);
461
+	if ( false === strpos(home_url(), '://www.') ) {
462
+			$url = str_replace('://www.', '://', $url);
463
+	}
455 464
 
456 465
 	// Strip 'index.php/' if we're not using path info permalinks
457
-	if ( !$wp_rewrite->using_index_permalinks() )
458
-		$url = str_replace( $wp_rewrite->index . '/', '', $url );
466
+	if ( !$wp_rewrite->using_index_permalinks() ) {
467
+			$url = str_replace( $wp_rewrite->index . '/', '', $url );
468
+	}
459 469
 
460 470
 	if ( false !== strpos( trailingslashit( $url ), home_url( '/' ) ) ) {
461 471
 		// Chop off http://domain.com/[path]
@@ -474,8 +484,9 @@  discard block
 block discarded – undo
474 484
 	$post_type_query_vars = array();
475 485
 
476 486
 	foreach ( get_post_types( array() , 'objects' ) as $post_type => $t ) {
477
-		if ( ! empty( $t->query_var ) )
478
-			$post_type_query_vars[ $t->query_var ] = $post_type;
487
+		if ( ! empty( $t->query_var ) ) {
488
+					$post_type_query_vars[ $t->query_var ] = $post_type;
489
+		}
479 490
 	}
480 491
 
481 492
 	// Look for matches.
@@ -484,15 +495,17 @@  discard block
 block discarded – undo
484 495
 
485 496
 		// If the requesting file is the anchor of the match, prepend it
486 497
 		// to the path info.
487
-		if ( !empty($url) && ($url != $request) && (strpos($match, $url) === 0) )
488
-			$request_match = $url . '/' . $request;
498
+		if ( !empty($url) && ($url != $request) && (strpos($match, $url) === 0) ) {
499
+					$request_match = $url . '/' . $request;
500
+		}
489 501
 
490 502
 		if ( preg_match("#^$match#", $request_match, $matches) ) {
491 503
 
492 504
 			if ( $wp_rewrite->use_verbose_page_rules && preg_match( '/pagename=\$matches\[([0-9]+)\]/', $query, $varmatch ) ) {
493 505
 				// This is a verbose page match, let's check to be sure about it.
494
-				if ( ! get_page_by_path( $matches[ $varmatch[1] ] ) )
495
-					continue;
506
+				if ( ! get_page_by_path( $matches[ $varmatch[1] ] ) ) {
507
+									continue;
508
+				}
496 509
 			}
497 510
 
498 511
 			// Got a match.
@@ -521,10 +534,11 @@  discard block
 block discarded – undo
521 534
 
522 535
 			// Do the query
523 536
 			$query = new WP_Query( $query );
524
-			if ( ! empty( $query->posts ) && $query->is_singular )
525
-				return $query->post->ID;
526
-			else
527
-				return 0;
537
+			if ( ! empty( $query->posts ) && $query->is_singular ) {
538
+							return $query->post->ID;
539
+			} else {
540
+							return 0;
541
+			}
528 542
 		}
529 543
 	}
530 544
 	return 0;
@@ -979,8 +993,9 @@  discard block
 block discarded – undo
979 993
 		$posts = get_page_hierarchy( $pages );
980 994
 
981 995
 		// If we have no pages get out quick
982
-		if ( !$posts )
983
-			return array( array(), array() );
996
+		if ( !$posts ) {
997
+					return array( array(), array() );
998
+		}
984 999
 
985 1000
 		//now reverse it, because we need parents after children for rewrite rules to work properly
986 1001
 		$posts = array_reverse($posts, true);
@@ -1041,8 +1056,9 @@  discard block
 block discarded – undo
1041 1056
 	 * @return string|false False on no permalink structure. Date permalink structure.
1042 1057
 	 */
1043 1058
 	public function get_date_permastruct() {
1044
-		if ( isset($this->date_structure) )
1045
-			return $this->date_structure;
1059
+		if ( isset($this->date_structure) ) {
1060
+					return $this->date_structure;
1061
+		}
1046 1062
 
1047 1063
 		if ( empty($this->permalink_structure) ) {
1048 1064
 			$this->date_structure = '';
@@ -1062,8 +1078,9 @@  discard block
 block discarded – undo
1062 1078
 			}
1063 1079
 		}
1064 1080
 
1065
-		if ( empty($date_endian) )
1066
-			$date_endian = '%year%/%monthnum%/%day%';
1081
+		if ( empty($date_endian) ) {
1082
+					$date_endian = '%year%/%monthnum%/%day%';
1083
+		}
1067 1084
 
1068 1085
 		// Do not allow the date tags and %post_id% to overlap in the permalink
1069 1086
 		// structure. If they do, move the date tags to $front/date/.
@@ -1097,8 +1114,9 @@  discard block
 block discarded – undo
1097 1114
 	public function get_year_permastruct() {
1098 1115
 		$structure = $this->get_date_permastruct();
1099 1116
 
1100
-		if ( empty($structure) )
1101
-			return false;
1117
+		if ( empty($structure) ) {
1118
+					return false;
1119
+		}
1102 1120
 
1103 1121
 		$structure = str_replace('%monthnum%', '', $structure);
1104 1122
 		$structure = str_replace('%day%', '', $structure);
@@ -1121,8 +1139,9 @@  discard block
 block discarded – undo
1121 1139
 	public function get_month_permastruct() {
1122 1140
 		$structure = $this->get_date_permastruct();
1123 1141
 
1124
-		if ( empty($structure) )
1125
-			return false;
1142
+		if ( empty($structure) ) {
1143
+					return false;
1144
+		}
1126 1145
 
1127 1146
 		$structure = str_replace('%day%', '', $structure);
1128 1147
 		$structure = preg_replace('#/+#', '/', $structure);
@@ -1188,11 +1207,13 @@  discard block
 block discarded – undo
1188 1207
 	 * @return string|false False if not found. Permalink structure string.
1189 1208
 	 */
1190 1209
 	public function get_extra_permastruct($name) {
1191
-		if ( empty($this->permalink_structure) )
1192
-			return false;
1210
+		if ( empty($this->permalink_structure) ) {
1211
+					return false;
1212
+		}
1193 1213
 
1194
-		if ( isset($this->extra_permastructs[$name]) )
1195
-			return $this->extra_permastructs[$name]['struct'];
1214
+		if ( isset($this->extra_permastructs[$name]) ) {
1215
+					return $this->extra_permastructs[$name]['struct'];
1216
+		}
1196 1217
 
1197 1218
 		return false;
1198 1219
 	}
@@ -1210,8 +1231,9 @@  discard block
 block discarded – undo
1210 1231
 	 * @return string|false False if not found. Permalink structure string.
1211 1232
 	 */
1212 1233
 	public function get_author_permastruct() {
1213
-		if ( isset($this->author_structure) )
1214
-			return $this->author_structure;
1234
+		if ( isset($this->author_structure) ) {
1235
+					return $this->author_structure;
1236
+		}
1215 1237
 
1216 1238
 		if ( empty($this->permalink_structure) ) {
1217 1239
 			$this->author_structure = '';
@@ -1236,8 +1258,9 @@  discard block
 block discarded – undo
1236 1258
 	 * @return string|false False if not found. Permalink structure string.
1237 1259
 	 */
1238 1260
 	public function get_search_permastruct() {
1239
-		if ( isset($this->search_structure) )
1240
-			return $this->search_structure;
1261
+		if ( isset($this->search_structure) ) {
1262
+					return $this->search_structure;
1263
+		}
1241 1264
 
1242 1265
 		if ( empty($this->permalink_structure) ) {
1243 1266
 			$this->search_structure = '';
@@ -1262,8 +1285,9 @@  discard block
 block discarded – undo
1262 1285
 	 * @return string|false False if not found. Permalink structure string.
1263 1286
 	 */
1264 1287
 	public function get_page_permastruct() {
1265
-		if ( isset($this->page_structure) )
1266
-			return $this->page_structure;
1288
+		if ( isset($this->page_structure) ) {
1289
+					return $this->page_structure;
1290
+		}
1267 1291
 
1268 1292
 		if (empty($this->permalink_structure)) {
1269 1293
 			$this->page_structure = '';
@@ -1288,8 +1312,9 @@  discard block
 block discarded – undo
1288 1312
 	 * @return string|false False if not found. Permalink structure string.
1289 1313
 	 */
1290 1314
 	public function get_feed_permastruct() {
1291
-		if ( isset($this->feed_structure) )
1292
-			return $this->feed_structure;
1315
+		if ( isset($this->feed_structure) ) {
1316
+					return $this->feed_structure;
1317
+		}
1293 1318
 
1294 1319
 		if ( empty($this->permalink_structure) ) {
1295 1320
 			$this->feed_structure = '';
@@ -1314,8 +1339,9 @@  discard block
 block discarded – undo
1314 1339
 	 * @return string|false False if not found. Permalink structure string.
1315 1340
 	 */
1316 1341
 	public function get_comment_feed_permastruct() {
1317
-		if ( isset($this->comment_feed_structure) )
1318
-			return $this->comment_feed_structure;
1342
+		if ( isset($this->comment_feed_structure) ) {
1343
+					return $this->comment_feed_structure;
1344
+		}
1319 1345
 
1320 1346
 		if (empty($this->permalink_structure)) {
1321 1347
 			$this->comment_feed_structure = '';
@@ -1378,8 +1404,9 @@  discard block
 block discarded – undo
1378 1404
 	public function generate_rewrite_rules($permalink_structure, $ep_mask = EP_NONE, $paged = true, $feed = true, $forcomments = false, $walk_dirs = true, $endpoints = true) {
1379 1405
 		//build a regex to match the feed section of URLs, something like (feed|atom|rss|rss2)/?
1380 1406
 		$feedregex2 = '';
1381
-		foreach ( (array) $this->feeds as $feed_name)
1382
-			$feedregex2 .= $feed_name . '|';
1407
+		foreach ( (array) $this->feeds as $feed_name) {
1408
+					$feedregex2 .= $feed_name . '|';
1409
+		}
1383 1410
 		$feedregex2 = '(' . trim($feedregex2, '|') . ')/?$';
1384 1411
 
1385 1412
 		//$feedregex is identical but with /feed/ added on as well, so URLs like <permalink>/feed/atom
@@ -1417,10 +1444,11 @@  discard block
 block discarded – undo
1417 1444
 		//tagname=$matches[i] where i is the current $i
1418 1445
 		$queries = array();
1419 1446
 		for ( $i = 0; $i < $num_tokens; ++$i ) {
1420
-			if ( 0 < $i )
1421
-				$queries[$i] = $queries[$i - 1] . '&';
1422
-			else
1423
-				$queries[$i] = '';
1447
+			if ( 0 < $i ) {
1448
+							$queries[$i] = $queries[$i - 1] . '&';
1449
+			} else {
1450
+							$queries[$i] = '';
1451
+			}
1424 1452
 
1425 1453
 			$query_token = str_replace($this->rewritecode, $this->queryreplace, $tokens[0][$i]) . $this->preg_index($i+1);
1426 1454
 			$queries[$i] .= $query_token;
@@ -1428,8 +1456,9 @@  discard block
 block discarded – undo
1428 1456
 
1429 1457
 		//get the structure, minus any cruft (stuff that isn't tags) at the front
1430 1458
 		$structure = $permalink_structure;
1431
-		if ( $front != '/' )
1432
-			$structure = str_replace($front, '', $structure);
1459
+		if ( $front != '/' ) {
1460
+					$structure = str_replace($front, '', $structure);
1461
+		}
1433 1462
 
1434 1463
 		//create a list of dirs to walk over, making rewrite rules for each level
1435 1464
 		//so for example, a $structure of /%year%/%monthnum%/%postname% would create
@@ -1503,10 +1532,14 @@  discard block
 block discarded – undo
1503 1532
 
1504 1533
 			//start creating the array of rewrites for this dir
1505 1534
 			$rewrite = array();
1506
-			if ( $feed ) //...adding on /feed/ regexes => queries
1535
+			if ( $feed ) {
1536
+				//...adding on /feed/ regexes => queries
1507 1537
 				$rewrite = array($feedmatch => $feedquery, $feedmatch2 => $feedquery2);
1508
-			if ( $paged ) //...and /page/xx ones
1538
+			}
1539
+			if ( $paged ) {
1540
+				//...and /page/xx ones
1509 1541
 				$rewrite = array_merge($rewrite, array($pagematch => $pagequery));
1542
+			}
1510 1543
 
1511 1544
 			//only on pages with comments add ../comment-page-xx/
1512 1545
 			if ( EP_PAGES & $ep_mask || EP_PERMALINK & $ep_mask ) {
@@ -1518,8 +1551,9 @@  discard block
 block discarded – undo
1518 1551
 			if ( $endpoints ) {
1519 1552
 				foreach ( (array) $ep_query_append as $regex => $ep) {
1520 1553
 					//add the endpoints on if the mask fits
1521
-					if ( $ep[0] & $ep_mask || $ep[0] & $ep_mask_specific )
1522
-						$rewrite[$match . $regex] = $index . '?' . $query . $ep[1] . $this->preg_index($num_toks + 2);
1554
+					if ( $ep[0] & $ep_mask || $ep[0] & $ep_mask_specific ) {
1555
+											$rewrite[$match . $regex] = $index . '?' . $query . $ep[1] . $this->preg_index($num_toks + 2);
1556
+					}
1523 1557
 				}
1524 1558
 			}
1525 1559
 
@@ -1538,8 +1572,9 @@  discard block
 block discarded – undo
1538 1572
 						|| (strpos($struct, '%year%') !== false && strpos($struct, '%monthnum%') !== false && strpos($struct, '%day%') !== false && strpos($struct, '%hour%') !== false && strpos($struct, '%minute%') !== false && strpos($struct, '%second%') !== false)
1539 1573
 						) {
1540 1574
 					$post = true;
1541
-					if ( strpos($struct, '%pagename%') !== false )
1542
-						$page = true;
1575
+					if ( strpos($struct, '%pagename%') !== false ) {
1576
+											$page = true;
1577
+					}
1543 1578
 				}
1544 1579
 
1545 1580
 				if ( ! $post ) {
@@ -1620,8 +1655,10 @@  discard block
 block discarded – undo
1620 1655
 					$rewrite = array_merge(array($trackbackmatch => $trackbackquery), $rewrite);
1621 1656
 
1622 1657
 					//add regexes/queries for attachments, attachment trackbacks and so on
1623
-					if ( ! $page ) //require <permalink>/attachment/stuff form for pages because of confusion with subpages
1658
+					if ( ! $page ) {
1659
+						//require <permalink>/attachment/stuff form for pages because of confusion with subpages
1624 1660
 						$rewrite = array_merge($rewrite, array($sub1 => $subquery, $sub1tb => $subtbquery, $sub1feed => $subfeedquery, $sub1feed2 => $subfeedquery, $sub1comment => $subcommentquery));
1661
+					}
1625 1662
 					$rewrite = array_merge(array($sub2 => $subquery, $sub2tb => $subtbquery, $sub2feed => $subfeedquery, $sub2feed2 => $subfeedquery, $sub2comment => $subcommentquery), $rewrite);
1626 1663
 				}
1627 1664
 			} //if($num_toks)
@@ -1671,8 +1708,9 @@  discard block
 block discarded – undo
1671 1708
 	public function rewrite_rules() {
1672 1709
 		$rewrite = array();
1673 1710
 
1674
-		if ( empty($this->permalink_structure) )
1675
-			return $rewrite;
1711
+		if ( empty($this->permalink_structure) ) {
1712
+					return $rewrite;
1713
+		}
1676 1714
 
1677 1715
 		// robots.txt -only if installed at the root
1678 1716
 		$home_path = parse_url( home_url() );
@@ -1793,10 +1831,11 @@  discard block
 block discarded – undo
1793 1831
 		// Extra permastructs.
1794 1832
 		foreach ( $this->extra_permastructs as $permastructname => $struct ) {
1795 1833
 			if ( is_array( $struct ) ) {
1796
-				if ( count( $struct ) == 2 )
1797
-					$rules = $this->generate_rewrite_rules( $struct[0], $struct[1] );
1798
-				else
1799
-					$rules = $this->generate_rewrite_rules( $struct['struct'], $struct['ep_mask'], $struct['paged'], $struct['feed'], $struct['forcomments'], $struct['walk_dirs'], $struct['endpoints'] );
1834
+				if ( count( $struct ) == 2 ) {
1835
+									$rules = $this->generate_rewrite_rules( $struct[0], $struct[1] );
1836
+				} else {
1837
+									$rules = $this->generate_rewrite_rules( $struct['struct'], $struct['ep_mask'], $struct['paged'], $struct['feed'], $struct['forcomments'], $struct['walk_dirs'], $struct['endpoints'] );
1838
+				}
1800 1839
 			} else {
1801 1840
 				$rules = $this->generate_rewrite_rules( $struct );
1802 1841
 			}
@@ -1830,10 +1869,11 @@  discard block
 block discarded – undo
1830 1869
 		}
1831 1870
 
1832 1871
 		// Put them together.
1833
-		if ( $this->use_verbose_page_rules )
1834
-			$this->rules = array_merge($this->extra_rules_top, $robots_rewrite, $deprecated_files, $registration_pages, $root_rewrite, $comments_rewrite, $search_rewrite,  $author_rewrite, $date_rewrite, $page_rewrite, $post_rewrite, $this->extra_rules);
1835
-		else
1836
-			$this->rules = array_merge($this->extra_rules_top, $robots_rewrite, $deprecated_files, $registration_pages, $root_rewrite, $comments_rewrite, $search_rewrite,  $author_rewrite, $date_rewrite, $post_rewrite, $page_rewrite, $this->extra_rules);
1872
+		if ( $this->use_verbose_page_rules ) {
1873
+					$this->rules = array_merge($this->extra_rules_top, $robots_rewrite, $deprecated_files, $registration_pages, $root_rewrite, $comments_rewrite, $search_rewrite,  $author_rewrite, $date_rewrite, $page_rewrite, $post_rewrite, $this->extra_rules);
1874
+		} else {
1875
+					$this->rules = array_merge($this->extra_rules_top, $robots_rewrite, $deprecated_files, $registration_pages, $root_rewrite, $comments_rewrite, $search_rewrite,  $author_rewrite, $date_rewrite, $post_rewrite, $page_rewrite, $this->extra_rules);
1876
+		}
1837 1877
 
1838 1878
 		/**
1839 1879
 		 * Fires after the rewrite rules are generated.
@@ -1896,18 +1936,21 @@  discard block
 block discarded – undo
1896 1936
 	 * @return string
1897 1937
 	 */
1898 1938
 	public function mod_rewrite_rules() {
1899
-		if ( ! $this->using_permalinks() )
1900
-			return '';
1939
+		if ( ! $this->using_permalinks() ) {
1940
+					return '';
1941
+		}
1901 1942
 
1902 1943
 		$site_root = parse_url( site_url() );
1903
-		if ( isset( $site_root['path'] ) )
1904
-			$site_root = trailingslashit($site_root['path']);
1944
+		if ( isset( $site_root['path'] ) ) {
1945
+					$site_root = trailingslashit($site_root['path']);
1946
+		}
1905 1947
 
1906 1948
 		$home_root = parse_url(home_url());
1907
-		if ( isset( $home_root['path'] ) )
1908
-			$home_root = trailingslashit($home_root['path']);
1909
-		else
1910
-			$home_root = '/';
1949
+		if ( isset( $home_root['path'] ) ) {
1950
+					$home_root = trailingslashit($home_root['path']);
1951
+		} else {
1952
+					$home_root = '/';
1953
+		}
1911 1954
 
1912 1955
 		$rules = "<IfModule mod_rewrite.c>\n";
1913 1956
 		$rules .= "RewriteEngine On\n";
@@ -1946,10 +1989,11 @@  discard block
 block discarded – undo
1946 1989
 					//nada.
1947 1990
 				//}
1948 1991
 
1949
-				if ( strpos($query, $this->index) !== false )
1950
-					$rules .= 'RewriteRule ^' . $match . ' ' . $home_root . $query . " [QSA,L]\n";
1951
-				else
1952
-					$rules .= 'RewriteRule ^' . $match . ' ' . $site_root . $query . " [QSA,L]\n";
1992
+				if ( strpos($query, $this->index) !== false ) {
1993
+									$rules .= 'RewriteRule ^' . $match . ' ' . $home_root . $query . " [QSA,L]\n";
1994
+				} else {
1995
+									$rules .= 'RewriteRule ^' . $match . ' ' . $site_root . $query . " [QSA,L]\n";
1996
+				}
1953 1997
 			}
1954 1998
 		} else {
1955 1999
 			$rules .= "RewriteCond %{REQUEST_FILENAME} !-f\n" .
@@ -1992,8 +2036,9 @@  discard block
 block discarded – undo
1992 2036
 	 * @return string
1993 2037
 	 */
1994 2038
 	public function iis7_url_rewrite_rules( $add_parent_tags = false ) {
1995
-		if ( ! $this->using_permalinks() )
1996
-			return '';
2039
+		if ( ! $this->using_permalinks() ) {
2040
+					return '';
2041
+		}
1997 2042
 		$rules = '';
1998 2043
 		if ( $add_parent_tags ) {
1999 2044
 			$rules .= '<configuration>
@@ -2050,10 +2095,11 @@  discard block
 block discarded – undo
2050 2095
 		if ( $front != $this->index ) { //it doesn't redirect to WP's index.php
2051 2096
 			$this->add_external_rule($regex, $redirect);
2052 2097
 		} else {
2053
-			if ( 'bottom' == $after)
2054
-				$this->extra_rules = array_merge($this->extra_rules, array($regex => $redirect));
2055
-			else
2056
-				$this->extra_rules_top = array_merge($this->extra_rules_top, array($regex => $redirect));
2098
+			if ( 'bottom' == $after) {
2099
+							$this->extra_rules = array_merge($this->extra_rules, array($regex => $redirect));
2100
+			} else {
2101
+							$this->extra_rules_top = array_merge($this->extra_rules_top, array($regex => $redirect));
2102
+			}
2057 2103
 			//$this->extra_rules[$regex] = $redirect;
2058 2104
 		}
2059 2105
 	}
@@ -2135,10 +2181,12 @@  discard block
 block discarded – undo
2135 2181
 	 */
2136 2182
 	public function add_permastruct( $name, $struct, $args = array() ) {
2137 2183
 		// backwards compatibility for the old parameters: $with_front and $ep_mask
2138
-		if ( ! is_array( $args ) )
2139
-			$args = array( 'with_front' => $args );
2140
-		if ( func_num_args() == 4 )
2141
-			$args['ep_mask'] = func_get_arg( 3 );
2184
+		if ( ! is_array( $args ) ) {
2185
+					$args = array( 'with_front' => $args );
2186
+		}
2187
+		if ( func_num_args() == 4 ) {
2188
+					$args['ep_mask'] = func_get_arg( 3 );
2189
+		}
2142 2190
 
2143 2191
 		$defaults = array(
2144 2192
 			'with_front' => true,
@@ -2152,10 +2200,11 @@  discard block
 block discarded – undo
2152 2200
 		$args = array_intersect_key( $args, $defaults );
2153 2201
 		$args = wp_parse_args( $args, $defaults );
2154 2202
 
2155
-		if ( $args['with_front'] )
2156
-			$struct = $this->front . $struct;
2157
-		else
2158
-			$struct = $this->root . $struct;
2203
+		if ( $args['with_front'] ) {
2204
+					$struct = $this->front . $struct;
2205
+		} else {
2206
+					$struct = $this->root . $struct;
2207
+		}
2159 2208
 		$args['struct'] = $struct;
2160 2209
 
2161 2210
 		$this->extra_permastructs[ $name ] = $args;
@@ -2204,10 +2253,12 @@  discard block
 block discarded – undo
2204 2253
 		if ( ! $hard || ! apply_filters( 'flush_rewrite_rules_hard', true ) ) {
2205 2254
 			return;
2206 2255
 		}
2207
-		if ( function_exists( 'save_mod_rewrite_rules' ) )
2208
-			save_mod_rewrite_rules();
2209
-		if ( function_exists( 'iis7_save_url_rewrite_rules' ) )
2210
-			iis7_save_url_rewrite_rules();
2256
+		if ( function_exists( 'save_mod_rewrite_rules' ) ) {
2257
+					save_mod_rewrite_rules();
2258
+		}
2259
+		if ( function_exists( 'iis7_save_url_rewrite_rules' ) ) {
2260
+					iis7_save_url_rewrite_rules();
2261
+		}
2211 2262
 	}
2212 2263
 
2213 2264
 	/**
@@ -2225,8 +2276,9 @@  discard block
 block discarded – undo
2225 2276
 		$this->permalink_structure = get_option('permalink_structure');
2226 2277
 		$this->front = substr($this->permalink_structure, 0, strpos($this->permalink_structure, '%'));
2227 2278
 		$this->root = '';
2228
-		if ( $this->using_index_permalinks() )
2229
-			$this->root = $this->index . '/';
2279
+		if ( $this->using_index_permalinks() ) {
2280
+					$this->root = $this->index . '/';
2281
+		}
2230 2282
 		unset($this->author_structure);
2231 2283
 		unset($this->date_structure);
2232 2284
 		unset($this->page_structure);
@@ -2236,10 +2288,11 @@  discard block
 block discarded – undo
2236 2288
 		$this->use_trailing_slashes = ( '/' == substr($this->permalink_structure, -1, 1) );
2237 2289
 
2238 2290
 		// Enable generic rules for pages if permalink structure doesn't begin with a wildcard.
2239
-		if ( preg_match("/^[^%]*%(?:postname|category|tag|author)%/", $this->permalink_structure) )
2240
-			 $this->use_verbose_page_rules = true;
2241
-		else
2242
-			$this->use_verbose_page_rules = false;
2291
+		if ( preg_match("/^[^%]*%(?:postname|category|tag|author)%/", $this->permalink_structure) ) {
2292
+					 $this->use_verbose_page_rules = true;
2293
+		} else {
2294
+					$this->use_verbose_page_rules = false;
2295
+		}
2243 2296
 	}
2244 2297
 
2245 2298
 	/**
Please login to merge, or discard this patch.
src/wp-includes/session.php 2 patches
Indentation   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -1,9 +1,9 @@
 block discarded – undo
1 1
 <?php
2 2
 /**
3
- * Abstract class for managing user session tokens.
4
- *
5
- * @since 4.0.0
6
- */
3
+	 * Abstract class for managing user session tokens.
4
+	 *
5
+	 * @since 4.0.0
6
+	 */
7 7
 abstract class WP_Session_Tokens {
8 8
 
9 9
 	/**
Please login to merge, or discard this patch.
Spacing   +63 added lines, -63 removed lines patch added patch discarded remove patch
@@ -22,7 +22,7 @@  discard block
 block discarded – undo
22 22
 	 *
23 23
 	 * @param int $user_id User whose session to manage.
24 24
 	 */
25
-	protected function __construct( $user_id ) {
25
+	protected function __construct($user_id) {
26 26
 		$this->user_id = $user_id;
27 27
 	}
28 28
 
@@ -38,7 +38,7 @@  discard block
 block discarded – undo
38 38
 	 *
39 39
 	 * @param int $user_id User whose session to manage.
40 40
 	 */
41
-	final public static function get_instance( $user_id ) {
41
+	final public static function get_instance($user_id) {
42 42
 		/**
43 43
 		 * Filter the session token manager used.
44 44
 		 *
@@ -47,8 +47,8 @@  discard block
 block discarded – undo
47 47
 		 * @param string $session Name of class to use as the manager.
48 48
 		 *                        Default 'WP_User_Meta_Session_Tokens'.
49 49
 		 */
50
-		$manager = apply_filters( 'session_token_manager', 'WP_User_Meta_Session_Tokens' );
51
-		return new $manager( $user_id );
50
+		$manager = apply_filters('session_token_manager', 'WP_User_Meta_Session_Tokens');
51
+		return new $manager($user_id);
52 52
 	}
53 53
 
54 54
 	/**
@@ -60,12 +60,12 @@  discard block
 block discarded – undo
60 60
 	 * @param string $token Session token to hash.
61 61
 	 * @return string A hash of the session token (a verifier).
62 62
 	 */
63
-	final private function hash_token( $token ) {
63
+	final private function hash_token($token) {
64 64
 		// If ext/hash is not present, use sha1() instead.
65
-		if ( function_exists( 'hash' ) ) {
66
-			return hash( 'sha256', $token );
65
+		if (function_exists('hash')) {
66
+			return hash('sha256', $token);
67 67
 		} else {
68
-			return sha1( $token );
68
+			return sha1($token);
69 69
 		}
70 70
 	}
71 71
 
@@ -78,9 +78,9 @@  discard block
 block discarded – undo
78 78
 	 * @param string $token Session token
79 79
 	 * @return array User session
80 80
 	 */
81
-	final public function get( $token ) {
82
-		$verifier = $this->hash_token( $token );
83
-		return $this->get_session( $verifier );
81
+	final public function get($token) {
82
+		$verifier = $this->hash_token($token);
83
+		return $this->get_session($verifier);
84 84
 	}
85 85
 
86 86
 	/**
@@ -94,9 +94,9 @@  discard block
 block discarded – undo
94 94
 	 * @param string $token Token to verify.
95 95
 	 * @return bool Whether the token is valid for the user.
96 96
 	 */
97
-	final public function verify( $token ) {
98
-		$verifier = $this->hash_token( $token );
99
-		return (bool) $this->get_session( $verifier );
97
+	final public function verify($token) {
98
+		$verifier = $this->hash_token($token);
99
+		return (bool) $this->get_session($verifier);
100 100
 	}
101 101
 
102 102
 	/**
@@ -116,7 +116,7 @@  discard block
 block discarded – undo
116 116
 	 * @param int $expiration Session expiration timestamp.
117 117
 	 * @return string Session token.
118 118
 	 */
119
-	final public function create( $expiration ) {
119
+	final public function create($expiration) {
120 120
 		/**
121 121
 		 * Filter the information attached to the newly created session.
122 122
 		 *
@@ -128,25 +128,25 @@  discard block
 block discarded – undo
128 128
 		 * @param array $session Array of extra data.
129 129
 		 * @param int   $user_id User ID.
130 130
 		 */
131
-		$session = apply_filters( 'attach_session_information', array(), $this->user_id );
131
+		$session = apply_filters('attach_session_information', array(), $this->user_id);
132 132
 		$session['expiration'] = $expiration;
133 133
 
134 134
 		// IP address.
135
-		if ( !empty( $_SERVER['REMOTE_ADDR'] ) ) {
135
+		if ( ! empty($_SERVER['REMOTE_ADDR'])) {
136 136
 			$session['ip'] = $_SERVER['REMOTE_ADDR'];
137 137
 		}
138 138
 
139 139
 		// User-agent.
140
-		if ( ! empty( $_SERVER['HTTP_USER_AGENT'] ) ) {
141
-			$session['ua'] = wp_unslash( $_SERVER['HTTP_USER_AGENT'] );
140
+		if ( ! empty($_SERVER['HTTP_USER_AGENT'])) {
141
+			$session['ua'] = wp_unslash($_SERVER['HTTP_USER_AGENT']);
142 142
 		}
143 143
 
144 144
 		// Timestamp
145 145
 		$session['login'] = time();
146 146
 
147
-		$token = wp_generate_password( 43, false, false );
147
+		$token = wp_generate_password(43, false, false);
148 148
 
149
-		$this->update( $token, $session );
149
+		$this->update($token, $session);
150 150
 
151 151
 		return $token;
152 152
 	}
@@ -160,9 +160,9 @@  discard block
 block discarded – undo
160 160
 	 * @param string $token Session token to update.
161 161
 	 * @param array  $session Session information.
162 162
 	 */
163
-	final public function update( $token, $session ) {
164
-		$verifier = $this->hash_token( $token );
165
-		$this->update_session( $verifier, $session );
163
+	final public function update($token, $session) {
164
+		$verifier = $this->hash_token($token);
165
+		$this->update_session($verifier, $session);
166 166
 	}
167 167
 
168 168
 	/**
@@ -173,9 +173,9 @@  discard block
 block discarded – undo
173 173
 	 *
174 174
 	 * @param string $token Session token to destroy.
175 175
 	 */
176
-	final public function destroy( $token ) {
177
-		$verifier = $this->hash_token( $token );
178
-		$this->update_session( $verifier, null );
176
+	final public function destroy($token) {
177
+		$verifier = $this->hash_token($token);
178
+		$this->update_session($verifier, null);
179 179
 	}
180 180
 
181 181
 	/**
@@ -187,11 +187,11 @@  discard block
 block discarded – undo
187 187
 	 *
188 188
 	 * @param string $token_to_keep Session token to keep.
189 189
 	 */
190
-	final public function destroy_others( $token_to_keep ) {
191
-		$verifier = $this->hash_token( $token_to_keep );
192
-		$session = $this->get_session( $verifier );
193
-		if ( $session ) {
194
-			$this->destroy_other_sessions( $verifier );
190
+	final public function destroy_others($token_to_keep) {
191
+		$verifier = $this->hash_token($token_to_keep);
192
+		$session = $this->get_session($verifier);
193
+		if ($session) {
194
+			$this->destroy_other_sessions($verifier);
195 195
 		} else {
196 196
 			$this->destroy_all_sessions();
197 197
 		}
@@ -207,7 +207,7 @@  discard block
 block discarded – undo
207 207
 	 * @param array $session Session to check.
208 208
 	 * @return bool Whether session is valid.
209 209
 	 */
210
-	final protected function is_still_valid( $session ) {
210
+	final protected function is_still_valid($session) {
211 211
 		return $session['expiration'] >= time();
212 212
 	}
213 213
 
@@ -229,8 +229,8 @@  discard block
 block discarded – undo
229 229
 	 * @static
230 230
 	 */
231 231
 	final public static function destroy_all_for_all_users() {
232
-		$manager = apply_filters( 'session_token_manager', 'WP_User_Meta_Session_Tokens' );
233
-		call_user_func( array( $manager, 'drop_sessions' ) );
232
+		$manager = apply_filters('session_token_manager', 'WP_User_Meta_Session_Tokens');
233
+		call_user_func(array($manager, 'drop_sessions'));
234 234
 	}
235 235
 
236 236
 	/**
@@ -242,7 +242,7 @@  discard block
 block discarded – undo
242 242
 	 * @return array Sessions of a user.
243 243
 	 */
244 244
 	final public function get_all() {
245
-		return array_values( $this->get_sessions() );
245
+		return array_values($this->get_sessions());
246 246
 	}
247 247
 
248 248
 	/**
@@ -264,7 +264,7 @@  discard block
 block discarded – undo
264 264
 	 * @param string $verifier Verifier of the session to retrieve.
265 265
 	 * @return array|null The session, or null if it does not exist.
266 266
 	 */
267
-	abstract protected function get_session( $verifier );
267
+	abstract protected function get_session($verifier);
268 268
 
269 269
 	/**
270 270
 	 * This method should update a session by its verifier.
@@ -276,7 +276,7 @@  discard block
 block discarded – undo
276 276
 	 *
277 277
 	 * @param string $verifier Verifier of the session to update.
278 278
 	 */
279
-	abstract protected function update_session( $verifier, $session = null );
279
+	abstract protected function update_session($verifier, $session = null);
280 280
 
281 281
 	/**
282 282
 	 * This method should destroy all session tokens for this user,
@@ -287,7 +287,7 @@  discard block
 block discarded – undo
287 287
 	 *
288 288
 	 * @param string $verifier Verifier of the session to keep.
289 289
 	 */
290
-	abstract protected function destroy_other_sessions( $verifier );
290
+	abstract protected function destroy_other_sessions($verifier);
291 291
 
292 292
 	/**
293 293
 	 * This method should destroy all sessions for a user.
@@ -323,14 +323,14 @@  discard block
 block discarded – undo
323 323
 	 * @return array Sessions of a user.
324 324
 	 */
325 325
 	protected function get_sessions() {
326
-		$sessions = get_user_meta( $this->user_id, 'session_tokens', true );
326
+		$sessions = get_user_meta($this->user_id, 'session_tokens', true);
327 327
 
328
-		if ( ! is_array( $sessions ) ) {
328
+		if ( ! is_array($sessions)) {
329 329
 			return array();
330 330
 		}
331 331
 
332
-		$sessions = array_map( array( $this, 'prepare_session' ), $sessions );
333
-		return array_filter( $sessions, array( $this, 'is_still_valid' ) );
332
+		$sessions = array_map(array($this, 'prepare_session'), $sessions);
333
+		return array_filter($sessions, array($this, 'is_still_valid'));
334 334
 	}
335 335
 
336 336
 	/**
@@ -339,9 +339,9 @@  discard block
 block discarded – undo
339 339
 	 * @param mixed $session Session or expiration.
340 340
 	 * @return array Session.
341 341
 	 */
342
-	protected function prepare_session( $session ) {
343
-		if ( is_int( $session ) ) {
344
-			return array( 'expiration' => $session );
342
+	protected function prepare_session($session) {
343
+		if (is_int($session)) {
344
+			return array('expiration' => $session);
345 345
 		}
346 346
 
347 347
 		return $session;
@@ -356,11 +356,11 @@  discard block
 block discarded – undo
356 356
 	 * @param string $verifier Verifier of the session to retrieve.
357 357
 	 * @return array|null The session, or null if it does not exist
358 358
 	 */
359
-	protected function get_session( $verifier ) {
359
+	protected function get_session($verifier) {
360 360
 		$sessions = $this->get_sessions();
361 361
 
362
-		if ( isset( $sessions[ $verifier ] ) ) {
363
-			return $sessions[ $verifier ];
362
+		if (isset($sessions[$verifier])) {
363
+			return $sessions[$verifier];
364 364
 		}
365 365
 
366 366
 		return null;
@@ -375,16 +375,16 @@  discard block
 block discarded – undo
375 375
 	 * @param string $verifier Verifier of the session to update.
376 376
 	 * @param array  $session  Optional. Session. Omitting this argument destroys the session.
377 377
 	 */
378
-	protected function update_session( $verifier, $session = null ) {
378
+	protected function update_session($verifier, $session = null) {
379 379
 		$sessions = $this->get_sessions();
380 380
 
381
-		if ( $session ) {
382
-			$sessions[ $verifier ] = $session;
381
+		if ($session) {
382
+			$sessions[$verifier] = $session;
383 383
 		} else {
384
-			unset( $sessions[ $verifier ] );
384
+			unset($sessions[$verifier]);
385 385
 		}
386 386
 
387
-		$this->update_sessions( $sessions );
387
+		$this->update_sessions($sessions);
388 388
 	}
389 389
 
390 390
 	/**
@@ -395,11 +395,11 @@  discard block
 block discarded – undo
395 395
 	 *
396 396
 	 * @param array $sessions Sessions.
397 397
 	 */
398
-	protected function update_sessions( $sessions ) {
399
-		if ( $sessions ) {
400
-			update_user_meta( $this->user_id, 'session_tokens', $sessions );
398
+	protected function update_sessions($sessions) {
399
+		if ($sessions) {
400
+			update_user_meta($this->user_id, 'session_tokens', $sessions);
401 401
 		} else {
402
-			delete_user_meta( $this->user_id, 'session_tokens' );
402
+			delete_user_meta($this->user_id, 'session_tokens');
403 403
 		}
404 404
 	}
405 405
 
@@ -411,9 +411,9 @@  discard block
 block discarded – undo
411 411
 	 *
412 412
 	 * @param string $verifier Verifier of the session to keep.
413 413
 	 */
414
-	protected function destroy_other_sessions( $verifier ) {
415
-		$session = $this->get_session( $verifier );
416
-		$this->update_sessions( array( $verifier => $session ) );
414
+	protected function destroy_other_sessions($verifier) {
415
+		$session = $this->get_session($verifier);
416
+		$this->update_sessions(array($verifier => $session));
417 417
 	}
418 418
 
419 419
 	/**
@@ -423,7 +423,7 @@  discard block
 block discarded – undo
423 423
 	 * @access protected
424 424
 	 */
425 425
 	protected function destroy_all_sessions() {
426
-		$this->update_sessions( array() );
426
+		$this->update_sessions(array());
427 427
 	}
428 428
 
429 429
 	/**
@@ -434,6 +434,6 @@  discard block
 block discarded – undo
434 434
 	 * @static
435 435
 	 */
436 436
 	public static function drop_sessions() {
437
-		delete_metadata( 'user', 0, 'session_tokens', false, true );
437
+		delete_metadata('user', 0, 'session_tokens', false, true);
438 438
 	}
439 439
 }
Please login to merge, or discard this patch.
src/wp-includes/feed-rss.php 2 patches
Indentation   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -1,9 +1,9 @@
 block discarded – undo
1 1
 <?php
2 2
 /**
3
- * RSS 0.92 Feed Template for displaying RSS 0.92 Posts feed.
4
- *
5
- * @package WordPress
6
- */
3
+	 * RSS 0.92 Feed Template for displaying RSS 0.92 Posts feed.
4
+	 *
5
+	 * @package WordPress
6
+	 */
7 7
 
8 8
 header('Content-Type: ' . feed_content_type('rss') . '; charset=' . get_option('blog_charset'), true);
9 9
 $more = 1;
Please login to merge, or discard this patch.
Spacing   +4 added lines, -4 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
-header('Content-Type: ' . feed_content_type('rss') . '; charset=' . get_option('blog_charset'), true);
8
+header('Content-Type: '.feed_content_type('rss').'; charset='.get_option('blog_charset'), true);
9 9
 $more = 1;
10 10
 
11 11
 echo '<?xml version="1.0" encoding="'.get_option('blog_charset').'"?'.'>'; ?>
@@ -16,7 +16,7 @@  discard block
 block discarded – undo
16 16
 	<description><?php bloginfo_rss('description') ?></description>
17 17
 	<lastBuildDate><?php echo mysql2date('D, d M Y H:i:s +0000', get_lastpostmodified('GMT'), false); ?></lastBuildDate>
18 18
 	<docs>http://backend.userland.com/rss092</docs>
19
-	<language><?php bloginfo_rss( 'language' ); ?></language>
19
+	<language><?php bloginfo_rss('language'); ?></language>
20 20
 
21 21
 	<?php
22 22
 	/**
@@ -24,7 +24,7 @@  discard block
 block discarded – undo
24 24
 	 *
25 25
 	 * @since 2.0.0
26 26
 	 */
27
-	do_action( 'rss_head' );
27
+	do_action('rss_head');
28 28
 	?>
29 29
 
30 30
 <?php while (have_posts()) : the_post(); ?>
@@ -38,7 +38,7 @@  discard block
 block discarded – undo
38 38
 		 *
39 39
 		 * @since 2.0.0
40 40
 		 */
41
-		do_action( 'rss_item' );
41
+		do_action('rss_item');
42 42
 		?>
43 43
 	</item>
44 44
 <?php endwhile; ?>
Please login to merge, or discard this patch.
src/wp-includes/admin-bar.php 3 patches
Indentation   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -1,9 +1,9 @@
 block discarded – undo
1 1
 <?php
2 2
 /**
3
- * Admin Bar
4
- *
5
- * This code handles the building and rendering of the press bar.
6
- */
3
+	 * Admin Bar
4
+	 *
5
+	 * This code handles the building and rendering of the press bar.
6
+	 */
7 7
 
8 8
 /**
9 9
  * Instantiate the admin bar object and set it up as a global for access elsewhere.
Please login to merge, or discard this patch.
Spacing   +287 added lines, -287 removed lines patch added patch discarded remove patch
@@ -21,11 +21,11 @@  discard block
 block discarded – undo
21 21
 function _wp_admin_bar_init() {
22 22
 	global $wp_admin_bar;
23 23
 
24
-	if ( ! is_admin_bar_showing() )
24
+	if ( ! is_admin_bar_showing())
25 25
 		return false;
26 26
 
27 27
 	/* Load the admin bar class code ready for instantiation */
28
-	require_once( ABSPATH . WPINC . '/class-wp-admin-bar.php' );
28
+	require_once(ABSPATH.WPINC.'/class-wp-admin-bar.php');
29 29
 
30 30
 	/* Instantiate the admin bar */
31 31
 
@@ -36,8 +36,8 @@  discard block
 block discarded – undo
36 36
 	 *
37 37
 	 * @param string $wp_admin_bar_class Admin bar class to use. Default 'WP_Admin_Bar'.
38 38
 	 */
39
-	$admin_bar_class = apply_filters( 'wp_admin_bar_class', 'WP_Admin_Bar' );
40
-	if ( class_exists( $admin_bar_class ) )
39
+	$admin_bar_class = apply_filters('wp_admin_bar_class', 'WP_Admin_Bar');
40
+	if (class_exists($admin_bar_class))
41 41
 		$wp_admin_bar = new $admin_bar_class;
42 42
 	else
43 43
 		return false;
@@ -64,7 +64,7 @@  discard block
 block discarded – undo
64 64
 function wp_admin_bar_render() {
65 65
 	global $wp_admin_bar;
66 66
 
67
-	if ( ! is_admin_bar_showing() || ! is_object( $wp_admin_bar ) )
67
+	if ( ! is_admin_bar_showing() || ! is_object($wp_admin_bar))
68 68
 		return;
69 69
 
70 70
 	/**
@@ -76,14 +76,14 @@  discard block
 block discarded – undo
76 76
 	 *
77 77
 	 * @param WP_Admin_Bar $wp_admin_bar WP_Admin_Bar instance, passed by reference
78 78
 	 */
79
-	do_action_ref_array( 'admin_bar_menu', array( &$wp_admin_bar ) );
79
+	do_action_ref_array('admin_bar_menu', array(&$wp_admin_bar));
80 80
 
81 81
 	/**
82 82
 	 * Fires before the admin bar is rendered.
83 83
 	 *
84 84
 	 * @since 3.1.0
85 85
 	 */
86
-	do_action( 'wp_before_admin_bar_render' );
86
+	do_action('wp_before_admin_bar_render');
87 87
 
88 88
 	$wp_admin_bar->render();
89 89
 
@@ -92,7 +92,7 @@  discard block
 block discarded – undo
92 92
 	 *
93 93
 	 * @since 3.1.0
94 94
 	 */
95
-	do_action( 'wp_after_admin_bar_render' );
95
+	do_action('wp_after_admin_bar_render');
96 96
 }
97 97
 
98 98
 /**
@@ -102,54 +102,54 @@  discard block
 block discarded – undo
102 102
  *
103 103
  * @param WP_Admin_Bar $wp_admin_bar
104 104
  */
105
-function wp_admin_bar_wp_menu( $wp_admin_bar ) {
106
-	$wp_admin_bar->add_menu( array(
105
+function wp_admin_bar_wp_menu($wp_admin_bar) {
106
+	$wp_admin_bar->add_menu(array(
107 107
 		'id'    => 'wp-logo',
108
-		'title' => '<span class="ab-icon"></span><span class="screen-reader-text">' . __( 'About WordPress' ) . '</span>',
109
-		'href'  => self_admin_url( 'about.php' ),
110
-	) );
108
+		'title' => '<span class="ab-icon"></span><span class="screen-reader-text">'.__('About WordPress').'</span>',
109
+		'href'  => self_admin_url('about.php'),
110
+	));
111 111
 
112
-	if ( is_user_logged_in() ) {
112
+	if (is_user_logged_in()) {
113 113
 		// Add "About WordPress" link
114
-		$wp_admin_bar->add_menu( array(
114
+		$wp_admin_bar->add_menu(array(
115 115
 			'parent' => 'wp-logo',
116 116
 			'id'     => 'about',
117 117
 			'title'  => __('About WordPress'),
118
-			'href'   => self_admin_url( 'about.php' ),
119
-		) );
118
+			'href'   => self_admin_url('about.php'),
119
+		));
120 120
 	}
121 121
 
122 122
 	// Add WordPress.org link
123
-	$wp_admin_bar->add_menu( array(
123
+	$wp_admin_bar->add_menu(array(
124 124
 		'parent'    => 'wp-logo-external',
125 125
 		'id'        => 'wporg',
126 126
 		'title'     => __('WordPress.org'),
127 127
 		'href'      => __('https://wordpress.org/'),
128
-	) );
128
+	));
129 129
 
130 130
 	// Add codex link
131
-	$wp_admin_bar->add_menu( array(
131
+	$wp_admin_bar->add_menu(array(
132 132
 		'parent'    => 'wp-logo-external',
133 133
 		'id'        => 'documentation',
134 134
 		'title'     => __('Documentation'),
135 135
 		'href'      => __('https://codex.wordpress.org/'),
136
-	) );
136
+	));
137 137
 
138 138
 	// Add forums link
139
-	$wp_admin_bar->add_menu( array(
139
+	$wp_admin_bar->add_menu(array(
140 140
 		'parent'    => 'wp-logo-external',
141 141
 		'id'        => 'support-forums',
142 142
 		'title'     => __('Support Forums'),
143 143
 		'href'      => __('https://wordpress.org/support/'),
144
-	) );
144
+	));
145 145
 
146 146
 	// Add feedback link
147
-	$wp_admin_bar->add_menu( array(
147
+	$wp_admin_bar->add_menu(array(
148 148
 		'parent'    => 'wp-logo-external',
149 149
 		'id'        => 'feedback',
150 150
 		'title'     => __('Feedback'),
151 151
 		'href'      => __('https://wordpress.org/support/forum/requests-and-feedback'),
152
-	) );
152
+	));
153 153
 }
154 154
 
155 155
 /**
@@ -159,13 +159,13 @@  discard block
 block discarded – undo
159 159
  *
160 160
  * @param WP_Admin_Bar $wp_admin_bar
161 161
  */
162
-function wp_admin_bar_sidebar_toggle( $wp_admin_bar ) {
163
-	if ( is_admin() ) {
164
-		$wp_admin_bar->add_menu( array(
162
+function wp_admin_bar_sidebar_toggle($wp_admin_bar) {
163
+	if (is_admin()) {
164
+		$wp_admin_bar->add_menu(array(
165 165
 			'id'    => 'menu-toggle',
166
-			'title' => '<span class="ab-icon"></span><span class="screen-reader-text">' . __( 'Menu' ) . '</span>',
166
+			'title' => '<span class="ab-icon"></span><span class="screen-reader-text">'.__('Menu').'</span>',
167 167
 			'href'  => '#',
168
-		) );
168
+		));
169 169
 	}
170 170
 }
171 171
 
@@ -176,27 +176,27 @@  discard block
 block discarded – undo
176 176
  *
177 177
  * @param WP_Admin_Bar $wp_admin_bar
178 178
  */
179
-function wp_admin_bar_my_account_item( $wp_admin_bar ) {
179
+function wp_admin_bar_my_account_item($wp_admin_bar) {
180 180
 	$user_id      = get_current_user_id();
181 181
 	$current_user = wp_get_current_user();
182
-	$profile_url  = get_edit_profile_url( $user_id );
182
+	$profile_url  = get_edit_profile_url($user_id);
183 183
 
184
-	if ( ! $user_id )
184
+	if ( ! $user_id)
185 185
 		return;
186 186
 
187
-	$avatar = get_avatar( $user_id, 26 );
188
-	$howdy  = sprintf( __('Howdy, %1$s'), $current_user->display_name );
189
-	$class  = empty( $avatar ) ? '' : 'with-avatar';
187
+	$avatar = get_avatar($user_id, 26);
188
+	$howdy  = sprintf(__('Howdy, %1$s'), $current_user->display_name);
189
+	$class  = empty($avatar) ? '' : 'with-avatar';
190 190
 
191
-	$wp_admin_bar->add_menu( array(
191
+	$wp_admin_bar->add_menu(array(
192 192
 		'id'        => 'my-account',
193 193
 		'parent'    => 'top-secondary',
194
-		'title'     => $howdy . $avatar,
194
+		'title'     => $howdy.$avatar,
195 195
 		'href'      => $profile_url,
196 196
 		'meta'      => array(
197 197
 			'class'     => $class,
198 198
 		),
199
-	) );
199
+	));
200 200
 }
201 201
 
202 202
 /**
@@ -206,26 +206,26 @@  discard block
 block discarded – undo
206 206
  *
207 207
  * @param WP_Admin_Bar $wp_admin_bar
208 208
  */
209
-function wp_admin_bar_my_account_menu( $wp_admin_bar ) {
209
+function wp_admin_bar_my_account_menu($wp_admin_bar) {
210 210
 	$user_id      = get_current_user_id();
211 211
 	$current_user = wp_get_current_user();
212
-	$profile_url  = get_edit_profile_url( $user_id );
212
+	$profile_url  = get_edit_profile_url($user_id);
213 213
 
214
-	if ( ! $user_id )
214
+	if ( ! $user_id)
215 215
 		return;
216 216
 
217
-	$wp_admin_bar->add_group( array(
217
+	$wp_admin_bar->add_group(array(
218 218
 		'parent' => 'my-account',
219 219
 		'id'     => 'user-actions',
220
-	) );
220
+	));
221 221
 
222
-	$user_info  = get_avatar( $user_id, 64 );
222
+	$user_info  = get_avatar($user_id, 64);
223 223
 	$user_info .= "<span class='display-name'>{$current_user->display_name}</span>";
224 224
 
225
-	if ( $current_user->display_name !== $current_user->user_login )
225
+	if ($current_user->display_name !== $current_user->user_login)
226 226
 		$user_info .= "<span class='username'>{$current_user->user_login}</span>";
227 227
 
228
-	$wp_admin_bar->add_menu( array(
228
+	$wp_admin_bar->add_menu(array(
229 229
 		'parent' => 'user-actions',
230 230
 		'id'     => 'user-info',
231 231
 		'title'  => $user_info,
@@ -233,19 +233,19 @@  discard block
 block discarded – undo
233 233
 		'meta'   => array(
234 234
 			'tabindex' => -1,
235 235
 		),
236
-	) );
237
-	$wp_admin_bar->add_menu( array(
236
+	));
237
+	$wp_admin_bar->add_menu(array(
238 238
 		'parent' => 'user-actions',
239 239
 		'id'     => 'edit-profile',
240
-		'title'  => __( 'Edit My Profile' ),
240
+		'title'  => __('Edit My Profile'),
241 241
 		'href' => $profile_url,
242
-	) );
243
-	$wp_admin_bar->add_menu( array(
242
+	));
243
+	$wp_admin_bar->add_menu(array(
244 244
 		'parent' => 'user-actions',
245 245
 		'id'     => 'logout',
246
-		'title'  => __( 'Log Out' ),
246
+		'title'  => __('Log Out'),
247 247
 		'href'   => wp_logout_url(),
248
-	) );
248
+	));
249 249
 }
250 250
 
251 251
 /**
@@ -255,66 +255,66 @@  discard block
 block discarded – undo
255 255
  *
256 256
  * @param WP_Admin_Bar $wp_admin_bar
257 257
  */
258
-function wp_admin_bar_site_menu( $wp_admin_bar ) {
258
+function wp_admin_bar_site_menu($wp_admin_bar) {
259 259
 	// Don't show for logged out users.
260
-	if ( ! is_user_logged_in() )
260
+	if ( ! is_user_logged_in())
261 261
 		return;
262 262
 
263 263
 	// Show only when the user is a member of this site, or they're a super admin.
264
-	if ( ! is_user_member_of_blog() && ! is_super_admin() )
264
+	if ( ! is_user_member_of_blog() && ! is_super_admin())
265 265
 		return;
266 266
 
267 267
 	$blogname = get_bloginfo('name');
268 268
 
269
-	if ( ! $blogname ) {
270
-		$blogname = preg_replace( '#^(https?://)?(www.)?#', '', get_home_url() );
269
+	if ( ! $blogname) {
270
+		$blogname = preg_replace('#^(https?://)?(www.)?#', '', get_home_url());
271 271
 	}
272 272
 
273
-	if ( is_network_admin() ) {
274
-		$blogname = sprintf( __('Network Admin: %s'), esc_html( get_current_site()->site_name ) );
275
-	} elseif ( is_user_admin() ) {
276
-		$blogname = sprintf( __('User Dashboard: %s'), esc_html( get_current_site()->site_name ) );
273
+	if (is_network_admin()) {
274
+		$blogname = sprintf(__('Network Admin: %s'), esc_html(get_current_site()->site_name));
275
+	} elseif (is_user_admin()) {
276
+		$blogname = sprintf(__('User Dashboard: %s'), esc_html(get_current_site()->site_name));
277 277
 	}
278 278
 
279
-	$title = wp_html_excerpt( $blogname, 40, '&hellip;' );
279
+	$title = wp_html_excerpt($blogname, 40, '&hellip;');
280 280
 
281
-	$wp_admin_bar->add_menu( array(
281
+	$wp_admin_bar->add_menu(array(
282 282
 		'id'    => 'site-name',
283 283
 		'title' => $title,
284
-		'href'  => is_admin() ? home_url( '/' ) : admin_url(),
285
-	) );
284
+		'href'  => is_admin() ? home_url('/') : admin_url(),
285
+	));
286 286
 
287 287
 	// Create submenu items.
288 288
 
289
-	if ( is_admin() ) {
289
+	if (is_admin()) {
290 290
 		// Add an option to visit the site.
291
-		$wp_admin_bar->add_menu( array(
291
+		$wp_admin_bar->add_menu(array(
292 292
 			'parent' => 'site-name',
293 293
 			'id'     => 'view-site',
294
-			'title'  => __( 'Visit Site' ),
295
-			'href'   => home_url( '/' ),
296
-		) );
294
+			'title'  => __('Visit Site'),
295
+			'href'   => home_url('/'),
296
+		));
297 297
 
298
-		if ( is_blog_admin() && is_multisite() && current_user_can( 'manage_sites' ) ) {
299
-			$wp_admin_bar->add_menu( array(
298
+		if (is_blog_admin() && is_multisite() && current_user_can('manage_sites')) {
299
+			$wp_admin_bar->add_menu(array(
300 300
 				'parent' => 'site-name',
301 301
 				'id'     => 'edit-site',
302
-				'title'  => __( 'Edit Site' ),
303
-				'href'   => network_admin_url( 'site-info.php?id=' . get_current_blog_id() ),
304
-			) );
302
+				'title'  => __('Edit Site'),
303
+				'href'   => network_admin_url('site-info.php?id='.get_current_blog_id()),
304
+			));
305 305
 		}
306 306
 
307 307
 	} else {
308 308
 		// We're on the front end, link to the Dashboard.
309
-		$wp_admin_bar->add_menu( array(
309
+		$wp_admin_bar->add_menu(array(
310 310
 			'parent' => 'site-name',
311 311
 			'id'     => 'dashboard',
312
-			'title'  => __( 'Dashboard' ),
312
+			'title'  => __('Dashboard'),
313 313
 			'href'   => admin_url(),
314
-		) );
314
+		));
315 315
 
316 316
 		// Add the appearance submenu items.
317
-		wp_admin_bar_appearance_menu( $wp_admin_bar );
317
+		wp_admin_bar_appearance_menu($wp_admin_bar);
318 318
 	}
319 319
 }
320 320
 
@@ -325,24 +325,24 @@  discard block
 block discarded – undo
325 325
  *
326 326
  * @param WP_Admin_Bar $wp_admin_bar WP_Admin_Bar instance.
327 327
  */
328
-function wp_admin_bar_customize_menu( $wp_admin_bar ) {
328
+function wp_admin_bar_customize_menu($wp_admin_bar) {
329 329
 	// Don't show for users who can't access the customizer or when in the admin.
330
-	if ( ! current_user_can( 'customize' ) || is_admin() ) {
330
+	if ( ! current_user_can('customize') || is_admin()) {
331 331
 		return;
332 332
 	}
333 333
 
334
-	$current_url = ( is_ssl() ? 'https://' : 'http://' ) . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
335
-	$customize_url = add_query_arg( 'url', urlencode( $current_url ), wp_customize_url() );
334
+	$current_url = (is_ssl() ? 'https://' : 'http://').$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'];
335
+	$customize_url = add_query_arg('url', urlencode($current_url), wp_customize_url());
336 336
 
337
-	$wp_admin_bar->add_menu( array(
337
+	$wp_admin_bar->add_menu(array(
338 338
 		'id'     => 'customize',
339
-		'title'  => __( 'Customize' ),
339
+		'title'  => __('Customize'),
340 340
 		'href'   => $customize_url,
341 341
 		'meta'   => array(
342 342
 			'class' => 'hide-if-no-customize',
343 343
 		),
344
-	) );
345
-	add_action( 'wp_before_admin_bar_render', 'wp_customize_support_script' );
344
+	));
345
+	add_action('wp_before_admin_bar_render', 'wp_customize_support_script');
346 346
 }
347 347
 
348 348
 /**
@@ -352,132 +352,132 @@  discard block
 block discarded – undo
352 352
  *
353 353
  * @param WP_Admin_Bar $wp_admin_bar
354 354
  */
355
-function wp_admin_bar_my_sites_menu( $wp_admin_bar ) {
355
+function wp_admin_bar_my_sites_menu($wp_admin_bar) {
356 356
 	// Don't show for logged out users or single site mode.
357
-	if ( ! is_user_logged_in() || ! is_multisite() )
357
+	if ( ! is_user_logged_in() || ! is_multisite())
358 358
 		return;
359 359
 
360 360
 	// Show only when the user has at least one site, or they're a super admin.
361
-	if ( count( $wp_admin_bar->user->blogs ) < 1 && ! is_super_admin() )
361
+	if (count($wp_admin_bar->user->blogs) < 1 && ! is_super_admin())
362 362
 		return;
363 363
 
364
-	if ( $wp_admin_bar->user->active_blog ) {
365
-		$my_sites_url = get_admin_url( $wp_admin_bar->user->active_blog->blog_id, 'my-sites.php' );
364
+	if ($wp_admin_bar->user->active_blog) {
365
+		$my_sites_url = get_admin_url($wp_admin_bar->user->active_blog->blog_id, 'my-sites.php');
366 366
 	} else {
367
-		$my_sites_url = admin_url( 'my-sites.php' );
367
+		$my_sites_url = admin_url('my-sites.php');
368 368
 	}
369 369
 
370
-	$wp_admin_bar->add_menu( array(
370
+	$wp_admin_bar->add_menu(array(
371 371
 		'id'    => 'my-sites',
372
-		'title' => __( 'My Sites' ),
372
+		'title' => __('My Sites'),
373 373
 		'href'  => $my_sites_url,
374
-	) );
374
+	));
375 375
 
376
-	if ( is_super_admin() ) {
377
-		$wp_admin_bar->add_group( array(
376
+	if (is_super_admin()) {
377
+		$wp_admin_bar->add_group(array(
378 378
 			'parent' => 'my-sites',
379 379
 			'id'     => 'my-sites-super-admin',
380
-		) );
380
+		));
381 381
 
382
-		$wp_admin_bar->add_menu( array(
382
+		$wp_admin_bar->add_menu(array(
383 383
 			'parent' => 'my-sites-super-admin',
384 384
 			'id'     => 'network-admin',
385 385
 			'title'  => __('Network Admin'),
386 386
 			'href'   => network_admin_url(),
387
-		) );
387
+		));
388 388
 
389
-		$wp_admin_bar->add_menu( array(
389
+		$wp_admin_bar->add_menu(array(
390 390
 			'parent' => 'network-admin',
391 391
 			'id'     => 'network-admin-d',
392
-			'title'  => __( 'Dashboard' ),
392
+			'title'  => __('Dashboard'),
393 393
 			'href'   => network_admin_url(),
394
-		) );
395
-		$wp_admin_bar->add_menu( array(
394
+		));
395
+		$wp_admin_bar->add_menu(array(
396 396
 			'parent' => 'network-admin',
397 397
 			'id'     => 'network-admin-s',
398
-			'title'  => __( 'Sites' ),
399
-			'href'   => network_admin_url( 'sites.php' ),
400
-		) );
401
-		$wp_admin_bar->add_menu( array(
398
+			'title'  => __('Sites'),
399
+			'href'   => network_admin_url('sites.php'),
400
+		));
401
+		$wp_admin_bar->add_menu(array(
402 402
 			'parent' => 'network-admin',
403 403
 			'id'     => 'network-admin-u',
404
-			'title'  => __( 'Users' ),
405
-			'href'   => network_admin_url( 'users.php' ),
406
-		) );
407
-		$wp_admin_bar->add_menu( array(
404
+			'title'  => __('Users'),
405
+			'href'   => network_admin_url('users.php'),
406
+		));
407
+		$wp_admin_bar->add_menu(array(
408 408
 			'parent' => 'network-admin',
409 409
 			'id'     => 'network-admin-t',
410
-			'title'  => __( 'Themes' ),
411
-			'href'   => network_admin_url( 'themes.php' ),
412
-		) );
413
-		$wp_admin_bar->add_menu( array(
410
+			'title'  => __('Themes'),
411
+			'href'   => network_admin_url('themes.php'),
412
+		));
413
+		$wp_admin_bar->add_menu(array(
414 414
 			'parent' => 'network-admin',
415 415
 			'id'     => 'network-admin-p',
416
-			'title'  => __( 'Plugins' ),
417
-			'href'   => network_admin_url( 'plugins.php' ),
418
-		) );
416
+			'title'  => __('Plugins'),
417
+			'href'   => network_admin_url('plugins.php'),
418
+		));
419 419
 	}
420 420
 
421 421
 	// Add site links
422
-	$wp_admin_bar->add_group( array(
422
+	$wp_admin_bar->add_group(array(
423 423
 		'parent' => 'my-sites',
424 424
 		'id'     => 'my-sites-list',
425 425
 		'meta'   => array(
426 426
 			'class' => is_super_admin() ? 'ab-sub-secondary' : '',
427 427
 		),
428
-	) );
428
+	));
429 429
 
430
-	foreach ( (array) $wp_admin_bar->user->blogs as $blog ) {
431
-		switch_to_blog( $blog->userblog_id );
430
+	foreach ((array) $wp_admin_bar->user->blogs as $blog) {
431
+		switch_to_blog($blog->userblog_id);
432 432
 
433 433
 		$blavatar = '<div class="blavatar"></div>';
434 434
 
435 435
 		$blogname = $blog->blogname;
436 436
 
437
-		if ( ! $blogname ) {
438
-			$blogname = preg_replace( '#^(https?://)?(www.)?#', '', get_home_url() );
437
+		if ( ! $blogname) {
438
+			$blogname = preg_replace('#^(https?://)?(www.)?#', '', get_home_url());
439 439
 		}
440 440
 
441
-		$menu_id  = 'blog-' . $blog->userblog_id;
441
+		$menu_id = 'blog-'.$blog->userblog_id;
442 442
 
443
-		$wp_admin_bar->add_menu( array(
443
+		$wp_admin_bar->add_menu(array(
444 444
 			'parent'    => 'my-sites-list',
445 445
 			'id'        => $menu_id,
446
-			'title'     => $blavatar . $blogname,
446
+			'title'     => $blavatar.$blogname,
447 447
 			'href'      => admin_url(),
448
-		) );
448
+		));
449 449
 
450
-		$wp_admin_bar->add_menu( array(
450
+		$wp_admin_bar->add_menu(array(
451 451
 			'parent' => $menu_id,
452
-			'id'     => $menu_id . '-d',
453
-			'title'  => __( 'Dashboard' ),
452
+			'id'     => $menu_id.'-d',
453
+			'title'  => __('Dashboard'),
454 454
 			'href'   => admin_url(),
455
-		) );
455
+		));
456 456
 
457
-		if ( current_user_can( get_post_type_object( 'post' )->cap->create_posts ) ) {
458
-			$wp_admin_bar->add_menu( array(
457
+		if (current_user_can(get_post_type_object('post')->cap->create_posts)) {
458
+			$wp_admin_bar->add_menu(array(
459 459
 				'parent' => $menu_id,
460
-				'id'     => $menu_id . '-n',
461
-				'title'  => __( 'New Post' ),
462
-				'href'   => admin_url( 'post-new.php' ),
463
-			) );
460
+				'id'     => $menu_id.'-n',
461
+				'title'  => __('New Post'),
462
+				'href'   => admin_url('post-new.php'),
463
+			));
464 464
 		}
465 465
 
466
-		if ( current_user_can( 'edit_posts' ) ) {
467
-			$wp_admin_bar->add_menu( array(
466
+		if (current_user_can('edit_posts')) {
467
+			$wp_admin_bar->add_menu(array(
468 468
 				'parent' => $menu_id,
469
-				'id'     => $menu_id . '-c',
470
-				'title'  => __( 'Manage Comments' ),
471
-				'href'   => admin_url( 'edit-comments.php' ),
472
-			) );
469
+				'id'     => $menu_id.'-c',
470
+				'title'  => __('Manage Comments'),
471
+				'href'   => admin_url('edit-comments.php'),
472
+			));
473 473
 		}
474 474
 
475
-		$wp_admin_bar->add_menu( array(
475
+		$wp_admin_bar->add_menu(array(
476 476
 			'parent' => $menu_id,
477
-			'id'     => $menu_id . '-v',
478
-			'title'  => __( 'Visit Site' ),
479
-			'href'   => home_url( '/' ),
480
-		) );
477
+			'id'     => $menu_id.'-v',
478
+			'title'  => __('Visit Site'),
479
+			'href'   => home_url('/'),
480
+		));
481 481
 
482 482
 		restore_current_blog();
483 483
 	}
@@ -490,21 +490,21 @@  discard block
 block discarded – undo
490 490
  *
491 491
  * @param WP_Admin_Bar $wp_admin_bar
492 492
  */
493
-function wp_admin_bar_shortlink_menu( $wp_admin_bar ) {
494
-	$short = wp_get_shortlink( 0, 'query' );
493
+function wp_admin_bar_shortlink_menu($wp_admin_bar) {
494
+	$short = wp_get_shortlink(0, 'query');
495 495
 	$id = 'get-shortlink';
496 496
 
497
-	if ( empty( $short ) )
497
+	if (empty($short))
498 498
 		return;
499 499
 
500
-	$html = '<input class="shortlink-input" type="text" readonly="readonly" value="' . esc_attr( $short ) . '" />';
500
+	$html = '<input class="shortlink-input" type="text" readonly="readonly" value="'.esc_attr($short).'" />';
501 501
 
502
-	$wp_admin_bar->add_menu( array(
502
+	$wp_admin_bar->add_menu(array(
503 503
 		'id' => $id,
504
-		'title' => __( 'Shortlink' ),
504
+		'title' => __('Shortlink'),
505 505
 		'href' => $short,
506
-		'meta' => array( 'html' => $html ),
507
-	) );
506
+		'meta' => array('html' => $html),
507
+	));
508 508
 }
509 509
 
510 510
 /**
@@ -517,76 +517,76 @@  discard block
 block discarded – undo
517 517
  *
518 518
  * @param WP_Admin_Bar $wp_admin_bar
519 519
  */
520
-function wp_admin_bar_edit_menu( $wp_admin_bar ) {
520
+function wp_admin_bar_edit_menu($wp_admin_bar) {
521 521
 	global $tag, $wp_the_query;
522 522
 
523
-	if ( is_admin() ) {
523
+	if (is_admin()) {
524 524
 		$current_screen = get_current_screen();
525 525
 		$post = get_post();
526 526
 
527
-		if ( 'post' == $current_screen->base
527
+		if ('post' == $current_screen->base
528 528
 			&& 'add' != $current_screen->action
529
-			&& ( $post_type_object = get_post_type_object( $post->post_type ) )
530
-			&& current_user_can( 'read_post', $post->ID )
531
-			&& ( $post_type_object->public )
532
-			&& ( $post_type_object->show_in_admin_bar ) )
529
+			&& ($post_type_object = get_post_type_object($post->post_type))
530
+			&& current_user_can('read_post', $post->ID)
531
+			&& ($post_type_object->public)
532
+			&& ($post_type_object->show_in_admin_bar))
533 533
 		{
534
-			if ( 'draft' == $post->post_status ) {
535
-				$preview_link = set_url_scheme( get_permalink( $post->ID ) );
534
+			if ('draft' == $post->post_status) {
535
+				$preview_link = set_url_scheme(get_permalink($post->ID));
536 536
 				/** This filter is documented in wp-admin/includes/meta-boxes.php */
537
-				$preview_link = apply_filters( 'preview_post_link', add_query_arg( 'preview', 'true', $preview_link ), $post );
538
-				$wp_admin_bar->add_menu( array(
537
+				$preview_link = apply_filters('preview_post_link', add_query_arg('preview', 'true', $preview_link), $post);
538
+				$wp_admin_bar->add_menu(array(
539 539
 					'id' => 'preview',
540 540
 					'title' => $post_type_object->labels->view_item,
541
-					'href' => esc_url( $preview_link ),
542
-					'meta' => array( 'target' => 'wp-preview-' . $post->ID ),
543
-				) );
541
+					'href' => esc_url($preview_link),
542
+					'meta' => array('target' => 'wp-preview-'.$post->ID),
543
+				));
544 544
 			} else {
545
-				$wp_admin_bar->add_menu( array(
545
+				$wp_admin_bar->add_menu(array(
546 546
 					'id' => 'view',
547 547
 					'title' => $post_type_object->labels->view_item,
548
-					'href' => get_permalink( $post->ID )
549
-				) );
548
+					'href' => get_permalink($post->ID)
549
+				));
550 550
 			}
551
-		} elseif ( 'edit-tags' == $current_screen->base
552
-			&& isset( $tag ) && is_object( $tag )
553
-			&& ( $tax = get_taxonomy( $tag->taxonomy ) )
554
-			&& $tax->public )
551
+		} elseif ('edit-tags' == $current_screen->base
552
+			&& isset($tag) && is_object($tag)
553
+			&& ($tax = get_taxonomy($tag->taxonomy))
554
+			&& $tax->public)
555 555
 		{
556
-			$wp_admin_bar->add_menu( array(
556
+			$wp_admin_bar->add_menu(array(
557 557
 				'id' => 'view',
558 558
 				'title' => $tax->labels->view_item,
559
-				'href' => get_term_link( $tag )
560
-			) );
559
+				'href' => get_term_link($tag)
560
+			));
561 561
 		}
562 562
 	} else {
563 563
 		$current_object = $wp_the_query->get_queried_object();
564 564
 
565
-		if ( empty( $current_object ) )
565
+		if (empty($current_object))
566 566
 			return;
567 567
 
568
-		if ( ! empty( $current_object->post_type )
569
-			&& ( $post_type_object = get_post_type_object( $current_object->post_type ) )
570
-			&& current_user_can( 'edit_post', $current_object->ID )
568
+		if ( ! empty($current_object->post_type)
569
+			&& ($post_type_object = get_post_type_object($current_object->post_type))
570
+			&& current_user_can('edit_post', $current_object->ID)
571 571
 			&& $post_type_object->show_ui && $post_type_object->show_in_admin_bar
572
-			&& $edit_post_link = get_edit_post_link( $current_object->ID ) )
572
+			&& $edit_post_link = get_edit_post_link($current_object->ID))
573 573
 		{
574
-			$wp_admin_bar->add_menu( array(
574
+			$wp_admin_bar->add_menu(array(
575 575
 				'id' => 'edit',
576 576
 				'title' => $post_type_object->labels->edit_item,
577 577
 				'href' => $edit_post_link
578
-			) );
579
-		} elseif ( ! empty( $current_object->taxonomy )
580
-			&& ( $tax = get_taxonomy( $current_object->taxonomy ) )
581
-			&& current_user_can( $tax->cap->edit_terms )
578
+			));
579
+		} elseif ( ! empty($current_object->taxonomy)
580
+			&& ($tax = get_taxonomy($current_object->taxonomy))
581
+			&& current_user_can($tax->cap->edit_terms)
582 582
 			&& $tax->show_ui
583
-			&& $edit_term_link = get_edit_term_link( $current_object->term_id, $current_object->taxonomy ) )
583
+			&& $edit_term_link = get_edit_term_link($current_object->term_id, $current_object->taxonomy))
584 584
 		{
585
-			$wp_admin_bar->add_menu( array(
585
+			$wp_admin_bar->add_menu(array(
586 586
 				'id' => 'edit',
587 587
 				'title' => $tax->labels->edit_item,
588 588
 				'href' => $edit_term_link
589
-			) );
589
+			));
590 590
 		}
591 591
 	}
592 592
 }
@@ -598,60 +598,60 @@  discard block
 block discarded – undo
598 598
  *
599 599
  * @param WP_Admin_Bar $wp_admin_bar
600 600
  */
601
-function wp_admin_bar_new_content_menu( $wp_admin_bar ) {
601
+function wp_admin_bar_new_content_menu($wp_admin_bar) {
602 602
 	$actions = array();
603 603
 
604
-	$cpts = (array) get_post_types( array( 'show_in_admin_bar' => true ), 'objects' );
604
+	$cpts = (array) get_post_types(array('show_in_admin_bar' => true), 'objects');
605 605
 
606
-	if ( isset( $cpts['post'] ) && current_user_can( $cpts['post']->cap->create_posts ) )
607
-		$actions[ 'post-new.php' ] = array( $cpts['post']->labels->name_admin_bar, 'new-post' );
606
+	if (isset($cpts['post']) && current_user_can($cpts['post']->cap->create_posts))
607
+		$actions['post-new.php'] = array($cpts['post']->labels->name_admin_bar, 'new-post');
608 608
 
609
-	if ( isset( $cpts['attachment'] ) && current_user_can( 'upload_files' ) )
610
-		$actions[ 'media-new.php' ] = array( $cpts['attachment']->labels->name_admin_bar, 'new-media' );
609
+	if (isset($cpts['attachment']) && current_user_can('upload_files'))
610
+		$actions['media-new.php'] = array($cpts['attachment']->labels->name_admin_bar, 'new-media');
611 611
 
612
-	if ( current_user_can( 'manage_links' ) )
613
-		$actions[ 'link-add.php' ] = array( _x( 'Link', 'add new from admin bar' ), 'new-link' );
612
+	if (current_user_can('manage_links'))
613
+		$actions['link-add.php'] = array(_x('Link', 'add new from admin bar'), 'new-link');
614 614
 
615
-	if ( isset( $cpts['page'] ) && current_user_can( $cpts['page']->cap->create_posts ) )
616
-		$actions[ 'post-new.php?post_type=page' ] = array( $cpts['page']->labels->name_admin_bar, 'new-page' );
615
+	if (isset($cpts['page']) && current_user_can($cpts['page']->cap->create_posts))
616
+		$actions['post-new.php?post_type=page'] = array($cpts['page']->labels->name_admin_bar, 'new-page');
617 617
 
618
-	unset( $cpts['post'], $cpts['page'], $cpts['attachment'] );
618
+	unset($cpts['post'], $cpts['page'], $cpts['attachment']);
619 619
 
620 620
 	// Add any additional custom post types.
621
-	foreach ( $cpts as $cpt ) {
622
-		if ( ! current_user_can( $cpt->cap->create_posts ) )
621
+	foreach ($cpts as $cpt) {
622
+		if ( ! current_user_can($cpt->cap->create_posts))
623 623
 			continue;
624 624
 
625
-		$key = 'post-new.php?post_type=' . $cpt->name;
626
-		$actions[ $key ] = array( $cpt->labels->name_admin_bar, 'new-' . $cpt->name );
625
+		$key = 'post-new.php?post_type='.$cpt->name;
626
+		$actions[$key] = array($cpt->labels->name_admin_bar, 'new-'.$cpt->name);
627 627
 	}
628 628
 	// Avoid clash with parent node and a 'content' post type.
629
-	if ( isset( $actions['post-new.php?post_type=content'] ) )
629
+	if (isset($actions['post-new.php?post_type=content']))
630 630
 		$actions['post-new.php?post_type=content'][1] = 'add-new-content';
631 631
 
632
-	if ( current_user_can( 'create_users' ) || current_user_can( 'promote_users' ) )
633
-		$actions[ 'user-new.php' ] = array( _x( 'User', 'add new from admin bar' ), 'new-user' );
632
+	if (current_user_can('create_users') || current_user_can('promote_users'))
633
+		$actions['user-new.php'] = array(_x('User', 'add new from admin bar'), 'new-user');
634 634
 
635
-	if ( ! $actions )
635
+	if ( ! $actions)
636 636
 		return;
637 637
 
638
-	$title = '<span class="ab-icon"></span><span class="ab-label">' . _x( 'New', 'admin bar menu group label' ) . '</span>';
638
+	$title = '<span class="ab-icon"></span><span class="ab-label">'._x('New', 'admin bar menu group label').'</span>';
639 639
 
640
-	$wp_admin_bar->add_menu( array(
640
+	$wp_admin_bar->add_menu(array(
641 641
 		'id'    => 'new-content',
642 642
 		'title' => $title,
643
-		'href'  => admin_url( current( array_keys( $actions ) ) ),
644
-	) );
643
+		'href'  => admin_url(current(array_keys($actions))),
644
+	));
645 645
 
646
-	foreach ( $actions as $link => $action ) {
647
-		list( $title, $id ) = $action;
646
+	foreach ($actions as $link => $action) {
647
+		list($title, $id) = $action;
648 648
 
649
-		$wp_admin_bar->add_menu( array(
649
+		$wp_admin_bar->add_menu(array(
650 650
 			'parent'    => 'new-content',
651 651
 			'id'        => $id,
652 652
 			'title'     => $title,
653
-			'href'      => admin_url( $link )
654
-		) );
653
+			'href'      => admin_url($link)
654
+		));
655 655
 	}
656 656
 }
657 657
 
@@ -662,23 +662,23 @@  discard block
 block discarded – undo
662 662
  *
663 663
  * @param WP_Admin_Bar $wp_admin_bar
664 664
  */
665
-function wp_admin_bar_comments_menu( $wp_admin_bar ) {
666
-	if ( !current_user_can('edit_posts') )
665
+function wp_admin_bar_comments_menu($wp_admin_bar) {
666
+	if ( ! current_user_can('edit_posts'))
667 667
 		return;
668 668
 
669 669
 	$awaiting_mod = wp_count_comments();
670 670
 	$awaiting_mod = $awaiting_mod->moderated;
671
-	$awaiting_title = esc_attr( sprintf( _n( '%s comment awaiting moderation', '%s comments awaiting moderation', $awaiting_mod ), number_format_i18n( $awaiting_mod ) ) );
671
+	$awaiting_title = esc_attr(sprintf(_n('%s comment awaiting moderation', '%s comments awaiting moderation', $awaiting_mod), number_format_i18n($awaiting_mod)));
672 672
 
673 673
 	$icon  = '<span class="ab-icon"></span>';
674
-	$title = '<span id="ab-awaiting-mod" class="ab-label awaiting-mod pending-count count-' . $awaiting_mod . '">' . number_format_i18n( $awaiting_mod ) . '</span>';
674
+	$title = '<span id="ab-awaiting-mod" class="ab-label awaiting-mod pending-count count-'.$awaiting_mod.'">'.number_format_i18n($awaiting_mod).'</span>';
675 675
 
676
-	$wp_admin_bar->add_menu( array(
676
+	$wp_admin_bar->add_menu(array(
677 677
 		'id'    => 'comments',
678
-		'title' => $icon . $title,
678
+		'title' => $icon.$title,
679 679
 		'href'  => admin_url('edit-comments.php'),
680
-		'meta'  => array( 'title' => $awaiting_title ),
681
-	) );
680
+		'meta'  => array('title' => $awaiting_title),
681
+	));
682 682
 }
683 683
 
684 684
 /**
@@ -688,56 +688,56 @@  discard block
 block discarded – undo
688 688
  *
689 689
  * @param WP_Admin_Bar $wp_admin_bar
690 690
  */
691
-function wp_admin_bar_appearance_menu( $wp_admin_bar ) {
692
-	$wp_admin_bar->add_group( array( 'parent' => 'site-name', 'id' => 'appearance' ) );
691
+function wp_admin_bar_appearance_menu($wp_admin_bar) {
692
+	$wp_admin_bar->add_group(array('parent' => 'site-name', 'id' => 'appearance'));
693 693
 
694
-	if ( current_user_can( 'switch_themes' ) ) {
695
-		$wp_admin_bar->add_menu( array(
694
+	if (current_user_can('switch_themes')) {
695
+		$wp_admin_bar->add_menu(array(
696 696
 			'parent' => 'appearance',
697 697
 			'id'     => 'themes',
698
-			'title'  => __( 'Themes' ),
699
-			'href'   => admin_url( 'themes.php' ),
700
-		) );
698
+			'title'  => __('Themes'),
699
+			'href'   => admin_url('themes.php'),
700
+		));
701 701
 	}
702 702
 
703
-	if ( ! current_user_can( 'edit_theme_options' ) ) {
703
+	if ( ! current_user_can('edit_theme_options')) {
704 704
 		return;
705 705
 	}
706 706
 
707
-	if ( current_theme_supports( 'widgets' )  ) {
708
-		$wp_admin_bar->add_menu( array(
707
+	if (current_theme_supports('widgets')) {
708
+		$wp_admin_bar->add_menu(array(
709 709
 			'parent' => 'appearance',
710 710
 			'id'     => 'widgets',
711
-			'title'  => __( 'Widgets' ),
712
-			'href'   => admin_url( 'widgets.php' ),
713
-		) );
711
+			'title'  => __('Widgets'),
712
+			'href'   => admin_url('widgets.php'),
713
+		));
714 714
 	}
715 715
 
716
-	if ( current_theme_supports( 'menus' ) || current_theme_supports( 'widgets' ) )
717
-		$wp_admin_bar->add_menu( array( 'parent' => 'appearance', 'id' => 'menus', 'title' => __('Menus'), 'href' => admin_url('nav-menus.php') ) );
716
+	if (current_theme_supports('menus') || current_theme_supports('widgets'))
717
+		$wp_admin_bar->add_menu(array('parent' => 'appearance', 'id' => 'menus', 'title' => __('Menus'), 'href' => admin_url('nav-menus.php')));
718 718
 
719
-	if ( current_theme_supports( 'custom-background' ) ) {
720
-		$wp_admin_bar->add_menu( array(
719
+	if (current_theme_supports('custom-background')) {
720
+		$wp_admin_bar->add_menu(array(
721 721
 			'parent' => 'appearance',
722 722
 			'id'     => 'background',
723
-			'title'  => __( 'Background' ),
724
-			'href'   => admin_url( 'themes.php?page=custom-background' ),
723
+			'title'  => __('Background'),
724
+			'href'   => admin_url('themes.php?page=custom-background'),
725 725
 			'meta'   => array(
726 726
 				'class' => 'hide-if-customize',
727 727
 			),
728
-		) );
728
+		));
729 729
 	}
730 730
 
731
-	if ( current_theme_supports( 'custom-header' ) ) {
732
-		$wp_admin_bar->add_menu( array(
731
+	if (current_theme_supports('custom-header')) {
732
+		$wp_admin_bar->add_menu(array(
733 733
 			'parent' => 'appearance',
734 734
 			'id'     => 'header',
735
-			'title'  => __( 'Header' ),
736
-			'href'   => admin_url( 'themes.php?page=custom-header' ),
735
+			'title'  => __('Header'),
736
+			'href'   => admin_url('themes.php?page=custom-header'),
737 737
 			'meta'   => array(
738 738
 				'class' => 'hide-if-customize',
739 739
 			),
740
-		) );
740
+		));
741 741
 	}
742 742
 
743 743
 }
@@ -749,24 +749,24 @@  discard block
 block discarded – undo
749 749
  *
750 750
  * @param WP_Admin_Bar $wp_admin_bar
751 751
  */
752
-function wp_admin_bar_updates_menu( $wp_admin_bar ) {
752
+function wp_admin_bar_updates_menu($wp_admin_bar) {
753 753
 
754 754
 	$update_data = wp_get_update_data();
755 755
 
756
-	if ( !$update_data['counts']['total'] )
756
+	if ( ! $update_data['counts']['total'])
757 757
 		return;
758 758
 
759
-	$title = '<span class="ab-icon"></span><span class="ab-label">' . number_format_i18n( $update_data['counts']['total'] ) . '</span>';
760
-	$title .= '<span class="screen-reader-text">' . $update_data['title'] . '</span>';
759
+	$title = '<span class="ab-icon"></span><span class="ab-label">'.number_format_i18n($update_data['counts']['total']).'</span>';
760
+	$title .= '<span class="screen-reader-text">'.$update_data['title'].'</span>';
761 761
 
762
-	$wp_admin_bar->add_menu( array(
762
+	$wp_admin_bar->add_menu(array(
763 763
 		'id'    => 'updates',
764 764
 		'title' => $title,
765
-		'href'  => network_admin_url( 'update-core.php' ),
765
+		'href'  => network_admin_url('update-core.php'),
766 766
 		'meta'  => array(
767 767
 			'title' => $update_data['title'],
768 768
 		),
769
-	) );
769
+	));
770 770
 }
771 771
 
772 772
 /**
@@ -776,17 +776,17 @@  discard block
 block discarded – undo
776 776
  *
777 777
  * @param WP_Admin_Bar $wp_admin_bar
778 778
  */
779
-function wp_admin_bar_search_menu( $wp_admin_bar ) {
780
-	if ( is_admin() )
779
+function wp_admin_bar_search_menu($wp_admin_bar) {
780
+	if (is_admin())
781 781
 		return;
782 782
 
783
-	$form  = '<form action="' . esc_url( home_url( '/' ) ) . '" method="get" id="adminbarsearch">';
783
+	$form  = '<form action="'.esc_url(home_url('/')).'" method="get" id="adminbarsearch">';
784 784
 	$form .= '<input class="adminbar-input" name="s" id="adminbar-search" type="text" value="" maxlength="150" />';
785
-	$form .= '<label for="adminbar-search" class="screen-reader-text">' . __( 'Search' ) . '</label>';
786
-	$form .= '<input type="submit" class="adminbar-button" value="' . __('Search') . '"/>';
785
+	$form .= '<label for="adminbar-search" class="screen-reader-text">'.__('Search').'</label>';
786
+	$form .= '<input type="submit" class="adminbar-button" value="'.__('Search').'"/>';
787 787
 	$form .= '</form>';
788 788
 
789
-	$wp_admin_bar->add_menu( array(
789
+	$wp_admin_bar->add_menu(array(
790 790
 		'parent' => 'top-secondary',
791 791
 		'id'     => 'search',
792 792
 		'title'  => $form,
@@ -794,7 +794,7 @@  discard block
 block discarded – undo
794 794
 			'class'    => 'admin-bar-search',
795 795
 			'tabindex' => -1,
796 796
 		)
797
-	) );
797
+	));
798 798
 }
799 799
 
800 800
 /**
@@ -804,21 +804,21 @@  discard block
 block discarded – undo
804 804
  *
805 805
  * @param WP_Admin_Bar $wp_admin_bar
806 806
  */
807
-function wp_admin_bar_add_secondary_groups( $wp_admin_bar ) {
808
-	$wp_admin_bar->add_group( array(
807
+function wp_admin_bar_add_secondary_groups($wp_admin_bar) {
808
+	$wp_admin_bar->add_group(array(
809 809
 		'id'     => 'top-secondary',
810 810
 		'meta'   => array(
811 811
 			'class' => 'ab-top-secondary',
812 812
 		),
813
-	) );
813
+	));
814 814
 
815
-	$wp_admin_bar->add_group( array(
815
+	$wp_admin_bar->add_group(array(
816 816
 		'parent' => 'wp-logo',
817 817
 		'id'     => 'wp-logo-external',
818 818
 		'meta'   => array(
819 819
 			'class' => 'ab-sub-secondary',
820 820
 		),
821
-	) );
821
+	));
822 822
 }
823 823
 
824 824
 /**
@@ -859,7 +859,7 @@  discard block
 block discarded – undo
859 859
  *
860 860
  * @param bool $show Whether to allow the admin bar to show.
861 861
  */
862
-function show_admin_bar( $show ) {
862
+function show_admin_bar($show) {
863 863
 	global $show_admin_bar;
864 864
 	$show_admin_bar = (bool) $show;
865 865
 }
@@ -878,15 +878,15 @@  discard block
 block discarded – undo
878 878
 	global $show_admin_bar, $pagenow;
879 879
 
880 880
 	// For all these types of requests, we never want an admin bar.
881
-	if ( defined('XMLRPC_REQUEST') || defined('DOING_AJAX') || defined('IFRAME_REQUEST') )
881
+	if (defined('XMLRPC_REQUEST') || defined('DOING_AJAX') || defined('IFRAME_REQUEST'))
882 882
 		return false;
883 883
 
884 884
 	// Integrated into the admin.
885
-	if ( is_admin() )
885
+	if (is_admin())
886 886
 		return true;
887 887
 
888
-	if ( ! isset( $show_admin_bar ) ) {
889
-		if ( ! is_user_logged_in() || 'wp-login.php' == $pagenow ) {
888
+	if ( ! isset($show_admin_bar)) {
889
+		if ( ! is_user_logged_in() || 'wp-login.php' == $pagenow) {
890 890
 			$show_admin_bar = false;
891 891
 		} else {
892 892
 			$show_admin_bar = _get_admin_bar_pref();
@@ -903,7 +903,7 @@  discard block
 block discarded – undo
903 903
 	 *
904 904
 	 * @param bool $show_admin_bar Whether the admin bar should be shown. Default false.
905 905
 	 */
906
-	$show_admin_bar = apply_filters( 'show_admin_bar', $show_admin_bar );
906
+	$show_admin_bar = apply_filters('show_admin_bar', $show_admin_bar);
907 907
 
908 908
 	return $show_admin_bar;
909 909
 }
@@ -919,9 +919,9 @@  discard block
 block discarded – undo
919 919
  * @param int $user Optional. ID of the user to check, defaults to 0 for current user.
920 920
  * @return bool Whether the admin bar should be showing for this user.
921 921
  */
922
-function _get_admin_bar_pref( $context = 'front', $user = 0 ) {
923
-	$pref = get_user_option( "show_admin_bar_{$context}", $user );
924
-	if ( false === $pref )
922
+function _get_admin_bar_pref($context = 'front', $user = 0) {
923
+	$pref = get_user_option("show_admin_bar_{$context}", $user);
924
+	if (false === $pref)
925 925
 		return true;
926 926
 
927 927
 	return 'true' === $pref;
Please login to merge, or discard this patch.
Braces   +83 added lines, -56 removed lines patch added patch discarded remove patch
@@ -21,8 +21,9 @@  discard block
 block discarded – undo
21 21
 function _wp_admin_bar_init() {
22 22
 	global $wp_admin_bar;
23 23
 
24
-	if ( ! is_admin_bar_showing() )
25
-		return false;
24
+	if ( ! is_admin_bar_showing() ) {
25
+			return false;
26
+	}
26 27
 
27 28
 	/* Load the admin bar class code ready for instantiation */
28 29
 	require_once( ABSPATH . WPINC . '/class-wp-admin-bar.php' );
@@ -37,10 +38,11 @@  discard block
 block discarded – undo
37 38
 	 * @param string $wp_admin_bar_class Admin bar class to use. Default 'WP_Admin_Bar'.
38 39
 	 */
39 40
 	$admin_bar_class = apply_filters( 'wp_admin_bar_class', 'WP_Admin_Bar' );
40
-	if ( class_exists( $admin_bar_class ) )
41
-		$wp_admin_bar = new $admin_bar_class;
42
-	else
43
-		return false;
41
+	if ( class_exists( $admin_bar_class ) ) {
42
+			$wp_admin_bar = new $admin_bar_class;
43
+	} else {
44
+			return false;
45
+	}
44 46
 
45 47
 	$wp_admin_bar->initialize();
46 48
 	$wp_admin_bar->add_menus();
@@ -64,8 +66,9 @@  discard block
 block discarded – undo
64 66
 function wp_admin_bar_render() {
65 67
 	global $wp_admin_bar;
66 68
 
67
-	if ( ! is_admin_bar_showing() || ! is_object( $wp_admin_bar ) )
68
-		return;
69
+	if ( ! is_admin_bar_showing() || ! is_object( $wp_admin_bar ) ) {
70
+			return;
71
+	}
69 72
 
70 73
 	/**
71 74
 	 * Load all necessary admin bar items.
@@ -181,8 +184,9 @@  discard block
 block discarded – undo
181 184
 	$current_user = wp_get_current_user();
182 185
 	$profile_url  = get_edit_profile_url( $user_id );
183 186
 
184
-	if ( ! $user_id )
185
-		return;
187
+	if ( ! $user_id ) {
188
+			return;
189
+	}
186 190
 
187 191
 	$avatar = get_avatar( $user_id, 26 );
188 192
 	$howdy  = sprintf( __('Howdy, %1$s'), $current_user->display_name );
@@ -211,8 +215,9 @@  discard block
 block discarded – undo
211 215
 	$current_user = wp_get_current_user();
212 216
 	$profile_url  = get_edit_profile_url( $user_id );
213 217
 
214
-	if ( ! $user_id )
215
-		return;
218
+	if ( ! $user_id ) {
219
+			return;
220
+	}
216 221
 
217 222
 	$wp_admin_bar->add_group( array(
218 223
 		'parent' => 'my-account',
@@ -222,8 +227,9 @@  discard block
 block discarded – undo
222 227
 	$user_info  = get_avatar( $user_id, 64 );
223 228
 	$user_info .= "<span class='display-name'>{$current_user->display_name}</span>";
224 229
 
225
-	if ( $current_user->display_name !== $current_user->user_login )
226
-		$user_info .= "<span class='username'>{$current_user->user_login}</span>";
230
+	if ( $current_user->display_name !== $current_user->user_login ) {
231
+			$user_info .= "<span class='username'>{$current_user->user_login}</span>";
232
+	}
227 233
 
228 234
 	$wp_admin_bar->add_menu( array(
229 235
 		'parent' => 'user-actions',
@@ -257,12 +263,14 @@  discard block
 block discarded – undo
257 263
  */
258 264
 function wp_admin_bar_site_menu( $wp_admin_bar ) {
259 265
 	// Don't show for logged out users.
260
-	if ( ! is_user_logged_in() )
261
-		return;
266
+	if ( ! is_user_logged_in() ) {
267
+			return;
268
+	}
262 269
 
263 270
 	// Show only when the user is a member of this site, or they're a super admin.
264
-	if ( ! is_user_member_of_blog() && ! is_super_admin() )
265
-		return;
271
+	if ( ! is_user_member_of_blog() && ! is_super_admin() ) {
272
+			return;
273
+	}
266 274
 
267 275
 	$blogname = get_bloginfo('name');
268 276
 
@@ -354,12 +362,14 @@  discard block
 block discarded – undo
354 362
  */
355 363
 function wp_admin_bar_my_sites_menu( $wp_admin_bar ) {
356 364
 	// Don't show for logged out users or single site mode.
357
-	if ( ! is_user_logged_in() || ! is_multisite() )
358
-		return;
365
+	if ( ! is_user_logged_in() || ! is_multisite() ) {
366
+			return;
367
+	}
359 368
 
360 369
 	// Show only when the user has at least one site, or they're a super admin.
361
-	if ( count( $wp_admin_bar->user->blogs ) < 1 && ! is_super_admin() )
362
-		return;
370
+	if ( count( $wp_admin_bar->user->blogs ) < 1 && ! is_super_admin() ) {
371
+			return;
372
+	}
363 373
 
364 374
 	if ( $wp_admin_bar->user->active_blog ) {
365 375
 		$my_sites_url = get_admin_url( $wp_admin_bar->user->active_blog->blog_id, 'my-sites.php' );
@@ -494,8 +504,9 @@  discard block
 block discarded – undo
494 504
 	$short = wp_get_shortlink( 0, 'query' );
495 505
 	$id = 'get-shortlink';
496 506
 
497
-	if ( empty( $short ) )
498
-		return;
507
+	if ( empty( $short ) ) {
508
+			return;
509
+	}
499 510
 
500 511
 	$html = '<input class="shortlink-input" type="text" readonly="readonly" value="' . esc_attr( $short ) . '" />';
501 512
 
@@ -562,8 +573,9 @@  discard block
 block discarded – undo
562 573
 	} else {
563 574
 		$current_object = $wp_the_query->get_queried_object();
564 575
 
565
-		if ( empty( $current_object ) )
566
-			return;
576
+		if ( empty( $current_object ) ) {
577
+					return;
578
+		}
567 579
 
568 580
 		if ( ! empty( $current_object->post_type )
569 581
 			&& ( $post_type_object = get_post_type_object( $current_object->post_type ) )
@@ -603,37 +615,45 @@  discard block
 block discarded – undo
603 615
 
604 616
 	$cpts = (array) get_post_types( array( 'show_in_admin_bar' => true ), 'objects' );
605 617
 
606
-	if ( isset( $cpts['post'] ) && current_user_can( $cpts['post']->cap->create_posts ) )
607
-		$actions[ 'post-new.php' ] = array( $cpts['post']->labels->name_admin_bar, 'new-post' );
618
+	if ( isset( $cpts['post'] ) && current_user_can( $cpts['post']->cap->create_posts ) ) {
619
+			$actions[ 'post-new.php' ] = array( $cpts['post']->labels->name_admin_bar, 'new-post' );
620
+	}
608 621
 
609
-	if ( isset( $cpts['attachment'] ) && current_user_can( 'upload_files' ) )
610
-		$actions[ 'media-new.php' ] = array( $cpts['attachment']->labels->name_admin_bar, 'new-media' );
622
+	if ( isset( $cpts['attachment'] ) && current_user_can( 'upload_files' ) ) {
623
+			$actions[ 'media-new.php' ] = array( $cpts['attachment']->labels->name_admin_bar, 'new-media' );
624
+	}
611 625
 
612
-	if ( current_user_can( 'manage_links' ) )
613
-		$actions[ 'link-add.php' ] = array( _x( 'Link', 'add new from admin bar' ), 'new-link' );
626
+	if ( current_user_can( 'manage_links' ) ) {
627
+			$actions[ 'link-add.php' ] = array( _x( 'Link', 'add new from admin bar' ), 'new-link' );
628
+	}
614 629
 
615
-	if ( isset( $cpts['page'] ) && current_user_can( $cpts['page']->cap->create_posts ) )
616
-		$actions[ 'post-new.php?post_type=page' ] = array( $cpts['page']->labels->name_admin_bar, 'new-page' );
630
+	if ( isset( $cpts['page'] ) && current_user_can( $cpts['page']->cap->create_posts ) ) {
631
+			$actions[ 'post-new.php?post_type=page' ] = array( $cpts['page']->labels->name_admin_bar, 'new-page' );
632
+	}
617 633
 
618 634
 	unset( $cpts['post'], $cpts['page'], $cpts['attachment'] );
619 635
 
620 636
 	// Add any additional custom post types.
621 637
 	foreach ( $cpts as $cpt ) {
622
-		if ( ! current_user_can( $cpt->cap->create_posts ) )
623
-			continue;
638
+		if ( ! current_user_can( $cpt->cap->create_posts ) ) {
639
+					continue;
640
+		}
624 641
 
625 642
 		$key = 'post-new.php?post_type=' . $cpt->name;
626 643
 		$actions[ $key ] = array( $cpt->labels->name_admin_bar, 'new-' . $cpt->name );
627 644
 	}
628 645
 	// Avoid clash with parent node and a 'content' post type.
629
-	if ( isset( $actions['post-new.php?post_type=content'] ) )
630
-		$actions['post-new.php?post_type=content'][1] = 'add-new-content';
646
+	if ( isset( $actions['post-new.php?post_type=content'] ) ) {
647
+			$actions['post-new.php?post_type=content'][1] = 'add-new-content';
648
+	}
631 649
 
632
-	if ( current_user_can( 'create_users' ) || current_user_can( 'promote_users' ) )
633
-		$actions[ 'user-new.php' ] = array( _x( 'User', 'add new from admin bar' ), 'new-user' );
650
+	if ( current_user_can( 'create_users' ) || current_user_can( 'promote_users' ) ) {
651
+			$actions[ 'user-new.php' ] = array( _x( 'User', 'add new from admin bar' ), 'new-user' );
652
+	}
634 653
 
635
-	if ( ! $actions )
636
-		return;
654
+	if ( ! $actions ) {
655
+			return;
656
+	}
637 657
 
638 658
 	$title = '<span class="ab-icon"></span><span class="ab-label">' . _x( 'New', 'admin bar menu group label' ) . '</span>';
639 659
 
@@ -663,8 +683,9 @@  discard block
 block discarded – undo
663 683
  * @param WP_Admin_Bar $wp_admin_bar
664 684
  */
665 685
 function wp_admin_bar_comments_menu( $wp_admin_bar ) {
666
-	if ( !current_user_can('edit_posts') )
667
-		return;
686
+	if ( !current_user_can('edit_posts') ) {
687
+			return;
688
+	}
668 689
 
669 690
 	$awaiting_mod = wp_count_comments();
670 691
 	$awaiting_mod = $awaiting_mod->moderated;
@@ -713,8 +734,9 @@  discard block
 block discarded – undo
713 734
 		) );
714 735
 	}
715 736
 
716
-	if ( current_theme_supports( 'menus' ) || current_theme_supports( 'widgets' ) )
717
-		$wp_admin_bar->add_menu( array( 'parent' => 'appearance', 'id' => 'menus', 'title' => __('Menus'), 'href' => admin_url('nav-menus.php') ) );
737
+	if ( current_theme_supports( 'menus' ) || current_theme_supports( 'widgets' ) ) {
738
+			$wp_admin_bar->add_menu( array( 'parent' => 'appearance', 'id' => 'menus', 'title' => __('Menus'), 'href' => admin_url('nav-menus.php') ) );
739
+	}
718 740
 
719 741
 	if ( current_theme_supports( 'custom-background' ) ) {
720 742
 		$wp_admin_bar->add_menu( array(
@@ -753,8 +775,9 @@  discard block
 block discarded – undo
753 775
 
754 776
 	$update_data = wp_get_update_data();
755 777
 
756
-	if ( !$update_data['counts']['total'] )
757
-		return;
778
+	if ( !$update_data['counts']['total'] ) {
779
+			return;
780
+	}
758 781
 
759 782
 	$title = '<span class="ab-icon"></span><span class="ab-label">' . number_format_i18n( $update_data['counts']['total'] ) . '</span>';
760 783
 	$title .= '<span class="screen-reader-text">' . $update_data['title'] . '</span>';
@@ -777,8 +800,9 @@  discard block
 block discarded – undo
777 800
  * @param WP_Admin_Bar $wp_admin_bar
778 801
  */
779 802
 function wp_admin_bar_search_menu( $wp_admin_bar ) {
780
-	if ( is_admin() )
781
-		return;
803
+	if ( is_admin() ) {
804
+			return;
805
+	}
782 806
 
783 807
 	$form  = '<form action="' . esc_url( home_url( '/' ) ) . '" method="get" id="adminbarsearch">';
784 808
 	$form .= '<input class="adminbar-input" name="s" id="adminbar-search" type="text" value="" maxlength="150" />';
@@ -878,12 +902,14 @@  discard block
 block discarded – undo
878 902
 	global $show_admin_bar, $pagenow;
879 903
 
880 904
 	// For all these types of requests, we never want an admin bar.
881
-	if ( defined('XMLRPC_REQUEST') || defined('DOING_AJAX') || defined('IFRAME_REQUEST') )
882
-		return false;
905
+	if ( defined('XMLRPC_REQUEST') || defined('DOING_AJAX') || defined('IFRAME_REQUEST') ) {
906
+			return false;
907
+	}
883 908
 
884 909
 	// Integrated into the admin.
885
-	if ( is_admin() )
886
-		return true;
910
+	if ( is_admin() ) {
911
+			return true;
912
+	}
887 913
 
888 914
 	if ( ! isset( $show_admin_bar ) ) {
889 915
 		if ( ! is_user_logged_in() || 'wp-login.php' == $pagenow ) {
@@ -921,8 +947,9 @@  discard block
 block discarded – undo
921 947
  */
922 948
 function _get_admin_bar_pref( $context = 'front', $user = 0 ) {
923 949
 	$pref = get_user_option( "show_admin_bar_{$context}", $user );
924
-	if ( false === $pref )
925
-		return true;
950
+	if ( false === $pref ) {
951
+			return true;
952
+	}
926 953
 
927 954
 	return 'true' === $pref;
928 955
 }
Please login to merge, or discard this patch.
src/wp-includes/bookmark-template.php 2 patches
Indentation   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -1,10 +1,10 @@
 block discarded – undo
1 1
 <?php
2 2
 /**
3
- * Bookmark Template Functions for usage in Themes
4
- *
5
- * @package WordPress
6
- * @subpackage Template
7
- */
3
+	 * Bookmark Template Functions for usage in Themes
4
+	 *
5
+	 * @package WordPress
6
+	 * @subpackage Template
7
+	 */
8 8
 
9 9
 /**
10 10
  * The formatted output of a list of bookmarks.
Please login to merge, or discard this patch.
Spacing   +61 added lines, -61 removed lines patch added patch discarded remove patch
@@ -48,7 +48,7 @@  discard block
 block discarded – undo
48 48
  * }
49 49
  * @return string Formatted output in HTML
50 50
  */
51
-function _walk_bookmarks( $bookmarks, $args = '' ) {
51
+function _walk_bookmarks($bookmarks, $args = '') {
52 52
 	$defaults = array(
53 53
 		'show_updated' => 0, 'show_description' => 0,
54 54
 		'show_images' => 1, 'show_name' => 0,
@@ -56,63 +56,63 @@  discard block
 block discarded – undo
56 56
 		'show_rating' => 0, 'link_before' => '', 'link_after' => ''
57 57
 	);
58 58
 
59
-	$r = wp_parse_args( $args, $defaults );
59
+	$r = wp_parse_args($args, $defaults);
60 60
 
61 61
 	$output = ''; // Blank string to start with.
62 62
 
63
-	foreach ( (array) $bookmarks as $bookmark ) {
64
-		if ( ! isset( $bookmark->recently_updated ) ) {
63
+	foreach ((array) $bookmarks as $bookmark) {
64
+		if ( ! isset($bookmark->recently_updated)) {
65 65
 			$bookmark->recently_updated = false;
66 66
 		}
67 67
 		$output .= $r['before'];
68
-		if ( $r['show_updated'] && $bookmark->recently_updated ) {
68
+		if ($r['show_updated'] && $bookmark->recently_updated) {
69 69
 			$output .= '<em>';
70 70
 		}
71 71
 		$the_link = '#';
72
-		if ( ! empty( $bookmark->link_url ) ) {
73
-			$the_link = esc_url( $bookmark->link_url );
72
+		if ( ! empty($bookmark->link_url)) {
73
+			$the_link = esc_url($bookmark->link_url);
74 74
 		}
75
-		$desc = esc_attr( sanitize_bookmark_field( 'link_description', $bookmark->link_description, $bookmark->link_id, 'display' ) );
76
-		$name = esc_attr( sanitize_bookmark_field( 'link_name', $bookmark->link_name, $bookmark->link_id, 'display' ) );
75
+		$desc = esc_attr(sanitize_bookmark_field('link_description', $bookmark->link_description, $bookmark->link_id, 'display'));
76
+		$name = esc_attr(sanitize_bookmark_field('link_name', $bookmark->link_name, $bookmark->link_id, 'display'));
77 77
  		$title = $desc;
78 78
 
79
-		if ( $r['show_updated'] ) {
80
-			if ( '00' != substr( $bookmark->link_updated_f, 0, 2 ) ) {
79
+		if ($r['show_updated']) {
80
+			if ('00' != substr($bookmark->link_updated_f, 0, 2)) {
81 81
 				$title .= ' (';
82 82
 				$title .= sprintf(
83 83
 					__('Last updated: %s'),
84 84
 					date(
85
-						get_option( 'links_updated_date_format' ),
86
-						$bookmark->link_updated_f + ( get_option( 'gmt_offset' ) * HOUR_IN_SECONDS )
85
+						get_option('links_updated_date_format'),
86
+						$bookmark->link_updated_f + (get_option('gmt_offset') * HOUR_IN_SECONDS)
87 87
 					)
88 88
 				);
89 89
 				$title .= ')';
90 90
 			}
91 91
 		}
92
-		$alt = ' alt="' . $name . ( $r['show_description'] ? ' ' . $title : '' ) . '"';
92
+		$alt = ' alt="'.$name.($r['show_description'] ? ' '.$title : '').'"';
93 93
 
94
-		if ( '' != $title ) {
95
-			$title = ' title="' . $title . '"';
94
+		if ('' != $title) {
95
+			$title = ' title="'.$title.'"';
96 96
 		}
97 97
 		$rel = $bookmark->link_rel;
98
-		if ( '' != $rel ) {
99
-			$rel = ' rel="' . esc_attr($rel) . '"';
98
+		if ('' != $rel) {
99
+			$rel = ' rel="'.esc_attr($rel).'"';
100 100
 		}
101 101
 		$target = $bookmark->link_target;
102
-		if ( '' != $target ) {
103
-			$target = ' target="' . $target . '"';
102
+		if ('' != $target) {
103
+			$target = ' target="'.$target.'"';
104 104
 		}
105
-		$output .= '<a href="' . $the_link . '"' . $rel . $title . $target . '>';
105
+		$output .= '<a href="'.$the_link.'"'.$rel.$title.$target.'>';
106 106
 
107 107
 		$output .= $r['link_before'];
108 108
 
109
-		if ( $bookmark->link_image != null && $r['show_images'] ) {
110
-			if ( strpos( $bookmark->link_image, 'http' ) === 0 ) {
109
+		if ($bookmark->link_image != null && $r['show_images']) {
110
+			if (strpos($bookmark->link_image, 'http') === 0) {
111 111
 				$output .= "<img src=\"$bookmark->link_image\" $alt $title />";
112 112
 			} else { // If it's a relative path
113
-				$output .= "<img src=\"" . get_option('siteurl') . "$bookmark->link_image\" $alt $title />";
113
+				$output .= "<img src=\"".get_option('siteurl')."$bookmark->link_image\" $alt $title />";
114 114
 			}
115
-			if ( $r['show_name'] ) {
115
+			if ($r['show_name']) {
116 116
 				$output .= " $name";
117 117
 			}
118 118
 		} else {
@@ -123,23 +123,23 @@  discard block
 block discarded – undo
123 123
 
124 124
 		$output .= '</a>';
125 125
 
126
-		if ( $r['show_updated'] && $bookmark->recently_updated ) {
126
+		if ($r['show_updated'] && $bookmark->recently_updated) {
127 127
 			$output .= '</em>';
128 128
 		}
129 129
 
130
-		if ( $r['show_description'] && '' != $desc ) {
131
-			$output .= $r['between'] . $desc;
130
+		if ($r['show_description'] && '' != $desc) {
131
+			$output .= $r['between'].$desc;
132 132
 		}
133 133
 
134
-		if ( $r['show_rating'] ) {
135
-			$output .= $r['between'] . sanitize_bookmark_field(
134
+		if ($r['show_rating']) {
135
+			$output .= $r['between'].sanitize_bookmark_field(
136 136
 				'link_rating',
137 137
 				$bookmark->link_rating,
138 138
 				$bookmark->link_id,
139 139
 				'display'
140 140
 			);
141 141
 		}
142
-		$output .= $r['after'] . "\n";
142
+		$output .= $r['after']."\n";
143 143
 	} // end while
144 144
 
145 145
 	return $output;
@@ -197,7 +197,7 @@  discard block
 block discarded – undo
197 197
  * }
198 198
  * @return string|void Will only return if echo option is set to not echo. Default is not return anything.
199 199
  */
200
-function wp_list_bookmarks( $args = '' ) {
200
+function wp_list_bookmarks($args = '') {
201 201
 	$defaults = array(
202 202
 		'orderby' => 'name', 'order' => 'ASC',
203 203
 		'limit' => -1, 'category' => '', 'exclude_category' => '',
@@ -210,41 +210,41 @@  discard block
 block discarded – undo
210 210
 		'category_after' => '</li>'
211 211
 	);
212 212
 
213
-	$r = wp_parse_args( $args, $defaults );
213
+	$r = wp_parse_args($args, $defaults);
214 214
 
215 215
 	$output = '';
216 216
 
217
-	if ( ! is_array( $r['class'] ) ) {
218
-		$r['class'] = explode( ' ', $r['class'] );
217
+	if ( ! is_array($r['class'])) {
218
+		$r['class'] = explode(' ', $r['class']);
219 219
 	}
220
- 	$r['class'] = array_map( 'sanitize_html_class', $r['class'] );
221
- 	$r['class'] = trim( join( ' ', $r['class'] ) );
220
+ 	$r['class'] = array_map('sanitize_html_class', $r['class']);
221
+ 	$r['class'] = trim(join(' ', $r['class']));
222 222
 
223
-	if ( $r['categorize'] ) {
224
-		$cats = get_terms( 'link_category', array(
223
+	if ($r['categorize']) {
224
+		$cats = get_terms('link_category', array(
225 225
 			'name__like' => $r['category_name'],
226 226
 			'include' => $r['category'],
227 227
 			'exclude' => $r['exclude_category'],
228 228
 			'orderby' => $r['category_orderby'],
229 229
 			'order' => $r['category_order'],
230 230
 			'hierarchical' => 0
231
-		) );
232
-		if ( empty( $cats ) ) {
231
+		));
232
+		if (empty($cats)) {
233 233
 			$r['categorize'] = false;
234 234
 		}
235 235
 	}
236 236
 
237
-	if ( $r['categorize'] ) {
237
+	if ($r['categorize']) {
238 238
 		// Split the bookmarks into ul's for each category
239
-		foreach ( (array) $cats as $cat ) {
240
-			$params = array_merge( $r, array( 'category' => $cat->term_id ) );
241
-			$bookmarks = get_bookmarks( $params );
242
-			if ( empty( $bookmarks ) ) {
239
+		foreach ((array) $cats as $cat) {
240
+			$params = array_merge($r, array('category' => $cat->term_id));
241
+			$bookmarks = get_bookmarks($params);
242
+			if (empty($bookmarks)) {
243 243
 				continue;
244 244
 			}
245 245
 			$output .= str_replace(
246
-				array( '%id', '%class' ),
247
-				array( "linkcat-$cat->term_id", $r['class'] ),
246
+				array('%id', '%class'),
247
+				array("linkcat-$cat->term_id", $r['class']),
248 248
 				$r['category_before']
249 249
 			);
250 250
 			/**
@@ -254,36 +254,36 @@  discard block
 block discarded – undo
254 254
 			 *
255 255
 			 * @param string $cat_name The category name of bookmarks.
256 256
 			 */
257
-			$catname = apply_filters( 'link_category', $cat->name );
257
+			$catname = apply_filters('link_category', $cat->name);
258 258
 
259 259
 			$output .= $r['title_before'];
260 260
 			$output .= $catname;
261 261
 			$output .= $r['title_after'];
262 262
 			$output .= "\n\t<ul class='xoxo blogroll'>\n";
263
-			$output .= _walk_bookmarks( $bookmarks, $r );
263
+			$output .= _walk_bookmarks($bookmarks, $r);
264 264
 			$output .= "\n\t</ul>\n";
265
-			$output .= $r['category_after'] . "\n";
265
+			$output .= $r['category_after']."\n";
266 266
 		}
267 267
 	} else {
268 268
 		//output one single list using title_li for the title
269
-		$bookmarks = get_bookmarks( $r );
269
+		$bookmarks = get_bookmarks($r);
270 270
 
271
-		if ( ! empty( $bookmarks ) ) {
272
-			if ( ! empty( $r['title_li'] ) ) {
271
+		if ( ! empty($bookmarks)) {
272
+			if ( ! empty($r['title_li'])) {
273 273
 				$output .= str_replace(
274
-					array( '%id', '%class' ),
275
-					array( "linkcat-" . $r['category'], $r['class'] ),
274
+					array('%id', '%class'),
275
+					array("linkcat-".$r['category'], $r['class']),
276 276
 					$r['category_before']
277 277
 				);
278 278
 				$output .= $r['title_before'];
279 279
 				$output .= $r['title_li'];
280 280
 				$output .= $r['title_after'];
281 281
 				$output .= "\n\t<ul class='xoxo blogroll'>\n";
282
-				$output .= _walk_bookmarks( $bookmarks, $r );
282
+				$output .= _walk_bookmarks($bookmarks, $r);
283 283
 				$output .= "\n\t</ul>\n";
284
-				$output .= $r['category_after'] . "\n";
284
+				$output .= $r['category_after']."\n";
285 285
 			} else {
286
-				$output .= _walk_bookmarks( $bookmarks, $r );
286
+				$output .= _walk_bookmarks($bookmarks, $r);
287 287
 			}
288 288
 		}
289 289
 	}
@@ -295,9 +295,9 @@  discard block
 block discarded – undo
295 295
 	 *
296 296
 	 * @param string $html The HTML list of bookmarks.
297 297
 	 */
298
-	$html = apply_filters( 'wp_list_bookmarks', $output );
298
+	$html = apply_filters('wp_list_bookmarks', $output);
299 299
 
300
-	if ( ! $r['echo'] ) {
300
+	if ( ! $r['echo']) {
301 301
 		return $html;
302 302
 	}
303 303
 	echo $html;
Please login to merge, or discard this patch.
src/wp-includes/pluggable-deprecated.php 3 patches
Indentation   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -1,15 +1,15 @@
 block discarded – undo
1 1
 <?php
2 2
 /**
3
- * Deprecated pluggable functions from past WordPress versions. You shouldn't use these
4
- * functions and look for the alternatives instead. The functions will be removed in a
5
- * later version.
6
- *
7
- * Deprecated warnings are also thrown if one of these functions is being defined by a plugin.
8
- *
9
- * @package WordPress
10
- * @subpackage Deprecated
11
- * @see pluggable.php
12
- */
3
+	 * Deprecated pluggable functions from past WordPress versions. You shouldn't use these
4
+	 * functions and look for the alternatives instead. The functions will be removed in a
5
+	 * later version.
6
+	 *
7
+	 * Deprecated warnings are also thrown if one of these functions is being defined by a plugin.
8
+	 *
9
+	 * @package WordPress
10
+	 * @subpackage Deprecated
11
+	 * @see pluggable.php
12
+	 */
13 13
 
14 14
 /*
15 15
  * Deprecated functions come here to die.
Please login to merge, or discard this patch.
Spacing   +24 added lines, -24 removed lines patch added patch discarded remove patch
@@ -15,7 +15,7 @@  discard block
 block discarded – undo
15 15
  * Deprecated functions come here to die.
16 16
  */
17 17
 
18
-if ( !function_exists('set_current_user') ) :
18
+if ( ! function_exists('set_current_user')) :
19 19
 /**
20 20
  * Changes the current user by ID or name.
21 21
  *
@@ -30,12 +30,12 @@  discard block
 block discarded – undo
30 30
  * @return WP_User returns wp_set_current_user()
31 31
  */
32 32
 function set_current_user($id, $name = '') {
33
-	_deprecated_function( __FUNCTION__, '3.0', 'wp_set_current_user()' );
33
+	_deprecated_function(__FUNCTION__, '3.0', 'wp_set_current_user()');
34 34
 	return wp_set_current_user($id, $name);
35 35
 }
36 36
 endif;
37 37
 
38
-if ( !function_exists('get_userdatabylogin') ) :
38
+if ( ! function_exists('get_userdatabylogin')) :
39 39
 /**
40 40
  * Retrieve user info by login name.
41 41
  *
@@ -47,12 +47,12 @@  discard block
 block discarded – undo
47 47
  * @return bool|object False on failure, User DB row object
48 48
  */
49 49
 function get_userdatabylogin($user_login) {
50
-	_deprecated_function( __FUNCTION__, '3.3', "get_user_by('login')" );
50
+	_deprecated_function(__FUNCTION__, '3.3', "get_user_by('login')");
51 51
 	return get_user_by('login', $user_login);
52 52
 }
53 53
 endif;
54 54
 
55
-if ( !function_exists('get_user_by_email') ) :
55
+if ( ! function_exists('get_user_by_email')) :
56 56
 /**
57 57
  * Retrieve user info by email.
58 58
  *
@@ -64,12 +64,12 @@  discard block
 block discarded – undo
64 64
  * @return bool|object False on failure, User DB row object
65 65
  */
66 66
 function get_user_by_email($email) {
67
-	_deprecated_function( __FUNCTION__, '3.3', "get_user_by('email')" );
67
+	_deprecated_function(__FUNCTION__, '3.3', "get_user_by('email')");
68 68
 	return get_user_by('email', $email);
69 69
 }
70 70
 endif;
71 71
 
72
-if ( !function_exists('wp_setcookie') ) :
72
+if ( ! function_exists('wp_setcookie')) :
73 73
 /**
74 74
  * Sets a cookie for a user who just logged in. This function is deprecated.
75 75
  *
@@ -85,15 +85,15 @@  discard block
 block discarded – undo
85 85
  * @param bool $remember Optional. Remember that the user is logged in
86 86
  */
87 87
 function wp_setcookie($username, $password = '', $already_md5 = false, $home = '', $siteurl = '', $remember = false) {
88
-	_deprecated_function( __FUNCTION__, '2.5', 'wp_set_auth_cookie()' );
88
+	_deprecated_function(__FUNCTION__, '2.5', 'wp_set_auth_cookie()');
89 89
 	$user = get_user_by('login', $username);
90 90
 	wp_set_auth_cookie($user->ID, $remember);
91 91
 }
92 92
 else :
93
-	_deprecated_function( 'wp_setcookie', '2.5', 'wp_set_auth_cookie()' );
93
+	_deprecated_function('wp_setcookie', '2.5', 'wp_set_auth_cookie()');
94 94
 endif;
95 95
 
96
-if ( !function_exists('wp_clearcookie') ) :
96
+if ( ! function_exists('wp_clearcookie')) :
97 97
 /**
98 98
  * Clears the authentication cookie, logging the user out. This function is deprecated.
99 99
  *
@@ -102,14 +102,14 @@  discard block
 block discarded – undo
102 102
  * @see wp_clear_auth_cookie()
103 103
  */
104 104
 function wp_clearcookie() {
105
-	_deprecated_function( __FUNCTION__, '2.5', 'wp_clear_auth_cookie()' );
105
+	_deprecated_function(__FUNCTION__, '2.5', 'wp_clear_auth_cookie()');
106 106
 	wp_clear_auth_cookie();
107 107
 }
108 108
 else :
109
-	_deprecated_function( 'wp_clearcookie', '2.5', 'wp_clear_auth_cookie()' );
109
+	_deprecated_function('wp_clearcookie', '2.5', 'wp_clear_auth_cookie()');
110 110
 endif;
111 111
 
112
-if ( !function_exists('wp_get_cookie_login') ):
112
+if ( ! function_exists('wp_get_cookie_login')):
113 113
 /**
114 114
  * Gets the user cookie login. This function is deprecated.
115 115
  *
@@ -122,14 +122,14 @@  discard block
 block discarded – undo
122 122
  * @return bool Always returns false
123 123
  */
124 124
 function wp_get_cookie_login() {
125
-	_deprecated_function( __FUNCTION__, '2.5' );
125
+	_deprecated_function(__FUNCTION__, '2.5');
126 126
 	return false;
127 127
 }
128 128
 else :
129
-	_deprecated_function( 'wp_get_cookie_login', '2.5' );
129
+	_deprecated_function('wp_get_cookie_login', '2.5');
130 130
 endif;
131 131
 
132
-if ( !function_exists('wp_login') ) :
132
+if ( ! function_exists('wp_login')) :
133 133
 /**
134 134
  * Checks a users login information and logs them in if it checks out. This function is deprecated.
135 135
  *
@@ -152,19 +152,19 @@  discard block
 block discarded – undo
152 152
  * @return bool False on login failure, true on successful check
153 153
  */
154 154
 function wp_login($username, $password, $deprecated = '') {
155
-	_deprecated_function( __FUNCTION__, '2.5', 'wp_signon()' );
155
+	_deprecated_function(__FUNCTION__, '2.5', 'wp_signon()');
156 156
 	global $error;
157 157
 
158 158
 	$user = wp_authenticate($username, $password);
159 159
 
160
-	if ( ! is_wp_error($user) )
160
+	if ( ! is_wp_error($user))
161 161
 		return true;
162 162
 
163 163
 	$error = $user->get_error_message();
164 164
 	return false;
165 165
 }
166 166
 else :
167
-	_deprecated_function( 'wp_login', '2.5', 'wp_signon()' );
167
+	_deprecated_function('wp_login', '2.5', 'wp_signon()');
168 168
 endif;
169 169
 
170 170
 /**
@@ -178,14 +178,14 @@  discard block
 block discarded – undo
178 178
  *
179 179
  * @link https://wordpress.org/plugins/atom-publishing-protocol/
180 180
  */
181
-if ( ! class_exists( 'wp_atom_server' ) ) {
181
+if ( ! class_exists('wp_atom_server')) {
182 182
 	class wp_atom_server {
183
-		public function __call( $name, $arguments ) {
184
-			_deprecated_function( __CLASS__ . '::' . $name, '3.5', 'the Atom Publishing Protocol plugin' );
183
+		public function __call($name, $arguments) {
184
+			_deprecated_function(__CLASS__.'::'.$name, '3.5', 'the Atom Publishing Protocol plugin');
185 185
 		}
186 186
 
187
-		public static function __callStatic( $name, $arguments ) {
188
-			_deprecated_function( __CLASS__ . '::' . $name, '3.5', 'the Atom Publishing Protocol plugin' );
187
+		public static function __callStatic($name, $arguments) {
188
+			_deprecated_function(__CLASS__.'::'.$name, '3.5', 'the Atom Publishing Protocol plugin');
189 189
 		}
190 190
 	}
191 191
 }
192 192
\ No newline at end of file
Please login to merge, or discard this patch.
Braces   +15 added lines, -10 removed lines patch added patch discarded remove patch
@@ -88,9 +88,10 @@  discard block
 block discarded – undo
88 88
 	_deprecated_function( __FUNCTION__, '2.5', 'wp_set_auth_cookie()' );
89 89
 	$user = get_user_by('login', $username);
90 90
 	wp_set_auth_cookie($user->ID, $remember);
91
-}
92
-else :
91
+} else {
92
+	:
93 93
 	_deprecated_function( 'wp_setcookie', '2.5', 'wp_set_auth_cookie()' );
94
+}
94 95
 endif;
95 96
 
96 97
 if ( !function_exists('wp_clearcookie') ) :
@@ -104,9 +105,10 @@  discard block
 block discarded – undo
104 105
 function wp_clearcookie() {
105 106
 	_deprecated_function( __FUNCTION__, '2.5', 'wp_clear_auth_cookie()' );
106 107
 	wp_clear_auth_cookie();
107
-}
108
-else :
108
+} else {
109
+	:
109 110
 	_deprecated_function( 'wp_clearcookie', '2.5', 'wp_clear_auth_cookie()' );
111
+}
110 112
 endif;
111 113
 
112 114
 if ( !function_exists('wp_get_cookie_login') ):
@@ -124,9 +126,10 @@  discard block
 block discarded – undo
124 126
 function wp_get_cookie_login() {
125 127
 	_deprecated_function( __FUNCTION__, '2.5' );
126 128
 	return false;
127
-}
128
-else :
129
+} else {
130
+	:
129 131
 	_deprecated_function( 'wp_get_cookie_login', '2.5' );
132
+}
130 133
 endif;
131 134
 
132 135
 if ( !function_exists('wp_login') ) :
@@ -157,14 +160,16 @@  discard block
 block discarded – undo
157 160
 
158 161
 	$user = wp_authenticate($username, $password);
159 162
 
160
-	if ( ! is_wp_error($user) )
161
-		return true;
163
+	if ( ! is_wp_error($user) ) {
164
+			return true;
165
+	}
162 166
 
163 167
 	$error = $user->get_error_message();
164 168
 	return false;
165
-}
166
-else :
169
+} else {
170
+	:
167 171
 	_deprecated_function( 'wp_login', '2.5', 'wp_signon()' );
172
+}
168 173
 endif;
169 174
 
170 175
 /**
Please login to merge, or discard this patch.
src/wp-includes/atomlib.php 3 patches
Indentation   +292 added lines, -292 removed lines patch added patch discarded remove patch
@@ -1,14 +1,14 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 /**
3
- * Atom Syndication Format PHP Library
4
- *
5
- * @package AtomLib
6
- * @link http://code.google.com/p/phpatomlib/
7
- *
8
- * @author Elias Torres <[email protected]>
9
- * @version 0.4
10
- * @since 2.3.0
11
- */
3
+	 * Atom Syndication Format PHP Library
4
+	 *
5
+	 * @package AtomLib
6
+	 * @link http://code.google.com/p/phpatomlib/
7
+	 *
8
+	 * @author Elias Torres <[email protected]>
9
+	 * @version 0.4
10
+	 * @since 2.3.0
11
+	 */
12 12
 
13 13
 /**
14 14
  * Structure that store common Atom Feed Properties
@@ -21,20 +21,20 @@  discard block
 block discarded – undo
21 21
 	 * @var array
22 22
 	 * @access public
23 23
 	 */
24
-    var $links = array();
25
-    /**
26
-     * Stores Categories
27
-     * @var array
28
-     * @access public
29
-     */
30
-    var $categories = array();
24
+	var $links = array();
25
+	/**
26
+	 * Stores Categories
27
+	 * @var array
28
+	 * @access public
29
+	 */
30
+	var $categories = array();
31 31
 	/**
32 32
 	 * Stores Entries
33 33
 	 *
34 34
 	 * @var array
35 35
 	 * @access public
36 36
 	 */
37
-    var $entries = array();
37
+	var $entries = array();
38 38
 }
39 39
 
40 40
 /**
@@ -48,13 +48,13 @@  discard block
 block discarded – undo
48 48
 	 * @var array
49 49
 	 * @access public
50 50
 	 */
51
-    var $links = array();
52
-    /**
53
-     * Stores Categories
54
-     * @var array
51
+	var $links = array();
52
+	/**
53
+	 * Stores Categories
54
+	 * @var array
55 55
 	 * @access public
56
-     */
57
-    var $categories = array();
56
+	 */
57
+	var $categories = array();
58 58
 }
59 59
 
60 60
 /**
@@ -64,39 +64,39 @@  discard block
 block discarded – undo
64 64
  */
65 65
 class AtomParser {
66 66
 
67
-    var $NS = 'http://www.w3.org/2005/Atom';
68
-    var $ATOM_CONTENT_ELEMENTS = array('content','summary','title','subtitle','rights');
69
-    var $ATOM_SIMPLE_ELEMENTS = array('id','updated','published','draft');
67
+	var $NS = 'http://www.w3.org/2005/Atom';
68
+	var $ATOM_CONTENT_ELEMENTS = array('content','summary','title','subtitle','rights');
69
+	var $ATOM_SIMPLE_ELEMENTS = array('id','updated','published','draft');
70 70
 
71
-    var $debug = false;
71
+	var $debug = false;
72 72
 
73
-    var $depth = 0;
74
-    var $indent = 2;
75
-    var $in_content;
76
-    var $ns_contexts = array();
77
-    var $ns_decls = array();
78
-    var $content_ns_decls = array();
79
-    var $content_ns_contexts = array();
80
-    var $is_xhtml = false;
81
-    var $is_html = false;
82
-    var $is_text = true;
83
-    var $skipped_div = false;
73
+	var $depth = 0;
74
+	var $indent = 2;
75
+	var $in_content;
76
+	var $ns_contexts = array();
77
+	var $ns_decls = array();
78
+	var $content_ns_decls = array();
79
+	var $content_ns_contexts = array();
80
+	var $is_xhtml = false;
81
+	var $is_html = false;
82
+	var $is_text = true;
83
+	var $skipped_div = false;
84 84
 
85
-    var $FILE = "php://input";
85
+	var $FILE = "php://input";
86 86
 
87
-    var $feed;
88
-    var $current;
87
+	var $feed;
88
+	var $current;
89 89
 
90 90
 	/**
91 91
 	 * PHP5 constructor.
92 92
 	 */
93
-    function __construct() {
93
+	function __construct() {
94 94
 
95
-        $this->feed = new AtomFeed();
96
-        $this->current = null;
97
-        $this->map_attrs_func = create_function('$k,$v', 'return "$k=\"$v\"";');
98
-        $this->map_xmlns_func = create_function('$p,$n', '$xd = "xmlns"; if(strlen($n[0])>0) $xd .= ":{$n[0]}"; return "{$xd}=\"{$n[1]}\"";');
99
-    }
95
+		$this->feed = new AtomFeed();
96
+		$this->current = null;
97
+		$this->map_attrs_func = create_function('$k,$v', 'return "$k=\"$v\"";');
98
+		$this->map_xmlns_func = create_function('$p,$n', '$xd = "xmlns"; if(strlen($n[0])>0) $xd .= ":{$n[0]}"; return "{$xd}=\"{$n[1]}\"";');
99
+	}
100 100
 
101 101
 	/**
102 102
 	 * PHP4 constructor.
@@ -105,259 +105,259 @@  discard block
 block discarded – undo
105 105
 		self::__construct();
106 106
 	}
107 107
 
108
-    function _p($msg) {
109
-        if($this->debug) {
110
-            print str_repeat(" ", $this->depth * $this->indent) . $msg ."\n";
111
-        }
112
-    }
108
+	function _p($msg) {
109
+		if($this->debug) {
110
+			print str_repeat(" ", $this->depth * $this->indent) . $msg ."\n";
111
+		}
112
+	}
113
+
114
+	function error_handler($log_level, $log_text, $error_file, $error_line) {
115
+		$this->error = $log_text;
116
+	}
117
+
118
+	function parse() {
119
+
120
+		set_error_handler(array(&$this, 'error_handler'));
121
+
122
+		array_unshift($this->ns_contexts, array());
123
+
124
+		$parser = xml_parser_create_ns();
125
+		xml_set_object($parser, $this);
126
+		xml_set_element_handler($parser, "start_element", "end_element");
127
+		xml_parser_set_option($parser,XML_OPTION_CASE_FOLDING,0);
128
+		xml_parser_set_option($parser,XML_OPTION_SKIP_WHITE,0);
129
+		xml_set_character_data_handler($parser, "cdata");
130
+		xml_set_default_handler($parser, "_default");
131
+		xml_set_start_namespace_decl_handler($parser, "start_ns");
132
+		xml_set_end_namespace_decl_handler($parser, "end_ns");
113 133
 
114
-    function error_handler($log_level, $log_text, $error_file, $error_line) {
115
-        $this->error = $log_text;
116
-    }
134
+		$this->content = '';
135
+
136
+		$ret = true;
137
+
138
+		$fp = fopen($this->FILE, "r");
139
+		while ($data = fread($fp, 4096)) {
140
+			if($this->debug) $this->content .= $data;
141
+
142
+			if(!xml_parse($parser, $data, feof($fp))) {
143
+				/* translators: 1: error message, 2: line number */
144
+				trigger_error(sprintf(__('XML Error: %1$s at line %2$s')."\n",
145
+					xml_error_string(xml_get_error_code($parser)),
146
+					xml_get_current_line_number($parser)));
147
+				$ret = false;
148
+				break;
149
+			}
150
+		}
151
+		fclose($fp);
152
+
153
+		xml_parser_free($parser);
154
+
155
+		restore_error_handler();
156
+
157
+		return $ret;
158
+	}
117 159
 
118
-    function parse() {
160
+	function start_element($parser, $name, $attrs) {
119 161
 
120
-        set_error_handler(array(&$this, 'error_handler'));
162
+		$tag = array_pop(split(":", $name));
121 163
 
122
-        array_unshift($this->ns_contexts, array());
164
+		switch($name) {
165
+			case $this->NS . ':feed':
166
+				$this->current = $this->feed;
167
+				break;
168
+			case $this->NS . ':entry':
169
+				$this->current = new AtomEntry();
170
+				break;
171
+		};
123 172
 
124
-        $parser = xml_parser_create_ns();
125
-        xml_set_object($parser, $this);
126
-        xml_set_element_handler($parser, "start_element", "end_element");
127
-        xml_parser_set_option($parser,XML_OPTION_CASE_FOLDING,0);
128
-        xml_parser_set_option($parser,XML_OPTION_SKIP_WHITE,0);
129
-        xml_set_character_data_handler($parser, "cdata");
130
-        xml_set_default_handler($parser, "_default");
131
-        xml_set_start_namespace_decl_handler($parser, "start_ns");
132
-        xml_set_end_namespace_decl_handler($parser, "end_ns");
173
+		$this->_p("start_element('$name')");
174
+		#$this->_p(print_r($this->ns_contexts,true));
175
+		#$this->_p('current(' . $this->current . ')');
133 176
 
134
-        $this->content = '';
177
+		array_unshift($this->ns_contexts, $this->ns_decls);
135 178
 
136
-        $ret = true;
179
+		$this->depth++;
137 180
 
138
-        $fp = fopen($this->FILE, "r");
139
-        while ($data = fread($fp, 4096)) {
140
-            if($this->debug) $this->content .= $data;
181
+		if(!empty($this->in_content)) {
141 182
 
142
-            if(!xml_parse($parser, $data, feof($fp))) {
143
-                /* translators: 1: error message, 2: line number */
144
-                trigger_error(sprintf(__('XML Error: %1$s at line %2$s')."\n",
145
-                    xml_error_string(xml_get_error_code($parser)),
146
-                    xml_get_current_line_number($parser)));
147
-                $ret = false;
148
-                break;
149
-            }
150
-        }
151
-        fclose($fp);
183
+			$this->content_ns_decls = array();
152 184
 
153
-        xml_parser_free($parser);
154
-
155
-        restore_error_handler();
156
-
157
-        return $ret;
158
-    }
159
-
160
-    function start_element($parser, $name, $attrs) {
161
-
162
-        $tag = array_pop(split(":", $name));
163
-
164
-        switch($name) {
165
-            case $this->NS . ':feed':
166
-                $this->current = $this->feed;
167
-                break;
168
-            case $this->NS . ':entry':
169
-                $this->current = new AtomEntry();
170
-                break;
171
-        };
172
-
173
-        $this->_p("start_element('$name')");
174
-        #$this->_p(print_r($this->ns_contexts,true));
175
-        #$this->_p('current(' . $this->current . ')');
176
-
177
-        array_unshift($this->ns_contexts, $this->ns_decls);
178
-
179
-        $this->depth++;
180
-
181
-        if(!empty($this->in_content)) {
182
-
183
-            $this->content_ns_decls = array();
184
-
185
-            if($this->is_html || $this->is_text)
186
-                trigger_error("Invalid content in element found. Content must not be of type text or html if it contains markup.");
187
-
188
-            $attrs_prefix = array();
189
-
190
-            // resolve prefixes for attributes
191
-            foreach($attrs as $key => $value) {
192
-                $with_prefix = $this->ns_to_prefix($key, true);
193
-                $attrs_prefix[$with_prefix[1]] = $this->xml_escape($value);
194
-            }
195
-
196
-            $attrs_str = join(' ', array_map($this->map_attrs_func, array_keys($attrs_prefix), array_values($attrs_prefix)));
197
-            if(strlen($attrs_str) > 0) {
198
-                $attrs_str = " " . $attrs_str;
199
-            }
200
-
201
-            $with_prefix = $this->ns_to_prefix($name);
202
-
203
-            if(!$this->is_declared_content_ns($with_prefix[0])) {
204
-                array_push($this->content_ns_decls, $with_prefix[0]);
205
-            }
206
-
207
-            $xmlns_str = '';
208
-            if(count($this->content_ns_decls) > 0) {
209
-                array_unshift($this->content_ns_contexts, $this->content_ns_decls);
210
-                $xmlns_str .= join(' ', array_map($this->map_xmlns_func, array_keys($this->content_ns_contexts[0]), array_values($this->content_ns_contexts[0])));
211
-                if(strlen($xmlns_str) > 0) {
212
-                    $xmlns_str = " " . $xmlns_str;
213
-                }
214
-            }
215
-
216
-            array_push($this->in_content, array($tag, $this->depth, "<". $with_prefix[1] ."{$xmlns_str}{$attrs_str}" . ">"));
217
-
218
-        } else if(in_array($tag, $this->ATOM_CONTENT_ELEMENTS) || in_array($tag, $this->ATOM_SIMPLE_ELEMENTS)) {
219
-            $this->in_content = array();
220
-            $this->is_xhtml = $attrs['type'] == 'xhtml';
221
-            $this->is_html = $attrs['type'] == 'html' || $attrs['type'] == 'text/html';
222
-            $this->is_text = !in_array('type',array_keys($attrs)) || $attrs['type'] == 'text';
223
-            $type = $this->is_xhtml ? 'XHTML' : ($this->is_html ? 'HTML' : ($this->is_text ? 'TEXT' : $attrs['type']));
224
-
225
-            if(in_array('src',array_keys($attrs))) {
226
-                $this->current->$tag = $attrs;
227
-            } else {
228
-                array_push($this->in_content, array($tag,$this->depth, $type));
229
-            }
230
-        } else if($tag == 'link') {
231
-            array_push($this->current->links, $attrs);
232
-        } else if($tag == 'category') {
233
-            array_push($this->current->categories, $attrs);
234
-        }
235
-
236
-        $this->ns_decls = array();
237
-    }
238
-
239
-    function end_element($parser, $name) {
240
-
241
-        $tag = array_pop(split(":", $name));
242
-
243
-        $ccount = count($this->in_content);
244
-
245
-        # if we are *in* content, then let's proceed to serialize it
246
-        if(!empty($this->in_content)) {
247
-            # if we are ending the original content element
248
-            # then let's finalize the content
249
-            if($this->in_content[0][0] == $tag &&
250
-                $this->in_content[0][1] == $this->depth) {
251
-                $origtype = $this->in_content[0][2];
252
-                array_shift($this->in_content);
253
-                $newcontent = array();
254
-                foreach($this->in_content as $c) {
255
-                    if(count($c) == 3) {
256
-                        array_push($newcontent, $c[2]);
257
-                    } else {
258
-                        if($this->is_xhtml || $this->is_text) {
259
-                            array_push($newcontent, $this->xml_escape($c));
260
-                        } else {
261
-                            array_push($newcontent, $c);
262
-                        }
263
-                    }
264
-                }
265
-                if(in_array($tag, $this->ATOM_CONTENT_ELEMENTS)) {
266
-                    $this->current->$tag = array($origtype, join('',$newcontent));
267
-                } else {
268
-                    $this->current->$tag = join('',$newcontent);
269
-                }
270
-                $this->in_content = array();
271
-            } else if($this->in_content[$ccount-1][0] == $tag &&
272
-                $this->in_content[$ccount-1][1] == $this->depth) {
273
-                $this->in_content[$ccount-1][2] = substr($this->in_content[$ccount-1][2],0,-1) . "/>";
274
-            } else {
275
-                # else, just finalize the current element's content
276
-                $endtag = $this->ns_to_prefix($name);
277
-                array_push($this->in_content, array($tag, $this->depth, "</$endtag[1]>"));
278
-            }
279
-        }
280
-
281
-        array_shift($this->ns_contexts);
282
-
283
-        $this->depth--;
284
-
285
-        if($name == ($this->NS . ':entry')) {
286
-            array_push($this->feed->entries, $this->current);
287
-            $this->current = null;
288
-        }
289
-
290
-        $this->_p("end_element('$name')");
291
-    }
292
-
293
-    function start_ns($parser, $prefix, $uri) {
294
-        $this->_p("starting: " . $prefix . ":" . $uri);
295
-        array_push($this->ns_decls, array($prefix,$uri));
296
-    }
297
-
298
-    function end_ns($parser, $prefix) {
299
-        $this->_p("ending: #" . $prefix . "#");
300
-    }
301
-
302
-    function cdata($parser, $data) {
303
-        $this->_p("data: #" . str_replace(array("\n"), array("\\n"), trim($data)) . "#");
304
-        if(!empty($this->in_content)) {
305
-            array_push($this->in_content, $data);
306
-        }
307
-    }
308
-
309
-    function _default($parser, $data) {
310
-        # when does this gets called?
311
-    }
312
-
313
-
314
-    function ns_to_prefix($qname, $attr=false) {
315
-        # split 'http://www.w3.org/1999/xhtml:div' into ('http','//www.w3.org/1999/xhtml','div')
316
-        $components = split(":", $qname);
317
-
318
-        # grab the last one (e.g 'div')
319
-        $name = array_pop($components);
320
-
321
-        if(!empty($components)) {
322
-            # re-join back the namespace component
323
-            $ns = join(":",$components);
324
-            foreach($this->ns_contexts as $context) {
325
-                foreach($context as $mapping) {
326
-                    if($mapping[1] == $ns && strlen($mapping[0]) > 0) {
327
-                        return array($mapping, "$mapping[0]:$name");
328
-                    }
329
-                }
330
-            }
331
-        }
332
-
333
-        if($attr) {
334
-            return array(null, $name);
335
-        } else {
336
-            foreach($this->ns_contexts as $context) {
337
-                foreach($context as $mapping) {
338
-                    if(strlen($mapping[0]) == 0) {
339
-                        return array($mapping, $name);
340
-                    }
341
-                }
342
-            }
343
-        }
344
-    }
345
-
346
-    function is_declared_content_ns($new_mapping) {
347
-        foreach($this->content_ns_contexts as $context) {
348
-            foreach($context as $mapping) {
349
-                if($new_mapping == $mapping) {
350
-                    return true;
351
-                }
352
-            }
353
-        }
354
-        return false;
355
-    }
356
-
357
-    function xml_escape($string)
358
-    {
359
-             return str_replace(array('&','"',"'",'<','>'),
360
-                array('&amp;','&quot;','&apos;','&lt;','&gt;'),
361
-                $string );
362
-    }
185
+			if($this->is_html || $this->is_text)
186
+				trigger_error("Invalid content in element found. Content must not be of type text or html if it contains markup.");
187
+
188
+			$attrs_prefix = array();
189
+
190
+			// resolve prefixes for attributes
191
+			foreach($attrs as $key => $value) {
192
+				$with_prefix = $this->ns_to_prefix($key, true);
193
+				$attrs_prefix[$with_prefix[1]] = $this->xml_escape($value);
194
+			}
195
+
196
+			$attrs_str = join(' ', array_map($this->map_attrs_func, array_keys($attrs_prefix), array_values($attrs_prefix)));
197
+			if(strlen($attrs_str) > 0) {
198
+				$attrs_str = " " . $attrs_str;
199
+			}
200
+
201
+			$with_prefix = $this->ns_to_prefix($name);
202
+
203
+			if(!$this->is_declared_content_ns($with_prefix[0])) {
204
+				array_push($this->content_ns_decls, $with_prefix[0]);
205
+			}
206
+
207
+			$xmlns_str = '';
208
+			if(count($this->content_ns_decls) > 0) {
209
+				array_unshift($this->content_ns_contexts, $this->content_ns_decls);
210
+				$xmlns_str .= join(' ', array_map($this->map_xmlns_func, array_keys($this->content_ns_contexts[0]), array_values($this->content_ns_contexts[0])));
211
+				if(strlen($xmlns_str) > 0) {
212
+					$xmlns_str = " " . $xmlns_str;
213
+				}
214
+			}
215
+
216
+			array_push($this->in_content, array($tag, $this->depth, "<". $with_prefix[1] ."{$xmlns_str}{$attrs_str}" . ">"));
217
+
218
+		} else if(in_array($tag, $this->ATOM_CONTENT_ELEMENTS) || in_array($tag, $this->ATOM_SIMPLE_ELEMENTS)) {
219
+			$this->in_content = array();
220
+			$this->is_xhtml = $attrs['type'] == 'xhtml';
221
+			$this->is_html = $attrs['type'] == 'html' || $attrs['type'] == 'text/html';
222
+			$this->is_text = !in_array('type',array_keys($attrs)) || $attrs['type'] == 'text';
223
+			$type = $this->is_xhtml ? 'XHTML' : ($this->is_html ? 'HTML' : ($this->is_text ? 'TEXT' : $attrs['type']));
224
+
225
+			if(in_array('src',array_keys($attrs))) {
226
+				$this->current->$tag = $attrs;
227
+			} else {
228
+				array_push($this->in_content, array($tag,$this->depth, $type));
229
+			}
230
+		} else if($tag == 'link') {
231
+			array_push($this->current->links, $attrs);
232
+		} else if($tag == 'category') {
233
+			array_push($this->current->categories, $attrs);
234
+		}
235
+
236
+		$this->ns_decls = array();
237
+	}
238
+
239
+	function end_element($parser, $name) {
240
+
241
+		$tag = array_pop(split(":", $name));
242
+
243
+		$ccount = count($this->in_content);
244
+
245
+		# if we are *in* content, then let's proceed to serialize it
246
+		if(!empty($this->in_content)) {
247
+			# if we are ending the original content element
248
+			# then let's finalize the content
249
+			if($this->in_content[0][0] == $tag &&
250
+				$this->in_content[0][1] == $this->depth) {
251
+				$origtype = $this->in_content[0][2];
252
+				array_shift($this->in_content);
253
+				$newcontent = array();
254
+				foreach($this->in_content as $c) {
255
+					if(count($c) == 3) {
256
+						array_push($newcontent, $c[2]);
257
+					} else {
258
+						if($this->is_xhtml || $this->is_text) {
259
+							array_push($newcontent, $this->xml_escape($c));
260
+						} else {
261
+							array_push($newcontent, $c);
262
+						}
263
+					}
264
+				}
265
+				if(in_array($tag, $this->ATOM_CONTENT_ELEMENTS)) {
266
+					$this->current->$tag = array($origtype, join('',$newcontent));
267
+				} else {
268
+					$this->current->$tag = join('',$newcontent);
269
+				}
270
+				$this->in_content = array();
271
+			} else if($this->in_content[$ccount-1][0] == $tag &&
272
+				$this->in_content[$ccount-1][1] == $this->depth) {
273
+				$this->in_content[$ccount-1][2] = substr($this->in_content[$ccount-1][2],0,-1) . "/>";
274
+			} else {
275
+				# else, just finalize the current element's content
276
+				$endtag = $this->ns_to_prefix($name);
277
+				array_push($this->in_content, array($tag, $this->depth, "</$endtag[1]>"));
278
+			}
279
+		}
280
+
281
+		array_shift($this->ns_contexts);
282
+
283
+		$this->depth--;
284
+
285
+		if($name == ($this->NS . ':entry')) {
286
+			array_push($this->feed->entries, $this->current);
287
+			$this->current = null;
288
+		}
289
+
290
+		$this->_p("end_element('$name')");
291
+	}
292
+
293
+	function start_ns($parser, $prefix, $uri) {
294
+		$this->_p("starting: " . $prefix . ":" . $uri);
295
+		array_push($this->ns_decls, array($prefix,$uri));
296
+	}
297
+
298
+	function end_ns($parser, $prefix) {
299
+		$this->_p("ending: #" . $prefix . "#");
300
+	}
301
+
302
+	function cdata($parser, $data) {
303
+		$this->_p("data: #" . str_replace(array("\n"), array("\\n"), trim($data)) . "#");
304
+		if(!empty($this->in_content)) {
305
+			array_push($this->in_content, $data);
306
+		}
307
+	}
308
+
309
+	function _default($parser, $data) {
310
+		# when does this gets called?
311
+	}
312
+
313
+
314
+	function ns_to_prefix($qname, $attr=false) {
315
+		# split 'http://www.w3.org/1999/xhtml:div' into ('http','//www.w3.org/1999/xhtml','div')
316
+		$components = split(":", $qname);
317
+
318
+		# grab the last one (e.g 'div')
319
+		$name = array_pop($components);
320
+
321
+		if(!empty($components)) {
322
+			# re-join back the namespace component
323
+			$ns = join(":",$components);
324
+			foreach($this->ns_contexts as $context) {
325
+				foreach($context as $mapping) {
326
+					if($mapping[1] == $ns && strlen($mapping[0]) > 0) {
327
+						return array($mapping, "$mapping[0]:$name");
328
+					}
329
+				}
330
+			}
331
+		}
332
+
333
+		if($attr) {
334
+			return array(null, $name);
335
+		} else {
336
+			foreach($this->ns_contexts as $context) {
337
+				foreach($context as $mapping) {
338
+					if(strlen($mapping[0]) == 0) {
339
+						return array($mapping, $name);
340
+					}
341
+				}
342
+			}
343
+		}
344
+	}
345
+
346
+	function is_declared_content_ns($new_mapping) {
347
+		foreach($this->content_ns_contexts as $context) {
348
+			foreach($context as $mapping) {
349
+				if($new_mapping == $mapping) {
350
+					return true;
351
+				}
352
+			}
353
+		}
354
+		return false;
355
+	}
356
+
357
+	function xml_escape($string)
358
+	{
359
+			 return str_replace(array('&','"',"'",'<','>'),
360
+				array('&amp;','&quot;','&apos;','&lt;','&gt;'),
361
+				$string );
362
+	}
363 363
 }
Please login to merge, or discard this patch.
Spacing   +60 added lines, -60 removed lines patch added patch discarded remove patch
@@ -65,8 +65,8 @@  discard block
 block discarded – undo
65 65
 class AtomParser {
66 66
 
67 67
     var $NS = 'http://www.w3.org/2005/Atom';
68
-    var $ATOM_CONTENT_ELEMENTS = array('content','summary','title','subtitle','rights');
69
-    var $ATOM_SIMPLE_ELEMENTS = array('id','updated','published','draft');
68
+    var $ATOM_CONTENT_ELEMENTS = array('content', 'summary', 'title', 'subtitle', 'rights');
69
+    var $ATOM_SIMPLE_ELEMENTS = array('id', 'updated', 'published', 'draft');
70 70
 
71 71
     var $debug = false;
72 72
 
@@ -106,8 +106,8 @@  discard block
 block discarded – undo
106 106
 	}
107 107
 
108 108
     function _p($msg) {
109
-        if($this->debug) {
110
-            print str_repeat(" ", $this->depth * $this->indent) . $msg ."\n";
109
+        if ($this->debug) {
110
+            print str_repeat(" ", $this->depth * $this->indent).$msg."\n";
111 111
         }
112 112
     }
113 113
 
@@ -124,8 +124,8 @@  discard block
 block discarded – undo
124 124
         $parser = xml_parser_create_ns();
125 125
         xml_set_object($parser, $this);
126 126
         xml_set_element_handler($parser, "start_element", "end_element");
127
-        xml_parser_set_option($parser,XML_OPTION_CASE_FOLDING,0);
128
-        xml_parser_set_option($parser,XML_OPTION_SKIP_WHITE,0);
127
+        xml_parser_set_option($parser, XML_OPTION_CASE_FOLDING, 0);
128
+        xml_parser_set_option($parser, XML_OPTION_SKIP_WHITE, 0);
129 129
         xml_set_character_data_handler($parser, "cdata");
130 130
         xml_set_default_handler($parser, "_default");
131 131
         xml_set_start_namespace_decl_handler($parser, "start_ns");
@@ -137,9 +137,9 @@  discard block
 block discarded – undo
137 137
 
138 138
         $fp = fopen($this->FILE, "r");
139 139
         while ($data = fread($fp, 4096)) {
140
-            if($this->debug) $this->content .= $data;
140
+            if ($this->debug) $this->content .= $data;
141 141
 
142
-            if(!xml_parse($parser, $data, feof($fp))) {
142
+            if ( ! xml_parse($parser, $data, feof($fp))) {
143 143
                 /* translators: 1: error message, 2: line number */
144 144
                 trigger_error(sprintf(__('XML Error: %1$s at line %2$s')."\n",
145 145
                     xml_error_string(xml_get_error_code($parser)),
@@ -161,11 +161,11 @@  discard block
 block discarded – undo
161 161
 
162 162
         $tag = array_pop(split(":", $name));
163 163
 
164
-        switch($name) {
165
-            case $this->NS . ':feed':
164
+        switch ($name) {
165
+            case $this->NS.':feed':
166 166
                 $this->current = $this->feed;
167 167
                 break;
168
-            case $this->NS . ':entry':
168
+            case $this->NS.':entry':
169 169
                 $this->current = new AtomEntry();
170 170
                 break;
171 171
         };
@@ -178,58 +178,58 @@  discard block
 block discarded – undo
178 178
 
179 179
         $this->depth++;
180 180
 
181
-        if(!empty($this->in_content)) {
181
+        if ( ! empty($this->in_content)) {
182 182
 
183 183
             $this->content_ns_decls = array();
184 184
 
185
-            if($this->is_html || $this->is_text)
185
+            if ($this->is_html || $this->is_text)
186 186
                 trigger_error("Invalid content in element found. Content must not be of type text or html if it contains markup.");
187 187
 
188 188
             $attrs_prefix = array();
189 189
 
190 190
             // resolve prefixes for attributes
191
-            foreach($attrs as $key => $value) {
191
+            foreach ($attrs as $key => $value) {
192 192
                 $with_prefix = $this->ns_to_prefix($key, true);
193 193
                 $attrs_prefix[$with_prefix[1]] = $this->xml_escape($value);
194 194
             }
195 195
 
196 196
             $attrs_str = join(' ', array_map($this->map_attrs_func, array_keys($attrs_prefix), array_values($attrs_prefix)));
197
-            if(strlen($attrs_str) > 0) {
198
-                $attrs_str = " " . $attrs_str;
197
+            if (strlen($attrs_str) > 0) {
198
+                $attrs_str = " ".$attrs_str;
199 199
             }
200 200
 
201 201
             $with_prefix = $this->ns_to_prefix($name);
202 202
 
203
-            if(!$this->is_declared_content_ns($with_prefix[0])) {
203
+            if ( ! $this->is_declared_content_ns($with_prefix[0])) {
204 204
                 array_push($this->content_ns_decls, $with_prefix[0]);
205 205
             }
206 206
 
207 207
             $xmlns_str = '';
208
-            if(count($this->content_ns_decls) > 0) {
208
+            if (count($this->content_ns_decls) > 0) {
209 209
                 array_unshift($this->content_ns_contexts, $this->content_ns_decls);
210 210
                 $xmlns_str .= join(' ', array_map($this->map_xmlns_func, array_keys($this->content_ns_contexts[0]), array_values($this->content_ns_contexts[0])));
211
-                if(strlen($xmlns_str) > 0) {
212
-                    $xmlns_str = " " . $xmlns_str;
211
+                if (strlen($xmlns_str) > 0) {
212
+                    $xmlns_str = " ".$xmlns_str;
213 213
                 }
214 214
             }
215 215
 
216
-            array_push($this->in_content, array($tag, $this->depth, "<". $with_prefix[1] ."{$xmlns_str}{$attrs_str}" . ">"));
216
+            array_push($this->in_content, array($tag, $this->depth, "<".$with_prefix[1]."{$xmlns_str}{$attrs_str}".">"));
217 217
 
218
-        } else if(in_array($tag, $this->ATOM_CONTENT_ELEMENTS) || in_array($tag, $this->ATOM_SIMPLE_ELEMENTS)) {
218
+        } else if (in_array($tag, $this->ATOM_CONTENT_ELEMENTS) || in_array($tag, $this->ATOM_SIMPLE_ELEMENTS)) {
219 219
             $this->in_content = array();
220 220
             $this->is_xhtml = $attrs['type'] == 'xhtml';
221 221
             $this->is_html = $attrs['type'] == 'html' || $attrs['type'] == 'text/html';
222
-            $this->is_text = !in_array('type',array_keys($attrs)) || $attrs['type'] == 'text';
222
+            $this->is_text = ! in_array('type', array_keys($attrs)) || $attrs['type'] == 'text';
223 223
             $type = $this->is_xhtml ? 'XHTML' : ($this->is_html ? 'HTML' : ($this->is_text ? 'TEXT' : $attrs['type']));
224 224
 
225
-            if(in_array('src',array_keys($attrs))) {
225
+            if (in_array('src', array_keys($attrs))) {
226 226
                 $this->current->$tag = $attrs;
227 227
             } else {
228
-                array_push($this->in_content, array($tag,$this->depth, $type));
228
+                array_push($this->in_content, array($tag, $this->depth, $type));
229 229
             }
230
-        } else if($tag == 'link') {
230
+        } else if ($tag == 'link') {
231 231
             array_push($this->current->links, $attrs);
232
-        } else if($tag == 'category') {
232
+        } else if ($tag == 'category') {
233 233
             array_push($this->current->categories, $attrs);
234 234
         }
235 235
 
@@ -243,34 +243,34 @@  discard block
 block discarded – undo
243 243
         $ccount = count($this->in_content);
244 244
 
245 245
         # if we are *in* content, then let's proceed to serialize it
246
-        if(!empty($this->in_content)) {
246
+        if ( ! empty($this->in_content)) {
247 247
             # if we are ending the original content element
248 248
             # then let's finalize the content
249
-            if($this->in_content[0][0] == $tag &&
249
+            if ($this->in_content[0][0] == $tag &&
250 250
                 $this->in_content[0][1] == $this->depth) {
251 251
                 $origtype = $this->in_content[0][2];
252 252
                 array_shift($this->in_content);
253 253
                 $newcontent = array();
254
-                foreach($this->in_content as $c) {
255
-                    if(count($c) == 3) {
254
+                foreach ($this->in_content as $c) {
255
+                    if (count($c) == 3) {
256 256
                         array_push($newcontent, $c[2]);
257 257
                     } else {
258
-                        if($this->is_xhtml || $this->is_text) {
258
+                        if ($this->is_xhtml || $this->is_text) {
259 259
                             array_push($newcontent, $this->xml_escape($c));
260 260
                         } else {
261 261
                             array_push($newcontent, $c);
262 262
                         }
263 263
                     }
264 264
                 }
265
-                if(in_array($tag, $this->ATOM_CONTENT_ELEMENTS)) {
266
-                    $this->current->$tag = array($origtype, join('',$newcontent));
265
+                if (in_array($tag, $this->ATOM_CONTENT_ELEMENTS)) {
266
+                    $this->current->$tag = array($origtype, join('', $newcontent));
267 267
                 } else {
268
-                    $this->current->$tag = join('',$newcontent);
268
+                    $this->current->$tag = join('', $newcontent);
269 269
                 }
270 270
                 $this->in_content = array();
271
-            } else if($this->in_content[$ccount-1][0] == $tag &&
272
-                $this->in_content[$ccount-1][1] == $this->depth) {
273
-                $this->in_content[$ccount-1][2] = substr($this->in_content[$ccount-1][2],0,-1) . "/>";
271
+            } else if ($this->in_content[$ccount - 1][0] == $tag &&
272
+                $this->in_content[$ccount - 1][1] == $this->depth) {
273
+                $this->in_content[$ccount - 1][2] = substr($this->in_content[$ccount - 1][2], 0, -1)."/>";
274 274
             } else {
275 275
                 # else, just finalize the current element's content
276 276
                 $endtag = $this->ns_to_prefix($name);
@@ -282,7 +282,7 @@  discard block
 block discarded – undo
282 282
 
283 283
         $this->depth--;
284 284
 
285
-        if($name == ($this->NS . ':entry')) {
285
+        if ($name == ($this->NS.':entry')) {
286 286
             array_push($this->feed->entries, $this->current);
287 287
             $this->current = null;
288 288
         }
@@ -291,17 +291,17 @@  discard block
 block discarded – undo
291 291
     }
292 292
 
293 293
     function start_ns($parser, $prefix, $uri) {
294
-        $this->_p("starting: " . $prefix . ":" . $uri);
295
-        array_push($this->ns_decls, array($prefix,$uri));
294
+        $this->_p("starting: ".$prefix.":".$uri);
295
+        array_push($this->ns_decls, array($prefix, $uri));
296 296
     }
297 297
 
298 298
     function end_ns($parser, $prefix) {
299
-        $this->_p("ending: #" . $prefix . "#");
299
+        $this->_p("ending: #".$prefix."#");
300 300
     }
301 301
 
302 302
     function cdata($parser, $data) {
303
-        $this->_p("data: #" . str_replace(array("\n"), array("\\n"), trim($data)) . "#");
304
-        if(!empty($this->in_content)) {
303
+        $this->_p("data: #".str_replace(array("\n"), array("\\n"), trim($data))."#");
304
+        if ( ! empty($this->in_content)) {
305 305
             array_push($this->in_content, $data);
306 306
         }
307 307
     }
@@ -311,31 +311,31 @@  discard block
 block discarded – undo
311 311
     }
312 312
 
313 313
 
314
-    function ns_to_prefix($qname, $attr=false) {
314
+    function ns_to_prefix($qname, $attr = false) {
315 315
         # split 'http://www.w3.org/1999/xhtml:div' into ('http','//www.w3.org/1999/xhtml','div')
316 316
         $components = split(":", $qname);
317 317
 
318 318
         # grab the last one (e.g 'div')
319 319
         $name = array_pop($components);
320 320
 
321
-        if(!empty($components)) {
321
+        if ( ! empty($components)) {
322 322
             # re-join back the namespace component
323
-            $ns = join(":",$components);
324
-            foreach($this->ns_contexts as $context) {
325
-                foreach($context as $mapping) {
326
-                    if($mapping[1] == $ns && strlen($mapping[0]) > 0) {
323
+            $ns = join(":", $components);
324
+            foreach ($this->ns_contexts as $context) {
325
+                foreach ($context as $mapping) {
326
+                    if ($mapping[1] == $ns && strlen($mapping[0]) > 0) {
327 327
                         return array($mapping, "$mapping[0]:$name");
328 328
                     }
329 329
                 }
330 330
             }
331 331
         }
332 332
 
333
-        if($attr) {
333
+        if ($attr) {
334 334
             return array(null, $name);
335 335
         } else {
336
-            foreach($this->ns_contexts as $context) {
337
-                foreach($context as $mapping) {
338
-                    if(strlen($mapping[0]) == 0) {
336
+            foreach ($this->ns_contexts as $context) {
337
+                foreach ($context as $mapping) {
338
+                    if (strlen($mapping[0]) == 0) {
339 339
                         return array($mapping, $name);
340 340
                     }
341 341
                 }
@@ -344,9 +344,9 @@  discard block
 block discarded – undo
344 344
     }
345 345
 
346 346
     function is_declared_content_ns($new_mapping) {
347
-        foreach($this->content_ns_contexts as $context) {
348
-            foreach($context as $mapping) {
349
-                if($new_mapping == $mapping) {
347
+        foreach ($this->content_ns_contexts as $context) {
348
+            foreach ($context as $mapping) {
349
+                if ($new_mapping == $mapping) {
350 350
                     return true;
351 351
                 }
352 352
             }
@@ -356,8 +356,8 @@  discard block
 block discarded – undo
356 356
 
357 357
     function xml_escape($string)
358 358
     {
359
-             return str_replace(array('&','"',"'",'<','>'),
360
-                array('&amp;','&quot;','&apos;','&lt;','&gt;'),
361
-                $string );
359
+             return str_replace(array('&', '"', "'", '<', '>'),
360
+                array('&amp;', '&quot;', '&apos;', '&lt;', '&gt;'),
361
+                $string);
362 362
     }
363 363
 }
Please login to merge, or discard this patch.
Braces   +6 added lines, -3 removed lines patch added patch discarded remove patch
@@ -137,7 +137,9 @@  discard block
 block discarded – undo
137 137
 
138 138
         $fp = fopen($this->FILE, "r");
139 139
         while ($data = fread($fp, 4096)) {
140
-            if($this->debug) $this->content .= $data;
140
+            if($this->debug) {
141
+            	$this->content .= $data;
142
+            }
141 143
 
142 144
             if(!xml_parse($parser, $data, feof($fp))) {
143 145
                 /* translators: 1: error message, 2: line number */
@@ -182,8 +184,9 @@  discard block
 block discarded – undo
182 184
 
183 185
             $this->content_ns_decls = array();
184 186
 
185
-            if($this->is_html || $this->is_text)
186
-                trigger_error("Invalid content in element found. Content must not be of type text or html if it contains markup.");
187
+            if($this->is_html || $this->is_text) {
188
+                            trigger_error("Invalid content in element found. Content must not be of type text or html if it contains markup.");
189
+            }
187 190
 
188 191
             $attrs_prefix = array();
189 192
 
Please login to merge, or discard this patch.
src/wp-includes/class-wp-image-editor-imagick.php 3 patches
Indentation   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -1,10 +1,10 @@
 block discarded – undo
1 1
 <?php
2 2
 /**
3
- * WordPress Imagick Image Editor
4
- *
5
- * @package WordPress
6
- * @subpackage Image_Editor
7
- */
3
+	 * WordPress Imagick Image Editor
4
+	 *
5
+	 * @package WordPress
6
+	 * @subpackage Image_Editor
7
+	 */
8 8
 
9 9
 /**
10 10
  * WordPress Image Editor Class for Image Manipulation through Imagick PHP Module
Please login to merge, or discard this patch.
Spacing   +111 added lines, -111 removed lines patch added patch discarded remove patch
@@ -24,7 +24,7 @@  discard block
 block discarded – undo
24 24
 	protected $image;
25 25
 
26 26
 	public function __destruct() {
27
-		if ( $this->image instanceof Imagick ) {
27
+		if ($this->image instanceof Imagick) {
28 28
 			// we don't need the original in memory anymore
29 29
 			$this->image->clear();
30 30
 			$this->image->destroy();
@@ -45,13 +45,13 @@  discard block
 block discarded – undo
45 45
 	 * @param array $args
46 46
 	 * @return bool
47 47
 	 */
48
-	public static function test( $args = array() ) {
48
+	public static function test($args = array()) {
49 49
 
50 50
 		// First, test Imagick's extension and classes.
51
-		if ( ! extension_loaded( 'imagick' ) || ! class_exists( 'Imagick' ) || ! class_exists( 'ImagickPixel' ) )
51
+		if ( ! extension_loaded('imagick') || ! class_exists('Imagick') || ! class_exists('ImagickPixel'))
52 52
 			return false;
53 53
 
54
-		if ( version_compare( phpversion( 'imagick' ), '2.2.0', '<' ) )
54
+		if (version_compare(phpversion('imagick'), '2.2.0', '<'))
55 55
 			return false;
56 56
 
57 57
 		$required_methods = array(
@@ -75,10 +75,10 @@  discard block
 block discarded – undo
75 75
 		);
76 76
 
77 77
 		// Now, test for deep requirements within Imagick.
78
-		if ( ! defined( 'imagick::COMPRESSION_JPEG' ) )
78
+		if ( ! defined('imagick::COMPRESSION_JPEG'))
79 79
 			return false;
80 80
 
81
-		if ( array_diff( $required_methods, get_class_methods( 'Imagick' ) ) )
81
+		if (array_diff($required_methods, get_class_methods('Imagick')))
82 82
 			return false;
83 83
 
84 84
 		return true;
@@ -95,21 +95,21 @@  discard block
 block discarded – undo
95 95
 	 * @param string $mime_type
96 96
 	 * @return bool
97 97
 	 */
98
-	public static function supports_mime_type( $mime_type ) {
99
-		$imagick_extension = strtoupper( self::get_extension( $mime_type ) );
98
+	public static function supports_mime_type($mime_type) {
99
+		$imagick_extension = strtoupper(self::get_extension($mime_type));
100 100
 
101
-		if ( ! $imagick_extension )
101
+		if ( ! $imagick_extension)
102 102
 			return false;
103 103
 
104 104
 		// setIteratorIndex is optional unless mime is an animated format.
105 105
 		// Here, we just say no if you are missing it and aren't loading a jpeg.
106
-		if ( ! method_exists( 'Imagick', 'setIteratorIndex' ) && $mime_type != 'image/jpeg' )
106
+		if ( ! method_exists('Imagick', 'setIteratorIndex') && $mime_type != 'image/jpeg')
107 107
 				return false;
108 108
 
109 109
 		try {
110
-			return ( (bool) @Imagick::queryFormats( $imagick_extension ) );
110
+			return ((bool) @Imagick::queryFormats($imagick_extension));
111 111
 		}
112
-		catch ( Exception $e ) {
112
+		catch (Exception $e) {
113 113
 			return false;
114 114
 		}
115 115
 	}
@@ -123,34 +123,34 @@  discard block
 block discarded – undo
123 123
 	 * @return true|WP_Error True if loaded; WP_Error on failure.
124 124
 	 */
125 125
 	public function load() {
126
-		if ( $this->image instanceof Imagick )
126
+		if ($this->image instanceof Imagick)
127 127
 			return true;
128 128
 
129
-		if ( ! is_file( $this->file ) && ! preg_match( '|^https?://|', $this->file ) )
130
-			return new WP_Error( 'error_loading_image', __('File doesn&#8217;t exist?'), $this->file );
129
+		if ( ! is_file($this->file) && ! preg_match('|^https?://|', $this->file))
130
+			return new WP_Error('error_loading_image', __('File doesn&#8217;t exist?'), $this->file);
131 131
 
132 132
 		/** This filter is documented in wp-includes/class-wp-image-editor-imagick.php */
133 133
 		// Even though Imagick uses less PHP memory than GD, set higher limit for users that have low PHP.ini limits
134
-		@ini_set( 'memory_limit', apply_filters( 'image_memory_limit', WP_MAX_MEMORY_LIMIT ) );
134
+		@ini_set('memory_limit', apply_filters('image_memory_limit', WP_MAX_MEMORY_LIMIT));
135 135
 
136 136
 		try {
137
-			$this->image = new Imagick( $this->file );
137
+			$this->image = new Imagick($this->file);
138 138
 
139
-			if ( ! $this->image->valid() )
140
-				return new WP_Error( 'invalid_image', __('File is not an image.'), $this->file);
139
+			if ( ! $this->image->valid())
140
+				return new WP_Error('invalid_image', __('File is not an image.'), $this->file);
141 141
 
142 142
 			// Select the first frame to handle animated images properly
143
-			if ( is_callable( array( $this->image, 'setIteratorIndex' ) ) )
143
+			if (is_callable(array($this->image, 'setIteratorIndex')))
144 144
 				$this->image->setIteratorIndex(0);
145 145
 
146
-			$this->mime_type = $this->get_mime_type( $this->image->getImageFormat() );
146
+			$this->mime_type = $this->get_mime_type($this->image->getImageFormat());
147 147
 		}
148
-		catch ( Exception $e ) {
149
-			return new WP_Error( 'invalid_image', $e->getMessage(), $this->file );
148
+		catch (Exception $e) {
149
+			return new WP_Error('invalid_image', $e->getMessage(), $this->file);
150 150
 		}
151 151
 
152 152
 		$updated_size = $this->update_size();
153
-		if ( is_wp_error( $updated_size ) ) {
153
+		if (is_wp_error($updated_size)) {
154 154
 			return $updated_size;
155 155
 		}
156 156
 
@@ -166,25 +166,25 @@  discard block
 block discarded – undo
166 166
 	 * @param int $quality Compression Quality. Range: [1,100]
167 167
 	 * @return true|WP_Error True if set successfully; WP_Error on failure.
168 168
 	 */
169
-	public function set_quality( $quality = null ) {
170
-		$quality_result = parent::set_quality( $quality );
171
-		if ( is_wp_error( $quality_result ) ) {
169
+	public function set_quality($quality = null) {
170
+		$quality_result = parent::set_quality($quality);
171
+		if (is_wp_error($quality_result)) {
172 172
 			return $quality_result;
173 173
 		} else {
174 174
 			$quality = $this->get_quality();
175 175
 		}
176 176
 
177 177
 		try {
178
-			if ( 'image/jpeg' == $this->mime_type ) {
179
-				$this->image->setImageCompressionQuality( $quality );
180
-				$this->image->setImageCompression( imagick::COMPRESSION_JPEG );
178
+			if ('image/jpeg' == $this->mime_type) {
179
+				$this->image->setImageCompressionQuality($quality);
180
+				$this->image->setImageCompression(imagick::COMPRESSION_JPEG);
181 181
 			}
182 182
 			else {
183
-				$this->image->setImageCompressionQuality( $quality );
183
+				$this->image->setImageCompressionQuality($quality);
184 184
 			}
185 185
 		}
186
-		catch ( Exception $e ) {
187
-			return new WP_Error( 'image_quality_error', $e->getMessage() );
186
+		catch (Exception $e) {
187
+			return new WP_Error('image_quality_error', $e->getMessage());
188 188
 		}
189 189
 
190 190
 		return true;
@@ -201,24 +201,24 @@  discard block
 block discarded – undo
201 201
 	 *
202 202
 	 * @return true|WP_Error
203 203
 	 */
204
-	protected function update_size( $width = null, $height = null ) {
204
+	protected function update_size($width = null, $height = null) {
205 205
 		$size = null;
206
-		if ( !$width || !$height ) {
206
+		if ( ! $width || ! $height) {
207 207
 			try {
208 208
 				$size = $this->image->getImageGeometry();
209 209
 			}
210
-			catch ( Exception $e ) {
211
-				return new WP_Error( 'invalid_image', __('Could not read image size'), $this->file );
210
+			catch (Exception $e) {
211
+				return new WP_Error('invalid_image', __('Could not read image size'), $this->file);
212 212
 			}
213 213
 		}
214 214
 
215
-		if ( ! $width )
215
+		if ( ! $width)
216 216
 			$width = $size['width'];
217 217
 
218
-		if ( ! $height )
218
+		if ( ! $height)
219 219
 			$height = $size['height'];
220 220
 
221
-		return parent::update_size( $width, $height );
221
+		return parent::update_size($width, $height);
222 222
 	}
223 223
 
224 224
 	/**
@@ -236,17 +236,17 @@  discard block
 block discarded – undo
236 236
 	 * @param  bool     $crop
237 237
 	 * @return bool|WP_Error
238 238
 	 */
239
-	public function resize( $max_w, $max_h, $crop = false ) {
240
-		if ( ( $this->size['width'] == $max_w ) && ( $this->size['height'] == $max_h ) )
239
+	public function resize($max_w, $max_h, $crop = false) {
240
+		if (($this->size['width'] == $max_w) && ($this->size['height'] == $max_h))
241 241
 			return true;
242 242
 
243
-		$dims = image_resize_dimensions( $this->size['width'], $this->size['height'], $max_w, $max_h, $crop );
244
-		if ( ! $dims )
245
-			return new WP_Error( 'error_getting_dimensions', __('Could not calculate resized image dimensions') );
246
-		list( $dst_x, $dst_y, $src_x, $src_y, $dst_w, $dst_h, $src_w, $src_h ) = $dims;
243
+		$dims = image_resize_dimensions($this->size['width'], $this->size['height'], $max_w, $max_h, $crop);
244
+		if ( ! $dims)
245
+			return new WP_Error('error_getting_dimensions', __('Could not calculate resized image dimensions'));
246
+		list($dst_x, $dst_y, $src_x, $src_y, $dst_w, $dst_h, $src_w, $src_h) = $dims;
247 247
 
248
-		if ( $crop ) {
249
-			return $this->crop( $src_x, $src_y, $src_w, $src_h, $dst_w, $dst_h );
248
+		if ($crop) {
249
+			return $this->crop($src_x, $src_y, $src_w, $src_h, $dst_w, $dst_h);
250 250
 		}
251 251
 
252 252
 		try {
@@ -254,13 +254,13 @@  discard block
 block discarded – undo
254 254
 			 * @TODO: Thumbnail is more efficient, given a newer version of Imagemagick.
255 255
 			 * $this->image->thumbnailImage( $dst_w, $dst_h );
256 256
 			 */
257
-			$this->image->scaleImage( $dst_w, $dst_h );
257
+			$this->image->scaleImage($dst_w, $dst_h);
258 258
 		}
259
-		catch ( Exception $e ) {
260
-			return new WP_Error( 'image_resize_error', $e->getMessage() );
259
+		catch (Exception $e) {
260
+			return new WP_Error('image_resize_error', $e->getMessage());
261 261
 		}
262 262
 
263
-		return $this->update_size( $dst_w, $dst_h );
263
+		return $this->update_size($dst_w, $dst_h);
264 264
 	}
265 265
 
266 266
 	/**
@@ -284,42 +284,42 @@  discard block
 block discarded – undo
284 284
 	 * }
285 285
 	 * @return array An array of resized images' metadata by size.
286 286
 	 */
287
-	public function multi_resize( $sizes ) {
287
+	public function multi_resize($sizes) {
288 288
 		$metadata = array();
289 289
 		$orig_size = $this->size;
290 290
 		$orig_image = $this->image->getImage();
291 291
 
292
-		foreach ( $sizes as $size => $size_data ) {
293
-			if ( ! $this->image )
292
+		foreach ($sizes as $size => $size_data) {
293
+			if ( ! $this->image)
294 294
 				$this->image = $orig_image->getImage();
295 295
 
296
-			if ( ! isset( $size_data['width'] ) && ! isset( $size_data['height'] ) ) {
296
+			if ( ! isset($size_data['width']) && ! isset($size_data['height'])) {
297 297
 				continue;
298 298
 			}
299 299
 
300
-			if ( ! isset( $size_data['width'] ) ) {
300
+			if ( ! isset($size_data['width'])) {
301 301
 				$size_data['width'] = null;
302 302
 			}
303
-			if ( ! isset( $size_data['height'] ) ) {
303
+			if ( ! isset($size_data['height'])) {
304 304
 				$size_data['height'] = null;
305 305
 			}
306 306
 
307
-			if ( ! isset( $size_data['crop'] ) ) {
307
+			if ( ! isset($size_data['crop'])) {
308 308
 				$size_data['crop'] = false;
309 309
 			}
310 310
 
311
-			$resize_result = $this->resize( $size_data['width'], $size_data['height'], $size_data['crop'] );
312
-			$duplicate = ( ( $orig_size['width'] == $size_data['width'] ) && ( $orig_size['height'] == $size_data['height'] ) );
311
+			$resize_result = $this->resize($size_data['width'], $size_data['height'], $size_data['crop']);
312
+			$duplicate = (($orig_size['width'] == $size_data['width']) && ($orig_size['height'] == $size_data['height']));
313 313
 
314
-			if ( ! is_wp_error( $resize_result ) && ! $duplicate ) {
315
-				$resized = $this->_save( $this->image );
314
+			if ( ! is_wp_error($resize_result) && ! $duplicate) {
315
+				$resized = $this->_save($this->image);
316 316
 
317 317
 				$this->image->clear();
318 318
 				$this->image->destroy();
319 319
 				$this->image = null;
320 320
 
321
-				if ( ! is_wp_error( $resized ) && $resized ) {
322
-					unset( $resized['path'] );
321
+				if ( ! is_wp_error($resized) && $resized) {
322
+					unset($resized['path']);
323 323
 					$metadata[$size] = $resized;
324 324
 				}
325 325
 			}
@@ -347,30 +347,30 @@  discard block
 block discarded – undo
347 347
 	 * @param bool $src_abs Optional. If the source crop points are absolute.
348 348
 	 * @return bool|WP_Error
349 349
 	 */
350
-	public function crop( $src_x, $src_y, $src_w, $src_h, $dst_w = null, $dst_h = null, $src_abs = false ) {
351
-		if ( $src_abs ) {
350
+	public function crop($src_x, $src_y, $src_w, $src_h, $dst_w = null, $dst_h = null, $src_abs = false) {
351
+		if ($src_abs) {
352 352
 			$src_w -= $src_x;
353 353
 			$src_h -= $src_y;
354 354
 		}
355 355
 
356 356
 		try {
357
-			$this->image->cropImage( $src_w, $src_h, $src_x, $src_y );
358
-			$this->image->setImagePage( $src_w, $src_h, 0, 0);
357
+			$this->image->cropImage($src_w, $src_h, $src_x, $src_y);
358
+			$this->image->setImagePage($src_w, $src_h, 0, 0);
359 359
 
360
-			if ( $dst_w || $dst_h ) {
360
+			if ($dst_w || $dst_h) {
361 361
 				// If destination width/height isn't specified, use same as
362 362
 				// width/height from source.
363
-				if ( ! $dst_w )
363
+				if ( ! $dst_w)
364 364
 					$dst_w = $src_w;
365
-				if ( ! $dst_h )
365
+				if ( ! $dst_h)
366 366
 					$dst_h = $src_h;
367 367
 
368
-				$this->image->scaleImage( $dst_w, $dst_h );
368
+				$this->image->scaleImage($dst_w, $dst_h);
369 369
 				return $this->update_size();
370 370
 			}
371 371
 		}
372
-		catch ( Exception $e ) {
373
-			return new WP_Error( 'image_crop_error', $e->getMessage() );
372
+		catch (Exception $e) {
373
+			return new WP_Error('image_crop_error', $e->getMessage());
374 374
 		}
375 375
 		return $this->update_size();
376 376
 	}
@@ -384,23 +384,23 @@  discard block
 block discarded – undo
384 384
 	 * @param float $angle
385 385
 	 * @return true|WP_Error
386 386
 	 */
387
-	public function rotate( $angle ) {
387
+	public function rotate($angle) {
388 388
 		/**
389 389
 		 * $angle is 360-$angle because Imagick rotates clockwise
390 390
 		 * (GD rotates counter-clockwise)
391 391
 		 */
392 392
 		try {
393
-			$this->image->rotateImage( new ImagickPixel('none'), 360-$angle );
393
+			$this->image->rotateImage(new ImagickPixel('none'), 360 - $angle);
394 394
 
395 395
 			// Since this changes the dimensions of the image, update the size.
396 396
 			$result = $this->update_size();
397
-			if ( is_wp_error( $result ) )
397
+			if (is_wp_error($result))
398 398
 				return $result;
399 399
 
400
-			$this->image->setImagePage( $this->size['width'], $this->size['height'], 0, 0 );
400
+			$this->image->setImagePage($this->size['width'], $this->size['height'], 0, 0);
401 401
 		}
402
-		catch ( Exception $e ) {
403
-			return new WP_Error( 'image_rotate_error', $e->getMessage() );
402
+		catch (Exception $e) {
403
+			return new WP_Error('image_rotate_error', $e->getMessage());
404 404
 		}
405 405
 		return true;
406 406
 	}
@@ -415,16 +415,16 @@  discard block
 block discarded – undo
415 415
 	 * @param bool $vert Flip along Vertical Axis
416 416
 	 * @return true|WP_Error
417 417
 	 */
418
-	public function flip( $horz, $vert ) {
418
+	public function flip($horz, $vert) {
419 419
 		try {
420
-			if ( $horz )
420
+			if ($horz)
421 421
 				$this->image->flipImage();
422 422
 
423
-			if ( $vert )
423
+			if ($vert)
424 424
 				$this->image->flopImage();
425 425
 		}
426
-		catch ( Exception $e ) {
427
-			return new WP_Error( 'image_flip_error', $e->getMessage() );
426
+		catch (Exception $e) {
427
+			return new WP_Error('image_flip_error', $e->getMessage());
428 428
 		}
429 429
 		return true;
430 430
 	}
@@ -439,18 +439,18 @@  discard block
 block discarded – undo
439 439
 	 * @param string $mime_type
440 440
 	 * @return array|WP_Error {'path'=>string, 'file'=>string, 'width'=>int, 'height'=>int, 'mime-type'=>string}
441 441
 	 */
442
-	public function save( $destfilename = null, $mime_type = null ) {
443
-		$saved = $this->_save( $this->image, $destfilename, $mime_type );
442
+	public function save($destfilename = null, $mime_type = null) {
443
+		$saved = $this->_save($this->image, $destfilename, $mime_type);
444 444
 
445
-		if ( ! is_wp_error( $saved ) ) {
445
+		if ( ! is_wp_error($saved)) {
446 446
 			$this->file = $saved['path'];
447 447
 			$this->mime_type = $saved['mime-type'];
448 448
 
449 449
 			try {
450
-				$this->image->setImageFormat( strtoupper( $this->get_extension( $this->mime_type ) ) );
450
+				$this->image->setImageFormat(strtoupper($this->get_extension($this->mime_type)));
451 451
 			}
452
-			catch ( Exception $e ) {
453
-				return new WP_Error( 'image_save_error', $e->getMessage(), $this->file );
452
+			catch (Exception $e) {
453
+				return new WP_Error('image_save_error', $e->getMessage(), $this->file);
454 454
 			}
455 455
 		}
456 456
 
@@ -464,35 +464,35 @@  discard block
 block discarded – undo
464 464
 	 * @param string $mime_type
465 465
 	 * @return array|WP_Error
466 466
 	 */
467
-	protected function _save( $image, $filename = null, $mime_type = null ) {
468
-		list( $filename, $extension, $mime_type ) = $this->get_output_format( $filename, $mime_type );
467
+	protected function _save($image, $filename = null, $mime_type = null) {
468
+		list($filename, $extension, $mime_type) = $this->get_output_format($filename, $mime_type);
469 469
 
470
-		if ( ! $filename )
471
-			$filename = $this->generate_filename( null, null, $extension );
470
+		if ( ! $filename)
471
+			$filename = $this->generate_filename(null, null, $extension);
472 472
 
473 473
 		try {
474 474
 			// Store initial Format
475 475
 			$orig_format = $this->image->getImageFormat();
476 476
 
477
-			$this->image->setImageFormat( strtoupper( $this->get_extension( $mime_type ) ) );
478
-			$this->make_image( $filename, array( $image, 'writeImage' ), array( $filename ) );
477
+			$this->image->setImageFormat(strtoupper($this->get_extension($mime_type)));
478
+			$this->make_image($filename, array($image, 'writeImage'), array($filename));
479 479
 
480 480
 			// Reset original Format
481
-			$this->image->setImageFormat( $orig_format );
481
+			$this->image->setImageFormat($orig_format);
482 482
 		}
483
-		catch ( Exception $e ) {
484
-			return new WP_Error( 'image_save_error', $e->getMessage(), $filename );
483
+		catch (Exception $e) {
484
+			return new WP_Error('image_save_error', $e->getMessage(), $filename);
485 485
 		}
486 486
 
487 487
 		// Set correct file permissions
488
-		$stat = stat( dirname( $filename ) );
488
+		$stat = stat(dirname($filename));
489 489
 		$perms = $stat['mode'] & 0000666; //same permissions as parent folder, strip off the executable bits
490
-		@ chmod( $filename, $perms );
490
+		@ chmod($filename, $perms);
491 491
 
492 492
 		/** This filter is documented in wp-includes/class-wp-image-editor-gd.php */
493 493
 		return array(
494 494
 			'path'      => $filename,
495
-			'file'      => wp_basename( apply_filters( 'image_make_intermediate_size', $filename ) ),
495
+			'file'      => wp_basename(apply_filters('image_make_intermediate_size', $filename)),
496 496
 			'width'     => $this->size['width'],
497 497
 			'height'    => $this->size['height'],
498 498
 			'mime-type' => $mime_type,
@@ -508,22 +508,22 @@  discard block
 block discarded – undo
508 508
 	 * @param string $mime_type
509 509
 	 * @return true|WP_Error
510 510
 	 */
511
-	public function stream( $mime_type = null ) {
512
-		list( $filename, $extension, $mime_type ) = $this->get_output_format( null, $mime_type );
511
+	public function stream($mime_type = null) {
512
+		list($filename, $extension, $mime_type) = $this->get_output_format(null, $mime_type);
513 513
 
514 514
 		try {
515 515
 			// Temporarily change format for stream
516
-			$this->image->setImageFormat( strtoupper( $extension ) );
516
+			$this->image->setImageFormat(strtoupper($extension));
517 517
 
518 518
 			// Output stream of image content
519
-			header( "Content-Type: $mime_type" );
519
+			header("Content-Type: $mime_type");
520 520
 			print $this->image->getImageBlob();
521 521
 
522 522
 			// Reset Image to original Format
523
-			$this->image->setImageFormat( $this->get_extension( $this->mime_type ) );
523
+			$this->image->setImageFormat($this->get_extension($this->mime_type));
524 524
 		}
525
-		catch ( Exception $e ) {
526
-			return new WP_Error( 'image_stream_error', $e->getMessage() );
525
+		catch (Exception $e) {
526
+			return new WP_Error('image_stream_error', $e->getMessage());
527 527
 		}
528 528
 
529 529
 		return true;
Please login to merge, or discard this patch.
Braces   +75 added lines, -66 removed lines patch added patch discarded remove patch
@@ -48,11 +48,13 @@  discard block
 block discarded – undo
48 48
 	public static function test( $args = array() ) {
49 49
 
50 50
 		// First, test Imagick's extension and classes.
51
-		if ( ! extension_loaded( 'imagick' ) || ! class_exists( 'Imagick' ) || ! class_exists( 'ImagickPixel' ) )
52
-			return false;
51
+		if ( ! extension_loaded( 'imagick' ) || ! class_exists( 'Imagick' ) || ! class_exists( 'ImagickPixel' ) ) {
52
+					return false;
53
+		}
53 54
 
54
-		if ( version_compare( phpversion( 'imagick' ), '2.2.0', '<' ) )
55
-			return false;
55
+		if ( version_compare( phpversion( 'imagick' ), '2.2.0', '<' ) ) {
56
+					return false;
57
+		}
56 58
 
57 59
 		$required_methods = array(
58 60
 			'clear',
@@ -75,11 +77,13 @@  discard block
 block discarded – undo
75 77
 		);
76 78
 
77 79
 		// Now, test for deep requirements within Imagick.
78
-		if ( ! defined( 'imagick::COMPRESSION_JPEG' ) )
79
-			return false;
80
+		if ( ! defined( 'imagick::COMPRESSION_JPEG' ) ) {
81
+					return false;
82
+		}
80 83
 
81
-		if ( array_diff( $required_methods, get_class_methods( 'Imagick' ) ) )
82
-			return false;
84
+		if ( array_diff( $required_methods, get_class_methods( 'Imagick' ) ) ) {
85
+					return false;
86
+		}
83 87
 
84 88
 		return true;
85 89
 	}
@@ -98,18 +102,19 @@  discard block
 block discarded – undo
98 102
 	public static function supports_mime_type( $mime_type ) {
99 103
 		$imagick_extension = strtoupper( self::get_extension( $mime_type ) );
100 104
 
101
-		if ( ! $imagick_extension )
102
-			return false;
105
+		if ( ! $imagick_extension ) {
106
+					return false;
107
+		}
103 108
 
104 109
 		// setIteratorIndex is optional unless mime is an animated format.
105 110
 		// Here, we just say no if you are missing it and aren't loading a jpeg.
106
-		if ( ! method_exists( 'Imagick', 'setIteratorIndex' ) && $mime_type != 'image/jpeg' )
107
-				return false;
111
+		if ( ! method_exists( 'Imagick', 'setIteratorIndex' ) && $mime_type != 'image/jpeg' ) {
112
+						return false;
113
+		}
108 114
 
109 115
 		try {
110 116
 			return ( (bool) @Imagick::queryFormats( $imagick_extension ) );
111
-		}
112
-		catch ( Exception $e ) {
117
+		} catch ( Exception $e ) {
113 118
 			return false;
114 119
 		}
115 120
 	}
@@ -123,11 +128,13 @@  discard block
 block discarded – undo
123 128
 	 * @return true|WP_Error True if loaded; WP_Error on failure.
124 129
 	 */
125 130
 	public function load() {
126
-		if ( $this->image instanceof Imagick )
127
-			return true;
131
+		if ( $this->image instanceof Imagick ) {
132
+					return true;
133
+		}
128 134
 
129
-		if ( ! is_file( $this->file ) && ! preg_match( '|^https?://|', $this->file ) )
130
-			return new WP_Error( 'error_loading_image', __('File doesn&#8217;t exist?'), $this->file );
135
+		if ( ! is_file( $this->file ) && ! preg_match( '|^https?://|', $this->file ) ) {
136
+					return new WP_Error( 'error_loading_image', __('File doesn&#8217;t exist?'), $this->file );
137
+		}
131 138
 
132 139
 		/** This filter is documented in wp-includes/class-wp-image-editor-imagick.php */
133 140
 		// Even though Imagick uses less PHP memory than GD, set higher limit for users that have low PHP.ini limits
@@ -136,16 +143,17 @@  discard block
 block discarded – undo
136 143
 		try {
137 144
 			$this->image = new Imagick( $this->file );
138 145
 
139
-			if ( ! $this->image->valid() )
140
-				return new WP_Error( 'invalid_image', __('File is not an image.'), $this->file);
146
+			if ( ! $this->image->valid() ) {
147
+							return new WP_Error( 'invalid_image', __('File is not an image.'), $this->file);
148
+			}
141 149
 
142 150
 			// Select the first frame to handle animated images properly
143
-			if ( is_callable( array( $this->image, 'setIteratorIndex' ) ) )
144
-				$this->image->setIteratorIndex(0);
151
+			if ( is_callable( array( $this->image, 'setIteratorIndex' ) ) ) {
152
+							$this->image->setIteratorIndex(0);
153
+			}
145 154
 
146 155
 			$this->mime_type = $this->get_mime_type( $this->image->getImageFormat() );
147
-		}
148
-		catch ( Exception $e ) {
156
+		} catch ( Exception $e ) {
149 157
 			return new WP_Error( 'invalid_image', $e->getMessage(), $this->file );
150 158
 		}
151 159
 
@@ -178,12 +186,10 @@  discard block
 block discarded – undo
178 186
 			if ( 'image/jpeg' == $this->mime_type ) {
179 187
 				$this->image->setImageCompressionQuality( $quality );
180 188
 				$this->image->setImageCompression( imagick::COMPRESSION_JPEG );
181
-			}
182
-			else {
189
+			} else {
183 190
 				$this->image->setImageCompressionQuality( $quality );
184 191
 			}
185
-		}
186
-		catch ( Exception $e ) {
192
+		} catch ( Exception $e ) {
187 193
 			return new WP_Error( 'image_quality_error', $e->getMessage() );
188 194
 		}
189 195
 
@@ -206,17 +212,18 @@  discard block
 block discarded – undo
206 212
 		if ( !$width || !$height ) {
207 213
 			try {
208 214
 				$size = $this->image->getImageGeometry();
209
-			}
210
-			catch ( Exception $e ) {
215
+			} catch ( Exception $e ) {
211 216
 				return new WP_Error( 'invalid_image', __('Could not read image size'), $this->file );
212 217
 			}
213 218
 		}
214 219
 
215
-		if ( ! $width )
216
-			$width = $size['width'];
220
+		if ( ! $width ) {
221
+					$width = $size['width'];
222
+		}
217 223
 
218
-		if ( ! $height )
219
-			$height = $size['height'];
224
+		if ( ! $height ) {
225
+					$height = $size['height'];
226
+		}
220 227
 
221 228
 		return parent::update_size( $width, $height );
222 229
 	}
@@ -237,12 +244,14 @@  discard block
 block discarded – undo
237 244
 	 * @return bool|WP_Error
238 245
 	 */
239 246
 	public function resize( $max_w, $max_h, $crop = false ) {
240
-		if ( ( $this->size['width'] == $max_w ) && ( $this->size['height'] == $max_h ) )
241
-			return true;
247
+		if ( ( $this->size['width'] == $max_w ) && ( $this->size['height'] == $max_h ) ) {
248
+					return true;
249
+		}
242 250
 
243 251
 		$dims = image_resize_dimensions( $this->size['width'], $this->size['height'], $max_w, $max_h, $crop );
244
-		if ( ! $dims )
245
-			return new WP_Error( 'error_getting_dimensions', __('Could not calculate resized image dimensions') );
252
+		if ( ! $dims ) {
253
+					return new WP_Error( 'error_getting_dimensions', __('Could not calculate resized image dimensions') );
254
+		}
246 255
 		list( $dst_x, $dst_y, $src_x, $src_y, $dst_w, $dst_h, $src_w, $src_h ) = $dims;
247 256
 
248 257
 		if ( $crop ) {
@@ -255,8 +264,7 @@  discard block
 block discarded – undo
255 264
 			 * $this->image->thumbnailImage( $dst_w, $dst_h );
256 265
 			 */
257 266
 			$this->image->scaleImage( $dst_w, $dst_h );
258
-		}
259
-		catch ( Exception $e ) {
267
+		} catch ( Exception $e ) {
260 268
 			return new WP_Error( 'image_resize_error', $e->getMessage() );
261 269
 		}
262 270
 
@@ -290,8 +298,9 @@  discard block
 block discarded – undo
290 298
 		$orig_image = $this->image->getImage();
291 299
 
292 300
 		foreach ( $sizes as $size => $size_data ) {
293
-			if ( ! $this->image )
294
-				$this->image = $orig_image->getImage();
301
+			if ( ! $this->image ) {
302
+							$this->image = $orig_image->getImage();
303
+			}
295 304
 
296 305
 			if ( ! isset( $size_data['width'] ) && ! isset( $size_data['height'] ) ) {
297 306
 				continue;
@@ -360,16 +369,17 @@  discard block
 block discarded – undo
360 369
 			if ( $dst_w || $dst_h ) {
361 370
 				// If destination width/height isn't specified, use same as
362 371
 				// width/height from source.
363
-				if ( ! $dst_w )
364
-					$dst_w = $src_w;
365
-				if ( ! $dst_h )
366
-					$dst_h = $src_h;
372
+				if ( ! $dst_w ) {
373
+									$dst_w = $src_w;
374
+				}
375
+				if ( ! $dst_h ) {
376
+									$dst_h = $src_h;
377
+				}
367 378
 
368 379
 				$this->image->scaleImage( $dst_w, $dst_h );
369 380
 				return $this->update_size();
370 381
 			}
371
-		}
372
-		catch ( Exception $e ) {
382
+		} catch ( Exception $e ) {
373 383
 			return new WP_Error( 'image_crop_error', $e->getMessage() );
374 384
 		}
375 385
 		return $this->update_size();
@@ -394,12 +404,12 @@  discard block
 block discarded – undo
394 404
 
395 405
 			// Since this changes the dimensions of the image, update the size.
396 406
 			$result = $this->update_size();
397
-			if ( is_wp_error( $result ) )
398
-				return $result;
407
+			if ( is_wp_error( $result ) ) {
408
+							return $result;
409
+			}
399 410
 
400 411
 			$this->image->setImagePage( $this->size['width'], $this->size['height'], 0, 0 );
401
-		}
402
-		catch ( Exception $e ) {
412
+		} catch ( Exception $e ) {
403 413
 			return new WP_Error( 'image_rotate_error', $e->getMessage() );
404 414
 		}
405 415
 		return true;
@@ -417,13 +427,14 @@  discard block
 block discarded – undo
417 427
 	 */
418 428
 	public function flip( $horz, $vert ) {
419 429
 		try {
420
-			if ( $horz )
421
-				$this->image->flipImage();
430
+			if ( $horz ) {
431
+							$this->image->flipImage();
432
+			}
422 433
 
423
-			if ( $vert )
424
-				$this->image->flopImage();
425
-		}
426
-		catch ( Exception $e ) {
434
+			if ( $vert ) {
435
+							$this->image->flopImage();
436
+			}
437
+		} catch ( Exception $e ) {
427 438
 			return new WP_Error( 'image_flip_error', $e->getMessage() );
428 439
 		}
429 440
 		return true;
@@ -448,8 +459,7 @@  discard block
 block discarded – undo
448 459
 
449 460
 			try {
450 461
 				$this->image->setImageFormat( strtoupper( $this->get_extension( $this->mime_type ) ) );
451
-			}
452
-			catch ( Exception $e ) {
462
+			} catch ( Exception $e ) {
453 463
 				return new WP_Error( 'image_save_error', $e->getMessage(), $this->file );
454 464
 			}
455 465
 		}
@@ -467,8 +477,9 @@  discard block
 block discarded – undo
467 477
 	protected function _save( $image, $filename = null, $mime_type = null ) {
468 478
 		list( $filename, $extension, $mime_type ) = $this->get_output_format( $filename, $mime_type );
469 479
 
470
-		if ( ! $filename )
471
-			$filename = $this->generate_filename( null, null, $extension );
480
+		if ( ! $filename ) {
481
+					$filename = $this->generate_filename( null, null, $extension );
482
+		}
472 483
 
473 484
 		try {
474 485
 			// Store initial Format
@@ -479,8 +490,7 @@  discard block
 block discarded – undo
479 490
 
480 491
 			// Reset original Format
481 492
 			$this->image->setImageFormat( $orig_format );
482
-		}
483
-		catch ( Exception $e ) {
493
+		} catch ( Exception $e ) {
484 494
 			return new WP_Error( 'image_save_error', $e->getMessage(), $filename );
485 495
 		}
486 496
 
@@ -521,8 +531,7 @@  discard block
 block discarded – undo
521 531
 
522 532
 			// Reset Image to original Format
523 533
 			$this->image->setImageFormat( $this->get_extension( $this->mime_type ) );
524
-		}
525
-		catch ( Exception $e ) {
534
+		} catch ( Exception $e ) {
526 535
 			return new WP_Error( 'image_stream_error', $e->getMessage() );
527 536
 		}
528 537
 
Please login to merge, or discard this patch.