Completed
Push — master ( fdb3a7...cde0c6 )
by Stephen
20:18
created
src/wp-admin/includes/media.php 1 patch
Spacing   +712 added lines, -712 removed lines patch added patch discarded remove patch
@@ -28,7 +28,7 @@  discard block
 block discarded – undo
28 28
 	 *
29 29
 	 * @param array $_default_tabs An array of media tabs.
30 30
 	 */
31
-	return apply_filters( 'media_upload_tabs', $_default_tabs );
31
+	return apply_filters('media_upload_tabs', $_default_tabs);
32 32
 }
33 33
 
34 34
 /**
@@ -44,17 +44,17 @@  discard block
 block discarded – undo
44 44
 function update_gallery_tab($tabs) {
45 45
 	global $wpdb;
46 46
 
47
-	if ( !isset($_REQUEST['post_id']) ) {
47
+	if ( ! isset($_REQUEST['post_id'])) {
48 48
 		unset($tabs['gallery']);
49 49
 		return $tabs;
50 50
 	}
51 51
 
52 52
 	$post_id = intval($_REQUEST['post_id']);
53 53
 
54
-	if ( $post_id )
55
-		$attachments = intval( $wpdb->get_var( $wpdb->prepare( "SELECT count(*) FROM $wpdb->posts WHERE post_type = 'attachment' AND post_status != 'trash' AND post_parent = %d", $post_id ) ) );
54
+	if ($post_id)
55
+		$attachments = intval($wpdb->get_var($wpdb->prepare("SELECT count(*) FROM $wpdb->posts WHERE post_type = 'attachment' AND post_status != 'trash' AND post_parent = %d", $post_id)));
56 56
 
57
-	if ( empty($attachments) ) {
57
+	if (empty($attachments)) {
58 58
 		unset($tabs['gallery']);
59 59
 		return $tabs;
60 60
 	}
@@ -76,26 +76,26 @@  discard block
 block discarded – undo
76 76
 	$tabs = media_upload_tabs();
77 77
 	$default = 'type';
78 78
 
79
-	if ( !empty($tabs) ) {
79
+	if ( ! empty($tabs)) {
80 80
 		echo "<ul id='sidemenu'>\n";
81
-		if ( isset($redir_tab) && array_key_exists($redir_tab, $tabs) ) {
81
+		if (isset($redir_tab) && array_key_exists($redir_tab, $tabs)) {
82 82
 			$current = $redir_tab;
83
-		} elseif ( isset($_GET['tab']) && array_key_exists($_GET['tab'], $tabs) ) {
83
+		} elseif (isset($_GET['tab']) && array_key_exists($_GET['tab'], $tabs)) {
84 84
 			$current = $_GET['tab'];
85 85
 		} else {
86 86
 			/** This filter is documented in wp-admin/media-upload.php */
87
-			$current = apply_filters( 'media_upload_default_tab', $default );
87
+			$current = apply_filters('media_upload_default_tab', $default);
88 88
 		}
89 89
 
90
-		foreach ( $tabs as $callback => $text ) {
90
+		foreach ($tabs as $callback => $text) {
91 91
 			$class = '';
92 92
 
93
-			if ( $current == $callback )
93
+			if ($current == $callback)
94 94
 				$class = " class='current'";
95 95
 
96 96
 			$href = add_query_arg(array('tab' => $callback, 's' => false, 'paged' => false, 'post_mime_type' => false, 'm' => false));
97
-			$link = "<a href='" . esc_url($href) . "'$class>$text</a>";
98
-			echo "\t<li id='" . esc_attr("tab-$callback") . "'>$link</li>\n";
97
+			$link = "<a href='".esc_url($href)."'$class>$text</a>";
98
+			echo "\t<li id='".esc_attr("tab-$callback")."'>$link</li>\n";
99 99
 		}
100 100
 		echo "</ul>\n";
101 101
 	}
@@ -117,22 +117,22 @@  discard block
 block discarded – undo
117 117
  * @param string       $alt     Optional. Image alt attribute. Default empty.
118 118
  * @return string The HTML output to insert into the editor.
119 119
  */
120
-function get_image_send_to_editor( $id, $caption, $title, $align, $url = '', $rel = false, $size = 'medium', $alt = '' ) {
120
+function get_image_send_to_editor($id, $caption, $title, $align, $url = '', $rel = false, $size = 'medium', $alt = '') {
121 121
 
122
-	$html = get_image_tag( $id, $alt, '', $align, $size );
122
+	$html = get_image_tag($id, $alt, '', $align, $size);
123 123
 
124
-	if ( $rel ) {
125
-		if ( is_string( $rel ) ) {
126
-			$rel = ' rel="' . esc_attr( $rel ) . '"';
124
+	if ($rel) {
125
+		if (is_string($rel)) {
126
+			$rel = ' rel="'.esc_attr($rel).'"';
127 127
 		} else {
128
-			$rel = ' rel="attachment wp-att-' . intval( $id ) . '"';
128
+			$rel = ' rel="attachment wp-att-'.intval($id).'"';
129 129
 		}
130 130
 	} else {
131 131
 		$rel = '';
132 132
 	}
133 133
 
134
-	if ( $url )
135
-		$html = '<a href="' . esc_attr( $url ) . '"' . $rel . '>' . $html . '</a>';
134
+	if ($url)
135
+		$html = '<a href="'.esc_attr($url).'"'.$rel.'>'.$html.'</a>';
136 136
 
137 137
 	/**
138 138
 	 * Filters the image HTML markup to send to the editor.
@@ -149,7 +149,7 @@  discard block
 block discarded – undo
149 149
 	 *                              (in that order). Default 'medium'.
150 150
 	 * @param string       $alt     The image alternative, or alt, text.
151 151
 	 */
152
-	$html = apply_filters( 'image_send_to_editor', $html, $id, $caption, $title, $align, $url, $size, $alt );
152
+	$html = apply_filters('image_send_to_editor', $html, $id, $caption, $title, $align, $url, $size, $alt);
153 153
 
154 154
 	return $html;
155 155
 }
@@ -169,7 +169,7 @@  discard block
 block discarded – undo
169 169
  * @param string $alt image alt attribute
170 170
  * @return string
171 171
  */
172
-function image_add_caption( $html, $id, $caption, $title, $align, $url, $size, $alt = '' ) {
172
+function image_add_caption($html, $id, $caption, $title, $align, $url, $size, $alt = '') {
173 173
 
174 174
 	/**
175 175
 	 * Filters the caption text.
@@ -185,7 +185,7 @@  discard block
 block discarded – undo
185 185
 	 * @param string $caption The original caption text.
186 186
 	 * @param int    $id      The attachment ID.
187 187
 	 */
188
-	$caption = apply_filters( 'image_add_caption_text', $caption, $id );
188
+	$caption = apply_filters('image_add_caption_text', $caption, $id);
189 189
 
190 190
 	/**
191 191
 	 * Filters whether to disable captions.
@@ -197,27 +197,27 @@  discard block
 block discarded – undo
197 197
 	 * @param bool $bool Whether to disable appending captions. Returning true to the filter
198 198
 	 *                   will disable captions. Default empty string.
199 199
 	 */
200
-	if ( empty($caption) || apply_filters( 'disable_captions', '' ) )
200
+	if (empty($caption) || apply_filters('disable_captions', ''))
201 201
 		return $html;
202 202
 
203
-	$id = ( 0 < (int) $id ) ? 'attachment_' . $id : '';
203
+	$id = (0 < (int) $id) ? 'attachment_'.$id : '';
204 204
 
205
-	if ( ! preg_match( '/width=["\']([0-9]+)/', $html, $matches ) )
205
+	if ( ! preg_match('/width=["\']([0-9]+)/', $html, $matches))
206 206
 		return $html;
207 207
 
208 208
 	$width = $matches[1];
209 209
 
210
-	$caption = str_replace( array("\r\n", "\r"), "\n", $caption);
211
-	$caption = preg_replace_callback( '/<[a-zA-Z0-9]+(?: [^<>]+>)*/', '_cleanup_image_add_caption', $caption );
210
+	$caption = str_replace(array("\r\n", "\r"), "\n", $caption);
211
+	$caption = preg_replace_callback('/<[a-zA-Z0-9]+(?: [^<>]+>)*/', '_cleanup_image_add_caption', $caption);
212 212
 
213 213
 	// Convert any remaining line breaks to <br>.
214
-	$caption = preg_replace( '/[ \n\t]*\n[ \t]*/', '<br />', $caption );
214
+	$caption = preg_replace('/[ \n\t]*\n[ \t]*/', '<br />', $caption);
215 215
 
216
-	$html = preg_replace( '/(class=["\'][^\'"]*)align(none|left|right|center)\s?/', '$1', $html );
217
-	if ( empty($align) )
216
+	$html = preg_replace('/(class=["\'][^\'"]*)align(none|left|right|center)\s?/', '$1', $html);
217
+	if (empty($align))
218 218
 		$align = 'none';
219 219
 
220
-	$shcode = '[caption id="' . $id . '" align="align' . $align	. '" width="' . $width . '"]' . $html . ' ' . $caption . '[/caption]';
220
+	$shcode = '[caption id="'.$id.'" align="align'.$align.'" width="'.$width.'"]'.$html.' '.$caption.'[/caption]';
221 221
 
222 222
 	/**
223 223
 	 * Filters the image HTML markup including the caption shortcode.
@@ -227,7 +227,7 @@  discard block
 block discarded – undo
227 227
 	 * @param string $shcode The image HTML markup with caption shortcode.
228 228
 	 * @param string $html   The image HTML markup.
229 229
 	 */
230
-	return apply_filters( 'image_add_caption_shortcode', $shcode, $html );
230
+	return apply_filters('image_add_caption_shortcode', $shcode, $html);
231 231
 }
232 232
 
233 233
 /**
@@ -236,9 +236,9 @@  discard block
 block discarded – undo
236 236
  * @access private
237 237
  * @since 3.4.0
238 238
  */
239
-function _cleanup_image_add_caption( $matches ) {
239
+function _cleanup_image_add_caption($matches) {
240 240
 	// Remove any line breaks from inside the tags.
241
-	return preg_replace( '/[\r\n\t]+/', ' ', $matches[0] );
241
+	return preg_replace('/[\r\n\t]+/', ' ', $matches[0]);
242 242
 }
243 243
 
244 244
 /**
@@ -252,7 +252,7 @@  discard block
 block discarded – undo
252 252
 ?>
253 253
 <script type="text/javascript">
254 254
 var win = window.dialogArguments || opener || parent || top;
255
-win.send_to_editor( <?php echo wp_json_encode( $html ); ?> );
255
+win.send_to_editor( <?php echo wp_json_encode($html); ?> );
256 256
 </script>
257 257
 <?php
258 258
 	exit;
@@ -270,22 +270,22 @@  discard block
 block discarded – undo
270 270
  * @param array  $overrides Override the wp_handle_upload() behavior. Optional.
271 271
  * @return int|WP_Error ID of the attachment or a WP_Error object on failure.
272 272
  */
273
-function media_handle_upload($file_id, $post_id, $post_data = array(), $overrides = array( 'test_form' => false )) {
273
+function media_handle_upload($file_id, $post_id, $post_data = array(), $overrides = array('test_form' => false)) {
274 274
 
275 275
 	$time = current_time('mysql');
276
-	if ( $post = get_post($post_id) ) {
277
-		if ( substr( $post->post_date, 0, 4 ) > 0 )
276
+	if ($post = get_post($post_id)) {
277
+		if (substr($post->post_date, 0, 4) > 0)
278 278
 			$time = $post->post_date;
279 279
 	}
280 280
 
281 281
 	$name = $_FILES[$file_id]['name'];
282 282
 	$file = wp_handle_upload($_FILES[$file_id], $overrides, $time);
283 283
 
284
-	if ( isset($file['error']) )
285
-		return new WP_Error( 'upload_error', $file['error'] );
284
+	if (isset($file['error']))
285
+		return new WP_Error('upload_error', $file['error']);
286 286
 
287 287
 	$name_parts = pathinfo($name);
288
-	$name = trim( substr( $name, 0, -(1 + strlen($name_parts['extension'])) ) );
288
+	$name = trim(substr($name, 0, -(1 + strlen($name_parts['extension']))));
289 289
 
290 290
 	$url = $file['url'];
291 291
 	$type = $file['type'];
@@ -294,85 +294,85 @@  discard block
 block discarded – undo
294 294
 	$content = '';
295 295
 	$excerpt = '';
296 296
 
297
-	if ( preg_match( '#^audio#', $type ) ) {
298
-		$meta = wp_read_audio_metadata( $file );
297
+	if (preg_match('#^audio#', $type)) {
298
+		$meta = wp_read_audio_metadata($file);
299 299
 
300
-		if ( ! empty( $meta['title'] ) ) {
300
+		if ( ! empty($meta['title'])) {
301 301
 			$title = $meta['title'];
302 302
 		}
303 303
 
304
-		if ( ! empty( $title ) ) {
304
+		if ( ! empty($title)) {
305 305
 
306
-			if ( ! empty( $meta['album'] ) && ! empty( $meta['artist'] ) ) {
306
+			if ( ! empty($meta['album']) && ! empty($meta['artist'])) {
307 307
 				/* translators: 1: audio track title, 2: album title, 3: artist name */
308
-				$content .= sprintf( __( '"%1$s" from %2$s by %3$s.' ), $title, $meta['album'], $meta['artist'] );
309
-			} elseif ( ! empty( $meta['album'] ) ) {
308
+				$content .= sprintf(__('"%1$s" from %2$s by %3$s.'), $title, $meta['album'], $meta['artist']);
309
+			} elseif ( ! empty($meta['album'])) {
310 310
 				/* translators: 1: audio track title, 2: album title */
311
-				$content .= sprintf( __( '"%1$s" from %2$s.' ), $title, $meta['album'] );
312
-			} elseif ( ! empty( $meta['artist'] ) ) {
311
+				$content .= sprintf(__('"%1$s" from %2$s.'), $title, $meta['album']);
312
+			} elseif ( ! empty($meta['artist'])) {
313 313
 				/* translators: 1: audio track title, 2: artist name */
314
-				$content .= sprintf( __( '"%1$s" by %2$s.' ), $title, $meta['artist'] );
314
+				$content .= sprintf(__('"%1$s" by %2$s.'), $title, $meta['artist']);
315 315
 			} else {
316
-				$content .= sprintf( __( '"%s".' ), $title );
316
+				$content .= sprintf(__('"%s".'), $title);
317 317
 			}
318 318
 
319
-		} elseif ( ! empty( $meta['album'] ) ) {
319
+		} elseif ( ! empty($meta['album'])) {
320 320
 
321
-			if ( ! empty( $meta['artist'] ) ) {
321
+			if ( ! empty($meta['artist'])) {
322 322
 				/* translators: 1: audio album title, 2: artist name */
323
-				$content .= sprintf( __( '%1$s by %2$s.' ), $meta['album'], $meta['artist'] );
323
+				$content .= sprintf(__('%1$s by %2$s.'), $meta['album'], $meta['artist']);
324 324
 			} else {
325
-				$content .= $meta['album'] . '.';
325
+				$content .= $meta['album'].'.';
326 326
 			}
327 327
 
328
-		} elseif ( ! empty( $meta['artist'] ) ) {
328
+		} elseif ( ! empty($meta['artist'])) {
329 329
 
330
-			$content .= $meta['artist'] . '.';
330
+			$content .= $meta['artist'].'.';
331 331
 
332 332
 		}
333 333
 
334
-		if ( ! empty( $meta['year'] ) )
335
-			$content .= ' ' . sprintf( __( 'Released: %d.' ), $meta['year'] );
334
+		if ( ! empty($meta['year']))
335
+			$content .= ' '.sprintf(__('Released: %d.'), $meta['year']);
336 336
 
337
-		if ( ! empty( $meta['track_number'] ) ) {
338
-			$track_number = explode( '/', $meta['track_number'] );
339
-			if ( isset( $track_number[1] ) )
340
-				$content .= ' ' . sprintf( __( 'Track %1$s of %2$s.' ), number_format_i18n( $track_number[0] ), number_format_i18n( $track_number[1] ) );
337
+		if ( ! empty($meta['track_number'])) {
338
+			$track_number = explode('/', $meta['track_number']);
339
+			if (isset($track_number[1]))
340
+				$content .= ' '.sprintf(__('Track %1$s of %2$s.'), number_format_i18n($track_number[0]), number_format_i18n($track_number[1]));
341 341
 			else
342
-				$content .= ' ' . sprintf( __( 'Track %1$s.' ), number_format_i18n( $track_number[0] ) );
342
+				$content .= ' '.sprintf(__('Track %1$s.'), number_format_i18n($track_number[0]));
343 343
 		}
344 344
 
345
-		if ( ! empty( $meta['genre'] ) )
346
-			$content .= ' ' . sprintf( __( 'Genre: %s.' ), $meta['genre'] );
345
+		if ( ! empty($meta['genre']))
346
+			$content .= ' '.sprintf(__('Genre: %s.'), $meta['genre']);
347 347
 
348 348
 	// Use image exif/iptc data for title and caption defaults if possible.
349
-	} elseif ( 0 === strpos( $type, 'image/' ) && $image_meta = @wp_read_image_metadata( $file ) ) {
350
-		if ( trim( $image_meta['title'] ) && ! is_numeric( sanitize_title( $image_meta['title'] ) ) ) {
349
+	} elseif (0 === strpos($type, 'image/') && $image_meta = @wp_read_image_metadata($file)) {
350
+		if (trim($image_meta['title']) && ! is_numeric(sanitize_title($image_meta['title']))) {
351 351
 			$title = $image_meta['title'];
352 352
 		}
353 353
 
354
-		if ( trim( $image_meta['caption'] ) ) {
354
+		if (trim($image_meta['caption'])) {
355 355
 			$excerpt = $image_meta['caption'];
356 356
 		}
357 357
 	}
358 358
 
359 359
 	// Construct the attachment array
360
-	$attachment = array_merge( array(
360
+	$attachment = array_merge(array(
361 361
 		'post_mime_type' => $type,
362 362
 		'guid' => $url,
363 363
 		'post_parent' => $post_id,
364 364
 		'post_title' => $title,
365 365
 		'post_content' => $content,
366 366
 		'post_excerpt' => $excerpt,
367
-	), $post_data );
367
+	), $post_data);
368 368
 
369 369
 	// This should never be set as it would then overwrite an existing attachment.
370
-	unset( $attachment['ID'] );
370
+	unset($attachment['ID']);
371 371
 
372 372
 	// Save the data
373 373
 	$id = wp_insert_attachment($attachment, $file, $post_id);
374
-	if ( !is_wp_error($id) ) {
375
-		wp_update_attachment_metadata( $id, wp_generate_attachment_metadata( $id, $file ) );
374
+	if ( ! is_wp_error($id)) {
375
+		wp_update_attachment_metadata($id, wp_generate_attachment_metadata($id, $file));
376 376
 	}
377 377
 
378 378
 	return $id;
@@ -390,18 +390,18 @@  discard block
 block discarded – undo
390 390
  * @param array  $post_data  Optional. Post data to override. Default empty array.
391 391
  * @return int|object The ID of the attachment or a WP_Error on failure.
392 392
  */
393
-function media_handle_sideload( $file_array, $post_id, $desc = null, $post_data = array() ) {
393
+function media_handle_sideload($file_array, $post_id, $desc = null, $post_data = array()) {
394 394
 	$overrides = array('test_form'=>false);
395 395
 
396
-	$time = current_time( 'mysql' );
397
-	if ( $post = get_post( $post_id ) ) {
398
-		if ( substr( $post->post_date, 0, 4 ) > 0 )
396
+	$time = current_time('mysql');
397
+	if ($post = get_post($post_id)) {
398
+		if (substr($post->post_date, 0, 4) > 0)
399 399
 			$time = $post->post_date;
400 400
 	}
401 401
 
402
-	$file = wp_handle_sideload( $file_array, $overrides, $time );
403
-	if ( isset($file['error']) )
404
-		return new WP_Error( 'upload_error', $file['error'] );
402
+	$file = wp_handle_sideload($file_array, $overrides, $time);
403
+	if (isset($file['error']))
404
+		return new WP_Error('upload_error', $file['error']);
405 405
 
406 406
 	$url = $file['url'];
407 407
 	$type = $file['type'];
@@ -410,32 +410,32 @@  discard block
 block discarded – undo
410 410
 	$content = '';
411 411
 
412 412
 	// Use image exif/iptc data for title and caption defaults if possible.
413
-	if ( $image_meta = @wp_read_image_metadata($file) ) {
414
-		if ( trim( $image_meta['title'] ) && ! is_numeric( sanitize_title( $image_meta['title'] ) ) )
413
+	if ($image_meta = @wp_read_image_metadata($file)) {
414
+		if (trim($image_meta['title']) && ! is_numeric(sanitize_title($image_meta['title'])))
415 415
 			$title = $image_meta['title'];
416
-		if ( trim( $image_meta['caption'] ) )
416
+		if (trim($image_meta['caption']))
417 417
 			$content = $image_meta['caption'];
418 418
 	}
419 419
 
420
-	if ( isset( $desc ) )
420
+	if (isset($desc))
421 421
 		$title = $desc;
422 422
 
423 423
 	// Construct the attachment array.
424
-	$attachment = array_merge( array(
424
+	$attachment = array_merge(array(
425 425
 		'post_mime_type' => $type,
426 426
 		'guid' => $url,
427 427
 		'post_parent' => $post_id,
428 428
 		'post_title' => $title,
429 429
 		'post_content' => $content,
430
-	), $post_data );
430
+	), $post_data);
431 431
 
432 432
 	// This should never be set as it would then overwrite an existing attachment.
433
-	unset( $attachment['ID'] );
433
+	unset($attachment['ID']);
434 434
 
435 435
 	// Save the attachment metadata
436 436
 	$id = wp_insert_attachment($attachment, $file, $post_id);
437
-	if ( !is_wp_error($id) )
438
-		wp_update_attachment_metadata( $id, wp_generate_attachment_metadata( $id, $file ) );
437
+	if ( ! is_wp_error($id))
438
+		wp_update_attachment_metadata($id, wp_generate_attachment_metadata($id, $file));
439 439
 
440 440
 	return $id;
441 441
 }
@@ -455,41 +455,41 @@  discard block
 block discarded – undo
455 455
 <title><?php bloginfo('name') ?> &rsaquo; <?php _e('Uploads'); ?> &#8212; <?php _e('WordPress'); ?></title>
456 456
 <?php
457 457
 
458
-wp_enqueue_style( 'colors' );
458
+wp_enqueue_style('colors');
459 459
 // Check callback name for 'media'
460
-if ( ( is_array( $content_func ) && ! empty( $content_func[1] ) && 0 === strpos( (string) $content_func[1], 'media' ) )
461
-	|| ( ! is_array( $content_func ) && 0 === strpos( $content_func, 'media' ) ) )
462
-	wp_enqueue_style( 'deprecated-media' );
463
-wp_enqueue_style( 'ie' );
460
+if ((is_array($content_func) && ! empty($content_func[1]) && 0 === strpos((string) $content_func[1], 'media'))
461
+	|| ( ! is_array($content_func) && 0 === strpos($content_func, 'media')))
462
+	wp_enqueue_style('deprecated-media');
463
+wp_enqueue_style('ie');
464 464
 ?>
465 465
 <script type="text/javascript">
466 466
 addLoadEvent = function(func){if(typeof jQuery!="undefined")jQuery(document).ready(func);else if(typeof wpOnload!='function'){wpOnload=func;}else{var oldonload=wpOnload;wpOnload=function(){oldonload();func();}}};
467
-var ajaxurl = '<?php echo admin_url( 'admin-ajax.php', 'relative' ); ?>', pagenow = 'media-upload-popup', adminpage = 'media-upload-popup',
467
+var ajaxurl = '<?php echo admin_url('admin-ajax.php', 'relative'); ?>', pagenow = 'media-upload-popup', adminpage = 'media-upload-popup',
468 468
 isRtl = <?php echo (int) is_rtl(); ?>;
469 469
 </script>
470 470
 <?php
471 471
 	/** This action is documented in wp-admin/admin-header.php */
472
-	do_action( 'admin_enqueue_scripts', 'media-upload-popup' );
472
+	do_action('admin_enqueue_scripts', 'media-upload-popup');
473 473
 
474 474
 	/**
475 475
 	 * Fires when admin styles enqueued for the legacy (pre-3.5.0) media upload popup are printed.
476 476
 	 *
477 477
 	 * @since 2.9.0
478 478
 	 */
479
-	do_action( 'admin_print_styles-media-upload-popup' );
479
+	do_action('admin_print_styles-media-upload-popup');
480 480
 
481 481
 	/** This action is documented in wp-admin/admin-header.php */
482
-	do_action( 'admin_print_styles' );
482
+	do_action('admin_print_styles');
483 483
 
484 484
 	/**
485 485
 	 * Fires when admin scripts enqueued for the legacy (pre-3.5.0) media upload popup are printed.
486 486
 	 *
487 487
 	 * @since 2.9.0
488 488
 	 */
489
-	do_action( 'admin_print_scripts-media-upload-popup' );
489
+	do_action('admin_print_scripts-media-upload-popup');
490 490
 
491 491
 	/** This action is documented in wp-admin/admin-header.php */
492
-	do_action( 'admin_print_scripts' );
492
+	do_action('admin_print_scripts');
493 493
 
494 494
 	/**
495 495
 	 * Fires when scripts enqueued for the admin header for the legacy (pre-3.5.0)
@@ -497,12 +497,12 @@  discard block
 block discarded – undo
497 497
 	 *
498 498
 	 * @since 2.9.0
499 499
 	 */
500
-	do_action( 'admin_head-media-upload-popup' );
500
+	do_action('admin_head-media-upload-popup');
501 501
 
502 502
 	/** This action is documented in wp-admin/admin-header.php */
503
-	do_action( 'admin_head' );
503
+	do_action('admin_head');
504 504
 
505
-if ( is_string( $content_func ) ) {
505
+if (is_string($content_func)) {
506 506
 	/**
507 507
 	 * Fires in the admin header for each specific form tab in the legacy
508 508
 	 * (pre-3.5.0) media upload popup.
@@ -514,11 +514,11 @@  discard block
 block discarded – undo
514 514
 	 *
515 515
 	 * @since 2.5.0
516 516
 	 */
517
-	do_action( "admin_head_{$content_func}" );
517
+	do_action("admin_head_{$content_func}");
518 518
 }
519 519
 ?>
520 520
 </head>
521
-<body<?php if ( isset($GLOBALS['body_id']) ) echo ' id="' . $GLOBALS['body_id'] . '"'; ?> class="wp-core-ui no-js">
521
+<body<?php if (isset($GLOBALS['body_id'])) echo ' id="'.$GLOBALS['body_id'].'"'; ?> class="wp-core-ui no-js">
522 522
 <script type="text/javascript">
523 523
 document.body.className = document.body.className.replace('no-js', 'js');
524 524
 </script>
@@ -528,7 +528,7 @@  discard block
 block discarded – undo
528 528
 	call_user_func_array($content_func, $args);
529 529
 
530 530
 	/** This action is documented in wp-admin/admin-footer.php */
531
-	do_action( 'admin_print_footer_scripts' );
531
+	do_action('admin_print_footer_scripts');
532 532
 ?>
533 533
 <script type="text/javascript">if(typeof wpOnload=='function')wpOnload();</script>
534 534
 </body>
@@ -552,20 +552,20 @@  discard block
 block discarded – undo
552 552
 	$instance++;
553 553
 
554 554
 	$post = get_post();
555
-	if ( ! $post && ! empty( $GLOBALS['post_ID'] ) )
555
+	if ( ! $post && ! empty($GLOBALS['post_ID']))
556 556
 		$post = $GLOBALS['post_ID'];
557 557
 
558
-	wp_enqueue_media( array(
558
+	wp_enqueue_media(array(
559 559
 		'post' => $post
560
-	) );
560
+	));
561 561
 
562 562
 	$img = '<span class="wp-media-buttons-icon"></span> ';
563 563
 
564 564
 	$id_attribute = $instance === 1 ? ' id="insert-media-button"' : '';
565
-	printf( '<button type="button"%s class="button insert-media add_media" data-editor="%s">%s</button>',
565
+	printf('<button type="button"%s class="button insert-media add_media" data-editor="%s">%s</button>',
566 566
 		$id_attribute,
567
-		esc_attr( $editor_id ),
568
-		$img . __( 'Add Media' )
567
+		esc_attr($editor_id),
568
+		$img.__('Add Media')
569 569
 	);
570 570
 	/**
571 571
 	 * Filters the legacy (pre-3.5.0) media buttons.
@@ -577,11 +577,11 @@  discard block
 block discarded – undo
577 577
 	 *
578 578
 	 * @param string $string Media buttons context. Default empty.
579 579
 	 */
580
-	$legacy_filter = apply_filters( 'media_buttons_context', '' );
580
+	$legacy_filter = apply_filters('media_buttons_context', '');
581 581
 
582
-	if ( $legacy_filter ) {
582
+	if ($legacy_filter) {
583 583
 		// #WP22559. Close <a> if a plugin started by closing <a> to open their own <a> tag.
584
-		if ( 0 === stripos( trim( $legacy_filter ), '</a>' ) )
584
+		if (0 === stripos(trim($legacy_filter), '</a>'))
585 585
 			$legacy_filter .= '</a>';
586 586
 		echo $legacy_filter;
587 587
 	}
@@ -595,18 +595,18 @@  discard block
 block discarded – undo
595 595
  * @param string $tab
596 596
  * @return string
597 597
  */
598
-function get_upload_iframe_src( $type = null, $post_id = null, $tab = null ) {
598
+function get_upload_iframe_src($type = null, $post_id = null, $tab = null) {
599 599
 	global $post_ID;
600 600
 
601
-	if ( empty( $post_id ) )
601
+	if (empty($post_id))
602 602
 		$post_id = $post_ID;
603 603
 
604
-	$upload_iframe_src = add_query_arg( 'post_id', (int) $post_id, admin_url('media-upload.php') );
604
+	$upload_iframe_src = add_query_arg('post_id', (int) $post_id, admin_url('media-upload.php'));
605 605
 
606
-	if ( $type && 'media' != $type )
606
+	if ($type && 'media' != $type)
607 607
 		$upload_iframe_src = add_query_arg('type', $type, $upload_iframe_src);
608 608
 
609
-	if ( ! empty( $tab ) )
609
+	if ( ! empty($tab))
610 610
 		$upload_iframe_src = add_query_arg('tab', $tab, $upload_iframe_src);
611 611
 
612 612
 	/**
@@ -619,7 +619,7 @@  discard block
 block discarded – undo
619 619
 	 *
620 620
 	 * @param string $upload_iframe_src The upload iframe source URL by type.
621 621
 	 */
622
-	$upload_iframe_src = apply_filters( $type . '_upload_iframe_src', $upload_iframe_src );
622
+	$upload_iframe_src = apply_filters($type.'_upload_iframe_src', $upload_iframe_src);
623 623
 
624 624
 	return add_query_arg('TB_iframe', true, $upload_iframe_src);
625 625
 }
@@ -636,28 +636,28 @@  discard block
 block discarded – undo
636 636
 
637 637
 	$errors = null;
638 638
 
639
-	if ( isset($_POST['send']) ) {
640
-		$keys = array_keys( $_POST['send'] );
641
-		$send_id = (int) reset( $keys );
639
+	if (isset($_POST['send'])) {
640
+		$keys = array_keys($_POST['send']);
641
+		$send_id = (int) reset($keys);
642 642
 	}
643 643
 
644
-	if ( !empty($_POST['attachments']) ) foreach ( $_POST['attachments'] as $attachment_id => $attachment ) {
644
+	if ( ! empty($_POST['attachments'])) foreach ($_POST['attachments'] as $attachment_id => $attachment) {
645 645
 		$post = $_post = get_post($attachment_id, ARRAY_A);
646 646
 
647
-		if ( !current_user_can( 'edit_post', $attachment_id ) )
647
+		if ( ! current_user_can('edit_post', $attachment_id))
648 648
 			continue;
649 649
 
650
-		if ( isset($attachment['post_content']) )
650
+		if (isset($attachment['post_content']))
651 651
 			$post['post_content'] = $attachment['post_content'];
652
-		if ( isset($attachment['post_title']) )
652
+		if (isset($attachment['post_title']))
653 653
 			$post['post_title'] = $attachment['post_title'];
654
-		if ( isset($attachment['post_excerpt']) )
654
+		if (isset($attachment['post_excerpt']))
655 655
 			$post['post_excerpt'] = $attachment['post_excerpt'];
656
-		if ( isset($attachment['menu_order']) )
656
+		if (isset($attachment['menu_order']))
657 657
 			$post['menu_order'] = $attachment['menu_order'];
658 658
 
659
-		if ( isset($send_id) && $attachment_id == $send_id ) {
660
-			if ( isset($attachment['post_parent']) )
659
+		if (isset($send_id) && $attachment_id == $send_id) {
660
+			if (isset($attachment['post_parent']))
661 661
 				$post['post_parent'] = $attachment['post_parent'];
662 662
 		}
663 663
 
@@ -671,33 +671,33 @@  discard block
 block discarded – undo
671 671
 		 * @param array $post       An array of post data.
672 672
 		 * @param array $attachment An array of attachment metadata.
673 673
 		 */
674
-		$post = apply_filters( 'attachment_fields_to_save', $post, $attachment );
674
+		$post = apply_filters('attachment_fields_to_save', $post, $attachment);
675 675
 
676
-		if ( isset($attachment['image_alt']) ) {
677
-			$image_alt = wp_unslash( $attachment['image_alt'] );
678
-			if ( $image_alt != get_post_meta($attachment_id, '_wp_attachment_image_alt', true) ) {
679
-				$image_alt = wp_strip_all_tags( $image_alt, true );
676
+		if (isset($attachment['image_alt'])) {
677
+			$image_alt = wp_unslash($attachment['image_alt']);
678
+			if ($image_alt != get_post_meta($attachment_id, '_wp_attachment_image_alt', true)) {
679
+				$image_alt = wp_strip_all_tags($image_alt, true);
680 680
 
681 681
 				// Update_meta expects slashed.
682
-				update_post_meta( $attachment_id, '_wp_attachment_image_alt', wp_slash( $image_alt ) );
682
+				update_post_meta($attachment_id, '_wp_attachment_image_alt', wp_slash($image_alt));
683 683
 			}
684 684
 		}
685 685
 
686
-		if ( isset($post['errors']) ) {
686
+		if (isset($post['errors'])) {
687 687
 			$errors[$attachment_id] = $post['errors'];
688 688
 			unset($post['errors']);
689 689
 		}
690 690
 
691
-		if ( $post != $_post )
691
+		if ($post != $_post)
692 692
 			wp_update_post($post);
693 693
 
694
-		foreach ( get_attachment_taxonomies($post) as $t ) {
695
-			if ( isset($attachment[$t]) )
694
+		foreach (get_attachment_taxonomies($post) as $t) {
695
+			if (isset($attachment[$t]))
696 696
 				wp_set_object_terms($attachment_id, array_map('trim', preg_split('/,+/', $attachment[$t])), $t, false);
697 697
 		}
698 698
 	}
699 699
 
700
-	if ( isset($_POST['insert-gallery']) || isset($_POST['update-gallery']) ) { ?>
700
+	if (isset($_POST['insert-gallery']) || isset($_POST['update-gallery'])) { ?>
701 701
 		<script type="text/javascript">
702 702
 		var win = window.dialogArguments || opener || parent || top;
703 703
 		win.tb_remove();
@@ -706,14 +706,14 @@  discard block
 block discarded – undo
706 706
 		exit;
707 707
 	}
708 708
 
709
-	if ( isset($send_id) ) {
710
-		$attachment = wp_unslash( $_POST['attachments'][$send_id] );
709
+	if (isset($send_id)) {
710
+		$attachment = wp_unslash($_POST['attachments'][$send_id]);
711 711
 
712
-		$html = isset( $attachment['post_title'] ) ? $attachment['post_title'] : '';
713
-		if ( !empty($attachment['url']) ) {
712
+		$html = isset($attachment['post_title']) ? $attachment['post_title'] : '';
713
+		if ( ! empty($attachment['url'])) {
714 714
 			$rel = '';
715
-			if ( strpos($attachment['url'], 'attachment_id') || get_attachment_link($send_id) == $attachment['url'] )
716
-				$rel = " rel='attachment wp-att-" . esc_attr($send_id) . "'";
715
+			if (strpos($attachment['url'], 'attachment_id') || get_attachment_link($send_id) == $attachment['url'])
716
+				$rel = " rel='attachment wp-att-".esc_attr($send_id)."'";
717 717
 			$html = "<a href='{$attachment['url']}'$rel>$html</a>";
718 718
 		}
719 719
 
@@ -728,7 +728,7 @@  discard block
 block discarded – undo
728 728
 		 * @param int    $send_id    The first key from the $_POST['send'] data.
729 729
 		 * @param array  $attachment Array of attachment metadata.
730 730
 		 */
731
-		$html = apply_filters( 'media_send_to_editor', $html, $send_id, $attachment );
731
+		$html = apply_filters('media_send_to_editor', $html, $send_id, $attachment);
732 732
 		return media_send_to_editor($html);
733 733
 	}
734 734
 
@@ -746,33 +746,33 @@  discard block
 block discarded – undo
746 746
 	$errors = array();
747 747
 	$id = 0;
748 748
 
749
-	if ( isset($_POST['html-upload']) && !empty($_FILES) ) {
749
+	if (isset($_POST['html-upload']) && ! empty($_FILES)) {
750 750
 		check_admin_referer('media-form');
751 751
 		// Upload File button was clicked
752 752
 		$id = media_handle_upload('async-upload', $_REQUEST['post_id']);
753 753
 		unset($_FILES);
754
-		if ( is_wp_error($id) ) {
754
+		if (is_wp_error($id)) {
755 755
 			$errors['upload_error'] = $id;
756 756
 			$id = false;
757 757
 		}
758 758
 	}
759 759
 
760
-	if ( !empty($_POST['insertonlybutton']) ) {
760
+	if ( ! empty($_POST['insertonlybutton'])) {
761 761
 		$src = $_POST['src'];
762
-		if ( !empty($src) && !strpos($src, '://') )
762
+		if ( ! empty($src) && ! strpos($src, '://'))
763 763
 			$src = "http://$src";
764 764
 
765
-		if ( isset( $_POST['media_type'] ) && 'image' != $_POST['media_type'] ) {
766
-			$title = esc_html( wp_unslash( $_POST['title'] ) );
767
-			if ( empty( $title ) )
768
-				$title = esc_html( basename( $src ) );
765
+		if (isset($_POST['media_type']) && 'image' != $_POST['media_type']) {
766
+			$title = esc_html(wp_unslash($_POST['title']));
767
+			if (empty($title))
768
+				$title = esc_html(basename($src));
769 769
 
770
-			if ( $title && $src )
771
-				$html = "<a href='" . esc_url($src) . "'>$title</a>";
770
+			if ($title && $src)
771
+				$html = "<a href='".esc_url($src)."'>$title</a>";
772 772
 
773 773
 			$type = 'file';
774
-			if ( ( $ext = preg_replace( '/^.+?\.([^.]+)$/', '$1', $src ) ) && ( $ext_type = wp_ext2type( $ext ) )
775
-				&& ( 'audio' == $ext_type || 'video' == $ext_type ) )
774
+			if (($ext = preg_replace('/^.+?\.([^.]+)$/', '$1', $src)) && ($ext_type = wp_ext2type($ext))
775
+				&& ('audio' == $ext_type || 'video' == $ext_type))
776 776
 					$type = $ext_type;
777 777
 
778 778
 			/**
@@ -787,16 +787,16 @@  discard block
 block discarded – undo
787 787
 			 * @param string $src   Media source URL.
788 788
 			 * @param string $title Media title.
789 789
 			 */
790
-			$html = apply_filters( $type . '_send_to_editor_url', $html, esc_url_raw( $src ), $title );
790
+			$html = apply_filters($type.'_send_to_editor_url', $html, esc_url_raw($src), $title);
791 791
 		} else {
792 792
 			$align = '';
793
-			$alt = esc_attr( wp_unslash( $_POST['alt'] ) );
794
-			if ( isset($_POST['align']) ) {
795
-				$align = esc_attr( wp_unslash( $_POST['align'] ) );
793
+			$alt = esc_attr(wp_unslash($_POST['alt']));
794
+			if (isset($_POST['align'])) {
795
+				$align = esc_attr(wp_unslash($_POST['align']));
796 796
 				$class = " class='align$align'";
797 797
 			}
798
-			if ( !empty($src) )
799
-				$html = "<img src='" . esc_url($src) . "' alt='$alt'$class />";
798
+			if ( ! empty($src))
799
+				$html = "<img src='".esc_url($src)."' alt='$alt'$class />";
800 800
 
801 801
 			/**
802 802
 			 * Filters the image URL sent to the editor.
@@ -809,34 +809,34 @@  discard block
 block discarded – undo
809 809
 			 * @param string $align The image alignment. Default 'alignnone'. Possible values include
810 810
 			 *                      'alignleft', 'aligncenter', 'alignright', 'alignnone'.
811 811
 			 */
812
-			$html = apply_filters( 'image_send_to_editor_url', $html, esc_url_raw( $src ), $alt, $align );
812
+			$html = apply_filters('image_send_to_editor_url', $html, esc_url_raw($src), $alt, $align);
813 813
 		}
814 814
 
815 815
 		return media_send_to_editor($html);
816 816
 	}
817 817
 
818
-	if ( isset( $_POST['save'] ) ) {
818
+	if (isset($_POST['save'])) {
819 819
 		$errors['upload_notice'] = __('Saved.');
820
-		wp_enqueue_script( 'admin-gallery' );
821
- 		return wp_iframe( 'media_upload_gallery_form', $errors );
820
+		wp_enqueue_script('admin-gallery');
821
+ 		return wp_iframe('media_upload_gallery_form', $errors);
822 822
 
823
-	} elseif ( ! empty( $_POST ) ) {
823
+	} elseif ( ! empty($_POST)) {
824 824
 		$return = media_upload_form_handler();
825 825
 
826
-		if ( is_string($return) )
826
+		if (is_string($return))
827 827
 			return $return;
828
-		if ( is_array($return) )
828
+		if (is_array($return))
829 829
 			$errors = $return;
830 830
 	}
831 831
 
832
-	if ( isset($_GET['tab']) && $_GET['tab'] == 'type_url' ) {
832
+	if (isset($_GET['tab']) && $_GET['tab'] == 'type_url') {
833 833
 		$type = 'image';
834
-		if ( isset( $_GET['type'] ) && in_array( $_GET['type'], array( 'video', 'audio', 'file' ) ) )
834
+		if (isset($_GET['type']) && in_array($_GET['type'], array('video', 'audio', 'file')))
835 835
 			$type = $_GET['type'];
836
-		return wp_iframe( 'media_upload_type_url_form', $type, $errors, $id );
836
+		return wp_iframe('media_upload_type_url_form', $type, $errors, $id);
837 837
 	}
838 838
 
839
-	return wp_iframe( 'media_upload_type_form', 'image', $errors, $id );
839
+	return wp_iframe('media_upload_type_form', 'image', $errors, $id);
840 840
 }
841 841
 
842 842
 /**
@@ -851,49 +851,49 @@  discard block
 block discarded – undo
851 851
  * @param string $return  Optional. Accepts 'html' (image tag html) or 'src' (URL). Default 'html'.
852 852
  * @return string|WP_Error Populated HTML img tag on success, WP_Error object otherwise.
853 853
  */
854
-function media_sideload_image( $file, $post_id, $desc = null, $return = 'html' ) {
855
-	if ( ! empty( $file ) ) {
854
+function media_sideload_image($file, $post_id, $desc = null, $return = 'html') {
855
+	if ( ! empty($file)) {
856 856
 
857 857
 		// Set variables for storage, fix file filename for query strings.
858
-		preg_match( '/[^\?]+\.(jpe?g|jpe|gif|png)\b/i', $file, $matches );
859
-		if ( ! $matches ) {
860
-			return new WP_Error( 'image_sideload_failed', __( 'Invalid image URL' ) );
858
+		preg_match('/[^\?]+\.(jpe?g|jpe|gif|png)\b/i', $file, $matches);
859
+		if ( ! $matches) {
860
+			return new WP_Error('image_sideload_failed', __('Invalid image URL'));
861 861
 		}
862 862
 
863 863
 		$file_array = array();
864
-		$file_array['name'] = basename( $matches[0] );
864
+		$file_array['name'] = basename($matches[0]);
865 865
 
866 866
 		// Download file to temp location.
867
-		$file_array['tmp_name'] = download_url( $file );
867
+		$file_array['tmp_name'] = download_url($file);
868 868
 
869 869
 		// If error storing temporarily, return the error.
870
-		if ( is_wp_error( $file_array['tmp_name'] ) ) {
870
+		if (is_wp_error($file_array['tmp_name'])) {
871 871
 			return $file_array['tmp_name'];
872 872
 		}
873 873
 
874 874
 		// Do the validation and storage stuff.
875
-		$id = media_handle_sideload( $file_array, $post_id, $desc );
875
+		$id = media_handle_sideload($file_array, $post_id, $desc);
876 876
 
877 877
 		// If error storing permanently, unlink.
878
-		if ( is_wp_error( $id ) ) {
879
-			@unlink( $file_array['tmp_name'] );
878
+		if (is_wp_error($id)) {
879
+			@unlink($file_array['tmp_name']);
880 880
 			return $id;
881 881
 		}
882 882
 
883
-		$src = wp_get_attachment_url( $id );
883
+		$src = wp_get_attachment_url($id);
884 884
 	}
885 885
 
886 886
 	// Finally, check to make sure the file has been saved, then return the HTML.
887
-	if ( ! empty( $src ) ) {
888
-		if ( $return === 'src' ) {
887
+	if ( ! empty($src)) {
888
+		if ($return === 'src') {
889 889
 			return $src;
890 890
 		}
891 891
 
892
-		$alt = isset( $desc ) ? esc_attr( $desc ) : '';
892
+		$alt = isset($desc) ? esc_attr($desc) : '';
893 893
 		$html = "<img src='$src' alt='$alt' />";
894 894
 		return $html;
895 895
 	} else {
896
-		return new WP_Error( 'image_sideload_failed' );
896
+		return new WP_Error('image_sideload_failed');
897 897
 	}
898 898
 }
899 899
 
@@ -907,17 +907,17 @@  discard block
 block discarded – undo
907 907
 function media_upload_gallery() {
908 908
 	$errors = array();
909 909
 
910
-	if ( !empty($_POST) ) {
910
+	if ( ! empty($_POST)) {
911 911
 		$return = media_upload_form_handler();
912 912
 
913
-		if ( is_string($return) )
913
+		if (is_string($return))
914 914
 			return $return;
915
-		if ( is_array($return) )
915
+		if (is_array($return))
916 916
 			$errors = $return;
917 917
 	}
918 918
 
919 919
 	wp_enqueue_script('admin-gallery');
920
-	return wp_iframe( 'media_upload_gallery_form', $errors );
920
+	return wp_iframe('media_upload_gallery_form', $errors);
921 921
 }
922 922
 
923 923
 /**
@@ -929,16 +929,16 @@  discard block
 block discarded – undo
929 929
  */
930 930
 function media_upload_library() {
931 931
 	$errors = array();
932
-	if ( !empty($_POST) ) {
932
+	if ( ! empty($_POST)) {
933 933
 		$return = media_upload_form_handler();
934 934
 
935
-		if ( is_string($return) )
935
+		if (is_string($return))
936 936
 			return $return;
937
-		if ( is_array($return) )
937
+		if (is_array($return))
938 938
 			$errors = $return;
939 939
 	}
940 940
 
941
-	return wp_iframe( 'media_upload_library_form', $errors );
941
+	return wp_iframe('media_upload_library_form', $errors);
942 942
 }
943 943
 
944 944
 /**
@@ -950,20 +950,20 @@  discard block
 block discarded – undo
950 950
  * @param string $checked
951 951
  * @return string
952 952
  */
953
-function image_align_input_fields( $post, $checked = '' ) {
953
+function image_align_input_fields($post, $checked = '') {
954 954
 
955
-	if ( empty($checked) )
955
+	if (empty($checked))
956 956
 		$checked = get_user_setting('align', 'none');
957 957
 
958 958
 	$alignments = array('none' => __('None'), 'left' => __('Left'), 'center' => __('Center'), 'right' => __('Right'));
959
-	if ( !array_key_exists( (string) $checked, $alignments ) )
959
+	if ( ! array_key_exists((string) $checked, $alignments))
960 960
 		$checked = 'none';
961 961
 
962 962
 	$out = array();
963
-	foreach ( $alignments as $name => $label ) {
963
+	foreach ($alignments as $name => $label) {
964 964
 		$name = esc_attr($name);
965 965
 		$out[] = "<input type='radio' name='attachments[{$post->ID}][align]' id='image-align-{$name}-{$post->ID}' value='$name'".
966
-			( $checked == $name ? " checked='checked'" : "" ) .
966
+			($checked == $name ? " checked='checked'" : "").
967 967
 			" /><label for='image-align-{$name}-{$post->ID}' class='align image-align-{$name}-label'>$label</label>";
968 968
 	}
969 969
 	return join("\n", $out);
@@ -978,7 +978,7 @@  discard block
 block discarded – undo
978 978
  * @param bool|string $check
979 979
  * @return array
980 980
  */
981
-function image_size_input_fields( $post, $check = '' ) {
981
+function image_size_input_fields($post, $check = '') {
982 982
 	/**
983 983
 	 * Filters the names and labels of the default image sizes.
984 984
 	 *
@@ -987,34 +987,34 @@  discard block
 block discarded – undo
987 987
 	 * @param array $size_names Array of image sizes and their names. Default values
988 988
 	 *                          include 'Thumbnail', 'Medium', 'Large', 'Full Size'.
989 989
 	 */
990
-	$size_names = apply_filters( 'image_size_names_choose', array(
991
-		'thumbnail' => __( 'Thumbnail' ),
992
-		'medium'    => __( 'Medium' ),
993
-		'large'     => __( 'Large' ),
994
-		'full'      => __( 'Full Size' )
995
-	) );
996
-
997
-	if ( empty( $check ) ) {
990
+	$size_names = apply_filters('image_size_names_choose', array(
991
+		'thumbnail' => __('Thumbnail'),
992
+		'medium'    => __('Medium'),
993
+		'large'     => __('Large'),
994
+		'full'      => __('Full Size')
995
+	));
996
+
997
+	if (empty($check)) {
998 998
 		$check = get_user_setting('imgsize', 'medium');
999 999
 	}
1000 1000
 	$out = array();
1001 1001
 
1002
-	foreach ( $size_names as $size => $label ) {
1003
-		$downsize = image_downsize( $post->ID, $size );
1002
+	foreach ($size_names as $size => $label) {
1003
+		$downsize = image_downsize($post->ID, $size);
1004 1004
 		$checked = '';
1005 1005
 
1006 1006
 		// Is this size selectable?
1007
-		$enabled = ( $downsize[3] || 'full' == $size );
1007
+		$enabled = ($downsize[3] || 'full' == $size);
1008 1008
 		$css_id = "image-size-{$size}-{$post->ID}";
1009 1009
 
1010 1010
 		// If this size is the default but that's not available, don't select it.
1011
-		if ( $size == $check ) {
1012
-			if ( $enabled ) {
1011
+		if ($size == $check) {
1012
+			if ($enabled) {
1013 1013
 				$checked = " checked='checked'";
1014 1014
 			} else {
1015 1015
 				$check = '';
1016 1016
 			}
1017
-		} elseif ( ! $check && $enabled && 'thumbnail' != $size ) {
1017
+		} elseif ( ! $check && $enabled && 'thumbnail' != $size) {
1018 1018
 			/*
1019 1019
 			 * If $check is not enabled, default to the first available size
1020 1020
 			 * that's bigger than a thumbnail.
@@ -1023,13 +1023,13 @@  discard block
 block discarded – undo
1023 1023
 			$checked = " checked='checked'";
1024 1024
 		}
1025 1025
 
1026
-		$html = "<div class='image-size-item'><input type='radio' " . disabled( $enabled, false, false ) . "name='attachments[$post->ID][image-size]' id='{$css_id}' value='{$size}'$checked />";
1026
+		$html = "<div class='image-size-item'><input type='radio' ".disabled($enabled, false, false)."name='attachments[$post->ID][image-size]' id='{$css_id}' value='{$size}'$checked />";
1027 1027
 
1028 1028
 		$html .= "<label for='{$css_id}'>$label</label>";
1029 1029
 
1030 1030
 		// Only show the dimensions if that choice is available.
1031
-		if ( $enabled ) {
1032
-			$html .= " <label for='{$css_id}' class='help'>" . sprintf( "(%d&nbsp;&times;&nbsp;%d)", $downsize[1], $downsize[2] ). "</label>";
1031
+		if ($enabled) {
1032
+			$html .= " <label for='{$css_id}' class='help'>".sprintf("(%d&nbsp;&times;&nbsp;%d)", $downsize[1], $downsize[2])."</label>";
1033 1033
 		}
1034 1034
 		$html .= '</div>';
1035 1035
 
@@ -1037,9 +1037,9 @@  discard block
 block discarded – undo
1037 1037
 	}
1038 1038
 
1039 1039
 	return array(
1040
-		'label' => __( 'Size' ),
1040
+		'label' => __('Size'),
1041 1041
 		'input' => 'html',
1042
-		'html'  => join( "\n", $out ),
1042
+		'html'  => join("\n", $out),
1043 1043
 	);
1044 1044
 }
1045 1045
 
@@ -1057,20 +1057,20 @@  discard block
 block discarded – undo
1057 1057
 	$file = wp_get_attachment_url($post->ID);
1058 1058
 	$link = get_attachment_link($post->ID);
1059 1059
 
1060
-	if ( empty($url_type) )
1060
+	if (empty($url_type))
1061 1061
 		$url_type = get_user_setting('urlbutton', 'post');
1062 1062
 
1063 1063
 	$url = '';
1064
-	if ( $url_type == 'file' )
1064
+	if ($url_type == 'file')
1065 1065
 		$url = $file;
1066
-	elseif ( $url_type == 'post' )
1066
+	elseif ($url_type == 'post')
1067 1067
 		$url = $link;
1068 1068
 
1069 1069
 	return "
1070
-	<input type='text' class='text urlfield' name='attachments[$post->ID][url]' value='" . esc_attr($url) . "' /><br />
1071
-	<button type='button' class='button urlnone' data-link-url=''>" . __('None') . "</button>
1072
-	<button type='button' class='button urlfile' data-link-url='" . esc_attr($file) . "'>" . __('File URL') . "</button>
1073
-	<button type='button' class='button urlpost' data-link-url='" . esc_attr($link) . "'>" . __('Attachment Post URL') . "</button>
1070
+	<input type='text' class='text urlfield' name='attachments[$post->ID][url]' value='".esc_attr($url)."' /><br />
1071
+	<button type='button' class='button urlnone' data-link-url=''>" . __('None')."</button>
1072
+	<button type='button' class='button urlfile' data-link-url='" . esc_attr($file)."'>".__('File URL')."</button>
1073
+	<button type='button' class='button urlpost' data-link-url='" . esc_attr($link)."'>".__('Attachment Post URL')."</button>
1074 1074
 ";
1075 1075
 }
1076 1076
 
@@ -1086,7 +1086,7 @@  discard block
 block discarded – undo
1086 1086
 	// Post data is already escaped.
1087 1087
 	$name = "attachments[{$edit_post->ID}][post_excerpt]";
1088 1088
 
1089
-	return '<textarea name="' . $name . '" id="' . $name . '">' . $edit_post->post_excerpt . '</textarea>';
1089
+	return '<textarea name="'.$name.'" id="'.$name.'">'.$edit_post->post_excerpt.'</textarea>';
1090 1090
 }
1091 1091
 
1092 1092
 /**
@@ -1111,7 +1111,7 @@  discard block
 block discarded – undo
1111 1111
  * @param WP_Post $post        The WP_Post attachment object.
1112 1112
  * @return array Filtered attachment form fields.
1113 1113
  */
1114
-function media_single_attachment_fields_to_edit( $form_fields, $post ) {
1114
+function media_single_attachment_fields_to_edit($form_fields, $post) {
1115 1115
 	unset($form_fields['url'], $form_fields['align'], $form_fields['image-size']);
1116 1116
 	return $form_fields;
1117 1117
 }
@@ -1125,7 +1125,7 @@  discard block
 block discarded – undo
1125 1125
  * @param WP_Post $post        The WP_Post attachment object.
1126 1126
  * @return array Filtered attachment form fields.
1127 1127
  */
1128
-function media_post_single_attachment_fields_to_edit( $form_fields, $post ) {
1128
+function media_post_single_attachment_fields_to_edit($form_fields, $post) {
1129 1129
 	unset($form_fields['image_url']);
1130 1130
 	return $form_fields;
1131 1131
 }
@@ -1143,12 +1143,12 @@  discard block
 block discarded – undo
1143 1143
  * @param array $attachment An array of attachment metadata.
1144 1144
  * @return array Filtered attachment post object.
1145 1145
  */
1146
-function image_attachment_fields_to_save( $post, $attachment ) {
1147
-	if ( substr( $post['post_mime_type'], 0, 5 ) == 'image' ) {
1148
-		if ( strlen( trim( $post['post_title'] ) ) == 0 ) {
1149
-			$attachment_url = ( isset( $post['attachment_url'] ) ) ? $post['attachment_url'] : $post['guid'];
1150
-			$post['post_title'] = preg_replace( '/\.\w+$/', '', wp_basename( $attachment_url ) );
1151
-			$post['errors']['post_title']['errors'][] = __( 'Empty Title filled from filename.' );
1146
+function image_attachment_fields_to_save($post, $attachment) {
1147
+	if (substr($post['post_mime_type'], 0, 5) == 'image') {
1148
+		if (strlen(trim($post['post_title'])) == 0) {
1149
+			$attachment_url = (isset($post['attachment_url'])) ? $post['attachment_url'] : $post['guid'];
1150
+			$post['post_title'] = preg_replace('/\.\w+$/', '', wp_basename($attachment_url));
1151
+			$post['errors']['post_title']['errors'][] = __('Empty Title filled from filename.');
1152 1152
 		}
1153 1153
 	}
1154 1154
 
@@ -1167,12 +1167,12 @@  discard block
 block discarded – undo
1167 1167
  */
1168 1168
 function image_media_send_to_editor($html, $attachment_id, $attachment) {
1169 1169
 	$post = get_post($attachment_id);
1170
-	if ( substr($post->post_mime_type, 0, 5) == 'image' ) {
1170
+	if (substr($post->post_mime_type, 0, 5) == 'image') {
1171 1171
 		$url = $attachment['url'];
1172
-		$align = !empty($attachment['align']) ? $attachment['align'] : 'none';
1173
-		$size = !empty($attachment['image-size']) ? $attachment['image-size'] : 'medium';
1174
-		$alt = !empty($attachment['image_alt']) ? $attachment['image_alt'] : '';
1175
-		$rel = ( strpos( $url, 'attachment_id') || $url === get_attachment_link( $attachment_id ) );
1172
+		$align = ! empty($attachment['align']) ? $attachment['align'] : 'none';
1173
+		$size = ! empty($attachment['image-size']) ? $attachment['image-size'] : 'medium';
1174
+		$alt = ! empty($attachment['image_alt']) ? $attachment['image_alt'] : '';
1175
+		$rel = (strpos($url, 'attachment_id') || $url === get_attachment_link($attachment_id));
1176 1176
 
1177 1177
 		return get_image_send_to_editor($attachment_id, $attachment['post_excerpt'], $attachment['post_title'], $align, $url, $rel, $size, $alt);
1178 1178
 	}
@@ -1190,10 +1190,10 @@  discard block
 block discarded – undo
1190 1190
  * @return array
1191 1191
  */
1192 1192
 function get_attachment_fields_to_edit($post, $errors = null) {
1193
-	if ( is_int($post) )
1193
+	if (is_int($post))
1194 1194
 		$post = get_post($post);
1195
-	if ( is_array($post) )
1196
-		$post = new WP_Post( (object) $post );
1195
+	if (is_array($post))
1196
+		$post = new WP_Post((object) $post);
1197 1197
 
1198 1198
 	$image_url = wp_get_attachment_url($post->ID);
1199 1199
 
@@ -1228,28 +1228,28 @@  discard block
 block discarded – undo
1228 1228
 		'image_url'	=> array(
1229 1229
 			'label'      => __('File URL'),
1230 1230
 			'input'      => 'html',
1231
-			'html'       => "<input type='text' class='text urlfield' readonly='readonly' name='attachments[$post->ID][url]' value='" . esc_attr($image_url) . "' /><br />",
1231
+			'html'       => "<input type='text' class='text urlfield' readonly='readonly' name='attachments[$post->ID][url]' value='".esc_attr($image_url)."' /><br />",
1232 1232
 			'value'      => wp_get_attachment_url($post->ID),
1233 1233
 			'helps'      => __('Location of the uploaded file.')
1234 1234
 		)
1235 1235
 	);
1236 1236
 
1237
-	foreach ( get_attachment_taxonomies($post) as $taxonomy ) {
1237
+	foreach (get_attachment_taxonomies($post) as $taxonomy) {
1238 1238
 		$t = (array) get_taxonomy($taxonomy);
1239
-		if ( ! $t['public'] || ! $t['show_ui'] )
1239
+		if ( ! $t['public'] || ! $t['show_ui'])
1240 1240
 			continue;
1241
-		if ( empty($t['label']) )
1241
+		if (empty($t['label']))
1242 1242
 			$t['label'] = $taxonomy;
1243
-		if ( empty($t['args']) )
1243
+		if (empty($t['args']))
1244 1244
 			$t['args'] = array();
1245 1245
 
1246 1246
 		$terms = get_object_term_cache($post->ID, $taxonomy);
1247
-		if ( false === $terms )
1247
+		if (false === $terms)
1248 1248
 			$terms = wp_get_object_terms($post->ID, $taxonomy, $t['args']);
1249 1249
 
1250 1250
 		$values = array();
1251 1251
 
1252
-		foreach ( $terms as $term )
1252
+		foreach ($terms as $term)
1253 1253
 			$values[] = $term->slug;
1254 1254
 		$t['value'] = join(', ', $values);
1255 1255
 
@@ -1261,9 +1261,9 @@  discard block
 block discarded – undo
1261 1261
 	$form_fields = array_merge_recursive($form_fields, (array) $errors);
1262 1262
 
1263 1263
 	// This was formerly in image_attachment_fields_to_edit().
1264
-	if ( substr($post->post_mime_type, 0, 5) == 'image' ) {
1264
+	if (substr($post->post_mime_type, 0, 5) == 'image') {
1265 1265
 		$alt = get_post_meta($post->ID, '_wp_attachment_image_alt', true);
1266
-		if ( empty($alt) )
1266
+		if (empty($alt))
1267 1267
 			$alt = '';
1268 1268
 
1269 1269
 		$form_fields['post_title']['required'] = true;
@@ -1280,10 +1280,10 @@  discard block
 block discarded – undo
1280 1280
 			'html'  => image_align_input_fields($post, get_option('image_default_align')),
1281 1281
 		);
1282 1282
 
1283
-		$form_fields['image-size'] = image_size_input_fields( $post, get_option('image_default_size', 'medium') );
1283
+		$form_fields['image-size'] = image_size_input_fields($post, get_option('image_default_size', 'medium'));
1284 1284
 
1285 1285
 	} else {
1286
-		unset( $form_fields['image_alt'] );
1286
+		unset($form_fields['image_alt']);
1287 1287
 	}
1288 1288
 
1289 1289
 	/**
@@ -1294,7 +1294,7 @@  discard block
 block discarded – undo
1294 1294
 	 * @param array   $form_fields An array of attachment form fields.
1295 1295
 	 * @param WP_Post $post        The WP_Post attachment object.
1296 1296
 	 */
1297
-	$form_fields = apply_filters( 'attachment_fields_to_edit', $form_fields, $post );
1297
+	$form_fields = apply_filters('attachment_fields_to_edit', $form_fields, $post);
1298 1298
 
1299 1299
 	return $form_fields;
1300 1300
 }
@@ -1314,25 +1314,25 @@  discard block
 block discarded – undo
1314 1314
  * @param array $errors Errors for attachment, if any.
1315 1315
  * @return string
1316 1316
  */
1317
-function get_media_items( $post_id, $errors ) {
1317
+function get_media_items($post_id, $errors) {
1318 1318
 	$attachments = array();
1319
-	if ( $post_id ) {
1319
+	if ($post_id) {
1320 1320
 		$post = get_post($post_id);
1321
-		if ( $post && $post->post_type == 'attachment' )
1321
+		if ($post && $post->post_type == 'attachment')
1322 1322
 			$attachments = array($post->ID => $post);
1323 1323
 		else
1324
-			$attachments = get_children( array( 'post_parent' => $post_id, 'post_type' => 'attachment', 'orderby' => 'menu_order ASC, ID', 'order' => 'DESC') );
1324
+			$attachments = get_children(array('post_parent' => $post_id, 'post_type' => 'attachment', 'orderby' => 'menu_order ASC, ID', 'order' => 'DESC'));
1325 1325
 	} else {
1326
-		if ( is_array($GLOBALS['wp_the_query']->posts) )
1327
-			foreach ( $GLOBALS['wp_the_query']->posts as $attachment )
1326
+		if (is_array($GLOBALS['wp_the_query']->posts))
1327
+			foreach ($GLOBALS['wp_the_query']->posts as $attachment)
1328 1328
 				$attachments[$attachment->ID] = $attachment;
1329 1329
 	}
1330 1330
 
1331 1331
 	$output = '';
1332
-	foreach ( (array) $attachments as $id => $attachment ) {
1333
-		if ( $attachment->post_status == 'trash' )
1332
+	foreach ((array) $attachments as $id => $attachment) {
1333
+		if ($attachment->post_status == 'trash')
1334 1334
 			continue;
1335
-		if ( $item = get_media_item( $id, array( 'errors' => isset($errors[$id]) ? $errors[$id] : null) ) )
1335
+		if ($item = get_media_item($id, array('errors' => isset($errors[$id]) ? $errors[$id] : null)))
1336 1336
 			$output .= "\n<div id='media-item-$id' class='media-item child-of-$attachment->post_parent preloaded'><div class='progress hidden'><div class='bar'></div></div><div id='media-upload-error-$id' class='hidden'></div><div class='filename hidden'></div>$item\n</div>";
1337 1337
 	}
1338 1338
 
@@ -1350,25 +1350,25 @@  discard block
 block discarded – undo
1350 1350
  * @param string|array $args Optional. Override defaults.
1351 1351
  * @return string HTML form for attachment.
1352 1352
  */
1353
-function get_media_item( $attachment_id, $args = null ) {
1353
+function get_media_item($attachment_id, $args = null) {
1354 1354
 	global $redir_tab;
1355 1355
 
1356
-	if ( ( $attachment_id = intval( $attachment_id ) ) && $thumb_url = wp_get_attachment_image_src( $attachment_id, 'thumbnail', true ) )
1356
+	if (($attachment_id = intval($attachment_id)) && $thumb_url = wp_get_attachment_image_src($attachment_id, 'thumbnail', true))
1357 1357
 		$thumb_url = $thumb_url[0];
1358 1358
 	else
1359 1359
 		$thumb_url = false;
1360 1360
 
1361
-	$post = get_post( $attachment_id );
1362
-	$current_post_id = !empty( $_GET['post_id'] ) ? (int) $_GET['post_id'] : 0;
1361
+	$post = get_post($attachment_id);
1362
+	$current_post_id = ! empty($_GET['post_id']) ? (int) $_GET['post_id'] : 0;
1363 1363
 
1364 1364
 	$default_args = array(
1365 1365
 		'errors' => null,
1366
-		'send' => $current_post_id ? post_type_supports( get_post_type( $current_post_id ), 'editor' ) : true,
1366
+		'send' => $current_post_id ? post_type_supports(get_post_type($current_post_id), 'editor') : true,
1367 1367
 		'delete' => true,
1368 1368
 		'toggle' => true,
1369 1369
 		'show_title' => true
1370 1370
 	);
1371
-	$args = wp_parse_args( $args, $default_args );
1371
+	$args = wp_parse_args($args, $default_args);
1372 1372
 
1373 1373
 	/**
1374 1374
 	 * Filters the arguments used to retrieve an image for the edit image form.
@@ -1379,24 +1379,24 @@  discard block
 block discarded – undo
1379 1379
 	 *
1380 1380
 	 * @param array $args An array of arguments.
1381 1381
 	 */
1382
-	$r = apply_filters( 'get_media_item_args', $args );
1382
+	$r = apply_filters('get_media_item_args', $args);
1383 1383
 
1384
-	$toggle_on  = __( 'Show' );
1385
-	$toggle_off = __( 'Hide' );
1384
+	$toggle_on  = __('Show');
1385
+	$toggle_off = __('Hide');
1386 1386
 
1387
-	$file = get_attached_file( $post->ID );
1388
-	$filename = esc_html( wp_basename( $file ) );
1389
-	$title = esc_attr( $post->post_title );
1387
+	$file = get_attached_file($post->ID);
1388
+	$filename = esc_html(wp_basename($file));
1389
+	$title = esc_attr($post->post_title);
1390 1390
 
1391 1391
 	$post_mime_types = get_post_mime_types();
1392
-	$keys = array_keys( wp_match_mime_types( array_keys( $post_mime_types ), $post->post_mime_type ) );
1393
-	$type = reset( $keys );
1394
-	$type_html = "<input type='hidden' id='type-of-$attachment_id' value='" . esc_attr( $type ) . "' />";
1392
+	$keys = array_keys(wp_match_mime_types(array_keys($post_mime_types), $post->post_mime_type));
1393
+	$type = reset($keys);
1394
+	$type_html = "<input type='hidden' id='type-of-$attachment_id' value='".esc_attr($type)."' />";
1395 1395
 
1396
-	$form_fields = get_attachment_fields_to_edit( $post, $r['errors'] );
1396
+	$form_fields = get_attachment_fields_to_edit($post, $r['errors']);
1397 1397
 
1398
-	if ( $r['toggle'] ) {
1399
-		$class = empty( $r['errors'] ) ? 'startclosed' : 'startopen';
1398
+	if ($r['toggle']) {
1399
+		$class = empty($r['errors']) ? 'startclosed' : 'startopen';
1400 1400
 		$toggle_links = "
1401 1401
 	<a class='toggle describe-toggle-on' href='#'>$toggle_on</a>
1402 1402
 	<a class='toggle describe-toggle-off' href='#'>$toggle_off</a>";
@@ -1405,27 +1405,27 @@  discard block
 block discarded – undo
1405 1405
 		$toggle_links = '';
1406 1406
 	}
1407 1407
 
1408
-	$display_title = ( !empty( $title ) ) ? $title : $filename; // $title shouldn't ever be empty, but just in case
1409
-	$display_title = $r['show_title'] ? "<div class='filename new'><span class='title'>" . wp_html_excerpt( $display_title, 60, '&hellip;' ) . "</span></div>" : '';
1408
+	$display_title = ( ! empty($title)) ? $title : $filename; // $title shouldn't ever be empty, but just in case
1409
+	$display_title = $r['show_title'] ? "<div class='filename new'><span class='title'>".wp_html_excerpt($display_title, 60, '&hellip;')."</span></div>" : '';
1410 1410
 
1411
-	$gallery = ( ( isset( $_REQUEST['tab'] ) && 'gallery' == $_REQUEST['tab'] ) || ( isset( $redir_tab ) && 'gallery' == $redir_tab ) );
1411
+	$gallery = ((isset($_REQUEST['tab']) && 'gallery' == $_REQUEST['tab']) || (isset($redir_tab) && 'gallery' == $redir_tab));
1412 1412
 	$order = '';
1413 1413
 
1414
-	foreach ( $form_fields as $key => $val ) {
1415
-		if ( 'menu_order' == $key ) {
1416
-			if ( $gallery )
1417
-				$order = "<div class='menu_order'> <input class='menu_order_input' type='text' id='attachments[$attachment_id][menu_order]' name='attachments[$attachment_id][menu_order]' value='" . esc_attr( $val['value'] ). "' /></div>";
1414
+	foreach ($form_fields as $key => $val) {
1415
+		if ('menu_order' == $key) {
1416
+			if ($gallery)
1417
+				$order = "<div class='menu_order'> <input class='menu_order_input' type='text' id='attachments[$attachment_id][menu_order]' name='attachments[$attachment_id][menu_order]' value='".esc_attr($val['value'])."' /></div>";
1418 1418
 			else
1419
-				$order = "<input type='hidden' name='attachments[$attachment_id][menu_order]' value='" . esc_attr( $val['value'] ) . "' />";
1419
+				$order = "<input type='hidden' name='attachments[$attachment_id][menu_order]' value='".esc_attr($val['value'])."' />";
1420 1420
 
1421
-			unset( $form_fields['menu_order'] );
1421
+			unset($form_fields['menu_order']);
1422 1422
 			break;
1423 1423
 		}
1424 1424
 	}
1425 1425
 
1426 1426
 	$media_dims = '';
1427
-	$meta = wp_get_attachment_metadata( $post->ID );
1428
-	if ( isset( $meta['width'], $meta['height'] ) )
1427
+	$meta = wp_get_attachment_metadata($post->ID);
1428
+	if (isset($meta['width'], $meta['height']))
1429 1429
 		$media_dims .= "<span id='media-dims-$post->ID'>{$meta['width']}&nbsp;&times;&nbsp;{$meta['height']}</span> ";
1430 1430
 
1431 1431
 	/**
@@ -1436,15 +1436,15 @@  discard block
 block discarded – undo
1436 1436
 	 * @param string  $media_dims The HTML markup containing the media dimensions.
1437 1437
 	 * @param WP_Post $post       The WP_Post attachment object.
1438 1438
 	 */
1439
-	$media_dims = apply_filters( 'media_meta', $media_dims, $post );
1439
+	$media_dims = apply_filters('media_meta', $media_dims, $post);
1440 1440
 
1441 1441
 	$image_edit_button = '';
1442
-	if ( wp_attachment_is_image( $post->ID ) && wp_image_editor_supports( array( 'mime_type' => $post->post_mime_type ) ) ) {
1443
-		$nonce = wp_create_nonce( "image_editor-$post->ID" );
1444
-		$image_edit_button = "<input type='button' id='imgedit-open-btn-$post->ID' onclick='imageEdit.open( $post->ID, \"$nonce\" )' class='button' value='" . esc_attr__( 'Edit Image' ) . "' /> <span class='spinner'></span>";
1442
+	if (wp_attachment_is_image($post->ID) && wp_image_editor_supports(array('mime_type' => $post->post_mime_type))) {
1443
+		$nonce = wp_create_nonce("image_editor-$post->ID");
1444
+		$image_edit_button = "<input type='button' id='imgedit-open-btn-$post->ID' onclick='imageEdit.open( $post->ID, \"$nonce\" )' class='button' value='".esc_attr__('Edit Image')."' /> <span class='spinner'></span>";
1445 1445
 	}
1446 1446
 
1447
-	$attachment_url = get_permalink( $attachment_id );
1447
+	$attachment_url = get_permalink($attachment_id);
1448 1448
 
1449 1449
 	$item = "
1450 1450
 	$type_html
@@ -1459,11 +1459,11 @@  discard block
 block discarded – undo
1459 1459
 			<p>$image_edit_button</p>
1460 1460
 			</td>
1461 1461
 			<td>
1462
-			<p><strong>" . __('File name:') . "</strong> $filename</p>
1463
-			<p><strong>" . __('File type:') . "</strong> $post->post_mime_type</p>
1464
-			<p><strong>" . __('Upload date:') . "</strong> " . mysql2date( __( 'F j, Y' ), $post->post_date ). '</p>';
1465
-			if ( !empty( $media_dims ) )
1466
-				$item .= "<p><strong>" . __('Dimensions:') . "</strong> $media_dims</p>\n";
1462
+			<p><strong>".__('File name:')."</strong> $filename</p>
1463
+			<p><strong>".__('File type:')."</strong> $post->post_mime_type</p>
1464
+			<p><strong>".__('Upload date:')."</strong> ".mysql2date(__('F j, Y'), $post->post_date).'</p>';
1465
+			if ( ! empty($media_dims))
1466
+				$item .= "<p><strong>".__('Dimensions:')."</strong> $media_dims</p>\n";
1467 1467
 
1468 1468
 			$item .= "</td></tr>\n";
1469 1469
 
@@ -1472,7 +1472,7 @@  discard block
 block discarded – undo
1472 1472
 		<tbody>
1473 1473
 		<tr><td colspan='2' class='imgedit-response' id='imgedit-response-$post->ID'></td></tr>\n
1474 1474
 		<tr><td style='display:none' colspan='2' class='image-editor' id='image-editor-$post->ID'></td></tr>\n
1475
-		<tr><td colspan='2'><p class='media-types media-types-required-info'>" . sprintf( __( 'Required fields are marked %s' ), '<span class="required">*</span>' ) . "</p></td></tr>\n";
1475
+		<tr><td colspan='2'><p class='media-types media-types-required-info'>".sprintf(__('Required fields are marked %s'), '<span class="required">*</span>')."</p></td></tr>\n";
1476 1476
 
1477 1477
 	$defaults = array(
1478 1478
 		'input'      => 'text',
@@ -1481,25 +1481,25 @@  discard block
 block discarded – undo
1481 1481
 		'extra_rows' => array(),
1482 1482
 	);
1483 1483
 
1484
-	if ( $r['send'] ) {
1485
-		$r['send'] = get_submit_button( __( 'Insert into Post' ), 'button', "send[$attachment_id]", false );
1484
+	if ($r['send']) {
1485
+		$r['send'] = get_submit_button(__('Insert into Post'), 'button', "send[$attachment_id]", false);
1486 1486
 	}
1487 1487
 
1488
-	$delete = empty( $r['delete'] ) ? '' : $r['delete'];
1489
-	if ( $delete && current_user_can( 'delete_post', $attachment_id ) ) {
1490
-		if ( !EMPTY_TRASH_DAYS ) {
1491
-			$delete = "<a href='" . wp_nonce_url( "post.php?action=delete&amp;post=$attachment_id", 'delete-post_' . $attachment_id ) . "' id='del[$attachment_id]' class='delete-permanently'>" . __( 'Delete Permanently' ) . '</a>';
1492
-		} elseif ( !MEDIA_TRASH ) {
1493
-			$delete = "<a href='#' class='del-link' onclick=\"document.getElementById('del_attachment_$attachment_id').style.display='block';return false;\">" . __( 'Delete' ) . "</a>
1494
-			 <div id='del_attachment_$attachment_id' class='del-attachment' style='display:none;'>" .
1488
+	$delete = empty($r['delete']) ? '' : $r['delete'];
1489
+	if ($delete && current_user_can('delete_post', $attachment_id)) {
1490
+		if ( ! EMPTY_TRASH_DAYS) {
1491
+			$delete = "<a href='".wp_nonce_url("post.php?action=delete&amp;post=$attachment_id", 'delete-post_'.$attachment_id)."' id='del[$attachment_id]' class='delete-permanently'>".__('Delete Permanently').'</a>';
1492
+		} elseif ( ! MEDIA_TRASH) {
1493
+			$delete = "<a href='#' class='del-link' onclick=\"document.getElementById('del_attachment_$attachment_id').style.display='block';return false;\">".__('Delete')."</a>
1494
+			 <div id='del_attachment_$attachment_id' class='del-attachment' style='display:none;'>".
1495 1495
 			 /* translators: %s: file name */
1496
-			'<p>' . sprintf( __( 'You are about to delete %s.' ), '<strong>' . $filename . '</strong>' ) . "</p>
1497
-			 <a href='" . wp_nonce_url( "post.php?action=delete&amp;post=$attachment_id", 'delete-post_' . $attachment_id ) . "' id='del[$attachment_id]' class='button'>" . __( 'Continue' ) . "</a>
1498
-			 <a href='#' class='button' onclick=\"this.parentNode.style.display='none';return false;\">" . __( 'Cancel' ) . "</a>
1496
+			'<p>'.sprintf(__('You are about to delete %s.'), '<strong>'.$filename.'</strong>')."</p>
1497
+			 <a href='" . wp_nonce_url("post.php?action=delete&amp;post=$attachment_id", 'delete-post_'.$attachment_id)."' id='del[$attachment_id]' class='button'>".__('Continue')."</a>
1498
+			 <a href='#' class='button' onclick=\"this.parentNode.style.display='none';return false;\">" . __('Cancel')."</a>
1499 1499
 			 </div>";
1500 1500
 		} else {
1501
-			$delete = "<a href='" . wp_nonce_url( "post.php?action=trash&amp;post=$attachment_id", 'trash-post_' . $attachment_id ) . "' id='del[$attachment_id]' class='delete'>" . __( 'Move to Trash' ) . "</a>
1502
-			<a href='" . wp_nonce_url( "post.php?action=untrash&amp;post=$attachment_id", 'untrash-post_' . $attachment_id ) . "' id='undo[$attachment_id]' class='undo hidden'>" . __( 'Undo' ) . "</a>";
1501
+			$delete = "<a href='".wp_nonce_url("post.php?action=trash&amp;post=$attachment_id", 'trash-post_'.$attachment_id)."' id='del[$attachment_id]' class='delete'>".__('Move to Trash')."</a>
1502
+			<a href='" . wp_nonce_url("post.php?action=untrash&amp;post=$attachment_id", 'untrash-post_'.$attachment_id)."' id='undo[$attachment_id]' class='undo hidden'>".__('Undo')."</a>";
1503 1503
 		}
1504 1504
 	} else {
1505 1505
 		$delete = '';
@@ -1507,39 +1507,39 @@  discard block
 block discarded – undo
1507 1507
 
1508 1508
 	$thumbnail = '';
1509 1509
 	$calling_post_id = 0;
1510
-	if ( isset( $_GET['post_id'] ) ) {
1511
-		$calling_post_id = absint( $_GET['post_id'] );
1512
-	} elseif ( isset( $_POST ) && count( $_POST ) ) {// Like for async-upload where $_GET['post_id'] isn't set
1510
+	if (isset($_GET['post_id'])) {
1511
+		$calling_post_id = absint($_GET['post_id']);
1512
+	} elseif (isset($_POST) && count($_POST)) {// Like for async-upload where $_GET['post_id'] isn't set
1513 1513
 		$calling_post_id = $post->post_parent;
1514 1514
 	}
1515
-	if ( 'image' == $type && $calling_post_id && current_theme_supports( 'post-thumbnails', get_post_type( $calling_post_id ) )
1516
-		&& post_type_supports( get_post_type( $calling_post_id ), 'thumbnail' ) && get_post_thumbnail_id( $calling_post_id ) != $attachment_id ) {
1515
+	if ('image' == $type && $calling_post_id && current_theme_supports('post-thumbnails', get_post_type($calling_post_id))
1516
+		&& post_type_supports(get_post_type($calling_post_id), 'thumbnail') && get_post_thumbnail_id($calling_post_id) != $attachment_id) {
1517 1517
 
1518
-		$calling_post = get_post( $calling_post_id );
1519
-		$calling_post_type_object = get_post_type_object( $calling_post->post_type );
1518
+		$calling_post = get_post($calling_post_id);
1519
+		$calling_post_type_object = get_post_type_object($calling_post->post_type);
1520 1520
 
1521
-		$ajax_nonce = wp_create_nonce( "set_post_thumbnail-$calling_post_id" );
1522
-		$thumbnail = "<a class='wp-post-thumbnail' id='wp-post-thumbnail-" . $attachment_id . "' href='#' onclick='WPSetAsThumbnail(\"$attachment_id\", \"$ajax_nonce\");return false;'>" . esc_html( $calling_post_type_object->labels->use_featured_image ) . "</a>";
1521
+		$ajax_nonce = wp_create_nonce("set_post_thumbnail-$calling_post_id");
1522
+		$thumbnail = "<a class='wp-post-thumbnail' id='wp-post-thumbnail-".$attachment_id."' href='#' onclick='WPSetAsThumbnail(\"$attachment_id\", \"$ajax_nonce\");return false;'>".esc_html($calling_post_type_object->labels->use_featured_image)."</a>";
1523 1523
 	}
1524 1524
 
1525
-	if ( ( $r['send'] || $thumbnail || $delete ) && !isset( $form_fields['buttons'] ) ) {
1526
-		$form_fields['buttons'] = array( 'tr' => "\t\t<tr class='submit'><td></td><td class='savesend'>" . $r['send'] . " $thumbnail $delete</td></tr>\n" );
1525
+	if (($r['send'] || $thumbnail || $delete) && ! isset($form_fields['buttons'])) {
1526
+		$form_fields['buttons'] = array('tr' => "\t\t<tr class='submit'><td></td><td class='savesend'>".$r['send']." $thumbnail $delete</td></tr>\n");
1527 1527
 	}
1528 1528
 	$hidden_fields = array();
1529 1529
 
1530
-	foreach ( $form_fields as $id => $field ) {
1531
-		if ( $id[0] == '_' )
1530
+	foreach ($form_fields as $id => $field) {
1531
+		if ($id[0] == '_')
1532 1532
 			continue;
1533 1533
 
1534
-		if ( !empty( $field['tr'] ) ) {
1534
+		if ( ! empty($field['tr'])) {
1535 1535
 			$item .= $field['tr'];
1536 1536
 			continue;
1537 1537
 		}
1538 1538
 
1539
-		$field = array_merge( $defaults, $field );
1539
+		$field = array_merge($defaults, $field);
1540 1540
 		$name = "attachments[$attachment_id][$id]";
1541 1541
 
1542
-		if ( $field['input'] == 'hidden' ) {
1542
+		if ($field['input'] == 'hidden') {
1543 1543
 			$hidden_fields[$name] = $field['value'];
1544 1544
 			continue;
1545 1545
 		}
@@ -1551,47 +1551,47 @@  discard block
 block discarded – undo
1551 1551
 		$class .= $field['required'] ? ' form-required' : '';
1552 1552
 
1553 1553
 		$item .= "\t\t<tr class='$class'>\n\t\t\t<th scope='row' class='label'><label for='$name'><span class='alignleft'>{$field['label']}{$required}</span><br class='clear' /></label></th>\n\t\t\t<td class='field'>";
1554
-		if ( !empty( $field[ $field['input'] ] ) )
1555
-			$item .= $field[ $field['input'] ];
1556
-		elseif ( $field['input'] == 'textarea' ) {
1557
-			if ( 'post_content' == $id && user_can_richedit() ) {
1554
+		if ( ! empty($field[$field['input']]))
1555
+			$item .= $field[$field['input']];
1556
+		elseif ($field['input'] == 'textarea') {
1557
+			if ('post_content' == $id && user_can_richedit()) {
1558 1558
 				// Sanitize_post() skips the post_content when user_can_richedit.
1559
-				$field['value'] = htmlspecialchars( $field['value'], ENT_QUOTES );
1559
+				$field['value'] = htmlspecialchars($field['value'], ENT_QUOTES);
1560 1560
 			}
1561 1561
 			// Post_excerpt is already escaped by sanitize_post() in get_attachment_fields_to_edit().
1562
-			$item .= "<textarea id='$name' name='$name'{$required_attr}{$aria_required}>" . $field['value'] . '</textarea>';
1562
+			$item .= "<textarea id='$name' name='$name'{$required_attr}{$aria_required}>".$field['value'].'</textarea>';
1563 1563
 		} else {
1564
-			$item .= "<input type='text' class='text' id='$name' name='$name' value='" . esc_attr( $field['value'] ) . "'{$required_attr}{$aria_required} />";
1564
+			$item .= "<input type='text' class='text' id='$name' name='$name' value='".esc_attr($field['value'])."'{$required_attr}{$aria_required} />";
1565 1565
 		}
1566
-		if ( !empty( $field['helps'] ) )
1567
-			$item .= "<p class='help'>" . join( "</p>\n<p class='help'>", array_unique( (array) $field['helps'] ) ) . '</p>';
1566
+		if ( ! empty($field['helps']))
1567
+			$item .= "<p class='help'>".join("</p>\n<p class='help'>", array_unique((array) $field['helps'])).'</p>';
1568 1568
 		$item .= "</td>\n\t\t</tr>\n";
1569 1569
 
1570 1570
 		$extra_rows = array();
1571 1571
 
1572
-		if ( !empty( $field['errors'] ) )
1573
-			foreach ( array_unique( (array) $field['errors'] ) as $error )
1572
+		if ( ! empty($field['errors']))
1573
+			foreach (array_unique((array) $field['errors']) as $error)
1574 1574
 				$extra_rows['error'][] = $error;
1575 1575
 
1576
-		if ( !empty( $field['extra_rows'] ) )
1577
-			foreach ( $field['extra_rows'] as $class => $rows )
1578
-				foreach ( (array) $rows as $html )
1576
+		if ( ! empty($field['extra_rows']))
1577
+			foreach ($field['extra_rows'] as $class => $rows)
1578
+				foreach ((array) $rows as $html)
1579 1579
 					$extra_rows[$class][] = $html;
1580 1580
 
1581
-		foreach ( $extra_rows as $class => $rows )
1582
-			foreach ( $rows as $html )
1581
+		foreach ($extra_rows as $class => $rows)
1582
+			foreach ($rows as $html)
1583 1583
 				$item .= "\t\t<tr><td></td><td class='$class'>$html</td></tr>\n";
1584 1584
 	}
1585 1585
 
1586
-	if ( !empty( $form_fields['_final'] ) )
1586
+	if ( ! empty($form_fields['_final']))
1587 1587
 		$item .= "\t\t<tr class='final'><td colspan='2'>{$form_fields['_final']}</td></tr>\n";
1588 1588
 	$item .= "\t</tbody>\n";
1589 1589
 	$item .= "\t</table>\n";
1590 1590
 
1591
-	foreach ( $hidden_fields as $name => $value )
1592
-		$item .= "\t<input type='hidden' name='$name' id='$name' value='" . esc_attr( $value ) . "' />\n";
1591
+	foreach ($hidden_fields as $name => $value)
1592
+		$item .= "\t<input type='hidden' name='$name' id='$name' value='".esc_attr($value)."' />\n";
1593 1593
 
1594
-	if ( $post->post_parent < 1 && isset( $_REQUEST['post_id'] ) ) {
1594
+	if ($post->post_parent < 1 && isset($_REQUEST['post_id'])) {
1595 1595
 		$parent = (int) $_REQUEST['post_id'];
1596 1596
 		$parent_name = "attachments[$attachment_id][post_parent]";
1597 1597
 		$item .= "\t<input type='hidden' name='$parent_name' id='$parent_name' value='$parent' />\n";
@@ -1607,40 +1607,40 @@  discard block
 block discarded – undo
1607 1607
  * @param array $args
1608 1608
  * @return array
1609 1609
  */
1610
-function get_compat_media_markup( $attachment_id, $args = null ) {
1611
-	$post = get_post( $attachment_id );
1610
+function get_compat_media_markup($attachment_id, $args = null) {
1611
+	$post = get_post($attachment_id);
1612 1612
 
1613 1613
 	$default_args = array(
1614 1614
 		'errors' => null,
1615 1615
 		'in_modal' => false,
1616 1616
 	);
1617 1617
 
1618
-	$user_can_edit = current_user_can( 'edit_post', $attachment_id );
1618
+	$user_can_edit = current_user_can('edit_post', $attachment_id);
1619 1619
 
1620
-	$args = wp_parse_args( $args, $default_args );
1620
+	$args = wp_parse_args($args, $default_args);
1621 1621
 
1622 1622
 	/** This filter is documented in wp-admin/includes/media.php */
1623
-	$args = apply_filters( 'get_media_item_args', $args );
1623
+	$args = apply_filters('get_media_item_args', $args);
1624 1624
 
1625 1625
 	$form_fields = array();
1626 1626
 
1627
-	if ( $args['in_modal'] ) {
1628
-		foreach ( get_attachment_taxonomies($post) as $taxonomy ) {
1627
+	if ($args['in_modal']) {
1628
+		foreach (get_attachment_taxonomies($post) as $taxonomy) {
1629 1629
 			$t = (array) get_taxonomy($taxonomy);
1630
-			if ( ! $t['public'] || ! $t['show_ui'] )
1630
+			if ( ! $t['public'] || ! $t['show_ui'])
1631 1631
 				continue;
1632
-			if ( empty($t['label']) )
1632
+			if (empty($t['label']))
1633 1633
 				$t['label'] = $taxonomy;
1634
-			if ( empty($t['args']) )
1634
+			if (empty($t['args']))
1635 1635
 				$t['args'] = array();
1636 1636
 
1637 1637
 			$terms = get_object_term_cache($post->ID, $taxonomy);
1638
-			if ( false === $terms )
1638
+			if (false === $terms)
1639 1639
 				$terms = wp_get_object_terms($post->ID, $taxonomy, $t['args']);
1640 1640
 
1641 1641
 			$values = array();
1642 1642
 
1643
-			foreach ( $terms as $term )
1643
+			foreach ($terms as $term)
1644 1644
 				$values[] = $term->slug;
1645 1645
 			$t['value'] = join(', ', $values);
1646 1646
 			$t['taxonomy'] = true;
@@ -1651,17 +1651,17 @@  discard block
 block discarded – undo
1651 1651
 
1652 1652
 	// Merge default fields with their errors, so any key passed with the error (e.g. 'error', 'helps', 'value') will replace the default
1653 1653
 	// The recursive merge is easily traversed with array casting: foreach ( (array) $things as $thing )
1654
-	$form_fields = array_merge_recursive($form_fields, (array) $args['errors'] );
1654
+	$form_fields = array_merge_recursive($form_fields, (array) $args['errors']);
1655 1655
 
1656 1656
 	/** This filter is documented in wp-admin/includes/media.php */
1657
-	$form_fields = apply_filters( 'attachment_fields_to_edit', $form_fields, $post );
1657
+	$form_fields = apply_filters('attachment_fields_to_edit', $form_fields, $post);
1658 1658
 
1659
-	unset( $form_fields['image-size'], $form_fields['align'], $form_fields['image_alt'],
1659
+	unset($form_fields['image-size'], $form_fields['align'], $form_fields['image_alt'],
1660 1660
 		$form_fields['post_title'], $form_fields['post_excerpt'], $form_fields['post_content'],
1661
-		$form_fields['url'], $form_fields['menu_order'], $form_fields['image_url'] );
1661
+		$form_fields['url'], $form_fields['menu_order'], $form_fields['image_url']);
1662 1662
 
1663 1663
 	/** This filter is documented in wp-admin/includes/media.php */
1664
-	$media_meta = apply_filters( 'media_meta', '', $post );
1664
+	$media_meta = apply_filters('media_meta', '', $post);
1665 1665
 
1666 1666
 	$defaults = array(
1667 1667
 		'input'         => 'text',
@@ -1675,85 +1675,85 @@  discard block
 block discarded – undo
1675 1675
 	$hidden_fields = array();
1676 1676
 
1677 1677
 	$item = '';
1678
-	foreach ( $form_fields as $id => $field ) {
1679
-		if ( $id[0] == '_' )
1678
+	foreach ($form_fields as $id => $field) {
1679
+		if ($id[0] == '_')
1680 1680
 			continue;
1681 1681
 
1682 1682
 		$name = "attachments[$attachment_id][$id]";
1683 1683
 		$id_attr = "attachments-$attachment_id-$id";
1684 1684
 
1685
-		if ( !empty( $field['tr'] ) ) {
1685
+		if ( ! empty($field['tr'])) {
1686 1686
 			$item .= $field['tr'];
1687 1687
 			continue;
1688 1688
 		}
1689 1689
 
1690
-		$field = array_merge( $defaults, $field );
1690
+		$field = array_merge($defaults, $field);
1691 1691
 
1692
-		if ( ( ! $field['show_in_edit'] && ! $args['in_modal'] ) || ( ! $field['show_in_modal'] && $args['in_modal'] ) )
1692
+		if (( ! $field['show_in_edit'] && ! $args['in_modal']) || ( ! $field['show_in_modal'] && $args['in_modal']))
1693 1693
 			continue;
1694 1694
 
1695
-		if ( $field['input'] == 'hidden' ) {
1695
+		if ($field['input'] == 'hidden') {
1696 1696
 			$hidden_fields[$name] = $field['value'];
1697 1697
 			continue;
1698 1698
 		}
1699 1699
 
1700
-		$readonly      = ! $user_can_edit && ! empty( $field['taxonomy'] ) ? " readonly='readonly' " : '';
1700
+		$readonly      = ! $user_can_edit && ! empty($field['taxonomy']) ? " readonly='readonly' " : '';
1701 1701
 		$required      = $field['required'] ? '<span class="required">*</span>' : '';
1702 1702
 		$required_attr = $field['required'] ? ' required' : '';
1703 1703
 		$aria_required = $field['required'] ? " aria-required='true'" : '';
1704
-		$class  = 'compat-field-' . $id;
1704
+		$class  = 'compat-field-'.$id;
1705 1705
 		$class .= $field['required'] ? ' form-required' : '';
1706 1706
 
1707 1707
 		$item .= "\t\t<tr class='$class'>";
1708 1708
 		$item .= "\t\t\t<th scope='row' class='label'><label for='$id_attr'><span class='alignleft'>{$field['label']}</span>$required<br class='clear' /></label>";
1709 1709
 		$item .= "</th>\n\t\t\t<td class='field'>";
1710 1710
 
1711
-		if ( !empty( $field[ $field['input'] ] ) )
1712
-			$item .= $field[ $field['input'] ];
1713
-		elseif ( $field['input'] == 'textarea' ) {
1714
-			if ( 'post_content' == $id && user_can_richedit() ) {
1711
+		if ( ! empty($field[$field['input']]))
1712
+			$item .= $field[$field['input']];
1713
+		elseif ($field['input'] == 'textarea') {
1714
+			if ('post_content' == $id && user_can_richedit()) {
1715 1715
 				// sanitize_post() skips the post_content when user_can_richedit.
1716
-				$field['value'] = htmlspecialchars( $field['value'], ENT_QUOTES );
1716
+				$field['value'] = htmlspecialchars($field['value'], ENT_QUOTES);
1717 1717
 			}
1718
-			$item .= "<textarea id='$id_attr' name='$name'{$required_attr}{$aria_required}>" . $field['value'] . '</textarea>';
1718
+			$item .= "<textarea id='$id_attr' name='$name'{$required_attr}{$aria_required}>".$field['value'].'</textarea>';
1719 1719
 		} else {
1720
-			$item .= "<input type='text' class='text' id='$id_attr' name='$name' value='" . esc_attr( $field['value'] ) . "' $readonly{$required_attr}{$aria_required} />";
1720
+			$item .= "<input type='text' class='text' id='$id_attr' name='$name' value='".esc_attr($field['value'])."' $readonly{$required_attr}{$aria_required} />";
1721 1721
 		}
1722
-		if ( !empty( $field['helps'] ) )
1723
-			$item .= "<p class='help'>" . join( "</p>\n<p class='help'>", array_unique( (array) $field['helps'] ) ) . '</p>';
1722
+		if ( ! empty($field['helps']))
1723
+			$item .= "<p class='help'>".join("</p>\n<p class='help'>", array_unique((array) $field['helps'])).'</p>';
1724 1724
 		$item .= "</td>\n\t\t</tr>\n";
1725 1725
 
1726 1726
 		$extra_rows = array();
1727 1727
 
1728
-		if ( !empty( $field['errors'] ) )
1729
-			foreach ( array_unique( (array) $field['errors'] ) as $error )
1728
+		if ( ! empty($field['errors']))
1729
+			foreach (array_unique((array) $field['errors']) as $error)
1730 1730
 				$extra_rows['error'][] = $error;
1731 1731
 
1732
-		if ( !empty( $field['extra_rows'] ) )
1733
-			foreach ( $field['extra_rows'] as $class => $rows )
1734
-				foreach ( (array) $rows as $html )
1732
+		if ( ! empty($field['extra_rows']))
1733
+			foreach ($field['extra_rows'] as $class => $rows)
1734
+				foreach ((array) $rows as $html)
1735 1735
 					$extra_rows[$class][] = $html;
1736 1736
 
1737
-		foreach ( $extra_rows as $class => $rows )
1738
-			foreach ( $rows as $html )
1737
+		foreach ($extra_rows as $class => $rows)
1738
+			foreach ($rows as $html)
1739 1739
 				$item .= "\t\t<tr><td></td><td class='$class'>$html</td></tr>\n";
1740 1740
 	}
1741 1741
 
1742
-	if ( !empty( $form_fields['_final'] ) )
1742
+	if ( ! empty($form_fields['_final']))
1743 1743
 		$item .= "\t\t<tr class='final'><td colspan='2'>{$form_fields['_final']}</td></tr>\n";
1744 1744
 
1745
-	if ( $item ) {
1746
-		$item = '<p class="media-types media-types-required-info">' .
1747
-			sprintf( __( 'Required fields are marked %s' ), '<span class="required">*</span>' ) . '</p>
1748
-			<table class="compat-attachment-fields">' . $item . '</table>';
1745
+	if ($item) {
1746
+		$item = '<p class="media-types media-types-required-info">'.
1747
+			sprintf(__('Required fields are marked %s'), '<span class="required">*</span>').'</p>
1748
+			<table class="compat-attachment-fields">' . $item.'</table>';
1749 1749
 	}
1750 1750
 
1751
-	foreach ( $hidden_fields as $hidden_field => $value ) {
1752
-		$item .= '<input type="hidden" name="' . esc_attr( $hidden_field ) . '" value="' . esc_attr( $value ) . '" />' . "\n";
1751
+	foreach ($hidden_fields as $hidden_field => $value) {
1752
+		$item .= '<input type="hidden" name="'.esc_attr($hidden_field).'" value="'.esc_attr($value).'" />'."\n";
1753 1753
 	}
1754 1754
 
1755
-	if ( $item )
1756
-		$item = '<input type="hidden" name="attachments[' . $attachment_id . '][menu_order]" value="' . esc_attr( $post->menu_order ) . '" />' . $item;
1755
+	if ($item)
1756
+		$item = '<input type="hidden" name="attachments['.$attachment_id.'][menu_order]" value="'.esc_attr($post->menu_order).'" />'.$item;
1757 1757
 
1758 1758
 	return array(
1759 1759
 		'item'   => $item,
@@ -1767,10 +1767,10 @@  discard block
 block discarded – undo
1767 1767
  * @since 2.5.0
1768 1768
  */
1769 1769
 function media_upload_header() {
1770
-	$post_id = isset( $_REQUEST['post_id'] ) ? intval( $_REQUEST['post_id'] ) : 0;
1770
+	$post_id = isset($_REQUEST['post_id']) ? intval($_REQUEST['post_id']) : 0;
1771 1771
 
1772
-	echo '<script type="text/javascript">post_id = ' . $post_id . ';</script>';
1773
-	if ( empty( $_GET['chromeless'] ) ) {
1772
+	echo '<script type="text/javascript">post_id = '.$post_id.';</script>';
1773
+	if (empty($_GET['chromeless'])) {
1774 1774
 		echo '<div id="media-upload-header">';
1775 1775
 		the_media_upload_tabs();
1776 1776
 		echo '</div>';
@@ -1789,11 +1789,11 @@  discard block
 block discarded – undo
1789 1789
  *
1790 1790
  * @param array $errors
1791 1791
  */
1792
-function media_upload_form( $errors = null ) {
1792
+function media_upload_form($errors = null) {
1793 1793
 	global $type, $tab, $is_IE, $is_opera;
1794 1794
 
1795
-	if ( ! _device_can_upload() ) {
1796
-		echo '<p>' . sprintf( __('The web browser on your device cannot be used to upload files. You may be able to use the <a href="%s">native app for your device</a> instead.'), 'https://apps.wordpress.org/' ) . '</p>';
1795
+	if ( ! _device_can_upload()) {
1796
+		echo '<p>'.sprintf(__('The web browser on your device cannot be used to upload files. You may be able to use the <a href="%s">native app for your device</a> instead.'), 'https://apps.wordpress.org/').'</p>';
1797 1797
 		return;
1798 1798
 	}
1799 1799
 
@@ -1803,14 +1803,14 @@  discard block
 block discarded – undo
1803 1803
 	$_tab = isset($tab) ? $tab : '';
1804 1804
 
1805 1805
 	$max_upload_size = wp_max_upload_size();
1806
-	if ( ! $max_upload_size ) {
1806
+	if ( ! $max_upload_size) {
1807 1807
 		$max_upload_size = 0;
1808 1808
 	}
1809 1809
 ?>
1810 1810
 
1811 1811
 <div id="media-upload-notice"><?php
1812 1812
 
1813
-	if (isset($errors['upload_notice']) )
1813
+	if (isset($errors['upload_notice']))
1814 1814
 		echo $errors['upload_notice'];
1815 1815
 
1816 1816
 ?></div>
@@ -1821,13 +1821,13 @@  discard block
 block discarded – undo
1821 1821
 
1822 1822
 ?></div>
1823 1823
 <?php
1824
-if ( is_multisite() && !is_upload_space_available() ) {
1824
+if (is_multisite() && ! is_upload_space_available()) {
1825 1825
 	/**
1826 1826
 	 * Fires when an upload will exceed the defined upload space quota for a network site.
1827 1827
 	 *
1828 1828
 	 * @since 3.5.0
1829 1829
 	 */
1830
-	do_action( 'upload_ui_over_quota' );
1830
+	do_action('upload_ui_over_quota');
1831 1831
 	return;
1832 1832
 }
1833 1833
 
@@ -1836,7 +1836,7 @@  discard block
 block discarded – undo
1836 1836
  *
1837 1837
  * @since 2.6.0
1838 1838
  */
1839
-do_action( 'pre-upload-ui' );
1839
+do_action('pre-upload-ui');
1840 1840
 
1841 1841
 $post_params = array(
1842 1842
 	"post_id" => $post_id,
@@ -1854,7 +1854,7 @@  discard block
 block discarded – undo
1854 1854
  *
1855 1855
  * @param array $post_params An array of media upload parameters used by Plupload.
1856 1856
  */
1857
-$post_params = apply_filters( 'upload_post_params', $post_params );
1857
+$post_params = apply_filters('upload_post_params', $post_params);
1858 1858
 
1859 1859
 $plupload_init = array(
1860 1860
 	'runtimes'            => 'html5,flash,silverlight,html4',
@@ -1863,18 +1863,18 @@  discard block
 block discarded – undo
1863 1863
 	'drop_element'        => 'drag-drop-area',
1864 1864
 	'file_data_name'      => 'async-upload',
1865 1865
 	'url'                 => $upload_action_url,
1866
-	'flash_swf_url'       => includes_url( 'js/plupload/plupload.flash.swf' ),
1867
-	'silverlight_xap_url' => includes_url( 'js/plupload/plupload.silverlight.xap' ),
1866
+	'flash_swf_url'       => includes_url('js/plupload/plupload.flash.swf'),
1867
+	'silverlight_xap_url' => includes_url('js/plupload/plupload.silverlight.xap'),
1868 1868
 	'filters' => array(
1869
-		'max_file_size'   => $max_upload_size . 'b',
1869
+		'max_file_size'   => $max_upload_size.'b',
1870 1870
 	),
1871 1871
 	'multipart_params'    => $post_params,
1872 1872
 );
1873 1873
 
1874 1874
 // Currently only iOS Safari supports multiple files uploading but iOS 7.x has a bug that prevents uploading of videos
1875 1875
 // when enabled. See #29602.
1876
-if ( wp_is_mobile() && strpos( $_SERVER['HTTP_USER_AGENT'], 'OS 7_' ) !== false &&
1877
-	strpos( $_SERVER['HTTP_USER_AGENT'], 'like Mac OS X' ) !== false ) {
1876
+if (wp_is_mobile() && strpos($_SERVER['HTTP_USER_AGENT'], 'OS 7_') !== false &&
1877
+	strpos($_SERVER['HTTP_USER_AGENT'], 'like Mac OS X') !== false) {
1878 1878
 
1879 1879
 	$plupload_init['multi_selection'] = false;
1880 1880
 }
@@ -1886,22 +1886,22 @@  discard block
 block discarded – undo
1886 1886
  *
1887 1887
  * @param array $plupload_init An array of default settings used by Plupload.
1888 1888
  */
1889
-$plupload_init = apply_filters( 'plupload_init', $plupload_init );
1889
+$plupload_init = apply_filters('plupload_init', $plupload_init);
1890 1890
 
1891 1891
 ?>
1892 1892
 
1893 1893
 <script type="text/javascript">
1894 1894
 <?php
1895 1895
 // Verify size is an int. If not return default value.
1896
-$large_size_h = absint( get_option('large_size_h') );
1897
-if( !$large_size_h )
1896
+$large_size_h = absint(get_option('large_size_h'));
1897
+if ( ! $large_size_h)
1898 1898
 	$large_size_h = 1024;
1899
-$large_size_w = absint( get_option('large_size_w') );
1900
-if( !$large_size_w )
1899
+$large_size_w = absint(get_option('large_size_w'));
1900
+if ( ! $large_size_w)
1901 1901
 	$large_size_w = 1024;
1902 1902
 ?>
1903 1903
 var resize_height = <?php echo $large_size_h; ?>, resize_width = <?php echo $large_size_w; ?>,
1904
-wpUploaderInit = <?php echo wp_json_encode( $plupload_init ); ?>;
1904
+wpUploaderInit = <?php echo wp_json_encode($plupload_init); ?>;
1905 1905
 </script>
1906 1906
 
1907 1907
 <div id="plupload-upload-ui" class="hide-if-no-js">
@@ -1912,7 +1912,7 @@  discard block
 block discarded – undo
1912 1912
  * @since 2.6.0 As 'pre-flash-upload-ui'
1913 1913
  * @since 3.3.0
1914 1914
  */
1915
-do_action( 'pre-plupload-upload-ui' ); ?>
1915
+do_action('pre-plupload-upload-ui'); ?>
1916 1916
 <div id="drag-drop-area">
1917 1917
 	<div class="drag-drop-inside">
1918 1918
 	<p class="drag-drop-info"><?php _e('Drop files here'); ?></p>
@@ -1927,7 +1927,7 @@  discard block
 block discarded – undo
1927 1927
  * @since 2.6.0 As 'post-flash-upload-ui'
1928 1928
  * @since 3.3.0
1929 1929
  */
1930
-do_action( 'post-plupload-upload-ui' ); ?>
1930
+do_action('post-plupload-upload-ui'); ?>
1931 1931
 </div>
1932 1932
 
1933 1933
 <div id="html-upload-ui" class="hide-if-js">
@@ -1937,12 +1937,12 @@  discard block
 block discarded – undo
1937 1937
 	 *
1938 1938
 	 * @since 2.6.0
1939 1939
 	 */
1940
-	do_action( 'pre-html-upload-ui' );
1940
+	do_action('pre-html-upload-ui');
1941 1941
 	?>
1942 1942
 	<p id="async-upload-wrap">
1943 1943
 		<label class="screen-reader-text" for="async-upload"><?php _e('Upload'); ?></label>
1944 1944
 		<input type="file" name="async-upload" id="async-upload" />
1945
-		<?php submit_button( __( 'Upload' ), 'primary', 'html-upload', false ); ?>
1945
+		<?php submit_button(__('Upload'), 'primary', 'html-upload', false); ?>
1946 1946
 		<a href="#" onclick="try{top.tb_remove();}catch(e){}; return false;"><?php _e('Cancel'); ?></a>
1947 1947
 	</p>
1948 1948
 	<div class="clear"></div>
@@ -1952,11 +1952,11 @@  discard block
 block discarded – undo
1952 1952
  *
1953 1953
  * @since 2.6.0
1954 1954
  */
1955
-do_action( 'post-html-upload-ui' );
1955
+do_action('post-html-upload-ui');
1956 1956
 ?>
1957 1957
 </div>
1958 1958
 
1959
-<p class="max-upload-size"><?php printf( __( 'Maximum upload file size: %s.' ), esc_html( size_format( $max_upload_size ) ) ); ?></p>
1959
+<p class="max-upload-size"><?php printf(__('Maximum upload file size: %s.'), esc_html(size_format($max_upload_size))); ?></p>
1960 1960
 <?php
1961 1961
 
1962 1962
 	/**
@@ -1966,7 +1966,7 @@  discard block
 block discarded – undo
1966 1966
 	 *
1967 1967
 	 * @since 2.6.0
1968 1968
 	 */
1969
-	do_action( 'post-upload-ui' );
1969
+	do_action('post-upload-ui');
1970 1970
 }
1971 1971
 
1972 1972
 /**
@@ -1982,7 +1982,7 @@  discard block
 block discarded – undo
1982 1982
 
1983 1983
 	media_upload_header();
1984 1984
 
1985
-	$post_id = isset( $_REQUEST['post_id'] )? intval( $_REQUEST['post_id'] ) : 0;
1985
+	$post_id = isset($_REQUEST['post_id']) ? intval($_REQUEST['post_id']) : 0;
1986 1986
 
1987 1987
 	$form_action_url = admin_url("media-upload.php?type=$type&tab=type&post_id=$post_id");
1988 1988
 
@@ -1994,21 +1994,21 @@  discard block
 block discarded – undo
1994 1994
 	 * @param string $form_action_url The media upload form action URL.
1995 1995
 	 * @param string $type            The type of media. Default 'file'.
1996 1996
 	 */
1997
-	$form_action_url = apply_filters( 'media_upload_form_url', $form_action_url, $type );
1997
+	$form_action_url = apply_filters('media_upload_form_url', $form_action_url, $type);
1998 1998
 	$form_class = 'media-upload-form type-form validate';
1999 1999
 
2000
-	if ( get_user_setting('uploader') )
2000
+	if (get_user_setting('uploader'))
2001 2001
 		$form_class .= ' html-uploader';
2002 2002
 ?>
2003 2003
 
2004
-<form enctype="multipart/form-data" method="post" action="<?php echo esc_url( $form_action_url ); ?>" class="<?php echo $form_class; ?>" id="<?php echo $type; ?>-form">
2005
-<?php submit_button( '', 'hidden', 'save', false ); ?>
2004
+<form enctype="multipart/form-data" method="post" action="<?php echo esc_url($form_action_url); ?>" class="<?php echo $form_class; ?>" id="<?php echo $type; ?>-form">
2005
+<?php submit_button('', 'hidden', 'save', false); ?>
2006 2006
 <input type="hidden" name="post_id" id="post_id" value="<?php echo (int) $post_id; ?>" />
2007 2007
 <?php wp_nonce_field('media-form'); ?>
2008 2008
 
2009 2009
 <h3 class="media-title"><?php _e('Add media files from your computer'); ?></h3>
2010 2010
 
2011
-<?php media_upload_form( $errors ); ?>
2011
+<?php media_upload_form($errors); ?>
2012 2012
 
2013 2013
 <script type="text/javascript">
2014 2014
 jQuery(function($){
@@ -2021,10 +2021,10 @@  discard block
 block discarded – undo
2021 2021
 </script>
2022 2022
 <div id="media-items"><?php
2023 2023
 
2024
-if ( $id ) {
2025
-	if ( !is_wp_error($id) ) {
2024
+if ($id) {
2025
+	if ( ! is_wp_error($id)) {
2026 2026
 		add_filter('attachment_fields_to_edit', 'media_post_single_attachment_fields_to_edit', 10, 2);
2027
-		echo get_media_items( $id, $errors );
2027
+		echo get_media_items($id, $errors);
2028 2028
 	} else {
2029 2029
 		echo '<div id="media-upload-error">'.esc_html($id->get_error_message()).'</div></div>';
2030 2030
 		exit;
@@ -2033,7 +2033,7 @@  discard block
 block discarded – undo
2033 2033
 ?></div>
2034 2034
 
2035 2035
 <p class="savebutton ml-submit">
2036
-<?php submit_button( __( 'Save all changes' ), 'button', 'save', false ); ?>
2036
+<?php submit_button(__('Save all changes'), 'button', 'save', false); ?>
2037 2037
 </p>
2038 2038
 </form>
2039 2039
 <?php
@@ -2049,23 +2049,23 @@  discard block
 block discarded – undo
2049 2049
  * @param integer $id
2050 2050
  */
2051 2051
 function media_upload_type_url_form($type = null, $errors = null, $id = null) {
2052
-	if ( null === $type )
2052
+	if (null === $type)
2053 2053
 		$type = 'image';
2054 2054
 
2055 2055
 	media_upload_header();
2056 2056
 
2057
-	$post_id = isset( $_REQUEST['post_id'] ) ? intval( $_REQUEST['post_id'] ) : 0;
2057
+	$post_id = isset($_REQUEST['post_id']) ? intval($_REQUEST['post_id']) : 0;
2058 2058
 
2059 2059
 	$form_action_url = admin_url("media-upload.php?type=$type&tab=type&post_id=$post_id");
2060 2060
 	/** This filter is documented in wp-admin/includes/media.php */
2061
-	$form_action_url = apply_filters( 'media_upload_form_url', $form_action_url, $type );
2061
+	$form_action_url = apply_filters('media_upload_form_url', $form_action_url, $type);
2062 2062
 	$form_class = 'media-upload-form type-form validate';
2063 2063
 
2064
-	if ( get_user_setting('uploader') )
2064
+	if (get_user_setting('uploader'))
2065 2065
 		$form_class .= ' html-uploader';
2066 2066
 ?>
2067 2067
 
2068
-<form enctype="multipart/form-data" method="post" action="<?php echo esc_url( $form_action_url ); ?>" class="<?php echo $form_class; ?>" id="<?php echo $type; ?>-form">
2068
+<form enctype="multipart/form-data" method="post" action="<?php echo esc_url($form_action_url); ?>" class="<?php echo $form_class; ?>" id="<?php echo $type; ?>-form">
2069 2069
 <input type="hidden" name="post_id" id="post_id" value="<?php echo (int) $post_id; ?>" />
2070 2070
 <?php wp_nonce_field('media-form'); ?>
2071 2071
 
@@ -2089,7 +2089,7 @@  discard block
 block discarded – undo
2089 2089
 
2090 2090
 <?php
2091 2091
 	/** This filter is documented in wp-admin/includes/media.php */
2092
-	if ( ! apply_filters( 'disable_captions', '' ) ) {
2092
+	if ( ! apply_filters('disable_captions', '')) {
2093 2093
 		?>
2094 2094
 		if ( f.caption.value ) {
2095 2095
 			caption = f.caption.value.replace(/\r\n|\r/g, '\n');
@@ -2125,7 +2125,7 @@  discard block
 block discarded – undo
2125 2125
 		document.getElementById('go_button').style.color = '#bbb';
2126 2126
 		if ( ! document.forms[0].src.value )
2127 2127
 			document.getElementById('status_img').innerHTML = '';
2128
-		else document.getElementById('status_img').innerHTML = '<img src="<?php echo esc_url( admin_url( 'images/no.png' ) ); ?>" alt="" />';
2128
+		else document.getElementById('status_img').innerHTML = '<img src="<?php echo esc_url(admin_url('images/no.png')); ?>" alt="" />';
2129 2129
 	},
2130 2130
 
2131 2131
 	updateImageData : function() {
@@ -2134,7 +2134,7 @@  discard block
 block discarded – undo
2134 2134
 		t.width = t.preloadImg.width;
2135 2135
 		t.height = t.preloadImg.height;
2136 2136
 		document.getElementById('go_button').style.color = '#333';
2137
-		document.getElementById('status_img').innerHTML = '<img src="<?php echo esc_url( admin_url( 'images/yes.png' ) ); ?>" alt="" />';
2137
+		document.getElementById('status_img').innerHTML = '<img src="<?php echo esc_url(admin_url('images/yes.png')); ?>" alt="" />';
2138 2138
 	},
2139 2139
 
2140 2140
 	getImageData : function() {
@@ -2148,7 +2148,7 @@  discard block
 block discarded – undo
2148 2148
 			return false;
2149 2149
 		}
2150 2150
 
2151
-		document.getElementById('status_img').innerHTML = '<img src="<?php echo esc_url( admin_url( 'images/spinner-2x.gif' ) ); ?>" alt="" width="16" height="16" />';
2151
+		document.getElementById('status_img').innerHTML = '<img src="<?php echo esc_url(admin_url('images/spinner-2x.gif')); ?>" alt="" width="16" height="16" />';
2152 2152
 		t.preloadImg = new Image();
2153 2153
 		t.preloadImg.onload = t.updateImageData;
2154 2154
 		t.preloadImg.onerror = t.resetImageData;
@@ -2173,7 +2173,7 @@  discard block
 block discarded – undo
2173 2173
  *
2174 2174
  * @param string $form_html The insert from URL form HTML.
2175 2175
  */
2176
-echo apply_filters( 'type_url_form_media', wp_media_insert_url_form( $type ) );
2176
+echo apply_filters('type_url_form_media', wp_media_insert_url_form($type));
2177 2177
 ?>
2178 2178
 </div>
2179 2179
 </div>
@@ -2201,10 +2201,10 @@  discard block
 block discarded – undo
2201 2201
 	$post_id = intval($_REQUEST['post_id']);
2202 2202
 	$form_action_url = admin_url("media-upload.php?type=$type&tab=gallery&post_id=$post_id");
2203 2203
 	/** This filter is documented in wp-admin/includes/media.php */
2204
-	$form_action_url = apply_filters( 'media_upload_form_url', $form_action_url, $type );
2204
+	$form_action_url = apply_filters('media_upload_form_url', $form_action_url, $type);
2205 2205
 	$form_class = 'media-upload-form validate';
2206 2206
 
2207
-	if ( get_user_setting('uploader') )
2207
+	if (get_user_setting('uploader'))
2208 2208
 		$form_class .= ' html-uploader';
2209 2209
 ?>
2210 2210
 
@@ -2228,7 +2228,7 @@  discard block
 block discarded – undo
2228 2228
 <a href="#" id="desc"><?php _e('Descending'); ?></a> |
2229 2229
 <a href="#" id="clear"><?php _ex('Clear', 'verb'); ?></a>
2230 2230
 </div>
2231
-<form enctype="multipart/form-data" method="post" action="<?php echo esc_url( $form_action_url ); ?>" class="<?php echo $form_class; ?>" id="gallery-form">
2231
+<form enctype="multipart/form-data" method="post" action="<?php echo esc_url($form_action_url); ?>" class="<?php echo $form_class; ?>" id="gallery-form">
2232 2232
 <?php wp_nonce_field('media-form'); ?>
2233 2233
 <?php //media_upload_form( $errors ); ?>
2234 2234
 <table class="widefat">
@@ -2244,10 +2244,10 @@  discard block
 block discarded – undo
2244 2244
 </div>
2245 2245
 
2246 2246
 <p class="ml-submit">
2247
-<?php submit_button( __( 'Save all changes' ), 'button savebutton', 'save', false, array( 'id' => 'save-all', 'style' => 'display: none;' ) ); ?>
2247
+<?php submit_button(__('Save all changes'), 'button savebutton', 'save', false, array('id' => 'save-all', 'style' => 'display: none;')); ?>
2248 2248
 <input type="hidden" name="post_id" id="post_id" value="<?php echo (int) $post_id; ?>" />
2249
-<input type="hidden" name="type" value="<?php echo esc_attr( $GLOBALS['type'] ); ?>" />
2250
-<input type="hidden" name="tab" value="<?php echo esc_attr( $GLOBALS['tab'] ); ?>" />
2249
+<input type="hidden" name="type" value="<?php echo esc_attr($GLOBALS['type']); ?>" />
2250
+<input type="hidden" name="tab" value="<?php echo esc_attr($GLOBALS['tab']); ?>" />
2251 2251
 </p>
2252 2252
 
2253 2253
 <div id="gallery-settings" style="display:none;">
@@ -2322,8 +2322,8 @@  discard block
 block discarded – undo
2322 2322
 </tbody></table>
2323 2323
 
2324 2324
 <p class="ml-submit">
2325
-<input type="button" class="button" style="display:none;" onMouseDown="wpgallery.update();" name="insert-gallery" id="insert-gallery" value="<?php esc_attr_e( 'Insert gallery' ); ?>" />
2326
-<input type="button" class="button" style="display:none;" onMouseDown="wpgallery.update();" name="update-gallery" id="update-gallery" value="<?php esc_attr_e( 'Update gallery settings' ); ?>" />
2325
+<input type="button" class="button" style="display:none;" onMouseDown="wpgallery.update();" name="insert-gallery" id="insert-gallery" value="<?php esc_attr_e('Insert gallery'); ?>" />
2326
+<input type="button" class="button" style="display:none;" onMouseDown="wpgallery.update();" name="update-gallery" id="update-gallery" value="<?php esc_attr_e('Update gallery settings'); ?>" />
2327 2327
 </p>
2328 2328
 </div>
2329 2329
 </form>
@@ -2349,42 +2349,42 @@  discard block
 block discarded – undo
2349 2349
 
2350 2350
 	media_upload_header();
2351 2351
 
2352
-	$post_id = isset( $_REQUEST['post_id'] ) ? intval( $_REQUEST['post_id'] ) : 0;
2352
+	$post_id = isset($_REQUEST['post_id']) ? intval($_REQUEST['post_id']) : 0;
2353 2353
 
2354 2354
 	$form_action_url = admin_url("media-upload.php?type=$type&tab=library&post_id=$post_id");
2355 2355
 	/** This filter is documented in wp-admin/includes/media.php */
2356
-	$form_action_url = apply_filters( 'media_upload_form_url', $form_action_url, $type );
2356
+	$form_action_url = apply_filters('media_upload_form_url', $form_action_url, $type);
2357 2357
 	$form_class = 'media-upload-form validate';
2358 2358
 
2359
-	if ( get_user_setting('uploader') )
2359
+	if (get_user_setting('uploader'))
2360 2360
 		$form_class .= ' html-uploader';
2361 2361
 
2362 2362
 	$q = $_GET;
2363 2363
 	$q['posts_per_page'] = 10;
2364
-	$q['paged'] = isset( $q['paged'] ) ? intval( $q['paged'] ) : 0;
2365
-	if ( $q['paged'] < 1 ) {
2364
+	$q['paged'] = isset($q['paged']) ? intval($q['paged']) : 0;
2365
+	if ($q['paged'] < 1) {
2366 2366
 		$q['paged'] = 1;
2367 2367
 	}
2368
-	$q['offset'] = ( $q['paged'] - 1 ) * 10;
2369
-	if ( $q['offset'] < 1 ) {
2368
+	$q['offset'] = ($q['paged'] - 1) * 10;
2369
+	if ($q['offset'] < 1) {
2370 2370
 		$q['offset'] = 0;
2371 2371
 	}
2372 2372
 
2373
-	list($post_mime_types, $avail_post_mime_types) = wp_edit_attachments_query( $q );
2373
+	list($post_mime_types, $avail_post_mime_types) = wp_edit_attachments_query($q);
2374 2374
 
2375 2375
 ?>
2376 2376
 
2377 2377
 <form id="filter" method="get">
2378
-<input type="hidden" name="type" value="<?php echo esc_attr( $type ); ?>" />
2379
-<input type="hidden" name="tab" value="<?php echo esc_attr( $tab ); ?>" />
2378
+<input type="hidden" name="type" value="<?php echo esc_attr($type); ?>" />
2379
+<input type="hidden" name="tab" value="<?php echo esc_attr($tab); ?>" />
2380 2380
 <input type="hidden" name="post_id" value="<?php echo (int) $post_id; ?>" />
2381
-<input type="hidden" name="post_mime_type" value="<?php echo isset( $_GET['post_mime_type'] ) ? esc_attr( $_GET['post_mime_type'] ) : ''; ?>" />
2382
-<input type="hidden" name="context" value="<?php echo isset( $_GET['context'] ) ? esc_attr( $_GET['context'] ) : ''; ?>" />
2381
+<input type="hidden" name="post_mime_type" value="<?php echo isset($_GET['post_mime_type']) ? esc_attr($_GET['post_mime_type']) : ''; ?>" />
2382
+<input type="hidden" name="context" value="<?php echo isset($_GET['context']) ? esc_attr($_GET['context']) : ''; ?>" />
2383 2383
 
2384 2384
 <p id="media-search" class="search-box">
2385
-	<label class="screen-reader-text" for="media-search-input"><?php _e('Search Media');?>:</label>
2385
+	<label class="screen-reader-text" for="media-search-input"><?php _e('Search Media'); ?>:</label>
2386 2386
 	<input type="search" id="media-search-input" name="s" value="<?php the_search_query(); ?>" />
2387
-	<?php submit_button( __( 'Search Media' ), 'button', '', false ); ?>
2387
+	<?php submit_button(__('Search Media'), 'button', '', false); ?>
2388 2388
 </p>
2389 2389
 
2390 2390
 <ul class="subsubsub">
@@ -2392,32 +2392,32 @@  discard block
 block discarded – undo
2392 2392
 $type_links = array();
2393 2393
 $_num_posts = (array) wp_count_attachments();
2394 2394
 $matches = wp_match_mime_types(array_keys($post_mime_types), array_keys($_num_posts));
2395
-foreach ( $matches as $_type => $reals )
2396
-	foreach ( $reals as $real )
2397
-		if ( isset($num_posts[$_type]) )
2395
+foreach ($matches as $_type => $reals)
2396
+	foreach ($reals as $real)
2397
+		if (isset($num_posts[$_type]))
2398 2398
 			$num_posts[$_type] += $_num_posts[$real];
2399 2399
 		else
2400 2400
 			$num_posts[$_type] = $_num_posts[$real];
2401 2401
 // If available type specified by media button clicked, filter by that type
2402
-if ( empty($_GET['post_mime_type']) && !empty($num_posts[$type]) ) {
2402
+if (empty($_GET['post_mime_type']) && ! empty($num_posts[$type])) {
2403 2403
 	$_GET['post_mime_type'] = $type;
2404 2404
 	list($post_mime_types, $avail_post_mime_types) = wp_edit_attachments_query();
2405 2405
 }
2406
-if ( empty($_GET['post_mime_type']) || $_GET['post_mime_type'] == 'all' )
2406
+if (empty($_GET['post_mime_type']) || $_GET['post_mime_type'] == 'all')
2407 2407
 	$class = ' class="current"';
2408 2408
 else
2409 2409
 	$class = '';
2410
-$type_links[] = '<li><a href="' . esc_url(add_query_arg(array('post_mime_type'=>'all', 'paged'=>false, 'm'=>false))) . '"' . $class . '>' . __('All Types') . '</a>';
2411
-foreach ( $post_mime_types as $mime_type => $label ) {
2410
+$type_links[] = '<li><a href="'.esc_url(add_query_arg(array('post_mime_type'=>'all', 'paged'=>false, 'm'=>false))).'"'.$class.'>'.__('All Types').'</a>';
2411
+foreach ($post_mime_types as $mime_type => $label) {
2412 2412
 	$class = '';
2413 2413
 
2414
-	if ( !wp_match_mime_types($mime_type, $avail_post_mime_types) )
2414
+	if ( ! wp_match_mime_types($mime_type, $avail_post_mime_types))
2415 2415
 		continue;
2416 2416
 
2417
-	if ( isset($_GET['post_mime_type']) && wp_match_mime_types($mime_type, $_GET['post_mime_type']) )
2417
+	if (isset($_GET['post_mime_type']) && wp_match_mime_types($mime_type, $_GET['post_mime_type']))
2418 2418
 		$class = ' class="current"';
2419 2419
 
2420
-	$type_links[] = '<li><a href="' . esc_url(add_query_arg(array('post_mime_type'=>$mime_type, 'paged'=>false))) . '"' . $class . '>' . sprintf( translate_nooped_plural( $label[2], $num_posts[$mime_type] ), '<span id="' . $mime_type . '-counter">' . number_format_i18n( $num_posts[$mime_type] ) . '</span>') . '</a>';
2420
+	$type_links[] = '<li><a href="'.esc_url(add_query_arg(array('post_mime_type'=>$mime_type, 'paged'=>false))).'"'.$class.'>'.sprintf(translate_nooped_plural($label[2], $num_posts[$mime_type]), '<span id="'.$mime_type.'-counter">'.number_format_i18n($num_posts[$mime_type]).'</span>').'</a>';
2421 2421
 }
2422 2422
 /**
2423 2423
  * Filters the media upload mime type list items.
@@ -2428,7 +2428,7 @@  discard block
 block discarded – undo
2428 2428
  *
2429 2429
  * @param array $type_links An array of list items containing mime type link HTML.
2430 2430
  */
2431
-echo implode(' | </li>', apply_filters( 'media_upload_mime_type_links', $type_links ) ) . '</li>';
2431
+echo implode(' | </li>', apply_filters('media_upload_mime_type_links', $type_links)).'</li>';
2432 2432
 unset($type_links);
2433 2433
 ?>
2434 2434
 </ul>
@@ -2436,8 +2436,8 @@  discard block
 block discarded – undo
2436 2436
 <div class="tablenav">
2437 2437
 
2438 2438
 <?php
2439
-$page_links = paginate_links( array(
2440
-	'base' => add_query_arg( 'paged', '%#%' ),
2439
+$page_links = paginate_links(array(
2440
+	'base' => add_query_arg('paged', '%#%'),
2441 2441
 	'format' => '',
2442 2442
 	'prev_text' => __('&laquo;'),
2443 2443
 	'next_text' => __('&raquo;'),
@@ -2445,7 +2445,7 @@  discard block
 block discarded – undo
2445 2445
 	'current' => $q['paged'],
2446 2446
 ));
2447 2447
 
2448
-if ( $page_links )
2448
+if ($page_links)
2449 2449
 	echo "<div class='tablenav-pages'>$page_links</div>";
2450 2450
 ?>
2451 2451
 
@@ -2454,34 +2454,34 @@  discard block
 block discarded – undo
2454 2454
 
2455 2455
 $arc_query = "SELECT DISTINCT YEAR(post_date) AS yyear, MONTH(post_date) AS mmonth FROM $wpdb->posts WHERE post_type = 'attachment' ORDER BY post_date DESC";
2456 2456
 
2457
-$arc_result = $wpdb->get_results( $arc_query );
2457
+$arc_result = $wpdb->get_results($arc_query);
2458 2458
 
2459 2459
 $month_count = count($arc_result);
2460
-$selected_month = isset( $_GET['m'] ) ? $_GET['m'] : 0;
2460
+$selected_month = isset($_GET['m']) ? $_GET['m'] : 0;
2461 2461
 
2462
-if ( $month_count && !( 1 == $month_count && 0 == $arc_result[0]->mmonth ) ) { ?>
2462
+if ($month_count && ! (1 == $month_count && 0 == $arc_result[0]->mmonth)) { ?>
2463 2463
 <select name='m'>
2464
-<option<?php selected( $selected_month, 0 ); ?> value='0'><?php _e( 'All dates' ); ?></option>
2464
+<option<?php selected($selected_month, 0); ?> value='0'><?php _e('All dates'); ?></option>
2465 2465
 <?php
2466 2466
 foreach ($arc_result as $arc_row) {
2467
-	if ( $arc_row->yyear == 0 )
2467
+	if ($arc_row->yyear == 0)
2468 2468
 		continue;
2469
-	$arc_row->mmonth = zeroise( $arc_row->mmonth, 2 );
2469
+	$arc_row->mmonth = zeroise($arc_row->mmonth, 2);
2470 2470
 
2471
-	if ( $arc_row->yyear . $arc_row->mmonth == $selected_month )
2471
+	if ($arc_row->yyear.$arc_row->mmonth == $selected_month)
2472 2472
 		$default = ' selected="selected"';
2473 2473
 	else
2474 2474
 		$default = '';
2475 2475
 
2476
-	echo "<option$default value='" . esc_attr( $arc_row->yyear . $arc_row->mmonth ) . "'>";
2477
-	echo esc_html( $wp_locale->get_month($arc_row->mmonth) . " $arc_row->yyear" );
2476
+	echo "<option$default value='".esc_attr($arc_row->yyear.$arc_row->mmonth)."'>";
2477
+	echo esc_html($wp_locale->get_month($arc_row->mmonth)." $arc_row->yyear");
2478 2478
 	echo "</option>\n";
2479 2479
 }
2480 2480
 ?>
2481 2481
 </select>
2482 2482
 <?php } ?>
2483 2483
 
2484
-<?php submit_button( __( 'Filter &#187;' ), 'button', 'post-query-submit', false ); ?>
2484
+<?php submit_button(__('Filter &#187;'), 'button', 'post-query-submit', false); ?>
2485 2485
 
2486 2486
 </div>
2487 2487
 
@@ -2489,7 +2489,7 @@  discard block
 block discarded – undo
2489 2489
 </div>
2490 2490
 </form>
2491 2491
 
2492
-<form enctype="multipart/form-data" method="post" action="<?php echo esc_url( $form_action_url ); ?>" class="<?php echo $form_class; ?>" id="library-form">
2492
+<form enctype="multipart/form-data" method="post" action="<?php echo esc_url($form_action_url); ?>" class="<?php echo $form_class; ?>" id="library-form">
2493 2493
 
2494 2494
 <?php wp_nonce_field('media-form'); ?>
2495 2495
 <?php //media_upload_form( $errors ); ?>
@@ -2511,7 +2511,7 @@  discard block
 block discarded – undo
2511 2511
 <?php echo get_media_items(null, $errors); ?>
2512 2512
 </div>
2513 2513
 <p class="ml-submit">
2514
-<?php submit_button( __( 'Save all changes' ), 'button savebutton', 'save', false ); ?>
2514
+<?php submit_button(__('Save all changes'), 'button savebutton', 'save', false); ?>
2515 2515
 <input type="hidden" name="post_id" id="post_id" value="<?php echo (int) $post_id; ?>" />
2516 2516
 </p>
2517 2517
 </form>
@@ -2526,13 +2526,13 @@  discard block
 block discarded – undo
2526 2526
  * @param string $default_view
2527 2527
  * @return string the form html
2528 2528
  */
2529
-function wp_media_insert_url_form( $default_view = 'image' ) {
2529
+function wp_media_insert_url_form($default_view = 'image') {
2530 2530
 	/** This filter is documented in wp-admin/includes/media.php */
2531
-	if ( ! apply_filters( 'disable_captions', '' ) ) {
2531
+	if ( ! apply_filters('disable_captions', '')) {
2532 2532
 		$caption = '
2533 2533
 		<tr class="image-only">
2534 2534
 			<th scope="row" class="label">
2535
-				<label for="caption"><span class="alignleft">' . __('Image Caption') . '</span></label>
2535
+				<label for="caption"><span class="alignleft">' . __('Image Caption').'</span></label>
2536 2536
 			</th>
2537 2537
 			<td class="field"><textarea id="caption" name="caption"></textarea></td>
2538 2538
 		</tr>
@@ -2542,10 +2542,10 @@  discard block
 block discarded – undo
2542 2542
 	}
2543 2543
 
2544 2544
 	$default_align = get_option('image_default_align');
2545
-	if ( empty($default_align) )
2545
+	if (empty($default_align))
2546 2546
 		$default_align = 'none';
2547 2547
 
2548
-	if ( 'image' == $default_view ) {
2548
+	if ('image' == $default_view) {
2549 2549
 		$view = 'image-only';
2550 2550
 		$table_class = '';
2551 2551
 	} else {
@@ -2553,12 +2553,12 @@  discard block
 block discarded – undo
2553 2553
 	}
2554 2554
 
2555 2555
 	return '
2556
-	<p class="media-types"><label><input type="radio" name="media_type" value="image" id="image-only"' . checked( 'image-only', $view, false ) . ' /> ' . __( 'Image' ) . '</label> &nbsp; &nbsp; <label><input type="radio" name="media_type" value="generic" id="not-image"' . checked( 'not-image', $view, false ) . ' /> ' . __( 'Audio, Video, or Other File' ) . '</label></p>
2557
-	<p class="media-types media-types-required-info">' . sprintf( __( 'Required fields are marked %s' ), '<span class="required">*</span>' ) . '</p>
2558
-	<table class="describe ' . $table_class . '"><tbody>
2556
+	<p class="media-types"><label><input type="radio" name="media_type" value="image" id="image-only"' . checked('image-only', $view, false).' /> '.__('Image').'</label> &nbsp; &nbsp; <label><input type="radio" name="media_type" value="generic" id="not-image"'.checked('not-image', $view, false).' /> '.__('Audio, Video, or Other File').'</label></p>
2557
+	<p class="media-types media-types-required-info">' . sprintf(__('Required fields are marked %s'), '<span class="required">*</span>').'</p>
2558
+	<table class="describe ' . $table_class.'"><tbody>
2559 2559
 		<tr>
2560 2560
 			<th scope="row" class="label" style="width:130px;">
2561
-				<label for="src"><span class="alignleft">' . __( 'URL' ) . '</span> <span class="required">*</span></label>
2561
+				<label for="src"><span class="alignleft">' . __('URL').'</span> <span class="required">*</span></label>
2562 2562
 				<span class="alignright" id="status_img"></span>
2563 2563
 			</th>
2564 2564
 			<td class="field"><input id="src" name="src" value="" type="text" required aria-required="true" onblur="addExtImage.getImageData()" /></td>
@@ -2566,55 +2566,55 @@  discard block
 block discarded – undo
2566 2566
 
2567 2567
 		<tr>
2568 2568
 			<th scope="row" class="label">
2569
-				<label for="title"><span class="alignleft">' . __( 'Title' ) . '</span> <span class="required">*</span></label>
2569
+				<label for="title"><span class="alignleft">' . __('Title').'</span> <span class="required">*</span></label>
2570 2570
 			</th>
2571 2571
 			<td class="field"><input id="title" name="title" value="" type="text" required aria-required="true" /></td>
2572 2572
 		</tr>
2573 2573
 
2574
-		<tr class="not-image"><td></td><td><p class="help">' . __('Link text, e.g. &#8220;Ransom Demands (PDF)&#8221;') . '</p></td></tr>
2574
+		<tr class="not-image"><td></td><td><p class="help">' . __('Link text, e.g. &#8220;Ransom Demands (PDF)&#8221;').'</p></td></tr>
2575 2575
 
2576 2576
 		<tr class="image-only">
2577 2577
 			<th scope="row" class="label">
2578
-				<label for="alt"><span class="alignleft">' . __('Alternative Text') . '</span></label>
2578
+				<label for="alt"><span class="alignleft">' . __('Alternative Text').'</span></label>
2579 2579
 			</th>
2580 2580
 			<td class="field"><input id="alt" name="alt" value="" type="text" aria-required="true" />
2581
-			<p class="help">' . __('Alt text for the image, e.g. &#8220;The Mona Lisa&#8221;') . '</p></td>
2581
+			<p class="help">' . __('Alt text for the image, e.g. &#8220;The Mona Lisa&#8221;').'</p></td>
2582 2582
 		</tr>
2583
-		' . $caption . '
2583
+		' . $caption.'
2584 2584
 		<tr class="align image-only">
2585
-			<th scope="row" class="label"><p><label for="align">' . __('Alignment') . '</label></p></th>
2585
+			<th scope="row" class="label"><p><label for="align">' . __('Alignment').'</label></p></th>
2586 2586
 			<td class="field">
2587 2587
 				<input name="align" id="align-none" value="none" onclick="addExtImage.align=\'align\'+this.value" type="radio"' . ($default_align == 'none' ? ' checked="checked"' : '').' />
2588
-				<label for="align-none" class="align image-align-none-label">' . __('None') . '</label>
2588
+				<label for="align-none" class="align image-align-none-label">' . __('None').'</label>
2589 2589
 				<input name="align" id="align-left" value="left" onclick="addExtImage.align=\'align\'+this.value" type="radio"' . ($default_align == 'left' ? ' checked="checked"' : '').' />
2590
-				<label for="align-left" class="align image-align-left-label">' . __('Left') . '</label>
2590
+				<label for="align-left" class="align image-align-left-label">' . __('Left').'</label>
2591 2591
 				<input name="align" id="align-center" value="center" onclick="addExtImage.align=\'align\'+this.value" type="radio"' . ($default_align == 'center' ? ' checked="checked"' : '').' />
2592
-				<label for="align-center" class="align image-align-center-label">' . __('Center') . '</label>
2592
+				<label for="align-center" class="align image-align-center-label">' . __('Center').'</label>
2593 2593
 				<input name="align" id="align-right" value="right" onclick="addExtImage.align=\'align\'+this.value" type="radio"' . ($default_align == 'right' ? ' checked="checked"' : '').' />
2594
-				<label for="align-right" class="align image-align-right-label">' . __('Right') . '</label>
2594
+				<label for="align-right" class="align image-align-right-label">' . __('Right').'</label>
2595 2595
 			</td>
2596 2596
 		</tr>
2597 2597
 
2598 2598
 		<tr class="image-only">
2599 2599
 			<th scope="row" class="label">
2600
-				<label for="url"><span class="alignleft">' . __('Link Image To:') . '</span></label>
2600
+				<label for="url"><span class="alignleft">' . __('Link Image To:').'</span></label>
2601 2601
 			</th>
2602 2602
 			<td class="field"><input id="url" name="url" value="" type="text" /><br />
2603 2603
 
2604
-			<button type="button" class="button" value="" onclick="document.forms[0].url.value=null">' . __('None') . '</button>
2605
-			<button type="button" class="button" value="" onclick="document.forms[0].url.value=document.forms[0].src.value">' . __('Link to image') . '</button>
2606
-			<p class="help">' . __('Enter a link URL or click above for presets.') . '</p></td>
2604
+			<button type="button" class="button" value="" onclick="document.forms[0].url.value=null">' . __('None').'</button>
2605
+			<button type="button" class="button" value="" onclick="document.forms[0].url.value=document.forms[0].src.value">' . __('Link to image').'</button>
2606
+			<p class="help">' . __('Enter a link URL or click above for presets.').'</p></td>
2607 2607
 		</tr>
2608 2608
 		<tr class="image-only">
2609 2609
 			<td></td>
2610 2610
 			<td>
2611
-				<input type="button" class="button" id="go_button" style="color:#bbb;" onclick="addExtImage.insert()" value="' . esc_attr__('Insert into Post') . '" />
2611
+				<input type="button" class="button" id="go_button" style="color:#bbb;" onclick="addExtImage.insert()" value="' . esc_attr__('Insert into Post').'" />
2612 2612
 			</td>
2613 2613
 		</tr>
2614 2614
 		<tr class="not-image">
2615 2615
 			<td></td>
2616 2616
 			<td>
2617
-				' . get_submit_button( __( 'Insert into Post' ), 'button', 'insertonlybutton', false ) . '
2617
+				' . get_submit_button(__('Insert into Post'), 'button', 'insertonlybutton', false).'
2618 2618
 			</td>
2619 2619
 		</tr>
2620 2620
 	</tbody></table>
@@ -2630,16 +2630,16 @@  discard block
 block discarded – undo
2630 2630
  * @global int $post_ID
2631 2631
  */
2632 2632
 function media_upload_flash_bypass() {
2633
-	$browser_uploader = admin_url( 'media-new.php?browser-uploader' );
2633
+	$browser_uploader = admin_url('media-new.php?browser-uploader');
2634 2634
 
2635
-	if ( $post = get_post() )
2636
-		$browser_uploader .= '&amp;post_id=' . intval( $post->ID );
2637
-	elseif ( ! empty( $GLOBALS['post_ID'] ) )
2638
-		$browser_uploader .= '&amp;post_id=' . intval( $GLOBALS['post_ID'] );
2635
+	if ($post = get_post())
2636
+		$browser_uploader .= '&amp;post_id='.intval($post->ID);
2637
+	elseif ( ! empty($GLOBALS['post_ID']))
2638
+		$browser_uploader .= '&amp;post_id='.intval($GLOBALS['post_ID']);
2639 2639
 
2640 2640
 	?>
2641 2641
 	<p class="upload-flash-bypass">
2642
-	<?php printf( __( 'You are using the multi-file uploader. Problems? Try the <a href="%1$s" target="%2$s">browser uploader</a> instead.' ), $browser_uploader, '_blank' ); ?>
2642
+	<?php printf(__('You are using the multi-file uploader. Problems? Try the <a href="%1$s" target="%2$s">browser uploader</a> instead.'), $browser_uploader, '_blank'); ?>
2643 2643
 	</p>
2644 2644
 	<?php
2645 2645
 }
@@ -2673,8 +2673,8 @@  discard block
 block discarded – undo
2673 2673
 	$checked = get_user_setting('upload_resize') ? ' checked="true"' : '';
2674 2674
 	$a = $end = '';
2675 2675
 
2676
-	if ( current_user_can( 'manage_options' ) ) {
2677
-		$a = '<a href="' . esc_url( admin_url( 'options-media.php' ) ) . '" target="_blank">';
2676
+	if (current_user_can('manage_options')) {
2677
+		$a = '<a href="'.esc_url(admin_url('options-media.php')).'" target="_blank">';
2678 2678
 		$end = '</a>';
2679 2679
 	}
2680 2680
 ?>
@@ -2682,7 +2682,7 @@  discard block
 block discarded – undo
2682 2682
 <input name="image_resize" type="checkbox" id="image_resize" value="true"<?php echo $checked; ?> />
2683 2683
 <?php
2684 2684
 	/* translators: %1$s is link start tag, %2$s is link end tag, %3$d is width, %4$d is height*/
2685
-	printf( __( 'Scale images to match the large size selected in %1$simage options%2$s (%3$d &times; %4$d).' ), $a, $end, (int) get_option( 'large_size_w', '1024' ), (int) get_option( 'large_size_h', '1024' ) );
2685
+	printf(__('Scale images to match the large size selected in %1$simage options%2$s (%3$d &times; %4$d).'), $a, $end, (int) get_option('large_size_w', '1024'), (int) get_option('large_size_h', '1024'));
2686 2686
 ?>
2687 2687
 </label></p>
2688 2688
 <?php
@@ -2694,7 +2694,7 @@  discard block
 block discarded – undo
2694 2694
  * @since 3.5.0
2695 2695
  */
2696 2696
 function multisite_over_quota_message() {
2697
-	echo '<p>' . sprintf( __( 'Sorry, you have used all of your storage quota of %s MB.' ), get_space_allowed() ) . '</p>';
2697
+	echo '<p>'.sprintf(__('Sorry, you have used all of your storage quota of %s MB.'), get_space_allowed()).'</p>';
2698 2698
 }
2699 2699
 
2700 2700
 /**
@@ -2704,67 +2704,67 @@  discard block
 block discarded – undo
2704 2704
  *
2705 2705
  * @param WP_Post $post A post object.
2706 2706
  */
2707
-function edit_form_image_editor( $post ) {
2708
-	$open = isset( $_GET['image-editor'] );
2709
-	if ( $open )
2710
-		require_once ABSPATH . 'wp-admin/includes/image-edit.php';
2707
+function edit_form_image_editor($post) {
2708
+	$open = isset($_GET['image-editor']);
2709
+	if ($open)
2710
+		require_once ABSPATH.'wp-admin/includes/image-edit.php';
2711 2711
 
2712 2712
 	$thumb_url = false;
2713
-	if ( $attachment_id = intval( $post->ID ) )
2714
-		$thumb_url = wp_get_attachment_image_src( $attachment_id, array( 900, 450 ), true );
2713
+	if ($attachment_id = intval($post->ID))
2714
+		$thumb_url = wp_get_attachment_image_src($attachment_id, array(900, 450), true);
2715 2715
 
2716
-	$alt_text = get_post_meta( $post->ID, '_wp_attachment_image_alt', true );
2716
+	$alt_text = get_post_meta($post->ID, '_wp_attachment_image_alt', true);
2717 2717
 
2718
-	$att_url = wp_get_attachment_url( $post->ID ); ?>
2718
+	$att_url = wp_get_attachment_url($post->ID); ?>
2719 2719
 	<div class="wp_attachment_holder wp-clearfix">
2720 2720
 	<?php
2721
-	if ( wp_attachment_is_image( $post->ID ) ) :
2721
+	if (wp_attachment_is_image($post->ID)) :
2722 2722
 		$image_edit_button = '';
2723
-		if ( wp_image_editor_supports( array( 'mime_type' => $post->post_mime_type ) ) ) {
2724
-			$nonce = wp_create_nonce( "image_editor-$post->ID" );
2725
-			$image_edit_button = "<input type='button' id='imgedit-open-btn-$post->ID' onclick='imageEdit.open( $post->ID, \"$nonce\" )' class='button' value='" . esc_attr__( 'Edit Image' ) . "' /> <span class='spinner'></span>";
2723
+		if (wp_image_editor_supports(array('mime_type' => $post->post_mime_type))) {
2724
+			$nonce = wp_create_nonce("image_editor-$post->ID");
2725
+			$image_edit_button = "<input type='button' id='imgedit-open-btn-$post->ID' onclick='imageEdit.open( $post->ID, \"$nonce\" )' class='button' value='".esc_attr__('Edit Image')."' /> <span class='spinner'></span>";
2726 2726
 		}
2727 2727
 	?>
2728 2728
 
2729 2729
 		<div class="imgedit-response" id="imgedit-response-<?php echo $attachment_id; ?>"></div>
2730 2730
 
2731
-		<div<?php if ( $open ) echo ' style="display:none"'; ?> class="wp_attachment_image wp-clearfix" id="media-head-<?php echo $attachment_id; ?>">
2732
-			<p id="thumbnail-head-<?php echo $attachment_id; ?>"><img class="thumbnail" src="<?php echo set_url_scheme( $thumb_url[0] ); ?>" style="max-width:100%" alt="" /></p>
2731
+		<div<?php if ($open) echo ' style="display:none"'; ?> class="wp_attachment_image wp-clearfix" id="media-head-<?php echo $attachment_id; ?>">
2732
+			<p id="thumbnail-head-<?php echo $attachment_id; ?>"><img class="thumbnail" src="<?php echo set_url_scheme($thumb_url[0]); ?>" style="max-width:100%" alt="" /></p>
2733 2733
 			<p><?php echo $image_edit_button; ?></p>
2734 2734
 		</div>
2735
-		<div<?php if ( ! $open ) echo ' style="display:none"'; ?> class="image-editor" id="image-editor-<?php echo $attachment_id; ?>">
2736
-			<?php if ( $open ) wp_image_editor( $attachment_id ); ?>
2735
+		<div<?php if ( ! $open) echo ' style="display:none"'; ?> class="image-editor" id="image-editor-<?php echo $attachment_id; ?>">
2736
+			<?php if ($open) wp_image_editor($attachment_id); ?>
2737 2737
 		</div>
2738 2738
 	<?php
2739
-	elseif ( $attachment_id && wp_attachment_is( 'audio', $post ) ):
2739
+	elseif ($attachment_id && wp_attachment_is('audio', $post)):
2740 2740
 
2741
-		wp_maybe_generate_attachment_metadata( $post );
2741
+		wp_maybe_generate_attachment_metadata($post);
2742 2742
 
2743
-		echo wp_audio_shortcode( array( 'src' => $att_url ) );
2743
+		echo wp_audio_shortcode(array('src' => $att_url));
2744 2744
 
2745
-	elseif ( $attachment_id && wp_attachment_is( 'video', $post ) ):
2745
+	elseif ($attachment_id && wp_attachment_is('video', $post)):
2746 2746
 
2747
-		wp_maybe_generate_attachment_metadata( $post );
2747
+		wp_maybe_generate_attachment_metadata($post);
2748 2748
 
2749
-		$meta = wp_get_attachment_metadata( $attachment_id );
2750
-		$w = ! empty( $meta['width'] ) ? min( $meta['width'], 640 ) : 0;
2751
-		$h = ! empty( $meta['height'] ) ? $meta['height'] : 0;
2752
-		if ( $h && $w < $meta['width'] ) {
2753
-			$h = round( ( $meta['height'] * $w ) / $meta['width'] );
2749
+		$meta = wp_get_attachment_metadata($attachment_id);
2750
+		$w = ! empty($meta['width']) ? min($meta['width'], 640) : 0;
2751
+		$h = ! empty($meta['height']) ? $meta['height'] : 0;
2752
+		if ($h && $w < $meta['width']) {
2753
+			$h = round(($meta['height'] * $w) / $meta['width']);
2754 2754
 		}
2755 2755
 
2756
-		$attr = array( 'src' => $att_url );
2757
-		if ( ! empty( $w ) && ! empty( $h ) ) {
2756
+		$attr = array('src' => $att_url);
2757
+		if ( ! empty($w) && ! empty($h)) {
2758 2758
 			$attr['width'] = $w;
2759 2759
 			$attr['height'] = $h;
2760 2760
 		}
2761 2761
 
2762
-		$thumb_id = get_post_thumbnail_id( $attachment_id );
2763
-		if ( ! empty( $thumb_id ) ) {
2764
-			$attr['poster'] = wp_get_attachment_url( $thumb_id );
2762
+		$thumb_id = get_post_thumbnail_id($attachment_id);
2763
+		if ( ! empty($thumb_id)) {
2764
+			$attr['poster'] = wp_get_attachment_url($thumb_id);
2765 2765
 		}
2766 2766
 
2767
-		echo wp_video_shortcode( $attr );
2767
+		echo wp_video_shortcode($attr);
2768 2768
 
2769 2769
 	else :
2770 2770
 
@@ -2775,26 +2775,26 @@  discard block
 block discarded – undo
2775 2775
 		 *
2776 2776
 		 * @param WP_Post $post A post object.
2777 2777
 		 */
2778
-		do_action( 'wp_edit_form_attachment_display', $post );
2778
+		do_action('wp_edit_form_attachment_display', $post);
2779 2779
 
2780 2780
 	endif; ?>
2781 2781
 	</div>
2782 2782
 	<div class="wp_attachment_details edit-form-section">
2783 2783
 		<p>
2784
-			<label for="attachment_caption"><strong><?php _e( 'Caption' ); ?></strong></label><br />
2784
+			<label for="attachment_caption"><strong><?php _e('Caption'); ?></strong></label><br />
2785 2785
 			<textarea class="widefat" name="excerpt" id="attachment_caption"><?php echo $post->post_excerpt; ?></textarea>
2786 2786
 		</p>
2787 2787
 
2788 2788
 
2789
-	<?php if ( 'image' === substr( $post->post_mime_type, 0, 5 ) ) : ?>
2789
+	<?php if ('image' === substr($post->post_mime_type, 0, 5)) : ?>
2790 2790
 		<p>
2791
-			<label for="attachment_alt"><strong><?php _e( 'Alternative Text' ); ?></strong></label><br />
2792
-			<input type="text" class="widefat" name="_wp_attachment_image_alt" id="attachment_alt" value="<?php echo esc_attr( $alt_text ); ?>" />
2791
+			<label for="attachment_alt"><strong><?php _e('Alternative Text'); ?></strong></label><br />
2792
+			<input type="text" class="widefat" name="_wp_attachment_image_alt" id="attachment_alt" value="<?php echo esc_attr($alt_text); ?>" />
2793 2793
 		</p>
2794 2794
 	<?php endif; ?>
2795 2795
 
2796 2796
 	<?php
2797
-		$quicktags_settings = array( 'buttons' => 'strong,em,link,block,del,ins,img,ul,ol,li,code,close' );
2797
+		$quicktags_settings = array('buttons' => 'strong,em,link,block,del,ins,img,ul,ol,li,code,close');
2798 2798
 		$editor_args = array(
2799 2799
 			'textarea_name' => 'content',
2800 2800
 			'textarea_rows' => 5,
@@ -2804,17 +2804,17 @@  discard block
 block discarded – undo
2804 2804
 		);
2805 2805
 	?>
2806 2806
 
2807
-	<label for="attachment_content"><strong><?php _e( 'Description' ); ?></strong><?php
2808
-	if ( preg_match( '#^(audio|video)/#', $post->post_mime_type ) ) {
2809
-		echo ': ' . __( 'Displayed on attachment pages.' );
2807
+	<label for="attachment_content"><strong><?php _e('Description'); ?></strong><?php
2808
+	if (preg_match('#^(audio|video)/#', $post->post_mime_type)) {
2809
+		echo ': '.__('Displayed on attachment pages.');
2810 2810
 	} ?></label>
2811
-	<?php wp_editor( $post->post_content, 'attachment_content', $editor_args ); ?>
2811
+	<?php wp_editor($post->post_content, 'attachment_content', $editor_args); ?>
2812 2812
 
2813 2813
 	</div>
2814 2814
 	<?php
2815
-	$extras = get_compat_media_markup( $post->ID );
2815
+	$extras = get_compat_media_markup($post->ID);
2816 2816
 	echo $extras['item'];
2817
-	echo '<input type="hidden" id="image-edit-context" value="edit-attachment" />' . "\n";
2817
+	echo '<input type="hidden" id="image-edit-context" value="edit-attachment" />'."\n";
2818 2818
 }
2819 2819
 
2820 2820
 /**
@@ -2825,37 +2825,37 @@  discard block
 block discarded – undo
2825 2825
 function attachment_submitbox_metadata() {
2826 2826
 	$post = get_post();
2827 2827
 
2828
-	$file = get_attached_file( $post->ID );
2829
-	$filename = esc_html( wp_basename( $file ) );
2828
+	$file = get_attached_file($post->ID);
2829
+	$filename = esc_html(wp_basename($file));
2830 2830
 
2831 2831
 	$media_dims = '';
2832
-	$meta = wp_get_attachment_metadata( $post->ID );
2833
-	if ( isset( $meta['width'], $meta['height'] ) )
2832
+	$meta = wp_get_attachment_metadata($post->ID);
2833
+	if (isset($meta['width'], $meta['height']))
2834 2834
 		$media_dims .= "<span id='media-dims-$post->ID'>{$meta['width']}&nbsp;&times;&nbsp;{$meta['height']}</span> ";
2835 2835
 	/** This filter is documented in wp-admin/includes/media.php */
2836
-	$media_dims = apply_filters( 'media_meta', $media_dims, $post );
2836
+	$media_dims = apply_filters('media_meta', $media_dims, $post);
2837 2837
 
2838
-	$att_url = wp_get_attachment_url( $post->ID );
2838
+	$att_url = wp_get_attachment_url($post->ID);
2839 2839
 ?>
2840 2840
 	<div class="misc-pub-section misc-pub-attachment">
2841
-		<label for="attachment_url"><?php _e( 'File URL:' ); ?></label>
2842
-		<input type="text" class="widefat urlfield" readonly="readonly" name="attachment_url" id="attachment_url" value="<?php echo esc_attr( $att_url ); ?>" />
2841
+		<label for="attachment_url"><?php _e('File URL:'); ?></label>
2842
+		<input type="text" class="widefat urlfield" readonly="readonly" name="attachment_url" id="attachment_url" value="<?php echo esc_attr($att_url); ?>" />
2843 2843
 	</div>
2844 2844
 	<div class="misc-pub-section misc-pub-filename">
2845
-		<?php _e( 'File name:' ); ?> <strong><?php echo $filename; ?></strong>
2845
+		<?php _e('File name:'); ?> <strong><?php echo $filename; ?></strong>
2846 2846
 	</div>
2847 2847
 	<div class="misc-pub-section misc-pub-filetype">
2848
-		<?php _e( 'File type:' ); ?> <strong><?php
2849
-			if ( preg_match( '/^.*?\.(\w+)$/', get_attached_file( $post->ID ), $matches ) ) {
2850
-				echo esc_html( strtoupper( $matches[1] ) );
2851
-				list( $mime_type ) = explode( '/', $post->post_mime_type );
2852
-				if ( $mime_type !== 'image' && ! empty( $meta['mime_type'] ) ) {
2853
-					if ( $meta['mime_type'] !== "$mime_type/" . strtolower( $matches[1] ) ) {
2854
-						echo ' (' . $meta['mime_type'] . ')';
2848
+		<?php _e('File type:'); ?> <strong><?php
2849
+			if (preg_match('/^.*?\.(\w+)$/', get_attached_file($post->ID), $matches)) {
2850
+				echo esc_html(strtoupper($matches[1]));
2851
+				list($mime_type) = explode('/', $post->post_mime_type);
2852
+				if ($mime_type !== 'image' && ! empty($meta['mime_type'])) {
2853
+					if ($meta['mime_type'] !== "$mime_type/".strtolower($matches[1])) {
2854
+						echo ' ('.$meta['mime_type'].')';
2855 2855
 					}
2856 2856
 				}
2857 2857
 			} else {
2858
-				echo strtoupper( str_replace( 'image/', '', $post->post_mime_type ) );
2858
+				echo strtoupper(str_replace('image/', '', $post->post_mime_type));
2859 2859
 			}
2860 2860
 		?></strong>
2861 2861
 	</div>
@@ -2863,19 +2863,19 @@  discard block
 block discarded – undo
2863 2863
 	<?php
2864 2864
 		$file_size = false;
2865 2865
 
2866
-		if ( isset( $meta['filesize'] ) )
2866
+		if (isset($meta['filesize']))
2867 2867
 			$file_size = $meta['filesize'];
2868
-		elseif ( file_exists( $file ) )
2869
-			$file_size = filesize( $file );
2868
+		elseif (file_exists($file))
2869
+			$file_size = filesize($file);
2870 2870
 
2871
-		if ( ! empty( $file_size ) ) : ?>
2871
+		if ( ! empty($file_size)) : ?>
2872 2872
 			<div class="misc-pub-section misc-pub-filesize">
2873
-				<?php _e( 'File size:' ); ?> <strong><?php echo size_format( $file_size ); ?></strong>
2873
+				<?php _e('File size:'); ?> <strong><?php echo size_format($file_size); ?></strong>
2874 2874
 			</div>
2875 2875
 			<?php
2876 2876
 		endif;
2877 2877
 
2878
-	if ( preg_match( '#^(audio|video)/#', $post->post_mime_type ) ) {
2878
+	if (preg_match('#^(audio|video)/#', $post->post_mime_type)) {
2879 2879
 
2880 2880
 		/**
2881 2881
 		 * Filters the audio and video metadata fields to be shown in the publish meta box.
@@ -2887,27 +2887,27 @@  discard block
 block discarded – undo
2887 2887
 		 *
2888 2888
 		 * @param array $fields An array of the attachment metadata keys and labels.
2889 2889
 		 */
2890
-		$fields = apply_filters( 'media_submitbox_misc_sections', array(
2891
-			'length_formatted' => __( 'Length:' ),
2892
-			'bitrate'          => __( 'Bitrate:' ),
2893
-		) );
2890
+		$fields = apply_filters('media_submitbox_misc_sections', array(
2891
+			'length_formatted' => __('Length:'),
2892
+			'bitrate'          => __('Bitrate:'),
2893
+		));
2894 2894
 
2895
-		foreach ( $fields as $key => $label ) {
2896
-			if ( empty( $meta[ $key ] ) ) {
2895
+		foreach ($fields as $key => $label) {
2896
+			if (empty($meta[$key])) {
2897 2897
 				continue;
2898 2898
 			}
2899 2899
 	?>
2900
-		<div class="misc-pub-section misc-pub-mime-meta misc-pub-<?php echo sanitize_html_class( $key ); ?>">
2900
+		<div class="misc-pub-section misc-pub-mime-meta misc-pub-<?php echo sanitize_html_class($key); ?>">
2901 2901
 			<?php echo $label ?> <strong><?php
2902
-				switch ( $key ) {
2902
+				switch ($key) {
2903 2903
 					case 'bitrate' :
2904
-						echo round( $meta['bitrate'] / 1000 ) . 'kb/s';
2905
-						if ( ! empty( $meta['bitrate_mode'] ) ) {
2906
-							echo ' ' . strtoupper( esc_html( $meta['bitrate_mode'] ) );
2904
+						echo round($meta['bitrate'] / 1000).'kb/s';
2905
+						if ( ! empty($meta['bitrate_mode'])) {
2906
+							echo ' '.strtoupper(esc_html($meta['bitrate_mode']));
2907 2907
 						}
2908 2908
 						break;
2909 2909
 					default:
2910
-						echo esc_html( $meta[ $key ] );
2910
+						echo esc_html($meta[$key]);
2911 2911
 						break;
2912 2912
 				}
2913 2913
 			?></strong>
@@ -2925,27 +2925,27 @@  discard block
 block discarded – undo
2925 2925
 		 *
2926 2926
 		 * @param array $fields An array of the attachment metadata keys and labels.
2927 2927
 		 */
2928
-		$audio_fields = apply_filters( 'audio_submitbox_misc_sections', array(
2929
-			'dataformat' => __( 'Audio Format:' ),
2930
-			'codec'      => __( 'Audio Codec:' )
2931
-		) );
2928
+		$audio_fields = apply_filters('audio_submitbox_misc_sections', array(
2929
+			'dataformat' => __('Audio Format:'),
2930
+			'codec'      => __('Audio Codec:')
2931
+		));
2932 2932
 
2933
-		foreach ( $audio_fields as $key => $label ) {
2934
-			if ( empty( $meta['audio'][ $key ] ) ) {
2933
+		foreach ($audio_fields as $key => $label) {
2934
+			if (empty($meta['audio'][$key])) {
2935 2935
 				continue;
2936 2936
 			}
2937 2937
 	?>
2938
-		<div class="misc-pub-section misc-pub-audio misc-pub-<?php echo sanitize_html_class( $key ); ?>">
2939
-			<?php echo $label; ?> <strong><?php echo esc_html( $meta['audio'][$key] ); ?></strong>
2938
+		<div class="misc-pub-section misc-pub-audio misc-pub-<?php echo sanitize_html_class($key); ?>">
2939
+			<?php echo $label; ?> <strong><?php echo esc_html($meta['audio'][$key]); ?></strong>
2940 2940
 		</div>
2941 2941
 	<?php
2942 2942
 		}
2943 2943
 
2944 2944
 	}
2945 2945
 
2946
-	if ( $media_dims ) : ?>
2946
+	if ($media_dims) : ?>
2947 2947
 	<div class="misc-pub-section misc-pub-dimensions">
2948
-		<?php _e( 'Dimensions:' ); ?> <strong><?php echo $media_dims; ?></strong>
2948
+		<?php _e('Dimensions:'); ?> <strong><?php echo $media_dims; ?></strong>
2949 2949
 	</div>
2950 2950
 <?php
2951 2951
 	endif;
@@ -2959,24 +2959,24 @@  discard block
 block discarded – undo
2959 2959
  * @param array $metadata An existing array with data
2960 2960
  * @param array $data Data supplied by ID3 tags
2961 2961
  */
2962
-function wp_add_id3_tag_data( &$metadata, $data ) {
2963
-	foreach ( array( 'id3v2', 'id3v1' ) as $version ) {
2964
-		if ( ! empty( $data[$version]['comments'] ) ) {
2965
-			foreach ( $data[$version]['comments'] as $key => $list ) {
2966
-				if ( 'length' !== $key && ! empty( $list ) ) {
2967
-					$metadata[$key] = reset( $list );
2962
+function wp_add_id3_tag_data(&$metadata, $data) {
2963
+	foreach (array('id3v2', 'id3v1') as $version) {
2964
+		if ( ! empty($data[$version]['comments'])) {
2965
+			foreach ($data[$version]['comments'] as $key => $list) {
2966
+				if ('length' !== $key && ! empty($list)) {
2967
+					$metadata[$key] = reset($list);
2968 2968
 					// Fix bug in byte stream analysis.
2969
-					if ( 'terms_of_use' === $key && 0 === strpos( $metadata[$key], 'yright notice.' ) )
2970
-						$metadata[$key] = 'Cop' . $metadata[$key];
2969
+					if ('terms_of_use' === $key && 0 === strpos($metadata[$key], 'yright notice.'))
2970
+						$metadata[$key] = 'Cop'.$metadata[$key];
2971 2971
 				}
2972 2972
 			}
2973 2973
 			break;
2974 2974
 		}
2975 2975
 	}
2976 2976
 
2977
-	if ( ! empty( $data['id3v2']['APIC'] ) ) {
2978
-		$image = reset( $data['id3v2']['APIC']);
2979
-		if ( ! empty( $image['data'] ) ) {
2977
+	if ( ! empty($data['id3v2']['APIC'])) {
2978
+		$image = reset($data['id3v2']['APIC']);
2979
+		if ( ! empty($image['data'])) {
2980 2980
 			$metadata['image'] = array(
2981 2981
 				'data' => $image['data'],
2982 2982
 				'mime' => $image['image_mime'],
@@ -2984,9 +2984,9 @@  discard block
 block discarded – undo
2984 2984
 				'height' => $image['image_height']
2985 2985
 			);
2986 2986
 		}
2987
-	} elseif ( ! empty( $data['comments']['picture'] ) ) {
2988
-		$image = reset( $data['comments']['picture'] );
2989
-		if ( ! empty( $image['data'] ) ) {
2987
+	} elseif ( ! empty($data['comments']['picture'])) {
2988
+		$image = reset($data['comments']['picture']);
2989
+		if ( ! empty($image['data'])) {
2990 2990
 			$metadata['image'] = array(
2991 2991
 				'data' => $image['data'],
2992 2992
 				'mime' => $image['image_mime']
@@ -3003,56 +3003,56 @@  discard block
 block discarded – undo
3003 3003
  * @param string $file Path to file.
3004 3004
  * @return array|bool Returns array of metadata, if found.
3005 3005
  */
3006
-function wp_read_video_metadata( $file ) {
3007
-	if ( ! file_exists( $file ) ) {
3006
+function wp_read_video_metadata($file) {
3007
+	if ( ! file_exists($file)) {
3008 3008
 		return false;
3009 3009
 	}
3010 3010
 
3011 3011
 	$metadata = array();
3012 3012
 
3013
-	if ( ! defined( 'GETID3_TEMP_DIR' ) ) {
3014
-		define( 'GETID3_TEMP_DIR', get_temp_dir() );
3013
+	if ( ! defined('GETID3_TEMP_DIR')) {
3014
+		define('GETID3_TEMP_DIR', get_temp_dir());
3015 3015
 	}
3016 3016
 
3017
-	if ( ! class_exists( 'getID3', false ) ) {
3018
-		require( ABSPATH . WPINC . '/ID3/getid3.php' );
3017
+	if ( ! class_exists('getID3', false)) {
3018
+		require(ABSPATH.WPINC.'/ID3/getid3.php');
3019 3019
 	}
3020 3020
 	$id3 = new getID3();
3021
-	$data = $id3->analyze( $file );
3021
+	$data = $id3->analyze($file);
3022 3022
 
3023
-	if ( isset( $data['video']['lossless'] ) )
3023
+	if (isset($data['video']['lossless']))
3024 3024
 		$metadata['lossless'] = $data['video']['lossless'];
3025
-	if ( ! empty( $data['video']['bitrate'] ) )
3025
+	if ( ! empty($data['video']['bitrate']))
3026 3026
 		$metadata['bitrate'] = (int) $data['video']['bitrate'];
3027
-	if ( ! empty( $data['video']['bitrate_mode'] ) )
3027
+	if ( ! empty($data['video']['bitrate_mode']))
3028 3028
 		$metadata['bitrate_mode'] = $data['video']['bitrate_mode'];
3029
-	if ( ! empty( $data['filesize'] ) )
3029
+	if ( ! empty($data['filesize']))
3030 3030
 		$metadata['filesize'] = (int) $data['filesize'];
3031
-	if ( ! empty( $data['mime_type'] ) )
3031
+	if ( ! empty($data['mime_type']))
3032 3032
 		$metadata['mime_type'] = $data['mime_type'];
3033
-	if ( ! empty( $data['playtime_seconds'] ) )
3034
-		$metadata['length'] = (int) round( $data['playtime_seconds'] );
3035
-	if ( ! empty( $data['playtime_string'] ) )
3033
+	if ( ! empty($data['playtime_seconds']))
3034
+		$metadata['length'] = (int) round($data['playtime_seconds']);
3035
+	if ( ! empty($data['playtime_string']))
3036 3036
 		$metadata['length_formatted'] = $data['playtime_string'];
3037
-	if ( ! empty( $data['video']['resolution_x'] ) )
3037
+	if ( ! empty($data['video']['resolution_x']))
3038 3038
 		$metadata['width'] = (int) $data['video']['resolution_x'];
3039
-	if ( ! empty( $data['video']['resolution_y'] ) )
3039
+	if ( ! empty($data['video']['resolution_y']))
3040 3040
 		$metadata['height'] = (int) $data['video']['resolution_y'];
3041
-	if ( ! empty( $data['fileformat'] ) )
3041
+	if ( ! empty($data['fileformat']))
3042 3042
 		$metadata['fileformat'] = $data['fileformat'];
3043
-	if ( ! empty( $data['video']['dataformat'] ) )
3043
+	if ( ! empty($data['video']['dataformat']))
3044 3044
 		$metadata['dataformat'] = $data['video']['dataformat'];
3045
-	if ( ! empty( $data['video']['encoder'] ) )
3045
+	if ( ! empty($data['video']['encoder']))
3046 3046
 		$metadata['encoder'] = $data['video']['encoder'];
3047
-	if ( ! empty( $data['video']['codec'] ) )
3047
+	if ( ! empty($data['video']['codec']))
3048 3048
 		$metadata['codec'] = $data['video']['codec'];
3049 3049
 
3050
-	if ( ! empty( $data['audio'] ) ) {
3051
-		unset( $data['audio']['streams'] );
3050
+	if ( ! empty($data['audio'])) {
3051
+		unset($data['audio']['streams']);
3052 3052
 		$metadata['audio'] = $data['audio'];
3053 3053
 	}
3054 3054
 
3055
-	wp_add_id3_tag_data( $metadata, $data );
3055
+	wp_add_id3_tag_data($metadata, $data);
3056 3056
 
3057 3057
 	return $metadata;
3058 3058
 }
@@ -3065,39 +3065,39 @@  discard block
 block discarded – undo
3065 3065
  * @param string $file Path to file.
3066 3066
  * @return array|bool Returns array of metadata, if found.
3067 3067
  */
3068
-function wp_read_audio_metadata( $file ) {
3069
-	if ( ! file_exists( $file ) ) {
3068
+function wp_read_audio_metadata($file) {
3069
+	if ( ! file_exists($file)) {
3070 3070
 		return false;
3071 3071
 	}
3072 3072
 	$metadata = array();
3073 3073
 
3074
-	if ( ! defined( 'GETID3_TEMP_DIR' ) ) {
3075
-		define( 'GETID3_TEMP_DIR', get_temp_dir() );
3074
+	if ( ! defined('GETID3_TEMP_DIR')) {
3075
+		define('GETID3_TEMP_DIR', get_temp_dir());
3076 3076
 	}
3077 3077
 
3078
-	if ( ! class_exists( 'getID3', false ) ) {
3079
-		require( ABSPATH . WPINC . '/ID3/getid3.php' );
3078
+	if ( ! class_exists('getID3', false)) {
3079
+		require(ABSPATH.WPINC.'/ID3/getid3.php');
3080 3080
 	}
3081 3081
 	$id3 = new getID3();
3082
-	$data = $id3->analyze( $file );
3082
+	$data = $id3->analyze($file);
3083 3083
 
3084
-	if ( ! empty( $data['audio'] ) ) {
3085
-		unset( $data['audio']['streams'] );
3084
+	if ( ! empty($data['audio'])) {
3085
+		unset($data['audio']['streams']);
3086 3086
 		$metadata = $data['audio'];
3087 3087
 	}
3088 3088
 
3089
-	if ( ! empty( $data['fileformat'] ) )
3089
+	if ( ! empty($data['fileformat']))
3090 3090
 		$metadata['fileformat'] = $data['fileformat'];
3091
-	if ( ! empty( $data['filesize'] ) )
3091
+	if ( ! empty($data['filesize']))
3092 3092
 		$metadata['filesize'] = (int) $data['filesize'];
3093
-	if ( ! empty( $data['mime_type'] ) )
3093
+	if ( ! empty($data['mime_type']))
3094 3094
 		$metadata['mime_type'] = $data['mime_type'];
3095
-	if ( ! empty( $data['playtime_seconds'] ) )
3096
-		$metadata['length'] = (int) round( $data['playtime_seconds'] );
3097
-	if ( ! empty( $data['playtime_string'] ) )
3095
+	if ( ! empty($data['playtime_seconds']))
3096
+		$metadata['length'] = (int) round($data['playtime_seconds']);
3097
+	if ( ! empty($data['playtime_string']))
3098 3098
 		$metadata['length_formatted'] = $data['playtime_string'];
3099 3099
 
3100
-	wp_add_id3_tag_data( $metadata, $data );
3100
+	wp_add_id3_tag_data($metadata, $data);
3101 3101
 
3102 3102
 	return $metadata;
3103 3103
 }
@@ -3113,51 +3113,51 @@  discard block
 block discarded – undo
3113 3113
  * @param string $action    Optional. Attach/detach action. Accepts 'attach' or 'detach'.
3114 3114
  *                          Default 'attach'.
3115 3115
  */
3116
-function wp_media_attach_action( $parent_id, $action = 'attach' ) {
3116
+function wp_media_attach_action($parent_id, $action = 'attach') {
3117 3117
 	global $wpdb;
3118 3118
 
3119
-	if ( ! $parent_id ) {
3119
+	if ( ! $parent_id) {
3120 3120
 		return;
3121 3121
 	}
3122 3122
 
3123
-	if ( ! current_user_can( 'edit_post', $parent_id ) ) {
3124
-		wp_die( __( 'Sorry, you are not allowed to edit this post.' ) );
3123
+	if ( ! current_user_can('edit_post', $parent_id)) {
3124
+		wp_die(__('Sorry, you are not allowed to edit this post.'));
3125 3125
 	}
3126 3126
 	$ids = array();
3127
-	foreach ( (array) $_REQUEST['media'] as $att_id ) {
3127
+	foreach ((array) $_REQUEST['media'] as $att_id) {
3128 3128
 		$att_id = (int) $att_id;
3129 3129
 
3130
-		if ( ! current_user_can( 'edit_post', $att_id ) ) {
3130
+		if ( ! current_user_can('edit_post', $att_id)) {
3131 3131
 			continue;
3132 3132
 		}
3133 3133
 
3134 3134
 		$ids[] = $att_id;
3135 3135
 	}
3136 3136
 
3137
-	if ( ! empty( $ids ) ) {
3138
-		$ids_string = implode( ',', $ids );
3139
-		if ( 'attach' === $action ) {
3140
-			$result = $wpdb->query( $wpdb->prepare( "UPDATE $wpdb->posts SET post_parent = %d WHERE post_type = 'attachment' AND ID IN ( $ids_string )", $parent_id ) );
3137
+	if ( ! empty($ids)) {
3138
+		$ids_string = implode(',', $ids);
3139
+		if ('attach' === $action) {
3140
+			$result = $wpdb->query($wpdb->prepare("UPDATE $wpdb->posts SET post_parent = %d WHERE post_type = 'attachment' AND ID IN ( $ids_string )", $parent_id));
3141 3141
 		} else {
3142
-			$result = $wpdb->query( "UPDATE $wpdb->posts SET post_parent = 0 WHERE post_type = 'attachment' AND ID IN ( $ids_string )" );
3142
+			$result = $wpdb->query("UPDATE $wpdb->posts SET post_parent = 0 WHERE post_type = 'attachment' AND ID IN ( $ids_string )");
3143 3143
 		}
3144 3144
 
3145
-		foreach ( $ids as $att_id ) {
3146
-			clean_attachment_cache( $att_id );
3145
+		foreach ($ids as $att_id) {
3146
+			clean_attachment_cache($att_id);
3147 3147
 		}
3148 3148
 	}
3149 3149
 
3150
-	if ( isset( $result ) ) {
3150
+	if (isset($result)) {
3151 3151
 		$location = 'upload.php';
3152
-		if ( $referer = wp_get_referer() ) {
3153
-			if ( false !== strpos( $referer, 'upload.php' ) ) {
3154
-				$location = remove_query_arg( array( 'attached', 'detach' ), $referer );
3152
+		if ($referer = wp_get_referer()) {
3153
+			if (false !== strpos($referer, 'upload.php')) {
3154
+				$location = remove_query_arg(array('attached', 'detach'), $referer);
3155 3155
 			}
3156 3156
 		}
3157 3157
 
3158 3158
 		$key = 'attach' === $action ? 'attached' : 'detach';
3159
-		$location = add_query_arg( array( $key => $result ), $location );
3160
-		wp_redirect( $location );
3159
+		$location = add_query_arg(array($key => $result), $location);
3160
+		wp_redirect($location);
3161 3161
 		exit;
3162 3162
 	}
3163 3163
 }
Please login to merge, or discard this patch.
src/wp-admin/includes/class-wp-ajax-upgrader-skin.php 1 patch
Spacing   +26 added lines, -26 removed lines patch added patch discarded remove patch
@@ -35,8 +35,8 @@  discard block
 block discarded – undo
35 35
 	 *
36 36
 	 * @param array $args Options for the upgrader, see WP_Upgrader_Skin::__construct().
37 37
 	 */
38
-	public function __construct( $args = array() ) {
39
-		parent::__construct( $args );
38
+	public function __construct($args = array()) {
39
+		parent::__construct($args);
40 40
 
41 41
 		$this->errors = new WP_Error();
42 42
 	}
@@ -64,15 +64,15 @@  discard block
 block discarded – undo
64 64
 	public function get_error_messages() {
65 65
 		$messages = array();
66 66
 
67
-		foreach ( $this->errors->get_error_codes() as $error_code ) {
68
-			if ( $this->errors->get_error_data( $error_code ) && is_string( $this->errors->get_error_data( $error_code ) ) ) {
69
-				$messages[] = $this->errors->get_error_message( $error_code ) . ' ' . esc_html( strip_tags( $this->errors->get_error_data( $error_code ) ) );
67
+		foreach ($this->errors->get_error_codes() as $error_code) {
68
+			if ($this->errors->get_error_data($error_code) && is_string($this->errors->get_error_data($error_code))) {
69
+				$messages[] = $this->errors->get_error_message($error_code).' '.esc_html(strip_tags($this->errors->get_error_data($error_code)));
70 70
 			} else {
71
-				$messages[] = $this->errors->get_error_message( $error_code );
71
+				$messages[] = $this->errors->get_error_message($error_code);
72 72
 			}
73 73
 		}
74 74
 
75
-		return implode( ', ', $messages );
75
+		return implode(', ', $messages);
76 76
 	}
77 77
 
78 78
 	/**
@@ -83,32 +83,32 @@  discard block
 block discarded – undo
83 83
 	 *
84 84
 	 * @param string|WP_Error $errors Errors.
85 85
 	 */
86
-	public function error( $errors ) {
87
-		if ( is_string( $errors ) ) {
86
+	public function error($errors) {
87
+		if (is_string($errors)) {
88 88
 			$string = $errors;
89
-			if ( ! empty( $this->upgrader->strings[ $string ] ) ) {
90
-				$string = $this->upgrader->strings[ $string ];
89
+			if ( ! empty($this->upgrader->strings[$string])) {
90
+				$string = $this->upgrader->strings[$string];
91 91
 			}
92 92
 
93
-			if ( false !== strpos( $string, '%' ) ) {
93
+			if (false !== strpos($string, '%')) {
94 94
 				$args = func_get_args();
95
-				$args = array_splice( $args, 1 );
96
-				if ( ! empty( $args ) ) {
97
-					$string = vsprintf( $string, $args );
95
+				$args = array_splice($args, 1);
96
+				if ( ! empty($args)) {
97
+					$string = vsprintf($string, $args);
98 98
 				}
99 99
 			}
100 100
 
101 101
 			// Count existing errors to generate an unique error code.
102
-			$errors_count = count( $errors->get_error_codes() );
103
-			$this->errors->add( 'unknown_upgrade_error_' . $errors_count + 1 , $string );
104
-		} elseif ( is_wp_error( $errors ) ) {
105
-			foreach ( $errors->get_error_codes() as $error_code ) {
106
-				$this->errors->add( $error_code, $errors->get_error_message( $error_code ), $errors->get_error_data( $error_code ) );
102
+			$errors_count = count($errors->get_error_codes());
103
+			$this->errors->add('unknown_upgrade_error_'.$errors_count + 1, $string);
104
+		} elseif (is_wp_error($errors)) {
105
+			foreach ($errors->get_error_codes() as $error_code) {
106
+				$this->errors->add($error_code, $errors->get_error_message($error_code), $errors->get_error_data($error_code));
107 107
 			}
108 108
 		}
109 109
 
110 110
 		$args = func_get_args();
111
-		call_user_func_array( array( $this, 'parent::error' ), $args );
111
+		call_user_func_array(array($this, 'parent::error'), $args);
112 112
 	}
113 113
 
114 114
 	/**
@@ -119,14 +119,14 @@  discard block
 block discarded – undo
119 119
 	 *
120 120
 	 * @param string|array|WP_Error $data Log entry data.
121 121
 	 */
122
-	public function feedback( $data ) {
123
-		if ( is_wp_error( $data ) ) {
124
-			foreach ( $data->get_error_codes() as $error_code ) {
125
-				$this->errors->add( $error_code, $data->get_error_message( $error_code ), $data->get_error_data( $error_code ) );
122
+	public function feedback($data) {
123
+		if (is_wp_error($data)) {
124
+			foreach ($data->get_error_codes() as $error_code) {
125
+				$this->errors->add($error_code, $data->get_error_message($error_code), $data->get_error_data($error_code));
126 126
 			}
127 127
 		}
128 128
 
129 129
 		$args = func_get_args();
130
-		call_user_func_array( array( $this, 'parent::feedback' ), $args );
130
+		call_user_func_array(array($this, 'parent::feedback'), $args);
131 131
 	}
132 132
 }
Please login to merge, or discard this patch.
src/wp-admin/includes/class-wp-filesystem-ftpsockets.php 2 patches
Spacing   +80 added lines, -80 removed lines patch added patch discarded remove patch
@@ -26,33 +26,33 @@  discard block
 block discarded – undo
26 26
 	 *
27 27
 	 * @param array $opt
28 28
 	 */
29
-	public function __construct( $opt  = '' ) {
29
+	public function __construct($opt = '') {
30 30
 		$this->method = 'ftpsockets';
31 31
 		$this->errors = new WP_Error();
32 32
 
33 33
 		// Check if possible to use ftp functions.
34
-		if ( ! @include_once( ABSPATH . 'wp-admin/includes/class-ftp.php' ) ) {
34
+		if ( ! @include_once(ABSPATH.'wp-admin/includes/class-ftp.php')) {
35 35
 			return;
36 36
 		}
37 37
 		$this->ftp = new ftp();
38 38
 
39
-		if ( empty($opt['port']) )
39
+		if (empty($opt['port']))
40 40
 			$this->options['port'] = 21;
41 41
 		else
42 42
 			$this->options['port'] = (int) $opt['port'];
43 43
 
44
-		if ( empty($opt['hostname']) )
44
+		if (empty($opt['hostname']))
45 45
 			$this->errors->add('empty_hostname', __('FTP hostname is required'));
46 46
 		else
47 47
 			$this->options['hostname'] = $opt['hostname'];
48 48
 
49 49
 		// Check if the options provided are OK.
50
-		if ( empty ($opt['username']) )
50
+		if (empty ($opt['username']))
51 51
 			$this->errors->add('empty_username', __('FTP username is required'));
52 52
 		else
53 53
 			$this->options['username'] = $opt['username'];
54 54
 
55
-		if ( empty ($opt['password']) )
55
+		if (empty ($opt['password']))
56 56
 			$this->errors->add('empty_password', __('FTP password is required'));
57 57
 		else
58 58
 			$this->options['password'] = $opt['password'];
@@ -64,44 +64,44 @@  discard block
 block discarded – undo
64 64
 	 * @return bool
65 65
 	 */
66 66
 	public function connect() {
67
-		if ( ! $this->ftp )
67
+		if ( ! $this->ftp)
68 68
 			return false;
69 69
 
70 70
 		$this->ftp->setTimeout(FS_CONNECT_TIMEOUT);
71 71
 
72
-		if ( ! $this->ftp->SetServer( $this->options['hostname'], $this->options['port'] ) ) {
73
-			$this->errors->add( 'connect',
72
+		if ( ! $this->ftp->SetServer($this->options['hostname'], $this->options['port'])) {
73
+			$this->errors->add('connect',
74 74
 				/* translators: %s: hostname:port */
75
-				sprintf( __( 'Failed to connect to FTP Server %s' ),
76
-					$this->options['hostname'] . ':' . $this->options['port']
75
+				sprintf(__('Failed to connect to FTP Server %s'),
76
+					$this->options['hostname'].':'.$this->options['port']
77 77
 				)
78 78
 			);
79 79
 			return false;
80 80
 		}
81 81
 
82
-		if ( ! $this->ftp->connect() ) {
83
-			$this->errors->add( 'connect',
82
+		if ( ! $this->ftp->connect()) {
83
+			$this->errors->add('connect',
84 84
 				/* translators: %s: hostname:port */
85
-				sprintf( __( 'Failed to connect to FTP Server %s' ),
86
-					$this->options['hostname'] . ':' . $this->options['port']
85
+				sprintf(__('Failed to connect to FTP Server %s'),
86
+					$this->options['hostname'].':'.$this->options['port']
87 87
 				)
88 88
 			);
89 89
 			return false;
90 90
 		}
91 91
 
92
-		if ( ! $this->ftp->login( $this->options['username'], $this->options['password'] ) ) {
93
-			$this->errors->add( 'auth',
92
+		if ( ! $this->ftp->login($this->options['username'], $this->options['password'])) {
93
+			$this->errors->add('auth',
94 94
 				/* translators: %s: username */
95
-				sprintf( __( 'Username/Password incorrect for %s' ),
95
+				sprintf(__('Username/Password incorrect for %s'),
96 96
 					$this->options['username']
97 97
 				)
98 98
 			);
99 99
 			return false;
100 100
 		}
101 101
 
102
-		$this->ftp->SetType( FTP_BINARY );
103
-		$this->ftp->Passive( true );
104
-		$this->ftp->setTimeout( FS_TIMEOUT );
102
+		$this->ftp->SetType(FTP_BINARY);
103
+		$this->ftp->Passive(true);
104
+		$this->ftp->setTimeout(FS_TIMEOUT);
105 105
 		return true;
106 106
 	}
107 107
 
@@ -115,20 +115,20 @@  discard block
 block discarded – undo
115 115
 	 * @return string|false File contents on success, false if no temp file could be opened,
116 116
 	 *                      or if the file doesn't exist.
117 117
 	 */
118
-	public function get_contents( $file ) {
119
-		if ( ! $this->exists($file) )
118
+	public function get_contents($file) {
119
+		if ( ! $this->exists($file))
120 120
 			return false;
121 121
 
122
-		$temp = wp_tempnam( $file );
122
+		$temp = wp_tempnam($file);
123 123
 
124
-		if ( ! $temphandle = fopen( $temp, 'w+' ) ) {
125
-			unlink( $temp );
124
+		if ( ! $temphandle = fopen($temp, 'w+')) {
125
+			unlink($temp);
126 126
 			return false;
127 127
 		}
128 128
 
129 129
 		mbstring_binary_safe_encoding();
130 130
 
131
-		if ( ! $this->ftp->fget($temphandle, $file) ) {
131
+		if ( ! $this->ftp->fget($temphandle, $file)) {
132 132
 			fclose($temphandle);
133 133
 			unlink($temp);
134 134
 
@@ -139,10 +139,10 @@  discard block
 block discarded – undo
139 139
 
140 140
 		reset_mbstring_encoding();
141 141
 
142
-		fseek( $temphandle, 0 ); // Skip back to the start of the file being written to
142
+		fseek($temphandle, 0); // Skip back to the start of the file being written to
143 143
 		$contents = '';
144 144
 
145
-		while ( ! feof($temphandle) )
145
+		while ( ! feof($temphandle))
146 146
 			$contents .= fread($temphandle, 8192);
147 147
 
148 148
 		fclose($temphandle);
@@ -157,7 +157,7 @@  discard block
 block discarded – undo
157 157
 	 * @return array
158 158
 	 */
159 159
 	public function get_contents_array($file) {
160
-		return explode("\n", $this->get_contents($file) );
160
+		return explode("\n", $this->get_contents($file));
161 161
 	}
162 162
 
163 163
 	/**
@@ -168,9 +168,9 @@  discard block
 block discarded – undo
168 168
 	 * @param int|bool $mode
169 169
 	 * @return bool
170 170
 	 */
171
-	public function put_contents($file, $contents, $mode = false ) {
172
-		$temp = wp_tempnam( $file );
173
-		if ( ! $temphandle = @fopen($temp, 'w+') ) {
171
+	public function put_contents($file, $contents, $mode = false) {
172
+		$temp = wp_tempnam($file);
173
+		if ( ! $temphandle = @fopen($temp, 'w+')) {
174 174
 			unlink($temp);
175 175
 			return false;
176 176
 		}
@@ -178,17 +178,17 @@  discard block
 block discarded – undo
178 178
 		// The FTP class uses string functions internally during file download/upload
179 179
 		mbstring_binary_safe_encoding();
180 180
 
181
-		$bytes_written = fwrite( $temphandle, $contents );
182
-		if ( false === $bytes_written || $bytes_written != strlen( $contents ) ) {
183
-			fclose( $temphandle );
184
-			unlink( $temp );
181
+		$bytes_written = fwrite($temphandle, $contents);
182
+		if (false === $bytes_written || $bytes_written != strlen($contents)) {
183
+			fclose($temphandle);
184
+			unlink($temp);
185 185
 
186 186
 			reset_mbstring_encoding();
187 187
 
188 188
 			return false;
189 189
 		}
190 190
 
191
-		fseek( $temphandle, 0 ); // Skip back to the start of the file being written to
191
+		fseek($temphandle, 0); // Skip back to the start of the file being written to
192 192
 
193 193
 		$ret = $this->ftp->fput($file, $temphandle);
194 194
 
@@ -209,7 +209,7 @@  discard block
 block discarded – undo
209 209
 	 */
210 210
 	public function cwd() {
211 211
 		$cwd = $this->ftp->pwd();
212
-		if ( $cwd )
212
+		if ($cwd)
213 213
 			$cwd = trailingslashit($cwd);
214 214
 		return $cwd;
215 215
 	}
@@ -232,21 +232,21 @@  discard block
 block discarded – undo
232 232
 	 * @param bool $recursive
233 233
 	 * @return bool
234 234
 	 */
235
-	public function chmod($file, $mode = false, $recursive = false ) {
236
-		if ( ! $mode ) {
237
-			if ( $this->is_file($file) )
235
+	public function chmod($file, $mode = false, $recursive = false) {
236
+		if ( ! $mode) {
237
+			if ($this->is_file($file))
238 238
 				$mode = FS_CHMOD_FILE;
239
-			elseif ( $this->is_dir($file) )
239
+			elseif ($this->is_dir($file))
240 240
 				$mode = FS_CHMOD_DIR;
241 241
 			else
242 242
 				return false;
243 243
 		}
244 244
 
245 245
 		// chmod any sub-objects if recursive.
246
-		if ( $recursive && $this->is_dir($file) ) {
246
+		if ($recursive && $this->is_dir($file)) {
247 247
 			$filelist = $this->dirlist($file);
248
-			foreach ( (array)$filelist as $filename => $filemeta )
249
-				$this->chmod($file . '/' . $filename, $mode, $recursive);
248
+			foreach ((array) $filelist as $filename => $filemeta)
249
+				$this->chmod($file.'/'.$filename, $mode, $recursive);
250 250
 		}
251 251
 
252 252
 		// chmod the file or directory
@@ -296,11 +296,11 @@  discard block
 block discarded – undo
296 296
 	 * @return bool
297 297
 	 */
298 298
 	public function copy($source, $destination, $overwrite = false, $mode = false) {
299
-		if ( ! $overwrite && $this->exists($destination) )
299
+		if ( ! $overwrite && $this->exists($destination))
300 300
 			return false;
301 301
 
302 302
 		$content = $this->get_contents($source);
303
-		if ( false === $content )
303
+		if (false === $content)
304 304
 			return false;
305 305
 
306 306
 		return $this->put_contents($destination, $content, $mode);
@@ -314,7 +314,7 @@  discard block
 block discarded – undo
314 314
 	 * @param bool   $overwrite
315 315
 	 * @return bool
316 316
 	 */
317
-	public function move($source, $destination, $overwrite = false ) {
317
+	public function move($source, $destination, $overwrite = false) {
318 318
 		return $this->ftp->rename($source, $destination);
319 319
 	}
320 320
 
@@ -327,11 +327,11 @@  discard block
 block discarded – undo
327 327
 	 * @return bool
328 328
 	 */
329 329
 	public function delete($file, $recursive = false, $type = false) {
330
-		if ( empty($file) )
330
+		if (empty($file))
331 331
 			return false;
332
-		if ( 'f' == $type || $this->is_file($file) )
332
+		if ('f' == $type || $this->is_file($file))
333 333
 			return $this->ftp->delete($file);
334
-		if ( !$recursive )
334
+		if ( ! $recursive)
335 335
 			return $this->ftp->rmdir($file);
336 336
 
337 337
 		return $this->ftp->mdel($file);
@@ -343,14 +343,14 @@  discard block
 block discarded – undo
343 343
 	 * @param string $file
344 344
 	 * @return bool
345 345
 	 */
346
-	public function exists( $file ) {
347
-		$list = $this->ftp->nlist( $file );
346
+	public function exists($file) {
347
+		$list = $this->ftp->nlist($file);
348 348
 
349
-		if ( empty( $list ) && $this->is_dir( $file ) ) {
349
+		if (empty($list) && $this->is_dir($file)) {
350 350
 			return true; // File is an empty directory.
351 351
 		}
352 352
 
353
-		return !empty( $list ); //empty list = no file, so invert.
353
+		return ! empty($list); //empty list = no file, so invert.
354 354
 		// Return $this->ftp->is_exists($file); has issues with ABOR+426 responses on the ncFTPd server.
355 355
 	}
356 356
 
@@ -361,9 +361,9 @@  discard block
 block discarded – undo
361 361
 	 * @return bool
362 362
 	 */
363 363
 	public function is_file($file) {
364
-		if ( $this->is_dir($file) )
364
+		if ($this->is_dir($file))
365 365
 			return false;
366
-		if ( $this->exists($file) )
366
+		if ($this->exists($file))
367 367
 			return true;
368 368
 		return false;
369 369
 	}
@@ -376,7 +376,7 @@  discard block
 block discarded – undo
376 376
 	 */
377 377
 	public function is_dir($path) {
378 378
 		$cwd = $this->cwd();
379
-		if ( $this->chdir($path) ) {
379
+		if ($this->chdir($path)) {
380 380
 			$this->chdir($cwd);
381 381
 			return true;
382 382
 		}
@@ -439,7 +439,7 @@  discard block
 block discarded – undo
439 439
 	 * @param int $atime
440 440
 	 * @return bool
441 441
 	 */
442
-	public function touch($file, $time = 0, $atime = 0 ) {
442
+	public function touch($file, $time = 0, $atime = 0) {
443 443
 		return false;
444 444
 	}
445 445
 
@@ -452,14 +452,14 @@  discard block
 block discarded – undo
452 452
 	 * @param mixed  $chgrp
453 453
 	 * @return bool
454 454
 	 */
455
-	public function mkdir($path, $chmod = false, $chown = false, $chgrp = false ) {
455
+	public function mkdir($path, $chmod = false, $chown = false, $chgrp = false) {
456 456
 		$path = untrailingslashit($path);
457
-		if ( empty($path) )
457
+		if (empty($path))
458 458
 			return false;
459 459
 
460
-		if ( ! $this->ftp->mkdir($path) )
460
+		if ( ! $this->ftp->mkdir($path))
461 461
 			return false;
462
-		if ( ! $chmod )
462
+		if ( ! $chmod)
463 463
 			$chmod = FS_CHMOD_DIR;
464 464
 		$this->chmod($path, $chmod);
465 465
 		return true;
@@ -471,7 +471,7 @@  discard block
 block discarded – undo
471 471
 	 * @param string $path
472 472
 	 * @param bool $recursive
473 473
 	 */
474
-	public function rmdir($path, $recursive = false ) {
474
+	public function rmdir($path, $recursive = false) {
475 475
 		$this->delete($path, $recursive);
476 476
 	}
477 477
 
@@ -483,10 +483,10 @@  discard block
 block discarded – undo
483 483
 	 * @param bool   $recursive
484 484
 	 * @return bool|array
485 485
 	 */
486
-	public function dirlist($path = '.', $include_hidden = true, $recursive = false ) {
487
-		if ( $this->is_file($path) ) {
486
+	public function dirlist($path = '.', $include_hidden = true, $recursive = false) {
487
+		if ($this->is_file($path)) {
488 488
 			$limit_file = basename($path);
489
-			$path = dirname($path) . '/';
489
+			$path = dirname($path).'/';
490 490
 		} else {
491 491
 			$limit_file = false;
492 492
 		}
@@ -494,7 +494,7 @@  discard block
 block discarded – undo
494 494
 		mbstring_binary_safe_encoding();
495 495
 
496 496
 		$list = $this->ftp->dirlist($path);
497
-		if ( empty( $list ) && ! $this->exists( $path ) ) {
497
+		if (empty($list) && ! $this->exists($path)) {
498 498
 
499 499
 			reset_mbstring_encoding();
500 500
 
@@ -502,32 +502,32 @@  discard block
 block discarded – undo
502 502
 		}
503 503
 
504 504
 		$ret = array();
505
-		foreach ( $list as $struc ) {
505
+		foreach ($list as $struc) {
506 506
 
507
-			if ( '.' == $struc['name'] || '..' == $struc['name'] )
507
+			if ('.' == $struc['name'] || '..' == $struc['name'])
508 508
 				continue;
509 509
 
510
-			if ( ! $include_hidden && '.' == $struc['name'][0] )
510
+			if ( ! $include_hidden && '.' == $struc['name'][0])
511 511
 				continue;
512 512
 
513
-			if ( $limit_file && $struc['name'] != $limit_file )
513
+			if ($limit_file && $struc['name'] != $limit_file)
514 514
 				continue;
515 515
 
516
-			if ( 'd' == $struc['type'] ) {
517
-				if ( $recursive )
518
-					$struc['files'] = $this->dirlist($path . '/' . $struc['name'], $include_hidden, $recursive);
516
+			if ('d' == $struc['type']) {
517
+				if ($recursive)
518
+					$struc['files'] = $this->dirlist($path.'/'.$struc['name'], $include_hidden, $recursive);
519 519
 				else
520 520
 					$struc['files'] = array();
521 521
 			}
522 522
 
523 523
 			// Replace symlinks formatted as "source -> target" with just the source name
524
-			if ( $struc['islink'] )
525
-				$struc['name'] = preg_replace( '/(\s*->\s*.*)$/', '', $struc['name'] );
524
+			if ($struc['islink'])
525
+				$struc['name'] = preg_replace('/(\s*->\s*.*)$/', '', $struc['name']);
526 526
 
527 527
 			// Add the Octal representation of the file permissions
528
-			$struc['permsn'] = $this->getnumchmodfromh( $struc['perms'] );
528
+			$struc['permsn'] = $this->getnumchmodfromh($struc['perms']);
529 529
 
530
-			$ret[ $struc['name'] ] = $struc;
530
+			$ret[$struc['name']] = $struc;
531 531
 		}
532 532
 
533 533
 		reset_mbstring_encoding();
Please login to merge, or discard this patch.
Braces   +90 added lines, -65 removed lines patch added patch discarded remove patch
@@ -36,26 +36,30 @@  discard block
 block discarded – undo
36 36
 		}
37 37
 		$this->ftp = new ftp();
38 38
 
39
-		if ( empty($opt['port']) )
40
-			$this->options['port'] = 21;
41
-		else
42
-			$this->options['port'] = (int) $opt['port'];
39
+		if ( empty($opt['port']) ) {
40
+					$this->options['port'] = 21;
41
+		} else {
42
+					$this->options['port'] = (int) $opt['port'];
43
+		}
43 44
 
44
-		if ( empty($opt['hostname']) )
45
-			$this->errors->add('empty_hostname', __('FTP hostname is required'));
46
-		else
47
-			$this->options['hostname'] = $opt['hostname'];
45
+		if ( empty($opt['hostname']) ) {
46
+					$this->errors->add('empty_hostname', __('FTP hostname is required'));
47
+		} else {
48
+					$this->options['hostname'] = $opt['hostname'];
49
+		}
48 50
 
49 51
 		// Check if the options provided are OK.
50
-		if ( empty ($opt['username']) )
51
-			$this->errors->add('empty_username', __('FTP username is required'));
52
-		else
53
-			$this->options['username'] = $opt['username'];
54
-
55
-		if ( empty ($opt['password']) )
56
-			$this->errors->add('empty_password', __('FTP password is required'));
57
-		else
58
-			$this->options['password'] = $opt['password'];
52
+		if ( empty ($opt['username']) ) {
53
+					$this->errors->add('empty_username', __('FTP username is required'));
54
+		} else {
55
+					$this->options['username'] = $opt['username'];
56
+		}
57
+
58
+		if ( empty ($opt['password']) ) {
59
+					$this->errors->add('empty_password', __('FTP password is required'));
60
+		} else {
61
+					$this->options['password'] = $opt['password'];
62
+		}
59 63
 	}
60 64
 
61 65
 	/**
@@ -64,8 +68,9 @@  discard block
 block discarded – undo
64 68
 	 * @return bool
65 69
 	 */
66 70
 	public function connect() {
67
-		if ( ! $this->ftp )
68
-			return false;
71
+		if ( ! $this->ftp ) {
72
+					return false;
73
+		}
69 74
 
70 75
 		$this->ftp->setTimeout(FS_CONNECT_TIMEOUT);
71 76
 
@@ -116,8 +121,9 @@  discard block
 block discarded – undo
116 121
 	 *                      or if the file doesn't exist.
117 122
 	 */
118 123
 	public function get_contents( $file ) {
119
-		if ( ! $this->exists($file) )
120
-			return false;
124
+		if ( ! $this->exists($file) ) {
125
+					return false;
126
+		}
121 127
 
122 128
 		$temp = wp_tempnam( $file );
123 129
 
@@ -142,8 +148,9 @@  discard block
 block discarded – undo
142 148
 		fseek( $temphandle, 0 ); // Skip back to the start of the file being written to
143 149
 		$contents = '';
144 150
 
145
-		while ( ! feof($temphandle) )
146
-			$contents .= fread($temphandle, 8192);
151
+		while ( ! feof($temphandle) ) {
152
+					$contents .= fread($temphandle, 8192);
153
+		}
147 154
 
148 155
 		fclose($temphandle);
149 156
 		unlink($temp);
@@ -209,8 +216,9 @@  discard block
 block discarded – undo
209 216
 	 */
210 217
 	public function cwd() {
211 218
 		$cwd = $this->ftp->pwd();
212
-		if ( $cwd )
213
-			$cwd = trailingslashit($cwd);
219
+		if ( $cwd ) {
220
+					$cwd = trailingslashit($cwd);
221
+		}
214 222
 		return $cwd;
215 223
 	}
216 224
 
@@ -234,19 +242,21 @@  discard block
 block discarded – undo
234 242
 	 */
235 243
 	public function chmod($file, $mode = false, $recursive = false ) {
236 244
 		if ( ! $mode ) {
237
-			if ( $this->is_file($file) )
238
-				$mode = FS_CHMOD_FILE;
239
-			elseif ( $this->is_dir($file) )
240
-				$mode = FS_CHMOD_DIR;
241
-			else
242
-				return false;
245
+			if ( $this->is_file($file) ) {
246
+							$mode = FS_CHMOD_FILE;
247
+			} elseif ( $this->is_dir($file) ) {
248
+							$mode = FS_CHMOD_DIR;
249
+			} else {
250
+							return false;
251
+			}
243 252
 		}
244 253
 
245 254
 		// chmod any sub-objects if recursive.
246 255
 		if ( $recursive && $this->is_dir($file) ) {
247 256
 			$filelist = $this->dirlist($file);
248
-			foreach ( (array)$filelist as $filename => $filemeta )
249
-				$this->chmod($file . '/' . $filename, $mode, $recursive);
257
+			foreach ( (array)$filelist as $filename => $filemeta ) {
258
+							$this->chmod($file . '/' . $filename, $mode, $recursive);
259
+			}
250 260
 		}
251 261
 
252 262
 		// chmod the file or directory
@@ -296,12 +306,14 @@  discard block
 block discarded – undo
296 306
 	 * @return bool
297 307
 	 */
298 308
 	public function copy($source, $destination, $overwrite = false, $mode = false) {
299
-		if ( ! $overwrite && $this->exists($destination) )
300
-			return false;
309
+		if ( ! $overwrite && $this->exists($destination) ) {
310
+					return false;
311
+		}
301 312
 
302 313
 		$content = $this->get_contents($source);
303
-		if ( false === $content )
304
-			return false;
314
+		if ( false === $content ) {
315
+					return false;
316
+		}
305 317
 
306 318
 		return $this->put_contents($destination, $content, $mode);
307 319
 	}
@@ -327,12 +339,15 @@  discard block
 block discarded – undo
327 339
 	 * @return bool
328 340
 	 */
329 341
 	public function delete($file, $recursive = false, $type = false) {
330
-		if ( empty($file) )
331
-			return false;
332
-		if ( 'f' == $type || $this->is_file($file) )
333
-			return $this->ftp->delete($file);
334
-		if ( !$recursive )
335
-			return $this->ftp->rmdir($file);
342
+		if ( empty($file) ) {
343
+					return false;
344
+		}
345
+		if ( 'f' == $type || $this->is_file($file) ) {
346
+					return $this->ftp->delete($file);
347
+		}
348
+		if ( !$recursive ) {
349
+					return $this->ftp->rmdir($file);
350
+		}
336 351
 
337 352
 		return $this->ftp->mdel($file);
338 353
 	}
@@ -361,10 +376,12 @@  discard block
 block discarded – undo
361 376
 	 * @return bool
362 377
 	 */
363 378
 	public function is_file($file) {
364
-		if ( $this->is_dir($file) )
365
-			return false;
366
-		if ( $this->exists($file) )
367
-			return true;
379
+		if ( $this->is_dir($file) ) {
380
+					return false;
381
+		}
382
+		if ( $this->exists($file) ) {
383
+					return true;
384
+		}
368 385
 		return false;
369 386
 	}
370 387
 
@@ -454,13 +471,16 @@  discard block
 block discarded – undo
454 471
 	 */
455 472
 	public function mkdir($path, $chmod = false, $chown = false, $chgrp = false ) {
456 473
 		$path = untrailingslashit($path);
457
-		if ( empty($path) )
458
-			return false;
474
+		if ( empty($path) ) {
475
+					return false;
476
+		}
459 477
 
460
-		if ( ! $this->ftp->mkdir($path) )
461
-			return false;
462
-		if ( ! $chmod )
463
-			$chmod = FS_CHMOD_DIR;
478
+		if ( ! $this->ftp->mkdir($path) ) {
479
+					return false;
480
+		}
481
+		if ( ! $chmod ) {
482
+					$chmod = FS_CHMOD_DIR;
483
+		}
464 484
 		$this->chmod($path, $chmod);
465 485
 		return true;
466 486
 	}
@@ -504,25 +524,30 @@  discard block
 block discarded – undo
504 524
 		$ret = array();
505 525
 		foreach ( $list as $struc ) {
506 526
 
507
-			if ( '.' == $struc['name'] || '..' == $struc['name'] )
508
-				continue;
527
+			if ( '.' == $struc['name'] || '..' == $struc['name'] ) {
528
+							continue;
529
+			}
509 530
 
510
-			if ( ! $include_hidden && '.' == $struc['name'][0] )
511
-				continue;
531
+			if ( ! $include_hidden && '.' == $struc['name'][0] ) {
532
+							continue;
533
+			}
512 534
 
513
-			if ( $limit_file && $struc['name'] != $limit_file )
514
-				continue;
535
+			if ( $limit_file && $struc['name'] != $limit_file ) {
536
+							continue;
537
+			}
515 538
 
516 539
 			if ( 'd' == $struc['type'] ) {
517
-				if ( $recursive )
518
-					$struc['files'] = $this->dirlist($path . '/' . $struc['name'], $include_hidden, $recursive);
519
-				else
520
-					$struc['files'] = array();
540
+				if ( $recursive ) {
541
+									$struc['files'] = $this->dirlist($path . '/' . $struc['name'], $include_hidden, $recursive);
542
+				} else {
543
+									$struc['files'] = array();
544
+				}
521 545
 			}
522 546
 
523 547
 			// Replace symlinks formatted as "source -> target" with just the source name
524
-			if ( $struc['islink'] )
525
-				$struc['name'] = preg_replace( '/(\s*->\s*.*)$/', '', $struc['name'] );
548
+			if ( $struc['islink'] ) {
549
+							$struc['name'] = preg_replace( '/(\s*->\s*.*)$/', '', $struc['name'] );
550
+			}
526 551
 
527 552
 			// Add the Octal representation of the file permissions
528 553
 			$struc['permsn'] = $this->getnumchmodfromh( $struc['perms'] );
Please login to merge, or discard this patch.
src/wp-admin/includes/class-wp-plugin-install-list-table.php 1 patch
Spacing   +145 added lines, -145 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
 		 * Filters 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
 		 * Filters 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,19 +170,19 @@  discard block
 block discarded – undo
170 170
 				break;
171 171
 
172 172
 			case 'favorites':
173
-				$action = 'save_wporg_username_' . get_current_user_id();
174
-				if ( isset( $_GET['_wpnonce'] ) && wp_verify_nonce( wp_unslash( $_GET['_wpnonce'] ), $action ) ) {
175
-					$user = isset( $_GET['user'] ) ? wp_unslash( $_GET['user'] ) : get_user_option( 'wporg_favorites' );
176
-					update_user_meta( get_current_user_id(), 'wporg_favorites', $user );
173
+				$action = 'save_wporg_username_'.get_current_user_id();
174
+				if (isset($_GET['_wpnonce']) && wp_verify_nonce(wp_unslash($_GET['_wpnonce']), $action)) {
175
+					$user = isset($_GET['user']) ? wp_unslash($_GET['user']) : get_user_option('wporg_favorites');
176
+					update_user_meta(get_current_user_id(), 'wporg_favorites', $user);
177 177
 				} else {
178
-					$user = get_user_option( 'wporg_favorites' );
178
+					$user = get_user_option('wporg_favorites');
179 179
 				}
180
-				if ( $user )
180
+				if ($user)
181 181
 					$args['user'] = $user;
182 182
 				else
183 183
 					$args = false;
184 184
 
185
-				add_action( 'install_plugins_favorites', 'install_plugins_favorites_form', 9, 0 );
185
+				add_action('install_plugins_favorites', 'install_plugins_favorites_form', 9, 0);
186 186
 				break;
187 187
 
188 188
 			default:
@@ -200,30 +200,30 @@  discard block
 block discarded – undo
200 200
 		 *
201 201
 		 * @param array|bool $args Plugin Install API arguments.
202 202
 		 */
203
-		$args = apply_filters( "install_plugins_table_api_args_$tab", $args );
203
+		$args = apply_filters("install_plugins_table_api_args_$tab", $args);
204 204
 
205
-		if ( !$args )
205
+		if ( ! $args)
206 206
 			return;
207 207
 
208
-		$api = plugins_api( 'query_plugins', $args );
208
+		$api = plugins_api('query_plugins', $args);
209 209
 
210
-		if ( is_wp_error( $api ) ) {
210
+		if (is_wp_error($api)) {
211 211
 			$this->error = $api;
212 212
 			return;
213 213
 		}
214 214
 
215 215
 		$this->items = $api->plugins;
216 216
 
217
-		if ( $this->orderby ) {
218
-			uasort( $this->items, array( $this, 'order_callback' ) );
217
+		if ($this->orderby) {
218
+			uasort($this->items, array($this, 'order_callback'));
219 219
 		}
220 220
 
221
-		$this->set_pagination_args( array(
221
+		$this->set_pagination_args(array(
222 222
 			'total_items' => $api->info['results'],
223 223
 			'per_page' => $args['per_page'],
224
-		) );
224
+		));
225 225
 
226
-		if ( isset( $api->info['groups'] ) ) {
226
+		if (isset($api->info['groups'])) {
227 227
 			$this->groups = $api->info['groups'];
228 228
 		}
229 229
 	}
@@ -232,12 +232,12 @@  discard block
 block discarded – undo
232 232
 	 * @access public
233 233
 	 */
234 234
 	public function no_items() {
235
-		if ( isset( $this->error ) ) {
236
-			$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>';
235
+		if (isset($this->error)) {
236
+			$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>';
237 237
 		} else {
238
-			$message = __( 'No plugins match your request.' );
238
+			$message = __('No plugins match your request.');
239 239
 		}
240
-		echo '<div class="no-plugin-results">' . $message . '</div>';
240
+		echo '<div class="no-plugin-results">'.$message.'</div>';
241 241
 	}
242 242
 
243 243
 	/**
@@ -251,13 +251,13 @@  discard block
 block discarded – undo
251 251
 		global $tabs, $tab;
252 252
 
253 253
 		$display_tabs = array();
254
-		foreach ( (array) $tabs as $action => $text ) {
255
-			$class = ( $action === $tab ) ? ' current' : '';
256
-			$href = self_admin_url('plugin-install.php?tab=' . $action);
254
+		foreach ((array) $tabs as $action => $text) {
255
+			$class = ($action === $tab) ? ' current' : '';
256
+			$href = self_admin_url('plugin-install.php?tab='.$action);
257 257
 			$display_tabs['plugin-install-'.$action] = "<a href='$href' class='$class'>$text</a>";
258 258
 		}
259 259
 		// No longer a real tab.
260
-		unset( $display_tabs['plugin-install-upload'] );
260
+		unset($display_tabs['plugin-install-upload']);
261 261
 
262 262
 		return $display_tabs;
263 263
 	}
@@ -269,18 +269,18 @@  discard block
 block discarded – undo
269 269
 		$views = $this->get_views();
270 270
 
271 271
 		/** This filter is documented in wp-admin/inclues/class-wp-list-table.php */
272
-		$views = apply_filters( "views_{$this->screen->id}", $views );
272
+		$views = apply_filters("views_{$this->screen->id}", $views);
273 273
 
274
-		$this->screen->render_screen_reader_content( 'heading_views' );
274
+		$this->screen->render_screen_reader_content('heading_views');
275 275
 ?>
276 276
 <div class="wp-filter">
277 277
 	<ul class="filter-links">
278 278
 		<?php
279
-		if ( ! empty( $views ) ) {
280
-			foreach ( $views as $class => $view ) {
281
-				$views[ $class ] = "\t<li class='$class'>$view";
279
+		if ( ! empty($views)) {
280
+			foreach ($views as $class => $view) {
281
+				$views[$class] = "\t<li class='$class'>$view";
282 282
 			}
283
-			echo implode( " </li>\n", $views ) . "</li>\n";
283
+			echo implode(" </li>\n", $views)."</li>\n";
284 284
 		}
285 285
 		?>
286 286
 	</ul>
@@ -298,23 +298,23 @@  discard block
 block discarded – undo
298 298
 
299 299
 		$data_attr = '';
300 300
 
301
-		if ( $singular ) {
301
+		if ($singular) {
302 302
 			$data_attr = " data-wp-lists='list:$singular'";
303 303
 		}
304 304
 
305
-		$this->display_tablenav( 'top' );
305
+		$this->display_tablenav('top');
306 306
 
307 307
 ?>
308
-<div class="wp-list-table <?php echo implode( ' ', $this->get_table_classes() ); ?>">
308
+<div class="wp-list-table <?php echo implode(' ', $this->get_table_classes()); ?>">
309 309
 <?php
310
-	$this->screen->render_screen_reader_content( 'heading_list' );
310
+	$this->screen->render_screen_reader_content('heading_list');
311 311
 ?>
312 312
 	<div id="the-list"<?php echo $data_attr; ?>>
313 313
 		<?php $this->display_rows_or_placeholder(); ?>
314 314
 	</div>
315 315
 </div>
316 316
 <?php
317
-		$this->display_tablenav( 'bottom' );
317
+		$this->display_tablenav('bottom');
318 318
 	}
319 319
 
320 320
 	/**
@@ -322,12 +322,12 @@  discard block
 block discarded – undo
322 322
 	 *
323 323
 	 * @param string $which
324 324
 	 */
325
-	protected function display_tablenav( $which ) {
326
-		if ( $GLOBALS['tab'] === 'featured' ) {
325
+	protected function display_tablenav($which) {
326
+		if ($GLOBALS['tab'] === 'featured') {
327 327
 			return;
328 328
 		}
329 329
 
330
-		if ( 'top' === $which ) {
330
+		if ('top' === $which) {
331 331
 			wp_referer_field();
332 332
 		?>
333 333
 			<div class="tablenav top">
@@ -338,14 +338,14 @@  discard block
 block discarded – undo
338 338
 					 *
339 339
 					 * @since 2.7.0
340 340
 					 */
341
-					do_action( 'install_plugins_table_header' ); ?>
341
+					do_action('install_plugins_table_header'); ?>
342 342
 				</div>
343
-				<?php $this->pagination( $which ); ?>
343
+				<?php $this->pagination($which); ?>
344 344
 				<br class="clear" />
345 345
 			</div>
346 346
 		<?php } else { ?>
347 347
 			<div class="tablenav bottom">
348
-				<?php $this->pagination( $which ); ?>
348
+				<?php $this->pagination($which); ?>
349 349
 				<br class="clear" />
350 350
 			</div>
351 351
 		<?php
@@ -356,7 +356,7 @@  discard block
 block discarded – undo
356 356
 	 * @return array
357 357
 	 */
358 358
 	protected function get_table_classes() {
359
-		return array( 'widefat', $this->_args['plural'] );
359
+		return array('widefat', $this->_args['plural']);
360 360
 	}
361 361
 
362 362
 	/**
@@ -371,23 +371,23 @@  discard block
 block discarded – undo
371 371
 	 * @param object $plugin_b
372 372
 	 * @return int
373 373
 	 */
374
-	private function order_callback( $plugin_a, $plugin_b ) {
374
+	private function order_callback($plugin_a, $plugin_b) {
375 375
 		$orderby = $this->orderby;
376
-		if ( ! isset( $plugin_a->$orderby, $plugin_b->$orderby ) ) {
376
+		if ( ! isset($plugin_a->$orderby, $plugin_b->$orderby)) {
377 377
 			return 0;
378 378
 		}
379 379
 
380 380
 		$a = $plugin_a->$orderby;
381 381
 		$b = $plugin_b->$orderby;
382 382
 
383
-		if ( $a == $b ) {
383
+		if ($a == $b) {
384 384
 			return 0;
385 385
 		}
386 386
 
387
-		if ( 'DESC' === $this->order ) {
388
-			return ( $a < $b ) ? 1 : -1;
387
+		if ('DESC' === $this->order) {
388
+			return ($a < $b) ? 1 : -1;
389 389
 		} else {
390
-			return ( $a < $b ) ? -1 : 1;
390
+			return ($a < $b) ? -1 : 1;
391 391
 		}
392 392
 	}
393 393
 
@@ -396,125 +396,125 @@  discard block
 block discarded – undo
396 396
 	 */
397 397
 	public function display_rows() {
398 398
 		$plugins_allowedtags = array(
399
-			'a' => array( 'href' => array(),'title' => array(), 'target' => array() ),
400
-			'abbr' => array( 'title' => array() ),'acronym' => array( 'title' => array() ),
401
-			'code' => array(), 'pre' => array(), 'em' => array(),'strong' => array(),
399
+			'a' => array('href' => array(), 'title' => array(), 'target' => array()),
400
+			'abbr' => array('title' => array()), 'acronym' => array('title' => array()),
401
+			'code' => array(), 'pre' => array(), 'em' => array(), 'strong' => array(),
402 402
 			'ul' => array(), 'ol' => array(), 'li' => array(), 'p' => array(), 'br' => array()
403 403
 		);
404 404
 
405 405
 		$plugins_group_titles = array(
406
-			'Performance' => _x( 'Performance', 'Plugin installer group title' ),
407
-			'Social'      => _x( 'Social',      'Plugin installer group title' ),
408
-			'Tools'       => _x( 'Tools',       'Plugin installer group title' ),
406
+			'Performance' => _x('Performance', 'Plugin installer group title'),
407
+			'Social'      => _x('Social', 'Plugin installer group title'),
408
+			'Tools'       => _x('Tools', 'Plugin installer group title'),
409 409
 		);
410 410
 
411 411
 		$group = null;
412 412
 
413
-		foreach ( (array) $this->items as $plugin ) {
414
-			if ( is_object( $plugin ) ) {
413
+		foreach ((array) $this->items as $plugin) {
414
+			if (is_object($plugin)) {
415 415
 				$plugin = (array) $plugin;
416 416
 			}
417 417
 
418 418
 			// Display the group heading if there is one
419
-			if ( isset( $plugin['group'] ) && $plugin['group'] != $group ) {
420
-				if ( isset( $this->groups[ $plugin['group'] ] ) ) {
421
-					$group_name = $this->groups[ $plugin['group'] ];
422
-					if ( isset( $plugins_group_titles[ $group_name ] ) ) {
423
-						$group_name = $plugins_group_titles[ $group_name ];
419
+			if (isset($plugin['group']) && $plugin['group'] != $group) {
420
+				if (isset($this->groups[$plugin['group']])) {
421
+					$group_name = $this->groups[$plugin['group']];
422
+					if (isset($plugins_group_titles[$group_name])) {
423
+						$group_name = $plugins_group_titles[$group_name];
424 424
 					}
425 425
 				} else {
426 426
 					$group_name = $plugin['group'];
427 427
 				}
428 428
 
429 429
 				// Starting a new group, close off the divs of the last one
430
-				if ( ! empty( $group ) ) {
430
+				if ( ! empty($group)) {
431 431
 					echo '</div></div>';
432 432
 				}
433 433
 
434
-				echo '<div class="plugin-group"><h3>' . esc_html( $group_name ) . '</h3>';
434
+				echo '<div class="plugin-group"><h3>'.esc_html($group_name).'</h3>';
435 435
 				// needs an extra wrapping div for nth-child selectors to work
436 436
 				echo '<div class="plugin-items">';
437 437
 
438 438
 				$group = $plugin['group'];
439 439
 			}
440
-			$title = wp_kses( $plugin['name'], $plugins_allowedtags );
440
+			$title = wp_kses($plugin['name'], $plugins_allowedtags);
441 441
 
442 442
 			// Remove any HTML from the description.
443
-			$description = strip_tags( $plugin['short_description'] );
444
-			$version = wp_kses( $plugin['version'], $plugins_allowedtags );
443
+			$description = strip_tags($plugin['short_description']);
444
+			$version = wp_kses($plugin['version'], $plugins_allowedtags);
445 445
 
446
-			$name = strip_tags( $title . ' ' . $version );
446
+			$name = strip_tags($title.' '.$version);
447 447
 
448
-			$author = wp_kses( $plugin['author'], $plugins_allowedtags );
449
-			if ( ! empty( $author ) ) {
450
-				$author = ' <cite>' . sprintf( __( 'By %s' ), $author ) . '</cite>';
448
+			$author = wp_kses($plugin['author'], $plugins_allowedtags);
449
+			if ( ! empty($author)) {
450
+				$author = ' <cite>'.sprintf(__('By %s'), $author).'</cite>';
451 451
 			}
452 452
 
453 453
 			$action_links = array();
454 454
 
455
-			if ( current_user_can( 'install_plugins' ) || current_user_can( 'update_plugins' ) ) {
456
-				$status = install_plugin_install_status( $plugin );
455
+			if (current_user_can('install_plugins') || current_user_can('update_plugins')) {
456
+				$status = install_plugin_install_status($plugin);
457 457
 
458
-				switch ( $status['status'] ) {
458
+				switch ($status['status']) {
459 459
 					case 'install':
460
-						if ( $status['url'] ) {
460
+						if ($status['url']) {
461 461
 							/* translators: 1: Plugin name and version. */
462
-							$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>';
462
+							$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>';
463 463
 						}
464 464
 						break;
465 465
 
466 466
 					case 'update_available':
467
-						if ( $status['url'] ) {
467
+						if ($status['url']) {
468 468
 							/* translators: 1: Plugin name and version */
469
-							$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>';
469
+							$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>';
470 470
 						}
471 471
 						break;
472 472
 
473 473
 					case 'latest_installed':
474 474
 					case 'newer_installed':
475
-						if ( is_plugin_active( $status['file'] ) ) {
476
-							$action_links[] = '<button type="button" class="button button-disabled" disabled="disabled">' . _x( 'Active', 'plugin' ) . '</button>';
477
-						} elseif ( current_user_can( 'activate_plugins' ) ) {
478
-							$button_text  = __( 'Activate' );
475
+						if (is_plugin_active($status['file'])) {
476
+							$action_links[] = '<button type="button" class="button button-disabled" disabled="disabled">'._x('Active', 'plugin').'</button>';
477
+						} elseif (current_user_can('activate_plugins')) {
478
+							$button_text  = __('Activate');
479 479
 							/* translators: %s: Plugin name */
480
-							$button_label = _x( 'Activate %s', 'plugin' );
481
-							$activate_url = add_query_arg( array(
482
-								'_wpnonce'    => wp_create_nonce( 'activate-plugin_' . $status['file'] ),
480
+							$button_label = _x('Activate %s', 'plugin');
481
+							$activate_url = add_query_arg(array(
482
+								'_wpnonce'    => wp_create_nonce('activate-plugin_'.$status['file']),
483 483
 								'action'      => 'activate',
484 484
 								'plugin'      => $status['file'],
485
-							), network_admin_url( 'plugins.php' ) );
485
+							), network_admin_url('plugins.php'));
486 486
 
487
-							if ( is_network_admin() ) {
488
-								$button_text  = __( 'Network Activate' );
487
+							if (is_network_admin()) {
488
+								$button_text  = __('Network Activate');
489 489
 								/* translators: %s: Plugin name */
490
-								$button_label = _x( 'Network Activate %s', 'plugin' );
491
-								$activate_url = add_query_arg( array( 'networkwide' => 1 ), $activate_url );
490
+								$button_label = _x('Network Activate %s', 'plugin');
491
+								$activate_url = add_query_arg(array('networkwide' => 1), $activate_url);
492 492
 							}
493 493
 
494 494
 							$action_links[] = sprintf(
495 495
 								'<a href="%1$s" class="button activate-now button-secondary" aria-label="%2$s">%3$s</a>',
496
-								esc_url( $activate_url ),
497
-								esc_attr( sprintf( $button_label, $plugin['name'] ) ),
496
+								esc_url($activate_url),
497
+								esc_attr(sprintf($button_label, $plugin['name'])),
498 498
 								$button_text
499 499
 							);
500 500
 						} else {
501
-							$action_links[] = '<button type="button" class="button button-disabled" disabled="disabled">' . _x( 'Installed', 'plugin' ) . '</button>';
501
+							$action_links[] = '<button type="button" class="button button-disabled" disabled="disabled">'._x('Installed', 'plugin').'</button>';
502 502
 						}
503 503
 						break;
504 504
 				}
505 505
 			}
506 506
 
507
-			$details_link   = self_admin_url( 'plugin-install.php?tab=plugin-information&amp;plugin=' . $plugin['slug'] .
508
-								'&amp;TB_iframe=true&amp;width=600&amp;height=550' );
507
+			$details_link = self_admin_url('plugin-install.php?tab=plugin-information&amp;plugin='.$plugin['slug'].
508
+								'&amp;TB_iframe=true&amp;width=600&amp;height=550');
509 509
 
510 510
 			/* translators: 1: Plugin name and version. */
511
-			$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>';
511
+			$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>';
512 512
 
513
-			if ( !empty( $plugin['icons']['svg'] ) ) {
513
+			if ( ! empty($plugin['icons']['svg'])) {
514 514
 				$plugin_icon_url = $plugin['icons']['svg'];
515
-			} elseif ( !empty( $plugin['icons']['2x'] ) ) {
515
+			} elseif ( ! empty($plugin['icons']['2x'])) {
516 516
 				$plugin_icon_url = $plugin['icons']['2x'];
517
-			} elseif ( !empty( $plugin['icons']['1x'] ) ) {
517
+			} elseif ( ! empty($plugin['icons']['1x'])) {
518 518
 				$plugin_icon_url = $plugin['icons']['1x'];
519 519
 			} else {
520 520
 				$plugin_icon_url = $plugin['icons']['default'];
@@ -528,24 +528,24 @@  discard block
 block discarded – undo
528 528
 			 * @param array $action_links An array of plugin action hyperlinks. Defaults are links to Details and Install Now.
529 529
 			 * @param array $plugin       The plugin currently being listed.
530 530
 			 */
531
-			$action_links = apply_filters( 'plugin_install_action_links', $action_links, $plugin );
531
+			$action_links = apply_filters('plugin_install_action_links', $action_links, $plugin);
532 532
 
533
-			$last_updated_timestamp = strtotime( $plugin['last_updated'] );
533
+			$last_updated_timestamp = strtotime($plugin['last_updated']);
534 534
 		?>
535
-		<div class="plugin-card plugin-card-<?php echo sanitize_html_class( $plugin['slug'] ); ?>">
535
+		<div class="plugin-card plugin-card-<?php echo sanitize_html_class($plugin['slug']); ?>">
536 536
 			<div class="plugin-card-top">
537 537
 				<div class="name column-name">
538 538
 					<h3>
539
-						<a href="<?php echo esc_url( $details_link ); ?>" class="thickbox open-plugin-details-modal">
539
+						<a href="<?php echo esc_url($details_link); ?>" class="thickbox open-plugin-details-modal">
540 540
 						<?php echo $title; ?>
541
-						<img src="<?php echo esc_attr( $plugin_icon_url ) ?>" class="plugin-icon" alt="">
541
+						<img src="<?php echo esc_attr($plugin_icon_url) ?>" class="plugin-icon" alt="">
542 542
 						</a>
543 543
 					</h3>
544 544
 				</div>
545 545
 				<div class="action-links">
546 546
 					<?php
547
-						if ( $action_links ) {
548
-							echo '<ul class="plugin-action-buttons"><li>' . implode( '</li><li>', $action_links ) . '</li></ul>';
547
+						if ($action_links) {
548
+							echo '<ul class="plugin-action-buttons"><li>'.implode('</li><li>', $action_links).'</li></ul>';
549 549
 						}
550 550
 					?>
551 551
 				</div>
@@ -556,30 +556,30 @@  discard block
 block discarded – undo
556 556
 			</div>
557 557
 			<div class="plugin-card-bottom">
558 558
 				<div class="vers column-rating">
559
-					<?php wp_star_rating( array( 'rating' => $plugin['rating'], 'type' => 'percent', 'number' => $plugin['num_ratings'] ) ); ?>
560
-					<span class="num-ratings" aria-hidden="true">(<?php echo number_format_i18n( $plugin['num_ratings'] ); ?>)</span>
559
+					<?php wp_star_rating(array('rating' => $plugin['rating'], 'type' => 'percent', 'number' => $plugin['num_ratings'])); ?>
560
+					<span class="num-ratings" aria-hidden="true">(<?php echo number_format_i18n($plugin['num_ratings']); ?>)</span>
561 561
 				</div>
562 562
 				<div class="column-updated">
563
-					<strong><?php _e( 'Last Updated:' ); ?></strong> <?php printf( __( '%s ago' ), human_time_diff( $last_updated_timestamp ) ); ?>
563
+					<strong><?php _e('Last Updated:'); ?></strong> <?php printf(__('%s ago'), human_time_diff($last_updated_timestamp)); ?>
564 564
 				</div>
565 565
 				<div class="column-downloaded">
566 566
 					<?php
567
-					if ( $plugin['active_installs'] >= 1000000 ) {
568
-						$active_installs_text = _x( '1+ Million', 'Active plugin installs' );
567
+					if ($plugin['active_installs'] >= 1000000) {
568
+						$active_installs_text = _x('1+ Million', 'Active plugin installs');
569 569
 					} else {
570
-						$active_installs_text = number_format_i18n( $plugin['active_installs'] ) . '+';
570
+						$active_installs_text = number_format_i18n($plugin['active_installs']).'+';
571 571
 					}
572
-					printf( __( '%s Active Installs' ), $active_installs_text );
572
+					printf(__('%s Active Installs'), $active_installs_text);
573 573
 					?>
574 574
 				</div>
575 575
 				<div class="column-compatibility">
576 576
 					<?php
577
-					if ( ! empty( $plugin['tested'] ) && version_compare( substr( $GLOBALS['wp_version'], 0, strlen( $plugin['tested'] ) ), $plugin['tested'], '>' ) ) {
578
-						echo '<span class="compatibility-untested">' . __( 'Untested with your version of WordPress' ) . '</span>';
579
-					} elseif ( ! empty( $plugin['requires'] ) && version_compare( substr( $GLOBALS['wp_version'], 0, strlen( $plugin['requires'] ) ), $plugin['requires'], '<' ) ) {
580
-						echo '<span class="compatibility-incompatible">' . __( '<strong>Incompatible</strong> with your version of WordPress' ) . '</span>';
577
+					if ( ! empty($plugin['tested']) && version_compare(substr($GLOBALS['wp_version'], 0, strlen($plugin['tested'])), $plugin['tested'], '>')) {
578
+						echo '<span class="compatibility-untested">'.__('Untested with your version of WordPress').'</span>';
579
+					} elseif ( ! empty($plugin['requires']) && version_compare(substr($GLOBALS['wp_version'], 0, strlen($plugin['requires'])), $plugin['requires'], '<')) {
580
+						echo '<span class="compatibility-incompatible">'.__('<strong>Incompatible</strong> with your version of WordPress').'</span>';
581 581
 					} else {
582
-						echo '<span class="compatibility-compatible">' . __( '<strong>Compatible</strong> with your version of WordPress' ) . '</span>';
582
+						echo '<span class="compatibility-compatible">'.__('<strong>Compatible</strong> with your version of WordPress').'</span>';
583 583
 					}
584 584
 					?>
585 585
 				</div>
@@ -589,7 +589,7 @@  discard block
 block discarded – undo
589 589
 		}
590 590
 
591 591
 		// Close off the group divs of the last one
592
-		if ( ! empty( $group ) ) {
592
+		if ( ! empty($group)) {
593 593
 			echo '</div></div>';
594 594
 		}
595 595
 	}
Please login to merge, or discard this patch.
src/wp-admin/includes/ajax-actions.php 2 patches
Spacing   +1276 added lines, -1276 removed lines patch added patch discarded remove patch
@@ -23,13 +23,13 @@  discard block
 block discarded – undo
23 23
 	$response = array();
24 24
 
25 25
 	// screen_id is the same as $current_screen->id and the JS global 'pagenow'.
26
-	if ( ! empty($_POST['screen_id']) )
26
+	if ( ! empty($_POST['screen_id']))
27 27
 		$screen_id = sanitize_key($_POST['screen_id']);
28 28
 	else
29 29
 		$screen_id = 'front';
30 30
 
31
-	if ( ! empty($_POST['data']) ) {
32
-		$data = wp_unslash( (array) $_POST['data'] );
31
+	if ( ! empty($_POST['data'])) {
32
+		$data = wp_unslash((array) $_POST['data']);
33 33
 
34 34
 		/**
35 35
 		 * Filters Heartbeat Ajax response in no-privilege environments.
@@ -40,7 +40,7 @@  discard block
 block discarded – undo
40 40
 		 * @param array        $data      An array of data passed via $_POST.
41 41
 		 * @param string       $screen_id The screen id.
42 42
 		 */
43
-		$response = apply_filters( 'heartbeat_nopriv_received', $response, $data, $screen_id );
43
+		$response = apply_filters('heartbeat_nopriv_received', $response, $data, $screen_id);
44 44
 	}
45 45
 
46 46
 	/**
@@ -51,7 +51,7 @@  discard block
 block discarded – undo
51 51
 	 * @param array|object $response  The Heartbeat response object or array.
52 52
 	 * @param string       $screen_id The screen id.
53 53
 	 */
54
-	$response = apply_filters( 'heartbeat_nopriv_send', $response, $screen_id );
54
+	$response = apply_filters('heartbeat_nopriv_send', $response, $screen_id);
55 55
 
56 56
 	/**
57 57
 	 * Fires when Heartbeat ticks in no-privilege environments.
@@ -63,7 +63,7 @@  discard block
 block discarded – undo
63 63
 	 * @param array|object $response  The no-priv Heartbeat response.
64 64
 	 * @param string       $screen_id The screen id.
65 65
 	 */
66
-	do_action( 'heartbeat_nopriv_tick', $response, $screen_id );
66
+	do_action('heartbeat_nopriv_tick', $response, $screen_id);
67 67
 
68 68
 	// Send the current time according to the server.
69 69
 	$response['server_time'] = time();
@@ -86,18 +86,18 @@  discard block
 block discarded – undo
86 86
 	global $wp_list_table;
87 87
 
88 88
 	$list_class = $_GET['list_args']['class'];
89
-	check_ajax_referer( "fetch-list-$list_class", '_ajax_fetch_list_nonce' );
89
+	check_ajax_referer("fetch-list-$list_class", '_ajax_fetch_list_nonce');
90 90
 
91
-	$wp_list_table = _get_list_table( $list_class, array( 'screen' => $_GET['list_args']['screen']['id'] ) );
92
-	if ( ! $wp_list_table )
93
-		wp_die( 0 );
91
+	$wp_list_table = _get_list_table($list_class, array('screen' => $_GET['list_args']['screen']['id']));
92
+	if ( ! $wp_list_table)
93
+		wp_die(0);
94 94
 
95
-	if ( ! $wp_list_table->ajax_user_can() )
95
+	if ( ! $wp_list_table->ajax_user_can())
96 96
 		wp_die( -1 );
97 97
 
98 98
 	$wp_list_table->ajax_response();
99 99
 
100
-	wp_die( 0 );
100
+	wp_die(0);
101 101
 }
102 102
 
103 103
 /**
@@ -106,30 +106,30 @@  discard block
 block discarded – undo
106 106
  * @since 3.1.0
107 107
  */
108 108
 function wp_ajax_ajax_tag_search() {
109
-	if ( ! isset( $_GET['tax'] ) ) {
110
-		wp_die( 0 );
109
+	if ( ! isset($_GET['tax'])) {
110
+		wp_die(0);
111 111
 	}
112 112
 
113
-	$taxonomy = sanitize_key( $_GET['tax'] );
114
-	$tax = get_taxonomy( $taxonomy );
115
-	if ( ! $tax ) {
116
-		wp_die( 0 );
113
+	$taxonomy = sanitize_key($_GET['tax']);
114
+	$tax = get_taxonomy($taxonomy);
115
+	if ( ! $tax) {
116
+		wp_die(0);
117 117
 	}
118 118
 
119
-	if ( ! current_user_can( $tax->cap->assign_terms ) ) {
119
+	if ( ! current_user_can($tax->cap->assign_terms)) {
120 120
 		wp_die( -1 );
121 121
 	}
122 122
 
123
-	$s = wp_unslash( $_GET['q'] );
123
+	$s = wp_unslash($_GET['q']);
124 124
 
125
-	$comma = _x( ',', 'tag delimiter' );
126
-	if ( ',' !== $comma )
127
-		$s = str_replace( $comma, ',', $s );
128
-	if ( false !== strpos( $s, ',' ) ) {
129
-		$s = explode( ',', $s );
130
-		$s = $s[count( $s ) - 1];
125
+	$comma = _x(',', 'tag delimiter');
126
+	if (',' !== $comma)
127
+		$s = str_replace($comma, ',', $s);
128
+	if (false !== strpos($s, ',')) {
129
+		$s = explode(',', $s);
130
+		$s = $s[count($s) - 1];
131 131
 	}
132
-	$s = trim( $s );
132
+	$s = trim($s);
133 133
 
134 134
 	/**
135 135
 	 * Filters the minimum number of characters required to fire a tag search via Ajax.
@@ -140,19 +140,19 @@  discard block
 block discarded – undo
140 140
 	 * @param object $tax        The taxonomy object.
141 141
 	 * @param string $s          The search term.
142 142
 	 */
143
-	$term_search_min_chars = (int) apply_filters( 'term_search_min_chars', 2, $tax, $s );
143
+	$term_search_min_chars = (int) apply_filters('term_search_min_chars', 2, $tax, $s);
144 144
 
145 145
 	/*
146 146
 	 * Require $term_search_min_chars chars for matching (default: 2)
147 147
 	 * ensure it's a non-negative, non-zero integer.
148 148
 	 */
149
-	if ( ( $term_search_min_chars == 0 ) || ( strlen( $s ) < $term_search_min_chars ) ){
149
+	if (($term_search_min_chars == 0) || (strlen($s) < $term_search_min_chars)) {
150 150
 		wp_die();
151 151
 	}
152 152
 
153
-	$results = get_terms( $taxonomy, array( 'name__like' => $s, 'fields' => 'names', 'hide_empty' => false ) );
153
+	$results = get_terms($taxonomy, array('name__like' => $s, 'fields' => 'names', 'hide_empty' => false));
154 154
 
155
-	echo join( $results, "\n" );
155
+	echo join($results, "\n");
156 156
 	wp_die();
157 157
 }
158 158
 
@@ -162,49 +162,49 @@  discard block
 block discarded – undo
162 162
  * @since 3.1.0
163 163
  */
164 164
 function wp_ajax_wp_compression_test() {
165
-	if ( !current_user_can( 'manage_options' ) )
165
+	if ( ! current_user_can('manage_options'))
166 166
 		wp_die( -1 );
167 167
 
168
-	if ( ini_get('zlib.output_compression') || 'ob_gzhandler' == ini_get('output_handler') ) {
168
+	if (ini_get('zlib.output_compression') || 'ob_gzhandler' == ini_get('output_handler')) {
169 169
 		update_site_option('can_compress_scripts', 0);
170
-		wp_die( 0 );
170
+		wp_die(0);
171 171
 	}
172 172
 
173
-	if ( isset($_GET['test']) ) {
174
-		header( 'Expires: Wed, 11 Jan 1984 05:00:00 GMT' );
175
-		header( 'Last-Modified: ' . gmdate( 'D, d M Y H:i:s' ) . ' GMT' );
176
-		header( 'Cache-Control: no-cache, must-revalidate, max-age=0' );
173
+	if (isset($_GET['test'])) {
174
+		header('Expires: Wed, 11 Jan 1984 05:00:00 GMT');
175
+		header('Last-Modified: '.gmdate('D, d M Y H:i:s').' GMT');
176
+		header('Cache-Control: no-cache, must-revalidate, max-age=0');
177 177
 		header('Content-Type: application/javascript; charset=UTF-8');
178
-		$force_gzip = ( defined('ENFORCE_GZIP') && ENFORCE_GZIP );
178
+		$force_gzip = (defined('ENFORCE_GZIP') && ENFORCE_GZIP);
179 179
 		$test_str = '"wpCompressionTest Lorem ipsum dolor sit amet consectetuer mollis sapien urna ut a. Eu nonummy condimentum fringilla tempor pretium platea vel nibh netus Maecenas. Hac molestie amet justo quis pellentesque est ultrices interdum nibh Morbi. Cras mattis pretium Phasellus ante ipsum ipsum ut sociis Suspendisse Lorem. Ante et non molestie. Porta urna Vestibulum egestas id congue nibh eu risus gravida sit. Ac augue auctor Ut et non a elit massa id sodales. Elit eu Nulla at nibh adipiscing mattis lacus mauris at tempus. Netus nibh quis suscipit nec feugiat eget sed lorem et urna. Pellentesque lacus at ut massa consectetuer ligula ut auctor semper Pellentesque. Ut metus massa nibh quam Curabitur molestie nec mauris congue. Volutpat molestie elit justo facilisis neque ac risus Ut nascetur tristique. Vitae sit lorem tellus et quis Phasellus lacus tincidunt nunc Fusce. Pharetra wisi Suspendisse mus sagittis libero lacinia Integer consequat ac Phasellus. Et urna ac cursus tortor aliquam Aliquam amet tellus volutpat Vestibulum. Justo interdum condimentum In augue congue tellus sollicitudin Quisque quis nibh."';
180 180
 
181
-		 if ( 1 == $_GET['test'] ) {
181
+		 if (1 == $_GET['test']) {
182 182
 		 	echo $test_str;
183 183
 		 	wp_die();
184
-		 } elseif ( 2 == $_GET['test'] ) {
185
-			if ( !isset($_SERVER['HTTP_ACCEPT_ENCODING']) )
184
+		 } elseif (2 == $_GET['test']) {
185
+			if ( ! isset($_SERVER['HTTP_ACCEPT_ENCODING']))
186 186
 				wp_die( -1 );
187
-			if ( false !== stripos( $_SERVER['HTTP_ACCEPT_ENCODING'], 'deflate') && function_exists('gzdeflate') && ! $force_gzip ) {
187
+			if (false !== stripos($_SERVER['HTTP_ACCEPT_ENCODING'], 'deflate') && function_exists('gzdeflate') && ! $force_gzip) {
188 188
 				header('Content-Encoding: deflate');
189
-				$out = gzdeflate( $test_str, 1 );
190
-			} elseif ( false !== stripos( $_SERVER['HTTP_ACCEPT_ENCODING'], 'gzip') && function_exists('gzencode') ) {
189
+				$out = gzdeflate($test_str, 1);
190
+			} elseif (false !== stripos($_SERVER['HTTP_ACCEPT_ENCODING'], 'gzip') && function_exists('gzencode')) {
191 191
 				header('Content-Encoding: gzip');
192
-				$out = gzencode( $test_str, 1 );
192
+				$out = gzencode($test_str, 1);
193 193
 			} else {
194 194
 				wp_die( -1 );
195 195
 			}
196 196
 			echo $out;
197 197
 			wp_die();
198
-		} elseif ( 'no' == $_GET['test'] ) {
199
-			check_ajax_referer( 'update_can_compress_scripts' );
198
+		} elseif ('no' == $_GET['test']) {
199
+			check_ajax_referer('update_can_compress_scripts');
200 200
 			update_site_option('can_compress_scripts', 0);
201
-		} elseif ( 'yes' == $_GET['test'] ) {
202
-			check_ajax_referer( 'update_can_compress_scripts' );
201
+		} elseif ('yes' == $_GET['test']) {
202
+			check_ajax_referer('update_can_compress_scripts');
203 203
 			update_site_option('can_compress_scripts', 1);
204 204
 		}
205 205
 	}
206 206
 
207
-	wp_die( 0 );
207
+	wp_die(0);
208 208
 }
209 209
 
210 210
 /**
@@ -214,13 +214,13 @@  discard block
 block discarded – undo
214 214
  */
215 215
 function wp_ajax_imgedit_preview() {
216 216
 	$post_id = intval($_GET['postid']);
217
-	if ( empty($post_id) || !current_user_can('edit_post', $post_id) )
217
+	if (empty($post_id) || ! current_user_can('edit_post', $post_id))
218 218
 		wp_die( -1 );
219 219
 
220
-	check_ajax_referer( "image_editor-$post_id" );
220
+	check_ajax_referer("image_editor-$post_id");
221 221
 
222
-	include_once( ABSPATH . 'wp-admin/includes/image-edit.php' );
223
-	if ( ! stream_preview_image($post_id) )
222
+	include_once(ABSPATH.'wp-admin/includes/image-edit.php');
223
+	if ( ! stream_preview_image($post_id))
224 224
 		wp_die( -1 );
225 225
 
226 226
 	wp_die();
@@ -234,8 +234,8 @@  discard block
 block discarded – undo
234 234
  * @global WP_Embed $wp_embed
235 235
  */
236 236
 function wp_ajax_oembed_cache() {
237
-	$GLOBALS['wp_embed']->cache_oembed( $_GET['post'] );
238
-	wp_die( 0 );
237
+	$GLOBALS['wp_embed']->cache_oembed($_GET['post']);
238
+	wp_die(0);
239 239
 }
240 240
 
241 241
 /**
@@ -244,18 +244,18 @@  discard block
 block discarded – undo
244 244
  * @since 3.4.0
245 245
  */
246 246
 function wp_ajax_autocomplete_user() {
247
-	if ( ! is_multisite() || ! current_user_can( 'promote_users' ) || wp_is_large_network( 'users' ) )
247
+	if ( ! is_multisite() || ! current_user_can('promote_users') || wp_is_large_network('users'))
248 248
 		wp_die( -1 );
249 249
 
250 250
 	/** This filter is documented in wp-admin/user-new.php */
251
-	if ( ! is_super_admin() && ! apply_filters( 'autocomplete_users_for_site_admins', false ) )
251
+	if ( ! is_super_admin() && ! apply_filters('autocomplete_users_for_site_admins', false))
252 252
 		wp_die( -1 );
253 253
 
254 254
 	$return = array();
255 255
 
256 256
 	// Check the type of request
257 257
 	// Current allowed values are `add` and `search`
258
-	if ( isset( $_REQUEST['autocomplete_type'] ) && 'search' === $_REQUEST['autocomplete_type'] ) {
258
+	if (isset($_REQUEST['autocomplete_type']) && 'search' === $_REQUEST['autocomplete_type']) {
259 259
 		$type = $_REQUEST['autocomplete_type'];
260 260
 	} else {
261 261
 		$type = 'add';
@@ -263,39 +263,39 @@  discard block
 block discarded – undo
263 263
 
264 264
 	// Check the desired field for value
265 265
 	// Current allowed values are `user_email` and `user_login`
266
-	if ( isset( $_REQUEST['autocomplete_field'] ) && 'user_email' === $_REQUEST['autocomplete_field'] ) {
266
+	if (isset($_REQUEST['autocomplete_field']) && 'user_email' === $_REQUEST['autocomplete_field']) {
267 267
 		$field = $_REQUEST['autocomplete_field'];
268 268
 	} else {
269 269
 		$field = 'user_login';
270 270
 	}
271 271
 
272 272
 	// Exclude current users of this blog
273
-	if ( isset( $_REQUEST['site_id'] ) ) {
274
-		$id = absint( $_REQUEST['site_id'] );
273
+	if (isset($_REQUEST['site_id'])) {
274
+		$id = absint($_REQUEST['site_id']);
275 275
 	} else {
276 276
 		$id = get_current_blog_id();
277 277
 	}
278 278
 
279
-	$include_blog_users = ( $type == 'search' ? get_users( array( 'blog_id' => $id, 'fields' => 'ID' ) ) : array() );
280
-	$exclude_blog_users = ( $type == 'add' ? get_users( array( 'blog_id' => $id, 'fields' => 'ID' ) ) : array() );
279
+	$include_blog_users = ($type == 'search' ? get_users(array('blog_id' => $id, 'fields' => 'ID')) : array());
280
+	$exclude_blog_users = ($type == 'add' ? get_users(array('blog_id' => $id, 'fields' => 'ID')) : array());
281 281
 
282
-	$users = get_users( array(
282
+	$users = get_users(array(
283 283
 		'blog_id' => false,
284
-		'search'  => '*' . $_REQUEST['term'] . '*',
284
+		'search'  => '*'.$_REQUEST['term'].'*',
285 285
 		'include' => $include_blog_users,
286 286
 		'exclude' => $exclude_blog_users,
287
-		'search_columns' => array( 'user_login', 'user_nicename', 'user_email' ),
288
-	) );
287
+		'search_columns' => array('user_login', 'user_nicename', 'user_email'),
288
+	));
289 289
 
290
-	foreach ( $users as $user ) {
290
+	foreach ($users as $user) {
291 291
 		$return[] = array(
292 292
 			/* translators: 1: user_login, 2: user_email */
293
-			'label' => sprintf( _x( '%1$s (%2$s)', 'user autocomplete result' ), $user->user_login, $user->user_email ),
293
+			'label' => sprintf(_x('%1$s (%2$s)', 'user autocomplete result'), $user->user_login, $user->user_email),
294 294
 			'value' => $user->$field,
295 295
 		);
296 296
 	}
297 297
 
298
-	wp_die( wp_json_encode( $return ) );
298
+	wp_die(wp_json_encode($return));
299 299
 }
300 300
 
301 301
 /**
@@ -304,14 +304,14 @@  discard block
 block discarded – undo
304 304
  * @since 3.4.0
305 305
  */
306 306
 function wp_ajax_dashboard_widgets() {
307
-	require_once ABSPATH . 'wp-admin/includes/dashboard.php';
307
+	require_once ABSPATH.'wp-admin/includes/dashboard.php';
308 308
 
309 309
 	$pagenow = $_GET['pagenow'];
310
-	if ( $pagenow === 'dashboard-user' || $pagenow === 'dashboard-network' || $pagenow === 'dashboard' ) {
311
-		set_current_screen( $pagenow );
310
+	if ($pagenow === 'dashboard-user' || $pagenow === 'dashboard-network' || $pagenow === 'dashboard') {
311
+		set_current_screen($pagenow);
312 312
 	}
313 313
 
314
-	switch ( $_GET['widget'] ) {
314
+	switch ($_GET['widget']) {
315 315
 		case 'dashboard_primary' :
316 316
 			wp_dashboard_primary();
317 317
 			break;
@@ -325,7 +325,7 @@  discard block
 block discarded – undo
325 325
  * @since 3.4.0
326 326
  */
327 327
 function wp_ajax_logged_in() {
328
-	wp_die( 1 );
328
+	wp_die(1);
329 329
 }
330 330
 
331 331
 //
@@ -343,30 +343,30 @@  discard block
 block discarded – undo
343 343
  * @param int $comment_id
344 344
  * @param int $delta
345 345
  */
346
-function _wp_ajax_delete_comment_response( $comment_id, $delta = -1 ) {
347
-	$total    = isset( $_POST['_total'] )    ? (int) $_POST['_total']    : 0;
348
-	$per_page = isset( $_POST['_per_page'] ) ? (int) $_POST['_per_page'] : 0;
349
-	$page     = isset( $_POST['_page'] )     ? (int) $_POST['_page']     : 0;
350
-	$url      = isset( $_POST['_url'] )      ? esc_url_raw( $_POST['_url'] ) : '';
346
+function _wp_ajax_delete_comment_response($comment_id, $delta = -1) {
347
+	$total    = isset($_POST['_total']) ? (int) $_POST['_total'] : 0;
348
+	$per_page = isset($_POST['_per_page']) ? (int) $_POST['_per_page'] : 0;
349
+	$page     = isset($_POST['_page']) ? (int) $_POST['_page'] : 0;
350
+	$url      = isset($_POST['_url']) ? esc_url_raw($_POST['_url']) : '';
351 351
 
352 352
 	// JS didn't send us everything we need to know. Just die with success message
353
-	if ( ! $total || ! $per_page || ! $page || ! $url ) {
353
+	if ( ! $total || ! $per_page || ! $page || ! $url) {
354 354
 		$time           = time();
355
-		$comment        = get_comment( $comment_id );
355
+		$comment        = get_comment($comment_id);
356 356
 		$comment_status = '';
357 357
 		$comment_link   = '';
358 358
 
359
-		if ( $comment ) {
359
+		if ($comment) {
360 360
 			$comment_status = $comment->comment_approved;
361 361
 		}
362 362
 
363
-		if ( 1 === (int) $comment_status ) {
364
-			$comment_link = get_comment_link( $comment );
363
+		if (1 === (int) $comment_status) {
364
+			$comment_link = get_comment_link($comment);
365 365
 		}
366 366
 
367 367
 		$counts = wp_count_comments();
368 368
 
369
-		$x = new WP_Ajax_Response( array(
369
+		$x = new WP_Ajax_Response(array(
370 370
 			'what' => 'comment',
371 371
 			// Here for completeness - not used.
372 372
 			'id' => $comment_id,
@@ -376,45 +376,45 @@  discard block
 block discarded – undo
376 376
 				'time' => $time,
377 377
 				'in_moderation' => $counts->moderated,
378 378
 				'i18n_comments_text' => sprintf(
379
-					_n( '%s Comment', '%s Comments', $counts->approved ),
380
-					number_format_i18n( $counts->approved )
379
+					_n('%s Comment', '%s Comments', $counts->approved),
380
+					number_format_i18n($counts->approved)
381 381
 				),
382 382
 				'i18n_moderation_text' => sprintf(
383
-					_nx( '%s in moderation', '%s in moderation', $counts->moderated, 'comments' ),
384
-					number_format_i18n( $counts->moderated )
383
+					_nx('%s in moderation', '%s in moderation', $counts->moderated, 'comments'),
384
+					number_format_i18n($counts->moderated)
385 385
 				),
386 386
 				'comment_link' => $comment_link,
387 387
 			)
388
-		) );
388
+		));
389 389
 		$x->send();
390 390
 	}
391 391
 
392 392
 	$total += $delta;
393
-	if ( $total < 0 )
393
+	if ($total < 0)
394 394
 		$total = 0;
395 395
 
396 396
 	// Only do the expensive stuff on a page-break, and about 1 other time per page
397
-	if ( 0 == $total % $per_page || 1 == mt_rand( 1, $per_page ) ) {
397
+	if (0 == $total % $per_page || 1 == mt_rand(1, $per_page)) {
398 398
 		$post_id = 0;
399 399
 		// What type of comment count are we looking for?
400 400
 		$status = 'all';
401
-		$parsed = parse_url( $url );
402
-		if ( isset( $parsed['query'] ) ) {
403
-			parse_str( $parsed['query'], $query_vars );
404
-			if ( !empty( $query_vars['comment_status'] ) )
401
+		$parsed = parse_url($url);
402
+		if (isset($parsed['query'])) {
403
+			parse_str($parsed['query'], $query_vars);
404
+			if ( ! empty($query_vars['comment_status']))
405 405
 				$status = $query_vars['comment_status'];
406
-			if ( !empty( $query_vars['p'] ) )
406
+			if ( ! empty($query_vars['p']))
407 407
 				$post_id = (int) $query_vars['p'];
408
-			if ( ! empty( $query_vars['comment_type'] ) )
408
+			if ( ! empty($query_vars['comment_type']))
409 409
 				$type = $query_vars['comment_type'];
410 410
 		}
411 411
 
412
-		if ( empty( $type ) ) {
412
+		if (empty($type)) {
413 413
 			// Only use the comment count if not filtering by a comment_type.
414 414
 			$comment_count = wp_count_comments($post_id);
415 415
 
416 416
 			// We're looking for a known type of comment count.
417
-			if ( isset( $comment_count->$status ) ) {
417
+			if (isset($comment_count->$status)) {
418 418
 				$total = $comment_count->$status;
419 419
 			}
420 420
 		}
@@ -423,22 +423,22 @@  discard block
 block discarded – undo
423 423
 
424 424
 	// The time since the last comment count.
425 425
 	$time = time();
426
-	$comment = get_comment( $comment_id );
426
+	$comment = get_comment($comment_id);
427 427
 
428
-	$x = new WP_Ajax_Response( array(
428
+	$x = new WP_Ajax_Response(array(
429 429
 		'what' => 'comment',
430 430
 		// Here for completeness - not used.
431 431
 		'id' => $comment_id,
432 432
 		'supplemental' => array(
433 433
 			'status' => $comment ? $comment->comment_approved : '',
434 434
 			'postId' => $comment ? $comment->comment_post_ID : '',
435
-			'total_items_i18n' => sprintf( _n( '%s item', '%s items', $total ), number_format_i18n( $total ) ),
436
-			'total_pages' => ceil( $total / $per_page ),
437
-			'total_pages_i18n' => number_format_i18n( ceil( $total / $per_page ) ),
435
+			'total_items_i18n' => sprintf(_n('%s item', '%s items', $total), number_format_i18n($total)),
436
+			'total_pages' => ceil($total / $per_page),
437
+			'total_pages_i18n' => number_format_i18n(ceil($total / $per_page)),
438 438
 			'total' => $total,
439 439
 			'time' => $time
440 440
 		)
441
-	) );
441
+	));
442 442
 	$x->send();
443 443
 }
444 444
 
@@ -455,87 +455,87 @@  discard block
 block discarded – undo
455 455
 function _wp_ajax_add_hierarchical_term() {
456 456
 	$action = $_POST['action'];
457 457
 	$taxonomy = get_taxonomy(substr($action, 4));
458
-	check_ajax_referer( $action, '_ajax_nonce-add-' . $taxonomy->name );
459
-	if ( !current_user_can( $taxonomy->cap->edit_terms ) )
458
+	check_ajax_referer($action, '_ajax_nonce-add-'.$taxonomy->name);
459
+	if ( ! current_user_can($taxonomy->cap->edit_terms))
460 460
 		wp_die( -1 );
461 461
 	$names = explode(',', $_POST['new'.$taxonomy->name]);
462 462
 	$parent = isset($_POST['new'.$taxonomy->name.'_parent']) ? (int) $_POST['new'.$taxonomy->name.'_parent'] : 0;
463
-	if ( 0 > $parent )
463
+	if (0 > $parent)
464 464
 		$parent = 0;
465
-	if ( $taxonomy->name == 'category' )
465
+	if ($taxonomy->name == 'category')
466 466
 		$post_category = isset($_POST['post_category']) ? (array) $_POST['post_category'] : array();
467 467
 	else
468
-		$post_category = ( isset($_POST['tax_input']) && isset($_POST['tax_input'][$taxonomy->name]) ) ? (array) $_POST['tax_input'][$taxonomy->name] : array();
469
-	$checked_categories = array_map( 'absint', (array) $post_category );
468
+		$post_category = (isset($_POST['tax_input']) && isset($_POST['tax_input'][$taxonomy->name])) ? (array) $_POST['tax_input'][$taxonomy->name] : array();
469
+	$checked_categories = array_map('absint', (array) $post_category);
470 470
 	$popular_ids = wp_popular_terms_checklist($taxonomy->name, 0, 10, false);
471 471
 
472
-	foreach ( $names as $cat_name ) {
472
+	foreach ($names as $cat_name) {
473 473
 		$cat_name = trim($cat_name);
474 474
 		$category_nicename = sanitize_title($cat_name);
475
-		if ( '' === $category_nicename )
475
+		if ('' === $category_nicename)
476 476
 			continue;
477
-		if ( !$cat_id = term_exists( $cat_name, $taxonomy->name, $parent ) )
478
-			$cat_id = wp_insert_term( $cat_name, $taxonomy->name, array( 'parent' => $parent ) );
479
-		if ( is_wp_error( $cat_id ) ) {
477
+		if ( ! $cat_id = term_exists($cat_name, $taxonomy->name, $parent))
478
+			$cat_id = wp_insert_term($cat_name, $taxonomy->name, array('parent' => $parent));
479
+		if (is_wp_error($cat_id)) {
480 480
 			continue;
481
-		} elseif ( is_array( $cat_id ) ) {
481
+		} elseif (is_array($cat_id)) {
482 482
 			$cat_id = $cat_id['term_id'];
483 483
 		}
484 484
 		$checked_categories[] = $cat_id;
485
-		if ( $parent ) // Do these all at once in a second
485
+		if ($parent) // Do these all at once in a second
486 486
 			continue;
487 487
 
488 488
 		ob_start();
489 489
 
490
-		wp_terms_checklist( 0, array( 'taxonomy' => $taxonomy->name, 'descendants_and_self' => $cat_id, 'selected_cats' => $checked_categories, 'popular_cats' => $popular_ids ));
490
+		wp_terms_checklist(0, array('taxonomy' => $taxonomy->name, 'descendants_and_self' => $cat_id, 'selected_cats' => $checked_categories, 'popular_cats' => $popular_ids));
491 491
 
492 492
 		$data = ob_get_clean();
493 493
 
494 494
 		$add = array(
495 495
 			'what' => $taxonomy->name,
496 496
 			'id' => $cat_id,
497
-			'data' => str_replace( array("\n", "\t"), '', $data),
497
+			'data' => str_replace(array("\n", "\t"), '', $data),
498 498
 			'position' => -1
499 499
 		);
500 500
 	}
501 501
 
502
-	if ( $parent ) { // Foncy - replace the parent and all its children
503
-		$parent = get_term( $parent, $taxonomy->name );
502
+	if ($parent) { // Foncy - replace the parent and all its children
503
+		$parent = get_term($parent, $taxonomy->name);
504 504
 		$term_id = $parent->term_id;
505 505
 
506
-		while ( $parent->parent ) { // get the top parent
507
-			$parent = get_term( $parent->parent, $taxonomy->name );
508
-			if ( is_wp_error( $parent ) )
506
+		while ($parent->parent) { // get the top parent
507
+			$parent = get_term($parent->parent, $taxonomy->name);
508
+			if (is_wp_error($parent))
509 509
 				break;
510 510
 			$term_id = $parent->term_id;
511 511
 		}
512 512
 
513 513
 		ob_start();
514 514
 
515
-		wp_terms_checklist( 0, array('taxonomy' => $taxonomy->name, 'descendants_and_self' => $term_id, 'selected_cats' => $checked_categories, 'popular_cats' => $popular_ids));
515
+		wp_terms_checklist(0, array('taxonomy' => $taxonomy->name, 'descendants_and_self' => $term_id, 'selected_cats' => $checked_categories, 'popular_cats' => $popular_ids));
516 516
 
517 517
 		$data = ob_get_clean();
518 518
 
519 519
 		$add = array(
520 520
 			'what' => $taxonomy->name,
521 521
 			'id' => $term_id,
522
-			'data' => str_replace( array("\n", "\t"), '', $data),
522
+			'data' => str_replace(array("\n", "\t"), '', $data),
523 523
 			'position' => -1
524 524
 		);
525 525
 	}
526 526
 
527 527
 	ob_start();
528 528
 
529
-	wp_dropdown_categories( array(
529
+	wp_dropdown_categories(array(
530 530
 		'taxonomy' => $taxonomy->name, 'hide_empty' => 0, 'name' => 'new'.$taxonomy->name.'_parent', 'orderby' => 'name',
531 531
 		'hierarchical' => 1, 'show_option_none' => '&mdash; '.$taxonomy->labels->parent_item.' &mdash;'
532
-	) );
532
+	));
533 533
 
534 534
 	$sup = ob_get_clean();
535 535
 
536
-	$add['supplemental'] = array( 'newcat_parent' => $sup );
536
+	$add['supplemental'] = array('newcat_parent' => $sup);
537 537
 
538
-	$x = new WP_Ajax_Response( $add );
538
+	$x = new WP_Ajax_Response($add);
539 539
 	$x->send();
540 540
 }
541 541
 
@@ -545,46 +545,46 @@  discard block
 block discarded – undo
545 545
  * @since 3.1.0
546 546
  */
547 547
 function wp_ajax_delete_comment() {
548
-	$id = isset( $_POST['id'] ) ? (int) $_POST['id'] : 0;
548
+	$id = isset($_POST['id']) ? (int) $_POST['id'] : 0;
549 549
 
550
-	if ( !$comment = get_comment( $id ) )
551
-		wp_die( time() );
552
-	if ( ! current_user_can( 'edit_comment', $comment->comment_ID ) )
550
+	if ( ! $comment = get_comment($id))
551
+		wp_die(time());
552
+	if ( ! current_user_can('edit_comment', $comment->comment_ID))
553 553
 		wp_die( -1 );
554 554
 
555
-	check_ajax_referer( "delete-comment_$id" );
556
-	$status = wp_get_comment_status( $comment );
555
+	check_ajax_referer("delete-comment_$id");
556
+	$status = wp_get_comment_status($comment);
557 557
 
558 558
 	$delta = -1;
559
-	if ( isset($_POST['trash']) && 1 == $_POST['trash'] ) {
560
-		if ( 'trash' == $status )
561
-			wp_die( time() );
562
-		$r = wp_trash_comment( $comment );
563
-	} elseif ( isset($_POST['untrash']) && 1 == $_POST['untrash'] ) {
564
-		if ( 'trash' != $status )
565
-			wp_die( time() );
566
-		$r = wp_untrash_comment( $comment );
567
-		if ( ! isset( $_POST['comment_status'] ) || $_POST['comment_status'] != 'trash' ) // undo trash, not in trash
559
+	if (isset($_POST['trash']) && 1 == $_POST['trash']) {
560
+		if ('trash' == $status)
561
+			wp_die(time());
562
+		$r = wp_trash_comment($comment);
563
+	} elseif (isset($_POST['untrash']) && 1 == $_POST['untrash']) {
564
+		if ('trash' != $status)
565
+			wp_die(time());
566
+		$r = wp_untrash_comment($comment);
567
+		if ( ! isset($_POST['comment_status']) || $_POST['comment_status'] != 'trash') // undo trash, not in trash
568 568
 			$delta = 1;
569
-	} elseif ( isset($_POST['spam']) && 1 == $_POST['spam'] ) {
570
-		if ( 'spam' == $status )
571
-			wp_die( time() );
572
-		$r = wp_spam_comment( $comment );
573
-	} elseif ( isset($_POST['unspam']) && 1 == $_POST['unspam'] ) {
574
-		if ( 'spam' != $status )
575
-			wp_die( time() );
576
-		$r = wp_unspam_comment( $comment );
577
-		if ( ! isset( $_POST['comment_status'] ) || $_POST['comment_status'] != 'spam' ) // undo spam, not in spam
569
+	} elseif (isset($_POST['spam']) && 1 == $_POST['spam']) {
570
+		if ('spam' == $status)
571
+			wp_die(time());
572
+		$r = wp_spam_comment($comment);
573
+	} elseif (isset($_POST['unspam']) && 1 == $_POST['unspam']) {
574
+		if ('spam' != $status)
575
+			wp_die(time());
576
+		$r = wp_unspam_comment($comment);
577
+		if ( ! isset($_POST['comment_status']) || $_POST['comment_status'] != 'spam') // undo spam, not in spam
578 578
 			$delta = 1;
579
-	} elseif ( isset($_POST['delete']) && 1 == $_POST['delete'] ) {
580
-		$r = wp_delete_comment( $comment );
579
+	} elseif (isset($_POST['delete']) && 1 == $_POST['delete']) {
580
+		$r = wp_delete_comment($comment);
581 581
 	} else {
582 582
 		wp_die( -1 );
583 583
 	}
584 584
 
585
-	if ( $r ) // Decide if we need to send back '1' or a more complicated response including page links and comment counts
586
-		_wp_ajax_delete_comment_response( $comment->comment_ID, $delta );
587
-	wp_die( 0 );
585
+	if ($r) // Decide if we need to send back '1' or a more complicated response including page links and comment counts
586
+		_wp_ajax_delete_comment_response($comment->comment_ID, $delta);
587
+	wp_die(0);
588 588
 }
589 589
 
590 590
 /**
@@ -594,22 +594,22 @@  discard block
 block discarded – undo
594 594
  */
595 595
 function wp_ajax_delete_tag() {
596 596
 	$tag_id = (int) $_POST['tag_ID'];
597
-	check_ajax_referer( "delete-tag_$tag_id" );
597
+	check_ajax_referer("delete-tag_$tag_id");
598 598
 
599
-	$taxonomy = !empty($_POST['taxonomy']) ? $_POST['taxonomy'] : 'post_tag';
599
+	$taxonomy = ! empty($_POST['taxonomy']) ? $_POST['taxonomy'] : 'post_tag';
600 600
 	$tax = get_taxonomy($taxonomy);
601 601
 
602
-	if ( !current_user_can( $tax->cap->delete_terms ) )
602
+	if ( ! current_user_can($tax->cap->delete_terms))
603 603
 		wp_die( -1 );
604 604
 
605
-	$tag = get_term( $tag_id, $taxonomy );
606
-	if ( !$tag || is_wp_error( $tag ) )
607
-		wp_die( 1 );
605
+	$tag = get_term($tag_id, $taxonomy);
606
+	if ( ! $tag || is_wp_error($tag))
607
+		wp_die(1);
608 608
 
609
-	if ( wp_delete_term($tag_id, $taxonomy))
610
-		wp_die( 1 );
609
+	if (wp_delete_term($tag_id, $taxonomy))
610
+		wp_die(1);
611 611
 	else
612
-		wp_die( 0 );
612
+		wp_die(0);
613 613
 }
614 614
 
615 615
 /**
@@ -618,20 +618,20 @@  discard block
 block discarded – undo
618 618
  * @since 3.1.0
619 619
  */
620 620
 function wp_ajax_delete_link() {
621
-	$id = isset( $_POST['id'] ) ? (int) $_POST['id'] : 0;
621
+	$id = isset($_POST['id']) ? (int) $_POST['id'] : 0;
622 622
 
623
-	check_ajax_referer( "delete-bookmark_$id" );
624
-	if ( !current_user_can( 'manage_links' ) )
623
+	check_ajax_referer("delete-bookmark_$id");
624
+	if ( ! current_user_can('manage_links'))
625 625
 		wp_die( -1 );
626 626
 
627
-	$link = get_bookmark( $id );
628
-	if ( !$link || is_wp_error( $link ) )
629
-		wp_die( 1 );
627
+	$link = get_bookmark($id);
628
+	if ( ! $link || is_wp_error($link))
629
+		wp_die(1);
630 630
 
631
-	if ( wp_delete_link( $id ) )
632
-		wp_die( 1 );
631
+	if (wp_delete_link($id))
632
+		wp_die(1);
633 633
 	else
634
-		wp_die( 0 );
634
+		wp_die(0);
635 635
 }
636 636
 
637 637
 /**
@@ -640,17 +640,17 @@  discard block
 block discarded – undo
640 640
  * @since 3.1.0
641 641
  */
642 642
 function wp_ajax_delete_meta() {
643
-	$id = isset( $_POST['id'] ) ? (int) $_POST['id'] : 0;
643
+	$id = isset($_POST['id']) ? (int) $_POST['id'] : 0;
644 644
 
645
-	check_ajax_referer( "delete-meta_$id" );
646
-	if ( !$meta = get_metadata_by_mid( 'post', $id ) )
647
-		wp_die( 1 );
645
+	check_ajax_referer("delete-meta_$id");
646
+	if ( ! $meta = get_metadata_by_mid('post', $id))
647
+		wp_die(1);
648 648
 
649
-	if ( is_protected_meta( $meta->meta_key, 'post' ) || ! current_user_can( 'delete_post_meta',  $meta->post_id, $meta->meta_key ) )
649
+	if (is_protected_meta($meta->meta_key, 'post') || ! current_user_can('delete_post_meta', $meta->post_id, $meta->meta_key))
650 650
 		wp_die( -1 );
651
-	if ( delete_meta( $meta->meta_id ) )
652
-		wp_die( 1 );
653
-	wp_die( 0 );
651
+	if (delete_meta($meta->meta_id))
652
+		wp_die(1);
653
+	wp_die(0);
654 654
 }
655 655
 
656 656
 /**
@@ -660,22 +660,22 @@  discard block
 block discarded – undo
660 660
  *
661 661
  * @param string $action Action to perform.
662 662
  */
663
-function wp_ajax_delete_post( $action ) {
664
-	if ( empty( $action ) )
663
+function wp_ajax_delete_post($action) {
664
+	if (empty($action))
665 665
 		$action = 'delete-post';
666
-	$id = isset( $_POST['id'] ) ? (int) $_POST['id'] : 0;
666
+	$id = isset($_POST['id']) ? (int) $_POST['id'] : 0;
667 667
 
668
-	check_ajax_referer( "{$action}_$id" );
669
-	if ( !current_user_can( 'delete_post', $id ) )
668
+	check_ajax_referer("{$action}_$id");
669
+	if ( ! current_user_can('delete_post', $id))
670 670
 		wp_die( -1 );
671 671
 
672
-	if ( !get_post( $id ) )
673
-		wp_die( 1 );
672
+	if ( ! get_post($id))
673
+		wp_die(1);
674 674
 
675
-	if ( wp_delete_post( $id ) )
676
-		wp_die( 1 );
675
+	if (wp_delete_post($id))
676
+		wp_die(1);
677 677
 	else
678
-		wp_die( 0 );
678
+		wp_die(0);
679 679
 }
680 680
 
681 681
 /**
@@ -685,27 +685,27 @@  discard block
 block discarded – undo
685 685
  *
686 686
  * @param string $action Action to perform.
687 687
  */
688
-function wp_ajax_trash_post( $action ) {
689
-	if ( empty( $action ) )
688
+function wp_ajax_trash_post($action) {
689
+	if (empty($action))
690 690
 		$action = 'trash-post';
691
-	$id = isset( $_POST['id'] ) ? (int) $_POST['id'] : 0;
691
+	$id = isset($_POST['id']) ? (int) $_POST['id'] : 0;
692 692
 
693
-	check_ajax_referer( "{$action}_$id" );
694
-	if ( !current_user_can( 'delete_post', $id ) )
693
+	check_ajax_referer("{$action}_$id");
694
+	if ( ! current_user_can('delete_post', $id))
695 695
 		wp_die( -1 );
696 696
 
697
-	if ( !get_post( $id ) )
698
-		wp_die( 1 );
697
+	if ( ! get_post($id))
698
+		wp_die(1);
699 699
 
700
-	if ( 'trash-post' == $action )
701
-		$done = wp_trash_post( $id );
700
+	if ('trash-post' == $action)
701
+		$done = wp_trash_post($id);
702 702
 	else
703
-		$done = wp_untrash_post( $id );
703
+		$done = wp_untrash_post($id);
704 704
 
705
-	if ( $done )
706
-		wp_die( 1 );
705
+	if ($done)
706
+		wp_die(1);
707 707
 
708
-	wp_die( 0 );
708
+	wp_die(0);
709 709
 }
710 710
 
711 711
 /**
@@ -715,10 +715,10 @@  discard block
 block discarded – undo
715 715
  *
716 716
  * @param string $action Action to perform.
717 717
  */
718
-function wp_ajax_untrash_post( $action ) {
719
-	if ( empty( $action ) )
718
+function wp_ajax_untrash_post($action) {
719
+	if (empty($action))
720 720
 		$action = 'untrash-post';
721
-	wp_ajax_trash_post( $action );
721
+	wp_ajax_trash_post($action);
722 722
 }
723 723
 
724 724
 /**
@@ -726,22 +726,22 @@  discard block
 block discarded – undo
726 726
  *
727 727
  * @param string $action
728 728
  */
729
-function wp_ajax_delete_page( $action ) {
730
-	if ( empty( $action ) )
729
+function wp_ajax_delete_page($action) {
730
+	if (empty($action))
731 731
 		$action = 'delete-page';
732
-	$id = isset( $_POST['id'] ) ? (int) $_POST['id'] : 0;
732
+	$id = isset($_POST['id']) ? (int) $_POST['id'] : 0;
733 733
 
734
-	check_ajax_referer( "{$action}_$id" );
735
-	if ( !current_user_can( 'delete_page', $id ) )
734
+	check_ajax_referer("{$action}_$id");
735
+	if ( ! current_user_can('delete_page', $id))
736 736
 		wp_die( -1 );
737 737
 
738
-	if ( ! get_post( $id ) )
739
-		wp_die( 1 );
738
+	if ( ! get_post($id))
739
+		wp_die(1);
740 740
 
741
-	if ( wp_delete_post( $id ) )
742
-		wp_die( 1 );
741
+	if (wp_delete_post($id))
742
+		wp_die(1);
743 743
 	else
744
-		wp_die( 0 );
744
+		wp_die(0);
745 745
 }
746 746
 
747 747
 /**
@@ -750,41 +750,41 @@  discard block
 block discarded – undo
750 750
  * @since 3.1.0
751 751
  */
752 752
 function wp_ajax_dim_comment() {
753
-	$id = isset( $_POST['id'] ) ? (int) $_POST['id'] : 0;
753
+	$id = isset($_POST['id']) ? (int) $_POST['id'] : 0;
754 754
 
755
-	if ( !$comment = get_comment( $id ) ) {
756
-		$x = new WP_Ajax_Response( array(
755
+	if ( ! $comment = get_comment($id)) {
756
+		$x = new WP_Ajax_Response(array(
757 757
 			'what' => 'comment',
758 758
 			'id' => new WP_Error('invalid_comment', sprintf(__('Comment %d does not exist'), $id))
759
-		) );
759
+		));
760 760
 		$x->send();
761 761
 	}
762 762
 
763
-	if ( ! current_user_can( 'edit_comment', $comment->comment_ID ) && ! current_user_can( 'moderate_comments' ) )
763
+	if ( ! current_user_can('edit_comment', $comment->comment_ID) && ! current_user_can('moderate_comments'))
764 764
 		wp_die( -1 );
765 765
 
766
-	$current = wp_get_comment_status( $comment );
767
-	if ( isset( $_POST['new'] ) && $_POST['new'] == $current )
768
-		wp_die( time() );
766
+	$current = wp_get_comment_status($comment);
767
+	if (isset($_POST['new']) && $_POST['new'] == $current)
768
+		wp_die(time());
769 769
 
770
-	check_ajax_referer( "approve-comment_$id" );
771
-	if ( in_array( $current, array( 'unapproved', 'spam' ) ) ) {
772
-		$result = wp_set_comment_status( $comment, 'approve', true );
770
+	check_ajax_referer("approve-comment_$id");
771
+	if (in_array($current, array('unapproved', 'spam'))) {
772
+		$result = wp_set_comment_status($comment, 'approve', true);
773 773
 	} else {
774
-		$result = wp_set_comment_status( $comment, 'hold', true );
774
+		$result = wp_set_comment_status($comment, 'hold', true);
775 775
 	}
776 776
 
777
-	if ( is_wp_error($result) ) {
778
-		$x = new WP_Ajax_Response( array(
777
+	if (is_wp_error($result)) {
778
+		$x = new WP_Ajax_Response(array(
779 779
 			'what' => 'comment',
780 780
 			'id' => $result
781
-		) );
781
+		));
782 782
 		$x->send();
783 783
 	}
784 784
 
785 785
 	// Decide if we need to send back '1' or a more complicated response including page links and comment counts
786
-	_wp_ajax_delete_comment_response( $comment->comment_ID );
787
-	wp_die( 0 );
786
+	_wp_ajax_delete_comment_response($comment->comment_ID);
787
+	wp_die(0);
788 788
 }
789 789
 
790 790
 /**
@@ -794,33 +794,33 @@  discard block
 block discarded – undo
794 794
  *
795 795
  * @param string $action Action to perform.
796 796
  */
797
-function wp_ajax_add_link_category( $action ) {
798
-	if ( empty( $action ) )
797
+function wp_ajax_add_link_category($action) {
798
+	if (empty($action))
799 799
 		$action = 'add-link-category';
800
-	check_ajax_referer( $action );
801
-	if ( !current_user_can( 'manage_categories' ) )
800
+	check_ajax_referer($action);
801
+	if ( ! current_user_can('manage_categories'))
802 802
 		wp_die( -1 );
803
-	$names = explode(',', wp_unslash( $_POST['newcat'] ) );
803
+	$names = explode(',', wp_unslash($_POST['newcat']));
804 804
 	$x = new WP_Ajax_Response();
805
-	foreach ( $names as $cat_name ) {
805
+	foreach ($names as $cat_name) {
806 806
 		$cat_name = trim($cat_name);
807 807
 		$slug = sanitize_title($cat_name);
808
-		if ( '' === $slug )
808
+		if ('' === $slug)
809 809
 			continue;
810
-		if ( !$cat_id = term_exists( $cat_name, 'link_category' ) )
811
-			$cat_id = wp_insert_term( $cat_name, 'link_category' );
812
-		if ( is_wp_error( $cat_id ) ) {
810
+		if ( ! $cat_id = term_exists($cat_name, 'link_category'))
811
+			$cat_id = wp_insert_term($cat_name, 'link_category');
812
+		if (is_wp_error($cat_id)) {
813 813
 			continue;
814
-		} elseif ( is_array( $cat_id ) ) {
814
+		} elseif (is_array($cat_id)) {
815 815
 			$cat_id = $cat_id['term_id'];
816 816
 		}
817
-		$cat_name = esc_html( $cat_name );
818
-		$x->add( array(
817
+		$cat_name = esc_html($cat_name);
818
+		$x->add(array(
819 819
 			'what' => 'link-category',
820 820
 			'id' => $cat_id,
821
-			'data' => "<li id='link-category-$cat_id'><label for='in-link-category-$cat_id' class='selectit'><input value='" . esc_attr($cat_id) . "' type='checkbox' checked='checked' name='link_category[]' id='in-link-category-$cat_id'/> $cat_name</label></li>",
821
+			'data' => "<li id='link-category-$cat_id'><label for='in-link-category-$cat_id' class='selectit'><input value='".esc_attr($cat_id)."' type='checkbox' checked='checked' name='link_category[]' id='in-link-category-$cat_id'/> $cat_name</label></li>",
822 822
 			'position' => -1
823
-		) );
823
+		));
824 824
 	}
825 825
 	$x->send();
826 826
 }
@@ -835,52 +835,52 @@  discard block
 block discarded – undo
835 835
 function wp_ajax_add_tag() {
836 836
 	global $wp_list_table;
837 837
 
838
-	check_ajax_referer( 'add-tag', '_wpnonce_add-tag' );
839
-	$taxonomy = !empty($_POST['taxonomy']) ? $_POST['taxonomy'] : 'post_tag';
838
+	check_ajax_referer('add-tag', '_wpnonce_add-tag');
839
+	$taxonomy = ! empty($_POST['taxonomy']) ? $_POST['taxonomy'] : 'post_tag';
840 840
 	$tax = get_taxonomy($taxonomy);
841 841
 
842
-	if ( !current_user_can( $tax->cap->edit_terms ) )
842
+	if ( ! current_user_can($tax->cap->edit_terms))
843 843
 		wp_die( -1 );
844 844
 
845 845
 	$x = new WP_Ajax_Response();
846 846
 
847
-	$tag = wp_insert_term($_POST['tag-name'], $taxonomy, $_POST );
847
+	$tag = wp_insert_term($_POST['tag-name'], $taxonomy, $_POST);
848 848
 
849
-	if ( !$tag || is_wp_error($tag) || (!$tag = get_term( $tag['term_id'], $taxonomy )) ) {
849
+	if ( ! $tag || is_wp_error($tag) || ( ! $tag = get_term($tag['term_id'], $taxonomy))) {
850 850
 		$message = __('An error has occurred. Please reload the page and try again.');
851
-		if ( is_wp_error($tag) && $tag->get_error_message() )
851
+		if (is_wp_error($tag) && $tag->get_error_message())
852 852
 			$message = $tag->get_error_message();
853 853
 
854
-		$x->add( array(
854
+		$x->add(array(
855 855
 			'what' => 'taxonomy',
856
-			'data' => new WP_Error('error', $message )
857
-		) );
856
+			'data' => new WP_Error('error', $message)
857
+		));
858 858
 		$x->send();
859 859
 	}
860 860
 
861
-	$wp_list_table = _get_list_table( 'WP_Terms_List_Table', array( 'screen' => $_POST['screen'] ) );
861
+	$wp_list_table = _get_list_table('WP_Terms_List_Table', array('screen' => $_POST['screen']));
862 862
 
863 863
 	$level = 0;
864
-	if ( is_taxonomy_hierarchical($taxonomy) ) {
865
-		$level = count( get_ancestors( $tag->term_id, $taxonomy, 'taxonomy' ) );
864
+	if (is_taxonomy_hierarchical($taxonomy)) {
865
+		$level = count(get_ancestors($tag->term_id, $taxonomy, 'taxonomy'));
866 866
 		ob_start();
867
-		$wp_list_table->single_row( $tag, $level );
867
+		$wp_list_table->single_row($tag, $level);
868 868
 		$noparents = ob_get_clean();
869 869
 	}
870 870
 
871 871
 	ob_start();
872
-	$wp_list_table->single_row( $tag );
872
+	$wp_list_table->single_row($tag);
873 873
 	$parents = ob_get_clean();
874 874
 
875
-	$x->add( array(
875
+	$x->add(array(
876 876
 		'what' => 'taxonomy',
877 877
 		'supplemental' => compact('parents', 'noparents')
878
-	) );
879
-	$x->add( array(
878
+	));
879
+	$x->add(array(
880 880
 		'what' => 'term',
881 881
 		'position' => $level,
882 882
 		'supplemental' => (array) $tag
883
-	) );
883
+	));
884 884
 	$x->send();
885 885
 }
886 886
 
@@ -890,38 +890,38 @@  discard block
 block discarded – undo
890 890
  * @since 3.1.0
891 891
  */
892 892
 function wp_ajax_get_tagcloud() {
893
-	if ( ! isset( $_POST['tax'] ) ) {
894
-		wp_die( 0 );
893
+	if ( ! isset($_POST['tax'])) {
894
+		wp_die(0);
895 895
 	}
896 896
 
897
-	$taxonomy = sanitize_key( $_POST['tax'] );
898
-	$tax = get_taxonomy( $taxonomy );
899
-	if ( ! $tax ) {
900
-		wp_die( 0 );
897
+	$taxonomy = sanitize_key($_POST['tax']);
898
+	$tax = get_taxonomy($taxonomy);
899
+	if ( ! $tax) {
900
+		wp_die(0);
901 901
 	}
902 902
 
903
-	if ( ! current_user_can( $tax->cap->assign_terms ) ) {
903
+	if ( ! current_user_can($tax->cap->assign_terms)) {
904 904
 		wp_die( -1 );
905 905
 	}
906 906
 
907
-	$tags = get_terms( $taxonomy, array( 'number' => 45, 'orderby' => 'count', 'order' => 'DESC' ) );
907
+	$tags = get_terms($taxonomy, array('number' => 45, 'orderby' => 'count', 'order' => 'DESC'));
908 908
 
909
-	if ( empty( $tags ) )
910
-		wp_die( $tax->labels->not_found );
909
+	if (empty($tags))
910
+		wp_die($tax->labels->not_found);
911 911
 
912
-	if ( is_wp_error( $tags ) )
913
-		wp_die( $tags->get_error_message() );
912
+	if (is_wp_error($tags))
913
+		wp_die($tags->get_error_message());
914 914
 
915
-	foreach ( $tags as $key => $tag ) {
916
-		$tags[ $key ]->link = '#';
917
-		$tags[ $key ]->id = $tag->term_id;
915
+	foreach ($tags as $key => $tag) {
916
+		$tags[$key]->link = '#';
917
+		$tags[$key]->id = $tag->term_id;
918 918
 	}
919 919
 
920 920
 	// We need raw tag names here, so don't filter the output
921
-	$return = wp_generate_tag_cloud( $tags, array('filter' => 0) );
921
+	$return = wp_generate_tag_cloud($tags, array('filter' => 0));
922 922
 
923
-	if ( empty($return) )
924
-		wp_die( 0 );
923
+	if (empty($return))
924
+		wp_die(0);
925 925
 
926 926
 	echo $return;
927 927
 
@@ -938,46 +938,46 @@  discard block
 block discarded – undo
938 938
  *
939 939
  * @param string $action Action to perform.
940 940
  */
941
-function wp_ajax_get_comments( $action ) {
941
+function wp_ajax_get_comments($action) {
942 942
 	global $wp_list_table, $post_id;
943
-	if ( empty( $action ) )
943
+	if (empty($action))
944 944
 		$action = 'get-comments';
945 945
 
946
-	check_ajax_referer( $action );
946
+	check_ajax_referer($action);
947 947
 
948
-	if ( empty( $post_id ) && ! empty( $_REQUEST['p'] ) ) {
949
-		$id = absint( $_REQUEST['p'] );
950
-		if ( ! empty( $id ) )
948
+	if (empty($post_id) && ! empty($_REQUEST['p'])) {
949
+		$id = absint($_REQUEST['p']);
950
+		if ( ! empty($id))
951 951
 			$post_id = $id;
952 952
 	}
953 953
 
954
-	if ( empty( $post_id ) )
954
+	if (empty($post_id))
955 955
 		wp_die( -1 );
956 956
 
957
-	$wp_list_table = _get_list_table( 'WP_Post_Comments_List_Table', array( 'screen' => 'edit-comments' ) );
957
+	$wp_list_table = _get_list_table('WP_Post_Comments_List_Table', array('screen' => 'edit-comments'));
958 958
 
959
-	if ( ! current_user_can( 'edit_post', $post_id ) )
959
+	if ( ! current_user_can('edit_post', $post_id))
960 960
 		wp_die( -1 );
961 961
 
962 962
 	$wp_list_table->prepare_items();
963 963
 
964
-	if ( !$wp_list_table->has_items() )
965
-		wp_die( 1 );
964
+	if ( ! $wp_list_table->has_items())
965
+		wp_die(1);
966 966
 
967 967
 	$x = new WP_Ajax_Response();
968 968
 	ob_start();
969
-	foreach ( $wp_list_table->items as $comment ) {
970
-		if ( ! current_user_can( 'edit_comment', $comment->comment_ID ) && 0 === $comment->comment_approved )
969
+	foreach ($wp_list_table->items as $comment) {
970
+		if ( ! current_user_can('edit_comment', $comment->comment_ID) && 0 === $comment->comment_approved)
971 971
 			continue;
972
-		get_comment( $comment );
973
-		$wp_list_table->single_row( $comment );
972
+		get_comment($comment);
973
+		$wp_list_table->single_row($comment);
974 974
 	}
975 975
 	$comment_list_item = ob_get_clean();
976 976
 
977
-	$x->add( array(
977
+	$x->add(array(
978 978
 		'what' => 'comments',
979 979
 		'data' => $comment_list_item
980
-	) );
980
+	));
981 981
 	$x->send();
982 982
 }
983 983
 
@@ -990,91 +990,91 @@  discard block
 block discarded – undo
990 990
  *
991 991
  * @param string $action Action to perform.
992 992
  */
993
-function wp_ajax_replyto_comment( $action ) {
993
+function wp_ajax_replyto_comment($action) {
994 994
 	global $wp_list_table;
995
-	if ( empty( $action ) )
995
+	if (empty($action))
996 996
 		$action = 'replyto-comment';
997 997
 
998
-	check_ajax_referer( $action, '_ajax_nonce-replyto-comment' );
998
+	check_ajax_referer($action, '_ajax_nonce-replyto-comment');
999 999
 
1000 1000
 	$comment_post_ID = (int) $_POST['comment_post_ID'];
1001
-	$post = get_post( $comment_post_ID );
1002
-	if ( ! $post )
1001
+	$post = get_post($comment_post_ID);
1002
+	if ( ! $post)
1003 1003
 		wp_die( -1 );
1004 1004
 
1005
-	if ( !current_user_can( 'edit_post', $comment_post_ID ) )
1005
+	if ( ! current_user_can('edit_post', $comment_post_ID))
1006 1006
 		wp_die( -1 );
1007 1007
 
1008
-	if ( empty( $post->post_status ) )
1009
-		wp_die( 1 );
1010
-	elseif ( in_array($post->post_status, array('draft', 'pending', 'trash') ) )
1011
-		wp_die( __('ERROR: you are replying to a comment on a draft post.') );
1008
+	if (empty($post->post_status))
1009
+		wp_die(1);
1010
+	elseif (in_array($post->post_status, array('draft', 'pending', 'trash')))
1011
+		wp_die(__('ERROR: you are replying to a comment on a draft post.'));
1012 1012
 
1013 1013
 	$user = wp_get_current_user();
1014
-	if ( $user->exists() ) {
1014
+	if ($user->exists()) {
1015 1015
 		$user_ID = $user->ID;
1016
-		$comment_author       = wp_slash( $user->display_name );
1017
-		$comment_author_email = wp_slash( $user->user_email );
1018
-		$comment_author_url   = wp_slash( $user->user_url );
1019
-		$comment_content      = trim( $_POST['content'] );
1020
-		$comment_type         = isset( $_POST['comment_type'] ) ? trim( $_POST['comment_type'] ) : '';
1021
-		if ( current_user_can( 'unfiltered_html' ) ) {
1022
-			if ( ! isset( $_POST['_wp_unfiltered_html_comment'] ) )
1016
+		$comment_author       = wp_slash($user->display_name);
1017
+		$comment_author_email = wp_slash($user->user_email);
1018
+		$comment_author_url   = wp_slash($user->user_url);
1019
+		$comment_content      = trim($_POST['content']);
1020
+		$comment_type         = isset($_POST['comment_type']) ? trim($_POST['comment_type']) : '';
1021
+		if (current_user_can('unfiltered_html')) {
1022
+			if ( ! isset($_POST['_wp_unfiltered_html_comment']))
1023 1023
 				$_POST['_wp_unfiltered_html_comment'] = '';
1024 1024
 
1025
-			if ( wp_create_nonce( 'unfiltered-html-comment' ) != $_POST['_wp_unfiltered_html_comment'] ) {
1025
+			if (wp_create_nonce('unfiltered-html-comment') != $_POST['_wp_unfiltered_html_comment']) {
1026 1026
 				kses_remove_filters(); // start with a clean slate
1027 1027
 				kses_init_filters(); // set up the filters
1028 1028
 			}
1029 1029
 		}
1030 1030
 	} else {
1031
-		wp_die( __( 'Sorry, you must be logged in to reply to a comment.' ) );
1031
+		wp_die(__('Sorry, you must be logged in to reply to a comment.'));
1032 1032
 	}
1033 1033
 
1034
-	if ( '' == $comment_content )
1035
-		wp_die( __( 'ERROR: please type a comment.' ) );
1034
+	if ('' == $comment_content)
1035
+		wp_die(__('ERROR: please type a comment.'));
1036 1036
 
1037 1037
 	$comment_parent = 0;
1038
-	if ( isset( $_POST['comment_ID'] ) )
1039
-		$comment_parent = absint( $_POST['comment_ID'] );
1038
+	if (isset($_POST['comment_ID']))
1039
+		$comment_parent = absint($_POST['comment_ID']);
1040 1040
 	$comment_auto_approved = false;
1041 1041
 	$commentdata = compact('comment_post_ID', 'comment_author', 'comment_author_email', 'comment_author_url', 'comment_content', 'comment_type', 'comment_parent', 'user_ID');
1042 1042
 
1043 1043
 	// Automatically approve parent comment.
1044
-	if ( !empty($_POST['approve_parent']) ) {
1045
-		$parent = get_comment( $comment_parent );
1044
+	if ( ! empty($_POST['approve_parent'])) {
1045
+		$parent = get_comment($comment_parent);
1046 1046
 
1047
-		if ( $parent && $parent->comment_approved === '0' && $parent->comment_post_ID == $comment_post_ID ) {
1048
-			if ( ! current_user_can( 'edit_comment', $parent->comment_ID ) ) {
1047
+		if ($parent && $parent->comment_approved === '0' && $parent->comment_post_ID == $comment_post_ID) {
1048
+			if ( ! current_user_can('edit_comment', $parent->comment_ID)) {
1049 1049
 				wp_die( -1 );
1050 1050
 			}
1051 1051
 
1052
-			if ( wp_set_comment_status( $parent, 'approve' ) )
1052
+			if (wp_set_comment_status($parent, 'approve'))
1053 1053
 				$comment_auto_approved = true;
1054 1054
 		}
1055 1055
 	}
1056 1056
 
1057
-	$comment_id = wp_new_comment( $commentdata );
1057
+	$comment_id = wp_new_comment($commentdata);
1058 1058
 	$comment = get_comment($comment_id);
1059
-	if ( ! $comment ) wp_die( 1 );
1059
+	if ( ! $comment) wp_die(1);
1060 1060
 
1061
-	$position = ( isset($_POST['position']) && (int) $_POST['position'] ) ? (int) $_POST['position'] : '-1';
1061
+	$position = (isset($_POST['position']) && (int) $_POST['position']) ? (int) $_POST['position'] : '-1';
1062 1062
 
1063 1063
 	ob_start();
1064
-	if ( isset( $_REQUEST['mode'] ) && 'dashboard' == $_REQUEST['mode'] ) {
1065
-		require_once( ABSPATH . 'wp-admin/includes/dashboard.php' );
1066
-		_wp_dashboard_recent_comments_row( $comment );
1064
+	if (isset($_REQUEST['mode']) && 'dashboard' == $_REQUEST['mode']) {
1065
+		require_once(ABSPATH.'wp-admin/includes/dashboard.php');
1066
+		_wp_dashboard_recent_comments_row($comment);
1067 1067
 	} else {
1068
-		if ( isset( $_REQUEST['mode'] ) && 'single' == $_REQUEST['mode'] ) {
1069
-			$wp_list_table = _get_list_table('WP_Post_Comments_List_Table', array( 'screen' => 'edit-comments' ) );
1068
+		if (isset($_REQUEST['mode']) && 'single' == $_REQUEST['mode']) {
1069
+			$wp_list_table = _get_list_table('WP_Post_Comments_List_Table', array('screen' => 'edit-comments'));
1070 1070
 		} else {
1071
-			$wp_list_table = _get_list_table('WP_Comments_List_Table', array( 'screen' => 'edit-comments' ) );
1071
+			$wp_list_table = _get_list_table('WP_Comments_List_Table', array('screen' => 'edit-comments'));
1072 1072
 		}
1073
-		$wp_list_table->single_row( $comment );
1073
+		$wp_list_table->single_row($comment);
1074 1074
 	}
1075 1075
 	$comment_list_item = ob_get_clean();
1076 1076
 
1077
-	$response =  array(
1077
+	$response = array(
1078 1078
 		'what' => 'comment',
1079 1079
 		'id' => $comment->comment_ID,
1080 1080
 		'data' => $comment_list_item,
@@ -1085,22 +1085,22 @@  discard block
 block discarded – undo
1085 1085
 	$response['supplemental'] = array(
1086 1086
 		'in_moderation' => $counts->moderated,
1087 1087
 		'i18n_comments_text' => sprintf(
1088
-			_n( '%s Comment', '%s Comments', $counts->approved ),
1089
-			number_format_i18n( $counts->approved )
1088
+			_n('%s Comment', '%s Comments', $counts->approved),
1089
+			number_format_i18n($counts->approved)
1090 1090
 		),
1091 1091
 		'i18n_moderation_text' => sprintf(
1092
-			_nx( '%s in moderation', '%s in moderation', $counts->moderated, 'comments' ),
1093
-			number_format_i18n( $counts->moderated )
1092
+			_nx('%s in moderation', '%s in moderation', $counts->moderated, 'comments'),
1093
+			number_format_i18n($counts->moderated)
1094 1094
 		)
1095 1095
 	);
1096 1096
 
1097
-	if ( $comment_auto_approved ) {
1097
+	if ($comment_auto_approved) {
1098 1098
 		$response['supplemental']['parent_approved'] = $parent->comment_ID;
1099 1099
 		$response['supplemental']['parent_post_id'] = $parent->comment_post_ID;
1100 1100
 	}
1101 1101
 
1102 1102
 	$x = new WP_Ajax_Response();
1103
-	$x->add( $response );
1103
+	$x->add($response);
1104 1104
 	$x->send();
1105 1105
 }
1106 1106
 
@@ -1114,34 +1114,34 @@  discard block
 block discarded – undo
1114 1114
 function wp_ajax_edit_comment() {
1115 1115
 	global $wp_list_table;
1116 1116
 
1117
-	check_ajax_referer( 'replyto-comment', '_ajax_nonce-replyto-comment' );
1117
+	check_ajax_referer('replyto-comment', '_ajax_nonce-replyto-comment');
1118 1118
 
1119 1119
 	$comment_id = (int) $_POST['comment_ID'];
1120
-	if ( ! current_user_can( 'edit_comment', $comment_id ) )
1120
+	if ( ! current_user_can('edit_comment', $comment_id))
1121 1121
 		wp_die( -1 );
1122 1122
 
1123
-	if ( '' == $_POST['content'] )
1124
-		wp_die( __( 'ERROR: please type a comment.' ) );
1123
+	if ('' == $_POST['content'])
1124
+		wp_die(__('ERROR: please type a comment.'));
1125 1125
 
1126
-	if ( isset( $_POST['status'] ) )
1126
+	if (isset($_POST['status']))
1127 1127
 		$_POST['comment_status'] = $_POST['status'];
1128 1128
 	edit_comment();
1129 1129
 
1130
-	$position = ( isset($_POST['position']) && (int) $_POST['position']) ? (int) $_POST['position'] : '-1';
1131
-	$checkbox = ( isset($_POST['checkbox']) && true == $_POST['checkbox'] ) ? 1 : 0;
1132
-	$wp_list_table = _get_list_table( $checkbox ? 'WP_Comments_List_Table' : 'WP_Post_Comments_List_Table', array( 'screen' => 'edit-comments' ) );
1130
+	$position = (isset($_POST['position']) && (int) $_POST['position']) ? (int) $_POST['position'] : '-1';
1131
+	$checkbox = (isset($_POST['checkbox']) && true == $_POST['checkbox']) ? 1 : 0;
1132
+	$wp_list_table = _get_list_table($checkbox ? 'WP_Comments_List_Table' : 'WP_Post_Comments_List_Table', array('screen' => 'edit-comments'));
1133 1133
 
1134
-	$comment = get_comment( $comment_id );
1135
-	if ( empty( $comment->comment_ID ) )
1134
+	$comment = get_comment($comment_id);
1135
+	if (empty($comment->comment_ID))
1136 1136
 		wp_die( -1 );
1137 1137
 
1138 1138
 	ob_start();
1139
-	$wp_list_table->single_row( $comment );
1139
+	$wp_list_table->single_row($comment);
1140 1140
 	$comment_list_item = ob_get_clean();
1141 1141
 
1142 1142
 	$x = new WP_Ajax_Response();
1143 1143
 
1144
-	$x->add( array(
1144
+	$x->add(array(
1145 1145
 		'what' => 'edit_comment',
1146 1146
 		'id' => $comment->comment_ID,
1147 1147
 		'data' => $comment_list_item,
@@ -1157,39 +1157,39 @@  discard block
 block discarded – undo
1157 1157
  * @since 3.1.0
1158 1158
  */
1159 1159
 function wp_ajax_add_menu_item() {
1160
-	check_ajax_referer( 'add-menu_item', 'menu-settings-column-nonce' );
1160
+	check_ajax_referer('add-menu_item', 'menu-settings-column-nonce');
1161 1161
 
1162
-	if ( ! current_user_can( 'edit_theme_options' ) )
1162
+	if ( ! current_user_can('edit_theme_options'))
1163 1163
 		wp_die( -1 );
1164 1164
 
1165
-	require_once ABSPATH . 'wp-admin/includes/nav-menu.php';
1165
+	require_once ABSPATH.'wp-admin/includes/nav-menu.php';
1166 1166
 
1167 1167
 	// For performance reasons, we omit some object properties from the checklist.
1168 1168
 	// The following is a hacky way to restore them when adding non-custom items.
1169 1169
 
1170 1170
 	$menu_items_data = array();
1171
-	foreach ( (array) $_POST['menu-item'] as $menu_item_data ) {
1171
+	foreach ((array) $_POST['menu-item'] as $menu_item_data) {
1172 1172
 		if (
1173
-			! empty( $menu_item_data['menu-item-type'] ) &&
1173
+			! empty($menu_item_data['menu-item-type']) &&
1174 1174
 			'custom' != $menu_item_data['menu-item-type'] &&
1175
-			! empty( $menu_item_data['menu-item-object-id'] )
1175
+			! empty($menu_item_data['menu-item-object-id'])
1176 1176
 		) {
1177
-			switch( $menu_item_data['menu-item-type'] ) {
1177
+			switch ($menu_item_data['menu-item-type']) {
1178 1178
 				case 'post_type' :
1179
-					$_object = get_post( $menu_item_data['menu-item-object-id'] );
1179
+					$_object = get_post($menu_item_data['menu-item-object-id']);
1180 1180
 				break;
1181 1181
 
1182 1182
 				case 'post_type_archive' :
1183
-					$_object = get_post_type_object( $menu_item_data['menu-item-object'] );
1183
+					$_object = get_post_type_object($menu_item_data['menu-item-object']);
1184 1184
 				break;
1185 1185
 
1186 1186
 				case 'taxonomy' :
1187
-					$_object = get_term( $menu_item_data['menu-item-object-id'], $menu_item_data['menu-item-object'] );
1187
+					$_object = get_term($menu_item_data['menu-item-object-id'], $menu_item_data['menu-item-object']);
1188 1188
 				break;
1189 1189
 			}
1190 1190
 
1191
-			$_menu_items = array_map( 'wp_setup_nav_menu_item', array( $_object ) );
1192
-			$_menu_item = reset( $_menu_items );
1191
+			$_menu_items = array_map('wp_setup_nav_menu_item', array($_object));
1192
+			$_menu_item = reset($_menu_items);
1193 1193
 
1194 1194
 			// Restore the missing menu item properties
1195 1195
 			$menu_item_data['menu-item-description'] = $_menu_item->description;
@@ -1198,28 +1198,28 @@  discard block
 block discarded – undo
1198 1198
 		$menu_items_data[] = $menu_item_data;
1199 1199
 	}
1200 1200
 
1201
-	$item_ids = wp_save_nav_menu_items( 0, $menu_items_data );
1202
-	if ( is_wp_error( $item_ids ) )
1203
-		wp_die( 0 );
1201
+	$item_ids = wp_save_nav_menu_items(0, $menu_items_data);
1202
+	if (is_wp_error($item_ids))
1203
+		wp_die(0);
1204 1204
 
1205 1205
 	$menu_items = array();
1206 1206
 
1207
-	foreach ( (array) $item_ids as $menu_item_id ) {
1208
-		$menu_obj = get_post( $menu_item_id );
1209
-		if ( ! empty( $menu_obj->ID ) ) {
1210
-			$menu_obj = wp_setup_nav_menu_item( $menu_obj );
1207
+	foreach ((array) $item_ids as $menu_item_id) {
1208
+		$menu_obj = get_post($menu_item_id);
1209
+		if ( ! empty($menu_obj->ID)) {
1210
+			$menu_obj = wp_setup_nav_menu_item($menu_obj);
1211 1211
 			$menu_obj->label = $menu_obj->title; // don't show "(pending)" in ajax-added items
1212 1212
 			$menu_items[] = $menu_obj;
1213 1213
 		}
1214 1214
 	}
1215 1215
 
1216 1216
 	/** This filter is documented in wp-admin/includes/nav-menu.php */
1217
-	$walker_class_name = apply_filters( 'wp_edit_nav_menu_walker', 'Walker_Nav_Menu_Edit', $_POST['menu'] );
1217
+	$walker_class_name = apply_filters('wp_edit_nav_menu_walker', 'Walker_Nav_Menu_Edit', $_POST['menu']);
1218 1218
 
1219
-	if ( ! class_exists( $walker_class_name ) )
1220
-		wp_die( 0 );
1219
+	if ( ! class_exists($walker_class_name))
1220
+		wp_die(0);
1221 1221
 
1222
-	if ( ! empty( $menu_items ) ) {
1222
+	if ( ! empty($menu_items)) {
1223 1223
 		$args = array(
1224 1224
 			'after' => '',
1225 1225
 			'before' => '',
@@ -1227,7 +1227,7 @@  discard block
 block discarded – undo
1227 1227
 			'link_before' => '',
1228 1228
 			'walker' => new $walker_class_name,
1229 1229
 		);
1230
-		echo walk_nav_menu_tree( $menu_items, 0, (object) $args );
1230
+		echo walk_nav_menu_tree($menu_items, 0, (object) $args);
1231 1231
 	}
1232 1232
 	wp_die();
1233 1233
 }
@@ -1238,86 +1238,86 @@  discard block
 block discarded – undo
1238 1238
  * @since 3.1.0
1239 1239
  */
1240 1240
 function wp_ajax_add_meta() {
1241
-	check_ajax_referer( 'add-meta', '_ajax_nonce-add-meta' );
1241
+	check_ajax_referer('add-meta', '_ajax_nonce-add-meta');
1242 1242
 	$c = 0;
1243 1243
 	$pid = (int) $_POST['post_id'];
1244
-	$post = get_post( $pid );
1244
+	$post = get_post($pid);
1245 1245
 
1246
-	if ( isset($_POST['metakeyselect']) || isset($_POST['metakeyinput']) ) {
1247
-		if ( !current_user_can( 'edit_post', $pid ) )
1246
+	if (isset($_POST['metakeyselect']) || isset($_POST['metakeyinput'])) {
1247
+		if ( ! current_user_can('edit_post', $pid))
1248 1248
 			wp_die( -1 );
1249
-		if ( isset($_POST['metakeyselect']) && '#NONE#' == $_POST['metakeyselect'] && empty($_POST['metakeyinput']) )
1250
-			wp_die( 1 );
1249
+		if (isset($_POST['metakeyselect']) && '#NONE#' == $_POST['metakeyselect'] && empty($_POST['metakeyinput']))
1250
+			wp_die(1);
1251 1251
 
1252 1252
 		// If the post is an autodraft, save the post as a draft and then attempt to save the meta.
1253
-		if ( $post->post_status == 'auto-draft' ) {
1253
+		if ($post->post_status == 'auto-draft') {
1254 1254
 			$post_data = array();
1255 1255
 			$post_data['action'] = 'draft'; // Warning fix
1256 1256
 			$post_data['post_ID'] = $pid;
1257 1257
 			$post_data['post_type'] = $post->post_type;
1258 1258
 			$post_data['post_status'] = 'draft';
1259 1259
 			$now = current_time('timestamp', 1);
1260
-			$post_data['post_title'] = sprintf( __( 'Draft created on %1$s at %2$s' ), date( __( 'F j, Y' ), $now ), date( __( 'g:i a' ), $now ) );
1260
+			$post_data['post_title'] = sprintf(__('Draft created on %1$s at %2$s'), date(__('F j, Y'), $now), date(__('g:i a'), $now));
1261 1261
 
1262
-			$pid = edit_post( $post_data );
1263
-			if ( $pid ) {
1264
-				if ( is_wp_error( $pid ) ) {
1265
-					$x = new WP_Ajax_Response( array(
1262
+			$pid = edit_post($post_data);
1263
+			if ($pid) {
1264
+				if (is_wp_error($pid)) {
1265
+					$x = new WP_Ajax_Response(array(
1266 1266
 						'what' => 'meta',
1267 1267
 						'data' => $pid
1268
-					) );
1268
+					));
1269 1269
 					$x->send();
1270 1270
 				}
1271 1271
 
1272
-				if ( !$mid = add_meta( $pid ) )
1273
-					wp_die( __( 'Please provide a custom field value.' ) );
1272
+				if ( ! $mid = add_meta($pid))
1273
+					wp_die(__('Please provide a custom field value.'));
1274 1274
 			} else {
1275
-				wp_die( 0 );
1275
+				wp_die(0);
1276 1276
 			}
1277
-		} elseif ( ! $mid = add_meta( $pid ) ) {
1278
-			wp_die( __( 'Please provide a custom field value.' ) );
1277
+		} elseif ( ! $mid = add_meta($pid)) {
1278
+			wp_die(__('Please provide a custom field value.'));
1279 1279
 		}
1280 1280
 
1281
-		$meta = get_metadata_by_mid( 'post', $mid );
1281
+		$meta = get_metadata_by_mid('post', $mid);
1282 1282
 		$pid = (int) $meta->post_id;
1283
-		$meta = get_object_vars( $meta );
1284
-		$x = new WP_Ajax_Response( array(
1283
+		$meta = get_object_vars($meta);
1284
+		$x = new WP_Ajax_Response(array(
1285 1285
 			'what' => 'meta',
1286 1286
 			'id' => $mid,
1287
-			'data' => _list_meta_row( $meta, $c ),
1287
+			'data' => _list_meta_row($meta, $c),
1288 1288
 			'position' => 1,
1289 1289
 			'supplemental' => array('postid' => $pid)
1290
-		) );
1290
+		));
1291 1291
 	} else { // Update?
1292
-		$mid = (int) key( $_POST['meta'] );
1293
-		$key = wp_unslash( $_POST['meta'][$mid]['key'] );
1294
-		$value = wp_unslash( $_POST['meta'][$mid]['value'] );
1295
-		if ( '' == trim($key) )
1296
-			wp_die( __( 'Please provide a custom field name.' ) );
1297
-		if ( '' == trim($value) )
1298
-			wp_die( __( 'Please provide a custom field value.' ) );
1299
-		if ( ! $meta = get_metadata_by_mid( 'post', $mid ) )
1300
-			wp_die( 0 ); // if meta doesn't exist
1301
-		if ( is_protected_meta( $meta->meta_key, 'post' ) || is_protected_meta( $key, 'post' ) ||
1302
-			! current_user_can( 'edit_post_meta', $meta->post_id, $meta->meta_key ) ||
1303
-			! current_user_can( 'edit_post_meta', $meta->post_id, $key ) )
1292
+		$mid = (int) key($_POST['meta']);
1293
+		$key = wp_unslash($_POST['meta'][$mid]['key']);
1294
+		$value = wp_unslash($_POST['meta'][$mid]['value']);
1295
+		if ('' == trim($key))
1296
+			wp_die(__('Please provide a custom field name.'));
1297
+		if ('' == trim($value))
1298
+			wp_die(__('Please provide a custom field value.'));
1299
+		if ( ! $meta = get_metadata_by_mid('post', $mid))
1300
+			wp_die(0); // if meta doesn't exist
1301
+		if (is_protected_meta($meta->meta_key, 'post') || is_protected_meta($key, 'post') ||
1302
+			! current_user_can('edit_post_meta', $meta->post_id, $meta->meta_key) ||
1303
+			! current_user_can('edit_post_meta', $meta->post_id, $key))
1304 1304
 			wp_die( -1 );
1305
-		if ( $meta->meta_value != $value || $meta->meta_key != $key ) {
1306
-			if ( !$u = update_metadata_by_mid( 'post', $mid, $value, $key ) )
1307
-				wp_die( 0 ); // We know meta exists; we also know it's unchanged (or DB error, in which case there are bigger problems).
1305
+		if ($meta->meta_value != $value || $meta->meta_key != $key) {
1306
+			if ( ! $u = update_metadata_by_mid('post', $mid, $value, $key))
1307
+				wp_die(0); // We know meta exists; we also know it's unchanged (or DB error, in which case there are bigger problems).
1308 1308
 		}
1309 1309
 
1310
-		$x = new WP_Ajax_Response( array(
1310
+		$x = new WP_Ajax_Response(array(
1311 1311
 			'what' => 'meta',
1312 1312
 			'id' => $mid, 'old_id' => $mid,
1313
-			'data' => _list_meta_row( array(
1313
+			'data' => _list_meta_row(array(
1314 1314
 				'meta_key' => $key,
1315 1315
 				'meta_value' => $value,
1316 1316
 				'meta_id' => $mid
1317
-			), $c ),
1317
+			), $c),
1318 1318
 			'position' => 0,
1319 1319
 			'supplemental' => array('postid' => $meta->post_id)
1320
-		) );
1320
+		));
1321 1321
 	}
1322 1322
 	$x->send();
1323 1323
 }
@@ -1331,42 +1331,42 @@  discard block
 block discarded – undo
1331 1331
  *
1332 1332
  * @param string $action Action to perform.
1333 1333
  */
1334
-function wp_ajax_add_user( $action ) {
1334
+function wp_ajax_add_user($action) {
1335 1335
 	global $wp_list_table;
1336
-	if ( empty( $action ) )
1336
+	if (empty($action))
1337 1337
 		$action = 'add-user';
1338 1338
 
1339
-	check_ajax_referer( $action );
1340
-	if ( ! current_user_can('create_users') )
1339
+	check_ajax_referer($action);
1340
+	if ( ! current_user_can('create_users'))
1341 1341
 		wp_die( -1 );
1342
-	if ( ! $user_id = edit_user() ) {
1343
-		wp_die( 0 );
1344
-	} elseif ( is_wp_error( $user_id ) ) {
1345
-		$x = new WP_Ajax_Response( array(
1342
+	if ( ! $user_id = edit_user()) {
1343
+		wp_die(0);
1344
+	} elseif (is_wp_error($user_id)) {
1345
+		$x = new WP_Ajax_Response(array(
1346 1346
 			'what' => 'user',
1347 1347
 			'id' => $user_id
1348
-		) );
1348
+		));
1349 1349
 		$x->send();
1350 1350
 	}
1351
-	$user_object = get_userdata( $user_id );
1351
+	$user_object = get_userdata($user_id);
1352 1352
 
1353 1353
 	$wp_list_table = _get_list_table('WP_Users_List_Table');
1354 1354
 
1355
-	$role = current( $user_object->roles );
1355
+	$role = current($user_object->roles);
1356 1356
 
1357
-	$x = new WP_Ajax_Response( array(
1357
+	$x = new WP_Ajax_Response(array(
1358 1358
 		'what' => 'user',
1359 1359
 		'id' => $user_id,
1360
-		'data' => $wp_list_table->single_row( $user_object, '', $role ),
1360
+		'data' => $wp_list_table->single_row($user_object, '', $role),
1361 1361
 		'supplemental' => array(
1362 1362
 			'show-link' => sprintf(
1363 1363
 				/* translators: %s: the new user */
1364
-				__( 'User %s added' ),
1365
-				'<a href="#user-' . $user_id . '">' . $user_object->user_login . '</a>'
1364
+				__('User %s added'),
1365
+				'<a href="#user-'.$user_id.'">'.$user_object->user_login.'</a>'
1366 1366
 			),
1367 1367
 			'role' => $role,
1368 1368
 		)
1369
-	) );
1369
+	));
1370 1370
 	$x->send();
1371 1371
 }
1372 1372
 
@@ -1376,30 +1376,30 @@  discard block
 block discarded – undo
1376 1376
  * @since 3.1.0
1377 1377
  */
1378 1378
 function wp_ajax_closed_postboxes() {
1379
-	check_ajax_referer( 'closedpostboxes', 'closedpostboxesnonce' );
1380
-	$closed = isset( $_POST['closed'] ) ? explode( ',', $_POST['closed']) : array();
1379
+	check_ajax_referer('closedpostboxes', 'closedpostboxesnonce');
1380
+	$closed = isset($_POST['closed']) ? explode(',', $_POST['closed']) : array();
1381 1381
 	$closed = array_filter($closed);
1382 1382
 
1383
-	$hidden = isset( $_POST['hidden'] ) ? explode( ',', $_POST['hidden']) : array();
1383
+	$hidden = isset($_POST['hidden']) ? explode(',', $_POST['hidden']) : array();
1384 1384
 	$hidden = array_filter($hidden);
1385 1385
 
1386
-	$page = isset( $_POST['page'] ) ? $_POST['page'] : '';
1386
+	$page = isset($_POST['page']) ? $_POST['page'] : '';
1387 1387
 
1388
-	if ( $page != sanitize_key( $page ) )
1389
-		wp_die( 0 );
1388
+	if ($page != sanitize_key($page))
1389
+		wp_die(0);
1390 1390
 
1391
-	if ( ! $user = wp_get_current_user() )
1391
+	if ( ! $user = wp_get_current_user())
1392 1392
 		wp_die( -1 );
1393 1393
 
1394
-	if ( is_array($closed) )
1394
+	if (is_array($closed))
1395 1395
 		update_user_option($user->ID, "closedpostboxes_$page", $closed, true);
1396 1396
 
1397
-	if ( is_array($hidden) ) {
1398
-		$hidden = array_diff( $hidden, array('submitdiv', 'linksubmitdiv', 'manage-menu', 'create-menu') ); // postboxes that are always shown
1397
+	if (is_array($hidden)) {
1398
+		$hidden = array_diff($hidden, array('submitdiv', 'linksubmitdiv', 'manage-menu', 'create-menu')); // postboxes that are always shown
1399 1399
 		update_user_option($user->ID, "metaboxhidden_$page", $hidden, true);
1400 1400
 	}
1401 1401
 
1402
-	wp_die( 1 );
1402
+	wp_die(1);
1403 1403
 }
1404 1404
 
1405 1405
 /**
@@ -1408,19 +1408,19 @@  discard block
 block discarded – undo
1408 1408
  * @since 3.1.0
1409 1409
  */
1410 1410
 function wp_ajax_hidden_columns() {
1411
-	check_ajax_referer( 'screen-options-nonce', 'screenoptionnonce' );
1412
-	$page = isset( $_POST['page'] ) ? $_POST['page'] : '';
1411
+	check_ajax_referer('screen-options-nonce', 'screenoptionnonce');
1412
+	$page = isset($_POST['page']) ? $_POST['page'] : '';
1413 1413
 
1414
-	if ( $page != sanitize_key( $page ) )
1415
-		wp_die( 0 );
1414
+	if ($page != sanitize_key($page))
1415
+		wp_die(0);
1416 1416
 
1417
-	if ( ! $user = wp_get_current_user() )
1417
+	if ( ! $user = wp_get_current_user())
1418 1418
 		wp_die( -1 );
1419 1419
 
1420
-	$hidden = ! empty( $_POST['hidden'] ) ? explode( ',', $_POST['hidden'] ) : array();
1421
-	update_user_option( $user->ID, "manage{$page}columnshidden", $hidden, true );
1420
+	$hidden = ! empty($_POST['hidden']) ? explode(',', $_POST['hidden']) : array();
1421
+	update_user_option($user->ID, "manage{$page}columnshidden", $hidden, true);
1422 1422
 
1423
-	wp_die( 1 );
1423
+	wp_die(1);
1424 1424
 }
1425 1425
 
1426 1426
 /**
@@ -1429,14 +1429,14 @@  discard block
 block discarded – undo
1429 1429
  * @since 3.1.0
1430 1430
  */
1431 1431
 function wp_ajax_update_welcome_panel() {
1432
-	check_ajax_referer( 'welcome-panel-nonce', 'welcomepanelnonce' );
1432
+	check_ajax_referer('welcome-panel-nonce', 'welcomepanelnonce');
1433 1433
 
1434
-	if ( ! current_user_can( 'edit_theme_options' ) )
1434
+	if ( ! current_user_can('edit_theme_options'))
1435 1435
 		wp_die( -1 );
1436 1436
 
1437
-	update_user_meta( get_current_user_id(), 'show_welcome_panel', empty( $_POST['visible'] ) ? 0 : 1 );
1437
+	update_user_meta(get_current_user_id(), 'show_welcome_panel', empty($_POST['visible']) ? 0 : 1);
1438 1438
 
1439
-	wp_die( 1 );
1439
+	wp_die(1);
1440 1440
 }
1441 1441
 
1442 1442
 /**
@@ -1445,31 +1445,31 @@  discard block
 block discarded – undo
1445 1445
  * @since 3.1.0
1446 1446
  */
1447 1447
 function wp_ajax_menu_get_metabox() {
1448
-	if ( ! current_user_can( 'edit_theme_options' ) )
1448
+	if ( ! current_user_can('edit_theme_options'))
1449 1449
 		wp_die( -1 );
1450 1450
 
1451
-	require_once ABSPATH . 'wp-admin/includes/nav-menu.php';
1451
+	require_once ABSPATH.'wp-admin/includes/nav-menu.php';
1452 1452
 
1453
-	if ( isset( $_POST['item-type'] ) && 'post_type' == $_POST['item-type'] ) {
1453
+	if (isset($_POST['item-type']) && 'post_type' == $_POST['item-type']) {
1454 1454
 		$type = 'posttype';
1455 1455
 		$callback = 'wp_nav_menu_item_post_type_meta_box';
1456
-		$items = (array) get_post_types( array( 'show_in_nav_menus' => true ), 'object' );
1457
-	} elseif ( isset( $_POST['item-type'] ) && 'taxonomy' == $_POST['item-type'] ) {
1456
+		$items = (array) get_post_types(array('show_in_nav_menus' => true), 'object');
1457
+	} elseif (isset($_POST['item-type']) && 'taxonomy' == $_POST['item-type']) {
1458 1458
 		$type = 'taxonomy';
1459 1459
 		$callback = 'wp_nav_menu_item_taxonomy_meta_box';
1460
-		$items = (array) get_taxonomies( array( 'show_ui' => true ), 'object' );
1460
+		$items = (array) get_taxonomies(array('show_ui' => true), 'object');
1461 1461
 	}
1462 1462
 
1463
-	if ( ! empty( $_POST['item-object'] ) && isset( $items[$_POST['item-object']] ) ) {
1464
-		$menus_meta_box_object = $items[ $_POST['item-object'] ];
1463
+	if ( ! empty($_POST['item-object']) && isset($items[$_POST['item-object']])) {
1464
+		$menus_meta_box_object = $items[$_POST['item-object']];
1465 1465
 
1466 1466
 		/** This filter is documented in wp-admin/includes/nav-menu.php */
1467
-		$item = apply_filters( 'nav_menu_meta_box_object', $menus_meta_box_object );
1467
+		$item = apply_filters('nav_menu_meta_box_object', $menus_meta_box_object);
1468 1468
 		ob_start();
1469 1469
 		call_user_func_array($callback, array(
1470 1470
 			null,
1471 1471
 			array(
1472
-				'id' => 'add-' . $item->name,
1472
+				'id' => 'add-'.$item->name,
1473 1473
 				'title' => $item->labels->name,
1474 1474
 				'callback' => $callback,
1475 1475
 				'args' => $item,
@@ -1479,7 +1479,7 @@  discard block
 block discarded – undo
1479 1479
 		$markup = ob_get_clean();
1480 1480
 
1481 1481
 		echo wp_json_encode(array(
1482
-			'replace-id' => $type . '-' . $item->name,
1482
+			'replace-id' => $type.'-'.$item->name,
1483 1483
 			'markup' => $markup,
1484 1484
 		));
1485 1485
 	}
@@ -1493,27 +1493,27 @@  discard block
 block discarded – undo
1493 1493
  * @since 3.1.0
1494 1494
  */
1495 1495
 function wp_ajax_wp_link_ajax() {
1496
-	check_ajax_referer( 'internal-linking', '_ajax_linking_nonce' );
1496
+	check_ajax_referer('internal-linking', '_ajax_linking_nonce');
1497 1497
 
1498 1498
 	$args = array();
1499 1499
 
1500
-	if ( isset( $_POST['search'] ) ) {
1501
-		$args['s'] = wp_unslash( $_POST['search'] );
1500
+	if (isset($_POST['search'])) {
1501
+		$args['s'] = wp_unslash($_POST['search']);
1502 1502
 	}
1503 1503
 
1504
-	if ( isset( $_POST['term'] ) ) {
1505
-		$args['s'] = wp_unslash( $_POST['term'] );
1504
+	if (isset($_POST['term'])) {
1505
+		$args['s'] = wp_unslash($_POST['term']);
1506 1506
 	}
1507 1507
 
1508
-	$args['pagenum'] = ! empty( $_POST['page'] ) ? absint( $_POST['page'] ) : 1;
1508
+	$args['pagenum'] = ! empty($_POST['page']) ? absint($_POST['page']) : 1;
1509 1509
 
1510
-	require(ABSPATH . WPINC . '/class-wp-editor.php');
1511
-	$results = _WP_Editors::wp_link_query( $args );
1510
+	require(ABSPATH.WPINC.'/class-wp-editor.php');
1511
+	$results = _WP_Editors::wp_link_query($args);
1512 1512
 
1513
-	if ( ! isset( $results ) )
1514
-		wp_die( 0 );
1513
+	if ( ! isset($results))
1514
+		wp_die(0);
1515 1515
 
1516
-	echo wp_json_encode( $results );
1516
+	echo wp_json_encode($results);
1517 1517
 	echo "\n";
1518 1518
 
1519 1519
 	wp_die();
@@ -1525,13 +1525,13 @@  discard block
 block discarded – undo
1525 1525
  * @since 3.1.0
1526 1526
  */
1527 1527
 function wp_ajax_menu_locations_save() {
1528
-	if ( ! current_user_can( 'edit_theme_options' ) )
1528
+	if ( ! current_user_can('edit_theme_options'))
1529 1529
 		wp_die( -1 );
1530
-	check_ajax_referer( 'add-menu_item', 'menu-settings-column-nonce' );
1531
-	if ( ! isset( $_POST['menu-locations'] ) )
1532
-		wp_die( 0 );
1533
-	set_theme_mod( 'nav_menu_locations', array_map( 'absint', $_POST['menu-locations'] ) );
1534
-	wp_die( 1 );
1530
+	check_ajax_referer('add-menu_item', 'menu-settings-column-nonce');
1531
+	if ( ! isset($_POST['menu-locations']))
1532
+		wp_die(0);
1533
+	set_theme_mod('nav_menu_locations', array_map('absint', $_POST['menu-locations']));
1534
+	wp_die(1);
1535 1535
 }
1536 1536
 
1537 1537
 /**
@@ -1540,28 +1540,28 @@  discard block
 block discarded – undo
1540 1540
  * @since 3.1.0
1541 1541
  */
1542 1542
 function wp_ajax_meta_box_order() {
1543
-	check_ajax_referer( 'meta-box-order' );
1544
-	$order = isset( $_POST['order'] ) ? (array) $_POST['order'] : false;
1545
-	$page_columns = isset( $_POST['page_columns'] ) ? $_POST['page_columns'] : 'auto';
1543
+	check_ajax_referer('meta-box-order');
1544
+	$order = isset($_POST['order']) ? (array) $_POST['order'] : false;
1545
+	$page_columns = isset($_POST['page_columns']) ? $_POST['page_columns'] : 'auto';
1546 1546
 
1547
-	if ( $page_columns != 'auto' )
1547
+	if ($page_columns != 'auto')
1548 1548
 		$page_columns = (int) $page_columns;
1549 1549
 
1550
-	$page = isset( $_POST['page'] ) ? $_POST['page'] : '';
1550
+	$page = isset($_POST['page']) ? $_POST['page'] : '';
1551 1551
 
1552
-	if ( $page != sanitize_key( $page ) )
1553
-		wp_die( 0 );
1552
+	if ($page != sanitize_key($page))
1553
+		wp_die(0);
1554 1554
 
1555
-	if ( ! $user = wp_get_current_user() )
1555
+	if ( ! $user = wp_get_current_user())
1556 1556
 		wp_die( -1 );
1557 1557
 
1558
-	if ( $order )
1558
+	if ($order)
1559 1559
 		update_user_option($user->ID, "meta-box-order_$page", $order, true);
1560 1560
 
1561
-	if ( $page_columns )
1561
+	if ($page_columns)
1562 1562
 		update_user_option($user->ID, "screen_layout_$page", $page_columns, true);
1563 1563
 
1564
-	wp_die( 1 );
1564
+	wp_die(1);
1565 1565
 }
1566 1566
 
1567 1567
 /**
@@ -1570,12 +1570,12 @@  discard block
 block discarded – undo
1570 1570
  * @since 3.1.0
1571 1571
  */
1572 1572
 function wp_ajax_menu_quick_search() {
1573
-	if ( ! current_user_can( 'edit_theme_options' ) )
1573
+	if ( ! current_user_can('edit_theme_options'))
1574 1574
 		wp_die( -1 );
1575 1575
 
1576
-	require_once ABSPATH . 'wp-admin/includes/nav-menu.php';
1576
+	require_once ABSPATH.'wp-admin/includes/nav-menu.php';
1577 1577
 
1578
-	_wp_ajax_menu_quick_search( $_POST );
1578
+	_wp_ajax_menu_quick_search($_POST);
1579 1579
 
1580 1580
 	wp_die();
1581 1581
 }
@@ -1586,9 +1586,9 @@  discard block
 block discarded – undo
1586 1586
  * @since 3.1.0
1587 1587
  */
1588 1588
 function wp_ajax_get_permalink() {
1589
-	check_ajax_referer( 'getpermalink', 'getpermalinknonce' );
1590
-	$post_id = isset($_POST['post_id'])? intval($_POST['post_id']) : 0;
1591
-	wp_die( get_preview_post_link( $post_id ) );
1589
+	check_ajax_referer('getpermalink', 'getpermalinknonce');
1590
+	$post_id = isset($_POST['post_id']) ? intval($_POST['post_id']) : 0;
1591
+	wp_die(get_preview_post_link($post_id));
1592 1592
 }
1593 1593
 
1594 1594
 /**
@@ -1597,11 +1597,11 @@  discard block
 block discarded – undo
1597 1597
  * @since 3.1.0
1598 1598
  */
1599 1599
 function wp_ajax_sample_permalink() {
1600
-	check_ajax_referer( 'samplepermalink', 'samplepermalinknonce' );
1601
-	$post_id = isset($_POST['post_id'])? intval($_POST['post_id']) : 0;
1602
-	$title = isset($_POST['new_title'])? $_POST['new_title'] : '';
1603
-	$slug = isset($_POST['new_slug'])? $_POST['new_slug'] : null;
1604
-	wp_die( get_sample_permalink_html( $post_id, $title, $slug ) );
1600
+	check_ajax_referer('samplepermalink', 'samplepermalinknonce');
1601
+	$post_id = isset($_POST['post_id']) ? intval($_POST['post_id']) : 0;
1602
+	$title = isset($_POST['new_title']) ? $_POST['new_title'] : '';
1603
+	$slug = isset($_POST['new_slug']) ? $_POST['new_slug'] : null;
1604
+	wp_die(get_sample_permalink_html($post_id, $title, $slug));
1605 1605
 }
1606 1606
 
1607 1607
 /**
@@ -1614,29 +1614,29 @@  discard block
 block discarded – undo
1614 1614
 function wp_ajax_inline_save() {
1615 1615
 	global $wp_list_table, $mode;
1616 1616
 
1617
-	check_ajax_referer( 'inlineeditnonce', '_inline_edit' );
1617
+	check_ajax_referer('inlineeditnonce', '_inline_edit');
1618 1618
 
1619
-	if ( ! isset($_POST['post_ID']) || ! ( $post_ID = (int) $_POST['post_ID'] ) )
1619
+	if ( ! isset($_POST['post_ID']) || ! ($post_ID = (int) $_POST['post_ID']))
1620 1620
 		wp_die();
1621 1621
 
1622
-	if ( 'page' == $_POST['post_type'] ) {
1623
-		if ( ! current_user_can( 'edit_page', $post_ID ) )
1624
-			wp_die( __( 'Sorry, you are not allowed to edit this page.' ) );
1622
+	if ('page' == $_POST['post_type']) {
1623
+		if ( ! current_user_can('edit_page', $post_ID))
1624
+			wp_die(__('Sorry, you are not allowed to edit this page.'));
1625 1625
 	} else {
1626
-		if ( ! current_user_can( 'edit_post', $post_ID ) )
1627
-			wp_die( __( 'Sorry, you are not allowed to edit this post.' ) );
1626
+		if ( ! current_user_can('edit_post', $post_ID))
1627
+			wp_die(__('Sorry, you are not allowed to edit this post.'));
1628 1628
 	}
1629 1629
 
1630
-	if ( $last = wp_check_post_lock( $post_ID ) ) {
1631
-		$last_user = get_userdata( $last );
1632
-		$last_user_name = $last_user ? $last_user->display_name : __( 'Someone' );
1633
-		printf( $_POST['post_type'] == 'page' ? __( 'Saving is disabled: %s is currently editing this page.' ) : __( 'Saving is disabled: %s is currently editing this post.' ),	esc_html( $last_user_name ) );
1630
+	if ($last = wp_check_post_lock($post_ID)) {
1631
+		$last_user = get_userdata($last);
1632
+		$last_user_name = $last_user ? $last_user->display_name : __('Someone');
1633
+		printf($_POST['post_type'] == 'page' ? __('Saving is disabled: %s is currently editing this page.') : __('Saving is disabled: %s is currently editing this post.'), esc_html($last_user_name));
1634 1634
 		wp_die();
1635 1635
 	}
1636 1636
 
1637 1637
 	$data = &$_POST;
1638 1638
 
1639
-	$post = get_post( $post_ID, ARRAY_A );
1639
+	$post = get_post($post_ID, ARRAY_A);
1640 1640
 
1641 1641
 	// Since it's coming from the database.
1642 1642
 	$post = wp_slash($post);
@@ -1647,59 +1647,59 @@  discard block
 block discarded – undo
1647 1647
 	// Rename.
1648 1648
 	$data['user_ID'] = get_current_user_id();
1649 1649
 
1650
-	if ( isset($data['post_parent']) )
1650
+	if (isset($data['post_parent']))
1651 1651
 		$data['parent_id'] = $data['post_parent'];
1652 1652
 
1653 1653
 	// Status.
1654
-	if ( isset( $data['keep_private'] ) && 'private' == $data['keep_private'] ) {
1654
+	if (isset($data['keep_private']) && 'private' == $data['keep_private']) {
1655 1655
 		$data['visibility']  = 'private';
1656 1656
 		$data['post_status'] = 'private';
1657 1657
 	} else {
1658 1658
 		$data['post_status'] = $data['_status'];
1659 1659
 	}
1660 1660
 
1661
-	if ( empty($data['comment_status']) )
1661
+	if (empty($data['comment_status']))
1662 1662
 		$data['comment_status'] = 'closed';
1663
-	if ( empty($data['ping_status']) )
1663
+	if (empty($data['ping_status']))
1664 1664
 		$data['ping_status'] = 'closed';
1665 1665
 
1666 1666
 	// Exclude terms from taxonomies that are not supposed to appear in Quick Edit.
1667
-	if ( ! empty( $data['tax_input'] ) ) {
1668
-		foreach ( $data['tax_input'] as $taxonomy => $terms ) {
1669
-			$tax_object = get_taxonomy( $taxonomy );
1667
+	if ( ! empty($data['tax_input'])) {
1668
+		foreach ($data['tax_input'] as $taxonomy => $terms) {
1669
+			$tax_object = get_taxonomy($taxonomy);
1670 1670
 			/** This filter is documented in wp-admin/includes/class-wp-posts-list-table.php */
1671
-			if ( ! apply_filters( 'quick_edit_show_taxonomy', $tax_object->show_in_quick_edit, $taxonomy, $post['post_type'] ) ) {
1672
-				unset( $data['tax_input'][ $taxonomy ] );
1671
+			if ( ! apply_filters('quick_edit_show_taxonomy', $tax_object->show_in_quick_edit, $taxonomy, $post['post_type'])) {
1672
+				unset($data['tax_input'][$taxonomy]);
1673 1673
 			}
1674 1674
 		}
1675 1675
 	}
1676 1676
 
1677 1677
 	// Hack: wp_unique_post_slug() doesn't work for drafts, so we will fake that our post is published.
1678
-	if ( ! empty( $data['post_name'] ) && in_array( $post['post_status'], array( 'draft', 'pending' ) ) ) {
1678
+	if ( ! empty($data['post_name']) && in_array($post['post_status'], array('draft', 'pending'))) {
1679 1679
 		$post['post_status'] = 'publish';
1680
-		$data['post_name'] = wp_unique_post_slug( $data['post_name'], $post['ID'], $post['post_status'], $post['post_type'], $post['post_parent'] );
1680
+		$data['post_name'] = wp_unique_post_slug($data['post_name'], $post['ID'], $post['post_status'], $post['post_type'], $post['post_parent']);
1681 1681
 	}
1682 1682
 
1683 1683
 	// Update the post.
1684 1684
 	edit_post();
1685 1685
 
1686
-	$wp_list_table = _get_list_table( 'WP_Posts_List_Table', array( 'screen' => $_POST['screen'] ) );
1686
+	$wp_list_table = _get_list_table('WP_Posts_List_Table', array('screen' => $_POST['screen']));
1687 1687
 
1688 1688
 	$mode = $_POST['post_view'] === 'excerpt' ? 'excerpt' : 'list';
1689 1689
 
1690 1690
 	$level = 0;
1691
-	if ( is_post_type_hierarchical( $wp_list_table->screen->post_type ) ) {
1692
-		$request_post = array( get_post( $_POST['post_ID'] ) );
1691
+	if (is_post_type_hierarchical($wp_list_table->screen->post_type)) {
1692
+		$request_post = array(get_post($_POST['post_ID']));
1693 1693
 		$parent       = $request_post[0]->post_parent;
1694 1694
 
1695
-		while ( $parent > 0 ) {
1696
-			$parent_post = get_post( $parent );
1695
+		while ($parent > 0) {
1696
+			$parent_post = get_post($parent);
1697 1697
 			$parent      = $parent_post->post_parent;
1698 1698
 			$level++;
1699 1699
 		}
1700 1700
 	}
1701 1701
 
1702
-	$wp_list_table->display_rows( array( get_post( $_POST['post_ID'] ) ), $level );
1702
+	$wp_list_table->display_rows(array(get_post($_POST['post_ID'])), $level);
1703 1703
 
1704 1704
 	wp_die();
1705 1705
 }
@@ -1714,45 +1714,45 @@  discard block
 block discarded – undo
1714 1714
 function wp_ajax_inline_save_tax() {
1715 1715
 	global $wp_list_table;
1716 1716
 
1717
-	check_ajax_referer( 'taxinlineeditnonce', '_inline_edit' );
1717
+	check_ajax_referer('taxinlineeditnonce', '_inline_edit');
1718 1718
 
1719
-	$taxonomy = sanitize_key( $_POST['taxonomy'] );
1720
-	$tax = get_taxonomy( $taxonomy );
1721
-	if ( ! $tax )
1722
-		wp_die( 0 );
1719
+	$taxonomy = sanitize_key($_POST['taxonomy']);
1720
+	$tax = get_taxonomy($taxonomy);
1721
+	if ( ! $tax)
1722
+		wp_die(0);
1723 1723
 
1724
-	if ( ! current_user_can( $tax->cap->edit_terms ) )
1724
+	if ( ! current_user_can($tax->cap->edit_terms))
1725 1725
 		wp_die( -1 );
1726 1726
 
1727
-	$wp_list_table = _get_list_table( 'WP_Terms_List_Table', array( 'screen' => 'edit-' . $taxonomy ) );
1727
+	$wp_list_table = _get_list_table('WP_Terms_List_Table', array('screen' => 'edit-'.$taxonomy));
1728 1728
 
1729
-	if ( ! isset($_POST['tax_ID']) || ! ( $id = (int) $_POST['tax_ID'] ) )
1729
+	if ( ! isset($_POST['tax_ID']) || ! ($id = (int) $_POST['tax_ID']))
1730 1730
 		wp_die( -1 );
1731 1731
 
1732
-	$tag = get_term( $id, $taxonomy );
1732
+	$tag = get_term($id, $taxonomy);
1733 1733
 	$_POST['description'] = $tag->description;
1734 1734
 
1735 1735
 	$updated = wp_update_term($id, $taxonomy, $_POST);
1736
-	if ( $updated && !is_wp_error($updated) ) {
1737
-		$tag = get_term( $updated['term_id'], $taxonomy );
1738
-		if ( !$tag || is_wp_error( $tag ) ) {
1739
-			if ( is_wp_error($tag) && $tag->get_error_message() )
1740
-				wp_die( $tag->get_error_message() );
1741
-			wp_die( __( 'Item not updated.' ) );
1736
+	if ($updated && ! is_wp_error($updated)) {
1737
+		$tag = get_term($updated['term_id'], $taxonomy);
1738
+		if ( ! $tag || is_wp_error($tag)) {
1739
+			if (is_wp_error($tag) && $tag->get_error_message())
1740
+				wp_die($tag->get_error_message());
1741
+			wp_die(__('Item not updated.'));
1742 1742
 		}
1743 1743
 	} else {
1744
-		if ( is_wp_error($updated) && $updated->get_error_message() )
1745
-			wp_die( $updated->get_error_message() );
1746
-		wp_die( __( 'Item not updated.' ) );
1744
+		if (is_wp_error($updated) && $updated->get_error_message())
1745
+			wp_die($updated->get_error_message());
1746
+		wp_die(__('Item not updated.'));
1747 1747
 	}
1748 1748
 	$level = 0;
1749 1749
 	$parent = $tag->parent;
1750
-	while ( $parent > 0 ) {
1751
-		$parent_tag = get_term( $parent, $taxonomy );
1750
+	while ($parent > 0) {
1751
+		$parent_tag = get_term($parent, $taxonomy);
1752 1752
 		$parent = $parent_tag->parent;
1753 1753
 		$level++;
1754 1754
 	}
1755
-	$wp_list_table->single_row( $tag, $level );
1755
+	$wp_list_table->single_row($tag, $level);
1756 1756
 	wp_die();
1757 1757
 }
1758 1758
 
@@ -1764,33 +1764,33 @@  discard block
 block discarded – undo
1764 1764
  * @since 3.1.0
1765 1765
  */
1766 1766
 function wp_ajax_find_posts() {
1767
-	check_ajax_referer( 'find-posts' );
1767
+	check_ajax_referer('find-posts');
1768 1768
 
1769
-	$post_types = get_post_types( array( 'public' => true ), 'objects' );
1770
-	unset( $post_types['attachment'] );
1769
+	$post_types = get_post_types(array('public' => true), 'objects');
1770
+	unset($post_types['attachment']);
1771 1771
 
1772
-	$s = wp_unslash( $_POST['ps'] );
1772
+	$s = wp_unslash($_POST['ps']);
1773 1773
 	$args = array(
1774
-		'post_type' => array_keys( $post_types ),
1774
+		'post_type' => array_keys($post_types),
1775 1775
 		'post_status' => 'any',
1776 1776
 		'posts_per_page' => 50,
1777 1777
 	);
1778
-	if ( '' !== $s )
1778
+	if ('' !== $s)
1779 1779
 		$args['s'] = $s;
1780 1780
 
1781
-	$posts = get_posts( $args );
1781
+	$posts = get_posts($args);
1782 1782
 
1783
-	if ( ! $posts ) {
1784
-		wp_send_json_error( __( 'No items found.' ) );
1783
+	if ( ! $posts) {
1784
+		wp_send_json_error(__('No items found.'));
1785 1785
 	}
1786 1786
 
1787 1787
 	$html = '<table class="widefat"><thead><tr><th class="found-radio"><br /></th><th>'.__('Title').'</th><th class="no-break">'.__('Type').'</th><th class="no-break">'.__('Date').'</th><th class="no-break">'.__('Status').'</th></tr></thead><tbody>';
1788 1788
 	$alt = '';
1789
-	foreach ( $posts as $post ) {
1790
-		$title = trim( $post->post_title ) ? $post->post_title : __( '(no title)' );
1791
-		$alt = ( 'alternate' == $alt ) ? '' : 'alternate';
1789
+	foreach ($posts as $post) {
1790
+		$title = trim($post->post_title) ? $post->post_title : __('(no title)');
1791
+		$alt = ('alternate' == $alt) ? '' : 'alternate';
1792 1792
 
1793
-		switch ( $post->post_status ) {
1793
+		switch ($post->post_status) {
1794 1794
 			case 'publish' :
1795 1795
 			case 'private' :
1796 1796
 				$stat = __('Published');
@@ -1806,20 +1806,20 @@  discard block
 block discarded – undo
1806 1806
 				break;
1807 1807
 		}
1808 1808
 
1809
-		if ( '0000-00-00 00:00:00' == $post->post_date ) {
1809
+		if ('0000-00-00 00:00:00' == $post->post_date) {
1810 1810
 			$time = '';
1811 1811
 		} else {
1812 1812
 			/* translators: date format in table columns, see https://secure.php.net/date */
1813 1813
 			$time = mysql2date(__('Y/m/d'), $post->post_date);
1814 1814
 		}
1815 1815
 
1816
-		$html .= '<tr class="' . trim( 'found-posts ' . $alt ) . '"><td class="found-radio"><input type="radio" id="found-'.$post->ID.'" name="found_post_id" value="' . esc_attr($post->ID) . '"></td>';
1817
-		$html .= '<td><label for="found-'.$post->ID.'">' . esc_html( $title ) . '</label></td><td class="no-break">' . esc_html( $post_types[$post->post_type]->labels->singular_name ) . '</td><td class="no-break">'.esc_html( $time ) . '</td><td class="no-break">' . esc_html( $stat ). ' </td></tr>' . "\n\n";
1816
+		$html .= '<tr class="'.trim('found-posts '.$alt).'"><td class="found-radio"><input type="radio" id="found-'.$post->ID.'" name="found_post_id" value="'.esc_attr($post->ID).'"></td>';
1817
+		$html .= '<td><label for="found-'.$post->ID.'">'.esc_html($title).'</label></td><td class="no-break">'.esc_html($post_types[$post->post_type]->labels->singular_name).'</td><td class="no-break">'.esc_html($time).'</td><td class="no-break">'.esc_html($stat).' </td></tr>'."\n\n";
1818 1818
 	}
1819 1819
 
1820 1820
 	$html .= '</tbody></table>';
1821 1821
 
1822
-	wp_send_json_success( $html );
1822
+	wp_send_json_success($html);
1823 1823
 }
1824 1824
 
1825 1825
 /**
@@ -1828,22 +1828,22 @@  discard block
 block discarded – undo
1828 1828
  * @since 3.1.0
1829 1829
  */
1830 1830
 function wp_ajax_widgets_order() {
1831
-	check_ajax_referer( 'save-sidebar-widgets', 'savewidgets' );
1831
+	check_ajax_referer('save-sidebar-widgets', 'savewidgets');
1832 1832
 
1833
-	if ( !current_user_can('edit_theme_options') )
1833
+	if ( ! current_user_can('edit_theme_options'))
1834 1834
 		wp_die( -1 );
1835 1835
 
1836
-	unset( $_POST['savewidgets'], $_POST['action'] );
1836
+	unset($_POST['savewidgets'], $_POST['action']);
1837 1837
 
1838 1838
 	// Save widgets order for all sidebars.
1839
-	if ( is_array($_POST['sidebars']) ) {
1839
+	if (is_array($_POST['sidebars'])) {
1840 1840
 		$sidebars = array();
1841
-		foreach ( $_POST['sidebars'] as $key => $val ) {
1841
+		foreach ($_POST['sidebars'] as $key => $val) {
1842 1842
 			$sb = array();
1843
-			if ( !empty($val) ) {
1843
+			if ( ! empty($val)) {
1844 1844
 				$val = explode(',', $val);
1845
-				foreach ( $val as $k => $v ) {
1846
-					if ( strpos($v, 'widget-') === false )
1845
+				foreach ($val as $k => $v) {
1846
+					if (strpos($v, 'widget-') === false)
1847 1847
 						continue;
1848 1848
 
1849 1849
 					$sb[$k] = substr($v, strpos($v, '_') + 1);
@@ -1852,7 +1852,7 @@  discard block
 block discarded – undo
1852 1852
 			$sidebars[$key] = $sb;
1853 1853
 		}
1854 1854
 		wp_set_sidebars_widgets($sidebars);
1855
-		wp_die( 1 );
1855
+		wp_die(1);
1856 1856
 	}
1857 1857
 
1858 1858
 	wp_die( -1 );
@@ -1870,87 +1870,87 @@  discard block
 block discarded – undo
1870 1870
 function wp_ajax_save_widget() {
1871 1871
 	global $wp_registered_widgets, $wp_registered_widget_controls, $wp_registered_widget_updates;
1872 1872
 
1873
-	check_ajax_referer( 'save-sidebar-widgets', 'savewidgets' );
1873
+	check_ajax_referer('save-sidebar-widgets', 'savewidgets');
1874 1874
 
1875
-	if ( !current_user_can('edit_theme_options') || !isset($_POST['id_base']) )
1875
+	if ( ! current_user_can('edit_theme_options') || ! isset($_POST['id_base']))
1876 1876
 		wp_die( -1 );
1877 1877
 
1878
-	unset( $_POST['savewidgets'], $_POST['action'] );
1878
+	unset($_POST['savewidgets'], $_POST['action']);
1879 1879
 
1880 1880
 	/**
1881 1881
 	 * Fires early when editing the widgets displayed in sidebars.
1882 1882
 	 *
1883 1883
 	 * @since 2.8.0
1884 1884
 	 */
1885
-	do_action( 'load-widgets.php' );
1885
+	do_action('load-widgets.php');
1886 1886
 
1887 1887
 	/**
1888 1888
 	 * Fires early when editing the widgets displayed in sidebars.
1889 1889
 	 *
1890 1890
 	 * @since 2.8.0
1891 1891
 	 */
1892
-	do_action( 'widgets.php' );
1892
+	do_action('widgets.php');
1893 1893
 
1894 1894
 	/** This action is documented in wp-admin/widgets.php */
1895
-	do_action( 'sidebar_admin_setup' );
1895
+	do_action('sidebar_admin_setup');
1896 1896
 
1897 1897
 	$id_base = $_POST['id_base'];
1898 1898
 	$widget_id = $_POST['widget-id'];
1899 1899
 	$sidebar_id = $_POST['sidebar'];
1900
-	$multi_number = !empty($_POST['multi_number']) ? (int) $_POST['multi_number'] : 0;
1901
-	$settings = isset($_POST['widget-' . $id_base]) && is_array($_POST['widget-' . $id_base]) ? $_POST['widget-' . $id_base] : false;
1902
-	$error = '<p>' . __('An error has occurred. Please reload the page and try again.') . '</p>';
1900
+	$multi_number = ! empty($_POST['multi_number']) ? (int) $_POST['multi_number'] : 0;
1901
+	$settings = isset($_POST['widget-'.$id_base]) && is_array($_POST['widget-'.$id_base]) ? $_POST['widget-'.$id_base] : false;
1902
+	$error = '<p>'.__('An error has occurred. Please reload the page and try again.').'</p>';
1903 1903
 
1904 1904
 	$sidebars = wp_get_sidebars_widgets();
1905 1905
 	$sidebar = isset($sidebars[$sidebar_id]) ? $sidebars[$sidebar_id] : array();
1906 1906
 
1907 1907
 	// Delete.
1908
-	if ( isset($_POST['delete_widget']) && $_POST['delete_widget'] ) {
1908
+	if (isset($_POST['delete_widget']) && $_POST['delete_widget']) {
1909 1909
 
1910
-		if ( !isset($wp_registered_widgets[$widget_id]) )
1911
-			wp_die( $error );
1910
+		if ( ! isset($wp_registered_widgets[$widget_id]))
1911
+			wp_die($error);
1912 1912
 
1913
-		$sidebar = array_diff( $sidebar, array($widget_id) );
1914
-		$_POST = array('sidebar' => $sidebar_id, 'widget-' . $id_base => array(), 'the-widget-id' => $widget_id, 'delete_widget' => '1');
1913
+		$sidebar = array_diff($sidebar, array($widget_id));
1914
+		$_POST = array('sidebar' => $sidebar_id, 'widget-'.$id_base => array(), 'the-widget-id' => $widget_id, 'delete_widget' => '1');
1915 1915
 
1916 1916
 		/** This action is documented in wp-admin/widgets.php */
1917
-		do_action( 'delete_widget', $widget_id, $sidebar_id, $id_base );
1917
+		do_action('delete_widget', $widget_id, $sidebar_id, $id_base);
1918 1918
 
1919
-	} elseif ( $settings && preg_match( '/__i__|%i%/', key($settings) ) ) {
1920
-		if ( !$multi_number )
1921
-			wp_die( $error );
1919
+	} elseif ($settings && preg_match('/__i__|%i%/', key($settings))) {
1920
+		if ( ! $multi_number)
1921
+			wp_die($error);
1922 1922
 
1923
-		$_POST[ 'widget-' . $id_base ] = array( $multi_number => reset( $settings ) );
1924
-		$widget_id = $id_base . '-' . $multi_number;
1923
+		$_POST['widget-'.$id_base] = array($multi_number => reset($settings));
1924
+		$widget_id = $id_base.'-'.$multi_number;
1925 1925
 		$sidebar[] = $widget_id;
1926 1926
 	}
1927 1927
 	$_POST['widget-id'] = $sidebar;
1928 1928
 
1929
-	foreach ( (array) $wp_registered_widget_updates as $name => $control ) {
1929
+	foreach ((array) $wp_registered_widget_updates as $name => $control) {
1930 1930
 
1931
-		if ( $name == $id_base ) {
1932
-			if ( !is_callable( $control['callback'] ) )
1931
+		if ($name == $id_base) {
1932
+			if ( ! is_callable($control['callback']))
1933 1933
 				continue;
1934 1934
 
1935 1935
 			ob_start();
1936
-				call_user_func_array( $control['callback'], $control['params'] );
1936
+				call_user_func_array($control['callback'], $control['params']);
1937 1937
 			ob_end_clean();
1938 1938
 			break;
1939 1939
 		}
1940 1940
 	}
1941 1941
 
1942
-	if ( isset($_POST['delete_widget']) && $_POST['delete_widget'] ) {
1942
+	if (isset($_POST['delete_widget']) && $_POST['delete_widget']) {
1943 1943
 		$sidebars[$sidebar_id] = $sidebar;
1944 1944
 		wp_set_sidebars_widgets($sidebars);
1945 1945
 		echo "deleted:$widget_id";
1946 1946
 		wp_die();
1947 1947
 	}
1948 1948
 
1949
-	if ( !empty($_POST['add_new']) )
1949
+	if ( ! empty($_POST['add_new']))
1950 1950
 		wp_die();
1951 1951
 
1952
-	if ( $form = $wp_registered_widget_controls[$widget_id] )
1953
-		call_user_func_array( $form['callback'], $form['params'] );
1952
+	if ($form = $wp_registered_widget_controls[$widget_id])
1953
+		call_user_func_array($form['callback'], $form['params']);
1954 1954
 
1955 1955
 	wp_die();
1956 1956
 }
@@ -1973,31 +1973,31 @@  discard block
 block discarded – undo
1973 1973
  * @since 4.4.0
1974 1974
  */
1975 1975
 function wp_ajax_delete_inactive_widgets() {
1976
-	check_ajax_referer( 'remove-inactive-widgets', 'removeinactivewidgets' );
1976
+	check_ajax_referer('remove-inactive-widgets', 'removeinactivewidgets');
1977 1977
 
1978
-	if ( ! current_user_can( 'edit_theme_options' ) ) {
1978
+	if ( ! current_user_can('edit_theme_options')) {
1979 1979
 		wp_die( -1 );
1980 1980
 	}
1981 1981
 
1982
-	unset( $_POST['removeinactivewidgets'], $_POST['action'] );
1982
+	unset($_POST['removeinactivewidgets'], $_POST['action']);
1983 1983
 
1984
-	do_action( 'load-widgets.php' );
1985
-	do_action( 'widgets.php' );
1986
-	do_action( 'sidebar_admin_setup' );
1984
+	do_action('load-widgets.php');
1985
+	do_action('widgets.php');
1986
+	do_action('sidebar_admin_setup');
1987 1987
 
1988 1988
 	$sidebars_widgets = wp_get_sidebars_widgets();
1989 1989
 
1990
-	foreach ( $sidebars_widgets['wp_inactive_widgets'] as $key => $widget_id ) {
1991
-		$pieces = explode( '-', $widget_id );
1992
-		$multi_number = array_pop( $pieces );
1993
-		$id_base = implode( '-', $pieces );
1994
-		$widget = get_option( 'widget_' . $id_base );
1995
-		unset( $widget[$multi_number] );
1996
-		update_option( 'widget_' . $id_base, $widget );
1997
-		unset( $sidebars_widgets['wp_inactive_widgets'][$key] );
1990
+	foreach ($sidebars_widgets['wp_inactive_widgets'] as $key => $widget_id) {
1991
+		$pieces = explode('-', $widget_id);
1992
+		$multi_number = array_pop($pieces);
1993
+		$id_base = implode('-', $pieces);
1994
+		$widget = get_option('widget_'.$id_base);
1995
+		unset($widget[$multi_number]);
1996
+		update_option('widget_'.$id_base, $widget);
1997
+		unset($sidebars_widgets['wp_inactive_widgets'][$key]);
1998 1998
 	}
1999 1999
 
2000
-	wp_set_sidebars_widgets( $sidebars_widgets );
2000
+	wp_set_sidebars_widgets($sidebars_widgets);
2001 2001
 
2002 2002
 	wp_die();
2003 2003
 }
@@ -2008,35 +2008,35 @@  discard block
 block discarded – undo
2008 2008
  * @since 3.3.0
2009 2009
  */
2010 2010
 function wp_ajax_upload_attachment() {
2011
-	check_ajax_referer( 'media-form' );
2011
+	check_ajax_referer('media-form');
2012 2012
 	/*
2013 2013
 	 * This function does not use wp_send_json_success() / wp_send_json_error()
2014 2014
 	 * as the html4 Plupload handler requires a text/html content-type for older IE.
2015 2015
 	 * See https://core.trac.wordpress.org/ticket/31037
2016 2016
 	 */
2017 2017
 
2018
-	if ( ! current_user_can( 'upload_files' ) ) {
2019
-		echo wp_json_encode( array(
2018
+	if ( ! current_user_can('upload_files')) {
2019
+		echo wp_json_encode(array(
2020 2020
 			'success' => false,
2021 2021
 			'data'    => array(
2022
-				'message'  => __( 'Sorry, you are not allowed to upload files.' ),
2022
+				'message'  => __('Sorry, you are not allowed to upload files.'),
2023 2023
 				'filename' => $_FILES['async-upload']['name'],
2024 2024
 			)
2025
-		) );
2025
+		));
2026 2026
 
2027 2027
 		wp_die();
2028 2028
 	}
2029 2029
 
2030
-	if ( isset( $_REQUEST['post_id'] ) ) {
2030
+	if (isset($_REQUEST['post_id'])) {
2031 2031
 		$post_id = $_REQUEST['post_id'];
2032
-		if ( ! current_user_can( 'edit_post', $post_id ) ) {
2033
-			echo wp_json_encode( array(
2032
+		if ( ! current_user_can('edit_post', $post_id)) {
2033
+			echo wp_json_encode(array(
2034 2034
 				'success' => false,
2035 2035
 				'data'    => array(
2036
-					'message'  => __( "You don't have permission to attach files to this post." ),
2036
+					'message'  => __("You don't have permission to attach files to this post."),
2037 2037
 					'filename' => $_FILES['async-upload']['name'],
2038 2038
 				)
2039
-			) );
2039
+			));
2040 2040
 
2041 2041
 			wp_die();
2042 2042
 		}
@@ -2044,53 +2044,53 @@  discard block
 block discarded – undo
2044 2044
 		$post_id = null;
2045 2045
 	}
2046 2046
 
2047
-	$post_data = isset( $_REQUEST['post_data'] ) ? $_REQUEST['post_data'] : array();
2047
+	$post_data = isset($_REQUEST['post_data']) ? $_REQUEST['post_data'] : array();
2048 2048
 
2049 2049
 	// If the context is custom header or background, make sure the uploaded file is an image.
2050
-	if ( isset( $post_data['context'] ) && in_array( $post_data['context'], array( 'custom-header', 'custom-background' ) ) ) {
2051
-		$wp_filetype = wp_check_filetype_and_ext( $_FILES['async-upload']['tmp_name'], $_FILES['async-upload']['name'] );
2052
-		if ( ! wp_match_mime_types( 'image', $wp_filetype['type'] ) ) {
2053
-			echo wp_json_encode( array(
2050
+	if (isset($post_data['context']) && in_array($post_data['context'], array('custom-header', 'custom-background'))) {
2051
+		$wp_filetype = wp_check_filetype_and_ext($_FILES['async-upload']['tmp_name'], $_FILES['async-upload']['name']);
2052
+		if ( ! wp_match_mime_types('image', $wp_filetype['type'])) {
2053
+			echo wp_json_encode(array(
2054 2054
 				'success' => false,
2055 2055
 				'data'    => array(
2056
-					'message'  => __( 'The uploaded file is not a valid image. Please try again.' ),
2056
+					'message'  => __('The uploaded file is not a valid image. Please try again.'),
2057 2057
 					'filename' => $_FILES['async-upload']['name'],
2058 2058
 				)
2059
-			) );
2059
+			));
2060 2060
 
2061 2061
 			wp_die();
2062 2062
 		}
2063 2063
 	}
2064 2064
 
2065
-	$attachment_id = media_handle_upload( 'async-upload', $post_id, $post_data );
2065
+	$attachment_id = media_handle_upload('async-upload', $post_id, $post_data);
2066 2066
 
2067
-	if ( is_wp_error( $attachment_id ) ) {
2068
-		echo wp_json_encode( array(
2067
+	if (is_wp_error($attachment_id)) {
2068
+		echo wp_json_encode(array(
2069 2069
 			'success' => false,
2070 2070
 			'data'    => array(
2071 2071
 				'message'  => $attachment_id->get_error_message(),
2072 2072
 				'filename' => $_FILES['async-upload']['name'],
2073 2073
 			)
2074
-		) );
2074
+		));
2075 2075
 
2076 2076
 		wp_die();
2077 2077
 	}
2078 2078
 
2079
-	if ( isset( $post_data['context'] ) && isset( $post_data['theme'] ) ) {
2080
-		if ( 'custom-background' === $post_data['context'] )
2081
-			update_post_meta( $attachment_id, '_wp_attachment_is_custom_background', $post_data['theme'] );
2079
+	if (isset($post_data['context']) && isset($post_data['theme'])) {
2080
+		if ('custom-background' === $post_data['context'])
2081
+			update_post_meta($attachment_id, '_wp_attachment_is_custom_background', $post_data['theme']);
2082 2082
 
2083
-		if ( 'custom-header' === $post_data['context'] )
2084
-			update_post_meta( $attachment_id, '_wp_attachment_is_custom_header', $post_data['theme'] );
2083
+		if ('custom-header' === $post_data['context'])
2084
+			update_post_meta($attachment_id, '_wp_attachment_is_custom_header', $post_data['theme']);
2085 2085
 	}
2086 2086
 
2087
-	if ( ! $attachment = wp_prepare_attachment_for_js( $attachment_id ) )
2087
+	if ( ! $attachment = wp_prepare_attachment_for_js($attachment_id))
2088 2088
 		wp_die();
2089 2089
 
2090
-	echo wp_json_encode( array(
2090
+	echo wp_json_encode(array(
2091 2091
 		'success' => true,
2092 2092
 		'data'    => $attachment,
2093
-	) );
2093
+	));
2094 2094
 
2095 2095
 	wp_die();
2096 2096
 }
@@ -2102,18 +2102,18 @@  discard block
 block discarded – undo
2102 2102
  */
2103 2103
 function wp_ajax_image_editor() {
2104 2104
 	$attachment_id = intval($_POST['postid']);
2105
-	if ( empty($attachment_id) || !current_user_can('edit_post', $attachment_id) )
2105
+	if (empty($attachment_id) || ! current_user_can('edit_post', $attachment_id))
2106 2106
 		wp_die( -1 );
2107 2107
 
2108
-	check_ajax_referer( "image_editor-$attachment_id" );
2109
-	include_once( ABSPATH . 'wp-admin/includes/image-edit.php' );
2108
+	check_ajax_referer("image_editor-$attachment_id");
2109
+	include_once(ABSPATH.'wp-admin/includes/image-edit.php');
2110 2110
 
2111 2111
 	$msg = false;
2112
-	switch ( $_POST['do'] ) {
2112
+	switch ($_POST['do']) {
2113 2113
 		case 'save' :
2114 2114
 			$msg = wp_save_image($attachment_id);
2115 2115
 			$msg = wp_json_encode($msg);
2116
-			wp_die( $msg );
2116
+			wp_die($msg);
2117 2117
 			break;
2118 2118
 		case 'scale' :
2119 2119
 			$msg = wp_save_image($attachment_id);
@@ -2133,34 +2133,34 @@  discard block
 block discarded – undo
2133 2133
  * @since 3.1.0
2134 2134
  */
2135 2135
 function wp_ajax_set_post_thumbnail() {
2136
-	$json = ! empty( $_REQUEST['json'] ); // New-style request
2136
+	$json = ! empty($_REQUEST['json']); // New-style request
2137 2137
 
2138
-	$post_ID = intval( $_POST['post_id'] );
2139
-	if ( ! current_user_can( 'edit_post', $post_ID ) )
2138
+	$post_ID = intval($_POST['post_id']);
2139
+	if ( ! current_user_can('edit_post', $post_ID))
2140 2140
 		wp_die( -1 );
2141 2141
 
2142
-	$thumbnail_id = intval( $_POST['thumbnail_id'] );
2142
+	$thumbnail_id = intval($_POST['thumbnail_id']);
2143 2143
 
2144
-	if ( $json )
2145
-		check_ajax_referer( "update-post_$post_ID" );
2144
+	if ($json)
2145
+		check_ajax_referer("update-post_$post_ID");
2146 2146
 	else
2147
-		check_ajax_referer( "set_post_thumbnail-$post_ID" );
2147
+		check_ajax_referer("set_post_thumbnail-$post_ID");
2148 2148
 
2149
-	if ( $thumbnail_id == '-1' ) {
2150
-		if ( delete_post_thumbnail( $post_ID ) ) {
2151
-			$return = _wp_post_thumbnail_html( null, $post_ID );
2152
-			$json ? wp_send_json_success( $return ) : wp_die( $return );
2149
+	if ($thumbnail_id == '-1') {
2150
+		if (delete_post_thumbnail($post_ID)) {
2151
+			$return = _wp_post_thumbnail_html(null, $post_ID);
2152
+			$json ? wp_send_json_success($return) : wp_die($return);
2153 2153
 		} else {
2154
-			wp_die( 0 );
2154
+			wp_die(0);
2155 2155
 		}
2156 2156
 	}
2157 2157
 
2158
-	if ( set_post_thumbnail( $post_ID, $thumbnail_id ) ) {
2159
-		$return = _wp_post_thumbnail_html( $thumbnail_id, $post_ID );
2160
-		$json ? wp_send_json_success( $return ) : wp_die( $return );
2158
+	if (set_post_thumbnail($post_ID, $thumbnail_id)) {
2159
+		$return = _wp_post_thumbnail_html($thumbnail_id, $post_ID);
2160
+		$json ? wp_send_json_success($return) : wp_die($return);
2161 2161
 	}
2162 2162
 
2163
-	wp_die( 0 );
2163
+	wp_die(0);
2164 2164
 }
2165 2165
 
2166 2166
 /**
@@ -2169,23 +2169,23 @@  discard block
 block discarded – undo
2169 2169
  * @since 4.6.0
2170 2170
  */
2171 2171
 function wp_ajax_get_post_thumbnail_html() {
2172
-	$post_ID = intval( $_POST['post_id'] );
2172
+	$post_ID = intval($_POST['post_id']);
2173 2173
 
2174
-	check_ajax_referer( "update-post_$post_ID" );
2174
+	check_ajax_referer("update-post_$post_ID");
2175 2175
 
2176
-	if ( ! current_user_can( 'edit_post', $post_ID ) ) {
2176
+	if ( ! current_user_can('edit_post', $post_ID)) {
2177 2177
 		wp_die( -1 );
2178 2178
 	}
2179 2179
 
2180
-	$thumbnail_id = intval( $_POST['thumbnail_id'] );
2180
+	$thumbnail_id = intval($_POST['thumbnail_id']);
2181 2181
 
2182 2182
 	// For backward compatibility, -1 refers to no featured image.
2183 2183
 	if ( -1 === $thumbnail_id ) {
2184 2184
 		$thumbnail_id = null;
2185 2185
 	}
2186 2186
 
2187
-	$return = _wp_post_thumbnail_html( $thumbnail_id, $post_ID );
2188
-	wp_send_json_success( $return );
2187
+	$return = _wp_post_thumbnail_html($thumbnail_id, $post_ID);
2188
+	wp_send_json_success($return);
2189 2189
 }
2190 2190
 
2191 2191
 /**
@@ -2196,41 +2196,41 @@  discard block
 block discarded – undo
2196 2196
  * @see set_post_thumbnail()
2197 2197
  */
2198 2198
 function wp_ajax_set_attachment_thumbnail() {
2199
-	if ( empty( $_POST['urls'] ) || ! is_array( $_POST['urls'] ) ) {
2199
+	if (empty($_POST['urls']) || ! is_array($_POST['urls'])) {
2200 2200
 		wp_send_json_error();
2201 2201
 	}
2202 2202
 
2203 2203
 	$thumbnail_id = (int) $_POST['thumbnail_id'];
2204
-	if ( empty( $thumbnail_id ) ) {
2204
+	if (empty($thumbnail_id)) {
2205 2205
 		wp_send_json_error();
2206 2206
 	}
2207 2207
 
2208 2208
 	$post_ids = array();
2209 2209
 	// For each URL, try to find its corresponding post ID.
2210
-	foreach ( $_POST['urls'] as $url ) {
2211
-		$post_id = attachment_url_to_postid( $url );
2212
-		if ( ! empty( $post_id ) ) {
2210
+	foreach ($_POST['urls'] as $url) {
2211
+		$post_id = attachment_url_to_postid($url);
2212
+		if ( ! empty($post_id)) {
2213 2213
 			$post_ids[] = $post_id;
2214 2214
 		}
2215 2215
 	}
2216 2216
 
2217
-	if ( empty( $post_ids ) ) {
2217
+	if (empty($post_ids)) {
2218 2218
 		wp_send_json_error();
2219 2219
 	}
2220 2220
 
2221 2221
 	$success = 0;
2222 2222
 	// For each found attachment, set its thumbnail.
2223
-	foreach ( $post_ids as $post_id ) {
2224
-		if ( ! current_user_can( 'edit_post', $post_id ) ) {
2223
+	foreach ($post_ids as $post_id) {
2224
+		if ( ! current_user_can('edit_post', $post_id)) {
2225 2225
 			continue;
2226 2226
 		}
2227 2227
 
2228
-		if ( set_post_thumbnail( $post_id, $thumbnail_id ) ) {
2228
+		if (set_post_thumbnail($post_id, $thumbnail_id)) {
2229 2229
 			$success++;
2230 2230
 		}
2231 2231
 	}
2232 2232
 
2233
-	if ( 0 === $success ) {
2233
+	if (0 === $success) {
2234 2234
 		wp_send_json_error();
2235 2235
 	} else {
2236 2236
 		wp_send_json_success();
@@ -2245,7 +2245,7 @@  discard block
 block discarded – undo
2245 2245
  * @since 3.1.0
2246 2246
  */
2247 2247
 function wp_ajax_date_format() {
2248
-	wp_die( date_i18n( sanitize_option( 'date_format', wp_unslash( $_POST['date'] ) ) ) );
2248
+	wp_die(date_i18n(sanitize_option('date_format', wp_unslash($_POST['date']))));
2249 2249
 }
2250 2250
 
2251 2251
 /**
@@ -2254,7 +2254,7 @@  discard block
 block discarded – undo
2254 2254
  * @since 3.1.0
2255 2255
  */
2256 2256
 function wp_ajax_time_format() {
2257
-	wp_die( date_i18n( sanitize_option( 'time_format', wp_unslash( $_POST['date'] ) ) ) );
2257
+	wp_die(date_i18n(sanitize_option('time_format', wp_unslash($_POST['date']))));
2258 2258
 }
2259 2259
 
2260 2260
 /**
@@ -2264,37 +2264,37 @@  discard block
 block discarded – undo
2264 2264
  * @deprecated 4.3.0
2265 2265
  */
2266 2266
 function wp_ajax_wp_fullscreen_save_post() {
2267
-	$post_id = isset( $_POST['post_ID'] ) ? (int) $_POST['post_ID'] : 0;
2267
+	$post_id = isset($_POST['post_ID']) ? (int) $_POST['post_ID'] : 0;
2268 2268
 
2269 2269
 	$post = null;
2270 2270
 
2271
-	if ( $post_id )
2272
-		$post = get_post( $post_id );
2271
+	if ($post_id)
2272
+		$post = get_post($post_id);
2273 2273
 
2274
-	check_ajax_referer('update-post_' . $post_id, '_wpnonce');
2274
+	check_ajax_referer('update-post_'.$post_id, '_wpnonce');
2275 2275
 
2276 2276
 	$post_id = edit_post();
2277 2277
 
2278
-	if ( is_wp_error( $post_id ) ) {
2278
+	if (is_wp_error($post_id)) {
2279 2279
 		wp_send_json_error();
2280 2280
 	}
2281 2281
 
2282
-	if ( $post ) {
2283
-		$last_date = mysql2date( __( 'F j, Y' ), $post->post_modified );
2284
-		$last_time = mysql2date( __( 'g:i a' ), $post->post_modified );
2282
+	if ($post) {
2283
+		$last_date = mysql2date(__('F j, Y'), $post->post_modified);
2284
+		$last_time = mysql2date(__('g:i a'), $post->post_modified);
2285 2285
 	} else {
2286
-		$last_date = date_i18n( __( 'F j, Y' ) );
2287
-		$last_time = date_i18n( __( 'g:i a' ) );
2286
+		$last_date = date_i18n(__('F j, Y'));
2287
+		$last_time = date_i18n(__('g:i a'));
2288 2288
 	}
2289 2289
 
2290
-	if ( $last_id = get_post_meta( $post_id, '_edit_last', true ) ) {
2291
-		$last_user = get_userdata( $last_id );
2292
-		$last_edited = sprintf( __('Last edited by %1$s on %2$s at %3$s'), esc_html( $last_user->display_name ), $last_date, $last_time );
2290
+	if ($last_id = get_post_meta($post_id, '_edit_last', true)) {
2291
+		$last_user = get_userdata($last_id);
2292
+		$last_edited = sprintf(__('Last edited by %1$s on %2$s at %3$s'), esc_html($last_user->display_name), $last_date, $last_time);
2293 2293
 	} else {
2294
-		$last_edited = sprintf( __('Last edited on %1$s at %2$s'), $last_date, $last_time );
2294
+		$last_edited = sprintf(__('Last edited on %1$s at %2$s'), $last_date, $last_time);
2295 2295
 	}
2296 2296
 
2297
-	wp_send_json_success( array( 'last_edited' => $last_edited ) );
2297
+	wp_send_json_success(array('last_edited' => $last_edited));
2298 2298
 }
2299 2299
 
2300 2300
 /**
@@ -2303,20 +2303,20 @@  discard block
 block discarded – undo
2303 2303
  * @since 3.1.0
2304 2304
  */
2305 2305
 function wp_ajax_wp_remove_post_lock() {
2306
-	if ( empty( $_POST['post_ID'] ) || empty( $_POST['active_post_lock'] ) )
2307
-		wp_die( 0 );
2306
+	if (empty($_POST['post_ID']) || empty($_POST['active_post_lock']))
2307
+		wp_die(0);
2308 2308
 	$post_id = (int) $_POST['post_ID'];
2309
-	if ( ! $post = get_post( $post_id ) )
2310
-		wp_die( 0 );
2309
+	if ( ! $post = get_post($post_id))
2310
+		wp_die(0);
2311 2311
 
2312
-	check_ajax_referer( 'update-post_' . $post_id );
2312
+	check_ajax_referer('update-post_'.$post_id);
2313 2313
 
2314
-	if ( ! current_user_can( 'edit_post', $post_id ) )
2314
+	if ( ! current_user_can('edit_post', $post_id))
2315 2315
 		wp_die( -1 );
2316 2316
 
2317
-	$active_lock = array_map( 'absint', explode( ':', $_POST['active_post_lock'] ) );
2318
-	if ( $active_lock[1] != get_current_user_id() )
2319
-		wp_die( 0 );
2317
+	$active_lock = array_map('absint', explode(':', $_POST['active_post_lock']));
2318
+	if ($active_lock[1] != get_current_user_id())
2319
+		wp_die(0);
2320 2320
 
2321 2321
 	/**
2322 2322
 	 * Filters the post lock window duration.
@@ -2326,9 +2326,9 @@  discard block
 block discarded – undo
2326 2326
 	 * @param int $interval The interval in seconds the post lock duration
2327 2327
 	 *                      should last, plus 5 seconds. Default 150.
2328 2328
 	 */
2329
-	$new_lock = ( time() - apply_filters( 'wp_check_post_lock_window', 150 ) + 5 ) . ':' . $active_lock[1];
2330
-	update_post_meta( $post_id, '_edit_lock', $new_lock, implode( ':', $active_lock ) );
2331
-	wp_die( 1 );
2329
+	$new_lock = (time() - apply_filters('wp_check_post_lock_window', 150) + 5).':'.$active_lock[1];
2330
+	update_post_meta($post_id, '_edit_lock', $new_lock, implode(':', $active_lock));
2331
+	wp_die(1);
2332 2332
 }
2333 2333
 
2334 2334
 /**
@@ -2338,21 +2338,21 @@  discard block
 block discarded – undo
2338 2338
  */
2339 2339
 function wp_ajax_dismiss_wp_pointer() {
2340 2340
 	$pointer = $_POST['pointer'];
2341
-	if ( $pointer != sanitize_key( $pointer ) )
2342
-		wp_die( 0 );
2341
+	if ($pointer != sanitize_key($pointer))
2342
+		wp_die(0);
2343 2343
 
2344 2344
 //	check_ajax_referer( 'dismiss-pointer_' . $pointer );
2345 2345
 
2346
-	$dismissed = array_filter( explode( ',', (string) get_user_meta( get_current_user_id(), 'dismissed_wp_pointers', true ) ) );
2346
+	$dismissed = array_filter(explode(',', (string) get_user_meta(get_current_user_id(), 'dismissed_wp_pointers', true)));
2347 2347
 
2348
-	if ( in_array( $pointer, $dismissed ) )
2349
-		wp_die( 0 );
2348
+	if (in_array($pointer, $dismissed))
2349
+		wp_die(0);
2350 2350
 
2351 2351
 	$dismissed[] = $pointer;
2352
-	$dismissed = implode( ',', $dismissed );
2352
+	$dismissed = implode(',', $dismissed);
2353 2353
 
2354
-	update_user_meta( get_current_user_id(), 'dismissed_wp_pointers', $dismissed );
2355
-	wp_die( 1 );
2354
+	update_user_meta(get_current_user_id(), 'dismissed_wp_pointers', $dismissed);
2355
+	wp_die(1);
2356 2356
 }
2357 2357
 
2358 2358
 /**
@@ -2361,25 +2361,25 @@  discard block
 block discarded – undo
2361 2361
  * @since 3.5.0
2362 2362
  */
2363 2363
 function wp_ajax_get_attachment() {
2364
-	if ( ! isset( $_REQUEST['id'] ) )
2364
+	if ( ! isset($_REQUEST['id']))
2365 2365
 		wp_send_json_error();
2366 2366
 
2367
-	if ( ! $id = absint( $_REQUEST['id'] ) )
2367
+	if ( ! $id = absint($_REQUEST['id']))
2368 2368
 		wp_send_json_error();
2369 2369
 
2370
-	if ( ! $post = get_post( $id ) )
2370
+	if ( ! $post = get_post($id))
2371 2371
 		wp_send_json_error();
2372 2372
 
2373
-	if ( 'attachment' != $post->post_type )
2373
+	if ('attachment' != $post->post_type)
2374 2374
 		wp_send_json_error();
2375 2375
 
2376
-	if ( ! current_user_can( 'upload_files' ) )
2376
+	if ( ! current_user_can('upload_files'))
2377 2377
 		wp_send_json_error();
2378 2378
 
2379
-	if ( ! $attachment = wp_prepare_attachment_for_js( $id ) )
2379
+	if ( ! $attachment = wp_prepare_attachment_for_js($id))
2380 2380
 		wp_send_json_error();
2381 2381
 
2382
-	wp_send_json_success( $attachment );
2382
+	wp_send_json_success($attachment);
2383 2383
 }
2384 2384
 
2385 2385
 /**
@@ -2388,31 +2388,31 @@  discard block
 block discarded – undo
2388 2388
  * @since 3.5.0
2389 2389
  */
2390 2390
 function wp_ajax_query_attachments() {
2391
-	if ( ! current_user_can( 'upload_files' ) )
2391
+	if ( ! current_user_can('upload_files'))
2392 2392
 		wp_send_json_error();
2393 2393
 
2394
-	$query = isset( $_REQUEST['query'] ) ? (array) $_REQUEST['query'] : array();
2394
+	$query = isset($_REQUEST['query']) ? (array) $_REQUEST['query'] : array();
2395 2395
 	$keys = array(
2396 2396
 		's', 'order', 'orderby', 'posts_per_page', 'paged', 'post_mime_type',
2397 2397
 		'post_parent', 'post__in', 'post__not_in', 'year', 'monthnum'
2398 2398
 	);
2399
-	foreach ( get_taxonomies_for_attachments( 'objects' ) as $t ) {
2400
-		if ( $t->query_var && isset( $query[ $t->query_var ] ) ) {
2399
+	foreach (get_taxonomies_for_attachments('objects') as $t) {
2400
+		if ($t->query_var && isset($query[$t->query_var])) {
2401 2401
 			$keys[] = $t->query_var;
2402 2402
 		}
2403 2403
 	}
2404 2404
 
2405
-	$query = array_intersect_key( $query, array_flip( $keys ) );
2405
+	$query = array_intersect_key($query, array_flip($keys));
2406 2406
 	$query['post_type'] = 'attachment';
2407
-	if ( MEDIA_TRASH
2408
-		&& ! empty( $_REQUEST['query']['post_status'] )
2409
-		&& 'trash' === $_REQUEST['query']['post_status'] ) {
2407
+	if (MEDIA_TRASH
2408
+		&& ! empty($_REQUEST['query']['post_status'])
2409
+		&& 'trash' === $_REQUEST['query']['post_status']) {
2410 2410
 		$query['post_status'] = 'trash';
2411 2411
 	} else {
2412 2412
 		$query['post_status'] = 'inherit';
2413 2413
 	}
2414 2414
 
2415
-	if ( current_user_can( get_post_type_object( 'attachment' )->cap->read_private_posts ) )
2415
+	if (current_user_can(get_post_type_object('attachment')->cap->read_private_posts))
2416 2416
 		$query['post_status'] .= ',private';
2417 2417
 
2418 2418
 	/**
@@ -2425,13 +2425,13 @@  discard block
 block discarded – undo
2425 2425
 	 *
2426 2426
 	 * @param array $query An array of query variables.
2427 2427
 	 */
2428
-	$query = apply_filters( 'ajax_query_attachments_args', $query );
2429
-	$query = new WP_Query( $query );
2428
+	$query = apply_filters('ajax_query_attachments_args', $query);
2429
+	$query = new WP_Query($query);
2430 2430
 
2431
-	$posts = array_map( 'wp_prepare_attachment_for_js', $query->posts );
2432
-	$posts = array_filter( $posts );
2431
+	$posts = array_map('wp_prepare_attachment_for_js', $query->posts);
2432
+	$posts = array_filter($posts);
2433 2433
 
2434
-	wp_send_json_success( $posts );
2434
+	wp_send_json_success($posts);
2435 2435
 }
2436 2436
 
2437 2437
 /**
@@ -2440,69 +2440,69 @@  discard block
 block discarded – undo
2440 2440
  * @since 3.5.0
2441 2441
  */
2442 2442
 function wp_ajax_save_attachment() {
2443
-	if ( ! isset( $_REQUEST['id'] ) || ! isset( $_REQUEST['changes'] ) )
2443
+	if ( ! isset($_REQUEST['id']) || ! isset($_REQUEST['changes']))
2444 2444
 		wp_send_json_error();
2445 2445
 
2446
-	if ( ! $id = absint( $_REQUEST['id'] ) )
2446
+	if ( ! $id = absint($_REQUEST['id']))
2447 2447
 		wp_send_json_error();
2448 2448
 
2449
-	check_ajax_referer( 'update-post_' . $id, 'nonce' );
2449
+	check_ajax_referer('update-post_'.$id, 'nonce');
2450 2450
 
2451
-	if ( ! current_user_can( 'edit_post', $id ) )
2451
+	if ( ! current_user_can('edit_post', $id))
2452 2452
 		wp_send_json_error();
2453 2453
 
2454 2454
 	$changes = $_REQUEST['changes'];
2455
-	$post    = get_post( $id, ARRAY_A );
2455
+	$post    = get_post($id, ARRAY_A);
2456 2456
 
2457
-	if ( 'attachment' != $post['post_type'] )
2457
+	if ('attachment' != $post['post_type'])
2458 2458
 		wp_send_json_error();
2459 2459
 
2460
-	if ( isset( $changes['parent'] ) )
2460
+	if (isset($changes['parent']))
2461 2461
 		$post['post_parent'] = $changes['parent'];
2462 2462
 
2463
-	if ( isset( $changes['title'] ) )
2463
+	if (isset($changes['title']))
2464 2464
 		$post['post_title'] = $changes['title'];
2465 2465
 
2466
-	if ( isset( $changes['caption'] ) )
2466
+	if (isset($changes['caption']))
2467 2467
 		$post['post_excerpt'] = $changes['caption'];
2468 2468
 
2469
-	if ( isset( $changes['description'] ) )
2469
+	if (isset($changes['description']))
2470 2470
 		$post['post_content'] = $changes['description'];
2471 2471
 
2472
-	if ( MEDIA_TRASH && isset( $changes['status'] ) )
2472
+	if (MEDIA_TRASH && isset($changes['status']))
2473 2473
 		$post['post_status'] = $changes['status'];
2474 2474
 
2475
-	if ( isset( $changes['alt'] ) ) {
2476
-		$alt = wp_unslash( $changes['alt'] );
2477
-		if ( $alt != get_post_meta( $id, '_wp_attachment_image_alt', true ) ) {
2478
-			$alt = wp_strip_all_tags( $alt, true );
2479
-			update_post_meta( $id, '_wp_attachment_image_alt', wp_slash( $alt ) );
2475
+	if (isset($changes['alt'])) {
2476
+		$alt = wp_unslash($changes['alt']);
2477
+		if ($alt != get_post_meta($id, '_wp_attachment_image_alt', true)) {
2478
+			$alt = wp_strip_all_tags($alt, true);
2479
+			update_post_meta($id, '_wp_attachment_image_alt', wp_slash($alt));
2480 2480
 		}
2481 2481
 	}
2482 2482
 
2483
-	if ( wp_attachment_is( 'audio', $post['ID'] ) ) {
2483
+	if (wp_attachment_is('audio', $post['ID'])) {
2484 2484
 		$changed = false;
2485
-		$id3data = wp_get_attachment_metadata( $post['ID'] );
2486
-		if ( ! is_array( $id3data ) ) {
2485
+		$id3data = wp_get_attachment_metadata($post['ID']);
2486
+		if ( ! is_array($id3data)) {
2487 2487
 			$changed = true;
2488 2488
 			$id3data = array();
2489 2489
 		}
2490
-		foreach ( wp_get_attachment_id3_keys( (object) $post, 'edit' ) as $key => $label ) {
2491
-			if ( isset( $changes[ $key ] ) ) {
2490
+		foreach (wp_get_attachment_id3_keys((object) $post, 'edit') as $key => $label) {
2491
+			if (isset($changes[$key])) {
2492 2492
 				$changed = true;
2493
-				$id3data[ $key ] = sanitize_text_field( wp_unslash( $changes[ $key ] ) );
2493
+				$id3data[$key] = sanitize_text_field(wp_unslash($changes[$key]));
2494 2494
 			}
2495 2495
 		}
2496 2496
 
2497
-		if ( $changed ) {
2498
-			wp_update_attachment_metadata( $id, $id3data );
2497
+		if ($changed) {
2498
+			wp_update_attachment_metadata($id, $id3data);
2499 2499
 		}
2500 2500
 	}
2501 2501
 
2502
-	if ( MEDIA_TRASH && isset( $changes['status'] ) && 'trash' === $changes['status'] ) {
2503
-		wp_delete_post( $id );
2502
+	if (MEDIA_TRASH && isset($changes['status']) && 'trash' === $changes['status']) {
2503
+		wp_delete_post($id);
2504 2504
 	} else {
2505
-		wp_update_post( $post );
2505
+		wp_update_post($post);
2506 2506
 	}
2507 2507
 
2508 2508
 	wp_send_json_success();
@@ -2514,45 +2514,45 @@  discard block
 block discarded – undo
2514 2514
  * @since 3.5.0
2515 2515
  */
2516 2516
 function wp_ajax_save_attachment_compat() {
2517
-	if ( ! isset( $_REQUEST['id'] ) )
2517
+	if ( ! isset($_REQUEST['id']))
2518 2518
 		wp_send_json_error();
2519 2519
 
2520
-	if ( ! $id = absint( $_REQUEST['id'] ) )
2520
+	if ( ! $id = absint($_REQUEST['id']))
2521 2521
 		wp_send_json_error();
2522 2522
 
2523
-	if ( empty( $_REQUEST['attachments'] ) || empty( $_REQUEST['attachments'][ $id ] ) )
2523
+	if (empty($_REQUEST['attachments']) || empty($_REQUEST['attachments'][$id]))
2524 2524
 		wp_send_json_error();
2525
-	$attachment_data = $_REQUEST['attachments'][ $id ];
2525
+	$attachment_data = $_REQUEST['attachments'][$id];
2526 2526
 
2527
-	check_ajax_referer( 'update-post_' . $id, 'nonce' );
2527
+	check_ajax_referer('update-post_'.$id, 'nonce');
2528 2528
 
2529
-	if ( ! current_user_can( 'edit_post', $id ) )
2529
+	if ( ! current_user_can('edit_post', $id))
2530 2530
 		wp_send_json_error();
2531 2531
 
2532
-	$post = get_post( $id, ARRAY_A );
2532
+	$post = get_post($id, ARRAY_A);
2533 2533
 
2534
-	if ( 'attachment' != $post['post_type'] )
2534
+	if ('attachment' != $post['post_type'])
2535 2535
 		wp_send_json_error();
2536 2536
 
2537 2537
 	/** This filter is documented in wp-admin/includes/media.php */
2538
-	$post = apply_filters( 'attachment_fields_to_save', $post, $attachment_data );
2538
+	$post = apply_filters('attachment_fields_to_save', $post, $attachment_data);
2539 2539
 
2540
-	if ( isset( $post['errors'] ) ) {
2540
+	if (isset($post['errors'])) {
2541 2541
 		$errors = $post['errors']; // @todo return me and display me!
2542
-		unset( $post['errors'] );
2542
+		unset($post['errors']);
2543 2543
 	}
2544 2544
 
2545
-	wp_update_post( $post );
2545
+	wp_update_post($post);
2546 2546
 
2547
-	foreach ( get_attachment_taxonomies( $post ) as $taxonomy ) {
2548
-		if ( isset( $attachment_data[ $taxonomy ] ) )
2549
-			wp_set_object_terms( $id, array_map( 'trim', preg_split( '/,+/', $attachment_data[ $taxonomy ] ) ), $taxonomy, false );
2547
+	foreach (get_attachment_taxonomies($post) as $taxonomy) {
2548
+		if (isset($attachment_data[$taxonomy]))
2549
+			wp_set_object_terms($id, array_map('trim', preg_split('/,+/', $attachment_data[$taxonomy])), $taxonomy, false);
2550 2550
 	}
2551 2551
 
2552
-	if ( ! $attachment = wp_prepare_attachment_for_js( $id ) )
2552
+	if ( ! $attachment = wp_prepare_attachment_for_js($id))
2553 2553
 		wp_send_json_error();
2554 2554
 
2555
-	wp_send_json_success( $attachment );
2555
+	wp_send_json_success($attachment);
2556 2556
 }
2557 2557
 
2558 2558
 /**
@@ -2561,31 +2561,31 @@  discard block
 block discarded – undo
2561 2561
  * @since 3.5.0
2562 2562
  */
2563 2563
 function wp_ajax_save_attachment_order() {
2564
-	if ( ! isset( $_REQUEST['post_id'] ) )
2564
+	if ( ! isset($_REQUEST['post_id']))
2565 2565
 		wp_send_json_error();
2566 2566
 
2567
-	if ( ! $post_id = absint( $_REQUEST['post_id'] ) )
2567
+	if ( ! $post_id = absint($_REQUEST['post_id']))
2568 2568
 		wp_send_json_error();
2569 2569
 
2570
-	if ( empty( $_REQUEST['attachments'] ) )
2570
+	if (empty($_REQUEST['attachments']))
2571 2571
 		wp_send_json_error();
2572 2572
 
2573
-	check_ajax_referer( 'update-post_' . $post_id, 'nonce' );
2573
+	check_ajax_referer('update-post_'.$post_id, 'nonce');
2574 2574
 
2575 2575
 	$attachments = $_REQUEST['attachments'];
2576 2576
 
2577
-	if ( ! current_user_can( 'edit_post', $post_id ) )
2577
+	if ( ! current_user_can('edit_post', $post_id))
2578 2578
 		wp_send_json_error();
2579 2579
 
2580
-	foreach ( $attachments as $attachment_id => $menu_order ) {
2581
-		if ( ! current_user_can( 'edit_post', $attachment_id ) )
2580
+	foreach ($attachments as $attachment_id => $menu_order) {
2581
+		if ( ! current_user_can('edit_post', $attachment_id))
2582 2582
 			continue;
2583
-		if ( ! $attachment = get_post( $attachment_id ) )
2583
+		if ( ! $attachment = get_post($attachment_id))
2584 2584
 			continue;
2585
-		if ( 'attachment' != $attachment->post_type )
2585
+		if ('attachment' != $attachment->post_type)
2586 2586
 			continue;
2587 2587
 
2588
-		wp_update_post( array( 'ID' => $attachment_id, 'menu_order' => $menu_order ) );
2588
+		wp_update_post(array('ID' => $attachment_id, 'menu_order' => $menu_order));
2589 2589
 	}
2590 2590
 
2591 2591
 	wp_send_json_success();
@@ -2601,58 +2601,58 @@  discard block
 block discarded – undo
2601 2601
  * @since 3.5.0
2602 2602
  */
2603 2603
 function wp_ajax_send_attachment_to_editor() {
2604
-	check_ajax_referer( 'media-send-to-editor', 'nonce' );
2604
+	check_ajax_referer('media-send-to-editor', 'nonce');
2605 2605
 
2606
-	$attachment = wp_unslash( $_POST['attachment'] );
2606
+	$attachment = wp_unslash($_POST['attachment']);
2607 2607
 
2608
-	$id = intval( $attachment['id'] );
2608
+	$id = intval($attachment['id']);
2609 2609
 
2610
-	if ( ! $post = get_post( $id ) )
2610
+	if ( ! $post = get_post($id))
2611 2611
 		wp_send_json_error();
2612 2612
 
2613
-	if ( 'attachment' != $post->post_type )
2613
+	if ('attachment' != $post->post_type)
2614 2614
 		wp_send_json_error();
2615 2615
 
2616
-	if ( current_user_can( 'edit_post', $id ) ) {
2616
+	if (current_user_can('edit_post', $id)) {
2617 2617
 		// If this attachment is unattached, attach it. Primarily a back compat thing.
2618
-		if ( 0 == $post->post_parent && $insert_into_post_id = intval( $_POST['post_id'] ) ) {
2619
-			wp_update_post( array( 'ID' => $id, 'post_parent' => $insert_into_post_id ) );
2618
+		if (0 == $post->post_parent && $insert_into_post_id = intval($_POST['post_id'])) {
2619
+			wp_update_post(array('ID' => $id, 'post_parent' => $insert_into_post_id));
2620 2620
 		}
2621 2621
 	}
2622 2622
 
2623
-	$url = empty( $attachment['url'] ) ? '' : $attachment['url'];
2624
-	$rel = ( strpos( $url, 'attachment_id') || get_attachment_link( $id ) == $url );
2623
+	$url = empty($attachment['url']) ? '' : $attachment['url'];
2624
+	$rel = (strpos($url, 'attachment_id') || get_attachment_link($id) == $url);
2625 2625
 
2626
-	remove_filter( 'media_send_to_editor', 'image_media_send_to_editor' );
2626
+	remove_filter('media_send_to_editor', 'image_media_send_to_editor');
2627 2627
 
2628
-	if ( 'image' === substr( $post->post_mime_type, 0, 5 ) ) {
2629
-		$align = isset( $attachment['align'] ) ? $attachment['align'] : 'none';
2630
-		$size = isset( $attachment['image-size'] ) ? $attachment['image-size'] : 'medium';
2631
-		$alt = isset( $attachment['image_alt'] ) ? $attachment['image_alt'] : '';
2628
+	if ('image' === substr($post->post_mime_type, 0, 5)) {
2629
+		$align = isset($attachment['align']) ? $attachment['align'] : 'none';
2630
+		$size = isset($attachment['image-size']) ? $attachment['image-size'] : 'medium';
2631
+		$alt = isset($attachment['image_alt']) ? $attachment['image_alt'] : '';
2632 2632
 
2633 2633
 		// No whitespace-only captions.
2634
-		$caption = isset( $attachment['post_excerpt'] ) ? $attachment['post_excerpt'] : '';
2635
-		if ( '' === trim( $caption ) ) {
2634
+		$caption = isset($attachment['post_excerpt']) ? $attachment['post_excerpt'] : '';
2635
+		if ('' === trim($caption)) {
2636 2636
 			$caption = '';
2637 2637
 		}
2638 2638
 
2639 2639
 		$title = ''; // We no longer insert title tags into <img> tags, as they are redundant.
2640
-		$html = get_image_send_to_editor( $id, $caption, $title, $align, $url, $rel, $size, $alt );
2641
-	} elseif ( wp_attachment_is( 'video', $post ) || wp_attachment_is( 'audio', $post )  ) {
2642
-		$html = stripslashes_deep( $_POST['html'] );
2640
+		$html = get_image_send_to_editor($id, $caption, $title, $align, $url, $rel, $size, $alt);
2641
+	} elseif (wp_attachment_is('video', $post) || wp_attachment_is('audio', $post)) {
2642
+		$html = stripslashes_deep($_POST['html']);
2643 2643
 	} else {
2644
-		$html = isset( $attachment['post_title'] ) ? $attachment['post_title'] : '';
2645
-		$rel = $rel ? ' rel="attachment wp-att-' . $id . '"' : ''; // Hard-coded string, $id is already sanitized
2644
+		$html = isset($attachment['post_title']) ? $attachment['post_title'] : '';
2645
+		$rel = $rel ? ' rel="attachment wp-att-'.$id.'"' : ''; // Hard-coded string, $id is already sanitized
2646 2646
 
2647
-		if ( ! empty( $url ) ) {
2648
-			$html = '<a href="' . esc_url( $url ) . '"' . $rel . '>' . $html . '</a>';
2647
+		if ( ! empty($url)) {
2648
+			$html = '<a href="'.esc_url($url).'"'.$rel.'>'.$html.'</a>';
2649 2649
 		}
2650 2650
 	}
2651 2651
 
2652 2652
 	/** This filter is documented in wp-admin/includes/media.php */
2653
-	$html = apply_filters( 'media_send_to_editor', $html, $id, $attachment );
2653
+	$html = apply_filters('media_send_to_editor', $html, $id, $attachment);
2654 2654
 
2655
-	wp_send_json_success( $html );
2655
+	wp_send_json_success($html);
2656 2656
 }
2657 2657
 
2658 2658
 /**
@@ -2673,47 +2673,47 @@  discard block
 block discarded – undo
2673 2673
 function wp_ajax_send_link_to_editor() {
2674 2674
 	global $post, $wp_embed;
2675 2675
 
2676
-	check_ajax_referer( 'media-send-to-editor', 'nonce' );
2676
+	check_ajax_referer('media-send-to-editor', 'nonce');
2677 2677
 
2678
-	if ( ! $src = wp_unslash( $_POST['src'] ) )
2678
+	if ( ! $src = wp_unslash($_POST['src']))
2679 2679
 		wp_send_json_error();
2680 2680
 
2681
-	if ( ! strpos( $src, '://' ) )
2682
-		$src = 'http://' . $src;
2681
+	if ( ! strpos($src, '://'))
2682
+		$src = 'http://'.$src;
2683 2683
 
2684
-	if ( ! $src = esc_url_raw( $src ) )
2684
+	if ( ! $src = esc_url_raw($src))
2685 2685
 		wp_send_json_error();
2686 2686
 
2687
-	if ( ! $link_text = trim( wp_unslash( $_POST['link_text'] ) ) )
2688
-		$link_text = wp_basename( $src );
2687
+	if ( ! $link_text = trim(wp_unslash($_POST['link_text'])))
2688
+		$link_text = wp_basename($src);
2689 2689
 
2690
-	$post = get_post( isset( $_POST['post_id'] ) ? $_POST['post_id'] : 0 );
2690
+	$post = get_post(isset($_POST['post_id']) ? $_POST['post_id'] : 0);
2691 2691
 
2692 2692
 	// Ping WordPress for an embed.
2693
-	$check_embed = $wp_embed->run_shortcode( '[embed]'. $src .'[/embed]' );
2693
+	$check_embed = $wp_embed->run_shortcode('[embed]'.$src.'[/embed]');
2694 2694
 
2695 2695
 	// Fallback that WordPress creates when no oEmbed was found.
2696
-	$fallback = $wp_embed->maybe_make_link( $src );
2696
+	$fallback = $wp_embed->maybe_make_link($src);
2697 2697
 
2698
-	if ( $check_embed !== $fallback ) {
2698
+	if ($check_embed !== $fallback) {
2699 2699
 		// TinyMCE view for [embed] will parse this
2700
-		$html = '[embed]' . $src . '[/embed]';
2701
-	} elseif ( $link_text ) {
2702
-		$html = '<a href="' . esc_url( $src ) . '">' . $link_text . '</a>';
2700
+		$html = '[embed]'.$src.'[/embed]';
2701
+	} elseif ($link_text) {
2702
+		$html = '<a href="'.esc_url($src).'">'.$link_text.'</a>';
2703 2703
 	} else {
2704 2704
 		$html = '';
2705 2705
 	}
2706 2706
 
2707 2707
 	// Figure out what filter to run:
2708 2708
 	$type = 'file';
2709
-	if ( ( $ext = preg_replace( '/^.+?\.([^.]+)$/', '$1', $src ) ) && ( $ext_type = wp_ext2type( $ext ) )
2710
-		&& ( 'audio' == $ext_type || 'video' == $ext_type ) )
2709
+	if (($ext = preg_replace('/^.+?\.([^.]+)$/', '$1', $src)) && ($ext_type = wp_ext2type($ext))
2710
+		&& ('audio' == $ext_type || 'video' == $ext_type))
2711 2711
 			$type = $ext_type;
2712 2712
 
2713 2713
 	/** This filter is documented in wp-admin/includes/media.php */
2714
-	$html = apply_filters( $type . '_send_to_editor_url', $html, $src, $link_text );
2714
+	$html = apply_filters($type.'_send_to_editor_url', $html, $src, $link_text);
2715 2715
 
2716
-	wp_send_json_success( $html );
2716
+	wp_send_json_success($html);
2717 2717
 }
2718 2718
 
2719 2719
 /**
@@ -2724,35 +2724,35 @@  discard block
 block discarded – undo
2724 2724
  * @since 3.6.0
2725 2725
  */
2726 2726
 function wp_ajax_heartbeat() {
2727
-	if ( empty( $_POST['_nonce'] ) ) {
2727
+	if (empty($_POST['_nonce'])) {
2728 2728
 		wp_send_json_error();
2729 2729
 	}
2730 2730
 
2731 2731
 	$response = $data = array();
2732
-	$nonce_state = wp_verify_nonce( $_POST['_nonce'], 'heartbeat-nonce' );
2732
+	$nonce_state = wp_verify_nonce($_POST['_nonce'], 'heartbeat-nonce');
2733 2733
 
2734 2734
 	// screen_id is the same as $current_screen->id and the JS global 'pagenow'.
2735
-	if ( ! empty( $_POST['screen_id'] ) ) {
2735
+	if ( ! empty($_POST['screen_id'])) {
2736 2736
 		$screen_id = sanitize_key($_POST['screen_id']);
2737 2737
 	} else {
2738 2738
 		$screen_id = 'front';
2739 2739
 	}
2740 2740
 
2741
-	if ( ! empty( $_POST['data'] ) ) {
2742
-		$data = wp_unslash( (array) $_POST['data'] );
2741
+	if ( ! empty($_POST['data'])) {
2742
+		$data = wp_unslash((array) $_POST['data']);
2743 2743
 	}
2744 2744
 
2745
-	if ( 1 !== $nonce_state ) {
2746
-		$response = apply_filters( 'wp_refresh_nonces', $response, $data, $screen_id );
2745
+	if (1 !== $nonce_state) {
2746
+		$response = apply_filters('wp_refresh_nonces', $response, $data, $screen_id);
2747 2747
 
2748
-		if ( false === $nonce_state ) {
2748
+		if (false === $nonce_state) {
2749 2749
 			// User is logged in but nonces have expired.
2750 2750
 			$response['nonces_expired'] = true;
2751
-			wp_send_json( $response );
2751
+			wp_send_json($response);
2752 2752
 		}
2753 2753
 	}
2754 2754
 
2755
-	if ( ! empty( $data ) ) {
2755
+	if ( ! empty($data)) {
2756 2756
 		/**
2757 2757
 		 * Filters the Heartbeat response received.
2758 2758
 		 *
@@ -2762,7 +2762,7 @@  discard block
 block discarded – undo
2762 2762
 		 * @param array  $data      The $_POST data sent.
2763 2763
 		 * @param string $screen_id The screen id.
2764 2764
 		 */
2765
-		$response = apply_filters( 'heartbeat_received', $response, $data, $screen_id );
2765
+		$response = apply_filters('heartbeat_received', $response, $data, $screen_id);
2766 2766
 	}
2767 2767
 
2768 2768
 	/**
@@ -2773,7 +2773,7 @@  discard block
 block discarded – undo
2773 2773
 	 * @param array  $response  The Heartbeat response.
2774 2774
 	 * @param string $screen_id The screen id.
2775 2775
 	 */
2776
-	$response = apply_filters( 'heartbeat_send', $response, $screen_id );
2776
+	$response = apply_filters('heartbeat_send', $response, $screen_id);
2777 2777
 
2778 2778
 	/**
2779 2779
 	 * Fires when Heartbeat ticks in logged-in environments.
@@ -2785,12 +2785,12 @@  discard block
 block discarded – undo
2785 2785
 	 * @param array  $response  The Heartbeat response.
2786 2786
 	 * @param string $screen_id The screen id.
2787 2787
 	 */
2788
-	do_action( 'heartbeat_tick', $response, $screen_id );
2788
+	do_action('heartbeat_tick', $response, $screen_id);
2789 2789
 
2790 2790
 	// Send the current time according to the server
2791 2791
 	$response['server_time'] = time();
2792 2792
 
2793
-	wp_send_json( $response );
2793
+	wp_send_json($response);
2794 2794
 }
2795 2795
 
2796 2796
 /**
@@ -2799,30 +2799,30 @@  discard block
 block discarded – undo
2799 2799
  * @since 3.6.0
2800 2800
  */
2801 2801
 function wp_ajax_get_revision_diffs() {
2802
-	require ABSPATH . 'wp-admin/includes/revision.php';
2802
+	require ABSPATH.'wp-admin/includes/revision.php';
2803 2803
 
2804
-	if ( ! $post = get_post( (int) $_REQUEST['post_id'] ) )
2804
+	if ( ! $post = get_post((int) $_REQUEST['post_id']))
2805 2805
 		wp_send_json_error();
2806 2806
 
2807
-	if ( ! current_user_can( 'edit_post', $post->ID ) )
2807
+	if ( ! current_user_can('edit_post', $post->ID))
2808 2808
 		wp_send_json_error();
2809 2809
 
2810 2810
 	// Really just pre-loading the cache here.
2811
-	if ( ! $revisions = wp_get_post_revisions( $post->ID, array( 'check_enabled' => false ) ) )
2811
+	if ( ! $revisions = wp_get_post_revisions($post->ID, array('check_enabled' => false)))
2812 2812
 		wp_send_json_error();
2813 2813
 
2814 2814
 	$return = array();
2815
-	@set_time_limit( 0 );
2815
+	@set_time_limit(0);
2816 2816
 
2817
-	foreach ( $_REQUEST['compare'] as $compare_key ) {
2818
-		list( $compare_from, $compare_to ) = explode( ':', $compare_key ); // from:to
2817
+	foreach ($_REQUEST['compare'] as $compare_key) {
2818
+		list($compare_from, $compare_to) = explode(':', $compare_key); // from:to
2819 2819
 
2820 2820
 		$return[] = array(
2821 2821
 			'id' => $compare_key,
2822
-			'fields' => wp_get_revision_ui_diff( $post, $compare_from, $compare_to ),
2822
+			'fields' => wp_get_revision_ui_diff($post, $compare_from, $compare_to),
2823 2823
 		);
2824 2824
 	}
2825
-	wp_send_json_success( $return );
2825
+	wp_send_json_success($return);
2826 2826
 }
2827 2827
 
2828 2828
 /**
@@ -2836,21 +2836,21 @@  discard block
 block discarded – undo
2836 2836
 function wp_ajax_save_user_color_scheme() {
2837 2837
 	global $_wp_admin_css_colors;
2838 2838
 
2839
-	check_ajax_referer( 'save-color-scheme', 'nonce' );
2839
+	check_ajax_referer('save-color-scheme', 'nonce');
2840 2840
 
2841
-	$color_scheme = sanitize_key( $_POST['color_scheme'] );
2841
+	$color_scheme = sanitize_key($_POST['color_scheme']);
2842 2842
 
2843
-	if ( ! isset( $_wp_admin_css_colors[ $color_scheme ] ) ) {
2843
+	if ( ! isset($_wp_admin_css_colors[$color_scheme])) {
2844 2844
 		wp_send_json_error();
2845 2845
 	}
2846 2846
 
2847
-	$previous_color_scheme = get_user_meta( get_current_user_id(), 'admin_color', true );
2848
-	update_user_meta( get_current_user_id(), 'admin_color', $color_scheme );
2847
+	$previous_color_scheme = get_user_meta(get_current_user_id(), 'admin_color', true);
2848
+	update_user_meta(get_current_user_id(), 'admin_color', $color_scheme);
2849 2849
 
2850
-	wp_send_json_success( array(
2851
-		'previousScheme' => 'admin-color-' . $previous_color_scheme,
2852
-		'currentScheme'  => 'admin-color-' . $color_scheme
2853
-	) );
2850
+	wp_send_json_success(array(
2851
+		'previousScheme' => 'admin-color-'.$previous_color_scheme,
2852
+		'currentScheme'  => 'admin-color-'.$color_scheme
2853
+	));
2854 2854
 }
2855 2855
 
2856 2856
 /**
@@ -2864,72 +2864,72 @@  discard block
 block discarded – undo
2864 2864
 function wp_ajax_query_themes() {
2865 2865
 	global $themes_allowedtags, $theme_field_defaults;
2866 2866
 
2867
-	if ( ! current_user_can( 'install_themes' ) ) {
2867
+	if ( ! current_user_can('install_themes')) {
2868 2868
 		wp_send_json_error();
2869 2869
 	}
2870 2870
 
2871
-	$args = wp_parse_args( wp_unslash( $_REQUEST['request'] ), array(
2871
+	$args = wp_parse_args(wp_unslash($_REQUEST['request']), array(
2872 2872
 		'per_page' => 20,
2873 2873
 		'fields'   => $theme_field_defaults
2874
-	) );
2874
+	));
2875 2875
 
2876
-	if ( isset( $args['browse'] ) && 'favorites' === $args['browse'] && ! isset( $args['user'] ) ) {
2877
-		$user = get_user_option( 'wporg_favorites' );
2878
-		if ( $user ) {
2876
+	if (isset($args['browse']) && 'favorites' === $args['browse'] && ! isset($args['user'])) {
2877
+		$user = get_user_option('wporg_favorites');
2878
+		if ($user) {
2879 2879
 			$args['user'] = $user;
2880 2880
 		}
2881 2881
 	}
2882 2882
 
2883
-	$old_filter = isset( $args['browse'] ) ? $args['browse'] : 'search';
2883
+	$old_filter = isset($args['browse']) ? $args['browse'] : 'search';
2884 2884
 
2885 2885
 	/** This filter is documented in wp-admin/includes/class-wp-theme-install-list-table.php */
2886
-	$args = apply_filters( 'install_themes_table_api_args_' . $old_filter, $args );
2886
+	$args = apply_filters('install_themes_table_api_args_'.$old_filter, $args);
2887 2887
 
2888
-	$api = themes_api( 'query_themes', $args );
2888
+	$api = themes_api('query_themes', $args);
2889 2889
 
2890
-	if ( is_wp_error( $api ) ) {
2890
+	if (is_wp_error($api)) {
2891 2891
 		wp_send_json_error();
2892 2892
 	}
2893 2893
 
2894
-	$update_php = network_admin_url( 'update.php?action=install-theme' );
2895
-	foreach ( $api->themes as &$theme ) {
2896
-		$theme->install_url = add_query_arg( array(
2894
+	$update_php = network_admin_url('update.php?action=install-theme');
2895
+	foreach ($api->themes as &$theme) {
2896
+		$theme->install_url = add_query_arg(array(
2897 2897
 			'theme'    => $theme->slug,
2898
-			'_wpnonce' => wp_create_nonce( 'install-theme_' . $theme->slug )
2899
-		), $update_php );
2898
+			'_wpnonce' => wp_create_nonce('install-theme_'.$theme->slug)
2899
+		), $update_php);
2900 2900
 
2901
-		if ( current_user_can( 'switch_themes' ) ) {
2902
-			if ( is_multisite() ) {
2903
-				$theme->activate_url = add_query_arg( array(
2901
+		if (current_user_can('switch_themes')) {
2902
+			if (is_multisite()) {
2903
+				$theme->activate_url = add_query_arg(array(
2904 2904
 					'action'   => 'enable',
2905
-					'_wpnonce' => wp_create_nonce( 'enable-theme_' . $theme->slug ),
2905
+					'_wpnonce' => wp_create_nonce('enable-theme_'.$theme->slug),
2906 2906
 					'theme'    => $theme->slug,
2907
-				), network_admin_url( 'themes.php' ) );
2907
+				), network_admin_url('themes.php'));
2908 2908
 			} else {
2909
-				$theme->activate_url = add_query_arg( array(
2909
+				$theme->activate_url = add_query_arg(array(
2910 2910
 					'action'     => 'activate',
2911
-					'_wpnonce'   => wp_create_nonce( 'switch-theme_' . $theme->slug ),
2911
+					'_wpnonce'   => wp_create_nonce('switch-theme_'.$theme->slug),
2912 2912
 					'stylesheet' => $theme->slug,
2913
-				), admin_url( 'themes.php' ) );
2913
+				), admin_url('themes.php'));
2914 2914
 			}
2915 2915
 		}
2916 2916
 
2917
-		if ( ! is_multisite() && current_user_can( 'edit_theme_options' ) && current_user_can( 'customize' ) ) {
2918
-			$theme->customize_url = add_query_arg( array(
2919
-				'return' => urlencode( network_admin_url( 'theme-install.php', 'relative' ) ),
2920
-			), wp_customize_url( $theme->slug ) );
2917
+		if ( ! is_multisite() && current_user_can('edit_theme_options') && current_user_can('customize')) {
2918
+			$theme->customize_url = add_query_arg(array(
2919
+				'return' => urlencode(network_admin_url('theme-install.php', 'relative')),
2920
+			), wp_customize_url($theme->slug));
2921 2921
 		}
2922 2922
 
2923
-		$theme->name        = wp_kses( $theme->name, $themes_allowedtags );
2924
-		$theme->author      = wp_kses( $theme->author, $themes_allowedtags );
2925
-		$theme->version     = wp_kses( $theme->version, $themes_allowedtags );
2926
-		$theme->description = wp_kses( $theme->description, $themes_allowedtags );
2927
-		$theme->stars       = wp_star_rating( array( 'rating' => $theme->rating, 'type' => 'percent', 'number' => $theme->num_ratings, 'echo' => false ) );
2928
-		$theme->num_ratings = number_format_i18n( $theme->num_ratings );
2929
-		$theme->preview_url = set_url_scheme( $theme->preview_url );
2923
+		$theme->name        = wp_kses($theme->name, $themes_allowedtags);
2924
+		$theme->author      = wp_kses($theme->author, $themes_allowedtags);
2925
+		$theme->version     = wp_kses($theme->version, $themes_allowedtags);
2926
+		$theme->description = wp_kses($theme->description, $themes_allowedtags);
2927
+		$theme->stars       = wp_star_rating(array('rating' => $theme->rating, 'type' => 'percent', 'number' => $theme->num_ratings, 'echo' => false));
2928
+		$theme->num_ratings = number_format_i18n($theme->num_ratings);
2929
+		$theme->preview_url = set_url_scheme($theme->preview_url);
2930 2930
 	}
2931 2931
 
2932
-	wp_send_json_success( $api );
2932
+	wp_send_json_success($api);
2933 2933
 }
2934 2934
 
2935 2935
 /**
@@ -2944,87 +2944,87 @@  discard block
 block discarded – undo
2944 2944
 function wp_ajax_parse_embed() {
2945 2945
 	global $post, $wp_embed;
2946 2946
 
2947
-	if ( ! $post = get_post( (int) $_POST['post_ID'] ) ) {
2947
+	if ( ! $post = get_post((int) $_POST['post_ID'])) {
2948 2948
 		wp_send_json_error();
2949 2949
 	}
2950 2950
 
2951
-	if ( empty( $_POST['shortcode'] ) || ! current_user_can( 'edit_post', $post->ID ) ) {
2951
+	if (empty($_POST['shortcode']) || ! current_user_can('edit_post', $post->ID)) {
2952 2952
 		wp_send_json_error();
2953 2953
 	}
2954 2954
 
2955
-	$shortcode = wp_unslash( $_POST['shortcode'] );
2955
+	$shortcode = wp_unslash($_POST['shortcode']);
2956 2956
 
2957
-	preg_match( '/' . get_shortcode_regex() . '/s', $shortcode, $matches );
2958
-	$atts = shortcode_parse_atts( $matches[3] );
2959
-	if ( ! empty( $matches[5] ) ) {
2957
+	preg_match('/'.get_shortcode_regex().'/s', $shortcode, $matches);
2958
+	$atts = shortcode_parse_atts($matches[3]);
2959
+	if ( ! empty($matches[5])) {
2960 2960
 		$url = $matches[5];
2961
-	} elseif ( ! empty( $atts['src'] ) ) {
2961
+	} elseif ( ! empty($atts['src'])) {
2962 2962
 		$url = $atts['src'];
2963 2963
 	} else {
2964 2964
 		$url = '';
2965 2965
 	}
2966 2966
 
2967 2967
 	$parsed = false;
2968
-	setup_postdata( $post );
2968
+	setup_postdata($post);
2969 2969
 
2970 2970
 	$wp_embed->return_false_on_fail = true;
2971 2971
 
2972
-	if ( is_ssl() && 0 === strpos( $url, 'http://' ) ) {
2972
+	if (is_ssl() && 0 === strpos($url, 'http://')) {
2973 2973
 		// Admin is ssl and the user pasted non-ssl URL.
2974 2974
 		// Check if the provider supports ssl embeds and use that for the preview.
2975
-		$ssl_shortcode = preg_replace( '%^(\\[embed[^\\]]*\\])http://%i', '$1https://', $shortcode );
2976
-		$parsed = $wp_embed->run_shortcode( $ssl_shortcode );
2975
+		$ssl_shortcode = preg_replace('%^(\\[embed[^\\]]*\\])http://%i', '$1https://', $shortcode);
2976
+		$parsed = $wp_embed->run_shortcode($ssl_shortcode);
2977 2977
 
2978
-		if ( ! $parsed ) {
2978
+		if ( ! $parsed) {
2979 2979
 			$no_ssl_support = true;
2980 2980
 		}
2981 2981
 	}
2982 2982
 
2983
-	if ( $url && ! $parsed ) {
2984
-		$parsed = $wp_embed->run_shortcode( $shortcode );
2983
+	if ($url && ! $parsed) {
2984
+		$parsed = $wp_embed->run_shortcode($shortcode);
2985 2985
 	}
2986 2986
 
2987
-	if ( ! $parsed ) {
2988
-		wp_send_json_error( array(
2987
+	if ( ! $parsed) {
2988
+		wp_send_json_error(array(
2989 2989
 			'type' => 'not-embeddable',
2990
-			'message' => sprintf( __( '%s failed to embed.' ), '<code>' . esc_html( $url ) . '</code>' ),
2991
-		) );
2990
+			'message' => sprintf(__('%s failed to embed.'), '<code>'.esc_html($url).'</code>'),
2991
+		));
2992 2992
 	}
2993 2993
 
2994
-	if ( has_shortcode( $parsed, 'audio' ) || has_shortcode( $parsed, 'video' ) ) {
2994
+	if (has_shortcode($parsed, 'audio') || has_shortcode($parsed, 'video')) {
2995 2995
 		$styles = '';
2996 2996
 		$mce_styles = wpview_media_sandbox_styles();
2997
-		foreach ( $mce_styles as $style ) {
2998
-			$styles .= sprintf( '<link rel="stylesheet" href="%s"/>', $style );
2997
+		foreach ($mce_styles as $style) {
2998
+			$styles .= sprintf('<link rel="stylesheet" href="%s"/>', $style);
2999 2999
 		}
3000 3000
 
3001
-		$html = do_shortcode( $parsed );
3001
+		$html = do_shortcode($parsed);
3002 3002
 
3003 3003
 		global $wp_scripts;
3004
-		if ( ! empty( $wp_scripts ) ) {
3004
+		if ( ! empty($wp_scripts)) {
3005 3005
 			$wp_scripts->done = array();
3006 3006
 		}
3007 3007
 		ob_start();
3008
-		wp_print_scripts( 'wp-mediaelement' );
3008
+		wp_print_scripts('wp-mediaelement');
3009 3009
 		$scripts = ob_get_clean();
3010 3010
 
3011
-		$parsed = $styles . $html . $scripts;
3011
+		$parsed = $styles.$html.$scripts;
3012 3012
 	}
3013 3013
 
3014 3014
 
3015
-	if ( ! empty( $no_ssl_support ) || ( is_ssl() && ( preg_match( '%<(iframe|script|embed) [^>]*src="http://%', $parsed ) ||
3016
-		preg_match( '%<link [^>]*href="http://%', $parsed ) ) ) ) {
3015
+	if ( ! empty($no_ssl_support) || (is_ssl() && (preg_match('%<(iframe|script|embed) [^>]*src="http://%', $parsed) ||
3016
+		preg_match('%<link [^>]*href="http://%', $parsed)))) {
3017 3017
 		// Admin is ssl and the embed is not. Iframes, scripts, and other "active content" will be blocked.
3018
-		wp_send_json_error( array(
3018
+		wp_send_json_error(array(
3019 3019
 			'type' => 'not-ssl',
3020
-			'message' => __( 'This preview is unavailable in the editor.' ),
3021
-		) );
3020
+			'message' => __('This preview is unavailable in the editor.'),
3021
+		));
3022 3022
 	}
3023 3023
 
3024
-	wp_send_json_success( array(
3024
+	wp_send_json_success(array(
3025 3025
 		'body' => $parsed,
3026 3026
 		'attr' => $wp_embed->last_attr
3027
-	) );
3027
+	));
3028 3028
 }
3029 3029
 
3030 3030
 /**
@@ -3036,42 +3036,42 @@  discard block
 block discarded – undo
3036 3036
 function wp_ajax_parse_media_shortcode() {
3037 3037
 	global $post, $wp_scripts;
3038 3038
 
3039
-	if ( empty( $_POST['shortcode'] ) ) {
3039
+	if (empty($_POST['shortcode'])) {
3040 3040
 		wp_send_json_error();
3041 3041
 	}
3042 3042
 
3043
-	$shortcode = wp_unslash( $_POST['shortcode'] );
3043
+	$shortcode = wp_unslash($_POST['shortcode']);
3044 3044
 
3045
-	if ( ! empty( $_POST['post_ID'] ) ) {
3046
-		$post = get_post( (int) $_POST['post_ID'] );
3045
+	if ( ! empty($_POST['post_ID'])) {
3046
+		$post = get_post((int) $_POST['post_ID']);
3047 3047
 	}
3048 3048
 
3049 3049
 	// the embed shortcode requires a post
3050
-	if ( ! $post || ! current_user_can( 'edit_post', $post->ID ) ) {
3051
-		if ( 'embed' === $shortcode ) {
3050
+	if ( ! $post || ! current_user_can('edit_post', $post->ID)) {
3051
+		if ('embed' === $shortcode) {
3052 3052
 			wp_send_json_error();
3053 3053
 		}
3054 3054
 	} else {
3055
-		setup_postdata( $post );
3055
+		setup_postdata($post);
3056 3056
 	}
3057 3057
 
3058
-	$parsed = do_shortcode( $shortcode  );
3058
+	$parsed = do_shortcode($shortcode);
3059 3059
 
3060
-	if ( empty( $parsed ) ) {
3061
-		wp_send_json_error( array(
3060
+	if (empty($parsed)) {
3061
+		wp_send_json_error(array(
3062 3062
 			'type' => 'no-items',
3063
-			'message' => __( 'No items found.' ),
3064
-		) );
3063
+			'message' => __('No items found.'),
3064
+		));
3065 3065
 	}
3066 3066
 
3067 3067
 	$head = '';
3068 3068
 	$styles = wpview_media_sandbox_styles();
3069 3069
 
3070
-	foreach ( $styles as $style ) {
3071
-		$head .= '<link type="text/css" rel="stylesheet" href="' . $style . '">';
3070
+	foreach ($styles as $style) {
3071
+		$head .= '<link type="text/css" rel="stylesheet" href="'.$style.'">';
3072 3072
 	}
3073 3073
 
3074
-	if ( ! empty( $wp_scripts ) ) {
3074
+	if ( ! empty($wp_scripts)) {
3075 3075
 		$wp_scripts->done = array();
3076 3076
 	}
3077 3077
 
@@ -3079,18 +3079,18 @@  discard block
 block discarded – undo
3079 3079
 
3080 3080
 	echo $parsed;
3081 3081
 
3082
-	if ( 'playlist' === $_REQUEST['type'] ) {
3082
+	if ('playlist' === $_REQUEST['type']) {
3083 3083
 		wp_underscore_playlist_templates();
3084 3084
 
3085
-		wp_print_scripts( 'wp-playlist' );
3085
+		wp_print_scripts('wp-playlist');
3086 3086
 	} else {
3087
-		wp_print_scripts( array( 'froogaloop', 'wp-mediaelement' ) );
3087
+		wp_print_scripts(array('froogaloop', 'wp-mediaelement'));
3088 3088
 	}
3089 3089
 
3090
-	wp_send_json_success( array(
3090
+	wp_send_json_success(array(
3091 3091
 		'head' => $head,
3092 3092
 		'body' => ob_get_clean()
3093
-	) );
3093
+	));
3094 3094
 }
3095 3095
 
3096 3096
 /**
@@ -3099,33 +3099,33 @@  discard block
 block discarded – undo
3099 3099
  * @since 4.1.0
3100 3100
  */
3101 3101
 function wp_ajax_destroy_sessions() {
3102
-	$user = get_userdata( (int) $_POST['user_id'] );
3103
-	if ( $user ) {
3104
-		if ( ! current_user_can( 'edit_user', $user->ID ) ) {
3102
+	$user = get_userdata((int) $_POST['user_id']);
3103
+	if ($user) {
3104
+		if ( ! current_user_can('edit_user', $user->ID)) {
3105 3105
 			$user = false;
3106
-		} elseif ( ! wp_verify_nonce( $_POST['nonce'], 'update-user_' . $user->ID ) ) {
3106
+		} elseif ( ! wp_verify_nonce($_POST['nonce'], 'update-user_'.$user->ID)) {
3107 3107
 			$user = false;
3108 3108
 		}
3109 3109
 	}
3110 3110
 
3111
-	if ( ! $user ) {
3112
-		wp_send_json_error( array(
3113
-			'message' => __( 'Could not log out user sessions. Please try again.' ),
3114
-		) );
3111
+	if ( ! $user) {
3112
+		wp_send_json_error(array(
3113
+			'message' => __('Could not log out user sessions. Please try again.'),
3114
+		));
3115 3115
 	}
3116 3116
 
3117
-	$sessions = WP_Session_Tokens::get_instance( $user->ID );
3117
+	$sessions = WP_Session_Tokens::get_instance($user->ID);
3118 3118
 
3119
-	if ( $user->ID === get_current_user_id() ) {
3120
-		$sessions->destroy_others( wp_get_session_token() );
3121
-		$message = __( 'You are now logged out everywhere else.' );
3119
+	if ($user->ID === get_current_user_id()) {
3120
+		$sessions->destroy_others(wp_get_session_token());
3121
+		$message = __('You are now logged out everywhere else.');
3122 3122
 	} else {
3123 3123
 		$sessions->destroy_all();
3124 3124
 		/* translators: 1: User's display name. */
3125
-		$message = sprintf( __( '%s has been logged out.' ), $user->display_name );
3125
+		$message = sprintf(__('%s has been logged out.'), $user->display_name);
3126 3126
 	}
3127 3127
 
3128
-	wp_send_json_success( array( 'message' => $message ) );
3128
+	wp_send_json_success(array('message' => $message));
3129 3129
 }
3130 3130
 
3131 3131
 /**
@@ -3136,8 +3136,8 @@  discard block
 block discarded – undo
3136 3136
  * @global WP_Press_This $wp_press_this
3137 3137
  */
3138 3138
 function wp_ajax_press_this_save_post() {
3139
-	if ( empty( $GLOBALS['wp_press_this'] ) ) {
3140
-		include( ABSPATH . 'wp-admin/includes/class-wp-press-this.php' );
3139
+	if (empty($GLOBALS['wp_press_this'])) {
3140
+		include(ABSPATH.'wp-admin/includes/class-wp-press-this.php');
3141 3141
 	}
3142 3142
 
3143 3143
 	$GLOBALS['wp_press_this']->save_post();
@@ -3151,8 +3151,8 @@  discard block
 block discarded – undo
3151 3151
  * @global WP_Press_This $wp_press_this
3152 3152
  */
3153 3153
 function wp_ajax_press_this_add_category() {
3154
-	if ( empty( $GLOBALS['wp_press_this'] ) ) {
3155
-		include( ABSPATH . 'wp-admin/includes/class-wp-press-this.php' );
3154
+	if (empty($GLOBALS['wp_press_this'])) {
3155
+		include(ABSPATH.'wp-admin/includes/class-wp-press-this.php');
3156 3156
 	}
3157 3157
 
3158 3158
 	$GLOBALS['wp_press_this']->add_category();
@@ -3166,49 +3166,49 @@  discard block
 block discarded – undo
3166 3166
  * @global WP_Site_Icon $wp_site_icon
3167 3167
  */
3168 3168
 function wp_ajax_crop_image() {
3169
-	$attachment_id = absint( $_POST['id'] );
3169
+	$attachment_id = absint($_POST['id']);
3170 3170
 
3171
-	check_ajax_referer( 'image_editor-' . $attachment_id, 'nonce' );
3172
-	if ( ! current_user_can( 'customize' ) ) {
3171
+	check_ajax_referer('image_editor-'.$attachment_id, 'nonce');
3172
+	if ( ! current_user_can('customize')) {
3173 3173
 		wp_send_json_error();
3174 3174
 	}
3175 3175
 
3176
-	$context = str_replace( '_', '-', $_POST['context'] );
3177
-	$data    = array_map( 'absint', $_POST['cropDetails'] );
3178
-	$cropped = wp_crop_image( $attachment_id, $data['x1'], $data['y1'], $data['width'], $data['height'], $data['dst_width'], $data['dst_height'] );
3176
+	$context = str_replace('_', '-', $_POST['context']);
3177
+	$data    = array_map('absint', $_POST['cropDetails']);
3178
+	$cropped = wp_crop_image($attachment_id, $data['x1'], $data['y1'], $data['width'], $data['height'], $data['dst_width'], $data['dst_height']);
3179 3179
 
3180
-	if ( ! $cropped || is_wp_error( $cropped ) ) {
3181
-		wp_send_json_error( array( 'message' => __( 'Image could not be processed.' ) ) );
3180
+	if ( ! $cropped || is_wp_error($cropped)) {
3181
+		wp_send_json_error(array('message' => __('Image could not be processed.')));
3182 3182
 	}
3183 3183
 
3184
-	switch ( $context ) {
3184
+	switch ($context) {
3185 3185
 		case 'site-icon':
3186
-			require_once ABSPATH . '/wp-admin/includes/class-wp-site-icon.php';
3186
+			require_once ABSPATH.'/wp-admin/includes/class-wp-site-icon.php';
3187 3187
 			global $wp_site_icon;
3188 3188
 
3189 3189
 			// Skip creating a new attachment if the attachment is a Site Icon.
3190
-			if ( get_post_meta( $attachment_id, '_wp_attachment_context', true ) == $context ) {
3190
+			if (get_post_meta($attachment_id, '_wp_attachment_context', true) == $context) {
3191 3191
 
3192 3192
 				// Delete the temporary cropped file, we don't need it.
3193
-				wp_delete_file( $cropped );
3193
+				wp_delete_file($cropped);
3194 3194
 
3195 3195
 				// Additional sizes in wp_prepare_attachment_for_js().
3196
-				add_filter( 'image_size_names_choose', array( $wp_site_icon, 'additional_sizes' ) );
3196
+				add_filter('image_size_names_choose', array($wp_site_icon, 'additional_sizes'));
3197 3197
 				break;
3198 3198
 			}
3199 3199
 
3200 3200
 			/** This filter is documented in wp-admin/custom-header.php */
3201
-			$cropped = apply_filters( 'wp_create_file_in_uploads', $cropped, $attachment_id ); // For replication.
3202
-			$object  = $wp_site_icon->create_attachment_object( $cropped, $attachment_id );
3203
-			unset( $object['ID'] );
3201
+			$cropped = apply_filters('wp_create_file_in_uploads', $cropped, $attachment_id); // For replication.
3202
+			$object  = $wp_site_icon->create_attachment_object($cropped, $attachment_id);
3203
+			unset($object['ID']);
3204 3204
 
3205 3205
 			// Update the attachment.
3206
-			add_filter( 'intermediate_image_sizes_advanced', array( $wp_site_icon, 'additional_sizes' ) );
3207
-			$attachment_id = $wp_site_icon->insert_attachment( $object, $cropped );
3208
-			remove_filter( 'intermediate_image_sizes_advanced', array( $wp_site_icon, 'additional_sizes' ) );
3206
+			add_filter('intermediate_image_sizes_advanced', array($wp_site_icon, 'additional_sizes'));
3207
+			$attachment_id = $wp_site_icon->insert_attachment($object, $cropped);
3208
+			remove_filter('intermediate_image_sizes_advanced', array($wp_site_icon, 'additional_sizes'));
3209 3209
 
3210 3210
 			// Additional sizes in wp_prepare_attachment_for_js().
3211
-			add_filter( 'image_size_names_choose', array( $wp_site_icon, 'additional_sizes' ) );
3211
+			add_filter('image_size_names_choose', array($wp_site_icon, 'additional_sizes'));
3212 3212
 			break;
3213 3213
 
3214 3214
 		default:
@@ -3224,27 +3224,27 @@  discard block
 block discarded – undo
3224 3224
 			 * @param int    $attachment_id The attachment ID of the original image.
3225 3225
 			 * @param string $cropped       Path to the cropped image file.
3226 3226
 			 */
3227
-			do_action( 'wp_ajax_crop_image_pre_save', $context, $attachment_id, $cropped );
3227
+			do_action('wp_ajax_crop_image_pre_save', $context, $attachment_id, $cropped);
3228 3228
 
3229 3229
 			/** This filter is documented in wp-admin/custom-header.php */
3230
-			$cropped = apply_filters( 'wp_create_file_in_uploads', $cropped, $attachment_id ); // For replication.
3230
+			$cropped = apply_filters('wp_create_file_in_uploads', $cropped, $attachment_id); // For replication.
3231 3231
 
3232
-			$parent_url = wp_get_attachment_url( $attachment_id );
3233
-			$url        = str_replace( basename( $parent_url ), basename( $cropped ), $parent_url );
3232
+			$parent_url = wp_get_attachment_url($attachment_id);
3233
+			$url        = str_replace(basename($parent_url), basename($cropped), $parent_url);
3234 3234
 
3235
-			$size       = @getimagesize( $cropped );
3236
-			$image_type = ( $size ) ? $size['mime'] : 'image/jpeg';
3235
+			$size       = @getimagesize($cropped);
3236
+			$image_type = ($size) ? $size['mime'] : 'image/jpeg';
3237 3237
 
3238 3238
 			$object = array(
3239
-				'post_title'     => basename( $cropped ),
3239
+				'post_title'     => basename($cropped),
3240 3240
 				'post_content'   => $url,
3241 3241
 				'post_mime_type' => $image_type,
3242 3242
 				'guid'           => $url,
3243 3243
 				'context'        => $context,
3244 3244
 			);
3245 3245
 
3246
-			$attachment_id = wp_insert_attachment( $object, $cropped );
3247
-			$metadata = wp_generate_attachment_metadata( $attachment_id, $cropped );
3246
+			$attachment_id = wp_insert_attachment($object, $cropped);
3247
+			$metadata = wp_generate_attachment_metadata($attachment_id, $cropped);
3248 3248
 
3249 3249
 			/**
3250 3250
 			 * Filters the cropped image attachment metadata.
@@ -3255,8 +3255,8 @@  discard block
 block discarded – undo
3255 3255
 			 *
3256 3256
 			 * @param array $metadata Attachment metadata.
3257 3257
 			 */
3258
-			$metadata = apply_filters( 'wp_ajax_cropped_attachment_metadata', $metadata );
3259
-			wp_update_attachment_metadata( $attachment_id, $metadata );
3258
+			$metadata = apply_filters('wp_ajax_cropped_attachment_metadata', $metadata);
3259
+			wp_update_attachment_metadata($attachment_id, $metadata);
3260 3260
 
3261 3261
 			/**
3262 3262
 			 * Filters the attachment ID for a cropped image.
@@ -3266,10 +3266,10 @@  discard block
 block discarded – undo
3266 3266
 			 * @param int    $attachment_id The attachment ID of the cropped image.
3267 3267
 			 * @param string $context       The Customizer control requesting the cropped image.
3268 3268
 			 */
3269
-			$attachment_id = apply_filters( 'wp_ajax_cropped_attachment_id', $attachment_id, $context );
3269
+			$attachment_id = apply_filters('wp_ajax_cropped_attachment_id', $attachment_id, $context);
3270 3270
 	}
3271 3271
 
3272
-	wp_send_json_success( wp_prepare_attachment_for_js( $attachment_id ) );
3272
+	wp_send_json_success(wp_prepare_attachment_for_js($attachment_id));
3273 3273
 }
3274 3274
 
3275 3275
 /**
@@ -3278,7 +3278,7 @@  discard block
 block discarded – undo
3278 3278
  * @since 4.4.0
3279 3279
  */
3280 3280
 function wp_ajax_generate_password() {
3281
-	wp_send_json_success( wp_generate_password( 24 ) );
3281
+	wp_send_json_success(wp_generate_password(24));
3282 3282
 }
3283 3283
 
3284 3284
 /**
@@ -3287,19 +3287,19 @@  discard block
 block discarded – undo
3287 3287
  * @since 4.4.0
3288 3288
  */
3289 3289
 function wp_ajax_save_wporg_username() {
3290
-	if ( ! current_user_can( 'install_themes' ) && ! current_user_can( 'install_plugins' ) ) {
3290
+	if ( ! current_user_can('install_themes') && ! current_user_can('install_plugins')) {
3291 3291
 		wp_send_json_error();
3292 3292
 	}
3293 3293
 
3294
-	check_ajax_referer( 'save_wporg_username_' . get_current_user_id() );
3294
+	check_ajax_referer('save_wporg_username_'.get_current_user_id());
3295 3295
 
3296
-	$username = isset( $_REQUEST['username'] ) ? wp_unslash( $_REQUEST['username'] ) : false;
3296
+	$username = isset($_REQUEST['username']) ? wp_unslash($_REQUEST['username']) : false;
3297 3297
 
3298
-	if ( ! $username ) {
3298
+	if ( ! $username) {
3299 3299
 		wp_send_json_error();
3300 3300
 	}
3301 3301
 
3302
-	wp_send_json_success( update_user_meta( get_current_user_id(), 'wporg_favorites', $username ) );
3302
+	wp_send_json_success(update_user_meta(get_current_user_id(), 'wporg_favorites', $username));
3303 3303
 }
3304 3304
 
3305 3305
 /**
@@ -3310,103 +3310,103 @@  discard block
 block discarded – undo
3310 3310
  * @see Theme_Upgrader
3311 3311
  */
3312 3312
 function wp_ajax_install_theme() {
3313
-	check_ajax_referer( 'updates' );
3313
+	check_ajax_referer('updates');
3314 3314
 
3315
-	if ( empty( $_POST['slug'] ) ) {
3316
-		wp_send_json_error( array(
3315
+	if (empty($_POST['slug'])) {
3316
+		wp_send_json_error(array(
3317 3317
 			'slug'         => '',
3318 3318
 			'errorCode'    => 'no_theme_specified',
3319
-			'errorMessage' => __( 'No theme specified.' ),
3320
-		) );
3319
+			'errorMessage' => __('No theme specified.'),
3320
+		));
3321 3321
 	}
3322 3322
 
3323
-	$slug = sanitize_key( wp_unslash( $_POST['slug'] ) );
3323
+	$slug = sanitize_key(wp_unslash($_POST['slug']));
3324 3324
 
3325 3325
 	$status = array(
3326 3326
 		'install' => 'theme',
3327 3327
 		'slug'    => $slug,
3328 3328
 	);
3329 3329
 
3330
-	if ( ! current_user_can( 'install_themes' ) ) {
3331
-		$status['errorMessage'] = __( 'Sorry, you are not allowed to install themes on this site.' );
3332
-		wp_send_json_error( $status );
3330
+	if ( ! current_user_can('install_themes')) {
3331
+		$status['errorMessage'] = __('Sorry, you are not allowed to install themes on this site.');
3332
+		wp_send_json_error($status);
3333 3333
 	}
3334 3334
 
3335
-	include_once( ABSPATH . 'wp-admin/includes/class-wp-upgrader.php' );
3336
-	include_once( ABSPATH . 'wp-admin/includes/theme.php' );
3335
+	include_once(ABSPATH.'wp-admin/includes/class-wp-upgrader.php');
3336
+	include_once(ABSPATH.'wp-admin/includes/theme.php');
3337 3337
 
3338
-	$api = themes_api( 'theme_information', array(
3338
+	$api = themes_api('theme_information', array(
3339 3339
 		'slug'   => $slug,
3340
-		'fields' => array( 'sections' => false ),
3341
-	) );
3340
+		'fields' => array('sections' => false),
3341
+	));
3342 3342
 
3343
-	if ( is_wp_error( $api ) ) {
3343
+	if (is_wp_error($api)) {
3344 3344
 		$status['errorMessage'] = $api->get_error_message();
3345
-		wp_send_json_error( $status );
3345
+		wp_send_json_error($status);
3346 3346
 	}
3347 3347
 
3348 3348
 	$skin     = new WP_Ajax_Upgrader_Skin();
3349
-	$upgrader = new Theme_Upgrader( $skin );
3350
-	$result   = $upgrader->install( $api->download_link );
3349
+	$upgrader = new Theme_Upgrader($skin);
3350
+	$result   = $upgrader->install($api->download_link);
3351 3351
 
3352
-	if ( defined( 'WP_DEBUG' ) && WP_DEBUG ) {
3352
+	if (defined('WP_DEBUG') && WP_DEBUG) {
3353 3353
 		$status['debug'] = $skin->get_upgrade_messages();
3354 3354
 	}
3355 3355
 
3356
-	if ( is_wp_error( $result ) ) {
3356
+	if (is_wp_error($result)) {
3357 3357
 		$status['errorCode']    = $result->get_error_code();
3358 3358
 		$status['errorMessage'] = $result->get_error_message();
3359
-		wp_send_json_error( $status );
3360
-	} elseif ( is_wp_error( $skin->result ) ) {
3359
+		wp_send_json_error($status);
3360
+	} elseif (is_wp_error($skin->result)) {
3361 3361
 		$status['errorCode']    = $skin->result->get_error_code();
3362 3362
 		$status['errorMessage'] = $skin->result->get_error_message();
3363
-		wp_send_json_error( $status );
3364
-	} elseif ( $skin->get_errors()->get_error_code() ) {
3363
+		wp_send_json_error($status);
3364
+	} elseif ($skin->get_errors()->get_error_code()) {
3365 3365
 		$status['errorMessage'] = $skin->get_error_messages();
3366
-		wp_send_json_error( $status );
3367
-	} elseif ( is_null( $result ) ) {
3366
+		wp_send_json_error($status);
3367
+	} elseif (is_null($result)) {
3368 3368
 		global $wp_filesystem;
3369 3369
 
3370 3370
 		$status['errorCode']    = 'unable_to_connect_to_filesystem';
3371
-		$status['errorMessage'] = __( 'Unable to connect to the filesystem. Please confirm your credentials.' );
3371
+		$status['errorMessage'] = __('Unable to connect to the filesystem. Please confirm your credentials.');
3372 3372
 
3373 3373
 		// Pass through the error from WP_Filesystem if one was raised.
3374
-		if ( $wp_filesystem instanceof WP_Filesystem_Base && is_wp_error( $wp_filesystem->errors ) && $wp_filesystem->errors->get_error_code() ) {
3375
-			$status['errorMessage'] = esc_html( $wp_filesystem->errors->get_error_message() );
3374
+		if ($wp_filesystem instanceof WP_Filesystem_Base && is_wp_error($wp_filesystem->errors) && $wp_filesystem->errors->get_error_code()) {
3375
+			$status['errorMessage'] = esc_html($wp_filesystem->errors->get_error_message());
3376 3376
 		}
3377 3377
 
3378
-		wp_send_json_error( $status );
3378
+		wp_send_json_error($status);
3379 3379
 	}
3380 3380
 
3381
-	$status['themeName'] = wp_get_theme( $slug )->get( 'Name' );
3381
+	$status['themeName'] = wp_get_theme($slug)->get('Name');
3382 3382
 
3383
-	if ( current_user_can( 'switch_themes' ) ) {
3384
-		if ( is_multisite() ) {
3385
-			$status['activateUrl'] = add_query_arg( array(
3383
+	if (current_user_can('switch_themes')) {
3384
+		if (is_multisite()) {
3385
+			$status['activateUrl'] = add_query_arg(array(
3386 3386
 				'action'   => 'enable',
3387
-				'_wpnonce' => wp_create_nonce( 'enable-theme_' . $slug ),
3387
+				'_wpnonce' => wp_create_nonce('enable-theme_'.$slug),
3388 3388
 				'theme'    => $slug,
3389
-			), network_admin_url( 'themes.php' ) );
3389
+			), network_admin_url('themes.php'));
3390 3390
 		} else {
3391
-			$status['activateUrl'] = add_query_arg( array(
3391
+			$status['activateUrl'] = add_query_arg(array(
3392 3392
 				'action'     => 'activate',
3393
-				'_wpnonce'   => wp_create_nonce( 'switch-theme_' . $slug ),
3393
+				'_wpnonce'   => wp_create_nonce('switch-theme_'.$slug),
3394 3394
 				'stylesheet' => $slug,
3395
-			), admin_url( 'themes.php' ) );
3395
+			), admin_url('themes.php'));
3396 3396
 		}
3397 3397
 	}
3398 3398
 
3399
-	if ( ! is_multisite() && current_user_can( 'edit_theme_options' ) && current_user_can( 'customize' ) ) {
3400
-		$status['customizeUrl'] = add_query_arg( array(
3401
-			'return' => urlencode( network_admin_url( 'theme-install.php', 'relative' ) ),
3402
-		), wp_customize_url( $slug ) );
3399
+	if ( ! is_multisite() && current_user_can('edit_theme_options') && current_user_can('customize')) {
3400
+		$status['customizeUrl'] = add_query_arg(array(
3401
+			'return' => urlencode(network_admin_url('theme-install.php', 'relative')),
3402
+		), wp_customize_url($slug));
3403 3403
 	}
3404 3404
 
3405 3405
 	/*
3406 3406
 	 * See WP_Theme_Install_List_Table::_get_theme_status() if we wanted to check
3407 3407
 	 * on post-install status.
3408 3408
 	 */
3409
-	wp_send_json_success( $status );
3409
+	wp_send_json_success($status);
3410 3410
 }
3411 3411
 
3412 3412
 /**
@@ -3417,81 +3417,81 @@  discard block
 block discarded – undo
3417 3417
  * @see Theme_Upgrader
3418 3418
  */
3419 3419
 function wp_ajax_update_theme() {
3420
-	check_ajax_referer( 'updates' );
3420
+	check_ajax_referer('updates');
3421 3421
 
3422
-	if ( empty( $_POST['slug'] ) ) {
3423
-		wp_send_json_error( array(
3422
+	if (empty($_POST['slug'])) {
3423
+		wp_send_json_error(array(
3424 3424
 			'slug'         => '',
3425 3425
 			'errorCode'    => 'no_theme_specified',
3426
-			'errorMessage' => __( 'No theme specified.' ),
3427
-		) );
3426
+			'errorMessage' => __('No theme specified.'),
3427
+		));
3428 3428
 	}
3429 3429
 
3430
-	$stylesheet = sanitize_key( wp_unslash( $_POST['slug'] ) );
3430
+	$stylesheet = sanitize_key(wp_unslash($_POST['slug']));
3431 3431
 	$status     = array(
3432 3432
 		'update'     => 'theme',
3433 3433
 		'slug'       => $stylesheet,
3434 3434
 		'newVersion' => '',
3435 3435
 	);
3436 3436
 
3437
-	if ( ! current_user_can( 'update_themes' ) ) {
3438
-		$status['errorMessage'] = __( 'Sorry, you are not allowed to update themes for this site.' );
3439
-		wp_send_json_error( $status );
3437
+	if ( ! current_user_can('update_themes')) {
3438
+		$status['errorMessage'] = __('Sorry, you are not allowed to update themes for this site.');
3439
+		wp_send_json_error($status);
3440 3440
 	}
3441 3441
 
3442
-	include_once( ABSPATH . 'wp-admin/includes/class-wp-upgrader.php' );
3442
+	include_once(ABSPATH.'wp-admin/includes/class-wp-upgrader.php');
3443 3443
 
3444
-	$current = get_site_transient( 'update_themes' );
3445
-	if ( empty( $current ) ) {
3444
+	$current = get_site_transient('update_themes');
3445
+	if (empty($current)) {
3446 3446
 		wp_update_themes();
3447 3447
 	}
3448 3448
 
3449 3449
 	$skin     = new WP_Ajax_Upgrader_Skin();
3450
-	$upgrader = new Theme_Upgrader( $skin );
3451
-	$result   = $upgrader->bulk_upgrade( array( $stylesheet ) );
3450
+	$upgrader = new Theme_Upgrader($skin);
3451
+	$result   = $upgrader->bulk_upgrade(array($stylesheet));
3452 3452
 
3453
-	if ( defined( 'WP_DEBUG' ) && WP_DEBUG ) {
3453
+	if (defined('WP_DEBUG') && WP_DEBUG) {
3454 3454
 		$status['debug'] = $skin->get_upgrade_messages();
3455 3455
 	}
3456 3456
 
3457
-	if ( is_wp_error( $skin->result ) ) {
3457
+	if (is_wp_error($skin->result)) {
3458 3458
 		$status['errorCode']    = $skin->result->get_error_code();
3459 3459
 		$status['errorMessage'] = $skin->result->get_error_message();
3460
-		wp_send_json_error( $status );
3461
-	} elseif ( $skin->get_errors()->get_error_code() ) {
3460
+		wp_send_json_error($status);
3461
+	} elseif ($skin->get_errors()->get_error_code()) {
3462 3462
 		$status['errorMessage'] = $skin->get_error_messages();
3463
-		wp_send_json_error( $status );
3464
-	} elseif ( is_array( $result ) && ! empty( $result[ $stylesheet ] ) ) {
3463
+		wp_send_json_error($status);
3464
+	} elseif (is_array($result) && ! empty($result[$stylesheet])) {
3465 3465
 
3466 3466
 		// Theme is already at the latest version.
3467
-		if ( true === $result[ $stylesheet ] ) {
3467
+		if (true === $result[$stylesheet]) {
3468 3468
 			$status['errorMessage'] = $upgrader->strings['up_to_date'];
3469
-			wp_send_json_error( $status );
3469
+			wp_send_json_error($status);
3470 3470
 		}
3471 3471
 
3472
-		$theme = wp_get_theme( $stylesheet );
3473
-		if ( $theme->get( 'Version' ) ) {
3474
-			$status['newVersion'] = $theme->get( 'Version' );
3472
+		$theme = wp_get_theme($stylesheet);
3473
+		if ($theme->get('Version')) {
3474
+			$status['newVersion'] = $theme->get('Version');
3475 3475
 		}
3476 3476
 
3477
-		wp_send_json_success( $status );
3478
-	} elseif ( false === $result ) {
3477
+		wp_send_json_success($status);
3478
+	} elseif (false === $result) {
3479 3479
 		global $wp_filesystem;
3480 3480
 
3481 3481
 		$status['errorCode']    = 'unable_to_connect_to_filesystem';
3482
-		$status['errorMessage'] = __( 'Unable to connect to the filesystem. Please confirm your credentials.' );
3482
+		$status['errorMessage'] = __('Unable to connect to the filesystem. Please confirm your credentials.');
3483 3483
 
3484 3484
 		// Pass through the error from WP_Filesystem if one was raised.
3485
-		if ( $wp_filesystem instanceof WP_Filesystem_Base && is_wp_error( $wp_filesystem->errors ) && $wp_filesystem->errors->get_error_code() ) {
3486
-			$status['errorMessage'] = esc_html( $wp_filesystem->errors->get_error_message() );
3485
+		if ($wp_filesystem instanceof WP_Filesystem_Base && is_wp_error($wp_filesystem->errors) && $wp_filesystem->errors->get_error_code()) {
3486
+			$status['errorMessage'] = esc_html($wp_filesystem->errors->get_error_message());
3487 3487
 		}
3488 3488
 
3489
-		wp_send_json_error( $status );
3489
+		wp_send_json_error($status);
3490 3490
 	}
3491 3491
 
3492 3492
 	// An unhandled error occurred.
3493
-	$status['errorMessage'] = __( 'Update failed.' );
3494
-	wp_send_json_error( $status );
3493
+	$status['errorMessage'] = __('Update failed.');
3494
+	wp_send_json_error($status);
3495 3495
 }
3496 3496
 
3497 3497
 /**
@@ -3502,64 +3502,64 @@  discard block
 block discarded – undo
3502 3502
  * @see delete_theme()
3503 3503
  */
3504 3504
 function wp_ajax_delete_theme() {
3505
-	check_ajax_referer( 'updates' );
3505
+	check_ajax_referer('updates');
3506 3506
 
3507
-	if ( empty( $_POST['slug'] ) ) {
3508
-		wp_send_json_error( array(
3507
+	if (empty($_POST['slug'])) {
3508
+		wp_send_json_error(array(
3509 3509
 			'slug'         => '',
3510 3510
 			'errorCode'    => 'no_theme_specified',
3511
-			'errorMessage' => __( 'No theme specified.' ),
3512
-		) );
3511
+			'errorMessage' => __('No theme specified.'),
3512
+		));
3513 3513
 	}
3514 3514
 
3515
-	$stylesheet = sanitize_key( wp_unslash( $_POST['slug'] ) );
3515
+	$stylesheet = sanitize_key(wp_unslash($_POST['slug']));
3516 3516
 	$status     = array(
3517 3517
 		'delete' => 'theme',
3518 3518
 		'slug'   => $stylesheet,
3519 3519
 	);
3520 3520
 
3521
-	if ( ! current_user_can( 'delete_themes' ) ) {
3522
-		$status['errorMessage'] = __( 'Sorry, you are not allowed to delete themes on this site.' );
3523
-		wp_send_json_error( $status );
3521
+	if ( ! current_user_can('delete_themes')) {
3522
+		$status['errorMessage'] = __('Sorry, you are not allowed to delete themes on this site.');
3523
+		wp_send_json_error($status);
3524 3524
 	}
3525 3525
 
3526
-	if ( ! wp_get_theme( $stylesheet )->exists() ) {
3527
-		$status['errorMessage'] = __( 'The requested theme does not exist.' );
3528
-		wp_send_json_error( $status );
3526
+	if ( ! wp_get_theme($stylesheet)->exists()) {
3527
+		$status['errorMessage'] = __('The requested theme does not exist.');
3528
+		wp_send_json_error($status);
3529 3529
 	}
3530 3530
 
3531 3531
 	// Check filesystem credentials. `delete_theme()` will bail otherwise.
3532
-	$url = wp_nonce_url( 'themes.php?action=delete&stylesheet=' . urlencode( $stylesheet ), 'delete-theme_' . $stylesheet );
3532
+	$url = wp_nonce_url('themes.php?action=delete&stylesheet='.urlencode($stylesheet), 'delete-theme_'.$stylesheet);
3533 3533
 	ob_start();
3534
-	$credentials = request_filesystem_credentials( $url );
3534
+	$credentials = request_filesystem_credentials($url);
3535 3535
 	ob_end_clean();
3536
-	if ( false === $credentials || ! WP_Filesystem( $credentials ) ) {
3536
+	if (false === $credentials || ! WP_Filesystem($credentials)) {
3537 3537
 		global $wp_filesystem;
3538 3538
 
3539 3539
 		$status['errorCode']    = 'unable_to_connect_to_filesystem';
3540
-		$status['errorMessage'] = __( 'Unable to connect to the filesystem. Please confirm your credentials.' );
3540
+		$status['errorMessage'] = __('Unable to connect to the filesystem. Please confirm your credentials.');
3541 3541
 
3542 3542
 		// Pass through the error from WP_Filesystem if one was raised.
3543
-		if ( $wp_filesystem instanceof WP_Filesystem_Base && is_wp_error( $wp_filesystem->errors ) && $wp_filesystem->errors->get_error_code() ) {
3544
-			$status['errorMessage'] = esc_html( $wp_filesystem->errors->get_error_message() );
3543
+		if ($wp_filesystem instanceof WP_Filesystem_Base && is_wp_error($wp_filesystem->errors) && $wp_filesystem->errors->get_error_code()) {
3544
+			$status['errorMessage'] = esc_html($wp_filesystem->errors->get_error_message());
3545 3545
 		}
3546 3546
 
3547
-		wp_send_json_error( $status );
3547
+		wp_send_json_error($status);
3548 3548
 	}
3549 3549
 
3550
-	include_once( ABSPATH . 'wp-admin/includes/theme.php' );
3550
+	include_once(ABSPATH.'wp-admin/includes/theme.php');
3551 3551
 
3552
-	$result = delete_theme( $stylesheet );
3552
+	$result = delete_theme($stylesheet);
3553 3553
 
3554
-	if ( is_wp_error( $result ) ) {
3554
+	if (is_wp_error($result)) {
3555 3555
 		$status['errorMessage'] = $result->get_error_message();
3556
-		wp_send_json_error( $status );
3557
-	} elseif ( false === $result ) {
3558
-		$status['errorMessage'] = __( 'Theme could not be deleted.' );
3559
-		wp_send_json_error( $status );
3556
+		wp_send_json_error($status);
3557
+	} elseif (false === $result) {
3558
+		$status['errorMessage'] = __('Theme could not be deleted.');
3559
+		wp_send_json_error($status);
3560 3560
 	}
3561 3561
 
3562
-	wp_send_json_success( $status );
3562
+	wp_send_json_success($status);
3563 3563
 }
3564 3564
 
3565 3565
 /**
@@ -3570,91 +3570,91 @@  discard block
 block discarded – undo
3570 3570
  * @see Plugin_Upgrader
3571 3571
  */
3572 3572
 function wp_ajax_install_plugin() {
3573
-	check_ajax_referer( 'updates' );
3573
+	check_ajax_referer('updates');
3574 3574
 
3575
-	if ( empty( $_POST['slug'] ) ) {
3576
-		wp_send_json_error( array(
3575
+	if (empty($_POST['slug'])) {
3576
+		wp_send_json_error(array(
3577 3577
 			'slug'         => '',
3578 3578
 			'errorCode'    => 'no_plugin_specified',
3579
-			'errorMessage' => __( 'No plugin specified.' ),
3580
-		) );
3579
+			'errorMessage' => __('No plugin specified.'),
3580
+		));
3581 3581
 	}
3582 3582
 
3583 3583
 	$status = array(
3584 3584
 		'install' => 'plugin',
3585
-		'slug'    => sanitize_key( wp_unslash( $_POST['slug'] ) ),
3585
+		'slug'    => sanitize_key(wp_unslash($_POST['slug'])),
3586 3586
 	);
3587 3587
 
3588
-	if ( ! current_user_can( 'install_plugins' ) ) {
3589
-		$status['errorMessage'] = __( 'Sorry, you are not allowed to install plugins on this site.' );
3590
-		wp_send_json_error( $status );
3588
+	if ( ! current_user_can('install_plugins')) {
3589
+		$status['errorMessage'] = __('Sorry, you are not allowed to install plugins on this site.');
3590
+		wp_send_json_error($status);
3591 3591
 	}
3592 3592
 
3593
-	include_once( ABSPATH . 'wp-admin/includes/class-wp-upgrader.php' );
3594
-	include_once( ABSPATH . 'wp-admin/includes/plugin-install.php' );
3593
+	include_once(ABSPATH.'wp-admin/includes/class-wp-upgrader.php');
3594
+	include_once(ABSPATH.'wp-admin/includes/plugin-install.php');
3595 3595
 
3596
-	$api = plugins_api( 'plugin_information', array(
3597
-		'slug'   => sanitize_key( wp_unslash( $_POST['slug'] ) ),
3596
+	$api = plugins_api('plugin_information', array(
3597
+		'slug'   => sanitize_key(wp_unslash($_POST['slug'])),
3598 3598
 		'fields' => array(
3599 3599
 			'sections' => false,
3600 3600
 		),
3601
-	) );
3601
+	));
3602 3602
 
3603
-	if ( is_wp_error( $api ) ) {
3603
+	if (is_wp_error($api)) {
3604 3604
 		$status['errorMessage'] = $api->get_error_message();
3605
-		wp_send_json_error( $status );
3605
+		wp_send_json_error($status);
3606 3606
 	}
3607 3607
 
3608 3608
 	$status['pluginName'] = $api->name;
3609 3609
 
3610 3610
 	$skin     = new WP_Ajax_Upgrader_Skin();
3611
-	$upgrader = new Plugin_Upgrader( $skin );
3612
-	$result   = $upgrader->install( $api->download_link );
3611
+	$upgrader = new Plugin_Upgrader($skin);
3612
+	$result   = $upgrader->install($api->download_link);
3613 3613
 
3614
-	if ( defined( 'WP_DEBUG' ) && WP_DEBUG ) {
3614
+	if (defined('WP_DEBUG') && WP_DEBUG) {
3615 3615
 		$status['debug'] = $skin->get_upgrade_messages();
3616 3616
 	}
3617 3617
 
3618
-	if ( is_wp_error( $result ) ) {
3618
+	if (is_wp_error($result)) {
3619 3619
 		$status['errorCode']    = $result->get_error_code();
3620 3620
 		$status['errorMessage'] = $result->get_error_message();
3621
-		wp_send_json_error( $status );
3622
-	} elseif ( is_wp_error( $skin->result ) ) {
3621
+		wp_send_json_error($status);
3622
+	} elseif (is_wp_error($skin->result)) {
3623 3623
 		$status['errorCode']    = $skin->result->get_error_code();
3624 3624
 		$status['errorMessage'] = $skin->result->get_error_message();
3625
-		wp_send_json_error( $status );
3626
-	} elseif ( $skin->get_errors()->get_error_code() ) {
3625
+		wp_send_json_error($status);
3626
+	} elseif ($skin->get_errors()->get_error_code()) {
3627 3627
 		$status['errorMessage'] = $skin->get_error_messages();
3628
-		wp_send_json_error( $status );
3629
-	} elseif ( is_null( $result ) ) {
3628
+		wp_send_json_error($status);
3629
+	} elseif (is_null($result)) {
3630 3630
 		global $wp_filesystem;
3631 3631
 
3632 3632
 		$status['errorCode']    = 'unable_to_connect_to_filesystem';
3633
-		$status['errorMessage'] = __( 'Unable to connect to the filesystem. Please confirm your credentials.' );
3633
+		$status['errorMessage'] = __('Unable to connect to the filesystem. Please confirm your credentials.');
3634 3634
 
3635 3635
 		// Pass through the error from WP_Filesystem if one was raised.
3636
-		if ( $wp_filesystem instanceof WP_Filesystem_Base && is_wp_error( $wp_filesystem->errors ) && $wp_filesystem->errors->get_error_code() ) {
3637
-			$status['errorMessage'] = esc_html( $wp_filesystem->errors->get_error_message() );
3636
+		if ($wp_filesystem instanceof WP_Filesystem_Base && is_wp_error($wp_filesystem->errors) && $wp_filesystem->errors->get_error_code()) {
3637
+			$status['errorMessage'] = esc_html($wp_filesystem->errors->get_error_message());
3638 3638
 		}
3639 3639
 
3640
-		wp_send_json_error( $status );
3640
+		wp_send_json_error($status);
3641 3641
 	}
3642 3642
 
3643
-	$install_status = install_plugin_install_status( $api );
3643
+	$install_status = install_plugin_install_status($api);
3644 3644
 
3645
-	if ( current_user_can( 'activate_plugins' ) && is_plugin_inactive( $install_status['file'] ) ) {
3646
-		$status['activateUrl'] = add_query_arg( array(
3647
-			'_wpnonce' => wp_create_nonce( 'activate-plugin_' . $install_status['file'] ),
3645
+	if (current_user_can('activate_plugins') && is_plugin_inactive($install_status['file'])) {
3646
+		$status['activateUrl'] = add_query_arg(array(
3647
+			'_wpnonce' => wp_create_nonce('activate-plugin_'.$install_status['file']),
3648 3648
 			'action'   => 'activate',
3649 3649
 			'plugin'   => $install_status['file'],
3650
-		), network_admin_url( 'plugins.php' ) );
3650
+		), network_admin_url('plugins.php'));
3651 3651
 	}
3652 3652
 
3653
-	if ( is_multisite() && current_user_can( 'manage_network_plugins' ) ) {
3654
-		$status['activateUrl'] = add_query_arg( array( 'networkwide' => 1 ), $status['activateUrl'] );
3653
+	if (is_multisite() && current_user_can('manage_network_plugins')) {
3654
+		$status['activateUrl'] = add_query_arg(array('networkwide' => 1), $status['activateUrl']);
3655 3655
 	}
3656 3656
 
3657
-	wp_send_json_success( $status );
3657
+	wp_send_json_success($status);
3658 3658
 }
3659 3659
 
3660 3660
 /**
@@ -3665,60 +3665,60 @@  discard block
 block discarded – undo
3665 3665
  * @see Plugin_Upgrader
3666 3666
  */
3667 3667
 function wp_ajax_update_plugin() {
3668
-	check_ajax_referer( 'updates' );
3668
+	check_ajax_referer('updates');
3669 3669
 
3670
-	if ( empty( $_POST['plugin'] ) || empty( $_POST['slug'] ) ) {
3671
-		wp_send_json_error( array(
3670
+	if (empty($_POST['plugin']) || empty($_POST['slug'])) {
3671
+		wp_send_json_error(array(
3672 3672
 			'slug'         => '',
3673 3673
 			'errorCode'    => 'no_plugin_specified',
3674
-			'errorMessage' => __( 'No plugin specified.' ),
3675
-		) );
3674
+			'errorMessage' => __('No plugin specified.'),
3675
+		));
3676 3676
 	}
3677 3677
 
3678
-	$plugin = plugin_basename( sanitize_text_field( wp_unslash( $_POST['plugin'] ) ) );
3678
+	$plugin = plugin_basename(sanitize_text_field(wp_unslash($_POST['plugin'])));
3679 3679
 
3680 3680
 	$status = array(
3681 3681
 		'update'     => 'plugin',
3682
-		'slug'       => sanitize_key( wp_unslash( $_POST['slug'] ) ),
3682
+		'slug'       => sanitize_key(wp_unslash($_POST['slug'])),
3683 3683
 		'oldVersion' => '',
3684 3684
 		'newVersion' => '',
3685 3685
 	);
3686 3686
 
3687
-	if ( ! current_user_can( 'update_plugins' ) || 0 !== validate_file( $plugin ) ) {
3688
-		$status['errorMessage'] = __( 'Sorry, you are not allowed to update plugins for this site.' );
3689
-		wp_send_json_error( $status );
3687
+	if ( ! current_user_can('update_plugins') || 0 !== validate_file($plugin)) {
3688
+		$status['errorMessage'] = __('Sorry, you are not allowed to update plugins for this site.');
3689
+		wp_send_json_error($status);
3690 3690
 	}
3691 3691
 
3692
-	$plugin_data          = get_plugin_data( WP_PLUGIN_DIR . '/' . $plugin );
3692
+	$plugin_data          = get_plugin_data(WP_PLUGIN_DIR.'/'.$plugin);
3693 3693
 	$status['plugin']     = $plugin;
3694 3694
 	$status['pluginName'] = $plugin_data['Name'];
3695 3695
 
3696
-	if ( $plugin_data['Version'] ) {
3696
+	if ($plugin_data['Version']) {
3697 3697
 		/* translators: %s: Plugin version */
3698
-		$status['oldVersion'] = sprintf( __( 'Version %s' ), $plugin_data['Version'] );
3698
+		$status['oldVersion'] = sprintf(__('Version %s'), $plugin_data['Version']);
3699 3699
 	}
3700 3700
 
3701
-	include_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php';
3701
+	include_once ABSPATH.'wp-admin/includes/class-wp-upgrader.php';
3702 3702
 
3703 3703
 	wp_update_plugins();
3704 3704
 
3705 3705
 	$skin     = new WP_Ajax_Upgrader_Skin();
3706
-	$upgrader = new Plugin_Upgrader( $skin );
3707
-	$result   = $upgrader->bulk_upgrade( array( $plugin ) );
3706
+	$upgrader = new Plugin_Upgrader($skin);
3707
+	$result   = $upgrader->bulk_upgrade(array($plugin));
3708 3708
 
3709
-	if ( defined( 'WP_DEBUG' ) && WP_DEBUG ) {
3709
+	if (defined('WP_DEBUG') && WP_DEBUG) {
3710 3710
 		$status['debug'] = $skin->get_upgrade_messages();
3711 3711
 	}
3712 3712
 
3713
-	if ( is_wp_error( $skin->result ) ) {
3713
+	if (is_wp_error($skin->result)) {
3714 3714
 		$status['errorCode']    = $skin->result->get_error_code();
3715 3715
 		$status['errorMessage'] = $skin->result->get_error_message();
3716
-		wp_send_json_error( $status );
3717
-	} elseif ( $skin->get_errors()->get_error_code() ) {
3716
+		wp_send_json_error($status);
3717
+	} elseif ($skin->get_errors()->get_error_code()) {
3718 3718
 		$status['errorMessage'] = $skin->get_error_messages();
3719
-		wp_send_json_error( $status );
3720
-	} elseif ( is_array( $result ) && ! empty( $result[ $plugin ] ) ) {
3721
-		$plugin_update_data = current( $result );
3719
+		wp_send_json_error($status);
3720
+	} elseif (is_array($result) && ! empty($result[$plugin])) {
3721
+		$plugin_update_data = current($result);
3722 3722
 
3723 3723
 		/*
3724 3724
 		 * If the `update_plugins` site transient is empty (e.g. when you update
@@ -3728,36 +3728,36 @@  discard block
 block discarded – undo
3728 3728
 		 * Preferably something can be done to ensure `update_plugins` isn't empty.
3729 3729
 		 * For now, surface some sort of error here.
3730 3730
 		 */
3731
-		if ( true === $plugin_update_data ) {
3732
-			$status['errorMessage'] = __( 'Plugin update failed.' );
3733
-			wp_send_json_error( $status );
3731
+		if (true === $plugin_update_data) {
3732
+			$status['errorMessage'] = __('Plugin update failed.');
3733
+			wp_send_json_error($status);
3734 3734
 		}
3735 3735
 
3736
-		$plugin_data = get_plugins( '/' . $result[ $plugin ]['destination_name'] );
3737
-		$plugin_data = reset( $plugin_data );
3736
+		$plugin_data = get_plugins('/'.$result[$plugin]['destination_name']);
3737
+		$plugin_data = reset($plugin_data);
3738 3738
 
3739
-		if ( $plugin_data['Version'] ) {
3739
+		if ($plugin_data['Version']) {
3740 3740
 			/* translators: %s: Plugin version */
3741
-			$status['newVersion'] = sprintf( __( 'Version %s' ), $plugin_data['Version'] );
3741
+			$status['newVersion'] = sprintf(__('Version %s'), $plugin_data['Version']);
3742 3742
 		}
3743
-		wp_send_json_success( $status );
3744
-	} elseif ( false === $result ) {
3743
+		wp_send_json_success($status);
3744
+	} elseif (false === $result) {
3745 3745
 		global $wp_filesystem;
3746 3746
 
3747 3747
 		$status['errorCode']    = 'unable_to_connect_to_filesystem';
3748
-		$status['errorMessage'] = __( 'Unable to connect to the filesystem. Please confirm your credentials.' );
3748
+		$status['errorMessage'] = __('Unable to connect to the filesystem. Please confirm your credentials.');
3749 3749
 
3750 3750
 		// Pass through the error from WP_Filesystem if one was raised.
3751
-		if ( $wp_filesystem instanceof WP_Filesystem_Base && is_wp_error( $wp_filesystem->errors ) && $wp_filesystem->errors->get_error_code() ) {
3752
-			$status['errorMessage'] = esc_html( $wp_filesystem->errors->get_error_message() );
3751
+		if ($wp_filesystem instanceof WP_Filesystem_Base && is_wp_error($wp_filesystem->errors) && $wp_filesystem->errors->get_error_code()) {
3752
+			$status['errorMessage'] = esc_html($wp_filesystem->errors->get_error_message());
3753 3753
 		}
3754 3754
 
3755
-		wp_send_json_error( $status );
3755
+		wp_send_json_error($status);
3756 3756
 	}
3757 3757
 
3758 3758
 	// An unhandled error occurred.
3759
-	$status['errorMessage'] = __( 'Plugin update failed.' );
3760
-	wp_send_json_error( $status );
3759
+	$status['errorMessage'] = __('Plugin update failed.');
3760
+	wp_send_json_error($status);
3761 3761
 }
3762 3762
 
3763 3763
 /**
@@ -3768,67 +3768,67 @@  discard block
 block discarded – undo
3768 3768
  * @see delete_plugins()
3769 3769
  */
3770 3770
 function wp_ajax_delete_plugin() {
3771
-	check_ajax_referer( 'updates' );
3771
+	check_ajax_referer('updates');
3772 3772
 
3773
-	if ( empty( $_POST['slug'] ) || empty( $_POST['plugin'] ) ) {
3774
-		wp_send_json_error( array(
3773
+	if (empty($_POST['slug']) || empty($_POST['plugin'])) {
3774
+		wp_send_json_error(array(
3775 3775
 			'slug'         => '',
3776 3776
 			'errorCode'    => 'no_plugin_specified',
3777
-			'errorMessage' => __( 'No plugin specified.' ),
3778
-		) );
3777
+			'errorMessage' => __('No plugin specified.'),
3778
+		));
3779 3779
 	}
3780 3780
 
3781
-	$plugin = plugin_basename( sanitize_text_field( wp_unslash( $_POST['plugin'] ) ) );
3781
+	$plugin = plugin_basename(sanitize_text_field(wp_unslash($_POST['plugin'])));
3782 3782
 
3783 3783
 	$status = array(
3784 3784
 		'delete' => 'plugin',
3785
-		'slug'   => sanitize_key( wp_unslash( $_POST['slug'] ) ),
3785
+		'slug'   => sanitize_key(wp_unslash($_POST['slug'])),
3786 3786
 	);
3787 3787
 
3788
-	if ( ! current_user_can( 'delete_plugins' ) || 0 !== validate_file( $plugin ) ) {
3789
-		$status['errorMessage'] = __( 'Sorry, you are not allowed to delete plugins for this site.' );
3790
-		wp_send_json_error( $status );
3788
+	if ( ! current_user_can('delete_plugins') || 0 !== validate_file($plugin)) {
3789
+		$status['errorMessage'] = __('Sorry, you are not allowed to delete plugins for this site.');
3790
+		wp_send_json_error($status);
3791 3791
 	}
3792 3792
 
3793
-	$plugin_data          = get_plugin_data( WP_PLUGIN_DIR . '/' . $plugin );
3793
+	$plugin_data          = get_plugin_data(WP_PLUGIN_DIR.'/'.$plugin);
3794 3794
 	$status['plugin']     = $plugin;
3795 3795
 	$status['pluginName'] = $plugin_data['Name'];
3796 3796
 
3797
-	if ( is_plugin_active( $plugin ) ) {
3798
-		$status['errorMessage'] = __( 'You cannot delete a plugin while it is active on the main site.' );
3799
-		wp_send_json_error( $status );
3797
+	if (is_plugin_active($plugin)) {
3798
+		$status['errorMessage'] = __('You cannot delete a plugin while it is active on the main site.');
3799
+		wp_send_json_error($status);
3800 3800
 	}
3801 3801
 
3802 3802
 	// Check filesystem credentials. `delete_plugins()` will bail otherwise.
3803
-	$url = wp_nonce_url( 'plugins.php?action=delete-selected&verify-delete=1&checked[]=' . $plugin, 'bulk-plugins' );
3803
+	$url = wp_nonce_url('plugins.php?action=delete-selected&verify-delete=1&checked[]='.$plugin, 'bulk-plugins');
3804 3804
 	ob_start();
3805
-	$credentials = request_filesystem_credentials( $url );
3805
+	$credentials = request_filesystem_credentials($url);
3806 3806
 	ob_end_clean();
3807
-	if ( false === $credentials || ! WP_Filesystem( $credentials ) ) {
3807
+	if (false === $credentials || ! WP_Filesystem($credentials)) {
3808 3808
 		global $wp_filesystem;
3809 3809
 
3810 3810
 		$status['errorCode']    = 'unable_to_connect_to_filesystem';
3811
-		$status['errorMessage'] = __( 'Unable to connect to the filesystem. Please confirm your credentials.' );
3811
+		$status['errorMessage'] = __('Unable to connect to the filesystem. Please confirm your credentials.');
3812 3812
 
3813 3813
 		// Pass through the error from WP_Filesystem if one was raised.
3814
-		if ( $wp_filesystem instanceof WP_Filesystem_Base && is_wp_error( $wp_filesystem->errors ) && $wp_filesystem->errors->get_error_code() ) {
3815
-			$status['errorMessage'] = esc_html( $wp_filesystem->errors->get_error_message() );
3814
+		if ($wp_filesystem instanceof WP_Filesystem_Base && is_wp_error($wp_filesystem->errors) && $wp_filesystem->errors->get_error_code()) {
3815
+			$status['errorMessage'] = esc_html($wp_filesystem->errors->get_error_message());
3816 3816
 		}
3817 3817
 
3818
-		wp_send_json_error( $status );
3818
+		wp_send_json_error($status);
3819 3819
 	}
3820 3820
 
3821
-	$result = delete_plugins( array( $plugin ) );
3821
+	$result = delete_plugins(array($plugin));
3822 3822
 
3823
-	if ( is_wp_error( $result ) ) {
3823
+	if (is_wp_error($result)) {
3824 3824
 		$status['errorMessage'] = $result->get_error_message();
3825
-		wp_send_json_error( $status );
3826
-	} elseif ( false === $result ) {
3827
-		$status['errorMessage'] = __( 'Plugin could not be deleted.' );
3828
-		wp_send_json_error( $status );
3825
+		wp_send_json_error($status);
3826
+	} elseif (false === $result) {
3827
+		$status['errorMessage'] = __('Plugin could not be deleted.');
3828
+		wp_send_json_error($status);
3829 3829
 	}
3830 3830
 
3831
-	wp_send_json_success( $status );
3831
+	wp_send_json_success($status);
3832 3832
 }
3833 3833
 
3834 3834
 /**
@@ -3839,41 +3839,41 @@  discard block
 block discarded – undo
3839 3839
  * @global string $s Search term.
3840 3840
  */
3841 3841
 function wp_ajax_search_plugins() {
3842
-	check_ajax_referer( 'updates' );
3842
+	check_ajax_referer('updates');
3843 3843
 
3844
-	$pagenow = isset( $_POST['pagenow'] ) ? sanitize_key( $_POST['pagenow'] ) : '';
3845
-	if ( 'plugins-network' === $pagenow || 'plugins' === $pagenow ) {
3846
-		set_current_screen( $pagenow );
3844
+	$pagenow = isset($_POST['pagenow']) ? sanitize_key($_POST['pagenow']) : '';
3845
+	if ('plugins-network' === $pagenow || 'plugins' === $pagenow) {
3846
+		set_current_screen($pagenow);
3847 3847
 	}
3848 3848
 
3849 3849
 	/** @var WP_Plugins_List_Table $wp_list_table */
3850
-	$wp_list_table = _get_list_table( 'WP_Plugins_List_Table', array(
3850
+	$wp_list_table = _get_list_table('WP_Plugins_List_Table', array(
3851 3851
 		'screen' => get_current_screen(),
3852
-	) );
3852
+	));
3853 3853
 
3854 3854
 	$status = array();
3855 3855
 
3856
-	if ( ! $wp_list_table->ajax_user_can() ) {
3857
-		$status['errorMessage'] = __( 'Sorry, you are not allowed to manage plugins for this site.' );
3858
-		wp_send_json_error( $status );
3856
+	if ( ! $wp_list_table->ajax_user_can()) {
3857
+		$status['errorMessage'] = __('Sorry, you are not allowed to manage plugins for this site.');
3858
+		wp_send_json_error($status);
3859 3859
 	}
3860 3860
 
3861 3861
 	// Set the correct requester, so pagination works.
3862
-	$_SERVER['REQUEST_URI'] = add_query_arg( array_diff_key( $_POST, array(
3862
+	$_SERVER['REQUEST_URI'] = add_query_arg(array_diff_key($_POST, array(
3863 3863
 		'_ajax_nonce' => null,
3864 3864
 		'action'      => null,
3865
-	) ), network_admin_url( 'plugins.php', 'relative' ) );
3865
+	)), network_admin_url('plugins.php', 'relative'));
3866 3866
 
3867
-	$GLOBALS['s'] = wp_unslash( $_POST['s'] );
3867
+	$GLOBALS['s'] = wp_unslash($_POST['s']);
3868 3868
 
3869 3869
 	$wp_list_table->prepare_items();
3870 3870
 
3871 3871
 	ob_start();
3872 3872
 	$wp_list_table->display();
3873
-	$status['count'] = count( $wp_list_table->items );
3873
+	$status['count'] = count($wp_list_table->items);
3874 3874
 	$status['items'] = ob_get_clean();
3875 3875
 
3876
-	wp_send_json_success( $status );
3876
+	wp_send_json_success($status);
3877 3877
 }
3878 3878
 
3879 3879
 /**
@@ -3882,37 +3882,37 @@  discard block
 block discarded – undo
3882 3882
  * @since 4.6.0
3883 3883
  */
3884 3884
 function wp_ajax_search_install_plugins() {
3885
-	check_ajax_referer( 'updates' );
3885
+	check_ajax_referer('updates');
3886 3886
 
3887
-	$pagenow = isset( $_POST['pagenow'] ) ? sanitize_key( $_POST['pagenow'] ) : '';
3888
-	if ( 'plugin-install-network' === $pagenow || 'plugin-install' === $pagenow ) {
3889
-		set_current_screen( $pagenow );
3887
+	$pagenow = isset($_POST['pagenow']) ? sanitize_key($_POST['pagenow']) : '';
3888
+	if ('plugin-install-network' === $pagenow || 'plugin-install' === $pagenow) {
3889
+		set_current_screen($pagenow);
3890 3890
 	}
3891 3891
 
3892 3892
 	/** @var WP_Plugin_Install_List_Table $wp_list_table */
3893
-	$wp_list_table = _get_list_table( 'WP_Plugin_Install_List_Table', array(
3893
+	$wp_list_table = _get_list_table('WP_Plugin_Install_List_Table', array(
3894 3894
 		'screen' => get_current_screen(),
3895
-	) );
3895
+	));
3896 3896
 
3897 3897
 	$status = array();
3898 3898
 
3899
-	if ( ! $wp_list_table->ajax_user_can() ) {
3900
-		$status['errorMessage'] = __( 'Sorry, you are not allowed to manage plugins for this site.' );
3901
-		wp_send_json_error( $status );
3899
+	if ( ! $wp_list_table->ajax_user_can()) {
3900
+		$status['errorMessage'] = __('Sorry, you are not allowed to manage plugins for this site.');
3901
+		wp_send_json_error($status);
3902 3902
 	}
3903 3903
 
3904 3904
 	// Set the correct requester, so pagination works.
3905
-	$_SERVER['REQUEST_URI'] = add_query_arg( array_diff_key( $_POST, array(
3905
+	$_SERVER['REQUEST_URI'] = add_query_arg(array_diff_key($_POST, array(
3906 3906
 		'_ajax_nonce' => null,
3907 3907
 		'action'      => null,
3908
-	) ), network_admin_url( 'plugin-install.php', 'relative' ) );
3908
+	)), network_admin_url('plugin-install.php', 'relative'));
3909 3909
 
3910 3910
 	$wp_list_table->prepare_items();
3911 3911
 
3912 3912
 	ob_start();
3913 3913
 	$wp_list_table->display();
3914
-	$status['count'] = (int) $wp_list_table->get_pagination_arg( 'total_items' );
3914
+	$status['count'] = (int) $wp_list_table->get_pagination_arg('total_items');
3915 3915
 	$status['items'] = ob_get_clean();
3916 3916
 
3917
-	wp_send_json_success( $status );
3917
+	wp_send_json_success($status);
3918 3918
 }
Please login to merge, or discard this patch.
Braces   +582 added lines, -389 removed lines patch added patch discarded remove patch
@@ -23,10 +23,11 @@  discard block
 block discarded – undo
23 23
 	$response = array();
24 24
 
25 25
 	// screen_id is the same as $current_screen->id and the JS global 'pagenow'.
26
-	if ( ! empty($_POST['screen_id']) )
27
-		$screen_id = sanitize_key($_POST['screen_id']);
28
-	else
29
-		$screen_id = 'front';
26
+	if ( ! empty($_POST['screen_id']) ) {
27
+			$screen_id = sanitize_key($_POST['screen_id']);
28
+	} else {
29
+			$screen_id = 'front';
30
+	}
30 31
 
31 32
 	if ( ! empty($_POST['data']) ) {
32 33
 		$data = wp_unslash( (array) $_POST['data'] );
@@ -89,11 +90,13 @@  discard block
 block discarded – undo
89 90
 	check_ajax_referer( "fetch-list-$list_class", '_ajax_fetch_list_nonce' );
90 91
 
91 92
 	$wp_list_table = _get_list_table( $list_class, array( 'screen' => $_GET['list_args']['screen']['id'] ) );
92
-	if ( ! $wp_list_table )
93
-		wp_die( 0 );
93
+	if ( ! $wp_list_table ) {
94
+			wp_die( 0 );
95
+	}
94 96
 
95
-	if ( ! $wp_list_table->ajax_user_can() )
96
-		wp_die( -1 );
97
+	if ( ! $wp_list_table->ajax_user_can() ) {
98
+			wp_die( -1 );
99
+	}
97 100
 
98 101
 	$wp_list_table->ajax_response();
99 102
 
@@ -123,8 +126,9 @@  discard block
 block discarded – undo
123 126
 	$s = wp_unslash( $_GET['q'] );
124 127
 
125 128
 	$comma = _x( ',', 'tag delimiter' );
126
-	if ( ',' !== $comma )
127
-		$s = str_replace( $comma, ',', $s );
129
+	if ( ',' !== $comma ) {
130
+			$s = str_replace( $comma, ',', $s );
131
+	}
128 132
 	if ( false !== strpos( $s, ',' ) ) {
129 133
 		$s = explode( ',', $s );
130 134
 		$s = $s[count( $s ) - 1];
@@ -162,8 +166,9 @@  discard block
 block discarded – undo
162 166
  * @since 3.1.0
163 167
  */
164 168
 function wp_ajax_wp_compression_test() {
165
-	if ( !current_user_can( 'manage_options' ) )
166
-		wp_die( -1 );
169
+	if ( !current_user_can( 'manage_options' ) ) {
170
+			wp_die( -1 );
171
+	}
167 172
 
168 173
 	if ( ini_get('zlib.output_compression') || 'ob_gzhandler' == ini_get('output_handler') ) {
169 174
 		update_site_option('can_compress_scripts', 0);
@@ -182,8 +187,9 @@  discard block
 block discarded – undo
182 187
 		 	echo $test_str;
183 188
 		 	wp_die();
184 189
 		 } elseif ( 2 == $_GET['test'] ) {
185
-			if ( !isset($_SERVER['HTTP_ACCEPT_ENCODING']) )
186
-				wp_die( -1 );
190
+			if ( !isset($_SERVER['HTTP_ACCEPT_ENCODING']) ) {
191
+							wp_die( -1 );
192
+			}
187 193
 			if ( false !== stripos( $_SERVER['HTTP_ACCEPT_ENCODING'], 'deflate') && function_exists('gzdeflate') && ! $force_gzip ) {
188 194
 				header('Content-Encoding: deflate');
189 195
 				$out = gzdeflate( $test_str, 1 );
@@ -214,14 +220,16 @@  discard block
 block discarded – undo
214 220
  */
215 221
 function wp_ajax_imgedit_preview() {
216 222
 	$post_id = intval($_GET['postid']);
217
-	if ( empty($post_id) || !current_user_can('edit_post', $post_id) )
218
-		wp_die( -1 );
223
+	if ( empty($post_id) || !current_user_can('edit_post', $post_id) ) {
224
+			wp_die( -1 );
225
+	}
219 226
 
220 227
 	check_ajax_referer( "image_editor-$post_id" );
221 228
 
222 229
 	include_once( ABSPATH . 'wp-admin/includes/image-edit.php' );
223
-	if ( ! stream_preview_image($post_id) )
224
-		wp_die( -1 );
230
+	if ( ! stream_preview_image($post_id) ) {
231
+			wp_die( -1 );
232
+	}
225 233
 
226 234
 	wp_die();
227 235
 }
@@ -244,12 +252,14 @@  discard block
 block discarded – undo
244 252
  * @since 3.4.0
245 253
  */
246 254
 function wp_ajax_autocomplete_user() {
247
-	if ( ! is_multisite() || ! current_user_can( 'promote_users' ) || wp_is_large_network( 'users' ) )
248
-		wp_die( -1 );
255
+	if ( ! is_multisite() || ! current_user_can( 'promote_users' ) || wp_is_large_network( 'users' ) ) {
256
+			wp_die( -1 );
257
+	}
249 258
 
250 259
 	/** This filter is documented in wp-admin/user-new.php */
251
-	if ( ! is_super_admin() && ! apply_filters( 'autocomplete_users_for_site_admins', false ) )
252
-		wp_die( -1 );
260
+	if ( ! is_super_admin() && ! apply_filters( 'autocomplete_users_for_site_admins', false ) ) {
261
+			wp_die( -1 );
262
+	}
253 263
 
254 264
 	$return = array();
255 265
 
@@ -390,8 +400,9 @@  discard block
 block discarded – undo
390 400
 	}
391 401
 
392 402
 	$total += $delta;
393
-	if ( $total < 0 )
394
-		$total = 0;
403
+	if ( $total < 0 ) {
404
+			$total = 0;
405
+	}
395 406
 
396 407
 	// Only do the expensive stuff on a page-break, and about 1 other time per page
397 408
 	if ( 0 == $total % $per_page || 1 == mt_rand( 1, $per_page ) ) {
@@ -401,12 +412,15 @@  discard block
 block discarded – undo
401 412
 		$parsed = parse_url( $url );
402 413
 		if ( isset( $parsed['query'] ) ) {
403 414
 			parse_str( $parsed['query'], $query_vars );
404
-			if ( !empty( $query_vars['comment_status'] ) )
405
-				$status = $query_vars['comment_status'];
406
-			if ( !empty( $query_vars['p'] ) )
407
-				$post_id = (int) $query_vars['p'];
408
-			if ( ! empty( $query_vars['comment_type'] ) )
409
-				$type = $query_vars['comment_type'];
415
+			if ( !empty( $query_vars['comment_status'] ) ) {
416
+							$status = $query_vars['comment_status'];
417
+			}
418
+			if ( !empty( $query_vars['p'] ) ) {
419
+							$post_id = (int) $query_vars['p'];
420
+			}
421
+			if ( ! empty( $query_vars['comment_type'] ) ) {
422
+							$type = $query_vars['comment_type'];
423
+			}
410 424
 		}
411 425
 
412 426
 		if ( empty( $type ) ) {
@@ -456,34 +470,41 @@  discard block
 block discarded – undo
456 470
 	$action = $_POST['action'];
457 471
 	$taxonomy = get_taxonomy(substr($action, 4));
458 472
 	check_ajax_referer( $action, '_ajax_nonce-add-' . $taxonomy->name );
459
-	if ( !current_user_can( $taxonomy->cap->edit_terms ) )
460
-		wp_die( -1 );
473
+	if ( !current_user_can( $taxonomy->cap->edit_terms ) ) {
474
+			wp_die( -1 );
475
+	}
461 476
 	$names = explode(',', $_POST['new'.$taxonomy->name]);
462 477
 	$parent = isset($_POST['new'.$taxonomy->name.'_parent']) ? (int) $_POST['new'.$taxonomy->name.'_parent'] : 0;
463
-	if ( 0 > $parent )
464
-		$parent = 0;
465
-	if ( $taxonomy->name == 'category' )
466
-		$post_category = isset($_POST['post_category']) ? (array) $_POST['post_category'] : array();
467
-	else
468
-		$post_category = ( isset($_POST['tax_input']) && isset($_POST['tax_input'][$taxonomy->name]) ) ? (array) $_POST['tax_input'][$taxonomy->name] : array();
478
+	if ( 0 > $parent ) {
479
+			$parent = 0;
480
+	}
481
+	if ( $taxonomy->name == 'category' ) {
482
+			$post_category = isset($_POST['post_category']) ? (array) $_POST['post_category'] : array();
483
+	} else {
484
+			$post_category = ( isset($_POST['tax_input']) && isset($_POST['tax_input'][$taxonomy->name]) ) ? (array) $_POST['tax_input'][$taxonomy->name] : array();
485
+	}
469 486
 	$checked_categories = array_map( 'absint', (array) $post_category );
470 487
 	$popular_ids = wp_popular_terms_checklist($taxonomy->name, 0, 10, false);
471 488
 
472 489
 	foreach ( $names as $cat_name ) {
473 490
 		$cat_name = trim($cat_name);
474 491
 		$category_nicename = sanitize_title($cat_name);
475
-		if ( '' === $category_nicename )
476
-			continue;
477
-		if ( !$cat_id = term_exists( $cat_name, $taxonomy->name, $parent ) )
478
-			$cat_id = wp_insert_term( $cat_name, $taxonomy->name, array( 'parent' => $parent ) );
492
+		if ( '' === $category_nicename ) {
493
+					continue;
494
+		}
495
+		if ( !$cat_id = term_exists( $cat_name, $taxonomy->name, $parent ) ) {
496
+					$cat_id = wp_insert_term( $cat_name, $taxonomy->name, array( 'parent' => $parent ) );
497
+		}
479 498
 		if ( is_wp_error( $cat_id ) ) {
480 499
 			continue;
481 500
 		} elseif ( is_array( $cat_id ) ) {
482 501
 			$cat_id = $cat_id['term_id'];
483 502
 		}
484 503
 		$checked_categories[] = $cat_id;
485
-		if ( $parent ) // Do these all at once in a second
504
+		if ( $parent ) {
505
+			// Do these all at once in a second
486 506
 			continue;
507
+		}
487 508
 
488 509
 		ob_start();
489 510
 
@@ -505,8 +526,9 @@  discard block
 block discarded – undo
505 526
 
506 527
 		while ( $parent->parent ) { // get the top parent
507 528
 			$parent = get_term( $parent->parent, $taxonomy->name );
508
-			if ( is_wp_error( $parent ) )
509
-				break;
529
+			if ( is_wp_error( $parent ) ) {
530
+							break;
531
+			}
510 532
 			$term_id = $parent->term_id;
511 533
 		}
512 534
 
@@ -547,43 +569,55 @@  discard block
 block discarded – undo
547 569
 function wp_ajax_delete_comment() {
548 570
 	$id = isset( $_POST['id'] ) ? (int) $_POST['id'] : 0;
549 571
 
550
-	if ( !$comment = get_comment( $id ) )
551
-		wp_die( time() );
552
-	if ( ! current_user_can( 'edit_comment', $comment->comment_ID ) )
553
-		wp_die( -1 );
572
+	if ( !$comment = get_comment( $id ) ) {
573
+			wp_die( time() );
574
+	}
575
+	if ( ! current_user_can( 'edit_comment', $comment->comment_ID ) ) {
576
+			wp_die( -1 );
577
+	}
554 578
 
555 579
 	check_ajax_referer( "delete-comment_$id" );
556 580
 	$status = wp_get_comment_status( $comment );
557 581
 
558 582
 	$delta = -1;
559 583
 	if ( isset($_POST['trash']) && 1 == $_POST['trash'] ) {
560
-		if ( 'trash' == $status )
561
-			wp_die( time() );
584
+		if ( 'trash' == $status ) {
585
+					wp_die( time() );
586
+		}
562 587
 		$r = wp_trash_comment( $comment );
563 588
 	} elseif ( isset($_POST['untrash']) && 1 == $_POST['untrash'] ) {
564
-		if ( 'trash' != $status )
565
-			wp_die( time() );
589
+		if ( 'trash' != $status ) {
590
+					wp_die( time() );
591
+		}
566 592
 		$r = wp_untrash_comment( $comment );
567
-		if ( ! isset( $_POST['comment_status'] ) || $_POST['comment_status'] != 'trash' ) // undo trash, not in trash
593
+		if ( ! isset( $_POST['comment_status'] ) || $_POST['comment_status'] != 'trash' ) {
594
+			// undo trash, not in trash
568 595
 			$delta = 1;
596
+		}
569 597
 	} elseif ( isset($_POST['spam']) && 1 == $_POST['spam'] ) {
570
-		if ( 'spam' == $status )
571
-			wp_die( time() );
598
+		if ( 'spam' == $status ) {
599
+					wp_die( time() );
600
+		}
572 601
 		$r = wp_spam_comment( $comment );
573 602
 	} elseif ( isset($_POST['unspam']) && 1 == $_POST['unspam'] ) {
574
-		if ( 'spam' != $status )
575
-			wp_die( time() );
603
+		if ( 'spam' != $status ) {
604
+					wp_die( time() );
605
+		}
576 606
 		$r = wp_unspam_comment( $comment );
577
-		if ( ! isset( $_POST['comment_status'] ) || $_POST['comment_status'] != 'spam' ) // undo spam, not in spam
607
+		if ( ! isset( $_POST['comment_status'] ) || $_POST['comment_status'] != 'spam' ) {
608
+			// undo spam, not in spam
578 609
 			$delta = 1;
610
+		}
579 611
 	} elseif ( isset($_POST['delete']) && 1 == $_POST['delete'] ) {
580 612
 		$r = wp_delete_comment( $comment );
581 613
 	} else {
582 614
 		wp_die( -1 );
583 615
 	}
584 616
 
585
-	if ( $r ) // Decide if we need to send back '1' or a more complicated response including page links and comment counts
617
+	if ( $r ) {
618
+		// Decide if we need to send back '1' or a more complicated response including page links and comment counts
586 619
 		_wp_ajax_delete_comment_response( $comment->comment_ID, $delta );
620
+	}
587 621
 	wp_die( 0 );
588 622
 }
589 623
 
@@ -599,18 +633,21 @@  discard block
 block discarded – undo
599 633
 	$taxonomy = !empty($_POST['taxonomy']) ? $_POST['taxonomy'] : 'post_tag';
600 634
 	$tax = get_taxonomy($taxonomy);
601 635
 
602
-	if ( !current_user_can( $tax->cap->delete_terms ) )
603
-		wp_die( -1 );
636
+	if ( !current_user_can( $tax->cap->delete_terms ) ) {
637
+			wp_die( -1 );
638
+	}
604 639
 
605 640
 	$tag = get_term( $tag_id, $taxonomy );
606
-	if ( !$tag || is_wp_error( $tag ) )
607
-		wp_die( 1 );
641
+	if ( !$tag || is_wp_error( $tag ) ) {
642
+			wp_die( 1 );
643
+	}
608 644
 
609
-	if ( wp_delete_term($tag_id, $taxonomy))
610
-		wp_die( 1 );
611
-	else
612
-		wp_die( 0 );
613
-}
645
+	if ( wp_delete_term($tag_id, $taxonomy)) {
646
+			wp_die( 1 );
647
+	} else {
648
+			wp_die( 0 );
649
+	}
650
+	}
614 651
 
615 652
 /**
616 653
  * Ajax handler for deleting a link.
@@ -621,18 +658,21 @@  discard block
 block discarded – undo
621 658
 	$id = isset( $_POST['id'] ) ? (int) $_POST['id'] : 0;
622 659
 
623 660
 	check_ajax_referer( "delete-bookmark_$id" );
624
-	if ( !current_user_can( 'manage_links' ) )
625
-		wp_die( -1 );
661
+	if ( !current_user_can( 'manage_links' ) ) {
662
+			wp_die( -1 );
663
+	}
626 664
 
627 665
 	$link = get_bookmark( $id );
628
-	if ( !$link || is_wp_error( $link ) )
629
-		wp_die( 1 );
666
+	if ( !$link || is_wp_error( $link ) ) {
667
+			wp_die( 1 );
668
+	}
630 669
 
631
-	if ( wp_delete_link( $id ) )
632
-		wp_die( 1 );
633
-	else
634
-		wp_die( 0 );
635
-}
670
+	if ( wp_delete_link( $id ) ) {
671
+			wp_die( 1 );
672
+	} else {
673
+			wp_die( 0 );
674
+	}
675
+	}
636 676
 
637 677
 /**
638 678
  * Ajax handler for deleting meta.
@@ -643,13 +683,16 @@  discard block
 block discarded – undo
643 683
 	$id = isset( $_POST['id'] ) ? (int) $_POST['id'] : 0;
644 684
 
645 685
 	check_ajax_referer( "delete-meta_$id" );
646
-	if ( !$meta = get_metadata_by_mid( 'post', $id ) )
647
-		wp_die( 1 );
686
+	if ( !$meta = get_metadata_by_mid( 'post', $id ) ) {
687
+			wp_die( 1 );
688
+	}
648 689
 
649
-	if ( is_protected_meta( $meta->meta_key, 'post' ) || ! current_user_can( 'delete_post_meta',  $meta->post_id, $meta->meta_key ) )
650
-		wp_die( -1 );
651
-	if ( delete_meta( $meta->meta_id ) )
652
-		wp_die( 1 );
690
+	if ( is_protected_meta( $meta->meta_key, 'post' ) || ! current_user_can( 'delete_post_meta',  $meta->post_id, $meta->meta_key ) ) {
691
+			wp_die( -1 );
692
+	}
693
+	if ( delete_meta( $meta->meta_id ) ) {
694
+			wp_die( 1 );
695
+	}
653 696
 	wp_die( 0 );
654 697
 }
655 698
 
@@ -661,22 +704,26 @@  discard block
 block discarded – undo
661 704
  * @param string $action Action to perform.
662 705
  */
663 706
 function wp_ajax_delete_post( $action ) {
664
-	if ( empty( $action ) )
665
-		$action = 'delete-post';
707
+	if ( empty( $action ) ) {
708
+			$action = 'delete-post';
709
+	}
666 710
 	$id = isset( $_POST['id'] ) ? (int) $_POST['id'] : 0;
667 711
 
668 712
 	check_ajax_referer( "{$action}_$id" );
669
-	if ( !current_user_can( 'delete_post', $id ) )
670
-		wp_die( -1 );
713
+	if ( !current_user_can( 'delete_post', $id ) ) {
714
+			wp_die( -1 );
715
+	}
671 716
 
672
-	if ( !get_post( $id ) )
673
-		wp_die( 1 );
717
+	if ( !get_post( $id ) ) {
718
+			wp_die( 1 );
719
+	}
674 720
 
675
-	if ( wp_delete_post( $id ) )
676
-		wp_die( 1 );
677
-	else
678
-		wp_die( 0 );
679
-}
721
+	if ( wp_delete_post( $id ) ) {
722
+			wp_die( 1 );
723
+	} else {
724
+			wp_die( 0 );
725
+	}
726
+	}
680 727
 
681 728
 /**
682 729
  * Ajax handler for sending a post to the trash.
@@ -686,24 +733,29 @@  discard block
 block discarded – undo
686 733
  * @param string $action Action to perform.
687 734
  */
688 735
 function wp_ajax_trash_post( $action ) {
689
-	if ( empty( $action ) )
690
-		$action = 'trash-post';
736
+	if ( empty( $action ) ) {
737
+			$action = 'trash-post';
738
+	}
691 739
 	$id = isset( $_POST['id'] ) ? (int) $_POST['id'] : 0;
692 740
 
693 741
 	check_ajax_referer( "{$action}_$id" );
694
-	if ( !current_user_can( 'delete_post', $id ) )
695
-		wp_die( -1 );
742
+	if ( !current_user_can( 'delete_post', $id ) ) {
743
+			wp_die( -1 );
744
+	}
696 745
 
697
-	if ( !get_post( $id ) )
698
-		wp_die( 1 );
746
+	if ( !get_post( $id ) ) {
747
+			wp_die( 1 );
748
+	}
699 749
 
700
-	if ( 'trash-post' == $action )
701
-		$done = wp_trash_post( $id );
702
-	else
703
-		$done = wp_untrash_post( $id );
750
+	if ( 'trash-post' == $action ) {
751
+			$done = wp_trash_post( $id );
752
+	} else {
753
+			$done = wp_untrash_post( $id );
754
+	}
704 755
 
705
-	if ( $done )
706
-		wp_die( 1 );
756
+	if ( $done ) {
757
+			wp_die( 1 );
758
+	}
707 759
 
708 760
 	wp_die( 0 );
709 761
 }
@@ -716,8 +768,9 @@  discard block
 block discarded – undo
716 768
  * @param string $action Action to perform.
717 769
  */
718 770
 function wp_ajax_untrash_post( $action ) {
719
-	if ( empty( $action ) )
720
-		$action = 'untrash-post';
771
+	if ( empty( $action ) ) {
772
+			$action = 'untrash-post';
773
+	}
721 774
 	wp_ajax_trash_post( $action );
722 775
 }
723 776
 
@@ -727,22 +780,26 @@  discard block
 block discarded – undo
727 780
  * @param string $action
728 781
  */
729 782
 function wp_ajax_delete_page( $action ) {
730
-	if ( empty( $action ) )
731
-		$action = 'delete-page';
783
+	if ( empty( $action ) ) {
784
+			$action = 'delete-page';
785
+	}
732 786
 	$id = isset( $_POST['id'] ) ? (int) $_POST['id'] : 0;
733 787
 
734 788
 	check_ajax_referer( "{$action}_$id" );
735
-	if ( !current_user_can( 'delete_page', $id ) )
736
-		wp_die( -1 );
789
+	if ( !current_user_can( 'delete_page', $id ) ) {
790
+			wp_die( -1 );
791
+	}
737 792
 
738
-	if ( ! get_post( $id ) )
739
-		wp_die( 1 );
793
+	if ( ! get_post( $id ) ) {
794
+			wp_die( 1 );
795
+	}
740 796
 
741
-	if ( wp_delete_post( $id ) )
742
-		wp_die( 1 );
743
-	else
744
-		wp_die( 0 );
745
-}
797
+	if ( wp_delete_post( $id ) ) {
798
+			wp_die( 1 );
799
+	} else {
800
+			wp_die( 0 );
801
+	}
802
+	}
746 803
 
747 804
 /**
748 805
  * Ajax handler to dim a comment.
@@ -760,12 +817,14 @@  discard block
 block discarded – undo
760 817
 		$x->send();
761 818
 	}
762 819
 
763
-	if ( ! current_user_can( 'edit_comment', $comment->comment_ID ) && ! current_user_can( 'moderate_comments' ) )
764
-		wp_die( -1 );
820
+	if ( ! current_user_can( 'edit_comment', $comment->comment_ID ) && ! current_user_can( 'moderate_comments' ) ) {
821
+			wp_die( -1 );
822
+	}
765 823
 
766 824
 	$current = wp_get_comment_status( $comment );
767
-	if ( isset( $_POST['new'] ) && $_POST['new'] == $current )
768
-		wp_die( time() );
825
+	if ( isset( $_POST['new'] ) && $_POST['new'] == $current ) {
826
+			wp_die( time() );
827
+	}
769 828
 
770 829
 	check_ajax_referer( "approve-comment_$id" );
771 830
 	if ( in_array( $current, array( 'unapproved', 'spam' ) ) ) {
@@ -795,20 +854,24 @@  discard block
 block discarded – undo
795 854
  * @param string $action Action to perform.
796 855
  */
797 856
 function wp_ajax_add_link_category( $action ) {
798
-	if ( empty( $action ) )
799
-		$action = 'add-link-category';
857
+	if ( empty( $action ) ) {
858
+			$action = 'add-link-category';
859
+	}
800 860
 	check_ajax_referer( $action );
801
-	if ( !current_user_can( 'manage_categories' ) )
802
-		wp_die( -1 );
861
+	if ( !current_user_can( 'manage_categories' ) ) {
862
+			wp_die( -1 );
863
+	}
803 864
 	$names = explode(',', wp_unslash( $_POST['newcat'] ) );
804 865
 	$x = new WP_Ajax_Response();
805 866
 	foreach ( $names as $cat_name ) {
806 867
 		$cat_name = trim($cat_name);
807 868
 		$slug = sanitize_title($cat_name);
808
-		if ( '' === $slug )
809
-			continue;
810
-		if ( !$cat_id = term_exists( $cat_name, 'link_category' ) )
811
-			$cat_id = wp_insert_term( $cat_name, 'link_category' );
869
+		if ( '' === $slug ) {
870
+					continue;
871
+		}
872
+		if ( !$cat_id = term_exists( $cat_name, 'link_category' ) ) {
873
+					$cat_id = wp_insert_term( $cat_name, 'link_category' );
874
+		}
812 875
 		if ( is_wp_error( $cat_id ) ) {
813 876
 			continue;
814 877
 		} elseif ( is_array( $cat_id ) ) {
@@ -839,8 +902,9 @@  discard block
 block discarded – undo
839 902
 	$taxonomy = !empty($_POST['taxonomy']) ? $_POST['taxonomy'] : 'post_tag';
840 903
 	$tax = get_taxonomy($taxonomy);
841 904
 
842
-	if ( !current_user_can( $tax->cap->edit_terms ) )
843
-		wp_die( -1 );
905
+	if ( !current_user_can( $tax->cap->edit_terms ) ) {
906
+			wp_die( -1 );
907
+	}
844 908
 
845 909
 	$x = new WP_Ajax_Response();
846 910
 
@@ -848,8 +912,9 @@  discard block
 block discarded – undo
848 912
 
849 913
 	if ( !$tag || is_wp_error($tag) || (!$tag = get_term( $tag['term_id'], $taxonomy )) ) {
850 914
 		$message = __('An error has occurred. Please reload the page and try again.');
851
-		if ( is_wp_error($tag) && $tag->get_error_message() )
852
-			$message = $tag->get_error_message();
915
+		if ( is_wp_error($tag) && $tag->get_error_message() ) {
916
+					$message = $tag->get_error_message();
917
+		}
853 918
 
854 919
 		$x->add( array(
855 920
 			'what' => 'taxonomy',
@@ -906,11 +971,13 @@  discard block
 block discarded – undo
906 971
 
907 972
 	$tags = get_terms( $taxonomy, array( 'number' => 45, 'orderby' => 'count', 'order' => 'DESC' ) );
908 973
 
909
-	if ( empty( $tags ) )
910
-		wp_die( $tax->labels->not_found );
974
+	if ( empty( $tags ) ) {
975
+			wp_die( $tax->labels->not_found );
976
+	}
911 977
 
912
-	if ( is_wp_error( $tags ) )
913
-		wp_die( $tags->get_error_message() );
978
+	if ( is_wp_error( $tags ) ) {
979
+			wp_die( $tags->get_error_message() );
980
+	}
914 981
 
915 982
 	foreach ( $tags as $key => $tag ) {
916 983
 		$tags[ $key ]->link = '#';
@@ -920,8 +987,9 @@  discard block
 block discarded – undo
920 987
 	// We need raw tag names here, so don't filter the output
921 988
 	$return = wp_generate_tag_cloud( $tags, array('filter' => 0) );
922 989
 
923
-	if ( empty($return) )
924
-		wp_die( 0 );
990
+	if ( empty($return) ) {
991
+			wp_die( 0 );
992
+	}
925 993
 
926 994
 	echo $return;
927 995
 
@@ -940,35 +1008,41 @@  discard block
 block discarded – undo
940 1008
  */
941 1009
 function wp_ajax_get_comments( $action ) {
942 1010
 	global $wp_list_table, $post_id;
943
-	if ( empty( $action ) )
944
-		$action = 'get-comments';
1011
+	if ( empty( $action ) ) {
1012
+			$action = 'get-comments';
1013
+	}
945 1014
 
946 1015
 	check_ajax_referer( $action );
947 1016
 
948 1017
 	if ( empty( $post_id ) && ! empty( $_REQUEST['p'] ) ) {
949 1018
 		$id = absint( $_REQUEST['p'] );
950
-		if ( ! empty( $id ) )
951
-			$post_id = $id;
1019
+		if ( ! empty( $id ) ) {
1020
+					$post_id = $id;
1021
+		}
952 1022
 	}
953 1023
 
954
-	if ( empty( $post_id ) )
955
-		wp_die( -1 );
1024
+	if ( empty( $post_id ) ) {
1025
+			wp_die( -1 );
1026
+	}
956 1027
 
957 1028
 	$wp_list_table = _get_list_table( 'WP_Post_Comments_List_Table', array( 'screen' => 'edit-comments' ) );
958 1029
 
959
-	if ( ! current_user_can( 'edit_post', $post_id ) )
960
-		wp_die( -1 );
1030
+	if ( ! current_user_can( 'edit_post', $post_id ) ) {
1031
+			wp_die( -1 );
1032
+	}
961 1033
 
962 1034
 	$wp_list_table->prepare_items();
963 1035
 
964
-	if ( !$wp_list_table->has_items() )
965
-		wp_die( 1 );
1036
+	if ( !$wp_list_table->has_items() ) {
1037
+			wp_die( 1 );
1038
+	}
966 1039
 
967 1040
 	$x = new WP_Ajax_Response();
968 1041
 	ob_start();
969 1042
 	foreach ( $wp_list_table->items as $comment ) {
970
-		if ( ! current_user_can( 'edit_comment', $comment->comment_ID ) && 0 === $comment->comment_approved )
971
-			continue;
1043
+		if ( ! current_user_can( 'edit_comment', $comment->comment_ID ) && 0 === $comment->comment_approved ) {
1044
+					continue;
1045
+		}
972 1046
 		get_comment( $comment );
973 1047
 		$wp_list_table->single_row( $comment );
974 1048
 	}
@@ -992,23 +1066,27 @@  discard block
 block discarded – undo
992 1066
  */
993 1067
 function wp_ajax_replyto_comment( $action ) {
994 1068
 	global $wp_list_table;
995
-	if ( empty( $action ) )
996
-		$action = 'replyto-comment';
1069
+	if ( empty( $action ) ) {
1070
+			$action = 'replyto-comment';
1071
+	}
997 1072
 
998 1073
 	check_ajax_referer( $action, '_ajax_nonce-replyto-comment' );
999 1074
 
1000 1075
 	$comment_post_ID = (int) $_POST['comment_post_ID'];
1001 1076
 	$post = get_post( $comment_post_ID );
1002
-	if ( ! $post )
1003
-		wp_die( -1 );
1077
+	if ( ! $post ) {
1078
+			wp_die( -1 );
1079
+	}
1004 1080
 
1005
-	if ( !current_user_can( 'edit_post', $comment_post_ID ) )
1006
-		wp_die( -1 );
1081
+	if ( !current_user_can( 'edit_post', $comment_post_ID ) ) {
1082
+			wp_die( -1 );
1083
+	}
1007 1084
 
1008
-	if ( empty( $post->post_status ) )
1009
-		wp_die( 1 );
1010
-	elseif ( in_array($post->post_status, array('draft', 'pending', 'trash') ) )
1011
-		wp_die( __('ERROR: you are replying to a comment on a draft post.') );
1085
+	if ( empty( $post->post_status ) ) {
1086
+			wp_die( 1 );
1087
+	} elseif ( in_array($post->post_status, array('draft', 'pending', 'trash') ) ) {
1088
+			wp_die( __('ERROR: you are replying to a comment on a draft post.') );
1089
+	}
1012 1090
 
1013 1091
 	$user = wp_get_current_user();
1014 1092
 	if ( $user->exists() ) {
@@ -1019,8 +1097,9 @@  discard block
 block discarded – undo
1019 1097
 		$comment_content      = trim( $_POST['content'] );
1020 1098
 		$comment_type         = isset( $_POST['comment_type'] ) ? trim( $_POST['comment_type'] ) : '';
1021 1099
 		if ( current_user_can( 'unfiltered_html' ) ) {
1022
-			if ( ! isset( $_POST['_wp_unfiltered_html_comment'] ) )
1023
-				$_POST['_wp_unfiltered_html_comment'] = '';
1100
+			if ( ! isset( $_POST['_wp_unfiltered_html_comment'] ) ) {
1101
+							$_POST['_wp_unfiltered_html_comment'] = '';
1102
+			}
1024 1103
 
1025 1104
 			if ( wp_create_nonce( 'unfiltered-html-comment' ) != $_POST['_wp_unfiltered_html_comment'] ) {
1026 1105
 				kses_remove_filters(); // start with a clean slate
@@ -1031,12 +1110,14 @@  discard block
 block discarded – undo
1031 1110
 		wp_die( __( 'Sorry, you must be logged in to reply to a comment.' ) );
1032 1111
 	}
1033 1112
 
1034
-	if ( '' == $comment_content )
1035
-		wp_die( __( 'ERROR: please type a comment.' ) );
1113
+	if ( '' == $comment_content ) {
1114
+			wp_die( __( 'ERROR: please type a comment.' ) );
1115
+	}
1036 1116
 
1037 1117
 	$comment_parent = 0;
1038
-	if ( isset( $_POST['comment_ID'] ) )
1039
-		$comment_parent = absint( $_POST['comment_ID'] );
1118
+	if ( isset( $_POST['comment_ID'] ) ) {
1119
+			$comment_parent = absint( $_POST['comment_ID'] );
1120
+	}
1040 1121
 	$comment_auto_approved = false;
1041 1122
 	$commentdata = compact('comment_post_ID', 'comment_author', 'comment_author_email', 'comment_author_url', 'comment_content', 'comment_type', 'comment_parent', 'user_ID');
1042 1123
 
@@ -1049,14 +1130,17 @@  discard block
 block discarded – undo
1049 1130
 				wp_die( -1 );
1050 1131
 			}
1051 1132
 
1052
-			if ( wp_set_comment_status( $parent, 'approve' ) )
1053
-				$comment_auto_approved = true;
1133
+			if ( wp_set_comment_status( $parent, 'approve' ) ) {
1134
+							$comment_auto_approved = true;
1135
+			}
1054 1136
 		}
1055 1137
 	}
1056 1138
 
1057 1139
 	$comment_id = wp_new_comment( $commentdata );
1058 1140
 	$comment = get_comment($comment_id);
1059
-	if ( ! $comment ) wp_die( 1 );
1141
+	if ( ! $comment ) {
1142
+		wp_die( 1 );
1143
+	}
1060 1144
 
1061 1145
 	$position = ( isset($_POST['position']) && (int) $_POST['position'] ) ? (int) $_POST['position'] : '-1';
1062 1146
 
@@ -1117,14 +1201,17 @@  discard block
 block discarded – undo
1117 1201
 	check_ajax_referer( 'replyto-comment', '_ajax_nonce-replyto-comment' );
1118 1202
 
1119 1203
 	$comment_id = (int) $_POST['comment_ID'];
1120
-	if ( ! current_user_can( 'edit_comment', $comment_id ) )
1121
-		wp_die( -1 );
1204
+	if ( ! current_user_can( 'edit_comment', $comment_id ) ) {
1205
+			wp_die( -1 );
1206
+	}
1122 1207
 
1123
-	if ( '' == $_POST['content'] )
1124
-		wp_die( __( 'ERROR: please type a comment.' ) );
1208
+	if ( '' == $_POST['content'] ) {
1209
+			wp_die( __( 'ERROR: please type a comment.' ) );
1210
+	}
1125 1211
 
1126
-	if ( isset( $_POST['status'] ) )
1127
-		$_POST['comment_status'] = $_POST['status'];
1212
+	if ( isset( $_POST['status'] ) ) {
1213
+			$_POST['comment_status'] = $_POST['status'];
1214
+	}
1128 1215
 	edit_comment();
1129 1216
 
1130 1217
 	$position = ( isset($_POST['position']) && (int) $_POST['position']) ? (int) $_POST['position'] : '-1';
@@ -1132,8 +1219,9 @@  discard block
 block discarded – undo
1132 1219
 	$wp_list_table = _get_list_table( $checkbox ? 'WP_Comments_List_Table' : 'WP_Post_Comments_List_Table', array( 'screen' => 'edit-comments' ) );
1133 1220
 
1134 1221
 	$comment = get_comment( $comment_id );
1135
-	if ( empty( $comment->comment_ID ) )
1136
-		wp_die( -1 );
1222
+	if ( empty( $comment->comment_ID ) ) {
1223
+			wp_die( -1 );
1224
+	}
1137 1225
 
1138 1226
 	ob_start();
1139 1227
 	$wp_list_table->single_row( $comment );
@@ -1159,8 +1247,9 @@  discard block
 block discarded – undo
1159 1247
 function wp_ajax_add_menu_item() {
1160 1248
 	check_ajax_referer( 'add-menu_item', 'menu-settings-column-nonce' );
1161 1249
 
1162
-	if ( ! current_user_can( 'edit_theme_options' ) )
1163
-		wp_die( -1 );
1250
+	if ( ! current_user_can( 'edit_theme_options' ) ) {
1251
+			wp_die( -1 );
1252
+	}
1164 1253
 
1165 1254
 	require_once ABSPATH . 'wp-admin/includes/nav-menu.php';
1166 1255
 
@@ -1199,8 +1288,9 @@  discard block
 block discarded – undo
1199 1288
 	}
1200 1289
 
1201 1290
 	$item_ids = wp_save_nav_menu_items( 0, $menu_items_data );
1202
-	if ( is_wp_error( $item_ids ) )
1203
-		wp_die( 0 );
1291
+	if ( is_wp_error( $item_ids ) ) {
1292
+			wp_die( 0 );
1293
+	}
1204 1294
 
1205 1295
 	$menu_items = array();
1206 1296
 
@@ -1216,8 +1306,9 @@  discard block
 block discarded – undo
1216 1306
 	/** This filter is documented in wp-admin/includes/nav-menu.php */
1217 1307
 	$walker_class_name = apply_filters( 'wp_edit_nav_menu_walker', 'Walker_Nav_Menu_Edit', $_POST['menu'] );
1218 1308
 
1219
-	if ( ! class_exists( $walker_class_name ) )
1220
-		wp_die( 0 );
1309
+	if ( ! class_exists( $walker_class_name ) ) {
1310
+			wp_die( 0 );
1311
+	}
1221 1312
 
1222 1313
 	if ( ! empty( $menu_items ) ) {
1223 1314
 		$args = array(
@@ -1244,10 +1335,12 @@  discard block
 block discarded – undo
1244 1335
 	$post = get_post( $pid );
1245 1336
 
1246 1337
 	if ( isset($_POST['metakeyselect']) || isset($_POST['metakeyinput']) ) {
1247
-		if ( !current_user_can( 'edit_post', $pid ) )
1248
-			wp_die( -1 );
1249
-		if ( isset($_POST['metakeyselect']) && '#NONE#' == $_POST['metakeyselect'] && empty($_POST['metakeyinput']) )
1250
-			wp_die( 1 );
1338
+		if ( !current_user_can( 'edit_post', $pid ) ) {
1339
+					wp_die( -1 );
1340
+		}
1341
+		if ( isset($_POST['metakeyselect']) && '#NONE#' == $_POST['metakeyselect'] && empty($_POST['metakeyinput']) ) {
1342
+					wp_die( 1 );
1343
+		}
1251 1344
 
1252 1345
 		// If the post is an autodraft, save the post as a draft and then attempt to save the meta.
1253 1346
 		if ( $post->post_status == 'auto-draft' ) {
@@ -1269,8 +1362,9 @@  discard block
 block discarded – undo
1269 1362
 					$x->send();
1270 1363
 				}
1271 1364
 
1272
-				if ( !$mid = add_meta( $pid ) )
1273
-					wp_die( __( 'Please provide a custom field value.' ) );
1365
+				if ( !$mid = add_meta( $pid ) ) {
1366
+									wp_die( __( 'Please provide a custom field value.' ) );
1367
+				}
1274 1368
 			} else {
1275 1369
 				wp_die( 0 );
1276 1370
 			}
@@ -1292,19 +1386,26 @@  discard block
 block discarded – undo
1292 1386
 		$mid = (int) key( $_POST['meta'] );
1293 1387
 		$key = wp_unslash( $_POST['meta'][$mid]['key'] );
1294 1388
 		$value = wp_unslash( $_POST['meta'][$mid]['value'] );
1295
-		if ( '' == trim($key) )
1296
-			wp_die( __( 'Please provide a custom field name.' ) );
1297
-		if ( '' == trim($value) )
1298
-			wp_die( __( 'Please provide a custom field value.' ) );
1299
-		if ( ! $meta = get_metadata_by_mid( 'post', $mid ) )
1300
-			wp_die( 0 ); // if meta doesn't exist
1389
+		if ( '' == trim($key) ) {
1390
+					wp_die( __( 'Please provide a custom field name.' ) );
1391
+		}
1392
+		if ( '' == trim($value) ) {
1393
+					wp_die( __( 'Please provide a custom field value.' ) );
1394
+		}
1395
+		if ( ! $meta = get_metadata_by_mid( 'post', $mid ) ) {
1396
+					wp_die( 0 );
1397
+		}
1398
+		// if meta doesn't exist
1301 1399
 		if ( is_protected_meta( $meta->meta_key, 'post' ) || is_protected_meta( $key, 'post' ) ||
1302 1400
 			! current_user_can( 'edit_post_meta', $meta->post_id, $meta->meta_key ) ||
1303
-			! current_user_can( 'edit_post_meta', $meta->post_id, $key ) )
1304
-			wp_die( -1 );
1401
+			! current_user_can( 'edit_post_meta', $meta->post_id, $key ) ) {
1402
+					wp_die( -1 );
1403
+		}
1305 1404
 		if ( $meta->meta_value != $value || $meta->meta_key != $key ) {
1306
-			if ( !$u = update_metadata_by_mid( 'post', $mid, $value, $key ) )
1307
-				wp_die( 0 ); // We know meta exists; we also know it's unchanged (or DB error, in which case there are bigger problems).
1405
+			if ( !$u = update_metadata_by_mid( 'post', $mid, $value, $key ) ) {
1406
+							wp_die( 0 );
1407
+			}
1408
+			// We know meta exists; we also know it's unchanged (or DB error, in which case there are bigger problems).
1308 1409
 		}
1309 1410
 
1310 1411
 		$x = new WP_Ajax_Response( array(
@@ -1333,12 +1434,14 @@  discard block
 block discarded – undo
1333 1434
  */
1334 1435
 function wp_ajax_add_user( $action ) {
1335 1436
 	global $wp_list_table;
1336
-	if ( empty( $action ) )
1337
-		$action = 'add-user';
1437
+	if ( empty( $action ) ) {
1438
+			$action = 'add-user';
1439
+	}
1338 1440
 
1339 1441
 	check_ajax_referer( $action );
1340
-	if ( ! current_user_can('create_users') )
1341
-		wp_die( -1 );
1442
+	if ( ! current_user_can('create_users') ) {
1443
+			wp_die( -1 );
1444
+	}
1342 1445
 	if ( ! $user_id = edit_user() ) {
1343 1446
 		wp_die( 0 );
1344 1447
 	} elseif ( is_wp_error( $user_id ) ) {
@@ -1385,14 +1488,17 @@  discard block
 block discarded – undo
1385 1488
 
1386 1489
 	$page = isset( $_POST['page'] ) ? $_POST['page'] : '';
1387 1490
 
1388
-	if ( $page != sanitize_key( $page ) )
1389
-		wp_die( 0 );
1491
+	if ( $page != sanitize_key( $page ) ) {
1492
+			wp_die( 0 );
1493
+	}
1390 1494
 
1391
-	if ( ! $user = wp_get_current_user() )
1392
-		wp_die( -1 );
1495
+	if ( ! $user = wp_get_current_user() ) {
1496
+			wp_die( -1 );
1497
+	}
1393 1498
 
1394
-	if ( is_array($closed) )
1395
-		update_user_option($user->ID, "closedpostboxes_$page", $closed, true);
1499
+	if ( is_array($closed) ) {
1500
+			update_user_option($user->ID, "closedpostboxes_$page", $closed, true);
1501
+	}
1396 1502
 
1397 1503
 	if ( is_array($hidden) ) {
1398 1504
 		$hidden = array_diff( $hidden, array('submitdiv', 'linksubmitdiv', 'manage-menu', 'create-menu') ); // postboxes that are always shown
@@ -1411,11 +1517,13 @@  discard block
 block discarded – undo
1411 1517
 	check_ajax_referer( 'screen-options-nonce', 'screenoptionnonce' );
1412 1518
 	$page = isset( $_POST['page'] ) ? $_POST['page'] : '';
1413 1519
 
1414
-	if ( $page != sanitize_key( $page ) )
1415
-		wp_die( 0 );
1520
+	if ( $page != sanitize_key( $page ) ) {
1521
+			wp_die( 0 );
1522
+	}
1416 1523
 
1417
-	if ( ! $user = wp_get_current_user() )
1418
-		wp_die( -1 );
1524
+	if ( ! $user = wp_get_current_user() ) {
1525
+			wp_die( -1 );
1526
+	}
1419 1527
 
1420 1528
 	$hidden = ! empty( $_POST['hidden'] ) ? explode( ',', $_POST['hidden'] ) : array();
1421 1529
 	update_user_option( $user->ID, "manage{$page}columnshidden", $hidden, true );
@@ -1431,8 +1539,9 @@  discard block
 block discarded – undo
1431 1539
 function wp_ajax_update_welcome_panel() {
1432 1540
 	check_ajax_referer( 'welcome-panel-nonce', 'welcomepanelnonce' );
1433 1541
 
1434
-	if ( ! current_user_can( 'edit_theme_options' ) )
1435
-		wp_die( -1 );
1542
+	if ( ! current_user_can( 'edit_theme_options' ) ) {
1543
+			wp_die( -1 );
1544
+	}
1436 1545
 
1437 1546
 	update_user_meta( get_current_user_id(), 'show_welcome_panel', empty( $_POST['visible'] ) ? 0 : 1 );
1438 1547
 
@@ -1445,8 +1554,9 @@  discard block
 block discarded – undo
1445 1554
  * @since 3.1.0
1446 1555
  */
1447 1556
 function wp_ajax_menu_get_metabox() {
1448
-	if ( ! current_user_can( 'edit_theme_options' ) )
1449
-		wp_die( -1 );
1557
+	if ( ! current_user_can( 'edit_theme_options' ) ) {
1558
+			wp_die( -1 );
1559
+	}
1450 1560
 
1451 1561
 	require_once ABSPATH . 'wp-admin/includes/nav-menu.php';
1452 1562
 
@@ -1510,8 +1620,9 @@  discard block
 block discarded – undo
1510 1620
 	require(ABSPATH . WPINC . '/class-wp-editor.php');
1511 1621
 	$results = _WP_Editors::wp_link_query( $args );
1512 1622
 
1513
-	if ( ! isset( $results ) )
1514
-		wp_die( 0 );
1623
+	if ( ! isset( $results ) ) {
1624
+			wp_die( 0 );
1625
+	}
1515 1626
 
1516 1627
 	echo wp_json_encode( $results );
1517 1628
 	echo "\n";
@@ -1525,11 +1636,13 @@  discard block
 block discarded – undo
1525 1636
  * @since 3.1.0
1526 1637
  */
1527 1638
 function wp_ajax_menu_locations_save() {
1528
-	if ( ! current_user_can( 'edit_theme_options' ) )
1529
-		wp_die( -1 );
1639
+	if ( ! current_user_can( 'edit_theme_options' ) ) {
1640
+			wp_die( -1 );
1641
+	}
1530 1642
 	check_ajax_referer( 'add-menu_item', 'menu-settings-column-nonce' );
1531
-	if ( ! isset( $_POST['menu-locations'] ) )
1532
-		wp_die( 0 );
1643
+	if ( ! isset( $_POST['menu-locations'] ) ) {
1644
+			wp_die( 0 );
1645
+	}
1533 1646
 	set_theme_mod( 'nav_menu_locations', array_map( 'absint', $_POST['menu-locations'] ) );
1534 1647
 	wp_die( 1 );
1535 1648
 }
@@ -1544,22 +1657,27 @@  discard block
 block discarded – undo
1544 1657
 	$order = isset( $_POST['order'] ) ? (array) $_POST['order'] : false;
1545 1658
 	$page_columns = isset( $_POST['page_columns'] ) ? $_POST['page_columns'] : 'auto';
1546 1659
 
1547
-	if ( $page_columns != 'auto' )
1548
-		$page_columns = (int) $page_columns;
1660
+	if ( $page_columns != 'auto' ) {
1661
+			$page_columns = (int) $page_columns;
1662
+	}
1549 1663
 
1550 1664
 	$page = isset( $_POST['page'] ) ? $_POST['page'] : '';
1551 1665
 
1552
-	if ( $page != sanitize_key( $page ) )
1553
-		wp_die( 0 );
1666
+	if ( $page != sanitize_key( $page ) ) {
1667
+			wp_die( 0 );
1668
+	}
1554 1669
 
1555
-	if ( ! $user = wp_get_current_user() )
1556
-		wp_die( -1 );
1670
+	if ( ! $user = wp_get_current_user() ) {
1671
+			wp_die( -1 );
1672
+	}
1557 1673
 
1558
-	if ( $order )
1559
-		update_user_option($user->ID, "meta-box-order_$page", $order, true);
1674
+	if ( $order ) {
1675
+			update_user_option($user->ID, "meta-box-order_$page", $order, true);
1676
+	}
1560 1677
 
1561
-	if ( $page_columns )
1562
-		update_user_option($user->ID, "screen_layout_$page", $page_columns, true);
1678
+	if ( $page_columns ) {
1679
+			update_user_option($user->ID, "screen_layout_$page", $page_columns, true);
1680
+	}
1563 1681
 
1564 1682
 	wp_die( 1 );
1565 1683
 }
@@ -1570,8 +1688,9 @@  discard block
 block discarded – undo
1570 1688
  * @since 3.1.0
1571 1689
  */
1572 1690
 function wp_ajax_menu_quick_search() {
1573
-	if ( ! current_user_can( 'edit_theme_options' ) )
1574
-		wp_die( -1 );
1691
+	if ( ! current_user_can( 'edit_theme_options' ) ) {
1692
+			wp_die( -1 );
1693
+	}
1575 1694
 
1576 1695
 	require_once ABSPATH . 'wp-admin/includes/nav-menu.php';
1577 1696
 
@@ -1616,15 +1735,18 @@  discard block
 block discarded – undo
1616 1735
 
1617 1736
 	check_ajax_referer( 'inlineeditnonce', '_inline_edit' );
1618 1737
 
1619
-	if ( ! isset($_POST['post_ID']) || ! ( $post_ID = (int) $_POST['post_ID'] ) )
1620
-		wp_die();
1738
+	if ( ! isset($_POST['post_ID']) || ! ( $post_ID = (int) $_POST['post_ID'] ) ) {
1739
+			wp_die();
1740
+	}
1621 1741
 
1622 1742
 	if ( 'page' == $_POST['post_type'] ) {
1623
-		if ( ! current_user_can( 'edit_page', $post_ID ) )
1624
-			wp_die( __( 'Sorry, you are not allowed to edit this page.' ) );
1743
+		if ( ! current_user_can( 'edit_page', $post_ID ) ) {
1744
+					wp_die( __( 'Sorry, you are not allowed to edit this page.' ) );
1745
+		}
1625 1746
 	} else {
1626
-		if ( ! current_user_can( 'edit_post', $post_ID ) )
1627
-			wp_die( __( 'Sorry, you are not allowed to edit this post.' ) );
1747
+		if ( ! current_user_can( 'edit_post', $post_ID ) ) {
1748
+					wp_die( __( 'Sorry, you are not allowed to edit this post.' ) );
1749
+		}
1628 1750
 	}
1629 1751
 
1630 1752
 	if ( $last = wp_check_post_lock( $post_ID ) ) {
@@ -1647,8 +1769,9 @@  discard block
 block discarded – undo
1647 1769
 	// Rename.
1648 1770
 	$data['user_ID'] = get_current_user_id();
1649 1771
 
1650
-	if ( isset($data['post_parent']) )
1651
-		$data['parent_id'] = $data['post_parent'];
1772
+	if ( isset($data['post_parent']) ) {
1773
+			$data['parent_id'] = $data['post_parent'];
1774
+	}
1652 1775
 
1653 1776
 	// Status.
1654 1777
 	if ( isset( $data['keep_private'] ) && 'private' == $data['keep_private'] ) {
@@ -1658,10 +1781,12 @@  discard block
 block discarded – undo
1658 1781
 		$data['post_status'] = $data['_status'];
1659 1782
 	}
1660 1783
 
1661
-	if ( empty($data['comment_status']) )
1662
-		$data['comment_status'] = 'closed';
1663
-	if ( empty($data['ping_status']) )
1664
-		$data['ping_status'] = 'closed';
1784
+	if ( empty($data['comment_status']) ) {
1785
+			$data['comment_status'] = 'closed';
1786
+	}
1787
+	if ( empty($data['ping_status']) ) {
1788
+			$data['ping_status'] = 'closed';
1789
+	}
1665 1790
 
1666 1791
 	// Exclude terms from taxonomies that are not supposed to appear in Quick Edit.
1667 1792
 	if ( ! empty( $data['tax_input'] ) ) {
@@ -1718,16 +1843,19 @@  discard block
 block discarded – undo
1718 1843
 
1719 1844
 	$taxonomy = sanitize_key( $_POST['taxonomy'] );
1720 1845
 	$tax = get_taxonomy( $taxonomy );
1721
-	if ( ! $tax )
1722
-		wp_die( 0 );
1846
+	if ( ! $tax ) {
1847
+			wp_die( 0 );
1848
+	}
1723 1849
 
1724
-	if ( ! current_user_can( $tax->cap->edit_terms ) )
1725
-		wp_die( -1 );
1850
+	if ( ! current_user_can( $tax->cap->edit_terms ) ) {
1851
+			wp_die( -1 );
1852
+	}
1726 1853
 
1727 1854
 	$wp_list_table = _get_list_table( 'WP_Terms_List_Table', array( 'screen' => 'edit-' . $taxonomy ) );
1728 1855
 
1729
-	if ( ! isset($_POST['tax_ID']) || ! ( $id = (int) $_POST['tax_ID'] ) )
1730
-		wp_die( -1 );
1856
+	if ( ! isset($_POST['tax_ID']) || ! ( $id = (int) $_POST['tax_ID'] ) ) {
1857
+			wp_die( -1 );
1858
+	}
1731 1859
 
1732 1860
 	$tag = get_term( $id, $taxonomy );
1733 1861
 	$_POST['description'] = $tag->description;
@@ -1736,13 +1864,15 @@  discard block
 block discarded – undo
1736 1864
 	if ( $updated && !is_wp_error($updated) ) {
1737 1865
 		$tag = get_term( $updated['term_id'], $taxonomy );
1738 1866
 		if ( !$tag || is_wp_error( $tag ) ) {
1739
-			if ( is_wp_error($tag) && $tag->get_error_message() )
1740
-				wp_die( $tag->get_error_message() );
1867
+			if ( is_wp_error($tag) && $tag->get_error_message() ) {
1868
+							wp_die( $tag->get_error_message() );
1869
+			}
1741 1870
 			wp_die( __( 'Item not updated.' ) );
1742 1871
 		}
1743 1872
 	} else {
1744
-		if ( is_wp_error($updated) && $updated->get_error_message() )
1745
-			wp_die( $updated->get_error_message() );
1873
+		if ( is_wp_error($updated) && $updated->get_error_message() ) {
1874
+					wp_die( $updated->get_error_message() );
1875
+		}
1746 1876
 		wp_die( __( 'Item not updated.' ) );
1747 1877
 	}
1748 1878
 	$level = 0;
@@ -1775,8 +1905,9 @@  discard block
 block discarded – undo
1775 1905
 		'post_status' => 'any',
1776 1906
 		'posts_per_page' => 50,
1777 1907
 	);
1778
-	if ( '' !== $s )
1779
-		$args['s'] = $s;
1908
+	if ( '' !== $s ) {
1909
+			$args['s'] = $s;
1910
+	}
1780 1911
 
1781 1912
 	$posts = get_posts( $args );
1782 1913
 
@@ -1830,8 +1961,9 @@  discard block
 block discarded – undo
1830 1961
 function wp_ajax_widgets_order() {
1831 1962
 	check_ajax_referer( 'save-sidebar-widgets', 'savewidgets' );
1832 1963
 
1833
-	if ( !current_user_can('edit_theme_options') )
1834
-		wp_die( -1 );
1964
+	if ( !current_user_can('edit_theme_options') ) {
1965
+			wp_die( -1 );
1966
+	}
1835 1967
 
1836 1968
 	unset( $_POST['savewidgets'], $_POST['action'] );
1837 1969
 
@@ -1843,8 +1975,9 @@  discard block
 block discarded – undo
1843 1975
 			if ( !empty($val) ) {
1844 1976
 				$val = explode(',', $val);
1845 1977
 				foreach ( $val as $k => $v ) {
1846
-					if ( strpos($v, 'widget-') === false )
1847
-						continue;
1978
+					if ( strpos($v, 'widget-') === false ) {
1979
+											continue;
1980
+					}
1848 1981
 
1849 1982
 					$sb[$k] = substr($v, strpos($v, '_') + 1);
1850 1983
 				}
@@ -1872,8 +2005,9 @@  discard block
 block discarded – undo
1872 2005
 
1873 2006
 	check_ajax_referer( 'save-sidebar-widgets', 'savewidgets' );
1874 2007
 
1875
-	if ( !current_user_can('edit_theme_options') || !isset($_POST['id_base']) )
1876
-		wp_die( -1 );
2008
+	if ( !current_user_can('edit_theme_options') || !isset($_POST['id_base']) ) {
2009
+			wp_die( -1 );
2010
+	}
1877 2011
 
1878 2012
 	unset( $_POST['savewidgets'], $_POST['action'] );
1879 2013
 
@@ -1907,8 +2041,9 @@  discard block
 block discarded – undo
1907 2041
 	// Delete.
1908 2042
 	if ( isset($_POST['delete_widget']) && $_POST['delete_widget'] ) {
1909 2043
 
1910
-		if ( !isset($wp_registered_widgets[$widget_id]) )
1911
-			wp_die( $error );
2044
+		if ( !isset($wp_registered_widgets[$widget_id]) ) {
2045
+					wp_die( $error );
2046
+		}
1912 2047
 
1913 2048
 		$sidebar = array_diff( $sidebar, array($widget_id) );
1914 2049
 		$_POST = array('sidebar' => $sidebar_id, 'widget-' . $id_base => array(), 'the-widget-id' => $widget_id, 'delete_widget' => '1');
@@ -1917,8 +2052,9 @@  discard block
 block discarded – undo
1917 2052
 		do_action( 'delete_widget', $widget_id, $sidebar_id, $id_base );
1918 2053
 
1919 2054
 	} elseif ( $settings && preg_match( '/__i__|%i%/', key($settings) ) ) {
1920
-		if ( !$multi_number )
1921
-			wp_die( $error );
2055
+		if ( !$multi_number ) {
2056
+					wp_die( $error );
2057
+		}
1922 2058
 
1923 2059
 		$_POST[ 'widget-' . $id_base ] = array( $multi_number => reset( $settings ) );
1924 2060
 		$widget_id = $id_base . '-' . $multi_number;
@@ -1929,8 +2065,9 @@  discard block
 block discarded – undo
1929 2065
 	foreach ( (array) $wp_registered_widget_updates as $name => $control ) {
1930 2066
 
1931 2067
 		if ( $name == $id_base ) {
1932
-			if ( !is_callable( $control['callback'] ) )
1933
-				continue;
2068
+			if ( !is_callable( $control['callback'] ) ) {
2069
+							continue;
2070
+			}
1934 2071
 
1935 2072
 			ob_start();
1936 2073
 				call_user_func_array( $control['callback'], $control['params'] );
@@ -1946,11 +2083,13 @@  discard block
 block discarded – undo
1946 2083
 		wp_die();
1947 2084
 	}
1948 2085
 
1949
-	if ( !empty($_POST['add_new']) )
1950
-		wp_die();
2086
+	if ( !empty($_POST['add_new']) ) {
2087
+			wp_die();
2088
+	}
1951 2089
 
1952
-	if ( $form = $wp_registered_widget_controls[$widget_id] )
1953
-		call_user_func_array( $form['callback'], $form['params'] );
2090
+	if ( $form = $wp_registered_widget_controls[$widget_id] ) {
2091
+			call_user_func_array( $form['callback'], $form['params'] );
2092
+	}
1954 2093
 
1955 2094
 	wp_die();
1956 2095
 }
@@ -2077,15 +2216,18 @@  discard block
 block discarded – undo
2077 2216
 	}
2078 2217
 
2079 2218
 	if ( isset( $post_data['context'] ) && isset( $post_data['theme'] ) ) {
2080
-		if ( 'custom-background' === $post_data['context'] )
2081
-			update_post_meta( $attachment_id, '_wp_attachment_is_custom_background', $post_data['theme'] );
2219
+		if ( 'custom-background' === $post_data['context'] ) {
2220
+					update_post_meta( $attachment_id, '_wp_attachment_is_custom_background', $post_data['theme'] );
2221
+		}
2082 2222
 
2083
-		if ( 'custom-header' === $post_data['context'] )
2084
-			update_post_meta( $attachment_id, '_wp_attachment_is_custom_header', $post_data['theme'] );
2223
+		if ( 'custom-header' === $post_data['context'] ) {
2224
+					update_post_meta( $attachment_id, '_wp_attachment_is_custom_header', $post_data['theme'] );
2225
+		}
2085 2226
 	}
2086 2227
 
2087
-	if ( ! $attachment = wp_prepare_attachment_for_js( $attachment_id ) )
2088
-		wp_die();
2228
+	if ( ! $attachment = wp_prepare_attachment_for_js( $attachment_id ) ) {
2229
+			wp_die();
2230
+	}
2089 2231
 
2090 2232
 	echo wp_json_encode( array(
2091 2233
 		'success' => true,
@@ -2102,8 +2244,9 @@  discard block
 block discarded – undo
2102 2244
  */
2103 2245
 function wp_ajax_image_editor() {
2104 2246
 	$attachment_id = intval($_POST['postid']);
2105
-	if ( empty($attachment_id) || !current_user_can('edit_post', $attachment_id) )
2106
-		wp_die( -1 );
2247
+	if ( empty($attachment_id) || !current_user_can('edit_post', $attachment_id) ) {
2248
+			wp_die( -1 );
2249
+	}
2107 2250
 
2108 2251
 	check_ajax_referer( "image_editor-$attachment_id" );
2109 2252
 	include_once( ABSPATH . 'wp-admin/includes/image-edit.php' );
@@ -2136,15 +2279,17 @@  discard block
 block discarded – undo
2136 2279
 	$json = ! empty( $_REQUEST['json'] ); // New-style request
2137 2280
 
2138 2281
 	$post_ID = intval( $_POST['post_id'] );
2139
-	if ( ! current_user_can( 'edit_post', $post_ID ) )
2140
-		wp_die( -1 );
2282
+	if ( ! current_user_can( 'edit_post', $post_ID ) ) {
2283
+			wp_die( -1 );
2284
+	}
2141 2285
 
2142 2286
 	$thumbnail_id = intval( $_POST['thumbnail_id'] );
2143 2287
 
2144
-	if ( $json )
2145
-		check_ajax_referer( "update-post_$post_ID" );
2146
-	else
2147
-		check_ajax_referer( "set_post_thumbnail-$post_ID" );
2288
+	if ( $json ) {
2289
+			check_ajax_referer( "update-post_$post_ID" );
2290
+	} else {
2291
+			check_ajax_referer( "set_post_thumbnail-$post_ID" );
2292
+	}
2148 2293
 
2149 2294
 	if ( $thumbnail_id == '-1' ) {
2150 2295
 		if ( delete_post_thumbnail( $post_ID ) ) {
@@ -2268,8 +2413,9 @@  discard block
 block discarded – undo
2268 2413
 
2269 2414
 	$post = null;
2270 2415
 
2271
-	if ( $post_id )
2272
-		$post = get_post( $post_id );
2416
+	if ( $post_id ) {
2417
+			$post = get_post( $post_id );
2418
+	}
2273 2419
 
2274 2420
 	check_ajax_referer('update-post_' . $post_id, '_wpnonce');
2275 2421
 
@@ -2303,20 +2449,24 @@  discard block
 block discarded – undo
2303 2449
  * @since 3.1.0
2304 2450
  */
2305 2451
 function wp_ajax_wp_remove_post_lock() {
2306
-	if ( empty( $_POST['post_ID'] ) || empty( $_POST['active_post_lock'] ) )
2307
-		wp_die( 0 );
2452
+	if ( empty( $_POST['post_ID'] ) || empty( $_POST['active_post_lock'] ) ) {
2453
+			wp_die( 0 );
2454
+	}
2308 2455
 	$post_id = (int) $_POST['post_ID'];
2309
-	if ( ! $post = get_post( $post_id ) )
2310
-		wp_die( 0 );
2456
+	if ( ! $post = get_post( $post_id ) ) {
2457
+			wp_die( 0 );
2458
+	}
2311 2459
 
2312 2460
 	check_ajax_referer( 'update-post_' . $post_id );
2313 2461
 
2314
-	if ( ! current_user_can( 'edit_post', $post_id ) )
2315
-		wp_die( -1 );
2462
+	if ( ! current_user_can( 'edit_post', $post_id ) ) {
2463
+			wp_die( -1 );
2464
+	}
2316 2465
 
2317 2466
 	$active_lock = array_map( 'absint', explode( ':', $_POST['active_post_lock'] ) );
2318
-	if ( $active_lock[1] != get_current_user_id() )
2319
-		wp_die( 0 );
2467
+	if ( $active_lock[1] != get_current_user_id() ) {
2468
+			wp_die( 0 );
2469
+	}
2320 2470
 
2321 2471
 	/**
2322 2472
 	 * Filters the post lock window duration.
@@ -2338,15 +2488,17 @@  discard block
 block discarded – undo
2338 2488
  */
2339 2489
 function wp_ajax_dismiss_wp_pointer() {
2340 2490
 	$pointer = $_POST['pointer'];
2341
-	if ( $pointer != sanitize_key( $pointer ) )
2342
-		wp_die( 0 );
2491
+	if ( $pointer != sanitize_key( $pointer ) ) {
2492
+			wp_die( 0 );
2493
+	}
2343 2494
 
2344 2495
 //	check_ajax_referer( 'dismiss-pointer_' . $pointer );
2345 2496
 
2346 2497
 	$dismissed = array_filter( explode( ',', (string) get_user_meta( get_current_user_id(), 'dismissed_wp_pointers', true ) ) );
2347 2498
 
2348
-	if ( in_array( $pointer, $dismissed ) )
2349
-		wp_die( 0 );
2499
+	if ( in_array( $pointer, $dismissed ) ) {
2500
+			wp_die( 0 );
2501
+	}
2350 2502
 
2351 2503
 	$dismissed[] = $pointer;
2352 2504
 	$dismissed = implode( ',', $dismissed );
@@ -2361,23 +2513,29 @@  discard block
 block discarded – undo
2361 2513
  * @since 3.5.0
2362 2514
  */
2363 2515
 function wp_ajax_get_attachment() {
2364
-	if ( ! isset( $_REQUEST['id'] ) )
2365
-		wp_send_json_error();
2516
+	if ( ! isset( $_REQUEST['id'] ) ) {
2517
+			wp_send_json_error();
2518
+	}
2366 2519
 
2367
-	if ( ! $id = absint( $_REQUEST['id'] ) )
2368
-		wp_send_json_error();
2520
+	if ( ! $id = absint( $_REQUEST['id'] ) ) {
2521
+			wp_send_json_error();
2522
+	}
2369 2523
 
2370
-	if ( ! $post = get_post( $id ) )
2371
-		wp_send_json_error();
2524
+	if ( ! $post = get_post( $id ) ) {
2525
+			wp_send_json_error();
2526
+	}
2372 2527
 
2373
-	if ( 'attachment' != $post->post_type )
2374
-		wp_send_json_error();
2528
+	if ( 'attachment' != $post->post_type ) {
2529
+			wp_send_json_error();
2530
+	}
2375 2531
 
2376
-	if ( ! current_user_can( 'upload_files' ) )
2377
-		wp_send_json_error();
2532
+	if ( ! current_user_can( 'upload_files' ) ) {
2533
+			wp_send_json_error();
2534
+	}
2378 2535
 
2379
-	if ( ! $attachment = wp_prepare_attachment_for_js( $id ) )
2380
-		wp_send_json_error();
2536
+	if ( ! $attachment = wp_prepare_attachment_for_js( $id ) ) {
2537
+			wp_send_json_error();
2538
+	}
2381 2539
 
2382 2540
 	wp_send_json_success( $attachment );
2383 2541
 }
@@ -2388,8 +2546,9 @@  discard block
 block discarded – undo
2388 2546
  * @since 3.5.0
2389 2547
  */
2390 2548
 function wp_ajax_query_attachments() {
2391
-	if ( ! current_user_can( 'upload_files' ) )
2392
-		wp_send_json_error();
2549
+	if ( ! current_user_can( 'upload_files' ) ) {
2550
+			wp_send_json_error();
2551
+	}
2393 2552
 
2394 2553
 	$query = isset( $_REQUEST['query'] ) ? (array) $_REQUEST['query'] : array();
2395 2554
 	$keys = array(
@@ -2412,8 +2571,9 @@  discard block
 block discarded – undo
2412 2571
 		$query['post_status'] = 'inherit';
2413 2572
 	}
2414 2573
 
2415
-	if ( current_user_can( get_post_type_object( 'attachment' )->cap->read_private_posts ) )
2416
-		$query['post_status'] .= ',private';
2574
+	if ( current_user_can( get_post_type_object( 'attachment' )->cap->read_private_posts ) ) {
2575
+			$query['post_status'] .= ',private';
2576
+	}
2417 2577
 
2418 2578
 	/**
2419 2579
 	 * Filters the arguments passed to WP_Query during an Ajax
@@ -2440,37 +2600,46 @@  discard block
 block discarded – undo
2440 2600
  * @since 3.5.0
2441 2601
  */
2442 2602
 function wp_ajax_save_attachment() {
2443
-	if ( ! isset( $_REQUEST['id'] ) || ! isset( $_REQUEST['changes'] ) )
2444
-		wp_send_json_error();
2603
+	if ( ! isset( $_REQUEST['id'] ) || ! isset( $_REQUEST['changes'] ) ) {
2604
+			wp_send_json_error();
2605
+	}
2445 2606
 
2446
-	if ( ! $id = absint( $_REQUEST['id'] ) )
2447
-		wp_send_json_error();
2607
+	if ( ! $id = absint( $_REQUEST['id'] ) ) {
2608
+			wp_send_json_error();
2609
+	}
2448 2610
 
2449 2611
 	check_ajax_referer( 'update-post_' . $id, 'nonce' );
2450 2612
 
2451
-	if ( ! current_user_can( 'edit_post', $id ) )
2452
-		wp_send_json_error();
2613
+	if ( ! current_user_can( 'edit_post', $id ) ) {
2614
+			wp_send_json_error();
2615
+	}
2453 2616
 
2454 2617
 	$changes = $_REQUEST['changes'];
2455 2618
 	$post    = get_post( $id, ARRAY_A );
2456 2619
 
2457
-	if ( 'attachment' != $post['post_type'] )
2458
-		wp_send_json_error();
2620
+	if ( 'attachment' != $post['post_type'] ) {
2621
+			wp_send_json_error();
2622
+	}
2459 2623
 
2460
-	if ( isset( $changes['parent'] ) )
2461
-		$post['post_parent'] = $changes['parent'];
2624
+	if ( isset( $changes['parent'] ) ) {
2625
+			$post['post_parent'] = $changes['parent'];
2626
+	}
2462 2627
 
2463
-	if ( isset( $changes['title'] ) )
2464
-		$post['post_title'] = $changes['title'];
2628
+	if ( isset( $changes['title'] ) ) {
2629
+			$post['post_title'] = $changes['title'];
2630
+	}
2465 2631
 
2466
-	if ( isset( $changes['caption'] ) )
2467
-		$post['post_excerpt'] = $changes['caption'];
2632
+	if ( isset( $changes['caption'] ) ) {
2633
+			$post['post_excerpt'] = $changes['caption'];
2634
+	}
2468 2635
 
2469
-	if ( isset( $changes['description'] ) )
2470
-		$post['post_content'] = $changes['description'];
2636
+	if ( isset( $changes['description'] ) ) {
2637
+			$post['post_content'] = $changes['description'];
2638
+	}
2471 2639
 
2472
-	if ( MEDIA_TRASH && isset( $changes['status'] ) )
2473
-		$post['post_status'] = $changes['status'];
2640
+	if ( MEDIA_TRASH && isset( $changes['status'] ) ) {
2641
+			$post['post_status'] = $changes['status'];
2642
+	}
2474 2643
 
2475 2644
 	if ( isset( $changes['alt'] ) ) {
2476 2645
 		$alt = wp_unslash( $changes['alt'] );
@@ -2514,25 +2683,30 @@  discard block
 block discarded – undo
2514 2683
  * @since 3.5.0
2515 2684
  */
2516 2685
 function wp_ajax_save_attachment_compat() {
2517
-	if ( ! isset( $_REQUEST['id'] ) )
2518
-		wp_send_json_error();
2686
+	if ( ! isset( $_REQUEST['id'] ) ) {
2687
+			wp_send_json_error();
2688
+	}
2519 2689
 
2520
-	if ( ! $id = absint( $_REQUEST['id'] ) )
2521
-		wp_send_json_error();
2690
+	if ( ! $id = absint( $_REQUEST['id'] ) ) {
2691
+			wp_send_json_error();
2692
+	}
2522 2693
 
2523
-	if ( empty( $_REQUEST['attachments'] ) || empty( $_REQUEST['attachments'][ $id ] ) )
2524
-		wp_send_json_error();
2694
+	if ( empty( $_REQUEST['attachments'] ) || empty( $_REQUEST['attachments'][ $id ] ) ) {
2695
+			wp_send_json_error();
2696
+	}
2525 2697
 	$attachment_data = $_REQUEST['attachments'][ $id ];
2526 2698
 
2527 2699
 	check_ajax_referer( 'update-post_' . $id, 'nonce' );
2528 2700
 
2529
-	if ( ! current_user_can( 'edit_post', $id ) )
2530
-		wp_send_json_error();
2701
+	if ( ! current_user_can( 'edit_post', $id ) ) {
2702
+			wp_send_json_error();
2703
+	}
2531 2704
 
2532 2705
 	$post = get_post( $id, ARRAY_A );
2533 2706
 
2534
-	if ( 'attachment' != $post['post_type'] )
2535
-		wp_send_json_error();
2707
+	if ( 'attachment' != $post['post_type'] ) {
2708
+			wp_send_json_error();
2709
+	}
2536 2710
 
2537 2711
 	/** This filter is documented in wp-admin/includes/media.php */
2538 2712
 	$post = apply_filters( 'attachment_fields_to_save', $post, $attachment_data );
@@ -2545,12 +2719,14 @@  discard block
 block discarded – undo
2545 2719
 	wp_update_post( $post );
2546 2720
 
2547 2721
 	foreach ( get_attachment_taxonomies( $post ) as $taxonomy ) {
2548
-		if ( isset( $attachment_data[ $taxonomy ] ) )
2549
-			wp_set_object_terms( $id, array_map( 'trim', preg_split( '/,+/', $attachment_data[ $taxonomy ] ) ), $taxonomy, false );
2722
+		if ( isset( $attachment_data[ $taxonomy ] ) ) {
2723
+					wp_set_object_terms( $id, array_map( 'trim', preg_split( '/,+/', $attachment_data[ $taxonomy ] ) ), $taxonomy, false );
2724
+		}
2550 2725
 	}
2551 2726
 
2552
-	if ( ! $attachment = wp_prepare_attachment_for_js( $id ) )
2553
-		wp_send_json_error();
2727
+	if ( ! $attachment = wp_prepare_attachment_for_js( $id ) ) {
2728
+			wp_send_json_error();
2729
+	}
2554 2730
 
2555 2731
 	wp_send_json_success( $attachment );
2556 2732
 }
@@ -2561,29 +2737,36 @@  discard block
 block discarded – undo
2561 2737
  * @since 3.5.0
2562 2738
  */
2563 2739
 function wp_ajax_save_attachment_order() {
2564
-	if ( ! isset( $_REQUEST['post_id'] ) )
2565
-		wp_send_json_error();
2740
+	if ( ! isset( $_REQUEST['post_id'] ) ) {
2741
+			wp_send_json_error();
2742
+	}
2566 2743
 
2567
-	if ( ! $post_id = absint( $_REQUEST['post_id'] ) )
2568
-		wp_send_json_error();
2744
+	if ( ! $post_id = absint( $_REQUEST['post_id'] ) ) {
2745
+			wp_send_json_error();
2746
+	}
2569 2747
 
2570
-	if ( empty( $_REQUEST['attachments'] ) )
2571
-		wp_send_json_error();
2748
+	if ( empty( $_REQUEST['attachments'] ) ) {
2749
+			wp_send_json_error();
2750
+	}
2572 2751
 
2573 2752
 	check_ajax_referer( 'update-post_' . $post_id, 'nonce' );
2574 2753
 
2575 2754
 	$attachments = $_REQUEST['attachments'];
2576 2755
 
2577
-	if ( ! current_user_can( 'edit_post', $post_id ) )
2578
-		wp_send_json_error();
2756
+	if ( ! current_user_can( 'edit_post', $post_id ) ) {
2757
+			wp_send_json_error();
2758
+	}
2579 2759
 
2580 2760
 	foreach ( $attachments as $attachment_id => $menu_order ) {
2581
-		if ( ! current_user_can( 'edit_post', $attachment_id ) )
2582
-			continue;
2583
-		if ( ! $attachment = get_post( $attachment_id ) )
2584
-			continue;
2585
-		if ( 'attachment' != $attachment->post_type )
2586
-			continue;
2761
+		if ( ! current_user_can( 'edit_post', $attachment_id ) ) {
2762
+					continue;
2763
+		}
2764
+		if ( ! $attachment = get_post( $attachment_id ) ) {
2765
+					continue;
2766
+		}
2767
+		if ( 'attachment' != $attachment->post_type ) {
2768
+					continue;
2769
+		}
2587 2770
 
2588 2771
 		wp_update_post( array( 'ID' => $attachment_id, 'menu_order' => $menu_order ) );
2589 2772
 	}
@@ -2607,11 +2790,13 @@  discard block
 block discarded – undo
2607 2790
 
2608 2791
 	$id = intval( $attachment['id'] );
2609 2792
 
2610
-	if ( ! $post = get_post( $id ) )
2611
-		wp_send_json_error();
2793
+	if ( ! $post = get_post( $id ) ) {
2794
+			wp_send_json_error();
2795
+	}
2612 2796
 
2613
-	if ( 'attachment' != $post->post_type )
2614
-		wp_send_json_error();
2797
+	if ( 'attachment' != $post->post_type ) {
2798
+			wp_send_json_error();
2799
+	}
2615 2800
 
2616 2801
 	if ( current_user_can( 'edit_post', $id ) ) {
2617 2802
 		// If this attachment is unattached, attach it. Primarily a back compat thing.
@@ -2675,17 +2860,21 @@  discard block
 block discarded – undo
2675 2860
 
2676 2861
 	check_ajax_referer( 'media-send-to-editor', 'nonce' );
2677 2862
 
2678
-	if ( ! $src = wp_unslash( $_POST['src'] ) )
2679
-		wp_send_json_error();
2863
+	if ( ! $src = wp_unslash( $_POST['src'] ) ) {
2864
+			wp_send_json_error();
2865
+	}
2680 2866
 
2681
-	if ( ! strpos( $src, '://' ) )
2682
-		$src = 'http://' . $src;
2867
+	if ( ! strpos( $src, '://' ) ) {
2868
+			$src = 'http://' . $src;
2869
+	}
2683 2870
 
2684
-	if ( ! $src = esc_url_raw( $src ) )
2685
-		wp_send_json_error();
2871
+	if ( ! $src = esc_url_raw( $src ) ) {
2872
+			wp_send_json_error();
2873
+	}
2686 2874
 
2687
-	if ( ! $link_text = trim( wp_unslash( $_POST['link_text'] ) ) )
2688
-		$link_text = wp_basename( $src );
2875
+	if ( ! $link_text = trim( wp_unslash( $_POST['link_text'] ) ) ) {
2876
+			$link_text = wp_basename( $src );
2877
+	}
2689 2878
 
2690 2879
 	$post = get_post( isset( $_POST['post_id'] ) ? $_POST['post_id'] : 0 );
2691 2880
 
@@ -2707,8 +2896,9 @@  discard block
 block discarded – undo
2707 2896
 	// Figure out what filter to run:
2708 2897
 	$type = 'file';
2709 2898
 	if ( ( $ext = preg_replace( '/^.+?\.([^.]+)$/', '$1', $src ) ) && ( $ext_type = wp_ext2type( $ext ) )
2710
-		&& ( 'audio' == $ext_type || 'video' == $ext_type ) )
2711
-			$type = $ext_type;
2899
+		&& ( 'audio' == $ext_type || 'video' == $ext_type ) ) {
2900
+				$type = $ext_type;
2901
+	}
2712 2902
 
2713 2903
 	/** This filter is documented in wp-admin/includes/media.php */
2714 2904
 	$html = apply_filters( $type . '_send_to_editor_url', $html, $src, $link_text );
@@ -2801,15 +2991,18 @@  discard block
 block discarded – undo
2801 2991
 function wp_ajax_get_revision_diffs() {
2802 2992
 	require ABSPATH . 'wp-admin/includes/revision.php';
2803 2993
 
2804
-	if ( ! $post = get_post( (int) $_REQUEST['post_id'] ) )
2805
-		wp_send_json_error();
2994
+	if ( ! $post = get_post( (int) $_REQUEST['post_id'] ) ) {
2995
+			wp_send_json_error();
2996
+	}
2806 2997
 
2807
-	if ( ! current_user_can( 'edit_post', $post->ID ) )
2808
-		wp_send_json_error();
2998
+	if ( ! current_user_can( 'edit_post', $post->ID ) ) {
2999
+			wp_send_json_error();
3000
+	}
2809 3001
 
2810 3002
 	// Really just pre-loading the cache here.
2811
-	if ( ! $revisions = wp_get_post_revisions( $post->ID, array( 'check_enabled' => false ) ) )
2812
-		wp_send_json_error();
3003
+	if ( ! $revisions = wp_get_post_revisions( $post->ID, array( 'check_enabled' => false ) ) ) {
3004
+			wp_send_json_error();
3005
+	}
2813 3006
 
2814 3007
 	$return = array();
2815 3008
 	@set_time_limit( 0 );
Please login to merge, or discard this patch.
src/wp-admin/includes/screen.php 1 patch
Spacing   +44 added lines, -44 removed lines patch added patch discarded remove patch
@@ -16,13 +16,13 @@  discard block
 block discarded – undo
16 16
  * @param string|WP_Screen $screen The screen you want the headers for
17 17
  * @return array Containing the headers in the format id => UI String
18 18
  */
19
-function get_column_headers( $screen ) {
20
-	if ( is_string( $screen ) )
21
-		$screen = convert_to_screen( $screen );
19
+function get_column_headers($screen) {
20
+	if (is_string($screen))
21
+		$screen = convert_to_screen($screen);
22 22
 
23 23
 	static $column_headers = array();
24 24
 
25
-	if ( ! isset( $column_headers[ $screen->id ] ) ) {
25
+	if ( ! isset($column_headers[$screen->id])) {
26 26
 
27 27
 		/**
28 28
 		 * Filters the column headers for a list table on a specific screen.
@@ -36,10 +36,10 @@  discard block
 block discarded – undo
36 36
 		 *
37 37
 		 * @param array $columns An array of column headers. Default empty.
38 38
 		 */
39
-		$column_headers[ $screen->id ] = apply_filters( "manage_{$screen->id}_columns", array() );
39
+		$column_headers[$screen->id] = apply_filters("manage_{$screen->id}_columns", array());
40 40
 	}
41 41
 
42
-	return $column_headers[ $screen->id ];
42
+	return $column_headers[$screen->id];
43 43
 }
44 44
 
45 45
 /**
@@ -50,16 +50,16 @@  discard block
 block discarded – undo
50 50
  * @param string|WP_Screen $screen The screen you want the hidden columns for
51 51
  * @return array
52 52
  */
53
-function get_hidden_columns( $screen ) {
54
-	if ( is_string( $screen ) ) {
55
-		$screen = convert_to_screen( $screen );
53
+function get_hidden_columns($screen) {
54
+	if (is_string($screen)) {
55
+		$screen = convert_to_screen($screen);
56 56
 	}
57 57
 
58
-	$hidden = get_user_option( 'manage' . $screen->id . 'columnshidden' );
58
+	$hidden = get_user_option('manage'.$screen->id.'columnshidden');
59 59
 
60
-	$use_defaults = ! is_array( $hidden );
60
+	$use_defaults = ! is_array($hidden);
61 61
 
62
-	if ( $use_defaults ) {
62
+	if ($use_defaults) {
63 63
 		$hidden = array();
64 64
 
65 65
 		/**
@@ -70,7 +70,7 @@  discard block
 block discarded – undo
70 70
 		 * @param array     $hidden An array of columns hidden by default.
71 71
 		 * @param WP_Screen $screen WP_Screen object of the current screen.
72 72
 		 */
73
-		$hidden = apply_filters( 'default_hidden_columns', $hidden, $screen );
73
+		$hidden = apply_filters('default_hidden_columns', $hidden, $screen);
74 74
 	}
75 75
 
76 76
 	/**
@@ -83,7 +83,7 @@  discard block
 block discarded – undo
83 83
 	 * @param WP_Screen $screen WP_Screen object of the current screen.
84 84
 	 * @param bool      $use_defaults Whether to show the default columns.
85 85
 	 */
86
-	return apply_filters( 'hidden_columns', $hidden, $screen, $use_defaults );
86
+	return apply_filters('hidden_columns', $hidden, $screen, $use_defaults);
87 87
 }
88 88
 
89 89
 /**
@@ -95,39 +95,39 @@  discard block
 block discarded – undo
95 95
  *
96 96
  * @param WP_Screen $screen
97 97
  */
98
-function meta_box_prefs( $screen ) {
98
+function meta_box_prefs($screen) {
99 99
 	global $wp_meta_boxes;
100 100
 
101
-	if ( is_string( $screen ) )
102
-		$screen = convert_to_screen( $screen );
101
+	if (is_string($screen))
102
+		$screen = convert_to_screen($screen);
103 103
 
104
-	if ( empty($wp_meta_boxes[$screen->id]) )
104
+	if (empty($wp_meta_boxes[$screen->id]))
105 105
 		return;
106 106
 
107 107
 	$hidden = get_hidden_meta_boxes($screen);
108 108
 
109
-	foreach ( array_keys( $wp_meta_boxes[ $screen->id ] ) as $context ) {
110
-		foreach ( array( 'high', 'core', 'default', 'low' ) as $priority ) {
111
-			if ( ! isset( $wp_meta_boxes[ $screen->id ][ $context ][ $priority ] ) ) {
109
+	foreach (array_keys($wp_meta_boxes[$screen->id]) as $context) {
110
+		foreach (array('high', 'core', 'default', 'low') as $priority) {
111
+			if ( ! isset($wp_meta_boxes[$screen->id][$context][$priority])) {
112 112
 				continue;
113 113
 			}
114
-			foreach ( $wp_meta_boxes[ $screen->id ][ $context ][ $priority ] as $box ) {
115
-				if ( false == $box || ! $box['title'] )
114
+			foreach ($wp_meta_boxes[$screen->id][$context][$priority] as $box) {
115
+				if (false == $box || ! $box['title'])
116 116
 					continue;
117 117
 				// Submit box cannot be hidden
118
-				if ( 'submitdiv' == $box['id'] || 'linksubmitdiv' == $box['id'] )
118
+				if ('submitdiv' == $box['id'] || 'linksubmitdiv' == $box['id'])
119 119
 					continue;
120 120
 
121 121
 				$widget_title = $box['title'];
122 122
 
123
-				if ( is_array( $box['args'] ) && isset( $box['args']['__widget_basename'] ) ) {
123
+				if (is_array($box['args']) && isset($box['args']['__widget_basename'])) {
124 124
 					$widget_title = $box['args']['__widget_basename'];
125 125
 				}
126 126
 
127 127
 				printf(
128 128
 					'<label for="%1$s-hide"><input class="hide-postbox-tog" name="%1$s-hide" type="checkbox" id="%1$s-hide" value="%1$s" %2$s />%3$s</label>',
129
-					esc_attr( $box['id'] ),
130
-					checked( in_array( $box['id'], $hidden ), false, false ),
129
+					esc_attr($box['id']),
130
+					checked(in_array($box['id'], $hidden), false, false),
131 131
 					$widget_title
132 132
 				);
133 133
 			}
@@ -143,22 +143,22 @@  discard block
 block discarded – undo
143 143
  * @param string|WP_Screen $screen Screen identifier
144 144
  * @return array Hidden Meta Boxes
145 145
  */
146
-function get_hidden_meta_boxes( $screen ) {
147
-	if ( is_string( $screen ) )
148
-		$screen = convert_to_screen( $screen );
146
+function get_hidden_meta_boxes($screen) {
147
+	if (is_string($screen))
148
+		$screen = convert_to_screen($screen);
149 149
 
150
-	$hidden = get_user_option( "metaboxhidden_{$screen->id}" );
150
+	$hidden = get_user_option("metaboxhidden_{$screen->id}");
151 151
 
152
-	$use_defaults = ! is_array( $hidden );
152
+	$use_defaults = ! is_array($hidden);
153 153
 
154 154
 	// Hide slug boxes by default
155
-	if ( $use_defaults ) {
155
+	if ($use_defaults) {
156 156
 		$hidden = array();
157
-		if ( 'post' == $screen->base ) {
158
-			if ( 'post' == $screen->post_type || 'page' == $screen->post_type || 'attachment' == $screen->post_type )
157
+		if ('post' == $screen->base) {
158
+			if ('post' == $screen->post_type || 'page' == $screen->post_type || 'attachment' == $screen->post_type)
159 159
 				$hidden = array('slugdiv', 'trackbacksdiv', 'postcustom', 'postexcerpt', 'commentstatusdiv', 'commentsdiv', 'authordiv', 'revisionsdiv');
160 160
 			else
161
-				$hidden = array( 'slugdiv' );
161
+				$hidden = array('slugdiv');
162 162
 		}
163 163
 
164 164
 		/**
@@ -169,7 +169,7 @@  discard block
 block discarded – undo
169 169
 		 * @param array     $hidden An array of meta boxes hidden by default.
170 170
 		 * @param WP_Screen $screen WP_Screen object of the current screen.
171 171
 		 */
172
-		$hidden = apply_filters( 'default_hidden_meta_boxes', $hidden, $screen );
172
+		$hidden = apply_filters('default_hidden_meta_boxes', $hidden, $screen);
173 173
 	}
174 174
 
175 175
 	/**
@@ -182,7 +182,7 @@  discard block
 block discarded – undo
182 182
 	 * @param bool      $use_defaults Whether to show the default meta boxes.
183 183
 	 *                                Default true.
184 184
 	 */
185
-	return apply_filters( 'hidden_meta_boxes', $hidden, $screen, $use_defaults );
185
+	return apply_filters('hidden_meta_boxes', $hidden, $screen, $use_defaults);
186 186
 }
187 187
 
188 188
 /**
@@ -193,13 +193,13 @@  discard block
 block discarded – undo
193 193
  * @param string $option An option name.
194 194
  * @param mixed $args Option-dependent arguments.
195 195
  */
196
-function add_screen_option( $option, $args = array() ) {
196
+function add_screen_option($option, $args = array()) {
197 197
 	$current_screen = get_current_screen();
198 198
 
199
-	if ( ! $current_screen )
199
+	if ( ! $current_screen)
200 200
 		return;
201 201
 
202
-	$current_screen->add_option( $option, $args );
202
+	$current_screen->add_option($option, $args);
203 203
 }
204 204
 
205 205
 /**
@@ -214,7 +214,7 @@  discard block
 block discarded – undo
214 214
 function get_current_screen() {
215 215
 	global $current_screen;
216 216
 
217
-	if ( ! isset( $current_screen ) )
217
+	if ( ! isset($current_screen))
218 218
 		return null;
219 219
 
220 220
 	return $current_screen;
@@ -228,6 +228,6 @@  discard block
 block discarded – undo
228 228
  * @param mixed $hook_name Optional. The hook name (also known as the hook suffix) used to determine the screen,
229 229
  *	                       or an existing screen object.
230 230
  */
231
-function set_current_screen( $hook_name = '' ) {
232
-	WP_Screen::get( $hook_name )->set_current_screen();
231
+function set_current_screen($hook_name = '') {
232
+	WP_Screen::get($hook_name)->set_current_screen();
233 233
 }
Please login to merge, or discard this patch.
src/wp-admin/includes/template.php 2 patches
Spacing   +466 added lines, -466 removed lines patch added patch discarded remove patch
@@ -9,10 +9,10 @@  discard block
 block discarded – undo
9 9
  */
10 10
 
11 11
 /** Walker_Category_Checklist class */
12
-require_once( ABSPATH . 'wp-admin/includes/class-walker-category-checklist.php' );
12
+require_once(ABSPATH.'wp-admin/includes/class-walker-category-checklist.php');
13 13
 
14 14
 /** WP_Internal_Pointers class */
15
-require_once( ABSPATH . 'wp-admin/includes/class-wp-internal-pointers.php' );
15
+require_once(ABSPATH.'wp-admin/includes/class-wp-internal-pointers.php');
16 16
 
17 17
 //
18 18
 // Category Checklists
@@ -37,15 +37,15 @@  discard block
 block discarded – undo
37 37
  * @param bool   $checked_ontop        Optional. Whether to move checked items out of the hierarchy and to
38 38
  *                                     the top of the list. Default true.
39 39
  */
40
-function wp_category_checklist( $post_id = 0, $descendants_and_self = 0, $selected_cats = false, $popular_cats = false, $walker = null, $checked_ontop = true ) {
41
-	wp_terms_checklist( $post_id, array(
40
+function wp_category_checklist($post_id = 0, $descendants_and_self = 0, $selected_cats = false, $popular_cats = false, $walker = null, $checked_ontop = true) {
41
+	wp_terms_checklist($post_id, array(
42 42
 		'taxonomy' => 'category',
43 43
 		'descendants_and_self' => $descendants_and_self,
44 44
 		'selected_cats' => $selected_cats,
45 45
 		'popular_cats' => $popular_cats,
46 46
 		'walker' => $walker,
47 47
 		'checked_ontop' => $checked_ontop
48
-	) );
48
+	));
49 49
 }
50 50
 
51 51
 /**
@@ -74,7 +74,7 @@  discard block
 block discarded – undo
74 74
  *                                        of echoing it. Default true.
75 75
  * }
76 76
  */
77
-function wp_terms_checklist( $post_id = 0, $args = array() ) {
77
+function wp_terms_checklist($post_id = 0, $args = array()) {
78 78
  	$defaults = array(
79 79
 		'descendants_and_self' => 0,
80 80
 		'selected_cats' => false,
@@ -95,11 +95,11 @@  discard block
 block discarded – undo
95 95
 	 * @param array $args    An array of arguments.
96 96
 	 * @param int   $post_id The post ID.
97 97
 	 */
98
-	$params = apply_filters( 'wp_terms_checklist_args', $args, $post_id );
98
+	$params = apply_filters('wp_terms_checklist_args', $args, $post_id);
99 99
 
100
-	$r = wp_parse_args( $params, $defaults );
100
+	$r = wp_parse_args($params, $defaults);
101 101
 
102
-	if ( empty( $r['walker'] ) || ! ( $r['walker'] instanceof Walker ) ) {
102
+	if (empty($r['walker']) || ! ($r['walker'] instanceof Walker)) {
103 103
 		$walker = new Walker_Category_Checklist;
104 104
 	} else {
105 105
 		$walker = $r['walker'];
@@ -108,64 +108,64 @@  discard block
 block discarded – undo
108 108
 	$taxonomy = $r['taxonomy'];
109 109
 	$descendants_and_self = (int) $r['descendants_and_self'];
110 110
 
111
-	$args = array( 'taxonomy' => $taxonomy );
111
+	$args = array('taxonomy' => $taxonomy);
112 112
 
113
-	$tax = get_taxonomy( $taxonomy );
114
-	$args['disabled'] = ! current_user_can( $tax->cap->assign_terms );
113
+	$tax = get_taxonomy($taxonomy);
114
+	$args['disabled'] = ! current_user_can($tax->cap->assign_terms);
115 115
 
116
-	$args['list_only'] = ! empty( $r['list_only'] );
116
+	$args['list_only'] = ! empty($r['list_only']);
117 117
 
118
-	if ( is_array( $r['selected_cats'] ) ) {
118
+	if (is_array($r['selected_cats'])) {
119 119
 		$args['selected_cats'] = $r['selected_cats'];
120
-	} elseif ( $post_id ) {
121
-		$args['selected_cats'] = wp_get_object_terms( $post_id, $taxonomy, array_merge( $args, array( 'fields' => 'ids' ) ) );
120
+	} elseif ($post_id) {
121
+		$args['selected_cats'] = wp_get_object_terms($post_id, $taxonomy, array_merge($args, array('fields' => 'ids')));
122 122
 	} else {
123 123
 		$args['selected_cats'] = array();
124 124
 	}
125
-	if ( is_array( $r['popular_cats'] ) ) {
125
+	if (is_array($r['popular_cats'])) {
126 126
 		$args['popular_cats'] = $r['popular_cats'];
127 127
 	} else {
128
-		$args['popular_cats'] = get_terms( $taxonomy, array(
128
+		$args['popular_cats'] = get_terms($taxonomy, array(
129 129
 			'fields' => 'ids',
130 130
 			'orderby' => 'count',
131 131
 			'order' => 'DESC',
132 132
 			'number' => 10,
133 133
 			'hierarchical' => false
134
-		) );
134
+		));
135 135
 	}
136
-	if ( $descendants_and_self ) {
137
-		$categories = (array) get_terms( $taxonomy, array(
136
+	if ($descendants_and_self) {
137
+		$categories = (array) get_terms($taxonomy, array(
138 138
 			'child_of' => $descendants_and_self,
139 139
 			'hierarchical' => 0,
140 140
 			'hide_empty' => 0
141
-		) );
142
-		$self = get_term( $descendants_and_self, $taxonomy );
143
-		array_unshift( $categories, $self );
141
+		));
142
+		$self = get_term($descendants_and_self, $taxonomy);
143
+		array_unshift($categories, $self);
144 144
 	} else {
145
-		$categories = (array) get_terms( $taxonomy, array( 'get' => 'all' ) );
145
+		$categories = (array) get_terms($taxonomy, array('get' => 'all'));
146 146
 	}
147 147
 
148 148
 	$output = '';
149 149
 
150
-	if ( $r['checked_ontop'] ) {
150
+	if ($r['checked_ontop']) {
151 151
 		// Post process $categories rather than adding an exclude to the get_terms() query to keep the query the same across all posts (for any query cache)
152 152
 		$checked_categories = array();
153
-		$keys = array_keys( $categories );
153
+		$keys = array_keys($categories);
154 154
 
155
-		foreach ( $keys as $k ) {
156
-			if ( in_array( $categories[$k]->term_id, $args['selected_cats'] ) ) {
155
+		foreach ($keys as $k) {
156
+			if (in_array($categories[$k]->term_id, $args['selected_cats'])) {
157 157
 				$checked_categories[] = $categories[$k];
158
-				unset( $categories[$k] );
158
+				unset($categories[$k]);
159 159
 			}
160 160
 		}
161 161
 
162 162
 		// Put checked cats on top
163
-		$output .= call_user_func_array( array( $walker, 'walk' ), array( $checked_categories, 0, $args ) );
163
+		$output .= call_user_func_array(array($walker, 'walk'), array($checked_categories, 0, $args));
164 164
 	}
165 165
 	// Then the rest of them
166
-	$output .= call_user_func_array( array( $walker, 'walk' ), array( $categories, 0, $args ) );
166
+	$output .= call_user_func_array(array($walker, 'walk'), array($categories, 0, $args));
167 167
 
168
-	if ( $r['echo'] ) {
168
+	if ($r['echo']) {
169 169
 		echo $output;
170 170
 	}
171 171
 
@@ -188,33 +188,33 @@  discard block
 block discarded – undo
188 188
  * @param bool $echo Optionally output the list as well. Defaults to true.
189 189
  * @return array List of popular term IDs.
190 190
  */
191
-function wp_popular_terms_checklist( $taxonomy, $default = 0, $number = 10, $echo = true ) {
191
+function wp_popular_terms_checklist($taxonomy, $default = 0, $number = 10, $echo = true) {
192 192
 	$post = get_post();
193 193
 
194
-	if ( $post && $post->ID )
194
+	if ($post && $post->ID)
195 195
 		$checked_terms = wp_get_object_terms($post->ID, $taxonomy, array('fields'=>'ids'));
196 196
 	else
197 197
 		$checked_terms = array();
198 198
 
199
-	$terms = get_terms( $taxonomy, array( 'orderby' => 'count', 'order' => 'DESC', 'number' => $number, 'hierarchical' => false ) );
199
+	$terms = get_terms($taxonomy, array('orderby' => 'count', 'order' => 'DESC', 'number' => $number, 'hierarchical' => false));
200 200
 
201 201
 	$tax = get_taxonomy($taxonomy);
202 202
 
203 203
 	$popular_ids = array();
204
-	foreach ( (array) $terms as $term ) {
204
+	foreach ((array) $terms as $term) {
205 205
 		$popular_ids[] = $term->term_id;
206
-		if ( !$echo ) // Hack for Ajax use.
206
+		if ( ! $echo) // Hack for Ajax use.
207 207
 			continue;
208 208
 		$id = "popular-$taxonomy-$term->term_id";
209
-		$checked = in_array( $term->term_id, $checked_terms ) ? 'checked="checked"' : '';
209
+		$checked = in_array($term->term_id, $checked_terms) ? 'checked="checked"' : '';
210 210
 		?>
211 211
 
212 212
 		<li id="<?php echo $id; ?>" class="popular-category">
213 213
 			<label class="selectit">
214
-				<input id="in-<?php echo $id; ?>" type="checkbox" <?php echo $checked; ?> value="<?php echo (int) $term->term_id; ?>" <?php disabled( ! current_user_can( $tax->cap->assign_terms ) ); ?> />
214
+				<input id="in-<?php echo $id; ?>" type="checkbox" <?php echo $checked; ?> value="<?php echo (int) $term->term_id; ?>" <?php disabled( ! current_user_can($tax->cap->assign_terms)); ?> />
215 215
 				<?php
216 216
 				/** This filter is documented in wp-includes/category-template.php */
217
-				echo esc_html( apply_filters( 'the_category', $term->name ) );
217
+				echo esc_html(apply_filters('the_category', $term->name));
218 218
 				?>
219 219
 			</label>
220 220
 		</li>
@@ -231,32 +231,32 @@  discard block
 block discarded – undo
231 231
  *
232 232
  * @param int $link_id
233 233
  */
234
-function wp_link_category_checklist( $link_id = 0 ) {
234
+function wp_link_category_checklist($link_id = 0) {
235 235
 	$default = 1;
236 236
 
237 237
 	$checked_categories = array();
238 238
 
239
-	if ( $link_id ) {
240
-		$checked_categories = wp_get_link_cats( $link_id );
239
+	if ($link_id) {
240
+		$checked_categories = wp_get_link_cats($link_id);
241 241
 		// No selected categories, strange
242
-		if ( ! count( $checked_categories ) ) {
242
+		if ( ! count($checked_categories)) {
243 243
 			$checked_categories[] = $default;
244 244
 		}
245 245
 	} else {
246 246
 		$checked_categories[] = $default;
247 247
 	}
248 248
 
249
-	$categories = get_terms( 'link_category', array( 'orderby' => 'name', 'hide_empty' => 0 ) );
249
+	$categories = get_terms('link_category', array('orderby' => 'name', 'hide_empty' => 0));
250 250
 
251
-	if ( empty( $categories ) )
251
+	if (empty($categories))
252 252
 		return;
253 253
 
254
-	foreach ( $categories as $category ) {
254
+	foreach ($categories as $category) {
255 255
 		$cat_id = $category->term_id;
256 256
 
257 257
 		/** This filter is documented in wp-includes/category-template.php */
258
-		$name = esc_html( apply_filters( 'the_category', $category->name ) );
259
-		$checked = in_array( $cat_id, $checked_categories ) ? ' checked="checked"' : '';
258
+		$name = esc_html(apply_filters('the_category', $category->name));
259
+		$checked = in_array($cat_id, $checked_categories) ? ' checked="checked"' : '';
260 260
 		echo '<li id="link-category-', $cat_id, '"><label for="in-link-category-', $cat_id, '" class="selectit"><input value="', $cat_id, '" type="checkbox" name="link_category[]" id="in-link-category-', $cat_id, '"', $checked, '/> ', $name, "</label></li>";
261 261
 	}
262 262
 }
@@ -270,71 +270,71 @@  discard block
 block discarded – undo
270 270
  */
271 271
 function get_inline_data($post) {
272 272
 	$post_type_object = get_post_type_object($post->post_type);
273
-	if ( ! current_user_can( 'edit_post', $post->ID ) )
273
+	if ( ! current_user_can('edit_post', $post->ID))
274 274
 		return;
275 275
 
276
-	$title = esc_textarea( trim( $post->post_title ) );
276
+	$title = esc_textarea(trim($post->post_title));
277 277
 
278 278
 	/** This filter is documented in wp-admin/edit-tag-form.php */
279 279
 	echo '
280
-<div class="hidden" id="inline_' . $post->ID . '">
281
-	<div class="post_title">' . $title . '</div>' .
280
+<div class="hidden" id="inline_' . $post->ID.'">
281
+	<div class="post_title">' . $title.'</div>'.
282 282
 	/** This filter is documented in wp-admin/edit-tag-form.php */
283
-	'<div class="post_name">' . apply_filters( 'editable_slug', $post->post_name, $post ) . '</div>
284
-	<div class="post_author">' . $post->post_author . '</div>
285
-	<div class="comment_status">' . esc_html( $post->comment_status ) . '</div>
286
-	<div class="ping_status">' . esc_html( $post->ping_status ) . '</div>
287
-	<div class="_status">' . esc_html( $post->post_status ) . '</div>
288
-	<div class="jj">' . mysql2date( 'd', $post->post_date, false ) . '</div>
289
-	<div class="mm">' . mysql2date( 'm', $post->post_date, false ) . '</div>
290
-	<div class="aa">' . mysql2date( 'Y', $post->post_date, false ) . '</div>
291
-	<div class="hh">' . mysql2date( 'H', $post->post_date, false ) . '</div>
292
-	<div class="mn">' . mysql2date( 'i', $post->post_date, false ) . '</div>
293
-	<div class="ss">' . mysql2date( 's', $post->post_date, false ) . '</div>
294
-	<div class="post_password">' . esc_html( $post->post_password ) . '</div>';
295
-
296
-	if ( $post_type_object->hierarchical )
297
-		echo '<div class="post_parent">' . $post->post_parent . '</div>';
298
-
299
-	if ( $post->post_type == 'page' )
300
-		echo '<div class="page_template">' . esc_html( get_post_meta( $post->ID, '_wp_page_template', true ) ) . '</div>';
301
-
302
-	if ( post_type_supports( $post->post_type, 'page-attributes' ) )
303
-		echo '<div class="menu_order">' . $post->menu_order . '</div>';
304
-
305
-	$taxonomy_names = get_object_taxonomies( $post->post_type );
306
-	foreach ( $taxonomy_names as $taxonomy_name) {
307
-		$taxonomy = get_taxonomy( $taxonomy_name );
308
-
309
-		if ( $taxonomy->hierarchical && $taxonomy->show_ui ) {
310
-
311
-			$terms = get_object_term_cache( $post->ID, $taxonomy_name );
312
-			if ( false === $terms ) {
313
-				$terms = wp_get_object_terms( $post->ID, $taxonomy_name );
314
-				wp_cache_add( $post->ID, wp_list_pluck( $terms, 'term_id' ), $taxonomy_name . '_relationships' );
283
+	'<div class="post_name">'.apply_filters('editable_slug', $post->post_name, $post).'</div>
284
+	<div class="post_author">' . $post->post_author.'</div>
285
+	<div class="comment_status">' . esc_html($post->comment_status).'</div>
286
+	<div class="ping_status">' . esc_html($post->ping_status).'</div>
287
+	<div class="_status">' . esc_html($post->post_status).'</div>
288
+	<div class="jj">' . mysql2date('d', $post->post_date, false).'</div>
289
+	<div class="mm">' . mysql2date('m', $post->post_date, false).'</div>
290
+	<div class="aa">' . mysql2date('Y', $post->post_date, false).'</div>
291
+	<div class="hh">' . mysql2date('H', $post->post_date, false).'</div>
292
+	<div class="mn">' . mysql2date('i', $post->post_date, false).'</div>
293
+	<div class="ss">' . mysql2date('s', $post->post_date, false).'</div>
294
+	<div class="post_password">' . esc_html($post->post_password).'</div>';
295
+
296
+	if ($post_type_object->hierarchical)
297
+		echo '<div class="post_parent">'.$post->post_parent.'</div>';
298
+
299
+	if ($post->post_type == 'page')
300
+		echo '<div class="page_template">'.esc_html(get_post_meta($post->ID, '_wp_page_template', true)).'</div>';
301
+
302
+	if (post_type_supports($post->post_type, 'page-attributes'))
303
+		echo '<div class="menu_order">'.$post->menu_order.'</div>';
304
+
305
+	$taxonomy_names = get_object_taxonomies($post->post_type);
306
+	foreach ($taxonomy_names as $taxonomy_name) {
307
+		$taxonomy = get_taxonomy($taxonomy_name);
308
+
309
+		if ($taxonomy->hierarchical && $taxonomy->show_ui) {
310
+
311
+			$terms = get_object_term_cache($post->ID, $taxonomy_name);
312
+			if (false === $terms) {
313
+				$terms = wp_get_object_terms($post->ID, $taxonomy_name);
314
+				wp_cache_add($post->ID, wp_list_pluck($terms, 'term_id'), $taxonomy_name.'_relationships');
315 315
 			}
316
-			$term_ids = empty( $terms ) ? array() : wp_list_pluck( $terms, 'term_id' );
316
+			$term_ids = empty($terms) ? array() : wp_list_pluck($terms, 'term_id');
317 317
 
318
-			echo '<div class="post_category" id="' . $taxonomy_name . '_' . $post->ID . '">' . implode( ',', $term_ids ) . '</div>';
318
+			echo '<div class="post_category" id="'.$taxonomy_name.'_'.$post->ID.'">'.implode(',', $term_ids).'</div>';
319 319
 
320
-		} elseif ( $taxonomy->show_ui ) {
320
+		} elseif ($taxonomy->show_ui) {
321 321
 
322
-			$terms_to_edit = get_terms_to_edit( $post->ID, $taxonomy_name );
323
-			if ( ! is_string( $terms_to_edit ) ) {
322
+			$terms_to_edit = get_terms_to_edit($post->ID, $taxonomy_name);
323
+			if ( ! is_string($terms_to_edit)) {
324 324
 				$terms_to_edit = '';
325 325
 			}
326 326
 
327 327
 			echo '<div class="tags_input" id="'.$taxonomy_name.'_'.$post->ID.'">'
328
-				. esc_html( str_replace( ',', ', ', $terms_to_edit ) ) . '</div>';
328
+				. esc_html(str_replace(',', ', ', $terms_to_edit)).'</div>';
329 329
 
330 330
 		}
331 331
 	}
332 332
 
333
-	if ( !$post_type_object->hierarchical )
334
-		echo '<div class="sticky">' . (is_sticky($post->ID) ? 'sticky' : '') . '</div>';
333
+	if ( ! $post_type_object->hierarchical)
334
+		echo '<div class="sticky">'.(is_sticky($post->ID) ? 'sticky' : '').'</div>';
335 335
 
336
-	if ( post_type_supports( $post->post_type, 'post-formats' ) )
337
-		echo '<div class="post_format">' . esc_html( get_post_format( $post->ID ) ) . '</div>';
336
+	if (post_type_supports($post->post_type, 'post-formats'))
337
+		echo '<div class="post_format">'.esc_html(get_post_format($post->ID)).'</div>';
338 338
 
339 339
 	echo '</div>';
340 340
 }
@@ -351,7 +351,7 @@  discard block
 block discarded – undo
351 351
  * @param string $mode
352 352
  * @param bool   $table_row
353 353
  */
354
-function wp_comment_reply( $position = 1, $checkbox = false, $mode = 'single', $table_row = true ) {
354
+function wp_comment_reply($position = 1, $checkbox = false, $mode = 'single', $table_row = true) {
355 355
 	global $wp_list_table;
356 356
 	/**
357 357
 	 * Filters the in-line comment reply-to form output in the Comments
@@ -368,15 +368,15 @@  discard block
 block discarded – undo
368 368
 	 * @param string $content The reply-to form content.
369 369
 	 * @param array  $args    An array of default args.
370 370
 	 */
371
-	$content = apply_filters( 'wp_comment_reply', '', array( 'position' => $position, 'checkbox' => $checkbox, 'mode' => $mode ) );
371
+	$content = apply_filters('wp_comment_reply', '', array('position' => $position, 'checkbox' => $checkbox, 'mode' => $mode));
372 372
 
373
-	if ( ! empty($content) ) {
373
+	if ( ! empty($content)) {
374 374
 		echo $content;
375 375
 		return;
376 376
 	}
377 377
 
378
-	if ( ! $wp_list_table ) {
379
-		if ( $mode == 'single' ) {
378
+	if ( ! $wp_list_table) {
379
+		if ($mode == 'single') {
380 380
 			$wp_list_table = _get_list_table('WP_Post_Comments_List_Table');
381 381
 		} else {
382 382
 			$wp_list_table = _get_list_table('WP_Comments_List_Table');
@@ -385,29 +385,29 @@  discard block
 block discarded – undo
385 385
 
386 386
 ?>
387 387
 <form method="get">
388
-<?php if ( $table_row ) : ?>
388
+<?php if ($table_row) : ?>
389 389
 <table style="display:none;"><tbody id="com-reply"><tr id="replyrow" class="inline-edit-row" style="display:none;"><td colspan="<?php echo $wp_list_table->get_column_count(); ?>" class="colspanchange">
390 390
 <?php else : ?>
391 391
 <div id="com-reply" style="display:none;"><div id="replyrow" style="display:none;">
392 392
 <?php endif; ?>
393 393
 	<fieldset class="comment-reply">
394 394
 	<legend>
395
-		<span class="hidden" id="editlegend"><?php _e( 'Edit Comment' ); ?></span>
396
-		<span class="hidden" id="replyhead"><?php _e( 'Reply to Comment' ); ?></span>
397
-		<span class="hidden" id="addhead"><?php _e( 'Add new Comment' ); ?></span>
395
+		<span class="hidden" id="editlegend"><?php _e('Edit Comment'); ?></span>
396
+		<span class="hidden" id="replyhead"><?php _e('Reply to Comment'); ?></span>
397
+		<span class="hidden" id="addhead"><?php _e('Add new Comment'); ?></span>
398 398
 	</legend>
399 399
 
400 400
 	<div id="replycontainer">
401
-	<label for="replycontent" class="screen-reader-text"><?php _e( 'Comment' ); ?></label>
401
+	<label for="replycontent" class="screen-reader-text"><?php _e('Comment'); ?></label>
402 402
 	<?php
403
-	$quicktags_settings = array( 'buttons' => 'strong,em,link,block,del,ins,img,ul,ol,li,code,close' );
404
-	wp_editor( '', 'replycontent', array( 'media_buttons' => false, 'tinymce' => false, 'quicktags' => $quicktags_settings ) );
403
+	$quicktags_settings = array('buttons' => 'strong,em,link,block,del,ins,img,ul,ol,li,code,close');
404
+	wp_editor('', 'replycontent', array('media_buttons' => false, 'tinymce' => false, 'quicktags' => $quicktags_settings));
405 405
 	?>
406 406
 	</div>
407 407
 
408 408
 	<div id="edithead" style="display:none;">
409 409
 		<div class="inside">
410
-		<label for="author-name"><?php _e( 'Name' ) ?></label>
410
+		<label for="author-name"><?php _e('Name') ?></label>
411 411
 		<input type="text" name="newcomment_author" size="50" value="" id="author-name" />
412 412
 		</div>
413 413
 
@@ -440,12 +440,12 @@  discard block
 block discarded – undo
440 440
 	<input type="hidden" name="checkbox" id="checkbox" value="<?php echo $checkbox ? 1 : 0; ?>" />
441 441
 	<input type="hidden" name="mode" id="mode" value="<?php echo esc_attr($mode); ?>" />
442 442
 	<?php
443
-		wp_nonce_field( 'replyto-comment', '_ajax_nonce-replyto-comment', false );
444
-		if ( current_user_can( 'unfiltered_html' ) )
445
-			wp_nonce_field( 'unfiltered-html-comment', '_wp_unfiltered_html_comment', false );
443
+		wp_nonce_field('replyto-comment', '_ajax_nonce-replyto-comment', false);
444
+		if (current_user_can('unfiltered_html'))
445
+			wp_nonce_field('unfiltered-html-comment', '_wp_unfiltered_html_comment', false);
446 446
 	?>
447 447
 	</fieldset>
448
-<?php if ( $table_row ) : ?>
448
+<?php if ($table_row) : ?>
449 449
 </td></tr></tbody></table>
450 450
 <?php else : ?>
451 451
 </div></div>
@@ -477,15 +477,15 @@  discard block
 block discarded – undo
477 477
  *
478 478
  * @param array $meta
479 479
  */
480
-function list_meta( $meta ) {
480
+function list_meta($meta) {
481 481
 	// Exit if no meta
482
-	if ( ! $meta ) {
482
+	if ( ! $meta) {
483 483
 		echo '
484 484
 <table id="list-table" style="display: none;">
485 485
 	<thead>
486 486
 	<tr>
487
-		<th class="left">' . _x( 'Name', 'meta name' ) . '</th>
488
-		<th>' . __( 'Value' ) . '</th>
487
+		<th class="left">' . _x('Name', 'meta name').'</th>
488
+		<th>' . __('Value').'</th>
489 489
 	</tr>
490 490
 	</thead>
491 491
 	<tbody id="the-list" data-wp-lists="list:meta">
@@ -499,14 +499,14 @@  discard block
 block discarded – undo
499 499
 <table id="list-table">
500 500
 	<thead>
501 501
 	<tr>
502
-		<th class="left"><?php _ex( 'Name', 'meta name' ) ?></th>
503
-		<th><?php _e( 'Value' ) ?></th>
502
+		<th class="left"><?php _ex('Name', 'meta name') ?></th>
503
+		<th><?php _e('Value') ?></th>
504 504
 	</tr>
505 505
 	</thead>
506 506
 	<tbody id='the-list' data-wp-lists='list:meta'>
507 507
 <?php
508
-	foreach ( $meta as $entry )
509
-		echo _list_meta_row( $entry, $count );
508
+	foreach ($meta as $entry)
509
+		echo _list_meta_row($entry, $count);
510 510
 ?>
511 511
 	</tbody>
512 512
 </table>
@@ -524,22 +524,22 @@  discard block
 block discarded – undo
524 524
  * @param int   $count
525 525
  * @return string
526 526
  */
527
-function _list_meta_row( $entry, &$count ) {
527
+function _list_meta_row($entry, &$count) {
528 528
 	static $update_nonce = '';
529 529
 
530
-	if ( is_protected_meta( $entry['meta_key'], 'post' ) )
530
+	if (is_protected_meta($entry['meta_key'], 'post'))
531 531
 		return '';
532 532
 
533
-	if ( ! $update_nonce )
534
-		$update_nonce = wp_create_nonce( 'add-meta' );
533
+	if ( ! $update_nonce)
534
+		$update_nonce = wp_create_nonce('add-meta');
535 535
 
536 536
 	$r = '';
537
-	++ $count;
537
+	++$count;
538 538
 
539
-	if ( is_serialized( $entry['meta_value'] ) ) {
540
-		if ( is_serialized_string( $entry['meta_value'] ) ) {
539
+	if (is_serialized($entry['meta_value'])) {
540
+		if (is_serialized_string($entry['meta_value'])) {
541 541
 			// This is a serialized string, so we should display it.
542
-			$entry['meta_value'] = maybe_unserialize( $entry['meta_value'] );
542
+			$entry['meta_value'] = maybe_unserialize($entry['meta_value']);
543 543
 		} else {
544 544
 			// This is a serialized array/object so we should NOT display it.
545 545
 			--$count;
@@ -548,23 +548,23 @@  discard block
 block discarded – undo
548 548
 	}
549 549
 
550 550
 	$entry['meta_key'] = esc_attr($entry['meta_key']);
551
-	$entry['meta_value'] = esc_textarea( $entry['meta_value'] ); // using a <textarea />
551
+	$entry['meta_value'] = esc_textarea($entry['meta_value']); // using a <textarea />
552 552
 	$entry['meta_id'] = (int) $entry['meta_id'];
553 553
 
554
-	$delete_nonce = wp_create_nonce( 'delete-meta_' . $entry['meta_id'] );
554
+	$delete_nonce = wp_create_nonce('delete-meta_'.$entry['meta_id']);
555 555
 
556 556
 	$r .= "\n\t<tr id='meta-{$entry['meta_id']}'>";
557
-	$r .= "\n\t\t<td class='left'><label class='screen-reader-text' for='meta-{$entry['meta_id']}-key'>" . __( 'Key' ) . "</label><input name='meta[{$entry['meta_id']}][key]' id='meta-{$entry['meta_id']}-key' type='text' size='20' value='{$entry['meta_key']}' />";
557
+	$r .= "\n\t\t<td class='left'><label class='screen-reader-text' for='meta-{$entry['meta_id']}-key'>".__('Key')."</label><input name='meta[{$entry['meta_id']}][key]' id='meta-{$entry['meta_id']}-key' type='text' size='20' value='{$entry['meta_key']}' />";
558 558
 
559 559
 	$r .= "\n\t\t<div class='submit'>";
560
-	$r .= get_submit_button( __( 'Delete' ), 'deletemeta small', "deletemeta[{$entry['meta_id']}]", false, array( 'data-wp-lists' => "delete:the-list:meta-{$entry['meta_id']}::_ajax_nonce=$delete_nonce" ) );
560
+	$r .= get_submit_button(__('Delete'), 'deletemeta small', "deletemeta[{$entry['meta_id']}]", false, array('data-wp-lists' => "delete:the-list:meta-{$entry['meta_id']}::_ajax_nonce=$delete_nonce"));
561 561
 	$r .= "\n\t\t";
562
-	$r .= get_submit_button( __( 'Update' ), 'updatemeta small', "meta-{$entry['meta_id']}-submit", false, array( 'data-wp-lists' => "add:the-list:meta-{$entry['meta_id']}::_ajax_nonce-add-meta=$update_nonce" ) );
562
+	$r .= get_submit_button(__('Update'), 'updatemeta small', "meta-{$entry['meta_id']}-submit", false, array('data-wp-lists' => "add:the-list:meta-{$entry['meta_id']}::_ajax_nonce-add-meta=$update_nonce"));
563 563
 	$r .= "</div>";
564
-	$r .= wp_nonce_field( 'change-meta', '_ajax_nonce', false, false );
564
+	$r .= wp_nonce_field('change-meta', '_ajax_nonce', false, false);
565 565
 	$r .= "</td>";
566 566
 
567
-	$r .= "\n\t\t<td><label class='screen-reader-text' for='meta-{$entry['meta_id']}-value'>" . __( 'Value' ) . "</label><textarea name='meta[{$entry['meta_id']}][value]' id='meta-{$entry['meta_id']}-value' rows='2' cols='30'>{$entry['meta_value']}</textarea></td>\n\t</tr>";
567
+	$r .= "\n\t\t<td><label class='screen-reader-text' for='meta-{$entry['meta_id']}-value'>".__('Value')."</label><textarea name='meta[{$entry['meta_id']}][value]' id='meta-{$entry['meta_id']}-value' rows='2' cols='30'>{$entry['meta_value']}</textarea></td>\n\t</tr>";
568 568
 	return $r;
569 569
 }
570 570
 
@@ -577,9 +577,9 @@  discard block
 block discarded – undo
577 577
  *
578 578
  * @param WP_Post $post Optional. The post being edited.
579 579
  */
580
-function meta_form( $post = null ) {
580
+function meta_form($post = null) {
581 581
 	global $wpdb;
582
-	$post = get_post( $post );
582
+	$post = get_post($post);
583 583
 
584 584
 	/**
585 585
 	 * Filters values for the meta key dropdown in the Custom Fields meta box.
@@ -592,9 +592,9 @@  discard block
 block discarded – undo
592 592
 	 * @param array|null $keys Pre-defined meta keys to be used in place of a postmeta query. Default null.
593 593
 	 * @param WP_Post    $post The current post object.
594 594
 	 */
595
-	$keys = apply_filters( 'postmeta_form_keys', null, $post );
595
+	$keys = apply_filters('postmeta_form_keys', null, $post);
596 596
 
597
-	if ( null === $keys ) {
597
+	if (null === $keys) {
598 598
 		/**
599 599
 		 * Filters the number of custom fields to retrieve for the drop-down
600 600
 		 * in the Custom Fields meta box.
@@ -603,44 +603,44 @@  discard block
 block discarded – undo
603 603
 		 *
604 604
 		 * @param int $limit Number of custom fields to retrieve. Default 30.
605 605
 		 */
606
-		$limit = apply_filters( 'postmeta_form_limit', 30 );
606
+		$limit = apply_filters('postmeta_form_limit', 30);
607 607
 		$sql = "SELECT DISTINCT meta_key
608 608
 			FROM $wpdb->postmeta
609 609
 			WHERE meta_key NOT BETWEEN '_' AND '_z'
610 610
 			HAVING meta_key NOT LIKE %s
611 611
 			ORDER BY meta_key
612 612
 			LIMIT %d";
613
-		$keys = $wpdb->get_col( $wpdb->prepare( $sql, $wpdb->esc_like( '_' ) . '%', $limit ) );
613
+		$keys = $wpdb->get_col($wpdb->prepare($sql, $wpdb->esc_like('_').'%', $limit));
614 614
 	}
615 615
 
616
-	if ( $keys ) {
617
-		natcasesort( $keys );
616
+	if ($keys) {
617
+		natcasesort($keys);
618 618
 		$meta_key_input_id = 'metakeyselect';
619 619
 	} else {
620 620
 		$meta_key_input_id = 'metakeyinput';
621 621
 	}
622 622
 ?>
623
-<p><strong><?php _e( 'Add New Custom Field:' ) ?></strong></p>
623
+<p><strong><?php _e('Add New Custom Field:') ?></strong></p>
624 624
 <table id="newmeta">
625 625
 <thead>
626 626
 <tr>
627
-<th class="left"><label for="<?php echo $meta_key_input_id; ?>"><?php _ex( 'Name', 'meta name' ) ?></label></th>
628
-<th><label for="metavalue"><?php _e( 'Value' ) ?></label></th>
627
+<th class="left"><label for="<?php echo $meta_key_input_id; ?>"><?php _ex('Name', 'meta name') ?></label></th>
628
+<th><label for="metavalue"><?php _e('Value') ?></label></th>
629 629
 </tr>
630 630
 </thead>
631 631
 
632 632
 <tbody>
633 633
 <tr>
634 634
 <td id="newmetaleft" class="left">
635
-<?php if ( $keys ) { ?>
635
+<?php if ($keys) { ?>
636 636
 <select id="metakeyselect" name="metakeyselect">
637
-<option value="#NONE#"><?php _e( '&mdash; Select &mdash;' ); ?></option>
637
+<option value="#NONE#"><?php _e('&mdash; Select &mdash;'); ?></option>
638 638
 <?php
639 639
 
640
-	foreach ( $keys as $key ) {
641
-		if ( is_protected_meta( $key, 'post' ) || ! current_user_can( 'add_post_meta', $post->ID, $key ) )
640
+	foreach ($keys as $key) {
641
+		if (is_protected_meta($key, 'post') || ! current_user_can('add_post_meta', $post->ID, $key))
642 642
 			continue;
643
-		echo "\n<option value='" . esc_attr($key) . "'>" . esc_html($key) . "</option>";
643
+		echo "\n<option value='".esc_attr($key)."'>".esc_html($key)."</option>";
644 644
 	}
645 645
 ?>
646 646
 </select>
@@ -657,9 +657,9 @@  discard block
 block discarded – undo
657 657
 
658 658
 <tr><td colspan="2">
659 659
 <div class="submit">
660
-<?php submit_button( __( 'Add Custom Field' ), 'secondary', 'addmeta', false, array( 'id' => 'newmeta-submit', 'data-wp-lists' => 'add:the-list:newmeta' ) ); ?>
660
+<?php submit_button(__('Add Custom Field'), 'secondary', 'addmeta', false, array('id' => 'newmeta-submit', 'data-wp-lists' => 'add:the-list:newmeta')); ?>
661 661
 </div>
662
-<?php wp_nonce_field( 'add-meta', '_ajax_nonce-add-meta', false ); ?>
662
+<?php wp_nonce_field('add-meta', '_ajax_nonce-add-meta', false); ?>
663 663
 </td></tr>
664 664
 </tbody>
665 665
 </table>
@@ -681,15 +681,15 @@  discard block
 block discarded – undo
681 681
  * @param int|bool $multi     Optional. Whether the additional fields and buttons should be added.
682 682
  *                            Default 0|false.
683 683
  */
684
-function touch_time( $edit = 1, $for_post = 1, $tab_index = 0, $multi = 0 ) {
684
+function touch_time($edit = 1, $for_post = 1, $tab_index = 0, $multi = 0) {
685 685
 	global $wp_locale;
686 686
 	$post = get_post();
687 687
 
688
-	if ( $for_post )
689
-		$edit = ! ( in_array($post->post_status, array('draft', 'pending') ) && (!$post->post_date_gmt || '0000-00-00 00:00:00' == $post->post_date_gmt ) );
688
+	if ($for_post)
689
+		$edit = ! (in_array($post->post_status, array('draft', 'pending')) && ( ! $post->post_date_gmt || '0000-00-00 00:00:00' == $post->post_date_gmt));
690 690
 
691 691
 	$tab_index_attribute = '';
692
-	if ( (int) $tab_index > 0 )
692
+	if ((int) $tab_index > 0)
693 693
 		$tab_index_attribute = " tabindex=\"$tab_index\"";
694 694
 
695 695
 	// todo: Remove this?
@@ -697,56 +697,56 @@  discard block
 block discarded – undo
697 697
 
698 698
 	$time_adj = current_time('timestamp');
699 699
 	$post_date = ($for_post) ? $post->post_date : get_comment()->comment_date;
700
-	$jj = ($edit) ? mysql2date( 'd', $post_date, false ) : gmdate( 'd', $time_adj );
701
-	$mm = ($edit) ? mysql2date( 'm', $post_date, false ) : gmdate( 'm', $time_adj );
702
-	$aa = ($edit) ? mysql2date( 'Y', $post_date, false ) : gmdate( 'Y', $time_adj );
703
-	$hh = ($edit) ? mysql2date( 'H', $post_date, false ) : gmdate( 'H', $time_adj );
704
-	$mn = ($edit) ? mysql2date( 'i', $post_date, false ) : gmdate( 'i', $time_adj );
705
-	$ss = ($edit) ? mysql2date( 's', $post_date, false ) : gmdate( 's', $time_adj );
706
-
707
-	$cur_jj = gmdate( 'd', $time_adj );
708
-	$cur_mm = gmdate( 'm', $time_adj );
709
-	$cur_aa = gmdate( 'Y', $time_adj );
710
-	$cur_hh = gmdate( 'H', $time_adj );
711
-	$cur_mn = gmdate( 'i', $time_adj );
712
-
713
-	$month = '<label><span class="screen-reader-text">' . __( 'Month' ) . '</span><select ' . ( $multi ? '' : 'id="mm" ' ) . 'name="mm"' . $tab_index_attribute . ">\n";
714
-	for ( $i = 1; $i < 13; $i = $i +1 ) {
700
+	$jj = ($edit) ? mysql2date('d', $post_date, false) : gmdate('d', $time_adj);
701
+	$mm = ($edit) ? mysql2date('m', $post_date, false) : gmdate('m', $time_adj);
702
+	$aa = ($edit) ? mysql2date('Y', $post_date, false) : gmdate('Y', $time_adj);
703
+	$hh = ($edit) ? mysql2date('H', $post_date, false) : gmdate('H', $time_adj);
704
+	$mn = ($edit) ? mysql2date('i', $post_date, false) : gmdate('i', $time_adj);
705
+	$ss = ($edit) ? mysql2date('s', $post_date, false) : gmdate('s', $time_adj);
706
+
707
+	$cur_jj = gmdate('d', $time_adj);
708
+	$cur_mm = gmdate('m', $time_adj);
709
+	$cur_aa = gmdate('Y', $time_adj);
710
+	$cur_hh = gmdate('H', $time_adj);
711
+	$cur_mn = gmdate('i', $time_adj);
712
+
713
+	$month = '<label><span class="screen-reader-text">'.__('Month').'</span><select '.($multi ? '' : 'id="mm" ').'name="mm"'.$tab_index_attribute.">\n";
714
+	for ($i = 1; $i < 13; $i = $i + 1) {
715 715
 		$monthnum = zeroise($i, 2);
716
-		$monthtext = $wp_locale->get_month_abbrev( $wp_locale->get_month( $i ) );
717
-		$month .= "\t\t\t" . '<option value="' . $monthnum . '" data-text="' . $monthtext . '" ' . selected( $monthnum, $mm, false ) . '>';
716
+		$monthtext = $wp_locale->get_month_abbrev($wp_locale->get_month($i));
717
+		$month .= "\t\t\t".'<option value="'.$monthnum.'" data-text="'.$monthtext.'" '.selected($monthnum, $mm, false).'>';
718 718
 		/* translators: 1: month number (01, 02, etc.), 2: month abbreviation */
719
-		$month .= sprintf( __( '%1$s-%2$s' ), $monthnum, $monthtext ) . "</option>\n";
719
+		$month .= sprintf(__('%1$s-%2$s'), $monthnum, $monthtext)."</option>\n";
720 720
 	}
721 721
 	$month .= '</select></label>';
722 722
 
723
-	$day = '<label><span class="screen-reader-text">' . __( 'Day' ) . '</span><input type="text" ' . ( $multi ? '' : 'id="jj" ' ) . 'name="jj" value="' . $jj . '" size="2" maxlength="2"' . $tab_index_attribute . ' autocomplete="off" /></label>';
724
-	$year = '<label><span class="screen-reader-text">' . __( 'Year' ) . '</span><input type="text" ' . ( $multi ? '' : 'id="aa" ' ) . 'name="aa" value="' . $aa . '" size="4" maxlength="4"' . $tab_index_attribute . ' autocomplete="off" /></label>';
725
-	$hour = '<label><span class="screen-reader-text">' . __( 'Hour' ) . '</span><input type="text" ' . ( $multi ? '' : 'id="hh" ' ) . 'name="hh" value="' . $hh . '" size="2" maxlength="2"' . $tab_index_attribute . ' autocomplete="off" /></label>';
726
-	$minute = '<label><span class="screen-reader-text">' . __( 'Minute' ) . '</span><input type="text" ' . ( $multi ? '' : 'id="mn" ' ) . 'name="mn" value="' . $mn . '" size="2" maxlength="2"' . $tab_index_attribute . ' autocomplete="off" /></label>';
723
+	$day = '<label><span class="screen-reader-text">'.__('Day').'</span><input type="text" '.($multi ? '' : 'id="jj" ').'name="jj" value="'.$jj.'" size="2" maxlength="2"'.$tab_index_attribute.' autocomplete="off" /></label>';
724
+	$year = '<label><span class="screen-reader-text">'.__('Year').'</span><input type="text" '.($multi ? '' : 'id="aa" ').'name="aa" value="'.$aa.'" size="4" maxlength="4"'.$tab_index_attribute.' autocomplete="off" /></label>';
725
+	$hour = '<label><span class="screen-reader-text">'.__('Hour').'</span><input type="text" '.($multi ? '' : 'id="hh" ').'name="hh" value="'.$hh.'" size="2" maxlength="2"'.$tab_index_attribute.' autocomplete="off" /></label>';
726
+	$minute = '<label><span class="screen-reader-text">'.__('Minute').'</span><input type="text" '.($multi ? '' : 'id="mn" ').'name="mn" value="'.$mn.'" size="2" maxlength="2"'.$tab_index_attribute.' autocomplete="off" /></label>';
727 727
 
728 728
 	echo '<div class="timestamp-wrap">';
729 729
 	/* translators: 1: month, 2: day, 3: year, 4: hour, 5: minute */
730
-	printf( __( '%1$s %2$s, %3$s @ %4$s:%5$s' ), $month, $day, $year, $hour, $minute );
730
+	printf(__('%1$s %2$s, %3$s @ %4$s:%5$s'), $month, $day, $year, $hour, $minute);
731 731
 
732
-	echo '</div><input type="hidden" id="ss" name="ss" value="' . $ss . '" />';
732
+	echo '</div><input type="hidden" id="ss" name="ss" value="'.$ss.'" />';
733 733
 
734
-	if ( $multi ) return;
734
+	if ($multi) return;
735 735
 
736 736
 	echo "\n\n";
737 737
 	$map = array(
738
-		'mm' => array( $mm, $cur_mm ),
739
-		'jj' => array( $jj, $cur_jj ),
740
-		'aa' => array( $aa, $cur_aa ),
741
-		'hh' => array( $hh, $cur_hh ),
742
-		'mn' => array( $mn, $cur_mn ),
738
+		'mm' => array($mm, $cur_mm),
739
+		'jj' => array($jj, $cur_jj),
740
+		'aa' => array($aa, $cur_aa),
741
+		'hh' => array($hh, $cur_hh),
742
+		'mn' => array($mn, $cur_mn),
743 743
 	);
744
-	foreach ( $map as $timeunit => $value ) {
745
-		list( $unit, $curr ) = $value;
744
+	foreach ($map as $timeunit => $value) {
745
+		list($unit, $curr) = $value;
746 746
 
747
-		echo '<input type="hidden" id="hidden_' . $timeunit . '" name="hidden_' . $timeunit . '" value="' . $unit . '" />' . "\n";
748
-		$cur_timeunit = 'cur_' . $timeunit;
749
-		echo '<input type="hidden" id="' . $cur_timeunit . '" name="' . $cur_timeunit . '" value="' . $curr . '" />' . "\n";
747
+		echo '<input type="hidden" id="hidden_'.$timeunit.'" name="hidden_'.$timeunit.'" value="'.$unit.'" />'."\n";
748
+		$cur_timeunit = 'cur_'.$timeunit;
749
+		echo '<input type="hidden" id="'.$cur_timeunit.'" name="'.$cur_timeunit.'" value="'.$curr.'" />'."\n";
750 750
 	}
751 751
 ?>
752 752
 
@@ -764,12 +764,12 @@  discard block
 block discarded – undo
764 764
  *
765 765
  * @param string $default Optional. The template file name. Default empty.
766 766
  */
767
-function page_template_dropdown( $default = '' ) {
768
-	$templates = get_page_templates( get_post() );
769
-	ksort( $templates );
770
-	foreach ( array_keys( $templates ) as $template ) {
771
-		$selected = selected( $default, $templates[ $template ], false );
772
-		echo "\n\t<option value='" . $templates[ $template ] . "' $selected>$template</option>";
767
+function page_template_dropdown($default = '') {
768
+	$templates = get_page_templates(get_post());
769
+	ksort($templates);
770
+	foreach (array_keys($templates) as $template) {
771
+		$selected = selected($default, $templates[$template], false);
772
+		echo "\n\t<option value='".$templates[$template]."' $selected>$template</option>";
773 773
 	}
774 774
 }
775 775
 
@@ -788,22 +788,22 @@  discard block
 block discarded – undo
788 788
  *
789 789
  * @return null|false Boolean False if page has no children, otherwise print out html elements
790 790
  */
791
-function parent_dropdown( $default = 0, $parent = 0, $level = 0, $post = null ) {
791
+function parent_dropdown($default = 0, $parent = 0, $level = 0, $post = null) {
792 792
 	global $wpdb;
793
-	$post = get_post( $post );
794
-	$items = $wpdb->get_results( $wpdb->prepare("SELECT ID, post_parent, post_title FROM $wpdb->posts WHERE post_parent = %d AND post_type = 'page' ORDER BY menu_order", $parent) );
793
+	$post = get_post($post);
794
+	$items = $wpdb->get_results($wpdb->prepare("SELECT ID, post_parent, post_title FROM $wpdb->posts WHERE post_parent = %d AND post_type = 'page' ORDER BY menu_order", $parent));
795 795
 
796
-	if ( $items ) {
797
-		foreach ( $items as $item ) {
796
+	if ($items) {
797
+		foreach ($items as $item) {
798 798
 			// A page cannot be its own parent.
799
-			if ( $post && $post->ID && $item->ID == $post->ID )
799
+			if ($post && $post->ID && $item->ID == $post->ID)
800 800
 				continue;
801 801
 
802
-			$pad = str_repeat( '&nbsp;', $level * 3 );
803
-			$selected = selected( $default, $item->ID, false );
802
+			$pad = str_repeat('&nbsp;', $level * 3);
803
+			$selected = selected($default, $item->ID, false);
804 804
 
805
-			echo "\n\t<option class='level-$level' value='$item->ID' $selected>$pad " . esc_html($item->post_title) . "</option>";
806
-			parent_dropdown( $default, $item->ID, $level +1 );
805
+			echo "\n\t<option class='level-$level' value='$item->ID' $selected>$pad ".esc_html($item->post_title)."</option>";
806
+			parent_dropdown($default, $item->ID, $level + 1);
807 807
 		}
808 808
 	} else {
809 809
 		return false;
@@ -817,20 +817,20 @@  discard block
 block discarded – undo
817 817
  *
818 818
  * @param string $selected Slug for the role that should be already selected.
819 819
  */
820
-function wp_dropdown_roles( $selected = '' ) {
820
+function wp_dropdown_roles($selected = '') {
821 821
 	$p = '';
822 822
 	$r = '';
823 823
 
824
-	$editable_roles = array_reverse( get_editable_roles() );
824
+	$editable_roles = array_reverse(get_editable_roles());
825 825
 
826
-	foreach ( $editable_roles as $role => $details ) {
827
-		$name = translate_user_role($details['name'] );
828
-		if ( $selected == $role ) // preselect specified role
829
-			$p = "\n\t<option selected='selected' value='" . esc_attr($role) . "'>$name</option>";
826
+	foreach ($editable_roles as $role => $details) {
827
+		$name = translate_user_role($details['name']);
828
+		if ($selected == $role) // preselect specified role
829
+			$p = "\n\t<option selected='selected' value='".esc_attr($role)."'>$name</option>";
830 830
 		else
831
-			$r .= "\n\t<option value='" . esc_attr($role) . "'>$name</option>";
831
+			$r .= "\n\t<option value='".esc_attr($role)."'>$name</option>";
832 832
 	}
833
-	echo $p . $r;
833
+	echo $p.$r;
834 834
 }
835 835
 
836 836
 /**
@@ -840,7 +840,7 @@  discard block
 block discarded – undo
840 840
  *
841 841
  * @param string $action The action attribute for the form.
842 842
  */
843
-function wp_import_upload_form( $action ) {
843
+function wp_import_upload_form($action) {
844 844
 
845 845
 	/**
846 846
 	 * Filters the maximum allowed upload size for import files.
@@ -851,22 +851,22 @@  discard block
 block discarded – undo
851 851
 	 *
852 852
 	 * @param int $max_upload_size Allowed upload size. Default 1 MB.
853 853
 	 */
854
-	$bytes = apply_filters( 'import_upload_size_limit', wp_max_upload_size() );
855
-	$size = size_format( $bytes );
854
+	$bytes = apply_filters('import_upload_size_limit', wp_max_upload_size());
855
+	$size = size_format($bytes);
856 856
 	$upload_dir = wp_upload_dir();
857
-	if ( ! empty( $upload_dir['error'] ) ) :
857
+	if ( ! empty($upload_dir['error'])) :
858 858
 		?><div class="error"><p><?php _e('Before you can upload your import file, you will need to fix the following error:'); ?></p>
859 859
 		<p><strong><?php echo $upload_dir['error']; ?></strong></p></div><?php
860 860
 	else :
861 861
 ?>
862
-<form enctype="multipart/form-data" id="import-upload-form" method="post" class="wp-upload-form" action="<?php echo esc_url( wp_nonce_url( $action, 'import-upload' ) ); ?>">
862
+<form enctype="multipart/form-data" id="import-upload-form" method="post" class="wp-upload-form" action="<?php echo esc_url(wp_nonce_url($action, 'import-upload')); ?>">
863 863
 <p>
864
-<label for="upload"><?php _e( 'Choose a file from your computer:' ); ?></label> (<?php printf( __('Maximum size: %s' ), $size ); ?>)
864
+<label for="upload"><?php _e('Choose a file from your computer:'); ?></label> (<?php printf(__('Maximum size: %s'), $size); ?>)
865 865
 <input type="file" id="upload" name="import" size="25" />
866 866
 <input type="hidden" name="action" value="save" />
867 867
 <input type="hidden" name="max_file_size" value="<?php echo $bytes; ?>" />
868 868
 </p>
869
-<?php submit_button( __('Upload file and import'), 'primary' ); ?>
869
+<?php submit_button(__('Upload file and import'), 'primary'); ?>
870 870
 </form>
871 871
 <?php
872 872
 	endif;
@@ -900,75 +900,75 @@  discard block
 block discarded – undo
900 900
  *                                              of the box array (which is the second parameter passed
901 901
  *                                              to your callback). Default null.
902 902
  */
903
-function add_meta_box( $id, $title, $callback, $screen = null, $context = 'advanced', $priority = 'default', $callback_args = null ) {
903
+function add_meta_box($id, $title, $callback, $screen = null, $context = 'advanced', $priority = 'default', $callback_args = null) {
904 904
 	global $wp_meta_boxes;
905 905
 
906
-	if ( empty( $screen ) ) {
906
+	if (empty($screen)) {
907 907
 		$screen = get_current_screen();
908
-	} elseif ( is_string( $screen ) ) {
909
-		$screen = convert_to_screen( $screen );
910
-	} elseif ( is_array( $screen ) ) {
911
-		foreach ( $screen as $single_screen ) {
912
-			add_meta_box( $id, $title, $callback, $single_screen, $context, $priority, $callback_args );
908
+	} elseif (is_string($screen)) {
909
+		$screen = convert_to_screen($screen);
910
+	} elseif (is_array($screen)) {
911
+		foreach ($screen as $single_screen) {
912
+			add_meta_box($id, $title, $callback, $single_screen, $context, $priority, $callback_args);
913 913
 		}
914 914
 	}
915 915
 
916
-	if ( ! isset( $screen->id ) ) {
916
+	if ( ! isset($screen->id)) {
917 917
 		return;
918 918
 	}
919 919
 
920 920
 	$page = $screen->id;
921 921
 
922
-	if ( !isset($wp_meta_boxes) )
922
+	if ( ! isset($wp_meta_boxes))
923 923
 		$wp_meta_boxes = array();
924
-	if ( !isset($wp_meta_boxes[$page]) )
924
+	if ( ! isset($wp_meta_boxes[$page]))
925 925
 		$wp_meta_boxes[$page] = array();
926
-	if ( !isset($wp_meta_boxes[$page][$context]) )
926
+	if ( ! isset($wp_meta_boxes[$page][$context]))
927 927
 		$wp_meta_boxes[$page][$context] = array();
928 928
 
929
-	foreach ( array_keys($wp_meta_boxes[$page]) as $a_context ) {
930
-		foreach ( array('high', 'core', 'default', 'low') as $a_priority ) {
931
-			if ( !isset($wp_meta_boxes[$page][$a_context][$a_priority][$id]) )
929
+	foreach (array_keys($wp_meta_boxes[$page]) as $a_context) {
930
+		foreach (array('high', 'core', 'default', 'low') as $a_priority) {
931
+			if ( ! isset($wp_meta_boxes[$page][$a_context][$a_priority][$id]))
932 932
 				continue;
933 933
 
934 934
 			// If a core box was previously added or removed by a plugin, don't add.
935
-			if ( 'core' == $priority ) {
935
+			if ('core' == $priority) {
936 936
 				// If core box previously deleted, don't add
937
-				if ( false === $wp_meta_boxes[$page][$a_context][$a_priority][$id] )
937
+				if (false === $wp_meta_boxes[$page][$a_context][$a_priority][$id])
938 938
 					return;
939 939
 
940 940
 				/*
941 941
 				 * If box was added with default priority, give it core priority to
942 942
 				 * maintain sort order.
943 943
 				 */
944
-				if ( 'default' == $a_priority ) {
944
+				if ('default' == $a_priority) {
945 945
 					$wp_meta_boxes[$page][$a_context]['core'][$id] = $wp_meta_boxes[$page][$a_context]['default'][$id];
946 946
 					unset($wp_meta_boxes[$page][$a_context]['default'][$id]);
947 947
 				}
948 948
 				return;
949 949
 			}
950 950
 			// If no priority given and id already present, use existing priority.
951
-			if ( empty($priority) ) {
951
+			if (empty($priority)) {
952 952
 				$priority = $a_priority;
953 953
 			/*
954 954
 			 * Else, if we're adding to the sorted priority, we don't know the title
955 955
 			 * or callback. Grab them from the previously added context/priority.
956 956
 			 */
957
-			} elseif ( 'sorted' == $priority ) {
957
+			} elseif ('sorted' == $priority) {
958 958
 				$title = $wp_meta_boxes[$page][$a_context][$a_priority][$id]['title'];
959 959
 				$callback = $wp_meta_boxes[$page][$a_context][$a_priority][$id]['callback'];
960 960
 				$callback_args = $wp_meta_boxes[$page][$a_context][$a_priority][$id]['args'];
961 961
 			}
962 962
 			// An id can be in only one priority and one context.
963
-			if ( $priority != $a_priority || $context != $a_context )
963
+			if ($priority != $a_priority || $context != $a_context)
964 964
 				unset($wp_meta_boxes[$page][$a_context][$a_priority][$id]);
965 965
 		}
966 966
 	}
967 967
 
968
-	if ( empty($priority) )
968
+	if (empty($priority))
969 969
 		$priority = 'low';
970 970
 
971
-	if ( !isset($wp_meta_boxes[$page][$context][$priority]) )
971
+	if ( ! isset($wp_meta_boxes[$page][$context][$priority]))
972 972
 		$wp_meta_boxes[$page][$context][$priority] = array();
973 973
 
974 974
 	$wp_meta_boxes[$page][$context][$priority][$id] = array('id' => $id, 'title' => $title, 'callback' => $callback, 'args' => $callback_args);
@@ -987,27 +987,27 @@  discard block
 block discarded – undo
987 987
  * @param mixed            $object  gets passed to the box callback function as first parameter
988 988
  * @return int number of meta_boxes
989 989
  */
990
-function do_meta_boxes( $screen, $context, $object ) {
990
+function do_meta_boxes($screen, $context, $object) {
991 991
 	global $wp_meta_boxes;
992 992
 	static $already_sorted = false;
993 993
 
994
-	if ( empty( $screen ) )
994
+	if (empty($screen))
995 995
 		$screen = get_current_screen();
996
-	elseif ( is_string( $screen ) )
997
-		$screen = convert_to_screen( $screen );
996
+	elseif (is_string($screen))
997
+		$screen = convert_to_screen($screen);
998 998
 
999 999
 	$page = $screen->id;
1000 1000
 
1001
-	$hidden = get_hidden_meta_boxes( $screen );
1001
+	$hidden = get_hidden_meta_boxes($screen);
1002 1002
 
1003 1003
 	printf('<div id="%s-sortables" class="meta-box-sortables">', htmlspecialchars($context));
1004 1004
 
1005 1005
 	// Grab the ones the user has manually sorted. Pull them out of their previous context/priority and into the one the user chose
1006
-	if ( ! $already_sorted && $sorted = get_user_option( "meta-box-order_$page" ) ) {
1007
-		foreach ( $sorted as $box_context => $ids ) {
1008
-			foreach ( explode( ',', $ids ) as $id ) {
1009
-				if ( $id && 'dashboard_browser_nag' !== $id ) {
1010
-					add_meta_box( $id, null, null, $screen, $box_context, 'sorted' );
1006
+	if ( ! $already_sorted && $sorted = get_user_option("meta-box-order_$page")) {
1007
+		foreach ($sorted as $box_context => $ids) {
1008
+			foreach (explode(',', $ids) as $id) {
1009
+				if ($id && 'dashboard_browser_nag' !== $id) {
1010
+					add_meta_box($id, null, null, $screen, $box_context, 'sorted');
1011 1011
 				}
1012 1012
 			}
1013 1013
 		}
@@ -1017,31 +1017,31 @@  discard block
 block discarded – undo
1017 1017
 
1018 1018
 	$i = 0;
1019 1019
 
1020
-	if ( isset( $wp_meta_boxes[ $page ][ $context ] ) ) {
1021
-		foreach ( array( 'high', 'sorted', 'core', 'default', 'low' ) as $priority ) {
1022
-			if ( isset( $wp_meta_boxes[ $page ][ $context ][ $priority ]) ) {
1023
-				foreach ( (array) $wp_meta_boxes[ $page ][ $context ][ $priority ] as $box ) {
1024
-					if ( false == $box || ! $box['title'] )
1020
+	if (isset($wp_meta_boxes[$page][$context])) {
1021
+		foreach (array('high', 'sorted', 'core', 'default', 'low') as $priority) {
1022
+			if (isset($wp_meta_boxes[$page][$context][$priority])) {
1023
+				foreach ((array) $wp_meta_boxes[$page][$context][$priority] as $box) {
1024
+					if (false == $box || ! $box['title'])
1025 1025
 						continue;
1026 1026
 					$i++;
1027 1027
 					$hidden_class = in_array($box['id'], $hidden) ? ' hide-if-js' : '';
1028
-					echo '<div id="' . $box['id'] . '" class="postbox ' . postbox_classes($box['id'], $page) . $hidden_class . '" ' . '>' . "\n";
1029
-					if ( 'dashboard_browser_nag' != $box['id'] ) {
1030
-						$widget_title = $box[ 'title' ];
1028
+					echo '<div id="'.$box['id'].'" class="postbox '.postbox_classes($box['id'], $page).$hidden_class.'" '.'>'."\n";
1029
+					if ('dashboard_browser_nag' != $box['id']) {
1030
+						$widget_title = $box['title'];
1031 1031
 
1032
-						if ( is_array( $box[ 'args' ] ) && isset( $box[ 'args' ][ '__widget_basename' ] ) ) {
1033
-							$widget_title = $box[ 'args' ][ '__widget_basename' ];
1032
+						if (is_array($box['args']) && isset($box['args']['__widget_basename'])) {
1033
+							$widget_title = $box['args']['__widget_basename'];
1034 1034
 							// Do not pass this parameter to the user callback function.
1035
-							unset( $box[ 'args' ][ '__widget_basename' ] );
1035
+							unset($box['args']['__widget_basename']);
1036 1036
 						}
1037 1037
 
1038 1038
 						echo '<button type="button" class="handlediv button-link" aria-expanded="true">';
1039
-						echo '<span class="screen-reader-text">' . sprintf( __( 'Toggle panel: %s' ), $widget_title ) . '</span>';
1039
+						echo '<span class="screen-reader-text">'.sprintf(__('Toggle panel: %s'), $widget_title).'</span>';
1040 1040
 						echo '<span class="toggle-indicator" aria-hidden="true"></span>';
1041 1041
 						echo '</button>';
1042 1042
 					}
1043 1043
 					echo "<h2 class='hndle'><span>{$box['title']}</span></h2>\n";
1044
-					echo '<div class="inside">' . "\n";
1044
+					echo '<div class="inside">'."\n";
1045 1045
 					call_user_func($box['callback'], $object, $box);
1046 1046
 					echo "</div>\n";
1047 1047
 					echo "</div>\n";
@@ -1074,33 +1074,33 @@  discard block
 block discarded – undo
1074 1074
  *                                        include 'normal' and 'side'. Menus meta boxes (accordion sections)
1075 1075
  *                                        all use the 'side' context.
1076 1076
  */
1077
-function remove_meta_box( $id, $screen, $context ) {
1077
+function remove_meta_box($id, $screen, $context) {
1078 1078
 	global $wp_meta_boxes;
1079 1079
 
1080
-	if ( empty( $screen ) ) {
1080
+	if (empty($screen)) {
1081 1081
 		$screen = get_current_screen();
1082
-	} elseif ( is_string( $screen ) ) {
1083
-		$screen = convert_to_screen( $screen );
1084
-	} elseif ( is_array( $screen ) ) {
1085
-		foreach ( $screen as $single_screen ) {
1086
-			remove_meta_box( $id, $single_screen, $context );
1082
+	} elseif (is_string($screen)) {
1083
+		$screen = convert_to_screen($screen);
1084
+	} elseif (is_array($screen)) {
1085
+		foreach ($screen as $single_screen) {
1086
+			remove_meta_box($id, $single_screen, $context);
1087 1087
 		}
1088 1088
 	}
1089 1089
 
1090
-	if ( ! isset( $screen->id ) ) {
1090
+	if ( ! isset($screen->id)) {
1091 1091
 		return;
1092 1092
 	}
1093 1093
 
1094 1094
 	$page = $screen->id;
1095 1095
 
1096
-	if ( !isset($wp_meta_boxes) )
1096
+	if ( ! isset($wp_meta_boxes))
1097 1097
 		$wp_meta_boxes = array();
1098
-	if ( !isset($wp_meta_boxes[$page]) )
1098
+	if ( ! isset($wp_meta_boxes[$page]))
1099 1099
 		$wp_meta_boxes[$page] = array();
1100
-	if ( !isset($wp_meta_boxes[$page][$context]) )
1100
+	if ( ! isset($wp_meta_boxes[$page][$context]))
1101 1101
 		$wp_meta_boxes[$page][$context] = array();
1102 1102
 
1103
-	foreach ( array('high', 'core', 'default', 'low') as $priority )
1103
+	foreach (array('high', 'core', 'default', 'low') as $priority)
1104 1104
 		$wp_meta_boxes[$page][$context][$priority][$id] = false;
1105 1105
 }
1106 1106
 
@@ -1120,19 +1120,19 @@  discard block
 block discarded – undo
1120 1120
  * @param mixed         $object  gets passed to the section callback function as first parameter.
1121 1121
  * @return int number of meta boxes as accordion sections.
1122 1122
  */
1123
-function do_accordion_sections( $screen, $context, $object ) {
1123
+function do_accordion_sections($screen, $context, $object) {
1124 1124
 	global $wp_meta_boxes;
1125 1125
 
1126
-	wp_enqueue_script( 'accordion' );
1126
+	wp_enqueue_script('accordion');
1127 1127
 
1128
-	if ( empty( $screen ) )
1128
+	if (empty($screen))
1129 1129
 		$screen = get_current_screen();
1130
-	elseif ( is_string( $screen ) )
1131
-		$screen = convert_to_screen( $screen );
1130
+	elseif (is_string($screen))
1131
+		$screen = convert_to_screen($screen);
1132 1132
 
1133 1133
 	$page = $screen->id;
1134 1134
 
1135
-	$hidden = get_hidden_meta_boxes( $screen );
1135
+	$hidden = get_hidden_meta_boxes($screen);
1136 1136
 	?>
1137 1137
 	<div id="side-sortables" class="accordion-container">
1138 1138
 		<ul class="outer-border">
@@ -1140,29 +1140,29 @@  discard block
 block discarded – undo
1140 1140
 	$i = 0;
1141 1141
 	$first_open = false;
1142 1142
 
1143
-	if ( isset( $wp_meta_boxes[ $page ][ $context ] ) ) {
1144
-		foreach ( array( 'high', 'core', 'default', 'low' ) as $priority ) {
1145
-			if ( isset( $wp_meta_boxes[ $page ][ $context ][ $priority ] ) ) {
1146
-				foreach ( $wp_meta_boxes[ $page ][ $context ][ $priority ] as $box ) {
1147
-					if ( false == $box || ! $box['title'] )
1143
+	if (isset($wp_meta_boxes[$page][$context])) {
1144
+		foreach (array('high', 'core', 'default', 'low') as $priority) {
1145
+			if (isset($wp_meta_boxes[$page][$context][$priority])) {
1146
+				foreach ($wp_meta_boxes[$page][$context][$priority] as $box) {
1147
+					if (false == $box || ! $box['title'])
1148 1148
 						continue;
1149 1149
 					$i++;
1150
-					$hidden_class = in_array( $box['id'], $hidden ) ? 'hide-if-js' : '';
1150
+					$hidden_class = in_array($box['id'], $hidden) ? 'hide-if-js' : '';
1151 1151
 
1152 1152
 					$open_class = '';
1153
-					if ( ! $first_open && empty( $hidden_class ) ) {
1153
+					if ( ! $first_open && empty($hidden_class)) {
1154 1154
 						$first_open = true;
1155 1155
 						$open_class = 'open';
1156 1156
 					}
1157 1157
 					?>
1158
-					<li class="control-section accordion-section <?php echo $hidden_class; ?> <?php echo $open_class; ?> <?php echo esc_attr( $box['id'] ); ?>" id="<?php echo esc_attr( $box['id'] ); ?>">
1158
+					<li class="control-section accordion-section <?php echo $hidden_class; ?> <?php echo $open_class; ?> <?php echo esc_attr($box['id']); ?>" id="<?php echo esc_attr($box['id']); ?>">
1159 1159
 						<h3 class="accordion-section-title hndle" tabindex="0">
1160
-							<?php echo esc_html( $box['title'] ); ?>
1161
-							<span class="screen-reader-text"><?php _e( 'Press return or enter to open this section' ); ?></span>
1160
+							<?php echo esc_html($box['title']); ?>
1161
+							<span class="screen-reader-text"><?php _e('Press return or enter to open this section'); ?></span>
1162 1162
 						</h3>
1163
-						<div class="accordion-section-content <?php postbox_classes( $box['id'], $page ); ?>">
1163
+						<div class="accordion-section-content <?php postbox_classes($box['id'], $page); ?>">
1164 1164
 							<div class="inside">
1165
-								<?php call_user_func( $box['callback'], $object, $box ); ?>
1165
+								<?php call_user_func($box['callback'], $object, $box); ?>
1166 1166
 							</div><!-- .inside -->
1167 1167
 						</div><!-- .accordion-section-content -->
1168 1168
 					</li><!-- .accordion-section -->
@@ -1203,13 +1203,13 @@  discard block
 block discarded – undo
1203 1203
 function add_settings_section($id, $title, $callback, $page) {
1204 1204
 	global $wp_settings_sections;
1205 1205
 
1206
-	if ( 'misc' == $page ) {
1207
-		_deprecated_argument( __FUNCTION__, '3.0.0', sprintf( __( 'The "%s" options group has been removed. Use another settings group.' ), 'misc' ) );
1206
+	if ('misc' == $page) {
1207
+		_deprecated_argument(__FUNCTION__, '3.0.0', sprintf(__('The "%s" options group has been removed. Use another settings group.'), 'misc'));
1208 1208
 		$page = 'general';
1209 1209
 	}
1210 1210
 
1211
-	if ( 'privacy' == $page ) {
1212
-		_deprecated_argument( __FUNCTION__, '3.5.0', sprintf( __( 'The "%s" options group has been removed. Use another settings group.' ), 'privacy' ) );
1211
+	if ('privacy' == $page) {
1212
+		_deprecated_argument(__FUNCTION__, '3.5.0', sprintf(__('The "%s" options group has been removed. Use another settings group.'), 'privacy'));
1213 1213
 		$page = 'reading';
1214 1214
 	}
1215 1215
 
@@ -1254,13 +1254,13 @@  discard block
 block discarded – undo
1254 1254
 function add_settings_field($id, $title, $callback, $page, $section = 'default', $args = array()) {
1255 1255
 	global $wp_settings_fields;
1256 1256
 
1257
-	if ( 'misc' == $page ) {
1258
-		_deprecated_argument( __FUNCTION__, '3.0.0', __( 'The miscellaneous options group has been removed. Use another settings group.' ) );
1257
+	if ('misc' == $page) {
1258
+		_deprecated_argument(__FUNCTION__, '3.0.0', __('The miscellaneous options group has been removed. Use another settings group.'));
1259 1259
 		$page = 'general';
1260 1260
 	}
1261 1261
 
1262
-	if ( 'privacy' == $page ) {
1263
-		_deprecated_argument( __FUNCTION__, '3.5.0', __( 'The privacy options group has been removed. Use another settings group.' ) );
1262
+	if ('privacy' == $page) {
1263
+		_deprecated_argument(__FUNCTION__, '3.5.0', __('The privacy options group has been removed. Use another settings group.'));
1264 1264
 		$page = 'reading';
1265 1265
 	}
1266 1266
 
@@ -1280,23 +1280,23 @@  discard block
 block discarded – undo
1280 1280
  *
1281 1281
  * @param string $page The slug name of the page whose settings sections you want to output
1282 1282
  */
1283
-function do_settings_sections( $page ) {
1283
+function do_settings_sections($page) {
1284 1284
 	global $wp_settings_sections, $wp_settings_fields;
1285 1285
 
1286
-	if ( ! isset( $wp_settings_sections[$page] ) )
1286
+	if ( ! isset($wp_settings_sections[$page]))
1287 1287
 		return;
1288 1288
 
1289
-	foreach ( (array) $wp_settings_sections[$page] as $section ) {
1290
-		if ( $section['title'] )
1289
+	foreach ((array) $wp_settings_sections[$page] as $section) {
1290
+		if ($section['title'])
1291 1291
 			echo "<h2>{$section['title']}</h2>\n";
1292 1292
 
1293
-		if ( $section['callback'] )
1294
-			call_user_func( $section['callback'], $section );
1293
+		if ($section['callback'])
1294
+			call_user_func($section['callback'], $section);
1295 1295
 
1296
-		if ( ! isset( $wp_settings_fields ) || !isset( $wp_settings_fields[$page] ) || !isset( $wp_settings_fields[$page][$section['id']] ) )
1296
+		if ( ! isset($wp_settings_fields) || ! isset($wp_settings_fields[$page]) || ! isset($wp_settings_fields[$page][$section['id']]))
1297 1297
 			continue;
1298 1298
 		echo '<table class="form-table">';
1299
-		do_settings_fields( $page, $section['id'] );
1299
+		do_settings_fields($page, $section['id']);
1300 1300
 		echo '</table>';
1301 1301
 	}
1302 1302
 }
@@ -1318,22 +1318,22 @@  discard block
 block discarded – undo
1318 1318
 function do_settings_fields($page, $section) {
1319 1319
 	global $wp_settings_fields;
1320 1320
 
1321
-	if ( ! isset( $wp_settings_fields[$page][$section] ) )
1321
+	if ( ! isset($wp_settings_fields[$page][$section]))
1322 1322
 		return;
1323 1323
 
1324
-	foreach ( (array) $wp_settings_fields[$page][$section] as $field ) {
1324
+	foreach ((array) $wp_settings_fields[$page][$section] as $field) {
1325 1325
 		$class = '';
1326 1326
 
1327
-		if ( ! empty( $field['args']['class'] ) ) {
1328
-			$class = ' class="' . esc_attr( $field['args']['class'] ) . '"';
1327
+		if ( ! empty($field['args']['class'])) {
1328
+			$class = ' class="'.esc_attr($field['args']['class']).'"';
1329 1329
 		}
1330 1330
 
1331 1331
 		echo "<tr{$class}>";
1332 1332
 
1333
-		if ( ! empty( $field['args']['label_for'] ) ) {
1334
-			echo '<th scope="row"><label for="' . esc_attr( $field['args']['label_for'] ) . '">' . $field['title'] . '</label></th>';
1333
+		if ( ! empty($field['args']['label_for'])) {
1334
+			echo '<th scope="row"><label for="'.esc_attr($field['args']['label_for']).'">'.$field['title'].'</label></th>';
1335 1335
 		} else {
1336
-			echo '<th scope="row">' . $field['title'] . '</th>';
1336
+			echo '<th scope="row">'.$field['title'].'</th>';
1337 1337
 		}
1338 1338
 
1339 1339
 		echo '<td>';
@@ -1367,7 +1367,7 @@  discard block
 block discarded – undo
1367 1367
  * @param string $type    Optional. Message type, controls HTML class. Accepts 'error' or 'updated'.
1368 1368
  *                        Default 'error'.
1369 1369
  */
1370
-function add_settings_error( $setting, $code, $message, $type = 'error' ) {
1370
+function add_settings_error($setting, $code, $message, $type = 'error') {
1371 1371
 	global $wp_settings_errors;
1372 1372
 
1373 1373
 	$wp_settings_errors[] = array(
@@ -1401,7 +1401,7 @@  discard block
 block discarded – undo
1401 1401
  * @param boolean $sanitize Whether to re-sanitize the setting value before returning errors.
1402 1402
  * @return array Array of settings errors
1403 1403
  */
1404
-function get_settings_errors( $setting = '', $sanitize = false ) {
1404
+function get_settings_errors($setting = '', $sanitize = false) {
1405 1405
 	global $wp_settings_errors;
1406 1406
 
1407 1407
 	/*
@@ -1409,24 +1409,24 @@  discard block
 block discarded – undo
1409 1409
 	 * This allows the $sanitize_callback from register_setting() to run, adding
1410 1410
 	 * any settings errors you want to show by default.
1411 1411
 	 */
1412
-	if ( $sanitize )
1413
-		sanitize_option( $setting, get_option( $setting ) );
1412
+	if ($sanitize)
1413
+		sanitize_option($setting, get_option($setting));
1414 1414
 
1415 1415
 	// If settings were passed back from options.php then use them.
1416
-	if ( isset( $_GET['settings-updated'] ) && $_GET['settings-updated'] && get_transient( 'settings_errors' ) ) {
1417
-		$wp_settings_errors = array_merge( (array) $wp_settings_errors, get_transient( 'settings_errors' ) );
1418
-		delete_transient( 'settings_errors' );
1416
+	if (isset($_GET['settings-updated']) && $_GET['settings-updated'] && get_transient('settings_errors')) {
1417
+		$wp_settings_errors = array_merge((array) $wp_settings_errors, get_transient('settings_errors'));
1418
+		delete_transient('settings_errors');
1419 1419
 	}
1420 1420
 
1421 1421
 	// Check global in case errors have been added on this pageload.
1422
-	if ( ! count( $wp_settings_errors ) )
1422
+	if ( ! count($wp_settings_errors))
1423 1423
 		return array();
1424 1424
 
1425 1425
 	// Filter the results to those of a specific setting if one was set.
1426
-	if ( $setting ) {
1426
+	if ($setting) {
1427 1427
 		$setting_errors = array();
1428
-		foreach ( (array) $wp_settings_errors as $key => $details ) {
1429
-			if ( $setting == $details['setting'] )
1428
+		foreach ((array) $wp_settings_errors as $key => $details) {
1429
+			if ($setting == $details['setting'])
1430 1430
 				$setting_errors[] = $wp_settings_errors[$key];
1431 1431
 		}
1432 1432
 		return $setting_errors;
@@ -1462,20 +1462,20 @@  discard block
 block discarded – undo
1462 1462
  * @param bool   $hide_on_update If set to true errors will not be shown if the settings page has
1463 1463
  *                               already been submitted.
1464 1464
  */
1465
-function settings_errors( $setting = '', $sanitize = false, $hide_on_update = false ) {
1465
+function settings_errors($setting = '', $sanitize = false, $hide_on_update = false) {
1466 1466
 
1467
-	if ( $hide_on_update && ! empty( $_GET['settings-updated'] ) )
1467
+	if ($hide_on_update && ! empty($_GET['settings-updated']))
1468 1468
 		return;
1469 1469
 
1470
-	$settings_errors = get_settings_errors( $setting, $sanitize );
1470
+	$settings_errors = get_settings_errors($setting, $sanitize);
1471 1471
 
1472
-	if ( empty( $settings_errors ) )
1472
+	if (empty($settings_errors))
1473 1473
 		return;
1474 1474
 
1475 1475
 	$output = '';
1476
-	foreach ( $settings_errors as $key => $details ) {
1477
-		$css_id = 'setting-error-' . $details['code'];
1478
-		$css_class = $details['type'] . ' settings-error notice is-dismissible';
1476
+	foreach ($settings_errors as $key => $details) {
1477
+		$css_id = 'setting-error-'.$details['code'];
1478
+		$css_class = $details['type'].' settings-error notice is-dismissible';
1479 1479
 		$output .= "<div id='$css_id' class='$css_class'> \n";
1480 1480
 		$output .= "<p><strong>{$details['message']}</strong></p>";
1481 1481
 		$output .= "</div> \n";
@@ -1494,26 +1494,26 @@  discard block
 block discarded – undo
1494 1494
 ?>
1495 1495
 	<div id="find-posts" class="find-box" style="display: none;">
1496 1496
 		<div id="find-posts-head" class="find-box-head">
1497
-			<?php _e( 'Attach to existing content' ); ?>
1498
-			<button type="button" id="find-posts-close"><span class="screen-reader-text"><?php _e( 'Close media attachment panel' ); ?></button>
1497
+			<?php _e('Attach to existing content'); ?>
1498
+			<button type="button" id="find-posts-close"><span class="screen-reader-text"><?php _e('Close media attachment panel'); ?></button>
1499 1499
 		</div>
1500 1500
 		<div class="find-box-inside">
1501 1501
 			<div class="find-box-search">
1502
-				<?php if ( $found_action ) { ?>
1502
+				<?php if ($found_action) { ?>
1503 1503
 					<input type="hidden" name="found_action" value="<?php echo esc_attr($found_action); ?>" />
1504 1504
 				<?php } ?>
1505 1505
 				<input type="hidden" name="affected" id="affected" value="" />
1506
-				<?php wp_nonce_field( 'find-posts', '_ajax_nonce', false ); ?>
1507
-				<label class="screen-reader-text" for="find-posts-input"><?php _e( 'Search' ); ?></label>
1506
+				<?php wp_nonce_field('find-posts', '_ajax_nonce', false); ?>
1507
+				<label class="screen-reader-text" for="find-posts-input"><?php _e('Search'); ?></label>
1508 1508
 				<input type="text" id="find-posts-input" name="ps" value="" />
1509 1509
 				<span class="spinner"></span>
1510
-				<input type="button" id="find-posts-search" value="<?php esc_attr_e( 'Search' ); ?>" class="button" />
1510
+				<input type="button" id="find-posts-search" value="<?php esc_attr_e('Search'); ?>" class="button" />
1511 1511
 				<div class="clear"></div>
1512 1512
 			</div>
1513 1513
 			<div id="find-posts-response"></div>
1514 1514
 		</div>
1515 1515
 		<div class="find-box-buttons">
1516
-			<?php submit_button( __( 'Select' ), 'button-primary alignright', 'find-posts-submit', false ); ?>
1516
+			<?php submit_button(__('Select'), 'button-primary alignright', 'find-posts-submit', false); ?>
1517 1517
 			<div class="clear"></div>
1518 1518
 		</div>
1519 1519
 	</div>
@@ -1529,8 +1529,8 @@  discard block
 block discarded – undo
1529 1529
  */
1530 1530
 function the_post_password() {
1531 1531
 	$post = get_post();
1532
-	if ( isset( $post->post_password ) )
1533
-		echo esc_attr( $post->post_password );
1532
+	if (isset($post->post_password))
1533
+		echo esc_attr($post->post_password);
1534 1534
 }
1535 1535
 
1536 1536
 /**
@@ -1544,11 +1544,11 @@  discard block
 block discarded – undo
1544 1544
  * @param int|WP_Post $post Optional. Post ID or WP_Post object. Default is global $post.
1545 1545
  * @return string The post title if set.
1546 1546
  */
1547
-function _draft_or_post_title( $post = 0 ) {
1548
-	$title = get_the_title( $post );
1549
-	if ( empty( $title ) )
1550
-		$title = __( '(no title)' );
1551
-	return esc_html( $title );
1547
+function _draft_or_post_title($post = 0) {
1548
+	$title = get_the_title($post);
1549
+	if (empty($title))
1550
+		$title = __('(no title)');
1551
+	return esc_html($title);
1552 1552
 }
1553 1553
 
1554 1554
 /**
@@ -1560,7 +1560,7 @@  discard block
 block discarded – undo
1560 1560
  * @since 2.7.0
1561 1561
  */
1562 1562
 function _admin_search_query() {
1563
-	echo isset($_REQUEST['s']) ? esc_attr( wp_unslash( $_REQUEST['s'] ) ) : '';
1563
+	echo isset($_REQUEST['s']) ? esc_attr(wp_unslash($_REQUEST['s'])) : '';
1564 1564
 }
1565 1565
 
1566 1566
 /**
@@ -1575,69 +1575,69 @@  discard block
 block discarded – undo
1575 1575
  * @param string $title      Optional. Title of the Iframe page. Default empty.
1576 1576
  * @param bool   $deprecated Not used.
1577 1577
  */
1578
-function iframe_header( $title = '', $deprecated = false ) {
1579
-	show_admin_bar( false );
1578
+function iframe_header($title = '', $deprecated = false) {
1579
+	show_admin_bar(false);
1580 1580
 	global $hook_suffix, $admin_body_class, $wp_locale;
1581 1581
 	$admin_body_class = preg_replace('/[^a-z0-9_-]+/i', '-', $hook_suffix);
1582 1582
 
1583 1583
 	$current_screen = get_current_screen();
1584 1584
 
1585
-	@header( 'Content-Type: ' . get_option( 'html_type' ) . '; charset=' . get_option( 'blog_charset' ) );
1585
+	@header('Content-Type: '.get_option('html_type').'; charset='.get_option('blog_charset'));
1586 1586
 	_wp_admin_html_begin();
1587 1587
 ?>
1588 1588
 <title><?php bloginfo('name') ?> &rsaquo; <?php echo $title ?> &#8212; <?php _e('WordPress'); ?></title>
1589 1589
 <?php
1590
-wp_enqueue_style( 'colors' );
1590
+wp_enqueue_style('colors');
1591 1591
 ?>
1592 1592
 <script type="text/javascript">
1593 1593
 addLoadEvent = function(func){if(typeof jQuery!="undefined")jQuery(document).ready(func);else if(typeof wpOnload!='function'){wpOnload=func;}else{var oldonload=wpOnload;wpOnload=function(){oldonload();func();}}};
1594 1594
 function tb_close(){var win=window.dialogArguments||opener||parent||top;win.tb_remove();}
1595
-var ajaxurl = '<?php echo admin_url( 'admin-ajax.php', 'relative' ); ?>',
1595
+var ajaxurl = '<?php echo admin_url('admin-ajax.php', 'relative'); ?>',
1596 1596
 	pagenow = '<?php echo $current_screen->id; ?>',
1597 1597
 	typenow = '<?php echo $current_screen->post_type; ?>',
1598 1598
 	adminpage = '<?php echo $admin_body_class; ?>',
1599
-	thousandsSeparator = '<?php echo addslashes( $wp_locale->number_format['thousands_sep'] ); ?>',
1600
-	decimalPoint = '<?php echo addslashes( $wp_locale->number_format['decimal_point'] ); ?>',
1599
+	thousandsSeparator = '<?php echo addslashes($wp_locale->number_format['thousands_sep']); ?>',
1600
+	decimalPoint = '<?php echo addslashes($wp_locale->number_format['decimal_point']); ?>',
1601 1601
 	isRtl = <?php echo (int) is_rtl(); ?>;
1602 1602
 </script>
1603 1603
 <?php
1604 1604
 /** This action is documented in wp-admin/admin-header.php */
1605
-do_action( 'admin_enqueue_scripts', $hook_suffix );
1605
+do_action('admin_enqueue_scripts', $hook_suffix);
1606 1606
 
1607 1607
 /** This action is documented in wp-admin/admin-header.php */
1608
-do_action( "admin_print_styles-$hook_suffix" );
1608
+do_action("admin_print_styles-$hook_suffix");
1609 1609
 
1610 1610
 /** This action is documented in wp-admin/admin-header.php */
1611
-do_action( 'admin_print_styles' );
1611
+do_action('admin_print_styles');
1612 1612
 
1613 1613
 /** This action is documented in wp-admin/admin-header.php */
1614
-do_action( "admin_print_scripts-$hook_suffix" );
1614
+do_action("admin_print_scripts-$hook_suffix");
1615 1615
 
1616 1616
 /** This action is documented in wp-admin/admin-header.php */
1617
-do_action( 'admin_print_scripts' );
1617
+do_action('admin_print_scripts');
1618 1618
 
1619 1619
 /** This action is documented in wp-admin/admin-header.php */
1620
-do_action( "admin_head-$hook_suffix" );
1620
+do_action("admin_head-$hook_suffix");
1621 1621
 
1622 1622
 /** This action is documented in wp-admin/admin-header.php */
1623
-do_action( 'admin_head' );
1623
+do_action('admin_head');
1624 1624
 
1625
-$admin_body_class .= ' locale-' . sanitize_html_class( strtolower( str_replace( '_', '-', get_locale() ) ) );
1625
+$admin_body_class .= ' locale-'.sanitize_html_class(strtolower(str_replace('_', '-', get_locale())));
1626 1626
 
1627
-if ( is_rtl() )
1627
+if (is_rtl())
1628 1628
 	$admin_body_class .= ' rtl';
1629 1629
 
1630 1630
 ?>
1631 1631
 </head>
1632 1632
 <?php
1633 1633
 /** This filter is documented in wp-admin/admin-header.php */
1634
-$admin_body_classes = apply_filters( 'admin_body_class', '' );
1634
+$admin_body_classes = apply_filters('admin_body_class', '');
1635 1635
 ?>
1636 1636
 <body<?php
1637 1637
 /**
1638 1638
  * @global string $body_id
1639 1639
  */
1640
-if ( isset($GLOBALS['body_id']) ) echo ' id="' . $GLOBALS['body_id'] . '"'; ?> class="wp-admin wp-core-ui no-js iframe <?php echo $admin_body_classes . ' ' . $admin_body_class; ?>">
1640
+if (isset($GLOBALS['body_id'])) echo ' id="'.$GLOBALS['body_id'].'"'; ?> class="wp-admin wp-core-ui no-js iframe <?php echo $admin_body_classes.' '.$admin_body_class; ?>">
1641 1641
 <script type="text/javascript">
1642 1642
 (function(){
1643 1643
 var c = document.body.className;
@@ -1668,13 +1668,13 @@  discard block
 block discarded – undo
1668 1668
 	<div class="hidden">
1669 1669
 <?php
1670 1670
 	/** This action is documented in wp-admin/admin-footer.php */
1671
-	do_action( 'admin_footer', $hook_suffix );
1671
+	do_action('admin_footer', $hook_suffix);
1672 1672
 
1673 1673
 	/** This action is documented in wp-admin/admin-footer.php */
1674
-	do_action( "admin_print_footer_scripts-$hook_suffix" );
1674
+	do_action("admin_print_footer_scripts-$hook_suffix");
1675 1675
 
1676 1676
 	/** This action is documented in wp-admin/admin-footer.php */
1677
-	do_action( 'admin_print_footer_scripts' );
1677
+	do_action('admin_print_footer_scripts');
1678 1678
 ?>
1679 1679
 	</div>
1680 1680
 <script type="text/javascript">if(typeof wpOnload=="function")wpOnload();</script>
@@ -1689,33 +1689,33 @@  discard block
 block discarded – undo
1689 1689
  */
1690 1690
 function _post_states($post) {
1691 1691
 	$post_states = array();
1692
-	if ( isset( $_REQUEST['post_status'] ) )
1692
+	if (isset($_REQUEST['post_status']))
1693 1693
 		$post_status = $_REQUEST['post_status'];
1694 1694
 	else
1695 1695
 		$post_status = '';
1696 1696
 
1697
-	if ( !empty($post->post_password) )
1697
+	if ( ! empty($post->post_password))
1698 1698
 		$post_states['protected'] = __('Password protected');
1699
-	if ( 'private' == $post->post_status && 'private' != $post_status )
1699
+	if ('private' == $post->post_status && 'private' != $post_status)
1700 1700
 		$post_states['private'] = __('Private');
1701
-	if ( 'draft' == $post->post_status && 'draft' != $post_status )
1701
+	if ('draft' == $post->post_status && 'draft' != $post_status)
1702 1702
 		$post_states['draft'] = __('Draft');
1703
-	if ( 'pending' == $post->post_status && 'pending' != $post_status )
1703
+	if ('pending' == $post->post_status && 'pending' != $post_status)
1704 1704
 		$post_states['pending'] = _x('Pending', 'post status');
1705
-	if ( is_sticky($post->ID) )
1705
+	if (is_sticky($post->ID))
1706 1706
 		$post_states['sticky'] = __('Sticky');
1707 1707
 
1708
-	if ( 'future' === $post->post_status ) {
1709
-		$post_states['scheduled'] = __( 'Scheduled' );
1708
+	if ('future' === $post->post_status) {
1709
+		$post_states['scheduled'] = __('Scheduled');
1710 1710
 	}
1711 1711
 
1712
-	if ( 'page' === get_option( 'show_on_front' ) ) {
1713
-		if ( intval( get_option( 'page_on_front' ) ) === $post->ID ) {
1714
-			$post_states['page_on_front'] = __( 'Front Page' );
1712
+	if ('page' === get_option('show_on_front')) {
1713
+		if (intval(get_option('page_on_front')) === $post->ID) {
1714
+			$post_states['page_on_front'] = __('Front Page');
1715 1715
 		}
1716 1716
 
1717
-		if ( intval( get_option( 'page_for_posts' ) ) === $post->ID ) {
1718
-			$post_states['page_for_posts'] = __( 'Posts Page' );
1717
+		if (intval(get_option('page_for_posts')) === $post->ID) {
1718
+			$post_states['page_for_posts'] = __('Posts Page');
1719 1719
 		}
1720 1720
 	}
1721 1721
 
@@ -1727,15 +1727,15 @@  discard block
 block discarded – undo
1727 1727
 	 * @param array   $post_states An array of post display states.
1728 1728
 	 * @param WP_Post $post        The current post object.
1729 1729
 	 */
1730
-	$post_states = apply_filters( 'display_post_states', $post_states, $post );
1730
+	$post_states = apply_filters('display_post_states', $post_states, $post);
1731 1731
 
1732
-	if ( ! empty($post_states) ) {
1732
+	if ( ! empty($post_states)) {
1733 1733
 		$state_count = count($post_states);
1734 1734
 		$i = 0;
1735 1735
 		echo ' &mdash; ';
1736
-		foreach ( $post_states as $state ) {
1736
+		foreach ($post_states as $state) {
1737 1737
 			++$i;
1738
-			( $i == $state_count ) ? $sep = '' : $sep = ', ';
1738
+			($i == $state_count) ? $sep = '' : $sep = ', ';
1739 1739
 			echo "<span class='post-state'>$state$sep</span>";
1740 1740
 		}
1741 1741
 	}
@@ -1746,28 +1746,28 @@  discard block
 block discarded – undo
1746 1746
  *
1747 1747
  * @param WP_Post $post
1748 1748
  */
1749
-function _media_states( $post ) {
1749
+function _media_states($post) {
1750 1750
 	$media_states = array();
1751 1751
 	$stylesheet = get_option('stylesheet');
1752 1752
 
1753
-	if ( current_theme_supports( 'custom-header') ) {
1754
-		$meta_header = get_post_meta($post->ID, '_wp_attachment_is_custom_header', true );
1755
-		if ( ! empty( $meta_header ) && $meta_header == $stylesheet )
1756
-			$media_states[] = __( 'Header Image' );
1753
+	if (current_theme_supports('custom-header')) {
1754
+		$meta_header = get_post_meta($post->ID, '_wp_attachment_is_custom_header', true);
1755
+		if ( ! empty($meta_header) && $meta_header == $stylesheet)
1756
+			$media_states[] = __('Header Image');
1757 1757
 	}
1758 1758
 
1759
-	if ( current_theme_supports( 'custom-background') ) {
1760
-		$meta_background = get_post_meta($post->ID, '_wp_attachment_is_custom_background', true );
1761
-		if ( ! empty( $meta_background ) && $meta_background == $stylesheet )
1762
-			$media_states[] = __( 'Background Image' );
1759
+	if (current_theme_supports('custom-background')) {
1760
+		$meta_background = get_post_meta($post->ID, '_wp_attachment_is_custom_background', true);
1761
+		if ( ! empty($meta_background) && $meta_background == $stylesheet)
1762
+			$media_states[] = __('Background Image');
1763 1763
 	}
1764 1764
 
1765
-	if ( $post->ID == get_option( 'site_icon' ) ) {
1766
-		$media_states[] = __( 'Site Icon' );
1765
+	if ($post->ID == get_option('site_icon')) {
1766
+		$media_states[] = __('Site Icon');
1767 1767
 	}
1768 1768
 
1769
-	if ( $post->ID == get_theme_mod( 'site_logo' ) ) {
1770
-		$media_states[] = __( 'Logo' );
1769
+	if ($post->ID == get_theme_mod('site_logo')) {
1770
+		$media_states[] = __('Logo');
1771 1771
 	}
1772 1772
 
1773 1773
 	/**
@@ -1778,15 +1778,15 @@  discard block
 block discarded – undo
1778 1778
 	 * @param array $media_states An array of media states. Default 'Header Image',
1779 1779
 	 *                            'Background Image', 'Site Icon', 'Logo'.
1780 1780
 	 */
1781
-	$media_states = apply_filters( 'display_media_states', $media_states );
1781
+	$media_states = apply_filters('display_media_states', $media_states);
1782 1782
 
1783
-	if ( ! empty( $media_states ) ) {
1784
-		$state_count = count( $media_states );
1783
+	if ( ! empty($media_states)) {
1784
+		$state_count = count($media_states);
1785 1785
 		$i = 0;
1786 1786
 		echo ' &mdash; ';
1787
-		foreach ( $media_states as $state ) {
1787
+		foreach ($media_states as $state) {
1788 1788
 			++$i;
1789
-			( $i == $state_count ) ? $sep = '' : $sep = ', ';
1789
+			($i == $state_count) ? $sep = '' : $sep = ', ';
1790 1790
 			echo "<span class='post-state'>$state$sep</span>";
1791 1791
 		}
1792 1792
 	}
@@ -1805,7 +1805,7 @@  discard block
 block discarded – undo
1805 1805
 function compression_test() {
1806 1806
 ?>
1807 1807
 	<script type="text/javascript">
1808
-	var compressionNonce = <?php echo wp_json_encode( wp_create_nonce( 'update_can_compress_scripts' ) ); ?>;
1808
+	var compressionNonce = <?php echo wp_json_encode(wp_create_nonce('update_can_compress_scripts')); ?>;
1809 1809
 	var testCompression = {
1810 1810
 		get : function(test) {
1811 1811
 			var x;
@@ -1878,8 +1878,8 @@  discard block
 block discarded – undo
1878 1878
  *                                       as a string such as 'tabindex="1"', though the array format is
1879 1879
  *                                       preferred. Default null.
1880 1880
  */
1881
-function submit_button( $text = null, $type = 'primary', $name = 'submit', $wrap = true, $other_attributes = null ) {
1882
-	echo get_submit_button( $text, $type, $name, $wrap, $other_attributes );
1881
+function submit_button($text = null, $type = 'primary', $name = 'submit', $wrap = true, $other_attributes = null) {
1882
+	echo get_submit_button($text, $type, $name, $wrap, $other_attributes);
1883 1883
 }
1884 1884
 
1885 1885
 /**
@@ -1903,49 +1903,49 @@  discard block
 block discarded – undo
1903 1903
  *                                       Default empty.
1904 1904
  * @return string Submit button HTML.
1905 1905
  */
1906
-function get_submit_button( $text = '', $type = 'primary large', $name = 'submit', $wrap = true, $other_attributes = '' ) {
1907
-	if ( ! is_array( $type ) )
1908
-		$type = explode( ' ', $type );
1909
-
1910
-	$button_shorthand = array( 'primary', 'small', 'large' );
1911
-	$classes = array( 'button' );
1912
-	foreach ( $type as $t ) {
1913
-		if ( 'secondary' === $t || 'button-secondary' === $t )
1906
+function get_submit_button($text = '', $type = 'primary large', $name = 'submit', $wrap = true, $other_attributes = '') {
1907
+	if ( ! is_array($type))
1908
+		$type = explode(' ', $type);
1909
+
1910
+	$button_shorthand = array('primary', 'small', 'large');
1911
+	$classes = array('button');
1912
+	foreach ($type as $t) {
1913
+		if ('secondary' === $t || 'button-secondary' === $t)
1914 1914
 			continue;
1915
-		$classes[] = in_array( $t, $button_shorthand ) ? 'button-' . $t : $t;
1915
+		$classes[] = in_array($t, $button_shorthand) ? 'button-'.$t : $t;
1916 1916
 	}
1917
-	$class = implode( ' ', array_unique( $classes ) );
1917
+	$class = implode(' ', array_unique($classes));
1918 1918
 
1919
-	if ( 'delete' === $type )
1919
+	if ('delete' === $type)
1920 1920
 		$class = 'button-secondary delete';
1921 1921
 
1922
-	$text = $text ? $text : __( 'Save Changes' );
1922
+	$text = $text ? $text : __('Save Changes');
1923 1923
 
1924 1924
 	// Default the id attribute to $name unless an id was specifically provided in $other_attributes
1925 1925
 	$id = $name;
1926
-	if ( is_array( $other_attributes ) && isset( $other_attributes['id'] ) ) {
1926
+	if (is_array($other_attributes) && isset($other_attributes['id'])) {
1927 1927
 		$id = $other_attributes['id'];
1928
-		unset( $other_attributes['id'] );
1928
+		unset($other_attributes['id']);
1929 1929
 	}
1930 1930
 
1931 1931
 	$attributes = '';
1932
-	if ( is_array( $other_attributes ) ) {
1933
-		foreach ( $other_attributes as $attribute => $value ) {
1934
-			$attributes .= $attribute . '="' . esc_attr( $value ) . '" '; // Trailing space is important
1932
+	if (is_array($other_attributes)) {
1933
+		foreach ($other_attributes as $attribute => $value) {
1934
+			$attributes .= $attribute.'="'.esc_attr($value).'" '; // Trailing space is important
1935 1935
 		}
1936
-	} elseif ( ! empty( $other_attributes ) ) { // Attributes provided as a string
1936
+	} elseif ( ! empty($other_attributes)) { // Attributes provided as a string
1937 1937
 		$attributes = $other_attributes;
1938 1938
 	}
1939 1939
 
1940 1940
 	// Don't output empty name and id attributes.
1941
-	$name_attr = $name ? ' name="' . esc_attr( $name ) . '"' : '';
1942
-	$id_attr = $id ? ' id="' . esc_attr( $id ) . '"' : '';
1941
+	$name_attr = $name ? ' name="'.esc_attr($name).'"' : '';
1942
+	$id_attr = $id ? ' id="'.esc_attr($id).'"' : '';
1943 1943
 
1944
-	$button = '<input type="submit"' . $name_attr . $id_attr . ' class="' . esc_attr( $class );
1945
-	$button	.= '" value="' . esc_attr( $text ) . '" ' . $attributes . ' />';
1944
+	$button = '<input type="submit"'.$name_attr.$id_attr.' class="'.esc_attr($class);
1945
+	$button	.= '" value="'.esc_attr($text).'" '.$attributes.' />';
1946 1946
 
1947
-	if ( $wrap ) {
1948
-		$button = '<p class="submit">' . $button . '</p>';
1947
+	if ($wrap) {
1948
+		$button = '<p class="submit">'.$button.'</p>';
1949 1949
 	}
1950 1950
 
1951 1951
 	return $button;
@@ -1958,9 +1958,9 @@  discard block
 block discarded – undo
1958 1958
 function _wp_admin_html_begin() {
1959 1959
 	global $is_IE;
1960 1960
 
1961
-	$admin_html_class = ( is_admin_bar_showing() ) ? 'wp-toolbar' : '';
1961
+	$admin_html_class = (is_admin_bar_showing()) ? 'wp-toolbar' : '';
1962 1962
 
1963
-	if ( $is_IE )
1963
+	if ($is_IE)
1964 1964
 		@header('X-UA-Compatible: IE=edge');
1965 1965
 
1966 1966
 ?>
@@ -1972,13 +1972,13 @@  discard block
 block discarded – undo
1972 1972
 	 *
1973 1973
 	 * @since 2.2.0
1974 1974
 	 */
1975
-	do_action( 'admin_xml_ns' );
1975
+	do_action('admin_xml_ns');
1976 1976
 ?> <?php language_attributes(); ?>>
1977 1977
 <![endif]-->
1978 1978
 <!--[if !(IE 8) ]><!-->
1979 1979
 <html xmlns="http://www.w3.org/1999/xhtml" class="<?php echo $admin_html_class; ?>" <?php
1980 1980
 	/** This action is documented in wp-admin/includes/template.php */
1981
-	do_action( 'admin_xml_ns' );
1981
+	do_action('admin_xml_ns');
1982 1982
 ?> <?php language_attributes(); ?>>
1983 1983
 <!--<![endif]-->
1984 1984
 <head>
@@ -1994,13 +1994,13 @@  discard block
 block discarded – undo
1994 1994
  * @param string $hook_name The hook name (also known as the hook suffix) used to determine the screen.
1995 1995
  * @return WP_Screen Screen object.
1996 1996
  */
1997
-function convert_to_screen( $hook_name ) {
1998
-	if ( ! class_exists( 'WP_Screen', false ) ) {
1999
-		_doing_it_wrong( 'convert_to_screen(), add_meta_box()', __( "Likely direct inclusion of wp-admin/includes/template.php in order to use add_meta_box(). This is very wrong. Hook the add_meta_box() call into the add_meta_boxes action instead." ), '3.3.0' );
2000
-		return (object) array( 'id' => '_invalid', 'base' => '_are_belong_to_us' );
1997
+function convert_to_screen($hook_name) {
1998
+	if ( ! class_exists('WP_Screen', false)) {
1999
+		_doing_it_wrong('convert_to_screen(), add_meta_box()', __("Likely direct inclusion of wp-admin/includes/template.php in order to use add_meta_box(). This is very wrong. Hook the add_meta_box() call into the add_meta_boxes action instead."), '3.3.0');
2000
+		return (object) array('id' => '_invalid', 'base' => '_are_belong_to_us');
2001 2001
 	}
2002 2002
 
2003
-	return WP_Screen::get( $hook_name );
2003
+	return WP_Screen::get($hook_name);
2004 2004
 }
2005 2005
 
2006 2006
 /**
@@ -2013,11 +2013,11 @@  discard block
 block discarded – undo
2013 2013
 	?>
2014 2014
 	<div id="local-storage-notice" class="hidden notice is-dismissible">
2015 2015
 	<p class="local-restore">
2016
-		<?php _e( 'The backup of this post in your browser is different from the version below.' ); ?>
2016
+		<?php _e('The backup of this post in your browser is different from the version below.'); ?>
2017 2017
 		<button type="button" class="button restore-backup"><?php _e('Restore the backup'); ?></button>
2018 2018
 	</p>
2019 2019
 	<p class="help">
2020
-		<?php _e( 'This will replace the current editor content with the last backup version. You can use undo and redo in the editor to get the old content back or to return to the restored version.' ); ?>
2020
+		<?php _e('This will replace the current editor content with the last backup version. You can use undo and redo in the editor to get the old content back or to return to the restored version.'); ?>
2021 2021
 	</p>
2022 2022
 	</div>
2023 2023
 	<?php
@@ -2045,45 +2045,45 @@  discard block
 block discarded – undo
2045 2045
  *                          of echoing it. Default true.
2046 2046
  * }
2047 2047
  */
2048
-function wp_star_rating( $args = array() ) {
2048
+function wp_star_rating($args = array()) {
2049 2049
 	$defaults = array(
2050 2050
 		'rating' => 0,
2051 2051
 		'type'   => 'rating',
2052 2052
 		'number' => 0,
2053 2053
 		'echo'   => true,
2054 2054
 	);
2055
-	$r = wp_parse_args( $args, $defaults );
2055
+	$r = wp_parse_args($args, $defaults);
2056 2056
 
2057 2057
 	// Non-english decimal places when the $rating is coming from a string
2058
-	$rating = str_replace( ',', '.', $r['rating'] );
2058
+	$rating = str_replace(',', '.', $r['rating']);
2059 2059
 
2060 2060
 	// Convert Percentage to star rating, 0..5 in .5 increments
2061
-	if ( 'percent' == $r['type'] ) {
2062
-		$rating = round( $rating / 10, 0 ) / 2;
2061
+	if ('percent' == $r['type']) {
2062
+		$rating = round($rating / 10, 0) / 2;
2063 2063
 	}
2064 2064
 
2065 2065
 	// Calculate the number of each type of star needed
2066
-	$full_stars = floor( $rating );
2067
-	$half_stars = ceil( $rating - $full_stars );
2066
+	$full_stars = floor($rating);
2067
+	$half_stars = ceil($rating - $full_stars);
2068 2068
 	$empty_stars = 5 - $full_stars - $half_stars;
2069 2069
 
2070
-	if ( $r['number'] ) {
2070
+	if ($r['number']) {
2071 2071
 		/* translators: 1: The rating, 2: The number of ratings */
2072
-		$format = _n( '%1$s rating based on %2$s rating', '%1$s rating based on %2$s ratings', $r['number'] );
2073
-		$title = sprintf( $format, number_format_i18n( $rating, 1 ), number_format_i18n( $r['number'] ) );
2072
+		$format = _n('%1$s rating based on %2$s rating', '%1$s rating based on %2$s ratings', $r['number']);
2073
+		$title = sprintf($format, number_format_i18n($rating, 1), number_format_i18n($r['number']));
2074 2074
 	} else {
2075 2075
 		/* translators: 1: The rating */
2076
-		$title = sprintf( __( '%s rating' ), number_format_i18n( $rating, 1 ) );
2076
+		$title = sprintf(__('%s rating'), number_format_i18n($rating, 1));
2077 2077
 	}
2078 2078
 
2079 2079
 	$output = '<div class="star-rating">';
2080
-	$output .= '<span class="screen-reader-text">' . $title . '</span>';
2081
-	$output .= str_repeat( '<div class="star star-full" aria-hidden="true"></div>', $full_stars );
2082
-	$output .= str_repeat( '<div class="star star-half" aria-hidden="true"></div>', $half_stars );
2083
-	$output .= str_repeat( '<div class="star star-empty" aria-hidden="true"></div>', $empty_stars );
2080
+	$output .= '<span class="screen-reader-text">'.$title.'</span>';
2081
+	$output .= str_repeat('<div class="star star-full" aria-hidden="true"></div>', $full_stars);
2082
+	$output .= str_repeat('<div class="star star-half" aria-hidden="true"></div>', $half_stars);
2083
+	$output .= str_repeat('<div class="star star-empty" aria-hidden="true"></div>', $empty_stars);
2084 2084
 	$output .= '</div>';
2085 2085
 
2086
-	if ( $r['echo'] ) {
2086
+	if ($r['echo']) {
2087 2087
 		echo $output;
2088 2088
 	}
2089 2089
 
@@ -2097,5 +2097,5 @@  discard block
 block discarded – undo
2097 2097
  * @since 4.2.0
2098 2098
  */
2099 2099
 function _wp_posts_page_notice() {
2100
-	echo '<div class="notice notice-warning inline"><p>' . __( 'You are currently editing the page that shows your latest posts.' ) . '</p></div>';
2100
+	echo '<div class="notice notice-warning inline"><p>'.__('You are currently editing the page that shows your latest posts.').'</p></div>';
2101 2101
 }
Please login to merge, or discard this patch.
Braces   +212 added lines, -137 removed lines patch added patch discarded remove patch
@@ -191,10 +191,11 @@  discard block
 block discarded – undo
191 191
 function wp_popular_terms_checklist( $taxonomy, $default = 0, $number = 10, $echo = true ) {
192 192
 	$post = get_post();
193 193
 
194
-	if ( $post && $post->ID )
195
-		$checked_terms = wp_get_object_terms($post->ID, $taxonomy, array('fields'=>'ids'));
196
-	else
197
-		$checked_terms = array();
194
+	if ( $post && $post->ID ) {
195
+			$checked_terms = wp_get_object_terms($post->ID, $taxonomy, array('fields'=>'ids'));
196
+	} else {
197
+			$checked_terms = array();
198
+	}
198 199
 
199 200
 	$terms = get_terms( $taxonomy, array( 'orderby' => 'count', 'order' => 'DESC', 'number' => $number, 'hierarchical' => false ) );
200 201
 
@@ -203,8 +204,10 @@  discard block
 block discarded – undo
203 204
 	$popular_ids = array();
204 205
 	foreach ( (array) $terms as $term ) {
205 206
 		$popular_ids[] = $term->term_id;
206
-		if ( !$echo ) // Hack for Ajax use.
207
+		if ( !$echo ) {
208
+			// Hack for Ajax use.
207 209
 			continue;
210
+		}
208 211
 		$id = "popular-$taxonomy-$term->term_id";
209 212
 		$checked = in_array( $term->term_id, $checked_terms ) ? 'checked="checked"' : '';
210 213
 		?>
@@ -248,8 +251,9 @@  discard block
 block discarded – undo
248 251
 
249 252
 	$categories = get_terms( 'link_category', array( 'orderby' => 'name', 'hide_empty' => 0 ) );
250 253
 
251
-	if ( empty( $categories ) )
252
-		return;
254
+	if ( empty( $categories ) ) {
255
+			return;
256
+	}
253 257
 
254 258
 	foreach ( $categories as $category ) {
255 259
 		$cat_id = $category->term_id;
@@ -270,8 +274,9 @@  discard block
 block discarded – undo
270 274
  */
271 275
 function get_inline_data($post) {
272 276
 	$post_type_object = get_post_type_object($post->post_type);
273
-	if ( ! current_user_can( 'edit_post', $post->ID ) )
274
-		return;
277
+	if ( ! current_user_can( 'edit_post', $post->ID ) ) {
278
+			return;
279
+	}
275 280
 
276 281
 	$title = esc_textarea( trim( $post->post_title ) );
277 282
 
@@ -293,14 +298,17 @@  discard block
 block discarded – undo
293 298
 	<div class="ss">' . mysql2date( 's', $post->post_date, false ) . '</div>
294 299
 	<div class="post_password">' . esc_html( $post->post_password ) . '</div>';
295 300
 
296
-	if ( $post_type_object->hierarchical )
297
-		echo '<div class="post_parent">' . $post->post_parent . '</div>';
301
+	if ( $post_type_object->hierarchical ) {
302
+			echo '<div class="post_parent">' . $post->post_parent . '</div>';
303
+	}
298 304
 
299
-	if ( $post->post_type == 'page' )
300
-		echo '<div class="page_template">' . esc_html( get_post_meta( $post->ID, '_wp_page_template', true ) ) . '</div>';
305
+	if ( $post->post_type == 'page' ) {
306
+			echo '<div class="page_template">' . esc_html( get_post_meta( $post->ID, '_wp_page_template', true ) ) . '</div>';
307
+	}
301 308
 
302
-	if ( post_type_supports( $post->post_type, 'page-attributes' ) )
303
-		echo '<div class="menu_order">' . $post->menu_order . '</div>';
309
+	if ( post_type_supports( $post->post_type, 'page-attributes' ) ) {
310
+			echo '<div class="menu_order">' . $post->menu_order . '</div>';
311
+	}
304 312
 
305 313
 	$taxonomy_names = get_object_taxonomies( $post->post_type );
306 314
 	foreach ( $taxonomy_names as $taxonomy_name) {
@@ -330,11 +338,13 @@  discard block
 block discarded – undo
330 338
 		}
331 339
 	}
332 340
 
333
-	if ( !$post_type_object->hierarchical )
334
-		echo '<div class="sticky">' . (is_sticky($post->ID) ? 'sticky' : '') . '</div>';
341
+	if ( !$post_type_object->hierarchical ) {
342
+			echo '<div class="sticky">' . (is_sticky($post->ID) ? 'sticky' : '') . '</div>';
343
+	}
335 344
 
336
-	if ( post_type_supports( $post->post_type, 'post-formats' ) )
337
-		echo '<div class="post_format">' . esc_html( get_post_format( $post->ID ) ) . '</div>';
345
+	if ( post_type_supports( $post->post_type, 'post-formats' ) ) {
346
+			echo '<div class="post_format">' . esc_html( get_post_format( $post->ID ) ) . '</div>';
347
+	}
338 348
 
339 349
 	echo '</div>';
340 350
 }
@@ -387,9 +397,12 @@  discard block
 block discarded – undo
387 397
 <form method="get">
388 398
 <?php if ( $table_row ) : ?>
389 399
 <table style="display:none;"><tbody id="com-reply"><tr id="replyrow" class="inline-edit-row" style="display:none;"><td colspan="<?php echo $wp_list_table->get_column_count(); ?>" class="colspanchange">
390
-<?php else : ?>
400
+<?php else {
401
+	: ?>
391 402
 <div id="com-reply" style="display:none;"><div id="replyrow" style="display:none;">
392
-<?php endif; ?>
403
+<?php endif;
404
+}
405
+?>
393 406
 	<fieldset class="comment-reply">
394 407
 	<legend>
395 408
 		<span class="hidden" id="editlegend"><?php _e( 'Edit Comment' ); ?></span>
@@ -441,15 +454,19 @@  discard block
 block discarded – undo
441 454
 	<input type="hidden" name="mode" id="mode" value="<?php echo esc_attr($mode); ?>" />
442 455
 	<?php
443 456
 		wp_nonce_field( 'replyto-comment', '_ajax_nonce-replyto-comment', false );
444
-		if ( current_user_can( 'unfiltered_html' ) )
445
-			wp_nonce_field( 'unfiltered-html-comment', '_wp_unfiltered_html_comment', false );
457
+		if ( current_user_can( 'unfiltered_html' ) ) {
458
+					wp_nonce_field( 'unfiltered-html-comment', '_wp_unfiltered_html_comment', false );
459
+		}
446 460
 	?>
447 461
 	</fieldset>
448 462
 <?php if ( $table_row ) : ?>
449 463
 </td></tr></tbody></table>
450
-<?php else : ?>
464
+<?php else {
465
+	: ?>
451 466
 </div></div>
452
-<?php endif; ?>
467
+<?php endif;
468
+}
469
+?>
453 470
 </form>
454 471
 <?php
455 472
 }
@@ -505,9 +522,10 @@  discard block
 block discarded – undo
505 522
 	</thead>
506 523
 	<tbody id='the-list' data-wp-lists='list:meta'>
507 524
 <?php
508
-	foreach ( $meta as $entry )
509
-		echo _list_meta_row( $entry, $count );
510
-?>
525
+	foreach ( $meta as $entry ) {
526
+			echo _list_meta_row( $entry, $count );
527
+	}
528
+	?>
511 529
 	</tbody>
512 530
 </table>
513 531
 <?php
@@ -527,11 +545,13 @@  discard block
 block discarded – undo
527 545
 function _list_meta_row( $entry, &$count ) {
528 546
 	static $update_nonce = '';
529 547
 
530
-	if ( is_protected_meta( $entry['meta_key'], 'post' ) )
531
-		return '';
548
+	if ( is_protected_meta( $entry['meta_key'], 'post' ) ) {
549
+			return '';
550
+	}
532 551
 
533
-	if ( ! $update_nonce )
534
-		$update_nonce = wp_create_nonce( 'add-meta' );
552
+	if ( ! $update_nonce ) {
553
+			$update_nonce = wp_create_nonce( 'add-meta' );
554
+	}
535 555
 
536 556
 	$r = '';
537 557
 	++ $count;
@@ -638,8 +658,9 @@  discard block
 block discarded – undo
638 658
 <?php
639 659
 
640 660
 	foreach ( $keys as $key ) {
641
-		if ( is_protected_meta( $key, 'post' ) || ! current_user_can( 'add_post_meta', $post->ID, $key ) )
642
-			continue;
661
+		if ( is_protected_meta( $key, 'post' ) || ! current_user_can( 'add_post_meta', $post->ID, $key ) ) {
662
+					continue;
663
+		}
643 664
 		echo "\n<option value='" . esc_attr($key) . "'>" . esc_html($key) . "</option>";
644 665
 	}
645 666
 ?>
@@ -685,12 +706,14 @@  discard block
 block discarded – undo
685 706
 	global $wp_locale;
686 707
 	$post = get_post();
687 708
 
688
-	if ( $for_post )
689
-		$edit = ! ( in_array($post->post_status, array('draft', 'pending') ) && (!$post->post_date_gmt || '0000-00-00 00:00:00' == $post->post_date_gmt ) );
709
+	if ( $for_post ) {
710
+			$edit = ! ( in_array($post->post_status, array('draft', 'pending') ) && (!$post->post_date_gmt || '0000-00-00 00:00:00' == $post->post_date_gmt ) );
711
+	}
690 712
 
691 713
 	$tab_index_attribute = '';
692
-	if ( (int) $tab_index > 0 )
693
-		$tab_index_attribute = " tabindex=\"$tab_index\"";
714
+	if ( (int) $tab_index > 0 ) {
715
+			$tab_index_attribute = " tabindex=\"$tab_index\"";
716
+	}
694 717
 
695 718
 	// todo: Remove this?
696 719
 	// echo '<label for="timestamp" style="display: block;"><input type="checkbox" class="checkbox" name="edit_date" value="1" id="timestamp"'.$tab_index_attribute.' /> '.__( 'Edit timestamp' ).'</label><br />';
@@ -731,7 +754,9 @@  discard block
 block discarded – undo
731 754
 
732 755
 	echo '</div><input type="hidden" id="ss" name="ss" value="' . $ss . '" />';
733 756
 
734
-	if ( $multi ) return;
757
+	if ( $multi ) {
758
+		return;
759
+	}
735 760
 
736 761
 	echo "\n\n";
737 762
 	$map = array(
@@ -796,8 +821,9 @@  discard block
 block discarded – undo
796 821
 	if ( $items ) {
797 822
 		foreach ( $items as $item ) {
798 823
 			// A page cannot be its own parent.
799
-			if ( $post && $post->ID && $item->ID == $post->ID )
800
-				continue;
824
+			if ( $post && $post->ID && $item->ID == $post->ID ) {
825
+							continue;
826
+			}
801 827
 
802 828
 			$pad = str_repeat( '&nbsp;', $level * 3 );
803 829
 			$selected = selected( $default, $item->ID, false );
@@ -825,10 +851,12 @@  discard block
 block discarded – undo
825 851
 
826 852
 	foreach ( $editable_roles as $role => $details ) {
827 853
 		$name = translate_user_role($details['name'] );
828
-		if ( $selected == $role ) // preselect specified role
854
+		if ( $selected == $role ) {
855
+			// preselect specified role
829 856
 			$p = "\n\t<option selected='selected' value='" . esc_attr($role) . "'>$name</option>";
830
-		else
831
-			$r .= "\n\t<option value='" . esc_attr($role) . "'>$name</option>";
857
+		} else {
858
+					$r .= "\n\t<option value='" . esc_attr($role) . "'>$name</option>";
859
+		}
832 860
 	}
833 861
 	echo $p . $r;
834 862
 }
@@ -857,9 +885,12 @@  discard block
 block discarded – undo
857 885
 	if ( ! empty( $upload_dir['error'] ) ) :
858 886
 		?><div class="error"><p><?php _e('Before you can upload your import file, you will need to fix the following error:'); ?></p>
859 887
 		<p><strong><?php echo $upload_dir['error']; ?></strong></p></div><?php
860
-	else :
888
+	else {
889
+		:
861 890
 ?>
862
-<form enctype="multipart/form-data" id="import-upload-form" method="post" class="wp-upload-form" action="<?php echo esc_url( wp_nonce_url( $action, 'import-upload' ) ); ?>">
891
+<form enctype="multipart/form-data" id="import-upload-form" method="post" class="wp-upload-form" action="<?php echo esc_url( wp_nonce_url( $action, 'import-upload' ) );
892
+	}
893
+	?>">
863 894
 <p>
864 895
 <label for="upload"><?php _e( 'Choose a file from your computer:' ); ?></label> (<?php printf( __('Maximum size: %s' ), $size ); ?>)
865 896
 <input type="file" id="upload" name="import" size="25" />
@@ -919,23 +950,28 @@  discard block
 block discarded – undo
919 950
 
920 951
 	$page = $screen->id;
921 952
 
922
-	if ( !isset($wp_meta_boxes) )
923
-		$wp_meta_boxes = array();
924
-	if ( !isset($wp_meta_boxes[$page]) )
925
-		$wp_meta_boxes[$page] = array();
926
-	if ( !isset($wp_meta_boxes[$page][$context]) )
927
-		$wp_meta_boxes[$page][$context] = array();
953
+	if ( !isset($wp_meta_boxes) ) {
954
+			$wp_meta_boxes = array();
955
+	}
956
+	if ( !isset($wp_meta_boxes[$page]) ) {
957
+			$wp_meta_boxes[$page] = array();
958
+	}
959
+	if ( !isset($wp_meta_boxes[$page][$context]) ) {
960
+			$wp_meta_boxes[$page][$context] = array();
961
+	}
928 962
 
929 963
 	foreach ( array_keys($wp_meta_boxes[$page]) as $a_context ) {
930 964
 		foreach ( array('high', 'core', 'default', 'low') as $a_priority ) {
931
-			if ( !isset($wp_meta_boxes[$page][$a_context][$a_priority][$id]) )
932
-				continue;
965
+			if ( !isset($wp_meta_boxes[$page][$a_context][$a_priority][$id]) ) {
966
+							continue;
967
+			}
933 968
 
934 969
 			// If a core box was previously added or removed by a plugin, don't add.
935 970
 			if ( 'core' == $priority ) {
936 971
 				// If core box previously deleted, don't add
937
-				if ( false === $wp_meta_boxes[$page][$a_context][$a_priority][$id] )
938
-					return;
972
+				if ( false === $wp_meta_boxes[$page][$a_context][$a_priority][$id] ) {
973
+									return;
974
+				}
939 975
 
940 976
 				/*
941 977
 				 * If box was added with default priority, give it core priority to
@@ -960,16 +996,19 @@  discard block
 block discarded – undo
960 996
 				$callback_args = $wp_meta_boxes[$page][$a_context][$a_priority][$id]['args'];
961 997
 			}
962 998
 			// An id can be in only one priority and one context.
963
-			if ( $priority != $a_priority || $context != $a_context )
964
-				unset($wp_meta_boxes[$page][$a_context][$a_priority][$id]);
999
+			if ( $priority != $a_priority || $context != $a_context ) {
1000
+							unset($wp_meta_boxes[$page][$a_context][$a_priority][$id]);
1001
+			}
965 1002
 		}
966 1003
 	}
967 1004
 
968
-	if ( empty($priority) )
969
-		$priority = 'low';
1005
+	if ( empty($priority) ) {
1006
+			$priority = 'low';
1007
+	}
970 1008
 
971
-	if ( !isset($wp_meta_boxes[$page][$context][$priority]) )
972
-		$wp_meta_boxes[$page][$context][$priority] = array();
1009
+	if ( !isset($wp_meta_boxes[$page][$context][$priority]) ) {
1010
+			$wp_meta_boxes[$page][$context][$priority] = array();
1011
+	}
973 1012
 
974 1013
 	$wp_meta_boxes[$page][$context][$priority][$id] = array('id' => $id, 'title' => $title, 'callback' => $callback, 'args' => $callback_args);
975 1014
 }
@@ -991,10 +1030,11 @@  discard block
 block discarded – undo
991 1030
 	global $wp_meta_boxes;
992 1031
 	static $already_sorted = false;
993 1032
 
994
-	if ( empty( $screen ) )
995
-		$screen = get_current_screen();
996
-	elseif ( is_string( $screen ) )
997
-		$screen = convert_to_screen( $screen );
1033
+	if ( empty( $screen ) ) {
1034
+			$screen = get_current_screen();
1035
+	} elseif ( is_string( $screen ) ) {
1036
+			$screen = convert_to_screen( $screen );
1037
+	}
998 1038
 
999 1039
 	$page = $screen->id;
1000 1040
 
@@ -1021,8 +1061,9 @@  discard block
 block discarded – undo
1021 1061
 		foreach ( array( 'high', 'sorted', 'core', 'default', 'low' ) as $priority ) {
1022 1062
 			if ( isset( $wp_meta_boxes[ $page ][ $context ][ $priority ]) ) {
1023 1063
 				foreach ( (array) $wp_meta_boxes[ $page ][ $context ][ $priority ] as $box ) {
1024
-					if ( false == $box || ! $box['title'] )
1025
-						continue;
1064
+					if ( false == $box || ! $box['title'] ) {
1065
+											continue;
1066
+					}
1026 1067
 					$i++;
1027 1068
 					$hidden_class = in_array($box['id'], $hidden) ? ' hide-if-js' : '';
1028 1069
 					echo '<div id="' . $box['id'] . '" class="postbox ' . postbox_classes($box['id'], $page) . $hidden_class . '" ' . '>' . "\n";
@@ -1093,16 +1134,20 @@  discard block
 block discarded – undo
1093 1134
 
1094 1135
 	$page = $screen->id;
1095 1136
 
1096
-	if ( !isset($wp_meta_boxes) )
1097
-		$wp_meta_boxes = array();
1098
-	if ( !isset($wp_meta_boxes[$page]) )
1099
-		$wp_meta_boxes[$page] = array();
1100
-	if ( !isset($wp_meta_boxes[$page][$context]) )
1101
-		$wp_meta_boxes[$page][$context] = array();
1137
+	if ( !isset($wp_meta_boxes) ) {
1138
+			$wp_meta_boxes = array();
1139
+	}
1140
+	if ( !isset($wp_meta_boxes[$page]) ) {
1141
+			$wp_meta_boxes[$page] = array();
1142
+	}
1143
+	if ( !isset($wp_meta_boxes[$page][$context]) ) {
1144
+			$wp_meta_boxes[$page][$context] = array();
1145
+	}
1102 1146
 
1103
-	foreach ( array('high', 'core', 'default', 'low') as $priority )
1104
-		$wp_meta_boxes[$page][$context][$priority][$id] = false;
1105
-}
1147
+	foreach ( array('high', 'core', 'default', 'low') as $priority ) {
1148
+			$wp_meta_boxes[$page][$context][$priority][$id] = false;
1149
+	}
1150
+	}
1106 1151
 
1107 1152
 /**
1108 1153
  * Meta Box Accordion Template Function
@@ -1125,10 +1170,11 @@  discard block
 block discarded – undo
1125 1170
 
1126 1171
 	wp_enqueue_script( 'accordion' );
1127 1172
 
1128
-	if ( empty( $screen ) )
1129
-		$screen = get_current_screen();
1130
-	elseif ( is_string( $screen ) )
1131
-		$screen = convert_to_screen( $screen );
1173
+	if ( empty( $screen ) ) {
1174
+			$screen = get_current_screen();
1175
+	} elseif ( is_string( $screen ) ) {
1176
+			$screen = convert_to_screen( $screen );
1177
+	}
1132 1178
 
1133 1179
 	$page = $screen->id;
1134 1180
 
@@ -1144,8 +1190,9 @@  discard block
 block discarded – undo
1144 1190
 		foreach ( array( 'high', 'core', 'default', 'low' ) as $priority ) {
1145 1191
 			if ( isset( $wp_meta_boxes[ $page ][ $context ][ $priority ] ) ) {
1146 1192
 				foreach ( $wp_meta_boxes[ $page ][ $context ][ $priority ] as $box ) {
1147
-					if ( false == $box || ! $box['title'] )
1148
-						continue;
1193
+					if ( false == $box || ! $box['title'] ) {
1194
+											continue;
1195
+					}
1149 1196
 					$i++;
1150 1197
 					$hidden_class = in_array( $box['id'], $hidden ) ? 'hide-if-js' : '';
1151 1198
 
@@ -1283,18 +1330,22 @@  discard block
 block discarded – undo
1283 1330
 function do_settings_sections( $page ) {
1284 1331
 	global $wp_settings_sections, $wp_settings_fields;
1285 1332
 
1286
-	if ( ! isset( $wp_settings_sections[$page] ) )
1287
-		return;
1333
+	if ( ! isset( $wp_settings_sections[$page] ) ) {
1334
+			return;
1335
+	}
1288 1336
 
1289 1337
 	foreach ( (array) $wp_settings_sections[$page] as $section ) {
1290
-		if ( $section['title'] )
1291
-			echo "<h2>{$section['title']}</h2>\n";
1338
+		if ( $section['title'] ) {
1339
+					echo "<h2>{$section['title']}</h2>\n";
1340
+		}
1292 1341
 
1293
-		if ( $section['callback'] )
1294
-			call_user_func( $section['callback'], $section );
1342
+		if ( $section['callback'] ) {
1343
+					call_user_func( $section['callback'], $section );
1344
+		}
1295 1345
 
1296
-		if ( ! isset( $wp_settings_fields ) || !isset( $wp_settings_fields[$page] ) || !isset( $wp_settings_fields[$page][$section['id']] ) )
1297
-			continue;
1346
+		if ( ! isset( $wp_settings_fields ) || !isset( $wp_settings_fields[$page] ) || !isset( $wp_settings_fields[$page][$section['id']] ) ) {
1347
+					continue;
1348
+		}
1298 1349
 		echo '<table class="form-table">';
1299 1350
 		do_settings_fields( $page, $section['id'] );
1300 1351
 		echo '</table>';
@@ -1318,8 +1369,9 @@  discard block
 block discarded – undo
1318 1369
 function do_settings_fields($page, $section) {
1319 1370
 	global $wp_settings_fields;
1320 1371
 
1321
-	if ( ! isset( $wp_settings_fields[$page][$section] ) )
1322
-		return;
1372
+	if ( ! isset( $wp_settings_fields[$page][$section] ) ) {
1373
+			return;
1374
+	}
1323 1375
 
1324 1376
 	foreach ( (array) $wp_settings_fields[$page][$section] as $field ) {
1325 1377
 		$class = '';
@@ -1409,8 +1461,9 @@  discard block
 block discarded – undo
1409 1461
 	 * This allows the $sanitize_callback from register_setting() to run, adding
1410 1462
 	 * any settings errors you want to show by default.
1411 1463
 	 */
1412
-	if ( $sanitize )
1413
-		sanitize_option( $setting, get_option( $setting ) );
1464
+	if ( $sanitize ) {
1465
+			sanitize_option( $setting, get_option( $setting ) );
1466
+	}
1414 1467
 
1415 1468
 	// If settings were passed back from options.php then use them.
1416 1469
 	if ( isset( $_GET['settings-updated'] ) && $_GET['settings-updated'] && get_transient( 'settings_errors' ) ) {
@@ -1419,15 +1472,17 @@  discard block
 block discarded – undo
1419 1472
 	}
1420 1473
 
1421 1474
 	// Check global in case errors have been added on this pageload.
1422
-	if ( ! count( $wp_settings_errors ) )
1423
-		return array();
1475
+	if ( ! count( $wp_settings_errors ) ) {
1476
+			return array();
1477
+	}
1424 1478
 
1425 1479
 	// Filter the results to those of a specific setting if one was set.
1426 1480
 	if ( $setting ) {
1427 1481
 		$setting_errors = array();
1428 1482
 		foreach ( (array) $wp_settings_errors as $key => $details ) {
1429
-			if ( $setting == $details['setting'] )
1430
-				$setting_errors[] = $wp_settings_errors[$key];
1483
+			if ( $setting == $details['setting'] ) {
1484
+							$setting_errors[] = $wp_settings_errors[$key];
1485
+			}
1431 1486
 		}
1432 1487
 		return $setting_errors;
1433 1488
 	}
@@ -1464,13 +1519,15 @@  discard block
 block discarded – undo
1464 1519
  */
1465 1520
 function settings_errors( $setting = '', $sanitize = false, $hide_on_update = false ) {
1466 1521
 
1467
-	if ( $hide_on_update && ! empty( $_GET['settings-updated'] ) )
1468
-		return;
1522
+	if ( $hide_on_update && ! empty( $_GET['settings-updated'] ) ) {
1523
+			return;
1524
+	}
1469 1525
 
1470 1526
 	$settings_errors = get_settings_errors( $setting, $sanitize );
1471 1527
 
1472
-	if ( empty( $settings_errors ) )
1473
-		return;
1528
+	if ( empty( $settings_errors ) ) {
1529
+			return;
1530
+	}
1474 1531
 
1475 1532
 	$output = '';
1476 1533
 	foreach ( $settings_errors as $key => $details ) {
@@ -1529,9 +1586,10 @@  discard block
 block discarded – undo
1529 1586
  */
1530 1587
 function the_post_password() {
1531 1588
 	$post = get_post();
1532
-	if ( isset( $post->post_password ) )
1533
-		echo esc_attr( $post->post_password );
1534
-}
1589
+	if ( isset( $post->post_password ) ) {
1590
+			echo esc_attr( $post->post_password );
1591
+	}
1592
+	}
1535 1593
 
1536 1594
 /**
1537 1595
  * Get the post title.
@@ -1546,8 +1604,9 @@  discard block
 block discarded – undo
1546 1604
  */
1547 1605
 function _draft_or_post_title( $post = 0 ) {
1548 1606
 	$title = get_the_title( $post );
1549
-	if ( empty( $title ) )
1550
-		$title = __( '(no title)' );
1607
+	if ( empty( $title ) ) {
1608
+			$title = __( '(no title)' );
1609
+	}
1551 1610
 	return esc_html( $title );
1552 1611
 }
1553 1612
 
@@ -1624,8 +1683,9 @@  discard block
 block discarded – undo
1624 1683
 
1625 1684
 $admin_body_class .= ' locale-' . sanitize_html_class( strtolower( str_replace( '_', '-', get_locale() ) ) );
1626 1685
 
1627
-if ( is_rtl() )
1686
+if ( is_rtl() ) {
1628 1687
 	$admin_body_class .= ' rtl';
1688
+}
1629 1689
 
1630 1690
 ?>
1631 1691
 </head>
@@ -1637,7 +1697,10 @@  discard block
 block discarded – undo
1637 1697
 /**
1638 1698
  * @global string $body_id
1639 1699
  */
1640
-if ( isset($GLOBALS['body_id']) ) echo ' id="' . $GLOBALS['body_id'] . '"'; ?> class="wp-admin wp-core-ui no-js iframe <?php echo $admin_body_classes . ' ' . $admin_body_class; ?>">
1700
+if ( isset($GLOBALS['body_id']) ) {
1701
+	echo ' id="' . $GLOBALS['body_id'] . '"';
1702
+}
1703
+?> class="wp-admin wp-core-ui no-js iframe <?php echo $admin_body_classes . ' ' . $admin_body_class; ?>">
1641 1704
 <script type="text/javascript">
1642 1705
 (function(){
1643 1706
 var c = document.body.className;
@@ -1689,21 +1752,27 @@  discard block
 block discarded – undo
1689 1752
  */
1690 1753
 function _post_states($post) {
1691 1754
 	$post_states = array();
1692
-	if ( isset( $_REQUEST['post_status'] ) )
1693
-		$post_status = $_REQUEST['post_status'];
1694
-	else
1695
-		$post_status = '';
1696
-
1697
-	if ( !empty($post->post_password) )
1698
-		$post_states['protected'] = __('Password protected');
1699
-	if ( 'private' == $post->post_status && 'private' != $post_status )
1700
-		$post_states['private'] = __('Private');
1701
-	if ( 'draft' == $post->post_status && 'draft' != $post_status )
1702
-		$post_states['draft'] = __('Draft');
1703
-	if ( 'pending' == $post->post_status && 'pending' != $post_status )
1704
-		$post_states['pending'] = _x('Pending', 'post status');
1705
-	if ( is_sticky($post->ID) )
1706
-		$post_states['sticky'] = __('Sticky');
1755
+	if ( isset( $_REQUEST['post_status'] ) ) {
1756
+			$post_status = $_REQUEST['post_status'];
1757
+	} else {
1758
+			$post_status = '';
1759
+	}
1760
+
1761
+	if ( !empty($post->post_password) ) {
1762
+			$post_states['protected'] = __('Password protected');
1763
+	}
1764
+	if ( 'private' == $post->post_status && 'private' != $post_status ) {
1765
+			$post_states['private'] = __('Private');
1766
+	}
1767
+	if ( 'draft' == $post->post_status && 'draft' != $post_status ) {
1768
+			$post_states['draft'] = __('Draft');
1769
+	}
1770
+	if ( 'pending' == $post->post_status && 'pending' != $post_status ) {
1771
+			$post_states['pending'] = _x('Pending', 'post status');
1772
+	}
1773
+	if ( is_sticky($post->ID) ) {
1774
+			$post_states['sticky'] = __('Sticky');
1775
+	}
1707 1776
 
1708 1777
 	if ( 'future' === $post->post_status ) {
1709 1778
 		$post_states['scheduled'] = __( 'Scheduled' );
@@ -1752,14 +1821,16 @@  discard block
 block discarded – undo
1752 1821
 
1753 1822
 	if ( current_theme_supports( 'custom-header') ) {
1754 1823
 		$meta_header = get_post_meta($post->ID, '_wp_attachment_is_custom_header', true );
1755
-		if ( ! empty( $meta_header ) && $meta_header == $stylesheet )
1756
-			$media_states[] = __( 'Header Image' );
1824
+		if ( ! empty( $meta_header ) && $meta_header == $stylesheet ) {
1825
+					$media_states[] = __( 'Header Image' );
1826
+		}
1757 1827
 	}
1758 1828
 
1759 1829
 	if ( current_theme_supports( 'custom-background') ) {
1760 1830
 		$meta_background = get_post_meta($post->ID, '_wp_attachment_is_custom_background', true );
1761
-		if ( ! empty( $meta_background ) && $meta_background == $stylesheet )
1762
-			$media_states[] = __( 'Background Image' );
1831
+		if ( ! empty( $meta_background ) && $meta_background == $stylesheet ) {
1832
+					$media_states[] = __( 'Background Image' );
1833
+		}
1763 1834
 	}
1764 1835
 
1765 1836
 	if ( $post->ID == get_option( 'site_icon' ) ) {
@@ -1904,20 +1975,23 @@  discard block
 block discarded – undo
1904 1975
  * @return string Submit button HTML.
1905 1976
  */
1906 1977
 function get_submit_button( $text = '', $type = 'primary large', $name = 'submit', $wrap = true, $other_attributes = '' ) {
1907
-	if ( ! is_array( $type ) )
1908
-		$type = explode( ' ', $type );
1978
+	if ( ! is_array( $type ) ) {
1979
+			$type = explode( ' ', $type );
1980
+	}
1909 1981
 
1910 1982
 	$button_shorthand = array( 'primary', 'small', 'large' );
1911 1983
 	$classes = array( 'button' );
1912 1984
 	foreach ( $type as $t ) {
1913
-		if ( 'secondary' === $t || 'button-secondary' === $t )
1914
-			continue;
1985
+		if ( 'secondary' === $t || 'button-secondary' === $t ) {
1986
+					continue;
1987
+		}
1915 1988
 		$classes[] = in_array( $t, $button_shorthand ) ? 'button-' . $t : $t;
1916 1989
 	}
1917 1990
 	$class = implode( ' ', array_unique( $classes ) );
1918 1991
 
1919
-	if ( 'delete' === $type )
1920
-		$class = 'button-secondary delete';
1992
+	if ( 'delete' === $type ) {
1993
+			$class = 'button-secondary delete';
1994
+	}
1921 1995
 
1922 1996
 	$text = $text ? $text : __( 'Save Changes' );
1923 1997
 
@@ -1960,8 +2034,9 @@  discard block
 block discarded – undo
1960 2034
 
1961 2035
 	$admin_html_class = ( is_admin_bar_showing() ) ? 'wp-toolbar' : '';
1962 2036
 
1963
-	if ( $is_IE )
1964
-		@header('X-UA-Compatible: IE=edge');
2037
+	if ( $is_IE ) {
2038
+			@header('X-UA-Compatible: IE=edge');
2039
+	}
1965 2040
 
1966 2041
 ?>
1967 2042
 <!DOCTYPE html>
Please login to merge, or discard this patch.
src/wp-admin/includes/plugin-install.php 1 patch
Spacing   +190 added lines, -190 removed lines patch added patch discarded remove patch
@@ -98,17 +98,17 @@  discard block
 block discarded – undo
98 98
  *         {@link https://developer.wordpress.org/reference/functions/plugins_api/ function reference article}
99 99
  *         for more information on the make-up of possible return values depending on the value of `$action`.
100 100
  */
101
-function plugins_api( $action, $args = array() ) {
101
+function plugins_api($action, $args = array()) {
102 102
 
103
-	if ( is_array( $args ) ) {
103
+	if (is_array($args)) {
104 104
 		$args = (object) $args;
105 105
 	}
106 106
 
107
-	if ( ! isset( $args->per_page ) ) {
107
+	if ( ! isset($args->per_page)) {
108 108
 		$args->per_page = 24;
109 109
 	}
110 110
 
111
-	if ( ! isset( $args->locale ) ) {
111
+	if ( ! isset($args->locale)) {
112 112
 		$args->locale = get_locale();
113 113
 	}
114 114
 
@@ -122,7 +122,7 @@  discard block
 block discarded – undo
122 122
 	 * @param object $args   Plugin API arguments.
123 123
 	 * @param string $action The type of information being requested from the Plugin Install API.
124 124
 	 */
125
-	$args = apply_filters( 'plugins_api_args', $args, $action );
125
+	$args = apply_filters('plugins_api_args', $args, $action);
126 126
 
127 127
 	/**
128 128
 	 * Filters the response for the current WordPress.org Plugin Install API request.
@@ -138,35 +138,35 @@  discard block
 block discarded – undo
138 138
 	 * @param string             $action The type of information being requested from the Plugin Install API.
139 139
 	 * @param object             $args   Plugin API arguments.
140 140
 	 */
141
-	$res = apply_filters( 'plugins_api', false, $action, $args );
141
+	$res = apply_filters('plugins_api', false, $action, $args);
142 142
 
143
-	if ( false === $res ) {
143
+	if (false === $res) {
144 144
 		$url = $http_url = 'http://api.wordpress.org/plugins/info/1.0/';
145
-		if ( $ssl = wp_http_supports( array( 'ssl' ) ) )
146
-			$url = set_url_scheme( $url, 'https' );
145
+		if ($ssl = wp_http_supports(array('ssl')))
146
+			$url = set_url_scheme($url, 'https');
147 147
 
148 148
 		$http_args = array(
149 149
 			'timeout' => 15,
150 150
 			'body' => array(
151 151
 				'action' => $action,
152
-				'request' => serialize( $args )
152
+				'request' => serialize($args)
153 153
 			)
154 154
 		);
155
-		$request = wp_remote_post( $url, $http_args );
155
+		$request = wp_remote_post($url, $http_args);
156 156
 
157
-		if ( $ssl && is_wp_error( $request ) ) {
158
-			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 );
159
-			$request = wp_remote_post( $http_url, $http_args );
157
+		if ($ssl && is_wp_error($request)) {
158
+			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);
159
+			$request = wp_remote_post($http_url, $http_args);
160 160
 		}
161 161
 
162
-		if ( is_wp_error($request) ) {
163
-			$res = new WP_Error('plugins_api_failed', __( '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>.' ), $request->get_error_message() );
162
+		if (is_wp_error($request)) {
163
+			$res = new WP_Error('plugins_api_failed', __('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>.'), $request->get_error_message());
164 164
 		} else {
165
-			$res = maybe_unserialize( wp_remote_retrieve_body( $request ) );
166
-			if ( ! is_object( $res ) && ! is_array( $res ) )
167
-				$res = new WP_Error('plugins_api_failed', __( '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>.' ), wp_remote_retrieve_body( $request ) );
165
+			$res = maybe_unserialize(wp_remote_retrieve_body($request));
166
+			if ( ! is_object($res) && ! is_array($res))
167
+				$res = new WP_Error('plugins_api_failed', __('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>.'), wp_remote_retrieve_body($request));
168 168
 		}
169
-	} elseif ( !is_wp_error($res) ) {
169
+	} elseif ( ! is_wp_error($res)) {
170 170
 		$res->external = true;
171 171
 	}
172 172
 
@@ -179,7 +179,7 @@  discard block
 block discarded – undo
179 179
 	 * @param string          $action The type of information being requested from the Plugin Install API.
180 180
 	 * @param object          $args   Plugin API arguments.
181 181
 	 */
182
-	return apply_filters( 'plugins_api_result', $res, $action, $args );
182
+	return apply_filters('plugins_api_result', $res, $action, $args);
183 183
 }
184 184
 
185 185
 /**
@@ -190,17 +190,17 @@  discard block
 block discarded – undo
190 190
  * @param array $args
191 191
  * @return array
192 192
  */
193
-function install_popular_tags( $args = array() ) {
193
+function install_popular_tags($args = array()) {
194 194
 	$key = md5(serialize($args));
195
-	if ( false !== ($tags = get_site_transient('poptags_' . $key) ) )
195
+	if (false !== ($tags = get_site_transient('poptags_'.$key)))
196 196
 		return $tags;
197 197
 
198 198
 	$tags = plugins_api('hot_tags', $args);
199 199
 
200
-	if ( is_wp_error($tags) )
200
+	if (is_wp_error($tags))
201 201
 		return $tags;
202 202
 
203
-	set_site_transient( 'poptags_' . $key, $tags, 3 * HOUR_IN_SECONDS );
203
+	set_site_transient('poptags_'.$key, $tags, 3 * HOUR_IN_SECONDS);
204 204
 
205 205
 	return $tags;
206 206
 }
@@ -210,35 +210,35 @@  discard block
 block discarded – undo
210 210
  */
211 211
 function install_dashboard() {
212 212
 	?>
213
-	<p><?php printf( __( 'Plugins extend and expand the functionality of WordPress. You may automatically install plugins from the <a href="%1$s">WordPress Plugin Directory</a> or upload a plugin in .zip format by clicking the button at the top of this page.' ), 'https://wordpress.org/plugins/' ); ?></p>
213
+	<p><?php printf(__('Plugins extend and expand the functionality of WordPress. You may automatically install plugins from the <a href="%1$s">WordPress Plugin Directory</a> or upload a plugin in .zip format by clicking the button at the top of this page.'), 'https://wordpress.org/plugins/'); ?></p>
214 214
 
215 215
 	<?php display_plugins_table(); ?>
216 216
 
217 217
 	<div class="plugins-popular-tags-wrapper">
218
-	<h2><?php _e( 'Popular tags' ) ?></h2>
219
-	<p><?php _e( 'You may also browse based on the most popular tags in the Plugin Directory:' ) ?></p>
218
+	<h2><?php _e('Popular tags') ?></h2>
219
+	<p><?php _e('You may also browse based on the most popular tags in the Plugin Directory:') ?></p>
220 220
 	<?php
221 221
 
222 222
 	$api_tags = install_popular_tags();
223 223
 
224 224
 	echo '<p class="popular-tags">';
225
-	if ( is_wp_error($api_tags) ) {
225
+	if (is_wp_error($api_tags)) {
226 226
 		echo $api_tags->get_error_message();
227 227
 	} else {
228 228
 		//Set up the tags in a way which can be interpreted by wp_generate_tag_cloud()
229 229
 		$tags = array();
230
-		foreach ( (array) $api_tags as $tag ) {
231
-			$url = self_admin_url( 'plugin-install.php?tab=search&type=tag&s=' . urlencode( $tag['name'] ) );
230
+		foreach ((array) $api_tags as $tag) {
231
+			$url = self_admin_url('plugin-install.php?tab=search&type=tag&s='.urlencode($tag['name']));
232 232
 			$data = array(
233
-				'link' => esc_url( $url ),
233
+				'link' => esc_url($url),
234 234
 				'name' => $tag['name'],
235 235
 				'slug' => $tag['slug'],
236
-				'id' => sanitize_title_with_dashes( $tag['name'] ),
236
+				'id' => sanitize_title_with_dashes($tag['name']),
237 237
 				'count' => $tag['count']
238 238
 			);
239
-			$tags[ $tag['name'] ] = (object) $data;
239
+			$tags[$tag['name']] = (object) $data;
240 240
 		}
241
-		echo wp_generate_tag_cloud($tags, array( 'single_text' => __('%s plugin'), 'multiple_text' => __('%s plugins') ) );
241
+		echo wp_generate_tag_cloud($tags, array('single_text' => __('%s plugin'), 'multiple_text' => __('%s plugins')));
242 242
 	}
243 243
 	echo '</p><br class="clear" /></div>';
244 244
 }
@@ -251,21 +251,21 @@  discard block
 block discarded – undo
251 251
  *
252 252
  * @param bool $deprecated Not used.
253 253
  */
254
-function install_search_form( $deprecated = true ) {
255
-	$type = isset( $_REQUEST['type'] ) ? wp_unslash( $_REQUEST['type'] ) : 'term';
256
-	$term = isset( $_REQUEST['s'] ) ? wp_unslash( $_REQUEST['s'] ) : '';
254
+function install_search_form($deprecated = true) {
255
+	$type = isset($_REQUEST['type']) ? wp_unslash($_REQUEST['type']) : 'term';
256
+	$term = isset($_REQUEST['s']) ? wp_unslash($_REQUEST['s']) : '';
257 257
 	?><form class="search-form search-plugins" method="get">
258 258
 		<input type="hidden" name="tab" value="search" />
259
-		<label class="screen-reader-text" for="typeselector"><?php _e( 'Search plugins by:' ); ?></label>
259
+		<label class="screen-reader-text" for="typeselector"><?php _e('Search plugins by:'); ?></label>
260 260
 		<select name="type" id="typeselector">
261
-			<option value="term"<?php selected( 'term', $type ); ?>><?php _e( 'Keyword' ); ?></option>
262
-			<option value="author"<?php selected( 'author', $type ); ?>><?php _e( 'Author' ); ?></option>
263
-			<option value="tag"<?php selected( 'tag', $type ); ?>><?php _ex( 'Tag', 'Plugin Installer' ); ?></option>
261
+			<option value="term"<?php selected('term', $type); ?>><?php _e('Keyword'); ?></option>
262
+			<option value="author"<?php selected('author', $type); ?>><?php _e('Author'); ?></option>
263
+			<option value="tag"<?php selected('tag', $type); ?>><?php _ex('Tag', 'Plugin Installer'); ?></option>
264 264
 		</select>
265
-		<label><span class="screen-reader-text"><?php _e( 'Search Plugins' ); ?></span>
266
-			<input type="search" name="s" value="<?php echo esc_attr( $term ) ?>" class="wp-filter-search" placeholder="<?php esc_attr_e( 'Search Plugins' ); ?>" />
265
+		<label><span class="screen-reader-text"><?php _e('Search Plugins'); ?></span>
266
+			<input type="search" name="s" value="<?php echo esc_attr($term) ?>" class="wp-filter-search" placeholder="<?php esc_attr_e('Search Plugins'); ?>" />
267 267
 		</label>
268
-		<?php submit_button( __( 'Search Plugins' ), 'button hide-if-js', false, false, array( 'id' => 'search-submit' ) ); ?>
268
+		<?php submit_button(__('Search Plugins'), 'button hide-if-js', false, false, array('id' => 'search-submit')); ?>
269 269
 	</form><?php
270 270
 }
271 271
 
@@ -278,10 +278,10 @@  discard block
 block discarded – undo
278 278
 <div class="upload-plugin">
279 279
 	<p class="install-help"><?php _e('If you have a plugin in a .zip format, you may install it by uploading it here.'); ?></p>
280 280
 	<form method="post" enctype="multipart/form-data" class="wp-upload-form" action="<?php echo self_admin_url('update.php?action=upload-plugin'); ?>">
281
-		<?php wp_nonce_field( 'plugin-upload' ); ?>
282
-		<label class="screen-reader-text" for="pluginzip"><?php _e( 'Plugin zip file' ); ?></label>
281
+		<?php wp_nonce_field('plugin-upload'); ?>
282
+		<label class="screen-reader-text" for="pluginzip"><?php _e('Plugin zip file'); ?></label>
283 283
 		<input type="file" id="pluginzip" name="pluginzip" />
284
-		<?php submit_button( __( 'Install Now' ), 'button', 'install-plugin-submit', false ); ?>
284
+		<?php submit_button(__('Install Now'), 'button', 'install-plugin-submit', false); ?>
285 285
 	</form>
286 286
 </div>
287 287
 <?php
@@ -293,17 +293,17 @@  discard block
 block discarded – undo
293 293
  *
294 294
  */
295 295
 function install_plugins_favorites_form() {
296
-	$user   = get_user_option( 'wporg_favorites' );
297
-	$action = 'save_wporg_username_' . get_current_user_id();
296
+	$user   = get_user_option('wporg_favorites');
297
+	$action = 'save_wporg_username_'.get_current_user_id();
298 298
 	?>
299
-	<p class="install-help"><?php _e( 'If you have marked plugins as favorites on WordPress.org, you can browse them here.' ); ?></p>
299
+	<p class="install-help"><?php _e('If you have marked plugins as favorites on WordPress.org, you can browse them here.'); ?></p>
300 300
 	<form method="get">
301 301
 		<input type="hidden" name="tab" value="favorites" />
302 302
 		<p>
303
-			<label for="user"><?php _e( 'Your WordPress.org username:' ); ?></label>
304
-			<input type="search" id="user" name="user" value="<?php echo esc_attr( $user ); ?>" />
305
-			<input type="submit" class="button" value="<?php esc_attr_e( 'Get Favorites' ); ?>" />
306
-			<input type="hidden" id="wporg-username-nonce" name="_wpnonce" value="<?php echo esc_attr( wp_create_nonce( $action ) ); ?>" />
303
+			<label for="user"><?php _e('Your WordPress.org username:'); ?></label>
304
+			<input type="search" id="user" name="user" value="<?php echo esc_attr($user); ?>" />
305
+			<input type="submit" class="button" value="<?php esc_attr_e('Get Favorites'); ?>" />
306
+			<input type="hidden" id="wporg-username-nonce" name="_wpnonce" value="<?php echo esc_attr(wp_create_nonce($action)); ?>" />
307 307
 		</p>
308 308
 	</form>
309 309
 	<?php
@@ -319,18 +319,18 @@  discard block
 block discarded – undo
319 319
 function display_plugins_table() {
320 320
 	global $wp_list_table;
321 321
 
322
-	switch ( current_filter() ) {
322
+	switch (current_filter()) {
323 323
 		case 'install_plugins_favorites' :
324
-			if ( empty( $_GET['user'] ) && ! get_user_option( 'wporg_favorites' ) ) {
324
+			if (empty($_GET['user']) && ! get_user_option('wporg_favorites')) {
325 325
 				return;
326 326
 			}
327 327
 			break;
328 328
 		case 'install_plugins_recommended' :
329
-			echo '<p>' . __( 'These suggestions are based on the plugins you and other users have installed.' ) . '</p>';
329
+			echo '<p>'.__('These suggestions are based on the plugins you and other users have installed.').'</p>';
330 330
 			break;
331 331
 		case 'install_plugins_beta' :
332 332
 			printf(
333
-				'<p>' . __( 'You are using a development version of WordPress. These feature plugins are also under development. <a href="%s">Learn more</a>.' ) . '</p>',
333
+				'<p>'.__('You are using a development version of WordPress. These feature plugins are also under development. <a href="%s">Learn more</a>.').'</p>',
334 334
 				'https://make.wordpress.org/core/handbook/about/release-cycle/features-as-plugins/'
335 335
 			);
336 336
 			break;
@@ -354,7 +354,7 @@  discard block
 block discarded – undo
354 354
  */
355 355
 function install_plugin_install_status($api, $loop = false) {
356 356
 	// This function is called recursively, $loop prevents further loops.
357
-	if ( is_array($api) )
357
+	if (is_array($api))
358 358
 		$api = (object) $api;
359 359
 
360 360
 	// Default to a "new" plugin
@@ -367,37 +367,37 @@  discard block
 block discarded – undo
367 367
 	 * and has an update awaiting it.
368 368
 	 */
369 369
 	$update_plugins = get_site_transient('update_plugins');
370
-	if ( isset( $update_plugins->response ) ) {
371
-		foreach ( (array)$update_plugins->response as $file => $plugin ) {
372
-			if ( $plugin->slug === $api->slug ) {
370
+	if (isset($update_plugins->response)) {
371
+		foreach ((array) $update_plugins->response as $file => $plugin) {
372
+			if ($plugin->slug === $api->slug) {
373 373
 				$status = 'update_available';
374 374
 				$update_file = $file;
375 375
 				$version = $plugin->new_version;
376
-				if ( current_user_can('update_plugins') )
377
-					$url = wp_nonce_url(self_admin_url('update.php?action=upgrade-plugin&plugin=' . $update_file), 'upgrade-plugin_' . $update_file);
376
+				if (current_user_can('update_plugins'))
377
+					$url = wp_nonce_url(self_admin_url('update.php?action=upgrade-plugin&plugin='.$update_file), 'upgrade-plugin_'.$update_file);
378 378
 				break;
379 379
 			}
380 380
 		}
381 381
 	}
382 382
 
383
-	if ( 'install' == $status ) {
384
-		if ( is_dir( WP_PLUGIN_DIR . '/' . $api->slug ) ) {
385
-			$installed_plugin = get_plugins('/' . $api->slug);
386
-			if ( empty($installed_plugin) ) {
387
-				if ( current_user_can('install_plugins') )
388
-					$url = wp_nonce_url(self_admin_url('update.php?action=install-plugin&plugin=' . $api->slug), 'install-plugin_' . $api->slug);
383
+	if ('install' == $status) {
384
+		if (is_dir(WP_PLUGIN_DIR.'/'.$api->slug)) {
385
+			$installed_plugin = get_plugins('/'.$api->slug);
386
+			if (empty($installed_plugin)) {
387
+				if (current_user_can('install_plugins'))
388
+					$url = wp_nonce_url(self_admin_url('update.php?action=install-plugin&plugin='.$api->slug), 'install-plugin_'.$api->slug);
389 389
 			} else {
390
-				$key = array_keys( $installed_plugin );
391
-				$key = reset( $key ); //Use the first plugin regardless of the name, Could have issues for multiple-plugins in one directory if they share different version numbers
392
-				$update_file = $api->slug . '/' . $key;
393
-				if ( version_compare($api->version, $installed_plugin[ $key ]['Version'], '=') ){
390
+				$key = array_keys($installed_plugin);
391
+				$key = reset($key); //Use the first plugin regardless of the name, Could have issues for multiple-plugins in one directory if they share different version numbers
392
+				$update_file = $api->slug.'/'.$key;
393
+				if (version_compare($api->version, $installed_plugin[$key]['Version'], '=')) {
394 394
 					$status = 'latest_installed';
395
-				} elseif ( version_compare($api->version, $installed_plugin[ $key ]['Version'], '<') ) {
395
+				} elseif (version_compare($api->version, $installed_plugin[$key]['Version'], '<')) {
396 396
 					$status = 'newer_installed';
397
-					$version = $installed_plugin[ $key ]['Version'];
397
+					$version = $installed_plugin[$key]['Version'];
398 398
 				} else {
399 399
 					//If the above update check failed, Then that probably means that the update checker has out-of-date information, force a refresh
400
-					if ( ! $loop ) {
400
+					if ( ! $loop) {
401 401
 						delete_site_transient('update_plugins');
402 402
 						wp_update_plugins();
403 403
 						return install_plugin_install_status($api, true);
@@ -406,15 +406,15 @@  discard block
 block discarded – undo
406 406
 			}
407 407
 		} else {
408 408
 			// "install" & no directory with that slug
409
-			if ( current_user_can('install_plugins') )
410
-				$url = wp_nonce_url(self_admin_url('update.php?action=install-plugin&plugin=' . $api->slug), 'install-plugin_' . $api->slug);
409
+			if (current_user_can('install_plugins'))
410
+				$url = wp_nonce_url(self_admin_url('update.php?action=install-plugin&plugin='.$api->slug), 'install-plugin_'.$api->slug);
411 411
 		}
412 412
 	}
413
-	if ( isset($_GET['from']) )
414
-		$url .= '&amp;from=' . urlencode( wp_unslash( $_GET['from'] ) );
413
+	if (isset($_GET['from']))
414
+		$url .= '&amp;from='.urlencode(wp_unslash($_GET['from']));
415 415
 
416 416
 	$file = $update_file;
417
-	return compact( 'status', 'url', 'version', 'file' );
417
+	return compact('status', 'url', 'version', 'file');
418 418
 }
419 419
 
420 420
 /**
@@ -428,12 +428,12 @@  discard block
 block discarded – undo
428 428
 function install_plugin_information() {
429 429
 	global $tab;
430 430
 
431
-	if ( empty( $_REQUEST['plugin'] ) ) {
431
+	if (empty($_REQUEST['plugin'])) {
432 432
 		return;
433 433
 	}
434 434
 
435
-	$api = plugins_api( 'plugin_information', array(
436
-		'slug' => wp_unslash( $_REQUEST['plugin'] ),
435
+	$api = plugins_api('plugin_information', array(
436
+		'slug' => wp_unslash($_REQUEST['plugin']),
437 437
 		'is_ssl' => is_ssl(),
438 438
 		'fields' => array(
439 439
 			'banners' => true,
@@ -441,67 +441,67 @@  discard block
 block discarded – undo
441 441
 			'downloaded' => false,
442 442
 			'active_installs' => true
443 443
 		)
444
-	) );
444
+	));
445 445
 
446
-	if ( is_wp_error( $api ) ) {
447
-		wp_die( $api );
446
+	if (is_wp_error($api)) {
447
+		wp_die($api);
448 448
 	}
449 449
 
450 450
 	$plugins_allowedtags = array(
451
-		'a' => array( 'href' => array(), 'title' => array(), 'target' => array() ),
452
-		'abbr' => array( 'title' => array() ), 'acronym' => array( 'title' => array() ),
451
+		'a' => array('href' => array(), 'title' => array(), 'target' => array()),
452
+		'abbr' => array('title' => array()), 'acronym' => array('title' => array()),
453 453
 		'code' => array(), 'pre' => array(), 'em' => array(), 'strong' => array(),
454
-		'div' => array( 'class' => array() ), 'span' => array( 'class' => array() ),
454
+		'div' => array('class' => array()), 'span' => array('class' => array()),
455 455
 		'p' => array(), 'ul' => array(), 'ol' => array(), 'li' => array(),
456 456
 		'h1' => array(), 'h2' => array(), 'h3' => array(), 'h4' => array(), 'h5' => array(), 'h6' => array(),
457
-		'img' => array( 'src' => array(), 'class' => array(), 'alt' => array() )
457
+		'img' => array('src' => array(), 'class' => array(), 'alt' => array())
458 458
 	);
459 459
 
460 460
 	$plugins_section_titles = array(
461
-		'description'  => _x( 'Description',  'Plugin installer section title' ),
462
-		'installation' => _x( 'Installation', 'Plugin installer section title' ),
463
-		'faq'          => _x( 'FAQ',          'Plugin installer section title' ),
464
-		'screenshots'  => _x( 'Screenshots',  'Plugin installer section title' ),
465
-		'changelog'    => _x( 'Changelog',    'Plugin installer section title' ),
466
-		'reviews'      => _x( 'Reviews',      'Plugin installer section title' ),
467
-		'other_notes'  => _x( 'Other Notes',  'Plugin installer section title' )
461
+		'description'  => _x('Description', 'Plugin installer section title'),
462
+		'installation' => _x('Installation', 'Plugin installer section title'),
463
+		'faq'          => _x('FAQ', 'Plugin installer section title'),
464
+		'screenshots'  => _x('Screenshots', 'Plugin installer section title'),
465
+		'changelog'    => _x('Changelog', 'Plugin installer section title'),
466
+		'reviews'      => _x('Reviews', 'Plugin installer section title'),
467
+		'other_notes'  => _x('Other Notes', 'Plugin installer section title')
468 468
 	);
469 469
 
470 470
 	// Sanitize HTML
471
-	foreach ( (array) $api->sections as $section_name => $content ) {
472
-		$api->sections[$section_name] = wp_kses( $content, $plugins_allowedtags );
471
+	foreach ((array) $api->sections as $section_name => $content) {
472
+		$api->sections[$section_name] = wp_kses($content, $plugins_allowedtags);
473 473
 	}
474 474
 
475
-	foreach ( array( 'version', 'author', 'requires', 'tested', 'homepage', 'downloaded', 'slug' ) as $key ) {
476
-		if ( isset( $api->$key ) ) {
477
-			$api->$key = wp_kses( $api->$key, $plugins_allowedtags );
475
+	foreach (array('version', 'author', 'requires', 'tested', 'homepage', 'downloaded', 'slug') as $key) {
476
+		if (isset($api->$key)) {
477
+			$api->$key = wp_kses($api->$key, $plugins_allowedtags);
478 478
 		}
479 479
 	}
480 480
 
481
-	$_tab = esc_attr( $tab );
481
+	$_tab = esc_attr($tab);
482 482
 
483
-	$section = isset( $_REQUEST['section'] ) ? wp_unslash( $_REQUEST['section'] ) : 'description'; // Default to the Description tab, Do not translate, API returns English.
484
-	if ( empty( $section ) || ! isset( $api->sections[ $section ] ) ) {
485
-		$section_titles = array_keys( (array) $api->sections );
486
-		$section = reset( $section_titles );
483
+	$section = isset($_REQUEST['section']) ? wp_unslash($_REQUEST['section']) : 'description'; // Default to the Description tab, Do not translate, API returns English.
484
+	if (empty($section) || ! isset($api->sections[$section])) {
485
+		$section_titles = array_keys((array) $api->sections);
486
+		$section = reset($section_titles);
487 487
 	}
488 488
 
489
-	iframe_header( __( 'Plugin Install' ) );
489
+	iframe_header(__('Plugin Install'));
490 490
 
491 491
 	$_with_banner = '';
492 492
 
493
-	if ( ! empty( $api->banners ) && ( ! empty( $api->banners['low'] ) || ! empty( $api->banners['high'] ) ) ) {
493
+	if ( ! empty($api->banners) && ( ! empty($api->banners['low']) || ! empty($api->banners['high']))) {
494 494
 		$_with_banner = 'with-banner';
495
-		$low  = empty( $api->banners['low'] ) ? $api->banners['high'] : $api->banners['low'];
496
-		$high = empty( $api->banners['high'] ) ? $api->banners['low'] : $api->banners['high'];
495
+		$low  = empty($api->banners['low']) ? $api->banners['high'] : $api->banners['low'];
496
+		$high = empty($api->banners['high']) ? $api->banners['low'] : $api->banners['high'];
497 497
 		?>
498 498
 		<style type="text/css">
499 499
 			#plugin-information-title.with-banner {
500
-				background-image: url( <?php echo esc_url( $low ); ?> );
500
+				background-image: url( <?php echo esc_url($low); ?> );
501 501
 			}
502 502
 			@media only screen and ( -webkit-min-device-pixel-ratio: 1.5 ) {
503 503
 				#plugin-information-title.with-banner {
504
-					background-image: url( <?php echo esc_url( $high ); ?> );
504
+					background-image: url( <?php echo esc_url($high); ?> );
505 505
 				}
506 506
 			}
507 507
 		</style>
@@ -512,21 +512,21 @@  discard block
 block discarded – undo
512 512
 	echo "<div id='{$_tab}-title' class='{$_with_banner}'><div class='vignette'></div><h2>{$api->name}</h2></div>";
513 513
 	echo "<div id='{$_tab}-tabs' class='{$_with_banner}'>\n";
514 514
 
515
-	foreach ( (array) $api->sections as $section_name => $content ) {
516
-		if ( 'reviews' === $section_name && ( empty( $api->ratings ) || 0 === array_sum( (array) $api->ratings ) ) ) {
515
+	foreach ((array) $api->sections as $section_name => $content) {
516
+		if ('reviews' === $section_name && (empty($api->ratings) || 0 === array_sum((array) $api->ratings))) {
517 517
 			continue;
518 518
 		}
519 519
 
520
-		if ( isset( $plugins_section_titles[ $section_name ] ) ) {
521
-			$title = $plugins_section_titles[ $section_name ];
520
+		if (isset($plugins_section_titles[$section_name])) {
521
+			$title = $plugins_section_titles[$section_name];
522 522
 		} else {
523
-			$title = ucwords( str_replace( '_', ' ', $section_name ) );
523
+			$title = ucwords(str_replace('_', ' ', $section_name));
524 524
 		}
525 525
 
526
-		$class = ( $section_name === $section ) ? ' class="current"' : '';
527
-		$href = add_query_arg( array('tab' => $tab, 'section' => $section_name) );
528
-		$href = esc_url( $href );
529
-		$san_section = esc_attr( $section_name );
526
+		$class = ($section_name === $section) ? ' class="current"' : '';
527
+		$href = add_query_arg(array('tab' => $tab, 'section' => $section_name));
528
+		$href = esc_url($href);
529
+		$san_section = esc_attr($section_name);
530 530
 		echo "\t<a name='$san_section' href='$href' $class>$title</a>\n";
531 531
 	}
532 532
 
@@ -536,86 +536,86 @@  discard block
 block discarded – undo
536 536
 <div id="<?php echo $_tab; ?>-content" class='<?php echo $_with_banner; ?>'>
537 537
 	<div class="fyi">
538 538
 		<ul>
539
-			<?php if ( ! empty( $api->version ) ) { ?>
540
-				<li><strong><?php _e( 'Version:' ); ?></strong> <?php echo $api->version; ?></li>
541
-			<?php } if ( ! empty( $api->author ) ) { ?>
542
-				<li><strong><?php _e( 'Author:' ); ?></strong> <?php echo links_add_target( $api->author, '_blank' ); ?></li>
543
-			<?php } if ( ! empty( $api->last_updated ) ) { ?>
544
-				<li><strong><?php _e( 'Last Updated:' ); ?></strong>
539
+			<?php if ( ! empty($api->version)) { ?>
540
+				<li><strong><?php _e('Version:'); ?></strong> <?php echo $api->version; ?></li>
541
+			<?php } if ( ! empty($api->author)) { ?>
542
+				<li><strong><?php _e('Author:'); ?></strong> <?php echo links_add_target($api->author, '_blank'); ?></li>
543
+			<?php } if ( ! empty($api->last_updated)) { ?>
544
+				<li><strong><?php _e('Last Updated:'); ?></strong>
545 545
 					<?php
546 546
 					/* translators: %s: Time since the last update */
547
-					printf( __( '%s ago' ), human_time_diff( strtotime( $api->last_updated ) ) );
547
+					printf(__('%s ago'), human_time_diff(strtotime($api->last_updated)));
548 548
 					?>
549 549
 				</li>
550
-			<?php } if ( ! empty( $api->requires ) ) { ?>
550
+			<?php } if ( ! empty($api->requires)) { ?>
551 551
 				<li>
552
-					<strong><?php _e( 'Requires WordPress Version:' ); ?></strong>
552
+					<strong><?php _e('Requires WordPress Version:'); ?></strong>
553 553
 					<?php
554 554
 					/* translators: %s: WordPress version */
555
-					printf( __( '%s or higher' ), $api->requires );
555
+					printf(__('%s or higher'), $api->requires);
556 556
 					?>
557 557
 				</li>
558
-			<?php } if ( ! empty( $api->tested ) ) { ?>
559
-				<li><strong><?php _e( 'Compatible up to:' ); ?></strong> <?php echo $api->tested; ?></li>
560
-			<?php } if ( ! empty( $api->active_installs ) ) { ?>
561
-				<li><strong><?php _e( 'Active Installs:' ); ?></strong> <?php
562
-					if ( $api->active_installs >= 1000000 ) {
563
-						_ex( '1+ Million', 'Active plugin installs' );
558
+			<?php } if ( ! empty($api->tested)) { ?>
559
+				<li><strong><?php _e('Compatible up to:'); ?></strong> <?php echo $api->tested; ?></li>
560
+			<?php } if ( ! empty($api->active_installs)) { ?>
561
+				<li><strong><?php _e('Active Installs:'); ?></strong> <?php
562
+					if ($api->active_installs >= 1000000) {
563
+						_ex('1+ Million', 'Active plugin installs');
564 564
 					} else {
565
-						echo number_format_i18n( $api->active_installs ) . '+';
565
+						echo number_format_i18n($api->active_installs).'+';
566 566
 					}
567 567
 					?></li>
568
-			<?php } if ( ! empty( $api->slug ) && empty( $api->external ) ) { ?>
569
-				<li><a target="_blank" href="https://wordpress.org/plugins/<?php echo $api->slug; ?>/"><?php _e( 'WordPress.org Plugin Page &#187;' ); ?></a></li>
570
-			<?php } if ( ! empty( $api->homepage ) ) { ?>
571
-				<li><a target="_blank" href="<?php echo esc_url( $api->homepage ); ?>"><?php _e( 'Plugin Homepage &#187;' ); ?></a></li>
572
-			<?php } if ( ! empty( $api->donate_link ) && empty( $api->contributors ) ) { ?>
573
-				<li><a target="_blank" href="<?php echo esc_url( $api->donate_link ); ?>"><?php _e( 'Donate to this plugin &#187;' ); ?></a></li>
568
+			<?php } if ( ! empty($api->slug) && empty($api->external)) { ?>
569
+				<li><a target="_blank" href="https://wordpress.org/plugins/<?php echo $api->slug; ?>/"><?php _e('WordPress.org Plugin Page &#187;'); ?></a></li>
570
+			<?php } if ( ! empty($api->homepage)) { ?>
571
+				<li><a target="_blank" href="<?php echo esc_url($api->homepage); ?>"><?php _e('Plugin Homepage &#187;'); ?></a></li>
572
+			<?php } if ( ! empty($api->donate_link) && empty($api->contributors)) { ?>
573
+				<li><a target="_blank" href="<?php echo esc_url($api->donate_link); ?>"><?php _e('Donate to this plugin &#187;'); ?></a></li>
574 574
 			<?php } ?>
575 575
 		</ul>
576
-		<?php if ( ! empty( $api->rating ) ) { ?>
577
-			<h3><?php _e( 'Average Rating' ); ?></h3>
578
-			<?php wp_star_rating( array( 'rating' => $api->rating, 'type' => 'percent', 'number' => $api->num_ratings ) ); ?>
579
-			<p aria-hidden="true" class="fyi-description"><?php printf( _n( '(based on %s rating)', '(based on %s ratings)', $api->num_ratings ), number_format_i18n( $api->num_ratings ) ); ?></p>
576
+		<?php if ( ! empty($api->rating)) { ?>
577
+			<h3><?php _e('Average Rating'); ?></h3>
578
+			<?php wp_star_rating(array('rating' => $api->rating, 'type' => 'percent', 'number' => $api->num_ratings)); ?>
579
+			<p aria-hidden="true" class="fyi-description"><?php printf(_n('(based on %s rating)', '(based on %s ratings)', $api->num_ratings), number_format_i18n($api->num_ratings)); ?></p>
580 580
 		<?php }
581 581
 
582
-		if ( ! empty( $api->ratings ) && array_sum( (array) $api->ratings ) > 0 ) { ?>
583
-			<h3><?php _e( 'Reviews' ); ?></h3>
584
-			<p class="fyi-description"><?php _e( 'Read all reviews on WordPress.org or write your own!' ); ?></p>
582
+		if ( ! empty($api->ratings) && array_sum((array) $api->ratings) > 0) { ?>
583
+			<h3><?php _e('Reviews'); ?></h3>
584
+			<p class="fyi-description"><?php _e('Read all reviews on WordPress.org or write your own!'); ?></p>
585 585
 			<?php
586
-			foreach ( $api->ratings as $key => $ratecount ) {
586
+			foreach ($api->ratings as $key => $ratecount) {
587 587
 				// Avoid div-by-zero.
588
-				$_rating = $api->num_ratings ? ( $ratecount / $api->num_ratings ) : 0;
588
+				$_rating = $api->num_ratings ? ($ratecount / $api->num_ratings) : 0;
589 589
 				/* translators: 1: number of stars (used to determine singular/plural), 2: number of reviews */
590
-				$aria_label = esc_attr( sprintf( _n( 'Reviews with %1$d star: %2$s. Opens in a new window.', 'Reviews with %1$d stars: %2$s. Opens in a new window.', $key ),
590
+				$aria_label = esc_attr(sprintf(_n('Reviews with %1$d star: %2$s. Opens in a new window.', 'Reviews with %1$d stars: %2$s. Opens in a new window.', $key),
591 591
 					$key,
592
-					number_format_i18n( $ratecount )
593
-				) );
592
+					number_format_i18n($ratecount)
593
+				));
594 594
 				?>
595 595
 				<div class="counter-container">
596 596
 						<span class="counter-label"><a href="https://wordpress.org/support/view/plugin-reviews/<?php echo $api->slug; ?>?filter=<?php echo $key; ?>"
597
-						                               target="_blank" aria-label="<?php echo $aria_label; ?>"><?php printf( _n( '%d star', '%d stars', $key ), $key ); ?></a></span>
597
+						                               target="_blank" aria-label="<?php echo $aria_label; ?>"><?php printf(_n('%d star', '%d stars', $key), $key); ?></a></span>
598 598
 						<span class="counter-back">
599 599
 							<span class="counter-bar" style="width: <?php echo 92 * $_rating; ?>px;"></span>
600 600
 						</span>
601
-					<span class="counter-count" aria-hidden="true"><?php echo number_format_i18n( $ratecount ); ?></span>
601
+					<span class="counter-count" aria-hidden="true"><?php echo number_format_i18n($ratecount); ?></span>
602 602
 				</div>
603 603
 				<?php
604 604
 			}
605 605
 		}
606
-		if ( ! empty( $api->contributors ) ) { ?>
607
-			<h3><?php _e( 'Contributors' ); ?></h3>
606
+		if ( ! empty($api->contributors)) { ?>
607
+			<h3><?php _e('Contributors'); ?></h3>
608 608
 			<ul class="contributors">
609 609
 				<?php
610
-				foreach ( (array) $api->contributors as $contrib_username => $contrib_profile ) {
611
-					if ( empty( $contrib_username ) && empty( $contrib_profile ) ) {
610
+				foreach ((array) $api->contributors as $contrib_username => $contrib_profile) {
611
+					if (empty($contrib_username) && empty($contrib_profile)) {
612 612
 						continue;
613 613
 					}
614
-					if ( empty( $contrib_username ) ) {
615
-						$contrib_username = preg_replace( '/^.+\/(.+)\/?$/', '\1', $contrib_profile );
614
+					if (empty($contrib_username)) {
615
+						$contrib_username = preg_replace('/^.+\/(.+)\/?$/', '\1', $contrib_profile);
616 616
 					}
617
-					$contrib_username = sanitize_user( $contrib_username );
618
-					if ( empty( $contrib_profile ) ) {
617
+					$contrib_username = sanitize_user($contrib_username);
618
+					if (empty($contrib_profile)) {
619 619
 						echo "<li><img src='https://wordpress.org/grav-redirect.php?user={$contrib_username}&amp;s=36' width='18' height='18' alt='' />{$contrib_username}</li>";
620 620
 					} else {
621 621
 						echo "<li><a href='{$contrib_profile}' target='_blank'><img src='https://wordpress.org/grav-redirect.php?user={$contrib_username}&amp;s=36' width='18' height='18' alt='' />{$contrib_username}</a></li>";
@@ -623,26 +623,26 @@  discard block
 block discarded – undo
623 623
 				}
624 624
 				?>
625 625
 			</ul>
626
-			<?php if ( ! empty( $api->donate_link ) ) { ?>
627
-				<a target="_blank" href="<?php echo esc_url( $api->donate_link ); ?>"><?php _e( 'Donate to this plugin &#187;' ); ?></a>
626
+			<?php if ( ! empty($api->donate_link)) { ?>
627
+				<a target="_blank" href="<?php echo esc_url($api->donate_link); ?>"><?php _e('Donate to this plugin &#187;'); ?></a>
628 628
 			<?php } ?>
629 629
 		<?php } ?>
630 630
 	</div>
631 631
 	<div id="section-holder" class="wrap">
632 632
 	<?php
633
-	if ( ! empty( $api->tested ) && version_compare( substr( $GLOBALS['wp_version'], 0, strlen( $api->tested ) ), $api->tested, '>' ) ) {
634
-		echo '<div class="notice notice-warning notice-alt"><p>' . __( '<strong>Warning:</strong> This plugin has <strong>not been tested</strong> with your current version of WordPress.' ) . '</p></div>';
635
-	} elseif ( ! empty( $api->requires ) && version_compare( substr( $GLOBALS['wp_version'], 0, strlen( $api->requires ) ), $api->requires, '<' ) ) {
636
-		echo '<div class="notice notice-warning notice-alt"><p>' . __( '<strong>Warning:</strong> This plugin has <strong>not been marked as compatible</strong> with your version of WordPress.' ) . '</p></div>';
633
+	if ( ! empty($api->tested) && version_compare(substr($GLOBALS['wp_version'], 0, strlen($api->tested)), $api->tested, '>')) {
634
+		echo '<div class="notice notice-warning notice-alt"><p>'.__('<strong>Warning:</strong> This plugin has <strong>not been tested</strong> with your current version of WordPress.').'</p></div>';
635
+	} elseif ( ! empty($api->requires) && version_compare(substr($GLOBALS['wp_version'], 0, strlen($api->requires)), $api->requires, '<')) {
636
+		echo '<div class="notice notice-warning notice-alt"><p>'.__('<strong>Warning:</strong> This plugin has <strong>not been marked as compatible</strong> with your version of WordPress.').'</p></div>';
637 637
 	}
638 638
 
639
-	foreach ( (array) $api->sections as $section_name => $content ) {
640
-		$content = links_add_base_url( $content, 'https://wordpress.org/plugins/' . $api->slug . '/' );
641
-		$content = links_add_target( $content, '_blank' );
639
+	foreach ((array) $api->sections as $section_name => $content) {
640
+		$content = links_add_base_url($content, 'https://wordpress.org/plugins/'.$api->slug.'/');
641
+		$content = links_add_target($content, '_blank');
642 642
 
643
-		$san_section = esc_attr( $section_name );
643
+		$san_section = esc_attr($section_name);
644 644
 
645
-		$display = ( $section_name === $section ) ? 'block' : 'none';
645
+		$display = ($section_name === $section) ? 'block' : 'none';
646 646
 
647 647
 		echo "\t<div id='section-{$san_section}' class='section' style='display: {$display};'>\n";
648 648
 		echo $content;
@@ -652,25 +652,25 @@  discard block
 block discarded – undo
652 652
 	echo "</div>\n";
653 653
 	echo "</div>\n"; // #plugin-information-scrollable
654 654
 	echo "<div id='$tab-footer'>\n";
655
-	if ( ! empty( $api->download_link ) && ( current_user_can( 'install_plugins' ) || current_user_can( 'update_plugins' ) ) ) {
656
-		$status = install_plugin_install_status( $api );
657
-		switch ( $status['status'] ) {
655
+	if ( ! empty($api->download_link) && (current_user_can('install_plugins') || current_user_can('update_plugins'))) {
656
+		$status = install_plugin_install_status($api);
657
+		switch ($status['status']) {
658 658
 			case 'install':
659
-				if ( $status['url'] ) {
660
-					echo '<a data-slug="' . esc_attr( $api->slug ) . '" id="plugin_install_from_iframe" class="button button-primary right" href="' . $status['url'] . '" target="_parent">' . __( 'Install Now' ) . '</a>';
659
+				if ($status['url']) {
660
+					echo '<a data-slug="'.esc_attr($api->slug).'" id="plugin_install_from_iframe" class="button button-primary right" href="'.$status['url'].'" target="_parent">'.__('Install Now').'</a>';
661 661
 				}
662 662
 				break;
663 663
 			case 'update_available':
664
-				if ( $status['url'] ) {
665
-					echo '<a data-slug="' . esc_attr( $api->slug ) . '" data-plugin="' . esc_attr( $status['file'] ) . '" id="plugin_update_from_iframe" class="button button-primary right" href="' . $status['url'] . '" target="_parent">' . __( 'Install Update Now' ) .'</a>';
664
+				if ($status['url']) {
665
+					echo '<a data-slug="'.esc_attr($api->slug).'" data-plugin="'.esc_attr($status['file']).'" id="plugin_update_from_iframe" class="button button-primary right" href="'.$status['url'].'" target="_parent">'.__('Install Update Now').'</a>';
666 666
 				}
667 667
 				break;
668 668
 			case 'newer_installed':
669 669
 				/* translators: %s: Plugin version */
670
-				echo '<a class="button button-primary right disabled">' . sprintf( __( 'Newer Version (%s) Installed'), $status['version'] ) . '</a>';
670
+				echo '<a class="button button-primary right disabled">'.sprintf(__('Newer Version (%s) Installed'), $status['version']).'</a>';
671 671
 				break;
672 672
 			case 'latest_installed':
673
-				echo '<a class="button button-primary right disabled">' . __( 'Latest Version Installed' ) . '</a>';
673
+				echo '<a class="button button-primary right disabled">'.__('Latest Version Installed').'</a>';
674 674
 				break;
675 675
 		}
676 676
 	}
Please login to merge, or discard this patch.
src/wp-admin/includes/deprecated.php 1 patch
Spacing   +176 added lines, -176 removed lines patch added patch discarded remove patch
@@ -18,7 +18,7 @@  discard block
 block discarded – undo
18 18
  * @see wp_editor()
19 19
  */
20 20
 function tinymce_include() {
21
-	_deprecated_function( __FUNCTION__, '2.1.0', 'wp_editor()' );
21
+	_deprecated_function(__FUNCTION__, '2.1.0', 'wp_editor()');
22 22
 
23 23
 	wp_tiny_mce();
24 24
 }
@@ -31,7 +31,7 @@  discard block
 block discarded – undo
31 31
  *
32 32
  */
33 33
 function documentation_link() {
34
-	_deprecated_function( __FUNCTION__, '2.5.0' );
34
+	_deprecated_function(__FUNCTION__, '2.5.0');
35 35
 }
36 36
 
37 37
 /**
@@ -47,9 +47,9 @@  discard block
 block discarded – undo
47 47
  * @param int $hmax Maximum wanted height
48 48
  * @return array Shrunk dimensions (width, height).
49 49
  */
50
-function wp_shrink_dimensions( $width, $height, $wmax = 128, $hmax = 96 ) {
51
-	_deprecated_function( __FUNCTION__, '3.0.0', 'wp_constrain_dimensions()' );
52
-	return wp_constrain_dimensions( $width, $height, $wmax, $hmax );
50
+function wp_shrink_dimensions($width, $height, $wmax = 128, $hmax = 96) {
51
+	_deprecated_function(__FUNCTION__, '3.0.0', 'wp_constrain_dimensions()');
52
+	return wp_constrain_dimensions($width, $height, $wmax, $hmax);
53 53
 }
54 54
 
55 55
 /**
@@ -63,9 +63,9 @@  discard block
 block discarded – undo
63 63
  * @param int $height Current height of the image
64 64
  * @return array Shrunk dimensions (width, height).
65 65
  */
66
-function get_udims( $width, $height ) {
67
-	_deprecated_function( __FUNCTION__, '3.5.0', 'wp_constrain_dimensions()' );
68
-	return wp_constrain_dimensions( $width, $height, 128, 96 );
66
+function get_udims($width, $height) {
67
+	_deprecated_function(__FUNCTION__, '3.5.0', 'wp_constrain_dimensions()');
68
+	return wp_constrain_dimensions($width, $height, 128, 96);
69 69
 }
70 70
 
71 71
 /**
@@ -79,10 +79,10 @@  discard block
 block discarded – undo
79 79
  * @param int $parent        Unused.
80 80
  * @param array $popular_ids Unused.
81 81
  */
82
-function dropdown_categories( $default = 0, $parent = 0, $popular_ids = array() ) {
83
-	_deprecated_function( __FUNCTION__, '2.6.0', 'wp_category_checklist()' );
82
+function dropdown_categories($default = 0, $parent = 0, $popular_ids = array()) {
83
+	_deprecated_function(__FUNCTION__, '2.6.0', 'wp_category_checklist()');
84 84
 	global $post_ID;
85
-	wp_category_checklist( $post_ID );
85
+	wp_category_checklist($post_ID);
86 86
 }
87 87
 
88 88
 /**
@@ -94,10 +94,10 @@  discard block
 block discarded – undo
94 94
  *
95 95
  * @param int $default Unused.
96 96
  */
97
-function dropdown_link_categories( $default = 0 ) {
98
-	_deprecated_function( __FUNCTION__, '2.6.0', 'wp_link_category_checklist()' );
97
+function dropdown_link_categories($default = 0) {
98
+	_deprecated_function(__FUNCTION__, '2.6.0', 'wp_link_category_checklist()');
99 99
 	global $link_id;
100
-	wp_link_category_checklist( $link_id );
100
+	wp_link_category_checklist($link_id);
101 101
 }
102 102
 
103 103
 /**
@@ -110,10 +110,10 @@  discard block
 block discarded – undo
110 110
  * @param string $file Filesystem path relative to the wp-content directory.
111 111
  * @return string Full filesystem path to edit.
112 112
  */
113
-function get_real_file_to_edit( $file ) {
114
-	_deprecated_function( __FUNCTION__, '2.9.0' );
113
+function get_real_file_to_edit($file) {
114
+	_deprecated_function(__FUNCTION__, '2.9.0');
115 115
 
116
-	return WP_CONTENT_DIR . $file;
116
+	return WP_CONTENT_DIR.$file;
117 117
 }
118 118
 
119 119
 /**
@@ -130,21 +130,21 @@  discard block
 block discarded – undo
130 130
  * @param array $categories  Optional. Categories to include in the control. Default 0.
131 131
  * @return bool|null False if no categories were found.
132 132
  */
133
-function wp_dropdown_cats( $currentcat = 0, $currentparent = 0, $parent = 0, $level = 0, $categories = 0 ) {
134
-	_deprecated_function( __FUNCTION__, '3.0.0', 'wp_dropdown_categories()' );
135
-	if (!$categories )
136
-		$categories = get_categories( array('hide_empty' => 0) );
133
+function wp_dropdown_cats($currentcat = 0, $currentparent = 0, $parent = 0, $level = 0, $categories = 0) {
134
+	_deprecated_function(__FUNCTION__, '3.0.0', 'wp_dropdown_categories()');
135
+	if ( ! $categories)
136
+		$categories = get_categories(array('hide_empty' => 0));
137 137
 
138
-	if ( $categories ) {
139
-		foreach ( $categories as $category ) {
140
-			if ( $currentcat != $category->term_id && $parent == $category->parent) {
141
-				$pad = str_repeat( '&#8211; ', $level );
142
-				$category->name = esc_html( $category->name );
138
+	if ($categories) {
139
+		foreach ($categories as $category) {
140
+			if ($currentcat != $category->term_id && $parent == $category->parent) {
141
+				$pad = str_repeat('&#8211; ', $level);
142
+				$category->name = esc_html($category->name);
143 143
 				echo "\n\t<option value='$category->term_id'";
144
-				if ( $currentparent == $category->term_id )
144
+				if ($currentparent == $category->term_id)
145 145
 					echo " selected='selected'";
146 146
 				echo ">$pad$category->name</option>";
147
-				wp_dropdown_cats( $currentcat, $currentparent, $category->term_id, $level +1, $categories );
147
+				wp_dropdown_cats($currentcat, $currentparent, $category->term_id, $level + 1, $categories);
148 148
 			}
149 149
 		}
150 150
 	} else {
@@ -164,9 +164,9 @@  discard block
 block discarded – undo
164 164
  * @param string $option_name The name of an option to sanitize and save.
165 165
  * @param callable $sanitize_callback A callback function that sanitizes the option's value.
166 166
  */
167
-function add_option_update_handler( $option_group, $option_name, $sanitize_callback = '' ) {
168
-	_deprecated_function( __FUNCTION__, '3.0.0', 'register_setting()' );
169
-	register_setting( $option_group, $option_name, $sanitize_callback );
167
+function add_option_update_handler($option_group, $option_name, $sanitize_callback = '') {
168
+	_deprecated_function(__FUNCTION__, '3.0.0', 'register_setting()');
169
+	register_setting($option_group, $option_name, $sanitize_callback);
170 170
 }
171 171
 
172 172
 /**
@@ -180,9 +180,9 @@  discard block
 block discarded – undo
180 180
  * @param string $option_name
181 181
  * @param callable $sanitize_callback
182 182
  */
183
-function remove_option_update_handler( $option_group, $option_name, $sanitize_callback = '' ) {
184
-	_deprecated_function( __FUNCTION__, '3.0.0', 'unregister_setting()' );
185
-	unregister_setting( $option_group, $option_name, $sanitize_callback );
183
+function remove_option_update_handler($option_group, $option_name, $sanitize_callback = '') {
184
+	_deprecated_function(__FUNCTION__, '3.0.0', 'unregister_setting()');
185
+	unregister_setting($option_group, $option_name, $sanitize_callback);
186 186
 }
187 187
 
188 188
 /**
@@ -193,8 +193,8 @@  discard block
 block discarded – undo
193 193
  *
194 194
  * @param string $filename
195 195
 **/
196
-function codepress_get_lang( $filename ) {
197
-	_deprecated_function( __FUNCTION__, '3.0.0' );
196
+function codepress_get_lang($filename) {
197
+	_deprecated_function(__FUNCTION__, '3.0.0');
198 198
 }
199 199
 
200 200
 /**
@@ -204,7 +204,7 @@  discard block
 block discarded – undo
204 204
  * @deprecated 3.0.0
205 205
 **/
206 206
 function codepress_footer_js() {
207
-	_deprecated_function( __FUNCTION__, '3.0.0' );
207
+	_deprecated_function(__FUNCTION__, '3.0.0');
208 208
 }
209 209
 
210 210
 /**
@@ -214,7 +214,7 @@  discard block
 block discarded – undo
214 214
  * @deprecated 3.0.0
215 215
 **/
216 216
 function use_codepress() {
217
-	_deprecated_function( __FUNCTION__, '3.0.0' );
217
+	_deprecated_function(__FUNCTION__, '3.0.0');
218 218
 }
219 219
 
220 220
 /**
@@ -225,15 +225,15 @@  discard block
 block discarded – undo
225 225
  * @return array List of user IDs.
226 226
  */
227 227
 function get_author_user_ids() {
228
-	_deprecated_function( __FUNCTION__, '3.1.0', 'get_users()' );
228
+	_deprecated_function(__FUNCTION__, '3.1.0', 'get_users()');
229 229
 
230 230
 	global $wpdb;
231
-	if ( !is_multisite() )
232
-		$level_key = $wpdb->get_blog_prefix() . 'user_level';
231
+	if ( ! is_multisite())
232
+		$level_key = $wpdb->get_blog_prefix().'user_level';
233 233
 	else
234
-		$level_key = $wpdb->get_blog_prefix() . 'capabilities'; // wpmu site admins don't have user_levels
234
+		$level_key = $wpdb->get_blog_prefix().'capabilities'; // wpmu site admins don't have user_levels
235 235
 
236
-	return $wpdb->get_col( $wpdb->prepare("SELECT user_id FROM $wpdb->usermeta WHERE meta_key = %s AND meta_value != '0'", $level_key) );
236
+	return $wpdb->get_col($wpdb->prepare("SELECT user_id FROM $wpdb->usermeta WHERE meta_key = %s AND meta_value != '0'", $level_key));
237 237
 }
238 238
 
239 239
 /**
@@ -244,18 +244,18 @@  discard block
 block discarded – undo
244 244
  * @param int $user_id User ID.
245 245
  * @return array|bool List of editable authors. False if no editable users.
246 246
  */
247
-function get_editable_authors( $user_id ) {
248
-	_deprecated_function( __FUNCTION__, '3.1.0', 'get_users()' );
247
+function get_editable_authors($user_id) {
248
+	_deprecated_function(__FUNCTION__, '3.1.0', 'get_users()');
249 249
 
250 250
 	global $wpdb;
251 251
 
252
-	$editable = get_editable_user_ids( $user_id );
252
+	$editable = get_editable_user_ids($user_id);
253 253
 
254
-	if ( !$editable ) {
254
+	if ( ! $editable) {
255 255
 		return false;
256 256
 	} else {
257 257
 		$editable = join(',', $editable);
258
-		$authors = $wpdb->get_results( "SELECT * FROM $wpdb->users WHERE ID IN ($editable) ORDER BY display_name" );
258
+		$authors = $wpdb->get_results("SELECT * FROM $wpdb->users WHERE ID IN ($editable) ORDER BY display_name");
259 259
 	}
260 260
 
261 261
 	return apply_filters('get_editable_authors', $authors);
@@ -270,32 +270,32 @@  discard block
 block discarded – undo
270 270
  * @param bool $exclude_zeros Optional. Whether to exclude zeroes. Default true.
271 271
  * @return array Array of editable user IDs, empty array otherwise.
272 272
  */
273
-function get_editable_user_ids( $user_id, $exclude_zeros = true, $post_type = 'post' ) {
274
-	_deprecated_function( __FUNCTION__, '3.1.0', 'get_users()' );
273
+function get_editable_user_ids($user_id, $exclude_zeros = true, $post_type = 'post') {
274
+	_deprecated_function(__FUNCTION__, '3.1.0', 'get_users()');
275 275
 
276 276
 	global $wpdb;
277 277
 
278
-	if ( ! $user = get_userdata( $user_id ) )
278
+	if ( ! $user = get_userdata($user_id))
279 279
 		return array();
280 280
 	$post_type_obj = get_post_type_object($post_type);
281 281
 
282
-	if ( ! $user->has_cap($post_type_obj->cap->edit_others_posts) ) {
283
-		if ( $user->has_cap($post_type_obj->cap->edit_posts) || ! $exclude_zeros )
282
+	if ( ! $user->has_cap($post_type_obj->cap->edit_others_posts)) {
283
+		if ($user->has_cap($post_type_obj->cap->edit_posts) || ! $exclude_zeros)
284 284
 			return array($user->ID);
285 285
 		else
286 286
 			return array();
287 287
 	}
288 288
 
289
-	if ( !is_multisite() )
290
-		$level_key = $wpdb->get_blog_prefix() . 'user_level';
289
+	if ( ! is_multisite())
290
+		$level_key = $wpdb->get_blog_prefix().'user_level';
291 291
 	else
292
-		$level_key = $wpdb->get_blog_prefix() . 'capabilities'; // wpmu site admins don't have user_levels
292
+		$level_key = $wpdb->get_blog_prefix().'capabilities'; // wpmu site admins don't have user_levels
293 293
 
294 294
 	$query = $wpdb->prepare("SELECT user_id FROM $wpdb->usermeta WHERE meta_key = %s", $level_key);
295
-	if ( $exclude_zeros )
295
+	if ($exclude_zeros)
296 296
 		$query .= " AND meta_value != '0'";
297 297
 
298
-	return $wpdb->get_col( $query );
298
+	return $wpdb->get_col($query);
299 299
 }
300 300
 
301 301
 /**
@@ -304,19 +304,19 @@  discard block
 block discarded – undo
304 304
  * @deprecated 3.1.0 Use get_users()
305 305
  */
306 306
 function get_nonauthor_user_ids() {
307
-	_deprecated_function( __FUNCTION__, '3.1.0', 'get_users()' );
307
+	_deprecated_function(__FUNCTION__, '3.1.0', 'get_users()');
308 308
 
309 309
 	global $wpdb;
310 310
 
311
-	if ( !is_multisite() )
312
-		$level_key = $wpdb->get_blog_prefix() . 'user_level';
311
+	if ( ! is_multisite())
312
+		$level_key = $wpdb->get_blog_prefix().'user_level';
313 313
 	else
314
-		$level_key = $wpdb->get_blog_prefix() . 'capabilities'; // wpmu site admins don't have user_levels
314
+		$level_key = $wpdb->get_blog_prefix().'capabilities'; // wpmu site admins don't have user_levels
315 315
 
316
-	return $wpdb->get_col( $wpdb->prepare("SELECT user_id FROM $wpdb->usermeta WHERE meta_key = %s AND meta_value = '0'", $level_key) );
316
+	return $wpdb->get_col($wpdb->prepare("SELECT user_id FROM $wpdb->usermeta WHERE meta_key = %s AND meta_value = '0'", $level_key));
317 317
 }
318 318
 
319
-if ( ! class_exists( 'WP_User_Search', false ) ) :
319
+if ( ! class_exists('WP_User_Search', false)) :
320 320
 /**
321 321
  * WordPress User Search class.
322 322
  *
@@ -479,12 +479,12 @@  discard block
 block discarded – undo
479 479
 	 * @param string $role Role name.
480 480
 	 * @return WP_User_Search
481 481
 	 */
482
-	function __construct( $search_term = '', $page = '', $role = '' ) {
483
-		_deprecated_function( __FUNCTION__, '3.1.0', 'WP_User_Query' );
482
+	function __construct($search_term = '', $page = '', $role = '') {
483
+		_deprecated_function(__FUNCTION__, '3.1.0', 'WP_User_Query');
484 484
 
485
-		$this->search_term = wp_unslash( $search_term );
486
-		$this->raw_page = ( '' == $page ) ? false : (int) $page;
487
-		$this->page = (int) ( '' == $page ) ? 1 : $page;
485
+		$this->search_term = wp_unslash($search_term);
486
+		$this->raw_page = ('' == $page) ? false : (int) $page;
487
+		$this->page = (int) ('' == $page) ? 1 : $page;
488 488
 		$this->role = $role;
489 489
 
490 490
 		$this->prepare_query();
@@ -502,8 +502,8 @@  discard block
 block discarded – undo
502 502
 	 * @param string $role Role name.
503 503
 	 * @return WP_User_Search
504 504
 	 */
505
-	public function WP_User_Search( $search_term = '', $page = '', $role = '' ) {
506
-		self::__construct( $search_term, $page, $role );
505
+	public function WP_User_Search($search_term = '', $page = '', $role = '') {
506
+		self::__construct($search_term, $page, $role);
507 507
 	}
508 508
 
509 509
 	/**
@@ -520,11 +520,11 @@  discard block
 block discarded – undo
520 520
 		$this->query_orderby = ' ORDER BY user_login';
521 521
 
522 522
 		$search_sql = '';
523
-		if ( $this->search_term ) {
523
+		if ($this->search_term) {
524 524
 			$searches = array();
525 525
 			$search_sql = 'AND (';
526
-			foreach ( array('user_login', 'user_nicename', 'user_email', 'user_url', 'display_name') as $col )
527
-				$searches[] = $wpdb->prepare( $col . ' LIKE %s', '%' . like_escape($this->search_term) . '%' );
526
+			foreach (array('user_login', 'user_nicename', 'user_email', 'user_url', 'display_name') as $col)
527
+				$searches[] = $wpdb->prepare($col.' LIKE %s', '%'.like_escape($this->search_term).'%');
528 528
 			$search_sql .= implode(' OR ', $searches);
529 529
 			$search_sql .= ')';
530 530
 		}
@@ -532,16 +532,16 @@  discard block
 block discarded – undo
532 532
 		$this->query_from = " FROM $wpdb->users";
533 533
 		$this->query_where = " WHERE 1=1 $search_sql";
534 534
 
535
-		if ( $this->role ) {
535
+		if ($this->role) {
536 536
 			$this->query_from .= " INNER JOIN $wpdb->usermeta ON $wpdb->users.ID = $wpdb->usermeta.user_id";
537
-			$this->query_where .= $wpdb->prepare(" AND $wpdb->usermeta.meta_key = '{$wpdb->prefix}capabilities' AND $wpdb->usermeta.meta_value LIKE %s", '%' . $this->role . '%');
538
-		} elseif ( is_multisite() ) {
539
-			$level_key = $wpdb->prefix . 'capabilities'; // wpmu site admins don't have user_levels
537
+			$this->query_where .= $wpdb->prepare(" AND $wpdb->usermeta.meta_key = '{$wpdb->prefix}capabilities' AND $wpdb->usermeta.meta_value LIKE %s", '%'.$this->role.'%');
538
+		} elseif (is_multisite()) {
539
+			$level_key = $wpdb->prefix.'capabilities'; // wpmu site admins don't have user_levels
540 540
 			$this->query_from .= ", $wpdb->usermeta";
541 541
 			$this->query_where .= " AND $wpdb->users.ID = $wpdb->usermeta.user_id AND meta_key = '{$level_key}'";
542 542
 		}
543 543
 
544
-		do_action_ref_array( 'pre_user_search', array( &$this ) );
544
+		do_action_ref_array('pre_user_search', array(&$this));
545 545
 	}
546 546
 
547 547
 	/**
@@ -553,10 +553,10 @@  discard block
 block discarded – undo
553 553
 	public function query() {
554 554
 		global $wpdb;
555 555
 
556
-		$this->results = $wpdb->get_col("SELECT DISTINCT($wpdb->users.ID)" . $this->query_from . $this->query_where . $this->query_orderby . $this->query_limit);
556
+		$this->results = $wpdb->get_col("SELECT DISTINCT($wpdb->users.ID)".$this->query_from.$this->query_where.$this->query_orderby.$this->query_limit);
557 557
 
558
-		if ( $this->results )
559
-			$this->total_users_for_query = $wpdb->get_var("SELECT COUNT(DISTINCT($wpdb->users.ID))" . $this->query_from . $this->query_where); // no limit
558
+		if ($this->results)
559
+			$this->total_users_for_query = $wpdb->get_var("SELECT COUNT(DISTINCT($wpdb->users.ID))".$this->query_from.$this->query_where); // no limit
560 560
 		else
561 561
 			$this->search_errors = new WP_Error('no_matching_users_found', __('No users found.'));
562 562
 	}
@@ -576,25 +576,25 @@  discard block
 block discarded – undo
576 576
 	 * @access public
577 577
 	 */
578 578
 	public function do_paging() {
579
-		if ( $this->total_users_for_query > $this->users_per_page ) { // have to page the results
579
+		if ($this->total_users_for_query > $this->users_per_page) { // have to page the results
580 580
 			$args = array();
581
-			if ( ! empty($this->search_term) )
581
+			if ( ! empty($this->search_term))
582 582
 				$args['usersearch'] = urlencode($this->search_term);
583
-			if ( ! empty($this->role) )
583
+			if ( ! empty($this->role))
584 584
 				$args['role'] = urlencode($this->role);
585 585
 
586
-			$this->paging_text = paginate_links( array(
586
+			$this->paging_text = paginate_links(array(
587 587
 				'total' => ceil($this->total_users_for_query / $this->users_per_page),
588 588
 				'current' => $this->page,
589 589
 				'base' => 'users.php?%_%',
590 590
 				'format' => 'userspage=%#%',
591 591
 				'add_args' => $args
592
-			) );
593
-			if ( $this->paging_text ) {
594
-				$this->paging_text = sprintf( '<span class="displaying-num">' . __( 'Displaying %s&#8211;%s of %s' ) . '</span>%s',
595
-					number_format_i18n( ( $this->page - 1 ) * $this->users_per_page + 1 ),
596
-					number_format_i18n( min( $this->page * $this->users_per_page, $this->total_users_for_query ) ),
597
-					number_format_i18n( $this->total_users_for_query ),
592
+			));
593
+			if ($this->paging_text) {
594
+				$this->paging_text = sprintf('<span class="displaying-num">'.__('Displaying %s&#8211;%s of %s').'</span>%s',
595
+					number_format_i18n(($this->page - 1) * $this->users_per_page + 1),
596
+					number_format_i18n(min($this->page * $this->users_per_page, $this->total_users_for_query)),
597
+					number_format_i18n($this->total_users_for_query),
598 598
 					$this->paging_text
599 599
 				);
600 600
 			}
@@ -636,7 +636,7 @@  discard block
 block discarded – undo
636 636
 	 * @return bool
637 637
 	 */
638 638
 	function results_are_paged() {
639
-		if ( $this->paging_text )
639
+		if ($this->paging_text)
640 640
 			return true;
641 641
 		return false;
642 642
 	}
@@ -650,7 +650,7 @@  discard block
 block discarded – undo
650 650
 	 * @return bool
651 651
 	 */
652 652
 	function is_search() {
653
-		if ( $this->search_term )
653
+		if ($this->search_term)
654 654
 			return true;
655 655
 		return false;
656 656
 	}
@@ -669,25 +669,25 @@  discard block
 block discarded – undo
669 669
  *                        Default 'any'.
670 670
  * @return array List of posts from others.
671 671
  */
672
-function get_others_unpublished_posts( $user_id, $type = 'any' ) {
673
-	_deprecated_function( __FUNCTION__, '3.1.0' );
672
+function get_others_unpublished_posts($user_id, $type = 'any') {
673
+	_deprecated_function(__FUNCTION__, '3.1.0');
674 674
 
675 675
 	global $wpdb;
676 676
 
677
-	$editable = get_editable_user_ids( $user_id );
677
+	$editable = get_editable_user_ids($user_id);
678 678
 
679
-	if ( in_array($type, array('draft', 'pending')) )
679
+	if (in_array($type, array('draft', 'pending')))
680 680
 		$type_sql = " post_status = '$type' ";
681 681
 	else
682 682
 		$type_sql = " ( post_status = 'draft' OR post_status = 'pending' ) ";
683 683
 
684
-	$dir = ( 'pending' == $type ) ? 'ASC' : 'DESC';
684
+	$dir = ('pending' == $type) ? 'ASC' : 'DESC';
685 685
 
686
-	if ( !$editable ) {
686
+	if ( ! $editable) {
687 687
 		$other_unpubs = '';
688 688
 	} else {
689 689
 		$editable = join(',', $editable);
690
-		$other_unpubs = $wpdb->get_results( $wpdb->prepare("SELECT ID, post_title, post_author FROM $wpdb->posts WHERE post_type = 'post' AND $type_sql AND post_author IN ($editable) AND post_author != %d ORDER BY post_modified $dir", $user_id) );
690
+		$other_unpubs = $wpdb->get_results($wpdb->prepare("SELECT ID, post_title, post_author FROM $wpdb->posts WHERE post_type = 'post' AND $type_sql AND post_author IN ($editable) AND post_author != %d ORDER BY post_modified $dir", $user_id));
691 691
 	}
692 692
 
693 693
 	return apply_filters('get_others_drafts', $other_unpubs);
@@ -703,7 +703,7 @@  discard block
 block discarded – undo
703 703
  * @return array List of drafts from other users.
704 704
  */
705 705
 function get_others_drafts($user_id) {
706
-	_deprecated_function( __FUNCTION__, '3.1.0' );
706
+	_deprecated_function(__FUNCTION__, '3.1.0');
707 707
 
708 708
 	return get_others_unpublished_posts($user_id, 'draft');
709 709
 }
@@ -718,7 +718,7 @@  discard block
 block discarded – undo
718 718
  * @return array List of posts with pending review post type from other users.
719 719
  */
720 720
 function get_others_pending($user_id) {
721
-	_deprecated_function( __FUNCTION__, '3.1.0' );
721
+	_deprecated_function(__FUNCTION__, '3.1.0');
722 722
 
723 723
 	return get_others_unpublished_posts($user_id, 'pending');
724 724
 }
@@ -731,7 +731,7 @@  discard block
 block discarded – undo
731 731
  * @see wp_dashboard_quick_press()
732 732
  */
733 733
 function wp_dashboard_quick_press_output() {
734
-	_deprecated_function( __FUNCTION__, '3.2.0', 'wp_dashboard_quick_press()' );
734
+	_deprecated_function(__FUNCTION__, '3.2.0', 'wp_dashboard_quick_press()');
735 735
 	wp_dashboard_quick_press();
736 736
 }
737 737
 
@@ -744,15 +744,15 @@  discard block
 block discarded – undo
744 744
  *
745 745
  * @staticvar int $num
746 746
  */
747
-function wp_tiny_mce( $teeny = false, $settings = false ) {
748
-	_deprecated_function( __FUNCTION__, '3.3.0', 'wp_editor()' );
747
+function wp_tiny_mce($teeny = false, $settings = false) {
748
+	_deprecated_function(__FUNCTION__, '3.3.0', 'wp_editor()');
749 749
 
750 750
 	static $num = 1;
751 751
 
752
-	if ( ! class_exists( '_WP_Editors', false ) )
753
-		require_once( ABSPATH . WPINC . '/class-wp-editor.php' );
752
+	if ( ! class_exists('_WP_Editors', false))
753
+		require_once(ABSPATH.WPINC.'/class-wp-editor.php');
754 754
 
755
-	$editor_id = 'content' . $num++;
755
+	$editor_id = 'content'.$num++;
756 756
 
757 757
 	$set = array(
758 758
 		'teeny' => $teeny,
@@ -771,7 +771,7 @@  discard block
 block discarded – undo
771 771
  * @see wp_editor()
772 772
  */
773 773
 function wp_preload_dialogs() {
774
-	_deprecated_function( __FUNCTION__, '3.3.0', 'wp_editor()' );
774
+	_deprecated_function(__FUNCTION__, '3.3.0', 'wp_editor()');
775 775
 }
776 776
 
777 777
 /**
@@ -781,7 +781,7 @@  discard block
 block discarded – undo
781 781
  * @see wp_editor()
782 782
  */
783 783
 function wp_print_editor_js() {
784
-	_deprecated_function( __FUNCTION__, '3.3.0', 'wp_editor()' );
784
+	_deprecated_function(__FUNCTION__, '3.3.0', 'wp_editor()');
785 785
 }
786 786
 
787 787
 /**
@@ -791,7 +791,7 @@  discard block
 block discarded – undo
791 791
  * @see wp_editor()
792 792
  */
793 793
 function wp_quicktags() {
794
-	_deprecated_function( __FUNCTION__, '3.3.0', 'wp_editor()' );
794
+	_deprecated_function(__FUNCTION__, '3.3.0', 'wp_editor()');
795 795
 }
796 796
 
797 797
 /**
@@ -801,12 +801,12 @@  discard block
 block discarded – undo
801 801
  * @deprecated 3.3.0 WP_Screen::render_screen_layout()
802 802
  * @see WP_Screen::render_screen_layout()
803 803
  */
804
-function screen_layout( $screen ) {
805
-	_deprecated_function( __FUNCTION__, '3.3.0', '$current_screen->render_screen_layout()' );
804
+function screen_layout($screen) {
805
+	_deprecated_function(__FUNCTION__, '3.3.0', '$current_screen->render_screen_layout()');
806 806
 
807 807
 	$current_screen = get_current_screen();
808 808
 
809
-	if ( ! $current_screen )
809
+	if ( ! $current_screen)
810 810
 		return '';
811 811
 
812 812
 	ob_start();
@@ -821,12 +821,12 @@  discard block
 block discarded – undo
821 821
  * @deprecated 3.3.0 Use WP_Screen::render_per_page_options()
822 822
  * @see WP_Screen::render_per_page_options()
823 823
  */
824
-function screen_options( $screen ) {
825
-	_deprecated_function( __FUNCTION__, '3.3.0', '$current_screen->render_per_page_options()' );
824
+function screen_options($screen) {
825
+	_deprecated_function(__FUNCTION__, '3.3.0', '$current_screen->render_per_page_options()');
826 826
 
827 827
 	$current_screen = get_current_screen();
828 828
 
829
-	if ( ! $current_screen )
829
+	if ( ! $current_screen)
830 830
 		return '';
831 831
 
832 832
 	ob_start();
@@ -841,7 +841,7 @@  discard block
 block discarded – undo
841 841
  * @deprecated 3.3.0 Use WP_Screen::render_screen_meta()
842 842
  * @see WP_Screen::render_screen_meta()
843 843
  */
844
-function screen_meta( $screen ) {
844
+function screen_meta($screen) {
845 845
 	$current_screen = get_current_screen();
846 846
 	$current_screen->render_screen_meta();
847 847
 }
@@ -854,7 +854,7 @@  discard block
 block discarded – undo
854 854
  * @see WP_Admin_Bar
855 855
  */
856 856
 function favorite_actions() {
857
-	_deprecated_function( __FUNCTION__, '3.2.0', 'WP_Admin_Bar' );
857
+	_deprecated_function(__FUNCTION__, '3.2.0', 'WP_Admin_Bar');
858 858
 }
859 859
 
860 860
 /**
@@ -866,7 +866,7 @@  discard block
 block discarded – undo
866 866
  * @return null|string
867 867
  */
868 868
 function media_upload_image() {
869
-	_deprecated_function( __FUNCTION__, '3.3.0', 'wp_media_upload_handler()' );
869
+	_deprecated_function(__FUNCTION__, '3.3.0', 'wp_media_upload_handler()');
870 870
 	return wp_media_upload_handler();
871 871
 }
872 872
 
@@ -879,7 +879,7 @@  discard block
 block discarded – undo
879 879
  * @return null|string
880 880
  */
881 881
 function media_upload_audio() {
882
-	_deprecated_function( __FUNCTION__, '3.3.0', 'wp_media_upload_handler()' );
882
+	_deprecated_function(__FUNCTION__, '3.3.0', 'wp_media_upload_handler()');
883 883
 	return wp_media_upload_handler();
884 884
 }
885 885
 
@@ -892,7 +892,7 @@  discard block
 block discarded – undo
892 892
  * @return null|string
893 893
  */
894 894
 function media_upload_video() {
895
-	_deprecated_function( __FUNCTION__, '3.3.0', 'wp_media_upload_handler()' );
895
+	_deprecated_function(__FUNCTION__, '3.3.0', 'wp_media_upload_handler()');
896 896
 	return wp_media_upload_handler();
897 897
 }
898 898
 
@@ -905,7 +905,7 @@  discard block
 block discarded – undo
905 905
  * @return null|string
906 906
  */
907 907
 function media_upload_file() {
908
-	_deprecated_function( __FUNCTION__, '3.3.0', 'wp_media_upload_handler()' );
908
+	_deprecated_function(__FUNCTION__, '3.3.0', 'wp_media_upload_handler()');
909 909
 	return wp_media_upload_handler();
910 910
 }
911 911
 
@@ -918,8 +918,8 @@  discard block
 block discarded – undo
918 918
  * @return string
919 919
  */
920 920
 function type_url_form_image() {
921
-	_deprecated_function( __FUNCTION__, '3.3.0', "wp_media_insert_url_form('image')" );
922
-	return wp_media_insert_url_form( 'image' );
921
+	_deprecated_function(__FUNCTION__, '3.3.0', "wp_media_insert_url_form('image')");
922
+	return wp_media_insert_url_form('image');
923 923
 }
924 924
 
925 925
 /**
@@ -931,8 +931,8 @@  discard block
 block discarded – undo
931 931
  * @return string
932 932
  */
933 933
 function type_url_form_audio() {
934
-	_deprecated_function( __FUNCTION__, '3.3.0', "wp_media_insert_url_form('audio')" );
935
-	return wp_media_insert_url_form( 'audio' );
934
+	_deprecated_function(__FUNCTION__, '3.3.0', "wp_media_insert_url_form('audio')");
935
+	return wp_media_insert_url_form('audio');
936 936
 }
937 937
 
938 938
 /**
@@ -944,8 +944,8 @@  discard block
 block discarded – undo
944 944
  * @return string
945 945
  */
946 946
 function type_url_form_video() {
947
-	_deprecated_function( __FUNCTION__, '3.3.0', "wp_media_insert_url_form('video')" );
948
-	return wp_media_insert_url_form( 'video' );
947
+	_deprecated_function(__FUNCTION__, '3.3.0', "wp_media_insert_url_form('video')");
948
+	return wp_media_insert_url_form('video');
949 949
 }
950 950
 
951 951
 /**
@@ -957,8 +957,8 @@  discard block
 block discarded – undo
957 957
  * @return string
958 958
  */
959 959
 function type_url_form_file() {
960
-	_deprecated_function( __FUNCTION__, '3.3.0', "wp_media_insert_url_form('file')" );
961
-	return wp_media_insert_url_form( 'file' );
960
+	_deprecated_function(__FUNCTION__, '3.3.0', "wp_media_insert_url_form('file')");
961
+	return wp_media_insert_url_form('file');
962 962
 }
963 963
 
964 964
 /**
@@ -973,13 +973,13 @@  discard block
 block discarded – undo
973 973
  * @param string    $screen The handle for the screen to add help to. This is usually the hook name returned by the add_*_page() functions.
974 974
  * @param string    $help   The content of an 'Overview' help tab.
975 975
  */
976
-function add_contextual_help( $screen, $help ) {
977
-	_deprecated_function( __FUNCTION__, '3.3.0', 'get_current_screen()->add_help_tab()' );
976
+function add_contextual_help($screen, $help) {
977
+	_deprecated_function(__FUNCTION__, '3.3.0', 'get_current_screen()->add_help_tab()');
978 978
 
979
-	if ( is_string( $screen ) )
980
-		$screen = convert_to_screen( $screen );
979
+	if (is_string($screen))
980
+		$screen = convert_to_screen($screen);
981 981
 
982
-	WP_Screen::add_old_compat_help( $screen, $help );
982
+	WP_Screen::add_old_compat_help($screen, $help);
983 983
 }
984 984
 
985 985
 /**
@@ -992,13 +992,13 @@  discard block
 block discarded – undo
992 992
  * @return array $themes Array of allowed themes.
993 993
  */
994 994
 function get_allowed_themes() {
995
-	_deprecated_function( __FUNCTION__, '3.4.0', "wp_get_themes( array( 'allowed' => true ) )" );
995
+	_deprecated_function(__FUNCTION__, '3.4.0', "wp_get_themes( array( 'allowed' => true ) )");
996 996
 
997
-	$themes = wp_get_themes( array( 'allowed' => true ) );
997
+	$themes = wp_get_themes(array('allowed' => true));
998 998
 
999 999
 	$wp_themes = array();
1000
-	foreach ( $themes as $theme ) {
1001
-		$wp_themes[ $theme->get('Name') ] = $theme;
1000
+	foreach ($themes as $theme) {
1001
+		$wp_themes[$theme->get('Name')] = $theme;
1002 1002
 	}
1003 1003
 
1004 1004
 	return $wp_themes;
@@ -1014,13 +1014,13 @@  discard block
 block discarded – undo
1014 1014
  * @return array
1015 1015
  */
1016 1016
 function get_broken_themes() {
1017
-	_deprecated_function( __FUNCTION__, '3.4.0', "wp_get_themes( array( 'errors' => true )" );
1017
+	_deprecated_function(__FUNCTION__, '3.4.0', "wp_get_themes( array( 'errors' => true )");
1018 1018
 
1019
-	$themes = wp_get_themes( array( 'errors' => true ) );
1019
+	$themes = wp_get_themes(array('errors' => true));
1020 1020
 	$broken = array();
1021
-	foreach ( $themes as $theme ) {
1021
+	foreach ($themes as $theme) {
1022 1022
 		$name = $theme->get('Name');
1023
-		$broken[ $name ] = array(
1023
+		$broken[$name] = array(
1024 1024
 			'Name' => $name,
1025 1025
 			'Title' => $name,
1026 1026
 			'Description' => $theme->errors()->get_error_message(),
@@ -1039,7 +1039,7 @@  discard block
 block discarded – undo
1039 1039
  * @return WP_Theme
1040 1040
  */
1041 1041
 function current_theme_info() {
1042
-	_deprecated_function( __FUNCTION__, '3.4.0', 'wp_get_theme()' );
1042
+	_deprecated_function(__FUNCTION__, '3.4.0', 'wp_get_theme()');
1043 1043
 
1044 1044
 	return wp_get_theme();
1045 1045
 }
@@ -1051,8 +1051,8 @@  discard block
 block discarded – undo
1051 1051
  *
1052 1052
  * @deprecated 3.5.0
1053 1053
  */
1054
-function _insert_into_post_button( $type ) {
1055
-	_deprecated_function( __FUNCTION__, '3.5.0' );
1054
+function _insert_into_post_button($type) {
1055
+	_deprecated_function(__FUNCTION__, '3.5.0');
1056 1056
 }
1057 1057
 
1058 1058
 /**
@@ -1063,7 +1063,7 @@  discard block
 block discarded – undo
1063 1063
  * @deprecated 3.5.0
1064 1064
  */
1065 1065
 function _media_button($title, $icon, $type, $id) {
1066
-	_deprecated_function( __FUNCTION__, '3.5.0' );
1066
+	_deprecated_function(__FUNCTION__, '3.5.0');
1067 1067
 }
1068 1068
 
1069 1069
 /**
@@ -1076,10 +1076,10 @@  discard block
 block discarded – undo
1076 1076
  * @param int $id
1077 1077
  * @return object
1078 1078
  */
1079
-function get_post_to_edit( $id ) {
1080
-	_deprecated_function( __FUNCTION__, '3.5.0', 'get_post()' );
1079
+function get_post_to_edit($id) {
1080
+	_deprecated_function(__FUNCTION__, '3.5.0', 'get_post()');
1081 1081
 
1082
-	return get_post( $id, OBJECT, 'edit' );
1082
+	return get_post($id, OBJECT, 'edit');
1083 1083
 }
1084 1084
 
1085 1085
 /**
@@ -1092,7 +1092,7 @@  discard block
 block discarded – undo
1092 1092
  * @return WP_Post Post object containing all the default post data as attributes
1093 1093
  */
1094 1094
 function get_default_page_to_edit() {
1095
-	_deprecated_function( __FUNCTION__, '3.5.0', "get_default_post_to_edit( 'page' )" );
1095
+	_deprecated_function(__FUNCTION__, '3.5.0', "get_default_post_to_edit( 'page' )");
1096 1096
 
1097 1097
 	$page = get_default_post_to_edit();
1098 1098
 	$page->post_type = 'page';
@@ -1111,9 +1111,9 @@  discard block
 block discarded – undo
1111 1111
  * @param mixed $deprecated Never used.
1112 1112
  * @return string Thumbnail path on success, Error string on failure.
1113 1113
  */
1114
-function wp_create_thumbnail( $file, $max_side, $deprecated = '' ) {
1115
-	_deprecated_function( __FUNCTION__, '3.5.0', 'image_resize()' );
1116
-	return apply_filters( 'wp_create_thumbnail', image_resize( $file, $max_side, $max_side ) );
1114
+function wp_create_thumbnail($file, $max_side, $deprecated = '') {
1115
+	_deprecated_function(__FUNCTION__, '3.5.0', 'image_resize()');
1116
+	return apply_filters('wp_create_thumbnail', image_resize($file, $max_side, $max_side));
1117 1117
 }
1118 1118
 
1119 1119
 /**
@@ -1125,7 +1125,7 @@  discard block
 block discarded – undo
1125 1125
  * @deprecated 3.6.0
1126 1126
  */
1127 1127
 function wp_nav_menu_locations_meta_box() {
1128
-	_deprecated_function( __FUNCTION__, '3.6.0' );
1128
+	_deprecated_function(__FUNCTION__, '3.6.0');
1129 1129
 }
1130 1130
 
1131 1131
 /**
@@ -1139,12 +1139,12 @@  discard block
 block discarded – undo
1139 1139
  * @see Core_Upgrader
1140 1140
  */
1141 1141
 function wp_update_core($current, $feedback = '') {
1142
-	_deprecated_function( __FUNCTION__, '3.7.0', 'new Core_Upgrader();' );
1142
+	_deprecated_function(__FUNCTION__, '3.7.0', 'new Core_Upgrader();');
1143 1143
 
1144
-	if ( !empty($feedback) )
1144
+	if ( ! empty($feedback))
1145 1145
 		add_filter('update_feedback', $feedback);
1146 1146
 
1147
-	include( ABSPATH . 'wp-admin/includes/class-wp-upgrader.php' );
1147
+	include(ABSPATH.'wp-admin/includes/class-wp-upgrader.php');
1148 1148
 	$upgrader = new Core_Upgrader();
1149 1149
 	return $upgrader->upgrade($current);
1150 1150
 
@@ -1162,12 +1162,12 @@  discard block
 block discarded – undo
1162 1162
  * @see Plugin_Upgrader
1163 1163
  */
1164 1164
 function wp_update_plugin($plugin, $feedback = '') {
1165
-	_deprecated_function( __FUNCTION__, '3.7.0', 'new Plugin_Upgrader();' );
1165
+	_deprecated_function(__FUNCTION__, '3.7.0', 'new Plugin_Upgrader();');
1166 1166
 
1167
-	if ( !empty($feedback) )
1167
+	if ( ! empty($feedback))
1168 1168
 		add_filter('update_feedback', $feedback);
1169 1169
 
1170
-	include( ABSPATH . 'wp-admin/includes/class-wp-upgrader.php' );
1170
+	include(ABSPATH.'wp-admin/includes/class-wp-upgrader.php');
1171 1171
 	$upgrader = new Plugin_Upgrader();
1172 1172
 	return $upgrader->upgrade($plugin);
1173 1173
 }
@@ -1184,12 +1184,12 @@  discard block
 block discarded – undo
1184 1184
  * @see Theme_Upgrader
1185 1185
  */
1186 1186
 function wp_update_theme($theme, $feedback = '') {
1187
-	_deprecated_function( __FUNCTION__, '3.7.0', 'new Theme_Upgrader();' );
1187
+	_deprecated_function(__FUNCTION__, '3.7.0', 'new Theme_Upgrader();');
1188 1188
 
1189
-	if ( !empty($feedback) )
1189
+	if ( ! empty($feedback))
1190 1190
 		add_filter('update_feedback', $feedback);
1191 1191
 
1192
-	include( ABSPATH . 'wp-admin/includes/class-wp-upgrader.php' );
1192
+	include(ABSPATH.'wp-admin/includes/class-wp-upgrader.php');
1193 1193
 	$upgrader = new Theme_Upgrader();
1194 1194
 	return $upgrader->upgrade($theme);
1195 1195
 }
@@ -1202,8 +1202,8 @@  discard block
 block discarded – undo
1202 1202
  *
1203 1203
  * @param int|bool $id
1204 1204
  */
1205
-function the_attachment_links( $id = false ) {
1206
-	_deprecated_function( __FUNCTION__, '3.7.0' );
1205
+function the_attachment_links($id = false) {
1206
+	_deprecated_function(__FUNCTION__, '3.7.0');
1207 1207
 }
1208 1208
 
1209 1209
 /**
@@ -1304,8 +1304,8 @@  discard block
 block discarded – undo
1304 1304
  * @param int $old_ID
1305 1305
  * @param int $new_ID
1306 1306
  */
1307
-function _relocate_children( $old_ID, $new_ID ) {
1308
-	_deprecated_function( __FUNCTION__, '3.9.0' );
1307
+function _relocate_children($old_ID, $new_ID) {
1308
+	_deprecated_function(__FUNCTION__, '3.9.0');
1309 1309
 }
1310 1310
 
1311 1311
 /**
@@ -1331,8 +1331,8 @@  discard block
 block discarded – undo
1331 1331
  * @param string   $icon_url   The url to the icon to be used for this menu.
1332 1332
  * @return string The resulting page's hook_suffix.
1333 1333
  */
1334
-function add_object_page( $page_title, $menu_title, $capability, $menu_slug, $function = '', $icon_url = '') {
1335
-	_deprecated_function( __FUNCTION__, '4.5.0', 'add_menu_page()' );
1334
+function add_object_page($page_title, $menu_title, $capability, $menu_slug, $function = '', $icon_url = '') {
1335
+	_deprecated_function(__FUNCTION__, '4.5.0', 'add_menu_page()');
1336 1336
 
1337 1337
 	global $_wp_last_object_menu;
1338 1338
 
@@ -1364,8 +1364,8 @@  discard block
 block discarded – undo
1364 1364
  * @param string   $icon_url   The url to the icon to be used for this menu.
1365 1365
  * @return string The resulting page's hook_suffix.
1366 1366
  */
1367
-function add_utility_page( $page_title, $menu_title, $capability, $menu_slug, $function = '', $icon_url = '') {
1368
-	_deprecated_function( __FUNCTION__, '4.5.0', 'add_menu_page()' );
1367
+function add_utility_page($page_title, $menu_title, $capability, $menu_slug, $function = '', $icon_url = '') {
1368
+	_deprecated_function(__FUNCTION__, '4.5.0', 'add_menu_page()');
1369 1369
 
1370 1370
 	global $_wp_last_utility_menu;
1371 1371
 
@@ -1390,9 +1390,9 @@  discard block
 block discarded – undo
1390 1390
 function post_form_autocomplete_off() {
1391 1391
 	global $is_safari, $is_chrome;
1392 1392
 
1393
-	_deprecated_function( __FUNCTION__, '4.6.0' );
1393
+	_deprecated_function(__FUNCTION__, '4.6.0');
1394 1394
 
1395
-	if ( $is_safari || $is_chrome ) {
1395
+	if ($is_safari || $is_chrome) {
1396 1396
 		echo ' autocomplete="off"';
1397 1397
 	}
1398 1398
 }
Please login to merge, or discard this patch.