Completed
Push — master ( fdb3a7...cde0c6 )
by Stephen
20:18
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.
Spacing   +272 added lines, -272 removed lines patch added patch discarded remove patch
@@ -15,33 +15,33 @@  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 ) {
32
-		$file['error'] = sprintf( __( 'Not enough space to upload. %1$s KB needed.' ), number_format( ( $file_size - $space_left ) / KB_IN_BYTES ) );
30
+	$file_size = filesize($file['tmp_name']);
31
+	if ($space_left < $file_size) {
32
+		$file['error'] = sprintf(__('Not enough space to upload. %1$s KB needed.'), number_format(($file_size - $space_left) / KB_IN_BYTES));
33 33
 	}
34 34
 
35
-	if ( $file_size > ( KB_IN_BYTES * get_site_option( 'fileupload_maxk', 1500 ) ) ) {
36
-		$file['error'] = sprintf( __( 'This file is too big. Files must be less than %1$s KB in size.' ), get_site_option( 'fileupload_maxk', 1500 ) );
35
+	if ($file_size > (KB_IN_BYTES * get_site_option('fileupload_maxk', 1500))) {
36
+		$file['error'] = sprintf(__('This file is too big. Files must be less than %1$s KB in size.'), get_site_option('fileupload_maxk', 1500));
37 37
 	}
38 38
 
39
-	if ( upload_is_user_over_quota( false ) ) {
40
-		$file['error'] = __( 'You have used your space quota. Please delete files before uploading.' );
39
+	if (upload_is_user_over_quota(false)) {
40
+		$file['error'] = __('You have used your space quota. Please delete files before uploading.');
41 41
 	}
42 42
 
43
-	if ( $file['error'] != '0' && ! isset( $_POST['html-upload'] ) && ( ! defined( 'DOING_AJAX' ) || ! DOING_AJAX ) ) {
44
-		wp_die( $file['error'] . ' <a href="javascript:history.go(-1)">' . __( 'Back' ) . '</a>' );
43
+	if ($file['error'] != '0' && ! isset($_POST['html-upload']) && ( ! defined('DOING_AJAX') || ! DOING_AJAX)) {
44
+		wp_die($file['error'].' <a href="javascript:history.go(-1)">'.__('Back').'</a>');
45 45
 	}
46 46
 
47 47
 	return $file;
@@ -57,16 +57,16 @@  discard block
 block discarded – undo
57 57
  * @param int  $blog_id Site ID.
58 58
  * @param bool $drop    True if site's database tables should be dropped. Default is false.
59 59
  */
60
-function wpmu_delete_blog( $blog_id, $drop = false ) {
60
+function wpmu_delete_blog($blog_id, $drop = false) {
61 61
 	global $wpdb;
62 62
 
63 63
 	$switch = false;
64
-	if ( get_current_blog_id() != $blog_id ) {
64
+	if (get_current_blog_id() != $blog_id) {
65 65
 		$switch = true;
66
-		switch_to_blog( $blog_id );
66
+		switch_to_blog($blog_id);
67 67
 	}
68 68
 
69
-	$blog = get_blog_details( $blog_id );
69
+	$blog = get_blog_details($blog_id);
70 70
 	/**
71 71
 	 * Fires before a site is deleted.
72 72
 	 *
@@ -75,42 +75,42 @@  discard block
 block discarded – undo
75 75
 	 * @param int  $blog_id The site ID.
76 76
 	 * @param bool $drop    True if site's table should be dropped. Default is false.
77 77
 	 */
78
-	do_action( 'delete_blog', $blog_id, $drop );
78
+	do_action('delete_blog', $blog_id, $drop);
79 79
 
80
-	$users = get_users( array( 'blog_id' => $blog_id, 'fields' => 'ids' ) );
80
+	$users = get_users(array('blog_id' => $blog_id, 'fields' => 'ids'));
81 81
 
82 82
 	// Remove users from this blog.
83
-	if ( ! empty( $users ) ) {
84
-		foreach ( $users as $user_id ) {
85
-			remove_user_from_blog( $user_id, $blog_id );
83
+	if ( ! empty($users)) {
84
+		foreach ($users as $user_id) {
85
+			remove_user_from_blog($user_id, $blog_id);
86 86
 		}
87 87
 	}
88 88
 
89
-	update_blog_status( $blog_id, 'deleted', 1 );
89
+	update_blog_status($blog_id, 'deleted', 1);
90 90
 
91 91
 	$current_site = get_current_site();
92 92
 
93 93
 	// If a full blog object is not available, do not destroy anything.
94
-	if ( $drop && ! $blog ) {
94
+	if ($drop && ! $blog) {
95 95
 		$drop = false;
96 96
 	}
97 97
 
98 98
 	// Don't destroy the initial, main, or root blog.
99
-	if ( $drop && ( 1 == $blog_id || is_main_site( $blog_id ) || ( $blog->path == $current_site->path && $blog->domain == $current_site->domain ) ) ) {
99
+	if ($drop && (1 == $blog_id || is_main_site($blog_id) || ($blog->path == $current_site->path && $blog->domain == $current_site->domain))) {
100 100
 		$drop = false;
101 101
 	}
102 102
 
103
-	$upload_path = trim( get_option( 'upload_path' ) );
103
+	$upload_path = trim(get_option('upload_path'));
104 104
 
105 105
 	// If ms_files_rewriting is enabled and upload_path is empty, wp_upload_dir is not reliable.
106
-	if ( $drop && get_site_option( 'ms_files_rewriting' ) && empty( $upload_path ) ) {
106
+	if ($drop && get_site_option('ms_files_rewriting') && empty($upload_path)) {
107 107
 		$drop = false;
108 108
 	}
109 109
 
110
-	if ( $drop ) {
110
+	if ($drop) {
111 111
 		$uploads = wp_get_upload_dir();
112 112
 
113
-		$tables = $wpdb->tables( 'blog' );
113
+		$tables = $wpdb->tables('blog');
114 114
 		/**
115 115
 		 * Filters the tables to drop when the site is deleted.
116 116
 		 *
@@ -119,13 +119,13 @@  discard block
 block discarded – undo
119 119
 		 * @param array $tables  The site tables to be dropped.
120 120
 		 * @param int   $blog_id The ID of the site to drop tables for.
121 121
 		 */
122
-		$drop_tables = apply_filters( 'wpmu_drop_tables', $tables, $blog_id );
122
+		$drop_tables = apply_filters('wpmu_drop_tables', $tables, $blog_id);
123 123
 
124
-		foreach ( (array) $drop_tables as $table ) {
125
-			$wpdb->query( "DROP TABLE IF EXISTS `$table`" );
124
+		foreach ((array) $drop_tables as $table) {
125
+			$wpdb->query("DROP TABLE IF EXISTS `$table`");
126 126
 		}
127 127
 
128
-		$wpdb->delete( $wpdb->blogs, array( 'blog_id' => $blog_id ) );
128
+		$wpdb->delete($wpdb->blogs, array('blog_id' => $blog_id));
129 129
 
130 130
 		/**
131 131
 		 * Filters the upload base directory to delete when the site is deleted.
@@ -135,43 +135,43 @@  discard block
 block discarded – undo
135 135
 		 * @param string $uploads['basedir'] Uploads path without subdirectory. @see wp_upload_dir()
136 136
 		 * @param int    $blog_id            The site ID.
137 137
 		 */
138
-		$dir = apply_filters( 'wpmu_delete_blog_upload_dir', $uploads['basedir'], $blog_id );
139
-		$dir = rtrim( $dir, DIRECTORY_SEPARATOR );
138
+		$dir = apply_filters('wpmu_delete_blog_upload_dir', $uploads['basedir'], $blog_id);
139
+		$dir = rtrim($dir, DIRECTORY_SEPARATOR);
140 140
 		$top_dir = $dir;
141 141
 		$stack = array($dir);
142 142
 		$index = 0;
143 143
 
144
-		while ( $index < count( $stack ) ) {
144
+		while ($index < count($stack)) {
145 145
 			// Get indexed directory from stack
146 146
 			$dir = $stack[$index];
147 147
 
148
-			$dh = @opendir( $dir );
149
-			if ( $dh ) {
150
-				while ( ( $file = @readdir( $dh ) ) !== false ) {
151
-					if ( $file == '.' || $file == '..' )
148
+			$dh = @opendir($dir);
149
+			if ($dh) {
150
+				while (($file = @readdir($dh)) !== false) {
151
+					if ($file == '.' || $file == '..')
152 152
 						continue;
153 153
 
154
-					if ( @is_dir( $dir . DIRECTORY_SEPARATOR . $file ) ) {
155
-						$stack[] = $dir . DIRECTORY_SEPARATOR . $file;
156
-					} elseif ( @is_file( $dir . DIRECTORY_SEPARATOR . $file ) ) {
157
-						@unlink( $dir . DIRECTORY_SEPARATOR . $file );
154
+					if (@is_dir($dir.DIRECTORY_SEPARATOR.$file)) {
155
+						$stack[] = $dir.DIRECTORY_SEPARATOR.$file;
156
+					} elseif (@is_file($dir.DIRECTORY_SEPARATOR.$file)) {
157
+						@unlink($dir.DIRECTORY_SEPARATOR.$file);
158 158
 					}
159 159
 				}
160
-				@closedir( $dh );
160
+				@closedir($dh);
161 161
 			}
162 162
 			$index++;
163 163
 		}
164 164
 
165
-		$stack = array_reverse( $stack ); // Last added dirs are deepest
166
-		foreach ( (array) $stack as $dir ) {
167
-			if ( $dir != $top_dir)
168
-			@rmdir( $dir );
165
+		$stack = array_reverse($stack); // Last added dirs are deepest
166
+		foreach ((array) $stack as $dir) {
167
+			if ($dir != $top_dir)
168
+			@rmdir($dir);
169 169
 		}
170 170
 
171
-		clean_blog_cache( $blog );
171
+		clean_blog_cache($blog);
172 172
 	}
173 173
 
174
-	if ( $switch )
174
+	if ($switch)
175 175
 		restore_current_blog();
176 176
 }
177 177
 
@@ -187,22 +187,22 @@  discard block
 block discarded – undo
187 187
  * @param int $id The user ID.
188 188
  * @return bool True if the user was deleted, otherwise false.
189 189
  */
190
-function wpmu_delete_user( $id ) {
190
+function wpmu_delete_user($id) {
191 191
 	global $wpdb;
192 192
 
193
-	if ( ! is_numeric( $id ) ) {
193
+	if ( ! is_numeric($id)) {
194 194
 		return false;
195 195
 	}
196 196
 
197 197
 	$id = (int) $id;
198
-	$user = new WP_User( $id );
198
+	$user = new WP_User($id);
199 199
 
200
-	if ( !$user->exists() )
200
+	if ( ! $user->exists())
201 201
 		return false;
202 202
 
203 203
 	// Global super-administrators are protected, and cannot be deleted.
204 204
 	$_super_admins = get_super_admins();
205
-	if ( in_array( $user->user_login, $_super_admins, true ) ) {
205
+	if (in_array($user->user_login, $_super_admins, true)) {
206 206
 		return false;
207 207
 	}
208 208
 
@@ -213,42 +213,42 @@  discard block
 block discarded – undo
213 213
 	 *
214 214
 	 * @param int $id ID of the user about to be deleted from the network.
215 215
 	 */
216
-	do_action( 'wpmu_delete_user', $id );
216
+	do_action('wpmu_delete_user', $id);
217 217
 
218
-	$blogs = get_blogs_of_user( $id );
218
+	$blogs = get_blogs_of_user($id);
219 219
 
220
-	if ( ! empty( $blogs ) ) {
221
-		foreach ( $blogs as $blog ) {
222
-			switch_to_blog( $blog->userblog_id );
223
-			remove_user_from_blog( $id, $blog->userblog_id );
220
+	if ( ! empty($blogs)) {
221
+		foreach ($blogs as $blog) {
222
+			switch_to_blog($blog->userblog_id);
223
+			remove_user_from_blog($id, $blog->userblog_id);
224 224
 
225
-			$post_ids = $wpdb->get_col( $wpdb->prepare( "SELECT ID FROM $wpdb->posts WHERE post_author = %d", $id ) );
226
-			foreach ( (array) $post_ids as $post_id ) {
227
-				wp_delete_post( $post_id );
225
+			$post_ids = $wpdb->get_col($wpdb->prepare("SELECT ID FROM $wpdb->posts WHERE post_author = %d", $id));
226
+			foreach ((array) $post_ids as $post_id) {
227
+				wp_delete_post($post_id);
228 228
 			}
229 229
 
230 230
 			// Clean links
231
-			$link_ids = $wpdb->get_col( $wpdb->prepare( "SELECT link_id FROM $wpdb->links WHERE link_owner = %d", $id ) );
231
+			$link_ids = $wpdb->get_col($wpdb->prepare("SELECT link_id FROM $wpdb->links WHERE link_owner = %d", $id));
232 232
 
233
-			if ( $link_ids ) {
234
-				foreach ( $link_ids as $link_id )
235
-					wp_delete_link( $link_id );
233
+			if ($link_ids) {
234
+				foreach ($link_ids as $link_id)
235
+					wp_delete_link($link_id);
236 236
 			}
237 237
 
238 238
 			restore_current_blog();
239 239
 		}
240 240
 	}
241 241
 
242
-	$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 );
242
+	$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);
245 245
 
246
-	$wpdb->delete( $wpdb->users, array( 'ID' => $id ) );
246
+	$wpdb->delete($wpdb->users, array('ID' => $id));
247 247
 
248
-	clean_user_cache( $user );
248
+	clean_user_cache($user);
249 249
 
250 250
 	/** This action is documented in wp-admin/includes/user.php */
251
-	do_action( 'deleted_user', $id );
251
+	do_action('deleted_user', $id);
252 252
 
253 253
 	return true;
254 254
 }
@@ -261,19 +261,19 @@  discard block
 block discarded – undo
261 261
  * @param string $old_value The old email address. Not currently used.
262 262
  * @param string $value     The new email address.
263 263
  */
264
-function update_option_new_admin_email( $old_value, $value ) {
265
-	if ( $value == get_option( 'admin_email' ) || !is_email( $value ) )
264
+function update_option_new_admin_email($old_value, $value) {
265
+	if ($value == get_option('admin_email') || ! is_email($value))
266 266
 		return;
267 267
 
268
-	$hash = md5( $value. time() .mt_rand() );
268
+	$hash = md5($value.time().mt_rand());
269 269
 	$new_admin_email = array(
270 270
 		'hash' => $hash,
271 271
 		'newemail' => $value
272 272
 	);
273
-	update_option( 'adminhash', $new_admin_email );
273
+	update_option('adminhash', $new_admin_email);
274 274
 
275 275
 	/* translators: Do not translate USERNAME, ADMIN_URL, EMAIL, SITENAME, SITEURL: those are placeholders. */
276
-	$email_text = __( 'Howdy ###USERNAME###,
276
+	$email_text = __('Howdy ###USERNAME###,
277 277
 
278 278
 You recently requested to have the administration email address on
279 279
 your site changed.
@@ -305,16 +305,16 @@  discard block
 block discarded – undo
305 305
 	 * @param string $email_text      Text in the email.
306 306
 	 * @param string $new_admin_email New admin email that the current administration email was changed to.
307 307
 	 */
308
-	$content = apply_filters( 'new_admin_email_content', $email_text, $new_admin_email );
308
+	$content = apply_filters('new_admin_email_content', $email_text, $new_admin_email);
309 309
 
310 310
 	$current_user = wp_get_current_user();
311
-	$content = str_replace( '###USERNAME###', $current_user->user_login, $content );
312
-	$content = str_replace( '###ADMIN_URL###', esc_url( self_admin_url( 'options.php?adminhash='.$hash ) ), $content );
313
-	$content = str_replace( '###EMAIL###', $value, $content );
314
-	$content = str_replace( '###SITENAME###', get_site_option( 'site_name' ), $content );
315
-	$content = str_replace( '###SITEURL###', network_home_url(), $content );
311
+	$content = str_replace('###USERNAME###', $current_user->user_login, $content);
312
+	$content = str_replace('###ADMIN_URL###', esc_url(self_admin_url('options.php?adminhash='.$hash)), $content);
313
+	$content = str_replace('###EMAIL###', $value, $content);
314
+	$content = str_replace('###SITENAME###', get_site_option('site_name'), $content);
315
+	$content = str_replace('###SITEURL###', network_home_url(), $content);
316 316
 
317
-	wp_mail( $value, sprintf( __( '[%s] New Admin Email Address' ), wp_specialchars_decode( get_option( 'blogname' ) ) ), $content );
317
+	wp_mail($value, sprintf(__('[%s] New Admin Email Address'), wp_specialchars_decode(get_option('blogname'))), $content);
318 318
 }
319 319
 
320 320
 /**
@@ -328,33 +328,33 @@  discard block
 block discarded – undo
328 328
 function send_confirmation_on_profile_email() {
329 329
 	global $errors, $wpdb;
330 330
 	$current_user = wp_get_current_user();
331
-	if ( ! is_object($errors) )
331
+	if ( ! is_object($errors))
332 332
 		$errors = new WP_Error();
333 333
 
334
-	if ( $current_user->ID != $_POST['user_id'] )
334
+	if ($current_user->ID != $_POST['user_id'])
335 335
 		return false;
336 336
 
337
-	if ( $current_user->user_email != $_POST['email'] ) {
338
-		if ( !is_email( $_POST['email'] ) ) {
339
-			$errors->add( 'user_email', __( "<strong>ERROR</strong>: The email address isn&#8217;t correct." ), array( 'form-field' => 'email' ) );
337
+	if ($current_user->user_email != $_POST['email']) {
338
+		if ( ! is_email($_POST['email'])) {
339
+			$errors->add('user_email', __("<strong>ERROR</strong>: The email address isn&#8217;t correct."), array('form-field' => 'email'));
340 340
 			return;
341 341
 		}
342 342
 
343
-		if ( $wpdb->get_var( $wpdb->prepare( "SELECT user_email FROM {$wpdb->users} WHERE user_email=%s", $_POST['email'] ) ) ) {
344
-			$errors->add( 'user_email', __( "<strong>ERROR</strong>: The email address is already used." ), array( 'form-field' => 'email' ) );
345
-			delete_user_meta( $current_user->ID, '_new_email' );
343
+		if ($wpdb->get_var($wpdb->prepare("SELECT user_email FROM {$wpdb->users} WHERE user_email=%s", $_POST['email']))) {
344
+			$errors->add('user_email', __("<strong>ERROR</strong>: The email address is already used."), array('form-field' => 'email'));
345
+			delete_user_meta($current_user->ID, '_new_email');
346 346
 			return;
347 347
 		}
348 348
 
349
-		$hash = md5( $_POST['email'] . time() . mt_rand() );
349
+		$hash = md5($_POST['email'].time().mt_rand());
350 350
 		$new_user_email = array(
351 351
 			'hash' => $hash,
352 352
 			'newemail' => $_POST['email']
353 353
 		);
354
-		update_user_meta( $current_user->ID, '_new_email', $new_user_email );
354
+		update_user_meta($current_user->ID, '_new_email', $new_user_email);
355 355
 
356 356
 		/* translators: Do not translate USERNAME, ADMIN_URL, EMAIL, SITENAME, SITEURL: those are placeholders. */
357
-		$email_text = __( 'Howdy ###USERNAME###,
357
+		$email_text = __('Howdy ###USERNAME###,
358 358
 
359 359
 You recently requested to have the email address on your account changed.
360 360
 
@@ -385,15 +385,15 @@  discard block
 block discarded – undo
385 385
 		 * @param string $email_text     Text in the email.
386 386
 		 * @param string $new_user_email New user email that the current user has changed to.
387 387
 		 */
388
-		$content = apply_filters( 'new_user_email_content', $email_text, $new_user_email );
388
+		$content = apply_filters('new_user_email_content', $email_text, $new_user_email);
389 389
 
390
-		$content = str_replace( '###USERNAME###', $current_user->user_login, $content );
391
-		$content = str_replace( '###ADMIN_URL###', esc_url( admin_url( 'profile.php?newuseremail='.$hash ) ), $content );
392
-		$content = str_replace( '###EMAIL###', $_POST['email'], $content);
393
-		$content = str_replace( '###SITENAME###', get_site_option( 'site_name' ), $content );
394
-		$content = str_replace( '###SITEURL###', network_home_url(), $content );
390
+		$content = str_replace('###USERNAME###', $current_user->user_login, $content);
391
+		$content = str_replace('###ADMIN_URL###', esc_url(admin_url('profile.php?newuseremail='.$hash)), $content);
392
+		$content = str_replace('###EMAIL###', $_POST['email'], $content);
393
+		$content = str_replace('###SITENAME###', get_site_option('site_name'), $content);
394
+		$content = str_replace('###SITEURL###', network_home_url(), $content);
395 395
 
396
-		wp_mail( $_POST['email'], sprintf( __( '[%s] New Email Address' ), wp_specialchars_decode( get_option( 'blogname' ) ) ), $content );
396
+		wp_mail($_POST['email'], sprintf(__('[%s] New Email Address'), wp_specialchars_decode(get_option('blogname'))), $content);
397 397
 		$_POST['email'] = $current_user->user_email;
398 398
 	}
399 399
 }
@@ -408,9 +408,9 @@  discard block
 block discarded – undo
408 408
  */
409 409
 function new_user_email_admin_notice() {
410 410
 	global $pagenow;
411
-	if ( 'profile.php' === $pagenow && isset( $_GET['updated'] ) && $email = get_user_meta( get_current_user_id(), '_new_email', true ) ) {
411
+	if ('profile.php' === $pagenow && isset($_GET['updated']) && $email = get_user_meta(get_current_user_id(), '_new_email', true)) {
412 412
 		/* translators: %s: New email address */
413
-		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>';
413
+		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>';
414 414
 	}
415 415
 }
416 416
 
@@ -422,19 +422,19 @@  discard block
 block discarded – undo
422 422
  * @param bool $echo Optional. If $echo is set and the quota is exceeded, a warning message is echoed. Default is true.
423 423
  * @return bool True if user is over upload space quota, otherwise false.
424 424
  */
425
-function upload_is_user_over_quota( $echo = true ) {
426
-	if ( get_site_option( 'upload_space_check_disabled' ) )
425
+function upload_is_user_over_quota($echo = true) {
426
+	if (get_site_option('upload_space_check_disabled'))
427 427
 		return false;
428 428
 
429 429
 	$space_allowed = get_space_allowed();
430
-	if ( ! is_numeric( $space_allowed ) ) {
430
+	if ( ! is_numeric($space_allowed)) {
431 431
 		$space_allowed = 10; // Default space allowed is 10 MB
432 432
 	}
433 433
 	$space_used = get_space_used();
434 434
 
435
-	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.' );
435
+	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.');
438 438
 		return true;
439 439
 	} else {
440 440
 		return false;
@@ -450,19 +450,19 @@  discard block
 block discarded – undo
450 450
 	$space_allowed = get_space_allowed();
451 451
 	$space_used = get_space_used();
452 452
 
453
-	$percent_used = ( $space_used / $space_allowed ) * 100;
453
+	$percent_used = ($space_used / $space_allowed) * 100;
454 454
 
455
-	if ( $space_allowed > 1000 ) {
456
-		$space = number_format( $space_allowed / KB_IN_BYTES );
455
+	if ($space_allowed > 1000) {
456
+		$space = number_format($space_allowed / KB_IN_BYTES);
457 457
 		/* translators: Gigabytes */
458
-		$space .= __( 'GB' );
458
+		$space .= __('GB');
459 459
 	} else {
460
-		$space = number_format( $space_allowed );
460
+		$space = number_format($space_allowed);
461 461
 		/* translators: Megabytes */
462
-		$space .= __( 'MB' );
462
+		$space .= __('MB');
463 463
 	}
464 464
 	?>
465
-	<strong><?php printf( __( 'Used: %1$s%% of %2$s' ), number_format( $percent_used ), $space ); ?></strong>
465
+	<strong><?php printf(__('Used: %1$s%% of %2$s'), number_format($percent_used), $space); ?></strong>
466 466
 	<?php
467 467
 }
468 468
 
@@ -474,12 +474,12 @@  discard block
 block discarded – undo
474 474
  * @param int $size Current max size in bytes
475 475
  * @return int Max size in bytes
476 476
  */
477
-function fix_import_form_size( $size ) {
478
-	if ( upload_is_user_over_quota( false ) ) {
477
+function fix_import_form_size($size) {
478
+	if (upload_is_user_over_quota(false)) {
479 479
 		return 0;
480 480
 	}
481 481
 	$available = get_upload_space_available();
482
-	return min( $size, $available );
482
+	return min($size, $available);
483 483
 }
484 484
 
485 485
 /**
@@ -489,20 +489,20 @@  discard block
 block discarded – undo
489 489
  *
490 490
  * @param int $id The ID of the site to display the setting for.
491 491
  */
492
-function upload_space_setting( $id ) {
493
-	switch_to_blog( $id );
494
-	$quota = get_option( 'blog_upload_space' );
492
+function upload_space_setting($id) {
493
+	switch_to_blog($id);
494
+	$quota = get_option('blog_upload_space');
495 495
 	restore_current_blog();
496 496
 
497
-	if ( !$quota )
497
+	if ( ! $quota)
498 498
 		$quota = '';
499 499
 
500 500
 	?>
501 501
 	<tr>
502
-		<th><label for="blog-upload-space-number"><?php _e( 'Site Upload Space Quota' ); ?></label></th>
502
+		<th><label for="blog-upload-space-number"><?php _e('Site Upload Space Quota'); ?></label></th>
503 503
 		<td>
504 504
 			<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; ?>" />
505
-			<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>
505
+			<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>
506 506
 		</td>
507 507
 	</tr>
508 508
 	<?php
@@ -524,19 +524,19 @@  discard block
 block discarded – undo
524 524
  * @param null   $deprecated Deprecated as of 3.0.2 and should not be used.
525 525
  * @return int   The initially passed $value.
526 526
  */
527
-function update_user_status( $id, $pref, $value, $deprecated = null ) {
527
+function update_user_status($id, $pref, $value, $deprecated = null) {
528 528
 	global $wpdb;
529 529
 
530
-	if ( null !== $deprecated )
531
-		_deprecated_argument( __FUNCTION__, '3.0.2' );
530
+	if (null !== $deprecated)
531
+		_deprecated_argument(__FUNCTION__, '3.0.2');
532 532
 
533
-	$wpdb->update( $wpdb->users, array( sanitize_key( $pref ) => $value ), array( 'ID' => $id ) );
533
+	$wpdb->update($wpdb->users, array(sanitize_key($pref) => $value), array('ID' => $id));
534 534
 
535
-	$user = new WP_User( $id );
536
-	clean_user_cache( $user );
535
+	$user = new WP_User($id);
536
+	clean_user_cache($user);
537 537
 
538
-	if ( $pref == 'spam' ) {
539
-		if ( $value == 1 ) {
538
+	if ($pref == 'spam') {
539
+		if ($value == 1) {
540 540
 			/**
541 541
 			 * Fires after the user is marked as a SPAM user.
542 542
 			 *
@@ -544,7 +544,7 @@  discard block
 block discarded – undo
544 544
 			 *
545 545
 			 * @param int $id ID of the user marked as SPAM.
546 546
 			 */
547
-			do_action( 'make_spam_user', $id );
547
+			do_action('make_spam_user', $id);
548 548
 		} else {
549 549
 			/**
550 550
 			 * Fires after the user is marked as a HAM user. Opposite of SPAM.
@@ -553,7 +553,7 @@  discard block
 block discarded – undo
553 553
 			 *
554 554
 			 * @param int $id ID of the user marked as HAM.
555 555
 			 */
556
-			do_action( 'make_ham_user', $id );
556
+			do_action('make_ham_user', $id);
557 557
 		}
558 558
 	}
559 559
 
@@ -568,13 +568,13 @@  discard block
 block discarded – undo
568 568
  * @param int $id The user ID.
569 569
  * @return bool|int The ID of the refreshed user or false if the user does not exist.
570 570
  */
571
-function refresh_user_details( $id ) {
571
+function refresh_user_details($id) {
572 572
 	$id = (int) $id;
573 573
 
574
-	if ( !$user = get_userdata( $id ) )
574
+	if ( ! $user = get_userdata($id))
575 575
 		return false;
576 576
 
577
-	clean_user_cache( $user );
577
+	clean_user_cache($user);
578 578
 
579 579
 	return $id;
580 580
 }
@@ -588,8 +588,8 @@  discard block
 block discarded – undo
588 588
  * @return string The language corresponding to $code if it exists. If it does not exist,
589 589
  *                then the first two letters of $code is returned.
590 590
  */
591
-function format_code_lang( $code = '' ) {
592
-	$code = strtolower( substr( $code, 0, 2 ) );
591
+function format_code_lang($code = '') {
592
+	$code = strtolower(substr($code, 0, 2));
593 593
 	$lang_codes = array(
594 594
 		'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',
595 595
 		'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',
@@ -601,7 +601,7 @@  discard block
 block discarded – undo
601 601
 		'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',
602 602
 		'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',
603 603
 		'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',
604
-		've' => 'Venda', 'vi' => 'Vietnamese', 'vo' => 'Volapük', 'cy' => 'Welsh','wa' => 'Walloon','wo' => 'Wolof', 'xh' => 'Xhosa', 'yi' => 'Yiddish', 'yo' => 'Yoruba', 'za' => 'Zhuang; Chuang', 'zu' => 'Zulu' );
604
+		've' => 'Venda', 'vi' => 'Vietnamese', 'vo' => 'Volapük', 'cy' => 'Welsh', 'wa' => 'Walloon', 'wo' => 'Wolof', 'xh' => 'Xhosa', 'yi' => 'Yiddish', 'yo' => 'Yoruba', 'za' => 'Zhuang; Chuang', 'zu' => 'Zulu' );
605 605
 
606 606
 	/**
607 607
 	 * Filters the language codes.
@@ -611,8 +611,8 @@  discard block
 block discarded – undo
611 611
 	 * @param array  $lang_codes Key/value pair of language codes where key is the short version.
612 612
 	 * @param string $code       A two-letter designation of the language.
613 613
 	 */
614
-	$lang_codes = apply_filters( 'lang_codes', $lang_codes, $code );
615
-	return strtr( $code, $lang_codes );
614
+	$lang_codes = apply_filters('lang_codes', $lang_codes, $code);
615
+	return strtr($code, $lang_codes);
616 616
 }
617 617
 
618 618
 /**
@@ -627,12 +627,12 @@  discard block
 block discarded – undo
627 627
  * @return object|array Returns `$term`, after filtering the 'slug' field with sanitize_title()
628 628
  *                      if $taxonomy is 'category' or 'post_tag'.
629 629
  */
630
-function sync_category_tag_slugs( $term, $taxonomy ) {
631
-	if ( global_terms_enabled() && ( $taxonomy == 'category' || $taxonomy == 'post_tag' ) ) {
632
-		if ( is_object( $term ) ) {
633
-			$term->slug = sanitize_title( $term->name );
630
+function sync_category_tag_slugs($term, $taxonomy) {
631
+	if (global_terms_enabled() && ($taxonomy == 'category' || $taxonomy == 'post_tag')) {
632
+		if (is_object($term)) {
633
+			$term->slug = sanitize_title($term->name);
634 634
 		} else {
635
-			$term['slug'] = sanitize_title( $term['name'] );
635
+			$term['slug'] = sanitize_title($term['name']);
636 636
 		}
637 637
 	}
638 638
 	return $term;
@@ -646,36 +646,36 @@  discard block
 block discarded – undo
646 646
  * @access private
647 647
  */
648 648
 function _access_denied_splash() {
649
-	if ( ! is_user_logged_in() || is_network_admin() )
649
+	if ( ! is_user_logged_in() || is_network_admin())
650 650
 		return;
651 651
 
652
-	$blogs = get_blogs_of_user( get_current_user_id() );
652
+	$blogs = get_blogs_of_user(get_current_user_id());
653 653
 
654
-	if ( wp_list_filter( $blogs, array( 'userblog_id' => get_current_blog_id() ) ) )
654
+	if (wp_list_filter($blogs, array('userblog_id' => get_current_blog_id())))
655 655
 		return;
656 656
 
657
-	$blog_name = get_bloginfo( 'name' );
657
+	$blog_name = get_bloginfo('name');
658 658
 
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 );
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);
661 661
 
662
-	$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
-	$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>';
662
+	$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
+	$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>';
664 664
 
665
-	$output .= '<h3>' . __('Your Sites') . '</h3>';
665
+	$output .= '<h3>'.__('Your Sites').'</h3>';
666 666
 	$output .= '<table>';
667 667
 
668
-	foreach ( $blogs as $blog ) {
668
+	foreach ($blogs as $blog) {
669 669
 		$output .= '<tr>';
670 670
 		$output .= "<td>{$blog->blogname}</td>";
671
-		$output .= '<td><a href="' . esc_url( get_admin_url( $blog->userblog_id ) ) . '">' . __( 'Visit Dashboard' ) . '</a> | ' .
672
-			'<a href="' . esc_url( get_home_url( $blog->userblog_id ) ). '">' . __( 'View Site' ) . '</a></td>';
671
+		$output .= '<td><a href="'.esc_url(get_admin_url($blog->userblog_id)).'">'.__('Visit Dashboard').'</a> | '.
672
+			'<a href="'.esc_url(get_home_url($blog->userblog_id)).'">'.__('View Site').'</a></td>';
673 673
 		$output .= '</tr>';
674 674
 	}
675 675
 
676 676
 	$output .= '</table>';
677 677
 
678
-	wp_die( $output, 403 );
678
+	wp_die($output, 403);
679 679
 }
680 680
 
681 681
 /**
@@ -686,8 +686,8 @@  discard block
 block discarded – undo
686 686
  * @param string $permission A permission to be checked. Currently not used.
687 687
  * @return bool True if the user has proper permissions, false if they do not.
688 688
  */
689
-function check_import_new_users( $permission ) {
690
-	if ( !is_super_admin() )
689
+function check_import_new_users($permission) {
690
+	if ( ! is_super_admin())
691 691
 		return false;
692 692
 	return true;
693 693
 }
@@ -701,33 +701,33 @@  discard block
 block discarded – undo
701 701
  * @param array  $lang_files Optional. An array of the language files. Default empty array.
702 702
  * @param string $current    Optional. The current language code. Default empty.
703 703
  */
704
-function mu_dropdown_languages( $lang_files = array(), $current = '' ) {
704
+function mu_dropdown_languages($lang_files = array(), $current = '') {
705 705
 	$flag = false;
706 706
 	$output = array();
707 707
 
708
-	foreach ( (array) $lang_files as $val ) {
709
-		$code_lang = basename( $val, '.mo' );
708
+	foreach ((array) $lang_files as $val) {
709
+		$code_lang = basename($val, '.mo');
710 710
 
711
-		if ( $code_lang == 'en_US' ) { // American English
711
+		if ($code_lang == 'en_US') { // American English
712 712
 			$flag = true;
713
-			$ae = __( 'American English' );
714
-			$output[$ae] = '<option value="' . esc_attr( $code_lang ) . '"' . selected( $current, $code_lang, false ) . '> ' . $ae . '</option>';
715
-		} elseif ( $code_lang == 'en_GB' ) { // British English
713
+			$ae = __('American English');
714
+			$output[$ae] = '<option value="'.esc_attr($code_lang).'"'.selected($current, $code_lang, false).'> '.$ae.'</option>';
715
+		} elseif ($code_lang == 'en_GB') { // British English
716 716
 			$flag = true;
717
-			$be = __( 'British English' );
718
-			$output[$be] = '<option value="' . esc_attr( $code_lang ) . '"' . selected( $current, $code_lang, false ) . '> ' . $be . '</option>';
717
+			$be = __('British English');
718
+			$output[$be] = '<option value="'.esc_attr($code_lang).'"'.selected($current, $code_lang, false).'> '.$be.'</option>';
719 719
 		} else {
720
-			$translated = format_code_lang( $code_lang );
721
-			$output[$translated] = '<option value="' . esc_attr( $code_lang ) . '"' . selected( $current, $code_lang, false ) . '> ' . esc_html ( $translated ) . '</option>';
720
+			$translated = format_code_lang($code_lang);
721
+			$output[$translated] = '<option value="'.esc_attr($code_lang).'"'.selected($current, $code_lang, false).'> '.esc_html($translated).'</option>';
722 722
 		}
723 723
 
724 724
 	}
725 725
 
726
-	if ( $flag === false ) // WordPress english
727
-		$output[] = '<option value=""' . selected( $current, '', false ) . '>' . __( 'English' ) . "</option>";
726
+	if ($flag === false) // WordPress english
727
+		$output[] = '<option value=""'.selected($current, '', false).'>'.__('English')."</option>";
728 728
 
729 729
 	// Order by name
730
-	uksort( $output, 'strnatcasecmp' );
730
+	uksort($output, 'strnatcasecmp');
731 731
 
732 732
 	/**
733 733
 	 * Filters the languages available in the dropdown.
@@ -738,9 +738,9 @@  discard block
 block discarded – undo
738 738
 	 * @param array $lang_files Available language files.
739 739
 	 * @param string $current   The current language code.
740 740
 	 */
741
-	$output = apply_filters( 'mu_dropdown_languages', $output, $lang_files, $current );
741
+	$output = apply_filters('mu_dropdown_languages', $output, $lang_files, $current);
742 742
 
743
-	echo implode( "\n\t", $output );
743
+	echo implode("\n\t", $output);
744 744
 }
745 745
 
746 746
 /**
@@ -756,16 +756,16 @@  discard block
 block discarded – undo
756 756
 function site_admin_notice() {
757 757
 	global $wp_db_version, $pagenow;
758 758
 
759
-	if ( ! is_super_admin() ) {
759
+	if ( ! is_super_admin()) {
760 760
 		return false;
761 761
 	}
762 762
 
763
-	if ( 'upgrade.php' == $pagenow ) {
763
+	if ('upgrade.php' == $pagenow) {
764 764
 		return;
765 765
 	}
766 766
 
767
-	if ( get_site_option( 'wpmu_upgrade_site' ) != $wp_db_version ) {
768
-		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>";
767
+	if (get_site_option('wpmu_upgrade_site') != $wp_db_version) {
768
+		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>";
769 769
 	}
770 770
 }
771 771
 
@@ -781,23 +781,23 @@  discard block
 block discarded – undo
781 781
  * @param array $postarr An array of posts. Not currently used.
782 782
  * @return array The new array of post data after checking for collisions.
783 783
  */
784
-function avoid_blog_page_permalink_collision( $data, $postarr ) {
785
-	if ( is_subdomain_install() )
784
+function avoid_blog_page_permalink_collision($data, $postarr) {
785
+	if (is_subdomain_install())
786 786
 		return $data;
787
-	if ( $data['post_type'] != 'page' )
787
+	if ($data['post_type'] != 'page')
788 788
 		return $data;
789
-	if ( !isset( $data['post_name'] ) || $data['post_name'] == '' )
789
+	if ( ! isset($data['post_name']) || $data['post_name'] == '')
790 790
 		return $data;
791
-	if ( !is_main_site() )
791
+	if ( ! is_main_site())
792 792
 		return $data;
793 793
 
794 794
 	$post_name = $data['post_name'];
795 795
 	$c = 0;
796
-	while( $c < 10 && get_id_from_blogname( $post_name ) ) {
797
-		$post_name .= mt_rand( 1, 10 );
798
-		$c ++;
796
+	while ($c < 10 && get_id_from_blogname($post_name)) {
797
+		$post_name .= mt_rand(1, 10);
798
+		$c++;
799 799
 	}
800
-	if ( $post_name != $data['post_name'] ) {
800
+	if ($post_name != $data['post_name']) {
801 801
 		$data['post_name'] = $post_name;
802 802
 	}
803 803
 	return $data;
@@ -816,31 +816,31 @@  discard block
 block discarded – undo
816 816
 	<table class="form-table">
817 817
 	<tr>
818 818
 	<?php /* translators: My sites label */ ?>
819
-		<th scope="row"><label for="primary_blog"><?php _e( 'Primary Site' ); ?></label></th>
819
+		<th scope="row"><label for="primary_blog"><?php _e('Primary Site'); ?></label></th>
820 820
 		<td>
821 821
 		<?php
822
-		$all_blogs = get_blogs_of_user( get_current_user_id() );
823
-		$primary_blog = get_user_meta( get_current_user_id(), 'primary_blog', true );
824
-		if ( count( $all_blogs ) > 1 ) {
822
+		$all_blogs = get_blogs_of_user(get_current_user_id());
823
+		$primary_blog = get_user_meta(get_current_user_id(), 'primary_blog', true);
824
+		if (count($all_blogs) > 1) {
825 825
 			$found = false;
826 826
 			?>
827 827
 			<select name="primary_blog" id="primary_blog">
828
-				<?php foreach ( (array) $all_blogs as $blog ) {
829
-					if ( $primary_blog == $blog->userblog_id )
828
+				<?php foreach ((array) $all_blogs as $blog) {
829
+					if ($primary_blog == $blog->userblog_id)
830 830
 						$found = true;
831
-					?><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
831
+					?><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 832
 				} ?>
833 833
 			</select>
834 834
 			<?php
835
-			if ( !$found ) {
836
-				$blog = reset( $all_blogs );
837
-				update_user_meta( get_current_user_id(), 'primary_blog', $blog->userblog_id );
835
+			if ( ! $found) {
836
+				$blog = reset($all_blogs);
837
+				update_user_meta(get_current_user_id(), 'primary_blog', $blog->userblog_id);
838 838
 			}
839
-		} elseif ( count( $all_blogs ) == 1 ) {
840
-			$blog = reset( $all_blogs );
841
-			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.
843
-				update_user_meta( get_current_user_id(), 'primary_blog', $blog->userblog_id );
839
+		} elseif (count($all_blogs) == 1) {
840
+			$blog = reset($all_blogs);
841
+			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.
843
+				update_user_meta(get_current_user_id(), 'primary_blog', $blog->userblog_id);
844 844
 		} else {
845 845
 			echo "N/A";
846 846
 		}
@@ -864,10 +864,10 @@  discard block
 block discarded – undo
864 864
  * @param int $site_id The network/site ID to check.
865 865
  * @return bool True if network can be edited, otherwise false.
866 866
  */
867
-function can_edit_network( $site_id ) {
867
+function can_edit_network($site_id) {
868 868
 	global $wpdb;
869 869
 
870
-	if ( $site_id == $wpdb->siteid )
870
+	if ($site_id == $wpdb->siteid)
871 871
 		$result = true;
872 872
 	else
873 873
 		$result = false;
@@ -880,7 +880,7 @@  discard block
 block discarded – undo
880 880
 	 * @param bool $result  Whether the network can be edited from this page.
881 881
 	 * @param int  $site_id The network/site ID to check.
882 882
 	 */
883
-	return apply_filters( 'can_edit_network', $result, $site_id );
883
+	return apply_filters('can_edit_network', $result, $site_id);
884 884
 }
885 885
 
886 886
 /**
@@ -893,7 +893,7 @@  discard block
 block discarded – undo
893 893
 function _thickbox_path_admin_subfolder() {
894 894
 ?>
895 895
 <script type="text/javascript">
896
-var tb_pathToImage = "<?php echo includes_url( 'js/thickbox/loadingAnimation.gif', 'relative' ); ?>";
896
+var tb_pathToImage = "<?php echo includes_url('js/thickbox/loadingAnimation.gif', 'relative'); ?>";
897 897
 </script>
898 898
 <?php
899 899
 }
@@ -902,77 +902,77 @@  discard block
 block discarded – undo
902 902
  *
903 903
  * @param array $users
904 904
  */
905
-function confirm_delete_users( $users ) {
905
+function confirm_delete_users($users) {
906 906
 	$current_user = wp_get_current_user();
907
-	if ( ! is_array( $users ) || empty( $users ) ) {
907
+	if ( ! is_array($users) || empty($users)) {
908 908
 		return false;
909 909
 	}
910 910
 	?>
911
-	<h1><?php esc_html_e( 'Users' ); ?></h1>
911
+	<h1><?php esc_html_e('Users'); ?></h1>
912 912
 
913
-	<?php if ( 1 == count( $users ) ) : ?>
914
-		<p><?php _e( 'You have chosen to delete the user from all networks and sites.' ); ?></p>
913
+	<?php if (1 == count($users)) : ?>
914
+		<p><?php _e('You have chosen to delete the user from all networks and sites.'); ?></p>
915 915
 	<?php else : ?>
916
-		<p><?php _e( 'You have chosen to delete the following users from all networks and sites.' ); ?></p>
916
+		<p><?php _e('You have chosen to delete the following users from all networks and sites.'); ?></p>
917 917
 	<?php endif; ?>
918 918
 
919 919
 	<form action="users.php?action=dodelete" method="post">
920 920
 	<input type="hidden" name="dodelete" />
921 921
 	<?php
922
-	wp_nonce_field( 'ms-users-delete' );
922
+	wp_nonce_field('ms-users-delete');
923 923
 	$site_admins = get_super_admins();
924
-	$admin_out = '<option value="' . esc_attr( $current_user->ID ) . '">' . $current_user->user_login . '</option>'; ?>
924
+	$admin_out = '<option value="'.esc_attr($current_user->ID).'">'.$current_user->user_login.'</option>'; ?>
925 925
 	<table class="form-table">
926
-	<?php foreach ( ( $allusers = (array) $_POST['allusers'] ) as $user_id ) {
927
-		if ( $user_id != '' && $user_id != '0' ) {
928
-			$delete_user = get_userdata( $user_id );
926
+	<?php foreach (($allusers = (array) $_POST['allusers']) as $user_id) {
927
+		if ($user_id != '' && $user_id != '0') {
928
+			$delete_user = get_userdata($user_id);
929 929
 
930
-			if ( ! current_user_can( 'delete_user', $delete_user->ID ) ) {
931
-				wp_die( sprintf( __( 'Warning! User %s cannot be deleted.' ), $delete_user->user_login ) );
930
+			if ( ! current_user_can('delete_user', $delete_user->ID)) {
931
+				wp_die(sprintf(__('Warning! User %s cannot be deleted.'), $delete_user->user_login));
932 932
 			}
933 933
 
934
-			if ( in_array( $delete_user->user_login, $site_admins ) ) {
935
-				wp_die( sprintf( __( 'Warning! User cannot be deleted. The user %s is a network administrator.' ), '<em>' . $delete_user->user_login . '</em>' ) );
934
+			if (in_array($delete_user->user_login, $site_admins)) {
935
+				wp_die(sprintf(__('Warning! User cannot be deleted. The user %s is a network administrator.'), '<em>'.$delete_user->user_login.'</em>'));
936 936
 			}
937 937
 			?>
938 938
 			<tr>
939 939
 				<th scope="row"><?php echo $delete_user->user_login; ?>
940
-					<?php echo '<input type="hidden" name="user[]" value="' . esc_attr( $user_id ) . '" />' . "\n"; ?>
940
+					<?php echo '<input type="hidden" name="user[]" value="'.esc_attr($user_id).'" />'."\n"; ?>
941 941
 				</th>
942
-			<?php $blogs = get_blogs_of_user( $user_id, true );
942
+			<?php $blogs = get_blogs_of_user($user_id, true);
943 943
 
944
-			if ( ! empty( $blogs ) ) {
944
+			if ( ! empty($blogs)) {
945 945
 				?>
946 946
 				<td><fieldset><p><legend><?php printf(
947 947
 					/* translators: user login */
948
-					__( 'What should be done with content owned by %s?' ),
949
-					'<em>' . $delete_user->user_login . '</em>'
948
+					__('What should be done with content owned by %s?'),
949
+					'<em>'.$delete_user->user_login.'</em>'
950 950
 				); ?></legend></p>
951 951
 				<?php
952
-				foreach ( (array) $blogs as $key => $details ) {
953
-					$blog_users = get_users( array( 'blog_id' => $details->userblog_id, 'fields' => array( 'ID', 'user_login' ) ) );
954
-					if ( is_array( $blog_users ) && !empty( $blog_users ) ) {
955
-						$user_site = "<a href='" . esc_url( get_home_url( $details->userblog_id ) ) . "'>{$details->blogname}</a>";
956
-						$user_dropdown = '<label for="reassign_user" class="screen-reader-text">' . __( 'Select a user' ) . '</label>';
952
+				foreach ((array) $blogs as $key => $details) {
953
+					$blog_users = get_users(array('blog_id' => $details->userblog_id, 'fields' => array('ID', 'user_login')));
954
+					if (is_array($blog_users) && ! empty($blog_users)) {
955
+						$user_site = "<a href='".esc_url(get_home_url($details->userblog_id))."'>{$details->blogname}</a>";
956
+						$user_dropdown = '<label for="reassign_user" class="screen-reader-text">'.__('Select a user').'</label>';
957 957
 						$user_dropdown .= "<select name='blog[$user_id][$key]' id='reassign_user'>";
958 958
 						$user_list = '';
959
-						foreach ( $blog_users as $user ) {
960
-							if ( ! in_array( $user->ID, $allusers ) ) {
959
+						foreach ($blog_users as $user) {
960
+							if ( ! in_array($user->ID, $allusers)) {
961 961
 								$user_list .= "<option value='{$user->ID}'>{$user->user_login}</option>";
962 962
 							}
963 963
 						}
964
-						if ( '' == $user_list ) {
964
+						if ('' == $user_list) {
965 965
 							$user_list = $admin_out;
966 966
 						}
967 967
 						$user_dropdown .= $user_list;
968 968
 						$user_dropdown .= "</select>\n";
969 969
 						?>
970 970
 						<ul style="list-style:none;">
971
-							<li><?php printf( __( 'Site: %s' ), $user_site ); ?></li>
972
-							<li><label><input type="radio" id="delete_option0" name="delete[<?php echo $details->userblog_id . '][' . $delete_user->ID ?>]" value="delete" checked="checked" />
973
-							<?php _e( 'Delete all content.' ); ?></label></li>
974
-							<li><label><input type="radio" id="delete_option1" name="delete[<?php echo $details->userblog_id . '][' . $delete_user->ID ?>]" value="reassign" />
975
-							<?php _e( 'Attribute all content to:' ); ?></label>
971
+							<li><?php printf(__('Site: %s'), $user_site); ?></li>
972
+							<li><label><input type="radio" id="delete_option0" name="delete[<?php echo $details->userblog_id.']['.$delete_user->ID ?>]" value="delete" checked="checked" />
973
+							<?php _e('Delete all content.'); ?></label></li>
974
+							<li><label><input type="radio" id="delete_option1" name="delete[<?php echo $details->userblog_id.']['.$delete_user->ID ?>]" value="reassign" />
975
+							<?php _e('Attribute all content to:'); ?></label>
976 976
 							<?php echo $user_dropdown; ?></li>
977 977
 						</ul>
978 978
 						<?php
@@ -981,7 +981,7 @@  discard block
 block discarded – undo
981 981
 				echo "</fieldset></td></tr>";
982 982
 			} else {
983 983
 				?>
984
-				<td><fieldset><p><legend><?php _e( 'User has no sites or content and will be deleted.' ); ?></legend></p>
984
+				<td><fieldset><p><legend><?php _e('User has no sites or content and will be deleted.'); ?></legend></p>
985 985
 			<?php } ?>
986 986
 			</tr>
987 987
 		<?php
@@ -992,15 +992,15 @@  discard block
 block discarded – undo
992 992
 	</table>
993 993
 	<?php
994 994
 	/** This action is documented in wp-admin/users.php */
995
-	do_action( 'delete_user_form', $current_user, $allusers );
995
+	do_action('delete_user_form', $current_user, $allusers);
996 996
 
997
-	if ( 1 == count( $users ) ) : ?>
998
-		<p><?php _e( 'Once you hit &#8220;Confirm Deletion&#8221;, the user will be permanently removed.' ); ?></p>
997
+	if (1 == count($users)) : ?>
998
+		<p><?php _e('Once you hit &#8220;Confirm Deletion&#8221;, the user will be permanently removed.'); ?></p>
999 999
 	<?php else : ?>
1000
-		<p><?php _e( 'Once you hit &#8220;Confirm Deletion&#8221;, these users will be permanently removed.' ); ?></p>
1000
+		<p><?php _e('Once you hit &#8220;Confirm Deletion&#8221;, these users will be permanently removed.'); ?></p>
1001 1001
 	<?php endif;
1002 1002
 
1003
-	submit_button( __('Confirm Deletion'), 'primary' );
1003
+	submit_button(__('Confirm Deletion'), 'primary');
1004 1004
 	?>
1005 1005
 	</form>
1006 1006
 	<?php
@@ -1042,7 +1042,7 @@  discard block
 block discarded – undo
1042 1042
  *     @type string $selected The ID of the selected link.
1043 1043
  * }
1044 1044
  */
1045
-function network_edit_site_nav( $args = array() ) {
1045
+function network_edit_site_nav($args = array()) {
1046 1046
 
1047 1047
 	/**
1048 1048
 	 * Filters the links that appear on site-editing network pages.
@@ -1063,51 +1063,51 @@  discard block
 block discarded – undo
1063 1063
 	 *     }
1064 1064
 	 * }
1065 1065
 	 */
1066
-	$links = apply_filters( 'network_edit_site_nav_links', array(
1067
-		'site-info'     => array( 'label' => __( 'Info' ),     'url' => 'site-info.php',     'cap' => 'manage_sites' ),
1068
-		'site-users'    => array( 'label' => __( 'Users' ),    'url' => 'site-users.php',    'cap' => 'manage_sites' ),
1069
-		'site-themes'   => array( 'label' => __( 'Themes' ),   'url' => 'site-themes.php',   'cap' => 'manage_sites' ),
1070
-		'site-settings' => array( 'label' => __( 'Settings' ), 'url' => 'site-settings.php', 'cap' => 'manage_sites' )
1071
-	) );
1066
+	$links = apply_filters('network_edit_site_nav_links', array(
1067
+		'site-info'     => array('label' => __('Info'), 'url' => 'site-info.php', 'cap' => 'manage_sites'),
1068
+		'site-users'    => array('label' => __('Users'), 'url' => 'site-users.php', 'cap' => 'manage_sites'),
1069
+		'site-themes'   => array('label' => __('Themes'), 'url' => 'site-themes.php', 'cap' => 'manage_sites'),
1070
+		'site-settings' => array('label' => __('Settings'), 'url' => 'site-settings.php', 'cap' => 'manage_sites')
1071
+	));
1072 1072
 
1073 1073
 	// Parse arguments
1074
-	$r = wp_parse_args( $args, array(
1075
-		'blog_id'  => isset( $_GET['blog_id'] ) ? (int) $_GET['blog_id'] : 0,
1074
+	$r = wp_parse_args($args, array(
1075
+		'blog_id'  => isset($_GET['blog_id']) ? (int) $_GET['blog_id'] : 0,
1076 1076
 		'links'    => $links,
1077 1077
 		'selected' => 'site-info',
1078
-	) );
1078
+	));
1079 1079
 
1080 1080
 	// Setup the links array
1081 1081
 	$screen_links = array();
1082 1082
 
1083 1083
 	// Loop through tabs
1084
-	foreach ( $r['links'] as $link_id => $link ) {
1084
+	foreach ($r['links'] as $link_id => $link) {
1085 1085
 
1086 1086
 		// Skip link if user can't access
1087
-		if ( ! current_user_can( $link['cap'], $r['blog_id'] ) ) {
1087
+		if ( ! current_user_can($link['cap'], $r['blog_id'])) {
1088 1088
 			continue;
1089 1089
 		}
1090 1090
 
1091 1091
 		// Link classes
1092
-		$classes = array( 'nav-tab' );
1092
+		$classes = array('nav-tab');
1093 1093
 
1094 1094
 		// Selected is set by the parent OR assumed by the $pagenow global
1095
-		if ( $r['selected'] === $link_id || $link['url'] === $GLOBALS['pagenow'] ) {
1095
+		if ($r['selected'] === $link_id || $link['url'] === $GLOBALS['pagenow']) {
1096 1096
 			$classes[] = 'nav-tab-active';
1097 1097
 		}
1098 1098
 
1099 1099
 		// Escape each class
1100
-		$esc_classes = implode( ' ', $classes );
1100
+		$esc_classes = implode(' ', $classes);
1101 1101
 
1102 1102
 		// Get the URL for this link
1103
-		$url = add_query_arg( array( 'id' => $r['blog_id'] ), network_admin_url( $link['url'] ) );
1103
+		$url = add_query_arg(array('id' => $r['blog_id']), network_admin_url($link['url']));
1104 1104
 
1105 1105
 		// Add link to nav links
1106
-		$screen_links[ $link_id ] = '<a href="' . esc_url( $url ) . '" id="' . esc_attr( $link_id ) . '" class="' . $esc_classes . '">' . esc_html( $link['label'] ) . '</a>';
1106
+		$screen_links[$link_id] = '<a href="'.esc_url($url).'" id="'.esc_attr($link_id).'" class="'.$esc_classes.'">'.esc_html($link['label']).'</a>';
1107 1107
 	}
1108 1108
 
1109 1109
 	// All done!
1110 1110
 	echo '<h2 class="nav-tab-wrapper wp-clearfix">';
1111
-	echo implode( '', $screen_links );
1111
+	echo implode('', $screen_links);
1112 1112
 	echo '</h2>';
1113 1113
 }
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.
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.
Spacing   +285 added lines, -285 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,46 +68,46 @@  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
-			$search_results_query = new WP_Query( array(
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
+			$search_results_query = new WP_Query(array(
74 74
 				'no_found_rows'          => true,
75 75
 				'update_post_meta_cache' => false,
76 76
 				'update_post_term_cache' => false,
77 77
 				'posts_per_page'         => 10,
78 78
 				'post_type'              => $matches[2],
79 79
 				's'                      => $query,
80
-			) );
81
-			if ( ! $search_results_query->have_posts() ) {
80
+			));
81
+			if ( ! $search_results_query->have_posts()) {
82 82
 				return;
83 83
 			}
84
-			while ( $search_results_query->have_posts() ) {
84
+			while ($search_results_query->have_posts()) {
85 85
 				$post = $search_results_query->next_post();
86
-				if ( 'markup' == $response_format ) {
86
+				if ('markup' == $response_format) {
87 87
 					$var_by_ref = $post->ID;
88
-					echo walk_nav_menu_tree( array_map('wp_setup_nav_menu_item', array( get_post( $var_by_ref ) ) ), 0, (object) $args );
89
-				} elseif ( 'json' == $response_format ) {
88
+					echo walk_nav_menu_tree(array_map('wp_setup_nav_menu_item', array(get_post($var_by_ref))), 0, (object) $args);
89
+				} elseif ('json' == $response_format) {
90 90
 					echo wp_json_encode(
91 91
 						array(
92 92
 							'ID' => $post->ID,
93
-							'post_title' => get_the_title( $post->ID ),
93
+							'post_title' => get_the_title($post->ID),
94 94
 							'post_type' => $matches[2],
95 95
 						)
96 96
 					);
97 97
 					echo "\n";
98 98
 				}
99 99
 			}
100
-		} elseif ( 'taxonomy' == $matches[1] ) {
101
-			$terms = get_terms( $matches[2], array(
100
+		} elseif ('taxonomy' == $matches[1]) {
101
+			$terms = get_terms($matches[2], array(
102 102
 				'name__like' => $query,
103 103
 				'number' => 10,
104 104
 			));
105
-			if ( empty( $terms ) || is_wp_error( $terms ) )
105
+			if (empty($terms) || is_wp_error($terms))
106 106
 				return;
107
-			foreach ( (array) $terms as $term ) {
108
-				if ( 'markup' == $response_format ) {
109
-					echo walk_nav_menu_tree( array_map('wp_setup_nav_menu_item', array( $term ) ), 0, (object) $args );
110
-				} elseif ( 'json' == $response_format ) {
107
+			foreach ((array) $terms as $term) {
108
+				if ('markup' == $response_format) {
109
+					echo walk_nav_menu_tree(array_map('wp_setup_nav_menu_item', array($term)), 0, (object) $args);
110
+				} elseif ('json' == $response_format) {
111 111
 					echo wp_json_encode(
112 112
 						array(
113 113
 							'ID' => $term->term_id,
@@ -130,17 +130,17 @@  discard block
 block discarded – undo
130 130
 function wp_nav_menu_setup() {
131 131
 	// Register meta boxes
132 132
 	wp_nav_menu_post_type_meta_boxes();
133
-	add_meta_box( 'add-custom-links', __( 'Custom Links' ), 'wp_nav_menu_item_link_meta_box', 'nav-menus', 'side', 'default' );
133
+	add_meta_box('add-custom-links', __('Custom Links'), 'wp_nav_menu_item_link_meta_box', 'nav-menus', 'side', 'default');
134 134
 	wp_nav_menu_taxonomy_meta_boxes();
135 135
 
136 136
 	// Register advanced menu items (columns)
137
-	add_filter( 'manage_nav-menus_columns', 'wp_nav_menu_manage_columns' );
137
+	add_filter('manage_nav-menus_columns', 'wp_nav_menu_manage_columns');
138 138
 
139 139
 	// If first time editing, disable advanced items by default.
140
-	if ( false === get_user_option( 'managenav-menuscolumnshidden' ) ) {
140
+	if (false === get_user_option('managenav-menuscolumnshidden')) {
141 141
 		$user = wp_get_current_user();
142 142
 		update_user_option($user->ID, 'managenav-menuscolumnshidden',
143
-			array( 0 => 'link-target', 1 => 'css-classes', 2 => 'xfn', 3 => 'description', 4 => 'title-attribute', ),
143
+			array(0 => 'link-target', 1 => 'css-classes', 2 => 'xfn', 3 => 'description', 4 => 'title-attribute',),
144 144
 			true);
145 145
 	}
146 146
 }
@@ -155,17 +155,17 @@  discard block
 block discarded – undo
155 155
 function wp_initial_nav_menu_meta_boxes() {
156 156
 	global $wp_meta_boxes;
157 157
 
158
-	if ( get_user_option( 'metaboxhidden_nav-menus' ) !== false || ! is_array($wp_meta_boxes) )
158
+	if (get_user_option('metaboxhidden_nav-menus') !== false || ! is_array($wp_meta_boxes))
159 159
 		return;
160 160
 
161
-	$initial_meta_boxes = array( 'add-post-type-page', 'add-post-type-post', 'add-custom-links', 'add-category' );
161
+	$initial_meta_boxes = array('add-post-type-page', 'add-post-type-post', 'add-custom-links', 'add-category');
162 162
 	$hidden_meta_boxes = array();
163 163
 
164
-	foreach ( array_keys($wp_meta_boxes['nav-menus']) as $context ) {
165
-		foreach ( array_keys($wp_meta_boxes['nav-menus'][$context]) as $priority ) {
166
-			foreach ( $wp_meta_boxes['nav-menus'][$context][$priority] as $box ) {
167
-				if ( in_array( $box['id'], $initial_meta_boxes ) ) {
168
-					unset( $box['id'] );
164
+	foreach (array_keys($wp_meta_boxes['nav-menus']) as $context) {
165
+		foreach (array_keys($wp_meta_boxes['nav-menus'][$context]) as $priority) {
166
+			foreach ($wp_meta_boxes['nav-menus'][$context][$priority] as $box) {
167
+				if (in_array($box['id'], $initial_meta_boxes)) {
168
+					unset($box['id']);
169 169
 				} else {
170 170
 					$hidden_meta_boxes[] = $box['id'];
171 171
 				}
@@ -174,7 +174,7 @@  discard block
 block discarded – undo
174 174
 	}
175 175
 
176 176
 	$user = wp_get_current_user();
177
-	update_user_option( $user->ID, 'metaboxhidden_nav-menus', $hidden_meta_boxes, true );
177
+	update_user_option($user->ID, 'metaboxhidden_nav-menus', $hidden_meta_boxes, true);
178 178
 }
179 179
 
180 180
 /**
@@ -183,12 +183,12 @@  discard block
 block discarded – undo
183 183
  * @since 3.0.0
184 184
  */
185 185
 function wp_nav_menu_post_type_meta_boxes() {
186
-	$post_types = get_post_types( array( 'show_in_nav_menus' => true ), 'object' );
186
+	$post_types = get_post_types(array('show_in_nav_menus' => true), 'object');
187 187
 
188
-	if ( ! $post_types )
188
+	if ( ! $post_types)
189 189
 		return;
190 190
 
191
-	foreach ( $post_types as $post_type ) {
191
+	foreach ($post_types as $post_type) {
192 192
 		/**
193 193
 		 * Filters whether a menu items meta box will be added for the current
194 194
 		 * object type.
@@ -201,12 +201,12 @@  discard block
 block discarded – undo
201 201
 		 * @param object $meta_box_object The current object to add a menu items
202 202
 		 *                                meta box for.
203 203
 		 */
204
-		$post_type = apply_filters( 'nav_menu_meta_box_object', $post_type );
205
-		if ( $post_type ) {
204
+		$post_type = apply_filters('nav_menu_meta_box_object', $post_type);
205
+		if ($post_type) {
206 206
 			$id = $post_type->name;
207 207
 			// Give pages a higher priority.
208
-			$priority = ( 'page' == $post_type->name ? 'core' : 'default' );
209
-			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 );
208
+			$priority = ('page' == $post_type->name ? 'core' : 'default');
209
+			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);
210 210
 		}
211 211
 	}
212 212
 }
@@ -217,17 +217,17 @@  discard block
 block discarded – undo
217 217
  * @since 3.0.0
218 218
  */
219 219
 function wp_nav_menu_taxonomy_meta_boxes() {
220
-	$taxonomies = get_taxonomies( array( 'show_in_nav_menus' => true ), 'object' );
220
+	$taxonomies = get_taxonomies(array('show_in_nav_menus' => true), 'object');
221 221
 
222
-	if ( !$taxonomies )
222
+	if ( ! $taxonomies)
223 223
 		return;
224 224
 
225
-	foreach ( $taxonomies as $tax ) {
225
+	foreach ($taxonomies as $tax) {
226 226
 		/** This filter is documented in wp-admin/includes/nav-menu.php */
227
-		$tax = apply_filters( 'nav_menu_meta_box_object', $tax );
228
-		if ( $tax ) {
227
+		$tax = apply_filters('nav_menu_meta_box_object', $tax);
228
+		if ($tax) {
229 229
 			$id = $tax->name;
230
-			add_meta_box( "add-{$id}", $tax->labels->name, 'wp_nav_menu_item_taxonomy_meta_box', 'nav-menus', 'side', 'default', $tax );
230
+			add_meta_box("add-{$id}", $tax->labels->name, 'wp_nav_menu_item_taxonomy_meta_box', 'nav-menus', 'side', 'default', $tax);
231 231
 		}
232 232
 	}
233 233
 }
@@ -242,13 +242,13 @@  discard block
 block discarded – undo
242 242
  * @param int|string $nav_menu_selected_id (id, name or slug) of the currently-selected menu
243 243
  * @return string Disabled attribute if at least one menu exists, false if not
244 244
  */
245
-function wp_nav_menu_disabled_check( $nav_menu_selected_id ) {
245
+function wp_nav_menu_disabled_check($nav_menu_selected_id) {
246 246
 	global $one_theme_location_no_menus;
247 247
 
248
-	if ( $one_theme_location_no_menus )
248
+	if ($one_theme_location_no_menus)
249 249
 		return false;
250 250
 
251
-	return disabled( $nav_menu_selected_id, 0 );
251
+	return disabled($nav_menu_selected_id, 0);
252 252
 }
253 253
 
254 254
 /**
@@ -268,18 +268,18 @@  discard block
 block discarded – undo
268 268
 	<div class="customlinkdiv" id="customlinkdiv">
269 269
 		<input type="hidden" value="custom" name="menu-item[<?php echo $_nav_menu_placeholder; ?>][menu-item-type]" />
270 270
 		<p id="menu-item-url-wrap" class="wp-clearfix">
271
-			<label class="howto" for="custom-menu-item-url"><?php _e( 'URL' ); ?></label>
271
+			<label class="howto" for="custom-menu-item-url"><?php _e('URL'); ?></label>
272 272
 			<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://" />
273 273
 		</p>
274 274
 
275 275
 		<p id="menu-item-name-wrap" class="wp-clearfix">
276
-			<label class="howto" for="custom-menu-item-name"><?php _e( 'Link Text' ); ?></label>
276
+			<label class="howto" for="custom-menu-item-name"><?php _e('Link Text'); ?></label>
277 277
 			<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" />
278 278
 		</p>
279 279
 
280 280
 		<p class="button-controls wp-clearfix">
281 281
 			<span class="add-to-menu">
282
-				<input type="submit"<?php wp_nav_menu_disabled_check( $nav_menu_selected_id ); ?> class="button-secondary submit-add-to-menu right" value="<?php esc_attr_e('Add to Menu'); ?>" name="add-custom-menu-item" id="submit-customlinkdiv" />
282
+				<input type="submit"<?php wp_nav_menu_disabled_check($nav_menu_selected_id); ?> class="button-secondary submit-add-to-menu right" value="<?php esc_attr_e('Add to Menu'); ?>" name="add-custom-menu-item" id="submit-customlinkdiv" />
283 283
 				<span class="spinner"></span>
284 284
 			</span>
285 285
 		</p>
@@ -306,15 +306,15 @@  discard block
 block discarded – undo
306 306
  *     @type WP_Post_Type $args     Extra meta box arguments (the post type object for this meta box).
307 307
  * }
308 308
  */
309
-function wp_nav_menu_item_post_type_meta_box( $object, $box ) {
309
+function wp_nav_menu_item_post_type_meta_box($object, $box) {
310 310
 	global $_nav_menu_placeholder, $nav_menu_selected_id;
311 311
 
312 312
 	$post_type_name = $box['args']->name;
313 313
 
314 314
 	// Paginate browsing for large numbers of post objects.
315 315
 	$per_page = 50;
316
-	$pagenum = isset( $_REQUEST[$post_type_name . '-tab'] ) && isset( $_REQUEST['paged'] ) ? absint( $_REQUEST['paged'] ) : 1;
317
-	$offset = 0 < $pagenum ? $per_page * ( $pagenum - 1 ) : 0;
316
+	$pagenum = isset($_REQUEST[$post_type_name.'-tab']) && isset($_REQUEST['paged']) ? absint($_REQUEST['paged']) : 1;
317
+	$offset = 0 < $pagenum ? $per_page * ($pagenum - 1) : 0;
318 318
 
319 319
 	$args = array(
320 320
 		'offset' => $offset,
@@ -327,23 +327,23 @@  discard block
 block discarded – undo
327 327
 		'update_post_meta_cache' => false
328 328
 	);
329 329
 
330
-	if ( isset( $box['args']->_default_query ) )
331
-		$args = array_merge($args, (array) $box['args']->_default_query );
330
+	if (isset($box['args']->_default_query))
331
+		$args = array_merge($args, (array) $box['args']->_default_query);
332 332
 
333 333
 	// @todo transient caching of these results with proper invalidation on updating of a post of this type
334 334
 	$get_posts = new WP_Query;
335
-	$posts = $get_posts->query( $args );
336
-	if ( ! $get_posts->post_count ) {
337
-		echo '<p>' . __( 'No items.' ) . '</p>';
335
+	$posts = $get_posts->query($args);
336
+	if ( ! $get_posts->post_count) {
337
+		echo '<p>'.__('No items.').'</p>';
338 338
 		return;
339 339
 	}
340 340
 
341 341
 	$num_pages = $get_posts->max_num_pages;
342 342
 
343
-	$page_links = paginate_links( array(
343
+	$page_links = paginate_links(array(
344 344
 		'base' => add_query_arg(
345 345
 			array(
346
-				$post_type_name . '-tab' => 'all',
346
+				$post_type_name.'-tab' => 'all',
347 347
 				'paged' => '%#%',
348 348
 				'item-type' => 'post_type',
349 349
 				'item-object' => $post_type_name,
@@ -357,18 +357,18 @@  discard block
 block discarded – undo
357 357
 	));
358 358
 
359 359
 	$db_fields = false;
360
-	if ( is_post_type_hierarchical( $post_type_name ) ) {
361
-		$db_fields = array( 'parent' => 'post_parent', 'id' => 'ID' );
360
+	if (is_post_type_hierarchical($post_type_name)) {
361
+		$db_fields = array('parent' => 'post_parent', 'id' => 'ID');
362 362
 	}
363 363
 
364
-	$walker = new Walker_Nav_Menu_Checklist( $db_fields );
364
+	$walker = new Walker_Nav_Menu_Checklist($db_fields);
365 365
 
366 366
 	$current_tab = 'most-recent';
367
-	if ( isset( $_REQUEST[$post_type_name . '-tab'] ) && in_array( $_REQUEST[$post_type_name . '-tab'], array('all', 'search') ) ) {
368
-		$current_tab = $_REQUEST[$post_type_name . '-tab'];
367
+	if (isset($_REQUEST[$post_type_name.'-tab']) && in_array($_REQUEST[$post_type_name.'-tab'], array('all', 'search'))) {
368
+		$current_tab = $_REQUEST[$post_type_name.'-tab'];
369 369
 	}
370 370
 
371
-	if ( ! empty( $_REQUEST['quick-search-posttype-' . $post_type_name] ) ) {
371
+	if ( ! empty($_REQUEST['quick-search-posttype-'.$post_type_name])) {
372 372
 		$current_tab = 'search';
373 373
 	}
374 374
 
@@ -384,30 +384,30 @@  discard block
 block discarded – undo
384 384
 	?>
385 385
 	<div id="posttype-<?php echo $post_type_name; ?>" class="posttypediv">
386 386
 		<ul id="posttype-<?php echo $post_type_name; ?>-tabs" class="posttype-tabs add-menu-item-tabs">
387
-			<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">
389
-					<?php _e( 'Most Recent' ); ?>
387
+			<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">
389
+					<?php _e('Most Recent'); ?>
390 390
 				</a>
391 391
 			</li>
392
-			<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">
394
-					<?php _e( 'View All' ); ?>
392
+			<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">
394
+					<?php _e('View All'); ?>
395 395
 				</a>
396 396
 			</li>
397
-			<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">
399
-					<?php _e( 'Search'); ?>
397
+			<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">
399
+					<?php _e('Search'); ?>
400 400
 				</a>
401 401
 			</li>
402 402
 		</ul><!-- .posttype-tabs -->
403 403
 
404 404
 		<div id="tabs-panel-posttype-<?php echo $post_type_name; ?>-most-recent" class="tabs-panel <?php
405
-			echo ( 'most-recent' == $current_tab ? 'tabs-panel-active' : 'tabs-panel-inactive' );
405
+			echo ('most-recent' == $current_tab ? 'tabs-panel-active' : 'tabs-panel-inactive');
406 406
 		?>">
407 407
 			<ul id="<?php echo $post_type_name; ?>checklist-most-recent" class="categorychecklist form-no-clear">
408 408
 				<?php
409
-				$recent_args = array_merge( $args, array( 'orderby' => 'post_date', 'order' => 'DESC', 'posts_per_page' => 15 ) );
410
-				$most_recent = $get_posts->query( $recent_args );
409
+				$recent_args = array_merge($args, array('orderby' => 'post_date', 'order' => 'DESC', 'posts_per_page' => 15));
410
+				$most_recent = $get_posts->query($recent_args);
411 411
 				$args['walker'] = $walker;
412 412
 
413 413
 				/**
@@ -422,50 +422,50 @@  discard block
 block discarded – undo
422 422
 				 * @param array $args        An array of WP_Query arguments.
423 423
 				 * @param array $box         Arguments passed to wp_nav_menu_item_post_type_meta_box().
424 424
 				 */
425
-				$most_recent = apply_filters( "nav_menu_items_{$post_type_name}_recent", $most_recent, $args, $box );
425
+				$most_recent = apply_filters("nav_menu_items_{$post_type_name}_recent", $most_recent, $args, $box);
426 426
 
427
-				echo walk_nav_menu_tree( array_map('wp_setup_nav_menu_item', $most_recent), 0, (object) $args );
427
+				echo walk_nav_menu_tree(array_map('wp_setup_nav_menu_item', $most_recent), 0, (object) $args);
428 428
 				?>
429 429
 			</ul>
430 430
 		</div><!-- /.tabs-panel -->
431 431
 
432 432
 		<div class="tabs-panel <?php
433
-			echo ( 'search' == $current_tab ? 'tabs-panel-active' : 'tabs-panel-inactive' );
433
+			echo ('search' == $current_tab ? 'tabs-panel-active' : 'tabs-panel-inactive');
434 434
 		?>" id="tabs-panel-posttype-<?php echo $post_type_name; ?>-search">
435 435
 			<?php
436
-			if ( isset( $_REQUEST['quick-search-posttype-' . $post_type_name] ) ) {
437
-				$searched = esc_attr( $_REQUEST['quick-search-posttype-' . $post_type_name] );
438
-				$search_results = get_posts( array( 's' => $searched, 'post_type' => $post_type_name, 'fields' => 'all', 'order' => 'DESC', ) );
436
+			if (isset($_REQUEST['quick-search-posttype-'.$post_type_name])) {
437
+				$searched = esc_attr($_REQUEST['quick-search-posttype-'.$post_type_name]);
438
+				$search_results = get_posts(array('s' => $searched, 'post_type' => $post_type_name, 'fields' => 'all', 'order' => 'DESC',));
439 439
 			} else {
440 440
 				$searched = '';
441 441
 				$search_results = array();
442 442
 			}
443 443
 			?>
444 444
 			<p class="quick-search-wrap">
445
-				<label for="quick-search-posttype-<?php echo $post_type_name; ?>" class="screen-reader-text"><?php _e( 'Search' ); ?></label>
445
+				<label for="quick-search-posttype-<?php echo $post_type_name; ?>" class="screen-reader-text"><?php _e('Search'); ?></label>
446 446
 				<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; ?>" />
447 447
 				<span class="spinner"></span>
448
-				<?php submit_button( __( 'Search' ), 'button-small quick-search-submit button-secondary hide-if-js', 'submit', false, array( 'id' => 'submit-quick-search-posttype-' . $post_type_name ) ); ?>
448
+				<?php submit_button(__('Search'), 'button-small quick-search-submit button-secondary hide-if-js', 'submit', false, array('id' => 'submit-quick-search-posttype-'.$post_type_name)); ?>
449 449
 			</p>
450 450
 
451 451
 			<ul id="<?php echo $post_type_name; ?>-search-checklist" data-wp-lists="list:<?php echo $post_type_name?>" class="categorychecklist form-no-clear">
452
-			<?php if ( ! empty( $search_results ) && ! is_wp_error( $search_results ) ) : ?>
452
+			<?php if ( ! empty($search_results) && ! is_wp_error($search_results)) : ?>
453 453
 				<?php
454 454
 				$args['walker'] = $walker;
455
-				echo walk_nav_menu_tree( array_map('wp_setup_nav_menu_item', $search_results), 0, (object) $args );
455
+				echo walk_nav_menu_tree(array_map('wp_setup_nav_menu_item', $search_results), 0, (object) $args);
456 456
 				?>
457
-			<?php elseif ( is_wp_error( $search_results ) ) : ?>
457
+			<?php elseif (is_wp_error($search_results)) : ?>
458 458
 				<li><?php echo $search_results->get_error_message(); ?></li>
459
-			<?php elseif ( ! empty( $searched ) ) : ?>
459
+			<?php elseif ( ! empty($searched)) : ?>
460 460
 				<li><?php _e('No results found.'); ?></li>
461 461
 			<?php endif; ?>
462 462
 			</ul>
463 463
 		</div><!-- /.tabs-panel -->
464 464
 
465 465
 		<div id="<?php echo $post_type_name; ?>-all" class="tabs-panel tabs-panel-view-all <?php
466
-			echo ( 'all' == $current_tab ? 'tabs-panel-active' : 'tabs-panel-inactive' );
466
+			echo ('all' == $current_tab ? 'tabs-panel-active' : 'tabs-panel-inactive');
467 467
 		?>">
468
-			<?php if ( ! empty( $page_links ) ) : ?>
468
+			<?php if ( ! empty($page_links)) : ?>
469 469
 				<div class="add-menu-item-pagelinks">
470 470
 					<?php echo $page_links; ?>
471 471
 				</div>
@@ -478,15 +478,15 @@  discard block
 block discarded – undo
478 478
 				 * If we're dealing with pages, let's put a checkbox for the front
479 479
 				 * page at the top of the list.
480 480
 				 */
481
-				if ( 'page' == $post_type_name ) {
482
-					$front_page = 'page' == get_option('show_on_front') ? (int) get_option( 'page_on_front' ) : 0;
483
-					if ( ! empty( $front_page ) ) {
484
-						$front_page_obj = get_post( $front_page );
481
+				if ('page' == $post_type_name) {
482
+					$front_page = 'page' == get_option('show_on_front') ? (int) get_option('page_on_front') : 0;
483
+					if ( ! empty($front_page)) {
484
+						$front_page_obj = get_post($front_page);
485 485
 						$front_page_obj->front_or_home = true;
486
-						array_unshift( $posts, $front_page_obj );
486
+						array_unshift($posts, $front_page_obj);
487 487
 					} else {
488
-						$_nav_menu_placeholder = ( 0 > $_nav_menu_placeholder ) ? intval($_nav_menu_placeholder) - 1 : -1;
489
-						array_unshift( $posts, (object) array(
488
+						$_nav_menu_placeholder = (0 > $_nav_menu_placeholder) ? intval($_nav_menu_placeholder) - 1 : -1;
489
+						array_unshift($posts, (object) array(
490 490
 							'front_or_home' => true,
491 491
 							'ID' => 0,
492 492
 							'object_id' => $_nav_menu_placeholder,
@@ -497,15 +497,15 @@  discard block
 block discarded – undo
497 497
 							'post_type' => 'nav_menu_item',
498 498
 							'type' => 'custom',
499 499
 							'url' => home_url('/'),
500
-						) );
500
+						));
501 501
 					}
502 502
 				}
503 503
 
504
-				$post_type = get_post_type_object( $post_type_name );
505
-				$archive_link = get_post_type_archive_link( $post_type_name );
506
-				if ( $post_type->has_archive ) {
507
-					$_nav_menu_placeholder = ( 0 > $_nav_menu_placeholder ) ? intval($_nav_menu_placeholder) - 1 : -1;
508
-					array_unshift( $posts, (object) array(
504
+				$post_type = get_post_type_object($post_type_name);
505
+				$archive_link = get_post_type_archive_link($post_type_name);
506
+				if ($post_type->has_archive) {
507
+					$_nav_menu_placeholder = (0 > $_nav_menu_placeholder) ? intval($_nav_menu_placeholder) - 1 : -1;
508
+					array_unshift($posts, (object) array(
509 509
 						'ID' => 0,
510 510
 						'object_id' => $_nav_menu_placeholder,
511 511
 						'object'     => $post_type_name,
@@ -514,8 +514,8 @@  discard block
 block discarded – undo
514 514
 						'post_title' => $post_type->labels->archives,
515 515
 						'post_type' => 'nav_menu_item',
516 516
 						'type' => 'post_type_archive',
517
-						'url' => get_post_type_archive_link( $post_type_name ),
518
-					) );
517
+						'url' => get_post_type_archive_link($post_type_name),
518
+					));
519 519
 				}
520 520
 
521 521
 				/**
@@ -534,11 +534,11 @@  discard block
 block discarded – undo
534 534
 				 * @param array        $args      An array of WP_Query arguments.
535 535
 				 * @param WP_Post_Type $post_type The current post type object for this menu item meta box.
536 536
 				 */
537
-				$posts = apply_filters( "nav_menu_items_{$post_type_name}", $posts, $args, $post_type );
537
+				$posts = apply_filters("nav_menu_items_{$post_type_name}", $posts, $args, $post_type);
538 538
 
539
-				$checkbox_items = walk_nav_menu_tree( array_map('wp_setup_nav_menu_item', $posts), 0, (object) $args );
539
+				$checkbox_items = walk_nav_menu_tree(array_map('wp_setup_nav_menu_item', $posts), 0, (object) $args);
540 540
 
541
-				if ( 'all' == $current_tab && ! empty( $_REQUEST['selectall'] ) ) {
541
+				if ('all' == $current_tab && ! empty($_REQUEST['selectall'])) {
542 542
 					$checkbox_items = preg_replace('/(type=(.)checkbox(\2))/', '$1 checked=$2checked$2', $checkbox_items);
543 543
 
544 544
 				}
@@ -546,7 +546,7 @@  discard block
 block discarded – undo
546 546
 				echo $checkbox_items;
547 547
 				?>
548 548
 			</ul>
549
-			<?php if ( ! empty( $page_links ) ) : ?>
549
+			<?php if ( ! empty($page_links)) : ?>
550 550
 				<div class="add-menu-item-pagelinks">
551 551
 					<?php echo $page_links; ?>
552 552
 				</div>
@@ -556,18 +556,18 @@  discard block
 block discarded – undo
556 556
 		<p class="button-controls wp-clearfix">
557 557
 			<span class="list-controls">
558 558
 				<a href="<?php
559
-					echo esc_url( add_query_arg(
559
+					echo esc_url(add_query_arg(
560 560
 						array(
561
-							$post_type_name . '-tab' => 'all',
561
+							$post_type_name.'-tab' => 'all',
562 562
 							'selectall' => 1,
563 563
 						),
564
-						remove_query_arg( $removed_args )
564
+						remove_query_arg($removed_args)
565 565
 					));
566 566
 				?>#posttype-<?php echo $post_type_name; ?>" class="select-all"><?php _e('Select All'); ?></a>
567 567
 			</span>
568 568
 
569 569
 			<span class="add-to-menu">
570
-				<input type="submit"<?php wp_nav_menu_disabled_check( $nav_menu_selected_id ); ?> class="button-secondary 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 ); ?>" />
570
+				<input type="submit"<?php wp_nav_menu_disabled_check($nav_menu_selected_id); ?> class="button-secondary 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); ?>" />
571 571
 				<span class="spinner"></span>
572 572
 			</span>
573 573
 		</p>
@@ -593,14 +593,14 @@  discard block
 block discarded – undo
593 593
  *     @type object $args     Extra meta box arguments (the taxonomy object for this meta box).
594 594
  * }
595 595
  */
596
-function wp_nav_menu_item_taxonomy_meta_box( $object, $box ) {
596
+function wp_nav_menu_item_taxonomy_meta_box($object, $box) {
597 597
 	global $nav_menu_selected_id;
598 598
 	$taxonomy_name = $box['args']->name;
599 599
 
600 600
 	// Paginate browsing for large numbers of objects.
601 601
 	$per_page = 50;
602
-	$pagenum = isset( $_REQUEST[$taxonomy_name . '-tab'] ) && isset( $_REQUEST['paged'] ) ? absint( $_REQUEST['paged'] ) : 1;
603
-	$offset = 0 < $pagenum ? $per_page * ( $pagenum - 1 ) : 0;
602
+	$pagenum = isset($_REQUEST[$taxonomy_name.'-tab']) && isset($_REQUEST['paged']) ? absint($_REQUEST['paged']) : 1;
603
+	$offset = 0 < $pagenum ? $per_page * ($pagenum - 1) : 0;
604 604
 
605 605
 	$args = array(
606 606
 		'child_of' => 0,
@@ -615,19 +615,19 @@  discard block
 block discarded – undo
615 615
 		'pad_counts' => false,
616 616
 	);
617 617
 
618
-	$terms = get_terms( $taxonomy_name, $args );
618
+	$terms = get_terms($taxonomy_name, $args);
619 619
 
620
-	if ( ! $terms || is_wp_error($terms) ) {
621
-		echo '<p>' . __( 'No items.' ) . '</p>';
620
+	if ( ! $terms || is_wp_error($terms)) {
621
+		echo '<p>'.__('No items.').'</p>';
622 622
 		return;
623 623
 	}
624 624
 
625
-	$num_pages = ceil( wp_count_terms( $taxonomy_name , array_merge( $args, array('number' => '', 'offset' => '') ) ) / $per_page );
625
+	$num_pages = ceil(wp_count_terms($taxonomy_name, array_merge($args, array('number' => '', 'offset' => ''))) / $per_page);
626 626
 
627
-	$page_links = paginate_links( array(
627
+	$page_links = paginate_links(array(
628 628
 		'base' => add_query_arg(
629 629
 			array(
630
-				$taxonomy_name . '-tab' => 'all',
630
+				$taxonomy_name.'-tab' => 'all',
631 631
 				'paged' => '%#%',
632 632
 				'item-type' => 'taxonomy',
633 633
 				'item-object' => $taxonomy_name,
@@ -641,18 +641,18 @@  discard block
 block discarded – undo
641 641
 	));
642 642
 
643 643
 	$db_fields = false;
644
-	if ( is_taxonomy_hierarchical( $taxonomy_name ) ) {
645
-		$db_fields = array( 'parent' => 'parent', 'id' => 'term_id' );
644
+	if (is_taxonomy_hierarchical($taxonomy_name)) {
645
+		$db_fields = array('parent' => 'parent', 'id' => 'term_id');
646 646
 	}
647 647
 
648
-	$walker = new Walker_Nav_Menu_Checklist( $db_fields );
648
+	$walker = new Walker_Nav_Menu_Checklist($db_fields);
649 649
 
650 650
 	$current_tab = 'most-used';
651
-	if ( isset( $_REQUEST[$taxonomy_name . '-tab'] ) && in_array( $_REQUEST[$taxonomy_name . '-tab'], array('all', 'most-used', 'search') ) ) {
652
-		$current_tab = $_REQUEST[$taxonomy_name . '-tab'];
651
+	if (isset($_REQUEST[$taxonomy_name.'-tab']) && in_array($_REQUEST[$taxonomy_name.'-tab'], array('all', 'most-used', 'search'))) {
652
+		$current_tab = $_REQUEST[$taxonomy_name.'-tab'];
653 653
 	}
654 654
 
655
-	if ( ! empty( $_REQUEST['quick-search-taxonomy-' . $taxonomy_name] ) ) {
655
+	if ( ! empty($_REQUEST['quick-search-taxonomy-'.$taxonomy_name])) {
656 656
 		$current_tab = 'search';
657 657
 	}
658 658
 
@@ -668,39 +668,39 @@  discard block
 block discarded – undo
668 668
 	?>
669 669
 	<div id="taxonomy-<?php echo $taxonomy_name; ?>" class="taxonomydiv">
670 670
 		<ul id="taxonomy-<?php echo $taxonomy_name; ?>-tabs" class="taxonomy-tabs add-menu-item-tabs">
671
-			<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">
673
-					<?php _e( 'Most Used' ); ?>
671
+			<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">
673
+					<?php _e('Most Used'); ?>
674 674
 				</a>
675 675
 			</li>
676
-			<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">
678
-					<?php _e( 'View All' ); ?>
676
+			<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">
678
+					<?php _e('View All'); ?>
679 679
 				</a>
680 680
 			</li>
681
-			<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; ?>">
683
-					<?php _e( 'Search' ); ?>
681
+			<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; ?>">
683
+					<?php _e('Search'); ?>
684 684
 				</a>
685 685
 			</li>
686 686
 		</ul><!-- .taxonomy-tabs -->
687 687
 
688 688
 		<div id="tabs-panel-<?php echo $taxonomy_name; ?>-pop" class="tabs-panel <?php
689
-			echo ( 'most-used' == $current_tab ? 'tabs-panel-active' : 'tabs-panel-inactive' );
689
+			echo ('most-used' == $current_tab ? 'tabs-panel-active' : 'tabs-panel-inactive');
690 690
 		?>">
691 691
 			<ul id="<?php echo $taxonomy_name; ?>checklist-pop" class="categorychecklist form-no-clear" >
692 692
 				<?php
693
-				$popular_terms = get_terms( $taxonomy_name, array( 'orderby' => 'count', 'order' => 'DESC', 'number' => 10, 'hierarchical' => false ) );
693
+				$popular_terms = get_terms($taxonomy_name, array('orderby' => 'count', 'order' => 'DESC', 'number' => 10, 'hierarchical' => false));
694 694
 				$args['walker'] = $walker;
695
-				echo walk_nav_menu_tree( array_map('wp_setup_nav_menu_item', $popular_terms), 0, (object) $args );
695
+				echo walk_nav_menu_tree(array_map('wp_setup_nav_menu_item', $popular_terms), 0, (object) $args);
696 696
 				?>
697 697
 			</ul>
698 698
 		</div><!-- /.tabs-panel -->
699 699
 
700 700
 		<div id="tabs-panel-<?php echo $taxonomy_name; ?>-all" class="tabs-panel tabs-panel-view-all <?php
701
-			echo ( 'all' == $current_tab ? 'tabs-panel-active' : 'tabs-panel-inactive' );
701
+			echo ('all' == $current_tab ? 'tabs-panel-active' : 'tabs-panel-inactive');
702 702
 		?>">
703
-			<?php if ( ! empty( $page_links ) ) : ?>
703
+			<?php if ( ! empty($page_links)) : ?>
704 704
 				<div class="add-menu-item-pagelinks">
705 705
 					<?php echo $page_links; ?>
706 706
 				</div>
@@ -708,10 +708,10 @@  discard block
 block discarded – undo
708 708
 			<ul id="<?php echo $taxonomy_name; ?>checklist" data-wp-lists="list:<?php echo $taxonomy_name?>" class="categorychecklist form-no-clear">
709 709
 				<?php
710 710
 				$args['walker'] = $walker;
711
-				echo walk_nav_menu_tree( array_map('wp_setup_nav_menu_item', $terms), 0, (object) $args );
711
+				echo walk_nav_menu_tree(array_map('wp_setup_nav_menu_item', $terms), 0, (object) $args);
712 712
 				?>
713 713
 			</ul>
714
-			<?php if ( ! empty( $page_links ) ) : ?>
714
+			<?php if ( ! empty($page_links)) : ?>
715 715
 				<div class="add-menu-item-pagelinks">
716 716
 					<?php echo $page_links; ?>
717 717
 				</div>
@@ -719,33 +719,33 @@  discard block
 block discarded – undo
719 719
 		</div><!-- /.tabs-panel -->
720 720
 
721 721
 		<div class="tabs-panel <?php
722
-			echo ( 'search' == $current_tab ? 'tabs-panel-active' : 'tabs-panel-inactive' );
722
+			echo ('search' == $current_tab ? 'tabs-panel-active' : 'tabs-panel-inactive');
723 723
 		?>" id="tabs-panel-search-taxonomy-<?php echo $taxonomy_name; ?>">
724 724
 			<?php
725
-			if ( isset( $_REQUEST['quick-search-taxonomy-' . $taxonomy_name] ) ) {
726
-				$searched = esc_attr( $_REQUEST['quick-search-taxonomy-' . $taxonomy_name] );
727
-				$search_results = get_terms( $taxonomy_name, array( 'name__like' => $searched, 'fields' => 'all', 'orderby' => 'count', 'order' => 'DESC', 'hierarchical' => false ) );
725
+			if (isset($_REQUEST['quick-search-taxonomy-'.$taxonomy_name])) {
726
+				$searched = esc_attr($_REQUEST['quick-search-taxonomy-'.$taxonomy_name]);
727
+				$search_results = get_terms($taxonomy_name, array('name__like' => $searched, 'fields' => 'all', 'orderby' => 'count', 'order' => 'DESC', 'hierarchical' => false));
728 728
 			} else {
729 729
 				$searched = '';
730 730
 				$search_results = array();
731 731
 			}
732 732
 			?>
733 733
 			<p class="quick-search-wrap">
734
-				<label for="quick-search-taxonomy-<?php echo $taxonomy_name; ?>" class="screen-reader-text"><?php _e( 'Search' ); ?></label>
734
+				<label for="quick-search-taxonomy-<?php echo $taxonomy_name; ?>" class="screen-reader-text"><?php _e('Search'); ?></label>
735 735
 				<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; ?>" />
736 736
 				<span class="spinner"></span>
737
-				<?php submit_button( __( 'Search' ), 'button-small quick-search-submit button-secondary hide-if-js', 'submit', false, array( 'id' => 'submit-quick-search-taxonomy-' . $taxonomy_name ) ); ?>
737
+				<?php submit_button(__('Search'), 'button-small quick-search-submit button-secondary hide-if-js', 'submit', false, array('id' => 'submit-quick-search-taxonomy-'.$taxonomy_name)); ?>
738 738
 			</p>
739 739
 
740 740
 			<ul id="<?php echo $taxonomy_name; ?>-search-checklist" data-wp-lists="list:<?php echo $taxonomy_name?>" class="categorychecklist form-no-clear">
741
-			<?php if ( ! empty( $search_results ) && ! is_wp_error( $search_results ) ) : ?>
741
+			<?php if ( ! empty($search_results) && ! is_wp_error($search_results)) : ?>
742 742
 				<?php
743 743
 				$args['walker'] = $walker;
744
-				echo walk_nav_menu_tree( array_map('wp_setup_nav_menu_item', $search_results), 0, (object) $args );
744
+				echo walk_nav_menu_tree(array_map('wp_setup_nav_menu_item', $search_results), 0, (object) $args);
745 745
 				?>
746
-			<?php elseif ( is_wp_error( $search_results ) ) : ?>
746
+			<?php elseif (is_wp_error($search_results)) : ?>
747 747
 				<li><?php echo $search_results->get_error_message(); ?></li>
748
-			<?php elseif ( ! empty( $searched ) ) : ?>
748
+			<?php elseif ( ! empty($searched)) : ?>
749 749
 				<li><?php _e('No results found.'); ?></li>
750 750
 			<?php endif; ?>
751 751
 			</ul>
@@ -756,7 +756,7 @@  discard block
 block discarded – undo
756 756
 				<a href="<?php
757 757
 					echo esc_url(add_query_arg(
758 758
 						array(
759
-							$taxonomy_name . '-tab' => 'all',
759
+							$taxonomy_name.'-tab' => 'all',
760 760
 							'selectall' => 1,
761 761
 						),
762 762
 						remove_query_arg($removed_args)
@@ -765,7 +765,7 @@  discard block
 block discarded – undo
765 765
 			</span>
766 766
 
767 767
 			<span class="add-to-menu">
768
-				<input type="submit"<?php wp_nav_menu_disabled_check( $nav_menu_selected_id ); ?> class="button-secondary 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 ); ?>" />
768
+				<input type="submit"<?php wp_nav_menu_disabled_check($nav_menu_selected_id); ?> class="button-secondary 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); ?>" />
769 769
 				<span class="spinner"></span>
770 770
 			</span>
771 771
 		</p>
@@ -783,25 +783,25 @@  discard block
 block discarded – undo
783 783
  * @param array $menu_data The unsanitized posted menu item data.
784 784
  * @return array The database IDs of the items saved
785 785
  */
786
-function wp_save_nav_menu_items( $menu_id = 0, $menu_data = array() ) {
786
+function wp_save_nav_menu_items($menu_id = 0, $menu_data = array()) {
787 787
 	$menu_id = (int) $menu_id;
788 788
 	$items_saved = array();
789 789
 
790
-	if ( 0 == $menu_id || is_nav_menu( $menu_id ) ) {
790
+	if (0 == $menu_id || is_nav_menu($menu_id)) {
791 791
 
792 792
 		// Loop through all the menu items' POST values.
793
-		foreach ( (array) $menu_data as $_possible_db_id => $_item_object_data ) {
793
+		foreach ((array) $menu_data as $_possible_db_id => $_item_object_data) {
794 794
 			if (
795 795
 				// Checkbox is not checked.
796
-				empty( $_item_object_data['menu-item-object-id'] ) &&
796
+				empty($_item_object_data['menu-item-object-id']) &&
797 797
 				(
798 798
 					// And item type either isn't set.
799
-					! isset( $_item_object_data['menu-item-type'] ) ||
799
+					! isset($_item_object_data['menu-item-type']) ||
800 800
 					// Or URL is the default.
801
-					in_array( $_item_object_data['menu-item-url'], array( 'http://', '' ) ) ||
802
-					! ( '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)
801
+					in_array($_item_object_data['menu-item-url'], array('http://', '')) ||
802
+					! ('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)
803 803
 					// Or it *is* a custom menu item that already exists.
804
-					! empty( $_item_object_data['menu-item-db-id'] )
804
+					! empty($_item_object_data['menu-item-db-id'])
805 805
 				)
806 806
 			) {
807 807
 				// Then this potential menu item is not getting added to this menu.
@@ -810,8 +810,8 @@  discard block
 block discarded – undo
810 810
 
811 811
 			// If this possible menu item doesn't actually have a menu database ID yet.
812 812
 			if (
813
-				empty( $_item_object_data['menu-item-db-id'] ) ||
814
-				( 0 > $_possible_db_id ) ||
813
+				empty($_item_object_data['menu-item-db-id']) ||
814
+				(0 > $_possible_db_id) ||
815 815
 				$_possible_db_id != $_item_object_data['menu-item-db-id']
816 816
 			) {
817 817
 				$_actual_db_id = 0;
@@ -820,22 +820,22 @@  discard block
 block discarded – undo
820 820
 			}
821 821
 
822 822
 			$args = array(
823
-				'menu-item-db-id' => ( isset( $_item_object_data['menu-item-db-id'] ) ? $_item_object_data['menu-item-db-id'] : '' ),
824
-				'menu-item-object-id' => ( isset( $_item_object_data['menu-item-object-id'] ) ? $_item_object_data['menu-item-object-id'] : '' ),
825
-				'menu-item-object' => ( isset( $_item_object_data['menu-item-object'] ) ? $_item_object_data['menu-item-object'] : '' ),
826
-				'menu-item-parent-id' => ( isset( $_item_object_data['menu-item-parent-id'] ) ? $_item_object_data['menu-item-parent-id'] : '' ),
827
-				'menu-item-position' => ( isset( $_item_object_data['menu-item-position'] ) ? $_item_object_data['menu-item-position'] : '' ),
828
-				'menu-item-type' => ( isset( $_item_object_data['menu-item-type'] ) ? $_item_object_data['menu-item-type'] : '' ),
829
-				'menu-item-title' => ( isset( $_item_object_data['menu-item-title'] ) ? $_item_object_data['menu-item-title'] : '' ),
830
-				'menu-item-url' => ( isset( $_item_object_data['menu-item-url'] ) ? $_item_object_data['menu-item-url'] : '' ),
831
-				'menu-item-description' => ( isset( $_item_object_data['menu-item-description'] ) ? $_item_object_data['menu-item-description'] : '' ),
832
-				'menu-item-attr-title' => ( isset( $_item_object_data['menu-item-attr-title'] ) ? $_item_object_data['menu-item-attr-title'] : '' ),
833
-				'menu-item-target' => ( isset( $_item_object_data['menu-item-target'] ) ? $_item_object_data['menu-item-target'] : '' ),
834
-				'menu-item-classes' => ( isset( $_item_object_data['menu-item-classes'] ) ? $_item_object_data['menu-item-classes'] : '' ),
835
-				'menu-item-xfn' => ( isset( $_item_object_data['menu-item-xfn'] ) ? $_item_object_data['menu-item-xfn'] : '' ),
823
+				'menu-item-db-id' => (isset($_item_object_data['menu-item-db-id']) ? $_item_object_data['menu-item-db-id'] : ''),
824
+				'menu-item-object-id' => (isset($_item_object_data['menu-item-object-id']) ? $_item_object_data['menu-item-object-id'] : ''),
825
+				'menu-item-object' => (isset($_item_object_data['menu-item-object']) ? $_item_object_data['menu-item-object'] : ''),
826
+				'menu-item-parent-id' => (isset($_item_object_data['menu-item-parent-id']) ? $_item_object_data['menu-item-parent-id'] : ''),
827
+				'menu-item-position' => (isset($_item_object_data['menu-item-position']) ? $_item_object_data['menu-item-position'] : ''),
828
+				'menu-item-type' => (isset($_item_object_data['menu-item-type']) ? $_item_object_data['menu-item-type'] : ''),
829
+				'menu-item-title' => (isset($_item_object_data['menu-item-title']) ? $_item_object_data['menu-item-title'] : ''),
830
+				'menu-item-url' => (isset($_item_object_data['menu-item-url']) ? $_item_object_data['menu-item-url'] : ''),
831
+				'menu-item-description' => (isset($_item_object_data['menu-item-description']) ? $_item_object_data['menu-item-description'] : ''),
832
+				'menu-item-attr-title' => (isset($_item_object_data['menu-item-attr-title']) ? $_item_object_data['menu-item-attr-title'] : ''),
833
+				'menu-item-target' => (isset($_item_object_data['menu-item-target']) ? $_item_object_data['menu-item-target'] : ''),
834
+				'menu-item-classes' => (isset($_item_object_data['menu-item-classes']) ? $_item_object_data['menu-item-classes'] : ''),
835
+				'menu-item-xfn' => (isset($_item_object_data['menu-item-xfn']) ? $_item_object_data['menu-item-xfn'] : ''),
836 836
 			);
837 837
 
838
-			$items_saved[] = wp_update_nav_menu_item( $menu_id, $_actual_db_id, $args );
838
+			$items_saved[] = wp_update_nav_menu_item($menu_id, $_actual_db_id, $args);
839 839
 
840 840
 		}
841 841
 	}
@@ -852,23 +852,23 @@  discard block
 block discarded – undo
852 852
  * @param object $object The post type or taxonomy meta-object.
853 853
  * @return object The post type of taxonomy object.
854 854
  */
855
-function _wp_nav_menu_meta_box_object( $object = null ) {
856
-	if ( isset( $object->name ) ) {
855
+function _wp_nav_menu_meta_box_object($object = null) {
856
+	if (isset($object->name)) {
857 857
 
858
-		if ( 'page' == $object->name ) {
858
+		if ('page' == $object->name) {
859 859
 			$object->_default_query = array(
860 860
 				'orderby' => 'menu_order title',
861 861
 				'post_status' => 'publish',
862 862
 			);
863 863
 
864 864
 		// Posts should show only published items.
865
-		} elseif ( 'post' == $object->name ) {
865
+		} elseif ('post' == $object->name) {
866 866
 			$object->_default_query = array(
867 867
 				'post_status' => 'publish',
868 868
 			);
869 869
 
870 870
 		// Categories should be in reverse chronological order.
871
-		} elseif ( 'category' == $object->name ) {
871
+		} elseif ('category' == $object->name) {
872 872
 			$object->_default_query = array(
873 873
 				'orderby' => 'id',
874 874
 				'order' => 'DESC',
@@ -893,19 +893,19 @@  discard block
 block discarded – undo
893 893
  * @param int $menu_id Optional. The ID of the menu to format. Default 0.
894 894
  * @return string|WP_Error $output The menu formatted to edit or error object on failure.
895 895
  */
896
-function wp_get_nav_menu_to_edit( $menu_id = 0 ) {
897
-	$menu = wp_get_nav_menu_object( $menu_id );
896
+function wp_get_nav_menu_to_edit($menu_id = 0) {
897
+	$menu = wp_get_nav_menu_object($menu_id);
898 898
 
899 899
 	// If the menu exists, get its items.
900
-	if ( is_nav_menu( $menu ) ) {
901
-		$menu_items = wp_get_nav_menu_items( $menu->term_id, array('post_status' => 'any') );
900
+	if (is_nav_menu($menu)) {
901
+		$menu_items = wp_get_nav_menu_items($menu->term_id, array('post_status' => 'any'));
902 902
 		$result = '<div id="menu-instructions" class="post-body-plain';
903
-		$result .= ( ! empty($menu_items) ) ? ' menu-instructions-inactive">' : '">';
904
-		$result .= '<p>' . __( 'Add menu items from the column on the left.' ) . '</p>';
903
+		$result .= ( ! empty($menu_items)) ? ' menu-instructions-inactive">' : '">';
904
+		$result .= '<p>'.__('Add menu items from the column on the left.').'</p>';
905 905
 		$result .= '</div>';
906 906
 
907
-		if ( empty($menu_items) )
908
-			return $result . ' <ul class="menu" id="menu-to-edit"> </ul>';
907
+		if (empty($menu_items))
908
+			return $result.' <ul class="menu" id="menu-to-edit"> </ul>';
909 909
 
910 910
 		/**
911 911
 		 * Filters the Walker class used when adding nav menu items.
@@ -915,40 +915,40 @@  discard block
 block discarded – undo
915 915
 		 * @param string $class   The walker class to use. Default 'Walker_Nav_Menu_Edit'.
916 916
 		 * @param int    $menu_id ID of the menu being rendered.
917 917
 		 */
918
-		$walker_class_name = apply_filters( 'wp_edit_nav_menu_walker', 'Walker_Nav_Menu_Edit', $menu_id );
918
+		$walker_class_name = apply_filters('wp_edit_nav_menu_walker', 'Walker_Nav_Menu_Edit', $menu_id);
919 919
 
920
-		if ( class_exists( $walker_class_name ) ) {
920
+		if (class_exists($walker_class_name)) {
921 921
 			$walker = new $walker_class_name;
922 922
 		} else {
923
-			return new WP_Error( 'menu_walker_not_exist',
923
+			return new WP_Error('menu_walker_not_exist',
924 924
 				/* translators: %s: walker class name */
925
-				sprintf( __( 'The Walker class named %s does not exist.' ),
926
-					'<strong>' . $walker_class_name . '</strong>'
925
+				sprintf(__('The Walker class named %s does not exist.'),
926
+					'<strong>'.$walker_class_name.'</strong>'
927 927
 				)
928 928
 			);
929 929
 		}
930 930
 
931 931
 		$some_pending_menu_items = $some_invalid_menu_items = false;
932
-		foreach ( (array) $menu_items as $menu_item ) {
933
-			if ( isset( $menu_item->post_status ) && 'draft' == $menu_item->post_status )
932
+		foreach ((array) $menu_items as $menu_item) {
933
+			if (isset($menu_item->post_status) && 'draft' == $menu_item->post_status)
934 934
 				$some_pending_menu_items = true;
935
-			if ( ! empty( $menu_item->_invalid ) )
935
+			if ( ! empty($menu_item->_invalid))
936 936
 				$some_invalid_menu_items = true;
937 937
 		}
938 938
 
939
-		if ( $some_pending_menu_items ) {
940
-			$result .= '<div class="notice notice-info notice-alt inline"><p>' . __( 'Click Save Menu to make pending menu items public.' ) . '</p></div>';
939
+		if ($some_pending_menu_items) {
940
+			$result .= '<div class="notice notice-info notice-alt inline"><p>'.__('Click Save Menu to make pending menu items public.').'</p></div>';
941 941
 		}
942 942
 
943
-		if ( $some_invalid_menu_items ) {
944
-			$result .= '<div class="notice notice-error notice-alt inline"><p>' . __( 'There are some invalid menu items. Please check or delete them.' ) . '</p></div>';
943
+		if ($some_invalid_menu_items) {
944
+			$result .= '<div class="notice notice-error notice-alt inline"><p>'.__('There are some invalid menu items. Please check or delete them.').'</p></div>';
945 945
 		}
946 946
 
947 947
 		$result .= '<ul class="menu" id="menu-to-edit"> ';
948
-		$result .= walk_nav_menu_tree( array_map('wp_setup_nav_menu_item', $menu_items), 0, (object) array('walker' => $walker ) );
948
+		$result .= walk_nav_menu_tree(array_map('wp_setup_nav_menu_item', $menu_items), 0, (object) array('walker' => $walker));
949 949
 		$result .= ' </ul> ';
950 950
 		return $result;
951
-	} elseif ( is_wp_error( $menu ) ) {
951
+	} elseif (is_wp_error($menu)) {
952 952
 		return $menu;
953 953
 	}
954 954
 
@@ -963,13 +963,13 @@  discard block
 block discarded – undo
963 963
  */
964 964
 function wp_nav_menu_manage_columns() {
965 965
 	return array(
966
-		'_title'          => __( 'Show advanced menu properties' ),
966
+		'_title'          => __('Show advanced menu properties'),
967 967
 		'cb'              => '<input type="checkbox" />',
968
-		'link-target'     => __( 'Link Target' ),
969
-		'title-attribute' => __( 'Title Attribute' ),
970
-		'css-classes'     => __( 'CSS Classes' ),
971
-		'xfn'             => __( 'Link Relationship (XFN)' ),
972
-		'description'     => __( 'Description' ),
968
+		'link-target'     => __('Link Target'),
969
+		'title-attribute' => __('Title Attribute'),
970
+		'css-classes'     => __('CSS Classes'),
971
+		'xfn'             => __('Link Relationship (XFN)'),
972
+		'description'     => __('Description'),
973 973
 	);
974 974
 }
975 975
 
@@ -983,13 +983,13 @@  discard block
 block discarded – undo
983 983
  */
984 984
 function _wp_delete_orphaned_draft_menu_items() {
985 985
 	global $wpdb;
986
-	$delete_timestamp = time() - ( DAY_IN_SECONDS * EMPTY_TRASH_DAYS );
986
+	$delete_timestamp = time() - (DAY_IN_SECONDS * EMPTY_TRASH_DAYS);
987 987
 
988 988
 	// Delete orphaned draft menu items.
989
-	$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 ) );
989
+	$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 990
 
991
-	foreach ( (array) $menu_items_to_delete as $menu_item_id )
992
-		wp_delete_post( $menu_item_id, true );
991
+	foreach ((array) $menu_items_to_delete as $menu_item_id)
992
+		wp_delete_post($menu_item_id, true);
993 993
 }
994 994
 
995 995
 /**
@@ -1001,12 +1001,12 @@  discard block
 block discarded – undo
1001 1001
  * @param string $nav_menu_selected_title Title of the currently-selected menu
1002 1002
  * @return array $messages The menu updated message
1003 1003
  */
1004
-function wp_nav_menu_update_menu_items ( $nav_menu_selected_id, $nav_menu_selected_title ) {
1005
-	$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' ) );
1004
+function wp_nav_menu_update_menu_items($nav_menu_selected_id, $nav_menu_selected_title) {
1005
+	$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'));
1006 1006
 	$messages = array();
1007 1007
 	$menu_items = array();
1008 1008
 	// Index menu items by db ID
1009
-	foreach ( $unsorted_menu_items as $_item )
1009
+	foreach ($unsorted_menu_items as $_item)
1010 1010
 		$menu_items[$_item->db_id] = $_item;
1011 1011
 
1012 1012
 	$post_fields = array(
@@ -1016,66 +1016,66 @@  discard block
 block discarded – undo
1016 1016
 		'menu-item-attr-title', 'menu-item-target', 'menu-item-classes', 'menu-item-xfn'
1017 1017
 	);
1018 1018
 
1019
-	wp_defer_term_counting( true );
1019
+	wp_defer_term_counting(true);
1020 1020
 	// Loop through all the menu items' POST variables
1021
-	if ( ! empty( $_POST['menu-item-db-id'] ) ) {
1022
-		foreach ( (array) $_POST['menu-item-db-id'] as $_key => $k ) {
1021
+	if ( ! empty($_POST['menu-item-db-id'])) {
1022
+		foreach ((array) $_POST['menu-item-db-id'] as $_key => $k) {
1023 1023
 
1024 1024
 			// Menu item title can't be blank
1025
-			if ( ! isset( $_POST['menu-item-title'][ $_key ] ) || '' == $_POST['menu-item-title'][ $_key ] )
1025
+			if ( ! isset($_POST['menu-item-title'][$_key]) || '' == $_POST['menu-item-title'][$_key])
1026 1026
 				continue;
1027 1027
 
1028 1028
 			$args = array();
1029
-			foreach ( $post_fields as $field )
1030
-				$args[$field] = isset( $_POST[$field][$_key] ) ? $_POST[$field][$_key] : '';
1029
+			foreach ($post_fields as $field)
1030
+				$args[$field] = isset($_POST[$field][$_key]) ? $_POST[$field][$_key] : '';
1031 1031
 
1032
-			$menu_item_db_id = wp_update_nav_menu_item( $nav_menu_selected_id, ( $_POST['menu-item-db-id'][$_key] != $_key ? 0 : $_key ), $args );
1032
+			$menu_item_db_id = wp_update_nav_menu_item($nav_menu_selected_id, ($_POST['menu-item-db-id'][$_key] != $_key ? 0 : $_key), $args);
1033 1033
 
1034
-			if ( is_wp_error( $menu_item_db_id ) ) {
1035
-				$messages[] = '<div id="message" class="error"><p>' . $menu_item_db_id->get_error_message() . '</p></div>';
1034
+			if (is_wp_error($menu_item_db_id)) {
1035
+				$messages[] = '<div id="message" class="error"><p>'.$menu_item_db_id->get_error_message().'</p></div>';
1036 1036
 			} else {
1037
-				unset( $menu_items[ $menu_item_db_id ] );
1037
+				unset($menu_items[$menu_item_db_id]);
1038 1038
 			}
1039 1039
 		}
1040 1040
 	}
1041 1041
 
1042 1042
 	// Remove menu items from the menu that weren't in $_POST
1043
-	if ( ! empty( $menu_items ) ) {
1044
-		foreach ( array_keys( $menu_items ) as $menu_item_id ) {
1045
-			if ( is_nav_menu_item( $menu_item_id ) ) {
1046
-				wp_delete_post( $menu_item_id );
1043
+	if ( ! empty($menu_items)) {
1044
+		foreach (array_keys($menu_items) as $menu_item_id) {
1045
+			if (is_nav_menu_item($menu_item_id)) {
1046
+				wp_delete_post($menu_item_id);
1047 1047
 			}
1048 1048
 		}
1049 1049
 	}
1050 1050
 
1051 1051
 	// Store 'auto-add' pages.
1052
-	$auto_add = ! empty( $_POST['auto-add-pages'] );
1053
-	$nav_menu_option = (array) get_option( 'nav_menu_options' );
1054
-	if ( ! isset( $nav_menu_option['auto_add'] ) )
1052
+	$auto_add = ! empty($_POST['auto-add-pages']);
1053
+	$nav_menu_option = (array) get_option('nav_menu_options');
1054
+	if ( ! isset($nav_menu_option['auto_add']))
1055 1055
 		$nav_menu_option['auto_add'] = array();
1056
-	if ( $auto_add ) {
1057
-		if ( ! in_array( $nav_menu_selected_id, $nav_menu_option['auto_add'] ) )
1056
+	if ($auto_add) {
1057
+		if ( ! in_array($nav_menu_selected_id, $nav_menu_option['auto_add']))
1058 1058
 			$nav_menu_option['auto_add'][] = $nav_menu_selected_id;
1059 1059
 	} else {
1060
-		if ( false !== ( $key = array_search( $nav_menu_selected_id, $nav_menu_option['auto_add'] ) ) )
1061
-			unset( $nav_menu_option['auto_add'][$key] );
1060
+		if (false !== ($key = array_search($nav_menu_selected_id, $nav_menu_option['auto_add'])))
1061
+			unset($nav_menu_option['auto_add'][$key]);
1062 1062
 	}
1063 1063
 	// Remove nonexistent/deleted menus
1064
-	$nav_menu_option['auto_add'] = array_intersect( $nav_menu_option['auto_add'], wp_get_nav_menus( array( 'fields' => 'ids' ) ) );
1065
-	update_option( 'nav_menu_options', $nav_menu_option );
1064
+	$nav_menu_option['auto_add'] = array_intersect($nav_menu_option['auto_add'], wp_get_nav_menus(array('fields' => 'ids')));
1065
+	update_option('nav_menu_options', $nav_menu_option);
1066 1066
 
1067
-	wp_defer_term_counting( false );
1067
+	wp_defer_term_counting(false);
1068 1068
 
1069 1069
 	/** This action is documented in wp-includes/nav-menu.php */
1070
-	do_action( 'wp_update_nav_menu', $nav_menu_selected_id );
1070
+	do_action('wp_update_nav_menu', $nav_menu_selected_id);
1071 1071
 
1072
-	$messages[] = '<div id="message" class="updated notice is-dismissible"><p>' .
1072
+	$messages[] = '<div id="message" class="updated notice is-dismissible"><p>'.
1073 1073
 		/* translators: %s: nav menu title */
1074
-		sprintf( __( '%s has been updated.' ),
1075
-			'<strong>' . $nav_menu_selected_title . '</strong>'
1076
-		) . '</p></div>';
1074
+		sprintf(__('%s has been updated.'),
1075
+			'<strong>'.$nav_menu_selected_title.'</strong>'
1076
+		).'</p></div>';
1077 1077
 
1078
-	unset( $menu_items, $unsorted_menu_items );
1078
+	unset($menu_items, $unsorted_menu_items);
1079 1079
 
1080 1080
 	return $messages;
1081 1081
 }
@@ -1089,36 +1089,36 @@  discard block
 block discarded – undo
1089 1089
  * @access private
1090 1090
  */
1091 1091
 function _wp_expand_nav_menu_post_data() {
1092
-	if ( ! isset( $_POST['nav-menu-data'] ) ) {
1092
+	if ( ! isset($_POST['nav-menu-data'])) {
1093 1093
 		return;
1094 1094
 	}
1095 1095
 
1096
-	$data = json_decode( stripslashes( $_POST['nav-menu-data'] ) );
1096
+	$data = json_decode(stripslashes($_POST['nav-menu-data']));
1097 1097
 
1098
-	if ( ! is_null( $data ) && $data ) {
1099
-		foreach ( $data as $post_input_data ) {
1098
+	if ( ! is_null($data) && $data) {
1099
+		foreach ($data as $post_input_data) {
1100 1100
 			// For input names that are arrays (e.g. `menu-item-db-id[3][4][5]`),
1101 1101
 			// derive the array path keys via regex and set the value in $_POST.
1102
-			preg_match( '#([^\[]*)(\[(.+)\])?#', $post_input_data->name, $matches );
1102
+			preg_match('#([^\[]*)(\[(.+)\])?#', $post_input_data->name, $matches);
1103 1103
 
1104
-			$array_bits = array( $matches[1] );
1104
+			$array_bits = array($matches[1]);
1105 1105
 
1106
-			if ( isset( $matches[3] ) ) {
1107
-				$array_bits = array_merge( $array_bits, explode( '][', $matches[3] ) );
1106
+			if (isset($matches[3])) {
1107
+				$array_bits = array_merge($array_bits, explode('][', $matches[3]));
1108 1108
 			}
1109 1109
 
1110 1110
 			$new_post_data = array();
1111 1111
 
1112 1112
 			// Build the new array value from leaf to trunk.
1113
-			for ( $i = count( $array_bits ) - 1; $i >= 0; $i -- ) {
1114
-				if ( $i == count( $array_bits ) - 1 ) {
1115
-					$new_post_data[ $array_bits[ $i ] ] = wp_slash( $post_input_data->value );
1113
+			for ($i = count($array_bits) - 1; $i >= 0; $i--) {
1114
+				if ($i == count($array_bits) - 1) {
1115
+					$new_post_data[$array_bits[$i]] = wp_slash($post_input_data->value);
1116 1116
 				} else {
1117
-					$new_post_data = array( $array_bits[ $i ] => $new_post_data );
1117
+					$new_post_data = array($array_bits[$i] => $new_post_data);
1118 1118
 				}
1119 1119
 			}
1120 1120
 
1121
-			$_POST = array_replace_recursive( $_POST, $new_post_data );
1121
+			$_POST = array_replace_recursive($_POST, $new_post_data);
1122 1122
 		}
1123 1123
 	}
1124 1124
 }
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.
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.
Spacing   +608 added lines, -608 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();
@@ -50,8 +50,8 @@  discard block
 block discarded – undo
50 50
 	update_option('admin_email', $user_email);
51 51
 	update_option('blog_public', $public);
52 52
 
53
-	if ( $language ) {
54
-		update_option( 'WPLANG', $language );
53
+	if ($language) {
54
+		update_option('WPLANG', $language);
55 55
 	}
56 56
 
57 57
 	$guessurl = wp_guess_url();
@@ -59,7 +59,7 @@  discard block
 block discarded – undo
59 59
 	update_option('siteurl', $guessurl);
60 60
 
61 61
 	// If not a public blog, don't ping.
62
-	if ( ! $public )
62
+	if ( ! $public)
63 63
 		update_option('default_pingback_flag', 0);
64 64
 
65 65
 	/*
@@ -69,13 +69,13 @@  discard block
 block discarded – undo
69 69
 	$user_id = username_exists($user_name);
70 70
 	$user_password = trim($user_password);
71 71
 	$email_password = false;
72
-	if ( !$user_id && empty($user_password) ) {
73
-		$user_password = wp_generate_password( 12, false );
72
+	if ( ! $user_id && empty($user_password)) {
73
+		$user_password = wp_generate_password(12, false);
74 74
 		$message = __('<strong><em>Note that password</em></strong> carefully! It is a <em>random</em> password that was generated just for you.');
75 75
 		$user_id = wp_create_user($user_name, $user_password, $user_email);
76 76
 		update_user_option($user_id, 'default_password_nag', true, true);
77 77
 		$email_password = true;
78
-	} elseif ( ! $user_id ) {
78
+	} elseif ( ! $user_id) {
79 79
 		// Password has been provided
80 80
 		$message = '<em>'.__('Your chosen password.').'</em>';
81 81
 		$user_id = wp_create_user($user_name, $user_password, $user_email);
@@ -92,7 +92,7 @@  discard block
 block discarded – undo
92 92
 
93 93
 	flush_rewrite_rules();
94 94
 
95
-	wp_new_blog_notification($blog_title, $guessurl, $user_id, ($email_password ? $user_password : __('The password you chose during the install.') ) );
95
+	wp_new_blog_notification($blog_title, $guessurl, $user_id, ($email_password ? $user_password : __('The password you chose during the install.')));
96 96
 
97 97
 	wp_cache_flush();
98 98
 
@@ -103,13 +103,13 @@  discard block
 block discarded – undo
103 103
 	 *
104 104
 	 * @param WP_User $user The site owner.
105 105
 	 */
106
-	do_action( 'wp_install', $user );
106
+	do_action('wp_install', $user);
107 107
 
108 108
 	return array('url' => $guessurl, 'user_id' => $user_id, 'password' => $user_password, 'password_message' => $message);
109 109
 }
110 110
 endif;
111 111
 
112
-if ( !function_exists('wp_install_defaults') ) :
112
+if ( ! function_exists('wp_install_defaults')) :
113 113
 /**
114 114
  * Creates the initial content for a newly-installed site.
115 115
  *
@@ -124,7 +124,7 @@  discard block
 block discarded – undo
124 124
  *
125 125
  * @param int $user_id User ID.
126 126
  */
127
-function wp_install_defaults( $user_id ) {
127
+function wp_install_defaults($user_id) {
128 128
 	global $wpdb, $wp_rewrite, $table_prefix;
129 129
 
130 130
 	// Default category
@@ -132,10 +132,10 @@  discard block
 block discarded – undo
132 132
 	/* translators: Default category slug */
133 133
 	$cat_slug = sanitize_title(_x('Uncategorized', 'Default category slug'));
134 134
 
135
-	if ( global_terms_enabled() ) {
136
-		$cat_id = $wpdb->get_var( $wpdb->prepare( "SELECT cat_ID FROM {$wpdb->sitecategories} WHERE category_nicename = %s", $cat_slug ) );
137
-		if ( $cat_id == null ) {
138
-			$wpdb->insert( $wpdb->sitecategories, array('cat_ID' => 0, 'cat_name' => $cat_name, 'category_nicename' => $cat_slug, 'last_updated' => current_time('mysql', true)) );
135
+	if (global_terms_enabled()) {
136
+		$cat_id = $wpdb->get_var($wpdb->prepare("SELECT cat_ID FROM {$wpdb->sitecategories} WHERE category_nicename = %s", $cat_slug));
137
+		if ($cat_id == null) {
138
+			$wpdb->insert($wpdb->sitecategories, array('cat_ID' => 0, 'cat_name' => $cat_name, 'category_nicename' => $cat_slug, 'last_updated' => current_time('mysql', true)));
139 139
 			$cat_id = $wpdb->insert_id;
140 140
 		}
141 141
 		update_option('default_category', $cat_id);
@@ -143,35 +143,35 @@  discard block
 block discarded – undo
143 143
 		$cat_id = 1;
144 144
 	}
145 145
 
146
-	$wpdb->insert( $wpdb->terms, array('term_id' => $cat_id, 'name' => $cat_name, 'slug' => $cat_slug, 'term_group' => 0) );
147
-	$wpdb->insert( $wpdb->term_taxonomy, array('term_id' => $cat_id, 'taxonomy' => 'category', 'description' => '', 'parent' => 0, 'count' => 1));
146
+	$wpdb->insert($wpdb->terms, array('term_id' => $cat_id, 'name' => $cat_name, 'slug' => $cat_slug, 'term_group' => 0));
147
+	$wpdb->insert($wpdb->term_taxonomy, array('term_id' => $cat_id, 'taxonomy' => 'category', 'description' => '', 'parent' => 0, 'count' => 1));
148 148
 	$cat_tt_id = $wpdb->insert_id;
149 149
 
150 150
 	// First post
151
-	$now = current_time( 'mysql' );
152
-	$now_gmt = current_time( 'mysql', 1 );
153
-	$first_post_guid = get_option( 'home' ) . '/?p=1';
151
+	$now = current_time('mysql');
152
+	$now_gmt = current_time('mysql', 1);
153
+	$first_post_guid = get_option('home').'/?p=1';
154 154
 
155
-	if ( is_multisite() ) {
156
-		$first_post = get_site_option( 'first_post' );
155
+	if (is_multisite()) {
156
+		$first_post = get_site_option('first_post');
157 157
 
158
-		if ( ! $first_post ) {
158
+		if ( ! $first_post) {
159 159
 			/* translators: %s: site link */
160
-			$first_post = __( 'Welcome to %s. This is your first post. Edit or delete it, then start blogging!' );
160
+			$first_post = __('Welcome to %s. This is your first post. Edit or delete it, then start blogging!');
161 161
 		}
162 162
 
163
-		$first_post = sprintf( $first_post,
164
-			sprintf( '<a href="%s">%s</a>', esc_url( network_home_url() ), get_current_site()->site_name )
163
+		$first_post = sprintf($first_post,
164
+			sprintf('<a href="%s">%s</a>', esc_url(network_home_url()), get_current_site()->site_name)
165 165
 		);
166 166
 
167 167
 		// Back-compat for pre-4.4
168
-		$first_post = str_replace( 'SITE_URL', esc_url( network_home_url() ), $first_post );
169
-		$first_post = str_replace( 'SITE_NAME', get_current_site()->site_name, $first_post );
168
+		$first_post = str_replace('SITE_URL', esc_url(network_home_url()), $first_post);
169
+		$first_post = str_replace('SITE_NAME', get_current_site()->site_name, $first_post);
170 170
 	} else {
171
-		$first_post = __( 'Welcome to WordPress. This is your first post. Edit or delete it, then start writing!' );
171
+		$first_post = __('Welcome to WordPress. This is your first post. Edit or delete it, then start writing!');
172 172
 	}
173 173
 
174
-	$wpdb->insert( $wpdb->posts, array(
174
+	$wpdb->insert($wpdb->posts, array(
175 175
 		'post_author' => $user_id,
176 176
 		'post_date' => $now,
177 177
 		'post_date_gmt' => $now_gmt,
@@ -179,7 +179,7 @@  discard block
 block discarded – undo
179 179
 		'post_excerpt' => '',
180 180
 		'post_title' => __('Hello world!'),
181 181
 		/* translators: Default post slug */
182
-		'post_name' => sanitize_title( _x('hello-world', 'Default post slug') ),
182
+		'post_name' => sanitize_title(_x('hello-world', 'Default post slug')),
183 183
 		'post_modified' => $now,
184 184
 		'post_modified_gmt' => $now_gmt,
185 185
 		'guid' => $first_post_guid,
@@ -188,22 +188,22 @@  discard block
 block discarded – undo
188 188
 		'pinged' => '',
189 189
 		'post_content_filtered' => ''
190 190
 	));
191
-	$wpdb->insert( $wpdb->term_relationships, array('term_taxonomy_id' => $cat_tt_id, 'object_id' => 1) );
191
+	$wpdb->insert($wpdb->term_relationships, array('term_taxonomy_id' => $cat_tt_id, 'object_id' => 1));
192 192
 
193 193
 	// Default comment
194
-	$first_comment_author = __( 'A WordPress Commenter' );
194
+	$first_comment_author = __('A WordPress Commenter');
195 195
 	$first_comment_email = '[email protected]';
196 196
 	$first_comment_url = 'https://wordpress.org/';
197
-	$first_comment = __( 'Hi, this is a comment.
197
+	$first_comment = __('Hi, this is a comment.
198 198
 To get started with moderating, editing, and deleting comments, please visit the Comments screen in the dashboard.
199 199
 Commenter avatars come from <a href="https://gravatar.com">Gravatar</a>.' );
200
-	if ( is_multisite() ) {
201
-		$first_comment_author = get_site_option( 'first_comment_author', $first_comment_author );
202
-		$first_comment_email = get_site_option( 'first_comment_email', $first_comment_email );
203
-		$first_comment_url = get_site_option( 'first_comment_url', network_home_url() );
204
-		$first_comment = get_site_option( 'first_comment', $first_comment );
200
+	if (is_multisite()) {
201
+		$first_comment_author = get_site_option('first_comment_author', $first_comment_author);
202
+		$first_comment_email = get_site_option('first_comment_email', $first_comment_email);
203
+		$first_comment_url = get_site_option('first_comment_url', network_home_url());
204
+		$first_comment = get_site_option('first_comment', $first_comment);
205 205
 	}
206
-	$wpdb->insert( $wpdb->comments, array(
206
+	$wpdb->insert($wpdb->comments, array(
207 207
 		'comment_post_ID' => 1,
208 208
 		'comment_author' => $first_comment_author,
209 209
 		'comment_author_email' => $first_comment_email,
@@ -214,7 +214,7 @@  discard block
 block discarded – undo
214 214
 	));
215 215
 
216 216
 	// First Page
217
-	$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:
217
+	$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:
218 218
 
219 219
 <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>
220 220
 
@@ -222,20 +222,20 @@  discard block
 block discarded – undo
222 222
 
223 223
 <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 224
 
225
-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 );
228
-	$first_post_guid = get_option('home') . '/?page_id=2';
229
-	$wpdb->insert( $wpdb->posts, array(
225
+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);
228
+	$first_post_guid = get_option('home').'/?page_id=2';
229
+	$wpdb->insert($wpdb->posts, array(
230 230
 		'post_author' => $user_id,
231 231
 		'post_date' => $now,
232 232
 		'post_date_gmt' => $now_gmt,
233 233
 		'post_content' => $first_page,
234 234
 		'post_excerpt' => '',
235 235
 		'comment_status' => 'closed',
236
-		'post_title' => __( 'Sample Page' ),
236
+		'post_title' => __('Sample Page'),
237 237
 		/* translators: Default page slug */
238
-		'post_name' => __( 'sample-page' ),
238
+		'post_name' => __('sample-page'),
239 239
 		'post_modified' => $now,
240 240
 		'post_modified_gmt' => $now_gmt,
241 241
 		'guid' => $first_post_guid,
@@ -244,37 +244,37 @@  discard block
 block discarded – undo
244 244
 		'pinged' => '',
245 245
 		'post_content_filtered' => ''
246 246
 	));
247
-	$wpdb->insert( $wpdb->postmeta, array( 'post_id' => 2, 'meta_key' => '_wp_page_template', 'meta_value' => 'default' ) );
247
+	$wpdb->insert($wpdb->postmeta, array('post_id' => 2, 'meta_key' => '_wp_page_template', 'meta_value' => 'default'));
248 248
 
249 249
 	// Set up default widgets for default theme.
250
-	update_option( 'widget_search', array ( 2 => array ( 'title' => '' ), '_multiwidget' => 1 ) );
251
-	update_option( 'widget_recent-posts', array ( 2 => array ( 'title' => '', 'number' => 5 ), '_multiwidget' => 1 ) );
252
-	update_option( 'widget_recent-comments', array ( 2 => array ( 'title' => '', 'number' => 5 ), '_multiwidget' => 1 ) );
253
-	update_option( 'widget_archives', array ( 2 => array ( 'title' => '', 'count' => 0, 'dropdown' => 0 ), '_multiwidget' => 1 ) );
254
-	update_option( 'widget_categories', array ( 2 => array ( 'title' => '', 'count' => 0, 'hierarchical' => 0, 'dropdown' => 0 ), '_multiwidget' => 1 ) );
255
-	update_option( 'widget_meta', array ( 2 => array ( 'title' => '' ), '_multiwidget' => 1 ) );
256
-	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
-
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
-
263
-	if ( is_multisite() ) {
250
+	update_option('widget_search', array(2 => array('title' => ''), '_multiwidget' => 1));
251
+	update_option('widget_recent-posts', array(2 => array('title' => '', 'number' => 5), '_multiwidget' => 1));
252
+	update_option('widget_recent-comments', array(2 => array('title' => '', 'number' => 5), '_multiwidget' => 1));
253
+	update_option('widget_archives', array(2 => array('title' => '', 'count' => 0, 'dropdown' => 0), '_multiwidget' => 1));
254
+	update_option('widget_categories', array(2 => array('title' => '', 'count' => 0, 'hierarchical' => 0, 'dropdown' => 0), '_multiwidget' => 1));
255
+	update_option('widget_meta', array(2 => array('title' => ''), '_multiwidget' => 1));
256
+	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
+
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
+
263
+	if (is_multisite()) {
264 264
 		// Flush rules to pick up the new page.
265 265
 		$wp_rewrite->init();
266 266
 		$wp_rewrite->flush_rules();
267 267
 
268 268
 		$user = new WP_User($user_id);
269
-		$wpdb->update( $wpdb->options, array('option_value' => $user->user_email), array('option_name' => 'admin_email') );
269
+		$wpdb->update($wpdb->options, array('option_value' => $user->user_email), array('option_name' => 'admin_email'));
270 270
 
271 271
 		// Remove all perms except for the login user.
272
-		$wpdb->query( $wpdb->prepare("DELETE FROM $wpdb->usermeta WHERE user_id != %d AND meta_key = %s", $user_id, $table_prefix.'user_level') );
273
-		$wpdb->query( $wpdb->prepare("DELETE FROM $wpdb->usermeta WHERE user_id != %d AND meta_key = %s", $user_id, $table_prefix.'capabilities') );
272
+		$wpdb->query($wpdb->prepare("DELETE FROM $wpdb->usermeta WHERE user_id != %d AND meta_key = %s", $user_id, $table_prefix.'user_level'));
273
+		$wpdb->query($wpdb->prepare("DELETE FROM $wpdb->usermeta WHERE user_id != %d AND meta_key = %s", $user_id, $table_prefix.'capabilities'));
274 274
 
275 275
 		// 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' ) );
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'));
278 278
 	}
279 279
 }
280 280
 endif;
@@ -294,7 +294,7 @@  discard block
 block discarded – undo
294 294
 	global $wp_rewrite;
295 295
 
296 296
 	// Bail if a permalink structure is already enabled.
297
-	if ( get_option( 'permalink_structure' ) ) {
297
+	if (get_option('permalink_structure')) {
298 298
 		return true;
299 299
 	}
300 300
 
@@ -311,21 +311,21 @@  discard block
 block discarded – undo
311 311
 		'/index.php/%year%/%monthnum%/%day%/%postname%/'
312 312
 	);
313 313
 
314
-	foreach ( (array) $permalink_structures as $permalink_structure ) {
315
-		$wp_rewrite->set_permalink_structure( $permalink_structure );
314
+	foreach ((array) $permalink_structures as $permalink_structure) {
315
+		$wp_rewrite->set_permalink_structure($permalink_structure);
316 316
 
317 317
 		/*
318 318
 	 	 * Flush rules with the hard option to force refresh of the web-server's
319 319
 	 	 * rewrite config file (e.g. .htaccess or web.config).
320 320
 	 	 */
321
-		$wp_rewrite->flush_rules( true );
321
+		$wp_rewrite->flush_rules(true);
322 322
 
323 323
 		$test_url = '';
324 324
 
325 325
 		// Test against a real WordPress Post
326
-		$first_post = get_page_by_path( sanitize_title( _x( 'hello-world', 'Default post slug' ) ), OBJECT, 'post' );
327
-		if ( $first_post ) {
328
-			$test_url = get_permalink( $first_post->ID );
326
+		$first_post = get_page_by_path(sanitize_title(_x('hello-world', 'Default post slug')), OBJECT, 'post');
327
+		if ($first_post) {
328
+			$test_url = get_permalink($first_post->ID);
329 329
 		}
330 330
 
331 331
 		/*
@@ -335,11 +335,11 @@  discard block
 block discarded – undo
335 335
 	 	 * Uses wp_remote_get() instead of wp_remote_head() because web servers
336 336
 	 	 * can block head requests.
337 337
 	 	 */
338
-		$response          = wp_remote_get( $test_url, array( 'timeout' => 5 ) );
339
-		$x_pingback_header = wp_remote_retrieve_header( $response, 'x-pingback' );
340
-		$pretty_permalinks = $x_pingback_header && $x_pingback_header === get_bloginfo( 'pingback_url' );
338
+		$response          = wp_remote_get($test_url, array('timeout' => 5));
339
+		$x_pingback_header = wp_remote_retrieve_header($response, 'x-pingback');
340
+		$pretty_permalinks = $x_pingback_header && $x_pingback_header === get_bloginfo('pingback_url');
341 341
 
342
-		if ( $pretty_permalinks ) {
342
+		if ($pretty_permalinks) {
343 343
 			return true;
344 344
 		}
345 345
 	}
@@ -348,13 +348,13 @@  discard block
 block discarded – undo
348 348
 	 * If it makes it this far, pretty permalinks failed.
349 349
 	 * Fallback to query-string permalinks.
350 350
 	 */
351
-	$wp_rewrite->set_permalink_structure( '' );
352
-	$wp_rewrite->flush_rules( true );
351
+	$wp_rewrite->set_permalink_structure('');
352
+	$wp_rewrite->flush_rules(true);
353 353
 
354 354
 	return false;
355 355
 }
356 356
 
357
-if ( !function_exists('wp_new_blog_notification') ) :
357
+if ( ! function_exists('wp_new_blog_notification')) :
358 358
 /**
359 359
  * Notifies the site admin that the setup is complete.
360 360
  *
@@ -369,11 +369,11 @@  discard block
 block discarded – undo
369 369
  * @param string $password   User's Password.
370 370
  */
371 371
 function wp_new_blog_notification($blog_title, $blog_url, $user_id, $password) {
372
-	$user = new WP_User( $user_id );
372
+	$user = new WP_User($user_id);
373 373
 	$email = $user->user_email;
374 374
 	$name = $user->user_login;
375 375
 	$login_url = wp_login_url();
376
-	$message = sprintf( __( "Your new WordPress site has been successfully set up at:
376
+	$message = sprintf(__("Your new WordPress site has been successfully set up at:
377 377
 
378 378
 %1\$s
379 379
 
@@ -387,13 +387,13 @@  discard block
 block discarded – undo
387 387
 
388 388
 --The WordPress Team
389 389
 https://wordpress.org/
390
-"), $blog_url, $name, $password, $login_url );
390
+"), $blog_url, $name, $password, $login_url);
391 391
 
392 392
 	@wp_mail($email, __('New WordPress Site'), $message);
393 393
 }
394 394
 endif;
395 395
 
396
-if ( !function_exists('wp_upgrade') ) :
396
+if ( ! function_exists('wp_upgrade')) :
397 397
 /**
398 398
  * Runs WordPress Upgrade functions.
399 399
  *
@@ -411,10 +411,10 @@  discard block
 block discarded – undo
411 411
 	$wp_current_db_version = __get_option('db_version');
412 412
 
413 413
 	// We are up-to-date. Nothing to do.
414
-	if ( $wp_db_version == $wp_current_db_version )
414
+	if ($wp_db_version == $wp_current_db_version)
415 415
 		return;
416 416
 
417
-	if ( ! is_blog_installed() )
417
+	if ( ! is_blog_installed())
418 418
 		return;
419 419
 
420 420
 	wp_check_mysql_version();
@@ -422,15 +422,15 @@  discard block
 block discarded – undo
422 422
 	pre_schema_upgrade();
423 423
 	make_db_current_silent();
424 424
 	upgrade_all();
425
-	if ( is_multisite() && is_main_site() )
425
+	if (is_multisite() && is_main_site())
426 426
 		upgrade_network();
427 427
 	wp_cache_flush();
428 428
 
429
-	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}'" );
429
+	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 432
 		else
433
-			$wpdb->query( "INSERT INTO {$wpdb->blog_versions} ( `blog_id` , `db_version` , `last_updated` ) VALUES ( '{$wpdb->blogid}', '{$wp_db_version}', NOW());" );
433
+			$wpdb->query("INSERT INTO {$wpdb->blog_versions} ( `blog_id` , `db_version` , `last_updated` ) VALUES ( '{$wpdb->blogid}', '{$wp_db_version}', NOW());");
434 434
 	}
435 435
 
436 436
 	/**
@@ -441,7 +441,7 @@  discard block
 block discarded – undo
441 441
 	 * @param int $wp_db_version         The new $wp_db_version.
442 442
 	 * @param int $wp_current_db_version The old (current) $wp_db_version.
443 443
 	 */
444
-	do_action( 'wp_upgrade', $wp_db_version, $wp_current_db_version );
444
+	do_action('wp_upgrade', $wp_db_version, $wp_current_db_version);
445 445
 }
446 446
 endif;
447 447
 
@@ -462,109 +462,109 @@  discard block
 block discarded – undo
462 462
 	$wp_current_db_version = __get_option('db_version');
463 463
 
464 464
 	// We are up-to-date. Nothing to do.
465
-	if ( $wp_db_version == $wp_current_db_version )
465
+	if ($wp_db_version == $wp_current_db_version)
466 466
 		return;
467 467
 
468 468
 	// If the version is not set in the DB, try to guess the version.
469
-	if ( empty($wp_current_db_version) ) {
469
+	if (empty($wp_current_db_version)) {
470 470
 		$wp_current_db_version = 0;
471 471
 
472 472
 		// If the template option exists, we have 1.5.
473 473
 		$template = __get_option('template');
474
-		if ( !empty($template) )
474
+		if ( ! empty($template))
475 475
 			$wp_current_db_version = 2541;
476 476
 	}
477 477
 
478
-	if ( $wp_current_db_version < 6039 )
478
+	if ($wp_current_db_version < 6039)
479 479
 		upgrade_230_options_table();
480 480
 
481 481
 	populate_options();
482 482
 
483
-	if ( $wp_current_db_version < 2541 ) {
483
+	if ($wp_current_db_version < 2541) {
484 484
 		upgrade_100();
485 485
 		upgrade_101();
486 486
 		upgrade_110();
487 487
 		upgrade_130();
488 488
 	}
489 489
 
490
-	if ( $wp_current_db_version < 3308 )
490
+	if ($wp_current_db_version < 3308)
491 491
 		upgrade_160();
492 492
 
493
-	if ( $wp_current_db_version < 4772 )
493
+	if ($wp_current_db_version < 4772)
494 494
 		upgrade_210();
495 495
 
496
-	if ( $wp_current_db_version < 4351 )
496
+	if ($wp_current_db_version < 4351)
497 497
 		upgrade_old_slugs();
498 498
 
499
-	if ( $wp_current_db_version < 5539 )
499
+	if ($wp_current_db_version < 5539)
500 500
 		upgrade_230();
501 501
 
502
-	if ( $wp_current_db_version < 6124 )
502
+	if ($wp_current_db_version < 6124)
503 503
 		upgrade_230_old_tables();
504 504
 
505
-	if ( $wp_current_db_version < 7499 )
505
+	if ($wp_current_db_version < 7499)
506 506
 		upgrade_250();
507 507
 
508
-	if ( $wp_current_db_version < 7935 )
508
+	if ($wp_current_db_version < 7935)
509 509
 		upgrade_252();
510 510
 
511
-	if ( $wp_current_db_version < 8201 )
511
+	if ($wp_current_db_version < 8201)
512 512
 		upgrade_260();
513 513
 
514
-	if ( $wp_current_db_version < 8989 )
514
+	if ($wp_current_db_version < 8989)
515 515
 		upgrade_270();
516 516
 
517
-	if ( $wp_current_db_version < 10360 )
517
+	if ($wp_current_db_version < 10360)
518 518
 		upgrade_280();
519 519
 
520
-	if ( $wp_current_db_version < 11958 )
520
+	if ($wp_current_db_version < 11958)
521 521
 		upgrade_290();
522 522
 
523
-	if ( $wp_current_db_version < 15260 )
523
+	if ($wp_current_db_version < 15260)
524 524
 		upgrade_300();
525 525
 
526
-	if ( $wp_current_db_version < 19389 )
526
+	if ($wp_current_db_version < 19389)
527 527
 		upgrade_330();
528 528
 
529
-	if ( $wp_current_db_version < 20080 )
529
+	if ($wp_current_db_version < 20080)
530 530
 		upgrade_340();
531 531
 
532
-	if ( $wp_current_db_version < 22422 )
532
+	if ($wp_current_db_version < 22422)
533 533
 		upgrade_350();
534 534
 
535
-	if ( $wp_current_db_version < 25824 )
535
+	if ($wp_current_db_version < 25824)
536 536
 		upgrade_370();
537 537
 
538
-	if ( $wp_current_db_version < 26148 )
538
+	if ($wp_current_db_version < 26148)
539 539
 		upgrade_372();
540 540
 
541
-	if ( $wp_current_db_version < 26691 )
541
+	if ($wp_current_db_version < 26691)
542 542
 		upgrade_380();
543 543
 
544
-	if ( $wp_current_db_version < 29630 )
544
+	if ($wp_current_db_version < 29630)
545 545
 		upgrade_400();
546 546
 
547
-	if ( $wp_current_db_version < 33055 )
547
+	if ($wp_current_db_version < 33055)
548 548
 		upgrade_430();
549 549
 
550
-	if ( $wp_current_db_version < 33056 )
550
+	if ($wp_current_db_version < 33056)
551 551
 		upgrade_431();
552 552
 
553
-	if ( $wp_current_db_version < 35700 )
553
+	if ($wp_current_db_version < 35700)
554 554
 		upgrade_440();
555 555
 
556
-	if ( $wp_current_db_version < 36686 )
556
+	if ($wp_current_db_version < 36686)
557 557
 		upgrade_450();
558 558
 
559
-	if ( $wp_current_db_version < 37965 )
559
+	if ($wp_current_db_version < 37965)
560 560
 		upgrade_460();
561 561
 
562 562
 	maybe_disable_link_manager();
563 563
 
564 564
 	maybe_disable_automattic_widgets();
565 565
 
566
-	update_option( 'db_version', $wp_db_version );
567
-	update_option( 'db_upgraded', true );
566
+	update_option('db_version', $wp_db_version);
567
+	update_option('db_upgraded', true);
568 568
 }
569 569
 
570 570
 /**
@@ -584,7 +584,7 @@  discard block
 block discarded – undo
584 584
 		foreach ($posts as $post) {
585 585
 			if ('' == $post->post_name) {
586 586
 				$newtitle = sanitize_title($post->post_title);
587
-				$wpdb->query( $wpdb->prepare("UPDATE $wpdb->posts SET post_name = %s WHERE ID = %d", $newtitle, $post->ID) );
587
+				$wpdb->query($wpdb->prepare("UPDATE $wpdb->posts SET post_name = %s WHERE ID = %d", $newtitle, $post->ID));
588 588
 			}
589 589
 		}
590 590
 	}
@@ -593,7 +593,7 @@  discard block
 block discarded – undo
593 593
 	foreach ($categories as $category) {
594 594
 		if ('' == $category->category_nicename) {
595 595
 			$newtitle = sanitize_title($category->cat_name);
596
-			$wpdb->update( $wpdb->categories, array('category_nicename' => $newtitle), array('cat_ID' => $category->cat_ID) );
596
+			$wpdb->update($wpdb->categories, array('category_nicename' => $newtitle), array('cat_ID' => $category->cat_ID));
597 597
 		}
598 598
 	}
599 599
 
@@ -601,7 +601,7 @@  discard block
 block discarded – undo
601 601
 		SET option_value = REPLACE(option_value, 'wp-links/links-images/', 'wp-images/links/')
602 602
 		WHERE option_name LIKE %s
603 603
 		AND option_value LIKE %s";
604
-	$wpdb->query( $wpdb->prepare( $sql, $wpdb->esc_like( 'links_rating_image' ) . '%', $wpdb->esc_like( 'wp-links/links-images/' ) . '%' ) );
604
+	$wpdb->query($wpdb->prepare($sql, $wpdb->esc_like('links_rating_image').'%', $wpdb->esc_like('wp-links/links-images/').'%'));
605 605
 
606 606
 	$done_ids = $wpdb->get_results("SELECT DISTINCT post_id FROM $wpdb->post2cat");
607 607
 	if ($done_ids) :
@@ -609,7 +609,7 @@  discard block
 block discarded – undo
609 609
 		foreach ($done_ids as $done_id) :
610 610
 			$done_posts[] = $done_id->post_id;
611 611
 		endforeach;
612
-		$catwhere = ' AND ID NOT IN (' . implode(',', $done_posts) . ')';
612
+		$catwhere = ' AND ID NOT IN ('.implode(',', $done_posts).')';
613 613
 	else:
614 614
 		$catwhere = '';
615 615
 	endif;
@@ -618,9 +618,9 @@  discard block
 block discarded – undo
618 618
 	if ($allposts) :
619 619
 		foreach ($allposts as $post) {
620 620
 			// Check to see if it's already been imported
621
-			$cat = $wpdb->get_row( $wpdb->prepare("SELECT * FROM $wpdb->post2cat WHERE post_id = %d AND category_id = %d", $post->ID, $post->post_category) );
622
-			if (!$cat && 0 != $post->post_category) { // If there's no result
623
-				$wpdb->insert( $wpdb->post2cat, array('post_id' => $post->ID, 'category_id' => $post->post_category) );
621
+			$cat = $wpdb->get_row($wpdb->prepare("SELECT * FROM $wpdb->post2cat WHERE post_id = %d AND category_id = %d", $post->ID, $post->post_category));
622
+			if ( ! $cat && 0 != $post->post_category) { // If there's no result
623
+				$wpdb->insert($wpdb->post2cat, array('post_id' => $post->ID, 'category_id' => $post->post_category));
624 624
 			}
625 625
 		}
626 626
 	endif;
@@ -643,8 +643,8 @@  discard block
 block discarded – undo
643 643
 	add_clean_index($wpdb->categories, 'category_nicename');
644 644
 	add_clean_index($wpdb->comments, 'comment_approved');
645 645
 	add_clean_index($wpdb->comments, 'comment_post_ID');
646
-	add_clean_index($wpdb->links , 'link_category');
647
-	add_clean_index($wpdb->links , 'link_visible');
646
+	add_clean_index($wpdb->links, 'link_category');
647
+	add_clean_index($wpdb->links, 'link_visible');
648 648
 }
649 649
 
650 650
 /**
@@ -663,14 +663,14 @@  discard block
 block discarded – undo
663 663
 	foreach ($users as $user) {
664 664
 		if ('' == $user->user_nicename) {
665 665
 			$newname = sanitize_title($user->user_nickname);
666
-			$wpdb->update( $wpdb->users, array('user_nicename' => $newname), array('ID' => $user->ID) );
666
+			$wpdb->update($wpdb->users, array('user_nicename' => $newname), array('ID' => $user->ID));
667 667
 		}
668 668
 	}
669 669
 
670 670
 	$users = $wpdb->get_results("SELECT ID, user_pass from $wpdb->users");
671 671
 	foreach ($users as $row) {
672
-		if (!preg_match('/^[A-Fa-f0-9]{32}$/', $row->user_pass)) {
673
-			$wpdb->update( $wpdb->users, array('user_pass' => md5($row->user_pass)), array('ID' => $row->ID) );
672
+		if ( ! preg_match('/^[A-Fa-f0-9]{32}$/', $row->user_pass)) {
673
+			$wpdb->update($wpdb->users, array('user_pass' => md5($row->user_pass)), array('ID' => $row->ID));
674 674
 		}
675 675
 	}
676 676
 
@@ -679,7 +679,7 @@  discard block
 block discarded – undo
679 679
 
680 680
 	$time_difference = $all_options->time_difference;
681 681
 
682
-		$server_time = time()+date('Z');
682
+		$server_time = time() + date('Z');
683 683
 	$weblogger_time = $server_time + $time_difference * HOUR_IN_SECONDS;
684 684
 	$gmt_time = time();
685 685
 
@@ -696,7 +696,7 @@  discard block
 block discarded – undo
696 696
 	// <michel_v> I just slapped myself silly for not thinking about it earlier
697 697
 	$got_gmt_fields = ! ($wpdb->get_var("SELECT MAX(post_date_gmt) FROM $wpdb->posts") == '0000-00-00 00:00:00');
698 698
 
699
-	if (!$got_gmt_fields) {
699
+	if ( ! $got_gmt_fields) {
700 700
 
701 701
 		// Add or subtract time to all dates, to get GMT dates
702 702
 		$add_hours = intval($diff_gmt_weblogger);
@@ -728,12 +728,12 @@  discard block
 block discarded – undo
728 728
 			$post_content = addslashes(deslash($post->post_content));
729 729
 			$post_title = addslashes(deslash($post->post_title));
730 730
 			$post_excerpt = addslashes(deslash($post->post_excerpt));
731
-			if ( empty($post->guid) )
731
+			if (empty($post->guid))
732 732
 				$guid = get_permalink($post->ID);
733 733
 			else
734 734
 				$guid = $post->guid;
735 735
 
736
-			$wpdb->update( $wpdb->posts, compact('post_title', 'post_content', 'post_excerpt', 'guid'), array('ID' => $post->ID) );
736
+			$wpdb->update($wpdb->posts, compact('post_title', 'post_content', 'post_excerpt', 'guid'), array('ID' => $post->ID));
737 737
 
738 738
 		}
739 739
 	}
@@ -745,7 +745,7 @@  discard block
 block discarded – undo
745 745
 			$comment_content = deslash($comment->comment_content);
746 746
 			$comment_author = deslash($comment->comment_author);
747 747
 
748
-			$wpdb->update($wpdb->comments, compact('comment_content', 'comment_author'), array('comment_ID' => $comment->comment_ID) );
748
+			$wpdb->update($wpdb->comments, compact('comment_content', 'comment_author'), array('comment_ID' => $comment->comment_ID));
749 749
 		}
750 750
 	}
751 751
 
@@ -756,7 +756,7 @@  discard block
 block discarded – undo
756 756
 			$link_name = deslash($link->link_name);
757 757
 			$link_description = deslash($link->link_description);
758 758
 
759
-			$wpdb->update( $wpdb->links, compact('link_name', 'link_description'), array('link_id' => $link->link_id) );
759
+			$wpdb->update($wpdb->links, compact('link_name', 'link_description'), array('link_id' => $link->link_id));
760 760
 		}
761 761
 	}
762 762
 
@@ -766,16 +766,16 @@  discard block
 block discarded – undo
766 766
 	 * If plugins are not stored in an array, they're stored in the old
767 767
 	 * newline separated format. Convert to new format.
768 768
 	 */
769
-	if ( !is_array( $active_plugins ) ) {
769
+	if ( ! is_array($active_plugins)) {
770 770
 		$active_plugins = explode("\n", trim($active_plugins));
771 771
 		update_option('active_plugins', $active_plugins);
772 772
 	}
773 773
 
774 774
 	// Obsolete tables
775
-	$wpdb->query('DROP TABLE IF EXISTS ' . $wpdb->prefix . 'optionvalues');
776
-	$wpdb->query('DROP TABLE IF EXISTS ' . $wpdb->prefix . 'optiontypes');
777
-	$wpdb->query('DROP TABLE IF EXISTS ' . $wpdb->prefix . 'optiongroups');
778
-	$wpdb->query('DROP TABLE IF EXISTS ' . $wpdb->prefix . 'optiongroup_options');
775
+	$wpdb->query('DROP TABLE IF EXISTS '.$wpdb->prefix.'optionvalues');
776
+	$wpdb->query('DROP TABLE IF EXISTS '.$wpdb->prefix.'optiontypes');
777
+	$wpdb->query('DROP TABLE IF EXISTS '.$wpdb->prefix.'optiongroups');
778
+	$wpdb->query('DROP TABLE IF EXISTS '.$wpdb->prefix.'optiongroup_options');
779 779
 
780 780
 	// Update comments table to use comment_type
781 781
 	$wpdb->query("UPDATE $wpdb->comments SET comment_type='trackback', comment_content = REPLACE(comment_content, '<trackback />', '') WHERE comment_content LIKE '<trackback />%'");
@@ -783,11 +783,11 @@  discard block
 block discarded – undo
783 783
 
784 784
 	// Some versions have multiple duplicate option_name rows with the same values
785 785
 	$options = $wpdb->get_results("SELECT option_name, COUNT(option_name) AS dupes FROM `$wpdb->options` GROUP BY option_name");
786
-	foreach ( $options as $option ) {
787
-		if ( 1 != $option->dupes ) { // Could this be done in the query?
786
+	foreach ($options as $option) {
787
+		if (1 != $option->dupes) { // Could this be done in the query?
788 788
 			$limit = $option->dupes - 1;
789
-			$dupe_ids = $wpdb->get_col( $wpdb->prepare("SELECT option_id FROM $wpdb->options WHERE option_name = %s LIMIT %d", $option->option_name, $limit) );
790
-			if ( $dupe_ids ) {
789
+			$dupe_ids = $wpdb->get_col($wpdb->prepare("SELECT option_id FROM $wpdb->options WHERE option_name = %s LIMIT %d", $option->option_name, $limit));
790
+			if ($dupe_ids) {
791 791
 				$dupe_ids = join($dupe_ids, ',');
792 792
 				$wpdb->query("DELETE FROM $wpdb->options WHERE option_id IN ($dupe_ids)");
793 793
 			}
@@ -812,27 +812,27 @@  discard block
 block discarded – undo
812 812
 	populate_roles_160();
813 813
 
814 814
 	$users = $wpdb->get_results("SELECT * FROM $wpdb->users");
815
-	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) );
834
-
835
-		if ( isset( $user->user_idmode ) ):
815
+	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));
834
+
835
+		if (isset($user->user_idmode)):
836 836
 			$idmode = $user->user_idmode;
837 837
 			if ($idmode == 'nickname') $id = $user->user_nickname;
838 838
 			if ($idmode == 'login') $id = $user->user_login;
@@ -840,46 +840,46 @@  discard block
 block discarded – undo
840 840
 			if ($idmode == 'lastname') $id = $user->user_lastname;
841 841
 			if ($idmode == 'namefl') $id = $user->user_firstname.' '.$user->user_lastname;
842 842
 			if ($idmode == 'namelf') $id = $user->user_lastname.' '.$user->user_firstname;
843
-			if (!$idmode) $id = $user->user_nickname;
844
-			$wpdb->update( $wpdb->users, array('display_name' => $id), array('ID' => $user->ID) );
843
+			if ( ! $idmode) $id = $user->user_nickname;
844
+			$wpdb->update($wpdb->users, array('display_name' => $id), array('ID' => $user->ID));
845 845
 		endif;
846 846
 
847 847
 		// FIXME: RESET_CAPS is temporary code to reset roles and caps if flag is set.
848
-		$caps = get_user_meta( $user->ID, $wpdb->prefix . 'capabilities');
849
-		if ( empty($caps) || defined('RESET_CAPS') ) {
850
-			$level = get_user_meta($user->ID, $wpdb->prefix . 'user_level', true);
848
+		$caps = get_user_meta($user->ID, $wpdb->prefix.'capabilities');
849
+		if (empty($caps) || defined('RESET_CAPS')) {
850
+			$level = get_user_meta($user->ID, $wpdb->prefix.'user_level', true);
851 851
 			$role = translate_level_to_role($level);
852
-			update_user_meta( $user->ID, $wpdb->prefix . 'capabilities', array($role => true) );
852
+			update_user_meta($user->ID, $wpdb->prefix.'capabilities', array($role => true));
853 853
 		}
854 854
 
855 855
 	endforeach;
856
-	$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' );
856
+	$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 857
 	$wpdb->hide_errors();
858
-	foreach ( $old_user_fields as $old )
858
+	foreach ($old_user_fields as $old)
859 859
 		$wpdb->query("ALTER TABLE $wpdb->users DROP $old");
860 860
 	$wpdb->show_errors();
861 861
 
862 862
 	// Populate comment_count field of posts table.
863
-	$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 ) )
863
+	$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 865
 		foreach ($comments as $comment)
866
-			$wpdb->update( $wpdb->posts, array('comment_count' => $comment->c), array('ID' => $comment->comment_post_ID) );
866
+			$wpdb->update($wpdb->posts, array('comment_count' => $comment->c), array('ID' => $comment->comment_post_ID));
867 867
 
868 868
 	/*
869 869
 	 * Some alpha versions used a post status of object instead of attachment
870 870
 	 * and put the mime type in post_type instead of post_mime_type.
871 871
 	 */
872
-	if ( $wp_current_db_version > 2541 && $wp_current_db_version <= 3091 ) {
872
+	if ($wp_current_db_version > 2541 && $wp_current_db_version <= 3091) {
873 873
 		$objects = $wpdb->get_results("SELECT ID, post_type FROM $wpdb->posts WHERE post_status = 'object'");
874 874
 		foreach ($objects as $object) {
875
-			$wpdb->update( $wpdb->posts, array(	'post_status' => 'attachment',
875
+			$wpdb->update($wpdb->posts, array('post_status' => 'attachment',
876 876
 												'post_mime_type' => $object->post_type,
877 877
 												'post_type' => ''),
878
-										 array( 'ID' => $object->ID ) );
878
+										 array('ID' => $object->ID));
879 879
 
880 880
 			$meta = get_post_meta($object->ID, 'imagedata', true);
881
-			if ( ! empty($meta['file']) )
882
-				update_attached_file( $object->ID, $meta['file'] );
881
+			if ( ! empty($meta['file']))
882
+				update_attached_file($object->ID, $meta['file']);
883 883
 		}
884 884
 	}
885 885
 }
@@ -896,38 +896,38 @@  discard block
 block discarded – undo
896 896
 function upgrade_210() {
897 897
 	global $wpdb, $wp_current_db_version;
898 898
 
899
-	if ( $wp_current_db_version < 3506 ) {
899
+	if ($wp_current_db_version < 3506) {
900 900
 		// Update status and type.
901 901
 		$posts = $wpdb->get_results("SELECT ID, post_status FROM $wpdb->posts");
902 902
 
903
-		if ( ! empty($posts) ) foreach ($posts as $post) {
903
+		if ( ! empty($posts)) foreach ($posts as $post) {
904 904
 			$status = $post->post_status;
905 905
 			$type = 'post';
906 906
 
907
-			if ( 'static' == $status ) {
907
+			if ('static' == $status) {
908 908
 				$status = 'publish';
909 909
 				$type = 'page';
910
-			} elseif ( 'attachment' == $status ) {
910
+			} elseif ('attachment' == $status) {
911 911
 				$status = 'inherit';
912 912
 				$type = 'attachment';
913 913
 			}
914 914
 
915
-			$wpdb->query( $wpdb->prepare("UPDATE $wpdb->posts SET post_status = %s, post_type = %s WHERE ID = %d", $status, $type, $post->ID) );
915
+			$wpdb->query($wpdb->prepare("UPDATE $wpdb->posts SET post_status = %s, post_type = %s WHERE ID = %d", $status, $type, $post->ID));
916 916
 		}
917 917
 	}
918 918
 
919
-	if ( $wp_current_db_version < 3845 ) {
919
+	if ($wp_current_db_version < 3845) {
920 920
 		populate_roles_210();
921 921
 	}
922 922
 
923
-	if ( $wp_current_db_version < 3531 ) {
923
+	if ($wp_current_db_version < 3531) {
924 924
 		// Give future posts a post_status of future.
925 925
 		$now = gmdate('Y-m-d H:i:59');
926
-		$wpdb->query ("UPDATE $wpdb->posts SET post_status = 'future' WHERE post_status = 'publish' AND post_date_gmt > '$now'");
926
+		$wpdb->query("UPDATE $wpdb->posts SET post_status = 'future' WHERE post_status = 'publish' AND post_date_gmt > '$now'");
927 927
 
928 928
 		$posts = $wpdb->get_results("SELECT ID, post_date FROM $wpdb->posts WHERE post_status ='future'");
929
-		if ( !empty($posts) )
930
-			foreach ( $posts as $post )
929
+		if ( ! empty($posts))
930
+			foreach ($posts as $post)
931 931
 				wp_schedule_single_event(mysql2date('U', $post->post_date, false), 'publish_future_post', array($post->ID));
932 932
 	}
933 933
 }
@@ -944,7 +944,7 @@  discard block
 block discarded – undo
944 944
 function upgrade_230() {
945 945
 	global $wp_current_db_version, $wpdb;
946 946
 
947
-	if ( $wp_current_db_version < 5200 ) {
947
+	if ($wp_current_db_version < 5200) {
948 948
 		populate_roles_230();
949 949
 	}
950 950
 
@@ -961,78 +961,78 @@  discard block
 block discarded – undo
961 961
 		$term_group = 0;
962 962
 
963 963
 		// Associate terms with the same slug in a term group and make slugs unique.
964
-		if ( $exists = $wpdb->get_results( $wpdb->prepare("SELECT term_id, term_group FROM $wpdb->terms WHERE slug = %s", $slug) ) ) {
964
+		if ($exists = $wpdb->get_results($wpdb->prepare("SELECT term_id, term_group FROM $wpdb->terms WHERE slug = %s", $slug))) {
965 965
 			$term_group = $exists[0]->term_group;
966 966
 			$id = $exists[0]->term_id;
967 967
 			$num = 2;
968 968
 			do {
969
-				$alt_slug = $slug . "-$num";
969
+				$alt_slug = $slug."-$num";
970 970
 				$num++;
971
-				$slug_check = $wpdb->get_var( $wpdb->prepare("SELECT slug FROM $wpdb->terms WHERE slug = %s", $alt_slug) );
972
-			} while ( $slug_check );
971
+				$slug_check = $wpdb->get_var($wpdb->prepare("SELECT slug FROM $wpdb->terms WHERE slug = %s", $alt_slug));
972
+			} while ($slug_check);
973 973
 
974 974
 			$slug = $alt_slug;
975 975
 
976
-			if ( empty( $term_group ) ) {
976
+			if (empty($term_group)) {
977 977
 				$term_group = $wpdb->get_var("SELECT MAX(term_group) FROM $wpdb->terms GROUP BY term_group") + 1;
978
-				$wpdb->query( $wpdb->prepare("UPDATE $wpdb->terms SET term_group = %d WHERE term_id = %d", $term_group, $id) );
978
+				$wpdb->query($wpdb->prepare("UPDATE $wpdb->terms SET term_group = %d WHERE term_id = %d", $term_group, $id));
979 979
 			}
980 980
 		}
981 981
 
982
-		$wpdb->query( $wpdb->prepare("INSERT INTO $wpdb->terms (term_id, name, slug, term_group) VALUES
983
-		(%d, %s, %s, %d)", $term_id, $name, $slug, $term_group) );
982
+		$wpdb->query($wpdb->prepare("INSERT INTO $wpdb->terms (term_id, name, slug, term_group) VALUES
983
+		(%d, %s, %s, %d)", $term_id, $name, $slug, $term_group));
984 984
 
985 985
 		$count = 0;
986
-		if ( !empty($category->category_count) ) {
986
+		if ( ! empty($category->category_count)) {
987 987
 			$count = (int) $category->category_count;
988 988
 			$taxonomy = 'category';
989
-			$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) );
989
+			$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));
990 990
 			$tt_ids[$term_id][$taxonomy] = (int) $wpdb->insert_id;
991 991
 		}
992 992
 
993
-		if ( !empty($category->link_count) ) {
993
+		if ( ! empty($category->link_count)) {
994 994
 			$count = (int) $category->link_count;
995 995
 			$taxonomy = 'link_category';
996
-			$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) );
996
+			$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));
997 997
 			$tt_ids[$term_id][$taxonomy] = (int) $wpdb->insert_id;
998 998
 		}
999 999
 
1000
-		if ( !empty($category->tag_count) ) {
1000
+		if ( ! empty($category->tag_count)) {
1001 1001
 			$have_tags = true;
1002 1002
 			$count = (int) $category->tag_count;
1003 1003
 			$taxonomy = 'post_tag';
1004
-			$wpdb->insert( $wpdb->term_taxonomy, compact('term_id', 'taxonomy', 'description', 'parent', 'count') );
1004
+			$wpdb->insert($wpdb->term_taxonomy, compact('term_id', 'taxonomy', 'description', 'parent', 'count'));
1005 1005
 			$tt_ids[$term_id][$taxonomy] = (int) $wpdb->insert_id;
1006 1006
 		}
1007 1007
 
1008
-		if ( empty($count) ) {
1008
+		if (empty($count)) {
1009 1009
 			$count = 0;
1010 1010
 			$taxonomy = 'category';
1011
-			$wpdb->insert( $wpdb->term_taxonomy, compact('term_id', 'taxonomy', 'description', 'parent', 'count') );
1011
+			$wpdb->insert($wpdb->term_taxonomy, compact('term_id', 'taxonomy', 'description', 'parent', 'count'));
1012 1012
 			$tt_ids[$term_id][$taxonomy] = (int) $wpdb->insert_id;
1013 1013
 		}
1014 1014
 	}
1015 1015
 
1016 1016
 	$select = 'post_id, category_id';
1017
-	if ( $have_tags )
1017
+	if ($have_tags)
1018 1018
 		$select .= ', rel_type';
1019 1019
 
1020 1020
 	$posts = $wpdb->get_results("SELECT $select FROM $wpdb->post2cat GROUP BY post_id, category_id");
1021
-	foreach ( $posts as $post ) {
1021
+	foreach ($posts as $post) {
1022 1022
 		$post_id = (int) $post->post_id;
1023 1023
 		$term_id = (int) $post->category_id;
1024 1024
 		$taxonomy = 'category';
1025
-		if ( !empty($post->rel_type) && 'tag' == $post->rel_type)
1025
+		if ( ! empty($post->rel_type) && 'tag' == $post->rel_type)
1026 1026
 			$taxonomy = 'tag';
1027 1027
 		$tt_id = $tt_ids[$term_id][$taxonomy];
1028
-		if ( empty($tt_id) )
1028
+		if (empty($tt_id))
1029 1029
 			continue;
1030 1030
 
1031
-		$wpdb->insert( $wpdb->term_relationships, array('object_id' => $post_id, 'term_taxonomy_id' => $tt_id) );
1031
+		$wpdb->insert($wpdb->term_relationships, array('object_id' => $post_id, 'term_taxonomy_id' => $tt_id));
1032 1032
 	}
1033 1033
 
1034 1034
 	// < 3570 we used linkcategories. >= 3570 we used categories and link2cat.
1035
-	if ( $wp_current_db_version < 3570 ) {
1035
+	if ($wp_current_db_version < 3570) {
1036 1036
 		/*
1037 1037
 		 * Create link_category terms for link categories. Create a map of link
1038 1038
 		 * cat IDs to link_category terms.
@@ -1040,8 +1040,8 @@  discard block
 block discarded – undo
1040 1040
 		$link_cat_id_map = array();
1041 1041
 		$default_link_cat = 0;
1042 1042
 		$tt_ids = array();
1043
-		$link_cats = $wpdb->get_results("SELECT cat_id, cat_name FROM " . $wpdb->prefix . 'linkcategories');
1044
-		foreach ( $link_cats as $category) {
1043
+		$link_cats = $wpdb->get_results("SELECT cat_id, cat_name FROM ".$wpdb->prefix.'linkcategories');
1044
+		foreach ($link_cats as $category) {
1045 1045
 			$cat_id = (int) $category->cat_id;
1046 1046
 			$term_id = 0;
1047 1047
 			$name = wp_slash($category->cat_name);
@@ -1049,66 +1049,66 @@  discard block
 block discarded – undo
1049 1049
 			$term_group = 0;
1050 1050
 
1051 1051
 			// Associate terms with the same slug in a term group and make slugs unique.
1052
-			if ( $exists = $wpdb->get_results( $wpdb->prepare("SELECT term_id, term_group FROM $wpdb->terms WHERE slug = %s", $slug) ) ) {
1052
+			if ($exists = $wpdb->get_results($wpdb->prepare("SELECT term_id, term_group FROM $wpdb->terms WHERE slug = %s", $slug))) {
1053 1053
 				$term_group = $exists[0]->term_group;
1054 1054
 				$term_id = $exists[0]->term_id;
1055 1055
 			}
1056 1056
 
1057
-			if ( empty($term_id) ) {
1058
-				$wpdb->insert( $wpdb->terms, compact('name', 'slug', 'term_group') );
1057
+			if (empty($term_id)) {
1058
+				$wpdb->insert($wpdb->terms, compact('name', 'slug', 'term_group'));
1059 1059
 				$term_id = (int) $wpdb->insert_id;
1060 1060
 			}
1061 1061
 
1062 1062
 			$link_cat_id_map[$cat_id] = $term_id;
1063 1063
 			$default_link_cat = $term_id;
1064 1064
 
1065
-			$wpdb->insert( $wpdb->term_taxonomy, array('term_id' => $term_id, 'taxonomy' => 'link_category', 'description' => '', 'parent' => 0, 'count' => 0) );
1065
+			$wpdb->insert($wpdb->term_taxonomy, array('term_id' => $term_id, 'taxonomy' => 'link_category', 'description' => '', 'parent' => 0, 'count' => 0));
1066 1066
 			$tt_ids[$term_id] = (int) $wpdb->insert_id;
1067 1067
 		}
1068 1068
 
1069 1069
 		// Associate links to cats.
1070 1070
 		$links = $wpdb->get_results("SELECT link_id, link_category FROM $wpdb->links");
1071
-		if ( !empty($links) ) foreach ( $links as $link ) {
1072
-			if ( 0 == $link->link_category )
1071
+		if ( ! empty($links)) foreach ($links as $link) {
1072
+			if (0 == $link->link_category)
1073 1073
 				continue;
1074
-			if ( ! isset($link_cat_id_map[$link->link_category]) )
1074
+			if ( ! isset($link_cat_id_map[$link->link_category]))
1075 1075
 				continue;
1076 1076
 			$term_id = $link_cat_id_map[$link->link_category];
1077 1077
 			$tt_id = $tt_ids[$term_id];
1078
-			if ( empty($tt_id) )
1078
+			if (empty($tt_id))
1079 1079
 				continue;
1080 1080
 
1081
-			$wpdb->insert( $wpdb->term_relationships, array('object_id' => $link->link_id, 'term_taxonomy_id' => $tt_id) );
1081
+			$wpdb->insert($wpdb->term_relationships, array('object_id' => $link->link_id, 'term_taxonomy_id' => $tt_id));
1082 1082
 		}
1083 1083
 
1084 1084
 		// Set default to the last category we grabbed during the upgrade loop.
1085 1085
 		update_option('default_link_category', $default_link_cat);
1086 1086
 	} else {
1087 1087
 		$links = $wpdb->get_results("SELECT link_id, category_id FROM $wpdb->link2cat GROUP BY link_id, category_id");
1088
-		foreach ( $links as $link ) {
1088
+		foreach ($links as $link) {
1089 1089
 			$link_id = (int) $link->link_id;
1090 1090
 			$term_id = (int) $link->category_id;
1091 1091
 			$taxonomy = 'link_category';
1092 1092
 			$tt_id = $tt_ids[$term_id][$taxonomy];
1093
-			if ( empty($tt_id) )
1093
+			if (empty($tt_id))
1094 1094
 				continue;
1095
-			$wpdb->insert( $wpdb->term_relationships, array('object_id' => $link_id, 'term_taxonomy_id' => $tt_id) );
1095
+			$wpdb->insert($wpdb->term_relationships, array('object_id' => $link_id, 'term_taxonomy_id' => $tt_id));
1096 1096
 		}
1097 1097
 	}
1098 1098
 
1099
-	if ( $wp_current_db_version < 4772 ) {
1099
+	if ($wp_current_db_version < 4772) {
1100 1100
 		// Obsolete linkcategories table
1101
-		$wpdb->query('DROP TABLE IF EXISTS ' . $wpdb->prefix . 'linkcategories');
1101
+		$wpdb->query('DROP TABLE IF EXISTS '.$wpdb->prefix.'linkcategories');
1102 1102
 	}
1103 1103
 
1104 1104
 	// Recalculate all counts
1105 1105
 	$terms = $wpdb->get_results("SELECT term_taxonomy_id, taxonomy FROM $wpdb->term_taxonomy");
1106
-	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) );
1106
+	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 1109
 		else
1110
-			$count = $wpdb->get_var( $wpdb->prepare("SELECT COUNT(*) FROM $wpdb->term_relationships WHERE term_taxonomy_id = %d", $term->term_taxonomy_id) );
1111
-		$wpdb->update( $wpdb->term_taxonomy, array('count' => $count), array('term_taxonomy_id' => $term->term_taxonomy_id) );
1110
+			$count = $wpdb->get_var($wpdb->prepare("SELECT COUNT(*) FROM $wpdb->term_relationships WHERE term_taxonomy_id = %d", $term->term_taxonomy_id));
1111
+		$wpdb->update($wpdb->term_taxonomy, array('count' => $count), array('term_taxonomy_id' => $term->term_taxonomy_id));
1112 1112
 	}
1113 1113
 }
1114 1114
 
@@ -1122,9 +1122,9 @@  discard block
 block discarded – undo
1122 1122
  */
1123 1123
 function upgrade_230_options_table() {
1124 1124
 	global $wpdb;
1125
-	$old_options_fields = array( 'option_can_override', 'option_type', 'option_width', 'option_height', 'option_description', 'option_admin_level' );
1125
+	$old_options_fields = array('option_can_override', 'option_type', 'option_width', 'option_height', 'option_description', 'option_admin_level');
1126 1126
 	$wpdb->hide_errors();
1127
-	foreach ( $old_options_fields as $old )
1127
+	foreach ($old_options_fields as $old)
1128 1128
 		$wpdb->query("ALTER TABLE $wpdb->options DROP $old");
1129 1129
 	$wpdb->show_errors();
1130 1130
 }
@@ -1139,9 +1139,9 @@  discard block
 block discarded – undo
1139 1139
  */
1140 1140
 function upgrade_230_old_tables() {
1141 1141
 	global $wpdb;
1142
-	$wpdb->query('DROP TABLE IF EXISTS ' . $wpdb->prefix . 'categories');
1143
-	$wpdb->query('DROP TABLE IF EXISTS ' . $wpdb->prefix . 'link2cat');
1144
-	$wpdb->query('DROP TABLE IF EXISTS ' . $wpdb->prefix . 'post2cat');
1142
+	$wpdb->query('DROP TABLE IF EXISTS '.$wpdb->prefix.'categories');
1143
+	$wpdb->query('DROP TABLE IF EXISTS '.$wpdb->prefix.'link2cat');
1144
+	$wpdb->query('DROP TABLE IF EXISTS '.$wpdb->prefix.'post2cat');
1145 1145
 }
1146 1146
 
1147 1147
 /**
@@ -1169,7 +1169,7 @@  discard block
 block discarded – undo
1169 1169
 function upgrade_250() {
1170 1170
 	global $wp_current_db_version;
1171 1171
 
1172
-	if ( $wp_current_db_version < 6689 ) {
1172
+	if ($wp_current_db_version < 6689) {
1173 1173
 		populate_roles_250();
1174 1174
 	}
1175 1175
 
@@ -1200,7 +1200,7 @@  discard block
 block discarded – undo
1200 1200
 function upgrade_260() {
1201 1201
 	global $wp_current_db_version;
1202 1202
 
1203
-	if ( $wp_current_db_version < 8000 )
1203
+	if ($wp_current_db_version < 8000)
1204 1204
 		populate_roles_260();
1205 1205
 }
1206 1206
 
@@ -1216,12 +1216,12 @@  discard block
 block discarded – undo
1216 1216
 function upgrade_270() {
1217 1217
 	global $wpdb, $wp_current_db_version;
1218 1218
 
1219
-	if ( $wp_current_db_version < 8980 )
1219
+	if ($wp_current_db_version < 8980)
1220 1220
 		populate_roles_270();
1221 1221
 
1222 1222
 	// 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'" );
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 1225
 }
1226 1226
 
1227 1227
 /**
@@ -1236,22 +1236,22 @@  discard block
 block discarded – undo
1236 1236
 function upgrade_280() {
1237 1237
 	global $wp_current_db_version, $wpdb;
1238 1238
 
1239
-	if ( $wp_current_db_version < 10360 )
1239
+	if ($wp_current_db_version < 10360)
1240 1240
 		populate_roles_280();
1241
-	if ( is_multisite() ) {
1241
+	if (is_multisite()) {
1242 1242
 		$start = 0;
1243
-		while( $rows = $wpdb->get_results( "SELECT option_name, option_value FROM $wpdb->options ORDER BY option_id LIMIT $start, 20" ) ) {
1244
-			foreach ( $rows as $row ) {
1243
+		while ($rows = $wpdb->get_results("SELECT option_name, option_value FROM $wpdb->options ORDER BY option_id LIMIT $start, 20")) {
1244
+			foreach ($rows as $row) {
1245 1245
 				$value = $row->option_value;
1246
-				if ( !@unserialize( $value ) )
1247
-					$value = stripslashes( $value );
1248
-				if ( $value !== $row->option_value ) {
1249
-					update_option( $row->option_name, $value );
1246
+				if ( ! @unserialize($value))
1247
+					$value = stripslashes($value);
1248
+				if ($value !== $row->option_value) {
1249
+					update_option($row->option_name, $value);
1250 1250
 				}
1251 1251
 			}
1252 1252
 			$start += 20;
1253 1253
 		}
1254
-		refresh_blog_details( $wpdb->blogid );
1254
+		refresh_blog_details($wpdb->blogid);
1255 1255
 	}
1256 1256
 }
1257 1257
 
@@ -1266,11 +1266,11 @@  discard block
 block discarded – undo
1266 1266
 function upgrade_290() {
1267 1267
 	global $wp_current_db_version;
1268 1268
 
1269
-	if ( $wp_current_db_version < 11958 ) {
1269
+	if ($wp_current_db_version < 11958) {
1270 1270
 		// Previously, setting depth to 1 would redundantly disable threading, but now 2 is the minimum depth to avoid confusion
1271
-		if ( get_option( 'thread_comments_depth' ) == '1' ) {
1272
-			update_option( 'thread_comments_depth', 2 );
1273
-			update_option( 'thread_comments', 0 );
1271
+		if (get_option('thread_comments_depth') == '1') {
1272
+			update_option('thread_comments_depth', 2);
1273
+			update_option('thread_comments', 0);
1274 1274
 		}
1275 1275
 	}
1276 1276
 }
@@ -1287,14 +1287,14 @@  discard block
 block discarded – undo
1287 1287
 function upgrade_300() {
1288 1288
 	global $wp_current_db_version, $wpdb;
1289 1289
 
1290
-	if ( $wp_current_db_version < 15093 )
1290
+	if ($wp_current_db_version < 15093)
1291 1291
 		populate_roles_300();
1292 1292
 
1293
-	if ( $wp_current_db_version < 14139 && is_multisite() && is_main_site() && ! defined( 'MULTISITE' ) && get_site_option( 'siteurl' ) === false )
1294
-		add_site_option( 'siteurl', '' );
1293
+	if ($wp_current_db_version < 14139 && is_multisite() && is_main_site() && ! defined('MULTISITE') && get_site_option('siteurl') === false)
1294
+		add_site_option('siteurl', '');
1295 1295
 
1296 1296
 	// 3.0 screen options key name changes.
1297
-	if ( wp_should_upgrade_global_tables() ) {
1297
+	if (wp_should_upgrade_global_tables()) {
1298 1298
 		$sql = "DELETE FROM $wpdb->usermeta
1299 1299
 			WHERE meta_key LIKE %s
1300 1300
 			OR meta_key LIKE %s
@@ -1308,15 +1308,15 @@  discard block
 block discarded – undo
1308 1308
 			OR meta_key = 'manageeditcolumnshidden'
1309 1309
 			OR meta_key = 'categories_per_page'
1310 1310
 			OR meta_key = 'edit_tags_per_page'";
1311
-		$prefix = $wpdb->esc_like( $wpdb->base_prefix );
1312
-		$wpdb->query( $wpdb->prepare( $sql,
1313
-			$prefix . '%' . $wpdb->esc_like( 'meta-box-hidden' ) . '%',
1314
-			$prefix . '%' . $wpdb->esc_like( 'closedpostboxes' ) . '%',
1315
-			$prefix . '%' . $wpdb->esc_like( 'manage-'	   ) . '%' . $wpdb->esc_like( '-columns-hidden' ) . '%',
1316
-			$prefix . '%' . $wpdb->esc_like( 'meta-box-order'  ) . '%',
1317
-			$prefix . '%' . $wpdb->esc_like( 'metaboxorder'    ) . '%',
1318
-			$prefix . '%' . $wpdb->esc_like( 'screen_layout'   ) . '%'
1319
-		) );
1311
+		$prefix = $wpdb->esc_like($wpdb->base_prefix);
1312
+		$wpdb->query($wpdb->prepare($sql,
1313
+			$prefix.'%'.$wpdb->esc_like('meta-box-hidden').'%',
1314
+			$prefix.'%'.$wpdb->esc_like('closedpostboxes').'%',
1315
+			$prefix.'%'.$wpdb->esc_like('manage-').'%'.$wpdb->esc_like('-columns-hidden').'%',
1316
+			$prefix.'%'.$wpdb->esc_like('meta-box-order').'%',
1317
+			$prefix.'%'.$wpdb->esc_like('metaboxorder').'%',
1318
+			$prefix.'%'.$wpdb->esc_like('screen_layout').'%'
1319
+		));
1320 1320
 	}
1321 1321
 
1322 1322
 }
@@ -1335,52 +1335,52 @@  discard block
 block discarded – undo
1335 1335
 function upgrade_330() {
1336 1336
 	global $wp_current_db_version, $wpdb, $wp_registered_widgets, $sidebars_widgets;
1337 1337
 
1338
-	if ( $wp_current_db_version < 19061 && wp_should_upgrade_global_tables() ) {
1339
-		$wpdb->query( "DELETE FROM $wpdb->usermeta WHERE meta_key IN ('show_admin_bar_admin', 'plugins_last_view')" );
1338
+	if ($wp_current_db_version < 19061 && wp_should_upgrade_global_tables()) {
1339
+		$wpdb->query("DELETE FROM $wpdb->usermeta WHERE meta_key IN ('show_admin_bar_admin', 'plugins_last_view')");
1340 1340
 	}
1341 1341
 
1342
-	if ( $wp_current_db_version >= 11548 )
1342
+	if ($wp_current_db_version >= 11548)
1343 1343
 		return;
1344 1344
 
1345
-	$sidebars_widgets = get_option( 'sidebars_widgets', array() );
1345
+	$sidebars_widgets = get_option('sidebars_widgets', array());
1346 1346
 	$_sidebars_widgets = array();
1347 1347
 
1348
-	if ( isset($sidebars_widgets['wp_inactive_widgets']) || empty($sidebars_widgets) )
1348
+	if (isset($sidebars_widgets['wp_inactive_widgets']) || empty($sidebars_widgets))
1349 1349
 		$sidebars_widgets['array_version'] = 3;
1350
-	elseif ( !isset($sidebars_widgets['array_version']) )
1350
+	elseif ( ! isset($sidebars_widgets['array_version']))
1351 1351
 		$sidebars_widgets['array_version'] = 1;
1352 1352
 
1353
-	switch ( $sidebars_widgets['array_version'] ) {
1353
+	switch ($sidebars_widgets['array_version']) {
1354 1354
 		case 1 :
1355
-			foreach ( (array) $sidebars_widgets as $index => $sidebar )
1356
-			if ( is_array($sidebar) )
1357
-			foreach ( (array) $sidebar as $i => $name ) {
1355
+			foreach ((array) $sidebars_widgets as $index => $sidebar)
1356
+			if (is_array($sidebar))
1357
+			foreach ((array) $sidebar as $i => $name) {
1358 1358
 				$id = strtolower($name);
1359
-				if ( isset($wp_registered_widgets[$id]) ) {
1359
+				if (isset($wp_registered_widgets[$id])) {
1360 1360
 					$_sidebars_widgets[$index][$i] = $id;
1361 1361
 					continue;
1362 1362
 				}
1363 1363
 				$id = sanitize_title($name);
1364
-				if ( isset($wp_registered_widgets[$id]) ) {
1364
+				if (isset($wp_registered_widgets[$id])) {
1365 1365
 					$_sidebars_widgets[$index][$i] = $id;
1366 1366
 					continue;
1367 1367
 				}
1368 1368
 
1369 1369
 				$found = false;
1370 1370
 
1371
-				foreach ( $wp_registered_widgets as $widget_id => $widget ) {
1372
-					if ( strtolower($widget['name']) == strtolower($name) ) {
1371
+				foreach ($wp_registered_widgets as $widget_id => $widget) {
1372
+					if (strtolower($widget['name']) == strtolower($name)) {
1373 1373
 						$_sidebars_widgets[$index][$i] = $widget['id'];
1374 1374
 						$found = true;
1375 1375
 						break;
1376
-					} elseif ( sanitize_title($widget['name']) == sanitize_title($name) ) {
1376
+					} elseif (sanitize_title($widget['name']) == sanitize_title($name)) {
1377 1377
 						$_sidebars_widgets[$index][$i] = $widget['id'];
1378 1378
 						$found = true;
1379 1379
 						break;
1380 1380
 					}
1381 1381
 				}
1382 1382
 
1383
-				if ( $found )
1383
+				if ($found)
1384 1384
 					continue;
1385 1385
 
1386 1386
 				unset($_sidebars_widgets[$index][$i]);
@@ -1392,7 +1392,7 @@  discard block
 block discarded – undo
1392 1392
 		case 2 :
1393 1393
 			$sidebars_widgets = retrieve_widgets();
1394 1394
 			$sidebars_widgets['array_version'] = 3;
1395
-			update_option( 'sidebars_widgets', $sidebars_widgets );
1395
+			update_option('sidebars_widgets', $sidebars_widgets);
1396 1396
 	}
1397 1397
 }
1398 1398
 
@@ -1408,27 +1408,27 @@  discard block
 block discarded – undo
1408 1408
 function upgrade_340() {
1409 1409
 	global $wp_current_db_version, $wpdb;
1410 1410
 
1411
-	if ( $wp_current_db_version < 19798 ) {
1411
+	if ($wp_current_db_version < 19798) {
1412 1412
 		$wpdb->hide_errors();
1413
-		$wpdb->query( "ALTER TABLE $wpdb->options DROP COLUMN blog_id" );
1413
+		$wpdb->query("ALTER TABLE $wpdb->options DROP COLUMN blog_id");
1414 1414
 		$wpdb->show_errors();
1415 1415
 	}
1416 1416
 
1417
-	if ( $wp_current_db_version < 19799 ) {
1417
+	if ($wp_current_db_version < 19799) {
1418 1418
 		$wpdb->hide_errors();
1419 1419
 		$wpdb->query("ALTER TABLE $wpdb->comments DROP INDEX comment_approved");
1420 1420
 		$wpdb->show_errors();
1421 1421
 	}
1422 1422
 
1423
-	if ( $wp_current_db_version < 20022 && wp_should_upgrade_global_tables() ) {
1424
-		$wpdb->query( "DELETE FROM $wpdb->usermeta WHERE meta_key = 'themes_last_view'" );
1423
+	if ($wp_current_db_version < 20022 && wp_should_upgrade_global_tables()) {
1424
+		$wpdb->query("DELETE FROM $wpdb->usermeta WHERE meta_key = 'themes_last_view'");
1425 1425
 	}
1426 1426
 
1427
-	if ( $wp_current_db_version < 20080 ) {
1428
-		if ( 'yes' == $wpdb->get_var( "SELECT autoload FROM $wpdb->options WHERE option_name = 'uninstall_plugins'" ) ) {
1429
-			$uninstall_plugins = get_option( 'uninstall_plugins' );
1430
-			delete_option( 'uninstall_plugins' );
1431
-			add_option( 'uninstall_plugins', $uninstall_plugins, null, 'no' );
1427
+	if ($wp_current_db_version < 20080) {
1428
+		if ('yes' == $wpdb->get_var("SELECT autoload FROM $wpdb->options WHERE option_name = 'uninstall_plugins'")) {
1429
+			$uninstall_plugins = get_option('uninstall_plugins');
1430
+			delete_option('uninstall_plugins');
1431
+			add_option('uninstall_plugins', $uninstall_plugins, null, 'no');
1432 1432
 		}
1433 1433
 	}
1434 1434
 }
@@ -1445,23 +1445,23 @@  discard block
 block discarded – undo
1445 1445
 function upgrade_350() {
1446 1446
 	global $wp_current_db_version, $wpdb;
1447 1447
 
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()
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()
1450 1450
 
1451
-	if ( $wp_current_db_version < 21811 && wp_should_upgrade_global_tables() ) {
1451
+	if ($wp_current_db_version < 21811 && wp_should_upgrade_global_tables()) {
1452 1452
 		$meta_keys = array();
1453
-		foreach ( array_merge( get_post_types(), get_taxonomies() ) as $name ) {
1454
-			if ( false !== strpos( $name, '-' ) )
1455
-			$meta_keys[] = 'edit_' . str_replace( '-', '_', $name ) . '_per_page';
1453
+		foreach (array_merge(get_post_types(), get_taxonomies()) as $name) {
1454
+			if (false !== strpos($name, '-'))
1455
+			$meta_keys[] = 'edit_'.str_replace('-', '_', $name).'_per_page';
1456 1456
 		}
1457
-		if ( $meta_keys ) {
1458
-			$meta_keys = implode( "', '", $meta_keys );
1459
-			$wpdb->query( "DELETE FROM $wpdb->usermeta WHERE meta_key IN ('$meta_keys')" );
1457
+		if ($meta_keys) {
1458
+			$meta_keys = implode("', '", $meta_keys);
1459
+			$wpdb->query("DELETE FROM $wpdb->usermeta WHERE meta_key IN ('$meta_keys')");
1460 1460
 		}
1461 1461
 	}
1462 1462
 
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' );
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 1465
 }
1466 1466
 
1467 1467
 /**
@@ -1474,8 +1474,8 @@  discard block
 block discarded – undo
1474 1474
  */
1475 1475
 function upgrade_370() {
1476 1476
 	global $wp_current_db_version;
1477
-	if ( $wp_current_db_version < 25824 )
1478
-		wp_clear_scheduled_hook( 'wp_auto_updates_maybe_update' );
1477
+	if ($wp_current_db_version < 25824)
1478
+		wp_clear_scheduled_hook('wp_auto_updates_maybe_update');
1479 1479
 }
1480 1480
 
1481 1481
 /**
@@ -1489,8 +1489,8 @@  discard block
 block discarded – undo
1489 1489
  */
1490 1490
 function upgrade_372() {
1491 1491
 	global $wp_current_db_version;
1492
-	if ( $wp_current_db_version < 26148 )
1493
-		wp_clear_scheduled_hook( 'wp_maybe_auto_update' );
1492
+	if ($wp_current_db_version < 26148)
1493
+		wp_clear_scheduled_hook('wp_maybe_auto_update');
1494 1494
 }
1495 1495
 
1496 1496
 /**
@@ -1503,8 +1503,8 @@  discard block
 block discarded – undo
1503 1503
  */
1504 1504
 function upgrade_380() {
1505 1505
 	global $wp_current_db_version;
1506
-	if ( $wp_current_db_version < 26691 ) {
1507
-		deactivate_plugins( array( 'mp6/mp6.php' ), true );
1506
+	if ($wp_current_db_version < 26691) {
1507
+		deactivate_plugins(array('mp6/mp6.php'), true);
1508 1508
 	}
1509 1509
 }
1510 1510
 
@@ -1518,12 +1518,12 @@  discard block
 block discarded – undo
1518 1518
  */
1519 1519
 function upgrade_400() {
1520 1520
 	global $wp_current_db_version;
1521
-	if ( $wp_current_db_version < 29630 ) {
1522
-		if ( ! is_multisite() && false === get_option( 'WPLANG' ) ) {
1523
-			if ( defined( 'WPLANG' ) && ( '' !== WPLANG ) && in_array( WPLANG, get_available_languages() ) ) {
1524
-				update_option( 'WPLANG', WPLANG );
1521
+	if ($wp_current_db_version < 29630) {
1522
+		if ( ! is_multisite() && false === get_option('WPLANG')) {
1523
+			if (defined('WPLANG') && ('' !== WPLANG) && in_array(WPLANG, get_available_languages())) {
1524
+				update_option('WPLANG', WPLANG);
1525 1525
 			} else {
1526
-				update_option( 'WPLANG', '' );
1526
+				update_option('WPLANG', '');
1527 1527
 			}
1528 1528
 		}
1529 1529
 	}
@@ -1552,29 +1552,29 @@  discard block
 block discarded – undo
1552 1552
 function upgrade_430() {
1553 1553
 	global $wp_current_db_version, $wpdb;
1554 1554
 
1555
-	if ( $wp_current_db_version < 32364 ) {
1555
+	if ($wp_current_db_version < 32364) {
1556 1556
 		upgrade_430_fix_comments();
1557 1557
 	}
1558 1558
 
1559 1559
 	// Shared terms are split in a separate process.
1560
-	if ( $wp_current_db_version < 32814 ) {
1561
-		update_option( 'finished_splitting_shared_terms', 0 );
1562
-		wp_schedule_single_event( time() + ( 1 * MINUTE_IN_SECONDS ), 'wp_split_shared_term_batch' );
1560
+	if ($wp_current_db_version < 32814) {
1561
+		update_option('finished_splitting_shared_terms', 0);
1562
+		wp_schedule_single_event(time() + (1 * MINUTE_IN_SECONDS), 'wp_split_shared_term_batch');
1563 1563
 	}
1564 1564
 
1565
-	if ( $wp_current_db_version < 33055 && 'utf8mb4' === $wpdb->charset ) {
1566
-		if ( is_multisite() ) {
1567
-			$tables = $wpdb->tables( 'blog' );
1565
+	if ($wp_current_db_version < 33055 && 'utf8mb4' === $wpdb->charset) {
1566
+		if (is_multisite()) {
1567
+			$tables = $wpdb->tables('blog');
1568 1568
 		} else {
1569
-			$tables = $wpdb->tables( 'all' );
1570
-			if ( ! wp_should_upgrade_global_tables() ) {
1571
-				$global_tables = $wpdb->tables( 'global' );
1572
-				$tables = array_diff_assoc( $tables, $global_tables );
1569
+			$tables = $wpdb->tables('all');
1570
+			if ( ! wp_should_upgrade_global_tables()) {
1571
+				$global_tables = $wpdb->tables('global');
1572
+				$tables = array_diff_assoc($tables, $global_tables);
1573 1573
 			}
1574 1574
 		}
1575 1575
 
1576
-		foreach ( $tables as $table ) {
1577
-			maybe_convert_table_to_utf8mb4( $table );
1576
+		foreach ($tables as $table) {
1577
+			maybe_convert_table_to_utf8mb4($table);
1578 1578
 		}
1579 1579
 	}
1580 1580
 }
@@ -1591,18 +1591,18 @@  discard block
 block discarded – undo
1591 1591
 function upgrade_430_fix_comments() {
1592 1592
 	global $wp_current_db_version, $wpdb;
1593 1593
 
1594
-	$content_length = $wpdb->get_col_length( $wpdb->comments, 'comment_content' );
1594
+	$content_length = $wpdb->get_col_length($wpdb->comments, 'comment_content');
1595 1595
 
1596
-	if ( is_wp_error( $content_length ) ) {
1596
+	if (is_wp_error($content_length)) {
1597 1597
 		return;
1598 1598
 	}
1599 1599
 
1600
-	if ( false === $content_length ) {
1600
+	if (false === $content_length) {
1601 1601
 		$content_length = array(
1602 1602
 			'type'   => 'byte',
1603 1603
 			'length' => 65535,
1604 1604
 		);
1605
-	} elseif ( ! is_array( $content_length ) ) {
1605
+	} elseif ( ! is_array($content_length)) {
1606 1606
 		$length = (int) $content_length > 0 ? (int) $content_length : 65535;
1607 1607
 		$content_length = array(
1608 1608
 			'type'	 => 'byte',
@@ -1610,12 +1610,12 @@  discard block
 block discarded – undo
1610 1610
 		);
1611 1611
 	}
1612 1612
 
1613
-	if ( 'byte' !== $content_length['type'] || 0 === $content_length['length'] ) {
1613
+	if ('byte' !== $content_length['type'] || 0 === $content_length['length']) {
1614 1614
 		// Sites with malformed DB schemas are on their own.
1615 1615
 		return;
1616 1616
 	}
1617 1617
 
1618
-	$allowed_length = intval( $content_length['length'] ) - 10;
1618
+	$allowed_length = intval($content_length['length']) - 10;
1619 1619
 
1620 1620
 	$comments = $wpdb->get_results(
1621 1621
 		"SELECT `comment_ID` FROM `{$wpdb->comments}`
@@ -1624,8 +1624,8 @@  discard block
 block discarded – undo
1624 1624
 			AND ( `comment_content` LIKE '%<%' OR `comment_content` LIKE '%>%' )"
1625 1625
 	);
1626 1626
 
1627
-	foreach ( $comments as $comment ) {
1628
-		wp_delete_comment( $comment->comment_ID, true );
1627
+	foreach ($comments as $comment) {
1628
+		wp_delete_comment($comment->comment_ID, true);
1629 1629
 	}
1630 1630
 }
1631 1631
 
@@ -1638,9 +1638,9 @@  discard block
 block discarded – undo
1638 1638
 function upgrade_431() {
1639 1639
 	// Fix incorrect cron entries for term splitting
1640 1640
 	$cron_array = _get_cron_array();
1641
-	if ( isset( $cron_array['wp_batch_split_terms'] ) ) {
1642
-		unset( $cron_array['wp_batch_split_terms'] );
1643
-		_set_cron_array( $cron_array );
1641
+	if (isset($cron_array['wp_batch_split_terms'])) {
1642
+		unset($cron_array['wp_batch_split_terms']);
1643
+		_set_cron_array($cron_array);
1644 1644
 	}
1645 1645
 }
1646 1646
 
@@ -1656,15 +1656,15 @@  discard block
 block discarded – undo
1656 1656
 function upgrade_440() {
1657 1657
 	global $wp_current_db_version, $wpdb;
1658 1658
 
1659
-	if ( $wp_current_db_version < 34030 ) {
1660
-		$wpdb->query( "ALTER TABLE {$wpdb->options} MODIFY option_name VARCHAR(191)" );
1659
+	if ($wp_current_db_version < 34030) {
1660
+		$wpdb->query("ALTER TABLE {$wpdb->options} MODIFY option_name VARCHAR(191)");
1661 1661
 	}
1662 1662
 
1663 1663
 	// Remove the unused 'add_users' role.
1664 1664
 	$roles = wp_roles();
1665
-	foreach ( $roles->role_objects as $role ) {
1666
-		if ( $role->has_cap( 'add_users' ) ) {
1667
-			$role->remove_cap( 'add_users' );
1665
+	foreach ($roles->role_objects as $role) {
1666
+		if ($role->has_cap('add_users')) {
1667
+			$role->remove_cap('add_users');
1668 1668
 		}
1669 1669
 	}
1670 1670
 }
@@ -1681,17 +1681,17 @@  discard block
 block discarded – undo
1681 1681
 function upgrade_450() {
1682 1682
 	global $wp_current_db_version, $wpdb;
1683 1683
 
1684
-	if ( $wp_current_db_version < 36180 ) {
1685
-		wp_clear_scheduled_hook( 'wp_maybe_auto_update' );
1684
+	if ($wp_current_db_version < 36180) {
1685
+		wp_clear_scheduled_hook('wp_maybe_auto_update');
1686 1686
 	}
1687 1687
 
1688 1688
 	// Remove unused email confirmation options, moved to usermeta.
1689
-	if ( $wp_current_db_version < 36679 && is_multisite() ) {
1690
-		$wpdb->query( "DELETE FROM $wpdb->options WHERE option_name REGEXP '^[0-9]+_new_email$'" );
1689
+	if ($wp_current_db_version < 36679 && is_multisite()) {
1690
+		$wpdb->query("DELETE FROM $wpdb->options WHERE option_name REGEXP '^[0-9]+_new_email$'");
1691 1691
 	}
1692 1692
 
1693 1693
 	// Remove unused user setting for wpLink.
1694
-	delete_user_setting( 'wplink' );
1694
+	delete_user_setting('wplink');
1695 1695
 }
1696 1696
 
1697 1697
 /**
@@ -1706,22 +1706,22 @@  discard block
 block discarded – undo
1706 1706
 	global $wp_current_db_version;
1707 1707
 
1708 1708
 	// Remove unused post meta.
1709
-	if ( $wp_current_db_version < 37854 ) {
1710
-		delete_post_meta_by_key( '_post_restored_from' );
1709
+	if ($wp_current_db_version < 37854) {
1710
+		delete_post_meta_by_key('_post_restored_from');
1711 1711
 	}
1712 1712
 
1713 1713
 	// Remove plugins with callback as an array object/method as the uninstall hook, see #13786.
1714
-	if ( $wp_current_db_version < 37965 ) {
1715
-		$uninstall_plugins = get_option( 'uninstall_plugins', array() );
1714
+	if ($wp_current_db_version < 37965) {
1715
+		$uninstall_plugins = get_option('uninstall_plugins', array());
1716 1716
 
1717
-		if ( ! empty( $uninstall_plugins ) ) {
1718
-			foreach ( $uninstall_plugins as $basename => $callback ) {
1719
-				if ( is_array( $callback ) && is_object( $callback[0] ) ) {
1720
-					unset( $uninstall_plugins[ $basename ] );
1717
+		if ( ! empty($uninstall_plugins)) {
1718
+			foreach ($uninstall_plugins as $basename => $callback) {
1719
+				if (is_array($callback) && is_object($callback[0])) {
1720
+					unset($uninstall_plugins[$basename]);
1721 1721
 				}
1722 1722
 			}
1723 1723
 
1724
-			update_option( 'uninstall_plugins', $uninstall_plugins );
1724
+			update_option('uninstall_plugins', $uninstall_plugins);
1725 1725
 		}
1726 1726
 	}
1727 1727
 }
@@ -1738,7 +1738,7 @@  discard block
 block discarded – undo
1738 1738
 	global $wp_current_db_version, $wpdb;
1739 1739
 
1740 1740
 	// Always.
1741
-	if ( is_main_network() ) {
1741
+	if (is_main_network()) {
1742 1742
 		/*
1743 1743
 		 * Deletes all expired transients. The multi-table delete syntax is used
1744 1744
 		 * to delete the transient record from table a, and the corresponding
@@ -1750,32 +1750,32 @@  discard block
 block discarded – undo
1750 1750
 			AND a.meta_key NOT LIKE %s
1751 1751
 			AND b.meta_key = CONCAT( '_site_transient_timeout_', SUBSTRING( a.meta_key, 17 ) )
1752 1752
 			AND b.meta_value < %d";
1753
-		$wpdb->query( $wpdb->prepare( $sql, $wpdb->esc_like( '_site_transient_' ) . '%', $wpdb->esc_like ( '_site_transient_timeout_' ) . '%', $time ) );
1753
+		$wpdb->query($wpdb->prepare($sql, $wpdb->esc_like('_site_transient_').'%', $wpdb->esc_like('_site_transient_timeout_').'%', $time));
1754 1754
 	}
1755 1755
 
1756 1756
 	// 2.8.
1757
-	if ( $wp_current_db_version < 11549 ) {
1758
-		$wpmu_sitewide_plugins = get_site_option( 'wpmu_sitewide_plugins' );
1759
-		$active_sitewide_plugins = get_site_option( 'active_sitewide_plugins' );
1760
-		if ( $wpmu_sitewide_plugins ) {
1761
-			if ( !$active_sitewide_plugins )
1757
+	if ($wp_current_db_version < 11549) {
1758
+		$wpmu_sitewide_plugins = get_site_option('wpmu_sitewide_plugins');
1759
+		$active_sitewide_plugins = get_site_option('active_sitewide_plugins');
1760
+		if ($wpmu_sitewide_plugins) {
1761
+			if ( ! $active_sitewide_plugins)
1762 1762
 				$sitewide_plugins = (array) $wpmu_sitewide_plugins;
1763 1763
 			else
1764
-				$sitewide_plugins = array_merge( (array) $active_sitewide_plugins, (array) $wpmu_sitewide_plugins );
1764
+				$sitewide_plugins = array_merge((array) $active_sitewide_plugins, (array) $wpmu_sitewide_plugins);
1765 1765
 
1766
-			update_site_option( 'active_sitewide_plugins', $sitewide_plugins );
1766
+			update_site_option('active_sitewide_plugins', $sitewide_plugins);
1767 1767
 		}
1768
-		delete_site_option( 'wpmu_sitewide_plugins' );
1769
-		delete_site_option( 'deactivated_sitewide_plugins' );
1768
+		delete_site_option('wpmu_sitewide_plugins');
1769
+		delete_site_option('deactivated_sitewide_plugins');
1770 1770
 
1771 1771
 		$start = 0;
1772
-		while( $rows = $wpdb->get_results( "SELECT meta_key, meta_value FROM {$wpdb->sitemeta} ORDER BY meta_id LIMIT $start, 20" ) ) {
1773
-			foreach ( $rows as $row ) {
1772
+		while ($rows = $wpdb->get_results("SELECT meta_key, meta_value FROM {$wpdb->sitemeta} ORDER BY meta_id LIMIT $start, 20")) {
1773
+			foreach ($rows as $row) {
1774 1774
 				$value = $row->meta_value;
1775
-				if ( !@unserialize( $value ) )
1776
-					$value = stripslashes( $value );
1777
-				if ( $value !== $row->meta_value ) {
1778
-					update_site_option( $row->meta_key, $value );
1775
+				if ( ! @unserialize($value))
1776
+					$value = stripslashes($value);
1777
+				if ($value !== $row->meta_value) {
1778
+					update_site_option($row->meta_key, $value);
1779 1779
 				}
1780 1780
 			}
1781 1781
 			$start += 20;
@@ -1783,95 +1783,95 @@  discard block
 block discarded – undo
1783 1783
 	}
1784 1784
 
1785 1785
 	// 3.0
1786
-	if ( $wp_current_db_version < 13576 )
1787
-		update_site_option( 'global_terms_enabled', '1' );
1786
+	if ($wp_current_db_version < 13576)
1787
+		update_site_option('global_terms_enabled', '1');
1788 1788
 
1789 1789
 	// 3.3
1790
-	if ( $wp_current_db_version < 19390 )
1791
-		update_site_option( 'initial_db_version', $wp_current_db_version );
1790
+	if ($wp_current_db_version < 19390)
1791
+		update_site_option('initial_db_version', $wp_current_db_version);
1792 1792
 
1793
-	if ( $wp_current_db_version < 19470 ) {
1794
-		if ( false === get_site_option( 'active_sitewide_plugins' ) )
1795
-			update_site_option( 'active_sitewide_plugins', array() );
1793
+	if ($wp_current_db_version < 19470) {
1794
+		if (false === get_site_option('active_sitewide_plugins'))
1795
+			update_site_option('active_sitewide_plugins', array());
1796 1796
 	}
1797 1797
 
1798 1798
 	// 3.4
1799
-	if ( $wp_current_db_version < 20148 ) {
1799
+	if ($wp_current_db_version < 20148) {
1800 1800
 		// 'allowedthemes' keys things by stylesheet. 'allowed_themes' keyed things by name.
1801
-		$allowedthemes  = get_site_option( 'allowedthemes'  );
1802
-		$allowed_themes = get_site_option( 'allowed_themes' );
1803
-		if ( false === $allowedthemes && is_array( $allowed_themes ) && $allowed_themes ) {
1801
+		$allowedthemes  = get_site_option('allowedthemes');
1802
+		$allowed_themes = get_site_option('allowed_themes');
1803
+		if (false === $allowedthemes && is_array($allowed_themes) && $allowed_themes) {
1804 1804
 			$converted = array();
1805 1805
 			$themes = wp_get_themes();
1806
-			foreach ( $themes as $stylesheet => $theme_data ) {
1807
-				if ( isset( $allowed_themes[ $theme_data->get('Name') ] ) )
1808
-					$converted[ $stylesheet ] = true;
1806
+			foreach ($themes as $stylesheet => $theme_data) {
1807
+				if (isset($allowed_themes[$theme_data->get('Name')]))
1808
+					$converted[$stylesheet] = true;
1809 1809
 			}
1810
-			update_site_option( 'allowedthemes', $converted );
1811
-			delete_site_option( 'allowed_themes' );
1810
+			update_site_option('allowedthemes', $converted);
1811
+			delete_site_option('allowed_themes');
1812 1812
 		}
1813 1813
 	}
1814 1814
 
1815 1815
 	// 3.5
1816
-	if ( $wp_current_db_version < 21823 )
1817
-		update_site_option( 'ms_files_rewriting', '1' );
1816
+	if ($wp_current_db_version < 21823)
1817
+		update_site_option('ms_files_rewriting', '1');
1818 1818
 
1819 1819
 	// 3.5.2
1820
-	if ( $wp_current_db_version < 24448 ) {
1821
-		$illegal_names = get_site_option( 'illegal_names' );
1822
-		if ( is_array( $illegal_names ) && count( $illegal_names ) === 1 ) {
1823
-			$illegal_name = reset( $illegal_names );
1824
-			$illegal_names = explode( ' ', $illegal_name );
1825
-			update_site_option( 'illegal_names', $illegal_names );
1820
+	if ($wp_current_db_version < 24448) {
1821
+		$illegal_names = get_site_option('illegal_names');
1822
+		if (is_array($illegal_names) && count($illegal_names) === 1) {
1823
+			$illegal_name = reset($illegal_names);
1824
+			$illegal_names = explode(' ', $illegal_name);
1825
+			update_site_option('illegal_names', $illegal_names);
1826 1826
 		}
1827 1827
 	}
1828 1828
 
1829 1829
 	// 4.2
1830
-	if ( $wp_current_db_version < 31351 && $wpdb->charset === 'utf8mb4' ) {
1831
-		if ( wp_should_upgrade_global_tables() ) {
1832
-			$wpdb->query( "ALTER TABLE $wpdb->usermeta DROP INDEX meta_key, ADD INDEX meta_key(meta_key(191))" );
1833
-			$wpdb->query( "ALTER TABLE $wpdb->site DROP INDEX domain, ADD INDEX domain(domain(140),path(51))" );
1834
-			$wpdb->query( "ALTER TABLE $wpdb->sitemeta DROP INDEX meta_key, ADD INDEX meta_key(meta_key(191))" );
1835
-			$wpdb->query( "ALTER TABLE $wpdb->signups DROP INDEX domain_path, ADD INDEX domain_path(domain(140),path(51))" );
1830
+	if ($wp_current_db_version < 31351 && $wpdb->charset === 'utf8mb4') {
1831
+		if (wp_should_upgrade_global_tables()) {
1832
+			$wpdb->query("ALTER TABLE $wpdb->usermeta DROP INDEX meta_key, ADD INDEX meta_key(meta_key(191))");
1833
+			$wpdb->query("ALTER TABLE $wpdb->site DROP INDEX domain, ADD INDEX domain(domain(140),path(51))");
1834
+			$wpdb->query("ALTER TABLE $wpdb->sitemeta DROP INDEX meta_key, ADD INDEX meta_key(meta_key(191))");
1835
+			$wpdb->query("ALTER TABLE $wpdb->signups DROP INDEX domain_path, ADD INDEX domain_path(domain(140),path(51))");
1836 1836
 
1837
-			$tables = $wpdb->tables( 'global' );
1837
+			$tables = $wpdb->tables('global');
1838 1838
 
1839 1839
 			// sitecategories may not exist.
1840
-			if ( ! $wpdb->get_var( "SHOW TABLES LIKE '{$tables['sitecategories']}'" ) ) {
1841
-				unset( $tables['sitecategories'] );
1840
+			if ( ! $wpdb->get_var("SHOW TABLES LIKE '{$tables['sitecategories']}'")) {
1841
+				unset($tables['sitecategories']);
1842 1842
 			}
1843 1843
 
1844
-			foreach ( $tables as $table ) {
1845
-				maybe_convert_table_to_utf8mb4( $table );
1844
+			foreach ($tables as $table) {
1845
+				maybe_convert_table_to_utf8mb4($table);
1846 1846
 			}
1847 1847
 		}
1848 1848
 	}
1849 1849
 
1850 1850
 	// 4.3
1851
-	if ( $wp_current_db_version < 33055 && 'utf8mb4' === $wpdb->charset ) {
1852
-		if ( wp_should_upgrade_global_tables() ) {
1851
+	if ($wp_current_db_version < 33055 && 'utf8mb4' === $wpdb->charset) {
1852
+		if (wp_should_upgrade_global_tables()) {
1853 1853
 			$upgrade = false;
1854
-			$indexes = $wpdb->get_results( "SHOW INDEXES FROM $wpdb->signups" );
1855
-			foreach ( $indexes as $index ) {
1856
-				if ( 'domain_path' == $index->Key_name && 'domain' == $index->Column_name && 140 != $index->Sub_part ) {
1854
+			$indexes = $wpdb->get_results("SHOW INDEXES FROM $wpdb->signups");
1855
+			foreach ($indexes as $index) {
1856
+				if ('domain_path' == $index->Key_name && 'domain' == $index->Column_name && 140 != $index->Sub_part) {
1857 1857
 					$upgrade = true;
1858 1858
 					break;
1859 1859
 				}
1860 1860
 			}
1861 1861
 
1862
-			if ( $upgrade ) {
1863
-				$wpdb->query( "ALTER TABLE $wpdb->signups DROP INDEX domain_path, ADD INDEX domain_path(domain(140),path(51))" );
1862
+			if ($upgrade) {
1863
+				$wpdb->query("ALTER TABLE $wpdb->signups DROP INDEX domain_path, ADD INDEX domain_path(domain(140),path(51))");
1864 1864
 			}
1865 1865
 
1866
-			$tables = $wpdb->tables( 'global' );
1866
+			$tables = $wpdb->tables('global');
1867 1867
 
1868 1868
 			// sitecategories may not exist.
1869
-			if ( ! $wpdb->get_var( "SHOW TABLES LIKE '{$tables['sitecategories']}'" ) ) {
1870
-				unset( $tables['sitecategories'] );
1869
+			if ( ! $wpdb->get_var("SHOW TABLES LIKE '{$tables['sitecategories']}'")) {
1870
+				unset($tables['sitecategories']);
1871 1871
 			}
1872 1872
 
1873
-			foreach ( $tables as $table ) {
1874
-				maybe_convert_table_to_utf8mb4( $table );
1873
+			foreach ($tables as $table) {
1874
+				maybe_convert_table_to_utf8mb4($table);
1875 1875
 			}
1876 1876
 		}
1877 1877
 	}
@@ -1899,9 +1899,9 @@  discard block
 block discarded – undo
1899 1899
 function maybe_create_table($table_name, $create_ddl) {
1900 1900
 	global $wpdb;
1901 1901
 
1902
-	$query = $wpdb->prepare( "SHOW TABLES LIKE %s", $wpdb->esc_like( $table_name ) );
1902
+	$query = $wpdb->prepare("SHOW TABLES LIKE %s", $wpdb->esc_like($table_name));
1903 1903
 
1904
-	if ( $wpdb->get_var( $query ) == $table_name ) {
1904
+	if ($wpdb->get_var($query) == $table_name) {
1905 1905
 		return true;
1906 1906
 	}
1907 1907
 
@@ -1909,7 +1909,7 @@  discard block
 block discarded – undo
1909 1909
 	$wpdb->query($create_ddl);
1910 1910
 
1911 1911
 	// We cannot directly tell that whether this succeeded!
1912
-	if ( $wpdb->get_var( $query ) == $table_name ) {
1912
+	if ($wpdb->get_var($query) == $table_name) {
1913 1913
 		return true;
1914 1914
 	}
1915 1915
 	return false;
@@ -1970,7 +1970,7 @@  discard block
 block discarded – undo
1970 1970
  */
1971 1971
 function maybe_add_column($table_name, $column_name, $create_ddl) {
1972 1972
 	global $wpdb;
1973
-	foreach ($wpdb->get_col("DESC $table_name", 0) as $column ) {
1973
+	foreach ($wpdb->get_col("DESC $table_name", 0) as $column) {
1974 1974
 		if ($column == $column_name) {
1975 1975
 			return true;
1976 1976
 		}
@@ -1980,7 +1980,7 @@  discard block
 block discarded – undo
1980 1980
 	$wpdb->query($create_ddl);
1981 1981
 
1982 1982
 	// We cannot directly tell that whether this succeeded!
1983
-	foreach ($wpdb->get_col("DESC $table_name", 0) as $column ) {
1983
+	foreach ($wpdb->get_col("DESC $table_name", 0) as $column) {
1984 1984
 		if ($column == $column_name) {
1985 1985
 			return true;
1986 1986
 		}
@@ -1998,37 +1998,37 @@  discard block
 block discarded – undo
1998 1998
  * @param string $table The table to convert.
1999 1999
  * @return bool true if the table was converted, false if it wasn't.
2000 2000
  */
2001
-function maybe_convert_table_to_utf8mb4( $table ) {
2001
+function maybe_convert_table_to_utf8mb4($table) {
2002 2002
 	global $wpdb;
2003 2003
 
2004
-	$results = $wpdb->get_results( "SHOW FULL COLUMNS FROM `$table`" );
2005
-	if ( ! $results ) {
2004
+	$results = $wpdb->get_results("SHOW FULL COLUMNS FROM `$table`");
2005
+	if ( ! $results) {
2006 2006
 		return false;
2007 2007
 	}
2008 2008
 
2009
-	foreach ( $results as $column ) {
2010
-		if ( $column->Collation ) {
2011
-			list( $charset ) = explode( '_', $column->Collation );
2012
-			$charset = strtolower( $charset );
2013
-			if ( 'utf8' !== $charset && 'utf8mb4' !== $charset ) {
2009
+	foreach ($results as $column) {
2010
+		if ($column->Collation) {
2011
+			list($charset) = explode('_', $column->Collation);
2012
+			$charset = strtolower($charset);
2013
+			if ('utf8' !== $charset && 'utf8mb4' !== $charset) {
2014 2014
 				// Don't upgrade tables that have non-utf8 columns.
2015 2015
 				return false;
2016 2016
 			}
2017 2017
 		}
2018 2018
 	}
2019 2019
 
2020
-	$table_details = $wpdb->get_row( "SHOW TABLE STATUS LIKE '$table'" );
2021
-	if ( ! $table_details ) {
2020
+	$table_details = $wpdb->get_row("SHOW TABLE STATUS LIKE '$table'");
2021
+	if ( ! $table_details) {
2022 2022
 		return false;
2023 2023
 	}
2024 2024
 
2025
-	list( $table_charset ) = explode( '_', $table_details->Collation );
2026
-	$table_charset = strtolower( $table_charset );
2027
-	if ( 'utf8mb4' === $table_charset ) {
2025
+	list($table_charset) = explode('_', $table_details->Collation);
2026
+	$table_charset = strtolower($table_charset);
2027
+	if ('utf8mb4' === $table_charset) {
2028 2028
 		return true;
2029 2029
 	}
2030 2030
 
2031
-	return $wpdb->query( "ALTER TABLE $table CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci" );
2031
+	return $wpdb->query("ALTER TABLE $table CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci");
2032 2032
 }
2033 2033
 
2034 2034
 /**
@@ -2043,11 +2043,11 @@  discard block
 block discarded – undo
2043 2043
 function get_alloptions_110() {
2044 2044
 	global $wpdb;
2045 2045
 	$all_options = new stdClass;
2046
-	if ( $options = $wpdb->get_results( "SELECT option_name, option_value FROM $wpdb->options" ) ) {
2047
-		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 );
2050
-			$all_options->{$option->option_name} = stripslashes( $option->option_value );
2046
+	if ($options = $wpdb->get_results("SELECT option_name, option_value FROM $wpdb->options")) {
2047
+		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);
2050
+			$all_options->{$option->option_name} = stripslashes($option->option_value);
2051 2051
 		}
2052 2052
 	}
2053 2053
 	return $all_options;
@@ -2068,21 +2068,21 @@  discard block
 block discarded – undo
2068 2068
 function __get_option($setting) {
2069 2069
 	global $wpdb;
2070 2070
 
2071
-	if ( $setting == 'home' && defined( 'WP_HOME' ) )
2072
-		return untrailingslashit( WP_HOME );
2071
+	if ($setting == 'home' && defined('WP_HOME'))
2072
+		return untrailingslashit(WP_HOME);
2073 2073
 
2074
-	if ( $setting == 'siteurl' && defined( 'WP_SITEURL' ) )
2075
-		return untrailingslashit( WP_SITEURL );
2074
+	if ($setting == 'siteurl' && defined('WP_SITEURL'))
2075
+		return untrailingslashit(WP_SITEURL);
2076 2076
 
2077
-	$option = $wpdb->get_var( $wpdb->prepare("SELECT option_value FROM $wpdb->options WHERE option_name = %s", $setting ) );
2077
+	$option = $wpdb->get_var($wpdb->prepare("SELECT option_value FROM $wpdb->options WHERE option_name = %s", $setting));
2078 2078
 
2079
-	if ( 'home' == $setting && '' == $option )
2080
-		return __get_option( 'siteurl' );
2079
+	if ('home' == $setting && '' == $option)
2080
+		return __get_option('siteurl');
2081 2081
 
2082
-	if ( 'siteurl' == $setting || 'home' == $setting || 'category_base' == $setting || 'tag_base' == $setting )
2083
-		$option = untrailingslashit( $option );
2082
+	if ('siteurl' == $setting || 'home' == $setting || 'category_base' == $setting || 'tag_base' == $setting)
2083
+		$option = untrailingslashit($option);
2084 2084
 
2085
-	return maybe_unserialize( $option );
2085
+	return maybe_unserialize($option);
2086 2086
 }
2087 2087
 
2088 2088
 /**
@@ -2130,16 +2130,16 @@  discard block
 block discarded – undo
2130 2130
  *                              Default true.
2131 2131
  * @return array Strings containing the results of the various update queries.
2132 2132
  */
2133
-function dbDelta( $queries = '', $execute = true ) {
2133
+function dbDelta($queries = '', $execute = true) {
2134 2134
 	global $wpdb;
2135 2135
 
2136
-	if ( in_array( $queries, array( '', 'all', 'blog', 'global', 'ms_global' ), true ) )
2137
-	    $queries = wp_get_db_schema( $queries );
2136
+	if (in_array($queries, array('', 'all', 'blog', 'global', 'ms_global'), true))
2137
+	    $queries = wp_get_db_schema($queries);
2138 2138
 
2139 2139
 	// Separate individual queries into an array
2140
-	if ( !is_array($queries) ) {
2141
-		$queries = explode( ';', $queries );
2142
-		$queries = array_filter( $queries );
2140
+	if ( ! is_array($queries)) {
2141
+		$queries = explode(';', $queries);
2142
+		$queries = array_filter($queries);
2143 2143
 	}
2144 2144
 
2145 2145
 	/**
@@ -2149,7 +2149,7 @@  discard block
 block discarded – undo
2149 2149
 	 *
2150 2150
 	 * @param array $queries An array of dbDelta SQL queries.
2151 2151
 	 */
2152
-	$queries = apply_filters( 'dbdelta_queries', $queries );
2152
+	$queries = apply_filters('dbdelta_queries', $queries);
2153 2153
 
2154 2154
 	$cqueries = array(); // Creation Queries
2155 2155
 	$iqueries = array(); // Insertion Queries
@@ -2157,14 +2157,14 @@  discard block
 block discarded – undo
2157 2157
 
2158 2158
 	// Create a tablename index for an array ($cqueries) of queries
2159 2159
 	foreach ($queries as $qry) {
2160
-		if ( preg_match( "|CREATE TABLE ([^ ]*)|", $qry, $matches ) ) {
2161
-			$cqueries[ trim( $matches[1], '`' ) ] = $qry;
2160
+		if (preg_match("|CREATE TABLE ([^ ]*)|", $qry, $matches)) {
2161
+			$cqueries[trim($matches[1], '`')] = $qry;
2162 2162
 			$for_update[$matches[1]] = 'Created table '.$matches[1];
2163
-		} elseif ( preg_match( "|CREATE DATABASE ([^ ]*)|", $qry, $matches ) ) {
2164
-			array_unshift( $cqueries, $qry );
2165
-		} elseif ( preg_match( "|INSERT INTO ([^ ]*)|", $qry, $matches ) ) {
2163
+		} elseif (preg_match("|CREATE DATABASE ([^ ]*)|", $qry, $matches)) {
2164
+			array_unshift($cqueries, $qry);
2165
+		} elseif (preg_match("|INSERT INTO ([^ ]*)|", $qry, $matches)) {
2166 2166
 			$iqueries[] = $qry;
2167
-		} elseif ( preg_match( "|UPDATE ([^ ]*)|", $qry, $matches ) ) {
2167
+		} elseif (preg_match("|UPDATE ([^ ]*)|", $qry, $matches)) {
2168 2168
 			$iqueries[] = $qry;
2169 2169
 		} else {
2170 2170
 			// Unrecognized query type
@@ -2180,7 +2180,7 @@  discard block
 block discarded – undo
2180 2180
 	 *
2181 2181
 	 * @param array $cqueries An array of dbDelta create SQL queries.
2182 2182
 	 */
2183
-	$cqueries = apply_filters( 'dbdelta_create_queries', $cqueries );
2183
+	$cqueries = apply_filters('dbdelta_create_queries', $cqueries);
2184 2184
 
2185 2185
 	/**
2186 2186
 	 * Filters the dbDelta SQL queries for inserting or updating.
@@ -2191,25 +2191,25 @@  discard block
 block discarded – undo
2191 2191
 	 *
2192 2192
 	 * @param array $iqueries An array of dbDelta insert or update SQL queries.
2193 2193
 	 */
2194
-	$iqueries = apply_filters( 'dbdelta_insert_queries', $iqueries );
2194
+	$iqueries = apply_filters('dbdelta_insert_queries', $iqueries);
2195 2195
 
2196
-	$text_fields = array( 'tinytext', 'text', 'mediumtext', 'longtext' );
2197
-	$blob_fields = array( 'tinyblob', 'blob', 'mediumblob', 'longblob' );
2196
+	$text_fields = array('tinytext', 'text', 'mediumtext', 'longtext');
2197
+	$blob_fields = array('tinyblob', 'blob', 'mediumblob', 'longblob');
2198 2198
 
2199
-	$global_tables = $wpdb->tables( 'global' );
2200
-	foreach ( $cqueries as $table => $qry ) {
2199
+	$global_tables = $wpdb->tables('global');
2200
+	foreach ($cqueries as $table => $qry) {
2201 2201
 		// Upgrade global tables only for the main site. Don't upgrade at all if conditions are not optimal.
2202
-		if ( in_array( $table, $global_tables ) && ! wp_should_upgrade_global_tables() ) {
2203
-			unset( $cqueries[ $table ], $for_update[ $table ] );
2202
+		if (in_array($table, $global_tables) && ! wp_should_upgrade_global_tables()) {
2203
+			unset($cqueries[$table], $for_update[$table]);
2204 2204
 			continue;
2205 2205
 		}
2206 2206
 
2207 2207
 		// Fetch the table column structure from the database
2208 2208
 		$suppress = $wpdb->suppress_errors();
2209 2209
 		$tablefields = $wpdb->get_results("DESCRIBE {$table};");
2210
-		$wpdb->suppress_errors( $suppress );
2210
+		$wpdb->suppress_errors($suppress);
2211 2211
 
2212
-		if ( ! $tablefields )
2212
+		if ( ! $tablefields)
2213 2213
 			continue;
2214 2214
 
2215 2215
 		// Clear the field and index arrays.
@@ -2223,17 +2223,17 @@  discard block
 block discarded – undo
2223 2223
 		$flds = explode("\n", $qryline);
2224 2224
 
2225 2225
 		// For every field line specified in the query.
2226
-		foreach ( $flds as $fld ) {
2227
-			$fld = trim( $fld, " \t\n\r\0\x0B," ); // Default trim characters, plus ','.
2226
+		foreach ($flds as $fld) {
2227
+			$fld = trim($fld, " \t\n\r\0\x0B,"); // Default trim characters, plus ','.
2228 2228
 
2229 2229
 			// Extract the field name.
2230
-			preg_match( '|^([^ ]*)|', $fld, $fvals );
2231
-			$fieldname = trim( $fvals[1], '`' );
2232
-			$fieldname_lowercased = strtolower( $fieldname );
2230
+			preg_match('|^([^ ]*)|', $fld, $fvals);
2231
+			$fieldname = trim($fvals[1], '`');
2232
+			$fieldname_lowercased = strtolower($fieldname);
2233 2233
 
2234 2234
 			// Verify the found field name.
2235 2235
 			$validfield = true;
2236
-			switch ( $fieldname_lowercased ) {
2236
+			switch ($fieldname_lowercased) {
2237 2237
 				case '':
2238 2238
 				case 'primary':
2239 2239
 				case 'index':
@@ -2277,19 +2277,19 @@  discard block
 block discarded – undo
2277 2277
 					);
2278 2278
 
2279 2279
 					// Uppercase the index type and normalize space characters.
2280
-					$index_type = strtoupper( preg_replace( '/\s+/', ' ', trim( $index_matches['index_type'] ) ) );
2280
+					$index_type = strtoupper(preg_replace('/\s+/', ' ', trim($index_matches['index_type'])));
2281 2281
 
2282 2282
 					// 'INDEX' is a synonym for 'KEY', standardize on 'KEY'.
2283
-					$index_type = str_replace( 'INDEX', 'KEY', $index_type );
2283
+					$index_type = str_replace('INDEX', 'KEY', $index_type);
2284 2284
 
2285 2285
 					// Escape the index name with backticks. An index for a primary key has no name.
2286
-					$index_name = ( 'PRIMARY KEY' === $index_type ) ? '' : '`' . $index_matches['index_name'] . '`';
2286
+					$index_name = ('PRIMARY KEY' === $index_type) ? '' : '`'.$index_matches['index_name'].'`';
2287 2287
 
2288 2288
 					// Parse the columns. Multiple columns are separated by a comma.
2289
-					$index_columns = array_map( 'trim', explode( ',', $index_matches['index_columns'] ) );
2289
+					$index_columns = array_map('trim', explode(',', $index_matches['index_columns']));
2290 2290
 
2291 2291
 					// Normalize columns.
2292
-					foreach ( $index_columns as &$index_column ) {
2292
+					foreach ($index_columns as &$index_column) {
2293 2293
 						// Extract column name and number of indexed characters (sub_part).
2294 2294
 						preg_match(
2295 2295
 							  '/'
@@ -2314,66 +2314,66 @@  discard block
 block discarded – undo
2314 2314
 						);
2315 2315
 
2316 2316
 						// Escape the column name with backticks.
2317
-						$index_column = '`' . $index_column_matches['column_name'] . '`';
2317
+						$index_column = '`'.$index_column_matches['column_name'].'`';
2318 2318
 
2319 2319
 						// Append the optional sup part with the number of indexed characters.
2320
-						if ( isset( $index_column_matches['sub_part'] ) ) {
2321
-							$index_column .= '(' . $index_column_matches['sub_part'] . ')';
2320
+						if (isset($index_column_matches['sub_part'])) {
2321
+							$index_column .= '('.$index_column_matches['sub_part'].')';
2322 2322
 						}
2323 2323
 					}
2324 2324
 
2325 2325
 					// Build the normalized index definition and add it to the list of indices.
2326
-					$indices[] = "{$index_type} {$index_name} (" . implode( ',', $index_columns ) . ")";
2326
+					$indices[] = "{$index_type} {$index_name} (".implode(',', $index_columns).")";
2327 2327
 
2328 2328
 					// Destroy no longer needed variables.
2329
-					unset( $index_column, $index_column_matches, $index_matches, $index_type, $index_name, $index_columns );
2329
+					unset($index_column, $index_column_matches, $index_matches, $index_type, $index_name, $index_columns);
2330 2330
 
2331 2331
 					break;
2332 2332
 			}
2333 2333
 
2334 2334
 			// If it's a valid field, add it to the field array.
2335
-			if ( $validfield ) {
2336
-				$cfields[ $fieldname_lowercased ] = $fld;
2335
+			if ($validfield) {
2336
+				$cfields[$fieldname_lowercased] = $fld;
2337 2337
 			}
2338 2338
 		}
2339 2339
 
2340 2340
 		// For every field in the table.
2341
-		foreach ( $tablefields as $tablefield ) {
2342
-			$tablefield_field_lowercased = strtolower( $tablefield->Field );
2343
-			$tablefield_type_lowercased = strtolower( $tablefield->Type );
2341
+		foreach ($tablefields as $tablefield) {
2342
+			$tablefield_field_lowercased = strtolower($tablefield->Field);
2343
+			$tablefield_type_lowercased = strtolower($tablefield->Type);
2344 2344
 
2345 2345
 			// If the table field exists in the field array ...
2346
-			if ( array_key_exists( $tablefield_field_lowercased, $cfields ) ) {
2346
+			if (array_key_exists($tablefield_field_lowercased, $cfields)) {
2347 2347
 
2348 2348
 				// Get the field type from the query.
2349
-				preg_match( '|`?' . $tablefield->Field . '`? ([^ ]*( unsigned)?)|i', $cfields[ $tablefield_field_lowercased ], $matches );
2349
+				preg_match('|`?'.$tablefield->Field.'`? ([^ ]*( unsigned)?)|i', $cfields[$tablefield_field_lowercased], $matches);
2350 2350
 				$fieldtype = $matches[1];
2351
-				$fieldtype_lowercased = strtolower( $fieldtype );
2351
+				$fieldtype_lowercased = strtolower($fieldtype);
2352 2352
 
2353 2353
 				// Is actual field type different from the field type in query?
2354 2354
 				if ($tablefield->Type != $fieldtype) {
2355 2355
 					$do_change = true;
2356
-					if ( in_array( $fieldtype_lowercased, $text_fields ) && in_array( $tablefield_type_lowercased, $text_fields ) ) {
2357
-						if ( array_search( $fieldtype_lowercased, $text_fields ) < array_search( $tablefield_type_lowercased, $text_fields ) ) {
2356
+					if (in_array($fieldtype_lowercased, $text_fields) && in_array($tablefield_type_lowercased, $text_fields)) {
2357
+						if (array_search($fieldtype_lowercased, $text_fields) < array_search($tablefield_type_lowercased, $text_fields)) {
2358 2358
 							$do_change = false;
2359 2359
 						}
2360 2360
 					}
2361 2361
 
2362
-					if ( in_array( $fieldtype_lowercased, $blob_fields ) && in_array( $tablefield_type_lowercased, $blob_fields ) ) {
2363
-						if ( array_search( $fieldtype_lowercased, $blob_fields ) < array_search( $tablefield_type_lowercased, $blob_fields ) ) {
2362
+					if (in_array($fieldtype_lowercased, $blob_fields) && in_array($tablefield_type_lowercased, $blob_fields)) {
2363
+						if (array_search($fieldtype_lowercased, $blob_fields) < array_search($tablefield_type_lowercased, $blob_fields)) {
2364 2364
 							$do_change = false;
2365 2365
 						}
2366 2366
 					}
2367 2367
 
2368
-					if ( $do_change ) {
2368
+					if ($do_change) {
2369 2369
 						// Add a query to change the column type.
2370
-						$cqueries[] = "ALTER TABLE {$table} CHANGE COLUMN `{$tablefield->Field}` " . $cfields[ $tablefield_field_lowercased ];
2370
+						$cqueries[] = "ALTER TABLE {$table} CHANGE COLUMN `{$tablefield->Field}` ".$cfields[$tablefield_field_lowercased];
2371 2371
 						$for_update[$table.'.'.$tablefield->Field] = "Changed type of {$table}.{$tablefield->Field} from {$tablefield->Type} to {$fieldtype}";
2372 2372
 					}
2373 2373
 				}
2374 2374
 
2375 2375
 				// Get the default value from the array.
2376
-				if ( preg_match( "| DEFAULT '(.*?)'|i", $cfields[ $tablefield_field_lowercased ], $matches ) ) {
2376
+				if (preg_match("| DEFAULT '(.*?)'|i", $cfields[$tablefield_field_lowercased], $matches)) {
2377 2377
 					$default_value = $matches[1];
2378 2378
 					if ($tablefield->Default != $default_value) {
2379 2379
 						// Add a query to change the column's default value
@@ -2383,7 +2383,7 @@  discard block
 block discarded – undo
2383 2383
 				}
2384 2384
 
2385 2385
 				// Remove the field from the array (so it's not added).
2386
-				unset( $cfields[ $tablefield_field_lowercased ] );
2386
+				unset($cfields[$tablefield_field_lowercased]);
2387 2387
 			} else {
2388 2388
 				// This field exists in the table, but not in the creation queries?
2389 2389
 			}
@@ -2409,7 +2409,7 @@  discard block
 block discarded – undo
2409 2409
 				// Add the index to the index data array.
2410 2410
 				$keyname = $tableindex->Key_name;
2411 2411
 				$index_ary[$keyname]['columns'][] = array('fieldname' => $tableindex->Column_name, 'subpart' => $tableindex->Sub_part);
2412
-				$index_ary[$keyname]['unique'] = ($tableindex->Non_unique == 0)?true:false;
2412
+				$index_ary[$keyname]['unique'] = ($tableindex->Non_unique == 0) ? true : false;
2413 2413
 				$index_ary[$keyname]['index_type'] = $tableindex->Index_type;
2414 2414
 			}
2415 2415
 
@@ -2420,36 +2420,36 @@  discard block
 block discarded – undo
2420 2420
 				$index_string = '';
2421 2421
 				if ($index_name == 'PRIMARY') {
2422 2422
 					$index_string .= 'PRIMARY ';
2423
-				} elseif ( $index_data['unique'] ) {
2423
+				} elseif ($index_data['unique']) {
2424 2424
 					$index_string .= 'UNIQUE ';
2425 2425
 				}
2426
-				if ( 'FULLTEXT' === strtoupper( $index_data['index_type'] ) ) {
2426
+				if ('FULLTEXT' === strtoupper($index_data['index_type'])) {
2427 2427
 					$index_string .= 'FULLTEXT ';
2428 2428
 				}
2429
-				if ( 'SPATIAL' === strtoupper( $index_data['index_type'] ) ) {
2429
+				if ('SPATIAL' === strtoupper($index_data['index_type'])) {
2430 2430
 					$index_string .= 'SPATIAL ';
2431 2431
 				}
2432 2432
 				$index_string .= 'KEY ';
2433
-				if ( 'PRIMARY' !== $index_name  ) {
2434
-					$index_string .= '`' . $index_name . '`';
2433
+				if ('PRIMARY' !== $index_name) {
2434
+					$index_string .= '`'.$index_name.'`';
2435 2435
 				}
2436 2436
 				$index_columns = '';
2437 2437
 
2438 2438
 				// For each column in the index.
2439 2439
 				foreach ($index_data['columns'] as $column_data) {
2440
-					if ( $index_columns != '' ) {
2440
+					if ($index_columns != '') {
2441 2441
 						$index_columns .= ',';
2442 2442
 					}
2443 2443
 
2444 2444
 					// Add the field to the column list string.
2445
-					$index_columns .= '`' . $column_data['fieldname'] . '`';
2445
+					$index_columns .= '`'.$column_data['fieldname'].'`';
2446 2446
 					if ($column_data['subpart'] != '') {
2447 2447
 						$index_columns .= '('.$column_data['subpart'].')';
2448 2448
 					}
2449 2449
 				}
2450 2450
 
2451 2451
 				// The alternative index string doesn't care about subparts
2452
-				$alt_index_columns = preg_replace( '/\([^)]*\)/', '', $index_columns );
2452
+				$alt_index_columns = preg_replace('/\([^)]*\)/', '', $index_columns);
2453 2453
 
2454 2454
 				// Add the column list to the index create string.
2455 2455
 				$index_strings = array(
@@ -2457,9 +2457,9 @@  discard block
 block discarded – undo
2457 2457
 					"$index_string ($alt_index_columns)",
2458 2458
 				);
2459 2459
 
2460
-				foreach ( $index_strings as $index_string ) {
2461
-					if ( ! ( ( $aindex = array_search( $index_string, $indices ) ) === false ) ) {
2462
-						unset( $indices[ $aindex ] );
2460
+				foreach ($index_strings as $index_string) {
2461
+					if ( ! (($aindex = array_search($index_string, $indices)) === false)) {
2462
+						unset($indices[$aindex]);
2463 2463
 						break;
2464 2464
 					}
2465 2465
 				}
@@ -2467,14 +2467,14 @@  discard block
 block discarded – undo
2467 2467
 		}
2468 2468
 
2469 2469
 		// For every remaining index specified for the table.
2470
-		foreach ( (array) $indices as $index ) {
2470
+		foreach ((array) $indices as $index) {
2471 2471
 			// Push a query line into $cqueries that adds the index to that table.
2472 2472
 			$cqueries[] = "ALTER TABLE {$table} ADD $index";
2473
-			$for_update[] = 'Added index ' . $table . ' ' . $index;
2473
+			$for_update[] = 'Added index '.$table.' '.$index;
2474 2474
 		}
2475 2475
 
2476 2476
 		// Remove the original table creation query from processing.
2477
-		unset( $cqueries[ $table ], $for_update[ $table ] );
2477
+		unset($cqueries[$table], $for_update[$table]);
2478 2478
 	}
2479 2479
 
2480 2480
 	$allqueries = array_merge($cqueries, $iqueries);
@@ -2499,8 +2499,8 @@  discard block
 block discarded – undo
2499 2499
  *
2500 2500
  * @param string $tables Optional. Which set of tables to update. Default is 'all'.
2501 2501
  */
2502
-function make_db_current( $tables = 'all' ) {
2503
-	$alterations = dbDelta( $tables );
2502
+function make_db_current($tables = 'all') {
2503
+	$alterations = dbDelta($tables);
2504 2504
 	echo "<ol>\n";
2505 2505
 	foreach ($alterations as $alteration) echo "<li>$alteration</li>\n";
2506 2506
 	echo "</ol>\n";
@@ -2518,8 +2518,8 @@  discard block
 block discarded – undo
2518 2518
  *
2519 2519
  * @param string $tables Optional. Which set of tables to update. Default is 'all'.
2520 2520
  */
2521
-function make_db_current_silent( $tables = 'all' ) {
2522
-	dbDelta( $tables );
2521
+function make_db_current_silent($tables = 'all') {
2522
+	dbDelta($tables);
2523 2523
 }
2524 2524
 
2525 2525
 /**
@@ -2535,9 +2535,9 @@  discard block
 block discarded – undo
2535 2535
  */
2536 2536
 function make_site_theme_from_oldschool($theme_name, $template) {
2537 2537
 	$home_path = get_home_path();
2538
-	$site_dir = WP_CONTENT_DIR . "/themes/$template";
2538
+	$site_dir = WP_CONTENT_DIR."/themes/$template";
2539 2539
 
2540
-	if (! file_exists("$home_path/index.php"))
2540
+	if ( ! file_exists("$home_path/index.php"))
2541 2541
 		return false;
2542 2542
 
2543 2543
 	/*
@@ -2556,7 +2556,7 @@  discard block
 block discarded – undo
2556 2556
 		if ($oldfile == 'index.php') {
2557 2557
 			$index = implode('', file("$oldpath/$oldfile"));
2558 2558
 			if (strpos($index, 'WP_USE_THEMES') !== false) {
2559
-				if (! @copy(WP_CONTENT_DIR . '/themes/' . WP_DEFAULT_THEME . '/index.php', "$site_dir/$newfile"))
2559
+				if ( ! @copy(WP_CONTENT_DIR.'/themes/'.WP_DEFAULT_THEME.'/index.php', "$site_dir/$newfile"))
2560 2560
 					return false;
2561 2561
 
2562 2562
 				// Don't copy anything.
@@ -2564,7 +2564,7 @@  discard block
 block discarded – undo
2564 2564
 			}
2565 2565
 		}
2566 2566
 
2567
-		if (! @copy("$oldpath/$oldfile", "$site_dir/$newfile"))
2567
+		if ( ! @copy("$oldpath/$oldfile", "$site_dir/$newfile"))
2568 2568
 			return false;
2569 2569
 
2570 2570
 		chmod("$site_dir/$newfile", 0777);
@@ -2576,7 +2576,7 @@  discard block
 block discarded – undo
2576 2576
 
2577 2577
 			foreach ($lines as $line) {
2578 2578
 				if (preg_match('/require.*wp-blog-header/', $line))
2579
-					$line = '//' . $line;
2579
+					$line = '//'.$line;
2580 2580
 
2581 2581
 				// Update stylesheet references.
2582 2582
 				$line = str_replace("<?php echo __get_option('siteurl'); ?>/wp-layout.css", "<?php bloginfo('stylesheet_url'); ?>", $line);
@@ -2591,7 +2591,7 @@  discard block
 block discarded – undo
2591 2591
 	}
2592 2592
 
2593 2593
 	// Add a theme header.
2594
-	$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";
2594
+	$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";
2595 2595
 
2596 2596
 	$stylelines = file_get_contents("$site_dir/style.css");
2597 2597
 	if ($stylelines) {
@@ -2617,18 +2617,18 @@  discard block
 block discarded – undo
2617 2617
  * @return false|void
2618 2618
  */
2619 2619
 function make_site_theme_from_default($theme_name, $template) {
2620
-	$site_dir = WP_CONTENT_DIR . "/themes/$template";
2621
-	$default_dir = WP_CONTENT_DIR . '/themes/' . WP_DEFAULT_THEME;
2620
+	$site_dir = WP_CONTENT_DIR."/themes/$template";
2621
+	$default_dir = WP_CONTENT_DIR.'/themes/'.WP_DEFAULT_THEME;
2622 2622
 
2623 2623
 	// Copy files from the default theme to the site theme.
2624 2624
 	//$files = array('index.php', 'comments.php', 'comments-popup.php', 'footer.php', 'header.php', 'sidebar.php', 'style.css');
2625 2625
 
2626 2626
 	$theme_dir = @ opendir($default_dir);
2627 2627
 	if ($theme_dir) {
2628
-		while(($theme_file = readdir( $theme_dir )) !== false) {
2628
+		while (($theme_file = readdir($theme_dir)) !== false) {
2629 2629
 			if (is_dir("$default_dir/$theme_file"))
2630 2630
 				continue;
2631
-			if (! @copy("$default_dir/$theme_file", "$site_dir/$theme_file"))
2631
+			if ( ! @copy("$default_dir/$theme_file", "$site_dir/$theme_file"))
2632 2632
 				return;
2633 2633
 			chmod("$site_dir/$theme_file", 0777);
2634 2634
 		}
@@ -2641,28 +2641,28 @@  discard block
 block discarded – undo
2641 2641
 		$f = fopen("$site_dir/style.css", 'w');
2642 2642
 
2643 2643
 		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');
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 2646
 			elseif (strpos($line, 'Description:') !== false) $line = 'Description: Your theme.';
2647 2647
 			elseif (strpos($line, 'Version:') !== false) $line = 'Version: 1';
2648 2648
 			elseif (strpos($line, 'Author:') !== false) $line = 'Author: You';
2649
-			fwrite($f, $line . "\n");
2649
+			fwrite($f, $line."\n");
2650 2650
 		}
2651 2651
 		fclose($f);
2652 2652
 	}
2653 2653
 
2654 2654
 	// Copy the images.
2655 2655
 	umask(0);
2656
-	if (! mkdir("$site_dir/images", 0777)) {
2656
+	if ( ! mkdir("$site_dir/images", 0777)) {
2657 2657
 		return false;
2658 2658
 	}
2659 2659
 
2660 2660
 	$images_dir = @ opendir("$default_dir/images");
2661 2661
 	if ($images_dir) {
2662
-		while(($image = readdir($images_dir)) !== false) {
2662
+		while (($image = readdir($images_dir)) !== false) {
2663 2663
 			if (is_dir("$default_dir/images/$image"))
2664 2664
 				continue;
2665
-			if (! @copy("$default_dir/images/$image", "$site_dir/images/$image"))
2665
+			if ( ! @copy("$default_dir/images/$image", "$site_dir/images/$image"))
2666 2666
 				return;
2667 2667
 			chmod("$site_dir/images/$image", 0777);
2668 2668
 		}
@@ -2683,30 +2683,30 @@  discard block
 block discarded – undo
2683 2683
 	// Name the theme after the blog.
2684 2684
 	$theme_name = __get_option('blogname');
2685 2685
 	$template = sanitize_title($theme_name);
2686
-	$site_dir = WP_CONTENT_DIR . "/themes/$template";
2686
+	$site_dir = WP_CONTENT_DIR."/themes/$template";
2687 2687
 
2688 2688
 	// If the theme already exists, nothing to do.
2689
-	if ( is_dir($site_dir)) {
2689
+	if (is_dir($site_dir)) {
2690 2690
 		return false;
2691 2691
 	}
2692 2692
 
2693 2693
 	// We must be able to write to the themes dir.
2694
-	if (! is_writable(WP_CONTENT_DIR . "/themes")) {
2694
+	if ( ! is_writable(WP_CONTENT_DIR."/themes")) {
2695 2695
 		return false;
2696 2696
 	}
2697 2697
 
2698 2698
 	umask(0);
2699
-	if (! mkdir($site_dir, 0777)) {
2699
+	if ( ! mkdir($site_dir, 0777)) {
2700 2700
 		return false;
2701 2701
 	}
2702 2702
 
2703
-	if (file_exists(ABSPATH . 'wp-layout.css')) {
2704
-		if (! make_site_theme_from_oldschool($theme_name, $template)) {
2703
+	if (file_exists(ABSPATH.'wp-layout.css')) {
2704
+		if ( ! make_site_theme_from_oldschool($theme_name, $template)) {
2705 2705
 			// TODO: rm -rf the site theme directory.
2706 2706
 			return false;
2707 2707
 		}
2708 2708
 	} else {
2709
-		if (! make_site_theme_from_default($theme_name, $template))
2709
+		if ( ! make_site_theme_from_default($theme_name, $template))
2710 2710
 			// TODO: rm -rf the site theme directory.
2711 2711
 			return false;
2712 2712
 	}
@@ -2759,8 +2759,8 @@  discard block
 block discarded – undo
2759 2759
 function wp_check_mysql_version() {
2760 2760
 	global $wpdb;
2761 2761
 	$result = $wpdb->check_database_version();
2762
-	if ( is_wp_error( $result ) )
2763
-		die( $result->get_error_message() );
2762
+	if (is_wp_error($result))
2763
+		die($result->get_error_message());
2764 2764
 }
2765 2765
 
2766 2766
 /**
@@ -2769,12 +2769,12 @@  discard block
 block discarded – undo
2769 2769
  * @since 2.2.0
2770 2770
  */
2771 2771
 function maybe_disable_automattic_widgets() {
2772
-	$plugins = __get_option( 'active_plugins' );
2772
+	$plugins = __get_option('active_plugins');
2773 2773
 
2774
-	foreach ( (array) $plugins as $plugin ) {
2775
-		if ( basename( $plugin ) == 'widgets.php' ) {
2776
-			array_splice( $plugins, array_search( $plugin, $plugins ), 1 );
2777
-			update_option( 'active_plugins', $plugins );
2774
+	foreach ((array) $plugins as $plugin) {
2775
+		if (basename($plugin) == 'widgets.php') {
2776
+			array_splice($plugins, array_search($plugin, $plugins), 1);
2777
+			update_option('active_plugins', $plugins);
2778 2778
 			break;
2779 2779
 		}
2780 2780
 	}
@@ -2791,8 +2791,8 @@  discard block
 block discarded – undo
2791 2791
 function maybe_disable_link_manager() {
2792 2792
 	global $wp_current_db_version, $wpdb;
2793 2793
 
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 );
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 2796
 }
2797 2797
 
2798 2798
 /**
@@ -2807,7 +2807,7 @@  discard block
 block discarded – undo
2807 2807
 	global $wp_current_db_version, $wpdb;
2808 2808
 
2809 2809
 	// Upgrade versions prior to 2.9
2810
-	if ( $wp_current_db_version < 11557 ) {
2810
+	if ($wp_current_db_version < 11557) {
2811 2811
 		// Delete duplicate options. Keep the option with the highest option_id.
2812 2812
 		$wpdb->query("DELETE o1 FROM $wpdb->options AS o1 JOIN $wpdb->options AS o2 USING (`option_name`) WHERE o2.option_id > o1.option_id");
2813 2813
 
@@ -2819,40 +2819,40 @@  discard block
 block discarded – undo
2819 2819
 	}
2820 2820
 
2821 2821
 	// Multisite schema upgrades.
2822
-	if ( $wp_current_db_version < 25448 && is_multisite() && wp_should_upgrade_global_tables() ) {
2822
+	if ($wp_current_db_version < 25448 && is_multisite() && wp_should_upgrade_global_tables()) {
2823 2823
 
2824 2824
 		// Upgrade verions prior to 3.7
2825
-		if ( $wp_current_db_version < 25179 ) {
2825
+		if ($wp_current_db_version < 25179) {
2826 2826
 			// New primary key for signups.
2827
-			$wpdb->query( "ALTER TABLE $wpdb->signups ADD signup_id BIGINT(20) NOT NULL AUTO_INCREMENT PRIMARY KEY FIRST" );
2828
-			$wpdb->query( "ALTER TABLE $wpdb->signups DROP INDEX domain" );
2827
+			$wpdb->query("ALTER TABLE $wpdb->signups ADD signup_id BIGINT(20) NOT NULL AUTO_INCREMENT PRIMARY KEY FIRST");
2828
+			$wpdb->query("ALTER TABLE $wpdb->signups DROP INDEX domain");
2829 2829
 		}
2830 2830
 
2831
-		if ( $wp_current_db_version < 25448 ) {
2831
+		if ($wp_current_db_version < 25448) {
2832 2832
 			// Convert archived from enum to tinyint.
2833
-			$wpdb->query( "ALTER TABLE $wpdb->blogs CHANGE COLUMN archived archived varchar(1) NOT NULL default '0'" );
2834
-			$wpdb->query( "ALTER TABLE $wpdb->blogs CHANGE COLUMN archived archived tinyint(2) NOT NULL default 0" );
2833
+			$wpdb->query("ALTER TABLE $wpdb->blogs CHANGE COLUMN archived archived varchar(1) NOT NULL default '0'");
2834
+			$wpdb->query("ALTER TABLE $wpdb->blogs CHANGE COLUMN archived archived tinyint(2) NOT NULL default 0");
2835 2835
 		}
2836 2836
 	}
2837 2837
 
2838 2838
 	// Upgrade versions prior to 4.2.
2839
-	if ( $wp_current_db_version < 31351 ) {
2840
-		if ( ! is_multisite() && wp_should_upgrade_global_tables() ) {
2841
-			$wpdb->query( "ALTER TABLE $wpdb->usermeta DROP INDEX meta_key, ADD INDEX meta_key(meta_key(191))" );
2839
+	if ($wp_current_db_version < 31351) {
2840
+		if ( ! is_multisite() && wp_should_upgrade_global_tables()) {
2841
+			$wpdb->query("ALTER TABLE $wpdb->usermeta DROP INDEX meta_key, ADD INDEX meta_key(meta_key(191))");
2842 2842
 		}
2843
-		$wpdb->query( "ALTER TABLE $wpdb->terms DROP INDEX slug, ADD INDEX slug(slug(191))" );
2844
-		$wpdb->query( "ALTER TABLE $wpdb->terms DROP INDEX name, ADD INDEX name(name(191))" );
2845
-		$wpdb->query( "ALTER TABLE $wpdb->commentmeta DROP INDEX meta_key, ADD INDEX meta_key(meta_key(191))" );
2846
-		$wpdb->query( "ALTER TABLE $wpdb->postmeta DROP INDEX meta_key, ADD INDEX meta_key(meta_key(191))" );
2847
-		$wpdb->query( "ALTER TABLE $wpdb->posts DROP INDEX post_name, ADD INDEX post_name(post_name(191))" );
2843
+		$wpdb->query("ALTER TABLE $wpdb->terms DROP INDEX slug, ADD INDEX slug(slug(191))");
2844
+		$wpdb->query("ALTER TABLE $wpdb->terms DROP INDEX name, ADD INDEX name(name(191))");
2845
+		$wpdb->query("ALTER TABLE $wpdb->commentmeta DROP INDEX meta_key, ADD INDEX meta_key(meta_key(191))");
2846
+		$wpdb->query("ALTER TABLE $wpdb->postmeta DROP INDEX meta_key, ADD INDEX meta_key(meta_key(191))");
2847
+		$wpdb->query("ALTER TABLE $wpdb->posts DROP INDEX post_name, ADD INDEX post_name(post_name(191))");
2848 2848
 	}
2849 2849
 
2850 2850
 	// Upgrade versions prior to 4.4.
2851
-	if ( $wp_current_db_version < 34978 ) {
2851
+	if ($wp_current_db_version < 34978) {
2852 2852
 		// If compatible termmeta table is found, use it, but enforce a proper index and update collation.
2853
-		if ( $wpdb->get_var( "SHOW TABLES LIKE '{$wpdb->termmeta}'" ) && $wpdb->get_results( "SHOW INDEX FROM {$wpdb->termmeta} WHERE Column_name = 'meta_key'" ) ) {
2854
-			$wpdb->query( "ALTER TABLE $wpdb->termmeta DROP INDEX meta_key, ADD INDEX meta_key(meta_key(191))" );
2855
-			maybe_convert_table_to_utf8mb4( $wpdb->termmeta );
2853
+		if ($wpdb->get_var("SHOW TABLES LIKE '{$wpdb->termmeta}'") && $wpdb->get_results("SHOW INDEX FROM {$wpdb->termmeta} WHERE Column_name = 'meta_key'")) {
2854
+			$wpdb->query("ALTER TABLE $wpdb->termmeta DROP INDEX meta_key, ADD INDEX meta_key(meta_key(191))");
2855
+			maybe_convert_table_to_utf8mb4($wpdb->termmeta);
2856 2856
 		}
2857 2857
 	}
2858 2858
 }
@@ -2865,7 +2865,7 @@  discard block
 block discarded – undo
2865 2865
  * @global wpdb   $wpdb
2866 2866
  * @global string $charset_collate
2867 2867
  */
2868
-if ( !function_exists( 'install_global_terms' ) ) :
2868
+if ( ! function_exists('install_global_terms')) :
2869 2869
 function install_global_terms() {
2870 2870
 	global $wpdb, $charset_collate;
2871 2871
 	$ms_queries = "
@@ -2880,7 +2880,7 @@  discard block
 block discarded – undo
2880 2880
 ) $charset_collate;
2881 2881
 ";
2882 2882
 // now create tables
2883
-	dbDelta( $ms_queries );
2883
+	dbDelta($ms_queries);
2884 2884
 }
2885 2885
 endif;
2886 2886
 
@@ -2905,7 +2905,7 @@  discard block
 block discarded – undo
2905 2905
 function wp_should_upgrade_global_tables() {
2906 2906
 
2907 2907
 	// Return false early if explicitly not upgrading
2908
-	if ( defined( 'DO_NOT_UPGRADE_GLOBAL_TABLES' ) ) {
2908
+	if (defined('DO_NOT_UPGRADE_GLOBAL_TABLES')) {
2909 2909
 		return false;
2910 2910
 	}
2911 2911
 
@@ -2913,12 +2913,12 @@  discard block
 block discarded – undo
2913 2913
 	$should_upgrade = true;
2914 2914
 
2915 2915
 	// Set to false if not on main network (does not matter if not multi-network)
2916
-	if ( ! is_main_network() ) {
2916
+	if ( ! is_main_network()) {
2917 2917
 		$should_upgrade = false;
2918 2918
 	}
2919 2919
 
2920 2920
 	// Set to false if not on main site of current network (does not matter if not multi-site)
2921
-	if ( ! is_main_site() ) {
2921
+	if ( ! is_main_site()) {
2922 2922
 		$should_upgrade = false;
2923 2923
 	}
2924 2924
 
@@ -2927,5 +2927,5 @@  discard block
 block discarded – undo
2927 2927
 	 *
2928 2928
 	 * @param bool $should_upgrade Whether to run the upgrade routines on global tables.
2929 2929
 	 */
2930
-	return apply_filters( 'wp_should_upgrade_global_tables', $should_upgrade );
2930
+	return apply_filters('wp_should_upgrade_global_tables', $should_upgrade);
2931 2931
 }
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.
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/category-template.php 3 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -686,7 +686,7 @@
 block discarded – undo
686 686
  * Default topic count scaling for tag links
687 687
  *
688 688
  * @param int $count number of posts with that tag
689
- * @return int scaled count
689
+ * @return double scaled count
690 690
  */
691 691
 function default_topic_count_scale( $count ) {
692 692
 	return round(log10($count + 1) * 100);
Please login to merge, or discard this patch.
Braces   +116 added lines, -83 removed lines patch added patch discarded remove patch
@@ -17,13 +17,15 @@  discard block
 block discarded – undo
17 17
  * @return string Link on success, empty string if category does not exist.
18 18
  */
19 19
 function get_category_link( $category ) {
20
-	if ( ! is_object( $category ) )
21
-		$category = (int) $category;
20
+	if ( ! is_object( $category ) ) {
21
+			$category = (int) $category;
22
+	}
22 23
 
23 24
 	$category = get_term_link( $category, 'category' );
24 25
 
25
-	if ( is_wp_error( $category ) )
26
-		return '';
26
+	if ( is_wp_error( $category ) ) {
27
+			return '';
28
+	}
27 29
 
28 30
 	return $category;
29 31
 }
@@ -43,23 +45,26 @@  discard block
 block discarded – undo
43 45
 function get_category_parents( $id, $link = false, $separator = '/', $nicename = false, $visited = array() ) {
44 46
 	$chain = '';
45 47
 	$parent = get_term( $id, 'category' );
46
-	if ( is_wp_error( $parent ) )
47
-		return $parent;
48
+	if ( is_wp_error( $parent ) ) {
49
+			return $parent;
50
+	}
48 51
 
49
-	if ( $nicename )
50
-		$name = $parent->slug;
51
-	else
52
-		$name = $parent->name;
52
+	if ( $nicename ) {
53
+			$name = $parent->slug;
54
+	} else {
55
+			$name = $parent->name;
56
+	}
53 57
 
54 58
 	if ( $parent->parent && ( $parent->parent != $parent->term_id ) && !in_array( $parent->parent, $visited ) ) {
55 59
 		$visited[] = $parent->parent;
56 60
 		$chain .= get_category_parents( $parent->parent, $link, $separator, $nicename, $visited );
57 61
 	}
58 62
 
59
-	if ( $link )
60
-		$chain .= '<a href="' . esc_url( get_category_link( $parent->term_id ) ) . '">'.$name.'</a>' . $separator;
61
-	else
62
-		$chain .= $name.$separator;
63
+	if ( $link ) {
64
+			$chain .= '<a href="' . esc_url( get_category_link( $parent->term_id ) ) . '">'.$name.'</a>' . $separator;
65
+	} else {
66
+			$chain .= $name.$separator;
67
+	}
63 68
 	return $chain;
64 69
 }
65 70
 
@@ -78,8 +83,9 @@  discard block
 block discarded – undo
78 83
  */
79 84
 function get_the_category( $id = false ) {
80 85
 	$categories = get_the_terms( $id, 'category' );
81
-	if ( ! $categories || is_wp_error( $categories ) )
82
-		$categories = array();
86
+	if ( ! $categories || is_wp_error( $categories ) ) {
87
+			$categories = array();
88
+	}
83 89
 
84 90
 	$categories = array_values( $categories );
85 91
 
@@ -130,13 +136,14 @@  discard block
 block discarded – undo
130 136
  * @return int
131 137
  */
132 138
 function _usort_terms_by_ID( $a, $b ) {
133
-	if ( $a->term_id > $b->term_id )
134
-		return 1;
135
-	elseif ( $a->term_id < $b->term_id )
136
-		return -1;
137
-	else
138
-		return 0;
139
-}
139
+	if ( $a->term_id > $b->term_id ) {
140
+			return 1;
141
+	} elseif ( $a->term_id < $b->term_id ) {
142
+			return -1;
143
+	} else {
144
+			return 0;
145
+	}
146
+	}
140 147
 
141 148
 /**
142 149
  * Retrieve category name based on category ID.
@@ -150,8 +157,9 @@  discard block
 block discarded – undo
150 157
 	$cat_ID = (int) $cat_ID;
151 158
 	$category = get_term( $cat_ID, 'category' );
152 159
 
153
-	if ( is_wp_error( $category ) )
154
-		return $category;
160
+	if ( is_wp_error( $category ) ) {
161
+			return $category;
162
+	}
155 163
 
156 164
 	return ( $category ) ? $category->name : '';
157 165
 }
@@ -200,14 +208,16 @@  discard block
 block discarded – undo
200 208
 			$thelist .= "\n\t<li>";
201 209
 			switch ( strtolower( $parents ) ) {
202 210
 				case 'multiple':
203
-					if ( $category->parent )
204
-						$thelist .= get_category_parents( $category->parent, true, $separator );
211
+					if ( $category->parent ) {
212
+											$thelist .= get_category_parents( $category->parent, true, $separator );
213
+					}
205 214
 					$thelist .= '<a href="' . esc_url( get_category_link( $category->term_id ) ) . '" ' . $rel . '>' . $category->name.'</a></li>';
206 215
 					break;
207 216
 				case 'single':
208 217
 					$thelist .= '<a href="' . esc_url( get_category_link( $category->term_id ) ) . '"  ' . $rel . '>';
209
-					if ( $category->parent )
210
-						$thelist .= get_category_parents( $category->parent, false, $separator );
218
+					if ( $category->parent ) {
219
+											$thelist .= get_category_parents( $category->parent, false, $separator );
220
+					}
211 221
 					$thelist .= $category->name.'</a></li>';
212 222
 					break;
213 223
 				case '':
@@ -219,18 +229,21 @@  discard block
 block discarded – undo
219 229
 	} else {
220 230
 		$i = 0;
221 231
 		foreach ( $categories as $category ) {
222
-			if ( 0 < $i )
223
-				$thelist .= $separator;
232
+			if ( 0 < $i ) {
233
+							$thelist .= $separator;
234
+			}
224 235
 			switch ( strtolower( $parents ) ) {
225 236
 				case 'multiple':
226
-					if ( $category->parent )
227
-						$thelist .= get_category_parents( $category->parent, true, $separator );
237
+					if ( $category->parent ) {
238
+											$thelist .= get_category_parents( $category->parent, true, $separator );
239
+					}
228 240
 					$thelist .= '<a href="' . esc_url( get_category_link( $category->term_id ) ) . '" ' . $rel . '>' . $category->name.'</a>';
229 241
 					break;
230 242
 				case 'single':
231 243
 					$thelist .= '<a href="' . esc_url( get_category_link( $category->term_id ) ) . '" ' . $rel . '>';
232
-					if ( $category->parent )
233
-						$thelist .= get_category_parents( $category->parent, false, $separator );
244
+					if ( $category->parent ) {
245
+											$thelist .= get_category_parents( $category->parent, false, $separator );
246
+					}
234 247
 					$thelist .= "$category->name</a>";
235 248
 					break;
236 249
 				case '':
@@ -273,8 +286,9 @@  discard block
 block discarded – undo
273 286
  * @return bool True if the current post is in any of the given categories.
274 287
  */
275 288
 function in_category( $category, $post = null ) {
276
-	if ( empty( $category ) )
277
-		return false;
289
+	if ( empty( $category ) ) {
290
+			return false;
291
+	}
278 292
 
279 293
 	return has_category( $category, $post );
280 294
 }
@@ -552,8 +566,9 @@  discard block
 block discarded – undo
552 566
 
553 567
 	$r = wp_parse_args( $args, $defaults );
554 568
 
555
-	if ( !isset( $r['pad_counts'] ) && $r['show_count'] && $r['hierarchical'] )
556
-		$r['pad_counts'] = true;
569
+	if ( !isset( $r['pad_counts'] ) && $r['show_count'] && $r['hierarchical'] ) {
570
+			$r['pad_counts'] = true;
571
+	}
557 572
 
558 573
 	// Descendants of exclusions should be excluded too.
559 574
 	if ( true == $r['hierarchical'] ) {
@@ -571,8 +586,9 @@  discard block
 block discarded – undo
571 586
 		$r['exclude'] = '';
572 587
 	}
573 588
 
574
-	if ( ! isset( $r['class'] ) )
575
-		$r['class'] = ( 'category' == $r['taxonomy'] ) ? 'categories' : $r['taxonomy'];
589
+	if ( ! isset( $r['class'] ) ) {
590
+			$r['class'] = ( 'category' == $r['taxonomy'] ) ? 'categories' : $r['taxonomy'];
591
+	}
576 592
 
577 593
 	if ( ! taxonomy_exists( $r['taxonomy'] ) ) {
578 594
 		return false;
@@ -646,8 +662,9 @@  discard block
 block discarded – undo
646 662
 		$output .= walk_category_tree( $categories, $depth, $r );
647 663
 	}
648 664
 
649
-	if ( $r['title_li'] && 'list' == $r['style'] )
650
-		$output .= '</ul></li>';
665
+	if ( $r['title_li'] && 'list' == $r['style'] ) {
666
+			$output .= '</ul></li>';
667
+	}
651 668
 
652 669
 	/**
653 670
 	 * Filter the HTML output of a taxonomy list.
@@ -711,16 +728,19 @@  discard block
 block discarded – undo
711 728
 
712 729
 	$tags = get_terms( $args['taxonomy'], array_merge( $args, array( 'orderby' => 'count', 'order' => 'DESC' ) ) ); // Always query top tags
713 730
 
714
-	if ( empty( $tags ) || is_wp_error( $tags ) )
715
-		return;
731
+	if ( empty( $tags ) || is_wp_error( $tags ) ) {
732
+			return;
733
+	}
716 734
 
717 735
 	foreach ( $tags as $key => $tag ) {
718
-		if ( 'edit' == $args['link'] )
719
-			$link = get_edit_term_link( $tag->term_id, $tag->taxonomy, $args['post_type'] );
720
-		else
721
-			$link = get_term_link( intval($tag->term_id), $tag->taxonomy );
722
-		if ( is_wp_error( $link ) )
723
-			return;
736
+		if ( 'edit' == $args['link'] ) {
737
+					$link = get_edit_term_link( $tag->term_id, $tag->taxonomy, $args['post_type'] );
738
+		} else {
739
+					$link = get_term_link( intval($tag->term_id), $tag->taxonomy );
740
+		}
741
+		if ( is_wp_error( $link ) ) {
742
+					return;
743
+		}
724 744
 
725 745
 		$tags[ $key ]->link = $link;
726 746
 		$tags[ $key ]->id = $tag->term_id;
@@ -738,8 +758,9 @@  discard block
 block discarded – undo
738 758
 	 */
739 759
 	$return = apply_filters( 'wp_tag_cloud', $return, $args );
740 760
 
741
-	if ( 'array' == $args['format'] || empty($args['echo']) )
742
-		return $return;
761
+	if ( 'array' == $args['format'] || empty($args['echo']) ) {
762
+			return $return;
763
+	}
743 764
 
744 765
 	echo $return;
745 766
 }
@@ -856,8 +877,9 @@  discard block
 block discarded – undo
856 877
 		}
857 878
 	}
858 879
 
859
-	if ( $args['number'] > 0 )
860
-		$tags = array_slice( $tags, 0, $args['number'] );
880
+	if ( $args['number'] > 0 ) {
881
+			$tags = array_slice( $tags, 0, $args['number'] );
882
+	}
861 883
 
862 884
 	$counts = array();
863 885
 	$real_counts = array(); // For the alt tag
@@ -868,11 +890,13 @@  discard block
 block discarded – undo
868 890
 
869 891
 	$min_count = min( $counts );
870 892
 	$spread = max( $counts ) - $min_count;
871
-	if ( $spread <= 0 )
872
-		$spread = 1;
893
+	if ( $spread <= 0 ) {
894
+			$spread = 1;
895
+	}
873 896
 	$font_spread = $args['largest'] - $args['smallest'];
874
-	if ( $font_spread < 0 )
875
-		$font_spread = 1;
897
+	if ( $font_spread < 0 ) {
898
+			$font_spread = 1;
899
+	}
876 900
 	$font_step = $font_spread / $spread;
877 901
 
878 902
 	// Assemble the data that will be used to generate the tag cloud markup.
@@ -950,11 +974,10 @@  discard block
 block discarded – undo
950 974
 		 * @param array        $args   An array of wp_generate_tag_cloud() arguments.
951 975
 		 */
952 976
 		return apply_filters( 'wp_generate_tag_cloud', $return, $tags, $args );
977
+	} else {
978
+			return $return;
979
+	}
953 980
 	}
954
-
955
-	else
956
-		return $return;
957
-}
958 981
 
959 982
 /**
960 983
  * Serves as a callback for comparing objects based on name.
@@ -1045,13 +1068,15 @@  discard block
 block discarded – undo
1045 1068
  * @return string Link on success, empty string if tag does not exist.
1046 1069
  */
1047 1070
 function get_tag_link( $tag ) {
1048
-	if ( ! is_object( $tag ) )
1049
-		$tag = (int) $tag;
1071
+	if ( ! is_object( $tag ) ) {
1072
+			$tag = (int) $tag;
1073
+	}
1050 1074
 
1051 1075
 	$tag = get_term_link( $tag, 'post_tag' );
1052 1076
 
1053
-	if ( is_wp_error( $tag ) )
1054
-		return '';
1077
+	if ( is_wp_error( $tag ) ) {
1078
+			return '';
1079
+	}
1055 1080
 
1056 1081
 	return $tag;
1057 1082
 }
@@ -1115,8 +1140,9 @@  discard block
 block discarded – undo
1115 1140
  * @param string $after Optional. After list.
1116 1141
  */
1117 1142
 function the_tags( $before = null, $sep = ', ', $after = '' ) {
1118
-	if ( null === $before )
1119
-		$before = __('Tags: ');
1143
+	if ( null === $before ) {
1144
+			$before = __('Tags: ');
1145
+	}
1120 1146
 	echo get_the_tag_list($before, $sep, $after);
1121 1147
 }
1122 1148
 
@@ -1164,8 +1190,9 @@  discard block
 block discarded – undo
1164 1190
  *                              or the post does not exist, WP_Error on failure.
1165 1191
  */
1166 1192
 function get_the_terms( $post, $taxonomy ) {
1167
-	if ( ! $post = get_post( $post ) )
1168
-		return false;
1193
+	if ( ! $post = get_post( $post ) ) {
1194
+			return false;
1195
+	}
1169 1196
 
1170 1197
 	$terms = get_object_term_cache( $post->ID, $taxonomy );
1171 1198
 	if ( false === $terms ) {
@@ -1194,8 +1221,9 @@  discard block
 block discarded – undo
1194 1221
 	 */
1195 1222
 	$terms = apply_filters( 'get_the_terms', $terms, $post->ID, $taxonomy );
1196 1223
 
1197
-	if ( empty( $terms ) )
1198
-		return false;
1224
+	if ( empty( $terms ) ) {
1225
+			return false;
1226
+	}
1199 1227
 
1200 1228
 	return $terms;
1201 1229
 }
@@ -1215,11 +1243,13 @@  discard block
 block discarded – undo
1215 1243
 function get_the_term_list( $id, $taxonomy, $before = '', $sep = '', $after = '' ) {
1216 1244
 	$terms = get_the_terms( $id, $taxonomy );
1217 1245
 
1218
-	if ( is_wp_error( $terms ) )
1219
-		return $terms;
1246
+	if ( is_wp_error( $terms ) ) {
1247
+			return $terms;
1248
+	}
1220 1249
 
1221
-	if ( empty( $terms ) )
1222
-		return false;
1250
+	if ( empty( $terms ) ) {
1251
+			return false;
1252
+	}
1223 1253
 
1224 1254
 	$links = array();
1225 1255
 
@@ -1261,8 +1291,9 @@  discard block
 block discarded – undo
1261 1291
 function the_terms( $id, $taxonomy, $before = '', $sep = ', ', $after = '' ) {
1262 1292
 	$term_list = get_the_term_list( $id, $taxonomy, $before, $sep, $after );
1263 1293
 
1264
-	if ( is_wp_error( $term_list ) )
1265
-		return false;
1294
+	if ( is_wp_error( $term_list ) ) {
1295
+			return false;
1296
+	}
1266 1297
 
1267 1298
 	/**
1268 1299
 	 * Filter the list of terms to display.
@@ -1329,12 +1360,14 @@  discard block
 block discarded – undo
1329 1360
 function has_term( $term = '', $taxonomy = '', $post = null ) {
1330 1361
 	$post = get_post($post);
1331 1362
 
1332
-	if ( !$post )
1333
-		return false;
1363
+	if ( !$post ) {
1364
+			return false;
1365
+	}
1334 1366
 
1335 1367
 	$r = is_object_in_term( $post->ID, $taxonomy, $term );
1336
-	if ( is_wp_error( $r ) )
1337
-		return false;
1368
+	if ( is_wp_error( $r ) ) {
1369
+			return false;
1370
+	}
1338 1371
 
1339 1372
 	return $r;
1340 1373
 }
Please login to merge, or discard this patch.
Spacing   +256 added lines, -256 removed lines patch added patch discarded remove patch
@@ -16,13 +16,13 @@  discard block
 block discarded – undo
16 16
  * @param int|object $category Category ID or object.
17 17
  * @return string Link on success, empty string if category does not exist.
18 18
  */
19
-function get_category_link( $category ) {
20
-	if ( ! is_object( $category ) )
19
+function get_category_link($category) {
20
+	if ( ! is_object($category))
21 21
 		$category = (int) $category;
22 22
 
23
-	$category = get_term_link( $category, 'category' );
23
+	$category = get_term_link($category, 'category');
24 24
 
25
-	if ( is_wp_error( $category ) )
25
+	if (is_wp_error($category))
26 26
 		return '';
27 27
 
28 28
 	return $category;
@@ -40,24 +40,24 @@  discard block
 block discarded – undo
40 40
  * @param array $visited Optional. Already linked to categories to prevent duplicates.
41 41
  * @return string|WP_Error A list of category parents on success, WP_Error on failure.
42 42
  */
43
-function get_category_parents( $id, $link = false, $separator = '/', $nicename = false, $visited = array() ) {
43
+function get_category_parents($id, $link = false, $separator = '/', $nicename = false, $visited = array()) {
44 44
 	$chain = '';
45
-	$parent = get_term( $id, 'category' );
46
-	if ( is_wp_error( $parent ) )
45
+	$parent = get_term($id, 'category');
46
+	if (is_wp_error($parent))
47 47
 		return $parent;
48 48
 
49
-	if ( $nicename )
49
+	if ($nicename)
50 50
 		$name = $parent->slug;
51 51
 	else
52 52
 		$name = $parent->name;
53 53
 
54
-	if ( $parent->parent && ( $parent->parent != $parent->term_id ) && !in_array( $parent->parent, $visited ) ) {
54
+	if ($parent->parent && ($parent->parent != $parent->term_id) && ! in_array($parent->parent, $visited)) {
55 55
 		$visited[] = $parent->parent;
56
-		$chain .= get_category_parents( $parent->parent, $link, $separator, $nicename, $visited );
56
+		$chain .= get_category_parents($parent->parent, $link, $separator, $nicename, $visited);
57 57
 	}
58 58
 
59
-	if ( $link )
60
-		$chain .= '<a href="' . esc_url( get_category_link( $parent->term_id ) ) . '">'.$name.'</a>' . $separator;
59
+	if ($link)
60
+		$chain .= '<a href="'.esc_url(get_category_link($parent->term_id)).'">'.$name.'</a>'.$separator;
61 61
 	else
62 62
 		$chain .= $name.$separator;
63 63
 	return $chain;
@@ -76,15 +76,15 @@  discard block
 block discarded – undo
76 76
  * @param int $id Optional, default to current post ID. The post ID.
77 77
  * @return array Array of WP_Term objects, one for each category assigned to the post.
78 78
  */
79
-function get_the_category( $id = false ) {
80
-	$categories = get_the_terms( $id, 'category' );
81
-	if ( ! $categories || is_wp_error( $categories ) )
79
+function get_the_category($id = false) {
80
+	$categories = get_the_terms($id, 'category');
81
+	if ( ! $categories || is_wp_error($categories))
82 82
 		$categories = array();
83 83
 
84
-	$categories = array_values( $categories );
84
+	$categories = array_values($categories);
85 85
 
86
-	foreach ( array_keys( $categories ) as $key ) {
87
-		_make_cat_compat( $categories[$key] );
86
+	foreach (array_keys($categories) as $key) {
87
+		_make_cat_compat($categories[$key]);
88 88
 	}
89 89
 
90 90
 	/**
@@ -96,7 +96,7 @@  discard block
 block discarded – undo
96 96
 	 * @param array $categories An array of categories to return for the post.
97 97
 	 * @param int   $id         ID of the post.
98 98
 	 */
99
-	return apply_filters( 'get_the_categories', $categories, $id );
99
+	return apply_filters('get_the_categories', $categories, $id);
100 100
 }
101 101
 
102 102
 /**
@@ -112,8 +112,8 @@  discard block
 block discarded – undo
112 112
  * @param object $b
113 113
  * @return int
114 114
  */
115
-function _usort_terms_by_name( $a, $b ) {
116
-	return strcmp( $a->name, $b->name );
115
+function _usort_terms_by_name($a, $b) {
116
+	return strcmp($a->name, $b->name);
117 117
 }
118 118
 
119 119
 /**
@@ -129,10 +129,10 @@  discard block
 block discarded – undo
129 129
  * @param object $b
130 130
  * @return int
131 131
  */
132
-function _usort_terms_by_ID( $a, $b ) {
133
-	if ( $a->term_id > $b->term_id )
132
+function _usort_terms_by_ID($a, $b) {
133
+	if ($a->term_id > $b->term_id)
134 134
 		return 1;
135
-	elseif ( $a->term_id < $b->term_id )
135
+	elseif ($a->term_id < $b->term_id)
136 136
 		return -1;
137 137
 	else
138 138
 		return 0;
@@ -146,14 +146,14 @@  discard block
 block discarded – undo
146 146
  * @param int $cat_ID Category ID.
147 147
  * @return string|WP_Error Category name on success, WP_Error on failure.
148 148
  */
149
-function get_the_category_by_ID( $cat_ID ) {
149
+function get_the_category_by_ID($cat_ID) {
150 150
 	$cat_ID = (int) $cat_ID;
151
-	$category = get_term( $cat_ID, 'category' );
151
+	$category = get_term($cat_ID, 'category');
152 152
 
153
-	if ( is_wp_error( $category ) )
153
+	if (is_wp_error($category))
154 154
 		return $category;
155 155
 
156
-	return ( $category ) ? $category->name : '';
156
+	return ($category) ? $category->name : '';
157 157
 }
158 158
 
159 159
 /**
@@ -168,11 +168,11 @@  discard block
 block discarded – undo
168 168
  * @param int $post_id Optional. Post ID to retrieve categories.
169 169
  * @return string
170 170
  */
171
-function get_the_category_list( $separator = '', $parents='', $post_id = false ) {
171
+function get_the_category_list($separator = '', $parents = '', $post_id = false) {
172 172
 	global $wp_rewrite;
173
-	if ( ! is_object_in_taxonomy( get_post_type( $post_id ), 'category' ) ) {
173
+	if ( ! is_object_in_taxonomy(get_post_type($post_id), 'category')) {
174 174
 		/** This filter is documented in wp-includes/category-template.php */
175
-		return apply_filters( 'the_category', '', $separator, $parents );
175
+		return apply_filters('the_category', '', $separator, $parents);
176 176
 	}
177 177
 
178 178
 	/**
@@ -184,58 +184,58 @@  discard block
 block discarded – undo
184 184
 	 * @param int|bool $post_id    ID of the post we're retrieving categories for. When `false`, we assume the
185 185
 	 *                             current post in the loop.
186 186
 	 */
187
-	$categories = apply_filters( 'the_category_list', get_the_category( $post_id ), $post_id );
187
+	$categories = apply_filters('the_category_list', get_the_category($post_id), $post_id);
188 188
 
189
-	if ( empty( $categories ) ) {
189
+	if (empty($categories)) {
190 190
 		/** This filter is documented in wp-includes/category-template.php */
191
-		return apply_filters( 'the_category', __( 'Uncategorized' ), $separator, $parents );
191
+		return apply_filters('the_category', __('Uncategorized'), $separator, $parents);
192 192
 	}
193 193
 
194
-	$rel = ( is_object( $wp_rewrite ) && $wp_rewrite->using_permalinks() ) ? 'rel="category tag"' : 'rel="category"';
194
+	$rel = (is_object($wp_rewrite) && $wp_rewrite->using_permalinks()) ? 'rel="category tag"' : 'rel="category"';
195 195
 
196 196
 	$thelist = '';
197
-	if ( '' == $separator ) {
197
+	if ('' == $separator) {
198 198
 		$thelist .= '<ul class="post-categories">';
199
-		foreach ( $categories as $category ) {
199
+		foreach ($categories as $category) {
200 200
 			$thelist .= "\n\t<li>";
201
-			switch ( strtolower( $parents ) ) {
201
+			switch (strtolower($parents)) {
202 202
 				case 'multiple':
203
-					if ( $category->parent )
204
-						$thelist .= get_category_parents( $category->parent, true, $separator );
205
-					$thelist .= '<a href="' . esc_url( get_category_link( $category->term_id ) ) . '" ' . $rel . '>' . $category->name.'</a></li>';
203
+					if ($category->parent)
204
+						$thelist .= get_category_parents($category->parent, true, $separator);
205
+					$thelist .= '<a href="'.esc_url(get_category_link($category->term_id)).'" '.$rel.'>'.$category->name.'</a></li>';
206 206
 					break;
207 207
 				case 'single':
208
-					$thelist .= '<a href="' . esc_url( get_category_link( $category->term_id ) ) . '"  ' . $rel . '>';
209
-					if ( $category->parent )
210
-						$thelist .= get_category_parents( $category->parent, false, $separator );
208
+					$thelist .= '<a href="'.esc_url(get_category_link($category->term_id)).'"  '.$rel.'>';
209
+					if ($category->parent)
210
+						$thelist .= get_category_parents($category->parent, false, $separator);
211 211
 					$thelist .= $category->name.'</a></li>';
212 212
 					break;
213 213
 				case '':
214 214
 				default:
215
-					$thelist .= '<a href="' . esc_url( get_category_link( $category->term_id ) ) . '" ' . $rel . '>' . $category->name.'</a></li>';
215
+					$thelist .= '<a href="'.esc_url(get_category_link($category->term_id)).'" '.$rel.'>'.$category->name.'</a></li>';
216 216
 			}
217 217
 		}
218 218
 		$thelist .= '</ul>';
219 219
 	} else {
220 220
 		$i = 0;
221
-		foreach ( $categories as $category ) {
222
-			if ( 0 < $i )
221
+		foreach ($categories as $category) {
222
+			if (0 < $i)
223 223
 				$thelist .= $separator;
224
-			switch ( strtolower( $parents ) ) {
224
+			switch (strtolower($parents)) {
225 225
 				case 'multiple':
226
-					if ( $category->parent )
227
-						$thelist .= get_category_parents( $category->parent, true, $separator );
228
-					$thelist .= '<a href="' . esc_url( get_category_link( $category->term_id ) ) . '" ' . $rel . '>' . $category->name.'</a>';
226
+					if ($category->parent)
227
+						$thelist .= get_category_parents($category->parent, true, $separator);
228
+					$thelist .= '<a href="'.esc_url(get_category_link($category->term_id)).'" '.$rel.'>'.$category->name.'</a>';
229 229
 					break;
230 230
 				case 'single':
231
-					$thelist .= '<a href="' . esc_url( get_category_link( $category->term_id ) ) . '" ' . $rel . '>';
232
-					if ( $category->parent )
233
-						$thelist .= get_category_parents( $category->parent, false, $separator );
231
+					$thelist .= '<a href="'.esc_url(get_category_link($category->term_id)).'" '.$rel.'>';
232
+					if ($category->parent)
233
+						$thelist .= get_category_parents($category->parent, false, $separator);
234 234
 					$thelist .= "$category->name</a>";
235 235
 					break;
236 236
 				case '':
237 237
 				default:
238
-					$thelist .= '<a href="' . esc_url( get_category_link( $category->term_id ) ) . '" ' . $rel . '>' . $category->name.'</a>';
238
+					$thelist .= '<a href="'.esc_url(get_category_link($category->term_id)).'" '.$rel.'>'.$category->name.'</a>';
239 239
 			}
240 240
 			++$i;
241 241
 		}
@@ -251,7 +251,7 @@  discard block
 block discarded – undo
251 251
 	 * @param string $parents   How to display the category parents. Accepts 'multiple',
252 252
 	 *                          'single', or empty.
253 253
 	 */
254
-	return apply_filters( 'the_category', $thelist, $separator, $parents );
254
+	return apply_filters('the_category', $thelist, $separator, $parents);
255 255
 }
256 256
 
257 257
 /**
@@ -272,11 +272,11 @@  discard block
 block discarded – undo
272 272
  * @param int|object $post Optional. Post to check instead of the current post. (since 2.7.0)
273 273
  * @return bool True if the current post is in any of the given categories.
274 274
  */
275
-function in_category( $category, $post = null ) {
276
-	if ( empty( $category ) )
275
+function in_category($category, $post = null) {
276
+	if (empty($category))
277 277
 		return false;
278 278
 
279
-	return has_category( $category, $post );
279
+	return has_category($category, $post);
280 280
 }
281 281
 
282 282
 /**
@@ -288,8 +288,8 @@  discard block
 block discarded – undo
288 288
  * @param string $parents Optional. How to display the parents.
289 289
  * @param int $post_id Optional. Post ID to retrieve categories.
290 290
  */
291
-function the_category( $separator = '', $parents='', $post_id = false ) {
292
-	echo get_the_category_list( $separator, $parents, $post_id );
291
+function the_category($separator = '', $parents = '', $post_id = false) {
292
+	echo get_the_category_list($separator, $parents, $post_id);
293 293
 }
294 294
 
295 295
 /**
@@ -300,8 +300,8 @@  discard block
 block discarded – undo
300 300
  * @param int $category Optional. Category ID. Will use global category ID by default.
301 301
  * @return string Category description, available.
302 302
  */
303
-function category_description( $category = 0 ) {
304
-	return term_description( $category, 'category' );
303
+function category_description($category = 0) {
304
+	return term_description($category, 'category');
305 305
 }
306 306
 
307 307
 /**
@@ -357,7 +357,7 @@  discard block
 block discarded – undo
357 357
  * }
358 358
  * @return string HTML content only if 'echo' argument is 0.
359 359
  */
360
-function wp_dropdown_categories( $args = '' ) {
360
+function wp_dropdown_categories($args = '') {
361 361
 	$defaults = array(
362 362
 		'show_option_all'   => '',
363 363
 		'show_option_none'  => '',
@@ -382,13 +382,13 @@  discard block
 block discarded – undo
382 382
 		'required'          => false,
383 383
 	);
384 384
 
385
-	$defaults['selected'] = ( is_category() ) ? get_query_var( 'cat' ) : 0;
385
+	$defaults['selected'] = (is_category()) ? get_query_var('cat') : 0;
386 386
 
387 387
 	// Back compat.
388
-	if ( isset( $args['type'] ) && 'link' == $args['type'] ) {
388
+	if (isset($args['type']) && 'link' == $args['type']) {
389 389
 		/* translators: 1: "type => link", 2: "taxonomy => link_category" alternative */
390
-		_deprecated_argument( __FUNCTION__, '3.0.0',
391
-			sprintf( __( '%1$s is deprecated. Use %2$s instead.' ),
390
+		_deprecated_argument(__FUNCTION__, '3.0.0',
391
+			sprintf(__('%1$s is deprecated. Use %2$s instead.'),
392 392
 				'<code>type => link</code>',
393 393
 				'<code>taxonomy => link_category</code>'
394 394
 			)
@@ -396,36 +396,36 @@  discard block
 block discarded – undo
396 396
 		$args['taxonomy'] = 'link_category';
397 397
 	}
398 398
 
399
-	$r = wp_parse_args( $args, $defaults );
399
+	$r = wp_parse_args($args, $defaults);
400 400
 	$option_none_value = $r['option_none_value'];
401 401
 
402
-	if ( ! isset( $r['pad_counts'] ) && $r['show_count'] && $r['hierarchical'] ) {
402
+	if ( ! isset($r['pad_counts']) && $r['show_count'] && $r['hierarchical']) {
403 403
 		$r['pad_counts'] = true;
404 404
 	}
405 405
 
406 406
 	$tab_index = $r['tab_index'];
407 407
 
408 408
 	$tab_index_attribute = '';
409
-	if ( (int) $tab_index > 0 ) {
409
+	if ((int) $tab_index > 0) {
410 410
 		$tab_index_attribute = " tabindex=\"$tab_index\"";
411 411
 	}
412 412
 
413 413
 	// Avoid clashes with the 'name' param of get_terms().
414 414
 	$get_terms_args = $r;
415
-	unset( $get_terms_args['name'] );
416
-	$categories = get_terms( $r['taxonomy'], $get_terms_args );
415
+	unset($get_terms_args['name']);
416
+	$categories = get_terms($r['taxonomy'], $get_terms_args);
417 417
 
418
-	$name = esc_attr( $r['name'] );
419
-	$class = esc_attr( $r['class'] );
420
-	$id = $r['id'] ? esc_attr( $r['id'] ) : $name;
418
+	$name = esc_attr($r['name']);
419
+	$class = esc_attr($r['class']);
420
+	$id = $r['id'] ? esc_attr($r['id']) : $name;
421 421
 	$required = $r['required'] ? 'required' : '';
422 422
 
423
-	if ( ! $r['hide_if_empty'] || ! empty( $categories ) ) {
423
+	if ( ! $r['hide_if_empty'] || ! empty($categories)) {
424 424
 		$output = "<select $required name='$name' id='$id' class='$class' $tab_index_attribute>\n";
425 425
 	} else {
426 426
 		$output = '';
427 427
 	}
428
-	if ( empty( $categories ) && ! $r['hide_if_empty'] && ! empty( $r['show_option_none'] ) ) {
428
+	if (empty($categories) && ! $r['hide_if_empty'] && ! empty($r['show_option_none'])) {
429 429
 
430 430
 		/**
431 431
 		 * Filters a taxonomy drop-down display element.
@@ -441,37 +441,37 @@  discard block
 block discarded – undo
441 441
 		 *
442 442
 		 * @param string $element Taxonomy element to list.
443 443
 		 */
444
-		$show_option_none = apply_filters( 'list_cats', $r['show_option_none'] );
445
-		$output .= "\t<option value='" . esc_attr( $option_none_value ) . "' selected='selected'>$show_option_none</option>\n";
444
+		$show_option_none = apply_filters('list_cats', $r['show_option_none']);
445
+		$output .= "\t<option value='".esc_attr($option_none_value)."' selected='selected'>$show_option_none</option>\n";
446 446
 	}
447 447
 
448
-	if ( ! empty( $categories ) ) {
448
+	if ( ! empty($categories)) {
449 449
 
450
-		if ( $r['show_option_all'] ) {
450
+		if ($r['show_option_all']) {
451 451
 
452 452
 			/** This filter is documented in wp-includes/category-template.php */
453
-			$show_option_all = apply_filters( 'list_cats', $r['show_option_all'] );
454
-			$selected = ( '0' === strval($r['selected']) ) ? " selected='selected'" : '';
453
+			$show_option_all = apply_filters('list_cats', $r['show_option_all']);
454
+			$selected = ('0' === strval($r['selected'])) ? " selected='selected'" : '';
455 455
 			$output .= "\t<option value='0'$selected>$show_option_all</option>\n";
456 456
 		}
457 457
 
458
-		if ( $r['show_option_none'] ) {
458
+		if ($r['show_option_none']) {
459 459
 
460 460
 			/** This filter is documented in wp-includes/category-template.php */
461
-			$show_option_none = apply_filters( 'list_cats', $r['show_option_none'] );
462
-			$selected = selected( $option_none_value, $r['selected'], false );
463
-			$output .= "\t<option value='" . esc_attr( $option_none_value ) . "'$selected>$show_option_none</option>\n";
461
+			$show_option_none = apply_filters('list_cats', $r['show_option_none']);
462
+			$selected = selected($option_none_value, $r['selected'], false);
463
+			$output .= "\t<option value='".esc_attr($option_none_value)."'$selected>$show_option_none</option>\n";
464 464
 		}
465 465
 
466
-		if ( $r['hierarchical'] ) {
467
-			$depth = $r['depth'];  // Walk the full depth.
466
+		if ($r['hierarchical']) {
467
+			$depth = $r['depth']; // Walk the full depth.
468 468
 		} else {
469 469
 			$depth = -1; // Flat.
470 470
 		}
471
-		$output .= walk_category_dropdown_tree( $categories, $depth, $r );
471
+		$output .= walk_category_dropdown_tree($categories, $depth, $r);
472 472
 	}
473 473
 
474
-	if ( ! $r['hide_if_empty'] || ! empty( $categories ) ) {
474
+	if ( ! $r['hide_if_empty'] || ! empty($categories)) {
475 475
 		$output .= "</select>\n";
476 476
 	}
477 477
 	/**
@@ -482,9 +482,9 @@  discard block
 block discarded – undo
482 482
 	 * @param string $output HTML output.
483 483
 	 * @param array  $r      Arguments used to build the drop-down.
484 484
 	 */
485
-	$output = apply_filters( 'wp_dropdown_cats', $output, $r );
485
+	$output = apply_filters('wp_dropdown_cats', $output, $r);
486 486
 
487
-	if ( $r['echo'] ) {
487
+	if ($r['echo']) {
488 488
 		echo $output;
489 489
 	}
490 490
 	return $output;
@@ -541,7 +541,7 @@  discard block
 block discarded – undo
541 541
  * }
542 542
  * @return false|string HTML content only if 'echo' argument is 0.
543 543
  */
544
-function wp_list_categories( $args = '' ) {
544
+function wp_list_categories($args = '') {
545 545
 	$defaults = array(
546 546
 		'child_of'            => 0,
547 547
 		'current_category'    => 0,
@@ -560,110 +560,110 @@  discard block
 block discarded – undo
560 560
 		'separator'           => '<br />',
561 561
 		'show_count'          => 0,
562 562
 		'show_option_all'     => '',
563
-		'show_option_none'    => __( 'No categories' ),
563
+		'show_option_none'    => __('No categories'),
564 564
 		'style'               => 'list',
565 565
 		'taxonomy'            => 'category',
566
-		'title_li'            => __( 'Categories' ),
566
+		'title_li'            => __('Categories'),
567 567
 		'use_desc_for_title'  => 1,
568 568
 	);
569 569
 
570
-	$r = wp_parse_args( $args, $defaults );
570
+	$r = wp_parse_args($args, $defaults);
571 571
 
572
-	if ( !isset( $r['pad_counts'] ) && $r['show_count'] && $r['hierarchical'] )
572
+	if ( ! isset($r['pad_counts']) && $r['show_count'] && $r['hierarchical'])
573 573
 		$r['pad_counts'] = true;
574 574
 
575 575
 	// Descendants of exclusions should be excluded too.
576
-	if ( true == $r['hierarchical'] ) {
576
+	if (true == $r['hierarchical']) {
577 577
 		$exclude_tree = array();
578 578
 
579
-		if ( $r['exclude_tree'] ) {
580
-			$exclude_tree = array_merge( $exclude_tree, wp_parse_id_list( $r['exclude_tree'] ) );
579
+		if ($r['exclude_tree']) {
580
+			$exclude_tree = array_merge($exclude_tree, wp_parse_id_list($r['exclude_tree']));
581 581
 		}
582 582
 
583
-		if ( $r['exclude'] ) {
584
-			$exclude_tree = array_merge( $exclude_tree, wp_parse_id_list( $r['exclude'] ) );
583
+		if ($r['exclude']) {
584
+			$exclude_tree = array_merge($exclude_tree, wp_parse_id_list($r['exclude']));
585 585
 		}
586 586
 
587 587
 		$r['exclude_tree'] = $exclude_tree;
588 588
 		$r['exclude'] = '';
589 589
 	}
590 590
 
591
-	if ( ! isset( $r['class'] ) )
592
-		$r['class'] = ( 'category' == $r['taxonomy'] ) ? 'categories' : $r['taxonomy'];
591
+	if ( ! isset($r['class']))
592
+		$r['class'] = ('category' == $r['taxonomy']) ? 'categories' : $r['taxonomy'];
593 593
 
594
-	if ( ! taxonomy_exists( $r['taxonomy'] ) ) {
594
+	if ( ! taxonomy_exists($r['taxonomy'])) {
595 595
 		return false;
596 596
 	}
597 597
 
598 598
 	$show_option_all = $r['show_option_all'];
599 599
 	$show_option_none = $r['show_option_none'];
600 600
 
601
-	$categories = get_categories( $r );
601
+	$categories = get_categories($r);
602 602
 
603 603
 	$output = '';
604
-	if ( $r['title_li'] && 'list' == $r['style'] && ( ! empty( $categories ) || ! $r['hide_title_if_empty'] ) ) {
605
-		$output = '<li class="' . esc_attr( $r['class'] ) . '">' . $r['title_li'] . '<ul>';
604
+	if ($r['title_li'] && 'list' == $r['style'] && ( ! empty($categories) || ! $r['hide_title_if_empty'])) {
605
+		$output = '<li class="'.esc_attr($r['class']).'">'.$r['title_li'].'<ul>';
606 606
 	}
607
-	if ( empty( $categories ) ) {
608
-		if ( ! empty( $show_option_none ) ) {
609
-			if ( 'list' == $r['style'] ) {
610
-				$output .= '<li class="cat-item-none">' . $show_option_none . '</li>';
607
+	if (empty($categories)) {
608
+		if ( ! empty($show_option_none)) {
609
+			if ('list' == $r['style']) {
610
+				$output .= '<li class="cat-item-none">'.$show_option_none.'</li>';
611 611
 			} else {
612 612
 				$output .= $show_option_none;
613 613
 			}
614 614
 		}
615 615
 	} else {
616
-		if ( ! empty( $show_option_all ) ) {
616
+		if ( ! empty($show_option_all)) {
617 617
 
618 618
 			$posts_page = '';
619 619
 
620 620
 			// For taxonomies that belong only to custom post types, point to a valid archive.
621
-			$taxonomy_object = get_taxonomy( $r['taxonomy'] );
622
-			if ( ! in_array( 'post', $taxonomy_object->object_type ) && ! in_array( 'page', $taxonomy_object->object_type ) ) {
623
-				foreach ( $taxonomy_object->object_type as $object_type ) {
624
-					$_object_type = get_post_type_object( $object_type );
621
+			$taxonomy_object = get_taxonomy($r['taxonomy']);
622
+			if ( ! in_array('post', $taxonomy_object->object_type) && ! in_array('page', $taxonomy_object->object_type)) {
623
+				foreach ($taxonomy_object->object_type as $object_type) {
624
+					$_object_type = get_post_type_object($object_type);
625 625
 
626 626
 					// Grab the first one.
627
-					if ( ! empty( $_object_type->has_archive ) ) {
628
-						$posts_page = get_post_type_archive_link( $object_type );
627
+					if ( ! empty($_object_type->has_archive)) {
628
+						$posts_page = get_post_type_archive_link($object_type);
629 629
 						break;
630 630
 					}
631 631
 				}
632 632
 			}
633 633
 
634 634
 			// Fallback for the 'All' link is the posts page.
635
-			if ( ! $posts_page ) {
636
-				if ( 'page' == get_option( 'show_on_front' ) && get_option( 'page_for_posts' ) ) {
637
-					$posts_page = get_permalink( get_option( 'page_for_posts' ) );
635
+			if ( ! $posts_page) {
636
+				if ('page' == get_option('show_on_front') && get_option('page_for_posts')) {
637
+					$posts_page = get_permalink(get_option('page_for_posts'));
638 638
 				} else {
639
-					$posts_page = home_url( '/' );
639
+					$posts_page = home_url('/');
640 640
 				}
641 641
 			}
642 642
 
643
-			$posts_page = esc_url( $posts_page );
644
-			if ( 'list' == $r['style'] ) {
643
+			$posts_page = esc_url($posts_page);
644
+			if ('list' == $r['style']) {
645 645
 				$output .= "<li class='cat-item-all'><a href='$posts_page'>$show_option_all</a></li>";
646 646
 			} else {
647 647
 				$output .= "<a href='$posts_page'>$show_option_all</a>";
648 648
 			}
649 649
 		}
650 650
 
651
-		if ( empty( $r['current_category'] ) && ( is_category() || is_tax() || is_tag() ) ) {
651
+		if (empty($r['current_category']) && (is_category() || is_tax() || is_tag())) {
652 652
 			$current_term_object = get_queried_object();
653
-			if ( $current_term_object && $r['taxonomy'] === $current_term_object->taxonomy ) {
653
+			if ($current_term_object && $r['taxonomy'] === $current_term_object->taxonomy) {
654 654
 				$r['current_category'] = get_queried_object_id();
655 655
 			}
656 656
 		}
657 657
 
658
-		if ( $r['hierarchical'] ) {
658
+		if ($r['hierarchical']) {
659 659
 			$depth = $r['depth'];
660 660
 		} else {
661 661
 			$depth = -1; // Flat.
662 662
 		}
663
-		$output .= walk_category_tree( $categories, $depth, $r );
663
+		$output .= walk_category_tree($categories, $depth, $r);
664 664
 	}
665 665
 
666
-	if ( $r['title_li'] && 'list' == $r['style'] )
666
+	if ($r['title_li'] && 'list' == $r['style'])
667 667
 		$output .= '</ul></li>';
668 668
 
669 669
 	/**
@@ -674,9 +674,9 @@  discard block
 block discarded – undo
674 674
 	 * @param string $output HTML output.
675 675
 	 * @param array  $args   An array of taxonomy-listing arguments.
676 676
 	 */
677
-	$html = apply_filters( 'wp_list_categories', $output, $args );
677
+	$html = apply_filters('wp_list_categories', $output, $args);
678 678
 
679
-	if ( $r['echo'] ) {
679
+	if ($r['echo']) {
680 680
 		echo $html;
681 681
 	} else {
682 682
 		return $html;
@@ -717,32 +717,32 @@  discard block
 block discarded – undo
717 717
  * @return void|array Generated tag cloud, only if no failures and 'array' is set for the 'format' argument.
718 718
  *                    Otherwise, this function outputs the tag cloud.
719 719
  */
720
-function wp_tag_cloud( $args = '' ) {
720
+function wp_tag_cloud($args = '') {
721 721
 	$defaults = array(
722 722
 		'smallest' => 8, 'largest' => 22, 'unit' => 'pt', 'number' => 45,
723 723
 		'format' => 'flat', 'separator' => "\n", 'orderby' => 'name', 'order' => 'ASC',
724 724
 		'exclude' => '', 'include' => '', 'link' => 'view', 'taxonomy' => 'post_tag', 'post_type' => '', 'echo' => true
725 725
 	);
726
-	$args = wp_parse_args( $args, $defaults );
726
+	$args = wp_parse_args($args, $defaults);
727 727
 
728
-	$tags = get_terms( $args['taxonomy'], array_merge( $args, array( 'orderby' => 'count', 'order' => 'DESC' ) ) ); // Always query top tags
728
+	$tags = get_terms($args['taxonomy'], array_merge($args, array('orderby' => 'count', 'order' => 'DESC'))); // Always query top tags
729 729
 
730
-	if ( empty( $tags ) || is_wp_error( $tags ) )
730
+	if (empty($tags) || is_wp_error($tags))
731 731
 		return;
732 732
 
733
-	foreach ( $tags as $key => $tag ) {
734
-		if ( 'edit' == $args['link'] )
735
-			$link = get_edit_term_link( $tag->term_id, $tag->taxonomy, $args['post_type'] );
733
+	foreach ($tags as $key => $tag) {
734
+		if ('edit' == $args['link'])
735
+			$link = get_edit_term_link($tag->term_id, $tag->taxonomy, $args['post_type']);
736 736
 		else
737
-			$link = get_term_link( intval($tag->term_id), $tag->taxonomy );
738
-		if ( is_wp_error( $link ) )
737
+			$link = get_term_link(intval($tag->term_id), $tag->taxonomy);
738
+		if (is_wp_error($link))
739 739
 			return;
740 740
 
741
-		$tags[ $key ]->link = $link;
742
-		$tags[ $key ]->id = $tag->term_id;
741
+		$tags[$key]->link = $link;
742
+		$tags[$key]->id = $tag->term_id;
743 743
 	}
744 744
 
745
-	$return = wp_generate_tag_cloud( $tags, $args ); // Here's where those top tags get sorted according to $args
745
+	$return = wp_generate_tag_cloud($tags, $args); // Here's where those top tags get sorted according to $args
746 746
 
747 747
 	/**
748 748
 	 * Filters the tag cloud output.
@@ -752,9 +752,9 @@  discard block
 block discarded – undo
752 752
 	 * @param string $return HTML output of the tag cloud.
753 753
 	 * @param array  $args   An array of tag cloud arguments.
754 754
 	 */
755
-	$return = apply_filters( 'wp_tag_cloud', $return, $args );
755
+	$return = apply_filters('wp_tag_cloud', $return, $args);
756 756
 
757
-	if ( 'array' == $args['format'] || empty($args['echo']) )
757
+	if ('array' == $args['format'] || empty($args['echo']))
758 758
 		return $return;
759 759
 
760 760
 	echo $return;
@@ -766,7 +766,7 @@  discard block
 block discarded – undo
766 766
  * @param int $count number of posts with that tag
767 767
  * @return int scaled count
768 768
  */
769
-function default_topic_count_scale( $count ) {
769
+function default_topic_count_scale($count) {
770 770
 	return round(log10($count + 1) * 100);
771 771
 }
772 772
 
@@ -813,7 +813,7 @@  discard block
 block discarded – undo
813 813
  * }
814 814
  * @return string|array Tag cloud as a string or an array, depending on 'format' argument.
815 815
  */
816
-function wp_generate_tag_cloud( $tags, $args = '' ) {
816
+function wp_generate_tag_cloud($tags, $args = '') {
817 817
 	$defaults = array(
818 818
 		'smallest' => 8, 'largest' => 22, 'unit' => 'pt', 'number' => 0,
819 819
 		'format' => 'flat', 'separator' => "\n", 'orderby' => 'name', 'order' => 'ASC',
@@ -821,31 +821,31 @@  discard block
 block discarded – undo
821 821
 		'topic_count_scale_callback' => 'default_topic_count_scale', 'filter' => 1,
822 822
 	);
823 823
 
824
-	$args = wp_parse_args( $args, $defaults );
824
+	$args = wp_parse_args($args, $defaults);
825 825
 
826
-	$return = ( 'array' === $args['format'] ) ? array() : '';
826
+	$return = ('array' === $args['format']) ? array() : '';
827 827
 
828
-	if ( empty( $tags ) ) {
828
+	if (empty($tags)) {
829 829
 		return $return;
830 830
 	}
831 831
 
832 832
 	// Juggle topic count tooltips:
833
-	if ( isset( $args['topic_count_text'] ) ) {
833
+	if (isset($args['topic_count_text'])) {
834 834
 		// First look for nooped plural support via topic_count_text.
835 835
 		$translate_nooped_plural = $args['topic_count_text'];
836
-	} elseif ( ! empty( $args['topic_count_text_callback'] ) ) {
836
+	} elseif ( ! empty($args['topic_count_text_callback'])) {
837 837
 		// Look for the alternative callback style. Ignore the previous default.
838
-		if ( $args['topic_count_text_callback'] === 'default_topic_count_text' ) {
839
-			$translate_nooped_plural = _n_noop( '%s topic', '%s topics' );
838
+		if ($args['topic_count_text_callback'] === 'default_topic_count_text') {
839
+			$translate_nooped_plural = _n_noop('%s topic', '%s topics');
840 840
 		} else {
841 841
 			$translate_nooped_plural = false;
842 842
 		}
843
-	} elseif ( isset( $args['single_text'] ) && isset( $args['multiple_text'] ) ) {
843
+	} elseif (isset($args['single_text']) && isset($args['multiple_text'])) {
844 844
 		// If no callback exists, look for the old-style single_text and multiple_text arguments.
845
-		$translate_nooped_plural = _n_noop( $args['single_text'], $args['multiple_text'] );
845
+		$translate_nooped_plural = _n_noop($args['single_text'], $args['multiple_text']);
846 846
 	} else {
847 847
 		// This is the default for when no callback, plural, or argument is passed in.
848
-		$translate_nooped_plural = _n_noop( '%s topic', '%s topics' );
848
+		$translate_nooped_plural = _n_noop('%s topic', '%s topics');
849 849
 	}
850 850
 
851 851
 	/**
@@ -856,62 +856,62 @@  discard block
 block discarded – undo
856 856
 	 * @param array $tags Ordered array of terms.
857 857
 	 * @param array $args An array of tag cloud arguments.
858 858
 	 */
859
-	$tags_sorted = apply_filters( 'tag_cloud_sort', $tags, $args );
860
-	if ( empty( $tags_sorted ) ) {
859
+	$tags_sorted = apply_filters('tag_cloud_sort', $tags, $args);
860
+	if (empty($tags_sorted)) {
861 861
 		return $return;
862 862
 	}
863 863
 
864
-	if ( $tags_sorted !== $tags ) {
864
+	if ($tags_sorted !== $tags) {
865 865
 		$tags = $tags_sorted;
866
-		unset( $tags_sorted );
866
+		unset($tags_sorted);
867 867
 	} else {
868
-		if ( 'RAND' === $args['order'] ) {
869
-			shuffle( $tags );
868
+		if ('RAND' === $args['order']) {
869
+			shuffle($tags);
870 870
 		} else {
871 871
 			// SQL cannot save you; this is a second (potentially different) sort on a subset of data.
872
-			if ( 'name' === $args['orderby'] ) {
873
-				uasort( $tags, '_wp_object_name_sort_cb' );
872
+			if ('name' === $args['orderby']) {
873
+				uasort($tags, '_wp_object_name_sort_cb');
874 874
 			} else {
875
-				uasort( $tags, '_wp_object_count_sort_cb' );
875
+				uasort($tags, '_wp_object_count_sort_cb');
876 876
 			}
877 877
 
878
-			if ( 'DESC' === $args['order'] ) {
879
-				$tags = array_reverse( $tags, true );
878
+			if ('DESC' === $args['order']) {
879
+				$tags = array_reverse($tags, true);
880 880
 			}
881 881
 		}
882 882
 	}
883 883
 
884
-	if ( $args['number'] > 0 )
885
-		$tags = array_slice( $tags, 0, $args['number'] );
884
+	if ($args['number'] > 0)
885
+		$tags = array_slice($tags, 0, $args['number']);
886 886
 
887 887
 	$counts = array();
888 888
 	$real_counts = array(); // For the alt tag
889
-	foreach ( (array) $tags as $key => $tag ) {
890
-		$real_counts[ $key ] = $tag->count;
891
-		$counts[ $key ] = call_user_func( $args['topic_count_scale_callback'], $tag->count );
889
+	foreach ((array) $tags as $key => $tag) {
890
+		$real_counts[$key] = $tag->count;
891
+		$counts[$key] = call_user_func($args['topic_count_scale_callback'], $tag->count);
892 892
 	}
893 893
 
894
-	$min_count = min( $counts );
895
-	$spread = max( $counts ) - $min_count;
896
-	if ( $spread <= 0 )
894
+	$min_count = min($counts);
895
+	$spread = max($counts) - $min_count;
896
+	if ($spread <= 0)
897 897
 		$spread = 1;
898 898
 	$font_spread = $args['largest'] - $args['smallest'];
899
-	if ( $font_spread < 0 )
899
+	if ($font_spread < 0)
900 900
 		$font_spread = 1;
901 901
 	$font_step = $font_spread / $spread;
902 902
 
903 903
 	// Assemble the data that will be used to generate the tag cloud markup.
904 904
 	$tags_data = array();
905
-	foreach ( $tags as $key => $tag ) {
906
-		$tag_id = isset( $tag->id ) ? $tag->id : $key;
905
+	foreach ($tags as $key => $tag) {
906
+		$tag_id = isset($tag->id) ? $tag->id : $key;
907 907
 
908
-		$count = $counts[ $key ];
909
-		$real_count = $real_counts[ $key ];
908
+		$count = $counts[$key];
909
+		$real_count = $real_counts[$key];
910 910
 
911
-		if ( $translate_nooped_plural ) {
912
-			$title = sprintf( translate_nooped_plural( $translate_nooped_plural, $real_count ), number_format_i18n( $real_count ) );
911
+		if ($translate_nooped_plural) {
912
+			$title = sprintf(translate_nooped_plural($translate_nooped_plural, $real_count), number_format_i18n($real_count));
913 913
 		} else {
914
-			$title = call_user_func( $args['topic_count_text_callback'], $real_count, $tag, $args );
914
+			$title = call_user_func($args['topic_count_text_callback'], $real_count, $tag, $args);
915 915
 		}
916 916
 
917 917
 		$tags_data[] = array(
@@ -921,8 +921,8 @@  discard block
 block discarded – undo
921 921
 			'title'      => $title,
922 922
 			'slug'       => $tag->slug,
923 923
 			'real_count' => $real_count,
924
-			'class'	     => 'tag-link-' . $tag_id,
925
-			'font_size'  => $args['smallest'] + ( $count - $min_count ) * $font_step,
924
+			'class'	     => 'tag-link-'.$tag_id,
925
+			'font_size'  => $args['smallest'] + ($count - $min_count) * $font_step,
926 926
 		);
927 927
 	}
928 928
 
@@ -933,31 +933,31 @@  discard block
 block discarded – undo
933 933
 	 *
934 934
 	 * @param array $tags_data An array of term data for term used to generate the tag cloud.
935 935
 	 */
936
-	$tags_data = apply_filters( 'wp_generate_tag_cloud_data', $tags_data );
936
+	$tags_data = apply_filters('wp_generate_tag_cloud_data', $tags_data);
937 937
 
938 938
 	$a = array();
939 939
 
940 940
 	// generate the output links array
941
-	foreach ( $tags_data as $key => $tag_data ) {
942
-		$class = $tag_data['class'] . ' tag-link-position-' . ( $key + 1 );
943
-		$a[] = "<a href='" . esc_url( $tag_data['url'] ) . "' class='" . esc_attr( $class ) . "' title='" . esc_attr( $tag_data['title'] ) . "' style='font-size: " . esc_attr( str_replace( ',', '.', $tag_data['font_size'] ) . $args['unit'] ) . ";'>" . esc_html( $tag_data['name'] ) . "</a>";
941
+	foreach ($tags_data as $key => $tag_data) {
942
+		$class = $tag_data['class'].' tag-link-position-'.($key + 1);
943
+		$a[] = "<a href='".esc_url($tag_data['url'])."' class='".esc_attr($class)."' title='".esc_attr($tag_data['title'])."' style='font-size: ".esc_attr(str_replace(',', '.', $tag_data['font_size']).$args['unit']).";'>".esc_html($tag_data['name'])."</a>";
944 944
 	}
945 945
 
946
-	switch ( $args['format'] ) {
946
+	switch ($args['format']) {
947 947
 		case 'array' :
948
-			$return =& $a;
948
+			$return = & $a;
949 949
 			break;
950 950
 		case 'list' :
951 951
 			$return = "<ul class='wp-tag-cloud'>\n\t<li>";
952
-			$return .= join( "</li>\n\t<li>", $a );
952
+			$return .= join("</li>\n\t<li>", $a);
953 953
 			$return .= "</li>\n</ul>\n";
954 954
 			break;
955 955
 		default :
956
-			$return = join( $args['separator'], $a );
956
+			$return = join($args['separator'], $a);
957 957
 			break;
958 958
 	}
959 959
 
960
-	if ( $args['filter'] ) {
960
+	if ($args['filter']) {
961 961
 		/**
962 962
 		 * Filters the generated output of a tag cloud.
963 963
 		 *
@@ -974,7 +974,7 @@  discard block
 block discarded – undo
974 974
 		 * @param array        $tags   An array of terms used in the tag cloud.
975 975
 		 * @param array        $args   An array of wp_generate_tag_cloud() arguments.
976 976
 		 */
977
-		return apply_filters( 'wp_generate_tag_cloud', $return, $tags, $args );
977
+		return apply_filters('wp_generate_tag_cloud', $return, $tags, $args);
978 978
 	}
979 979
 
980 980
 	else
@@ -994,8 +994,8 @@  discard block
 block discarded – undo
994 994
  * @return int Negative number if `$a->name` is less than `$b->name`, zero if they are equal,
995 995
  *             or greater than zero if `$a->name` is greater than `$b->name`.
996 996
  */
997
-function _wp_object_name_sort_cb( $a, $b ) {
998
-	return strnatcasecmp( $a->name, $b->name );
997
+function _wp_object_name_sort_cb($a, $b) {
998
+	return strnatcasecmp($a->name, $b->name);
999 999
 }
1000 1000
 
1001 1001
 /**
@@ -1010,8 +1010,8 @@  discard block
 block discarded – undo
1010 1010
  * @param object $b The second object to compare.
1011 1011
  * @return bool Whether the count value for `$a` is greater than the count value for `$b`.
1012 1012
  */
1013
-function _wp_object_count_sort_cb( $a, $b ) {
1014
-	return ( $a->count > $b->count );
1013
+function _wp_object_count_sort_cb($a, $b) {
1014
+	return ($a->count > $b->count);
1015 1015
 }
1016 1016
 
1017 1017
 //
@@ -1029,12 +1029,12 @@  discard block
 block discarded – undo
1029 1029
 function walk_category_tree() {
1030 1030
 	$args = func_get_args();
1031 1031
 	// the user's options are the third parameter
1032
-	if ( empty( $args[2]['walker'] ) || ! ( $args[2]['walker'] instanceof Walker ) ) {
1032
+	if (empty($args[2]['walker']) || ! ($args[2]['walker'] instanceof Walker)) {
1033 1033
 		$walker = new Walker_Category;
1034 1034
 	} else {
1035 1035
 		$walker = $args[2]['walker'];
1036 1036
 	}
1037
-	return call_user_func_array( array( $walker, 'walk' ), $args );
1037
+	return call_user_func_array(array($walker, 'walk'), $args);
1038 1038
 }
1039 1039
 
1040 1040
 /**
@@ -1048,12 +1048,12 @@  discard block
 block discarded – undo
1048 1048
 function walk_category_dropdown_tree() {
1049 1049
 	$args = func_get_args();
1050 1050
 	// the user's options are the third parameter
1051
-	if ( empty( $args[2]['walker'] ) || ! ( $args[2]['walker'] instanceof Walker ) ) {
1051
+	if (empty($args[2]['walker']) || ! ($args[2]['walker'] instanceof Walker)) {
1052 1052
 		$walker = new Walker_CategoryDropdown;
1053 1053
 	} else {
1054 1054
 		$walker = $args[2]['walker'];
1055 1055
 	}
1056
-	return call_user_func_array( array( $walker, 'walk' ), $args );
1056
+	return call_user_func_array(array($walker, 'walk'), $args);
1057 1057
 }
1058 1058
 
1059 1059
 //
@@ -1069,13 +1069,13 @@  discard block
 block discarded – undo
1069 1069
  * @param int|object $tag Tag ID or object.
1070 1070
  * @return string Link on success, empty string if tag does not exist.
1071 1071
  */
1072
-function get_tag_link( $tag ) {
1073
-	if ( ! is_object( $tag ) )
1072
+function get_tag_link($tag) {
1073
+	if ( ! is_object($tag))
1074 1074
 		$tag = (int) $tag;
1075 1075
 
1076
-	$tag = get_term_link( $tag, 'post_tag' );
1076
+	$tag = get_term_link($tag, 'post_tag');
1077 1077
 
1078
-	if ( is_wp_error( $tag ) )
1078
+	if (is_wp_error($tag))
1079 1079
 		return '';
1080 1080
 
1081 1081
 	return $tag;
@@ -1089,7 +1089,7 @@  discard block
 block discarded – undo
1089 1089
  * @param int $id Post ID.
1090 1090
  * @return array|false|WP_Error Array of tag objects on success, false on failure.
1091 1091
  */
1092
-function get_the_tags( $id = 0 ) {
1092
+function get_the_tags($id = 0) {
1093 1093
 
1094 1094
 	/**
1095 1095
 	 * Filters the array of tags for the given post.
@@ -1100,7 +1100,7 @@  discard block
 block discarded – undo
1100 1100
 	 *
1101 1101
 	 * @param array $terms An array of tags for the given post.
1102 1102
 	 */
1103
-	return apply_filters( 'get_the_tags', get_the_terms( $id, 'post_tag' ) );
1103
+	return apply_filters('get_the_tags', get_the_terms($id, 'post_tag'));
1104 1104
 }
1105 1105
 
1106 1106
 /**
@@ -1114,7 +1114,7 @@  discard block
 block discarded – undo
1114 1114
  * @param int $id Optional. Post ID. Defaults to the current post.
1115 1115
  * @return string|false|WP_Error A list of tags on success, false if there are no terms, WP_Error on failure.
1116 1116
  */
1117
-function get_the_tag_list( $before = '', $sep = '', $after = '', $id = 0 ) {
1117
+function get_the_tag_list($before = '', $sep = '', $after = '', $id = 0) {
1118 1118
 
1119 1119
 	/**
1120 1120
 	 * Filters the tags list for a given post.
@@ -1127,7 +1127,7 @@  discard block
 block discarded – undo
1127 1127
 	 * @param string $after    String to use after tags.
1128 1128
 	 * @param int    $id       Post ID.
1129 1129
 	 */
1130
-	return apply_filters( 'the_tags', get_the_term_list( $id, 'post_tag', $before, $sep, $after ), $before, $sep, $after, $id );
1130
+	return apply_filters('the_tags', get_the_term_list($id, 'post_tag', $before, $sep, $after), $before, $sep, $after, $id);
1131 1131
 }
1132 1132
 
1133 1133
 /**
@@ -1139,8 +1139,8 @@  discard block
 block discarded – undo
1139 1139
  * @param string $sep Optional. Separate items using this.
1140 1140
  * @param string $after Optional. After list.
1141 1141
  */
1142
-function the_tags( $before = null, $sep = ', ', $after = '' ) {
1143
-	if ( null === $before )
1142
+function the_tags($before = null, $sep = ', ', $after = '') {
1143
+	if (null === $before)
1144 1144
 		$before = __('Tags: ');
1145 1145
 	echo get_the_tag_list($before, $sep, $after);
1146 1146
 }
@@ -1153,8 +1153,8 @@  discard block
 block discarded – undo
1153 1153
  * @param int $tag Optional. Tag ID. Will use global tag ID by default.
1154 1154
  * @return string Tag description, available.
1155 1155
  */
1156
-function tag_description( $tag = 0 ) {
1157
-	return term_description( $tag );
1156
+function tag_description($tag = 0) {
1157
+	return term_description($tag);
1158 1158
 }
1159 1159
 
1160 1160
 /**
@@ -1166,16 +1166,16 @@  discard block
 block discarded – undo
1166 1166
  * @param string $taxonomy Optional taxonomy name. Defaults to 'post_tag'.
1167 1167
  * @return string Term description, available.
1168 1168
  */
1169
-function term_description( $term = 0, $taxonomy = 'post_tag' ) {
1170
-	if ( ! $term && ( is_tax() || is_tag() || is_category() ) ) {
1169
+function term_description($term = 0, $taxonomy = 'post_tag') {
1170
+	if ( ! $term && (is_tax() || is_tag() || is_category())) {
1171 1171
 		$term = get_queried_object();
1172
-		if ( $term ) {
1172
+		if ($term) {
1173 1173
 			$taxonomy = $term->taxonomy;
1174 1174
 			$term = $term->term_id;
1175 1175
 		}
1176 1176
 	}
1177
-	$description = get_term_field( 'description', $term, $taxonomy );
1178
-	return is_wp_error( $description ) ? '' : $description;
1177
+	$description = get_term_field('description', $term, $taxonomy);
1178
+	return is_wp_error($description) ? '' : $description;
1179 1179
 }
1180 1180
 
1181 1181
 /**
@@ -1188,16 +1188,16 @@  discard block
 block discarded – undo
1188 1188
  * @return array|false|WP_Error Array of WP_Term objects on success, false if there are no terms
1189 1189
  *                              or the post does not exist, WP_Error on failure.
1190 1190
  */
1191
-function get_the_terms( $post, $taxonomy ) {
1192
-	if ( ! $post = get_post( $post ) )
1191
+function get_the_terms($post, $taxonomy) {
1192
+	if ( ! $post = get_post($post))
1193 1193
 		return false;
1194 1194
 
1195
-	$terms = get_object_term_cache( $post->ID, $taxonomy );
1196
-	if ( false === $terms ) {
1197
-		$terms = wp_get_object_terms( $post->ID, $taxonomy );
1198
-		if ( ! is_wp_error( $terms ) ) {
1199
-			$term_ids = wp_list_pluck( $terms, 'term_id' );
1200
-			wp_cache_add( $post->ID, $term_ids, $taxonomy . '_relationships' );
1195
+	$terms = get_object_term_cache($post->ID, $taxonomy);
1196
+	if (false === $terms) {
1197
+		$terms = wp_get_object_terms($post->ID, $taxonomy);
1198
+		if ( ! is_wp_error($terms)) {
1199
+			$term_ids = wp_list_pluck($terms, 'term_id');
1200
+			wp_cache_add($post->ID, $term_ids, $taxonomy.'_relationships');
1201 1201
 		}
1202 1202
 	}
1203 1203
 
@@ -1210,9 +1210,9 @@  discard block
 block discarded – undo
1210 1210
 	 * @param int            $post_id  Post ID.
1211 1211
 	 * @param string         $taxonomy Name of the taxonomy.
1212 1212
 	 */
1213
-	$terms = apply_filters( 'get_the_terms', $terms, $post->ID, $taxonomy );
1213
+	$terms = apply_filters('get_the_terms', $terms, $post->ID, $taxonomy);
1214 1214
 
1215
-	if ( empty( $terms ) )
1215
+	if (empty($terms))
1216 1216
 		return false;
1217 1217
 
1218 1218
 	return $terms;
@@ -1230,23 +1230,23 @@  discard block
 block discarded – undo
1230 1230
  * @param string $after Optional. After list.
1231 1231
  * @return string|false|WP_Error A list of terms on success, false if there are no terms, WP_Error on failure.
1232 1232
  */
1233
-function get_the_term_list( $id, $taxonomy, $before = '', $sep = '', $after = '' ) {
1234
-	$terms = get_the_terms( $id, $taxonomy );
1233
+function get_the_term_list($id, $taxonomy, $before = '', $sep = '', $after = '') {
1234
+	$terms = get_the_terms($id, $taxonomy);
1235 1235
 
1236
-	if ( is_wp_error( $terms ) )
1236
+	if (is_wp_error($terms))
1237 1237
 		return $terms;
1238 1238
 
1239
-	if ( empty( $terms ) )
1239
+	if (empty($terms))
1240 1240
 		return false;
1241 1241
 
1242 1242
 	$links = array();
1243 1243
 
1244
-	foreach ( $terms as $term ) {
1245
-		$link = get_term_link( $term, $taxonomy );
1246
-		if ( is_wp_error( $link ) ) {
1244
+	foreach ($terms as $term) {
1245
+		$link = get_term_link($term, $taxonomy);
1246
+		if (is_wp_error($link)) {
1247 1247
 			return $link;
1248 1248
 		}
1249
-		$links[] = '<a href="' . esc_url( $link ) . '" rel="tag">' . $term->name . '</a>';
1249
+		$links[] = '<a href="'.esc_url($link).'" rel="tag">'.$term->name.'</a>';
1250 1250
 	}
1251 1251
 
1252 1252
 	/**
@@ -1259,9 +1259,9 @@  discard block
 block discarded – undo
1259 1259
 	 *
1260 1260
 	 * @param array $links An array of term links.
1261 1261
 	 */
1262
-	$term_links = apply_filters( "term_links-$taxonomy", $links );
1262
+	$term_links = apply_filters("term_links-$taxonomy", $links);
1263 1263
 
1264
-	return $before . join( $sep, $term_links ) . $after;
1264
+	return $before.join($sep, $term_links).$after;
1265 1265
 }
1266 1266
 
1267 1267
 /**
@@ -1276,10 +1276,10 @@  discard block
 block discarded – undo
1276 1276
  * @param string $after Optional. After list.
1277 1277
  * @return false|void False on WordPress error.
1278 1278
  */
1279
-function the_terms( $id, $taxonomy, $before = '', $sep = ', ', $after = '' ) {
1280
-	$term_list = get_the_term_list( $id, $taxonomy, $before, $sep, $after );
1279
+function the_terms($id, $taxonomy, $before = '', $sep = ', ', $after = '') {
1280
+	$term_list = get_the_term_list($id, $taxonomy, $before, $sep, $after);
1281 1281
 
1282
-	if ( is_wp_error( $term_list ) )
1282
+	if (is_wp_error($term_list))
1283 1283
 		return false;
1284 1284
 
1285 1285
 	/**
@@ -1293,7 +1293,7 @@  discard block
 block discarded – undo
1293 1293
 	 * @param string $sep       String to use between the terms.
1294 1294
 	 * @param string $after     String to use after the terms.
1295 1295
 	 */
1296
-	echo apply_filters( 'the_terms', $term_list, $taxonomy, $before, $sep, $after );
1296
+	echo apply_filters('the_terms', $term_list, $taxonomy, $before, $sep, $after);
1297 1297
 }
1298 1298
 
1299 1299
 /**
@@ -1305,8 +1305,8 @@  discard block
 block discarded – undo
1305 1305
  * @param int|object $post Optional. Post to check instead of the current post.
1306 1306
  * @return bool True if the current post has any of the given categories (or any category, if no category specified).
1307 1307
  */
1308
-function has_category( $category = '', $post = null ) {
1309
-	return has_term( $category, 'category', $post );
1308
+function has_category($category = '', $post = null) {
1309
+	return has_term($category, 'category', $post);
1310 1310
 }
1311 1311
 
1312 1312
 /**
@@ -1326,8 +1326,8 @@  discard block
 block discarded – undo
1326 1326
  * @param int|object $post Optional. Post to check instead of the current post. (since 2.7.0)
1327 1327
  * @return bool True if the current post has any of the given tags (or any tag, if no tag specified).
1328 1328
  */
1329
-function has_tag( $tag = '', $post = null ) {
1330
-	return has_term( $tag, 'post_tag', $post );
1329
+function has_tag($tag = '', $post = null) {
1330
+	return has_term($tag, 'post_tag', $post);
1331 1331
 }
1332 1332
 
1333 1333
 /**
@@ -1344,14 +1344,14 @@  discard block
 block discarded – undo
1344 1344
  * @param int|object $post Optional. Post to check instead of the current post.
1345 1345
  * @return bool True if the current post has any of the given tags (or any tag, if no tag specified).
1346 1346
  */
1347
-function has_term( $term = '', $taxonomy = '', $post = null ) {
1347
+function has_term($term = '', $taxonomy = '', $post = null) {
1348 1348
 	$post = get_post($post);
1349 1349
 
1350
-	if ( !$post )
1350
+	if ( ! $post)
1351 1351
 		return false;
1352 1352
 
1353
-	$r = is_object_in_term( $post->ID, $taxonomy, $term );
1354
-	if ( is_wp_error( $r ) )
1353
+	$r = is_object_in_term($post->ID, $taxonomy, $term);
1354
+	if (is_wp_error($r))
1355 1355
 		return false;
1356 1356
 
1357 1357
 	return $r;
Please login to merge, or discard this patch.
src/wp-includes/class-IXR.php 4 patches
Doc Comments   +6 added lines patch added patch discarded remove patch
@@ -1048,6 +1048,12 @@
 block discarded – undo
1048 1048
 		self::__construct();
1049 1049
 	}
1050 1050
 
1051
+    /**
1052
+     * @param string $method
1053
+     * @param string $callback
1054
+     * @param string[] $args
1055
+     * @param string $help
1056
+     */
1051 1057
     function addCallback($method, $callback, $args, $help)
1052 1058
     {
1053 1059
         $this->callbacks[$method] = $callback;
Please login to merge, or discard this patch.
Braces   +10 added lines, -8 removed lines patch added patch discarded remove patch
@@ -534,17 +534,19 @@
 block discarded – undo
534 534
     function output($xml)
535 535
     {
536 536
         $charset = function_exists('get_option') ? get_option('blog_charset') : '';
537
-        if ($charset)
538
-            $xml = '<?xml version="1.0" encoding="'.$charset.'"?>'."\n".$xml;
539
-        else
540
-            $xml = '<?xml version="1.0"?>'."\n".$xml;
537
+        if ($charset) {
538
+                    $xml = '<?xml version="1.0" encoding="'.$charset.'"?>'."\n".$xml;
539
+        } else {
540
+                    $xml = '<?xml version="1.0"?>'."\n".$xml;
541
+        }
541 542
         $length = strlen($xml);
542 543
         header('Connection: close');
543 544
         header('Content-Length: '.$length);
544
-        if ($charset)
545
-            header('Content-Type: text/xml; charset='.$charset);
546
-        else
547
-            header('Content-Type: text/xml');
545
+        if ($charset) {
546
+                    header('Content-Type: text/xml; charset='.$charset);
547
+        } else {
548
+                    header('Content-Type: text/xml');
549
+        }
548 550
         header('Date: '.date('r'));
549 551
         echo $xml;
550 552
         exit;
Please login to merge, or discard this patch.
Indentation   +923 added lines, -923 removed lines patch added patch discarded remove patch
@@ -46,31 +46,31 @@  discard block
 block discarded – undo
46 46
  * @since 1.5.0
47 47
  */
48 48
 class IXR_Value {
49
-    var $data;
50
-    var $type;
49
+	var $data;
50
+	var $type;
51 51
 
52 52
 	/**
53 53
 	 * PHP5 constructor.
54 54
 	 */
55 55
 	function __construct( $data, $type = false )
56
-    {
57
-        $this->data = $data;
58
-        if (!$type) {
59
-            $type = $this->calculateType();
60
-        }
61
-        $this->type = $type;
62
-        if ($type == 'struct') {
63
-            // Turn all the values in the array in to new IXR_Value objects
64
-            foreach ($this->data as $key => $value) {
65
-                $this->data[$key] = new IXR_Value($value);
66
-            }
67
-        }
68
-        if ($type == 'array') {
69
-            for ($i = 0, $j = count($this->data); $i < $j; $i++) {
70
-                $this->data[$i] = new IXR_Value($this->data[$i]);
71
-            }
72
-        }
73
-    }
56
+	{
57
+		$this->data = $data;
58
+		if (!$type) {
59
+			$type = $this->calculateType();
60
+		}
61
+		$this->type = $type;
62
+		if ($type == 'struct') {
63
+			// Turn all the values in the array in to new IXR_Value objects
64
+			foreach ($this->data as $key => $value) {
65
+				$this->data[$key] = new IXR_Value($value);
66
+			}
67
+		}
68
+		if ($type == 'array') {
69
+			for ($i = 0, $j = count($this->data); $i < $j; $i++) {
70
+				$this->data[$i] = new IXR_Value($this->data[$i]);
71
+			}
72
+		}
73
+	}
74 74
 
75 75
 	/**
76 76
 	 * PHP4 constructor.
@@ -79,102 +79,102 @@  discard block
 block discarded – undo
79 79
 		self::__construct( $data, $type );
80 80
 	}
81 81
 
82
-    function calculateType()
83
-    {
84
-        if ($this->data === true || $this->data === false) {
85
-            return 'boolean';
86
-        }
87
-        if (is_integer($this->data)) {
88
-            return 'int';
89
-        }
90
-        if (is_double($this->data)) {
91
-            return 'double';
92
-        }
93
-
94
-        // Deal with IXR object types base64 and date
95
-        if (is_object($this->data) && is_a($this->data, 'IXR_Date')) {
96
-            return 'date';
97
-        }
98
-        if (is_object($this->data) && is_a($this->data, 'IXR_Base64')) {
99
-            return 'base64';
100
-        }
101
-
102
-        // If it is a normal PHP object convert it in to a struct
103
-        if (is_object($this->data)) {
104
-            $this->data = get_object_vars($this->data);
105
-            return 'struct';
106
-        }
107
-        if (!is_array($this->data)) {
108
-            return 'string';
109
-        }
110
-
111
-        // We have an array - is it an array or a struct?
112
-        if ($this->isStruct($this->data)) {
113
-            return 'struct';
114
-        } else {
115
-            return 'array';
116
-        }
117
-    }
118
-
119
-    function getXml()
120
-    {
121
-        // Return XML for this value
122
-        switch ($this->type) {
123
-            case 'boolean':
124
-                return '<boolean>'.(($this->data) ? '1' : '0').'</boolean>';
125
-                break;
126
-            case 'int':
127
-                return '<int>'.$this->data.'</int>';
128
-                break;
129
-            case 'double':
130
-                return '<double>'.$this->data.'</double>';
131
-                break;
132
-            case 'string':
133
-                return '<string>'.htmlspecialchars($this->data).'</string>';
134
-                break;
135
-            case 'array':
136
-                $return = '<array><data>'."\n";
137
-                foreach ($this->data as $item) {
138
-                    $return .= '  <value>'.$item->getXml()."</value>\n";
139
-                }
140
-                $return .= '</data></array>';
141
-                return $return;
142
-                break;
143
-            case 'struct':
144
-                $return = '<struct>'."\n";
145
-                foreach ($this->data as $name => $value) {
82
+	function calculateType()
83
+	{
84
+		if ($this->data === true || $this->data === false) {
85
+			return 'boolean';
86
+		}
87
+		if (is_integer($this->data)) {
88
+			return 'int';
89
+		}
90
+		if (is_double($this->data)) {
91
+			return 'double';
92
+		}
93
+
94
+		// Deal with IXR object types base64 and date
95
+		if (is_object($this->data) && is_a($this->data, 'IXR_Date')) {
96
+			return 'date';
97
+		}
98
+		if (is_object($this->data) && is_a($this->data, 'IXR_Base64')) {
99
+			return 'base64';
100
+		}
101
+
102
+		// If it is a normal PHP object convert it in to a struct
103
+		if (is_object($this->data)) {
104
+			$this->data = get_object_vars($this->data);
105
+			return 'struct';
106
+		}
107
+		if (!is_array($this->data)) {
108
+			return 'string';
109
+		}
110
+
111
+		// We have an array - is it an array or a struct?
112
+		if ($this->isStruct($this->data)) {
113
+			return 'struct';
114
+		} else {
115
+			return 'array';
116
+		}
117
+	}
118
+
119
+	function getXml()
120
+	{
121
+		// Return XML for this value
122
+		switch ($this->type) {
123
+			case 'boolean':
124
+				return '<boolean>'.(($this->data) ? '1' : '0').'</boolean>';
125
+				break;
126
+			case 'int':
127
+				return '<int>'.$this->data.'</int>';
128
+				break;
129
+			case 'double':
130
+				return '<double>'.$this->data.'</double>';
131
+				break;
132
+			case 'string':
133
+				return '<string>'.htmlspecialchars($this->data).'</string>';
134
+				break;
135
+			case 'array':
136
+				$return = '<array><data>'."\n";
137
+				foreach ($this->data as $item) {
138
+					$return .= '  <value>'.$item->getXml()."</value>\n";
139
+				}
140
+				$return .= '</data></array>';
141
+				return $return;
142
+				break;
143
+			case 'struct':
144
+				$return = '<struct>'."\n";
145
+				foreach ($this->data as $name => $value) {
146 146
 					$name = htmlspecialchars($name);
147
-                    $return .= "  <member><name>$name</name><value>";
148
-                    $return .= $value->getXml()."</value></member>\n";
149
-                }
150
-                $return .= '</struct>';
151
-                return $return;
152
-                break;
153
-            case 'date':
154
-            case 'base64':
155
-                return $this->data->getXml();
156
-                break;
157
-        }
158
-        return false;
159
-    }
160
-
161
-    /**
162
-     * Checks whether or not the supplied array is a struct or not
163
-     *
164
-     * @param array $array
165
-     * @return bool
166
-     */
167
-    function isStruct($array)
168
-    {
169
-        $expected = 0;
170
-        foreach ($array as $key => $value) {
171
-            if ((string)$key !== (string)$expected) {
172
-                return true;
173
-            }
174
-            $expected++;
175
-        }
176
-        return false;
177
-    }
147
+					$return .= "  <member><name>$name</name><value>";
148
+					$return .= $value->getXml()."</value></member>\n";
149
+				}
150
+				$return .= '</struct>';
151
+				return $return;
152
+				break;
153
+			case 'date':
154
+			case 'base64':
155
+				return $this->data->getXml();
156
+				break;
157
+		}
158
+		return false;
159
+	}
160
+
161
+	/**
162
+	 * Checks whether or not the supplied array is a struct or not
163
+	 *
164
+	 * @param array $array
165
+	 * @return bool
166
+	 */
167
+	function isStruct($array)
168
+	{
169
+		$expected = 0;
170
+		foreach ($array as $key => $value) {
171
+			if ((string)$key !== (string)$expected) {
172
+				return true;
173
+			}
174
+			$expected++;
175
+		}
176
+		return false;
177
+	}
178 178
 }
179 179
 
180 180
 /**
@@ -186,31 +186,31 @@  discard block
 block discarded – undo
186 186
  */
187 187
 class IXR_Message
188 188
 {
189
-    var $message;
190
-    var $messageType;  // methodCall / methodResponse / fault
191
-    var $faultCode;
192
-    var $faultString;
193
-    var $methodName;
194
-    var $params;
195
-
196
-    // Current variable stacks
197
-    var $_arraystructs = array();   // The stack used to keep track of the current array/struct
198
-    var $_arraystructstypes = array(); // Stack keeping track of if things are structs or array
199
-    var $_currentStructName = array();  // A stack as well
200
-    var $_param;
201
-    var $_value;
202
-    var $_currentTag;
203
-    var $_currentTagContents;
204
-    // The XML parser
205
-    var $_parser;
189
+	var $message;
190
+	var $messageType;  // methodCall / methodResponse / fault
191
+	var $faultCode;
192
+	var $faultString;
193
+	var $methodName;
194
+	var $params;
195
+
196
+	// Current variable stacks
197
+	var $_arraystructs = array();   // The stack used to keep track of the current array/struct
198
+	var $_arraystructstypes = array(); // Stack keeping track of if things are structs or array
199
+	var $_currentStructName = array();  // A stack as well
200
+	var $_param;
201
+	var $_value;
202
+	var $_currentTag;
203
+	var $_currentTagContents;
204
+	// The XML parser
205
+	var $_parser;
206 206
 
207 207
 	/**
208 208
 	 * PHP5 constructor.
209 209
 	 */
210
-    function __construct( $message )
211
-    {
212
-        $this->message =& $message;
213
-    }
210
+	function __construct( $message )
211
+	{
212
+		$this->message =& $message;
213
+	}
214 214
 
215 215
 	/**
216 216
 	 * PHP4 constructor.
@@ -219,190 +219,190 @@  discard block
 block discarded – undo
219 219
 		self::__construct( $message );
220 220
 	}
221 221
 
222
-    function parse()
223
-    {
224
-        // first remove the XML declaration
225
-        // merged from WP #10698 - this method avoids the RAM usage of preg_replace on very large messages
226
-        $header = preg_replace( '/<\?xml.*?\?'.'>/s', '', substr( $this->message, 0, 100 ), 1 );
227
-        $this->message = trim( substr_replace( $this->message, $header, 0, 100 ) );
228
-        if ( '' == $this->message ) {
229
-            return false;
230
-        }
231
-
232
-        // Then remove the DOCTYPE
233
-        $header = preg_replace( '/^<!DOCTYPE[^>]*+>/i', '', substr( $this->message, 0, 200 ), 1 );
234
-        $this->message = trim( substr_replace( $this->message, $header, 0, 200 ) );
235
-        if ( '' == $this->message ) {
236
-            return false;
237
-        }
238
-
239
-        // Check that the root tag is valid
240
-        $root_tag = substr( $this->message, 0, strcspn( substr( $this->message, 0, 20 ), "> \t\r\n" ) );
241
-        if ( '<!DOCTYPE' === strtoupper( $root_tag ) ) {
242
-            return false;
243
-        }
244
-        if ( ! in_array( $root_tag, array( '<methodCall', '<methodResponse', '<fault' ) ) ) {
245
-            return false;
246
-        }
247
-
248
-        // Bail if there are too many elements to parse
249
-        $element_limit = 30000;
250
-        if ( function_exists( 'apply_filters' ) ) {
251
-            /**
252
-             * Filters the number of elements to parse in an XML-RPC response.
253
-             *
254
-             * @since 4.0.0
255
-             *
256
-             * @param int $element_limit Default elements limit.
257
-             */
258
-            $element_limit = apply_filters( 'xmlrpc_element_limit', $element_limit );
259
-        }
260
-        if ( $element_limit && 2 * $element_limit < substr_count( $this->message, '<' ) ) {
261
-            return false;
262
-        }
263
-
264
-        $this->_parser = xml_parser_create();
265
-        // Set XML parser to take the case of tags in to account
266
-        xml_parser_set_option($this->_parser, XML_OPTION_CASE_FOLDING, false);
267
-        // Set XML parser callback functions
268
-        xml_set_object($this->_parser, $this);
269
-        xml_set_element_handler($this->_parser, 'tag_open', 'tag_close');
270
-        xml_set_character_data_handler($this->_parser, 'cdata');
271
-
272
-        // 256Kb, parse in chunks to avoid the RAM usage on very large messages
273
-        $chunk_size = 262144;
274
-
275
-        /**
276
-         * Filters the chunk size that can be used to parse an XML-RPC reponse message.
277
-         *
278
-         * @since 4.4.0
279
-         *
280
-         * @param int $chunk_size Chunk size to parse in bytes.
281
-         */
282
-        $chunk_size = apply_filters( 'xmlrpc_chunk_parsing_size', $chunk_size );
283
-
284
-        $final = false;
285
-        do {
286
-            if (strlen($this->message) <= $chunk_size) {
287
-                $final = true;
288
-            }
289
-            $part = substr($this->message, 0, $chunk_size);
290
-            $this->message = substr($this->message, $chunk_size);
291
-            if (!xml_parse($this->_parser, $part, $final)) {
292
-                return false;
293
-            }
294
-            if ($final) {
295
-                break;
296
-            }
297
-        } while (true);
298
-        xml_parser_free($this->_parser);
299
-
300
-        // Grab the error messages, if any
301
-        if ($this->messageType == 'fault') {
302
-            $this->faultCode = $this->params[0]['faultCode'];
303
-            $this->faultString = $this->params[0]['faultString'];
304
-        }
305
-        return true;
306
-    }
307
-
308
-    function tag_open($parser, $tag, $attr)
309
-    {
310
-        $this->_currentTagContents = '';
311
-        $this->currentTag = $tag;
312
-        switch($tag) {
313
-            case 'methodCall':
314
-            case 'methodResponse':
315
-            case 'fault':
316
-                $this->messageType = $tag;
317
-                break;
318
-                /* Deal with stacks of arrays and structs */
319
-            case 'data':    // data is to all intents and puposes more interesting than array
320
-                $this->_arraystructstypes[] = 'array';
321
-                $this->_arraystructs[] = array();
322
-                break;
323
-            case 'struct':
324
-                $this->_arraystructstypes[] = 'struct';
325
-                $this->_arraystructs[] = array();
326
-                break;
327
-        }
328
-    }
329
-
330
-    function cdata($parser, $cdata)
331
-    {
332
-        $this->_currentTagContents .= $cdata;
333
-    }
334
-
335
-    function tag_close($parser, $tag)
336
-    {
337
-        $valueFlag = false;
338
-        switch($tag) {
339
-            case 'int':
340
-            case 'i4':
341
-                $value = (int)trim($this->_currentTagContents);
342
-                $valueFlag = true;
343
-                break;
344
-            case 'double':
345
-                $value = (double)trim($this->_currentTagContents);
346
-                $valueFlag = true;
347
-                break;
348
-            case 'string':
349
-                $value = (string)trim($this->_currentTagContents);
350
-                $valueFlag = true;
351
-                break;
352
-            case 'dateTime.iso8601':
353
-                $value = new IXR_Date(trim($this->_currentTagContents));
354
-                $valueFlag = true;
355
-                break;
356
-            case 'value':
357
-                // "If no type is indicated, the type is string."
358
-                if (trim($this->_currentTagContents) != '') {
359
-                    $value = (string)$this->_currentTagContents;
360
-                    $valueFlag = true;
361
-                }
362
-                break;
363
-            case 'boolean':
364
-                $value = (boolean)trim($this->_currentTagContents);
365
-                $valueFlag = true;
366
-                break;
367
-            case 'base64':
368
-                $value = base64_decode($this->_currentTagContents);
369
-                $valueFlag = true;
370
-                break;
371
-                /* Deal with stacks of arrays and structs */
372
-            case 'data':
373
-            case 'struct':
374
-                $value = array_pop($this->_arraystructs);
375
-                array_pop($this->_arraystructstypes);
376
-                $valueFlag = true;
377
-                break;
378
-            case 'member':
379
-                array_pop($this->_currentStructName);
380
-                break;
381
-            case 'name':
382
-                $this->_currentStructName[] = trim($this->_currentTagContents);
383
-                break;
384
-            case 'methodName':
385
-                $this->methodName = trim($this->_currentTagContents);
386
-                break;
387
-        }
388
-
389
-        if ($valueFlag) {
390
-            if (count($this->_arraystructs) > 0) {
391
-                // Add value to struct or array
392
-                if ($this->_arraystructstypes[count($this->_arraystructstypes)-1] == 'struct') {
393
-                    // Add to struct
394
-                    $this->_arraystructs[count($this->_arraystructs)-1][$this->_currentStructName[count($this->_currentStructName)-1]] = $value;
395
-                } else {
396
-                    // Add to array
397
-                    $this->_arraystructs[count($this->_arraystructs)-1][] = $value;
398
-                }
399
-            } else {
400
-                // Just add as a parameter
401
-                $this->params[] = $value;
402
-            }
403
-        }
404
-        $this->_currentTagContents = '';
405
-    }
222
+	function parse()
223
+	{
224
+		// first remove the XML declaration
225
+		// merged from WP #10698 - this method avoids the RAM usage of preg_replace on very large messages
226
+		$header = preg_replace( '/<\?xml.*?\?'.'>/s', '', substr( $this->message, 0, 100 ), 1 );
227
+		$this->message = trim( substr_replace( $this->message, $header, 0, 100 ) );
228
+		if ( '' == $this->message ) {
229
+			return false;
230
+		}
231
+
232
+		// Then remove the DOCTYPE
233
+		$header = preg_replace( '/^<!DOCTYPE[^>]*+>/i', '', substr( $this->message, 0, 200 ), 1 );
234
+		$this->message = trim( substr_replace( $this->message, $header, 0, 200 ) );
235
+		if ( '' == $this->message ) {
236
+			return false;
237
+		}
238
+
239
+		// Check that the root tag is valid
240
+		$root_tag = substr( $this->message, 0, strcspn( substr( $this->message, 0, 20 ), "> \t\r\n" ) );
241
+		if ( '<!DOCTYPE' === strtoupper( $root_tag ) ) {
242
+			return false;
243
+		}
244
+		if ( ! in_array( $root_tag, array( '<methodCall', '<methodResponse', '<fault' ) ) ) {
245
+			return false;
246
+		}
247
+
248
+		// Bail if there are too many elements to parse
249
+		$element_limit = 30000;
250
+		if ( function_exists( 'apply_filters' ) ) {
251
+			/**
252
+			 * Filters the number of elements to parse in an XML-RPC response.
253
+			 *
254
+			 * @since 4.0.0
255
+			 *
256
+			 * @param int $element_limit Default elements limit.
257
+			 */
258
+			$element_limit = apply_filters( 'xmlrpc_element_limit', $element_limit );
259
+		}
260
+		if ( $element_limit && 2 * $element_limit < substr_count( $this->message, '<' ) ) {
261
+			return false;
262
+		}
263
+
264
+		$this->_parser = xml_parser_create();
265
+		// Set XML parser to take the case of tags in to account
266
+		xml_parser_set_option($this->_parser, XML_OPTION_CASE_FOLDING, false);
267
+		// Set XML parser callback functions
268
+		xml_set_object($this->_parser, $this);
269
+		xml_set_element_handler($this->_parser, 'tag_open', 'tag_close');
270
+		xml_set_character_data_handler($this->_parser, 'cdata');
271
+
272
+		// 256Kb, parse in chunks to avoid the RAM usage on very large messages
273
+		$chunk_size = 262144;
274
+
275
+		/**
276
+		 * Filters the chunk size that can be used to parse an XML-RPC reponse message.
277
+		 *
278
+		 * @since 4.4.0
279
+		 *
280
+		 * @param int $chunk_size Chunk size to parse in bytes.
281
+		 */
282
+		$chunk_size = apply_filters( 'xmlrpc_chunk_parsing_size', $chunk_size );
283
+
284
+		$final = false;
285
+		do {
286
+			if (strlen($this->message) <= $chunk_size) {
287
+				$final = true;
288
+			}
289
+			$part = substr($this->message, 0, $chunk_size);
290
+			$this->message = substr($this->message, $chunk_size);
291
+			if (!xml_parse($this->_parser, $part, $final)) {
292
+				return false;
293
+			}
294
+			if ($final) {
295
+				break;
296
+			}
297
+		} while (true);
298
+		xml_parser_free($this->_parser);
299
+
300
+		// Grab the error messages, if any
301
+		if ($this->messageType == 'fault') {
302
+			$this->faultCode = $this->params[0]['faultCode'];
303
+			$this->faultString = $this->params[0]['faultString'];
304
+		}
305
+		return true;
306
+	}
307
+
308
+	function tag_open($parser, $tag, $attr)
309
+	{
310
+		$this->_currentTagContents = '';
311
+		$this->currentTag = $tag;
312
+		switch($tag) {
313
+			case 'methodCall':
314
+			case 'methodResponse':
315
+			case 'fault':
316
+				$this->messageType = $tag;
317
+				break;
318
+				/* Deal with stacks of arrays and structs */
319
+			case 'data':    // data is to all intents and puposes more interesting than array
320
+				$this->_arraystructstypes[] = 'array';
321
+				$this->_arraystructs[] = array();
322
+				break;
323
+			case 'struct':
324
+				$this->_arraystructstypes[] = 'struct';
325
+				$this->_arraystructs[] = array();
326
+				break;
327
+		}
328
+	}
329
+
330
+	function cdata($parser, $cdata)
331
+	{
332
+		$this->_currentTagContents .= $cdata;
333
+	}
334
+
335
+	function tag_close($parser, $tag)
336
+	{
337
+		$valueFlag = false;
338
+		switch($tag) {
339
+			case 'int':
340
+			case 'i4':
341
+				$value = (int)trim($this->_currentTagContents);
342
+				$valueFlag = true;
343
+				break;
344
+			case 'double':
345
+				$value = (double)trim($this->_currentTagContents);
346
+				$valueFlag = true;
347
+				break;
348
+			case 'string':
349
+				$value = (string)trim($this->_currentTagContents);
350
+				$valueFlag = true;
351
+				break;
352
+			case 'dateTime.iso8601':
353
+				$value = new IXR_Date(trim($this->_currentTagContents));
354
+				$valueFlag = true;
355
+				break;
356
+			case 'value':
357
+				// "If no type is indicated, the type is string."
358
+				if (trim($this->_currentTagContents) != '') {
359
+					$value = (string)$this->_currentTagContents;
360
+					$valueFlag = true;
361
+				}
362
+				break;
363
+			case 'boolean':
364
+				$value = (boolean)trim($this->_currentTagContents);
365
+				$valueFlag = true;
366
+				break;
367
+			case 'base64':
368
+				$value = base64_decode($this->_currentTagContents);
369
+				$valueFlag = true;
370
+				break;
371
+				/* Deal with stacks of arrays and structs */
372
+			case 'data':
373
+			case 'struct':
374
+				$value = array_pop($this->_arraystructs);
375
+				array_pop($this->_arraystructstypes);
376
+				$valueFlag = true;
377
+				break;
378
+			case 'member':
379
+				array_pop($this->_currentStructName);
380
+				break;
381
+			case 'name':
382
+				$this->_currentStructName[] = trim($this->_currentTagContents);
383
+				break;
384
+			case 'methodName':
385
+				$this->methodName = trim($this->_currentTagContents);
386
+				break;
387
+		}
388
+
389
+		if ($valueFlag) {
390
+			if (count($this->_arraystructs) > 0) {
391
+				// Add value to struct or array
392
+				if ($this->_arraystructstypes[count($this->_arraystructstypes)-1] == 'struct') {
393
+					// Add to struct
394
+					$this->_arraystructs[count($this->_arraystructs)-1][$this->_currentStructName[count($this->_currentStructName)-1]] = $value;
395
+				} else {
396
+					// Add to array
397
+					$this->_arraystructs[count($this->_arraystructs)-1][] = $value;
398
+				}
399
+			} else {
400
+				// Just add as a parameter
401
+				$this->params[] = $value;
402
+			}
403
+		}
404
+		$this->_currentTagContents = '';
405
+	}
406 406
 }
407 407
 
408 408
 /**
@@ -413,25 +413,25 @@  discard block
 block discarded – undo
413 413
  */
414 414
 class IXR_Server
415 415
 {
416
-    var $data;
417
-    var $callbacks = array();
418
-    var $message;
419
-    var $capabilities;
416
+	var $data;
417
+	var $callbacks = array();
418
+	var $message;
419
+	var $capabilities;
420 420
 
421 421
 	/**
422 422
 	 * PHP5 constructor.
423 423
 	 */
424
-    function __construct( $callbacks = false, $data = false, $wait = false )
425
-    {
426
-        $this->setCapabilities();
427
-        if ($callbacks) {
428
-            $this->callbacks = $callbacks;
429
-        }
430
-        $this->setCallbacks();
431
-        if (!$wait) {
432
-            $this->serve($data);
433
-        }
434
-    }
424
+	function __construct( $callbacks = false, $data = false, $wait = false )
425
+	{
426
+		$this->setCapabilities();
427
+		if ($callbacks) {
428
+			$this->callbacks = $callbacks;
429
+		}
430
+		$this->setCallbacks();
431
+		if (!$wait) {
432
+			$this->serve($data);
433
+		}
434
+	}
435 435
 
436 436
 	/**
437 437
 	 * PHP4 constructor.
@@ -440,46 +440,46 @@  discard block
 block discarded – undo
440 440
 		self::__construct( $callbacks, $data, $wait );
441 441
 	}
442 442
 
443
-    function serve($data = false)
444
-    {
445
-        if (!$data) {
446
-            if (isset($_SERVER['REQUEST_METHOD']) && $_SERVER['REQUEST_METHOD'] !== 'POST') {
447
-                if ( function_exists( 'status_header' ) ) {
448
-                    status_header( 405 ); // WP #20986
449
-                    header( 'Allow: POST' );
450
-                }
451
-                header('Content-Type: text/plain'); // merged from WP #9093
452
-                die('XML-RPC server accepts POST requests only.');
453
-            }
454
-
455
-            global $HTTP_RAW_POST_DATA;
456
-            if (empty($HTTP_RAW_POST_DATA)) {
457
-                // workaround for a bug in PHP 5.2.2 - http://bugs.php.net/bug.php?id=41293
458
-                $data = file_get_contents('php://input');
459
-            } else {
460
-                $data =& $HTTP_RAW_POST_DATA;
461
-            }
462
-        }
463
-        $this->message = new IXR_Message($data);
464
-        if (!$this->message->parse()) {
465
-            $this->error(-32700, 'parse error. not well formed');
466
-        }
467
-        if ($this->message->messageType != 'methodCall') {
468
-            $this->error(-32600, 'server error. invalid xml-rpc. not conforming to spec. Request must be a methodCall');
469
-        }
470
-        $result = $this->call($this->message->methodName, $this->message->params);
471
-
472
-        // Is the result an error?
473
-        if (is_a($result, 'IXR_Error')) {
474
-            $this->error($result);
475
-        }
476
-
477
-        // Encode the result
478
-        $r = new IXR_Value($result);
479
-        $resultxml = $r->getXml();
480
-
481
-        // Create the XML
482
-        $xml = <<<EOD
443
+	function serve($data = false)
444
+	{
445
+		if (!$data) {
446
+			if (isset($_SERVER['REQUEST_METHOD']) && $_SERVER['REQUEST_METHOD'] !== 'POST') {
447
+				if ( function_exists( 'status_header' ) ) {
448
+					status_header( 405 ); // WP #20986
449
+					header( 'Allow: POST' );
450
+				}
451
+				header('Content-Type: text/plain'); // merged from WP #9093
452
+				die('XML-RPC server accepts POST requests only.');
453
+			}
454
+
455
+			global $HTTP_RAW_POST_DATA;
456
+			if (empty($HTTP_RAW_POST_DATA)) {
457
+				// workaround for a bug in PHP 5.2.2 - http://bugs.php.net/bug.php?id=41293
458
+				$data = file_get_contents('php://input');
459
+			} else {
460
+				$data =& $HTTP_RAW_POST_DATA;
461
+			}
462
+		}
463
+		$this->message = new IXR_Message($data);
464
+		if (!$this->message->parse()) {
465
+			$this->error(-32700, 'parse error. not well formed');
466
+		}
467
+		if ($this->message->messageType != 'methodCall') {
468
+			$this->error(-32600, 'server error. invalid xml-rpc. not conforming to spec. Request must be a methodCall');
469
+		}
470
+		$result = $this->call($this->message->methodName, $this->message->params);
471
+
472
+		// Is the result an error?
473
+		if (is_a($result, 'IXR_Error')) {
474
+			$this->error($result);
475
+		}
476
+
477
+		// Encode the result
478
+		$r = new IXR_Value($result);
479
+		$resultxml = $r->getXml();
480
+
481
+		// Create the XML
482
+		$xml = <<<EOD
483 483
 <methodResponse>
484 484
   <params>
485 485
     <param>
@@ -491,142 +491,142 @@  discard block
 block discarded – undo
491 491
 </methodResponse>
492 492
 
493 493
 EOD;
494
-      // Send it
495
-      $this->output($xml);
496
-    }
497
-
498
-    function call($methodname, $args)
499
-    {
500
-        if (!$this->hasMethod($methodname)) {
501
-            return new IXR_Error(-32601, 'server error. requested method '.$methodname.' does not exist.');
502
-        }
503
-        $method = $this->callbacks[$methodname];
504
-
505
-        // Perform the callback and send the response
506
-        if (count($args) == 1) {
507
-            // If only one parameter just send that instead of the whole array
508
-            $args = $args[0];
509
-        }
510
-
511
-        // Are we dealing with a function or a method?
512
-        if (is_string($method) && substr($method, 0, 5) == 'this:') {
513
-            // It's a class method - check it exists
514
-            $method = substr($method, 5);
515
-            if (!method_exists($this, $method)) {
516
-                return new IXR_Error(-32601, 'server error. requested class method "'.$method.'" does not exist.');
517
-            }
518
-
519
-            //Call the method
520
-            $result = $this->$method($args);
521
-        } else {
522
-            // It's a function - does it exist?
523
-            if (is_array($method)) {
524
-                if (!is_callable(array($method[0], $method[1]))) {
525
-                    return new IXR_Error(-32601, 'server error. requested object method "'.$method[1].'" does not exist.');
526
-                }
527
-            } else if (!function_exists($method)) {
528
-                return new IXR_Error(-32601, 'server error. requested function "'.$method.'" does not exist.');
529
-            }
530
-
531
-            // Call the function
532
-            $result = call_user_func($method, $args);
533
-        }
534
-        return $result;
535
-    }
536
-
537
-    function error($error, $message = false)
538
-    {
539
-        // Accepts either an error object or an error code and message
540
-        if ($message && !is_object($error)) {
541
-            $error = new IXR_Error($error, $message);
542
-        }
543
-        $this->output($error->getXml());
544
-    }
545
-
546
-    function output($xml)
547
-    {
548
-        $charset = function_exists('get_option') ? get_option('blog_charset') : '';
549
-        if ($charset)
550
-            $xml = '<?xml version="1.0" encoding="'.$charset.'"?>'."\n".$xml;
551
-        else
552
-            $xml = '<?xml version="1.0"?>'."\n".$xml;
553
-        $length = strlen($xml);
554
-        header('Connection: close');
555
-        if ($charset)
556
-            header('Content-Type: text/xml; charset='.$charset);
557
-        else
558
-            header('Content-Type: text/xml');
559
-        header('Date: '.date('r'));
560
-        echo $xml;
561
-        exit;
562
-    }
563
-
564
-    function hasMethod($method)
565
-    {
566
-        return in_array($method, array_keys($this->callbacks));
567
-    }
568
-
569
-    function setCapabilities()
570
-    {
571
-        // Initialises capabilities array
572
-        $this->capabilities = array(
573
-            'xmlrpc' => array(
574
-                'specUrl' => 'http://www.xmlrpc.com/spec',
575
-                'specVersion' => 1
576
-        ),
577
-            'faults_interop' => array(
578
-                'specUrl' => 'http://xmlrpc-epi.sourceforge.net/specs/rfc.fault_codes.php',
579
-                'specVersion' => 20010516
580
-        ),
581
-            'system.multicall' => array(
582
-                'specUrl' => 'http://www.xmlrpc.com/discuss/msgReader$1208',
583
-                'specVersion' => 1
584
-        ),
585
-        );
586
-    }
587
-
588
-    function getCapabilities($args)
589
-    {
590
-        return $this->capabilities;
591
-    }
592
-
593
-    function setCallbacks()
594
-    {
595
-        $this->callbacks['system.getCapabilities'] = 'this:getCapabilities';
596
-        $this->callbacks['system.listMethods'] = 'this:listMethods';
597
-        $this->callbacks['system.multicall'] = 'this:multiCall';
598
-    }
599
-
600
-    function listMethods($args)
601
-    {
602
-        // Returns a list of methods - uses array_reverse to ensure user defined
603
-        // methods are listed before server defined methods
604
-        return array_reverse(array_keys($this->callbacks));
605
-    }
606
-
607
-    function multiCall($methodcalls)
608
-    {
609
-        // See http://www.xmlrpc.com/discuss/msgReader$1208
610
-        $return = array();
611
-        foreach ($methodcalls as $call) {
612
-            $method = $call['methodName'];
613
-            $params = $call['params'];
614
-            if ($method == 'system.multicall') {
615
-                $result = new IXR_Error(-32600, 'Recursive calls to system.multicall are forbidden');
616
-            } else {
617
-                $result = $this->call($method, $params);
618
-            }
619
-            if (is_a($result, 'IXR_Error')) {
620
-                $return[] = array(
621
-                    'faultCode' => $result->code,
622
-                    'faultString' => $result->message
623
-                );
624
-            } else {
625
-                $return[] = array($result);
626
-            }
627
-        }
628
-        return $return;
629
-    }
494
+	  // Send it
495
+	  $this->output($xml);
496
+	}
497
+
498
+	function call($methodname, $args)
499
+	{
500
+		if (!$this->hasMethod($methodname)) {
501
+			return new IXR_Error(-32601, 'server error. requested method '.$methodname.' does not exist.');
502
+		}
503
+		$method = $this->callbacks[$methodname];
504
+
505
+		// Perform the callback and send the response
506
+		if (count($args) == 1) {
507
+			// If only one parameter just send that instead of the whole array
508
+			$args = $args[0];
509
+		}
510
+
511
+		// Are we dealing with a function or a method?
512
+		if (is_string($method) && substr($method, 0, 5) == 'this:') {
513
+			// It's a class method - check it exists
514
+			$method = substr($method, 5);
515
+			if (!method_exists($this, $method)) {
516
+				return new IXR_Error(-32601, 'server error. requested class method "'.$method.'" does not exist.');
517
+			}
518
+
519
+			//Call the method
520
+			$result = $this->$method($args);
521
+		} else {
522
+			// It's a function - does it exist?
523
+			if (is_array($method)) {
524
+				if (!is_callable(array($method[0], $method[1]))) {
525
+					return new IXR_Error(-32601, 'server error. requested object method "'.$method[1].'" does not exist.');
526
+				}
527
+			} else if (!function_exists($method)) {
528
+				return new IXR_Error(-32601, 'server error. requested function "'.$method.'" does not exist.');
529
+			}
530
+
531
+			// Call the function
532
+			$result = call_user_func($method, $args);
533
+		}
534
+		return $result;
535
+	}
536
+
537
+	function error($error, $message = false)
538
+	{
539
+		// Accepts either an error object or an error code and message
540
+		if ($message && !is_object($error)) {
541
+			$error = new IXR_Error($error, $message);
542
+		}
543
+		$this->output($error->getXml());
544
+	}
545
+
546
+	function output($xml)
547
+	{
548
+		$charset = function_exists('get_option') ? get_option('blog_charset') : '';
549
+		if ($charset)
550
+			$xml = '<?xml version="1.0" encoding="'.$charset.'"?>'."\n".$xml;
551
+		else
552
+			$xml = '<?xml version="1.0"?>'."\n".$xml;
553
+		$length = strlen($xml);
554
+		header('Connection: close');
555
+		if ($charset)
556
+			header('Content-Type: text/xml; charset='.$charset);
557
+		else
558
+			header('Content-Type: text/xml');
559
+		header('Date: '.date('r'));
560
+		echo $xml;
561
+		exit;
562
+	}
563
+
564
+	function hasMethod($method)
565
+	{
566
+		return in_array($method, array_keys($this->callbacks));
567
+	}
568
+
569
+	function setCapabilities()
570
+	{
571
+		// Initialises capabilities array
572
+		$this->capabilities = array(
573
+			'xmlrpc' => array(
574
+				'specUrl' => 'http://www.xmlrpc.com/spec',
575
+				'specVersion' => 1
576
+		),
577
+			'faults_interop' => array(
578
+				'specUrl' => 'http://xmlrpc-epi.sourceforge.net/specs/rfc.fault_codes.php',
579
+				'specVersion' => 20010516
580
+		),
581
+			'system.multicall' => array(
582
+				'specUrl' => 'http://www.xmlrpc.com/discuss/msgReader$1208',
583
+				'specVersion' => 1
584
+		),
585
+		);
586
+	}
587
+
588
+	function getCapabilities($args)
589
+	{
590
+		return $this->capabilities;
591
+	}
592
+
593
+	function setCallbacks()
594
+	{
595
+		$this->callbacks['system.getCapabilities'] = 'this:getCapabilities';
596
+		$this->callbacks['system.listMethods'] = 'this:listMethods';
597
+		$this->callbacks['system.multicall'] = 'this:multiCall';
598
+	}
599
+
600
+	function listMethods($args)
601
+	{
602
+		// Returns a list of methods - uses array_reverse to ensure user defined
603
+		// methods are listed before server defined methods
604
+		return array_reverse(array_keys($this->callbacks));
605
+	}
606
+
607
+	function multiCall($methodcalls)
608
+	{
609
+		// See http://www.xmlrpc.com/discuss/msgReader$1208
610
+		$return = array();
611
+		foreach ($methodcalls as $call) {
612
+			$method = $call['methodName'];
613
+			$params = $call['params'];
614
+			if ($method == 'system.multicall') {
615
+				$result = new IXR_Error(-32600, 'Recursive calls to system.multicall are forbidden');
616
+			} else {
617
+				$result = $this->call($method, $params);
618
+			}
619
+			if (is_a($result, 'IXR_Error')) {
620
+				$return[] = array(
621
+					'faultCode' => $result->code,
622
+					'faultString' => $result->message
623
+				);
624
+			} else {
625
+				$return[] = array($result);
626
+			}
627
+		}
628
+		return $return;
629
+	}
630 630
 }
631 631
 
632 632
 /**
@@ -637,32 +637,32 @@  discard block
 block discarded – undo
637 637
  */
638 638
 class IXR_Request
639 639
 {
640
-    var $method;
641
-    var $args;
642
-    var $xml;
640
+	var $method;
641
+	var $args;
642
+	var $xml;
643 643
 
644 644
 	/**
645 645
 	 * PHP5 constructor.
646 646
 	 */
647
-    function __construct($method, $args)
648
-    {
649
-        $this->method = $method;
650
-        $this->args = $args;
651
-        $this->xml = <<<EOD
647
+	function __construct($method, $args)
648
+	{
649
+		$this->method = $method;
650
+		$this->args = $args;
651
+		$this->xml = <<<EOD
652 652
 <?xml version="1.0"?>
653 653
 <methodCall>
654 654
 <methodName>{$this->method}</methodName>
655 655
 <params>
656 656
 
657 657
 EOD;
658
-        foreach ($this->args as $arg) {
659
-            $this->xml .= '<param><value>';
660
-            $v = new IXR_Value($arg);
661
-            $this->xml .= $v->getXml();
662
-            $this->xml .= "</value></param>\n";
663
-        }
664
-        $this->xml .= '</params></methodCall>';
665
-    }
658
+		foreach ($this->args as $arg) {
659
+			$this->xml .= '<param><value>';
660
+			$v = new IXR_Value($arg);
661
+			$this->xml .= $v->getXml();
662
+			$this->xml .= "</value></param>\n";
663
+		}
664
+		$this->xml .= '</params></methodCall>';
665
+	}
666 666
 
667 667
 	/**
668 668
 	 * PHP4 constructor.
@@ -671,15 +671,15 @@  discard block
 block discarded – undo
671 671
 		self::__construct( $method, $args );
672 672
 	}
673 673
 
674
-    function getLength()
675
-    {
676
-        return strlen($this->xml);
677
-    }
674
+	function getLength()
675
+	{
676
+		return strlen($this->xml);
677
+	}
678 678
 
679
-    function getXml()
680
-    {
681
-        return $this->xml;
682
-    }
679
+	function getXml()
680
+	{
681
+		return $this->xml;
682
+	}
683 683
 }
684 684
 
685 685
 /**
@@ -691,47 +691,47 @@  discard block
 block discarded – undo
691 691
  */
692 692
 class IXR_Client
693 693
 {
694
-    var $server;
695
-    var $port;
696
-    var $path;
697
-    var $useragent;
698
-    var $response;
699
-    var $message = false;
700
-    var $debug = false;
701
-    var $timeout;
702
-    var $headers = array();
703
-
704
-    // Storage place for an error message
705
-    var $error = false;
694
+	var $server;
695
+	var $port;
696
+	var $path;
697
+	var $useragent;
698
+	var $response;
699
+	var $message = false;
700
+	var $debug = false;
701
+	var $timeout;
702
+	var $headers = array();
703
+
704
+	// Storage place for an error message
705
+	var $error = false;
706 706
 
707 707
 	/**
708 708
 	 * PHP5 constructor.
709 709
 	 */
710
-    function __construct( $server, $path = false, $port = 80, $timeout = 15 )
711
-    {
712
-        if (!$path) {
713
-            // Assume we have been given a URL instead
714
-            $bits = parse_url($server);
715
-            $this->server = $bits['host'];
716
-            $this->port = isset($bits['port']) ? $bits['port'] : 80;
717
-            $this->path = isset($bits['path']) ? $bits['path'] : '/';
718
-
719
-            // Make absolutely sure we have a path
720
-            if (!$this->path) {
721
-                $this->path = '/';
722
-            }
723
-
724
-            if ( ! empty( $bits['query'] ) ) {
725
-                $this->path .= '?' . $bits['query'];
726
-            }
727
-        } else {
728
-            $this->server = $server;
729
-            $this->path = $path;
730
-            $this->port = $port;
731
-        }
732
-        $this->useragent = 'The Incutio XML-RPC PHP Library';
733
-        $this->timeout = $timeout;
734
-    }
710
+	function __construct( $server, $path = false, $port = 80, $timeout = 15 )
711
+	{
712
+		if (!$path) {
713
+			// Assume we have been given a URL instead
714
+			$bits = parse_url($server);
715
+			$this->server = $bits['host'];
716
+			$this->port = isset($bits['port']) ? $bits['port'] : 80;
717
+			$this->path = isset($bits['path']) ? $bits['path'] : '/';
718
+
719
+			// Make absolutely sure we have a path
720
+			if (!$this->path) {
721
+				$this->path = '/';
722
+			}
723
+
724
+			if ( ! empty( $bits['query'] ) ) {
725
+				$this->path .= '?' . $bits['query'];
726
+			}
727
+		} else {
728
+			$this->server = $server;
729
+			$this->path = $path;
730
+			$this->port = $port;
731
+		}
732
+		$this->useragent = 'The Incutio XML-RPC PHP Library';
733
+		$this->timeout = $timeout;
734
+	}
735 735
 
736 736
 	/**
737 737
 	 * PHP4 constructor.
@@ -740,111 +740,111 @@  discard block
 block discarded – undo
740 740
 		self::__construct( $server, $path, $port, $timeout );
741 741
 	}
742 742
 
743
-    function query()
744
-    {
745
-        $args = func_get_args();
746
-        $method = array_shift($args);
747
-        $request = new IXR_Request($method, $args);
748
-        $length = $request->getLength();
749
-        $xml = $request->getXml();
750
-        $r = "\r\n";
751
-        $request  = "POST {$this->path} HTTP/1.0$r";
752
-
753
-        // Merged from WP #8145 - allow custom headers
754
-        $this->headers['Host']          = $this->server;
755
-        $this->headers['Content-Type']  = 'text/xml';
756
-        $this->headers['User-Agent']    = $this->useragent;
757
-        $this->headers['Content-Length']= $length;
758
-
759
-        foreach( $this->headers as $header => $value ) {
760
-            $request .= "{$header}: {$value}{$r}";
761
-        }
762
-        $request .= $r;
763
-
764
-        $request .= $xml;
765
-
766
-        // Now send the request
767
-        if ($this->debug) {
768
-            echo '<pre class="ixr_request">'.htmlspecialchars($request)."\n</pre>\n\n";
769
-        }
770
-
771
-        if ($this->timeout) {
772
-            $fp = @fsockopen($this->server, $this->port, $errno, $errstr, $this->timeout);
773
-        } else {
774
-            $fp = @fsockopen($this->server, $this->port, $errno, $errstr);
775
-        }
776
-        if (!$fp) {
777
-            $this->error = new IXR_Error(-32300, 'transport error - could not open socket');
778
-            return false;
779
-        }
780
-        fputs($fp, $request);
781
-        $contents = '';
782
-        $debugContents = '';
783
-        $gotFirstLine = false;
784
-        $gettingHeaders = true;
785
-        while (!feof($fp)) {
786
-            $line = fgets($fp, 4096);
787
-            if (!$gotFirstLine) {
788
-                // Check line for '200'
789
-                if (strstr($line, '200') === false) {
790
-                    $this->error = new IXR_Error(-32300, 'transport error - HTTP status code was not 200');
791
-                    return false;
792
-                }
793
-                $gotFirstLine = true;
794
-            }
795
-            if (trim($line) == '') {
796
-                $gettingHeaders = false;
797
-            }
798
-            if (!$gettingHeaders) {
799
-            	// merged from WP #12559 - remove trim
800
-                $contents .= $line;
801
-            }
802
-            if ($this->debug) {
803
-            	$debugContents .= $line;
804
-            }
805
-        }
806
-        if ($this->debug) {
807
-            echo '<pre class="ixr_response">'.htmlspecialchars($debugContents)."\n</pre>\n\n";
808
-        }
809
-
810
-        // Now parse what we've got back
811
-        $this->message = new IXR_Message($contents);
812
-        if (!$this->message->parse()) {
813
-            // XML error
814
-            $this->error = new IXR_Error(-32700, 'parse error. not well formed');
815
-            return false;
816
-        }
817
-
818
-        // Is the message a fault?
819
-        if ($this->message->messageType == 'fault') {
820
-            $this->error = new IXR_Error($this->message->faultCode, $this->message->faultString);
821
-            return false;
822
-        }
823
-
824
-        // Message must be OK
825
-        return true;
826
-    }
827
-
828
-    function getResponse()
829
-    {
830
-        // methodResponses can only have one param - return that
831
-        return $this->message->params[0];
832
-    }
833
-
834
-    function isError()
835
-    {
836
-        return (is_object($this->error));
837
-    }
838
-
839
-    function getErrorCode()
840
-    {
841
-        return $this->error->code;
842
-    }
843
-
844
-    function getErrorMessage()
845
-    {
846
-        return $this->error->message;
847
-    }
743
+	function query()
744
+	{
745
+		$args = func_get_args();
746
+		$method = array_shift($args);
747
+		$request = new IXR_Request($method, $args);
748
+		$length = $request->getLength();
749
+		$xml = $request->getXml();
750
+		$r = "\r\n";
751
+		$request  = "POST {$this->path} HTTP/1.0$r";
752
+
753
+		// Merged from WP #8145 - allow custom headers
754
+		$this->headers['Host']          = $this->server;
755
+		$this->headers['Content-Type']  = 'text/xml';
756
+		$this->headers['User-Agent']    = $this->useragent;
757
+		$this->headers['Content-Length']= $length;
758
+
759
+		foreach( $this->headers as $header => $value ) {
760
+			$request .= "{$header}: {$value}{$r}";
761
+		}
762
+		$request .= $r;
763
+
764
+		$request .= $xml;
765
+
766
+		// Now send the request
767
+		if ($this->debug) {
768
+			echo '<pre class="ixr_request">'.htmlspecialchars($request)."\n</pre>\n\n";
769
+		}
770
+
771
+		if ($this->timeout) {
772
+			$fp = @fsockopen($this->server, $this->port, $errno, $errstr, $this->timeout);
773
+		} else {
774
+			$fp = @fsockopen($this->server, $this->port, $errno, $errstr);
775
+		}
776
+		if (!$fp) {
777
+			$this->error = new IXR_Error(-32300, 'transport error - could not open socket');
778
+			return false;
779
+		}
780
+		fputs($fp, $request);
781
+		$contents = '';
782
+		$debugContents = '';
783
+		$gotFirstLine = false;
784
+		$gettingHeaders = true;
785
+		while (!feof($fp)) {
786
+			$line = fgets($fp, 4096);
787
+			if (!$gotFirstLine) {
788
+				// Check line for '200'
789
+				if (strstr($line, '200') === false) {
790
+					$this->error = new IXR_Error(-32300, 'transport error - HTTP status code was not 200');
791
+					return false;
792
+				}
793
+				$gotFirstLine = true;
794
+			}
795
+			if (trim($line) == '') {
796
+				$gettingHeaders = false;
797
+			}
798
+			if (!$gettingHeaders) {
799
+				// merged from WP #12559 - remove trim
800
+				$contents .= $line;
801
+			}
802
+			if ($this->debug) {
803
+				$debugContents .= $line;
804
+			}
805
+		}
806
+		if ($this->debug) {
807
+			echo '<pre class="ixr_response">'.htmlspecialchars($debugContents)."\n</pre>\n\n";
808
+		}
809
+
810
+		// Now parse what we've got back
811
+		$this->message = new IXR_Message($contents);
812
+		if (!$this->message->parse()) {
813
+			// XML error
814
+			$this->error = new IXR_Error(-32700, 'parse error. not well formed');
815
+			return false;
816
+		}
817
+
818
+		// Is the message a fault?
819
+		if ($this->message->messageType == 'fault') {
820
+			$this->error = new IXR_Error($this->message->faultCode, $this->message->faultString);
821
+			return false;
822
+		}
823
+
824
+		// Message must be OK
825
+		return true;
826
+	}
827
+
828
+	function getResponse()
829
+	{
830
+		// methodResponses can only have one param - return that
831
+		return $this->message->params[0];
832
+	}
833
+
834
+	function isError()
835
+	{
836
+		return (is_object($this->error));
837
+	}
838
+
839
+	function getErrorCode()
840
+	{
841
+		return $this->error->code;
842
+	}
843
+
844
+	function getErrorMessage()
845
+	{
846
+		return $this->error->message;
847
+	}
848 848
 }
849 849
 
850 850
 
@@ -856,17 +856,17 @@  discard block
 block discarded – undo
856 856
  */
857 857
 class IXR_Error
858 858
 {
859
-    var $code;
860
-    var $message;
859
+	var $code;
860
+	var $message;
861 861
 
862 862
 	/**
863 863
 	 * PHP5 constructor.
864 864
 	 */
865
-    function __construct( $code, $message )
866
-    {
867
-        $this->code = $code;
868
-        $this->message = htmlspecialchars($message);
869
-    }
865
+	function __construct( $code, $message )
866
+	{
867
+		$this->code = $code;
868
+		$this->message = htmlspecialchars($message);
869
+	}
870 870
 
871 871
 	/**
872 872
 	 * PHP4 constructor.
@@ -875,9 +875,9 @@  discard block
 block discarded – undo
875 875
 		self::__construct( $code, $message );
876 876
 	}
877 877
 
878
-    function getXml()
879
-    {
880
-        $xml = <<<EOD
878
+	function getXml()
879
+	{
880
+		$xml = <<<EOD
881 881
 <methodResponse>
882 882
   <fault>
883 883
     <value>
@@ -896,8 +896,8 @@  discard block
 block discarded – undo
896 896
 </methodResponse>
897 897
 
898 898
 EOD;
899
-        return $xml;
900
-    }
899
+		return $xml;
900
+	}
901 901
 }
902 902
 
903 903
 /**
@@ -907,26 +907,26 @@  discard block
 block discarded – undo
907 907
  * @since 1.5.0
908 908
  */
909 909
 class IXR_Date {
910
-    var $year;
911
-    var $month;
912
-    var $day;
913
-    var $hour;
914
-    var $minute;
915
-    var $second;
916
-    var $timezone;
910
+	var $year;
911
+	var $month;
912
+	var $day;
913
+	var $hour;
914
+	var $minute;
915
+	var $second;
916
+	var $timezone;
917 917
 
918 918
 	/**
919 919
 	 * PHP5 constructor.
920 920
 	 */
921
-    function __construct( $time )
922
-    {
923
-        // $time can be a PHP timestamp or an ISO one
924
-        if (is_numeric($time)) {
925
-            $this->parseTimestamp($time);
926
-        } else {
927
-            $this->parseIso($time);
928
-        }
929
-    }
921
+	function __construct( $time )
922
+	{
923
+		// $time can be a PHP timestamp or an ISO one
924
+		if (is_numeric($time)) {
925
+			$this->parseTimestamp($time);
926
+		} else {
927
+			$this->parseIso($time);
928
+		}
929
+	}
930 930
 
931 931
 	/**
932 932
 	 * PHP4 constructor.
@@ -935,42 +935,42 @@  discard block
 block discarded – undo
935 935
 		self::__construct( $time );
936 936
 	}
937 937
 
938
-    function parseTimestamp($timestamp)
939
-    {
940
-        $this->year = date('Y', $timestamp);
941
-        $this->month = date('m', $timestamp);
942
-        $this->day = date('d', $timestamp);
943
-        $this->hour = date('H', $timestamp);
944
-        $this->minute = date('i', $timestamp);
945
-        $this->second = date('s', $timestamp);
946
-        $this->timezone = '';
947
-    }
948
-
949
-    function parseIso($iso)
950
-    {
951
-        $this->year = substr($iso, 0, 4);
952
-        $this->month = substr($iso, 4, 2);
953
-        $this->day = substr($iso, 6, 2);
954
-        $this->hour = substr($iso, 9, 2);
955
-        $this->minute = substr($iso, 12, 2);
956
-        $this->second = substr($iso, 15, 2);
957
-        $this->timezone = substr($iso, 17);
958
-    }
959
-
960
-    function getIso()
961
-    {
962
-        return $this->year.$this->month.$this->day.'T'.$this->hour.':'.$this->minute.':'.$this->second.$this->timezone;
963
-    }
964
-
965
-    function getXml()
966
-    {
967
-        return '<dateTime.iso8601>'.$this->getIso().'</dateTime.iso8601>';
968
-    }
969
-
970
-    function getTimestamp()
971
-    {
972
-        return mktime($this->hour, $this->minute, $this->second, $this->month, $this->day, $this->year);
973
-    }
938
+	function parseTimestamp($timestamp)
939
+	{
940
+		$this->year = date('Y', $timestamp);
941
+		$this->month = date('m', $timestamp);
942
+		$this->day = date('d', $timestamp);
943
+		$this->hour = date('H', $timestamp);
944
+		$this->minute = date('i', $timestamp);
945
+		$this->second = date('s', $timestamp);
946
+		$this->timezone = '';
947
+	}
948
+
949
+	function parseIso($iso)
950
+	{
951
+		$this->year = substr($iso, 0, 4);
952
+		$this->month = substr($iso, 4, 2);
953
+		$this->day = substr($iso, 6, 2);
954
+		$this->hour = substr($iso, 9, 2);
955
+		$this->minute = substr($iso, 12, 2);
956
+		$this->second = substr($iso, 15, 2);
957
+		$this->timezone = substr($iso, 17);
958
+	}
959
+
960
+	function getIso()
961
+	{
962
+		return $this->year.$this->month.$this->day.'T'.$this->hour.':'.$this->minute.':'.$this->second.$this->timezone;
963
+	}
964
+
965
+	function getXml()
966
+	{
967
+		return '<dateTime.iso8601>'.$this->getIso().'</dateTime.iso8601>';
968
+	}
969
+
970
+	function getTimestamp()
971
+	{
972
+		return mktime($this->hour, $this->minute, $this->second, $this->month, $this->day, $this->year);
973
+	}
974 974
 }
975 975
 
976 976
 /**
@@ -981,15 +981,15 @@  discard block
 block discarded – undo
981 981
  */
982 982
 class IXR_Base64
983 983
 {
984
-    var $data;
984
+	var $data;
985 985
 
986 986
 	/**
987 987
 	 * PHP5 constructor.
988 988
 	 */
989
-    function __construct( $data )
990
-    {
991
-        $this->data = $data;
992
-    }
989
+	function __construct( $data )
990
+	{
991
+		$this->data = $data;
992
+	}
993 993
 
994 994
 	/**
995 995
 	 * PHP4 constructor.
@@ -998,10 +998,10 @@  discard block
 block discarded – undo
998 998
 		self::__construct( $data );
999 999
 	}
1000 1000
 
1001
-    function getXml()
1002
-    {
1003
-        return '<base64>'.base64_encode($this->data).'</base64>';
1004
-    }
1001
+	function getXml()
1002
+	{
1003
+		return '<base64>'.base64_encode($this->data).'</base64>';
1004
+	}
1005 1005
 }
1006 1006
 
1007 1007
 /**
@@ -1012,45 +1012,45 @@  discard block
 block discarded – undo
1012 1012
  */
1013 1013
 class IXR_IntrospectionServer extends IXR_Server
1014 1014
 {
1015
-    var $signatures;
1016
-    var $help;
1015
+	var $signatures;
1016
+	var $help;
1017 1017
 
1018 1018
 	/**
1019 1019
 	 * PHP5 constructor.
1020 1020
 	 */
1021
-    function __construct()
1022
-    {
1023
-        $this->setCallbacks();
1024
-        $this->setCapabilities();
1025
-        $this->capabilities['introspection'] = array(
1026
-            'specUrl' => 'http://xmlrpc.usefulinc.com/doc/reserved.html',
1027
-            'specVersion' => 1
1028
-        );
1029
-        $this->addCallback(
1030
-            'system.methodSignature',
1031
-            'this:methodSignature',
1032
-            array('array', 'string'),
1033
-            'Returns an array describing the return type and required parameters of a method'
1034
-        );
1035
-        $this->addCallback(
1036
-            'system.getCapabilities',
1037
-            'this:getCapabilities',
1038
-            array('struct'),
1039
-            'Returns a struct describing the XML-RPC specifications supported by this server'
1040
-        );
1041
-        $this->addCallback(
1042
-            'system.listMethods',
1043
-            'this:listMethods',
1044
-            array('array'),
1045
-            'Returns an array of available methods on this server'
1046
-        );
1047
-        $this->addCallback(
1048
-            'system.methodHelp',
1049
-            'this:methodHelp',
1050
-            array('string', 'string'),
1051
-            'Returns a documentation string for the specified method'
1052
-        );
1053
-    }
1021
+	function __construct()
1022
+	{
1023
+		$this->setCallbacks();
1024
+		$this->setCapabilities();
1025
+		$this->capabilities['introspection'] = array(
1026
+			'specUrl' => 'http://xmlrpc.usefulinc.com/doc/reserved.html',
1027
+			'specVersion' => 1
1028
+		);
1029
+		$this->addCallback(
1030
+			'system.methodSignature',
1031
+			'this:methodSignature',
1032
+			array('array', 'string'),
1033
+			'Returns an array describing the return type and required parameters of a method'
1034
+		);
1035
+		$this->addCallback(
1036
+			'system.getCapabilities',
1037
+			'this:getCapabilities',
1038
+			array('struct'),
1039
+			'Returns a struct describing the XML-RPC specifications supported by this server'
1040
+		);
1041
+		$this->addCallback(
1042
+			'system.listMethods',
1043
+			'this:listMethods',
1044
+			array('array'),
1045
+			'Returns an array of available methods on this server'
1046
+		);
1047
+		$this->addCallback(
1048
+			'system.methodHelp',
1049
+			'this:methodHelp',
1050
+			array('string', 'string'),
1051
+			'Returns a documentation string for the specified method'
1052
+		);
1053
+	}
1054 1054
 
1055 1055
 	/**
1056 1056
 	 * PHP4 constructor.
@@ -1059,122 +1059,122 @@  discard block
 block discarded – undo
1059 1059
 		self::__construct();
1060 1060
 	}
1061 1061
 
1062
-    function addCallback($method, $callback, $args, $help)
1063
-    {
1064
-        $this->callbacks[$method] = $callback;
1065
-        $this->signatures[$method] = $args;
1066
-        $this->help[$method] = $help;
1067
-    }
1068
-
1069
-    function call($methodname, $args)
1070
-    {
1071
-        // Make sure it's in an array
1072
-        if ($args && !is_array($args)) {
1073
-            $args = array($args);
1074
-        }
1075
-
1076
-        // Over-rides default call method, adds signature check
1077
-        if (!$this->hasMethod($methodname)) {
1078
-            return new IXR_Error(-32601, 'server error. requested method "'.$this->message->methodName.'" not specified.');
1079
-        }
1080
-        $method = $this->callbacks[$methodname];
1081
-        $signature = $this->signatures[$methodname];
1082
-        $returnType = array_shift($signature);
1083
-
1084
-        // Check the number of arguments
1085
-        if (count($args) != count($signature)) {
1086
-            return new IXR_Error(-32602, 'server error. wrong number of method parameters');
1087
-        }
1088
-
1089
-        // Check the argument types
1090
-        $ok = true;
1091
-        $argsbackup = $args;
1092
-        for ($i = 0, $j = count($args); $i < $j; $i++) {
1093
-            $arg = array_shift($args);
1094
-            $type = array_shift($signature);
1095
-            switch ($type) {
1096
-                case 'int':
1097
-                case 'i4':
1098
-                    if (is_array($arg) || !is_int($arg)) {
1099
-                        $ok = false;
1100
-                    }
1101
-                    break;
1102
-                case 'base64':
1103
-                case 'string':
1104
-                    if (!is_string($arg)) {
1105
-                        $ok = false;
1106
-                    }
1107
-                    break;
1108
-                case 'boolean':
1109
-                    if ($arg !== false && $arg !== true) {
1110
-                        $ok = false;
1111
-                    }
1112
-                    break;
1113
-                case 'float':
1114
-                case 'double':
1115
-                    if (!is_float($arg)) {
1116
-                        $ok = false;
1117
-                    }
1118
-                    break;
1119
-                case 'date':
1120
-                case 'dateTime.iso8601':
1121
-                    if (!is_a($arg, 'IXR_Date')) {
1122
-                        $ok = false;
1123
-                    }
1124
-                    break;
1125
-            }
1126
-            if (!$ok) {
1127
-                return new IXR_Error(-32602, 'server error. invalid method parameters');
1128
-            }
1129
-        }
1130
-        // It passed the test - run the "real" method call
1131
-        return parent::call($methodname, $argsbackup);
1132
-    }
1133
-
1134
-    function methodSignature($method)
1135
-    {
1136
-        if (!$this->hasMethod($method)) {
1137
-            return new IXR_Error(-32601, 'server error. requested method "'.$method.'" not specified.');
1138
-        }
1139
-        // We should be returning an array of types
1140
-        $types = $this->signatures[$method];
1141
-        $return = array();
1142
-        foreach ($types as $type) {
1143
-            switch ($type) {
1144
-                case 'string':
1145
-                    $return[] = 'string';
1146
-                    break;
1147
-                case 'int':
1148
-                case 'i4':
1149
-                    $return[] = 42;
1150
-                    break;
1151
-                case 'double':
1152
-                    $return[] = 3.1415;
1153
-                    break;
1154
-                case 'dateTime.iso8601':
1155
-                    $return[] = new IXR_Date(time());
1156
-                    break;
1157
-                case 'boolean':
1158
-                    $return[] = true;
1159
-                    break;
1160
-                case 'base64':
1161
-                    $return[] = new IXR_Base64('base64');
1162
-                    break;
1163
-                case 'array':
1164
-                    $return[] = array('array');
1165
-                    break;
1166
-                case 'struct':
1167
-                    $return[] = array('struct' => 'struct');
1168
-                    break;
1169
-            }
1170
-        }
1171
-        return $return;
1172
-    }
1173
-
1174
-    function methodHelp($method)
1175
-    {
1176
-        return $this->help[$method];
1177
-    }
1062
+	function addCallback($method, $callback, $args, $help)
1063
+	{
1064
+		$this->callbacks[$method] = $callback;
1065
+		$this->signatures[$method] = $args;
1066
+		$this->help[$method] = $help;
1067
+	}
1068
+
1069
+	function call($methodname, $args)
1070
+	{
1071
+		// Make sure it's in an array
1072
+		if ($args && !is_array($args)) {
1073
+			$args = array($args);
1074
+		}
1075
+
1076
+		// Over-rides default call method, adds signature check
1077
+		if (!$this->hasMethod($methodname)) {
1078
+			return new IXR_Error(-32601, 'server error. requested method "'.$this->message->methodName.'" not specified.');
1079
+		}
1080
+		$method = $this->callbacks[$methodname];
1081
+		$signature = $this->signatures[$methodname];
1082
+		$returnType = array_shift($signature);
1083
+
1084
+		// Check the number of arguments
1085
+		if (count($args) != count($signature)) {
1086
+			return new IXR_Error(-32602, 'server error. wrong number of method parameters');
1087
+		}
1088
+
1089
+		// Check the argument types
1090
+		$ok = true;
1091
+		$argsbackup = $args;
1092
+		for ($i = 0, $j = count($args); $i < $j; $i++) {
1093
+			$arg = array_shift($args);
1094
+			$type = array_shift($signature);
1095
+			switch ($type) {
1096
+				case 'int':
1097
+				case 'i4':
1098
+					if (is_array($arg) || !is_int($arg)) {
1099
+						$ok = false;
1100
+					}
1101
+					break;
1102
+				case 'base64':
1103
+				case 'string':
1104
+					if (!is_string($arg)) {
1105
+						$ok = false;
1106
+					}
1107
+					break;
1108
+				case 'boolean':
1109
+					if ($arg !== false && $arg !== true) {
1110
+						$ok = false;
1111
+					}
1112
+					break;
1113
+				case 'float':
1114
+				case 'double':
1115
+					if (!is_float($arg)) {
1116
+						$ok = false;
1117
+					}
1118
+					break;
1119
+				case 'date':
1120
+				case 'dateTime.iso8601':
1121
+					if (!is_a($arg, 'IXR_Date')) {
1122
+						$ok = false;
1123
+					}
1124
+					break;
1125
+			}
1126
+			if (!$ok) {
1127
+				return new IXR_Error(-32602, 'server error. invalid method parameters');
1128
+			}
1129
+		}
1130
+		// It passed the test - run the "real" method call
1131
+		return parent::call($methodname, $argsbackup);
1132
+	}
1133
+
1134
+	function methodSignature($method)
1135
+	{
1136
+		if (!$this->hasMethod($method)) {
1137
+			return new IXR_Error(-32601, 'server error. requested method "'.$method.'" not specified.');
1138
+		}
1139
+		// We should be returning an array of types
1140
+		$types = $this->signatures[$method];
1141
+		$return = array();
1142
+		foreach ($types as $type) {
1143
+			switch ($type) {
1144
+				case 'string':
1145
+					$return[] = 'string';
1146
+					break;
1147
+				case 'int':
1148
+				case 'i4':
1149
+					$return[] = 42;
1150
+					break;
1151
+				case 'double':
1152
+					$return[] = 3.1415;
1153
+					break;
1154
+				case 'dateTime.iso8601':
1155
+					$return[] = new IXR_Date(time());
1156
+					break;
1157
+				case 'boolean':
1158
+					$return[] = true;
1159
+					break;
1160
+				case 'base64':
1161
+					$return[] = new IXR_Base64('base64');
1162
+					break;
1163
+				case 'array':
1164
+					$return[] = array('array');
1165
+					break;
1166
+				case 'struct':
1167
+					$return[] = array('struct' => 'struct');
1168
+					break;
1169
+			}
1170
+		}
1171
+		return $return;
1172
+	}
1173
+
1174
+	function methodHelp($method)
1175
+	{
1176
+		return $this->help[$method];
1177
+	}
1178 1178
 }
1179 1179
 
1180 1180
 /**
@@ -1185,16 +1185,16 @@  discard block
 block discarded – undo
1185 1185
  */
1186 1186
 class IXR_ClientMulticall extends IXR_Client
1187 1187
 {
1188
-    var $calls = array();
1188
+	var $calls = array();
1189 1189
 
1190 1190
 	/**
1191 1191
 	 * PHP5 constructor.
1192 1192
 	 */
1193
-    function __construct( $server, $path = false, $port = 80 )
1194
-    {
1195
-        parent::IXR_Client($server, $path, $port);
1196
-        $this->useragent = 'The Incutio XML-RPC PHP Library (multicall client)';
1197
-    }
1193
+	function __construct( $server, $path = false, $port = 80 )
1194
+	{
1195
+		parent::IXR_Client($server, $path, $port);
1196
+		$this->useragent = 'The Incutio XML-RPC PHP Library (multicall client)';
1197
+	}
1198 1198
 
1199 1199
 	/**
1200 1200
 	 * PHP4 constructor.
@@ -1203,20 +1203,20 @@  discard block
 block discarded – undo
1203 1203
 		self::__construct( $server, $path, $port );
1204 1204
 	}
1205 1205
 
1206
-    function addCall()
1207
-    {
1208
-        $args = func_get_args();
1209
-        $methodName = array_shift($args);
1210
-        $struct = array(
1211
-            'methodName' => $methodName,
1212
-            'params' => $args
1213
-        );
1214
-        $this->calls[] = $struct;
1215
-    }
1216
-
1217
-    function query()
1218
-    {
1219
-        // Prepare multicall, then call the parent::query() method
1220
-        return parent::query('system.multicall', $this->calls);
1221
-    }
1206
+	function addCall()
1207
+	{
1208
+		$args = func_get_args();
1209
+		$methodName = array_shift($args);
1210
+		$struct = array(
1211
+			'methodName' => $methodName,
1212
+			'params' => $args
1213
+		);
1214
+		$this->calls[] = $struct;
1215
+	}
1216
+
1217
+	function query()
1218
+	{
1219
+		// Prepare multicall, then call the parent::query() method
1220
+		return parent::query('system.multicall', $this->calls);
1221
+	}
1222 1222
 }
Please login to merge, or discard this patch.
Spacing   +89 added lines, -89 removed lines patch added patch discarded remove patch
@@ -52,10 +52,10 @@  discard block
 block discarded – undo
52 52
 	/**
53 53
 	 * PHP5 constructor.
54 54
 	 */
55
-	function __construct( $data, $type = false )
55
+	function __construct($data, $type = false)
56 56
     {
57 57
         $this->data = $data;
58
-        if (!$type) {
58
+        if ( ! $type) {
59 59
             $type = $this->calculateType();
60 60
         }
61 61
         $this->type = $type;
@@ -75,8 +75,8 @@  discard block
 block discarded – undo
75 75
 	/**
76 76
 	 * PHP4 constructor.
77 77
 	 */
78
-	public function IXR_Value( $data, $type = false ) {
79
-		self::__construct( $data, $type );
78
+	public function IXR_Value($data, $type = false) {
79
+		self::__construct($data, $type);
80 80
 	}
81 81
 
82 82
     function calculateType()
@@ -104,7 +104,7 @@  discard block
 block discarded – undo
104 104
             $this->data = get_object_vars($this->data);
105 105
             return 'struct';
106 106
         }
107
-        if (!is_array($this->data)) {
107
+        if ( ! is_array($this->data)) {
108 108
             return 'string';
109 109
         }
110 110
 
@@ -168,7 +168,7 @@  discard block
 block discarded – undo
168 168
     {
169 169
         $expected = 0;
170 170
         foreach ($array as $key => $value) {
171
-            if ((string)$key !== (string)$expected) {
171
+            if ((string) $key !== (string) $expected) {
172 172
                 return true;
173 173
             }
174 174
             $expected++;
@@ -187,16 +187,16 @@  discard block
 block discarded – undo
187 187
 class IXR_Message
188 188
 {
189 189
     var $message;
190
-    var $messageType;  // methodCall / methodResponse / fault
190
+    var $messageType; // methodCall / methodResponse / fault
191 191
     var $faultCode;
192 192
     var $faultString;
193 193
     var $methodName;
194 194
     var $params;
195 195
 
196 196
     // Current variable stacks
197
-    var $_arraystructs = array();   // The stack used to keep track of the current array/struct
197
+    var $_arraystructs = array(); // The stack used to keep track of the current array/struct
198 198
     var $_arraystructstypes = array(); // Stack keeping track of if things are structs or array
199
-    var $_currentStructName = array();  // A stack as well
199
+    var $_currentStructName = array(); // A stack as well
200 200
     var $_param;
201 201
     var $_value;
202 202
     var $_currentTag;
@@ -207,47 +207,47 @@  discard block
 block discarded – undo
207 207
 	/**
208 208
 	 * PHP5 constructor.
209 209
 	 */
210
-    function __construct( $message )
210
+    function __construct($message)
211 211
     {
212
-        $this->message =& $message;
212
+        $this->message = & $message;
213 213
     }
214 214
 
215 215
 	/**
216 216
 	 * PHP4 constructor.
217 217
 	 */
218
-	public function IXR_Message( $message ) {
219
-		self::__construct( $message );
218
+	public function IXR_Message($message) {
219
+		self::__construct($message);
220 220
 	}
221 221
 
222 222
     function parse()
223 223
     {
224 224
         // first remove the XML declaration
225 225
         // merged from WP #10698 - this method avoids the RAM usage of preg_replace on very large messages
226
-        $header = preg_replace( '/<\?xml.*?\?'.'>/s', '', substr( $this->message, 0, 100 ), 1 );
227
-        $this->message = trim( substr_replace( $this->message, $header, 0, 100 ) );
228
-        if ( '' == $this->message ) {
226
+        $header = preg_replace('/<\?xml.*?\?'.'>/s', '', substr($this->message, 0, 100), 1);
227
+        $this->message = trim(substr_replace($this->message, $header, 0, 100));
228
+        if ('' == $this->message) {
229 229
             return false;
230 230
         }
231 231
 
232 232
         // Then remove the DOCTYPE
233
-        $header = preg_replace( '/^<!DOCTYPE[^>]*+>/i', '', substr( $this->message, 0, 200 ), 1 );
234
-        $this->message = trim( substr_replace( $this->message, $header, 0, 200 ) );
235
-        if ( '' == $this->message ) {
233
+        $header = preg_replace('/^<!DOCTYPE[^>]*+>/i', '', substr($this->message, 0, 200), 1);
234
+        $this->message = trim(substr_replace($this->message, $header, 0, 200));
235
+        if ('' == $this->message) {
236 236
             return false;
237 237
         }
238 238
 
239 239
         // Check that the root tag is valid
240
-        $root_tag = substr( $this->message, 0, strcspn( substr( $this->message, 0, 20 ), "> \t\r\n" ) );
241
-        if ( '<!DOCTYPE' === strtoupper( $root_tag ) ) {
240
+        $root_tag = substr($this->message, 0, strcspn(substr($this->message, 0, 20), "> \t\r\n"));
241
+        if ('<!DOCTYPE' === strtoupper($root_tag)) {
242 242
             return false;
243 243
         }
244
-        if ( ! in_array( $root_tag, array( '<methodCall', '<methodResponse', '<fault' ) ) ) {
244
+        if ( ! in_array($root_tag, array('<methodCall', '<methodResponse', '<fault'))) {
245 245
             return false;
246 246
         }
247 247
 
248 248
         // Bail if there are too many elements to parse
249 249
         $element_limit = 30000;
250
-        if ( function_exists( 'apply_filters' ) ) {
250
+        if (function_exists('apply_filters')) {
251 251
             /**
252 252
              * Filters the number of elements to parse in an XML-RPC response.
253 253
              *
@@ -255,9 +255,9 @@  discard block
 block discarded – undo
255 255
              *
256 256
              * @param int $element_limit Default elements limit.
257 257
              */
258
-            $element_limit = apply_filters( 'xmlrpc_element_limit', $element_limit );
258
+            $element_limit = apply_filters('xmlrpc_element_limit', $element_limit);
259 259
         }
260
-        if ( $element_limit && 2 * $element_limit < substr_count( $this->message, '<' ) ) {
260
+        if ($element_limit && 2 * $element_limit < substr_count($this->message, '<')) {
261 261
             return false;
262 262
         }
263 263
 
@@ -279,7 +279,7 @@  discard block
 block discarded – undo
279 279
          *
280 280
          * @param int $chunk_size Chunk size to parse in bytes.
281 281
          */
282
-        $chunk_size = apply_filters( 'xmlrpc_chunk_parsing_size', $chunk_size );
282
+        $chunk_size = apply_filters('xmlrpc_chunk_parsing_size', $chunk_size);
283 283
 
284 284
         $final = false;
285 285
         do {
@@ -288,7 +288,7 @@  discard block
 block discarded – undo
288 288
             }
289 289
             $part = substr($this->message, 0, $chunk_size);
290 290
             $this->message = substr($this->message, $chunk_size);
291
-            if (!xml_parse($this->_parser, $part, $final)) {
291
+            if ( ! xml_parse($this->_parser, $part, $final)) {
292 292
                 return false;
293 293
             }
294 294
             if ($final) {
@@ -309,7 +309,7 @@  discard block
 block discarded – undo
309 309
     {
310 310
         $this->_currentTagContents = '';
311 311
         $this->currentTag = $tag;
312
-        switch($tag) {
312
+        switch ($tag) {
313 313
             case 'methodCall':
314 314
             case 'methodResponse':
315 315
             case 'fault':
@@ -335,18 +335,18 @@  discard block
 block discarded – undo
335 335
     function tag_close($parser, $tag)
336 336
     {
337 337
         $valueFlag = false;
338
-        switch($tag) {
338
+        switch ($tag) {
339 339
             case 'int':
340 340
             case 'i4':
341
-                $value = (int)trim($this->_currentTagContents);
341
+                $value = (int) trim($this->_currentTagContents);
342 342
                 $valueFlag = true;
343 343
                 break;
344 344
             case 'double':
345
-                $value = (double)trim($this->_currentTagContents);
345
+                $value = (double) trim($this->_currentTagContents);
346 346
                 $valueFlag = true;
347 347
                 break;
348 348
             case 'string':
349
-                $value = (string)trim($this->_currentTagContents);
349
+                $value = (string) trim($this->_currentTagContents);
350 350
                 $valueFlag = true;
351 351
                 break;
352 352
             case 'dateTime.iso8601':
@@ -356,12 +356,12 @@  discard block
 block discarded – undo
356 356
             case 'value':
357 357
                 // "If no type is indicated, the type is string."
358 358
                 if (trim($this->_currentTagContents) != '') {
359
-                    $value = (string)$this->_currentTagContents;
359
+                    $value = (string) $this->_currentTagContents;
360 360
                     $valueFlag = true;
361 361
                 }
362 362
                 break;
363 363
             case 'boolean':
364
-                $value = (boolean)trim($this->_currentTagContents);
364
+                $value = (boolean) trim($this->_currentTagContents);
365 365
                 $valueFlag = true;
366 366
                 break;
367 367
             case 'base64':
@@ -389,12 +389,12 @@  discard block
 block discarded – undo
389 389
         if ($valueFlag) {
390 390
             if (count($this->_arraystructs) > 0) {
391 391
                 // Add value to struct or array
392
-                if ($this->_arraystructstypes[count($this->_arraystructstypes)-1] == 'struct') {
392
+                if ($this->_arraystructstypes[count($this->_arraystructstypes) - 1] == 'struct') {
393 393
                     // Add to struct
394
-                    $this->_arraystructs[count($this->_arraystructs)-1][$this->_currentStructName[count($this->_currentStructName)-1]] = $value;
394
+                    $this->_arraystructs[count($this->_arraystructs) - 1][$this->_currentStructName[count($this->_currentStructName) - 1]] = $value;
395 395
                 } else {
396 396
                     // Add to array
397
-                    $this->_arraystructs[count($this->_arraystructs)-1][] = $value;
397
+                    $this->_arraystructs[count($this->_arraystructs) - 1][] = $value;
398 398
                 }
399 399
             } else {
400 400
                 // Just add as a parameter
@@ -421,14 +421,14 @@  discard block
 block discarded – undo
421 421
 	/**
422 422
 	 * PHP5 constructor.
423 423
 	 */
424
-    function __construct( $callbacks = false, $data = false, $wait = false )
424
+    function __construct($callbacks = false, $data = false, $wait = false)
425 425
     {
426 426
         $this->setCapabilities();
427 427
         if ($callbacks) {
428 428
             $this->callbacks = $callbacks;
429 429
         }
430 430
         $this->setCallbacks();
431
-        if (!$wait) {
431
+        if ( ! $wait) {
432 432
             $this->serve($data);
433 433
         }
434 434
     }
@@ -436,17 +436,17 @@  discard block
 block discarded – undo
436 436
 	/**
437 437
 	 * PHP4 constructor.
438 438
 	 */
439
-	public function IXR_Server( $callbacks = false, $data = false, $wait = false ) {
440
-		self::__construct( $callbacks, $data, $wait );
439
+	public function IXR_Server($callbacks = false, $data = false, $wait = false) {
440
+		self::__construct($callbacks, $data, $wait);
441 441
 	}
442 442
 
443 443
     function serve($data = false)
444 444
     {
445
-        if (!$data) {
445
+        if ( ! $data) {
446 446
             if (isset($_SERVER['REQUEST_METHOD']) && $_SERVER['REQUEST_METHOD'] !== 'POST') {
447
-                if ( function_exists( 'status_header' ) ) {
448
-                    status_header( 405 ); // WP #20986
449
-                    header( 'Allow: POST' );
447
+                if (function_exists('status_header')) {
448
+                    status_header(405); // WP #20986
449
+                    header('Allow: POST');
450 450
                 }
451 451
                 header('Content-Type: text/plain'); // merged from WP #9093
452 452
                 die('XML-RPC server accepts POST requests only.');
@@ -457,11 +457,11 @@  discard block
 block discarded – undo
457 457
                 // workaround for a bug in PHP 5.2.2 - http://bugs.php.net/bug.php?id=41293
458 458
                 $data = file_get_contents('php://input');
459 459
             } else {
460
-                $data =& $HTTP_RAW_POST_DATA;
460
+                $data = & $HTTP_RAW_POST_DATA;
461 461
             }
462 462
         }
463 463
         $this->message = new IXR_Message($data);
464
-        if (!$this->message->parse()) {
464
+        if ( ! $this->message->parse()) {
465 465
             $this->error(-32700, 'parse error. not well formed');
466 466
         }
467 467
         if ($this->message->messageType != 'methodCall') {
@@ -497,7 +497,7 @@  discard block
 block discarded – undo
497 497
 
498 498
     function call($methodname, $args)
499 499
     {
500
-        if (!$this->hasMethod($methodname)) {
500
+        if ( ! $this->hasMethod($methodname)) {
501 501
             return new IXR_Error(-32601, 'server error. requested method '.$methodname.' does not exist.');
502 502
         }
503 503
         $method = $this->callbacks[$methodname];
@@ -512,7 +512,7 @@  discard block
 block discarded – undo
512 512
         if (is_string($method) && substr($method, 0, 5) == 'this:') {
513 513
             // It's a class method - check it exists
514 514
             $method = substr($method, 5);
515
-            if (!method_exists($this, $method)) {
515
+            if ( ! method_exists($this, $method)) {
516 516
                 return new IXR_Error(-32601, 'server error. requested class method "'.$method.'" does not exist.');
517 517
             }
518 518
 
@@ -521,10 +521,10 @@  discard block
 block discarded – undo
521 521
         } else {
522 522
             // It's a function - does it exist?
523 523
             if (is_array($method)) {
524
-                if (!is_callable(array($method[0], $method[1]))) {
524
+                if ( ! is_callable(array($method[0], $method[1]))) {
525 525
                     return new IXR_Error(-32601, 'server error. requested object method "'.$method[1].'" does not exist.');
526 526
                 }
527
-            } else if (!function_exists($method)) {
527
+            } else if ( ! function_exists($method)) {
528 528
                 return new IXR_Error(-32601, 'server error. requested function "'.$method.'" does not exist.');
529 529
             }
530 530
 
@@ -537,7 +537,7 @@  discard block
 block discarded – undo
537 537
     function error($error, $message = false)
538 538
     {
539 539
         // Accepts either an error object or an error code and message
540
-        if ($message && !is_object($error)) {
540
+        if ($message && ! is_object($error)) {
541 541
             $error = new IXR_Error($error, $message);
542 542
         }
543 543
         $this->output($error->getXml());
@@ -667,8 +667,8 @@  discard block
 block discarded – undo
667 667
 	/**
668 668
 	 * PHP4 constructor.
669 669
 	 */
670
-	public function IXR_Request( $method, $args ) {
671
-		self::__construct( $method, $args );
670
+	public function IXR_Request($method, $args) {
671
+		self::__construct($method, $args);
672 672
 	}
673 673
 
674 674
     function getLength()
@@ -707,9 +707,9 @@  discard block
 block discarded – undo
707 707
 	/**
708 708
 	 * PHP5 constructor.
709 709
 	 */
710
-    function __construct( $server, $path = false, $port = 80, $timeout = 15 )
710
+    function __construct($server, $path = false, $port = 80, $timeout = 15)
711 711
     {
712
-        if (!$path) {
712
+        if ( ! $path) {
713 713
             // Assume we have been given a URL instead
714 714
             $bits = parse_url($server);
715 715
             $this->server = $bits['host'];
@@ -717,12 +717,12 @@  discard block
 block discarded – undo
717 717
             $this->path = isset($bits['path']) ? $bits['path'] : '/';
718 718
 
719 719
             // Make absolutely sure we have a path
720
-            if (!$this->path) {
720
+            if ( ! $this->path) {
721 721
                 $this->path = '/';
722 722
             }
723 723
 
724
-            if ( ! empty( $bits['query'] ) ) {
725
-                $this->path .= '?' . $bits['query'];
724
+            if ( ! empty($bits['query'])) {
725
+                $this->path .= '?'.$bits['query'];
726 726
             }
727 727
         } else {
728 728
             $this->server = $server;
@@ -736,8 +736,8 @@  discard block
 block discarded – undo
736 736
 	/**
737 737
 	 * PHP4 constructor.
738 738
 	 */
739
-	public function IXR_Client( $server, $path = false, $port = 80, $timeout = 15 ) {
740
-		self::__construct( $server, $path, $port, $timeout );
739
+	public function IXR_Client($server, $path = false, $port = 80, $timeout = 15) {
740
+		self::__construct($server, $path, $port, $timeout);
741 741
 	}
742 742
 
743 743
     function query()
@@ -748,15 +748,15 @@  discard block
 block discarded – undo
748 748
         $length = $request->getLength();
749 749
         $xml = $request->getXml();
750 750
         $r = "\r\n";
751
-        $request  = "POST {$this->path} HTTP/1.0$r";
751
+        $request = "POST {$this->path} HTTP/1.0$r";
752 752
 
753 753
         // Merged from WP #8145 - allow custom headers
754 754
         $this->headers['Host']          = $this->server;
755 755
         $this->headers['Content-Type']  = 'text/xml';
756 756
         $this->headers['User-Agent']    = $this->useragent;
757
-        $this->headers['Content-Length']= $length;
757
+        $this->headers['Content-Length'] = $length;
758 758
 
759
-        foreach( $this->headers as $header => $value ) {
759
+        foreach ($this->headers as $header => $value) {
760 760
             $request .= "{$header}: {$value}{$r}";
761 761
         }
762 762
         $request .= $r;
@@ -773,7 +773,7 @@  discard block
 block discarded – undo
773 773
         } else {
774 774
             $fp = @fsockopen($this->server, $this->port, $errno, $errstr);
775 775
         }
776
-        if (!$fp) {
776
+        if ( ! $fp) {
777 777
             $this->error = new IXR_Error(-32300, 'transport error - could not open socket');
778 778
             return false;
779 779
         }
@@ -782,9 +782,9 @@  discard block
 block discarded – undo
782 782
         $debugContents = '';
783 783
         $gotFirstLine = false;
784 784
         $gettingHeaders = true;
785
-        while (!feof($fp)) {
785
+        while ( ! feof($fp)) {
786 786
             $line = fgets($fp, 4096);
787
-            if (!$gotFirstLine) {
787
+            if ( ! $gotFirstLine) {
788 788
                 // Check line for '200'
789 789
                 if (strstr($line, '200') === false) {
790 790
                     $this->error = new IXR_Error(-32300, 'transport error - HTTP status code was not 200');
@@ -795,7 +795,7 @@  discard block
 block discarded – undo
795 795
             if (trim($line) == '') {
796 796
                 $gettingHeaders = false;
797 797
             }
798
-            if (!$gettingHeaders) {
798
+            if ( ! $gettingHeaders) {
799 799
             	// merged from WP #12559 - remove trim
800 800
                 $contents .= $line;
801 801
             }
@@ -809,7 +809,7 @@  discard block
 block discarded – undo
809 809
 
810 810
         // Now parse what we've got back
811 811
         $this->message = new IXR_Message($contents);
812
-        if (!$this->message->parse()) {
812
+        if ( ! $this->message->parse()) {
813 813
             // XML error
814 814
             $this->error = new IXR_Error(-32700, 'parse error. not well formed');
815 815
             return false;
@@ -862,7 +862,7 @@  discard block
 block discarded – undo
862 862
 	/**
863 863
 	 * PHP5 constructor.
864 864
 	 */
865
-    function __construct( $code, $message )
865
+    function __construct($code, $message)
866 866
     {
867 867
         $this->code = $code;
868 868
         $this->message = htmlspecialchars($message);
@@ -871,8 +871,8 @@  discard block
 block discarded – undo
871 871
 	/**
872 872
 	 * PHP4 constructor.
873 873
 	 */
874
-	public function IXR_Error( $code, $message ) {
875
-		self::__construct( $code, $message );
874
+	public function IXR_Error($code, $message) {
875
+		self::__construct($code, $message);
876 876
 	}
877 877
 
878 878
     function getXml()
@@ -918,7 +918,7 @@  discard block
 block discarded – undo
918 918
 	/**
919 919
 	 * PHP5 constructor.
920 920
 	 */
921
-    function __construct( $time )
921
+    function __construct($time)
922 922
     {
923 923
         // $time can be a PHP timestamp or an ISO one
924 924
         if (is_numeric($time)) {
@@ -931,8 +931,8 @@  discard block
 block discarded – undo
931 931
 	/**
932 932
 	 * PHP4 constructor.
933 933
 	 */
934
-	public function IXR_Date( $time ) {
935
-		self::__construct( $time );
934
+	public function IXR_Date($time) {
935
+		self::__construct($time);
936 936
 	}
937 937
 
938 938
     function parseTimestamp($timestamp)
@@ -986,7 +986,7 @@  discard block
 block discarded – undo
986 986
 	/**
987 987
 	 * PHP5 constructor.
988 988
 	 */
989
-    function __construct( $data )
989
+    function __construct($data)
990 990
     {
991 991
         $this->data = $data;
992 992
     }
@@ -994,8 +994,8 @@  discard block
 block discarded – undo
994 994
 	/**
995 995
 	 * PHP4 constructor.
996 996
 	 */
997
-	public function IXR_Base64( $data ) {
998
-		self::__construct( $data );
997
+	public function IXR_Base64($data) {
998
+		self::__construct($data);
999 999
 	}
1000 1000
 
1001 1001
     function getXml()
@@ -1069,12 +1069,12 @@  discard block
 block discarded – undo
1069 1069
     function call($methodname, $args)
1070 1070
     {
1071 1071
         // Make sure it's in an array
1072
-        if ($args && !is_array($args)) {
1072
+        if ($args && ! is_array($args)) {
1073 1073
             $args = array($args);
1074 1074
         }
1075 1075
 
1076 1076
         // Over-rides default call method, adds signature check
1077
-        if (!$this->hasMethod($methodname)) {
1077
+        if ( ! $this->hasMethod($methodname)) {
1078 1078
             return new IXR_Error(-32601, 'server error. requested method "'.$this->message->methodName.'" not specified.');
1079 1079
         }
1080 1080
         $method = $this->callbacks[$methodname];
@@ -1095,13 +1095,13 @@  discard block
 block discarded – undo
1095 1095
             switch ($type) {
1096 1096
                 case 'int':
1097 1097
                 case 'i4':
1098
-                    if (is_array($arg) || !is_int($arg)) {
1098
+                    if (is_array($arg) || ! is_int($arg)) {
1099 1099
                         $ok = false;
1100 1100
                     }
1101 1101
                     break;
1102 1102
                 case 'base64':
1103 1103
                 case 'string':
1104
-                    if (!is_string($arg)) {
1104
+                    if ( ! is_string($arg)) {
1105 1105
                         $ok = false;
1106 1106
                     }
1107 1107
                     break;
@@ -1112,18 +1112,18 @@  discard block
 block discarded – undo
1112 1112
                     break;
1113 1113
                 case 'float':
1114 1114
                 case 'double':
1115
-                    if (!is_float($arg)) {
1115
+                    if ( ! is_float($arg)) {
1116 1116
                         $ok = false;
1117 1117
                     }
1118 1118
                     break;
1119 1119
                 case 'date':
1120 1120
                 case 'dateTime.iso8601':
1121
-                    if (!is_a($arg, 'IXR_Date')) {
1121
+                    if ( ! is_a($arg, 'IXR_Date')) {
1122 1122
                         $ok = false;
1123 1123
                     }
1124 1124
                     break;
1125 1125
             }
1126
-            if (!$ok) {
1126
+            if ( ! $ok) {
1127 1127
                 return new IXR_Error(-32602, 'server error. invalid method parameters');
1128 1128
             }
1129 1129
         }
@@ -1133,7 +1133,7 @@  discard block
 block discarded – undo
1133 1133
 
1134 1134
     function methodSignature($method)
1135 1135
     {
1136
-        if (!$this->hasMethod($method)) {
1136
+        if ( ! $this->hasMethod($method)) {
1137 1137
             return new IXR_Error(-32601, 'server error. requested method "'.$method.'" not specified.');
1138 1138
         }
1139 1139
         // We should be returning an array of types
@@ -1190,7 +1190,7 @@  discard block
 block discarded – undo
1190 1190
 	/**
1191 1191
 	 * PHP5 constructor.
1192 1192
 	 */
1193
-    function __construct( $server, $path = false, $port = 80 )
1193
+    function __construct($server, $path = false, $port = 80)
1194 1194
     {
1195 1195
         parent::IXR_Client($server, $path, $port);
1196 1196
         $this->useragent = 'The Incutio XML-RPC PHP Library (multicall client)';
@@ -1199,8 +1199,8 @@  discard block
 block discarded – undo
1199 1199
 	/**
1200 1200
 	 * PHP4 constructor.
1201 1201
 	 */
1202
-	public function IXR_ClientMulticall( $server, $path = false, $port = 80 ) {
1203
-		self::__construct( $server, $path, $port );
1202
+	public function IXR_ClientMulticall($server, $path = false, $port = 80) {
1203
+		self::__construct($server, $path, $port);
1204 1204
 	}
1205 1205
 
1206 1206
     function addCall()
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 truely
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 truely
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.