Completed
Push — master ( cde0c6...d99bf9 )
by Stephen
15:46
created
src/wp-admin/includes/ms.php 3 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -736,7 +736,7 @@
 block discarded – undo
736 736
  *
737 737
  * @global int $wp_db_version The version number of the database.
738 738
  *
739
- * @return false False if the current user is not a super admin.
739
+ * @return false|null False if the current user is not a super admin.
740 740
  */
741 741
 function site_admin_notice() {
742 742
 	global $wp_db_version;
Please login to merge, or discard this patch.
Braces   +100 added lines, -62 removed lines patch added patch discarded remove patch
@@ -16,14 +16,18 @@  discard block
 block discarded – undo
16 16
  * @return array $_FILES array with 'error' key set if file exceeds quota. 'error' is empty otherwise.
17 17
  */
18 18
 function check_upload_size( $file ) {
19
-	if ( get_site_option( 'upload_space_check_disabled' ) )
20
-		return $file;
19
+	if ( get_site_option( 'upload_space_check_disabled' ) ) {
20
+			return $file;
21
+	}
21 22
 
22
-	if ( $file['error'] != '0' ) // there's already an error
23
+	if ( $file['error'] != '0' ) {
24
+		// there's already an error
23 25
 		return $file;
26
+	}
24 27
 
25
-	if ( defined( 'WP_IMPORTING' ) )
26
-		return $file;
28
+	if ( defined( 'WP_IMPORTING' ) ) {
29
+			return $file;
30
+	}
27 31
 
28 32
 	$space_left = get_upload_space_available();
29 33
 
@@ -148,8 +152,9 @@  discard block
 block discarded – undo
148 152
 			$dh = @opendir( $dir );
149 153
 			if ( $dh ) {
150 154
 				while ( ( $file = @readdir( $dh ) ) !== false ) {
151
-					if ( $file == '.' || $file == '..' )
152
-						continue;
155
+					if ( $file == '.' || $file == '..' ) {
156
+											continue;
157
+					}
153 158
 
154 159
 					if ( @is_dir( $dir . DIRECTORY_SEPARATOR . $file ) ) {
155 160
 						$stack[] = $dir . DIRECTORY_SEPARATOR . $file;
@@ -164,16 +169,18 @@  discard block
 block discarded – undo
164 169
 
165 170
 		$stack = array_reverse( $stack ); // Last added dirs are deepest
166 171
 		foreach ( (array) $stack as $dir ) {
167
-			if ( $dir != $top_dir)
168
-			@rmdir( $dir );
172
+			if ( $dir != $top_dir) {
173
+						@rmdir( $dir );
174
+			}
169 175
 		}
170 176
 
171 177
 		clean_blog_cache( $blog );
172 178
 	}
173 179
 
174
-	if ( $switch )
175
-		restore_current_blog();
176
-}
180
+	if ( $switch ) {
181
+			restore_current_blog();
182
+	}
183
+	}
177 184
 
178 185
 /**
179 186
  * Delete a user from the network and remove from all sites.
@@ -197,8 +204,9 @@  discard block
 block discarded – undo
197 204
 	$id = (int) $id;
198 205
 	$user = new WP_User( $id );
199 206
 
200
-	if ( !$user->exists() )
201
-		return false;
207
+	if ( !$user->exists() ) {
208
+			return false;
209
+	}
202 210
 
203 211
 	// Global super-administrators are protected, and cannot be deleted.
204 212
 	$_super_admins = get_super_admins();
@@ -231,8 +239,9 @@  discard block
 block discarded – undo
231 239
 			$link_ids = $wpdb->get_col( $wpdb->prepare( "SELECT link_id FROM $wpdb->links WHERE link_owner = %d", $id ) );
232 240
 
233 241
 			if ( $link_ids ) {
234
-				foreach ( $link_ids as $link_id )
235
-					wp_delete_link( $link_id );
242
+				foreach ( $link_ids as $link_id ) {
243
+									wp_delete_link( $link_id );
244
+				}
236 245
 			}
237 246
 
238 247
 			restore_current_blog();
@@ -240,8 +249,9 @@  discard block
 block discarded – undo
240 249
 	}
241 250
 
242 251
 	$meta = $wpdb->get_col( $wpdb->prepare( "SELECT umeta_id FROM $wpdb->usermeta WHERE user_id = %d", $id ) );
243
-	foreach ( $meta as $mid )
244
-		delete_metadata_by_mid( 'user', $mid );
252
+	foreach ( $meta as $mid ) {
253
+			delete_metadata_by_mid( 'user', $mid );
254
+	}
245 255
 
246 256
 	$wpdb->delete( $wpdb->users, array( 'ID' => $id ) );
247 257
 
@@ -262,8 +272,9 @@  discard block
 block discarded – undo
262 272
  * @param string $value     The new email address.
263 273
  */
264 274
 function update_option_new_admin_email( $old_value, $value ) {
265
-	if ( $value == get_option( 'admin_email' ) || !is_email( $value ) )
266
-		return;
275
+	if ( $value == get_option( 'admin_email' ) || !is_email( $value ) ) {
276
+			return;
277
+	}
267 278
 
268 279
 	$hash = md5( $value. time() .mt_rand() );
269 280
 	$new_admin_email = array(
@@ -328,11 +339,13 @@  discard block
 block discarded – undo
328 339
 function send_confirmation_on_profile_email() {
329 340
 	global $errors, $wpdb;
330 341
 	$current_user = wp_get_current_user();
331
-	if ( ! is_object($errors) )
332
-		$errors = new WP_Error();
342
+	if ( ! is_object($errors) ) {
343
+			$errors = new WP_Error();
344
+	}
333 345
 
334
-	if ( $current_user->ID != $_POST['user_id'] )
335
-		return false;
346
+	if ( $current_user->ID != $_POST['user_id'] ) {
347
+			return false;
348
+	}
336 349
 
337 350
 	if ( $current_user->user_email != $_POST['email'] ) {
338 351
 		if ( !is_email( $_POST['email'] ) ) {
@@ -423,8 +436,9 @@  discard block
 block discarded – undo
423 436
  * @return bool True if user is over upload space quota, otherwise false.
424 437
  */
425 438
 function upload_is_user_over_quota( $echo = true ) {
426
-	if ( get_site_option( 'upload_space_check_disabled' ) )
427
-		return false;
439
+	if ( get_site_option( 'upload_space_check_disabled' ) ) {
440
+			return false;
441
+	}
428 442
 
429 443
 	$space_allowed = get_space_allowed();
430 444
 	if ( ! is_numeric( $space_allowed ) ) {
@@ -433,8 +447,9 @@  discard block
 block discarded – undo
433 447
 	$space_used = get_space_used();
434 448
 
435 449
 	if ( ( $space_allowed - $space_used ) < 0 ) {
436
-		if ( $echo )
437
-			_e( 'Sorry, you have used your space allocation. Please delete some files to upload more files.' );
450
+		if ( $echo ) {
451
+					_e( 'Sorry, you have used your space allocation. Please delete some files to upload more files.' );
452
+		}
438 453
 		return true;
439 454
 	} else {
440 455
 		return false;
@@ -494,8 +509,9 @@  discard block
 block discarded – undo
494 509
 	$quota = get_option( 'blog_upload_space' );
495 510
 	restore_current_blog();
496 511
 
497
-	if ( !$quota )
498
-		$quota = '';
512
+	if ( !$quota ) {
513
+			$quota = '';
514
+	}
499 515
 
500 516
 	?>
501 517
 	<tr>
@@ -527,8 +543,9 @@  discard block
 block discarded – undo
527 543
 function update_user_status( $id, $pref, $value, $deprecated = null ) {
528 544
 	global $wpdb;
529 545
 
530
-	if ( null !== $deprecated )
531
-		_deprecated_argument( __FUNCTION__, '3.0.2' );
546
+	if ( null !== $deprecated ) {
547
+			_deprecated_argument( __FUNCTION__, '3.0.2' );
548
+	}
532 549
 
533 550
 	$wpdb->update( $wpdb->users, array( sanitize_key( $pref ) => $value ), array( 'ID' => $id ) );
534 551
 
@@ -571,8 +588,9 @@  discard block
 block discarded – undo
571 588
 function refresh_user_details( $id ) {
572 589
 	$id = (int) $id;
573 590
 
574
-	if ( !$user = get_userdata( $id ) )
575
-		return false;
591
+	if ( !$user = get_userdata( $id ) ) {
592
+			return false;
593
+	}
576 594
 
577 595
 	clean_user_cache( $user );
578 596
 
@@ -646,18 +664,21 @@  discard block
 block discarded – undo
646 664
  * @access private
647 665
  */
648 666
 function _access_denied_splash() {
649
-	if ( ! is_user_logged_in() || is_network_admin() )
650
-		return;
667
+	if ( ! is_user_logged_in() || is_network_admin() ) {
668
+			return;
669
+	}
651 670
 
652 671
 	$blogs = get_blogs_of_user( get_current_user_id() );
653 672
 
654
-	if ( wp_list_filter( $blogs, array( 'userblog_id' => get_current_blog_id() ) ) )
655
-		return;
673
+	if ( wp_list_filter( $blogs, array( 'userblog_id' => get_current_blog_id() ) ) ) {
674
+			return;
675
+	}
656 676
 
657 677
 	$blog_name = get_bloginfo( 'name' );
658 678
 
659
-	if ( empty( $blogs ) )
660
-		wp_die( sprintf( __( 'You attempted to access the "%1$s" dashboard, but you do not currently have privileges on this site. If you believe you should be able to access the "%1$s" dashboard, please contact your network administrator.' ), $blog_name ), 403 );
679
+	if ( empty( $blogs ) ) {
680
+			wp_die( sprintf( __( 'You attempted to access the "%1$s" dashboard, but you do not currently have privileges on this site. If you believe you should be able to access the "%1$s" dashboard, please contact your network administrator.' ), $blog_name ), 403 );
681
+	}
661 682
 
662 683
 	$output = '<p>' . sprintf( __( 'You attempted to access the "%1$s" dashboard, but you do not currently have privileges on this site. If you believe you should be able to access the "%1$s" dashboard, please contact your network administrator.' ), $blog_name ) . '</p>';
663 684
 	$output .= '<p>' . __( 'If you reached this screen by accident and meant to visit one of your own sites, here are some shortcuts to help you find your way.' ) . '</p>';
@@ -687,8 +708,9 @@  discard block
 block discarded – undo
687 708
  * @return bool True if the user has proper permissions, false if they do not.
688 709
  */
689 710
 function check_import_new_users( $permission ) {
690
-	if ( !is_super_admin() )
691
-		return false;
711
+	if ( !is_super_admin() ) {
712
+			return false;
713
+	}
692 714
 	return true;
693 715
 }
694 716
 // See "import_allow_fetch_attachments" and "import_attachment_size_limit" filters too.
@@ -723,8 +745,10 @@  discard block
 block discarded – undo
723 745
 
724 746
 	}
725 747
 
726
-	if ( $flag === false ) // WordPress english
748
+	if ( $flag === false ) {
749
+		// WordPress english
727 750
 		$output[] = '<option value=""' . selected( $current, '', false ) . '>' . __( 'English' ) . "</option>";
751
+	}
728 752
 
729 753
 	// Order by name
730 754
 	uksort( $output, 'strnatcasecmp' );
@@ -782,14 +806,18 @@  discard block
 block discarded – undo
782 806
  * @return array The new array of post data after checking for collisions.
783 807
  */
784 808
 function avoid_blog_page_permalink_collision( $data, $postarr ) {
785
-	if ( is_subdomain_install() )
786
-		return $data;
787
-	if ( $data['post_type'] != 'page' )
788
-		return $data;
789
-	if ( !isset( $data['post_name'] ) || $data['post_name'] == '' )
790
-		return $data;
791
-	if ( !is_main_site() )
792
-		return $data;
809
+	if ( is_subdomain_install() ) {
810
+			return $data;
811
+	}
812
+	if ( $data['post_type'] != 'page' ) {
813
+			return $data;
814
+	}
815
+	if ( !isset( $data['post_name'] ) || $data['post_name'] == '' ) {
816
+			return $data;
817
+	}
818
+	if ( !is_main_site() ) {
819
+			return $data;
820
+	}
793 821
 
794 822
 	$post_name = $data['post_name'];
795 823
 	$c = 0;
@@ -826,8 +854,9 @@  discard block
 block discarded – undo
826 854
 			?>
827 855
 			<select name="primary_blog" id="primary_blog">
828 856
 				<?php foreach ( (array) $all_blogs as $blog ) {
829
-					if ( $primary_blog == $blog->userblog_id )
830
-						$found = true;
857
+					if ( $primary_blog == $blog->userblog_id ) {
858
+											$found = true;
859
+					}
831 860
 					?><option value="<?php echo $blog->userblog_id ?>"<?php selected( $primary_blog, $blog->userblog_id ); ?>><?php echo esc_url( get_home_url( $blog->userblog_id ) ) ?></option><?php
832 861
 				} ?>
833 862
 			</select>
@@ -839,8 +868,10 @@  discard block
 block discarded – undo
839 868
 		} elseif ( count( $all_blogs ) == 1 ) {
840 869
 			$blog = reset( $all_blogs );
841 870
 			echo esc_url( get_home_url( $blog->userblog_id ) );
842
-			if ( $primary_blog != $blog->userblog_id ) // Set the primary blog again if it's out of sync with blog list.
871
+			if ( $primary_blog != $blog->userblog_id ) {
872
+				// Set the primary blog again if it's out of sync with blog list.
843 873
 				update_user_meta( get_current_user_id(), 'primary_blog', $blog->userblog_id );
874
+			}
844 875
 		} else {
845 876
 			echo "N/A";
846 877
 		}
@@ -867,10 +898,11 @@  discard block
 block discarded – undo
867 898
 function can_edit_network( $site_id ) {
868 899
 	global $wpdb;
869 900
 
870
-	if ( $site_id == $wpdb->siteid )
871
-		$result = true;
872
-	else
873
-		$result = false;
901
+	if ( $site_id == $wpdb->siteid ) {
902
+			$result = true;
903
+	} else {
904
+			$result = false;
905
+	}
874 906
 
875 907
 	/**
876 908
 	 * Filters whether this network can be edited from this page.
@@ -912,8 +944,11 @@  discard block
 block discarded – undo
912 944
 
913 945
 	<?php if ( 1 == count( $users ) ) : ?>
914 946
 		<p><?php _e( 'You have chosen to delete the user from all networks and sites.' ); ?></p>
915
-	<?php else : ?>
916
-		<p><?php _e( 'You have chosen to delete the following users from all networks and sites.' ); ?></p>
947
+	<?php else {
948
+	: ?>
949
+		<p><?php _e( 'You have chosen to delete the following users from all networks and sites.' );
950
+}
951
+?></p>
917 952
 	<?php endif; ?>
918 953
 
919 954
 	<form action="users.php?action=dodelete" method="post">
@@ -996,8 +1031,11 @@  discard block
 block discarded – undo
996 1031
 
997 1032
 	if ( 1 == count( $users ) ) : ?>
998 1033
 		<p><?php _e( 'Once you hit &#8220;Confirm Deletion&#8221;, the user will be permanently removed.' ); ?></p>
999
-	<?php else : ?>
1000
-		<p><?php _e( 'Once you hit &#8220;Confirm Deletion&#8221;, these users will be permanently removed.' ); ?></p>
1034
+	<?php else {
1035
+	: ?>
1036
+		<p><?php _e( 'Once you hit &#8220;Confirm Deletion&#8221;, these users will be permanently removed.' );
1037
+}
1038
+?></p>
1001 1039
 	<?php endif;
1002 1040
 
1003 1041
 	submit_button( __('Confirm Deletion'), 'primary' );
Please login to merge, or discard this patch.
Spacing   +276 added lines, -276 removed lines patch added patch discarded remove patch
@@ -15,35 +15,35 @@  discard block
 block discarded – undo
15 15
  * @param array $file $_FILES array for a given file.
16 16
  * @return array $_FILES array with 'error' key set if file exceeds quota. 'error' is empty otherwise.
17 17
  */
18
-function check_upload_size( $file ) {
19
-	if ( get_site_option( 'upload_space_check_disabled' ) )
18
+function check_upload_size($file) {
19
+	if (get_site_option('upload_space_check_disabled'))
20 20
 		return $file;
21 21
 
22
-	if ( $file['error'] != '0' ) // there's already an error
22
+	if ($file['error'] != '0') // there's already an error
23 23
 		return $file;
24 24
 
25
-	if ( defined( 'WP_IMPORTING' ) )
25
+	if (defined('WP_IMPORTING'))
26 26
 		return $file;
27 27
 
28 28
 	$space_left = get_upload_space_available();
29 29
 
30
-	$file_size = filesize( $file['tmp_name'] );
31
-	if ( $space_left < $file_size ) {
30
+	$file_size = filesize($file['tmp_name']);
31
+	if ($space_left < $file_size) {
32 32
 		/* translators: 1: Required disk space in kilobytes */
33
-		$file['error'] = sprintf( __( 'Not enough space to upload. %1$s KB needed.' ), number_format( ( $file_size - $space_left ) / KB_IN_BYTES ) );
33
+		$file['error'] = sprintf(__('Not enough space to upload. %1$s KB needed.'), number_format(($file_size - $space_left) / KB_IN_BYTES));
34 34
 	}
35 35
 
36
-	if ( $file_size > ( KB_IN_BYTES * get_site_option( 'fileupload_maxk', 1500 ) ) ) {
36
+	if ($file_size > (KB_IN_BYTES * get_site_option('fileupload_maxk', 1500))) {
37 37
 		/* translators: 1: Maximum allowed file size in kilobytes */
38
-		$file['error'] = sprintf( __( 'This file is too big. Files must be less than %1$s KB in size.' ), get_site_option( 'fileupload_maxk', 1500 ) );
38
+		$file['error'] = sprintf(__('This file is too big. Files must be less than %1$s KB in size.'), get_site_option('fileupload_maxk', 1500));
39 39
 	}
40 40
 
41
-	if ( upload_is_user_over_quota( false ) ) {
42
-		$file['error'] = __( 'You have used your space quota. Please delete files before uploading.' );
41
+	if (upload_is_user_over_quota(false)) {
42
+		$file['error'] = __('You have used your space quota. Please delete files before uploading.');
43 43
 	}
44 44
 
45
-	if ( $file['error'] != '0' && ! isset( $_POST['html-upload'] ) && ! wp_doing_ajax() ) {
46
-		wp_die( $file['error'] . ' <a href="javascript:history.go(-1)">' . __( 'Back' ) . '</a>' );
45
+	if ($file['error'] != '0' && ! isset($_POST['html-upload']) && ! wp_doing_ajax()) {
46
+		wp_die($file['error'].' <a href="javascript:history.go(-1)">'.__('Back').'</a>');
47 47
 	}
48 48
 
49 49
 	return $file;
@@ -59,16 +59,16 @@  discard block
 block discarded – undo
59 59
  * @param int  $blog_id Site ID.
60 60
  * @param bool $drop    True if site's database tables should be dropped. Default is false.
61 61
  */
62
-function wpmu_delete_blog( $blog_id, $drop = false ) {
62
+function wpmu_delete_blog($blog_id, $drop = false) {
63 63
 	global $wpdb;
64 64
 
65 65
 	$switch = false;
66
-	if ( get_current_blog_id() != $blog_id ) {
66
+	if (get_current_blog_id() != $blog_id) {
67 67
 		$switch = true;
68
-		switch_to_blog( $blog_id );
68
+		switch_to_blog($blog_id);
69 69
 	}
70 70
 
71
-	$blog = get_site( $blog_id );
71
+	$blog = get_site($blog_id);
72 72
 	/**
73 73
 	 * Fires before a site is deleted.
74 74
 	 *
@@ -77,42 +77,42 @@  discard block
 block discarded – undo
77 77
 	 * @param int  $blog_id The site ID.
78 78
 	 * @param bool $drop    True if site's table should be dropped. Default is false.
79 79
 	 */
80
-	do_action( 'delete_blog', $blog_id, $drop );
80
+	do_action('delete_blog', $blog_id, $drop);
81 81
 
82
-	$users = get_users( array( 'blog_id' => $blog_id, 'fields' => 'ids' ) );
82
+	$users = get_users(array('blog_id' => $blog_id, 'fields' => 'ids'));
83 83
 
84 84
 	// Remove users from this blog.
85
-	if ( ! empty( $users ) ) {
86
-		foreach ( $users as $user_id ) {
87
-			remove_user_from_blog( $user_id, $blog_id );
85
+	if ( ! empty($users)) {
86
+		foreach ($users as $user_id) {
87
+			remove_user_from_blog($user_id, $blog_id);
88 88
 		}
89 89
 	}
90 90
 
91
-	update_blog_status( $blog_id, 'deleted', 1 );
91
+	update_blog_status($blog_id, 'deleted', 1);
92 92
 
93 93
 	$current_network = get_network();
94 94
 
95 95
 	// If a full blog object is not available, do not destroy anything.
96
-	if ( $drop && ! $blog ) {
96
+	if ($drop && ! $blog) {
97 97
 		$drop = false;
98 98
 	}
99 99
 
100 100
 	// Don't destroy the initial, main, or root blog.
101
-	if ( $drop && ( 1 == $blog_id || is_main_site( $blog_id ) || ( $blog->path == $current_network->path && $blog->domain == $current_network->domain ) ) ) {
101
+	if ($drop && (1 == $blog_id || is_main_site($blog_id) || ($blog->path == $current_network->path && $blog->domain == $current_network->domain))) {
102 102
 		$drop = false;
103 103
 	}
104 104
 
105
-	$upload_path = trim( get_option( 'upload_path' ) );
105
+	$upload_path = trim(get_option('upload_path'));
106 106
 
107 107
 	// If ms_files_rewriting is enabled and upload_path is empty, wp_upload_dir is not reliable.
108
-	if ( $drop && get_site_option( 'ms_files_rewriting' ) && empty( $upload_path ) ) {
108
+	if ($drop && get_site_option('ms_files_rewriting') && empty($upload_path)) {
109 109
 		$drop = false;
110 110
 	}
111 111
 
112
-	if ( $drop ) {
112
+	if ($drop) {
113 113
 		$uploads = wp_get_upload_dir();
114 114
 
115
-		$tables = $wpdb->tables( 'blog' );
115
+		$tables = $wpdb->tables('blog');
116 116
 		/**
117 117
 		 * Filters the tables to drop when the site is deleted.
118 118
 		 *
@@ -121,13 +121,13 @@  discard block
 block discarded – undo
121 121
 		 * @param array $tables  The site tables to be dropped.
122 122
 		 * @param int   $blog_id The ID of the site to drop tables for.
123 123
 		 */
124
-		$drop_tables = apply_filters( 'wpmu_drop_tables', $tables, $blog_id );
124
+		$drop_tables = apply_filters('wpmu_drop_tables', $tables, $blog_id);
125 125
 
126
-		foreach ( (array) $drop_tables as $table ) {
127
-			$wpdb->query( "DROP TABLE IF EXISTS `$table`" );
126
+		foreach ((array) $drop_tables as $table) {
127
+			$wpdb->query("DROP TABLE IF EXISTS `$table`");
128 128
 		}
129 129
 
130
-		$wpdb->delete( $wpdb->blogs, array( 'blog_id' => $blog_id ) );
130
+		$wpdb->delete($wpdb->blogs, array('blog_id' => $blog_id));
131 131
 
132 132
 		/**
133 133
 		 * Filters the upload base directory to delete when the site is deleted.
@@ -137,43 +137,43 @@  discard block
 block discarded – undo
137 137
 		 * @param string $uploads['basedir'] Uploads path without subdirectory. @see wp_upload_dir()
138 138
 		 * @param int    $blog_id            The site ID.
139 139
 		 */
140
-		$dir = apply_filters( 'wpmu_delete_blog_upload_dir', $uploads['basedir'], $blog_id );
141
-		$dir = rtrim( $dir, DIRECTORY_SEPARATOR );
140
+		$dir = apply_filters('wpmu_delete_blog_upload_dir', $uploads['basedir'], $blog_id);
141
+		$dir = rtrim($dir, DIRECTORY_SEPARATOR);
142 142
 		$top_dir = $dir;
143 143
 		$stack = array($dir);
144 144
 		$index = 0;
145 145
 
146
-		while ( $index < count( $stack ) ) {
146
+		while ($index < count($stack)) {
147 147
 			// Get indexed directory from stack
148 148
 			$dir = $stack[$index];
149 149
 
150
-			$dh = @opendir( $dir );
151
-			if ( $dh ) {
152
-				while ( ( $file = @readdir( $dh ) ) !== false ) {
153
-					if ( $file == '.' || $file == '..' )
150
+			$dh = @opendir($dir);
151
+			if ($dh) {
152
+				while (($file = @readdir($dh)) !== false) {
153
+					if ($file == '.' || $file == '..')
154 154
 						continue;
155 155
 
156
-					if ( @is_dir( $dir . DIRECTORY_SEPARATOR . $file ) ) {
157
-						$stack[] = $dir . DIRECTORY_SEPARATOR . $file;
158
-					} elseif ( @is_file( $dir . DIRECTORY_SEPARATOR . $file ) ) {
159
-						@unlink( $dir . DIRECTORY_SEPARATOR . $file );
156
+					if (@is_dir($dir.DIRECTORY_SEPARATOR.$file)) {
157
+						$stack[] = $dir.DIRECTORY_SEPARATOR.$file;
158
+					} elseif (@is_file($dir.DIRECTORY_SEPARATOR.$file)) {
159
+						@unlink($dir.DIRECTORY_SEPARATOR.$file);
160 160
 					}
161 161
 				}
162
-				@closedir( $dh );
162
+				@closedir($dh);
163 163
 			}
164 164
 			$index++;
165 165
 		}
166 166
 
167
-		$stack = array_reverse( $stack ); // Last added dirs are deepest
168
-		foreach ( (array) $stack as $dir ) {
169
-			if ( $dir != $top_dir)
170
-			@rmdir( $dir );
167
+		$stack = array_reverse($stack); // Last added dirs are deepest
168
+		foreach ((array) $stack as $dir) {
169
+			if ($dir != $top_dir)
170
+			@rmdir($dir);
171 171
 		}
172 172
 
173
-		clean_blog_cache( $blog );
173
+		clean_blog_cache($blog);
174 174
 	}
175 175
 
176
-	if ( $switch )
176
+	if ($switch)
177 177
 		restore_current_blog();
178 178
 }
179 179
 
@@ -189,22 +189,22 @@  discard block
 block discarded – undo
189 189
  * @param int $id The user ID.
190 190
  * @return bool True if the user was deleted, otherwise false.
191 191
  */
192
-function wpmu_delete_user( $id ) {
192
+function wpmu_delete_user($id) {
193 193
 	global $wpdb;
194 194
 
195
-	if ( ! is_numeric( $id ) ) {
195
+	if ( ! is_numeric($id)) {
196 196
 		return false;
197 197
 	}
198 198
 
199 199
 	$id = (int) $id;
200
-	$user = new WP_User( $id );
200
+	$user = new WP_User($id);
201 201
 
202
-	if ( !$user->exists() )
202
+	if ( ! $user->exists())
203 203
 		return false;
204 204
 
205 205
 	// Global super-administrators are protected, and cannot be deleted.
206 206
 	$_super_admins = get_super_admins();
207
-	if ( in_array( $user->user_login, $_super_admins, true ) ) {
207
+	if (in_array($user->user_login, $_super_admins, true)) {
208 208
 		return false;
209 209
 	}
210 210
 
@@ -215,42 +215,42 @@  discard block
 block discarded – undo
215 215
 	 *
216 216
 	 * @param int $id ID of the user about to be deleted from the network.
217 217
 	 */
218
-	do_action( 'wpmu_delete_user', $id );
218
+	do_action('wpmu_delete_user', $id);
219 219
 
220
-	$blogs = get_blogs_of_user( $id );
220
+	$blogs = get_blogs_of_user($id);
221 221
 
222
-	if ( ! empty( $blogs ) ) {
223
-		foreach ( $blogs as $blog ) {
224
-			switch_to_blog( $blog->userblog_id );
225
-			remove_user_from_blog( $id, $blog->userblog_id );
222
+	if ( ! empty($blogs)) {
223
+		foreach ($blogs as $blog) {
224
+			switch_to_blog($blog->userblog_id);
225
+			remove_user_from_blog($id, $blog->userblog_id);
226 226
 
227
-			$post_ids = $wpdb->get_col( $wpdb->prepare( "SELECT ID FROM $wpdb->posts WHERE post_author = %d", $id ) );
228
-			foreach ( (array) $post_ids as $post_id ) {
229
-				wp_delete_post( $post_id );
227
+			$post_ids = $wpdb->get_col($wpdb->prepare("SELECT ID FROM $wpdb->posts WHERE post_author = %d", $id));
228
+			foreach ((array) $post_ids as $post_id) {
229
+				wp_delete_post($post_id);
230 230
 			}
231 231
 
232 232
 			// Clean links
233
-			$link_ids = $wpdb->get_col( $wpdb->prepare( "SELECT link_id FROM $wpdb->links WHERE link_owner = %d", $id ) );
233
+			$link_ids = $wpdb->get_col($wpdb->prepare("SELECT link_id FROM $wpdb->links WHERE link_owner = %d", $id));
234 234
 
235
-			if ( $link_ids ) {
236
-				foreach ( $link_ids as $link_id )
237
-					wp_delete_link( $link_id );
235
+			if ($link_ids) {
236
+				foreach ($link_ids as $link_id)
237
+					wp_delete_link($link_id);
238 238
 			}
239 239
 
240 240
 			restore_current_blog();
241 241
 		}
242 242
 	}
243 243
 
244
-	$meta = $wpdb->get_col( $wpdb->prepare( "SELECT umeta_id FROM $wpdb->usermeta WHERE user_id = %d", $id ) );
245
-	foreach ( $meta as $mid )
246
-		delete_metadata_by_mid( 'user', $mid );
244
+	$meta = $wpdb->get_col($wpdb->prepare("SELECT umeta_id FROM $wpdb->usermeta WHERE user_id = %d", $id));
245
+	foreach ($meta as $mid)
246
+		delete_metadata_by_mid('user', $mid);
247 247
 
248
-	$wpdb->delete( $wpdb->users, array( 'ID' => $id ) );
248
+	$wpdb->delete($wpdb->users, array('ID' => $id));
249 249
 
250
-	clean_user_cache( $user );
250
+	clean_user_cache($user);
251 251
 
252 252
 	/** This action is documented in wp-admin/includes/user.php */
253
-	do_action( 'deleted_user', $id );
253
+	do_action('deleted_user', $id);
254 254
 
255 255
 	return true;
256 256
 }
@@ -263,21 +263,21 @@  discard block
 block discarded – undo
263 263
  * @param string $old_value The old email address. Not currently used.
264 264
  * @param string $value     The new email address.
265 265
  */
266
-function update_option_new_admin_email( $old_value, $value ) {
267
-	if ( $value == get_option( 'admin_email' ) || !is_email( $value ) )
266
+function update_option_new_admin_email($old_value, $value) {
267
+	if ($value == get_option('admin_email') || ! is_email($value))
268 268
 		return;
269 269
 
270
-	$hash = md5( $value. time() .mt_rand() );
270
+	$hash = md5($value.time().mt_rand());
271 271
 	$new_admin_email = array(
272 272
 		'hash' => $hash,
273 273
 		'newemail' => $value
274 274
 	);
275
-	update_option( 'adminhash', $new_admin_email );
275
+	update_option('adminhash', $new_admin_email);
276 276
 
277
-	$switched_locale = switch_to_locale( get_user_locale() );
277
+	$switched_locale = switch_to_locale(get_user_locale());
278 278
 
279 279
 	/* translators: Do not translate USERNAME, ADMIN_URL, EMAIL, SITENAME, SITEURL: those are placeholders. */
280
-	$email_text = __( 'Howdy ###USERNAME###,
280
+	$email_text = __('Howdy ###USERNAME###,
281 281
 
282 282
 You recently requested to have the administration email address on
283 283
 your site changed.
@@ -309,18 +309,18 @@  discard block
 block discarded – undo
309 309
 	 * @param string $email_text      Text in the email.
310 310
 	 * @param string $new_admin_email New admin email that the current administration email was changed to.
311 311
 	 */
312
-	$content = apply_filters( 'new_admin_email_content', $email_text, $new_admin_email );
312
+	$content = apply_filters('new_admin_email_content', $email_text, $new_admin_email);
313 313
 
314 314
 	$current_user = wp_get_current_user();
315
-	$content = str_replace( '###USERNAME###', $current_user->user_login, $content );
316
-	$content = str_replace( '###ADMIN_URL###', esc_url( self_admin_url( 'options.php?adminhash='.$hash ) ), $content );
317
-	$content = str_replace( '###EMAIL###', $value, $content );
318
-	$content = str_replace( '###SITENAME###', get_site_option( 'site_name' ), $content );
319
-	$content = str_replace( '###SITEURL###', network_home_url(), $content );
315
+	$content = str_replace('###USERNAME###', $current_user->user_login, $content);
316
+	$content = str_replace('###ADMIN_URL###', esc_url(self_admin_url('options.php?adminhash='.$hash)), $content);
317
+	$content = str_replace('###EMAIL###', $value, $content);
318
+	$content = str_replace('###SITENAME###', get_site_option('site_name'), $content);
319
+	$content = str_replace('###SITEURL###', network_home_url(), $content);
320 320
 
321
-	wp_mail( $value, sprintf( __( '[%s] New Admin Email Address' ), wp_specialchars_decode( get_option( 'blogname' ) ) ), $content );
321
+	wp_mail($value, sprintf(__('[%s] New Admin Email Address'), wp_specialchars_decode(get_option('blogname'))), $content);
322 322
 
323
-	if ( $switched_locale ) {
323
+	if ($switched_locale) {
324 324
 		restore_previous_locale();
325 325
 	}
326 326
 }
@@ -336,35 +336,35 @@  discard block
 block discarded – undo
336 336
 function send_confirmation_on_profile_email() {
337 337
 	global $errors, $wpdb;
338 338
 	$current_user = wp_get_current_user();
339
-	if ( ! is_object($errors) )
339
+	if ( ! is_object($errors))
340 340
 		$errors = new WP_Error();
341 341
 
342
-	if ( $current_user->ID != $_POST['user_id'] )
342
+	if ($current_user->ID != $_POST['user_id'])
343 343
 		return false;
344 344
 
345
-	if ( $current_user->user_email != $_POST['email'] ) {
346
-		if ( !is_email( $_POST['email'] ) ) {
347
-			$errors->add( 'user_email', __( "<strong>ERROR</strong>: The email address isn&#8217;t correct." ), array( 'form-field' => 'email' ) );
345
+	if ($current_user->user_email != $_POST['email']) {
346
+		if ( ! is_email($_POST['email'])) {
347
+			$errors->add('user_email', __("<strong>ERROR</strong>: The email address isn&#8217;t correct."), array('form-field' => 'email'));
348 348
 			return;
349 349
 		}
350 350
 
351
-		if ( $wpdb->get_var( $wpdb->prepare( "SELECT user_email FROM {$wpdb->users} WHERE user_email=%s", $_POST['email'] ) ) ) {
352
-			$errors->add( 'user_email', __( "<strong>ERROR</strong>: The email address is already used." ), array( 'form-field' => 'email' ) );
353
-			delete_user_meta( $current_user->ID, '_new_email' );
351
+		if ($wpdb->get_var($wpdb->prepare("SELECT user_email FROM {$wpdb->users} WHERE user_email=%s", $_POST['email']))) {
352
+			$errors->add('user_email', __("<strong>ERROR</strong>: The email address is already used."), array('form-field' => 'email'));
353
+			delete_user_meta($current_user->ID, '_new_email');
354 354
 			return;
355 355
 		}
356 356
 
357
-		$hash = md5( $_POST['email'] . time() . mt_rand() );
357
+		$hash = md5($_POST['email'].time().mt_rand());
358 358
 		$new_user_email = array(
359 359
 			'hash' => $hash,
360 360
 			'newemail' => $_POST['email']
361 361
 		);
362
-		update_user_meta( $current_user->ID, '_new_email', $new_user_email );
362
+		update_user_meta($current_user->ID, '_new_email', $new_user_email);
363 363
 
364
-		$switched_locale = switch_to_locale( get_user_locale() );
364
+		$switched_locale = switch_to_locale(get_user_locale());
365 365
 
366 366
 		/* translators: Do not translate USERNAME, ADMIN_URL, EMAIL, SITENAME, SITEURL: those are placeholders. */
367
-		$email_text = __( 'Howdy ###USERNAME###,
367
+		$email_text = __('Howdy ###USERNAME###,
368 368
 
369 369
 You recently requested to have the email address on your account changed.
370 370
 
@@ -395,18 +395,18 @@  discard block
 block discarded – undo
395 395
 		 * @param string $email_text     Text in the email.
396 396
 		 * @param string $new_user_email New user email that the current user has changed to.
397 397
 		 */
398
-		$content = apply_filters( 'new_user_email_content', $email_text, $new_user_email );
398
+		$content = apply_filters('new_user_email_content', $email_text, $new_user_email);
399 399
 
400
-		$content = str_replace( '###USERNAME###', $current_user->user_login, $content );
401
-		$content = str_replace( '###ADMIN_URL###', esc_url( self_admin_url( 'profile.php?newuseremail=' . $hash ) ), $content );
402
-		$content = str_replace( '###EMAIL###', $_POST['email'], $content);
403
-		$content = str_replace( '###SITENAME###', get_site_option( 'site_name' ), $content );
404
-		$content = str_replace( '###SITEURL###', network_home_url(), $content );
400
+		$content = str_replace('###USERNAME###', $current_user->user_login, $content);
401
+		$content = str_replace('###ADMIN_URL###', esc_url(self_admin_url('profile.php?newuseremail='.$hash)), $content);
402
+		$content = str_replace('###EMAIL###', $_POST['email'], $content);
403
+		$content = str_replace('###SITENAME###', get_site_option('site_name'), $content);
404
+		$content = str_replace('###SITEURL###', network_home_url(), $content);
405 405
 
406
-		wp_mail( $_POST['email'], sprintf( __( '[%s] New Email Address' ), wp_specialchars_decode( get_option( 'blogname' ) ) ), $content );
406
+		wp_mail($_POST['email'], sprintf(__('[%s] New Email Address'), wp_specialchars_decode(get_option('blogname'))), $content);
407 407
 		$_POST['email'] = $current_user->user_email;
408 408
 
409
-		if ( $switched_locale ) {
409
+		if ($switched_locale) {
410 410
 			restore_previous_locale();
411 411
 		}
412 412
 	}
@@ -422,9 +422,9 @@  discard block
 block discarded – undo
422 422
  */
423 423
 function new_user_email_admin_notice() {
424 424
 	global $pagenow;
425
-	if ( 'profile.php' === $pagenow && isset( $_GET['updated'] ) && $email = get_user_meta( get_current_user_id(), '_new_email', true ) ) {
425
+	if ('profile.php' === $pagenow && isset($_GET['updated']) && $email = get_user_meta(get_current_user_id(), '_new_email', true)) {
426 426
 		/* translators: %s: New email address */
427
-		echo '<div class="notice notice-info"><p>' . sprintf( __( 'Your email address has not been updated yet. Please check your inbox at %s for a confirmation email.' ), '<code>' . esc_html( $email['newemail'] ) . '</code>' ) . '</p></div>';
427
+		echo '<div class="notice notice-info"><p>'.sprintf(__('Your email address has not been updated yet. Please check your inbox at %s for a confirmation email.'), '<code>'.esc_html($email['newemail']).'</code>').'</p></div>';
428 428
 	}
429 429
 }
430 430
 
@@ -436,19 +436,19 @@  discard block
 block discarded – undo
436 436
  * @param bool $echo Optional. If $echo is set and the quota is exceeded, a warning message is echoed. Default is true.
437 437
  * @return bool True if user is over upload space quota, otherwise false.
438 438
  */
439
-function upload_is_user_over_quota( $echo = true ) {
440
-	if ( get_site_option( 'upload_space_check_disabled' ) )
439
+function upload_is_user_over_quota($echo = true) {
440
+	if (get_site_option('upload_space_check_disabled'))
441 441
 		return false;
442 442
 
443 443
 	$space_allowed = get_space_allowed();
444
-	if ( ! is_numeric( $space_allowed ) ) {
444
+	if ( ! is_numeric($space_allowed)) {
445 445
 		$space_allowed = 10; // Default space allowed is 10 MB
446 446
 	}
447 447
 	$space_used = get_space_used();
448 448
 
449
-	if ( ( $space_allowed - $space_used ) < 0 ) {
450
-		if ( $echo )
451
-			_e( 'Sorry, you have used your space allocation. Please delete some files to upload more files.' );
449
+	if (($space_allowed - $space_used) < 0) {
450
+		if ($echo)
451
+			_e('Sorry, you have used your space allocation. Please delete some files to upload more files.');
452 452
 		return true;
453 453
 	} else {
454 454
 		return false;
@@ -464,21 +464,21 @@  discard block
 block discarded – undo
464 464
 	$space_allowed = get_space_allowed();
465 465
 	$space_used = get_space_used();
466 466
 
467
-	$percent_used = ( $space_used / $space_allowed ) * 100;
467
+	$percent_used = ($space_used / $space_allowed) * 100;
468 468
 
469
-	if ( $space_allowed > 1000 ) {
470
-		$space = number_format( $space_allowed / KB_IN_BYTES );
469
+	if ($space_allowed > 1000) {
470
+		$space = number_format($space_allowed / KB_IN_BYTES);
471 471
 		/* translators: Gigabytes */
472
-		$space .= __( 'GB' );
472
+		$space .= __('GB');
473 473
 	} else {
474
-		$space = number_format( $space_allowed );
474
+		$space = number_format($space_allowed);
475 475
 		/* translators: Megabytes */
476
-		$space .= __( 'MB' );
476
+		$space .= __('MB');
477 477
 	}
478 478
 	?>
479 479
 	<strong><?php
480 480
 		/* translators: Storage space that's been used. 1: Percentage of used space, 2: Total space allowed in megabytes or gigabytes */
481
-		printf( __( 'Used: %1$s%% of %2$s' ), number_format( $percent_used ), $space );
481
+		printf(__('Used: %1$s%% of %2$s'), number_format($percent_used), $space);
482 482
 	?></strong>
483 483
 	<?php
484 484
 }
@@ -491,12 +491,12 @@  discard block
 block discarded – undo
491 491
  * @param int $size Current max size in bytes
492 492
  * @return int Max size in bytes
493 493
  */
494
-function fix_import_form_size( $size ) {
495
-	if ( upload_is_user_over_quota( false ) ) {
494
+function fix_import_form_size($size) {
495
+	if (upload_is_user_over_quota(false)) {
496 496
 		return 0;
497 497
 	}
498 498
 	$available = get_upload_space_available();
499
-	return min( $size, $available );
499
+	return min($size, $available);
500 500
 }
501 501
 
502 502
 /**
@@ -506,20 +506,20 @@  discard block
 block discarded – undo
506 506
  *
507 507
  * @param int $id The ID of the site to display the setting for.
508 508
  */
509
-function upload_space_setting( $id ) {
510
-	switch_to_blog( $id );
511
-	$quota = get_option( 'blog_upload_space' );
509
+function upload_space_setting($id) {
510
+	switch_to_blog($id);
511
+	$quota = get_option('blog_upload_space');
512 512
 	restore_current_blog();
513 513
 
514
-	if ( !$quota )
514
+	if ( ! $quota)
515 515
 		$quota = '';
516 516
 
517 517
 	?>
518 518
 	<tr>
519
-		<th><label for="blog-upload-space-number"><?php _e( 'Site Upload Space Quota' ); ?></label></th>
519
+		<th><label for="blog-upload-space-number"><?php _e('Site Upload Space Quota'); ?></label></th>
520 520
 		<td>
521 521
 			<input type="number" step="1" min="0" style="width: 100px" name="option[blog_upload_space]" id="blog-upload-space-number" aria-describedby="blog-upload-space-desc" value="<?php echo $quota; ?>" />
522
-			<span id="blog-upload-space-desc"><span class="screen-reader-text"><?php _e( 'Size in megabytes' ); ?></span> <?php _e( 'MB (Leave blank for network default)' ); ?></span>
522
+			<span id="blog-upload-space-desc"><span class="screen-reader-text"><?php _e('Size in megabytes'); ?></span> <?php _e('MB (Leave blank for network default)'); ?></span>
523 523
 		</td>
524 524
 	</tr>
525 525
 	<?php
@@ -541,19 +541,19 @@  discard block
 block discarded – undo
541 541
  * @param null   $deprecated Deprecated as of 3.0.2 and should not be used.
542 542
  * @return int   The initially passed $value.
543 543
  */
544
-function update_user_status( $id, $pref, $value, $deprecated = null ) {
544
+function update_user_status($id, $pref, $value, $deprecated = null) {
545 545
 	global $wpdb;
546 546
 
547
-	if ( null !== $deprecated )
548
-		_deprecated_argument( __FUNCTION__, '3.0.2' );
547
+	if (null !== $deprecated)
548
+		_deprecated_argument(__FUNCTION__, '3.0.2');
549 549
 
550
-	$wpdb->update( $wpdb->users, array( sanitize_key( $pref ) => $value ), array( 'ID' => $id ) );
550
+	$wpdb->update($wpdb->users, array(sanitize_key($pref) => $value), array('ID' => $id));
551 551
 
552
-	$user = new WP_User( $id );
553
-	clean_user_cache( $user );
552
+	$user = new WP_User($id);
553
+	clean_user_cache($user);
554 554
 
555
-	if ( $pref == 'spam' ) {
556
-		if ( $value == 1 ) {
555
+	if ($pref == 'spam') {
556
+		if ($value == 1) {
557 557
 			/**
558 558
 			 * Fires after the user is marked as a SPAM user.
559 559
 			 *
@@ -561,7 +561,7 @@  discard block
 block discarded – undo
561 561
 			 *
562 562
 			 * @param int $id ID of the user marked as SPAM.
563 563
 			 */
564
-			do_action( 'make_spam_user', $id );
564
+			do_action('make_spam_user', $id);
565 565
 		} else {
566 566
 			/**
567 567
 			 * Fires after the user is marked as a HAM user. Opposite of SPAM.
@@ -570,7 +570,7 @@  discard block
 block discarded – undo
570 570
 			 *
571 571
 			 * @param int $id ID of the user marked as HAM.
572 572
 			 */
573
-			do_action( 'make_ham_user', $id );
573
+			do_action('make_ham_user', $id);
574 574
 		}
575 575
 	}
576 576
 
@@ -585,13 +585,13 @@  discard block
 block discarded – undo
585 585
  * @param int $id The user ID.
586 586
  * @return bool|int The ID of the refreshed user or false if the user does not exist.
587 587
  */
588
-function refresh_user_details( $id ) {
588
+function refresh_user_details($id) {
589 589
 	$id = (int) $id;
590 590
 
591
-	if ( !$user = get_userdata( $id ) )
591
+	if ( ! $user = get_userdata($id))
592 592
 		return false;
593 593
 
594
-	clean_user_cache( $user );
594
+	clean_user_cache($user);
595 595
 
596 596
 	return $id;
597 597
 }
@@ -605,8 +605,8 @@  discard block
 block discarded – undo
605 605
  * @return string The language corresponding to $code if it exists. If it does not exist,
606 606
  *                then the first two letters of $code is returned.
607 607
  */
608
-function format_code_lang( $code = '' ) {
609
-	$code = strtolower( substr( $code, 0, 2 ) );
608
+function format_code_lang($code = '') {
609
+	$code = strtolower(substr($code, 0, 2));
610 610
 	$lang_codes = array(
611 611
 		'aa' => 'Afar', 'ab' => 'Abkhazian', 'af' => 'Afrikaans', 'ak' => 'Akan', 'sq' => 'Albanian', 'am' => 'Amharic', 'ar' => 'Arabic', 'an' => 'Aragonese', 'hy' => 'Armenian', 'as' => 'Assamese', 'av' => 'Avaric', 'ae' => 'Avestan', 'ay' => 'Aymara', 'az' => 'Azerbaijani', 'ba' => 'Bashkir', 'bm' => 'Bambara', 'eu' => 'Basque', 'be' => 'Belarusian', 'bn' => 'Bengali',
612 612
 		'bh' => 'Bihari', 'bi' => 'Bislama', 'bs' => 'Bosnian', 'br' => 'Breton', 'bg' => 'Bulgarian', 'my' => 'Burmese', 'ca' => 'Catalan; Valencian', 'ch' => 'Chamorro', 'ce' => 'Chechen', 'zh' => 'Chinese', 'cu' => 'Church Slavic; Old Slavonic; Church Slavonic; Old Bulgarian; Old Church Slavonic', 'cv' => 'Chuvash', 'kw' => 'Cornish', 'co' => 'Corsican', 'cr' => 'Cree',
@@ -618,7 +618,7 @@  discard block
 block discarded – undo
618 618
 		'no' => 'Norwegian', 'ny' => 'Chichewa; Chewa; Nyanja', 'oc' => 'Occitan, Provençal', 'oj' => 'Ojibwa', 'or' => 'Oriya', 'om' => 'Oromo', 'os' => 'Ossetian; Ossetic', 'pa' => 'Panjabi; Punjabi', 'fa' => 'Persian', 'pi' => 'Pali', 'pl' => 'Polish', 'pt' => 'Portuguese', 'ps' => 'Pushto', 'qu' => 'Quechua', 'rm' => 'Romansh', 'ro' => 'Romanian', 'rn' => 'Rundi', 'ru' => 'Russian',
619 619
 		'sg' => 'Sango', 'sa' => 'Sanskrit', 'sr' => 'Serbian', 'hr' => 'Croatian', 'si' => 'Sinhala; Sinhalese', 'sk' => 'Slovak', 'sl' => 'Slovenian', 'se' => 'Northern Sami', 'sm' => 'Samoan', 'sn' => 'Shona', 'sd' => 'Sindhi', 'so' => 'Somali', 'st' => 'Sotho, Southern', 'es' => 'Spanish; Castilian', 'sc' => 'Sardinian', 'ss' => 'Swati', 'su' => 'Sundanese', 'sw' => 'Swahili',
620 620
 		'sv' => 'Swedish', 'ty' => 'Tahitian', 'ta' => 'Tamil', 'tt' => 'Tatar', 'te' => 'Telugu', 'tg' => 'Tajik', 'tl' => 'Tagalog', 'th' => 'Thai', 'bo' => 'Tibetan', 'ti' => 'Tigrinya', 'to' => 'Tonga (Tonga Islands)', 'tn' => 'Tswana', 'ts' => 'Tsonga', 'tk' => 'Turkmen', 'tr' => 'Turkish', 'tw' => 'Twi', 'ug' => 'Uighur; Uyghur', 'uk' => 'Ukrainian', 'ur' => 'Urdu', 'uz' => 'Uzbek',
621
-		've' => 'Venda', 'vi' => 'Vietnamese', 'vo' => 'Volapük', 'cy' => 'Welsh','wa' => 'Walloon','wo' => 'Wolof', 'xh' => 'Xhosa', 'yi' => 'Yiddish', 'yo' => 'Yoruba', 'za' => 'Zhuang; Chuang', 'zu' => 'Zulu' );
621
+		've' => 'Venda', 'vi' => 'Vietnamese', 'vo' => 'Volapük', 'cy' => 'Welsh', 'wa' => 'Walloon', 'wo' => 'Wolof', 'xh' => 'Xhosa', 'yi' => 'Yiddish', 'yo' => 'Yoruba', 'za' => 'Zhuang; Chuang', 'zu' => 'Zulu' );
622 622
 
623 623
 	/**
624 624
 	 * Filters the language codes.
@@ -628,8 +628,8 @@  discard block
 block discarded – undo
628 628
 	 * @param array  $lang_codes Key/value pair of language codes where key is the short version.
629 629
 	 * @param string $code       A two-letter designation of the language.
630 630
 	 */
631
-	$lang_codes = apply_filters( 'lang_codes', $lang_codes, $code );
632
-	return strtr( $code, $lang_codes );
631
+	$lang_codes = apply_filters('lang_codes', $lang_codes, $code);
632
+	return strtr($code, $lang_codes);
633 633
 }
634 634
 
635 635
 /**
@@ -644,12 +644,12 @@  discard block
 block discarded – undo
644 644
  * @return object|array Returns `$term`, after filtering the 'slug' field with sanitize_title()
645 645
  *                      if $taxonomy is 'category' or 'post_tag'.
646 646
  */
647
-function sync_category_tag_slugs( $term, $taxonomy ) {
648
-	if ( global_terms_enabled() && ( $taxonomy == 'category' || $taxonomy == 'post_tag' ) ) {
649
-		if ( is_object( $term ) ) {
650
-			$term->slug = sanitize_title( $term->name );
647
+function sync_category_tag_slugs($term, $taxonomy) {
648
+	if (global_terms_enabled() && ($taxonomy == 'category' || $taxonomy == 'post_tag')) {
649
+		if (is_object($term)) {
650
+			$term->slug = sanitize_title($term->name);
651 651
 		} else {
652
-			$term['slug'] = sanitize_title( $term['name'] );
652
+			$term['slug'] = sanitize_title($term['name']);
653 653
 		}
654 654
 	}
655 655
 	return $term;
@@ -663,36 +663,36 @@  discard block
 block discarded – undo
663 663
  * @access private
664 664
  */
665 665
 function _access_denied_splash() {
666
-	if ( ! is_user_logged_in() || is_network_admin() )
666
+	if ( ! is_user_logged_in() || is_network_admin())
667 667
 		return;
668 668
 
669
-	$blogs = get_blogs_of_user( get_current_user_id() );
669
+	$blogs = get_blogs_of_user(get_current_user_id());
670 670
 
671
-	if ( wp_list_filter( $blogs, array( 'userblog_id' => get_current_blog_id() ) ) )
671
+	if (wp_list_filter($blogs, array('userblog_id' => get_current_blog_id())))
672 672
 		return;
673 673
 
674
-	$blog_name = get_bloginfo( 'name' );
674
+	$blog_name = get_bloginfo('name');
675 675
 
676
-	if ( empty( $blogs ) )
677
-		wp_die( sprintf( __( 'You attempted to access the "%1$s" dashboard, but you do not currently have privileges on this site. If you believe you should be able to access the "%1$s" dashboard, please contact your network administrator.' ), $blog_name ), 403 );
676
+	if (empty($blogs))
677
+		wp_die(sprintf(__('You attempted to access the "%1$s" dashboard, but you do not currently have privileges on this site. If you believe you should be able to access the "%1$s" dashboard, please contact your network administrator.'), $blog_name), 403);
678 678
 
679
-	$output = '<p>' . sprintf( __( 'You attempted to access the "%1$s" dashboard, but you do not currently have privileges on this site. If you believe you should be able to access the "%1$s" dashboard, please contact your network administrator.' ), $blog_name ) . '</p>';
680
-	$output .= '<p>' . __( 'If you reached this screen by accident and meant to visit one of your own sites, here are some shortcuts to help you find your way.' ) . '</p>';
679
+	$output = '<p>'.sprintf(__('You attempted to access the "%1$s" dashboard, but you do not currently have privileges on this site. If you believe you should be able to access the "%1$s" dashboard, please contact your network administrator.'), $blog_name).'</p>';
680
+	$output .= '<p>'.__('If you reached this screen by accident and meant to visit one of your own sites, here are some shortcuts to help you find your way.').'</p>';
681 681
 
682
-	$output .= '<h3>' . __('Your Sites') . '</h3>';
682
+	$output .= '<h3>'.__('Your Sites').'</h3>';
683 683
 	$output .= '<table>';
684 684
 
685
-	foreach ( $blogs as $blog ) {
685
+	foreach ($blogs as $blog) {
686 686
 		$output .= '<tr>';
687 687
 		$output .= "<td>{$blog->blogname}</td>";
688
-		$output .= '<td><a href="' . esc_url( get_admin_url( $blog->userblog_id ) ) . '">' . __( 'Visit Dashboard' ) . '</a> | ' .
689
-			'<a href="' . esc_url( get_home_url( $blog->userblog_id ) ). '">' . __( 'View Site' ) . '</a></td>';
688
+		$output .= '<td><a href="'.esc_url(get_admin_url($blog->userblog_id)).'">'.__('Visit Dashboard').'</a> | '.
689
+			'<a href="'.esc_url(get_home_url($blog->userblog_id)).'">'.__('View Site').'</a></td>';
690 690
 		$output .= '</tr>';
691 691
 	}
692 692
 
693 693
 	$output .= '</table>';
694 694
 
695
-	wp_die( $output, 403 );
695
+	wp_die($output, 403);
696 696
 }
697 697
 
698 698
 /**
@@ -703,8 +703,8 @@  discard block
 block discarded – undo
703 703
  * @param string $permission A permission to be checked. Currently not used.
704 704
  * @return bool True if the user has proper permissions, false if they do not.
705 705
  */
706
-function check_import_new_users( $permission ) {
707
-	if ( !is_super_admin() )
706
+function check_import_new_users($permission) {
707
+	if ( ! is_super_admin())
708 708
 		return false;
709 709
 	return true;
710 710
 }
@@ -718,33 +718,33 @@  discard block
 block discarded – undo
718 718
  * @param array  $lang_files Optional. An array of the language files. Default empty array.
719 719
  * @param string $current    Optional. The current language code. Default empty.
720 720
  */
721
-function mu_dropdown_languages( $lang_files = array(), $current = '' ) {
721
+function mu_dropdown_languages($lang_files = array(), $current = '') {
722 722
 	$flag = false;
723 723
 	$output = array();
724 724
 
725
-	foreach ( (array) $lang_files as $val ) {
726
-		$code_lang = basename( $val, '.mo' );
725
+	foreach ((array) $lang_files as $val) {
726
+		$code_lang = basename($val, '.mo');
727 727
 
728
-		if ( $code_lang == 'en_US' ) { // American English
728
+		if ($code_lang == 'en_US') { // American English
729 729
 			$flag = true;
730
-			$ae = __( 'American English' );
731
-			$output[$ae] = '<option value="' . esc_attr( $code_lang ) . '"' . selected( $current, $code_lang, false ) . '> ' . $ae . '</option>';
732
-		} elseif ( $code_lang == 'en_GB' ) { // British English
730
+			$ae = __('American English');
731
+			$output[$ae] = '<option value="'.esc_attr($code_lang).'"'.selected($current, $code_lang, false).'> '.$ae.'</option>';
732
+		} elseif ($code_lang == 'en_GB') { // British English
733 733
 			$flag = true;
734
-			$be = __( 'British English' );
735
-			$output[$be] = '<option value="' . esc_attr( $code_lang ) . '"' . selected( $current, $code_lang, false ) . '> ' . $be . '</option>';
734
+			$be = __('British English');
735
+			$output[$be] = '<option value="'.esc_attr($code_lang).'"'.selected($current, $code_lang, false).'> '.$be.'</option>';
736 736
 		} else {
737
-			$translated = format_code_lang( $code_lang );
738
-			$output[$translated] = '<option value="' . esc_attr( $code_lang ) . '"' . selected( $current, $code_lang, false ) . '> ' . esc_html ( $translated ) . '</option>';
737
+			$translated = format_code_lang($code_lang);
738
+			$output[$translated] = '<option value="'.esc_attr($code_lang).'"'.selected($current, $code_lang, false).'> '.esc_html($translated).'</option>';
739 739
 		}
740 740
 
741 741
 	}
742 742
 
743
-	if ( $flag === false ) // WordPress english
744
-		$output[] = '<option value=""' . selected( $current, '', false ) . '>' . __( 'English' ) . "</option>";
743
+	if ($flag === false) // WordPress english
744
+		$output[] = '<option value=""'.selected($current, '', false).'>'.__('English')."</option>";
745 745
 
746 746
 	// Order by name
747
-	uksort( $output, 'strnatcasecmp' );
747
+	uksort($output, 'strnatcasecmp');
748 748
 
749 749
 	/**
750 750
 	 * Filters the languages available in the dropdown.
@@ -755,9 +755,9 @@  discard block
 block discarded – undo
755 755
 	 * @param array $lang_files Available language files.
756 756
 	 * @param string $current   The current language code.
757 757
 	 */
758
-	$output = apply_filters( 'mu_dropdown_languages', $output, $lang_files, $current );
758
+	$output = apply_filters('mu_dropdown_languages', $output, $lang_files, $current);
759 759
 
760
-	echo implode( "\n\t", $output );
760
+	echo implode("\n\t", $output);
761 761
 }
762 762
 
763 763
 /**
@@ -773,16 +773,16 @@  discard block
 block discarded – undo
773 773
 function site_admin_notice() {
774 774
 	global $wp_db_version, $pagenow;
775 775
 
776
-	if ( ! is_super_admin() ) {
776
+	if ( ! is_super_admin()) {
777 777
 		return false;
778 778
 	}
779 779
 
780
-	if ( 'upgrade.php' == $pagenow ) {
780
+	if ('upgrade.php' == $pagenow) {
781 781
 		return;
782 782
 	}
783 783
 
784
-	if ( get_site_option( 'wpmu_upgrade_site' ) != $wp_db_version ) {
785
-		echo "<div class='update-nag'>" . sprintf( __( 'Thank you for Updating! Please visit the <a href="%s">Upgrade Network</a> page to update all your sites.' ), esc_url( network_admin_url( 'upgrade.php' ) ) ) . "</div>";
784
+	if (get_site_option('wpmu_upgrade_site') != $wp_db_version) {
785
+		echo "<div class='update-nag'>".sprintf(__('Thank you for Updating! Please visit the <a href="%s">Upgrade Network</a> page to update all your sites.'), esc_url(network_admin_url('upgrade.php')))."</div>";
786 786
 	}
787 787
 }
788 788
 
@@ -798,23 +798,23 @@  discard block
 block discarded – undo
798 798
  * @param array $postarr An array of posts. Not currently used.
799 799
  * @return array The new array of post data after checking for collisions.
800 800
  */
801
-function avoid_blog_page_permalink_collision( $data, $postarr ) {
802
-	if ( is_subdomain_install() )
801
+function avoid_blog_page_permalink_collision($data, $postarr) {
802
+	if (is_subdomain_install())
803 803
 		return $data;
804
-	if ( $data['post_type'] != 'page' )
804
+	if ($data['post_type'] != 'page')
805 805
 		return $data;
806
-	if ( !isset( $data['post_name'] ) || $data['post_name'] == '' )
806
+	if ( ! isset($data['post_name']) || $data['post_name'] == '')
807 807
 		return $data;
808
-	if ( !is_main_site() )
808
+	if ( ! is_main_site())
809 809
 		return $data;
810 810
 
811 811
 	$post_name = $data['post_name'];
812 812
 	$c = 0;
813
-	while( $c < 10 && get_id_from_blogname( $post_name ) ) {
814
-		$post_name .= mt_rand( 1, 10 );
815
-		$c ++;
813
+	while ($c < 10 && get_id_from_blogname($post_name)) {
814
+		$post_name .= mt_rand(1, 10);
815
+		$c++;
816 816
 	}
817
-	if ( $post_name != $data['post_name'] ) {
817
+	if ($post_name != $data['post_name']) {
818 818
 		$data['post_name'] = $post_name;
819 819
 	}
820 820
 	return $data;
@@ -833,31 +833,31 @@  discard block
 block discarded – undo
833 833
 	<table class="form-table">
834 834
 	<tr>
835 835
 	<?php /* translators: My sites label */ ?>
836
-		<th scope="row"><label for="primary_blog"><?php _e( 'Primary Site' ); ?></label></th>
836
+		<th scope="row"><label for="primary_blog"><?php _e('Primary Site'); ?></label></th>
837 837
 		<td>
838 838
 		<?php
839
-		$all_blogs = get_blogs_of_user( get_current_user_id() );
840
-		$primary_blog = get_user_meta( get_current_user_id(), 'primary_blog', true );
841
-		if ( count( $all_blogs ) > 1 ) {
839
+		$all_blogs = get_blogs_of_user(get_current_user_id());
840
+		$primary_blog = get_user_meta(get_current_user_id(), 'primary_blog', true);
841
+		if (count($all_blogs) > 1) {
842 842
 			$found = false;
843 843
 			?>
844 844
 			<select name="primary_blog" id="primary_blog">
845
-				<?php foreach ( (array) $all_blogs as $blog ) {
846
-					if ( $primary_blog == $blog->userblog_id )
845
+				<?php foreach ((array) $all_blogs as $blog) {
846
+					if ($primary_blog == $blog->userblog_id)
847 847
 						$found = true;
848
-					?><option value="<?php echo $blog->userblog_id ?>"<?php selected( $primary_blog, $blog->userblog_id ); ?>><?php echo esc_url( get_home_url( $blog->userblog_id ) ) ?></option><?php
848
+					?><option value="<?php echo $blog->userblog_id ?>"<?php selected($primary_blog, $blog->userblog_id); ?>><?php echo esc_url(get_home_url($blog->userblog_id)) ?></option><?php
849 849
 				} ?>
850 850
 			</select>
851 851
 			<?php
852
-			if ( !$found ) {
853
-				$blog = reset( $all_blogs );
854
-				update_user_meta( get_current_user_id(), 'primary_blog', $blog->userblog_id );
852
+			if ( ! $found) {
853
+				$blog = reset($all_blogs);
854
+				update_user_meta(get_current_user_id(), 'primary_blog', $blog->userblog_id);
855 855
 			}
856
-		} elseif ( count( $all_blogs ) == 1 ) {
857
-			$blog = reset( $all_blogs );
858
-			echo esc_url( get_home_url( $blog->userblog_id ) );
859
-			if ( $primary_blog != $blog->userblog_id ) // Set the primary blog again if it's out of sync with blog list.
860
-				update_user_meta( get_current_user_id(), 'primary_blog', $blog->userblog_id );
856
+		} elseif (count($all_blogs) == 1) {
857
+			$blog = reset($all_blogs);
858
+			echo esc_url(get_home_url($blog->userblog_id));
859
+			if ($primary_blog != $blog->userblog_id) // Set the primary blog again if it's out of sync with blog list.
860
+				update_user_meta(get_current_user_id(), 'primary_blog', $blog->userblog_id);
861 861
 		} else {
862 862
 			echo "N/A";
863 863
 		}
@@ -881,10 +881,10 @@  discard block
 block discarded – undo
881 881
  * @param int $site_id The network/site ID to check.
882 882
  * @return bool True if network can be edited, otherwise false.
883 883
  */
884
-function can_edit_network( $site_id ) {
884
+function can_edit_network($site_id) {
885 885
 	global $wpdb;
886 886
 
887
-	if ( $site_id == $wpdb->siteid )
887
+	if ($site_id == $wpdb->siteid)
888 888
 		$result = true;
889 889
 	else
890 890
 		$result = false;
@@ -897,7 +897,7 @@  discard block
 block discarded – undo
897 897
 	 * @param bool $result  Whether the network can be edited from this page.
898 898
 	 * @param int  $site_id The network/site ID to check.
899 899
 	 */
900
-	return apply_filters( 'can_edit_network', $result, $site_id );
900
+	return apply_filters('can_edit_network', $result, $site_id);
901 901
 }
902 902
 
903 903
 /**
@@ -910,7 +910,7 @@  discard block
 block discarded – undo
910 910
 function _thickbox_path_admin_subfolder() {
911 911
 ?>
912 912
 <script type="text/javascript">
913
-var tb_pathToImage = "<?php echo includes_url( 'js/thickbox/loadingAnimation.gif', 'relative' ); ?>";
913
+var tb_pathToImage = "<?php echo includes_url('js/thickbox/loadingAnimation.gif', 'relative'); ?>";
914 914
 </script>
915 915
 <?php
916 916
 }
@@ -919,77 +919,77 @@  discard block
 block discarded – undo
919 919
  *
920 920
  * @param array $users
921 921
  */
922
-function confirm_delete_users( $users ) {
922
+function confirm_delete_users($users) {
923 923
 	$current_user = wp_get_current_user();
924
-	if ( ! is_array( $users ) || empty( $users ) ) {
924
+	if ( ! is_array($users) || empty($users)) {
925 925
 		return false;
926 926
 	}
927 927
 	?>
928
-	<h1><?php esc_html_e( 'Users' ); ?></h1>
928
+	<h1><?php esc_html_e('Users'); ?></h1>
929 929
 
930
-	<?php if ( 1 == count( $users ) ) : ?>
931
-		<p><?php _e( 'You have chosen to delete the user from all networks and sites.' ); ?></p>
930
+	<?php if (1 == count($users)) : ?>
931
+		<p><?php _e('You have chosen to delete the user from all networks and sites.'); ?></p>
932 932
 	<?php else : ?>
933
-		<p><?php _e( 'You have chosen to delete the following users from all networks and sites.' ); ?></p>
933
+		<p><?php _e('You have chosen to delete the following users from all networks and sites.'); ?></p>
934 934
 	<?php endif; ?>
935 935
 
936 936
 	<form action="users.php?action=dodelete" method="post">
937 937
 	<input type="hidden" name="dodelete" />
938 938
 	<?php
939
-	wp_nonce_field( 'ms-users-delete' );
939
+	wp_nonce_field('ms-users-delete');
940 940
 	$site_admins = get_super_admins();
941
-	$admin_out = '<option value="' . esc_attr( $current_user->ID ) . '">' . $current_user->user_login . '</option>'; ?>
941
+	$admin_out = '<option value="'.esc_attr($current_user->ID).'">'.$current_user->user_login.'</option>'; ?>
942 942
 	<table class="form-table">
943
-	<?php foreach ( ( $allusers = (array) $_POST['allusers'] ) as $user_id ) {
944
-		if ( $user_id != '' && $user_id != '0' ) {
945
-			$delete_user = get_userdata( $user_id );
943
+	<?php foreach (($allusers = (array) $_POST['allusers']) as $user_id) {
944
+		if ($user_id != '' && $user_id != '0') {
945
+			$delete_user = get_userdata($user_id);
946 946
 
947
-			if ( ! current_user_can( 'delete_user', $delete_user->ID ) ) {
948
-				wp_die( sprintf( __( 'Warning! User %s cannot be deleted.' ), $delete_user->user_login ) );
947
+			if ( ! current_user_can('delete_user', $delete_user->ID)) {
948
+				wp_die(sprintf(__('Warning! User %s cannot be deleted.'), $delete_user->user_login));
949 949
 			}
950 950
 
951
-			if ( in_array( $delete_user->user_login, $site_admins ) ) {
952
-				wp_die( sprintf( __( 'Warning! User cannot be deleted. The user %s is a network administrator.' ), '<em>' . $delete_user->user_login . '</em>' ) );
951
+			if (in_array($delete_user->user_login, $site_admins)) {
952
+				wp_die(sprintf(__('Warning! User cannot be deleted. The user %s is a network administrator.'), '<em>'.$delete_user->user_login.'</em>'));
953 953
 			}
954 954
 			?>
955 955
 			<tr>
956 956
 				<th scope="row"><?php echo $delete_user->user_login; ?>
957
-					<?php echo '<input type="hidden" name="user[]" value="' . esc_attr( $user_id ) . '" />' . "\n"; ?>
957
+					<?php echo '<input type="hidden" name="user[]" value="'.esc_attr($user_id).'" />'."\n"; ?>
958 958
 				</th>
959
-			<?php $blogs = get_blogs_of_user( $user_id, true );
959
+			<?php $blogs = get_blogs_of_user($user_id, true);
960 960
 
961
-			if ( ! empty( $blogs ) ) {
961
+			if ( ! empty($blogs)) {
962 962
 				?>
963 963
 				<td><fieldset><p><legend><?php printf(
964 964
 					/* translators: user login */
965
-					__( 'What should be done with content owned by %s?' ),
966
-					'<em>' . $delete_user->user_login . '</em>'
965
+					__('What should be done with content owned by %s?'),
966
+					'<em>'.$delete_user->user_login.'</em>'
967 967
 				); ?></legend></p>
968 968
 				<?php
969
-				foreach ( (array) $blogs as $key => $details ) {
970
-					$blog_users = get_users( array( 'blog_id' => $details->userblog_id, 'fields' => array( 'ID', 'user_login' ) ) );
971
-					if ( is_array( $blog_users ) && !empty( $blog_users ) ) {
972
-						$user_site = "<a href='" . esc_url( get_home_url( $details->userblog_id ) ) . "'>{$details->blogname}</a>";
973
-						$user_dropdown = '<label for="reassign_user" class="screen-reader-text">' . __( 'Select a user' ) . '</label>';
969
+				foreach ((array) $blogs as $key => $details) {
970
+					$blog_users = get_users(array('blog_id' => $details->userblog_id, 'fields' => array('ID', 'user_login')));
971
+					if (is_array($blog_users) && ! empty($blog_users)) {
972
+						$user_site = "<a href='".esc_url(get_home_url($details->userblog_id))."'>{$details->blogname}</a>";
973
+						$user_dropdown = '<label for="reassign_user" class="screen-reader-text">'.__('Select a user').'</label>';
974 974
 						$user_dropdown .= "<select name='blog[$user_id][$key]' id='reassign_user'>";
975 975
 						$user_list = '';
976
-						foreach ( $blog_users as $user ) {
977
-							if ( ! in_array( $user->ID, $allusers ) ) {
976
+						foreach ($blog_users as $user) {
977
+							if ( ! in_array($user->ID, $allusers)) {
978 978
 								$user_list .= "<option value='{$user->ID}'>{$user->user_login}</option>";
979 979
 							}
980 980
 						}
981
-						if ( '' == $user_list ) {
981
+						if ('' == $user_list) {
982 982
 							$user_list = $admin_out;
983 983
 						}
984 984
 						$user_dropdown .= $user_list;
985 985
 						$user_dropdown .= "</select>\n";
986 986
 						?>
987 987
 						<ul style="list-style:none;">
988
-							<li><?php printf( __( 'Site: %s' ), $user_site ); ?></li>
989
-							<li><label><input type="radio" id="delete_option0" name="delete[<?php echo $details->userblog_id . '][' . $delete_user->ID ?>]" value="delete" checked="checked" />
990
-							<?php _e( 'Delete all content.' ); ?></label></li>
991
-							<li><label><input type="radio" id="delete_option1" name="delete[<?php echo $details->userblog_id . '][' . $delete_user->ID ?>]" value="reassign" />
992
-							<?php _e( 'Attribute all content to:' ); ?></label>
988
+							<li><?php printf(__('Site: %s'), $user_site); ?></li>
989
+							<li><label><input type="radio" id="delete_option0" name="delete[<?php echo $details->userblog_id.']['.$delete_user->ID ?>]" value="delete" checked="checked" />
990
+							<?php _e('Delete all content.'); ?></label></li>
991
+							<li><label><input type="radio" id="delete_option1" name="delete[<?php echo $details->userblog_id.']['.$delete_user->ID ?>]" value="reassign" />
992
+							<?php _e('Attribute all content to:'); ?></label>
993 993
 							<?php echo $user_dropdown; ?></li>
994 994
 						</ul>
995 995
 						<?php
@@ -998,7 +998,7 @@  discard block
 block discarded – undo
998 998
 				echo "</fieldset></td></tr>";
999 999
 			} else {
1000 1000
 				?>
1001
-				<td><fieldset><p><legend><?php _e( 'User has no sites or content and will be deleted.' ); ?></legend></p>
1001
+				<td><fieldset><p><legend><?php _e('User has no sites or content and will be deleted.'); ?></legend></p>
1002 1002
 			<?php } ?>
1003 1003
 			</tr>
1004 1004
 		<?php
@@ -1009,15 +1009,15 @@  discard block
 block discarded – undo
1009 1009
 	</table>
1010 1010
 	<?php
1011 1011
 	/** This action is documented in wp-admin/users.php */
1012
-	do_action( 'delete_user_form', $current_user, $allusers );
1012
+	do_action('delete_user_form', $current_user, $allusers);
1013 1013
 
1014
-	if ( 1 == count( $users ) ) : ?>
1015
-		<p><?php _e( 'Once you hit &#8220;Confirm Deletion&#8221;, the user will be permanently removed.' ); ?></p>
1014
+	if (1 == count($users)) : ?>
1015
+		<p><?php _e('Once you hit &#8220;Confirm Deletion&#8221;, the user will be permanently removed.'); ?></p>
1016 1016
 	<?php else : ?>
1017
-		<p><?php _e( 'Once you hit &#8220;Confirm Deletion&#8221;, these users will be permanently removed.' ); ?></p>
1017
+		<p><?php _e('Once you hit &#8220;Confirm Deletion&#8221;, these users will be permanently removed.'); ?></p>
1018 1018
 	<?php endif;
1019 1019
 
1020
-	submit_button( __('Confirm Deletion'), 'primary' );
1020
+	submit_button(__('Confirm Deletion'), 'primary');
1021 1021
 	?>
1022 1022
 	</form>
1023 1023
 	<?php
@@ -1059,7 +1059,7 @@  discard block
 block discarded – undo
1059 1059
  *     @type string $selected The ID of the selected link.
1060 1060
  * }
1061 1061
  */
1062
-function network_edit_site_nav( $args = array() ) {
1062
+function network_edit_site_nav($args = array()) {
1063 1063
 
1064 1064
 	/**
1065 1065
 	 * Filters the links that appear on site-editing network pages.
@@ -1080,51 +1080,51 @@  discard block
 block discarded – undo
1080 1080
 	 *     }
1081 1081
 	 * }
1082 1082
 	 */
1083
-	$links = apply_filters( 'network_edit_site_nav_links', array(
1084
-		'site-info'     => array( 'label' => __( 'Info' ),     'url' => 'site-info.php',     'cap' => 'manage_sites' ),
1085
-		'site-users'    => array( 'label' => __( 'Users' ),    'url' => 'site-users.php',    'cap' => 'manage_sites' ),
1086
-		'site-themes'   => array( 'label' => __( 'Themes' ),   'url' => 'site-themes.php',   'cap' => 'manage_sites' ),
1087
-		'site-settings' => array( 'label' => __( 'Settings' ), 'url' => 'site-settings.php', 'cap' => 'manage_sites' )
1088
-	) );
1083
+	$links = apply_filters('network_edit_site_nav_links', array(
1084
+		'site-info'     => array('label' => __('Info'), 'url' => 'site-info.php', 'cap' => 'manage_sites'),
1085
+		'site-users'    => array('label' => __('Users'), 'url' => 'site-users.php', 'cap' => 'manage_sites'),
1086
+		'site-themes'   => array('label' => __('Themes'), 'url' => 'site-themes.php', 'cap' => 'manage_sites'),
1087
+		'site-settings' => array('label' => __('Settings'), 'url' => 'site-settings.php', 'cap' => 'manage_sites')
1088
+	));
1089 1089
 
1090 1090
 	// Parse arguments
1091
-	$r = wp_parse_args( $args, array(
1092
-		'blog_id'  => isset( $_GET['blog_id'] ) ? (int) $_GET['blog_id'] : 0,
1091
+	$r = wp_parse_args($args, array(
1092
+		'blog_id'  => isset($_GET['blog_id']) ? (int) $_GET['blog_id'] : 0,
1093 1093
 		'links'    => $links,
1094 1094
 		'selected' => 'site-info',
1095
-	) );
1095
+	));
1096 1096
 
1097 1097
 	// Setup the links array
1098 1098
 	$screen_links = array();
1099 1099
 
1100 1100
 	// Loop through tabs
1101
-	foreach ( $r['links'] as $link_id => $link ) {
1101
+	foreach ($r['links'] as $link_id => $link) {
1102 1102
 
1103 1103
 		// Skip link if user can't access
1104
-		if ( ! current_user_can( $link['cap'], $r['blog_id'] ) ) {
1104
+		if ( ! current_user_can($link['cap'], $r['blog_id'])) {
1105 1105
 			continue;
1106 1106
 		}
1107 1107
 
1108 1108
 		// Link classes
1109
-		$classes = array( 'nav-tab' );
1109
+		$classes = array('nav-tab');
1110 1110
 
1111 1111
 		// Selected is set by the parent OR assumed by the $pagenow global
1112
-		if ( $r['selected'] === $link_id || $link['url'] === $GLOBALS['pagenow'] ) {
1112
+		if ($r['selected'] === $link_id || $link['url'] === $GLOBALS['pagenow']) {
1113 1113
 			$classes[] = 'nav-tab-active';
1114 1114
 		}
1115 1115
 
1116 1116
 		// Escape each class
1117
-		$esc_classes = implode( ' ', $classes );
1117
+		$esc_classes = implode(' ', $classes);
1118 1118
 
1119 1119
 		// Get the URL for this link
1120
-		$url = add_query_arg( array( 'id' => $r['blog_id'] ), network_admin_url( $link['url'] ) );
1120
+		$url = add_query_arg(array('id' => $r['blog_id']), network_admin_url($link['url']));
1121 1121
 
1122 1122
 		// Add link to nav links
1123
-		$screen_links[ $link_id ] = '<a href="' . esc_url( $url ) . '" id="' . esc_attr( $link_id ) . '" class="' . $esc_classes . '">' . esc_html( $link['label'] ) . '</a>';
1123
+		$screen_links[$link_id] = '<a href="'.esc_url($url).'" id="'.esc_attr($link_id).'" class="'.$esc_classes.'">'.esc_html($link['label']).'</a>';
1124 1124
 	}
1125 1125
 
1126 1126
 	// All done!
1127 1127
 	echo '<h2 class="nav-tab-wrapper wp-clearfix">';
1128
-	echo implode( '', $screen_links );
1128
+	echo implode('', $screen_links);
1129 1129
 	echo '</h2>';
1130 1130
 }
Please login to merge, or discard this patch.
src/wp-admin/includes/nav-menu.php 3 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -1282,7 +1282,7 @@
 block discarded – undo
1282 1282
  *
1283 1283
  * @param int|string $nav_menu_selected_id (id, slug, or name ) of the currently-selected menu
1284 1284
  * @param string $nav_menu_selected_title Title of the currently-selected menu
1285
- * @return array $messages The menu updated message
1285
+ * @return string[] $messages The menu updated message
1286 1286
  */
1287 1287
 function wp_nav_menu_update_menu_items ( $nav_menu_selected_id, $nav_menu_selected_title ) {
1288 1288
 	$unsorted_menu_items = wp_get_nav_menu_items( $nav_menu_selected_id, array( 'orderby' => 'ID', 'output' => ARRAY_A, 'output_key' => 'ID', 'post_status' => 'draft,publish' ) );
Please login to merge, or discard this patch.
Braces   +73 added lines, -39 removed lines patch added patch discarded remove patch
@@ -102,8 +102,9 @@  discard block
 block discarded – undo
102 102
 				'name__like' => $query,
103 103
 				'number' => 10,
104 104
 			));
105
-			if ( empty( $terms ) || is_wp_error( $terms ) )
106
-				return;
105
+			if ( empty( $terms ) || is_wp_error( $terms ) ) {
106
+							return;
107
+			}
107 108
 			foreach ( (array) $terms as $term ) {
108 109
 				if ( 'markup' == $response_format ) {
109 110
 					echo walk_nav_menu_tree( array_map('wp_setup_nav_menu_item', array( $term ) ), 0, (object) $args );
@@ -155,8 +156,9 @@  discard block
 block discarded – undo
155 156
 function wp_initial_nav_menu_meta_boxes() {
156 157
 	global $wp_meta_boxes;
157 158
 
158
-	if ( get_user_option( 'metaboxhidden_nav-menus' ) !== false || ! is_array($wp_meta_boxes) )
159
-		return;
159
+	if ( get_user_option( 'metaboxhidden_nav-menus' ) !== false || ! is_array($wp_meta_boxes) ) {
160
+			return;
161
+	}
160 162
 
161 163
 	$initial_meta_boxes = array( 'add-post-type-page', 'add-post-type-post', 'add-custom-links', 'add-category' );
162 164
 	$hidden_meta_boxes = array();
@@ -185,8 +187,9 @@  discard block
 block discarded – undo
185 187
 function wp_nav_menu_post_type_meta_boxes() {
186 188
 	$post_types = get_post_types( array( 'show_in_nav_menus' => true ), 'object' );
187 189
 
188
-	if ( ! $post_types )
189
-		return;
190
+	if ( ! $post_types ) {
191
+			return;
192
+	}
190 193
 
191 194
 	foreach ( $post_types as $post_type ) {
192 195
 		/**
@@ -219,8 +222,9 @@  discard block
 block discarded – undo
219 222
 function wp_nav_menu_taxonomy_meta_boxes() {
220 223
 	$taxonomies = get_taxonomies( array( 'show_in_nav_menus' => true ), 'object' );
221 224
 
222
-	if ( !$taxonomies )
223
-		return;
225
+	if ( !$taxonomies ) {
226
+			return;
227
+	}
224 228
 
225 229
 	foreach ( $taxonomies as $tax ) {
226 230
 		/** This filter is documented in wp-admin/includes/nav-menu.php */
@@ -245,8 +249,9 @@  discard block
 block discarded – undo
245 249
 function wp_nav_menu_disabled_check( $nav_menu_selected_id ) {
246 250
 	global $one_theme_location_no_menus;
247 251
 
248
-	if ( $one_theme_location_no_menus )
249
-		return false;
252
+	if ( $one_theme_location_no_menus ) {
253
+			return false;
254
+	}
250 255
 
251 256
 	return disabled( $nav_menu_selected_id, 0 );
252 257
 }
@@ -327,8 +332,9 @@  discard block
 block discarded – undo
327 332
 		'update_post_meta_cache' => false
328 333
 	);
329 334
 
330
-	if ( isset( $box['args']->_default_query ) )
331
-		$args = array_merge($args, (array) $box['args']->_default_query );
335
+	if ( isset( $box['args']->_default_query ) ) {
336
+			$args = array_merge($args, (array) $box['args']->_default_query );
337
+	}
332 338
 
333 339
 	// @todo transient caching of these results with proper invalidation on updating of a post of this type
334 340
 	$get_posts = new WP_Query;
@@ -385,17 +391,26 @@  discard block
 block discarded – undo
385 391
 	<div id="posttype-<?php echo $post_type_name; ?>" class="posttypediv">
386 392
 		<ul id="posttype-<?php echo $post_type_name; ?>-tabs" class="posttype-tabs add-menu-item-tabs">
387 393
 			<li <?php echo ( 'most-recent' == $current_tab ? ' class="tabs"' : '' ); ?>>
388
-				<a class="nav-tab-link" data-type="tabs-panel-posttype-<?php echo esc_attr( $post_type_name ); ?>-most-recent" href="<?php if ( $nav_menu_selected_id ) echo esc_url(add_query_arg($post_type_name . '-tab', 'most-recent', remove_query_arg($removed_args))); ?>#tabs-panel-posttype-<?php echo $post_type_name; ?>-most-recent">
394
+				<a class="nav-tab-link" data-type="tabs-panel-posttype-<?php echo esc_attr( $post_type_name ); ?>-most-recent" href="<?php if ( $nav_menu_selected_id ) {
395
+	echo esc_url(add_query_arg($post_type_name . '-tab', 'most-recent', remove_query_arg($removed_args)));
396
+}
397
+?>#tabs-panel-posttype-<?php echo $post_type_name; ?>-most-recent">
389 398
 					<?php _e( 'Most Recent' ); ?>
390 399
 				</a>
391 400
 			</li>
392 401
 			<li <?php echo ( 'all' == $current_tab ? ' class="tabs"' : '' ); ?>>
393
-				<a class="nav-tab-link" data-type="<?php echo esc_attr( $post_type_name ); ?>-all" href="<?php if ( $nav_menu_selected_id ) echo esc_url(add_query_arg($post_type_name . '-tab', 'all', remove_query_arg($removed_args))); ?>#<?php echo $post_type_name; ?>-all">
402
+				<a class="nav-tab-link" data-type="<?php echo esc_attr( $post_type_name ); ?>-all" href="<?php if ( $nav_menu_selected_id ) {
403
+	echo esc_url(add_query_arg($post_type_name . '-tab', 'all', remove_query_arg($removed_args)));
404
+}
405
+?>#<?php echo $post_type_name; ?>-all">
394 406
 					<?php _e( 'View All' ); ?>
395 407
 				</a>
396 408
 			</li>
397 409
 			<li <?php echo ( 'search' == $current_tab ? ' class="tabs"' : '' ); ?>>
398
-				<a class="nav-tab-link" data-type="tabs-panel-posttype-<?php echo esc_attr( $post_type_name ); ?>-search" href="<?php if ( $nav_menu_selected_id ) echo esc_url(add_query_arg($post_type_name . '-tab', 'search', remove_query_arg($removed_args))); ?>#tabs-panel-posttype-<?php echo $post_type_name; ?>-search">
410
+				<a class="nav-tab-link" data-type="tabs-panel-posttype-<?php echo esc_attr( $post_type_name ); ?>-search" href="<?php if ( $nav_menu_selected_id ) {
411
+	echo esc_url(add_query_arg($post_type_name . '-tab', 'search', remove_query_arg($removed_args)));
412
+}
413
+?>#tabs-panel-posttype-<?php echo $post_type_name; ?>-search">
399 414
 					<?php _e( 'Search'); ?>
400 415
 				</a>
401 416
 			</li>
@@ -669,17 +684,26 @@  discard block
 block discarded – undo
669 684
 	<div id="taxonomy-<?php echo $taxonomy_name; ?>" class="taxonomydiv">
670 685
 		<ul id="taxonomy-<?php echo $taxonomy_name; ?>-tabs" class="taxonomy-tabs add-menu-item-tabs">
671 686
 			<li <?php echo ( 'most-used' == $current_tab ? ' class="tabs"' : '' ); ?>>
672
-				<a class="nav-tab-link" data-type="tabs-panel-<?php echo esc_attr( $taxonomy_name ); ?>-pop" href="<?php if ( $nav_menu_selected_id ) echo esc_url(add_query_arg($taxonomy_name . '-tab', 'most-used', remove_query_arg($removed_args))); ?>#tabs-panel-<?php echo $taxonomy_name; ?>-pop">
687
+				<a class="nav-tab-link" data-type="tabs-panel-<?php echo esc_attr( $taxonomy_name ); ?>-pop" href="<?php if ( $nav_menu_selected_id ) {
688
+	echo esc_url(add_query_arg($taxonomy_name . '-tab', 'most-used', remove_query_arg($removed_args)));
689
+}
690
+?>#tabs-panel-<?php echo $taxonomy_name; ?>-pop">
673 691
 					<?php _e( 'Most Used' ); ?>
674 692
 				</a>
675 693
 			</li>
676 694
 			<li <?php echo ( 'all' == $current_tab ? ' class="tabs"' : '' ); ?>>
677
-				<a class="nav-tab-link" data-type="tabs-panel-<?php echo esc_attr( $taxonomy_name ); ?>-all" href="<?php if ( $nav_menu_selected_id ) echo esc_url(add_query_arg($taxonomy_name . '-tab', 'all', remove_query_arg($removed_args))); ?>#tabs-panel-<?php echo $taxonomy_name; ?>-all">
695
+				<a class="nav-tab-link" data-type="tabs-panel-<?php echo esc_attr( $taxonomy_name ); ?>-all" href="<?php if ( $nav_menu_selected_id ) {
696
+	echo esc_url(add_query_arg($taxonomy_name . '-tab', 'all', remove_query_arg($removed_args)));
697
+}
698
+?>#tabs-panel-<?php echo $taxonomy_name; ?>-all">
678 699
 					<?php _e( 'View All' ); ?>
679 700
 				</a>
680 701
 			</li>
681 702
 			<li <?php echo ( 'search' == $current_tab ? ' class="tabs"' : '' ); ?>>
682
-				<a class="nav-tab-link" data-type="tabs-panel-search-taxonomy-<?php echo esc_attr( $taxonomy_name ); ?>" href="<?php if ( $nav_menu_selected_id ) echo esc_url(add_query_arg($taxonomy_name . '-tab', 'search', remove_query_arg($removed_args))); ?>#tabs-panel-search-taxonomy-<?php echo $taxonomy_name; ?>">
703
+				<a class="nav-tab-link" data-type="tabs-panel-search-taxonomy-<?php echo esc_attr( $taxonomy_name ); ?>" href="<?php if ( $nav_menu_selected_id ) {
704
+	echo esc_url(add_query_arg($taxonomy_name . '-tab', 'search', remove_query_arg($removed_args)));
705
+}
706
+?>#tabs-panel-search-taxonomy-<?php echo $taxonomy_name; ?>">
683 707
 					<?php _e( 'Search' ); ?>
684 708
 				</a>
685 709
 			</li>
@@ -904,8 +928,9 @@  discard block
 block discarded – undo
904 928
 		$result .= '<p>' . __( 'Add menu items from the column on the left.' ) . '</p>';
905 929
 		$result .= '</div>';
906 930
 
907
-		if ( empty($menu_items) )
908
-			return $result . ' <ul class="menu" id="menu-to-edit"> </ul>';
931
+		if ( empty($menu_items) ) {
932
+					return $result . ' <ul class="menu" id="menu-to-edit"> </ul>';
933
+		}
909 934
 
910 935
 		/**
911 936
 		 * Filters the Walker class used when adding nav menu items.
@@ -930,10 +955,12 @@  discard block
 block discarded – undo
930 955
 
931 956
 		$some_pending_menu_items = $some_invalid_menu_items = false;
932 957
 		foreach ( (array) $menu_items as $menu_item ) {
933
-			if ( isset( $menu_item->post_status ) && 'draft' == $menu_item->post_status )
934
-				$some_pending_menu_items = true;
935
-			if ( ! empty( $menu_item->_invalid ) )
936
-				$some_invalid_menu_items = true;
958
+			if ( isset( $menu_item->post_status ) && 'draft' == $menu_item->post_status ) {
959
+							$some_pending_menu_items = true;
960
+			}
961
+			if ( ! empty( $menu_item->_invalid ) ) {
962
+							$some_invalid_menu_items = true;
963
+			}
937 964
 		}
938 965
 
939 966
 		if ( $some_pending_menu_items ) {
@@ -988,9 +1015,10 @@  discard block
 block discarded – undo
988 1015
 	// Delete orphaned draft menu items.
989 1016
 	$menu_items_to_delete = $wpdb->get_col($wpdb->prepare("SELECT ID FROM $wpdb->posts AS p LEFT JOIN $wpdb->postmeta AS m ON p.ID = m.post_id WHERE post_type = 'nav_menu_item' AND post_status = 'draft' AND meta_key = '_menu_item_orphaned' AND meta_value < '%d'", $delete_timestamp ) );
990 1017
 
991
-	foreach ( (array) $menu_items_to_delete as $menu_item_id )
992
-		wp_delete_post( $menu_item_id, true );
993
-}
1018
+	foreach ( (array) $menu_items_to_delete as $menu_item_id ) {
1019
+			wp_delete_post( $menu_item_id, true );
1020
+	}
1021
+	}
994 1022
 
995 1023
 /**
996 1024
  * Saves nav menu items
@@ -1006,8 +1034,9 @@  discard block
 block discarded – undo
1006 1034
 	$messages = array();
1007 1035
 	$menu_items = array();
1008 1036
 	// Index menu items by db ID
1009
-	foreach ( $unsorted_menu_items as $_item )
1010
-		$menu_items[$_item->db_id] = $_item;
1037
+	foreach ( $unsorted_menu_items as $_item ) {
1038
+			$menu_items[$_item->db_id] = $_item;
1039
+	}
1011 1040
 
1012 1041
 	$post_fields = array(
1013 1042
 		'menu-item-db-id', 'menu-item-object-id', 'menu-item-object',
@@ -1022,12 +1051,14 @@  discard block
 block discarded – undo
1022 1051
 		foreach ( (array) $_POST['menu-item-db-id'] as $_key => $k ) {
1023 1052
 
1024 1053
 			// Menu item title can't be blank
1025
-			if ( ! isset( $_POST['menu-item-title'][ $_key ] ) || '' == $_POST['menu-item-title'][ $_key ] )
1026
-				continue;
1054
+			if ( ! isset( $_POST['menu-item-title'][ $_key ] ) || '' == $_POST['menu-item-title'][ $_key ] ) {
1055
+							continue;
1056
+			}
1027 1057
 
1028 1058
 			$args = array();
1029
-			foreach ( $post_fields as $field )
1030
-				$args[$field] = isset( $_POST[$field][$_key] ) ? $_POST[$field][$_key] : '';
1059
+			foreach ( $post_fields as $field ) {
1060
+							$args[$field] = isset( $_POST[$field][$_key] ) ? $_POST[$field][$_key] : '';
1061
+			}
1031 1062
 
1032 1063
 			$menu_item_db_id = wp_update_nav_menu_item( $nav_menu_selected_id, ( $_POST['menu-item-db-id'][$_key] != $_key ? 0 : $_key ), $args );
1033 1064
 
@@ -1051,14 +1082,17 @@  discard block
 block discarded – undo
1051 1082
 	// Store 'auto-add' pages.
1052 1083
 	$auto_add = ! empty( $_POST['auto-add-pages'] );
1053 1084
 	$nav_menu_option = (array) get_option( 'nav_menu_options' );
1054
-	if ( ! isset( $nav_menu_option['auto_add'] ) )
1055
-		$nav_menu_option['auto_add'] = array();
1085
+	if ( ! isset( $nav_menu_option['auto_add'] ) ) {
1086
+			$nav_menu_option['auto_add'] = array();
1087
+	}
1056 1088
 	if ( $auto_add ) {
1057
-		if ( ! in_array( $nav_menu_selected_id, $nav_menu_option['auto_add'] ) )
1058
-			$nav_menu_option['auto_add'][] = $nav_menu_selected_id;
1089
+		if ( ! in_array( $nav_menu_selected_id, $nav_menu_option['auto_add'] ) ) {
1090
+					$nav_menu_option['auto_add'][] = $nav_menu_selected_id;
1091
+		}
1059 1092
 	} else {
1060
-		if ( false !== ( $key = array_search( $nav_menu_selected_id, $nav_menu_option['auto_add'] ) ) )
1061
-			unset( $nav_menu_option['auto_add'][$key] );
1093
+		if ( false !== ( $key = array_search( $nav_menu_selected_id, $nav_menu_option['auto_add'] ) ) ) {
1094
+					unset( $nav_menu_option['auto_add'][$key] );
1095
+		}
1062 1096
 	}
1063 1097
 	// Remove nonexistent/deleted menus
1064 1098
 	$nav_menu_option['auto_add'] = array_intersect( $nav_menu_option['auto_add'], wp_get_nav_menus( array( 'fields' => 'ids' ) ) );
Please login to merge, or discard this patch.
Spacing   +294 added lines, -294 removed lines patch added patch discarded remove patch
@@ -8,10 +8,10 @@  discard block
 block discarded – undo
8 8
  */
9 9
 
10 10
 /** Walker_Nav_Menu_Edit class */
11
-require_once( ABSPATH . 'wp-admin/includes/class-walker-nav-menu-edit.php' );
11
+require_once(ABSPATH.'wp-admin/includes/class-walker-nav-menu-edit.php');
12 12
 
13 13
 /** Walker_Nav_Menu_Checklist class */
14
-require_once( ABSPATH . 'wp-admin/includes/class-walker-nav-menu-checklist.php' );
14
+require_once(ABSPATH.'wp-admin/includes/class-walker-nav-menu-checklist.php');
15 15
 
16 16
 /**
17 17
  * Prints the appropriate response to a menu quick search.
@@ -20,41 +20,41 @@  discard block
 block discarded – undo
20 20
  *
21 21
  * @param array $request The unsanitized request values.
22 22
  */
23
-function _wp_ajax_menu_quick_search( $request = array() ) {
23
+function _wp_ajax_menu_quick_search($request = array()) {
24 24
 	$args = array();
25
-	$type = isset( $request['type'] ) ? $request['type'] : '';
26
-	$object_type = isset( $request['object_type'] ) ? $request['object_type'] : '';
27
-	$query = isset( $request['q'] ) ? $request['q'] : '';
28
-	$response_format = isset( $request['response-format'] ) && in_array( $request['response-format'], array( 'json', 'markup' ) ) ? $request['response-format'] : 'json';
25
+	$type = isset($request['type']) ? $request['type'] : '';
26
+	$object_type = isset($request['object_type']) ? $request['object_type'] : '';
27
+	$query = isset($request['q']) ? $request['q'] : '';
28
+	$response_format = isset($request['response-format']) && in_array($request['response-format'], array('json', 'markup')) ? $request['response-format'] : 'json';
29 29
 
30
-	if ( 'markup' == $response_format ) {
30
+	if ('markup' == $response_format) {
31 31
 		$args['walker'] = new Walker_Nav_Menu_Checklist;
32 32
 	}
33 33
 
34
-	if ( 'get-post-item' == $type ) {
35
-		if ( post_type_exists( $object_type ) ) {
36
-			if ( isset( $request['ID'] ) ) {
34
+	if ('get-post-item' == $type) {
35
+		if (post_type_exists($object_type)) {
36
+			if (isset($request['ID'])) {
37 37
 				$object_id = (int) $request['ID'];
38
-				if ( 'markup' == $response_format ) {
39
-					echo walk_nav_menu_tree( array_map('wp_setup_nav_menu_item', array( get_post( $object_id ) ) ), 0, (object) $args );
40
-				} elseif ( 'json' == $response_format ) {
38
+				if ('markup' == $response_format) {
39
+					echo walk_nav_menu_tree(array_map('wp_setup_nav_menu_item', array(get_post($object_id))), 0, (object) $args);
40
+				} elseif ('json' == $response_format) {
41 41
 					echo wp_json_encode(
42 42
 						array(
43 43
 							'ID' => $object_id,
44
-							'post_title' => get_the_title( $object_id ),
45
-							'post_type' => get_post_type( $object_id ),
44
+							'post_title' => get_the_title($object_id),
45
+							'post_type' => get_post_type($object_id),
46 46
 						)
47 47
 					);
48 48
 					echo "\n";
49 49
 				}
50 50
 			}
51
-		} elseif ( taxonomy_exists( $object_type ) ) {
52
-			if ( isset( $request['ID'] ) ) {
51
+		} elseif (taxonomy_exists($object_type)) {
52
+			if (isset($request['ID'])) {
53 53
 				$object_id = (int) $request['ID'];
54
-				if ( 'markup' == $response_format ) {
55
-					echo walk_nav_menu_tree( array_map('wp_setup_nav_menu_item', array( get_term( $object_id, $object_type ) ) ), 0, (object) $args );
56
-				} elseif ( 'json' == $response_format ) {
57
-					$post_obj = get_term( $object_id, $object_type );
54
+				if ('markup' == $response_format) {
55
+					echo walk_nav_menu_tree(array_map('wp_setup_nav_menu_item', array(get_term($object_id, $object_type))), 0, (object) $args);
56
+				} elseif ('json' == $response_format) {
57
+					$post_obj = get_term($object_id, $object_type);
58 58
 					echo wp_json_encode(
59 59
 						array(
60 60
 							'ID' => $object_id,
@@ -68,9 +68,9 @@  discard block
 block discarded – undo
68 68
 
69 69
 		}
70 70
 
71
-	} elseif ( preg_match('/quick-search-(posttype|taxonomy)-([a-zA-Z_-]*\b)/', $type, $matches) ) {
72
-		if ( 'posttype' == $matches[1] && get_post_type_object( $matches[2] ) ) {
73
-			$post_type_obj = _wp_nav_menu_meta_box_object( get_post_type_object( $matches[2] ) );
71
+	} elseif (preg_match('/quick-search-(posttype|taxonomy)-([a-zA-Z_-]*\b)/', $type, $matches)) {
72
+		if ('posttype' == $matches[1] && get_post_type_object($matches[2])) {
73
+			$post_type_obj = _wp_nav_menu_meta_box_object(get_post_type_object($matches[2]));
74 74
 			$args = array_merge(
75 75
 				$args,
76 76
 				array(
@@ -82,40 +82,40 @@  discard block
 block discarded – undo
82 82
 					's'                      => $query,
83 83
 				)
84 84
 			);
85
-			if ( isset( $post_type_obj->_default_query ) ) {
86
-				$args = array_merge( $args, (array) $post_type_obj->_default_query );
85
+			if (isset($post_type_obj->_default_query)) {
86
+				$args = array_merge($args, (array) $post_type_obj->_default_query);
87 87
 			}
88
-			$search_results_query = new WP_Query( $args );
89
-			if ( ! $search_results_query->have_posts() ) {
88
+			$search_results_query = new WP_Query($args);
89
+			if ( ! $search_results_query->have_posts()) {
90 90
 				return;
91 91
 			}
92
-			while ( $search_results_query->have_posts() ) {
92
+			while ($search_results_query->have_posts()) {
93 93
 				$post = $search_results_query->next_post();
94
-				if ( 'markup' == $response_format ) {
94
+				if ('markup' == $response_format) {
95 95
 					$var_by_ref = $post->ID;
96
-					echo walk_nav_menu_tree( array_map('wp_setup_nav_menu_item', array( get_post( $var_by_ref ) ) ), 0, (object) $args );
97
-				} elseif ( 'json' == $response_format ) {
96
+					echo walk_nav_menu_tree(array_map('wp_setup_nav_menu_item', array(get_post($var_by_ref))), 0, (object) $args);
97
+				} elseif ('json' == $response_format) {
98 98
 					echo wp_json_encode(
99 99
 						array(
100 100
 							'ID' => $post->ID,
101
-							'post_title' => get_the_title( $post->ID ),
101
+							'post_title' => get_the_title($post->ID),
102 102
 							'post_type' => $matches[2],
103 103
 						)
104 104
 					);
105 105
 					echo "\n";
106 106
 				}
107 107
 			}
108
-		} elseif ( 'taxonomy' == $matches[1] ) {
109
-			$terms = get_terms( $matches[2], array(
108
+		} elseif ('taxonomy' == $matches[1]) {
109
+			$terms = get_terms($matches[2], array(
110 110
 				'name__like' => $query,
111 111
 				'number' => 10,
112 112
 			));
113
-			if ( empty( $terms ) || is_wp_error( $terms ) )
113
+			if (empty($terms) || is_wp_error($terms))
114 114
 				return;
115
-			foreach ( (array) $terms as $term ) {
116
-				if ( 'markup' == $response_format ) {
117
-					echo walk_nav_menu_tree( array_map('wp_setup_nav_menu_item', array( $term ) ), 0, (object) $args );
118
-				} elseif ( 'json' == $response_format ) {
115
+			foreach ((array) $terms as $term) {
116
+				if ('markup' == $response_format) {
117
+					echo walk_nav_menu_tree(array_map('wp_setup_nav_menu_item', array($term)), 0, (object) $args);
118
+				} elseif ('json' == $response_format) {
119 119
 					echo wp_json_encode(
120 120
 						array(
121 121
 							'ID' => $term->term_id,
@@ -138,17 +138,17 @@  discard block
 block discarded – undo
138 138
 function wp_nav_menu_setup() {
139 139
 	// Register meta boxes
140 140
 	wp_nav_menu_post_type_meta_boxes();
141
-	add_meta_box( 'add-custom-links', __( 'Custom Links' ), 'wp_nav_menu_item_link_meta_box', 'nav-menus', 'side', 'default' );
141
+	add_meta_box('add-custom-links', __('Custom Links'), 'wp_nav_menu_item_link_meta_box', 'nav-menus', 'side', 'default');
142 142
 	wp_nav_menu_taxonomy_meta_boxes();
143 143
 
144 144
 	// Register advanced menu items (columns)
145
-	add_filter( 'manage_nav-menus_columns', 'wp_nav_menu_manage_columns' );
145
+	add_filter('manage_nav-menus_columns', 'wp_nav_menu_manage_columns');
146 146
 
147 147
 	// If first time editing, disable advanced items by default.
148
-	if ( false === get_user_option( 'managenav-menuscolumnshidden' ) ) {
148
+	if (false === get_user_option('managenav-menuscolumnshidden')) {
149 149
 		$user = wp_get_current_user();
150 150
 		update_user_option($user->ID, 'managenav-menuscolumnshidden',
151
-			array( 0 => 'link-target', 1 => 'css-classes', 2 => 'xfn', 3 => 'description', 4 => 'title-attribute', ),
151
+			array(0 => 'link-target', 1 => 'css-classes', 2 => 'xfn', 3 => 'description', 4 => 'title-attribute',),
152 152
 			true);
153 153
 	}
154 154
 }
@@ -163,17 +163,17 @@  discard block
 block discarded – undo
163 163
 function wp_initial_nav_menu_meta_boxes() {
164 164
 	global $wp_meta_boxes;
165 165
 
166
-	if ( get_user_option( 'metaboxhidden_nav-menus' ) !== false || ! is_array($wp_meta_boxes) )
166
+	if (get_user_option('metaboxhidden_nav-menus') !== false || ! is_array($wp_meta_boxes))
167 167
 		return;
168 168
 
169
-	$initial_meta_boxes = array( 'add-post-type-page', 'add-post-type-post', 'add-custom-links', 'add-category' );
169
+	$initial_meta_boxes = array('add-post-type-page', 'add-post-type-post', 'add-custom-links', 'add-category');
170 170
 	$hidden_meta_boxes = array();
171 171
 
172
-	foreach ( array_keys($wp_meta_boxes['nav-menus']) as $context ) {
173
-		foreach ( array_keys($wp_meta_boxes['nav-menus'][$context]) as $priority ) {
174
-			foreach ( $wp_meta_boxes['nav-menus'][$context][$priority] as $box ) {
175
-				if ( in_array( $box['id'], $initial_meta_boxes ) ) {
176
-					unset( $box['id'] );
172
+	foreach (array_keys($wp_meta_boxes['nav-menus']) as $context) {
173
+		foreach (array_keys($wp_meta_boxes['nav-menus'][$context]) as $priority) {
174
+			foreach ($wp_meta_boxes['nav-menus'][$context][$priority] as $box) {
175
+				if (in_array($box['id'], $initial_meta_boxes)) {
176
+					unset($box['id']);
177 177
 				} else {
178 178
 					$hidden_meta_boxes[] = $box['id'];
179 179
 				}
@@ -182,7 +182,7 @@  discard block
 block discarded – undo
182 182
 	}
183 183
 
184 184
 	$user = wp_get_current_user();
185
-	update_user_option( $user->ID, 'metaboxhidden_nav-menus', $hidden_meta_boxes, true );
185
+	update_user_option($user->ID, 'metaboxhidden_nav-menus', $hidden_meta_boxes, true);
186 186
 }
187 187
 
188 188
 /**
@@ -191,12 +191,12 @@  discard block
 block discarded – undo
191 191
  * @since 3.0.0
192 192
  */
193 193
 function wp_nav_menu_post_type_meta_boxes() {
194
-	$post_types = get_post_types( array( 'show_in_nav_menus' => true ), 'object' );
194
+	$post_types = get_post_types(array('show_in_nav_menus' => true), 'object');
195 195
 
196
-	if ( ! $post_types )
196
+	if ( ! $post_types)
197 197
 		return;
198 198
 
199
-	foreach ( $post_types as $post_type ) {
199
+	foreach ($post_types as $post_type) {
200 200
 		/**
201 201
 		 * Filters whether a menu items meta box will be added for the current
202 202
 		 * object type.
@@ -209,12 +209,12 @@  discard block
 block discarded – undo
209 209
 		 * @param object $meta_box_object The current object to add a menu items
210 210
 		 *                                meta box for.
211 211
 		 */
212
-		$post_type = apply_filters( 'nav_menu_meta_box_object', $post_type );
213
-		if ( $post_type ) {
212
+		$post_type = apply_filters('nav_menu_meta_box_object', $post_type);
213
+		if ($post_type) {
214 214
 			$id = $post_type->name;
215 215
 			// Give pages a higher priority.
216
-			$priority = ( 'page' == $post_type->name ? 'core' : 'default' );
217
-			add_meta_box( "add-post-type-{$id}", $post_type->labels->name, 'wp_nav_menu_item_post_type_meta_box', 'nav-menus', 'side', $priority, $post_type );
216
+			$priority = ('page' == $post_type->name ? 'core' : 'default');
217
+			add_meta_box("add-post-type-{$id}", $post_type->labels->name, 'wp_nav_menu_item_post_type_meta_box', 'nav-menus', 'side', $priority, $post_type);
218 218
 		}
219 219
 	}
220 220
 }
@@ -225,17 +225,17 @@  discard block
 block discarded – undo
225 225
  * @since 3.0.0
226 226
  */
227 227
 function wp_nav_menu_taxonomy_meta_boxes() {
228
-	$taxonomies = get_taxonomies( array( 'show_in_nav_menus' => true ), 'object' );
228
+	$taxonomies = get_taxonomies(array('show_in_nav_menus' => true), 'object');
229 229
 
230
-	if ( !$taxonomies )
230
+	if ( ! $taxonomies)
231 231
 		return;
232 232
 
233
-	foreach ( $taxonomies as $tax ) {
233
+	foreach ($taxonomies as $tax) {
234 234
 		/** This filter is documented in wp-admin/includes/nav-menu.php */
235
-		$tax = apply_filters( 'nav_menu_meta_box_object', $tax );
236
-		if ( $tax ) {
235
+		$tax = apply_filters('nav_menu_meta_box_object', $tax);
236
+		if ($tax) {
237 237
 			$id = $tax->name;
238
-			add_meta_box( "add-{$id}", $tax->labels->name, 'wp_nav_menu_item_taxonomy_meta_box', 'nav-menus', 'side', 'default', $tax );
238
+			add_meta_box("add-{$id}", $tax->labels->name, 'wp_nav_menu_item_taxonomy_meta_box', 'nav-menus', 'side', 'default', $tax);
239 239
 		}
240 240
 	}
241 241
 }
@@ -250,13 +250,13 @@  discard block
 block discarded – undo
250 250
  * @param int|string $nav_menu_selected_id (id, name or slug) of the currently-selected menu
251 251
  * @return string Disabled attribute if at least one menu exists, false if not
252 252
  */
253
-function wp_nav_menu_disabled_check( $nav_menu_selected_id ) {
253
+function wp_nav_menu_disabled_check($nav_menu_selected_id) {
254 254
 	global $one_theme_location_no_menus;
255 255
 
256
-	if ( $one_theme_location_no_menus )
256
+	if ($one_theme_location_no_menus)
257 257
 		return false;
258 258
 
259
-	return disabled( $nav_menu_selected_id, 0 );
259
+	return disabled($nav_menu_selected_id, 0);
260 260
 }
261 261
 
262 262
 /**
@@ -276,18 +276,18 @@  discard block
 block discarded – undo
276 276
 	<div class="customlinkdiv" id="customlinkdiv">
277 277
 		<input type="hidden" value="custom" name="menu-item[<?php echo $_nav_menu_placeholder; ?>][menu-item-type]" />
278 278
 		<p id="menu-item-url-wrap" class="wp-clearfix">
279
-			<label class="howto" for="custom-menu-item-url"><?php _e( 'URL' ); ?></label>
279
+			<label class="howto" for="custom-menu-item-url"><?php _e('URL'); ?></label>
280 280
 			<input id="custom-menu-item-url" name="menu-item[<?php echo $_nav_menu_placeholder; ?>][menu-item-url]" type="text" class="code menu-item-textbox" value="http://" />
281 281
 		</p>
282 282
 
283 283
 		<p id="menu-item-name-wrap" class="wp-clearfix">
284
-			<label class="howto" for="custom-menu-item-name"><?php _e( 'Link Text' ); ?></label>
284
+			<label class="howto" for="custom-menu-item-name"><?php _e('Link Text'); ?></label>
285 285
 			<input id="custom-menu-item-name" name="menu-item[<?php echo $_nav_menu_placeholder; ?>][menu-item-title]" type="text" class="regular-text menu-item-textbox" />
286 286
 		</p>
287 287
 
288 288
 		<p class="button-controls wp-clearfix">
289 289
 			<span class="add-to-menu">
290
-				<input type="submit"<?php wp_nav_menu_disabled_check( $nav_menu_selected_id ); ?> class="button submit-add-to-menu right" value="<?php esc_attr_e('Add to Menu'); ?>" name="add-custom-menu-item" id="submit-customlinkdiv" />
290
+				<input type="submit"<?php wp_nav_menu_disabled_check($nav_menu_selected_id); ?> class="button submit-add-to-menu right" value="<?php esc_attr_e('Add to Menu'); ?>" name="add-custom-menu-item" id="submit-customlinkdiv" />
291 291
 				<span class="spinner"></span>
292 292
 			</span>
293 293
 		</p>
@@ -314,15 +314,15 @@  discard block
 block discarded – undo
314 314
  *     @type WP_Post_Type $args     Extra meta box arguments (the post type object for this meta box).
315 315
  * }
316 316
  */
317
-function wp_nav_menu_item_post_type_meta_box( $object, $box ) {
317
+function wp_nav_menu_item_post_type_meta_box($object, $box) {
318 318
 	global $_nav_menu_placeholder, $nav_menu_selected_id;
319 319
 
320 320
 	$post_type_name = $box['args']->name;
321 321
 
322 322
 	// Paginate browsing for large numbers of post objects.
323 323
 	$per_page = 50;
324
-	$pagenum = isset( $_REQUEST[$post_type_name . '-tab'] ) && isset( $_REQUEST['paged'] ) ? absint( $_REQUEST['paged'] ) : 1;
325
-	$offset = 0 < $pagenum ? $per_page * ( $pagenum - 1 ) : 0;
324
+	$pagenum = isset($_REQUEST[$post_type_name.'-tab']) && isset($_REQUEST['paged']) ? absint($_REQUEST['paged']) : 1;
325
+	$offset = 0 < $pagenum ? $per_page * ($pagenum - 1) : 0;
326 326
 
327 327
 	$args = array(
328 328
 		'offset' => $offset,
@@ -335,49 +335,49 @@  discard block
 block discarded – undo
335 335
 		'update_post_meta_cache' => false
336 336
 	);
337 337
 
338
-	if ( isset( $box['args']->_default_query ) )
339
-		$args = array_merge($args, (array) $box['args']->_default_query );
338
+	if (isset($box['args']->_default_query))
339
+		$args = array_merge($args, (array) $box['args']->_default_query);
340 340
 
341 341
 	// @todo transient caching of these results with proper invalidation on updating of a post of this type
342 342
 	$get_posts = new WP_Query;
343
-	$posts = $get_posts->query( $args );
344
-	if ( ! $get_posts->post_count ) {
345
-		echo '<p>' . __( 'No items.' ) . '</p>';
343
+	$posts = $get_posts->query($args);
344
+	if ( ! $get_posts->post_count) {
345
+		echo '<p>'.__('No items.').'</p>';
346 346
 		return;
347 347
 	}
348 348
 
349 349
 	$num_pages = $get_posts->max_num_pages;
350 350
 
351
-	$page_links = paginate_links( array(
351
+	$page_links = paginate_links(array(
352 352
 		'base' => add_query_arg(
353 353
 			array(
354
-				$post_type_name . '-tab' => 'all',
354
+				$post_type_name.'-tab' => 'all',
355 355
 				'paged' => '%#%',
356 356
 				'item-type' => 'post_type',
357 357
 				'item-object' => $post_type_name,
358 358
 			)
359 359
 		),
360 360
 		'format' => '',
361
-		'prev_text'          => '<span aria-label="' . esc_attr__( 'Previous page' ) . '">' . __( '&laquo;' ) . '</span>',
362
-		'next_text'          => '<span aria-label="' . esc_attr__( 'Next page' ) . '">' . __( '&raquo;' ) . '</span>',
363
-		'before_page_number' => '<span class="screen-reader-text">' . __( 'Page' ) . '</span> ',
361
+		'prev_text'          => '<span aria-label="'.esc_attr__('Previous page').'">'.__('&laquo;').'</span>',
362
+		'next_text'          => '<span aria-label="'.esc_attr__('Next page').'">'.__('&raquo;').'</span>',
363
+		'before_page_number' => '<span class="screen-reader-text">'.__('Page').'</span> ',
364 364
 		'total'   => $num_pages,
365 365
 		'current' => $pagenum
366 366
 	));
367 367
 
368 368
 	$db_fields = false;
369
-	if ( is_post_type_hierarchical( $post_type_name ) ) {
370
-		$db_fields = array( 'parent' => 'post_parent', 'id' => 'ID' );
369
+	if (is_post_type_hierarchical($post_type_name)) {
370
+		$db_fields = array('parent' => 'post_parent', 'id' => 'ID');
371 371
 	}
372 372
 
373
-	$walker = new Walker_Nav_Menu_Checklist( $db_fields );
373
+	$walker = new Walker_Nav_Menu_Checklist($db_fields);
374 374
 
375 375
 	$current_tab = 'most-recent';
376
-	if ( isset( $_REQUEST[$post_type_name . '-tab'] ) && in_array( $_REQUEST[$post_type_name . '-tab'], array('all', 'search') ) ) {
377
-		$current_tab = $_REQUEST[$post_type_name . '-tab'];
376
+	if (isset($_REQUEST[$post_type_name.'-tab']) && in_array($_REQUEST[$post_type_name.'-tab'], array('all', 'search'))) {
377
+		$current_tab = $_REQUEST[$post_type_name.'-tab'];
378 378
 	}
379 379
 
380
-	if ( ! empty( $_REQUEST['quick-search-posttype-' . $post_type_name] ) ) {
380
+	if ( ! empty($_REQUEST['quick-search-posttype-'.$post_type_name])) {
381 381
 		$current_tab = 'search';
382 382
 	}
383 383
 
@@ -393,30 +393,30 @@  discard block
 block discarded – undo
393 393
 	?>
394 394
 	<div id="posttype-<?php echo $post_type_name; ?>" class="posttypediv">
395 395
 		<ul id="posttype-<?php echo $post_type_name; ?>-tabs" class="posttype-tabs add-menu-item-tabs">
396
-			<li <?php echo ( 'most-recent' == $current_tab ? ' class="tabs"' : '' ); ?>>
397
-				<a class="nav-tab-link" data-type="tabs-panel-posttype-<?php echo esc_attr( $post_type_name ); ?>-most-recent" href="<?php if ( $nav_menu_selected_id ) echo esc_url(add_query_arg($post_type_name . '-tab', 'most-recent', remove_query_arg($removed_args))); ?>#tabs-panel-posttype-<?php echo $post_type_name; ?>-most-recent">
398
-					<?php _e( 'Most Recent' ); ?>
396
+			<li <?php echo ('most-recent' == $current_tab ? ' class="tabs"' : ''); ?>>
397
+				<a class="nav-tab-link" data-type="tabs-panel-posttype-<?php echo esc_attr($post_type_name); ?>-most-recent" href="<?php if ($nav_menu_selected_id) echo esc_url(add_query_arg($post_type_name.'-tab', 'most-recent', remove_query_arg($removed_args))); ?>#tabs-panel-posttype-<?php echo $post_type_name; ?>-most-recent">
398
+					<?php _e('Most Recent'); ?>
399 399
 				</a>
400 400
 			</li>
401
-			<li <?php echo ( 'all' == $current_tab ? ' class="tabs"' : '' ); ?>>
402
-				<a class="nav-tab-link" data-type="<?php echo esc_attr( $post_type_name ); ?>-all" href="<?php if ( $nav_menu_selected_id ) echo esc_url(add_query_arg($post_type_name . '-tab', 'all', remove_query_arg($removed_args))); ?>#<?php echo $post_type_name; ?>-all">
403
-					<?php _e( 'View All' ); ?>
401
+			<li <?php echo ('all' == $current_tab ? ' class="tabs"' : ''); ?>>
402
+				<a class="nav-tab-link" data-type="<?php echo esc_attr($post_type_name); ?>-all" href="<?php if ($nav_menu_selected_id) echo esc_url(add_query_arg($post_type_name.'-tab', 'all', remove_query_arg($removed_args))); ?>#<?php echo $post_type_name; ?>-all">
403
+					<?php _e('View All'); ?>
404 404
 				</a>
405 405
 			</li>
406
-			<li <?php echo ( 'search' == $current_tab ? ' class="tabs"' : '' ); ?>>
407
-				<a class="nav-tab-link" data-type="tabs-panel-posttype-<?php echo esc_attr( $post_type_name ); ?>-search" href="<?php if ( $nav_menu_selected_id ) echo esc_url(add_query_arg($post_type_name . '-tab', 'search', remove_query_arg($removed_args))); ?>#tabs-panel-posttype-<?php echo $post_type_name; ?>-search">
408
-					<?php _e( 'Search'); ?>
406
+			<li <?php echo ('search' == $current_tab ? ' class="tabs"' : ''); ?>>
407
+				<a class="nav-tab-link" data-type="tabs-panel-posttype-<?php echo esc_attr($post_type_name); ?>-search" href="<?php if ($nav_menu_selected_id) echo esc_url(add_query_arg($post_type_name.'-tab', 'search', remove_query_arg($removed_args))); ?>#tabs-panel-posttype-<?php echo $post_type_name; ?>-search">
408
+					<?php _e('Search'); ?>
409 409
 				</a>
410 410
 			</li>
411 411
 		</ul><!-- .posttype-tabs -->
412 412
 
413 413
 		<div id="tabs-panel-posttype-<?php echo $post_type_name; ?>-most-recent" class="tabs-panel <?php
414
-			echo ( 'most-recent' == $current_tab ? 'tabs-panel-active' : 'tabs-panel-inactive' );
414
+			echo ('most-recent' == $current_tab ? 'tabs-panel-active' : 'tabs-panel-inactive');
415 415
 		?>">
416 416
 			<ul id="<?php echo $post_type_name; ?>checklist-most-recent" class="categorychecklist form-no-clear">
417 417
 				<?php
418
-				$recent_args = array_merge( $args, array( 'orderby' => 'post_date', 'order' => 'DESC', 'posts_per_page' => 15 ) );
419
-				$most_recent = $get_posts->query( $recent_args );
418
+				$recent_args = array_merge($args, array('orderby' => 'post_date', 'order' => 'DESC', 'posts_per_page' => 15));
419
+				$most_recent = $get_posts->query($recent_args);
420 420
 				$args['walker'] = $walker;
421 421
 
422 422
 				/**
@@ -431,50 +431,50 @@  discard block
 block discarded – undo
431 431
 				 * @param array $args        An array of WP_Query arguments.
432 432
 				 * @param array $box         Arguments passed to wp_nav_menu_item_post_type_meta_box().
433 433
 				 */
434
-				$most_recent = apply_filters( "nav_menu_items_{$post_type_name}_recent", $most_recent, $args, $box );
434
+				$most_recent = apply_filters("nav_menu_items_{$post_type_name}_recent", $most_recent, $args, $box);
435 435
 
436
-				echo walk_nav_menu_tree( array_map('wp_setup_nav_menu_item', $most_recent), 0, (object) $args );
436
+				echo walk_nav_menu_tree(array_map('wp_setup_nav_menu_item', $most_recent), 0, (object) $args);
437 437
 				?>
438 438
 			</ul>
439 439
 		</div><!-- /.tabs-panel -->
440 440
 
441 441
 		<div class="tabs-panel <?php
442
-			echo ( 'search' == $current_tab ? 'tabs-panel-active' : 'tabs-panel-inactive' );
442
+			echo ('search' == $current_tab ? 'tabs-panel-active' : 'tabs-panel-inactive');
443 443
 		?>" id="tabs-panel-posttype-<?php echo $post_type_name; ?>-search">
444 444
 			<?php
445
-			if ( isset( $_REQUEST['quick-search-posttype-' . $post_type_name] ) ) {
446
-				$searched = esc_attr( $_REQUEST['quick-search-posttype-' . $post_type_name] );
447
-				$search_results = get_posts( array( 's' => $searched, 'post_type' => $post_type_name, 'fields' => 'all', 'order' => 'DESC', ) );
445
+			if (isset($_REQUEST['quick-search-posttype-'.$post_type_name])) {
446
+				$searched = esc_attr($_REQUEST['quick-search-posttype-'.$post_type_name]);
447
+				$search_results = get_posts(array('s' => $searched, 'post_type' => $post_type_name, 'fields' => 'all', 'order' => 'DESC',));
448 448
 			} else {
449 449
 				$searched = '';
450 450
 				$search_results = array();
451 451
 			}
452 452
 			?>
453 453
 			<p class="quick-search-wrap">
454
-				<label for="quick-search-posttype-<?php echo $post_type_name; ?>" class="screen-reader-text"><?php _e( 'Search' ); ?></label>
454
+				<label for="quick-search-posttype-<?php echo $post_type_name; ?>" class="screen-reader-text"><?php _e('Search'); ?></label>
455 455
 				<input type="search" class="quick-search" value="<?php echo $searched; ?>" name="quick-search-posttype-<?php echo $post_type_name; ?>" id="quick-search-posttype-<?php echo $post_type_name; ?>" />
456 456
 				<span class="spinner"></span>
457
-				<?php submit_button( __( 'Search' ), 'small quick-search-submit hide-if-js', 'submit', false, array( 'id' => 'submit-quick-search-posttype-' . $post_type_name ) ); ?>
457
+				<?php submit_button(__('Search'), 'small quick-search-submit hide-if-js', 'submit', false, array('id' => 'submit-quick-search-posttype-'.$post_type_name)); ?>
458 458
 			</p>
459 459
 
460 460
 			<ul id="<?php echo $post_type_name; ?>-search-checklist" data-wp-lists="list:<?php echo $post_type_name?>" class="categorychecklist form-no-clear">
461
-			<?php if ( ! empty( $search_results ) && ! is_wp_error( $search_results ) ) : ?>
461
+			<?php if ( ! empty($search_results) && ! is_wp_error($search_results)) : ?>
462 462
 				<?php
463 463
 				$args['walker'] = $walker;
464
-				echo walk_nav_menu_tree( array_map('wp_setup_nav_menu_item', $search_results), 0, (object) $args );
464
+				echo walk_nav_menu_tree(array_map('wp_setup_nav_menu_item', $search_results), 0, (object) $args);
465 465
 				?>
466
-			<?php elseif ( is_wp_error( $search_results ) ) : ?>
466
+			<?php elseif (is_wp_error($search_results)) : ?>
467 467
 				<li><?php echo $search_results->get_error_message(); ?></li>
468
-			<?php elseif ( ! empty( $searched ) ) : ?>
468
+			<?php elseif ( ! empty($searched)) : ?>
469 469
 				<li><?php _e('No results found.'); ?></li>
470 470
 			<?php endif; ?>
471 471
 			</ul>
472 472
 		</div><!-- /.tabs-panel -->
473 473
 
474 474
 		<div id="<?php echo $post_type_name; ?>-all" class="tabs-panel tabs-panel-view-all <?php
475
-			echo ( 'all' == $current_tab ? 'tabs-panel-active' : 'tabs-panel-inactive' );
475
+			echo ('all' == $current_tab ? 'tabs-panel-active' : 'tabs-panel-inactive');
476 476
 		?>">
477
-			<?php if ( ! empty( $page_links ) ) : ?>
477
+			<?php if ( ! empty($page_links)) : ?>
478 478
 				<div class="add-menu-item-pagelinks">
479 479
 					<?php echo $page_links; ?>
480 480
 				</div>
@@ -487,15 +487,15 @@  discard block
 block discarded – undo
487 487
 				 * If we're dealing with pages, let's put a checkbox for the front
488 488
 				 * page at the top of the list.
489 489
 				 */
490
-				if ( 'page' == $post_type_name ) {
491
-					$front_page = 'page' == get_option('show_on_front') ? (int) get_option( 'page_on_front' ) : 0;
492
-					if ( ! empty( $front_page ) ) {
493
-						$front_page_obj = get_post( $front_page );
490
+				if ('page' == $post_type_name) {
491
+					$front_page = 'page' == get_option('show_on_front') ? (int) get_option('page_on_front') : 0;
492
+					if ( ! empty($front_page)) {
493
+						$front_page_obj = get_post($front_page);
494 494
 						$front_page_obj->front_or_home = true;
495
-						array_unshift( $posts, $front_page_obj );
495
+						array_unshift($posts, $front_page_obj);
496 496
 					} else {
497
-						$_nav_menu_placeholder = ( 0 > $_nav_menu_placeholder ) ? intval($_nav_menu_placeholder) - 1 : -1;
498
-						array_unshift( $posts, (object) array(
497
+						$_nav_menu_placeholder = (0 > $_nav_menu_placeholder) ? intval($_nav_menu_placeholder) - 1 : -1;
498
+						array_unshift($posts, (object) array(
499 499
 							'front_or_home' => true,
500 500
 							'ID' => 0,
501 501
 							'object_id' => $_nav_menu_placeholder,
@@ -506,15 +506,15 @@  discard block
 block discarded – undo
506 506
 							'post_type' => 'nav_menu_item',
507 507
 							'type' => 'custom',
508 508
 							'url' => home_url('/'),
509
-						) );
509
+						));
510 510
 					}
511 511
 				}
512 512
 
513
-				$post_type = get_post_type_object( $post_type_name );
513
+				$post_type = get_post_type_object($post_type_name);
514 514
 
515
-				if ( $post_type->has_archive ) {
516
-					$_nav_menu_placeholder = ( 0 > $_nav_menu_placeholder ) ? intval($_nav_menu_placeholder) - 1 : -1;
517
-					array_unshift( $posts, (object) array(
515
+				if ($post_type->has_archive) {
516
+					$_nav_menu_placeholder = (0 > $_nav_menu_placeholder) ? intval($_nav_menu_placeholder) - 1 : -1;
517
+					array_unshift($posts, (object) array(
518 518
 						'ID' => 0,
519 519
 						'object_id' => $_nav_menu_placeholder,
520 520
 						'object'     => $post_type_name,
@@ -523,8 +523,8 @@  discard block
 block discarded – undo
523 523
 						'post_title' => $post_type->labels->archives,
524 524
 						'post_type' => 'nav_menu_item',
525 525
 						'type' => 'post_type_archive',
526
-						'url' => get_post_type_archive_link( $post_type_name ),
527
-					) );
526
+						'url' => get_post_type_archive_link($post_type_name),
527
+					));
528 528
 				}
529 529
 
530 530
 				/**
@@ -543,11 +543,11 @@  discard block
 block discarded – undo
543 543
 				 * @param array        $args      An array of WP_Query arguments.
544 544
 				 * @param WP_Post_Type $post_type The current post type object for this menu item meta box.
545 545
 				 */
546
-				$posts = apply_filters( "nav_menu_items_{$post_type_name}", $posts, $args, $post_type );
546
+				$posts = apply_filters("nav_menu_items_{$post_type_name}", $posts, $args, $post_type);
547 547
 
548
-				$checkbox_items = walk_nav_menu_tree( array_map('wp_setup_nav_menu_item', $posts), 0, (object) $args );
548
+				$checkbox_items = walk_nav_menu_tree(array_map('wp_setup_nav_menu_item', $posts), 0, (object) $args);
549 549
 
550
-				if ( 'all' == $current_tab && ! empty( $_REQUEST['selectall'] ) ) {
550
+				if ('all' == $current_tab && ! empty($_REQUEST['selectall'])) {
551 551
 					$checkbox_items = preg_replace('/(type=(.)checkbox(\2))/', '$1 checked=$2checked$2', $checkbox_items);
552 552
 
553 553
 				}
@@ -555,7 +555,7 @@  discard block
 block discarded – undo
555 555
 				echo $checkbox_items;
556 556
 				?>
557 557
 			</ul>
558
-			<?php if ( ! empty( $page_links ) ) : ?>
558
+			<?php if ( ! empty($page_links)) : ?>
559 559
 				<div class="add-menu-item-pagelinks">
560 560
 					<?php echo $page_links; ?>
561 561
 				</div>
@@ -565,18 +565,18 @@  discard block
 block discarded – undo
565 565
 		<p class="button-controls wp-clearfix">
566 566
 			<span class="list-controls">
567 567
 				<a href="<?php
568
-					echo esc_url( add_query_arg(
568
+					echo esc_url(add_query_arg(
569 569
 						array(
570
-							$post_type_name . '-tab' => 'all',
570
+							$post_type_name.'-tab' => 'all',
571 571
 							'selectall' => 1,
572 572
 						),
573
-						remove_query_arg( $removed_args )
573
+						remove_query_arg($removed_args)
574 574
 					));
575
-				?>#posttype-<?php echo $post_type_name; ?>" class="select-all aria-button-if-js"><?php _e( 'Select All' ); ?></a>
575
+				?>#posttype-<?php echo $post_type_name; ?>" class="select-all aria-button-if-js"><?php _e('Select All'); ?></a>
576 576
 			</span>
577 577
 
578 578
 			<span class="add-to-menu">
579
-				<input type="submit"<?php wp_nav_menu_disabled_check( $nav_menu_selected_id ); ?> class="button submit-add-to-menu right" value="<?php esc_attr_e( 'Add to Menu' ); ?>" name="add-post-type-menu-item" id="<?php echo esc_attr( 'submit-posttype-' . $post_type_name ); ?>" />
579
+				<input type="submit"<?php wp_nav_menu_disabled_check($nav_menu_selected_id); ?> class="button submit-add-to-menu right" value="<?php esc_attr_e('Add to Menu'); ?>" name="add-post-type-menu-item" id="<?php echo esc_attr('submit-posttype-'.$post_type_name); ?>" />
580 580
 				<span class="spinner"></span>
581 581
 			</span>
582 582
 		</p>
@@ -602,14 +602,14 @@  discard block
 block discarded – undo
602 602
  *     @type object $args     Extra meta box arguments (the taxonomy object for this meta box).
603 603
  * }
604 604
  */
605
-function wp_nav_menu_item_taxonomy_meta_box( $object, $box ) {
605
+function wp_nav_menu_item_taxonomy_meta_box($object, $box) {
606 606
 	global $nav_menu_selected_id;
607 607
 	$taxonomy_name = $box['args']->name;
608 608
 
609 609
 	// Paginate browsing for large numbers of objects.
610 610
 	$per_page = 50;
611
-	$pagenum = isset( $_REQUEST[$taxonomy_name . '-tab'] ) && isset( $_REQUEST['paged'] ) ? absint( $_REQUEST['paged'] ) : 1;
612
-	$offset = 0 < $pagenum ? $per_page * ( $pagenum - 1 ) : 0;
611
+	$pagenum = isset($_REQUEST[$taxonomy_name.'-tab']) && isset($_REQUEST['paged']) ? absint($_REQUEST['paged']) : 1;
612
+	$offset = 0 < $pagenum ? $per_page * ($pagenum - 1) : 0;
613 613
 
614 614
 	$args = array(
615 615
 		'child_of' => 0,
@@ -624,45 +624,45 @@  discard block
 block discarded – undo
624 624
 		'pad_counts' => false,
625 625
 	);
626 626
 
627
-	$terms = get_terms( $taxonomy_name, $args );
627
+	$terms = get_terms($taxonomy_name, $args);
628 628
 
629
-	if ( ! $terms || is_wp_error($terms) ) {
630
-		echo '<p>' . __( 'No items.' ) . '</p>';
629
+	if ( ! $terms || is_wp_error($terms)) {
630
+		echo '<p>'.__('No items.').'</p>';
631 631
 		return;
632 632
 	}
633 633
 
634
-	$num_pages = ceil( wp_count_terms( $taxonomy_name , array_merge( $args, array('number' => '', 'offset' => '') ) ) / $per_page );
634
+	$num_pages = ceil(wp_count_terms($taxonomy_name, array_merge($args, array('number' => '', 'offset' => ''))) / $per_page);
635 635
 
636
-	$page_links = paginate_links( array(
636
+	$page_links = paginate_links(array(
637 637
 		'base' => add_query_arg(
638 638
 			array(
639
-				$taxonomy_name . '-tab' => 'all',
639
+				$taxonomy_name.'-tab' => 'all',
640 640
 				'paged' => '%#%',
641 641
 				'item-type' => 'taxonomy',
642 642
 				'item-object' => $taxonomy_name,
643 643
 			)
644 644
 		),
645 645
 		'format' => '',
646
-		'prev_text'          => '<span aria-label="' . esc_attr__( 'Previous page' ) . '">' . __( '&laquo;' ) . '</span>',
647
-		'next_text'          => '<span aria-label="' . esc_attr__( 'Next page' ) . '">' . __( '&raquo;' ) . '</span>',
648
-		'before_page_number' => '<span class="screen-reader-text">' . __( 'Page' ) . '</span> ',
646
+		'prev_text'          => '<span aria-label="'.esc_attr__('Previous page').'">'.__('&laquo;').'</span>',
647
+		'next_text'          => '<span aria-label="'.esc_attr__('Next page').'">'.__('&raquo;').'</span>',
648
+		'before_page_number' => '<span class="screen-reader-text">'.__('Page').'</span> ',
649 649
 		'total'   => $num_pages,
650 650
 		'current' => $pagenum
651 651
 	));
652 652
 
653 653
 	$db_fields = false;
654
-	if ( is_taxonomy_hierarchical( $taxonomy_name ) ) {
655
-		$db_fields = array( 'parent' => 'parent', 'id' => 'term_id' );
654
+	if (is_taxonomy_hierarchical($taxonomy_name)) {
655
+		$db_fields = array('parent' => 'parent', 'id' => 'term_id');
656 656
 	}
657 657
 
658
-	$walker = new Walker_Nav_Menu_Checklist( $db_fields );
658
+	$walker = new Walker_Nav_Menu_Checklist($db_fields);
659 659
 
660 660
 	$current_tab = 'most-used';
661
-	if ( isset( $_REQUEST[$taxonomy_name . '-tab'] ) && in_array( $_REQUEST[$taxonomy_name . '-tab'], array('all', 'most-used', 'search') ) ) {
662
-		$current_tab = $_REQUEST[$taxonomy_name . '-tab'];
661
+	if (isset($_REQUEST[$taxonomy_name.'-tab']) && in_array($_REQUEST[$taxonomy_name.'-tab'], array('all', 'most-used', 'search'))) {
662
+		$current_tab = $_REQUEST[$taxonomy_name.'-tab'];
663 663
 	}
664 664
 
665
-	if ( ! empty( $_REQUEST['quick-search-taxonomy-' . $taxonomy_name] ) ) {
665
+	if ( ! empty($_REQUEST['quick-search-taxonomy-'.$taxonomy_name])) {
666 666
 		$current_tab = 'search';
667 667
 	}
668 668
 
@@ -678,39 +678,39 @@  discard block
 block discarded – undo
678 678
 	?>
679 679
 	<div id="taxonomy-<?php echo $taxonomy_name; ?>" class="taxonomydiv">
680 680
 		<ul id="taxonomy-<?php echo $taxonomy_name; ?>-tabs" class="taxonomy-tabs add-menu-item-tabs">
681
-			<li <?php echo ( 'most-used' == $current_tab ? ' class="tabs"' : '' ); ?>>
682
-				<a class="nav-tab-link" data-type="tabs-panel-<?php echo esc_attr( $taxonomy_name ); ?>-pop" href="<?php if ( $nav_menu_selected_id ) echo esc_url(add_query_arg($taxonomy_name . '-tab', 'most-used', remove_query_arg($removed_args))); ?>#tabs-panel-<?php echo $taxonomy_name; ?>-pop">
683
-					<?php _e( 'Most Used' ); ?>
681
+			<li <?php echo ('most-used' == $current_tab ? ' class="tabs"' : ''); ?>>
682
+				<a class="nav-tab-link" data-type="tabs-panel-<?php echo esc_attr($taxonomy_name); ?>-pop" href="<?php if ($nav_menu_selected_id) echo esc_url(add_query_arg($taxonomy_name.'-tab', 'most-used', remove_query_arg($removed_args))); ?>#tabs-panel-<?php echo $taxonomy_name; ?>-pop">
683
+					<?php _e('Most Used'); ?>
684 684
 				</a>
685 685
 			</li>
686
-			<li <?php echo ( 'all' == $current_tab ? ' class="tabs"' : '' ); ?>>
687
-				<a class="nav-tab-link" data-type="tabs-panel-<?php echo esc_attr( $taxonomy_name ); ?>-all" href="<?php if ( $nav_menu_selected_id ) echo esc_url(add_query_arg($taxonomy_name . '-tab', 'all', remove_query_arg($removed_args))); ?>#tabs-panel-<?php echo $taxonomy_name; ?>-all">
688
-					<?php _e( 'View All' ); ?>
686
+			<li <?php echo ('all' == $current_tab ? ' class="tabs"' : ''); ?>>
687
+				<a class="nav-tab-link" data-type="tabs-panel-<?php echo esc_attr($taxonomy_name); ?>-all" href="<?php if ($nav_menu_selected_id) echo esc_url(add_query_arg($taxonomy_name.'-tab', 'all', remove_query_arg($removed_args))); ?>#tabs-panel-<?php echo $taxonomy_name; ?>-all">
688
+					<?php _e('View All'); ?>
689 689
 				</a>
690 690
 			</li>
691
-			<li <?php echo ( 'search' == $current_tab ? ' class="tabs"' : '' ); ?>>
692
-				<a class="nav-tab-link" data-type="tabs-panel-search-taxonomy-<?php echo esc_attr( $taxonomy_name ); ?>" href="<?php if ( $nav_menu_selected_id ) echo esc_url(add_query_arg($taxonomy_name . '-tab', 'search', remove_query_arg($removed_args))); ?>#tabs-panel-search-taxonomy-<?php echo $taxonomy_name; ?>">
693
-					<?php _e( 'Search' ); ?>
691
+			<li <?php echo ('search' == $current_tab ? ' class="tabs"' : ''); ?>>
692
+				<a class="nav-tab-link" data-type="tabs-panel-search-taxonomy-<?php echo esc_attr($taxonomy_name); ?>" href="<?php if ($nav_menu_selected_id) echo esc_url(add_query_arg($taxonomy_name.'-tab', 'search', remove_query_arg($removed_args))); ?>#tabs-panel-search-taxonomy-<?php echo $taxonomy_name; ?>">
693
+					<?php _e('Search'); ?>
694 694
 				</a>
695 695
 			</li>
696 696
 		</ul><!-- .taxonomy-tabs -->
697 697
 
698 698
 		<div id="tabs-panel-<?php echo $taxonomy_name; ?>-pop" class="tabs-panel <?php
699
-			echo ( 'most-used' == $current_tab ? 'tabs-panel-active' : 'tabs-panel-inactive' );
699
+			echo ('most-used' == $current_tab ? 'tabs-panel-active' : 'tabs-panel-inactive');
700 700
 		?>">
701 701
 			<ul id="<?php echo $taxonomy_name; ?>checklist-pop" class="categorychecklist form-no-clear" >
702 702
 				<?php
703
-				$popular_terms = get_terms( $taxonomy_name, array( 'orderby' => 'count', 'order' => 'DESC', 'number' => 10, 'hierarchical' => false ) );
703
+				$popular_terms = get_terms($taxonomy_name, array('orderby' => 'count', 'order' => 'DESC', 'number' => 10, 'hierarchical' => false));
704 704
 				$args['walker'] = $walker;
705
-				echo walk_nav_menu_tree( array_map('wp_setup_nav_menu_item', $popular_terms), 0, (object) $args );
705
+				echo walk_nav_menu_tree(array_map('wp_setup_nav_menu_item', $popular_terms), 0, (object) $args);
706 706
 				?>
707 707
 			</ul>
708 708
 		</div><!-- /.tabs-panel -->
709 709
 
710 710
 		<div id="tabs-panel-<?php echo $taxonomy_name; ?>-all" class="tabs-panel tabs-panel-view-all <?php
711
-			echo ( 'all' == $current_tab ? 'tabs-panel-active' : 'tabs-panel-inactive' );
711
+			echo ('all' == $current_tab ? 'tabs-panel-active' : 'tabs-panel-inactive');
712 712
 		?>">
713
-			<?php if ( ! empty( $page_links ) ) : ?>
713
+			<?php if ( ! empty($page_links)) : ?>
714 714
 				<div class="add-menu-item-pagelinks">
715 715
 					<?php echo $page_links; ?>
716 716
 				</div>
@@ -718,10 +718,10 @@  discard block
 block discarded – undo
718 718
 			<ul id="<?php echo $taxonomy_name; ?>checklist" data-wp-lists="list:<?php echo $taxonomy_name?>" class="categorychecklist form-no-clear">
719 719
 				<?php
720 720
 				$args['walker'] = $walker;
721
-				echo walk_nav_menu_tree( array_map('wp_setup_nav_menu_item', $terms), 0, (object) $args );
721
+				echo walk_nav_menu_tree(array_map('wp_setup_nav_menu_item', $terms), 0, (object) $args);
722 722
 				?>
723 723
 			</ul>
724
-			<?php if ( ! empty( $page_links ) ) : ?>
724
+			<?php if ( ! empty($page_links)) : ?>
725 725
 				<div class="add-menu-item-pagelinks">
726 726
 					<?php echo $page_links; ?>
727 727
 				</div>
@@ -729,33 +729,33 @@  discard block
 block discarded – undo
729 729
 		</div><!-- /.tabs-panel -->
730 730
 
731 731
 		<div class="tabs-panel <?php
732
-			echo ( 'search' == $current_tab ? 'tabs-panel-active' : 'tabs-panel-inactive' );
732
+			echo ('search' == $current_tab ? 'tabs-panel-active' : 'tabs-panel-inactive');
733 733
 		?>" id="tabs-panel-search-taxonomy-<?php echo $taxonomy_name; ?>">
734 734
 			<?php
735
-			if ( isset( $_REQUEST['quick-search-taxonomy-' . $taxonomy_name] ) ) {
736
-				$searched = esc_attr( $_REQUEST['quick-search-taxonomy-' . $taxonomy_name] );
737
-				$search_results = get_terms( $taxonomy_name, array( 'name__like' => $searched, 'fields' => 'all', 'orderby' => 'count', 'order' => 'DESC', 'hierarchical' => false ) );
735
+			if (isset($_REQUEST['quick-search-taxonomy-'.$taxonomy_name])) {
736
+				$searched = esc_attr($_REQUEST['quick-search-taxonomy-'.$taxonomy_name]);
737
+				$search_results = get_terms($taxonomy_name, array('name__like' => $searched, 'fields' => 'all', 'orderby' => 'count', 'order' => 'DESC', 'hierarchical' => false));
738 738
 			} else {
739 739
 				$searched = '';
740 740
 				$search_results = array();
741 741
 			}
742 742
 			?>
743 743
 			<p class="quick-search-wrap">
744
-				<label for="quick-search-taxonomy-<?php echo $taxonomy_name; ?>" class="screen-reader-text"><?php _e( 'Search' ); ?></label>
744
+				<label for="quick-search-taxonomy-<?php echo $taxonomy_name; ?>" class="screen-reader-text"><?php _e('Search'); ?></label>
745 745
 				<input type="search" class="quick-search" value="<?php echo $searched; ?>" name="quick-search-taxonomy-<?php echo $taxonomy_name; ?>" id="quick-search-taxonomy-<?php echo $taxonomy_name; ?>" />
746 746
 				<span class="spinner"></span>
747
-				<?php submit_button( __( 'Search' ), 'small quick-search-submit hide-if-js', 'submit', false, array( 'id' => 'submit-quick-search-taxonomy-' . $taxonomy_name ) ); ?>
747
+				<?php submit_button(__('Search'), 'small quick-search-submit hide-if-js', 'submit', false, array('id' => 'submit-quick-search-taxonomy-'.$taxonomy_name)); ?>
748 748
 			</p>
749 749
 
750 750
 			<ul id="<?php echo $taxonomy_name; ?>-search-checklist" data-wp-lists="list:<?php echo $taxonomy_name?>" class="categorychecklist form-no-clear">
751
-			<?php if ( ! empty( $search_results ) && ! is_wp_error( $search_results ) ) : ?>
751
+			<?php if ( ! empty($search_results) && ! is_wp_error($search_results)) : ?>
752 752
 				<?php
753 753
 				$args['walker'] = $walker;
754
-				echo walk_nav_menu_tree( array_map('wp_setup_nav_menu_item', $search_results), 0, (object) $args );
754
+				echo walk_nav_menu_tree(array_map('wp_setup_nav_menu_item', $search_results), 0, (object) $args);
755 755
 				?>
756
-			<?php elseif ( is_wp_error( $search_results ) ) : ?>
756
+			<?php elseif (is_wp_error($search_results)) : ?>
757 757
 				<li><?php echo $search_results->get_error_message(); ?></li>
758
-			<?php elseif ( ! empty( $searched ) ) : ?>
758
+			<?php elseif ( ! empty($searched)) : ?>
759 759
 				<li><?php _e('No results found.'); ?></li>
760 760
 			<?php endif; ?>
761 761
 			</ul>
@@ -766,16 +766,16 @@  discard block
 block discarded – undo
766 766
 				<a href="<?php
767 767
 					echo esc_url(add_query_arg(
768 768
 						array(
769
-							$taxonomy_name . '-tab' => 'all',
769
+							$taxonomy_name.'-tab' => 'all',
770 770
 							'selectall' => 1,
771 771
 						),
772 772
 						remove_query_arg($removed_args)
773 773
 					));
774
-				?>#taxonomy-<?php echo $taxonomy_name; ?>" class="select-all aria-button-if-js"><?php _e( 'Select All' ); ?></a>
774
+				?>#taxonomy-<?php echo $taxonomy_name; ?>" class="select-all aria-button-if-js"><?php _e('Select All'); ?></a>
775 775
 			</span>
776 776
 
777 777
 			<span class="add-to-menu">
778
-				<input type="submit"<?php wp_nav_menu_disabled_check( $nav_menu_selected_id ); ?> class="button submit-add-to-menu right" value="<?php esc_attr_e( 'Add to Menu' ); ?>" name="add-taxonomy-menu-item" id="<?php echo esc_attr( 'submit-taxonomy-' . $taxonomy_name ); ?>" />
778
+				<input type="submit"<?php wp_nav_menu_disabled_check($nav_menu_selected_id); ?> class="button submit-add-to-menu right" value="<?php esc_attr_e('Add to Menu'); ?>" name="add-taxonomy-menu-item" id="<?php echo esc_attr('submit-taxonomy-'.$taxonomy_name); ?>" />
779 779
 				<span class="spinner"></span>
780 780
 			</span>
781 781
 		</p>
@@ -793,25 +793,25 @@  discard block
 block discarded – undo
793 793
  * @param array $menu_data The unsanitized posted menu item data.
794 794
  * @return array The database IDs of the items saved
795 795
  */
796
-function wp_save_nav_menu_items( $menu_id = 0, $menu_data = array() ) {
796
+function wp_save_nav_menu_items($menu_id = 0, $menu_data = array()) {
797 797
 	$menu_id = (int) $menu_id;
798 798
 	$items_saved = array();
799 799
 
800
-	if ( 0 == $menu_id || is_nav_menu( $menu_id ) ) {
800
+	if (0 == $menu_id || is_nav_menu($menu_id)) {
801 801
 
802 802
 		// Loop through all the menu items' POST values.
803
-		foreach ( (array) $menu_data as $_possible_db_id => $_item_object_data ) {
803
+		foreach ((array) $menu_data as $_possible_db_id => $_item_object_data) {
804 804
 			if (
805 805
 				// Checkbox is not checked.
806
-				empty( $_item_object_data['menu-item-object-id'] ) &&
806
+				empty($_item_object_data['menu-item-object-id']) &&
807 807
 				(
808 808
 					// And item type either isn't set.
809
-					! isset( $_item_object_data['menu-item-type'] ) ||
809
+					! isset($_item_object_data['menu-item-type']) ||
810 810
 					// Or URL is the default.
811
-					in_array( $_item_object_data['menu-item-url'], array( 'http://', '' ) ) ||
812
-					! ( 'custom' == $_item_object_data['menu-item-type'] && ! isset( $_item_object_data['menu-item-db-id'] ) ) || // or it's not a custom menu item (but not the custom home page)
811
+					in_array($_item_object_data['menu-item-url'], array('http://', '')) ||
812
+					! ('custom' == $_item_object_data['menu-item-type'] && ! isset($_item_object_data['menu-item-db-id'])) || // or it's not a custom menu item (but not the custom home page)
813 813
 					// Or it *is* a custom menu item that already exists.
814
-					! empty( $_item_object_data['menu-item-db-id'] )
814
+					! empty($_item_object_data['menu-item-db-id'])
815 815
 				)
816 816
 			) {
817 817
 				// Then this potential menu item is not getting added to this menu.
@@ -820,8 +820,8 @@  discard block
 block discarded – undo
820 820
 
821 821
 			// If this possible menu item doesn't actually have a menu database ID yet.
822 822
 			if (
823
-				empty( $_item_object_data['menu-item-db-id'] ) ||
824
-				( 0 > $_possible_db_id ) ||
823
+				empty($_item_object_data['menu-item-db-id']) ||
824
+				(0 > $_possible_db_id) ||
825 825
 				$_possible_db_id != $_item_object_data['menu-item-db-id']
826 826
 			) {
827 827
 				$_actual_db_id = 0;
@@ -830,22 +830,22 @@  discard block
 block discarded – undo
830 830
 			}
831 831
 
832 832
 			$args = array(
833
-				'menu-item-db-id' => ( isset( $_item_object_data['menu-item-db-id'] ) ? $_item_object_data['menu-item-db-id'] : '' ),
834
-				'menu-item-object-id' => ( isset( $_item_object_data['menu-item-object-id'] ) ? $_item_object_data['menu-item-object-id'] : '' ),
835
-				'menu-item-object' => ( isset( $_item_object_data['menu-item-object'] ) ? $_item_object_data['menu-item-object'] : '' ),
836
-				'menu-item-parent-id' => ( isset( $_item_object_data['menu-item-parent-id'] ) ? $_item_object_data['menu-item-parent-id'] : '' ),
837
-				'menu-item-position' => ( isset( $_item_object_data['menu-item-position'] ) ? $_item_object_data['menu-item-position'] : '' ),
838
-				'menu-item-type' => ( isset( $_item_object_data['menu-item-type'] ) ? $_item_object_data['menu-item-type'] : '' ),
839
-				'menu-item-title' => ( isset( $_item_object_data['menu-item-title'] ) ? $_item_object_data['menu-item-title'] : '' ),
840
-				'menu-item-url' => ( isset( $_item_object_data['menu-item-url'] ) ? $_item_object_data['menu-item-url'] : '' ),
841
-				'menu-item-description' => ( isset( $_item_object_data['menu-item-description'] ) ? $_item_object_data['menu-item-description'] : '' ),
842
-				'menu-item-attr-title' => ( isset( $_item_object_data['menu-item-attr-title'] ) ? $_item_object_data['menu-item-attr-title'] : '' ),
843
-				'menu-item-target' => ( isset( $_item_object_data['menu-item-target'] ) ? $_item_object_data['menu-item-target'] : '' ),
844
-				'menu-item-classes' => ( isset( $_item_object_data['menu-item-classes'] ) ? $_item_object_data['menu-item-classes'] : '' ),
845
-				'menu-item-xfn' => ( isset( $_item_object_data['menu-item-xfn'] ) ? $_item_object_data['menu-item-xfn'] : '' ),
833
+				'menu-item-db-id' => (isset($_item_object_data['menu-item-db-id']) ? $_item_object_data['menu-item-db-id'] : ''),
834
+				'menu-item-object-id' => (isset($_item_object_data['menu-item-object-id']) ? $_item_object_data['menu-item-object-id'] : ''),
835
+				'menu-item-object' => (isset($_item_object_data['menu-item-object']) ? $_item_object_data['menu-item-object'] : ''),
836
+				'menu-item-parent-id' => (isset($_item_object_data['menu-item-parent-id']) ? $_item_object_data['menu-item-parent-id'] : ''),
837
+				'menu-item-position' => (isset($_item_object_data['menu-item-position']) ? $_item_object_data['menu-item-position'] : ''),
838
+				'menu-item-type' => (isset($_item_object_data['menu-item-type']) ? $_item_object_data['menu-item-type'] : ''),
839
+				'menu-item-title' => (isset($_item_object_data['menu-item-title']) ? $_item_object_data['menu-item-title'] : ''),
840
+				'menu-item-url' => (isset($_item_object_data['menu-item-url']) ? $_item_object_data['menu-item-url'] : ''),
841
+				'menu-item-description' => (isset($_item_object_data['menu-item-description']) ? $_item_object_data['menu-item-description'] : ''),
842
+				'menu-item-attr-title' => (isset($_item_object_data['menu-item-attr-title']) ? $_item_object_data['menu-item-attr-title'] : ''),
843
+				'menu-item-target' => (isset($_item_object_data['menu-item-target']) ? $_item_object_data['menu-item-target'] : ''),
844
+				'menu-item-classes' => (isset($_item_object_data['menu-item-classes']) ? $_item_object_data['menu-item-classes'] : ''),
845
+				'menu-item-xfn' => (isset($_item_object_data['menu-item-xfn']) ? $_item_object_data['menu-item-xfn'] : ''),
846 846
 			);
847 847
 
848
-			$items_saved[] = wp_update_nav_menu_item( $menu_id, $_actual_db_id, $args );
848
+			$items_saved[] = wp_update_nav_menu_item($menu_id, $_actual_db_id, $args);
849 849
 
850 850
 		}
851 851
 	}
@@ -862,23 +862,23 @@  discard block
 block discarded – undo
862 862
  * @param object $object The post type or taxonomy meta-object.
863 863
  * @return object The post type of taxonomy object.
864 864
  */
865
-function _wp_nav_menu_meta_box_object( $object = null ) {
866
-	if ( isset( $object->name ) ) {
865
+function _wp_nav_menu_meta_box_object($object = null) {
866
+	if (isset($object->name)) {
867 867
 
868
-		if ( 'page' == $object->name ) {
868
+		if ('page' == $object->name) {
869 869
 			$object->_default_query = array(
870 870
 				'orderby' => 'menu_order title',
871 871
 				'post_status' => 'publish',
872 872
 			);
873 873
 
874 874
 		// Posts should show only published items.
875
-		} elseif ( 'post' == $object->name ) {
875
+		} elseif ('post' == $object->name) {
876 876
 			$object->_default_query = array(
877 877
 				'post_status' => 'publish',
878 878
 			);
879 879
 
880 880
 		// Categories should be in reverse chronological order.
881
-		} elseif ( 'category' == $object->name ) {
881
+		} elseif ('category' == $object->name) {
882 882
 			$object->_default_query = array(
883 883
 				'orderby' => 'id',
884 884
 				'order' => 'DESC',
@@ -903,19 +903,19 @@  discard block
 block discarded – undo
903 903
  * @param int $menu_id Optional. The ID of the menu to format. Default 0.
904 904
  * @return string|WP_Error $output The menu formatted to edit or error object on failure.
905 905
  */
906
-function wp_get_nav_menu_to_edit( $menu_id = 0 ) {
907
-	$menu = wp_get_nav_menu_object( $menu_id );
906
+function wp_get_nav_menu_to_edit($menu_id = 0) {
907
+	$menu = wp_get_nav_menu_object($menu_id);
908 908
 
909 909
 	// If the menu exists, get its items.
910
-	if ( is_nav_menu( $menu ) ) {
911
-		$menu_items = wp_get_nav_menu_items( $menu->term_id, array('post_status' => 'any') );
910
+	if (is_nav_menu($menu)) {
911
+		$menu_items = wp_get_nav_menu_items($menu->term_id, array('post_status' => 'any'));
912 912
 		$result = '<div id="menu-instructions" class="post-body-plain';
913
-		$result .= ( ! empty($menu_items) ) ? ' menu-instructions-inactive">' : '">';
914
-		$result .= '<p>' . __( 'Add menu items from the column on the left.' ) . '</p>';
913
+		$result .= ( ! empty($menu_items)) ? ' menu-instructions-inactive">' : '">';
914
+		$result .= '<p>'.__('Add menu items from the column on the left.').'</p>';
915 915
 		$result .= '</div>';
916 916
 
917
-		if ( empty($menu_items) )
918
-			return $result . ' <ul class="menu" id="menu-to-edit"> </ul>';
917
+		if (empty($menu_items))
918
+			return $result.' <ul class="menu" id="menu-to-edit"> </ul>';
919 919
 
920 920
 		/**
921 921
 		 * Filters the Walker class used when adding nav menu items.
@@ -925,40 +925,40 @@  discard block
 block discarded – undo
925 925
 		 * @param string $class   The walker class to use. Default 'Walker_Nav_Menu_Edit'.
926 926
 		 * @param int    $menu_id ID of the menu being rendered.
927 927
 		 */
928
-		$walker_class_name = apply_filters( 'wp_edit_nav_menu_walker', 'Walker_Nav_Menu_Edit', $menu_id );
928
+		$walker_class_name = apply_filters('wp_edit_nav_menu_walker', 'Walker_Nav_Menu_Edit', $menu_id);
929 929
 
930
-		if ( class_exists( $walker_class_name ) ) {
930
+		if (class_exists($walker_class_name)) {
931 931
 			$walker = new $walker_class_name;
932 932
 		} else {
933
-			return new WP_Error( 'menu_walker_not_exist',
933
+			return new WP_Error('menu_walker_not_exist',
934 934
 				/* translators: %s: walker class name */
935
-				sprintf( __( 'The Walker class named %s does not exist.' ),
936
-					'<strong>' . $walker_class_name . '</strong>'
935
+				sprintf(__('The Walker class named %s does not exist.'),
936
+					'<strong>'.$walker_class_name.'</strong>'
937 937
 				)
938 938
 			);
939 939
 		}
940 940
 
941 941
 		$some_pending_menu_items = $some_invalid_menu_items = false;
942
-		foreach ( (array) $menu_items as $menu_item ) {
943
-			if ( isset( $menu_item->post_status ) && 'draft' == $menu_item->post_status )
942
+		foreach ((array) $menu_items as $menu_item) {
943
+			if (isset($menu_item->post_status) && 'draft' == $menu_item->post_status)
944 944
 				$some_pending_menu_items = true;
945
-			if ( ! empty( $menu_item->_invalid ) )
945
+			if ( ! empty($menu_item->_invalid))
946 946
 				$some_invalid_menu_items = true;
947 947
 		}
948 948
 
949
-		if ( $some_pending_menu_items ) {
950
-			$result .= '<div class="notice notice-info notice-alt inline"><p>' . __( 'Click Save Menu to make pending menu items public.' ) . '</p></div>';
949
+		if ($some_pending_menu_items) {
950
+			$result .= '<div class="notice notice-info notice-alt inline"><p>'.__('Click Save Menu to make pending menu items public.').'</p></div>';
951 951
 		}
952 952
 
953
-		if ( $some_invalid_menu_items ) {
954
-			$result .= '<div class="notice notice-error notice-alt inline"><p>' . __( 'There are some invalid menu items. Please check or delete them.' ) . '</p></div>';
953
+		if ($some_invalid_menu_items) {
954
+			$result .= '<div class="notice notice-error notice-alt inline"><p>'.__('There are some invalid menu items. Please check or delete them.').'</p></div>';
955 955
 		}
956 956
 
957 957
 		$result .= '<ul class="menu" id="menu-to-edit"> ';
958
-		$result .= walk_nav_menu_tree( array_map('wp_setup_nav_menu_item', $menu_items), 0, (object) array('walker' => $walker ) );
958
+		$result .= walk_nav_menu_tree(array_map('wp_setup_nav_menu_item', $menu_items), 0, (object) array('walker' => $walker));
959 959
 		$result .= ' </ul> ';
960 960
 		return $result;
961
-	} elseif ( is_wp_error( $menu ) ) {
961
+	} elseif (is_wp_error($menu)) {
962 962
 		return $menu;
963 963
 	}
964 964
 
@@ -973,13 +973,13 @@  discard block
 block discarded – undo
973 973
  */
974 974
 function wp_nav_menu_manage_columns() {
975 975
 	return array(
976
-		'_title'          => __( 'Show advanced menu properties' ),
976
+		'_title'          => __('Show advanced menu properties'),
977 977
 		'cb'              => '<input type="checkbox" />',
978
-		'link-target'     => __( 'Link Target' ),
979
-		'title-attribute' => __( 'Title Attribute' ),
980
-		'css-classes'     => __( 'CSS Classes' ),
981
-		'xfn'             => __( 'Link Relationship (XFN)' ),
982
-		'description'     => __( 'Description' ),
978
+		'link-target'     => __('Link Target'),
979
+		'title-attribute' => __('Title Attribute'),
980
+		'css-classes'     => __('CSS Classes'),
981
+		'xfn'             => __('Link Relationship (XFN)'),
982
+		'description'     => __('Description'),
983 983
 	);
984 984
 }
985 985
 
@@ -993,13 +993,13 @@  discard block
 block discarded – undo
993 993
  */
994 994
 function _wp_delete_orphaned_draft_menu_items() {
995 995
 	global $wpdb;
996
-	$delete_timestamp = time() - ( DAY_IN_SECONDS * EMPTY_TRASH_DAYS );
996
+	$delete_timestamp = time() - (DAY_IN_SECONDS * EMPTY_TRASH_DAYS);
997 997
 
998 998
 	// Delete orphaned draft menu items.
999
-	$menu_items_to_delete = $wpdb->get_col($wpdb->prepare("SELECT ID FROM $wpdb->posts AS p LEFT JOIN $wpdb->postmeta AS m ON p.ID = m.post_id WHERE post_type = 'nav_menu_item' AND post_status = 'draft' AND meta_key = '_menu_item_orphaned' AND meta_value < '%d'", $delete_timestamp ) );
999
+	$menu_items_to_delete = $wpdb->get_col($wpdb->prepare("SELECT ID FROM $wpdb->posts AS p LEFT JOIN $wpdb->postmeta AS m ON p.ID = m.post_id WHERE post_type = 'nav_menu_item' AND post_status = 'draft' AND meta_key = '_menu_item_orphaned' AND meta_value < '%d'", $delete_timestamp));
1000 1000
 
1001
-	foreach ( (array) $menu_items_to_delete as $menu_item_id )
1002
-		wp_delete_post( $menu_item_id, true );
1001
+	foreach ((array) $menu_items_to_delete as $menu_item_id)
1002
+		wp_delete_post($menu_item_id, true);
1003 1003
 }
1004 1004
 
1005 1005
 /**
@@ -1011,12 +1011,12 @@  discard block
 block discarded – undo
1011 1011
  * @param string $nav_menu_selected_title Title of the currently-selected menu
1012 1012
  * @return array $messages The menu updated message
1013 1013
  */
1014
-function wp_nav_menu_update_menu_items ( $nav_menu_selected_id, $nav_menu_selected_title ) {
1015
-	$unsorted_menu_items = wp_get_nav_menu_items( $nav_menu_selected_id, array( 'orderby' => 'ID', 'output' => ARRAY_A, 'output_key' => 'ID', 'post_status' => 'draft,publish' ) );
1014
+function wp_nav_menu_update_menu_items($nav_menu_selected_id, $nav_menu_selected_title) {
1015
+	$unsorted_menu_items = wp_get_nav_menu_items($nav_menu_selected_id, array('orderby' => 'ID', 'output' => ARRAY_A, 'output_key' => 'ID', 'post_status' => 'draft,publish'));
1016 1016
 	$messages = array();
1017 1017
 	$menu_items = array();
1018 1018
 	// Index menu items by db ID
1019
-	foreach ( $unsorted_menu_items as $_item )
1019
+	foreach ($unsorted_menu_items as $_item)
1020 1020
 		$menu_items[$_item->db_id] = $_item;
1021 1021
 
1022 1022
 	$post_fields = array(
@@ -1026,66 +1026,66 @@  discard block
 block discarded – undo
1026 1026
 		'menu-item-attr-title', 'menu-item-target', 'menu-item-classes', 'menu-item-xfn'
1027 1027
 	);
1028 1028
 
1029
-	wp_defer_term_counting( true );
1029
+	wp_defer_term_counting(true);
1030 1030
 	// Loop through all the menu items' POST variables
1031
-	if ( ! empty( $_POST['menu-item-db-id'] ) ) {
1032
-		foreach ( (array) $_POST['menu-item-db-id'] as $_key => $k ) {
1031
+	if ( ! empty($_POST['menu-item-db-id'])) {
1032
+		foreach ((array) $_POST['menu-item-db-id'] as $_key => $k) {
1033 1033
 
1034 1034
 			// Menu item title can't be blank
1035
-			if ( ! isset( $_POST['menu-item-title'][ $_key ] ) || '' == $_POST['menu-item-title'][ $_key ] )
1035
+			if ( ! isset($_POST['menu-item-title'][$_key]) || '' == $_POST['menu-item-title'][$_key])
1036 1036
 				continue;
1037 1037
 
1038 1038
 			$args = array();
1039
-			foreach ( $post_fields as $field )
1040
-				$args[$field] = isset( $_POST[$field][$_key] ) ? $_POST[$field][$_key] : '';
1039
+			foreach ($post_fields as $field)
1040
+				$args[$field] = isset($_POST[$field][$_key]) ? $_POST[$field][$_key] : '';
1041 1041
 
1042
-			$menu_item_db_id = wp_update_nav_menu_item( $nav_menu_selected_id, ( $_POST['menu-item-db-id'][$_key] != $_key ? 0 : $_key ), $args );
1042
+			$menu_item_db_id = wp_update_nav_menu_item($nav_menu_selected_id, ($_POST['menu-item-db-id'][$_key] != $_key ? 0 : $_key), $args);
1043 1043
 
1044
-			if ( is_wp_error( $menu_item_db_id ) ) {
1045
-				$messages[] = '<div id="message" class="error"><p>' . $menu_item_db_id->get_error_message() . '</p></div>';
1044
+			if (is_wp_error($menu_item_db_id)) {
1045
+				$messages[] = '<div id="message" class="error"><p>'.$menu_item_db_id->get_error_message().'</p></div>';
1046 1046
 			} else {
1047
-				unset( $menu_items[ $menu_item_db_id ] );
1047
+				unset($menu_items[$menu_item_db_id]);
1048 1048
 			}
1049 1049
 		}
1050 1050
 	}
1051 1051
 
1052 1052
 	// Remove menu items from the menu that weren't in $_POST
1053
-	if ( ! empty( $menu_items ) ) {
1054
-		foreach ( array_keys( $menu_items ) as $menu_item_id ) {
1055
-			if ( is_nav_menu_item( $menu_item_id ) ) {
1056
-				wp_delete_post( $menu_item_id );
1053
+	if ( ! empty($menu_items)) {
1054
+		foreach (array_keys($menu_items) as $menu_item_id) {
1055
+			if (is_nav_menu_item($menu_item_id)) {
1056
+				wp_delete_post($menu_item_id);
1057 1057
 			}
1058 1058
 		}
1059 1059
 	}
1060 1060
 
1061 1061
 	// Store 'auto-add' pages.
1062
-	$auto_add = ! empty( $_POST['auto-add-pages'] );
1063
-	$nav_menu_option = (array) get_option( 'nav_menu_options' );
1064
-	if ( ! isset( $nav_menu_option['auto_add'] ) )
1062
+	$auto_add = ! empty($_POST['auto-add-pages']);
1063
+	$nav_menu_option = (array) get_option('nav_menu_options');
1064
+	if ( ! isset($nav_menu_option['auto_add']))
1065 1065
 		$nav_menu_option['auto_add'] = array();
1066
-	if ( $auto_add ) {
1067
-		if ( ! in_array( $nav_menu_selected_id, $nav_menu_option['auto_add'] ) )
1066
+	if ($auto_add) {
1067
+		if ( ! in_array($nav_menu_selected_id, $nav_menu_option['auto_add']))
1068 1068
 			$nav_menu_option['auto_add'][] = $nav_menu_selected_id;
1069 1069
 	} else {
1070
-		if ( false !== ( $key = array_search( $nav_menu_selected_id, $nav_menu_option['auto_add'] ) ) )
1071
-			unset( $nav_menu_option['auto_add'][$key] );
1070
+		if (false !== ($key = array_search($nav_menu_selected_id, $nav_menu_option['auto_add'])))
1071
+			unset($nav_menu_option['auto_add'][$key]);
1072 1072
 	}
1073 1073
 	// Remove nonexistent/deleted menus
1074
-	$nav_menu_option['auto_add'] = array_intersect( $nav_menu_option['auto_add'], wp_get_nav_menus( array( 'fields' => 'ids' ) ) );
1075
-	update_option( 'nav_menu_options', $nav_menu_option );
1074
+	$nav_menu_option['auto_add'] = array_intersect($nav_menu_option['auto_add'], wp_get_nav_menus(array('fields' => 'ids')));
1075
+	update_option('nav_menu_options', $nav_menu_option);
1076 1076
 
1077
-	wp_defer_term_counting( false );
1077
+	wp_defer_term_counting(false);
1078 1078
 
1079 1079
 	/** This action is documented in wp-includes/nav-menu.php */
1080
-	do_action( 'wp_update_nav_menu', $nav_menu_selected_id );
1080
+	do_action('wp_update_nav_menu', $nav_menu_selected_id);
1081 1081
 
1082
-	$messages[] = '<div id="message" class="updated notice is-dismissible"><p>' .
1082
+	$messages[] = '<div id="message" class="updated notice is-dismissible"><p>'.
1083 1083
 		/* translators: %s: nav menu title */
1084
-		sprintf( __( '%s has been updated.' ),
1085
-			'<strong>' . $nav_menu_selected_title . '</strong>'
1086
-		) . '</p></div>';
1084
+		sprintf(__('%s has been updated.'),
1085
+			'<strong>'.$nav_menu_selected_title.'</strong>'
1086
+		).'</p></div>';
1087 1087
 
1088
-	unset( $menu_items, $unsorted_menu_items );
1088
+	unset($menu_items, $unsorted_menu_items);
1089 1089
 
1090 1090
 	return $messages;
1091 1091
 }
@@ -1099,36 +1099,36 @@  discard block
 block discarded – undo
1099 1099
  * @access private
1100 1100
  */
1101 1101
 function _wp_expand_nav_menu_post_data() {
1102
-	if ( ! isset( $_POST['nav-menu-data'] ) ) {
1102
+	if ( ! isset($_POST['nav-menu-data'])) {
1103 1103
 		return;
1104 1104
 	}
1105 1105
 
1106
-	$data = json_decode( stripslashes( $_POST['nav-menu-data'] ) );
1106
+	$data = json_decode(stripslashes($_POST['nav-menu-data']));
1107 1107
 
1108
-	if ( ! is_null( $data ) && $data ) {
1109
-		foreach ( $data as $post_input_data ) {
1108
+	if ( ! is_null($data) && $data) {
1109
+		foreach ($data as $post_input_data) {
1110 1110
 			// For input names that are arrays (e.g. `menu-item-db-id[3][4][5]`),
1111 1111
 			// derive the array path keys via regex and set the value in $_POST.
1112
-			preg_match( '#([^\[]*)(\[(.+)\])?#', $post_input_data->name, $matches );
1112
+			preg_match('#([^\[]*)(\[(.+)\])?#', $post_input_data->name, $matches);
1113 1113
 
1114
-			$array_bits = array( $matches[1] );
1114
+			$array_bits = array($matches[1]);
1115 1115
 
1116
-			if ( isset( $matches[3] ) ) {
1117
-				$array_bits = array_merge( $array_bits, explode( '][', $matches[3] ) );
1116
+			if (isset($matches[3])) {
1117
+				$array_bits = array_merge($array_bits, explode('][', $matches[3]));
1118 1118
 			}
1119 1119
 
1120 1120
 			$new_post_data = array();
1121 1121
 
1122 1122
 			// Build the new array value from leaf to trunk.
1123
-			for ( $i = count( $array_bits ) - 1; $i >= 0; $i -- ) {
1124
-				if ( $i == count( $array_bits ) - 1 ) {
1125
-					$new_post_data[ $array_bits[ $i ] ] = wp_slash( $post_input_data->value );
1123
+			for ($i = count($array_bits) - 1; $i >= 0; $i--) {
1124
+				if ($i == count($array_bits) - 1) {
1125
+					$new_post_data[$array_bits[$i]] = wp_slash($post_input_data->value);
1126 1126
 				} else {
1127
-					$new_post_data = array( $array_bits[ $i ] => $new_post_data );
1127
+					$new_post_data = array($array_bits[$i] => $new_post_data);
1128 1128
 				}
1129 1129
 			}
1130 1130
 
1131
-			$_POST = array_replace_recursive( $_POST, $new_post_data );
1131
+			$_POST = array_replace_recursive($_POST, $new_post_data);
1132 1132
 		}
1133 1133
 	}
1134 1134
 }
Please login to merge, or discard this patch.
src/wp-admin/includes/upgrade.php 5 patches
Doc Comments   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -1795,7 +1795,7 @@  discard block
 block discarded – undo
1795 1795
  *
1796 1796
  * @param string $table Database table name.
1797 1797
  * @param string $index Index name to drop.
1798
- * @return true True, when finished.
1798
+ * @return boolean True, when finished.
1799 1799
  */
1800 1800
 function drop_index($table, $index) {
1801 1801
 	global $wpdb;
@@ -1818,7 +1818,7 @@  discard block
 block discarded – undo
1818 1818
  *
1819 1819
  * @param string $table Database table name.
1820 1820
  * @param string $index Database table index column.
1821
- * @return true True, when done with execution.
1821
+ * @return boolean True, when done with execution.
1822 1822
  */
1823 1823
 function add_clean_index($table, $index) {
1824 1824
 	global $wpdb;
Please login to merge, or discard this patch.
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -2114,7 +2114,7 @@
 block discarded – undo
2114 2114
 	global $wpdb;
2115 2115
 
2116 2116
 	if ( in_array( $queries, array( '', 'all', 'blog', 'global', 'ms_global' ), true ) )
2117
-	    $queries = wp_get_db_schema( $queries );
2117
+		$queries = wp_get_db_schema( $queries );
2118 2118
 
2119 2119
 	// Separate individual queries into an array
2120 2120
 	if ( !is_array($queries) ) {
Please login to merge, or discard this patch.
Switch Indentation   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -2710,22 +2710,22 @@
 block discarded – undo
2710 2710
  */
2711 2711
 function translate_level_to_role($level) {
2712 2712
 	switch ($level) {
2713
-	case 10:
2714
-	case 9:
2715
-	case 8:
2716
-		return 'administrator';
2717
-	case 7:
2718
-	case 6:
2719
-	case 5:
2720
-		return 'editor';
2721
-	case 4:
2722
-	case 3:
2723
-	case 2:
2724
-		return 'author';
2725
-	case 1:
2726
-		return 'contributor';
2727
-	case 0:
2728
-		return 'subscriber';
2713
+		case 10:
2714
+		case 9:
2715
+		case 8:
2716
+			return 'administrator';
2717
+		case 7:
2718
+		case 6:
2719
+		case 5:
2720
+			return 'editor';
2721
+		case 4:
2722
+		case 3:
2723
+		case 2:
2724
+			return 'author';
2725
+		case 1:
2726
+			return 'contributor';
2727
+		case 0:
2728
+			return 'subscriber';
2729 2729
 	}
2730 2730
 }
2731 2731
 
Please login to merge, or discard this patch.
Braces   +368 added lines, -238 removed lines patch added patch discarded remove patch
@@ -9,8 +9,9 @@  discard block
 block discarded – undo
9 9
  */
10 10
 
11 11
 /** Include user install customize script. */
12
-if ( file_exists(WP_CONTENT_DIR . '/install.php') )
12
+if ( file_exists(WP_CONTENT_DIR . '/install.php') ) {
13 13
 	require (WP_CONTENT_DIR . '/install.php');
14
+}
14 15
 
15 16
 /** WordPress Administration API */
16 17
 require_once(ABSPATH . 'wp-admin/includes/admin.php');
@@ -37,8 +38,9 @@  discard block
 block discarded – undo
37 38
  * @return array Array keys 'url', 'user_id', 'password', and 'password_message'.
38 39
  */
39 40
 function wp_install( $blog_title, $user_name, $user_email, $public, $deprecated = '', $user_password = '', $language = '' ) {
40
-	if ( !empty( $deprecated ) )
41
-		_deprecated_argument( __FUNCTION__, '2.6.0' );
41
+	if ( !empty( $deprecated ) ) {
42
+			_deprecated_argument( __FUNCTION__, '2.6.0' );
43
+	}
42 44
 
43 45
 	wp_check_mysql_version();
44 46
 	wp_cache_flush();
@@ -59,8 +61,9 @@  discard block
 block discarded – undo
59 61
 	update_option('siteurl', $guessurl);
60 62
 
61 63
 	// If not a public blog, don't ping.
62
-	if ( ! $public )
63
-		update_option('default_pingback_flag', 0);
64
+	if ( ! $public ) {
65
+			update_option('default_pingback_flag', 0);
66
+	}
64 67
 
65 68
 	/*
66 69
 	 * Create default user. If the user already exists, the user tables are
@@ -223,8 +226,9 @@  discard block
 block discarded – undo
223 226
 <blockquote>The XYZ Doohickey Company was founded in 1971, and has been providing quality doohickeys to the public ever since. Located in Gotham City, XYZ employs over 2,000 people and does all kinds of awesome things for the Gotham community.</blockquote>
224 227
 
225 228
 As a new WordPress user, you should go to <a href=\"%s\">your dashboard</a> to delete this page and create new pages for your content. Have fun!" ), admin_url() );
226
-	if ( is_multisite() )
227
-		$first_page = get_site_option( 'first_page', $first_page );
229
+	if ( is_multisite() ) {
230
+			$first_page = get_site_option( 'first_page', $first_page );
231
+	}
228 232
 	$first_post_guid = get_option('home') . '/?page_id=2';
229 233
 	$wpdb->insert( $wpdb->posts, array(
230 234
 		'post_author' => $user_id,
@@ -255,10 +259,11 @@  discard block
 block discarded – undo
255 259
 	update_option( 'widget_meta', array ( 2 => array ( 'title' => '' ), '_multiwidget' => 1 ) );
256 260
 	update_option( 'sidebars_widgets', array ( 'wp_inactive_widgets' => array (), 'sidebar-1' => array ( 0 => 'search-2', 1 => 'recent-posts-2', 2 => 'recent-comments-2', 3 => 'archives-2', 4 => 'categories-2', 5 => 'meta-2', ), 'array_version' => 3 ) );
257 261
 
258
-	if ( ! is_multisite() )
259
-		update_user_meta( $user_id, 'show_welcome_panel', 1 );
260
-	elseif ( ! is_super_admin( $user_id ) && ! metadata_exists( 'user', $user_id, 'show_welcome_panel' ) )
261
-		update_user_meta( $user_id, 'show_welcome_panel', 2 );
262
+	if ( ! is_multisite() ) {
263
+			update_user_meta( $user_id, 'show_welcome_panel', 1 );
264
+	} elseif ( ! is_super_admin( $user_id ) && ! metadata_exists( 'user', $user_id, 'show_welcome_panel' ) ) {
265
+			update_user_meta( $user_id, 'show_welcome_panel', 2 );
266
+	}
262 267
 
263 268
 	if ( is_multisite() ) {
264 269
 		// Flush rules to pick up the new page.
@@ -273,8 +278,9 @@  discard block
 block discarded – undo
273 278
 		$wpdb->query( $wpdb->prepare("DELETE FROM $wpdb->usermeta WHERE user_id != %d AND meta_key = %s", $user_id, $table_prefix.'capabilities') );
274 279
 
275 280
 		// Delete any caps that snuck into the previously active blog. (Hardcoded to blog 1 for now.) TODO: Get previous_blog_id.
276
-		if ( !is_super_admin( $user_id ) && $user_id != 1 )
277
-			$wpdb->delete( $wpdb->usermeta, array( 'user_id' => $user_id , 'meta_key' => $wpdb->base_prefix.'1_capabilities' ) );
281
+		if ( !is_super_admin( $user_id ) && $user_id != 1 ) {
282
+					$wpdb->delete( $wpdb->usermeta, array( 'user_id' => $user_id , 'meta_key' => $wpdb->base_prefix.'1_capabilities' ) );
283
+		}
278 284
 	}
279 285
 }
280 286
 endif;
@@ -411,26 +417,30 @@  discard block
 block discarded – undo
411 417
 	$wp_current_db_version = __get_option('db_version');
412 418
 
413 419
 	// We are up-to-date. Nothing to do.
414
-	if ( $wp_db_version == $wp_current_db_version )
415
-		return;
420
+	if ( $wp_db_version == $wp_current_db_version ) {
421
+			return;
422
+	}
416 423
 
417
-	if ( ! is_blog_installed() )
418
-		return;
424
+	if ( ! is_blog_installed() ) {
425
+			return;
426
+	}
419 427
 
420 428
 	wp_check_mysql_version();
421 429
 	wp_cache_flush();
422 430
 	pre_schema_upgrade();
423 431
 	make_db_current_silent();
424 432
 	upgrade_all();
425
-	if ( is_multisite() && is_main_site() )
426
-		upgrade_network();
433
+	if ( is_multisite() && is_main_site() ) {
434
+			upgrade_network();
435
+	}
427 436
 	wp_cache_flush();
428 437
 
429 438
 	if ( is_multisite() ) {
430
-		if ( $wpdb->get_row( "SELECT blog_id FROM {$wpdb->blog_versions} WHERE blog_id = '{$wpdb->blogid}'" ) )
431
-			$wpdb->query( "UPDATE {$wpdb->blog_versions} SET db_version = '{$wp_db_version}' WHERE blog_id = '{$wpdb->blogid}'" );
432
-		else
433
-			$wpdb->query( "INSERT INTO {$wpdb->blog_versions} ( `blog_id` , `db_version` , `last_updated` ) VALUES ( '{$wpdb->blogid}', '{$wp_db_version}', NOW());" );
439
+		if ( $wpdb->get_row( "SELECT blog_id FROM {$wpdb->blog_versions} WHERE blog_id = '{$wpdb->blogid}'" ) ) {
440
+					$wpdb->query( "UPDATE {$wpdb->blog_versions} SET db_version = '{$wp_db_version}' WHERE blog_id = '{$wpdb->blogid}'" );
441
+		} else {
442
+					$wpdb->query( "INSERT INTO {$wpdb->blog_versions} ( `blog_id` , `db_version` , `last_updated` ) VALUES ( '{$wpdb->blogid}', '{$wp_db_version}', NOW());" );
443
+		}
434 444
 	}
435 445
 
436 446
 	/**
@@ -462,8 +472,9 @@  discard block
 block discarded – undo
462 472
 	$wp_current_db_version = __get_option('db_version');
463 473
 
464 474
 	// We are up-to-date. Nothing to do.
465
-	if ( $wp_db_version == $wp_current_db_version )
466
-		return;
475
+	if ( $wp_db_version == $wp_current_db_version ) {
476
+			return;
477
+	}
467 478
 
468 479
 	// If the version is not set in the DB, try to guess the version.
469 480
 	if ( empty($wp_current_db_version) ) {
@@ -471,12 +482,14 @@  discard block
 block discarded – undo
471 482
 
472 483
 		// If the template option exists, we have 1.5.
473 484
 		$template = __get_option('template');
474
-		if ( !empty($template) )
475
-			$wp_current_db_version = 2541;
485
+		if ( !empty($template) ) {
486
+					$wp_current_db_version = 2541;
487
+		}
476 488
 	}
477 489
 
478
-	if ( $wp_current_db_version < 6039 )
479
-		upgrade_230_options_table();
490
+	if ( $wp_current_db_version < 6039 ) {
491
+			upgrade_230_options_table();
492
+	}
480 493
 
481 494
 	populate_options();
482 495
 
@@ -487,77 +500,101 @@  discard block
 block discarded – undo
487 500
 		upgrade_130();
488 501
 	}
489 502
 
490
-	if ( $wp_current_db_version < 3308 )
491
-		upgrade_160();
503
+	if ( $wp_current_db_version < 3308 ) {
504
+			upgrade_160();
505
+	}
492 506
 
493
-	if ( $wp_current_db_version < 4772 )
494
-		upgrade_210();
507
+	if ( $wp_current_db_version < 4772 ) {
508
+			upgrade_210();
509
+	}
495 510
 
496
-	if ( $wp_current_db_version < 4351 )
497
-		upgrade_old_slugs();
511
+	if ( $wp_current_db_version < 4351 ) {
512
+			upgrade_old_slugs();
513
+	}
498 514
 
499
-	if ( $wp_current_db_version < 5539 )
500
-		upgrade_230();
515
+	if ( $wp_current_db_version < 5539 ) {
516
+			upgrade_230();
517
+	}
501 518
 
502
-	if ( $wp_current_db_version < 6124 )
503
-		upgrade_230_old_tables();
519
+	if ( $wp_current_db_version < 6124 ) {
520
+			upgrade_230_old_tables();
521
+	}
504 522
 
505
-	if ( $wp_current_db_version < 7499 )
506
-		upgrade_250();
523
+	if ( $wp_current_db_version < 7499 ) {
524
+			upgrade_250();
525
+	}
507 526
 
508
-	if ( $wp_current_db_version < 7935 )
509
-		upgrade_252();
527
+	if ( $wp_current_db_version < 7935 ) {
528
+			upgrade_252();
529
+	}
510 530
 
511
-	if ( $wp_current_db_version < 8201 )
512
-		upgrade_260();
531
+	if ( $wp_current_db_version < 8201 ) {
532
+			upgrade_260();
533
+	}
513 534
 
514
-	if ( $wp_current_db_version < 8989 )
515
-		upgrade_270();
535
+	if ( $wp_current_db_version < 8989 ) {
536
+			upgrade_270();
537
+	}
516 538
 
517
-	if ( $wp_current_db_version < 10360 )
518
-		upgrade_280();
539
+	if ( $wp_current_db_version < 10360 ) {
540
+			upgrade_280();
541
+	}
519 542
 
520
-	if ( $wp_current_db_version < 11958 )
521
-		upgrade_290();
543
+	if ( $wp_current_db_version < 11958 ) {
544
+			upgrade_290();
545
+	}
522 546
 
523
-	if ( $wp_current_db_version < 15260 )
524
-		upgrade_300();
547
+	if ( $wp_current_db_version < 15260 ) {
548
+			upgrade_300();
549
+	}
525 550
 
526
-	if ( $wp_current_db_version < 19389 )
527
-		upgrade_330();
551
+	if ( $wp_current_db_version < 19389 ) {
552
+			upgrade_330();
553
+	}
528 554
 
529
-	if ( $wp_current_db_version < 20080 )
530
-		upgrade_340();
555
+	if ( $wp_current_db_version < 20080 ) {
556
+			upgrade_340();
557
+	}
531 558
 
532
-	if ( $wp_current_db_version < 22422 )
533
-		upgrade_350();
559
+	if ( $wp_current_db_version < 22422 ) {
560
+			upgrade_350();
561
+	}
534 562
 
535
-	if ( $wp_current_db_version < 25824 )
536
-		upgrade_370();
563
+	if ( $wp_current_db_version < 25824 ) {
564
+			upgrade_370();
565
+	}
537 566
 
538
-	if ( $wp_current_db_version < 26148 )
539
-		upgrade_372();
567
+	if ( $wp_current_db_version < 26148 ) {
568
+			upgrade_372();
569
+	}
540 570
 
541
-	if ( $wp_current_db_version < 26691 )
542
-		upgrade_380();
571
+	if ( $wp_current_db_version < 26691 ) {
572
+			upgrade_380();
573
+	}
543 574
 
544
-	if ( $wp_current_db_version < 29630 )
545
-		upgrade_400();
575
+	if ( $wp_current_db_version < 29630 ) {
576
+			upgrade_400();
577
+	}
546 578
 
547
-	if ( $wp_current_db_version < 33055 )
548
-		upgrade_430();
579
+	if ( $wp_current_db_version < 33055 ) {
580
+			upgrade_430();
581
+	}
549 582
 
550
-	if ( $wp_current_db_version < 33056 )
551
-		upgrade_431();
583
+	if ( $wp_current_db_version < 33056 ) {
584
+			upgrade_431();
585
+	}
552 586
 
553
-	if ( $wp_current_db_version < 35700 )
554
-		upgrade_440();
587
+	if ( $wp_current_db_version < 35700 ) {
588
+			upgrade_440();
589
+	}
555 590
 
556
-	if ( $wp_current_db_version < 36686 )
557
-		upgrade_450();
591
+	if ( $wp_current_db_version < 36686 ) {
592
+			upgrade_450();
593
+	}
558 594
 
559
-	if ( $wp_current_db_version < 37965 )
560
-		upgrade_460();
595
+	if ( $wp_current_db_version < 37965 ) {
596
+			upgrade_460();
597
+	}
561 598
 
562 599
 	maybe_disable_link_manager();
563 600
 
@@ -610,8 +647,10 @@  discard block
 block discarded – undo
610 647
 			$done_posts[] = $done_id->post_id;
611 648
 		endforeach;
612 649
 		$catwhere = ' AND ID NOT IN (' . implode(',', $done_posts) . ')';
613
-	else:
650
+	else {
651
+		:
614 652
 		$catwhere = '';
653
+	}
615 654
 	endif;
616 655
 
617 656
 	$allposts = $wpdb->get_results("SELECT ID, post_category FROM $wpdb->posts WHERE post_category != '0' $catwhere");
@@ -728,10 +767,11 @@  discard block
 block discarded – undo
728 767
 			$post_content = addslashes(deslash($post->post_content));
729 768
 			$post_title = addslashes(deslash($post->post_title));
730 769
 			$post_excerpt = addslashes(deslash($post->post_excerpt));
731
-			if ( empty($post->guid) )
732
-				$guid = get_permalink($post->ID);
733
-			else
734
-				$guid = $post->guid;
770
+			if ( empty($post->guid) ) {
771
+							$guid = get_permalink($post->ID);
772
+			} else {
773
+							$guid = $post->guid;
774
+			}
735 775
 
736 776
 			$wpdb->update( $wpdb->posts, compact('post_title', 'post_content', 'post_excerpt', 'guid'), array('ID' => $post->ID) );
737 777
 
@@ -813,34 +853,57 @@  discard block
 block discarded – undo
813 853
 
814 854
 	$users = $wpdb->get_results("SELECT * FROM $wpdb->users");
815 855
 	foreach ( $users as $user ) :
816
-		if ( !empty( $user->user_firstname ) )
817
-			update_user_meta( $user->ID, 'first_name', wp_slash($user->user_firstname) );
818
-		if ( !empty( $user->user_lastname ) )
819
-			update_user_meta( $user->ID, 'last_name', wp_slash($user->user_lastname) );
820
-		if ( !empty( $user->user_nickname ) )
821
-			update_user_meta( $user->ID, 'nickname', wp_slash($user->user_nickname) );
822
-		if ( !empty( $user->user_level ) )
823
-			update_user_meta( $user->ID, $wpdb->prefix . 'user_level', $user->user_level );
824
-		if ( !empty( $user->user_icq ) )
825
-			update_user_meta( $user->ID, 'icq', wp_slash($user->user_icq) );
826
-		if ( !empty( $user->user_aim ) )
827
-			update_user_meta( $user->ID, 'aim', wp_slash($user->user_aim) );
828
-		if ( !empty( $user->user_msn ) )
829
-			update_user_meta( $user->ID, 'msn', wp_slash($user->user_msn) );
830
-		if ( !empty( $user->user_yim ) )
831
-			update_user_meta( $user->ID, 'yim', wp_slash($user->user_icq) );
832
-		if ( !empty( $user->user_description ) )
833
-			update_user_meta( $user->ID, 'description', wp_slash($user->user_description) );
856
+		if ( !empty( $user->user_firstname ) ) {
857
+					update_user_meta( $user->ID, 'first_name', wp_slash($user->user_firstname) );
858
+		}
859
+		if ( !empty( $user->user_lastname ) ) {
860
+					update_user_meta( $user->ID, 'last_name', wp_slash($user->user_lastname) );
861
+		}
862
+		if ( !empty( $user->user_nickname ) ) {
863
+					update_user_meta( $user->ID, 'nickname', wp_slash($user->user_nickname) );
864
+		}
865
+		if ( !empty( $user->user_level ) ) {
866
+					update_user_meta( $user->ID, $wpdb->prefix . 'user_level', $user->user_level );
867
+		}
868
+		if ( !empty( $user->user_icq ) ) {
869
+					update_user_meta( $user->ID, 'icq', wp_slash($user->user_icq) );
870
+		}
871
+		if ( !empty( $user->user_aim ) ) {
872
+					update_user_meta( $user->ID, 'aim', wp_slash($user->user_aim) );
873
+		}
874
+		if ( !empty( $user->user_msn ) ) {
875
+					update_user_meta( $user->ID, 'msn', wp_slash($user->user_msn) );
876
+		}
877
+		if ( !empty( $user->user_yim ) ) {
878
+					update_user_meta( $user->ID, 'yim', wp_slash($user->user_icq) );
879
+		}
880
+		if ( !empty( $user->user_description ) ) {
881
+					update_user_meta( $user->ID, 'description', wp_slash($user->user_description) );
882
+		}
834 883
 
835 884
 		if ( isset( $user->user_idmode ) ):
836 885
 			$idmode = $user->user_idmode;
837
-			if ($idmode == 'nickname') $id = $user->user_nickname;
838
-			if ($idmode == 'login') $id = $user->user_login;
839
-			if ($idmode == 'firstname') $id = $user->user_firstname;
840
-			if ($idmode == 'lastname') $id = $user->user_lastname;
841
-			if ($idmode == 'namefl') $id = $user->user_firstname.' '.$user->user_lastname;
842
-			if ($idmode == 'namelf') $id = $user->user_lastname.' '.$user->user_firstname;
843
-			if (!$idmode) $id = $user->user_nickname;
886
+			if ($idmode == 'nickname') {
887
+				$id = $user->user_nickname;
888
+			}
889
+			if ($idmode == 'login') {
890
+				$id = $user->user_login;
891
+			}
892
+			if ($idmode == 'firstname') {
893
+				$id = $user->user_firstname;
894
+			}
895
+			if ($idmode == 'lastname') {
896
+				$id = $user->user_lastname;
897
+			}
898
+			if ($idmode == 'namefl') {
899
+				$id = $user->user_firstname.' '.$user->user_lastname;
900
+			}
901
+			if ($idmode == 'namelf') {
902
+				$id = $user->user_lastname.' '.$user->user_firstname;
903
+			}
904
+			if (!$idmode) {
905
+				$id = $user->user_nickname;
906
+			}
844 907
 			$wpdb->update( $wpdb->users, array('display_name' => $id), array('ID' => $user->ID) );
845 908
 		endif;
846 909
 
@@ -855,15 +918,17 @@  discard block
 block discarded – undo
855 918
 	endforeach;
856 919
 	$old_user_fields = array( 'user_firstname', 'user_lastname', 'user_icq', 'user_aim', 'user_msn', 'user_yim', 'user_idmode', 'user_ip', 'user_domain', 'user_browser', 'user_description', 'user_nickname', 'user_level' );
857 920
 	$wpdb->hide_errors();
858
-	foreach ( $old_user_fields as $old )
859
-		$wpdb->query("ALTER TABLE $wpdb->users DROP $old");
921
+	foreach ( $old_user_fields as $old ) {
922
+			$wpdb->query("ALTER TABLE $wpdb->users DROP $old");
923
+	}
860 924
 	$wpdb->show_errors();
861 925
 
862 926
 	// Populate comment_count field of posts table.
863 927
 	$comments = $wpdb->get_results( "SELECT comment_post_ID, COUNT(*) as c FROM $wpdb->comments WHERE comment_approved = '1' GROUP BY comment_post_ID" );
864
-	if ( is_array( $comments ) )
865
-		foreach ($comments as $comment)
928
+	if ( is_array( $comments ) ) {
929
+			foreach ($comments as $comment)
866 930
 			$wpdb->update( $wpdb->posts, array('comment_count' => $comment->c), array('ID' => $comment->comment_post_ID) );
931
+	}
867 932
 
868 933
 	/*
869 934
 	 * Some alpha versions used a post status of object instead of attachment
@@ -878,8 +943,9 @@  discard block
 block discarded – undo
878 943
 										 array( 'ID' => $object->ID ) );
879 944
 
880 945
 			$meta = get_post_meta($object->ID, 'imagedata', true);
881
-			if ( ! empty($meta['file']) )
882
-				update_attached_file( $object->ID, $meta['file'] );
946
+			if ( ! empty($meta['file']) ) {
947
+							update_attached_file( $object->ID, $meta['file'] );
948
+			}
883 949
 		}
884 950
 	}
885 951
 }
@@ -900,8 +966,10 @@  discard block
 block discarded – undo
900 966
 		// Update status and type.
901 967
 		$posts = $wpdb->get_results("SELECT ID, post_status FROM $wpdb->posts");
902 968
 
903
-		if ( ! empty($posts) ) foreach ($posts as $post) {
969
+		if ( ! empty($posts) ) {
970
+			foreach ($posts as $post) {
904 971
 			$status = $post->post_status;
972
+		}
905 973
 			$type = 'post';
906 974
 
907 975
 			if ( 'static' == $status ) {
@@ -926,9 +994,10 @@  discard block
 block discarded – undo
926 994
 		$wpdb->query ("UPDATE $wpdb->posts SET post_status = 'future' WHERE post_status = 'publish' AND post_date_gmt > '$now'");
927 995
 
928 996
 		$posts = $wpdb->get_results("SELECT ID, post_date FROM $wpdb->posts WHERE post_status ='future'");
929
-		if ( !empty($posts) )
930
-			foreach ( $posts as $post )
997
+		if ( !empty($posts) ) {
998
+					foreach ( $posts as $post )
931 999
 				wp_schedule_single_event(mysql2date('U', $post->post_date, false), 'publish_future_post', array($post->ID));
1000
+		}
932 1001
 	}
933 1002
 }
934 1003
 
@@ -1014,19 +1083,22 @@  discard block
 block discarded – undo
1014 1083
 	}
1015 1084
 
1016 1085
 	$select = 'post_id, category_id';
1017
-	if ( $have_tags )
1018
-		$select .= ', rel_type';
1086
+	if ( $have_tags ) {
1087
+			$select .= ', rel_type';
1088
+	}
1019 1089
 
1020 1090
 	$posts = $wpdb->get_results("SELECT $select FROM $wpdb->post2cat GROUP BY post_id, category_id");
1021 1091
 	foreach ( $posts as $post ) {
1022 1092
 		$post_id = (int) $post->post_id;
1023 1093
 		$term_id = (int) $post->category_id;
1024 1094
 		$taxonomy = 'category';
1025
-		if ( !empty($post->rel_type) && 'tag' == $post->rel_type)
1026
-			$taxonomy = 'tag';
1095
+		if ( !empty($post->rel_type) && 'tag' == $post->rel_type) {
1096
+					$taxonomy = 'tag';
1097
+		}
1027 1098
 		$tt_id = $tt_ids[$term_id][$taxonomy];
1028
-		if ( empty($tt_id) )
1029
-			continue;
1099
+		if ( empty($tt_id) ) {
1100
+					continue;
1101
+		}
1030 1102
 
1031 1103
 		$wpdb->insert( $wpdb->term_relationships, array('object_id' => $post_id, 'term_taxonomy_id' => $tt_id) );
1032 1104
 	}
@@ -1068,15 +1140,19 @@  discard block
 block discarded – undo
1068 1140
 
1069 1141
 		// Associate links to cats.
1070 1142
 		$links = $wpdb->get_results("SELECT link_id, link_category FROM $wpdb->links");
1071
-		if ( !empty($links) ) foreach ( $links as $link ) {
1143
+		if ( !empty($links) ) {
1144
+			foreach ( $links as $link ) {
1072 1145
 			if ( 0 == $link->link_category )
1073 1146
 				continue;
1074
-			if ( ! isset($link_cat_id_map[$link->link_category]) )
1075
-				continue;
1147
+		}
1148
+			if ( ! isset($link_cat_id_map[$link->link_category]) ) {
1149
+							continue;
1150
+			}
1076 1151
 			$term_id = $link_cat_id_map[$link->link_category];
1077 1152
 			$tt_id = $tt_ids[$term_id];
1078
-			if ( empty($tt_id) )
1079
-				continue;
1153
+			if ( empty($tt_id) ) {
1154
+							continue;
1155
+			}
1080 1156
 
1081 1157
 			$wpdb->insert( $wpdb->term_relationships, array('object_id' => $link->link_id, 'term_taxonomy_id' => $tt_id) );
1082 1158
 		}
@@ -1090,8 +1166,9 @@  discard block
 block discarded – undo
1090 1166
 			$term_id = (int) $link->category_id;
1091 1167
 			$taxonomy = 'link_category';
1092 1168
 			$tt_id = $tt_ids[$term_id][$taxonomy];
1093
-			if ( empty($tt_id) )
1094
-				continue;
1169
+			if ( empty($tt_id) ) {
1170
+							continue;
1171
+			}
1095 1172
 			$wpdb->insert( $wpdb->term_relationships, array('object_id' => $link_id, 'term_taxonomy_id' => $tt_id) );
1096 1173
 		}
1097 1174
 	}
@@ -1104,10 +1181,11 @@  discard block
 block discarded – undo
1104 1181
 	// Recalculate all counts
1105 1182
 	$terms = $wpdb->get_results("SELECT term_taxonomy_id, taxonomy FROM $wpdb->term_taxonomy");
1106 1183
 	foreach ( (array) $terms as $term ) {
1107
-		if ( ('post_tag' == $term->taxonomy) || ('category' == $term->taxonomy) )
1108
-			$count = $wpdb->get_var( $wpdb->prepare("SELECT COUNT(*) FROM $wpdb->term_relationships, $wpdb->posts WHERE $wpdb->posts.ID = $wpdb->term_relationships.object_id AND post_status = 'publish' AND post_type = 'post' AND term_taxonomy_id = %d", $term->term_taxonomy_id) );
1109
-		else
1110
-			$count = $wpdb->get_var( $wpdb->prepare("SELECT COUNT(*) FROM $wpdb->term_relationships WHERE term_taxonomy_id = %d", $term->term_taxonomy_id) );
1184
+		if ( ('post_tag' == $term->taxonomy) || ('category' == $term->taxonomy) ) {
1185
+					$count = $wpdb->get_var( $wpdb->prepare("SELECT COUNT(*) FROM $wpdb->term_relationships, $wpdb->posts WHERE $wpdb->posts.ID = $wpdb->term_relationships.object_id AND post_status = 'publish' AND post_type = 'post' AND term_taxonomy_id = %d", $term->term_taxonomy_id) );
1186
+		} else {
1187
+					$count = $wpdb->get_var( $wpdb->prepare("SELECT COUNT(*) FROM $wpdb->term_relationships WHERE term_taxonomy_id = %d", $term->term_taxonomy_id) );
1188
+		}
1111 1189
 		$wpdb->update( $wpdb->term_taxonomy, array('count' => $count), array('term_taxonomy_id' => $term->term_taxonomy_id) );
1112 1190
 	}
1113 1191
 }
@@ -1124,8 +1202,9 @@  discard block
 block discarded – undo
1124 1202
 	global $wpdb;
1125 1203
 	$old_options_fields = array( 'option_can_override', 'option_type', 'option_width', 'option_height', 'option_description', 'option_admin_level' );
1126 1204
 	$wpdb->hide_errors();
1127
-	foreach ( $old_options_fields as $old )
1128
-		$wpdb->query("ALTER TABLE $wpdb->options DROP $old");
1205
+	foreach ( $old_options_fields as $old ) {
1206
+			$wpdb->query("ALTER TABLE $wpdb->options DROP $old");
1207
+	}
1129 1208
 	$wpdb->show_errors();
1130 1209
 }
1131 1210
 
@@ -1200,9 +1279,10 @@  discard block
 block discarded – undo
1200 1279
 function upgrade_260() {
1201 1280
 	global $wp_current_db_version;
1202 1281
 
1203
-	if ( $wp_current_db_version < 8000 )
1204
-		populate_roles_260();
1205
-}
1282
+	if ( $wp_current_db_version < 8000 ) {
1283
+			populate_roles_260();
1284
+	}
1285
+	}
1206 1286
 
1207 1287
 /**
1208 1288
  * Execute changes made in WordPress 2.7.
@@ -1216,13 +1296,15 @@  discard block
 block discarded – undo
1216 1296
 function upgrade_270() {
1217 1297
 	global $wpdb, $wp_current_db_version;
1218 1298
 
1219
-	if ( $wp_current_db_version < 8980 )
1220
-		populate_roles_270();
1299
+	if ( $wp_current_db_version < 8980 ) {
1300
+			populate_roles_270();
1301
+	}
1221 1302
 
1222 1303
 	// Update post_date for unpublished posts with empty timestamp
1223
-	if ( $wp_current_db_version < 8921 )
1224
-		$wpdb->query( "UPDATE $wpdb->posts SET post_date = post_modified WHERE post_date = '0000-00-00 00:00:00'" );
1225
-}
1304
+	if ( $wp_current_db_version < 8921 ) {
1305
+			$wpdb->query( "UPDATE $wpdb->posts SET post_date = post_modified WHERE post_date = '0000-00-00 00:00:00'" );
1306
+	}
1307
+	}
1226 1308
 
1227 1309
 /**
1228 1310
  * Execute changes made in WordPress 2.8.
@@ -1236,15 +1318,17 @@  discard block
 block discarded – undo
1236 1318
 function upgrade_280() {
1237 1319
 	global $wp_current_db_version, $wpdb;
1238 1320
 
1239
-	if ( $wp_current_db_version < 10360 )
1240
-		populate_roles_280();
1321
+	if ( $wp_current_db_version < 10360 ) {
1322
+			populate_roles_280();
1323
+	}
1241 1324
 	if ( is_multisite() ) {
1242 1325
 		$start = 0;
1243 1326
 		while( $rows = $wpdb->get_results( "SELECT option_name, option_value FROM $wpdb->options ORDER BY option_id LIMIT $start, 20" ) ) {
1244 1327
 			foreach ( $rows as $row ) {
1245 1328
 				$value = $row->option_value;
1246
-				if ( !@unserialize( $value ) )
1247
-					$value = stripslashes( $value );
1329
+				if ( !@unserialize( $value ) ) {
1330
+									$value = stripslashes( $value );
1331
+				}
1248 1332
 				if ( $value !== $row->option_value ) {
1249 1333
 					update_option( $row->option_name, $value );
1250 1334
 				}
@@ -1287,11 +1371,13 @@  discard block
 block discarded – undo
1287 1371
 function upgrade_300() {
1288 1372
 	global $wp_current_db_version, $wpdb;
1289 1373
 
1290
-	if ( $wp_current_db_version < 15093 )
1291
-		populate_roles_300();
1374
+	if ( $wp_current_db_version < 15093 ) {
1375
+			populate_roles_300();
1376
+	}
1292 1377
 
1293
-	if ( $wp_current_db_version < 14139 && is_multisite() && is_main_site() && ! defined( 'MULTISITE' ) && get_site_option( 'siteurl' ) === false )
1294
-		add_site_option( 'siteurl', '' );
1378
+	if ( $wp_current_db_version < 14139 && is_multisite() && is_main_site() && ! defined( 'MULTISITE' ) && get_site_option( 'siteurl' ) === false ) {
1379
+			add_site_option( 'siteurl', '' );
1380
+	}
1295 1381
 
1296 1382
 	// 3.0 screen options key name changes.
1297 1383
 	if ( wp_should_upgrade_global_tables() ) {
@@ -1339,23 +1425,26 @@  discard block
 block discarded – undo
1339 1425
 		$wpdb->query( "DELETE FROM $wpdb->usermeta WHERE meta_key IN ('show_admin_bar_admin', 'plugins_last_view')" );
1340 1426
 	}
1341 1427
 
1342
-	if ( $wp_current_db_version >= 11548 )
1343
-		return;
1428
+	if ( $wp_current_db_version >= 11548 ) {
1429
+			return;
1430
+	}
1344 1431
 
1345 1432
 	$sidebars_widgets = get_option( 'sidebars_widgets', array() );
1346 1433
 	$_sidebars_widgets = array();
1347 1434
 
1348
-	if ( isset($sidebars_widgets['wp_inactive_widgets']) || empty($sidebars_widgets) )
1349
-		$sidebars_widgets['array_version'] = 3;
1350
-	elseif ( !isset($sidebars_widgets['array_version']) )
1351
-		$sidebars_widgets['array_version'] = 1;
1435
+	if ( isset($sidebars_widgets['wp_inactive_widgets']) || empty($sidebars_widgets) ) {
1436
+			$sidebars_widgets['array_version'] = 3;
1437
+	} elseif ( !isset($sidebars_widgets['array_version']) ) {
1438
+			$sidebars_widgets['array_version'] = 1;
1439
+	}
1352 1440
 
1353 1441
 	switch ( $sidebars_widgets['array_version'] ) {
1354 1442
 		case 1 :
1355
-			foreach ( (array) $sidebars_widgets as $index => $sidebar )
1356
-			if ( is_array($sidebar) )
1443
+			foreach ( (array) $sidebars_widgets as $index => $sidebar ) {
1444
+						if ( is_array($sidebar) )
1357 1445
 			foreach ( (array) $sidebar as $i => $name ) {
1358 1446
 				$id = strtolower($name);
1447
+			}
1359 1448
 				if ( isset($wp_registered_widgets[$id]) ) {
1360 1449
 					$_sidebars_widgets[$index][$i] = $id;
1361 1450
 					continue;
@@ -1380,8 +1469,9 @@  discard block
 block discarded – undo
1380 1469
 					}
1381 1470
 				}
1382 1471
 
1383
-				if ( $found )
1384
-					continue;
1472
+				if ( $found ) {
1473
+									continue;
1474
+				}
1385 1475
 
1386 1476
 				unset($_sidebars_widgets[$index][$i]);
1387 1477
 			}
@@ -1445,14 +1535,17 @@  discard block
 block discarded – undo
1445 1535
 function upgrade_350() {
1446 1536
 	global $wp_current_db_version, $wpdb;
1447 1537
 
1448
-	if ( $wp_current_db_version < 22006 && $wpdb->get_var( "SELECT link_id FROM $wpdb->links LIMIT 1" ) )
1449
-		update_option( 'link_manager_enabled', 1 ); // Previously set to 0 by populate_options()
1538
+	if ( $wp_current_db_version < 22006 && $wpdb->get_var( "SELECT link_id FROM $wpdb->links LIMIT 1" ) ) {
1539
+			update_option( 'link_manager_enabled', 1 );
1540
+	}
1541
+	// Previously set to 0 by populate_options()
1450 1542
 
1451 1543
 	if ( $wp_current_db_version < 21811 && wp_should_upgrade_global_tables() ) {
1452 1544
 		$meta_keys = array();
1453 1545
 		foreach ( array_merge( get_post_types(), get_taxonomies() ) as $name ) {
1454
-			if ( false !== strpos( $name, '-' ) )
1455
-			$meta_keys[] = 'edit_' . str_replace( '-', '_', $name ) . '_per_page';
1546
+			if ( false !== strpos( $name, '-' ) ) {
1547
+						$meta_keys[] = 'edit_' . str_replace( '-', '_', $name ) . '_per_page';
1548
+			}
1456 1549
 		}
1457 1550
 		if ( $meta_keys ) {
1458 1551
 			$meta_keys = implode( "', '", $meta_keys );
@@ -1460,9 +1553,10 @@  discard block
 block discarded – undo
1460 1553
 		}
1461 1554
 	}
1462 1555
 
1463
-	if ( $wp_current_db_version < 22422 && $term = get_term_by( 'slug', 'post-format-standard', 'post_format' ) )
1464
-		wp_delete_term( $term->term_id, 'post_format' );
1465
-}
1556
+	if ( $wp_current_db_version < 22422 && $term = get_term_by( 'slug', 'post-format-standard', 'post_format' ) ) {
1557
+			wp_delete_term( $term->term_id, 'post_format' );
1558
+	}
1559
+	}
1466 1560
 
1467 1561
 /**
1468 1562
  * Execute changes made in WordPress 3.7.
@@ -1474,9 +1568,10 @@  discard block
 block discarded – undo
1474 1568
  */
1475 1569
 function upgrade_370() {
1476 1570
 	global $wp_current_db_version;
1477
-	if ( $wp_current_db_version < 25824 )
1478
-		wp_clear_scheduled_hook( 'wp_auto_updates_maybe_update' );
1479
-}
1571
+	if ( $wp_current_db_version < 25824 ) {
1572
+			wp_clear_scheduled_hook( 'wp_auto_updates_maybe_update' );
1573
+	}
1574
+	}
1480 1575
 
1481 1576
 /**
1482 1577
  * Execute changes made in WordPress 3.7.2.
@@ -1489,9 +1584,10 @@  discard block
 block discarded – undo
1489 1584
  */
1490 1585
 function upgrade_372() {
1491 1586
 	global $wp_current_db_version;
1492
-	if ( $wp_current_db_version < 26148 )
1493
-		wp_clear_scheduled_hook( 'wp_maybe_auto_update' );
1494
-}
1587
+	if ( $wp_current_db_version < 26148 ) {
1588
+			wp_clear_scheduled_hook( 'wp_maybe_auto_update' );
1589
+	}
1590
+	}
1495 1591
 
1496 1592
 /**
1497 1593
  * Execute changes made in WordPress 3.8.0.
@@ -1758,10 +1854,11 @@  discard block
 block discarded – undo
1758 1854
 		$wpmu_sitewide_plugins = get_site_option( 'wpmu_sitewide_plugins' );
1759 1855
 		$active_sitewide_plugins = get_site_option( 'active_sitewide_plugins' );
1760 1856
 		if ( $wpmu_sitewide_plugins ) {
1761
-			if ( !$active_sitewide_plugins )
1762
-				$sitewide_plugins = (array) $wpmu_sitewide_plugins;
1763
-			else
1764
-				$sitewide_plugins = array_merge( (array) $active_sitewide_plugins, (array) $wpmu_sitewide_plugins );
1857
+			if ( !$active_sitewide_plugins ) {
1858
+							$sitewide_plugins = (array) $wpmu_sitewide_plugins;
1859
+			} else {
1860
+							$sitewide_plugins = array_merge( (array) $active_sitewide_plugins, (array) $wpmu_sitewide_plugins );
1861
+			}
1765 1862
 
1766 1863
 			update_site_option( 'active_sitewide_plugins', $sitewide_plugins );
1767 1864
 		}
@@ -1772,8 +1869,9 @@  discard block
 block discarded – undo
1772 1869
 		while( $rows = $wpdb->get_results( "SELECT meta_key, meta_value FROM {$wpdb->sitemeta} ORDER BY meta_id LIMIT $start, 20" ) ) {
1773 1870
 			foreach ( $rows as $row ) {
1774 1871
 				$value = $row->meta_value;
1775
-				if ( !@unserialize( $value ) )
1776
-					$value = stripslashes( $value );
1872
+				if ( !@unserialize( $value ) ) {
1873
+									$value = stripslashes( $value );
1874
+				}
1777 1875
 				if ( $value !== $row->meta_value ) {
1778 1876
 					update_site_option( $row->meta_key, $value );
1779 1877
 				}
@@ -1783,16 +1881,19 @@  discard block
 block discarded – undo
1783 1881
 	}
1784 1882
 
1785 1883
 	// 3.0
1786
-	if ( $wp_current_db_version < 13576 )
1787
-		update_site_option( 'global_terms_enabled', '1' );
1884
+	if ( $wp_current_db_version < 13576 ) {
1885
+			update_site_option( 'global_terms_enabled', '1' );
1886
+	}
1788 1887
 
1789 1888
 	// 3.3
1790
-	if ( $wp_current_db_version < 19390 )
1791
-		update_site_option( 'initial_db_version', $wp_current_db_version );
1889
+	if ( $wp_current_db_version < 19390 ) {
1890
+			update_site_option( 'initial_db_version', $wp_current_db_version );
1891
+	}
1792 1892
 
1793 1893
 	if ( $wp_current_db_version < 19470 ) {
1794
-		if ( false === get_site_option( 'active_sitewide_plugins' ) )
1795
-			update_site_option( 'active_sitewide_plugins', array() );
1894
+		if ( false === get_site_option( 'active_sitewide_plugins' ) ) {
1895
+					update_site_option( 'active_sitewide_plugins', array() );
1896
+		}
1796 1897
 	}
1797 1898
 
1798 1899
 	// 3.4
@@ -1804,8 +1905,9 @@  discard block
 block discarded – undo
1804 1905
 			$converted = array();
1805 1906
 			$themes = wp_get_themes();
1806 1907
 			foreach ( $themes as $stylesheet => $theme_data ) {
1807
-				if ( isset( $allowed_themes[ $theme_data->get('Name') ] ) )
1808
-					$converted[ $stylesheet ] = true;
1908
+				if ( isset( $allowed_themes[ $theme_data->get('Name') ] ) ) {
1909
+									$converted[ $stylesheet ] = true;
1910
+				}
1809 1911
 			}
1810 1912
 			update_site_option( 'allowedthemes', $converted );
1811 1913
 			delete_site_option( 'allowed_themes' );
@@ -1813,8 +1915,9 @@  discard block
 block discarded – undo
1813 1915
 	}
1814 1916
 
1815 1917
 	// 3.5
1816
-	if ( $wp_current_db_version < 21823 )
1817
-		update_site_option( 'ms_files_rewriting', '1' );
1918
+	if ( $wp_current_db_version < 21823 ) {
1919
+			update_site_option( 'ms_files_rewriting', '1' );
1920
+	}
1818 1921
 
1819 1922
 	// 3.5.2
1820 1923
 	if ( $wp_current_db_version < 24448 ) {
@@ -2045,8 +2148,9 @@  discard block
 block discarded – undo
2045 2148
 	$all_options = new stdClass;
2046 2149
 	if ( $options = $wpdb->get_results( "SELECT option_name, option_value FROM $wpdb->options" ) ) {
2047 2150
 		foreach ( $options as $option ) {
2048
-			if ( 'siteurl' == $option->option_name || 'home' == $option->option_name || 'category_base' == $option->option_name )
2049
-				$option->option_value = untrailingslashit( $option->option_value );
2151
+			if ( 'siteurl' == $option->option_name || 'home' == $option->option_name || 'category_base' == $option->option_name ) {
2152
+							$option->option_value = untrailingslashit( $option->option_value );
2153
+			}
2050 2154
 			$all_options->{$option->option_name} = stripslashes( $option->option_value );
2051 2155
 		}
2052 2156
 	}
@@ -2068,19 +2172,23 @@  discard block
 block discarded – undo
2068 2172
 function __get_option($setting) {
2069 2173
 	global $wpdb;
2070 2174
 
2071
-	if ( $setting == 'home' && defined( 'WP_HOME' ) )
2072
-		return untrailingslashit( WP_HOME );
2175
+	if ( $setting == 'home' && defined( 'WP_HOME' ) ) {
2176
+			return untrailingslashit( WP_HOME );
2177
+	}
2073 2178
 
2074
-	if ( $setting == 'siteurl' && defined( 'WP_SITEURL' ) )
2075
-		return untrailingslashit( WP_SITEURL );
2179
+	if ( $setting == 'siteurl' && defined( 'WP_SITEURL' ) ) {
2180
+			return untrailingslashit( WP_SITEURL );
2181
+	}
2076 2182
 
2077 2183
 	$option = $wpdb->get_var( $wpdb->prepare("SELECT option_value FROM $wpdb->options WHERE option_name = %s", $setting ) );
2078 2184
 
2079
-	if ( 'home' == $setting && '' == $option )
2080
-		return __get_option( 'siteurl' );
2185
+	if ( 'home' == $setting && '' == $option ) {
2186
+			return __get_option( 'siteurl' );
2187
+	}
2081 2188
 
2082
-	if ( 'siteurl' == $setting || 'home' == $setting || 'category_base' == $setting || 'tag_base' == $setting )
2083
-		$option = untrailingslashit( $option );
2189
+	if ( 'siteurl' == $setting || 'home' == $setting || 'category_base' == $setting || 'tag_base' == $setting ) {
2190
+			$option = untrailingslashit( $option );
2191
+	}
2084 2192
 
2085 2193
 	return maybe_unserialize( $option );
2086 2194
 }
@@ -2133,8 +2241,9 @@  discard block
 block discarded – undo
2133 2241
 function dbDelta( $queries = '', $execute = true ) {
2134 2242
 	global $wpdb;
2135 2243
 
2136
-	if ( in_array( $queries, array( '', 'all', 'blog', 'global', 'ms_global' ), true ) )
2137
-	    $queries = wp_get_db_schema( $queries );
2244
+	if ( in_array( $queries, array( '', 'all', 'blog', 'global', 'ms_global' ), true ) ) {
2245
+		    $queries = wp_get_db_schema( $queries );
2246
+	}
2138 2247
 
2139 2248
 	// Separate individual queries into an array
2140 2249
 	if ( !is_array($queries) ) {
@@ -2209,8 +2318,9 @@  discard block
 block discarded – undo
2209 2318
 		$tablefields = $wpdb->get_results("DESCRIBE {$table};");
2210 2319
 		$wpdb->suppress_errors( $suppress );
2211 2320
 
2212
-		if ( ! $tablefields )
2213
-			continue;
2321
+		if ( ! $tablefields ) {
2322
+					continue;
2323
+		}
2214 2324
 
2215 2325
 		// Clear the field and index arrays.
2216 2326
 		$cfields = $indices = array();
@@ -2502,7 +2612,9 @@  discard block
 block discarded – undo
2502 2612
 function make_db_current( $tables = 'all' ) {
2503 2613
 	$alterations = dbDelta( $tables );
2504 2614
 	echo "<ol>\n";
2505
-	foreach ($alterations as $alteration) echo "<li>$alteration</li>\n";
2615
+	foreach ($alterations as $alteration) {
2616
+		echo "<li>$alteration</li>\n";
2617
+	}
2506 2618
 	echo "</ol>\n";
2507 2619
 }
2508 2620
 
@@ -2537,8 +2649,9 @@  discard block
 block discarded – undo
2537 2649
 	$home_path = get_home_path();
2538 2650
 	$site_dir = WP_CONTENT_DIR . "/themes/$template";
2539 2651
 
2540
-	if (! file_exists("$home_path/index.php"))
2541
-		return false;
2652
+	if (! file_exists("$home_path/index.php")) {
2653
+			return false;
2654
+	}
2542 2655
 
2543 2656
 	/*
2544 2657
 	 * Copy files from the old locations to the site theme.
@@ -2547,25 +2660,28 @@  discard block
 block discarded – undo
2547 2660
 	$files = array('index.php' => 'index.php', 'wp-layout.css' => 'style.css', 'wp-comments.php' => 'comments.php', 'wp-comments-popup.php' => 'comments-popup.php');
2548 2661
 
2549 2662
 	foreach ($files as $oldfile => $newfile) {
2550
-		if ($oldfile == 'index.php')
2551
-			$oldpath = $home_path;
2552
-		else
2553
-			$oldpath = ABSPATH;
2663
+		if ($oldfile == 'index.php') {
2664
+					$oldpath = $home_path;
2665
+		} else {
2666
+					$oldpath = ABSPATH;
2667
+		}
2554 2668
 
2555 2669
 		// Check to make sure it's not a new index.
2556 2670
 		if ($oldfile == 'index.php') {
2557 2671
 			$index = implode('', file("$oldpath/$oldfile"));
2558 2672
 			if (strpos($index, 'WP_USE_THEMES') !== false) {
2559
-				if (! @copy(WP_CONTENT_DIR . '/themes/' . WP_DEFAULT_THEME . '/index.php', "$site_dir/$newfile"))
2560
-					return false;
2673
+				if (! @copy(WP_CONTENT_DIR . '/themes/' . WP_DEFAULT_THEME . '/index.php', "$site_dir/$newfile")) {
2674
+									return false;
2675
+				}
2561 2676
 
2562 2677
 				// Don't copy anything.
2563 2678
 				continue;
2564 2679
 			}
2565 2680
 		}
2566 2681
 
2567
-		if (! @copy("$oldpath/$oldfile", "$site_dir/$newfile"))
2568
-			return false;
2682
+		if (! @copy("$oldpath/$oldfile", "$site_dir/$newfile")) {
2683
+					return false;
2684
+		}
2569 2685
 
2570 2686
 		chmod("$site_dir/$newfile", 0777);
2571 2687
 
@@ -2575,8 +2691,9 @@  discard block
 block discarded – undo
2575 2691
 			$f = fopen("$site_dir/$newfile", 'w');
2576 2692
 
2577 2693
 			foreach ($lines as $line) {
2578
-				if (preg_match('/require.*wp-blog-header/', $line))
2579
-					$line = '//' . $line;
2694
+				if (preg_match('/require.*wp-blog-header/', $line)) {
2695
+									$line = '//' . $line;
2696
+				}
2580 2697
 
2581 2698
 				// Update stylesheet references.
2582 2699
 				$line = str_replace("<?php echo __get_option('siteurl'); ?>/wp-layout.css", "<?php bloginfo('stylesheet_url'); ?>", $line);
@@ -2626,10 +2743,12 @@  discard block
 block discarded – undo
2626 2743
 	$theme_dir = @ opendir($default_dir);
2627 2744
 	if ($theme_dir) {
2628 2745
 		while(($theme_file = readdir( $theme_dir )) !== false) {
2629
-			if (is_dir("$default_dir/$theme_file"))
2630
-				continue;
2631
-			if (! @copy("$default_dir/$theme_file", "$site_dir/$theme_file"))
2632
-				return;
2746
+			if (is_dir("$default_dir/$theme_file")) {
2747
+							continue;
2748
+			}
2749
+			if (! @copy("$default_dir/$theme_file", "$site_dir/$theme_file")) {
2750
+							return;
2751
+			}
2633 2752
 			chmod("$site_dir/$theme_file", 0777);
2634 2753
 		}
2635 2754
 	}
@@ -2641,11 +2760,17 @@  discard block
 block discarded – undo
2641 2760
 		$f = fopen("$site_dir/style.css", 'w');
2642 2761
 
2643 2762
 		foreach ($stylelines as $line) {
2644
-			if (strpos($line, 'Theme Name:') !== false) $line = 'Theme Name: ' . $theme_name;
2645
-			elseif (strpos($line, 'Theme URI:') !== false) $line = 'Theme URI: ' . __get_option('url');
2646
-			elseif (strpos($line, 'Description:') !== false) $line = 'Description: Your theme.';
2647
-			elseif (strpos($line, 'Version:') !== false) $line = 'Version: 1';
2648
-			elseif (strpos($line, 'Author:') !== false) $line = 'Author: You';
2763
+			if (strpos($line, 'Theme Name:') !== false) {
2764
+				$line = 'Theme Name: ' . $theme_name;
2765
+			} elseif (strpos($line, 'Theme URI:') !== false) {
2766
+				$line = 'Theme URI: ' . __get_option('url');
2767
+			} elseif (strpos($line, 'Description:') !== false) {
2768
+				$line = 'Description: Your theme.';
2769
+			} elseif (strpos($line, 'Version:') !== false) {
2770
+				$line = 'Version: 1';
2771
+			} elseif (strpos($line, 'Author:') !== false) {
2772
+				$line = 'Author: You';
2773
+			}
2649 2774
 			fwrite($f, $line . "\n");
2650 2775
 		}
2651 2776
 		fclose($f);
@@ -2660,10 +2785,12 @@  discard block
 block discarded – undo
2660 2785
 	$images_dir = @ opendir("$default_dir/images");
2661 2786
 	if ($images_dir) {
2662 2787
 		while(($image = readdir($images_dir)) !== false) {
2663
-			if (is_dir("$default_dir/images/$image"))
2664
-				continue;
2665
-			if (! @copy("$default_dir/images/$image", "$site_dir/images/$image"))
2666
-				return;
2788
+			if (is_dir("$default_dir/images/$image")) {
2789
+							continue;
2790
+			}
2791
+			if (! @copy("$default_dir/images/$image", "$site_dir/images/$image")) {
2792
+							return;
2793
+			}
2667 2794
 			chmod("$site_dir/images/$image", 0777);
2668 2795
 		}
2669 2796
 	}
@@ -2706,9 +2833,10 @@  discard block
 block discarded – undo
2706 2833
 			return false;
2707 2834
 		}
2708 2835
 	} else {
2709
-		if (! make_site_theme_from_default($theme_name, $template))
2710
-			// TODO: rm -rf the site theme directory.
2836
+		if (! make_site_theme_from_default($theme_name, $template)) {
2837
+					// TODO: rm -rf the site theme directory.
2711 2838
 			return false;
2839
+		}
2712 2840
 	}
2713 2841
 
2714 2842
 	// Make the new site theme active.
@@ -2759,9 +2887,10 @@  discard block
 block discarded – undo
2759 2887
 function wp_check_mysql_version() {
2760 2888
 	global $wpdb;
2761 2889
 	$result = $wpdb->check_database_version();
2762
-	if ( is_wp_error( $result ) )
2763
-		die( $result->get_error_message() );
2764
-}
2890
+	if ( is_wp_error( $result ) ) {
2891
+			die( $result->get_error_message() );
2892
+	}
2893
+	}
2765 2894
 
2766 2895
 /**
2767 2896
  * Disables the Automattic widgets plugin, which was merged into core.
@@ -2791,9 +2920,10 @@  discard block
 block discarded – undo
2791 2920
 function maybe_disable_link_manager() {
2792 2921
 	global $wp_current_db_version, $wpdb;
2793 2922
 
2794
-	if ( $wp_current_db_version >= 22006 && get_option( 'link_manager_enabled' ) && ! $wpdb->get_var( "SELECT link_id FROM $wpdb->links LIMIT 1" ) )
2795
-		update_option( 'link_manager_enabled', 0 );
2796
-}
2923
+	if ( $wp_current_db_version >= 22006 && get_option( 'link_manager_enabled' ) && ! $wpdb->get_var( "SELECT link_id FROM $wpdb->links LIMIT 1" ) ) {
2924
+			update_option( 'link_manager_enabled', 0 );
2925
+	}
2926
+	}
2797 2927
 
2798 2928
 /**
2799 2929
  * Runs before the schema is upgraded.
Please login to merge, or discard this patch.
Spacing   +609 added lines, -609 removed lines patch added patch discarded remove patch
@@ -9,16 +9,16 @@  discard block
 block discarded – undo
9 9
  */
10 10
 
11 11
 /** Include user install customize script. */
12
-if ( file_exists(WP_CONTENT_DIR . '/install.php') )
13
-	require (WP_CONTENT_DIR . '/install.php');
12
+if (file_exists(WP_CONTENT_DIR.'/install.php'))
13
+	require (WP_CONTENT_DIR.'/install.php');
14 14
 
15 15
 /** WordPress Administration API */
16
-require_once(ABSPATH . 'wp-admin/includes/admin.php');
16
+require_once(ABSPATH.'wp-admin/includes/admin.php');
17 17
 
18 18
 /** WordPress Schema API */
19
-require_once(ABSPATH . 'wp-admin/includes/schema.php');
19
+require_once(ABSPATH.'wp-admin/includes/schema.php');
20 20
 
21
-if ( !function_exists('wp_install') ) :
21
+if ( ! function_exists('wp_install')) :
22 22
 /**
23 23
  * Installs the site.
24 24
  *
@@ -36,9 +36,9 @@  discard block
 block discarded – undo
36 36
  * @param string $language      Optional. Language chosen. Default empty.
37 37
  * @return array Array keys 'url', 'user_id', 'password', and 'password_message'.
38 38
  */
39
-function wp_install( $blog_title, $user_name, $user_email, $public, $deprecated = '', $user_password = '', $language = '' ) {
40
-	if ( !empty( $deprecated ) )
41
-		_deprecated_argument( __FUNCTION__, '2.6.0' );
39
+function wp_install($blog_title, $user_name, $user_email, $public, $deprecated = '', $user_password = '', $language = '') {
40
+	if ( ! empty($deprecated))
41
+		_deprecated_argument(__FUNCTION__, '2.6.0');
42 42
 
43 43
 	wp_check_mysql_version();
44 44
 	wp_cache_flush();
@@ -51,10 +51,10 @@  discard block
 block discarded – undo
51 51
 	update_option('blog_public', $public);
52 52
 
53 53
 	// Freshness of site - in the future, this could get more specific about actions taken, perhaps.
54
-	update_option( 'fresh_site', 1 );
54
+	update_option('fresh_site', 1);
55 55
 
56
-	if ( $language ) {
57
-		update_option( 'WPLANG', $language );
56
+	if ($language) {
57
+		update_option('WPLANG', $language);
58 58
 	}
59 59
 
60 60
 	$guessurl = wp_guess_url();
@@ -62,7 +62,7 @@  discard block
 block discarded – undo
62 62
 	update_option('siteurl', $guessurl);
63 63
 
64 64
 	// If not a public blog, don't ping.
65
-	if ( ! $public )
65
+	if ( ! $public)
66 66
 		update_option('default_pingback_flag', 0);
67 67
 
68 68
 	/*
@@ -72,13 +72,13 @@  discard block
 block discarded – undo
72 72
 	$user_id = username_exists($user_name);
73 73
 	$user_password = trim($user_password);
74 74
 	$email_password = false;
75
-	if ( !$user_id && empty($user_password) ) {
76
-		$user_password = wp_generate_password( 12, false );
75
+	if ( ! $user_id && empty($user_password)) {
76
+		$user_password = wp_generate_password(12, false);
77 77
 		$message = __('<strong><em>Note that password</em></strong> carefully! It is a <em>random</em> password that was generated just for you.');
78 78
 		$user_id = wp_create_user($user_name, $user_password, $user_email);
79 79
 		update_user_option($user_id, 'default_password_nag', true, true);
80 80
 		$email_password = true;
81
-	} elseif ( ! $user_id ) {
81
+	} elseif ( ! $user_id) {
82 82
 		// Password has been provided
83 83
 		$message = '<em>'.__('Your chosen password.').'</em>';
84 84
 		$user_id = wp_create_user($user_name, $user_password, $user_email);
@@ -95,7 +95,7 @@  discard block
 block discarded – undo
95 95
 
96 96
 	flush_rewrite_rules();
97 97
 
98
-	wp_new_blog_notification($blog_title, $guessurl, $user_id, ($email_password ? $user_password : __('The password you chose during the install.') ) );
98
+	wp_new_blog_notification($blog_title, $guessurl, $user_id, ($email_password ? $user_password : __('The password you chose during the install.')));
99 99
 
100 100
 	wp_cache_flush();
101 101
 
@@ -106,13 +106,13 @@  discard block
 block discarded – undo
106 106
 	 *
107 107
 	 * @param WP_User $user The site owner.
108 108
 	 */
109
-	do_action( 'wp_install', $user );
109
+	do_action('wp_install', $user);
110 110
 
111 111
 	return array('url' => $guessurl, 'user_id' => $user_id, 'password' => $user_password, 'password_message' => $message);
112 112
 }
113 113
 endif;
114 114
 
115
-if ( !function_exists('wp_install_defaults') ) :
115
+if ( ! function_exists('wp_install_defaults')) :
116 116
 /**
117 117
  * Creates the initial content for a newly-installed site.
118 118
  *
@@ -127,7 +127,7 @@  discard block
 block discarded – undo
127 127
  *
128 128
  * @param int $user_id User ID.
129 129
  */
130
-function wp_install_defaults( $user_id ) {
130
+function wp_install_defaults($user_id) {
131 131
 	global $wpdb, $wp_rewrite, $table_prefix;
132 132
 
133 133
 	// Default category
@@ -135,10 +135,10 @@  discard block
 block discarded – undo
135 135
 	/* translators: Default category slug */
136 136
 	$cat_slug = sanitize_title(_x('Uncategorized', 'Default category slug'));
137 137
 
138
-	if ( global_terms_enabled() ) {
139
-		$cat_id = $wpdb->get_var( $wpdb->prepare( "SELECT cat_ID FROM {$wpdb->sitecategories} WHERE category_nicename = %s", $cat_slug ) );
140
-		if ( $cat_id == null ) {
141
-			$wpdb->insert( $wpdb->sitecategories, array('cat_ID' => 0, 'cat_name' => $cat_name, 'category_nicename' => $cat_slug, 'last_updated' => current_time('mysql', true)) );
138
+	if (global_terms_enabled()) {
139
+		$cat_id = $wpdb->get_var($wpdb->prepare("SELECT cat_ID FROM {$wpdb->sitecategories} WHERE category_nicename = %s", $cat_slug));
140
+		if ($cat_id == null) {
141
+			$wpdb->insert($wpdb->sitecategories, array('cat_ID' => 0, 'cat_name' => $cat_name, 'category_nicename' => $cat_slug, 'last_updated' => current_time('mysql', true)));
142 142
 			$cat_id = $wpdb->insert_id;
143 143
 		}
144 144
 		update_option('default_category', $cat_id);
@@ -146,35 +146,35 @@  discard block
 block discarded – undo
146 146
 		$cat_id = 1;
147 147
 	}
148 148
 
149
-	$wpdb->insert( $wpdb->terms, array('term_id' => $cat_id, 'name' => $cat_name, 'slug' => $cat_slug, 'term_group' => 0) );
150
-	$wpdb->insert( $wpdb->term_taxonomy, array('term_id' => $cat_id, 'taxonomy' => 'category', 'description' => '', 'parent' => 0, 'count' => 1));
149
+	$wpdb->insert($wpdb->terms, array('term_id' => $cat_id, 'name' => $cat_name, 'slug' => $cat_slug, 'term_group' => 0));
150
+	$wpdb->insert($wpdb->term_taxonomy, array('term_id' => $cat_id, 'taxonomy' => 'category', 'description' => '', 'parent' => 0, 'count' => 1));
151 151
 	$cat_tt_id = $wpdb->insert_id;
152 152
 
153 153
 	// First post
154
-	$now = current_time( 'mysql' );
155
-	$now_gmt = current_time( 'mysql', 1 );
156
-	$first_post_guid = get_option( 'home' ) . '/?p=1';
154
+	$now = current_time('mysql');
155
+	$now_gmt = current_time('mysql', 1);
156
+	$first_post_guid = get_option('home').'/?p=1';
157 157
 
158
-	if ( is_multisite() ) {
159
-		$first_post = get_site_option( 'first_post' );
158
+	if (is_multisite()) {
159
+		$first_post = get_site_option('first_post');
160 160
 
161
-		if ( ! $first_post ) {
161
+		if ( ! $first_post) {
162 162
 			/* translators: %s: site link */
163
-			$first_post = __( 'Welcome to %s. This is your first post. Edit or delete it, then start blogging!' );
163
+			$first_post = __('Welcome to %s. This is your first post. Edit or delete it, then start blogging!');
164 164
 		}
165 165
 
166
-		$first_post = sprintf( $first_post,
167
-			sprintf( '<a href="%s">%s</a>', esc_url( network_home_url() ), get_network()->site_name )
166
+		$first_post = sprintf($first_post,
167
+			sprintf('<a href="%s">%s</a>', esc_url(network_home_url()), get_network()->site_name)
168 168
 		);
169 169
 
170 170
 		// Back-compat for pre-4.4
171
-		$first_post = str_replace( 'SITE_URL', esc_url( network_home_url() ), $first_post );
172
-		$first_post = str_replace( 'SITE_NAME', get_network()->site_name, $first_post );
171
+		$first_post = str_replace('SITE_URL', esc_url(network_home_url()), $first_post);
172
+		$first_post = str_replace('SITE_NAME', get_network()->site_name, $first_post);
173 173
 	} else {
174
-		$first_post = __( 'Welcome to WordPress. This is your first post. Edit or delete it, then start writing!' );
174
+		$first_post = __('Welcome to WordPress. This is your first post. Edit or delete it, then start writing!');
175 175
 	}
176 176
 
177
-	$wpdb->insert( $wpdb->posts, array(
177
+	$wpdb->insert($wpdb->posts, array(
178 178
 		'post_author' => $user_id,
179 179
 		'post_date' => $now,
180 180
 		'post_date_gmt' => $now_gmt,
@@ -182,7 +182,7 @@  discard block
 block discarded – undo
182 182
 		'post_excerpt' => '',
183 183
 		'post_title' => __('Hello world!'),
184 184
 		/* translators: Default post slug */
185
-		'post_name' => sanitize_title( _x('hello-world', 'Default post slug') ),
185
+		'post_name' => sanitize_title(_x('hello-world', 'Default post slug')),
186 186
 		'post_modified' => $now,
187 187
 		'post_modified_gmt' => $now_gmt,
188 188
 		'guid' => $first_post_guid,
@@ -191,22 +191,22 @@  discard block
 block discarded – undo
191 191
 		'pinged' => '',
192 192
 		'post_content_filtered' => ''
193 193
 	));
194
-	$wpdb->insert( $wpdb->term_relationships, array('term_taxonomy_id' => $cat_tt_id, 'object_id' => 1) );
194
+	$wpdb->insert($wpdb->term_relationships, array('term_taxonomy_id' => $cat_tt_id, 'object_id' => 1));
195 195
 
196 196
 	// Default comment
197
-	$first_comment_author = __( 'A WordPress Commenter' );
197
+	$first_comment_author = __('A WordPress Commenter');
198 198
 	$first_comment_email = '[email protected]';
199 199
 	$first_comment_url = 'https://wordpress.org/';
200
-	$first_comment = __( 'Hi, this is a comment.
200
+	$first_comment = __('Hi, this is a comment.
201 201
 To get started with moderating, editing, and deleting comments, please visit the Comments screen in the dashboard.
202 202
 Commenter avatars come from <a href="https://gravatar.com">Gravatar</a>.' );
203
-	if ( is_multisite() ) {
204
-		$first_comment_author = get_site_option( 'first_comment_author', $first_comment_author );
205
-		$first_comment_email = get_site_option( 'first_comment_email', $first_comment_email );
206
-		$first_comment_url = get_site_option( 'first_comment_url', network_home_url() );
207
-		$first_comment = get_site_option( 'first_comment', $first_comment );
203
+	if (is_multisite()) {
204
+		$first_comment_author = get_site_option('first_comment_author', $first_comment_author);
205
+		$first_comment_email = get_site_option('first_comment_email', $first_comment_email);
206
+		$first_comment_url = get_site_option('first_comment_url', network_home_url());
207
+		$first_comment = get_site_option('first_comment', $first_comment);
208 208
 	}
209
-	$wpdb->insert( $wpdb->comments, array(
209
+	$wpdb->insert($wpdb->comments, array(
210 210
 		'comment_post_ID' => 1,
211 211
 		'comment_author' => $first_comment_author,
212 212
 		'comment_author_email' => $first_comment_email,
@@ -217,7 +217,7 @@  discard block
 block discarded – undo
217 217
 	));
218 218
 
219 219
 	// First Page
220
-	$first_page = sprintf( __( "This is an example page. It's different from a blog post because it will stay in one place and will show up in your site navigation (in most themes). Most people start with an About page that introduces them to potential site visitors. It might say something like this:
220
+	$first_page = sprintf(__("This is an example page. It's different from a blog post because it will stay in one place and will show up in your site navigation (in most themes). Most people start with an About page that introduces them to potential site visitors. It might say something like this:
221 221
 
222 222
 <blockquote>Hi there! I'm a bike messenger by day, aspiring actor by night, and this is my website. I live in Los Angeles, have a great dog named Jack, and I like pi&#241;a coladas. (And gettin' caught in the rain.)</blockquote>
223 223
 
@@ -225,20 +225,20 @@  discard block
 block discarded – undo
225 225
 
226 226
 <blockquote>The XYZ Doohickey Company was founded in 1971, and has been providing quality doohickeys to the public ever since. Located in Gotham City, XYZ employs over 2,000 people and does all kinds of awesome things for the Gotham community.</blockquote>
227 227
 
228
-As a new WordPress user, you should go to <a href=\"%s\">your dashboard</a> to delete this page and create new pages for your content. Have fun!" ), admin_url() );
229
-	if ( is_multisite() )
230
-		$first_page = get_site_option( 'first_page', $first_page );
231
-	$first_post_guid = get_option('home') . '/?page_id=2';
232
-	$wpdb->insert( $wpdb->posts, array(
228
+As a new WordPress user, you should go to <a href=\"%s\">your dashboard</a> to delete this page and create new pages for your content. Have fun!" ), admin_url());
229
+	if (is_multisite())
230
+		$first_page = get_site_option('first_page', $first_page);
231
+	$first_post_guid = get_option('home').'/?page_id=2';
232
+	$wpdb->insert($wpdb->posts, array(
233 233
 		'post_author' => $user_id,
234 234
 		'post_date' => $now,
235 235
 		'post_date_gmt' => $now_gmt,
236 236
 		'post_content' => $first_page,
237 237
 		'post_excerpt' => '',
238 238
 		'comment_status' => 'closed',
239
-		'post_title' => __( 'Sample Page' ),
239
+		'post_title' => __('Sample Page'),
240 240
 		/* translators: Default page slug */
241
-		'post_name' => __( 'sample-page' ),
241
+		'post_name' => __('sample-page'),
242 242
 		'post_modified' => $now,
243 243
 		'post_modified_gmt' => $now_gmt,
244 244
 		'guid' => $first_post_guid,
@@ -247,36 +247,36 @@  discard block
 block discarded – undo
247 247
 		'pinged' => '',
248 248
 		'post_content_filtered' => ''
249 249
 	));
250
-	$wpdb->insert( $wpdb->postmeta, array( 'post_id' => 2, 'meta_key' => '_wp_page_template', 'meta_value' => 'default' ) );
250
+	$wpdb->insert($wpdb->postmeta, array('post_id' => 2, 'meta_key' => '_wp_page_template', 'meta_value' => 'default'));
251 251
 
252 252
 	// Set up default widgets for default theme.
253
-	update_option( 'widget_search', array ( 2 => array ( 'title' => '' ), '_multiwidget' => 1 ) );
254
-	update_option( 'widget_recent-posts', array ( 2 => array ( 'title' => '', 'number' => 5 ), '_multiwidget' => 1 ) );
255
-	update_option( 'widget_recent-comments', array ( 2 => array ( 'title' => '', 'number' => 5 ), '_multiwidget' => 1 ) );
256
-	update_option( 'widget_archives', array ( 2 => array ( 'title' => '', 'count' => 0, 'dropdown' => 0 ), '_multiwidget' => 1 ) );
257
-	update_option( 'widget_categories', array ( 2 => array ( 'title' => '', 'count' => 0, 'hierarchical' => 0, 'dropdown' => 0 ), '_multiwidget' => 1 ) );
258
-	update_option( 'widget_meta', array ( 2 => array ( 'title' => '' ), '_multiwidget' => 1 ) );
259
-	update_option( 'sidebars_widgets', array( 'wp_inactive_widgets' => array(), 'sidebar-1' => array( 0 => 'search-2', 1 => 'recent-posts-2', 2 => 'recent-comments-2', 3 => 'archives-2', 4 => 'categories-2', 5 => 'meta-2' ), 'sidebar-2' => array(), 'sidebar-3' => array(), 'array_version' => 3 ) );
260
-	if ( ! is_multisite() )
261
-		update_user_meta( $user_id, 'show_welcome_panel', 1 );
262
-	elseif ( ! is_super_admin( $user_id ) && ! metadata_exists( 'user', $user_id, 'show_welcome_panel' ) )
263
-		update_user_meta( $user_id, 'show_welcome_panel', 2 );
264
-
265
-	if ( is_multisite() ) {
253
+	update_option('widget_search', array(2 => array('title' => ''), '_multiwidget' => 1));
254
+	update_option('widget_recent-posts', array(2 => array('title' => '', 'number' => 5), '_multiwidget' => 1));
255
+	update_option('widget_recent-comments', array(2 => array('title' => '', 'number' => 5), '_multiwidget' => 1));
256
+	update_option('widget_archives', array(2 => array('title' => '', 'count' => 0, 'dropdown' => 0), '_multiwidget' => 1));
257
+	update_option('widget_categories', array(2 => array('title' => '', 'count' => 0, 'hierarchical' => 0, 'dropdown' => 0), '_multiwidget' => 1));
258
+	update_option('widget_meta', array(2 => array('title' => ''), '_multiwidget' => 1));
259
+	update_option('sidebars_widgets', array('wp_inactive_widgets' => array(), 'sidebar-1' => array(0 => 'search-2', 1 => 'recent-posts-2', 2 => 'recent-comments-2', 3 => 'archives-2', 4 => 'categories-2', 5 => 'meta-2'), 'sidebar-2' => array(), 'sidebar-3' => array(), 'array_version' => 3));
260
+	if ( ! is_multisite())
261
+		update_user_meta($user_id, 'show_welcome_panel', 1);
262
+	elseif ( ! is_super_admin($user_id) && ! metadata_exists('user', $user_id, 'show_welcome_panel'))
263
+		update_user_meta($user_id, 'show_welcome_panel', 2);
264
+
265
+	if (is_multisite()) {
266 266
 		// Flush rules to pick up the new page.
267 267
 		$wp_rewrite->init();
268 268
 		$wp_rewrite->flush_rules();
269 269
 
270 270
 		$user = new WP_User($user_id);
271
-		$wpdb->update( $wpdb->options, array('option_value' => $user->user_email), array('option_name' => 'admin_email') );
271
+		$wpdb->update($wpdb->options, array('option_value' => $user->user_email), array('option_name' => 'admin_email'));
272 272
 
273 273
 		// Remove all perms except for the login user.
274
-		$wpdb->query( $wpdb->prepare("DELETE FROM $wpdb->usermeta WHERE user_id != %d AND meta_key = %s", $user_id, $table_prefix.'user_level') );
275
-		$wpdb->query( $wpdb->prepare("DELETE FROM $wpdb->usermeta WHERE user_id != %d AND meta_key = %s", $user_id, $table_prefix.'capabilities') );
274
+		$wpdb->query($wpdb->prepare("DELETE FROM $wpdb->usermeta WHERE user_id != %d AND meta_key = %s", $user_id, $table_prefix.'user_level'));
275
+		$wpdb->query($wpdb->prepare("DELETE FROM $wpdb->usermeta WHERE user_id != %d AND meta_key = %s", $user_id, $table_prefix.'capabilities'));
276 276
 
277 277
 		// Delete any caps that snuck into the previously active blog. (Hardcoded to blog 1 for now.) TODO: Get previous_blog_id.
278
-		if ( !is_super_admin( $user_id ) && $user_id != 1 )
279
-			$wpdb->delete( $wpdb->usermeta, array( 'user_id' => $user_id , 'meta_key' => $wpdb->base_prefix.'1_capabilities' ) );
278
+		if ( ! is_super_admin($user_id) && $user_id != 1)
279
+			$wpdb->delete($wpdb->usermeta, array('user_id' => $user_id, 'meta_key' => $wpdb->base_prefix.'1_capabilities'));
280 280
 	}
281 281
 }
282 282
 endif;
@@ -296,7 +296,7 @@  discard block
 block discarded – undo
296 296
 	global $wp_rewrite;
297 297
 
298 298
 	// Bail if a permalink structure is already enabled.
299
-	if ( get_option( 'permalink_structure' ) ) {
299
+	if (get_option('permalink_structure')) {
300 300
 		return true;
301 301
 	}
302 302
 
@@ -313,21 +313,21 @@  discard block
 block discarded – undo
313 313
 		'/index.php/%year%/%monthnum%/%day%/%postname%/'
314 314
 	);
315 315
 
316
-	foreach ( (array) $permalink_structures as $permalink_structure ) {
317
-		$wp_rewrite->set_permalink_structure( $permalink_structure );
316
+	foreach ((array) $permalink_structures as $permalink_structure) {
317
+		$wp_rewrite->set_permalink_structure($permalink_structure);
318 318
 
319 319
 		/*
320 320
 	 	 * Flush rules with the hard option to force refresh of the web-server's
321 321
 	 	 * rewrite config file (e.g. .htaccess or web.config).
322 322
 	 	 */
323
-		$wp_rewrite->flush_rules( true );
323
+		$wp_rewrite->flush_rules(true);
324 324
 
325 325
 		$test_url = '';
326 326
 
327 327
 		// Test against a real WordPress Post
328
-		$first_post = get_page_by_path( sanitize_title( _x( 'hello-world', 'Default post slug' ) ), OBJECT, 'post' );
329
-		if ( $first_post ) {
330
-			$test_url = get_permalink( $first_post->ID );
328
+		$first_post = get_page_by_path(sanitize_title(_x('hello-world', 'Default post slug')), OBJECT, 'post');
329
+		if ($first_post) {
330
+			$test_url = get_permalink($first_post->ID);
331 331
 		}
332 332
 
333 333
 		/*
@@ -337,11 +337,11 @@  discard block
 block discarded – undo
337 337
 	 	 * Uses wp_remote_get() instead of wp_remote_head() because web servers
338 338
 	 	 * can block head requests.
339 339
 	 	 */
340
-		$response          = wp_remote_get( $test_url, array( 'timeout' => 5 ) );
341
-		$x_pingback_header = wp_remote_retrieve_header( $response, 'x-pingback' );
342
-		$pretty_permalinks = $x_pingback_header && $x_pingback_header === get_bloginfo( 'pingback_url' );
340
+		$response          = wp_remote_get($test_url, array('timeout' => 5));
341
+		$x_pingback_header = wp_remote_retrieve_header($response, 'x-pingback');
342
+		$pretty_permalinks = $x_pingback_header && $x_pingback_header === get_bloginfo('pingback_url');
343 343
 
344
-		if ( $pretty_permalinks ) {
344
+		if ($pretty_permalinks) {
345 345
 			return true;
346 346
 		}
347 347
 	}
@@ -350,13 +350,13 @@  discard block
 block discarded – undo
350 350
 	 * If it makes it this far, pretty permalinks failed.
351 351
 	 * Fallback to query-string permalinks.
352 352
 	 */
353
-	$wp_rewrite->set_permalink_structure( '' );
354
-	$wp_rewrite->flush_rules( true );
353
+	$wp_rewrite->set_permalink_structure('');
354
+	$wp_rewrite->flush_rules(true);
355 355
 
356 356
 	return false;
357 357
 }
358 358
 
359
-if ( !function_exists('wp_new_blog_notification') ) :
359
+if ( ! function_exists('wp_new_blog_notification')) :
360 360
 /**
361 361
  * Notifies the site admin that the setup is complete.
362 362
  *
@@ -371,12 +371,12 @@  discard block
 block discarded – undo
371 371
  * @param string $password   User's Password.
372 372
  */
373 373
 function wp_new_blog_notification($blog_title, $blog_url, $user_id, $password) {
374
-	$user = new WP_User( $user_id );
374
+	$user = new WP_User($user_id);
375 375
 	$email = $user->user_email;
376 376
 	$name = $user->user_login;
377 377
 	$login_url = wp_login_url();
378 378
 	/* translators: New site notification email. 1: New site URL, 2: User login, 3: User password or password reset link, 4: Login URL */
379
-	$message = sprintf( __( "Your new WordPress site has been successfully set up at:
379
+	$message = sprintf(__("Your new WordPress site has been successfully set up at:
380 380
 
381 381
 %1\$s
382 382
 
@@ -390,13 +390,13 @@  discard block
 block discarded – undo
390 390
 
391 391
 --The WordPress Team
392 392
 https://wordpress.org/
393
-"), $blog_url, $name, $password, $login_url );
393
+"), $blog_url, $name, $password, $login_url);
394 394
 
395 395
 	@wp_mail($email, __('New WordPress Site'), $message);
396 396
 }
397 397
 endif;
398 398
 
399
-if ( !function_exists('wp_upgrade') ) :
399
+if ( ! function_exists('wp_upgrade')) :
400 400
 /**
401 401
  * Runs WordPress Upgrade functions.
402 402
  *
@@ -414,10 +414,10 @@  discard block
 block discarded – undo
414 414
 	$wp_current_db_version = __get_option('db_version');
415 415
 
416 416
 	// We are up-to-date. Nothing to do.
417
-	if ( $wp_db_version == $wp_current_db_version )
417
+	if ($wp_db_version == $wp_current_db_version)
418 418
 		return;
419 419
 
420
-	if ( ! is_blog_installed() )
420
+	if ( ! is_blog_installed())
421 421
 		return;
422 422
 
423 423
 	wp_check_mysql_version();
@@ -425,15 +425,15 @@  discard block
 block discarded – undo
425 425
 	pre_schema_upgrade();
426 426
 	make_db_current_silent();
427 427
 	upgrade_all();
428
-	if ( is_multisite() && is_main_site() )
428
+	if (is_multisite() && is_main_site())
429 429
 		upgrade_network();
430 430
 	wp_cache_flush();
431 431
 
432
-	if ( is_multisite() ) {
433
-		if ( $wpdb->get_row( "SELECT blog_id FROM {$wpdb->blog_versions} WHERE blog_id = '{$wpdb->blogid}'" ) )
434
-			$wpdb->query( "UPDATE {$wpdb->blog_versions} SET db_version = '{$wp_db_version}' WHERE blog_id = '{$wpdb->blogid}'" );
432
+	if (is_multisite()) {
433
+		if ($wpdb->get_row("SELECT blog_id FROM {$wpdb->blog_versions} WHERE blog_id = '{$wpdb->blogid}'"))
434
+			$wpdb->query("UPDATE {$wpdb->blog_versions} SET db_version = '{$wp_db_version}' WHERE blog_id = '{$wpdb->blogid}'");
435 435
 		else
436
-			$wpdb->query( "INSERT INTO {$wpdb->blog_versions} ( `blog_id` , `db_version` , `last_updated` ) VALUES ( '{$wpdb->blogid}', '{$wp_db_version}', NOW());" );
436
+			$wpdb->query("INSERT INTO {$wpdb->blog_versions} ( `blog_id` , `db_version` , `last_updated` ) VALUES ( '{$wpdb->blogid}', '{$wp_db_version}', NOW());");
437 437
 	}
438 438
 
439 439
 	/**
@@ -444,7 +444,7 @@  discard block
 block discarded – undo
444 444
 	 * @param int $wp_db_version         The new $wp_db_version.
445 445
 	 * @param int $wp_current_db_version The old (current) $wp_db_version.
446 446
 	 */
447
-	do_action( 'wp_upgrade', $wp_db_version, $wp_current_db_version );
447
+	do_action('wp_upgrade', $wp_db_version, $wp_current_db_version);
448 448
 }
449 449
 endif;
450 450
 
@@ -465,109 +465,109 @@  discard block
 block discarded – undo
465 465
 	$wp_current_db_version = __get_option('db_version');
466 466
 
467 467
 	// We are up-to-date. Nothing to do.
468
-	if ( $wp_db_version == $wp_current_db_version )
468
+	if ($wp_db_version == $wp_current_db_version)
469 469
 		return;
470 470
 
471 471
 	// If the version is not set in the DB, try to guess the version.
472
-	if ( empty($wp_current_db_version) ) {
472
+	if (empty($wp_current_db_version)) {
473 473
 		$wp_current_db_version = 0;
474 474
 
475 475
 		// If the template option exists, we have 1.5.
476 476
 		$template = __get_option('template');
477
-		if ( !empty($template) )
477
+		if ( ! empty($template))
478 478
 			$wp_current_db_version = 2541;
479 479
 	}
480 480
 
481
-	if ( $wp_current_db_version < 6039 )
481
+	if ($wp_current_db_version < 6039)
482 482
 		upgrade_230_options_table();
483 483
 
484 484
 	populate_options();
485 485
 
486
-	if ( $wp_current_db_version < 2541 ) {
486
+	if ($wp_current_db_version < 2541) {
487 487
 		upgrade_100();
488 488
 		upgrade_101();
489 489
 		upgrade_110();
490 490
 		upgrade_130();
491 491
 	}
492 492
 
493
-	if ( $wp_current_db_version < 3308 )
493
+	if ($wp_current_db_version < 3308)
494 494
 		upgrade_160();
495 495
 
496
-	if ( $wp_current_db_version < 4772 )
496
+	if ($wp_current_db_version < 4772)
497 497
 		upgrade_210();
498 498
 
499
-	if ( $wp_current_db_version < 4351 )
499
+	if ($wp_current_db_version < 4351)
500 500
 		upgrade_old_slugs();
501 501
 
502
-	if ( $wp_current_db_version < 5539 )
502
+	if ($wp_current_db_version < 5539)
503 503
 		upgrade_230();
504 504
 
505
-	if ( $wp_current_db_version < 6124 )
505
+	if ($wp_current_db_version < 6124)
506 506
 		upgrade_230_old_tables();
507 507
 
508
-	if ( $wp_current_db_version < 7499 )
508
+	if ($wp_current_db_version < 7499)
509 509
 		upgrade_250();
510 510
 
511
-	if ( $wp_current_db_version < 7935 )
511
+	if ($wp_current_db_version < 7935)
512 512
 		upgrade_252();
513 513
 
514
-	if ( $wp_current_db_version < 8201 )
514
+	if ($wp_current_db_version < 8201)
515 515
 		upgrade_260();
516 516
 
517
-	if ( $wp_current_db_version < 8989 )
517
+	if ($wp_current_db_version < 8989)
518 518
 		upgrade_270();
519 519
 
520
-	if ( $wp_current_db_version < 10360 )
520
+	if ($wp_current_db_version < 10360)
521 521
 		upgrade_280();
522 522
 
523
-	if ( $wp_current_db_version < 11958 )
523
+	if ($wp_current_db_version < 11958)
524 524
 		upgrade_290();
525 525
 
526
-	if ( $wp_current_db_version < 15260 )
526
+	if ($wp_current_db_version < 15260)
527 527
 		upgrade_300();
528 528
 
529
-	if ( $wp_current_db_version < 19389 )
529
+	if ($wp_current_db_version < 19389)
530 530
 		upgrade_330();
531 531
 
532
-	if ( $wp_current_db_version < 20080 )
532
+	if ($wp_current_db_version < 20080)
533 533
 		upgrade_340();
534 534
 
535
-	if ( $wp_current_db_version < 22422 )
535
+	if ($wp_current_db_version < 22422)
536 536
 		upgrade_350();
537 537
 
538
-	if ( $wp_current_db_version < 25824 )
538
+	if ($wp_current_db_version < 25824)
539 539
 		upgrade_370();
540 540
 
541
-	if ( $wp_current_db_version < 26148 )
541
+	if ($wp_current_db_version < 26148)
542 542
 		upgrade_372();
543 543
 
544
-	if ( $wp_current_db_version < 26691 )
544
+	if ($wp_current_db_version < 26691)
545 545
 		upgrade_380();
546 546
 
547
-	if ( $wp_current_db_version < 29630 )
547
+	if ($wp_current_db_version < 29630)
548 548
 		upgrade_400();
549 549
 
550
-	if ( $wp_current_db_version < 33055 )
550
+	if ($wp_current_db_version < 33055)
551 551
 		upgrade_430();
552 552
 
553
-	if ( $wp_current_db_version < 33056 )
553
+	if ($wp_current_db_version < 33056)
554 554
 		upgrade_431();
555 555
 
556
-	if ( $wp_current_db_version < 35700 )
556
+	if ($wp_current_db_version < 35700)
557 557
 		upgrade_440();
558 558
 
559
-	if ( $wp_current_db_version < 36686 )
559
+	if ($wp_current_db_version < 36686)
560 560
 		upgrade_450();
561 561
 
562
-	if ( $wp_current_db_version < 37965 )
562
+	if ($wp_current_db_version < 37965)
563 563
 		upgrade_460();
564 564
 
565 565
 	maybe_disable_link_manager();
566 566
 
567 567
 	maybe_disable_automattic_widgets();
568 568
 
569
-	update_option( 'db_version', $wp_db_version );
570
-	update_option( 'db_upgraded', true );
569
+	update_option('db_version', $wp_db_version);
570
+	update_option('db_upgraded', true);
571 571
 }
572 572
 
573 573
 /**
@@ -587,7 +587,7 @@  discard block
 block discarded – undo
587 587
 		foreach ($posts as $post) {
588 588
 			if ('' == $post->post_name) {
589 589
 				$newtitle = sanitize_title($post->post_title);
590
-				$wpdb->query( $wpdb->prepare("UPDATE $wpdb->posts SET post_name = %s WHERE ID = %d", $newtitle, $post->ID) );
590
+				$wpdb->query($wpdb->prepare("UPDATE $wpdb->posts SET post_name = %s WHERE ID = %d", $newtitle, $post->ID));
591 591
 			}
592 592
 		}
593 593
 	}
@@ -596,7 +596,7 @@  discard block
 block discarded – undo
596 596
 	foreach ($categories as $category) {
597 597
 		if ('' == $category->category_nicename) {
598 598
 			$newtitle = sanitize_title($category->cat_name);
599
-			$wpdb->update( $wpdb->categories, array('category_nicename' => $newtitle), array('cat_ID' => $category->cat_ID) );
599
+			$wpdb->update($wpdb->categories, array('category_nicename' => $newtitle), array('cat_ID' => $category->cat_ID));
600 600
 		}
601 601
 	}
602 602
 
@@ -604,7 +604,7 @@  discard block
 block discarded – undo
604 604
 		SET option_value = REPLACE(option_value, 'wp-links/links-images/', 'wp-images/links/')
605 605
 		WHERE option_name LIKE %s
606 606
 		AND option_value LIKE %s";
607
-	$wpdb->query( $wpdb->prepare( $sql, $wpdb->esc_like( 'links_rating_image' ) . '%', $wpdb->esc_like( 'wp-links/links-images/' ) . '%' ) );
607
+	$wpdb->query($wpdb->prepare($sql, $wpdb->esc_like('links_rating_image').'%', $wpdb->esc_like('wp-links/links-images/').'%'));
608 608
 
609 609
 	$done_ids = $wpdb->get_results("SELECT DISTINCT post_id FROM $wpdb->post2cat");
610 610
 	if ($done_ids) :
@@ -612,7 +612,7 @@  discard block
 block discarded – undo
612 612
 		foreach ($done_ids as $done_id) :
613 613
 			$done_posts[] = $done_id->post_id;
614 614
 		endforeach;
615
-		$catwhere = ' AND ID NOT IN (' . implode(',', $done_posts) . ')';
615
+		$catwhere = ' AND ID NOT IN ('.implode(',', $done_posts).')';
616 616
 	else:
617 617
 		$catwhere = '';
618 618
 	endif;
@@ -621,9 +621,9 @@  discard block
 block discarded – undo
621 621
 	if ($allposts) :
622 622
 		foreach ($allposts as $post) {
623 623
 			// Check to see if it's already been imported
624
-			$cat = $wpdb->get_row( $wpdb->prepare("SELECT * FROM $wpdb->post2cat WHERE post_id = %d AND category_id = %d", $post->ID, $post->post_category) );
625
-			if (!$cat && 0 != $post->post_category) { // If there's no result
626
-				$wpdb->insert( $wpdb->post2cat, array('post_id' => $post->ID, 'category_id' => $post->post_category) );
624
+			$cat = $wpdb->get_row($wpdb->prepare("SELECT * FROM $wpdb->post2cat WHERE post_id = %d AND category_id = %d", $post->ID, $post->post_category));
625
+			if ( ! $cat && 0 != $post->post_category) { // If there's no result
626
+				$wpdb->insert($wpdb->post2cat, array('post_id' => $post->ID, 'category_id' => $post->post_category));
627 627
 			}
628 628
 		}
629 629
 	endif;
@@ -646,8 +646,8 @@  discard block
 block discarded – undo
646 646
 	add_clean_index($wpdb->categories, 'category_nicename');
647 647
 	add_clean_index($wpdb->comments, 'comment_approved');
648 648
 	add_clean_index($wpdb->comments, 'comment_post_ID');
649
-	add_clean_index($wpdb->links , 'link_category');
650
-	add_clean_index($wpdb->links , 'link_visible');
649
+	add_clean_index($wpdb->links, 'link_category');
650
+	add_clean_index($wpdb->links, 'link_visible');
651 651
 }
652 652
 
653 653
 /**
@@ -666,14 +666,14 @@  discard block
 block discarded – undo
666 666
 	foreach ($users as $user) {
667 667
 		if ('' == $user->user_nicename) {
668 668
 			$newname = sanitize_title($user->user_nickname);
669
-			$wpdb->update( $wpdb->users, array('user_nicename' => $newname), array('ID' => $user->ID) );
669
+			$wpdb->update($wpdb->users, array('user_nicename' => $newname), array('ID' => $user->ID));
670 670
 		}
671 671
 	}
672 672
 
673 673
 	$users = $wpdb->get_results("SELECT ID, user_pass from $wpdb->users");
674 674
 	foreach ($users as $row) {
675
-		if (!preg_match('/^[A-Fa-f0-9]{32}$/', $row->user_pass)) {
676
-			$wpdb->update( $wpdb->users, array('user_pass' => md5($row->user_pass)), array('ID' => $row->ID) );
675
+		if ( ! preg_match('/^[A-Fa-f0-9]{32}$/', $row->user_pass)) {
676
+			$wpdb->update($wpdb->users, array('user_pass' => md5($row->user_pass)), array('ID' => $row->ID));
677 677
 		}
678 678
 	}
679 679
 
@@ -682,7 +682,7 @@  discard block
 block discarded – undo
682 682
 
683 683
 	$time_difference = $all_options->time_difference;
684 684
 
685
-		$server_time = time()+date('Z');
685
+		$server_time = time() + date('Z');
686 686
 	$weblogger_time = $server_time + $time_difference * HOUR_IN_SECONDS;
687 687
 	$gmt_time = time();
688 688
 
@@ -699,7 +699,7 @@  discard block
 block discarded – undo
699 699
 	// <michel_v> I just slapped myself silly for not thinking about it earlier
700 700
 	$got_gmt_fields = ! ($wpdb->get_var("SELECT MAX(post_date_gmt) FROM $wpdb->posts") == '0000-00-00 00:00:00');
701 701
 
702
-	if (!$got_gmt_fields) {
702
+	if ( ! $got_gmt_fields) {
703 703
 
704 704
 		// Add or subtract time to all dates, to get GMT dates
705 705
 		$add_hours = intval($diff_gmt_weblogger);
@@ -731,12 +731,12 @@  discard block
 block discarded – undo
731 731
 			$post_content = addslashes(deslash($post->post_content));
732 732
 			$post_title = addslashes(deslash($post->post_title));
733 733
 			$post_excerpt = addslashes(deslash($post->post_excerpt));
734
-			if ( empty($post->guid) )
734
+			if (empty($post->guid))
735 735
 				$guid = get_permalink($post->ID);
736 736
 			else
737 737
 				$guid = $post->guid;
738 738
 
739
-			$wpdb->update( $wpdb->posts, compact('post_title', 'post_content', 'post_excerpt', 'guid'), array('ID' => $post->ID) );
739
+			$wpdb->update($wpdb->posts, compact('post_title', 'post_content', 'post_excerpt', 'guid'), array('ID' => $post->ID));
740 740
 
741 741
 		}
742 742
 	}
@@ -748,7 +748,7 @@  discard block
 block discarded – undo
748 748
 			$comment_content = deslash($comment->comment_content);
749 749
 			$comment_author = deslash($comment->comment_author);
750 750
 
751
-			$wpdb->update($wpdb->comments, compact('comment_content', 'comment_author'), array('comment_ID' => $comment->comment_ID) );
751
+			$wpdb->update($wpdb->comments, compact('comment_content', 'comment_author'), array('comment_ID' => $comment->comment_ID));
752 752
 		}
753 753
 	}
754 754
 
@@ -759,7 +759,7 @@  discard block
 block discarded – undo
759 759
 			$link_name = deslash($link->link_name);
760 760
 			$link_description = deslash($link->link_description);
761 761
 
762
-			$wpdb->update( $wpdb->links, compact('link_name', 'link_description'), array('link_id' => $link->link_id) );
762
+			$wpdb->update($wpdb->links, compact('link_name', 'link_description'), array('link_id' => $link->link_id));
763 763
 		}
764 764
 	}
765 765
 
@@ -769,16 +769,16 @@  discard block
 block discarded – undo
769 769
 	 * If plugins are not stored in an array, they're stored in the old
770 770
 	 * newline separated format. Convert to new format.
771 771
 	 */
772
-	if ( !is_array( $active_plugins ) ) {
772
+	if ( ! is_array($active_plugins)) {
773 773
 		$active_plugins = explode("\n", trim($active_plugins));
774 774
 		update_option('active_plugins', $active_plugins);
775 775
 	}
776 776
 
777 777
 	// Obsolete tables
778
-	$wpdb->query('DROP TABLE IF EXISTS ' . $wpdb->prefix . 'optionvalues');
779
-	$wpdb->query('DROP TABLE IF EXISTS ' . $wpdb->prefix . 'optiontypes');
780
-	$wpdb->query('DROP TABLE IF EXISTS ' . $wpdb->prefix . 'optiongroups');
781
-	$wpdb->query('DROP TABLE IF EXISTS ' . $wpdb->prefix . 'optiongroup_options');
778
+	$wpdb->query('DROP TABLE IF EXISTS '.$wpdb->prefix.'optionvalues');
779
+	$wpdb->query('DROP TABLE IF EXISTS '.$wpdb->prefix.'optiontypes');
780
+	$wpdb->query('DROP TABLE IF EXISTS '.$wpdb->prefix.'optiongroups');
781
+	$wpdb->query('DROP TABLE IF EXISTS '.$wpdb->prefix.'optiongroup_options');
782 782
 
783 783
 	// Update comments table to use comment_type
784 784
 	$wpdb->query("UPDATE $wpdb->comments SET comment_type='trackback', comment_content = REPLACE(comment_content, '<trackback />', '') WHERE comment_content LIKE '<trackback />%'");
@@ -786,11 +786,11 @@  discard block
 block discarded – undo
786 786
 
787 787
 	// Some versions have multiple duplicate option_name rows with the same values
788 788
 	$options = $wpdb->get_results("SELECT option_name, COUNT(option_name) AS dupes FROM `$wpdb->options` GROUP BY option_name");
789
-	foreach ( $options as $option ) {
790
-		if ( 1 != $option->dupes ) { // Could this be done in the query?
789
+	foreach ($options as $option) {
790
+		if (1 != $option->dupes) { // Could this be done in the query?
791 791
 			$limit = $option->dupes - 1;
792
-			$dupe_ids = $wpdb->get_col( $wpdb->prepare("SELECT option_id FROM $wpdb->options WHERE option_name = %s LIMIT %d", $option->option_name, $limit) );
793
-			if ( $dupe_ids ) {
792
+			$dupe_ids = $wpdb->get_col($wpdb->prepare("SELECT option_id FROM $wpdb->options WHERE option_name = %s LIMIT %d", $option->option_name, $limit));
793
+			if ($dupe_ids) {
794 794
 				$dupe_ids = join($dupe_ids, ',');
795 795
 				$wpdb->query("DELETE FROM $wpdb->options WHERE option_id IN ($dupe_ids)");
796 796
 			}
@@ -815,27 +815,27 @@  discard block
 block discarded – undo
815 815
 	populate_roles_160();
816 816
 
817 817
 	$users = $wpdb->get_results("SELECT * FROM $wpdb->users");
818
-	foreach ( $users as $user ) :
819
-		if ( !empty( $user->user_firstname ) )
820
-			update_user_meta( $user->ID, 'first_name', wp_slash($user->user_firstname) );
821
-		if ( !empty( $user->user_lastname ) )
822
-			update_user_meta( $user->ID, 'last_name', wp_slash($user->user_lastname) );
823
-		if ( !empty( $user->user_nickname ) )
824
-			update_user_meta( $user->ID, 'nickname', wp_slash($user->user_nickname) );
825
-		if ( !empty( $user->user_level ) )
826
-			update_user_meta( $user->ID, $wpdb->prefix . 'user_level', $user->user_level );
827
-		if ( !empty( $user->user_icq ) )
828
-			update_user_meta( $user->ID, 'icq', wp_slash($user->user_icq) );
829
-		if ( !empty( $user->user_aim ) )
830
-			update_user_meta( $user->ID, 'aim', wp_slash($user->user_aim) );
831
-		if ( !empty( $user->user_msn ) )
832
-			update_user_meta( $user->ID, 'msn', wp_slash($user->user_msn) );
833
-		if ( !empty( $user->user_yim ) )
834
-			update_user_meta( $user->ID, 'yim', wp_slash($user->user_icq) );
835
-		if ( !empty( $user->user_description ) )
836
-			update_user_meta( $user->ID, 'description', wp_slash($user->user_description) );
837
-
838
-		if ( isset( $user->user_idmode ) ):
818
+	foreach ($users as $user) :
819
+		if ( ! empty($user->user_firstname))
820
+			update_user_meta($user->ID, 'first_name', wp_slash($user->user_firstname));
821
+		if ( ! empty($user->user_lastname))
822
+			update_user_meta($user->ID, 'last_name', wp_slash($user->user_lastname));
823
+		if ( ! empty($user->user_nickname))
824
+			update_user_meta($user->ID, 'nickname', wp_slash($user->user_nickname));
825
+		if ( ! empty($user->user_level))
826
+			update_user_meta($user->ID, $wpdb->prefix.'user_level', $user->user_level);
827
+		if ( ! empty($user->user_icq))
828
+			update_user_meta($user->ID, 'icq', wp_slash($user->user_icq));
829
+		if ( ! empty($user->user_aim))
830
+			update_user_meta($user->ID, 'aim', wp_slash($user->user_aim));
831
+		if ( ! empty($user->user_msn))
832
+			update_user_meta($user->ID, 'msn', wp_slash($user->user_msn));
833
+		if ( ! empty($user->user_yim))
834
+			update_user_meta($user->ID, 'yim', wp_slash($user->user_icq));
835
+		if ( ! empty($user->user_description))
836
+			update_user_meta($user->ID, 'description', wp_slash($user->user_description));
837
+
838
+		if (isset($user->user_idmode)):
839 839
 			$idmode = $user->user_idmode;
840 840
 			if ($idmode == 'nickname') $id = $user->user_nickname;
841 841
 			if ($idmode == 'login') $id = $user->user_login;
@@ -843,46 +843,46 @@  discard block
 block discarded – undo
843 843
 			if ($idmode == 'lastname') $id = $user->user_lastname;
844 844
 			if ($idmode == 'namefl') $id = $user->user_firstname.' '.$user->user_lastname;
845 845
 			if ($idmode == 'namelf') $id = $user->user_lastname.' '.$user->user_firstname;
846
-			if (!$idmode) $id = $user->user_nickname;
847
-			$wpdb->update( $wpdb->users, array('display_name' => $id), array('ID' => $user->ID) );
846
+			if ( ! $idmode) $id = $user->user_nickname;
847
+			$wpdb->update($wpdb->users, array('display_name' => $id), array('ID' => $user->ID));
848 848
 		endif;
849 849
 
850 850
 		// FIXME: RESET_CAPS is temporary code to reset roles and caps if flag is set.
851
-		$caps = get_user_meta( $user->ID, $wpdb->prefix . 'capabilities');
852
-		if ( empty($caps) || defined('RESET_CAPS') ) {
853
-			$level = get_user_meta($user->ID, $wpdb->prefix . 'user_level', true);
851
+		$caps = get_user_meta($user->ID, $wpdb->prefix.'capabilities');
852
+		if (empty($caps) || defined('RESET_CAPS')) {
853
+			$level = get_user_meta($user->ID, $wpdb->prefix.'user_level', true);
854 854
 			$role = translate_level_to_role($level);
855
-			update_user_meta( $user->ID, $wpdb->prefix . 'capabilities', array($role => true) );
855
+			update_user_meta($user->ID, $wpdb->prefix.'capabilities', array($role => true));
856 856
 		}
857 857
 
858 858
 	endforeach;
859
-	$old_user_fields = array( 'user_firstname', 'user_lastname', 'user_icq', 'user_aim', 'user_msn', 'user_yim', 'user_idmode', 'user_ip', 'user_domain', 'user_browser', 'user_description', 'user_nickname', 'user_level' );
859
+	$old_user_fields = array('user_firstname', 'user_lastname', 'user_icq', 'user_aim', 'user_msn', 'user_yim', 'user_idmode', 'user_ip', 'user_domain', 'user_browser', 'user_description', 'user_nickname', 'user_level');
860 860
 	$wpdb->hide_errors();
861
-	foreach ( $old_user_fields as $old )
861
+	foreach ($old_user_fields as $old)
862 862
 		$wpdb->query("ALTER TABLE $wpdb->users DROP $old");
863 863
 	$wpdb->show_errors();
864 864
 
865 865
 	// Populate comment_count field of posts table.
866
-	$comments = $wpdb->get_results( "SELECT comment_post_ID, COUNT(*) as c FROM $wpdb->comments WHERE comment_approved = '1' GROUP BY comment_post_ID" );
867
-	if ( is_array( $comments ) )
866
+	$comments = $wpdb->get_results("SELECT comment_post_ID, COUNT(*) as c FROM $wpdb->comments WHERE comment_approved = '1' GROUP BY comment_post_ID");
867
+	if (is_array($comments))
868 868
 		foreach ($comments as $comment)
869
-			$wpdb->update( $wpdb->posts, array('comment_count' => $comment->c), array('ID' => $comment->comment_post_ID) );
869
+			$wpdb->update($wpdb->posts, array('comment_count' => $comment->c), array('ID' => $comment->comment_post_ID));
870 870
 
871 871
 	/*
872 872
 	 * Some alpha versions used a post status of object instead of attachment
873 873
 	 * and put the mime type in post_type instead of post_mime_type.
874 874
 	 */
875
-	if ( $wp_current_db_version > 2541 && $wp_current_db_version <= 3091 ) {
875
+	if ($wp_current_db_version > 2541 && $wp_current_db_version <= 3091) {
876 876
 		$objects = $wpdb->get_results("SELECT ID, post_type FROM $wpdb->posts WHERE post_status = 'object'");
877 877
 		foreach ($objects as $object) {
878
-			$wpdb->update( $wpdb->posts, array(	'post_status' => 'attachment',
878
+			$wpdb->update($wpdb->posts, array('post_status' => 'attachment',
879 879
 												'post_mime_type' => $object->post_type,
880 880
 												'post_type' => ''),
881
-										 array( 'ID' => $object->ID ) );
881
+										 array('ID' => $object->ID));
882 882
 
883 883
 			$meta = get_post_meta($object->ID, 'imagedata', true);
884
-			if ( ! empty($meta['file']) )
885
-				update_attached_file( $object->ID, $meta['file'] );
884
+			if ( ! empty($meta['file']))
885
+				update_attached_file($object->ID, $meta['file']);
886 886
 		}
887 887
 	}
888 888
 }
@@ -899,38 +899,38 @@  discard block
 block discarded – undo
899 899
 function upgrade_210() {
900 900
 	global $wpdb, $wp_current_db_version;
901 901
 
902
-	if ( $wp_current_db_version < 3506 ) {
902
+	if ($wp_current_db_version < 3506) {
903 903
 		// Update status and type.
904 904
 		$posts = $wpdb->get_results("SELECT ID, post_status FROM $wpdb->posts");
905 905
 
906
-		if ( ! empty($posts) ) foreach ($posts as $post) {
906
+		if ( ! empty($posts)) foreach ($posts as $post) {
907 907
 			$status = $post->post_status;
908 908
 			$type = 'post';
909 909
 
910
-			if ( 'static' == $status ) {
910
+			if ('static' == $status) {
911 911
 				$status = 'publish';
912 912
 				$type = 'page';
913
-			} elseif ( 'attachment' == $status ) {
913
+			} elseif ('attachment' == $status) {
914 914
 				$status = 'inherit';
915 915
 				$type = 'attachment';
916 916
 			}
917 917
 
918
-			$wpdb->query( $wpdb->prepare("UPDATE $wpdb->posts SET post_status = %s, post_type = %s WHERE ID = %d", $status, $type, $post->ID) );
918
+			$wpdb->query($wpdb->prepare("UPDATE $wpdb->posts SET post_status = %s, post_type = %s WHERE ID = %d", $status, $type, $post->ID));
919 919
 		}
920 920
 	}
921 921
 
922
-	if ( $wp_current_db_version < 3845 ) {
922
+	if ($wp_current_db_version < 3845) {
923 923
 		populate_roles_210();
924 924
 	}
925 925
 
926
-	if ( $wp_current_db_version < 3531 ) {
926
+	if ($wp_current_db_version < 3531) {
927 927
 		// Give future posts a post_status of future.
928 928
 		$now = gmdate('Y-m-d H:i:59');
929
-		$wpdb->query ("UPDATE $wpdb->posts SET post_status = 'future' WHERE post_status = 'publish' AND post_date_gmt > '$now'");
929
+		$wpdb->query("UPDATE $wpdb->posts SET post_status = 'future' WHERE post_status = 'publish' AND post_date_gmt > '$now'");
930 930
 
931 931
 		$posts = $wpdb->get_results("SELECT ID, post_date FROM $wpdb->posts WHERE post_status ='future'");
932
-		if ( !empty($posts) )
933
-			foreach ( $posts as $post )
932
+		if ( ! empty($posts))
933
+			foreach ($posts as $post)
934 934
 				wp_schedule_single_event(mysql2date('U', $post->post_date, false), 'publish_future_post', array($post->ID));
935 935
 	}
936 936
 }
@@ -947,7 +947,7 @@  discard block
 block discarded – undo
947 947
 function upgrade_230() {
948 948
 	global $wp_current_db_version, $wpdb;
949 949
 
950
-	if ( $wp_current_db_version < 5200 ) {
950
+	if ($wp_current_db_version < 5200) {
951 951
 		populate_roles_230();
952 952
 	}
953 953
 
@@ -964,78 +964,78 @@  discard block
 block discarded – undo
964 964
 		$term_group = 0;
965 965
 
966 966
 		// Associate terms with the same slug in a term group and make slugs unique.
967
-		if ( $exists = $wpdb->get_results( $wpdb->prepare("SELECT term_id, term_group FROM $wpdb->terms WHERE slug = %s", $slug) ) ) {
967
+		if ($exists = $wpdb->get_results($wpdb->prepare("SELECT term_id, term_group FROM $wpdb->terms WHERE slug = %s", $slug))) {
968 968
 			$term_group = $exists[0]->term_group;
969 969
 			$id = $exists[0]->term_id;
970 970
 			$num = 2;
971 971
 			do {
972
-				$alt_slug = $slug . "-$num";
972
+				$alt_slug = $slug."-$num";
973 973
 				$num++;
974
-				$slug_check = $wpdb->get_var( $wpdb->prepare("SELECT slug FROM $wpdb->terms WHERE slug = %s", $alt_slug) );
975
-			} while ( $slug_check );
974
+				$slug_check = $wpdb->get_var($wpdb->prepare("SELECT slug FROM $wpdb->terms WHERE slug = %s", $alt_slug));
975
+			} while ($slug_check);
976 976
 
977 977
 			$slug = $alt_slug;
978 978
 
979
-			if ( empty( $term_group ) ) {
979
+			if (empty($term_group)) {
980 980
 				$term_group = $wpdb->get_var("SELECT MAX(term_group) FROM $wpdb->terms GROUP BY term_group") + 1;
981
-				$wpdb->query( $wpdb->prepare("UPDATE $wpdb->terms SET term_group = %d WHERE term_id = %d", $term_group, $id) );
981
+				$wpdb->query($wpdb->prepare("UPDATE $wpdb->terms SET term_group = %d WHERE term_id = %d", $term_group, $id));
982 982
 			}
983 983
 		}
984 984
 
985
-		$wpdb->query( $wpdb->prepare("INSERT INTO $wpdb->terms (term_id, name, slug, term_group) VALUES
986
-		(%d, %s, %s, %d)", $term_id, $name, $slug, $term_group) );
985
+		$wpdb->query($wpdb->prepare("INSERT INTO $wpdb->terms (term_id, name, slug, term_group) VALUES
986
+		(%d, %s, %s, %d)", $term_id, $name, $slug, $term_group));
987 987
 
988 988
 		$count = 0;
989
-		if ( !empty($category->category_count) ) {
989
+		if ( ! empty($category->category_count)) {
990 990
 			$count = (int) $category->category_count;
991 991
 			$taxonomy = 'category';
992
-			$wpdb->query( $wpdb->prepare("INSERT INTO $wpdb->term_taxonomy (term_id, taxonomy, description, parent, count) VALUES ( %d, %s, %s, %d, %d)", $term_id, $taxonomy, $description, $parent, $count) );
992
+			$wpdb->query($wpdb->prepare("INSERT INTO $wpdb->term_taxonomy (term_id, taxonomy, description, parent, count) VALUES ( %d, %s, %s, %d, %d)", $term_id, $taxonomy, $description, $parent, $count));
993 993
 			$tt_ids[$term_id][$taxonomy] = (int) $wpdb->insert_id;
994 994
 		}
995 995
 
996
-		if ( !empty($category->link_count) ) {
996
+		if ( ! empty($category->link_count)) {
997 997
 			$count = (int) $category->link_count;
998 998
 			$taxonomy = 'link_category';
999
-			$wpdb->query( $wpdb->prepare("INSERT INTO $wpdb->term_taxonomy (term_id, taxonomy, description, parent, count) VALUES ( %d, %s, %s, %d, %d)", $term_id, $taxonomy, $description, $parent, $count) );
999
+			$wpdb->query($wpdb->prepare("INSERT INTO $wpdb->term_taxonomy (term_id, taxonomy, description, parent, count) VALUES ( %d, %s, %s, %d, %d)", $term_id, $taxonomy, $description, $parent, $count));
1000 1000
 			$tt_ids[$term_id][$taxonomy] = (int) $wpdb->insert_id;
1001 1001
 		}
1002 1002
 
1003
-		if ( !empty($category->tag_count) ) {
1003
+		if ( ! empty($category->tag_count)) {
1004 1004
 			$have_tags = true;
1005 1005
 			$count = (int) $category->tag_count;
1006 1006
 			$taxonomy = 'post_tag';
1007
-			$wpdb->insert( $wpdb->term_taxonomy, compact('term_id', 'taxonomy', 'description', 'parent', 'count') );
1007
+			$wpdb->insert($wpdb->term_taxonomy, compact('term_id', 'taxonomy', 'description', 'parent', 'count'));
1008 1008
 			$tt_ids[$term_id][$taxonomy] = (int) $wpdb->insert_id;
1009 1009
 		}
1010 1010
 
1011
-		if ( empty($count) ) {
1011
+		if (empty($count)) {
1012 1012
 			$count = 0;
1013 1013
 			$taxonomy = 'category';
1014
-			$wpdb->insert( $wpdb->term_taxonomy, compact('term_id', 'taxonomy', 'description', 'parent', 'count') );
1014
+			$wpdb->insert($wpdb->term_taxonomy, compact('term_id', 'taxonomy', 'description', 'parent', 'count'));
1015 1015
 			$tt_ids[$term_id][$taxonomy] = (int) $wpdb->insert_id;
1016 1016
 		}
1017 1017
 	}
1018 1018
 
1019 1019
 	$select = 'post_id, category_id';
1020
-	if ( $have_tags )
1020
+	if ($have_tags)
1021 1021
 		$select .= ', rel_type';
1022 1022
 
1023 1023
 	$posts = $wpdb->get_results("SELECT $select FROM $wpdb->post2cat GROUP BY post_id, category_id");
1024
-	foreach ( $posts as $post ) {
1024
+	foreach ($posts as $post) {
1025 1025
 		$post_id = (int) $post->post_id;
1026 1026
 		$term_id = (int) $post->category_id;
1027 1027
 		$taxonomy = 'category';
1028
-		if ( !empty($post->rel_type) && 'tag' == $post->rel_type)
1028
+		if ( ! empty($post->rel_type) && 'tag' == $post->rel_type)
1029 1029
 			$taxonomy = 'tag';
1030 1030
 		$tt_id = $tt_ids[$term_id][$taxonomy];
1031
-		if ( empty($tt_id) )
1031
+		if (empty($tt_id))
1032 1032
 			continue;
1033 1033
 
1034
-		$wpdb->insert( $wpdb->term_relationships, array('object_id' => $post_id, 'term_taxonomy_id' => $tt_id) );
1034
+		$wpdb->insert($wpdb->term_relationships, array('object_id' => $post_id, 'term_taxonomy_id' => $tt_id));
1035 1035
 	}
1036 1036
 
1037 1037
 	// < 3570 we used linkcategories. >= 3570 we used categories and link2cat.
1038
-	if ( $wp_current_db_version < 3570 ) {
1038
+	if ($wp_current_db_version < 3570) {
1039 1039
 		/*
1040 1040
 		 * Create link_category terms for link categories. Create a map of link
1041 1041
 		 * cat IDs to link_category terms.
@@ -1043,8 +1043,8 @@  discard block
 block discarded – undo
1043 1043
 		$link_cat_id_map = array();
1044 1044
 		$default_link_cat = 0;
1045 1045
 		$tt_ids = array();
1046
-		$link_cats = $wpdb->get_results("SELECT cat_id, cat_name FROM " . $wpdb->prefix . 'linkcategories');
1047
-		foreach ( $link_cats as $category) {
1046
+		$link_cats = $wpdb->get_results("SELECT cat_id, cat_name FROM ".$wpdb->prefix.'linkcategories');
1047
+		foreach ($link_cats as $category) {
1048 1048
 			$cat_id = (int) $category->cat_id;
1049 1049
 			$term_id = 0;
1050 1050
 			$name = wp_slash($category->cat_name);
@@ -1052,66 +1052,66 @@  discard block
 block discarded – undo
1052 1052
 			$term_group = 0;
1053 1053
 
1054 1054
 			// Associate terms with the same slug in a term group and make slugs unique.
1055
-			if ( $exists = $wpdb->get_results( $wpdb->prepare("SELECT term_id, term_group FROM $wpdb->terms WHERE slug = %s", $slug) ) ) {
1055
+			if ($exists = $wpdb->get_results($wpdb->prepare("SELECT term_id, term_group FROM $wpdb->terms WHERE slug = %s", $slug))) {
1056 1056
 				$term_group = $exists[0]->term_group;
1057 1057
 				$term_id = $exists[0]->term_id;
1058 1058
 			}
1059 1059
 
1060
-			if ( empty($term_id) ) {
1061
-				$wpdb->insert( $wpdb->terms, compact('name', 'slug', 'term_group') );
1060
+			if (empty($term_id)) {
1061
+				$wpdb->insert($wpdb->terms, compact('name', 'slug', 'term_group'));
1062 1062
 				$term_id = (int) $wpdb->insert_id;
1063 1063
 			}
1064 1064
 
1065 1065
 			$link_cat_id_map[$cat_id] = $term_id;
1066 1066
 			$default_link_cat = $term_id;
1067 1067
 
1068
-			$wpdb->insert( $wpdb->term_taxonomy, array('term_id' => $term_id, 'taxonomy' => 'link_category', 'description' => '', 'parent' => 0, 'count' => 0) );
1068
+			$wpdb->insert($wpdb->term_taxonomy, array('term_id' => $term_id, 'taxonomy' => 'link_category', 'description' => '', 'parent' => 0, 'count' => 0));
1069 1069
 			$tt_ids[$term_id] = (int) $wpdb->insert_id;
1070 1070
 		}
1071 1071
 
1072 1072
 		// Associate links to cats.
1073 1073
 		$links = $wpdb->get_results("SELECT link_id, link_category FROM $wpdb->links");
1074
-		if ( !empty($links) ) foreach ( $links as $link ) {
1075
-			if ( 0 == $link->link_category )
1074
+		if ( ! empty($links)) foreach ($links as $link) {
1075
+			if (0 == $link->link_category)
1076 1076
 				continue;
1077
-			if ( ! isset($link_cat_id_map[$link->link_category]) )
1077
+			if ( ! isset($link_cat_id_map[$link->link_category]))
1078 1078
 				continue;
1079 1079
 			$term_id = $link_cat_id_map[$link->link_category];
1080 1080
 			$tt_id = $tt_ids[$term_id];
1081
-			if ( empty($tt_id) )
1081
+			if (empty($tt_id))
1082 1082
 				continue;
1083 1083
 
1084
-			$wpdb->insert( $wpdb->term_relationships, array('object_id' => $link->link_id, 'term_taxonomy_id' => $tt_id) );
1084
+			$wpdb->insert($wpdb->term_relationships, array('object_id' => $link->link_id, 'term_taxonomy_id' => $tt_id));
1085 1085
 		}
1086 1086
 
1087 1087
 		// Set default to the last category we grabbed during the upgrade loop.
1088 1088
 		update_option('default_link_category', $default_link_cat);
1089 1089
 	} else {
1090 1090
 		$links = $wpdb->get_results("SELECT link_id, category_id FROM $wpdb->link2cat GROUP BY link_id, category_id");
1091
-		foreach ( $links as $link ) {
1091
+		foreach ($links as $link) {
1092 1092
 			$link_id = (int) $link->link_id;
1093 1093
 			$term_id = (int) $link->category_id;
1094 1094
 			$taxonomy = 'link_category';
1095 1095
 			$tt_id = $tt_ids[$term_id][$taxonomy];
1096
-			if ( empty($tt_id) )
1096
+			if (empty($tt_id))
1097 1097
 				continue;
1098
-			$wpdb->insert( $wpdb->term_relationships, array('object_id' => $link_id, 'term_taxonomy_id' => $tt_id) );
1098
+			$wpdb->insert($wpdb->term_relationships, array('object_id' => $link_id, 'term_taxonomy_id' => $tt_id));
1099 1099
 		}
1100 1100
 	}
1101 1101
 
1102
-	if ( $wp_current_db_version < 4772 ) {
1102
+	if ($wp_current_db_version < 4772) {
1103 1103
 		// Obsolete linkcategories table
1104
-		$wpdb->query('DROP TABLE IF EXISTS ' . $wpdb->prefix . 'linkcategories');
1104
+		$wpdb->query('DROP TABLE IF EXISTS '.$wpdb->prefix.'linkcategories');
1105 1105
 	}
1106 1106
 
1107 1107
 	// Recalculate all counts
1108 1108
 	$terms = $wpdb->get_results("SELECT term_taxonomy_id, taxonomy FROM $wpdb->term_taxonomy");
1109
-	foreach ( (array) $terms as $term ) {
1110
-		if ( ('post_tag' == $term->taxonomy) || ('category' == $term->taxonomy) )
1111
-			$count = $wpdb->get_var( $wpdb->prepare("SELECT COUNT(*) FROM $wpdb->term_relationships, $wpdb->posts WHERE $wpdb->posts.ID = $wpdb->term_relationships.object_id AND post_status = 'publish' AND post_type = 'post' AND term_taxonomy_id = %d", $term->term_taxonomy_id) );
1109
+	foreach ((array) $terms as $term) {
1110
+		if (('post_tag' == $term->taxonomy) || ('category' == $term->taxonomy))
1111
+			$count = $wpdb->get_var($wpdb->prepare("SELECT COUNT(*) FROM $wpdb->term_relationships, $wpdb->posts WHERE $wpdb->posts.ID = $wpdb->term_relationships.object_id AND post_status = 'publish' AND post_type = 'post' AND term_taxonomy_id = %d", $term->term_taxonomy_id));
1112 1112
 		else
1113
-			$count = $wpdb->get_var( $wpdb->prepare("SELECT COUNT(*) FROM $wpdb->term_relationships WHERE term_taxonomy_id = %d", $term->term_taxonomy_id) );
1114
-		$wpdb->update( $wpdb->term_taxonomy, array('count' => $count), array('term_taxonomy_id' => $term->term_taxonomy_id) );
1113
+			$count = $wpdb->get_var($wpdb->prepare("SELECT COUNT(*) FROM $wpdb->term_relationships WHERE term_taxonomy_id = %d", $term->term_taxonomy_id));
1114
+		$wpdb->update($wpdb->term_taxonomy, array('count' => $count), array('term_taxonomy_id' => $term->term_taxonomy_id));
1115 1115
 	}
1116 1116
 }
1117 1117
 
@@ -1125,9 +1125,9 @@  discard block
 block discarded – undo
1125 1125
  */
1126 1126
 function upgrade_230_options_table() {
1127 1127
 	global $wpdb;
1128
-	$old_options_fields = array( 'option_can_override', 'option_type', 'option_width', 'option_height', 'option_description', 'option_admin_level' );
1128
+	$old_options_fields = array('option_can_override', 'option_type', 'option_width', 'option_height', 'option_description', 'option_admin_level');
1129 1129
 	$wpdb->hide_errors();
1130
-	foreach ( $old_options_fields as $old )
1130
+	foreach ($old_options_fields as $old)
1131 1131
 		$wpdb->query("ALTER TABLE $wpdb->options DROP $old");
1132 1132
 	$wpdb->show_errors();
1133 1133
 }
@@ -1142,9 +1142,9 @@  discard block
 block discarded – undo
1142 1142
  */
1143 1143
 function upgrade_230_old_tables() {
1144 1144
 	global $wpdb;
1145
-	$wpdb->query('DROP TABLE IF EXISTS ' . $wpdb->prefix . 'categories');
1146
-	$wpdb->query('DROP TABLE IF EXISTS ' . $wpdb->prefix . 'link2cat');
1147
-	$wpdb->query('DROP TABLE IF EXISTS ' . $wpdb->prefix . 'post2cat');
1145
+	$wpdb->query('DROP TABLE IF EXISTS '.$wpdb->prefix.'categories');
1146
+	$wpdb->query('DROP TABLE IF EXISTS '.$wpdb->prefix.'link2cat');
1147
+	$wpdb->query('DROP TABLE IF EXISTS '.$wpdb->prefix.'post2cat');
1148 1148
 }
1149 1149
 
1150 1150
 /**
@@ -1172,7 +1172,7 @@  discard block
 block discarded – undo
1172 1172
 function upgrade_250() {
1173 1173
 	global $wp_current_db_version;
1174 1174
 
1175
-	if ( $wp_current_db_version < 6689 ) {
1175
+	if ($wp_current_db_version < 6689) {
1176 1176
 		populate_roles_250();
1177 1177
 	}
1178 1178
 
@@ -1203,7 +1203,7 @@  discard block
 block discarded – undo
1203 1203
 function upgrade_260() {
1204 1204
 	global $wp_current_db_version;
1205 1205
 
1206
-	if ( $wp_current_db_version < 8000 )
1206
+	if ($wp_current_db_version < 8000)
1207 1207
 		populate_roles_260();
1208 1208
 }
1209 1209
 
@@ -1219,12 +1219,12 @@  discard block
 block discarded – undo
1219 1219
 function upgrade_270() {
1220 1220
 	global $wpdb, $wp_current_db_version;
1221 1221
 
1222
-	if ( $wp_current_db_version < 8980 )
1222
+	if ($wp_current_db_version < 8980)
1223 1223
 		populate_roles_270();
1224 1224
 
1225 1225
 	// Update post_date for unpublished posts with empty timestamp
1226
-	if ( $wp_current_db_version < 8921 )
1227
-		$wpdb->query( "UPDATE $wpdb->posts SET post_date = post_modified WHERE post_date = '0000-00-00 00:00:00'" );
1226
+	if ($wp_current_db_version < 8921)
1227
+		$wpdb->query("UPDATE $wpdb->posts SET post_date = post_modified WHERE post_date = '0000-00-00 00:00:00'");
1228 1228
 }
1229 1229
 
1230 1230
 /**
@@ -1239,22 +1239,22 @@  discard block
 block discarded – undo
1239 1239
 function upgrade_280() {
1240 1240
 	global $wp_current_db_version, $wpdb;
1241 1241
 
1242
-	if ( $wp_current_db_version < 10360 )
1242
+	if ($wp_current_db_version < 10360)
1243 1243
 		populate_roles_280();
1244
-	if ( is_multisite() ) {
1244
+	if (is_multisite()) {
1245 1245
 		$start = 0;
1246
-		while( $rows = $wpdb->get_results( "SELECT option_name, option_value FROM $wpdb->options ORDER BY option_id LIMIT $start, 20" ) ) {
1247
-			foreach ( $rows as $row ) {
1246
+		while ($rows = $wpdb->get_results("SELECT option_name, option_value FROM $wpdb->options ORDER BY option_id LIMIT $start, 20")) {
1247
+			foreach ($rows as $row) {
1248 1248
 				$value = $row->option_value;
1249
-				if ( !@unserialize( $value ) )
1250
-					$value = stripslashes( $value );
1251
-				if ( $value !== $row->option_value ) {
1252
-					update_option( $row->option_name, $value );
1249
+				if ( ! @unserialize($value))
1250
+					$value = stripslashes($value);
1251
+				if ($value !== $row->option_value) {
1252
+					update_option($row->option_name, $value);
1253 1253
 				}
1254 1254
 			}
1255 1255
 			$start += 20;
1256 1256
 		}
1257
-		refresh_blog_details( $wpdb->blogid );
1257
+		refresh_blog_details($wpdb->blogid);
1258 1258
 	}
1259 1259
 }
1260 1260
 
@@ -1269,11 +1269,11 @@  discard block
 block discarded – undo
1269 1269
 function upgrade_290() {
1270 1270
 	global $wp_current_db_version;
1271 1271
 
1272
-	if ( $wp_current_db_version < 11958 ) {
1272
+	if ($wp_current_db_version < 11958) {
1273 1273
 		// Previously, setting depth to 1 would redundantly disable threading, but now 2 is the minimum depth to avoid confusion
1274
-		if ( get_option( 'thread_comments_depth' ) == '1' ) {
1275
-			update_option( 'thread_comments_depth', 2 );
1276
-			update_option( 'thread_comments', 0 );
1274
+		if (get_option('thread_comments_depth') == '1') {
1275
+			update_option('thread_comments_depth', 2);
1276
+			update_option('thread_comments', 0);
1277 1277
 		}
1278 1278
 	}
1279 1279
 }
@@ -1290,14 +1290,14 @@  discard block
 block discarded – undo
1290 1290
 function upgrade_300() {
1291 1291
 	global $wp_current_db_version, $wpdb;
1292 1292
 
1293
-	if ( $wp_current_db_version < 15093 )
1293
+	if ($wp_current_db_version < 15093)
1294 1294
 		populate_roles_300();
1295 1295
 
1296
-	if ( $wp_current_db_version < 14139 && is_multisite() && is_main_site() && ! defined( 'MULTISITE' ) && get_site_option( 'siteurl' ) === false )
1297
-		add_site_option( 'siteurl', '' );
1296
+	if ($wp_current_db_version < 14139 && is_multisite() && is_main_site() && ! defined('MULTISITE') && get_site_option('siteurl') === false)
1297
+		add_site_option('siteurl', '');
1298 1298
 
1299 1299
 	// 3.0 screen options key name changes.
1300
-	if ( wp_should_upgrade_global_tables() ) {
1300
+	if (wp_should_upgrade_global_tables()) {
1301 1301
 		$sql = "DELETE FROM $wpdb->usermeta
1302 1302
 			WHERE meta_key LIKE %s
1303 1303
 			OR meta_key LIKE %s
@@ -1311,15 +1311,15 @@  discard block
 block discarded – undo
1311 1311
 			OR meta_key = 'manageeditcolumnshidden'
1312 1312
 			OR meta_key = 'categories_per_page'
1313 1313
 			OR meta_key = 'edit_tags_per_page'";
1314
-		$prefix = $wpdb->esc_like( $wpdb->base_prefix );
1315
-		$wpdb->query( $wpdb->prepare( $sql,
1316
-			$prefix . '%' . $wpdb->esc_like( 'meta-box-hidden' ) . '%',
1317
-			$prefix . '%' . $wpdb->esc_like( 'closedpostboxes' ) . '%',
1318
-			$prefix . '%' . $wpdb->esc_like( 'manage-'	   ) . '%' . $wpdb->esc_like( '-columns-hidden' ) . '%',
1319
-			$prefix . '%' . $wpdb->esc_like( 'meta-box-order'  ) . '%',
1320
-			$prefix . '%' . $wpdb->esc_like( 'metaboxorder'    ) . '%',
1321
-			$prefix . '%' . $wpdb->esc_like( 'screen_layout'   ) . '%'
1322
-		) );
1314
+		$prefix = $wpdb->esc_like($wpdb->base_prefix);
1315
+		$wpdb->query($wpdb->prepare($sql,
1316
+			$prefix.'%'.$wpdb->esc_like('meta-box-hidden').'%',
1317
+			$prefix.'%'.$wpdb->esc_like('closedpostboxes').'%',
1318
+			$prefix.'%'.$wpdb->esc_like('manage-').'%'.$wpdb->esc_like('-columns-hidden').'%',
1319
+			$prefix.'%'.$wpdb->esc_like('meta-box-order').'%',
1320
+			$prefix.'%'.$wpdb->esc_like('metaboxorder').'%',
1321
+			$prefix.'%'.$wpdb->esc_like('screen_layout').'%'
1322
+		));
1323 1323
 	}
1324 1324
 
1325 1325
 }
@@ -1338,52 +1338,52 @@  discard block
 block discarded – undo
1338 1338
 function upgrade_330() {
1339 1339
 	global $wp_current_db_version, $wpdb, $wp_registered_widgets, $sidebars_widgets;
1340 1340
 
1341
-	if ( $wp_current_db_version < 19061 && wp_should_upgrade_global_tables() ) {
1342
-		$wpdb->query( "DELETE FROM $wpdb->usermeta WHERE meta_key IN ('show_admin_bar_admin', 'plugins_last_view')" );
1341
+	if ($wp_current_db_version < 19061 && wp_should_upgrade_global_tables()) {
1342
+		$wpdb->query("DELETE FROM $wpdb->usermeta WHERE meta_key IN ('show_admin_bar_admin', 'plugins_last_view')");
1343 1343
 	}
1344 1344
 
1345
-	if ( $wp_current_db_version >= 11548 )
1345
+	if ($wp_current_db_version >= 11548)
1346 1346
 		return;
1347 1347
 
1348
-	$sidebars_widgets = get_option( 'sidebars_widgets', array() );
1348
+	$sidebars_widgets = get_option('sidebars_widgets', array());
1349 1349
 	$_sidebars_widgets = array();
1350 1350
 
1351
-	if ( isset($sidebars_widgets['wp_inactive_widgets']) || empty($sidebars_widgets) )
1351
+	if (isset($sidebars_widgets['wp_inactive_widgets']) || empty($sidebars_widgets))
1352 1352
 		$sidebars_widgets['array_version'] = 3;
1353
-	elseif ( !isset($sidebars_widgets['array_version']) )
1353
+	elseif ( ! isset($sidebars_widgets['array_version']))
1354 1354
 		$sidebars_widgets['array_version'] = 1;
1355 1355
 
1356
-	switch ( $sidebars_widgets['array_version'] ) {
1356
+	switch ($sidebars_widgets['array_version']) {
1357 1357
 		case 1 :
1358
-			foreach ( (array) $sidebars_widgets as $index => $sidebar )
1359
-			if ( is_array($sidebar) )
1360
-			foreach ( (array) $sidebar as $i => $name ) {
1358
+			foreach ((array) $sidebars_widgets as $index => $sidebar)
1359
+			if (is_array($sidebar))
1360
+			foreach ((array) $sidebar as $i => $name) {
1361 1361
 				$id = strtolower($name);
1362
-				if ( isset($wp_registered_widgets[$id]) ) {
1362
+				if (isset($wp_registered_widgets[$id])) {
1363 1363
 					$_sidebars_widgets[$index][$i] = $id;
1364 1364
 					continue;
1365 1365
 				}
1366 1366
 				$id = sanitize_title($name);
1367
-				if ( isset($wp_registered_widgets[$id]) ) {
1367
+				if (isset($wp_registered_widgets[$id])) {
1368 1368
 					$_sidebars_widgets[$index][$i] = $id;
1369 1369
 					continue;
1370 1370
 				}
1371 1371
 
1372 1372
 				$found = false;
1373 1373
 
1374
-				foreach ( $wp_registered_widgets as $widget_id => $widget ) {
1375
-					if ( strtolower($widget['name']) == strtolower($name) ) {
1374
+				foreach ($wp_registered_widgets as $widget_id => $widget) {
1375
+					if (strtolower($widget['name']) == strtolower($name)) {
1376 1376
 						$_sidebars_widgets[$index][$i] = $widget['id'];
1377 1377
 						$found = true;
1378 1378
 						break;
1379
-					} elseif ( sanitize_title($widget['name']) == sanitize_title($name) ) {
1379
+					} elseif (sanitize_title($widget['name']) == sanitize_title($name)) {
1380 1380
 						$_sidebars_widgets[$index][$i] = $widget['id'];
1381 1381
 						$found = true;
1382 1382
 						break;
1383 1383
 					}
1384 1384
 				}
1385 1385
 
1386
-				if ( $found )
1386
+				if ($found)
1387 1387
 					continue;
1388 1388
 
1389 1389
 				unset($_sidebars_widgets[$index][$i]);
@@ -1395,7 +1395,7 @@  discard block
 block discarded – undo
1395 1395
 		case 2 :
1396 1396
 			$sidebars_widgets = retrieve_widgets();
1397 1397
 			$sidebars_widgets['array_version'] = 3;
1398
-			update_option( 'sidebars_widgets', $sidebars_widgets );
1398
+			update_option('sidebars_widgets', $sidebars_widgets);
1399 1399
 	}
1400 1400
 }
1401 1401
 
@@ -1411,27 +1411,27 @@  discard block
 block discarded – undo
1411 1411
 function upgrade_340() {
1412 1412
 	global $wp_current_db_version, $wpdb;
1413 1413
 
1414
-	if ( $wp_current_db_version < 19798 ) {
1414
+	if ($wp_current_db_version < 19798) {
1415 1415
 		$wpdb->hide_errors();
1416
-		$wpdb->query( "ALTER TABLE $wpdb->options DROP COLUMN blog_id" );
1416
+		$wpdb->query("ALTER TABLE $wpdb->options DROP COLUMN blog_id");
1417 1417
 		$wpdb->show_errors();
1418 1418
 	}
1419 1419
 
1420
-	if ( $wp_current_db_version < 19799 ) {
1420
+	if ($wp_current_db_version < 19799) {
1421 1421
 		$wpdb->hide_errors();
1422 1422
 		$wpdb->query("ALTER TABLE $wpdb->comments DROP INDEX comment_approved");
1423 1423
 		$wpdb->show_errors();
1424 1424
 	}
1425 1425
 
1426
-	if ( $wp_current_db_version < 20022 && wp_should_upgrade_global_tables() ) {
1427
-		$wpdb->query( "DELETE FROM $wpdb->usermeta WHERE meta_key = 'themes_last_view'" );
1426
+	if ($wp_current_db_version < 20022 && wp_should_upgrade_global_tables()) {
1427
+		$wpdb->query("DELETE FROM $wpdb->usermeta WHERE meta_key = 'themes_last_view'");
1428 1428
 	}
1429 1429
 
1430
-	if ( $wp_current_db_version < 20080 ) {
1431
-		if ( 'yes' == $wpdb->get_var( "SELECT autoload FROM $wpdb->options WHERE option_name = 'uninstall_plugins'" ) ) {
1432
-			$uninstall_plugins = get_option( 'uninstall_plugins' );
1433
-			delete_option( 'uninstall_plugins' );
1434
-			add_option( 'uninstall_plugins', $uninstall_plugins, null, 'no' );
1430
+	if ($wp_current_db_version < 20080) {
1431
+		if ('yes' == $wpdb->get_var("SELECT autoload FROM $wpdb->options WHERE option_name = 'uninstall_plugins'")) {
1432
+			$uninstall_plugins = get_option('uninstall_plugins');
1433
+			delete_option('uninstall_plugins');
1434
+			add_option('uninstall_plugins', $uninstall_plugins, null, 'no');
1435 1435
 		}
1436 1436
 	}
1437 1437
 }
@@ -1448,23 +1448,23 @@  discard block
 block discarded – undo
1448 1448
 function upgrade_350() {
1449 1449
 	global $wp_current_db_version, $wpdb;
1450 1450
 
1451
-	if ( $wp_current_db_version < 22006 && $wpdb->get_var( "SELECT link_id FROM $wpdb->links LIMIT 1" ) )
1452
-		update_option( 'link_manager_enabled', 1 ); // Previously set to 0 by populate_options()
1451
+	if ($wp_current_db_version < 22006 && $wpdb->get_var("SELECT link_id FROM $wpdb->links LIMIT 1"))
1452
+		update_option('link_manager_enabled', 1); // Previously set to 0 by populate_options()
1453 1453
 
1454
-	if ( $wp_current_db_version < 21811 && wp_should_upgrade_global_tables() ) {
1454
+	if ($wp_current_db_version < 21811 && wp_should_upgrade_global_tables()) {
1455 1455
 		$meta_keys = array();
1456
-		foreach ( array_merge( get_post_types(), get_taxonomies() ) as $name ) {
1457
-			if ( false !== strpos( $name, '-' ) )
1458
-			$meta_keys[] = 'edit_' . str_replace( '-', '_', $name ) . '_per_page';
1456
+		foreach (array_merge(get_post_types(), get_taxonomies()) as $name) {
1457
+			if (false !== strpos($name, '-'))
1458
+			$meta_keys[] = 'edit_'.str_replace('-', '_', $name).'_per_page';
1459 1459
 		}
1460
-		if ( $meta_keys ) {
1461
-			$meta_keys = implode( "', '", $meta_keys );
1462
-			$wpdb->query( "DELETE FROM $wpdb->usermeta WHERE meta_key IN ('$meta_keys')" );
1460
+		if ($meta_keys) {
1461
+			$meta_keys = implode("', '", $meta_keys);
1462
+			$wpdb->query("DELETE FROM $wpdb->usermeta WHERE meta_key IN ('$meta_keys')");
1463 1463
 		}
1464 1464
 	}
1465 1465
 
1466
-	if ( $wp_current_db_version < 22422 && $term = get_term_by( 'slug', 'post-format-standard', 'post_format' ) )
1467
-		wp_delete_term( $term->term_id, 'post_format' );
1466
+	if ($wp_current_db_version < 22422 && $term = get_term_by('slug', 'post-format-standard', 'post_format'))
1467
+		wp_delete_term($term->term_id, 'post_format');
1468 1468
 }
1469 1469
 
1470 1470
 /**
@@ -1477,8 +1477,8 @@  discard block
 block discarded – undo
1477 1477
  */
1478 1478
 function upgrade_370() {
1479 1479
 	global $wp_current_db_version;
1480
-	if ( $wp_current_db_version < 25824 )
1481
-		wp_clear_scheduled_hook( 'wp_auto_updates_maybe_update' );
1480
+	if ($wp_current_db_version < 25824)
1481
+		wp_clear_scheduled_hook('wp_auto_updates_maybe_update');
1482 1482
 }
1483 1483
 
1484 1484
 /**
@@ -1492,8 +1492,8 @@  discard block
 block discarded – undo
1492 1492
  */
1493 1493
 function upgrade_372() {
1494 1494
 	global $wp_current_db_version;
1495
-	if ( $wp_current_db_version < 26148 )
1496
-		wp_clear_scheduled_hook( 'wp_maybe_auto_update' );
1495
+	if ($wp_current_db_version < 26148)
1496
+		wp_clear_scheduled_hook('wp_maybe_auto_update');
1497 1497
 }
1498 1498
 
1499 1499
 /**
@@ -1506,8 +1506,8 @@  discard block
 block discarded – undo
1506 1506
  */
1507 1507
 function upgrade_380() {
1508 1508
 	global $wp_current_db_version;
1509
-	if ( $wp_current_db_version < 26691 ) {
1510
-		deactivate_plugins( array( 'mp6/mp6.php' ), true );
1509
+	if ($wp_current_db_version < 26691) {
1510
+		deactivate_plugins(array('mp6/mp6.php'), true);
1511 1511
 	}
1512 1512
 }
1513 1513
 
@@ -1521,12 +1521,12 @@  discard block
 block discarded – undo
1521 1521
  */
1522 1522
 function upgrade_400() {
1523 1523
 	global $wp_current_db_version;
1524
-	if ( $wp_current_db_version < 29630 ) {
1525
-		if ( ! is_multisite() && false === get_option( 'WPLANG' ) ) {
1526
-			if ( defined( 'WPLANG' ) && ( '' !== WPLANG ) && in_array( WPLANG, get_available_languages() ) ) {
1527
-				update_option( 'WPLANG', WPLANG );
1524
+	if ($wp_current_db_version < 29630) {
1525
+		if ( ! is_multisite() && false === get_option('WPLANG')) {
1526
+			if (defined('WPLANG') && ('' !== WPLANG) && in_array(WPLANG, get_available_languages())) {
1527
+				update_option('WPLANG', WPLANG);
1528 1528
 			} else {
1529
-				update_option( 'WPLANG', '' );
1529
+				update_option('WPLANG', '');
1530 1530
 			}
1531 1531
 		}
1532 1532
 	}
@@ -1555,29 +1555,29 @@  discard block
 block discarded – undo
1555 1555
 function upgrade_430() {
1556 1556
 	global $wp_current_db_version, $wpdb;
1557 1557
 
1558
-	if ( $wp_current_db_version < 32364 ) {
1558
+	if ($wp_current_db_version < 32364) {
1559 1559
 		upgrade_430_fix_comments();
1560 1560
 	}
1561 1561
 
1562 1562
 	// Shared terms are split in a separate process.
1563
-	if ( $wp_current_db_version < 32814 ) {
1564
-		update_option( 'finished_splitting_shared_terms', 0 );
1565
-		wp_schedule_single_event( time() + ( 1 * MINUTE_IN_SECONDS ), 'wp_split_shared_term_batch' );
1563
+	if ($wp_current_db_version < 32814) {
1564
+		update_option('finished_splitting_shared_terms', 0);
1565
+		wp_schedule_single_event(time() + (1 * MINUTE_IN_SECONDS), 'wp_split_shared_term_batch');
1566 1566
 	}
1567 1567
 
1568
-	if ( $wp_current_db_version < 33055 && 'utf8mb4' === $wpdb->charset ) {
1569
-		if ( is_multisite() ) {
1570
-			$tables = $wpdb->tables( 'blog' );
1568
+	if ($wp_current_db_version < 33055 && 'utf8mb4' === $wpdb->charset) {
1569
+		if (is_multisite()) {
1570
+			$tables = $wpdb->tables('blog');
1571 1571
 		} else {
1572
-			$tables = $wpdb->tables( 'all' );
1573
-			if ( ! wp_should_upgrade_global_tables() ) {
1574
-				$global_tables = $wpdb->tables( 'global' );
1575
-				$tables = array_diff_assoc( $tables, $global_tables );
1572
+			$tables = $wpdb->tables('all');
1573
+			if ( ! wp_should_upgrade_global_tables()) {
1574
+				$global_tables = $wpdb->tables('global');
1575
+				$tables = array_diff_assoc($tables, $global_tables);
1576 1576
 			}
1577 1577
 		}
1578 1578
 
1579
-		foreach ( $tables as $table ) {
1580
-			maybe_convert_table_to_utf8mb4( $table );
1579
+		foreach ($tables as $table) {
1580
+			maybe_convert_table_to_utf8mb4($table);
1581 1581
 		}
1582 1582
 	}
1583 1583
 }
@@ -1594,18 +1594,18 @@  discard block
 block discarded – undo
1594 1594
 function upgrade_430_fix_comments() {
1595 1595
 	global $wp_current_db_version, $wpdb;
1596 1596
 
1597
-	$content_length = $wpdb->get_col_length( $wpdb->comments, 'comment_content' );
1597
+	$content_length = $wpdb->get_col_length($wpdb->comments, 'comment_content');
1598 1598
 
1599
-	if ( is_wp_error( $content_length ) ) {
1599
+	if (is_wp_error($content_length)) {
1600 1600
 		return;
1601 1601
 	}
1602 1602
 
1603
-	if ( false === $content_length ) {
1603
+	if (false === $content_length) {
1604 1604
 		$content_length = array(
1605 1605
 			'type'   => 'byte',
1606 1606
 			'length' => 65535,
1607 1607
 		);
1608
-	} elseif ( ! is_array( $content_length ) ) {
1608
+	} elseif ( ! is_array($content_length)) {
1609 1609
 		$length = (int) $content_length > 0 ? (int) $content_length : 65535;
1610 1610
 		$content_length = array(
1611 1611
 			'type'	 => 'byte',
@@ -1613,12 +1613,12 @@  discard block
 block discarded – undo
1613 1613
 		);
1614 1614
 	}
1615 1615
 
1616
-	if ( 'byte' !== $content_length['type'] || 0 === $content_length['length'] ) {
1616
+	if ('byte' !== $content_length['type'] || 0 === $content_length['length']) {
1617 1617
 		// Sites with malformed DB schemas are on their own.
1618 1618
 		return;
1619 1619
 	}
1620 1620
 
1621
-	$allowed_length = intval( $content_length['length'] ) - 10;
1621
+	$allowed_length = intval($content_length['length']) - 10;
1622 1622
 
1623 1623
 	$comments = $wpdb->get_results(
1624 1624
 		"SELECT `comment_ID` FROM `{$wpdb->comments}`
@@ -1627,8 +1627,8 @@  discard block
 block discarded – undo
1627 1627
 			AND ( `comment_content` LIKE '%<%' OR `comment_content` LIKE '%>%' )"
1628 1628
 	);
1629 1629
 
1630
-	foreach ( $comments as $comment ) {
1631
-		wp_delete_comment( $comment->comment_ID, true );
1630
+	foreach ($comments as $comment) {
1631
+		wp_delete_comment($comment->comment_ID, true);
1632 1632
 	}
1633 1633
 }
1634 1634
 
@@ -1641,9 +1641,9 @@  discard block
 block discarded – undo
1641 1641
 function upgrade_431() {
1642 1642
 	// Fix incorrect cron entries for term splitting
1643 1643
 	$cron_array = _get_cron_array();
1644
-	if ( isset( $cron_array['wp_batch_split_terms'] ) ) {
1645
-		unset( $cron_array['wp_batch_split_terms'] );
1646
-		_set_cron_array( $cron_array );
1644
+	if (isset($cron_array['wp_batch_split_terms'])) {
1645
+		unset($cron_array['wp_batch_split_terms']);
1646
+		_set_cron_array($cron_array);
1647 1647
 	}
1648 1648
 }
1649 1649
 
@@ -1659,15 +1659,15 @@  discard block
 block discarded – undo
1659 1659
 function upgrade_440() {
1660 1660
 	global $wp_current_db_version, $wpdb;
1661 1661
 
1662
-	if ( $wp_current_db_version < 34030 ) {
1663
-		$wpdb->query( "ALTER TABLE {$wpdb->options} MODIFY option_name VARCHAR(191)" );
1662
+	if ($wp_current_db_version < 34030) {
1663
+		$wpdb->query("ALTER TABLE {$wpdb->options} MODIFY option_name VARCHAR(191)");
1664 1664
 	}
1665 1665
 
1666 1666
 	// Remove the unused 'add_users' role.
1667 1667
 	$roles = wp_roles();
1668
-	foreach ( $roles->role_objects as $role ) {
1669
-		if ( $role->has_cap( 'add_users' ) ) {
1670
-			$role->remove_cap( 'add_users' );
1668
+	foreach ($roles->role_objects as $role) {
1669
+		if ($role->has_cap('add_users')) {
1670
+			$role->remove_cap('add_users');
1671 1671
 		}
1672 1672
 	}
1673 1673
 }
@@ -1684,17 +1684,17 @@  discard block
 block discarded – undo
1684 1684
 function upgrade_450() {
1685 1685
 	global $wp_current_db_version, $wpdb;
1686 1686
 
1687
-	if ( $wp_current_db_version < 36180 ) {
1688
-		wp_clear_scheduled_hook( 'wp_maybe_auto_update' );
1687
+	if ($wp_current_db_version < 36180) {
1688
+		wp_clear_scheduled_hook('wp_maybe_auto_update');
1689 1689
 	}
1690 1690
 
1691 1691
 	// Remove unused email confirmation options, moved to usermeta.
1692
-	if ( $wp_current_db_version < 36679 && is_multisite() ) {
1693
-		$wpdb->query( "DELETE FROM $wpdb->options WHERE option_name REGEXP '^[0-9]+_new_email$'" );
1692
+	if ($wp_current_db_version < 36679 && is_multisite()) {
1693
+		$wpdb->query("DELETE FROM $wpdb->options WHERE option_name REGEXP '^[0-9]+_new_email$'");
1694 1694
 	}
1695 1695
 
1696 1696
 	// Remove unused user setting for wpLink.
1697
-	delete_user_setting( 'wplink' );
1697
+	delete_user_setting('wplink');
1698 1698
 }
1699 1699
 
1700 1700
 /**
@@ -1709,22 +1709,22 @@  discard block
 block discarded – undo
1709 1709
 	global $wp_current_db_version;
1710 1710
 
1711 1711
 	// Remove unused post meta.
1712
-	if ( $wp_current_db_version < 37854 ) {
1713
-		delete_post_meta_by_key( '_post_restored_from' );
1712
+	if ($wp_current_db_version < 37854) {
1713
+		delete_post_meta_by_key('_post_restored_from');
1714 1714
 	}
1715 1715
 
1716 1716
 	// Remove plugins with callback as an array object/method as the uninstall hook, see #13786.
1717
-	if ( $wp_current_db_version < 37965 ) {
1718
-		$uninstall_plugins = get_option( 'uninstall_plugins', array() );
1717
+	if ($wp_current_db_version < 37965) {
1718
+		$uninstall_plugins = get_option('uninstall_plugins', array());
1719 1719
 
1720
-		if ( ! empty( $uninstall_plugins ) ) {
1721
-			foreach ( $uninstall_plugins as $basename => $callback ) {
1722
-				if ( is_array( $callback ) && is_object( $callback[0] ) ) {
1723
-					unset( $uninstall_plugins[ $basename ] );
1720
+		if ( ! empty($uninstall_plugins)) {
1721
+			foreach ($uninstall_plugins as $basename => $callback) {
1722
+				if (is_array($callback) && is_object($callback[0])) {
1723
+					unset($uninstall_plugins[$basename]);
1724 1724
 				}
1725 1725
 			}
1726 1726
 
1727
-			update_option( 'uninstall_plugins', $uninstall_plugins );
1727
+			update_option('uninstall_plugins', $uninstall_plugins);
1728 1728
 		}
1729 1729
 	}
1730 1730
 }
@@ -1741,7 +1741,7 @@  discard block
 block discarded – undo
1741 1741
 	global $wp_current_db_version, $wpdb;
1742 1742
 
1743 1743
 	// Always.
1744
-	if ( is_main_network() ) {
1744
+	if (is_main_network()) {
1745 1745
 		/*
1746 1746
 		 * Deletes all expired transients. The multi-table delete syntax is used
1747 1747
 		 * to delete the transient record from table a, and the corresponding
@@ -1753,32 +1753,32 @@  discard block
 block discarded – undo
1753 1753
 			AND a.meta_key NOT LIKE %s
1754 1754
 			AND b.meta_key = CONCAT( '_site_transient_timeout_', SUBSTRING( a.meta_key, 17 ) )
1755 1755
 			AND b.meta_value < %d";
1756
-		$wpdb->query( $wpdb->prepare( $sql, $wpdb->esc_like( '_site_transient_' ) . '%', $wpdb->esc_like ( '_site_transient_timeout_' ) . '%', $time ) );
1756
+		$wpdb->query($wpdb->prepare($sql, $wpdb->esc_like('_site_transient_').'%', $wpdb->esc_like('_site_transient_timeout_').'%', $time));
1757 1757
 	}
1758 1758
 
1759 1759
 	// 2.8.
1760
-	if ( $wp_current_db_version < 11549 ) {
1761
-		$wpmu_sitewide_plugins = get_site_option( 'wpmu_sitewide_plugins' );
1762
-		$active_sitewide_plugins = get_site_option( 'active_sitewide_plugins' );
1763
-		if ( $wpmu_sitewide_plugins ) {
1764
-			if ( !$active_sitewide_plugins )
1760
+	if ($wp_current_db_version < 11549) {
1761
+		$wpmu_sitewide_plugins = get_site_option('wpmu_sitewide_plugins');
1762
+		$active_sitewide_plugins = get_site_option('active_sitewide_plugins');
1763
+		if ($wpmu_sitewide_plugins) {
1764
+			if ( ! $active_sitewide_plugins)
1765 1765
 				$sitewide_plugins = (array) $wpmu_sitewide_plugins;
1766 1766
 			else
1767
-				$sitewide_plugins = array_merge( (array) $active_sitewide_plugins, (array) $wpmu_sitewide_plugins );
1767
+				$sitewide_plugins = array_merge((array) $active_sitewide_plugins, (array) $wpmu_sitewide_plugins);
1768 1768
 
1769
-			update_site_option( 'active_sitewide_plugins', $sitewide_plugins );
1769
+			update_site_option('active_sitewide_plugins', $sitewide_plugins);
1770 1770
 		}
1771
-		delete_site_option( 'wpmu_sitewide_plugins' );
1772
-		delete_site_option( 'deactivated_sitewide_plugins' );
1771
+		delete_site_option('wpmu_sitewide_plugins');
1772
+		delete_site_option('deactivated_sitewide_plugins');
1773 1773
 
1774 1774
 		$start = 0;
1775
-		while( $rows = $wpdb->get_results( "SELECT meta_key, meta_value FROM {$wpdb->sitemeta} ORDER BY meta_id LIMIT $start, 20" ) ) {
1776
-			foreach ( $rows as $row ) {
1775
+		while ($rows = $wpdb->get_results("SELECT meta_key, meta_value FROM {$wpdb->sitemeta} ORDER BY meta_id LIMIT $start, 20")) {
1776
+			foreach ($rows as $row) {
1777 1777
 				$value = $row->meta_value;
1778
-				if ( !@unserialize( $value ) )
1779
-					$value = stripslashes( $value );
1780
-				if ( $value !== $row->meta_value ) {
1781
-					update_site_option( $row->meta_key, $value );
1778
+				if ( ! @unserialize($value))
1779
+					$value = stripslashes($value);
1780
+				if ($value !== $row->meta_value) {
1781
+					update_site_option($row->meta_key, $value);
1782 1782
 				}
1783 1783
 			}
1784 1784
 			$start += 20;
@@ -1786,95 +1786,95 @@  discard block
 block discarded – undo
1786 1786
 	}
1787 1787
 
1788 1788
 	// 3.0
1789
-	if ( $wp_current_db_version < 13576 )
1790
-		update_site_option( 'global_terms_enabled', '1' );
1789
+	if ($wp_current_db_version < 13576)
1790
+		update_site_option('global_terms_enabled', '1');
1791 1791
 
1792 1792
 	// 3.3
1793
-	if ( $wp_current_db_version < 19390 )
1794
-		update_site_option( 'initial_db_version', $wp_current_db_version );
1793
+	if ($wp_current_db_version < 19390)
1794
+		update_site_option('initial_db_version', $wp_current_db_version);
1795 1795
 
1796
-	if ( $wp_current_db_version < 19470 ) {
1797
-		if ( false === get_site_option( 'active_sitewide_plugins' ) )
1798
-			update_site_option( 'active_sitewide_plugins', array() );
1796
+	if ($wp_current_db_version < 19470) {
1797
+		if (false === get_site_option('active_sitewide_plugins'))
1798
+			update_site_option('active_sitewide_plugins', array());
1799 1799
 	}
1800 1800
 
1801 1801
 	// 3.4
1802
-	if ( $wp_current_db_version < 20148 ) {
1802
+	if ($wp_current_db_version < 20148) {
1803 1803
 		// 'allowedthemes' keys things by stylesheet. 'allowed_themes' keyed things by name.
1804
-		$allowedthemes  = get_site_option( 'allowedthemes'  );
1805
-		$allowed_themes = get_site_option( 'allowed_themes' );
1806
-		if ( false === $allowedthemes && is_array( $allowed_themes ) && $allowed_themes ) {
1804
+		$allowedthemes  = get_site_option('allowedthemes');
1805
+		$allowed_themes = get_site_option('allowed_themes');
1806
+		if (false === $allowedthemes && is_array($allowed_themes) && $allowed_themes) {
1807 1807
 			$converted = array();
1808 1808
 			$themes = wp_get_themes();
1809
-			foreach ( $themes as $stylesheet => $theme_data ) {
1810
-				if ( isset( $allowed_themes[ $theme_data->get('Name') ] ) )
1811
-					$converted[ $stylesheet ] = true;
1809
+			foreach ($themes as $stylesheet => $theme_data) {
1810
+				if (isset($allowed_themes[$theme_data->get('Name')]))
1811
+					$converted[$stylesheet] = true;
1812 1812
 			}
1813
-			update_site_option( 'allowedthemes', $converted );
1814
-			delete_site_option( 'allowed_themes' );
1813
+			update_site_option('allowedthemes', $converted);
1814
+			delete_site_option('allowed_themes');
1815 1815
 		}
1816 1816
 	}
1817 1817
 
1818 1818
 	// 3.5
1819
-	if ( $wp_current_db_version < 21823 )
1820
-		update_site_option( 'ms_files_rewriting', '1' );
1819
+	if ($wp_current_db_version < 21823)
1820
+		update_site_option('ms_files_rewriting', '1');
1821 1821
 
1822 1822
 	// 3.5.2
1823
-	if ( $wp_current_db_version < 24448 ) {
1824
-		$illegal_names = get_site_option( 'illegal_names' );
1825
-		if ( is_array( $illegal_names ) && count( $illegal_names ) === 1 ) {
1826
-			$illegal_name = reset( $illegal_names );
1827
-			$illegal_names = explode( ' ', $illegal_name );
1828
-			update_site_option( 'illegal_names', $illegal_names );
1823
+	if ($wp_current_db_version < 24448) {
1824
+		$illegal_names = get_site_option('illegal_names');
1825
+		if (is_array($illegal_names) && count($illegal_names) === 1) {
1826
+			$illegal_name = reset($illegal_names);
1827
+			$illegal_names = explode(' ', $illegal_name);
1828
+			update_site_option('illegal_names', $illegal_names);
1829 1829
 		}
1830 1830
 	}
1831 1831
 
1832 1832
 	// 4.2
1833
-	if ( $wp_current_db_version < 31351 && $wpdb->charset === 'utf8mb4' ) {
1834
-		if ( wp_should_upgrade_global_tables() ) {
1835
-			$wpdb->query( "ALTER TABLE $wpdb->usermeta DROP INDEX meta_key, ADD INDEX meta_key(meta_key(191))" );
1836
-			$wpdb->query( "ALTER TABLE $wpdb->site DROP INDEX domain, ADD INDEX domain(domain(140),path(51))" );
1837
-			$wpdb->query( "ALTER TABLE $wpdb->sitemeta DROP INDEX meta_key, ADD INDEX meta_key(meta_key(191))" );
1838
-			$wpdb->query( "ALTER TABLE $wpdb->signups DROP INDEX domain_path, ADD INDEX domain_path(domain(140),path(51))" );
1833
+	if ($wp_current_db_version < 31351 && $wpdb->charset === 'utf8mb4') {
1834
+		if (wp_should_upgrade_global_tables()) {
1835
+			$wpdb->query("ALTER TABLE $wpdb->usermeta DROP INDEX meta_key, ADD INDEX meta_key(meta_key(191))");
1836
+			$wpdb->query("ALTER TABLE $wpdb->site DROP INDEX domain, ADD INDEX domain(domain(140),path(51))");
1837
+			$wpdb->query("ALTER TABLE $wpdb->sitemeta DROP INDEX meta_key, ADD INDEX meta_key(meta_key(191))");
1838
+			$wpdb->query("ALTER TABLE $wpdb->signups DROP INDEX domain_path, ADD INDEX domain_path(domain(140),path(51))");
1839 1839
 
1840
-			$tables = $wpdb->tables( 'global' );
1840
+			$tables = $wpdb->tables('global');
1841 1841
 
1842 1842
 			// sitecategories may not exist.
1843
-			if ( ! $wpdb->get_var( "SHOW TABLES LIKE '{$tables['sitecategories']}'" ) ) {
1844
-				unset( $tables['sitecategories'] );
1843
+			if ( ! $wpdb->get_var("SHOW TABLES LIKE '{$tables['sitecategories']}'")) {
1844
+				unset($tables['sitecategories']);
1845 1845
 			}
1846 1846
 
1847
-			foreach ( $tables as $table ) {
1848
-				maybe_convert_table_to_utf8mb4( $table );
1847
+			foreach ($tables as $table) {
1848
+				maybe_convert_table_to_utf8mb4($table);
1849 1849
 			}
1850 1850
 		}
1851 1851
 	}
1852 1852
 
1853 1853
 	// 4.3
1854
-	if ( $wp_current_db_version < 33055 && 'utf8mb4' === $wpdb->charset ) {
1855
-		if ( wp_should_upgrade_global_tables() ) {
1854
+	if ($wp_current_db_version < 33055 && 'utf8mb4' === $wpdb->charset) {
1855
+		if (wp_should_upgrade_global_tables()) {
1856 1856
 			$upgrade = false;
1857
-			$indexes = $wpdb->get_results( "SHOW INDEXES FROM $wpdb->signups" );
1858
-			foreach ( $indexes as $index ) {
1859
-				if ( 'domain_path' == $index->Key_name && 'domain' == $index->Column_name && 140 != $index->Sub_part ) {
1857
+			$indexes = $wpdb->get_results("SHOW INDEXES FROM $wpdb->signups");
1858
+			foreach ($indexes as $index) {
1859
+				if ('domain_path' == $index->Key_name && 'domain' == $index->Column_name && 140 != $index->Sub_part) {
1860 1860
 					$upgrade = true;
1861 1861
 					break;
1862 1862
 				}
1863 1863
 			}
1864 1864
 
1865
-			if ( $upgrade ) {
1866
-				$wpdb->query( "ALTER TABLE $wpdb->signups DROP INDEX domain_path, ADD INDEX domain_path(domain(140),path(51))" );
1865
+			if ($upgrade) {
1866
+				$wpdb->query("ALTER TABLE $wpdb->signups DROP INDEX domain_path, ADD INDEX domain_path(domain(140),path(51))");
1867 1867
 			}
1868 1868
 
1869
-			$tables = $wpdb->tables( 'global' );
1869
+			$tables = $wpdb->tables('global');
1870 1870
 
1871 1871
 			// sitecategories may not exist.
1872
-			if ( ! $wpdb->get_var( "SHOW TABLES LIKE '{$tables['sitecategories']}'" ) ) {
1873
-				unset( $tables['sitecategories'] );
1872
+			if ( ! $wpdb->get_var("SHOW TABLES LIKE '{$tables['sitecategories']}'")) {
1873
+				unset($tables['sitecategories']);
1874 1874
 			}
1875 1875
 
1876
-			foreach ( $tables as $table ) {
1877
-				maybe_convert_table_to_utf8mb4( $table );
1876
+			foreach ($tables as $table) {
1877
+				maybe_convert_table_to_utf8mb4($table);
1878 1878
 			}
1879 1879
 		}
1880 1880
 	}
@@ -1902,9 +1902,9 @@  discard block
 block discarded – undo
1902 1902
 function maybe_create_table($table_name, $create_ddl) {
1903 1903
 	global $wpdb;
1904 1904
 
1905
-	$query = $wpdb->prepare( "SHOW TABLES LIKE %s", $wpdb->esc_like( $table_name ) );
1905
+	$query = $wpdb->prepare("SHOW TABLES LIKE %s", $wpdb->esc_like($table_name));
1906 1906
 
1907
-	if ( $wpdb->get_var( $query ) == $table_name ) {
1907
+	if ($wpdb->get_var($query) == $table_name) {
1908 1908
 		return true;
1909 1909
 	}
1910 1910
 
@@ -1912,7 +1912,7 @@  discard block
 block discarded – undo
1912 1912
 	$wpdb->query($create_ddl);
1913 1913
 
1914 1914
 	// We cannot directly tell that whether this succeeded!
1915
-	if ( $wpdb->get_var( $query ) == $table_name ) {
1915
+	if ($wpdb->get_var($query) == $table_name) {
1916 1916
 		return true;
1917 1917
 	}
1918 1918
 	return false;
@@ -1973,7 +1973,7 @@  discard block
 block discarded – undo
1973 1973
  */
1974 1974
 function maybe_add_column($table_name, $column_name, $create_ddl) {
1975 1975
 	global $wpdb;
1976
-	foreach ($wpdb->get_col("DESC $table_name", 0) as $column ) {
1976
+	foreach ($wpdb->get_col("DESC $table_name", 0) as $column) {
1977 1977
 		if ($column == $column_name) {
1978 1978
 			return true;
1979 1979
 		}
@@ -1983,7 +1983,7 @@  discard block
 block discarded – undo
1983 1983
 	$wpdb->query($create_ddl);
1984 1984
 
1985 1985
 	// We cannot directly tell that whether this succeeded!
1986
-	foreach ($wpdb->get_col("DESC $table_name", 0) as $column ) {
1986
+	foreach ($wpdb->get_col("DESC $table_name", 0) as $column) {
1987 1987
 		if ($column == $column_name) {
1988 1988
 			return true;
1989 1989
 		}
@@ -2001,37 +2001,37 @@  discard block
 block discarded – undo
2001 2001
  * @param string $table The table to convert.
2002 2002
  * @return bool true if the table was converted, false if it wasn't.
2003 2003
  */
2004
-function maybe_convert_table_to_utf8mb4( $table ) {
2004
+function maybe_convert_table_to_utf8mb4($table) {
2005 2005
 	global $wpdb;
2006 2006
 
2007
-	$results = $wpdb->get_results( "SHOW FULL COLUMNS FROM `$table`" );
2008
-	if ( ! $results ) {
2007
+	$results = $wpdb->get_results("SHOW FULL COLUMNS FROM `$table`");
2008
+	if ( ! $results) {
2009 2009
 		return false;
2010 2010
 	}
2011 2011
 
2012
-	foreach ( $results as $column ) {
2013
-		if ( $column->Collation ) {
2014
-			list( $charset ) = explode( '_', $column->Collation );
2015
-			$charset = strtolower( $charset );
2016
-			if ( 'utf8' !== $charset && 'utf8mb4' !== $charset ) {
2012
+	foreach ($results as $column) {
2013
+		if ($column->Collation) {
2014
+			list($charset) = explode('_', $column->Collation);
2015
+			$charset = strtolower($charset);
2016
+			if ('utf8' !== $charset && 'utf8mb4' !== $charset) {
2017 2017
 				// Don't upgrade tables that have non-utf8 columns.
2018 2018
 				return false;
2019 2019
 			}
2020 2020
 		}
2021 2021
 	}
2022 2022
 
2023
-	$table_details = $wpdb->get_row( "SHOW TABLE STATUS LIKE '$table'" );
2024
-	if ( ! $table_details ) {
2023
+	$table_details = $wpdb->get_row("SHOW TABLE STATUS LIKE '$table'");
2024
+	if ( ! $table_details) {
2025 2025
 		return false;
2026 2026
 	}
2027 2027
 
2028
-	list( $table_charset ) = explode( '_', $table_details->Collation );
2029
-	$table_charset = strtolower( $table_charset );
2030
-	if ( 'utf8mb4' === $table_charset ) {
2028
+	list($table_charset) = explode('_', $table_details->Collation);
2029
+	$table_charset = strtolower($table_charset);
2030
+	if ('utf8mb4' === $table_charset) {
2031 2031
 		return true;
2032 2032
 	}
2033 2033
 
2034
-	return $wpdb->query( "ALTER TABLE $table CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci" );
2034
+	return $wpdb->query("ALTER TABLE $table CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci");
2035 2035
 }
2036 2036
 
2037 2037
 /**
@@ -2046,11 +2046,11 @@  discard block
 block discarded – undo
2046 2046
 function get_alloptions_110() {
2047 2047
 	global $wpdb;
2048 2048
 	$all_options = new stdClass;
2049
-	if ( $options = $wpdb->get_results( "SELECT option_name, option_value FROM $wpdb->options" ) ) {
2050
-		foreach ( $options as $option ) {
2051
-			if ( 'siteurl' == $option->option_name || 'home' == $option->option_name || 'category_base' == $option->option_name )
2052
-				$option->option_value = untrailingslashit( $option->option_value );
2053
-			$all_options->{$option->option_name} = stripslashes( $option->option_value );
2049
+	if ($options = $wpdb->get_results("SELECT option_name, option_value FROM $wpdb->options")) {
2050
+		foreach ($options as $option) {
2051
+			if ('siteurl' == $option->option_name || 'home' == $option->option_name || 'category_base' == $option->option_name)
2052
+				$option->option_value = untrailingslashit($option->option_value);
2053
+			$all_options->{$option->option_name} = stripslashes($option->option_value);
2054 2054
 		}
2055 2055
 	}
2056 2056
 	return $all_options;
@@ -2071,21 +2071,21 @@  discard block
 block discarded – undo
2071 2071
 function __get_option($setting) {
2072 2072
 	global $wpdb;
2073 2073
 
2074
-	if ( $setting == 'home' && defined( 'WP_HOME' ) )
2075
-		return untrailingslashit( WP_HOME );
2074
+	if ($setting == 'home' && defined('WP_HOME'))
2075
+		return untrailingslashit(WP_HOME);
2076 2076
 
2077
-	if ( $setting == 'siteurl' && defined( 'WP_SITEURL' ) )
2078
-		return untrailingslashit( WP_SITEURL );
2077
+	if ($setting == 'siteurl' && defined('WP_SITEURL'))
2078
+		return untrailingslashit(WP_SITEURL);
2079 2079
 
2080
-	$option = $wpdb->get_var( $wpdb->prepare("SELECT option_value FROM $wpdb->options WHERE option_name = %s", $setting ) );
2080
+	$option = $wpdb->get_var($wpdb->prepare("SELECT option_value FROM $wpdb->options WHERE option_name = %s", $setting));
2081 2081
 
2082
-	if ( 'home' == $setting && '' == $option )
2083
-		return __get_option( 'siteurl' );
2082
+	if ('home' == $setting && '' == $option)
2083
+		return __get_option('siteurl');
2084 2084
 
2085
-	if ( 'siteurl' == $setting || 'home' == $setting || 'category_base' == $setting || 'tag_base' == $setting )
2086
-		$option = untrailingslashit( $option );
2085
+	if ('siteurl' == $setting || 'home' == $setting || 'category_base' == $setting || 'tag_base' == $setting)
2086
+		$option = untrailingslashit($option);
2087 2087
 
2088
-	return maybe_unserialize( $option );
2088
+	return maybe_unserialize($option);
2089 2089
 }
2090 2090
 
2091 2091
 /**
@@ -2133,16 +2133,16 @@  discard block
 block discarded – undo
2133 2133
  *                              Default true.
2134 2134
  * @return array Strings containing the results of the various update queries.
2135 2135
  */
2136
-function dbDelta( $queries = '', $execute = true ) {
2136
+function dbDelta($queries = '', $execute = true) {
2137 2137
 	global $wpdb;
2138 2138
 
2139
-	if ( in_array( $queries, array( '', 'all', 'blog', 'global', 'ms_global' ), true ) )
2140
-	    $queries = wp_get_db_schema( $queries );
2139
+	if (in_array($queries, array('', 'all', 'blog', 'global', 'ms_global'), true))
2140
+	    $queries = wp_get_db_schema($queries);
2141 2141
 
2142 2142
 	// Separate individual queries into an array
2143
-	if ( !is_array($queries) ) {
2144
-		$queries = explode( ';', $queries );
2145
-		$queries = array_filter( $queries );
2143
+	if ( ! is_array($queries)) {
2144
+		$queries = explode(';', $queries);
2145
+		$queries = array_filter($queries);
2146 2146
 	}
2147 2147
 
2148 2148
 	/**
@@ -2152,7 +2152,7 @@  discard block
 block discarded – undo
2152 2152
 	 *
2153 2153
 	 * @param array $queries An array of dbDelta SQL queries.
2154 2154
 	 */
2155
-	$queries = apply_filters( 'dbdelta_queries', $queries );
2155
+	$queries = apply_filters('dbdelta_queries', $queries);
2156 2156
 
2157 2157
 	$cqueries = array(); // Creation Queries
2158 2158
 	$iqueries = array(); // Insertion Queries
@@ -2160,14 +2160,14 @@  discard block
 block discarded – undo
2160 2160
 
2161 2161
 	// Create a tablename index for an array ($cqueries) of queries
2162 2162
 	foreach ($queries as $qry) {
2163
-		if ( preg_match( "|CREATE TABLE ([^ ]*)|", $qry, $matches ) ) {
2164
-			$cqueries[ trim( $matches[1], '`' ) ] = $qry;
2163
+		if (preg_match("|CREATE TABLE ([^ ]*)|", $qry, $matches)) {
2164
+			$cqueries[trim($matches[1], '`')] = $qry;
2165 2165
 			$for_update[$matches[1]] = 'Created table '.$matches[1];
2166
-		} elseif ( preg_match( "|CREATE DATABASE ([^ ]*)|", $qry, $matches ) ) {
2167
-			array_unshift( $cqueries, $qry );
2168
-		} elseif ( preg_match( "|INSERT INTO ([^ ]*)|", $qry, $matches ) ) {
2166
+		} elseif (preg_match("|CREATE DATABASE ([^ ]*)|", $qry, $matches)) {
2167
+			array_unshift($cqueries, $qry);
2168
+		} elseif (preg_match("|INSERT INTO ([^ ]*)|", $qry, $matches)) {
2169 2169
 			$iqueries[] = $qry;
2170
-		} elseif ( preg_match( "|UPDATE ([^ ]*)|", $qry, $matches ) ) {
2170
+		} elseif (preg_match("|UPDATE ([^ ]*)|", $qry, $matches)) {
2171 2171
 			$iqueries[] = $qry;
2172 2172
 		} else {
2173 2173
 			// Unrecognized query type
@@ -2183,7 +2183,7 @@  discard block
 block discarded – undo
2183 2183
 	 *
2184 2184
 	 * @param array $cqueries An array of dbDelta create SQL queries.
2185 2185
 	 */
2186
-	$cqueries = apply_filters( 'dbdelta_create_queries', $cqueries );
2186
+	$cqueries = apply_filters('dbdelta_create_queries', $cqueries);
2187 2187
 
2188 2188
 	/**
2189 2189
 	 * Filters the dbDelta SQL queries for inserting or updating.
@@ -2194,25 +2194,25 @@  discard block
 block discarded – undo
2194 2194
 	 *
2195 2195
 	 * @param array $iqueries An array of dbDelta insert or update SQL queries.
2196 2196
 	 */
2197
-	$iqueries = apply_filters( 'dbdelta_insert_queries', $iqueries );
2197
+	$iqueries = apply_filters('dbdelta_insert_queries', $iqueries);
2198 2198
 
2199
-	$text_fields = array( 'tinytext', 'text', 'mediumtext', 'longtext' );
2200
-	$blob_fields = array( 'tinyblob', 'blob', 'mediumblob', 'longblob' );
2199
+	$text_fields = array('tinytext', 'text', 'mediumtext', 'longtext');
2200
+	$blob_fields = array('tinyblob', 'blob', 'mediumblob', 'longblob');
2201 2201
 
2202
-	$global_tables = $wpdb->tables( 'global' );
2203
-	foreach ( $cqueries as $table => $qry ) {
2202
+	$global_tables = $wpdb->tables('global');
2203
+	foreach ($cqueries as $table => $qry) {
2204 2204
 		// Upgrade global tables only for the main site. Don't upgrade at all if conditions are not optimal.
2205
-		if ( in_array( $table, $global_tables ) && ! wp_should_upgrade_global_tables() ) {
2206
-			unset( $cqueries[ $table ], $for_update[ $table ] );
2205
+		if (in_array($table, $global_tables) && ! wp_should_upgrade_global_tables()) {
2206
+			unset($cqueries[$table], $for_update[$table]);
2207 2207
 			continue;
2208 2208
 		}
2209 2209
 
2210 2210
 		// Fetch the table column structure from the database
2211 2211
 		$suppress = $wpdb->suppress_errors();
2212 2212
 		$tablefields = $wpdb->get_results("DESCRIBE {$table};");
2213
-		$wpdb->suppress_errors( $suppress );
2213
+		$wpdb->suppress_errors($suppress);
2214 2214
 
2215
-		if ( ! $tablefields )
2215
+		if ( ! $tablefields)
2216 2216
 			continue;
2217 2217
 
2218 2218
 		// Clear the field and index arrays.
@@ -2226,17 +2226,17 @@  discard block
 block discarded – undo
2226 2226
 		$flds = explode("\n", $qryline);
2227 2227
 
2228 2228
 		// For every field line specified in the query.
2229
-		foreach ( $flds as $fld ) {
2230
-			$fld = trim( $fld, " \t\n\r\0\x0B," ); // Default trim characters, plus ','.
2229
+		foreach ($flds as $fld) {
2230
+			$fld = trim($fld, " \t\n\r\0\x0B,"); // Default trim characters, plus ','.
2231 2231
 
2232 2232
 			// Extract the field name.
2233
-			preg_match( '|^([^ ]*)|', $fld, $fvals );
2234
-			$fieldname = trim( $fvals[1], '`' );
2235
-			$fieldname_lowercased = strtolower( $fieldname );
2233
+			preg_match('|^([^ ]*)|', $fld, $fvals);
2234
+			$fieldname = trim($fvals[1], '`');
2235
+			$fieldname_lowercased = strtolower($fieldname);
2236 2236
 
2237 2237
 			// Verify the found field name.
2238 2238
 			$validfield = true;
2239
-			switch ( $fieldname_lowercased ) {
2239
+			switch ($fieldname_lowercased) {
2240 2240
 				case '':
2241 2241
 				case 'primary':
2242 2242
 				case 'index':
@@ -2280,19 +2280,19 @@  discard block
 block discarded – undo
2280 2280
 					);
2281 2281
 
2282 2282
 					// Uppercase the index type and normalize space characters.
2283
-					$index_type = strtoupper( preg_replace( '/\s+/', ' ', trim( $index_matches['index_type'] ) ) );
2283
+					$index_type = strtoupper(preg_replace('/\s+/', ' ', trim($index_matches['index_type'])));
2284 2284
 
2285 2285
 					// 'INDEX' is a synonym for 'KEY', standardize on 'KEY'.
2286
-					$index_type = str_replace( 'INDEX', 'KEY', $index_type );
2286
+					$index_type = str_replace('INDEX', 'KEY', $index_type);
2287 2287
 
2288 2288
 					// Escape the index name with backticks. An index for a primary key has no name.
2289
-					$index_name = ( 'PRIMARY KEY' === $index_type ) ? '' : '`' . strtolower( $index_matches['index_name'] ) . '`';
2289
+					$index_name = ('PRIMARY KEY' === $index_type) ? '' : '`'.strtolower($index_matches['index_name']).'`';
2290 2290
 
2291 2291
 					// Parse the columns. Multiple columns are separated by a comma.
2292
-					$index_columns = array_map( 'trim', explode( ',', $index_matches['index_columns'] ) );
2292
+					$index_columns = array_map('trim', explode(',', $index_matches['index_columns']));
2293 2293
 
2294 2294
 					// Normalize columns.
2295
-					foreach ( $index_columns as &$index_column ) {
2295
+					foreach ($index_columns as &$index_column) {
2296 2296
 						// Extract column name and number of indexed characters (sub_part).
2297 2297
 						preg_match(
2298 2298
 							  '/'
@@ -2317,66 +2317,66 @@  discard block
 block discarded – undo
2317 2317
 						);
2318 2318
 
2319 2319
 						// Escape the column name with backticks.
2320
-						$index_column = '`' . $index_column_matches['column_name'] . '`';
2320
+						$index_column = '`'.$index_column_matches['column_name'].'`';
2321 2321
 
2322 2322
 						// Append the optional sup part with the number of indexed characters.
2323
-						if ( isset( $index_column_matches['sub_part'] ) ) {
2324
-							$index_column .= '(' . $index_column_matches['sub_part'] . ')';
2323
+						if (isset($index_column_matches['sub_part'])) {
2324
+							$index_column .= '('.$index_column_matches['sub_part'].')';
2325 2325
 						}
2326 2326
 					}
2327 2327
 
2328 2328
 					// Build the normalized index definition and add it to the list of indices.
2329
-					$indices[] = "{$index_type} {$index_name} (" . implode( ',', $index_columns ) . ")";
2329
+					$indices[] = "{$index_type} {$index_name} (".implode(',', $index_columns).")";
2330 2330
 
2331 2331
 					// Destroy no longer needed variables.
2332
-					unset( $index_column, $index_column_matches, $index_matches, $index_type, $index_name, $index_columns );
2332
+					unset($index_column, $index_column_matches, $index_matches, $index_type, $index_name, $index_columns);
2333 2333
 
2334 2334
 					break;
2335 2335
 			}
2336 2336
 
2337 2337
 			// If it's a valid field, add it to the field array.
2338
-			if ( $validfield ) {
2339
-				$cfields[ $fieldname_lowercased ] = $fld;
2338
+			if ($validfield) {
2339
+				$cfields[$fieldname_lowercased] = $fld;
2340 2340
 			}
2341 2341
 		}
2342 2342
 
2343 2343
 		// For every field in the table.
2344
-		foreach ( $tablefields as $tablefield ) {
2345
-			$tablefield_field_lowercased = strtolower( $tablefield->Field );
2346
-			$tablefield_type_lowercased = strtolower( $tablefield->Type );
2344
+		foreach ($tablefields as $tablefield) {
2345
+			$tablefield_field_lowercased = strtolower($tablefield->Field);
2346
+			$tablefield_type_lowercased = strtolower($tablefield->Type);
2347 2347
 
2348 2348
 			// If the table field exists in the field array ...
2349
-			if ( array_key_exists( $tablefield_field_lowercased, $cfields ) ) {
2349
+			if (array_key_exists($tablefield_field_lowercased, $cfields)) {
2350 2350
 
2351 2351
 				// Get the field type from the query.
2352
-				preg_match( '|`?' . $tablefield->Field . '`? ([^ ]*( unsigned)?)|i', $cfields[ $tablefield_field_lowercased ], $matches );
2352
+				preg_match('|`?'.$tablefield->Field.'`? ([^ ]*( unsigned)?)|i', $cfields[$tablefield_field_lowercased], $matches);
2353 2353
 				$fieldtype = $matches[1];
2354
-				$fieldtype_lowercased = strtolower( $fieldtype );
2354
+				$fieldtype_lowercased = strtolower($fieldtype);
2355 2355
 
2356 2356
 				// Is actual field type different from the field type in query?
2357 2357
 				if ($tablefield->Type != $fieldtype) {
2358 2358
 					$do_change = true;
2359
-					if ( in_array( $fieldtype_lowercased, $text_fields ) && in_array( $tablefield_type_lowercased, $text_fields ) ) {
2360
-						if ( array_search( $fieldtype_lowercased, $text_fields ) < array_search( $tablefield_type_lowercased, $text_fields ) ) {
2359
+					if (in_array($fieldtype_lowercased, $text_fields) && in_array($tablefield_type_lowercased, $text_fields)) {
2360
+						if (array_search($fieldtype_lowercased, $text_fields) < array_search($tablefield_type_lowercased, $text_fields)) {
2361 2361
 							$do_change = false;
2362 2362
 						}
2363 2363
 					}
2364 2364
 
2365
-					if ( in_array( $fieldtype_lowercased, $blob_fields ) && in_array( $tablefield_type_lowercased, $blob_fields ) ) {
2366
-						if ( array_search( $fieldtype_lowercased, $blob_fields ) < array_search( $tablefield_type_lowercased, $blob_fields ) ) {
2365
+					if (in_array($fieldtype_lowercased, $blob_fields) && in_array($tablefield_type_lowercased, $blob_fields)) {
2366
+						if (array_search($fieldtype_lowercased, $blob_fields) < array_search($tablefield_type_lowercased, $blob_fields)) {
2367 2367
 							$do_change = false;
2368 2368
 						}
2369 2369
 					}
2370 2370
 
2371
-					if ( $do_change ) {
2371
+					if ($do_change) {
2372 2372
 						// Add a query to change the column type.
2373
-						$cqueries[] = "ALTER TABLE {$table} CHANGE COLUMN `{$tablefield->Field}` " . $cfields[ $tablefield_field_lowercased ];
2373
+						$cqueries[] = "ALTER TABLE {$table} CHANGE COLUMN `{$tablefield->Field}` ".$cfields[$tablefield_field_lowercased];
2374 2374
 						$for_update[$table.'.'.$tablefield->Field] = "Changed type of {$table}.{$tablefield->Field} from {$tablefield->Type} to {$fieldtype}";
2375 2375
 					}
2376 2376
 				}
2377 2377
 
2378 2378
 				// Get the default value from the array.
2379
-				if ( preg_match( "| DEFAULT '(.*?)'|i", $cfields[ $tablefield_field_lowercased ], $matches ) ) {
2379
+				if (preg_match("| DEFAULT '(.*?)'|i", $cfields[$tablefield_field_lowercased], $matches)) {
2380 2380
 					$default_value = $matches[1];
2381 2381
 					if ($tablefield->Default != $default_value) {
2382 2382
 						// Add a query to change the column's default value
@@ -2386,7 +2386,7 @@  discard block
 block discarded – undo
2386 2386
 				}
2387 2387
 
2388 2388
 				// Remove the field from the array (so it's not added).
2389
-				unset( $cfields[ $tablefield_field_lowercased ] );
2389
+				unset($cfields[$tablefield_field_lowercased]);
2390 2390
 			} else {
2391 2391
 				// This field exists in the table, but not in the creation queries?
2392 2392
 			}
@@ -2410,9 +2410,9 @@  discard block
 block discarded – undo
2410 2410
 			foreach ($tableindices as $tableindex) {
2411 2411
 
2412 2412
 				// Add the index to the index data array.
2413
-				$keyname = strtolower( $tableindex->Key_name );
2413
+				$keyname = strtolower($tableindex->Key_name);
2414 2414
 				$index_ary[$keyname]['columns'][] = array('fieldname' => $tableindex->Column_name, 'subpart' => $tableindex->Sub_part);
2415
-				$index_ary[$keyname]['unique'] = ($tableindex->Non_unique == 0)?true:false;
2415
+				$index_ary[$keyname]['unique'] = ($tableindex->Non_unique == 0) ? true : false;
2416 2416
 				$index_ary[$keyname]['index_type'] = $tableindex->Index_type;
2417 2417
 			}
2418 2418
 
@@ -2423,36 +2423,36 @@  discard block
 block discarded – undo
2423 2423
 				$index_string = '';
2424 2424
 				if ($index_name == 'primary') {
2425 2425
 					$index_string .= 'PRIMARY ';
2426
-				} elseif ( $index_data['unique'] ) {
2426
+				} elseif ($index_data['unique']) {
2427 2427
 					$index_string .= 'UNIQUE ';
2428 2428
 				}
2429
-				if ( 'FULLTEXT' === strtoupper( $index_data['index_type'] ) ) {
2429
+				if ('FULLTEXT' === strtoupper($index_data['index_type'])) {
2430 2430
 					$index_string .= 'FULLTEXT ';
2431 2431
 				}
2432
-				if ( 'SPATIAL' === strtoupper( $index_data['index_type'] ) ) {
2432
+				if ('SPATIAL' === strtoupper($index_data['index_type'])) {
2433 2433
 					$index_string .= 'SPATIAL ';
2434 2434
 				}
2435 2435
 				$index_string .= 'KEY ';
2436
-				if ( 'primary' !== $index_name  ) {
2437
-					$index_string .= '`' . $index_name . '`';
2436
+				if ('primary' !== $index_name) {
2437
+					$index_string .= '`'.$index_name.'`';
2438 2438
 				}
2439 2439
 				$index_columns = '';
2440 2440
 
2441 2441
 				// For each column in the index.
2442 2442
 				foreach ($index_data['columns'] as $column_data) {
2443
-					if ( $index_columns != '' ) {
2443
+					if ($index_columns != '') {
2444 2444
 						$index_columns .= ',';
2445 2445
 					}
2446 2446
 
2447 2447
 					// Add the field to the column list string.
2448
-					$index_columns .= '`' . $column_data['fieldname'] . '`';
2448
+					$index_columns .= '`'.$column_data['fieldname'].'`';
2449 2449
 					if ($column_data['subpart'] != '') {
2450 2450
 						$index_columns .= '('.$column_data['subpart'].')';
2451 2451
 					}
2452 2452
 				}
2453 2453
 
2454 2454
 				// The alternative index string doesn't care about subparts
2455
-				$alt_index_columns = preg_replace( '/\([^)]*\)/', '', $index_columns );
2455
+				$alt_index_columns = preg_replace('/\([^)]*\)/', '', $index_columns);
2456 2456
 
2457 2457
 				// Add the column list to the index create string.
2458 2458
 				$index_strings = array(
@@ -2460,9 +2460,9 @@  discard block
 block discarded – undo
2460 2460
 					"$index_string ($alt_index_columns)",
2461 2461
 				);
2462 2462
 
2463
-				foreach ( $index_strings as $index_string ) {
2464
-					if ( ! ( ( $aindex = array_search( $index_string, $indices ) ) === false ) ) {
2465
-						unset( $indices[ $aindex ] );
2463
+				foreach ($index_strings as $index_string) {
2464
+					if ( ! (($aindex = array_search($index_string, $indices)) === false)) {
2465
+						unset($indices[$aindex]);
2466 2466
 						break;
2467 2467
 					}
2468 2468
 				}
@@ -2470,14 +2470,14 @@  discard block
 block discarded – undo
2470 2470
 		}
2471 2471
 
2472 2472
 		// For every remaining index specified for the table.
2473
-		foreach ( (array) $indices as $index ) {
2473
+		foreach ((array) $indices as $index) {
2474 2474
 			// Push a query line into $cqueries that adds the index to that table.
2475 2475
 			$cqueries[] = "ALTER TABLE {$table} ADD $index";
2476
-			$for_update[] = 'Added index ' . $table . ' ' . $index;
2476
+			$for_update[] = 'Added index '.$table.' '.$index;
2477 2477
 		}
2478 2478
 
2479 2479
 		// Remove the original table creation query from processing.
2480
-		unset( $cqueries[ $table ], $for_update[ $table ] );
2480
+		unset($cqueries[$table], $for_update[$table]);
2481 2481
 	}
2482 2482
 
2483 2483
 	$allqueries = array_merge($cqueries, $iqueries);
@@ -2502,8 +2502,8 @@  discard block
 block discarded – undo
2502 2502
  *
2503 2503
  * @param string $tables Optional. Which set of tables to update. Default is 'all'.
2504 2504
  */
2505
-function make_db_current( $tables = 'all' ) {
2506
-	$alterations = dbDelta( $tables );
2505
+function make_db_current($tables = 'all') {
2506
+	$alterations = dbDelta($tables);
2507 2507
 	echo "<ol>\n";
2508 2508
 	foreach ($alterations as $alteration) echo "<li>$alteration</li>\n";
2509 2509
 	echo "</ol>\n";
@@ -2521,8 +2521,8 @@  discard block
 block discarded – undo
2521 2521
  *
2522 2522
  * @param string $tables Optional. Which set of tables to update. Default is 'all'.
2523 2523
  */
2524
-function make_db_current_silent( $tables = 'all' ) {
2525
-	dbDelta( $tables );
2524
+function make_db_current_silent($tables = 'all') {
2525
+	dbDelta($tables);
2526 2526
 }
2527 2527
 
2528 2528
 /**
@@ -2538,9 +2538,9 @@  discard block
 block discarded – undo
2538 2538
  */
2539 2539
 function make_site_theme_from_oldschool($theme_name, $template) {
2540 2540
 	$home_path = get_home_path();
2541
-	$site_dir = WP_CONTENT_DIR . "/themes/$template";
2541
+	$site_dir = WP_CONTENT_DIR."/themes/$template";
2542 2542
 
2543
-	if (! file_exists("$home_path/index.php"))
2543
+	if ( ! file_exists("$home_path/index.php"))
2544 2544
 		return false;
2545 2545
 
2546 2546
 	/*
@@ -2559,7 +2559,7 @@  discard block
 block discarded – undo
2559 2559
 		if ($oldfile == 'index.php') {
2560 2560
 			$index = implode('', file("$oldpath/$oldfile"));
2561 2561
 			if (strpos($index, 'WP_USE_THEMES') !== false) {
2562
-				if (! @copy(WP_CONTENT_DIR . '/themes/' . WP_DEFAULT_THEME . '/index.php', "$site_dir/$newfile"))
2562
+				if ( ! @copy(WP_CONTENT_DIR.'/themes/'.WP_DEFAULT_THEME.'/index.php', "$site_dir/$newfile"))
2563 2563
 					return false;
2564 2564
 
2565 2565
 				// Don't copy anything.
@@ -2567,7 +2567,7 @@  discard block
 block discarded – undo
2567 2567
 			}
2568 2568
 		}
2569 2569
 
2570
-		if (! @copy("$oldpath/$oldfile", "$site_dir/$newfile"))
2570
+		if ( ! @copy("$oldpath/$oldfile", "$site_dir/$newfile"))
2571 2571
 			return false;
2572 2572
 
2573 2573
 		chmod("$site_dir/$newfile", 0777);
@@ -2579,7 +2579,7 @@  discard block
 block discarded – undo
2579 2579
 
2580 2580
 			foreach ($lines as $line) {
2581 2581
 				if (preg_match('/require.*wp-blog-header/', $line))
2582
-					$line = '//' . $line;
2582
+					$line = '//'.$line;
2583 2583
 
2584 2584
 				// Update stylesheet references.
2585 2585
 				$line = str_replace("<?php echo __get_option('siteurl'); ?>/wp-layout.css", "<?php bloginfo('stylesheet_url'); ?>", $line);
@@ -2594,7 +2594,7 @@  discard block
 block discarded – undo
2594 2594
 	}
2595 2595
 
2596 2596
 	// Add a theme header.
2597
-	$header = "/*\nTheme Name: $theme_name\nTheme URI: " . __get_option('siteurl') . "\nDescription: A theme automatically created by the update.\nVersion: 1.0\nAuthor: Moi\n*/\n";
2597
+	$header = "/*\nTheme Name: $theme_name\nTheme URI: ".__get_option('siteurl')."\nDescription: A theme automatically created by the update.\nVersion: 1.0\nAuthor: Moi\n*/\n";
2598 2598
 
2599 2599
 	$stylelines = file_get_contents("$site_dir/style.css");
2600 2600
 	if ($stylelines) {
@@ -2620,18 +2620,18 @@  discard block
 block discarded – undo
2620 2620
  * @return false|void
2621 2621
  */
2622 2622
 function make_site_theme_from_default($theme_name, $template) {
2623
-	$site_dir = WP_CONTENT_DIR . "/themes/$template";
2624
-	$default_dir = WP_CONTENT_DIR . '/themes/' . WP_DEFAULT_THEME;
2623
+	$site_dir = WP_CONTENT_DIR."/themes/$template";
2624
+	$default_dir = WP_CONTENT_DIR.'/themes/'.WP_DEFAULT_THEME;
2625 2625
 
2626 2626
 	// Copy files from the default theme to the site theme.
2627 2627
 	//$files = array('index.php', 'comments.php', 'comments-popup.php', 'footer.php', 'header.php', 'sidebar.php', 'style.css');
2628 2628
 
2629 2629
 	$theme_dir = @ opendir($default_dir);
2630 2630
 	if ($theme_dir) {
2631
-		while(($theme_file = readdir( $theme_dir )) !== false) {
2631
+		while (($theme_file = readdir($theme_dir)) !== false) {
2632 2632
 			if (is_dir("$default_dir/$theme_file"))
2633 2633
 				continue;
2634
-			if (! @copy("$default_dir/$theme_file", "$site_dir/$theme_file"))
2634
+			if ( ! @copy("$default_dir/$theme_file", "$site_dir/$theme_file"))
2635 2635
 				return;
2636 2636
 			chmod("$site_dir/$theme_file", 0777);
2637 2637
 		}
@@ -2644,28 +2644,28 @@  discard block
 block discarded – undo
2644 2644
 		$f = fopen("$site_dir/style.css", 'w');
2645 2645
 
2646 2646
 		foreach ($stylelines as $line) {
2647
-			if (strpos($line, 'Theme Name:') !== false) $line = 'Theme Name: ' . $theme_name;
2648
-			elseif (strpos($line, 'Theme URI:') !== false) $line = 'Theme URI: ' . __get_option('url');
2647
+			if (strpos($line, 'Theme Name:') !== false) $line = 'Theme Name: '.$theme_name;
2648
+			elseif (strpos($line, 'Theme URI:') !== false) $line = 'Theme URI: '.__get_option('url');
2649 2649
 			elseif (strpos($line, 'Description:') !== false) $line = 'Description: Your theme.';
2650 2650
 			elseif (strpos($line, 'Version:') !== false) $line = 'Version: 1';
2651 2651
 			elseif (strpos($line, 'Author:') !== false) $line = 'Author: You';
2652
-			fwrite($f, $line . "\n");
2652
+			fwrite($f, $line."\n");
2653 2653
 		}
2654 2654
 		fclose($f);
2655 2655
 	}
2656 2656
 
2657 2657
 	// Copy the images.
2658 2658
 	umask(0);
2659
-	if (! mkdir("$site_dir/images", 0777)) {
2659
+	if ( ! mkdir("$site_dir/images", 0777)) {
2660 2660
 		return false;
2661 2661
 	}
2662 2662
 
2663 2663
 	$images_dir = @ opendir("$default_dir/images");
2664 2664
 	if ($images_dir) {
2665
-		while(($image = readdir($images_dir)) !== false) {
2665
+		while (($image = readdir($images_dir)) !== false) {
2666 2666
 			if (is_dir("$default_dir/images/$image"))
2667 2667
 				continue;
2668
-			if (! @copy("$default_dir/images/$image", "$site_dir/images/$image"))
2668
+			if ( ! @copy("$default_dir/images/$image", "$site_dir/images/$image"))
2669 2669
 				return;
2670 2670
 			chmod("$site_dir/images/$image", 0777);
2671 2671
 		}
@@ -2686,30 +2686,30 @@  discard block
 block discarded – undo
2686 2686
 	// Name the theme after the blog.
2687 2687
 	$theme_name = __get_option('blogname');
2688 2688
 	$template = sanitize_title($theme_name);
2689
-	$site_dir = WP_CONTENT_DIR . "/themes/$template";
2689
+	$site_dir = WP_CONTENT_DIR."/themes/$template";
2690 2690
 
2691 2691
 	// If the theme already exists, nothing to do.
2692
-	if ( is_dir($site_dir)) {
2692
+	if (is_dir($site_dir)) {
2693 2693
 		return false;
2694 2694
 	}
2695 2695
 
2696 2696
 	// We must be able to write to the themes dir.
2697
-	if (! is_writable(WP_CONTENT_DIR . "/themes")) {
2697
+	if ( ! is_writable(WP_CONTENT_DIR."/themes")) {
2698 2698
 		return false;
2699 2699
 	}
2700 2700
 
2701 2701
 	umask(0);
2702
-	if (! mkdir($site_dir, 0777)) {
2702
+	if ( ! mkdir($site_dir, 0777)) {
2703 2703
 		return false;
2704 2704
 	}
2705 2705
 
2706
-	if (file_exists(ABSPATH . 'wp-layout.css')) {
2707
-		if (! make_site_theme_from_oldschool($theme_name, $template)) {
2706
+	if (file_exists(ABSPATH.'wp-layout.css')) {
2707
+		if ( ! make_site_theme_from_oldschool($theme_name, $template)) {
2708 2708
 			// TODO: rm -rf the site theme directory.
2709 2709
 			return false;
2710 2710
 		}
2711 2711
 	} else {
2712
-		if (! make_site_theme_from_default($theme_name, $template))
2712
+		if ( ! make_site_theme_from_default($theme_name, $template))
2713 2713
 			// TODO: rm -rf the site theme directory.
2714 2714
 			return false;
2715 2715
 	}
@@ -2762,8 +2762,8 @@  discard block
 block discarded – undo
2762 2762
 function wp_check_mysql_version() {
2763 2763
 	global $wpdb;
2764 2764
 	$result = $wpdb->check_database_version();
2765
-	if ( is_wp_error( $result ) )
2766
-		die( $result->get_error_message() );
2765
+	if (is_wp_error($result))
2766
+		die($result->get_error_message());
2767 2767
 }
2768 2768
 
2769 2769
 /**
@@ -2772,12 +2772,12 @@  discard block
 block discarded – undo
2772 2772
  * @since 2.2.0
2773 2773
  */
2774 2774
 function maybe_disable_automattic_widgets() {
2775
-	$plugins = __get_option( 'active_plugins' );
2775
+	$plugins = __get_option('active_plugins');
2776 2776
 
2777
-	foreach ( (array) $plugins as $plugin ) {
2778
-		if ( basename( $plugin ) == 'widgets.php' ) {
2779
-			array_splice( $plugins, array_search( $plugin, $plugins ), 1 );
2780
-			update_option( 'active_plugins', $plugins );
2777
+	foreach ((array) $plugins as $plugin) {
2778
+		if (basename($plugin) == 'widgets.php') {
2779
+			array_splice($plugins, array_search($plugin, $plugins), 1);
2780
+			update_option('active_plugins', $plugins);
2781 2781
 			break;
2782 2782
 		}
2783 2783
 	}
@@ -2794,8 +2794,8 @@  discard block
 block discarded – undo
2794 2794
 function maybe_disable_link_manager() {
2795 2795
 	global $wp_current_db_version, $wpdb;
2796 2796
 
2797
-	if ( $wp_current_db_version >= 22006 && get_option( 'link_manager_enabled' ) && ! $wpdb->get_var( "SELECT link_id FROM $wpdb->links LIMIT 1" ) )
2798
-		update_option( 'link_manager_enabled', 0 );
2797
+	if ($wp_current_db_version >= 22006 && get_option('link_manager_enabled') && ! $wpdb->get_var("SELECT link_id FROM $wpdb->links LIMIT 1"))
2798
+		update_option('link_manager_enabled', 0);
2799 2799
 }
2800 2800
 
2801 2801
 /**
@@ -2810,7 +2810,7 @@  discard block
 block discarded – undo
2810 2810
 	global $wp_current_db_version, $wpdb;
2811 2811
 
2812 2812
 	// Upgrade versions prior to 2.9
2813
-	if ( $wp_current_db_version < 11557 ) {
2813
+	if ($wp_current_db_version < 11557) {
2814 2814
 		// Delete duplicate options. Keep the option with the highest option_id.
2815 2815
 		$wpdb->query("DELETE o1 FROM $wpdb->options AS o1 JOIN $wpdb->options AS o2 USING (`option_name`) WHERE o2.option_id > o1.option_id");
2816 2816
 
@@ -2822,40 +2822,40 @@  discard block
 block discarded – undo
2822 2822
 	}
2823 2823
 
2824 2824
 	// Multisite schema upgrades.
2825
-	if ( $wp_current_db_version < 25448 && is_multisite() && wp_should_upgrade_global_tables() ) {
2825
+	if ($wp_current_db_version < 25448 && is_multisite() && wp_should_upgrade_global_tables()) {
2826 2826
 
2827 2827
 		// Upgrade versions prior to 3.7
2828
-		if ( $wp_current_db_version < 25179 ) {
2828
+		if ($wp_current_db_version < 25179) {
2829 2829
 			// New primary key for signups.
2830
-			$wpdb->query( "ALTER TABLE $wpdb->signups ADD signup_id BIGINT(20) NOT NULL AUTO_INCREMENT PRIMARY KEY FIRST" );
2831
-			$wpdb->query( "ALTER TABLE $wpdb->signups DROP INDEX domain" );
2830
+			$wpdb->query("ALTER TABLE $wpdb->signups ADD signup_id BIGINT(20) NOT NULL AUTO_INCREMENT PRIMARY KEY FIRST");
2831
+			$wpdb->query("ALTER TABLE $wpdb->signups DROP INDEX domain");
2832 2832
 		}
2833 2833
 
2834
-		if ( $wp_current_db_version < 25448 ) {
2834
+		if ($wp_current_db_version < 25448) {
2835 2835
 			// Convert archived from enum to tinyint.
2836
-			$wpdb->query( "ALTER TABLE $wpdb->blogs CHANGE COLUMN archived archived varchar(1) NOT NULL default '0'" );
2837
-			$wpdb->query( "ALTER TABLE $wpdb->blogs CHANGE COLUMN archived archived tinyint(2) NOT NULL default 0" );
2836
+			$wpdb->query("ALTER TABLE $wpdb->blogs CHANGE COLUMN archived archived varchar(1) NOT NULL default '0'");
2837
+			$wpdb->query("ALTER TABLE $wpdb->blogs CHANGE COLUMN archived archived tinyint(2) NOT NULL default 0");
2838 2838
 		}
2839 2839
 	}
2840 2840
 
2841 2841
 	// Upgrade versions prior to 4.2.
2842
-	if ( $wp_current_db_version < 31351 ) {
2843
-		if ( ! is_multisite() && wp_should_upgrade_global_tables() ) {
2844
-			$wpdb->query( "ALTER TABLE $wpdb->usermeta DROP INDEX meta_key, ADD INDEX meta_key(meta_key(191))" );
2842
+	if ($wp_current_db_version < 31351) {
2843
+		if ( ! is_multisite() && wp_should_upgrade_global_tables()) {
2844
+			$wpdb->query("ALTER TABLE $wpdb->usermeta DROP INDEX meta_key, ADD INDEX meta_key(meta_key(191))");
2845 2845
 		}
2846
-		$wpdb->query( "ALTER TABLE $wpdb->terms DROP INDEX slug, ADD INDEX slug(slug(191))" );
2847
-		$wpdb->query( "ALTER TABLE $wpdb->terms DROP INDEX name, ADD INDEX name(name(191))" );
2848
-		$wpdb->query( "ALTER TABLE $wpdb->commentmeta DROP INDEX meta_key, ADD INDEX meta_key(meta_key(191))" );
2849
-		$wpdb->query( "ALTER TABLE $wpdb->postmeta DROP INDEX meta_key, ADD INDEX meta_key(meta_key(191))" );
2850
-		$wpdb->query( "ALTER TABLE $wpdb->posts DROP INDEX post_name, ADD INDEX post_name(post_name(191))" );
2846
+		$wpdb->query("ALTER TABLE $wpdb->terms DROP INDEX slug, ADD INDEX slug(slug(191))");
2847
+		$wpdb->query("ALTER TABLE $wpdb->terms DROP INDEX name, ADD INDEX name(name(191))");
2848
+		$wpdb->query("ALTER TABLE $wpdb->commentmeta DROP INDEX meta_key, ADD INDEX meta_key(meta_key(191))");
2849
+		$wpdb->query("ALTER TABLE $wpdb->postmeta DROP INDEX meta_key, ADD INDEX meta_key(meta_key(191))");
2850
+		$wpdb->query("ALTER TABLE $wpdb->posts DROP INDEX post_name, ADD INDEX post_name(post_name(191))");
2851 2851
 	}
2852 2852
 
2853 2853
 	// Upgrade versions prior to 4.4.
2854
-	if ( $wp_current_db_version < 34978 ) {
2854
+	if ($wp_current_db_version < 34978) {
2855 2855
 		// If compatible termmeta table is found, use it, but enforce a proper index and update collation.
2856
-		if ( $wpdb->get_var( "SHOW TABLES LIKE '{$wpdb->termmeta}'" ) && $wpdb->get_results( "SHOW INDEX FROM {$wpdb->termmeta} WHERE Column_name = 'meta_key'" ) ) {
2857
-			$wpdb->query( "ALTER TABLE $wpdb->termmeta DROP INDEX meta_key, ADD INDEX meta_key(meta_key(191))" );
2858
-			maybe_convert_table_to_utf8mb4( $wpdb->termmeta );
2856
+		if ($wpdb->get_var("SHOW TABLES LIKE '{$wpdb->termmeta}'") && $wpdb->get_results("SHOW INDEX FROM {$wpdb->termmeta} WHERE Column_name = 'meta_key'")) {
2857
+			$wpdb->query("ALTER TABLE $wpdb->termmeta DROP INDEX meta_key, ADD INDEX meta_key(meta_key(191))");
2858
+			maybe_convert_table_to_utf8mb4($wpdb->termmeta);
2859 2859
 		}
2860 2860
 	}
2861 2861
 }
@@ -2868,7 +2868,7 @@  discard block
 block discarded – undo
2868 2868
  * @global wpdb   $wpdb
2869 2869
  * @global string $charset_collate
2870 2870
  */
2871
-if ( !function_exists( 'install_global_terms' ) ) :
2871
+if ( ! function_exists('install_global_terms')) :
2872 2872
 function install_global_terms() {
2873 2873
 	global $wpdb, $charset_collate;
2874 2874
 	$ms_queries = "
@@ -2883,7 +2883,7 @@  discard block
 block discarded – undo
2883 2883
 ) $charset_collate;
2884 2884
 ";
2885 2885
 // now create tables
2886
-	dbDelta( $ms_queries );
2886
+	dbDelta($ms_queries);
2887 2887
 }
2888 2888
 endif;
2889 2889
 
@@ -2908,7 +2908,7 @@  discard block
 block discarded – undo
2908 2908
 function wp_should_upgrade_global_tables() {
2909 2909
 
2910 2910
 	// Return false early if explicitly not upgrading
2911
-	if ( defined( 'DO_NOT_UPGRADE_GLOBAL_TABLES' ) ) {
2911
+	if (defined('DO_NOT_UPGRADE_GLOBAL_TABLES')) {
2912 2912
 		return false;
2913 2913
 	}
2914 2914
 
@@ -2916,12 +2916,12 @@  discard block
 block discarded – undo
2916 2916
 	$should_upgrade = true;
2917 2917
 
2918 2918
 	// Set to false if not on main network (does not matter if not multi-network)
2919
-	if ( ! is_main_network() ) {
2919
+	if ( ! is_main_network()) {
2920 2920
 		$should_upgrade = false;
2921 2921
 	}
2922 2922
 
2923 2923
 	// Set to false if not on main site of current network (does not matter if not multi-site)
2924
-	if ( ! is_main_site() ) {
2924
+	if ( ! is_main_site()) {
2925 2925
 		$should_upgrade = false;
2926 2926
 	}
2927 2927
 
@@ -2930,5 +2930,5 @@  discard block
 block discarded – undo
2930 2930
 	 *
2931 2931
 	 * @param bool $should_upgrade Whether to run the upgrade routines on global tables.
2932 2932
 	 */
2933
-	return apply_filters( 'wp_should_upgrade_global_tables', $should_upgrade );
2933
+	return apply_filters('wp_should_upgrade_global_tables', $should_upgrade);
2934 2934
 }
Please login to merge, or discard this patch.
src/wp-content/themes/twentyeleven/functions.php 3 patches
Doc Comments   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -387,7 +387,7 @@  discard block
 block discarded – undo
387 387
  * @since Twenty Eleven 1.0
388 388
  *
389 389
  * @param string $more The Read More text.
390
- * @return The filtered Read More text.
390
+ * @return string filtered Read More text.
391 391
  */
392 392
 function twentyeleven_auto_excerpt_more( $more ) {
393 393
 	if ( ! is_admin() ) {
@@ -540,7 +540,7 @@  discard block
 block discarded – undo
540 540
  *
541 541
  * @since Twenty Eleven 1.0
542 542
  *
543
- * @return string|bool URL or false when no link is present.
543
+ * @return false|string URL or false when no link is present.
544 544
  */
545 545
 function twentyeleven_url_grabber() {
546 546
 	if ( ! preg_match( '/<a\s[^>]*?href=[\'"](.+?)[\'"]/is', get_the_content(), $matches ) )
Please login to merge, or discard this patch.
Braces   +52 added lines, -34 removed lines patch added patch discarded remove patch
@@ -39,8 +39,9 @@  discard block
 block discarded – undo
39 39
  */
40 40
 
41 41
 // Set the content width based on the theme's design and stylesheet.
42
-if ( ! isset( $content_width ) )
42
+if ( ! isset( $content_width ) ) {
43 43
 	$content_width = 584;
44
+}
44 45
 
45 46
 /*
46 47
  * Tell WordPress to run twentyeleven_setup() when the 'after_setup_theme' hook is run.
@@ -98,10 +99,11 @@  discard block
 block discarded – undo
98 99
 	add_theme_support( 'post-formats', array( 'aside', 'link', 'gallery', 'status', 'quote', 'image' ) );
99 100
 
100 101
 	$theme_options = twentyeleven_get_theme_options();
101
-	if ( 'dark' == $theme_options['color_scheme'] )
102
-		$default_background_color = '1d1d1d';
103
-	else
104
-		$default_background_color = 'e2e2e2';
102
+	if ( 'dark' == $theme_options['color_scheme'] ) {
103
+			$default_background_color = '1d1d1d';
104
+	} else {
105
+			$default_background_color = 'e2e2e2';
106
+	}
105 107
 
106 108
 	// Add support for custom backgrounds.
107 109
 	add_theme_support( 'custom-background', array(
@@ -239,8 +241,9 @@  discard block
 block discarded – undo
239 241
 	$text_color = get_header_textcolor();
240 242
 
241 243
 	// If no custom options for text are set, let's bail.
242
-	if ( $text_color == HEADER_TEXTCOLOR )
243
-		return;
244
+	if ( $text_color == HEADER_TEXTCOLOR ) {
245
+			return;
246
+	}
244 247
 
245 248
 	// If we get this far, we have custom styles. Let's do this.
246 249
 	?>
@@ -257,11 +260,14 @@  discard block
 block discarded – undo
257 260
 		}
258 261
 	<?php
259 262
 		// If the user has set a custom color for the text use that
260
-		else :
263
+		else {
264
+			:
261 265
 	?>
262 266
 		#site-title a,
263 267
 		#site-description {
264
-			color: #<?php echo $text_color; ?>;
268
+			color: #<?php echo $text_color;
269
+		}
270
+		?>;
265 271
 		}
266 272
 	<?php endif; ?>
267 273
 	</style>
@@ -425,8 +431,9 @@  discard block
 block discarded – undo
425 431
  * @return array The filtered page menu arguments.
426 432
  */
427 433
 function twentyeleven_page_menu_args( $args ) {
428
-	if ( ! isset( $args['show_home'] ) )
429
-		$args['show_home'] = true;
434
+	if ( ! isset( $args['show_home'] ) ) {
435
+			$args['show_home'] = true;
436
+	}
430 437
 	return $args;
431 438
 }
432 439
 add_filter( 'wp_page_menu_args', 'twentyeleven_page_menu_args' );
@@ -528,8 +535,9 @@  discard block
 block discarded – undo
528 535
 	$content = get_the_content();
529 536
 	$has_url = function_exists( 'get_url_in_content' ) ? get_url_in_content( $content ) : false;
530 537
 
531
-	if ( ! $has_url )
532
-		$has_url = twentyeleven_url_grabber();
538
+	if ( ! $has_url ) {
539
+			$has_url = twentyeleven_url_grabber();
540
+	}
533 541
 
534 542
 	/** This filter is documented in wp-includes/link-template.php */
535 543
 	return ( $has_url ) ? $has_url : apply_filters( 'the_permalink', get_permalink() );
@@ -543,8 +551,9 @@  discard block
 block discarded – undo
543 551
  * @return string|bool URL or false when no link is present.
544 552
  */
545 553
 function twentyeleven_url_grabber() {
546
-	if ( ! preg_match( '/<a\s[^>]*?href=[\'"](.+?)[\'"]/is', get_the_content(), $matches ) )
547
-		return false;
554
+	if ( ! preg_match( '/<a\s[^>]*?href=[\'"](.+?)[\'"]/is', get_the_content(), $matches ) ) {
555
+			return false;
556
+	}
548 557
 
549 558
 	return esc_url_raw( $matches[1] );
550 559
 }
@@ -557,14 +566,17 @@  discard block
 block discarded – undo
557 566
 function twentyeleven_footer_sidebar_class() {
558 567
 	$count = 0;
559 568
 
560
-	if ( is_active_sidebar( 'sidebar-3' ) )
561
-		$count++;
569
+	if ( is_active_sidebar( 'sidebar-3' ) ) {
570
+			$count++;
571
+	}
562 572
 
563
-	if ( is_active_sidebar( 'sidebar-4' ) )
564
-		$count++;
573
+	if ( is_active_sidebar( 'sidebar-4' ) ) {
574
+			$count++;
575
+	}
565 576
 
566
-	if ( is_active_sidebar( 'sidebar-5' ) )
567
-		$count++;
577
+	if ( is_active_sidebar( 'sidebar-5' ) ) {
578
+			$count++;
579
+	}
568 580
 
569 581
 	$class = '';
570 582
 
@@ -580,9 +592,10 @@  discard block
 block discarded – undo
580 592
 			break;
581 593
 	}
582 594
 
583
-	if ( $class )
584
-		echo 'class="' . esc_attr( $class ) . '"';
585
-}
595
+	if ( $class ) {
596
+			echo 'class="' . esc_attr( $class ) . '"';
597
+	}
598
+	}
586 599
 
587 600
 if ( ! function_exists( 'twentyeleven_comment' ) ) :
588 601
 /**
@@ -617,8 +630,9 @@  discard block
 block discarded – undo
617 630
 				<div class="comment-author vcard">
618 631
 					<?php
619 632
 						$avatar_size = 68;
620
-						if ( '0' != $comment->comment_parent )
621
-							$avatar_size = 39;
633
+						if ( '0' != $comment->comment_parent ) {
634
+													$avatar_size = 39;
635
+						}
622 636
 
623 637
 						echo get_avatar( $comment, $avatar_size );
624 638
 
@@ -691,11 +705,13 @@  discard block
 block discarded – undo
691 705
  */
692 706
 function twentyeleven_body_classes( $classes ) {
693 707
 
694
-	if ( function_exists( 'is_multi_author' ) && ! is_multi_author() )
695
-		$classes[] = 'single-author';
708
+	if ( function_exists( 'is_multi_author' ) && ! is_multi_author() ) {
709
+			$classes[] = 'single-author';
710
+	}
696 711
 
697
-	if ( is_singular() && ! is_home() && ! is_page_template( 'showcase.php' ) && ! is_page_template( 'sidebar-page.php' ) )
698
-		$classes[] = 'singular';
712
+	if ( is_singular() && ! is_home() && ! is_page_template( 'showcase.php' ) && ! is_page_template( 'sidebar-page.php' ) ) {
713
+			$classes[] = 'singular';
714
+	}
699 715
 
700 716
 	return $classes;
701 717
 }
@@ -716,14 +732,16 @@  discard block
 block discarded – undo
716 732
 
717 733
 	if ( function_exists( 'get_post_galleries' ) ) {
718 734
 		$galleries = get_post_galleries( get_the_ID(), false );
719
-		if ( isset( $galleries[0]['ids'] ) )
720
-			$images = explode( ',', $galleries[0]['ids'] );
735
+		if ( isset( $galleries[0]['ids'] ) ) {
736
+					$images = explode( ',', $galleries[0]['ids'] );
737
+		}
721 738
 	} else {
722 739
 		$pattern = get_shortcode_regex();
723 740
 		preg_match( "/$pattern/s", get_the_content(), $match );
724 741
 		$atts = shortcode_parse_atts( $match[3] );
725
-		if ( isset( $atts['ids'] ) )
726
-			$images = explode( ',', $atts['ids'] );
742
+		if ( isset( $atts['ids'] ) ) {
743
+					$images = explode( ',', $atts['ids'] );
744
+		}
727 745
 	}
728 746
 
729 747
 	if ( ! $images ) {
Please login to merge, or discard this patch.
Spacing   +140 added lines, -140 removed lines patch added patch discarded remove patch
@@ -39,15 +39,15 @@  discard block
 block discarded – undo
39 39
  */
40 40
 
41 41
 // Set the content width based on the theme's design and stylesheet.
42
-if ( ! isset( $content_width ) )
42
+if ( ! isset($content_width))
43 43
 	$content_width = 584;
44 44
 
45 45
 /*
46 46
  * Tell WordPress to run twentyeleven_setup() when the 'after_setup_theme' hook is run.
47 47
  */
48
-add_action( 'after_setup_theme', 'twentyeleven_setup' );
48
+add_action('after_setup_theme', 'twentyeleven_setup');
49 49
 
50
-if ( ! function_exists( 'twentyeleven_setup' ) ):
50
+if ( ! function_exists('twentyeleven_setup')):
51 51
 /**
52 52
  * Set up theme defaults and registers support for various WordPress features.
53 53
  *
@@ -77,43 +77,43 @@  discard block
 block discarded – undo
77 77
 	 * a find and replace to change 'twentyeleven' to the name
78 78
 	 * of your theme in all the template files.
79 79
 	 */
80
-	load_theme_textdomain( 'twentyeleven', get_template_directory() . '/languages' );
80
+	load_theme_textdomain('twentyeleven', get_template_directory().'/languages');
81 81
 
82 82
 	// This theme styles the visual editor with editor-style.css to match the theme style.
83 83
 	add_editor_style();
84 84
 
85 85
 	// Load up our theme options page and related code.
86
-	require( get_template_directory() . '/inc/theme-options.php' );
86
+	require(get_template_directory().'/inc/theme-options.php');
87 87
 
88 88
 	// Grab Twenty Eleven's Ephemera widget.
89
-	require( get_template_directory() . '/inc/widgets.php' );
89
+	require(get_template_directory().'/inc/widgets.php');
90 90
 
91 91
 	// Add default posts and comments RSS feed links to <head>.
92
-	add_theme_support( 'automatic-feed-links' );
92
+	add_theme_support('automatic-feed-links');
93 93
 
94 94
 	// This theme uses wp_nav_menu() in one location.
95
-	register_nav_menu( 'primary', __( 'Primary Menu', 'twentyeleven' ) );
95
+	register_nav_menu('primary', __('Primary Menu', 'twentyeleven'));
96 96
 
97 97
 	// Add support for a variety of post formats
98
-	add_theme_support( 'post-formats', array( 'aside', 'link', 'gallery', 'status', 'quote', 'image' ) );
98
+	add_theme_support('post-formats', array('aside', 'link', 'gallery', 'status', 'quote', 'image'));
99 99
 
100 100
 	$theme_options = twentyeleven_get_theme_options();
101
-	if ( 'dark' == $theme_options['color_scheme'] )
101
+	if ('dark' == $theme_options['color_scheme'])
102 102
 		$default_background_color = '1d1d1d';
103 103
 	else
104 104
 		$default_background_color = 'e2e2e2';
105 105
 
106 106
 	// Add support for custom backgrounds.
107
-	add_theme_support( 'custom-background', array(
107
+	add_theme_support('custom-background', array(
108 108
 		/*
109 109
 		 * Let WordPress know what our default background color is.
110 110
 		 * This is dependent on our current color scheme.
111 111
 		 */
112 112
 		'default-color' => $default_background_color,
113
-	) );
113
+	));
114 114
 
115 115
 	// This theme uses Featured Images (also known as post thumbnails) for per-post/per-page Custom Header images
116
-	add_theme_support( 'post-thumbnails' );
116
+	add_theme_support('post-thumbnails');
117 117
 
118 118
 	// Add support for custom headers.
119 119
 	$custom_header_support = array(
@@ -127,7 +127,7 @@  discard block
 block discarded – undo
127 127
 		 *
128 128
 		 * @param int The default header image width in pixels. Default 1000.
129 129
 		 */
130
-		'width' => apply_filters( 'twentyeleven_header_image_width', 1000 ),
130
+		'width' => apply_filters('twentyeleven_header_image_width', 1000),
131 131
 		/**
132 132
 		 * Filter the Twenty Eleven default header image height.
133 133
 		 *
@@ -135,7 +135,7 @@  discard block
 block discarded – undo
135 135
 		 *
136 136
 		 * @param int The default header image height in pixels. Default 288.
137 137
 		 */
138
-		'height' => apply_filters( 'twentyeleven_header_image_height', 288 ),
138
+		'height' => apply_filters('twentyeleven_header_image_height', 288),
139 139
 		// Support flexible heights.
140 140
 		'flex-height' => true,
141 141
 		// Random image rotation by default.
@@ -148,15 +148,15 @@  discard block
 block discarded – undo
148 148
 		'admin-preview-callback' => 'twentyeleven_admin_header_image',
149 149
 	);
150 150
 
151
-	add_theme_support( 'custom-header', $custom_header_support );
151
+	add_theme_support('custom-header', $custom_header_support);
152 152
 
153
-	if ( ! function_exists( 'get_custom_header' ) ) {
153
+	if ( ! function_exists('get_custom_header')) {
154 154
 		// This is all for compatibility with versions of WordPress prior to 3.4.
155
-		define( 'HEADER_TEXTCOLOR', $custom_header_support['default-text-color'] );
156
-		define( 'HEADER_IMAGE', '' );
157
-		define( 'HEADER_IMAGE_WIDTH', $custom_header_support['width'] );
158
-		define( 'HEADER_IMAGE_HEIGHT', $custom_header_support['height'] );
159
-		add_custom_image_header( $custom_header_support['wp-head-callback'], $custom_header_support['admin-head-callback'], $custom_header_support['admin-preview-callback'] );
155
+		define('HEADER_TEXTCOLOR', $custom_header_support['default-text-color']);
156
+		define('HEADER_IMAGE', '');
157
+		define('HEADER_IMAGE_WIDTH', $custom_header_support['width']);
158
+		define('HEADER_IMAGE_HEIGHT', $custom_header_support['height']);
159
+		add_custom_image_header($custom_header_support['wp-head-callback'], $custom_header_support['admin-head-callback'], $custom_header_support['admin-preview-callback']);
160 160
 		add_custom_background();
161 161
 	}
162 162
 
@@ -165,74 +165,74 @@  discard block
 block discarded – undo
165 165
 	 * We want them to be the size of the header image that we just defined.
166 166
 	 * Larger images will be auto-cropped to fit, smaller ones will be ignored. See header.php.
167 167
 	 */
168
-	set_post_thumbnail_size( $custom_header_support['width'], $custom_header_support['height'], true );
168
+	set_post_thumbnail_size($custom_header_support['width'], $custom_header_support['height'], true);
169 169
 
170 170
 	/*
171 171
 	 * Add Twenty Eleven's custom image sizes.
172 172
 	 * Used for large feature (header) images.
173 173
 	 */
174
-	add_image_size( 'large-feature', $custom_header_support['width'], $custom_header_support['height'], true );
174
+	add_image_size('large-feature', $custom_header_support['width'], $custom_header_support['height'], true);
175 175
 	// Used for featured posts if a large-feature doesn't exist.
176
-	add_image_size( 'small-feature', 500, 300 );
176
+	add_image_size('small-feature', 500, 300);
177 177
 
178 178
 	// Default custom headers packaged with the theme. %s is a placeholder for the theme template directory URI.
179
-	register_default_headers( array(
179
+	register_default_headers(array(
180 180
 		'wheel' => array(
181 181
 			'url' => '%s/images/headers/wheel.jpg',
182 182
 			'thumbnail_url' => '%s/images/headers/wheel-thumbnail.jpg',
183 183
 			/* translators: header image description */
184
-			'description' => __( 'Wheel', 'twentyeleven' )
184
+			'description' => __('Wheel', 'twentyeleven')
185 185
 		),
186 186
 		'shore' => array(
187 187
 			'url' => '%s/images/headers/shore.jpg',
188 188
 			'thumbnail_url' => '%s/images/headers/shore-thumbnail.jpg',
189 189
 			/* translators: header image description */
190
-			'description' => __( 'Shore', 'twentyeleven' )
190
+			'description' => __('Shore', 'twentyeleven')
191 191
 		),
192 192
 		'trolley' => array(
193 193
 			'url' => '%s/images/headers/trolley.jpg',
194 194
 			'thumbnail_url' => '%s/images/headers/trolley-thumbnail.jpg',
195 195
 			/* translators: header image description */
196
-			'description' => __( 'Trolley', 'twentyeleven' )
196
+			'description' => __('Trolley', 'twentyeleven')
197 197
 		),
198 198
 		'pine-cone' => array(
199 199
 			'url' => '%s/images/headers/pine-cone.jpg',
200 200
 			'thumbnail_url' => '%s/images/headers/pine-cone-thumbnail.jpg',
201 201
 			/* translators: header image description */
202
-			'description' => __( 'Pine Cone', 'twentyeleven' )
202
+			'description' => __('Pine Cone', 'twentyeleven')
203 203
 		),
204 204
 		'chessboard' => array(
205 205
 			'url' => '%s/images/headers/chessboard.jpg',
206 206
 			'thumbnail_url' => '%s/images/headers/chessboard-thumbnail.jpg',
207 207
 			/* translators: header image description */
208
-			'description' => __( 'Chessboard', 'twentyeleven' )
208
+			'description' => __('Chessboard', 'twentyeleven')
209 209
 		),
210 210
 		'lanterns' => array(
211 211
 			'url' => '%s/images/headers/lanterns.jpg',
212 212
 			'thumbnail_url' => '%s/images/headers/lanterns-thumbnail.jpg',
213 213
 			/* translators: header image description */
214
-			'description' => __( 'Lanterns', 'twentyeleven' )
214
+			'description' => __('Lanterns', 'twentyeleven')
215 215
 		),
216 216
 		'willow' => array(
217 217
 			'url' => '%s/images/headers/willow.jpg',
218 218
 			'thumbnail_url' => '%s/images/headers/willow-thumbnail.jpg',
219 219
 			/* translators: header image description */
220
-			'description' => __( 'Willow', 'twentyeleven' )
220
+			'description' => __('Willow', 'twentyeleven')
221 221
 		),
222 222
 		'hanoi' => array(
223 223
 			'url' => '%s/images/headers/hanoi.jpg',
224 224
 			'thumbnail_url' => '%s/images/headers/hanoi-thumbnail.jpg',
225 225
 			/* translators: header image description */
226
-			'description' => __( 'Hanoi Plant', 'twentyeleven' )
226
+			'description' => __('Hanoi Plant', 'twentyeleven')
227 227
 		)
228
-	) );
228
+	));
229 229
 
230 230
 	// Indicate widget sidebars can use selective refresh in the Customizer.
231
-	add_theme_support( 'customize-selective-refresh-widgets' );
231
+	add_theme_support('customize-selective-refresh-widgets');
232 232
 }
233 233
 endif; // twentyeleven_setup
234 234
 
235
-if ( ! function_exists( 'twentyeleven_header_style' ) ) :
235
+if ( ! function_exists('twentyeleven_header_style')) :
236 236
 /**
237 237
  * Styles the header image and text displayed on the blog.
238 238
  *
@@ -242,7 +242,7 @@  discard block
 block discarded – undo
242 242
 	$text_color = get_header_textcolor();
243 243
 
244 244
 	// If no custom options for text are set, let's bail.
245
-	if ( $text_color == HEADER_TEXTCOLOR )
245
+	if ($text_color == HEADER_TEXTCOLOR)
246 246
 		return;
247 247
 
248 248
 	// If we get this far, we have custom styles. Let's do this.
@@ -250,7 +250,7 @@  discard block
 block discarded – undo
250 250
 	<style type="text/css" id="twentyeleven-header-css">
251 251
 	<?php
252 252
 		// Has the text been hidden?
253
-		if ( 'blank' == $text_color ) :
253
+		if ('blank' == $text_color) :
254 254
 	?>
255 255
 		#site-title,
256 256
 		#site-description {
@@ -272,7 +272,7 @@  discard block
 block discarded – undo
272 272
 }
273 273
 endif; // twentyeleven_header_style
274 274
 
275
-if ( ! function_exists( 'twentyeleven_admin_header_style' ) ) :
275
+if ( ! function_exists('twentyeleven_admin_header_style')) :
276 276
 /**
277 277
  * Styles the header image displayed on the Appearance > Header admin panel.
278 278
  *
@@ -305,7 +305,7 @@  discard block
 block discarded – undo
305 305
 	}
306 306
 	<?php
307 307
 		// If the user has set a custom color for the text use that
308
-		if ( get_header_textcolor() != HEADER_TEXTCOLOR ) :
308
+		if (get_header_textcolor() != HEADER_TEXTCOLOR) :
309 309
 	?>
310 310
 		#site-title a,
311 311
 		#site-description {
@@ -322,7 +322,7 @@  discard block
 block discarded – undo
322 322
 }
323 323
 endif; // twentyeleven_admin_header_style
324 324
 
325
-if ( ! function_exists( 'twentyeleven_admin_header_image' ) ) :
325
+if ( ! function_exists('twentyeleven_admin_header_image')) :
326 326
 /**
327 327
  * Custom header image markup displayed on the Appearance > Header admin panel.
328 328
  *
@@ -336,14 +336,14 @@  discard block
 block discarded – undo
336 336
 		$color = get_header_textcolor();
337 337
 		$image = get_header_image();
338 338
 		$style = 'display: none;';
339
-		if ( $color && $color != 'blank' ) {
340
-			$style = 'color: #' . $color . ';';
339
+		if ($color && $color != 'blank') {
340
+			$style = 'color: #'.$color.';';
341 341
 		}
342 342
 		?>
343
-		<h1 class="displaying-header-text"><a id="name" style="<?php echo esc_attr( $style ); ?>" onclick="return false;" href="<?php echo esc_url( home_url( '/' ) ); ?>" tabindex="-1"><?php bloginfo( 'name' ); ?></a></h1>
344
-		<div id="desc" class="displaying-header-text" style="<?php echo esc_attr( $style ); ?>"><?php bloginfo( 'description' ); ?></div>
345
-  		<?php if ( $image ) : ?>
346
-			<img src="<?php echo esc_url( $image ); ?>" alt="" />
343
+		<h1 class="displaying-header-text"><a id="name" style="<?php echo esc_attr($style); ?>" onclick="return false;" href="<?php echo esc_url(home_url('/')); ?>" tabindex="-1"><?php bloginfo('name'); ?></a></h1>
344
+		<div id="desc" class="displaying-header-text" style="<?php echo esc_attr($style); ?>"><?php bloginfo('description'); ?></div>
345
+  		<?php if ($image) : ?>
346
+			<img src="<?php echo esc_url($image); ?>" alt="" />
347 347
 		<?php endif; ?>
348 348
 	</div>
349 349
 <?php }
@@ -361,12 +361,12 @@  discard block
 block discarded – undo
361 361
  * @param int $length The number of excerpt characters.
362 362
  * @return int The filtered number of characters.
363 363
  */
364
-function twentyeleven_excerpt_length( $length ) {
364
+function twentyeleven_excerpt_length($length) {
365 365
 	return 40;
366 366
 }
367
-add_filter( 'excerpt_length', 'twentyeleven_excerpt_length' );
367
+add_filter('excerpt_length', 'twentyeleven_excerpt_length');
368 368
 
369
-if ( ! function_exists( 'twentyeleven_continue_reading_link' ) ) :
369
+if ( ! function_exists('twentyeleven_continue_reading_link')) :
370 370
 /**
371 371
  * Return a "Continue Reading" link for excerpts
372 372
  *
@@ -375,7 +375,7 @@  discard block
 block discarded – undo
375 375
  * @return string The "Continue Reading" HTML link.
376 376
  */
377 377
 function twentyeleven_continue_reading_link() {
378
-	return ' <a href="'. esc_url( get_permalink() ) . '">' . __( 'Continue reading <span class="meta-nav">&rarr;</span>', 'twentyeleven' ) . '</a>';
378
+	return ' <a href="'.esc_url(get_permalink()).'">'.__('Continue reading <span class="meta-nav">&rarr;</span>', 'twentyeleven').'</a>';
379 379
 }
380 380
 endif; // twentyeleven_continue_reading_link
381 381
 
@@ -392,13 +392,13 @@  discard block
 block discarded – undo
392 392
  * @param string $more The Read More text.
393 393
  * @return The filtered Read More text.
394 394
  */
395
-function twentyeleven_auto_excerpt_more( $more ) {
396
-	if ( ! is_admin() ) {
397
-		return ' &hellip;' . twentyeleven_continue_reading_link();
395
+function twentyeleven_auto_excerpt_more($more) {
396
+	if ( ! is_admin()) {
397
+		return ' &hellip;'.twentyeleven_continue_reading_link();
398 398
 	}
399 399
 	return $more;
400 400
 }
401
-add_filter( 'excerpt_more', 'twentyeleven_auto_excerpt_more' );
401
+add_filter('excerpt_more', 'twentyeleven_auto_excerpt_more');
402 402
 
403 403
 /**
404 404
  * Add a pretty "Continue Reading" link to custom post excerpts.
@@ -411,13 +411,13 @@  discard block
 block discarded – undo
411 411
  * @param string $output The "Continue Reading" link.
412 412
  * @return string The filtered "Continue Reading" link.
413 413
  */
414
-function twentyeleven_custom_excerpt_more( $output ) {
415
-	if ( has_excerpt() && ! is_attachment() && ! is_admin() ) {
414
+function twentyeleven_custom_excerpt_more($output) {
415
+	if (has_excerpt() && ! is_attachment() && ! is_admin()) {
416 416
 		$output .= twentyeleven_continue_reading_link();
417 417
 	}
418 418
 	return $output;
419 419
 }
420
-add_filter( 'get_the_excerpt', 'twentyeleven_custom_excerpt_more' );
420
+add_filter('get_the_excerpt', 'twentyeleven_custom_excerpt_more');
421 421
 
422 422
 /**
423 423
  * Show a home link for the wp_nav_menu() fallback, wp_page_menu().
@@ -427,12 +427,12 @@  discard block
 block discarded – undo
427 427
  * @param array $args The page menu arguments. @see wp_page_menu()
428 428
  * @return array The filtered page menu arguments.
429 429
  */
430
-function twentyeleven_page_menu_args( $args ) {
431
-	if ( ! isset( $args['show_home'] ) )
430
+function twentyeleven_page_menu_args($args) {
431
+	if ( ! isset($args['show_home']))
432 432
 		$args['show_home'] = true;
433 433
 	return $args;
434 434
 }
435
-add_filter( 'wp_page_menu_args', 'twentyeleven_page_menu_args' );
435
+add_filter('wp_page_menu_args', 'twentyeleven_page_menu_args');
436 436
 
437 437
 /**
438 438
  * Register sidebars and widgetized areas.
@@ -443,60 +443,60 @@  discard block
 block discarded – undo
443 443
  */
444 444
 function twentyeleven_widgets_init() {
445 445
 
446
-	register_widget( 'Twenty_Eleven_Ephemera_Widget' );
446
+	register_widget('Twenty_Eleven_Ephemera_Widget');
447 447
 
448
-	register_sidebar( array(
449
-		'name' => __( 'Main Sidebar', 'twentyeleven' ),
448
+	register_sidebar(array(
449
+		'name' => __('Main Sidebar', 'twentyeleven'),
450 450
 		'id' => 'sidebar-1',
451 451
 		'before_widget' => '<aside id="%1$s" class="widget %2$s">',
452 452
 		'after_widget' => '</aside>',
453 453
 		'before_title' => '<h3 class="widget-title">',
454 454
 		'after_title' => '</h3>',
455
-	) );
455
+	));
456 456
 
457
-	register_sidebar( array(
458
-		'name' => __( 'Showcase Sidebar', 'twentyeleven' ),
457
+	register_sidebar(array(
458
+		'name' => __('Showcase Sidebar', 'twentyeleven'),
459 459
 		'id' => 'sidebar-2',
460
-		'description' => __( 'The sidebar for the optional Showcase Template', 'twentyeleven' ),
460
+		'description' => __('The sidebar for the optional Showcase Template', 'twentyeleven'),
461 461
 		'before_widget' => '<aside id="%1$s" class="widget %2$s">',
462 462
 		'after_widget' => '</aside>',
463 463
 		'before_title' => '<h3 class="widget-title">',
464 464
 		'after_title' => '</h3>',
465
-	) );
465
+	));
466 466
 
467
-	register_sidebar( array(
468
-		'name' => __( 'Footer Area One', 'twentyeleven' ),
467
+	register_sidebar(array(
468
+		'name' => __('Footer Area One', 'twentyeleven'),
469 469
 		'id' => 'sidebar-3',
470
-		'description' => __( 'An optional widget area for your site footer', 'twentyeleven' ),
470
+		'description' => __('An optional widget area for your site footer', 'twentyeleven'),
471 471
 		'before_widget' => '<aside id="%1$s" class="widget %2$s">',
472 472
 		'after_widget' => '</aside>',
473 473
 		'before_title' => '<h3 class="widget-title">',
474 474
 		'after_title' => '</h3>',
475
-	) );
475
+	));
476 476
 
477
-	register_sidebar( array(
478
-		'name' => __( 'Footer Area Two', 'twentyeleven' ),
477
+	register_sidebar(array(
478
+		'name' => __('Footer Area Two', 'twentyeleven'),
479 479
 		'id' => 'sidebar-4',
480
-		'description' => __( 'An optional widget area for your site footer', 'twentyeleven' ),
480
+		'description' => __('An optional widget area for your site footer', 'twentyeleven'),
481 481
 		'before_widget' => '<aside id="%1$s" class="widget %2$s">',
482 482
 		'after_widget' => '</aside>',
483 483
 		'before_title' => '<h3 class="widget-title">',
484 484
 		'after_title' => '</h3>',
485
-	) );
485
+	));
486 486
 
487
-	register_sidebar( array(
488
-		'name' => __( 'Footer Area Three', 'twentyeleven' ),
487
+	register_sidebar(array(
488
+		'name' => __('Footer Area Three', 'twentyeleven'),
489 489
 		'id' => 'sidebar-5',
490
-		'description' => __( 'An optional widget area for your site footer', 'twentyeleven' ),
490
+		'description' => __('An optional widget area for your site footer', 'twentyeleven'),
491 491
 		'before_widget' => '<aside id="%1$s" class="widget %2$s">',
492 492
 		'after_widget' => '</aside>',
493 493
 		'before_title' => '<h3 class="widget-title">',
494 494
 		'after_title' => '</h3>',
495
-	) );
495
+	));
496 496
 }
497
-add_action( 'widgets_init', 'twentyeleven_widgets_init' );
497
+add_action('widgets_init', 'twentyeleven_widgets_init');
498 498
 
499
-if ( ! function_exists( 'twentyeleven_content_nav' ) ) :
499
+if ( ! function_exists('twentyeleven_content_nav')) :
500 500
 /**
501 501
  * Display navigation to next/previous pages when applicable.
502 502
  *
@@ -504,14 +504,14 @@  discard block
 block discarded – undo
504 504
  *
505 505
  * @param string $html_id The HTML id attribute.
506 506
  */
507
-function twentyeleven_content_nav( $html_id ) {
507
+function twentyeleven_content_nav($html_id) {
508 508
 	global $wp_query;
509 509
 
510
-	if ( $wp_query->max_num_pages > 1 ) : ?>
511
-		<nav id="<?php echo esc_attr( $html_id ); ?>">
512
-			<h3 class="assistive-text"><?php _e( 'Post navigation', 'twentyeleven' ); ?></h3>
513
-			<div class="nav-previous"><?php next_posts_link( __( '<span class="meta-nav">&larr;</span> Older posts', 'twentyeleven' ) ); ?></div>
514
-			<div class="nav-next"><?php previous_posts_link( __( 'Newer posts <span class="meta-nav">&rarr;</span>', 'twentyeleven' ) ); ?></div>
510
+	if ($wp_query->max_num_pages > 1) : ?>
511
+		<nav id="<?php echo esc_attr($html_id); ?>">
512
+			<h3 class="assistive-text"><?php _e('Post navigation', 'twentyeleven'); ?></h3>
513
+			<div class="nav-previous"><?php next_posts_link(__('<span class="meta-nav">&larr;</span> Older posts', 'twentyeleven')); ?></div>
514
+			<div class="nav-next"><?php previous_posts_link(__('Newer posts <span class="meta-nav">&rarr;</span>', 'twentyeleven')); ?></div>
515 515
 		</nav><!-- #nav-above -->
516 516
 	<?php endif;
517 517
 }
@@ -529,13 +529,13 @@  discard block
 block discarded – undo
529 529
  */
530 530
 function twentyeleven_get_first_url() {
531 531
 	$content = get_the_content();
532
-	$has_url = function_exists( 'get_url_in_content' ) ? get_url_in_content( $content ) : false;
532
+	$has_url = function_exists('get_url_in_content') ? get_url_in_content($content) : false;
533 533
 
534
-	if ( ! $has_url )
534
+	if ( ! $has_url)
535 535
 		$has_url = twentyeleven_url_grabber();
536 536
 
537 537
 	/** This filter is documented in wp-includes/link-template.php */
538
-	return ( $has_url ) ? $has_url : apply_filters( 'the_permalink', get_permalink() );
538
+	return ($has_url) ? $has_url : apply_filters('the_permalink', get_permalink());
539 539
 }
540 540
 
541 541
 /**
@@ -546,10 +546,10 @@  discard block
 block discarded – undo
546 546
  * @return string|bool URL or false when no link is present.
547 547
  */
548 548
 function twentyeleven_url_grabber() {
549
-	if ( ! preg_match( '/<a\s[^>]*?href=[\'"](.+?)[\'"]/is', get_the_content(), $matches ) )
549
+	if ( ! preg_match('/<a\s[^>]*?href=[\'"](.+?)[\'"]/is', get_the_content(), $matches))
550 550
 		return false;
551 551
 
552
-	return esc_url_raw( $matches[1] );
552
+	return esc_url_raw($matches[1]);
553 553
 }
554 554
 
555 555
 /**
@@ -560,18 +560,18 @@  discard block
 block discarded – undo
560 560
 function twentyeleven_footer_sidebar_class() {
561 561
 	$count = 0;
562 562
 
563
-	if ( is_active_sidebar( 'sidebar-3' ) )
563
+	if (is_active_sidebar('sidebar-3'))
564 564
 		$count++;
565 565
 
566
-	if ( is_active_sidebar( 'sidebar-4' ) )
566
+	if (is_active_sidebar('sidebar-4'))
567 567
 		$count++;
568 568
 
569
-	if ( is_active_sidebar( 'sidebar-5' ) )
569
+	if (is_active_sidebar('sidebar-5'))
570 570
 		$count++;
571 571
 
572 572
 	$class = '';
573 573
 
574
-	switch ( $count ) {
574
+	switch ($count) {
575 575
 		case '1':
576 576
 			$class = 'one';
577 577
 			break;
@@ -583,11 +583,11 @@  discard block
 block discarded – undo
583 583
 			break;
584 584
 	}
585 585
 
586
-	if ( $class )
587
-		echo 'class="' . esc_attr( $class ) . '"';
586
+	if ($class)
587
+		echo 'class="'.esc_attr($class).'"';
588 588
 }
589 589
 
590
-if ( ! function_exists( 'twentyeleven_comment' ) ) :
590
+if ( ! function_exists('twentyeleven_comment')) :
591 591
 /**
592 592
  * Template for comments and pingbacks.
593 593
  *
@@ -602,14 +602,14 @@  discard block
 block discarded – undo
602 602
  * @param array  $args    An array of comment arguments. @see get_comment_reply_link()
603 603
  * @param int    $depth   The depth of the comment.
604 604
  */
605
-function twentyeleven_comment( $comment, $args, $depth ) {
605
+function twentyeleven_comment($comment, $args, $depth) {
606 606
 	$GLOBALS['comment'] = $comment;
607
-	switch ( $comment->comment_type ) :
607
+	switch ($comment->comment_type) :
608 608
 		case 'pingback' :
609 609
 		case 'trackback' :
610 610
 	?>
611 611
 	<li class="post pingback">
612
-		<p><?php _e( 'Pingback:', 'twentyeleven' ); ?> <?php comment_author_link(); ?><?php edit_comment_link( __( 'Edit', 'twentyeleven' ), '<span class="edit-link">', '</span>' ); ?></p>
612
+		<p><?php _e('Pingback:', 'twentyeleven'); ?> <?php comment_author_link(); ?><?php edit_comment_link(__('Edit', 'twentyeleven'), '<span class="edit-link">', '</span>'); ?></p>
613 613
 	<?php
614 614
 			break;
615 615
 		default :
@@ -620,28 +620,28 @@  discard block
 block discarded – undo
620 620
 				<div class="comment-author vcard">
621 621
 					<?php
622 622
 						$avatar_size = 68;
623
-						if ( '0' != $comment->comment_parent )
623
+						if ('0' != $comment->comment_parent)
624 624
 							$avatar_size = 39;
625 625
 
626
-						echo get_avatar( $comment, $avatar_size );
626
+						echo get_avatar($comment, $avatar_size);
627 627
 
628 628
 						/* translators: 1: comment author, 2: date and time */
629
-						printf( __( '%1$s on %2$s <span class="says">said:</span>', 'twentyeleven' ),
630
-							sprintf( '<span class="fn">%s</span>', get_comment_author_link() ),
631
-							sprintf( '<a href="%1$s"><time datetime="%2$s">%3$s</time></a>',
632
-								esc_url( get_comment_link( $comment->comment_ID ) ),
633
-								get_comment_time( 'c' ),
629
+						printf(__('%1$s on %2$s <span class="says">said:</span>', 'twentyeleven'),
630
+							sprintf('<span class="fn">%s</span>', get_comment_author_link()),
631
+							sprintf('<a href="%1$s"><time datetime="%2$s">%3$s</time></a>',
632
+								esc_url(get_comment_link($comment->comment_ID)),
633
+								get_comment_time('c'),
634 634
 								/* translators: 1: date, 2: time */
635
-								sprintf( __( '%1$s at %2$s', 'twentyeleven' ), get_comment_date(), get_comment_time() )
635
+								sprintf(__('%1$s at %2$s', 'twentyeleven'), get_comment_date(), get_comment_time())
636 636
 							)
637 637
 						);
638 638
 					?>
639 639
 
640
-					<?php edit_comment_link( __( 'Edit', 'twentyeleven' ), '<span class="edit-link">', '</span>' ); ?>
640
+					<?php edit_comment_link(__('Edit', 'twentyeleven'), '<span class="edit-link">', '</span>'); ?>
641 641
 				</div><!-- .comment-author .vcard -->
642 642
 
643
-				<?php if ( $comment->comment_approved == '0' ) : ?>
644
-					<em class="comment-awaiting-moderation"><?php _e( 'Your comment is awaiting moderation.', 'twentyeleven' ); ?></em>
643
+				<?php if ($comment->comment_approved == '0') : ?>
644
+					<em class="comment-awaiting-moderation"><?php _e('Your comment is awaiting moderation.', 'twentyeleven'); ?></em>
645 645
 					<br />
646 646
 				<?php endif; ?>
647 647
 
@@ -650,7 +650,7 @@  discard block
 block discarded – undo
650 650
 			<div class="comment-content"><?php comment_text(); ?></div>
651 651
 
652 652
 			<div class="reply">
653
-				<?php comment_reply_link( array_merge( $args, array( 'reply_text' => __( 'Reply <span>&darr;</span>', 'twentyeleven' ), 'depth' => $depth, 'max_depth' => $args['max_depth'] ) ) ); ?>
653
+				<?php comment_reply_link(array_merge($args, array('reply_text' => __('Reply <span>&darr;</span>', 'twentyeleven'), 'depth' => $depth, 'max_depth' => $args['max_depth']))); ?>
654 654
 			</div><!-- .reply -->
655 655
 		</article><!-- #comment-## -->
656 656
 
@@ -660,7 +660,7 @@  discard block
 block discarded – undo
660 660
 }
661 661
 endif; // ends check for twentyeleven_comment()
662 662
 
663
-if ( ! function_exists( 'twentyeleven_posted_on' ) ) :
663
+if ( ! function_exists('twentyeleven_posted_on')) :
664 664
 /**
665 665
  * Print HTML with meta information for the current post-date/time and author.
666 666
  *
@@ -669,13 +669,13 @@  discard block
 block discarded – undo
669 669
  * @since Twenty Eleven 1.0
670 670
  */
671 671
 function twentyeleven_posted_on() {
672
-	printf( __( '<span class="sep">Posted on </span><a href="%1$s" title="%2$s" rel="bookmark"><time class="entry-date" datetime="%3$s">%4$s</time></a><span class="by-author"> <span class="sep"> by </span> <span class="author vcard"><a class="url fn n" href="%5$s" title="%6$s" rel="author">%7$s</a></span></span>', 'twentyeleven' ),
673
-		esc_url( get_permalink() ),
674
-		esc_attr( get_the_time() ),
675
-		esc_attr( get_the_date( 'c' ) ),
676
-		esc_html( get_the_date() ),
677
-		esc_url( get_author_posts_url( get_the_author_meta( 'ID' ) ) ),
678
-		esc_attr( sprintf( __( 'View all posts by %s', 'twentyeleven' ), get_the_author() ) ),
672
+	printf(__('<span class="sep">Posted on </span><a href="%1$s" title="%2$s" rel="bookmark"><time class="entry-date" datetime="%3$s">%4$s</time></a><span class="by-author"> <span class="sep"> by </span> <span class="author vcard"><a class="url fn n" href="%5$s" title="%6$s" rel="author">%7$s</a></span></span>', 'twentyeleven'),
673
+		esc_url(get_permalink()),
674
+		esc_attr(get_the_time()),
675
+		esc_attr(get_the_date('c')),
676
+		esc_html(get_the_date()),
677
+		esc_url(get_author_posts_url(get_the_author_meta('ID'))),
678
+		esc_attr(sprintf(__('View all posts by %s', 'twentyeleven'), get_the_author())),
679 679
 		get_the_author()
680 680
 	);
681 681
 }
@@ -692,17 +692,17 @@  discard block
 block discarded – undo
692 692
  * @param array $classes Existing body classes.
693 693
  * @return array The filtered array of body classes.
694 694
  */
695
-function twentyeleven_body_classes( $classes ) {
695
+function twentyeleven_body_classes($classes) {
696 696
 
697
-	if ( function_exists( 'is_multi_author' ) && ! is_multi_author() )
697
+	if (function_exists('is_multi_author') && ! is_multi_author())
698 698
 		$classes[] = 'single-author';
699 699
 
700
-	if ( is_singular() && ! is_home() && ! is_page_template( 'showcase.php' ) && ! is_page_template( 'sidebar-page.php' ) )
700
+	if (is_singular() && ! is_home() && ! is_page_template('showcase.php') && ! is_page_template('sidebar-page.php'))
701 701
 		$classes[] = 'singular';
702 702
 
703 703
 	return $classes;
704 704
 }
705
-add_filter( 'body_class', 'twentyeleven_body_classes' );
705
+add_filter('body_class', 'twentyeleven_body_classes');
706 706
 
707 707
 /**
708 708
  * Retrieve the IDs for images in a gallery.
@@ -717,20 +717,20 @@  discard block
 block discarded – undo
717 717
 function twentyeleven_get_gallery_images() {
718 718
 	$images = array();
719 719
 
720
-	if ( function_exists( 'get_post_galleries' ) ) {
721
-		$galleries = get_post_galleries( get_the_ID(), false );
722
-		if ( isset( $galleries[0]['ids'] ) )
723
-			$images = explode( ',', $galleries[0]['ids'] );
720
+	if (function_exists('get_post_galleries')) {
721
+		$galleries = get_post_galleries(get_the_ID(), false);
722
+		if (isset($galleries[0]['ids']))
723
+			$images = explode(',', $galleries[0]['ids']);
724 724
 	} else {
725 725
 		$pattern = get_shortcode_regex();
726
-		preg_match( "/$pattern/s", get_the_content(), $match );
727
-		$atts = shortcode_parse_atts( $match[3] );
728
-		if ( isset( $atts['ids'] ) )
729
-			$images = explode( ',', $atts['ids'] );
726
+		preg_match("/$pattern/s", get_the_content(), $match);
727
+		$atts = shortcode_parse_atts($match[3]);
728
+		if (isset($atts['ids']))
729
+			$images = explode(',', $atts['ids']);
730 730
 	}
731 731
 
732
-	if ( ! $images ) {
733
-		$images = get_posts( array(
732
+	if ( ! $images) {
733
+		$images = get_posts(array(
734 734
 			'fields'         => 'ids',
735 735
 			'numberposts'    => 999,
736 736
 			'order'          => 'ASC',
@@ -738,7 +738,7 @@  discard block
 block discarded – undo
738 738
 			'post_mime_type' => 'image',
739 739
 			'post_parent'    => get_the_ID(),
740 740
 			'post_type'      => 'attachment',
741
-		) );
741
+		));
742 742
 	}
743 743
 
744 744
 	return $images;
Please login to merge, or discard this patch.
src/wp-includes/canonical.php 3 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -503,7 +503,7 @@
 block discarded – undo
503 503
  * @access private
504 504
  *
505 505
  * @param string $query_string
506
- * @param array $args_to_check
506
+ * @param string[] $args_to_check
507 507
  * @param string $url
508 508
  * @return string The altered query string
509 509
  */
Please login to merge, or discard this patch.
Braces   +143 added lines, -99 removed lines patch added patch discarded remove patch
@@ -75,10 +75,12 @@  discard block
 block discarded – undo
75 75
 	$redirect_url = false;
76 76
 
77 77
 	// Notice fixing
78
-	if ( !isset($redirect['path']) )
79
-		$redirect['path'] = '';
80
-	if ( !isset($redirect['query']) )
81
-		$redirect['query'] = '';
78
+	if ( !isset($redirect['path']) ) {
79
+			$redirect['path'] = '';
80
+	}
81
+	if ( !isset($redirect['query']) ) {
82
+			$redirect['query'] = '';
83
+	}
82 84
 
83 85
 	// If the original URL ended with non-breaking spaces, they were almost
84 86
 	// certainly inserted by accident. Let's remove them, so the reader doesn't
@@ -102,11 +104,13 @@  discard block
 block discarded – undo
102 104
 		$vars = $wpdb->get_results( $wpdb->prepare("SELECT post_type, post_parent FROM $wpdb->posts WHERE ID = %d", $id) );
103 105
 
104 106
 		if ( isset($vars[0]) && $vars = $vars[0] ) {
105
-			if ( 'revision' == $vars->post_type && $vars->post_parent > 0 )
106
-				$id = $vars->post_parent;
107
+			if ( 'revision' == $vars->post_type && $vars->post_parent > 0 ) {
108
+							$id = $vars->post_parent;
109
+			}
107 110
 
108
-			if ( $redirect_url = get_permalink($id) )
109
-				$redirect['query'] = _remove_qs_args_if_not_in_url( $redirect['query'], array( 'p', 'page_id', 'attachment_id', 'pagename', 'name', 'post_type' ), $redirect_url );
111
+			if ( $redirect_url = get_permalink($id) ) {
112
+							$redirect['query'] = _remove_qs_args_if_not_in_url( $redirect['query'], array( 'p', 'page_id', 'attachment_id', 'pagename', 'name', 'post_type' ), $redirect_url );
113
+			}
110 114
 		}
111 115
 	}
112 116
 
@@ -164,19 +168,23 @@  discard block
 block discarded – undo
164 168
 				$redirect_url = get_attachment_link();
165 169
 			}
166 170
 		} elseif ( is_single() && !empty($_GET['p']) && ! $redirect_url ) {
167
-			if ( $redirect_url = get_permalink(get_query_var('p')) )
168
-				$redirect['query'] = remove_query_arg(array('p', 'post_type'), $redirect['query']);
171
+			if ( $redirect_url = get_permalink(get_query_var('p')) ) {
172
+							$redirect['query'] = remove_query_arg(array('p', 'post_type'), $redirect['query']);
173
+			}
169 174
 		} elseif ( is_single() && !empty($_GET['name'])  && ! $redirect_url ) {
170
-			if ( $redirect_url = get_permalink( $wp_query->get_queried_object_id() ) )
171
-				$redirect['query'] = remove_query_arg('name', $redirect['query']);
175
+			if ( $redirect_url = get_permalink( $wp_query->get_queried_object_id() ) ) {
176
+							$redirect['query'] = remove_query_arg('name', $redirect['query']);
177
+			}
172 178
 		} elseif ( is_page() && !empty($_GET['page_id']) && ! $redirect_url ) {
173
-			if ( $redirect_url = get_permalink(get_query_var('page_id')) )
174
-				$redirect['query'] = remove_query_arg('page_id', $redirect['query']);
179
+			if ( $redirect_url = get_permalink(get_query_var('page_id')) ) {
180
+							$redirect['query'] = remove_query_arg('page_id', $redirect['query']);
181
+			}
175 182
 		} elseif ( is_page() && !is_feed() && 'page' == get_option('show_on_front') && get_queried_object_id() == get_option('page_on_front')  && ! $redirect_url ) {
176 183
 			$redirect_url = home_url('/');
177 184
 		} elseif ( is_home() && !empty($_GET['page_id']) && 'page' == get_option('show_on_front') && get_query_var('page_id') == get_option('page_for_posts')  && ! $redirect_url ) {
178
-			if ( $redirect_url = get_permalink(get_option('page_for_posts')) )
179
-				$redirect['query'] = remove_query_arg('page_id', $redirect['query']);
185
+			if ( $redirect_url = get_permalink(get_option('page_for_posts')) ) {
186
+							$redirect['query'] = remove_query_arg('page_id', $redirect['query']);
187
+			}
180 188
 		} elseif ( !empty($_GET['m']) && ( is_year() || is_month() || is_day() ) ) {
181 189
 			$m = get_query_var('m');
182 190
 			switch ( strlen($m) ) {
@@ -190,29 +198,35 @@  discard block
 block discarded – undo
190 198
 					$redirect_url = get_day_link(substr($m, 0, 4), substr($m, 4, 2), substr($m, 6, 2));
191 199
 					break;
192 200
 			}
193
-			if ( $redirect_url )
194
-				$redirect['query'] = remove_query_arg('m', $redirect['query']);
201
+			if ( $redirect_url ) {
202
+							$redirect['query'] = remove_query_arg('m', $redirect['query']);
203
+			}
195 204
 		// now moving on to non ?m=X year/month/day links
196 205
 		} elseif ( is_day() && get_query_var('year') && get_query_var('monthnum') && !empty($_GET['day']) ) {
197
-			if ( $redirect_url = get_day_link(get_query_var('year'), get_query_var('monthnum'), get_query_var('day')) )
198
-				$redirect['query'] = remove_query_arg(array('year', 'monthnum', 'day'), $redirect['query']);
206
+			if ( $redirect_url = get_day_link(get_query_var('year'), get_query_var('monthnum'), get_query_var('day')) ) {
207
+							$redirect['query'] = remove_query_arg(array('year', 'monthnum', 'day'), $redirect['query']);
208
+			}
199 209
 		} elseif ( is_month() && get_query_var('year') && !empty($_GET['monthnum']) ) {
200
-			if ( $redirect_url = get_month_link(get_query_var('year'), get_query_var('monthnum')) )
201
-				$redirect['query'] = remove_query_arg(array('year', 'monthnum'), $redirect['query']);
210
+			if ( $redirect_url = get_month_link(get_query_var('year'), get_query_var('monthnum')) ) {
211
+							$redirect['query'] = remove_query_arg(array('year', 'monthnum'), $redirect['query']);
212
+			}
202 213
 		} elseif ( is_year() && !empty($_GET['year']) ) {
203
-			if ( $redirect_url = get_year_link(get_query_var('year')) )
204
-				$redirect['query'] = remove_query_arg('year', $redirect['query']);
214
+			if ( $redirect_url = get_year_link(get_query_var('year')) ) {
215
+							$redirect['query'] = remove_query_arg('year', $redirect['query']);
216
+			}
205 217
 		} elseif ( is_author() && !empty($_GET['author']) && preg_match( '|^[0-9]+$|', $_GET['author'] ) ) {
206 218
 			$author = get_userdata(get_query_var('author'));
207 219
 			if ( ( false !== $author ) && $wpdb->get_var( $wpdb->prepare( "SELECT ID FROM $wpdb->posts WHERE $wpdb->posts.post_author = %d AND $wpdb->posts.post_status = 'publish' LIMIT 1", $author->ID ) ) ) {
208
-				if ( $redirect_url = get_author_posts_url($author->ID, $author->user_nicename) )
209
-					$redirect['query'] = remove_query_arg('author', $redirect['query']);
220
+				if ( $redirect_url = get_author_posts_url($author->ID, $author->user_nicename) ) {
221
+									$redirect['query'] = remove_query_arg('author', $redirect['query']);
222
+				}
210 223
 			}
211 224
 		} elseif ( is_category() || is_tag() || is_tax() ) { // Terms (Tags/categories)
212 225
 
213 226
 			$term_count = 0;
214
-			foreach ( $wp_query->tax_query->queried_terms as $tax_query )
215
-				$term_count += count( $tax_query['terms'] );
227
+			foreach ( $wp_query->tax_query->queried_terms as $tax_query ) {
228
+							$term_count += count( $tax_query['terms'] );
229
+			}
216 230
 
217 231
 			$obj = $wp_query->get_queried_object();
218 232
 			if ( $term_count <= 1 && !empty($obj->term_id) && ( $tax_url = get_term_link((int)$obj->term_id, $obj->taxonomy) ) && !is_wp_error($tax_url) ) {
@@ -227,8 +241,9 @@  discard block
 block discarded – undo
227 241
 						$qv_remove[] = 'tag_id';
228 242
 					} else { // Custom taxonomies will have a custom query var, remove those too:
229 243
 						$tax_obj = get_taxonomy( $obj->taxonomy );
230
-						if ( false !== $tax_obj->query_var )
231
-							$qv_remove[] = $tax_obj->query_var;
244
+						if ( false !== $tax_obj->query_var ) {
245
+													$qv_remove[] = $tax_obj->query_var;
246
+						}
232 247
 					}
233 248
 
234 249
 					$rewrite_vars = array_diff( array_keys($wp_query->query), array_keys($_GET) );
@@ -247,8 +262,9 @@  discard block
 block discarded – undo
247 262
 
248 263
 					} else { // Some query vars are set via $_GET. Unset those from $_GET that exist via the rewrite
249 264
 						foreach ( $qv_remove as $_qv ) {
250
-							if ( isset($rewrite_vars[$_qv]) )
251
-								$redirect['query'] = remove_query_arg($_qv, $redirect['query']);
265
+							if ( isset($rewrite_vars[$_qv]) ) {
266
+															$redirect['query'] = remove_query_arg($_qv, $redirect['query']);
267
+							}
252 268
 						}
253 269
 					}
254 270
 				}
@@ -264,8 +280,9 @@  discard block
 block discarded – undo
264 280
 
265 281
 		// Post Paging
266 282
 		if ( is_singular() && get_query_var('page') ) {
267
-			if ( !$redirect_url )
268
-				$redirect_url = get_permalink( get_queried_object_id() );
283
+			if ( !$redirect_url ) {
284
+							$redirect_url = get_permalink( get_queried_object_id() );
285
+			}
269 286
 
270 287
 			$page = get_query_var( 'page' );
271 288
 			if ( $page > 1 ) {
@@ -290,12 +307,14 @@  discard block
 block discarded – undo
290 307
 			$addl_path = '';
291 308
 			if ( is_feed() && in_array( get_query_var('feed'), $wp_rewrite->feeds ) ) {
292 309
 				$addl_path = !empty( $addl_path ) ? trailingslashit($addl_path) : '';
293
-				if ( !is_singular() && get_query_var( 'withcomments' ) )
294
-					$addl_path .= 'comments/';
295
-				if ( ( 'rss' == get_default_feed() && 'feed' == get_query_var('feed') ) || 'rss' == get_query_var('feed') )
296
-					$addl_path .= user_trailingslashit( 'feed/' . ( ( get_default_feed() == 'rss2' ) ? '' : 'rss2' ), 'feed' );
297
-				else
298
-					$addl_path .= user_trailingslashit( 'feed/' . ( ( get_default_feed() ==  get_query_var('feed') || 'feed' == get_query_var('feed') ) ? '' : get_query_var('feed') ), 'feed' );
310
+				if ( !is_singular() && get_query_var( 'withcomments' ) ) {
311
+									$addl_path .= 'comments/';
312
+				}
313
+				if ( ( 'rss' == get_default_feed() && 'feed' == get_query_var('feed') ) || 'rss' == get_query_var('feed') ) {
314
+									$addl_path .= user_trailingslashit( 'feed/' . ( ( get_default_feed() == 'rss2' ) ? '' : 'rss2' ), 'feed' );
315
+				} else {
316
+									$addl_path .= user_trailingslashit( 'feed/' . ( ( get_default_feed() ==  get_query_var('feed') || 'feed' == get_query_var('feed') ) ? '' : get_query_var('feed') ), 'feed' );
317
+				}
299 318
 				$redirect['query'] = remove_query_arg( 'feed', $redirect['query'] );
300 319
 			} elseif ( is_feed() && 'old' == get_query_var('feed') ) {
301 320
 				$old_feed_files = array(
@@ -336,10 +355,12 @@  discard block
 block discarded – undo
336 355
 			}
337 356
 
338 357
 			$redirect['path'] = user_trailingslashit( preg_replace('|/' . preg_quote( $wp_rewrite->index, '|' ) . '/?$|', '/', $redirect['path']) ); // strip off trailing /index.php/
339
-			if ( !empty( $addl_path ) && $wp_rewrite->using_index_permalinks() && strpos($redirect['path'], '/' . $wp_rewrite->index . '/') === false )
340
-				$redirect['path'] = trailingslashit($redirect['path']) . $wp_rewrite->index . '/';
341
-			if ( !empty( $addl_path ) )
342
-				$redirect['path'] = trailingslashit($redirect['path']) . $addl_path;
358
+			if ( !empty( $addl_path ) && $wp_rewrite->using_index_permalinks() && strpos($redirect['path'], '/' . $wp_rewrite->index . '/') === false ) {
359
+							$redirect['path'] = trailingslashit($redirect['path']) . $wp_rewrite->index . '/';
360
+			}
361
+			if ( !empty( $addl_path ) ) {
362
+							$redirect['path'] = trailingslashit($redirect['path']) . $addl_path;
363
+			}
343 364
 			$redirect_url = $redirect['scheme'] . '://' . $redirect['host'] . $redirect['path'];
344 365
 		}
345 366
 
@@ -365,29 +386,34 @@  discard block
 block discarded – undo
365 386
 		if ( ! empty( $_parsed_query['name'] ) && ! empty( $redirect['query'] ) ) {
366 387
 			parse_str( $redirect['query'], $_parsed_redirect_query );
367 388
 
368
-			if ( empty( $_parsed_redirect_query['name'] ) )
369
-				unset( $_parsed_query['name'] );
389
+			if ( empty( $_parsed_redirect_query['name'] ) ) {
390
+							unset( $_parsed_query['name'] );
391
+			}
370 392
 		}
371 393
 
372 394
 		$_parsed_query = rawurlencode_deep( $_parsed_query );
373 395
 		$redirect_url = add_query_arg( $_parsed_query, $redirect_url );
374 396
 	}
375 397
 
376
-	if ( $redirect_url )
377
-		$redirect = @parse_url($redirect_url);
398
+	if ( $redirect_url ) {
399
+			$redirect = @parse_url($redirect_url);
400
+	}
378 401
 
379 402
 	// www.example.com vs example.com
380 403
 	$user_home = @parse_url(home_url());
381
-	if ( !empty($user_home['host']) )
382
-		$redirect['host'] = $user_home['host'];
383
-	if ( empty($user_home['path']) )
384
-		$user_home['path'] = '/';
404
+	if ( !empty($user_home['host']) ) {
405
+			$redirect['host'] = $user_home['host'];
406
+	}
407
+	if ( empty($user_home['path']) ) {
408
+			$user_home['path'] = '/';
409
+	}
385 410
 
386 411
 	// Handle ports
387
-	if ( !empty($user_home['port']) )
388
-		$redirect['port'] = $user_home['port'];
389
-	else
390
-		unset($redirect['port']);
412
+	if ( !empty($user_home['port']) ) {
413
+			$redirect['port'] = $user_home['port'];
414
+	} else {
415
+			unset($redirect['port']);
416
+	}
391 417
 
392 418
 	// trailing /index.php
393 419
 	$redirect['path'] = preg_replace('|/' . preg_quote( $wp_rewrite->index, '|' ) . '/*?$|', '/', $redirect['path']);
@@ -410,8 +436,9 @@  discard block
 block discarded – undo
410 436
 	}
411 437
 
412 438
 	// strip /index.php/ when we're not using PATHINFO permalinks
413
-	if ( !$wp_rewrite->using_index_permalinks() )
414
-		$redirect['path'] = str_replace( '/' . $wp_rewrite->index . '/', '/', $redirect['path'] );
439
+	if ( !$wp_rewrite->using_index_permalinks() ) {
440
+			$redirect['path'] = str_replace( '/' . $wp_rewrite->index . '/', '/', $redirect['path'] );
441
+	}
415 442
 
416 443
 	// trailing slashes
417 444
 	if ( is_object($wp_rewrite) && $wp_rewrite->using_permalinks() && !is_404() && (!is_front_page() || ( is_front_page() && (get_query_var('paged') > 1) ) ) ) {
@@ -433,42 +460,51 @@  discard block
 block discarded – undo
433 460
 	}
434 461
 
435 462
 	// Strip multiple slashes out of the URL
436
-	if ( strpos($redirect['path'], '//') > -1 )
437
-		$redirect['path'] = preg_replace('|/+|', '/', $redirect['path']);
463
+	if ( strpos($redirect['path'], '//') > -1 ) {
464
+			$redirect['path'] = preg_replace('|/+|', '/', $redirect['path']);
465
+	}
438 466
 
439 467
 	// Always trailing slash the Front Page URL
440
-	if ( trailingslashit( $redirect['path'] ) == trailingslashit( $user_home['path'] ) )
441
-		$redirect['path'] = trailingslashit($redirect['path']);
468
+	if ( trailingslashit( $redirect['path'] ) == trailingslashit( $user_home['path'] ) ) {
469
+			$redirect['path'] = trailingslashit($redirect['path']);
470
+	}
442 471
 
443 472
 	// Ignore differences in host capitalization, as this can lead to infinite redirects
444 473
 	// Only redirect no-www <=> yes-www
445 474
 	if ( strtolower($original['host']) == strtolower($redirect['host']) ||
446
-		( strtolower($original['host']) != 'www.' . strtolower($redirect['host']) && 'www.' . strtolower($original['host']) != strtolower($redirect['host']) ) )
447
-		$redirect['host'] = $original['host'];
475
+		( strtolower($original['host']) != 'www.' . strtolower($redirect['host']) && 'www.' . strtolower($original['host']) != strtolower($redirect['host']) ) ) {
476
+			$redirect['host'] = $original['host'];
477
+	}
448 478
 
449 479
 	$compare_original = array( $original['host'], $original['path'] );
450 480
 
451
-	if ( !empty( $original['port'] ) )
452
-		$compare_original[] = $original['port'];
481
+	if ( !empty( $original['port'] ) ) {
482
+			$compare_original[] = $original['port'];
483
+	}
453 484
 
454
-	if ( !empty( $original['query'] ) )
455
-		$compare_original[] = $original['query'];
485
+	if ( !empty( $original['query'] ) ) {
486
+			$compare_original[] = $original['query'];
487
+	}
456 488
 
457 489
 	$compare_redirect = array( $redirect['host'], $redirect['path'] );
458 490
 
459
-	if ( !empty( $redirect['port'] ) )
460
-		$compare_redirect[] = $redirect['port'];
491
+	if ( !empty( $redirect['port'] ) ) {
492
+			$compare_redirect[] = $redirect['port'];
493
+	}
461 494
 
462
-	if ( !empty( $redirect['query'] ) )
463
-		$compare_redirect[] = $redirect['query'];
495
+	if ( !empty( $redirect['query'] ) ) {
496
+			$compare_redirect[] = $redirect['query'];
497
+	}
464 498
 
465 499
 	if ( $compare_original !== $compare_redirect ) {
466 500
 		$redirect_url = $redirect['scheme'] . '://' . $redirect['host'];
467
-		if ( !empty($redirect['port']) )
468
-			$redirect_url .= ':' . $redirect['port'];
501
+		if ( !empty($redirect['port']) ) {
502
+					$redirect_url .= ':' . $redirect['port'];
503
+		}
469 504
 		$redirect_url .= $redirect['path'];
470
-		if ( !empty($redirect['query']) )
471
-			$redirect_url .= '?' . $redirect['query'];
505
+		if ( !empty($redirect['query']) ) {
506
+					$redirect_url .= '?' . $redirect['query'];
507
+		}
472 508
 	}
473 509
 
474 510
 	if ( ! $redirect_url || $redirect_url == $requested_url ) {
@@ -534,8 +570,9 @@  discard block
 block discarded – undo
534 570
 	if ( ! empty( $parsed_url['query'] ) ) {
535 571
 		parse_str( $parsed_url['query'], $parsed_query );
536 572
 		foreach ( $args_to_check as $qv ) {
537
-			if ( !isset( $parsed_query[$qv] ) )
538
-				$query_string = remove_query_arg( $qv, $query_string );
573
+			if ( !isset( $parsed_query[$qv] ) ) {
574
+							$query_string = remove_query_arg( $qv, $query_string );
575
+			}
539 576
 		}
540 577
 	} else {
541 578
 		$query_string = remove_query_arg( $args_to_check, $query_string );
@@ -584,27 +621,33 @@  discard block
 block discarded – undo
584 621
 		$where = $wpdb->prepare("post_name LIKE %s", $wpdb->esc_like( get_query_var('name') ) . '%');
585 622
 
586 623
 		// if any of post_type, year, monthnum, or day are set, use them to refine the query
587
-		if ( get_query_var('post_type') )
588
-			$where .= $wpdb->prepare(" AND post_type = %s", get_query_var('post_type'));
589
-		else
590
-			$where .= " AND post_type IN ('" . implode( "', '", get_post_types( array( 'public' => true ) ) ) . "')";
591
-
592
-		if ( get_query_var('year') )
593
-			$where .= $wpdb->prepare(" AND YEAR(post_date) = %d", get_query_var('year'));
594
-		if ( get_query_var('monthnum') )
595
-			$where .= $wpdb->prepare(" AND MONTH(post_date) = %d", get_query_var('monthnum'));
596
-		if ( get_query_var('day') )
597
-			$where .= $wpdb->prepare(" AND DAYOFMONTH(post_date) = %d", get_query_var('day'));
624
+		if ( get_query_var('post_type') ) {
625
+					$where .= $wpdb->prepare(" AND post_type = %s", get_query_var('post_type'));
626
+		} else {
627
+					$where .= " AND post_type IN ('" . implode( "', '", get_post_types( array( 'public' => true ) ) ) . "')";
628
+		}
629
+
630
+		if ( get_query_var('year') ) {
631
+					$where .= $wpdb->prepare(" AND YEAR(post_date) = %d", get_query_var('year'));
632
+		}
633
+		if ( get_query_var('monthnum') ) {
634
+					$where .= $wpdb->prepare(" AND MONTH(post_date) = %d", get_query_var('monthnum'));
635
+		}
636
+		if ( get_query_var('day') ) {
637
+					$where .= $wpdb->prepare(" AND DAYOFMONTH(post_date) = %d", get_query_var('day'));
638
+		}
598 639
 
599 640
 		$post_id = $wpdb->get_var("SELECT ID FROM $wpdb->posts WHERE $where AND post_status = 'publish'");
600
-		if ( ! $post_id )
601
-			return false;
602
-		if ( get_query_var( 'feed' ) )
603
-			return get_post_comments_feed_link( $post_id, get_query_var( 'feed' ) );
604
-		elseif ( get_query_var( 'page' ) && 1 < get_query_var( 'page' ) )
605
-			return trailingslashit( get_permalink( $post_id ) ) . user_trailingslashit( get_query_var( 'page' ), 'single_paged' );
606
-		else
607
-			return get_permalink( $post_id );
641
+		if ( ! $post_id ) {
642
+					return false;
643
+		}
644
+		if ( get_query_var( 'feed' ) ) {
645
+					return get_post_comments_feed_link( $post_id, get_query_var( 'feed' ) );
646
+		} elseif ( get_query_var( 'page' ) && 1 < get_query_var( 'page' ) ) {
647
+					return trailingslashit( get_permalink( $post_id ) ) . user_trailingslashit( get_query_var( 'page' ), 'single_paged' );
648
+		} else {
649
+					return get_permalink( $post_id );
650
+		}
608 651
 	}
609 652
 
610 653
 	return false;
@@ -622,8 +665,9 @@  discard block
 block discarded – undo
622 665
  */
623 666
 function wp_redirect_admin_locations() {
624 667
 	global $wp_rewrite;
625
-	if ( ! ( is_404() && $wp_rewrite->using_permalinks() ) )
626
-		return;
668
+	if ( ! ( is_404() && $wp_rewrite->using_permalinks() ) ) {
669
+			return;
670
+	}
627 671
 
628 672
 	$admins = array(
629 673
 		home_url( 'wp-admin', 'relative' ),
Please login to merge, or discard this patch.
Spacing   +238 added lines, -238 removed lines patch added patch discarded remove patch
@@ -38,28 +38,28 @@  discard block
 block discarded – undo
38 38
  * @param bool $do_redirect Optional. Redirect to the new URL.
39 39
  * @return string|void The string of the URL, if redirect needed.
40 40
  */
41
-function redirect_canonical( $requested_url = null, $do_redirect = true ) {
41
+function redirect_canonical($requested_url = null, $do_redirect = true) {
42 42
 	global $wp_rewrite, $is_IIS, $wp_query, $wpdb, $wp;
43 43
 
44
-	if ( isset( $_SERVER['REQUEST_METHOD'] ) && ! in_array( strtoupper( $_SERVER['REQUEST_METHOD'] ), array( 'GET', 'HEAD' ) ) ) {
44
+	if (isset($_SERVER['REQUEST_METHOD']) && ! in_array(strtoupper($_SERVER['REQUEST_METHOD']), array('GET', 'HEAD'))) {
45 45
 		return;
46 46
 	}
47 47
 
48 48
 	// If we're not in wp-admin and the post has been published and preview nonce
49 49
 	// is non-existent or invalid then no need for preview in query
50
-	if ( is_preview() && get_query_var( 'p' ) && 'publish' == get_post_status( get_query_var( 'p' ) ) ) {
51
-		if ( ! isset( $_GET['preview_id'] )
52
-			|| ! isset( $_GET['preview_nonce'] )
53
-			|| ! wp_verify_nonce( $_GET['preview_nonce'], 'post_preview_' . (int) $_GET['preview_id'] ) ) {
50
+	if (is_preview() && get_query_var('p') && 'publish' == get_post_status(get_query_var('p'))) {
51
+		if ( ! isset($_GET['preview_id'])
52
+			|| ! isset($_GET['preview_nonce'])
53
+			|| ! wp_verify_nonce($_GET['preview_nonce'], 'post_preview_'.(int) $_GET['preview_id'])) {
54 54
 			$wp_query->is_preview = false;
55 55
 		}
56 56
 	}
57 57
 
58
-	if ( is_trackback() || is_search() || is_admin() || is_preview() || is_robots() || ( $is_IIS && !iis7_supports_permalinks() ) ) {
58
+	if (is_trackback() || is_search() || is_admin() || is_preview() || is_robots() || ($is_IIS && ! iis7_supports_permalinks())) {
59 59
 		return;
60 60
 	}
61 61
 
62
-	if ( ! $requested_url && isset( $_SERVER['HTTP_HOST'] ) ) {
62
+	if ( ! $requested_url && isset($_SERVER['HTTP_HOST'])) {
63 63
 		// build the URL in the address bar
64 64
 		$requested_url  = is_ssl() ? 'https://' : 'http://';
65 65
 		$requested_url .= $_SERVER['HTTP_HOST'];
@@ -67,7 +67,7 @@  discard block
 block discarded – undo
67 67
 	}
68 68
 
69 69
 	$original = @parse_url($requested_url);
70
-	if ( false === $original ) {
70
+	if (false === $original) {
71 71
 		return;
72 72
 	}
73 73
 
@@ -75,170 +75,170 @@  discard block
 block discarded – undo
75 75
 	$redirect_url = false;
76 76
 
77 77
 	// Notice fixing
78
-	if ( !isset($redirect['path']) )
78
+	if ( ! isset($redirect['path']))
79 79
 		$redirect['path'] = '';
80
-	if ( !isset($redirect['query']) )
80
+	if ( ! isset($redirect['query']))
81 81
 		$redirect['query'] = '';
82 82
 
83 83
 	// If the original URL ended with non-breaking spaces, they were almost
84 84
 	// certainly inserted by accident. Let's remove them, so the reader doesn't
85 85
 	// see a 404 error with no obvious cause.
86
-	$redirect['path'] = preg_replace( '|(%C2%A0)+$|i', '', $redirect['path'] );
86
+	$redirect['path'] = preg_replace('|(%C2%A0)+$|i', '', $redirect['path']);
87 87
 
88 88
 	// It's not a preview, so remove it from URL
89
-	if ( get_query_var( 'preview' ) ) {
90
-		$redirect['query'] = remove_query_arg( 'preview', $redirect['query'] );
89
+	if (get_query_var('preview')) {
90
+		$redirect['query'] = remove_query_arg('preview', $redirect['query']);
91 91
 	}
92 92
 
93
-	if ( is_feed() && ( $id = get_query_var( 'p' ) ) ) {
94
-		if ( $redirect_url = get_post_comments_feed_link( $id, get_query_var( 'feed' ) ) ) {
95
-			$redirect['query'] = _remove_qs_args_if_not_in_url( $redirect['query'], array( 'p', 'page_id', 'attachment_id', 'pagename', 'name', 'post_type', 'feed'), $redirect_url );
96
-			$redirect['path'] = parse_url( $redirect_url, PHP_URL_PATH );
93
+	if (is_feed() && ($id = get_query_var('p'))) {
94
+		if ($redirect_url = get_post_comments_feed_link($id, get_query_var('feed'))) {
95
+			$redirect['query'] = _remove_qs_args_if_not_in_url($redirect['query'], array('p', 'page_id', 'attachment_id', 'pagename', 'name', 'post_type', 'feed'), $redirect_url);
96
+			$redirect['path'] = parse_url($redirect_url, PHP_URL_PATH);
97 97
 		}
98 98
 	}
99 99
 
100
-	if ( is_singular() && 1 > $wp_query->post_count && ($id = get_query_var('p')) ) {
100
+	if (is_singular() && 1 > $wp_query->post_count && ($id = get_query_var('p'))) {
101 101
 
102
-		$vars = $wpdb->get_results( $wpdb->prepare("SELECT post_type, post_parent FROM $wpdb->posts WHERE ID = %d", $id) );
102
+		$vars = $wpdb->get_results($wpdb->prepare("SELECT post_type, post_parent FROM $wpdb->posts WHERE ID = %d", $id));
103 103
 
104
-		if ( isset($vars[0]) && $vars = $vars[0] ) {
105
-			if ( 'revision' == $vars->post_type && $vars->post_parent > 0 )
104
+		if (isset($vars[0]) && $vars = $vars[0]) {
105
+			if ('revision' == $vars->post_type && $vars->post_parent > 0)
106 106
 				$id = $vars->post_parent;
107 107
 
108
-			if ( $redirect_url = get_permalink($id) )
109
-				$redirect['query'] = _remove_qs_args_if_not_in_url( $redirect['query'], array( 'p', 'page_id', 'attachment_id', 'pagename', 'name', 'post_type' ), $redirect_url );
108
+			if ($redirect_url = get_permalink($id))
109
+				$redirect['query'] = _remove_qs_args_if_not_in_url($redirect['query'], array('p', 'page_id', 'attachment_id', 'pagename', 'name', 'post_type'), $redirect_url);
110 110
 		}
111 111
 	}
112 112
 
113 113
 	// These tests give us a WP-generated permalink
114
-	if ( is_404() ) {
114
+	if (is_404()) {
115 115
 
116 116
 		// Redirect ?page_id, ?p=, ?attachment_id= to their respective url's
117
-		$id = max( get_query_var('p'), get_query_var('page_id'), get_query_var('attachment_id') );
118
-		if ( $id && $redirect_post = get_post($id) ) {
117
+		$id = max(get_query_var('p'), get_query_var('page_id'), get_query_var('attachment_id'));
118
+		if ($id && $redirect_post = get_post($id)) {
119 119
 			$post_type_obj = get_post_type_object($redirect_post->post_type);
120
-			if ( $post_type_obj->public && 'auto-draft' != $redirect_post->post_status ) {
120
+			if ($post_type_obj->public && 'auto-draft' != $redirect_post->post_status) {
121 121
 				$redirect_url = get_permalink($redirect_post);
122
-				$redirect['query'] = _remove_qs_args_if_not_in_url( $redirect['query'], array( 'p', 'page_id', 'attachment_id', 'pagename', 'name', 'post_type' ), $redirect_url );
122
+				$redirect['query'] = _remove_qs_args_if_not_in_url($redirect['query'], array('p', 'page_id', 'attachment_id', 'pagename', 'name', 'post_type'), $redirect_url);
123 123
 			}
124 124
 		}
125 125
 
126
-		if ( get_query_var( 'day' ) && get_query_var( 'monthnum' ) && get_query_var( 'year' ) ) {
127
-			$year  = get_query_var( 'year' );
128
-			$month = get_query_var( 'monthnum' );
129
-			$day   = get_query_var( 'day' );
130
-			$date  = sprintf( '%04d-%02d-%02d', $year, $month, $day );
131
-			if ( ! wp_checkdate( $month, $day, $year, $date ) ) {
132
-				$redirect_url = get_month_link( $year, $month );
133
-				$redirect['query'] = _remove_qs_args_if_not_in_url( $redirect['query'], array( 'year', 'monthnum', 'day' ), $redirect_url );
126
+		if (get_query_var('day') && get_query_var('monthnum') && get_query_var('year')) {
127
+			$year  = get_query_var('year');
128
+			$month = get_query_var('monthnum');
129
+			$day   = get_query_var('day');
130
+			$date  = sprintf('%04d-%02d-%02d', $year, $month, $day);
131
+			if ( ! wp_checkdate($month, $day, $year, $date)) {
132
+				$redirect_url = get_month_link($year, $month);
133
+				$redirect['query'] = _remove_qs_args_if_not_in_url($redirect['query'], array('year', 'monthnum', 'day'), $redirect_url);
134 134
 			}
135
-		} elseif ( get_query_var( 'monthnum' ) && get_query_var( 'year' ) && 12 < get_query_var( 'monthnum' ) ) {
136
-			$redirect_url = get_year_link( get_query_var( 'year' ) );
137
-			$redirect['query'] = _remove_qs_args_if_not_in_url( $redirect['query'], array( 'year', 'monthnum' ), $redirect_url );
135
+		} elseif (get_query_var('monthnum') && get_query_var('year') && 12 < get_query_var('monthnum')) {
136
+			$redirect_url = get_year_link(get_query_var('year'));
137
+			$redirect['query'] = _remove_qs_args_if_not_in_url($redirect['query'], array('year', 'monthnum'), $redirect_url);
138 138
 		}
139 139
 
140
-		if ( ! $redirect_url ) {
141
-			if ( $redirect_url = redirect_guess_404_permalink() ) {
142
-				$redirect['query'] = _remove_qs_args_if_not_in_url( $redirect['query'], array( 'page', 'feed', 'p', 'page_id', 'attachment_id', 'pagename', 'name', 'post_type' ), $redirect_url );
140
+		if ( ! $redirect_url) {
141
+			if ($redirect_url = redirect_guess_404_permalink()) {
142
+				$redirect['query'] = _remove_qs_args_if_not_in_url($redirect['query'], array('page', 'feed', 'p', 'page_id', 'attachment_id', 'pagename', 'name', 'post_type'), $redirect_url);
143 143
 			}
144 144
 		}
145 145
 
146
-		if ( get_query_var( 'page' ) && $wp_query->post &&
147
-			false !== strpos( $wp_query->post->post_content, '<!--nextpage-->' ) ) {
148
-			$redirect['path'] = rtrim( $redirect['path'], (int) get_query_var( 'page' ) . '/' );
149
-			$redirect['query'] = remove_query_arg( 'page', $redirect['query'] );
150
-			$redirect_url = get_permalink( $wp_query->post->ID );
146
+		if (get_query_var('page') && $wp_query->post &&
147
+			false !== strpos($wp_query->post->post_content, '<!--nextpage-->')) {
148
+			$redirect['path'] = rtrim($redirect['path'], (int) get_query_var('page').'/');
149
+			$redirect['query'] = remove_query_arg('page', $redirect['query']);
150
+			$redirect_url = get_permalink($wp_query->post->ID);
151 151
 		}
152 152
 
153
-	} elseif ( is_object($wp_rewrite) && $wp_rewrite->using_permalinks() ) {
153
+	} elseif (is_object($wp_rewrite) && $wp_rewrite->using_permalinks()) {
154 154
 		// rewriting of old ?p=X, ?m=2004, ?m=200401, ?m=20040101
155
-		if ( is_attachment() &&
156
-			! array_diff( array_keys( $wp->query_vars ), array( 'attachment', 'attachment_id' ) ) &&
157
-			! $redirect_url ) {
158
-			if ( ! empty( $_GET['attachment_id'] ) ) {
159
-				$redirect_url = get_attachment_link( get_query_var( 'attachment_id' ) );
160
-				if ( $redirect_url ) {
161
-					$redirect['query'] = remove_query_arg( 'attachment_id', $redirect['query'] );
155
+		if (is_attachment() &&
156
+			! array_diff(array_keys($wp->query_vars), array('attachment', 'attachment_id')) &&
157
+			! $redirect_url) {
158
+			if ( ! empty($_GET['attachment_id'])) {
159
+				$redirect_url = get_attachment_link(get_query_var('attachment_id'));
160
+				if ($redirect_url) {
161
+					$redirect['query'] = remove_query_arg('attachment_id', $redirect['query']);
162 162
 				}
163 163
 			} else {
164 164
 				$redirect_url = get_attachment_link();
165 165
 			}
166
-		} elseif ( is_single() && !empty($_GET['p']) && ! $redirect_url ) {
167
-			if ( $redirect_url = get_permalink(get_query_var('p')) )
166
+		} elseif (is_single() && ! empty($_GET['p']) && ! $redirect_url) {
167
+			if ($redirect_url = get_permalink(get_query_var('p')))
168 168
 				$redirect['query'] = remove_query_arg(array('p', 'post_type'), $redirect['query']);
169
-		} elseif ( is_single() && !empty($_GET['name'])  && ! $redirect_url ) {
170
-			if ( $redirect_url = get_permalink( $wp_query->get_queried_object_id() ) )
169
+		} elseif (is_single() && ! empty($_GET['name']) && ! $redirect_url) {
170
+			if ($redirect_url = get_permalink($wp_query->get_queried_object_id()))
171 171
 				$redirect['query'] = remove_query_arg('name', $redirect['query']);
172
-		} elseif ( is_page() && !empty($_GET['page_id']) && ! $redirect_url ) {
173
-			if ( $redirect_url = get_permalink(get_query_var('page_id')) )
172
+		} elseif (is_page() && ! empty($_GET['page_id']) && ! $redirect_url) {
173
+			if ($redirect_url = get_permalink(get_query_var('page_id')))
174 174
 				$redirect['query'] = remove_query_arg('page_id', $redirect['query']);
175
-		} elseif ( is_page() && !is_feed() && 'page' == get_option('show_on_front') && get_queried_object_id() == get_option('page_on_front')  && ! $redirect_url ) {
175
+		} elseif (is_page() && ! is_feed() && 'page' == get_option('show_on_front') && get_queried_object_id() == get_option('page_on_front') && ! $redirect_url) {
176 176
 			$redirect_url = home_url('/');
177
-		} elseif ( is_home() && !empty($_GET['page_id']) && 'page' == get_option('show_on_front') && get_query_var('page_id') == get_option('page_for_posts')  && ! $redirect_url ) {
178
-			if ( $redirect_url = get_permalink(get_option('page_for_posts')) )
177
+		} elseif (is_home() && ! empty($_GET['page_id']) && 'page' == get_option('show_on_front') && get_query_var('page_id') == get_option('page_for_posts') && ! $redirect_url) {
178
+			if ($redirect_url = get_permalink(get_option('page_for_posts')))
179 179
 				$redirect['query'] = remove_query_arg('page_id', $redirect['query']);
180
-		} elseif ( !empty($_GET['m']) && ( is_year() || is_month() || is_day() ) ) {
180
+		} elseif ( ! empty($_GET['m']) && (is_year() || is_month() || is_day())) {
181 181
 			$m = get_query_var('m');
182
-			switch ( strlen($m) ) {
182
+			switch (strlen($m)) {
183 183
 				case 4: // Yearly
184 184
 					$redirect_url = get_year_link($m);
185 185
 					break;
186 186
 				case 6: // Monthly
187
-					$redirect_url = get_month_link( substr($m, 0, 4), substr($m, 4, 2) );
187
+					$redirect_url = get_month_link(substr($m, 0, 4), substr($m, 4, 2));
188 188
 					break;
189 189
 				case 8: // Daily
190 190
 					$redirect_url = get_day_link(substr($m, 0, 4), substr($m, 4, 2), substr($m, 6, 2));
191 191
 					break;
192 192
 			}
193
-			if ( $redirect_url )
193
+			if ($redirect_url)
194 194
 				$redirect['query'] = remove_query_arg('m', $redirect['query']);
195 195
 		// now moving on to non ?m=X year/month/day links
196
-		} elseif ( is_day() && get_query_var('year') && get_query_var('monthnum') && !empty($_GET['day']) ) {
197
-			if ( $redirect_url = get_day_link(get_query_var('year'), get_query_var('monthnum'), get_query_var('day')) )
196
+		} elseif (is_day() && get_query_var('year') && get_query_var('monthnum') && ! empty($_GET['day'])) {
197
+			if ($redirect_url = get_day_link(get_query_var('year'), get_query_var('monthnum'), get_query_var('day')))
198 198
 				$redirect['query'] = remove_query_arg(array('year', 'monthnum', 'day'), $redirect['query']);
199
-		} elseif ( is_month() && get_query_var('year') && !empty($_GET['monthnum']) ) {
200
-			if ( $redirect_url = get_month_link(get_query_var('year'), get_query_var('monthnum')) )
199
+		} elseif (is_month() && get_query_var('year') && ! empty($_GET['monthnum'])) {
200
+			if ($redirect_url = get_month_link(get_query_var('year'), get_query_var('monthnum')))
201 201
 				$redirect['query'] = remove_query_arg(array('year', 'monthnum'), $redirect['query']);
202
-		} elseif ( is_year() && !empty($_GET['year']) ) {
203
-			if ( $redirect_url = get_year_link(get_query_var('year')) )
202
+		} elseif (is_year() && ! empty($_GET['year'])) {
203
+			if ($redirect_url = get_year_link(get_query_var('year')))
204 204
 				$redirect['query'] = remove_query_arg('year', $redirect['query']);
205
-		} elseif ( is_author() && !empty($_GET['author']) && preg_match( '|^[0-9]+$|', $_GET['author'] ) ) {
205
+		} elseif (is_author() && ! empty($_GET['author']) && preg_match('|^[0-9]+$|', $_GET['author'])) {
206 206
 			$author = get_userdata(get_query_var('author'));
207
-			if ( ( false !== $author ) && $wpdb->get_var( $wpdb->prepare( "SELECT ID FROM $wpdb->posts WHERE $wpdb->posts.post_author = %d AND $wpdb->posts.post_status = 'publish' LIMIT 1", $author->ID ) ) ) {
208
-				if ( $redirect_url = get_author_posts_url($author->ID, $author->user_nicename) )
207
+			if ((false !== $author) && $wpdb->get_var($wpdb->prepare("SELECT ID FROM $wpdb->posts WHERE $wpdb->posts.post_author = %d AND $wpdb->posts.post_status = 'publish' LIMIT 1", $author->ID))) {
208
+				if ($redirect_url = get_author_posts_url($author->ID, $author->user_nicename))
209 209
 					$redirect['query'] = remove_query_arg('author', $redirect['query']);
210 210
 			}
211
-		} elseif ( is_category() || is_tag() || is_tax() ) { // Terms (Tags/categories)
211
+		} elseif (is_category() || is_tag() || is_tax()) { // Terms (Tags/categories)
212 212
 
213 213
 			$term_count = 0;
214
-			foreach ( $wp_query->tax_query->queried_terms as $tax_query )
215
-				$term_count += count( $tax_query['terms'] );
214
+			foreach ($wp_query->tax_query->queried_terms as $tax_query)
215
+				$term_count += count($tax_query['terms']);
216 216
 
217 217
 			$obj = $wp_query->get_queried_object();
218
-			if ( $term_count <= 1 && !empty($obj->term_id) && ( $tax_url = get_term_link((int)$obj->term_id, $obj->taxonomy) ) && !is_wp_error($tax_url) ) {
219
-				if ( !empty($redirect['query']) ) {
218
+			if ($term_count <= 1 && ! empty($obj->term_id) && ($tax_url = get_term_link((int) $obj->term_id, $obj->taxonomy)) && ! is_wp_error($tax_url)) {
219
+				if ( ! empty($redirect['query'])) {
220 220
 					// Strip taxonomy query vars off the url.
221
-					$qv_remove = array( 'term', 'taxonomy');
222
-					if ( is_category() ) {
221
+					$qv_remove = array('term', 'taxonomy');
222
+					if (is_category()) {
223 223
 						$qv_remove[] = 'category_name';
224 224
 						$qv_remove[] = 'cat';
225
-					} elseif ( is_tag() ) {
225
+					} elseif (is_tag()) {
226 226
 						$qv_remove[] = 'tag';
227 227
 						$qv_remove[] = 'tag_id';
228 228
 					} else { // Custom taxonomies will have a custom query var, remove those too:
229
-						$tax_obj = get_taxonomy( $obj->taxonomy );
230
-						if ( false !== $tax_obj->query_var )
229
+						$tax_obj = get_taxonomy($obj->taxonomy);
230
+						if (false !== $tax_obj->query_var)
231 231
 							$qv_remove[] = $tax_obj->query_var;
232 232
 					}
233 233
 
234
-					$rewrite_vars = array_diff( array_keys($wp_query->query), array_keys($_GET) );
234
+					$rewrite_vars = array_diff(array_keys($wp_query->query), array_keys($_GET));
235 235
 
236
-					if ( !array_diff($rewrite_vars, array_keys($_GET))  ) { // Check to see if all the Query vars are coming from the rewrite, none are set via $_GET
236
+					if ( ! array_diff($rewrite_vars, array_keys($_GET))) { // Check to see if all the Query vars are coming from the rewrite, none are set via $_GET
237 237
 						$redirect['query'] = remove_query_arg($qv_remove, $redirect['query']); //Remove all of the per-tax qv's
238 238
 
239 239
 						// Create the destination url for this taxonomy
240 240
 						$tax_url = parse_url($tax_url);
241
-						if ( ! empty($tax_url['query']) ) { // Taxonomy accessible via ?taxonomy=..&term=.. or any custom qv..
241
+						if ( ! empty($tax_url['query'])) { // Taxonomy accessible via ?taxonomy=..&term=.. or any custom qv..
242 242
 							parse_str($tax_url['query'], $query_vars);
243 243
 							$redirect['query'] = add_query_arg($query_vars, $redirect['query']);
244 244
 						} else { // Taxonomy is accessible via a "pretty-URL"
@@ -246,40 +246,40 @@  discard block
 block discarded – undo
246 246
 						}
247 247
 
248 248
 					} else { // Some query vars are set via $_GET. Unset those from $_GET that exist via the rewrite
249
-						foreach ( $qv_remove as $_qv ) {
250
-							if ( isset($rewrite_vars[$_qv]) )
249
+						foreach ($qv_remove as $_qv) {
250
+							if (isset($rewrite_vars[$_qv]))
251 251
 								$redirect['query'] = remove_query_arg($_qv, $redirect['query']);
252 252
 						}
253 253
 					}
254 254
 				}
255 255
 
256 256
 			}
257
-		} elseif ( is_single() && strpos($wp_rewrite->permalink_structure, '%category%') !== false && $cat = get_query_var( 'category_name' ) ) {
258
-			$category = get_category_by_path( $cat );
259
-			if ( ( ! $category || is_wp_error( $category ) ) || ! has_term( $category->term_id, 'category', $wp_query->get_queried_object_id() ) ) {
257
+		} elseif (is_single() && strpos($wp_rewrite->permalink_structure, '%category%') !== false && $cat = get_query_var('category_name')) {
258
+			$category = get_category_by_path($cat);
259
+			if (( ! $category || is_wp_error($category)) || ! has_term($category->term_id, 'category', $wp_query->get_queried_object_id())) {
260 260
 				$redirect_url = get_permalink($wp_query->get_queried_object_id());
261 261
 			}
262 262
 		}
263 263
 
264 264
 		// Post Paging
265
-		if ( is_singular() && get_query_var('page') ) {
266
-			if ( !$redirect_url )
267
-				$redirect_url = get_permalink( get_queried_object_id() );
268
-
269
-			$page = get_query_var( 'page' );
270
-			if ( $page > 1 ) {
271
-				if ( is_front_page() ) {
272
-					$redirect_url = trailingslashit( $redirect_url ) . user_trailingslashit( "$wp_rewrite->pagination_base/$page", 'paged' );
265
+		if (is_singular() && get_query_var('page')) {
266
+			if ( ! $redirect_url)
267
+				$redirect_url = get_permalink(get_queried_object_id());
268
+
269
+			$page = get_query_var('page');
270
+			if ($page > 1) {
271
+				if (is_front_page()) {
272
+					$redirect_url = trailingslashit($redirect_url).user_trailingslashit("$wp_rewrite->pagination_base/$page", 'paged');
273 273
 				} else {
274
-					$redirect_url = trailingslashit( $redirect_url ) . user_trailingslashit( $page, 'single_paged' );
274
+					$redirect_url = trailingslashit($redirect_url).user_trailingslashit($page, 'single_paged');
275 275
 				}
276 276
 			}
277
-			$redirect['query'] = remove_query_arg( 'page', $redirect['query'] );
277
+			$redirect['query'] = remove_query_arg('page', $redirect['query']);
278 278
 		}
279 279
 
280 280
 		// paging and feeds
281
-		if ( get_query_var('paged') || is_feed() || get_query_var('cpage') ) {
282
-			while ( preg_match( "#/$wp_rewrite->pagination_base/?[0-9]+?(/+)?$#", $redirect['path'] ) || preg_match( '#/(comments/?)?(feed|rss|rdf|atom|rss2)(/+)?$#', $redirect['path'] ) || preg_match( "#/{$wp_rewrite->comments_pagination_base}-[0-9]+(/+)?$#", $redirect['path'] ) ) {
281
+		if (get_query_var('paged') || is_feed() || get_query_var('cpage')) {
282
+			while (preg_match("#/$wp_rewrite->pagination_base/?[0-9]+?(/+)?$#", $redirect['path']) || preg_match('#/(comments/?)?(feed|rss|rdf|atom|rss2)(/+)?$#', $redirect['path']) || preg_match("#/{$wp_rewrite->comments_pagination_base}-[0-9]+(/+)?$#", $redirect['path'])) {
283 283
 				// Strip off paging and feed
284 284
 				$redirect['path'] = preg_replace("#/$wp_rewrite->pagination_base/?[0-9]+?(/+)?$#", '/', $redirect['path']); // strip off any existing paging
285 285
 				$redirect['path'] = preg_replace('#/(comments/?)?(feed|rss2?|rdf|atom)(/+|$)#', '/', $redirect['path']); // strip off feed endings
@@ -287,16 +287,16 @@  discard block
 block discarded – undo
287 287
 			}
288 288
 
289 289
 			$addl_path = '';
290
-			if ( is_feed() && in_array( get_query_var('feed'), $wp_rewrite->feeds ) ) {
291
-				$addl_path = !empty( $addl_path ) ? trailingslashit($addl_path) : '';
292
-				if ( !is_singular() && get_query_var( 'withcomments' ) )
290
+			if (is_feed() && in_array(get_query_var('feed'), $wp_rewrite->feeds)) {
291
+				$addl_path = ! empty($addl_path) ? trailingslashit($addl_path) : '';
292
+				if ( ! is_singular() && get_query_var('withcomments'))
293 293
 					$addl_path .= 'comments/';
294
-				if ( ( 'rss' == get_default_feed() && 'feed' == get_query_var('feed') ) || 'rss' == get_query_var('feed') )
295
-					$addl_path .= user_trailingslashit( 'feed/' . ( ( get_default_feed() == 'rss2' ) ? '' : 'rss2' ), 'feed' );
294
+				if (('rss' == get_default_feed() && 'feed' == get_query_var('feed')) || 'rss' == get_query_var('feed'))
295
+					$addl_path .= user_trailingslashit('feed/'.((get_default_feed() == 'rss2') ? '' : 'rss2'), 'feed');
296 296
 				else
297
-					$addl_path .= user_trailingslashit( 'feed/' . ( ( get_default_feed() ==  get_query_var('feed') || 'feed' == get_query_var('feed') ) ? '' : get_query_var('feed') ), 'feed' );
298
-				$redirect['query'] = remove_query_arg( 'feed', $redirect['query'] );
299
-			} elseif ( is_feed() && 'old' == get_query_var('feed') ) {
297
+					$addl_path .= user_trailingslashit('feed/'.((get_default_feed() == get_query_var('feed') || 'feed' == get_query_var('feed')) ? '' : get_query_var('feed')), 'feed');
298
+				$redirect['query'] = remove_query_arg('feed', $redirect['query']);
299
+			} elseif (is_feed() && 'old' == get_query_var('feed')) {
300 300
 				$old_feed_files = array(
301 301
 					'wp-atom.php'         => 'atom',
302 302
 					'wp-commentsrss2.php' => 'comments_rss2',
@@ -305,178 +305,178 @@  discard block
 block discarded – undo
305 305
 					'wp-rss.php'          => 'rss2',
306 306
 					'wp-rss2.php'         => 'rss2',
307 307
 				);
308
-				if ( isset( $old_feed_files[ basename( $redirect['path'] ) ] ) ) {
309
-					$redirect_url = get_feed_link( $old_feed_files[ basename( $redirect['path'] ) ] );
310
-					wp_redirect( $redirect_url, 301 );
308
+				if (isset($old_feed_files[basename($redirect['path'])])) {
309
+					$redirect_url = get_feed_link($old_feed_files[basename($redirect['path'])]);
310
+					wp_redirect($redirect_url, 301);
311 311
 					die();
312 312
 				}
313 313
 			}
314 314
 
315
-			if ( get_query_var('paged') > 0 ) {
315
+			if (get_query_var('paged') > 0) {
316 316
 				$paged = get_query_var('paged');
317
-				$redirect['query'] = remove_query_arg( 'paged', $redirect['query'] );
318
-				if ( !is_feed() ) {
319
-					if ( $paged > 1 && !is_single() ) {
320
-						$addl_path = ( !empty( $addl_path ) ? trailingslashit($addl_path) : '' ) . user_trailingslashit("$wp_rewrite->pagination_base/$paged", 'paged');
321
-					} elseif ( !is_single() ) {
322
-						$addl_path = !empty( $addl_path ) ? trailingslashit($addl_path) : '';
317
+				$redirect['query'] = remove_query_arg('paged', $redirect['query']);
318
+				if ( ! is_feed()) {
319
+					if ($paged > 1 && ! is_single()) {
320
+						$addl_path = ( ! empty($addl_path) ? trailingslashit($addl_path) : '').user_trailingslashit("$wp_rewrite->pagination_base/$paged", 'paged');
321
+					} elseif ( ! is_single()) {
322
+						$addl_path = ! empty($addl_path) ? trailingslashit($addl_path) : '';
323 323
 					}
324
-				} elseif ( $paged > 1 ) {
325
-					$redirect['query'] = add_query_arg( 'paged', $paged, $redirect['query'] );
324
+				} elseif ($paged > 1) {
325
+					$redirect['query'] = add_query_arg('paged', $paged, $redirect['query']);
326 326
 				}
327 327
 			}
328 328
 
329
-			if ( get_option( 'page_comments' ) && (
330
-				( 'newest' == get_option( 'default_comments_page' ) && get_query_var( 'cpage' ) > 0 ) ||
331
-				( 'newest' != get_option( 'default_comments_page' ) && get_query_var( 'cpage' ) > 1 )
332
-			) ) {
333
-				$addl_path = ( !empty( $addl_path ) ? trailingslashit($addl_path) : '' ) . user_trailingslashit( $wp_rewrite->comments_pagination_base . '-' . get_query_var('cpage'), 'commentpaged' );
334
-				$redirect['query'] = remove_query_arg( 'cpage', $redirect['query'] );
329
+			if (get_option('page_comments') && (
330
+				('newest' == get_option('default_comments_page') && get_query_var('cpage') > 0) ||
331
+				('newest' != get_option('default_comments_page') && get_query_var('cpage') > 1)
332
+			)) {
333
+				$addl_path = ( ! empty($addl_path) ? trailingslashit($addl_path) : '').user_trailingslashit($wp_rewrite->comments_pagination_base.'-'.get_query_var('cpage'), 'commentpaged');
334
+				$redirect['query'] = remove_query_arg('cpage', $redirect['query']);
335 335
 			}
336 336
 
337
-			$redirect['path'] = user_trailingslashit( preg_replace('|/' . preg_quote( $wp_rewrite->index, '|' ) . '/?$|', '/', $redirect['path']) ); // strip off trailing /index.php/
338
-			if ( !empty( $addl_path ) && $wp_rewrite->using_index_permalinks() && strpos($redirect['path'], '/' . $wp_rewrite->index . '/') === false )
339
-				$redirect['path'] = trailingslashit($redirect['path']) . $wp_rewrite->index . '/';
340
-			if ( !empty( $addl_path ) )
341
-				$redirect['path'] = trailingslashit($redirect['path']) . $addl_path;
342
-			$redirect_url = $redirect['scheme'] . '://' . $redirect['host'] . $redirect['path'];
337
+			$redirect['path'] = user_trailingslashit(preg_replace('|/'.preg_quote($wp_rewrite->index, '|').'/?$|', '/', $redirect['path'])); // strip off trailing /index.php/
338
+			if ( ! empty($addl_path) && $wp_rewrite->using_index_permalinks() && strpos($redirect['path'], '/'.$wp_rewrite->index.'/') === false)
339
+				$redirect['path'] = trailingslashit($redirect['path']).$wp_rewrite->index.'/';
340
+			if ( ! empty($addl_path))
341
+				$redirect['path'] = trailingslashit($redirect['path']).$addl_path;
342
+			$redirect_url = $redirect['scheme'].'://'.$redirect['host'].$redirect['path'];
343 343
 		}
344 344
 
345
-		if ( 'wp-register.php' == basename( $redirect['path'] ) ) {
346
-			if ( is_multisite() ) {
345
+		if ('wp-register.php' == basename($redirect['path'])) {
346
+			if (is_multisite()) {
347 347
 				/** This filter is documented in wp-login.php */
348
-				$redirect_url = apply_filters( 'wp_signup_location', network_site_url( 'wp-signup.php' ) );
348
+				$redirect_url = apply_filters('wp_signup_location', network_site_url('wp-signup.php'));
349 349
 			} else {
350 350
 				$redirect_url = wp_registration_url();
351 351
 			}
352 352
 
353
-			wp_redirect( $redirect_url, 301 );
353
+			wp_redirect($redirect_url, 301);
354 354
 			die();
355 355
 		}
356 356
 	}
357 357
 
358 358
 	// tack on any additional query vars
359
-	$redirect['query'] = preg_replace( '#^\??&*?#', '', $redirect['query'] );
360
-	if ( $redirect_url && !empty($redirect['query']) ) {
361
-		parse_str( $redirect['query'], $_parsed_query );
359
+	$redirect['query'] = preg_replace('#^\??&*?#', '', $redirect['query']);
360
+	if ($redirect_url && ! empty($redirect['query'])) {
361
+		parse_str($redirect['query'], $_parsed_query);
362 362
 		$redirect = @parse_url($redirect_url);
363 363
 
364
-		if ( ! empty( $_parsed_query['name'] ) && ! empty( $redirect['query'] ) ) {
365
-			parse_str( $redirect['query'], $_parsed_redirect_query );
364
+		if ( ! empty($_parsed_query['name']) && ! empty($redirect['query'])) {
365
+			parse_str($redirect['query'], $_parsed_redirect_query);
366 366
 
367
-			if ( empty( $_parsed_redirect_query['name'] ) )
368
-				unset( $_parsed_query['name'] );
367
+			if (empty($_parsed_redirect_query['name']))
368
+				unset($_parsed_query['name']);
369 369
 		}
370 370
 
371
-		$_parsed_query = rawurlencode_deep( $_parsed_query );
372
-		$redirect_url = add_query_arg( $_parsed_query, $redirect_url );
371
+		$_parsed_query = rawurlencode_deep($_parsed_query);
372
+		$redirect_url = add_query_arg($_parsed_query, $redirect_url);
373 373
 	}
374 374
 
375
-	if ( $redirect_url )
375
+	if ($redirect_url)
376 376
 		$redirect = @parse_url($redirect_url);
377 377
 
378 378
 	// www.example.com vs example.com
379 379
 	$user_home = @parse_url(home_url());
380
-	if ( !empty($user_home['host']) )
380
+	if ( ! empty($user_home['host']))
381 381
 		$redirect['host'] = $user_home['host'];
382
-	if ( empty($user_home['path']) )
382
+	if (empty($user_home['path']))
383 383
 		$user_home['path'] = '/';
384 384
 
385 385
 	// Handle ports
386
-	if ( !empty($user_home['port']) )
386
+	if ( ! empty($user_home['port']))
387 387
 		$redirect['port'] = $user_home['port'];
388 388
 	else
389 389
 		unset($redirect['port']);
390 390
 
391 391
 	// trailing /index.php
392
-	$redirect['path'] = preg_replace('|/' . preg_quote( $wp_rewrite->index, '|' ) . '/*?$|', '/', $redirect['path']);
392
+	$redirect['path'] = preg_replace('|/'.preg_quote($wp_rewrite->index, '|').'/*?$|', '/', $redirect['path']);
393 393
 
394 394
 	// Remove trailing spaces from the path
395
-	$redirect['path'] = preg_replace( '#(%20| )+$#', '', $redirect['path'] );
395
+	$redirect['path'] = preg_replace('#(%20| )+$#', '', $redirect['path']);
396 396
 
397
-	if ( !empty( $redirect['query'] ) ) {
397
+	if ( ! empty($redirect['query'])) {
398 398
 		// Remove trailing spaces from certain terminating query string args
399
-		$redirect['query'] = preg_replace( '#((p|page_id|cat|tag)=[^&]*?)(%20| )+$#', '$1', $redirect['query'] );
399
+		$redirect['query'] = preg_replace('#((p|page_id|cat|tag)=[^&]*?)(%20| )+$#', '$1', $redirect['query']);
400 400
 
401 401
 		// Clean up empty query strings
402
-		$redirect['query'] = trim(preg_replace( '#(^|&)(p|page_id|cat|tag)=?(&|$)#', '&', $redirect['query']), '&');
402
+		$redirect['query'] = trim(preg_replace('#(^|&)(p|page_id|cat|tag)=?(&|$)#', '&', $redirect['query']), '&');
403 403
 
404 404
 		// Redirect obsolete feeds
405
-		$redirect['query'] = preg_replace( '#(^|&)feed=rss(&|$)#', '$1feed=rss2$2', $redirect['query'] );
405
+		$redirect['query'] = preg_replace('#(^|&)feed=rss(&|$)#', '$1feed=rss2$2', $redirect['query']);
406 406
 
407 407
 		// Remove redundant leading ampersands
408
-		$redirect['query'] = preg_replace( '#^\??&*?#', '', $redirect['query'] );
408
+		$redirect['query'] = preg_replace('#^\??&*?#', '', $redirect['query']);
409 409
 	}
410 410
 
411 411
 	// strip /index.php/ when we're not using PATHINFO permalinks
412
-	if ( !$wp_rewrite->using_index_permalinks() )
413
-		$redirect['path'] = str_replace( '/' . $wp_rewrite->index . '/', '/', $redirect['path'] );
412
+	if ( ! $wp_rewrite->using_index_permalinks())
413
+		$redirect['path'] = str_replace('/'.$wp_rewrite->index.'/', '/', $redirect['path']);
414 414
 
415 415
 	// trailing slashes
416
-	if ( is_object($wp_rewrite) && $wp_rewrite->using_permalinks() && !is_404() && (!is_front_page() || ( is_front_page() && (get_query_var('paged') > 1) ) ) ) {
416
+	if (is_object($wp_rewrite) && $wp_rewrite->using_permalinks() && ! is_404() && ( ! is_front_page() || (is_front_page() && (get_query_var('paged') > 1)))) {
417 417
 		$user_ts_type = '';
418
-		if ( get_query_var('paged') > 0 ) {
418
+		if (get_query_var('paged') > 0) {
419 419
 			$user_ts_type = 'paged';
420 420
 		} else {
421
-			foreach ( array('single', 'category', 'page', 'day', 'month', 'year', 'home') as $type ) {
422
-				$func = 'is_' . $type;
423
-				if ( call_user_func($func) ) {
421
+			foreach (array('single', 'category', 'page', 'day', 'month', 'year', 'home') as $type) {
422
+				$func = 'is_'.$type;
423
+				if (call_user_func($func)) {
424 424
 					$user_ts_type = $type;
425 425
 					break;
426 426
 				}
427 427
 			}
428 428
 		}
429 429
 		$redirect['path'] = user_trailingslashit($redirect['path'], $user_ts_type);
430
-	} elseif ( is_front_page() ) {
430
+	} elseif (is_front_page()) {
431 431
 		$redirect['path'] = trailingslashit($redirect['path']);
432 432
 	}
433 433
 
434 434
 	// Strip multiple slashes out of the URL
435
-	if ( strpos($redirect['path'], '//') > -1 )
435
+	if (strpos($redirect['path'], '//') > -1)
436 436
 		$redirect['path'] = preg_replace('|/+|', '/', $redirect['path']);
437 437
 
438 438
 	// Always trailing slash the Front Page URL
439
-	if ( trailingslashit( $redirect['path'] ) == trailingslashit( $user_home['path'] ) )
439
+	if (trailingslashit($redirect['path']) == trailingslashit($user_home['path']))
440 440
 		$redirect['path'] = trailingslashit($redirect['path']);
441 441
 
442 442
 	// Ignore differences in host capitalization, as this can lead to infinite redirects
443 443
 	// Only redirect no-www <=> yes-www
444
-	if ( strtolower($original['host']) == strtolower($redirect['host']) ||
445
-		( strtolower($original['host']) != 'www.' . strtolower($redirect['host']) && 'www.' . strtolower($original['host']) != strtolower($redirect['host']) ) )
444
+	if (strtolower($original['host']) == strtolower($redirect['host']) ||
445
+		(strtolower($original['host']) != 'www.'.strtolower($redirect['host']) && 'www.'.strtolower($original['host']) != strtolower($redirect['host'])))
446 446
 		$redirect['host'] = $original['host'];
447 447
 
448
-	$compare_original = array( $original['host'], $original['path'] );
448
+	$compare_original = array($original['host'], $original['path']);
449 449
 
450
-	if ( !empty( $original['port'] ) )
450
+	if ( ! empty($original['port']))
451 451
 		$compare_original[] = $original['port'];
452 452
 
453
-	if ( !empty( $original['query'] ) )
453
+	if ( ! empty($original['query']))
454 454
 		$compare_original[] = $original['query'];
455 455
 
456
-	$compare_redirect = array( $redirect['host'], $redirect['path'] );
456
+	$compare_redirect = array($redirect['host'], $redirect['path']);
457 457
 
458
-	if ( !empty( $redirect['port'] ) )
458
+	if ( ! empty($redirect['port']))
459 459
 		$compare_redirect[] = $redirect['port'];
460 460
 
461
-	if ( !empty( $redirect['query'] ) )
461
+	if ( ! empty($redirect['query']))
462 462
 		$compare_redirect[] = $redirect['query'];
463 463
 
464
-	if ( $compare_original !== $compare_redirect ) {
465
-		$redirect_url = $redirect['scheme'] . '://' . $redirect['host'];
466
-		if ( !empty($redirect['port']) )
467
-			$redirect_url .= ':' . $redirect['port'];
464
+	if ($compare_original !== $compare_redirect) {
465
+		$redirect_url = $redirect['scheme'].'://'.$redirect['host'];
466
+		if ( ! empty($redirect['port']))
467
+			$redirect_url .= ':'.$redirect['port'];
468 468
 		$redirect_url .= $redirect['path'];
469
-		if ( !empty($redirect['query']) )
470
-			$redirect_url .= '?' . $redirect['query'];
469
+		if ( ! empty($redirect['query']))
470
+			$redirect_url .= '?'.$redirect['query'];
471 471
 	}
472 472
 
473
-	if ( ! $redirect_url || $redirect_url == $requested_url ) {
473
+	if ( ! $redirect_url || $redirect_url == $requested_url) {
474 474
 		return;
475 475
 	}
476 476
 
477 477
 	// Hex encoded octets are case-insensitive.
478
-	if ( false !== strpos($requested_url, '%') ) {
479
-		if ( !function_exists('lowercase_octets') ) {
478
+	if (false !== strpos($requested_url, '%')) {
479
+		if ( ! function_exists('lowercase_octets')) {
480 480
 			/**
481 481
 			 * Converts the first hex-encoded octet match to lowercase.
482 482
 			 *
@@ -487,7 +487,7 @@  discard block
 block discarded – undo
487 487
 			 * @return string Lowercased version of the first match.
488 488
 			 */
489 489
 			function lowercase_octets($matches) {
490
-				return strtolower( $matches[0] );
490
+				return strtolower($matches[0]);
491 491
 			}
492 492
 		}
493 493
 		$requested_url = preg_replace_callback('|%[a-fA-F0-9][a-fA-F0-9]|', 'lowercase_octets', $requested_url);
@@ -503,16 +503,16 @@  discard block
 block discarded – undo
503 503
 	 * @param string $redirect_url  The redirect URL.
504 504
 	 * @param string $requested_url The requested URL.
505 505
 	 */
506
-	$redirect_url = apply_filters( 'redirect_canonical', $redirect_url, $requested_url );
506
+	$redirect_url = apply_filters('redirect_canonical', $redirect_url, $requested_url);
507 507
 
508 508
 	// yes, again -- in case the filter aborted the request
509
-	if ( ! $redirect_url || strip_fragment_from_url( $redirect_url ) == strip_fragment_from_url( $requested_url ) ) {
509
+	if ( ! $redirect_url || strip_fragment_from_url($redirect_url) == strip_fragment_from_url($requested_url)) {
510 510
 		return;
511 511
 	}
512 512
 
513
-	if ( $do_redirect ) {
513
+	if ($do_redirect) {
514 514
 		// protect against chained redirects
515
-		if ( !redirect_canonical($redirect_url, false) ) {
515
+		if ( ! redirect_canonical($redirect_url, false)) {
516 516
 			wp_redirect($redirect_url, 301);
517 517
 			exit();
518 518
 		} else {
@@ -537,16 +537,16 @@  discard block
 block discarded – undo
537 537
  * @param string $url
538 538
  * @return string The altered query string
539 539
  */
540
-function _remove_qs_args_if_not_in_url( $query_string, Array $args_to_check, $url ) {
541
-	$parsed_url = @parse_url( $url );
542
-	if ( ! empty( $parsed_url['query'] ) ) {
543
-		parse_str( $parsed_url['query'], $parsed_query );
544
-		foreach ( $args_to_check as $qv ) {
545
-			if ( !isset( $parsed_query[$qv] ) )
546
-				$query_string = remove_query_arg( $qv, $query_string );
540
+function _remove_qs_args_if_not_in_url($query_string, Array $args_to_check, $url) {
541
+	$parsed_url = @parse_url($url);
542
+	if ( ! empty($parsed_url['query'])) {
543
+		parse_str($parsed_url['query'], $parsed_query);
544
+		foreach ($args_to_check as $qv) {
545
+			if ( ! isset($parsed_query[$qv]))
546
+				$query_string = remove_query_arg($qv, $query_string);
547 547
 		}
548 548
 	} else {
549
-		$query_string = remove_query_arg( $args_to_check, $query_string );
549
+		$query_string = remove_query_arg($args_to_check, $query_string);
550 550
 	}
551 551
 	return $query_string;
552 552
 }
@@ -559,17 +559,17 @@  discard block
 block discarded – undo
559 559
  * @param string $url The URL to strip.
560 560
  * @return string The altered URL.
561 561
  */
562
-function strip_fragment_from_url( $url ) {
563
-	$parsed_url = @parse_url( $url );
564
-	if ( ! empty( $parsed_url['host'] ) ) {
562
+function strip_fragment_from_url($url) {
563
+	$parsed_url = @parse_url($url);
564
+	if ( ! empty($parsed_url['host'])) {
565 565
 		// This mirrors code in redirect_canonical(). It does not handle every case.
566
-		$url = $parsed_url['scheme'] . '://' . $parsed_url['host'];
567
-		if ( ! empty( $parsed_url['port'] ) ) {
568
-			$url .= ':' . $parsed_url['port'];
566
+		$url = $parsed_url['scheme'].'://'.$parsed_url['host'];
567
+		if ( ! empty($parsed_url['port'])) {
568
+			$url .= ':'.$parsed_url['port'];
569 569
 		}
570 570
 		$url .= $parsed_url['path'];
571
-		if ( ! empty( $parsed_url['query'] ) ) {
572
-			$url .= '?' . $parsed_url['query'];
571
+		if ( ! empty($parsed_url['query'])) {
572
+			$url .= '?'.$parsed_url['query'];
573 573
 		}
574 574
 	}
575 575
 
@@ -588,31 +588,31 @@  discard block
 block discarded – undo
588 588
 function redirect_guess_404_permalink() {
589 589
 	global $wpdb;
590 590
 
591
-	if ( get_query_var('name') ) {
592
-		$where = $wpdb->prepare("post_name LIKE %s", $wpdb->esc_like( get_query_var('name') ) . '%');
591
+	if (get_query_var('name')) {
592
+		$where = $wpdb->prepare("post_name LIKE %s", $wpdb->esc_like(get_query_var('name')).'%');
593 593
 
594 594
 		// if any of post_type, year, monthnum, or day are set, use them to refine the query
595
-		if ( get_query_var('post_type') )
595
+		if (get_query_var('post_type'))
596 596
 			$where .= $wpdb->prepare(" AND post_type = %s", get_query_var('post_type'));
597 597
 		else
598
-			$where .= " AND post_type IN ('" . implode( "', '", get_post_types( array( 'public' => true ) ) ) . "')";
598
+			$where .= " AND post_type IN ('".implode("', '", get_post_types(array('public' => true)))."')";
599 599
 
600
-		if ( get_query_var('year') )
600
+		if (get_query_var('year'))
601 601
 			$where .= $wpdb->prepare(" AND YEAR(post_date) = %d", get_query_var('year'));
602
-		if ( get_query_var('monthnum') )
602
+		if (get_query_var('monthnum'))
603 603
 			$where .= $wpdb->prepare(" AND MONTH(post_date) = %d", get_query_var('monthnum'));
604
-		if ( get_query_var('day') )
604
+		if (get_query_var('day'))
605 605
 			$where .= $wpdb->prepare(" AND DAYOFMONTH(post_date) = %d", get_query_var('day'));
606 606
 
607 607
 		$post_id = $wpdb->get_var("SELECT ID FROM $wpdb->posts WHERE $where AND post_status = 'publish'");
608
-		if ( ! $post_id )
608
+		if ( ! $post_id)
609 609
 			return false;
610
-		if ( get_query_var( 'feed' ) )
611
-			return get_post_comments_feed_link( $post_id, get_query_var( 'feed' ) );
612
-		elseif ( get_query_var( 'page' ) && 1 < get_query_var( 'page' ) )
613
-			return trailingslashit( get_permalink( $post_id ) ) . user_trailingslashit( get_query_var( 'page' ), 'single_paged' );
610
+		if (get_query_var('feed'))
611
+			return get_post_comments_feed_link($post_id, get_query_var('feed'));
612
+		elseif (get_query_var('page') && 1 < get_query_var('page'))
613
+			return trailingslashit(get_permalink($post_id)).user_trailingslashit(get_query_var('page'), 'single_paged');
614 614
 		else
615
-			return get_permalink( $post_id );
615
+			return get_permalink($post_id);
616 616
 	}
617 617
 
618 618
 	return false;
@@ -630,28 +630,28 @@  discard block
 block discarded – undo
630 630
  */
631 631
 function wp_redirect_admin_locations() {
632 632
 	global $wp_rewrite;
633
-	if ( ! ( is_404() && $wp_rewrite->using_permalinks() ) )
633
+	if ( ! (is_404() && $wp_rewrite->using_permalinks()))
634 634
 		return;
635 635
 
636 636
 	$admins = array(
637
-		home_url( 'wp-admin', 'relative' ),
638
-		home_url( 'dashboard', 'relative' ),
639
-		home_url( 'admin', 'relative' ),
640
-		site_url( 'dashboard', 'relative' ),
641
-		site_url( 'admin', 'relative' ),
637
+		home_url('wp-admin', 'relative'),
638
+		home_url('dashboard', 'relative'),
639
+		home_url('admin', 'relative'),
640
+		site_url('dashboard', 'relative'),
641
+		site_url('admin', 'relative'),
642 642
 	);
643
-	if ( in_array( untrailingslashit( $_SERVER['REQUEST_URI'] ), $admins ) ) {
644
-		wp_redirect( admin_url() );
643
+	if (in_array(untrailingslashit($_SERVER['REQUEST_URI']), $admins)) {
644
+		wp_redirect(admin_url());
645 645
 		exit;
646 646
 	}
647 647
 
648 648
 	$logins = array(
649
-		home_url( 'wp-login.php', 'relative' ),
650
-		home_url( 'login', 'relative' ),
651
-		site_url( 'login', 'relative' ),
649
+		home_url('wp-login.php', 'relative'),
650
+		home_url('login', 'relative'),
651
+		site_url('login', 'relative'),
652 652
 	);
653
-	if ( in_array( untrailingslashit( $_SERVER['REQUEST_URI'] ), $logins ) ) {
654
-		wp_redirect( wp_login_url() );
653
+	if (in_array(untrailingslashit($_SERVER['REQUEST_URI']), $logins)) {
654
+		wp_redirect(wp_login_url());
655 655
 		exit;
656 656
 	}
657 657
 }
Please login to merge, or discard this patch.
src/wp-includes/class-phpass.php 4 patches
Doc Comments   +18 added lines patch added patch discarded remove patch
@@ -62,6 +62,9 @@  discard block
 block discarded – undo
62 62
 		self::__construct( $iteration_count_log2, $portable_hashes );
63 63
 	}
64 64
 
65
+	/**
66
+	 * @param integer $count
67
+	 */
65 68
 	function get_random_bytes($count)
66 69
 	{
67 70
 		$output = '';
@@ -85,6 +88,9 @@  discard block
 block discarded – undo
85 88
 		return $output;
86 89
 	}
87 90
 
91
+	/**
92
+	 * @param integer $count
93
+	 */
88 94
 	function encode64($input, $count)
89 95
 	{
90 96
 		$output = '';
@@ -108,6 +114,9 @@  discard block
 block discarded – undo
108 114
 		return $output;
109 115
 	}
110 116
 
117
+	/**
118
+	 * @param string $input
119
+	 */
111 120
 	function gensalt_private($input)
112 121
 	{
113 122
 		$output = '$P$';
@@ -163,6 +172,9 @@  discard block
 block discarded – undo
163 172
 		return $output;
164 173
 	}
165 174
 
175
+	/**
176
+	 * @param string $input
177
+	 */
166 178
 	function gensalt_extended($input)
167 179
 	{
168 180
 		$count_log2 = min($this->iteration_count_log2 + 8, 24);
@@ -181,6 +193,9 @@  discard block
 block discarded – undo
181 193
 		return $output;
182 194
 	}
183 195
 
196
+	/**
197
+	 * @param string $input
198
+	 */
184 199
 	function gensalt_blowfish($input)
185 200
 	{
186 201
 		# This one needs to use a different order of characters and a
@@ -222,6 +237,9 @@  discard block
 block discarded – undo
222 237
 		return $output;
223 238
 	}
224 239
 
240
+	/**
241
+	 * @param string $password
242
+	 */
225 243
 	function HashPassword($password)
226 244
 	{
227 245
 		if ( strlen( $password ) > 4096 ) {
Please login to merge, or discard this patch.
Spacing   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -42,7 +42,7 @@  discard block
 block discarded – undo
42 42
 	/**
43 43
 	 * PHP5 constructor.
44 44
 	 */
45
-	function __construct( $iteration_count_log2, $portable_hashes )
45
+	function __construct($iteration_count_log2, $portable_hashes)
46 46
 	{
47 47
 		$this->itoa64 = './0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz';
48 48
 
@@ -52,20 +52,20 @@  discard block
 block discarded – undo
52 52
 
53 53
 		$this->portable_hashes = $portable_hashes;
54 54
 
55
-		$this->random_state = microtime() . uniqid(rand(), TRUE); // removed getmypid() for compatibility reasons
55
+		$this->random_state = microtime().uniqid(rand(), TRUE); // removed getmypid() for compatibility reasons
56 56
 	}
57 57
 
58 58
 	/**
59 59
 	 * PHP4 constructor.
60 60
 	 */
61
-	public function PasswordHash( $iteration_count_log2, $portable_hashes ) {
62
-		self::__construct( $iteration_count_log2, $portable_hashes );
61
+	public function PasswordHash($iteration_count_log2, $portable_hashes) {
62
+		self::__construct($iteration_count_log2, $portable_hashes);
63 63
 	}
64 64
 
65 65
 	function get_random_bytes($count)
66 66
 	{
67 67
 		$output = '';
68
-		if ( @is_readable('/dev/urandom') &&
68
+		if (@is_readable('/dev/urandom') &&
69 69
 		    ($fh = @fopen('/dev/urandom', 'rb'))) {
70 70
 			$output = fread($fh, $count);
71 71
 			fclose($fh);
@@ -75,7 +75,7 @@  discard block
 block discarded – undo
75 75
 			$output = '';
76 76
 			for ($i = 0; $i < $count; $i += 16) {
77 77
 				$this->random_state =
78
-				    md5(microtime() . $this->random_state);
78
+				    md5(microtime().$this->random_state);
79 79
 				$output .=
80 80
 				    pack('H*', md5($this->random_state));
81 81
 			}
@@ -146,14 +146,14 @@  discard block
 block discarded – undo
146 146
 		# consequently in lower iteration counts and hashes that are
147 147
 		# quicker to crack (by non-PHP code).
148 148
 		if (PHP_VERSION >= '5') {
149
-			$hash = md5($salt . $password, TRUE);
149
+			$hash = md5($salt.$password, TRUE);
150 150
 			do {
151
-				$hash = md5($hash . $password, TRUE);
151
+				$hash = md5($hash.$password, TRUE);
152 152
 			} while (--$count);
153 153
 		} else {
154
-			$hash = pack('H*', md5($salt . $password));
154
+			$hash = pack('H*', md5($salt.$password));
155 155
 			do {
156
-				$hash = pack('H*', md5($hash . $password));
156
+				$hash = pack('H*', md5($hash.$password));
157 157
 			} while (--$count);
158 158
 		}
159 159
 
@@ -224,13 +224,13 @@  discard block
 block discarded – undo
224 224
 
225 225
 	function HashPassword($password)
226 226
 	{
227
-		if ( strlen( $password ) > 4096 ) {
227
+		if (strlen($password) > 4096) {
228 228
 			return '*';
229 229
 		}
230 230
 
231 231
 		$random = '';
232 232
 
233
-		if (CRYPT_BLOWFISH == 1 && !$this->portable_hashes) {
233
+		if (CRYPT_BLOWFISH == 1 && ! $this->portable_hashes) {
234 234
 			$random = $this->get_random_bytes(16);
235 235
 			$hash =
236 236
 			    crypt($password, $this->gensalt_blowfish($random));
@@ -238,7 +238,7 @@  discard block
 block discarded – undo
238 238
 				return $hash;
239 239
 		}
240 240
 
241
-		if (CRYPT_EXT_DES == 1 && !$this->portable_hashes) {
241
+		if (CRYPT_EXT_DES == 1 && ! $this->portable_hashes) {
242 242
 			if (strlen($random) < 3)
243 243
 				$random = $this->get_random_bytes(3);
244 244
 			$hash =
@@ -263,7 +263,7 @@  discard block
 block discarded – undo
263 263
 
264 264
 	function CheckPassword($password, $stored_hash)
265 265
 	{
266
-		if ( strlen( $password ) > 4096 ) {
266
+		if (strlen($password) > 4096) {
267 267
 			return false;
268 268
 		}
269 269
 
Please login to merge, or discard this patch.
Braces   +45 added lines, -30 removed lines patch added patch discarded remove patch
@@ -46,8 +46,9 @@  discard block
 block discarded – undo
46 46
 	{
47 47
 		$this->itoa64 = './0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz';
48 48
 
49
-		if ($iteration_count_log2 < 4 || $iteration_count_log2 > 31)
50
-			$iteration_count_log2 = 8;
49
+		if ($iteration_count_log2 < 4 || $iteration_count_log2 > 31) {
50
+					$iteration_count_log2 = 8;
51
+		}
51 52
 		$this->iteration_count_log2 = $iteration_count_log2;
52 53
 
53 54
 		$this->portable_hashes = $portable_hashes;
@@ -92,16 +93,20 @@  discard block
 block discarded – undo
92 93
 		do {
93 94
 			$value = ord($input[$i++]);
94 95
 			$output .= $this->itoa64[$value & 0x3f];
95
-			if ($i < $count)
96
-				$value |= ord($input[$i]) << 8;
96
+			if ($i < $count) {
97
+							$value |= ord($input[$i]) << 8;
98
+			}
97 99
 			$output .= $this->itoa64[($value >> 6) & 0x3f];
98
-			if ($i++ >= $count)
99
-				break;
100
-			if ($i < $count)
101
-				$value |= ord($input[$i]) << 16;
100
+			if ($i++ >= $count) {
101
+							break;
102
+			}
103
+			if ($i < $count) {
104
+							$value |= ord($input[$i]) << 16;
105
+			}
102 106
 			$output .= $this->itoa64[($value >> 12) & 0x3f];
103
-			if ($i++ >= $count)
104
-				break;
107
+			if ($i++ >= $count) {
108
+							break;
109
+			}
105 110
 			$output .= $this->itoa64[($value >> 18) & 0x3f];
106 111
 		} while ($i < $count);
107 112
 
@@ -121,23 +126,27 @@  discard block
 block discarded – undo
121 126
 	function crypt_private($password, $setting)
122 127
 	{
123 128
 		$output = '*0';
124
-		if (substr($setting, 0, 2) == $output)
125
-			$output = '*1';
129
+		if (substr($setting, 0, 2) == $output) {
130
+					$output = '*1';
131
+		}
126 132
 
127 133
 		$id = substr($setting, 0, 3);
128 134
 		# We use "$P$", phpBB3 uses "$H$" for the same thing
129
-		if ($id != '$P$' && $id != '$H$')
130
-			return $output;
135
+		if ($id != '$P$' && $id != '$H$') {
136
+					return $output;
137
+		}
131 138
 
132 139
 		$count_log2 = strpos($this->itoa64, $setting[3]);
133
-		if ($count_log2 < 7 || $count_log2 > 30)
134
-			return $output;
140
+		if ($count_log2 < 7 || $count_log2 > 30) {
141
+					return $output;
142
+		}
135 143
 
136 144
 		$count = 1 << $count_log2;
137 145
 
138 146
 		$salt = substr($setting, 4, 8);
139
-		if (strlen($salt) != 8)
140
-			return $output;
147
+		if (strlen($salt) != 8) {
148
+					return $output;
149
+		}
141 150
 
142 151
 		# We're kind of forced to use MD5 here since it's the only
143 152
 		# cryptographic primitive available in all versions of PHP
@@ -234,26 +243,31 @@  discard block
 block discarded – undo
234 243
 			$random = $this->get_random_bytes(16);
235 244
 			$hash =
236 245
 			    crypt($password, $this->gensalt_blowfish($random));
237
-			if (strlen($hash) == 60)
238
-				return $hash;
246
+			if (strlen($hash) == 60) {
247
+							return $hash;
248
+			}
239 249
 		}
240 250
 
241 251
 		if (CRYPT_EXT_DES == 1 && !$this->portable_hashes) {
242
-			if (strlen($random) < 3)
243
-				$random = $this->get_random_bytes(3);
252
+			if (strlen($random) < 3) {
253
+							$random = $this->get_random_bytes(3);
254
+			}
244 255
 			$hash =
245 256
 			    crypt($password, $this->gensalt_extended($random));
246
-			if (strlen($hash) == 20)
247
-				return $hash;
257
+			if (strlen($hash) == 20) {
258
+							return $hash;
259
+			}
248 260
 		}
249 261
 
250
-		if (strlen($random) < 6)
251
-			$random = $this->get_random_bytes(6);
262
+		if (strlen($random) < 6) {
263
+					$random = $this->get_random_bytes(6);
264
+		}
252 265
 		$hash =
253 266
 		    $this->crypt_private($password,
254 267
 		    $this->gensalt_private($random));
255
-		if (strlen($hash) == 34)
256
-			return $hash;
268
+		if (strlen($hash) == 34) {
269
+					return $hash;
270
+		}
257 271
 
258 272
 		# Returning '*' on error is safe here, but would _not_ be safe
259 273
 		# in a crypt(3)-like function used _both_ for generating new
@@ -268,8 +282,9 @@  discard block
 block discarded – undo
268 282
 		}
269 283
 
270 284
 		$hash = $this->crypt_private($password, $stored_hash);
271
-		if ($hash[0] == '*')
272
-			$hash = crypt($password, $stored_hash);
285
+		if ($hash[0] == '*') {
286
+					$hash = crypt($password, $stored_hash);
287
+		}
273 288
 
274 289
 		return $hash === $stored_hash;
275 290
 	}
Please login to merge, or discard this patch.
Indentation   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -66,7 +66,7 @@  discard block
 block discarded – undo
66 66
 	{
67 67
 		$output = '';
68 68
 		if ( @is_readable('/dev/urandom') &&
69
-		    ($fh = @fopen('/dev/urandom', 'rb'))) {
69
+			($fh = @fopen('/dev/urandom', 'rb'))) {
70 70
 			$output = fread($fh, $count);
71 71
 			fclose($fh);
72 72
 		}
@@ -75,9 +75,9 @@  discard block
 block discarded – undo
75 75
 			$output = '';
76 76
 			for ($i = 0; $i < $count; $i += 16) {
77 77
 				$this->random_state =
78
-				    md5(microtime() . $this->random_state);
78
+					md5(microtime() . $this->random_state);
79 79
 				$output .=
80
-				    pack('H*', md5($this->random_state));
80
+					pack('H*', md5($this->random_state));
81 81
 			}
82 82
 			$output = substr($output, 0, $count);
83 83
 		}
@@ -233,7 +233,7 @@  discard block
 block discarded – undo
233 233
 		if (CRYPT_BLOWFISH == 1 && !$this->portable_hashes) {
234 234
 			$random = $this->get_random_bytes(16);
235 235
 			$hash =
236
-			    crypt($password, $this->gensalt_blowfish($random));
236
+				crypt($password, $this->gensalt_blowfish($random));
237 237
 			if (strlen($hash) == 60)
238 238
 				return $hash;
239 239
 		}
@@ -242,7 +242,7 @@  discard block
 block discarded – undo
242 242
 			if (strlen($random) < 3)
243 243
 				$random = $this->get_random_bytes(3);
244 244
 			$hash =
245
-			    crypt($password, $this->gensalt_extended($random));
245
+				crypt($password, $this->gensalt_extended($random));
246 246
 			if (strlen($hash) == 20)
247 247
 				return $hash;
248 248
 		}
@@ -250,8 +250,8 @@  discard block
 block discarded – undo
250 250
 		if (strlen($random) < 6)
251 251
 			$random = $this->get_random_bytes(6);
252 252
 		$hash =
253
-		    $this->crypt_private($password,
254
-		    $this->gensalt_private($random));
253
+			$this->crypt_private($password,
254
+			$this->gensalt_private($random));
255 255
 		if (strlen($hash) == 34)
256 256
 			return $hash;
257 257
 
Please login to merge, or discard this patch.
src/wp-includes/class-pop3.php 4 patches
Doc Comments   +3 added lines patch added patch discarded remove patch
@@ -626,6 +626,9 @@
 block discarded – undo
626 626
         }
627 627
     }
628 628
 
629
+    /**
630
+     * @param string $server_text
631
+     */
629 632
     function parse_banner ( $server_text ) {
630 633
         $outside = true;
631 634
         $banner = "";
Please login to merge, or discard this patch.
Spacing   +182 added lines, -182 removed lines patch added patch discarded remove patch
@@ -17,49 +17,49 @@  discard block
 block discarded – undo
17 17
  */
18 18
 
19 19
 class POP3 {
20
-    var $ERROR      = '';       //  Error string.
20
+    var $ERROR      = ''; //  Error string.
21 21
 
22
-    var $TIMEOUT    = 60;       //  Default timeout before giving up on a
22
+    var $TIMEOUT    = 60; //  Default timeout before giving up on a
23 23
                                 //  network operation.
24 24
 
25
-    var $COUNT      = -1;       //  Mailbox msg count
25
+    var $COUNT      = -1; //  Mailbox msg count
26 26
 
27
-    var $BUFFER     = 512;      //  Socket buffer for socket fgets() calls.
27
+    var $BUFFER     = 512; //  Socket buffer for socket fgets() calls.
28 28
                                 //  Per RFC 1939 the returned line a POP3
29 29
                                 //  server can send is 512 bytes.
30 30
 
31
-    var $FP         = '';       //  The connection to the server's
31
+    var $FP         = ''; //  The connection to the server's
32 32
                                 //  file descriptor
33 33
 
34
-    var $MAILSERVER = '';       // Set this to hard code the server name
34
+    var $MAILSERVER = ''; // Set this to hard code the server name
35 35
 
36
-    var $DEBUG      = FALSE;    // set to true to echo pop3
36
+    var $DEBUG      = FALSE; // set to true to echo pop3
37 37
                                 // commands and responses to error_log
38 38
                                 // this WILL log passwords!
39 39
 
40
-    var $BANNER     = '';       //  Holds the banner returned by the
40
+    var $BANNER     = ''; //  Holds the banner returned by the
41 41
                                 //  pop server - used for apop()
42 42
 
43
-    var $ALLOWAPOP  = FALSE;    //  Allow or disallow apop()
43
+    var $ALLOWAPOP  = FALSE; //  Allow or disallow apop()
44 44
                                 //  This must be set to true
45 45
                                 //  manually
46 46
 
47 47
 	/**
48 48
 	 * PHP5 constructor.
49 49
 	 */
50
-    function __construct ( $server = '', $timeout = '' ) {
51
-        settype($this->BUFFER,"integer");
52
-        if( !empty($server) ) {
50
+    function __construct($server = '', $timeout = '') {
51
+        settype($this->BUFFER, "integer");
52
+        if ( ! empty($server)) {
53 53
             // Do not allow programs to alter MAILSERVER
54 54
             // if it is already specified. They can get around
55 55
             // this if they -really- want to, so don't count on it.
56
-            if(empty($this->MAILSERVER))
56
+            if (empty($this->MAILSERVER))
57 57
                 $this->MAILSERVER = $server;
58 58
         }
59
-        if(!empty($timeout)) {
60
-            settype($timeout,"integer");
59
+        if ( ! empty($timeout)) {
60
+            settype($timeout, "integer");
61 61
             $this->TIMEOUT = $timeout;
62
-            if (!ini_get('safe_mode'))
62
+            if ( ! ini_get('safe_mode'))
63 63
                 set_time_limit($timeout);
64 64
         }
65 65
         return true;
@@ -68,48 +68,48 @@  discard block
 block discarded – undo
68 68
 	/**
69 69
 	 * PHP4 constructor.
70 70
 	 */
71
-	public function POP3( $server = '', $timeout = '' ) {
72
-		self::__construct( $server, $timeout );
71
+	public function POP3($server = '', $timeout = '') {
72
+		self::__construct($server, $timeout);
73 73
 	}
74 74
 
75
-    function update_timer () {
76
-        if (!ini_get('safe_mode'))
75
+    function update_timer() {
76
+        if ( ! ini_get('safe_mode'))
77 77
             set_time_limit($this->TIMEOUT);
78 78
         return true;
79 79
     }
80 80
 
81
-    function connect ($server, $port = 110)  {
81
+    function connect($server, $port = 110) {
82 82
         //  Opens a socket to the specified server. Unless overridden,
83 83
         //  port defaults to 110. Returns true on success, false on fail
84 84
 
85 85
         // If MAILSERVER is set, override $server with it's value
86 86
 
87
-    if (!isset($port) || !$port) {$port = 110;}
88
-        if(!empty($this->MAILSERVER))
87
+    if ( ! isset($port) || ! $port) {$port = 110; }
88
+        if ( ! empty($this->MAILSERVER))
89 89
             $server = $this->MAILSERVER;
90 90
 
91
-        if(empty($server)){
92
-            $this->ERROR = "POP3 connect: " . _("No server specified");
91
+        if (empty($server)) {
92
+            $this->ERROR = "POP3 connect: "._("No server specified");
93 93
             unset($this->FP);
94 94
             return false;
95 95
         }
96 96
 
97 97
         $fp = @fsockopen("$server", $port, $errno, $errstr);
98 98
 
99
-        if(!$fp) {
100
-            $this->ERROR = "POP3 connect: " . _("Error ") . "[$errno] [$errstr]";
99
+        if ( ! $fp) {
100
+            $this->ERROR = "POP3 connect: "._("Error ")."[$errno] [$errstr]";
101 101
             unset($this->FP);
102 102
             return false;
103 103
         }
104 104
 
105
-        socket_set_blocking($fp,-1);
105
+        socket_set_blocking($fp, -1);
106 106
         $this->update_timer();
107
-        $reply = fgets($fp,$this->BUFFER);
107
+        $reply = fgets($fp, $this->BUFFER);
108 108
         $reply = $this->strip_clf($reply);
109
-        if($this->DEBUG)
110
-            error_log("POP3 SEND [connect: $server] GOT [$reply]",0);
111
-        if(!$this->is_ok($reply)) {
112
-            $this->ERROR = "POP3 connect: " . _("Error ") . "[$reply]";
109
+        if ($this->DEBUG)
110
+            error_log("POP3 SEND [connect: $server] GOT [$reply]", 0);
111
+        if ( ! $this->is_ok($reply)) {
112
+            $this->ERROR = "POP3 connect: "._("Error ")."[$reply]";
113 113
             unset($this->FP);
114 114
             return false;
115 115
         }
@@ -118,39 +118,39 @@  discard block
 block discarded – undo
118 118
         return true;
119 119
     }
120 120
 
121
-    function user ($user = "") {
121
+    function user($user = "") {
122 122
         // Sends the USER command, returns true or false
123 123
 
124
-        if( empty($user) ) {
125
-            $this->ERROR = "POP3 user: " . _("no login ID submitted");
124
+        if (empty($user)) {
125
+            $this->ERROR = "POP3 user: "._("no login ID submitted");
126 126
             return false;
127
-        } elseif(!isset($this->FP)) {
128
-            $this->ERROR = "POP3 user: " . _("connection not established");
127
+        } elseif ( ! isset($this->FP)) {
128
+            $this->ERROR = "POP3 user: "._("connection not established");
129 129
             return false;
130 130
         } else {
131 131
             $reply = $this->send_cmd("USER $user");
132
-            if(!$this->is_ok($reply)) {
133
-                $this->ERROR = "POP3 user: " . _("Error ") . "[$reply]";
132
+            if ( ! $this->is_ok($reply)) {
133
+                $this->ERROR = "POP3 user: "._("Error ")."[$reply]";
134 134
                 return false;
135 135
             } else
136 136
                 return true;
137 137
         }
138 138
     }
139 139
 
140
-    function pass ($pass = "")     {
140
+    function pass($pass = "") {
141 141
         // Sends the PASS command, returns # of msgs in mailbox,
142 142
         // returns false (undef) on Auth failure
143 143
 
144
-        if(empty($pass)) {
145
-            $this->ERROR = "POP3 pass: " . _("No password submitted");
144
+        if (empty($pass)) {
145
+            $this->ERROR = "POP3 pass: "._("No password submitted");
146 146
             return false;
147
-        } elseif(!isset($this->FP)) {
148
-            $this->ERROR = "POP3 pass: " . _("connection not established");
147
+        } elseif ( ! isset($this->FP)) {
148
+            $this->ERROR = "POP3 pass: "._("connection not established");
149 149
             return false;
150 150
         } else {
151 151
             $reply = $this->send_cmd("PASS $pass");
152
-            if(!$this->is_ok($reply)) {
153
-                $this->ERROR = "POP3 pass: " . _("Authentication failed") . " [$reply]";
152
+            if ( ! $this->is_ok($reply)) {
153
+                $this->ERROR = "POP3 pass: "._("Authentication failed")." [$reply]";
154 154
                 $this->quit();
155 155
                 return false;
156 156
             } else {
@@ -162,29 +162,29 @@  discard block
 block discarded – undo
162 162
         }
163 163
     }
164 164
 
165
-    function apop ($login,$pass) {
165
+    function apop($login, $pass) {
166 166
         //  Attempts an APOP login. If this fails, it'll
167 167
         //  try a standard login. YOUR SERVER MUST SUPPORT
168 168
         //  THE USE OF THE APOP COMMAND!
169 169
         //  (apop is optional per rfc1939)
170 170
 
171
-        if(!isset($this->FP)) {
172
-            $this->ERROR = "POP3 apop: " . _("No connection to server");
171
+        if ( ! isset($this->FP)) {
172
+            $this->ERROR = "POP3 apop: "._("No connection to server");
173 173
             return false;
174
-        } elseif(!$this->ALLOWAPOP) {
175
-            $retVal = $this->login($login,$pass);
174
+        } elseif ( ! $this->ALLOWAPOP) {
175
+            $retVal = $this->login($login, $pass);
176 176
             return $retVal;
177
-        } elseif(empty($login)) {
178
-            $this->ERROR = "POP3 apop: " . _("No login ID submitted");
177
+        } elseif (empty($login)) {
178
+            $this->ERROR = "POP3 apop: "._("No login ID submitted");
179 179
             return false;
180
-        } elseif(empty($pass)) {
181
-            $this->ERROR = "POP3 apop: " . _("No password submitted");
180
+        } elseif (empty($pass)) {
181
+            $this->ERROR = "POP3 apop: "._("No password submitted");
182 182
             return false;
183 183
         } else {
184 184
             $banner = $this->BANNER;
185
-            if( (!$banner) or (empty($banner)) ) {
186
-                $this->ERROR = "POP3 apop: " . _("No server banner") . ' - ' . _("abort");
187
-                $retVal = $this->login($login,$pass);
185
+            if (( ! $banner) or (empty($banner))) {
186
+                $this->ERROR = "POP3 apop: "._("No server banner").' - '._("abort");
187
+                $retVal = $this->login($login, $pass);
188 188
                 return $retVal;
189 189
             } else {
190 190
                 $AuthString = $banner;
@@ -192,9 +192,9 @@  discard block
 block discarded – undo
192 192
                 $APOPString = md5($AuthString);
193 193
                 $cmd = "APOP $login $APOPString";
194 194
                 $reply = $this->send_cmd($cmd);
195
-                if(!$this->is_ok($reply)) {
196
-                    $this->ERROR = "POP3 apop: " . _("apop authentication failed") . ' - ' . _("abort");
197
-                    $retVal = $this->login($login,$pass);
195
+                if ( ! $this->is_ok($reply)) {
196
+                    $this->ERROR = "POP3 apop: "._("apop authentication failed").' - '._("abort");
197
+                    $retVal = $this->login($login, $pass);
198 198
                     return $retVal;
199 199
                 } else {
200 200
                     //  Auth successful.
@@ -206,22 +206,22 @@  discard block
 block discarded – undo
206 206
         }
207 207
     }
208 208
 
209
-    function login ($login = "", $pass = "") {
209
+    function login($login = "", $pass = "") {
210 210
         // Sends both user and pass. Returns # of msgs in mailbox or
211 211
         // false on failure (or -1, if the error occurs while getting
212 212
         // the number of messages.)
213 213
 
214
-        if( !isset($this->FP) ) {
215
-            $this->ERROR = "POP3 login: " . _("No connection to server");
214
+        if ( ! isset($this->FP)) {
215
+            $this->ERROR = "POP3 login: "._("No connection to server");
216 216
             return false;
217 217
         } else {
218 218
             $fp = $this->FP;
219
-            if( !$this->user( $login ) ) {
219
+            if ( ! $this->user($login)) {
220 220
                 //  Preserve the error generated by user()
221 221
                 return false;
222 222
             } else {
223 223
                 $count = $this->pass($pass);
224
-                if( (!$count) || ($count == -1) ) {
224
+                if (( ! $count) || ($count == -1)) {
225 225
                     //  Preserve the error generated by last() and pass()
226 226
                     return false;
227 227
                 } else
@@ -230,14 +230,14 @@  discard block
 block discarded – undo
230 230
         }
231 231
     }
232 232
 
233
-    function top ($msgNum, $numLines = "0") {
233
+    function top($msgNum, $numLines = "0") {
234 234
         //  Gets the header and first $numLines of the msg body
235 235
         //  returns data in an array with each returned line being
236 236
         //  an array element. If $numLines is empty, returns
237 237
         //  only the header information, and none of the body.
238 238
 
239
-        if(!isset($this->FP)) {
240
-            $this->ERROR = "POP3 top: " . _("No connection to server");
239
+        if ( ! isset($this->FP)) {
240
+            $this->ERROR = "POP3 top: "._("No connection to server");
241 241
             return false;
242 242
         }
243 243
         $this->update_timer();
@@ -248,94 +248,94 @@  discard block
 block discarded – undo
248 248
         fwrite($fp, "TOP $msgNum $numLines\r\n");
249 249
         $reply = fgets($fp, $buffer);
250 250
         $reply = $this->strip_clf($reply);
251
-        if($this->DEBUG) {
252
-            @error_log("POP3 SEND [$cmd] GOT [$reply]",0);
251
+        if ($this->DEBUG) {
252
+            @error_log("POP3 SEND [$cmd] GOT [$reply]", 0);
253 253
         }
254
-        if(!$this->is_ok($reply))
254
+        if ( ! $this->is_ok($reply))
255 255
         {
256
-            $this->ERROR = "POP3 top: " . _("Error ") . "[$reply]";
256
+            $this->ERROR = "POP3 top: "._("Error ")."[$reply]";
257 257
             return false;
258 258
         }
259 259
 
260 260
         $count = 0;
261 261
         $MsgArray = array();
262 262
 
263
-        $line = fgets($fp,$buffer);
264
-        while ( !preg_match('/^\.\r\n/',$line))
263
+        $line = fgets($fp, $buffer);
264
+        while ( ! preg_match('/^\.\r\n/', $line))
265 265
         {
266 266
             $MsgArray[$count] = $line;
267 267
             $count++;
268
-            $line = fgets($fp,$buffer);
269
-            if(empty($line))    { break; }
268
+            $line = fgets($fp, $buffer);
269
+            if (empty($line)) { break; }
270 270
         }
271 271
 
272 272
         return $MsgArray;
273 273
     }
274 274
 
275
-    function pop_list ($msgNum = "") {
275
+    function pop_list($msgNum = "") {
276 276
         //  If called with an argument, returns that msgs' size in octets
277 277
         //  No argument returns an associative array of undeleted
278 278
         //  msg numbers and their sizes in octets
279 279
 
280
-        if(!isset($this->FP))
280
+        if ( ! isset($this->FP))
281 281
         {
282
-            $this->ERROR = "POP3 pop_list: " . _("No connection to server");
282
+            $this->ERROR = "POP3 pop_list: "._("No connection to server");
283 283
             return false;
284 284
         }
285 285
         $fp = $this->FP;
286 286
         $Total = $this->COUNT;
287
-        if( (!$Total) or ($Total == -1) )
287
+        if (( ! $Total) or ($Total == -1))
288 288
         {
289 289
             return false;
290 290
         }
291
-        if($Total == 0)
291
+        if ($Total == 0)
292 292
         {
293
-            return array("0","0");
293
+            return array("0", "0");
294 294
             // return -1;   // mailbox empty
295 295
         }
296 296
 
297 297
         $this->update_timer();
298 298
 
299
-        if(!empty($msgNum))
299
+        if ( ! empty($msgNum))
300 300
         {
301 301
             $cmd = "LIST $msgNum";
302
-            fwrite($fp,"$cmd\r\n");
303
-            $reply = fgets($fp,$this->BUFFER);
302
+            fwrite($fp, "$cmd\r\n");
303
+            $reply = fgets($fp, $this->BUFFER);
304 304
             $reply = $this->strip_clf($reply);
305
-            if($this->DEBUG) {
306
-                @error_log("POP3 SEND [$cmd] GOT [$reply]",0);
305
+            if ($this->DEBUG) {
306
+                @error_log("POP3 SEND [$cmd] GOT [$reply]", 0);
307 307
             }
308
-            if(!$this->is_ok($reply))
308
+            if ( ! $this->is_ok($reply))
309 309
             {
310
-                $this->ERROR = "POP3 pop_list: " . _("Error ") . "[$reply]";
310
+                $this->ERROR = "POP3 pop_list: "._("Error ")."[$reply]";
311 311
                 return false;
312 312
             }
313
-            list($junk,$num,$size) = preg_split('/\s+/',$reply);
313
+            list($junk, $num, $size) = preg_split('/\s+/', $reply);
314 314
             return $size;
315 315
         }
316 316
         $cmd = "LIST";
317 317
         $reply = $this->send_cmd($cmd);
318
-        if(!$this->is_ok($reply))
318
+        if ( ! $this->is_ok($reply))
319 319
         {
320 320
             $reply = $this->strip_clf($reply);
321
-            $this->ERROR = "POP3 pop_list: " . _("Error ") .  "[$reply]";
321
+            $this->ERROR = "POP3 pop_list: "._("Error ")."[$reply]";
322 322
             return false;
323 323
         }
324 324
         $MsgArray = array();
325 325
         $MsgArray[0] = $Total;
326
-        for($msgC=1;$msgC <= $Total; $msgC++)
326
+        for ($msgC = 1; $msgC <= $Total; $msgC++)
327 327
         {
328
-            if($msgC > $Total) { break; }
329
-            $line = fgets($fp,$this->BUFFER);
328
+            if ($msgC > $Total) { break; }
329
+            $line = fgets($fp, $this->BUFFER);
330 330
             $line = $this->strip_clf($line);
331
-            if(strpos($line, '.') === 0)
331
+            if (strpos($line, '.') === 0)
332 332
             {
333
-                $this->ERROR = "POP3 pop_list: " . _("Premature end of list");
333
+                $this->ERROR = "POP3 pop_list: "._("Premature end of list");
334 334
                 return false;
335 335
             }
336
-            list($thisMsg,$msgSize) = preg_split('/\s+/',$line);
337
-            settype($thisMsg,"integer");
338
-            if($thisMsg != $msgC)
336
+            list($thisMsg, $msgSize) = preg_split('/\s+/', $line);
337
+            settype($thisMsg, "integer");
338
+            if ($thisMsg != $msgC)
339 339
             {
340 340
                 $MsgArray[$msgC] = "deleted";
341 341
             }
@@ -347,13 +347,13 @@  discard block
 block discarded – undo
347 347
         return $MsgArray;
348 348
     }
349 349
 
350
-    function get ($msgNum) {
350
+    function get($msgNum) {
351 351
         //  Retrieve the specified msg number. Returns an array
352 352
         //  where each line of the msg is an array element.
353 353
 
354
-        if(!isset($this->FP))
354
+        if ( ! isset($this->FP))
355 355
         {
356
-            $this->ERROR = "POP3 get: " . _("No connection to server");
356
+            $this->ERROR = "POP3 get: "._("No connection to server");
357 357
             return false;
358 358
         }
359 359
 
@@ -364,83 +364,83 @@  discard block
 block discarded – undo
364 364
         $cmd = "RETR $msgNum";
365 365
         $reply = $this->send_cmd($cmd);
366 366
 
367
-        if(!$this->is_ok($reply))
367
+        if ( ! $this->is_ok($reply))
368 368
         {
369
-            $this->ERROR = "POP3 get: " . _("Error ") . "[$reply]";
369
+            $this->ERROR = "POP3 get: "._("Error ")."[$reply]";
370 370
             return false;
371 371
         }
372 372
 
373 373
         $count = 0;
374 374
         $MsgArray = array();
375 375
 
376
-        $line = fgets($fp,$buffer);
377
-        while ( !preg_match('/^\.\r\n/',$line))
376
+        $line = fgets($fp, $buffer);
377
+        while ( ! preg_match('/^\.\r\n/', $line))
378 378
         {
379
-            if ( $line{0} == '.' ) { $line = substr($line,1); }
379
+            if ($line{0} == '.') { $line = substr($line, 1); }
380 380
             $MsgArray[$count] = $line;
381 381
             $count++;
382
-            $line = fgets($fp,$buffer);
383
-            if(empty($line))    { break; }
382
+            $line = fgets($fp, $buffer);
383
+            if (empty($line)) { break; }
384 384
         }
385 385
         return $MsgArray;
386 386
     }
387 387
 
388
-    function last ( $type = "count" ) {
388
+    function last($type = "count") {
389 389
         //  Returns the highest msg number in the mailbox.
390 390
         //  returns -1 on error, 0+ on success, if type != count
391 391
         //  results in a popstat() call (2 element array returned)
392 392
 
393 393
         $last = -1;
394
-        if(!isset($this->FP))
394
+        if ( ! isset($this->FP))
395 395
         {
396
-            $this->ERROR = "POP3 last: " . _("No connection to server");
396
+            $this->ERROR = "POP3 last: "._("No connection to server");
397 397
             return $last;
398 398
         }
399 399
 
400 400
         $reply = $this->send_cmd("STAT");
401
-        if(!$this->is_ok($reply))
401
+        if ( ! $this->is_ok($reply))
402 402
         {
403
-            $this->ERROR = "POP3 last: " . _("Error ") . "[$reply]";
403
+            $this->ERROR = "POP3 last: "._("Error ")."[$reply]";
404 404
             return $last;
405 405
         }
406 406
 
407
-        $Vars = preg_split('/\s+/',$reply);
407
+        $Vars = preg_split('/\s+/', $reply);
408 408
         $count = $Vars[1];
409 409
         $size = $Vars[2];
410
-        settype($count,"integer");
411
-        settype($size,"integer");
412
-        if($type != "count")
410
+        settype($count, "integer");
411
+        settype($size, "integer");
412
+        if ($type != "count")
413 413
         {
414
-            return array($count,$size);
414
+            return array($count, $size);
415 415
         }
416 416
         return $count;
417 417
     }
418 418
 
419
-    function reset () {
419
+    function reset() {
420 420
         //  Resets the status of the remote server. This includes
421 421
         //  resetting the status of ALL msgs to not be deleted.
422 422
         //  This method automatically closes the connection to the server.
423 423
 
424
-        if(!isset($this->FP))
424
+        if ( ! isset($this->FP))
425 425
         {
426
-            $this->ERROR = "POP3 reset: " . _("No connection to server");
426
+            $this->ERROR = "POP3 reset: "._("No connection to server");
427 427
             return false;
428 428
         }
429 429
         $reply = $this->send_cmd("RSET");
430
-        if(!$this->is_ok($reply))
430
+        if ( ! $this->is_ok($reply))
431 431
         {
432 432
             //  The POP3 RSET command -never- gives a -ERR
433 433
             //  response - if it ever does, something truely
434 434
             //  wild is going on.
435 435
 
436
-            $this->ERROR = "POP3 reset: " . _("Error ") . "[$reply]";
437
-            @error_log("POP3 reset: ERROR [$reply]",0);
436
+            $this->ERROR = "POP3 reset: "._("Error ")."[$reply]";
437
+            @error_log("POP3 reset: ERROR [$reply]", 0);
438 438
         }
439 439
         $this->quit();
440 440
         return true;
441 441
     }
442 442
 
443
-    function send_cmd ( $cmd = "" )
443
+    function send_cmd($cmd = "")
444 444
     {
445 445
         //  Sends a user defined command string to the
446 446
         //  POP server and returns the results. Useful for
@@ -455,25 +455,25 @@  discard block
 block discarded – undo
455 455
         //  This method works best if $cmd responds with only
456 456
         //  one line of data.
457 457
 
458
-        if(!isset($this->FP))
458
+        if ( ! isset($this->FP))
459 459
         {
460
-            $this->ERROR = "POP3 send_cmd: " . _("No connection to server");
460
+            $this->ERROR = "POP3 send_cmd: "._("No connection to server");
461 461
             return false;
462 462
         }
463 463
 
464
-        if(empty($cmd))
464
+        if (empty($cmd))
465 465
         {
466
-            $this->ERROR = "POP3 send_cmd: " . _("Empty command string");
466
+            $this->ERROR = "POP3 send_cmd: "._("Empty command string");
467 467
             return "";
468 468
         }
469 469
 
470 470
         $fp = $this->FP;
471 471
         $buffer = $this->BUFFER;
472 472
         $this->update_timer();
473
-        fwrite($fp,"$cmd\r\n");
474
-        $reply = fgets($fp,$buffer);
473
+        fwrite($fp, "$cmd\r\n");
474
+        $reply = fgets($fp, $buffer);
475 475
         $reply = $this->strip_clf($reply);
476
-        if($this->DEBUG) { @error_log("POP3 SEND [$cmd] GOT [$reply]",0); }
476
+        if ($this->DEBUG) { @error_log("POP3 SEND [$cmd] GOT [$reply]", 0); }
477 477
         return $reply;
478 478
     }
479 479
 
@@ -481,61 +481,61 @@  discard block
 block discarded – undo
481 481
         //  Closes the connection to the POP3 server, deleting
482 482
         //  any msgs marked as deleted.
483 483
 
484
-        if(!isset($this->FP))
484
+        if ( ! isset($this->FP))
485 485
         {
486
-            $this->ERROR = "POP3 quit: " . _("connection does not exist");
486
+            $this->ERROR = "POP3 quit: "._("connection does not exist");
487 487
             return false;
488 488
         }
489 489
         $fp = $this->FP;
490 490
         $cmd = "QUIT";
491
-        fwrite($fp,"$cmd\r\n");
492
-        $reply = fgets($fp,$this->BUFFER);
491
+        fwrite($fp, "$cmd\r\n");
492
+        $reply = fgets($fp, $this->BUFFER);
493 493
         $reply = $this->strip_clf($reply);
494
-        if($this->DEBUG) { @error_log("POP3 SEND [$cmd] GOT [$reply]",0); }
494
+        if ($this->DEBUG) { @error_log("POP3 SEND [$cmd] GOT [$reply]", 0); }
495 495
         fclose($fp);
496 496
         unset($this->FP);
497 497
         return true;
498 498
     }
499 499
 
500
-    function popstat () {
500
+    function popstat() {
501 501
         //  Returns an array of 2 elements. The number of undeleted
502 502
         //  msgs in the mailbox, and the size of the mbox in octets.
503 503
 
504 504
         $PopArray = $this->last("array");
505 505
 
506
-        if($PopArray == -1) { return false; }
506
+        if ($PopArray == -1) { return false; }
507 507
 
508
-        if( (!$PopArray) or (empty($PopArray)) )
508
+        if (( ! $PopArray) or (empty($PopArray)))
509 509
         {
510 510
             return false;
511 511
         }
512 512
         return $PopArray;
513 513
     }
514 514
 
515
-    function uidl ($msgNum = "")
515
+    function uidl($msgNum = "")
516 516
     {
517 517
         //  Returns the UIDL of the msg specified. If called with
518 518
         //  no arguments, returns an associative array where each
519 519
         //  undeleted msg num is a key, and the msg's uidl is the element
520 520
         //  Array element 0 will contain the total number of msgs
521 521
 
522
-        if(!isset($this->FP)) {
523
-            $this->ERROR = "POP3 uidl: " . _("No connection to server");
522
+        if ( ! isset($this->FP)) {
523
+            $this->ERROR = "POP3 uidl: "._("No connection to server");
524 524
             return false;
525 525
         }
526 526
 
527 527
         $fp = $this->FP;
528 528
         $buffer = $this->BUFFER;
529 529
 
530
-        if(!empty($msgNum)) {
530
+        if ( ! empty($msgNum)) {
531 531
             $cmd = "UIDL $msgNum";
532 532
             $reply = $this->send_cmd($cmd);
533
-            if(!$this->is_ok($reply))
533
+            if ( ! $this->is_ok($reply))
534 534
             {
535
-                $this->ERROR = "POP3 uidl: " . _("Error ") . "[$reply]";
535
+                $this->ERROR = "POP3 uidl: "._("Error ")."[$reply]";
536 536
                 return false;
537 537
             }
538
-            list ($ok,$num,$myUidl) = preg_split('/\s+/',$reply);
538
+            list ($ok, $num, $myUidl) = preg_split('/\s+/', $reply);
539 539
             return $myUidl;
540 540
         } else {
541 541
             $this->update_timer();
@@ -552,20 +552,20 @@  discard block
 block discarded – undo
552 552
             fwrite($fp, "UIDL\r\n");
553 553
             $reply = fgets($fp, $buffer);
554 554
             $reply = $this->strip_clf($reply);
555
-            if($this->DEBUG) { @error_log("POP3 SEND [$cmd] GOT [$reply]",0); }
556
-            if(!$this->is_ok($reply))
555
+            if ($this->DEBUG) { @error_log("POP3 SEND [$cmd] GOT [$reply]", 0); }
556
+            if ( ! $this->is_ok($reply))
557 557
             {
558
-                $this->ERROR = "POP3 uidl: " . _("Error ") . "[$reply]";
558
+                $this->ERROR = "POP3 uidl: "._("Error ")."[$reply]";
559 559
                 return false;
560 560
             }
561 561
 
562 562
             $line = "";
563 563
             $count = 1;
564
-            $line = fgets($fp,$buffer);
565
-            while ( !preg_match('/^\.\r\n/',$line)) {
566
-                list ($msg,$msgUidl) = preg_split('/\s+/',$line);
564
+            $line = fgets($fp, $buffer);
565
+            while ( ! preg_match('/^\.\r\n/', $line)) {
566
+                list ($msg, $msgUidl) = preg_split('/\s+/', $line);
567 567
                 $msgUidl = $this->strip_clf($msgUidl);
568
-                if($count == $msg) {
568
+                if ($count == $msg) {
569 569
                     $UIDLArray[$msg] = $msgUidl;
570 570
                 }
571 571
                 else
@@ -573,30 +573,30 @@  discard block
 block discarded – undo
573 573
                     $UIDLArray[$count] = 'deleted';
574 574
                 }
575 575
                 $count++;
576
-                $line = fgets($fp,$buffer);
576
+                $line = fgets($fp, $buffer);
577 577
             }
578 578
         }
579 579
         return $UIDLArray;
580 580
     }
581 581
 
582
-    function delete ($msgNum = "") {
582
+    function delete($msgNum = "") {
583 583
         //  Flags a specified msg as deleted. The msg will not
584 584
         //  be deleted until a quit() method is called.
585 585
 
586
-        if(!isset($this->FP))
586
+        if ( ! isset($this->FP))
587 587
         {
588
-            $this->ERROR = "POP3 delete: " . _("No connection to server");
588
+            $this->ERROR = "POP3 delete: "._("No connection to server");
589 589
             return false;
590 590
         }
591
-        if(empty($msgNum))
591
+        if (empty($msgNum))
592 592
         {
593
-            $this->ERROR = "POP3 delete: " . _("No msg number submitted");
593
+            $this->ERROR = "POP3 delete: "._("No msg number submitted");
594 594
             return false;
595 595
         }
596 596
         $reply = $this->send_cmd("DELE $msgNum");
597
-        if(!$this->is_ok($reply))
597
+        if ( ! $this->is_ok($reply))
598 598
         {
599
-            $this->ERROR = "POP3 delete: " . _("Command failed ") . "[$reply]";
599
+            $this->ERROR = "POP3 delete: "._("Command failed ")."[$reply]";
600 600
             return false;
601 601
         }
602 602
         return true;
@@ -606,35 +606,35 @@  discard block
 block discarded – undo
606 606
 
607 607
     //  The following methods are internal to the class.
608 608
 
609
-    function is_ok ($cmd = "") {
609
+    function is_ok($cmd = "") {
610 610
         //  Return true or false on +OK or -ERR
611 611
 
612
-        if( empty($cmd) )
612
+        if (empty($cmd))
613 613
             return false;
614 614
         else
615
-            return( stripos($cmd, '+OK') !== false );
615
+            return(stripos($cmd, '+OK') !== false);
616 616
     }
617 617
 
618
-    function strip_clf ($text = "") {
618
+    function strip_clf($text = "") {
619 619
         // Strips \r\n from server responses
620 620
 
621
-        if(empty($text))
621
+        if (empty($text))
622 622
             return $text;
623 623
         else {
624
-            $stripped = str_replace(array("\r","\n"),'',$text);
624
+            $stripped = str_replace(array("\r", "\n"), '', $text);
625 625
             return $stripped;
626 626
         }
627 627
     }
628 628
 
629
-    function parse_banner ( $server_text ) {
629
+    function parse_banner($server_text) {
630 630
         $outside = true;
631 631
         $banner = "";
632 632
         $length = strlen($server_text);
633
-        for($count =0; $count < $length; $count++)
633
+        for ($count = 0; $count < $length; $count++)
634 634
         {
635
-            $digit = substr($server_text,$count,1);
636
-            if(!empty($digit))             {
637
-                if( (!$outside) && ($digit != '<') && ($digit != '>') )
635
+            $digit = substr($server_text, $count, 1);
636
+            if ( ! empty($digit)) {
637
+                if (( ! $outside) && ($digit != '<') && ($digit != '>'))
638 638
                 {
639 639
                     $banner .= $digit;
640 640
                 }
@@ -642,21 +642,21 @@  discard block
 block discarded – undo
642 642
                 {
643 643
                     $outside = false;
644 644
                 }
645
-                if($digit == '>')
645
+                if ($digit == '>')
646 646
                 {
647 647
                     $outside = true;
648 648
                 }
649 649
             }
650 650
         }
651
-        $banner = $this->strip_clf($banner);    // Just in case
651
+        $banner = $this->strip_clf($banner); // Just in case
652 652
         return "<$banner>";
653 653
     }
654 654
 
655 655
 }   // End class
656 656
 
657 657
 // For php4 compatibility
658
-if (!function_exists("stripos")) {
659
-    function stripos($haystack, $needle){
660
-        return strpos($haystack, stristr( $haystack, $needle ));
658
+if ( ! function_exists("stripos")) {
659
+    function stripos($haystack, $needle) {
660
+        return strpos($haystack, stristr($haystack, $needle));
661 661
     }
662 662
 }
Please login to merge, or discard this patch.
Braces   +31 added lines, -25 removed lines patch added patch discarded remove patch
@@ -53,14 +53,16 @@  discard block
 block discarded – undo
53 53
             // Do not allow programs to alter MAILSERVER
54 54
             // if it is already specified. They can get around
55 55
             // this if they -really- want to, so don't count on it.
56
-            if(empty($this->MAILSERVER))
57
-                $this->MAILSERVER = $server;
56
+            if(empty($this->MAILSERVER)) {
57
+                            $this->MAILSERVER = $server;
58
+            }
58 59
         }
59 60
         if(!empty($timeout)) {
60 61
             settype($timeout,"integer");
61 62
             $this->TIMEOUT = $timeout;
62
-            if (!ini_get('safe_mode'))
63
-                set_time_limit($timeout);
63
+            if (!ini_get('safe_mode')) {
64
+                            set_time_limit($timeout);
65
+            }
64 66
         }
65 67
         return true;
66 68
     }
@@ -73,8 +75,9 @@  discard block
 block discarded – undo
73 75
 	}
74 76
 
75 77
     function update_timer () {
76
-        if (!ini_get('safe_mode'))
77
-            set_time_limit($this->TIMEOUT);
78
+        if (!ini_get('safe_mode')) {
79
+                    set_time_limit($this->TIMEOUT);
80
+        }
78 81
         return true;
79 82
     }
80 83
 
@@ -85,8 +88,9 @@  discard block
 block discarded – undo
85 88
         // If MAILSERVER is set, override $server with it's value
86 89
 
87 90
     if (!isset($port) || !$port) {$port = 110;}
88
-        if(!empty($this->MAILSERVER))
89
-            $server = $this->MAILSERVER;
91
+        if(!empty($this->MAILSERVER)) {
92
+                    $server = $this->MAILSERVER;
93
+        }
90 94
 
91 95
         if(empty($server)){
92 96
             $this->ERROR = "POP3 connect: " . _("No server specified");
@@ -106,8 +110,9 @@  discard block
 block discarded – undo
106 110
         $this->update_timer();
107 111
         $reply = fgets($fp,$this->BUFFER);
108 112
         $reply = $this->strip_clf($reply);
109
-        if($this->DEBUG)
110
-            error_log("POP3 SEND [connect: $server] GOT [$reply]",0);
113
+        if($this->DEBUG) {
114
+                    error_log("POP3 SEND [connect: $server] GOT [$reply]",0);
115
+        }
111 116
         if(!$this->is_ok($reply)) {
112 117
             $this->ERROR = "POP3 connect: " . _("Error ") . "[$reply]";
113 118
             unset($this->FP);
@@ -132,8 +137,9 @@  discard block
 block discarded – undo
132 137
             if(!$this->is_ok($reply)) {
133 138
                 $this->ERROR = "POP3 user: " . _("Error ") . "[$reply]";
134 139
                 return false;
135
-            } else
136
-                return true;
140
+            } else {
141
+                            return true;
142
+            }
137 143
         }
138 144
     }
139 145
 
@@ -224,8 +230,9 @@  discard block
 block discarded – undo
224 230
                 if( (!$count) || ($count == -1) ) {
225 231
                     //  Preserve the error generated by last() and pass()
226 232
                     return false;
227
-                } else
228
-                    return $count;
233
+                } else {
234
+                                    return $count;
235
+                }
229 236
             }
230 237
         }
231 238
     }
@@ -338,8 +345,7 @@  discard block
 block discarded – undo
338 345
             if($thisMsg != $msgC)
339 346
             {
340 347
                 $MsgArray[$msgC] = "deleted";
341
-            }
342
-            else
348
+            } else
343 349
             {
344 350
                 $MsgArray[$msgC] = $msgSize;
345 351
             }
@@ -567,8 +573,7 @@  discard block
 block discarded – undo
567 573
                 $msgUidl = $this->strip_clf($msgUidl);
568 574
                 if($count == $msg) {
569 575
                     $UIDLArray[$msg] = $msgUidl;
570
-                }
571
-                else
576
+                } else
572 577
                 {
573 578
                     $UIDLArray[$count] = 'deleted';
574 579
                 }
@@ -609,18 +614,19 @@  discard block
 block discarded – undo
609 614
     function is_ok ($cmd = "") {
610 615
         //  Return true or false on +OK or -ERR
611 616
 
612
-        if( empty($cmd) )
613
-            return false;
614
-        else
615
-            return( stripos($cmd, '+OK') !== false );
617
+        if( empty($cmd) ) {
618
+                    return false;
619
+        } else {
620
+                    return( stripos($cmd, '+OK') !== false );
621
+        }
616 622
     }
617 623
 
618 624
     function strip_clf ($text = "") {
619 625
         // Strips \r\n from server responses
620 626
 
621
-        if(empty($text))
622
-            return $text;
623
-        else {
627
+        if(empty($text)) {
628
+                    return $text;
629
+        } else {
624 630
             $stripped = str_replace(array("\r","\n"),'',$text);
625 631
             return $stripped;
626 632
         }
Please login to merge, or discard this patch.
Indentation   +617 added lines, -617 removed lines patch added patch discarded remove patch
@@ -17,53 +17,53 @@  discard block
 block discarded – undo
17 17
  */
18 18
 
19 19
 class POP3 {
20
-    var $ERROR      = '';       //  Error string.
20
+	var $ERROR      = '';       //  Error string.
21 21
 
22
-    var $TIMEOUT    = 60;       //  Default timeout before giving up on a
23
-                                //  network operation.
22
+	var $TIMEOUT    = 60;       //  Default timeout before giving up on a
23
+								//  network operation.
24 24
 
25
-    var $COUNT      = -1;       //  Mailbox msg count
25
+	var $COUNT      = -1;       //  Mailbox msg count
26 26
 
27
-    var $BUFFER     = 512;      //  Socket buffer for socket fgets() calls.
28
-                                //  Per RFC 1939 the returned line a POP3
29
-                                //  server can send is 512 bytes.
27
+	var $BUFFER     = 512;      //  Socket buffer for socket fgets() calls.
28
+								//  Per RFC 1939 the returned line a POP3
29
+								//  server can send is 512 bytes.
30 30
 
31
-    var $FP         = '';       //  The connection to the server's
32
-                                //  file descriptor
31
+	var $FP         = '';       //  The connection to the server's
32
+								//  file descriptor
33 33
 
34
-    var $MAILSERVER = '';       // Set this to hard code the server name
34
+	var $MAILSERVER = '';       // Set this to hard code the server name
35 35
 
36
-    var $DEBUG      = FALSE;    // set to true to echo pop3
37
-                                // commands and responses to error_log
38
-                                // this WILL log passwords!
36
+	var $DEBUG      = FALSE;    // set to true to echo pop3
37
+								// commands and responses to error_log
38
+								// this WILL log passwords!
39 39
 
40
-    var $BANNER     = '';       //  Holds the banner returned by the
41
-                                //  pop server - used for apop()
40
+	var $BANNER     = '';       //  Holds the banner returned by the
41
+								//  pop server - used for apop()
42 42
 
43
-    var $ALLOWAPOP  = FALSE;    //  Allow or disallow apop()
44
-                                //  This must be set to true
45
-                                //  manually
43
+	var $ALLOWAPOP  = FALSE;    //  Allow or disallow apop()
44
+								//  This must be set to true
45
+								//  manually
46 46
 
47 47
 	/**
48 48
 	 * PHP5 constructor.
49 49
 	 */
50
-    function __construct ( $server = '', $timeout = '' ) {
51
-        settype($this->BUFFER,"integer");
52
-        if( !empty($server) ) {
53
-            // Do not allow programs to alter MAILSERVER
54
-            // if it is already specified. They can get around
55
-            // this if they -really- want to, so don't count on it.
56
-            if(empty($this->MAILSERVER))
57
-                $this->MAILSERVER = $server;
58
-        }
59
-        if(!empty($timeout)) {
60
-            settype($timeout,"integer");
61
-            $this->TIMEOUT = $timeout;
62
-            if (!ini_get('safe_mode'))
63
-                set_time_limit($timeout);
64
-        }
65
-        return true;
66
-    }
50
+	function __construct ( $server = '', $timeout = '' ) {
51
+		settype($this->BUFFER,"integer");
52
+		if( !empty($server) ) {
53
+			// Do not allow programs to alter MAILSERVER
54
+			// if it is already specified. They can get around
55
+			// this if they -really- want to, so don't count on it.
56
+			if(empty($this->MAILSERVER))
57
+				$this->MAILSERVER = $server;
58
+		}
59
+		if(!empty($timeout)) {
60
+			settype($timeout,"integer");
61
+			$this->TIMEOUT = $timeout;
62
+			if (!ini_get('safe_mode'))
63
+				set_time_limit($timeout);
64
+		}
65
+		return true;
66
+	}
67 67
 
68 68
 	/**
69 69
 	 * PHP4 constructor.
@@ -72,591 +72,591 @@  discard block
 block discarded – undo
72 72
 		self::__construct( $server, $timeout );
73 73
 	}
74 74
 
75
-    function update_timer () {
76
-        if (!ini_get('safe_mode'))
77
-            set_time_limit($this->TIMEOUT);
78
-        return true;
79
-    }
80
-
81
-    function connect ($server, $port = 110)  {
82
-        //  Opens a socket to the specified server. Unless overridden,
83
-        //  port defaults to 110. Returns true on success, false on fail
84
-
85
-        // If MAILSERVER is set, override $server with its value.
86
-
87
-    if (!isset($port) || !$port) {$port = 110;}
88
-        if(!empty($this->MAILSERVER))
89
-            $server = $this->MAILSERVER;
90
-
91
-        if(empty($server)){
92
-            $this->ERROR = "POP3 connect: " . _("No server specified");
93
-            unset($this->FP);
94
-            return false;
95
-        }
96
-
97
-        $fp = @fsockopen("$server", $port, $errno, $errstr);
98
-
99
-        if(!$fp) {
100
-            $this->ERROR = "POP3 connect: " . _("Error ") . "[$errno] [$errstr]";
101
-            unset($this->FP);
102
-            return false;
103
-        }
104
-
105
-        socket_set_blocking($fp,-1);
106
-        $this->update_timer();
107
-        $reply = fgets($fp,$this->BUFFER);
108
-        $reply = $this->strip_clf($reply);
109
-        if($this->DEBUG)
110
-            error_log("POP3 SEND [connect: $server] GOT [$reply]",0);
111
-        if(!$this->is_ok($reply)) {
112
-            $this->ERROR = "POP3 connect: " . _("Error ") . "[$reply]";
113
-            unset($this->FP);
114
-            return false;
115
-        }
116
-        $this->FP = $fp;
117
-        $this->BANNER = $this->parse_banner($reply);
118
-        return true;
119
-    }
120
-
121
-    function user ($user = "") {
122
-        // Sends the USER command, returns true or false
123
-
124
-        if( empty($user) ) {
125
-            $this->ERROR = "POP3 user: " . _("no login ID submitted");
126
-            return false;
127
-        } elseif(!isset($this->FP)) {
128
-            $this->ERROR = "POP3 user: " . _("connection not established");
129
-            return false;
130
-        } else {
131
-            $reply = $this->send_cmd("USER $user");
132
-            if(!$this->is_ok($reply)) {
133
-                $this->ERROR = "POP3 user: " . _("Error ") . "[$reply]";
134
-                return false;
135
-            } else
136
-                return true;
137
-        }
138
-    }
139
-
140
-    function pass ($pass = "")     {
141
-        // Sends the PASS command, returns # of msgs in mailbox,
142
-        // returns false (undef) on Auth failure
143
-
144
-        if(empty($pass)) {
145
-            $this->ERROR = "POP3 pass: " . _("No password submitted");
146
-            return false;
147
-        } elseif(!isset($this->FP)) {
148
-            $this->ERROR = "POP3 pass: " . _("connection not established");
149
-            return false;
150
-        } else {
151
-            $reply = $this->send_cmd("PASS $pass");
152
-            if(!$this->is_ok($reply)) {
153
-                $this->ERROR = "POP3 pass: " . _("Authentication failed") . " [$reply]";
154
-                $this->quit();
155
-                return false;
156
-            } else {
157
-                //  Auth successful.
158
-                $count = $this->last("count");
159
-                $this->COUNT = $count;
160
-                return $count;
161
-            }
162
-        }
163
-    }
164
-
165
-    function apop ($login,$pass) {
166
-        //  Attempts an APOP login. If this fails, it'll
167
-        //  try a standard login. YOUR SERVER MUST SUPPORT
168
-        //  THE USE OF THE APOP COMMAND!
169
-        //  (apop is optional per rfc1939)
170
-
171
-        if(!isset($this->FP)) {
172
-            $this->ERROR = "POP3 apop: " . _("No connection to server");
173
-            return false;
174
-        } elseif(!$this->ALLOWAPOP) {
175
-            $retVal = $this->login($login,$pass);
176
-            return $retVal;
177
-        } elseif(empty($login)) {
178
-            $this->ERROR = "POP3 apop: " . _("No login ID submitted");
179
-            return false;
180
-        } elseif(empty($pass)) {
181
-            $this->ERROR = "POP3 apop: " . _("No password submitted");
182
-            return false;
183
-        } else {
184
-            $banner = $this->BANNER;
185
-            if( (!$banner) or (empty($banner)) ) {
186
-                $this->ERROR = "POP3 apop: " . _("No server banner") . ' - ' . _("abort");
187
-                $retVal = $this->login($login,$pass);
188
-                return $retVal;
189
-            } else {
190
-                $AuthString = $banner;
191
-                $AuthString .= $pass;
192
-                $APOPString = md5($AuthString);
193
-                $cmd = "APOP $login $APOPString";
194
-                $reply = $this->send_cmd($cmd);
195
-                if(!$this->is_ok($reply)) {
196
-                    $this->ERROR = "POP3 apop: " . _("apop authentication failed") . ' - ' . _("abort");
197
-                    $retVal = $this->login($login,$pass);
198
-                    return $retVal;
199
-                } else {
200
-                    //  Auth successful.
201
-                    $count = $this->last("count");
202
-                    $this->COUNT = $count;
203
-                    return $count;
204
-                }
205
-            }
206
-        }
207
-    }
208
-
209
-    function login ($login = "", $pass = "") {
210
-        // Sends both user and pass. Returns # of msgs in mailbox or
211
-        // false on failure (or -1, if the error occurs while getting
212
-        // the number of messages.)
213
-
214
-        if( !isset($this->FP) ) {
215
-            $this->ERROR = "POP3 login: " . _("No connection to server");
216
-            return false;
217
-        } else {
218
-            $fp = $this->FP;
219
-            if( !$this->user( $login ) ) {
220
-                //  Preserve the error generated by user()
221
-                return false;
222
-            } else {
223
-                $count = $this->pass($pass);
224
-                if( (!$count) || ($count == -1) ) {
225
-                    //  Preserve the error generated by last() and pass()
226
-                    return false;
227
-                } else
228
-                    return $count;
229
-            }
230
-        }
231
-    }
232
-
233
-    function top ($msgNum, $numLines = "0") {
234
-        //  Gets the header and first $numLines of the msg body
235
-        //  returns data in an array with each returned line being
236
-        //  an array element. If $numLines is empty, returns
237
-        //  only the header information, and none of the body.
238
-
239
-        if(!isset($this->FP)) {
240
-            $this->ERROR = "POP3 top: " . _("No connection to server");
241
-            return false;
242
-        }
243
-        $this->update_timer();
244
-
245
-        $fp = $this->FP;
246
-        $buffer = $this->BUFFER;
247
-        $cmd = "TOP $msgNum $numLines";
248
-        fwrite($fp, "TOP $msgNum $numLines\r\n");
249
-        $reply = fgets($fp, $buffer);
250
-        $reply = $this->strip_clf($reply);
251
-        if($this->DEBUG) {
252
-            @error_log("POP3 SEND [$cmd] GOT [$reply]",0);
253
-        }
254
-        if(!$this->is_ok($reply))
255
-        {
256
-            $this->ERROR = "POP3 top: " . _("Error ") . "[$reply]";
257
-            return false;
258
-        }
259
-
260
-        $count = 0;
261
-        $MsgArray = array();
262
-
263
-        $line = fgets($fp,$buffer);
264
-        while ( !preg_match('/^\.\r\n/',$line))
265
-        {
266
-            $MsgArray[$count] = $line;
267
-            $count++;
268
-            $line = fgets($fp,$buffer);
269
-            if(empty($line))    { break; }
270
-        }
271
-
272
-        return $MsgArray;
273
-    }
274
-
275
-    function pop_list ($msgNum = "") {
276
-        //  If called with an argument, returns that msgs' size in octets
277
-        //  No argument returns an associative array of undeleted
278
-        //  msg numbers and their sizes in octets
279
-
280
-        if(!isset($this->FP))
281
-        {
282
-            $this->ERROR = "POP3 pop_list: " . _("No connection to server");
283
-            return false;
284
-        }
285
-        $fp = $this->FP;
286
-        $Total = $this->COUNT;
287
-        if( (!$Total) or ($Total == -1) )
288
-        {
289
-            return false;
290
-        }
291
-        if($Total == 0)
292
-        {
293
-            return array("0","0");
294
-            // return -1;   // mailbox empty
295
-        }
296
-
297
-        $this->update_timer();
298
-
299
-        if(!empty($msgNum))
300
-        {
301
-            $cmd = "LIST $msgNum";
302
-            fwrite($fp,"$cmd\r\n");
303
-            $reply = fgets($fp,$this->BUFFER);
304
-            $reply = $this->strip_clf($reply);
305
-            if($this->DEBUG) {
306
-                @error_log("POP3 SEND [$cmd] GOT [$reply]",0);
307
-            }
308
-            if(!$this->is_ok($reply))
309
-            {
310
-                $this->ERROR = "POP3 pop_list: " . _("Error ") . "[$reply]";
311
-                return false;
312
-            }
313
-            list($junk,$num,$size) = preg_split('/\s+/',$reply);
314
-            return $size;
315
-        }
316
-        $cmd = "LIST";
317
-        $reply = $this->send_cmd($cmd);
318
-        if(!$this->is_ok($reply))
319
-        {
320
-            $reply = $this->strip_clf($reply);
321
-            $this->ERROR = "POP3 pop_list: " . _("Error ") .  "[$reply]";
322
-            return false;
323
-        }
324
-        $MsgArray = array();
325
-        $MsgArray[0] = $Total;
326
-        for($msgC=1;$msgC <= $Total; $msgC++)
327
-        {
328
-            if($msgC > $Total) { break; }
329
-            $line = fgets($fp,$this->BUFFER);
330
-            $line = $this->strip_clf($line);
331
-            if(strpos($line, '.') === 0)
332
-            {
333
-                $this->ERROR = "POP3 pop_list: " . _("Premature end of list");
334
-                return false;
335
-            }
336
-            list($thisMsg,$msgSize) = preg_split('/\s+/',$line);
337
-            settype($thisMsg,"integer");
338
-            if($thisMsg != $msgC)
339
-            {
340
-                $MsgArray[$msgC] = "deleted";
341
-            }
342
-            else
343
-            {
344
-                $MsgArray[$msgC] = $msgSize;
345
-            }
346
-        }
347
-        return $MsgArray;
348
-    }
349
-
350
-    function get ($msgNum) {
351
-        //  Retrieve the specified msg number. Returns an array
352
-        //  where each line of the msg is an array element.
353
-
354
-        if(!isset($this->FP))
355
-        {
356
-            $this->ERROR = "POP3 get: " . _("No connection to server");
357
-            return false;
358
-        }
359
-
360
-        $this->update_timer();
361
-
362
-        $fp = $this->FP;
363
-        $buffer = $this->BUFFER;
364
-        $cmd = "RETR $msgNum";
365
-        $reply = $this->send_cmd($cmd);
366
-
367
-        if(!$this->is_ok($reply))
368
-        {
369
-            $this->ERROR = "POP3 get: " . _("Error ") . "[$reply]";
370
-            return false;
371
-        }
372
-
373
-        $count = 0;
374
-        $MsgArray = array();
375
-
376
-        $line = fgets($fp,$buffer);
377
-        while ( !preg_match('/^\.\r\n/',$line))
378
-        {
379
-            if ( $line{0} == '.' ) { $line = substr($line,1); }
380
-            $MsgArray[$count] = $line;
381
-            $count++;
382
-            $line = fgets($fp,$buffer);
383
-            if(empty($line))    { break; }
384
-        }
385
-        return $MsgArray;
386
-    }
387
-
388
-    function last ( $type = "count" ) {
389
-        //  Returns the highest msg number in the mailbox.
390
-        //  returns -1 on error, 0+ on success, if type != count
391
-        //  results in a popstat() call (2 element array returned)
392
-
393
-        $last = -1;
394
-        if(!isset($this->FP))
395
-        {
396
-            $this->ERROR = "POP3 last: " . _("No connection to server");
397
-            return $last;
398
-        }
399
-
400
-        $reply = $this->send_cmd("STAT");
401
-        if(!$this->is_ok($reply))
402
-        {
403
-            $this->ERROR = "POP3 last: " . _("Error ") . "[$reply]";
404
-            return $last;
405
-        }
406
-
407
-        $Vars = preg_split('/\s+/',$reply);
408
-        $count = $Vars[1];
409
-        $size = $Vars[2];
410
-        settype($count,"integer");
411
-        settype($size,"integer");
412
-        if($type != "count")
413
-        {
414
-            return array($count,$size);
415
-        }
416
-        return $count;
417
-    }
418
-
419
-    function reset () {
420
-        //  Resets the status of the remote server. This includes
421
-        //  resetting the status of ALL msgs to not be deleted.
422
-        //  This method automatically closes the connection to the server.
423
-
424
-        if(!isset($this->FP))
425
-        {
426
-            $this->ERROR = "POP3 reset: " . _("No connection to server");
427
-            return false;
428
-        }
429
-        $reply = $this->send_cmd("RSET");
430
-        if(!$this->is_ok($reply))
431
-        {
432
-            //  The POP3 RSET command -never- gives a -ERR
433
-            //  response - if it ever does, something truly
434
-            //  wild is going on.
435
-
436
-            $this->ERROR = "POP3 reset: " . _("Error ") . "[$reply]";
437
-            @error_log("POP3 reset: ERROR [$reply]",0);
438
-        }
439
-        $this->quit();
440
-        return true;
441
-    }
442
-
443
-    function send_cmd ( $cmd = "" )
444
-    {
445
-        //  Sends a user defined command string to the
446
-        //  POP server and returns the results. Useful for
447
-        //  non-compliant or custom POP servers.
448
-        //  Do NOT includ the \r\n as part of your command
449
-        //  string - it will be appended automatically.
450
-
451
-        //  The return value is a standard fgets() call, which
452
-        //  will read up to $this->BUFFER bytes of data, until it
453
-        //  encounters a new line, or EOF, whichever happens first.
454
-
455
-        //  This method works best if $cmd responds with only
456
-        //  one line of data.
457
-
458
-        if(!isset($this->FP))
459
-        {
460
-            $this->ERROR = "POP3 send_cmd: " . _("No connection to server");
461
-            return false;
462
-        }
463
-
464
-        if(empty($cmd))
465
-        {
466
-            $this->ERROR = "POP3 send_cmd: " . _("Empty command string");
467
-            return "";
468
-        }
469
-
470
-        $fp = $this->FP;
471
-        $buffer = $this->BUFFER;
472
-        $this->update_timer();
473
-        fwrite($fp,"$cmd\r\n");
474
-        $reply = fgets($fp,$buffer);
475
-        $reply = $this->strip_clf($reply);
476
-        if($this->DEBUG) { @error_log("POP3 SEND [$cmd] GOT [$reply]",0); }
477
-        return $reply;
478
-    }
479
-
480
-    function quit() {
481
-        //  Closes the connection to the POP3 server, deleting
482
-        //  any msgs marked as deleted.
483
-
484
-        if(!isset($this->FP))
485
-        {
486
-            $this->ERROR = "POP3 quit: " . _("connection does not exist");
487
-            return false;
488
-        }
489
-        $fp = $this->FP;
490
-        $cmd = "QUIT";
491
-        fwrite($fp,"$cmd\r\n");
492
-        $reply = fgets($fp,$this->BUFFER);
493
-        $reply = $this->strip_clf($reply);
494
-        if($this->DEBUG) { @error_log("POP3 SEND [$cmd] GOT [$reply]",0); }
495
-        fclose($fp);
496
-        unset($this->FP);
497
-        return true;
498
-    }
499
-
500
-    function popstat () {
501
-        //  Returns an array of 2 elements. The number of undeleted
502
-        //  msgs in the mailbox, and the size of the mbox in octets.
503
-
504
-        $PopArray = $this->last("array");
505
-
506
-        if($PopArray == -1) { return false; }
507
-
508
-        if( (!$PopArray) or (empty($PopArray)) )
509
-        {
510
-            return false;
511
-        }
512
-        return $PopArray;
513
-    }
514
-
515
-    function uidl ($msgNum = "")
516
-    {
517
-        //  Returns the UIDL of the msg specified. If called with
518
-        //  no arguments, returns an associative array where each
519
-        //  undeleted msg num is a key, and the msg's uidl is the element
520
-        //  Array element 0 will contain the total number of msgs
521
-
522
-        if(!isset($this->FP)) {
523
-            $this->ERROR = "POP3 uidl: " . _("No connection to server");
524
-            return false;
525
-        }
526
-
527
-        $fp = $this->FP;
528
-        $buffer = $this->BUFFER;
529
-
530
-        if(!empty($msgNum)) {
531
-            $cmd = "UIDL $msgNum";
532
-            $reply = $this->send_cmd($cmd);
533
-            if(!$this->is_ok($reply))
534
-            {
535
-                $this->ERROR = "POP3 uidl: " . _("Error ") . "[$reply]";
536
-                return false;
537
-            }
538
-            list ($ok,$num,$myUidl) = preg_split('/\s+/',$reply);
539
-            return $myUidl;
540
-        } else {
541
-            $this->update_timer();
542
-
543
-            $UIDLArray = array();
544
-            $Total = $this->COUNT;
545
-            $UIDLArray[0] = $Total;
546
-
547
-            if ($Total < 1)
548
-            {
549
-                return $UIDLArray;
550
-            }
551
-            $cmd = "UIDL";
552
-            fwrite($fp, "UIDL\r\n");
553
-            $reply = fgets($fp, $buffer);
554
-            $reply = $this->strip_clf($reply);
555
-            if($this->DEBUG) { @error_log("POP3 SEND [$cmd] GOT [$reply]",0); }
556
-            if(!$this->is_ok($reply))
557
-            {
558
-                $this->ERROR = "POP3 uidl: " . _("Error ") . "[$reply]";
559
-                return false;
560
-            }
561
-
562
-            $line = "";
563
-            $count = 1;
564
-            $line = fgets($fp,$buffer);
565
-            while ( !preg_match('/^\.\r\n/',$line)) {
566
-                list ($msg,$msgUidl) = preg_split('/\s+/',$line);
567
-                $msgUidl = $this->strip_clf($msgUidl);
568
-                if($count == $msg) {
569
-                    $UIDLArray[$msg] = $msgUidl;
570
-                }
571
-                else
572
-                {
573
-                    $UIDLArray[$count] = 'deleted';
574
-                }
575
-                $count++;
576
-                $line = fgets($fp,$buffer);
577
-            }
578
-        }
579
-        return $UIDLArray;
580
-    }
581
-
582
-    function delete ($msgNum = "") {
583
-        //  Flags a specified msg as deleted. The msg will not
584
-        //  be deleted until a quit() method is called.
585
-
586
-        if(!isset($this->FP))
587
-        {
588
-            $this->ERROR = "POP3 delete: " . _("No connection to server");
589
-            return false;
590
-        }
591
-        if(empty($msgNum))
592
-        {
593
-            $this->ERROR = "POP3 delete: " . _("No msg number submitted");
594
-            return false;
595
-        }
596
-        $reply = $this->send_cmd("DELE $msgNum");
597
-        if(!$this->is_ok($reply))
598
-        {
599
-            $this->ERROR = "POP3 delete: " . _("Command failed ") . "[$reply]";
600
-            return false;
601
-        }
602
-        return true;
603
-    }
604
-
605
-    //  *********************************************************
606
-
607
-    //  The following methods are internal to the class.
608
-
609
-    function is_ok ($cmd = "") {
610
-        //  Return true or false on +OK or -ERR
611
-
612
-        if( empty($cmd) )
613
-            return false;
614
-        else
615
-            return( stripos($cmd, '+OK') !== false );
616
-    }
617
-
618
-    function strip_clf ($text = "") {
619
-        // Strips \r\n from server responses
620
-
621
-        if(empty($text))
622
-            return $text;
623
-        else {
624
-            $stripped = str_replace(array("\r","\n"),'',$text);
625
-            return $stripped;
626
-        }
627
-    }
628
-
629
-    function parse_banner ( $server_text ) {
630
-        $outside = true;
631
-        $banner = "";
632
-        $length = strlen($server_text);
633
-        for($count =0; $count < $length; $count++)
634
-        {
635
-            $digit = substr($server_text,$count,1);
636
-            if(!empty($digit))             {
637
-                if( (!$outside) && ($digit != '<') && ($digit != '>') )
638
-                {
639
-                    $banner .= $digit;
640
-                }
641
-                if ($digit == '<')
642
-                {
643
-                    $outside = false;
644
-                }
645
-                if($digit == '>')
646
-                {
647
-                    $outside = true;
648
-                }
649
-            }
650
-        }
651
-        $banner = $this->strip_clf($banner);    // Just in case
652
-        return "<$banner>";
653
-    }
75
+	function update_timer () {
76
+		if (!ini_get('safe_mode'))
77
+			set_time_limit($this->TIMEOUT);
78
+		return true;
79
+	}
80
+
81
+	function connect ($server, $port = 110)  {
82
+		//  Opens a socket to the specified server. Unless overridden,
83
+		//  port defaults to 110. Returns true on success, false on fail
84
+
85
+		// If MAILSERVER is set, override $server with its value.
86
+
87
+	if (!isset($port) || !$port) {$port = 110;}
88
+		if(!empty($this->MAILSERVER))
89
+			$server = $this->MAILSERVER;
90
+
91
+		if(empty($server)){
92
+			$this->ERROR = "POP3 connect: " . _("No server specified");
93
+			unset($this->FP);
94
+			return false;
95
+		}
96
+
97
+		$fp = @fsockopen("$server", $port, $errno, $errstr);
98
+
99
+		if(!$fp) {
100
+			$this->ERROR = "POP3 connect: " . _("Error ") . "[$errno] [$errstr]";
101
+			unset($this->FP);
102
+			return false;
103
+		}
104
+
105
+		socket_set_blocking($fp,-1);
106
+		$this->update_timer();
107
+		$reply = fgets($fp,$this->BUFFER);
108
+		$reply = $this->strip_clf($reply);
109
+		if($this->DEBUG)
110
+			error_log("POP3 SEND [connect: $server] GOT [$reply]",0);
111
+		if(!$this->is_ok($reply)) {
112
+			$this->ERROR = "POP3 connect: " . _("Error ") . "[$reply]";
113
+			unset($this->FP);
114
+			return false;
115
+		}
116
+		$this->FP = $fp;
117
+		$this->BANNER = $this->parse_banner($reply);
118
+		return true;
119
+	}
120
+
121
+	function user ($user = "") {
122
+		// Sends the USER command, returns true or false
123
+
124
+		if( empty($user) ) {
125
+			$this->ERROR = "POP3 user: " . _("no login ID submitted");
126
+			return false;
127
+		} elseif(!isset($this->FP)) {
128
+			$this->ERROR = "POP3 user: " . _("connection not established");
129
+			return false;
130
+		} else {
131
+			$reply = $this->send_cmd("USER $user");
132
+			if(!$this->is_ok($reply)) {
133
+				$this->ERROR = "POP3 user: " . _("Error ") . "[$reply]";
134
+				return false;
135
+			} else
136
+				return true;
137
+		}
138
+	}
139
+
140
+	function pass ($pass = "")     {
141
+		// Sends the PASS command, returns # of msgs in mailbox,
142
+		// returns false (undef) on Auth failure
143
+
144
+		if(empty($pass)) {
145
+			$this->ERROR = "POP3 pass: " . _("No password submitted");
146
+			return false;
147
+		} elseif(!isset($this->FP)) {
148
+			$this->ERROR = "POP3 pass: " . _("connection not established");
149
+			return false;
150
+		} else {
151
+			$reply = $this->send_cmd("PASS $pass");
152
+			if(!$this->is_ok($reply)) {
153
+				$this->ERROR = "POP3 pass: " . _("Authentication failed") . " [$reply]";
154
+				$this->quit();
155
+				return false;
156
+			} else {
157
+				//  Auth successful.
158
+				$count = $this->last("count");
159
+				$this->COUNT = $count;
160
+				return $count;
161
+			}
162
+		}
163
+	}
164
+
165
+	function apop ($login,$pass) {
166
+		//  Attempts an APOP login. If this fails, it'll
167
+		//  try a standard login. YOUR SERVER MUST SUPPORT
168
+		//  THE USE OF THE APOP COMMAND!
169
+		//  (apop is optional per rfc1939)
170
+
171
+		if(!isset($this->FP)) {
172
+			$this->ERROR = "POP3 apop: " . _("No connection to server");
173
+			return false;
174
+		} elseif(!$this->ALLOWAPOP) {
175
+			$retVal = $this->login($login,$pass);
176
+			return $retVal;
177
+		} elseif(empty($login)) {
178
+			$this->ERROR = "POP3 apop: " . _("No login ID submitted");
179
+			return false;
180
+		} elseif(empty($pass)) {
181
+			$this->ERROR = "POP3 apop: " . _("No password submitted");
182
+			return false;
183
+		} else {
184
+			$banner = $this->BANNER;
185
+			if( (!$banner) or (empty($banner)) ) {
186
+				$this->ERROR = "POP3 apop: " . _("No server banner") . ' - ' . _("abort");
187
+				$retVal = $this->login($login,$pass);
188
+				return $retVal;
189
+			} else {
190
+				$AuthString = $banner;
191
+				$AuthString .= $pass;
192
+				$APOPString = md5($AuthString);
193
+				$cmd = "APOP $login $APOPString";
194
+				$reply = $this->send_cmd($cmd);
195
+				if(!$this->is_ok($reply)) {
196
+					$this->ERROR = "POP3 apop: " . _("apop authentication failed") . ' - ' . _("abort");
197
+					$retVal = $this->login($login,$pass);
198
+					return $retVal;
199
+				} else {
200
+					//  Auth successful.
201
+					$count = $this->last("count");
202
+					$this->COUNT = $count;
203
+					return $count;
204
+				}
205
+			}
206
+		}
207
+	}
208
+
209
+	function login ($login = "", $pass = "") {
210
+		// Sends both user and pass. Returns # of msgs in mailbox or
211
+		// false on failure (or -1, if the error occurs while getting
212
+		// the number of messages.)
213
+
214
+		if( !isset($this->FP) ) {
215
+			$this->ERROR = "POP3 login: " . _("No connection to server");
216
+			return false;
217
+		} else {
218
+			$fp = $this->FP;
219
+			if( !$this->user( $login ) ) {
220
+				//  Preserve the error generated by user()
221
+				return false;
222
+			} else {
223
+				$count = $this->pass($pass);
224
+				if( (!$count) || ($count == -1) ) {
225
+					//  Preserve the error generated by last() and pass()
226
+					return false;
227
+				} else
228
+					return $count;
229
+			}
230
+		}
231
+	}
232
+
233
+	function top ($msgNum, $numLines = "0") {
234
+		//  Gets the header and first $numLines of the msg body
235
+		//  returns data in an array with each returned line being
236
+		//  an array element. If $numLines is empty, returns
237
+		//  only the header information, and none of the body.
238
+
239
+		if(!isset($this->FP)) {
240
+			$this->ERROR = "POP3 top: " . _("No connection to server");
241
+			return false;
242
+		}
243
+		$this->update_timer();
244
+
245
+		$fp = $this->FP;
246
+		$buffer = $this->BUFFER;
247
+		$cmd = "TOP $msgNum $numLines";
248
+		fwrite($fp, "TOP $msgNum $numLines\r\n");
249
+		$reply = fgets($fp, $buffer);
250
+		$reply = $this->strip_clf($reply);
251
+		if($this->DEBUG) {
252
+			@error_log("POP3 SEND [$cmd] GOT [$reply]",0);
253
+		}
254
+		if(!$this->is_ok($reply))
255
+		{
256
+			$this->ERROR = "POP3 top: " . _("Error ") . "[$reply]";
257
+			return false;
258
+		}
259
+
260
+		$count = 0;
261
+		$MsgArray = array();
262
+
263
+		$line = fgets($fp,$buffer);
264
+		while ( !preg_match('/^\.\r\n/',$line))
265
+		{
266
+			$MsgArray[$count] = $line;
267
+			$count++;
268
+			$line = fgets($fp,$buffer);
269
+			if(empty($line))    { break; }
270
+		}
271
+
272
+		return $MsgArray;
273
+	}
274
+
275
+	function pop_list ($msgNum = "") {
276
+		//  If called with an argument, returns that msgs' size in octets
277
+		//  No argument returns an associative array of undeleted
278
+		//  msg numbers and their sizes in octets
279
+
280
+		if(!isset($this->FP))
281
+		{
282
+			$this->ERROR = "POP3 pop_list: " . _("No connection to server");
283
+			return false;
284
+		}
285
+		$fp = $this->FP;
286
+		$Total = $this->COUNT;
287
+		if( (!$Total) or ($Total == -1) )
288
+		{
289
+			return false;
290
+		}
291
+		if($Total == 0)
292
+		{
293
+			return array("0","0");
294
+			// return -1;   // mailbox empty
295
+		}
296
+
297
+		$this->update_timer();
298
+
299
+		if(!empty($msgNum))
300
+		{
301
+			$cmd = "LIST $msgNum";
302
+			fwrite($fp,"$cmd\r\n");
303
+			$reply = fgets($fp,$this->BUFFER);
304
+			$reply = $this->strip_clf($reply);
305
+			if($this->DEBUG) {
306
+				@error_log("POP3 SEND [$cmd] GOT [$reply]",0);
307
+			}
308
+			if(!$this->is_ok($reply))
309
+			{
310
+				$this->ERROR = "POP3 pop_list: " . _("Error ") . "[$reply]";
311
+				return false;
312
+			}
313
+			list($junk,$num,$size) = preg_split('/\s+/',$reply);
314
+			return $size;
315
+		}
316
+		$cmd = "LIST";
317
+		$reply = $this->send_cmd($cmd);
318
+		if(!$this->is_ok($reply))
319
+		{
320
+			$reply = $this->strip_clf($reply);
321
+			$this->ERROR = "POP3 pop_list: " . _("Error ") .  "[$reply]";
322
+			return false;
323
+		}
324
+		$MsgArray = array();
325
+		$MsgArray[0] = $Total;
326
+		for($msgC=1;$msgC <= $Total; $msgC++)
327
+		{
328
+			if($msgC > $Total) { break; }
329
+			$line = fgets($fp,$this->BUFFER);
330
+			$line = $this->strip_clf($line);
331
+			if(strpos($line, '.') === 0)
332
+			{
333
+				$this->ERROR = "POP3 pop_list: " . _("Premature end of list");
334
+				return false;
335
+			}
336
+			list($thisMsg,$msgSize) = preg_split('/\s+/',$line);
337
+			settype($thisMsg,"integer");
338
+			if($thisMsg != $msgC)
339
+			{
340
+				$MsgArray[$msgC] = "deleted";
341
+			}
342
+			else
343
+			{
344
+				$MsgArray[$msgC] = $msgSize;
345
+			}
346
+		}
347
+		return $MsgArray;
348
+	}
349
+
350
+	function get ($msgNum) {
351
+		//  Retrieve the specified msg number. Returns an array
352
+		//  where each line of the msg is an array element.
353
+
354
+		if(!isset($this->FP))
355
+		{
356
+			$this->ERROR = "POP3 get: " . _("No connection to server");
357
+			return false;
358
+		}
359
+
360
+		$this->update_timer();
361
+
362
+		$fp = $this->FP;
363
+		$buffer = $this->BUFFER;
364
+		$cmd = "RETR $msgNum";
365
+		$reply = $this->send_cmd($cmd);
366
+
367
+		if(!$this->is_ok($reply))
368
+		{
369
+			$this->ERROR = "POP3 get: " . _("Error ") . "[$reply]";
370
+			return false;
371
+		}
372
+
373
+		$count = 0;
374
+		$MsgArray = array();
375
+
376
+		$line = fgets($fp,$buffer);
377
+		while ( !preg_match('/^\.\r\n/',$line))
378
+		{
379
+			if ( $line{0} == '.' ) { $line = substr($line,1); }
380
+			$MsgArray[$count] = $line;
381
+			$count++;
382
+			$line = fgets($fp,$buffer);
383
+			if(empty($line))    { break; }
384
+		}
385
+		return $MsgArray;
386
+	}
387
+
388
+	function last ( $type = "count" ) {
389
+		//  Returns the highest msg number in the mailbox.
390
+		//  returns -1 on error, 0+ on success, if type != count
391
+		//  results in a popstat() call (2 element array returned)
392
+
393
+		$last = -1;
394
+		if(!isset($this->FP))
395
+		{
396
+			$this->ERROR = "POP3 last: " . _("No connection to server");
397
+			return $last;
398
+		}
399
+
400
+		$reply = $this->send_cmd("STAT");
401
+		if(!$this->is_ok($reply))
402
+		{
403
+			$this->ERROR = "POP3 last: " . _("Error ") . "[$reply]";
404
+			return $last;
405
+		}
406
+
407
+		$Vars = preg_split('/\s+/',$reply);
408
+		$count = $Vars[1];
409
+		$size = $Vars[2];
410
+		settype($count,"integer");
411
+		settype($size,"integer");
412
+		if($type != "count")
413
+		{
414
+			return array($count,$size);
415
+		}
416
+		return $count;
417
+	}
418
+
419
+	function reset () {
420
+		//  Resets the status of the remote server. This includes
421
+		//  resetting the status of ALL msgs to not be deleted.
422
+		//  This method automatically closes the connection to the server.
423
+
424
+		if(!isset($this->FP))
425
+		{
426
+			$this->ERROR = "POP3 reset: " . _("No connection to server");
427
+			return false;
428
+		}
429
+		$reply = $this->send_cmd("RSET");
430
+		if(!$this->is_ok($reply))
431
+		{
432
+			//  The POP3 RSET command -never- gives a -ERR
433
+			//  response - if it ever does, something truly
434
+			//  wild is going on.
435
+
436
+			$this->ERROR = "POP3 reset: " . _("Error ") . "[$reply]";
437
+			@error_log("POP3 reset: ERROR [$reply]",0);
438
+		}
439
+		$this->quit();
440
+		return true;
441
+	}
442
+
443
+	function send_cmd ( $cmd = "" )
444
+	{
445
+		//  Sends a user defined command string to the
446
+		//  POP server and returns the results. Useful for
447
+		//  non-compliant or custom POP servers.
448
+		//  Do NOT includ the \r\n as part of your command
449
+		//  string - it will be appended automatically.
450
+
451
+		//  The return value is a standard fgets() call, which
452
+		//  will read up to $this->BUFFER bytes of data, until it
453
+		//  encounters a new line, or EOF, whichever happens first.
454
+
455
+		//  This method works best if $cmd responds with only
456
+		//  one line of data.
457
+
458
+		if(!isset($this->FP))
459
+		{
460
+			$this->ERROR = "POP3 send_cmd: " . _("No connection to server");
461
+			return false;
462
+		}
463
+
464
+		if(empty($cmd))
465
+		{
466
+			$this->ERROR = "POP3 send_cmd: " . _("Empty command string");
467
+			return "";
468
+		}
469
+
470
+		$fp = $this->FP;
471
+		$buffer = $this->BUFFER;
472
+		$this->update_timer();
473
+		fwrite($fp,"$cmd\r\n");
474
+		$reply = fgets($fp,$buffer);
475
+		$reply = $this->strip_clf($reply);
476
+		if($this->DEBUG) { @error_log("POP3 SEND [$cmd] GOT [$reply]",0); }
477
+		return $reply;
478
+	}
479
+
480
+	function quit() {
481
+		//  Closes the connection to the POP3 server, deleting
482
+		//  any msgs marked as deleted.
483
+
484
+		if(!isset($this->FP))
485
+		{
486
+			$this->ERROR = "POP3 quit: " . _("connection does not exist");
487
+			return false;
488
+		}
489
+		$fp = $this->FP;
490
+		$cmd = "QUIT";
491
+		fwrite($fp,"$cmd\r\n");
492
+		$reply = fgets($fp,$this->BUFFER);
493
+		$reply = $this->strip_clf($reply);
494
+		if($this->DEBUG) { @error_log("POP3 SEND [$cmd] GOT [$reply]",0); }
495
+		fclose($fp);
496
+		unset($this->FP);
497
+		return true;
498
+	}
499
+
500
+	function popstat () {
501
+		//  Returns an array of 2 elements. The number of undeleted
502
+		//  msgs in the mailbox, and the size of the mbox in octets.
503
+
504
+		$PopArray = $this->last("array");
505
+
506
+		if($PopArray == -1) { return false; }
507
+
508
+		if( (!$PopArray) or (empty($PopArray)) )
509
+		{
510
+			return false;
511
+		}
512
+		return $PopArray;
513
+	}
514
+
515
+	function uidl ($msgNum = "")
516
+	{
517
+		//  Returns the UIDL of the msg specified. If called with
518
+		//  no arguments, returns an associative array where each
519
+		//  undeleted msg num is a key, and the msg's uidl is the element
520
+		//  Array element 0 will contain the total number of msgs
521
+
522
+		if(!isset($this->FP)) {
523
+			$this->ERROR = "POP3 uidl: " . _("No connection to server");
524
+			return false;
525
+		}
526
+
527
+		$fp = $this->FP;
528
+		$buffer = $this->BUFFER;
529
+
530
+		if(!empty($msgNum)) {
531
+			$cmd = "UIDL $msgNum";
532
+			$reply = $this->send_cmd($cmd);
533
+			if(!$this->is_ok($reply))
534
+			{
535
+				$this->ERROR = "POP3 uidl: " . _("Error ") . "[$reply]";
536
+				return false;
537
+			}
538
+			list ($ok,$num,$myUidl) = preg_split('/\s+/',$reply);
539
+			return $myUidl;
540
+		} else {
541
+			$this->update_timer();
542
+
543
+			$UIDLArray = array();
544
+			$Total = $this->COUNT;
545
+			$UIDLArray[0] = $Total;
546
+
547
+			if ($Total < 1)
548
+			{
549
+				return $UIDLArray;
550
+			}
551
+			$cmd = "UIDL";
552
+			fwrite($fp, "UIDL\r\n");
553
+			$reply = fgets($fp, $buffer);
554
+			$reply = $this->strip_clf($reply);
555
+			if($this->DEBUG) { @error_log("POP3 SEND [$cmd] GOT [$reply]",0); }
556
+			if(!$this->is_ok($reply))
557
+			{
558
+				$this->ERROR = "POP3 uidl: " . _("Error ") . "[$reply]";
559
+				return false;
560
+			}
561
+
562
+			$line = "";
563
+			$count = 1;
564
+			$line = fgets($fp,$buffer);
565
+			while ( !preg_match('/^\.\r\n/',$line)) {
566
+				list ($msg,$msgUidl) = preg_split('/\s+/',$line);
567
+				$msgUidl = $this->strip_clf($msgUidl);
568
+				if($count == $msg) {
569
+					$UIDLArray[$msg] = $msgUidl;
570
+				}
571
+				else
572
+				{
573
+					$UIDLArray[$count] = 'deleted';
574
+				}
575
+				$count++;
576
+				$line = fgets($fp,$buffer);
577
+			}
578
+		}
579
+		return $UIDLArray;
580
+	}
581
+
582
+	function delete ($msgNum = "") {
583
+		//  Flags a specified msg as deleted. The msg will not
584
+		//  be deleted until a quit() method is called.
585
+
586
+		if(!isset($this->FP))
587
+		{
588
+			$this->ERROR = "POP3 delete: " . _("No connection to server");
589
+			return false;
590
+		}
591
+		if(empty($msgNum))
592
+		{
593
+			$this->ERROR = "POP3 delete: " . _("No msg number submitted");
594
+			return false;
595
+		}
596
+		$reply = $this->send_cmd("DELE $msgNum");
597
+		if(!$this->is_ok($reply))
598
+		{
599
+			$this->ERROR = "POP3 delete: " . _("Command failed ") . "[$reply]";
600
+			return false;
601
+		}
602
+		return true;
603
+	}
604
+
605
+	//  *********************************************************
606
+
607
+	//  The following methods are internal to the class.
608
+
609
+	function is_ok ($cmd = "") {
610
+		//  Return true or false on +OK or -ERR
611
+
612
+		if( empty($cmd) )
613
+			return false;
614
+		else
615
+			return( stripos($cmd, '+OK') !== false );
616
+	}
617
+
618
+	function strip_clf ($text = "") {
619
+		// Strips \r\n from server responses
620
+
621
+		if(empty($text))
622
+			return $text;
623
+		else {
624
+			$stripped = str_replace(array("\r","\n"),'',$text);
625
+			return $stripped;
626
+		}
627
+	}
628
+
629
+	function parse_banner ( $server_text ) {
630
+		$outside = true;
631
+		$banner = "";
632
+		$length = strlen($server_text);
633
+		for($count =0; $count < $length; $count++)
634
+		{
635
+			$digit = substr($server_text,$count,1);
636
+			if(!empty($digit))             {
637
+				if( (!$outside) && ($digit != '<') && ($digit != '>') )
638
+				{
639
+					$banner .= $digit;
640
+				}
641
+				if ($digit == '<')
642
+				{
643
+					$outside = false;
644
+				}
645
+				if($digit == '>')
646
+				{
647
+					$outside = true;
648
+				}
649
+			}
650
+		}
651
+		$banner = $this->strip_clf($banner);    // Just in case
652
+		return "<$banner>";
653
+	}
654 654
 
655 655
 }   // End class
656 656
 
657 657
 // For php4 compatibility
658 658
 if (!function_exists("stripos")) {
659
-    function stripos($haystack, $needle){
660
-        return strpos($haystack, stristr( $haystack, $needle ));
661
-    }
659
+	function stripos($haystack, $needle){
660
+		return strpos($haystack, stristr( $haystack, $needle ));
661
+	}
662 662
 }
Please login to merge, or discard this patch.
src/wp-includes/class-snoopy.php 4 patches
Doc Comments   +10 added lines patch added patch discarded remove patch
@@ -781,6 +781,9 @@  discard block
 block discarded – undo
781 781
 	Output:
782 782
 \*======================================================================*/
783 783
 
784
+	/**
785
+	 * @param string $http_method
786
+	 */
784 787
 	function _httprequest($url,$fp,$URI,$http_method,$content_type="",$body="")
785 788
 	{
786 789
 		$cookie_headers = '';
@@ -944,6 +947,9 @@  discard block
 block discarded – undo
944 947
 	Output:
945 948
 \*======================================================================*/
946 949
 
950
+	/**
951
+	 * @param string $http_method
952
+	 */
947 953
 	function _httpsrequest($url,$URI,$http_method,$content_type="",$body="")
948 954
 	{
949 955
 		if($this->passcookies && $this->_redirectaddr)
@@ -1189,6 +1195,10 @@  discard block
 block discarded – undo
1189 1195
 	Output:		post body
1190 1196
 \*======================================================================*/
1191 1197
 
1198
+	/**
1199
+	 * @param string $formvars
1200
+	 * @param string $formfiles
1201
+	 */
1192 1202
 	function _prepare_post_body($formvars, $formfiles)
1193 1203
 	{
1194 1204
 		settype($formvars, "array");
Please login to merge, or discard this patch.
Indentation   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -205,8 +205,8 @@  discard block
 block discarded – undo
205 205
 				if(!$this->curl_path)
206 206
 					return false;
207 207
 				if(function_exists("is_executable"))
208
-				    if (!is_executable($this->curl_path))
209
-				        return false;
208
+					if (!is_executable($this->curl_path))
209
+						return false;
210 210
 				$this->host = $URI_PARTS["host"];
211 211
 				if(!empty($URI_PARTS["port"]))
212 212
 					$this->port = $URI_PARTS["port"];
@@ -364,8 +364,8 @@  discard block
 block discarded – undo
364 364
 				if(!$this->curl_path)
365 365
 					return false;
366 366
 				if(function_exists("is_executable"))
367
-				    if (!is_executable($this->curl_path))
368
-				        return false;
367
+					if (!is_executable($this->curl_path))
368
+						return false;
369 369
 				$this->host = $URI_PARTS["host"];
370 370
 				if(!empty($URI_PARTS["port"]))
371 371
 					$this->port = $URI_PARTS["port"];
@@ -885,10 +885,10 @@  discard block
 block discarded – undo
885 885
 
886 886
 			if(preg_match("|^HTTP/|",$currentHeader))
887 887
 			{
888
-                if(preg_match("|^HTTP/[^\s]*\s(.*?)\s|",$currentHeader, $status))
888
+				if(preg_match("|^HTTP/[^\s]*\s(.*?)\s|",$currentHeader, $status))
889 889
 				{
890 890
 					$this->status= $status[1];
891
-                }
891
+				}
892 892
 				$this->response_code = $currentHeader;
893 893
 			}
894 894
 
@@ -897,11 +897,11 @@  discard block
 block discarded – undo
897 897
 
898 898
 		$results = '';
899 899
 		do {
900
-    		$_data = fread($fp, $this->maxlength);
901
-    		if (strlen($_data) == 0) {
902
-        		break;
903
-    		}
904
-    		$results .= $_data;
900
+			$_data = fread($fp, $this->maxlength);
901
+			if (strlen($_data) == 0) {
902
+				break;
903
+			}
904
+			$results .= $_data;
905 905
 		} while(true);
906 906
 
907 907
 		if ($this->read_timeout > 0 && $this->_check_timeout($fp))
Please login to merge, or discard this patch.
Braces   +273 added lines, -205 removed lines patch added patch discarded remove patch
@@ -131,29 +131,33 @@  discard block
 block discarded – undo
131 131
 
132 132
 		//preg_match("|^([^:]+)://([^:/]+)(:[\d]+)*(.*)|",$URI,$URI_PARTS);
133 133
 		$URI_PARTS = parse_url($URI);
134
-		if (!empty($URI_PARTS["user"]))
135
-			$this->user = $URI_PARTS["user"];
136
-		if (!empty($URI_PARTS["pass"]))
137
-			$this->pass = $URI_PARTS["pass"];
138
-		if (empty($URI_PARTS["query"]))
139
-			$URI_PARTS["query"] = '';
140
-		if (empty($URI_PARTS["path"]))
141
-			$URI_PARTS["path"] = '';
134
+		if (!empty($URI_PARTS["user"])) {
135
+					$this->user = $URI_PARTS["user"];
136
+		}
137
+		if (!empty($URI_PARTS["pass"])) {
138
+					$this->pass = $URI_PARTS["pass"];
139
+		}
140
+		if (empty($URI_PARTS["query"])) {
141
+					$URI_PARTS["query"] = '';
142
+		}
143
+		if (empty($URI_PARTS["path"])) {
144
+					$URI_PARTS["path"] = '';
145
+		}
142 146
 
143 147
 		switch(strtolower($URI_PARTS["scheme"]))
144 148
 		{
145 149
 			case "http":
146 150
 				$this->host = $URI_PARTS["host"];
147
-				if(!empty($URI_PARTS["port"]))
148
-					$this->port = $URI_PARTS["port"];
151
+				if(!empty($URI_PARTS["port"])) {
152
+									$this->port = $URI_PARTS["port"];
153
+				}
149 154
 				if($this->_connect($fp))
150 155
 				{
151 156
 					if($this->_isproxy)
152 157
 					{
153 158
 						// using proxy, send entire URI
154 159
 						$this->_httprequest($URI,$fp,$URI,$this->_httpmethod);
155
-					}
156
-					else
160
+					} else
157 161
 					{
158 162
 						$path = $URI_PARTS["path"].($URI_PARTS["query"] ? "?".$URI_PARTS["query"] : "");
159 163
 						// no proxy, send only the path
@@ -189,33 +193,34 @@  discard block
 block discarded – undo
189 193
 							{
190 194
 								$this->fetch($frameurl);
191 195
 								$this->_framedepth++;
196
+							} else {
197
+															break;
192 198
 							}
193
-							else
194
-								break;
195 199
 						}
196 200
 					}
197
-				}
198
-				else
201
+				} else
199 202
 				{
200 203
 					return false;
201 204
 				}
202 205
 				return true;
203 206
 				break;
204 207
 			case "https":
205
-				if(!$this->curl_path)
206
-					return false;
207
-				if(function_exists("is_executable"))
208
-				    if (!is_executable($this->curl_path))
208
+				if(!$this->curl_path) {
209
+									return false;
210
+				}
211
+				if(function_exists("is_executable")) {
212
+								    if (!is_executable($this->curl_path))
209 213
 				        return false;
214
+				}
210 215
 				$this->host = $URI_PARTS["host"];
211
-				if(!empty($URI_PARTS["port"]))
212
-					$this->port = $URI_PARTS["port"];
216
+				if(!empty($URI_PARTS["port"])) {
217
+									$this->port = $URI_PARTS["port"];
218
+				}
213 219
 				if($this->_isproxy)
214 220
 				{
215 221
 					// using proxy, send entire URI
216 222
 					$this->_httpsrequest($URI,$URI,$this->_httpmethod);
217
-				}
218
-				else
223
+				} else
219 224
 				{
220 225
 					$path = $URI_PARTS["path"].($URI_PARTS["query"] ? "?".$URI_PARTS["query"] : "");
221 226
 					// no proxy, send only the path
@@ -249,9 +254,9 @@  discard block
 block discarded – undo
249 254
 						{
250 255
 							$this->fetch($frameurl);
251 256
 							$this->_framedepth++;
257
+						} else {
258
+													break;
252 259
 						}
253
-						else
254
-							break;
255 260
 					}
256 261
 				}
257 262
 				return true;
@@ -283,29 +288,33 @@  discard block
 block discarded – undo
283 288
 		$postdata = $this->_prepare_post_body($formvars, $formfiles);
284 289
 
285 290
 		$URI_PARTS = parse_url($URI);
286
-		if (!empty($URI_PARTS["user"]))
287
-			$this->user = $URI_PARTS["user"];
288
-		if (!empty($URI_PARTS["pass"]))
289
-			$this->pass = $URI_PARTS["pass"];
290
-		if (empty($URI_PARTS["query"]))
291
-			$URI_PARTS["query"] = '';
292
-		if (empty($URI_PARTS["path"]))
293
-			$URI_PARTS["path"] = '';
291
+		if (!empty($URI_PARTS["user"])) {
292
+					$this->user = $URI_PARTS["user"];
293
+		}
294
+		if (!empty($URI_PARTS["pass"])) {
295
+					$this->pass = $URI_PARTS["pass"];
296
+		}
297
+		if (empty($URI_PARTS["query"])) {
298
+					$URI_PARTS["query"] = '';
299
+		}
300
+		if (empty($URI_PARTS["path"])) {
301
+					$URI_PARTS["path"] = '';
302
+		}
294 303
 
295 304
 		switch(strtolower($URI_PARTS["scheme"]))
296 305
 		{
297 306
 			case "http":
298 307
 				$this->host = $URI_PARTS["host"];
299
-				if(!empty($URI_PARTS["port"]))
300
-					$this->port = $URI_PARTS["port"];
308
+				if(!empty($URI_PARTS["port"])) {
309
+									$this->port = $URI_PARTS["port"];
310
+				}
301 311
 				if($this->_connect($fp))
302 312
 				{
303 313
 					if($this->_isproxy)
304 314
 					{
305 315
 						// using proxy, send entire URI
306 316
 						$this->_httprequest($URI,$fp,$URI,$this->_submit_method,$this->_submit_type,$postdata);
307
-					}
308
-					else
317
+					} else
309 318
 					{
310 319
 						$path = $URI_PARTS["path"].($URI_PARTS["query"] ? "?".$URI_PARTS["query"] : "");
311 320
 						// no proxy, send only the path
@@ -319,8 +328,9 @@  discard block
 block discarded – undo
319 328
 						/* url was redirected, check if we've hit the max depth */
320 329
 						if($this->maxredirs > $this->_redirectdepth)
321 330
 						{
322
-							if(!preg_match("|^".$URI_PARTS["scheme"]."://|", $this->_redirectaddr))
323
-								$this->_redirectaddr = $this->_expandlinks($this->_redirectaddr,$URI_PARTS["scheme"]."://".$URI_PARTS["host"]);
331
+							if(!preg_match("|^".$URI_PARTS["scheme"]."://|", $this->_redirectaddr)) {
332
+															$this->_redirectaddr = $this->_expandlinks($this->_redirectaddr,$URI_PARTS["scheme"]."://".$URI_PARTS["host"]);
333
+							}
324 334
 
325 335
 							// only follow redirect if it's on this site, or offsiteok is true
326 336
 							if(preg_match("|^http://".preg_quote($this->host)."|i",$this->_redirectaddr) || $this->offsiteok)
@@ -328,10 +338,13 @@  discard block
 block discarded – undo
328 338
 								/* follow the redirect */
329 339
 								$this->_redirectdepth++;
330 340
 								$this->lastredirectaddr=$this->_redirectaddr;
331
-								if( strpos( $this->_redirectaddr, "?" ) > 0 )
332
-									$this->fetch($this->_redirectaddr); // the redirect has changed the request method from post to get
333
-								else
334
-									$this->submit($this->_redirectaddr,$formvars, $formfiles);
341
+								if( strpos( $this->_redirectaddr, "?" ) > 0 ) {
342
+																	$this->fetch($this->_redirectaddr);
343
+								}
344
+								// the redirect has changed the request method from post to get
345
+								else {
346
+																	$this->submit($this->_redirectaddr,$formvars, $formfiles);
347
+								}
335 348
 							}
336 349
 						}
337 350
 					}
@@ -347,34 +360,35 @@  discard block
 block discarded – undo
347 360
 							{
348 361
 								$this->fetch($frameurl);
349 362
 								$this->_framedepth++;
363
+							} else {
364
+															break;
350 365
 							}
351
-							else
352
-								break;
353 366
 						}
354 367
 					}
355 368
 
356
-				}
357
-				else
369
+				} else
358 370
 				{
359 371
 					return false;
360 372
 				}
361 373
 				return true;
362 374
 				break;
363 375
 			case "https":
364
-				if(!$this->curl_path)
365
-					return false;
366
-				if(function_exists("is_executable"))
367
-				    if (!is_executable($this->curl_path))
376
+				if(!$this->curl_path) {
377
+									return false;
378
+				}
379
+				if(function_exists("is_executable")) {
380
+								    if (!is_executable($this->curl_path))
368 381
 				        return false;
382
+				}
369 383
 				$this->host = $URI_PARTS["host"];
370
-				if(!empty($URI_PARTS["port"]))
371
-					$this->port = $URI_PARTS["port"];
384
+				if(!empty($URI_PARTS["port"])) {
385
+									$this->port = $URI_PARTS["port"];
386
+				}
372 387
 				if($this->_isproxy)
373 388
 				{
374 389
 					// using proxy, send entire URI
375 390
 					$this->_httpsrequest($URI, $URI, $this->_submit_method, $this->_submit_type, $postdata);
376
-				}
377
-				else
391
+				} else
378 392
 				{
379 393
 					$path = $URI_PARTS["path"].($URI_PARTS["query"] ? "?".$URI_PARTS["query"] : "");
380 394
 					// no proxy, send only the path
@@ -386,8 +400,9 @@  discard block
 block discarded – undo
386 400
 					/* url was redirected, check if we've hit the max depth */
387 401
 					if($this->maxredirs > $this->_redirectdepth)
388 402
 					{
389
-						if(!preg_match("|^".$URI_PARTS["scheme"]."://|", $this->_redirectaddr))
390
-							$this->_redirectaddr = $this->_expandlinks($this->_redirectaddr,$URI_PARTS["scheme"]."://".$URI_PARTS["host"]);
403
+						if(!preg_match("|^".$URI_PARTS["scheme"]."://|", $this->_redirectaddr)) {
404
+													$this->_redirectaddr = $this->_expandlinks($this->_redirectaddr,$URI_PARTS["scheme"]."://".$URI_PARTS["host"]);
405
+						}
391 406
 
392 407
 						// only follow redirect if it's on this site, or offsiteok is true
393 408
 						if(preg_match("|^http://".preg_quote($this->host)."|i",$this->_redirectaddr) || $this->offsiteok)
@@ -395,10 +410,13 @@  discard block
 block discarded – undo
395 410
 							/* follow the redirect */
396 411
 							$this->_redirectdepth++;
397 412
 							$this->lastredirectaddr=$this->_redirectaddr;
398
-							if( strpos( $this->_redirectaddr, "?" ) > 0 )
399
-								$this->fetch($this->_redirectaddr); // the redirect has changed the request method from post to get
400
-							else
401
-								$this->submit($this->_redirectaddr,$formvars, $formfiles);
413
+							if( strpos( $this->_redirectaddr, "?" ) > 0 ) {
414
+															$this->fetch($this->_redirectaddr);
415
+							}
416
+							// the redirect has changed the request method from post to get
417
+							else {
418
+															$this->submit($this->_redirectaddr,$formvars, $formfiles);
419
+							}
402 420
 						}
403 421
 					}
404 422
 				}
@@ -414,9 +432,9 @@  discard block
 block discarded – undo
414 432
 						{
415 433
 							$this->fetch($frameurl);
416 434
 							$this->_framedepth++;
435
+						} else {
436
+													break;
417 437
 						}
418
-						else
419
-							break;
420 438
 					}
421 439
 				}
422 440
 				return true;
@@ -442,22 +460,25 @@  discard block
 block discarded – undo
442 460
 	{
443 461
 		if ($this->fetch($URI))
444 462
 		{
445
-			if($this->lastredirectaddr)
446
-				$URI = $this->lastredirectaddr;
463
+			if($this->lastredirectaddr) {
464
+							$URI = $this->lastredirectaddr;
465
+			}
447 466
 			if(is_array($this->results))
448 467
 			{
449
-				for($x=0;$x<count($this->results);$x++)
450
-					$this->results[$x] = $this->_striplinks($this->results[$x]);
468
+				for($x=0;$x<count($this->results);$x++) {
469
+									$this->results[$x] = $this->_striplinks($this->results[$x]);
470
+				}
471
+			} else {
472
+							$this->results = $this->_striplinks($this->results);
451 473
 			}
452
-			else
453
-				$this->results = $this->_striplinks($this->results);
454 474
 
455
-			if($this->expandlinks)
456
-				$this->results = $this->_expandlinks($this->results, $URI);
475
+			if($this->expandlinks) {
476
+							$this->results = $this->_expandlinks($this->results, $URI);
477
+			}
457 478
 			return true;
479
+		} else {
480
+					return false;
458 481
 		}
459
-		else
460
-			return false;
461 482
 	}
462 483
 
463 484
 /*======================================================================*\
@@ -475,16 +496,17 @@  discard block
 block discarded – undo
475 496
 
476 497
 			if(is_array($this->results))
477 498
 			{
478
-				for($x=0;$x<count($this->results);$x++)
479
-					$this->results[$x] = $this->_stripform($this->results[$x]);
499
+				for($x=0;$x<count($this->results);$x++) {
500
+									$this->results[$x] = $this->_stripform($this->results[$x]);
501
+				}
502
+			} else {
503
+							$this->results = $this->_stripform($this->results);
480 504
 			}
481
-			else
482
-				$this->results = $this->_stripform($this->results);
483 505
 
484 506
 			return true;
507
+		} else {
508
+					return false;
485 509
 		}
486
-		else
487
-			return false;
488 510
 	}
489 511
 
490 512
 
@@ -501,15 +523,16 @@  discard block
 block discarded – undo
501 523
 		{
502 524
 			if(is_array($this->results))
503 525
 			{
504
-				for($x=0;$x<count($this->results);$x++)
505
-					$this->results[$x] = $this->_striptext($this->results[$x]);
526
+				for($x=0;$x<count($this->results);$x++) {
527
+									$this->results[$x] = $this->_striptext($this->results[$x]);
528
+				}
529
+			} else {
530
+							$this->results = $this->_striptext($this->results);
506 531
 			}
507
-			else
508
-				$this->results = $this->_striptext($this->results);
509 532
 			return true;
533
+		} else {
534
+					return false;
510 535
 		}
511
-		else
512
-			return false;
513 536
 	}
514 537
 
515 538
 /*======================================================================*\
@@ -523,27 +546,29 @@  discard block
 block discarded – undo
523 546
 	{
524 547
 		if($this->submit($URI,$formvars, $formfiles))
525 548
 		{
526
-			if($this->lastredirectaddr)
527
-				$URI = $this->lastredirectaddr;
549
+			if($this->lastredirectaddr) {
550
+							$URI = $this->lastredirectaddr;
551
+			}
528 552
 			if(is_array($this->results))
529 553
 			{
530 554
 				for($x=0;$x<count($this->results);$x++)
531 555
 				{
532 556
 					$this->results[$x] = $this->_striplinks($this->results[$x]);
533
-					if($this->expandlinks)
534
-						$this->results[$x] = $this->_expandlinks($this->results[$x],$URI);
557
+					if($this->expandlinks) {
558
+											$this->results[$x] = $this->_expandlinks($this->results[$x],$URI);
559
+					}
535 560
 				}
536
-			}
537
-			else
561
+			} else
538 562
 			{
539 563
 				$this->results = $this->_striplinks($this->results);
540
-				if($this->expandlinks)
541
-					$this->results = $this->_expandlinks($this->results,$URI);
564
+				if($this->expandlinks) {
565
+									$this->results = $this->_expandlinks($this->results,$URI);
566
+				}
542 567
 			}
543 568
 			return true;
569
+		} else {
570
+					return false;
544 571
 		}
545
-		else
546
-			return false;
547 572
 	}
548 573
 
549 574
 /*======================================================================*\
@@ -557,27 +582,29 @@  discard block
 block discarded – undo
557 582
 	{
558 583
 		if($this->submit($URI,$formvars, $formfiles))
559 584
 		{
560
-			if($this->lastredirectaddr)
561
-				$URI = $this->lastredirectaddr;
585
+			if($this->lastredirectaddr) {
586
+							$URI = $this->lastredirectaddr;
587
+			}
562 588
 			if(is_array($this->results))
563 589
 			{
564 590
 				for($x=0;$x<count($this->results);$x++)
565 591
 				{
566 592
 					$this->results[$x] = $this->_striptext($this->results[$x]);
567
-					if($this->expandlinks)
568
-						$this->results[$x] = $this->_expandlinks($this->results[$x],$URI);
593
+					if($this->expandlinks) {
594
+											$this->results[$x] = $this->_expandlinks($this->results[$x],$URI);
595
+					}
569 596
 				}
570
-			}
571
-			else
597
+			} else
572 598
 			{
573 599
 				$this->results = $this->_striptext($this->results);
574
-				if($this->expandlinks)
575
-					$this->results = $this->_expandlinks($this->results,$URI);
600
+				if($this->expandlinks) {
601
+									$this->results = $this->_expandlinks($this->results,$URI);
602
+				}
576 603
 			}
577 604
 			return true;
605
+		} else {
606
+					return false;
578 607
 		}
579
-		else
580
-			return false;
581 608
 	}
582 609
 
583 610
 
@@ -631,14 +658,16 @@  discard block
 block discarded – undo
631 658
 
632 659
 		while(list($key,$val) = each($links[2]))
633 660
 		{
634
-			if(!empty($val))
635
-				$match[] = $val;
661
+			if(!empty($val)) {
662
+							$match[] = $val;
663
+			}
636 664
 		}
637 665
 
638 666
 		while(list($key,$val) = each($links[3]))
639 667
 		{
640
-			if(!empty($val))
641
-				$match[] = $val;
668
+			if(!empty($val)) {
669
+							$match[] = $val;
670
+			}
642 671
 		}
643 672
 
644 673
 		// return the links
@@ -784,29 +813,36 @@  discard block
 block discarded – undo
784 813
 	function _httprequest($url,$fp,$URI,$http_method,$content_type="",$body="")
785 814
 	{
786 815
 		$cookie_headers = '';
787
-		if($this->passcookies && $this->_redirectaddr)
788
-			$this->setcookies();
816
+		if($this->passcookies && $this->_redirectaddr) {
817
+					$this->setcookies();
818
+		}
789 819
 
790 820
 		$URI_PARTS = parse_url($URI);
791
-		if(empty($url))
792
-			$url = "/";
821
+		if(empty($url)) {
822
+					$url = "/";
823
+		}
793 824
 		$headers = $http_method." ".$url." ".$this->_httpversion."\r\n";
794
-		if(!empty($this->agent))
795
-			$headers .= "User-Agent: ".$this->agent."\r\n";
825
+		if(!empty($this->agent)) {
826
+					$headers .= "User-Agent: ".$this->agent."\r\n";
827
+		}
796 828
 		if(!empty($this->host) && !isset($this->rawheaders['Host'])) {
797 829
 			$headers .= "Host: ".$this->host;
798
-			if(!empty($this->port) && $this->port != 80)
799
-				$headers .= ":".$this->port;
830
+			if(!empty($this->port) && $this->port != 80) {
831
+							$headers .= ":".$this->port;
832
+			}
800 833
 			$headers .= "\r\n";
801 834
 		}
802
-		if(!empty($this->accept))
803
-			$headers .= "Accept: ".$this->accept."\r\n";
804
-		if(!empty($this->referer))
805
-			$headers .= "Referer: ".$this->referer."\r\n";
835
+		if(!empty($this->accept)) {
836
+					$headers .= "Accept: ".$this->accept."\r\n";
837
+		}
838
+		if(!empty($this->referer)) {
839
+					$headers .= "Referer: ".$this->referer."\r\n";
840
+		}
806 841
 		if(!empty($this->cookies))
807 842
 		{
808
-			if(!is_array($this->cookies))
809
-				$this->cookies = (array)$this->cookies;
843
+			if(!is_array($this->cookies)) {
844
+							$this->cookies = (array)$this->cookies;
845
+			}
810 846
 
811 847
 			reset($this->cookies);
812 848
 			if ( count($this->cookies) > 0 ) {
@@ -819,32 +855,39 @@  discard block
 block discarded – undo
819 855
 		}
820 856
 		if(!empty($this->rawheaders))
821 857
 		{
822
-			if(!is_array($this->rawheaders))
823
-				$this->rawheaders = (array)$this->rawheaders;
824
-			while(list($headerKey,$headerVal) = each($this->rawheaders))
825
-				$headers .= $headerKey.": ".$headerVal."\r\n";
858
+			if(!is_array($this->rawheaders)) {
859
+							$this->rawheaders = (array)$this->rawheaders;
860
+			}
861
+			while(list($headerKey,$headerVal) = each($this->rawheaders)) {
862
+							$headers .= $headerKey.": ".$headerVal."\r\n";
863
+			}
826 864
 		}
827 865
 		if(!empty($content_type)) {
828 866
 			$headers .= "Content-type: $content_type";
829
-			if ($content_type == "multipart/form-data")
830
-				$headers .= "; boundary=".$this->_mime_boundary;
867
+			if ($content_type == "multipart/form-data") {
868
+							$headers .= "; boundary=".$this->_mime_boundary;
869
+			}
831 870
 			$headers .= "\r\n";
832 871
 		}
833
-		if(!empty($body))
834
-			$headers .= "Content-length: ".strlen($body)."\r\n";
835
-		if(!empty($this->user) || !empty($this->pass))
836
-			$headers .= "Authorization: Basic ".base64_encode($this->user.":".$this->pass)."\r\n";
872
+		if(!empty($body)) {
873
+					$headers .= "Content-length: ".strlen($body)."\r\n";
874
+		}
875
+		if(!empty($this->user) || !empty($this->pass)) {
876
+					$headers .= "Authorization: Basic ".base64_encode($this->user.":".$this->pass)."\r\n";
877
+		}
837 878
 
838 879
 		//add proxy auth headers
839
-		if(!empty($this->proxy_user))
840
-			$headers .= 'Proxy-Authorization: ' . 'Basic ' . base64_encode($this->proxy_user . ':' . $this->proxy_pass)."\r\n";
880
+		if(!empty($this->proxy_user)) {
881
+					$headers .= 'Proxy-Authorization: ' . 'Basic ' . base64_encode($this->proxy_user . ':' . $this->proxy_pass)."\r\n";
882
+		}
841 883
 
842 884
 
843 885
 		$headers .= "\r\n";
844 886
 
845 887
 		// set the read timeout if needed
846
-		if ($this->read_timeout > 0)
847
-			socket_set_timeout($fp, $this->read_timeout);
888
+		if ($this->read_timeout > 0) {
889
+					socket_set_timeout($fp, $this->read_timeout);
890
+		}
848 891
 		$this->timed_out = false;
849 892
 
850 893
 		fwrite($fp,$headers.$body,strlen($headers.$body));
@@ -860,8 +903,9 @@  discard block
 block discarded – undo
860 903
 				return false;
861 904
 			}
862 905
 
863
-			if($currentHeader == "\r\n")
864
-				break;
906
+			if($currentHeader == "\r\n") {
907
+							break;
908
+			}
865 909
 
866 910
 			// if a header begins with Location: or URI:, set the redirect
867 911
 			if(preg_match("/^(Location:|URI:)/i",$currentHeader))
@@ -874,13 +918,14 @@  discard block
 block discarded – undo
874 918
 					// no host in the path, so prepend
875 919
 					$this->_redirectaddr = $URI_PARTS["scheme"]."://".$this->host.":".$this->port;
876 920
 					// eliminate double slash
877
-					if(!preg_match("|^/|",$matches[2]))
878
-							$this->_redirectaddr .= "/".$matches[2];
879
-					else
880
-							$this->_redirectaddr .= $matches[2];
921
+					if(!preg_match("|^/|",$matches[2])) {
922
+												$this->_redirectaddr .= "/".$matches[2];
923
+					} else {
924
+												$this->_redirectaddr .= $matches[2];
925
+					}
926
+				} else {
927
+									$this->_redirectaddr = $matches[2];
881 928
 				}
882
-				else
883
-					$this->_redirectaddr = $matches[2];
884 929
 			}
885 930
 
886 931
 			if(preg_match("|^HTTP/|",$currentHeader))
@@ -922,15 +967,18 @@  discard block
 block discarded – undo
922 967
 		if(($this->_framedepth < $this->maxframes) && preg_match_all("'<frame\s+.*src[\s]*=[\'\"]?([^\'\"\>]+)'i",$results,$match))
923 968
 		{
924 969
 			$this->results[] = $results;
925
-			for($x=0; $x<count($match[1]); $x++)
926
-				$this->_frameurls[] = $this->_expandlinks($match[1][$x],$URI_PARTS["scheme"]."://".$this->host);
970
+			for($x=0; $x<count($match[1]); $x++) {
971
+							$this->_frameurls[] = $this->_expandlinks($match[1][$x],$URI_PARTS["scheme"]."://".$this->host);
972
+			}
927 973
 		}
928 974
 		// have we already fetched framed content?
929
-		elseif(is_array($this->results))
930
-			$this->results[] = $results;
975
+		elseif(is_array($this->results)) {
976
+					$this->results[] = $results;
977
+		}
931 978
 		// no framed content
932
-		else
933
-			$this->results = $results;
979
+		else {
980
+					$this->results = $results;
981
+		}
934 982
 
935 983
 		return true;
936 984
 	}
@@ -946,31 +994,38 @@  discard block
 block discarded – undo
946 994
 
947 995
 	function _httpsrequest($url,$URI,$http_method,$content_type="",$body="")
948 996
 	{
949
-		if($this->passcookies && $this->_redirectaddr)
950
-			$this->setcookies();
997
+		if($this->passcookies && $this->_redirectaddr) {
998
+					$this->setcookies();
999
+		}
951 1000
 
952 1001
 		$headers = array();
953 1002
 
954 1003
 		$URI_PARTS = parse_url($URI);
955
-		if(empty($url))
956
-			$url = "/";
1004
+		if(empty($url)) {
1005
+					$url = "/";
1006
+		}
957 1007
 		// GET ... header not needed for curl
958 1008
 		//$headers[] = $http_method." ".$url." ".$this->_httpversion;
959
-		if(!empty($this->agent))
960
-			$headers[] = "User-Agent: ".$this->agent;
961
-		if(!empty($this->host))
962
-			if(!empty($this->port))
1009
+		if(!empty($this->agent)) {
1010
+					$headers[] = "User-Agent: ".$this->agent;
1011
+		}
1012
+		if(!empty($this->host)) {
1013
+					if(!empty($this->port))
963 1014
 				$headers[] = "Host: ".$this->host.":".$this->port;
964
-			else
965
-				$headers[] = "Host: ".$this->host;
966
-		if(!empty($this->accept))
967
-			$headers[] = "Accept: ".$this->accept;
968
-		if(!empty($this->referer))
969
-			$headers[] = "Referer: ".$this->referer;
1015
+		} else {
1016
+							$headers[] = "Host: ".$this->host;
1017
+			}
1018
+		if(!empty($this->accept)) {
1019
+					$headers[] = "Accept: ".$this->accept;
1020
+		}
1021
+		if(!empty($this->referer)) {
1022
+					$headers[] = "Referer: ".$this->referer;
1023
+		}
970 1024
 		if(!empty($this->cookies))
971 1025
 		{
972
-			if(!is_array($this->cookies))
973
-				$this->cookies = (array)$this->cookies;
1026
+			if(!is_array($this->cookies)) {
1027
+							$this->cookies = (array)$this->cookies;
1028
+			}
974 1029
 
975 1030
 			reset($this->cookies);
976 1031
 			if ( count($this->cookies) > 0 ) {
@@ -983,21 +1038,26 @@  discard block
 block discarded – undo
983 1038
 		}
984 1039
 		if(!empty($this->rawheaders))
985 1040
 		{
986
-			if(!is_array($this->rawheaders))
987
-				$this->rawheaders = (array)$this->rawheaders;
988
-			while(list($headerKey,$headerVal) = each($this->rawheaders))
989
-				$headers[] = $headerKey.": ".$headerVal;
1041
+			if(!is_array($this->rawheaders)) {
1042
+							$this->rawheaders = (array)$this->rawheaders;
1043
+			}
1044
+			while(list($headerKey,$headerVal) = each($this->rawheaders)) {
1045
+							$headers[] = $headerKey.": ".$headerVal;
1046
+			}
990 1047
 		}
991 1048
 		if(!empty($content_type)) {
992
-			if ($content_type == "multipart/form-data")
993
-				$headers[] = "Content-type: $content_type; boundary=".$this->_mime_boundary;
994
-			else
995
-				$headers[] = "Content-type: $content_type";
1049
+			if ($content_type == "multipart/form-data") {
1050
+							$headers[] = "Content-type: $content_type; boundary=".$this->_mime_boundary;
1051
+			} else {
1052
+							$headers[] = "Content-type: $content_type";
1053
+			}
1054
+		}
1055
+		if(!empty($body)) {
1056
+					$headers[] = "Content-length: ".strlen($body);
1057
+		}
1058
+		if(!empty($this->user) || !empty($this->pass)) {
1059
+					$headers[] = "Authorization: BASIC ".base64_encode($this->user.":".$this->pass);
996 1060
 		}
997
-		if(!empty($body))
998
-			$headers[] = "Content-length: ".strlen($body);
999
-		if(!empty($this->user) || !empty($this->pass))
1000
-			$headers[] = "Authorization: BASIC ".base64_encode($this->user.":".$this->pass);
1001 1061
 
1002 1062
 		$headerfile = tempnam( $this->temp_dir, "sno" );
1003 1063
 		$cmdline_params = '-k -D ' . escapeshellarg( $headerfile );
@@ -1045,17 +1105,19 @@  discard block
 block discarded – undo
1045 1105
 					// no host in the path, so prepend
1046 1106
 					$this->_redirectaddr = $URI_PARTS["scheme"]."://".$this->host.":".$this->port;
1047 1107
 					// eliminate double slash
1048
-					if(!preg_match("|^/|",$matches[2]))
1049
-							$this->_redirectaddr .= "/".$matches[2];
1050
-					else
1051
-							$this->_redirectaddr .= $matches[2];
1108
+					if(!preg_match("|^/|",$matches[2])) {
1109
+												$this->_redirectaddr .= "/".$matches[2];
1110
+					} else {
1111
+												$this->_redirectaddr .= $matches[2];
1112
+					}
1113
+				} else {
1114
+									$this->_redirectaddr = $matches[2];
1052 1115
 				}
1053
-				else
1054
-					$this->_redirectaddr = $matches[2];
1055 1116
 			}
1056 1117
 
1057
-			if(preg_match("|^HTTP/|",$result_headers[$currentHeader]))
1058
-				$this->response_code = $result_headers[$currentHeader];
1118
+			if(preg_match("|^HTTP/|",$result_headers[$currentHeader])) {
1119
+							$this->response_code = $result_headers[$currentHeader];
1120
+			}
1059 1121
 
1060 1122
 			$this->headers[] = $result_headers[$currentHeader];
1061 1123
 		}
@@ -1071,15 +1133,18 @@  discard block
 block discarded – undo
1071 1133
 		if(($this->_framedepth < $this->maxframes) && preg_match_all("'<frame\s+.*src[\s]*=[\'\"]?([^\'\"\>]+)'i",$results,$match))
1072 1134
 		{
1073 1135
 			$this->results[] = $results;
1074
-			for($x=0; $x<count($match[1]); $x++)
1075
-				$this->_frameurls[] = $this->_expandlinks($match[1][$x],$URI_PARTS["scheme"]."://".$this->host);
1136
+			for($x=0; $x<count($match[1]); $x++) {
1137
+							$this->_frameurls[] = $this->_expandlinks($match[1][$x],$URI_PARTS["scheme"]."://".$this->host);
1138
+			}
1076 1139
 		}
1077 1140
 		// have we already fetched framed content?
1078
-		elseif(is_array($this->results))
1079
-			$this->results[] = $results;
1141
+		elseif(is_array($this->results)) {
1142
+					$this->results[] = $results;
1143
+		}
1080 1144
 		// no framed content
1081
-		else
1082
-			$this->results = $results;
1145
+		else {
1146
+					$this->results = $results;
1147
+		}
1083 1148
 
1084 1149
 		unlink("$headerfile");
1085 1150
 
@@ -1095,8 +1160,9 @@  discard block
 block discarded – undo
1095 1160
 	{
1096 1161
 		for($x=0; $x<count($this->headers); $x++)
1097 1162
 		{
1098
-		if(preg_match('/^set-cookie:[\s]+([^=]+)=([^;]+)/i', $this->headers[$x],$match))
1099
-			$this->cookies[$match[1]] = urldecode($match[2]);
1163
+		if(preg_match('/^set-cookie:[\s]+([^=]+)=([^;]+)/i', $this->headers[$x],$match)) {
1164
+					$this->cookies[$match[1]] = urldecode($match[2]);
1165
+		}
1100 1166
 		}
1101 1167
 	}
1102 1168
 
@@ -1133,8 +1199,7 @@  discard block
 block discarded – undo
1133 1199
 
1134 1200
 				$host = $this->proxy_host;
1135 1201
 				$port = $this->proxy_port;
1136
-			}
1137
-		else
1202
+			} else
1138 1203
 		{
1139 1204
 			$host = $this->host;
1140 1205
 			$port = $this->port;
@@ -1153,8 +1218,7 @@  discard block
 block discarded – undo
1153 1218
 			// socket connection succeeded
1154 1219
 
1155 1220
 			return true;
1156
-		}
1157
-		else
1221
+		} else
1158 1222
 		{
1159 1223
 			// socket connection failed
1160 1224
 			$this->status = $errno;
@@ -1198,8 +1262,9 @@  discard block
 block discarded – undo
1198 1262
 		settype($formfiles, "array");
1199 1263
 		$postdata = '';
1200 1264
 
1201
-		if (count($formvars) == 0 && count($formfiles) == 0)
1202
-			return;
1265
+		if (count($formvars) == 0 && count($formfiles) == 0) {
1266
+					return;
1267
+		}
1203 1268
 
1204 1269
 		switch ($this->_submit_type) {
1205 1270
 			case "application/x-www-form-urlencoded":
@@ -1209,8 +1274,9 @@  discard block
 block discarded – undo
1209 1274
 						while (list($cur_key, $cur_val) = each($val)) {
1210 1275
 							$postdata .= urlencode($key)."[]=".urlencode($cur_val)."&";
1211 1276
 						}
1212
-					} else
1213
-						$postdata .= urlencode($key)."=".urlencode($val)."&";
1277
+					} else {
1278
+											$postdata .= urlencode($key)."=".urlencode($val)."&";
1279
+					}
1214 1280
 				}
1215 1281
 				break;
1216 1282
 
@@ -1236,7 +1302,9 @@  discard block
 block discarded – undo
1236 1302
 				while (list($field_name, $file_names) = each($formfiles)) {
1237 1303
 					settype($file_names, "array");
1238 1304
 					while (list(, $file_name) = each($file_names)) {
1239
-						if (!is_readable($file_name)) continue;
1305
+						if (!is_readable($file_name)) {
1306
+							continue;
1307
+						}
1240 1308
 
1241 1309
 						$fp = fopen($file_name, "r");
1242 1310
 						$file_content = fread($fp, filesize($file_name));
Please login to merge, or discard this patch.
Spacing   +254 added lines, -254 removed lines patch added patch discarded remove patch
@@ -3,9 +3,9 @@  discard block
 block discarded – undo
3 3
 /**
4 4
  * Deprecated. Use WP_HTTP (http.php) instead.
5 5
  */
6
-_deprecated_file( basename( __FILE__ ), '3.0.0', WPINC . '/http.php' );
6
+_deprecated_file(basename(__FILE__), '3.0.0', WPINC.'/http.php');
7 7
 
8
-if ( ! class_exists( 'Snoopy', false ) ) :
8
+if ( ! class_exists('Snoopy', false)) :
9 9
 /*************************************************
10 10
 
11 11
 Snoopy - the PHP net client
@@ -41,54 +41,54 @@  discard block
 block discarded – undo
41 41
 
42 42
 	/* user definable vars */
43 43
 
44
-	var $host			=	"www.php.net";		// host name we are connecting to
45
-	var $port			=	80;					// port we are connecting to
46
-	var $proxy_host		=	"";					// proxy host to use
47
-	var $proxy_port		=	"";					// proxy port to use
48
-	var $proxy_user		=	"";					// proxy user to use
49
-	var $proxy_pass		=	"";					// proxy password to use
44
+	var $host			= "www.php.net"; // host name we are connecting to
45
+	var $port			= 80; // port we are connecting to
46
+	var $proxy_host		= ""; // proxy host to use
47
+	var $proxy_port		= ""; // proxy port to use
48
+	var $proxy_user		= ""; // proxy user to use
49
+	var $proxy_pass		= ""; // proxy password to use
50 50
 
51
-	var $agent			=	"Snoopy v1.2.4";	// agent we masquerade as
52
-	var	$referer		=	"";					// referer info to pass
53
-	var $cookies		=	array();			// array of cookies to pass
51
+	var $agent = "Snoopy v1.2.4"; // agent we masquerade as
52
+	var	$referer		= ""; // referer info to pass
53
+	var $cookies		= array(); // array of cookies to pass
54 54
 												// $cookies["username"]="joe";
55
-	var	$rawheaders		=	array();			// array of raw headers to send
55
+	var	$rawheaders = array(); // array of raw headers to send
56 56
 												// $rawheaders["Content-type"]="text/html";
57 57
 
58
-	var $maxredirs		=	5;					// http redirection depth maximum. 0 = disallow
59
-	var $lastredirectaddr	=	"";				// contains address of last redirected address
60
-	var	$offsiteok		=	true;				// allows redirection off-site
61
-	var $maxframes		=	0;					// frame content depth maximum. 0 = disallow
62
-	var $expandlinks	=	true;				// expand links to fully qualified URLs.
58
+	var $maxredirs		= 5; // http redirection depth maximum. 0 = disallow
59
+	var $lastredirectaddr = ""; // contains address of last redirected address
60
+	var	$offsiteok		= true; // allows redirection off-site
61
+	var $maxframes		= 0; // frame content depth maximum. 0 = disallow
62
+	var $expandlinks	= true; // expand links to fully qualified URLs.
63 63
 												// this only applies to fetchlinks()
64 64
 												// submitlinks(), and submittext()
65
-	var $passcookies	=	true;				// pass set cookies back through redirects
65
+	var $passcookies	= true; // pass set cookies back through redirects
66 66
 												// NOTE: this currently does not respect
67 67
 												// dates, domains or paths.
68 68
 
69
-	var	$user			=	"";					// user for http authentication
70
-	var	$pass			=	"";					// password for http authentication
69
+	var	$user			= ""; // user for http authentication
70
+	var	$pass			= ""; // password for http authentication
71 71
 
72 72
 	// http accept types
73
-	var $accept			=	"image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, */*";
73
+	var $accept			= "image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, */*";
74 74
 
75
-	var $results		=	"";					// where the content is put
75
+	var $results		= ""; // where the content is put
76 76
 
77
-	var $error			=	"";					// error messages sent here
78
-	var	$response_code	=	"";					// response code returned from server
79
-	var	$headers		=	array();			// headers returned from server sent here
80
-	var	$maxlength		=	500000;				// max return data length (body)
81
-	var $read_timeout	=	0;					// timeout on read operations, in seconds
77
+	var $error = ""; // error messages sent here
78
+	var	$response_code = ""; // response code returned from server
79
+	var	$headers = array(); // headers returned from server sent here
80
+	var	$maxlength = 500000; // max return data length (body)
81
+	var $read_timeout = 0; // timeout on read operations, in seconds
82 82
 												// supported only since PHP 4 Beta 4
83 83
 												// set to 0 to disallow timeouts
84
-	var $timed_out		=	false;				// if a read operation timed out
85
-	var	$status			=	0;					// http request status
84
+	var $timed_out = false; // if a read operation timed out
85
+	var	$status = 0; // http request status
86 86
 
87
-	var $temp_dir		=	"/tmp";				// temporary directory that the webserver
87
+	var $temp_dir = "/tmp"; // temporary directory that the webserver
88 88
 												// has permission to write to.
89 89
 												// under Windows, this should be C:\temp
90 90
 
91
-	var	$curl_path		=	"/usr/local/bin/curl";
91
+	var	$curl_path = "/usr/local/bin/curl";
92 92
 												// Snoopy will use cURL for fetching
93 93
 												// SSL content if a full system path to
94 94
 												// the cURL binary is supplied here.
@@ -102,20 +102,20 @@  discard block
 block discarded – undo
102 102
 
103 103
 	/**** Private variables ****/
104 104
 
105
-	var	$_maxlinelen	=	4096;				// max line length (headers)
105
+	var	$_maxlinelen	= 4096; // max line length (headers)
106 106
 
107
-	var $_httpmethod	=	"GET";				// default http request method
108
-	var $_httpversion	=	"HTTP/1.0";			// default http request version
109
-	var $_submit_method	=	"POST";				// default submit method
110
-	var $_submit_type	=	"application/x-www-form-urlencoded";	// default submit type
111
-	var $_mime_boundary	=   "";					// MIME boundary for multipart/form-data submit type
112
-	var $_redirectaddr	=	false;				// will be set if page fetched is a redirect
113
-	var $_redirectdepth	=	0;					// increments on an http redirect
114
-	var $_frameurls		= 	array();			// frame src urls
115
-	var $_framedepth	=	0;					// increments on frame depth
107
+	var $_httpmethod	= "GET"; // default http request method
108
+	var $_httpversion	= "HTTP/1.0"; // default http request version
109
+	var $_submit_method	= "POST"; // default submit method
110
+	var $_submit_type	= "application/x-www-form-urlencoded"; // default submit type
111
+	var $_mime_boundary	= ""; // MIME boundary for multipart/form-data submit type
112
+	var $_redirectaddr = false; // will be set if page fetched is a redirect
113
+	var $_redirectdepth	= 0; // increments on an http redirect
114
+	var $_frameurls		= array(); // frame src urls
115
+	var $_framedepth	= 0; // increments on frame depth
116 116
 
117
-	var $_isproxy		=	false;				// set if using a proxy server
118
-	var $_fp_timeout	=	30;					// timeout for socket connection
117
+	var $_isproxy = false; // set if using a proxy server
118
+	var $_fp_timeout	= 30; // timeout for socket connection
119 119
 
120 120
 /*======================================================================*\
121 121
 	Function:	fetch
@@ -131,27 +131,27 @@  discard block
 block discarded – undo
131 131
 
132 132
 		//preg_match("|^([^:]+)://([^:/]+)(:[\d]+)*(.*)|",$URI,$URI_PARTS);
133 133
 		$URI_PARTS = parse_url($URI);
134
-		if (!empty($URI_PARTS["user"]))
134
+		if ( ! empty($URI_PARTS["user"]))
135 135
 			$this->user = $URI_PARTS["user"];
136
-		if (!empty($URI_PARTS["pass"]))
136
+		if ( ! empty($URI_PARTS["pass"]))
137 137
 			$this->pass = $URI_PARTS["pass"];
138 138
 		if (empty($URI_PARTS["query"]))
139 139
 			$URI_PARTS["query"] = '';
140 140
 		if (empty($URI_PARTS["path"]))
141 141
 			$URI_PARTS["path"] = '';
142 142
 
143
-		switch(strtolower($URI_PARTS["scheme"]))
143
+		switch (strtolower($URI_PARTS["scheme"]))
144 144
 		{
145 145
 			case "http":
146 146
 				$this->host = $URI_PARTS["host"];
147
-				if(!empty($URI_PARTS["port"]))
147
+				if ( ! empty($URI_PARTS["port"]))
148 148
 					$this->port = $URI_PARTS["port"];
149
-				if($this->_connect($fp))
149
+				if ($this->_connect($fp))
150 150
 				{
151
-					if($this->_isproxy)
151
+					if ($this->_isproxy)
152 152
 					{
153 153
 						// using proxy, send entire URI
154
-						$this->_httprequest($URI,$fp,$URI,$this->_httpmethod);
154
+						$this->_httprequest($URI, $fp, $URI, $this->_httpmethod);
155 155
 					}
156 156
 					else
157 157
 					{
@@ -162,30 +162,30 @@  discard block
 block discarded – undo
162 162
 
163 163
 					$this->_disconnect($fp);
164 164
 
165
-					if($this->_redirectaddr)
165
+					if ($this->_redirectaddr)
166 166
 					{
167 167
 						/* url was redirected, check if we've hit the max depth */
168
-						if($this->maxredirs > $this->_redirectdepth)
168
+						if ($this->maxredirs > $this->_redirectdepth)
169 169
 						{
170 170
 							// only follow redirect if it's on this site, or offsiteok is true
171
-							if(preg_match("|^http://".preg_quote($this->host)."|i",$this->_redirectaddr) || $this->offsiteok)
171
+							if (preg_match("|^http://".preg_quote($this->host)."|i", $this->_redirectaddr) || $this->offsiteok)
172 172
 							{
173 173
 								/* follow the redirect */
174 174
 								$this->_redirectdepth++;
175
-								$this->lastredirectaddr=$this->_redirectaddr;
175
+								$this->lastredirectaddr = $this->_redirectaddr;
176 176
 								$this->fetch($this->_redirectaddr);
177 177
 							}
178 178
 						}
179 179
 					}
180 180
 
181
-					if($this->_framedepth < $this->maxframes && count($this->_frameurls) > 0)
181
+					if ($this->_framedepth < $this->maxframes && count($this->_frameurls) > 0)
182 182
 					{
183 183
 						$frameurls = $this->_frameurls;
184 184
 						$this->_frameurls = array();
185 185
 
186
-						while(list(,$frameurl) = each($frameurls))
186
+						while (list(,$frameurl) = each($frameurls))
187 187
 						{
188
-							if($this->_framedepth < $this->maxframes)
188
+							if ($this->_framedepth < $this->maxframes)
189 189
 							{
190 190
 								$this->fetch($frameurl);
191 191
 								$this->_framedepth++;
@@ -202,18 +202,18 @@  discard block
 block discarded – undo
202 202
 				return true;
203 203
 				break;
204 204
 			case "https":
205
-				if(!$this->curl_path)
205
+				if ( ! $this->curl_path)
206 206
 					return false;
207
-				if(function_exists("is_executable"))
208
-				    if (!is_executable($this->curl_path))
207
+				if (function_exists("is_executable"))
208
+				    if ( ! is_executable($this->curl_path))
209 209
 				        return false;
210 210
 				$this->host = $URI_PARTS["host"];
211
-				if(!empty($URI_PARTS["port"]))
211
+				if ( ! empty($URI_PARTS["port"]))
212 212
 					$this->port = $URI_PARTS["port"];
213
-				if($this->_isproxy)
213
+				if ($this->_isproxy)
214 214
 				{
215 215
 					// using proxy, send entire URI
216
-					$this->_httpsrequest($URI,$URI,$this->_httpmethod);
216
+					$this->_httpsrequest($URI, $URI, $this->_httpmethod);
217 217
 				}
218 218
 				else
219 219
 				{
@@ -222,30 +222,30 @@  discard block
 block discarded – undo
222 222
 					$this->_httpsrequest($path, $URI, $this->_httpmethod);
223 223
 				}
224 224
 
225
-				if($this->_redirectaddr)
225
+				if ($this->_redirectaddr)
226 226
 				{
227 227
 					/* url was redirected, check if we've hit the max depth */
228
-					if($this->maxredirs > $this->_redirectdepth)
228
+					if ($this->maxredirs > $this->_redirectdepth)
229 229
 					{
230 230
 						// only follow redirect if it's on this site, or offsiteok is true
231
-						if(preg_match("|^http://".preg_quote($this->host)."|i",$this->_redirectaddr) || $this->offsiteok)
231
+						if (preg_match("|^http://".preg_quote($this->host)."|i", $this->_redirectaddr) || $this->offsiteok)
232 232
 						{
233 233
 							/* follow the redirect */
234 234
 							$this->_redirectdepth++;
235
-							$this->lastredirectaddr=$this->_redirectaddr;
235
+							$this->lastredirectaddr = $this->_redirectaddr;
236 236
 							$this->fetch($this->_redirectaddr);
237 237
 						}
238 238
 					}
239 239
 				}
240 240
 
241
-				if($this->_framedepth < $this->maxframes && count($this->_frameurls) > 0)
241
+				if ($this->_framedepth < $this->maxframes && count($this->_frameurls) > 0)
242 242
 				{
243 243
 					$frameurls = $this->_frameurls;
244 244
 					$this->_frameurls = array();
245 245
 
246
-					while(list(,$frameurl) = each($frameurls))
246
+					while (list(,$frameurl) = each($frameurls))
247 247
 					{
248
-						if($this->_framedepth < $this->maxframes)
248
+						if ($this->_framedepth < $this->maxframes)
249 249
 						{
250 250
 							$this->fetch($frameurl);
251 251
 							$this->_framedepth++;
@@ -258,7 +258,7 @@  discard block
 block discarded – undo
258 258
 				break;
259 259
 			default:
260 260
 				// not a valid protocol
261
-				$this->error	=	'Invalid protocol "'.$URI_PARTS["scheme"].'"\n';
261
+				$this->error = 'Invalid protocol "'.$URI_PARTS["scheme"].'"\n';
262 262
 				return false;
263 263
 				break;
264 264
 		}
@@ -276,34 +276,34 @@  discard block
 block discarded – undo
276 276
 	Output:		$this->results	the text output from the post
277 277
 \*======================================================================*/
278 278
 
279
-	function submit($URI, $formvars="", $formfiles="")
279
+	function submit($URI, $formvars = "", $formfiles = "")
280 280
 	{
281 281
 		unset($postdata);
282 282
 
283 283
 		$postdata = $this->_prepare_post_body($formvars, $formfiles);
284 284
 
285 285
 		$URI_PARTS = parse_url($URI);
286
-		if (!empty($URI_PARTS["user"]))
286
+		if ( ! empty($URI_PARTS["user"]))
287 287
 			$this->user = $URI_PARTS["user"];
288
-		if (!empty($URI_PARTS["pass"]))
288
+		if ( ! empty($URI_PARTS["pass"]))
289 289
 			$this->pass = $URI_PARTS["pass"];
290 290
 		if (empty($URI_PARTS["query"]))
291 291
 			$URI_PARTS["query"] = '';
292 292
 		if (empty($URI_PARTS["path"]))
293 293
 			$URI_PARTS["path"] = '';
294 294
 
295
-		switch(strtolower($URI_PARTS["scheme"]))
295
+		switch (strtolower($URI_PARTS["scheme"]))
296 296
 		{
297 297
 			case "http":
298 298
 				$this->host = $URI_PARTS["host"];
299
-				if(!empty($URI_PARTS["port"]))
299
+				if ( ! empty($URI_PARTS["port"]))
300 300
 					$this->port = $URI_PARTS["port"];
301
-				if($this->_connect($fp))
301
+				if ($this->_connect($fp))
302 302
 				{
303
-					if($this->_isproxy)
303
+					if ($this->_isproxy)
304 304
 					{
305 305
 						// using proxy, send entire URI
306
-						$this->_httprequest($URI,$fp,$URI,$this->_submit_method,$this->_submit_type,$postdata);
306
+						$this->_httprequest($URI, $fp, $URI, $this->_submit_method, $this->_submit_type, $postdata);
307 307
 					}
308 308
 					else
309 309
 					{
@@ -314,36 +314,36 @@  discard block
 block discarded – undo
314 314
 
315 315
 					$this->_disconnect($fp);
316 316
 
317
-					if($this->_redirectaddr)
317
+					if ($this->_redirectaddr)
318 318
 					{
319 319
 						/* url was redirected, check if we've hit the max depth */
320
-						if($this->maxredirs > $this->_redirectdepth)
320
+						if ($this->maxredirs > $this->_redirectdepth)
321 321
 						{
322
-							if(!preg_match("|^".$URI_PARTS["scheme"]."://|", $this->_redirectaddr))
323
-								$this->_redirectaddr = $this->_expandlinks($this->_redirectaddr,$URI_PARTS["scheme"]."://".$URI_PARTS["host"]);
322
+							if ( ! preg_match("|^".$URI_PARTS["scheme"]."://|", $this->_redirectaddr))
323
+								$this->_redirectaddr = $this->_expandlinks($this->_redirectaddr, $URI_PARTS["scheme"]."://".$URI_PARTS["host"]);
324 324
 
325 325
 							// only follow redirect if it's on this site, or offsiteok is true
326
-							if(preg_match("|^http://".preg_quote($this->host)."|i",$this->_redirectaddr) || $this->offsiteok)
326
+							if (preg_match("|^http://".preg_quote($this->host)."|i", $this->_redirectaddr) || $this->offsiteok)
327 327
 							{
328 328
 								/* follow the redirect */
329 329
 								$this->_redirectdepth++;
330
-								$this->lastredirectaddr=$this->_redirectaddr;
331
-								if( strpos( $this->_redirectaddr, "?" ) > 0 )
330
+								$this->lastredirectaddr = $this->_redirectaddr;
331
+								if (strpos($this->_redirectaddr, "?") > 0)
332 332
 									$this->fetch($this->_redirectaddr); // the redirect has changed the request method from post to get
333 333
 								else
334
-									$this->submit($this->_redirectaddr,$formvars, $formfiles);
334
+									$this->submit($this->_redirectaddr, $formvars, $formfiles);
335 335
 							}
336 336
 						}
337 337
 					}
338 338
 
339
-					if($this->_framedepth < $this->maxframes && count($this->_frameurls) > 0)
339
+					if ($this->_framedepth < $this->maxframes && count($this->_frameurls) > 0)
340 340
 					{
341 341
 						$frameurls = $this->_frameurls;
342 342
 						$this->_frameurls = array();
343 343
 
344
-						while(list(,$frameurl) = each($frameurls))
344
+						while (list(,$frameurl) = each($frameurls))
345 345
 						{
346
-							if($this->_framedepth < $this->maxframes)
346
+							if ($this->_framedepth < $this->maxframes)
347 347
 							{
348 348
 								$this->fetch($frameurl);
349 349
 								$this->_framedepth++;
@@ -361,15 +361,15 @@  discard block
 block discarded – undo
361 361
 				return true;
362 362
 				break;
363 363
 			case "https":
364
-				if(!$this->curl_path)
364
+				if ( ! $this->curl_path)
365 365
 					return false;
366
-				if(function_exists("is_executable"))
367
-				    if (!is_executable($this->curl_path))
366
+				if (function_exists("is_executable"))
367
+				    if ( ! is_executable($this->curl_path))
368 368
 				        return false;
369 369
 				$this->host = $URI_PARTS["host"];
370
-				if(!empty($URI_PARTS["port"]))
370
+				if ( ! empty($URI_PARTS["port"]))
371 371
 					$this->port = $URI_PARTS["port"];
372
-				if($this->_isproxy)
372
+				if ($this->_isproxy)
373 373
 				{
374 374
 					// using proxy, send entire URI
375 375
 					$this->_httpsrequest($URI, $URI, $this->_submit_method, $this->_submit_type, $postdata);
@@ -381,36 +381,36 @@  discard block
 block discarded – undo
381 381
 					$this->_httpsrequest($path, $URI, $this->_submit_method, $this->_submit_type, $postdata);
382 382
 				}
383 383
 
384
-				if($this->_redirectaddr)
384
+				if ($this->_redirectaddr)
385 385
 				{
386 386
 					/* url was redirected, check if we've hit the max depth */
387
-					if($this->maxredirs > $this->_redirectdepth)
387
+					if ($this->maxredirs > $this->_redirectdepth)
388 388
 					{
389
-						if(!preg_match("|^".$URI_PARTS["scheme"]."://|", $this->_redirectaddr))
390
-							$this->_redirectaddr = $this->_expandlinks($this->_redirectaddr,$URI_PARTS["scheme"]."://".$URI_PARTS["host"]);
389
+						if ( ! preg_match("|^".$URI_PARTS["scheme"]."://|", $this->_redirectaddr))
390
+							$this->_redirectaddr = $this->_expandlinks($this->_redirectaddr, $URI_PARTS["scheme"]."://".$URI_PARTS["host"]);
391 391
 
392 392
 						// only follow redirect if it's on this site, or offsiteok is true
393
-						if(preg_match("|^http://".preg_quote($this->host)."|i",$this->_redirectaddr) || $this->offsiteok)
393
+						if (preg_match("|^http://".preg_quote($this->host)."|i", $this->_redirectaddr) || $this->offsiteok)
394 394
 						{
395 395
 							/* follow the redirect */
396 396
 							$this->_redirectdepth++;
397
-							$this->lastredirectaddr=$this->_redirectaddr;
398
-							if( strpos( $this->_redirectaddr, "?" ) > 0 )
397
+							$this->lastredirectaddr = $this->_redirectaddr;
398
+							if (strpos($this->_redirectaddr, "?") > 0)
399 399
 								$this->fetch($this->_redirectaddr); // the redirect has changed the request method from post to get
400 400
 							else
401
-								$this->submit($this->_redirectaddr,$formvars, $formfiles);
401
+								$this->submit($this->_redirectaddr, $formvars, $formfiles);
402 402
 						}
403 403
 					}
404 404
 				}
405 405
 
406
-				if($this->_framedepth < $this->maxframes && count($this->_frameurls) > 0)
406
+				if ($this->_framedepth < $this->maxframes && count($this->_frameurls) > 0)
407 407
 				{
408 408
 					$frameurls = $this->_frameurls;
409 409
 					$this->_frameurls = array();
410 410
 
411
-					while(list(,$frameurl) = each($frameurls))
411
+					while (list(,$frameurl) = each($frameurls))
412 412
 					{
413
-						if($this->_framedepth < $this->maxframes)
413
+						if ($this->_framedepth < $this->maxframes)
414 414
 						{
415 415
 							$this->fetch($frameurl);
416 416
 							$this->_framedepth++;
@@ -424,7 +424,7 @@  discard block
 block discarded – undo
424 424
 
425 425
 			default:
426 426
 				// not a valid protocol
427
-				$this->error	=	'Invalid protocol "'.$URI_PARTS["scheme"].'"\n';
427
+				$this->error = 'Invalid protocol "'.$URI_PARTS["scheme"].'"\n';
428 428
 				return false;
429 429
 				break;
430 430
 		}
@@ -442,17 +442,17 @@  discard block
 block discarded – undo
442 442
 	{
443 443
 		if ($this->fetch($URI))
444 444
 		{
445
-			if($this->lastredirectaddr)
445
+			if ($this->lastredirectaddr)
446 446
 				$URI = $this->lastredirectaddr;
447
-			if(is_array($this->results))
447
+			if (is_array($this->results))
448 448
 			{
449
-				for($x=0;$x<count($this->results);$x++)
449
+				for ($x = 0; $x < count($this->results); $x++)
450 450
 					$this->results[$x] = $this->_striplinks($this->results[$x]);
451 451
 			}
452 452
 			else
453 453
 				$this->results = $this->_striplinks($this->results);
454 454
 
455
-			if($this->expandlinks)
455
+			if ($this->expandlinks)
456 456
 				$this->results = $this->_expandlinks($this->results, $URI);
457 457
 			return true;
458 458
 		}
@@ -473,9 +473,9 @@  discard block
 block discarded – undo
473 473
 		if ($this->fetch($URI))
474 474
 		{
475 475
 
476
-			if(is_array($this->results))
476
+			if (is_array($this->results))
477 477
 			{
478
-				for($x=0;$x<count($this->results);$x++)
478
+				for ($x = 0; $x < count($this->results); $x++)
479 479
 					$this->results[$x] = $this->_stripform($this->results[$x]);
480 480
 			}
481 481
 			else
@@ -497,11 +497,11 @@  discard block
 block discarded – undo
497 497
 
498 498
 	function fetchtext($URI)
499 499
 	{
500
-		if($this->fetch($URI))
500
+		if ($this->fetch($URI))
501 501
 		{
502
-			if(is_array($this->results))
502
+			if (is_array($this->results))
503 503
 			{
504
-				for($x=0;$x<count($this->results);$x++)
504
+				for ($x = 0; $x < count($this->results); $x++)
505 505
 					$this->results[$x] = $this->_striptext($this->results[$x]);
506 506
 			}
507 507
 			else
@@ -519,26 +519,26 @@  discard block
 block discarded – undo
519 519
 	Output:		$this->results	an array of the links from the post
520 520
 \*======================================================================*/
521 521
 
522
-	function submitlinks($URI, $formvars="", $formfiles="")
522
+	function submitlinks($URI, $formvars = "", $formfiles = "")
523 523
 	{
524
-		if($this->submit($URI,$formvars, $formfiles))
524
+		if ($this->submit($URI, $formvars, $formfiles))
525 525
 		{
526
-			if($this->lastredirectaddr)
526
+			if ($this->lastredirectaddr)
527 527
 				$URI = $this->lastredirectaddr;
528
-			if(is_array($this->results))
528
+			if (is_array($this->results))
529 529
 			{
530
-				for($x=0;$x<count($this->results);$x++)
530
+				for ($x = 0; $x < count($this->results); $x++)
531 531
 				{
532 532
 					$this->results[$x] = $this->_striplinks($this->results[$x]);
533
-					if($this->expandlinks)
534
-						$this->results[$x] = $this->_expandlinks($this->results[$x],$URI);
533
+					if ($this->expandlinks)
534
+						$this->results[$x] = $this->_expandlinks($this->results[$x], $URI);
535 535
 				}
536 536
 			}
537 537
 			else
538 538
 			{
539 539
 				$this->results = $this->_striplinks($this->results);
540
-				if($this->expandlinks)
541
-					$this->results = $this->_expandlinks($this->results,$URI);
540
+				if ($this->expandlinks)
541
+					$this->results = $this->_expandlinks($this->results, $URI);
542 542
 			}
543 543
 			return true;
544 544
 		}
@@ -555,24 +555,24 @@  discard block
 block discarded – undo
555 555
 
556 556
 	function submittext($URI, $formvars = "", $formfiles = "")
557 557
 	{
558
-		if($this->submit($URI,$formvars, $formfiles))
558
+		if ($this->submit($URI, $formvars, $formfiles))
559 559
 		{
560
-			if($this->lastredirectaddr)
560
+			if ($this->lastredirectaddr)
561 561
 				$URI = $this->lastredirectaddr;
562
-			if(is_array($this->results))
562
+			if (is_array($this->results))
563 563
 			{
564
-				for($x=0;$x<count($this->results);$x++)
564
+				for ($x = 0; $x < count($this->results); $x++)
565 565
 				{
566 566
 					$this->results[$x] = $this->_striptext($this->results[$x]);
567
-					if($this->expandlinks)
568
-						$this->results[$x] = $this->_expandlinks($this->results[$x],$URI);
567
+					if ($this->expandlinks)
568
+						$this->results[$x] = $this->_expandlinks($this->results[$x], $URI);
569 569
 				}
570 570
 			}
571 571
 			else
572 572
 			{
573 573
 				$this->results = $this->_striptext($this->results);
574
-				if($this->expandlinks)
575
-					$this->results = $this->_expandlinks($this->results,$URI);
574
+				if ($this->expandlinks)
575
+					$this->results = $this->_expandlinks($this->results, $URI);
576 576
 			}
577 577
 			return true;
578 578
 		}
@@ -624,20 +624,20 @@  discard block
 block discarded – undo
624 624
 						([\"\'])?					# find single or double quote
625 625
 						(?(1) (.*?)\\1 | ([^\s\>]+))		# if quote found, match up to next matching
626 626
 													# quote, otherwise match up to next space
627
-						'isx",$document,$links);
627
+						'isx",$document, $links);
628 628
 
629 629
 
630 630
 		// catenate the non-empty matches from the conditional subpattern
631 631
 
632
-		while(list($key,$val) = each($links[2]))
632
+		while (list($key, $val) = each($links[2]))
633 633
 		{
634
-			if(!empty($val))
634
+			if ( ! empty($val))
635 635
 				$match[] = $val;
636 636
 		}
637 637
 
638
-		while(list($key,$val) = each($links[3]))
638
+		while (list($key, $val) = each($links[3]))
639 639
 		{
640
-			if(!empty($val))
640
+			if ( ! empty($val))
641 641
 				$match[] = $val;
642 642
 		}
643 643
 
@@ -654,10 +654,10 @@  discard block
 block discarded – undo
654 654
 
655 655
 	function _stripform($document)
656 656
 	{
657
-		preg_match_all("'<\/?(FORM|INPUT|SELECT|TEXTAREA|(OPTION))[^<>]*>(?(2)(.*(?=<\/?(option|select)[^<>]*>[\r\n]*)|(?=[\r\n]*))|(?=[\r\n]*))'Usi",$document,$elements);
657
+		preg_match_all("'<\/?(FORM|INPUT|SELECT|TEXTAREA|(OPTION))[^<>]*>(?(2)(.*(?=<\/?(option|select)[^<>]*>[\r\n]*)|(?=[\r\n]*))|(?=[\r\n]*))'Usi", $document, $elements);
658 658
 
659 659
 		// catenate the matches
660
-		$match = implode("\r\n",$elements[0]);
660
+		$match = implode("\r\n", $elements[0]);
661 661
 
662 662
 		// return the links
663 663
 		return $match;
@@ -679,11 +679,11 @@  discard block
 block discarded – undo
679 679
 		// so, list your entities one by one here. I included some of the
680 680
 		// more common ones.
681 681
 
682
-		$search = array("'<script[^>]*?>.*?</script>'si",	// strip out javascript
683
-						"'<[\/\!]*?[^<>]*?>'si",			// strip out html tags
684
-						"'([\r\n])[\s]+'",					// strip out white space
685
-						"'&(quot|#34|#034|#x22);'i",		// replace html entities
686
-						"'&(amp|#38|#038|#x26);'i",			// added hexadecimal values
682
+		$search = array("'<script[^>]*?>.*?</script>'si", // strip out javascript
683
+						"'<[\/\!]*?[^<>]*?>'si", // strip out html tags
684
+						"'([\r\n])[\s]+'", // strip out white space
685
+						"'&(quot|#34|#034|#x22);'i", // replace html entities
686
+						"'&(amp|#38|#038|#x26);'i", // added hexadecimal values
687 687
 						"'&(lt|#60|#060|#x3c);'i",
688 688
 						"'&(gt|#62|#062|#x3e);'i",
689 689
 						"'&(nbsp|#160|#xa0);'i",
@@ -694,8 +694,8 @@  discard block
 block discarded – undo
694 694
 						"'&(reg|#174);'i",
695 695
 						"'&(deg|#176);'i",
696 696
 						"'&(#39|#039|#x27);'",
697
-						"'&(euro|#8364);'i",				// europe
698
-						"'&a(uml|UML);'",					// german
697
+						"'&(euro|#8364);'i", // europe
698
+						"'&a(uml|UML);'", // german
699 699
 						"'&o(uml|UML);'",
700 700
 						"'&u(uml|UML);'",
701 701
 						"'&A(uml|UML);'",
@@ -703,7 +703,7 @@  discard block
 block discarded – undo
703 703
 						"'&U(uml|UML);'",
704 704
 						"'&szlig;'i",
705 705
 						);
706
-		$replace = array(	"",
706
+		$replace = array("",
707 707
 							"",
708 708
 							"\\1",
709 709
 							"\"",
@@ -728,7 +728,7 @@  discard block
 block discarded – undo
728 728
 							chr(0xDF), // ANSI &szlig;
729 729
 						);
730 730
 
731
-		$text = preg_replace($search,$replace,$document);
731
+		$text = preg_replace($search, $replace, $document);
732 732
 
733 733
 		return $text;
734 734
 	}
@@ -741,32 +741,32 @@  discard block
 block discarded – undo
741 741
 	Output:		$expandedLinks	the expanded links
742 742
 \*======================================================================*/
743 743
 
744
-	function _expandlinks($links,$URI)
744
+	function _expandlinks($links, $URI)
745 745
 	{
746 746
 
747
-		preg_match("/^[^\?]+/",$URI,$match);
747
+		preg_match("/^[^\?]+/", $URI, $match);
748 748
 
749
-		$match = preg_replace("|/[^\/\.]+\.[^\/\.]+$|","",$match[0]);
750
-		$match = preg_replace("|/$|","",$match);
749
+		$match = preg_replace("|/[^\/\.]+\.[^\/\.]+$|", "", $match[0]);
750
+		$match = preg_replace("|/$|", "", $match);
751 751
 		$match_part = parse_url($match);
752 752
 		$match_root =
753 753
 		$match_part["scheme"]."://".$match_part["host"];
754 754
 
755
-		$search = array( 	"|^http://".preg_quote($this->host)."|i",
755
+		$search = array("|^http://".preg_quote($this->host)."|i",
756 756
 							"|^(\/)|i",
757 757
 							"|^(?!http://)(?!mailto:)|i",
758 758
 							"|/\./|",
759 759
 							"|/[^\/]+/\.\./|"
760 760
 						);
761 761
 
762
-		$replace = array(	"",
762
+		$replace = array("",
763 763
 							$match_root."/",
764 764
 							$match."/",
765 765
 							"/",
766 766
 							"/"
767 767
 						);
768 768
 
769
-		$expandedLinks = preg_replace($search,$replace,$links);
769
+		$expandedLinks = preg_replace($search, $replace, $links);
770 770
 
771 771
 		return $expandedLinks;
772 772
 	}
@@ -781,63 +781,63 @@  discard block
 block discarded – undo
781 781
 	Output:
782 782
 \*======================================================================*/
783 783
 
784
-	function _httprequest($url,$fp,$URI,$http_method,$content_type="",$body="")
784
+	function _httprequest($url, $fp, $URI, $http_method, $content_type = "", $body = "")
785 785
 	{
786 786
 		$cookie_headers = '';
787
-		if($this->passcookies && $this->_redirectaddr)
787
+		if ($this->passcookies && $this->_redirectaddr)
788 788
 			$this->setcookies();
789 789
 
790 790
 		$URI_PARTS = parse_url($URI);
791
-		if(empty($url))
791
+		if (empty($url))
792 792
 			$url = "/";
793 793
 		$headers = $http_method." ".$url." ".$this->_httpversion."\r\n";
794
-		if(!empty($this->agent))
794
+		if ( ! empty($this->agent))
795 795
 			$headers .= "User-Agent: ".$this->agent."\r\n";
796
-		if(!empty($this->host) && !isset($this->rawheaders['Host'])) {
796
+		if ( ! empty($this->host) && ! isset($this->rawheaders['Host'])) {
797 797
 			$headers .= "Host: ".$this->host;
798
-			if(!empty($this->port) && $this->port != 80)
798
+			if ( ! empty($this->port) && $this->port != 80)
799 799
 				$headers .= ":".$this->port;
800 800
 			$headers .= "\r\n";
801 801
 		}
802
-		if(!empty($this->accept))
802
+		if ( ! empty($this->accept))
803 803
 			$headers .= "Accept: ".$this->accept."\r\n";
804
-		if(!empty($this->referer))
804
+		if ( ! empty($this->referer))
805 805
 			$headers .= "Referer: ".$this->referer."\r\n";
806
-		if(!empty($this->cookies))
806
+		if ( ! empty($this->cookies))
807 807
 		{
808
-			if(!is_array($this->cookies))
809
-				$this->cookies = (array)$this->cookies;
808
+			if ( ! is_array($this->cookies))
809
+				$this->cookies = (array) $this->cookies;
810 810
 
811 811
 			reset($this->cookies);
812
-			if ( count($this->cookies) > 0 ) {
812
+			if (count($this->cookies) > 0) {
813 813
 				$cookie_headers .= 'Cookie: ';
814
-				foreach ( $this->cookies as $cookieKey => $cookieVal ) {
814
+				foreach ($this->cookies as $cookieKey => $cookieVal) {
815 815
 				$cookie_headers .= $cookieKey."=".urlencode($cookieVal)."; ";
816 816
 				}
817
-				$headers .= substr($cookie_headers,0,-2) . "\r\n";
817
+				$headers .= substr($cookie_headers, 0, -2)."\r\n";
818 818
 			}
819 819
 		}
820
-		if(!empty($this->rawheaders))
820
+		if ( ! empty($this->rawheaders))
821 821
 		{
822
-			if(!is_array($this->rawheaders))
823
-				$this->rawheaders = (array)$this->rawheaders;
824
-			while(list($headerKey,$headerVal) = each($this->rawheaders))
822
+			if ( ! is_array($this->rawheaders))
823
+				$this->rawheaders = (array) $this->rawheaders;
824
+			while (list($headerKey, $headerVal) = each($this->rawheaders))
825 825
 				$headers .= $headerKey.": ".$headerVal."\r\n";
826 826
 		}
827
-		if(!empty($content_type)) {
827
+		if ( ! empty($content_type)) {
828 828
 			$headers .= "Content-type: $content_type";
829 829
 			if ($content_type == "multipart/form-data")
830 830
 				$headers .= "; boundary=".$this->_mime_boundary;
831 831
 			$headers .= "\r\n";
832 832
 		}
833
-		if(!empty($body))
833
+		if ( ! empty($body))
834 834
 			$headers .= "Content-length: ".strlen($body)."\r\n";
835
-		if(!empty($this->user) || !empty($this->pass))
835
+		if ( ! empty($this->user) || ! empty($this->pass))
836 836
 			$headers .= "Authorization: Basic ".base64_encode($this->user.":".$this->pass)."\r\n";
837 837
 
838 838
 		//add proxy auth headers
839
-		if(!empty($this->proxy_user))
840
-			$headers .= 'Proxy-Authorization: ' . 'Basic ' . base64_encode($this->proxy_user . ':' . $this->proxy_pass)."\r\n";
839
+		if ( ! empty($this->proxy_user))
840
+			$headers .= 'Proxy-Authorization: '.'Basic '.base64_encode($this->proxy_user.':'.$this->proxy_pass)."\r\n";
841 841
 
842 842
 
843 843
 		$headers .= "\r\n";
@@ -847,34 +847,34 @@  discard block
 block discarded – undo
847 847
 			socket_set_timeout($fp, $this->read_timeout);
848 848
 		$this->timed_out = false;
849 849
 
850
-		fwrite($fp,$headers.$body,strlen($headers.$body));
850
+		fwrite($fp, $headers.$body, strlen($headers.$body));
851 851
 
852 852
 		$this->_redirectaddr = false;
853 853
 		unset($this->headers);
854 854
 
855
-		while($currentHeader = fgets($fp,$this->_maxlinelen))
855
+		while ($currentHeader = fgets($fp, $this->_maxlinelen))
856 856
 		{
857 857
 			if ($this->read_timeout > 0 && $this->_check_timeout($fp))
858 858
 			{
859
-				$this->status=-100;
859
+				$this->status = -100;
860 860
 				return false;
861 861
 			}
862 862
 
863
-			if($currentHeader == "\r\n")
863
+			if ($currentHeader == "\r\n")
864 864
 				break;
865 865
 
866 866
 			// if a header begins with Location: or URI:, set the redirect
867
-			if(preg_match("/^(Location:|URI:)/i",$currentHeader))
867
+			if (preg_match("/^(Location:|URI:)/i", $currentHeader))
868 868
 			{
869 869
 				// get URL portion of the redirect
870
-				preg_match("/^(Location:|URI:)[ ]+(.*)/i",chop($currentHeader),$matches);
870
+				preg_match("/^(Location:|URI:)[ ]+(.*)/i", chop($currentHeader), $matches);
871 871
 				// look for :// in the Location header to see if hostname is included
872
-				if(!preg_match("|\:\/\/|",$matches[2]))
872
+				if ( ! preg_match("|\:\/\/|", $matches[2]))
873 873
 				{
874 874
 					// no host in the path, so prepend
875 875
 					$this->_redirectaddr = $URI_PARTS["scheme"]."://".$this->host.":".$this->port;
876 876
 					// eliminate double slash
877
-					if(!preg_match("|^/|",$matches[2]))
877
+					if ( ! preg_match("|^/|", $matches[2]))
878 878
 							$this->_redirectaddr .= "/".$matches[2];
879 879
 					else
880 880
 							$this->_redirectaddr .= $matches[2];
@@ -883,11 +883,11 @@  discard block
 block discarded – undo
883 883
 					$this->_redirectaddr = $matches[2];
884 884
 			}
885 885
 
886
-			if(preg_match("|^HTTP/|",$currentHeader))
886
+			if (preg_match("|^HTTP/|", $currentHeader))
887 887
 			{
888
-                if(preg_match("|^HTTP/[^\s]*\s(.*?)\s|",$currentHeader, $status))
888
+                if (preg_match("|^HTTP/[^\s]*\s(.*?)\s|", $currentHeader, $status))
889 889
 				{
890
-					$this->status= $status[1];
890
+					$this->status = $status[1];
891 891
                 }
892 892
 				$this->response_code = $currentHeader;
893 893
 			}
@@ -902,31 +902,31 @@  discard block
 block discarded – undo
902 902
         		break;
903 903
     		}
904 904
     		$results .= $_data;
905
-		} while(true);
905
+		} while (true);
906 906
 
907 907
 		if ($this->read_timeout > 0 && $this->_check_timeout($fp))
908 908
 		{
909
-			$this->status=-100;
909
+			$this->status = -100;
910 910
 			return false;
911 911
 		}
912 912
 
913 913
 		// check if there is a redirect meta tag
914 914
 
915
-		if(preg_match("'<meta[\s]*http-equiv[^>]*?content[\s]*=[\s]*[\"\']?\d+;[\s]*URL[\s]*=[\s]*([^\"\']*?)[\"\']?>'i",$results,$match))
915
+		if (preg_match("'<meta[\s]*http-equiv[^>]*?content[\s]*=[\s]*[\"\']?\d+;[\s]*URL[\s]*=[\s]*([^\"\']*?)[\"\']?>'i", $results, $match))
916 916
 
917 917
 		{
918
-			$this->_redirectaddr = $this->_expandlinks($match[1],$URI);
918
+			$this->_redirectaddr = $this->_expandlinks($match[1], $URI);
919 919
 		}
920 920
 
921 921
 		// have we hit our frame depth and is there frame src to fetch?
922
-		if(($this->_framedepth < $this->maxframes) && preg_match_all("'<frame\s+.*src[\s]*=[\'\"]?([^\'\"\>]+)'i",$results,$match))
922
+		if (($this->_framedepth < $this->maxframes) && preg_match_all("'<frame\s+.*src[\s]*=[\'\"]?([^\'\"\>]+)'i", $results, $match))
923 923
 		{
924 924
 			$this->results[] = $results;
925
-			for($x=0; $x<count($match[1]); $x++)
926
-				$this->_frameurls[] = $this->_expandlinks($match[1][$x],$URI_PARTS["scheme"]."://".$this->host);
925
+			for ($x = 0; $x < count($match[1]); $x++)
926
+				$this->_frameurls[] = $this->_expandlinks($match[1][$x], $URI_PARTS["scheme"]."://".$this->host);
927 927
 		}
928 928
 		// have we already fetched framed content?
929
-		elseif(is_array($this->results))
929
+		elseif (is_array($this->results))
930 930
 			$this->results[] = $results;
931 931
 		// no framed content
932 932
 		else
@@ -944,108 +944,108 @@  discard block
 block discarded – undo
944 944
 	Output:
945 945
 \*======================================================================*/
946 946
 
947
-	function _httpsrequest($url,$URI,$http_method,$content_type="",$body="")
947
+	function _httpsrequest($url, $URI, $http_method, $content_type = "", $body = "")
948 948
 	{
949
-		if($this->passcookies && $this->_redirectaddr)
949
+		if ($this->passcookies && $this->_redirectaddr)
950 950
 			$this->setcookies();
951 951
 
952 952
 		$headers = array();
953 953
 
954 954
 		$URI_PARTS = parse_url($URI);
955
-		if(empty($url))
955
+		if (empty($url))
956 956
 			$url = "/";
957 957
 		// GET ... header not needed for curl
958 958
 		//$headers[] = $http_method." ".$url." ".$this->_httpversion;
959
-		if(!empty($this->agent))
959
+		if ( ! empty($this->agent))
960 960
 			$headers[] = "User-Agent: ".$this->agent;
961
-		if(!empty($this->host))
962
-			if(!empty($this->port))
961
+		if ( ! empty($this->host))
962
+			if ( ! empty($this->port))
963 963
 				$headers[] = "Host: ".$this->host.":".$this->port;
964 964
 			else
965 965
 				$headers[] = "Host: ".$this->host;
966
-		if(!empty($this->accept))
966
+		if ( ! empty($this->accept))
967 967
 			$headers[] = "Accept: ".$this->accept;
968
-		if(!empty($this->referer))
968
+		if ( ! empty($this->referer))
969 969
 			$headers[] = "Referer: ".$this->referer;
970
-		if(!empty($this->cookies))
970
+		if ( ! empty($this->cookies))
971 971
 		{
972
-			if(!is_array($this->cookies))
973
-				$this->cookies = (array)$this->cookies;
972
+			if ( ! is_array($this->cookies))
973
+				$this->cookies = (array) $this->cookies;
974 974
 
975 975
 			reset($this->cookies);
976
-			if ( count($this->cookies) > 0 ) {
976
+			if (count($this->cookies) > 0) {
977 977
 				$cookie_str = 'Cookie: ';
978
-				foreach ( $this->cookies as $cookieKey => $cookieVal ) {
978
+				foreach ($this->cookies as $cookieKey => $cookieVal) {
979 979
 				$cookie_str .= $cookieKey."=".urlencode($cookieVal)."; ";
980 980
 				}
981
-				$headers[] = substr($cookie_str,0,-2);
981
+				$headers[] = substr($cookie_str, 0, -2);
982 982
 			}
983 983
 		}
984
-		if(!empty($this->rawheaders))
984
+		if ( ! empty($this->rawheaders))
985 985
 		{
986
-			if(!is_array($this->rawheaders))
987
-				$this->rawheaders = (array)$this->rawheaders;
988
-			while(list($headerKey,$headerVal) = each($this->rawheaders))
986
+			if ( ! is_array($this->rawheaders))
987
+				$this->rawheaders = (array) $this->rawheaders;
988
+			while (list($headerKey, $headerVal) = each($this->rawheaders))
989 989
 				$headers[] = $headerKey.": ".$headerVal;
990 990
 		}
991
-		if(!empty($content_type)) {
991
+		if ( ! empty($content_type)) {
992 992
 			if ($content_type == "multipart/form-data")
993 993
 				$headers[] = "Content-type: $content_type; boundary=".$this->_mime_boundary;
994 994
 			else
995 995
 				$headers[] = "Content-type: $content_type";
996 996
 		}
997
-		if(!empty($body))
997
+		if ( ! empty($body))
998 998
 			$headers[] = "Content-length: ".strlen($body);
999
-		if(!empty($this->user) || !empty($this->pass))
999
+		if ( ! empty($this->user) || ! empty($this->pass))
1000 1000
 			$headers[] = "Authorization: BASIC ".base64_encode($this->user.":".$this->pass);
1001 1001
 
1002
-		$headerfile = tempnam( $this->temp_dir, "sno" );
1003
-		$cmdline_params = '-k -D ' . escapeshellarg( $headerfile );
1002
+		$headerfile = tempnam($this->temp_dir, "sno");
1003
+		$cmdline_params = '-k -D '.escapeshellarg($headerfile);
1004 1004
 
1005
-		foreach ( $headers as $header ) {
1006
-			$cmdline_params .= ' -H ' . escapeshellarg( $header );
1005
+		foreach ($headers as $header) {
1006
+			$cmdline_params .= ' -H '.escapeshellarg($header);
1007 1007
 		}
1008 1008
 
1009
-		if ( ! empty( $body ) ) {
1010
-			$cmdline_params .= ' -d ' . escapeshellarg( $body );
1009
+		if ( ! empty($body)) {
1010
+			$cmdline_params .= ' -d '.escapeshellarg($body);
1011 1011
 		}
1012 1012
 
1013
-		if ( $this->read_timeout > 0 ) {
1014
-			$cmdline_params .= ' -m ' . escapeshellarg( $this->read_timeout );
1013
+		if ($this->read_timeout > 0) {
1014
+			$cmdline_params .= ' -m '.escapeshellarg($this->read_timeout);
1015 1015
 		}
1016 1016
 
1017 1017
 
1018
-		exec( $this->curl_path . ' ' . $cmdline_params . ' ' . escapeshellarg( $URI ), $results, $return );
1018
+		exec($this->curl_path.' '.$cmdline_params.' '.escapeshellarg($URI), $results, $return);
1019 1019
 
1020
-		if($return)
1020
+		if ($return)
1021 1021
 		{
1022 1022
 			$this->error = "Error: cURL could not retrieve the document, error $return.";
1023 1023
 			return false;
1024 1024
 		}
1025 1025
 
1026 1026
 
1027
-		$results = implode("\r\n",$results);
1027
+		$results = implode("\r\n", $results);
1028 1028
 
1029 1029
 		$result_headers = file("$headerfile");
1030 1030
 
1031 1031
 		$this->_redirectaddr = false;
1032 1032
 		unset($this->headers);
1033 1033
 
1034
-		for($currentHeader = 0; $currentHeader < count($result_headers); $currentHeader++)
1034
+		for ($currentHeader = 0; $currentHeader < count($result_headers); $currentHeader++)
1035 1035
 		{
1036 1036
 
1037 1037
 			// if a header begins with Location: or URI:, set the redirect
1038
-			if(preg_match("/^(Location: |URI: )/i",$result_headers[$currentHeader]))
1038
+			if (preg_match("/^(Location: |URI: )/i", $result_headers[$currentHeader]))
1039 1039
 			{
1040 1040
 				// get URL portion of the redirect
1041
-				preg_match("/^(Location: |URI:)\s+(.*)/",chop($result_headers[$currentHeader]),$matches);
1041
+				preg_match("/^(Location: |URI:)\s+(.*)/", chop($result_headers[$currentHeader]), $matches);
1042 1042
 				// look for :// in the Location header to see if hostname is included
1043
-				if(!preg_match("|\:\/\/|",$matches[2]))
1043
+				if ( ! preg_match("|\:\/\/|", $matches[2]))
1044 1044
 				{
1045 1045
 					// no host in the path, so prepend
1046 1046
 					$this->_redirectaddr = $URI_PARTS["scheme"]."://".$this->host.":".$this->port;
1047 1047
 					// eliminate double slash
1048
-					if(!preg_match("|^/|",$matches[2]))
1048
+					if ( ! preg_match("|^/|", $matches[2]))
1049 1049
 							$this->_redirectaddr .= "/".$matches[2];
1050 1050
 					else
1051 1051
 							$this->_redirectaddr .= $matches[2];
@@ -1054,7 +1054,7 @@  discard block
 block discarded – undo
1054 1054
 					$this->_redirectaddr = $matches[2];
1055 1055
 			}
1056 1056
 
1057
-			if(preg_match("|^HTTP/|",$result_headers[$currentHeader]))
1057
+			if (preg_match("|^HTTP/|", $result_headers[$currentHeader]))
1058 1058
 				$this->response_code = $result_headers[$currentHeader];
1059 1059
 
1060 1060
 			$this->headers[] = $result_headers[$currentHeader];
@@ -1062,20 +1062,20 @@  discard block
 block discarded – undo
1062 1062
 
1063 1063
 		// check if there is a redirect meta tag
1064 1064
 
1065
-		if(preg_match("'<meta[\s]*http-equiv[^>]*?content[\s]*=[\s]*[\"\']?\d+;[\s]*URL[\s]*=[\s]*([^\"\']*?)[\"\']?>'i",$results,$match))
1065
+		if (preg_match("'<meta[\s]*http-equiv[^>]*?content[\s]*=[\s]*[\"\']?\d+;[\s]*URL[\s]*=[\s]*([^\"\']*?)[\"\']?>'i", $results, $match))
1066 1066
 		{
1067
-			$this->_redirectaddr = $this->_expandlinks($match[1],$URI);
1067
+			$this->_redirectaddr = $this->_expandlinks($match[1], $URI);
1068 1068
 		}
1069 1069
 
1070 1070
 		// have we hit our frame depth and is there frame src to fetch?
1071
-		if(($this->_framedepth < $this->maxframes) && preg_match_all("'<frame\s+.*src[\s]*=[\'\"]?([^\'\"\>]+)'i",$results,$match))
1071
+		if (($this->_framedepth < $this->maxframes) && preg_match_all("'<frame\s+.*src[\s]*=[\'\"]?([^\'\"\>]+)'i", $results, $match))
1072 1072
 		{
1073 1073
 			$this->results[] = $results;
1074
-			for($x=0; $x<count($match[1]); $x++)
1075
-				$this->_frameurls[] = $this->_expandlinks($match[1][$x],$URI_PARTS["scheme"]."://".$this->host);
1074
+			for ($x = 0; $x < count($match[1]); $x++)
1075
+				$this->_frameurls[] = $this->_expandlinks($match[1][$x], $URI_PARTS["scheme"]."://".$this->host);
1076 1076
 		}
1077 1077
 		// have we already fetched framed content?
1078
-		elseif(is_array($this->results))
1078
+		elseif (is_array($this->results))
1079 1079
 			$this->results[] = $results;
1080 1080
 		// no framed content
1081 1081
 		else
@@ -1093,9 +1093,9 @@  discard block
 block discarded – undo
1093 1093
 
1094 1094
 	function setcookies()
1095 1095
 	{
1096
-		for($x=0; $x<count($this->headers); $x++)
1096
+		for ($x = 0; $x < count($this->headers); $x++)
1097 1097
 		{
1098
-		if(preg_match('/^set-cookie:[\s]+([^=]+)=([^;]+)/i', $this->headers[$x],$match))
1098
+		if (preg_match('/^set-cookie:[\s]+([^=]+)=([^;]+)/i', $this->headers[$x], $match))
1099 1099
 			$this->cookies[$match[1]] = urldecode($match[2]);
1100 1100
 		}
1101 1101
 	}
@@ -1127,7 +1127,7 @@  discard block
 block discarded – undo
1127 1127
 
1128 1128
 	function _connect(&$fp)
1129 1129
 	{
1130
-		if(!empty($this->proxy_host) && !empty($this->proxy_port))
1130
+		if ( ! empty($this->proxy_host) && ! empty($this->proxy_port))
1131 1131
 			{
1132 1132
 				$this->_isproxy = true;
1133 1133
 
@@ -1142,7 +1142,7 @@  discard block
 block discarded – undo
1142 1142
 
1143 1143
 		$this->status = 0;
1144 1144
 
1145
-		if($fp = fsockopen(
1145
+		if ($fp = fsockopen(
1146 1146
 					$host,
1147 1147
 					$port,
1148 1148
 					$errno,
@@ -1158,16 +1158,16 @@  discard block
 block discarded – undo
1158 1158
 		{
1159 1159
 			// socket connection failed
1160 1160
 			$this->status = $errno;
1161
-			switch($errno)
1161
+			switch ($errno)
1162 1162
 			{
1163 1163
 				case -3:
1164
-					$this->error="socket creation failed (-3)";
1164
+					$this->error = "socket creation failed (-3)";
1165 1165
 				case -4:
1166
-					$this->error="dns lookup failure (-4)";
1166
+					$this->error = "dns lookup failure (-4)";
1167 1167
 				case -5:
1168
-					$this->error="connection refused or timed out (-5)";
1168
+					$this->error = "connection refused or timed out (-5)";
1169 1169
 				default:
1170
-					$this->error="connection failed (".$errno.")";
1170
+					$this->error = "connection failed (".$errno.")";
1171 1171
 			}
1172 1172
 			return false;
1173 1173
 		}
@@ -1204,7 +1204,7 @@  discard block
 block discarded – undo
1204 1204
 		switch ($this->_submit_type) {
1205 1205
 			case "application/x-www-form-urlencoded":
1206 1206
 				reset($formvars);
1207
-				while(list($key,$val) = each($formvars)) {
1207
+				while (list($key, $val) = each($formvars)) {
1208 1208
 					if (is_array($val) || is_object($val)) {
1209 1209
 						while (list($cur_key, $cur_val) = each($val)) {
1210 1210
 							$postdata .= urlencode($key)."[]=".urlencode($cur_val)."&";
@@ -1218,7 +1218,7 @@  discard block
 block discarded – undo
1218 1218
 				$this->_mime_boundary = "Snoopy".md5(uniqid(microtime()));
1219 1219
 
1220 1220
 				reset($formvars);
1221
-				while(list($key,$val) = each($formvars)) {
1221
+				while (list($key, $val) = each($formvars)) {
1222 1222
 					if (is_array($val) || is_object($val)) {
1223 1223
 						while (list($cur_key, $cur_val) = each($val)) {
1224 1224
 							$postdata .= "--".$this->_mime_boundary."\r\n";
@@ -1236,7 +1236,7 @@  discard block
 block discarded – undo
1236 1236
 				while (list($field_name, $file_names) = each($formfiles)) {
1237 1237
 					settype($file_names, "array");
1238 1238
 					while (list(, $file_name) = each($file_names)) {
1239
-						if (!is_readable($file_name)) continue;
1239
+						if ( ! is_readable($file_name)) continue;
1240 1240
 
1241 1241
 						$fp = fopen($file_name, "r");
1242 1242
 						$file_content = fread($fp, filesize($file_name));
Please login to merge, or discard this patch.
src/wp-includes/class-wp-customize-nav-menus.php 2 patches
Doc Comments   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -42,7 +42,7 @@  discard block
 block discarded – undo
42 42
 	 * @since 4.3.0
43 43
 	 * @access public
44 44
 	 *
45
-	 * @param object $manager An instance of the WP_Customize_Manager class.
45
+	 * @param WP_Customize_Manager $manager An instance of the WP_Customize_Manager class.
46 46
 	 */
47 47
 	public function __construct( $manager ) {
48 48
 		$this->previewed_menus = array();
@@ -876,7 +876,7 @@  discard block
 block discarded – undo
876 876
 	 *
877 877
 	 * @param string $nav_menu_content The HTML content for the navigation menu.
878 878
 	 * @param object $args             An object containing wp_nav_menu() arguments.
879
-	 * @return null
879
+	 * @return string
880 880
 	 */
881 881
 	public function filter_wp_nav_menu( $nav_menu_content, $args ) {
882 882
 		if ( ! empty( $args->can_partial_refresh ) && ! empty( $args->instance_number ) ) {
Please login to merge, or discard this patch.
Spacing   +378 added lines, -378 removed lines patch added patch discarded remove patch
@@ -44,33 +44,33 @@  discard block
 block discarded – undo
44 44
 	 *
45 45
 	 * @param object $manager An instance of the WP_Customize_Manager class.
46 46
 	 */
47
-	public function __construct( $manager ) {
47
+	public function __construct($manager) {
48 48
 		$this->previewed_menus = array();
49 49
 		$this->manager         = $manager;
50 50
 
51 51
 		// See https://github.com/xwp/wp-customize-snapshots/blob/962586659688a5b1fd9ae93618b7ce2d4e7a421c/php/class-customize-snapshot-manager.php#L469-L499
52
-		add_action( 'customize_register', array( $this, 'customize_register' ), 11 );
53
-		add_filter( 'customize_dynamic_setting_args', array( $this, 'filter_dynamic_setting_args' ), 10, 2 );
54
-		add_filter( 'customize_dynamic_setting_class', array( $this, 'filter_dynamic_setting_class' ), 10, 3 );
52
+		add_action('customize_register', array($this, 'customize_register'), 11);
53
+		add_filter('customize_dynamic_setting_args', array($this, 'filter_dynamic_setting_args'), 10, 2);
54
+		add_filter('customize_dynamic_setting_class', array($this, 'filter_dynamic_setting_class'), 10, 3);
55 55
 
56 56
 		// Skip remaining hooks when the user can't manage nav menus anyway.
57
-		if ( ! current_user_can( 'edit_theme_options' ) ) {
57
+		if ( ! current_user_can('edit_theme_options')) {
58 58
 			return;
59 59
 		}
60 60
 
61
-		add_filter( 'customize_refresh_nonces', array( $this, 'filter_nonces' ) );
62
-		add_action( 'wp_ajax_load-available-menu-items-customizer', array( $this, 'ajax_load_available_items' ) );
63
-		add_action( 'wp_ajax_search-available-menu-items-customizer', array( $this, 'ajax_search_available_items' ) );
64
-		add_action( 'wp_ajax_customize-nav-menus-insert-auto-draft', array( $this, 'ajax_insert_auto_draft_post' ) );
65
-		add_action( 'customize_controls_enqueue_scripts', array( $this, 'enqueue_scripts' ) );
66
-		add_action( 'customize_controls_print_footer_scripts', array( $this, 'print_templates' ) );
67
-		add_action( 'customize_controls_print_footer_scripts', array( $this, 'available_items_template' ) );
68
-		add_action( 'customize_preview_init', array( $this, 'customize_preview_init' ) );
69
-		add_action( 'customize_preview_init', array( $this, 'make_auto_draft_status_previewable' ) );
70
-		add_action( 'customize_save_nav_menus_created_posts', array( $this, 'save_nav_menus_created_posts' ) );
61
+		add_filter('customize_refresh_nonces', array($this, 'filter_nonces'));
62
+		add_action('wp_ajax_load-available-menu-items-customizer', array($this, 'ajax_load_available_items'));
63
+		add_action('wp_ajax_search-available-menu-items-customizer', array($this, 'ajax_search_available_items'));
64
+		add_action('wp_ajax_customize-nav-menus-insert-auto-draft', array($this, 'ajax_insert_auto_draft_post'));
65
+		add_action('customize_controls_enqueue_scripts', array($this, 'enqueue_scripts'));
66
+		add_action('customize_controls_print_footer_scripts', array($this, 'print_templates'));
67
+		add_action('customize_controls_print_footer_scripts', array($this, 'available_items_template'));
68
+		add_action('customize_preview_init', array($this, 'customize_preview_init'));
69
+		add_action('customize_preview_init', array($this, 'make_auto_draft_status_previewable'));
70
+		add_action('customize_save_nav_menus_created_posts', array($this, 'save_nav_menus_created_posts'));
71 71
 
72 72
 		// Selective Refresh partials.
73
-		add_filter( 'customize_dynamic_partial_args', array( $this, 'customize_dynamic_partial_args' ), 10, 2 );
73
+		add_filter('customize_dynamic_partial_args', array($this, 'customize_dynamic_partial_args'), 10, 2);
74 74
 	}
75 75
 
76 76
 	/**
@@ -82,8 +82,8 @@  discard block
 block discarded – undo
82 82
 	 * @param array $nonces Array of nonces.
83 83
 	 * @return array $nonces Modified array of nonces.
84 84
 	 */
85
-	public function filter_nonces( $nonces ) {
86
-		$nonces['customize-menus'] = wp_create_nonce( 'customize-menus' );
85
+	public function filter_nonces($nonces) {
86
+		$nonces['customize-menus'] = wp_create_nonce('customize-menus');
87 87
 		return $nonces;
88 88
 	}
89 89
 
@@ -94,41 +94,41 @@  discard block
 block discarded – undo
94 94
 	 * @access public
95 95
 	 */
96 96
 	public function ajax_load_available_items() {
97
-		check_ajax_referer( 'customize-menus', 'customize-menus-nonce' );
97
+		check_ajax_referer('customize-menus', 'customize-menus-nonce');
98 98
 
99
-		if ( ! current_user_can( 'edit_theme_options' ) ) {
99
+		if ( ! current_user_can('edit_theme_options')) {
100 100
 			wp_die( -1 );
101 101
 		}
102 102
 
103 103
 		$all_items = array();
104 104
 		$item_types = array();
105
-		if ( isset( $_POST['item_types'] ) && is_array( $_POST['item_types'] ) ) {
106
-			$item_types = wp_unslash( $_POST['item_types'] );
107
-		} elseif ( isset( $_POST['type'] ) && isset( $_POST['object'] ) ) { // Back compat.
105
+		if (isset($_POST['item_types']) && is_array($_POST['item_types'])) {
106
+			$item_types = wp_unslash($_POST['item_types']);
107
+		} elseif (isset($_POST['type']) && isset($_POST['object'])) { // Back compat.
108 108
 			$item_types[] = array(
109
-				'type' => wp_unslash( $_POST['type'] ),
110
-				'object' => wp_unslash( $_POST['object'] ),
111
-				'page' => empty( $_POST['page'] ) ? 0 : absint( $_POST['page'] ),
109
+				'type' => wp_unslash($_POST['type']),
110
+				'object' => wp_unslash($_POST['object']),
111
+				'page' => empty($_POST['page']) ? 0 : absint($_POST['page']),
112 112
 			);
113 113
 		} else {
114
-			wp_send_json_error( 'nav_menus_missing_type_or_object_parameter' );
114
+			wp_send_json_error('nav_menus_missing_type_or_object_parameter');
115 115
 		}
116 116
 
117
-		foreach ( $item_types as $item_type ) {
118
-			if ( empty( $item_type['type'] ) || empty( $item_type['object'] ) ) {
119
-				wp_send_json_error( 'nav_menus_missing_type_or_object_parameter' );
117
+		foreach ($item_types as $item_type) {
118
+			if (empty($item_type['type']) || empty($item_type['object'])) {
119
+				wp_send_json_error('nav_menus_missing_type_or_object_parameter');
120 120
 			}
121
-			$type = sanitize_key( $item_type['type'] );
122
-			$object = sanitize_key( $item_type['object'] );
123
-			$page = empty( $item_type['page'] ) ? 0 : absint( $item_type['page'] );
124
-			$items = $this->load_available_items_query( $type, $object, $page );
125
-			if ( is_wp_error( $items ) ) {
126
-				wp_send_json_error( $items->get_error_code() );
121
+			$type = sanitize_key($item_type['type']);
122
+			$object = sanitize_key($item_type['object']);
123
+			$page = empty($item_type['page']) ? 0 : absint($item_type['page']);
124
+			$items = $this->load_available_items_query($type, $object, $page);
125
+			if (is_wp_error($items)) {
126
+				wp_send_json_error($items->get_error_code());
127 127
 			}
128
-			$all_items[ $item_type['type'] . ':' . $item_type['object'] ] = $items;
128
+			$all_items[$item_type['type'].':'.$item_type['object']] = $items;
129 129
 		}
130 130
 
131
-		wp_send_json_success( array( 'items' => $all_items ) );
131
+		wp_send_json_success(array('items' => $all_items));
132 132
 	}
133 133
 
134 134
 	/**
@@ -143,74 +143,74 @@  discard block
 block discarded – undo
143 143
 	 * @param int    $page   Optional. The page number used to generate the query offset. Default is '0'.
144 144
 	 * @return WP_Error|array Returns either a WP_Error object or an array of menu items.
145 145
 	 */
146
-	public function load_available_items_query( $type = 'post_type', $object = 'page', $page = 0 ) {
146
+	public function load_available_items_query($type = 'post_type', $object = 'page', $page = 0) {
147 147
 		$items = array();
148 148
 
149
-		if ( 'post_type' === $type ) {
150
-			$post_type = get_post_type_object( $object );
151
-			if ( ! $post_type ) {
152
-				return new WP_Error( 'nav_menus_invalid_post_type' );
149
+		if ('post_type' === $type) {
150
+			$post_type = get_post_type_object($object);
151
+			if ( ! $post_type) {
152
+				return new WP_Error('nav_menus_invalid_post_type');
153 153
 			}
154 154
 
155
-			if ( 0 === $page && 'page' === $object ) {
155
+			if (0 === $page && 'page' === $object) {
156 156
 				// Add "Home" link. Treat as a page, but switch to custom on add.
157 157
 				$items[] = array(
158 158
 					'id'         => 'home',
159
-					'title'      => _x( 'Home', 'nav menu home label' ),
159
+					'title'      => _x('Home', 'nav menu home label'),
160 160
 					'type'       => 'custom',
161
-					'type_label' => __( 'Custom Link' ),
161
+					'type_label' => __('Custom Link'),
162 162
 					'object'     => '',
163 163
 					'url'        => home_url(),
164 164
 				);
165
-			} elseif ( 'post' !== $object && 0 === $page && $post_type->has_archive ) {
165
+			} elseif ('post' !== $object && 0 === $page && $post_type->has_archive) {
166 166
 				// Add a post type archive link.
167 167
 				$items[] = array(
168
-					'id'         => $object . '-archive',
168
+					'id'         => $object.'-archive',
169 169
 					'title'      => $post_type->labels->archives,
170 170
 					'type'       => 'post_type_archive',
171
-					'type_label' => __( 'Post Type Archive' ),
171
+					'type_label' => __('Post Type Archive'),
172 172
 					'object'     => $object,
173
-					'url'        => get_post_type_archive_link( $object ),
173
+					'url'        => get_post_type_archive_link($object),
174 174
 				);
175 175
 			}
176 176
 
177 177
 			// Prepend posts with nav_menus_created_posts on first page.
178 178
 			$posts = array();
179
-			if ( 0 === $page && $this->manager->get_setting( 'nav_menus_created_posts' ) ) {
180
-				foreach ( $this->manager->get_setting( 'nav_menus_created_posts' )->value() as $post_id ) {
181
-					$auto_draft_post = get_post( $post_id );
182
-					if ( $post_type->name === $auto_draft_post->post_type ) {
179
+			if (0 === $page && $this->manager->get_setting('nav_menus_created_posts')) {
180
+				foreach ($this->manager->get_setting('nav_menus_created_posts')->value() as $post_id) {
181
+					$auto_draft_post = get_post($post_id);
182
+					if ($post_type->name === $auto_draft_post->post_type) {
183 183
 						$posts[] = $auto_draft_post;
184 184
 					}
185 185
 				}
186 186
 			}
187 187
 
188
-			$posts = array_merge( $posts, get_posts( array(
188
+			$posts = array_merge($posts, get_posts(array(
189 189
 				'numberposts' => 10,
190 190
 				'offset'      => 10 * $page,
191 191
 				'orderby'     => 'date',
192 192
 				'order'       => 'DESC',
193 193
 				'post_type'   => $object,
194
-			) ) );
194
+			)));
195 195
 
196
-			foreach ( $posts as $post ) {
196
+			foreach ($posts as $post) {
197 197
 				$post_title = $post->post_title;
198
-				if ( '' === $post_title ) {
198
+				if ('' === $post_title) {
199 199
 					/* translators: %d: ID of a post */
200
-					$post_title = sprintf( __( '#%d (no title)' ), $post->ID );
200
+					$post_title = sprintf(__('#%d (no title)'), $post->ID);
201 201
 				}
202 202
 				$items[] = array(
203 203
 					'id'         => "post-{$post->ID}",
204
-					'title'      => html_entity_decode( $post_title, ENT_QUOTES, get_bloginfo( 'charset' ) ),
204
+					'title'      => html_entity_decode($post_title, ENT_QUOTES, get_bloginfo('charset')),
205 205
 					'type'       => 'post_type',
206
-					'type_label' => get_post_type_object( $post->post_type )->labels->singular_name,
206
+					'type_label' => get_post_type_object($post->post_type)->labels->singular_name,
207 207
 					'object'     => $post->post_type,
208
-					'object_id'  => intval( $post->ID ),
209
-					'url'        => get_permalink( intval( $post->ID ) ),
208
+					'object_id'  => intval($post->ID),
209
+					'url'        => get_permalink(intval($post->ID)),
210 210
 				);
211 211
 			}
212
-		} elseif ( 'taxonomy' === $type ) {
213
-			$terms = get_terms( $object, array(
212
+		} elseif ('taxonomy' === $type) {
213
+			$terms = get_terms($object, array(
214 214
 				'child_of'     => 0,
215 215
 				'exclude'      => '',
216 216
 				'hide_empty'   => false,
@@ -221,20 +221,20 @@  discard block
 block discarded – undo
221 221
 				'order'        => 'DESC',
222 222
 				'orderby'      => 'count',
223 223
 				'pad_counts'   => false,
224
-			) );
225
-			if ( is_wp_error( $terms ) ) {
224
+			));
225
+			if (is_wp_error($terms)) {
226 226
 				return $terms;
227 227
 			}
228 228
 
229
-			foreach ( $terms as $term ) {
229
+			foreach ($terms as $term) {
230 230
 				$items[] = array(
231 231
 					'id'         => "term-{$term->term_id}",
232
-					'title'      => html_entity_decode( $term->name, ENT_QUOTES, get_bloginfo( 'charset' ) ),
232
+					'title'      => html_entity_decode($term->name, ENT_QUOTES, get_bloginfo('charset')),
233 233
 					'type'       => 'taxonomy',
234
-					'type_label' => get_taxonomy( $term->taxonomy )->labels->singular_name,
234
+					'type_label' => get_taxonomy($term->taxonomy)->labels->singular_name,
235 235
 					'object'     => $term->taxonomy,
236
-					'object_id'  => intval( $term->term_id ),
237
-					'url'        => get_term_link( intval( $term->term_id ), $term->taxonomy ),
236
+					'object_id'  => intval($term->term_id),
237
+					'url'        => get_term_link(intval($term->term_id), $term->taxonomy),
238 238
 				);
239 239
 			}
240 240
 		}
@@ -249,7 +249,7 @@  discard block
 block discarded – undo
249 249
 		 * @param string $object The object name.
250 250
 		 * @param int    $page   The current page number.
251 251
 		 */
252
-		$items = apply_filters( 'customize_nav_menu_available_items', $items, $type, $object, $page );
252
+		$items = apply_filters('customize_nav_menu_available_items', $items, $type, $object, $page);
253 253
 
254 254
 		return $items;
255 255
 	}
@@ -261,28 +261,28 @@  discard block
 block discarded – undo
261 261
 	 * @access public
262 262
 	 */
263 263
 	public function ajax_search_available_items() {
264
-		check_ajax_referer( 'customize-menus', 'customize-menus-nonce' );
264
+		check_ajax_referer('customize-menus', 'customize-menus-nonce');
265 265
 
266
-		if ( ! current_user_can( 'edit_theme_options' ) ) {
266
+		if ( ! current_user_can('edit_theme_options')) {
267 267
 			wp_die( -1 );
268 268
 		}
269 269
 
270
-		if ( empty( $_POST['search'] ) ) {
271
-			wp_send_json_error( 'nav_menus_missing_search_parameter' );
270
+		if (empty($_POST['search'])) {
271
+			wp_send_json_error('nav_menus_missing_search_parameter');
272 272
 		}
273 273
 
274
-		$p = isset( $_POST['page'] ) ? absint( $_POST['page'] ) : 0;
275
-		if ( $p < 1 ) {
274
+		$p = isset($_POST['page']) ? absint($_POST['page']) : 0;
275
+		if ($p < 1) {
276 276
 			$p = 1;
277 277
 		}
278 278
 
279
-		$s = sanitize_text_field( wp_unslash( $_POST['search'] ) );
280
-		$items = $this->search_available_items_query( array( 'pagenum' => $p, 's' => $s ) );
279
+		$s = sanitize_text_field(wp_unslash($_POST['search']));
280
+		$items = $this->search_available_items_query(array('pagenum' => $p, 's' => $s));
281 281
 
282
-		if ( empty( $items ) ) {
283
-			wp_send_json_error( array( 'message' => __( 'No results found.' ) ) );
282
+		if (empty($items)) {
283
+			wp_send_json_error(array('message' => __('No results found.')));
284 284
 		} else {
285
-			wp_send_json_success( array( 'items' => $items ) );
285
+			wp_send_json_success(array('items' => $items));
286 286
 		}
287 287
 	}
288 288
 
@@ -297,12 +297,12 @@  discard block
 block discarded – undo
297 297
 	 * @param array $args Optional. Accepts 'pagenum' and 's' (search) arguments.
298 298
 	 * @return array Menu items.
299 299
 	 */
300
-	public function search_available_items_query( $args = array() ) {
300
+	public function search_available_items_query($args = array()) {
301 301
 		$items = array();
302 302
 
303
-		$post_type_objects = get_post_types( array( 'show_in_nav_menus' => true ), 'objects' );
303
+		$post_type_objects = get_post_types(array('show_in_nav_menus' => true), 'objects');
304 304
 		$query = array(
305
-			'post_type'              => array_keys( $post_type_objects ),
305
+			'post_type'              => array_keys($post_type_objects),
306 306
 			'suppress_filters'       => true,
307 307
 			'update_post_term_cache' => false,
308 308
 			'update_post_meta_cache' => false,
@@ -310,70 +310,70 @@  discard block
 block discarded – undo
310 310
 			'posts_per_page'         => 20,
311 311
 		);
312 312
 
313
-		$args['pagenum'] = isset( $args['pagenum'] ) ? absint( $args['pagenum'] ) : 1;
314
-		$query['offset'] = $args['pagenum'] > 1 ? $query['posts_per_page'] * ( $args['pagenum'] - 1 ) : 0;
313
+		$args['pagenum'] = isset($args['pagenum']) ? absint($args['pagenum']) : 1;
314
+		$query['offset'] = $args['pagenum'] > 1 ? $query['posts_per_page'] * ($args['pagenum'] - 1) : 0;
315 315
 
316
-		if ( isset( $args['s'] ) ) {
316
+		if (isset($args['s'])) {
317 317
 			$query['s'] = $args['s'];
318 318
 		}
319 319
 
320 320
 		$posts = array();
321 321
 
322 322
 		// Prepend list of posts with nav_menus_created_posts search results on first page.
323
-		$nav_menus_created_posts_setting = $this->manager->get_setting( 'nav_menus_created_posts' );
324
-		if ( 1 === $args['pagenum'] && $nav_menus_created_posts_setting && count( $nav_menus_created_posts_setting ) > 0 ) {
325
-			$stub_post_query = new WP_Query( array_merge(
323
+		$nav_menus_created_posts_setting = $this->manager->get_setting('nav_menus_created_posts');
324
+		if (1 === $args['pagenum'] && $nav_menus_created_posts_setting && count($nav_menus_created_posts_setting) > 0) {
325
+			$stub_post_query = new WP_Query(array_merge(
326 326
 				$query,
327 327
 				array(
328 328
 					'post_status' => 'auto-draft',
329 329
 					'post__in' => $nav_menus_created_posts_setting->value(),
330 330
 					'posts_per_page' => -1,
331 331
 				)
332
-			) );
333
-			$posts = array_merge( $posts, $stub_post_query->posts );
332
+			));
333
+			$posts = array_merge($posts, $stub_post_query->posts);
334 334
 		}
335 335
 
336 336
 		// Query posts.
337
-		$get_posts = new WP_Query( $query );
338
-		$posts = array_merge( $posts, $get_posts->posts );
337
+		$get_posts = new WP_Query($query);
338
+		$posts = array_merge($posts, $get_posts->posts);
339 339
 
340 340
 		// Create items for posts.
341
-		foreach ( $posts as $post ) {
341
+		foreach ($posts as $post) {
342 342
 			$post_title = $post->post_title;
343
-			if ( '' === $post_title ) {
343
+			if ('' === $post_title) {
344 344
 				/* translators: %d: ID of a post */
345
-				$post_title = sprintf( __( '#%d (no title)' ), $post->ID );
345
+				$post_title = sprintf(__('#%d (no title)'), $post->ID);
346 346
 			}
347 347
 			$items[] = array(
348
-				'id'         => 'post-' . $post->ID,
349
-				'title'      => html_entity_decode( $post_title, ENT_QUOTES, get_bloginfo( 'charset' ) ),
348
+				'id'         => 'post-'.$post->ID,
349
+				'title'      => html_entity_decode($post_title, ENT_QUOTES, get_bloginfo('charset')),
350 350
 				'type'       => 'post_type',
351
-				'type_label' => $post_type_objects[ $post->post_type ]->labels->singular_name,
351
+				'type_label' => $post_type_objects[$post->post_type]->labels->singular_name,
352 352
 				'object'     => $post->post_type,
353
-				'object_id'  => intval( $post->ID ),
354
-				'url'        => get_permalink( intval( $post->ID ) ),
353
+				'object_id'  => intval($post->ID),
354
+				'url'        => get_permalink(intval($post->ID)),
355 355
 			);
356 356
 		}
357 357
 
358 358
 		// Query taxonomy terms.
359
-		$taxonomies = get_taxonomies( array( 'show_in_nav_menus' => true ), 'names' );
360
-		$terms = get_terms( $taxonomies, array(
359
+		$taxonomies = get_taxonomies(array('show_in_nav_menus' => true), 'names');
360
+		$terms = get_terms($taxonomies, array(
361 361
 			'name__like' => $args['s'],
362 362
 			'number'     => 20,
363 363
 			'offset'     => 20 * ($args['pagenum'] - 1),
364
-		) );
364
+		));
365 365
 
366 366
 		// Check if any taxonomies were found.
367
-		if ( ! empty( $terms ) ) {
368
-			foreach ( $terms as $term ) {
367
+		if ( ! empty($terms)) {
368
+			foreach ($terms as $term) {
369 369
 				$items[] = array(
370
-					'id'         => 'term-' . $term->term_id,
371
-					'title'      => html_entity_decode( $term->name, ENT_QUOTES, get_bloginfo( 'charset' ) ),
370
+					'id'         => 'term-'.$term->term_id,
371
+					'title'      => html_entity_decode($term->name, ENT_QUOTES, get_bloginfo('charset')),
372 372
 					'type'       => 'taxonomy',
373
-					'type_label' => get_taxonomy( $term->taxonomy )->labels->singular_name,
373
+					'type_label' => get_taxonomy($term->taxonomy)->labels->singular_name,
374 374
 					'object'     => $term->taxonomy,
375
-					'object_id'  => intval( $term->term_id ),
376
-					'url'        => get_term_link( intval( $term->term_id ), $term->taxonomy ),
375
+					'object_id'  => intval($term->term_id),
376
+					'url'        => get_term_link(intval($term->term_id), $term->taxonomy),
377 377
 				);
378 378
 			}
379 379
 		}
@@ -386,7 +386,7 @@  discard block
 block discarded – undo
386 386
 		 * @param array $items The array of menu items.
387 387
 		 * @param array $args  Includes 'pagenum' and 's' (search) arguments.
388 388
 		 */
389
-		$items = apply_filters( 'customize_nav_menu_searched_items', $items, $args );
389
+		$items = apply_filters('customize_nav_menu_searched_items', $items, $args);
390 390
 
391 391
 		return $items;
392 392
 	}
@@ -398,45 +398,45 @@  discard block
 block discarded – undo
398 398
 	 * @access public
399 399
 	 */
400 400
 	public function enqueue_scripts() {
401
-		wp_enqueue_style( 'customize-nav-menus' );
402
-		wp_enqueue_script( 'customize-nav-menus' );
401
+		wp_enqueue_style('customize-nav-menus');
402
+		wp_enqueue_script('customize-nav-menus');
403 403
 
404
-		$temp_nav_menu_setting      = new WP_Customize_Nav_Menu_Setting( $this->manager, 'nav_menu[-1]' );
405
-		$temp_nav_menu_item_setting = new WP_Customize_Nav_Menu_Item_Setting( $this->manager, 'nav_menu_item[-1]' );
404
+		$temp_nav_menu_setting      = new WP_Customize_Nav_Menu_Setting($this->manager, 'nav_menu[-1]');
405
+		$temp_nav_menu_item_setting = new WP_Customize_Nav_Menu_Item_Setting($this->manager, 'nav_menu_item[-1]');
406 406
 
407 407
 		// Pass data to JS.
408 408
 		$settings = array(
409 409
 			'allMenus'             => wp_get_nav_menus(),
410 410
 			'itemTypes'            => $this->available_item_types(),
411 411
 			'l10n'                 => array(
412
-				'untitled'          => _x( '(no label)', 'missing menu item navigation label' ),
413
-				'unnamed'           => _x( '(unnamed)', 'Missing menu name.' ),
414
-				'custom_label'      => __( 'Custom Link' ),
415
-				'page_label'        => get_post_type_object( 'page' )->labels->singular_name,
412
+				'untitled'          => _x('(no label)', 'missing menu item navigation label'),
413
+				'unnamed'           => _x('(unnamed)', 'Missing menu name.'),
414
+				'custom_label'      => __('Custom Link'),
415
+				'page_label'        => get_post_type_object('page')->labels->singular_name,
416 416
 				/* translators: %s: menu location */
417
-				'menuLocation'      => _x( '(Currently set to: %s)', 'menu' ),
418
-				'menuNameLabel'     => __( 'Menu Name' ),
419
-				'itemAdded'         => __( 'Menu item added' ),
420
-				'itemDeleted'       => __( 'Menu item deleted' ),
421
-				'menuAdded'         => __( 'Menu created' ),
422
-				'menuDeleted'       => __( 'Menu deleted' ),
423
-				'movedUp'           => __( 'Menu item moved up' ),
424
-				'movedDown'         => __( 'Menu item moved down' ),
425
-				'movedLeft'         => __( 'Menu item moved out of submenu' ),
426
-				'movedRight'        => __( 'Menu item is now a sub-item' ),
417
+				'menuLocation'      => _x('(Currently set to: %s)', 'menu'),
418
+				'menuNameLabel'     => __('Menu Name'),
419
+				'itemAdded'         => __('Menu item added'),
420
+				'itemDeleted'       => __('Menu item deleted'),
421
+				'menuAdded'         => __('Menu created'),
422
+				'menuDeleted'       => __('Menu deleted'),
423
+				'movedUp'           => __('Menu item moved up'),
424
+				'movedDown'         => __('Menu item moved down'),
425
+				'movedLeft'         => __('Menu item moved out of submenu'),
426
+				'movedRight'        => __('Menu item is now a sub-item'),
427 427
 				/* translators: &#9656; is the unicode right-pointing triangle, and %s is the section title in the Customizer */
428
-				'customizingMenus'  => sprintf( __( 'Customizing &#9656; %s' ), esc_html( $this->manager->get_panel( 'nav_menus' )->title ) ),
428
+				'customizingMenus'  => sprintf(__('Customizing &#9656; %s'), esc_html($this->manager->get_panel('nav_menus')->title)),
429 429
 				/* translators: %s: title of menu item which is invalid */
430
-				'invalidTitleTpl'   => __( '%s (Invalid)' ),
430
+				'invalidTitleTpl'   => __('%s (Invalid)'),
431 431
 				/* translators: %s: title of menu item in draft status */
432
-				'pendingTitleTpl'   => __( '%s (Pending)' ),
433
-				'itemsFound'        => __( 'Number of items found: %d' ),
434
-				'itemsFoundMore'    => __( 'Additional items found: %d' ),
435
-				'itemsLoadingMore'  => __( 'Loading more results... please wait.' ),
436
-				'reorderModeOn'     => __( 'Reorder mode enabled' ),
437
-				'reorderModeOff'    => __( 'Reorder mode closed' ),
438
-				'reorderLabelOn'    => esc_attr__( 'Reorder menu items' ),
439
-				'reorderLabelOff'   => esc_attr__( 'Close reorder mode' ),
432
+				'pendingTitleTpl'   => __('%s (Pending)'),
433
+				'itemsFound'        => __('Number of items found: %d'),
434
+				'itemsFoundMore'    => __('Additional items found: %d'),
435
+				'itemsLoadingMore'  => __('Loading more results... please wait.'),
436
+				'reorderModeOn'     => __('Reorder mode enabled'),
437
+				'reorderModeOff'    => __('Reorder mode closed'),
438
+				'reorderLabelOn'    => esc_attr__('Reorder menu items'),
439
+				'reorderLabelOff'   => esc_attr__('Close reorder mode'),
440 440
 			),
441 441
 			'settingTransport'     => 'postMessage',
442 442
 			'phpIntMax'            => PHP_INT_MAX,
@@ -447,29 +447,29 @@  discard block
 block discarded – undo
447 447
 			'locationSlugMappedToName' => get_registered_nav_menus(),
448 448
 		);
449 449
 
450
-		$data = sprintf( 'var _wpCustomizeNavMenusSettings = %s;', wp_json_encode( $settings ) );
451
-		wp_scripts()->add_data( 'customize-nav-menus', 'data', $data );
450
+		$data = sprintf('var _wpCustomizeNavMenusSettings = %s;', wp_json_encode($settings));
451
+		wp_scripts()->add_data('customize-nav-menus', 'data', $data);
452 452
 
453 453
 		// This is copied from nav-menus.php, and it has an unfortunate object name of `menus`.
454 454
 		$nav_menus_l10n = array(
455 455
 			'oneThemeLocationNoMenus' => null,
456
-			'moveUp'       => __( 'Move up one' ),
457
-			'moveDown'     => __( 'Move down one' ),
458
-			'moveToTop'    => __( 'Move to the top' ),
456
+			'moveUp'       => __('Move up one'),
457
+			'moveDown'     => __('Move down one'),
458
+			'moveToTop'    => __('Move to the top'),
459 459
 			/* translators: %s: previous item name */
460
-			'moveUnder'    => __( 'Move under %s' ),
460
+			'moveUnder'    => __('Move under %s'),
461 461
 			/* translators: %s: previous item name */
462
-			'moveOutFrom'  => __( 'Move out from under %s' ),
462
+			'moveOutFrom'  => __('Move out from under %s'),
463 463
 			/* translators: %s: previous item name */
464
-			'under'        => __( 'Under %s' ),
464
+			'under'        => __('Under %s'),
465 465
 			/* translators: %s: previous item name */
466
-			'outFrom'      => __( 'Out from under %s' ),
466
+			'outFrom'      => __('Out from under %s'),
467 467
 			/* translators: 1: item name, 2: item position, 3: total number of items */
468
-			'menuFocus'    => __( '%1$s. Menu item %2$d of %3$d.' ),
468
+			'menuFocus'    => __('%1$s. Menu item %2$d of %3$d.'),
469 469
 			/* translators: 1: item name, 2: item position, 3: parent item name */
470
-			'subMenuFocus' => __( '%1$s. Sub item number %2$d under %3$s.' ),
470
+			'subMenuFocus' => __('%1$s. Sub item number %2$d under %3$s.'),
471 471
 		);
472
-		wp_localize_script( 'nav-menu', 'menus', $nav_menus_l10n );
472
+		wp_localize_script('nav-menu', 'menus', $nav_menus_l10n);
473 473
 	}
474 474
 
475 475
 	/**
@@ -486,13 +486,13 @@  discard block
 block discarded – undo
486 486
 	 * @param string      $setting_id   ID for dynamic setting, usually coming from `$_POST['customized']`.
487 487
 	 * @return array|false
488 488
 	 */
489
-	public function filter_dynamic_setting_args( $setting_args, $setting_id ) {
490
-		if ( preg_match( WP_Customize_Nav_Menu_Setting::ID_PATTERN, $setting_id ) ) {
489
+	public function filter_dynamic_setting_args($setting_args, $setting_id) {
490
+		if (preg_match(WP_Customize_Nav_Menu_Setting::ID_PATTERN, $setting_id)) {
491 491
 			$setting_args = array(
492 492
 				'type'      => WP_Customize_Nav_Menu_Setting::TYPE,
493 493
 				'transport' => 'postMessage',
494 494
 			);
495
-		} elseif ( preg_match( WP_Customize_Nav_Menu_Item_Setting::ID_PATTERN, $setting_id ) ) {
495
+		} elseif (preg_match(WP_Customize_Nav_Menu_Item_Setting::ID_PATTERN, $setting_id)) {
496 496
 			$setting_args = array(
497 497
 				'type'      => WP_Customize_Nav_Menu_Item_Setting::TYPE,
498 498
 				'transport' => 'postMessage',
@@ -512,12 +512,12 @@  discard block
 block discarded – undo
512 512
 	 * @param array  $setting_args  WP_Customize_Setting or a subclass.
513 513
 	 * @return string
514 514
 	 */
515
-	public function filter_dynamic_setting_class( $setting_class, $setting_id, $setting_args ) {
516
-		unset( $setting_id );
515
+	public function filter_dynamic_setting_class($setting_class, $setting_id, $setting_args) {
516
+		unset($setting_id);
517 517
 
518
-		if ( ! empty( $setting_args['type'] ) && WP_Customize_Nav_Menu_Setting::TYPE === $setting_args['type'] ) {
518
+		if ( ! empty($setting_args['type']) && WP_Customize_Nav_Menu_Setting::TYPE === $setting_args['type']) {
519 519
 			$setting_class = 'WP_Customize_Nav_Menu_Setting';
520
-		} elseif ( ! empty( $setting_args['type'] ) && WP_Customize_Nav_Menu_Item_Setting::TYPE === $setting_args['type'] ) {
520
+		} elseif ( ! empty($setting_args['type']) && WP_Customize_Nav_Menu_Item_Setting::TYPE === $setting_args['type']) {
521 521
 			$setting_class = 'WP_Customize_Nav_Menu_Item_Setting';
522 522
 		}
523 523
 		return $setting_class;
@@ -533,172 +533,172 @@  discard block
 block discarded – undo
533 533
 
534 534
 		// Preview settings for nav menus early so that the sections and controls will be added properly.
535 535
 		$nav_menus_setting_ids = array();
536
-		foreach ( array_keys( $this->manager->unsanitized_post_values() ) as $setting_id ) {
537
-			if ( preg_match( '/^(nav_menu_locations|nav_menu|nav_menu_item)\[/', $setting_id ) ) {
536
+		foreach (array_keys($this->manager->unsanitized_post_values()) as $setting_id) {
537
+			if (preg_match('/^(nav_menu_locations|nav_menu|nav_menu_item)\[/', $setting_id)) {
538 538
 				$nav_menus_setting_ids[] = $setting_id;
539 539
 			}
540 540
 		}
541
-		$this->manager->add_dynamic_settings( $nav_menus_setting_ids );
542
-		if ( ! $this->manager->doing_ajax( 'customize_save' ) ) {
543
-			foreach ( $nav_menus_setting_ids as $setting_id ) {
544
-				$setting = $this->manager->get_setting( $setting_id );
545
-				if ( $setting ) {
541
+		$this->manager->add_dynamic_settings($nav_menus_setting_ids);
542
+		if ( ! $this->manager->doing_ajax('customize_save')) {
543
+			foreach ($nav_menus_setting_ids as $setting_id) {
544
+				$setting = $this->manager->get_setting($setting_id);
545
+				if ($setting) {
546 546
 					$setting->preview();
547 547
 				}
548 548
 			}
549 549
 		}
550 550
 
551 551
 		// Require JS-rendered control types.
552
-		$this->manager->register_panel_type( 'WP_Customize_Nav_Menus_Panel' );
553
-		$this->manager->register_control_type( 'WP_Customize_Nav_Menu_Control' );
554
-		$this->manager->register_control_type( 'WP_Customize_Nav_Menu_Name_Control' );
555
-		$this->manager->register_control_type( 'WP_Customize_Nav_Menu_Auto_Add_Control' );
556
-		$this->manager->register_control_type( 'WP_Customize_Nav_Menu_Item_Control' );
552
+		$this->manager->register_panel_type('WP_Customize_Nav_Menus_Panel');
553
+		$this->manager->register_control_type('WP_Customize_Nav_Menu_Control');
554
+		$this->manager->register_control_type('WP_Customize_Nav_Menu_Name_Control');
555
+		$this->manager->register_control_type('WP_Customize_Nav_Menu_Auto_Add_Control');
556
+		$this->manager->register_control_type('WP_Customize_Nav_Menu_Item_Control');
557 557
 
558 558
 		// Create a panel for Menus.
559
-		$description = '<p>' . __( 'This panel is used for managing navigation menus for content you have already published on your site. You can create menus and add items for existing content such as pages, posts, categories, tags, formats, or custom links.' ) . '</p>';
560
-		if ( current_theme_supports( 'widgets' ) ) {
559
+		$description = '<p>'.__('This panel is used for managing navigation menus for content you have already published on your site. You can create menus and add items for existing content such as pages, posts, categories, tags, formats, or custom links.').'</p>';
560
+		if (current_theme_supports('widgets')) {
561 561
 			/* translators: URL to the widgets panel of the customizer */
562
-			$description .= '<p>' . sprintf( __( 'Menus can be displayed in locations defined by your theme or in <a href="%s">widget areas</a> by adding a &#8220;Custom Menu&#8221; widget.' ), "javascript:wp.customize.panel( 'widgets' ).focus();" ) . '</p>';
562
+			$description .= '<p>'.sprintf(__('Menus can be displayed in locations defined by your theme or in <a href="%s">widget areas</a> by adding a &#8220;Custom Menu&#8221; widget.'), "javascript:wp.customize.panel( 'widgets' ).focus();").'</p>';
563 563
 		} else {
564
-			$description .= '<p>' . __( 'Menus can be displayed in locations defined by your theme.' ) . '</p>';
564
+			$description .= '<p>'.__('Menus can be displayed in locations defined by your theme.').'</p>';
565 565
 		}
566
-		$this->manager->add_panel( new WP_Customize_Nav_Menus_Panel( $this->manager, 'nav_menus', array(
567
-			'title'       => __( 'Menus' ),
566
+		$this->manager->add_panel(new WP_Customize_Nav_Menus_Panel($this->manager, 'nav_menus', array(
567
+			'title'       => __('Menus'),
568 568
 			'description' => $description,
569 569
 			'priority'    => 100,
570 570
 			// 'theme_supports' => 'menus|widgets', @todo allow multiple theme supports
571
-		) ) );
571
+		)));
572 572
 		$menus = wp_get_nav_menus();
573 573
 
574 574
 		// Menu locations.
575 575
 		$locations     = get_registered_nav_menus();
576
-		$num_locations = count( array_keys( $locations ) );
577
-		if ( 1 == $num_locations ) {
578
-			$description = '<p>' . __( 'Your theme supports one menu. Select which menu you would like to use.' ) . '</p>';
576
+		$num_locations = count(array_keys($locations));
577
+		if (1 == $num_locations) {
578
+			$description = '<p>'.__('Your theme supports one menu. Select which menu you would like to use.').'</p>';
579 579
 		} else {
580 580
 			/* translators: %s: number of menu locations */
581
-			$description = '<p>' . sprintf( _n( 'Your theme supports %s menu. Select which menu appears in each location.', 'Your theme supports %s menus. Select which menu appears in each location.', $num_locations ), number_format_i18n( $num_locations ) ) . '</p>';
581
+			$description = '<p>'.sprintf(_n('Your theme supports %s menu. Select which menu appears in each location.', 'Your theme supports %s menus. Select which menu appears in each location.', $num_locations), number_format_i18n($num_locations)).'</p>';
582 582
 		}
583
-		if ( current_theme_supports( 'widgets' ) ) {
583
+		if (current_theme_supports('widgets')) {
584 584
 			/* translators: URL to the widgets panel of the customizer */
585
-			$description .= '<p>' . sprintf( __( 'You can also place menus in <a href="%s">widget areas</a> with the &#8220;Custom Menu&#8221; widget.' ), "javascript:wp.customize.panel( 'widgets' ).focus();" ) . '</p>';
585
+			$description .= '<p>'.sprintf(__('You can also place menus in <a href="%s">widget areas</a> with the &#8220;Custom Menu&#8221; widget.'), "javascript:wp.customize.panel( 'widgets' ).focus();").'</p>';
586 586
 		}
587 587
 
588
-		$this->manager->add_section( 'menu_locations', array(
589
-			'title'       => __( 'Menu Locations' ),
588
+		$this->manager->add_section('menu_locations', array(
589
+			'title'       => __('Menu Locations'),
590 590
 			'panel'       => 'nav_menus',
591 591
 			'priority'    => 5,
592 592
 			'description' => $description,
593
-		) );
593
+		));
594 594
 
595
-		$choices = array( '0' => __( '&mdash; Select &mdash;' ) );
596
-		foreach ( $menus as $menu ) {
597
-			$choices[ $menu->term_id ] = wp_html_excerpt( $menu->name, 40, '&hellip;' );
595
+		$choices = array('0' => __('&mdash; Select &mdash;'));
596
+		foreach ($menus as $menu) {
597
+			$choices[$menu->term_id] = wp_html_excerpt($menu->name, 40, '&hellip;');
598 598
 		}
599 599
 
600
-		foreach ( $locations as $location => $description ) {
600
+		foreach ($locations as $location => $description) {
601 601
 			$setting_id = "nav_menu_locations[{$location}]";
602 602
 
603
-			$setting = $this->manager->get_setting( $setting_id );
604
-			if ( $setting ) {
603
+			$setting = $this->manager->get_setting($setting_id);
604
+			if ($setting) {
605 605
 				$setting->transport = 'postMessage';
606
-				remove_filter( "customize_sanitize_{$setting_id}", 'absint' );
607
-				add_filter( "customize_sanitize_{$setting_id}", array( $this, 'intval_base10' ) );
606
+				remove_filter("customize_sanitize_{$setting_id}", 'absint');
607
+				add_filter("customize_sanitize_{$setting_id}", array($this, 'intval_base10'));
608 608
 			} else {
609
-				$this->manager->add_setting( $setting_id, array(
610
-					'sanitize_callback' => array( $this, 'intval_base10' ),
609
+				$this->manager->add_setting($setting_id, array(
610
+					'sanitize_callback' => array($this, 'intval_base10'),
611 611
 					'theme_supports'    => 'menus',
612 612
 					'type'              => 'theme_mod',
613 613
 					'transport'         => 'postMessage',
614 614
 					'default'           => 0,
615
-				) );
615
+				));
616 616
 			}
617 617
 
618
-			$this->manager->add_control( new WP_Customize_Nav_Menu_Location_Control( $this->manager, $setting_id, array(
618
+			$this->manager->add_control(new WP_Customize_Nav_Menu_Location_Control($this->manager, $setting_id, array(
619 619
 				'label'       => $description,
620 620
 				'location_id' => $location,
621 621
 				'section'     => 'menu_locations',
622 622
 				'choices'     => $choices,
623
-			) ) );
623
+			)));
624 624
 		}
625 625
 
626 626
 		// Register each menu as a Customizer section, and add each menu item to each menu.
627
-		foreach ( $menus as $menu ) {
627
+		foreach ($menus as $menu) {
628 628
 			$menu_id = $menu->term_id;
629 629
 
630 630
 			// Create a section for each menu.
631
-			$section_id = 'nav_menu[' . $menu_id . ']';
632
-			$this->manager->add_section( new WP_Customize_Nav_Menu_Section( $this->manager, $section_id, array(
633
-				'title'     => html_entity_decode( $menu->name, ENT_QUOTES, get_bloginfo( 'charset' ) ),
631
+			$section_id = 'nav_menu['.$menu_id.']';
632
+			$this->manager->add_section(new WP_Customize_Nav_Menu_Section($this->manager, $section_id, array(
633
+				'title'     => html_entity_decode($menu->name, ENT_QUOTES, get_bloginfo('charset')),
634 634
 				'priority'  => 10,
635 635
 				'panel'     => 'nav_menus',
636
-			) ) );
636
+			)));
637 637
 
638
-			$nav_menu_setting_id = 'nav_menu[' . $menu_id . ']';
639
-			$this->manager->add_setting( new WP_Customize_Nav_Menu_Setting( $this->manager, $nav_menu_setting_id, array(
638
+			$nav_menu_setting_id = 'nav_menu['.$menu_id.']';
639
+			$this->manager->add_setting(new WP_Customize_Nav_Menu_Setting($this->manager, $nav_menu_setting_id, array(
640 640
 				'transport' => 'postMessage',
641
-			) ) );
641
+			)));
642 642
 
643 643
 			// Add the menu contents.
644
-			$menu_items = (array) wp_get_nav_menu_items( $menu_id );
644
+			$menu_items = (array) wp_get_nav_menu_items($menu_id);
645 645
 
646
-			foreach ( array_values( $menu_items ) as $i => $item ) {
646
+			foreach (array_values($menu_items) as $i => $item) {
647 647
 
648 648
 				// Create a setting for each menu item (which doesn't actually manage data, currently).
649
-				$menu_item_setting_id = 'nav_menu_item[' . $item->ID . ']';
649
+				$menu_item_setting_id = 'nav_menu_item['.$item->ID.']';
650 650
 
651 651
 				$value = (array) $item;
652
-				if ( empty( $value['post_title'] ) ) {
652
+				if (empty($value['post_title'])) {
653 653
 					$value['title'] = '';
654 654
 				}
655 655
 
656 656
 				$value['nav_menu_term_id'] = $menu_id;
657
-				$this->manager->add_setting( new WP_Customize_Nav_Menu_Item_Setting( $this->manager, $menu_item_setting_id, array(
657
+				$this->manager->add_setting(new WP_Customize_Nav_Menu_Item_Setting($this->manager, $menu_item_setting_id, array(
658 658
 					'value'     => $value,
659 659
 					'transport' => 'postMessage',
660
-				) ) );
660
+				)));
661 661
 
662 662
 				// Create a control for each menu item.
663
-				$this->manager->add_control( new WP_Customize_Nav_Menu_Item_Control( $this->manager, $menu_item_setting_id, array(
663
+				$this->manager->add_control(new WP_Customize_Nav_Menu_Item_Control($this->manager, $menu_item_setting_id, array(
664 664
 					'label'    => $item->title,
665 665
 					'section'  => $section_id,
666 666
 					'priority' => 10 + $i,
667
-				) ) );
667
+				)));
668 668
 			}
669 669
 
670 670
 			// Note: other controls inside of this section get added dynamically in JS via the MenuSection.ready() function.
671 671
 		}
672 672
 
673 673
 		// Add the add-new-menu section and controls.
674
-		$this->manager->add_section( new WP_Customize_New_Menu_Section( $this->manager, 'add_menu', array(
675
-			'title'    => __( 'Add a Menu' ),
674
+		$this->manager->add_section(new WP_Customize_New_Menu_Section($this->manager, 'add_menu', array(
675
+			'title'    => __('Add a Menu'),
676 676
 			'panel'    => 'nav_menus',
677 677
 			'priority' => 999,
678
-		) ) );
678
+		)));
679 679
 
680
-		$this->manager->add_control( 'new_menu_name', array(
680
+		$this->manager->add_control('new_menu_name', array(
681 681
 			'label'       => '',
682 682
 			'section'     => 'add_menu',
683 683
 			'type'        => 'text',
684 684
 			'settings'    => array(),
685 685
 			'input_attrs' => array(
686 686
 				'class'       => 'menu-name-field',
687
-				'placeholder' => __( 'New menu name' ),
687
+				'placeholder' => __('New menu name'),
688 688
 			),
689
-		) );
689
+		));
690 690
 
691
-		$this->manager->add_control( new WP_Customize_New_Menu_Control( $this->manager, 'create_new_menu', array(
691
+		$this->manager->add_control(new WP_Customize_New_Menu_Control($this->manager, 'create_new_menu', array(
692 692
 			'section'  => 'add_menu',
693 693
 			'settings' => array(),
694
-		) ) );
694
+		)));
695 695
 
696
-		$this->manager->add_setting( new WP_Customize_Filter_Setting( $this->manager, 'nav_menus_created_posts', array(
696
+		$this->manager->add_setting(new WP_Customize_Filter_Setting($this->manager, 'nav_menus_created_posts', array(
697 697
 			'transport' => 'postMessage',
698 698
 			'type' => 'option', // To prevent theme prefix in changeset.
699 699
 			'default' => array(),
700
-			'sanitize_callback' => array( $this, 'sanitize_nav_menus_created_posts' ),
701
-		) ) );
700
+			'sanitize_callback' => array($this, 'sanitize_nav_menus_created_posts'),
701
+		)));
702 702
 	}
703 703
 
704 704
 	/**
@@ -713,8 +713,8 @@  discard block
 block discarded – undo
713 713
 	 * @param mixed $value Number to convert.
714 714
 	 * @return int Integer.
715 715
 	 */
716
-	public function intval_base10( $value ) {
717
-		return intval( $value, 10 );
716
+	public function intval_base10($value) {
717
+		return intval($value, 10);
718 718
 	}
719 719
 
720 720
 	/**
@@ -729,9 +729,9 @@  discard block
 block discarded – undo
729 729
 	public function available_item_types() {
730 730
 		$item_types = array();
731 731
 
732
-		$post_types = get_post_types( array( 'show_in_nav_menus' => true ), 'objects' );
733
-		if ( $post_types ) {
734
-			foreach ( $post_types as $slug => $post_type ) {
732
+		$post_types = get_post_types(array('show_in_nav_menus' => true), 'objects');
733
+		if ($post_types) {
734
+			foreach ($post_types as $slug => $post_type) {
735 735
 				$item_types[] = array(
736 736
 					'title'  => $post_type->labels->name,
737 737
 					'type_label' => $post_type->labels->singular_name,
@@ -741,10 +741,10 @@  discard block
 block discarded – undo
741 741
 			}
742 742
 		}
743 743
 
744
-		$taxonomies = get_taxonomies( array( 'show_in_nav_menus' => true ), 'objects' );
745
-		if ( $taxonomies ) {
746
-			foreach ( $taxonomies as $slug => $taxonomy ) {
747
-				if ( 'post_format' === $taxonomy && ! current_theme_supports( 'post-formats' ) ) {
744
+		$taxonomies = get_taxonomies(array('show_in_nav_menus' => true), 'objects');
745
+		if ($taxonomies) {
746
+			foreach ($taxonomies as $slug => $taxonomy) {
747
+				if ('post_format' === $taxonomy && ! current_theme_supports('post-formats')) {
748 748
 					continue;
749 749
 				}
750 750
 				$item_types[] = array(
@@ -764,7 +764,7 @@  discard block
 block discarded – undo
764 764
 		 *
765 765
 		 * @param array $item_types Custom menu item types.
766 766
 		 */
767
-		$item_types = apply_filters( 'customize_nav_menu_available_item_types', $item_types );
767
+		$item_types = apply_filters('customize_nav_menu_available_item_types', $item_types);
768 768
 
769 769
 		return $item_types;
770 770
 	}
@@ -785,37 +785,37 @@  discard block
 block discarded – undo
785 785
 	 * }
786 786
 	 * @return WP_Post|WP_Error Inserted auto-draft post object or error.
787 787
 	 */
788
-	public function insert_auto_draft_post( $postarr ) {
789
-		if ( ! isset( $postarr['post_type'] ) || ! post_type_exists( $postarr['post_type'] )  ) {
790
-			return new WP_Error( 'unknown_post_type', __( 'Unknown post type' ) );
788
+	public function insert_auto_draft_post($postarr) {
789
+		if ( ! isset($postarr['post_type']) || ! post_type_exists($postarr['post_type'])) {
790
+			return new WP_Error('unknown_post_type', __('Unknown post type'));
791 791
 		}
792
-		if ( empty( $postarr['post_title'] ) ) {
793
-			return new WP_Error( 'empty_title', __( 'Empty title' ) );
792
+		if (empty($postarr['post_title'])) {
793
+			return new WP_Error('empty_title', __('Empty title'));
794 794
 		}
795
-		if ( ! empty( $postarr['post_status'] ) ) {
796
-			return new WP_Error( 'status_forbidden', __( 'Status is forbidden' ) );
795
+		if ( ! empty($postarr['post_status'])) {
796
+			return new WP_Error('status_forbidden', __('Status is forbidden'));
797 797
 		}
798 798
 
799 799
 		$postarr['post_status'] = 'auto-draft';
800 800
 
801 801
 		// Auto-drafts are allowed to have empty post_names, so it has to be explicitly set.
802
-		if ( empty( $postarr['post_name'] ) ) {
803
-			$postarr['post_name'] = sanitize_title( $postarr['post_title'] );
802
+		if (empty($postarr['post_name'])) {
803
+			$postarr['post_name'] = sanitize_title($postarr['post_title']);
804 804
 		}
805
-		if ( ! isset( $postarr['meta_input'] ) ) {
805
+		if ( ! isset($postarr['meta_input'])) {
806 806
 			$postarr['meta_input'] = array();
807 807
 		}
808 808
 		$postarr['meta_input']['_customize_draft_post_name'] = $postarr['post_name'];
809
-		unset( $postarr['post_name'] );
809
+		unset($postarr['post_name']);
810 810
 
811
-		add_filter( 'wp_insert_post_empty_content', '__return_false', 1000 );
812
-		$r = wp_insert_post( wp_slash( $postarr ), true );
813
-		remove_filter( 'wp_insert_post_empty_content', '__return_false', 1000 );
811
+		add_filter('wp_insert_post_empty_content', '__return_false', 1000);
812
+		$r = wp_insert_post(wp_slash($postarr), true);
813
+		remove_filter('wp_insert_post_empty_content', '__return_false', 1000);
814 814
 
815
-		if ( is_wp_error( $r ) ) {
815
+		if (is_wp_error($r)) {
816 816
 			return $r;
817 817
 		} else {
818
-			return get_post( $r );
818
+			return get_post($r);
819 819
 		}
820 820
 	}
821 821
 
@@ -826,22 +826,22 @@  discard block
 block discarded – undo
826 826
 	 * @since 4.7.0
827 827
 	 */
828 828
 	public function ajax_insert_auto_draft_post() {
829
-		if ( ! check_ajax_referer( 'customize-menus', 'customize-menus-nonce', false ) ) {
830
-			wp_send_json_error( 'bad_nonce', 400 );
829
+		if ( ! check_ajax_referer('customize-menus', 'customize-menus-nonce', false)) {
830
+			wp_send_json_error('bad_nonce', 400);
831 831
 		}
832 832
 
833
-		if ( ! current_user_can( 'customize' ) ) {
834
-			wp_send_json_error( 'customize_not_allowed', 403 );
833
+		if ( ! current_user_can('customize')) {
834
+			wp_send_json_error('customize_not_allowed', 403);
835 835
 		}
836 836
 
837
-		if ( empty( $_POST['params'] ) || ! is_array( $_POST['params'] ) ) {
838
-			wp_send_json_error( 'missing_params', 400 );
837
+		if (empty($_POST['params']) || ! is_array($_POST['params'])) {
838
+			wp_send_json_error('missing_params', 400);
839 839
 		}
840 840
 
841
-		$params = wp_unslash( $_POST['params'] );
842
-		$illegal_params = array_diff( array_keys( $params ), array( 'post_type', 'post_title' ) );
843
-		if ( ! empty( $illegal_params ) ) {
844
-			wp_send_json_error( 'illegal_params', 400 );
841
+		$params = wp_unslash($_POST['params']);
842
+		$illegal_params = array_diff(array_keys($params), array('post_type', 'post_title'));
843
+		if ( ! empty($illegal_params)) {
844
+			wp_send_json_error('illegal_params', 400);
845 845
 		}
846 846
 
847 847
 		$params = array_merge(
@@ -852,44 +852,44 @@  discard block
 block discarded – undo
852 852
 			$params
853 853
 		);
854 854
 
855
-		if ( empty( $params['post_type'] ) || ! post_type_exists( $params['post_type'] ) ) {
856
-			status_header( 400 );
857
-			wp_send_json_error( 'missing_post_type_param' );
855
+		if (empty($params['post_type']) || ! post_type_exists($params['post_type'])) {
856
+			status_header(400);
857
+			wp_send_json_error('missing_post_type_param');
858 858
 		}
859 859
 
860
-		$post_type_object = get_post_type_object( $params['post_type'] );
861
-		if ( ! current_user_can( $post_type_object->cap->create_posts ) || ! current_user_can( $post_type_object->cap->publish_posts ) ) {
862
-			status_header( 403 );
863
-			wp_send_json_error( 'insufficient_post_permissions' );
860
+		$post_type_object = get_post_type_object($params['post_type']);
861
+		if ( ! current_user_can($post_type_object->cap->create_posts) || ! current_user_can($post_type_object->cap->publish_posts)) {
862
+			status_header(403);
863
+			wp_send_json_error('insufficient_post_permissions');
864 864
 		}
865 865
 
866
-		$params['post_title'] = trim( $params['post_title'] );
867
-		if ( '' === $params['post_title'] ) {
868
-			status_header( 400 );
869
-			wp_send_json_error( 'missing_post_title' );
866
+		$params['post_title'] = trim($params['post_title']);
867
+		if ('' === $params['post_title']) {
868
+			status_header(400);
869
+			wp_send_json_error('missing_post_title');
870 870
 		}
871 871
 
872
-		$r = $this->insert_auto_draft_post( $params );
873
-		if ( is_wp_error( $r ) ) {
872
+		$r = $this->insert_auto_draft_post($params);
873
+		if (is_wp_error($r)) {
874 874
 			$error = $r;
875
-			if ( ! empty( $post_type_object->labels->singular_name ) ) {
875
+			if ( ! empty($post_type_object->labels->singular_name)) {
876 876
 				$singular_name = $post_type_object->labels->singular_name;
877 877
 			} else {
878
-				$singular_name = __( 'Post' );
878
+				$singular_name = __('Post');
879 879
 			}
880 880
 
881 881
 			$data = array(
882 882
 				/* translators: %1$s is the post type name and %2$s is the error message. */
883
-				'message' => sprintf( __( '%1$s could not be created: %2$s' ), $singular_name, $error->get_error_message() ),
883
+				'message' => sprintf(__('%1$s could not be created: %2$s'), $singular_name, $error->get_error_message()),
884 884
 			);
885
-			wp_send_json_error( $data );
885
+			wp_send_json_error($data);
886 886
 		} else {
887 887
 			$post = $r;
888 888
 			$data = array(
889 889
 				'post_id' => $post->ID,
890
-				'url'     => get_permalink( $post->ID ),
890
+				'url'     => get_permalink($post->ID),
891 891
 			);
892
-			wp_send_json_success( $data );
892
+			wp_send_json_success($data);
893 893
 		}
894 894
 	}
895 895
 
@@ -914,7 +914,7 @@  discard block
 block discarded – undo
914 914
 						<button type="button" class="button-link item-add">
915 915
 							<span class="screen-reader-text"><?php
916 916
 								/* translators: 1: Title of a menu item, 2: Type of a menu item */
917
-								printf( __( 'Add to menu: %1$s (%2$s)' ), '{{ data.title || wp.customize.Menus.data.l10n.untitled }}', '{{ data.type_label }}' );
917
+								printf(__('Add to menu: %1$s (%2$s)'), '{{ data.title || wp.customize.Menus.data.l10n.untitled }}', '{{ data.type_label }}');
918 918
 							?></span>
919 919
 						</button>
920 920
 					</div>
@@ -927,10 +927,10 @@  discard block
 block discarded – undo
927 927
 				<?php
928 928
 				printf(
929 929
 					'<button type="button" class="menus-move-up">%1$s</button><button type="button" class="menus-move-down">%2$s</button><button type="button" class="menus-move-left">%3$s</button><button type="button" class="menus-move-right">%4$s</button>',
930
-					__( 'Move up' ),
931
-					__( 'Move down' ),
932
-					__( 'Move one level up' ),
933
-					__( 'Move one level down' )
930
+					__('Move up'),
931
+					__('Move down'),
932
+					__('Move one level up'),
933
+					__('Move one level down')
934 934
 				);
935 935
 				?>
936 936
 			</div>
@@ -949,27 +949,27 @@  discard block
 block discarded – undo
949 949
 		<div id="available-menu-items" class="accordion-container">
950 950
 			<div class="customize-section-title">
951 951
 				<button type="button" class="customize-section-back" tabindex="-1">
952
-					<span class="screen-reader-text"><?php _e( 'Back' ); ?></span>
952
+					<span class="screen-reader-text"><?php _e('Back'); ?></span>
953 953
 				</button>
954 954
 				<h3>
955 955
 					<span class="customize-action">
956 956
 						<?php
957 957
 							/* translators: &#9656; is the unicode right-pointing triangle, and %s is the section title in the Customizer */
958
-							printf( __( 'Customizing &#9656; %s' ), esc_html( $this->manager->get_panel( 'nav_menus' )->title ) );
958
+							printf(__('Customizing &#9656; %s'), esc_html($this->manager->get_panel('nav_menus')->title));
959 959
 						?>
960 960
 					</span>
961
-					<?php _e( 'Add Menu Items' ); ?>
961
+					<?php _e('Add Menu Items'); ?>
962 962
 				</h3>
963 963
 			</div>
964 964
 			<div id="available-menu-items-search" class="accordion-section cannot-expand">
965 965
 				<div class="accordion-section-title">
966
-					<label class="screen-reader-text" for="menu-items-search"><?php _e( 'Search Menu Items' ); ?></label>
967
-					<input type="text" id="menu-items-search" placeholder="<?php esc_attr_e( 'Search menu items&hellip;' ) ?>" aria-describedby="menu-items-search-desc" />
968
-					<p class="screen-reader-text" id="menu-items-search-desc"><?php _e( 'The search results will be updated as you type.' ); ?></p>
966
+					<label class="screen-reader-text" for="menu-items-search"><?php _e('Search Menu Items'); ?></label>
967
+					<input type="text" id="menu-items-search" placeholder="<?php esc_attr_e('Search menu items&hellip;') ?>" aria-describedby="menu-items-search-desc" />
968
+					<p class="screen-reader-text" id="menu-items-search-desc"><?php _e('The search results will be updated as you type.'); ?></p>
969 969
 					<span class="spinner"></span>
970 970
 				</div>
971 971
 				<div class="search-icon" aria-hidden="true"></div>
972
-				<button type="button" class="clear-results"><span class="screen-reader-text"><?php _e( 'Clear Results' ); ?></span></button>
972
+				<button type="button" class="clear-results"><span class="screen-reader-text"><?php _e('Clear Results'); ?></span></button>
973 973
 				<ul class="accordion-section-content available-menu-items-list" data-type="search"></ul>
974 974
 			</div>
975 975
 			<?php
@@ -977,20 +977,20 @@  discard block
 block discarded – undo
977 977
 			// Ensure the page post type comes first in the list.
978 978
 			$item_types = $this->available_item_types();
979 979
 			$page_item_type = null;
980
-			foreach ( $item_types as $i => $item_type ) {
981
-				if ( isset( $item_type['object'] ) && 'page' === $item_type['object'] ) {
980
+			foreach ($item_types as $i => $item_type) {
981
+				if (isset($item_type['object']) && 'page' === $item_type['object']) {
982 982
 					$page_item_type = $item_type;
983
-					unset( $item_types[ $i ] );
983
+					unset($item_types[$i]);
984 984
 				}
985 985
 			}
986 986
 
987 987
 			$this->print_custom_links_available_menu_item();
988
-			if ( $page_item_type ) {
989
-				$this->print_post_type_container( $page_item_type );
988
+			if ($page_item_type) {
989
+				$this->print_post_type_container($page_item_type);
990 990
 			}
991 991
 			// Containers for per-post-type item browsing; items are added with JS.
992
-			foreach ( $item_types as $item_type ) {
993
-				$this->print_post_type_container( $item_type );
992
+			foreach ($item_types as $item_type) {
993
+				$this->print_post_type_container($item_type);
994 994
 			}
995 995
 			?>
996 996
 		</div><!-- #available-menu-items -->
@@ -1008,32 +1008,32 @@  discard block
 block discarded – undo
1008 1008
 	 * @param array $available_item_type Menu item data to output, including title, type, and label.
1009 1009
 	 * @return void
1010 1010
 	 */
1011
-	protected function print_post_type_container( $available_item_type ) {
1012
-		$id = sprintf( 'available-menu-items-%s-%s', $available_item_type['type'], $available_item_type['object'] );
1011
+	protected function print_post_type_container($available_item_type) {
1012
+		$id = sprintf('available-menu-items-%s-%s', $available_item_type['type'], $available_item_type['object']);
1013 1013
 		?>
1014
-		<div id="<?php echo esc_attr( $id ); ?>" class="accordion-section">
1014
+		<div id="<?php echo esc_attr($id); ?>" class="accordion-section">
1015 1015
 			<h4 class="accordion-section-title" role="presentation">
1016
-				<?php echo esc_html( $available_item_type['title'] ); ?>
1016
+				<?php echo esc_html($available_item_type['title']); ?>
1017 1017
 				<span class="spinner"></span>
1018
-				<span class="no-items"><?php _e( 'No items' ); ?></span>
1018
+				<span class="no-items"><?php _e('No items'); ?></span>
1019 1019
 				<button type="button" class="button-link" aria-expanded="false">
1020 1020
 					<span class="screen-reader-text"><?php
1021 1021
 						/* translators: %s: Title of a section with menu items */
1022
-						printf( __( 'Toggle section: %s' ), esc_html( $available_item_type['title'] ) ); ?></span>
1022
+						printf(__('Toggle section: %s'), esc_html($available_item_type['title'])); ?></span>
1023 1023
 					<span class="toggle-indicator" aria-hidden="true"></span>
1024 1024
 				</button>
1025 1025
 			</h4>
1026 1026
 			<div class="accordion-section-content">
1027
-				<?php if ( 'post_type' === $available_item_type['type'] ) : ?>
1028
-					<?php $post_type_obj = get_post_type_object( $available_item_type['object'] ); ?>
1029
-					<?php if ( current_user_can( $post_type_obj->cap->create_posts ) && current_user_can( $post_type_obj->cap->publish_posts ) ) : ?>
1027
+				<?php if ('post_type' === $available_item_type['type']) : ?>
1028
+					<?php $post_type_obj = get_post_type_object($available_item_type['object']); ?>
1029
+					<?php if (current_user_can($post_type_obj->cap->create_posts) && current_user_can($post_type_obj->cap->publish_posts)) : ?>
1030 1030
 						<div class="new-content-item">
1031
-							<input type="text" class="create-item-input" placeholder="<?php echo esc_attr( $post_type_obj->labels->add_new_item ); ?>">
1032
-							<button type="button" class="button add-content"><?php _e( 'Add' ); ?></button>
1031
+							<input type="text" class="create-item-input" placeholder="<?php echo esc_attr($post_type_obj->labels->add_new_item); ?>">
1032
+							<button type="button" class="button add-content"><?php _e('Add'); ?></button>
1033 1033
 						</div>
1034 1034
 					<?php endif; ?>
1035 1035
 				<?php endif; ?>
1036
-				<ul class="available-menu-items-list" data-type="<?php echo esc_attr( $available_item_type['type'] ); ?>" data-object="<?php echo esc_attr( $available_item_type['object'] ); ?>" data-type_label="<?php echo esc_attr( isset( $available_item_type['type_label'] ) ? $available_item_type['type_label'] : $available_item_type['type'] ); ?>"></ul>
1036
+				<ul class="available-menu-items-list" data-type="<?php echo esc_attr($available_item_type['type']); ?>" data-object="<?php echo esc_attr($available_item_type['object']); ?>" data-type_label="<?php echo esc_attr(isset($available_item_type['type_label']) ? $available_item_type['type_label'] : $available_item_type['type']); ?>"></ul>
1037 1037
 			</div>
1038 1038
 		</div>
1039 1039
 		<?php
@@ -1051,25 +1051,25 @@  discard block
 block discarded – undo
1051 1051
 		?>
1052 1052
 		<div id="new-custom-menu-item" class="accordion-section">
1053 1053
 			<h4 class="accordion-section-title" role="presentation">
1054
-				<?php _e( 'Custom Links' ); ?>
1054
+				<?php _e('Custom Links'); ?>
1055 1055
 				<button type="button" class="button-link" aria-expanded="false">
1056
-					<span class="screen-reader-text"><?php _e( 'Toggle section: Custom Links' ); ?></span>
1056
+					<span class="screen-reader-text"><?php _e('Toggle section: Custom Links'); ?></span>
1057 1057
 					<span class="toggle-indicator" aria-hidden="true"></span>
1058 1058
 				</button>
1059 1059
 			</h4>
1060 1060
 			<div class="accordion-section-content customlinkdiv">
1061 1061
 				<input type="hidden" value="custom" id="custom-menu-item-type" name="menu-item[-1][menu-item-type]" />
1062 1062
 				<p id="menu-item-url-wrap" class="wp-clearfix">
1063
-					<label class="howto" for="custom-menu-item-url"><?php _e( 'URL' ); ?></label>
1063
+					<label class="howto" for="custom-menu-item-url"><?php _e('URL'); ?></label>
1064 1064
 					<input id="custom-menu-item-url" name="menu-item[-1][menu-item-url]" type="text" class="code menu-item-textbox" value="http://">
1065 1065
 				</p>
1066 1066
 				<p id="menu-item-name-wrap" class="wp-clearfix">
1067
-					<label class="howto" for="custom-menu-item-name"><?php _e( 'Link Text' ); ?></label>
1067
+					<label class="howto" for="custom-menu-item-name"><?php _e('Link Text'); ?></label>
1068 1068
 					<input id="custom-menu-item-name" name="menu-item[-1][menu-item-title]" type="text" class="regular-text menu-item-textbox">
1069 1069
 				</p>
1070 1070
 				<p class="button-controls">
1071 1071
 					<span class="add-to-menu">
1072
-						<input type="submit" class="button submit-add-to-menu right" value="<?php esc_attr_e( 'Add to Menu' ); ?>" name="add-custom-menu-item" id="custom-menu-item-submit">
1072
+						<input type="submit" class="button submit-add-to-menu right" value="<?php esc_attr_e('Add to Menu'); ?>" name="add-custom-menu-item" id="custom-menu-item-submit">
1073 1073
 						<span class="spinner"></span>
1074 1074
 					</span>
1075 1075
 				</p>
@@ -1101,17 +1101,17 @@  discard block
 block discarded – undo
1101 1101
 	 * @param string      $partial_id   Partial ID.
1102 1102
 	 * @return array Partial args.
1103 1103
 	 */
1104
-	public function customize_dynamic_partial_args( $partial_args, $partial_id ) {
1104
+	public function customize_dynamic_partial_args($partial_args, $partial_id) {
1105 1105
 
1106
-		if ( preg_match( '/^nav_menu_instance\[[0-9a-f]{32}\]$/', $partial_id ) ) {
1107
-			if ( false === $partial_args ) {
1106
+		if (preg_match('/^nav_menu_instance\[[0-9a-f]{32}\]$/', $partial_id)) {
1107
+			if (false === $partial_args) {
1108 1108
 				$partial_args = array();
1109 1109
 			}
1110 1110
 			$partial_args = array_merge(
1111 1111
 				$partial_args,
1112 1112
 				array(
1113 1113
 					'type'                => 'nav_menu_instance',
1114
-					'render_callback'     => array( $this, 'render_nav_menu_partial' ),
1114
+					'render_callback'     => array($this, 'render_nav_menu_partial'),
1115 1115
 					'container_inclusive' => true,
1116 1116
 					'settings'            => array(), // Empty because the nav menu instance may relate to a menu or a location.
1117 1117
 					'capability'          => 'edit_theme_options',
@@ -1129,11 +1129,11 @@  discard block
 block discarded – undo
1129 1129
 	 * @access public
1130 1130
 	 */
1131 1131
 	public function customize_preview_init() {
1132
-		add_action( 'wp_enqueue_scripts', array( $this, 'customize_preview_enqueue_deps' ) );
1133
-		add_filter( 'wp_nav_menu_args', array( $this, 'filter_wp_nav_menu_args' ), 1000 );
1134
-		add_filter( 'wp_nav_menu', array( $this, 'filter_wp_nav_menu' ), 10, 2 );
1135
-		add_filter( 'wp_footer', array( $this, 'export_preview_data' ), 1 );
1136
-		add_filter( 'customize_render_partials_response', array( $this, 'export_partial_rendered_nav_menu_instances' ) );
1132
+		add_action('wp_enqueue_scripts', array($this, 'customize_preview_enqueue_deps'));
1133
+		add_filter('wp_nav_menu_args', array($this, 'filter_wp_nav_menu_args'), 1000);
1134
+		add_filter('wp_nav_menu', array($this, 'filter_wp_nav_menu'), 10, 2);
1135
+		add_filter('wp_footer', array($this, 'export_preview_data'), 1);
1136
+		add_filter('customize_render_partials_response', array($this, 'export_partial_rendered_nav_menu_instances'));
1137 1137
 	}
1138 1138
 
1139 1139
 	/**
@@ -1156,21 +1156,21 @@  discard block
 block discarded – undo
1156 1156
 	 * @param array $value Post IDs.
1157 1157
 	 * @returns array Post IDs.
1158 1158
 	 */
1159
-	public function sanitize_nav_menus_created_posts( $value ) {
1159
+	public function sanitize_nav_menus_created_posts($value) {
1160 1160
 		$post_ids = array();
1161
-		foreach ( wp_parse_id_list( $value ) as $post_id ) {
1162
-			if ( empty( $post_id ) ) {
1161
+		foreach (wp_parse_id_list($value) as $post_id) {
1162
+			if (empty($post_id)) {
1163 1163
 				continue;
1164 1164
 			}
1165
-			$post = get_post( $post_id );
1166
-			if ( 'auto-draft' !== $post->post_status ) {
1165
+			$post = get_post($post_id);
1166
+			if ('auto-draft' !== $post->post_status) {
1167 1167
 				continue;
1168 1168
 			}
1169
-			$post_type_obj = get_post_type_object( $post->post_type );
1170
-			if ( ! $post_type_obj ) {
1169
+			$post_type_obj = get_post_type_object($post->post_type);
1170
+			if ( ! $post_type_obj) {
1171 1171
 				continue;
1172 1172
 			}
1173
-			if ( ! current_user_can( $post_type_obj->cap->publish_posts ) || ! current_user_can( $post_type_obj->cap->edit_post, $post_id ) ) {
1173
+			if ( ! current_user_can($post_type_obj->cap->publish_posts) || ! current_user_can($post_type_obj->cap->edit_post, $post_id)) {
1174 1174
 				continue;
1175 1175
 			}
1176 1176
 			$post_ids[] = $post->ID;
@@ -1191,24 +1191,24 @@  discard block
 block discarded – undo
1191 1191
 	 *
1192 1192
 	 * @param WP_Customize_Setting $setting Customizer setting object.
1193 1193
 	 */
1194
-	public function save_nav_menus_created_posts( $setting ) {
1194
+	public function save_nav_menus_created_posts($setting) {
1195 1195
 		$post_ids = $setting->post_value();
1196
-		if ( ! empty( $post_ids ) ) {
1197
-			foreach ( $post_ids as $post_id ) {
1198
-				$target_status = 'attachment' === get_post_type( $post_id ) ? 'inherit' : 'publish';
1196
+		if ( ! empty($post_ids)) {
1197
+			foreach ($post_ids as $post_id) {
1198
+				$target_status = 'attachment' === get_post_type($post_id) ? 'inherit' : 'publish';
1199 1199
 				$args = array(
1200 1200
 					'ID' => $post_id,
1201 1201
 					'post_status' => $target_status,
1202 1202
 				);
1203
-				$post_name = get_post_meta( $post_id, '_customize_draft_post_name', true );
1204
-				if ( $post_name ) {
1203
+				$post_name = get_post_meta($post_id, '_customize_draft_post_name', true);
1204
+				if ($post_name) {
1205 1205
 					$args['post_name'] = $post_name;
1206 1206
 				}
1207 1207
 
1208 1208
 				// Note that wp_publish_post() cannot be used because unique slugs need to be assigned.
1209
-				wp_update_post( wp_slash( $args ) );
1209
+				wp_update_post(wp_slash($args));
1210 1210
 
1211
-				delete_post_meta( $post_id, '_customize_draft_post_name' );
1211
+				delete_post_meta($post_id, '_customize_draft_post_name');
1212 1212
 			}
1213 1213
 		}
1214 1214
 	}
@@ -1224,7 +1224,7 @@  discard block
 block discarded – undo
1224 1224
 	 * @param array $args An array containing wp_nav_menu() arguments.
1225 1225
 	 * @return array Arguments.
1226 1226
 	 */
1227
-	public function filter_wp_nav_menu_args( $args ) {
1227
+	public function filter_wp_nav_menu_args($args) {
1228 1228
 		/*
1229 1229
 		 * The following conditions determine whether or not this instance of
1230 1230
 		 * wp_nav_menu() can use selective refreshed. A wp_nav_menu() can be
@@ -1232,25 +1232,25 @@  discard block
 block discarded – undo
1232 1232
 		 */
1233 1233
 		$can_partial_refresh = (
1234 1234
 			// ...if wp_nav_menu() is directly echoing out the menu (and thus isn't manipulating the string after generated),
1235
-			! empty( $args['echo'] )
1235
+			! empty($args['echo'])
1236 1236
 			&&
1237 1237
 			// ...and if the fallback_cb can be serialized to JSON, since it will be included in the placement context data,
1238
-			( empty( $args['fallback_cb'] ) || is_string( $args['fallback_cb'] ) )
1238
+			(empty($args['fallback_cb']) || is_string($args['fallback_cb']))
1239 1239
 			&&
1240 1240
 			// ...and if the walker can also be serialized to JSON, since it will be included in the placement context data as well,
1241
-			( empty( $args['walker'] ) || is_string( $args['walker'] ) )
1241
+			(empty($args['walker']) || is_string($args['walker']))
1242 1242
 			// ...and if it has a theme location assigned or an assigned menu to display,
1243 1243
 			&& (
1244
-				! empty( $args['theme_location'] )
1244
+				! empty($args['theme_location'])
1245 1245
 				||
1246
-				( ! empty( $args['menu'] ) && ( is_numeric( $args['menu'] ) || is_object( $args['menu'] ) ) )
1246
+				( ! empty($args['menu']) && (is_numeric($args['menu']) || is_object($args['menu'])))
1247 1247
 			)
1248 1248
 			&&
1249 1249
 			// ...and if the nav menu would be rendered with a wrapper container element (upon which to attach data-* attributes).
1250 1250
 			(
1251
-				! empty( $args['container'] )
1251
+				! empty($args['container'])
1252 1252
 				||
1253
-				( isset( $args['items_wrap'] ) && '<' === substr( $args['items_wrap'], 0, 1 ) )
1253
+				(isset($args['items_wrap']) && '<' === substr($args['items_wrap'], 0, 1))
1254 1254
 			)
1255 1255
 		);
1256 1256
 		$args['can_partial_refresh'] = $can_partial_refresh;
@@ -1258,7 +1258,7 @@  discard block
 block discarded – undo
1258 1258
 		$exported_args = $args;
1259 1259
 
1260 1260
 		// Empty out args which may not be JSON-serializable.
1261
-		if ( ! $can_partial_refresh ) {
1261
+		if ( ! $can_partial_refresh) {
1262 1262
 			$exported_args['fallback_cb'] = '';
1263 1263
 			$exported_args['walker'] = '';
1264 1264
 		}
@@ -1267,15 +1267,15 @@  discard block
 block discarded – undo
1267 1267
 		 * Replace object menu arg with a term_id menu arg, as this exports better
1268 1268
 		 * to JS and is easier to compare hashes.
1269 1269
 		 */
1270
-		if ( ! empty( $exported_args['menu'] ) && is_object( $exported_args['menu'] ) ) {
1270
+		if ( ! empty($exported_args['menu']) && is_object($exported_args['menu'])) {
1271 1271
 			$exported_args['menu'] = $exported_args['menu']->term_id;
1272 1272
 		}
1273 1273
 
1274
-		ksort( $exported_args );
1275
-		$exported_args['args_hmac'] = $this->hash_nav_menu_args( $exported_args );
1274
+		ksort($exported_args);
1275
+		$exported_args['args_hmac'] = $this->hash_nav_menu_args($exported_args);
1276 1276
 
1277 1277
 		$args['customize_preview_nav_menus_args'] = $exported_args;
1278
-		$this->preview_nav_menu_instance_args[ $exported_args['args_hmac'] ] = $exported_args;
1278
+		$this->preview_nav_menu_instance_args[$exported_args['args_hmac']] = $exported_args;
1279 1279
 		return $args;
1280 1280
 	}
1281 1281
 
@@ -1293,12 +1293,12 @@  discard block
 block discarded – undo
1293 1293
 	 * @param object $args             An object containing wp_nav_menu() arguments.
1294 1294
 	 * @return null
1295 1295
 	 */
1296
-	public function filter_wp_nav_menu( $nav_menu_content, $args ) {
1297
-		if ( isset( $args->customize_preview_nav_menus_args['can_partial_refresh'] ) && $args->customize_preview_nav_menus_args['can_partial_refresh'] ) {
1298
-			$attributes = sprintf( ' data-customize-partial-id="%s"', esc_attr( 'nav_menu_instance[' . $args->customize_preview_nav_menus_args['args_hmac'] . ']' ) );
1296
+	public function filter_wp_nav_menu($nav_menu_content, $args) {
1297
+		if (isset($args->customize_preview_nav_menus_args['can_partial_refresh']) && $args->customize_preview_nav_menus_args['can_partial_refresh']) {
1298
+			$attributes = sprintf(' data-customize-partial-id="%s"', esc_attr('nav_menu_instance['.$args->customize_preview_nav_menus_args['args_hmac'].']'));
1299 1299
 			$attributes .= ' data-customize-partial-type="nav_menu_instance"';
1300
-			$attributes .= sprintf( ' data-customize-partial-placement-context="%s"', esc_attr( wp_json_encode( $args->customize_preview_nav_menus_args ) ) );
1301
-			$nav_menu_content = preg_replace( '#^(<\w+)#', '$1 ' . $attributes, $nav_menu_content, 1 );
1300
+			$attributes .= sprintf(' data-customize-partial-placement-context="%s"', esc_attr(wp_json_encode($args->customize_preview_nav_menus_args)));
1301
+			$nav_menu_content = preg_replace('#^(<\w+)#', '$1 '.$attributes, $nav_menu_content, 1);
1302 1302
 		}
1303 1303
 		return $nav_menu_content;
1304 1304
 	}
@@ -1315,8 +1315,8 @@  discard block
 block discarded – undo
1315 1315
 	 * @param array $args The arguments to hash.
1316 1316
 	 * @return string Hashed nav menu arguments.
1317 1317
 	 */
1318
-	public function hash_nav_menu_args( $args ) {
1319
-		return wp_hash( serialize( $args ) );
1318
+	public function hash_nav_menu_args($args) {
1319
+		return wp_hash(serialize($args));
1320 1320
 	}
1321 1321
 
1322 1322
 	/**
@@ -1326,8 +1326,8 @@  discard block
 block discarded – undo
1326 1326
 	 * @access public
1327 1327
 	 */
1328 1328
 	public function customize_preview_enqueue_deps() {
1329
-		wp_enqueue_script( 'customize-preview-nav-menus' ); // Note that we have overridden this.
1330
-		wp_enqueue_style( 'customize-preview' );
1329
+		wp_enqueue_script('customize-preview-nav-menus'); // Note that we have overridden this.
1330
+		wp_enqueue_style('customize-preview');
1331 1331
 	}
1332 1332
 
1333 1333
 	/**
@@ -1342,7 +1342,7 @@  discard block
 block discarded – undo
1342 1342
 		$exports = array(
1343 1343
 			'navMenuInstanceArgs' => $this->preview_nav_menu_instance_args,
1344 1344
 		);
1345
-		printf( '<script>var _wpCustomizePreviewNavMenusExports = %s;</script>', wp_json_encode( $exports ) );
1345
+		printf('<script>var _wpCustomizePreviewNavMenusExports = %s;</script>', wp_json_encode($exports));
1346 1346
 	}
1347 1347
 
1348 1348
 	/**
@@ -1354,7 +1354,7 @@  discard block
 block discarded – undo
1354 1354
 	 * @param array $response Response.
1355 1355
 	 * @return array Response.
1356 1356
 	 */
1357
-	public function export_partial_rendered_nav_menu_instances( $response ) {
1357
+	public function export_partial_rendered_nav_menu_instances($response) {
1358 1358
 		$response['nav_menu_instance_args'] = $this->preview_nav_menu_instance_args;
1359 1359
 		return $response;
1360 1360
 	}
@@ -1371,25 +1371,25 @@  discard block
 block discarded – undo
1371 1371
 	 * @param array                $nav_menu_args Nav menu args supplied as container context.
1372 1372
 	 * @return string|false
1373 1373
 	 */
1374
-	public function render_nav_menu_partial( $partial, $nav_menu_args ) {
1375
-		unset( $partial );
1374
+	public function render_nav_menu_partial($partial, $nav_menu_args) {
1375
+		unset($partial);
1376 1376
 
1377
-		if ( ! isset( $nav_menu_args['args_hmac'] ) ) {
1377
+		if ( ! isset($nav_menu_args['args_hmac'])) {
1378 1378
 			// Error: missing_args_hmac.
1379 1379
 			return false;
1380 1380
 		}
1381 1381
 
1382 1382
 		$nav_menu_args_hmac = $nav_menu_args['args_hmac'];
1383
-		unset( $nav_menu_args['args_hmac'] );
1383
+		unset($nav_menu_args['args_hmac']);
1384 1384
 
1385
-		ksort( $nav_menu_args );
1386
-		if ( ! hash_equals( $this->hash_nav_menu_args( $nav_menu_args ), $nav_menu_args_hmac ) ) {
1385
+		ksort($nav_menu_args);
1386
+		if ( ! hash_equals($this->hash_nav_menu_args($nav_menu_args), $nav_menu_args_hmac)) {
1387 1387
 			// Error: args_hmac_mismatch.
1388 1388
 			return false;
1389 1389
 		}
1390 1390
 
1391 1391
 		ob_start();
1392
-		wp_nav_menu( $nav_menu_args );
1392
+		wp_nav_menu($nav_menu_args);
1393 1393
 		$content = ob_get_clean();
1394 1394
 
1395 1395
 		return $content;
Please login to merge, or discard this patch.