Completed
Push — master ( a7cd2a...eabd6c )
by Stephen
38:42
created
src/wp-admin/upload.php 2 patches
Spacing   +143 added lines, -143 removed lines patch added patch discarded remove patch
@@ -7,90 +7,90 @@  discard block
 block discarded – undo
7 7
  */
8 8
 
9 9
 /** WordPress Administration Bootstrap */
10
-require_once( dirname( __FILE__ ) . '/admin.php' );
10
+require_once(dirname(__FILE__).'/admin.php');
11 11
 
12
-if ( !current_user_can('upload_files') )
13
-	wp_die( __( 'You do not have permission to upload files.' ) );
12
+if ( ! current_user_can('upload_files'))
13
+	wp_die(__('You do not have permission to upload files.'));
14 14
 
15
-$mode = get_user_option( 'media_library_mode', get_current_user_id() ) ? get_user_option( 'media_library_mode', get_current_user_id() ) : 'grid';
16
-$modes = array( 'grid', 'list' );
15
+$mode = get_user_option('media_library_mode', get_current_user_id()) ? get_user_option('media_library_mode', get_current_user_id()) : 'grid';
16
+$modes = array('grid', 'list');
17 17
 
18
-if ( isset( $_GET['mode'] ) && in_array( $_GET['mode'], $modes ) ) {
18
+if (isset($_GET['mode']) && in_array($_GET['mode'], $modes)) {
19 19
 	$mode = $_GET['mode'];
20
-	update_user_option( get_current_user_id(), 'media_library_mode', $mode );
20
+	update_user_option(get_current_user_id(), 'media_library_mode', $mode);
21 21
 }
22 22
 
23
-if ( 'grid' === $mode ) {
23
+if ('grid' === $mode) {
24 24
 	wp_enqueue_media();
25
-	wp_enqueue_script( 'media-grid' );
26
-	wp_enqueue_script( 'media' );
25
+	wp_enqueue_script('media-grid');
26
+	wp_enqueue_script('media');
27 27
 
28
-	remove_action( 'admin_head', 'wp_admin_canonical_url' );
28
+	remove_action('admin_head', 'wp_admin_canonical_url');
29 29
 
30 30
 	$q = $_GET;
31 31
 	// let JS handle this
32
-	unset( $q['s'] );
33
-	$vars = wp_edit_attachments_query_vars( $q );
34
-	$ignore = array( 'mode', 'post_type', 'post_status', 'posts_per_page' );
35
-	foreach ( $vars as $key => $value ) {
36
-		if ( ! $value || in_array( $key, $ignore ) ) {
37
-			unset( $vars[ $key ] );
32
+	unset($q['s']);
33
+	$vars = wp_edit_attachments_query_vars($q);
34
+	$ignore = array('mode', 'post_type', 'post_status', 'posts_per_page');
35
+	foreach ($vars as $key => $value) {
36
+		if ( ! $value || in_array($key, $ignore)) {
37
+			unset($vars[$key]);
38 38
 		}
39 39
 	}
40 40
 
41
-	wp_localize_script( 'media-grid', '_wpMediaGridSettings', array(
42
-		'adminUrl' => parse_url( self_admin_url(), PHP_URL_PATH ),
41
+	wp_localize_script('media-grid', '_wpMediaGridSettings', array(
42
+		'adminUrl' => parse_url(self_admin_url(), PHP_URL_PATH),
43 43
 		'queryVars' => (object) $vars
44
-	) );
44
+	));
45 45
 
46
-	get_current_screen()->add_help_tab( array(
46
+	get_current_screen()->add_help_tab(array(
47 47
 		'id'		=> 'overview',
48
-		'title'		=> __( 'Overview' ),
48
+		'title'		=> __('Overview'),
49 49
 		'content'	=>
50
-			'<p>' . __( 'All the files you&#8217;ve uploaded are listed in the Media Library, with the most recent uploads listed first.' ) . '</p>' .
51
-			'<p>' . __( 'You can view your media in a simple visual grid or a list with columns. Switch between these views using the icons to the left above the media.' ) . '</p>' .
52
-			'<p>' . __( 'To delete media items, click the Bulk Select button at the top of the screen. Select any items you wish to delete, then click the Delete Selected button. Clicking the Cancel Selection button takes you back to viewing your media.' ) . '</p>'
53
-	) );
50
+			'<p>'.__('All the files you&#8217;ve uploaded are listed in the Media Library, with the most recent uploads listed first.').'</p>'.
51
+			'<p>'.__('You can view your media in a simple visual grid or a list with columns. Switch between these views using the icons to the left above the media.').'</p>'.
52
+			'<p>'.__('To delete media items, click the Bulk Select button at the top of the screen. Select any items you wish to delete, then click the Delete Selected button. Clicking the Cancel Selection button takes you back to viewing your media.').'</p>'
53
+	));
54 54
 
55
-	get_current_screen()->add_help_tab( array(
55
+	get_current_screen()->add_help_tab(array(
56 56
 		'id'		=> 'attachment-details',
57
-		'title'		=> __( 'Attachment Details' ),
57
+		'title'		=> __('Attachment Details'),
58 58
 		'content'	=>
59
-			'<p>' . __( 'Clicking an item will display an Attachment Details dialog, which allows you to preview media and make quick edits. Any changes you make to the attachment details will be automatically saved.' ) . '</p>' .
60
-			'<p>' . __( 'Use the arrow buttons at the top of the dialog, or the left and right arrow keys on your keyboard, to navigate between media items quickly.' ) . '</p>' .
61
-			'<p>' . __( 'You can also delete individual items and access the extended edit screen from the details dialog.' ) . '</p>'
62
-	) );
59
+			'<p>'.__('Clicking an item will display an Attachment Details dialog, which allows you to preview media and make quick edits. Any changes you make to the attachment details will be automatically saved.').'</p>'.
60
+			'<p>'.__('Use the arrow buttons at the top of the dialog, or the left and right arrow keys on your keyboard, to navigate between media items quickly.').'</p>'.
61
+			'<p>'.__('You can also delete individual items and access the extended edit screen from the details dialog.').'</p>'
62
+	));
63 63
 
64 64
 	get_current_screen()->set_help_sidebar(
65
-		'<p><strong>' . __( 'For more information:' ) . '</strong></p>' .
66
-		'<p>' . __( '<a href="https://codex.wordpress.org/Media_Library_Screen" target="_blank">Documentation on Media Library</a>' ) . '</p>' .
67
-		'<p>' . __( '<a href="https://wordpress.org/support/" target="_blank">Support Forums</a>' ) . '</p>'
65
+		'<p><strong>'.__('For more information:').'</strong></p>'.
66
+		'<p>'.__('<a href="https://codex.wordpress.org/Media_Library_Screen" target="_blank">Documentation on Media Library</a>').'</p>'.
67
+		'<p>'.__('<a href="https://wordpress.org/support/" target="_blank">Support Forums</a>').'</p>'
68 68
 	);
69 69
 
70 70
 	$title = __('Media Library');
71 71
 	$parent_file = 'upload.php';
72 72
 
73
-	require_once( ABSPATH . 'wp-admin/admin-header.php' );
73
+	require_once(ABSPATH.'wp-admin/admin-header.php');
74 74
 	?>
75 75
 	<div class="wrap" id="wp-media-grid" data-search="<?php _admin_search_query() ?>">
76 76
 		<h1>
77 77
 		<?php
78
-		echo esc_html( $title );
79
-		if ( current_user_can( 'upload_files' ) ) { ?>
80
-			<a href="<?php echo admin_url( 'media-new.php' ); ?>" class="page-title-action"><?php echo esc_html_x( 'Add New', 'file' ); ?></a><?php
78
+		echo esc_html($title);
79
+		if (current_user_can('upload_files')) { ?>
80
+			<a href="<?php echo admin_url('media-new.php'); ?>" class="page-title-action"><?php echo esc_html_x('Add New', 'file'); ?></a><?php
81 81
 		}
82 82
 		?>
83 83
 		</h1>
84 84
 		<div class="error hide-if-js">
85 85
 			<p><?php printf(
86 86
 				/* translators: %s: list view URL */
87
-				__( 'The grid view for the Media Library requires JavaScript. <a href="%s">Switch to the list view</a>.' ),
87
+				__('The grid view for the Media Library requires JavaScript. <a href="%s">Switch to the list view</a>.'),
88 88
 				'upload.php?mode=list'
89 89
 			); ?></p>
90 90
 		</div>
91 91
 	</div>
92 92
 	<?php
93
-	include( ABSPATH . 'wp-admin/admin-footer.php' );
93
+	include(ABSPATH.'wp-admin/admin-footer.php');
94 94
 	exit;
95 95
 }
96 96
 
@@ -100,75 +100,75 @@  discard block
 block discarded – undo
100 100
 // Handle bulk actions
101 101
 $doaction = $wp_list_table->current_action();
102 102
 
103
-if ( $doaction ) {
103
+if ($doaction) {
104 104
 	check_admin_referer('bulk-media');
105 105
 
106
-	if ( 'delete_all' == $doaction ) {
107
-		$post_ids = $wpdb->get_col( "SELECT ID FROM $wpdb->posts WHERE post_type='attachment' AND post_status = 'trash'" );
106
+	if ('delete_all' == $doaction) {
107
+		$post_ids = $wpdb->get_col("SELECT ID FROM $wpdb->posts WHERE post_type='attachment' AND post_status = 'trash'");
108 108
 		$doaction = 'delete';
109
-	} elseif ( isset( $_REQUEST['media'] ) ) {
109
+	} elseif (isset($_REQUEST['media'])) {
110 110
 		$post_ids = $_REQUEST['media'];
111
-	} elseif ( isset( $_REQUEST['ids'] ) ) {
112
-		$post_ids = explode( ',', $_REQUEST['ids'] );
111
+	} elseif (isset($_REQUEST['ids'])) {
112
+		$post_ids = explode(',', $_REQUEST['ids']);
113 113
 	}
114 114
 
115 115
 	$location = 'upload.php';
116
-	if ( $referer = wp_get_referer() ) {
117
-		if ( false !== strpos( $referer, 'upload.php' ) )
118
-			$location = remove_query_arg( array( 'trashed', 'untrashed', 'deleted', 'message', 'ids', 'posted' ), $referer );
116
+	if ($referer = wp_get_referer()) {
117
+		if (false !== strpos($referer, 'upload.php'))
118
+			$location = remove_query_arg(array('trashed', 'untrashed', 'deleted', 'message', 'ids', 'posted'), $referer);
119 119
 	}
120 120
 
121
-	switch ( $doaction ) {
121
+	switch ($doaction) {
122 122
 		case 'detach':
123
-			wp_media_attach_action( $_REQUEST['parent_post_id'], 'detach' );
123
+			wp_media_attach_action($_REQUEST['parent_post_id'], 'detach');
124 124
 			break;
125 125
 
126 126
 		case 'attach':
127
-			wp_media_attach_action( $_REQUEST['found_post_id'] );
127
+			wp_media_attach_action($_REQUEST['found_post_id']);
128 128
 			break;
129 129
 
130 130
 		case 'trash':
131
-			if ( !isset( $post_ids ) )
131
+			if ( ! isset($post_ids))
132 132
 				break;
133
-			foreach ( (array) $post_ids as $post_id ) {
134
-				if ( !current_user_can( 'delete_post', $post_id ) )
135
-					wp_die( __( 'You are not allowed to move this item to the Trash.' ) );
133
+			foreach ((array) $post_ids as $post_id) {
134
+				if ( ! current_user_can('delete_post', $post_id))
135
+					wp_die(__('You are not allowed to move this item to the Trash.'));
136 136
 
137
-				if ( !wp_trash_post( $post_id ) )
138
-					wp_die( __( 'Error in moving to Trash.' ) );
137
+				if ( ! wp_trash_post($post_id))
138
+					wp_die(__('Error in moving to Trash.'));
139 139
 			}
140
-			$location = add_query_arg( array( 'trashed' => count( $post_ids ), 'ids' => join( ',', $post_ids ) ), $location );
140
+			$location = add_query_arg(array('trashed' => count($post_ids), 'ids' => join(',', $post_ids)), $location);
141 141
 			break;
142 142
 		case 'untrash':
143
-			if ( !isset( $post_ids ) )
143
+			if ( ! isset($post_ids))
144 144
 				break;
145
-			foreach ( (array) $post_ids as $post_id ) {
146
-				if ( !current_user_can( 'delete_post', $post_id ) )
147
-					wp_die( __( 'You are not allowed to move this item out of the Trash.' ) );
145
+			foreach ((array) $post_ids as $post_id) {
146
+				if ( ! current_user_can('delete_post', $post_id))
147
+					wp_die(__('You are not allowed to move this item out of the Trash.'));
148 148
 
149
-				if ( !wp_untrash_post( $post_id ) )
150
-					wp_die( __( 'Error in restoring from Trash.' ) );
149
+				if ( ! wp_untrash_post($post_id))
150
+					wp_die(__('Error in restoring from Trash.'));
151 151
 			}
152
-			$location = add_query_arg( 'untrashed', count( $post_ids ), $location );
152
+			$location = add_query_arg('untrashed', count($post_ids), $location);
153 153
 			break;
154 154
 		case 'delete':
155
-			if ( !isset( $post_ids ) )
155
+			if ( ! isset($post_ids))
156 156
 				break;
157
-			foreach ( (array) $post_ids as $post_id_del ) {
158
-				if ( !current_user_can( 'delete_post', $post_id_del ) )
159
-					wp_die( __( 'You are not allowed to delete this item.' ) );
157
+			foreach ((array) $post_ids as $post_id_del) {
158
+				if ( ! current_user_can('delete_post', $post_id_del))
159
+					wp_die(__('You are not allowed to delete this item.'));
160 160
 
161
-				if ( !wp_delete_attachment( $post_id_del ) )
162
-					wp_die( __( 'Error in deleting.' ) );
161
+				if ( ! wp_delete_attachment($post_id_del))
162
+					wp_die(__('Error in deleting.'));
163 163
 			}
164
-			$location = add_query_arg( 'deleted', count( $post_ids ), $location );
164
+			$location = add_query_arg('deleted', count($post_ids), $location);
165 165
 			break;
166 166
 	}
167 167
 
168
-	wp_redirect( $location );
168
+	wp_redirect($location);
169 169
 	exit;
170
-} elseif ( ! empty( $_GET['_wp_http_referer'] ) ) {
171
-	 wp_redirect( remove_query_arg( array( '_wp_http_referer', '_wpnonce' ), wp_unslash( $_SERVER['REQUEST_URI'] ) ) );
170
+} elseif ( ! empty($_GET['_wp_http_referer'])) {
171
+	 wp_redirect(remove_query_arg(array('_wp_http_referer', '_wpnonce'), wp_unslash($_SERVER['REQUEST_URI'])));
172 172
 	 exit;
173 173
 }
174 174
 
@@ -177,135 +177,135 @@  discard block
 block discarded – undo
177 177
 $title = __('Media Library');
178 178
 $parent_file = 'upload.php';
179 179
 
180
-wp_enqueue_script( 'media' );
180
+wp_enqueue_script('media');
181 181
 
182
-add_screen_option( 'per_page' );
182
+add_screen_option('per_page');
183 183
 
184
-get_current_screen()->add_help_tab( array(
184
+get_current_screen()->add_help_tab(array(
185 185
 'id'		=> 'overview',
186 186
 'title'		=> __('Overview'),
187 187
 'content'	=>
188
-	'<p>' . __( 'All the files you&#8217;ve uploaded are listed in the Media Library, with the most recent uploads listed first. You can use the Screen Options tab to customize the display of this screen.' ) . '</p>' .
189
-	'<p>' . __( 'You can narrow the list by file type/status or by date using the dropdown menus above the media table.' ) . '</p>' .
190
-	'<p>' . __( 'You can view your media in a simple visual grid or a list with columns. Switch between these views using the icons to the left above the media.' ) . '</p>'
191
-) );
192
-get_current_screen()->add_help_tab( array(
188
+	'<p>'.__('All the files you&#8217;ve uploaded are listed in the Media Library, with the most recent uploads listed first. You can use the Screen Options tab to customize the display of this screen.').'</p>'.
189
+	'<p>'.__('You can narrow the list by file type/status or by date using the dropdown menus above the media table.').'</p>'.
190
+	'<p>'.__('You can view your media in a simple visual grid or a list with columns. Switch between these views using the icons to the left above the media.').'</p>'
191
+));
192
+get_current_screen()->add_help_tab(array(
193 193
 'id'		=> 'actions-links',
194 194
 'title'		=> __('Available Actions'),
195 195
 'content'	=>
196
-	'<p>' . __( 'Hovering over a row reveals action links: Edit, Delete Permanently, and View. Clicking Edit or on the media file&#8217;s name displays a simple screen to edit that individual file&#8217;s metadata. Clicking Delete Permanently will delete the file from the media library (as well as from any posts to which it is currently attached). View will take you to the display page for that file.' ) . '</p>'
197
-) );
198
-get_current_screen()->add_help_tab( array(
196
+	'<p>'.__('Hovering over a row reveals action links: Edit, Delete Permanently, and View. Clicking Edit or on the media file&#8217;s name displays a simple screen to edit that individual file&#8217;s metadata. Clicking Delete Permanently will delete the file from the media library (as well as from any posts to which it is currently attached). View will take you to the display page for that file.').'</p>'
197
+));
198
+get_current_screen()->add_help_tab(array(
199 199
 'id'		=> 'attaching-files',
200 200
 'title'		=> __('Attaching Files'),
201 201
 'content'	=>
202
-	'<p>' . __( 'If a media file has not been attached to any content, you will see that in the Uploaded To column, and can click on Attach to launch a small popup that will allow you to search for existing content and attach the file.' ) . '</p>'
203
-) );
202
+	'<p>'.__('If a media file has not been attached to any content, you will see that in the Uploaded To column, and can click on Attach to launch a small popup that will allow you to search for existing content and attach the file.').'</p>'
203
+));
204 204
 
205 205
 get_current_screen()->set_help_sidebar(
206
-	'<p><strong>' . __( 'For more information:' ) . '</strong></p>' .
207
-	'<p>' . __( '<a href="https://codex.wordpress.org/Media_Library_Screen" target="_blank">Documentation on Media Library</a>' ) . '</p>' .
208
-	'<p>' . __( '<a href="https://wordpress.org/support/" target="_blank">Support Forums</a>' ) . '</p>'
206
+	'<p><strong>'.__('For more information:').'</strong></p>'.
207
+	'<p>'.__('<a href="https://codex.wordpress.org/Media_Library_Screen" target="_blank">Documentation on Media Library</a>').'</p>'.
208
+	'<p>'.__('<a href="https://wordpress.org/support/" target="_blank">Support Forums</a>').'</p>'
209 209
 );
210 210
 
211
-get_current_screen()->set_screen_reader_content( array(
212
-	'heading_views'      => __( 'Filter media items list' ),
213
-	'heading_pagination' => __( 'Media items list navigation' ),
214
-	'heading_list'       => __( 'Media items list' ),
215
-) );
211
+get_current_screen()->set_screen_reader_content(array(
212
+	'heading_views'      => __('Filter media items list'),
213
+	'heading_pagination' => __('Media items list navigation'),
214
+	'heading_list'       => __('Media items list'),
215
+));
216 216
 
217
-require_once( ABSPATH . 'wp-admin/admin-header.php' );
217
+require_once(ABSPATH.'wp-admin/admin-header.php');
218 218
 ?>
219 219
 
220 220
 <div class="wrap">
221 221
 <h1>
222 222
 <?php
223
-echo esc_html( $title );
224
-if ( current_user_can( 'upload_files' ) ) { ?>
225
-	<a href="<?php echo admin_url( 'media-new.php' ); ?>" class="page-title-action"><?php echo esc_html_x('Add New', 'file'); ?></a><?php
223
+echo esc_html($title);
224
+if (current_user_can('upload_files')) { ?>
225
+	<a href="<?php echo admin_url('media-new.php'); ?>" class="page-title-action"><?php echo esc_html_x('Add New', 'file'); ?></a><?php
226 226
 }
227
-if ( isset( $_REQUEST['s'] ) && strlen( $_REQUEST['s'] ) ) {
227
+if (isset($_REQUEST['s']) && strlen($_REQUEST['s'])) {
228 228
 	/* translators: %s: search keywords */
229
-	printf( '<span class="subtitle">' . __( 'Search results for &#8220;%s&#8221;' ) . '</span>', get_search_query() );
229
+	printf('<span class="subtitle">'.__('Search results for &#8220;%s&#8221;').'</span>', get_search_query());
230 230
 }
231 231
 ?>
232 232
 </h1>
233 233
 
234 234
 <?php
235 235
 $message = '';
236
-if ( ! empty( $_GET['posted'] ) ) {
237
-	$message = __( 'Media file updated.' );
236
+if ( ! empty($_GET['posted'])) {
237
+	$message = __('Media file updated.');
238 238
 	$_SERVER['REQUEST_URI'] = remove_query_arg(array('posted'), $_SERVER['REQUEST_URI']);
239 239
 }
240 240
 
241
-if ( ! empty( $_GET['attached'] ) && $attached = absint( $_GET['attached'] ) ) {
242
-	if ( 1 == $attached ) {
243
-		$message = __( 'Media file attached.' );
241
+if ( ! empty($_GET['attached']) && $attached = absint($_GET['attached'])) {
242
+	if (1 == $attached) {
243
+		$message = __('Media file attached.');
244 244
 	} else {
245 245
 		/* translators: %s: number of media files */
246
-		$message = _n( '%s media file attached.', '%s media files attached.', $attached );
246
+		$message = _n('%s media file attached.', '%s media files attached.', $attached);
247 247
 	}
248
-	$message = sprintf( $message, number_format_i18n( $attached ) );
249
-	$_SERVER['REQUEST_URI'] = remove_query_arg( array( 'detach', 'attached' ), $_SERVER['REQUEST_URI'] );
248
+	$message = sprintf($message, number_format_i18n($attached));
249
+	$_SERVER['REQUEST_URI'] = remove_query_arg(array('detach', 'attached'), $_SERVER['REQUEST_URI']);
250 250
 }
251 251
 
252
-if ( ! empty( $_GET['detach'] ) && $detached = absint( $_GET['detach'] ) ) {
253
-	if ( 1 == $detached ) {
254
-		$message = __( 'Media file detached.' );
252
+if ( ! empty($_GET['detach']) && $detached = absint($_GET['detach'])) {
253
+	if (1 == $detached) {
254
+		$message = __('Media file detached.');
255 255
 	} else {
256 256
 		/* translators: %s: number of media files */
257
-		$message = _n( '%s media file detached.', '%s media files detached.', $detached );
257
+		$message = _n('%s media file detached.', '%s media files detached.', $detached);
258 258
 	}
259
-	$message = sprintf( $message, number_format_i18n( $detached ) );
260
-	$_SERVER['REQUEST_URI'] = remove_query_arg( array( 'detach', 'attached' ), $_SERVER['REQUEST_URI'] );
259
+	$message = sprintf($message, number_format_i18n($detached));
260
+	$_SERVER['REQUEST_URI'] = remove_query_arg(array('detach', 'attached'), $_SERVER['REQUEST_URI']);
261 261
 }
262 262
 
263
-if ( ! empty( $_GET['deleted'] ) && $deleted = absint( $_GET['deleted'] ) ) {
264
-	if ( 1 == $deleted ) {
265
-		$message = __( 'Media file permanently deleted.' );
263
+if ( ! empty($_GET['deleted']) && $deleted = absint($_GET['deleted'])) {
264
+	if (1 == $deleted) {
265
+		$message = __('Media file permanently deleted.');
266 266
 	} else {
267 267
 		/* translators: %s: number of media files */
268
-		$message = _n( '%s media file permanently deleted.', '%s media files permanently deleted.', $deleted );
268
+		$message = _n('%s media file permanently deleted.', '%s media files permanently deleted.', $deleted);
269 269
 	}
270
-	$message = sprintf( $message, number_format_i18n( $deleted ) );
270
+	$message = sprintf($message, number_format_i18n($deleted));
271 271
 	$_SERVER['REQUEST_URI'] = remove_query_arg(array('deleted'), $_SERVER['REQUEST_URI']);
272 272
 }
273 273
 
274
-if ( ! empty( $_GET['trashed'] ) && $trashed = absint( $_GET['trashed'] ) ) {
275
-	if ( 1 == $trashed ) {
276
-		$message = __( 'Media file moved to the trash.' );
274
+if ( ! empty($_GET['trashed']) && $trashed = absint($_GET['trashed'])) {
275
+	if (1 == $trashed) {
276
+		$message = __('Media file moved to the trash.');
277 277
 	} else {
278 278
 		/* translators: %s: number of media files */
279
-		$message = _n( '%s media file moved to the trash.', '%s media files moved to the trash.', $trashed );
279
+		$message = _n('%s media file moved to the trash.', '%s media files moved to the trash.', $trashed);
280 280
 	}
281
-	$message = sprintf( $message, number_format_i18n( $trashed ) );
282
-	$message .= ' <a href="' . esc_url( wp_nonce_url( 'upload.php?doaction=undo&action=untrash&ids='.(isset($_GET['ids']) ? $_GET['ids'] : ''), "bulk-media" ) ) . '">' . __('Undo') . '</a>';
281
+	$message = sprintf($message, number_format_i18n($trashed));
282
+	$message .= ' <a href="'.esc_url(wp_nonce_url('upload.php?doaction=undo&action=untrash&ids='.(isset($_GET['ids']) ? $_GET['ids'] : ''), "bulk-media")).'">'.__('Undo').'</a>';
283 283
 	$_SERVER['REQUEST_URI'] = remove_query_arg(array('trashed'), $_SERVER['REQUEST_URI']);
284 284
 }
285 285
 
286
-if ( ! empty( $_GET['untrashed'] ) && $untrashed = absint( $_GET['untrashed'] ) ) {
287
-	if ( 1 == $untrashed ) {
288
-		$message = __( 'Media file restored from the trash.' );
286
+if ( ! empty($_GET['untrashed']) && $untrashed = absint($_GET['untrashed'])) {
287
+	if (1 == $untrashed) {
288
+		$message = __('Media file restored from the trash.');
289 289
 	} else {
290 290
 		/* translators: %s: number of media files */
291
-		$message = _n( '%s media file restored from the trash.', '%s media files restored from the trash.', $untrashed );
291
+		$message = _n('%s media file restored from the trash.', '%s media files restored from the trash.', $untrashed);
292 292
 	}
293
-	$message = sprintf( $message, number_format_i18n( $untrashed ) );
293
+	$message = sprintf($message, number_format_i18n($untrashed));
294 294
 	$_SERVER['REQUEST_URI'] = remove_query_arg(array('untrashed'), $_SERVER['REQUEST_URI']);
295 295
 }
296 296
 
297
-$messages[1] = __( 'Media file updated.' );
298
-$messages[2] = __( 'Media file permanently deleted.' );
299
-$messages[3] = __( 'Error saving media file.' );
300
-$messages[4] = __( 'Media file moved to the trash.' ) . ' <a href="' . esc_url( wp_nonce_url( 'upload.php?doaction=undo&action=untrash&ids='.(isset($_GET['ids']) ? $_GET['ids'] : ''), "bulk-media" ) ) . '">' . __( 'Undo' ) . '</a>';
301
-$messages[5] = __( 'Media file restored from the trash.' );
297
+$messages[1] = __('Media file updated.');
298
+$messages[2] = __('Media file permanently deleted.');
299
+$messages[3] = __('Error saving media file.');
300
+$messages[4] = __('Media file moved to the trash.').' <a href="'.esc_url(wp_nonce_url('upload.php?doaction=undo&action=untrash&ids='.(isset($_GET['ids']) ? $_GET['ids'] : ''), "bulk-media")).'">'.__('Undo').'</a>';
301
+$messages[5] = __('Media file restored from the trash.');
302 302
 
303
-if ( ! empty( $_GET['message'] ) && isset( $messages[ $_GET['message'] ] ) ) {
304
-	$message = $messages[ $_GET['message'] ];
303
+if ( ! empty($_GET['message']) && isset($messages[$_GET['message']])) {
304
+	$message = $messages[$_GET['message']];
305 305
 	$_SERVER['REQUEST_URI'] = remove_query_arg(array('message'), $_SERVER['REQUEST_URI']);
306 306
 }
307 307
 
308
-if ( !empty($message) ) { ?>
308
+if ( ! empty($message)) { ?>
309 309
 <div id="message" class="updated notice is-dismissible"><p><?php echo $message; ?></p></div>
310 310
 <?php } ?>
311 311
 
@@ -321,4 +321,4 @@  discard block
 block discarded – undo
321 321
 </div>
322 322
 
323 323
 <?php
324
-include( ABSPATH . 'wp-admin/admin-footer.php' );
324
+include(ABSPATH.'wp-admin/admin-footer.php');
Please login to merge, or discard this patch.
Braces   +32 added lines, -21 removed lines patch added patch discarded remove patch
@@ -9,8 +9,9 @@  discard block
 block discarded – undo
9 9
 /** WordPress Administration Bootstrap */
10 10
 require_once( dirname( __FILE__ ) . '/admin.php' );
11 11
 
12
-if ( !current_user_can('upload_files') )
12
+if ( !current_user_can('upload_files') ) {
13 13
 	wp_die( __( 'You do not have permission to upload files.' ) );
14
+}
14 15
 
15 16
 $mode = get_user_option( 'media_library_mode', get_current_user_id() ) ? get_user_option( 'media_library_mode', get_current_user_id() ) : 'grid';
16 17
 $modes = array( 'grid', 'list' );
@@ -114,8 +115,9 @@  discard block
 block discarded – undo
114 115
 
115 116
 	$location = 'upload.php';
116 117
 	if ( $referer = wp_get_referer() ) {
117
-		if ( false !== strpos( $referer, 'upload.php' ) )
118
-			$location = remove_query_arg( array( 'trashed', 'untrashed', 'deleted', 'message', 'ids', 'posted' ), $referer );
118
+		if ( false !== strpos( $referer, 'upload.php' ) ) {
119
+					$location = remove_query_arg( array( 'trashed', 'untrashed', 'deleted', 'message', 'ids', 'posted' ), $referer );
120
+		}
119 121
 	}
120 122
 
121 123
 	switch ( $doaction ) {
@@ -128,38 +130,47 @@  discard block
 block discarded – undo
128 130
 			break;
129 131
 
130 132
 		case 'trash':
131
-			if ( !isset( $post_ids ) )
132
-				break;
133
+			if ( !isset( $post_ids ) ) {
134
+							break;
135
+			}
133 136
 			foreach ( (array) $post_ids as $post_id ) {
134
-				if ( !current_user_can( 'delete_post', $post_id ) )
135
-					wp_die( __( 'You are not allowed to move this item to the Trash.' ) );
137
+				if ( !current_user_can( 'delete_post', $post_id ) ) {
138
+									wp_die( __( 'You are not allowed to move this item to the Trash.' ) );
139
+				}
136 140
 
137
-				if ( !wp_trash_post( $post_id ) )
138
-					wp_die( __( 'Error in moving to Trash.' ) );
141
+				if ( !wp_trash_post( $post_id ) ) {
142
+									wp_die( __( 'Error in moving to Trash.' ) );
143
+				}
139 144
 			}
140 145
 			$location = add_query_arg( array( 'trashed' => count( $post_ids ), 'ids' => join( ',', $post_ids ) ), $location );
141 146
 			break;
142 147
 		case 'untrash':
143
-			if ( !isset( $post_ids ) )
144
-				break;
148
+			if ( !isset( $post_ids ) ) {
149
+							break;
150
+			}
145 151
 			foreach ( (array) $post_ids as $post_id ) {
146
-				if ( !current_user_can( 'delete_post', $post_id ) )
147
-					wp_die( __( 'You are not allowed to move this item out of the Trash.' ) );
152
+				if ( !current_user_can( 'delete_post', $post_id ) ) {
153
+									wp_die( __( 'You are not allowed to move this item out of the Trash.' ) );
154
+				}
148 155
 
149
-				if ( !wp_untrash_post( $post_id ) )
150
-					wp_die( __( 'Error in restoring from Trash.' ) );
156
+				if ( !wp_untrash_post( $post_id ) ) {
157
+									wp_die( __( 'Error in restoring from Trash.' ) );
158
+				}
151 159
 			}
152 160
 			$location = add_query_arg( 'untrashed', count( $post_ids ), $location );
153 161
 			break;
154 162
 		case 'delete':
155
-			if ( !isset( $post_ids ) )
156
-				break;
163
+			if ( !isset( $post_ids ) ) {
164
+							break;
165
+			}
157 166
 			foreach ( (array) $post_ids as $post_id_del ) {
158
-				if ( !current_user_can( 'delete_post', $post_id_del ) )
159
-					wp_die( __( 'You are not allowed to delete this item.' ) );
167
+				if ( !current_user_can( 'delete_post', $post_id_del ) ) {
168
+									wp_die( __( 'You are not allowed to delete this item.' ) );
169
+				}
160 170
 
161
-				if ( !wp_delete_attachment( $post_id_del ) )
162
-					wp_die( __( 'Error in deleting.' ) );
171
+				if ( !wp_delete_attachment( $post_id_del ) ) {
172
+									wp_die( __( 'Error in deleting.' ) );
173
+				}
163 174
 			}
164 175
 			$location = add_query_arg( 'deleted', count( $post_ids ), $location );
165 176
 			break;
Please login to merge, or discard this patch.
src/wp-admin/includes/upgrade.php 2 patches
Spacing   +558 added lines, -558 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' );
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');
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,19 +188,19 @@  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 194
 	$first_comment_author = __('Mr WordPress');
195 195
 	$first_comment_url = 'https://wordpress.org/';
196 196
 	$first_comment = __('Hi, this is a comment.
197 197
 To delete a comment, just log in and view the post&#039;s comments. There you will have the option to edit or delete them.');
198
-	if ( is_multisite() ) {
199
-		$first_comment_author = get_site_option( 'first_comment_author', $first_comment_author );
200
-		$first_comment_url = get_site_option( 'first_comment_url', network_home_url() );
201
-		$first_comment = get_site_option( 'first_comment', $first_comment );
198
+	if (is_multisite()) {
199
+		$first_comment_author = get_site_option('first_comment_author', $first_comment_author);
200
+		$first_comment_url = get_site_option('first_comment_url', network_home_url());
201
+		$first_comment = get_site_option('first_comment', $first_comment);
202 202
 	}
203
-	$wpdb->insert( $wpdb->comments, array(
203
+	$wpdb->insert($wpdb->comments, array(
204 204
 		'comment_post_ID' => 1,
205 205
 		'comment_author' => $first_comment_author,
206 206
 		'comment_author_email' => '',
@@ -211,7 +211,7 @@  discard block
 block discarded – undo
211 211
 	));
212 212
 
213 213
 	// First Page
214
-	$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:
214
+	$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:
215 215
 
216 216
 <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>
217 217
 
@@ -219,20 +219,20 @@  discard block
 block discarded – undo
219 219
 
220 220
 <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>
221 221
 
222
-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() );
223
-	if ( is_multisite() )
224
-		$first_page = get_site_option( 'first_page', $first_page );
225
-	$first_post_guid = get_option('home') . '/?page_id=2';
226
-	$wpdb->insert( $wpdb->posts, array(
222
+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());
223
+	if (is_multisite())
224
+		$first_page = get_site_option('first_page', $first_page);
225
+	$first_post_guid = get_option('home').'/?page_id=2';
226
+	$wpdb->insert($wpdb->posts, array(
227 227
 		'post_author' => $user_id,
228 228
 		'post_date' => $now,
229 229
 		'post_date_gmt' => $now_gmt,
230 230
 		'post_content' => $first_page,
231 231
 		'post_excerpt' => '',
232 232
 		'comment_status' => 'closed',
233
-		'post_title' => __( 'Sample Page' ),
233
+		'post_title' => __('Sample Page'),
234 234
 		/* translators: Default page slug */
235
-		'post_name' => __( 'sample-page' ),
235
+		'post_name' => __('sample-page'),
236 236
 		'post_modified' => $now,
237 237
 		'post_modified_gmt' => $now_gmt,
238 238
 		'guid' => $first_post_guid,
@@ -241,37 +241,37 @@  discard block
 block discarded – undo
241 241
 		'pinged' => '',
242 242
 		'post_content_filtered' => ''
243 243
 	));
244
-	$wpdb->insert( $wpdb->postmeta, array( 'post_id' => 2, 'meta_key' => '_wp_page_template', 'meta_value' => 'default' ) );
244
+	$wpdb->insert($wpdb->postmeta, array('post_id' => 2, 'meta_key' => '_wp_page_template', 'meta_value' => 'default'));
245 245
 
246 246
 	// Set up default widgets for default theme.
247
-	update_option( 'widget_search', array ( 2 => array ( 'title' => '' ), '_multiwidget' => 1 ) );
248
-	update_option( 'widget_recent-posts', array ( 2 => array ( 'title' => '', 'number' => 5 ), '_multiwidget' => 1 ) );
249
-	update_option( 'widget_recent-comments', array ( 2 => array ( 'title' => '', 'number' => 5 ), '_multiwidget' => 1 ) );
250
-	update_option( 'widget_archives', array ( 2 => array ( 'title' => '', 'count' => 0, 'dropdown' => 0 ), '_multiwidget' => 1 ) );
251
-	update_option( 'widget_categories', array ( 2 => array ( 'title' => '', 'count' => 0, 'hierarchical' => 0, 'dropdown' => 0 ), '_multiwidget' => 1 ) );
252
-	update_option( 'widget_meta', array ( 2 => array ( 'title' => '' ), '_multiwidget' => 1 ) );
253
-	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 ) );
254
-
255
-	if ( ! is_multisite() )
256
-		update_user_meta( $user_id, 'show_welcome_panel', 1 );
257
-	elseif ( ! is_super_admin( $user_id ) && ! metadata_exists( 'user', $user_id, 'show_welcome_panel' ) )
258
-		update_user_meta( $user_id, 'show_welcome_panel', 2 );
259
-
260
-	if ( is_multisite() ) {
247
+	update_option('widget_search', array(2 => array('title' => ''), '_multiwidget' => 1));
248
+	update_option('widget_recent-posts', array(2 => array('title' => '', 'number' => 5), '_multiwidget' => 1));
249
+	update_option('widget_recent-comments', array(2 => array('title' => '', 'number' => 5), '_multiwidget' => 1));
250
+	update_option('widget_archives', array(2 => array('title' => '', 'count' => 0, 'dropdown' => 0), '_multiwidget' => 1));
251
+	update_option('widget_categories', array(2 => array('title' => '', 'count' => 0, 'hierarchical' => 0, 'dropdown' => 0), '_multiwidget' => 1));
252
+	update_option('widget_meta', array(2 => array('title' => ''), '_multiwidget' => 1));
253
+	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));
254
+
255
+	if ( ! is_multisite())
256
+		update_user_meta($user_id, 'show_welcome_panel', 1);
257
+	elseif ( ! is_super_admin($user_id) && ! metadata_exists('user', $user_id, 'show_welcome_panel'))
258
+		update_user_meta($user_id, 'show_welcome_panel', 2);
259
+
260
+	if (is_multisite()) {
261 261
 		// Flush rules to pick up the new page.
262 262
 		$wp_rewrite->init();
263 263
 		$wp_rewrite->flush_rules();
264 264
 
265 265
 		$user = new WP_User($user_id);
266
-		$wpdb->update( $wpdb->options, array('option_value' => $user->user_email), array('option_name' => 'admin_email') );
266
+		$wpdb->update($wpdb->options, array('option_value' => $user->user_email), array('option_name' => 'admin_email'));
267 267
 
268 268
 		// Remove all perms except for the login user.
269
-		$wpdb->query( $wpdb->prepare("DELETE FROM $wpdb->usermeta WHERE user_id != %d AND meta_key = %s", $user_id, $table_prefix.'user_level') );
270
-		$wpdb->query( $wpdb->prepare("DELETE FROM $wpdb->usermeta WHERE user_id != %d AND meta_key = %s", $user_id, $table_prefix.'capabilities') );
269
+		$wpdb->query($wpdb->prepare("DELETE FROM $wpdb->usermeta WHERE user_id != %d AND meta_key = %s", $user_id, $table_prefix.'user_level'));
270
+		$wpdb->query($wpdb->prepare("DELETE FROM $wpdb->usermeta WHERE user_id != %d AND meta_key = %s", $user_id, $table_prefix.'capabilities'));
271 271
 
272 272
 		// Delete any caps that snuck into the previously active blog. (Hardcoded to blog 1 for now.) TODO: Get previous_blog_id.
273
-		if ( !is_super_admin( $user_id ) && $user_id != 1 )
274
-			$wpdb->delete( $wpdb->usermeta, array( 'user_id' => $user_id , 'meta_key' => $wpdb->base_prefix.'1_capabilities' ) );
273
+		if ( ! is_super_admin($user_id) && $user_id != 1)
274
+			$wpdb->delete($wpdb->usermeta, array('user_id' => $user_id, 'meta_key' => $wpdb->base_prefix.'1_capabilities'));
275 275
 	}
276 276
 }
277 277
 endif;
@@ -291,7 +291,7 @@  discard block
 block discarded – undo
291 291
 	global $wp_rewrite;
292 292
 
293 293
 	// Bail if a permalink structure is already enabled.
294
-	if ( get_option( 'permalink_structure' ) ) {
294
+	if (get_option('permalink_structure')) {
295 295
 		return true;
296 296
 	}
297 297
 
@@ -308,20 +308,20 @@  discard block
 block discarded – undo
308 308
 		'/index.php/%year%/%monthnum%/%day%/%postname%/'
309 309
 	);
310 310
 
311
-	foreach ( (array) $permalink_structures as $permalink_structure ) {
312
-		$wp_rewrite->set_permalink_structure( $permalink_structure );
311
+	foreach ((array) $permalink_structures as $permalink_structure) {
312
+		$wp_rewrite->set_permalink_structure($permalink_structure);
313 313
 
314 314
 		/*
315 315
 	 	 * Flush rules with the hard option to force refresh of the web-server's
316 316
 	 	 * rewrite config file (e.g. .htaccess or web.config).
317 317
 	 	 */
318
-		$wp_rewrite->flush_rules( true );
318
+		$wp_rewrite->flush_rules(true);
319 319
 
320 320
 		// Test against a real WordPress Post, or if none were created, a random 404 page.
321
-		$test_url = get_permalink( 1 );
321
+		$test_url = get_permalink(1);
322 322
 
323
-		if ( ! $test_url ) {
324
-			$test_url = home_url( '/wordpress-check-for-rewrites/' );
323
+		if ( ! $test_url) {
324
+			$test_url = home_url('/wordpress-check-for-rewrites/');
325 325
 		}
326 326
 
327 327
 		/*
@@ -331,11 +331,11 @@  discard block
 block discarded – undo
331 331
 	 	 * Uses wp_remote_get() instead of wp_remote_head() because web servers
332 332
 	 	 * can block head requests.
333 333
 	 	 */
334
-		$response          = wp_remote_get( $test_url, array( 'timeout' => 5 ) );
335
-		$x_pingback_header = wp_remote_retrieve_header( $response, 'x-pingback' );
336
-		$pretty_permalinks = $x_pingback_header && $x_pingback_header === get_bloginfo( 'pingback_url' );
334
+		$response          = wp_remote_get($test_url, array('timeout' => 5));
335
+		$x_pingback_header = wp_remote_retrieve_header($response, 'x-pingback');
336
+		$pretty_permalinks = $x_pingback_header && $x_pingback_header === get_bloginfo('pingback_url');
337 337
 
338
-		if ( $pretty_permalinks ) {
338
+		if ($pretty_permalinks) {
339 339
 			return true;
340 340
 		}
341 341
 	}
@@ -344,13 +344,13 @@  discard block
 block discarded – undo
344 344
 	 * If it makes it this far, pretty permalinks failed.
345 345
 	 * Fallback to query-string permalinks.
346 346
 	 */
347
-	$wp_rewrite->set_permalink_structure( '' );
348
-	$wp_rewrite->flush_rules( true );
347
+	$wp_rewrite->set_permalink_structure('');
348
+	$wp_rewrite->flush_rules(true);
349 349
 
350 350
 	return false;
351 351
 }
352 352
 
353
-if ( !function_exists('wp_new_blog_notification') ) :
353
+if ( ! function_exists('wp_new_blog_notification')) :
354 354
 /**
355 355
  * Notifies the site admin that the setup is complete.
356 356
  *
@@ -365,11 +365,11 @@  discard block
 block discarded – undo
365 365
  * @param string $password   User's Password.
366 366
  */
367 367
 function wp_new_blog_notification($blog_title, $blog_url, $user_id, $password) {
368
-	$user = new WP_User( $user_id );
368
+	$user = new WP_User($user_id);
369 369
 	$email = $user->user_email;
370 370
 	$name = $user->user_login;
371 371
 	$login_url = wp_login_url();
372
-	$message = sprintf( __( "Your new WordPress site has been successfully set up at:
372
+	$message = sprintf(__("Your new WordPress site has been successfully set up at:
373 373
 
374 374
 %1\$s
375 375
 
@@ -383,13 +383,13 @@  discard block
 block discarded – undo
383 383
 
384 384
 --The WordPress Team
385 385
 https://wordpress.org/
386
-"), $blog_url, $name, $password, $login_url );
386
+"), $blog_url, $name, $password, $login_url);
387 387
 
388 388
 	@wp_mail($email, __('New WordPress Site'), $message);
389 389
 }
390 390
 endif;
391 391
 
392
-if ( !function_exists('wp_upgrade') ) :
392
+if ( ! function_exists('wp_upgrade')) :
393 393
 /**
394 394
  * Runs WordPress Upgrade functions.
395 395
  *
@@ -407,10 +407,10 @@  discard block
 block discarded – undo
407 407
 	$wp_current_db_version = __get_option('db_version');
408 408
 
409 409
 	// We are up-to-date. Nothing to do.
410
-	if ( $wp_db_version == $wp_current_db_version )
410
+	if ($wp_db_version == $wp_current_db_version)
411 411
 		return;
412 412
 
413
-	if ( ! is_blog_installed() )
413
+	if ( ! is_blog_installed())
414 414
 		return;
415 415
 
416 416
 	wp_check_mysql_version();
@@ -418,15 +418,15 @@  discard block
 block discarded – undo
418 418
 	pre_schema_upgrade();
419 419
 	make_db_current_silent();
420 420
 	upgrade_all();
421
-	if ( is_multisite() && is_main_site() )
421
+	if (is_multisite() && is_main_site())
422 422
 		upgrade_network();
423 423
 	wp_cache_flush();
424 424
 
425
-	if ( is_multisite() ) {
426
-		if ( $wpdb->get_row( "SELECT blog_id FROM {$wpdb->blog_versions} WHERE blog_id = '{$wpdb->blogid}'" ) )
427
-			$wpdb->query( "UPDATE {$wpdb->blog_versions} SET db_version = '{$wp_db_version}' WHERE blog_id = '{$wpdb->blogid}'" );
425
+	if (is_multisite()) {
426
+		if ($wpdb->get_row("SELECT blog_id FROM {$wpdb->blog_versions} WHERE blog_id = '{$wpdb->blogid}'"))
427
+			$wpdb->query("UPDATE {$wpdb->blog_versions} SET db_version = '{$wp_db_version}' WHERE blog_id = '{$wpdb->blogid}'");
428 428
 		else
429
-			$wpdb->query( "INSERT INTO {$wpdb->blog_versions} ( `blog_id` , `db_version` , `last_updated` ) VALUES ( '{$wpdb->blogid}', '{$wp_db_version}', NOW());" );
429
+			$wpdb->query("INSERT INTO {$wpdb->blog_versions} ( `blog_id` , `db_version` , `last_updated` ) VALUES ( '{$wpdb->blogid}', '{$wp_db_version}', NOW());");
430 430
 	}
431 431
 
432 432
 	/**
@@ -437,7 +437,7 @@  discard block
 block discarded – undo
437 437
 	 * @param int $wp_db_version         The new $wp_db_version.
438 438
 	 * @param int $wp_current_db_version The old (current) $wp_db_version.
439 439
 	 */
440
-	do_action( 'wp_upgrade', $wp_db_version, $wp_current_db_version );
440
+	do_action('wp_upgrade', $wp_db_version, $wp_current_db_version);
441 441
 }
442 442
 endif;
443 443
 
@@ -458,106 +458,106 @@  discard block
 block discarded – undo
458 458
 	$wp_current_db_version = __get_option('db_version');
459 459
 
460 460
 	// We are up-to-date. Nothing to do.
461
-	if ( $wp_db_version == $wp_current_db_version )
461
+	if ($wp_db_version == $wp_current_db_version)
462 462
 		return;
463 463
 
464 464
 	// If the version is not set in the DB, try to guess the version.
465
-	if ( empty($wp_current_db_version) ) {
465
+	if (empty($wp_current_db_version)) {
466 466
 		$wp_current_db_version = 0;
467 467
 
468 468
 		// If the template option exists, we have 1.5.
469 469
 		$template = __get_option('template');
470
-		if ( !empty($template) )
470
+		if ( ! empty($template))
471 471
 			$wp_current_db_version = 2541;
472 472
 	}
473 473
 
474
-	if ( $wp_current_db_version < 6039 )
474
+	if ($wp_current_db_version < 6039)
475 475
 		upgrade_230_options_table();
476 476
 
477 477
 	populate_options();
478 478
 
479
-	if ( $wp_current_db_version < 2541 ) {
479
+	if ($wp_current_db_version < 2541) {
480 480
 		upgrade_100();
481 481
 		upgrade_101();
482 482
 		upgrade_110();
483 483
 		upgrade_130();
484 484
 	}
485 485
 
486
-	if ( $wp_current_db_version < 3308 )
486
+	if ($wp_current_db_version < 3308)
487 487
 		upgrade_160();
488 488
 
489
-	if ( $wp_current_db_version < 4772 )
489
+	if ($wp_current_db_version < 4772)
490 490
 		upgrade_210();
491 491
 
492
-	if ( $wp_current_db_version < 4351 )
492
+	if ($wp_current_db_version < 4351)
493 493
 		upgrade_old_slugs();
494 494
 
495
-	if ( $wp_current_db_version < 5539 )
495
+	if ($wp_current_db_version < 5539)
496 496
 		upgrade_230();
497 497
 
498
-	if ( $wp_current_db_version < 6124 )
498
+	if ($wp_current_db_version < 6124)
499 499
 		upgrade_230_old_tables();
500 500
 
501
-	if ( $wp_current_db_version < 7499 )
501
+	if ($wp_current_db_version < 7499)
502 502
 		upgrade_250();
503 503
 
504
-	if ( $wp_current_db_version < 7935 )
504
+	if ($wp_current_db_version < 7935)
505 505
 		upgrade_252();
506 506
 
507
-	if ( $wp_current_db_version < 8201 )
507
+	if ($wp_current_db_version < 8201)
508 508
 		upgrade_260();
509 509
 
510
-	if ( $wp_current_db_version < 8989 )
510
+	if ($wp_current_db_version < 8989)
511 511
 		upgrade_270();
512 512
 
513
-	if ( $wp_current_db_version < 10360 )
513
+	if ($wp_current_db_version < 10360)
514 514
 		upgrade_280();
515 515
 
516
-	if ( $wp_current_db_version < 11958 )
516
+	if ($wp_current_db_version < 11958)
517 517
 		upgrade_290();
518 518
 
519
-	if ( $wp_current_db_version < 15260 )
519
+	if ($wp_current_db_version < 15260)
520 520
 		upgrade_300();
521 521
 
522
-	if ( $wp_current_db_version < 19389 )
522
+	if ($wp_current_db_version < 19389)
523 523
 		upgrade_330();
524 524
 
525
-	if ( $wp_current_db_version < 20080 )
525
+	if ($wp_current_db_version < 20080)
526 526
 		upgrade_340();
527 527
 
528
-	if ( $wp_current_db_version < 22422 )
528
+	if ($wp_current_db_version < 22422)
529 529
 		upgrade_350();
530 530
 
531
-	if ( $wp_current_db_version < 25824 )
531
+	if ($wp_current_db_version < 25824)
532 532
 		upgrade_370();
533 533
 
534
-	if ( $wp_current_db_version < 26148 )
534
+	if ($wp_current_db_version < 26148)
535 535
 		upgrade_372();
536 536
 
537
-	if ( $wp_current_db_version < 26691 )
537
+	if ($wp_current_db_version < 26691)
538 538
 		upgrade_380();
539 539
 
540
-	if ( $wp_current_db_version < 29630 )
540
+	if ($wp_current_db_version < 29630)
541 541
 		upgrade_400();
542 542
 
543
-	if ( $wp_current_db_version < 33055 )
543
+	if ($wp_current_db_version < 33055)
544 544
 		upgrade_430();
545 545
 
546
-	if ( $wp_current_db_version < 33056 )
546
+	if ($wp_current_db_version < 33056)
547 547
 		upgrade_431();
548 548
 
549
-	if ( $wp_current_db_version < 35700 )
549
+	if ($wp_current_db_version < 35700)
550 550
 		upgrade_440();
551 551
 
552
-	if ( $wp_current_db_version < 36686 )
552
+	if ($wp_current_db_version < 36686)
553 553
 		upgrade_450();
554 554
 
555 555
 	maybe_disable_link_manager();
556 556
 
557 557
 	maybe_disable_automattic_widgets();
558 558
 
559
-	update_option( 'db_version', $wp_db_version );
560
-	update_option( 'db_upgraded', true );
559
+	update_option('db_version', $wp_db_version);
560
+	update_option('db_upgraded', true);
561 561
 }
562 562
 
563 563
 /**
@@ -577,7 +577,7 @@  discard block
 block discarded – undo
577 577
 		foreach ($posts as $post) {
578 578
 			if ('' == $post->post_name) {
579 579
 				$newtitle = sanitize_title($post->post_title);
580
-				$wpdb->query( $wpdb->prepare("UPDATE $wpdb->posts SET post_name = %s WHERE ID = %d", $newtitle, $post->ID) );
580
+				$wpdb->query($wpdb->prepare("UPDATE $wpdb->posts SET post_name = %s WHERE ID = %d", $newtitle, $post->ID));
581 581
 			}
582 582
 		}
583 583
 	}
@@ -586,7 +586,7 @@  discard block
 block discarded – undo
586 586
 	foreach ($categories as $category) {
587 587
 		if ('' == $category->category_nicename) {
588 588
 			$newtitle = sanitize_title($category->cat_name);
589
-			$wpdb->update( $wpdb->categories, array('category_nicename' => $newtitle), array('cat_ID' => $category->cat_ID) );
589
+			$wpdb->update($wpdb->categories, array('category_nicename' => $newtitle), array('cat_ID' => $category->cat_ID));
590 590
 		}
591 591
 	}
592 592
 
@@ -594,7 +594,7 @@  discard block
 block discarded – undo
594 594
 		SET option_value = REPLACE(option_value, 'wp-links/links-images/', 'wp-images/links/')
595 595
 		WHERE option_name LIKE %s
596 596
 		AND option_value LIKE %s";
597
-	$wpdb->query( $wpdb->prepare( $sql, $wpdb->esc_like( 'links_rating_image' ) . '%', $wpdb->esc_like( 'wp-links/links-images/' ) . '%' ) );
597
+	$wpdb->query($wpdb->prepare($sql, $wpdb->esc_like('links_rating_image').'%', $wpdb->esc_like('wp-links/links-images/').'%'));
598 598
 
599 599
 	$done_ids = $wpdb->get_results("SELECT DISTINCT post_id FROM $wpdb->post2cat");
600 600
 	if ($done_ids) :
@@ -602,7 +602,7 @@  discard block
 block discarded – undo
602 602
 		foreach ($done_ids as $done_id) :
603 603
 			$done_posts[] = $done_id->post_id;
604 604
 		endforeach;
605
-		$catwhere = ' AND ID NOT IN (' . implode(',', $done_posts) . ')';
605
+		$catwhere = ' AND ID NOT IN ('.implode(',', $done_posts).')';
606 606
 	else:
607 607
 		$catwhere = '';
608 608
 	endif;
@@ -611,9 +611,9 @@  discard block
 block discarded – undo
611 611
 	if ($allposts) :
612 612
 		foreach ($allposts as $post) {
613 613
 			// Check to see if it's already been imported
614
-			$cat = $wpdb->get_row( $wpdb->prepare("SELECT * FROM $wpdb->post2cat WHERE post_id = %d AND category_id = %d", $post->ID, $post->post_category) );
615
-			if (!$cat && 0 != $post->post_category) { // If there's no result
616
-				$wpdb->insert( $wpdb->post2cat, array('post_id' => $post->ID, 'category_id' => $post->post_category) );
614
+			$cat = $wpdb->get_row($wpdb->prepare("SELECT * FROM $wpdb->post2cat WHERE post_id = %d AND category_id = %d", $post->ID, $post->post_category));
615
+			if ( ! $cat && 0 != $post->post_category) { // If there's no result
616
+				$wpdb->insert($wpdb->post2cat, array('post_id' => $post->ID, 'category_id' => $post->post_category));
617 617
 			}
618 618
 		}
619 619
 	endif;
@@ -636,8 +636,8 @@  discard block
 block discarded – undo
636 636
 	add_clean_index($wpdb->categories, 'category_nicename');
637 637
 	add_clean_index($wpdb->comments, 'comment_approved');
638 638
 	add_clean_index($wpdb->comments, 'comment_post_ID');
639
-	add_clean_index($wpdb->links , 'link_category');
640
-	add_clean_index($wpdb->links , 'link_visible');
639
+	add_clean_index($wpdb->links, 'link_category');
640
+	add_clean_index($wpdb->links, 'link_visible');
641 641
 }
642 642
 
643 643
 /**
@@ -656,14 +656,14 @@  discard block
 block discarded – undo
656 656
 	foreach ($users as $user) {
657 657
 		if ('' == $user->user_nicename) {
658 658
 			$newname = sanitize_title($user->user_nickname);
659
-			$wpdb->update( $wpdb->users, array('user_nicename' => $newname), array('ID' => $user->ID) );
659
+			$wpdb->update($wpdb->users, array('user_nicename' => $newname), array('ID' => $user->ID));
660 660
 		}
661 661
 	}
662 662
 
663 663
 	$users = $wpdb->get_results("SELECT ID, user_pass from $wpdb->users");
664 664
 	foreach ($users as $row) {
665
-		if (!preg_match('/^[A-Fa-f0-9]{32}$/', $row->user_pass)) {
666
-			$wpdb->update( $wpdb->users, array('user_pass' => md5($row->user_pass)), array('ID' => $row->ID) );
665
+		if ( ! preg_match('/^[A-Fa-f0-9]{32}$/', $row->user_pass)) {
666
+			$wpdb->update($wpdb->users, array('user_pass' => md5($row->user_pass)), array('ID' => $row->ID));
667 667
 		}
668 668
 	}
669 669
 
@@ -672,7 +672,7 @@  discard block
 block discarded – undo
672 672
 
673 673
 	$time_difference = $all_options->time_difference;
674 674
 
675
-		$server_time = time()+date('Z');
675
+		$server_time = time() + date('Z');
676 676
 	$weblogger_time = $server_time + $time_difference * HOUR_IN_SECONDS;
677 677
 	$gmt_time = time();
678 678
 
@@ -689,7 +689,7 @@  discard block
 block discarded – undo
689 689
 	// <michel_v> I just slapped myself silly for not thinking about it earlier
690 690
 	$got_gmt_fields = ! ($wpdb->get_var("SELECT MAX(post_date_gmt) FROM $wpdb->posts") == '0000-00-00 00:00:00');
691 691
 
692
-	if (!$got_gmt_fields) {
692
+	if ( ! $got_gmt_fields) {
693 693
 
694 694
 		// Add or subtract time to all dates, to get GMT dates
695 695
 		$add_hours = intval($diff_gmt_weblogger);
@@ -721,12 +721,12 @@  discard block
 block discarded – undo
721 721
 			$post_content = addslashes(deslash($post->post_content));
722 722
 			$post_title = addslashes(deslash($post->post_title));
723 723
 			$post_excerpt = addslashes(deslash($post->post_excerpt));
724
-			if ( empty($post->guid) )
724
+			if (empty($post->guid))
725 725
 				$guid = get_permalink($post->ID);
726 726
 			else
727 727
 				$guid = $post->guid;
728 728
 
729
-			$wpdb->update( $wpdb->posts, compact('post_title', 'post_content', 'post_excerpt', 'guid'), array('ID' => $post->ID) );
729
+			$wpdb->update($wpdb->posts, compact('post_title', 'post_content', 'post_excerpt', 'guid'), array('ID' => $post->ID));
730 730
 
731 731
 		}
732 732
 	}
@@ -738,7 +738,7 @@  discard block
 block discarded – undo
738 738
 			$comment_content = deslash($comment->comment_content);
739 739
 			$comment_author = deslash($comment->comment_author);
740 740
 
741
-			$wpdb->update($wpdb->comments, compact('comment_content', 'comment_author'), array('comment_ID' => $comment->comment_ID) );
741
+			$wpdb->update($wpdb->comments, compact('comment_content', 'comment_author'), array('comment_ID' => $comment->comment_ID));
742 742
 		}
743 743
 	}
744 744
 
@@ -749,7 +749,7 @@  discard block
 block discarded – undo
749 749
 			$link_name = deslash($link->link_name);
750 750
 			$link_description = deslash($link->link_description);
751 751
 
752
-			$wpdb->update( $wpdb->links, compact('link_name', 'link_description'), array('link_id' => $link->link_id) );
752
+			$wpdb->update($wpdb->links, compact('link_name', 'link_description'), array('link_id' => $link->link_id));
753 753
 		}
754 754
 	}
755 755
 
@@ -759,16 +759,16 @@  discard block
 block discarded – undo
759 759
 	 * If plugins are not stored in an array, they're stored in the old
760 760
 	 * newline separated format. Convert to new format.
761 761
 	 */
762
-	if ( !is_array( $active_plugins ) ) {
762
+	if ( ! is_array($active_plugins)) {
763 763
 		$active_plugins = explode("\n", trim($active_plugins));
764 764
 		update_option('active_plugins', $active_plugins);
765 765
 	}
766 766
 
767 767
 	// Obsolete tables
768
-	$wpdb->query('DROP TABLE IF EXISTS ' . $wpdb->prefix . 'optionvalues');
769
-	$wpdb->query('DROP TABLE IF EXISTS ' . $wpdb->prefix . 'optiontypes');
770
-	$wpdb->query('DROP TABLE IF EXISTS ' . $wpdb->prefix . 'optiongroups');
771
-	$wpdb->query('DROP TABLE IF EXISTS ' . $wpdb->prefix . 'optiongroup_options');
768
+	$wpdb->query('DROP TABLE IF EXISTS '.$wpdb->prefix.'optionvalues');
769
+	$wpdb->query('DROP TABLE IF EXISTS '.$wpdb->prefix.'optiontypes');
770
+	$wpdb->query('DROP TABLE IF EXISTS '.$wpdb->prefix.'optiongroups');
771
+	$wpdb->query('DROP TABLE IF EXISTS '.$wpdb->prefix.'optiongroup_options');
772 772
 
773 773
 	// Update comments table to use comment_type
774 774
 	$wpdb->query("UPDATE $wpdb->comments SET comment_type='trackback', comment_content = REPLACE(comment_content, '<trackback />', '') WHERE comment_content LIKE '<trackback />%'");
@@ -776,11 +776,11 @@  discard block
 block discarded – undo
776 776
 
777 777
 	// Some versions have multiple duplicate option_name rows with the same values
778 778
 	$options = $wpdb->get_results("SELECT option_name, COUNT(option_name) AS dupes FROM `$wpdb->options` GROUP BY option_name");
779
-	foreach ( $options as $option ) {
780
-		if ( 1 != $option->dupes ) { // Could this be done in the query?
779
+	foreach ($options as $option) {
780
+		if (1 != $option->dupes) { // Could this be done in the query?
781 781
 			$limit = $option->dupes - 1;
782
-			$dupe_ids = $wpdb->get_col( $wpdb->prepare("SELECT option_id FROM $wpdb->options WHERE option_name = %s LIMIT %d", $option->option_name, $limit) );
783
-			if ( $dupe_ids ) {
782
+			$dupe_ids = $wpdb->get_col($wpdb->prepare("SELECT option_id FROM $wpdb->options WHERE option_name = %s LIMIT %d", $option->option_name, $limit));
783
+			if ($dupe_ids) {
784 784
 				$dupe_ids = join($dupe_ids, ',');
785 785
 				$wpdb->query("DELETE FROM $wpdb->options WHERE option_id IN ($dupe_ids)");
786 786
 			}
@@ -805,27 +805,27 @@  discard block
 block discarded – undo
805 805
 	populate_roles_160();
806 806
 
807 807
 	$users = $wpdb->get_results("SELECT * FROM $wpdb->users");
808
-	foreach ( $users as $user ) :
809
-		if ( !empty( $user->user_firstname ) )
810
-			update_user_meta( $user->ID, 'first_name', wp_slash($user->user_firstname) );
811
-		if ( !empty( $user->user_lastname ) )
812
-			update_user_meta( $user->ID, 'last_name', wp_slash($user->user_lastname) );
813
-		if ( !empty( $user->user_nickname ) )
814
-			update_user_meta( $user->ID, 'nickname', wp_slash($user->user_nickname) );
815
-		if ( !empty( $user->user_level ) )
816
-			update_user_meta( $user->ID, $wpdb->prefix . 'user_level', $user->user_level );
817
-		if ( !empty( $user->user_icq ) )
818
-			update_user_meta( $user->ID, 'icq', wp_slash($user->user_icq) );
819
-		if ( !empty( $user->user_aim ) )
820
-			update_user_meta( $user->ID, 'aim', wp_slash($user->user_aim) );
821
-		if ( !empty( $user->user_msn ) )
822
-			update_user_meta( $user->ID, 'msn', wp_slash($user->user_msn) );
823
-		if ( !empty( $user->user_yim ) )
824
-			update_user_meta( $user->ID, 'yim', wp_slash($user->user_icq) );
825
-		if ( !empty( $user->user_description ) )
826
-			update_user_meta( $user->ID, 'description', wp_slash($user->user_description) );
827
-
828
-		if ( isset( $user->user_idmode ) ):
808
+	foreach ($users as $user) :
809
+		if ( ! empty($user->user_firstname))
810
+			update_user_meta($user->ID, 'first_name', wp_slash($user->user_firstname));
811
+		if ( ! empty($user->user_lastname))
812
+			update_user_meta($user->ID, 'last_name', wp_slash($user->user_lastname));
813
+		if ( ! empty($user->user_nickname))
814
+			update_user_meta($user->ID, 'nickname', wp_slash($user->user_nickname));
815
+		if ( ! empty($user->user_level))
816
+			update_user_meta($user->ID, $wpdb->prefix.'user_level', $user->user_level);
817
+		if ( ! empty($user->user_icq))
818
+			update_user_meta($user->ID, 'icq', wp_slash($user->user_icq));
819
+		if ( ! empty($user->user_aim))
820
+			update_user_meta($user->ID, 'aim', wp_slash($user->user_aim));
821
+		if ( ! empty($user->user_msn))
822
+			update_user_meta($user->ID, 'msn', wp_slash($user->user_msn));
823
+		if ( ! empty($user->user_yim))
824
+			update_user_meta($user->ID, 'yim', wp_slash($user->user_icq));
825
+		if ( ! empty($user->user_description))
826
+			update_user_meta($user->ID, 'description', wp_slash($user->user_description));
827
+
828
+		if (isset($user->user_idmode)):
829 829
 			$idmode = $user->user_idmode;
830 830
 			if ($idmode == 'nickname') $id = $user->user_nickname;
831 831
 			if ($idmode == 'login') $id = $user->user_login;
@@ -833,46 +833,46 @@  discard block
 block discarded – undo
833 833
 			if ($idmode == 'lastname') $id = $user->user_lastname;
834 834
 			if ($idmode == 'namefl') $id = $user->user_firstname.' '.$user->user_lastname;
835 835
 			if ($idmode == 'namelf') $id = $user->user_lastname.' '.$user->user_firstname;
836
-			if (!$idmode) $id = $user->user_nickname;
837
-			$wpdb->update( $wpdb->users, array('display_name' => $id), array('ID' => $user->ID) );
836
+			if ( ! $idmode) $id = $user->user_nickname;
837
+			$wpdb->update($wpdb->users, array('display_name' => $id), array('ID' => $user->ID));
838 838
 		endif;
839 839
 
840 840
 		// FIXME: RESET_CAPS is temporary code to reset roles and caps if flag is set.
841
-		$caps = get_user_meta( $user->ID, $wpdb->prefix . 'capabilities');
842
-		if ( empty($caps) || defined('RESET_CAPS') ) {
843
-			$level = get_user_meta($user->ID, $wpdb->prefix . 'user_level', true);
841
+		$caps = get_user_meta($user->ID, $wpdb->prefix.'capabilities');
842
+		if (empty($caps) || defined('RESET_CAPS')) {
843
+			$level = get_user_meta($user->ID, $wpdb->prefix.'user_level', true);
844 844
 			$role = translate_level_to_role($level);
845
-			update_user_meta( $user->ID, $wpdb->prefix . 'capabilities', array($role => true) );
845
+			update_user_meta($user->ID, $wpdb->prefix.'capabilities', array($role => true));
846 846
 		}
847 847
 
848 848
 	endforeach;
849
-	$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' );
849
+	$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');
850 850
 	$wpdb->hide_errors();
851
-	foreach ( $old_user_fields as $old )
851
+	foreach ($old_user_fields as $old)
852 852
 		$wpdb->query("ALTER TABLE $wpdb->users DROP $old");
853 853
 	$wpdb->show_errors();
854 854
 
855 855
 	// Populate comment_count field of posts table.
856
-	$comments = $wpdb->get_results( "SELECT comment_post_ID, COUNT(*) as c FROM $wpdb->comments WHERE comment_approved = '1' GROUP BY comment_post_ID" );
857
-	if ( is_array( $comments ) )
856
+	$comments = $wpdb->get_results("SELECT comment_post_ID, COUNT(*) as c FROM $wpdb->comments WHERE comment_approved = '1' GROUP BY comment_post_ID");
857
+	if (is_array($comments))
858 858
 		foreach ($comments as $comment)
859
-			$wpdb->update( $wpdb->posts, array('comment_count' => $comment->c), array('ID' => $comment->comment_post_ID) );
859
+			$wpdb->update($wpdb->posts, array('comment_count' => $comment->c), array('ID' => $comment->comment_post_ID));
860 860
 
861 861
 	/*
862 862
 	 * Some alpha versions used a post status of object instead of attachment
863 863
 	 * and put the mime type in post_type instead of post_mime_type.
864 864
 	 */
865
-	if ( $wp_current_db_version > 2541 && $wp_current_db_version <= 3091 ) {
865
+	if ($wp_current_db_version > 2541 && $wp_current_db_version <= 3091) {
866 866
 		$objects = $wpdb->get_results("SELECT ID, post_type FROM $wpdb->posts WHERE post_status = 'object'");
867 867
 		foreach ($objects as $object) {
868
-			$wpdb->update( $wpdb->posts, array(	'post_status' => 'attachment',
868
+			$wpdb->update($wpdb->posts, array('post_status' => 'attachment',
869 869
 												'post_mime_type' => $object->post_type,
870 870
 												'post_type' => ''),
871
-										 array( 'ID' => $object->ID ) );
871
+										 array('ID' => $object->ID));
872 872
 
873 873
 			$meta = get_post_meta($object->ID, 'imagedata', true);
874
-			if ( ! empty($meta['file']) )
875
-				update_attached_file( $object->ID, $meta['file'] );
874
+			if ( ! empty($meta['file']))
875
+				update_attached_file($object->ID, $meta['file']);
876 876
 		}
877 877
 	}
878 878
 }
@@ -889,38 +889,38 @@  discard block
 block discarded – undo
889 889
 function upgrade_210() {
890 890
 	global $wpdb, $wp_current_db_version;
891 891
 
892
-	if ( $wp_current_db_version < 3506 ) {
892
+	if ($wp_current_db_version < 3506) {
893 893
 		// Update status and type.
894 894
 		$posts = $wpdb->get_results("SELECT ID, post_status FROM $wpdb->posts");
895 895
 
896
-		if ( ! empty($posts) ) foreach ($posts as $post) {
896
+		if ( ! empty($posts)) foreach ($posts as $post) {
897 897
 			$status = $post->post_status;
898 898
 			$type = 'post';
899 899
 
900
-			if ( 'static' == $status ) {
900
+			if ('static' == $status) {
901 901
 				$status = 'publish';
902 902
 				$type = 'page';
903
-			} elseif ( 'attachment' == $status ) {
903
+			} elseif ('attachment' == $status) {
904 904
 				$status = 'inherit';
905 905
 				$type = 'attachment';
906 906
 			}
907 907
 
908
-			$wpdb->query( $wpdb->prepare("UPDATE $wpdb->posts SET post_status = %s, post_type = %s WHERE ID = %d", $status, $type, $post->ID) );
908
+			$wpdb->query($wpdb->prepare("UPDATE $wpdb->posts SET post_status = %s, post_type = %s WHERE ID = %d", $status, $type, $post->ID));
909 909
 		}
910 910
 	}
911 911
 
912
-	if ( $wp_current_db_version < 3845 ) {
912
+	if ($wp_current_db_version < 3845) {
913 913
 		populate_roles_210();
914 914
 	}
915 915
 
916
-	if ( $wp_current_db_version < 3531 ) {
916
+	if ($wp_current_db_version < 3531) {
917 917
 		// Give future posts a post_status of future.
918 918
 		$now = gmdate('Y-m-d H:i:59');
919
-		$wpdb->query ("UPDATE $wpdb->posts SET post_status = 'future' WHERE post_status = 'publish' AND post_date_gmt > '$now'");
919
+		$wpdb->query("UPDATE $wpdb->posts SET post_status = 'future' WHERE post_status = 'publish' AND post_date_gmt > '$now'");
920 920
 
921 921
 		$posts = $wpdb->get_results("SELECT ID, post_date FROM $wpdb->posts WHERE post_status ='future'");
922
-		if ( !empty($posts) )
923
-			foreach ( $posts as $post )
922
+		if ( ! empty($posts))
923
+			foreach ($posts as $post)
924 924
 				wp_schedule_single_event(mysql2date('U', $post->post_date, false), 'publish_future_post', array($post->ID));
925 925
 	}
926 926
 }
@@ -937,7 +937,7 @@  discard block
 block discarded – undo
937 937
 function upgrade_230() {
938 938
 	global $wp_current_db_version, $wpdb;
939 939
 
940
-	if ( $wp_current_db_version < 5200 ) {
940
+	if ($wp_current_db_version < 5200) {
941 941
 		populate_roles_230();
942 942
 	}
943 943
 
@@ -954,78 +954,78 @@  discard block
 block discarded – undo
954 954
 		$term_group = 0;
955 955
 
956 956
 		// Associate terms with the same slug in a term group and make slugs unique.
957
-		if ( $exists = $wpdb->get_results( $wpdb->prepare("SELECT term_id, term_group FROM $wpdb->terms WHERE slug = %s", $slug) ) ) {
957
+		if ($exists = $wpdb->get_results($wpdb->prepare("SELECT term_id, term_group FROM $wpdb->terms WHERE slug = %s", $slug))) {
958 958
 			$term_group = $exists[0]->term_group;
959 959
 			$id = $exists[0]->term_id;
960 960
 			$num = 2;
961 961
 			do {
962
-				$alt_slug = $slug . "-$num";
962
+				$alt_slug = $slug."-$num";
963 963
 				$num++;
964
-				$slug_check = $wpdb->get_var( $wpdb->prepare("SELECT slug FROM $wpdb->terms WHERE slug = %s", $alt_slug) );
965
-			} while ( $slug_check );
964
+				$slug_check = $wpdb->get_var($wpdb->prepare("SELECT slug FROM $wpdb->terms WHERE slug = %s", $alt_slug));
965
+			} while ($slug_check);
966 966
 
967 967
 			$slug = $alt_slug;
968 968
 
969
-			if ( empty( $term_group ) ) {
969
+			if (empty($term_group)) {
970 970
 				$term_group = $wpdb->get_var("SELECT MAX(term_group) FROM $wpdb->terms GROUP BY term_group") + 1;
971
-				$wpdb->query( $wpdb->prepare("UPDATE $wpdb->terms SET term_group = %d WHERE term_id = %d", $term_group, $id) );
971
+				$wpdb->query($wpdb->prepare("UPDATE $wpdb->terms SET term_group = %d WHERE term_id = %d", $term_group, $id));
972 972
 			}
973 973
 		}
974 974
 
975
-		$wpdb->query( $wpdb->prepare("INSERT INTO $wpdb->terms (term_id, name, slug, term_group) VALUES
976
-		(%d, %s, %s, %d)", $term_id, $name, $slug, $term_group) );
975
+		$wpdb->query($wpdb->prepare("INSERT INTO $wpdb->terms (term_id, name, slug, term_group) VALUES
976
+		(%d, %s, %s, %d)", $term_id, $name, $slug, $term_group));
977 977
 
978 978
 		$count = 0;
979
-		if ( !empty($category->category_count) ) {
979
+		if ( ! empty($category->category_count)) {
980 980
 			$count = (int) $category->category_count;
981 981
 			$taxonomy = 'category';
982
-			$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) );
982
+			$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));
983 983
 			$tt_ids[$term_id][$taxonomy] = (int) $wpdb->insert_id;
984 984
 		}
985 985
 
986
-		if ( !empty($category->link_count) ) {
986
+		if ( ! empty($category->link_count)) {
987 987
 			$count = (int) $category->link_count;
988 988
 			$taxonomy = 'link_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->tag_count) ) {
993
+		if ( ! empty($category->tag_count)) {
994 994
 			$have_tags = true;
995 995
 			$count = (int) $category->tag_count;
996 996
 			$taxonomy = 'post_tag';
997
-			$wpdb->insert( $wpdb->term_taxonomy, compact('term_id', 'taxonomy', 'description', 'parent', 'count') );
997
+			$wpdb->insert($wpdb->term_taxonomy, compact('term_id', 'taxonomy', 'description', 'parent', 'count'));
998 998
 			$tt_ids[$term_id][$taxonomy] = (int) $wpdb->insert_id;
999 999
 		}
1000 1000
 
1001
-		if ( empty($count) ) {
1001
+		if (empty($count)) {
1002 1002
 			$count = 0;
1003 1003
 			$taxonomy = 'category';
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 1008
 
1009 1009
 	$select = 'post_id, category_id';
1010
-	if ( $have_tags )
1010
+	if ($have_tags)
1011 1011
 		$select .= ', rel_type';
1012 1012
 
1013 1013
 	$posts = $wpdb->get_results("SELECT $select FROM $wpdb->post2cat GROUP BY post_id, category_id");
1014
-	foreach ( $posts as $post ) {
1014
+	foreach ($posts as $post) {
1015 1015
 		$post_id = (int) $post->post_id;
1016 1016
 		$term_id = (int) $post->category_id;
1017 1017
 		$taxonomy = 'category';
1018
-		if ( !empty($post->rel_type) && 'tag' == $post->rel_type)
1018
+		if ( ! empty($post->rel_type) && 'tag' == $post->rel_type)
1019 1019
 			$taxonomy = 'tag';
1020 1020
 		$tt_id = $tt_ids[$term_id][$taxonomy];
1021
-		if ( empty($tt_id) )
1021
+		if (empty($tt_id))
1022 1022
 			continue;
1023 1023
 
1024
-		$wpdb->insert( $wpdb->term_relationships, array('object_id' => $post_id, 'term_taxonomy_id' => $tt_id) );
1024
+		$wpdb->insert($wpdb->term_relationships, array('object_id' => $post_id, 'term_taxonomy_id' => $tt_id));
1025 1025
 	}
1026 1026
 
1027 1027
 	// < 3570 we used linkcategories. >= 3570 we used categories and link2cat.
1028
-	if ( $wp_current_db_version < 3570 ) {
1028
+	if ($wp_current_db_version < 3570) {
1029 1029
 		/*
1030 1030
 		 * Create link_category terms for link categories. Create a map of link
1031 1031
 		 * cat IDs to link_category terms.
@@ -1033,8 +1033,8 @@  discard block
 block discarded – undo
1033 1033
 		$link_cat_id_map = array();
1034 1034
 		$default_link_cat = 0;
1035 1035
 		$tt_ids = array();
1036
-		$link_cats = $wpdb->get_results("SELECT cat_id, cat_name FROM " . $wpdb->prefix . 'linkcategories');
1037
-		foreach ( $link_cats as $category) {
1036
+		$link_cats = $wpdb->get_results("SELECT cat_id, cat_name FROM ".$wpdb->prefix.'linkcategories');
1037
+		foreach ($link_cats as $category) {
1038 1038
 			$cat_id = (int) $category->cat_id;
1039 1039
 			$term_id = 0;
1040 1040
 			$name = wp_slash($category->cat_name);
@@ -1042,66 +1042,66 @@  discard block
 block discarded – undo
1042 1042
 			$term_group = 0;
1043 1043
 
1044 1044
 			// Associate terms with the same slug in a term group and make slugs unique.
1045
-			if ( $exists = $wpdb->get_results( $wpdb->prepare("SELECT term_id, term_group FROM $wpdb->terms WHERE slug = %s", $slug) ) ) {
1045
+			if ($exists = $wpdb->get_results($wpdb->prepare("SELECT term_id, term_group FROM $wpdb->terms WHERE slug = %s", $slug))) {
1046 1046
 				$term_group = $exists[0]->term_group;
1047 1047
 				$term_id = $exists[0]->term_id;
1048 1048
 			}
1049 1049
 
1050
-			if ( empty($term_id) ) {
1051
-				$wpdb->insert( $wpdb->terms, compact('name', 'slug', 'term_group') );
1050
+			if (empty($term_id)) {
1051
+				$wpdb->insert($wpdb->terms, compact('name', 'slug', 'term_group'));
1052 1052
 				$term_id = (int) $wpdb->insert_id;
1053 1053
 			}
1054 1054
 
1055 1055
 			$link_cat_id_map[$cat_id] = $term_id;
1056 1056
 			$default_link_cat = $term_id;
1057 1057
 
1058
-			$wpdb->insert( $wpdb->term_taxonomy, array('term_id' => $term_id, 'taxonomy' => 'link_category', 'description' => '', 'parent' => 0, 'count' => 0) );
1058
+			$wpdb->insert($wpdb->term_taxonomy, array('term_id' => $term_id, 'taxonomy' => 'link_category', 'description' => '', 'parent' => 0, 'count' => 0));
1059 1059
 			$tt_ids[$term_id] = (int) $wpdb->insert_id;
1060 1060
 		}
1061 1061
 
1062 1062
 		// Associate links to cats.
1063 1063
 		$links = $wpdb->get_results("SELECT link_id, link_category FROM $wpdb->links");
1064
-		if ( !empty($links) ) foreach ( $links as $link ) {
1065
-			if ( 0 == $link->link_category )
1064
+		if ( ! empty($links)) foreach ($links as $link) {
1065
+			if (0 == $link->link_category)
1066 1066
 				continue;
1067
-			if ( ! isset($link_cat_id_map[$link->link_category]) )
1067
+			if ( ! isset($link_cat_id_map[$link->link_category]))
1068 1068
 				continue;
1069 1069
 			$term_id = $link_cat_id_map[$link->link_category];
1070 1070
 			$tt_id = $tt_ids[$term_id];
1071
-			if ( empty($tt_id) )
1071
+			if (empty($tt_id))
1072 1072
 				continue;
1073 1073
 
1074
-			$wpdb->insert( $wpdb->term_relationships, array('object_id' => $link->link_id, 'term_taxonomy_id' => $tt_id) );
1074
+			$wpdb->insert($wpdb->term_relationships, array('object_id' => $link->link_id, 'term_taxonomy_id' => $tt_id));
1075 1075
 		}
1076 1076
 
1077 1077
 		// Set default to the last category we grabbed during the upgrade loop.
1078 1078
 		update_option('default_link_category', $default_link_cat);
1079 1079
 	} else {
1080 1080
 		$links = $wpdb->get_results("SELECT link_id, category_id FROM $wpdb->link2cat GROUP BY link_id, category_id");
1081
-		foreach ( $links as $link ) {
1081
+		foreach ($links as $link) {
1082 1082
 			$link_id = (int) $link->link_id;
1083 1083
 			$term_id = (int) $link->category_id;
1084 1084
 			$taxonomy = 'link_category';
1085 1085
 			$tt_id = $tt_ids[$term_id][$taxonomy];
1086
-			if ( empty($tt_id) )
1086
+			if (empty($tt_id))
1087 1087
 				continue;
1088
-			$wpdb->insert( $wpdb->term_relationships, array('object_id' => $link_id, 'term_taxonomy_id' => $tt_id) );
1088
+			$wpdb->insert($wpdb->term_relationships, array('object_id' => $link_id, 'term_taxonomy_id' => $tt_id));
1089 1089
 		}
1090 1090
 	}
1091 1091
 
1092
-	if ( $wp_current_db_version < 4772 ) {
1092
+	if ($wp_current_db_version < 4772) {
1093 1093
 		// Obsolete linkcategories table
1094
-		$wpdb->query('DROP TABLE IF EXISTS ' . $wpdb->prefix . 'linkcategories');
1094
+		$wpdb->query('DROP TABLE IF EXISTS '.$wpdb->prefix.'linkcategories');
1095 1095
 	}
1096 1096
 
1097 1097
 	// Recalculate all counts
1098 1098
 	$terms = $wpdb->get_results("SELECT term_taxonomy_id, taxonomy FROM $wpdb->term_taxonomy");
1099
-	foreach ( (array) $terms as $term ) {
1100
-		if ( ('post_tag' == $term->taxonomy) || ('category' == $term->taxonomy) )
1101
-			$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) );
1099
+	foreach ((array) $terms as $term) {
1100
+		if (('post_tag' == $term->taxonomy) || ('category' == $term->taxonomy))
1101
+			$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));
1102 1102
 		else
1103
-			$count = $wpdb->get_var( $wpdb->prepare("SELECT COUNT(*) FROM $wpdb->term_relationships WHERE term_taxonomy_id = %d", $term->term_taxonomy_id) );
1104
-		$wpdb->update( $wpdb->term_taxonomy, array('count' => $count), array('term_taxonomy_id' => $term->term_taxonomy_id) );
1103
+			$count = $wpdb->get_var($wpdb->prepare("SELECT COUNT(*) FROM $wpdb->term_relationships WHERE term_taxonomy_id = %d", $term->term_taxonomy_id));
1104
+		$wpdb->update($wpdb->term_taxonomy, array('count' => $count), array('term_taxonomy_id' => $term->term_taxonomy_id));
1105 1105
 	}
1106 1106
 }
1107 1107
 
@@ -1115,9 +1115,9 @@  discard block
 block discarded – undo
1115 1115
  */
1116 1116
 function upgrade_230_options_table() {
1117 1117
 	global $wpdb;
1118
-	$old_options_fields = array( 'option_can_override', 'option_type', 'option_width', 'option_height', 'option_description', 'option_admin_level' );
1118
+	$old_options_fields = array('option_can_override', 'option_type', 'option_width', 'option_height', 'option_description', 'option_admin_level');
1119 1119
 	$wpdb->hide_errors();
1120
-	foreach ( $old_options_fields as $old )
1120
+	foreach ($old_options_fields as $old)
1121 1121
 		$wpdb->query("ALTER TABLE $wpdb->options DROP $old");
1122 1122
 	$wpdb->show_errors();
1123 1123
 }
@@ -1132,9 +1132,9 @@  discard block
 block discarded – undo
1132 1132
  */
1133 1133
 function upgrade_230_old_tables() {
1134 1134
 	global $wpdb;
1135
-	$wpdb->query('DROP TABLE IF EXISTS ' . $wpdb->prefix . 'categories');
1136
-	$wpdb->query('DROP TABLE IF EXISTS ' . $wpdb->prefix . 'link2cat');
1137
-	$wpdb->query('DROP TABLE IF EXISTS ' . $wpdb->prefix . 'post2cat');
1135
+	$wpdb->query('DROP TABLE IF EXISTS '.$wpdb->prefix.'categories');
1136
+	$wpdb->query('DROP TABLE IF EXISTS '.$wpdb->prefix.'link2cat');
1137
+	$wpdb->query('DROP TABLE IF EXISTS '.$wpdb->prefix.'post2cat');
1138 1138
 }
1139 1139
 
1140 1140
 /**
@@ -1162,7 +1162,7 @@  discard block
 block discarded – undo
1162 1162
 function upgrade_250() {
1163 1163
 	global $wp_current_db_version;
1164 1164
 
1165
-	if ( $wp_current_db_version < 6689 ) {
1165
+	if ($wp_current_db_version < 6689) {
1166 1166
 		populate_roles_250();
1167 1167
 	}
1168 1168
 
@@ -1193,7 +1193,7 @@  discard block
 block discarded – undo
1193 1193
 function upgrade_260() {
1194 1194
 	global $wp_current_db_version;
1195 1195
 
1196
-	if ( $wp_current_db_version < 8000 )
1196
+	if ($wp_current_db_version < 8000)
1197 1197
 		populate_roles_260();
1198 1198
 }
1199 1199
 
@@ -1209,12 +1209,12 @@  discard block
 block discarded – undo
1209 1209
 function upgrade_270() {
1210 1210
 	global $wpdb, $wp_current_db_version;
1211 1211
 
1212
-	if ( $wp_current_db_version < 8980 )
1212
+	if ($wp_current_db_version < 8980)
1213 1213
 		populate_roles_270();
1214 1214
 
1215 1215
 	// Update post_date for unpublished posts with empty timestamp
1216
-	if ( $wp_current_db_version < 8921 )
1217
-		$wpdb->query( "UPDATE $wpdb->posts SET post_date = post_modified WHERE post_date = '0000-00-00 00:00:00'" );
1216
+	if ($wp_current_db_version < 8921)
1217
+		$wpdb->query("UPDATE $wpdb->posts SET post_date = post_modified WHERE post_date = '0000-00-00 00:00:00'");
1218 1218
 }
1219 1219
 
1220 1220
 /**
@@ -1229,22 +1229,22 @@  discard block
 block discarded – undo
1229 1229
 function upgrade_280() {
1230 1230
 	global $wp_current_db_version, $wpdb;
1231 1231
 
1232
-	if ( $wp_current_db_version < 10360 )
1232
+	if ($wp_current_db_version < 10360)
1233 1233
 		populate_roles_280();
1234
-	if ( is_multisite() ) {
1234
+	if (is_multisite()) {
1235 1235
 		$start = 0;
1236
-		while( $rows = $wpdb->get_results( "SELECT option_name, option_value FROM $wpdb->options ORDER BY option_id LIMIT $start, 20" ) ) {
1237
-			foreach ( $rows as $row ) {
1236
+		while ($rows = $wpdb->get_results("SELECT option_name, option_value FROM $wpdb->options ORDER BY option_id LIMIT $start, 20")) {
1237
+			foreach ($rows as $row) {
1238 1238
 				$value = $row->option_value;
1239
-				if ( !@unserialize( $value ) )
1240
-					$value = stripslashes( $value );
1241
-				if ( $value !== $row->option_value ) {
1242
-					update_option( $row->option_name, $value );
1239
+				if ( ! @unserialize($value))
1240
+					$value = stripslashes($value);
1241
+				if ($value !== $row->option_value) {
1242
+					update_option($row->option_name, $value);
1243 1243
 				}
1244 1244
 			}
1245 1245
 			$start += 20;
1246 1246
 		}
1247
-		refresh_blog_details( $wpdb->blogid );
1247
+		refresh_blog_details($wpdb->blogid);
1248 1248
 	}
1249 1249
 }
1250 1250
 
@@ -1259,11 +1259,11 @@  discard block
 block discarded – undo
1259 1259
 function upgrade_290() {
1260 1260
 	global $wp_current_db_version;
1261 1261
 
1262
-	if ( $wp_current_db_version < 11958 ) {
1262
+	if ($wp_current_db_version < 11958) {
1263 1263
 		// Previously, setting depth to 1 would redundantly disable threading, but now 2 is the minimum depth to avoid confusion
1264
-		if ( get_option( 'thread_comments_depth' ) == '1' ) {
1265
-			update_option( 'thread_comments_depth', 2 );
1266
-			update_option( 'thread_comments', 0 );
1264
+		if (get_option('thread_comments_depth') == '1') {
1265
+			update_option('thread_comments_depth', 2);
1266
+			update_option('thread_comments', 0);
1267 1267
 		}
1268 1268
 	}
1269 1269
 }
@@ -1280,14 +1280,14 @@  discard block
 block discarded – undo
1280 1280
 function upgrade_300() {
1281 1281
 	global $wp_current_db_version, $wpdb;
1282 1282
 
1283
-	if ( $wp_current_db_version < 15093 )
1283
+	if ($wp_current_db_version < 15093)
1284 1284
 		populate_roles_300();
1285 1285
 
1286
-	if ( $wp_current_db_version < 14139 && is_multisite() && is_main_site() && ! defined( 'MULTISITE' ) && get_site_option( 'siteurl' ) === false )
1287
-		add_site_option( 'siteurl', '' );
1286
+	if ($wp_current_db_version < 14139 && is_multisite() && is_main_site() && ! defined('MULTISITE') && get_site_option('siteurl') === false)
1287
+		add_site_option('siteurl', '');
1288 1288
 
1289 1289
 	// 3.0 screen options key name changes.
1290
-	if ( wp_should_upgrade_global_tables() ) {
1290
+	if (wp_should_upgrade_global_tables()) {
1291 1291
 		$sql = "DELETE FROM $wpdb->usermeta
1292 1292
 			WHERE meta_key LIKE %s
1293 1293
 			OR meta_key LIKE %s
@@ -1301,15 +1301,15 @@  discard block
 block discarded – undo
1301 1301
 			OR meta_key = 'manageeditcolumnshidden'
1302 1302
 			OR meta_key = 'categories_per_page'
1303 1303
 			OR meta_key = 'edit_tags_per_page'";
1304
-		$prefix = $wpdb->esc_like( $wpdb->base_prefix );
1305
-		$wpdb->query( $wpdb->prepare( $sql,
1306
-			$prefix . '%' . $wpdb->esc_like( 'meta-box-hidden' ) . '%',
1307
-			$prefix . '%' . $wpdb->esc_like( 'closedpostboxes' ) . '%',
1308
-			$prefix . '%' . $wpdb->esc_like( 'manage-'	   ) . '%' . $wpdb->esc_like( '-columns-hidden' ) . '%',
1309
-			$prefix . '%' . $wpdb->esc_like( 'meta-box-order'  ) . '%',
1310
-			$prefix . '%' . $wpdb->esc_like( 'metaboxorder'    ) . '%',
1311
-			$prefix . '%' . $wpdb->esc_like( 'screen_layout'   ) . '%'
1312
-		) );
1304
+		$prefix = $wpdb->esc_like($wpdb->base_prefix);
1305
+		$wpdb->query($wpdb->prepare($sql,
1306
+			$prefix.'%'.$wpdb->esc_like('meta-box-hidden').'%',
1307
+			$prefix.'%'.$wpdb->esc_like('closedpostboxes').'%',
1308
+			$prefix.'%'.$wpdb->esc_like('manage-').'%'.$wpdb->esc_like('-columns-hidden').'%',
1309
+			$prefix.'%'.$wpdb->esc_like('meta-box-order').'%',
1310
+			$prefix.'%'.$wpdb->esc_like('metaboxorder').'%',
1311
+			$prefix.'%'.$wpdb->esc_like('screen_layout').'%'
1312
+		));
1313 1313
 	}
1314 1314
 
1315 1315
 }
@@ -1328,52 +1328,52 @@  discard block
 block discarded – undo
1328 1328
 function upgrade_330() {
1329 1329
 	global $wp_current_db_version, $wpdb, $wp_registered_widgets, $sidebars_widgets;
1330 1330
 
1331
-	if ( $wp_current_db_version < 19061 && wp_should_upgrade_global_tables() ) {
1332
-		$wpdb->query( "DELETE FROM $wpdb->usermeta WHERE meta_key IN ('show_admin_bar_admin', 'plugins_last_view')" );
1331
+	if ($wp_current_db_version < 19061 && wp_should_upgrade_global_tables()) {
1332
+		$wpdb->query("DELETE FROM $wpdb->usermeta WHERE meta_key IN ('show_admin_bar_admin', 'plugins_last_view')");
1333 1333
 	}
1334 1334
 
1335
-	if ( $wp_current_db_version >= 11548 )
1335
+	if ($wp_current_db_version >= 11548)
1336 1336
 		return;
1337 1337
 
1338
-	$sidebars_widgets = get_option( 'sidebars_widgets', array() );
1338
+	$sidebars_widgets = get_option('sidebars_widgets', array());
1339 1339
 	$_sidebars_widgets = array();
1340 1340
 
1341
-	if ( isset($sidebars_widgets['wp_inactive_widgets']) || empty($sidebars_widgets) )
1341
+	if (isset($sidebars_widgets['wp_inactive_widgets']) || empty($sidebars_widgets))
1342 1342
 		$sidebars_widgets['array_version'] = 3;
1343
-	elseif ( !isset($sidebars_widgets['array_version']) )
1343
+	elseif ( ! isset($sidebars_widgets['array_version']))
1344 1344
 		$sidebars_widgets['array_version'] = 1;
1345 1345
 
1346
-	switch ( $sidebars_widgets['array_version'] ) {
1346
+	switch ($sidebars_widgets['array_version']) {
1347 1347
 		case 1 :
1348
-			foreach ( (array) $sidebars_widgets as $index => $sidebar )
1349
-			if ( is_array($sidebar) )
1350
-			foreach ( (array) $sidebar as $i => $name ) {
1348
+			foreach ((array) $sidebars_widgets as $index => $sidebar)
1349
+			if (is_array($sidebar))
1350
+			foreach ((array) $sidebar as $i => $name) {
1351 1351
 				$id = strtolower($name);
1352
-				if ( isset($wp_registered_widgets[$id]) ) {
1352
+				if (isset($wp_registered_widgets[$id])) {
1353 1353
 					$_sidebars_widgets[$index][$i] = $id;
1354 1354
 					continue;
1355 1355
 				}
1356 1356
 				$id = sanitize_title($name);
1357
-				if ( isset($wp_registered_widgets[$id]) ) {
1357
+				if (isset($wp_registered_widgets[$id])) {
1358 1358
 					$_sidebars_widgets[$index][$i] = $id;
1359 1359
 					continue;
1360 1360
 				}
1361 1361
 
1362 1362
 				$found = false;
1363 1363
 
1364
-				foreach ( $wp_registered_widgets as $widget_id => $widget ) {
1365
-					if ( strtolower($widget['name']) == strtolower($name) ) {
1364
+				foreach ($wp_registered_widgets as $widget_id => $widget) {
1365
+					if (strtolower($widget['name']) == strtolower($name)) {
1366 1366
 						$_sidebars_widgets[$index][$i] = $widget['id'];
1367 1367
 						$found = true;
1368 1368
 						break;
1369
-					} elseif ( sanitize_title($widget['name']) == sanitize_title($name) ) {
1369
+					} elseif (sanitize_title($widget['name']) == sanitize_title($name)) {
1370 1370
 						$_sidebars_widgets[$index][$i] = $widget['id'];
1371 1371
 						$found = true;
1372 1372
 						break;
1373 1373
 					}
1374 1374
 				}
1375 1375
 
1376
-				if ( $found )
1376
+				if ($found)
1377 1377
 					continue;
1378 1378
 
1379 1379
 				unset($_sidebars_widgets[$index][$i]);
@@ -1385,7 +1385,7 @@  discard block
 block discarded – undo
1385 1385
 		case 2 :
1386 1386
 			$sidebars_widgets = retrieve_widgets();
1387 1387
 			$sidebars_widgets['array_version'] = 3;
1388
-			update_option( 'sidebars_widgets', $sidebars_widgets );
1388
+			update_option('sidebars_widgets', $sidebars_widgets);
1389 1389
 	}
1390 1390
 }
1391 1391
 
@@ -1401,27 +1401,27 @@  discard block
 block discarded – undo
1401 1401
 function upgrade_340() {
1402 1402
 	global $wp_current_db_version, $wpdb;
1403 1403
 
1404
-	if ( $wp_current_db_version < 19798 ) {
1404
+	if ($wp_current_db_version < 19798) {
1405 1405
 		$wpdb->hide_errors();
1406
-		$wpdb->query( "ALTER TABLE $wpdb->options DROP COLUMN blog_id" );
1406
+		$wpdb->query("ALTER TABLE $wpdb->options DROP COLUMN blog_id");
1407 1407
 		$wpdb->show_errors();
1408 1408
 	}
1409 1409
 
1410
-	if ( $wp_current_db_version < 19799 ) {
1410
+	if ($wp_current_db_version < 19799) {
1411 1411
 		$wpdb->hide_errors();
1412 1412
 		$wpdb->query("ALTER TABLE $wpdb->comments DROP INDEX comment_approved");
1413 1413
 		$wpdb->show_errors();
1414 1414
 	}
1415 1415
 
1416
-	if ( $wp_current_db_version < 20022 && wp_should_upgrade_global_tables() ) {
1417
-		$wpdb->query( "DELETE FROM $wpdb->usermeta WHERE meta_key = 'themes_last_view'" );
1416
+	if ($wp_current_db_version < 20022 && wp_should_upgrade_global_tables()) {
1417
+		$wpdb->query("DELETE FROM $wpdb->usermeta WHERE meta_key = 'themes_last_view'");
1418 1418
 	}
1419 1419
 
1420
-	if ( $wp_current_db_version < 20080 ) {
1421
-		if ( 'yes' == $wpdb->get_var( "SELECT autoload FROM $wpdb->options WHERE option_name = 'uninstall_plugins'" ) ) {
1422
-			$uninstall_plugins = get_option( 'uninstall_plugins' );
1423
-			delete_option( 'uninstall_plugins' );
1424
-			add_option( 'uninstall_plugins', $uninstall_plugins, null, 'no' );
1420
+	if ($wp_current_db_version < 20080) {
1421
+		if ('yes' == $wpdb->get_var("SELECT autoload FROM $wpdb->options WHERE option_name = 'uninstall_plugins'")) {
1422
+			$uninstall_plugins = get_option('uninstall_plugins');
1423
+			delete_option('uninstall_plugins');
1424
+			add_option('uninstall_plugins', $uninstall_plugins, null, 'no');
1425 1425
 		}
1426 1426
 	}
1427 1427
 }
@@ -1438,23 +1438,23 @@  discard block
 block discarded – undo
1438 1438
 function upgrade_350() {
1439 1439
 	global $wp_current_db_version, $wpdb;
1440 1440
 
1441
-	if ( $wp_current_db_version < 22006 && $wpdb->get_var( "SELECT link_id FROM $wpdb->links LIMIT 1" ) )
1442
-		update_option( 'link_manager_enabled', 1 ); // Previously set to 0 by populate_options()
1441
+	if ($wp_current_db_version < 22006 && $wpdb->get_var("SELECT link_id FROM $wpdb->links LIMIT 1"))
1442
+		update_option('link_manager_enabled', 1); // Previously set to 0 by populate_options()
1443 1443
 
1444
-	if ( $wp_current_db_version < 21811 && wp_should_upgrade_global_tables() ) {
1444
+	if ($wp_current_db_version < 21811 && wp_should_upgrade_global_tables()) {
1445 1445
 		$meta_keys = array();
1446
-		foreach ( array_merge( get_post_types(), get_taxonomies() ) as $name ) {
1447
-			if ( false !== strpos( $name, '-' ) )
1448
-			$meta_keys[] = 'edit_' . str_replace( '-', '_', $name ) . '_per_page';
1446
+		foreach (array_merge(get_post_types(), get_taxonomies()) as $name) {
1447
+			if (false !== strpos($name, '-'))
1448
+			$meta_keys[] = 'edit_'.str_replace('-', '_', $name).'_per_page';
1449 1449
 		}
1450
-		if ( $meta_keys ) {
1451
-			$meta_keys = implode( "', '", $meta_keys );
1452
-			$wpdb->query( "DELETE FROM $wpdb->usermeta WHERE meta_key IN ('$meta_keys')" );
1450
+		if ($meta_keys) {
1451
+			$meta_keys = implode("', '", $meta_keys);
1452
+			$wpdb->query("DELETE FROM $wpdb->usermeta WHERE meta_key IN ('$meta_keys')");
1453 1453
 		}
1454 1454
 	}
1455 1455
 
1456
-	if ( $wp_current_db_version < 22422 && $term = get_term_by( 'slug', 'post-format-standard', 'post_format' ) )
1457
-		wp_delete_term( $term->term_id, 'post_format' );
1456
+	if ($wp_current_db_version < 22422 && $term = get_term_by('slug', 'post-format-standard', 'post_format'))
1457
+		wp_delete_term($term->term_id, 'post_format');
1458 1458
 }
1459 1459
 
1460 1460
 /**
@@ -1467,8 +1467,8 @@  discard block
 block discarded – undo
1467 1467
  */
1468 1468
 function upgrade_370() {
1469 1469
 	global $wp_current_db_version;
1470
-	if ( $wp_current_db_version < 25824 )
1471
-		wp_clear_scheduled_hook( 'wp_auto_updates_maybe_update' );
1470
+	if ($wp_current_db_version < 25824)
1471
+		wp_clear_scheduled_hook('wp_auto_updates_maybe_update');
1472 1472
 }
1473 1473
 
1474 1474
 /**
@@ -1482,8 +1482,8 @@  discard block
 block discarded – undo
1482 1482
  */
1483 1483
 function upgrade_372() {
1484 1484
 	global $wp_current_db_version;
1485
-	if ( $wp_current_db_version < 26148 )
1486
-		wp_clear_scheduled_hook( 'wp_maybe_auto_update' );
1485
+	if ($wp_current_db_version < 26148)
1486
+		wp_clear_scheduled_hook('wp_maybe_auto_update');
1487 1487
 }
1488 1488
 
1489 1489
 /**
@@ -1496,8 +1496,8 @@  discard block
 block discarded – undo
1496 1496
  */
1497 1497
 function upgrade_380() {
1498 1498
 	global $wp_current_db_version;
1499
-	if ( $wp_current_db_version < 26691 ) {
1500
-		deactivate_plugins( array( 'mp6/mp6.php' ), true );
1499
+	if ($wp_current_db_version < 26691) {
1500
+		deactivate_plugins(array('mp6/mp6.php'), true);
1501 1501
 	}
1502 1502
 }
1503 1503
 
@@ -1511,12 +1511,12 @@  discard block
 block discarded – undo
1511 1511
  */
1512 1512
 function upgrade_400() {
1513 1513
 	global $wp_current_db_version;
1514
-	if ( $wp_current_db_version < 29630 ) {
1515
-		if ( ! is_multisite() && false === get_option( 'WPLANG' ) ) {
1516
-			if ( defined( 'WPLANG' ) && ( '' !== WPLANG ) && in_array( WPLANG, get_available_languages() ) ) {
1517
-				update_option( 'WPLANG', WPLANG );
1514
+	if ($wp_current_db_version < 29630) {
1515
+		if ( ! is_multisite() && false === get_option('WPLANG')) {
1516
+			if (defined('WPLANG') && ('' !== WPLANG) && in_array(WPLANG, get_available_languages())) {
1517
+				update_option('WPLANG', WPLANG);
1518 1518
 			} else {
1519
-				update_option( 'WPLANG', '' );
1519
+				update_option('WPLANG', '');
1520 1520
 			}
1521 1521
 		}
1522 1522
 	}
@@ -1545,29 +1545,29 @@  discard block
 block discarded – undo
1545 1545
 function upgrade_430() {
1546 1546
 	global $wp_current_db_version, $wpdb;
1547 1547
 
1548
-	if ( $wp_current_db_version < 32364 ) {
1548
+	if ($wp_current_db_version < 32364) {
1549 1549
 		upgrade_430_fix_comments();
1550 1550
 	}
1551 1551
 
1552 1552
 	// Shared terms are split in a separate process.
1553
-	if ( $wp_current_db_version < 32814 ) {
1554
-		update_option( 'finished_splitting_shared_terms', 0 );
1555
-		wp_schedule_single_event( time() + ( 1 * MINUTE_IN_SECONDS ), 'wp_split_shared_term_batch' );
1553
+	if ($wp_current_db_version < 32814) {
1554
+		update_option('finished_splitting_shared_terms', 0);
1555
+		wp_schedule_single_event(time() + (1 * MINUTE_IN_SECONDS), 'wp_split_shared_term_batch');
1556 1556
 	}
1557 1557
 
1558
-	if ( $wp_current_db_version < 33055 && 'utf8mb4' === $wpdb->charset ) {
1559
-		if ( is_multisite() ) {
1560
-			$tables = $wpdb->tables( 'blog' );
1558
+	if ($wp_current_db_version < 33055 && 'utf8mb4' === $wpdb->charset) {
1559
+		if (is_multisite()) {
1560
+			$tables = $wpdb->tables('blog');
1561 1561
 		} else {
1562
-			$tables = $wpdb->tables( 'all' );
1563
-			if ( ! wp_should_upgrade_global_tables() ) {
1564
-				$global_tables = $wpdb->tables( 'global' );
1565
-				$tables = array_diff_assoc( $tables, $global_tables );
1562
+			$tables = $wpdb->tables('all');
1563
+			if ( ! wp_should_upgrade_global_tables()) {
1564
+				$global_tables = $wpdb->tables('global');
1565
+				$tables = array_diff_assoc($tables, $global_tables);
1566 1566
 			}
1567 1567
 		}
1568 1568
 
1569
-		foreach ( $tables as $table ) {
1570
-			maybe_convert_table_to_utf8mb4( $table );
1569
+		foreach ($tables as $table) {
1570
+			maybe_convert_table_to_utf8mb4($table);
1571 1571
 		}
1572 1572
 	}
1573 1573
 }
@@ -1584,18 +1584,18 @@  discard block
 block discarded – undo
1584 1584
 function upgrade_430_fix_comments() {
1585 1585
 	global $wp_current_db_version, $wpdb;
1586 1586
 
1587
-	$content_length = $wpdb->get_col_length( $wpdb->comments, 'comment_content' );
1587
+	$content_length = $wpdb->get_col_length($wpdb->comments, 'comment_content');
1588 1588
 
1589
-	if ( is_wp_error( $content_length ) ) {
1589
+	if (is_wp_error($content_length)) {
1590 1590
 		return;
1591 1591
 	}
1592 1592
 
1593
-	if ( false === $content_length ) {
1593
+	if (false === $content_length) {
1594 1594
 		$content_length = array(
1595 1595
 			'type'   => 'byte',
1596 1596
 			'length' => 65535,
1597 1597
 		);
1598
-	} elseif ( ! is_array( $content_length ) ) {
1598
+	} elseif ( ! is_array($content_length)) {
1599 1599
 		$length = (int) $content_length > 0 ? (int) $content_length : 65535;
1600 1600
 		$content_length = array(
1601 1601
 			'type'	 => 'byte',
@@ -1603,12 +1603,12 @@  discard block
 block discarded – undo
1603 1603
 		);
1604 1604
 	}
1605 1605
 
1606
-	if ( 'byte' !== $content_length['type'] || 0 === $content_length['length'] ) {
1606
+	if ('byte' !== $content_length['type'] || 0 === $content_length['length']) {
1607 1607
 		// Sites with malformed DB schemas are on their own.
1608 1608
 		return;
1609 1609
 	}
1610 1610
 
1611
-	$allowed_length = intval( $content_length['length'] ) - 10;
1611
+	$allowed_length = intval($content_length['length']) - 10;
1612 1612
 
1613 1613
 	$comments = $wpdb->get_results(
1614 1614
 		"SELECT `comment_ID` FROM `{$wpdb->comments}`
@@ -1617,8 +1617,8 @@  discard block
 block discarded – undo
1617 1617
 			AND ( `comment_content` LIKE '%<%' OR `comment_content` LIKE '%>%' )"
1618 1618
 	);
1619 1619
 
1620
-	foreach ( $comments as $comment ) {
1621
-		wp_delete_comment( $comment->comment_ID, true );
1620
+	foreach ($comments as $comment) {
1621
+		wp_delete_comment($comment->comment_ID, true);
1622 1622
 	}
1623 1623
 }
1624 1624
 
@@ -1631,9 +1631,9 @@  discard block
 block discarded – undo
1631 1631
 function upgrade_431() {
1632 1632
 	// Fix incorrect cron entries for term splitting
1633 1633
 	$cron_array = _get_cron_array();
1634
-	if ( isset( $cron_array['wp_batch_split_terms'] ) ) {
1635
-		unset( $cron_array['wp_batch_split_terms'] );
1636
-		_set_cron_array( $cron_array );
1634
+	if (isset($cron_array['wp_batch_split_terms'])) {
1635
+		unset($cron_array['wp_batch_split_terms']);
1636
+		_set_cron_array($cron_array);
1637 1637
 	}
1638 1638
 }
1639 1639
 
@@ -1649,15 +1649,15 @@  discard block
 block discarded – undo
1649 1649
 function upgrade_440() {
1650 1650
 	global $wp_current_db_version, $wpdb;
1651 1651
 
1652
-	if ( $wp_current_db_version < 34030 ) {
1653
-		$wpdb->query( "ALTER TABLE {$wpdb->options} MODIFY option_name VARCHAR(191)" );
1652
+	if ($wp_current_db_version < 34030) {
1653
+		$wpdb->query("ALTER TABLE {$wpdb->options} MODIFY option_name VARCHAR(191)");
1654 1654
 	}
1655 1655
 
1656 1656
 	// Remove the unused 'add_users' role.
1657 1657
 	$roles = wp_roles();
1658
-	foreach ( $roles->role_objects as $role ) {
1659
-		if ( $role->has_cap( 'add_users' ) ) {
1660
-			$role->remove_cap( 'add_users' );
1658
+	foreach ($roles->role_objects as $role) {
1659
+		if ($role->has_cap('add_users')) {
1660
+			$role->remove_cap('add_users');
1661 1661
 		}
1662 1662
 	}
1663 1663
 }
@@ -1674,17 +1674,17 @@  discard block
 block discarded – undo
1674 1674
 function upgrade_450() {
1675 1675
 	global $wp_current_db_version, $wpdb;
1676 1676
 
1677
-	if ( $wp_current_db_version < 36180 ) {
1678
-		wp_clear_scheduled_hook( 'wp_maybe_auto_update' );
1677
+	if ($wp_current_db_version < 36180) {
1678
+		wp_clear_scheduled_hook('wp_maybe_auto_update');
1679 1679
 	}
1680 1680
 
1681 1681
 	// Remove unused email confirmation options, moved to usermeta.
1682
-	if ( $wp_current_db_version < 36679 && is_multisite() ) {
1683
-		$wpdb->query( "DELETE FROM $wpdb->options WHERE option_name REGEXP '^[0-9]+_new_email$'" );
1682
+	if ($wp_current_db_version < 36679 && is_multisite()) {
1683
+		$wpdb->query("DELETE FROM $wpdb->options WHERE option_name REGEXP '^[0-9]+_new_email$'");
1684 1684
 	}
1685 1685
 
1686 1686
 	// Remove unused user setting for wpLink.
1687
-	delete_user_setting( 'wplink' );
1687
+	delete_user_setting('wplink');
1688 1688
 }
1689 1689
 
1690 1690
 /**
@@ -1699,7 +1699,7 @@  discard block
 block discarded – undo
1699 1699
 	global $wp_current_db_version, $wpdb;
1700 1700
 
1701 1701
 	// Always.
1702
-	if ( is_main_network() ) {
1702
+	if (is_main_network()) {
1703 1703
 		/*
1704 1704
 		 * Deletes all expired transients. The multi-table delete syntax is used
1705 1705
 		 * to delete the transient record from table a, and the corresponding
@@ -1711,32 +1711,32 @@  discard block
 block discarded – undo
1711 1711
 			AND a.meta_key NOT LIKE %s
1712 1712
 			AND b.meta_key = CONCAT( '_site_transient_timeout_', SUBSTRING( a.meta_key, 17 ) )
1713 1713
 			AND b.meta_value < %d";
1714
-		$wpdb->query( $wpdb->prepare( $sql, $wpdb->esc_like( '_site_transient_' ) . '%', $wpdb->esc_like ( '_site_transient_timeout_' ) . '%', $time ) );
1714
+		$wpdb->query($wpdb->prepare($sql, $wpdb->esc_like('_site_transient_').'%', $wpdb->esc_like('_site_transient_timeout_').'%', $time));
1715 1715
 	}
1716 1716
 
1717 1717
 	// 2.8.
1718
-	if ( $wp_current_db_version < 11549 ) {
1719
-		$wpmu_sitewide_plugins = get_site_option( 'wpmu_sitewide_plugins' );
1720
-		$active_sitewide_plugins = get_site_option( 'active_sitewide_plugins' );
1721
-		if ( $wpmu_sitewide_plugins ) {
1722
-			if ( !$active_sitewide_plugins )
1718
+	if ($wp_current_db_version < 11549) {
1719
+		$wpmu_sitewide_plugins = get_site_option('wpmu_sitewide_plugins');
1720
+		$active_sitewide_plugins = get_site_option('active_sitewide_plugins');
1721
+		if ($wpmu_sitewide_plugins) {
1722
+			if ( ! $active_sitewide_plugins)
1723 1723
 				$sitewide_plugins = (array) $wpmu_sitewide_plugins;
1724 1724
 			else
1725
-				$sitewide_plugins = array_merge( (array) $active_sitewide_plugins, (array) $wpmu_sitewide_plugins );
1725
+				$sitewide_plugins = array_merge((array) $active_sitewide_plugins, (array) $wpmu_sitewide_plugins);
1726 1726
 
1727
-			update_site_option( 'active_sitewide_plugins', $sitewide_plugins );
1727
+			update_site_option('active_sitewide_plugins', $sitewide_plugins);
1728 1728
 		}
1729
-		delete_site_option( 'wpmu_sitewide_plugins' );
1730
-		delete_site_option( 'deactivated_sitewide_plugins' );
1729
+		delete_site_option('wpmu_sitewide_plugins');
1730
+		delete_site_option('deactivated_sitewide_plugins');
1731 1731
 
1732 1732
 		$start = 0;
1733
-		while( $rows = $wpdb->get_results( "SELECT meta_key, meta_value FROM {$wpdb->sitemeta} ORDER BY meta_id LIMIT $start, 20" ) ) {
1734
-			foreach ( $rows as $row ) {
1733
+		while ($rows = $wpdb->get_results("SELECT meta_key, meta_value FROM {$wpdb->sitemeta} ORDER BY meta_id LIMIT $start, 20")) {
1734
+			foreach ($rows as $row) {
1735 1735
 				$value = $row->meta_value;
1736
-				if ( !@unserialize( $value ) )
1737
-					$value = stripslashes( $value );
1738
-				if ( $value !== $row->meta_value ) {
1739
-					update_site_option( $row->meta_key, $value );
1736
+				if ( ! @unserialize($value))
1737
+					$value = stripslashes($value);
1738
+				if ($value !== $row->meta_value) {
1739
+					update_site_option($row->meta_key, $value);
1740 1740
 				}
1741 1741
 			}
1742 1742
 			$start += 20;
@@ -1744,95 +1744,95 @@  discard block
 block discarded – undo
1744 1744
 	}
1745 1745
 
1746 1746
 	// 3.0
1747
-	if ( $wp_current_db_version < 13576 )
1748
-		update_site_option( 'global_terms_enabled', '1' );
1747
+	if ($wp_current_db_version < 13576)
1748
+		update_site_option('global_terms_enabled', '1');
1749 1749
 
1750 1750
 	// 3.3
1751
-	if ( $wp_current_db_version < 19390 )
1752
-		update_site_option( 'initial_db_version', $wp_current_db_version );
1751
+	if ($wp_current_db_version < 19390)
1752
+		update_site_option('initial_db_version', $wp_current_db_version);
1753 1753
 
1754
-	if ( $wp_current_db_version < 19470 ) {
1755
-		if ( false === get_site_option( 'active_sitewide_plugins' ) )
1756
-			update_site_option( 'active_sitewide_plugins', array() );
1754
+	if ($wp_current_db_version < 19470) {
1755
+		if (false === get_site_option('active_sitewide_plugins'))
1756
+			update_site_option('active_sitewide_plugins', array());
1757 1757
 	}
1758 1758
 
1759 1759
 	// 3.4
1760
-	if ( $wp_current_db_version < 20148 ) {
1760
+	if ($wp_current_db_version < 20148) {
1761 1761
 		// 'allowedthemes' keys things by stylesheet. 'allowed_themes' keyed things by name.
1762
-		$allowedthemes  = get_site_option( 'allowedthemes'  );
1763
-		$allowed_themes = get_site_option( 'allowed_themes' );
1764
-		if ( false === $allowedthemes && is_array( $allowed_themes ) && $allowed_themes ) {
1762
+		$allowedthemes  = get_site_option('allowedthemes');
1763
+		$allowed_themes = get_site_option('allowed_themes');
1764
+		if (false === $allowedthemes && is_array($allowed_themes) && $allowed_themes) {
1765 1765
 			$converted = array();
1766 1766
 			$themes = wp_get_themes();
1767
-			foreach ( $themes as $stylesheet => $theme_data ) {
1768
-				if ( isset( $allowed_themes[ $theme_data->get('Name') ] ) )
1769
-					$converted[ $stylesheet ] = true;
1767
+			foreach ($themes as $stylesheet => $theme_data) {
1768
+				if (isset($allowed_themes[$theme_data->get('Name')]))
1769
+					$converted[$stylesheet] = true;
1770 1770
 			}
1771
-			update_site_option( 'allowedthemes', $converted );
1772
-			delete_site_option( 'allowed_themes' );
1771
+			update_site_option('allowedthemes', $converted);
1772
+			delete_site_option('allowed_themes');
1773 1773
 		}
1774 1774
 	}
1775 1775
 
1776 1776
 	// 3.5
1777
-	if ( $wp_current_db_version < 21823 )
1778
-		update_site_option( 'ms_files_rewriting', '1' );
1777
+	if ($wp_current_db_version < 21823)
1778
+		update_site_option('ms_files_rewriting', '1');
1779 1779
 
1780 1780
 	// 3.5.2
1781
-	if ( $wp_current_db_version < 24448 ) {
1782
-		$illegal_names = get_site_option( 'illegal_names' );
1783
-		if ( is_array( $illegal_names ) && count( $illegal_names ) === 1 ) {
1784
-			$illegal_name = reset( $illegal_names );
1785
-			$illegal_names = explode( ' ', $illegal_name );
1786
-			update_site_option( 'illegal_names', $illegal_names );
1781
+	if ($wp_current_db_version < 24448) {
1782
+		$illegal_names = get_site_option('illegal_names');
1783
+		if (is_array($illegal_names) && count($illegal_names) === 1) {
1784
+			$illegal_name = reset($illegal_names);
1785
+			$illegal_names = explode(' ', $illegal_name);
1786
+			update_site_option('illegal_names', $illegal_names);
1787 1787
 		}
1788 1788
 	}
1789 1789
 
1790 1790
 	// 4.2
1791
-	if ( $wp_current_db_version < 31351 && $wpdb->charset === 'utf8mb4' ) {
1792
-		if ( wp_should_upgrade_global_tables() ) {
1793
-			$wpdb->query( "ALTER TABLE $wpdb->usermeta DROP INDEX meta_key, ADD INDEX meta_key(meta_key(191))" );
1794
-			$wpdb->query( "ALTER TABLE $wpdb->site DROP INDEX domain, ADD INDEX domain(domain(140),path(51))" );
1795
-			$wpdb->query( "ALTER TABLE $wpdb->sitemeta DROP INDEX meta_key, ADD INDEX meta_key(meta_key(191))" );
1796
-			$wpdb->query( "ALTER TABLE $wpdb->signups DROP INDEX domain_path, ADD INDEX domain_path(domain(140),path(51))" );
1791
+	if ($wp_current_db_version < 31351 && $wpdb->charset === 'utf8mb4') {
1792
+		if (wp_should_upgrade_global_tables()) {
1793
+			$wpdb->query("ALTER TABLE $wpdb->usermeta DROP INDEX meta_key, ADD INDEX meta_key(meta_key(191))");
1794
+			$wpdb->query("ALTER TABLE $wpdb->site DROP INDEX domain, ADD INDEX domain(domain(140),path(51))");
1795
+			$wpdb->query("ALTER TABLE $wpdb->sitemeta DROP INDEX meta_key, ADD INDEX meta_key(meta_key(191))");
1796
+			$wpdb->query("ALTER TABLE $wpdb->signups DROP INDEX domain_path, ADD INDEX domain_path(domain(140),path(51))");
1797 1797
 
1798
-			$tables = $wpdb->tables( 'global' );
1798
+			$tables = $wpdb->tables('global');
1799 1799
 
1800 1800
 			// sitecategories may not exist.
1801
-			if ( ! $wpdb->get_var( "SHOW TABLES LIKE '{$tables['sitecategories']}'" ) ) {
1802
-				unset( $tables['sitecategories'] );
1801
+			if ( ! $wpdb->get_var("SHOW TABLES LIKE '{$tables['sitecategories']}'")) {
1802
+				unset($tables['sitecategories']);
1803 1803
 			}
1804 1804
 
1805
-			foreach ( $tables as $table ) {
1806
-				maybe_convert_table_to_utf8mb4( $table );
1805
+			foreach ($tables as $table) {
1806
+				maybe_convert_table_to_utf8mb4($table);
1807 1807
 			}
1808 1808
 		}
1809 1809
 	}
1810 1810
 
1811 1811
 	// 4.3
1812
-	if ( $wp_current_db_version < 33055 && 'utf8mb4' === $wpdb->charset ) {
1813
-		if ( wp_should_upgrade_global_tables() ) {
1812
+	if ($wp_current_db_version < 33055 && 'utf8mb4' === $wpdb->charset) {
1813
+		if (wp_should_upgrade_global_tables()) {
1814 1814
 			$upgrade = false;
1815
-			$indexes = $wpdb->get_results( "SHOW INDEXES FROM $wpdb->signups" );
1816
-			foreach ( $indexes as $index ) {
1817
-				if ( 'domain_path' == $index->Key_name && 'domain' == $index->Column_name && 140 != $index->Sub_part ) {
1815
+			$indexes = $wpdb->get_results("SHOW INDEXES FROM $wpdb->signups");
1816
+			foreach ($indexes as $index) {
1817
+				if ('domain_path' == $index->Key_name && 'domain' == $index->Column_name && 140 != $index->Sub_part) {
1818 1818
 					$upgrade = true;
1819 1819
 					break;
1820 1820
 				}
1821 1821
 			}
1822 1822
 
1823
-			if ( $upgrade ) {
1824
-				$wpdb->query( "ALTER TABLE $wpdb->signups DROP INDEX domain_path, ADD INDEX domain_path(domain(140),path(51))" );
1823
+			if ($upgrade) {
1824
+				$wpdb->query("ALTER TABLE $wpdb->signups DROP INDEX domain_path, ADD INDEX domain_path(domain(140),path(51))");
1825 1825
 			}
1826 1826
 
1827
-			$tables = $wpdb->tables( 'global' );
1827
+			$tables = $wpdb->tables('global');
1828 1828
 
1829 1829
 			// sitecategories may not exist.
1830
-			if ( ! $wpdb->get_var( "SHOW TABLES LIKE '{$tables['sitecategories']}'" ) ) {
1831
-				unset( $tables['sitecategories'] );
1830
+			if ( ! $wpdb->get_var("SHOW TABLES LIKE '{$tables['sitecategories']}'")) {
1831
+				unset($tables['sitecategories']);
1832 1832
 			}
1833 1833
 
1834
-			foreach ( $tables as $table ) {
1835
-				maybe_convert_table_to_utf8mb4( $table );
1834
+			foreach ($tables as $table) {
1835
+				maybe_convert_table_to_utf8mb4($table);
1836 1836
 			}
1837 1837
 		}
1838 1838
 	}
@@ -1860,9 +1860,9 @@  discard block
 block discarded – undo
1860 1860
 function maybe_create_table($table_name, $create_ddl) {
1861 1861
 	global $wpdb;
1862 1862
 
1863
-	$query = $wpdb->prepare( "SHOW TABLES LIKE %s", $wpdb->esc_like( $table_name ) );
1863
+	$query = $wpdb->prepare("SHOW TABLES LIKE %s", $wpdb->esc_like($table_name));
1864 1864
 
1865
-	if ( $wpdb->get_var( $query ) == $table_name ) {
1865
+	if ($wpdb->get_var($query) == $table_name) {
1866 1866
 		return true;
1867 1867
 	}
1868 1868
 
@@ -1870,7 +1870,7 @@  discard block
 block discarded – undo
1870 1870
 	$wpdb->query($create_ddl);
1871 1871
 
1872 1872
 	// We cannot directly tell that whether this succeeded!
1873
-	if ( $wpdb->get_var( $query ) == $table_name ) {
1873
+	if ($wpdb->get_var($query) == $table_name) {
1874 1874
 		return true;
1875 1875
 	}
1876 1876
 	return false;
@@ -1931,7 +1931,7 @@  discard block
 block discarded – undo
1931 1931
  */
1932 1932
 function maybe_add_column($table_name, $column_name, $create_ddl) {
1933 1933
 	global $wpdb;
1934
-	foreach ($wpdb->get_col("DESC $table_name", 0) as $column ) {
1934
+	foreach ($wpdb->get_col("DESC $table_name", 0) as $column) {
1935 1935
 		if ($column == $column_name) {
1936 1936
 			return true;
1937 1937
 		}
@@ -1941,7 +1941,7 @@  discard block
 block discarded – undo
1941 1941
 	$wpdb->query($create_ddl);
1942 1942
 
1943 1943
 	// We cannot directly tell that whether this succeeded!
1944
-	foreach ($wpdb->get_col("DESC $table_name", 0) as $column ) {
1944
+	foreach ($wpdb->get_col("DESC $table_name", 0) as $column) {
1945 1945
 		if ($column == $column_name) {
1946 1946
 			return true;
1947 1947
 		}
@@ -1959,37 +1959,37 @@  discard block
 block discarded – undo
1959 1959
  * @param string $table The table to convert.
1960 1960
  * @return bool true if the table was converted, false if it wasn't.
1961 1961
  */
1962
-function maybe_convert_table_to_utf8mb4( $table ) {
1962
+function maybe_convert_table_to_utf8mb4($table) {
1963 1963
 	global $wpdb;
1964 1964
 
1965
-	$results = $wpdb->get_results( "SHOW FULL COLUMNS FROM `$table`" );
1966
-	if ( ! $results ) {
1965
+	$results = $wpdb->get_results("SHOW FULL COLUMNS FROM `$table`");
1966
+	if ( ! $results) {
1967 1967
 		return false;
1968 1968
 	}
1969 1969
 
1970
-	foreach ( $results as $column ) {
1971
-		if ( $column->Collation ) {
1972
-			list( $charset ) = explode( '_', $column->Collation );
1973
-			$charset = strtolower( $charset );
1974
-			if ( 'utf8' !== $charset && 'utf8mb4' !== $charset ) {
1970
+	foreach ($results as $column) {
1971
+		if ($column->Collation) {
1972
+			list($charset) = explode('_', $column->Collation);
1973
+			$charset = strtolower($charset);
1974
+			if ('utf8' !== $charset && 'utf8mb4' !== $charset) {
1975 1975
 				// Don't upgrade tables that have non-utf8 columns.
1976 1976
 				return false;
1977 1977
 			}
1978 1978
 		}
1979 1979
 	}
1980 1980
 
1981
-	$table_details = $wpdb->get_row( "SHOW TABLE STATUS LIKE '$table'" );
1982
-	if ( ! $table_details ) {
1981
+	$table_details = $wpdb->get_row("SHOW TABLE STATUS LIKE '$table'");
1982
+	if ( ! $table_details) {
1983 1983
 		return false;
1984 1984
 	}
1985 1985
 
1986
-	list( $table_charset ) = explode( '_', $table_details->Collation );
1987
-	$table_charset = strtolower( $table_charset );
1988
-	if ( 'utf8mb4' === $table_charset ) {
1986
+	list($table_charset) = explode('_', $table_details->Collation);
1987
+	$table_charset = strtolower($table_charset);
1988
+	if ('utf8mb4' === $table_charset) {
1989 1989
 		return true;
1990 1990
 	}
1991 1991
 
1992
-	return $wpdb->query( "ALTER TABLE $table CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci" );
1992
+	return $wpdb->query("ALTER TABLE $table CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci");
1993 1993
 }
1994 1994
 
1995 1995
 /**
@@ -2004,11 +2004,11 @@  discard block
 block discarded – undo
2004 2004
 function get_alloptions_110() {
2005 2005
 	global $wpdb;
2006 2006
 	$all_options = new stdClass;
2007
-	if ( $options = $wpdb->get_results( "SELECT option_name, option_value FROM $wpdb->options" ) ) {
2008
-		foreach ( $options as $option ) {
2009
-			if ( 'siteurl' == $option->option_name || 'home' == $option->option_name || 'category_base' == $option->option_name )
2010
-				$option->option_value = untrailingslashit( $option->option_value );
2011
-			$all_options->{$option->option_name} = stripslashes( $option->option_value );
2007
+	if ($options = $wpdb->get_results("SELECT option_name, option_value FROM $wpdb->options")) {
2008
+		foreach ($options as $option) {
2009
+			if ('siteurl' == $option->option_name || 'home' == $option->option_name || 'category_base' == $option->option_name)
2010
+				$option->option_value = untrailingslashit($option->option_value);
2011
+			$all_options->{$option->option_name} = stripslashes($option->option_value);
2012 2012
 		}
2013 2013
 	}
2014 2014
 	return $all_options;
@@ -2029,21 +2029,21 @@  discard block
 block discarded – undo
2029 2029
 function __get_option($setting) {
2030 2030
 	global $wpdb;
2031 2031
 
2032
-	if ( $setting == 'home' && defined( 'WP_HOME' ) )
2033
-		return untrailingslashit( WP_HOME );
2032
+	if ($setting == 'home' && defined('WP_HOME'))
2033
+		return untrailingslashit(WP_HOME);
2034 2034
 
2035
-	if ( $setting == 'siteurl' && defined( 'WP_SITEURL' ) )
2036
-		return untrailingslashit( WP_SITEURL );
2035
+	if ($setting == 'siteurl' && defined('WP_SITEURL'))
2036
+		return untrailingslashit(WP_SITEURL);
2037 2037
 
2038
-	$option = $wpdb->get_var( $wpdb->prepare("SELECT option_value FROM $wpdb->options WHERE option_name = %s", $setting ) );
2038
+	$option = $wpdb->get_var($wpdb->prepare("SELECT option_value FROM $wpdb->options WHERE option_name = %s", $setting));
2039 2039
 
2040
-	if ( 'home' == $setting && '' == $option )
2041
-		return __get_option( 'siteurl' );
2040
+	if ('home' == $setting && '' == $option)
2041
+		return __get_option('siteurl');
2042 2042
 
2043
-	if ( 'siteurl' == $setting || 'home' == $setting || 'category_base' == $setting || 'tag_base' == $setting )
2044
-		$option = untrailingslashit( $option );
2043
+	if ('siteurl' == $setting || 'home' == $setting || 'category_base' == $setting || 'tag_base' == $setting)
2044
+		$option = untrailingslashit($option);
2045 2045
 
2046
-	return maybe_unserialize( $option );
2046
+	return maybe_unserialize($option);
2047 2047
 }
2048 2048
 
2049 2049
 /**
@@ -2091,16 +2091,16 @@  discard block
 block discarded – undo
2091 2091
  *                              Default true.
2092 2092
  * @return array Strings containing the results of the various update queries.
2093 2093
  */
2094
-function dbDelta( $queries = '', $execute = true ) {
2094
+function dbDelta($queries = '', $execute = true) {
2095 2095
 	global $wpdb;
2096 2096
 
2097
-	if ( in_array( $queries, array( '', 'all', 'blog', 'global', 'ms_global' ), true ) )
2098
-	    $queries = wp_get_db_schema( $queries );
2097
+	if (in_array($queries, array('', 'all', 'blog', 'global', 'ms_global'), true))
2098
+	    $queries = wp_get_db_schema($queries);
2099 2099
 
2100 2100
 	// Separate individual queries into an array
2101
-	if ( !is_array($queries) ) {
2102
-		$queries = explode( ';', $queries );
2103
-		$queries = array_filter( $queries );
2101
+	if ( ! is_array($queries)) {
2102
+		$queries = explode(';', $queries);
2103
+		$queries = array_filter($queries);
2104 2104
 	}
2105 2105
 
2106 2106
 	/**
@@ -2110,7 +2110,7 @@  discard block
 block discarded – undo
2110 2110
 	 *
2111 2111
 	 * @param array $queries An array of dbDelta SQL queries.
2112 2112
 	 */
2113
-	$queries = apply_filters( 'dbdelta_queries', $queries );
2113
+	$queries = apply_filters('dbdelta_queries', $queries);
2114 2114
 
2115 2115
 	$cqueries = array(); // Creation Queries
2116 2116
 	$iqueries = array(); // Insertion Queries
@@ -2118,14 +2118,14 @@  discard block
 block discarded – undo
2118 2118
 
2119 2119
 	// Create a tablename index for an array ($cqueries) of queries
2120 2120
 	foreach ($queries as $qry) {
2121
-		if ( preg_match( "|CREATE TABLE ([^ ]*)|", $qry, $matches ) ) {
2122
-			$cqueries[ trim( $matches[1], '`' ) ] = $qry;
2121
+		if (preg_match("|CREATE TABLE ([^ ]*)|", $qry, $matches)) {
2122
+			$cqueries[trim($matches[1], '`')] = $qry;
2123 2123
 			$for_update[$matches[1]] = 'Created table '.$matches[1];
2124
-		} elseif ( preg_match( "|CREATE DATABASE ([^ ]*)|", $qry, $matches ) ) {
2125
-			array_unshift( $cqueries, $qry );
2126
-		} elseif ( preg_match( "|INSERT INTO ([^ ]*)|", $qry, $matches ) ) {
2124
+		} elseif (preg_match("|CREATE DATABASE ([^ ]*)|", $qry, $matches)) {
2125
+			array_unshift($cqueries, $qry);
2126
+		} elseif (preg_match("|INSERT INTO ([^ ]*)|", $qry, $matches)) {
2127 2127
 			$iqueries[] = $qry;
2128
-		} elseif ( preg_match( "|UPDATE ([^ ]*)|", $qry, $matches ) ) {
2128
+		} elseif (preg_match("|UPDATE ([^ ]*)|", $qry, $matches)) {
2129 2129
 			$iqueries[] = $qry;
2130 2130
 		} else {
2131 2131
 			// Unrecognized query type
@@ -2141,7 +2141,7 @@  discard block
 block discarded – undo
2141 2141
 	 *
2142 2142
 	 * @param array $cqueries An array of dbDelta create SQL queries.
2143 2143
 	 */
2144
-	$cqueries = apply_filters( 'dbdelta_create_queries', $cqueries );
2144
+	$cqueries = apply_filters('dbdelta_create_queries', $cqueries);
2145 2145
 
2146 2146
 	/**
2147 2147
 	 * Filter the dbDelta SQL queries for inserting or updating.
@@ -2152,22 +2152,22 @@  discard block
 block discarded – undo
2152 2152
 	 *
2153 2153
 	 * @param array $iqueries An array of dbDelta insert or update SQL queries.
2154 2154
 	 */
2155
-	$iqueries = apply_filters( 'dbdelta_insert_queries', $iqueries );
2155
+	$iqueries = apply_filters('dbdelta_insert_queries', $iqueries);
2156 2156
 
2157
-	$global_tables = $wpdb->tables( 'global' );
2158
-	foreach ( $cqueries as $table => $qry ) {
2157
+	$global_tables = $wpdb->tables('global');
2158
+	foreach ($cqueries as $table => $qry) {
2159 2159
 		// Upgrade global tables only for the main site. Don't upgrade at all if conditions are not optimal.
2160
-		if ( in_array( $table, $global_tables ) && ! wp_should_upgrade_global_tables() ) {
2161
-			unset( $cqueries[ $table ], $for_update[ $table ] );
2160
+		if (in_array($table, $global_tables) && ! wp_should_upgrade_global_tables()) {
2161
+			unset($cqueries[$table], $for_update[$table]);
2162 2162
 			continue;
2163 2163
 		}
2164 2164
 
2165 2165
 		// Fetch the table column structure from the database
2166 2166
 		$suppress = $wpdb->suppress_errors();
2167 2167
 		$tablefields = $wpdb->get_results("DESCRIBE {$table};");
2168
-		$wpdb->suppress_errors( $suppress );
2168
+		$wpdb->suppress_errors($suppress);
2169 2169
 
2170
-		if ( ! $tablefields )
2170
+		if ( ! $tablefields)
2171 2171
 			continue;
2172 2172
 
2173 2173
 		// Clear the field and index arrays.
@@ -2188,7 +2188,7 @@  discard block
 block discarded – undo
2188 2188
 
2189 2189
 			// Extract the field name.
2190 2190
 			preg_match("|^([^ ]*)|", trim($fld), $fvals);
2191
-			$fieldname = trim( $fvals[1], '`' );
2191
+			$fieldname = trim($fvals[1], '`');
2192 2192
 
2193 2193
 			// Verify the found field name.
2194 2194
 			$validfield = true;
@@ -2224,7 +2224,7 @@  discard block
 block discarded – undo
2224 2224
 				// Is actual field type different from the field type in query?
2225 2225
 				if ($tablefield->Type != $fieldtype) {
2226 2226
 					// Add a query to change the column type
2227
-					$cqueries[] = "ALTER TABLE {$table} CHANGE COLUMN {$tablefield->Field} " . $cfields[strtolower($tablefield->Field)];
2227
+					$cqueries[] = "ALTER TABLE {$table} CHANGE COLUMN {$tablefield->Field} ".$cfields[strtolower($tablefield->Field)];
2228 2228
 					$for_update[$table.'.'.$tablefield->Field] = "Changed type of {$table}.{$tablefield->Field} from {$tablefield->Type} to {$fieldtype}";
2229 2229
 				}
2230 2230
 
@@ -2267,7 +2267,7 @@  discard block
 block discarded – undo
2267 2267
 				// Add the index to the index data array.
2268 2268
 				$keyname = $tableindex->Key_name;
2269 2269
 				$index_ary[$keyname]['columns'][] = array('fieldname' => $tableindex->Column_name, 'subpart' => $tableindex->Sub_part);
2270
-				$index_ary[$keyname]['unique'] = ($tableindex->Non_unique == 0)?true:false;
2270
+				$index_ary[$keyname]['unique'] = ($tableindex->Non_unique == 0) ? true : false;
2271 2271
 				$index_ary[$keyname]['index_type'] = $tableindex->Index_type;
2272 2272
 			}
2273 2273
 
@@ -2278,10 +2278,10 @@  discard block
 block discarded – undo
2278 2278
 				$index_string = '';
2279 2279
 				if ($index_name == 'PRIMARY') {
2280 2280
 					$index_string .= 'PRIMARY ';
2281
-				} elseif ( $index_data['unique'] ) {
2281
+				} elseif ($index_data['unique']) {
2282 2282
 					$index_string .= 'UNIQUE ';
2283 2283
 				}
2284
-				if ( 'FULLTEXT' === strtoupper( $index_data['index_type'] ) ) {
2284
+				if ('FULLTEXT' === strtoupper($index_data['index_type'])) {
2285 2285
 					$index_string .= 'FULLTEXT ';
2286 2286
 				}
2287 2287
 				$index_string .= 'KEY ';
@@ -2302,7 +2302,7 @@  discard block
 block discarded – undo
2302 2302
 				}
2303 2303
 
2304 2304
 				// The alternative index string doesn't care about subparts
2305
-				$alt_index_columns = preg_replace( '/\([^)]*\)/', '', $index_columns );
2305
+				$alt_index_columns = preg_replace('/\([^)]*\)/', '', $index_columns);
2306 2306
 
2307 2307
 				// Add the column list to the index create string.
2308 2308
 				$index_strings = array(
@@ -2310,9 +2310,9 @@  discard block
 block discarded – undo
2310 2310
 					"$index_string ($alt_index_columns)",
2311 2311
 				);
2312 2312
 
2313
-				foreach ( $index_strings as $index_string ) {
2314
-					if ( ! ( ( $aindex = array_search( $index_string, $indices ) ) === false ) ) {
2315
-						unset( $indices[ $aindex ] );
2313
+				foreach ($index_strings as $index_string) {
2314
+					if ( ! (($aindex = array_search($index_string, $indices)) === false)) {
2315
+						unset($indices[$aindex]);
2316 2316
 						break;
2317 2317
 						// todo: Remove this?
2318 2318
 						//echo "<pre style=\"border:1px solid #ccc;margin-top:5px;\">{$table}:<br />Found index:".$index_string."</pre>\n";
@@ -2324,14 +2324,14 @@  discard block
 block discarded – undo
2324 2324
 		}
2325 2325
 
2326 2326
 		// For every remaining index specified for the table.
2327
-		foreach ( (array) $indices as $index ) {
2327
+		foreach ((array) $indices as $index) {
2328 2328
 			// Push a query line into $cqueries that adds the index to that table.
2329 2329
 			$cqueries[] = "ALTER TABLE {$table} ADD $index";
2330
-			$for_update[] = 'Added index ' . $table . ' ' . $index;
2330
+			$for_update[] = 'Added index '.$table.' '.$index;
2331 2331
 		}
2332 2332
 
2333 2333
 		// Remove the original table creation query from processing.
2334
-		unset( $cqueries[ $table ], $for_update[ $table ] );
2334
+		unset($cqueries[$table], $for_update[$table]);
2335 2335
 	}
2336 2336
 
2337 2337
 	$allqueries = array_merge($cqueries, $iqueries);
@@ -2358,8 +2358,8 @@  discard block
 block discarded – undo
2358 2358
  *
2359 2359
  * @param string $tables Optional. Which set of tables to update. Default is 'all'.
2360 2360
  */
2361
-function make_db_current( $tables = 'all' ) {
2362
-	$alterations = dbDelta( $tables );
2361
+function make_db_current($tables = 'all') {
2362
+	$alterations = dbDelta($tables);
2363 2363
 	echo "<ol>\n";
2364 2364
 	foreach ($alterations as $alteration) echo "<li>$alteration</li>\n";
2365 2365
 	echo "</ol>\n";
@@ -2377,8 +2377,8 @@  discard block
 block discarded – undo
2377 2377
  *
2378 2378
  * @param string $tables Optional. Which set of tables to update. Default is 'all'.
2379 2379
  */
2380
-function make_db_current_silent( $tables = 'all' ) {
2381
-	dbDelta( $tables );
2380
+function make_db_current_silent($tables = 'all') {
2381
+	dbDelta($tables);
2382 2382
 }
2383 2383
 
2384 2384
 /**
@@ -2394,9 +2394,9 @@  discard block
 block discarded – undo
2394 2394
  */
2395 2395
 function make_site_theme_from_oldschool($theme_name, $template) {
2396 2396
 	$home_path = get_home_path();
2397
-	$site_dir = WP_CONTENT_DIR . "/themes/$template";
2397
+	$site_dir = WP_CONTENT_DIR."/themes/$template";
2398 2398
 
2399
-	if (! file_exists("$home_path/index.php"))
2399
+	if ( ! file_exists("$home_path/index.php"))
2400 2400
 		return false;
2401 2401
 
2402 2402
 	/*
@@ -2415,7 +2415,7 @@  discard block
 block discarded – undo
2415 2415
 		if ($oldfile == 'index.php') {
2416 2416
 			$index = implode('', file("$oldpath/$oldfile"));
2417 2417
 			if (strpos($index, 'WP_USE_THEMES') !== false) {
2418
-				if (! @copy(WP_CONTENT_DIR . '/themes/' . WP_DEFAULT_THEME . '/index.php', "$site_dir/$newfile"))
2418
+				if ( ! @copy(WP_CONTENT_DIR.'/themes/'.WP_DEFAULT_THEME.'/index.php', "$site_dir/$newfile"))
2419 2419
 					return false;
2420 2420
 
2421 2421
 				// Don't copy anything.
@@ -2423,7 +2423,7 @@  discard block
 block discarded – undo
2423 2423
 			}
2424 2424
 		}
2425 2425
 
2426
-		if (! @copy("$oldpath/$oldfile", "$site_dir/$newfile"))
2426
+		if ( ! @copy("$oldpath/$oldfile", "$site_dir/$newfile"))
2427 2427
 			return false;
2428 2428
 
2429 2429
 		chmod("$site_dir/$newfile", 0777);
@@ -2435,7 +2435,7 @@  discard block
 block discarded – undo
2435 2435
 
2436 2436
 			foreach ($lines as $line) {
2437 2437
 				if (preg_match('/require.*wp-blog-header/', $line))
2438
-					$line = '//' . $line;
2438
+					$line = '//'.$line;
2439 2439
 
2440 2440
 				// Update stylesheet references.
2441 2441
 				$line = str_replace("<?php echo __get_option('siteurl'); ?>/wp-layout.css", "<?php bloginfo('stylesheet_url'); ?>", $line);
@@ -2450,7 +2450,7 @@  discard block
 block discarded – undo
2450 2450
 	}
2451 2451
 
2452 2452
 	// Add a theme header.
2453
-	$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";
2453
+	$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";
2454 2454
 
2455 2455
 	$stylelines = file_get_contents("$site_dir/style.css");
2456 2456
 	if ($stylelines) {
@@ -2476,18 +2476,18 @@  discard block
 block discarded – undo
2476 2476
  * @return false|void
2477 2477
  */
2478 2478
 function make_site_theme_from_default($theme_name, $template) {
2479
-	$site_dir = WP_CONTENT_DIR . "/themes/$template";
2480
-	$default_dir = WP_CONTENT_DIR . '/themes/' . WP_DEFAULT_THEME;
2479
+	$site_dir = WP_CONTENT_DIR."/themes/$template";
2480
+	$default_dir = WP_CONTENT_DIR.'/themes/'.WP_DEFAULT_THEME;
2481 2481
 
2482 2482
 	// Copy files from the default theme to the site theme.
2483 2483
 	//$files = array('index.php', 'comments.php', 'comments-popup.php', 'footer.php', 'header.php', 'sidebar.php', 'style.css');
2484 2484
 
2485 2485
 	$theme_dir = @ opendir($default_dir);
2486 2486
 	if ($theme_dir) {
2487
-		while(($theme_file = readdir( $theme_dir )) !== false) {
2487
+		while (($theme_file = readdir($theme_dir)) !== false) {
2488 2488
 			if (is_dir("$default_dir/$theme_file"))
2489 2489
 				continue;
2490
-			if (! @copy("$default_dir/$theme_file", "$site_dir/$theme_file"))
2490
+			if ( ! @copy("$default_dir/$theme_file", "$site_dir/$theme_file"))
2491 2491
 				return;
2492 2492
 			chmod("$site_dir/$theme_file", 0777);
2493 2493
 		}
@@ -2500,28 +2500,28 @@  discard block
 block discarded – undo
2500 2500
 		$f = fopen("$site_dir/style.css", 'w');
2501 2501
 
2502 2502
 		foreach ($stylelines as $line) {
2503
-			if (strpos($line, 'Theme Name:') !== false) $line = 'Theme Name: ' . $theme_name;
2504
-			elseif (strpos($line, 'Theme URI:') !== false) $line = 'Theme URI: ' . __get_option('url');
2503
+			if (strpos($line, 'Theme Name:') !== false) $line = 'Theme Name: '.$theme_name;
2504
+			elseif (strpos($line, 'Theme URI:') !== false) $line = 'Theme URI: '.__get_option('url');
2505 2505
 			elseif (strpos($line, 'Description:') !== false) $line = 'Description: Your theme.';
2506 2506
 			elseif (strpos($line, 'Version:') !== false) $line = 'Version: 1';
2507 2507
 			elseif (strpos($line, 'Author:') !== false) $line = 'Author: You';
2508
-			fwrite($f, $line . "\n");
2508
+			fwrite($f, $line."\n");
2509 2509
 		}
2510 2510
 		fclose($f);
2511 2511
 	}
2512 2512
 
2513 2513
 	// Copy the images.
2514 2514
 	umask(0);
2515
-	if (! mkdir("$site_dir/images", 0777)) {
2515
+	if ( ! mkdir("$site_dir/images", 0777)) {
2516 2516
 		return false;
2517 2517
 	}
2518 2518
 
2519 2519
 	$images_dir = @ opendir("$default_dir/images");
2520 2520
 	if ($images_dir) {
2521
-		while(($image = readdir($images_dir)) !== false) {
2521
+		while (($image = readdir($images_dir)) !== false) {
2522 2522
 			if (is_dir("$default_dir/images/$image"))
2523 2523
 				continue;
2524
-			if (! @copy("$default_dir/images/$image", "$site_dir/images/$image"))
2524
+			if ( ! @copy("$default_dir/images/$image", "$site_dir/images/$image"))
2525 2525
 				return;
2526 2526
 			chmod("$site_dir/images/$image", 0777);
2527 2527
 		}
@@ -2542,30 +2542,30 @@  discard block
 block discarded – undo
2542 2542
 	// Name the theme after the blog.
2543 2543
 	$theme_name = __get_option('blogname');
2544 2544
 	$template = sanitize_title($theme_name);
2545
-	$site_dir = WP_CONTENT_DIR . "/themes/$template";
2545
+	$site_dir = WP_CONTENT_DIR."/themes/$template";
2546 2546
 
2547 2547
 	// If the theme already exists, nothing to do.
2548
-	if ( is_dir($site_dir)) {
2548
+	if (is_dir($site_dir)) {
2549 2549
 		return false;
2550 2550
 	}
2551 2551
 
2552 2552
 	// We must be able to write to the themes dir.
2553
-	if (! is_writable(WP_CONTENT_DIR . "/themes")) {
2553
+	if ( ! is_writable(WP_CONTENT_DIR."/themes")) {
2554 2554
 		return false;
2555 2555
 	}
2556 2556
 
2557 2557
 	umask(0);
2558
-	if (! mkdir($site_dir, 0777)) {
2558
+	if ( ! mkdir($site_dir, 0777)) {
2559 2559
 		return false;
2560 2560
 	}
2561 2561
 
2562
-	if (file_exists(ABSPATH . 'wp-layout.css')) {
2563
-		if (! make_site_theme_from_oldschool($theme_name, $template)) {
2562
+	if (file_exists(ABSPATH.'wp-layout.css')) {
2563
+		if ( ! make_site_theme_from_oldschool($theme_name, $template)) {
2564 2564
 			// TODO: rm -rf the site theme directory.
2565 2565
 			return false;
2566 2566
 		}
2567 2567
 	} else {
2568
-		if (! make_site_theme_from_default($theme_name, $template))
2568
+		if ( ! make_site_theme_from_default($theme_name, $template))
2569 2569
 			// TODO: rm -rf the site theme directory.
2570 2570
 			return false;
2571 2571
 	}
@@ -2618,8 +2618,8 @@  discard block
 block discarded – undo
2618 2618
 function wp_check_mysql_version() {
2619 2619
 	global $wpdb;
2620 2620
 	$result = $wpdb->check_database_version();
2621
-	if ( is_wp_error( $result ) )
2622
-		die( $result->get_error_message() );
2621
+	if (is_wp_error($result))
2622
+		die($result->get_error_message());
2623 2623
 }
2624 2624
 
2625 2625
 /**
@@ -2628,12 +2628,12 @@  discard block
 block discarded – undo
2628 2628
  * @since 2.2.0
2629 2629
  */
2630 2630
 function maybe_disable_automattic_widgets() {
2631
-	$plugins = __get_option( 'active_plugins' );
2631
+	$plugins = __get_option('active_plugins');
2632 2632
 
2633
-	foreach ( (array) $plugins as $plugin ) {
2634
-		if ( basename( $plugin ) == 'widgets.php' ) {
2635
-			array_splice( $plugins, array_search( $plugin, $plugins ), 1 );
2636
-			update_option( 'active_plugins', $plugins );
2633
+	foreach ((array) $plugins as $plugin) {
2634
+		if (basename($plugin) == 'widgets.php') {
2635
+			array_splice($plugins, array_search($plugin, $plugins), 1);
2636
+			update_option('active_plugins', $plugins);
2637 2637
 			break;
2638 2638
 		}
2639 2639
 	}
@@ -2650,8 +2650,8 @@  discard block
 block discarded – undo
2650 2650
 function maybe_disable_link_manager() {
2651 2651
 	global $wp_current_db_version, $wpdb;
2652 2652
 
2653
-	if ( $wp_current_db_version >= 22006 && get_option( 'link_manager_enabled' ) && ! $wpdb->get_var( "SELECT link_id FROM $wpdb->links LIMIT 1" ) )
2654
-		update_option( 'link_manager_enabled', 0 );
2653
+	if ($wp_current_db_version >= 22006 && get_option('link_manager_enabled') && ! $wpdb->get_var("SELECT link_id FROM $wpdb->links LIMIT 1"))
2654
+		update_option('link_manager_enabled', 0);
2655 2655
 }
2656 2656
 
2657 2657
 /**
@@ -2666,7 +2666,7 @@  discard block
 block discarded – undo
2666 2666
 	global $wp_current_db_version, $wpdb;
2667 2667
 
2668 2668
 	// Upgrade versions prior to 2.9
2669
-	if ( $wp_current_db_version < 11557 ) {
2669
+	if ($wp_current_db_version < 11557) {
2670 2670
 		// Delete duplicate options. Keep the option with the highest option_id.
2671 2671
 		$wpdb->query("DELETE o1 FROM $wpdb->options AS o1 JOIN $wpdb->options AS o2 USING (`option_name`) WHERE o2.option_id > o1.option_id");
2672 2672
 
@@ -2678,40 +2678,40 @@  discard block
 block discarded – undo
2678 2678
 	}
2679 2679
 
2680 2680
 	// Multisite schema upgrades.
2681
-	if ( $wp_current_db_version < 25448 && is_multisite() && wp_should_upgrade_global_tables() ) {
2681
+	if ($wp_current_db_version < 25448 && is_multisite() && wp_should_upgrade_global_tables()) {
2682 2682
 
2683 2683
 		// Upgrade verions prior to 3.7
2684
-		if ( $wp_current_db_version < 25179 ) {
2684
+		if ($wp_current_db_version < 25179) {
2685 2685
 			// New primary key for signups.
2686
-			$wpdb->query( "ALTER TABLE $wpdb->signups ADD signup_id BIGINT(20) NOT NULL AUTO_INCREMENT PRIMARY KEY FIRST" );
2687
-			$wpdb->query( "ALTER TABLE $wpdb->signups DROP INDEX domain" );
2686
+			$wpdb->query("ALTER TABLE $wpdb->signups ADD signup_id BIGINT(20) NOT NULL AUTO_INCREMENT PRIMARY KEY FIRST");
2687
+			$wpdb->query("ALTER TABLE $wpdb->signups DROP INDEX domain");
2688 2688
 		}
2689 2689
 
2690
-		if ( $wp_current_db_version < 25448 ) {
2690
+		if ($wp_current_db_version < 25448) {
2691 2691
 			// Convert archived from enum to tinyint.
2692
-			$wpdb->query( "ALTER TABLE $wpdb->blogs CHANGE COLUMN archived archived varchar(1) NOT NULL default '0'" );
2693
-			$wpdb->query( "ALTER TABLE $wpdb->blogs CHANGE COLUMN archived archived tinyint(2) NOT NULL default 0" );
2692
+			$wpdb->query("ALTER TABLE $wpdb->blogs CHANGE COLUMN archived archived varchar(1) NOT NULL default '0'");
2693
+			$wpdb->query("ALTER TABLE $wpdb->blogs CHANGE COLUMN archived archived tinyint(2) NOT NULL default 0");
2694 2694
 		}
2695 2695
 	}
2696 2696
 
2697 2697
 	// Upgrade versions prior to 4.2.
2698
-	if ( $wp_current_db_version < 31351 ) {
2699
-		if ( ! is_multisite() && wp_should_upgrade_global_tables() ) {
2700
-			$wpdb->query( "ALTER TABLE $wpdb->usermeta DROP INDEX meta_key, ADD INDEX meta_key(meta_key(191))" );
2698
+	if ($wp_current_db_version < 31351) {
2699
+		if ( ! is_multisite() && wp_should_upgrade_global_tables()) {
2700
+			$wpdb->query("ALTER TABLE $wpdb->usermeta DROP INDEX meta_key, ADD INDEX meta_key(meta_key(191))");
2701 2701
 		}
2702
-		$wpdb->query( "ALTER TABLE $wpdb->terms DROP INDEX slug, ADD INDEX slug(slug(191))" );
2703
-		$wpdb->query( "ALTER TABLE $wpdb->terms DROP INDEX name, ADD INDEX name(name(191))" );
2704
-		$wpdb->query( "ALTER TABLE $wpdb->commentmeta DROP INDEX meta_key, ADD INDEX meta_key(meta_key(191))" );
2705
-		$wpdb->query( "ALTER TABLE $wpdb->postmeta DROP INDEX meta_key, ADD INDEX meta_key(meta_key(191))" );
2706
-		$wpdb->query( "ALTER TABLE $wpdb->posts DROP INDEX post_name, ADD INDEX post_name(post_name(191))" );
2702
+		$wpdb->query("ALTER TABLE $wpdb->terms DROP INDEX slug, ADD INDEX slug(slug(191))");
2703
+		$wpdb->query("ALTER TABLE $wpdb->terms DROP INDEX name, ADD INDEX name(name(191))");
2704
+		$wpdb->query("ALTER TABLE $wpdb->commentmeta DROP INDEX meta_key, ADD INDEX meta_key(meta_key(191))");
2705
+		$wpdb->query("ALTER TABLE $wpdb->postmeta DROP INDEX meta_key, ADD INDEX meta_key(meta_key(191))");
2706
+		$wpdb->query("ALTER TABLE $wpdb->posts DROP INDEX post_name, ADD INDEX post_name(post_name(191))");
2707 2707
 	}
2708 2708
 
2709 2709
 	// Upgrade versions prior to 4.4.
2710
-	if ( $wp_current_db_version < 34978 ) {
2710
+	if ($wp_current_db_version < 34978) {
2711 2711
 		// If compatible termmeta table is found, use it, but enforce a proper index and update collation.
2712
-		if ( $wpdb->get_var( "SHOW TABLES LIKE '{$wpdb->termmeta}'" ) && $wpdb->get_results( "SHOW INDEX FROM {$wpdb->termmeta} WHERE Column_name = 'meta_key'" ) ) {
2713
-			$wpdb->query( "ALTER TABLE $wpdb->termmeta DROP INDEX meta_key, ADD INDEX meta_key(meta_key(191))" );
2714
-			maybe_convert_table_to_utf8mb4( $wpdb->termmeta );
2712
+		if ($wpdb->get_var("SHOW TABLES LIKE '{$wpdb->termmeta}'") && $wpdb->get_results("SHOW INDEX FROM {$wpdb->termmeta} WHERE Column_name = 'meta_key'")) {
2713
+			$wpdb->query("ALTER TABLE $wpdb->termmeta DROP INDEX meta_key, ADD INDEX meta_key(meta_key(191))");
2714
+			maybe_convert_table_to_utf8mb4($wpdb->termmeta);
2715 2715
 		}
2716 2716
 	}
2717 2717
 }
@@ -2724,7 +2724,7 @@  discard block
 block discarded – undo
2724 2724
  * @global wpdb   $wpdb
2725 2725
  * @global string $charset_collate
2726 2726
  */
2727
-if ( !function_exists( 'install_global_terms' ) ) :
2727
+if ( ! function_exists('install_global_terms')) :
2728 2728
 function install_global_terms() {
2729 2729
 	global $wpdb, $charset_collate;
2730 2730
 	$ms_queries = "
@@ -2739,7 +2739,7 @@  discard block
 block discarded – undo
2739 2739
 ) $charset_collate;
2740 2740
 ";
2741 2741
 // now create tables
2742
-	dbDelta( $ms_queries );
2742
+	dbDelta($ms_queries);
2743 2743
 }
2744 2744
 endif;
2745 2745
 
@@ -2764,7 +2764,7 @@  discard block
 block discarded – undo
2764 2764
 function wp_should_upgrade_global_tables() {
2765 2765
 
2766 2766
 	// Return false early if explicitly not upgrading
2767
-	if ( defined( 'DO_NOT_UPGRADE_GLOBAL_TABLES' ) ) {
2767
+	if (defined('DO_NOT_UPGRADE_GLOBAL_TABLES')) {
2768 2768
 		return false;
2769 2769
 	}
2770 2770
 
@@ -2772,12 +2772,12 @@  discard block
 block discarded – undo
2772 2772
 	$should_upgrade = true;
2773 2773
 
2774 2774
 	// Set to false if not on main network (does not matter if not multi-network)
2775
-	if ( ! is_main_network() ) {
2775
+	if ( ! is_main_network()) {
2776 2776
 		$should_upgrade = false;
2777 2777
 	}
2778 2778
 
2779 2779
 	// Set to false if not on main site of current network (does not matter if not multi-site)
2780
-	if ( ! is_main_site() ) {
2780
+	if ( ! is_main_site()) {
2781 2781
 		$should_upgrade = false;
2782 2782
 	}
2783 2783
 
@@ -2786,5 +2786,5 @@  discard block
 block discarded – undo
2786 2786
 	 *
2787 2787
 	 * @param bool $should_upgrade Whether to run the upgrade routines on global tables.
2788 2788
 	 */
2789
-	return apply_filters( 'wp_should_upgrade_global_tables', $should_upgrade );
2789
+	return apply_filters('wp_should_upgrade_global_tables', $should_upgrade);
2790 2790
 }
Please login to merge, or discard this patch.
Braces   +368 added lines, -237 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' );
41
+	if ( !empty( $deprecated ) ) {
42
+			_deprecated_argument( __FUNCTION__, '2.6' );
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
@@ -220,8 +223,9 @@  discard block
 block discarded – undo
220 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>
221 224
 
222 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() );
223
-	if ( is_multisite() )
224
-		$first_page = get_site_option( 'first_page', $first_page );
226
+	if ( is_multisite() ) {
227
+			$first_page = get_site_option( 'first_page', $first_page );
228
+	}
225 229
 	$first_post_guid = get_option('home') . '/?page_id=2';
226 230
 	$wpdb->insert( $wpdb->posts, array(
227 231
 		'post_author' => $user_id,
@@ -252,10 +256,11 @@  discard block
 block discarded – undo
252 256
 	update_option( 'widget_meta', array ( 2 => array ( 'title' => '' ), '_multiwidget' => 1 ) );
253 257
 	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 ) );
254 258
 
255
-	if ( ! is_multisite() )
256
-		update_user_meta( $user_id, 'show_welcome_panel', 1 );
257
-	elseif ( ! is_super_admin( $user_id ) && ! metadata_exists( 'user', $user_id, 'show_welcome_panel' ) )
258
-		update_user_meta( $user_id, 'show_welcome_panel', 2 );
259
+	if ( ! is_multisite() ) {
260
+			update_user_meta( $user_id, 'show_welcome_panel', 1 );
261
+	} elseif ( ! is_super_admin( $user_id ) && ! metadata_exists( 'user', $user_id, 'show_welcome_panel' ) ) {
262
+			update_user_meta( $user_id, 'show_welcome_panel', 2 );
263
+	}
259 264
 
260 265
 	if ( is_multisite() ) {
261 266
 		// Flush rules to pick up the new page.
@@ -270,8 +275,9 @@  discard block
 block discarded – undo
270 275
 		$wpdb->query( $wpdb->prepare("DELETE FROM $wpdb->usermeta WHERE user_id != %d AND meta_key = %s", $user_id, $table_prefix.'capabilities') );
271 276
 
272 277
 		// Delete any caps that snuck into the previously active blog. (Hardcoded to blog 1 for now.) TODO: Get previous_blog_id.
273
-		if ( !is_super_admin( $user_id ) && $user_id != 1 )
274
-			$wpdb->delete( $wpdb->usermeta, array( 'user_id' => $user_id , 'meta_key' => $wpdb->base_prefix.'1_capabilities' ) );
278
+		if ( !is_super_admin( $user_id ) && $user_id != 1 ) {
279
+					$wpdb->delete( $wpdb->usermeta, array( 'user_id' => $user_id , 'meta_key' => $wpdb->base_prefix.'1_capabilities' ) );
280
+		}
275 281
 	}
276 282
 }
277 283
 endif;
@@ -407,26 +413,30 @@  discard block
 block discarded – undo
407 413
 	$wp_current_db_version = __get_option('db_version');
408 414
 
409 415
 	// We are up-to-date. Nothing to do.
410
-	if ( $wp_db_version == $wp_current_db_version )
411
-		return;
416
+	if ( $wp_db_version == $wp_current_db_version ) {
417
+			return;
418
+	}
412 419
 
413
-	if ( ! is_blog_installed() )
414
-		return;
420
+	if ( ! is_blog_installed() ) {
421
+			return;
422
+	}
415 423
 
416 424
 	wp_check_mysql_version();
417 425
 	wp_cache_flush();
418 426
 	pre_schema_upgrade();
419 427
 	make_db_current_silent();
420 428
 	upgrade_all();
421
-	if ( is_multisite() && is_main_site() )
422
-		upgrade_network();
429
+	if ( is_multisite() && is_main_site() ) {
430
+			upgrade_network();
431
+	}
423 432
 	wp_cache_flush();
424 433
 
425 434
 	if ( is_multisite() ) {
426
-		if ( $wpdb->get_row( "SELECT blog_id FROM {$wpdb->blog_versions} WHERE blog_id = '{$wpdb->blogid}'" ) )
427
-			$wpdb->query( "UPDATE {$wpdb->blog_versions} SET db_version = '{$wp_db_version}' WHERE blog_id = '{$wpdb->blogid}'" );
428
-		else
429
-			$wpdb->query( "INSERT INTO {$wpdb->blog_versions} ( `blog_id` , `db_version` , `last_updated` ) VALUES ( '{$wpdb->blogid}', '{$wp_db_version}', NOW());" );
435
+		if ( $wpdb->get_row( "SELECT blog_id FROM {$wpdb->blog_versions} WHERE blog_id = '{$wpdb->blogid}'" ) ) {
436
+					$wpdb->query( "UPDATE {$wpdb->blog_versions} SET db_version = '{$wp_db_version}' WHERE blog_id = '{$wpdb->blogid}'" );
437
+		} else {
438
+					$wpdb->query( "INSERT INTO {$wpdb->blog_versions} ( `blog_id` , `db_version` , `last_updated` ) VALUES ( '{$wpdb->blogid}', '{$wp_db_version}', NOW());" );
439
+		}
430 440
 	}
431 441
 
432 442
 	/**
@@ -458,8 +468,9 @@  discard block
 block discarded – undo
458 468
 	$wp_current_db_version = __get_option('db_version');
459 469
 
460 470
 	// We are up-to-date. Nothing to do.
461
-	if ( $wp_db_version == $wp_current_db_version )
462
-		return;
471
+	if ( $wp_db_version == $wp_current_db_version ) {
472
+			return;
473
+	}
463 474
 
464 475
 	// If the version is not set in the DB, try to guess the version.
465 476
 	if ( empty($wp_current_db_version) ) {
@@ -467,12 +478,14 @@  discard block
 block discarded – undo
467 478
 
468 479
 		// If the template option exists, we have 1.5.
469 480
 		$template = __get_option('template');
470
-		if ( !empty($template) )
471
-			$wp_current_db_version = 2541;
481
+		if ( !empty($template) ) {
482
+					$wp_current_db_version = 2541;
483
+		}
472 484
 	}
473 485
 
474
-	if ( $wp_current_db_version < 6039 )
475
-		upgrade_230_options_table();
486
+	if ( $wp_current_db_version < 6039 ) {
487
+			upgrade_230_options_table();
488
+	}
476 489
 
477 490
 	populate_options();
478 491
 
@@ -483,74 +496,97 @@  discard block
 block discarded – undo
483 496
 		upgrade_130();
484 497
 	}
485 498
 
486
-	if ( $wp_current_db_version < 3308 )
487
-		upgrade_160();
499
+	if ( $wp_current_db_version < 3308 ) {
500
+			upgrade_160();
501
+	}
488 502
 
489
-	if ( $wp_current_db_version < 4772 )
490
-		upgrade_210();
503
+	if ( $wp_current_db_version < 4772 ) {
504
+			upgrade_210();
505
+	}
491 506
 
492
-	if ( $wp_current_db_version < 4351 )
493
-		upgrade_old_slugs();
507
+	if ( $wp_current_db_version < 4351 ) {
508
+			upgrade_old_slugs();
509
+	}
494 510
 
495
-	if ( $wp_current_db_version < 5539 )
496
-		upgrade_230();
511
+	if ( $wp_current_db_version < 5539 ) {
512
+			upgrade_230();
513
+	}
497 514
 
498
-	if ( $wp_current_db_version < 6124 )
499
-		upgrade_230_old_tables();
515
+	if ( $wp_current_db_version < 6124 ) {
516
+			upgrade_230_old_tables();
517
+	}
500 518
 
501
-	if ( $wp_current_db_version < 7499 )
502
-		upgrade_250();
519
+	if ( $wp_current_db_version < 7499 ) {
520
+			upgrade_250();
521
+	}
503 522
 
504
-	if ( $wp_current_db_version < 7935 )
505
-		upgrade_252();
523
+	if ( $wp_current_db_version < 7935 ) {
524
+			upgrade_252();
525
+	}
506 526
 
507
-	if ( $wp_current_db_version < 8201 )
508
-		upgrade_260();
527
+	if ( $wp_current_db_version < 8201 ) {
528
+			upgrade_260();
529
+	}
509 530
 
510
-	if ( $wp_current_db_version < 8989 )
511
-		upgrade_270();
531
+	if ( $wp_current_db_version < 8989 ) {
532
+			upgrade_270();
533
+	}
512 534
 
513
-	if ( $wp_current_db_version < 10360 )
514
-		upgrade_280();
535
+	if ( $wp_current_db_version < 10360 ) {
536
+			upgrade_280();
537
+	}
515 538
 
516
-	if ( $wp_current_db_version < 11958 )
517
-		upgrade_290();
539
+	if ( $wp_current_db_version < 11958 ) {
540
+			upgrade_290();
541
+	}
518 542
 
519
-	if ( $wp_current_db_version < 15260 )
520
-		upgrade_300();
543
+	if ( $wp_current_db_version < 15260 ) {
544
+			upgrade_300();
545
+	}
521 546
 
522
-	if ( $wp_current_db_version < 19389 )
523
-		upgrade_330();
547
+	if ( $wp_current_db_version < 19389 ) {
548
+			upgrade_330();
549
+	}
524 550
 
525
-	if ( $wp_current_db_version < 20080 )
526
-		upgrade_340();
551
+	if ( $wp_current_db_version < 20080 ) {
552
+			upgrade_340();
553
+	}
527 554
 
528
-	if ( $wp_current_db_version < 22422 )
529
-		upgrade_350();
555
+	if ( $wp_current_db_version < 22422 ) {
556
+			upgrade_350();
557
+	}
530 558
 
531
-	if ( $wp_current_db_version < 25824 )
532
-		upgrade_370();
559
+	if ( $wp_current_db_version < 25824 ) {
560
+			upgrade_370();
561
+	}
533 562
 
534
-	if ( $wp_current_db_version < 26148 )
535
-		upgrade_372();
563
+	if ( $wp_current_db_version < 26148 ) {
564
+			upgrade_372();
565
+	}
536 566
 
537
-	if ( $wp_current_db_version < 26691 )
538
-		upgrade_380();
567
+	if ( $wp_current_db_version < 26691 ) {
568
+			upgrade_380();
569
+	}
539 570
 
540
-	if ( $wp_current_db_version < 29630 )
541
-		upgrade_400();
571
+	if ( $wp_current_db_version < 29630 ) {
572
+			upgrade_400();
573
+	}
542 574
 
543
-	if ( $wp_current_db_version < 33055 )
544
-		upgrade_430();
575
+	if ( $wp_current_db_version < 33055 ) {
576
+			upgrade_430();
577
+	}
545 578
 
546
-	if ( $wp_current_db_version < 33056 )
547
-		upgrade_431();
579
+	if ( $wp_current_db_version < 33056 ) {
580
+			upgrade_431();
581
+	}
548 582
 
549
-	if ( $wp_current_db_version < 35700 )
550
-		upgrade_440();
583
+	if ( $wp_current_db_version < 35700 ) {
584
+			upgrade_440();
585
+	}
551 586
 
552
-	if ( $wp_current_db_version < 36686 )
553
-		upgrade_450();
587
+	if ( $wp_current_db_version < 36686 ) {
588
+			upgrade_450();
589
+	}
554 590
 
555 591
 	maybe_disable_link_manager();
556 592
 
@@ -603,8 +639,10 @@  discard block
 block discarded – undo
603 639
 			$done_posts[] = $done_id->post_id;
604 640
 		endforeach;
605 641
 		$catwhere = ' AND ID NOT IN (' . implode(',', $done_posts) . ')';
606
-	else:
642
+	else {
643
+		:
607 644
 		$catwhere = '';
645
+	}
608 646
 	endif;
609 647
 
610 648
 	$allposts = $wpdb->get_results("SELECT ID, post_category FROM $wpdb->posts WHERE post_category != '0' $catwhere");
@@ -721,10 +759,11 @@  discard block
 block discarded – undo
721 759
 			$post_content = addslashes(deslash($post->post_content));
722 760
 			$post_title = addslashes(deslash($post->post_title));
723 761
 			$post_excerpt = addslashes(deslash($post->post_excerpt));
724
-			if ( empty($post->guid) )
725
-				$guid = get_permalink($post->ID);
726
-			else
727
-				$guid = $post->guid;
762
+			if ( empty($post->guid) ) {
763
+							$guid = get_permalink($post->ID);
764
+			} else {
765
+							$guid = $post->guid;
766
+			}
728 767
 
729 768
 			$wpdb->update( $wpdb->posts, compact('post_title', 'post_content', 'post_excerpt', 'guid'), array('ID' => $post->ID) );
730 769
 
@@ -806,34 +845,57 @@  discard block
 block discarded – undo
806 845
 
807 846
 	$users = $wpdb->get_results("SELECT * FROM $wpdb->users");
808 847
 	foreach ( $users as $user ) :
809
-		if ( !empty( $user->user_firstname ) )
810
-			update_user_meta( $user->ID, 'first_name', wp_slash($user->user_firstname) );
811
-		if ( !empty( $user->user_lastname ) )
812
-			update_user_meta( $user->ID, 'last_name', wp_slash($user->user_lastname) );
813
-		if ( !empty( $user->user_nickname ) )
814
-			update_user_meta( $user->ID, 'nickname', wp_slash($user->user_nickname) );
815
-		if ( !empty( $user->user_level ) )
816
-			update_user_meta( $user->ID, $wpdb->prefix . 'user_level', $user->user_level );
817
-		if ( !empty( $user->user_icq ) )
818
-			update_user_meta( $user->ID, 'icq', wp_slash($user->user_icq) );
819
-		if ( !empty( $user->user_aim ) )
820
-			update_user_meta( $user->ID, 'aim', wp_slash($user->user_aim) );
821
-		if ( !empty( $user->user_msn ) )
822
-			update_user_meta( $user->ID, 'msn', wp_slash($user->user_msn) );
823
-		if ( !empty( $user->user_yim ) )
824
-			update_user_meta( $user->ID, 'yim', wp_slash($user->user_icq) );
825
-		if ( !empty( $user->user_description ) )
826
-			update_user_meta( $user->ID, 'description', wp_slash($user->user_description) );
848
+		if ( !empty( $user->user_firstname ) ) {
849
+					update_user_meta( $user->ID, 'first_name', wp_slash($user->user_firstname) );
850
+		}
851
+		if ( !empty( $user->user_lastname ) ) {
852
+					update_user_meta( $user->ID, 'last_name', wp_slash($user->user_lastname) );
853
+		}
854
+		if ( !empty( $user->user_nickname ) ) {
855
+					update_user_meta( $user->ID, 'nickname', wp_slash($user->user_nickname) );
856
+		}
857
+		if ( !empty( $user->user_level ) ) {
858
+					update_user_meta( $user->ID, $wpdb->prefix . 'user_level', $user->user_level );
859
+		}
860
+		if ( !empty( $user->user_icq ) ) {
861
+					update_user_meta( $user->ID, 'icq', wp_slash($user->user_icq) );
862
+		}
863
+		if ( !empty( $user->user_aim ) ) {
864
+					update_user_meta( $user->ID, 'aim', wp_slash($user->user_aim) );
865
+		}
866
+		if ( !empty( $user->user_msn ) ) {
867
+					update_user_meta( $user->ID, 'msn', wp_slash($user->user_msn) );
868
+		}
869
+		if ( !empty( $user->user_yim ) ) {
870
+					update_user_meta( $user->ID, 'yim', wp_slash($user->user_icq) );
871
+		}
872
+		if ( !empty( $user->user_description ) ) {
873
+					update_user_meta( $user->ID, 'description', wp_slash($user->user_description) );
874
+		}
827 875
 
828 876
 		if ( isset( $user->user_idmode ) ):
829 877
 			$idmode = $user->user_idmode;
830
-			if ($idmode == 'nickname') $id = $user->user_nickname;
831
-			if ($idmode == 'login') $id = $user->user_login;
832
-			if ($idmode == 'firstname') $id = $user->user_firstname;
833
-			if ($idmode == 'lastname') $id = $user->user_lastname;
834
-			if ($idmode == 'namefl') $id = $user->user_firstname.' '.$user->user_lastname;
835
-			if ($idmode == 'namelf') $id = $user->user_lastname.' '.$user->user_firstname;
836
-			if (!$idmode) $id = $user->user_nickname;
878
+			if ($idmode == 'nickname') {
879
+				$id = $user->user_nickname;
880
+			}
881
+			if ($idmode == 'login') {
882
+				$id = $user->user_login;
883
+			}
884
+			if ($idmode == 'firstname') {
885
+				$id = $user->user_firstname;
886
+			}
887
+			if ($idmode == 'lastname') {
888
+				$id = $user->user_lastname;
889
+			}
890
+			if ($idmode == 'namefl') {
891
+				$id = $user->user_firstname.' '.$user->user_lastname;
892
+			}
893
+			if ($idmode == 'namelf') {
894
+				$id = $user->user_lastname.' '.$user->user_firstname;
895
+			}
896
+			if (!$idmode) {
897
+				$id = $user->user_nickname;
898
+			}
837 899
 			$wpdb->update( $wpdb->users, array('display_name' => $id), array('ID' => $user->ID) );
838 900
 		endif;
839 901
 
@@ -848,15 +910,17 @@  discard block
 block discarded – undo
848 910
 	endforeach;
849 911
 	$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' );
850 912
 	$wpdb->hide_errors();
851
-	foreach ( $old_user_fields as $old )
852
-		$wpdb->query("ALTER TABLE $wpdb->users DROP $old");
913
+	foreach ( $old_user_fields as $old ) {
914
+			$wpdb->query("ALTER TABLE $wpdb->users DROP $old");
915
+	}
853 916
 	$wpdb->show_errors();
854 917
 
855 918
 	// Populate comment_count field of posts table.
856 919
 	$comments = $wpdb->get_results( "SELECT comment_post_ID, COUNT(*) as c FROM $wpdb->comments WHERE comment_approved = '1' GROUP BY comment_post_ID" );
857
-	if ( is_array( $comments ) )
858
-		foreach ($comments as $comment)
920
+	if ( is_array( $comments ) ) {
921
+			foreach ($comments as $comment)
859 922
 			$wpdb->update( $wpdb->posts, array('comment_count' => $comment->c), array('ID' => $comment->comment_post_ID) );
923
+	}
860 924
 
861 925
 	/*
862 926
 	 * Some alpha versions used a post status of object instead of attachment
@@ -871,8 +935,9 @@  discard block
 block discarded – undo
871 935
 										 array( 'ID' => $object->ID ) );
872 936
 
873 937
 			$meta = get_post_meta($object->ID, 'imagedata', true);
874
-			if ( ! empty($meta['file']) )
875
-				update_attached_file( $object->ID, $meta['file'] );
938
+			if ( ! empty($meta['file']) ) {
939
+							update_attached_file( $object->ID, $meta['file'] );
940
+			}
876 941
 		}
877 942
 	}
878 943
 }
@@ -893,8 +958,10 @@  discard block
 block discarded – undo
893 958
 		// Update status and type.
894 959
 		$posts = $wpdb->get_results("SELECT ID, post_status FROM $wpdb->posts");
895 960
 
896
-		if ( ! empty($posts) ) foreach ($posts as $post) {
961
+		if ( ! empty($posts) ) {
962
+			foreach ($posts as $post) {
897 963
 			$status = $post->post_status;
964
+		}
898 965
 			$type = 'post';
899 966
 
900 967
 			if ( 'static' == $status ) {
@@ -919,9 +986,10 @@  discard block
 block discarded – undo
919 986
 		$wpdb->query ("UPDATE $wpdb->posts SET post_status = 'future' WHERE post_status = 'publish' AND post_date_gmt > '$now'");
920 987
 
921 988
 		$posts = $wpdb->get_results("SELECT ID, post_date FROM $wpdb->posts WHERE post_status ='future'");
922
-		if ( !empty($posts) )
923
-			foreach ( $posts as $post )
989
+		if ( !empty($posts) ) {
990
+					foreach ( $posts as $post )
924 991
 				wp_schedule_single_event(mysql2date('U', $post->post_date, false), 'publish_future_post', array($post->ID));
992
+		}
925 993
 	}
926 994
 }
927 995
 
@@ -1007,19 +1075,22 @@  discard block
 block discarded – undo
1007 1075
 	}
1008 1076
 
1009 1077
 	$select = 'post_id, category_id';
1010
-	if ( $have_tags )
1011
-		$select .= ', rel_type';
1078
+	if ( $have_tags ) {
1079
+			$select .= ', rel_type';
1080
+	}
1012 1081
 
1013 1082
 	$posts = $wpdb->get_results("SELECT $select FROM $wpdb->post2cat GROUP BY post_id, category_id");
1014 1083
 	foreach ( $posts as $post ) {
1015 1084
 		$post_id = (int) $post->post_id;
1016 1085
 		$term_id = (int) $post->category_id;
1017 1086
 		$taxonomy = 'category';
1018
-		if ( !empty($post->rel_type) && 'tag' == $post->rel_type)
1019
-			$taxonomy = 'tag';
1087
+		if ( !empty($post->rel_type) && 'tag' == $post->rel_type) {
1088
+					$taxonomy = 'tag';
1089
+		}
1020 1090
 		$tt_id = $tt_ids[$term_id][$taxonomy];
1021
-		if ( empty($tt_id) )
1022
-			continue;
1091
+		if ( empty($tt_id) ) {
1092
+					continue;
1093
+		}
1023 1094
 
1024 1095
 		$wpdb->insert( $wpdb->term_relationships, array('object_id' => $post_id, 'term_taxonomy_id' => $tt_id) );
1025 1096
 	}
@@ -1061,15 +1132,19 @@  discard block
 block discarded – undo
1061 1132
 
1062 1133
 		// Associate links to cats.
1063 1134
 		$links = $wpdb->get_results("SELECT link_id, link_category FROM $wpdb->links");
1064
-		if ( !empty($links) ) foreach ( $links as $link ) {
1135
+		if ( !empty($links) ) {
1136
+			foreach ( $links as $link ) {
1065 1137
 			if ( 0 == $link->link_category )
1066 1138
 				continue;
1067
-			if ( ! isset($link_cat_id_map[$link->link_category]) )
1068
-				continue;
1139
+		}
1140
+			if ( ! isset($link_cat_id_map[$link->link_category]) ) {
1141
+							continue;
1142
+			}
1069 1143
 			$term_id = $link_cat_id_map[$link->link_category];
1070 1144
 			$tt_id = $tt_ids[$term_id];
1071
-			if ( empty($tt_id) )
1072
-				continue;
1145
+			if ( empty($tt_id) ) {
1146
+							continue;
1147
+			}
1073 1148
 
1074 1149
 			$wpdb->insert( $wpdb->term_relationships, array('object_id' => $link->link_id, 'term_taxonomy_id' => $tt_id) );
1075 1150
 		}
@@ -1083,8 +1158,9 @@  discard block
 block discarded – undo
1083 1158
 			$term_id = (int) $link->category_id;
1084 1159
 			$taxonomy = 'link_category';
1085 1160
 			$tt_id = $tt_ids[$term_id][$taxonomy];
1086
-			if ( empty($tt_id) )
1087
-				continue;
1161
+			if ( empty($tt_id) ) {
1162
+							continue;
1163
+			}
1088 1164
 			$wpdb->insert( $wpdb->term_relationships, array('object_id' => $link_id, 'term_taxonomy_id' => $tt_id) );
1089 1165
 		}
1090 1166
 	}
@@ -1097,10 +1173,11 @@  discard block
 block discarded – undo
1097 1173
 	// Recalculate all counts
1098 1174
 	$terms = $wpdb->get_results("SELECT term_taxonomy_id, taxonomy FROM $wpdb->term_taxonomy");
1099 1175
 	foreach ( (array) $terms as $term ) {
1100
-		if ( ('post_tag' == $term->taxonomy) || ('category' == $term->taxonomy) )
1101
-			$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) );
1102
-		else
1103
-			$count = $wpdb->get_var( $wpdb->prepare("SELECT COUNT(*) FROM $wpdb->term_relationships WHERE term_taxonomy_id = %d", $term->term_taxonomy_id) );
1176
+		if ( ('post_tag' == $term->taxonomy) || ('category' == $term->taxonomy) ) {
1177
+					$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) );
1178
+		} else {
1179
+					$count = $wpdb->get_var( $wpdb->prepare("SELECT COUNT(*) FROM $wpdb->term_relationships WHERE term_taxonomy_id = %d", $term->term_taxonomy_id) );
1180
+		}
1104 1181
 		$wpdb->update( $wpdb->term_taxonomy, array('count' => $count), array('term_taxonomy_id' => $term->term_taxonomy_id) );
1105 1182
 	}
1106 1183
 }
@@ -1117,8 +1194,9 @@  discard block
 block discarded – undo
1117 1194
 	global $wpdb;
1118 1195
 	$old_options_fields = array( 'option_can_override', 'option_type', 'option_width', 'option_height', 'option_description', 'option_admin_level' );
1119 1196
 	$wpdb->hide_errors();
1120
-	foreach ( $old_options_fields as $old )
1121
-		$wpdb->query("ALTER TABLE $wpdb->options DROP $old");
1197
+	foreach ( $old_options_fields as $old ) {
1198
+			$wpdb->query("ALTER TABLE $wpdb->options DROP $old");
1199
+	}
1122 1200
 	$wpdb->show_errors();
1123 1201
 }
1124 1202
 
@@ -1193,9 +1271,10 @@  discard block
 block discarded – undo
1193 1271
 function upgrade_260() {
1194 1272
 	global $wp_current_db_version;
1195 1273
 
1196
-	if ( $wp_current_db_version < 8000 )
1197
-		populate_roles_260();
1198
-}
1274
+	if ( $wp_current_db_version < 8000 ) {
1275
+			populate_roles_260();
1276
+	}
1277
+	}
1199 1278
 
1200 1279
 /**
1201 1280
  * Execute changes made in WordPress 2.7.
@@ -1209,13 +1288,15 @@  discard block
 block discarded – undo
1209 1288
 function upgrade_270() {
1210 1289
 	global $wpdb, $wp_current_db_version;
1211 1290
 
1212
-	if ( $wp_current_db_version < 8980 )
1213
-		populate_roles_270();
1291
+	if ( $wp_current_db_version < 8980 ) {
1292
+			populate_roles_270();
1293
+	}
1214 1294
 
1215 1295
 	// Update post_date for unpublished posts with empty timestamp
1216
-	if ( $wp_current_db_version < 8921 )
1217
-		$wpdb->query( "UPDATE $wpdb->posts SET post_date = post_modified WHERE post_date = '0000-00-00 00:00:00'" );
1218
-}
1296
+	if ( $wp_current_db_version < 8921 ) {
1297
+			$wpdb->query( "UPDATE $wpdb->posts SET post_date = post_modified WHERE post_date = '0000-00-00 00:00:00'" );
1298
+	}
1299
+	}
1219 1300
 
1220 1301
 /**
1221 1302
  * Execute changes made in WordPress 2.8.
@@ -1229,15 +1310,17 @@  discard block
 block discarded – undo
1229 1310
 function upgrade_280() {
1230 1311
 	global $wp_current_db_version, $wpdb;
1231 1312
 
1232
-	if ( $wp_current_db_version < 10360 )
1233
-		populate_roles_280();
1313
+	if ( $wp_current_db_version < 10360 ) {
1314
+			populate_roles_280();
1315
+	}
1234 1316
 	if ( is_multisite() ) {
1235 1317
 		$start = 0;
1236 1318
 		while( $rows = $wpdb->get_results( "SELECT option_name, option_value FROM $wpdb->options ORDER BY option_id LIMIT $start, 20" ) ) {
1237 1319
 			foreach ( $rows as $row ) {
1238 1320
 				$value = $row->option_value;
1239
-				if ( !@unserialize( $value ) )
1240
-					$value = stripslashes( $value );
1321
+				if ( !@unserialize( $value ) ) {
1322
+									$value = stripslashes( $value );
1323
+				}
1241 1324
 				if ( $value !== $row->option_value ) {
1242 1325
 					update_option( $row->option_name, $value );
1243 1326
 				}
@@ -1280,11 +1363,13 @@  discard block
 block discarded – undo
1280 1363
 function upgrade_300() {
1281 1364
 	global $wp_current_db_version, $wpdb;
1282 1365
 
1283
-	if ( $wp_current_db_version < 15093 )
1284
-		populate_roles_300();
1366
+	if ( $wp_current_db_version < 15093 ) {
1367
+			populate_roles_300();
1368
+	}
1285 1369
 
1286
-	if ( $wp_current_db_version < 14139 && is_multisite() && is_main_site() && ! defined( 'MULTISITE' ) && get_site_option( 'siteurl' ) === false )
1287
-		add_site_option( 'siteurl', '' );
1370
+	if ( $wp_current_db_version < 14139 && is_multisite() && is_main_site() && ! defined( 'MULTISITE' ) && get_site_option( 'siteurl' ) === false ) {
1371
+			add_site_option( 'siteurl', '' );
1372
+	}
1288 1373
 
1289 1374
 	// 3.0 screen options key name changes.
1290 1375
 	if ( wp_should_upgrade_global_tables() ) {
@@ -1332,23 +1417,26 @@  discard block
 block discarded – undo
1332 1417
 		$wpdb->query( "DELETE FROM $wpdb->usermeta WHERE meta_key IN ('show_admin_bar_admin', 'plugins_last_view')" );
1333 1418
 	}
1334 1419
 
1335
-	if ( $wp_current_db_version >= 11548 )
1336
-		return;
1420
+	if ( $wp_current_db_version >= 11548 ) {
1421
+			return;
1422
+	}
1337 1423
 
1338 1424
 	$sidebars_widgets = get_option( 'sidebars_widgets', array() );
1339 1425
 	$_sidebars_widgets = array();
1340 1426
 
1341
-	if ( isset($sidebars_widgets['wp_inactive_widgets']) || empty($sidebars_widgets) )
1342
-		$sidebars_widgets['array_version'] = 3;
1343
-	elseif ( !isset($sidebars_widgets['array_version']) )
1344
-		$sidebars_widgets['array_version'] = 1;
1427
+	if ( isset($sidebars_widgets['wp_inactive_widgets']) || empty($sidebars_widgets) ) {
1428
+			$sidebars_widgets['array_version'] = 3;
1429
+	} elseif ( !isset($sidebars_widgets['array_version']) ) {
1430
+			$sidebars_widgets['array_version'] = 1;
1431
+	}
1345 1432
 
1346 1433
 	switch ( $sidebars_widgets['array_version'] ) {
1347 1434
 		case 1 :
1348
-			foreach ( (array) $sidebars_widgets as $index => $sidebar )
1349
-			if ( is_array($sidebar) )
1435
+			foreach ( (array) $sidebars_widgets as $index => $sidebar ) {
1436
+						if ( is_array($sidebar) )
1350 1437
 			foreach ( (array) $sidebar as $i => $name ) {
1351 1438
 				$id = strtolower($name);
1439
+			}
1352 1440
 				if ( isset($wp_registered_widgets[$id]) ) {
1353 1441
 					$_sidebars_widgets[$index][$i] = $id;
1354 1442
 					continue;
@@ -1373,8 +1461,9 @@  discard block
 block discarded – undo
1373 1461
 					}
1374 1462
 				}
1375 1463
 
1376
-				if ( $found )
1377
-					continue;
1464
+				if ( $found ) {
1465
+									continue;
1466
+				}
1378 1467
 
1379 1468
 				unset($_sidebars_widgets[$index][$i]);
1380 1469
 			}
@@ -1438,14 +1527,17 @@  discard block
 block discarded – undo
1438 1527
 function upgrade_350() {
1439 1528
 	global $wp_current_db_version, $wpdb;
1440 1529
 
1441
-	if ( $wp_current_db_version < 22006 && $wpdb->get_var( "SELECT link_id FROM $wpdb->links LIMIT 1" ) )
1442
-		update_option( 'link_manager_enabled', 1 ); // Previously set to 0 by populate_options()
1530
+	if ( $wp_current_db_version < 22006 && $wpdb->get_var( "SELECT link_id FROM $wpdb->links LIMIT 1" ) ) {
1531
+			update_option( 'link_manager_enabled', 1 );
1532
+	}
1533
+	// Previously set to 0 by populate_options()
1443 1534
 
1444 1535
 	if ( $wp_current_db_version < 21811 && wp_should_upgrade_global_tables() ) {
1445 1536
 		$meta_keys = array();
1446 1537
 		foreach ( array_merge( get_post_types(), get_taxonomies() ) as $name ) {
1447
-			if ( false !== strpos( $name, '-' ) )
1448
-			$meta_keys[] = 'edit_' . str_replace( '-', '_', $name ) . '_per_page';
1538
+			if ( false !== strpos( $name, '-' ) ) {
1539
+						$meta_keys[] = 'edit_' . str_replace( '-', '_', $name ) . '_per_page';
1540
+			}
1449 1541
 		}
1450 1542
 		if ( $meta_keys ) {
1451 1543
 			$meta_keys = implode( "', '", $meta_keys );
@@ -1453,9 +1545,10 @@  discard block
 block discarded – undo
1453 1545
 		}
1454 1546
 	}
1455 1547
 
1456
-	if ( $wp_current_db_version < 22422 && $term = get_term_by( 'slug', 'post-format-standard', 'post_format' ) )
1457
-		wp_delete_term( $term->term_id, 'post_format' );
1458
-}
1548
+	if ( $wp_current_db_version < 22422 && $term = get_term_by( 'slug', 'post-format-standard', 'post_format' ) ) {
1549
+			wp_delete_term( $term->term_id, 'post_format' );
1550
+	}
1551
+	}
1459 1552
 
1460 1553
 /**
1461 1554
  * Execute changes made in WordPress 3.7.
@@ -1467,9 +1560,10 @@  discard block
 block discarded – undo
1467 1560
  */
1468 1561
 function upgrade_370() {
1469 1562
 	global $wp_current_db_version;
1470
-	if ( $wp_current_db_version < 25824 )
1471
-		wp_clear_scheduled_hook( 'wp_auto_updates_maybe_update' );
1472
-}
1563
+	if ( $wp_current_db_version < 25824 ) {
1564
+			wp_clear_scheduled_hook( 'wp_auto_updates_maybe_update' );
1565
+	}
1566
+	}
1473 1567
 
1474 1568
 /**
1475 1569
  * Execute changes made in WordPress 3.7.2.
@@ -1482,9 +1576,10 @@  discard block
 block discarded – undo
1482 1576
  */
1483 1577
 function upgrade_372() {
1484 1578
 	global $wp_current_db_version;
1485
-	if ( $wp_current_db_version < 26148 )
1486
-		wp_clear_scheduled_hook( 'wp_maybe_auto_update' );
1487
-}
1579
+	if ( $wp_current_db_version < 26148 ) {
1580
+			wp_clear_scheduled_hook( 'wp_maybe_auto_update' );
1581
+	}
1582
+	}
1488 1583
 
1489 1584
 /**
1490 1585
  * Execute changes made in WordPress 3.8.0.
@@ -1719,10 +1814,11 @@  discard block
 block discarded – undo
1719 1814
 		$wpmu_sitewide_plugins = get_site_option( 'wpmu_sitewide_plugins' );
1720 1815
 		$active_sitewide_plugins = get_site_option( 'active_sitewide_plugins' );
1721 1816
 		if ( $wpmu_sitewide_plugins ) {
1722
-			if ( !$active_sitewide_plugins )
1723
-				$sitewide_plugins = (array) $wpmu_sitewide_plugins;
1724
-			else
1725
-				$sitewide_plugins = array_merge( (array) $active_sitewide_plugins, (array) $wpmu_sitewide_plugins );
1817
+			if ( !$active_sitewide_plugins ) {
1818
+							$sitewide_plugins = (array) $wpmu_sitewide_plugins;
1819
+			} else {
1820
+							$sitewide_plugins = array_merge( (array) $active_sitewide_plugins, (array) $wpmu_sitewide_plugins );
1821
+			}
1726 1822
 
1727 1823
 			update_site_option( 'active_sitewide_plugins', $sitewide_plugins );
1728 1824
 		}
@@ -1733,8 +1829,9 @@  discard block
 block discarded – undo
1733 1829
 		while( $rows = $wpdb->get_results( "SELECT meta_key, meta_value FROM {$wpdb->sitemeta} ORDER BY meta_id LIMIT $start, 20" ) ) {
1734 1830
 			foreach ( $rows as $row ) {
1735 1831
 				$value = $row->meta_value;
1736
-				if ( !@unserialize( $value ) )
1737
-					$value = stripslashes( $value );
1832
+				if ( !@unserialize( $value ) ) {
1833
+									$value = stripslashes( $value );
1834
+				}
1738 1835
 				if ( $value !== $row->meta_value ) {
1739 1836
 					update_site_option( $row->meta_key, $value );
1740 1837
 				}
@@ -1744,16 +1841,19 @@  discard block
 block discarded – undo
1744 1841
 	}
1745 1842
 
1746 1843
 	// 3.0
1747
-	if ( $wp_current_db_version < 13576 )
1748
-		update_site_option( 'global_terms_enabled', '1' );
1844
+	if ( $wp_current_db_version < 13576 ) {
1845
+			update_site_option( 'global_terms_enabled', '1' );
1846
+	}
1749 1847
 
1750 1848
 	// 3.3
1751
-	if ( $wp_current_db_version < 19390 )
1752
-		update_site_option( 'initial_db_version', $wp_current_db_version );
1849
+	if ( $wp_current_db_version < 19390 ) {
1850
+			update_site_option( 'initial_db_version', $wp_current_db_version );
1851
+	}
1753 1852
 
1754 1853
 	if ( $wp_current_db_version < 19470 ) {
1755
-		if ( false === get_site_option( 'active_sitewide_plugins' ) )
1756
-			update_site_option( 'active_sitewide_plugins', array() );
1854
+		if ( false === get_site_option( 'active_sitewide_plugins' ) ) {
1855
+					update_site_option( 'active_sitewide_plugins', array() );
1856
+		}
1757 1857
 	}
1758 1858
 
1759 1859
 	// 3.4
@@ -1765,8 +1865,9 @@  discard block
 block discarded – undo
1765 1865
 			$converted = array();
1766 1866
 			$themes = wp_get_themes();
1767 1867
 			foreach ( $themes as $stylesheet => $theme_data ) {
1768
-				if ( isset( $allowed_themes[ $theme_data->get('Name') ] ) )
1769
-					$converted[ $stylesheet ] = true;
1868
+				if ( isset( $allowed_themes[ $theme_data->get('Name') ] ) ) {
1869
+									$converted[ $stylesheet ] = true;
1870
+				}
1770 1871
 			}
1771 1872
 			update_site_option( 'allowedthemes', $converted );
1772 1873
 			delete_site_option( 'allowed_themes' );
@@ -1774,8 +1875,9 @@  discard block
 block discarded – undo
1774 1875
 	}
1775 1876
 
1776 1877
 	// 3.5
1777
-	if ( $wp_current_db_version < 21823 )
1778
-		update_site_option( 'ms_files_rewriting', '1' );
1878
+	if ( $wp_current_db_version < 21823 ) {
1879
+			update_site_option( 'ms_files_rewriting', '1' );
1880
+	}
1779 1881
 
1780 1882
 	// 3.5.2
1781 1883
 	if ( $wp_current_db_version < 24448 ) {
@@ -2006,8 +2108,9 @@  discard block
 block discarded – undo
2006 2108
 	$all_options = new stdClass;
2007 2109
 	if ( $options = $wpdb->get_results( "SELECT option_name, option_value FROM $wpdb->options" ) ) {
2008 2110
 		foreach ( $options as $option ) {
2009
-			if ( 'siteurl' == $option->option_name || 'home' == $option->option_name || 'category_base' == $option->option_name )
2010
-				$option->option_value = untrailingslashit( $option->option_value );
2111
+			if ( 'siteurl' == $option->option_name || 'home' == $option->option_name || 'category_base' == $option->option_name ) {
2112
+							$option->option_value = untrailingslashit( $option->option_value );
2113
+			}
2011 2114
 			$all_options->{$option->option_name} = stripslashes( $option->option_value );
2012 2115
 		}
2013 2116
 	}
@@ -2029,19 +2132,23 @@  discard block
 block discarded – undo
2029 2132
 function __get_option($setting) {
2030 2133
 	global $wpdb;
2031 2134
 
2032
-	if ( $setting == 'home' && defined( 'WP_HOME' ) )
2033
-		return untrailingslashit( WP_HOME );
2135
+	if ( $setting == 'home' && defined( 'WP_HOME' ) ) {
2136
+			return untrailingslashit( WP_HOME );
2137
+	}
2034 2138
 
2035
-	if ( $setting == 'siteurl' && defined( 'WP_SITEURL' ) )
2036
-		return untrailingslashit( WP_SITEURL );
2139
+	if ( $setting == 'siteurl' && defined( 'WP_SITEURL' ) ) {
2140
+			return untrailingslashit( WP_SITEURL );
2141
+	}
2037 2142
 
2038 2143
 	$option = $wpdb->get_var( $wpdb->prepare("SELECT option_value FROM $wpdb->options WHERE option_name = %s", $setting ) );
2039 2144
 
2040
-	if ( 'home' == $setting && '' == $option )
2041
-		return __get_option( 'siteurl' );
2145
+	if ( 'home' == $setting && '' == $option ) {
2146
+			return __get_option( 'siteurl' );
2147
+	}
2042 2148
 
2043
-	if ( 'siteurl' == $setting || 'home' == $setting || 'category_base' == $setting || 'tag_base' == $setting )
2044
-		$option = untrailingslashit( $option );
2149
+	if ( 'siteurl' == $setting || 'home' == $setting || 'category_base' == $setting || 'tag_base' == $setting ) {
2150
+			$option = untrailingslashit( $option );
2151
+	}
2045 2152
 
2046 2153
 	return maybe_unserialize( $option );
2047 2154
 }
@@ -2094,8 +2201,9 @@  discard block
 block discarded – undo
2094 2201
 function dbDelta( $queries = '', $execute = true ) {
2095 2202
 	global $wpdb;
2096 2203
 
2097
-	if ( in_array( $queries, array( '', 'all', 'blog', 'global', 'ms_global' ), true ) )
2098
-	    $queries = wp_get_db_schema( $queries );
2204
+	if ( in_array( $queries, array( '', 'all', 'blog', 'global', 'ms_global' ), true ) ) {
2205
+		    $queries = wp_get_db_schema( $queries );
2206
+	}
2099 2207
 
2100 2208
 	// Separate individual queries into an array
2101 2209
 	if ( !is_array($queries) ) {
@@ -2167,8 +2275,9 @@  discard block
 block discarded – undo
2167 2275
 		$tablefields = $wpdb->get_results("DESCRIBE {$table};");
2168 2276
 		$wpdb->suppress_errors( $suppress );
2169 2277
 
2170
-		if ( ! $tablefields )
2171
-			continue;
2278
+		if ( ! $tablefields ) {
2279
+					continue;
2280
+		}
2172 2281
 
2173 2282
 		// Clear the field and index arrays.
2174 2283
 		$cfields = $indices = array();
@@ -2292,7 +2401,9 @@  discard block
 block discarded – undo
2292 2401
 
2293 2402
 				// For each column in the index.
2294 2403
 				foreach ($index_data['columns'] as $column_data) {
2295
-					if ($index_columns != '') $index_columns .= ',';
2404
+					if ($index_columns != '') {
2405
+						$index_columns .= ',';
2406
+					}
2296 2407
 
2297 2408
 					// Add the field to the column list string.
2298 2409
 					$index_columns .= $column_data['fieldname'];
@@ -2361,7 +2472,9 @@  discard block
 block discarded – undo
2361 2472
 function make_db_current( $tables = 'all' ) {
2362 2473
 	$alterations = dbDelta( $tables );
2363 2474
 	echo "<ol>\n";
2364
-	foreach ($alterations as $alteration) echo "<li>$alteration</li>\n";
2475
+	foreach ($alterations as $alteration) {
2476
+		echo "<li>$alteration</li>\n";
2477
+	}
2365 2478
 	echo "</ol>\n";
2366 2479
 }
2367 2480
 
@@ -2396,8 +2509,9 @@  discard block
 block discarded – undo
2396 2509
 	$home_path = get_home_path();
2397 2510
 	$site_dir = WP_CONTENT_DIR . "/themes/$template";
2398 2511
 
2399
-	if (! file_exists("$home_path/index.php"))
2400
-		return false;
2512
+	if (! file_exists("$home_path/index.php")) {
2513
+			return false;
2514
+	}
2401 2515
 
2402 2516
 	/*
2403 2517
 	 * Copy files from the old locations to the site theme.
@@ -2406,25 +2520,28 @@  discard block
 block discarded – undo
2406 2520
 	$files = array('index.php' => 'index.php', 'wp-layout.css' => 'style.css', 'wp-comments.php' => 'comments.php', 'wp-comments-popup.php' => 'comments-popup.php');
2407 2521
 
2408 2522
 	foreach ($files as $oldfile => $newfile) {
2409
-		if ($oldfile == 'index.php')
2410
-			$oldpath = $home_path;
2411
-		else
2412
-			$oldpath = ABSPATH;
2523
+		if ($oldfile == 'index.php') {
2524
+					$oldpath = $home_path;
2525
+		} else {
2526
+					$oldpath = ABSPATH;
2527
+		}
2413 2528
 
2414 2529
 		// Check to make sure it's not a new index.
2415 2530
 		if ($oldfile == 'index.php') {
2416 2531
 			$index = implode('', file("$oldpath/$oldfile"));
2417 2532
 			if (strpos($index, 'WP_USE_THEMES') !== false) {
2418
-				if (! @copy(WP_CONTENT_DIR . '/themes/' . WP_DEFAULT_THEME . '/index.php', "$site_dir/$newfile"))
2419
-					return false;
2533
+				if (! @copy(WP_CONTENT_DIR . '/themes/' . WP_DEFAULT_THEME . '/index.php', "$site_dir/$newfile")) {
2534
+									return false;
2535
+				}
2420 2536
 
2421 2537
 				// Don't copy anything.
2422 2538
 				continue;
2423 2539
 			}
2424 2540
 		}
2425 2541
 
2426
-		if (! @copy("$oldpath/$oldfile", "$site_dir/$newfile"))
2427
-			return false;
2542
+		if (! @copy("$oldpath/$oldfile", "$site_dir/$newfile")) {
2543
+					return false;
2544
+		}
2428 2545
 
2429 2546
 		chmod("$site_dir/$newfile", 0777);
2430 2547
 
@@ -2434,8 +2551,9 @@  discard block
 block discarded – undo
2434 2551
 			$f = fopen("$site_dir/$newfile", 'w');
2435 2552
 
2436 2553
 			foreach ($lines as $line) {
2437
-				if (preg_match('/require.*wp-blog-header/', $line))
2438
-					$line = '//' . $line;
2554
+				if (preg_match('/require.*wp-blog-header/', $line)) {
2555
+									$line = '//' . $line;
2556
+				}
2439 2557
 
2440 2558
 				// Update stylesheet references.
2441 2559
 				$line = str_replace("<?php echo __get_option('siteurl'); ?>/wp-layout.css", "<?php bloginfo('stylesheet_url'); ?>", $line);
@@ -2485,10 +2603,12 @@  discard block
 block discarded – undo
2485 2603
 	$theme_dir = @ opendir($default_dir);
2486 2604
 	if ($theme_dir) {
2487 2605
 		while(($theme_file = readdir( $theme_dir )) !== false) {
2488
-			if (is_dir("$default_dir/$theme_file"))
2489
-				continue;
2490
-			if (! @copy("$default_dir/$theme_file", "$site_dir/$theme_file"))
2491
-				return;
2606
+			if (is_dir("$default_dir/$theme_file")) {
2607
+							continue;
2608
+			}
2609
+			if (! @copy("$default_dir/$theme_file", "$site_dir/$theme_file")) {
2610
+							return;
2611
+			}
2492 2612
 			chmod("$site_dir/$theme_file", 0777);
2493 2613
 		}
2494 2614
 	}
@@ -2500,11 +2620,17 @@  discard block
 block discarded – undo
2500 2620
 		$f = fopen("$site_dir/style.css", 'w');
2501 2621
 
2502 2622
 		foreach ($stylelines as $line) {
2503
-			if (strpos($line, 'Theme Name:') !== false) $line = 'Theme Name: ' . $theme_name;
2504
-			elseif (strpos($line, 'Theme URI:') !== false) $line = 'Theme URI: ' . __get_option('url');
2505
-			elseif (strpos($line, 'Description:') !== false) $line = 'Description: Your theme.';
2506
-			elseif (strpos($line, 'Version:') !== false) $line = 'Version: 1';
2507
-			elseif (strpos($line, 'Author:') !== false) $line = 'Author: You';
2623
+			if (strpos($line, 'Theme Name:') !== false) {
2624
+				$line = 'Theme Name: ' . $theme_name;
2625
+			} elseif (strpos($line, 'Theme URI:') !== false) {
2626
+				$line = 'Theme URI: ' . __get_option('url');
2627
+			} elseif (strpos($line, 'Description:') !== false) {
2628
+				$line = 'Description: Your theme.';
2629
+			} elseif (strpos($line, 'Version:') !== false) {
2630
+				$line = 'Version: 1';
2631
+			} elseif (strpos($line, 'Author:') !== false) {
2632
+				$line = 'Author: You';
2633
+			}
2508 2634
 			fwrite($f, $line . "\n");
2509 2635
 		}
2510 2636
 		fclose($f);
@@ -2519,10 +2645,12 @@  discard block
 block discarded – undo
2519 2645
 	$images_dir = @ opendir("$default_dir/images");
2520 2646
 	if ($images_dir) {
2521 2647
 		while(($image = readdir($images_dir)) !== false) {
2522
-			if (is_dir("$default_dir/images/$image"))
2523
-				continue;
2524
-			if (! @copy("$default_dir/images/$image", "$site_dir/images/$image"))
2525
-				return;
2648
+			if (is_dir("$default_dir/images/$image")) {
2649
+							continue;
2650
+			}
2651
+			if (! @copy("$default_dir/images/$image", "$site_dir/images/$image")) {
2652
+							return;
2653
+			}
2526 2654
 			chmod("$site_dir/images/$image", 0777);
2527 2655
 		}
2528 2656
 	}
@@ -2565,9 +2693,10 @@  discard block
 block discarded – undo
2565 2693
 			return false;
2566 2694
 		}
2567 2695
 	} else {
2568
-		if (! make_site_theme_from_default($theme_name, $template))
2569
-			// TODO: rm -rf the site theme directory.
2696
+		if (! make_site_theme_from_default($theme_name, $template)) {
2697
+					// TODO: rm -rf the site theme directory.
2570 2698
 			return false;
2699
+		}
2571 2700
 	}
2572 2701
 
2573 2702
 	// Make the new site theme active.
@@ -2618,9 +2747,10 @@  discard block
 block discarded – undo
2618 2747
 function wp_check_mysql_version() {
2619 2748
 	global $wpdb;
2620 2749
 	$result = $wpdb->check_database_version();
2621
-	if ( is_wp_error( $result ) )
2622
-		die( $result->get_error_message() );
2623
-}
2750
+	if ( is_wp_error( $result ) ) {
2751
+			die( $result->get_error_message() );
2752
+	}
2753
+	}
2624 2754
 
2625 2755
 /**
2626 2756
  * Disables the Automattic widgets plugin, which was merged into core.
@@ -2650,9 +2780,10 @@  discard block
 block discarded – undo
2650 2780
 function maybe_disable_link_manager() {
2651 2781
 	global $wp_current_db_version, $wpdb;
2652 2782
 
2653
-	if ( $wp_current_db_version >= 22006 && get_option( 'link_manager_enabled' ) && ! $wpdb->get_var( "SELECT link_id FROM $wpdb->links LIMIT 1" ) )
2654
-		update_option( 'link_manager_enabled', 0 );
2655
-}
2783
+	if ( $wp_current_db_version >= 22006 && get_option( 'link_manager_enabled' ) && ! $wpdb->get_var( "SELECT link_id FROM $wpdb->links LIMIT 1" ) ) {
2784
+			update_option( 'link_manager_enabled', 0 );
2785
+	}
2786
+	}
2656 2787
 
2657 2788
 /**
2658 2789
  * Runs before the schema is upgraded.
Please login to merge, or discard this patch.
src/wp-admin/includes/update.php 2 patches
Switch Indentation   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -199,15 +199,15 @@
 block discarded – undo
199 199
 		$cur->response = '';
200 200
 
201 201
 	switch ( $cur->response ) {
202
-	case 'development' :
203
-		return sprintf( __( 'You are using a development version (%1$s). Cool! Please <a href="%2$s">stay updated</a>.' ), get_bloginfo( 'version', 'display' ), network_admin_url( 'update-core.php' ) );
202
+		case 'development' :
203
+			return sprintf( __( 'You are using a development version (%1$s). Cool! Please <a href="%2$s">stay updated</a>.' ), get_bloginfo( 'version', 'display' ), network_admin_url( 'update-core.php' ) );
204 204
 
205
-	case 'upgrade' :
206
-		return '<strong><a href="' . network_admin_url( 'update-core.php' ) . '">' . sprintf( __( 'Get Version %s' ), $cur->current ) . '</a></strong>';
205
+		case 'upgrade' :
206
+			return '<strong><a href="' . network_admin_url( 'update-core.php' ) . '">' . sprintf( __( 'Get Version %s' ), $cur->current ) . '</a></strong>';
207 207
 
208
-	case 'latest' :
209
-	default :
210
-		return sprintf( __( 'Version %s' ), get_bloginfo( 'version', 'display' ) );
208
+		case 'latest' :
209
+		default :
210
+			return sprintf( __( 'Version %s' ), get_bloginfo( 'version', 'display' ) );
211 211
 	}
212 212
 }
213 213
 
Please login to merge, or discard this patch.
Spacing   +151 added lines, -151 removed lines patch added patch discarded remove patch
@@ -13,10 +13,10 @@  discard block
 block discarded – undo
13 13
  */
14 14
 function get_preferred_from_update_core() {
15 15
 	$updates = get_core_updates();
16
-	if ( ! is_array( $updates ) )
16
+	if ( ! is_array($updates))
17 17
 		return false;
18
-	if ( empty( $updates ) )
19
-		return (object) array( 'response' => 'latest' );
18
+	if (empty($updates))
19
+		return (object) array('response' => 'latest');
20 20
 	return $updates[0];
21 21
 }
22 22
 
@@ -27,31 +27,31 @@  discard block
 block discarded – undo
27 27
  * 	                     set $options['available'] to false to skip not-dismissed updates.
28 28
  * @return array|false Array of the update objects on success, false on failure.
29 29
  */
30
-function get_core_updates( $options = array() ) {
31
-	$options = array_merge( array( 'available' => true, 'dismissed' => false ), $options );
32
-	$dismissed = get_site_option( 'dismissed_update_core' );
30
+function get_core_updates($options = array()) {
31
+	$options = array_merge(array('available' => true, 'dismissed' => false), $options);
32
+	$dismissed = get_site_option('dismissed_update_core');
33 33
 
34
-	if ( ! is_array( $dismissed ) )
34
+	if ( ! is_array($dismissed))
35 35
 		$dismissed = array();
36 36
 
37
-	$from_api = get_site_transient( 'update_core' );
37
+	$from_api = get_site_transient('update_core');
38 38
 
39
-	if ( ! isset( $from_api->updates ) || ! is_array( $from_api->updates ) )
39
+	if ( ! isset($from_api->updates) || ! is_array($from_api->updates))
40 40
 		return false;
41 41
 
42 42
 	$updates = $from_api->updates;
43 43
 	$result = array();
44
-	foreach ( $updates as $update ) {
45
-		if ( $update->response == 'autoupdate' )
44
+	foreach ($updates as $update) {
45
+		if ($update->response == 'autoupdate')
46 46
 			continue;
47 47
 
48
-		if ( array_key_exists( $update->current . '|' . $update->locale, $dismissed ) ) {
49
-			if ( $options['dismissed'] ) {
48
+		if (array_key_exists($update->current.'|'.$update->locale, $dismissed)) {
49
+			if ($options['dismissed']) {
50 50
 				$update->dismissed = true;
51 51
 				$result[] = $update;
52 52
 			}
53 53
 		} else {
54
-			if ( $options['available'] ) {
54
+			if ($options['available']) {
55 55
 				$update->dismissed = false;
56 56
 				$result[] = $update;
57 57
 			}
@@ -70,22 +70,22 @@  discard block
 block discarded – undo
70 70
  * @return array|false False on failure, otherwise the core update offering.
71 71
  */
72 72
 function find_core_auto_update() {
73
-	$updates = get_site_transient( 'update_core' );
74
-	if ( ! $updates || empty( $updates->updates ) )
73
+	$updates = get_site_transient('update_core');
74
+	if ( ! $updates || empty($updates->updates))
75 75
 		return false;
76 76
 
77
-	include_once( ABSPATH . 'wp-admin/includes/class-wp-upgrader.php' );
77
+	include_once(ABSPATH.'wp-admin/includes/class-wp-upgrader.php');
78 78
 
79 79
 	$auto_update = false;
80 80
 	$upgrader = new WP_Automatic_Updater;
81
-	foreach ( $updates->updates as $update ) {
82
-		if ( 'autoupdate' != $update->response )
81
+	foreach ($updates->updates as $update) {
82
+		if ('autoupdate' != $update->response)
83 83
 			continue;
84 84
 
85
-		if ( ! $upgrader->should_update( 'core', $update, ABSPATH ) )
85
+		if ( ! $upgrader->should_update('core', $update, ABSPATH))
86 86
 			continue;
87 87
 
88
-		if ( ! $auto_update || version_compare( $update->current, $auto_update->current, '>' ) )
88
+		if ( ! $auto_update || version_compare($update->current, $auto_update->current, '>'))
89 89
 			$auto_update = $update;
90 90
 	}
91 91
 	return $auto_update;
@@ -100,29 +100,29 @@  discard block
 block discarded – undo
100 100
  * @param string $locale  Locale to query.
101 101
  * @return bool|array False on failure. An array of checksums on success.
102 102
  */
103
-function get_core_checksums( $version, $locale ) {
104
-	$url = $http_url = 'http://api.wordpress.org/core/checksums/1.0/?' . http_build_query( compact( 'version', 'locale' ), null, '&' );
103
+function get_core_checksums($version, $locale) {
104
+	$url = $http_url = 'http://api.wordpress.org/core/checksums/1.0/?'.http_build_query(compact('version', 'locale'), null, '&');
105 105
 
106
-	if ( $ssl = wp_http_supports( array( 'ssl' ) ) )
107
-		$url = set_url_scheme( $url, 'https' );
106
+	if ($ssl = wp_http_supports(array('ssl')))
107
+		$url = set_url_scheme($url, 'https');
108 108
 
109 109
 	$options = array(
110
-		'timeout' => ( ( defined('DOING_CRON') && DOING_CRON ) ? 30 : 3 ),
110
+		'timeout' => ((defined('DOING_CRON') && DOING_CRON) ? 30 : 3),
111 111
 	);
112 112
 
113
-	$response = wp_remote_get( $url, $options );
114
-	if ( $ssl && is_wp_error( $response ) ) {
115
-		trigger_error( __( 'An unexpected error occurred. Something may be wrong with WordPress.org or this server&#8217;s configuration. If you continue to have problems, please try the <a href="https://wordpress.org/support/">support forums</a>.' ) . ' ' . __( '(WordPress could not establish a secure connection to WordPress.org. Please contact your server administrator.)' ), headers_sent() || WP_DEBUG ? E_USER_WARNING : E_USER_NOTICE );
116
-		$response = wp_remote_get( $http_url, $options );
113
+	$response = wp_remote_get($url, $options);
114
+	if ($ssl && is_wp_error($response)) {
115
+		trigger_error(__('An unexpected error occurred. Something may be wrong with WordPress.org or this server&#8217;s configuration. If you continue to have problems, please try the <a href="https://wordpress.org/support/">support forums</a>.').' '.__('(WordPress could not establish a secure connection to WordPress.org. Please contact your server administrator.)'), headers_sent() || WP_DEBUG ? E_USER_WARNING : E_USER_NOTICE);
116
+		$response = wp_remote_get($http_url, $options);
117 117
 	}
118 118
 
119
-	if ( is_wp_error( $response ) || 200 != wp_remote_retrieve_response_code( $response ) )
119
+	if (is_wp_error($response) || 200 != wp_remote_retrieve_response_code($response))
120 120
 		return false;
121 121
 
122
-	$body = trim( wp_remote_retrieve_body( $response ) );
123
-	$body = json_decode( $body, true );
122
+	$body = trim(wp_remote_retrieve_body($response));
123
+	$body = json_decode($body, true);
124 124
 
125
-	if ( ! is_array( $body ) || ! isset( $body['checksums'] ) || ! is_array( $body['checksums'] ) )
125
+	if ( ! is_array($body) || ! isset($body['checksums']) || ! is_array($body['checksums']))
126 126
 		return false;
127 127
 
128 128
 	return $body['checksums'];
@@ -133,10 +133,10 @@  discard block
 block discarded – undo
133 133
  * @param object $update
134 134
  * @return bool
135 135
  */
136
-function dismiss_core_update( $update ) {
137
-	$dismissed = get_site_option( 'dismissed_update_core' );
138
-	$dismissed[ $update->current . '|' . $update->locale ] = true;
139
-	return update_site_option( 'dismissed_update_core', $dismissed );
136
+function dismiss_core_update($update) {
137
+	$dismissed = get_site_option('dismissed_update_core');
138
+	$dismissed[$update->current.'|'.$update->locale] = true;
139
+	return update_site_option('dismissed_update_core', $dismissed);
140 140
 }
141 141
 
142 142
 /**
@@ -145,15 +145,15 @@  discard block
 block discarded – undo
145 145
  * @param string $locale
146 146
  * @return bool
147 147
  */
148
-function undismiss_core_update( $version, $locale ) {
149
-	$dismissed = get_site_option( 'dismissed_update_core' );
150
-	$key = $version . '|' . $locale;
148
+function undismiss_core_update($version, $locale) {
149
+	$dismissed = get_site_option('dismissed_update_core');
150
+	$key = $version.'|'.$locale;
151 151
 
152
-	if ( ! isset( $dismissed[$key] ) )
152
+	if ( ! isset($dismissed[$key]))
153 153
 		return false;
154 154
 
155
-	unset( $dismissed[$key] );
156
-	return update_site_option( 'dismissed_update_core', $dismissed );
155
+	unset($dismissed[$key]);
156
+	return update_site_option('dismissed_update_core', $dismissed);
157 157
 }
158 158
 
159 159
 /**
@@ -162,15 +162,15 @@  discard block
 block discarded – undo
162 162
  * @param string $locale
163 163
  * @return object|false
164 164
  */
165
-function find_core_update( $version, $locale ) {
166
-	$from_api = get_site_transient( 'update_core' );
165
+function find_core_update($version, $locale) {
166
+	$from_api = get_site_transient('update_core');
167 167
 
168
-	if ( ! isset( $from_api->updates ) || ! is_array( $from_api->updates ) )
168
+	if ( ! isset($from_api->updates) || ! is_array($from_api->updates))
169 169
 		return false;
170 170
 
171 171
 	$updates = $from_api->updates;
172
-	foreach ( $updates as $update ) {
173
-		if ( $update->current == $version && $update->locale == $locale )
172
+	foreach ($updates as $update) {
173
+		if ($update->current == $version && $update->locale == $locale)
174 174
 			return $update;
175 175
 	}
176 176
 	return false;
@@ -181,33 +181,33 @@  discard block
 block discarded – undo
181 181
  * @param string $msg
182 182
  * @return string
183 183
  */
184
-function core_update_footer( $msg = '' ) {
185
-	if ( !current_user_can('update_core') )
186
-		return sprintf( __( 'Version %s' ), get_bloginfo( 'version', 'display' ) );
184
+function core_update_footer($msg = '') {
185
+	if ( ! current_user_can('update_core'))
186
+		return sprintf(__('Version %s'), get_bloginfo('version', 'display'));
187 187
 
188 188
 	$cur = get_preferred_from_update_core();
189
-	if ( ! is_object( $cur ) )
189
+	if ( ! is_object($cur))
190 190
 		$cur = new stdClass;
191 191
 
192
-	if ( ! isset( $cur->current ) )
192
+	if ( ! isset($cur->current))
193 193
 		$cur->current = '';
194 194
 
195
-	if ( ! isset( $cur->url ) )
195
+	if ( ! isset($cur->url))
196 196
 		$cur->url = '';
197 197
 
198
-	if ( ! isset( $cur->response ) )
198
+	if ( ! isset($cur->response))
199 199
 		$cur->response = '';
200 200
 
201
-	switch ( $cur->response ) {
201
+	switch ($cur->response) {
202 202
 	case 'development' :
203
-		return sprintf( __( 'You are using a development version (%1$s). Cool! Please <a href="%2$s">stay updated</a>.' ), get_bloginfo( 'version', 'display' ), network_admin_url( 'update-core.php' ) );
203
+		return sprintf(__('You are using a development version (%1$s). Cool! Please <a href="%2$s">stay updated</a>.'), get_bloginfo('version', 'display'), network_admin_url('update-core.php'));
204 204
 
205 205
 	case 'upgrade' :
206
-		return '<strong><a href="' . network_admin_url( 'update-core.php' ) . '">' . sprintf( __( 'Get Version %s' ), $cur->current ) . '</a></strong>';
206
+		return '<strong><a href="'.network_admin_url('update-core.php').'">'.sprintf(__('Get Version %s'), $cur->current).'</a></strong>';
207 207
 
208 208
 	case 'latest' :
209 209
 	default :
210
-		return sprintf( __( 'Version %s' ), get_bloginfo( 'version', 'display' ) );
210
+		return sprintf(__('Version %s'), get_bloginfo('version', 'display'));
211 211
 	}
212 212
 }
213 213
 
@@ -217,23 +217,23 @@  discard block
 block discarded – undo
217 217
  * @return false|void
218 218
  */
219 219
 function update_nag() {
220
-	if ( is_multisite() && !current_user_can('update_core') )
220
+	if (is_multisite() && ! current_user_can('update_core'))
221 221
 		return false;
222 222
 
223 223
 	global $pagenow;
224 224
 
225
-	if ( 'update-core.php' == $pagenow )
225
+	if ('update-core.php' == $pagenow)
226 226
 		return;
227 227
 
228 228
 	$cur = get_preferred_from_update_core();
229 229
 
230
-	if ( ! isset( $cur->response ) || $cur->response != 'upgrade' )
230
+	if ( ! isset($cur->response) || $cur->response != 'upgrade')
231 231
 		return false;
232 232
 
233
-	if ( current_user_can('update_core') ) {
234
-		$msg = sprintf( __( '<a href="https://codex.wordpress.org/Version_%1$s">WordPress %1$s</a> is available! <a href="%2$s" aria-label="Please update WordPress now">Please update now</a>.' ), $cur->current, network_admin_url( 'update-core.php' ) );
233
+	if (current_user_can('update_core')) {
234
+		$msg = sprintf(__('<a href="https://codex.wordpress.org/Version_%1$s">WordPress %1$s</a> is available! <a href="%2$s" aria-label="Please update WordPress now">Please update now</a>.'), $cur->current, network_admin_url('update-core.php'));
235 235
 	} else {
236
-		$msg = sprintf( __('<a href="https://codex.wordpress.org/Version_%1$s">WordPress %1$s</a> is available! Please notify the site administrator.'), $cur->current );
236
+		$msg = sprintf(__('<a href="https://codex.wordpress.org/Version_%1$s">WordPress %1$s</a> is available! Please notify the site administrator.'), $cur->current);
237 237
 	}
238 238
 	echo "<div class='update-nag'>$msg</div>";
239 239
 }
@@ -241,21 +241,21 @@  discard block
 block discarded – undo
241 241
 // Called directly from dashboard
242 242
 function update_right_now_message() {
243 243
 	$theme_name = wp_get_theme();
244
-	if ( current_user_can( 'switch_themes' ) ) {
245
-		$theme_name = sprintf( '<a href="themes.php">%1$s</a>', $theme_name );
244
+	if (current_user_can('switch_themes')) {
245
+		$theme_name = sprintf('<a href="themes.php">%1$s</a>', $theme_name);
246 246
 	}
247 247
 
248 248
 	$msg = '';
249 249
 
250
-	if ( current_user_can('update_core') ) {
250
+	if (current_user_can('update_core')) {
251 251
 		$cur = get_preferred_from_update_core();
252 252
 
253
-		if ( isset( $cur->response ) && $cur->response == 'upgrade' )
254
-			$msg .= '<a href="' . network_admin_url( 'update-core.php' ) . '" class="button" aria-describedby="wp-version">' . sprintf( __( 'Update to %s' ), $cur->current ? $cur->current : __( 'Latest' ) ) . '</a> ';
253
+		if (isset($cur->response) && $cur->response == 'upgrade')
254
+			$msg .= '<a href="'.network_admin_url('update-core.php').'" class="button" aria-describedby="wp-version">'.sprintf(__('Update to %s'), $cur->current ? $cur->current : __('Latest')).'</a> ';
255 255
 	}
256 256
 
257 257
 	/* translators: 1: version number, 2: theme name */
258
-	$content = __( 'WordPress %1$s running %2$s theme.' );
258
+	$content = __('WordPress %1$s running %2$s theme.');
259 259
 
260 260
 	/**
261 261
 	 * Filter the text displayed in the 'At a Glance' dashboard widget.
@@ -266,9 +266,9 @@  discard block
 block discarded – undo
266 266
 	 *
267 267
 	 * @param string $content Default text.
268 268
 	 */
269
-	$content = apply_filters( 'update_right_now_text', $content );
269
+	$content = apply_filters('update_right_now_text', $content);
270 270
 
271
-	$msg .= sprintf( '<span id="wp-version">' . $content . '</span>', get_bloginfo( 'version', 'display' ), $theme_name );
271
+	$msg .= sprintf('<span id="wp-version">'.$content.'</span>', get_bloginfo('version', 'display'), $theme_name);
272 272
 
273 273
 	echo "<p id='wp-version-message'>$msg</p>";
274 274
 }
@@ -281,11 +281,11 @@  discard block
 block discarded – undo
281 281
 function get_plugin_updates() {
282 282
 	$all_plugins = get_plugins();
283 283
 	$upgrade_plugins = array();
284
-	$current = get_site_transient( 'update_plugins' );
285
-	foreach ( (array)$all_plugins as $plugin_file => $plugin_data) {
286
-		if ( isset( $current->response[ $plugin_file ] ) ) {
287
-			$upgrade_plugins[ $plugin_file ] = (object) $plugin_data;
288
-			$upgrade_plugins[ $plugin_file ]->update = $current->response[ $plugin_file ];
284
+	$current = get_site_transient('update_plugins');
285
+	foreach ((array) $all_plugins as $plugin_file => $plugin_data) {
286
+		if (isset($current->response[$plugin_file])) {
287
+			$upgrade_plugins[$plugin_file] = (object) $plugin_data;
288
+			$upgrade_plugins[$plugin_file]->update = $current->response[$plugin_file];
289 289
 		}
290 290
 	}
291 291
 
@@ -296,14 +296,14 @@  discard block
 block discarded – undo
296 296
  * @since 2.9.0
297 297
  */
298 298
 function wp_plugin_update_rows() {
299
-	if ( !current_user_can('update_plugins' ) )
299
+	if ( ! current_user_can('update_plugins'))
300 300
 		return;
301 301
 
302
-	$plugins = get_site_transient( 'update_plugins' );
303
-	if ( isset($plugins->response) && is_array($plugins->response) ) {
304
-		$plugins = array_keys( $plugins->response );
305
-		foreach ( $plugins as $plugin_file ) {
306
-			add_action( "after_plugin_row_$plugin_file", 'wp_plugin_update_row', 10, 2 );
302
+	$plugins = get_site_transient('update_plugins');
303
+	if (isset($plugins->response) && is_array($plugins->response)) {
304
+		$plugins = array_keys($plugins->response);
305
+		foreach ($plugins as $plugin_file) {
306
+			add_action("after_plugin_row_$plugin_file", 'wp_plugin_update_row', 10, 2);
307 307
 		}
308 308
 	}
309 309
 }
@@ -314,58 +314,58 @@  discard block
 block discarded – undo
314 314
  * @param array  $plugin_data
315 315
  * @return false|void
316 316
  */
317
-function wp_plugin_update_row( $file, $plugin_data ) {
318
-	$current = get_site_transient( 'update_plugins' );
319
-	if ( !isset( $current->response[ $file ] ) )
317
+function wp_plugin_update_row($file, $plugin_data) {
318
+	$current = get_site_transient('update_plugins');
319
+	if ( ! isset($current->response[$file]))
320 320
 		return false;
321 321
 
322
-	$r = $current->response[ $file ];
322
+	$r = $current->response[$file];
323 323
 
324
-	$plugins_allowedtags = array('a' => array('href' => array(),'title' => array()),'abbr' => array('title' => array()),'acronym' => array('title' => array()),'code' => array(),'em' => array(),'strong' => array());
325
-	$plugin_name = wp_kses( $plugin_data['Name'], $plugins_allowedtags );
324
+	$plugins_allowedtags = array('a' => array('href' => array(), 'title' => array()), 'abbr' => array('title' => array()), 'acronym' => array('title' => array()), 'code' => array(), 'em' => array(), 'strong' => array());
325
+	$plugin_name = wp_kses($plugin_data['Name'], $plugins_allowedtags);
326 326
 
327
-	$details_url = self_admin_url('plugin-install.php?tab=plugin-information&plugin=' . $r->slug . '&section=changelog&TB_iframe=true&width=600&height=800');
327
+	$details_url = self_admin_url('plugin-install.php?tab=plugin-information&plugin='.$r->slug.'&section=changelog&TB_iframe=true&width=600&height=800');
328 328
 
329 329
 	$wp_list_table = _get_list_table('WP_Plugins_List_Table');
330 330
 
331
-	if ( is_network_admin() || !is_multisite() ) {
332
-		if ( is_network_admin() ) {
333
-			$active_class = is_plugin_active_for_network( $file ) ? ' active': '';
331
+	if (is_network_admin() || ! is_multisite()) {
332
+		if (is_network_admin()) {
333
+			$active_class = is_plugin_active_for_network($file) ? ' active' : '';
334 334
 		} else {
335
-			$active_class = is_plugin_active( $file ) ? ' active' : '';
335
+			$active_class = is_plugin_active($file) ? ' active' : '';
336 336
 		}
337 337
 
338
-		echo '<tr class="plugin-update-tr' . $active_class . '" id="' . esc_attr( $r->slug . '-update' ) . '" data-slug="' . esc_attr( $r->slug ) . '" data-plugin="' . esc_attr( $file ) . '"><td colspan="' . esc_attr( $wp_list_table->get_column_count() ) . '" class="plugin-update colspanchange"><div class="update-message">';
338
+		echo '<tr class="plugin-update-tr'.$active_class.'" id="'.esc_attr($r->slug.'-update').'" data-slug="'.esc_attr($r->slug).'" data-plugin="'.esc_attr($file).'"><td colspan="'.esc_attr($wp_list_table->get_column_count()).'" class="plugin-update colspanchange"><div class="update-message">';
339 339
 
340
-		if ( ! current_user_can( 'update_plugins' ) ) {
340
+		if ( ! current_user_can('update_plugins')) {
341 341
 			/* translators: 1: plugin name, 2: details URL, 3: accessibility text, 4: version number */
342
-			printf( __( 'There is a new version of %1$s available. <a href="%2$s" class="thickbox open-plugin-details-modal" aria-label="%3$s">View version %4$s details</a>.' ),
342
+			printf(__('There is a new version of %1$s available. <a href="%2$s" class="thickbox open-plugin-details-modal" aria-label="%3$s">View version %4$s details</a>.'),
343 343
 				$plugin_name,
344
-				esc_url( $details_url ),
344
+				esc_url($details_url),
345 345
 				/* translators: 1: plugin name, 2: version number */
346
-				esc_attr( sprintf( __( 'View %1$s version %2$s details' ), $plugin_name, $r->new_version ) ),
346
+				esc_attr(sprintf(__('View %1$s version %2$s details'), $plugin_name, $r->new_version)),
347 347
 				$r->new_version
348 348
 			);
349
-		} elseif ( empty( $r->package ) ) {
349
+		} elseif (empty($r->package)) {
350 350
 			/* translators: 1: plugin name, 2: details URL, 3: accessibility text, 4: version number */
351
-			printf( __( 'There is a new version of %1$s available. <a href="%2$s" class="thickbox open-plugin-details-modal" aria-label="%3$s">View version %4$s details</a>. <em>Automatic update is unavailable for this plugin.</em>' ),
351
+			printf(__('There is a new version of %1$s available. <a href="%2$s" class="thickbox open-plugin-details-modal" aria-label="%3$s">View version %4$s details</a>. <em>Automatic update is unavailable for this plugin.</em>'),
352 352
 				$plugin_name,
353
-				esc_url( $details_url ),
353
+				esc_url($details_url),
354 354
 				/* translators: 1: plugin name, 2: version number */
355
-				esc_attr( sprintf( __( 'View %1$s version %2$s details' ), $plugin_name, $r->new_version ) ),
355
+				esc_attr(sprintf(__('View %1$s version %2$s details'), $plugin_name, $r->new_version)),
356 356
 				$r->new_version
357 357
 			);
358 358
 		} else {
359 359
 			/* translators: 1: plugin name, 2: details URL, 3: accessibility text, 4: version number, 5: update URL, 6: accessibility text */
360
-			printf( __( 'There is a new version of %1$s available. <a href="%2$s" class="thickbox open-plugin-details-modal" aria-label="%3$s">View version %4$s details</a> or <a href="%5$s" class="update-link" aria-label="%6$s">update now</a>.' ),
360
+			printf(__('There is a new version of %1$s available. <a href="%2$s" class="thickbox open-plugin-details-modal" aria-label="%3$s">View version %4$s details</a> or <a href="%5$s" class="update-link" aria-label="%6$s">update now</a>.'),
361 361
 				$plugin_name,
362
-				esc_url( $details_url ),
362
+				esc_url($details_url),
363 363
 				/* translators: 1: plugin name, 2: version number */
364
-				esc_attr( sprintf( __( 'View %1$s version %2$s details' ), $plugin_name, $r->new_version ) ),
364
+				esc_attr(sprintf(__('View %1$s version %2$s details'), $plugin_name, $r->new_version)),
365 365
 				$r->new_version,
366
-				wp_nonce_url( self_admin_url( 'update.php?action=upgrade-plugin&plugin=' ) . $file, 'upgrade-plugin_' . $file ),
366
+				wp_nonce_url(self_admin_url('update.php?action=upgrade-plugin&plugin=').$file, 'upgrade-plugin_'.$file),
367 367
 				/* translators: %s: plugin name */
368
-				esc_attr( sprintf( __( 'Update %s now' ), $plugin_name ) )
368
+				esc_attr(sprintf(__('Update %s now'), $plugin_name))
369 369
 			);
370 370
 		}
371 371
 		/**
@@ -403,7 +403,7 @@  discard block
 block discarded – undo
403 403
 	 	 *     @type string $package      Plugin update package URL.
404 404
 	 	 * }
405 405
 		 */
406
-		do_action( "in_plugin_update_message-{$file}", $plugin_data, $r );
406
+		do_action("in_plugin_update_message-{$file}", $plugin_data, $r);
407 407
 
408 408
 		echo '</div></td></tr>';
409 409
 	}
@@ -416,13 +416,13 @@  discard block
 block discarded – undo
416 416
 function get_theme_updates() {
417 417
 	$current = get_site_transient('update_themes');
418 418
 
419
-	if ( ! isset( $current->response ) )
419
+	if ( ! isset($current->response))
420 420
 		return array();
421 421
 
422 422
 	$update_themes = array();
423
-	foreach ( $current->response as $stylesheet => $data ) {
424
-		$update_themes[ $stylesheet ] = wp_get_theme( $stylesheet );
425
-		$update_themes[ $stylesheet ]->update = $data;
423
+	foreach ($current->response as $stylesheet => $data) {
424
+		$update_themes[$stylesheet] = wp_get_theme($stylesheet);
425
+		$update_themes[$stylesheet]->update = $data;
426 426
 	}
427 427
 
428 428
 	return $update_themes;
@@ -432,15 +432,15 @@  discard block
 block discarded – undo
432 432
  * @since 3.1.0
433 433
  */
434 434
 function wp_theme_update_rows() {
435
-	if ( !current_user_can('update_themes' ) )
435
+	if ( ! current_user_can('update_themes'))
436 436
 		return;
437 437
 
438
-	$themes = get_site_transient( 'update_themes' );
439
-	if ( isset($themes->response) && is_array($themes->response) ) {
440
-		$themes = array_keys( $themes->response );
438
+	$themes = get_site_transient('update_themes');
439
+	if (isset($themes->response) && is_array($themes->response)) {
440
+		$themes = array_keys($themes->response);
441 441
 
442
-		foreach ( $themes as $theme ) {
443
-			add_action( "after_theme_row_$theme", 'wp_theme_update_row', 10, 2 );
442
+		foreach ($themes as $theme) {
443
+			add_action("after_theme_row_$theme", 'wp_theme_update_row', 10, 2);
444 444
 		}
445 445
 	}
446 446
 }
@@ -451,51 +451,51 @@  discard block
 block discarded – undo
451 451
  * @param WP_Theme $theme
452 452
  * @return false|void
453 453
  */
454
-function wp_theme_update_row( $theme_key, $theme ) {
455
-	$current = get_site_transient( 'update_themes' );
456
-	if ( !isset( $current->response[ $theme_key ] ) )
454
+function wp_theme_update_row($theme_key, $theme) {
455
+	$current = get_site_transient('update_themes');
456
+	if ( ! isset($current->response[$theme_key]))
457 457
 		return false;
458 458
 
459
-	$r = $current->response[ $theme_key ];
459
+	$r = $current->response[$theme_key];
460 460
 
461 461
 	$theme_name = $theme['Name'];
462 462
 
463
-	$details_url = add_query_arg( array( 'TB_iframe' => 'true', 'width' => 1024, 'height' => 800 ), $current->response[ $theme_key ]['url'] );
463
+	$details_url = add_query_arg(array('TB_iframe' => 'true', 'width' => 1024, 'height' => 800), $current->response[$theme_key]['url']);
464 464
 
465 465
 	$wp_list_table = _get_list_table('WP_MS_Themes_List_Table');
466 466
 
467
-	$active = $theme->is_allowed( 'network' ) ? ' active': '';
467
+	$active = $theme->is_allowed('network') ? ' active' : '';
468 468
 
469
-	echo '<tr class="plugin-update-tr' . $active . '" id="' . esc_attr( $theme->get_stylesheet() . '-update' ) . '" data-slug="' . esc_attr( $theme->get_stylesheet() ) . '"><td colspan="' . $wp_list_table->get_column_count() . '" class="plugin-update colspanchange"><div class="update-message">';
470
-	if ( ! current_user_can('update_themes') ) {
469
+	echo '<tr class="plugin-update-tr'.$active.'" id="'.esc_attr($theme->get_stylesheet().'-update').'" data-slug="'.esc_attr($theme->get_stylesheet()).'"><td colspan="'.$wp_list_table->get_column_count().'" class="plugin-update colspanchange"><div class="update-message">';
470
+	if ( ! current_user_can('update_themes')) {
471 471
 		/* translators: 1: theme name, 2: details URL, 3: accessibility text, 4: version number */
472
-		printf( __( 'There is a new version of %1$s available. <a href="%2$s" class="thickbox open-plugin-details-modal" aria-label="%3$s">View version %4$s details</a>.'),
472
+		printf(__('There is a new version of %1$s available. <a href="%2$s" class="thickbox open-plugin-details-modal" aria-label="%3$s">View version %4$s details</a>.'),
473 473
 			$theme_name,
474
-			esc_url( $details_url ),
474
+			esc_url($details_url),
475 475
 			/* translators: 1: theme name, 2: version number */
476
-			esc_attr( sprintf( __( 'View %1$s version %2$s details' ), $theme_name, $r['new_version'] ) ),
476
+			esc_attr(sprintf(__('View %1$s version %2$s details'), $theme_name, $r['new_version'])),
477 477
 			$r['new_version']
478 478
 		);
479
-	} elseif ( empty( $r['package'] ) ) {
479
+	} elseif (empty($r['package'])) {
480 480
 		/* translators: 1: theme name, 2: details URL, 3: accessibility text, 4: version number */
481
-		printf( __( 'There is a new version of %1$s available. <a href="%2$s" class="thickbox open-plugin-details-modal" aria-label="%3$s">View version %4$s details</a>. <em>Automatic update is unavailable for this theme.</em>' ),
481
+		printf(__('There is a new version of %1$s available. <a href="%2$s" class="thickbox open-plugin-details-modal" aria-label="%3$s">View version %4$s details</a>. <em>Automatic update is unavailable for this theme.</em>'),
482 482
 			$theme_name,
483
-			esc_url( $details_url ),
483
+			esc_url($details_url),
484 484
 			/* translators: 1: theme name, 2: version number */
485
-			esc_attr( sprintf( __( 'View %1$s version %2$s details' ), $theme_name, $r['new_version'] ) ),
485
+			esc_attr(sprintf(__('View %1$s version %2$s details'), $theme_name, $r['new_version'])),
486 486
 			$r['new_version']
487 487
 		);
488 488
 	} else {
489 489
 		/* translators: 1: theme name, 2: details URL, 3: accessibility text, 4: version number, 5: update URL, 6: accessibility text */
490
-		printf( __( 'There is a new version of %1$s available. <a href="%2$s" class="thickbox open-plugin-details-modal" aria-label="%3$s">View version %4$s details</a> or <a href="%5$s" class="update-link" aria-label="%6$s">update now</a>.' ),
490
+		printf(__('There is a new version of %1$s available. <a href="%2$s" class="thickbox open-plugin-details-modal" aria-label="%3$s">View version %4$s details</a> or <a href="%5$s" class="update-link" aria-label="%6$s">update now</a>.'),
491 491
 			$theme_name,
492
-			esc_url( $details_url ),
492
+			esc_url($details_url),
493 493
 			/* translators: 1: theme name, 2: version number */
494
-			esc_attr( sprintf( __( 'View %1$s version %2$s details' ), $theme_name, $r['new_version'] ) ),
494
+			esc_attr(sprintf(__('View %1$s version %2$s details'), $theme_name, $r['new_version'])),
495 495
 			$r['new_version'],
496
-			wp_nonce_url( self_admin_url( 'update.php?action=upgrade-theme&theme=' ) . $theme_key, 'upgrade-theme_' . $theme_key ),
496
+			wp_nonce_url(self_admin_url('update.php?action=upgrade-theme&theme=').$theme_key, 'upgrade-theme_'.$theme_key),
497 497
 			/* translators: %s: theme name */
498
-			esc_attr( sprintf( __( 'Update %s now' ), $theme_name ) )
498
+			esc_attr(sprintf(__('Update %s now'), $theme_name))
499 499
 		);
500 500
 	}
501 501
 	/**
@@ -516,7 +516,7 @@  discard block
 block discarded – undo
516 516
 	 *     @type string $package     Theme update package URL.
517 517
 	 * }
518 518
 	 */
519
-	do_action( "in_theme_update_message-{$theme_key}", $theme, $r );
519
+	do_action("in_theme_update_message-{$theme_key}", $theme, $r);
520 520
 
521 521
 	echo '</div></td></tr>';
522 522
 }
@@ -527,11 +527,11 @@  discard block
 block discarded – undo
527 527
  * @return false|void
528 528
  */
529 529
 function maintenance_nag() {
530
-	include( ABSPATH . WPINC . '/version.php' ); // include an unmodified $wp_version
530
+	include(ABSPATH.WPINC.'/version.php'); // include an unmodified $wp_version
531 531
 	global $upgrading;
532
-	$nag = isset( $upgrading );
533
-	if ( ! $nag ) {
534
-		$failed = get_site_option( 'auto_core_update_failed' );
532
+	$nag = isset($upgrading);
533
+	if ( ! $nag) {
534
+		$failed = get_site_option('auto_core_update_failed');
535 535
 		/*
536 536
 		 * If an update failed critically, we may have copied over version.php but not other files.
537 537
 		 * In that case, if the install claims we're running the version we attempted, nag.
@@ -542,16 +542,16 @@  discard block
 block discarded – undo
542 542
 		 *
543 543
 		 * This flag is cleared whenever a successful update occurs using Core_Upgrader.
544 544
 		 */
545
-		$comparison = ! empty( $failed['critical'] ) ? '>=' : '>';
546
-		if ( version_compare( $failed['attempted'], $wp_version, $comparison ) )
545
+		$comparison = ! empty($failed['critical']) ? '>=' : '>';
546
+		if (version_compare($failed['attempted'], $wp_version, $comparison))
547 547
 			$nag = true;
548 548
 	}
549 549
 
550
-	if ( ! $nag )
550
+	if ( ! $nag)
551 551
 		return false;
552 552
 
553
-	if ( current_user_can('update_core') )
554
-		$msg = sprintf( __('An automated WordPress update has failed to complete - <a href="%s">please attempt the update again now</a>.'), 'update-core.php' );
553
+	if (current_user_can('update_core'))
554
+		$msg = sprintf(__('An automated WordPress update has failed to complete - <a href="%s">please attempt the update again now</a>.'), 'update-core.php');
555 555
 	else
556 556
 		$msg = __('An automated WordPress update has failed to complete! Please notify the site administrator.');
557 557
 
Please login to merge, or discard this patch.
src/wp-admin/includes/meta-boxes.php 2 patches
Indentation   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -61,12 +61,12 @@  discard block
 block discarded – undo
61 61
 <?php endif; // public post type ?>
62 62
 <?php
63 63
 /**
64
- * Fires before the post time/date setting in the Publish meta box.
65
- *
66
- * @since 4.4.0
67
- *
68
- * @param WP_Post $post WP_Post object for the current post.
69
- */
64
+	 * Fires before the post time/date setting in the Publish meta box.
65
+	 *
66
+	 * @since 4.4.0
67
+	 *
68
+	 * @param WP_Post $post WP_Post object for the current post.
69
+	 */
70 70
 do_action( 'post_submitbox_minor_actions', $post );
71 71
 ?>
72 72
 <div class="clear"></div>
@@ -835,14 +835,14 @@  discard block
 block discarded – undo
835 835
 <label class="screen-reader-text" for="page_template"><?php _e('Page Template') ?></label><select name="page_template" id="page_template">
836 836
 <?php
837 837
 /**
838
- * Filter the title of the default page template displayed in the drop-down.
839
- *
840
- * @since 4.1.0
841
- *
842
- * @param string $label   The display value for the default page template title.
843
- * @param string $context Where the option label is displayed. Possible values
844
- *                        include 'meta-box' or 'quick-edit'.
845
- */
838
+	 * Filter the title of the default page template displayed in the drop-down.
839
+	 *
840
+	 * @since 4.1.0
841
+	 *
842
+	 * @param string $label   The display value for the default page template title.
843
+	 * @param string $context Where the option label is displayed. Possible values
844
+	 *                        include 'meta-box' or 'quick-edit'.
845
+	 */
846 846
 $default_title = apply_filters( 'default_page_template_title',  __( 'Default Template' ), 'meta-box' );
847 847
 ?>
848 848
 <option value="default"><?php echo esc_html( $default_title ); ?></option>
Please login to merge, or discard this patch.
Spacing   +207 added lines, -207 removed lines patch added patch discarded remove patch
@@ -19,7 +19,7 @@  discard block
 block discarded – undo
19 19
  *     @type array    $args     Extra meta box arguments.
20 20
  * }
21 21
  */
22
-function post_submit_meta_box( $post, $args = array() ) {
22
+function post_submit_meta_box($post, $args = array()) {
23 23
 	global $action;
24 24
 
25 25
 	$post_type = $post->post_type;
@@ -32,27 +32,27 @@  discard block
 block discarded – undo
32 32
 
33 33
 <?php // Hidden submit button early on so that the browser chooses the right button when form is submitted with Return key ?>
34 34
 <div style="display:none;">
35
-<?php submit_button( __( 'Save' ), 'button', 'save' ); ?>
35
+<?php submit_button(__('Save'), 'button', 'save'); ?>
36 36
 </div>
37 37
 
38 38
 <div id="minor-publishing-actions">
39 39
 <div id="save-action">
40
-<?php if ( 'publish' != $post->post_status && 'future' != $post->post_status && 'pending' != $post->post_status ) { ?>
41
-<input <?php if ( 'private' == $post->post_status ) { ?>style="display:none"<?php } ?> type="submit" name="save" id="save-post" value="<?php esc_attr_e('Save Draft'); ?>" class="button" />
40
+<?php if ('publish' != $post->post_status && 'future' != $post->post_status && 'pending' != $post->post_status) { ?>
41
+<input <?php if ('private' == $post->post_status) { ?>style="display:none"<?php } ?> type="submit" name="save" id="save-post" value="<?php esc_attr_e('Save Draft'); ?>" class="button" />
42 42
 <span class="spinner"></span>
43
-<?php } elseif ( 'pending' == $post->post_status && $can_publish ) { ?>
43
+<?php } elseif ('pending' == $post->post_status && $can_publish) { ?>
44 44
 <input type="submit" name="save" id="save-post" value="<?php esc_attr_e('Save as Pending'); ?>" class="button" />
45 45
 <span class="spinner"></span>
46 46
 <?php } ?>
47 47
 </div>
48
-<?php if ( is_post_type_viewable( $post_type_object ) ) : ?>
48
+<?php if (is_post_type_viewable($post_type_object)) : ?>
49 49
 <div id="preview-action">
50 50
 <?php
51
-$preview_link = esc_url( get_preview_post_link( $post ) );
52
-if ( 'publish' == $post->post_status ) {
53
-	$preview_button = __( 'Preview Changes' );
51
+$preview_link = esc_url(get_preview_post_link($post));
52
+if ('publish' == $post->post_status) {
53
+	$preview_button = __('Preview Changes');
54 54
 } else {
55
-	$preview_button = __( 'Preview' );
55
+	$preview_button = __('Preview');
56 56
 }
57 57
 ?>
58 58
 <a class="preview button" href="<?php echo $preview_link; ?>" target="wp-preview-<?php echo (int) $post->ID; ?>" id="post-preview"><?php echo $preview_button; ?></a>
@@ -67,7 +67,7 @@  discard block
 block discarded – undo
67 67
  *
68 68
  * @param WP_Post $post WP_Post object for the current post.
69 69
  */
70
-do_action( 'post_submitbox_minor_actions', $post );
70
+do_action('post_submitbox_minor_actions', $post);
71 71
 ?>
72 72
 <div class="clear"></div>
73 73
 </div><!-- #minor-publishing-actions -->
@@ -77,7 +77,7 @@  discard block
 block discarded – undo
77 77
 <div class="misc-pub-section misc-pub-post-status"><label for="post_status"><?php _e('Status:') ?></label>
78 78
 <span id="post-status-display">
79 79
 <?php
80
-switch ( $post->post_status ) {
80
+switch ($post->post_status) {
81 81
 	case 'private':
82 82
 		_e('Privately Published');
83 83
 		break;
@@ -97,24 +97,24 @@  discard block
 block discarded – undo
97 97
 }
98 98
 ?>
99 99
 </span>
100
-<?php if ( 'publish' == $post->post_status || 'private' == $post->post_status || $can_publish ) { ?>
101
-<a href="#post_status" <?php if ( 'private' == $post->post_status ) { ?>style="display:none;" <?php } ?>class="edit-post-status hide-if-no-js"><span aria-hidden="true"><?php _e( 'Edit' ); ?></span> <span class="screen-reader-text"><?php _e( 'Edit status' ); ?></span></a>
100
+<?php if ('publish' == $post->post_status || 'private' == $post->post_status || $can_publish) { ?>
101
+<a href="#post_status" <?php if ('private' == $post->post_status) { ?>style="display:none;" <?php } ?>class="edit-post-status hide-if-no-js"><span aria-hidden="true"><?php _e('Edit'); ?></span> <span class="screen-reader-text"><?php _e('Edit status'); ?></span></a>
102 102
 
103 103
 <div id="post-status-select" class="hide-if-js">
104
-<input type="hidden" name="hidden_post_status" id="hidden_post_status" value="<?php echo esc_attr( ('auto-draft' == $post->post_status ) ? 'draft' : $post->post_status); ?>" />
104
+<input type="hidden" name="hidden_post_status" id="hidden_post_status" value="<?php echo esc_attr(('auto-draft' == $post->post_status) ? 'draft' : $post->post_status); ?>" />
105 105
 <select name='post_status' id='post_status'>
106
-<?php if ( 'publish' == $post->post_status ) : ?>
107
-<option<?php selected( $post->post_status, 'publish' ); ?> value='publish'><?php _e('Published') ?></option>
108
-<?php elseif ( 'private' == $post->post_status ) : ?>
109
-<option<?php selected( $post->post_status, 'private' ); ?> value='publish'><?php _e('Privately Published') ?></option>
110
-<?php elseif ( 'future' == $post->post_status ) : ?>
111
-<option<?php selected( $post->post_status, 'future' ); ?> value='future'><?php _e('Scheduled') ?></option>
106
+<?php if ('publish' == $post->post_status) : ?>
107
+<option<?php selected($post->post_status, 'publish'); ?> value='publish'><?php _e('Published') ?></option>
108
+<?php elseif ('private' == $post->post_status) : ?>
109
+<option<?php selected($post->post_status, 'private'); ?> value='publish'><?php _e('Privately Published') ?></option>
110
+<?php elseif ('future' == $post->post_status) : ?>
111
+<option<?php selected($post->post_status, 'future'); ?> value='future'><?php _e('Scheduled') ?></option>
112 112
 <?php endif; ?>
113
-<option<?php selected( $post->post_status, 'pending' ); ?> value='pending'><?php _e('Pending Review') ?></option>
114
-<?php if ( 'auto-draft' == $post->post_status ) : ?>
115
-<option<?php selected( $post->post_status, 'auto-draft' ); ?> value='draft'><?php _e('Draft') ?></option>
113
+<option<?php selected($post->post_status, 'pending'); ?> value='pending'><?php _e('Pending Review') ?></option>
114
+<?php if ('auto-draft' == $post->post_status) : ?>
115
+<option<?php selected($post->post_status, 'auto-draft'); ?> value='draft'><?php _e('Draft') ?></option>
116 116
 <?php else : ?>
117
-<option<?php selected( $post->post_status, 'draft' ); ?> value='draft'><?php _e('Draft') ?></option>
117
+<option<?php selected($post->post_status, 'draft'); ?> value='draft'><?php _e('Draft') ?></option>
118 118
 <?php endif; ?>
119 119
 </select>
120 120
  <a href="#post_status" class="save-post-status hide-if-no-js button"><?php _e('OK'); ?></a>
@@ -127,14 +127,14 @@  discard block
 block discarded – undo
127 127
 <div class="misc-pub-section misc-pub-visibility" id="visibility">
128 128
 <?php _e('Visibility:'); ?> <span id="post-visibility-display"><?php
129 129
 
130
-if ( 'private' == $post->post_status ) {
130
+if ('private' == $post->post_status) {
131 131
 	$post->post_password = '';
132 132
 	$visibility = 'private';
133 133
 	$visibility_trans = __('Private');
134
-} elseif ( !empty( $post->post_password ) ) {
134
+} elseif ( ! empty($post->post_password)) {
135 135
 	$visibility = 'password';
136 136
 	$visibility_trans = __('Password protected');
137
-} elseif ( $post_type == 'post' && is_sticky( $post->ID ) ) {
137
+} elseif ($post_type == 'post' && is_sticky($post->ID)) {
138 138
 	$visibility = 'public';
139 139
 	$visibility_trans = __('Public, Sticky');
140 140
 } else {
@@ -142,23 +142,23 @@  discard block
 block discarded – undo
142 142
 	$visibility_trans = __('Public');
143 143
 }
144 144
 
145
-echo esc_html( $visibility_trans ); ?></span>
146
-<?php if ( $can_publish ) { ?>
147
-<a href="#visibility" class="edit-visibility hide-if-no-js"><span aria-hidden="true"><?php _e( 'Edit' ); ?></span> <span class="screen-reader-text"><?php _e( 'Edit visibility' ); ?></span></a>
145
+echo esc_html($visibility_trans); ?></span>
146
+<?php if ($can_publish) { ?>
147
+<a href="#visibility" class="edit-visibility hide-if-no-js"><span aria-hidden="true"><?php _e('Edit'); ?></span> <span class="screen-reader-text"><?php _e('Edit visibility'); ?></span></a>
148 148
 
149 149
 <div id="post-visibility-select" class="hide-if-js">
150 150
 <input type="hidden" name="hidden_post_password" id="hidden-post-password" value="<?php echo esc_attr($post->post_password); ?>" />
151 151
 <?php if ($post_type == 'post'): ?>
152 152
 <input type="checkbox" style="display:none" name="hidden_post_sticky" id="hidden-post-sticky" value="sticky" <?php checked(is_sticky($post->ID)); ?> />
153 153
 <?php endif; ?>
154
-<input type="hidden" name="hidden_post_visibility" id="hidden-post-visibility" value="<?php echo esc_attr( $visibility ); ?>" />
155
-<input type="radio" name="visibility" id="visibility-radio-public" value="public" <?php checked( $visibility, 'public' ); ?> /> <label for="visibility-radio-public" class="selectit"><?php _e('Public'); ?></label><br />
156
-<?php if ( $post_type == 'post' && current_user_can( 'edit_others_posts' ) ) : ?>
157
-<span id="sticky-span"><input id="sticky" name="sticky" type="checkbox" value="sticky" <?php checked( is_sticky( $post->ID ) ); ?> /> <label for="sticky" class="selectit"><?php _e( 'Stick this post to the front page' ); ?></label><br /></span>
154
+<input type="hidden" name="hidden_post_visibility" id="hidden-post-visibility" value="<?php echo esc_attr($visibility); ?>" />
155
+<input type="radio" name="visibility" id="visibility-radio-public" value="public" <?php checked($visibility, 'public'); ?> /> <label for="visibility-radio-public" class="selectit"><?php _e('Public'); ?></label><br />
156
+<?php if ($post_type == 'post' && current_user_can('edit_others_posts')) : ?>
157
+<span id="sticky-span"><input id="sticky" name="sticky" type="checkbox" value="sticky" <?php checked(is_sticky($post->ID)); ?> /> <label for="sticky" class="selectit"><?php _e('Stick this post to the front page'); ?></label><br /></span>
158 158
 <?php endif; ?>
159
-<input type="radio" name="visibility" id="visibility-radio-password" value="password" <?php checked( $visibility, 'password' ); ?> /> <label for="visibility-radio-password" class="selectit"><?php _e('Password protected'); ?></label><br />
159
+<input type="radio" name="visibility" id="visibility-radio-password" value="password" <?php checked($visibility, 'password'); ?> /> <label for="visibility-radio-password" class="selectit"><?php _e('Password protected'); ?></label><br />
160 160
 <span id="password-span"><label for="post_password"><?php _e('Password:'); ?></label> <input type="text" name="post_password" id="post_password" value="<?php echo esc_attr($post->post_password); ?>"  maxlength="20" /><br /></span>
161
-<input type="radio" name="visibility" id="visibility-radio-private" value="private" <?php checked( $visibility, 'private' ); ?> /> <label for="visibility-radio-private" class="selectit"><?php _e('Private'); ?></label><br />
161
+<input type="radio" name="visibility" id="visibility-radio-private" value="private" <?php checked($visibility, 'private'); ?> /> <label for="visibility-radio-private" class="selectit"><?php _e('Private'); ?></label><br />
162 162
 
163 163
 <p>
164 164
  <a href="#visibility" class="save-post-visibility hide-if-no-js button"><?php _e('OK'); ?></a>
@@ -171,40 +171,40 @@  discard block
 block discarded – undo
171 171
 
172 172
 <?php
173 173
 /* translators: Publish box date format, see http://php.net/date */
174
-$datef = __( 'M j, Y @ H:i' );
175
-if ( 0 != $post->ID ) {
176
-	if ( 'future' == $post->post_status ) { // scheduled for publishing at a future date
174
+$datef = __('M j, Y @ H:i');
175
+if (0 != $post->ID) {
176
+	if ('future' == $post->post_status) { // scheduled for publishing at a future date
177 177
 		$stamp = __('Scheduled for: <b>%1$s</b>');
178
-	} elseif ( 'publish' == $post->post_status || 'private' == $post->post_status ) { // already published
178
+	} elseif ('publish' == $post->post_status || 'private' == $post->post_status) { // already published
179 179
 		$stamp = __('Published on: <b>%1$s</b>');
180
-	} elseif ( '0000-00-00 00:00:00' == $post->post_date_gmt ) { // draft, 1 or more saves, no date specified
180
+	} elseif ('0000-00-00 00:00:00' == $post->post_date_gmt) { // draft, 1 or more saves, no date specified
181 181
 		$stamp = __('Publish <b>immediately</b>');
182
-	} elseif ( time() < strtotime( $post->post_date_gmt . ' +0000' ) ) { // draft, 1 or more saves, future date specified
182
+	} elseif (time() < strtotime($post->post_date_gmt.' +0000')) { // draft, 1 or more saves, future date specified
183 183
 		$stamp = __('Schedule for: <b>%1$s</b>');
184 184
 	} else { // draft, 1 or more saves, date specified
185 185
 		$stamp = __('Publish on: <b>%1$s</b>');
186 186
 	}
187
-	$date = date_i18n( $datef, strtotime( $post->post_date ) );
187
+	$date = date_i18n($datef, strtotime($post->post_date));
188 188
 } else { // draft (no saves, and thus no date specified)
189 189
 	$stamp = __('Publish <b>immediately</b>');
190
-	$date = date_i18n( $datef, strtotime( current_time('mysql') ) );
190
+	$date = date_i18n($datef, strtotime(current_time('mysql')));
191 191
 }
192 192
 
193
-if ( ! empty( $args['args']['revisions_count'] ) ) : ?>
193
+if ( ! empty($args['args']['revisions_count'])) : ?>
194 194
 <div class="misc-pub-section misc-pub-revisions">
195
-	<?php printf( __( 'Revisions: %s' ), '<b>' . number_format_i18n( $args['args']['revisions_count'] ) . '</b>' ); ?>
196
-	<a class="hide-if-no-js" href="<?php echo esc_url( get_edit_post_link( $args['args']['revision_id'] ) ); ?>"><span aria-hidden="true"><?php _ex( 'Browse', 'revisions' ); ?></span> <span class="screen-reader-text"><?php _e( 'Browse revisions' ); ?></span></a>
195
+	<?php printf(__('Revisions: %s'), '<b>'.number_format_i18n($args['args']['revisions_count']).'</b>'); ?>
196
+	<a class="hide-if-no-js" href="<?php echo esc_url(get_edit_post_link($args['args']['revision_id'])); ?>"><span aria-hidden="true"><?php _ex('Browse', 'revisions'); ?></span> <span class="screen-reader-text"><?php _e('Browse revisions'); ?></span></a>
197 197
 </div>
198 198
 <?php endif;
199 199
 
200
-if ( $can_publish ) : // Contributors don't get to choose the date of publish ?>
200
+if ($can_publish) : // Contributors don't get to choose the date of publish ?>
201 201
 <div class="misc-pub-section curtime misc-pub-curtime">
202 202
 	<span id="timestamp">
203 203
 	<?php printf($stamp, $date); ?></span>
204
-	<a href="#edit_timestamp" class="edit-timestamp hide-if-no-js"><span aria-hidden="true"><?php _e( 'Edit' ); ?></span> <span class="screen-reader-text"><?php _e( 'Edit date and time' ); ?></span></a>
204
+	<a href="#edit_timestamp" class="edit-timestamp hide-if-no-js"><span aria-hidden="true"><?php _e('Edit'); ?></span> <span class="screen-reader-text"><?php _e('Edit date and time'); ?></span></a>
205 205
 	<fieldset id="timestampdiv" class="hide-if-js">
206
-	<legend class="screen-reader-text"><?php _e( 'Date and time' ); ?></legend>
207
-	<?php touch_time( ( $action === 'edit' ), 1 ); ?>
206
+	<legend class="screen-reader-text"><?php _e('Date and time'); ?></legend>
207
+	<?php touch_time(($action === 'edit'), 1); ?>
208 208
 	</fieldset>
209 209
 </div><?php // /misc-pub-section ?>
210 210
 <?php endif; ?>
@@ -218,7 +218,7 @@  discard block
 block discarded – undo
218 218
  *
219 219
  * @param WP_Post $post WP_Post object for the current post.
220 220
  */
221
-do_action( 'post_submitbox_misc_actions', $post );
221
+do_action('post_submitbox_misc_actions', $post);
222 222
 ?>
223 223
 </div>
224 224
 <div class="clear"></div>
@@ -231,12 +231,12 @@  discard block
 block discarded – undo
231 231
  *
232 232
  * @since 2.7.0
233 233
  */
234
-do_action( 'post_submitbox_start' );
234
+do_action('post_submitbox_start');
235 235
 ?>
236 236
 <div id="delete-action">
237 237
 <?php
238
-if ( current_user_can( "delete_post", $post->ID ) ) {
239
-	if ( !EMPTY_TRASH_DAYS )
238
+if (current_user_can("delete_post", $post->ID)) {
239
+	if ( ! EMPTY_TRASH_DAYS)
240 240
 		$delete_text = __('Delete Permanently');
241 241
 	else
242 242
 		$delete_text = __('Move to Trash');
@@ -248,23 +248,23 @@  discard block
 block discarded – undo
248 248
 <div id="publishing-action">
249 249
 <span class="spinner"></span>
250 250
 <?php
251
-if ( !in_array( $post->post_status, array('publish', 'future', 'private') ) || 0 == $post->ID ) {
252
-	if ( $can_publish ) :
253
-		if ( !empty($post->post_date_gmt) && time() < strtotime( $post->post_date_gmt . ' +0000' ) ) : ?>
251
+if ( ! in_array($post->post_status, array('publish', 'future', 'private')) || 0 == $post->ID) {
252
+	if ($can_publish) :
253
+		if ( ! empty($post->post_date_gmt) && time() < strtotime($post->post_date_gmt.' +0000')) : ?>
254 254
 		<input name="original_publish" type="hidden" id="original_publish" value="<?php esc_attr_e('Schedule') ?>" />
255
-		<?php submit_button( __( 'Schedule' ), 'primary button-large', 'publish', false ); ?>
255
+		<?php submit_button(__('Schedule'), 'primary button-large', 'publish', false); ?>
256 256
 <?php	else : ?>
257 257
 		<input name="original_publish" type="hidden" id="original_publish" value="<?php esc_attr_e('Publish') ?>" />
258
-		<?php submit_button( __( 'Publish' ), 'primary button-large', 'publish', false ); ?>
258
+		<?php submit_button(__('Publish'), 'primary button-large', 'publish', false); ?>
259 259
 <?php	endif;
260 260
 	else : ?>
261 261
 		<input name="original_publish" type="hidden" id="original_publish" value="<?php esc_attr_e('Submit for Review') ?>" />
262
-		<?php submit_button( __( 'Submit for Review' ), 'primary button-large', 'publish', false ); ?>
262
+		<?php submit_button(__('Submit for Review'), 'primary button-large', 'publish', false); ?>
263 263
 <?php
264 264
 	endif;
265 265
 } else { ?>
266 266
 		<input name="original_publish" type="hidden" id="original_publish" value="<?php esc_attr_e('Update') ?>" />
267
-		<input name="save" type="submit" class="button button-primary button-large" id="publish" value="<?php esc_attr_e( 'Update' ) ?>" />
267
+		<input name="save" type="submit" class="button button-primary button-large" id="publish" value="<?php esc_attr_e('Update') ?>" />
268 268
 <?php
269 269
 } ?>
270 270
 </div>
@@ -282,7 +282,7 @@  discard block
 block discarded – undo
282 282
  *
283 283
  * @param object $post
284 284
  */
285
-function attachment_submit_meta_box( $post ) {
285
+function attachment_submit_meta_box($post) {
286 286
 ?>
287 287
 <div class="submitbox" id="submitpost">
288 288
 
@@ -290,16 +290,16 @@  discard block
 block discarded – undo
290 290
 
291 291
 <?php // Hidden submit button early on so that the browser chooses the right button when form is submitted with Return key ?>
292 292
 <div style="display:none;">
293
-<?php submit_button( __( 'Save' ), 'button', 'save' ); ?>
293
+<?php submit_button(__('Save'), 'button', 'save'); ?>
294 294
 </div>
295 295
 
296 296
 
297 297
 <div id="misc-publishing-actions">
298 298
 	<?php
299 299
 	/* translators: Publish box date format, see http://php.net/date */
300
-	$datef = __( 'M j, Y @ H:i' );
300
+	$datef = __('M j, Y @ H:i');
301 301
 	$stamp = __('Uploaded on: <b>%1$s</b>');
302
-	$date = date_i18n( $datef, strtotime( $post->post_date ) );
302
+	$date = date_i18n($datef, strtotime($post->post_date));
303 303
 	?>
304 304
 	<div class="misc-pub-section curtime misc-pub-curtime">
305 305
 		<span id="timestamp"><?php printf($stamp, $date); ?></span>
@@ -312,7 +312,7 @@  discard block
 block discarded – undo
312 312
 	 *
313 313
 	 * @since 3.5.0
314 314
 	 */
315
-	do_action( 'attachment_submitbox_misc_actions' );
315
+	do_action('attachment_submitbox_misc_actions');
316 316
 	?>
317 317
 </div><!-- #misc-publishing-actions -->
318 318
 <div class="clear"></div>
@@ -321,12 +321,12 @@  discard block
 block discarded – undo
321 321
 <div id="major-publishing-actions">
322 322
 	<div id="delete-action">
323 323
 	<?php
324
-	if ( current_user_can( 'delete_post', $post->ID ) )
325
-		if ( EMPTY_TRASH_DAYS && MEDIA_TRASH ) {
326
-			echo "<a class='submitdelete deletion' href='" . get_delete_post_link( $post->ID ) . "'>" . _x( 'Trash', 'verb' ) . "</a>";
324
+	if (current_user_can('delete_post', $post->ID))
325
+		if (EMPTY_TRASH_DAYS && MEDIA_TRASH) {
326
+			echo "<a class='submitdelete deletion' href='".get_delete_post_link($post->ID)."'>"._x('Trash', 'verb')."</a>";
327 327
 		} else {
328 328
 			$delete_ays = ! MEDIA_TRASH ? " onclick='return showNotice.warn();'" : '';
329
-			echo  "<a class='submitdelete deletion'$delete_ays href='" . get_delete_post_link( $post->ID, null, true ) . "'>" . __( 'Delete Permanently' ) . "</a>";
329
+			echo  "<a class='submitdelete deletion'$delete_ays href='".get_delete_post_link($post->ID, null, true)."'>".__('Delete Permanently')."</a>";
330 330
 		}
331 331
 	?>
332 332
 	</div>
@@ -334,7 +334,7 @@  discard block
 block discarded – undo
334 334
 	<div id="publishing-action">
335 335
 		<span class="spinner"></span>
336 336
 		<input name="original_publish" type="hidden" id="original_publish" value="<?php esc_attr_e('Update') ?>" />
337
-		<input name="save" type="submit" class="button-primary button-large" id="publish" value="<?php esc_attr_e( 'Update' ) ?>" />
337
+		<input name="save" type="submit" class="button-primary button-large" id="publish" value="<?php esc_attr_e('Update') ?>" />
338 338
 	</div>
339 339
 	<div class="clear"></div>
340 340
 </div><!-- #major-publishing-actions -->
@@ -359,24 +359,24 @@  discard block
 block discarded – undo
359 359
  *     @type array    $args     Extra meta box arguments.
360 360
  * }
361 361
  */
362
-function post_format_meta_box( $post, $box ) {
363
-	if ( current_theme_supports( 'post-formats' ) && post_type_supports( $post->post_type, 'post-formats' ) ) :
364
-	$post_formats = get_theme_support( 'post-formats' );
362
+function post_format_meta_box($post, $box) {
363
+	if (current_theme_supports('post-formats') && post_type_supports($post->post_type, 'post-formats')) :
364
+	$post_formats = get_theme_support('post-formats');
365 365
 
366
-	if ( is_array( $post_formats[0] ) ) :
367
-		$post_format = get_post_format( $post->ID );
368
-		if ( !$post_format )
366
+	if (is_array($post_formats[0])) :
367
+		$post_format = get_post_format($post->ID);
368
+		if ( ! $post_format)
369 369
 			$post_format = '0';
370 370
 		// Add in the current one if it isn't there yet, in case the current theme doesn't support it
371
-		if ( $post_format && !in_array( $post_format, $post_formats[0] ) )
371
+		if ($post_format && ! in_array($post_format, $post_formats[0]))
372 372
 			$post_formats[0][] = $post_format;
373 373
 	?>
374 374
 	<div id="post-formats-select">
375 375
 		<fieldset>
376
-			<legend class="screen-reader-text"><?php _e( 'Post Formats' ); ?></legend>
377
-			<input type="radio" name="post_format" class="post-format" id="post-format-0" value="0" <?php checked( $post_format, '0' ); ?> /> <label for="post-format-0" class="post-format-icon post-format-standard"><?php echo get_post_format_string( 'standard' ); ?></label>
378
-			<?php foreach ( $post_formats[0] as $format ) : ?>
379
-			<br /><input type="radio" name="post_format" class="post-format" id="post-format-<?php echo esc_attr( $format ); ?>" value="<?php echo esc_attr( $format ); ?>" <?php checked( $post_format, $format ); ?> /> <label for="post-format-<?php echo esc_attr( $format ); ?>" class="post-format-icon post-format-<?php echo esc_attr( $format ); ?>"><?php echo esc_html( get_post_format_string( $format ) ); ?></label>
376
+			<legend class="screen-reader-text"><?php _e('Post Formats'); ?></legend>
377
+			<input type="radio" name="post_format" class="post-format" id="post-format-0" value="0" <?php checked($post_format, '0'); ?> /> <label for="post-format-0" class="post-format-icon post-format-standard"><?php echo get_post_format_string('standard'); ?></label>
378
+			<?php foreach ($post_formats[0] as $format) : ?>
379
+			<br /><input type="radio" name="post_format" class="post-format" id="post-format-<?php echo esc_attr($format); ?>" value="<?php echo esc_attr($format); ?>" <?php checked($post_format, $format); ?> /> <label for="post-format-<?php echo esc_attr($format); ?>" class="post-format-icon post-format-<?php echo esc_attr($format); ?>"><?php echo esc_html(get_post_format_string($format)); ?></label>
380 380
 			<?php endforeach; ?>
381 381
 		</fieldset>
382 382
 	</div>
@@ -404,20 +404,20 @@  discard block
 block discarded – undo
404 404
  *     }
405 405
  * }
406 406
  */
407
-function post_tags_meta_box( $post, $box ) {
408
-	$defaults = array( 'taxonomy' => 'post_tag' );
409
-	if ( ! isset( $box['args'] ) || ! is_array( $box['args'] ) ) {
407
+function post_tags_meta_box($post, $box) {
408
+	$defaults = array('taxonomy' => 'post_tag');
409
+	if ( ! isset($box['args']) || ! is_array($box['args'])) {
410 410
 		$args = array();
411 411
 	} else {
412 412
 		$args = $box['args'];
413 413
 	}
414
-	$r = wp_parse_args( $args, $defaults );
415
-	$tax_name = esc_attr( $r['taxonomy'] );
416
-	$taxonomy = get_taxonomy( $r['taxonomy'] );
417
-	$user_can_assign_terms = current_user_can( $taxonomy->cap->assign_terms );
418
-	$comma = _x( ',', 'tag delimiter' );
419
-	$terms_to_edit = get_terms_to_edit( $post->ID, $tax_name );
420
-	if ( ! is_string( $terms_to_edit ) ) {
414
+	$r = wp_parse_args($args, $defaults);
415
+	$tax_name = esc_attr($r['taxonomy']);
416
+	$taxonomy = get_taxonomy($r['taxonomy']);
417
+	$user_can_assign_terms = current_user_can($taxonomy->cap->assign_terms);
418
+	$comma = _x(',', 'tag delimiter');
419
+	$terms_to_edit = get_terms_to_edit($post->ID, $tax_name);
420
+	if ( ! is_string($terms_to_edit)) {
421 421
 		$terms_to_edit = '';
422 422
 	}
423 423
 ?>
@@ -425,9 +425,9 @@  discard block
 block discarded – undo
425 425
 	<div class="jaxtag">
426 426
 	<div class="nojs-tags hide-if-js">
427 427
 		<label for="tax-input-<?php echo $tax_name; ?>"><?php echo $taxonomy->labels->add_or_remove_items; ?></label>
428
-		<p><textarea name="<?php echo "tax_input[$tax_name]"; ?>" rows="3" cols="20" class="the-tags" id="tax-input-<?php echo $tax_name; ?>" <?php disabled( ! $user_can_assign_terms ); ?> aria-describedby="new-tag-<?php echo $tax_name; ?>-desc"><?php echo str_replace( ',', $comma . ' ', $terms_to_edit ); // textarea_escaped by esc_attr() ?></textarea></p>
428
+		<p><textarea name="<?php echo "tax_input[$tax_name]"; ?>" rows="3" cols="20" class="the-tags" id="tax-input-<?php echo $tax_name; ?>" <?php disabled( ! $user_can_assign_terms); ?> aria-describedby="new-tag-<?php echo $tax_name; ?>-desc"><?php echo str_replace(',', $comma.' ', $terms_to_edit); // textarea_escaped by esc_attr() ?></textarea></p>
429 429
 	</div>
430
- 	<?php if ( $user_can_assign_terms ) : ?>
430
+ 	<?php if ($user_can_assign_terms) : ?>
431 431
 	<div class="ajaxtag hide-if-no-js">
432 432
 		<label class="screen-reader-text" for="new-tag-<?php echo $tax_name; ?>"><?php echo $taxonomy->labels->add_new_item; ?></label>
433 433
 		<p><input type="text" id="new-tag-<?php echo $tax_name; ?>" name="newtag[<?php echo $tax_name; ?>]" class="newtag form-input-tip" size="16" autocomplete="off" aria-describedby="new-tag-<?php echo $tax_name; ?>-desc" value="" />
@@ -438,7 +438,7 @@  discard block
 block discarded – undo
438 438
 	</div>
439 439
 	<div class="tagchecklist"></div>
440 440
 </div>
441
-<?php if ( $user_can_assign_terms ) : ?>
441
+<?php if ($user_can_assign_terms) : ?>
442 442
 <p class="hide-if-no-js"><a href="#titlediv" class="tagcloud-link" id="link-<?php echo $tax_name; ?>"><?php echo $taxonomy->labels->choose_from_most_used; ?></a></p>
443 443
 <?php endif; ?>
444 444
 <?php
@@ -465,49 +465,49 @@  discard block
 block discarded – undo
465 465
  *     }
466 466
  * }
467 467
  */
468
-function post_categories_meta_box( $post, $box ) {
469
-	$defaults = array( 'taxonomy' => 'category' );
470
-	if ( ! isset( $box['args'] ) || ! is_array( $box['args'] ) ) {
468
+function post_categories_meta_box($post, $box) {
469
+	$defaults = array('taxonomy' => 'category');
470
+	if ( ! isset($box['args']) || ! is_array($box['args'])) {
471 471
 		$args = array();
472 472
 	} else {
473 473
 		$args = $box['args'];
474 474
 	}
475
-	$r = wp_parse_args( $args, $defaults );
476
-	$tax_name = esc_attr( $r['taxonomy'] );
477
-	$taxonomy = get_taxonomy( $r['taxonomy'] );
475
+	$r = wp_parse_args($args, $defaults);
476
+	$tax_name = esc_attr($r['taxonomy']);
477
+	$taxonomy = get_taxonomy($r['taxonomy']);
478 478
 	?>
479 479
 	<div id="taxonomy-<?php echo $tax_name; ?>" class="categorydiv">
480 480
 		<ul id="<?php echo $tax_name; ?>-tabs" class="category-tabs">
481 481
 			<li class="tabs"><a href="#<?php echo $tax_name; ?>-all"><?php echo $taxonomy->labels->all_items; ?></a></li>
482
-			<li class="hide-if-no-js"><a href="#<?php echo $tax_name; ?>-pop"><?php _e( 'Most Used' ); ?></a></li>
482
+			<li class="hide-if-no-js"><a href="#<?php echo $tax_name; ?>-pop"><?php _e('Most Used'); ?></a></li>
483 483
 		</ul>
484 484
 
485 485
 		<div id="<?php echo $tax_name; ?>-pop" class="tabs-panel" style="display: none;">
486 486
 			<ul id="<?php echo $tax_name; ?>checklist-pop" class="categorychecklist form-no-clear" >
487
-				<?php $popular_ids = wp_popular_terms_checklist( $tax_name ); ?>
487
+				<?php $popular_ids = wp_popular_terms_checklist($tax_name); ?>
488 488
 			</ul>
489 489
 		</div>
490 490
 
491 491
 		<div id="<?php echo $tax_name; ?>-all" class="tabs-panel">
492 492
 			<?php
493
-			$name = ( $tax_name == 'category' ) ? 'post_category' : 'tax_input[' . $tax_name . ']';
493
+			$name = ($tax_name == 'category') ? 'post_category' : 'tax_input['.$tax_name.']';
494 494
 			echo "<input type='hidden' name='{$name}[]' value='0' />"; // Allows for an empty term set to be sent. 0 is an invalid Term ID and will be ignored by empty() checks.
495 495
 			?>
496 496
 			<ul id="<?php echo $tax_name; ?>checklist" data-wp-lists="list:<?php echo $tax_name; ?>" class="categorychecklist form-no-clear">
497
-				<?php wp_terms_checklist( $post->ID, array( 'taxonomy' => $tax_name, 'popular_cats' => $popular_ids ) ); ?>
497
+				<?php wp_terms_checklist($post->ID, array('taxonomy' => $tax_name, 'popular_cats' => $popular_ids)); ?>
498 498
 			</ul>
499 499
 		</div>
500
-	<?php if ( current_user_can( $taxonomy->cap->edit_terms ) ) : ?>
500
+	<?php if (current_user_can($taxonomy->cap->edit_terms)) : ?>
501 501
 			<div id="<?php echo $tax_name; ?>-adder" class="wp-hidden-children">
502 502
 				<a id="<?php echo $tax_name; ?>-add-toggle" href="#<?php echo $tax_name; ?>-add" class="hide-if-no-js taxonomy-add-new">
503 503
 					<?php
504 504
 						/* translators: %s: add new taxonomy label */
505
-						printf( __( '+ %s' ), $taxonomy->labels->add_new_item );
505
+						printf(__('+ %s'), $taxonomy->labels->add_new_item);
506 506
 					?>
507 507
 				</a>
508 508
 				<p id="<?php echo $tax_name; ?>-add" class="category-add wp-hidden-child">
509 509
 					<label class="screen-reader-text" for="new<?php echo $tax_name; ?>"><?php echo $taxonomy->labels->add_new_item; ?></label>
510
-					<input type="text" name="new<?php echo $tax_name; ?>" id="new<?php echo $tax_name; ?>" class="form-required form-input-tip" value="<?php echo esc_attr( $taxonomy->labels->new_item_name ); ?>" aria-required="true"/>
510
+					<input type="text" name="new<?php echo $tax_name; ?>" id="new<?php echo $tax_name; ?>" class="form-required form-input-tip" value="<?php echo esc_attr($taxonomy->labels->new_item_name); ?>" aria-required="true"/>
511 511
 					<label class="screen-reader-text" for="new<?php echo $tax_name; ?>_parent">
512 512
 						<?php echo $taxonomy->labels->parent_item_colon; ?>
513 513
 					</label>
@@ -515,10 +515,10 @@  discard block
 block discarded – undo
515 515
 					$parent_dropdown_args = array(
516 516
 						'taxonomy'         => $tax_name,
517 517
 						'hide_empty'       => 0,
518
-						'name'             => 'new' . $tax_name . '_parent',
518
+						'name'             => 'new'.$tax_name.'_parent',
519 519
 						'orderby'          => 'name',
520 520
 						'hierarchical'     => 1,
521
-						'show_option_none' => '&mdash; ' . $taxonomy->labels->parent_item . ' &mdash;',
521
+						'show_option_none' => '&mdash; '.$taxonomy->labels->parent_item.' &mdash;',
522 522
 					);
523 523
 
524 524
 					/**
@@ -545,12 +545,12 @@  discard block
 block discarded – undo
545 545
 					 *                                      taxonomy label.
546 546
 					 * }
547 547
 					 */
548
-					$parent_dropdown_args = apply_filters( 'post_edit_category_parent_dropdown_args', $parent_dropdown_args );
548
+					$parent_dropdown_args = apply_filters('post_edit_category_parent_dropdown_args', $parent_dropdown_args);
549 549
 
550
-					wp_dropdown_categories( $parent_dropdown_args );
550
+					wp_dropdown_categories($parent_dropdown_args);
551 551
 					?>
552
-					<input type="button" id="<?php echo $tax_name; ?>-add-submit" data-wp-lists="add:<?php echo $tax_name; ?>checklist:<?php echo $tax_name; ?>-add" class="button category-add-submit" value="<?php echo esc_attr( $taxonomy->labels->add_new_item ); ?>" />
553
-					<?php wp_nonce_field( 'add-' . $tax_name, '_ajax_nonce-add-' . $tax_name, false ); ?>
552
+					<input type="button" id="<?php echo $tax_name; ?>-add-submit" data-wp-lists="add:<?php echo $tax_name; ?>checklist:<?php echo $tax_name; ?>-add" class="button category-add-submit" value="<?php echo esc_attr($taxonomy->labels->add_new_item); ?>" />
553
+					<?php wp_nonce_field('add-'.$tax_name, '_ajax_nonce-add-'.$tax_name, false); ?>
554 554
 					<span id="<?php echo $tax_name; ?>-ajax-response"></span>
555 555
 				</p>
556 556
 			</div>
@@ -572,8 +572,8 @@  discard block
 block discarded – undo
572 572
 <p><?php
573 573
 	printf(
574 574
 		/* translators: %s: Codex URL */
575
-		__( 'Excerpts are optional hand-crafted summaries of your content that can be used in your theme. <a href="%s">Learn more about manual excerpts</a>.' ),
576
-		__( 'https://codex.wordpress.org/Excerpt' )
575
+		__('Excerpts are optional hand-crafted summaries of your content that can be used in your theme. <a href="%s">Learn more about manual excerpts</a>.'),
576
+		__('https://codex.wordpress.org/Excerpt')
577 577
 	);
578 578
 ?></p>
579 579
 <?php
@@ -587,32 +587,32 @@  discard block
 block discarded – undo
587 587
  * @param object $post
588 588
  */
589 589
 function post_trackback_meta_box($post) {
590
-	$form_trackback = '<input type="text" name="trackback_url" id="trackback_url" class="code" value="' .
591
-		esc_attr( str_replace( "\n", ' ', $post->to_ping ) ) . '" aria-describedby="trackback-url-desc" />';
590
+	$form_trackback = '<input type="text" name="trackback_url" id="trackback_url" class="code" value="'.
591
+		esc_attr(str_replace("\n", ' ', $post->to_ping)).'" aria-describedby="trackback-url-desc" />';
592 592
 	if ('' != $post->pinged) {
593
-		$pings = '<p>'. __('Already pinged:') . '</p><ul>';
593
+		$pings = '<p>'.__('Already pinged:').'</p><ul>';
594 594
 		$already_pinged = explode("\n", trim($post->pinged));
595 595
 		foreach ($already_pinged as $pinged_url) {
596
-			$pings .= "\n\t<li>" . esc_html($pinged_url) . "</li>";
596
+			$pings .= "\n\t<li>".esc_html($pinged_url)."</li>";
597 597
 		}
598 598
 		$pings .= '</ul>';
599 599
 	}
600 600
 
601 601
 ?>
602 602
 <p>
603
-	<label for="trackback_url"><?php _e( 'Send trackbacks to:' ); ?></label>
603
+	<label for="trackback_url"><?php _e('Send trackbacks to:'); ?></label>
604 604
 	<?php echo $form_trackback; ?>
605 605
 </p>
606
-<p id="trackback-url-desc" class="howto"><?php _e( 'Separate multiple URLs with spaces' ); ?></p>
606
+<p id="trackback-url-desc" class="howto"><?php _e('Separate multiple URLs with spaces'); ?></p>
607 607
 <p><?php
608 608
 	printf(
609 609
 		/* translators: %s: Codex URL */
610
-		__( 'Trackbacks are a way to notify legacy blog systems that you&#8217;ve linked to them. If you link other WordPress sites, they&#8217;ll be notified automatically using <a href="%s">pingbacks</a>, no other action necessary.' ),
611
-		__( 'https://codex.wordpress.org/Introduction_to_Blogging#Managing_Comments' )
610
+		__('Trackbacks are a way to notify legacy blog systems that you&#8217;ve linked to them. If you link other WordPress sites, they&#8217;ll be notified automatically using <a href="%s">pingbacks</a>, no other action necessary.'),
611
+		__('https://codex.wordpress.org/Introduction_to_Blogging#Managing_Comments')
612 612
 	);
613 613
 ?></p>
614 614
 <?php
615
-if ( ! empty($pings) )
615
+if ( ! empty($pings))
616 616
 	echo $pings;
617 617
 }
618 618
 
@@ -629,18 +629,18 @@  discard block
 block discarded – undo
629 629
 <div id="ajax-response"></div>
630 630
 <?php
631 631
 $metadata = has_meta($post->ID);
632
-foreach ( $metadata as $key => $value ) {
633
-	if ( is_protected_meta( $metadata[ $key ][ 'meta_key' ], 'post' ) || ! current_user_can( 'edit_post_meta', $post->ID, $metadata[ $key ][ 'meta_key' ] ) )
634
-		unset( $metadata[ $key ] );
632
+foreach ($metadata as $key => $value) {
633
+	if (is_protected_meta($metadata[$key]['meta_key'], 'post') || ! current_user_can('edit_post_meta', $post->ID, $metadata[$key]['meta_key']))
634
+		unset($metadata[$key]);
635 635
 }
636
-list_meta( $metadata );
637
-meta_form( $post ); ?>
636
+list_meta($metadata);
637
+meta_form($post); ?>
638 638
 </div>
639 639
 <p><?php
640 640
 	printf(
641 641
 		/* translators: %s: Codex URL */
642
-		__( 'Custom fields can be used to add extra metadata to a post that you can <a href="%s">use in your theme</a>.' ),
643
-		__( 'https://codex.wordpress.org/Using_Custom_Fields' )
642
+		__('Custom fields can be used to add extra metadata to a post that you can <a href="%s">use in your theme</a>.'),
643
+		__('https://codex.wordpress.org/Using_Custom_Fields')
644 644
 	);
645 645
 ?></p>
646 646
 <?php
@@ -657,12 +657,12 @@  discard block
 block discarded – undo
657 657
 ?>
658 658
 <input name="advanced_view" type="hidden" value="1" />
659 659
 <p class="meta-options">
660
-	<label for="comment_status" class="selectit"><input name="comment_status" type="checkbox" id="comment_status" value="open" <?php checked($post->comment_status, 'open'); ?> /> <?php _e( 'Allow comments.' ) ?></label><br />
660
+	<label for="comment_status" class="selectit"><input name="comment_status" type="checkbox" id="comment_status" value="open" <?php checked($post->comment_status, 'open'); ?> /> <?php _e('Allow comments.') ?></label><br />
661 661
 	<label for="ping_status" class="selectit"><input name="ping_status" type="checkbox" id="ping_status" value="open" <?php checked($post->ping_status, 'open'); ?> /> <?php
662 662
 		printf(
663 663
 			/* translators: %s: Codex URL */
664
-			__( 'Allow <a href="%s">trackbacks and pingbacks</a> on this page.' ),
665
-			__( 'https://codex.wordpress.org/Introduction_to_Blogging#Managing_Comments' ) );
664
+			__('Allow <a href="%s">trackbacks and pingbacks</a> on this page.'),
665
+			__('https://codex.wordpress.org/Introduction_to_Blogging#Managing_Comments') );
666 666
 		?></label>
667 667
 	<?php
668 668
 	/**
@@ -672,7 +672,7 @@  discard block
 block discarded – undo
672 672
 	 *
673 673
 	 * @param WP_Post $post WP_Post object of the current post.
674 674
 	 */
675
-	do_action( 'post_comment_status_meta_box-options', $post );
675
+	do_action('post_comment_status_meta_box-options', $post);
676 676
 	?>
677 677
 </p>
678 678
 <?php
@@ -698,21 +698,21 @@  discard block
 block discarded – undo
698 698
  *
699 699
  * @param object $post
700 700
  */
701
-function post_comment_meta_box( $post ) {
702
-	wp_nonce_field( 'get-comments', 'add_comment_nonce', false );
701
+function post_comment_meta_box($post) {
702
+	wp_nonce_field('get-comments', 'add_comment_nonce', false);
703 703
 	?>
704 704
 	<p class="hide-if-no-js" id="add-new-comment"><a class="button" href="#commentstatusdiv" onclick="window.commentReply && commentReply.addcomment(<?php echo $post->ID; ?>);return false;"><?php _e('Add comment'); ?></a></p>
705 705
 	<?php
706 706
 
707
-	$total = get_comments( array( 'post_id' => $post->ID, 'number' => 1, 'count' => true ) );
707
+	$total = get_comments(array('post_id' => $post->ID, 'number' => 1, 'count' => true));
708 708
 	$wp_list_table = _get_list_table('WP_Post_Comments_List_Table');
709
-	$wp_list_table->display( true );
709
+	$wp_list_table->display(true);
710 710
 
711
-	if ( 1 > $total ) {
712
-		echo '<p id="no-comments">' . __('No comments yet.') . '</p>';
711
+	if (1 > $total) {
712
+		echo '<p id="no-comments">'.__('No comments yet.').'</p>';
713 713
 	} else {
714
-		$hidden = get_hidden_meta_boxes( get_current_screen() );
715
-		if ( ! in_array('commentsdiv', $hidden) ) {
714
+		$hidden = get_hidden_meta_boxes(get_current_screen());
715
+		if ( ! in_array('commentsdiv', $hidden)) {
716 716
 			?>
717 717
 			<script type="text/javascript">jQuery(document).ready(function(){commentsBox.get(<?php echo $total; ?>, 10);});</script>
718 718
 			<?php
@@ -735,9 +735,9 @@  discard block
 block discarded – undo
735 735
  */
736 736
 function post_slug_meta_box($post) {
737 737
 /** This filter is documented in wp-admin/edit-tag-form.php */
738
-$editable_slug = apply_filters( 'editable_slug', $post->post_name, $post );
738
+$editable_slug = apply_filters('editable_slug', $post->post_name, $post);
739 739
 ?>
740
-<label class="screen-reader-text" for="post_name"><?php _e('Slug') ?></label><input name="post_name" type="text" size="13" id="post_name" value="<?php echo esc_attr( $editable_slug ); ?>" />
740
+<label class="screen-reader-text" for="post_name"><?php _e('Slug') ?></label><input name="post_name" type="text" size="13" id="post_name" value="<?php echo esc_attr($editable_slug); ?>" />
741 741
 <?php
742 742
 }
743 743
 
@@ -755,13 +755,13 @@  discard block
 block discarded – undo
755 755
 ?>
756 756
 <label class="screen-reader-text" for="post_author_override"><?php _e('Author'); ?></label>
757 757
 <?php
758
-	wp_dropdown_users( array(
758
+	wp_dropdown_users(array(
759 759
 		'who' => 'authors',
760 760
 		'name' => 'post_author_override',
761 761
 		'selected' => empty($post->ID) ? $user_ID : $post->post_author,
762 762
 		'include_selected' => true,
763 763
 		'show' => 'display_name_with_login',
764
-	) );
764
+	));
765 765
 }
766 766
 
767 767
 /**
@@ -771,8 +771,8 @@  discard block
 block discarded – undo
771 771
  *
772 772
  * @param object $post
773 773
  */
774
-function post_revisions_meta_box( $post ) {
775
-	wp_list_post_revisions( $post );
774
+function post_revisions_meta_box($post) {
775
+	wp_list_post_revisions($post);
776 776
 }
777 777
 
778 778
 // -- Page related Meta Boxes
@@ -786,7 +786,7 @@  discard block
 block discarded – undo
786 786
  */
787 787
 function page_attributes_meta_box($post) {
788 788
 	$post_type_object = get_post_type_object($post->post_type);
789
-	if ( $post_type_object->hierarchical ) {
789
+	if ($post_type_object->hierarchical) {
790 790
 		$dropdown_args = array(
791 791
 			'post_type'        => $post->post_type,
792 792
 			'exclude_tree'     => $post->ID,
@@ -807,9 +807,9 @@  discard block
 block discarded – undo
807 807
 		 * @param array   $dropdown_args Array of arguments used to generate the pages drop-down.
808 808
 		 * @param WP_Post $post          The current WP_Post object.
809 809
 		 */
810
-		$dropdown_args = apply_filters( 'page_attributes_dropdown_pages_args', $dropdown_args, $post );
811
-		$pages = wp_dropdown_pages( $dropdown_args );
812
-		if ( ! empty($pages) ) {
810
+		$dropdown_args = apply_filters('page_attributes_dropdown_pages_args', $dropdown_args, $post);
811
+		$pages = wp_dropdown_pages($dropdown_args);
812
+		if ( ! empty($pages)) {
813 813
 ?>
814 814
 <p><strong><?php _e('Parent') ?></strong></p>
815 815
 <label class="screen-reader-text" for="parent_id"><?php _e('Parent') ?></label>
@@ -817,8 +817,8 @@  discard block
 block discarded – undo
817 817
 <?php
818 818
 		} // end empty pages check
819 819
 	} // end hierarchical check.
820
-	if ( 'page' == $post->post_type && 0 != count( get_page_templates( $post ) ) && get_option( 'page_for_posts' ) != $post->ID ) {
821
-		$template = !empty($post->page_template) ? $post->page_template : false;
820
+	if ('page' == $post->post_type && 0 != count(get_page_templates($post)) && get_option('page_for_posts') != $post->ID) {
821
+		$template = ! empty($post->page_template) ? $post->page_template : false;
822 822
 		?>
823 823
 <p><strong><?php _e('Template') ?></strong><?php
824 824
 	/**
@@ -830,7 +830,7 @@  discard block
 block discarded – undo
830 830
 	 * @param string  $template The template used for the current post.
831 831
 	 * @param WP_Post $post     The current post.
832 832
 	 */
833
-	do_action( 'page_attributes_meta_box_template', $template, $post );
833
+	do_action('page_attributes_meta_box_template', $template, $post);
834 834
 ?></p>
835 835
 <label class="screen-reader-text" for="page_template"><?php _e('Page Template') ?></label><select name="page_template" id="page_template">
836 836
 <?php
@@ -843,17 +843,17 @@  discard block
 block discarded – undo
843 843
  * @param string $context Where the option label is displayed. Possible values
844 844
  *                        include 'meta-box' or 'quick-edit'.
845 845
  */
846
-$default_title = apply_filters( 'default_page_template_title',  __( 'Default Template' ), 'meta-box' );
846
+$default_title = apply_filters('default_page_template_title', __('Default Template'), 'meta-box');
847 847
 ?>
848
-<option value="default"><?php echo esc_html( $default_title ); ?></option>
848
+<option value="default"><?php echo esc_html($default_title); ?></option>
849 849
 <?php page_template_dropdown($template); ?>
850 850
 </select>
851 851
 <?php
852 852
 	} ?>
853 853
 <p><strong><?php _e('Order') ?></strong></p>
854 854
 <p><label class="screen-reader-text" for="menu_order"><?php _e('Order') ?></label><input name="menu_order" type="text" size="4" id="menu_order" value="<?php echo esc_attr($post->menu_order) ?>" /></p>
855
-<?php if ( 'page' == $post->post_type && get_current_screen()->get_help_tabs() ) { ?>
856
-<p><?php _e( 'Need help? Use the Help tab in the upper right of your screen.' ); ?></p>
855
+<?php if ('page' == $post->post_type && get_current_screen()->get_help_tabs()) { ?>
856
+<p><?php _e('Need help? Use the Help tab in the upper right of your screen.'); ?></p>
857 857
 <?php
858 858
 	}
859 859
 }
@@ -875,12 +875,12 @@  discard block
 block discarded – undo
875 875
 
876 876
 <?php // Hidden submit button early on so that the browser chooses the right button when form is submitted with Return key ?>
877 877
 <div style="display:none;">
878
-<?php submit_button( __( 'Save' ), 'button', 'save', false ); ?>
878
+<?php submit_button(__('Save'), 'button', 'save', false); ?>
879 879
 </div>
880 880
 
881 881
 <div id="minor-publishing-actions">
882 882
 <div id="preview-action">
883
-<?php if ( !empty($link->link_id) ) { ?>
883
+<?php if ( ! empty($link->link_id)) { ?>
884 884
 	<a class="preview button" href="<?php echo $link->link_url; ?>" target="_blank"><?php _e('Visit Link'); ?></a>
885 885
 <?php } ?>
886 886
 </div>
@@ -898,20 +898,20 @@  discard block
 block discarded – undo
898 898
 <div id="major-publishing-actions">
899 899
 <?php
900 900
 /** This action is documented in wp-admin/includes/meta-boxes.php */
901
-do_action( 'post_submitbox_start' );
901
+do_action('post_submitbox_start');
902 902
 ?>
903 903
 <div id="delete-action">
904 904
 <?php
905
-if ( !empty($_GET['action']) && 'edit' == $_GET['action'] && current_user_can('manage_links') ) { ?>
906
-	<a class="submitdelete deletion" href="<?php echo wp_nonce_url("link.php?action=delete&amp;link_id=$link->link_id", 'delete-bookmark_' . $link->link_id); ?>" onclick="if ( confirm('<?php echo esc_js(sprintf(__("You are about to delete this link '%s'\n  'Cancel' to stop, 'OK' to delete."), $link->link_name )); ?>') ) {return true;}return false;"><?php _e('Delete'); ?></a>
905
+if ( ! empty($_GET['action']) && 'edit' == $_GET['action'] && current_user_can('manage_links')) { ?>
906
+	<a class="submitdelete deletion" href="<?php echo wp_nonce_url("link.php?action=delete&amp;link_id=$link->link_id", 'delete-bookmark_'.$link->link_id); ?>" onclick="if ( confirm('<?php echo esc_js(sprintf(__("You are about to delete this link '%s'\n  'Cancel' to stop, 'OK' to delete."), $link->link_name)); ?>') ) {return true;}return false;"><?php _e('Delete'); ?></a>
907 907
 <?php } ?>
908 908
 </div>
909 909
 
910 910
 <div id="publishing-action">
911
-<?php if ( !empty($link->link_id) ) { ?>
912
-	<input name="save" type="submit" class="button-large button-primary" id="publish" value="<?php esc_attr_e( 'Update Link' ) ?>" />
911
+<?php if ( ! empty($link->link_id)) { ?>
912
+	<input name="save" type="submit" class="button-large button-primary" id="publish" value="<?php esc_attr_e('Update Link') ?>" />
913 913
 <?php } else { ?>
914
-	<input name="save" type="submit" class="button-large button-primary" id="publish" value="<?php esc_attr_e( 'Add Link' ) ?>" />
914
+	<input name="save" type="submit" class="button-large button-primary" id="publish" value="<?php esc_attr_e('Add Link') ?>" />
915 915
 <?php } ?>
916 916
 </div>
917 917
 <div class="clear"></div>
@@ -922,7 +922,7 @@  discard block
 block discarded – undo
922 922
  *
923 923
  * @since 2.5.0
924 924
  */
925
-do_action( 'submitlink_box' );
925
+do_action('submitlink_box');
926 926
 ?>
927 927
 <div class="clear"></div>
928 928
 </div>
@@ -940,14 +940,14 @@  discard block
 block discarded – undo
940 940
 ?>
941 941
 <div id="taxonomy-linkcategory" class="categorydiv">
942 942
 	<ul id="category-tabs" class="category-tabs">
943
-		<li class="tabs"><a href="#categories-all"><?php _e( 'All Categories' ); ?></a></li>
944
-		<li class="hide-if-no-js"><a href="#categories-pop"><?php _e( 'Most Used' ); ?></a></li>
943
+		<li class="tabs"><a href="#categories-all"><?php _e('All Categories'); ?></a></li>
944
+		<li class="hide-if-no-js"><a href="#categories-pop"><?php _e('Most Used'); ?></a></li>
945 945
 	</ul>
946 946
 
947 947
 	<div id="categories-all" class="tabs-panel">
948 948
 		<ul id="categorychecklist" data-wp-lists="list:category" class="categorychecklist form-no-clear">
949 949
 			<?php
950
-			if ( isset($link->link_id) )
950
+			if (isset($link->link_id))
951 951
 				wp_link_category_checklist($link->link_id);
952 952
 			else
953 953
 				wp_link_category_checklist();
@@ -962,12 +962,12 @@  discard block
 block discarded – undo
962 962
 	</div>
963 963
 
964 964
 	<div id="category-adder" class="wp-hidden-children">
965
-		<a id="category-add-toggle" href="#category-add" class="taxonomy-add-new"><?php _e( '+ Add New Category' ); ?></a>
965
+		<a id="category-add-toggle" href="#category-add" class="taxonomy-add-new"><?php _e('+ Add New Category'); ?></a>
966 966
 		<p id="link-category-add" class="wp-hidden-child">
967
-			<label class="screen-reader-text" for="newcat"><?php _e( '+ Add New Category' ); ?></label>
968
-			<input type="text" name="newcat" id="newcat" class="form-required form-input-tip" value="<?php esc_attr_e( 'New category name' ); ?>" aria-required="true" />
969
-			<input type="button" id="link-category-add-submit" data-wp-lists="add:categorychecklist:link-category-add" class="button" value="<?php esc_attr_e( 'Add' ); ?>" />
970
-			<?php wp_nonce_field( 'add-link-category', '_ajax_nonce', false ); ?>
967
+			<label class="screen-reader-text" for="newcat"><?php _e('+ Add New Category'); ?></label>
968
+			<input type="text" name="newcat" id="newcat" class="form-required form-input-tip" value="<?php esc_attr_e('New category name'); ?>" aria-required="true" />
969
+			<input type="button" id="link-category-add-submit" data-wp-lists="add:categorychecklist:link-category-add" class="button" value="<?php esc_attr_e('Add'); ?>" />
970
+			<?php wp_nonce_field('add-link-category', '_ajax_nonce', false); ?>
971 971
 			<span id="category-ajax-response"></span>
972 972
 		</p>
973 973
 	</div>
@@ -985,13 +985,13 @@  discard block
 block discarded – undo
985 985
 function link_target_meta_box($link) { ?>
986 986
 <fieldset><legend class="screen-reader-text"><span><?php _e('Target') ?></span></legend>
987 987
 <p><label for="link_target_blank" class="selectit">
988
-<input id="link_target_blank" type="radio" name="link_target" value="_blank" <?php echo ( isset( $link->link_target ) && ($link->link_target == '_blank') ? 'checked="checked"' : ''); ?> />
988
+<input id="link_target_blank" type="radio" name="link_target" value="_blank" <?php echo (isset($link->link_target) && ($link->link_target == '_blank') ? 'checked="checked"' : ''); ?> />
989 989
 <?php _e('<code>_blank</code> &mdash; new window or tab.'); ?></label></p>
990 990
 <p><label for="link_target_top" class="selectit">
991
-<input id="link_target_top" type="radio" name="link_target" value="_top" <?php echo ( isset( $link->link_target ) && ($link->link_target == '_top') ? 'checked="checked"' : ''); ?> />
991
+<input id="link_target_top" type="radio" name="link_target" value="_top" <?php echo (isset($link->link_target) && ($link->link_target == '_top') ? 'checked="checked"' : ''); ?> />
992 992
 <?php _e('<code>_top</code> &mdash; current window or tab, with no frames.'); ?></label></p>
993 993
 <p><label for="link_target_none" class="selectit">
994
-<input id="link_target_none" type="radio" name="link_target" value="" <?php echo ( isset( $link->link_target ) && ($link->link_target == '') ? 'checked="checked"' : ''); ?> />
994
+<input id="link_target_none" type="radio" name="link_target" value="" <?php echo (isset($link->link_target) && ($link->link_target == '') ? 'checked="checked"' : ''); ?> />
995 995
 <?php _e('<code>_none</code> &mdash; same window or tab.'); ?></label></p>
996 996
 </fieldset>
997 997
 <p><?php _e('Choose the target frame for your link.'); ?></p>
@@ -1009,16 +1009,16 @@  discard block
 block discarded – undo
1009 1009
  * @param string $value
1010 1010
  * @param mixed $deprecated Never used.
1011 1011
  */
1012
-function xfn_check( $class, $value = '', $deprecated = '' ) {
1012
+function xfn_check($class, $value = '', $deprecated = '') {
1013 1013
 	global $link;
1014 1014
 
1015
-	if ( !empty( $deprecated ) )
1016
-		_deprecated_argument( __FUNCTION__, '0.0' ); // Never implemented
1015
+	if ( ! empty($deprecated))
1016
+		_deprecated_argument(__FUNCTION__, '0.0'); // Never implemented
1017 1017
 
1018
-	$link_rel = isset( $link->link_rel ) ? $link->link_rel : ''; // In PHP 5.3: $link_rel = $link->link_rel ?: '';
1018
+	$link_rel = isset($link->link_rel) ? $link->link_rel : ''; // In PHP 5.3: $link_rel = $link->link_rel ?: '';
1019 1019
 	$rels = preg_split('/\s+/', $link_rel);
1020 1020
 
1021
-	if ('' != $value && in_array($value, $rels) ) {
1021
+	if ('' != $value && in_array($value, $rels)) {
1022 1022
 		echo ' checked="checked"';
1023 1023
 	}
1024 1024
 
@@ -1026,7 +1026,7 @@  discard block
 block discarded – undo
1026 1026
 		if ('family' == $class && strpos($link_rel, 'child') === false && strpos($link_rel, 'parent') === false && strpos($link_rel, 'sibling') === false && strpos($link_rel, 'spouse') === false && strpos($link_rel, 'kin') === false) echo ' checked="checked"';
1027 1027
 		if ('friendship' == $class && strpos($link_rel, 'friend') === false && strpos($link_rel, 'acquaintance') === false && strpos($link_rel, 'contact') === false) echo ' checked="checked"';
1028 1028
 		if ('geographical' == $class && strpos($link_rel, 'co-resident') === false && strpos($link_rel, 'neighbor') === false) echo ' checked="checked"';
1029
-		if ('identity' == $class && in_array('me', $rels) ) echo ' checked="checked"';
1029
+		if ('identity' == $class && in_array('me', $rels)) echo ' checked="checked"';
1030 1030
 	}
1031 1031
 }
1032 1032
 
@@ -1042,7 +1042,7 @@  discard block
 block discarded – undo
1042 1042
 <table class="links-table">
1043 1043
 	<tr>
1044 1044
 		<th scope="row"><label for="link_rel"><?php /* translators: xfn: http://gmpg.org/xfn/ */ _e('rel:') ?></label></th>
1045
-		<td><input type="text" name="link_rel" id="link_rel" value="<?php echo ( isset( $link->link_rel ) ? esc_attr($link->link_rel) : ''); ?>" /></td>
1045
+		<td><input type="text" name="link_rel" id="link_rel" value="<?php echo (isset($link->link_rel) ? esc_attr($link->link_rel) : ''); ?>" /></td>
1046 1046
 	</tr>
1047 1047
 	<tr>
1048 1048
 		<th scope="row"><?php /* translators: xfn: http://gmpg.org/xfn/ */ _e('identity') ?></th>
@@ -1160,25 +1160,25 @@  discard block
 block discarded – undo
1160 1160
 <table class="links-table" cellpadding="0">
1161 1161
 	<tr>
1162 1162
 		<th scope="row"><label for="link_image"><?php _e('Image Address') ?></label></th>
1163
-		<td><input type="text" name="link_image" class="code" id="link_image" maxlength="255" value="<?php echo ( isset( $link->link_image ) ? esc_attr($link->link_image) : ''); ?>" /></td>
1163
+		<td><input type="text" name="link_image" class="code" id="link_image" maxlength="255" value="<?php echo (isset($link->link_image) ? esc_attr($link->link_image) : ''); ?>" /></td>
1164 1164
 	</tr>
1165 1165
 	<tr>
1166 1166
 		<th scope="row"><label for="rss_uri"><?php _e('RSS Address') ?></label></th>
1167
-		<td><input name="link_rss" class="code" type="text" id="rss_uri" maxlength="255" value="<?php echo ( isset( $link->link_rss ) ? esc_attr($link->link_rss) : ''); ?>" /></td>
1167
+		<td><input name="link_rss" class="code" type="text" id="rss_uri" maxlength="255" value="<?php echo (isset($link->link_rss) ? esc_attr($link->link_rss) : ''); ?>" /></td>
1168 1168
 	</tr>
1169 1169
 	<tr>
1170 1170
 		<th scope="row"><label for="link_notes"><?php _e('Notes') ?></label></th>
1171
-		<td><textarea name="link_notes" id="link_notes" rows="10"><?php echo ( isset( $link->link_notes ) ? $link->link_notes : ''); // textarea_escaped ?></textarea></td>
1171
+		<td><textarea name="link_notes" id="link_notes" rows="10"><?php echo (isset($link->link_notes) ? $link->link_notes : ''); // textarea_escaped ?></textarea></td>
1172 1172
 	</tr>
1173 1173
 	<tr>
1174 1174
 		<th scope="row"><label for="link_rating"><?php _e('Rating') ?></label></th>
1175 1175
 		<td><select name="link_rating" id="link_rating" size="1">
1176 1176
 		<?php
1177
-			for ( $r = 0; $r <= 10; $r++ ) {
1178
-				echo '<option value="' . $r . '"';
1179
-				if ( isset($link->link_rating) && $link->link_rating == $r )
1177
+			for ($r = 0; $r <= 10; $r++) {
1178
+				echo '<option value="'.$r.'"';
1179
+				if (isset($link->link_rating) && $link->link_rating == $r)
1180 1180
 					echo ' selected="selected"';
1181
-				echo('>' . $r . '</option>');
1181
+				echo('>'.$r.'</option>');
1182 1182
 			}
1183 1183
 		?></select>&nbsp;<?php _e('(Leave at 0 for no rating.)') ?>
1184 1184
 		</td>
@@ -1194,9 +1194,9 @@  discard block
 block discarded – undo
1194 1194
  *
1195 1195
  * @param WP_Post $post A post object.
1196 1196
  */
1197
-function post_thumbnail_meta_box( $post ) {
1198
-	$thumbnail_id = get_post_meta( $post->ID, '_thumbnail_id', true );
1199
-	echo _wp_post_thumbnail_html( $thumbnail_id, $post->ID );
1197
+function post_thumbnail_meta_box($post) {
1198
+	$thumbnail_id = get_post_meta($post->ID, '_thumbnail_id', true);
1199
+	echo _wp_post_thumbnail_html($thumbnail_id, $post->ID);
1200 1200
 }
1201 1201
 
1202 1202
 /**
@@ -1206,18 +1206,18 @@  discard block
 block discarded – undo
1206 1206
  *
1207 1207
  * @param WP_Post $post A post object.
1208 1208
  */
1209
-function attachment_id3_data_meta_box( $post ) {
1209
+function attachment_id3_data_meta_box($post) {
1210 1210
 	$meta = array();
1211
-	if ( ! empty( $post->ID ) ) {
1212
-		$meta = wp_get_attachment_metadata( $post->ID );
1211
+	if ( ! empty($post->ID)) {
1212
+		$meta = wp_get_attachment_metadata($post->ID);
1213 1213
 	}
1214 1214
 
1215
-	foreach ( wp_get_attachment_id3_keys( $post, 'edit' ) as $key => $label ) : ?>
1215
+	foreach (wp_get_attachment_id3_keys($post, 'edit') as $key => $label) : ?>
1216 1216
 	<p>
1217 1217
 		<label for="title"><?php echo $label ?></label><br />
1218
-		<input type="text" name="id3_<?php echo esc_attr( $key ) ?>" id="id3_<?php echo esc_attr( $key ) ?>" class="large-text" value="<?php
1219
-			if ( ! empty( $meta[ $key ] ) ) {
1220
-				echo esc_attr( $meta[ $key ] );
1218
+		<input type="text" name="id3_<?php echo esc_attr($key) ?>" id="id3_<?php echo esc_attr($key) ?>" class="large-text" value="<?php
1219
+			if ( ! empty($meta[$key])) {
1220
+				echo esc_attr($meta[$key]);
1221 1221
 			}
1222 1222
 		?>" />
1223 1223
 	</p>
Please login to merge, or discard this patch.
src/wp-admin/includes/class-wp-plugin-install-list-table.php 3 patches
Indentation   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -1,11 +1,11 @@
 block discarded – undo
1 1
 <?php
2 2
 /**
3
- * List Table API: WP_Plugin_Install_List_Table class
4
- *
5
- * @package WordPress
6
- * @subpackage Administration
7
- * @since 3.1.0
8
- */
3
+	 * List Table API: WP_Plugin_Install_List_Table class
4
+	 *
5
+	 * @package WordPress
6
+	 * @subpackage Administration
7
+	 * @since 3.1.0
8
+	 */
9 9
 
10 10
 /**
11 11
  * Core class used to implement displaying plugins to install in a list table.
Please login to merge, or discard this patch.
Spacing   +129 added lines, -129 removed lines patch added patch discarded remove patch
@@ -46,15 +46,15 @@  discard block
 block discarded – undo
46 46
 	protected function get_installed_plugin_slugs() {
47 47
 		$slugs = array();
48 48
 
49
-		$plugin_info = get_site_transient( 'update_plugins' );
50
-		if ( isset( $plugin_info->no_update ) ) {
51
-			foreach ( $plugin_info->no_update as $plugin ) {
49
+		$plugin_info = get_site_transient('update_plugins');
50
+		if (isset($plugin_info->no_update)) {
51
+			foreach ($plugin_info->no_update as $plugin) {
52 52
 				$slugs[] = $plugin->slug;
53 53
 			}
54 54
 		}
55 55
 
56
-		if ( isset( $plugin_info->response ) ) {
57
-			foreach ( $plugin_info->response as $plugin ) {
56
+		if (isset($plugin_info->response)) {
57
+			foreach ($plugin_info->response as $plugin) {
58 58
 				$slugs[] = $plugin->slug;
59 59
 			}
60 60
 		}
@@ -72,11 +72,11 @@  discard block
 block discarded – undo
72 72
 	 * @global string $wp_version
73 73
 	 */
74 74
 	public function prepare_items() {
75
-		include( ABSPATH . 'wp-admin/includes/plugin-install.php' );
75
+		include(ABSPATH.'wp-admin/includes/plugin-install.php');
76 76
 
77 77
 		global $tabs, $tab, $paged, $type, $term;
78 78
 
79
-		wp_reset_vars( array( 'tab' ) );
79
+		wp_reset_vars(array('tab'));
80 80
 
81 81
 		$paged = $this->get_pagenum();
82 82
 
@@ -85,23 +85,23 @@  discard block
 block discarded – undo
85 85
 		// These are the tabs which are shown on the page
86 86
 		$tabs = array();
87 87
 
88
-		if ( 'search' === $tab ) {
89
-			$tabs['search'] = __( 'Search Results' );
88
+		if ('search' === $tab) {
89
+			$tabs['search'] = __('Search Results');
90 90
 		}
91
-		if ( $tab === 'beta' || false !== strpos( $GLOBALS['wp_version'], '-' ) ) {
92
-			$tabs['beta'] = _x( 'Beta Testing', 'Plugin Installer' );
91
+		if ($tab === 'beta' || false !== strpos($GLOBALS['wp_version'], '-')) {
92
+			$tabs['beta'] = _x('Beta Testing', 'Plugin Installer');
93 93
 		}
94
-		$tabs['featured']    = _x( 'Featured', 'Plugin Installer' );
95
-		$tabs['popular']     = _x( 'Popular', 'Plugin Installer' );
96
-		$tabs['recommended'] = _x( 'Recommended', 'Plugin Installer' );
97
-		$tabs['favorites']   = _x( 'Favorites', 'Plugin Installer' );
98
-		if ( current_user_can( 'upload_plugins' ) ) {
94
+		$tabs['featured']    = _x('Featured', 'Plugin Installer');
95
+		$tabs['popular']     = _x('Popular', 'Plugin Installer');
96
+		$tabs['recommended'] = _x('Recommended', 'Plugin Installer');
97
+		$tabs['favorites']   = _x('Favorites', 'Plugin Installer');
98
+		if (current_user_can('upload_plugins')) {
99 99
 			// No longer a real tab. Here for filter compatibility.
100 100
 			// Gets skipped in get_views().
101
-			$tabs['upload'] = __( 'Upload Plugin' );
101
+			$tabs['upload'] = __('Upload Plugin');
102 102
 		}
103 103
 
104
-		$nonmenu_tabs = array( 'plugin-information' ); // Valid actions to perform which do not have a Menu item.
104
+		$nonmenu_tabs = array('plugin-information'); // Valid actions to perform which do not have a Menu item.
105 105
 
106 106
 		/**
107 107
 		 * Filter the tabs shown on the Plugin Install screen.
@@ -111,7 +111,7 @@  discard block
 block discarded – undo
111 111
 		 * @param array $tabs The tabs shown on the Plugin Install screen. Defaults include 'featured', 'popular',
112 112
 		 *                    'recommended', 'favorites', and 'upload'.
113 113
 		 */
114
-		$tabs = apply_filters( 'install_plugins_tabs', $tabs );
114
+		$tabs = apply_filters('install_plugins_tabs', $tabs);
115 115
 
116 116
 		/**
117 117
 		 * Filter tabs not associated with a menu item on the Plugin Install screen.
@@ -120,11 +120,11 @@  discard block
 block discarded – undo
120 120
 		 *
121 121
 		 * @param array $nonmenu_tabs The tabs that don't have a Menu item on the Plugin Install screen.
122 122
 		 */
123
-		$nonmenu_tabs = apply_filters( 'install_plugins_nonmenu_tabs', $nonmenu_tabs );
123
+		$nonmenu_tabs = apply_filters('install_plugins_nonmenu_tabs', $nonmenu_tabs);
124 124
 
125 125
 		// If a non-valid menu tab has been selected, And it's not a non-menu action.
126
-		if ( empty( $tab ) || ( !isset( $tabs[ $tab ] ) && !in_array( $tab, (array) $nonmenu_tabs ) ) )
127
-			$tab = key( $tabs );
126
+		if (empty($tab) || ( ! isset($tabs[$tab]) && ! in_array($tab, (array) $nonmenu_tabs)))
127
+			$tab = key($tabs);
128 128
 
129 129
 		$args = array(
130 130
 			'page' => $paged,
@@ -139,14 +139,14 @@  discard block
 block discarded – undo
139 139
 			'installed_plugins' => $this->get_installed_plugin_slugs(),
140 140
 		);
141 141
 
142
-		switch ( $tab ) {
142
+		switch ($tab) {
143 143
 			case 'search':
144
-				$type = isset( $_REQUEST['type'] ) ? wp_unslash( $_REQUEST['type'] ) : 'term';
145
-				$term = isset( $_REQUEST['s'] ) ? wp_unslash( $_REQUEST['s'] ) : '';
144
+				$type = isset($_REQUEST['type']) ? wp_unslash($_REQUEST['type']) : 'term';
145
+				$term = isset($_REQUEST['s']) ? wp_unslash($_REQUEST['s']) : '';
146 146
 
147
-				switch ( $type ) {
147
+				switch ($type) {
148 148
 					case 'tag':
149
-						$args['tag'] = sanitize_title_with_dashes( $term );
149
+						$args['tag'] = sanitize_title_with_dashes($term);
150 150
 						break;
151 151
 					case 'term':
152 152
 						$args['search'] = $term;
@@ -170,14 +170,14 @@  discard block
 block discarded – undo
170 170
 				break;
171 171
 
172 172
 			case 'favorites':
173
-				$user = isset( $_GET['user'] ) ? wp_unslash( $_GET['user'] ) : get_user_option( 'wporg_favorites' );
174
-				update_user_meta( get_current_user_id(), 'wporg_favorites', $user );
175
-				if ( $user )
173
+				$user = isset($_GET['user']) ? wp_unslash($_GET['user']) : get_user_option('wporg_favorites');
174
+				update_user_meta(get_current_user_id(), 'wporg_favorites', $user);
175
+				if ($user)
176 176
 					$args['user'] = $user;
177 177
 				else
178 178
 					$args = false;
179 179
 
180
-				add_action( 'install_plugins_favorites', 'install_plugins_favorites_form', 9, 0 );
180
+				add_action('install_plugins_favorites', 'install_plugins_favorites_form', 9, 0);
181 181
 				break;
182 182
 
183 183
 			default:
@@ -195,30 +195,30 @@  discard block
 block discarded – undo
195 195
 		 *
196 196
 		 * @param array|bool $args Plugin Install API arguments.
197 197
 		 */
198
-		$args = apply_filters( "install_plugins_table_api_args_$tab", $args );
198
+		$args = apply_filters("install_plugins_table_api_args_$tab", $args);
199 199
 
200
-		if ( !$args )
200
+		if ( ! $args)
201 201
 			return;
202 202
 
203
-		$api = plugins_api( 'query_plugins', $args );
203
+		$api = plugins_api('query_plugins', $args);
204 204
 
205
-		if ( is_wp_error( $api ) ) {
205
+		if (is_wp_error($api)) {
206 206
 			$this->error = $api;
207 207
 			return;
208 208
 		}
209 209
 
210 210
 		$this->items = $api->plugins;
211 211
 
212
-		if ( $this->orderby ) {
213
-			uasort( $this->items, array( $this, 'order_callback' ) );
212
+		if ($this->orderby) {
213
+			uasort($this->items, array($this, 'order_callback'));
214 214
 		}
215 215
 
216
-		$this->set_pagination_args( array(
216
+		$this->set_pagination_args(array(
217 217
 			'total_items' => $api->info['results'],
218 218
 			'per_page' => $args['per_page'],
219
-		) );
219
+		));
220 220
 
221
-		if ( isset( $api->info['groups'] ) ) {
221
+		if (isset($api->info['groups'])) {
222 222
 			$this->groups = $api->info['groups'];
223 223
 		}
224 224
 	}
@@ -227,12 +227,12 @@  discard block
 block discarded – undo
227 227
 	 * @access public
228 228
 	 */
229 229
 	public function no_items() {
230
-		if ( isset( $this->error ) ) {
231
-			$message = $this->error->get_error_message() . '<p class="hide-if-no-js"><a href="#" class="button" onclick="document.location.reload(); return false;">' . __( 'Try again' ) . '</a></p>';
230
+		if (isset($this->error)) {
231
+			$message = $this->error->get_error_message().'<p class="hide-if-no-js"><a href="#" class="button" onclick="document.location.reload(); return false;">'.__('Try again').'</a></p>';
232 232
 		} else {
233
-			$message = __( 'No plugins match your request.' );
233
+			$message = __('No plugins match your request.');
234 234
 		}
235
-		echo '<div class="no-plugin-results">' . $message . '</div>';
235
+		echo '<div class="no-plugin-results">'.$message.'</div>';
236 236
 	}
237 237
 
238 238
 	/**
@@ -246,13 +246,13 @@  discard block
 block discarded – undo
246 246
 		global $tabs, $tab;
247 247
 
248 248
 		$display_tabs = array();
249
-		foreach ( (array) $tabs as $action => $text ) {
250
-			$class = ( $action === $tab ) ? ' current' : '';
251
-			$href = self_admin_url('plugin-install.php?tab=' . $action);
249
+		foreach ((array) $tabs as $action => $text) {
250
+			$class = ($action === $tab) ? ' current' : '';
251
+			$href = self_admin_url('plugin-install.php?tab='.$action);
252 252
 			$display_tabs['plugin-install-'.$action] = "<a href='$href' class='$class'>$text</a>";
253 253
 		}
254 254
 		// No longer a real tab.
255
-		unset( $display_tabs['plugin-install-upload'] );
255
+		unset($display_tabs['plugin-install-upload']);
256 256
 
257 257
 		return $display_tabs;
258 258
 	}
@@ -264,23 +264,23 @@  discard block
 block discarded – undo
264 264
 		$views = $this->get_views();
265 265
 
266 266
 		/** This filter is documented in wp-admin/inclues/class-wp-list-table.php */
267
-		$views = apply_filters( "views_{$this->screen->id}", $views );
267
+		$views = apply_filters("views_{$this->screen->id}", $views);
268 268
 
269
-		$this->screen->render_screen_reader_content( 'heading_views' );
269
+		$this->screen->render_screen_reader_content('heading_views');
270 270
 ?>
271 271
 <div class="wp-filter">
272 272
 	<ul class="filter-links">
273 273
 		<?php
274
-		if ( ! empty( $views ) ) {
275
-			foreach ( $views as $class => $view ) {
276
-				$views[ $class ] = "\t<li class='$class'>$view";
274
+		if ( ! empty($views)) {
275
+			foreach ($views as $class => $view) {
276
+				$views[$class] = "\t<li class='$class'>$view";
277 277
 			}
278
-			echo implode( " </li>\n", $views ) . "</li>\n";
278
+			echo implode(" </li>\n", $views)."</li>\n";
279 279
 		}
280 280
 		?>
281 281
 	</ul>
282 282
 
283
-	<?php install_search_form( isset( $views['plugin-install-search'] ) ); ?>
283
+	<?php install_search_form(isset($views['plugin-install-search'])); ?>
284 284
 </div>
285 285
 <?php
286 286
 	}
@@ -293,23 +293,23 @@  discard block
 block discarded – undo
293 293
 
294 294
 		$data_attr = '';
295 295
 
296
-		if ( $singular ) {
296
+		if ($singular) {
297 297
 			$data_attr = " data-wp-lists='list:$singular'";
298 298
 		}
299 299
 
300
-		$this->display_tablenav( 'top' );
300
+		$this->display_tablenav('top');
301 301
 
302 302
 ?>
303
-<div class="wp-list-table <?php echo implode( ' ', $this->get_table_classes() ); ?>">
303
+<div class="wp-list-table <?php echo implode(' ', $this->get_table_classes()); ?>">
304 304
 <?php
305
-	$this->screen->render_screen_reader_content( 'heading_list' );
305
+	$this->screen->render_screen_reader_content('heading_list');
306 306
 ?>
307 307
 	<div id="the-list"<?php echo $data_attr; ?>>
308 308
 		<?php $this->display_rows_or_placeholder(); ?>
309 309
 	</div>
310 310
 </div>
311 311
 <?php
312
-		$this->display_tablenav( 'bottom' );
312
+		$this->display_tablenav('bottom');
313 313
 	}
314 314
 
315 315
 	/**
@@ -317,12 +317,12 @@  discard block
 block discarded – undo
317 317
 	 *
318 318
 	 * @param string $which
319 319
 	 */
320
-	protected function display_tablenav( $which ) {
321
-		if ( $GLOBALS['tab'] === 'featured' ) {
320
+	protected function display_tablenav($which) {
321
+		if ($GLOBALS['tab'] === 'featured') {
322 322
 			return;
323 323
 		}
324 324
 
325
-		if ( 'top' === $which ) {
325
+		if ('top' === $which) {
326 326
 			wp_referer_field();
327 327
 		?>
328 328
 			<div class="tablenav top">
@@ -333,14 +333,14 @@  discard block
 block discarded – undo
333 333
 					 *
334 334
 					 * @since 2.7.0
335 335
 					 */
336
-					do_action( 'install_plugins_table_header' ); ?>
336
+					do_action('install_plugins_table_header'); ?>
337 337
 				</div>
338
-				<?php $this->pagination( $which ); ?>
338
+				<?php $this->pagination($which); ?>
339 339
 				<br class="clear" />
340 340
 			</div>
341 341
 		<?php } else { ?>
342 342
 			<div class="tablenav bottom">
343
-				<?php $this->pagination( $which ); ?>
343
+				<?php $this->pagination($which); ?>
344 344
 				<br class="clear" />
345 345
 			</div>
346 346
 		<?php
@@ -351,7 +351,7 @@  discard block
 block discarded – undo
351 351
 	 * @return array
352 352
 	 */
353 353
 	protected function get_table_classes() {
354
-		return array( 'widefat', $this->_args['plural'] );
354
+		return array('widefat', $this->_args['plural']);
355 355
 	}
356 356
 
357 357
 	/**
@@ -366,23 +366,23 @@  discard block
 block discarded – undo
366 366
 	 * @param object $plugin_b
367 367
 	 * @return int
368 368
 	 */
369
-	private function order_callback( $plugin_a, $plugin_b ) {
369
+	private function order_callback($plugin_a, $plugin_b) {
370 370
 		$orderby = $this->orderby;
371
-		if ( ! isset( $plugin_a->$orderby, $plugin_b->$orderby ) ) {
371
+		if ( ! isset($plugin_a->$orderby, $plugin_b->$orderby)) {
372 372
 			return 0;
373 373
 		}
374 374
 
375 375
 		$a = $plugin_a->$orderby;
376 376
 		$b = $plugin_b->$orderby;
377 377
 
378
-		if ( $a == $b ) {
378
+		if ($a == $b) {
379 379
 			return 0;
380 380
 		}
381 381
 
382
-		if ( 'DESC' === $this->order ) {
383
-			return ( $a < $b ) ? 1 : -1;
382
+		if ('DESC' === $this->order) {
383
+			return ($a < $b) ? 1 : -1;
384 384
 		} else {
385
-			return ( $a < $b ) ? -1 : 1;
385
+			return ($a < $b) ? -1 : 1;
386 386
 		}
387 387
 	}
388 388
 
@@ -391,98 +391,98 @@  discard block
 block discarded – undo
391 391
 	 */
392 392
 	public function display_rows() {
393 393
 		$plugins_allowedtags = array(
394
-			'a' => array( 'href' => array(),'title' => array(), 'target' => array() ),
395
-			'abbr' => array( 'title' => array() ),'acronym' => array( 'title' => array() ),
396
-			'code' => array(), 'pre' => array(), 'em' => array(),'strong' => array(),
394
+			'a' => array('href' => array(), 'title' => array(), 'target' => array()),
395
+			'abbr' => array('title' => array()), 'acronym' => array('title' => array()),
396
+			'code' => array(), 'pre' => array(), 'em' => array(), 'strong' => array(),
397 397
 			'ul' => array(), 'ol' => array(), 'li' => array(), 'p' => array(), 'br' => array()
398 398
 		);
399 399
 
400 400
 		$plugins_group_titles = array(
401
-			'Performance' => _x( 'Performance', 'Plugin installer group title' ),
402
-			'Social'      => _x( 'Social',      'Plugin installer group title' ),
403
-			'Tools'       => _x( 'Tools',       'Plugin installer group title' ),
401
+			'Performance' => _x('Performance', 'Plugin installer group title'),
402
+			'Social'      => _x('Social', 'Plugin installer group title'),
403
+			'Tools'       => _x('Tools', 'Plugin installer group title'),
404 404
 		);
405 405
 
406 406
 		$group = null;
407 407
 
408
-		foreach ( (array) $this->items as $plugin ) {
409
-			if ( is_object( $plugin ) ) {
408
+		foreach ((array) $this->items as $plugin) {
409
+			if (is_object($plugin)) {
410 410
 				$plugin = (array) $plugin;
411 411
 			}
412 412
 
413 413
 			// Display the group heading if there is one
414
-			if ( isset( $plugin['group'] ) && $plugin['group'] != $group ) {
415
-				if ( isset( $this->groups[ $plugin['group'] ] ) ) {
416
-					$group_name = $this->groups[ $plugin['group'] ];
417
-					if ( isset( $plugins_group_titles[ $group_name ] ) ) {
418
-						$group_name = $plugins_group_titles[ $group_name ];
414
+			if (isset($plugin['group']) && $plugin['group'] != $group) {
415
+				if (isset($this->groups[$plugin['group']])) {
416
+					$group_name = $this->groups[$plugin['group']];
417
+					if (isset($plugins_group_titles[$group_name])) {
418
+						$group_name = $plugins_group_titles[$group_name];
419 419
 					}
420 420
 				} else {
421 421
 					$group_name = $plugin['group'];
422 422
 				}
423 423
 
424 424
 				// Starting a new group, close off the divs of the last one
425
-				if ( ! empty( $group ) ) {
425
+				if ( ! empty($group)) {
426 426
 					echo '</div></div>';
427 427
 				}
428 428
 
429
-				echo '<div class="plugin-group"><h3>' . esc_html( $group_name ) . '</h3>';
429
+				echo '<div class="plugin-group"><h3>'.esc_html($group_name).'</h3>';
430 430
 				// needs an extra wrapping div for nth-child selectors to work
431 431
 				echo '<div class="plugin-items">';
432 432
 
433 433
 				$group = $plugin['group'];
434 434
 			}
435
-			$title = wp_kses( $plugin['name'], $plugins_allowedtags );
435
+			$title = wp_kses($plugin['name'], $plugins_allowedtags);
436 436
 
437 437
 			// Remove any HTML from the description.
438
-			$description = strip_tags( $plugin['short_description'] );
439
-			$version = wp_kses( $plugin['version'], $plugins_allowedtags );
438
+			$description = strip_tags($plugin['short_description']);
439
+			$version = wp_kses($plugin['version'], $plugins_allowedtags);
440 440
 
441
-			$name = strip_tags( $title . ' ' . $version );
441
+			$name = strip_tags($title.' '.$version);
442 442
 
443
-			$author = wp_kses( $plugin['author'], $plugins_allowedtags );
444
-			if ( ! empty( $author ) ) {
445
-				$author = ' <cite>' . sprintf( __( 'By %s' ), $author ) . '</cite>';
443
+			$author = wp_kses($plugin['author'], $plugins_allowedtags);
444
+			if ( ! empty($author)) {
445
+				$author = ' <cite>'.sprintf(__('By %s'), $author).'</cite>';
446 446
 			}
447 447
 
448 448
 			$action_links = array();
449 449
 
450
-			if ( current_user_can( 'install_plugins' ) || current_user_can( 'update_plugins' ) ) {
451
-				$status = install_plugin_install_status( $plugin );
450
+			if (current_user_can('install_plugins') || current_user_can('update_plugins')) {
451
+				$status = install_plugin_install_status($plugin);
452 452
 
453
-				switch ( $status['status'] ) {
453
+				switch ($status['status']) {
454 454
 					case 'install':
455
-						if ( $status['url'] ) {
455
+						if ($status['url']) {
456 456
 							/* translators: 1: Plugin name and version. */
457
-							$action_links[] = '<a class="install-now button" data-slug="' . esc_attr( $plugin['slug'] ) . '" href="' . esc_url( $status['url'] ) . '" aria-label="' . esc_attr( sprintf( __( 'Install %s now' ), $name ) ) . '" data-name="' . esc_attr( $name ) . '">' . __( 'Install Now' ) . '</a>';
457
+							$action_links[] = '<a class="install-now button" data-slug="'.esc_attr($plugin['slug']).'" href="'.esc_url($status['url']).'" aria-label="'.esc_attr(sprintf(__('Install %s now'), $name)).'" data-name="'.esc_attr($name).'">'.__('Install Now').'</a>';
458 458
 						}
459 459
 
460 460
 						break;
461 461
 					case 'update_available':
462
-						if ( $status['url'] ) {
462
+						if ($status['url']) {
463 463
 							/* translators: 1: Plugin name and version */
464
-							$action_links[] = '<a class="update-now button aria-button-if-js" data-plugin="' . esc_attr( $status['file'] ) . '" data-slug="' . esc_attr( $plugin['slug'] ) . '" href="' . esc_url( $status['url'] ) . '" aria-label="' . esc_attr( sprintf( __( 'Update %s now' ), $name ) ) . '" data-name="' . esc_attr( $name ) . '">' . __( 'Update Now' ) . '</a>';
464
+							$action_links[] = '<a class="update-now button aria-button-if-js" data-plugin="'.esc_attr($status['file']).'" data-slug="'.esc_attr($plugin['slug']).'" href="'.esc_url($status['url']).'" aria-label="'.esc_attr(sprintf(__('Update %s now'), $name)).'" data-name="'.esc_attr($name).'">'.__('Update Now').'</a>';
465 465
 						}
466 466
 
467 467
 						break;
468 468
 					case 'latest_installed':
469 469
 					case 'newer_installed':
470
-						$action_links[] = '<span class="button button-disabled">' . _x( 'Installed', 'plugin' ) . '</span>';
470
+						$action_links[] = '<span class="button button-disabled">'._x('Installed', 'plugin').'</span>';
471 471
 						break;
472 472
 				}
473 473
 			}
474 474
 
475
-			$details_link   = self_admin_url( 'plugin-install.php?tab=plugin-information&amp;plugin=' . $plugin['slug'] .
476
-								'&amp;TB_iframe=true&amp;width=600&amp;height=550' );
475
+			$details_link = self_admin_url('plugin-install.php?tab=plugin-information&amp;plugin='.$plugin['slug'].
476
+								'&amp;TB_iframe=true&amp;width=600&amp;height=550');
477 477
 
478 478
 			/* translators: 1: Plugin name and version. */
479
-			$action_links[] = '<a href="' . esc_url( $details_link ) . '" class="thickbox open-plugin-details-modal" aria-label="' . esc_attr( sprintf( __( 'More information about %s' ), $name ) ) . '" data-title="' . esc_attr( $name ) . '">' . __( 'More Details' ) . '</a>';
479
+			$action_links[] = '<a href="'.esc_url($details_link).'" class="thickbox open-plugin-details-modal" aria-label="'.esc_attr(sprintf(__('More information about %s'), $name)).'" data-title="'.esc_attr($name).'">'.__('More Details').'</a>';
480 480
 
481
-			if ( !empty( $plugin['icons']['svg'] ) ) {
481
+			if ( ! empty($plugin['icons']['svg'])) {
482 482
 				$plugin_icon_url = $plugin['icons']['svg'];
483
-			} elseif ( !empty( $plugin['icons']['2x'] ) ) {
483
+			} elseif ( ! empty($plugin['icons']['2x'])) {
484 484
 				$plugin_icon_url = $plugin['icons']['2x'];
485
-			} elseif ( !empty( $plugin['icons']['1x'] ) ) {
485
+			} elseif ( ! empty($plugin['icons']['1x'])) {
486 486
 				$plugin_icon_url = $plugin['icons']['1x'];
487 487
 			} else {
488 488
 				$plugin_icon_url = $plugin['icons']['default'];
@@ -496,24 +496,24 @@  discard block
 block discarded – undo
496 496
 			 * @param array $action_links An array of plugin action hyperlinks. Defaults are links to Details and Install Now.
497 497
 			 * @param array $plugin       The plugin currently being listed.
498 498
 			 */
499
-			$action_links = apply_filters( 'plugin_install_action_links', $action_links, $plugin );
499
+			$action_links = apply_filters('plugin_install_action_links', $action_links, $plugin);
500 500
 
501
-			$last_updated_timestamp = strtotime( $plugin['last_updated'] );
501
+			$last_updated_timestamp = strtotime($plugin['last_updated']);
502 502
 		?>
503
-		<div class="plugin-card plugin-card-<?php echo sanitize_html_class( $plugin['slug'] ); ?>">
503
+		<div class="plugin-card plugin-card-<?php echo sanitize_html_class($plugin['slug']); ?>">
504 504
 			<div class="plugin-card-top">
505 505
 				<div class="name column-name">
506 506
 					<h3>
507
-						<a href="<?php echo esc_url( $details_link ); ?>" class="thickbox open-plugin-details-modal">
507
+						<a href="<?php echo esc_url($details_link); ?>" class="thickbox open-plugin-details-modal">
508 508
 						<?php echo $title; ?>
509
-						<img src="<?php echo esc_attr( $plugin_icon_url ) ?>" class="plugin-icon" alt="">
509
+						<img src="<?php echo esc_attr($plugin_icon_url) ?>" class="plugin-icon" alt="">
510 510
 						</a>
511 511
 					</h3>
512 512
 				</div>
513 513
 				<div class="action-links">
514 514
 					<?php
515
-						if ( $action_links ) {
516
-							echo '<ul class="plugin-action-buttons"><li>' . implode( '</li><li>', $action_links ) . '</li></ul>';
515
+						if ($action_links) {
516
+							echo '<ul class="plugin-action-buttons"><li>'.implode('</li><li>', $action_links).'</li></ul>';
517 517
 						}
518 518
 					?>
519 519
 				</div>
@@ -524,30 +524,30 @@  discard block
 block discarded – undo
524 524
 			</div>
525 525
 			<div class="plugin-card-bottom">
526 526
 				<div class="vers column-rating">
527
-					<?php wp_star_rating( array( 'rating' => $plugin['rating'], 'type' => 'percent', 'number' => $plugin['num_ratings'] ) ); ?>
528
-					<span class="num-ratings" aria-hidden="true">(<?php echo number_format_i18n( $plugin['num_ratings'] ); ?>)</span>
527
+					<?php wp_star_rating(array('rating' => $plugin['rating'], 'type' => 'percent', 'number' => $plugin['num_ratings'])); ?>
528
+					<span class="num-ratings" aria-hidden="true">(<?php echo number_format_i18n($plugin['num_ratings']); ?>)</span>
529 529
 				</div>
530 530
 				<div class="column-updated">
531
-					<strong><?php _e( 'Last Updated:' ); ?></strong> <?php printf( __( '%s ago' ), human_time_diff( $last_updated_timestamp ) ); ?>
531
+					<strong><?php _e('Last Updated:'); ?></strong> <?php printf(__('%s ago'), human_time_diff($last_updated_timestamp)); ?>
532 532
 				</div>
533 533
 				<div class="column-downloaded">
534 534
 					<?php
535
-					if ( $plugin['active_installs'] >= 1000000 ) {
536
-						$active_installs_text = _x( '1+ Million', 'Active plugin installs' );
535
+					if ($plugin['active_installs'] >= 1000000) {
536
+						$active_installs_text = _x('1+ Million', 'Active plugin installs');
537 537
 					} else {
538
-						$active_installs_text = number_format_i18n( $plugin['active_installs'] ) . '+';
538
+						$active_installs_text = number_format_i18n($plugin['active_installs']).'+';
539 539
 					}
540
-					printf( __( '%s Active Installs' ), $active_installs_text );
540
+					printf(__('%s Active Installs'), $active_installs_text);
541 541
 					?>
542 542
 				</div>
543 543
 				<div class="column-compatibility">
544 544
 					<?php
545
-					if ( ! empty( $plugin['tested'] ) && version_compare( substr( $GLOBALS['wp_version'], 0, strlen( $plugin['tested'] ) ), $plugin['tested'], '>' ) ) {
546
-						echo '<span class="compatibility-untested">' . __( 'Untested with your version of WordPress' ) . '</span>';
547
-					} elseif ( ! empty( $plugin['requires'] ) && version_compare( substr( $GLOBALS['wp_version'], 0, strlen( $plugin['requires'] ) ), $plugin['requires'], '<' ) ) {
548
-						echo '<span class="compatibility-incompatible">' . __( '<strong>Incompatible</strong> with your version of WordPress' ) . '</span>';
545
+					if ( ! empty($plugin['tested']) && version_compare(substr($GLOBALS['wp_version'], 0, strlen($plugin['tested'])), $plugin['tested'], '>')) {
546
+						echo '<span class="compatibility-untested">'.__('Untested with your version of WordPress').'</span>';
547
+					} elseif ( ! empty($plugin['requires']) && version_compare(substr($GLOBALS['wp_version'], 0, strlen($plugin['requires'])), $plugin['requires'], '<')) {
548
+						echo '<span class="compatibility-incompatible">'.__('<strong>Incompatible</strong> with your version of WordPress').'</span>';
549 549
 					} else {
550
-						echo '<span class="compatibility-compatible">' . __( '<strong>Compatible</strong> with your version of WordPress' ) . '</span>';
550
+						echo '<span class="compatibility-compatible">'.__('<strong>Compatible</strong> with your version of WordPress').'</span>';
551 551
 					}
552 552
 					?>
553 553
 				</div>
@@ -557,7 +557,7 @@  discard block
 block discarded – undo
557 557
 		}
558 558
 
559 559
 		// Close off the group divs of the last one
560
-		if ( ! empty( $group ) ) {
560
+		if ( ! empty($group)) {
561 561
 			echo '</div></div>';
562 562
 		}
563 563
 	}
Please login to merge, or discard this patch.
Braces   +11 added lines, -8 removed lines patch added patch discarded remove patch
@@ -123,8 +123,9 @@  discard block
 block discarded – undo
123 123
 		$nonmenu_tabs = apply_filters( 'install_plugins_nonmenu_tabs', $nonmenu_tabs );
124 124
 
125 125
 		// If a non-valid menu tab has been selected, And it's not a non-menu action.
126
-		if ( empty( $tab ) || ( !isset( $tabs[ $tab ] ) && !in_array( $tab, (array) $nonmenu_tabs ) ) )
127
-			$tab = key( $tabs );
126
+		if ( empty( $tab ) || ( !isset( $tabs[ $tab ] ) && !in_array( $tab, (array) $nonmenu_tabs ) ) ) {
127
+					$tab = key( $tabs );
128
+		}
128 129
 
129 130
 		$args = array(
130 131
 			'page' => $paged,
@@ -172,10 +173,11 @@  discard block
 block discarded – undo
172 173
 			case 'favorites':
173 174
 				$user = isset( $_GET['user'] ) ? wp_unslash( $_GET['user'] ) : get_user_option( 'wporg_favorites' );
174 175
 				update_user_meta( get_current_user_id(), 'wporg_favorites', $user );
175
-				if ( $user )
176
-					$args['user'] = $user;
177
-				else
178
-					$args = false;
176
+				if ( $user ) {
177
+									$args['user'] = $user;
178
+				} else {
179
+									$args = false;
180
+				}
179 181
 
180 182
 				add_action( 'install_plugins_favorites', 'install_plugins_favorites_form', 9, 0 );
181 183
 				break;
@@ -197,8 +199,9 @@  discard block
 block discarded – undo
197 199
 		 */
198 200
 		$args = apply_filters( "install_plugins_table_api_args_$tab", $args );
199 201
 
200
-		if ( !$args )
201
-			return;
202
+		if ( !$args ) {
203
+					return;
204
+		}
202 205
 
203 206
 		$api = plugins_api( 'query_plugins', $args );
204 207
 
Please login to merge, or discard this patch.
src/wp-admin/includes/class-wp-plugins-list-table.php 3 patches
Indentation   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -1,11 +1,11 @@
 block discarded – undo
1 1
 <?php
2 2
 /**
3
- * List Table API: WP_Plugins_List_Table class
4
- *
5
- * @package WordPress
6
- * @subpackage Administration
7
- * @since 3.1.0
8
- */
3
+							 * List Table API: WP_Plugins_List_Table class
4
+							 *
5
+							 * @package WordPress
6
+							 * @subpackage Administration
7
+							 * @since 3.1.0
8
+							 */
9 9
 
10 10
 /**
11 11
  * Core class used to implement displaying installed plugins in a list table.
Please login to merge, or discard this patch.
Spacing   +220 added lines, -220 removed lines patch added patch discarded remove patch
@@ -30,20 +30,20 @@  discard block
 block discarded – undo
30 30
 	 *
31 31
 	 * @param array $args An associative array of arguments.
32 32
 	 */
33
-	public function __construct( $args = array() ) {
33
+	public function __construct($args = array()) {
34 34
 		global $status, $page;
35 35
 
36
-		parent::__construct( array(
36
+		parent::__construct(array(
37 37
 			'plural' => 'plugins',
38
-			'screen' => isset( $args['screen'] ) ? $args['screen'] : null,
39
-		) );
38
+			'screen' => isset($args['screen']) ? $args['screen'] : null,
39
+		));
40 40
 
41 41
 		$status = 'all';
42
-		if ( isset( $_REQUEST['plugin_status'] ) && in_array( $_REQUEST['plugin_status'], array( 'active', 'inactive', 'recently_activated', 'upgrade', 'mustuse', 'dropins', 'search' ) ) )
42
+		if (isset($_REQUEST['plugin_status']) && in_array($_REQUEST['plugin_status'], array('active', 'inactive', 'recently_activated', 'upgrade', 'mustuse', 'dropins', 'search')))
43 43
 			$status = $_REQUEST['plugin_status'];
44 44
 
45
-		if ( isset($_REQUEST['s']) )
46
-			$_SERVER['REQUEST_URI'] = add_query_arg('s', wp_unslash($_REQUEST['s']) );
45
+		if (isset($_REQUEST['s']))
46
+			$_SERVER['REQUEST_URI'] = add_query_arg('s', wp_unslash($_REQUEST['s']));
47 47
 
48 48
 		$page = $this->get_pagenum();
49 49
 	}
@@ -52,7 +52,7 @@  discard block
 block discarded – undo
52 52
 	 * @return array
53 53
 	 */
54 54
 	protected function get_table_classes() {
55
-		return array( 'widefat', $this->_args['plural'] );
55
+		return array('widefat', $this->_args['plural']);
56 56
 	}
57 57
 
58 58
 	/**
@@ -75,7 +75,7 @@  discard block
 block discarded – undo
75 75
 	public function prepare_items() {
76 76
 		global $status, $plugins, $totals, $page, $orderby, $order, $s;
77 77
 
78
-		wp_reset_vars( array( 'orderby', 'order' ) );
78
+		wp_reset_vars(array('orderby', 'order'));
79 79
 
80 80
 		/**
81 81
 		 * Filters the full array of plugins to list in the Plugins list table.
@@ -86,7 +86,7 @@  discard block
 block discarded – undo
86 86
 		 *
87 87
 		 * @param array $all_plugins An array of plugins to display in the list table.
88 88
 		 */
89
-		$all_plugins = apply_filters( 'all_plugins', get_plugins() );
89
+		$all_plugins = apply_filters('all_plugins', get_plugins());
90 90
 
91 91
 		$plugins = array(
92 92
 			'all'                => $all_plugins,
@@ -101,7 +101,7 @@  discard block
 block discarded – undo
101 101
 
102 102
 		$screen = $this->screen;
103 103
 
104
-		if ( ! is_multisite() || ( $screen->in_admin( 'network' ) && current_user_can( 'manage_network_plugins' ) ) ) {
104
+		if ( ! is_multisite() || ($screen->in_admin('network') && current_user_can('manage_network_plugins'))) {
105 105
 
106 106
 			/**
107 107
 			 * Filter whether to display the advanced plugins list table.
@@ -118,27 +118,27 @@  discard block
 block discarded – undo
118 118
 			 *                     plugin type. Default true.
119 119
 			 * @param string $type The plugin type. Accepts 'mustuse', 'dropins'.
120 120
 			 */
121
-			if ( apply_filters( 'show_advanced_plugins', true, 'mustuse' ) ) {
121
+			if (apply_filters('show_advanced_plugins', true, 'mustuse')) {
122 122
 				$plugins['mustuse'] = get_mu_plugins();
123 123
 			}
124 124
 
125 125
 			/** This action is documented in wp-admin/includes/class-wp-plugins-list-table.php */
126
-			if ( apply_filters( 'show_advanced_plugins', true, 'dropins' ) )
126
+			if (apply_filters('show_advanced_plugins', true, 'dropins'))
127 127
 				$plugins['dropins'] = get_dropins();
128 128
 
129
-			if ( current_user_can( 'update_plugins' ) ) {
130
-				$current = get_site_transient( 'update_plugins' );
131
-				foreach ( (array) $plugins['all'] as $plugin_file => $plugin_data ) {
132
-					if ( isset( $current->response[ $plugin_file ] ) ) {
133
-						$plugins['all'][ $plugin_file ]['update'] = true;
134
-						$plugins['upgrade'][ $plugin_file ] = $plugins['all'][ $plugin_file ];
129
+			if (current_user_can('update_plugins')) {
130
+				$current = get_site_transient('update_plugins');
131
+				foreach ((array) $plugins['all'] as $plugin_file => $plugin_data) {
132
+					if (isset($current->response[$plugin_file])) {
133
+						$plugins['all'][$plugin_file]['update'] = true;
134
+						$plugins['upgrade'][$plugin_file] = $plugins['all'][$plugin_file];
135 135
 					}
136 136
 				}
137 137
 			}
138 138
 		}
139 139
 
140
-		if ( ! $screen->in_admin( 'network' ) ) {
141
-			$show = current_user_can( 'manage_network_plugins' );
140
+		if ( ! $screen->in_admin('network')) {
141
+			$show = current_user_can('manage_network_plugins');
142 142
 			/**
143 143
 			 * Filter whether to display network-active plugins alongside plugins active for the current site.
144 144
 			 *
@@ -152,121 +152,121 @@  discard block
 block discarded – undo
152 152
 			 * @param bool $show Whether to show network-active plugins. Default is whether the current
153 153
 			 *                   user can manage network plugins (ie. a Super Admin).
154 154
 			 */
155
-			$show_network_active = apply_filters( 'show_network_active_plugins', $show );
155
+			$show_network_active = apply_filters('show_network_active_plugins', $show);
156 156
 		}
157 157
 
158
-		set_transient( 'plugin_slugs', array_keys( $plugins['all'] ), DAY_IN_SECONDS );
158
+		set_transient('plugin_slugs', array_keys($plugins['all']), DAY_IN_SECONDS);
159 159
 
160
-		if ( $screen->in_admin( 'network' ) ) {
161
-			$recently_activated = get_site_option( 'recently_activated', array() );
160
+		if ($screen->in_admin('network')) {
161
+			$recently_activated = get_site_option('recently_activated', array());
162 162
 		} else {
163
-			$recently_activated = get_option( 'recently_activated', array() );
163
+			$recently_activated = get_option('recently_activated', array());
164 164
 		}
165 165
 
166
-		foreach ( $recently_activated as $key => $time ) {
167
-			if ( $time + WEEK_IN_SECONDS < time() ) {
168
-				unset( $recently_activated[$key] );
166
+		foreach ($recently_activated as $key => $time) {
167
+			if ($time + WEEK_IN_SECONDS < time()) {
168
+				unset($recently_activated[$key]);
169 169
 			}
170 170
 		}
171 171
 
172
-		if ( $screen->in_admin( 'network' ) ) {
173
-			update_site_option( 'recently_activated', $recently_activated );
172
+		if ($screen->in_admin('network')) {
173
+			update_site_option('recently_activated', $recently_activated);
174 174
 		} else {
175
-			update_option( 'recently_activated', $recently_activated );
175
+			update_option('recently_activated', $recently_activated);
176 176
 		}
177 177
 
178
-		$plugin_info = get_site_transient( 'update_plugins' );
178
+		$plugin_info = get_site_transient('update_plugins');
179 179
 
180
-		foreach ( (array) $plugins['all'] as $plugin_file => $plugin_data ) {
180
+		foreach ((array) $plugins['all'] as $plugin_file => $plugin_data) {
181 181
 			// Extra info if known. array_merge() ensures $plugin_data has precedence if keys collide.
182
-			if ( isset( $plugin_info->response[ $plugin_file ] ) ) {
183
-				$plugins['all'][ $plugin_file ] = $plugin_data = array_merge( (array) $plugin_info->response[ $plugin_file ], $plugin_data );
182
+			if (isset($plugin_info->response[$plugin_file])) {
183
+				$plugins['all'][$plugin_file] = $plugin_data = array_merge((array) $plugin_info->response[$plugin_file], $plugin_data);
184 184
 				// Make sure that $plugins['upgrade'] also receives the extra info since it is used on ?plugin_status=upgrade
185
-				if ( isset( $plugins['upgrade'][ $plugin_file ] ) ) {
186
-					$plugins['upgrade'][ $plugin_file ] = $plugin_data = array_merge( (array) $plugin_info->response[ $plugin_file ], $plugin_data );
185
+				if (isset($plugins['upgrade'][$plugin_file])) {
186
+					$plugins['upgrade'][$plugin_file] = $plugin_data = array_merge((array) $plugin_info->response[$plugin_file], $plugin_data);
187 187
 				}
188 188
 
189
-			} elseif ( isset( $plugin_info->no_update[ $plugin_file ] ) ) {
190
-				$plugins['all'][ $plugin_file ] = $plugin_data = array_merge( (array) $plugin_info->no_update[ $plugin_file ], $plugin_data );
189
+			} elseif (isset($plugin_info->no_update[$plugin_file])) {
190
+				$plugins['all'][$plugin_file] = $plugin_data = array_merge((array) $plugin_info->no_update[$plugin_file], $plugin_data);
191 191
 				// Make sure that $plugins['upgrade'] also receives the extra info since it is used on ?plugin_status=upgrade
192
-				if ( isset( $plugins['upgrade'][ $plugin_file ] ) ) {
193
-					$plugins['upgrade'][ $plugin_file ] = $plugin_data = array_merge( (array) $plugin_info->no_update[ $plugin_file ], $plugin_data );
192
+				if (isset($plugins['upgrade'][$plugin_file])) {
193
+					$plugins['upgrade'][$plugin_file] = $plugin_data = array_merge((array) $plugin_info->no_update[$plugin_file], $plugin_data);
194 194
 				}
195 195
 			}
196 196
 
197 197
 			// Filter into individual sections
198
-			if ( is_multisite() && ! $screen->in_admin( 'network' ) && is_network_only_plugin( $plugin_file ) && ! is_plugin_active( $plugin_file ) ) {
199
-				if ( $show_network_active ) {
198
+			if (is_multisite() && ! $screen->in_admin('network') && is_network_only_plugin($plugin_file) && ! is_plugin_active($plugin_file)) {
199
+				if ($show_network_active) {
200 200
 					// On the non-network screen, show inactive network-only plugins if allowed
201
-					$plugins['inactive'][ $plugin_file ] = $plugin_data;
201
+					$plugins['inactive'][$plugin_file] = $plugin_data;
202 202
 				} else {
203 203
 					// On the non-network screen, filter out network-only plugins as long as they're not individually active
204
-					unset( $plugins['all'][ $plugin_file ] );
204
+					unset($plugins['all'][$plugin_file]);
205 205
 				}
206
-			} elseif ( ! $screen->in_admin( 'network' ) && is_plugin_active_for_network( $plugin_file ) ) {
207
-				if ( $show_network_active ) {
206
+			} elseif ( ! $screen->in_admin('network') && is_plugin_active_for_network($plugin_file)) {
207
+				if ($show_network_active) {
208 208
 					// On the non-network screen, show network-active plugins if allowed
209
-					$plugins['active'][ $plugin_file ] = $plugin_data;
209
+					$plugins['active'][$plugin_file] = $plugin_data;
210 210
 				} else {
211 211
 					// On the non-network screen, filter out network-active plugins
212
-					unset( $plugins['all'][ $plugin_file ] );
212
+					unset($plugins['all'][$plugin_file]);
213 213
 				}
214
-			} elseif ( ( ! $screen->in_admin( 'network' ) && is_plugin_active( $plugin_file ) )
215
-				|| ( $screen->in_admin( 'network' ) && is_plugin_active_for_network( $plugin_file ) ) ) {
214
+			} elseif (( ! $screen->in_admin('network') && is_plugin_active($plugin_file))
215
+				|| ($screen->in_admin('network') && is_plugin_active_for_network($plugin_file))) {
216 216
 				// On the non-network screen, populate the active list with plugins that are individually activated
217 217
 				// On the network-admin screen, populate the active list with plugins that are network activated
218
-				$plugins['active'][ $plugin_file ] = $plugin_data;
218
+				$plugins['active'][$plugin_file] = $plugin_data;
219 219
 			} else {
220
-				if ( isset( $recently_activated[ $plugin_file ] ) ) {
220
+				if (isset($recently_activated[$plugin_file])) {
221 221
 					// Populate the recently activated list with plugins that have been recently activated
222
-					$plugins['recently_activated'][ $plugin_file ] = $plugin_data;
222
+					$plugins['recently_activated'][$plugin_file] = $plugin_data;
223 223
 				}
224 224
 				// Populate the inactive list with plugins that aren't activated
225
-				$plugins['inactive'][ $plugin_file ] = $plugin_data;
225
+				$plugins['inactive'][$plugin_file] = $plugin_data;
226 226
 			}
227 227
 		}
228 228
 
229
-		if ( strlen( $s ) ) {
229
+		if (strlen($s)) {
230 230
 			$status = 'search';
231
-			$plugins['search'] = array_filter( $plugins['all'], array( $this, '_search_callback' ) );
231
+			$plugins['search'] = array_filter($plugins['all'], array($this, '_search_callback'));
232 232
 		}
233 233
 
234 234
 		$totals = array();
235
-		foreach ( $plugins as $type => $list )
236
-			$totals[ $type ] = count( $list );
235
+		foreach ($plugins as $type => $list)
236
+			$totals[$type] = count($list);
237 237
 
238
-		if ( empty( $plugins[ $status ] ) && !in_array( $status, array( 'all', 'search' ) ) )
238
+		if (empty($plugins[$status]) && ! in_array($status, array('all', 'search')))
239 239
 			$status = 'all';
240 240
 
241 241
 		$this->items = array();
242
-		foreach ( $plugins[ $status ] as $plugin_file => $plugin_data ) {
242
+		foreach ($plugins[$status] as $plugin_file => $plugin_data) {
243 243
 			// Translate, Don't Apply Markup, Sanitize HTML
244
-			$this->items[$plugin_file] = _get_plugin_data_markup_translate( $plugin_file, $plugin_data, false, true );
244
+			$this->items[$plugin_file] = _get_plugin_data_markup_translate($plugin_file, $plugin_data, false, true);
245 245
 		}
246 246
 
247
-		$total_this_page = $totals[ $status ];
247
+		$total_this_page = $totals[$status];
248 248
 
249
-		if ( ! $orderby ) {
249
+		if ( ! $orderby) {
250 250
 			$orderby = 'Name';
251 251
 		} else {
252
-			$orderby = ucfirst( $orderby );
252
+			$orderby = ucfirst($orderby);
253 253
 		}
254 254
 
255
-		$order = strtoupper( $order );
255
+		$order = strtoupper($order);
256 256
 
257
-		uasort( $this->items, array( $this, '_order_callback' ) );
257
+		uasort($this->items, array($this, '_order_callback'));
258 258
 
259
-		$plugins_per_page = $this->get_items_per_page( str_replace( '-', '_', $screen->id . '_per_page' ), 999 );
259
+		$plugins_per_page = $this->get_items_per_page(str_replace('-', '_', $screen->id.'_per_page'), 999);
260 260
 
261
-		$start = ( $page - 1 ) * $plugins_per_page;
261
+		$start = ($page - 1) * $plugins_per_page;
262 262
 
263
-		if ( $total_this_page > $plugins_per_page )
264
-			$this->items = array_slice( $this->items, $start, $plugins_per_page );
263
+		if ($total_this_page > $plugins_per_page)
264
+			$this->items = array_slice($this->items, $start, $plugins_per_page);
265 265
 
266
-		$this->set_pagination_args( array(
266
+		$this->set_pagination_args(array(
267 267
 			'total_items' => $total_this_page,
268 268
 			'per_page' => $plugins_per_page,
269
-		) );
269
+		));
270 270
 	}
271 271
 
272 272
 	/**
@@ -275,11 +275,11 @@  discard block
 block discarded – undo
275 275
 	 * @param array $plugin
276 276
 	 * @return bool
277 277
 	 */
278
-	public function _search_callback( $plugin ) {
278
+	public function _search_callback($plugin) {
279 279
 		global $s;
280 280
 
281
-		foreach ( $plugin as $value ) {
282
-			if ( is_string( $value ) && false !== stripos( strip_tags( $value ), urldecode( $s ) ) ) {
281
+		foreach ($plugin as $value) {
282
+			if (is_string($value) && false !== stripos(strip_tags($value), urldecode($s))) {
283 283
 				return true;
284 284
 			}
285 285
 		}
@@ -294,19 +294,19 @@  discard block
 block discarded – undo
294 294
 	 * @param array $plugin_b
295 295
 	 * @return int
296 296
 	 */
297
-	public function _order_callback( $plugin_a, $plugin_b ) {
297
+	public function _order_callback($plugin_a, $plugin_b) {
298 298
 		global $orderby, $order;
299 299
 
300 300
 		$a = $plugin_a[$orderby];
301 301
 		$b = $plugin_b[$orderby];
302 302
 
303
-		if ( $a == $b )
303
+		if ($a == $b)
304 304
 			return 0;
305 305
 
306
-		if ( 'DESC' === $order ) {
307
-			return strcasecmp( $b, $a );
306
+		if ('DESC' === $order) {
307
+			return strcasecmp($b, $a);
308 308
 		} else {
309
-			return strcasecmp( $a, $b );
309
+			return strcasecmp($a, $b);
310 310
 		}
311 311
 	}
312 312
 
@@ -317,19 +317,19 @@  discard block
 block discarded – undo
317 317
 	public function no_items() {
318 318
 		global $plugins;
319 319
 
320
-		if ( ! empty( $_REQUEST['s'] ) ) {
321
-			$s = esc_html( wp_unslash( $_REQUEST['s'] ) );
320
+		if ( ! empty($_REQUEST['s'])) {
321
+			$s = esc_html(wp_unslash($_REQUEST['s']));
322 322
 
323
-			printf( __( 'No plugins found for &#8220;%s&#8221;.' ), $s );
323
+			printf(__('No plugins found for &#8220;%s&#8221;.'), $s);
324 324
 
325 325
 			// We assume that somebody who can install plugins in multisite is experienced enough to not need this helper link.
326
-			if ( ! is_multisite() && current_user_can( 'install_plugins' ) ) {
327
-				echo ' <a href="' . esc_url( admin_url( 'plugin-install.php?tab=search&s=' . urlencode( $s ) ) ) . '">' . __( 'Search for plugins in the WordPress Plugin Directory.' ) . '</a>';
326
+			if ( ! is_multisite() && current_user_can('install_plugins')) {
327
+				echo ' <a href="'.esc_url(admin_url('plugin-install.php?tab=search&s='.urlencode($s))).'">'.__('Search for plugins in the WordPress Plugin Directory.').'</a>';
328 328
 			}
329
-		} elseif ( ! empty( $plugins['all'] ) )
330
-			_e( 'No plugins found.' );
329
+		} elseif ( ! empty($plugins['all']))
330
+			_e('No plugins found.');
331 331
 		else
332
-			_e( 'You do not appear to have any plugins available at this time.' );
332
+			_e('You do not appear to have any plugins available at this time.');
333 333
 	}
334 334
 
335 335
 	/**
@@ -341,9 +341,9 @@  discard block
 block discarded – undo
341 341
 		global $status;
342 342
 
343 343
 		return array(
344
-			'cb'          => !in_array( $status, array( 'mustuse', 'dropins' ) ) ? '<input type="checkbox" />' : '',
345
-			'name'        => __( 'Plugin' ),
346
-			'description' => __( 'Description' ),
344
+			'cb'          => ! in_array($status, array('mustuse', 'dropins')) ? '<input type="checkbox" />' : '',
345
+			'name'        => __('Plugin'),
346
+			'description' => __('Description'),
347 347
 		);
348 348
 	}
349 349
 
@@ -364,39 +364,39 @@  discard block
 block discarded – undo
364 364
 		global $totals, $status;
365 365
 
366 366
 		$status_links = array();
367
-		foreach ( $totals as $type => $count ) {
368
-			if ( !$count )
367
+		foreach ($totals as $type => $count) {
368
+			if ( ! $count)
369 369
 				continue;
370 370
 
371
-			switch ( $type ) {
371
+			switch ($type) {
372 372
 				case 'all':
373
-					$text = _nx( 'All <span class="count">(%s)</span>', 'All <span class="count">(%s)</span>', $count, 'plugins' );
373
+					$text = _nx('All <span class="count">(%s)</span>', 'All <span class="count">(%s)</span>', $count, 'plugins');
374 374
 					break;
375 375
 				case 'active':
376
-					$text = _n( 'Active <span class="count">(%s)</span>', 'Active <span class="count">(%s)</span>', $count );
376
+					$text = _n('Active <span class="count">(%s)</span>', 'Active <span class="count">(%s)</span>', $count);
377 377
 					break;
378 378
 				case 'recently_activated':
379
-					$text = _n( 'Recently Active <span class="count">(%s)</span>', 'Recently Active <span class="count">(%s)</span>', $count );
379
+					$text = _n('Recently Active <span class="count">(%s)</span>', 'Recently Active <span class="count">(%s)</span>', $count);
380 380
 					break;
381 381
 				case 'inactive':
382
-					$text = _n( 'Inactive <span class="count">(%s)</span>', 'Inactive <span class="count">(%s)</span>', $count );
382
+					$text = _n('Inactive <span class="count">(%s)</span>', 'Inactive <span class="count">(%s)</span>', $count);
383 383
 					break;
384 384
 				case 'mustuse':
385
-					$text = _n( 'Must-Use <span class="count">(%s)</span>', 'Must-Use <span class="count">(%s)</span>', $count );
385
+					$text = _n('Must-Use <span class="count">(%s)</span>', 'Must-Use <span class="count">(%s)</span>', $count);
386 386
 					break;
387 387
 				case 'dropins':
388
-					$text = _n( 'Drop-ins <span class="count">(%s)</span>', 'Drop-ins <span class="count">(%s)</span>', $count );
388
+					$text = _n('Drop-ins <span class="count">(%s)</span>', 'Drop-ins <span class="count">(%s)</span>', $count);
389 389
 					break;
390 390
 				case 'upgrade':
391
-					$text = _n( 'Update Available <span class="count">(%s)</span>', 'Update Available <span class="count">(%s)</span>', $count );
391
+					$text = _n('Update Available <span class="count">(%s)</span>', 'Update Available <span class="count">(%s)</span>', $count);
392 392
 					break;
393 393
 			}
394 394
 
395
-			if ( 'search' !== $type ) {
396
-				$status_links[$type] = sprintf( "<a href='%s' %s>%s</a>",
395
+			if ('search' !== $type) {
396
+				$status_links[$type] = sprintf("<a href='%s' %s>%s</a>",
397 397
 					add_query_arg('plugin_status', $type, 'plugins.php'),
398
-					( $type === $status ) ? ' class="current"' : '',
399
-					sprintf( $text, number_format_i18n( $count ) )
398
+					($type === $status) ? ' class="current"' : '',
399
+					sprintf($text, number_format_i18n($count))
400 400
 					);
401 401
 			}
402 402
 		}
@@ -414,17 +414,17 @@  discard block
 block discarded – undo
414 414
 
415 415
 		$actions = array();
416 416
 
417
-		if ( 'active' != $status )
418
-			$actions['activate-selected'] = $this->screen->in_admin( 'network' ) ? __( 'Network Activate' ) : __( 'Activate' );
417
+		if ('active' != $status)
418
+			$actions['activate-selected'] = $this->screen->in_admin('network') ? __('Network Activate') : __('Activate');
419 419
 
420
-		if ( 'inactive' != $status && 'recent' != $status )
421
-			$actions['deactivate-selected'] = $this->screen->in_admin( 'network' ) ? __( 'Network Deactivate' ) : __( 'Deactivate' );
420
+		if ('inactive' != $status && 'recent' != $status)
421
+			$actions['deactivate-selected'] = $this->screen->in_admin('network') ? __('Network Deactivate') : __('Deactivate');
422 422
 
423
-		if ( !is_multisite() || $this->screen->in_admin( 'network' ) ) {
424
-			if ( current_user_can( 'update_plugins' ) )
425
-				$actions['update-selected'] = __( 'Update' );
426
-			if ( current_user_can( 'delete_plugins' ) && ( 'active' != $status ) )
427
-				$actions['delete-selected'] = __( 'Delete' );
423
+		if ( ! is_multisite() || $this->screen->in_admin('network')) {
424
+			if (current_user_can('update_plugins'))
425
+				$actions['update-selected'] = __('Update');
426
+			if (current_user_can('delete_plugins') && ('active' != $status))
427
+				$actions['delete-selected'] = __('Delete');
428 428
 		}
429 429
 
430 430
 		return $actions;
@@ -434,39 +434,39 @@  discard block
 block discarded – undo
434 434
 	 * @global string $status
435 435
 	 * @param string $which
436 436
 	 */
437
-	public function bulk_actions( $which = '' ) {
437
+	public function bulk_actions($which = '') {
438 438
 		global $status;
439 439
 
440
-		if ( in_array( $status, array( 'mustuse', 'dropins' ) ) )
440
+		if (in_array($status, array('mustuse', 'dropins')))
441 441
 			return;
442 442
 
443
-		parent::bulk_actions( $which );
443
+		parent::bulk_actions($which);
444 444
 	}
445 445
 
446 446
 	/**
447 447
 	 * @global string $status
448 448
 	 * @param string $which
449 449
 	 */
450
-	protected function extra_tablenav( $which ) {
450
+	protected function extra_tablenav($which) {
451 451
 		global $status;
452 452
 
453
-		if ( ! in_array($status, array('recently_activated', 'mustuse', 'dropins') ) )
453
+		if ( ! in_array($status, array('recently_activated', 'mustuse', 'dropins')))
454 454
 			return;
455 455
 
456 456
 		echo '<div class="alignleft actions">';
457 457
 
458
-		if ( 'recently_activated' == $status ) {
459
-			submit_button( __( 'Clear List' ), 'button', 'clear-recent-list', false );
460
-		} elseif ( 'top' === $which && 'mustuse' === $status ) {
458
+		if ('recently_activated' == $status) {
459
+			submit_button(__('Clear List'), 'button', 'clear-recent-list', false);
460
+		} elseif ('top' === $which && 'mustuse' === $status) {
461 461
 			/* translators: %s: mu-plugins directory name */
462
-			echo '<p>' . sprintf( __( 'Files in the %s directory are executed automatically.' ),
463
-				'<code>' . str_replace( ABSPATH, '/', WPMU_PLUGIN_DIR ) . '</code>'
464
-			) . '</p>';
465
-		} elseif ( 'top' === $which && 'dropins' === $status ) {
462
+			echo '<p>'.sprintf(__('Files in the %s directory are executed automatically.'),
463
+				'<code>'.str_replace(ABSPATH, '/', WPMU_PLUGIN_DIR).'</code>'
464
+			).'</p>';
465
+		} elseif ('top' === $which && 'dropins' === $status) {
466 466
 			/* translators: %s: wp-content directory name */
467
-			echo '<p>' . sprintf( __( 'Drop-ins are advanced plugins in the %s directory that replace WordPress functionality when present.' ),
468
-				'<code>' . str_replace( ABSPATH, '', WP_CONTENT_DIR ) . '</code>'
469
-			) . '</p>';
467
+			echo '<p>'.sprintf(__('Drop-ins are advanced plugins in the %s directory that replace WordPress functionality when present.'),
468
+				'<code>'.str_replace(ABSPATH, '', WP_CONTENT_DIR).'</code>'
469
+			).'</p>';
470 470
 		}
471 471
 		echo '</div>';
472 472
 	}
@@ -475,7 +475,7 @@  discard block
 block discarded – undo
475 475
 	 * @return string
476 476
 	 */
477 477
 	public function current_action() {
478
-		if ( isset($_POST['clear-recent-list']) )
478
+		if (isset($_POST['clear-recent-list']))
479 479
 			return 'clear-recent-list';
480 480
 
481 481
 		return parent::current_action();
@@ -488,11 +488,11 @@  discard block
 block discarded – undo
488 488
 	public function display_rows() {
489 489
 		global $status;
490 490
 
491
-		if ( is_multisite() && ! $this->screen->in_admin( 'network' ) && in_array( $status, array( 'mustuse', 'dropins' ) ) )
491
+		if (is_multisite() && ! $this->screen->in_admin('network') && in_array($status, array('mustuse', 'dropins')))
492 492
 			return;
493 493
 
494
-		foreach ( $this->items as $plugin_file => $plugin_data )
495
-			$this->single_row( array( $plugin_file, $plugin_data ) );
494
+		foreach ($this->items as $plugin_file => $plugin_data)
495
+			$this->single_row(array($plugin_file, $plugin_data));
496 496
 	}
497 497
 
498 498
 	/**
@@ -503,10 +503,10 @@  discard block
 block discarded – undo
503 503
 	 *
504 504
 	 * @param array $item
505 505
 	 */
506
-	public function single_row( $item ) {
506
+	public function single_row($item) {
507 507
 		global $status, $page, $s, $totals;
508 508
 
509
-		list( $plugin_file, $plugin_data ) = $item;
509
+		list($plugin_file, $plugin_data) = $item;
510 510
 		$context = $status;
511 511
 		$screen = $this->screen;
512 512
 
@@ -523,88 +523,88 @@  discard block
 block discarded – undo
523 523
 		$restrict_network_active = false;
524 524
 		$restrict_network_only = false;
525 525
 
526
-		if ( 'mustuse' === $context ) {
526
+		if ('mustuse' === $context) {
527 527
 			$is_active = true;
528
-		} elseif ( 'dropins' === $context ) {
528
+		} elseif ('dropins' === $context) {
529 529
 			$dropins = _get_dropins();
530 530
 			$plugin_name = $plugin_file;
531
-			if ( $plugin_file != $plugin_data['Name'] )
532
-				$plugin_name .= '<br/>' . $plugin_data['Name'];
533
-			if ( true === ( $dropins[ $plugin_file ][1] ) ) { // Doesn't require a constant
531
+			if ($plugin_file != $plugin_data['Name'])
532
+				$plugin_name .= '<br/>'.$plugin_data['Name'];
533
+			if (true === ($dropins[$plugin_file][1])) { // Doesn't require a constant
534 534
 				$is_active = true;
535
-				$description = '<p><strong>' . $dropins[ $plugin_file ][0] . '</strong></p>';
536
-			} elseif ( defined( $dropins[ $plugin_file ][1] ) && constant( $dropins[ $plugin_file ][1] ) ) { // Constant is true
535
+				$description = '<p><strong>'.$dropins[$plugin_file][0].'</strong></p>';
536
+			} elseif (defined($dropins[$plugin_file][1]) && constant($dropins[$plugin_file][1])) { // Constant is true
537 537
 				$is_active = true;
538
-				$description = '<p><strong>' . $dropins[ $plugin_file ][0] . '</strong></p>';
538
+				$description = '<p><strong>'.$dropins[$plugin_file][0].'</strong></p>';
539 539
 			} else {
540 540
 				$is_active = false;
541
-				$description = '<p><strong>' . $dropins[ $plugin_file ][0] . ' <span class="error-message">' . __( 'Inactive:' ) . '</span></strong> ' .
541
+				$description = '<p><strong>'.$dropins[$plugin_file][0].' <span class="error-message">'.__('Inactive:').'</span></strong> '.
542 542
 					/* translators: 1: drop-in constant name, 2: wp-config.php */
543
-					sprintf( __( 'Requires %1$s in %2$s file.' ),
544
-						"<code>define('" . $dropins[ $plugin_file ][1] . "', true);</code>",
543
+					sprintf(__('Requires %1$s in %2$s file.'),
544
+						"<code>define('".$dropins[$plugin_file][1]."', true);</code>",
545 545
 						'<code>wp-config.php</code>'
546
-					) . '</p>';
546
+					).'</p>';
547 547
 			}
548
-			if ( $plugin_data['Description'] )
549
-				$description .= '<p>' . $plugin_data['Description'] . '</p>';
548
+			if ($plugin_data['Description'])
549
+				$description .= '<p>'.$plugin_data['Description'].'</p>';
550 550
 		} else {
551
-			if ( $screen->in_admin( 'network' ) ) {
552
-				$is_active = is_plugin_active_for_network( $plugin_file );
551
+			if ($screen->in_admin('network')) {
552
+				$is_active = is_plugin_active_for_network($plugin_file);
553 553
 			} else {
554
-				$is_active = is_plugin_active( $plugin_file );
555
-				$restrict_network_active = ( is_multisite() && is_plugin_active_for_network( $plugin_file ) );
556
-				$restrict_network_only = ( is_multisite() && is_network_only_plugin( $plugin_file ) && ! $is_active );
554
+				$is_active = is_plugin_active($plugin_file);
555
+				$restrict_network_active = (is_multisite() && is_plugin_active_for_network($plugin_file));
556
+				$restrict_network_only = (is_multisite() && is_network_only_plugin($plugin_file) && ! $is_active);
557 557
 			}
558 558
 
559
-			if ( $screen->in_admin( 'network' ) ) {
560
-				if ( $is_active ) {
561
-					if ( current_user_can( 'manage_network_plugins' ) ) {
559
+			if ($screen->in_admin('network')) {
560
+				if ($is_active) {
561
+					if (current_user_can('manage_network_plugins')) {
562 562
 						/* translators: %s: plugin name */
563
-						$actions['deactivate'] = '<a href="' . wp_nonce_url( 'plugins.php?action=deactivate&amp;plugin=' . $plugin_file . '&amp;plugin_status=' . $context . '&amp;paged=' . $page . '&amp;s=' . $s, 'deactivate-plugin_' . $plugin_file ) . '" aria-label="' . esc_attr( sprintf( __( 'Network deactivate %s' ), $plugin_data['Name'] ) ) . '">' . __( 'Network Deactivate' ) . '</a>';
563
+						$actions['deactivate'] = '<a href="'.wp_nonce_url('plugins.php?action=deactivate&amp;plugin='.$plugin_file.'&amp;plugin_status='.$context.'&amp;paged='.$page.'&amp;s='.$s, 'deactivate-plugin_'.$plugin_file).'" aria-label="'.esc_attr(sprintf(__('Network deactivate %s'), $plugin_data['Name'])).'">'.__('Network Deactivate').'</a>';
564 564
 						}
565 565
 				} else {
566
-					if ( current_user_can( 'manage_network_plugins' ) ) {
566
+					if (current_user_can('manage_network_plugins')) {
567 567
 						/* translators: %s: plugin name */
568
-						$actions['activate'] = '<a href="' . wp_nonce_url( 'plugins.php?action=activate&amp;plugin=' . $plugin_file . '&amp;plugin_status=' . $context . '&amp;paged=' . $page . '&amp;s=' . $s, 'activate-plugin_' . $plugin_file ) . '" class="edit" aria-label="' . esc_attr( sprintf( __( 'Network Activate %s' ), $plugin_data['Name'] ) ) . '">' . __( 'Network Activate' ) . '</a>';
568
+						$actions['activate'] = '<a href="'.wp_nonce_url('plugins.php?action=activate&amp;plugin='.$plugin_file.'&amp;plugin_status='.$context.'&amp;paged='.$page.'&amp;s='.$s, 'activate-plugin_'.$plugin_file).'" class="edit" aria-label="'.esc_attr(sprintf(__('Network Activate %s'), $plugin_data['Name'])).'">'.__('Network Activate').'</a>';
569 569
 					}
570
-					if ( current_user_can( 'delete_plugins' ) && ! is_plugin_active( $plugin_file ) ) {
570
+					if (current_user_can('delete_plugins') && ! is_plugin_active($plugin_file)) {
571 571
 						/* translators: %s: plugin name */
572
-						$actions['delete'] = '<a href="' . wp_nonce_url( 'plugins.php?action=delete-selected&amp;checked[]=' . $plugin_file . '&amp;plugin_status=' . $context . '&amp;paged=' . $page . '&amp;s=' . $s, 'bulk-plugins' ) . '" class="delete" aria-label="' . esc_attr( sprintf( __( 'Delete %s' ), $plugin_data['Name'] ) ) . '">' . __( 'Delete' ) . '</a>';
572
+						$actions['delete'] = '<a href="'.wp_nonce_url('plugins.php?action=delete-selected&amp;checked[]='.$plugin_file.'&amp;plugin_status='.$context.'&amp;paged='.$page.'&amp;s='.$s, 'bulk-plugins').'" class="delete" aria-label="'.esc_attr(sprintf(__('Delete %s'), $plugin_data['Name'])).'">'.__('Delete').'</a>';
573 573
 					}
574 574
 				}
575 575
 			} else {
576
-				if ( $restrict_network_active ) {
576
+				if ($restrict_network_active) {
577 577
 					$actions = array(
578
-						'network_active' => __( 'Network Active' ),
578
+						'network_active' => __('Network Active'),
579 579
 					);
580
-				} elseif ( $restrict_network_only ) {
580
+				} elseif ($restrict_network_only) {
581 581
 					$actions = array(
582
-						'network_only' => __( 'Network Only' ),
582
+						'network_only' => __('Network Only'),
583 583
 					);
584
-				} elseif ( $is_active ) {
584
+				} elseif ($is_active) {
585 585
 					/* translators: %s: plugin name */
586
-					$actions['deactivate'] = '<a href="' . wp_nonce_url( 'plugins.php?action=deactivate&amp;plugin=' . $plugin_file . '&amp;plugin_status=' . $context . '&amp;paged=' . $page . '&amp;s=' . $s, 'deactivate-plugin_' . $plugin_file ) . '" aria-label="' . esc_attr( sprintf( __( 'Deactivate %s' ), $plugin_data['Name'] ) ) . '">' . __( 'Deactivate' ) . '</a>';
586
+					$actions['deactivate'] = '<a href="'.wp_nonce_url('plugins.php?action=deactivate&amp;plugin='.$plugin_file.'&amp;plugin_status='.$context.'&amp;paged='.$page.'&amp;s='.$s, 'deactivate-plugin_'.$plugin_file).'" aria-label="'.esc_attr(sprintf(__('Deactivate %s'), $plugin_data['Name'])).'">'.__('Deactivate').'</a>';
587 587
 				} else {
588 588
 					/* translators: %s: plugin name */
589
-					$actions['activate'] = '<a href="' . wp_nonce_url( 'plugins.php?action=activate&amp;plugin=' . $plugin_file . '&amp;plugin_status=' . $context . '&amp;paged=' . $page . '&amp;s=' . $s, 'activate-plugin_' . $plugin_file ) . '" class="edit" aria-label="' . esc_attr( sprintf( __( 'Activate %s' ), $plugin_data['Name'] ) ) . '">' . __( 'Activate' ) . '</a>';
589
+					$actions['activate'] = '<a href="'.wp_nonce_url('plugins.php?action=activate&amp;plugin='.$plugin_file.'&amp;plugin_status='.$context.'&amp;paged='.$page.'&amp;s='.$s, 'activate-plugin_'.$plugin_file).'" class="edit" aria-label="'.esc_attr(sprintf(__('Activate %s'), $plugin_data['Name'])).'">'.__('Activate').'</a>';
590 590
 
591
-					if ( ! is_multisite() && current_user_can( 'delete_plugins' ) ) {
591
+					if ( ! is_multisite() && current_user_can('delete_plugins')) {
592 592
 						/* translators: %s: plugin name */
593
-						$actions['delete'] = '<a href="' . wp_nonce_url( 'plugins.php?action=delete-selected&amp;checked[]=' . $plugin_file . '&amp;plugin_status=' . $context . '&amp;paged=' . $page . '&amp;s=' . $s, 'bulk-plugins' ) . '" class="delete" aria-label="' . esc_attr( sprintf( __( 'Delete %s' ), $plugin_data['Name'] ) ) . '">' . __( 'Delete' ) . '</a>';
593
+						$actions['delete'] = '<a href="'.wp_nonce_url('plugins.php?action=delete-selected&amp;checked[]='.$plugin_file.'&amp;plugin_status='.$context.'&amp;paged='.$page.'&amp;s='.$s, 'bulk-plugins').'" class="delete" aria-label="'.esc_attr(sprintf(__('Delete %s'), $plugin_data['Name'])).'">'.__('Delete').'</a>';
594 594
 					}
595 595
 				} // end if $is_active
596 596
 
597 597
 			 } // end if $screen->in_admin( 'network' )
598 598
 
599
-			if ( ( ! is_multisite() || $screen->in_admin( 'network' ) ) && current_user_can( 'edit_plugins' ) && is_writable( WP_PLUGIN_DIR . '/' . $plugin_file ) ) {
599
+			if (( ! is_multisite() || $screen->in_admin('network')) && current_user_can('edit_plugins') && is_writable(WP_PLUGIN_DIR.'/'.$plugin_file)) {
600 600
 				/* translators: %s: plugin name */
601
-				$actions['edit'] = '<a href="plugin-editor.php?file=' . $plugin_file . '" class="edit" aria-label="' . esc_attr( sprintf( __( 'Edit %s' ), $plugin_data['Name'] ) ) . '">' . __( 'Edit' ) . '</a>';
601
+				$actions['edit'] = '<a href="plugin-editor.php?file='.$plugin_file.'" class="edit" aria-label="'.esc_attr(sprintf(__('Edit %s'), $plugin_data['Name'])).'">'.__('Edit').'</a>';
602 602
 			}
603 603
 		} // end if $context
604 604
 
605
-		$actions = array_filter( $actions );
605
+		$actions = array_filter($actions);
606 606
 
607
-		if ( $screen->in_admin( 'network' ) ) {
607
+		if ($screen->in_admin('network')) {
608 608
 
609 609
 			/**
610 610
 			 * Filter the action links displayed for each plugin in the Network Admin Plugins list table.
@@ -622,7 +622,7 @@  discard block
 block discarded – undo
622 622
 			 *                            'Inactive', 'Recently Activated', 'Upgrade',
623 623
 			 *                            'Must-Use', 'Drop-ins', 'Search'.
624 624
 			 */
625
-			$actions = apply_filters( 'network_admin_plugin_action_links', $actions, $plugin_file, $plugin_data, $context );
625
+			$actions = apply_filters('network_admin_plugin_action_links', $actions, $plugin_file, $plugin_data, $context);
626 626
 
627 627
 			/**
628 628
 			 * Filter the list of action links displayed for a specific plugin in the Network Admin Plugins list table.
@@ -640,7 +640,7 @@  discard block
 block discarded – undo
640 640
 			 *                            'Inactive', 'Recently Activated', 'Upgrade',
641 641
 			 *                            'Must-Use', 'Drop-ins', 'Search'.
642 642
 			 */
643
-			$actions = apply_filters( "network_admin_plugin_action_links_{$plugin_file}", $actions, $plugin_file, $plugin_data, $context );
643
+			$actions = apply_filters("network_admin_plugin_action_links_{$plugin_file}", $actions, $plugin_file, $plugin_data, $context);
644 644
 
645 645
 		} else {
646 646
 
@@ -661,7 +661,7 @@  discard block
 block discarded – undo
661 661
 			 *                            'Inactive', 'Recently Activated', 'Upgrade',
662 662
 			 *                            'Must-Use', 'Drop-ins', 'Search'.
663 663
 			 */
664
-			$actions = apply_filters( 'plugin_action_links', $actions, $plugin_file, $plugin_data, $context );
664
+			$actions = apply_filters('plugin_action_links', $actions, $plugin_file, $plugin_data, $context);
665 665
 
666 666
 			/**
667 667
 			 * Filter the list of action links displayed for a specific plugin in the Plugins list table.
@@ -679,48 +679,48 @@  discard block
 block discarded – undo
679 679
 			 *                            'Inactive', 'Recently Activated', 'Upgrade',
680 680
 			 *                            'Must-Use', 'Drop-ins', 'Search'.
681 681
 			 */
682
-			$actions = apply_filters( "plugin_action_links_{$plugin_file}", $actions, $plugin_file, $plugin_data, $context );
682
+			$actions = apply_filters("plugin_action_links_{$plugin_file}", $actions, $plugin_file, $plugin_data, $context);
683 683
 
684 684
 		}
685 685
 
686 686
 		$class = $is_active ? 'active' : 'inactive';
687
-		$checkbox_id =  "checkbox_" . md5($plugin_data['Name']);
688
-		if ( $restrict_network_active || $restrict_network_only || in_array( $status, array( 'mustuse', 'dropins' ) ) ) {
687
+		$checkbox_id = "checkbox_".md5($plugin_data['Name']);
688
+		if ($restrict_network_active || $restrict_network_only || in_array($status, array('mustuse', 'dropins'))) {
689 689
 			$checkbox = '';
690 690
 		} else {
691
-			$checkbox = "<label class='screen-reader-text' for='" . $checkbox_id . "' >" . sprintf( __( 'Select %s' ), $plugin_data['Name'] ) . "</label>"
692
-				. "<input type='checkbox' name='checked[]' value='" . esc_attr( $plugin_file ) . "' id='" . $checkbox_id . "' />";
691
+			$checkbox = "<label class='screen-reader-text' for='".$checkbox_id."' >".sprintf(__('Select %s'), $plugin_data['Name'])."</label>"
692
+				. "<input type='checkbox' name='checked[]' value='".esc_attr($plugin_file)."' id='".$checkbox_id."' />";
693 693
 		}
694
-		if ( 'dropins' != $context ) {
695
-			$description = '<p>' . ( $plugin_data['Description'] ? $plugin_data['Description'] : '&nbsp;' ) . '</p>';
694
+		if ('dropins' != $context) {
695
+			$description = '<p>'.($plugin_data['Description'] ? $plugin_data['Description'] : '&nbsp;').'</p>';
696 696
 			$plugin_name = $plugin_data['Name'];
697 697
 		}
698 698
 
699
-		if ( ! empty( $totals['upgrade'] ) && ! empty( $plugin_data['update'] ) )
699
+		if ( ! empty($totals['upgrade']) && ! empty($plugin_data['update']))
700 700
 			$class .= ' update';
701 701
 
702
-		$plugin_slug = isset( $plugin_data['slug'] ) ? $plugin_data['slug'] : sanitize_title( $plugin_name );
703
-		printf( '<tr class="%s" data-slug="%s" data-plugin="%s">',
704
-			esc_attr( $class ),
705
-			esc_attr( $plugin_slug ),
706
-			esc_attr( $plugin_file )
702
+		$plugin_slug = isset($plugin_data['slug']) ? $plugin_data['slug'] : sanitize_title($plugin_name);
703
+		printf('<tr class="%s" data-slug="%s" data-plugin="%s">',
704
+			esc_attr($class),
705
+			esc_attr($plugin_slug),
706
+			esc_attr($plugin_file)
707 707
 		);
708 708
 
709
-		list( $columns, $hidden, $sortable, $primary ) = $this->get_column_info();
709
+		list($columns, $hidden, $sortable, $primary) = $this->get_column_info();
710 710
 
711
-		foreach ( $columns as $column_name => $column_display_name ) {
711
+		foreach ($columns as $column_name => $column_display_name) {
712 712
 			$extra_classes = '';
713
-			if ( in_array( $column_name, $hidden ) ) {
713
+			if (in_array($column_name, $hidden)) {
714 714
 				$extra_classes = ' hidden';
715 715
 			}
716 716
 
717
-			switch ( $column_name ) {
717
+			switch ($column_name) {
718 718
 				case 'cb':
719 719
 					echo "<th scope='row' class='check-column'>$checkbox</th>";
720 720
 					break;
721 721
 				case 'name':
722 722
 					echo "<td class='plugin-title column-primary'><strong>$plugin_name</strong>";
723
-					echo $this->row_actions( $actions, true );
723
+					echo $this->row_actions($actions, true);
724 724
 					echo "</td>";
725 725
 					break;
726 726
 				case 'description':
@@ -731,28 +731,28 @@  discard block
 block discarded – undo
731 731
 						<div class='$class second plugin-version-author-uri'>";
732 732
 
733 733
 					$plugin_meta = array();
734
-					if ( !empty( $plugin_data['Version'] ) )
735
-						$plugin_meta[] = sprintf( __( 'Version %s' ), $plugin_data['Version'] );
736
-					if ( !empty( $plugin_data['Author'] ) ) {
734
+					if ( ! empty($plugin_data['Version']))
735
+						$plugin_meta[] = sprintf(__('Version %s'), $plugin_data['Version']);
736
+					if ( ! empty($plugin_data['Author'])) {
737 737
 						$author = $plugin_data['Author'];
738
-						if ( !empty( $plugin_data['AuthorURI'] ) )
739
-							$author = '<a href="' . $plugin_data['AuthorURI'] . '">' . $plugin_data['Author'] . '</a>';
740
-						$plugin_meta[] = sprintf( __( 'By %s' ), $author );
738
+						if ( ! empty($plugin_data['AuthorURI']))
739
+							$author = '<a href="'.$plugin_data['AuthorURI'].'">'.$plugin_data['Author'].'</a>';
740
+						$plugin_meta[] = sprintf(__('By %s'), $author);
741 741
 					}
742 742
 
743 743
 					// Details link using API info, if available
744
-					if ( isset( $plugin_data['slug'] ) && current_user_can( 'install_plugins' ) ) {
745
-						$plugin_meta[] = sprintf( '<a href="%s" class="thickbox open-plugin-details-modal" aria-label="%s" data-title="%s">%s</a>',
746
-							esc_url( network_admin_url( 'plugin-install.php?tab=plugin-information&plugin=' . $plugin_data['slug'] .
747
-								'&TB_iframe=true&width=600&height=550' ) ),
748
-							esc_attr( sprintf( __( 'More information about %s' ), $plugin_name ) ),
749
-							esc_attr( $plugin_name ),
750
-							__( 'View details' )
744
+					if (isset($plugin_data['slug']) && current_user_can('install_plugins')) {
745
+						$plugin_meta[] = sprintf('<a href="%s" class="thickbox open-plugin-details-modal" aria-label="%s" data-title="%s">%s</a>',
746
+							esc_url(network_admin_url('plugin-install.php?tab=plugin-information&plugin='.$plugin_data['slug'].
747
+								'&TB_iframe=true&width=600&height=550')),
748
+							esc_attr(sprintf(__('More information about %s'), $plugin_name)),
749
+							esc_attr($plugin_name),
750
+							__('View details')
751 751
 						);
752
-					} elseif ( ! empty( $plugin_data['PluginURI'] ) ) {
753
-						$plugin_meta[] = sprintf( '<a href="%s">%s</a>',
754
-							esc_url( $plugin_data['PluginURI'] ),
755
-							__( 'Visit plugin site' )
752
+					} elseif ( ! empty($plugin_data['PluginURI'])) {
753
+						$plugin_meta[] = sprintf('<a href="%s">%s</a>',
754
+							esc_url($plugin_data['PluginURI']),
755
+							__('Visit plugin site')
756 756
 						);
757 757
 					}
758 758
 
@@ -770,8 +770,8 @@  discard block
 block discarded – undo
770 770
 					 *                            'Inactive', 'Recently Activated', 'Upgrade', 'Must-Use',
771 771
 					 *                            'Drop-ins', 'Search'.
772 772
 					 */
773
-					$plugin_meta = apply_filters( 'plugin_row_meta', $plugin_meta, $plugin_file, $plugin_data, $status );
774
-					echo implode( ' | ', $plugin_meta );
773
+					$plugin_meta = apply_filters('plugin_row_meta', $plugin_meta, $plugin_file, $plugin_data, $status);
774
+					echo implode(' | ', $plugin_meta);
775 775
 
776 776
 					echo "</div></td>";
777 777
 					break;
@@ -789,7 +789,7 @@  discard block
 block discarded – undo
789 789
 					 * @param string $plugin_file Path to the plugin file.
790 790
 					 * @param array  $plugin_data An array of plugin data.
791 791
 					 */
792
-					do_action( 'manage_plugins_custom_column', $column_name, $plugin_file, $plugin_data );
792
+					do_action('manage_plugins_custom_column', $column_name, $plugin_file, $plugin_data);
793 793
 
794 794
 					echo "</td>";
795 795
 			}
@@ -808,7 +808,7 @@  discard block
 block discarded – undo
808 808
 		 *                            'Inactive', 'Recently Activated', 'Upgrade', 'Must-Use',
809 809
 		 *                            'Drop-ins', 'Search'.
810 810
 		 */
811
-		do_action( 'after_plugin_row', $plugin_file, $plugin_data, $status );
811
+		do_action('after_plugin_row', $plugin_file, $plugin_data, $status);
812 812
 
813 813
 		/**
814 814
 		 * Fires after each specific row in the Plugins list table.
@@ -824,7 +824,7 @@  discard block
 block discarded – undo
824 824
 		 *                            'Inactive', 'Recently Activated', 'Upgrade', 'Must-Use',
825 825
 		 *                            'Drop-ins', 'Search'.
826 826
 		 */
827
-		do_action( "after_plugin_row_$plugin_file", $plugin_file, $plugin_data, $status );
827
+		do_action("after_plugin_row_$plugin_file", $plugin_file, $plugin_data, $status);
828 828
 	}
829 829
 
830 830
 	/**
Please login to merge, or discard this patch.
Braces   +71 added lines, -48 removed lines patch added patch discarded remove patch
@@ -39,11 +39,13 @@  discard block
 block discarded – undo
39 39
 		) );
40 40
 
41 41
 		$status = 'all';
42
-		if ( isset( $_REQUEST['plugin_status'] ) && in_array( $_REQUEST['plugin_status'], array( 'active', 'inactive', 'recently_activated', 'upgrade', 'mustuse', 'dropins', 'search' ) ) )
43
-			$status = $_REQUEST['plugin_status'];
42
+		if ( isset( $_REQUEST['plugin_status'] ) && in_array( $_REQUEST['plugin_status'], array( 'active', 'inactive', 'recently_activated', 'upgrade', 'mustuse', 'dropins', 'search' ) ) ) {
43
+					$status = $_REQUEST['plugin_status'];
44
+		}
44 45
 
45
-		if ( isset($_REQUEST['s']) )
46
-			$_SERVER['REQUEST_URI'] = add_query_arg('s', wp_unslash($_REQUEST['s']) );
46
+		if ( isset($_REQUEST['s']) ) {
47
+					$_SERVER['REQUEST_URI'] = add_query_arg('s', wp_unslash($_REQUEST['s']) );
48
+		}
47 49
 
48 50
 		$page = $this->get_pagenum();
49 51
 	}
@@ -123,8 +125,9 @@  discard block
 block discarded – undo
123 125
 			}
124 126
 
125 127
 			/** This action is documented in wp-admin/includes/class-wp-plugins-list-table.php */
126
-			if ( apply_filters( 'show_advanced_plugins', true, 'dropins' ) )
127
-				$plugins['dropins'] = get_dropins();
128
+			if ( apply_filters( 'show_advanced_plugins', true, 'dropins' ) ) {
129
+							$plugins['dropins'] = get_dropins();
130
+			}
128 131
 
129 132
 			if ( current_user_can( 'update_plugins' ) ) {
130 133
 				$current = get_site_transient( 'update_plugins' );
@@ -232,11 +235,13 @@  discard block
 block discarded – undo
232 235
 		}
233 236
 
234 237
 		$totals = array();
235
-		foreach ( $plugins as $type => $list )
236
-			$totals[ $type ] = count( $list );
238
+		foreach ( $plugins as $type => $list ) {
239
+					$totals[ $type ] = count( $list );
240
+		}
237 241
 
238
-		if ( empty( $plugins[ $status ] ) && !in_array( $status, array( 'all', 'search' ) ) )
239
-			$status = 'all';
242
+		if ( empty( $plugins[ $status ] ) && !in_array( $status, array( 'all', 'search' ) ) ) {
243
+					$status = 'all';
244
+		}
240 245
 
241 246
 		$this->items = array();
242 247
 		foreach ( $plugins[ $status ] as $plugin_file => $plugin_data ) {
@@ -260,8 +265,9 @@  discard block
 block discarded – undo
260 265
 
261 266
 		$start = ( $page - 1 ) * $plugins_per_page;
262 267
 
263
-		if ( $total_this_page > $plugins_per_page )
264
-			$this->items = array_slice( $this->items, $start, $plugins_per_page );
268
+		if ( $total_this_page > $plugins_per_page ) {
269
+					$this->items = array_slice( $this->items, $start, $plugins_per_page );
270
+		}
265 271
 
266 272
 		$this->set_pagination_args( array(
267 273
 			'total_items' => $total_this_page,
@@ -300,8 +306,9 @@  discard block
 block discarded – undo
300 306
 		$a = $plugin_a[$orderby];
301 307
 		$b = $plugin_b[$orderby];
302 308
 
303
-		if ( $a == $b )
304
-			return 0;
309
+		if ( $a == $b ) {
310
+					return 0;
311
+		}
305 312
 
306 313
 		if ( 'DESC' === $order ) {
307 314
 			return strcasecmp( $b, $a );
@@ -326,10 +333,11 @@  discard block
 block discarded – undo
326 333
 			if ( ! is_multisite() && current_user_can( 'install_plugins' ) ) {
327 334
 				echo ' <a href="' . esc_url( admin_url( 'plugin-install.php?tab=search&s=' . urlencode( $s ) ) ) . '">' . __( 'Search for plugins in the WordPress Plugin Directory.' ) . '</a>';
328 335
 			}
329
-		} elseif ( ! empty( $plugins['all'] ) )
330
-			_e( 'No plugins found.' );
331
-		else
332
-			_e( 'You do not appear to have any plugins available at this time.' );
336
+		} elseif ( ! empty( $plugins['all'] ) ) {
337
+					_e( 'No plugins found.' );
338
+		} else {
339
+					_e( 'You do not appear to have any plugins available at this time.' );
340
+		}
333 341
 	}
334 342
 
335 343
 	/**
@@ -365,8 +373,9 @@  discard block
 block discarded – undo
365 373
 
366 374
 		$status_links = array();
367 375
 		foreach ( $totals as $type => $count ) {
368
-			if ( !$count )
369
-				continue;
376
+			if ( !$count ) {
377
+							continue;
378
+			}
370 379
 
371 380
 			switch ( $type ) {
372 381
 				case 'all':
@@ -414,17 +423,21 @@  discard block
 block discarded – undo
414 423
 
415 424
 		$actions = array();
416 425
 
417
-		if ( 'active' != $status )
418
-			$actions['activate-selected'] = $this->screen->in_admin( 'network' ) ? __( 'Network Activate' ) : __( 'Activate' );
426
+		if ( 'active' != $status ) {
427
+					$actions['activate-selected'] = $this->screen->in_admin( 'network' ) ? __( 'Network Activate' ) : __( 'Activate' );
428
+		}
419 429
 
420
-		if ( 'inactive' != $status && 'recent' != $status )
421
-			$actions['deactivate-selected'] = $this->screen->in_admin( 'network' ) ? __( 'Network Deactivate' ) : __( 'Deactivate' );
430
+		if ( 'inactive' != $status && 'recent' != $status ) {
431
+					$actions['deactivate-selected'] = $this->screen->in_admin( 'network' ) ? __( 'Network Deactivate' ) : __( 'Deactivate' );
432
+		}
422 433
 
423 434
 		if ( !is_multisite() || $this->screen->in_admin( 'network' ) ) {
424
-			if ( current_user_can( 'update_plugins' ) )
425
-				$actions['update-selected'] = __( 'Update' );
426
-			if ( current_user_can( 'delete_plugins' ) && ( 'active' != $status ) )
427
-				$actions['delete-selected'] = __( 'Delete' );
435
+			if ( current_user_can( 'update_plugins' ) ) {
436
+							$actions['update-selected'] = __( 'Update' );
437
+			}
438
+			if ( current_user_can( 'delete_plugins' ) && ( 'active' != $status ) ) {
439
+							$actions['delete-selected'] = __( 'Delete' );
440
+			}
428 441
 		}
429 442
 
430 443
 		return $actions;
@@ -437,8 +450,9 @@  discard block
 block discarded – undo
437 450
 	public function bulk_actions( $which = '' ) {
438 451
 		global $status;
439 452
 
440
-		if ( in_array( $status, array( 'mustuse', 'dropins' ) ) )
441
-			return;
453
+		if ( in_array( $status, array( 'mustuse', 'dropins' ) ) ) {
454
+					return;
455
+		}
442 456
 
443 457
 		parent::bulk_actions( $which );
444 458
 	}
@@ -450,8 +464,9 @@  discard block
 block discarded – undo
450 464
 	protected function extra_tablenav( $which ) {
451 465
 		global $status;
452 466
 
453
-		if ( ! in_array($status, array('recently_activated', 'mustuse', 'dropins') ) )
454
-			return;
467
+		if ( ! in_array($status, array('recently_activated', 'mustuse', 'dropins') ) ) {
468
+					return;
469
+		}
455 470
 
456 471
 		echo '<div class="alignleft actions">';
457 472
 
@@ -475,8 +490,9 @@  discard block
 block discarded – undo
475 490
 	 * @return string
476 491
 	 */
477 492
 	public function current_action() {
478
-		if ( isset($_POST['clear-recent-list']) )
479
-			return 'clear-recent-list';
493
+		if ( isset($_POST['clear-recent-list']) ) {
494
+					return 'clear-recent-list';
495
+		}
480 496
 
481 497
 		return parent::current_action();
482 498
 	}
@@ -488,11 +504,13 @@  discard block
 block discarded – undo
488 504
 	public function display_rows() {
489 505
 		global $status;
490 506
 
491
-		if ( is_multisite() && ! $this->screen->in_admin( 'network' ) && in_array( $status, array( 'mustuse', 'dropins' ) ) )
492
-			return;
507
+		if ( is_multisite() && ! $this->screen->in_admin( 'network' ) && in_array( $status, array( 'mustuse', 'dropins' ) ) ) {
508
+					return;
509
+		}
493 510
 
494
-		foreach ( $this->items as $plugin_file => $plugin_data )
495
-			$this->single_row( array( $plugin_file, $plugin_data ) );
511
+		foreach ( $this->items as $plugin_file => $plugin_data ) {
512
+					$this->single_row( array( $plugin_file, $plugin_data ) );
513
+		}
496 514
 	}
497 515
 
498 516
 	/**
@@ -528,8 +546,9 @@  discard block
 block discarded – undo
528 546
 		} elseif ( 'dropins' === $context ) {
529 547
 			$dropins = _get_dropins();
530 548
 			$plugin_name = $plugin_file;
531
-			if ( $plugin_file != $plugin_data['Name'] )
532
-				$plugin_name .= '<br/>' . $plugin_data['Name'];
549
+			if ( $plugin_file != $plugin_data['Name'] ) {
550
+							$plugin_name .= '<br/>' . $plugin_data['Name'];
551
+			}
533 552
 			if ( true === ( $dropins[ $plugin_file ][1] ) ) { // Doesn't require a constant
534 553
 				$is_active = true;
535 554
 				$description = '<p><strong>' . $dropins[ $plugin_file ][0] . '</strong></p>';
@@ -545,8 +564,9 @@  discard block
 block discarded – undo
545 564
 						'<code>wp-config.php</code>'
546 565
 					) . '</p>';
547 566
 			}
548
-			if ( $plugin_data['Description'] )
549
-				$description .= '<p>' . $plugin_data['Description'] . '</p>';
567
+			if ( $plugin_data['Description'] ) {
568
+							$description .= '<p>' . $plugin_data['Description'] . '</p>';
569
+			}
550 570
 		} else {
551 571
 			if ( $screen->in_admin( 'network' ) ) {
552 572
 				$is_active = is_plugin_active_for_network( $plugin_file );
@@ -696,8 +716,9 @@  discard block
 block discarded – undo
696 716
 			$plugin_name = $plugin_data['Name'];
697 717
 		}
698 718
 
699
-		if ( ! empty( $totals['upgrade'] ) && ! empty( $plugin_data['update'] ) )
700
-			$class .= ' update';
719
+		if ( ! empty( $totals['upgrade'] ) && ! empty( $plugin_data['update'] ) ) {
720
+					$class .= ' update';
721
+		}
701 722
 
702 723
 		$plugin_slug = isset( $plugin_data['slug'] ) ? $plugin_data['slug'] : sanitize_title( $plugin_name );
703 724
 		printf( '<tr class="%s" data-slug="%s" data-plugin="%s">',
@@ -731,12 +752,14 @@  discard block
 block discarded – undo
731 752
 						<div class='$class second plugin-version-author-uri'>";
732 753
 
733 754
 					$plugin_meta = array();
734
-					if ( !empty( $plugin_data['Version'] ) )
735
-						$plugin_meta[] = sprintf( __( 'Version %s' ), $plugin_data['Version'] );
755
+					if ( !empty( $plugin_data['Version'] ) ) {
756
+											$plugin_meta[] = sprintf( __( 'Version %s' ), $plugin_data['Version'] );
757
+					}
736 758
 					if ( !empty( $plugin_data['Author'] ) ) {
737 759
 						$author = $plugin_data['Author'];
738
-						if ( !empty( $plugin_data['AuthorURI'] ) )
739
-							$author = '<a href="' . $plugin_data['AuthorURI'] . '">' . $plugin_data['Author'] . '</a>';
760
+						if ( !empty( $plugin_data['AuthorURI'] ) ) {
761
+													$author = '<a href="' . $plugin_data['AuthorURI'] . '">' . $plugin_data['Author'] . '</a>';
762
+						}
740 763
 						$plugin_meta[] = sprintf( __( 'By %s' ), $author );
741 764
 					}
742 765
 
Please login to merge, or discard this patch.
src/wp-admin/includes/nav-menu.php 3 patches
Indentation   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -1,11 +1,11 @@
 block discarded – undo
1 1
 <?php
2 2
 /**
3
- * Core Navigation Menu API
4
- *
5
- * @package WordPress
6
- * @subpackage Nav_Menus
7
- * @since 3.0.0
8
- */
3
+	 * Core Navigation Menu API
4
+	 *
5
+	 * @package WordPress
6
+	 * @subpackage Nav_Menus
7
+	 * @since 3.0.0
8
+	 */
9 9
 
10 10
 /** Walker_Nav_Menu_Edit class */
11 11
 require_once( ABSPATH . 'wp-admin/includes/class-walker-nav-menu-edit.php' );
Please login to merge, or discard this patch.
Spacing   +269 added lines, -269 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,21 +68,21 @@  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] ) ) {
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 73
 			query_posts(array(
74 74
 				'posts_per_page' => 10,
75 75
 				'post_type' => $matches[2],
76 76
 				's' => $query,
77 77
 			));
78
-			if ( ! have_posts() )
78
+			if ( ! have_posts())
79 79
 				return;
80
-			while ( have_posts() ) {
80
+			while (have_posts()) {
81 81
 				the_post();
82
-				if ( 'markup' == $response_format ) {
82
+				if ('markup' == $response_format) {
83 83
 					$var_by_ref = get_the_ID();
84
-					echo walk_nav_menu_tree( array_map('wp_setup_nav_menu_item', array( get_post( $var_by_ref ) ) ), 0, (object) $args );
85
-				} elseif ( 'json' == $response_format ) {
84
+					echo walk_nav_menu_tree(array_map('wp_setup_nav_menu_item', array(get_post($var_by_ref))), 0, (object) $args);
85
+				} elseif ('json' == $response_format) {
86 86
 					echo wp_json_encode(
87 87
 						array(
88 88
 							'ID' => get_the_ID(),
@@ -93,17 +93,17 @@  discard block
 block discarded – undo
93 93
 					echo "\n";
94 94
 				}
95 95
 			}
96
-		} elseif ( 'taxonomy' == $matches[1] ) {
97
-			$terms = get_terms( $matches[2], array(
96
+		} elseif ('taxonomy' == $matches[1]) {
97
+			$terms = get_terms($matches[2], array(
98 98
 				'name__like' => $query,
99 99
 				'number' => 10,
100 100
 			));
101
-			if ( empty( $terms ) || is_wp_error( $terms ) )
101
+			if (empty($terms) || is_wp_error($terms))
102 102
 				return;
103
-			foreach ( (array) $terms as $term ) {
104
-				if ( 'markup' == $response_format ) {
105
-					echo walk_nav_menu_tree( array_map('wp_setup_nav_menu_item', array( $term ) ), 0, (object) $args );
106
-				} elseif ( 'json' == $response_format ) {
103
+			foreach ((array) $terms as $term) {
104
+				if ('markup' == $response_format) {
105
+					echo walk_nav_menu_tree(array_map('wp_setup_nav_menu_item', array($term)), 0, (object) $args);
106
+				} elseif ('json' == $response_format) {
107 107
 					echo wp_json_encode(
108 108
 						array(
109 109
 							'ID' => $term->term_id,
@@ -126,17 +126,17 @@  discard block
 block discarded – undo
126 126
 function wp_nav_menu_setup() {
127 127
 	// Register meta boxes
128 128
 	wp_nav_menu_post_type_meta_boxes();
129
-	add_meta_box( 'add-custom-links', __( 'Custom Links' ), 'wp_nav_menu_item_link_meta_box', 'nav-menus', 'side', 'default' );
129
+	add_meta_box('add-custom-links', __('Custom Links'), 'wp_nav_menu_item_link_meta_box', 'nav-menus', 'side', 'default');
130 130
 	wp_nav_menu_taxonomy_meta_boxes();
131 131
 
132 132
 	// Register advanced menu items (columns)
133
-	add_filter( 'manage_nav-menus_columns', 'wp_nav_menu_manage_columns' );
133
+	add_filter('manage_nav-menus_columns', 'wp_nav_menu_manage_columns');
134 134
 
135 135
 	// If first time editing, disable advanced items by default.
136
-	if ( false === get_user_option( 'managenav-menuscolumnshidden' ) ) {
136
+	if (false === get_user_option('managenav-menuscolumnshidden')) {
137 137
 		$user = wp_get_current_user();
138 138
 		update_user_option($user->ID, 'managenav-menuscolumnshidden',
139
-			array( 0 => 'link-target', 1 => 'css-classes', 2 => 'xfn', 3 => 'description', 4 => 'title-attribute', ),
139
+			array(0 => 'link-target', 1 => 'css-classes', 2 => 'xfn', 3 => 'description', 4 => 'title-attribute',),
140 140
 			true);
141 141
 	}
142 142
 }
@@ -151,17 +151,17 @@  discard block
 block discarded – undo
151 151
 function wp_initial_nav_menu_meta_boxes() {
152 152
 	global $wp_meta_boxes;
153 153
 
154
-	if ( get_user_option( 'metaboxhidden_nav-menus' ) !== false || ! is_array($wp_meta_boxes) )
154
+	if (get_user_option('metaboxhidden_nav-menus') !== false || ! is_array($wp_meta_boxes))
155 155
 		return;
156 156
 
157
-	$initial_meta_boxes = array( 'add-post-type-page', 'add-post-type-post', 'add-custom-links', 'add-category' );
157
+	$initial_meta_boxes = array('add-post-type-page', 'add-post-type-post', 'add-custom-links', 'add-category');
158 158
 	$hidden_meta_boxes = array();
159 159
 
160
-	foreach ( array_keys($wp_meta_boxes['nav-menus']) as $context ) {
161
-		foreach ( array_keys($wp_meta_boxes['nav-menus'][$context]) as $priority ) {
162
-			foreach ( $wp_meta_boxes['nav-menus'][$context][$priority] as $box ) {
163
-				if ( in_array( $box['id'], $initial_meta_boxes ) ) {
164
-					unset( $box['id'] );
160
+	foreach (array_keys($wp_meta_boxes['nav-menus']) as $context) {
161
+		foreach (array_keys($wp_meta_boxes['nav-menus'][$context]) as $priority) {
162
+			foreach ($wp_meta_boxes['nav-menus'][$context][$priority] as $box) {
163
+				if (in_array($box['id'], $initial_meta_boxes)) {
164
+					unset($box['id']);
165 165
 				} else {
166 166
 					$hidden_meta_boxes[] = $box['id'];
167 167
 				}
@@ -170,7 +170,7 @@  discard block
 block discarded – undo
170 170
 	}
171 171
 
172 172
 	$user = wp_get_current_user();
173
-	update_user_option( $user->ID, 'metaboxhidden_nav-menus', $hidden_meta_boxes, true );
173
+	update_user_option($user->ID, 'metaboxhidden_nav-menus', $hidden_meta_boxes, true);
174 174
 }
175 175
 
176 176
 /**
@@ -179,12 +179,12 @@  discard block
 block discarded – undo
179 179
  * @since 3.0.0
180 180
  */
181 181
 function wp_nav_menu_post_type_meta_boxes() {
182
-	$post_types = get_post_types( array( 'show_in_nav_menus' => true ), 'object' );
182
+	$post_types = get_post_types(array('show_in_nav_menus' => true), 'object');
183 183
 
184
-	if ( ! $post_types )
184
+	if ( ! $post_types)
185 185
 		return;
186 186
 
187
-	foreach ( $post_types as $post_type ) {
187
+	foreach ($post_types as $post_type) {
188 188
 		/**
189 189
 		 * Filter whether a menu items meta box will be added for the current
190 190
 		 * object type.
@@ -197,12 +197,12 @@  discard block
 block discarded – undo
197 197
 		 * @param object $meta_box_object The current object to add a menu items
198 198
 		 *                                meta box for.
199 199
 		 */
200
-		$post_type = apply_filters( 'nav_menu_meta_box_object', $post_type );
201
-		if ( $post_type ) {
200
+		$post_type = apply_filters('nav_menu_meta_box_object', $post_type);
201
+		if ($post_type) {
202 202
 			$id = $post_type->name;
203 203
 			// Give pages a higher priority.
204
-			$priority = ( 'page' == $post_type->name ? 'core' : 'default' );
205
-			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 );
204
+			$priority = ('page' == $post_type->name ? 'core' : 'default');
205
+			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);
206 206
 		}
207 207
 	}
208 208
 }
@@ -213,17 +213,17 @@  discard block
 block discarded – undo
213 213
  * @since 3.0.0
214 214
  */
215 215
 function wp_nav_menu_taxonomy_meta_boxes() {
216
-	$taxonomies = get_taxonomies( array( 'show_in_nav_menus' => true ), 'object' );
216
+	$taxonomies = get_taxonomies(array('show_in_nav_menus' => true), 'object');
217 217
 
218
-	if ( !$taxonomies )
218
+	if ( ! $taxonomies)
219 219
 		return;
220 220
 
221
-	foreach ( $taxonomies as $tax ) {
221
+	foreach ($taxonomies as $tax) {
222 222
 		/** This filter is documented in wp-admin/includes/nav-menu.php */
223
-		$tax = apply_filters( 'nav_menu_meta_box_object', $tax );
224
-		if ( $tax ) {
223
+		$tax = apply_filters('nav_menu_meta_box_object', $tax);
224
+		if ($tax) {
225 225
 			$id = $tax->name;
226
-			add_meta_box( "add-{$id}", $tax->labels->name, 'wp_nav_menu_item_taxonomy_meta_box', 'nav-menus', 'side', 'default', $tax );
226
+			add_meta_box("add-{$id}", $tax->labels->name, 'wp_nav_menu_item_taxonomy_meta_box', 'nav-menus', 'side', 'default', $tax);
227 227
 		}
228 228
 	}
229 229
 }
@@ -238,13 +238,13 @@  discard block
 block discarded – undo
238 238
  * @param int|string $nav_menu_selected_id (id, name or slug) of the currently-selected menu
239 239
  * @return string Disabled attribute if at least one menu exists, false if not
240 240
  */
241
-function wp_nav_menu_disabled_check( $nav_menu_selected_id ) {
241
+function wp_nav_menu_disabled_check($nav_menu_selected_id) {
242 242
 	global $one_theme_location_no_menus;
243 243
 
244
-	if ( $one_theme_location_no_menus )
244
+	if ($one_theme_location_no_menus)
245 245
 		return false;
246 246
 
247
-	return disabled( $nav_menu_selected_id, 0 );
247
+	return disabled($nav_menu_selected_id, 0);
248 248
 }
249 249
 
250 250
 /**
@@ -264,18 +264,18 @@  discard block
 block discarded – undo
264 264
 	<div class="customlinkdiv" id="customlinkdiv">
265 265
 		<input type="hidden" value="custom" name="menu-item[<?php echo $_nav_menu_placeholder; ?>][menu-item-type]" />
266 266
 		<p id="menu-item-url-wrap" class="wp-clearfix">
267
-			<label class="howto" for="custom-menu-item-url"><?php _e( 'URL' ); ?></label>
267
+			<label class="howto" for="custom-menu-item-url"><?php _e('URL'); ?></label>
268 268
 			<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://" />
269 269
 		</p>
270 270
 
271 271
 		<p id="menu-item-name-wrap" class="wp-clearfix">
272
-			<label class="howto" for="custom-menu-item-name"><?php _e( 'Link Text' ); ?></label>
272
+			<label class="howto" for="custom-menu-item-name"><?php _e('Link Text'); ?></label>
273 273
 			<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" />
274 274
 		</p>
275 275
 
276 276
 		<p class="button-controls wp-clearfix">
277 277
 			<span class="add-to-menu">
278
-				<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" />
278
+				<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" />
279 279
 				<span class="spinner"></span>
280 280
 			</span>
281 281
 		</p>
@@ -295,15 +295,15 @@  discard block
 block discarded – undo
295 295
  * @param string $object Not used.
296 296
  * @param string $post_type The post type object.
297 297
  */
298
-function wp_nav_menu_item_post_type_meta_box( $object, $post_type ) {
298
+function wp_nav_menu_item_post_type_meta_box($object, $post_type) {
299 299
 	global $_nav_menu_placeholder, $nav_menu_selected_id;
300 300
 
301 301
 	$post_type_name = $post_type['args']->name;
302 302
 
303 303
 	// Paginate browsing for large numbers of post objects.
304 304
 	$per_page = 50;
305
-	$pagenum = isset( $_REQUEST[$post_type_name . '-tab'] ) && isset( $_REQUEST['paged'] ) ? absint( $_REQUEST['paged'] ) : 1;
306
-	$offset = 0 < $pagenum ? $per_page * ( $pagenum - 1 ) : 0;
305
+	$pagenum = isset($_REQUEST[$post_type_name.'-tab']) && isset($_REQUEST['paged']) ? absint($_REQUEST['paged']) : 1;
306
+	$offset = 0 < $pagenum ? $per_page * ($pagenum - 1) : 0;
307 307
 
308 308
 	$args = array(
309 309
 		'offset' => $offset,
@@ -316,23 +316,23 @@  discard block
 block discarded – undo
316 316
 		'update_post_meta_cache' => false
317 317
 	);
318 318
 
319
-	if ( isset( $post_type['args']->_default_query ) )
320
-		$args = array_merge($args, (array) $post_type['args']->_default_query );
319
+	if (isset($post_type['args']->_default_query))
320
+		$args = array_merge($args, (array) $post_type['args']->_default_query);
321 321
 
322 322
 	// @todo transient caching of these results with proper invalidation on updating of a post of this type
323 323
 	$get_posts = new WP_Query;
324
-	$posts = $get_posts->query( $args );
325
-	if ( ! $get_posts->post_count ) {
326
-		echo '<p>' . __( 'No items.' ) . '</p>';
324
+	$posts = $get_posts->query($args);
325
+	if ( ! $get_posts->post_count) {
326
+		echo '<p>'.__('No items.').'</p>';
327 327
 		return;
328 328
 	}
329 329
 
330 330
 	$num_pages = $get_posts->max_num_pages;
331 331
 
332
-	$page_links = paginate_links( array(
332
+	$page_links = paginate_links(array(
333 333
 		'base' => add_query_arg(
334 334
 			array(
335
-				$post_type_name . '-tab' => 'all',
335
+				$post_type_name.'-tab' => 'all',
336 336
 				'paged' => '%#%',
337 337
 				'item-type' => 'post_type',
338 338
 				'item-object' => $post_type_name,
@@ -346,18 +346,18 @@  discard block
 block discarded – undo
346 346
 	));
347 347
 
348 348
 	$db_fields = false;
349
-	if ( is_post_type_hierarchical( $post_type_name ) ) {
350
-		$db_fields = array( 'parent' => 'post_parent', 'id' => 'ID' );
349
+	if (is_post_type_hierarchical($post_type_name)) {
350
+		$db_fields = array('parent' => 'post_parent', 'id' => 'ID');
351 351
 	}
352 352
 
353
-	$walker = new Walker_Nav_Menu_Checklist( $db_fields );
353
+	$walker = new Walker_Nav_Menu_Checklist($db_fields);
354 354
 
355 355
 	$current_tab = 'most-recent';
356
-	if ( isset( $_REQUEST[$post_type_name . '-tab'] ) && in_array( $_REQUEST[$post_type_name . '-tab'], array('all', 'search') ) ) {
357
-		$current_tab = $_REQUEST[$post_type_name . '-tab'];
356
+	if (isset($_REQUEST[$post_type_name.'-tab']) && in_array($_REQUEST[$post_type_name.'-tab'], array('all', 'search'))) {
357
+		$current_tab = $_REQUEST[$post_type_name.'-tab'];
358 358
 	}
359 359
 
360
-	if ( ! empty( $_REQUEST['quick-search-posttype-' . $post_type_name] ) ) {
360
+	if ( ! empty($_REQUEST['quick-search-posttype-'.$post_type_name])) {
361 361
 		$current_tab = 'search';
362 362
 	}
363 363
 
@@ -373,30 +373,30 @@  discard block
 block discarded – undo
373 373
 	?>
374 374
 	<div id="posttype-<?php echo $post_type_name; ?>" class="posttypediv">
375 375
 		<ul id="posttype-<?php echo $post_type_name; ?>-tabs" class="posttype-tabs add-menu-item-tabs">
376
-			<li <?php echo ( 'most-recent' == $current_tab ? ' class="tabs"' : '' ); ?>>
377
-				<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">
378
-					<?php _e( 'Most Recent' ); ?>
376
+			<li <?php echo ('most-recent' == $current_tab ? ' class="tabs"' : ''); ?>>
377
+				<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">
378
+					<?php _e('Most Recent'); ?>
379 379
 				</a>
380 380
 			</li>
381
-			<li <?php echo ( 'all' == $current_tab ? ' class="tabs"' : '' ); ?>>
382
-				<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">
383
-					<?php _e( 'View All' ); ?>
381
+			<li <?php echo ('all' == $current_tab ? ' class="tabs"' : ''); ?>>
382
+				<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">
383
+					<?php _e('View All'); ?>
384 384
 				</a>
385 385
 			</li>
386
-			<li <?php echo ( 'search' == $current_tab ? ' class="tabs"' : '' ); ?>>
387
-				<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">
388
-					<?php _e( 'Search'); ?>
386
+			<li <?php echo ('search' == $current_tab ? ' class="tabs"' : ''); ?>>
387
+				<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">
388
+					<?php _e('Search'); ?>
389 389
 				</a>
390 390
 			</li>
391 391
 		</ul><!-- .posttype-tabs -->
392 392
 
393 393
 		<div id="tabs-panel-posttype-<?php echo $post_type_name; ?>-most-recent" class="tabs-panel <?php
394
-			echo ( 'most-recent' == $current_tab ? 'tabs-panel-active' : 'tabs-panel-inactive' );
394
+			echo ('most-recent' == $current_tab ? 'tabs-panel-active' : 'tabs-panel-inactive');
395 395
 		?>">
396 396
 			<ul id="<?php echo $post_type_name; ?>checklist-most-recent" class="categorychecklist form-no-clear">
397 397
 				<?php
398
-				$recent_args = array_merge( $args, array( 'orderby' => 'post_date', 'order' => 'DESC', 'posts_per_page' => 15 ) );
399
-				$most_recent = $get_posts->query( $recent_args );
398
+				$recent_args = array_merge($args, array('orderby' => 'post_date', 'order' => 'DESC', 'posts_per_page' => 15));
399
+				$most_recent = $get_posts->query($recent_args);
400 400
 				$args['walker'] = $walker;
401 401
 
402 402
 				/**
@@ -411,50 +411,50 @@  discard block
 block discarded – undo
411 411
 				 * @param array  $args        An array of WP_Query arguments.
412 412
 				 * @param object $post_type   The current post type object for this menu item meta box.
413 413
 				 */
414
-				$most_recent = apply_filters( "nav_menu_items_{$post_type_name}_recent", $most_recent, $args, $post_type );
414
+				$most_recent = apply_filters("nav_menu_items_{$post_type_name}_recent", $most_recent, $args, $post_type);
415 415
 
416
-				echo walk_nav_menu_tree( array_map('wp_setup_nav_menu_item', $most_recent), 0, (object) $args );
416
+				echo walk_nav_menu_tree(array_map('wp_setup_nav_menu_item', $most_recent), 0, (object) $args);
417 417
 				?>
418 418
 			</ul>
419 419
 		</div><!-- /.tabs-panel -->
420 420
 
421 421
 		<div class="tabs-panel <?php
422
-			echo ( 'search' == $current_tab ? 'tabs-panel-active' : 'tabs-panel-inactive' );
422
+			echo ('search' == $current_tab ? 'tabs-panel-active' : 'tabs-panel-inactive');
423 423
 		?>" id="tabs-panel-posttype-<?php echo $post_type_name; ?>-search">
424 424
 			<?php
425
-			if ( isset( $_REQUEST['quick-search-posttype-' . $post_type_name] ) ) {
426
-				$searched = esc_attr( $_REQUEST['quick-search-posttype-' . $post_type_name] );
427
-				$search_results = get_posts( array( 's' => $searched, 'post_type' => $post_type_name, 'fields' => 'all', 'order' => 'DESC', ) );
425
+			if (isset($_REQUEST['quick-search-posttype-'.$post_type_name])) {
426
+				$searched = esc_attr($_REQUEST['quick-search-posttype-'.$post_type_name]);
427
+				$search_results = get_posts(array('s' => $searched, 'post_type' => $post_type_name, 'fields' => 'all', 'order' => 'DESC',));
428 428
 			} else {
429 429
 				$searched = '';
430 430
 				$search_results = array();
431 431
 			}
432 432
 			?>
433 433
 			<p class="quick-search-wrap">
434
-				<label for="quick-search-posttype-<?php echo $post_type_name; ?>" class="screen-reader-text"><?php _e( 'Search' ); ?></label>
434
+				<label for="quick-search-posttype-<?php echo $post_type_name; ?>" class="screen-reader-text"><?php _e('Search'); ?></label>
435 435
 				<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; ?>" />
436 436
 				<span class="spinner"></span>
437
-				<?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 ) ); ?>
437
+				<?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)); ?>
438 438
 			</p>
439 439
 
440 440
 			<ul id="<?php echo $post_type_name; ?>-search-checklist" data-wp-lists="list:<?php echo $post_type_name?>" class="categorychecklist form-no-clear">
441
-			<?php if ( ! empty( $search_results ) && ! is_wp_error( $search_results ) ) : ?>
441
+			<?php if ( ! empty($search_results) && ! is_wp_error($search_results)) : ?>
442 442
 				<?php
443 443
 				$args['walker'] = $walker;
444
-				echo walk_nav_menu_tree( array_map('wp_setup_nav_menu_item', $search_results), 0, (object) $args );
444
+				echo walk_nav_menu_tree(array_map('wp_setup_nav_menu_item', $search_results), 0, (object) $args);
445 445
 				?>
446
-			<?php elseif ( is_wp_error( $search_results ) ) : ?>
446
+			<?php elseif (is_wp_error($search_results)) : ?>
447 447
 				<li><?php echo $search_results->get_error_message(); ?></li>
448
-			<?php elseif ( ! empty( $searched ) ) : ?>
448
+			<?php elseif ( ! empty($searched)) : ?>
449 449
 				<li><?php _e('No results found.'); ?></li>
450 450
 			<?php endif; ?>
451 451
 			</ul>
452 452
 		</div><!-- /.tabs-panel -->
453 453
 
454 454
 		<div id="<?php echo $post_type_name; ?>-all" class="tabs-panel tabs-panel-view-all <?php
455
-			echo ( 'all' == $current_tab ? 'tabs-panel-active' : 'tabs-panel-inactive' );
455
+			echo ('all' == $current_tab ? 'tabs-panel-active' : 'tabs-panel-inactive');
456 456
 		?>">
457
-			<?php if ( ! empty( $page_links ) ) : ?>
457
+			<?php if ( ! empty($page_links)) : ?>
458 458
 				<div class="add-menu-item-pagelinks">
459 459
 					<?php echo $page_links; ?>
460 460
 				</div>
@@ -467,15 +467,15 @@  discard block
 block discarded – undo
467 467
 				 * If we're dealing with pages, let's put a checkbox for the front
468 468
 				 * page at the top of the list.
469 469
 				 */
470
-				if ( 'page' == $post_type_name ) {
471
-					$front_page = 'page' == get_option('show_on_front') ? (int) get_option( 'page_on_front' ) : 0;
472
-					if ( ! empty( $front_page ) ) {
473
-						$front_page_obj = get_post( $front_page );
470
+				if ('page' == $post_type_name) {
471
+					$front_page = 'page' == get_option('show_on_front') ? (int) get_option('page_on_front') : 0;
472
+					if ( ! empty($front_page)) {
473
+						$front_page_obj = get_post($front_page);
474 474
 						$front_page_obj->front_or_home = true;
475
-						array_unshift( $posts, $front_page_obj );
475
+						array_unshift($posts, $front_page_obj);
476 476
 					} else {
477
-						$_nav_menu_placeholder = ( 0 > $_nav_menu_placeholder ) ? intval($_nav_menu_placeholder) - 1 : -1;
478
-						array_unshift( $posts, (object) array(
477
+						$_nav_menu_placeholder = (0 > $_nav_menu_placeholder) ? intval($_nav_menu_placeholder) - 1 : -1;
478
+						array_unshift($posts, (object) array(
479 479
 							'front_or_home' => true,
480 480
 							'ID' => 0,
481 481
 							'object_id' => $_nav_menu_placeholder,
@@ -486,15 +486,15 @@  discard block
 block discarded – undo
486 486
 							'post_type' => 'nav_menu_item',
487 487
 							'type' => 'custom',
488 488
 							'url' => home_url('/'),
489
-						) );
489
+						));
490 490
 					}
491 491
 				}
492 492
 
493
-				$post_type = get_post_type_object( $post_type_name );
494
-				$archive_link = get_post_type_archive_link( $post_type_name );
495
-				if ( $post_type->has_archive ) {
496
-					$_nav_menu_placeholder = ( 0 > $_nav_menu_placeholder ) ? intval($_nav_menu_placeholder) - 1 : -1;
497
-					array_unshift( $posts, (object) array(
493
+				$post_type = get_post_type_object($post_type_name);
494
+				$archive_link = get_post_type_archive_link($post_type_name);
495
+				if ($post_type->has_archive) {
496
+					$_nav_menu_placeholder = (0 > $_nav_menu_placeholder) ? intval($_nav_menu_placeholder) - 1 : -1;
497
+					array_unshift($posts, (object) array(
498 498
 						'ID' => 0,
499 499
 						'object_id' => $_nav_menu_placeholder,
500 500
 						'object'     => $post_type_name,
@@ -503,8 +503,8 @@  discard block
 block discarded – undo
503 503
 						'post_title' => $post_type->labels->archives,
504 504
 						'post_type' => 'nav_menu_item',
505 505
 						'type' => 'post_type_archive',
506
-						'url' => get_post_type_archive_link( $post_type_name ),
507
-					) );
506
+						'url' => get_post_type_archive_link($post_type_name),
507
+					));
508 508
 				}
509 509
 
510 510
 				/**
@@ -522,10 +522,10 @@  discard block
 block discarded – undo
522 522
 				 * @param array  $args      An array of WP_Query arguments.
523 523
 				 * @param object $post_type The current post type object for this menu item meta box.
524 524
 				 */
525
-				$posts = apply_filters( "nav_menu_items_{$post_type_name}", $posts, $args, $post_type );
526
-				$checkbox_items = walk_nav_menu_tree( array_map('wp_setup_nav_menu_item', $posts), 0, (object) $args );
525
+				$posts = apply_filters("nav_menu_items_{$post_type_name}", $posts, $args, $post_type);
526
+				$checkbox_items = walk_nav_menu_tree(array_map('wp_setup_nav_menu_item', $posts), 0, (object) $args);
527 527
 
528
-				if ( 'all' == $current_tab && ! empty( $_REQUEST['selectall'] ) ) {
528
+				if ('all' == $current_tab && ! empty($_REQUEST['selectall'])) {
529 529
 					$checkbox_items = preg_replace('/(type=(.)checkbox(\2))/', '$1 checked=$2checked$2', $checkbox_items);
530 530
 
531 531
 				}
@@ -533,7 +533,7 @@  discard block
 block discarded – undo
533 533
 				echo $checkbox_items;
534 534
 				?>
535 535
 			</ul>
536
-			<?php if ( ! empty( $page_links ) ) : ?>
536
+			<?php if ( ! empty($page_links)) : ?>
537 537
 				<div class="add-menu-item-pagelinks">
538 538
 					<?php echo $page_links; ?>
539 539
 				</div>
@@ -543,18 +543,18 @@  discard block
 block discarded – undo
543 543
 		<p class="button-controls wp-clearfix">
544 544
 			<span class="list-controls">
545 545
 				<a href="<?php
546
-					echo esc_url( add_query_arg(
546
+					echo esc_url(add_query_arg(
547 547
 						array(
548
-							$post_type_name . '-tab' => 'all',
548
+							$post_type_name.'-tab' => 'all',
549 549
 							'selectall' => 1,
550 550
 						),
551
-						remove_query_arg( $removed_args )
551
+						remove_query_arg($removed_args)
552 552
 					));
553 553
 				?>#posttype-<?php echo $post_type_name; ?>" class="select-all"><?php _e('Select All'); ?></a>
554 554
 			</span>
555 555
 
556 556
 			<span class="add-to-menu">
557
-				<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 ); ?>" />
557
+				<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); ?>" />
558 558
 				<span class="spinner"></span>
559 559
 			</span>
560 560
 		</p>
@@ -573,14 +573,14 @@  discard block
 block discarded – undo
573 573
  * @param string $object Not used.
574 574
  * @param string $taxonomy The taxonomy object.
575 575
  */
576
-function wp_nav_menu_item_taxonomy_meta_box( $object, $taxonomy ) {
576
+function wp_nav_menu_item_taxonomy_meta_box($object, $taxonomy) {
577 577
 	global $nav_menu_selected_id;
578 578
 	$taxonomy_name = $taxonomy['args']->name;
579 579
 
580 580
 	// Paginate browsing for large numbers of objects.
581 581
 	$per_page = 50;
582
-	$pagenum = isset( $_REQUEST[$taxonomy_name . '-tab'] ) && isset( $_REQUEST['paged'] ) ? absint( $_REQUEST['paged'] ) : 1;
583
-	$offset = 0 < $pagenum ? $per_page * ( $pagenum - 1 ) : 0;
582
+	$pagenum = isset($_REQUEST[$taxonomy_name.'-tab']) && isset($_REQUEST['paged']) ? absint($_REQUEST['paged']) : 1;
583
+	$offset = 0 < $pagenum ? $per_page * ($pagenum - 1) : 0;
584 584
 
585 585
 	$args = array(
586 586
 		'child_of' => 0,
@@ -595,19 +595,19 @@  discard block
 block discarded – undo
595 595
 		'pad_counts' => false,
596 596
 	);
597 597
 
598
-	$terms = get_terms( $taxonomy_name, $args );
598
+	$terms = get_terms($taxonomy_name, $args);
599 599
 
600
-	if ( ! $terms || is_wp_error($terms) ) {
601
-		echo '<p>' . __( 'No items.' ) . '</p>';
600
+	if ( ! $terms || is_wp_error($terms)) {
601
+		echo '<p>'.__('No items.').'</p>';
602 602
 		return;
603 603
 	}
604 604
 
605
-	$num_pages = ceil( wp_count_terms( $taxonomy_name , array_merge( $args, array('number' => '', 'offset' => '') ) ) / $per_page );
605
+	$num_pages = ceil(wp_count_terms($taxonomy_name, array_merge($args, array('number' => '', 'offset' => ''))) / $per_page);
606 606
 
607
-	$page_links = paginate_links( array(
607
+	$page_links = paginate_links(array(
608 608
 		'base' => add_query_arg(
609 609
 			array(
610
-				$taxonomy_name . '-tab' => 'all',
610
+				$taxonomy_name.'-tab' => 'all',
611 611
 				'paged' => '%#%',
612 612
 				'item-type' => 'taxonomy',
613 613
 				'item-object' => $taxonomy_name,
@@ -621,18 +621,18 @@  discard block
 block discarded – undo
621 621
 	));
622 622
 
623 623
 	$db_fields = false;
624
-	if ( is_taxonomy_hierarchical( $taxonomy_name ) ) {
625
-		$db_fields = array( 'parent' => 'parent', 'id' => 'term_id' );
624
+	if (is_taxonomy_hierarchical($taxonomy_name)) {
625
+		$db_fields = array('parent' => 'parent', 'id' => 'term_id');
626 626
 	}
627 627
 
628
-	$walker = new Walker_Nav_Menu_Checklist( $db_fields );
628
+	$walker = new Walker_Nav_Menu_Checklist($db_fields);
629 629
 
630 630
 	$current_tab = 'most-used';
631
-	if ( isset( $_REQUEST[$taxonomy_name . '-tab'] ) && in_array( $_REQUEST[$taxonomy_name . '-tab'], array('all', 'most-used', 'search') ) ) {
632
-		$current_tab = $_REQUEST[$taxonomy_name . '-tab'];
631
+	if (isset($_REQUEST[$taxonomy_name.'-tab']) && in_array($_REQUEST[$taxonomy_name.'-tab'], array('all', 'most-used', 'search'))) {
632
+		$current_tab = $_REQUEST[$taxonomy_name.'-tab'];
633 633
 	}
634 634
 
635
-	if ( ! empty( $_REQUEST['quick-search-taxonomy-' . $taxonomy_name] ) ) {
635
+	if ( ! empty($_REQUEST['quick-search-taxonomy-'.$taxonomy_name])) {
636 636
 		$current_tab = 'search';
637 637
 	}
638 638
 
@@ -648,39 +648,39 @@  discard block
 block discarded – undo
648 648
 	?>
649 649
 	<div id="taxonomy-<?php echo $taxonomy_name; ?>" class="taxonomydiv">
650 650
 		<ul id="taxonomy-<?php echo $taxonomy_name; ?>-tabs" class="taxonomy-tabs add-menu-item-tabs">
651
-			<li <?php echo ( 'most-used' == $current_tab ? ' class="tabs"' : '' ); ?>>
652
-				<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">
653
-					<?php _e( 'Most Used' ); ?>
651
+			<li <?php echo ('most-used' == $current_tab ? ' class="tabs"' : ''); ?>>
652
+				<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">
653
+					<?php _e('Most Used'); ?>
654 654
 				</a>
655 655
 			</li>
656
-			<li <?php echo ( 'all' == $current_tab ? ' class="tabs"' : '' ); ?>>
657
-				<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">
658
-					<?php _e( 'View All' ); ?>
656
+			<li <?php echo ('all' == $current_tab ? ' class="tabs"' : ''); ?>>
657
+				<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">
658
+					<?php _e('View All'); ?>
659 659
 				</a>
660 660
 			</li>
661
-			<li <?php echo ( 'search' == $current_tab ? ' class="tabs"' : '' ); ?>>
662
-				<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; ?>">
663
-					<?php _e( 'Search' ); ?>
661
+			<li <?php echo ('search' == $current_tab ? ' class="tabs"' : ''); ?>>
662
+				<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; ?>">
663
+					<?php _e('Search'); ?>
664 664
 				</a>
665 665
 			</li>
666 666
 		</ul><!-- .taxonomy-tabs -->
667 667
 
668 668
 		<div id="tabs-panel-<?php echo $taxonomy_name; ?>-pop" class="tabs-panel <?php
669
-			echo ( 'most-used' == $current_tab ? 'tabs-panel-active' : 'tabs-panel-inactive' );
669
+			echo ('most-used' == $current_tab ? 'tabs-panel-active' : 'tabs-panel-inactive');
670 670
 		?>">
671 671
 			<ul id="<?php echo $taxonomy_name; ?>checklist-pop" class="categorychecklist form-no-clear" >
672 672
 				<?php
673
-				$popular_terms = get_terms( $taxonomy_name, array( 'orderby' => 'count', 'order' => 'DESC', 'number' => 10, 'hierarchical' => false ) );
673
+				$popular_terms = get_terms($taxonomy_name, array('orderby' => 'count', 'order' => 'DESC', 'number' => 10, 'hierarchical' => false));
674 674
 				$args['walker'] = $walker;
675
-				echo walk_nav_menu_tree( array_map('wp_setup_nav_menu_item', $popular_terms), 0, (object) $args );
675
+				echo walk_nav_menu_tree(array_map('wp_setup_nav_menu_item', $popular_terms), 0, (object) $args);
676 676
 				?>
677 677
 			</ul>
678 678
 		</div><!-- /.tabs-panel -->
679 679
 
680 680
 		<div id="tabs-panel-<?php echo $taxonomy_name; ?>-all" class="tabs-panel tabs-panel-view-all <?php
681
-			echo ( 'all' == $current_tab ? 'tabs-panel-active' : 'tabs-panel-inactive' );
681
+			echo ('all' == $current_tab ? 'tabs-panel-active' : 'tabs-panel-inactive');
682 682
 		?>">
683
-			<?php if ( ! empty( $page_links ) ) : ?>
683
+			<?php if ( ! empty($page_links)) : ?>
684 684
 				<div class="add-menu-item-pagelinks">
685 685
 					<?php echo $page_links; ?>
686 686
 				</div>
@@ -688,10 +688,10 @@  discard block
 block discarded – undo
688 688
 			<ul id="<?php echo $taxonomy_name; ?>checklist" data-wp-lists="list:<?php echo $taxonomy_name?>" class="categorychecklist form-no-clear">
689 689
 				<?php
690 690
 				$args['walker'] = $walker;
691
-				echo walk_nav_menu_tree( array_map('wp_setup_nav_menu_item', $terms), 0, (object) $args );
691
+				echo walk_nav_menu_tree(array_map('wp_setup_nav_menu_item', $terms), 0, (object) $args);
692 692
 				?>
693 693
 			</ul>
694
-			<?php if ( ! empty( $page_links ) ) : ?>
694
+			<?php if ( ! empty($page_links)) : ?>
695 695
 				<div class="add-menu-item-pagelinks">
696 696
 					<?php echo $page_links; ?>
697 697
 				</div>
@@ -699,33 +699,33 @@  discard block
 block discarded – undo
699 699
 		</div><!-- /.tabs-panel -->
700 700
 
701 701
 		<div class="tabs-panel <?php
702
-			echo ( 'search' == $current_tab ? 'tabs-panel-active' : 'tabs-panel-inactive' );
702
+			echo ('search' == $current_tab ? 'tabs-panel-active' : 'tabs-panel-inactive');
703 703
 		?>" id="tabs-panel-search-taxonomy-<?php echo $taxonomy_name; ?>">
704 704
 			<?php
705
-			if ( isset( $_REQUEST['quick-search-taxonomy-' . $taxonomy_name] ) ) {
706
-				$searched = esc_attr( $_REQUEST['quick-search-taxonomy-' . $taxonomy_name] );
707
-				$search_results = get_terms( $taxonomy_name, array( 'name__like' => $searched, 'fields' => 'all', 'orderby' => 'count', 'order' => 'DESC', 'hierarchical' => false ) );
705
+			if (isset($_REQUEST['quick-search-taxonomy-'.$taxonomy_name])) {
706
+				$searched = esc_attr($_REQUEST['quick-search-taxonomy-'.$taxonomy_name]);
707
+				$search_results = get_terms($taxonomy_name, array('name__like' => $searched, 'fields' => 'all', 'orderby' => 'count', 'order' => 'DESC', 'hierarchical' => false));
708 708
 			} else {
709 709
 				$searched = '';
710 710
 				$search_results = array();
711 711
 			}
712 712
 			?>
713 713
 			<p class="quick-search-wrap">
714
-				<label for="quick-search-taxonomy-<?php echo $taxonomy_name; ?>" class="screen-reader-text"><?php _e( 'Search' ); ?></label>
714
+				<label for="quick-search-taxonomy-<?php echo $taxonomy_name; ?>" class="screen-reader-text"><?php _e('Search'); ?></label>
715 715
 				<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; ?>" />
716 716
 				<span class="spinner"></span>
717
-				<?php submit_button( __( 'Search' ), 'button-small quick-search-submit button-secondary hide-if-js', 'submit', false, array( 'id' => 'submit-quick-search-taxonomy-' . $taxonomy_name ) ); ?>
717
+				<?php submit_button(__('Search'), 'button-small quick-search-submit button-secondary hide-if-js', 'submit', false, array('id' => 'submit-quick-search-taxonomy-'.$taxonomy_name)); ?>
718 718
 			</p>
719 719
 
720 720
 			<ul id="<?php echo $taxonomy_name; ?>-search-checklist" data-wp-lists="list:<?php echo $taxonomy_name?>" class="categorychecklist form-no-clear">
721
-			<?php if ( ! empty( $search_results ) && ! is_wp_error( $search_results ) ) : ?>
721
+			<?php if ( ! empty($search_results) && ! is_wp_error($search_results)) : ?>
722 722
 				<?php
723 723
 				$args['walker'] = $walker;
724
-				echo walk_nav_menu_tree( array_map('wp_setup_nav_menu_item', $search_results), 0, (object) $args );
724
+				echo walk_nav_menu_tree(array_map('wp_setup_nav_menu_item', $search_results), 0, (object) $args);
725 725
 				?>
726
-			<?php elseif ( is_wp_error( $search_results ) ) : ?>
726
+			<?php elseif (is_wp_error($search_results)) : ?>
727 727
 				<li><?php echo $search_results->get_error_message(); ?></li>
728
-			<?php elseif ( ! empty( $searched ) ) : ?>
728
+			<?php elseif ( ! empty($searched)) : ?>
729 729
 				<li><?php _e('No results found.'); ?></li>
730 730
 			<?php endif; ?>
731 731
 			</ul>
@@ -736,7 +736,7 @@  discard block
 block discarded – undo
736 736
 				<a href="<?php
737 737
 					echo esc_url(add_query_arg(
738 738
 						array(
739
-							$taxonomy_name . '-tab' => 'all',
739
+							$taxonomy_name.'-tab' => 'all',
740 740
 							'selectall' => 1,
741 741
 						),
742 742
 						remove_query_arg($removed_args)
@@ -745,7 +745,7 @@  discard block
 block discarded – undo
745 745
 			</span>
746 746
 
747 747
 			<span class="add-to-menu">
748
-				<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 ); ?>" />
748
+				<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); ?>" />
749 749
 				<span class="spinner"></span>
750 750
 			</span>
751 751
 		</p>
@@ -763,25 +763,25 @@  discard block
 block discarded – undo
763 763
  * @param array $menu_data The unsanitized posted menu item data.
764 764
  * @return array The database IDs of the items saved
765 765
  */
766
-function wp_save_nav_menu_items( $menu_id = 0, $menu_data = array() ) {
766
+function wp_save_nav_menu_items($menu_id = 0, $menu_data = array()) {
767 767
 	$menu_id = (int) $menu_id;
768 768
 	$items_saved = array();
769 769
 
770
-	if ( 0 == $menu_id || is_nav_menu( $menu_id ) ) {
770
+	if (0 == $menu_id || is_nav_menu($menu_id)) {
771 771
 
772 772
 		// Loop through all the menu items' POST values.
773
-		foreach ( (array) $menu_data as $_possible_db_id => $_item_object_data ) {
773
+		foreach ((array) $menu_data as $_possible_db_id => $_item_object_data) {
774 774
 			if (
775 775
 				// Checkbox is not checked.
776
-				empty( $_item_object_data['menu-item-object-id'] ) &&
776
+				empty($_item_object_data['menu-item-object-id']) &&
777 777
 				(
778 778
 					// And item type either isn't set.
779
-					! isset( $_item_object_data['menu-item-type'] ) ||
779
+					! isset($_item_object_data['menu-item-type']) ||
780 780
 					// Or URL is the default.
781
-					in_array( $_item_object_data['menu-item-url'], array( 'http://', '' ) ) ||
782
-					! ( '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)
781
+					in_array($_item_object_data['menu-item-url'], array('http://', '')) ||
782
+					! ('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)
783 783
 					// Or it *is* a custom menu item that already exists.
784
-					! empty( $_item_object_data['menu-item-db-id'] )
784
+					! empty($_item_object_data['menu-item-db-id'])
785 785
 				)
786 786
 			) {
787 787
 				// Then this potential menu item is not getting added to this menu.
@@ -790,8 +790,8 @@  discard block
 block discarded – undo
790 790
 
791 791
 			// If this possible menu item doesn't actually have a menu database ID yet.
792 792
 			if (
793
-				empty( $_item_object_data['menu-item-db-id'] ) ||
794
-				( 0 > $_possible_db_id ) ||
793
+				empty($_item_object_data['menu-item-db-id']) ||
794
+				(0 > $_possible_db_id) ||
795 795
 				$_possible_db_id != $_item_object_data['menu-item-db-id']
796 796
 			) {
797 797
 				$_actual_db_id = 0;
@@ -800,22 +800,22 @@  discard block
 block discarded – undo
800 800
 			}
801 801
 
802 802
 			$args = array(
803
-				'menu-item-db-id' => ( isset( $_item_object_data['menu-item-db-id'] ) ? $_item_object_data['menu-item-db-id'] : '' ),
804
-				'menu-item-object-id' => ( isset( $_item_object_data['menu-item-object-id'] ) ? $_item_object_data['menu-item-object-id'] : '' ),
805
-				'menu-item-object' => ( isset( $_item_object_data['menu-item-object'] ) ? $_item_object_data['menu-item-object'] : '' ),
806
-				'menu-item-parent-id' => ( isset( $_item_object_data['menu-item-parent-id'] ) ? $_item_object_data['menu-item-parent-id'] : '' ),
807
-				'menu-item-position' => ( isset( $_item_object_data['menu-item-position'] ) ? $_item_object_data['menu-item-position'] : '' ),
808
-				'menu-item-type' => ( isset( $_item_object_data['menu-item-type'] ) ? $_item_object_data['menu-item-type'] : '' ),
809
-				'menu-item-title' => ( isset( $_item_object_data['menu-item-title'] ) ? $_item_object_data['menu-item-title'] : '' ),
810
-				'menu-item-url' => ( isset( $_item_object_data['menu-item-url'] ) ? $_item_object_data['menu-item-url'] : '' ),
811
-				'menu-item-description' => ( isset( $_item_object_data['menu-item-description'] ) ? $_item_object_data['menu-item-description'] : '' ),
812
-				'menu-item-attr-title' => ( isset( $_item_object_data['menu-item-attr-title'] ) ? $_item_object_data['menu-item-attr-title'] : '' ),
813
-				'menu-item-target' => ( isset( $_item_object_data['menu-item-target'] ) ? $_item_object_data['menu-item-target'] : '' ),
814
-				'menu-item-classes' => ( isset( $_item_object_data['menu-item-classes'] ) ? $_item_object_data['menu-item-classes'] : '' ),
815
-				'menu-item-xfn' => ( isset( $_item_object_data['menu-item-xfn'] ) ? $_item_object_data['menu-item-xfn'] : '' ),
803
+				'menu-item-db-id' => (isset($_item_object_data['menu-item-db-id']) ? $_item_object_data['menu-item-db-id'] : ''),
804
+				'menu-item-object-id' => (isset($_item_object_data['menu-item-object-id']) ? $_item_object_data['menu-item-object-id'] : ''),
805
+				'menu-item-object' => (isset($_item_object_data['menu-item-object']) ? $_item_object_data['menu-item-object'] : ''),
806
+				'menu-item-parent-id' => (isset($_item_object_data['menu-item-parent-id']) ? $_item_object_data['menu-item-parent-id'] : ''),
807
+				'menu-item-position' => (isset($_item_object_data['menu-item-position']) ? $_item_object_data['menu-item-position'] : ''),
808
+				'menu-item-type' => (isset($_item_object_data['menu-item-type']) ? $_item_object_data['menu-item-type'] : ''),
809
+				'menu-item-title' => (isset($_item_object_data['menu-item-title']) ? $_item_object_data['menu-item-title'] : ''),
810
+				'menu-item-url' => (isset($_item_object_data['menu-item-url']) ? $_item_object_data['menu-item-url'] : ''),
811
+				'menu-item-description' => (isset($_item_object_data['menu-item-description']) ? $_item_object_data['menu-item-description'] : ''),
812
+				'menu-item-attr-title' => (isset($_item_object_data['menu-item-attr-title']) ? $_item_object_data['menu-item-attr-title'] : ''),
813
+				'menu-item-target' => (isset($_item_object_data['menu-item-target']) ? $_item_object_data['menu-item-target'] : ''),
814
+				'menu-item-classes' => (isset($_item_object_data['menu-item-classes']) ? $_item_object_data['menu-item-classes'] : ''),
815
+				'menu-item-xfn' => (isset($_item_object_data['menu-item-xfn']) ? $_item_object_data['menu-item-xfn'] : ''),
816 816
 			);
817 817
 
818
-			$items_saved[] = wp_update_nav_menu_item( $menu_id, $_actual_db_id, $args );
818
+			$items_saved[] = wp_update_nav_menu_item($menu_id, $_actual_db_id, $args);
819 819
 
820 820
 		}
821 821
 	}
@@ -832,23 +832,23 @@  discard block
 block discarded – undo
832 832
  * @param object $object The post type or taxonomy meta-object.
833 833
  * @return object The post type of taxonomy object.
834 834
  */
835
-function _wp_nav_menu_meta_box_object( $object = null ) {
836
-	if ( isset( $object->name ) ) {
835
+function _wp_nav_menu_meta_box_object($object = null) {
836
+	if (isset($object->name)) {
837 837
 
838
-		if ( 'page' == $object->name ) {
838
+		if ('page' == $object->name) {
839 839
 			$object->_default_query = array(
840 840
 				'orderby' => 'menu_order title',
841 841
 				'post_status' => 'publish',
842 842
 			);
843 843
 
844 844
 		// Posts should show only published items.
845
-		} elseif ( 'post' == $object->name ) {
845
+		} elseif ('post' == $object->name) {
846 846
 			$object->_default_query = array(
847 847
 				'post_status' => 'publish',
848 848
 			);
849 849
 
850 850
 		// Categories should be in reverse chronological order.
851
-		} elseif ( 'category' == $object->name ) {
851
+		} elseif ('category' == $object->name) {
852 852
 			$object->_default_query = array(
853 853
 				'orderby' => 'id',
854 854
 				'order' => 'DESC',
@@ -873,19 +873,19 @@  discard block
 block discarded – undo
873 873
  * @param int $menu_id Optional. The ID of the menu to format. Default 0.
874 874
  * @return string|WP_Error $output The menu formatted to edit or error object on failure.
875 875
  */
876
-function wp_get_nav_menu_to_edit( $menu_id = 0 ) {
877
-	$menu = wp_get_nav_menu_object( $menu_id );
876
+function wp_get_nav_menu_to_edit($menu_id = 0) {
877
+	$menu = wp_get_nav_menu_object($menu_id);
878 878
 
879 879
 	// If the menu exists, get its items.
880
-	if ( is_nav_menu( $menu ) ) {
881
-		$menu_items = wp_get_nav_menu_items( $menu->term_id, array('post_status' => 'any') );
880
+	if (is_nav_menu($menu)) {
881
+		$menu_items = wp_get_nav_menu_items($menu->term_id, array('post_status' => 'any'));
882 882
 		$result = '<div id="menu-instructions" class="post-body-plain';
883
-		$result .= ( ! empty($menu_items) ) ? ' menu-instructions-inactive">' : '">';
884
-		$result .= '<p>' . __( 'Add menu items from the column on the left.' ) . '</p>';
883
+		$result .= ( ! empty($menu_items)) ? ' menu-instructions-inactive">' : '">';
884
+		$result .= '<p>'.__('Add menu items from the column on the left.').'</p>';
885 885
 		$result .= '</div>';
886 886
 
887
-		if ( empty($menu_items) )
888
-			return $result . ' <ul class="menu" id="menu-to-edit"> </ul>';
887
+		if (empty($menu_items))
888
+			return $result.' <ul class="menu" id="menu-to-edit"> </ul>';
889 889
 
890 890
 		/**
891 891
 		 * Filter the Walker class used when adding nav menu items.
@@ -895,38 +895,38 @@  discard block
 block discarded – undo
895 895
 		 * @param string $class   The walker class to use. Default 'Walker_Nav_Menu_Edit'.
896 896
 		 * @param int    $menu_id ID of the menu being rendered.
897 897
 		 */
898
-		$walker_class_name = apply_filters( 'wp_edit_nav_menu_walker', 'Walker_Nav_Menu_Edit', $menu_id );
898
+		$walker_class_name = apply_filters('wp_edit_nav_menu_walker', 'Walker_Nav_Menu_Edit', $menu_id);
899 899
 
900
-		if ( class_exists( $walker_class_name ) ) {
900
+		if (class_exists($walker_class_name)) {
901 901
 			$walker = new $walker_class_name;
902 902
 		} else {
903
-			return new WP_Error( 'menu_walker_not_exist',
903
+			return new WP_Error('menu_walker_not_exist',
904 904
 				/* translators: %s: walker class name */
905
-				sprintf( __( 'The Walker class named %s does not exist.' ),
906
-					'<strong>' . $walker_class_name . '</strong>'
905
+				sprintf(__('The Walker class named %s does not exist.'),
906
+					'<strong>'.$walker_class_name.'</strong>'
907 907
 				)
908 908
 			);
909 909
 		}
910 910
 
911 911
 		$some_pending_menu_items = $some_invalid_menu_items = false;
912
-		foreach ( (array) $menu_items as $menu_item ) {
913
-			if ( isset( $menu_item->post_status ) && 'draft' == $menu_item->post_status )
912
+		foreach ((array) $menu_items as $menu_item) {
913
+			if (isset($menu_item->post_status) && 'draft' == $menu_item->post_status)
914 914
 				$some_pending_menu_items = true;
915
-			if ( ! empty( $menu_item->_invalid ) )
915
+			if ( ! empty($menu_item->_invalid))
916 916
 				$some_invalid_menu_items = true;
917 917
 		}
918 918
 
919
-		if ( $some_pending_menu_items )
920
-			$result .= '<div class="updated inline"><p>' . __('Click Save Menu to make pending menu items public.') . '</p></div>';
919
+		if ($some_pending_menu_items)
920
+			$result .= '<div class="updated inline"><p>'.__('Click Save Menu to make pending menu items public.').'</p></div>';
921 921
 
922
-		if ( $some_invalid_menu_items )
923
-			$result .= '<div class="error inline"><p>' . __('There are some invalid menu items. Please check or delete them.') . '</p></div>';
922
+		if ($some_invalid_menu_items)
923
+			$result .= '<div class="error inline"><p>'.__('There are some invalid menu items. Please check or delete them.').'</p></div>';
924 924
 
925 925
 		$result .= '<ul class="menu" id="menu-to-edit"> ';
926
-		$result .= walk_nav_menu_tree( array_map('wp_setup_nav_menu_item', $menu_items), 0, (object) array('walker' => $walker ) );
926
+		$result .= walk_nav_menu_tree(array_map('wp_setup_nav_menu_item', $menu_items), 0, (object) array('walker' => $walker));
927 927
 		$result .= ' </ul> ';
928 928
 		return $result;
929
-	} elseif ( is_wp_error( $menu ) ) {
929
+	} elseif (is_wp_error($menu)) {
930 930
 		return $menu;
931 931
 	}
932 932
 
@@ -941,13 +941,13 @@  discard block
 block discarded – undo
941 941
  */
942 942
 function wp_nav_menu_manage_columns() {
943 943
 	return array(
944
-		'_title'      => __( 'Show advanced menu properties' ),
944
+		'_title'      => __('Show advanced menu properties'),
945 945
 		'cb'          => '<input type="checkbox" />',
946
-		'link-target' => __( 'Link Target' ),
947
-		'attr-title'  => __( 'Title Attribute' ),
948
-		'css-classes' => __( 'CSS Classes' ),
949
-		'xfn'         => __( 'Link Relationship (XFN)' ),
950
-		'description' => __( 'Description' ),
946
+		'link-target' => __('Link Target'),
947
+		'attr-title'  => __('Title Attribute'),
948
+		'css-classes' => __('CSS Classes'),
949
+		'xfn'         => __('Link Relationship (XFN)'),
950
+		'description' => __('Description'),
951 951
 	);
952 952
 }
953 953
 
@@ -961,13 +961,13 @@  discard block
 block discarded – undo
961 961
  */
962 962
 function _wp_delete_orphaned_draft_menu_items() {
963 963
 	global $wpdb;
964
-	$delete_timestamp = time() - ( DAY_IN_SECONDS * EMPTY_TRASH_DAYS );
964
+	$delete_timestamp = time() - (DAY_IN_SECONDS * EMPTY_TRASH_DAYS);
965 965
 
966 966
 	// Delete orphaned draft menu items.
967
-	$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 ) );
967
+	$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));
968 968
 
969
-	foreach ( (array) $menu_items_to_delete as $menu_item_id )
970
-		wp_delete_post( $menu_item_id, true );
969
+	foreach ((array) $menu_items_to_delete as $menu_item_id)
970
+		wp_delete_post($menu_item_id, true);
971 971
 }
972 972
 
973 973
 /**
@@ -979,12 +979,12 @@  discard block
 block discarded – undo
979 979
  * @param string $nav_menu_selected_title Title of the currently-selected menu
980 980
  * @return array $messages The menu updated message
981 981
  */
982
-function wp_nav_menu_update_menu_items ( $nav_menu_selected_id, $nav_menu_selected_title ) {
983
-	$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' ) );
982
+function wp_nav_menu_update_menu_items($nav_menu_selected_id, $nav_menu_selected_title) {
983
+	$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'));
984 984
 	$messages = array();
985 985
 	$menu_items = array();
986 986
 	// Index menu items by db ID
987
-	foreach ( $unsorted_menu_items as $_item )
987
+	foreach ($unsorted_menu_items as $_item)
988 988
 		$menu_items[$_item->db_id] = $_item;
989 989
 
990 990
 	$post_fields = array(
@@ -994,66 +994,66 @@  discard block
 block discarded – undo
994 994
 		'menu-item-attr-title', 'menu-item-target', 'menu-item-classes', 'menu-item-xfn'
995 995
 	);
996 996
 
997
-	wp_defer_term_counting( true );
997
+	wp_defer_term_counting(true);
998 998
 	// Loop through all the menu items' POST variables
999
-	if ( ! empty( $_POST['menu-item-db-id'] ) ) {
1000
-		foreach ( (array) $_POST['menu-item-db-id'] as $_key => $k ) {
999
+	if ( ! empty($_POST['menu-item-db-id'])) {
1000
+		foreach ((array) $_POST['menu-item-db-id'] as $_key => $k) {
1001 1001
 
1002 1002
 			// Menu item title can't be blank
1003
-			if ( ! isset( $_POST['menu-item-title'][ $_key ] ) || '' == $_POST['menu-item-title'][ $_key ] )
1003
+			if ( ! isset($_POST['menu-item-title'][$_key]) || '' == $_POST['menu-item-title'][$_key])
1004 1004
 				continue;
1005 1005
 
1006 1006
 			$args = array();
1007
-			foreach ( $post_fields as $field )
1008
-				$args[$field] = isset( $_POST[$field][$_key] ) ? $_POST[$field][$_key] : '';
1007
+			foreach ($post_fields as $field)
1008
+				$args[$field] = isset($_POST[$field][$_key]) ? $_POST[$field][$_key] : '';
1009 1009
 
1010
-			$menu_item_db_id = wp_update_nav_menu_item( $nav_menu_selected_id, ( $_POST['menu-item-db-id'][$_key] != $_key ? 0 : $_key ), $args );
1010
+			$menu_item_db_id = wp_update_nav_menu_item($nav_menu_selected_id, ($_POST['menu-item-db-id'][$_key] != $_key ? 0 : $_key), $args);
1011 1011
 
1012
-			if ( is_wp_error( $menu_item_db_id ) ) {
1013
-				$messages[] = '<div id="message" class="error"><p>' . $menu_item_db_id->get_error_message() . '</p></div>';
1012
+			if (is_wp_error($menu_item_db_id)) {
1013
+				$messages[] = '<div id="message" class="error"><p>'.$menu_item_db_id->get_error_message().'</p></div>';
1014 1014
 			} else {
1015
-				unset( $menu_items[ $menu_item_db_id ] );
1015
+				unset($menu_items[$menu_item_db_id]);
1016 1016
 			}
1017 1017
 		}
1018 1018
 	}
1019 1019
 
1020 1020
 	// Remove menu items from the menu that weren't in $_POST
1021
-	if ( ! empty( $menu_items ) ) {
1022
-		foreach ( array_keys( $menu_items ) as $menu_item_id ) {
1023
-			if ( is_nav_menu_item( $menu_item_id ) ) {
1024
-				wp_delete_post( $menu_item_id );
1021
+	if ( ! empty($menu_items)) {
1022
+		foreach (array_keys($menu_items) as $menu_item_id) {
1023
+			if (is_nav_menu_item($menu_item_id)) {
1024
+				wp_delete_post($menu_item_id);
1025 1025
 			}
1026 1026
 		}
1027 1027
 	}
1028 1028
 
1029 1029
 	// Store 'auto-add' pages.
1030
-	$auto_add = ! empty( $_POST['auto-add-pages'] );
1031
-	$nav_menu_option = (array) get_option( 'nav_menu_options' );
1032
-	if ( ! isset( $nav_menu_option['auto_add'] ) )
1030
+	$auto_add = ! empty($_POST['auto-add-pages']);
1031
+	$nav_menu_option = (array) get_option('nav_menu_options');
1032
+	if ( ! isset($nav_menu_option['auto_add']))
1033 1033
 		$nav_menu_option['auto_add'] = array();
1034
-	if ( $auto_add ) {
1035
-		if ( ! in_array( $nav_menu_selected_id, $nav_menu_option['auto_add'] ) )
1034
+	if ($auto_add) {
1035
+		if ( ! in_array($nav_menu_selected_id, $nav_menu_option['auto_add']))
1036 1036
 			$nav_menu_option['auto_add'][] = $nav_menu_selected_id;
1037 1037
 	} else {
1038
-		if ( false !== ( $key = array_search( $nav_menu_selected_id, $nav_menu_option['auto_add'] ) ) )
1039
-			unset( $nav_menu_option['auto_add'][$key] );
1038
+		if (false !== ($key = array_search($nav_menu_selected_id, $nav_menu_option['auto_add'])))
1039
+			unset($nav_menu_option['auto_add'][$key]);
1040 1040
 	}
1041 1041
 	// Remove nonexistent/deleted menus
1042
-	$nav_menu_option['auto_add'] = array_intersect( $nav_menu_option['auto_add'], wp_get_nav_menus( array( 'fields' => 'ids' ) ) );
1043
-	update_option( 'nav_menu_options', $nav_menu_option );
1042
+	$nav_menu_option['auto_add'] = array_intersect($nav_menu_option['auto_add'], wp_get_nav_menus(array('fields' => 'ids')));
1043
+	update_option('nav_menu_options', $nav_menu_option);
1044 1044
 
1045
-	wp_defer_term_counting( false );
1045
+	wp_defer_term_counting(false);
1046 1046
 
1047 1047
 	/** This action is documented in wp-includes/nav-menu.php */
1048
-	do_action( 'wp_update_nav_menu', $nav_menu_selected_id );
1048
+	do_action('wp_update_nav_menu', $nav_menu_selected_id);
1049 1049
 
1050
-	$messages[] = '<div id="message" class="updated notice is-dismissible"><p>' .
1050
+	$messages[] = '<div id="message" class="updated notice is-dismissible"><p>'.
1051 1051
 		/* translators: %s: nav menu title */
1052
-		sprintf( __( '%s has been updated.' ),
1053
-			'<strong>' . $nav_menu_selected_title . '</strong>'
1054
-		) . '</p></div>';
1052
+		sprintf(__('%s has been updated.'),
1053
+			'<strong>'.$nav_menu_selected_title.'</strong>'
1054
+		).'</p></div>';
1055 1055
 
1056
-	unset( $menu_items, $unsorted_menu_items );
1056
+	unset($menu_items, $unsorted_menu_items);
1057 1057
 
1058 1058
 	return $messages;
1059 1059
 }
Please login to merge, or discard this patch.
Braces   +82 added lines, -45 removed lines patch added patch discarded remove patch
@@ -75,8 +75,9 @@  discard block
 block discarded – undo
75 75
 				'post_type' => $matches[2],
76 76
 				's' => $query,
77 77
 			));
78
-			if ( ! have_posts() )
79
-				return;
78
+			if ( ! have_posts() ) {
79
+							return;
80
+			}
80 81
 			while ( have_posts() ) {
81 82
 				the_post();
82 83
 				if ( 'markup' == $response_format ) {
@@ -98,8 +99,9 @@  discard block
 block discarded – undo
98 99
 				'name__like' => $query,
99 100
 				'number' => 10,
100 101
 			));
101
-			if ( empty( $terms ) || is_wp_error( $terms ) )
102
-				return;
102
+			if ( empty( $terms ) || is_wp_error( $terms ) ) {
103
+							return;
104
+			}
103 105
 			foreach ( (array) $terms as $term ) {
104 106
 				if ( 'markup' == $response_format ) {
105 107
 					echo walk_nav_menu_tree( array_map('wp_setup_nav_menu_item', array( $term ) ), 0, (object) $args );
@@ -151,8 +153,9 @@  discard block
 block discarded – undo
151 153
 function wp_initial_nav_menu_meta_boxes() {
152 154
 	global $wp_meta_boxes;
153 155
 
154
-	if ( get_user_option( 'metaboxhidden_nav-menus' ) !== false || ! is_array($wp_meta_boxes) )
155
-		return;
156
+	if ( get_user_option( 'metaboxhidden_nav-menus' ) !== false || ! is_array($wp_meta_boxes) ) {
157
+			return;
158
+	}
156 159
 
157 160
 	$initial_meta_boxes = array( 'add-post-type-page', 'add-post-type-post', 'add-custom-links', 'add-category' );
158 161
 	$hidden_meta_boxes = array();
@@ -181,8 +184,9 @@  discard block
 block discarded – undo
181 184
 function wp_nav_menu_post_type_meta_boxes() {
182 185
 	$post_types = get_post_types( array( 'show_in_nav_menus' => true ), 'object' );
183 186
 
184
-	if ( ! $post_types )
185
-		return;
187
+	if ( ! $post_types ) {
188
+			return;
189
+	}
186 190
 
187 191
 	foreach ( $post_types as $post_type ) {
188 192
 		/**
@@ -215,8 +219,9 @@  discard block
 block discarded – undo
215 219
 function wp_nav_menu_taxonomy_meta_boxes() {
216 220
 	$taxonomies = get_taxonomies( array( 'show_in_nav_menus' => true ), 'object' );
217 221
 
218
-	if ( !$taxonomies )
219
-		return;
222
+	if ( !$taxonomies ) {
223
+			return;
224
+	}
220 225
 
221 226
 	foreach ( $taxonomies as $tax ) {
222 227
 		/** This filter is documented in wp-admin/includes/nav-menu.php */
@@ -241,8 +246,9 @@  discard block
 block discarded – undo
241 246
 function wp_nav_menu_disabled_check( $nav_menu_selected_id ) {
242 247
 	global $one_theme_location_no_menus;
243 248
 
244
-	if ( $one_theme_location_no_menus )
245
-		return false;
249
+	if ( $one_theme_location_no_menus ) {
250
+			return false;
251
+	}
246 252
 
247 253
 	return disabled( $nav_menu_selected_id, 0 );
248 254
 }
@@ -316,8 +322,9 @@  discard block
 block discarded – undo
316 322
 		'update_post_meta_cache' => false
317 323
 	);
318 324
 
319
-	if ( isset( $post_type['args']->_default_query ) )
320
-		$args = array_merge($args, (array) $post_type['args']->_default_query );
325
+	if ( isset( $post_type['args']->_default_query ) ) {
326
+			$args = array_merge($args, (array) $post_type['args']->_default_query );
327
+	}
321 328
 
322 329
 	// @todo transient caching of these results with proper invalidation on updating of a post of this type
323 330
 	$get_posts = new WP_Query;
@@ -374,17 +381,26 @@  discard block
 block discarded – undo
374 381
 	<div id="posttype-<?php echo $post_type_name; ?>" class="posttypediv">
375 382
 		<ul id="posttype-<?php echo $post_type_name; ?>-tabs" class="posttype-tabs add-menu-item-tabs">
376 383
 			<li <?php echo ( 'most-recent' == $current_tab ? ' class="tabs"' : '' ); ?>>
377
-				<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">
384
+				<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 ) {
385
+	echo esc_url(add_query_arg($post_type_name . '-tab', 'most-recent', remove_query_arg($removed_args)));
386
+}
387
+?>#tabs-panel-posttype-<?php echo $post_type_name; ?>-most-recent">
378 388
 					<?php _e( 'Most Recent' ); ?>
379 389
 				</a>
380 390
 			</li>
381 391
 			<li <?php echo ( 'all' == $current_tab ? ' class="tabs"' : '' ); ?>>
382
-				<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">
392
+				<a class="nav-tab-link" data-type="<?php echo esc_attr( $post_type_name ); ?>-all" href="<?php if ( $nav_menu_selected_id ) {
393
+	echo esc_url(add_query_arg($post_type_name . '-tab', 'all', remove_query_arg($removed_args)));
394
+}
395
+?>#<?php echo $post_type_name; ?>-all">
383 396
 					<?php _e( 'View All' ); ?>
384 397
 				</a>
385 398
 			</li>
386 399
 			<li <?php echo ( 'search' == $current_tab ? ' class="tabs"' : '' ); ?>>
387
-				<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">
400
+				<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 ) {
401
+	echo esc_url(add_query_arg($post_type_name . '-tab', 'search', remove_query_arg($removed_args)));
402
+}
403
+?>#tabs-panel-posttype-<?php echo $post_type_name; ?>-search">
388 404
 					<?php _e( 'Search'); ?>
389 405
 				</a>
390 406
 			</li>
@@ -649,17 +665,26 @@  discard block
 block discarded – undo
649 665
 	<div id="taxonomy-<?php echo $taxonomy_name; ?>" class="taxonomydiv">
650 666
 		<ul id="taxonomy-<?php echo $taxonomy_name; ?>-tabs" class="taxonomy-tabs add-menu-item-tabs">
651 667
 			<li <?php echo ( 'most-used' == $current_tab ? ' class="tabs"' : '' ); ?>>
652
-				<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">
668
+				<a class="nav-tab-link" data-type="tabs-panel-<?php echo esc_attr( $taxonomy_name ); ?>-pop" href="<?php if ( $nav_menu_selected_id ) {
669
+	echo esc_url(add_query_arg($taxonomy_name . '-tab', 'most-used', remove_query_arg($removed_args)));
670
+}
671
+?>#tabs-panel-<?php echo $taxonomy_name; ?>-pop">
653 672
 					<?php _e( 'Most Used' ); ?>
654 673
 				</a>
655 674
 			</li>
656 675
 			<li <?php echo ( 'all' == $current_tab ? ' class="tabs"' : '' ); ?>>
657
-				<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">
676
+				<a class="nav-tab-link" data-type="tabs-panel-<?php echo esc_attr( $taxonomy_name ); ?>-all" href="<?php if ( $nav_menu_selected_id ) {
677
+	echo esc_url(add_query_arg($taxonomy_name . '-tab', 'all', remove_query_arg($removed_args)));
678
+}
679
+?>#tabs-panel-<?php echo $taxonomy_name; ?>-all">
658 680
 					<?php _e( 'View All' ); ?>
659 681
 				</a>
660 682
 			</li>
661 683
 			<li <?php echo ( 'search' == $current_tab ? ' class="tabs"' : '' ); ?>>
662
-				<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; ?>">
684
+				<a class="nav-tab-link" data-type="tabs-panel-search-taxonomy-<?php echo esc_attr( $taxonomy_name ); ?>" href="<?php if ( $nav_menu_selected_id ) {
685
+	echo esc_url(add_query_arg($taxonomy_name . '-tab', 'search', remove_query_arg($removed_args)));
686
+}
687
+?>#tabs-panel-search-taxonomy-<?php echo $taxonomy_name; ?>">
663 688
 					<?php _e( 'Search' ); ?>
664 689
 				</a>
665 690
 			</li>
@@ -884,8 +909,9 @@  discard block
 block discarded – undo
884 909
 		$result .= '<p>' . __( 'Add menu items from the column on the left.' ) . '</p>';
885 910
 		$result .= '</div>';
886 911
 
887
-		if ( empty($menu_items) )
888
-			return $result . ' <ul class="menu" id="menu-to-edit"> </ul>';
912
+		if ( empty($menu_items) ) {
913
+					return $result . ' <ul class="menu" id="menu-to-edit"> </ul>';
914
+		}
889 915
 
890 916
 		/**
891 917
 		 * Filter the Walker class used when adding nav menu items.
@@ -910,17 +936,21 @@  discard block
 block discarded – undo
910 936
 
911 937
 		$some_pending_menu_items = $some_invalid_menu_items = false;
912 938
 		foreach ( (array) $menu_items as $menu_item ) {
913
-			if ( isset( $menu_item->post_status ) && 'draft' == $menu_item->post_status )
914
-				$some_pending_menu_items = true;
915
-			if ( ! empty( $menu_item->_invalid ) )
916
-				$some_invalid_menu_items = true;
939
+			if ( isset( $menu_item->post_status ) && 'draft' == $menu_item->post_status ) {
940
+							$some_pending_menu_items = true;
941
+			}
942
+			if ( ! empty( $menu_item->_invalid ) ) {
943
+							$some_invalid_menu_items = true;
944
+			}
917 945
 		}
918 946
 
919
-		if ( $some_pending_menu_items )
920
-			$result .= '<div class="updated inline"><p>' . __('Click Save Menu to make pending menu items public.') . '</p></div>';
947
+		if ( $some_pending_menu_items ) {
948
+					$result .= '<div class="updated inline"><p>' . __('Click Save Menu to make pending menu items public.') . '</p></div>';
949
+		}
921 950
 
922
-		if ( $some_invalid_menu_items )
923
-			$result .= '<div class="error inline"><p>' . __('There are some invalid menu items. Please check or delete them.') . '</p></div>';
951
+		if ( $some_invalid_menu_items ) {
952
+					$result .= '<div class="error inline"><p>' . __('There are some invalid menu items. Please check or delete them.') . '</p></div>';
953
+		}
924 954
 
925 955
 		$result .= '<ul class="menu" id="menu-to-edit"> ';
926 956
 		$result .= walk_nav_menu_tree( array_map('wp_setup_nav_menu_item', $menu_items), 0, (object) array('walker' => $walker ) );
@@ -966,9 +996,10 @@  discard block
 block discarded – undo
966 996
 	// Delete orphaned draft menu items.
967 997
 	$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 ) );
968 998
 
969
-	foreach ( (array) $menu_items_to_delete as $menu_item_id )
970
-		wp_delete_post( $menu_item_id, true );
971
-}
999
+	foreach ( (array) $menu_items_to_delete as $menu_item_id ) {
1000
+			wp_delete_post( $menu_item_id, true );
1001
+	}
1002
+	}
972 1003
 
973 1004
 /**
974 1005
  * Saves nav menu items
@@ -984,8 +1015,9 @@  discard block
 block discarded – undo
984 1015
 	$messages = array();
985 1016
 	$menu_items = array();
986 1017
 	// Index menu items by db ID
987
-	foreach ( $unsorted_menu_items as $_item )
988
-		$menu_items[$_item->db_id] = $_item;
1018
+	foreach ( $unsorted_menu_items as $_item ) {
1019
+			$menu_items[$_item->db_id] = $_item;
1020
+	}
989 1021
 
990 1022
 	$post_fields = array(
991 1023
 		'menu-item-db-id', 'menu-item-object-id', 'menu-item-object',
@@ -1000,12 +1032,14 @@  discard block
 block discarded – undo
1000 1032
 		foreach ( (array) $_POST['menu-item-db-id'] as $_key => $k ) {
1001 1033
 
1002 1034
 			// Menu item title can't be blank
1003
-			if ( ! isset( $_POST['menu-item-title'][ $_key ] ) || '' == $_POST['menu-item-title'][ $_key ] )
1004
-				continue;
1035
+			if ( ! isset( $_POST['menu-item-title'][ $_key ] ) || '' == $_POST['menu-item-title'][ $_key ] ) {
1036
+							continue;
1037
+			}
1005 1038
 
1006 1039
 			$args = array();
1007
-			foreach ( $post_fields as $field )
1008
-				$args[$field] = isset( $_POST[$field][$_key] ) ? $_POST[$field][$_key] : '';
1040
+			foreach ( $post_fields as $field ) {
1041
+							$args[$field] = isset( $_POST[$field][$_key] ) ? $_POST[$field][$_key] : '';
1042
+			}
1009 1043
 
1010 1044
 			$menu_item_db_id = wp_update_nav_menu_item( $nav_menu_selected_id, ( $_POST['menu-item-db-id'][$_key] != $_key ? 0 : $_key ), $args );
1011 1045
 
@@ -1029,14 +1063,17 @@  discard block
 block discarded – undo
1029 1063
 	// Store 'auto-add' pages.
1030 1064
 	$auto_add = ! empty( $_POST['auto-add-pages'] );
1031 1065
 	$nav_menu_option = (array) get_option( 'nav_menu_options' );
1032
-	if ( ! isset( $nav_menu_option['auto_add'] ) )
1033
-		$nav_menu_option['auto_add'] = array();
1066
+	if ( ! isset( $nav_menu_option['auto_add'] ) ) {
1067
+			$nav_menu_option['auto_add'] = array();
1068
+	}
1034 1069
 	if ( $auto_add ) {
1035
-		if ( ! in_array( $nav_menu_selected_id, $nav_menu_option['auto_add'] ) )
1036
-			$nav_menu_option['auto_add'][] = $nav_menu_selected_id;
1070
+		if ( ! in_array( $nav_menu_selected_id, $nav_menu_option['auto_add'] ) ) {
1071
+					$nav_menu_option['auto_add'][] = $nav_menu_selected_id;
1072
+		}
1037 1073
 	} else {
1038
-		if ( false !== ( $key = array_search( $nav_menu_selected_id, $nav_menu_option['auto_add'] ) ) )
1039
-			unset( $nav_menu_option['auto_add'][$key] );
1074
+		if ( false !== ( $key = array_search( $nav_menu_selected_id, $nav_menu_option['auto_add'] ) ) ) {
1075
+					unset( $nav_menu_option['auto_add'][$key] );
1076
+		}
1040 1077
 	}
1041 1078
 	// Remove nonexistent/deleted menus
1042 1079
 	$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/class-wp-press-this.php 2 patches
Indentation   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -1,11 +1,11 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 /**
3
- * Press This class and display functionality
4
- *
5
- * @package WordPress
6
- * @subpackage Press_This
7
- * @since 4.2.0
8
- */
3
+	 * Press This class and display functionality
4
+	 *
5
+	 * @package WordPress
6
+	 * @subpackage Press_This
7
+	 * @since 4.2.0
8
+	 */
9 9
 
10 10
 /**
11 11
  * Press This class.
@@ -1049,7 +1049,7 @@  discard block
 block discarded – undo
1049 1049
 	 * @since 4.2.0
1050 1050
 	 * @access public
1051 1051
 	 *
1052
- 	 * @param array $data The site's data.
1052
+	 * @param array $data The site's data.
1053 1053
 	 * @return string Discovered canonical URL, or empty
1054 1054
 	 */
1055 1055
 	public function get_canonical_link( $data ) {
Please login to merge, or discard this patch.
Spacing   +395 added lines, -395 removed lines patch added patch discarded remove patch
@@ -48,7 +48,7 @@  discard block
 block discarded – undo
48 48
 			 *
49 49
 			 * @param bool $redirect Whether to redirect in parent window or not. Default false.
50 50
 			 */
51
-			'redirInParent' => apply_filters( 'press_this_redirect_in_parent', false ),
51
+			'redirInParent' => apply_filters('press_this_redirect_in_parent', false),
52 52
 		);
53 53
 	}
54 54
 
@@ -62,37 +62,37 @@  discard block
 block discarded – undo
62 62
 	 * @param string $content Optional. Current expected markup for Press This. Expects slashed. Default empty.
63 63
 	 * @return string New markup with old image URLs replaced with the local attachment ones if swapped.
64 64
 	 */
65
-	public function side_load_images( $post_id, $content = '' ) {
66
-		$content = wp_unslash( $content );
65
+	public function side_load_images($post_id, $content = '') {
66
+		$content = wp_unslash($content);
67 67
 
68
-		if ( preg_match_all( '/<img [^>]+>/', $content, $matches ) && current_user_can( 'upload_files' ) ) {
69
-			foreach ( (array) $matches[0] as $image ) {
68
+		if (preg_match_all('/<img [^>]+>/', $content, $matches) && current_user_can('upload_files')) {
69
+			foreach ((array) $matches[0] as $image) {
70 70
 				// This is inserted from our JS so HTML attributes should always be in double quotes.
71
-				if ( ! preg_match( '/src="([^"]+)"/', $image, $url_matches ) ) {
71
+				if ( ! preg_match('/src="([^"]+)"/', $image, $url_matches)) {
72 72
 					continue;
73 73
 				}
74 74
 
75 75
 				$image_src = $url_matches[1];
76 76
 
77 77
 				// Don't try to sideload a file without a file extension, leads to WP upload error.
78
-				if ( ! preg_match( '/[^\?]+\.(?:jpe?g|jpe|gif|png)(?:\?|$)/i', $image_src ) ) {
78
+				if ( ! preg_match('/[^\?]+\.(?:jpe?g|jpe|gif|png)(?:\?|$)/i', $image_src)) {
79 79
 					continue;
80 80
 				}
81 81
 
82 82
 				// Sideload image, which gives us a new image src.
83
-				$new_src = media_sideload_image( $image_src, $post_id, null, 'src' );
83
+				$new_src = media_sideload_image($image_src, $post_id, null, 'src');
84 84
 
85
-				if ( ! is_wp_error( $new_src ) ) {
85
+				if ( ! is_wp_error($new_src)) {
86 86
 					// Replace the POSTED content <img> with correct uploaded ones.
87 87
 					// Need to do it in two steps so we don't replace links to the original image if any.
88
-					$new_image = str_replace( $image_src, $new_src, $image );
89
-					$content = str_replace( $image, $new_image, $content );
88
+					$new_image = str_replace($image_src, $new_src, $image);
89
+					$content = str_replace($image, $new_image, $content);
90 90
 				}
91 91
 			}
92 92
 		}
93 93
 
94 94
 		// Expected slashed
95
-		return wp_slash( $content );
95
+		return wp_slash($content);
96 96
 	}
97 97
 
98 98
 	/**
@@ -102,36 +102,36 @@  discard block
 block discarded – undo
102 102
 	 * @access public
103 103
 	 */
104 104
 	public function save_post() {
105
-		if ( empty( $_POST['post_ID'] ) || ! $post_id = (int) $_POST['post_ID'] ) {
106
-			wp_send_json_error( array( 'errorMessage' => __( 'Missing post ID.' ) ) );
105
+		if (empty($_POST['post_ID']) || ! $post_id = (int) $_POST['post_ID']) {
106
+			wp_send_json_error(array('errorMessage' => __('Missing post ID.')));
107 107
 		}
108 108
 
109
-		if ( empty( $_POST['_wpnonce'] ) || ! wp_verify_nonce( $_POST['_wpnonce'], 'update-post_' . $post_id ) ||
110
-			! current_user_can( 'edit_post', $post_id ) ) {
109
+		if (empty($_POST['_wpnonce']) || ! wp_verify_nonce($_POST['_wpnonce'], 'update-post_'.$post_id) ||
110
+			! current_user_can('edit_post', $post_id)) {
111 111
 
112
-			wp_send_json_error( array( 'errorMessage' => __( 'Invalid post.' ) ) );
112
+			wp_send_json_error(array('errorMessage' => __('Invalid post.')));
113 113
 		}
114 114
 
115 115
 		$post_data = array(
116 116
 			'ID'            => $post_id,
117
-			'post_title'    => ( ! empty( $_POST['post_title'] ) ) ? sanitize_text_field( trim( $_POST['post_title'] ) ) : '',
118
-			'post_content'  => ( ! empty( $_POST['post_content'] ) ) ? trim( $_POST['post_content'] ) : '',
117
+			'post_title'    => ( ! empty($_POST['post_title'])) ? sanitize_text_field(trim($_POST['post_title'])) : '',
118
+			'post_content'  => ( ! empty($_POST['post_content'])) ? trim($_POST['post_content']) : '',
119 119
 			'post_type'     => 'post',
120 120
 			'post_status'   => 'draft',
121
-			'post_format'   => ( ! empty( $_POST['post_format'] ) ) ? sanitize_text_field( $_POST['post_format'] ) : '',
122
-			'tax_input'     => ( ! empty( $_POST['tax_input'] ) ) ? $_POST['tax_input'] : array(),
123
-			'post_category' => ( ! empty( $_POST['post_category'] ) ) ? $_POST['post_category'] : array(),
121
+			'post_format'   => ( ! empty($_POST['post_format'])) ? sanitize_text_field($_POST['post_format']) : '',
122
+			'tax_input'     => ( ! empty($_POST['tax_input'])) ? $_POST['tax_input'] : array(),
123
+			'post_category' => ( ! empty($_POST['post_category'])) ? $_POST['post_category'] : array(),
124 124
 		);
125 125
 
126
-		if ( ! empty( $_POST['post_status'] ) && 'publish' === $_POST['post_status'] ) {
127
-			if ( current_user_can( 'publish_posts' ) ) {
126
+		if ( ! empty($_POST['post_status']) && 'publish' === $_POST['post_status']) {
127
+			if (current_user_can('publish_posts')) {
128 128
 				$post_data['post_status'] = 'publish';
129 129
 			} else {
130 130
 				$post_data['post_status'] = 'pending';
131 131
 			}
132 132
 		}
133 133
 
134
-		$post_data['post_content'] = $this->side_load_images( $post_id, $post_data['post_content'] );
134
+		$post_data['post_content'] = $this->side_load_images($post_id, $post_data['post_content']);
135 135
 
136 136
 		/**
137 137
 		 * Filter the post data of a Press This post before saving/updating, after
@@ -141,28 +141,28 @@  discard block
 block discarded – undo
141 141
 		 *
142 142
 		 * @param array $post_data The post data.
143 143
 		 */
144
-		$post_data = apply_filters( 'press_this_save_post', $post_data );
144
+		$post_data = apply_filters('press_this_save_post', $post_data);
145 145
 
146
-		$updated = wp_update_post( $post_data, true );
146
+		$updated = wp_update_post($post_data, true);
147 147
 
148
-		if ( is_wp_error( $updated ) ) {
149
-			wp_send_json_error( array( 'errorMessage' => $updated->get_error_message() ) );
148
+		if (is_wp_error($updated)) {
149
+			wp_send_json_error(array('errorMessage' => $updated->get_error_message()));
150 150
 		} else {
151
-			if ( isset( $post_data['post_format'] ) ) {
152
-				if ( current_theme_supports( 'post-formats', $post_data['post_format'] ) ) {
153
-					set_post_format( $post_id, $post_data['post_format'] );
154
-				} elseif ( $post_data['post_format'] ) {
155
-					set_post_format( $post_id, false );
151
+			if (isset($post_data['post_format'])) {
152
+				if (current_theme_supports('post-formats', $post_data['post_format'])) {
153
+					set_post_format($post_id, $post_data['post_format']);
154
+				} elseif ($post_data['post_format']) {
155
+					set_post_format($post_id, false);
156 156
 				}
157 157
 			}
158 158
 
159 159
 			$forceRedirect = false;
160 160
 
161
-			if ( 'publish' === get_post_status( $post_id ) ) {
162
-				$redirect = get_post_permalink( $post_id );
163
-			} elseif ( isset( $_POST['pt-force-redirect'] ) && $_POST['pt-force-redirect'] === 'true' ) {
161
+			if ('publish' === get_post_status($post_id)) {
162
+				$redirect = get_post_permalink($post_id);
163
+			} elseif (isset($_POST['pt-force-redirect']) && $_POST['pt-force-redirect'] === 'true') {
164 164
 				$forceRedirect = true;
165
-				$redirect = get_edit_post_link( $post_id, 'js' );
165
+				$redirect = get_edit_post_link($post_id, 'js');
166 166
 			} else {
167 167
 				$redirect = false;
168 168
 			}
@@ -177,12 +177,12 @@  discard block
 block discarded – undo
177 177
 			 * @param int    $post_id Post ID.
178 178
 			 * @param string $status  Post status.
179 179
 			 */
180
-			$redirect = apply_filters( 'press_this_save_redirect', $redirect, $post_id, $post_data['post_status'] );
180
+			$redirect = apply_filters('press_this_save_redirect', $redirect, $post_id, $post_data['post_status']);
181 181
 
182
-			if ( $redirect ) {
183
-				wp_send_json_success( array( 'redirect' => $redirect, 'force' => $forceRedirect ) );
182
+			if ($redirect) {
183
+				wp_send_json_success(array('redirect' => $redirect, 'force' => $forceRedirect));
184 184
 			} else {
185
-				wp_send_json_success( array( 'postSaved' => true ) );
185
+				wp_send_json_success(array('postSaved' => true));
186 186
 			}
187 187
 		}
188 188
 	}
@@ -194,57 +194,57 @@  discard block
 block discarded – undo
194 194
 	 * @access public
195 195
 	 */
196 196
 	public function add_category() {
197
-		if ( false === wp_verify_nonce( $_POST['new_cat_nonce'], 'add-category' ) ) {
197
+		if (false === wp_verify_nonce($_POST['new_cat_nonce'], 'add-category')) {
198 198
 			wp_send_json_error();
199 199
 		}
200 200
 
201
-		$taxonomy = get_taxonomy( 'category' );
201
+		$taxonomy = get_taxonomy('category');
202 202
 
203
-		if ( ! current_user_can( $taxonomy->cap->edit_terms ) || empty( $_POST['name'] ) ) {
203
+		if ( ! current_user_can($taxonomy->cap->edit_terms) || empty($_POST['name'])) {
204 204
 			wp_send_json_error();
205 205
 		}
206 206
 
207
-		$parent = isset( $_POST['parent'] ) && (int) $_POST['parent'] > 0 ? (int) $_POST['parent'] : 0;
208
-		$names = explode( ',', $_POST['name'] );
207
+		$parent = isset($_POST['parent']) && (int) $_POST['parent'] > 0 ? (int) $_POST['parent'] : 0;
208
+		$names = explode(',', $_POST['name']);
209 209
 		$added = $data = array();
210 210
 
211
-		foreach ( $names as $cat_name ) {
212
-			$cat_name = trim( $cat_name );
213
-			$cat_nicename = sanitize_title( $cat_name );
211
+		foreach ($names as $cat_name) {
212
+			$cat_name = trim($cat_name);
213
+			$cat_nicename = sanitize_title($cat_name);
214 214
 
215
-			if ( empty( $cat_nicename ) ) {
215
+			if (empty($cat_nicename)) {
216 216
 				continue;
217 217
 			}
218 218
 
219 219
 			// @todo Find a more performant way to check existence, maybe get_term() with a separate parent check.
220
-			if ( term_exists( $cat_name, $taxonomy->name, $parent ) ) {
221
-				if ( count( $names ) === 1 ) {
222
-					wp_send_json_error( array( 'errorMessage' => __( 'This category already exists.' ) ) );
220
+			if (term_exists($cat_name, $taxonomy->name, $parent)) {
221
+				if (count($names) === 1) {
222
+					wp_send_json_error(array('errorMessage' => __('This category already exists.')));
223 223
 				} else {
224 224
 					continue;
225 225
 				}
226 226
 			}
227 227
 
228
-			$cat_id = wp_insert_term( $cat_name, $taxonomy->name, array( 'parent' => $parent ) );
228
+			$cat_id = wp_insert_term($cat_name, $taxonomy->name, array('parent' => $parent));
229 229
 
230
-			if ( is_wp_error( $cat_id ) ) {
230
+			if (is_wp_error($cat_id)) {
231 231
 				continue;
232
-			} elseif ( is_array( $cat_id ) ) {
232
+			} elseif (is_array($cat_id)) {
233 233
 				$cat_id = $cat_id['term_id'];
234 234
 			}
235 235
 
236 236
 			$added[] = $cat_id;
237 237
 		}
238 238
 
239
-		if ( empty( $added ) ) {
240
-			wp_send_json_error( array( 'errorMessage' => __( 'This category cannot be added. Please change the name and try again.' ) ) );
239
+		if (empty($added)) {
240
+			wp_send_json_error(array('errorMessage' => __('This category cannot be added. Please change the name and try again.')));
241 241
 		}
242 242
 
243
-		foreach ( $added as $new_cat_id ) {
244
-			$new_cat = get_category( $new_cat_id );
243
+		foreach ($added as $new_cat_id) {
244
+			$new_cat = get_category($new_cat_id);
245 245
 
246
-			if ( is_wp_error( $new_cat ) ) {
247
-				wp_send_json_error( array( 'errorMessage' => __( 'Error while adding the category. Please try again later.' ) ) );
246
+			if (is_wp_error($new_cat)) {
247
+				wp_send_json_error(array('errorMessage' => __('Error while adding the category. Please try again later.')));
248 248
 			}
249 249
 
250 250
 			$data[] = array(
@@ -253,7 +253,7 @@  discard block
 block discarded – undo
253 253
 				'parent' => $new_cat->parent,
254 254
 			);
255 255
 		}
256
-		wp_send_json_success( $data );
256
+		wp_send_json_success($data);
257 257
 	}
258 258
 
259 259
 	/**
@@ -265,20 +265,20 @@  discard block
 block discarded – undo
265 265
 	 * @param string $url URL to scan.
266 266
 	 * @return string Source's HTML sanitized markup
267 267
 	 */
268
-	public function fetch_source_html( $url ) {
268
+	public function fetch_source_html($url) {
269 269
 		global $wp_version;
270 270
 
271
-		if ( empty( $url ) ) {
272
-			return new WP_Error( 'invalid-url', __( 'A valid URL was not provided.' ) );
271
+		if (empty($url)) {
272
+			return new WP_Error('invalid-url', __('A valid URL was not provided.'));
273 273
 		}
274 274
 
275
-		$remote_url = wp_safe_remote_get( $url, array(
275
+		$remote_url = wp_safe_remote_get($url, array(
276 276
 			'timeout' => 30,
277 277
 			// Use an explicit user-agent for Press This
278
-			'user-agent' => 'Press This (WordPress/' . $wp_version . '); ' . get_bloginfo( 'url' )
279
-		) );
278
+			'user-agent' => 'Press This (WordPress/'.$wp_version.'); '.get_bloginfo('url')
279
+		));
280 280
 
281
-		if ( is_wp_error( $remote_url ) ) {
281
+		if (is_wp_error($remote_url)) {
282 282
 			return $remote_url;
283 283
 		}
284 284
 
@@ -303,8 +303,8 @@  discard block
 block discarded – undo
303 303
 			)
304 304
 		);
305 305
 
306
-		$source_content = wp_remote_retrieve_body( $remote_url );
307
-		$source_content = wp_kses( $source_content, $allowed_elements );
306
+		$source_content = wp_remote_retrieve_body($remote_url);
307
+		$source_content = wp_kses($source_content, $allowed_elements);
308 308
 
309 309
 		return $source_content;
310 310
 	}
@@ -318,10 +318,10 @@  discard block
 block discarded – undo
318 318
 	 * @param array $value Array to limit.
319 319
 	 * @return array Original array if fewer than 50 values, limited array, empty array otherwise.
320 320
 	 */
321
-	private function _limit_array( $value ) {
322
-		if ( is_array( $value ) ) {
323
-			if ( count( $value ) > 50 ) {
324
-				return array_slice( $value, 0, 50 );
321
+	private function _limit_array($value) {
322
+		if (is_array($value)) {
323
+			if (count($value) > 50) {
324
+				return array_slice($value, 0, 50);
325 325
 			}
326 326
 
327 327
 			return $value;
@@ -341,20 +341,20 @@  discard block
 block discarded – undo
341 341
 	 *                         if fewer than 5,000 characters, a truncated version, otherwise an
342 342
 	 *                         empty string.
343 343
 	 */
344
-	private function _limit_string( $value ) {
344
+	private function _limit_string($value) {
345 345
 		$return = '';
346 346
 
347
-		if ( is_numeric( $value ) || is_bool( $value ) ) {
347
+		if (is_numeric($value) || is_bool($value)) {
348 348
 			$return = $value;
349
-		} else if ( is_string( $value ) ) {
350
-			if ( mb_strlen( $value ) > 5000 ) {
351
-				$return = mb_substr( $value, 0, 5000 );
349
+		} else if (is_string($value)) {
350
+			if (mb_strlen($value) > 5000) {
351
+				$return = mb_substr($value, 0, 5000);
352 352
 			} else {
353 353
 				$return = $value;
354 354
 			}
355 355
 
356
-			$return = html_entity_decode( $return, ENT_QUOTES, 'UTF-8' );
357
-			$return = sanitize_text_field( trim( $return ) );
356
+			$return = html_entity_decode($return, ENT_QUOTES, 'UTF-8');
357
+			$return = sanitize_text_field(trim($return));
358 358
 		}
359 359
 
360 360
 		return $return;
@@ -369,32 +369,32 @@  discard block
 block discarded – undo
369 369
 	 * @param string $url URL to check for length and validity.
370 370
 	 * @return string Escaped URL if of valid length (< 2048) and makeup. Empty string otherwise.
371 371
 	 */
372
-	private function _limit_url( $url ) {
373
-		if ( ! is_string( $url ) ) {
372
+	private function _limit_url($url) {
373
+		if ( ! is_string($url)) {
374 374
 			return '';
375 375
 		}
376 376
 
377 377
 		// HTTP 1.1 allows 8000 chars but the "de-facto" standard supported in all current browsers is 2048.
378
-		if ( strlen( $url ) > 2048 ) {
378
+		if (strlen($url) > 2048) {
379 379
 			return ''; // Return empty rather than a truncated/invalid URL
380 380
 		}
381 381
 
382 382
 		// Does not look like a URL.
383
-		if ( ! preg_match( '/^([!#$&-;=?-\[\]_a-z~]|%[0-9a-fA-F]{2})+$/', $url ) ) {
383
+		if ( ! preg_match('/^([!#$&-;=?-\[\]_a-z~]|%[0-9a-fA-F]{2})+$/', $url)) {
384 384
 			return '';
385 385
 		}
386 386
 
387 387
 		// If the URL is root-relative, prepend the protocol and domain name
388
-		if ( $url && $this->domain && preg_match( '%^/[^/]+%', $url ) ) {
389
-			$url = $this->domain . $url;
388
+		if ($url && $this->domain && preg_match('%^/[^/]+%', $url)) {
389
+			$url = $this->domain.$url;
390 390
 		}
391 391
 
392 392
 		// Not absolute or protocol-relative URL.
393
-		if ( ! preg_match( '%^(?:https?:)?//[^/]+%', $url ) ) {
393
+		if ( ! preg_match('%^(?:https?:)?//[^/]+%', $url)) {
394 394
 			return '';
395 395
 		}
396 396
 
397
-		return esc_url_raw( $url, array( 'http', 'https' ) );
397
+		return esc_url_raw($url, array('http', 'https'));
398 398
 	}
399 399
 
400 400
 	/**
@@ -409,34 +409,34 @@  discard block
 block discarded – undo
409 409
 	 * @param string $src Image source URL.
410 410
 	 * @return string If not matched an excluded URL type, the original URL, empty string otherwise.
411 411
 	 */
412
-	private function _limit_img( $src ) {
413
-		$src = $this->_limit_url( $src );
412
+	private function _limit_img($src) {
413
+		$src = $this->_limit_url($src);
414 414
 
415
-		if ( preg_match( '!/ad[sx]?/!i', $src ) ) {
415
+		if (preg_match('!/ad[sx]?/!i', $src)) {
416 416
 			// Ads
417 417
 			return '';
418
-		} else if ( preg_match( '!(/share-?this[^.]+?\.[a-z0-9]{3,4})(\?.*)?$!i', $src ) ) {
418
+		} else if (preg_match('!(/share-?this[^.]+?\.[a-z0-9]{3,4})(\?.*)?$!i', $src)) {
419 419
 			// Share-this type button
420 420
 			return '';
421
-		} else if ( preg_match( '!/(spinner|loading|spacer|blank|rss)\.(gif|jpg|png)!i', $src ) ) {
421
+		} else if (preg_match('!/(spinner|loading|spacer|blank|rss)\.(gif|jpg|png)!i', $src)) {
422 422
 			// Loaders, spinners, spacers
423 423
 			return '';
424
-		} else if ( preg_match( '!/([^./]+[-_])?(spinner|loading|spacer|blank)s?([-_][^./]+)?\.[a-z0-9]{3,4}!i', $src ) ) {
424
+		} else if (preg_match('!/([^./]+[-_])?(spinner|loading|spacer|blank)s?([-_][^./]+)?\.[a-z0-9]{3,4}!i', $src)) {
425 425
 			// Fancy loaders, spinners, spacers
426 426
 			return '';
427
-		} else if ( preg_match( '!([^./]+[-_])?thumb[^.]*\.(gif|jpg|png)$!i', $src ) ) {
427
+		} else if (preg_match('!([^./]+[-_])?thumb[^.]*\.(gif|jpg|png)$!i', $src)) {
428 428
 			// Thumbnails, too small, usually irrelevant to context
429 429
 			return '';
430
-		} else if ( false !== stripos( $src, '/wp-includes/' ) ) {
430
+		} else if (false !== stripos($src, '/wp-includes/')) {
431 431
 			// Classic WordPress interface images
432 432
 			return '';
433
-		} else if ( preg_match( '![^\d]\d{1,2}x\d+\.(gif|jpg|png)$!i', $src ) ) {
433
+		} else if (preg_match('![^\d]\d{1,2}x\d+\.(gif|jpg|png)$!i', $src)) {
434 434
 			// Most often tiny buttons/thumbs (< 100px wide)
435 435
 			return '';
436
-		} else if ( preg_match( '!/pixel\.(mathtag|quantserve)\.com!i', $src ) ) {
436
+		} else if (preg_match('!/pixel\.(mathtag|quantserve)\.com!i', $src)) {
437 437
 			// See mathtag.com and https://www.quantcast.com/how-we-do-it/iab-standard-measurement/how-we-collect-data/
438 438
 			return '';
439
-		} else if ( preg_match( '!/[gb]\.gif(\?.+)?$!i', $src ) ) {
439
+		} else if (preg_match('!/[gb]\.gif(\?.+)?$!i', $src)) {
440 440
 			// WordPress.com stats gif
441 441
 			return '';
442 442
 		}
@@ -456,32 +456,32 @@  discard block
 block discarded – undo
456 456
 	 * @param string $src Embed source URL.
457 457
 	 * @return string If not from a supported provider, an empty string. Otherwise, a reformattd embed URL.
458 458
 	 */
459
-	private function _limit_embed( $src ) {
460
-		$src = $this->_limit_url( $src );
459
+	private function _limit_embed($src) {
460
+		$src = $this->_limit_url($src);
461 461
 
462
-		if ( empty( $src ) )
462
+		if (empty($src))
463 463
 			return '';
464 464
 
465
-		if ( preg_match( '!//(m|www)\.youtube\.com/(embed|v)/([^?]+)\?.+$!i', $src, $src_matches ) ) {
465
+		if (preg_match('!//(m|www)\.youtube\.com/(embed|v)/([^?]+)\?.+$!i', $src, $src_matches)) {
466 466
 			// Embedded Youtube videos (www or mobile)
467
-			$src = 'https://www.youtube.com/watch?v=' . $src_matches[3];
468
-		} else if ( preg_match( '!//player\.vimeo\.com/video/([\d]+)([?/].*)?$!i', $src, $src_matches ) ) {
467
+			$src = 'https://www.youtube.com/watch?v='.$src_matches[3];
468
+		} else if (preg_match('!//player\.vimeo\.com/video/([\d]+)([?/].*)?$!i', $src, $src_matches)) {
469 469
 			// Embedded Vimeo iframe videos
470
-			$src = 'https://vimeo.com/' . (int) $src_matches[1];
471
-		} else if ( preg_match( '!//vimeo\.com/moogaloop\.swf\?clip_id=([\d]+)$!i', $src, $src_matches ) ) {
470
+			$src = 'https://vimeo.com/'.(int) $src_matches[1];
471
+		} else if (preg_match('!//vimeo\.com/moogaloop\.swf\?clip_id=([\d]+)$!i', $src, $src_matches)) {
472 472
 			// Embedded Vimeo Flash videos
473
-			$src = 'https://vimeo.com/' . (int) $src_matches[1];
474
-		} else if ( preg_match( '!//vine\.co/v/([^/]+)/embed!i', $src, $src_matches ) ) {
473
+			$src = 'https://vimeo.com/'.(int) $src_matches[1];
474
+		} else if (preg_match('!//vine\.co/v/([^/]+)/embed!i', $src, $src_matches)) {
475 475
 			// Embedded Vine videos
476
-			$src = 'https://vine.co/v/' . $src_matches[1];
477
-		} else if ( preg_match( '!//(www\.)?dailymotion\.com/embed/video/([^/?]+)([/?].+)?!i', $src, $src_matches ) ) {
476
+			$src = 'https://vine.co/v/'.$src_matches[1];
477
+		} else if (preg_match('!//(www\.)?dailymotion\.com/embed/video/([^/?]+)([/?].+)?!i', $src, $src_matches)) {
478 478
 			// Embedded Daily Motion videos
479
-			$src = 'https://www.dailymotion.com/video/' . $src_matches[2];
479
+			$src = 'https://www.dailymotion.com/video/'.$src_matches[2];
480 480
 		} else {
481
-			require_once( ABSPATH . WPINC . '/class-oembed.php' );
481
+			require_once(ABSPATH.WPINC.'/class-oembed.php');
482 482
 			$oembed = _wp_oembed_get_object();
483 483
 
484
-			if ( ! $oembed->get_provider( $src, array( 'discover' => false ) ) ) {
484
+			if ( ! $oembed->get_provider($src, array('discover' => false))) {
485 485
 				$src = '';
486 486
 			}
487 487
 		}
@@ -500,21 +500,21 @@  discard block
 block discarded – undo
500 500
 	 * @param array  $data       Associative array of source data.
501 501
 	 * @return array Processed data array.
502 502
 	 */
503
-	private function _process_meta_entry( $meta_name, $meta_value, $data ) {
504
-		if ( preg_match( '/:?(title|description|keywords|site_name)$/', $meta_name ) ) {
505
-			$data['_meta'][ $meta_name ] = $meta_value;
503
+	private function _process_meta_entry($meta_name, $meta_value, $data) {
504
+		if (preg_match('/:?(title|description|keywords|site_name)$/', $meta_name)) {
505
+			$data['_meta'][$meta_name] = $meta_value;
506 506
 		} else {
507
-			switch ( $meta_name ) {
507
+			switch ($meta_name) {
508 508
 				case 'og:url':
509 509
 				case 'og:video':
510 510
 				case 'og:video:secure_url':
511
-					$meta_value = $this->_limit_embed( $meta_value );
511
+					$meta_value = $this->_limit_embed($meta_value);
512 512
 
513
-					if ( ! isset( $data['_embeds'] ) ) {
513
+					if ( ! isset($data['_embeds'])) {
514 514
 						$data['_embeds'] = array();
515 515
 					}
516 516
 
517
-					if ( ! empty( $meta_value ) && ! in_array( $meta_value, $data['_embeds'] ) ) {
517
+					if ( ! empty($meta_value) && ! in_array($meta_value, $data['_embeds'])) {
518 518
 						$data['_embeds'][] = $meta_value;
519 519
 					}
520 520
 
@@ -525,13 +525,13 @@  discard block
 block discarded – undo
525 525
 				case 'twitter:image0':
526 526
 				case 'twitter:image:src':
527 527
 				case 'twitter:image':
528
-					$meta_value = $this->_limit_img( $meta_value );
528
+					$meta_value = $this->_limit_img($meta_value);
529 529
 
530
-					if ( ! isset( $data['_images'] ) ) {
530
+					if ( ! isset($data['_images'])) {
531 531
 						$data['_images'] = array();
532 532
 					}
533 533
 
534
-					if ( ! empty( $meta_value ) && ! in_array( $meta_value, $data['_images'] ) ) {
534
+					if ( ! empty($meta_value) && ! in_array($meta_value, $data['_images'])) {
535 535
 						$data['_images'][] = $meta_value;
536 536
 					}
537 537
 
@@ -552,58 +552,58 @@  discard block
 block discarded – undo
552 552
 	 * @param array  $data Optional. Existing data array if you have one. Default empty array.
553 553
 	 * @return array New data array.
554 554
 	 */
555
-	public function source_data_fetch_fallback( $url, $data = array() ) {
556
-		if ( empty( $url ) ) {
555
+	public function source_data_fetch_fallback($url, $data = array()) {
556
+		if (empty($url)) {
557 557
 			return array();
558 558
 		}
559 559
 
560 560
 		// Download source page to tmp file.
561
-		$source_content = $this->fetch_source_html( $url );
562
-		if ( is_wp_error( $source_content ) ) {
563
-			return array( 'errors' => $source_content->get_error_messages() );
561
+		$source_content = $this->fetch_source_html($url);
562
+		if (is_wp_error($source_content)) {
563
+			return array('errors' => $source_content->get_error_messages());
564 564
 		}
565 565
 
566 566
 		// Fetch and gather <meta> data first, so discovered media is offered 1st to user.
567
-		if ( empty( $data['_meta'] ) ) {
567
+		if (empty($data['_meta'])) {
568 568
 			$data['_meta'] = array();
569 569
 		}
570 570
 
571
-		if ( preg_match_all( '/<meta [^>]+>/', $source_content, $matches ) ) {
572
-			$items = $this->_limit_array( $matches[0] );
571
+		if (preg_match_all('/<meta [^>]+>/', $source_content, $matches)) {
572
+			$items = $this->_limit_array($matches[0]);
573 573
 
574
-			foreach ( $items as $value ) {
575
-				if ( preg_match( '/(property|name)="([^"]+)"[^>]+content="([^"]+)"/', $value, $new_matches ) ) {
576
-					$meta_name  = $this->_limit_string( $new_matches[2] );
577
-					$meta_value = $this->_limit_string( $new_matches[3] );
574
+			foreach ($items as $value) {
575
+				if (preg_match('/(property|name)="([^"]+)"[^>]+content="([^"]+)"/', $value, $new_matches)) {
576
+					$meta_name  = $this->_limit_string($new_matches[2]);
577
+					$meta_value = $this->_limit_string($new_matches[3]);
578 578
 
579 579
 					// Sanity check. $key is usually things like 'title', 'description', 'keywords', etc.
580
-					if ( strlen( $meta_name ) > 100 ) {
580
+					if (strlen($meta_name) > 100) {
581 581
 						continue;
582 582
 					}
583 583
 
584
-					$data = $this->_process_meta_entry( $meta_name, $meta_value, $data );
584
+					$data = $this->_process_meta_entry($meta_name, $meta_value, $data);
585 585
 				}
586 586
 			}
587 587
 		}
588 588
 
589 589
 		// Fetch and gather <img> data.
590
-		if ( empty( $data['_images'] ) ) {
590
+		if (empty($data['_images'])) {
591 591
 			$data['_images'] = array();
592 592
 		}
593 593
 
594
-		if ( preg_match_all( '/<img [^>]+>/', $source_content, $matches ) ) {
595
-			$items = $this->_limit_array( $matches[0] );
594
+		if (preg_match_all('/<img [^>]+>/', $source_content, $matches)) {
595
+			$items = $this->_limit_array($matches[0]);
596 596
 
597
-			foreach ( $items as $value ) {
598
-				if ( ( preg_match( '/width=(\'|")(\d+)\\1/i', $value, $new_matches ) && $new_matches[2] < 256 ) ||
599
-					( preg_match( '/height=(\'|")(\d+)\\1/i', $value, $new_matches ) && $new_matches[2] < 128 ) ) {
597
+			foreach ($items as $value) {
598
+				if ((preg_match('/width=(\'|")(\d+)\\1/i', $value, $new_matches) && $new_matches[2] < 256) ||
599
+					(preg_match('/height=(\'|")(\d+)\\1/i', $value, $new_matches) && $new_matches[2] < 128)) {
600 600
 
601 601
 					continue;
602 602
 				}
603 603
 
604
-				if ( preg_match( '/src=(\'|")([^\'"]+)\\1/i', $value, $new_matches ) ) {
605
-					$src = $this->_limit_img( $new_matches[2] );
606
-					if ( ! empty( $src ) && ! in_array( $src, $data['_images'] ) ) {
604
+				if (preg_match('/src=(\'|")([^\'"]+)\\1/i', $value, $new_matches)) {
605
+					$src = $this->_limit_img($new_matches[2]);
606
+					if ( ! empty($src) && ! in_array($src, $data['_images'])) {
607 607
 						$data['_images'][] = $src;
608 608
 					}
609 609
 				}
@@ -611,18 +611,18 @@  discard block
 block discarded – undo
611 611
 		}
612 612
 
613 613
 		// Fetch and gather <iframe> data.
614
-		if ( empty( $data['_embeds'] ) ) {
614
+		if (empty($data['_embeds'])) {
615 615
 			$data['_embeds'] = array();
616 616
 		}
617 617
 
618
-		if ( preg_match_all( '/<iframe [^>]+>/', $source_content, $matches ) ) {
619
-			$items = $this->_limit_array( $matches[0] );
618
+		if (preg_match_all('/<iframe [^>]+>/', $source_content, $matches)) {
619
+			$items = $this->_limit_array($matches[0]);
620 620
 
621
-			foreach ( $items as $value ) {
622
-				if ( preg_match( '/src=(\'|")([^\'"]+)\\1/', $value, $new_matches ) ) {
623
-					$src = $this->_limit_embed( $new_matches[2] );
621
+			foreach ($items as $value) {
622
+				if (preg_match('/src=(\'|")([^\'"]+)\\1/', $value, $new_matches)) {
623
+					$src = $this->_limit_embed($new_matches[2]);
624 624
 
625
-					if ( ! empty( $src ) && ! in_array( $src, $data['_embeds'] ) ) {
625
+					if ( ! empty($src) && ! in_array($src, $data['_embeds'])) {
626 626
 						$data['_embeds'][] = $src;
627 627
 					}
628 628
 				}
@@ -630,20 +630,20 @@  discard block
 block discarded – undo
630 630
 		}
631 631
 
632 632
 		// Fetch and gather <link> data.
633
-		if ( empty( $data['_links'] ) ) {
633
+		if (empty($data['_links'])) {
634 634
 			$data['_links'] = array();
635 635
 		}
636 636
 
637
-		if ( preg_match_all( '/<link [^>]+>/', $source_content, $matches ) ) {
638
-			$items = $this->_limit_array( $matches[0] );
637
+		if (preg_match_all('/<link [^>]+>/', $source_content, $matches)) {
638
+			$items = $this->_limit_array($matches[0]);
639 639
 
640
-			foreach ( $items as $value ) {
641
-				if ( preg_match( '/rel=["\'](canonical|shortlink|icon)["\']/i', $value, $matches_rel ) && preg_match( '/href=[\'"]([^\'" ]+)[\'"]/i', $value, $matches_url ) ) {
640
+			foreach ($items as $value) {
641
+				if (preg_match('/rel=["\'](canonical|shortlink|icon)["\']/i', $value, $matches_rel) && preg_match('/href=[\'"]([^\'" ]+)[\'"]/i', $value, $matches_url)) {
642 642
 					$rel = $matches_rel[1];
643
-					$url = $this->_limit_url( $matches_url[1] );
643
+					$url = $this->_limit_url($matches_url[1]);
644 644
 
645
-					if ( ! empty( $url ) && empty( $data['_links'][ $rel ] ) ) {
646
-						$data['_links'][ $rel ] = $url;
645
+					if ( ! empty($url) && empty($data['_links'][$rel])) {
646
+						$data['_links'][$rel] = $url;
647 647
 					}
648 648
 				}
649 649
 			}
@@ -665,27 +665,27 @@  discard block
 block discarded – undo
665 665
 		$data = array();
666 666
 
667 667
 		// Only instantiate the keys we want. Sanity check and sanitize each one.
668
-		foreach ( array( 'u', 's', 't', 'v' ) as $key ) {
669
-			if ( ! empty( $_POST[ $key ] ) ) {
670
-				$value = wp_unslash( $_POST[ $key ] );
671
-			} else if ( ! empty( $_GET[ $key ] ) ) {
672
-				$value = wp_unslash( $_GET[ $key ] );
668
+		foreach (array('u', 's', 't', 'v') as $key) {
669
+			if ( ! empty($_POST[$key])) {
670
+				$value = wp_unslash($_POST[$key]);
671
+			} else if ( ! empty($_GET[$key])) {
672
+				$value = wp_unslash($_GET[$key]);
673 673
 			} else {
674 674
 				continue;
675 675
 			}
676 676
 
677
-			if ( 'u' === $key ) {
678
-				$value = $this->_limit_url( $value );
677
+			if ('u' === $key) {
678
+				$value = $this->_limit_url($value);
679 679
 
680
-				if ( preg_match( '%^(?:https?:)?//[^/]+%i', $value, $domain_match ) ) {
680
+				if (preg_match('%^(?:https?:)?//[^/]+%i', $value, $domain_match)) {
681 681
 					$this->domain = $domain_match[0];
682 682
 				}
683 683
 			} else {
684
-				$value = $this->_limit_string( $value );
684
+				$value = $this->_limit_string($value);
685 685
 			}
686 686
 
687
-			if ( ! empty( $value ) ) {
688
-				$data[ $key ] = $value;
687
+			if ( ! empty($value)) {
688
+				$data[$key] = $value;
689 689
 			}
690 690
 		}
691 691
 
@@ -696,58 +696,58 @@  discard block
 block discarded – undo
696 696
 		 *
697 697
 		 * @param bool $enable Whether to enable media discovery.
698 698
 		 */
699
-		if ( apply_filters( 'enable_press_this_media_discovery', true ) ) {
699
+		if (apply_filters('enable_press_this_media_discovery', true)) {
700 700
 			/*
701 701
 			 * If no title, _images, _embed, and _meta was passed via $_POST, fetch data from source as fallback,
702 702
 			 * making PT fully backward compatible with the older bookmarklet.
703 703
 			 */
704
-			if ( empty( $_POST ) && ! empty( $data['u'] ) ) {
705
-				$data = $this->source_data_fetch_fallback( $data['u'], $data );
704
+			if (empty($_POST) && ! empty($data['u'])) {
705
+				$data = $this->source_data_fetch_fallback($data['u'], $data);
706 706
 			} else {
707
-				foreach ( array( '_images', '_embeds' ) as $type ) {
708
-					if ( empty( $_POST[ $type ] ) ) {
707
+				foreach (array('_images', '_embeds') as $type) {
708
+					if (empty($_POST[$type])) {
709 709
 						continue;
710 710
 					}
711 711
 
712
-					$data[ $type ] = array();
713
-					$items = $this->_limit_array( $_POST[ $type ] );
712
+					$data[$type] = array();
713
+					$items = $this->_limit_array($_POST[$type]);
714 714
 
715
-					foreach ( $items as $key => $value ) {
716
-						if ( $type === '_images' ) {
717
-							$value = $this->_limit_img( wp_unslash( $value ) );
715
+					foreach ($items as $key => $value) {
716
+						if ($type === '_images') {
717
+							$value = $this->_limit_img(wp_unslash($value));
718 718
 						} else {
719
-							$value = $this->_limit_embed( wp_unslash( $value ) );
719
+							$value = $this->_limit_embed(wp_unslash($value));
720 720
 						}
721 721
 
722
-						if ( ! empty( $value ) ) {
723
-							$data[ $type ][] = $value;
722
+						if ( ! empty($value)) {
723
+							$data[$type][] = $value;
724 724
 						}
725 725
 					}
726 726
 				}
727 727
 
728
-				foreach ( array( '_meta', '_links' ) as $type ) {
729
-					if ( empty( $_POST[ $type ] ) ) {
728
+				foreach (array('_meta', '_links') as $type) {
729
+					if (empty($_POST[$type])) {
730 730
 						continue;
731 731
 					}
732 732
 
733
-					$data[ $type ] = array();
734
-					$items = $this->_limit_array( $_POST[ $type ] );
733
+					$data[$type] = array();
734
+					$items = $this->_limit_array($_POST[$type]);
735 735
 
736
-					foreach ( $items as $key => $value ) {
736
+					foreach ($items as $key => $value) {
737 737
 						// Sanity check. These are associative arrays, $key is usually things like 'title', 'description', 'keywords', etc.
738
-						if ( empty( $key ) || strlen( $key ) > 100 ) {
738
+						if (empty($key) || strlen($key) > 100) {
739 739
 							continue;
740 740
 						}
741 741
 
742
-						if ( $type === '_meta' ) {
743
-							$value = $this->_limit_string( wp_unslash( $value ) );
742
+						if ($type === '_meta') {
743
+							$value = $this->_limit_string(wp_unslash($value));
744 744
 
745
-							if ( ! empty( $value ) ) {
746
-								$data = $this->_process_meta_entry( $key, $value, $data );
745
+							if ( ! empty($value)) {
746
+								$data = $this->_process_meta_entry($key, $value, $data);
747 747
 							}
748 748
 						} else {
749
-							if ( in_array( $key, array( 'canonical', 'shortlink', 'icon' ), true ) ) {
750
-								$data[ $type ][ $key ] = $this->_limit_url( wp_unslash( $value ) );
749
+							if (in_array($key, array('canonical', 'shortlink', 'icon'), true)) {
750
+								$data[$type][$key] = $this->_limit_url(wp_unslash($value));
751 751
 							}
752 752
 						}
753 753
 					}
@@ -755,11 +755,11 @@  discard block
 block discarded – undo
755 755
 			}
756 756
 
757 757
 			// Support passing a single image src as `i`
758
-			if ( ! empty( $_REQUEST['i'] ) && ( $img_src = $this->_limit_img( wp_unslash( $_REQUEST['i'] ) ) ) ) {
759
-				if ( empty( $data['_images'] ) ) {
760
-					$data['_images'] = array( $img_src );
761
-				} elseif ( ! in_array( $img_src, $data['_images'], true ) ) {
762
-					array_unshift( $data['_images'], $img_src );
758
+			if ( ! empty($_REQUEST['i']) && ($img_src = $this->_limit_img(wp_unslash($_REQUEST['i'])))) {
759
+				if (empty($data['_images'])) {
760
+					$data['_images'] = array($img_src);
761
+				} elseif ( ! in_array($img_src, $data['_images'], true)) {
762
+					array_unshift($data['_images'], $img_src);
763 763
 				}
764 764
 			}
765 765
 		}
@@ -771,7 +771,7 @@  discard block
 block discarded – undo
771 771
 		 *
772 772
 		 * @param array $data Press This Data array.
773 773
 		 */
774
-		return apply_filters( 'press_this_data', $data );
774
+		return apply_filters('press_this_data', $data);
775 775
 	}
776 776
 
777 777
 	/**
@@ -783,14 +783,14 @@  discard block
 block discarded – undo
783 783
 	 * @param string $styles URL to editor stylesheet.
784 784
 	 * @return string Possibly modified stylesheets list.
785 785
 	 */
786
-	public function add_editor_style( $styles ) {
787
-		if ( ! empty( $styles ) ) {
786
+	public function add_editor_style($styles) {
787
+		if ( ! empty($styles)) {
788 788
 			$styles .= ',';
789 789
 		}
790 790
 
791
-		$press_this = admin_url( 'css/press-this-editor.css' );
792
-		if ( is_rtl() ) {
793
-			$press_this = str_replace( '.css', '-rtl.css', $press_this );
791
+		$press_this = admin_url('css/press-this-editor.css');
792
+		if (is_rtl()) {
793
+			$press_this = str_replace('.css', '-rtl.css', $press_this);
794 794
 		}
795 795
 
796 796
 		$open_sans_font_url = '';
@@ -798,31 +798,31 @@  discard block
 block discarded – undo
798 798
 		/* translators: If there are characters in your language that are not supported
799 799
 		 * by Open Sans, translate this to 'off'. Do not translate into your own language.
800 800
 		 */
801
-		if ( 'off' !== _x( 'on', 'Open Sans font: on or off' ) ) {
801
+		if ('off' !== _x('on', 'Open Sans font: on or off')) {
802 802
 			$subsets = 'latin,latin-ext';
803 803
 
804 804
 			/* translators: To add an additional Open Sans character subset specific to your language,
805 805
 			 * translate this to 'greek', 'cyrillic' or 'vietnamese'. Do not translate into your own language.
806 806
 			 */
807
-			$subset = _x( 'no-subset', 'Open Sans font: add new subset (greek, cyrillic, vietnamese)' );
807
+			$subset = _x('no-subset', 'Open Sans font: add new subset (greek, cyrillic, vietnamese)');
808 808
 
809
-			if ( 'cyrillic' == $subset ) {
809
+			if ('cyrillic' == $subset) {
810 810
 				$subsets .= ',cyrillic,cyrillic-ext';
811
-			} elseif ( 'greek' == $subset ) {
811
+			} elseif ('greek' == $subset) {
812 812
 				$subsets .= ',greek,greek-ext';
813
-			} elseif ( 'vietnamese' == $subset ) {
813
+			} elseif ('vietnamese' == $subset) {
814 814
 				$subsets .= ',vietnamese';
815 815
 			}
816 816
 
817 817
 			$query_args = array(
818
-				'family' => urlencode( 'Open Sans:400italic,700italic,400,600,700' ),
819
-				'subset' => urlencode( $subsets ),
818
+				'family' => urlencode('Open Sans:400italic,700italic,400,600,700'),
819
+				'subset' => urlencode($subsets),
820 820
 			);
821 821
 
822
-			$open_sans_font_url = ',' . add_query_arg( $query_args, 'https://fonts.googleapis.com/css' );
822
+			$open_sans_font_url = ','.add_query_arg($query_args, 'https://fonts.googleapis.com/css');
823 823
 		}
824 824
 
825
-		return $styles . $press_this . $open_sans_font_url;
825
+		return $styles.$press_this.$open_sans_font_url;
826 826
 	}
827 827
 
828 828
 	/**
@@ -833,35 +833,35 @@  discard block
 block discarded – undo
833 833
 	 *
834 834
 	 * @param WP_Post $post Post object.
835 835
 	 */
836
-	public function post_formats_html( $post ) {
837
-		if ( current_theme_supports( 'post-formats' ) && post_type_supports( $post->post_type, 'post-formats' ) ) {
838
-			$post_formats = get_theme_support( 'post-formats' );
836
+	public function post_formats_html($post) {
837
+		if (current_theme_supports('post-formats') && post_type_supports($post->post_type, 'post-formats')) {
838
+			$post_formats = get_theme_support('post-formats');
839 839
 
840
-			if ( is_array( $post_formats[0] ) ) {
841
-				$post_format = get_post_format( $post->ID );
840
+			if (is_array($post_formats[0])) {
841
+				$post_format = get_post_format($post->ID);
842 842
 
843
-				if ( ! $post_format ) {
843
+				if ( ! $post_format) {
844 844
 					$post_format = '0';
845 845
 				}
846 846
 
847 847
 				// Add in the current one if it isn't there yet, in case the current theme doesn't support it.
848
-				if ( $post_format && ! in_array( $post_format, $post_formats[0] ) ) {
848
+				if ($post_format && ! in_array($post_format, $post_formats[0])) {
849 849
 					$post_formats[0][] = $post_format;
850 850
 				}
851 851
 
852 852
 				?>
853 853
 				<div id="post-formats-select">
854
-				<fieldset><legend class="screen-reader-text"><?php _e( 'Post Formats' ); ?></legend>
855
-					<input type="radio" name="post_format" class="post-format" id="post-format-0" value="0" <?php checked( $post_format, '0' ); ?> />
856
-					<label for="post-format-0" class="post-format-icon post-format-standard"><?php echo get_post_format_string( 'standard' ); ?></label>
854
+				<fieldset><legend class="screen-reader-text"><?php _e('Post Formats'); ?></legend>
855
+					<input type="radio" name="post_format" class="post-format" id="post-format-0" value="0" <?php checked($post_format, '0'); ?> />
856
+					<label for="post-format-0" class="post-format-icon post-format-standard"><?php echo get_post_format_string('standard'); ?></label>
857 857
 					<?php
858 858
 
859
-					foreach ( $post_formats[0] as $format ) {
860
-						$attr_format = esc_attr( $format );
859
+					foreach ($post_formats[0] as $format) {
860
+						$attr_format = esc_attr($format);
861 861
 						?>
862 862
 						<br />
863
-						<input type="radio" name="post_format" class="post-format" id="post-format-<?php echo $attr_format; ?>" value="<?php echo $attr_format; ?>" <?php checked( $post_format, $format ); ?> />
864
-						<label for="post-format-<?php echo $attr_format ?>" class="post-format-icon post-format-<?php echo $attr_format; ?>"><?php echo esc_html( get_post_format_string( $format ) ); ?></label>
863
+						<input type="radio" name="post_format" class="post-format" id="post-format-<?php echo $attr_format; ?>" value="<?php echo $attr_format; ?>" <?php checked($post_format, $format); ?> />
864
+						<label for="post-format-<?php echo $attr_format ?>" class="post-format-icon post-format-<?php echo $attr_format; ?>"><?php echo esc_html(get_post_format_string($format)); ?></label>
865 865
 						<?php
866 866
 					 }
867 867
 
@@ -881,45 +881,45 @@  discard block
 block discarded – undo
881 881
 	 *
882 882
 	 * @param WP_Post $post Post object.
883 883
 	 */
884
-	public function categories_html( $post ) {
885
-		$taxonomy = get_taxonomy( 'category' );
884
+	public function categories_html($post) {
885
+		$taxonomy = get_taxonomy('category');
886 886
 
887
-		if ( current_user_can( $taxonomy->cap->edit_terms ) ) {
887
+		if (current_user_can($taxonomy->cap->edit_terms)) {
888 888
 			?>
889 889
 			<button type="button" class="add-cat-toggle button-link" aria-expanded="false">
890
-				<span class="dashicons dashicons-plus"></span><span class="screen-reader-text"><?php _e( 'Toggle add category' ); ?></span>
890
+				<span class="dashicons dashicons-plus"></span><span class="screen-reader-text"><?php _e('Toggle add category'); ?></span>
891 891
 			</button>
892 892
 			<div class="add-category is-hidden">
893 893
 				<label class="screen-reader-text" for="new-category"><?php echo $taxonomy->labels->add_new_item; ?></label>
894
-				<input type="text" id="new-category" class="add-category-name" placeholder="<?php echo esc_attr( $taxonomy->labels->new_item_name ); ?>" value="" aria-required="true">
894
+				<input type="text" id="new-category" class="add-category-name" placeholder="<?php echo esc_attr($taxonomy->labels->new_item_name); ?>" value="" aria-required="true">
895 895
 				<label class="screen-reader-text" for="new-category-parent"><?php echo $taxonomy->labels->parent_item_colon; ?></label>
896 896
 				<div class="postform-wrapper">
897 897
 					<?php
898
-					wp_dropdown_categories( array(
898
+					wp_dropdown_categories(array(
899 899
 						'taxonomy'         => 'category',
900 900
 						'hide_empty'       => 0,
901 901
 						'name'             => 'new-category-parent',
902 902
 						'orderby'          => 'name',
903 903
 						'hierarchical'     => 1,
904
-						'show_option_none' => '&mdash; ' . $taxonomy->labels->parent_item . ' &mdash;'
905
-					) );
904
+						'show_option_none' => '&mdash; '.$taxonomy->labels->parent_item.' &mdash;'
905
+					));
906 906
 					?>
907 907
 				</div>
908
-				<button type="button" class="add-cat-submit"><?php _e( 'Add' ); ?></button>
908
+				<button type="button" class="add-cat-submit"><?php _e('Add'); ?></button>
909 909
 			</div>
910 910
 			<?php
911 911
 
912 912
 		}
913 913
 		?>
914 914
 		<div class="categories-search-wrapper">
915
-			<input id="categories-search" type="search" class="categories-search" placeholder="<?php esc_attr_e( 'Search categories by name' ) ?>">
915
+			<input id="categories-search" type="search" class="categories-search" placeholder="<?php esc_attr_e('Search categories by name') ?>">
916 916
 			<label for="categories-search">
917
-				<span class="dashicons dashicons-search"></span><span class="screen-reader-text"><?php _e( 'Search categories' ); ?></span>
917
+				<span class="dashicons dashicons-search"></span><span class="screen-reader-text"><?php _e('Search categories'); ?></span>
918 918
 			</label>
919 919
 		</div>
920
-		<div aria-label="<?php esc_attr_e( 'Categories' ); ?>">
920
+		<div aria-label="<?php esc_attr_e('Categories'); ?>">
921 921
 			<ul class="categories-select">
922
-				<?php wp_terms_checklist( $post->ID, array( 'taxonomy' => 'category', 'list_only' => true ) ); ?>
922
+				<?php wp_terms_checklist($post->ID, array('taxonomy' => 'category', 'list_only' => true)); ?>
923 923
 			</ul>
924 924
 		</div>
925 925
 		<?php
@@ -933,12 +933,12 @@  discard block
 block discarded – undo
933 933
 	 *
934 934
 	 * @param WP_Post $post Post object.
935 935
 	 */
936
-	public function tags_html( $post ) {
937
-		$taxonomy              = get_taxonomy( 'post_tag' );
938
-		$user_can_assign_terms = current_user_can( $taxonomy->cap->assign_terms );
939
-		$esc_tags              = get_terms_to_edit( $post->ID, 'post_tag' );
936
+	public function tags_html($post) {
937
+		$taxonomy              = get_taxonomy('post_tag');
938
+		$user_can_assign_terms = current_user_can($taxonomy->cap->assign_terms);
939
+		$esc_tags              = get_terms_to_edit($post->ID, 'post_tag');
940 940
 
941
-		if ( ! $esc_tags || is_wp_error( $esc_tags ) ) {
941
+		if ( ! $esc_tags || is_wp_error($esc_tags)) {
942 942
 			$esc_tags = '';
943 943
 		}
944 944
 
@@ -948,13 +948,13 @@  discard block
 block discarded – undo
948 948
 			<input type="hidden" name="tax_input[post_tag]" class="the-tags" value="<?php echo $esc_tags; // escaped in get_terms_to_edit() ?>">
949 949
 		 	<?php
950 950
 
951
-			if ( $user_can_assign_terms ) {
951
+			if ($user_can_assign_terms) {
952 952
 				?>
953 953
 				<div class="ajaxtag hide-if-no-js">
954
-					<label class="screen-reader-text" for="new-tag-post_tag"><?php _e( 'Tags' ); ?></label>
954
+					<label class="screen-reader-text" for="new-tag-post_tag"><?php _e('Tags'); ?></label>
955 955
 					<p>
956 956
 						<input type="text" id="new-tag-post_tag" name="newtag[post_tag]" class="newtag form-input-tip" size="16" autocomplete="off" value="" aria-describedby="new-tag-desc" />
957
-						<button type="button" class="tagadd"><?php _e( 'Add' ); ?></button>
957
+						<button type="button" class="tagadd"><?php _e('Add'); ?></button>
958 958
 					</p>
959 959
 				</div>
960 960
 				<p class="howto" id="new-tag-desc">
@@ -969,7 +969,7 @@  discard block
 block discarded – undo
969 969
 		</div>
970 970
 		<?php
971 971
 
972
-		if ( $user_can_assign_terms ) {
972
+		if ($user_can_assign_terms) {
973 973
 			?>
974 974
 			<button type="button" class="button-link tagcloud-link" id="link-post_tag"><?php echo $taxonomy->labels->choose_from_most_used; ?></button>
975 975
 			<?php
@@ -985,19 +985,19 @@  discard block
 block discarded – undo
985 985
 	 * @param array $data The site's data.
986 986
 	 * @return array Embeds selected to be available.
987 987
 	 */
988
-	public function get_embeds( $data ) {
988
+	public function get_embeds($data) {
989 989
 		$selected_embeds = array();
990 990
 
991 991
 		// Make sure to add the Pressed page if it's a valid oembed itself
992
-		if ( ! empty ( $data['u'] ) && $this->_limit_embed( $data['u'] ) ) {
992
+		if ( ! empty ($data['u']) && $this->_limit_embed($data['u'])) {
993 993
 			$data['_embeds'][] = $data['u'];
994 994
 		}
995 995
 
996
-		if ( ! empty( $data['_embeds'] ) ) {
997
-			foreach ( $data['_embeds'] as $src ) {
998
-				$prot_relative_src = preg_replace( '/^https?:/', '', $src );
996
+		if ( ! empty($data['_embeds'])) {
997
+			foreach ($data['_embeds'] as $src) {
998
+				$prot_relative_src = preg_replace('/^https?:/', '', $src);
999 999
 
1000
-				if ( in_array( $prot_relative_src, $this->embeds ) ) {
1000
+				if (in_array($prot_relative_src, $this->embeds)) {
1001 1001
 					continue;
1002 1002
 				}
1003 1003
 
@@ -1018,19 +1018,19 @@  discard block
 block discarded – undo
1018 1018
 	 * @param array $data The site's data.
1019 1019
 	 * @return array
1020 1020
 	 */
1021
-	public function get_images( $data ) {
1021
+	public function get_images($data) {
1022 1022
 		$selected_images = array();
1023 1023
 
1024
-		if ( ! empty( $data['_images'] ) ) {
1025
-			foreach ( $data['_images'] as $src ) {
1026
-				if ( false !== strpos( $src, 'gravatar.com' ) ) {
1027
-					$src = preg_replace( '%http://[\d]+\.gravatar\.com/%', 'https://secure.gravatar.com/', $src );
1024
+		if ( ! empty($data['_images'])) {
1025
+			foreach ($data['_images'] as $src) {
1026
+				if (false !== strpos($src, 'gravatar.com')) {
1027
+					$src = preg_replace('%http://[\d]+\.gravatar\.com/%', 'https://secure.gravatar.com/', $src);
1028 1028
 				}
1029 1029
 
1030
-				$prot_relative_src = preg_replace( '/^https?:/', '', $src );
1030
+				$prot_relative_src = preg_replace('/^https?:/', '', $src);
1031 1031
 
1032
-				if ( in_array( $prot_relative_src, $this->images ) ||
1033
-					( false !== strpos( $src, 'avatar' ) && count( $this->images ) > 15 ) ) {
1032
+				if (in_array($prot_relative_src, $this->images) ||
1033
+					(false !== strpos($src, 'avatar') && count($this->images) > 15)) {
1034 1034
 					// Skip: already selected or some type of avatar and we've already gathered more than 15 images.
1035 1035
 					continue;
1036 1036
 				}
@@ -1052,22 +1052,22 @@  discard block
 block discarded – undo
1052 1052
  	 * @param array $data The site's data.
1053 1053
 	 * @return string Discovered canonical URL, or empty
1054 1054
 	 */
1055
-	public function get_canonical_link( $data ) {
1055
+	public function get_canonical_link($data) {
1056 1056
 		$link = '';
1057 1057
 
1058
-		if ( ! empty( $data['_links']['canonical'] ) ) {
1058
+		if ( ! empty($data['_links']['canonical'])) {
1059 1059
 			$link = $data['_links']['canonical'];
1060
-		} elseif ( ! empty( $data['u'] ) ) {
1060
+		} elseif ( ! empty($data['u'])) {
1061 1061
 			$link = $data['u'];
1062
-		} elseif ( ! empty( $data['_meta'] ) ) {
1063
-			if ( ! empty( $data['_meta']['twitter:url'] ) ) {
1062
+		} elseif ( ! empty($data['_meta'])) {
1063
+			if ( ! empty($data['_meta']['twitter:url'])) {
1064 1064
 				$link = $data['_meta']['twitter:url'];
1065
-			} else if ( ! empty( $data['_meta']['og:url'] ) ) {
1065
+			} else if ( ! empty($data['_meta']['og:url'])) {
1066 1066
 				$link = $data['_meta']['og:url'];
1067 1067
 			}
1068 1068
 		}
1069 1069
 
1070
-		if ( empty( $link ) && ! empty( $data['_links']['shortlink'] ) ) {
1070
+		if (empty($link) && ! empty($data['_links']['shortlink'])) {
1071 1071
 			$link = $data['_links']['shortlink'];
1072 1072
 		}
1073 1073
 
@@ -1083,13 +1083,13 @@  discard block
 block discarded – undo
1083 1083
 	 * @param array $data The site's data.
1084 1084
 	 * @return string Discovered site name, or empty
1085 1085
 	 */
1086
-	public function get_source_site_name( $data ) {
1086
+	public function get_source_site_name($data) {
1087 1087
 		$name = '';
1088 1088
 
1089
-		if ( ! empty( $data['_meta'] ) ) {
1090
-			if ( ! empty( $data['_meta']['og:site_name'] ) ) {
1089
+		if ( ! empty($data['_meta'])) {
1090
+			if ( ! empty($data['_meta']['og:site_name'])) {
1091 1091
 				$name = $data['_meta']['og:site_name'];
1092
-			} else if ( ! empty( $data['_meta']['application-name'] ) ) {
1092
+			} else if ( ! empty($data['_meta']['application-name'])) {
1093 1093
 				$name = $data['_meta']['application-name'];
1094 1094
 			}
1095 1095
 		}
@@ -1106,17 +1106,17 @@  discard block
 block discarded – undo
1106 1106
 	 * @param array $data The site's data.
1107 1107
 	 * @return string Discovered page title, or empty
1108 1108
 	 */
1109
-	public function get_suggested_title( $data ) {
1109
+	public function get_suggested_title($data) {
1110 1110
 		$title = '';
1111 1111
 
1112
-		if ( ! empty( $data['t'] ) ) {
1112
+		if ( ! empty($data['t'])) {
1113 1113
 			$title = $data['t'];
1114
-		} elseif ( ! empty( $data['_meta'] ) ) {
1115
-			if ( ! empty( $data['_meta']['twitter:title'] ) ) {
1114
+		} elseif ( ! empty($data['_meta'])) {
1115
+			if ( ! empty($data['_meta']['twitter:title'])) {
1116 1116
 				$title = $data['_meta']['twitter:title'];
1117
-			} else if ( ! empty( $data['_meta']['og:title'] ) ) {
1117
+			} else if ( ! empty($data['_meta']['og:title'])) {
1118 1118
 				$title = $data['_meta']['og:title'];
1119
-			} else if ( ! empty( $data['_meta']['title'] ) ) {
1119
+			} else if ( ! empty($data['_meta']['title'])) {
1120 1120
 				$title = $data['_meta']['title'];
1121 1121
 			}
1122 1122
 		}
@@ -1135,38 +1135,38 @@  discard block
 block discarded – undo
1135 1135
 	 * @param array $data The site's data.
1136 1136
 	 * @return string Discovered content, or empty
1137 1137
 	 */
1138
-	public function get_suggested_content( $data ) {
1138
+	public function get_suggested_content($data) {
1139 1139
 		$content = $text = '';
1140 1140
 
1141
-		if ( ! empty( $data['s'] ) ) {
1141
+		if ( ! empty($data['s'])) {
1142 1142
 			$text = $data['s'];
1143
-		} else if ( ! empty( $data['_meta'] ) ) {
1144
-			if ( ! empty( $data['_meta']['twitter:description'] ) ) {
1143
+		} else if ( ! empty($data['_meta'])) {
1144
+			if ( ! empty($data['_meta']['twitter:description'])) {
1145 1145
 				$text = $data['_meta']['twitter:description'];
1146
-			} else if ( ! empty( $data['_meta']['og:description'] ) ) {
1146
+			} else if ( ! empty($data['_meta']['og:description'])) {
1147 1147
 				$text = $data['_meta']['og:description'];
1148
-			} else if ( ! empty( $data['_meta']['description'] ) ) {
1148
+			} else if ( ! empty($data['_meta']['description'])) {
1149 1149
 				$text = $data['_meta']['description'];
1150 1150
 			}
1151 1151
 
1152 1152
 			// If there is an ellipsis at the end, the description is very likely auto-generated. Better to ignore it.
1153
-			if ( $text && substr( $text, -3 ) === '...' ) {
1153
+			if ($text && substr($text, -3) === '...') {
1154 1154
 				$text = '';
1155 1155
 			}
1156 1156
 		}
1157 1157
 
1158
-		$default_html = array( 'quote' => '', 'link' => '', 'embed' => '' );
1158
+		$default_html = array('quote' => '', 'link' => '', 'embed' => '');
1159 1159
 
1160
-		if ( ! empty( $data['u'] ) && $this->_limit_embed( $data['u'] ) ) {
1161
-			$default_html['embed'] = '<p>[embed]' . $data['u'] . '[/embed]</p>';
1160
+		if ( ! empty($data['u']) && $this->_limit_embed($data['u'])) {
1161
+			$default_html['embed'] = '<p>[embed]'.$data['u'].'[/embed]</p>';
1162 1162
 
1163
-			if ( ! empty( $data['s'] ) ) {
1163
+			if ( ! empty($data['s'])) {
1164 1164
 				// If the user has selected some text, do quote it.
1165 1165
 				$default_html['quote'] = '<blockquote>%1$s</blockquote>';
1166 1166
 			}
1167 1167
 		} else {
1168 1168
 			$default_html['quote'] = '<blockquote>%1$s</blockquote>';
1169
-			$default_html['link'] = '<p>' . _x( 'Source:', 'Used in Press This to indicate where the content comes from.' ) .
1169
+			$default_html['link'] = '<p>'._x('Source:', 'Used in Press This to indicate where the content comes from.').
1170 1170
 				' <em><a href="%1$s">%2$s</a></em></p>';
1171 1171
 		}
1172 1172
 
@@ -1183,28 +1183,28 @@  discard block
 block discarded – undo
1183 1183
 		 *                                - 'embed' which contains an [embed] shortcode when the source page offers embeddable content.
1184 1184
 		 * @param array $data         Associative array containing the data from the source page.
1185 1185
 		 */
1186
-		$default_html = apply_filters( 'press_this_suggested_html', $default_html, $data );
1186
+		$default_html = apply_filters('press_this_suggested_html', $default_html, $data);
1187 1187
 
1188
-		if ( ! empty( $default_html['embed'] ) ) {
1188
+		if ( ! empty($default_html['embed'])) {
1189 1189
 			$content .= $default_html['embed'];
1190 1190
 		}
1191 1191
 
1192 1192
 		// Wrap suggested content in the specified HTML.
1193
-		if ( ! empty( $default_html['quote'] ) && $text ) {
1194
-			$content .= sprintf( $default_html['quote'], $text );
1193
+		if ( ! empty($default_html['quote']) && $text) {
1194
+			$content .= sprintf($default_html['quote'], $text);
1195 1195
 		}
1196 1196
 
1197 1197
 		// Add source attribution if there is one available.
1198
-		if ( ! empty( $default_html['link'] ) ) {
1199
-			$title = $this->get_suggested_title( $data );
1200
-			$url = $this->get_canonical_link( $data );
1198
+		if ( ! empty($default_html['link'])) {
1199
+			$title = $this->get_suggested_title($data);
1200
+			$url = $this->get_canonical_link($data);
1201 1201
 
1202
-			if ( ! $title ) {
1203
-				$title = $this->get_source_site_name( $data );
1202
+			if ( ! $title) {
1203
+				$title = $this->get_source_site_name($data);
1204 1204
 			}
1205 1205
 
1206
-			if ( $url && $title ) {
1207
-				$content .= sprintf( $default_html['link'], $url, $title );
1206
+			if ($url && $title) {
1207
+				$content .= sprintf($default_html['link'], $url, $title);
1208 1208
 			}
1209 1209
 		}
1210 1210
 
@@ -1227,41 +1227,41 @@  discard block
 block discarded – undo
1227 1227
 		// Get data, new (POST) and old (GET).
1228 1228
 		$data = $this->merge_or_fetch_data();
1229 1229
 
1230
-		$post_title = $this->get_suggested_title( $data );
1230
+		$post_title = $this->get_suggested_title($data);
1231 1231
 
1232
-		$post_content = $this->get_suggested_content( $data );
1232
+		$post_content = $this->get_suggested_content($data);
1233 1233
 
1234 1234
 		// Get site settings array/data.
1235 1235
 		$site_settings = $this->site_settings();
1236 1236
 
1237 1237
 		// Pass the images and embeds
1238
-		$images = $this->get_images( $data );
1239
-		$embeds = $this->get_embeds( $data );
1238
+		$images = $this->get_images($data);
1239
+		$embeds = $this->get_embeds($data);
1240 1240
 
1241 1241
 		$site_data = array(
1242
-			'v' => ! empty( $data['v'] ) ? $data['v'] : '',
1243
-			'u' => ! empty( $data['u'] ) ? $data['u'] : '',
1244
-			'hasData' => ! empty( $data ),
1242
+			'v' => ! empty($data['v']) ? $data['v'] : '',
1243
+			'u' => ! empty($data['u']) ? $data['u'] : '',
1244
+			'hasData' => ! empty($data),
1245 1245
 		);
1246 1246
 
1247
-		if ( ! empty( $images ) ) {
1247
+		if ( ! empty($images)) {
1248 1248
 			$site_data['_images'] = $images;
1249 1249
 		}
1250 1250
 
1251
-		if ( ! empty( $embeds ) ) {
1251
+		if ( ! empty($embeds)) {
1252 1252
 			$site_data['_embeds'] = $embeds;
1253 1253
 		}
1254 1254
 
1255 1255
 		// Add press-this-editor.css and remove theme's editor-style.css, if any.
1256 1256
 		remove_editor_styles();
1257 1257
 
1258
-		add_filter( 'mce_css', array( $this, 'add_editor_style' ) );
1258
+		add_filter('mce_css', array($this, 'add_editor_style'));
1259 1259
 
1260
-		if ( ! empty( $GLOBALS['is_IE'] ) ) {
1261
-			@header( 'X-UA-Compatible: IE=edge' );
1260
+		if ( ! empty($GLOBALS['is_IE'])) {
1261
+			@header('X-UA-Compatible: IE=edge');
1262 1262
 		}
1263 1263
 
1264
-		@header( 'Content-Type: ' . get_option( 'html_type' ) . '; charset=' . get_option( 'blog_charset' ) );
1264
+		@header('Content-Type: '.get_option('html_type').'; charset='.get_option('blog_charset'));
1265 1265
 
1266 1266
 ?>
1267 1267
 <!DOCTYPE html>
@@ -1269,22 +1269,22 @@  discard block
 block discarded – undo
1269 1269
 <!--[if IE 8]>         <html class="lt-ie9" <?php language_attributes(); ?>> <![endif]-->
1270 1270
 <!--[if gt IE 8]><!--> <html <?php language_attributes(); ?>> <!--<![endif]-->
1271 1271
 <head>
1272
-	<meta http-equiv="Content-Type" content="<?php echo esc_attr( get_bloginfo( 'html_type' ) ); ?>; charset=<?php echo esc_attr( get_option( 'blog_charset' ) ); ?>" />
1272
+	<meta http-equiv="Content-Type" content="<?php echo esc_attr(get_bloginfo('html_type')); ?>; charset=<?php echo esc_attr(get_option('blog_charset')); ?>" />
1273 1273
 	<meta name="viewport" content="width=device-width">
1274
-	<title><?php esc_html_e( 'Press This!' ) ?></title>
1274
+	<title><?php esc_html_e('Press This!') ?></title>
1275 1275
 
1276 1276
 	<script>
1277
-		window.wpPressThisData   = <?php echo wp_json_encode( $site_data ); ?>;
1278
-		window.wpPressThisConfig = <?php echo wp_json_encode( $site_settings ); ?>;
1277
+		window.wpPressThisData   = <?php echo wp_json_encode($site_data); ?>;
1278
+		window.wpPressThisConfig = <?php echo wp_json_encode($site_settings); ?>;
1279 1279
 	</script>
1280 1280
 
1281 1281
 	<script type="text/javascript">
1282
-		var ajaxurl = '<?php echo esc_js( admin_url( 'admin-ajax.php', 'relative' ) ); ?>',
1282
+		var ajaxurl = '<?php echo esc_js(admin_url('admin-ajax.php', 'relative')); ?>',
1283 1283
 			pagenow = 'press-this',
1284 1284
 			typenow = 'post',
1285 1285
 			adminpage = 'press-this-php',
1286
-			thousandsSeparator = '<?php echo addslashes( $wp_locale->number_format['thousands_sep'] ); ?>',
1287
-			decimalPoint = '<?php echo addslashes( $wp_locale->number_format['decimal_point'] ); ?>',
1286
+			thousandsSeparator = '<?php echo addslashes($wp_locale->number_format['thousands_sep']); ?>',
1287
+			decimalPoint = '<?php echo addslashes($wp_locale->number_format['decimal_point']); ?>',
1288 1288
 			isRtl = <?php echo (int) is_rtl(); ?>;
1289 1289
 	</script>
1290 1290
 
@@ -1293,82 +1293,82 @@  discard block
 block discarded – undo
1293 1293
 		 * $post->ID is needed for the embed shortcode so we can show oEmbed previews in the editor.
1294 1294
 		 * Maybe find a way without it.
1295 1295
 		 */
1296
-		$post = get_default_post_to_edit( 'post', true );
1296
+		$post = get_default_post_to_edit('post', true);
1297 1297
 		$post_ID = (int) $post->ID;
1298 1298
 
1299
-		wp_enqueue_media( array( 'post' => $post_ID ) );
1300
-		wp_enqueue_style( 'press-this' );
1301
-		wp_enqueue_script( 'press-this' );
1302
-		wp_enqueue_script( 'json2' );
1303
-		wp_enqueue_script( 'editor' );
1299
+		wp_enqueue_media(array('post' => $post_ID));
1300
+		wp_enqueue_style('press-this');
1301
+		wp_enqueue_script('press-this');
1302
+		wp_enqueue_script('json2');
1303
+		wp_enqueue_script('editor');
1304 1304
 
1305 1305
 		$supports_formats = false;
1306 1306
 		$post_format      = 0;
1307 1307
 
1308
-		if ( current_theme_supports( 'post-formats' ) && post_type_supports( $post->post_type, 'post-formats' ) ) {
1308
+		if (current_theme_supports('post-formats') && post_type_supports($post->post_type, 'post-formats')) {
1309 1309
 			$supports_formats = true;
1310 1310
 
1311
-			if ( ! ( $post_format = get_post_format( $post_ID ) ) ) {
1311
+			if ( ! ($post_format = get_post_format($post_ID))) {
1312 1312
 				$post_format = 0;
1313 1313
 			}
1314 1314
 		}
1315 1315
 
1316 1316
 		/** This action is documented in wp-admin/admin-header.php */
1317
-		do_action( 'admin_enqueue_scripts', 'press-this.php' );
1317
+		do_action('admin_enqueue_scripts', 'press-this.php');
1318 1318
 
1319 1319
 		/** This action is documented in wp-admin/admin-header.php */
1320
-		do_action( 'admin_print_styles-press-this.php' );
1320
+		do_action('admin_print_styles-press-this.php');
1321 1321
 
1322 1322
 		/** This action is documented in wp-admin/admin-header.php */
1323
-		do_action( 'admin_print_styles' );
1323
+		do_action('admin_print_styles');
1324 1324
 
1325 1325
 		/** This action is documented in wp-admin/admin-header.php */
1326
-		do_action( 'admin_print_scripts-press-this.php' );
1326
+		do_action('admin_print_scripts-press-this.php');
1327 1327
 
1328 1328
 		/** This action is documented in wp-admin/admin-header.php */
1329
-		do_action( 'admin_print_scripts' );
1329
+		do_action('admin_print_scripts');
1330 1330
 
1331 1331
 		/** This action is documented in wp-admin/admin-header.php */
1332
-		do_action( 'admin_head-press-this.php' );
1332
+		do_action('admin_head-press-this.php');
1333 1333
 
1334 1334
 		/** This action is documented in wp-admin/admin-header.php */
1335
-		do_action( 'admin_head' );
1335
+		do_action('admin_head');
1336 1336
 	?>
1337 1337
 </head>
1338 1338
 <?php
1339 1339
 
1340 1340
 	$admin_body_class  = 'press-this';
1341
-	$admin_body_class .= ( is_rtl() ) ? ' rtl' : '';
1342
-	$admin_body_class .= ' branch-' . str_replace( array( '.', ',' ), '-', floatval( $wp_version ) );
1343
-	$admin_body_class .= ' version-' . str_replace( '.', '-', preg_replace( '/^([.0-9]+).*/', '$1', $wp_version ) );
1344
-	$admin_body_class .= ' admin-color-' . sanitize_html_class( get_user_option( 'admin_color' ), 'fresh' );
1345
-	$admin_body_class .= ' locale-' . sanitize_html_class( strtolower( str_replace( '_', '-', get_locale() ) ) );
1341
+	$admin_body_class .= (is_rtl()) ? ' rtl' : '';
1342
+	$admin_body_class .= ' branch-'.str_replace(array('.', ','), '-', floatval($wp_version));
1343
+	$admin_body_class .= ' version-'.str_replace('.', '-', preg_replace('/^([.0-9]+).*/', '$1', $wp_version));
1344
+	$admin_body_class .= ' admin-color-'.sanitize_html_class(get_user_option('admin_color'), 'fresh');
1345
+	$admin_body_class .= ' locale-'.sanitize_html_class(strtolower(str_replace('_', '-', get_locale())));
1346 1346
 
1347 1347
 	/** This filter is documented in wp-admin/admin-header.php */
1348
-	$admin_body_classes = apply_filters( 'admin_body_class', '' );
1348
+	$admin_body_classes = apply_filters('admin_body_class', '');
1349 1349
 
1350 1350
 ?>
1351
-<body class="wp-admin wp-core-ui <?php echo $admin_body_classes . ' ' . $admin_body_class; ?>">
1351
+<body class="wp-admin wp-core-ui <?php echo $admin_body_classes.' '.$admin_body_class; ?>">
1352 1352
 	<div id="adminbar" class="adminbar">
1353 1353
 		<h1 id="current-site" class="current-site">
1354
-			<a class="current-site-link" href="<?php echo esc_url( home_url( '/' ) ); ?>" target="_blank" rel="home">
1354
+			<a class="current-site-link" href="<?php echo esc_url(home_url('/')); ?>" target="_blank" rel="home">
1355 1355
 				<span class="dashicons dashicons-wordpress"></span>
1356
-				<span class="current-site-name"><?php bloginfo( 'name' ); ?></span>
1356
+				<span class="current-site-name"><?php bloginfo('name'); ?></span>
1357 1357
 			</a>
1358 1358
 		</h1>
1359 1359
 		<button type="button" class="options button-link closed">
1360 1360
 			<span class="dashicons dashicons-tag on-closed"></span>
1361
-			<span class="screen-reader-text on-closed"><?php _e( 'Show post options' ); ?></span>
1362
-			<span aria-hidden="true" class="on-open"><?php _e( 'Done' ); ?></span>
1363
-			<span class="screen-reader-text on-open"><?php _e( 'Hide post options' ); ?></span>
1361
+			<span class="screen-reader-text on-closed"><?php _e('Show post options'); ?></span>
1362
+			<span aria-hidden="true" class="on-open"><?php _e('Done'); ?></span>
1363
+			<span class="screen-reader-text on-open"><?php _e('Hide post options'); ?></span>
1364 1364
 		</button>
1365 1365
 	</div>
1366 1366
 
1367 1367
 	<div id="scanbar" class="scan">
1368 1368
 		<form method="GET">
1369
-			<label for="url-scan" class="screen-reader-text"><?php _e( 'Scan site for content' ); ?></label>
1370
-			<input type="url" name="u" id="url-scan" class="scan-url" value="" placeholder="<?php esc_attr_e( 'Enter a URL to scan' ) ?>" />
1371
-			<input type="submit" name="url-scan-submit" id="url-scan-submit" class="scan-submit" value="<?php esc_attr_e( 'Scan' ) ?>" />
1369
+			<label for="url-scan" class="screen-reader-text"><?php _e('Scan site for content'); ?></label>
1370
+			<input type="url" name="u" id="url-scan" class="scan-url" value="" placeholder="<?php esc_attr_e('Enter a URL to scan') ?>" />
1371
+			<input type="submit" name="url-scan-submit" id="url-scan-submit" class="scan-submit" value="<?php esc_attr_e('Scan') ?>" />
1372 1372
 		</form>
1373 1373
 	</div>
1374 1374
 
@@ -1381,8 +1381,8 @@  discard block
 block discarded – undo
1381 1381
 		<input type="hidden" name="pt-force-redirect" id="pt-force-redirect" value="" />
1382 1382
 		<?php
1383 1383
 
1384
-		wp_nonce_field( 'update-post_' . $post_ID, '_wpnonce', false );
1385
-		wp_nonce_field( 'add-category', '_ajax_nonce-add-category', false );
1384
+		wp_nonce_field('update-post_'.$post_ID, '_wpnonce', false);
1385
+		wp_nonce_field('add-category', '_ajax_nonce-add-category', false);
1386 1386
 
1387 1387
 		?>
1388 1388
 
@@ -1391,10 +1391,10 @@  discard block
 block discarded – undo
1391 1391
 			<div class="alerts" role="alert" aria-live="assertive" aria-relevant="all" aria-atomic="true">
1392 1392
 				<?php
1393 1393
 
1394
-				if ( isset( $data['v'] ) && $this->version > $data['v'] ) {
1394
+				if (isset($data['v']) && $this->version > $data['v']) {
1395 1395
 					?>
1396 1396
 					<p class="alert is-notice">
1397
-						<?php printf( __( 'You should upgrade <a href="%s" target="_blank">your bookmarklet</a> to the latest version!' ), admin_url( 'tools.php' ) ); ?>
1397
+						<?php printf(__('You should upgrade <a href="%s" target="_blank">your bookmarklet</a> to the latest version!'), admin_url('tools.php')); ?>
1398 1398
 					</p>
1399 1399
 					<?php
1400 1400
 				}
@@ -1403,18 +1403,18 @@  discard block
 block discarded – undo
1403 1403
 			</div>
1404 1404
 
1405 1405
 			<div id="app-container" class="editor">
1406
-				<span id="title-container-label" class="post-title-placeholder" aria-hidden="true"><?php _e( 'Post title' ); ?></span>
1407
-				<h2 id="title-container" class="post-title" contenteditable="true" spellcheck="true" aria-label="<?php esc_attr_e( 'Post title' ); ?>" tabindex="0"><?php echo esc_html( $post_title ); ?></h2>
1406
+				<span id="title-container-label" class="post-title-placeholder" aria-hidden="true"><?php _e('Post title'); ?></span>
1407
+				<h2 id="title-container" class="post-title" contenteditable="true" spellcheck="true" aria-label="<?php esc_attr_e('Post title'); ?>" tabindex="0"><?php echo esc_html($post_title); ?></h2>
1408 1408
 
1409 1409
 				<div class="media-list-container">
1410 1410
 					<div class="media-list-inner-container">
1411
-						<h2 class="screen-reader-text"><?php _e( 'Suggested media' ); ?></h2>
1411
+						<h2 class="screen-reader-text"><?php _e('Suggested media'); ?></h2>
1412 1412
 						<ul class="media-list"></ul>
1413 1413
 					</div>
1414 1414
 				</div>
1415 1415
 
1416 1416
 				<?php
1417
-				wp_editor( $post_content, 'pressthis', array(
1417
+				wp_editor($post_content, 'pressthis', array(
1418 1418
 					'drag_drop_upload' => true,
1419 1419
 					'editor_height'    => 600,
1420 1420
 					'media_buttons'    => false,
@@ -1434,7 +1434,7 @@  discard block
 block discarded – undo
1434 1434
 					'quicktags' => array(
1435 1435
 						'buttons' => 'strong,em,link,block,del,ins,img,ul,ol,li,code,more',
1436 1436
 					),
1437
-				) );
1437
+				));
1438 1438
 
1439 1439
 				?>
1440 1440
 			</div>
@@ -1444,55 +1444,55 @@  discard block
 block discarded – undo
1444 1444
 		<div class="options-panel is-off-screen is-hidden" tabindex="-1">
1445 1445
 			<div class="post-options">
1446 1446
 
1447
-				<?php if ( $supports_formats ) : ?>
1447
+				<?php if ($supports_formats) : ?>
1448 1448
 					<button type="button" class="button-link post-option">
1449 1449
 						<span class="dashicons dashicons-admin-post"></span>
1450
-						<span class="post-option-title"><?php _ex( 'Format', 'post format' ); ?></span>
1451
-						<span class="post-option-contents" id="post-option-post-format"><?php echo esc_html( get_post_format_string( $post_format ) ); ?></span>
1450
+						<span class="post-option-title"><?php _ex('Format', 'post format'); ?></span>
1451
+						<span class="post-option-contents" id="post-option-post-format"><?php echo esc_html(get_post_format_string($post_format)); ?></span>
1452 1452
 						<span class="dashicons post-option-forward"></span>
1453 1453
 					</button>
1454 1454
 				<?php endif; ?>
1455 1455
 
1456 1456
 				<button type="button" class="button-link post-option">
1457 1457
 					<span class="dashicons dashicons-category"></span>
1458
-					<span class="post-option-title"><?php _e( 'Categories' ); ?></span>
1458
+					<span class="post-option-title"><?php _e('Categories'); ?></span>
1459 1459
 					<span class="dashicons post-option-forward"></span>
1460 1460
 				</button>
1461 1461
 
1462 1462
 				<button type="button" class="button-link post-option">
1463 1463
 					<span class="dashicons dashicons-tag"></span>
1464
-					<span class="post-option-title"><?php _e( 'Tags' ); ?></span>
1464
+					<span class="post-option-title"><?php _e('Tags'); ?></span>
1465 1465
 					<span class="dashicons post-option-forward"></span>
1466 1466
 				</button>
1467 1467
 			</div>
1468 1468
 
1469
-			<?php if ( $supports_formats ) : ?>
1469
+			<?php if ($supports_formats) : ?>
1470 1470
 				<div class="setting-modal is-off-screen is-hidden">
1471 1471
 					<button type="button" class="button-link modal-close">
1472 1472
 						<span class="dashicons post-option-back"></span>
1473
-						<span class="setting-title" aria-hidden="true"><?php _ex( 'Format', 'post format' ); ?></span>
1474
-						<span class="screen-reader-text"><?php _e( 'Back to post options' ) ?></span>
1473
+						<span class="setting-title" aria-hidden="true"><?php _ex('Format', 'post format'); ?></span>
1474
+						<span class="screen-reader-text"><?php _e('Back to post options') ?></span>
1475 1475
 					</button>
1476
-					<?php $this->post_formats_html( $post ); ?>
1476
+					<?php $this->post_formats_html($post); ?>
1477 1477
 				</div>
1478 1478
 			<?php endif; ?>
1479 1479
 
1480 1480
 			<div class="setting-modal is-off-screen is-hidden">
1481 1481
 				<button type="button" class="button-link modal-close">
1482 1482
 					<span class="dashicons post-option-back"></span>
1483
-					<span class="setting-title" aria-hidden="true"><?php _e( 'Categories' ); ?></span>
1484
-					<span class="screen-reader-text"><?php _e( 'Back to post options' ) ?></span>
1483
+					<span class="setting-title" aria-hidden="true"><?php _e('Categories'); ?></span>
1484
+					<span class="screen-reader-text"><?php _e('Back to post options') ?></span>
1485 1485
 				</button>
1486
-				<?php $this->categories_html( $post ); ?>
1486
+				<?php $this->categories_html($post); ?>
1487 1487
 			</div>
1488 1488
 
1489 1489
 			<div class="setting-modal tags is-off-screen is-hidden">
1490 1490
 				<button type="button" class="button-link modal-close">
1491 1491
 					<span class="dashicons post-option-back"></span>
1492
-					<span class="setting-title" aria-hidden="true"><?php _e( 'Tags' ); ?></span>
1493
-					<span class="screen-reader-text"><?php _e( 'Back to post options' ) ?></span>
1492
+					<span class="setting-title" aria-hidden="true"><?php _e('Tags'); ?></span>
1493
+					<span class="screen-reader-text"><?php _e('Back to post options') ?></span>
1494 1494
 				</button>
1495
-				<?php $this->tags_html( $post ); ?>
1495
+				<?php $this->tags_html($post); ?>
1496 1496
 			</div>
1497 1497
 		</div><!-- .options-panel -->
1498 1498
 	</div><!-- .wrapper -->
@@ -1501,7 +1501,7 @@  discard block
 block discarded – undo
1501 1501
 		<div class="pressthis-media-buttons">
1502 1502
 			<button type="button" class="insert-media button-link" data-editor="pressthis">
1503 1503
 				<span class="dashicons dashicons-admin-media"></span>
1504
-				<span class="screen-reader-text"><?php _e( 'Add Media' ); ?></span>
1504
+				<span class="screen-reader-text"><?php _e('Add Media'); ?></span>
1505 1505
 			</button>
1506 1506
 		</div>
1507 1507
 		<div class="post-actions">
@@ -1509,17 +1509,17 @@  discard block
 block discarded – undo
1509 1509
 			<div class="split-button">
1510 1510
 				<div class="split-button-head">
1511 1511
 					<button type="button" class="publish-button split-button-primary" aria-live="polite">
1512
-						<span class="publish"><?php echo ( current_user_can( 'publish_posts' ) ) ? __( 'Publish' ) : __( 'Submit for Review' ); ?></span>
1513
-						<span class="saving-draft"><?php _e( 'Saving&hellip;' ); ?></span>
1512
+						<span class="publish"><?php echo (current_user_can('publish_posts')) ? __('Publish') : __('Submit for Review'); ?></span>
1513
+						<span class="saving-draft"><?php _e('Saving&hellip;'); ?></span>
1514 1514
 					</button><button type="button" class="split-button-toggle" aria-haspopup="true" aria-expanded="false">
1515 1515
 						<i class="dashicons dashicons-arrow-down-alt2"></i>
1516 1516
 						<span class="screen-reader-text"><?php _e('More actions'); ?></span>
1517 1517
 					</button>
1518 1518
 				</div>
1519 1519
 				<ul class="split-button-body">
1520
-					<li><button type="button" class="button-link draft-button split-button-option"><?php _e( 'Save Draft' ); ?></button></li>
1521
-					<li><button type="button" class="button-link standard-editor-button split-button-option"><?php _e( 'Standard Editor' ); ?></button></li>
1522
-					<li><button type="button" class="button-link preview-button split-button-option"><?php _e( 'Preview' ); ?></button></li>
1520
+					<li><button type="button" class="button-link draft-button split-button-option"><?php _e('Save Draft'); ?></button></li>
1521
+					<li><button type="button" class="button-link standard-editor-button split-button-option"><?php _e('Standard Editor'); ?></button></li>
1522
+					<li><button type="button" class="button-link preview-button split-button-option"><?php _e('Preview'); ?></button></li>
1523 1523
 				</ul>
1524 1524
 			</div>
1525 1525
 		</div>
@@ -1528,13 +1528,13 @@  discard block
 block discarded – undo
1528 1528
 
1529 1529
 	<?php
1530 1530
 	/** This action is documented in wp-admin/admin-footer.php */
1531
-	do_action( 'admin_footer' );
1531
+	do_action('admin_footer');
1532 1532
 
1533 1533
 	/** This action is documented in wp-admin/admin-footer.php */
1534
-	do_action( 'admin_print_footer_scripts' );
1534
+	do_action('admin_print_footer_scripts');
1535 1535
 
1536 1536
 	/** This action is documented in wp-admin/admin-footer.php */
1537
-	do_action( 'admin_footer-press-this.php' );
1537
+	do_action('admin_footer-press-this.php');
1538 1538
 	?>
1539 1539
 </body>
1540 1540
 </html>
Please login to merge, or discard this patch.
src/wp-admin/includes/file.php 3 patches
Indentation   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -1,15 +1,15 @@
 block discarded – undo
1 1
 <?php
2 2
 /**
3
- * Filesystem API: Top-level functionality
4
- *
5
- * Functions for reading, writing, modifying, and deleting files on the file system.
6
- * Includes functionality for theme-specific files as well as operations for uploading,
7
- * archiving, and rendering output when necessary.
8
- *
9
- * @package WordPress
10
- * @subpackage Filesystem
11
- * @since 2.3.0
12
- */
3
+	 * Filesystem API: Top-level functionality
4
+	 *
5
+	 * Functions for reading, writing, modifying, and deleting files on the file system.
6
+	 * Includes functionality for theme-specific files as well as operations for uploading,
7
+	 * archiving, and rendering output when necessary.
8
+	 *
9
+	 * @package WordPress
10
+	 * @subpackage Filesystem
11
+	 * @since 2.3.0
12
+	 */
13 13
 
14 14
 /** The descriptions for theme files. */
15 15
 $wp_file_descriptions = array(
Please login to merge, or discard this patch.
Spacing   +366 added lines, -366 removed lines patch added patch discarded remove patch
@@ -13,48 +13,48 @@  discard block
 block discarded – undo
13 13
 
14 14
 /** The descriptions for theme files. */
15 15
 $wp_file_descriptions = array(
16
-	'functions.php'         => __( 'Theme Functions' ),
17
-	'header.php'            => __( 'Theme Header' ),
18
-	'footer.php'            => __( 'Theme Footer' ),
19
-	'sidebar.php'           => __( 'Sidebar' ),
20
-	'comments.php'          => __( 'Comments' ),
21
-	'searchform.php'        => __( 'Search Form' ),
22
-	'404.php'               => __( '404 Template' ),
23
-	'link.php'              => __( 'Links Template' ),
16
+	'functions.php'         => __('Theme Functions'),
17
+	'header.php'            => __('Theme Header'),
18
+	'footer.php'            => __('Theme Footer'),
19
+	'sidebar.php'           => __('Sidebar'),
20
+	'comments.php'          => __('Comments'),
21
+	'searchform.php'        => __('Search Form'),
22
+	'404.php'               => __('404 Template'),
23
+	'link.php'              => __('Links Template'),
24 24
 	// Archives
25
-	'index.php'             => __( 'Main Index Template' ),
26
-	'archive.php'           => __( 'Archives' ),
27
-	'author.php'            => __( 'Author Template' ),
28
-	'taxonomy.php'          => __( 'Taxonomy Template' ),
29
-	'category.php'          => __( 'Category Template' ),
30
-	'tag.php'               => __( 'Tag Template' ),
31
-	'home.php'              => __( 'Posts Page' ),
32
-	'search.php'            => __( 'Search Results' ),
33
-	'date.php'              => __( 'Date Template' ),
25
+	'index.php'             => __('Main Index Template'),
26
+	'archive.php'           => __('Archives'),
27
+	'author.php'            => __('Author Template'),
28
+	'taxonomy.php'          => __('Taxonomy Template'),
29
+	'category.php'          => __('Category Template'),
30
+	'tag.php'               => __('Tag Template'),
31
+	'home.php'              => __('Posts Page'),
32
+	'search.php'            => __('Search Results'),
33
+	'date.php'              => __('Date Template'),
34 34
 	// Content
35
-	'singular.php'          => __( 'Singular Template' ),
36
-	'single.php'            => __( 'Single Post' ),
37
-	'page.php'              => __( 'Single Page' ),
38
-	'front-page.php'        => __( 'Static Front Page' ),
35
+	'singular.php'          => __('Singular Template'),
36
+	'single.php'            => __('Single Post'),
37
+	'page.php'              => __('Single Page'),
38
+	'front-page.php'        => __('Static Front Page'),
39 39
 	// Attachments
40
-	'attachment.php'        => __( 'Attachment Template' ),
41
-	'image.php'             => __( 'Image Attachment Template' ),
42
-	'video.php'             => __( 'Video Attachment Template' ),
43
-	'audio.php'             => __( 'Audio Attachment Template' ),
44
-	'application.php'       => __( 'Application Attachment Template' ),
40
+	'attachment.php'        => __('Attachment Template'),
41
+	'image.php'             => __('Image Attachment Template'),
42
+	'video.php'             => __('Video Attachment Template'),
43
+	'audio.php'             => __('Audio Attachment Template'),
44
+	'application.php'       => __('Application Attachment Template'),
45 45
 	// Stylesheets
46
-	'style.css'             => __( 'Stylesheet' ),
47
-	'editor-style.css'      => __( 'Visual Editor Stylesheet' ),
48
-	'editor-style-rtl.css'  => __( 'Visual Editor RTL Stylesheet' ),
49
-	'rtl.css'               => __( 'RTL Stylesheet' ),
46
+	'style.css'             => __('Stylesheet'),
47
+	'editor-style.css'      => __('Visual Editor Stylesheet'),
48
+	'editor-style-rtl.css'  => __('Visual Editor RTL Stylesheet'),
49
+	'rtl.css'               => __('RTL Stylesheet'),
50 50
 	// Other
51
-	'my-hacks.php'          => __( 'my-hacks.php (legacy hacks support)' ),
52
-	'.htaccess'             => __( '.htaccess (for rewrite rules )' ),
51
+	'my-hacks.php'          => __('my-hacks.php (legacy hacks support)'),
52
+	'.htaccess'             => __('.htaccess (for rewrite rules )'),
53 53
 	// Deprecated files
54
-	'wp-layout.css'         => __( 'Stylesheet' ),
55
-	'wp-comments.php'       => __( 'Comments Template' ),
56
-	'wp-comments-popup.php' => __( 'Popup Comments Template' ),
57
-	'comments-popup.php'    => __( 'Popup Comments' ),
54
+	'wp-layout.css'         => __('Stylesheet'),
55
+	'wp-comments.php'       => __('Comments Template'),
56
+	'wp-comments-popup.php' => __('Popup Comments Template'),
57
+	'comments-popup.php'    => __('Popup Comments'),
58 58
 );
59 59
 
60 60
 /**
@@ -68,21 +68,21 @@  discard block
 block discarded – undo
68 68
  * @return string Description of file from $wp_file_descriptions or basename of $file if description doesn't exist.
69 69
  *                Appends 'Page Template' to basename of $file if the file is a page template
70 70
  */
71
-function get_file_description( $file ) {
71
+function get_file_description($file) {
72 72
 	global $wp_file_descriptions, $allowed_files;
73 73
 
74
-	$relative_pathinfo = pathinfo( $file );
75
-	$file_path = $allowed_files[ $file ];
76
-	if ( isset( $wp_file_descriptions[ basename( $file ) ] ) && '.' === $relative_pathinfo['dirname'] ) {
77
-		return $wp_file_descriptions[ basename( $file ) ];
78
-	} elseif ( file_exists( $file_path ) && is_file( $file_path ) ) {
79
-		$template_data = implode( '', file( $file_path ) );
80
-		if ( preg_match( '|Template Name:(.*)$|mi', $template_data, $name ) ) {
81
-			return sprintf( __( '%s Page Template' ), _cleanup_header_comment( $name[1] ) );
74
+	$relative_pathinfo = pathinfo($file);
75
+	$file_path = $allowed_files[$file];
76
+	if (isset($wp_file_descriptions[basename($file)]) && '.' === $relative_pathinfo['dirname']) {
77
+		return $wp_file_descriptions[basename($file)];
78
+	} elseif (file_exists($file_path) && is_file($file_path)) {
79
+		$template_data = implode('', file($file_path));
80
+		if (preg_match('|Template Name:(.*)$|mi', $template_data, $name)) {
81
+			return sprintf(__('%s Page Template'), _cleanup_header_comment($name[1]));
82 82
 		}
83 83
 	}
84 84
 
85
-	return trim( basename( $file ) );
85
+	return trim(basename($file));
86 86
 }
87 87
 
88 88
 /**
@@ -93,18 +93,18 @@  discard block
 block discarded – undo
93 93
  * @return string Full filesystem path to the root of the WordPress installation
94 94
  */
95 95
 function get_home_path() {
96
-	$home    = set_url_scheme( get_option( 'home' ), 'http' );
97
-	$siteurl = set_url_scheme( get_option( 'siteurl' ), 'http' );
98
-	if ( ! empty( $home ) && 0 !== strcasecmp( $home, $siteurl ) ) {
99
-		$wp_path_rel_to_home = str_ireplace( $home, '', $siteurl ); /* $siteurl - $home */
100
-		$pos = strripos( str_replace( '\\', '/', $_SERVER['SCRIPT_FILENAME'] ), trailingslashit( $wp_path_rel_to_home ) );
101
-		$home_path = substr( $_SERVER['SCRIPT_FILENAME'], 0, $pos );
102
-		$home_path = trailingslashit( $home_path );
96
+	$home    = set_url_scheme(get_option('home'), 'http');
97
+	$siteurl = set_url_scheme(get_option('siteurl'), 'http');
98
+	if ( ! empty($home) && 0 !== strcasecmp($home, $siteurl)) {
99
+		$wp_path_rel_to_home = str_ireplace($home, '', $siteurl); /* $siteurl - $home */
100
+		$pos = strripos(str_replace('\\', '/', $_SERVER['SCRIPT_FILENAME']), trailingslashit($wp_path_rel_to_home));
101
+		$home_path = substr($_SERVER['SCRIPT_FILENAME'], 0, $pos);
102
+		$home_path = trailingslashit($home_path);
103 103
 	} else {
104 104
 		$home_path = ABSPATH;
105 105
 	}
106 106
 
107
-	return str_replace( '\\', '/', $home_path );
107
+	return str_replace('\\', '/', $home_path);
108 108
 }
109 109
 
110 110
 /**
@@ -117,30 +117,30 @@  discard block
 block discarded – undo
117 117
  * @param int    $levels Optional. Levels of folders to follow, Default 100 (PHP Loop limit).
118 118
  * @return bool|array False on failure, Else array of files
119 119
  */
120
-function list_files( $folder = '', $levels = 100 ) {
121
-	if ( empty($folder) )
120
+function list_files($folder = '', $levels = 100) {
121
+	if (empty($folder))
122 122
 		return false;
123 123
 
124
-	if ( ! $levels )
124
+	if ( ! $levels)
125 125
 		return false;
126 126
 
127 127
 	$files = array();
128
-	if ( $dir = @opendir( $folder ) ) {
129
-		while (($file = readdir( $dir ) ) !== false ) {
130
-			if ( in_array($file, array('.', '..') ) )
128
+	if ($dir = @opendir($folder)) {
129
+		while (($file = readdir($dir)) !== false) {
130
+			if (in_array($file, array('.', '..')))
131 131
 				continue;
132
-			if ( is_dir( $folder . '/' . $file ) ) {
133
-				$files2 = list_files( $folder . '/' . $file, $levels - 1);
134
-				if ( $files2 )
135
-					$files = array_merge($files, $files2 );
132
+			if (is_dir($folder.'/'.$file)) {
133
+				$files2 = list_files($folder.'/'.$file, $levels - 1);
134
+				if ($files2)
135
+					$files = array_merge($files, $files2);
136 136
 				else
137
-					$files[] = $folder . '/' . $file . '/';
137
+					$files[] = $folder.'/'.$file.'/';
138 138
 			} else {
139
-				$files[] = $folder . '/' . $file;
139
+				$files[] = $folder.'/'.$file;
140 140
 			}
141 141
 		}
142 142
 	}
143
-	@closedir( $dir );
143
+	@closedir($dir);
144 144
 	return $files;
145 145
 }
146 146
 
@@ -157,35 +157,35 @@  discard block
 block discarded – undo
157 157
  * @param string $dir      Optional. Directory to store the file in. Default empty.
158 158
  * @return string a writable filename
159 159
  */
160
-function wp_tempnam( $filename = '', $dir = '' ) {
161
-	if ( empty( $dir ) ) {
160
+function wp_tempnam($filename = '', $dir = '') {
161
+	if (empty($dir)) {
162 162
 		$dir = get_temp_dir();
163 163
 	}
164 164
 
165
-	if ( empty( $filename ) || '.' == $filename || '/' == $filename ) {
165
+	if (empty($filename) || '.' == $filename || '/' == $filename) {
166 166
 		$filename = time();
167 167
 	}
168 168
 
169 169
 	// Use the basename of the given file without the extension as the name for the temporary directory
170
-	$temp_filename = basename( $filename );
171
-	$temp_filename = preg_replace( '|\.[^.]*$|', '', $temp_filename );
170
+	$temp_filename = basename($filename);
171
+	$temp_filename = preg_replace('|\.[^.]*$|', '', $temp_filename);
172 172
 
173 173
 	// If the folder is falsey, use its parent directory name instead.
174
-	if ( ! $temp_filename ) {
175
-		return wp_tempnam( dirname( $filename ), $dir );
174
+	if ( ! $temp_filename) {
175
+		return wp_tempnam(dirname($filename), $dir);
176 176
 	}
177 177
 
178 178
 	// Suffix some random data to avoid filename conflicts
179
-	$temp_filename .= '-' . wp_generate_password( 6, false );
179
+	$temp_filename .= '-'.wp_generate_password(6, false);
180 180
 	$temp_filename .= '.tmp';
181
-	$temp_filename = $dir . wp_unique_filename( $dir, $temp_filename );
181
+	$temp_filename = $dir.wp_unique_filename($dir, $temp_filename);
182 182
 
183
-	$fp = @fopen( $temp_filename, 'x' );
184
-	if ( ! $fp && is_writable( $dir ) && file_exists( $temp_filename ) ) {
185
-		return wp_tempnam( $filename, $dir );
183
+	$fp = @fopen($temp_filename, 'x');
184
+	if ( ! $fp && is_writable($dir) && file_exists($temp_filename)) {
185
+		return wp_tempnam($filename, $dir);
186 186
 	}
187
-	if ( $fp ) {
188
-		fclose( $fp );
187
+	if ($fp) {
188
+		fclose($fp);
189 189
 	}
190 190
 
191 191
 	return $temp_filename;
@@ -202,21 +202,21 @@  discard block
 block discarded – undo
202 202
  * @param array $allowed_files Array of allowed files to edit, $file must match an entry exactly
203 203
  * @return string|null
204 204
  */
205
-function validate_file_to_edit( $file, $allowed_files = '' ) {
206
-	$code = validate_file( $file, $allowed_files );
205
+function validate_file_to_edit($file, $allowed_files = '') {
206
+	$code = validate_file($file, $allowed_files);
207 207
 
208
-	if (!$code )
208
+	if ( ! $code)
209 209
 		return $file;
210 210
 
211
-	switch ( $code ) {
211
+	switch ($code) {
212 212
 		case 1 :
213
-			wp_die( __( 'Sorry, that file cannot be edited.' ) );
213
+			wp_die(__('Sorry, that file cannot be edited.'));
214 214
 
215 215
 		// case 2 :
216 216
 		// wp_die( __('Sorry, can&#8217;t call files with their real path.' ));
217 217
 
218 218
 		case 3 :
219
-			wp_die( __( 'Sorry, that file cannot be edited.' ) );
219
+			wp_die(__('Sorry, that file cannot be edited.'));
220 220
 	}
221 221
 }
222 222
 
@@ -236,11 +236,11 @@  discard block
 block discarded – undo
236 236
  * @return array On success, returns an associative array of file attributes. On failure, returns
237 237
  *               $overrides['upload_error_handler'](&$file, $message ) or array( 'error'=>$message ).
238 238
  */
239
-function _wp_handle_upload( &$file, $overrides, $time, $action ) {
239
+function _wp_handle_upload(&$file, $overrides, $time, $action) {
240 240
 	// The default error handler.
241
-	if ( ! function_exists( 'wp_handle_upload_error' ) ) {
242
-		function wp_handle_upload_error( &$file, $message ) {
243
-			return array( 'error' => $message );
241
+	if ( ! function_exists('wp_handle_upload_error')) {
242
+		function wp_handle_upload_error(&$file, $message) {
243
+			return array('error' => $message);
244 244
 		}
245 245
 	}
246 246
 
@@ -254,24 +254,24 @@  discard block
 block discarded – undo
254 254
 	 *
255 255
 	 * @param array $file An array of data for a single file.
256 256
 	 */
257
-	$file = apply_filters( "{$action}_prefilter", $file );
257
+	$file = apply_filters("{$action}_prefilter", $file);
258 258
 
259 259
 	// You may define your own function and pass the name in $overrides['upload_error_handler']
260 260
 	$upload_error_handler = 'wp_handle_upload_error';
261
-	if ( isset( $overrides['upload_error_handler'] ) ) {
261
+	if (isset($overrides['upload_error_handler'])) {
262 262
 		$upload_error_handler = $overrides['upload_error_handler'];
263 263
 	}
264 264
 
265 265
 	// You may have had one or more 'wp_handle_upload_prefilter' functions error out the file. Handle that gracefully.
266
-	if ( isset( $file['error'] ) && ! is_numeric( $file['error'] ) && $file['error'] ) {
267
-		return $upload_error_handler( $file, $file['error'] );
266
+	if (isset($file['error']) && ! is_numeric($file['error']) && $file['error']) {
267
+		return $upload_error_handler($file, $file['error']);
268 268
 	}
269 269
 
270 270
 	// Install user overrides. Did we mention that this voids your warranty?
271 271
 
272 272
 	// You may define your own function and pass the name in $overrides['unique_filename_callback']
273 273
 	$unique_filename_callback = null;
274
-	if ( isset( $overrides['unique_filename_callback'] ) ) {
274
+	if (isset($overrides['unique_filename_callback'])) {
275 275
 		$unique_filename_callback = $overrides['unique_filename_callback'];
276 276
 	}
277 277
 
@@ -279,72 +279,72 @@  discard block
 block discarded – undo
279 279
 	 * This may not have orignially been intended to be overrideable,
280 280
 	 * but historically has been.
281 281
 	 */
282
-	if ( isset( $overrides['upload_error_strings'] ) ) {
282
+	if (isset($overrides['upload_error_strings'])) {
283 283
 		$upload_error_strings = $overrides['upload_error_strings'];
284 284
 	} else {
285 285
 		// Courtesy of php.net, the strings that describe the error indicated in $_FILES[{form field}]['error'].
286 286
 		$upload_error_strings = array(
287 287
 			false,
288
-			__( 'The uploaded file exceeds the upload_max_filesize directive in php.ini.' ),
289
-			__( 'The uploaded file exceeds the MAX_FILE_SIZE directive that was specified in the HTML form.' ),
290
-			__( 'The uploaded file was only partially uploaded.' ),
291
-			__( 'No file was uploaded.' ),
288
+			__('The uploaded file exceeds the upload_max_filesize directive in php.ini.'),
289
+			__('The uploaded file exceeds the MAX_FILE_SIZE directive that was specified in the HTML form.'),
290
+			__('The uploaded file was only partially uploaded.'),
291
+			__('No file was uploaded.'),
292 292
 			'',
293
-			__( 'Missing a temporary folder.' ),
294
-			__( 'Failed to write file to disk.' ),
295
-			__( 'File upload stopped by extension.' )
293
+			__('Missing a temporary folder.'),
294
+			__('Failed to write file to disk.'),
295
+			__('File upload stopped by extension.')
296 296
 		);
297 297
 	}
298 298
 
299 299
 	// All tests are on by default. Most can be turned off by $overrides[{test_name}] = false;
300
-	$test_form = isset( $overrides['test_form'] ) ? $overrides['test_form'] : true;
301
-	$test_size = isset( $overrides['test_size'] ) ? $overrides['test_size'] : true;
300
+	$test_form = isset($overrides['test_form']) ? $overrides['test_form'] : true;
301
+	$test_size = isset($overrides['test_size']) ? $overrides['test_size'] : true;
302 302
 
303 303
 	// If you override this, you must provide $ext and $type!!
304
-	$test_type = isset( $overrides['test_type'] ) ? $overrides['test_type'] : true;
305
-	$mimes = isset( $overrides['mimes'] ) ? $overrides['mimes'] : false;
304
+	$test_type = isset($overrides['test_type']) ? $overrides['test_type'] : true;
305
+	$mimes = isset($overrides['mimes']) ? $overrides['mimes'] : false;
306 306
 
307 307
 	// A correct form post will pass this test.
308
-	if ( $test_form && ( ! isset( $_POST['action'] ) || ( $_POST['action'] != $action ) ) ) {
309
-		return call_user_func( $upload_error_handler, $file, __( 'Invalid form submission.' ) );
308
+	if ($test_form && ( ! isset($_POST['action']) || ($_POST['action'] != $action))) {
309
+		return call_user_func($upload_error_handler, $file, __('Invalid form submission.'));
310 310
 	}
311 311
 	// A successful upload will pass this test. It makes no sense to override this one.
312
-	if ( isset( $file['error'] ) && $file['error'] > 0 ) {
313
-		return call_user_func( $upload_error_handler, $file, $upload_error_strings[ $file['error'] ] );
312
+	if (isset($file['error']) && $file['error'] > 0) {
313
+		return call_user_func($upload_error_handler, $file, $upload_error_strings[$file['error']]);
314 314
 	}
315 315
 
316
-	$test_file_size = 'wp_handle_upload' === $action ? $file['size'] : filesize( $file['tmp_name'] );
316
+	$test_file_size = 'wp_handle_upload' === $action ? $file['size'] : filesize($file['tmp_name']);
317 317
 	// A non-empty file will pass this test.
318
-	if ( $test_size && ! ( $test_file_size > 0 ) ) {
319
-		if ( is_multisite() ) {
320
-			$error_msg = __( 'File is empty. Please upload something more substantial.' );
318
+	if ($test_size && ! ($test_file_size > 0)) {
319
+		if (is_multisite()) {
320
+			$error_msg = __('File is empty. Please upload something more substantial.');
321 321
 		} else {
322
-			$error_msg = __( 'File is empty. Please upload something more substantial. This error could also be caused by uploads being disabled in your php.ini or by post_max_size being defined as smaller than upload_max_filesize in php.ini.' );
322
+			$error_msg = __('File is empty. Please upload something more substantial. This error could also be caused by uploads being disabled in your php.ini or by post_max_size being defined as smaller than upload_max_filesize in php.ini.');
323 323
 		}
324
-		return call_user_func( $upload_error_handler, $file, $error_msg );
324
+		return call_user_func($upload_error_handler, $file, $error_msg);
325 325
 	}
326 326
 
327 327
 	// A properly uploaded file will pass this test. There should be no reason to override this one.
328
-	$test_uploaded_file = 'wp_handle_upload' === $action ? @ is_uploaded_file( $file['tmp_name'] ) : @ is_file( $file['tmp_name'] );
329
-	if ( ! $test_uploaded_file ) {
330
-		return call_user_func( $upload_error_handler, $file, __( 'Specified file failed upload test.' ) );
328
+	$test_uploaded_file = 'wp_handle_upload' === $action ? @ is_uploaded_file($file['tmp_name']) : @ is_file($file['tmp_name']);
329
+	if ( ! $test_uploaded_file) {
330
+		return call_user_func($upload_error_handler, $file, __('Specified file failed upload test.'));
331 331
 	}
332 332
 
333 333
 	// A correct MIME type will pass this test. Override $mimes or use the upload_mimes filter.
334
-	if ( $test_type ) {
335
-		$wp_filetype = wp_check_filetype_and_ext( $file['tmp_name'], $file['name'], $mimes );
336
-		$ext = empty( $wp_filetype['ext'] ) ? '' : $wp_filetype['ext'];
337
-		$type = empty( $wp_filetype['type'] ) ? '' : $wp_filetype['type'];
338
-		$proper_filename = empty( $wp_filetype['proper_filename'] ) ? '' : $wp_filetype['proper_filename'];
334
+	if ($test_type) {
335
+		$wp_filetype = wp_check_filetype_and_ext($file['tmp_name'], $file['name'], $mimes);
336
+		$ext = empty($wp_filetype['ext']) ? '' : $wp_filetype['ext'];
337
+		$type = empty($wp_filetype['type']) ? '' : $wp_filetype['type'];
338
+		$proper_filename = empty($wp_filetype['proper_filename']) ? '' : $wp_filetype['proper_filename'];
339 339
 
340 340
 		// Check to see if wp_check_filetype_and_ext() determined the filename was incorrect
341
-		if ( $proper_filename ) {
341
+		if ($proper_filename) {
342 342
 			$file['name'] = $proper_filename;
343 343
 		}
344
-		if ( ( ! $type || !$ext ) && ! current_user_can( 'unfiltered_upload' ) ) {
345
-			return call_user_func( $upload_error_handler, $file, __( 'Sorry, this file type is not permitted for security reasons.' ) );
344
+		if (( ! $type || ! $ext) && ! current_user_can('unfiltered_upload')) {
345
+			return call_user_func($upload_error_handler, $file, __('Sorry, this file type is not permitted for security reasons.'));
346 346
 		}
347
-		if ( ! $type ) {
347
+		if ( ! $type) {
348 348
 			$type = $file['type'];
349 349
 		}
350 350
 	} else {
@@ -355,41 +355,41 @@  discard block
 block discarded – undo
355 355
 	 * A writable uploads dir will pass this test. Again, there's no point
356 356
 	 * overriding this one.
357 357
 	 */
358
-	if ( ! ( ( $uploads = wp_upload_dir( $time ) ) && false === $uploads['error'] ) ) {
359
-		return call_user_func( $upload_error_handler, $file, $uploads['error'] );
358
+	if ( ! (($uploads = wp_upload_dir($time)) && false === $uploads['error'])) {
359
+		return call_user_func($upload_error_handler, $file, $uploads['error']);
360 360
 	}
361 361
 
362
-	$filename = wp_unique_filename( $uploads['path'], $file['name'], $unique_filename_callback );
362
+	$filename = wp_unique_filename($uploads['path'], $file['name'], $unique_filename_callback);
363 363
 
364 364
 	// Move the file to the uploads dir.
365
-	$new_file = $uploads['path'] . "/$filename";
366
-	if ( 'wp_handle_upload' === $action ) {
367
-		$move_new_file = @ move_uploaded_file( $file['tmp_name'], $new_file );
365
+	$new_file = $uploads['path']."/$filename";
366
+	if ('wp_handle_upload' === $action) {
367
+		$move_new_file = @ move_uploaded_file($file['tmp_name'], $new_file);
368 368
 	} else {
369 369
 		// use copy and unlink because rename breaks streams.
370
-		$move_new_file = @ copy( $file['tmp_name'], $new_file );
371
-		unlink( $file['tmp_name'] );
370
+		$move_new_file = @ copy($file['tmp_name'], $new_file);
371
+		unlink($file['tmp_name']);
372 372
 	}
373 373
 
374
-	if ( false === $move_new_file ) {
375
-		if ( 0 === strpos( $uploads['basedir'], ABSPATH ) ) {
376
-			$error_path = str_replace( ABSPATH, '', $uploads['basedir'] ) . $uploads['subdir'];
374
+	if (false === $move_new_file) {
375
+		if (0 === strpos($uploads['basedir'], ABSPATH)) {
376
+			$error_path = str_replace(ABSPATH, '', $uploads['basedir']).$uploads['subdir'];
377 377
 		} else {
378
-			$error_path = basename( $uploads['basedir'] ) . $uploads['subdir'];
378
+			$error_path = basename($uploads['basedir']).$uploads['subdir'];
379 379
 		}
380
-		return $upload_error_handler( $file, sprintf( __('The uploaded file could not be moved to %s.' ), $error_path ) );
380
+		return $upload_error_handler($file, sprintf(__('The uploaded file could not be moved to %s.'), $error_path));
381 381
 	}
382 382
 
383 383
 	// Set correct file permissions.
384
-	$stat = stat( dirname( $new_file ));
384
+	$stat = stat(dirname($new_file));
385 385
 	$perms = $stat['mode'] & 0000666;
386
-	@ chmod( $new_file, $perms );
386
+	@ chmod($new_file, $perms);
387 387
 
388 388
 	// Compute the URL.
389
-	$url = $uploads['url'] . "/$filename";
389
+	$url = $uploads['url']."/$filename";
390 390
 
391
-	if ( is_multisite() ) {
392
-		delete_transient( 'dirsize_cache' );
391
+	if (is_multisite()) {
392
+		delete_transient('dirsize_cache');
393 393
 	}
394 394
 
395 395
 	/**
@@ -406,11 +406,11 @@  discard block
 block discarded – undo
406 406
 	 * }
407 407
 	 * @param string $context The type of upload action. Values include 'upload' or 'sideload'.
408 408
 	 */
409
-	return apply_filters( 'wp_handle_upload', array(
409
+	return apply_filters('wp_handle_upload', array(
410 410
 		'file' => $new_file,
411 411
 		'url'  => $url,
412 412
 		'type' => $type
413
-	), 'wp_handle_sideload' === $action ? 'sideload' : 'upload' );
413
+	), 'wp_handle_sideload' === $action ? 'sideload' : 'upload');
414 414
 }
415 415
 
416 416
 /**
@@ -428,17 +428,17 @@  discard block
 block discarded – undo
428 428
  * @return array On success, returns an associative array of file attributes. On failure, returns
429 429
  *               $overrides['upload_error_handler'](&$file, $message ) or array( 'error'=>$message ).
430 430
  */
431
-function wp_handle_upload( &$file, $overrides = false, $time = null ) {
431
+function wp_handle_upload(&$file, $overrides = false, $time = null) {
432 432
 	/*
433 433
 	 *  $_POST['action'] must be set and its value must equal $overrides['action']
434 434
 	 *  or this:
435 435
 	 */
436 436
 	$action = 'wp_handle_upload';
437
-	if ( isset( $overrides['action'] ) ) {
437
+	if (isset($overrides['action'])) {
438 438
 		$action = $overrides['action'];
439 439
 	}
440 440
 
441
-	return _wp_handle_upload( $file, $overrides, $time, $action );
441
+	return _wp_handle_upload($file, $overrides, $time, $action);
442 442
 }
443 443
 
444 444
 /**
@@ -455,16 +455,16 @@  discard block
 block discarded – undo
455 455
  * @return array On success, returns an associative array of file attributes. On failure, returns
456 456
  *               $overrides['upload_error_handler'](&$file, $message ) or array( 'error'=>$message ).
457 457
  */
458
-function wp_handle_sideload( &$file, $overrides = false, $time = null ) {
458
+function wp_handle_sideload(&$file, $overrides = false, $time = null) {
459 459
 	/*
460 460
 	 *  $_POST['action'] must be set and its value must equal $overrides['action']
461 461
 	 *  or this:
462 462
 	 */
463 463
 	$action = 'wp_handle_sideload';
464
-	if ( isset( $overrides['action'] ) ) {
464
+	if (isset($overrides['action'])) {
465 465
 		$action = $overrides['action'];
466 466
 	}
467
-	return _wp_handle_upload( $file, $overrides, $time, $action );
467
+	return _wp_handle_upload($file, $overrides, $time, $action);
468 468
 }
469 469
 
470 470
 
@@ -478,32 +478,32 @@  discard block
 block discarded – undo
478 478
  * @param int $timeout The timeout for the request to download the file default 300 seconds
479 479
  * @return mixed WP_Error on failure, string Filename on success.
480 480
  */
481
-function download_url( $url, $timeout = 300 ) {
481
+function download_url($url, $timeout = 300) {
482 482
 	//WARNING: The file is not automatically deleted, The script must unlink() the file.
483
-	if ( ! $url )
483
+	if ( ! $url)
484 484
 		return new WP_Error('http_no_url', __('Invalid URL Provided.'));
485 485
 
486 486
 	$tmpfname = wp_tempnam($url);
487
-	if ( ! $tmpfname )
487
+	if ( ! $tmpfname)
488 488
 		return new WP_Error('http_no_file', __('Could not create Temporary file.'));
489 489
 
490
-	$response = wp_safe_remote_get( $url, array( 'timeout' => $timeout, 'stream' => true, 'filename' => $tmpfname ) );
490
+	$response = wp_safe_remote_get($url, array('timeout' => $timeout, 'stream' => true, 'filename' => $tmpfname));
491 491
 
492
-	if ( is_wp_error( $response ) ) {
493
-		unlink( $tmpfname );
492
+	if (is_wp_error($response)) {
493
+		unlink($tmpfname);
494 494
 		return $response;
495 495
 	}
496 496
 
497
-	if ( 200 != wp_remote_retrieve_response_code( $response ) ){
498
-		unlink( $tmpfname );
499
-		return new WP_Error( 'http_404', trim( wp_remote_retrieve_response_message( $response ) ) );
497
+	if (200 != wp_remote_retrieve_response_code($response)) {
498
+		unlink($tmpfname);
499
+		return new WP_Error('http_404', trim(wp_remote_retrieve_response_message($response)));
500 500
 	}
501 501
 
502
-	$content_md5 = wp_remote_retrieve_header( $response, 'content-md5' );
503
-	if ( $content_md5 ) {
504
-		$md5_check = verify_file_md5( $tmpfname, $content_md5 );
505
-		if ( is_wp_error( $md5_check ) ) {
506
-			unlink( $tmpfname );
502
+	$content_md5 = wp_remote_retrieve_header($response, 'content-md5');
503
+	if ($content_md5) {
504
+		$md5_check = verify_file_md5($tmpfname, $content_md5);
505
+		if (is_wp_error($md5_check)) {
506
+			unlink($tmpfname);
507 507
 			return $md5_check;
508 508
 		}
509 509
 	}
@@ -520,20 +520,20 @@  discard block
 block discarded – undo
520 520
  * @param string $expected_md5 The expected MD5 of the file, either a base64 encoded raw md5, or a hex-encoded md5
521 521
  * @return bool|object WP_Error on failure, true on success, false when the MD5 format is unknown/unexpected
522 522
  */
523
-function verify_file_md5( $filename, $expected_md5 ) {
524
-	if ( 32 == strlen( $expected_md5 ) )
525
-		$expected_raw_md5 = pack( 'H*', $expected_md5 );
526
-	elseif ( 24 == strlen( $expected_md5 ) )
527
-		$expected_raw_md5 = base64_decode( $expected_md5 );
523
+function verify_file_md5($filename, $expected_md5) {
524
+	if (32 == strlen($expected_md5))
525
+		$expected_raw_md5 = pack('H*', $expected_md5);
526
+	elseif (24 == strlen($expected_md5))
527
+		$expected_raw_md5 = base64_decode($expected_md5);
528 528
 	else
529 529
 		return false; // unknown format
530 530
 
531
-	$file_md5 = md5_file( $filename, true );
531
+	$file_md5 = md5_file($filename, true);
532 532
 
533
-	if ( $file_md5 === $expected_raw_md5 )
533
+	if ($file_md5 === $expected_raw_md5)
534 534
 		return true;
535 535
 
536
-	return new WP_Error( 'md5_mismatch', sprintf( __( 'The checksum of the file (%1$s) does not match the expected checksum value (%2$s).' ), bin2hex( $file_md5 ), bin2hex( $expected_raw_md5 ) ) );
536
+	return new WP_Error('md5_mismatch', sprintf(__('The checksum of the file (%1$s) does not match the expected checksum value (%2$s).'), bin2hex($file_md5), bin2hex($expected_raw_md5)));
537 537
 }
538 538
 
539 539
 /**
@@ -554,28 +554,28 @@  discard block
 block discarded – undo
554 554
 function unzip_file($file, $to) {
555 555
 	global $wp_filesystem;
556 556
 
557
-	if ( ! $wp_filesystem || !is_object($wp_filesystem) )
557
+	if ( ! $wp_filesystem || ! is_object($wp_filesystem))
558 558
 		return new WP_Error('fs_unavailable', __('Could not access filesystem.'));
559 559
 
560 560
 	// Unzip can use a lot of memory, but not this much hopefully
561 561
 	/** This filter is documented in wp-admin/admin.php */
562
-	@ini_set( 'memory_limit', apply_filters( 'admin_memory_limit', WP_MAX_MEMORY_LIMIT ) );
562
+	@ini_set('memory_limit', apply_filters('admin_memory_limit', WP_MAX_MEMORY_LIMIT));
563 563
 
564 564
 	$needed_dirs = array();
565 565
 	$to = trailingslashit($to);
566 566
 
567 567
 	// Determine any parent dir's needed (of the upgrade directory)
568
-	if ( ! $wp_filesystem->is_dir($to) ) { //Only do parents if no children exist
568
+	if ( ! $wp_filesystem->is_dir($to)) { //Only do parents if no children exist
569 569
 		$path = preg_split('![/\\\]!', untrailingslashit($to));
570
-		for ( $i = count($path); $i >= 0; $i-- ) {
571
-			if ( empty($path[$i]) )
570
+		for ($i = count($path); $i >= 0; $i--) {
571
+			if (empty($path[$i]))
572 572
 				continue;
573 573
 
574
-			$dir = implode('/', array_slice($path, 0, $i+1) );
575
-			if ( preg_match('!^[a-z]:$!i', $dir) ) // Skip it if it looks like a Windows Drive letter.
574
+			$dir = implode('/', array_slice($path, 0, $i + 1));
575
+			if (preg_match('!^[a-z]:$!i', $dir)) // Skip it if it looks like a Windows Drive letter.
576 576
 				continue;
577 577
 
578
-			if ( ! $wp_filesystem->is_dir($dir) )
578
+			if ( ! $wp_filesystem->is_dir($dir))
579 579
 				$needed_dirs[] = $dir;
580 580
 			else
581 581
 				break; // A folder exists, therefor, we dont need the check the levels below this
@@ -589,12 +589,12 @@  discard block
 block discarded – undo
589 589
 	 *
590 590
 	 * @param bool $ziparchive Whether to use ZipArchive. Default true.
591 591
 	 */
592
-	if ( class_exists( 'ZipArchive', false ) && apply_filters( 'unzip_file_use_ziparchive', true ) ) {
592
+	if (class_exists('ZipArchive', false) && apply_filters('unzip_file_use_ziparchive', true)) {
593 593
 		$result = _unzip_file_ziparchive($file, $to, $needed_dirs);
594
-		if ( true === $result ) {
594
+		if (true === $result) {
595 595
 			return $result;
596
-		} elseif ( is_wp_error($result) ) {
597
-			if ( 'incompatible_archive' != $result->get_error_code() )
596
+		} elseif (is_wp_error($result)) {
597
+			if ('incompatible_archive' != $result->get_error_code())
598 598
 				return $result;
599 599
 		}
600 600
 	}
@@ -617,30 +617,30 @@  discard block
 block discarded – undo
617 617
  * @param array $needed_dirs A partial list of required folders needed to be created.
618 618
  * @return mixed WP_Error on failure, True on success
619 619
  */
620
-function _unzip_file_ziparchive($file, $to, $needed_dirs = array() ) {
620
+function _unzip_file_ziparchive($file, $to, $needed_dirs = array()) {
621 621
 	global $wp_filesystem;
622 622
 
623 623
 	$z = new ZipArchive();
624 624
 
625
-	$zopen = $z->open( $file, ZIPARCHIVE::CHECKCONS );
626
-	if ( true !== $zopen )
627
-		return new WP_Error( 'incompatible_archive', __( 'Incompatible Archive.' ), array( 'ziparchive_error' => $zopen ) );
625
+	$zopen = $z->open($file, ZIPARCHIVE::CHECKCONS);
626
+	if (true !== $zopen)
627
+		return new WP_Error('incompatible_archive', __('Incompatible Archive.'), array('ziparchive_error' => $zopen));
628 628
 
629 629
 	$uncompressed_size = 0;
630 630
 
631
-	for ( $i = 0; $i < $z->numFiles; $i++ ) {
632
-		if ( ! $info = $z->statIndex($i) )
633
-			return new WP_Error( 'stat_failed_ziparchive', __( 'Could not retrieve file from archive.' ) );
631
+	for ($i = 0; $i < $z->numFiles; $i++) {
632
+		if ( ! $info = $z->statIndex($i))
633
+			return new WP_Error('stat_failed_ziparchive', __('Could not retrieve file from archive.'));
634 634
 
635
-		if ( '__MACOSX/' === substr($info['name'], 0, 9) ) // Skip the OS X-created __MACOSX directory
635
+		if ('__MACOSX/' === substr($info['name'], 0, 9)) // Skip the OS X-created __MACOSX directory
636 636
 			continue;
637 637
 
638 638
 		$uncompressed_size += $info['size'];
639 639
 
640
-		if ( '/' == substr($info['name'], -1) ) // directory
641
-			$needed_dirs[] = $to . untrailingslashit($info['name']);
640
+		if ('/' == substr($info['name'], -1)) // directory
641
+			$needed_dirs[] = $to.untrailingslashit($info['name']);
642 642
 		else
643
-			$needed_dirs[] = $to . untrailingslashit(dirname($info['name']));
643
+			$needed_dirs[] = $to.untrailingslashit(dirname($info['name']));
644 644
 	}
645 645
 
646 646
 	/*
@@ -648,22 +648,22 @@  discard block
 block discarded – undo
648 648
 	 * A disk that has zero free bytes has bigger problems.
649 649
 	 * Require we have enough space to unzip the file and copy its contents, with a 10% buffer.
650 650
 	 */
651
-	if ( defined( 'DOING_CRON' ) && DOING_CRON ) {
652
-		$available_space = @disk_free_space( WP_CONTENT_DIR );
653
-		if ( $available_space && ( $uncompressed_size * 2.1 ) > $available_space )
654
-			return new WP_Error( 'disk_full_unzip_file', __( 'Could not copy files. You may have run out of disk space.' ), compact( 'uncompressed_size', 'available_space' ) );
651
+	if (defined('DOING_CRON') && DOING_CRON) {
652
+		$available_space = @disk_free_space(WP_CONTENT_DIR);
653
+		if ($available_space && ($uncompressed_size * 2.1) > $available_space)
654
+			return new WP_Error('disk_full_unzip_file', __('Could not copy files. You may have run out of disk space.'), compact('uncompressed_size', 'available_space'));
655 655
 	}
656 656
 
657 657
 	$needed_dirs = array_unique($needed_dirs);
658
-	foreach ( $needed_dirs as $dir ) {
658
+	foreach ($needed_dirs as $dir) {
659 659
 		// Check the parent folders of the folders all exist within the creation array.
660
-		if ( untrailingslashit($to) == $dir ) // Skip over the working directory, We know this exists (or will exist)
660
+		if (untrailingslashit($to) == $dir) // Skip over the working directory, We know this exists (or will exist)
661 661
 			continue;
662
-		if ( strpos($dir, $to) === false ) // If the directory is not within the working directory, Skip it
662
+		if (strpos($dir, $to) === false) // If the directory is not within the working directory, Skip it
663 663
 			continue;
664 664
 
665 665
 		$parent_folder = dirname($dir);
666
-		while ( !empty($parent_folder) && untrailingslashit($to) != $parent_folder && !in_array($parent_folder, $needed_dirs) ) {
666
+		while ( ! empty($parent_folder) && untrailingslashit($to) != $parent_folder && ! in_array($parent_folder, $needed_dirs)) {
667 667
 			$needed_dirs[] = $parent_folder;
668 668
 			$parent_folder = dirname($parent_folder);
669 669
 		}
@@ -671,30 +671,30 @@  discard block
 block discarded – undo
671 671
 	asort($needed_dirs);
672 672
 
673 673
 	// Create those directories if need be:
674
-	foreach ( $needed_dirs as $_dir ) {
674
+	foreach ($needed_dirs as $_dir) {
675 675
 		// Only check to see if the Dir exists upon creation failure. Less I/O this way.
676
-		if ( ! $wp_filesystem->mkdir( $_dir, FS_CHMOD_DIR ) && ! $wp_filesystem->is_dir( $_dir ) ) {
677
-			return new WP_Error( 'mkdir_failed_ziparchive', __( 'Could not create directory.' ), substr( $_dir, strlen( $to ) ) );
676
+		if ( ! $wp_filesystem->mkdir($_dir, FS_CHMOD_DIR) && ! $wp_filesystem->is_dir($_dir)) {
677
+			return new WP_Error('mkdir_failed_ziparchive', __('Could not create directory.'), substr($_dir, strlen($to)));
678 678
 		}
679 679
 	}
680 680
 	unset($needed_dirs);
681 681
 
682
-	for ( $i = 0; $i < $z->numFiles; $i++ ) {
683
-		if ( ! $info = $z->statIndex($i) )
684
-			return new WP_Error( 'stat_failed_ziparchive', __( 'Could not retrieve file from archive.' ) );
682
+	for ($i = 0; $i < $z->numFiles; $i++) {
683
+		if ( ! $info = $z->statIndex($i))
684
+			return new WP_Error('stat_failed_ziparchive', __('Could not retrieve file from archive.'));
685 685
 
686
-		if ( '/' == substr($info['name'], -1) ) // directory
686
+		if ('/' == substr($info['name'], -1)) // directory
687 687
 			continue;
688 688
 
689
-		if ( '__MACOSX/' === substr($info['name'], 0, 9) ) // Don't extract the OS X-created __MACOSX directory files
689
+		if ('__MACOSX/' === substr($info['name'], 0, 9)) // Don't extract the OS X-created __MACOSX directory files
690 690
 			continue;
691 691
 
692 692
 		$contents = $z->getFromIndex($i);
693
-		if ( false === $contents )
694
-			return new WP_Error( 'extract_failed_ziparchive', __( 'Could not extract file from archive.' ), $info['name'] );
693
+		if (false === $contents)
694
+			return new WP_Error('extract_failed_ziparchive', __('Could not extract file from archive.'), $info['name']);
695 695
 
696
-		if ( ! $wp_filesystem->put_contents( $to . $info['name'], $contents, FS_CHMOD_FILE) )
697
-			return new WP_Error( 'copy_failed_ziparchive', __( 'Could not copy file.' ), $info['name'] );
696
+		if ( ! $wp_filesystem->put_contents($to.$info['name'], $contents, FS_CHMOD_FILE))
697
+			return new WP_Error('copy_failed_ziparchive', __('Could not copy file.'), $info['name']);
698 698
 	}
699 699
 
700 700
 	$z->close();
@@ -722,7 +722,7 @@  discard block
 block discarded – undo
722 722
 
723 723
 	mbstring_binary_safe_encoding();
724 724
 
725
-	require_once(ABSPATH . 'wp-admin/includes/class-pclzip.php');
725
+	require_once(ABSPATH.'wp-admin/includes/class-pclzip.php');
726 726
 
727 727
 	$archive = new PclZip($file);
728 728
 
@@ -731,22 +731,22 @@  discard block
 block discarded – undo
731 731
 	reset_mbstring_encoding();
732 732
 
733 733
 	// Is the archive valid?
734
-	if ( !is_array($archive_files) )
734
+	if ( ! is_array($archive_files))
735 735
 		return new WP_Error('incompatible_archive', __('Incompatible Archive.'), $archive->errorInfo(true));
736 736
 
737
-	if ( 0 == count($archive_files) )
738
-		return new WP_Error( 'empty_archive_pclzip', __( 'Empty archive.' ) );
737
+	if (0 == count($archive_files))
738
+		return new WP_Error('empty_archive_pclzip', __('Empty archive.'));
739 739
 
740 740
 	$uncompressed_size = 0;
741 741
 
742 742
 	// Determine any children directories needed (From within the archive)
743
-	foreach ( $archive_files as $file ) {
744
-		if ( '__MACOSX/' === substr($file['filename'], 0, 9) ) // Skip the OS X-created __MACOSX directory
743
+	foreach ($archive_files as $file) {
744
+		if ('__MACOSX/' === substr($file['filename'], 0, 9)) // Skip the OS X-created __MACOSX directory
745 745
 			continue;
746 746
 
747 747
 		$uncompressed_size += $file['size'];
748 748
 
749
-		$needed_dirs[] = $to . untrailingslashit( $file['folder'] ? $file['filename'] : dirname($file['filename']) );
749
+		$needed_dirs[] = $to.untrailingslashit($file['folder'] ? $file['filename'] : dirname($file['filename']));
750 750
 	}
751 751
 
752 752
 	/*
@@ -754,22 +754,22 @@  discard block
 block discarded – undo
754 754
 	 * A disk that has zero free bytes has bigger problems.
755 755
 	 * Require we have enough space to unzip the file and copy its contents, with a 10% buffer.
756 756
 	 */
757
-	if ( defined( 'DOING_CRON' ) && DOING_CRON ) {
758
-		$available_space = @disk_free_space( WP_CONTENT_DIR );
759
-		if ( $available_space && ( $uncompressed_size * 2.1 ) > $available_space )
760
-			return new WP_Error( 'disk_full_unzip_file', __( 'Could not copy files. You may have run out of disk space.' ), compact( 'uncompressed_size', 'available_space' ) );
757
+	if (defined('DOING_CRON') && DOING_CRON) {
758
+		$available_space = @disk_free_space(WP_CONTENT_DIR);
759
+		if ($available_space && ($uncompressed_size * 2.1) > $available_space)
760
+			return new WP_Error('disk_full_unzip_file', __('Could not copy files. You may have run out of disk space.'), compact('uncompressed_size', 'available_space'));
761 761
 	}
762 762
 
763 763
 	$needed_dirs = array_unique($needed_dirs);
764
-	foreach ( $needed_dirs as $dir ) {
764
+	foreach ($needed_dirs as $dir) {
765 765
 		// Check the parent folders of the folders all exist within the creation array.
766
-		if ( untrailingslashit($to) == $dir ) // Skip over the working directory, We know this exists (or will exist)
766
+		if (untrailingslashit($to) == $dir) // Skip over the working directory, We know this exists (or will exist)
767 767
 			continue;
768
-		if ( strpos($dir, $to) === false ) // If the directory is not within the working directory, Skip it
768
+		if (strpos($dir, $to) === false) // If the directory is not within the working directory, Skip it
769 769
 			continue;
770 770
 
771 771
 		$parent_folder = dirname($dir);
772
-		while ( !empty($parent_folder) && untrailingslashit($to) != $parent_folder && !in_array($parent_folder, $needed_dirs) ) {
772
+		while ( ! empty($parent_folder) && untrailingslashit($to) != $parent_folder && ! in_array($parent_folder, $needed_dirs)) {
773 773
 			$needed_dirs[] = $parent_folder;
774 774
 			$parent_folder = dirname($parent_folder);
775 775
 		}
@@ -777,23 +777,23 @@  discard block
 block discarded – undo
777 777
 	asort($needed_dirs);
778 778
 
779 779
 	// Create those directories if need be:
780
-	foreach ( $needed_dirs as $_dir ) {
780
+	foreach ($needed_dirs as $_dir) {
781 781
 		// Only check to see if the dir exists upon creation failure. Less I/O this way.
782
-		if ( ! $wp_filesystem->mkdir( $_dir, FS_CHMOD_DIR ) && ! $wp_filesystem->is_dir( $_dir ) )
783
-			return new WP_Error( 'mkdir_failed_pclzip', __( 'Could not create directory.' ), substr( $_dir, strlen( $to ) ) );
782
+		if ( ! $wp_filesystem->mkdir($_dir, FS_CHMOD_DIR) && ! $wp_filesystem->is_dir($_dir))
783
+			return new WP_Error('mkdir_failed_pclzip', __('Could not create directory.'), substr($_dir, strlen($to)));
784 784
 	}
785 785
 	unset($needed_dirs);
786 786
 
787 787
 	// Extract the files from the zip
788
-	foreach ( $archive_files as $file ) {
789
-		if ( $file['folder'] )
788
+	foreach ($archive_files as $file) {
789
+		if ($file['folder'])
790 790
 			continue;
791 791
 
792
-		if ( '__MACOSX/' === substr($file['filename'], 0, 9) ) // Don't extract the OS X-created __MACOSX directory files
792
+		if ('__MACOSX/' === substr($file['filename'], 0, 9)) // Don't extract the OS X-created __MACOSX directory files
793 793
 			continue;
794 794
 
795
-		if ( ! $wp_filesystem->put_contents( $to . $file['filename'], $file['content'], FS_CHMOD_FILE) )
796
-			return new WP_Error( 'copy_failed_pclzip', __( 'Could not copy file.' ), $file['filename'] );
795
+		if ( ! $wp_filesystem->put_contents($to.$file['filename'], $file['content'], FS_CHMOD_FILE))
796
+			return new WP_Error('copy_failed_pclzip', __('Could not copy file.'), $file['filename']);
797 797
 	}
798 798
 	return true;
799 799
 }
@@ -811,7 +811,7 @@  discard block
 block discarded – undo
811 811
  * @param array $skip_list a list of files/folders to skip copying
812 812
  * @return mixed WP_Error on failure, True on success.
813 813
  */
814
-function copy_dir($from, $to, $skip_list = array() ) {
814
+function copy_dir($from, $to, $skip_list = array()) {
815 815
 	global $wp_filesystem;
816 816
 
817 817
 	$dirlist = $wp_filesystem->dirlist($from);
@@ -819,32 +819,32 @@  discard block
 block discarded – undo
819 819
 	$from = trailingslashit($from);
820 820
 	$to = trailingslashit($to);
821 821
 
822
-	foreach ( (array) $dirlist as $filename => $fileinfo ) {
823
-		if ( in_array( $filename, $skip_list ) )
822
+	foreach ((array) $dirlist as $filename => $fileinfo) {
823
+		if (in_array($filename, $skip_list))
824 824
 			continue;
825 825
 
826
-		if ( 'f' == $fileinfo['type'] ) {
827
-			if ( ! $wp_filesystem->copy($from . $filename, $to . $filename, true, FS_CHMOD_FILE) ) {
826
+		if ('f' == $fileinfo['type']) {
827
+			if ( ! $wp_filesystem->copy($from.$filename, $to.$filename, true, FS_CHMOD_FILE)) {
828 828
 				// If copy failed, chmod file to 0644 and try again.
829
-				$wp_filesystem->chmod( $to . $filename, FS_CHMOD_FILE );
830
-				if ( ! $wp_filesystem->copy($from . $filename, $to . $filename, true, FS_CHMOD_FILE) )
831
-					return new WP_Error( 'copy_failed_copy_dir', __( 'Could not copy file.' ), $to . $filename );
829
+				$wp_filesystem->chmod($to.$filename, FS_CHMOD_FILE);
830
+				if ( ! $wp_filesystem->copy($from.$filename, $to.$filename, true, FS_CHMOD_FILE))
831
+					return new WP_Error('copy_failed_copy_dir', __('Could not copy file.'), $to.$filename);
832 832
 			}
833
-		} elseif ( 'd' == $fileinfo['type'] ) {
834
-			if ( !$wp_filesystem->is_dir($to . $filename) ) {
835
-				if ( !$wp_filesystem->mkdir($to . $filename, FS_CHMOD_DIR) )
836
-					return new WP_Error( 'mkdir_failed_copy_dir', __( 'Could not create directory.' ), $to . $filename );
833
+		} elseif ('d' == $fileinfo['type']) {
834
+			if ( ! $wp_filesystem->is_dir($to.$filename)) {
835
+				if ( ! $wp_filesystem->mkdir($to.$filename, FS_CHMOD_DIR))
836
+					return new WP_Error('mkdir_failed_copy_dir', __('Could not create directory.'), $to.$filename);
837 837
 			}
838 838
 
839 839
 			// generate the $sub_skip_list for the subdirectory as a sub-set of the existing $skip_list
840 840
 			$sub_skip_list = array();
841
-			foreach ( $skip_list as $skip_item ) {
842
-				if ( 0 === strpos( $skip_item, $filename . '/' ) )
843
-					$sub_skip_list[] = preg_replace( '!^' . preg_quote( $filename, '!' ) . '/!i', '', $skip_item );
841
+			foreach ($skip_list as $skip_item) {
842
+				if (0 === strpos($skip_item, $filename.'/'))
843
+					$sub_skip_list[] = preg_replace('!^'.preg_quote($filename, '!').'/!i', '', $skip_item);
844 844
 			}
845 845
 
846
-			$result = copy_dir($from . $filename, $to . $filename, $sub_skip_list);
847
-			if ( is_wp_error($result) )
846
+			$result = copy_dir($from.$filename, $to.$filename, $sub_skip_list);
847
+			if (is_wp_error($result))
848 848
 				return $result;
849 849
 		}
850 850
 	}
@@ -868,17 +868,17 @@  discard block
 block discarded – undo
868 868
  * @param bool         $allow_relaxed_file_ownership Optional. Whether to allow Group/World writable. Default false.
869 869
  * @return null|bool false on failure, true on success.
870 870
  */
871
-function WP_Filesystem( $args = false, $context = false, $allow_relaxed_file_ownership = false ) {
871
+function WP_Filesystem($args = false, $context = false, $allow_relaxed_file_ownership = false) {
872 872
 	global $wp_filesystem;
873 873
 
874
-	require_once(ABSPATH . 'wp-admin/includes/class-wp-filesystem-base.php');
874
+	require_once(ABSPATH.'wp-admin/includes/class-wp-filesystem-base.php');
875 875
 
876
-	$method = get_filesystem_method( $args, $context, $allow_relaxed_file_ownership );
876
+	$method = get_filesystem_method($args, $context, $allow_relaxed_file_ownership);
877 877
 
878
-	if ( ! $method )
878
+	if ( ! $method)
879 879
 		return false;
880 880
 
881
-	if ( ! class_exists( "WP_Filesystem_$method" ) ) {
881
+	if ( ! class_exists("WP_Filesystem_$method")) {
882 882
 
883 883
 		/**
884 884
 		 * Filter the path for a specific filesystem method class file.
@@ -890,9 +890,9 @@  discard block
 block discarded – undo
890 890
 		 * @param string $path   Path to the specific filesystem method class file.
891 891
 		 * @param string $method The filesystem method to use.
892 892
 		 */
893
-		$abstraction_file = apply_filters( 'filesystem_method_file', ABSPATH . 'wp-admin/includes/class-wp-filesystem-' . $method . '.php', $method );
893
+		$abstraction_file = apply_filters('filesystem_method_file', ABSPATH.'wp-admin/includes/class-wp-filesystem-'.$method.'.php', $method);
894 894
 
895
-		if ( ! file_exists($abstraction_file) )
895
+		if ( ! file_exists($abstraction_file))
896 896
 			return;
897 897
 
898 898
 		require_once($abstraction_file);
@@ -902,22 +902,22 @@  discard block
 block discarded – undo
902 902
 	$wp_filesystem = new $method($args);
903 903
 
904 904
 	//Define the timeouts for the connections. Only available after the construct is called to allow for per-transport overriding of the default.
905
-	if ( ! defined('FS_CONNECT_TIMEOUT') )
905
+	if ( ! defined('FS_CONNECT_TIMEOUT'))
906 906
 		define('FS_CONNECT_TIMEOUT', 30);
907
-	if ( ! defined('FS_TIMEOUT') )
907
+	if ( ! defined('FS_TIMEOUT'))
908 908
 		define('FS_TIMEOUT', 30);
909 909
 
910
-	if ( is_wp_error($wp_filesystem->errors) && $wp_filesystem->errors->get_error_code() )
910
+	if (is_wp_error($wp_filesystem->errors) && $wp_filesystem->errors->get_error_code())
911 911
 		return false;
912 912
 
913
-	if ( !$wp_filesystem->connect() )
913
+	if ( ! $wp_filesystem->connect())
914 914
 		return false; //There was an error connecting to the server.
915 915
 
916 916
 	// Set the permission constants if not already set.
917
-	if ( ! defined('FS_CHMOD_DIR') )
918
-		define('FS_CHMOD_DIR', ( fileperms( ABSPATH ) & 0777 | 0755 ) );
919
-	if ( ! defined('FS_CHMOD_FILE') )
920
-		define('FS_CHMOD_FILE', ( fileperms( ABSPATH . 'index.php' ) & 0777 | 0644 ) );
917
+	if ( ! defined('FS_CHMOD_DIR'))
918
+		define('FS_CHMOD_DIR', (fileperms(ABSPATH) & 0777 | 0755));
919
+	if ( ! defined('FS_CHMOD_FILE'))
920
+		define('FS_CHMOD_FILE', (fileperms(ABSPATH.'index.php') & 0777 | 0644));
921 921
 
922 922
 	return true;
923 923
 }
@@ -948,39 +948,39 @@  discard block
 block discarded – undo
948 948
  *                                             Default false.
949 949
  * @return string The transport to use, see description for valid return values.
950 950
  */
951
-function get_filesystem_method( $args = array(), $context = false, $allow_relaxed_file_ownership = false ) {
951
+function get_filesystem_method($args = array(), $context = false, $allow_relaxed_file_ownership = false) {
952 952
 	$method = defined('FS_METHOD') ? FS_METHOD : false; // Please ensure that this is either 'direct', 'ssh2', 'ftpext' or 'ftpsockets'
953 953
 
954
-	if ( ! $context ) {
954
+	if ( ! $context) {
955 955
 		$context = WP_CONTENT_DIR;
956 956
 	}
957 957
 
958 958
 	// If the directory doesn't exist (wp-content/languages) then use the parent directory as we'll create it.
959
-	if ( WP_LANG_DIR == $context && ! is_dir( $context ) ) {
960
-		$context = dirname( $context );
959
+	if (WP_LANG_DIR == $context && ! is_dir($context)) {
960
+		$context = dirname($context);
961 961
 	}
962 962
 
963
-	$context = trailingslashit( $context );
963
+	$context = trailingslashit($context);
964 964
 
965
-	if ( ! $method ) {
965
+	if ( ! $method) {
966 966
 
967
-		$temp_file_name = $context . 'temp-write-test-' . time();
967
+		$temp_file_name = $context.'temp-write-test-'.time();
968 968
 		$temp_handle = @fopen($temp_file_name, 'w');
969
-		if ( $temp_handle ) {
969
+		if ($temp_handle) {
970 970
 
971 971
 			// Attempt to determine the file owner of the WordPress files, and that of newly created files
972 972
 			$wp_file_owner = $temp_file_owner = false;
973
-			if ( function_exists('fileowner') ) {
974
-				$wp_file_owner = @fileowner( __FILE__ );
975
-				$temp_file_owner = @fileowner( $temp_file_name );
973
+			if (function_exists('fileowner')) {
974
+				$wp_file_owner = @fileowner(__FILE__);
975
+				$temp_file_owner = @fileowner($temp_file_name);
976 976
 			}
977 977
 
978
-			if ( $wp_file_owner !== false && $wp_file_owner === $temp_file_owner ) {
978
+			if ($wp_file_owner !== false && $wp_file_owner === $temp_file_owner) {
979 979
 				// WordPress is creating files as the same owner as the WordPress files,
980 980
 				// this means it's safe to modify & create new files via PHP.
981 981
 				$method = 'direct';
982 982
 				$GLOBALS['_wp_filesystem_direct_method'] = 'file_owner';
983
-			} elseif ( $allow_relaxed_file_ownership ) {
983
+			} elseif ($allow_relaxed_file_ownership) {
984 984
 				// The $context directory is writable, and $allow_relaxed_file_ownership is set, this means we can modify files
985 985
 				// safely in this directory. This mode doesn't create new files, only alter existing ones.
986 986
 				$method = 'direct';
@@ -992,9 +992,9 @@  discard block
 block discarded – undo
992 992
 		}
993 993
  	}
994 994
 
995
-	if ( ! $method && isset($args['connection_type']) && 'ssh' == $args['connection_type'] && extension_loaded('ssh2') && function_exists('stream_get_contents') ) $method = 'ssh2';
996
-	if ( ! $method && extension_loaded('ftp') ) $method = 'ftpext';
997
-	if ( ! $method && ( extension_loaded('sockets') || function_exists('fsockopen') ) ) $method = 'ftpsockets'; //Sockets: Socket extension; PHP Mode: FSockopen / fwrite / fread
995
+	if ( ! $method && isset($args['connection_type']) && 'ssh' == $args['connection_type'] && extension_loaded('ssh2') && function_exists('stream_get_contents')) $method = 'ssh2';
996
+	if ( ! $method && extension_loaded('ftp')) $method = 'ftpext';
997
+	if ( ! $method && (extension_loaded('sockets') || function_exists('fsockopen'))) $method = 'ftpsockets'; //Sockets: Socket extension; PHP Mode: FSockopen / fwrite / fread
998 998
 
999 999
 	/**
1000 1000
 	 * Filter the filesystem method to use.
@@ -1006,7 +1006,7 @@  discard block
 block discarded – undo
1006 1006
 	 * @param string $context Full path to the directory that is tested for being writable.
1007 1007
 	 * @param bool   $allow_relaxed_file_ownership Whether to allow Group/World writable.
1008 1008
 	 */
1009
-	return apply_filters( 'filesystem_method', $method, $args, $context, $allow_relaxed_file_ownership );
1009
+	return apply_filters('filesystem_method', $method, $args, $context, $allow_relaxed_file_ownership);
1010 1010
 }
1011 1011
 
1012 1012
 /**
@@ -1038,7 +1038,7 @@  discard block
 block discarded – undo
1038 1038
  *
1039 1039
  * @return bool False on failure, true on success.
1040 1040
  */
1041
-function request_filesystem_credentials( $form_post, $type = '', $error = false, $context = false, $extra_fields = null, $allow_relaxed_file_ownership = false ) {
1041
+function request_filesystem_credentials($form_post, $type = '', $error = false, $context = false, $extra_fields = null, $allow_relaxed_file_ownership = false) {
1042 1042
 	global $pagenow;
1043 1043
 
1044 1044
 	/**
@@ -1060,87 +1060,87 @@  discard block
 block discarded – undo
1060 1060
 	 *                                             Default false.
1061 1061
 	 * @param array  $extra_fields                 Extra POST fields.
1062 1062
 	 */
1063
-	$req_cred = apply_filters( 'request_filesystem_credentials', '', $form_post, $type, $error, $context, $extra_fields, $allow_relaxed_file_ownership );
1064
-	if ( '' !== $req_cred )
1063
+	$req_cred = apply_filters('request_filesystem_credentials', '', $form_post, $type, $error, $context, $extra_fields, $allow_relaxed_file_ownership);
1064
+	if ('' !== $req_cred)
1065 1065
 		return $req_cred;
1066 1066
 
1067
-	if ( empty($type) ) {
1068
-		$type = get_filesystem_method( array(), $context, $allow_relaxed_file_ownership );
1067
+	if (empty($type)) {
1068
+		$type = get_filesystem_method(array(), $context, $allow_relaxed_file_ownership);
1069 1069
 	}
1070 1070
 
1071
-	if ( 'direct' == $type )
1071
+	if ('direct' == $type)
1072 1072
 		return true;
1073 1073
 
1074
-	if ( is_null( $extra_fields ) )
1075
-		$extra_fields = array( 'version', 'locale' );
1074
+	if (is_null($extra_fields))
1075
+		$extra_fields = array('version', 'locale');
1076 1076
 
1077
-	$credentials = get_option('ftp_credentials', array( 'hostname' => '', 'username' => ''));
1077
+	$credentials = get_option('ftp_credentials', array('hostname' => '', 'username' => ''));
1078 1078
 
1079 1079
 	// If defined, set it to that, Else, If POST'd, set it to that, If not, Set it to whatever it previously was(saved details in option)
1080
-	$credentials['hostname'] = defined('FTP_HOST') ? FTP_HOST : (!empty($_POST['hostname']) ? wp_unslash( $_POST['hostname'] ) : $credentials['hostname']);
1081
-	$credentials['username'] = defined('FTP_USER') ? FTP_USER : (!empty($_POST['username']) ? wp_unslash( $_POST['username'] ) : $credentials['username']);
1082
-	$credentials['password'] = defined('FTP_PASS') ? FTP_PASS : (!empty($_POST['password']) ? wp_unslash( $_POST['password'] ) : '');
1080
+	$credentials['hostname'] = defined('FTP_HOST') ? FTP_HOST : ( ! empty($_POST['hostname']) ? wp_unslash($_POST['hostname']) : $credentials['hostname']);
1081
+	$credentials['username'] = defined('FTP_USER') ? FTP_USER : ( ! empty($_POST['username']) ? wp_unslash($_POST['username']) : $credentials['username']);
1082
+	$credentials['password'] = defined('FTP_PASS') ? FTP_PASS : ( ! empty($_POST['password']) ? wp_unslash($_POST['password']) : '');
1083 1083
 
1084 1084
 	// Check to see if we are setting the public/private keys for ssh
1085
-	$credentials['public_key'] = defined('FTP_PUBKEY') ? FTP_PUBKEY : (!empty($_POST['public_key']) ? wp_unslash( $_POST['public_key'] ) : '');
1086
-	$credentials['private_key'] = defined('FTP_PRIKEY') ? FTP_PRIKEY : (!empty($_POST['private_key']) ? wp_unslash( $_POST['private_key'] ) : '');
1085
+	$credentials['public_key'] = defined('FTP_PUBKEY') ? FTP_PUBKEY : ( ! empty($_POST['public_key']) ? wp_unslash($_POST['public_key']) : '');
1086
+	$credentials['private_key'] = defined('FTP_PRIKEY') ? FTP_PRIKEY : ( ! empty($_POST['private_key']) ? wp_unslash($_POST['private_key']) : '');
1087 1087
 
1088 1088
 	// Sanitize the hostname, Some people might pass in odd-data:
1089 1089
 	$credentials['hostname'] = preg_replace('|\w+://|', '', $credentials['hostname']); //Strip any schemes off
1090 1090
 
1091
-	if ( strpos($credentials['hostname'], ':') ) {
1092
-		list( $credentials['hostname'], $credentials['port'] ) = explode(':', $credentials['hostname'], 2);
1093
-		if ( ! is_numeric($credentials['port']) )
1091
+	if (strpos($credentials['hostname'], ':')) {
1092
+		list($credentials['hostname'], $credentials['port']) = explode(':', $credentials['hostname'], 2);
1093
+		if ( ! is_numeric($credentials['port']))
1094 1094
 			unset($credentials['port']);
1095 1095
 	} else {
1096 1096
 		unset($credentials['port']);
1097 1097
 	}
1098 1098
 
1099
-	if ( ( defined( 'FTP_SSH' ) && FTP_SSH ) || ( defined( 'FS_METHOD' ) && 'ssh2' == FS_METHOD ) ) {
1099
+	if ((defined('FTP_SSH') && FTP_SSH) || (defined('FS_METHOD') && 'ssh2' == FS_METHOD)) {
1100 1100
 		$credentials['connection_type'] = 'ssh';
1101
-	} elseif ( ( defined( 'FTP_SSL' ) && FTP_SSL ) && 'ftpext' == $type ) { //Only the FTP Extension understands SSL
1101
+	} elseif ((defined('FTP_SSL') && FTP_SSL) && 'ftpext' == $type) { //Only the FTP Extension understands SSL
1102 1102
 		$credentials['connection_type'] = 'ftps';
1103
-	} elseif ( ! empty( $_POST['connection_type'] ) ) {
1104
-		$credentials['connection_type'] = wp_unslash( $_POST['connection_type'] );
1105
-	} elseif ( ! isset( $credentials['connection_type'] ) ) { //All else fails (And it's not defaulted to something else saved), Default to FTP
1103
+	} elseif ( ! empty($_POST['connection_type'])) {
1104
+		$credentials['connection_type'] = wp_unslash($_POST['connection_type']);
1105
+	} elseif ( ! isset($credentials['connection_type'])) { //All else fails (And it's not defaulted to something else saved), Default to FTP
1106 1106
 		$credentials['connection_type'] = 'ftp';
1107 1107
 	}
1108 1108
 	if ( ! $error &&
1109 1109
 			(
1110
-				( !empty($credentials['password']) && !empty($credentials['username']) && !empty($credentials['hostname']) ) ||
1111
-				( 'ssh' == $credentials['connection_type'] && !empty($credentials['public_key']) && !empty($credentials['private_key']) )
1112
-			) ) {
1110
+				( ! empty($credentials['password']) && ! empty($credentials['username']) && ! empty($credentials['hostname'])) ||
1111
+				('ssh' == $credentials['connection_type'] && ! empty($credentials['public_key']) && ! empty($credentials['private_key']))
1112
+			)) {
1113 1113
 		$stored_credentials = $credentials;
1114
-		if ( !empty($stored_credentials['port']) ) //save port as part of hostname to simplify above code.
1115
-			$stored_credentials['hostname'] .= ':' . $stored_credentials['port'];
1114
+		if ( ! empty($stored_credentials['port'])) //save port as part of hostname to simplify above code.
1115
+			$stored_credentials['hostname'] .= ':'.$stored_credentials['port'];
1116 1116
 
1117 1117
 		unset($stored_credentials['password'], $stored_credentials['port'], $stored_credentials['private_key'], $stored_credentials['public_key']);
1118
-		if ( ! wp_installing() ) {
1119
-			update_option( 'ftp_credentials', $stored_credentials );
1118
+		if ( ! wp_installing()) {
1119
+			update_option('ftp_credentials', $stored_credentials);
1120 1120
 		}
1121 1121
 		return $credentials;
1122 1122
 	}
1123
-	$hostname = isset( $credentials['hostname'] ) ? $credentials['hostname'] : '';
1124
-	$username = isset( $credentials['username'] ) ? $credentials['username'] : '';
1125
-	$public_key = isset( $credentials['public_key'] ) ? $credentials['public_key'] : '';
1126
-	$private_key = isset( $credentials['private_key'] ) ? $credentials['private_key'] : '';
1127
-	$port = isset( $credentials['port'] ) ? $credentials['port'] : '';
1128
-	$connection_type = isset( $credentials['connection_type'] ) ? $credentials['connection_type'] : '';
1129
-
1130
-	if ( $error ) {
1123
+	$hostname = isset($credentials['hostname']) ? $credentials['hostname'] : '';
1124
+	$username = isset($credentials['username']) ? $credentials['username'] : '';
1125
+	$public_key = isset($credentials['public_key']) ? $credentials['public_key'] : '';
1126
+	$private_key = isset($credentials['private_key']) ? $credentials['private_key'] : '';
1127
+	$port = isset($credentials['port']) ? $credentials['port'] : '';
1128
+	$connection_type = isset($credentials['connection_type']) ? $credentials['connection_type'] : '';
1129
+
1130
+	if ($error) {
1131 1131
 		$error_string = __('<strong>ERROR:</strong> There was an error connecting to the server, Please verify the settings are correct.');
1132
-		if ( is_wp_error($error) )
1133
-			$error_string = esc_html( $error->get_error_message() );
1134
-		echo '<div id="message" class="error"><p>' . $error_string . '</p></div>';
1132
+		if (is_wp_error($error))
1133
+			$error_string = esc_html($error->get_error_message());
1134
+		echo '<div id="message" class="error"><p>'.$error_string.'</p></div>';
1135 1135
 	}
1136 1136
 
1137 1137
 	$types = array();
1138
-	if ( extension_loaded('ftp') || extension_loaded('sockets') || function_exists('fsockopen') )
1139
-		$types[ 'ftp' ] = __('FTP');
1140
-	if ( extension_loaded('ftp') ) //Only this supports FTPS
1141
-		$types[ 'ftps' ] = __('FTPS (SSL)');
1142
-	if ( extension_loaded('ssh2') && function_exists('stream_get_contents') )
1143
-		$types[ 'ssh' ] = __('SSH2');
1138
+	if (extension_loaded('ftp') || extension_loaded('sockets') || function_exists('fsockopen'))
1139
+		$types['ftp'] = __('FTP');
1140
+	if (extension_loaded('ftp')) //Only this supports FTPS
1141
+		$types['ftps'] = __('FTPS (SSL)');
1142
+	if (extension_loaded('ssh2') && function_exists('stream_get_contents'))
1143
+		$types['ssh'] = __('SSH2');
1144 1144
 
1145 1145
 	/**
1146 1146
 	 * Filter the connection types to output to the filesystem credentials form.
@@ -1154,7 +1154,7 @@  discard block
 block discarded – undo
1154 1154
 	 * @param string $context     Full path to the directory that is tested
1155 1155
 	 *                            for being writable.
1156 1156
 	 */
1157
-	$types = apply_filters( 'fs_ftp_connection_types', $types, $credentials, $type, $error, $context );
1157
+	$types = apply_filters('fs_ftp_connection_types', $types, $credentials, $type, $error, $context);
1158 1158
 
1159 1159
 ?>
1160 1160
 <script type="text/javascript">
@@ -1170,23 +1170,23 @@  discard block
 block discarded – undo
1170 1170
 });
1171 1171
 -->
1172 1172
 </script>
1173
-<form action="<?php echo esc_url( $form_post ) ?>" method="post">
1173
+<form action="<?php echo esc_url($form_post) ?>" method="post">
1174 1174
 <div id="request-filesystem-credentials-form" class="request-filesystem-credentials-form">
1175 1175
 <?php
1176 1176
 // Print a H1 heading in the FTP credentials modal dialog, default is a H2.
1177 1177
 $heading_tag = 'h2';
1178
-if ( 'plugins.php' === $pagenow || 'plugin-install.php' === $pagenow ) {
1178
+if ('plugins.php' === $pagenow || 'plugin-install.php' === $pagenow) {
1179 1179
 	$heading_tag = 'h1';
1180 1180
 }
1181
-echo "<$heading_tag id='request-filesystem-credentials-title'>" . __( 'Connection Information' ) . "</$heading_tag>";
1181
+echo "<$heading_tag id='request-filesystem-credentials-title'>".__('Connection Information')."</$heading_tag>";
1182 1182
 ?>
1183 1183
 <p id="request-filesystem-credentials-desc"><?php
1184 1184
 	$label_user = __('Username');
1185 1185
 	$label_pass = __('Password');
1186 1186
 	_e('To perform the requested action, WordPress needs to access your web server.');
1187 1187
 	echo ' ';
1188
-	if ( ( isset( $types['ftp'] ) || isset( $types['ftps'] ) ) ) {
1189
-		if ( isset( $types['ssh'] ) ) {
1188
+	if ((isset($types['ftp']) || isset($types['ftps']))) {
1189
+		if (isset($types['ssh'])) {
1190 1190
 			_e('Please enter your FTP or SSH credentials to proceed.');
1191 1191
 			$label_user = __('FTP/SSH Username');
1192 1192
 			$label_pass = __('FTP/SSH Password');
@@ -1200,41 +1200,41 @@  discard block
 block discarded – undo
1200 1200
 	_e('If you do not remember your credentials, you should contact your web host.');
1201 1201
 ?></p>
1202 1202
 <label for="hostname">
1203
-	<span class="field-title"><?php _e( 'Hostname' ) ?></span>
1204
-	<input name="hostname" type="text" id="hostname" aria-describedby="request-filesystem-credentials-desc" class="code" placeholder="<?php esc_attr_e( 'example: www.wordpress.org' ) ?>" value="<?php echo esc_attr($hostname); if ( !empty($port) ) echo ":$port"; ?>"<?php disabled( defined('FTP_HOST') ); ?> />
1203
+	<span class="field-title"><?php _e('Hostname') ?></span>
1204
+	<input name="hostname" type="text" id="hostname" aria-describedby="request-filesystem-credentials-desc" class="code" placeholder="<?php esc_attr_e('example: www.wordpress.org') ?>" value="<?php echo esc_attr($hostname); if ( ! empty($port)) echo ":$port"; ?>"<?php disabled(defined('FTP_HOST')); ?> />
1205 1205
 </label>
1206 1206
 <div class="ftp-username">
1207 1207
 	<label for="username">
1208 1208
 		<span class="field-title"><?php echo $label_user; ?></span>
1209
-		<input name="username" type="text" id="username" value="<?php echo esc_attr($username) ?>"<?php disabled( defined('FTP_USER') ); ?> />
1209
+		<input name="username" type="text" id="username" value="<?php echo esc_attr($username) ?>"<?php disabled(defined('FTP_USER')); ?> />
1210 1210
 	</label>
1211 1211
 </div>
1212 1212
 <div class="ftp-password">
1213 1213
 	<label for="password">
1214 1214
 		<span class="field-title"><?php echo $label_pass; ?></span>
1215
-		<input name="password" type="password" id="password" value="<?php if ( defined('FTP_PASS') ) echo '*****'; ?>"<?php disabled( defined('FTP_PASS') ); ?> />
1216
-		<em><?php if ( ! defined('FTP_PASS') ) _e( 'This password will not be stored on the server.' ); ?></em>
1215
+		<input name="password" type="password" id="password" value="<?php if (defined('FTP_PASS')) echo '*****'; ?>"<?php disabled(defined('FTP_PASS')); ?> />
1216
+		<em><?php if ( ! defined('FTP_PASS')) _e('This password will not be stored on the server.'); ?></em>
1217 1217
 	</label>
1218 1218
 </div>
1219
-<?php if ( isset($types['ssh']) ) : ?>
1219
+<?php if (isset($types['ssh'])) : ?>
1220 1220
 <fieldset>
1221
-<legend><?php _e( 'Authentication Keys' ); ?></legend>
1221
+<legend><?php _e('Authentication Keys'); ?></legend>
1222 1222
 <label for="public_key">
1223 1223
 	<span class="field-title"><?php _e('Public Key:') ?></span>
1224
-	<input name="public_key" type="text" id="public_key" aria-describedby="auth-keys-desc" value="<?php echo esc_attr($public_key) ?>"<?php disabled( defined('FTP_PUBKEY') ); ?> />
1224
+	<input name="public_key" type="text" id="public_key" aria-describedby="auth-keys-desc" value="<?php echo esc_attr($public_key) ?>"<?php disabled(defined('FTP_PUBKEY')); ?> />
1225 1225
 </label>
1226 1226
 <label for="private_key">
1227 1227
 	<span class="field-title"><?php _e('Private Key:') ?></span>
1228
-	<input name="private_key" type="text" id="private_key" value="<?php echo esc_attr($private_key) ?>"<?php disabled( defined('FTP_PRIKEY') ); ?> />
1228
+	<input name="private_key" type="text" id="private_key" value="<?php echo esc_attr($private_key) ?>"<?php disabled(defined('FTP_PRIKEY')); ?> />
1229 1229
 </label>
1230 1230
 </fieldset>
1231 1231
 <span id="auth-keys-desc"><?php _e('Enter the location on the server where the public and private keys are located. If a passphrase is needed, enter that in the password field above.') ?></span>
1232 1232
 <?php endif; ?>
1233 1233
 <fieldset>
1234
-<legend><?php _e( 'Connection Type' ); ?></legend>
1234
+<legend><?php _e('Connection Type'); ?></legend>
1235 1235
 <?php
1236
-	$disabled = disabled( (defined('FTP_SSL') && FTP_SSL) || (defined('FTP_SSH') && FTP_SSH), true, false );
1237
-	foreach ( $types as $name => $text ) : ?>
1236
+	$disabled = disabled((defined('FTP_SSL') && FTP_SSL) || (defined('FTP_SSH') && FTP_SSH), true, false);
1237
+	foreach ($types as $name => $text) : ?>
1238 1238
 	<label for="<?php echo esc_attr($name) ?>">
1239 1239
 		<input type="radio" name="connection_type" id="<?php echo esc_attr($name) ?>" value="<?php echo esc_attr($name) ?>"<?php checked($name, $connection_type); echo $disabled; ?> />
1240 1240
 		<?php echo $text ?>
@@ -1242,14 +1242,14 @@  discard block
 block discarded – undo
1242 1242
 	<?php endforeach; ?>
1243 1243
 </fieldset>
1244 1244
 <?php
1245
-foreach ( (array) $extra_fields as $field ) {
1246
-	if ( isset( $_POST[ $field ] ) )
1247
-		echo '<input type="hidden" name="' . esc_attr( $field ) . '" value="' . esc_attr( wp_unslash( $_POST[ $field ] ) ) . '" />';
1245
+foreach ((array) $extra_fields as $field) {
1246
+	if (isset($_POST[$field]))
1247
+		echo '<input type="hidden" name="'.esc_attr($field).'" value="'.esc_attr(wp_unslash($_POST[$field])).'" />';
1248 1248
 }
1249 1249
 ?>
1250 1250
 	<p class="request-filesystem-credentials-action-buttons">
1251
-		<button class="button cancel-button" data-js-action="close" type="button"><?php _e( 'Cancel' ); ?></button>
1252
-		<?php submit_button( __( 'Proceed' ), 'button', 'upgrade', false ); ?>
1251
+		<button class="button cancel-button" data-js-action="close" type="button"><?php _e('Cancel'); ?></button>
1252
+		<?php submit_button(__('Proceed'), 'button', 'upgrade', false); ?>
1253 1253
 	</p>
1254 1254
 </div>
1255 1255
 </form>
@@ -1265,10 +1265,10 @@  discard block
 block discarded – undo
1265 1265
 function wp_print_request_filesystem_credentials_modal() {
1266 1266
 	$filesystem_method = get_filesystem_method();
1267 1267
 	ob_start();
1268
-	$filesystem_credentials_are_stored = request_filesystem_credentials( self_admin_url() );
1268
+	$filesystem_credentials_are_stored = request_filesystem_credentials(self_admin_url());
1269 1269
 	ob_end_clean();
1270
-	$request_filesystem_credentials = ( $filesystem_method != 'direct' && ! $filesystem_credentials_are_stored );
1271
-	if ( ! $request_filesystem_credentials ) {
1270
+	$request_filesystem_credentials = ($filesystem_method != 'direct' && ! $filesystem_credentials_are_stored);
1271
+	if ( ! $request_filesystem_credentials) {
1272 1272
 		return;
1273 1273
 	}
1274 1274
 	?>
@@ -1276,7 +1276,7 @@  discard block
 block discarded – undo
1276 1276
 		<div class="notification-dialog-background"></div>
1277 1277
 		<div class="notification-dialog" role="dialog" aria-labelledby="request-filesystem-credentials-title" tabindex="0">
1278 1278
 			<div class="request-filesystem-credentials-dialog-content">
1279
-				<?php request_filesystem_credentials( site_url() ); ?>
1279
+				<?php request_filesystem_credentials(site_url()); ?>
1280 1280
 			</div>
1281 1281
 		</div>
1282 1282
 	</div>
Please login to merge, or discard this patch.
Braces   +213 added lines, -122 removed lines patch added patch discarded remove patch
@@ -118,23 +118,27 @@  discard block
 block discarded – undo
118 118
  * @return bool|array False on failure, Else array of files
119 119
  */
120 120
 function list_files( $folder = '', $levels = 100 ) {
121
-	if ( empty($folder) )
122
-		return false;
121
+	if ( empty($folder) ) {
122
+			return false;
123
+	}
123 124
 
124
-	if ( ! $levels )
125
-		return false;
125
+	if ( ! $levels ) {
126
+			return false;
127
+	}
126 128
 
127 129
 	$files = array();
128 130
 	if ( $dir = @opendir( $folder ) ) {
129 131
 		while (($file = readdir( $dir ) ) !== false ) {
130
-			if ( in_array($file, array('.', '..') ) )
131
-				continue;
132
+			if ( in_array($file, array('.', '..') ) ) {
133
+							continue;
134
+			}
132 135
 			if ( is_dir( $folder . '/' . $file ) ) {
133 136
 				$files2 = list_files( $folder . '/' . $file, $levels - 1);
134
-				if ( $files2 )
135
-					$files = array_merge($files, $files2 );
136
-				else
137
-					$files[] = $folder . '/' . $file . '/';
137
+				if ( $files2 ) {
138
+									$files = array_merge($files, $files2 );
139
+				} else {
140
+									$files[] = $folder . '/' . $file . '/';
141
+				}
138 142
 			} else {
139 143
 				$files[] = $folder . '/' . $file;
140 144
 			}
@@ -205,8 +209,9 @@  discard block
 block discarded – undo
205 209
 function validate_file_to_edit( $file, $allowed_files = '' ) {
206 210
 	$code = validate_file( $file, $allowed_files );
207 211
 
208
-	if (!$code )
209
-		return $file;
212
+	if (!$code ) {
213
+			return $file;
214
+	}
210 215
 
211 216
 	switch ( $code ) {
212 217
 		case 1 :
@@ -480,12 +485,14 @@  discard block
 block discarded – undo
480 485
  */
481 486
 function download_url( $url, $timeout = 300 ) {
482 487
 	//WARNING: The file is not automatically deleted, The script must unlink() the file.
483
-	if ( ! $url )
484
-		return new WP_Error('http_no_url', __('Invalid URL Provided.'));
488
+	if ( ! $url ) {
489
+			return new WP_Error('http_no_url', __('Invalid URL Provided.'));
490
+	}
485 491
 
486 492
 	$tmpfname = wp_tempnam($url);
487
-	if ( ! $tmpfname )
488
-		return new WP_Error('http_no_file', __('Could not create Temporary file.'));
493
+	if ( ! $tmpfname ) {
494
+			return new WP_Error('http_no_file', __('Could not create Temporary file.'));
495
+	}
489 496
 
490 497
 	$response = wp_safe_remote_get( $url, array( 'timeout' => $timeout, 'stream' => true, 'filename' => $tmpfname ) );
491 498
 
@@ -521,17 +528,20 @@  discard block
 block discarded – undo
521 528
  * @return bool|object WP_Error on failure, true on success, false when the MD5 format is unknown/unexpected
522 529
  */
523 530
 function verify_file_md5( $filename, $expected_md5 ) {
524
-	if ( 32 == strlen( $expected_md5 ) )
525
-		$expected_raw_md5 = pack( 'H*', $expected_md5 );
526
-	elseif ( 24 == strlen( $expected_md5 ) )
527
-		$expected_raw_md5 = base64_decode( $expected_md5 );
528
-	else
529
-		return false; // unknown format
531
+	if ( 32 == strlen( $expected_md5 ) ) {
532
+			$expected_raw_md5 = pack( 'H*', $expected_md5 );
533
+	} elseif ( 24 == strlen( $expected_md5 ) ) {
534
+			$expected_raw_md5 = base64_decode( $expected_md5 );
535
+	} else {
536
+			return false;
537
+	}
538
+	// unknown format
530 539
 
531 540
 	$file_md5 = md5_file( $filename, true );
532 541
 
533
-	if ( $file_md5 === $expected_raw_md5 )
534
-		return true;
542
+	if ( $file_md5 === $expected_raw_md5 ) {
543
+			return true;
544
+	}
535 545
 
536 546
 	return new WP_Error( 'md5_mismatch', sprintf( __( 'The checksum of the file (%1$s) does not match the expected checksum value (%2$s).' ), bin2hex( $file_md5 ), bin2hex( $expected_raw_md5 ) ) );
537 547
 }
@@ -554,8 +564,9 @@  discard block
 block discarded – undo
554 564
 function unzip_file($file, $to) {
555 565
 	global $wp_filesystem;
556 566
 
557
-	if ( ! $wp_filesystem || !is_object($wp_filesystem) )
558
-		return new WP_Error('fs_unavailable', __('Could not access filesystem.'));
567
+	if ( ! $wp_filesystem || !is_object($wp_filesystem) ) {
568
+			return new WP_Error('fs_unavailable', __('Could not access filesystem.'));
569
+	}
559 570
 
560 571
 	// Unzip can use a lot of memory, but not this much hopefully
561 572
 	/** This filter is documented in wp-admin/admin.php */
@@ -568,17 +579,22 @@  discard block
 block discarded – undo
568 579
 	if ( ! $wp_filesystem->is_dir($to) ) { //Only do parents if no children exist
569 580
 		$path = preg_split('![/\\\]!', untrailingslashit($to));
570 581
 		for ( $i = count($path); $i >= 0; $i-- ) {
571
-			if ( empty($path[$i]) )
572
-				continue;
582
+			if ( empty($path[$i]) ) {
583
+							continue;
584
+			}
573 585
 
574 586
 			$dir = implode('/', array_slice($path, 0, $i+1) );
575
-			if ( preg_match('!^[a-z]:$!i', $dir) ) // Skip it if it looks like a Windows Drive letter.
587
+			if ( preg_match('!^[a-z]:$!i', $dir) ) {
588
+				// Skip it if it looks like a Windows Drive letter.
576 589
 				continue;
590
+			}
577 591
 
578
-			if ( ! $wp_filesystem->is_dir($dir) )
579
-				$needed_dirs[] = $dir;
580
-			else
581
-				break; // A folder exists, therefor, we dont need the check the levels below this
592
+			if ( ! $wp_filesystem->is_dir($dir) ) {
593
+							$needed_dirs[] = $dir;
594
+			} else {
595
+							break;
596
+			}
597
+			// A folder exists, therefor, we dont need the check the levels below this
582 598
 		}
583 599
 	}
584 600
 
@@ -594,8 +610,9 @@  discard block
 block discarded – undo
594 610
 		if ( true === $result ) {
595 611
 			return $result;
596 612
 		} elseif ( is_wp_error($result) ) {
597
-			if ( 'incompatible_archive' != $result->get_error_code() )
598
-				return $result;
613
+			if ( 'incompatible_archive' != $result->get_error_code() ) {
614
+							return $result;
615
+			}
599 616
 		}
600 617
 	}
601 618
 	// Fall through to PclZip if ZipArchive is not available, or encountered an error opening the file.
@@ -623,24 +640,30 @@  discard block
 block discarded – undo
623 640
 	$z = new ZipArchive();
624 641
 
625 642
 	$zopen = $z->open( $file, ZIPARCHIVE::CHECKCONS );
626
-	if ( true !== $zopen )
627
-		return new WP_Error( 'incompatible_archive', __( 'Incompatible Archive.' ), array( 'ziparchive_error' => $zopen ) );
643
+	if ( true !== $zopen ) {
644
+			return new WP_Error( 'incompatible_archive', __( 'Incompatible Archive.' ), array( 'ziparchive_error' => $zopen ) );
645
+	}
628 646
 
629 647
 	$uncompressed_size = 0;
630 648
 
631 649
 	for ( $i = 0; $i < $z->numFiles; $i++ ) {
632
-		if ( ! $info = $z->statIndex($i) )
633
-			return new WP_Error( 'stat_failed_ziparchive', __( 'Could not retrieve file from archive.' ) );
650
+		if ( ! $info = $z->statIndex($i) ) {
651
+					return new WP_Error( 'stat_failed_ziparchive', __( 'Could not retrieve file from archive.' ) );
652
+		}
634 653
 
635
-		if ( '__MACOSX/' === substr($info['name'], 0, 9) ) // Skip the OS X-created __MACOSX directory
654
+		if ( '__MACOSX/' === substr($info['name'], 0, 9) ) {
655
+			// Skip the OS X-created __MACOSX directory
636 656
 			continue;
657
+		}
637 658
 
638 659
 		$uncompressed_size += $info['size'];
639 660
 
640
-		if ( '/' == substr($info['name'], -1) ) // directory
661
+		if ( '/' == substr($info['name'], -1) ) {
662
+			// directory
641 663
 			$needed_dirs[] = $to . untrailingslashit($info['name']);
642
-		else
643
-			$needed_dirs[] = $to . untrailingslashit(dirname($info['name']));
664
+		} else {
665
+					$needed_dirs[] = $to . untrailingslashit(dirname($info['name']));
666
+		}
644 667
 	}
645 668
 
646 669
 	/*
@@ -650,17 +673,22 @@  discard block
 block discarded – undo
650 673
 	 */
651 674
 	if ( defined( 'DOING_CRON' ) && DOING_CRON ) {
652 675
 		$available_space = @disk_free_space( WP_CONTENT_DIR );
653
-		if ( $available_space && ( $uncompressed_size * 2.1 ) > $available_space )
654
-			return new WP_Error( 'disk_full_unzip_file', __( 'Could not copy files. You may have run out of disk space.' ), compact( 'uncompressed_size', 'available_space' ) );
676
+		if ( $available_space && ( $uncompressed_size * 2.1 ) > $available_space ) {
677
+					return new WP_Error( 'disk_full_unzip_file', __( 'Could not copy files. You may have run out of disk space.' ), compact( 'uncompressed_size', 'available_space' ) );
678
+		}
655 679
 	}
656 680
 
657 681
 	$needed_dirs = array_unique($needed_dirs);
658 682
 	foreach ( $needed_dirs as $dir ) {
659 683
 		// Check the parent folders of the folders all exist within the creation array.
660
-		if ( untrailingslashit($to) == $dir ) // Skip over the working directory, We know this exists (or will exist)
684
+		if ( untrailingslashit($to) == $dir ) {
685
+			// Skip over the working directory, We know this exists (or will exist)
661 686
 			continue;
662
-		if ( strpos($dir, $to) === false ) // If the directory is not within the working directory, Skip it
687
+		}
688
+		if ( strpos($dir, $to) === false ) {
689
+			// If the directory is not within the working directory, Skip it
663 690
 			continue;
691
+		}
664 692
 
665 693
 		$parent_folder = dirname($dir);
666 694
 		while ( !empty($parent_folder) && untrailingslashit($to) != $parent_folder && !in_array($parent_folder, $needed_dirs) ) {
@@ -680,21 +708,28 @@  discard block
 block discarded – undo
680 708
 	unset($needed_dirs);
681 709
 
682 710
 	for ( $i = 0; $i < $z->numFiles; $i++ ) {
683
-		if ( ! $info = $z->statIndex($i) )
684
-			return new WP_Error( 'stat_failed_ziparchive', __( 'Could not retrieve file from archive.' ) );
711
+		if ( ! $info = $z->statIndex($i) ) {
712
+					return new WP_Error( 'stat_failed_ziparchive', __( 'Could not retrieve file from archive.' ) );
713
+		}
685 714
 
686
-		if ( '/' == substr($info['name'], -1) ) // directory
715
+		if ( '/' == substr($info['name'], -1) ) {
716
+			// directory
687 717
 			continue;
718
+		}
688 719
 
689
-		if ( '__MACOSX/' === substr($info['name'], 0, 9) ) // Don't extract the OS X-created __MACOSX directory files
720
+		if ( '__MACOSX/' === substr($info['name'], 0, 9) ) {
721
+			// Don't extract the OS X-created __MACOSX directory files
690 722
 			continue;
723
+		}
691 724
 
692 725
 		$contents = $z->getFromIndex($i);
693
-		if ( false === $contents )
694
-			return new WP_Error( 'extract_failed_ziparchive', __( 'Could not extract file from archive.' ), $info['name'] );
726
+		if ( false === $contents ) {
727
+					return new WP_Error( 'extract_failed_ziparchive', __( 'Could not extract file from archive.' ), $info['name'] );
728
+		}
695 729
 
696
-		if ( ! $wp_filesystem->put_contents( $to . $info['name'], $contents, FS_CHMOD_FILE) )
697
-			return new WP_Error( 'copy_failed_ziparchive', __( 'Could not copy file.' ), $info['name'] );
730
+		if ( ! $wp_filesystem->put_contents( $to . $info['name'], $contents, FS_CHMOD_FILE) ) {
731
+					return new WP_Error( 'copy_failed_ziparchive', __( 'Could not copy file.' ), $info['name'] );
732
+		}
698 733
 	}
699 734
 
700 735
 	$z->close();
@@ -731,18 +766,22 @@  discard block
 block discarded – undo
731 766
 	reset_mbstring_encoding();
732 767
 
733 768
 	// Is the archive valid?
734
-	if ( !is_array($archive_files) )
735
-		return new WP_Error('incompatible_archive', __('Incompatible Archive.'), $archive->errorInfo(true));
769
+	if ( !is_array($archive_files) ) {
770
+			return new WP_Error('incompatible_archive', __('Incompatible Archive.'), $archive->errorInfo(true));
771
+	}
736 772
 
737
-	if ( 0 == count($archive_files) )
738
-		return new WP_Error( 'empty_archive_pclzip', __( 'Empty archive.' ) );
773
+	if ( 0 == count($archive_files) ) {
774
+			return new WP_Error( 'empty_archive_pclzip', __( 'Empty archive.' ) );
775
+	}
739 776
 
740 777
 	$uncompressed_size = 0;
741 778
 
742 779
 	// Determine any children directories needed (From within the archive)
743 780
 	foreach ( $archive_files as $file ) {
744
-		if ( '__MACOSX/' === substr($file['filename'], 0, 9) ) // Skip the OS X-created __MACOSX directory
781
+		if ( '__MACOSX/' === substr($file['filename'], 0, 9) ) {
782
+			// Skip the OS X-created __MACOSX directory
745 783
 			continue;
784
+		}
746 785
 
747 786
 		$uncompressed_size += $file['size'];
748 787
 
@@ -756,17 +795,22 @@  discard block
 block discarded – undo
756 795
 	 */
757 796
 	if ( defined( 'DOING_CRON' ) && DOING_CRON ) {
758 797
 		$available_space = @disk_free_space( WP_CONTENT_DIR );
759
-		if ( $available_space && ( $uncompressed_size * 2.1 ) > $available_space )
760
-			return new WP_Error( 'disk_full_unzip_file', __( 'Could not copy files. You may have run out of disk space.' ), compact( 'uncompressed_size', 'available_space' ) );
798
+		if ( $available_space && ( $uncompressed_size * 2.1 ) > $available_space ) {
799
+					return new WP_Error( 'disk_full_unzip_file', __( 'Could not copy files. You may have run out of disk space.' ), compact( 'uncompressed_size', 'available_space' ) );
800
+		}
761 801
 	}
762 802
 
763 803
 	$needed_dirs = array_unique($needed_dirs);
764 804
 	foreach ( $needed_dirs as $dir ) {
765 805
 		// Check the parent folders of the folders all exist within the creation array.
766
-		if ( untrailingslashit($to) == $dir ) // Skip over the working directory, We know this exists (or will exist)
806
+		if ( untrailingslashit($to) == $dir ) {
807
+			// Skip over the working directory, We know this exists (or will exist)
767 808
 			continue;
768
-		if ( strpos($dir, $to) === false ) // If the directory is not within the working directory, Skip it
809
+		}
810
+		if ( strpos($dir, $to) === false ) {
811
+			// If the directory is not within the working directory, Skip it
769 812
 			continue;
813
+		}
770 814
 
771 815
 		$parent_folder = dirname($dir);
772 816
 		while ( !empty($parent_folder) && untrailingslashit($to) != $parent_folder && !in_array($parent_folder, $needed_dirs) ) {
@@ -779,21 +823,26 @@  discard block
 block discarded – undo
779 823
 	// Create those directories if need be:
780 824
 	foreach ( $needed_dirs as $_dir ) {
781 825
 		// Only check to see if the dir exists upon creation failure. Less I/O this way.
782
-		if ( ! $wp_filesystem->mkdir( $_dir, FS_CHMOD_DIR ) && ! $wp_filesystem->is_dir( $_dir ) )
783
-			return new WP_Error( 'mkdir_failed_pclzip', __( 'Could not create directory.' ), substr( $_dir, strlen( $to ) ) );
826
+		if ( ! $wp_filesystem->mkdir( $_dir, FS_CHMOD_DIR ) && ! $wp_filesystem->is_dir( $_dir ) ) {
827
+					return new WP_Error( 'mkdir_failed_pclzip', __( 'Could not create directory.' ), substr( $_dir, strlen( $to ) ) );
828
+		}
784 829
 	}
785 830
 	unset($needed_dirs);
786 831
 
787 832
 	// Extract the files from the zip
788 833
 	foreach ( $archive_files as $file ) {
789
-		if ( $file['folder'] )
790
-			continue;
834
+		if ( $file['folder'] ) {
835
+					continue;
836
+		}
791 837
 
792
-		if ( '__MACOSX/' === substr($file['filename'], 0, 9) ) // Don't extract the OS X-created __MACOSX directory files
838
+		if ( '__MACOSX/' === substr($file['filename'], 0, 9) ) {
839
+			// Don't extract the OS X-created __MACOSX directory files
793 840
 			continue;
841
+		}
794 842
 
795
-		if ( ! $wp_filesystem->put_contents( $to . $file['filename'], $file['content'], FS_CHMOD_FILE) )
796
-			return new WP_Error( 'copy_failed_pclzip', __( 'Could not copy file.' ), $file['filename'] );
843
+		if ( ! $wp_filesystem->put_contents( $to . $file['filename'], $file['content'], FS_CHMOD_FILE) ) {
844
+					return new WP_Error( 'copy_failed_pclzip', __( 'Could not copy file.' ), $file['filename'] );
845
+		}
797 846
 	}
798 847
 	return true;
799 848
 }
@@ -820,32 +869,37 @@  discard block
 block discarded – undo
820 869
 	$to = trailingslashit($to);
821 870
 
822 871
 	foreach ( (array) $dirlist as $filename => $fileinfo ) {
823
-		if ( in_array( $filename, $skip_list ) )
824
-			continue;
872
+		if ( in_array( $filename, $skip_list ) ) {
873
+					continue;
874
+		}
825 875
 
826 876
 		if ( 'f' == $fileinfo['type'] ) {
827 877
 			if ( ! $wp_filesystem->copy($from . $filename, $to . $filename, true, FS_CHMOD_FILE) ) {
828 878
 				// If copy failed, chmod file to 0644 and try again.
829 879
 				$wp_filesystem->chmod( $to . $filename, FS_CHMOD_FILE );
830
-				if ( ! $wp_filesystem->copy($from . $filename, $to . $filename, true, FS_CHMOD_FILE) )
831
-					return new WP_Error( 'copy_failed_copy_dir', __( 'Could not copy file.' ), $to . $filename );
880
+				if ( ! $wp_filesystem->copy($from . $filename, $to . $filename, true, FS_CHMOD_FILE) ) {
881
+									return new WP_Error( 'copy_failed_copy_dir', __( 'Could not copy file.' ), $to . $filename );
882
+				}
832 883
 			}
833 884
 		} elseif ( 'd' == $fileinfo['type'] ) {
834 885
 			if ( !$wp_filesystem->is_dir($to . $filename) ) {
835
-				if ( !$wp_filesystem->mkdir($to . $filename, FS_CHMOD_DIR) )
836
-					return new WP_Error( 'mkdir_failed_copy_dir', __( 'Could not create directory.' ), $to . $filename );
886
+				if ( !$wp_filesystem->mkdir($to . $filename, FS_CHMOD_DIR) ) {
887
+									return new WP_Error( 'mkdir_failed_copy_dir', __( 'Could not create directory.' ), $to . $filename );
888
+				}
837 889
 			}
838 890
 
839 891
 			// generate the $sub_skip_list for the subdirectory as a sub-set of the existing $skip_list
840 892
 			$sub_skip_list = array();
841 893
 			foreach ( $skip_list as $skip_item ) {
842
-				if ( 0 === strpos( $skip_item, $filename . '/' ) )
843
-					$sub_skip_list[] = preg_replace( '!^' . preg_quote( $filename, '!' ) . '/!i', '', $skip_item );
894
+				if ( 0 === strpos( $skip_item, $filename . '/' ) ) {
895
+									$sub_skip_list[] = preg_replace( '!^' . preg_quote( $filename, '!' ) . '/!i', '', $skip_item );
896
+				}
844 897
 			}
845 898
 
846 899
 			$result = copy_dir($from . $filename, $to . $filename, $sub_skip_list);
847
-			if ( is_wp_error($result) )
848
-				return $result;
900
+			if ( is_wp_error($result) ) {
901
+							return $result;
902
+			}
849 903
 		}
850 904
 	}
851 905
 	return true;
@@ -875,8 +929,9 @@  discard block
 block discarded – undo
875 929
 
876 930
 	$method = get_filesystem_method( $args, $context, $allow_relaxed_file_ownership );
877 931
 
878
-	if ( ! $method )
879
-		return false;
932
+	if ( ! $method ) {
933
+			return false;
934
+	}
880 935
 
881 936
 	if ( ! class_exists( "WP_Filesystem_$method" ) ) {
882 937
 
@@ -892,8 +947,9 @@  discard block
 block discarded – undo
892 947
 		 */
893 948
 		$abstraction_file = apply_filters( 'filesystem_method_file', ABSPATH . 'wp-admin/includes/class-wp-filesystem-' . $method . '.php', $method );
894 949
 
895
-		if ( ! file_exists($abstraction_file) )
896
-			return;
950
+		if ( ! file_exists($abstraction_file) ) {
951
+					return;
952
+		}
897 953
 
898 954
 		require_once($abstraction_file);
899 955
 	}
@@ -902,22 +958,29 @@  discard block
 block discarded – undo
902 958
 	$wp_filesystem = new $method($args);
903 959
 
904 960
 	//Define the timeouts for the connections. Only available after the construct is called to allow for per-transport overriding of the default.
905
-	if ( ! defined('FS_CONNECT_TIMEOUT') )
906
-		define('FS_CONNECT_TIMEOUT', 30);
907
-	if ( ! defined('FS_TIMEOUT') )
908
-		define('FS_TIMEOUT', 30);
961
+	if ( ! defined('FS_CONNECT_TIMEOUT') ) {
962
+			define('FS_CONNECT_TIMEOUT', 30);
963
+	}
964
+	if ( ! defined('FS_TIMEOUT') ) {
965
+			define('FS_TIMEOUT', 30);
966
+	}
909 967
 
910
-	if ( is_wp_error($wp_filesystem->errors) && $wp_filesystem->errors->get_error_code() )
911
-		return false;
968
+	if ( is_wp_error($wp_filesystem->errors) && $wp_filesystem->errors->get_error_code() ) {
969
+			return false;
970
+	}
912 971
 
913
-	if ( !$wp_filesystem->connect() )
914
-		return false; //There was an error connecting to the server.
972
+	if ( !$wp_filesystem->connect() ) {
973
+			return false;
974
+	}
975
+	//There was an error connecting to the server.
915 976
 
916 977
 	// Set the permission constants if not already set.
917
-	if ( ! defined('FS_CHMOD_DIR') )
918
-		define('FS_CHMOD_DIR', ( fileperms( ABSPATH ) & 0777 | 0755 ) );
919
-	if ( ! defined('FS_CHMOD_FILE') )
920
-		define('FS_CHMOD_FILE', ( fileperms( ABSPATH . 'index.php' ) & 0777 | 0644 ) );
978
+	if ( ! defined('FS_CHMOD_DIR') ) {
979
+			define('FS_CHMOD_DIR', ( fileperms( ABSPATH ) & 0777 | 0755 ) );
980
+	}
981
+	if ( ! defined('FS_CHMOD_FILE') ) {
982
+			define('FS_CHMOD_FILE', ( fileperms( ABSPATH . 'index.php' ) & 0777 | 0644 ) );
983
+	}
921 984
 
922 985
 	return true;
923 986
 }
@@ -992,9 +1055,16 @@  discard block
 block discarded – undo
992 1055
 		}
993 1056
  	}
994 1057
 
995
-	if ( ! $method && isset($args['connection_type']) && 'ssh' == $args['connection_type'] && extension_loaded('ssh2') && function_exists('stream_get_contents') ) $method = 'ssh2';
996
-	if ( ! $method && extension_loaded('ftp') ) $method = 'ftpext';
997
-	if ( ! $method && ( extension_loaded('sockets') || function_exists('fsockopen') ) ) $method = 'ftpsockets'; //Sockets: Socket extension; PHP Mode: FSockopen / fwrite / fread
1058
+	if ( ! $method && isset($args['connection_type']) && 'ssh' == $args['connection_type'] && extension_loaded('ssh2') && function_exists('stream_get_contents') ) {
1059
+		$method = 'ssh2';
1060
+	}
1061
+	if ( ! $method && extension_loaded('ftp') ) {
1062
+		$method = 'ftpext';
1063
+	}
1064
+	if ( ! $method && ( extension_loaded('sockets') || function_exists('fsockopen') ) ) {
1065
+		$method = 'ftpsockets';
1066
+	}
1067
+	//Sockets: Socket extension; PHP Mode: FSockopen / fwrite / fread
998 1068
 
999 1069
 	/**
1000 1070
 	 * Filter the filesystem method to use.
@@ -1061,18 +1131,21 @@  discard block
 block discarded – undo
1061 1131
 	 * @param array  $extra_fields                 Extra POST fields.
1062 1132
 	 */
1063 1133
 	$req_cred = apply_filters( 'request_filesystem_credentials', '', $form_post, $type, $error, $context, $extra_fields, $allow_relaxed_file_ownership );
1064
-	if ( '' !== $req_cred )
1065
-		return $req_cred;
1134
+	if ( '' !== $req_cred ) {
1135
+			return $req_cred;
1136
+	}
1066 1137
 
1067 1138
 	if ( empty($type) ) {
1068 1139
 		$type = get_filesystem_method( array(), $context, $allow_relaxed_file_ownership );
1069 1140
 	}
1070 1141
 
1071
-	if ( 'direct' == $type )
1072
-		return true;
1142
+	if ( 'direct' == $type ) {
1143
+			return true;
1144
+	}
1073 1145
 
1074
-	if ( is_null( $extra_fields ) )
1075
-		$extra_fields = array( 'version', 'locale' );
1146
+	if ( is_null( $extra_fields ) ) {
1147
+			$extra_fields = array( 'version', 'locale' );
1148
+	}
1076 1149
 
1077 1150
 	$credentials = get_option('ftp_credentials', array( 'hostname' => '', 'username' => ''));
1078 1151
 
@@ -1090,8 +1163,9 @@  discard block
 block discarded – undo
1090 1163
 
1091 1164
 	if ( strpos($credentials['hostname'], ':') ) {
1092 1165
 		list( $credentials['hostname'], $credentials['port'] ) = explode(':', $credentials['hostname'], 2);
1093
-		if ( ! is_numeric($credentials['port']) )
1094
-			unset($credentials['port']);
1166
+		if ( ! is_numeric($credentials['port']) ) {
1167
+					unset($credentials['port']);
1168
+		}
1095 1169
 	} else {
1096 1170
 		unset($credentials['port']);
1097 1171
 	}
@@ -1111,8 +1185,10 @@  discard block
 block discarded – undo
1111 1185
 				( 'ssh' == $credentials['connection_type'] && !empty($credentials['public_key']) && !empty($credentials['private_key']) )
1112 1186
 			) ) {
1113 1187
 		$stored_credentials = $credentials;
1114
-		if ( !empty($stored_credentials['port']) ) //save port as part of hostname to simplify above code.
1188
+		if ( !empty($stored_credentials['port']) ) {
1189
+			//save port as part of hostname to simplify above code.
1115 1190
 			$stored_credentials['hostname'] .= ':' . $stored_credentials['port'];
1191
+		}
1116 1192
 
1117 1193
 		unset($stored_credentials['password'], $stored_credentials['port'], $stored_credentials['private_key'], $stored_credentials['public_key']);
1118 1194
 		if ( ! wp_installing() ) {
@@ -1129,18 +1205,23 @@  discard block
 block discarded – undo
1129 1205
 
1130 1206
 	if ( $error ) {
1131 1207
 		$error_string = __('<strong>ERROR:</strong> There was an error connecting to the server, Please verify the settings are correct.');
1132
-		if ( is_wp_error($error) )
1133
-			$error_string = esc_html( $error->get_error_message() );
1208
+		if ( is_wp_error($error) ) {
1209
+					$error_string = esc_html( $error->get_error_message() );
1210
+		}
1134 1211
 		echo '<div id="message" class="error"><p>' . $error_string . '</p></div>';
1135 1212
 	}
1136 1213
 
1137 1214
 	$types = array();
1138
-	if ( extension_loaded('ftp') || extension_loaded('sockets') || function_exists('fsockopen') )
1139
-		$types[ 'ftp' ] = __('FTP');
1140
-	if ( extension_loaded('ftp') ) //Only this supports FTPS
1215
+	if ( extension_loaded('ftp') || extension_loaded('sockets') || function_exists('fsockopen') ) {
1216
+			$types[ 'ftp' ] = __('FTP');
1217
+	}
1218
+	if ( extension_loaded('ftp') ) {
1219
+		//Only this supports FTPS
1141 1220
 		$types[ 'ftps' ] = __('FTPS (SSL)');
1142
-	if ( extension_loaded('ssh2') && function_exists('stream_get_contents') )
1143
-		$types[ 'ssh' ] = __('SSH2');
1221
+	}
1222
+	if ( extension_loaded('ssh2') && function_exists('stream_get_contents') ) {
1223
+			$types[ 'ssh' ] = __('SSH2');
1224
+	}
1144 1225
 
1145 1226
 	/**
1146 1227
 	 * Filter the connection types to output to the filesystem credentials form.
@@ -1201,7 +1282,10 @@  discard block
 block discarded – undo
1201 1282
 ?></p>
1202 1283
 <label for="hostname">
1203 1284
 	<span class="field-title"><?php _e( 'Hostname' ) ?></span>
1204
-	<input name="hostname" type="text" id="hostname" aria-describedby="request-filesystem-credentials-desc" class="code" placeholder="<?php esc_attr_e( 'example: www.wordpress.org' ) ?>" value="<?php echo esc_attr($hostname); if ( !empty($port) ) echo ":$port"; ?>"<?php disabled( defined('FTP_HOST') ); ?> />
1285
+	<input name="hostname" type="text" id="hostname" aria-describedby="request-filesystem-credentials-desc" class="code" placeholder="<?php esc_attr_e( 'example: www.wordpress.org' ) ?>" value="<?php echo esc_attr($hostname); if ( !empty($port) ) {
1286
+	echo ":$port";
1287
+}
1288
+?>"<?php disabled( defined('FTP_HOST') ); ?> />
1205 1289
 </label>
1206 1290
 <div class="ftp-username">
1207 1291
 	<label for="username">
@@ -1212,8 +1296,14 @@  discard block
 block discarded – undo
1212 1296
 <div class="ftp-password">
1213 1297
 	<label for="password">
1214 1298
 		<span class="field-title"><?php echo $label_pass; ?></span>
1215
-		<input name="password" type="password" id="password" value="<?php if ( defined('FTP_PASS') ) echo '*****'; ?>"<?php disabled( defined('FTP_PASS') ); ?> />
1216
-		<em><?php if ( ! defined('FTP_PASS') ) _e( 'This password will not be stored on the server.' ); ?></em>
1299
+		<input name="password" type="password" id="password" value="<?php if ( defined('FTP_PASS') ) {
1300
+	echo '*****';
1301
+}
1302
+?>"<?php disabled( defined('FTP_PASS') ); ?> />
1303
+		<em><?php if ( ! defined('FTP_PASS') ) {
1304
+	_e( 'This password will not be stored on the server.' );
1305
+}
1306
+?></em>
1217 1307
 	</label>
1218 1308
 </div>
1219 1309
 <?php if ( isset($types['ssh']) ) : ?>
@@ -1243,9 +1333,10 @@  discard block
 block discarded – undo
1243 1333
 </fieldset>
1244 1334
 <?php
1245 1335
 foreach ( (array) $extra_fields as $field ) {
1246
-	if ( isset( $_POST[ $field ] ) )
1247
-		echo '<input type="hidden" name="' . esc_attr( $field ) . '" value="' . esc_attr( wp_unslash( $_POST[ $field ] ) ) . '" />';
1248
-}
1336
+	if ( isset( $_POST[ $field ] ) ) {
1337
+			echo '<input type="hidden" name="' . esc_attr( $field ) . '" value="' . esc_attr( wp_unslash( $_POST[ $field ] ) ) . '" />';
1338
+	}
1339
+	}
1249 1340
 ?>
1250 1341
 	<p class="request-filesystem-credentials-action-buttons">
1251 1342
 		<button class="button cancel-button" data-js-action="close" type="button"><?php _e( 'Cancel' ); ?></button>
Please login to merge, or discard this patch.